spiegel-keyman/web/src/engine/predictive-text/worker-main
Marc Durdin 3c90c732e1 chore(android): remove unused map-polyfill.js and es6-shim.min.js polyfills
These files were copied in but never referenced in 19.0 source.

Fixes: #16583
Test-bot: skip
2026-09-23 11:25:13 +02:00
..
docs docs(web): markdown doc update: worker comm protocols 2025-08-15 12:07:17 -05:00
src Merge branch 'epic/autocorrect' into auto/A19S30-merge-master-into-autocorrect 2026-06-09 14:50:36 -05:00
unit_tests refactor(web): Rename (Default)Worker to WebWorker and NodeWorker 2026-01-12 10:52:05 +01:00
.gitignore refactor(web): move predictive-text → worker-main 2024-08-15 12:26:50 +02:00
build.sh maint(web): ensure Web build scripts handle paths with spaces properly 2026-02-18 09:14:30 +07:00
package.json chore(android): remove unused map-polyfill.js and es6-shim.min.js polyfills 2026-09-23 11:25:13 +02:00
README.md refactor(web): move predictive-text → worker-main 2024-08-15 12:26:50 +02:00
tsconfig.all.json refactor(web): change @keymanapp/web-utils to keyman/common/web-utils 2025-11-06 07:24:36 +01: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.