spiegel-keyman/common/predictive-text
2018-11-28 14:46:04 -07:00
..
docs Move worker communications docs to the docs/ directory. 2018-11-28 14:26:04 -07:00
testing Demonstrate Blob code proof-of-concept. 2018-11-20 11:12:05 -07:00
unit_tests Comment ALL THE THINGS. 2018-11-28 14:20:09 -07:00
worker Comment ALL THE THINGS. 2018-11-28 14:20:09 -07:00
.gitignore More general pattern for .gitignore. 2018-11-20 08:48:45 -07:00
build.sh Source the utilities in resources/ in the build.sh script. 2018-11-28 14:23:14 -07:00
embedded_worker.d.ts Comment ALL THE THINGS. 2018-11-28 14:20:09 -07:00
history.md Created an initial build script for use in common/predictive-text 2018-11-01 08:04:06 +07:00
index.ts Comment ALL THE THINGS. 2018-11-28 14:20:09 -07:00
package-lock.json Test LMLayerWorker can mock postMessage. 2018-11-16 14:05:30 -07:00
package.json Let main script be index.js (implitly). 2018-11-27 15:24:37 -07:00
README.md Add a README describing how to build the code and vaguely what's going on here. 2018-11-28 14:46:04 -07:00
tsconfig.json Compile worker code and interface code into one .js file. 2018-11-27 14:53:53 -07: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 >= 6.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, the LMLayer must be compiled in two stages:

  1. Compile the inner worker code a. Compile the TypeScript sources for only the Worker code. b. Wrap the Worker code as embedded_worker.js

  2. Compile the top-level code a. Include embedded_worker.js verbatim using a TypeScript directive. b. Compile the top-level TypeScript code. c. 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, this ./build.sh -tdd skips running the in-browser tests, and skips downloading/updating npm dependencies.