Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/implement ws #5

Merged

Conversation

viralgupta
Copy link
Contributor

@viralgupta viralgupta commented Jun 22, 2024

Hi @shalithasuranga sir, I have several questions regarding this PR. Please bear with me 😅

  • For the URL parameter when initializing the class, should the user provide the path to the app (i.e., the path to the neutralinojs.config.json file) or the path to the index.html file?
  • Currently, I am building the package based on the first method, but it has a few issues:
    1. We are assuming that the binaries will be located in the bin folder inside the root folder (i.e., "{url}/bin${path.sep}${binaryName}").
    2. If we proceed with this method, we will not be able to support apps with frontend libraries since it does not contain the logic to run the frontend app separately and specify the path to the index.html file.
      • To support frontend libraries with this package, we would need to take additional arguments like patchFile, devUrl, initCommand, etc.
  • If we choose to build the package according to the second method (where we only ask the user for the path to the index.html file), it also comes with some issues:
    1. How will we get the path to the binaries? We would have to ask the user separately for the path to the binaries when initializing the class.
    2. How will we support frontend libraries' hot reloading? Since they only generate the resource files after running the build command, the user would always have to build the app to test any changes.
    3. Neutralino server requires neutralinojs.config.json file to run the app, since we only have index.html file so how will we solve this issue. we might have to generate a basic config file before running the app.
    • Issue 1 and 3 can be fixed if we include a basic neutralinojs.config.json with minimal config and logic to fetch the binaries before running the app in the package already.

Info about this PR

  • implemented WS server similar to the CLI
  • ability to receive a message and process it has been added
  • Neutralino class has been extended by EventEmitter class to allow the object to emit events when receiving a message from WS, ref: https://www.geeksforgeeks.org/node-js-eventemitter/
  • added a check for reinitializing when initializing the app
  • function to send a message, maintain queues for messages, and all other functions can be added in next PR.

@shalithasuranga
Copy link
Collaborator

Hello @viralgupta, thanks so much for sending this pull request. Please check the following answers for the above queries:

  • For the URL parameter when initializing the class, should the user provide the path to the app (i.e., the path to the neutralinojs.config.json file) or the path to the index.html file?

Answer: The app gets launched the same as the new CLI. The user doesn't need to provide any app path or path to web resources. We can use the path as . similar to the runner module in CLI, so users can store resources where the bin directory exists.

  • Currently, I am building the package based on the first method, but it has a few issues:
    1. We are assuming that the binaries will be located in the bin folder inside the root folder (i.e., "{url}/bin${path.sep}${binaryName}").
      Answer: Yes, that's the right approach

    2. If we proceed with this method, we will not be able to support apps with frontend libraries since it does not contain the logic to run the frontend app separately and specify the path to the index.html file.

      • To support frontend libraries with this package, we would need to take additional arguments like patchFile, devUrl, initCommand, etc.
  • If we choose to build the package according to the second method (where we only ask the user for the path to the index.html file), it also comes with some issues:
    1. How will we get the path to the binaries? We would have to ask the user separately for the path to the binaries when initializing the class.
    2. How will we support frontend libraries' hot reloading? Since they only generate the resource files after running the build command, the user would always have to build the app to test any changes.

Answer: (For all questions regarding frontend library-based development): This won't be an issue as long as we use the same logic that exists in neu CLI. Please check CLI implementation carefully. We can ignore this until you implement the WS connection and implement APIs I guess.

  1. Neutralino server requires neutralinojs.config.json file to run the app, since we only have index.html file so how will we solve this issue. we might have to generate a basic config file before running the app.
    Answer: The config file is optional in the latest version, please check the release notes for more details about the configless mode
  • Issue 1 and 3 can be fixed if we include a basic neutralinojs.config.json with minimal config and logic to fetch the binaries before running the app in the package already.

spec/app.spec.js Outdated Show resolved Hide resolved
spec/app.spec.js Outdated Show resolved Hide resolved
spec/utils.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
src/utils.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@shalithasuranga shalithasuranga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @viralgupta Thanks so much for sending this PR. I've added some notes to the submitted changes and answered your queries posted on the PR description 🎉

@viralgupta
Copy link
Contributor Author

viralgupta commented Jun 24, 2024

Hi @shalithasuranga sir,
Thank you for reviewing the PR, I have made the changes according to the review.

Copy link
Collaborator

@shalithasuranga shalithasuranga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sending your updates. Looks great now 🎉

@shalithasuranga shalithasuranga merged commit 0ba0ef0 into neutralinojs-community:main Jun 27, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants