spiegel-keyman/common/predictive-text
Marc Durdin 2f2d3c72c9 chore(web): move lm-worker into its own folder
This starts the reorg required for splitting the lm worker into its own
module. Tests are still not working. But builds are going.

Some decisions to be made around the final path for wrapping of the
code. I think it may be possible to do something a whole lot more
elegant by moving the wrapping process into the KMW build and leaving
the LM Worker output as a pure tsc output -- given only KMW wants the
wrapped worker anyway (tests aside). The actual wrapping code could
still be in the lm-worker folder.
2022-04-14 15:33:23 +10:00
..
docs docs(common/models): Update common/predictive-text/docs/worker-communication-protocol.md 2020-12-04 08:26:32 +07:00
testing chore(common): cleanup sh global color variables 2022-03-10 10:12:09 +11:00
unit_tests feat(web): prediction casing follows current layer 2022-04-08 16:14:01 +10:00
.gitignore fix(common): Actually adds polyfill (and fixes .gitignore) 2019-12-10 09:24:23 +07:00
browser.tsconfig.json chore(web): move lm-worker into its own folder 2022-04-14 15:33:23 +10:00
build.sh chore(web): move lm-worker into its own folder 2022-04-14 15:33:23 +10:00
embedded_worker.d.ts chore(web): replace lerna with npm workspaces and ts projects 2022-04-12 21:02:33 +10:00
index.d.ts chore(web): move lm-worker into its own folder 2022-04-14 15:33:23 +10:00
index.ts chore(web): move lm-worker into its own folder 2022-04-14 15:33:23 +10:00
node-defaultWorker.ts refactor(common/lmlayer): Adapts to rework of base PR 2020-04-17 11:18:13 +07:00
package-lock.json auto: increment beta version to 15.0.233 2022-04-11 14:02:20 -04:00
package.json chore(web): Merge branch 'beta' into chore/web/no-more-lerna 2022-04-12 21:17:15 +10:00
promise-store.ts chore(web): replace lerna with npm workspaces and ts projects 2022-04-12 21:02:33 +10:00
README.md feat(common): lerna now npm-installed locally 2020-04-21 15:55:43 +07:00
tsconfig.json chore(web): move lm-worker into its own folder 2022-04-14 15:33:23 +10:00
virtualizedWorker.ts change(common/lmlayer): a bit more PR review polish 2020-04-20 23:18:22 +07:00
web-defaultWorker.ts refactor(common/lmlayer): Adapts to rework of base PR 2020-04-17 11:18:13 +07:00
worker-interface.d.ts chore(web): replace lerna with npm workspaces and ts projects 2022-04-12 21:02:33 +10: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.