Skip to content

Commit

Permalink
chore(web): reverts keyboard-processor demodularization from #6597
Browse files Browse the repository at this point in the history
  • Loading branch information
jahorton committed May 23, 2022
1 parent 7e5cd7a commit 60cdd7f
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 81 deletions.
2 changes: 1 addition & 1 deletion common/web/keyboard-processor/src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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]}")"
. "$(dirname "$THIS_SCRIPT")/../../../../../resources/build/build-utils.sh"
. "$(dirname "$THIS_SCRIPT")/../../../../resources/build/build-utils.sh"
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
## END STANDARD BUILD SCRIPT INCLUDE

Expand Down
15 changes: 15 additions & 0 deletions common/web/keyboard-processor/src/tsconfig.bundled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// This variant of the tsconfig.json exists to create a 'leaf', 'bundled'
// version of the keyboard-processor build product. The same reference
// cannot be prepended twice in a composite tsc build, posing problems
// for certain down-line builds if the two tsconfigs are not differentiated.
"extends": "./tsconfig.json",
"compilerOptions": {
"outFile": "../build/index.bundled.js"
},
"references": [
{ "path": "../../../models/types" },
{ "path": "../../web-environment/", "prepend": true },
{ "path": "../../utils/", "prepend": true}
]
}
43 changes: 8 additions & 35 deletions common/web/keyboard-processor/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,43 +58,16 @@ test-headless ( ) {
FLAGS="$FLAGS --reporter mocha-teamcity-reporter"
fi

# Poor Man's Modules until we support ES6 throughout
PREPEND=./tests/cases/prepend.js
rm -f $PREPEND
for n in tests/cases/*.js; do
echo $n
(cat ../web-environment/build/index.js; echo) > $PREPEND
(cat ../utils/build/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
rm $PREPEND
done

# Poor Man's Modules until we support ES6 throughout
PREPEND=./tests/cases/engine/prepend.js
rm -f $PREPEND
for n in tests/cases/engine/*.js; do
echo $n
(cat ../web-environment/build/index.js; echo) > $PREPEND
(cat ../utils/build/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
rm $PREPEND
done

# npm run mocha -- --recursive $FLAGS ./tests/cases/
npm run mocha -- --recursive $FLAGS ./tests/cases/
}

if [ $FETCH_DEPS = true ]; then
# Build test dependency
pushd "$KEYMAN_ROOT/common/web/recorder/src"
./build.sh -skip-package-install || fail "recorder-core compilation failed."
popd
fi
# Build test dependency
pushd "$KEYMAN_ROOT/common/web/recorder/src"
./build.sh -skip-package-install || fail "recorder-core compilation failed."
popd

# Compile web's `keyboard-processor` module."
npm run tsc -- -b src/tsconfig.bundled.json || fail "Failed to compile the testing version of the core/web/keyboard-processor module."

# Run headless (browserless) tests.
echo_heading "Running Keyboard Processor test suite"
Expand Down
9 changes: 5 additions & 4 deletions common/web/keyboard-processor/tests/cases/basic-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');

let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
let KeyboardProcessor = require('../../build/index.bundled.js');

// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.

let KMWRecorder = require('../../../recorder/build/nodeProctor');

describe('Engine - Basic Simulation', function() {
let testJSONtext = fs.readFileSync('../../test/resources/json/engine_tests/basic_lao_simulation.json');
Expand Down
11 changes: 7 additions & 4 deletions common/web/keyboard-processor/tests/cases/basic-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ var assert = require('chai').assert;
var fs = require("fs");
var vm = require("vm");

let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
global.com = com;
let KeyboardProcessor = require('../../build/index.bundled.js');

// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
global.keyman = {}; // So that keyboard-based checks against the global `keyman` succeed.
// 10.0+ dependent keyboards, like khmer_angkor, will otherwise fail to load.

// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
String.kmwEnableSupplementaryPlane(false);

// Test the KeyboardProcessor interface.
describe('KeyboardProcessor', function() {
Expand Down
8 changes: 4 additions & 4 deletions common/web/keyboard-processor/tests/cases/chirality.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');

let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
let KeyboardProcessor = require('../../build/index.bundled.js');
let KMWRecorder = require('../../../recorder/build/nodeProctor');

// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.

describe('Engine - Chirality', function() {
let testJSONtext = fs.readFileSync('../../test/resources/json/engine_tests/chirality.json');
Expand Down
10 changes: 5 additions & 5 deletions common/web/keyboard-processor/tests/cases/deadkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');

let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
global.com = com;
let KeyboardProcessor = require('../../build/index.bundled.js');

// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.

let KMWRecorder = require('../../../recorder/build/nodeProctor');

describe('Engine - Deadkeys', function() {
let testJSONtext = fs.readFileSync('../../test/resources/json/engine_tests/deadkeys.json');
Expand Down
18 changes: 8 additions & 10 deletions common/web/keyboard-processor/tests/cases/engine/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');

let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
global.com = com;
let KeyboardProcessor = require('../../../build/index.bundled.js');

// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.

let KMWRecorder = require('../../../../recorder/build/nodeProctor');

/*
* ABOUT THIS TEST SUITE
Expand Down Expand Up @@ -68,8 +68,7 @@ function runEngineRuleSet(ruleSet, defaultNoun) {
ruleSeq.test(proctor, target);

// Now for the real test!
let processor = new KeyboardProcessor();
processor.device = device;
let processor = new KeyboardProcessor(device);
processor.activeKeyboard = keyboard;
var res = processor.keyboardInterface.fullContextMatch(ruleDef.n, target, ruleDef.rule);

Expand Down Expand Up @@ -983,7 +982,7 @@ var NOTANY_NUL_RULE_SET = [ NOTANY_NUL_TEST_1, NOTANY_NUL_TEST_2, NOTANY_NUL_TES

describe('Engine - Context Matching', function() {
before(function() {
let kp = new KeyboardProcessor();
let kp = new KeyboardProcessor(device);

// These two lines will load a keyboard from its file; headless-mode `registerKeyboard` will
// automatically set the keyboard as active.
Expand All @@ -1008,8 +1007,7 @@ describe('Engine - Context Matching', function() {
ruleSeq.test(proctor, target);

// Now for the real test!
let processor = new KeyboardProcessor();
processor.device = device;
let processor = new KeyboardProcessor(device);
processor.activeKeyboard = keyboard;
var res = processor.keyboardInterface._BuildExtendedContext(ruleDef.n, ruleDef.ln, target);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ const assert = require('chai').assert;
const fs = require('fs');
const vm = require('vm');

let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
let KeyboardProcessor = require('../../../build/index.bundled.js');

// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
global.keyman = {}; // So that keyboard-based checks against the global `keyman` succeed.
// 10.0+ dependent keyboards, like khmer_angkor, will otherwise fail to load.

let KMWRecorder = require('../../../../recorder/build/nodeProctor');

// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
Expand Down
10 changes: 4 additions & 6 deletions common/web/keyboard-processor/tests/cases/engine/stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');

let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
let KeyboardProcessor = require('../../../build/index.bundled.js');

// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.

let device = {
formFactor: 'desktop',
Expand All @@ -23,8 +22,7 @@ describe('Engine - Stores', function() {
}

it('Store \'Explosion\'', function() {
let processor = new KeyboardProcessor();
processor.device = device;
let processor = new KeyboardProcessor(device);
// A 'hollow' Keyboard that only follows default rules. That said, we need a Keyboard
// instance to host cache data for our exploded store tests.
processor.activeKeyboard = new com.keyman.keyboards.Keyboard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');

let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
let KeyboardProcessor = require('../../../build/index.bundled.js');

// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.

let KMWRecorder = require('../../../../recorder/build/nodeProctor');

describe('Engine - Unmatched Final Groups', function() {
let testJSONtext = fs.readFileSync('../../test/resources/json/engine_tests/ghp_enter.json');
Expand Down
5 changes: 3 additions & 2 deletions common/web/keyboard-processor/tests/cases/transcriptions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
var assert = require('chai').assert;
let KeyboardProcessor = require('../../build/index.bundled.js');

global.keyman = {};
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.

// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);

describe("Transcriptions and Transforms", function() {
Expand Down
7 changes: 3 additions & 4 deletions common/web/keyboard-processor/tests/cases/versions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
var assert = require('chai').assert;
let KeyboardProcessor = require('../../build/index.bundled.js');

global.keyman = {};

// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.

describe('Version Logic', function() {
it('Should provide a default, fallback value when nothing is specified', function() {
Expand Down

0 comments on commit 60cdd7f

Please sign in to comment.