diff --git a/common/core/web/input-processor/.gitignore b/common/core/web/input-processor/.gitignore new file mode 100644 index 0000000000..c613a78f7d --- /dev/null +++ b/common/core/web/input-processor/.gitignore @@ -0,0 +1,18 @@ +# Build products +src/environment.inc.ts + +# Legacy build folders. +output/ +build/ +embedded/ + +# Current build output folder (matches standard node publish location). +dist/ + +# Other local files. +node_modules/ +unit_tests/modernizr.js +source/environment.inc.ts +.idea/**/*.xml +*.iml +*.kpj.user \ No newline at end of file diff --git a/common/core/web/input-processor/README.md b/common/core/web/input-processor/README.md new file mode 100644 index 0000000000..825c2bccee --- /dev/null +++ b/common/core/web/input-processor/README.md @@ -0,0 +1,21 @@ +# Keyman: Keyboard Processor Module +The Original Code is (C) 2017-2020 SIL International + +The Keyboard Processor module is an internal component of KeymanWeb, seen within this repo at /web/. + +## Minimum Compilation Requirements + +* A local installation of [Node.js](https://nodejs.org/) v8.9+. + * Builds will call `npm install` to automatically install further necessary build dependencies. + + * Linux users can run the following to update to LTS version of nodejs + +``` +sudo apt-get install python-software-properties +curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - +sudo apt-get install nodejs +``` + +********************************************************************** + +The build script may be found at src/build.sh. \ No newline at end of file diff --git a/common/core/web/input-processor/package-lock.json b/common/core/web/input-processor/package-lock.json new file mode 100644 index 0000000000..0fc9040409 --- /dev/null +++ b/common/core/web/input-processor/package-lock.json @@ -0,0 +1,318 @@ +{ + "name": "@keymanapp/input-processor", + "version": "14.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "11.15.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-11.15.10.tgz", + "integrity": "sha512-FHli7aK/ViA02vbWKmiNejJW4BCJxCVb6macS5gi71fST+UrrdqcES6Lh5rx23hU1QCBeUNXfPquYr9jJv7FuA==" + }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "eventemitter3": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz", + "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + }, + "dependencies": { + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "source-map-support": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz", + "integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==", + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "ts-node": { + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.8.2.tgz", + "integrity": "sha512-duVj6BpSpUpD/oM4MfhO98ozgkp3Gt9qIp3jGxwU2DFvl/3IRaEAvbLa8G60uS7C77457e/m5TMowjedeRxI1Q==", + "requires": { + "arg": "^4.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.6", + "yn": "3.1.1" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "typescript": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", + "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==" + } + } +} diff --git a/common/core/web/input-processor/package.json b/common/core/web/input-processor/package.json new file mode 100644 index 0000000000..6b1af5aa53 --- /dev/null +++ b/common/core/web/input-processor/package.json @@ -0,0 +1,38 @@ +{ + "name": "@keymanapp/input-processor", + "version": "14.0.0", + "description": "The core text and prediction processing engine for KeymanWeb", + "repository": { + "type": "git", + "url": "git+https://github.com/keymanapp/keyman.git" + }, + "keywords": [ + "input", + "languages", + "keyboards" + ], + "author": "SIL International", + "license": "MIT", + "bugs": { + "url": "https://github.com/keymanapp/keyman/issues" + }, + "homepage": "https://github.com/keymanapp/keyman#readme", + "devDependencies": { + "chai": "^4.2.0", + "mocha": "^5.2.0", + "typescript": "^3.7.2" + }, + "scripts": { + "lerna": "cd ../ && npm run lerna --", + "tsc": "tsc", + "test": "bash ./unit_tests/test.sh" + }, + "dependencies": { + "@keymanapp/keyboard-processor": "^14.0.0", + "@keymanapp/lexical-model-layer": "^14.0.0", + "@keymanapp/lexical-model-types": "^0.0.0", + "@types/node": "^11.9.4", + "eventemitter3": "^4.0.0", + "ts-node": "^8.0.2" + } +} diff --git a/common/core/web/input-processor/src/build.sh b/common/core/web/input-processor/src/build.sh new file mode 100755 index 0000000000..ce0a2c53ed --- /dev/null +++ b/common/core/web/input-processor/src/build.sh @@ -0,0 +1,91 @@ +#! /bin/bash +# +# Compile KeymanWeb's 'keyboard-processor' module, one of the components of Web's 'core' module. +# + +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +. "$(dirname "$THIS_SCRIPT")/../../../../../resources/build/build-utils.sh" +. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" +## END STANDARD BUILD SCRIPT INCLUDE + +# This script runs from its own folder +cd "$(dirname "$THIS_SCRIPT")" + +display_usage ( ) { + echo "build.sh [-skip-package-install | -S] [-test]" + echo + echo " -test to compile for testing without re-fetching external dependencies" + echo " or recompiling the lm-layer module." + echo " -skip-package-install (or -S) skips the `lerna bootstrap` dependency check." + echo "" + echo " If more than one target is specified, the last one will take precedence." + exit 1 +} + +# Establish default build parameters +set_default_vars ( ) { + BUILD_LMLAYER=true + BUILD_CORE=true + FETCH_DEPS=true +} + +set_default_vars + +# Parse args +while [[ $# -gt 0 ]] ; do + key="$1" + case $key in + -test) + set_default_vars + BUILD_LMLAYER=false + FETCH_DEPS=false + ;; + -skip-package-install|-S) + set_default_vars + FETCH_DEPS=false + ;; + esac + shift # past argument +done + +# Generates a linkable TS file; defined in resources/build-utils.sh. +exportEnvironmentDefinitionTS + +if [ $FETCH_DEPS = true ]; then + verify_npm_setup +fi + +if [ $BUILD_LMLAYER = true ]; then + FLAGS="-skip-package-install" + + # Ensure that the LMLayer compiles properly, readying the build product for comsumption by KMW. + cd ../../../../predictive-text/ + echo "" + echo "Compiling the Language Modeling layer module..." + ./build.sh $FLAGS || fail "Failed to compile the language modeling layer module." + cd ../core/web/input-processor/src + # TODO: Move this back to KMW's main build script. Consider it part of the dependency update. + echo "Language Modeling layer compilation successful." + echo "" +fi + +if [ $BUILD_CORE = true ]; then + FLAGS="-skip-package-install" + + # Ensure that the KeyboardProcessor module compiles properly. + cd ../../keyboard-processor/src + echo "" + echo "Compiling Keyboard Processor module..." + ./build.sh $FLAGS || fail "Dependency build failed; aborting" + cd ../../input-processor/src + echo "Keyboard Processor module compilation successful." + echo "" +fi + +# Compile web's `keyboard-processor` module. +echo "Compiling Input Processor module..." +npm run tsc -- -p src/tsconfig.json || fail "Failed to compile the core/web/input-processor module." +echo "Input Processor module compilation successful." +echo "" \ No newline at end of file diff --git a/web/source/includes/events.ts b/common/core/web/input-processor/src/includes/events.ts similarity index 100% rename from web/source/includes/events.ts rename to common/core/web/input-processor/src/includes/events.ts diff --git a/web/source/text/inputProcessor.ts b/common/core/web/input-processor/src/text/inputProcessor.ts similarity index 99% rename from web/source/text/inputProcessor.ts rename to common/core/web/input-processor/src/text/inputProcessor.ts index a2d24f708c..8c28479345 100644 --- a/web/source/text/inputProcessor.ts +++ b/common/core/web/input-processor/src/text/inputProcessor.ts @@ -1,6 +1,5 @@ // Defines a 'polyfill' of sorts for NPM's events module /// -/// /// /// diff --git a/web/source/text/prediction/languageProcessor.ts b/common/core/web/input-processor/src/text/prediction/languageProcessor.ts similarity index 96% rename from web/source/text/prediction/languageProcessor.ts rename to common/core/web/input-processor/src/text/prediction/languageProcessor.ts index 1f2b07ac3e..2b225b8186 100644 --- a/web/source/text/prediction/languageProcessor.ts +++ b/common/core/web/input-processor/src/text/prediction/languageProcessor.ts @@ -1,3 +1,8 @@ +/// +/// +/// +/// + namespace com.keyman.text.prediction { export interface ModelSpec { /** diff --git a/web/source/web-core.tsconfig.json b/common/core/web/input-processor/src/tsconfig.json similarity index 65% rename from web/source/web-core.tsconfig.json rename to common/core/web/input-processor/src/tsconfig.json index 18a391e4fc..6c3a1f1b1f 100644 --- a/web/source/web-core.tsconfig.json +++ b/common/core/web/input-processor/src/tsconfig.json @@ -2,17 +2,17 @@ "compilerOptions": { "allowJs": true, "module": "none", - "outDir": "../intermediate/", + "outDir": "../dist/", "inlineSources": true, "sourceMap": true, "sourceRoot": "/keyman/", "target": "es5", "types": ["node"], "lib": ["es6"], - "outFile": "../intermediate/web-core/index.js" + "outFile": "../dist/index.js" }, "files": [ - "includes/node-lmlayer.ts", + "../node_modules/@keymanapp/lexical-model-layer/node-defaultWorker.ts", "text/inputProcessor.ts" ] } diff --git a/common/core/web/keyboard-processor/.gitignore b/common/core/web/keyboard-processor/.gitignore index a9e0c25514..c613a78f7d 100644 --- a/common/core/web/keyboard-processor/.gitignore +++ b/common/core/web/keyboard-processor/.gitignore @@ -13,6 +13,6 @@ dist/ node_modules/ unit_tests/modernizr.js source/environment.inc.ts -**/.idea/**/*.xml -**/*.iml -**/*.kpj.user \ No newline at end of file +.idea/**/*.xml +*.iml +*.kpj.user \ No newline at end of file diff --git a/common/core/web/keyboard-processor/src/build.sh b/common/core/web/keyboard-processor/src/build.sh index d60b367d10..ea8d7823f8 100755 --- a/common/core/web/keyboard-processor/src/build.sh +++ b/common/core/web/keyboard-processor/src/build.sh @@ -13,10 +13,41 @@ THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BA # This script runs from its own folder cd "$(dirname "$THIS_SCRIPT")" -verify_npm_setup +display_usage ( ) { + echo "build.sh [-skip-package-install | -S] [-test]" + echo + echo " -skip-package-install (or -S) skips the `lerna bootstrap` dependency check." + echo " Intended for use when this script is called by another build script." + echo "" + echo " If more than one target is specified, the last one will take precedence." + exit 1 +} + +# Establish default build parameters +set_default_vars ( ) { + FETCH_DEPS=true +} + +set_default_vars + +# Parse args +while [[ $# -gt 0 ]] ; do + key="$1" + case $key in + -skip-package-install|-S) + set_default_vars + FETCH_DEPS=false + ;; + esac + shift # past argument +done + +if [ $FETCH_DEPS = true ]; then + verify_npm_setup +fi # Generates a linkable TS file; defined in resources/build-utils.sh. exportEnvironmentDefinitionTS # Compile web's `keyboard-processor` module. -npm run tsc -- -p src/tsconfig.json \ No newline at end of file +npm run tsc -- -p src/tsconfig.json || fail "Failed to compile the core/web/keyboard-processor module." \ No newline at end of file diff --git a/common/predictive-text/build.sh b/common/predictive-text/build.sh index 5718b35f25..fa492cb380 100755 --- a/common/predictive-text/build.sh +++ b/common/predictive-text/build.sh @@ -85,13 +85,14 @@ clean ( ) { } display_usage ( ) { - echo "Usage: $0 [-clean] [-test | -tdd]" + echo "Usage: $0 [-clean] [-skip-package-install | -S] [-test | -tdd]" echo " $0 -help" echo - echo " -clean to erase pre-existing build products before a re-build" - echo " -help displays this screen and exits" - echo " -tdd skips dependency updates, builds, then runs unit tests only" - echo " -test runs unit and integration tests after building" + echo " -clean to erase pre-existing build products before a re-build" + echo " -help displays this screen and exits" + echo " -skip-package-install (or -S) skips dependency updates" + echo " -tdd skips dependency updates, builds, then runs unit tests only" + echo " -test runs unit and integration tests after building" } # Creates embedded_worker.js. Must be run after the worker is built for the @@ -149,6 +150,9 @@ while [[ $# -gt 0 ]] ; do display_usage exit ;; + -skip-package-install|-S) + fetch_deps=false + ;; -test) run_tests=1 ;; diff --git a/lerna.json b/lerna.json index 415f34b0d6..677b6d94d3 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,6 @@ { "packages": [ + "common/core/web/input-processor", "common/core/web/keyboard-processor", "common/predictive-text", "common/lexical-model-types", diff --git a/web/bulk_rendering/tsconfig.json b/web/bulk_rendering/tsconfig.json index e2341b97cd..a714f4c308 100644 --- a/web/bulk_rendering/tsconfig.json +++ b/web/bulk_rendering/tsconfig.json @@ -9,7 +9,8 @@ }, "files": [ "../node_modules/@keymanapp/keyboard-processor/src/utils/version.ts", - "../node_modules/@keyman/language-modeling-layer/message.d.ts", + "../node_modules/@keymanapp/keyboard-processor/src/text/engineDeviceSpec.ts", + "../node_modules/@keymanapp/lexical-model-layer/message.d.ts", "renderer_core.ts" ] } diff --git a/web/package.json b/web/package.json index 6cacbdc281..d096ef2c3d 100644 --- a/web/package.json +++ b/web/package.json @@ -47,6 +47,7 @@ "modernizr": "modernizr" }, "dependencies": { + "@keymanapp/input-processor": "^14.0.0", "@keymanapp/keyboard-processor": "^14.0.0", "@keymanapp/lexical-model-layer": "^14.0.0", "@keymanapp/lexical-model-types": "^0.0.0", diff --git a/web/source/build-web-core.sh b/web/source/build-web-core.sh deleted file mode 100755 index 2117b325fd..0000000000 --- a/web/source/build-web-core.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/bash -# -# Compile KeymanWeb's 'keyboard-processor' module, one of the components of Web's 'core' module. -# - -## START STANDARD BUILD SCRIPT INCLUDE -# adjust relative paths as necessary -THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" -. "$(dirname "$THIS_SCRIPT")/../../resources/build/build-utils.sh" -## END STANDARD BUILD SCRIPT INCLUDE - -# This script runs from its own folder -cd "$(dirname "$THIS_SCRIPT")" - -# Generates a linkable TS file; defined in resources/build-utils.sh. -exportEnvironmentDefinitionTS - -# Compile web's `keyboard-processor` module. -npm run tsc -- -p source/web-core.tsconfig.json \ No newline at end of file diff --git a/web/source/build.sh b/web/source/build.sh index cbbd87548f..1c41984a41 100755 --- a/web/source/build.sh +++ b/web/source/build.sh @@ -227,6 +227,7 @@ set_default_vars ( ) { BUILD_DEBUG_EMBED=false BUILD_COREWEB=true DO_MINIFY=true + FETCH_DEPS=true } if [[ $# = 0 ]]; then @@ -256,6 +257,7 @@ while [[ $# -gt 0 ]] ; do BUILD_UI=false BUILD_EMBED=false BUILD_FULLWEB=false + FETCH_DEPS=false ;; -embed) set_default_vars @@ -296,8 +298,13 @@ readonly BUILD_DEBUG_EMBED readonly BUILD_COREWEB readonly DO_MINIFY -# Ensure the dependencies are downloaded. --no-optional should help block fsevents warnings. -verify_npm_setup +if [ $FETCH_DEPS = true ]; then + # Ensure the dependencies are downloaded. + verify_npm_setup + + echo "Copying testing resource ${PREDICTIVE_TEXT_SOURCE} to ${PREDICTIVE_TEXT_OUTPUT}" + cp "${PREDICTIVE_TEXT_SOURCE}" "${PREDICTIVE_TEXT_OUTPUT}" || fail "Failed to copy predictive text model" +fi if [ $DO_MINIFY = true ]; then # NPM install is required for the file to be present. @@ -307,33 +314,27 @@ if [ $DO_MINIFY = true ]; then exit 1 fi - # Also, build our sourcemap-root tool for cleaning up the minified version's sourcemaps. - echo "Compiling build tools for minified build products" - $compiler --build "source/$minified_sourcemap_cleaner/tsconfig.json" - assert "$minified_sourcemap_cleaner/index.js" -fi - -if [ $BUILD_LMLAYER = true ]; then - # Ensure that the LMLayer compiles properly, readying the build product for comsumption by KMW. - cd ../../common/predictive-text/ - echo "" - echo "Compiling the Language Modeling layer module..." - ./build.sh || fail "Failed to compile the language modeling layer module." - cd ../../web/source - echo "Copying ${PREDICTIVE_TEXT_SOURCE} to ${PREDICTIVE_TEXT_OUTPUT}" - cp "${PREDICTIVE_TEXT_SOURCE}" "${PREDICTIVE_TEXT_OUTPUT}" || fail "Failed to copy predictive text model" - echo "Language Modeling layer compilation successful." - echo "" + if [ $FETCH_DEPS = true ]; then + # Also, build our sourcemap-root tool for cleaning up the minified version's sourcemaps. + echo "Compiling build tools for minified build products" + $compiler --build "source/$minified_sourcemap_cleaner/tsconfig.json" + assert "$minified_sourcemap_cleaner/index.js" + fi fi if [ $BUILD_CORE = true ]; then - # Ensure that the KeyboardProcessor module compiles properly. - cd ../../common/core/web/keyboard-processor/src + CORE_FLAGS="-skip-package-install" + if [ $BUILD_LMLAYER = false ]; then + CORE_FLAGS="$CORE_FLAGS -test" + fi + + # Ensure that the Input Processor module compiles properly. + cd ../../common/core/web/input-processor/src echo "" - echo "Compiling KMW's Keyboard Processor module..." - ./build.sh || fail "Failed to compile the core/web/keyboard-processor module." + echo "${TERM_HEADING}Compiling local KeymanWeb dependencies...${NORMAL}" + ./build.sh $CORE_FLAGS || fail "Failed to compile KeymanWeb dependencies" cd $WORKING_DIRECTORY - echo "Keyboard Processor module compilation successful." + echo "${TERM_HEADING}Local KeymanWeb dependency compilations completed successfully.${NORMAL}" echo "" fi diff --git a/web/source/dom/targets/touchAlias.ts b/web/source/dom/targets/touchAlias.ts index 549068be04..11b68a1810 100644 --- a/web/source/dom/targets/touchAlias.ts +++ b/web/source/dom/targets/touchAlias.ts @@ -1,7 +1,5 @@ // Defines the TouchAliasElement merged type. /// -// Defines the OutputTarget interface. -/// namespace com.keyman.dom.targets { export class TouchAlias extends OutputTarget { diff --git a/web/source/dom/touchAliasElement.ts b/web/source/dom/touchAliasElement.ts index c8164897ac..933c9b4edf 100644 --- a/web/source/dom/touchAliasElement.ts +++ b/web/source/dom/touchAliasElement.ts @@ -1,5 +1,3 @@ -// References the KMW string extensions. -/// // References extra HTML definitions not included by default in TS. /// // References device-specific code checks (separable module from KMW) diff --git a/web/source/includes/dom-lmlayer.ts b/web/source/includes/dom-lmlayer.ts deleted file mode 100644 index 36c3985498..0000000000 --- a/web/source/includes/dom-lmlayer.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Defines the reference-path tags necessary to link properly with common/predictive-text. - */ - -// Defines the main interface of the Language Modeling Layer (LMLayer) and its original typing information. -/// -/// -/// - -// We DO need the embedded_worker.d.ts file - since we're directly linking into the LMLayer's code, -// we need the typedef for the embedded worker to be linked. \ No newline at end of file diff --git a/web/source/includes/lmMsgs.d.ts b/web/source/includes/lmMsgs.d.ts deleted file mode 100644 index c91043a7ba..0000000000 --- a/web/source/includes/lmMsgs.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// \ No newline at end of file diff --git a/web/source/includes/node-lmlayer.ts b/web/source/includes/node-lmlayer.ts deleted file mode 100644 index 5d2e3ba8bf..0000000000 --- a/web/source/includes/node-lmlayer.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Defines the reference-path tags necessary to link properly with common/predictive-text. - */ - -// Defines the main interface of the Language Modeling Layer (LMLayer) and its original typing information. -/// -/// -/// - -// We DO need the embedded_worker.d.ts file - since we're directly linking into the LMLayer's code, -// we need the typedef for the embedded worker to be linked. \ No newline at end of file diff --git a/web/source/kmwbase.ts b/web/source/kmwbase.ts index 815efdcb5f..0ca1f26083 100644 --- a/web/source/kmwbase.ts +++ b/web/source/kmwbase.ts @@ -7,7 +7,7 @@ // Defines the web-page interface object. /// // Defines the core text processor. -/// +/// // Extends KeyboardInterface with DOM-oriented offerings. /// // Defines the web-page interface object. diff --git a/web/source/kmwdevice.ts b/web/source/kmwdevice.ts index d4f9321780..335f9a3fba 100644 --- a/web/source/kmwdevice.ts +++ b/web/source/kmwdevice.ts @@ -1,7 +1,5 @@ // Includes version-related functionality -/// /// -/// // The Device object definition ------------------------------------------------- diff --git a/web/source/kmwutils.ts b/web/source/kmwutils.ts index 6247253bdf..16add189c7 100644 --- a/web/source/kmwutils.ts +++ b/web/source/kmwutils.ts @@ -4,8 +4,6 @@ /// // Includes the DOM utils, since our UI modules need access to certain methods here. /// -// Include other important utils -/// namespace com.keyman { class DOMEventTracking { diff --git a/web/source/osk/oskManager.ts b/web/source/osk/oskManager.ts index 4ce7ab3f2d..3d14a0b31b 100644 --- a/web/source/osk/oskManager.ts +++ b/web/source/osk/oskManager.ts @@ -1,6 +1,4 @@ /// // Includes KMW-added property declaration extensions for HTML elements. -// Includes the default layout specification. -/// // Includes the touch-mode language picker UI. /// // Includes the banner diff --git a/web/source/osk/visualKeyboard.ts b/web/source/osk/visualKeyboard.ts index 8943b90336..c54b1deb2b 100644 --- a/web/source/osk/visualKeyboard.ts +++ b/web/source/osk/visualKeyboard.ts @@ -1,4 +1,3 @@ -/// /// namespace com.keyman.osk { diff --git a/web/source/text/domKbdInterface.ts b/web/source/text/domKbdInterface.ts index 678d5bb852..e9662dc77f 100644 --- a/web/source/text/domKbdInterface.ts +++ b/web/source/text/domKbdInterface.ts @@ -1,5 +1,3 @@ -/// - /* * This file defines DOM-specific keyboard API that is not available in headless mode, extending web-core's * base KeyboardInterface offerings. diff --git a/web/source/text/prediction/modelManager.ts b/web/source/text/prediction/modelManager.ts index 86737c48ce..883c84f512 100644 --- a/web/source/text/prediction/modelManager.ts +++ b/web/source/text/prediction/modelManager.ts @@ -1,5 +1,3 @@ -// Defines the text processing KMW core. -/// // Defines the KeyboardManager and its related types. /// diff --git a/web/source/tsconfig.dev_resources.json b/web/source/tsconfig.dev_resources.json index 0b1db1de9f..9513a6759f 100644 --- a/web/source/tsconfig.dev_resources.json +++ b/web/source/tsconfig.dev_resources.json @@ -10,7 +10,7 @@ "files": [ "../node_modules/@keymanapp/keyboard-processor/src/text/outputTarget.ts", "../node_modules/@keymanapp/keyboard-processor/src/utils/version.ts", - "../node_modules/@keymanapp/language-modeling-layer/message.d.ts", + "../node_modules/@keymanapp/lexical-model-layer/message.d.ts", "dom/targets/wrapElement.ts" ] } diff --git a/web/source/tsconfig.embedded.json b/web/source/tsconfig.embedded.json index a67eda5f8d..f4ec6bcfec 100644 --- a/web/source/tsconfig.embedded.json +++ b/web/source/tsconfig.embedded.json @@ -4,7 +4,7 @@ "outFile": "../intermediate/keyman.js" }, "files": [ - "includes/dom-lmlayer.ts", + "../node_modules/@keymanapp/lexical-model-layer/web-defaultWorker.ts", "kmwbase.ts", "keymanweb.ts", "kmwembedded.ts", diff --git a/web/source/tsconfig.recorder.json b/web/source/tsconfig.recorder.json index 54b572791f..daaac99145 100644 --- a/web/source/tsconfig.recorder.json +++ b/web/source/tsconfig.recorder.json @@ -9,7 +9,8 @@ }, "files": [ "../node_modules/@keymanapp/keyboard-processor/src/utils/version.ts", - "../node_modules/@keymanapp/language-modeling-layer/message.d.ts", + "../node_modules/@keymanapp/keyboard-processor/src/text/engineDeviceSpec.ts", + "../node_modules/@keymanapp/lexical-model-layer/message.d.ts", "recorder_InputEvents.ts" ] } diff --git a/web/source/tsconfig.web.json b/web/source/tsconfig.web.json index de11bc9315..8d1e8b9788 100644 --- a/web/source/tsconfig.web.json +++ b/web/source/tsconfig.web.json @@ -4,7 +4,7 @@ "outFile": "../intermediate/keymanweb.js" }, "files": [ - "includes/dom-lmlayer.ts", + "../node_modules/@keymanapp/lexical-model-layer/web-defaultWorker.ts", "kmwbase.ts", "keymanweb.ts", "kmwnative.ts",