Skip to content

Commit

Permalink
chore(web): move common/web/utilsweb/src/engine/common/utils/
Browse files Browse the repository at this point in the history
Move files from `common/web/utils` according to the document linked in
#11374.

Fixes: #12025
  • Loading branch information
ermshiperete committed Jul 26, 2024
1 parent 4fadd9c commit 785505d
Show file tree
Hide file tree
Showing 32 changed files with 44 additions and 35 deletions.
1 change: 0 additions & 1 deletion common/web/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
builder_describe "Keyman common web modules" \
:keyman-version \
:types \
:utils \
clean \
configure \
build \
Expand Down
4 changes: 2 additions & 2 deletions common/web/gesture-recognizer/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BUNDLE_CMD="node $KEYMAN_ROOT/common/web/es-bundling/build/common-bundle.mjs"

builder_describe "Builds the gesture-recognition model for Web-based on-screen keyboards" \
"@/common/web/es-bundling build" \
"@/common/web/utils build" \
"@/web/src/engine/common/utils build" \
"clean" \
"configure" \
"build" \
Expand Down Expand Up @@ -75,4 +75,4 @@ fi

if builder_has_action test:tools && ! builder_has_action test:module; then
echo "The $(builder_term test:tools) action is currently a no-op."
fi
fi
2 changes: 1 addition & 1 deletion common/web/keyboard-processor/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ builder_describe \
"@/common/web/keyman-version" \
"@/common/web/es-bundling" \
"@/common/web/types" \
"@/common/web/utils" \
"@/web/src/engine/common/utils" \
configure \
clean \
build \
Expand Down
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 resources/gosh/gosh.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"foo": "gosh ./foo.sh ..."
}
For example, in common/web/utils/package.json, npm run build is defined as:
For example, in web/src/engine/common/utils/package.json, npm run build is defined as:
"build": "gosh ./build.sh -skip-package-install"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@keymanapp/models-types": ["./common/models/types"],
"@keymanapp/models-templates": ["./common/models/templates"],
"@keymanapp/models-wordbreakers": ["./common/models/wordbreakers"],
"@keymanapp/web-utils": ["./common/web/utils"],
"@keymanapp/web-utils": ["./web/src/engine/common/utils"],
"@keymanapp/lm-message-types": ["./common/web/lm-message-types"],
"@keymanapp/keyman-version": ["./common/web/keyman-version"],
"@keymanapp/ldml-keyboard-constants": [ "./core/include/ldml" ],
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
{ "path": "./common/web/recorder/tsconfig.json" },
{ "path": "./common/web/sentry-manager/src/tsconfig.json" },
{ "path": "./common/web/types/" },
{ "path": "./common/web/utils/tsconfig.json" },

{ "path": "./developer/src/common/web/test-helpers/tsconfig.json" },
{ "path": "./developer/src/common/web/utils/tsconfig.json" },
Expand All @@ -45,7 +44,8 @@
{ "path": "./resources/build/version/" },

{ "path": "./web/src/tsconfig.all.json" },
{ "path": "./web/src/engine/common/utils/tsconfig.json" },
// { "path": "./web/tools/recorder/tsconfig.json" },
// { "path": "./web/tools/sourcemap-root/tsconfig.json" },
]
}
}
14 changes: 7 additions & 7 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ graph TD;
IP["common/web/input-processor"];
OSK-->KP;
IP-->KP;
Utils["common/web/utils"];
KP---->Utils;
WebUtils["web/src/engine/common/utils"];
KP---->WebUtils;
Wordbreakers["common/models/wordbreakers"];
Models["common/models/templates"];
Models-->Utils;
Models-->WebUtils;
LMWorker["common/web/lm-worker"];
LMWorker-->Models;
LMWorker-->Wordbreakers;
Expand All @@ -97,19 +97,19 @@ graph TD;
direction LR
KP;
IP;
Utils;
WebUtils;
PredText;
end
subgraph ClassicWeb["Previously unmodularized components"]
Device[web/src/engine/device-detect];
Device----->Utils;
Device----->WebUtils;
Elements[web/src/engine/element-wrappers];
Elements-->KP;
KeyboardCache[web/src/engine/package-cache];
KeyboardCache-->IP;
DomUtils[web/src/engine/dom-utils];
DomUtils-->Utils;
DomUtils-->WebUtils;
OSK-->DomUtils;
OSK---->IP;
Configuration[web/src/engine/paths];
Expand All @@ -133,4 +133,4 @@ graph TD;
Browser--->CommonEngine;
Browser-->Attachment;
end
```
```
2 changes: 2 additions & 0 deletions web/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ builder_describe "Builds engine modules for Keyman Engine for Web (KMW)." \
":app/webview A puppetable version of KMW designed for use in a host app's WebView" \
":app/ui Builds KMW's desktop form-factor keyboard-selection UI modules" \
":engine/attachment Subset used for detecting valid page contexts for use in text editing " \
":engine/common/utils Web-oriented utility function module. " \
":engine/device-detect Subset used for device-detection " \
":engine/dom-utils A common subset of function used for DOM calculations, layout, etc" \
":engine/events Specialized classes utilized to support KMW API events" \
Expand Down Expand Up @@ -53,6 +54,7 @@ builder_describe_outputs \
build:app/webview "/web/build/app/webview/${config}/keymanweb-webview.js" \
build:app/ui "/web/build/app/ui/${config}/kmwuitoggle.js" \
build:engine/attachment "/web/build/engine/attachment/lib/index.mjs" \
build:engine/common/utils "/web/build/engine/common/utils/lib/index.mjs" \
build:engine/device-detect "/web/build/engine/device-detect/lib/index.mjs" \
build:engine/dom-utils "/web/build/engine/dom-utils/obj/index.js" \
build:engine/events "/web/build/engine/events/lib/index.mjs" \
Expand Down
6 changes: 5 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"types": "./build/engine/attachment/obj/index.d.ts",
"import": "./build/engine/attachment/obj/index.js"
},
"./engine/common/utils": {
"es6-bundling": "./src/engine/common/utils/src/index.ts",
"types": "./build/engine/common/utils/obj/index.d.ts",
"import": "./build/engine/common/utils/obj/index.js"
},
"./engine/paths": {
"es6-bundling": "./src/engine/paths/src/index.ts",
"types": "./build/engine/paths/obj/index.d.ts",
Expand Down Expand Up @@ -105,7 +110,6 @@
"@keymanapp/lexical-model-layer": "*",
"@keymanapp/models-types": "*",
"@keymanapp/recorder-core": "*",
"@keymanapp/web-utils": "*",
"core-js": "^3.34.0",
"eventemitter3": "^5.0.0",
"tslib": "^2.5.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"reports-dir": "../../../../build/coverage",
"src": [
"src/"
]
Expand Down
File renamed without changes.
24 changes: 14 additions & 10 deletions common/web/utils/build.sh → web/src/engine/common/utils/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
## 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"
# shellcheck disable=SC2154
. "${KEYMAN_ROOT}/resources/shellHelperFunctions.sh"

BUNDLE_CMD="node $KEYMAN_ROOT/common/web/es-bundling/build/common-bundle.mjs"
BUNDLE_CMD="node ${KEYMAN_ROOT}/common/web/es-bundling/build/common-bundle.mjs"

################################ Main script ################################

# shellcheck disable=SC2154
builder_describe \
"Compiles the web-oriented utility function module." \
"@/common/web/keyman-version" \
Expand All @@ -23,21 +25,22 @@ builder_describe \

builder_describe_outputs \
configure "/node_modules" \
build "/common/web/utils/build/obj/index.js"
build "/web/src/engine/common/utils/build/lib/index.mjs"

builder_parse "$@"

function do_build() {
tsc --build "$THIS_SCRIPT_PATH/tsconfig.json"
# shellcheck disable=SC2154
tsc --build "${THIS_SCRIPT_PATH}/tsconfig.json"

# May be useful one day, for building a mass .d.ts for KMW as a whole.
# So... tsc does declaration-bundling on its own pretty well, at least for local development.
tsc --emitDeclarationOnly --outFile ./build/lib/index.d.ts
tsc --emitDeclarationOnly --outFile "${KEYMAN_ROOT}/web/src/engine/common/utils/build/lib/index.d.ts"

# One of the functions (timedPromise) is quite helpful for automated testing, even in the DOM.
# So, to make sure it's easily-accessible for the DOM-based tests...
$BUNDLE_CMD "${KEYMAN_ROOT}/common/web/utils/build/obj/index.js" \
--out "${KEYMAN_ROOT}/common/web/utils/build/lib/index.mjs" \
${BUNDLE_CMD} "${KEYMAN_ROOT}/web/src/engine/common/utils/build/obj/index.js" \
--out "${KEYMAN_ROOT}/web/src/engine/common/utils/build/lib/index.mjs" \
--format esm
}

Expand All @@ -47,10 +50,11 @@ function do_test() {
local FLAGS=
if builder_has_option --ci; then
echo "Replacing user-friendly test reports with CI-friendly versions."
FLAGS="$FLAGS --reporter mocha-teamcity-reporter"
FLAGS="${FLAGS} --reporter mocha-teamcity-reporter"
fi

c8 mocha --recursive $FLAGS ./src/test/
# shellcheck disable=SC2086
c8 mocha --recursive ${FLAGS} ./src/test/
}

builder_run_action configure verify_npm_setup
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.kmw-main-base.json",
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"tsBuildInfoFile": "./build/obj/tsconfig.tsbuildinfo",
"baseUrl": "./",
Expand Down
2 changes: 1 addition & 1 deletion web/src/engine/device-detect/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SUBPROJECT_NAME=engine/device-detect

builder_describe "Builds the device-detection component of Keyman Engine for Web (KMW)." \
"@/common/web/keyman-version" \
"@/common/web/utils" \
"@/web/src/engine/common/utils build" \
"clean" \
"configure" \
"build" \
Expand Down
2 changes: 1 addition & 1 deletion web/src/engine/device-detect/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import StyleConstants from './utils/styleConstants.js';
import { DeviceSpec, Version } from "@keymanapp/web-utils";
import { DeviceSpec, Version } from '@keymanapp/web-utils';

// The Device object definition -------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion web/src/engine/device-detect/src/utils/styleConstants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeviceSpec } from "@keymanapp/web-utils";
import { DeviceSpec } from '@keymanapp/web-utils';

/*
* This file is intended for CSS-styling constants that see use with the OSK.
Expand Down
2 changes: 1 addition & 1 deletion web/src/engine/dom-utils/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ SUBPROJECT_NAME=engine/dom-utils
# ################################ Main script ################################

builder_describe "Builds DOM-utility modules used by the Keyman Engine for Web (KMW)." \
"@/common/web/utils" \
"@/common/web/keyboard-processor" \
"@/web/src/engine/common/utils build" \
"clean" \
"configure" \
"build" \
Expand Down
2 changes: 1 addition & 1 deletion web/src/engine/events/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SUBPROJECT_NAME=engine/events
# ################################ Main script ################################

builder_describe "Builds specialized event-related modules utilized by Keyman Engine for Web." \
"@/common/web/utils build" \
"@../common/utils build" \
"@/common/web/keyboard-processor build" \
"clean" \
"configure" \
Expand Down

0 comments on commit 785505d

Please sign in to comment.