spiegel-keyman/web/src/engine/predictive-text/worker-main
Marc Durdin 2726050601 maint(common): rename and move node-related script functions into node.inc.sh
Consolidates the node-related script functions into node.inc.sh, as part
of cleaning up the build scripts and making them easier to maintain into
the future.

Fixes: #14447
2025-08-02 13:34:29 +10:00
..
docs refactor(web): move predictive-text → worker-main 2024-08-15 12:26:50 +02:00
src change(web): replace USVString with string in predictive-text engine 2025-04-29 10:47:20 +07:00
unit_tests maint(common): rename and move node-related script functions into node.inc.sh 2025-08-02 13:34:29 +10:00
.gitignore refactor(web): move predictive-text → worker-main 2024-08-15 12:26:50 +02:00
build.sh maint(common): rename and move node-related script functions into node.inc.sh 2025-08-02 13:34:29 +10:00
package.json maint: update mocha 2025-05-13 14:02:02 +07:00
README.md refactor(web): move predictive-text → worker-main 2024-08-15 12:26:50 +02:00
tsconfig.all.json refactor(web): move common/web/utils to web/src/engine/common/web-utils/ 2024-09-10 18:12:46 +02:00

Language Modelling Layer (LMLayer)

Provide predictions and corrections while you type!

See Worker Communication Protocol for a semi-formal specification on how the Worker and the main thread communicate.

System dependencies

You will need Bash and Node.js >= 10.0.

Build

Run build.sh. This will also automatically install dependencies with npm.

./build.sh

Two-stage compilation process

Since the primary LMLayer code runs within a Web Worker, build.sh compiles the LMLayer in two stages:

  1. Compile the inner worker code

    1. Compile the TypeScript sources for only the Worker code.
    2. Wrap the Worker code as embedded_worker.js
  2. Compile the top-level code

    1. Include embedded_worker.js verbatim using a TypeScript directive.
    2. Compile the top-level TypeScript code.
    3. Unwrap the Worker code at runtime.

Test

This will run both headless unit tests, and in-browser unit tests and integration tests:

./build.sh -test

Test-Driven Development

I like to use entr to automatically build and re-run the unit tests anytime I change a source code file. Here's the command I run in separate window:

git ls-files | entr -c ./build.sh -tdd

Importantly, ./build.sh -tdd skips running the in-browser tests, and skips downloading/updating npm dependencies.