diff --git a/web/src/app/browser/src/hardwareEventKeyboard.ts b/web/src/app/browser/src/hardwareEventKeyboard.ts index b323cdefbd8..75238e6410b 100644 --- a/web/src/app/browser/src/hardwareEventKeyboard.ts +++ b/web/src/app/browser/src/hardwareEventKeyboard.ts @@ -1,5 +1,5 @@ import { Codes, DeviceSpec, KeyEvent, KeyMapping, JSKeyboard } from 'keyman/engine/keyboard'; -import { KeyboardProcessor } from 'keyman/engine/js-processor'; +import { JSKeyboardProcessor } from 'keyman/engine/js-processor'; import { ModifierKeyConstants } from '@keymanapp/common-types'; import { HardKeyboard, processForMnemonicsAndLegacy } from 'keyman/engine/main'; @@ -209,13 +209,13 @@ export default class HardwareEventKeyboard extends HardKeyboard { // - `modStateFlags` // - `baseLayout` // - `doModifierPress()` - for modifier updates on key-up. - private readonly processor: KeyboardProcessor; + private readonly processor: JSKeyboardProcessor; private readonly contextManager: ContextManager; private domEventTracker = new DomEventTracker(); private swallowKeypress: boolean = false; - constructor(hardDevice: DeviceSpec, processor: KeyboardProcessor, contextManager: ContextManager) { + constructor(hardDevice: DeviceSpec, processor: JSKeyboardProcessor, contextManager: ContextManager) { super(); this.hardDevice = hardDevice; this.contextManager = contextManager; diff --git a/web/src/engine/js-processor/src/index.ts b/web/src/engine/js-processor/src/index.ts index 04b8426923f..4042d72c181 100644 --- a/web/src/engine/js-processor/src/index.ts +++ b/web/src/engine/js-processor/src/index.ts @@ -1,5 +1,5 @@ -export { default as KeyboardProcessor } from "./keyboardProcessor.js"; -export * from "./keyboardProcessor.js"; +export { JSKeyboardProcessor } from "./jsKeyboardProcessor.js"; +export * from "./jsKeyboardProcessor.js"; export { default as RuleBehavior } from "./ruleBehavior.js"; export * from './jsKeyboardInterface.js'; export { JSKeyboardInterface } from "./jsKeyboardInterface.js"; diff --git a/web/src/engine/js-processor/src/keyboardProcessor.ts b/web/src/engine/js-processor/src/jsKeyboardProcessor.ts similarity index 98% rename from web/src/engine/js-processor/src/keyboardProcessor.ts rename to web/src/engine/js-processor/src/jsKeyboardProcessor.ts index f2141ae2e68..cbd4d7ca4a0 100644 --- a/web/src/engine/js-processor/src/keyboardProcessor.ts +++ b/web/src/engine/js-processor/src/jsKeyboardProcessor.ts @@ -33,10 +33,10 @@ export interface ProcessorInitOptions { } interface EventMap { - statekeychange: (stateKeys: typeof KeyboardProcessor.prototype.stateKeys) => void; + statekeychange: (stateKeys: typeof JSKeyboardProcessor.prototype.stateKeys) => void; } -export default class KeyboardProcessor extends EventEmitter { +export class JSKeyboardProcessor extends EventEmitter { public static readonly DEFAULT_OPTIONS: ProcessorInitOptions = { baseLayout: 'us', defaultOutputRules: new DefaultRules() @@ -77,14 +77,14 @@ export default class KeyboardProcessor extends EventEmitter { super(); if(!options) { - options = KeyboardProcessor.DEFAULT_OPTIONS; + options = JSKeyboardProcessor.DEFAULT_OPTIONS; } this.contextDevice = device; - this.baseLayout = options.baseLayout || KeyboardProcessor.DEFAULT_OPTIONS.baseLayout; + this.baseLayout = options.baseLayout || JSKeyboardProcessor.DEFAULT_OPTIONS.baseLayout; this.keyboardInterface = options.keyboardInterface || new JSKeyboardInterface(globalObject(), MinimalKeymanGlobal); - this.defaultRules = options.defaultOutputRules || KeyboardProcessor.DEFAULT_OPTIONS.defaultOutputRules; + this.defaultRules = options.defaultOutputRules || JSKeyboardProcessor.DEFAULT_OPTIONS.defaultOutputRules; } public get activeKeyboard(): JSKeyboard { diff --git a/web/src/engine/js-processor/src/ruleBehavior.ts b/web/src/engine/js-processor/src/ruleBehavior.ts index fd736f0fd82..b00577b09db 100644 --- a/web/src/engine/js-processor/src/ruleBehavior.ts +++ b/web/src/engine/js-processor/src/ruleBehavior.ts @@ -1,4 +1,4 @@ -import KeyboardProcessor from "./keyboardProcessor.js"; +import { JSKeyboardProcessor } from "./jsKeyboardProcessor.js"; import { VariableStoreDictionary } from "keyman/engine/keyboard"; import OutputTarget, { type Transcription } from './outputTarget.js'; import { Mock } from "./mock.js"; @@ -65,7 +65,7 @@ export default class RuleBehavior { */ triggerKeyDefault?: boolean; - finalize(processor: KeyboardProcessor, outputTarget: OutputTarget, readonly: boolean) { + finalize(processor: JSKeyboardProcessor, outputTarget: OutputTarget, readonly: boolean) { if(!this.transcription) { throw "Cannot finalize a RuleBehavior with no transcription."; } diff --git a/web/src/engine/main/src/headless/inputProcessor.ts b/web/src/engine/main/src/headless/inputProcessor.ts index ee0b3da7aae..750f17c6700 100644 --- a/web/src/engine/main/src/headless/inputProcessor.ts +++ b/web/src/engine/main/src/headless/inputProcessor.ts @@ -12,7 +12,7 @@ import { type Alternate, isEmptyTransform, JSKeyboardInterface, - KeyboardProcessor, + JSKeyboardProcessor, Mock, type OutputTarget, RuleBehavior, @@ -34,7 +34,7 @@ export class InputProcessor { * entry points. */ private contextDevice: DeviceSpec; - private kbdProcessor: KeyboardProcessor; + private kbdProcessor: JSKeyboardProcessor; private lngProcessor: LanguageProcessor; private km_core: KmCoreModule; @@ -50,7 +50,7 @@ export class InputProcessor { } this.contextDevice = device; - this.kbdProcessor = new KeyboardProcessor(device, options); + this.kbdProcessor = new JSKeyboardProcessor(device, options); this.lngProcessor = new LanguageProcessor(predictiveTextWorker, this.contextCache); } @@ -62,7 +62,7 @@ export class InputProcessor { return this.lngProcessor; } - public get keyboardProcessor(): KeyboardProcessor { + public get keyboardProcessor(): JSKeyboardProcessor { return this.kbdProcessor; } diff --git a/web/src/test/auto/headless/engine/js-processor/engine/context.tests.js b/web/src/test/auto/headless/engine/js-processor/engine/context.tests.js index 22532205d2d..7456c311b85 100644 --- a/web/src/test/auto/headless/engine/js-processor/engine/context.tests.js +++ b/web/src/test/auto/headless/engine/js-processor/engine/context.tests.js @@ -4,7 +4,7 @@ import { createRequire } from 'module'; const require = createRequire(import.meta.url); import { MinimalKeymanGlobal } from 'keyman/engine/keyboard'; -import { JSKeyboardInterface, KeyboardProcessor, Mock } from 'keyman/engine/js-processor'; +import { JSKeyboardInterface, JSKeyboardProcessor, Mock } from 'keyman/engine/js-processor'; import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { NodeProctor, RecordedKeystrokeSequence } from '@keymanapp/recorder-core'; @@ -68,7 +68,7 @@ function runEngineRuleSet(ruleSet, defaultNoun) { ruleSeq.test(proctor, target); // Now for the real test! - let processor = new KeyboardProcessor(device); + let processor = new JSKeyboardProcessor(device); processor.keyboardInterface = keyboardWithHarness; var res = processor.keyboardInterface.fullContextMatch(ruleDef.n, target, ruleDef.rule); @@ -1007,7 +1007,7 @@ describe('Engine - Context Matching', function() { ruleSeq.test(proctor, target); // Now for the real test! - let processor = new KeyboardProcessor(device); + let processor = new JSKeyboardProcessor(device); processor.keyboardInterface = keyboardWithHarness; var res = processor.keyboardInterface._BuildExtendedContext(ruleDef.n, ruleDef.ln, target); diff --git a/web/src/test/auto/headless/engine/js-processor/specialized-backspace.tests.js b/web/src/test/auto/headless/engine/js-processor/specialized-backspace.tests.js index 42012760dbb..d8430ab99b4 100644 --- a/web/src/test/auto/headless/engine/js-processor/specialized-backspace.tests.js +++ b/web/src/test/auto/headless/engine/js-processor/specialized-backspace.tests.js @@ -5,7 +5,7 @@ import { createRequire } from 'module'; const require = createRequire(import.meta.url); import { Codes, KeyEvent, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; -import { JSKeyboardInterface, KeyboardProcessor, Mock } from 'keyman/engine/js-processor'; +import { JSKeyboardInterface, JSKeyboardProcessor, Mock } from 'keyman/engine/js-processor'; import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { ModifierKeyConstants } from '@keymanapp/common-types'; @@ -138,7 +138,7 @@ describe('Engine - specialized backspace handling', function() { device: device }); - const processor = new KeyboardProcessor(TEST_DEVICE, { + const processor = new JSKeyboardProcessor(TEST_DEVICE, { keyboardInterface: angkorWithHarness }); const result = processor.processKeystroke(event, contextSource); @@ -169,7 +169,7 @@ describe('Engine - specialized backspace handling', function() { // A specialized test keyboard that handles keys without emitting any content. // We want to ensure error cases without output, on null context, don't act // like backspaces. - const processor = new KeyboardProcessor(TEST_DEVICE, { + const processor = new JSKeyboardProcessor(TEST_DEVICE, { keyboardInterface: dummiedWithHarness }); const result = processor.processKeystroke(event, contextSource); @@ -201,7 +201,7 @@ describe('Engine - specialized backspace handling', function() { device: device }); - const processor = new KeyboardProcessor(TEST_DEVICE, { + const processor = new JSKeyboardProcessor(TEST_DEVICE, { keyboardInterface: angkorWithHarness }); const result = processor.processKeystroke(event, contextSource); @@ -236,7 +236,7 @@ describe('Engine - specialized backspace handling', function() { device: device }); - const processor = new KeyboardProcessor(TEST_DEVICE, { + const processor = new JSKeyboardProcessor(TEST_DEVICE, { keyboardInterface: angkorWithHarness }); const result = processor.processKeystroke(event, contextSource); @@ -264,7 +264,7 @@ describe('Engine - specialized backspace handling', function() { device: device }); - const processor = new KeyboardProcessor(TEST_DEVICE, { + const processor = new JSKeyboardProcessor(TEST_DEVICE, { keyboardInterface: ipaWithHarness }); const result = processor.processKeystroke(event, contextSource); @@ -295,7 +295,7 @@ describe('Engine - specialized backspace handling', function() { // A specialized test keyboard that duplicates backspaces when sufficient // context exists. - const processor = new KeyboardProcessor(TEST_DEVICE, { + const processor = new JSKeyboardProcessor(TEST_DEVICE, { keyboardInterface: bksp2xWithHarness }); const result = processor.processKeystroke(event, contextSource); @@ -330,7 +330,7 @@ describe('Engine - specialized backspace handling', function() { // A specialized test keyboard that handles keys without emitting any content. // We want to ensure error cases without output, on null context, don't act // like backspaces. - const processor = new KeyboardProcessor(TEST_DEVICE, { + const processor = new JSKeyboardProcessor(TEST_DEVICE, { keyboardInterface: dummiedWithHarness }); const result = processor.processKeystroke(event, contextSource); diff --git a/web/src/tools/testing/recorder-core/src/nodeProctor.ts b/web/src/tools/testing/recorder-core/src/nodeProctor.ts index 61554e2db59..58be39cc799 100644 --- a/web/src/tools/testing/recorder-core/src/nodeProctor.ts +++ b/web/src/tools/testing/recorder-core/src/nodeProctor.ts @@ -11,7 +11,7 @@ import { import { KeyEvent, KeyEventSpec, KeyboardHarness } from "keyman/engine/keyboard"; import { Mock, type OutputTarget } from "keyman/engine/js-processor"; import { DeviceSpec } from "@keymanapp/web-utils"; -import { JSKeyboardInterface, KeyboardProcessor } from 'keyman/engine/js-processor'; +import { JSKeyboardInterface, JSKeyboardProcessor } from 'keyman/engine/js-processor'; export default class NodeProctor extends Proctor { private keyboardWithHarness: KeyboardHarness; @@ -56,7 +56,7 @@ export default class NodeProctor extends Proctor { } // Establish a fresh processor, setting its keyboard appropriately for the test. - let processor = new KeyboardProcessor(this.device); + let processor = new JSKeyboardProcessor(this.device); processor.keyboardInterface = this.keyboardWithHarness as JSKeyboardInterface; const keyboard = processor.activeKeyboard;