From ea62ac23e792b7c16d0377a39de13468724cb7d2 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Fri, 9 Aug 2024 18:18:53 +0200 Subject: [PATCH 1/2] =?UTF-8?q?refactor(web):=20move=20`lm-worker`=20?= =?UTF-8?q?=E2=86=92=20`worker-thread`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move `common/web/lm-worker/` → `web/src/engine/predictive-text/worker-thread/`. Fixes: #12148 --- common/web/lm-worker/tsconfig.json | 26 --------------- package-lock.json | 4 +-- tsconfig.json | 2 +- web/README.md | 2 +- web/src/app/browser/build.sh | 2 +- .../predictive-text/worker-main/build.sh | 2 +- .../worker-main/unit_tests/test.sh | 4 +-- .../predictive-text/worker-thread}/.c8rc.json | 0 .../worker-thread}/build-polyfiller.js | 2 +- .../worker-thread}/build-wrapper.js | 0 .../predictive-text/worker-thread}/build.sh | 10 +++--- .../worker-thread}/package.json | 0 .../main/correction/classical-calculation.ts | 0 .../src/main/correction/context-tracker.ts | 0 .../src/main/correction/distance-modeler.ts | 0 .../src/main/correction/execution-timer.ts | 0 .../src/main/correction/index.ts | 0 .../main/correction/transform-tokenization.ts | 0 .../worker-thread}/src/main/index.ts | 0 .../src/main/model-compositor.ts | 0 .../worker-thread}/src/main/model-helpers.ts | 0 .../src/main/models/dummy-model.ts | 0 .../worker-thread}/src/main/models/index.ts | 0 .../src/main/predict-helpers.ts | 0 .../worker-thread}/src/main/transformUtils.ts | 0 .../src/main/worker-interfaces.ts | 0 .../worker-thread}/src/main/worker-main.ts | 0 .../src/polyfills/array.fill.js | 0 .../src/polyfills/array.findIndex.js | 0 .../src/polyfills/array.from.js | 0 .../src/polyfills/array.includes.js | 0 .../src/polyfills/object.values.js | 0 .../src/polyfills/symbol-es6.min.js | 0 .../src/test/mocha/cases/auto-correct.js | 0 .../src/test/mocha/cases/casing-detection.js | 0 .../cases/early-correction-search-stopping.js | 0 .../edit-distance/classical-calculation.js | 0 .../cases/edit-distance/context-tracker.js | 0 .../cases/edit-distance/distance-modeler.js | 0 .../cases/edit-distance/execution-timer.js | 0 .../mocha/cases/predict-from-corrections.js | 0 .../mocha/cases/suggestion-deduplication.js | 0 .../mocha/cases/suggestion-finalization.js | 0 .../test/mocha/cases/suggestion-similarity.js | 0 .../mocha/cases/transform-tokenization.js | 0 .../src/test/mocha/cases/transform-utils.js | 0 .../mocha/cases/worker-custom-punctuation.js | 0 .../test/mocha/cases/worker-initialization.js | 0 .../mocha/cases/worker-model-compositor.js | 0 .../test/mocha/cases/worker-predict-dummy.js | 0 .../src/test/mocha/cases/worker-predict.js | 0 .../src/test/test-runner/cases/worker.spec.ts | 0 .../test-runner/web-test-runner.CI.config.mjs | 0 .../test-runner/web-test-runner.config.mjs | 0 .../worker-thread/tsconfig.json | 32 +++++++++++++++++++ 55 files changed, 46 insertions(+), 40 deletions(-) delete mode 100644 common/web/lm-worker/tsconfig.json rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/.c8rc.json (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/build-polyfiller.js (98%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/build-wrapper.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/build.sh (87%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/package.json (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/correction/classical-calculation.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/correction/context-tracker.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/correction/distance-modeler.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/correction/execution-timer.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/correction/index.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/correction/transform-tokenization.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/index.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/model-compositor.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/model-helpers.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/models/dummy-model.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/models/index.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/predict-helpers.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/transformUtils.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/worker-interfaces.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/main/worker-main.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/polyfills/array.fill.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/polyfills/array.findIndex.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/polyfills/array.from.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/polyfills/array.includes.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/polyfills/object.values.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/polyfills/symbol-es6.min.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/auto-correct.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/casing-detection.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/early-correction-search-stopping.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/edit-distance/classical-calculation.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/edit-distance/context-tracker.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/edit-distance/distance-modeler.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/edit-distance/execution-timer.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/predict-from-corrections.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/suggestion-deduplication.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/suggestion-finalization.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/suggestion-similarity.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/transform-tokenization.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/transform-utils.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/worker-custom-punctuation.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/worker-initialization.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/worker-model-compositor.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/worker-predict-dummy.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/mocha/cases/worker-predict.js (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/test-runner/cases/worker.spec.ts (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/test-runner/web-test-runner.CI.config.mjs (100%) rename {common/web/lm-worker => web/src/engine/predictive-text/worker-thread}/src/test/test-runner/web-test-runner.config.mjs (100%) create mode 100644 web/src/engine/predictive-text/worker-thread/tsconfig.json diff --git a/common/web/lm-worker/tsconfig.json b/common/web/lm-worker/tsconfig.json deleted file mode 100644 index 95b403c768b..00000000000 --- a/common/web/lm-worker/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "extends": "../../models/tsconfig.kmw-worker-base.json", - - "compilerOptions": { - "baseUrl": "./", - "outDir": "build/obj", - "tsBuildInfoFile": "build/obj/tsconfig.tsbuildinfo", - "rootDir": "./src/main", - - // As this one is the one that directly interfaces with the worker (from the inside) - "lib": ["webworker", "es6"], - }, - "references": [ - // types - { "path": "../../models/types" }, - { "path": "../../../web/src/engine/predictive-text/types" }, - // modules - { "path": "../keyman-version" }, - { "path": "../utils" }, - { "path": "../../models/templates" }, - { "path": "../../models/wordbreakers" }, - ], - "include": [ - "src/main/**/*.ts" - ] -} diff --git a/package-lock.json b/package-lock.json index 99a3d2f934b..8df9c941c25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -205,7 +205,7 @@ "typescript": "^5.4.5" } }, - "common/web/lm-worker": { + "web/src/engine/predictive-text/worker-thread": { "name": "@keymanapp/lm-worker", "license": "MIT", "dependencies": { @@ -2900,7 +2900,7 @@ "link": true }, "node_modules/@keymanapp/lm-worker": { - "resolved": "common/web/lm-worker", + "resolved": "web/src/engine/predictive-text/worker-thread", "link": true }, "node_modules/@keymanapp/models-templates": { diff --git a/tsconfig.json b/tsconfig.json index 252fd738dc3..1a02e20ff15 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,6 @@ { "path": "./common/web/gesture-recognizer/tsconfig.json" }, { "path": "./common/web/gesture-recognizer/src/tools/unit-test-resources/tsconfig.json" }, { "path": "./common/web/keyman-version" }, - { "path": "./common/web/lm-worker/" }, { "path": "./common/web/recorder/tsconfig.json" }, { "path": "./common/web/sentry-manager/src/tsconfig.json" }, { "path": "./common/web/types/" }, @@ -43,6 +42,7 @@ { "path": "./web/src/tsconfig.all.json" }, { "path": "./web/src/engine/predictive-text/types/" }, { "path": "./web/src/engine/predictive-text/worker-main/tsconfig.all.json" }, + { "path": "./web/src/engine/predictive-text/worker-thread" }, // { "path": "./web/tools/recorder/tsconfig.json" }, // { "path": "./web/tools/sourcemap-root/tsconfig.json" }, ] diff --git a/web/README.md b/web/README.md index 1e41497657c..bc2938bae0a 100644 --- a/web/README.md +++ b/web/README.md @@ -89,7 +89,7 @@ graph TD; Wordbreakers["@keymanapp/models-wordbreakers
(/common/models/wordbreakers)"]; Models["@keymanapp/models-templates
(/common/models/templates)"]; Models-->WebUtils; - LMWorker["@keymanapp/lm-worker
(/common/web/lm-worker)"]; + LMWorker["@keymanapp/lm-worker
(/web/src/engine/predictive-text/worker-thread)"]; LMWorker-->Models; LMWorker-->Wordbreakers; LMLayer["@keymanapp/lexical-model-layer
(/web/src/engine/predictive-text/worker-main)"]; diff --git a/web/src/app/browser/build.sh b/web/src/app/browser/build.sh index 049bc056b5e..1d757e264a2 100755 --- a/web/src/app/browser/build.sh +++ b/web/src/app/browser/build.sh @@ -79,7 +79,7 @@ compile_and_copy() { local PROFILE_DEST="$KEYMAN_ROOT/web/build/profiling/" mkdir -p "$PROFILE_DEST" cp "${BUILD_ROOT}/filesize-profile.log" "$PROFILE_DEST/web-engine-filesize.log" - cp "$KEYMAN_ROOT/common/web/lm-worker/build/filesize-profile.log" "$PROFILE_DEST/lm-worker-filesize.log" + cp "$KEYMAN_ROOT/web/src/engine/predictive-text/worker-thread/build/filesize-profile.log" "$PROFILE_DEST/lm-worker-filesize.log" } builder_run_action configure verify_npm_setup diff --git a/web/src/engine/predictive-text/worker-main/build.sh b/web/src/engine/predictive-text/worker-main/build.sh index 4120fce53b1..33e5eaebeb6 100755 --- a/web/src/engine/predictive-text/worker-main/build.sh +++ b/web/src/engine/predictive-text/worker-main/build.sh @@ -22,7 +22,7 @@ BUNDLE_CMD="node $KEYMAN_ROOT/common/web/es-bundling/build/common-bundle.mjs" builder_describe "Builds the lm-layer module" \ "@/common/web/keyman-version" \ "@/common/web/es-bundling" \ - "@/common/web/lm-worker" \ + "@/web/src/engine/predictive-text/worker-thread" \ "clean" \ "configure" \ "build" \ diff --git a/web/src/engine/predictive-text/worker-main/unit_tests/test.sh b/web/src/engine/predictive-text/worker-main/unit_tests/test.sh index 007bf363576..dda8d578640 100755 --- a/web/src/engine/predictive-text/worker-main/unit_tests/test.sh +++ b/web/src/engine/predictive-text/worker-main/unit_tests/test.sh @@ -57,9 +57,9 @@ if builder_start_action test:libraries; then "$KEYMAN_ROOT/common/models/templates/build.sh" test $TEST_OPTS popd - pushd "$KEYMAN_ROOT/common/web/lm-worker" + pushd "$KEYMAN_ROOT/web/src/engine/predictive-text/worker-thread" echo - echo "### Running ${BUILDER_TERM_START}common/web/lm-worker${BUILDER_TERM_END} tests" + echo "### Running ${BUILDER_TERM_START}web/src/engine/predictive-text/worker-thread${BUILDER_TERM_END} tests" ./build.sh test $TEST_OPTS popd diff --git a/common/web/lm-worker/.c8rc.json b/web/src/engine/predictive-text/worker-thread/.c8rc.json similarity index 100% rename from common/web/lm-worker/.c8rc.json rename to web/src/engine/predictive-text/worker-thread/.c8rc.json diff --git a/common/web/lm-worker/build-polyfiller.js b/web/src/engine/predictive-text/worker-thread/build-polyfiller.js similarity index 98% rename from common/web/lm-worker/build-polyfiller.js rename to web/src/engine/predictive-text/worker-thread/build-polyfiller.js index 41cec75ce7d..eab268e9867 100644 --- a/common/web/lm-worker/build-polyfiller.js +++ b/web/src/engine/predictive-text/worker-thread/build-polyfiller.js @@ -166,7 +166,7 @@ let fullWorkerConcatenation = concatScriptsAndSourcemaps(sourceFileSet, destFile // New stage: cleaning the sourcemaps // Sources are being passed into the sourcemap concatenator via our working directory. -let sourceRoot = '@keymanapp/keyman/common/web/lm-worker/'; +let sourceRoot = '@keymanapp/keyman/web/src/engine/predictive-text/worker-thread/'; fullWorkerConcatenation.sourcemapJSON.sourceRoot = sourceRoot; // End "cleaning the sourcemaps" diff --git a/common/web/lm-worker/build-wrapper.js b/web/src/engine/predictive-text/worker-thread/build-wrapper.js similarity index 100% rename from common/web/lm-worker/build-wrapper.js rename to web/src/engine/predictive-text/worker-thread/build-wrapper.js diff --git a/common/web/lm-worker/build.sh b/web/src/engine/predictive-text/worker-thread/build.sh similarity index 87% rename from common/web/lm-worker/build.sh rename to web/src/engine/predictive-text/worker-thread/build.sh index 0343d151c8f..8c6a4ca0012 100755 --- a/common/web/lm-worker/build.sh +++ b/web/src/engine/predictive-text/worker-thread/build.sh @@ -6,7 +6,7 @@ ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" -. "${THIS_SCRIPT%/*}/../../../resources/build/builder.inc.sh" +. "${THIS_SCRIPT%/*}/../../../../../resources/build/builder.inc.sh" ## END STANDARD BUILD SCRIPT INCLUDE . "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" @@ -17,7 +17,7 @@ WORKER_OUTPUT_FILENAME=build/lib/worker-main.js INTERMEDIATE=./build/intermediate LIB=./build/lib -bundle_cmd="node ../es-bundling/build/common-bundle.mjs" +bundle_cmd="node ${KEYMAN_ROOT}/common/web/es-bundling/build/common-bundle.mjs" SRCMAP_CLEANER="node $KEYMAN_ROOT/web/build/tools/building/sourcemap-root/index.js" @@ -34,7 +34,7 @@ builder_describe \ builder_describe_outputs \ configure /node_modules \ - build /common/web/lm-worker/$LIB/worker-main.wrapped.min.js + build "/web/src/engine/predictive-text/worker-thread/${LIB}/worker-main.wrapped.min.js" builder_parse "$@" @@ -65,7 +65,7 @@ function do_build() { $bundle_cmd src/main/worker-main.ts \ --out $INTERMEDIATE/worker-main.js \ --target "es6" \ - --sourceRoot '@keymanapp/keyman/common/web/lm-worker/src/main' + --sourceRoot '@keymanapp/keyman/web/src/engine/predictive-text/worker-thread/src/main' $SRCMAP_CLEANER \ $INTERMEDIATE/worker-main.js.map \ @@ -77,7 +77,7 @@ function do_build() { --minify \ --profile build/filesize-profile.log \ --target "es6" \ - --sourceRoot '@keymanapp/keyman/common/web/lm-worker/src/main' + --sourceRoot '@keymanapp/keyman/web/src/engine/predictive-text/worker-thread/src/main' $SRCMAP_CLEANER \ $INTERMEDIATE/worker-main.min.js.map \ diff --git a/common/web/lm-worker/package.json b/web/src/engine/predictive-text/worker-thread/package.json similarity index 100% rename from common/web/lm-worker/package.json rename to web/src/engine/predictive-text/worker-thread/package.json diff --git a/common/web/lm-worker/src/main/correction/classical-calculation.ts b/web/src/engine/predictive-text/worker-thread/src/main/correction/classical-calculation.ts similarity index 100% rename from common/web/lm-worker/src/main/correction/classical-calculation.ts rename to web/src/engine/predictive-text/worker-thread/src/main/correction/classical-calculation.ts diff --git a/common/web/lm-worker/src/main/correction/context-tracker.ts b/web/src/engine/predictive-text/worker-thread/src/main/correction/context-tracker.ts similarity index 100% rename from common/web/lm-worker/src/main/correction/context-tracker.ts rename to web/src/engine/predictive-text/worker-thread/src/main/correction/context-tracker.ts diff --git a/common/web/lm-worker/src/main/correction/distance-modeler.ts b/web/src/engine/predictive-text/worker-thread/src/main/correction/distance-modeler.ts similarity index 100% rename from common/web/lm-worker/src/main/correction/distance-modeler.ts rename to web/src/engine/predictive-text/worker-thread/src/main/correction/distance-modeler.ts diff --git a/common/web/lm-worker/src/main/correction/execution-timer.ts b/web/src/engine/predictive-text/worker-thread/src/main/correction/execution-timer.ts similarity index 100% rename from common/web/lm-worker/src/main/correction/execution-timer.ts rename to web/src/engine/predictive-text/worker-thread/src/main/correction/execution-timer.ts diff --git a/common/web/lm-worker/src/main/correction/index.ts b/web/src/engine/predictive-text/worker-thread/src/main/correction/index.ts similarity index 100% rename from common/web/lm-worker/src/main/correction/index.ts rename to web/src/engine/predictive-text/worker-thread/src/main/correction/index.ts diff --git a/common/web/lm-worker/src/main/correction/transform-tokenization.ts b/web/src/engine/predictive-text/worker-thread/src/main/correction/transform-tokenization.ts similarity index 100% rename from common/web/lm-worker/src/main/correction/transform-tokenization.ts rename to web/src/engine/predictive-text/worker-thread/src/main/correction/transform-tokenization.ts diff --git a/common/web/lm-worker/src/main/index.ts b/web/src/engine/predictive-text/worker-thread/src/main/index.ts similarity index 100% rename from common/web/lm-worker/src/main/index.ts rename to web/src/engine/predictive-text/worker-thread/src/main/index.ts diff --git a/common/web/lm-worker/src/main/model-compositor.ts b/web/src/engine/predictive-text/worker-thread/src/main/model-compositor.ts similarity index 100% rename from common/web/lm-worker/src/main/model-compositor.ts rename to web/src/engine/predictive-text/worker-thread/src/main/model-compositor.ts diff --git a/common/web/lm-worker/src/main/model-helpers.ts b/web/src/engine/predictive-text/worker-thread/src/main/model-helpers.ts similarity index 100% rename from common/web/lm-worker/src/main/model-helpers.ts rename to web/src/engine/predictive-text/worker-thread/src/main/model-helpers.ts diff --git a/common/web/lm-worker/src/main/models/dummy-model.ts b/web/src/engine/predictive-text/worker-thread/src/main/models/dummy-model.ts similarity index 100% rename from common/web/lm-worker/src/main/models/dummy-model.ts rename to web/src/engine/predictive-text/worker-thread/src/main/models/dummy-model.ts diff --git a/common/web/lm-worker/src/main/models/index.ts b/web/src/engine/predictive-text/worker-thread/src/main/models/index.ts similarity index 100% rename from common/web/lm-worker/src/main/models/index.ts rename to web/src/engine/predictive-text/worker-thread/src/main/models/index.ts diff --git a/common/web/lm-worker/src/main/predict-helpers.ts b/web/src/engine/predictive-text/worker-thread/src/main/predict-helpers.ts similarity index 100% rename from common/web/lm-worker/src/main/predict-helpers.ts rename to web/src/engine/predictive-text/worker-thread/src/main/predict-helpers.ts diff --git a/common/web/lm-worker/src/main/transformUtils.ts b/web/src/engine/predictive-text/worker-thread/src/main/transformUtils.ts similarity index 100% rename from common/web/lm-worker/src/main/transformUtils.ts rename to web/src/engine/predictive-text/worker-thread/src/main/transformUtils.ts diff --git a/common/web/lm-worker/src/main/worker-interfaces.ts b/web/src/engine/predictive-text/worker-thread/src/main/worker-interfaces.ts similarity index 100% rename from common/web/lm-worker/src/main/worker-interfaces.ts rename to web/src/engine/predictive-text/worker-thread/src/main/worker-interfaces.ts diff --git a/common/web/lm-worker/src/main/worker-main.ts b/web/src/engine/predictive-text/worker-thread/src/main/worker-main.ts similarity index 100% rename from common/web/lm-worker/src/main/worker-main.ts rename to web/src/engine/predictive-text/worker-thread/src/main/worker-main.ts diff --git a/common/web/lm-worker/src/polyfills/array.fill.js b/web/src/engine/predictive-text/worker-thread/src/polyfills/array.fill.js similarity index 100% rename from common/web/lm-worker/src/polyfills/array.fill.js rename to web/src/engine/predictive-text/worker-thread/src/polyfills/array.fill.js diff --git a/common/web/lm-worker/src/polyfills/array.findIndex.js b/web/src/engine/predictive-text/worker-thread/src/polyfills/array.findIndex.js similarity index 100% rename from common/web/lm-worker/src/polyfills/array.findIndex.js rename to web/src/engine/predictive-text/worker-thread/src/polyfills/array.findIndex.js diff --git a/common/web/lm-worker/src/polyfills/array.from.js b/web/src/engine/predictive-text/worker-thread/src/polyfills/array.from.js similarity index 100% rename from common/web/lm-worker/src/polyfills/array.from.js rename to web/src/engine/predictive-text/worker-thread/src/polyfills/array.from.js diff --git a/common/web/lm-worker/src/polyfills/array.includes.js b/web/src/engine/predictive-text/worker-thread/src/polyfills/array.includes.js similarity index 100% rename from common/web/lm-worker/src/polyfills/array.includes.js rename to web/src/engine/predictive-text/worker-thread/src/polyfills/array.includes.js diff --git a/common/web/lm-worker/src/polyfills/object.values.js b/web/src/engine/predictive-text/worker-thread/src/polyfills/object.values.js similarity index 100% rename from common/web/lm-worker/src/polyfills/object.values.js rename to web/src/engine/predictive-text/worker-thread/src/polyfills/object.values.js diff --git a/common/web/lm-worker/src/polyfills/symbol-es6.min.js b/web/src/engine/predictive-text/worker-thread/src/polyfills/symbol-es6.min.js similarity index 100% rename from common/web/lm-worker/src/polyfills/symbol-es6.min.js rename to web/src/engine/predictive-text/worker-thread/src/polyfills/symbol-es6.min.js diff --git a/common/web/lm-worker/src/test/mocha/cases/auto-correct.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/auto-correct.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/auto-correct.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/auto-correct.js diff --git a/common/web/lm-worker/src/test/mocha/cases/casing-detection.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/casing-detection.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/casing-detection.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/casing-detection.js diff --git a/common/web/lm-worker/src/test/mocha/cases/early-correction-search-stopping.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/early-correction-search-stopping.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/early-correction-search-stopping.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/early-correction-search-stopping.js diff --git a/common/web/lm-worker/src/test/mocha/cases/edit-distance/classical-calculation.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/edit-distance/classical-calculation.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/edit-distance/classical-calculation.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/edit-distance/classical-calculation.js diff --git a/common/web/lm-worker/src/test/mocha/cases/edit-distance/context-tracker.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/edit-distance/context-tracker.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/edit-distance/context-tracker.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/edit-distance/context-tracker.js diff --git a/common/web/lm-worker/src/test/mocha/cases/edit-distance/distance-modeler.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/edit-distance/distance-modeler.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/edit-distance/distance-modeler.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/edit-distance/distance-modeler.js diff --git a/common/web/lm-worker/src/test/mocha/cases/edit-distance/execution-timer.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/edit-distance/execution-timer.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/edit-distance/execution-timer.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/edit-distance/execution-timer.js diff --git a/common/web/lm-worker/src/test/mocha/cases/predict-from-corrections.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/predict-from-corrections.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/predict-from-corrections.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/predict-from-corrections.js diff --git a/common/web/lm-worker/src/test/mocha/cases/suggestion-deduplication.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/suggestion-deduplication.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/suggestion-deduplication.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/suggestion-deduplication.js diff --git a/common/web/lm-worker/src/test/mocha/cases/suggestion-finalization.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/suggestion-finalization.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/suggestion-finalization.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/suggestion-finalization.js diff --git a/common/web/lm-worker/src/test/mocha/cases/suggestion-similarity.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/suggestion-similarity.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/suggestion-similarity.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/suggestion-similarity.js diff --git a/common/web/lm-worker/src/test/mocha/cases/transform-tokenization.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/transform-tokenization.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/transform-tokenization.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/transform-tokenization.js diff --git a/common/web/lm-worker/src/test/mocha/cases/transform-utils.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/transform-utils.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/transform-utils.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/transform-utils.js diff --git a/common/web/lm-worker/src/test/mocha/cases/worker-custom-punctuation.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/worker-custom-punctuation.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/worker-custom-punctuation.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/worker-custom-punctuation.js diff --git a/common/web/lm-worker/src/test/mocha/cases/worker-initialization.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/worker-initialization.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/worker-initialization.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/worker-initialization.js diff --git a/common/web/lm-worker/src/test/mocha/cases/worker-model-compositor.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/worker-model-compositor.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/worker-model-compositor.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/worker-model-compositor.js diff --git a/common/web/lm-worker/src/test/mocha/cases/worker-predict-dummy.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/worker-predict-dummy.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/worker-predict-dummy.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/worker-predict-dummy.js diff --git a/common/web/lm-worker/src/test/mocha/cases/worker-predict.js b/web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/worker-predict.js similarity index 100% rename from common/web/lm-worker/src/test/mocha/cases/worker-predict.js rename to web/src/engine/predictive-text/worker-thread/src/test/mocha/cases/worker-predict.js diff --git a/common/web/lm-worker/src/test/test-runner/cases/worker.spec.ts b/web/src/engine/predictive-text/worker-thread/src/test/test-runner/cases/worker.spec.ts similarity index 100% rename from common/web/lm-worker/src/test/test-runner/cases/worker.spec.ts rename to web/src/engine/predictive-text/worker-thread/src/test/test-runner/cases/worker.spec.ts diff --git a/common/web/lm-worker/src/test/test-runner/web-test-runner.CI.config.mjs b/web/src/engine/predictive-text/worker-thread/src/test/test-runner/web-test-runner.CI.config.mjs similarity index 100% rename from common/web/lm-worker/src/test/test-runner/web-test-runner.CI.config.mjs rename to web/src/engine/predictive-text/worker-thread/src/test/test-runner/web-test-runner.CI.config.mjs diff --git a/common/web/lm-worker/src/test/test-runner/web-test-runner.config.mjs b/web/src/engine/predictive-text/worker-thread/src/test/test-runner/web-test-runner.config.mjs similarity index 100% rename from common/web/lm-worker/src/test/test-runner/web-test-runner.config.mjs rename to web/src/engine/predictive-text/worker-thread/src/test/test-runner/web-test-runner.config.mjs diff --git a/web/src/engine/predictive-text/worker-thread/tsconfig.json b/web/src/engine/predictive-text/worker-thread/tsconfig.json new file mode 100644 index 00000000000..bfc8498730b --- /dev/null +++ b/web/src/engine/predictive-text/worker-thread/tsconfig.json @@ -0,0 +1,32 @@ +{ + "extends": "../../../../tsconfig.base.json", + + "compilerOptions": { + "baseUrl": "./", + "outDir": "build/obj", + "tsBuildInfoFile": "build/obj/tsconfig.tsbuildinfo", + "rootDir": "./src/main", + // To help better support legacy Android devices + "downlevelIteration": true, + // Facilitates & simplifies stitching together the worker sourcemaps during the polyfill-concatenation step. + "inlineSourceMap": true, + // May not be set at the same time as the prior setting. + "sourceMap": false, + + // As this one is the one that directly interfaces with the worker (from the inside) + "lib": ["webworker", "es6"], + }, + "references": [ + // types + { "path": "../../../../../common/models/types" }, + { "path": "../types" }, + // modules + { "path": "../../../../../common/web/keyman-version" }, + { "path": "../../../../../common/web/utils" }, + { "path": "../../../../../common/models/templates" }, + { "path": "../../../../../common/models/wordbreakers" }, + ], + "include": [ + "src/main/**/*.ts" + ] +} From ac0f4f6a83297f6bd2cac53590427a6dc73c8b90 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Mon, 19 Aug 2024 10:08:36 +0200 Subject: [PATCH 2/2] refactor(web): run npm install Addresses code review comments --- package-lock.json | 99 +++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8df9c941c25..d87ca37496c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -108,25 +108,6 @@ "typescript": "^5.4.5" } }, - "web/src/engine/predictive-text/worker-main": { - "name": "@keymanapp/lexical-model-layer", - "license": "MIT", - "dependencies": { - "@keymanapp/keyman-version": "*", - "@keymanapp/models-templates": "*", - "@keymanapp/models-wordbreakers": "*", - "@keymanapp/web-utils": "*", - "es6-shim": "^0.35.5", - "string.prototype.codepointat": "^0.2.1" - }, - "devDependencies": { - "@keymanapp/models-types": "*", - "@keymanapp/resources-gosh": "*", - "mocha": "^10.0.0", - "mocha-teamcity-reporter": "^4.0.0", - "typescript": "^5.4.5" - } - }, "common/test/resources": { "name": "@keymanapp/common-test-resources", "license": "MIT", @@ -198,36 +179,6 @@ "typescript": "^5.4.5" } }, - "web/src/engine/predictive-text/types": { - "name": "@keymanapp/lm-message-types", - "license": "MIT", - "devDependencies": { - "typescript": "^5.4.5" - } - }, - "web/src/engine/predictive-text/worker-thread": { - "name": "@keymanapp/lm-worker", - "license": "MIT", - "dependencies": { - "@keymanapp/keyman-version": "*", - "@keymanapp/models-templates": "*", - "@keymanapp/models-wordbreakers": "*", - "@keymanapp/web-utils": "*", - "es6-shim": "^0.35.5", - "string.prototype.codepointat": "^0.2.1", - "string.prototype.startswith": "^0.2.0" - }, - "devDependencies": { - "@keymanapp/common-test-resources": "*", - "@keymanapp/models-types": "*", - "@keymanapp/resources-gosh": "*", - "c8": "^7.12.0", - "combine-source-map": "^0.8.0", - "mocha": "^10.0.0", - "mocha-teamcity-reporter": "^4.0.0", - "typescript": "^5.4.5" - } - }, "common/web/sentry-manager": { "name": "@keymanapp/web-sentry-manager", "license": "MIT", @@ -14819,11 +14770,59 @@ "mocha": "^10.0.0" } }, + "web/src/engine/predictive-text/types": { + "name": "@keymanapp/lm-message-types", + "license": "MIT", + "devDependencies": { + "typescript": "^5.4.5" + } + }, + "web/src/engine/predictive-text/worker-main": { + "name": "@keymanapp/lexical-model-layer", + "license": "MIT", + "dependencies": { + "@keymanapp/keyman-version": "*", + "@keymanapp/models-templates": "*", + "@keymanapp/models-wordbreakers": "*", + "@keymanapp/web-utils": "*", + "es6-shim": "^0.35.5", + "string.prototype.codepointat": "^0.2.1" + }, + "devDependencies": { + "@keymanapp/models-types": "*", + "@keymanapp/resources-gosh": "*", + "mocha": "^10.0.0", + "mocha-teamcity-reporter": "^4.0.0", + "typescript": "^5.4.5" + } + }, + "web/src/engine/predictive-text/worker-thread": { + "name": "@keymanapp/lm-worker", + "license": "MIT", + "dependencies": { + "@keymanapp/keyman-version": "*", + "@keymanapp/models-templates": "*", + "@keymanapp/models-wordbreakers": "*", + "@keymanapp/web-utils": "*", + "es6-shim": "^0.35.5", + "string.prototype.codepointat": "^0.2.1", + "string.prototype.startswith": "^0.2.0" + }, + "devDependencies": { + "@keymanapp/common-test-resources": "*", + "@keymanapp/models-types": "*", + "@keymanapp/resources-gosh": "*", + "c8": "^7.12.0", + "combine-source-map": "^0.8.0", + "mocha": "^10.0.0", + "mocha-teamcity-reporter": "^4.0.0", + "typescript": "^5.4.5" + } + }, "web/src/tools/testing/recorder-core": { "name": "@keymanapp/recorder-core", "license": "MIT", "dependencies": { - "@keymanapp/keyboard-processor": "*", "@keymanapp/keyman-version": "*", "@keymanapp/models-types": "*", "@keymanapp/web-utils": "*"