-
-
Notifications
You must be signed in to change notification settings - Fork 114
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(web): refactor loading of .js keyboards 🎼 #12334
Conversation
- split keyboard loading into loading into blob and then loading the script - look at first four bytes to see if it's a .js or a .kmx keyboard - for domKeyboardLoader, use fetch to get the blob, then use indirect eval to load the script, instead of injecting a script element. This does not yet implement the loading of .kmx keyboards.
User Test ResultsTest specification and instructions User tests are not required Test Artifacts
|
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.
This is looking good, most of my commentary is around error management. It would be good to be able to unit test the various error scenarios.
web/src/engine/keyboard/src/keyboards/loaders/domKeyboardLoader.ts
Outdated
Show resolved
Hide resolved
web/src/engine/keyboard/src/keyboards/loaders/domKeyboardLoader.ts
Outdated
Show resolved
Hide resolved
web/src/engine/keyboard/src/keyboards/loaders/domKeyboardLoader.ts
Outdated
Show resolved
Hide resolved
web/src/engine/keyboard/src/keyboards/loaders/nodeKeyboardLoader.ts
Outdated
Show resolved
Hide resolved
web/src/engine/keyboard/src/keyboards/loaders/nodeKeyboardLoader.ts
Outdated
Show resolved
Hide resolved
#11746 removed the `ts-node` dependency. Unfortunately that broke running TypeScript test files with Mocha in VSCode Test Explorer because it no longer knows what to do with .ts files. This change adds the more modern `tsx` package as developer dependency, which allows to use Test Explorer again. See https://stackoverflow.com/a/77609121.
Addresses code review comments.
fd184a2
to
1dd6989
Compare
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 like where this is going. Have a number of additional comments, but it's getting close. Given this is so core to KMW, I think it is important to get it really solid!
web/src/engine/keyboard/src/keyboards/loaders/domKeyboardLoader.ts
Outdated
Show resolved
Hide resolved
web/src/engine/keyboard/src/keyboards/loaders/domKeyboardLoader.ts
Outdated
Show resolved
Hide resolved
web/src/engine/keyboard/src/keyboards/loaders/domKeyboardLoader.ts
Outdated
Show resolved
Hide resolved
web/src/test/auto/headless/engine/keyboard/keyboard-loading.tests.ts
Outdated
Show resolved
Hide resolved
web/src/test/auto/headless/engine/keyboard/keyboard-loading.tests.ts
Outdated
Show resolved
Hide resolved
web/src/test/auto/headless/engine/keyboard/keyboard-loading.tests.ts
Outdated
Show resolved
Hide resolved
web/src/test/auto/headless/engine/keyboard/keyboard-loading.tests.ts
Outdated
Show resolved
Hide resolved
web/src/test/auto/headless/engine/keyboard/keyboard-loading.tests.ts
Outdated
Show resolved
Hide resolved
Addresses code review comments.
Make sure to test & user-test with the page found at /web/src/test/manual/web/keyboard-errors/ if you aren't already doing so; it's designed to test keyboard-load error handling. |
@jahorton Thanks for the hint! That showed two scenarios that this PR doesn't handle correctly. One (non-parsable) is easy to fix, but for the other (timeout) I'm not sure how to make it behave the same as before: for that test |
Since we're using
|
https://stackoverflow.com/a/50101022/1836776 discusses ways to handle timeout for Fetch -- and discourages use of Promise.race. |
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.
The updates look good, but I realized there is still one problem, with .kmx detection. Only a couple of other minor nits.
web/src/engine/keyboard/src/keyboards/loaders/domKeyboardLoader.ts
Outdated
Show resolved
Hide resolved
The previous approach with overriding `onload` no longer works if we use indirect eval. However, since we now need to use a server anyways instead of directly loading a file (because of Core), we can add a timeout to the test server and implement this test in a cleaner way.
This does not yet implement the loading of .kmx keyboards.
@keymanapp-test-bot skip