Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions web/src/app/browser/src/keymanEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ export class KeymanEngine extends KeymanEngineBase<BrowserConfiguration, Context
});

this._util = new UtilApiEndpoint(config);
this.beepHandler = new BeepHandler(this.core.keyboardInterface);
this.core.keyboardProcessor.beepHandler = () => this.beepHandler.beep(this.contextManager.activeTextStore);
this.beepHandler = new BeepHandler(this.inputProcessor.keyboardInterface);
this.inputProcessor.keyboardProcessor.beepHandler = () => this.beepHandler.beep(this.contextManager.activeTextStore);

this.hardKeyboard = new HardwareEventKeyboard(config.hardDevice, this.core.keyboardProcessor, this.contextManager);
this.hardKeyboard = new HardwareEventKeyboard(config.hardDevice, this.inputProcessor.keyboardProcessor, this.contextManager);

// Scrolls the document-body to ensure that a focused element remains visible after the OSK appears.
this.contextManager.on('textstorechange', (textStore) => {
Expand Down Expand Up @@ -444,7 +444,7 @@ export class KeymanEngine extends KeymanEngineBase<BrowserConfiguration, Context
kbd = new JSKeyboard(k0);
}
} else {
kbd = this.core.activeKeyboard;
kbd = this.inputProcessor.activeKeyboard;
}

// We only support isCJK on legacy .js keyboards; see #7928
Expand Down Expand Up @@ -695,7 +695,7 @@ export class KeymanEngine extends KeymanEngineBase<BrowserConfiguration, Context
PKbd = this.keyboardRequisitioner.cache.getKeyboard(PInternalName);
}

PKbd = PKbd || this.core.activeKeyboard;
PKbd = PKbd || this.inputProcessor.activeKeyboard;
if (PKbd instanceof KMXKeyboard) {
// TODO-web-core: implement for KMX keyboards (epic/embed-osk-in-kmx)
return null;
Expand Down Expand Up @@ -733,7 +733,7 @@ export class KeymanEngine extends KeymanEngineBase<BrowserConfiguration, Context
this.pageIntegration.shutdown();
this.contextManager.shutdown();
this.osk?.shutdown();
this.core.languageProcessor.shutdown();
this.inputProcessor.languageProcessor.shutdown();
this.hardKeyboard.shutdown();
this.util.shutdown(); // For tracked dom events, stylesheets.

Expand Down
2 changes: 1 addition & 1 deletion web/src/app/webview/src/keymanEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class KeymanEngine extends KeymanEngineBase<WebviewConfiguration, Context
}

if(this.beepKeyboard) {
this.core.keyboardProcessor.beepHandler = this.beepKeyboard;
this.inputProcessor.keyboardProcessor.beepHandler = this.beepKeyboard;
}

this.contextManager.on('keyboardchange', (kbd) => {
Expand Down
54 changes: 27 additions & 27 deletions web/src/engine/src/main/keymanEngineBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class KeymanEngineBase<
readonly config: ConfigurationT;
contextManager: ContextManagerT;
interface: KeyboardInterfaceBase<ContextManagerT>;
readonly core: InputProcessor;
readonly inputProcessor: InputProcessor;
keyboardRequisitioner: KeyboardRequisitioner;
modelCache: ModelCache;

Expand All @@ -63,7 +63,7 @@ export class KeymanEngineBase<
return;
}

if(!this.core.languageProcessor.mayCorrect) {
if(!this.inputProcessor.languageProcessor.mayCorrect) {
event.keyDistribution = [];
}

Expand All @@ -84,11 +84,11 @@ export class KeymanEngineBase<
const oskLayer = this.osk.vkbd.layerId;

// In case of modipresses.
if(oskLayer && oskLayer != this.core.keyboardProcessor.layerId) {
this.core.keyboardProcessor.layerId = oskLayer;
if(oskLayer && oskLayer != this.inputProcessor.keyboardProcessor.layerId) {
this.inputProcessor.keyboardProcessor.layerId = oskLayer;
}
}
const result = this.core.processKeyEvent(event, textStore);
const result = this.inputProcessor.processKeyEvent(event, textStore);

if(result && result.transcription?.transform) {
this.config.onRuleFinalization(result, this.contextManager.activeTextStore);
Expand Down Expand Up @@ -125,9 +125,9 @@ export class KeymanEngineBase<
const processorConfiguration = processorConfigInitializer(this);
processorConfiguration.baseLayout = determineBaseLayout();
this.interface = processorConfiguration.keyboardInterface as KeyboardInterfaceBase<ContextManagerT>;
this.core = new InputProcessor(config.hostDevice, workerFactory, processorConfiguration);
this.inputProcessor = new InputProcessor(config.hostDevice, workerFactory, processorConfiguration);

this.core.languageProcessor.on('statechange', (state) => {
this.inputProcessor.languageProcessor.on('statechange', (state) => {
// The banner controller cannot directly trigger a layout-refresh at this time,
// so we handle that here.
this.osk?.bannerController.selectBanner(state);
Expand All @@ -137,7 +137,7 @@ export class KeymanEngineBase<
// The OSK does not possess a direct connection to the KeyboardProcessor's state-key
// management object; this event + handler allow us to keep the OSK's related states
// in sync.
this.core.keyboardProcessor.on('statekeychange', (stateKeys) => {
this.inputProcessor.keyboardProcessor.on('statekeychange', (stateKeys) => {
this.osk?.vkbd?.updateStateKeys(stateKeys);
})

Expand All @@ -160,7 +160,7 @@ export class KeymanEngineBase<
this.refreshModel();
// Triggers context resets that can trigger layout stuff.
// It's not the final such context-reset, though.
this.core.activeKeyboard = kbdData?.keyboard;
this.inputProcessor.activeKeyboard = kbdData?.keyboard;

this.legacyAPIEvents.callEvent('keyboardchange', {
internalName: kbdData?.metadata.id ?? '',
Expand Down Expand Up @@ -247,18 +247,18 @@ export class KeymanEngineBase<
this.modelCache = new ModelCache();
const kbdCache = this.keyboardRequisitioner.cache;

const keyboardProcessor = this.core.keyboardProcessor;
const predictionContext = new PredictionContext(this.core.languageProcessor, () => keyboardProcessor.layerId);
const keyboardProcessor = this.inputProcessor.keyboardProcessor;
const predictionContext = new PredictionContext(this.inputProcessor.languageProcessor, () => keyboardProcessor.layerId);
this.contextManager.configure({
resetContext: (textStore) => {
// Could reset the textStore's deadkeys here, but it's really more of a 'core' task.
// So we delegate that to keyboard.
if(this.osk) {
this.osk.batchLayoutAfter(() => {
this.core.resetContext(textStore);
this.inputProcessor.resetContext(textStore);
})
} else {
this.core.resetContext(textStore);
this.inputProcessor.resetContext(textStore);
}
},
predictionContext: predictionContext,
Expand All @@ -271,7 +271,7 @@ export class KeymanEngineBase<
* This is called after the suggestion is applied but _before_ new
* predictions are requested based on the resulting context.
*/
this.core.languageProcessor.on('suggestionapplied', () => {
this.inputProcessor.languageProcessor.on('suggestionapplied', () => {
// Tell the keyboard that the current layer has not changed
keyboardProcessor.newLayerStore.set('');
keyboardProcessor.oldLayerStore.set('');
Expand Down Expand Up @@ -337,7 +337,7 @@ export class KeymanEngineBase<
//
// #endregion

await this.core.init(config.paths);
await this.inputProcessor.init(config.paths);
}

/**
Expand Down Expand Up @@ -377,20 +377,20 @@ export class KeymanEngineBase<
public set osk(value: OSKView) {
if(this._osk) {
this._osk.off('keyevent', this.keyEventListener);
this.core.keyboardProcessor.layerStore.handler = this.osk.layerChangeHandler;
this.inputProcessor.keyboardProcessor.layerStore.handler = this.osk.layerChangeHandler;
}
this._osk = value;
// As the `new context` ruleset is designed to facilitate OSK layer-change updates
// based on the context being entered, we want the keyboard processor's current
// contextDevice to match that of the active OSK. See #11740.
this.core.keyboardProcessor.contextDevice = value?.targetDevice ?? this.config.softDevice;
this.inputProcessor.keyboardProcessor.contextDevice = value?.targetDevice ?? this.config.softDevice;
if(value) {
// Don't build an OSK if no keyboard is available yet; avoid the extra flash.
if (this.contextManager.activeKeyboard && this.contextManager.activeKeyboard instanceof JSKeyboardData) { // TODO-embed-osk-in-kmx: add support for OSK for KMX keyboards
value.activeKeyboard = this.contextManager.activeKeyboard;
}
value.on('keyevent', this.keyEventListener);
this.core.keyboardProcessor.layerStore.handler = value.layerChangeHandler;
this.inputProcessor.keyboardProcessor.layerStore.handler = value.layerChangeHandler;
}
}

Expand All @@ -405,7 +405,7 @@ export class KeymanEngineBase<
version: activeKbd?.keyboard?.version ?? ''
},
model: {
id: this.core?.activeModel?.id || ''
id: this.inputProcessor?.activeModel?.id || ''
},
osk: {
banner: this.osk?.banner?.banner.type ?? '',
Expand All @@ -422,14 +422,14 @@ export class KeymanEngineBase<
const kbd = this.contextManager.activeKeyboard;
const model = this.modelCache.modelForLanguage(kbd?.metadata.langId);

if(this.core.activeModel != model) {
if(this.core.activeModel) {
this.core.languageProcessor.unloadModel();
if(this.inputProcessor.activeModel != model) {
if(this.inputProcessor.activeModel) {
this.inputProcessor.languageProcessor.unloadModel();
}

// Semi-hacky management of banner display state.
if(model) {
return this.core.languageProcessor.loadModel(model).then(() => {
return this.inputProcessor.languageProcessor.loadModel(model).then(() => {
return model;
});
}
Expand Down Expand Up @@ -501,8 +501,8 @@ export class KeymanEngineBase<
this.modelCache.unregister(modelId);

// Is it the active model?
if(this.core.activeModel && this.core.activeModel.id == modelId) {
this.core.languageProcessor.unloadModel();
if(this.inputProcessor.activeModel && this.inputProcessor.activeModel.id == modelId) {
this.inputProcessor.languageProcessor.unloadModel();
}
}

Expand Down Expand Up @@ -575,7 +575,7 @@ export class KeymanEngineBase<

jsKbd = k0;
} else {
const kbd = this.core.activeKeyboard;
const kbd = this.inputProcessor.activeKeyboard;
if (kbd instanceof JSKeyboard) {
jsKbd = kbd;
} else {
Expand Down Expand Up @@ -603,7 +603,7 @@ export class KeymanEngineBase<
* Description Set OSK to numeric layer if it exists
*/
setNumericLayer() {
this.core.keyboardProcessor.setNumericLayer(this.config.softDevice);
this.inputProcessor.keyboardProcessor.setNumericLayer(this.config.softDevice);
};
}

Expand Down
8 changes: 4 additions & 4 deletions web/src/tools/testing/bulk_rendering/renderer_core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class BatchRenderer {
eleDescription.appendChild(document.createTextNode('Name: ' + kbd.Name));
eleDescription.appendChild(document.createElement('br'));

const keyboard = keyman.core.activeKeyboard;
const keyboard = keyman.inputProcessor.activeKeyboard;
if (keyboard instanceof JSKeyboard) {
// Some keyboards, such as sil_euro_latin and sil_ipa, no longer specify this property.
if (keyboard['_legacyLayoutSpec']) {
Expand Down Expand Up @@ -173,12 +173,12 @@ export class BatchRenderer {

// Uses 'private' APIs that may be subject to change in the future. Keep it updated!
let layers: string[];
if(!isMobile && keyman.core.activeKeyboard instanceof JSKeyboard) {
if(!isMobile && keyman.inputProcessor.activeKeyboard instanceof JSKeyboard) {
// The desktop OSK will be overpopulated, with a number of blank layers to display in most cases.
// We instead rely upon the KLS definition to ensure we keep the renders sparse.
//
// _legacyLayoutSpec is technically private, but it's what we've been using, so... yeah.
layers = Object.keys(keyman.core.activeKeyboard['_legacyLayoutSpec']?.KLS);
layers = Object.keys(keyman.inputProcessor.activeKeyboard['_legacyLayoutSpec']?.KLS);
}

// If mobile, or if the desktop definition lacks a `_legacyLayoutSpec` entry.
Expand All @@ -189,7 +189,7 @@ export class BatchRenderer {
return new Promise(function(resolve) {
// (Private API) Directly sets the keyboard layer within KMW, then uses .show to force-display it.
if(keyman.osk.vkbd) {
keyman.core.keyboardProcessor.layerId = layers[i];
keyman.inputProcessor.keyboardProcessor.layerId = layers[i];
} else {
// Again, occurs for keyboards with desktop help-text.
console.error(`Error - keyman.osk.vkbd is undefined for ${kbd.InternalName}!`);
Expand Down