Skip to content

Commit

Permalink
refactor(web): rename KeyboardProcessor class to JSKeyboardProcessor
Browse files Browse the repository at this point in the history
Also rename file `keyboardProcessor.ts` to `jsKeyboardProcessor.ts`.
  • Loading branch information
ermshiperete committed Dec 11, 2024
1 parent 185bb00 commit ce89d66
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions web/src/app/browser/src/hardwareEventKeyboard.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions web/src/engine/js-processor/src/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EventMap> {
export class JSKeyboardProcessor extends EventEmitter<EventMap> {
public static readonly DEFAULT_OPTIONS: ProcessorInitOptions = {
baseLayout: 'us',
defaultOutputRules: new DefaultRules()
Expand Down Expand Up @@ -77,14 +77,14 @@ export default class KeyboardProcessor extends EventEmitter<EventMap> {
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 {
Expand Down
4 changes: 2 additions & 2 deletions web/src/engine/js-processor/src/ruleBehavior.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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.";
}
Expand Down
8 changes: 4 additions & 4 deletions web/src/engine/main/src/headless/inputProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
type Alternate,
isEmptyTransform,
JSKeyboardInterface,
KeyboardProcessor,
JSKeyboardProcessor,
Mock,
type OutputTarget,
RuleBehavior,
Expand All @@ -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;

Expand All @@ -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);
}

Expand All @@ -62,7 +62,7 @@ export class InputProcessor {
return this.lngProcessor;
}

public get keyboardProcessor(): KeyboardProcessor {
public get keyboardProcessor(): JSKeyboardProcessor {
return this.kbdProcessor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions web/src/tools/testing/recorder-core/src/nodeProctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit ce89d66

Please sign in to comment.