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(developer): Keyman Developer Server #6073
Conversation
Initial integration of ngrok into Keyman Developer web debugger experience, so that the user can access their web debug session from another device without significant configuration. By default, ngrok is switched off, but when it is enabled and configured (user must register an email address online I think), then Keyman Developer will start an ngrok tunnel in the background and make it the default link in the list of available addresses. This also adds an option to hide the list of local addresses, which is probably clearer for users when ngrok is active. However, as local addresses will be faster if configured, it may be less sensible to do this. If the user has ngrok installed and in use already, then it is recommended that they simply open a tunnel via the ngrok interface for the debugger web host, rather than relying on Keyman Developer's internal integration, as Keyman Deveoper does not do handle multiple ngrok sessions. The user may choose to make the ngrok tunnel window visible, which will be helpful in error scenarios. If Keyman Developer crashes, the ngrok tunnel may be left running, and will need to be manually killed.
Adds ngrok configuration dialog and processes for downloading, updating and setting up ngrok. It is likely this will change with a refactor of the web debugger into a standalone node module in the future. This will add support for multi- instance Keyman Developer and be another step towards a cross-platform IDE.
…d-debugger-server
Initial commit for Keyman Developer Server, running on Node. Supports web debugger only at this point. Extensive rewrite of web debugger, much of it more modern standards, significantly improved UX: 1. Drop keyboards, packages, fonts, models onto debug page to load them 2. Websocket for instant reload of recompiled keyboards, packages, models. 3. API for interacting with debug server. 4. Cache of recently used items. 5. Integration with ngrok for public access as desired. 6. Tray icon (currently default icon) for control of server. 7. Server can live after TIKE closes, supports multiple TIKE instances. 8. UI of debug host page rewritten with Bootstrap. 9. Packages downloads integrated into main page, and download link for Keyman supports all platforms (Linux is just a link to instructions...) 10. Avoids file locking and contention by managing all files internally. 11. Not yet tested, but should run cross-platform.
User Test ResultsTest specification and instructions ✅ SUITE_BASIC_USAGE: Basic usage tests
✅ SUITE_WEB_TEST_FUNCTIONALITY: Testing aspects of the user interface in the Web Test page
✅ SUITE_NGROK: Testing the ngrok integration
✅ SUITE_INTEROPERABILITY: Verify that various processes function correctly
Test Artifacts |
1. Renamed form UfrmNGrokOptions to UfrmServerOptions 2. Renamed kmdev-server to just plain server 3. Tidied up npm versioning to use VERSION_WITH_TAG This last point should help avoid confusion as now only CI release builds will ever generate a package.json with a.b.c, a.b.c-alpha or a.b.c-beta. Local and test builds will always have the corresponding -test or -local environment appended. This also helps avoid issues if we accidentally publish an incorrect version.
This also tidies up the mkver.sh script and adds the replaceVersionStrings() function to build-utils.sh for use globally.
SUITE_NGROK: Testing the ngrok integration
SUITE_INTEROPERABILITY: Verify that various processes function correctly
|
It turns out that this is because the page is only allowed to accept dropped files when it is loaded on localhost, for security reasons. The drag+drop interface and upload menu item should be disabled in this context (see checkbox in 'For upcoming pull requests' section). Documentation required on this limitation! SUITE_WEB_TEST_FUNCTIONALITY
|
Is it fine to use the current LTS of Node v16? |
Good catch. This note is now irrelevant, and I have removed it, as we are able to build the necessary modules on demand. You should not need to run a specific version of Node, but should be on Node v16 (LTS) of course because that's our current supported version. |
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.
Just some comments re dead code
Is there a way on the test page for the user to test portrait vs landscape layout? |
This is not currently supported. Given the keyboard functions identically, I'm not inclined to prioritise this at this time. At some point we can add a rotate button. |
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.
lgtm
I don't think the iOS build fail is related to this. Maybe certificate issue? |
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.
lgtm
…d-debugger-server
Changes in this pull request will be available for download in Keyman version 15.0.188-alpha |
Keyman Developer Server
Initial version of Keyman Developer Server, running on Node.js. This PR has a few too many changes -- sorry -- but hopefully a large proportion of them are boilerplate! Happy to walk reviewers through code.
This starts the process of moving the internal web server in Keyman Developer IDE to a standalone module. The initial version supports the KeymanWeb keyboard debugger, which is the primary module which is currently needed outside of Keyman Developer IDE.
Rationale
I was working on updating the existing web keyboard debugger following feedback from ELTW. The existing debugger had a Delphi backend and a HTML/JS frontend. I was finding that I had reached the limits of the existing design, and the whole module really needed rewriting: the code was pretty rudimentary. I was also hitting some limitations with the Delphi backend, in particular:
Given the need to rewrite, I felt that choosing Node.js made the most sense:
Benefits
This new server module has a number of benefits:
Features
Architecture
This is intended to be the first step in the way to having a fully cross-platform Keyman Developer. As such, Keyman Developer Server runs in Node.js and I have already tested on Linux (macOS not yet). Longer term, we may publish it as an npm module (it is currently called @keymanapp/developer-server).
Keyman Developer Server is located in /developer/server/ and the Keyman Developer build process (still under /windows/src/developer/ for now) will build the server when do a release build.
For your own builds,
/developer/server/build.sh [--production]
will build the server, todist/
. The server can be then run withnode .
If you specify to build to production, the build will create abuild/
folder, and this will be a self-contained version, ready to deploy. The Keyman Developer build bundles this folder, both into the Keyman Developer installer, and into the kmcomp.zip archive for other platforms.The server runs in its own process, and its Node.js console window will be hidden by default when started from Keyman Developer. On Windows, the process runs a taskbar icon which allows you to shutdown the server, or show/hide the console window.
When you start testing a keyboard, model or package, or when you compile one of these which is already under test, the server will be notified of the updated file via an api,
/api/<object-type>/register
. The server caches the updated file to a data folder, so it will be available even if the original file is removed, and across sessions. The server automatically expires old cached objects, with a limit of 12 of each object type in cache (this number may be too high?).The server will then notify all client web browsers, via WebSockets, of the updated files (a 'refresh' notification).
The client web browser (viewing e.g. http://localhost:8008) will reload the list of keyboards and models from a pretty awful
/inc/keyboards.js
endpoint (see TODO), and then read the debug objects themselves from/data/<object-type>/<filename>
.ngrok Integration
Keyman Developer Server includes integration with ngrok, which provides a public URL that works through firewalls and NAT. This is not enabled by default, and ngrok is not bundled with Keyman Developer at this time, but this can all be configured in Keyman Developer Options dialog (see screenshot below).
The user will need to:
%appdata%\Keyman\Keyman Developer\ngrok.exe
Once ngrok is configured and running, the IDE will include the public URL in the Tools/Web Debugger menu, and also in the available test addresses within the Keyboard, Package and Model editors (see screenshots).
This public URL will be available for the duration of the Keyman Developer Server session (use the option
Leave server running after closing IDE
for a longer session!). You can share this URL to your devices or even with other users (who need not be in the same location as you), which enables an instant user test-feedback cycle.Note: if the user runs ngrok for other purposes, they may prefer to configure ngrok externally. In this case, Keyman Developer will not show the ngrok URL in the UI, but otherwise it should still work in the same way.
Screenshots
For upcoming pull requests
/inc/
endpoints (currently all a bit ... dodgy)%appdata%\Keyman\Keyman Developer\Server
Future work