Comments (16)
Solved in v0.2.0, please install it manually :)
from hotelier.
Hi, thanks for opening the issue! Yes, I had this in mind. Not sure what is the path on Windows, so this would need to be checked as well.
If you manage to look into it first, i'd be very glad for the PR!
from hotelier.
I know in the Windows environment, at least from Command Prompt, the path is like this:
%HOMEPATH%\.hotel\conf.json
Windows wraps its environment vars in %
.
I'll see when I can open a PR. May not be until the weekend, but I'll try to get one open.
from hotelier.
Some notes, especially for me. This will be my first time actually contributing to a Node-based project.
- Getting the home path
path.join
path.normalize
- Start in
api.js
from hotelier.
@macav I noticed in src/api.js:22
that an empty string is returned during development. May I ask why? Asking as someone who doesn't have much Node or Electron experience.
Also, after reading the code more closely, does this app use SSR? If not, I would be confused about how you have access to process.env
client-side. But since the src/api.js
file does have access to that, maybe I did add my code in the right location.
from hotelier.
Yes, this is due to the fact that I had problems with CORS and Hotel. There's a reverse proxy set up, so that all the request in development to the same origin go to localhost:2000
- https://github.com/macav/hotelier/blob/master/package.json#L35
It's not really SSR, but there's electron which is running in the background and react app which is the client. you should have access to process.env
from anywhere. One thing maybe would help, there's a file which makes some electron API accessible to the client, so that electron & react app can communicate via ipcRenderer
... this is used for example to open the URL of the hotel server: https://github.com/macav/hotelier/blob/master/public/preload.js
And yes, the tests would be nice :)
Hopefully this helps you a bit.
from hotelier.
Ok. Will look at that file then. Thanks!
from hotelier.
Just letting you know I haven't given up yet. It's just taking me a while to digest everything.
For the most part, I can tell what's going on in electron.js
. and I get that I can use the Node API from within preload.js
. I still need to learn how to use the ipcMain
and ipcRenderer
objects, but I think I'm getting there.
from hotelier.
@macav may I ask what part this app is considered part of the "renderer" process?
This is where I'm stuck. I keep coming across information saying I should be able to import Node and Electron modules (such as fs
and ipcRenderer
) inside of the renderer process. But trying to import ipcRenderer
from Electron results in the following error:
TypeError: fs.existsSync is not a function
(anonymous function)
<path/to/projects/dir>/hotelier/node_modules/electron/index.js:6
3 |
4 | var pathFile = path.join(__dirname, 'path.txt')
5 |
> 6 | if (fs.existsSync(pathFile)) {
7 | module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8'))
8 | } else {
9 | throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
So it's trying to import the Electron module, but it's not able to use the fs
module, even when I try to import it before importing Electron.
I've tried using both require
and import
syntaxes with the same issue.
Current example in src/util.js
Other files tried in:
Those last 2 files don't currently have code like what's in util.js
. That's just where I've tried to import ipcRenderer
from Electron.
from hotelier.
Hey there.. I think what you're looking for is located here: https://github.com/JSn1nj4/hotelier/blob/feature/read-custom-hotel-port/public/preload.js#L12
You correctly set the hotel port there and you should bind ipcRenderer
to window
just like it's done for shell
. The util.js
file is used from the react app and this has no access to the node API
from hotelier.
Ok. So then the React app doesn't have direct access to the renderer. But wouldn't the port value need to be accessible to the React app, for instance, in the src/api.js
file?
from hotelier.
no, directly no. Yes, it would be needed for the API, but you can bind the port to window
and read it from there. Again, the shell
example can be useful here. It's bound in preload.js
and then used in https://github.com/macav/hotelier/blob/master/src/utils.js#L10.
from hotelier.
@macav I keep getting undefined
though when I try to read it from there. Same for ipcRenderer
.
If I could read the hotel port directly from the window, I wouldn't need ipcRenderer
, but both of those (when attached to window
via the preload script) are undefined
within the React app. I've also confirmed this by console.log(window)
within the React app and manually inspecting the logged Window object, just in case I was missing something.
From the examples I've looked at, I think this has to do with the React app not having access to the renderer. My understanding is that attaching values to the window
object that way gives the renderer access to those values.
I'm going to see if there's another way to handle it (maybe exposing a rest API endpoint for the React app to call, if that's possible with Electron).
from hotelier.
I'm sorry to say that I think I need to give this up. I've spent a good deal of time trying to find a workaround, but I think I'm too green to work this deep in an Electron project.
Thanks for the pointers though. I have definitely learned a bit by fiddling with this project.
from hotelier.
@JSn1nj4 Thanks for your help anyway! Could you please open a WIP PR with what you have? Maybe it will be useful and i could continue from that..
from hotelier.
@macav sure. I can't do it right this minute, but I'll make sure to do it the first chance I get.
from hotelier.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hotelier.