Skip to content

Commit

Permalink
refactor(web): move lm-workerworker-thread
Browse files Browse the repository at this point in the history
Move `common/web/lm-worker/` →
`web/src/engine/predictive-text/worker-thread/`.

Fixes: #12148
  • Loading branch information
ermshiperete committed Aug 15, 2024
1 parent 392a0fb commit 08e0d30
Show file tree
Hide file tree
Showing 55 changed files with 46 additions and 40 deletions.
26 changes: 0 additions & 26 deletions common/web/lm-worker/tsconfig.json

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/" },
Expand Down Expand Up @@ -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" },
]
Expand Down
2 changes: 1 addition & 1 deletion web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ graph TD;
Wordbreakers["@keymanapp/models-wordbreakers<br>(/common/models/wordbreakers)"];
Models["@keymanapp/models-templates<br>(/common/models/templates)"];
Models-->WebUtils;
LMWorker["@keymanapp/lm-worker<br>(/common/web/lm-worker)"];
LMWorker["@keymanapp/lm-worker<br>(/web/src/engine/predictive-text/worker-thread)"];
LMWorker-->Models;
LMWorker-->Wordbreakers;
LMLayer["@keymanapp/lexical-model-layer<br>(/web/src/engine/predictive-text/worker-main)"];
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/browser/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion web/src/engine/predictive-text/worker-main/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
4 changes: 2 additions & 2 deletions web/src/engine/predictive-text/worker-main/unit_tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand All @@ -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 "$@"

Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions web/src/engine/predictive-text/worker-thread/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
]
}

0 comments on commit 08e0d30

Please sign in to comment.