From 7aa6d474ac693d11c60ce573f74b2be4f56338c1 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Thu, 22 Jun 2023 14:25:10 +0700 Subject: [PATCH 1/2] chore(web): reorganizes gesture-recognizer source in prep for chopping subsegmentation --- common/web/gesture-recognizer/.c8rc.json | 18 ++++++++++++++++++ common/web/gesture-recognizer/build.sh | 5 ++--- common/web/gesture-recognizer/package.json | 8 ++------ .../gestureRecognizerConfiguration.ts | 0 .../configuration}/paddedZoneSource.ts | 0 .../configuration}/recognitionZoneSource.ts | 0 .../configuration}/viewportZoneSource.ts | 0 .../configuration}/zoneBoundaryChecker.ts | 4 ++-- .../src/{ => engine}/gestureRecognizer.ts | 4 ++-- .../headless}/cumulativePathStats.ts | 0 .../src/{ => engine/headless}/inputSample.ts | 0 .../src/{ => engine/headless}/segment.ts | 0 .../{ => engine/headless}/segmentClassifier.ts | 0 .../subsegmentation}/constructingSegment.ts | 6 +++--- .../headless/subsegmentation}/pathSegmenter.ts | 8 ++++---- .../subsegmentCompatibilityAnalyzer.ts | 2 +- .../src/{ => engine/headless}/trackedPath.ts | 2 +- .../web/gesture-recognizer/src/engine/index.ts | 18 ++++++++++++++++++ .../src/{ => engine}/inputEventEngine.ts | 4 ++-- .../src/{ => engine}/mouseEventEngine.ts | 6 +++--- .../src/{ => engine}/mutable.ts | 0 .../src/{ => engine}/nonoptional.ts | 0 .../src/{ => engine}/touchEventEngine.ts | 6 +++--- .../src/{ => engine}/trackedInput.ts | 0 .../src/{ => engine}/trackedPoint.ts | 2 +- common/web/gesture-recognizer/src/index.ts | 15 --------------- .../auto/headless/recordedSegmentations.js | 7 ++++++- .../src/test/auto/headless/trackedPath.js | 8 ++++++-- .../gesture-recognizer/{src/test => }/test.sh | 6 +++--- common/web/gesture-recognizer/tsconfig.json | 6 +++--- 30 files changed, 80 insertions(+), 55 deletions(-) create mode 100644 common/web/gesture-recognizer/.c8rc.json rename common/web/gesture-recognizer/src/{ => engine/configuration}/gestureRecognizerConfiguration.ts (100%) rename common/web/gesture-recognizer/src/{ => engine/configuration}/paddedZoneSource.ts (100%) rename common/web/gesture-recognizer/src/{ => engine/configuration}/recognitionZoneSource.ts (100%) rename common/web/gesture-recognizer/src/{ => engine/configuration}/viewportZoneSource.ts (100%) rename common/web/gesture-recognizer/src/{ => engine/configuration}/zoneBoundaryChecker.ts (96%) rename common/web/gesture-recognizer/src/{ => engine}/gestureRecognizer.ts (95%) rename common/web/gesture-recognizer/src/{ => engine/headless}/cumulativePathStats.ts (100%) rename common/web/gesture-recognizer/src/{ => engine/headless}/inputSample.ts (100%) rename common/web/gesture-recognizer/src/{ => engine/headless}/segment.ts (100%) rename common/web/gesture-recognizer/src/{ => engine/headless}/segmentClassifier.ts (100%) rename common/web/gesture-recognizer/src/{ => engine/headless/subsegmentation}/constructingSegment.ts (98%) rename common/web/gesture-recognizer/src/{ => engine/headless/subsegmentation}/pathSegmenter.ts (99%) rename common/web/gesture-recognizer/src/{ => engine/headless/subsegmentation}/subsegmentCompatibilityAnalyzer.ts (98%) rename common/web/gesture-recognizer/src/{ => engine/headless}/trackedPath.ts (99%) create mode 100644 common/web/gesture-recognizer/src/engine/index.ts rename common/web/gesture-recognizer/src/{ => engine}/inputEventEngine.ts (94%) rename common/web/gesture-recognizer/src/{ => engine}/mouseEventEngine.ts (95%) rename common/web/gesture-recognizer/src/{ => engine}/mutable.ts (100%) rename common/web/gesture-recognizer/src/{ => engine}/nonoptional.ts (100%) rename common/web/gesture-recognizer/src/{ => engine}/touchEventEngine.ts (95%) rename common/web/gesture-recognizer/src/{ => engine}/trackedInput.ts (100%) rename common/web/gesture-recognizer/src/{ => engine}/trackedPoint.ts (97%) delete mode 100644 common/web/gesture-recognizer/src/index.ts rename common/web/gesture-recognizer/{src/test => }/test.sh (91%) diff --git a/common/web/gesture-recognizer/.c8rc.json b/common/web/gesture-recognizer/.c8rc.json new file mode 100644 index 0000000000..719cd11dae --- /dev/null +++ b/common/web/gesture-recognizer/.c8rc.json @@ -0,0 +1,18 @@ +{ + "check-coverage": false, + "clean": true, + "exclude": [ + "src/test/*", + "node_modules/*", + "src/tools/*" + ], + "exclude-after-remap": true, + "include": [ + "src/engine/headless/*" + ], + "reporter": ["text", "text-summary"], + "reports-dir": "build/coverage", + "src": [ + "src/engine/headless/*" + ] +} \ No newline at end of file diff --git a/common/web/gesture-recognizer/build.sh b/common/web/gesture-recognizer/build.sh index 786abd083c..ffbbfe223f 100755 --- a/common/web/gesture-recognizer/build.sh +++ b/common/web/gesture-recognizer/build.sh @@ -40,7 +40,6 @@ if builder_start_action configure; then fi if builder_start_action clean; then - npm run clean rm -rf build/ builder_finish_action success clean fi @@ -59,9 +58,9 @@ fi if builder_start_action test:module; then if builder_has_option --ci; then - npm test -- --ci + ./test.sh --ci else - npm test + ./test.sh fi builder_finish_action success test:module fi diff --git a/common/web/gesture-recognizer/package.json b/common/web/gesture-recognizer/package.json index 4f646ae571..48e4d34606 100644 --- a/common/web/gesture-recognizer/package.json +++ b/common/web/gesture-recognizer/package.json @@ -27,12 +27,8 @@ "typescript": "^4.9.5" }, "scripts": { - "build": "echo 'Building @keymanapp/gesture-recognizer' && tsc -b ./tsconfig.json", - "clean": "tsc -b --clean", - "karma": "karma", - "mocha": "mocha", - "test": "gosh ./src/test/test.sh", - "tsc": "tsc" + "build": "gosh ./build.sh", + "test": "gosh ./test.sh" }, "dependencies": { "eventemitter3": "^4.0.0" diff --git a/common/web/gesture-recognizer/src/gestureRecognizerConfiguration.ts b/common/web/gesture-recognizer/src/engine/configuration/gestureRecognizerConfiguration.ts similarity index 100% rename from common/web/gesture-recognizer/src/gestureRecognizerConfiguration.ts rename to common/web/gesture-recognizer/src/engine/configuration/gestureRecognizerConfiguration.ts diff --git a/common/web/gesture-recognizer/src/paddedZoneSource.ts b/common/web/gesture-recognizer/src/engine/configuration/paddedZoneSource.ts similarity index 100% rename from common/web/gesture-recognizer/src/paddedZoneSource.ts rename to common/web/gesture-recognizer/src/engine/configuration/paddedZoneSource.ts diff --git a/common/web/gesture-recognizer/src/recognitionZoneSource.ts b/common/web/gesture-recognizer/src/engine/configuration/recognitionZoneSource.ts similarity index 100% rename from common/web/gesture-recognizer/src/recognitionZoneSource.ts rename to common/web/gesture-recognizer/src/engine/configuration/recognitionZoneSource.ts diff --git a/common/web/gesture-recognizer/src/viewportZoneSource.ts b/common/web/gesture-recognizer/src/engine/configuration/viewportZoneSource.ts similarity index 100% rename from common/web/gesture-recognizer/src/viewportZoneSource.ts rename to common/web/gesture-recognizer/src/engine/configuration/viewportZoneSource.ts diff --git a/common/web/gesture-recognizer/src/zoneBoundaryChecker.ts b/common/web/gesture-recognizer/src/engine/configuration/zoneBoundaryChecker.ts similarity index 96% rename from common/web/gesture-recognizer/src/zoneBoundaryChecker.ts rename to common/web/gesture-recognizer/src/engine/configuration/zoneBoundaryChecker.ts index f9f74f7a50..2dcd33489c 100644 --- a/common/web/gesture-recognizer/src/zoneBoundaryChecker.ts +++ b/common/web/gesture-recognizer/src/engine/configuration/zoneBoundaryChecker.ts @@ -1,6 +1,6 @@ import { GestureRecognizerConfiguration } from "./gestureRecognizerConfiguration.js"; -import { InputSample } from "./inputSample.js"; -import { Nonoptional } from "./nonoptional.js"; +import { InputSample } from "../headless/inputSample.js"; +import { Nonoptional } from "../nonoptional.js"; import { RecognitionZoneSource } from "./recognitionZoneSource.js"; export class ZoneBoundaryChecker { diff --git a/common/web/gesture-recognizer/src/gestureRecognizer.ts b/common/web/gesture-recognizer/src/engine/gestureRecognizer.ts similarity index 95% rename from common/web/gesture-recognizer/src/gestureRecognizer.ts rename to common/web/gesture-recognizer/src/engine/gestureRecognizer.ts index e8e73a605c..de010190e6 100644 --- a/common/web/gesture-recognizer/src/gestureRecognizer.ts +++ b/common/web/gesture-recognizer/src/engine/gestureRecognizer.ts @@ -1,9 +1,9 @@ import EventEmitter from "eventemitter3"; -import { GestureRecognizerConfiguration } from "./gestureRecognizerConfiguration.js"; +import { GestureRecognizerConfiguration } from "./configuration/gestureRecognizerConfiguration.js"; import { MouseEventEngine } from "./mouseEventEngine.js"; import { Mutable } from "./mutable.js"; import { Nonoptional } from "./nonoptional.js"; -import { PaddedZoneSource } from "./paddedZoneSource.js"; +import { PaddedZoneSource } from "./configuration/paddedZoneSource.js"; import { TouchEventEngine } from "./touchEventEngine.js"; import { TrackedInput } from "./trackedInput.js"; import { TrackedPoint } from "./trackedPoint.js"; diff --git a/common/web/gesture-recognizer/src/cumulativePathStats.ts b/common/web/gesture-recognizer/src/engine/headless/cumulativePathStats.ts similarity index 100% rename from common/web/gesture-recognizer/src/cumulativePathStats.ts rename to common/web/gesture-recognizer/src/engine/headless/cumulativePathStats.ts diff --git a/common/web/gesture-recognizer/src/inputSample.ts b/common/web/gesture-recognizer/src/engine/headless/inputSample.ts similarity index 100% rename from common/web/gesture-recognizer/src/inputSample.ts rename to common/web/gesture-recognizer/src/engine/headless/inputSample.ts diff --git a/common/web/gesture-recognizer/src/segment.ts b/common/web/gesture-recognizer/src/engine/headless/segment.ts similarity index 100% rename from common/web/gesture-recognizer/src/segment.ts rename to common/web/gesture-recognizer/src/engine/headless/segment.ts diff --git a/common/web/gesture-recognizer/src/segmentClassifier.ts b/common/web/gesture-recognizer/src/engine/headless/segmentClassifier.ts similarity index 100% rename from common/web/gesture-recognizer/src/segmentClassifier.ts rename to common/web/gesture-recognizer/src/engine/headless/segmentClassifier.ts diff --git a/common/web/gesture-recognizer/src/constructingSegment.ts b/common/web/gesture-recognizer/src/engine/headless/subsegmentation/constructingSegment.ts similarity index 98% rename from common/web/gesture-recognizer/src/constructingSegment.ts rename to common/web/gesture-recognizer/src/engine/headless/subsegmentation/constructingSegment.ts index 7c3b1eeaa6..343276a826 100644 --- a/common/web/gesture-recognizer/src/constructingSegment.ts +++ b/common/web/gesture-recognizer/src/engine/headless/subsegmentation/constructingSegment.ts @@ -1,7 +1,7 @@ -import { SegmentClassifier } from "./segmentClassifier.js"; -import { CumulativePathStats } from "./cumulativePathStats.js"; +import { SegmentClassifier } from "../segmentClassifier.js"; +import { CumulativePathStats } from "../cumulativePathStats.js"; import { SegmentationSplit, Subsegmentation } from "./pathSegmenter.js"; -import { SegmentImplementation } from "./segment.js"; +import { SegmentImplementation } from "../segment.js"; import { SubsegmentCompatibilityAnalyzer } from "./subsegmentCompatibilityAnalyzer.js"; /** diff --git a/common/web/gesture-recognizer/src/pathSegmenter.ts b/common/web/gesture-recognizer/src/engine/headless/subsegmentation/pathSegmenter.ts similarity index 99% rename from common/web/gesture-recognizer/src/pathSegmenter.ts rename to common/web/gesture-recognizer/src/engine/headless/subsegmentation/pathSegmenter.ts index 8c5ac9a193..79480d7588 100644 --- a/common/web/gesture-recognizer/src/pathSegmenter.ts +++ b/common/web/gesture-recognizer/src/engine/headless/subsegmentation/pathSegmenter.ts @@ -1,8 +1,8 @@ import { ConstructingSegment } from "./constructingSegment.js"; -import { CumulativePathStats, PathCoordAxis, sigMinus } from "./cumulativePathStats.js"; -import { InputSample } from "./inputSample.js"; -import { Segment, SegmentImplementation } from "./segment.js"; -import { SegmentClass, SegmentClassifier, SegmentClassifierConfig } from "./segmentClassifier.js"; +import { CumulativePathStats, PathCoordAxis, sigMinus } from "../cumulativePathStats.js"; +import { InputSample } from "../inputSample.js"; +import { Segment, SegmentImplementation } from "../segment.js"; +import { SegmentClass, SegmentClassifier, SegmentClassifierConfig } from "../segmentClassifier.js"; // Mostly used here to compare the sum-squared error components of segmented regressions // to the sum-squared "modeled" components of their overall variance. Those are the two diff --git a/common/web/gesture-recognizer/src/subsegmentCompatibilityAnalyzer.ts b/common/web/gesture-recognizer/src/engine/headless/subsegmentation/subsegmentCompatibilityAnalyzer.ts similarity index 98% rename from common/web/gesture-recognizer/src/subsegmentCompatibilityAnalyzer.ts rename to common/web/gesture-recognizer/src/engine/headless/subsegmentation/subsegmentCompatibilityAnalyzer.ts index 2b977577ed..cfa2f7c5a9 100644 --- a/common/web/gesture-recognizer/src/subsegmentCompatibilityAnalyzer.ts +++ b/common/web/gesture-recognizer/src/engine/headless/subsegmentation/subsegmentCompatibilityAnalyzer.ts @@ -1,5 +1,5 @@ import { SegmentationSplit } from "./pathSegmenter.js"; -import { SegmentClass, SegmentClassifier } from "./segmentClassifier.js"; +import { SegmentClass, SegmentClassifier } from "../segmentClassifier.js"; /** * This class fulfills two roles: diff --git a/common/web/gesture-recognizer/src/trackedPath.ts b/common/web/gesture-recognizer/src/engine/headless/trackedPath.ts similarity index 99% rename from common/web/gesture-recognizer/src/trackedPath.ts rename to common/web/gesture-recognizer/src/engine/headless/trackedPath.ts index 37d4336c65..41bd378dfe 100644 --- a/common/web/gesture-recognizer/src/trackedPath.ts +++ b/common/web/gesture-recognizer/src/engine/headless/trackedPath.ts @@ -1,6 +1,6 @@ import EventEmitter from "eventemitter3"; import { InputSample } from "./inputSample.js"; -import { PathSegmenter } from "./pathSegmenter.js"; +import { PathSegmenter } from "./subsegmentation/pathSegmenter.js"; import { Segment } from "./segment.js"; /** diff --git a/common/web/gesture-recognizer/src/engine/index.ts b/common/web/gesture-recognizer/src/engine/index.ts new file mode 100644 index 0000000000..c7671ece94 --- /dev/null +++ b/common/web/gesture-recognizer/src/engine/index.ts @@ -0,0 +1,18 @@ +export { ConstructingSegment } from './headless/subsegmentation/constructingSegment.js'; +export { CumulativePathStats } from './headless/cumulativePathStats.js'; +export { GestureRecognizer } from "./gestureRecognizer.js"; +export { GestureRecognizerConfiguration } from "./configuration/gestureRecognizerConfiguration.js" +export { InputSample } from "./headless/inputSample.js"; +export { JSONTrackedInput, TrackedInput } from "./trackedInput.js"; +export { JSONTrackedPath, TrackedPath } from "./headless/trackedPath.js"; +export { JSONTrackedPoint, TrackedPoint } from "./trackedPoint.js"; +export { MouseEventEngine } from "./mouseEventEngine.js"; +export { PathSegmenter, Subsegmentation } from "./headless/subsegmentation/pathSegmenter.js"; +export { PaddedZoneSource } from './configuration/paddedZoneSource.js'; +export { RecognitionZoneSource } from './configuration/recognitionZoneSource.js'; +export { Segment } from "./headless/segment.js"; +export { SegmentClassifier } from "./headless/segmentClassifier.js"; +export { TouchEventEngine } from "./touchEventEngine.js"; +export { ViewportZoneSource } from './configuration/viewportZoneSource.js'; + +// TODO: export other odds & ends. \ No newline at end of file diff --git a/common/web/gesture-recognizer/src/inputEventEngine.ts b/common/web/gesture-recognizer/src/engine/inputEventEngine.ts similarity index 94% rename from common/web/gesture-recognizer/src/inputEventEngine.ts rename to common/web/gesture-recognizer/src/engine/inputEventEngine.ts index d15b1e6e01..b37b449c89 100644 --- a/common/web/gesture-recognizer/src/inputEventEngine.ts +++ b/common/web/gesture-recognizer/src/engine/inputEventEngine.ts @@ -1,6 +1,6 @@ import EventEmitter from "eventemitter3"; -import { GestureRecognizerConfiguration } from "./gestureRecognizerConfiguration.js"; -import { InputSample } from "./inputSample.js"; +import { GestureRecognizerConfiguration } from "./configuration/gestureRecognizerConfiguration.js"; +import { InputSample } from "./headless/inputSample.js"; import { Nonoptional } from "./nonoptional.js"; import { TrackedPoint } from "./trackedPoint.js"; diff --git a/common/web/gesture-recognizer/src/mouseEventEngine.ts b/common/web/gesture-recognizer/src/engine/mouseEventEngine.ts similarity index 95% rename from common/web/gesture-recognizer/src/mouseEventEngine.ts rename to common/web/gesture-recognizer/src/engine/mouseEventEngine.ts index d9a12735eb..6e5acd8bd5 100644 --- a/common/web/gesture-recognizer/src/mouseEventEngine.ts +++ b/common/web/gesture-recognizer/src/engine/mouseEventEngine.ts @@ -1,8 +1,8 @@ -import { GestureRecognizerConfiguration } from "./gestureRecognizerConfiguration.js"; +import { GestureRecognizerConfiguration } from "./configuration/gestureRecognizerConfiguration.js"; import { InputEventEngine } from "./inputEventEngine.js"; -import { InputSample } from "./inputSample.js"; +import { InputSample } from "./headless/inputSample.js"; import { Nonoptional } from "./nonoptional.js"; -import { ZoneBoundaryChecker } from "./zoneBoundaryChecker.js"; +import { ZoneBoundaryChecker } from "./configuration/zoneBoundaryChecker.js"; export class MouseEventEngine extends InputEventEngine { private readonly _mouseStart: typeof MouseEventEngine.prototype.onMouseStart; diff --git a/common/web/gesture-recognizer/src/mutable.ts b/common/web/gesture-recognizer/src/engine/mutable.ts similarity index 100% rename from common/web/gesture-recognizer/src/mutable.ts rename to common/web/gesture-recognizer/src/engine/mutable.ts diff --git a/common/web/gesture-recognizer/src/nonoptional.ts b/common/web/gesture-recognizer/src/engine/nonoptional.ts similarity index 100% rename from common/web/gesture-recognizer/src/nonoptional.ts rename to common/web/gesture-recognizer/src/engine/nonoptional.ts diff --git a/common/web/gesture-recognizer/src/touchEventEngine.ts b/common/web/gesture-recognizer/src/engine/touchEventEngine.ts similarity index 95% rename from common/web/gesture-recognizer/src/touchEventEngine.ts rename to common/web/gesture-recognizer/src/engine/touchEventEngine.ts index 62ec5d0d40..d4a8de5065 100644 --- a/common/web/gesture-recognizer/src/touchEventEngine.ts +++ b/common/web/gesture-recognizer/src/engine/touchEventEngine.ts @@ -1,8 +1,8 @@ -import { GestureRecognizerConfiguration } from "./gestureRecognizerConfiguration.js"; +import { GestureRecognizerConfiguration } from "./configuration/gestureRecognizerConfiguration.js"; import { InputEventEngine } from "./inputEventEngine.js"; -import { InputSample } from "./inputSample.js"; +import { InputSample } from "./headless/inputSample.js"; import { Nonoptional } from "./nonoptional.js"; -import { ZoneBoundaryChecker } from "./zoneBoundaryChecker.js"; +import { ZoneBoundaryChecker } from "./configuration/zoneBoundaryChecker.js"; export class TouchEventEngine extends InputEventEngine { private readonly _touchStart: typeof TouchEventEngine.prototype.onTouchStart; diff --git a/common/web/gesture-recognizer/src/trackedInput.ts b/common/web/gesture-recognizer/src/engine/trackedInput.ts similarity index 100% rename from common/web/gesture-recognizer/src/trackedInput.ts rename to common/web/gesture-recognizer/src/engine/trackedInput.ts diff --git a/common/web/gesture-recognizer/src/trackedPoint.ts b/common/web/gesture-recognizer/src/engine/trackedPoint.ts similarity index 97% rename from common/web/gesture-recognizer/src/trackedPoint.ts rename to common/web/gesture-recognizer/src/engine/trackedPoint.ts index d558a1e823..25548825cb 100644 --- a/common/web/gesture-recognizer/src/trackedPoint.ts +++ b/common/web/gesture-recognizer/src/engine/trackedPoint.ts @@ -1,4 +1,4 @@ -import { JSONTrackedPath, TrackedPath } from "./trackedPath.js"; +import { JSONTrackedPath, TrackedPath } from "./headless/trackedPath.js"; /** * Documents the expected typing of serialized versions of the `TrackedPoint` class. diff --git a/common/web/gesture-recognizer/src/index.ts b/common/web/gesture-recognizer/src/index.ts deleted file mode 100644 index d6e29cfe57..0000000000 --- a/common/web/gesture-recognizer/src/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export { ConstructingSegment } from './constructingSegment.js'; -export { CumulativePathStats } from './cumulativePathStats.js'; -export { GestureRecognizer } from "./gestureRecognizer.js"; -export { GestureRecognizerConfiguration } from "./gestureRecognizerConfiguration.js" -export { InputSample } from "./inputSample.js"; -export { JSONTrackedInput, TrackedInput } from "./trackedInput.js"; -export { JSONTrackedPath, TrackedPath } from "./trackedPath.js"; -export { JSONTrackedPoint, TrackedPoint } from "./trackedPoint.js"; -export { MouseEventEngine } from "./mouseEventEngine.js"; -export { PathSegmenter, Subsegmentation } from "./pathSegmenter.js"; -export { Segment } from "./segment.js"; -export { SegmentClassifier } from "./segmentClassifier.js"; -export { TouchEventEngine } from "./touchEventEngine.js"; - -// TODO: export other odds & ends. \ No newline at end of file diff --git a/common/web/gesture-recognizer/src/test/auto/headless/recordedSegmentations.js b/common/web/gesture-recognizer/src/test/auto/headless/recordedSegmentations.js index bd416a5b3f..04c68a4b16 100644 --- a/common/web/gesture-recognizer/src/test/auto/headless/recordedSegmentations.js +++ b/common/web/gesture-recognizer/src/test/auto/headless/recordedSegmentations.js @@ -1,6 +1,8 @@ import { assert } from 'chai'; import sinon from 'sinon'; import fs from 'fs'; +import path from 'path'; +import url from 'url'; import * as PromiseStatusModule from 'promise-status-async'; const promiseStatus = PromiseStatusModule.promiseStatus; @@ -10,7 +12,10 @@ import { PathSegmenter } from '@keymanapp/gesture-recognizer'; import { HeadlessRecordingSimulator } from '../../../../build/tools/obj/index.js'; -const SEGMENT_TEST_JSON_FOLDER = './resources/json/segmentation'; +// Ensures that the resources are resolved relative to this script, not to the cwd when the test +// runner was launched. +const scriptFolder = path.dirname(url.fileURLToPath(import.meta.url)); +const SEGMENT_TEST_JSON_FOLDER = path.resolve(`${scriptFolder}/../../resources/json/segmentation`); import { assertSegmentSimilarity } from '../../resources/assertSegmentSimilarity.js'; diff --git a/common/web/gesture-recognizer/src/test/auto/headless/trackedPath.js b/common/web/gesture-recognizer/src/test/auto/headless/trackedPath.js index 23e3857569..03c7d6000d 100644 --- a/common/web/gesture-recognizer/src/test/auto/headless/trackedPath.js +++ b/common/web/gesture-recognizer/src/test/auto/headless/trackedPath.js @@ -1,13 +1,17 @@ import { assert } from 'chai' import sinon from 'sinon'; import fs from 'fs'; +import path from 'path'; +import url from 'url'; import { TrackedPath } from '@keymanapp/gesture-recognizer'; import { HeadlessRecordingSimulator, timedPromise } from '../../../../build/tools/obj/index.js'; -// For the integrated-style recording-based test. -const SEGMENT_TEST_JSON_FOLDER = './resources/json/segmentation'; +// Ensures that the resources are resolved relative to this script, not to the cwd when the test +// runner was launched. +const scriptFolder = path.dirname(url.fileURLToPath(import.meta.url)); +const SEGMENT_TEST_JSON_FOLDER = path.resolve(`${scriptFolder}/../../resources/json/segmentation`); import { assertSegmentSimilarity } from '../../resources/assertSegmentSimilarity.js' ; diff --git a/common/web/gesture-recognizer/src/test/test.sh b/common/web/gesture-recognizer/test.sh similarity index 91% rename from common/web/gesture-recognizer/src/test/test.sh rename to common/web/gesture-recognizer/test.sh index efc9267d80..ccf0cc5c73 100755 --- a/common/web/gesture-recognizer/src/test/test.sh +++ b/common/web/gesture-recognizer/test.sh @@ -3,7 +3,7 @@ ## 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" ## END STANDARD BUILD SCRIPT INCLUDE . $KEYMAN_ROOT/resources/shellHelperFunctions.sh @@ -44,7 +44,7 @@ test-headless ( ) { MOCHA_FLAGS="--reporter mocha-teamcity-reporter" fi - mocha --recursive $MOCHA_FLAGS ./auto/headless/ + c8 mocha --recursive $MOCHA_FLAGS ./src/test/auto/headless/ } test-browser ( ) { @@ -58,7 +58,7 @@ test-browser ( ) { KARMA_CONFIG="CI.conf.cjs" fi - karma start auto/browser/$KARMA_CONFIG "$KARMA_FLAGS" + karma start src/test/auto/browser/$KARMA_CONFIG "$KARMA_FLAGS" } if builder_start_action test:headless; then diff --git a/common/web/gesture-recognizer/tsconfig.json b/common/web/gesture-recognizer/tsconfig.json index aa5d55b827..2f2e06a7ba 100644 --- a/common/web/gesture-recognizer/tsconfig.json +++ b/common/web/gesture-recognizer/tsconfig.json @@ -4,9 +4,9 @@ "baseUrl": "./", "lib": [ "dom", "es6" ], "outDir": "./build/obj/", - "rootDir": "./src", + "rootDir": "./src/engine", "tsBuildInfoFile": "./build/obj/tsconfig.tsbuildinfo" }, - "include": ["./src/**/*.ts"], - "exclude": ["./src/tools/**/*.ts"] + "include": ["./src/engine/**/*.ts"], + "exclude": ["./src/test/**/*.ts", "./src/tools/**/*.ts"] } From 0c0728836db74a329cd63d97317ea7e1f2e12985 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Wed, 28 Jun 2023 10:18:41 +0700 Subject: [PATCH 2/2] chore(web): top-level tsconfig bookkeeping --- tsconfig.cjs.json | 2 -- tsconfig.esm.json | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 4695672e90..3dff61f8b6 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -5,8 +5,6 @@ "files": [], "include": [], "references": [ - { "path": "./common/web/gesture-recognizer/tsconfig.json" }, - { "path": "./common/web/gesture-recognizer/src/tools/unit-test-resources/tsconfig.json" }, { "path": "./common/predictive-text/testing/one-stage-embedded-webworker/tsconfig.json" }, { "path": "./common/predictive-text/testing/two-stage-embedded-webworker/tsconfig.json" }, { "path": "./common/predictive-text/testing/two-stage-embedded-webworker/worker/tsconfig.json" }, diff --git a/tsconfig.esm.json b/tsconfig.esm.json index de47c84fde..e254483d0a 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -24,6 +24,8 @@ { "path": "./common/web/keyman-version" }, { "path": "./common/web/types/" }, + { "path": "./common/web/gesture-recognizer/tsconfig.json" }, + { "path": "./common/web/gesture-recognizer/src/tools/unit-test-resources/tsconfig.json" }, { "path": "./common/web/input-processor/tsconfig.json" }, { "path": "./common/web/keyboard-processor/tsconfig.json" }, { "path": "./common/web/recorder/tsconfig.json" },