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(client): client/src/cordova/dev action #2111

Merged
merged 13 commits into from
Aug 12, 2024

Conversation

daniellacosse
Copy link
Contributor

@daniellacosse daniellacosse commented Aug 8, 2024

simply run npm run action client/src/cordova/dev to start working in a native livereload environment!

demo (note that I'm speaking throughout):

lq-demo.mov

@daniellacosse daniellacosse changed the title feat(client): reload UI on www source change feat(client): prototype - reload UI on www source change Aug 8, 2024
@daniellacosse
Copy link
Contributor Author

daniellacosse commented Aug 9, 2024

note to self: revert package.json changes

DONE

@@ -26,5 +26,16 @@
</head>
<body unresolved>
<app-root></app-root>

<script>
Copy link
Contributor Author

@daniellacosse daniellacosse Aug 9, 2024

Choose a reason for hiding this comment

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

Unfortunately I can't inject this in debug mode because that mode doesn't work on MacOS.

@fortuna are there security concerns with this?

Copy link
Contributor Author

@daniellacosse daniellacosse Aug 9, 2024

Choose a reason for hiding this comment

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

If it's a problem, I can try injecting this script tag in the action after cordova/src/www/build is run! Maybe with jsdom?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use a separate index_cordova.dev.html file and use that in the cordova setup using makeReplacements()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So creating a separate file would mean i'd have to breakout a whole other webpack config/build workflow so instead i opted to just call makeReplacements() on the index_cordova.html output by the webpack process. PTAL.

@daniellacosse daniellacosse marked this pull request as ready for review August 9, 2024 20:32
@daniellacosse daniellacosse requested a review from a team as a code owner August 9, 2024 20:32
@daniellacosse daniellacosse changed the title feat(client): prototype - reload UI on www source change feat(client): client/src/cordova/dev action Aug 9, 2024
@github-actions github-actions bot added size/L and removed size/M labels Aug 12, 2024
};

/**
* @description Builds the parameterized cordova binary (ios, macos, maccatalyst, android).
Copy link
Contributor

Choose a reason for hiding this comment

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

Update this description?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops!

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you push your latest changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops! (pushed)

export async function main() {
console.warn(
chalk.yellow(
'This action only works for the MacOS platform. Ignoring all inputs.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not parse the inputs and exit early or throw an error if it's not targeting macos? It would be more explicit.

'This action only works for the MacOS platform. Ignoring all inputs.'
)
);
export async function main(...givenParameters) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, thanks. This is better.

@daniellacosse daniellacosse enabled auto-merge (squash) August 12, 2024 20:25
@daniellacosse daniellacosse merged commit c69689c into master Aug 12, 2024
18 checks passed
@daniellacosse daniellacosse deleted the daniellacosse/ui_reload branch August 12, 2024 20:27
Copy link
Collaborator

@fortuna fortuna left a comment

Choose a reason for hiding this comment

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

Please see the issue below


<script>
try {
const reloadSocket = new WebSocket("ws://localhost:35729");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need to hard-code the server? Can this be a dynamic port of a unix socket instead?

You start the reload server, so you might as well use a dynamic port to avoid port conflicts.

);

return true;
}).listen(RELOAD_SERVER_PORT);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe you are listening on the "any" address here. This is a security issue. Please change this to localhost.

Also, use port zero, so that the OS assign a port for you. Then read the port (really, the full address) to pass it to the websocket url.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tips - this is great. Since we merged this I'll do it in a follow up PR ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants