-
-
Notifications
You must be signed in to change notification settings - Fork 547
Refactor and improve browser versions (tic-html, export stubs, webapp) #1912
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
Conversation
This commit refactor & fix various problems in HTML builds: - Build emscripten script as ES6 module, so that it doesn't pollute the global namespace and can be easier to import to SPA projects (vue, react,...). - Change `SDL_EMSCRIPTEN_KEYBOARD_ELEMENT` to the canvas element so that emscripten won't block all keyboard input to the rest of the webpage (fixing the problem that make typing comment content on tic80.com is not possible after starting the game) - Add tabindex to canvas element so that canvas can be focused (and unfocused) and capture the keyboard input properly. - Refactor html template of html, html export stub and webapp build to be more minimal, and add a simple "play" icon instead of "click to play" text - Small changes to html build directories in github action's script
What is the goal of:
Also, we should state clearly this is going to break older browsers that don't support ES6 modules. How far bad do we want our browser support to extend? Do we have any stats from the website showing us the browser distribution (to perhaps use as a rough metric instead of just spitballing). I'm not super worried about this, but it's worth mentioning since if it was more than a few users I'm personally not sure the benefits listed here are worth breaking compatibility. |
Also if we're adding sub-directories now I'm not sure |
@joshgoebel I don't think there is any serious issues in compatibility, ES6 modules feature (import/export) is supported by most modern browsers, and has roughly same browser support to webassembly, so if browser does not support ES modules then it probably does not support webassembly anyway. These are browser compatibility information of ES6 modules amd webassembly: And also it is possible to support even older browsers with javascript build tools and bundlers (webpack, esbuild,...) when necessary. |
The argument It is not needed without |
@joshgoebel I'm super bad at naming things, do you have any suggestions? ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a web developer and I don't understand some things, but anyway let's merge it.
Thank you for the help. 👍
This PR refactor & fix various problems in browser/HTML versions:
SDL_EMSCRIPTEN_KEYBOARD_ELEMENT
to the canvas element so that emscripten won't block all keyboard input in the rest of the webpage (fixing the problem that make typing or backspace-ing comment content on tic80.com not possible after starting the game)This is my first PR so forgive me if I missed anything.