Merge pull request #6628 from keymanapp/chore/web/move-common-core-web-to-common-web

chore(web): move common/core/web to common/web 🎡
This commit is contained in:
Marc Durdin 2022-05-27 09:05:05 +10:00 committed by GitHub
commit 3fe15a75cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
138 changed files with 246 additions and 211 deletions

1
.github/labeler.yml vendored
View file

@ -21,7 +21,6 @@ common/:
- resources/**
common/core/: common/core/**
common/core/desktop/: common/core/desktop/**
common/core/web/: common/core/web/**
common/models/: common/models/**
common/models/types/: common/models/types/**

View file

@ -147,7 +147,7 @@ if [ "$DO_COPY" = true ]; then
cp $KMW_ROOT/release/$KMW_PATH/embedded/resources/osk/kmwosk.css $KMEA_ASSETS/kmwosk.css
cp $KMW_ROOT/release/$KMW_PATH/embedded/resources/osk/keymanweb-osk.ttf $KMEA_ASSETS/keymanweb-osk.ttf
cp $KEYMAN_ROOT/common/core/web/tools/sentry-manager/build/index.js $KMEA_ASSETS/keyman-sentry.js
cp $KEYMAN_ROOT/common/web/sentry-manager/build/index.js $KMEA_ASSETS/keyman-sentry.js
if [ $? -ne 0 ]; then
die "ERROR: copying artifacts failed"

View file

@ -9,7 +9,7 @@
"target": "es5",
},
"references": [
{ "path": "../../core/web/utils" },
{ "path": "../../web/utils" },
{ "path": "../types" }
],
"include": [

View file

@ -11,7 +11,7 @@
"lib": ["es6"]
},
"references": [
{ "path": "../core/web/utils" },
{ "path": "../web/utils" },
{ "path": "../web/es6-shim" },
{ "path": "../models/types"},
{ "path": "../models/wordbreakers"},

View file

@ -63,7 +63,7 @@ if [ $BUILD_LMLAYER = true ]; then
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
cd ../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 ""
@ -84,6 +84,6 @@ fi
# Compile web's `keyboard-processor` module.
echo "Compiling Input Processor module..."
npm run tsc -- -b src/tsconfig.json || fail "Failed to compile the core/web/input-processor module."
npm run tsc -- -b src/tsconfig.json || fail "Failed to compile the web/input-processor module."
echo "Input Processor module compilation successful."
echo ""

View file

@ -1,6 +1,6 @@
// Implements Node's EventEmitter class and related module components in a near
// browser-compatible way. (Just requires a blank 'module' object on the window.)
///<reference path="../../../../../../node_modules/eventemitter3/index.js" />
///<reference path="../../../../../node_modules/eventemitter3/index.js" />
// Unfortunately, I can't get it to recognize type information properly
// because we can't use require statements. So, a small-scale manual definition.

View file

@ -1,5 +1,5 @@
{
"extends": "../../../../../tsconfig-base.json",
"extends": "../../../../tsconfig-base.json",
"compilerOptions": {
"allowJs": true,
"module": "none",
@ -13,15 +13,15 @@
"outFile": "../build/index.js"
},
"references": [
{ "path": "../../../../web/web-environment" },
{ "path": "../../web-environment" },
{ "path": "../../utils" },
{ "path": "../../keyboard-processor/src" },
{ "path": "../../../../predictive-text/browser.tsconfig.json" },
{ "path": "../../../../web/es6-shim" }
{ "path": "../../../predictive-text/browser.tsconfig.json" },
{ "path": "../../es6-shim" }
],
"include": ["./**/*.ts"],
"files": [
"text/inputProcessor.ts",
"../../../../../node_modules/eventemitter3/index.js"
"../../../../node_modules/eventemitter3/index.js"
]
}

View file

@ -1,18 +1,19 @@
#!/bin/bash
# We should work within the script's directory, not the one we were called in.
cd $(dirname "$BASH_SOURCE")
WORKING_DIRECTORY=`pwd`
set -eu
# Include useful testing resource functions
## 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"
. "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh"
## END STANDARD BUILD SCRIPT INCLUDE
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
# We should work within the script's directory, not the one we were called in.
cd "$THIS_SCRIPT_PATH"
# A simple utility script to facilitate unit-testing for the LM Layer.
# It's rigged to be callable by NPM to facilitate testing during development when in other folders.
@ -67,7 +68,7 @@ test-headless ( ) {
# TODO: Poor Man's Modules until we support ES6 throughout
PREPEND=./tests/cases/prepend.js
(cat ../../../web/web-environment/build/index.js; echo) > $PREPEND
(cat ../web-environment/build/index.js; echo) > $PREPEND
(cat ../utils/build/index.js; echo) >> $PREPEND
(cat ../keyboard-processor/build/index.js; echo) >> $PREPEND
(cat ../input-processor/build/index.js; echo) >> $PREPEND
@ -76,12 +77,12 @@ test-headless ( ) {
npm run mocha -- --recursive $FLAGS ./tests/cases/prepend.js
PREPEND=./tests/cases/prepend.js
(cat ../../../web/web-environment/build/index.js; echo) > $PREPEND
(cat ../../../predictive-text/build/headless.js; echo) >> $PREPEND
(cat ../web-environment/build/index.js; echo) > $PREPEND
(cat ../../predictive-text/build/headless.js; echo) >> $PREPEND
(cat ../utils/build/index.js; echo) >> $PREPEND
(cat ../keyboard-processor/build/index.js; echo) >> $PREPEND
(cat ../input-processor/build/index.js; echo) >> $PREPEND
(cat ../../../web/lm-worker/build/index.js; echo) >> $PREPEND
(cat ../lm-worker/build/index.js; echo) >> $PREPEND
(cat tests/cases/languageProcessor.js; echo) >> $PREPEND
npm run mocha -- --recursive $FLAGS ./tests/cases/prepend.js
@ -91,7 +92,7 @@ test-headless ( ) {
if [ $FETCH_DEPS = true ]; then
# First, run tests on the keyboard processor.
pushd "$KEYMAN_ROOT/common/core/web/keyboard-processor"
pushd "$KEYMAN_ROOT/common/web/keyboard-processor"
./test.sh -skip-package-install || fail "Tests failed by dependencies; aborting integration tests."
popd
fi

View file

@ -36,7 +36,7 @@ describe('InputProcessor', function() {
assert.isUndefined(core.activeModel); // Same for the model.
// These checks are lifted from the keyboard-processor init checks found in
// common/core/web/keyboard-processor/tests/cases/basic-init.js.
// common/web/keyboard-processor/tests/cases/basic-init.js.
assert.equal('us', core.keyboardProcessor.baseLayout, 'KeyboardProcessor has unexpected base layout')
assert.isNotNull(global.KeymanWeb, 'KeymanWeb global was not automatically installed');
assert.equal('default', core.keyboardProcessor.layerId, 'Default layer is not set to "default"');
@ -79,7 +79,7 @@ describe('InputProcessor', function() {
// These two lines will load a keyboard from its file; headless-mode `registerKeyboard` will
// automatically set the keyboard as active.
let kbdScript = new vm.Script(fs.readFileSync('../tests/resources/keyboards/test_chirality.js'));
let kbdScript = new vm.Script(fs.readFileSync('../../test/resources/keyboards/test_chirality.js'));
kbdScript.runInThisContext();
keyboard = core.activeKeyboard;

View file

@ -6,7 +6,7 @@ var vm = require("vm");
* Unit tests for the Dummy prediction model.
*/
var LexicalModelCompiler = require('../../../../../../developer/js/dist/lexical-model-compiler/lexical-model-compiler').default;
var LexicalModelCompiler = require('../../../../../developer/js/dist/lexical-model-compiler/lexical-model-compiler').default;
var path = require('path');
// Required initialization setup.
@ -30,7 +30,7 @@ describe('LanguageProcessor', function() {
let languageProcessor = new LanguageProcessor();
// These checks are lifted from the keyboard-processor init checks found in
// common/core/web/keyboard-processor/tests/cases/basic-init.js.
// common/web/keyboard-processor/tests/cases/basic-init.js.
assert.isUndefined(languageProcessor.lmEngine);
assert.isUndefined(languageProcessor.activeModel);
assert.isFalse(languageProcessor.isActive);
@ -46,7 +46,7 @@ describe('LanguageProcessor', function() {
describe('.predict', function() {
let compiler = new LexicalModelCompiler();
const MODEL_ID = 'example.qaa.trivial';
const PATH = path.join(__dirname, '../../../../../../developer/js/tests/fixtures', MODEL_ID);
const PATH = path.join(__dirname, '../../../../../developer/js/tests/fixtures', MODEL_ID);
describe('using angle brackets for quotes', function() {
let modelCode = compiler.generateLexicalModelCode(MODEL_ID, {

View file

@ -48,4 +48,4 @@ if [ $FETCH_DEPS = true ]; then
fi
# Compile web's `keyboard-processor` module.
npm run tsc -- -b src/tsconfig.json || fail "Failed to compile the core/web/keyboard-processor module."
npm run tsc -- -b src/tsconfig.json || fail "Failed to compile the web/keyboard-processor module."

View file

@ -1,5 +1,5 @@
{
"extends": "../../../../../tsconfig-base.json",
"extends": "../../../../tsconfig-base.json",
"compilerOptions": {
"allowJs": true,
"module": "none",
@ -14,9 +14,9 @@
"experimentalDecorators": true,
},
"references": [
{ "path": "../../../../../common/models/types" },
{ "path": "../../../../../common/web/web-environment/" },
{ "path": "../../../../../common/core/web/utils/" }
{ "path": "../../../models/types" },
{ "path": "../../web-environment/" },
{ "path": "../../utils/" }
],
"include": ["./**/*.ts"],
"files": ["text/outputTarget.ts", "text/keyboardProcessor.ts"]

View file

@ -1,16 +1,19 @@
#!/bin/bash
# We should work within the script's directory, not the one we were called in.
cd $(dirname "$BASH_SOURCE")
set -eu
# Include useful testing resource functions
## 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"
. "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh"
## END STANDARD BUILD SCRIPT INCLUDE
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
# We should work within the script's directory, not the one we were called in.
cd "$THIS_SCRIPT_PATH"
# A simple utility script to facilitate unit-testing for the LM Layer.
# It's rigged to be callable by NPM to facilitate testing during development when in other folders.
@ -60,9 +63,9 @@ test-headless ( ) {
rm -f $PREPEND
for n in tests/cases/*.js; do
echo $n
(cat ../../../web/web-environment/build/index.js; echo) > $PREPEND
(cat ../web-environment/build/index.js; echo) > $PREPEND
(cat ../utils/build/index.js; echo) >> $PREPEND
(cat ../tools/recorder/build/nodeProctor/index.js; echo) >> $PREPEND
(cat ../recorder/build/nodeProctor/index.js; echo) >> $PREPEND
(cat ../keyboard-processor/build/index.js; echo) >> $PREPEND
(cat $n; echo) >> $PREPEND;
npm run mocha -- --recursive $FLAGS $PREPEND || die
@ -74,9 +77,9 @@ test-headless ( ) {
rm -f $PREPEND
for n in tests/cases/engine/*.js; do
echo $n
(cat ../../../web/web-environment/build/index.js; echo) > $PREPEND
(cat ../web-environment/build/index.js; echo) > $PREPEND
(cat ../utils/build/index.js; echo) >> $PREPEND
(cat ../tools/recorder/build/nodeProctor/index.js; echo) >> $PREPEND
(cat ../recorder/build/nodeProctor/index.js; echo) >> $PREPEND
(cat ../keyboard-processor/build/index.js; echo) >> $PREPEND
(cat $n; echo) >> $PREPEND;
npm run mocha -- --recursive $FLAGS $PREPEND || die
@ -88,7 +91,7 @@ test-headless ( ) {
if [ $FETCH_DEPS = true ]; then
# Build test dependency
pushd "$KEYMAN_ROOT/common/core/web/tools/recorder/src"
pushd "$KEYMAN_ROOT/common/web/recorder/src"
./build.sh -skip-package-install || fail "recorder-core compilation failed."
popd
fi

View file

@ -9,7 +9,7 @@ global.keyman = {};
String.kmwEnableSupplementaryPlane(false);
describe('Engine - Basic Simulation', function() {
let testJSONtext = fs.readFileSync('../tests/resources/json/engine_tests/basic_lao_simulation.json');
let testJSONtext = fs.readFileSync('../../test/resources/json/engine_tests/basic_lao_simulation.json');
// Common test suite setup.
let testSuite = new KMWRecorder.KeyboardTest(JSON.parse(testJSONtext));
@ -27,7 +27,7 @@ describe('Engine - Basic Simulation', function() {
// These two lines will load a keyboard from its file; headless-mode `registerKeyboard` will
// automatically set the keyboard as active.
var script = new vm.Script(fs.readFileSync('../tests/' + testSuite.keyboard.filename));
var script = new vm.Script(fs.readFileSync('../../test/' + testSuite.keyboard.filename));
script.runInThisContext();
keyboard = kp.activeKeyboard;

View file

@ -32,7 +32,7 @@ describe('KeyboardProcessor', function() {
// These two lines will load a keyboard from its file; headless-mode `registerKeyboard` will
// automatically set the keyboard as active.
var script = new vm.Script(fs.readFileSync('../tests/resources/keyboards/khmer_angkor.js'));
var script = new vm.Script(fs.readFileSync('../../test/resources/keyboards/khmer_angkor.js'));
script.runInThisContext();
assert.isDefined(kp.activeKeyboard, 'Keyboard failed to register on script load');

View file

@ -9,7 +9,7 @@ global.keyman = {};
String.kmwEnableSupplementaryPlane(false);
describe('Engine - Chirality', function() {
let testJSONtext = fs.readFileSync('../tests/resources/json/engine_tests/chirality.json');
let testJSONtext = fs.readFileSync('../../test/resources/json/engine_tests/chirality.json');
// Common test suite setup.
let testSuite = new KMWRecorder.KeyboardTest(JSON.parse(testJSONtext));
@ -27,7 +27,7 @@ describe('Engine - Chirality', function() {
// These two lines will load a keyboard from its file; headless-mode `registerKeyboard` will
// automatically set the keyboard as active.
var script = new vm.Script(fs.readFileSync('../tests/' + testSuite.keyboard.filename));
var script = new vm.Script(fs.readFileSync('../../test/' + testSuite.keyboard.filename));
script.runInThisContext();
keyboard = kp.activeKeyboard;

View file

@ -10,7 +10,7 @@ global.com = com;
String.kmwEnableSupplementaryPlane(false);
describe('Engine - Deadkeys', function() {
let testJSONtext = fs.readFileSync('../tests/resources/json/engine_tests/deadkeys.json');
let testJSONtext = fs.readFileSync('../../test/resources/json/engine_tests/deadkeys.json');
// Common test suite setup.
let testSuite = new KMWRecorder.KeyboardTest(JSON.parse(testJSONtext));
@ -28,7 +28,7 @@ describe('Engine - Deadkeys', function() {
// These two lines will load a keyboard from its file; headless-mode `registerKeyboard` will
// automatically set the keyboard as active.
var script = new vm.Script(fs.readFileSync('../tests/' + testSuite.keyboard.filename));
var script = new vm.Script(fs.readFileSync('../../test/' + testSuite.keyboard.filename));
script.runInThisContext();
keyboard = kp.activeKeyboard;

View file

@ -987,7 +987,7 @@ describe('Engine - Context Matching', function() {
// These two lines will load a keyboard from its file; headless-mode `registerKeyboard` will
// automatically set the keyboard as active.
var script = new vm.Script(fs.readFileSync('../tests/resources/keyboards/test_simple_deadkeys.js'));
var script = new vm.Script(fs.readFileSync('../../test/resources/keyboards/test_simple_deadkeys.js'));
script.runInThisContext();
keyboard = kp.activeKeyboard;

View file

@ -54,7 +54,7 @@ describe('Engine - notany() and context()', function() {
// These two lines will load a keyboard from its file; headless-mode `registerKeyboard` will
// automatically set the keyboard as active.
const script = new vm.Script(fs.readFileSync('../tests/resources/keyboards/test_917.js'));
const script = new vm.Script(fs.readFileSync('../../test/resources/keyboards/test_917.js'));
script.runInThisContext();
keyboard = kp.activeKeyboard;

View file

@ -9,7 +9,7 @@ global.keyman = {};
String.kmwEnableSupplementaryPlane(false);
describe('Engine - Unmatched Final Groups', function() {
let testJSONtext = fs.readFileSync('../tests/resources/json/engine_tests/ghp_enter.json');
let testJSONtext = fs.readFileSync('../../test/resources/json/engine_tests/ghp_enter.json');
// Common test suite setup.
let testSuite = new KMWRecorder.KeyboardTest(JSON.parse(testJSONtext));
@ -27,7 +27,7 @@ describe('Engine - Unmatched Final Groups', function() {
// These two lines will load a keyboard from its file; headless-mode `registerKeyboard` will
// automatically set the keyboard as active.
var script = new vm.Script(fs.readFileSync('../tests/' + testSuite.keyboard.filename));
var script = new vm.Script(fs.readFileSync('../../test/' + testSuite.keyboard.filename));
script.runInThisContext();
keyboard = kp.activeKeyboard;

View file

@ -17,7 +17,7 @@
{ "path": "../lm-message-types" },
// modules
{ "path": "../web-environment", "prepend": true },
{ "path": "../../core/web/utils", "prepend": true },
{ "path": "../utils", "prepend": true },
{ "path": "../../models/templates", "prepend": true },
{ "path": "../../models/wordbreakers", "prepend": true },
],

View file

@ -4,15 +4,16 @@
# - the Recorder module (for engine tests)
# - the DOM module (for touch-alias and element-interface tests)
set -eu
## 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]}")"
SCRIPT_DIR="$(dirname "$THIS_SCRIPT")"
KEYMAN_ROOT="$(dirname "$THIS_SCRIPT")/../../../../../.."
. "$KEYMAN_ROOT/resources/build/build-utils.sh"
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
. "$(dirname "$THIS_SCRIPT")/../../../../resources/build/build-utils.sh"
## END STANDARD BUILD SCRIPT INCLUDE
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
display_usage ( ) {
echo "build.sh [-skip-package-install]"
echo
@ -46,23 +47,12 @@ if [ $FETCH_DEPS = true ]; then
verify_npm_setup
fi
# Definition of global compile constants
OUTPUT_DIR="build"
OUTPUT="index.js"
# Ensures that we rely first upon the local npm-based install of Typescript.
# (Facilitates automated setup for build agents.)
PATH="../node_modules/.bin:$PATH"
compiler="npm run tsc --"
compilecmd="$compiler"
$compilecmd --build "$SCRIPT_DIR/tsconfig.json"
npm run tsc -- --build "$THIS_SCRIPT_PATH/tsconfig.json"
if [ $? -ne 0 ]; then
fail "KeymanWeb recorder-core compilation failed."
fi
$compilecmd --build "$SCRIPT_DIR/nodeProctor.tsconfig.json"
npm run tsc -- --build "$THIS_SCRIPT_PATH/nodeProctor.tsconfig.json"
if [ $? -ne 0 ]; then
fail "Node-based unit-test Proctor compilation failed."
fi

View file

@ -1,5 +1,5 @@
{
"extends": "../../../../../../tsconfig-base.json",
"extends": "../../../../tsconfig-base.json",
"compilerOptions": {
"allowJs": true,
@ -20,9 +20,9 @@
],
"references": [
{ "path": "../../../../../web/web-environment" },
{ "path": "../../../../../core/web/utils" },
{ "path": "../../../../../core/web/keyboard-processor/src" },
{ "path": "../../../../../web/lm-message-types" }
{ "path": "../../web-environment" },
{ "path": "../../utils" },
{ "path": "../../keyboard-processor/src" },
{ "path": "../../lm-message-types" }
]
}

View file

@ -1,5 +1,5 @@
{
"extends": "../../../../../../tsconfig-base.json",
"extends": "../../../../tsconfig-base.json",
"compilerOptions": {
"allowJs": true,
@ -19,9 +19,9 @@
],
"references": [
{ "path": "../../../../../web/web-environment" },
{ "path": "../../../../../core/web/utils" },
{ "path": "../../../../../core/web/keyboard-processor/src" },
{ "path": "../../../../../web/lm-message-types" }
{ "path": "../../web-environment" },
{ "path": "../../utils" },
{ "path": "../../keyboard-processor/src" },
{ "path": "../../lm-message-types" }
]
}

Some files were not shown because too many files have changed in this diff Show more