From db6b61e8fca942fb6bd6093cd693b95cd674f4da Mon Sep 17 00:00:00 2001 From: Joshua Horton Date: Tue, 29 Apr 2025 10:54:37 +0700 Subject: [PATCH] change(web): address engine/js-processor linter errors --- web/src/engine/js-processor/src/deadkeys.ts | 22 ++-- .../engine/js-processor/src/kbdInterface.ts | 104 +++++++++--------- .../js-processor/src/keyboardProcessor.ts | 40 +++---- web/src/engine/js-processor/src/mock.ts | 10 +- .../engine/js-processor/src/outputTarget.ts | 6 +- .../engine/js-processor/src/ruleBehavior.ts | 14 +-- .../engine/js-processor/src/systemStores.ts | 8 +- 7 files changed, 102 insertions(+), 102 deletions(-) diff --git a/web/src/engine/js-processor/src/deadkeys.ts b/web/src/engine/js-processor/src/deadkeys.ts index 31bfa1100d..53cf0d5995 100644 --- a/web/src/engine/js-processor/src/deadkeys.ts +++ b/web/src/engine/js-processor/src/deadkeys.ts @@ -14,7 +14,7 @@ export class Deadkey { } match(p: number, d: number): boolean { - var result:boolean = (this.p == p && this.d == d); + const result:boolean = (this.p == p && this.d == d); return result; } @@ -32,7 +32,7 @@ export class Deadkey { } clone(): Deadkey { - let dk = new Deadkey(this.p, this.d); + const dk = new Deadkey(this.p, this.d); dk.o = this.o; return dk; @@ -65,8 +65,8 @@ export class DeadkeyTracker { } clone(): DeadkeyTracker { - let dkt = new DeadkeyTracker(); - let dks = this.toSortedArray(); + const dkt = new DeadkeyTracker(); + const dks = this.toSortedArray(); // Make sure to clone the deadkeys themselves - the Deadkey object is mutable. dkt.dks = []; @@ -91,9 +91,9 @@ export class DeadkeyTracker { return false; // I3318 } - var sp=caretPos; + const sp=caretPos; n = sp - n; - for(var i = 0; i < this.dks.length; i++) { + for(let i = 0; i < this.dks.length; i++) { // Don't re-match an already-matched deadkey. It's possible to have two identical // entries, and they should be kept separately. if(this.dks[i].match(n, d) && !this.dks[i].matched) { @@ -114,7 +114,7 @@ export class DeadkeyTracker { } remove(dk: Deadkey) { - var index = this.dks.indexOf(dk); + const index = this.dks.indexOf(dk); this.dks.splice(index, 1); } @@ -123,13 +123,13 @@ export class DeadkeyTracker { } resetMatched() { - for(let dk of this.dks) { + for(const dk of this.dks) { dk.reset(); } } deleteMatched(): void { - for(var Li = 0; Li < this.dks.length; Li++) { + for(let Li = 0; Li < this.dks.length; Li++) { if(this.dks[Li].matched) { this.dks.splice(Li--, 1); // Don't forget to decrement! } @@ -148,7 +148,7 @@ export class DeadkeyTracker { return; } - for(let dk of this.dks) { + for(const dk of this.dks) { if(dk.p > Lstart) { dk.p += Ldelta; } @@ -163,7 +163,7 @@ export class DeadkeyTracker { const otherDks = other.dks; const matchedDks: Deadkey[] = []; - for(let dk of this.dks) { + for(const dk of this.dks) { const match = otherDks.find((otherDk) => dk.equal(otherDk)); if(!match) { return false; diff --git a/web/src/engine/js-processor/src/kbdInterface.ts b/web/src/engine/js-processor/src/kbdInterface.ts index efca7b8a80..d3c2593807 100644 --- a/web/src/engine/js-processor/src/kbdInterface.ts +++ b/web/src/engine/js-processor/src/kbdInterface.ts @@ -157,7 +157,7 @@ class CachedContextEx { } clone(): CachedContextEx { - let r = new CachedContextEx(); + const r = new CachedContextEx(); r._cache = this._cache; return r; } @@ -231,7 +231,7 @@ export default class KeyboardInterface extends KeyboardHarness { registerKeyboard(Pk: any): void { // NOTE: This implementation is web-core specific and is intentionally replaced, whole-sale, // by DOM-aware code. - let keyboard = new Keyboard(Pk); + const keyboard = new Keyboard(Pk); this.loadedKeyboard = keyboard; } @@ -250,12 +250,12 @@ export default class KeyboardInterface extends KeyboardHarness { */ context(n: number, ln: number, outputTarget: OutputTarget): string { - var v = this.cachedContext.get(n, ln); + const v = this.cachedContext.get(n, ln); if(v !== null) { return v; } - var r = this.KC_(n, ln, outputTarget); + const r = this.KC_(n, ln, outputTarget); this.cachedContext.set(n, ln, r); return r; } @@ -274,7 +274,7 @@ export default class KeyboardInterface extends KeyboardHarness { * KC(10,10,Pelem) == "XXXXabcdef" i.e. return as much as possible of the requested string, where X = \uFFFE */ private KC_(n: number, ln: number, outputTarget: OutputTarget): string { - var tempContext = ''; + let tempContext = ''; // If we have a selection, we have an empty context tempContext = outputTarget.isSelectionEmpty() ? outputTarget.getTextBeforeCaret() : ""; @@ -300,7 +300,7 @@ export default class KeyboardInterface extends KeyboardHarness { * KN(4,Pelem) == TRUE */ nul(n: number, outputTarget: OutputTarget): boolean { - var cx=this.context(n+1, 1, outputTarget); + const cx=this.context(n+1, 1, outputTarget); // With #31, the result will be a replacement character if context is empty. return cx === "\uFFFE"; @@ -317,7 +317,7 @@ export default class KeyboardInterface extends KeyboardHarness { * Description Test keyboard context for match */ contextMatch(n: number, outputTarget: OutputTarget, val: string, ln: number): boolean { - var cx=this.context(n, ln, outputTarget); + const cx=this.context(n, ln, outputTarget); if(cx === val) { return true; // I3318 } @@ -334,7 +334,7 @@ export default class KeyboardInterface extends KeyboardHarness { * @return {Array} Context array (of strings and numbers) */ private _BuildExtendedContext(n: number, ln: number, outputTarget: OutputTarget): CachedExEntry { - var cache: CachedExEntry = this.cachedContextEx.get(n, ln); + let cache: CachedExEntry = this.cachedContextEx.get(n, ln); if(cache !== null) { return cache; } else { @@ -343,15 +343,15 @@ export default class KeyboardInterface extends KeyboardHarness { cache = this.cachedContextEx.get(n, n); if(cache === null) { // First, let's make sure we have a cloned, sorted copy of the deadkey array. - let unmatchedDeadkeys = outputTarget.deadkeys().toSortedArray(); // Is reverse-order sorted for us already. + const unmatchedDeadkeys = outputTarget.deadkeys().toSortedArray(); // Is reverse-order sorted for us already. // Time to build from scratch! - var index = 0; + let index = 0; cache = { valContext: [], deadContext: []}; while(cache.valContext.length < n) { // As adapted from `deadkeyMatch`. - var sp = outputTarget.getDeadkeyCaret(); - var deadPos = sp - index; + const sp = outputTarget.getDeadkeyCaret(); + const deadPos = sp - index; if(unmatchedDeadkeys.length > 0 && unmatchedDeadkeys[0].p > deadPos) { // We have deadkeys at the right-hand side of the caret! They don't belong in the context, so pop 'em off. unmatchedDeadkeys.splice(0, 1); @@ -363,7 +363,7 @@ export default class KeyboardInterface extends KeyboardHarness { unmatchedDeadkeys.splice(0, 1); } else { // Take the character. We get "\ufffe" if it doesn't exist. - var kc = this.context(++index, 1, outputTarget); + const kc = this.context(++index, 1, outputTarget); cache.valContext = ([kc] as (string|number)[]).concat(cache.valContext); } } @@ -371,7 +371,7 @@ export default class KeyboardInterface extends KeyboardHarness { } // Now that we have the cache... - var subCache = cache; + const subCache = cache; subCache.valContext = subCache.valContext.slice(0, ln); this.cachedContextEx.set(n, ln, subCache); @@ -392,32 +392,32 @@ export default class KeyboardInterface extends KeyboardHarness { */ fullContextMatch(n: number, outputTarget: OutputTarget, rule: ContextEntry[]): boolean { // Stage one: build the context index map. - var fullContext = this._BuildExtendedContext(n, rule.length, outputTarget); + const fullContext = this._BuildExtendedContext(n, rule.length, outputTarget); this.ruleContextEx = this.cachedContextEx.clone(); - var context = fullContext.valContext; - var deadContext = fullContext.deadContext; + const context = fullContext.valContext; + const deadContext = fullContext.deadContext; - var mismatch = false; + let mismatch = false; // This symbol internally indicates lack of context in a position. (See KC_) const NUL_CONTEXT = "\uFFFE"; - var assertNever = function(x: never): never { + const assertNever = function(x: never): never { // Could be accessed by improperly handwritten calls to `fullContextMatch`. throw new Error("Unexpected object in fullContextMatch specification: " + x); } // Stage two: time to match against the rule specified. - for(var i=0; i < rule.length; i++) { + for(let i=0; i < rule.length; i++) { if(typeof rule[i] == 'string') { - var str = rule[i] as string; + const str = rule[i] as string; if(str !== context[i]) { mismatch = true; break; } } else { // TypeScript needs a cast to this intermediate type to do its discriminated union magic. - var r = rule[i] as ContextNonCharEntry; + const r = rule[i] as ContextNonCharEntry; switch(r.t) { case 'd': // We still need to set a flag here; @@ -428,7 +428,7 @@ export default class KeyboardInterface extends KeyboardHarness { } break; case 'a': - var lookup: KeyboardStoreElement; + let lookup: KeyboardStoreElement; if(typeof context[i] == 'string') { lookup = context[i] as string; @@ -436,7 +436,7 @@ export default class KeyboardInterface extends KeyboardHarness { lookup = {'t': 'd', 'd': context[i] as number}; } - var result = this.any(i, lookup, r.a); + const result = this.any(i, lookup, r.a); if(!r.n) { // If it's a standard 'any'... if(!result) { @@ -454,7 +454,7 @@ export default class KeyboardInterface extends KeyboardHarness { break; case 'i': // The context will never hold a 'beep.' - var ch = this._Index(r.i, r.o) as string | RuleDeadkey; + const ch = this._Index(r.i, r.o) as string | RuleDeadkey; if(ch !== undefined && (typeof(ch) == 'string' ? ch : ch.d) !== context[i]) { mismatch = true; @@ -552,12 +552,12 @@ export default class KeyboardInterface extends KeyboardHarness { * Description Test keystroke with modifiers against rule */ keyMatch(e: KeyEvent, Lruleshift:number, Lrulekey:number): boolean { - var retVal = false; // I3318 - var keyCode = (e.Lcode == 173 ? 189 : e.Lcode); //I3555 (Firefox hyphen issue) + let retVal = false; // I3318 + let keyCode = (e.Lcode == 173 ? 189 : e.Lcode); //I3555 (Firefox hyphen issue) - let bitmask = this.activeKeyboard.modifierBitmask; - var modifierBitmask = bitmask & Codes.modifierBitmasks["ALL"]; - var stateBitmask = bitmask & Codes.stateBitmasks["ALL"]; + const bitmask = this.activeKeyboard.modifierBitmask; + const modifierBitmask = bitmask & Codes.modifierBitmasks["ALL"]; + const stateBitmask = bitmask & Codes.stateBitmasks["ALL"]; const eventModifiers = KeyboardInterface.matchModifiersToRuleChirality(e.Lmodifiers, Lruleshift); @@ -598,7 +598,7 @@ export default class KeyboardInterface extends KeyboardHarness { * Description Get object with extended key event information */ keyInformation(e: KeyEvent): KeyInformation { - var ei = new KeyInformation(); + const ei = new KeyInformation(); ei['vk'] = e.LisVirtualKey; ei['code'] = e.Lcode; ei['modifiers'] = e.Lmodifiers; @@ -633,7 +633,7 @@ export default class KeyboardInterface extends KeyboardHarness { _ExplodeStore(store: KeyboardStore): ComplexKeyboardStore { if(typeof(store) == 'string') { - let cachedStores = this.activeKeyboard.explodedStores; + const cachedStores = this.activeKeyboard.explodedStores; // Is the result cached? if(cachedStores[store]) { @@ -641,8 +641,8 @@ export default class KeyboardInterface extends KeyboardHarness { } // Nope, so let's build its cache. - var result: ComplexKeyboardStore = []; - for(var i=0; i < store._kmwLength(); i++) { + const result: ComplexKeyboardStore = []; + for(let i=0; i < store._kmwLength(); i++) { result.push(store._kmwCharAt(i)); } @@ -669,8 +669,8 @@ export default class KeyboardInterface extends KeyboardHarness { } s = this._ExplodeStore(s); - var Lix = -1; - for(var i=0; i < s.length; i++) { + let Lix = -1; + for(let i=0; i < s.length; i++) { const entry = s[i]; if(typeof(entry) == 'string') { if(s[i] == ch) { @@ -720,12 +720,12 @@ export default class KeyboardInterface extends KeyboardHarness { indexOutput(Pdn: number, Ps: KeyboardStore, Pn: number, outputTarget: OutputTarget): void { this.resetContextCache(); - var assertNever = function(x: never): never { + const assertNever = function(x: never): never { // Could be accessed by improperly handwritten calls to `fullContextMatch`. throw new Error("Unexpected object in fullContextMatch specification: " + x); } - var indexChar = this._Index(Ps, Pn); + const indexChar = this._Index(Ps, Pn); if(indexChar !== "") { if(typeof indexChar == 'string' ) { this.output(Pdn, outputTarget, indexChar); //I3319 @@ -756,15 +756,15 @@ export default class KeyboardInterface extends KeyboardHarness { * Description Keyboard output */ deleteContext(dn: number, outputTarget: OutputTarget): void { - var context: CachedExEntry; + let context: CachedExEntry; // We want to control exactly which deadkeys get removed. if(dn > 0) { context = this._BuildExtendedContext(dn, dn, outputTarget); let nulCount = 0; - for(var i=0; i < context.valContext.length; i++) { - var dk = context.deadContext[i]; + for(let i=0; i < context.valContext.length; i++) { + const dk = context.deadContext[i]; if(dk) { // Remove deadkey in context. @@ -780,7 +780,7 @@ export default class KeyboardInterface extends KeyboardHarness { // Prevent attempts to delete nul sentinels, as they don't exist in the actual context. // (Addresses regression from KMW v 12.0 paired with Developer bug through same version) - let contextLength = context.valContext.length - nulCount; + const contextLength = context.valContext.length - nulCount; if(dn > contextLength) { dn = contextLength; } @@ -874,8 +874,8 @@ export default class KeyboardInterface extends KeyboardHarness { * @return {boolean} True if the test succeeds */ ifStore(systemId: number, strValue: string, outputTarget: OutputTarget): boolean { - var result=true; - let store = this.systemStores[systemId]; + let result=true; + const store = this.systemStores[systemId]; if(store) { result = store.matches(strValue); } @@ -919,7 +919,7 @@ export default class KeyboardInterface extends KeyboardHarness { loadStore(kbdName: string, storeName:string, dfltValue:string): string { this.resetContextCache(); if(this.variableStoreSerializer) { - let cValue = this.variableStoreSerializer.loadStore(kbdName, storeName); + const cValue = this.variableStoreSerializer.loadStore(kbdName, storeName); return cValue[storeName] || dfltValue; } else { return dfltValue; @@ -939,13 +939,13 @@ export default class KeyboardInterface extends KeyboardHarness { */ saveStore(storeName:string, optValue:string): boolean { this.resetContextCache(); - var kbd=this.activeKeyboard; + const kbd=this.activeKeyboard; if(!kbd || typeof kbd.id == 'undefined' || kbd.id == '') { return false; } // And the lookup under that entry looks for the value under the store name, again. - let valueObj: VariableStore = {}; + const valueObj: VariableStore = {}; valueObj[storeName] = optValue; // Null-check in case of invocation during unit-test @@ -1035,7 +1035,7 @@ export default class KeyboardInterface extends KeyboardHarness { this.resetContextCache(); // Capture the initial state of the OutputTarget before any rules are matched. - let preInput = Mock.from(outputTarget, true); + const preInput = Mock.from(outputTarget, true); // Capture the initial state of any variable stores const cachedVariableStores = this.activeKeyboard.variableStores; @@ -1049,7 +1049,7 @@ export default class KeyboardInterface extends KeyboardHarness { // Calls the start-group of the active keyboard. this.activeTargetOutput = outputTarget; - var matched = callee(outputTarget, keystroke); + const matched = callee(outputTarget, keystroke); this.activeTargetOutput = null; // Finalize the rule's results. @@ -1069,7 +1069,7 @@ export default class KeyboardInterface extends KeyboardHarness { this.ruleBehavior.triggerKeyDefault = !matched; // Clear our result-tracking variable to prevent any possible pollution for future processing. - let behavior = this.ruleBehavior; + const behavior = this.ruleBehavior; this.ruleBehavior = null; return behavior; @@ -1098,9 +1098,9 @@ export default class KeyboardInterface extends KeyboardHarness { */ static __publishShorthandAPI() { // Keyboard callbacks - let prototype = this.prototype; + const prototype = this.prototype; - var exportKBCallback = function(miniName: string, longName: keyof KeyboardInterface) { + const exportKBCallback = function(miniName: string, longName: keyof KeyboardInterface) { if(prototype[longName]) { // @ts-ignore prototype[miniName] = prototype[longName]; diff --git a/web/src/engine/js-processor/src/keyboardProcessor.ts b/web/src/engine/js-processor/src/keyboardProcessor.ts index dea537dfdf..9b2f656e30 100644 --- a/web/src/engine/js-processor/src/keyboardProcessor.ts +++ b/web/src/engine/js-processor/src/keyboardProcessor.ts @@ -129,12 +129,12 @@ export default class KeyboardProcessor extends EventEmitter { * @return {string} */ defaultRuleBehavior(Lkc: KeyEvent, outputTarget: OutputTarget, readonly: boolean): RuleBehavior { - let preInput = Mock.from(outputTarget, readonly); - let ruleBehavior = new RuleBehavior(); + const preInput = Mock.from(outputTarget, readonly); + const ruleBehavior = new RuleBehavior(); let matched = false; - var char = ''; - var special: EmulationKeystrokes; + let char = ''; + let special: EmulationKeystrokes; if(Lkc.isSynthetic || outputTarget.isSynthetic) { matched = true; // All the conditions below result in matches until the final else, which restores the expected default // if no match occurs. @@ -166,7 +166,7 @@ export default class KeyboardProcessor extends EventEmitter { } } - let isMnemonic = this.activeKeyboard && this.activeKeyboard.isMnemonic; + const isMnemonic = this.activeKeyboard && this.activeKeyboard.isMnemonic; if(!matched) { if((char = this.defaultRules.forAny(Lkc, isMnemonic, ruleBehavior)) != null) { @@ -192,7 +192,7 @@ export default class KeyboardProcessor extends EventEmitter { return ruleBehavior; } - let transcription = outputTarget.buildTranscriptionFrom(preInput, Lkc, readonly); + const transcription = outputTarget.buildTranscriptionFrom(preInput, Lkc, readonly); ruleBehavior.transcription = transcription; return ruleBehavior; @@ -211,7 +211,7 @@ export default class KeyboardProcessor extends EventEmitter { } processKeystroke(keyEvent: KeyEvent, outputTarget: OutputTarget): RuleBehavior { - var matchBehavior: RuleBehavior; + let matchBehavior: RuleBehavior; // Before keyboard rules apply, check if the left-context is empty. const nothingDeletable = outputTarget.getTextBeforeCaret().kmwLength() == 0 && outputTarget.isSelectionEmpty(); @@ -244,7 +244,7 @@ export default class KeyboardProcessor extends EventEmitter { // Match against the 'default keyboard' - rules to mimic the default string output when typing in a browser. // Many keyboards rely upon these 'implied rules'. - let defaultBehavior = this.defaultRuleBehavior(keyEvent, outputTarget, false); + const defaultBehavior = this.defaultRuleBehavior(keyEvent, outputTarget, false); if(defaultBehavior) { if(!matchBehavior) { matchBehavior = defaultBehavior; @@ -355,9 +355,9 @@ export default class KeyboardProcessor extends EventEmitter { * @return {boolean} return true if keyboard layer changed */ selectLayer(keyEvent: KeyEvent): boolean { - let keyName = keyEvent.kName; - var nextLayer = keyEvent.kNextLayer; - var isChiral = this.activeKeyboard && this.activeKeyboard.isChiral; + const keyName = keyEvent.kName; + let nextLayer = keyEvent.kNextLayer; + const isChiral = this.activeKeyboard && this.activeKeyboard.isChiral; // Layer must be identified by name, not number (27/08/2015) if(typeof nextLayer == 'number') { @@ -438,20 +438,20 @@ export default class KeyboardProcessor extends EventEmitter { * @param {string} id layer id (e.g. ctrlshift) */ updateLayer(keyEvent: KeyEvent, id: string) { - let activeLayer = this.layerId; - var s = activeLayer; + const activeLayer = this.layerId; + let s = activeLayer; // Do not change layer unless needed (27/08/2015) if(id == activeLayer && keyEvent.device.formFactor != DeviceSpec.FormFactor.Desktop) { return; } - var idx=id; - var i; + let idx=id; + let i; if(keyEvent.device.formFactor == DeviceSpec.FormFactor.Desktop) { // Need to test if target layer is a standard layer (based on the plain 'default') - var replacements= ['leftctrl', 'rightctrl', 'ctrl', 'leftalt', 'rightalt', 'alt', 'shift']; + const replacements= ['leftctrl', 'rightctrl', 'ctrl', 'leftalt', 'rightalt', 'alt', 'shift']; for(i=0; i < replacements.length; i++) { // Don't forget to remove the kebab-case hyphens! @@ -471,7 +471,7 @@ export default class KeyboardProcessor extends EventEmitter { // if(idx == '') with accompanying if-else structural shift would be a far better test here. else { // Save our current modifier state. - var modifier=Codes.getModifierState(s); + let modifier=Codes.getModifierState(s); // Strip down to the base modifiable layer. for(i=0; i < replacements.length; i++) { @@ -526,14 +526,14 @@ export default class KeyboardProcessor extends EventEmitter { s = id; } - let layout = this.activeKeyboard.layout(keyEvent.device.formFactor); + const layout = this.activeKeyboard.layout(keyEvent.device.formFactor); if(layout.getLayer(s)) { this.layerId = s; } else { this.layerId = 'default'; } - let baseModifierState = Codes.getModifierState(this.layerId); + const baseModifierState = Codes.getModifierState(this.layerId); this.modStateFlags = baseModifierState | keyEvent.Lstates; } @@ -603,7 +603,7 @@ export default class KeyboardProcessor extends EventEmitter { setNumericLayer(device: DeviceSpec) { if (this.activeKeyboard) { - let layout = this.activeKeyboard.layout(device.formFactor); + const layout = this.activeKeyboard.layout(device.formFactor); if(layout.getLayer('numeric')) { this.layerId = 'numeric'; } diff --git a/web/src/engine/js-processor/src/mock.ts b/web/src/engine/js-processor/src/mock.ts index e44b76e759..dacdbe2e15 100644 --- a/web/src/engine/js-processor/src/mock.ts +++ b/web/src/engine/js-processor/src/mock.ts @@ -13,7 +13,7 @@ export class Mock extends OutputTarget { super(); this.text = text ? text : ""; - var defaultLength = this.text._kmwLength(); + const defaultLength = this.text._kmwLength(); // Ensures that `caretPos == 0` is handled correctly. this.selStart = typeof selStart == "number" ? selStart : defaultLength; @@ -31,7 +31,7 @@ export class Mock extends OutputTarget { if (outputTarget instanceof Mock) { // Avoids the need to run expensive kmwstring.ts / `_kmwLength()` // calculations when deep-copying Mock instances. - let priorMock = outputTarget as Mock; + const priorMock = outputTarget as Mock; clone = new Mock(priorMock.text, priorMock.selStart, priorMock.selEnd); } else { const text = outputTarget.getText(); @@ -42,8 +42,8 @@ export class Mock extends OutputTarget { let selectionEnd: number = 0; if (outputTarget.hasSelection()) { - let beforeText = outputTarget.getTextBeforeCaret(); - let afterText = outputTarget.getTextAfterCaret(); + const beforeText = outputTarget.getTextBeforeCaret(); + const afterText = outputTarget.getTextAfterCaret(); selectionStart = beforeText._kmwLength(); selectionEnd = textLen - afterText._kmwLength(); } @@ -88,7 +88,7 @@ export class Mock extends OutputTarget { this.selForward = end >= start; if (!this.selForward) { - let temp = this.selStart; + const temp = this.selStart; this.selStart = this.selEnd; this.selEnd = temp; } diff --git a/web/src/engine/js-processor/src/outputTarget.ts b/web/src/engine/js-processor/src/outputTarget.ts index 4b6aac6af6..59773d6f35 100644 --- a/web/src/engine/js-processor/src/outputTarget.ts +++ b/web/src/engine/js-processor/src/outputTarget.ts @@ -46,7 +46,7 @@ export class Transcription { private static tokenSeed: number = 0; constructor(keystroke: KeyEvent, transform: TextTransform, preInput: Mock, alternates?: Alternate[]/*, removedDks: Deadkey[], insertedDks: Deadkey[]*/) { - let token = this.token = Transcription.tokenSeed++; + const token = this.token = Transcription.tokenSeed++; this.keystroke = keystroke; this.transform = transform; @@ -94,7 +94,7 @@ export default abstract class OutputTarget implements OutputTargetInterface { } insertDeadkeyBeforeCaret(d: number) { - var dk: Deadkey = new Deadkey(this.getDeadkeyCaret(), d); + const dk: Deadkey = new Deadkey(this.getDeadkeyCaret(), d); this.deadkeys().add(dk); } @@ -146,7 +146,7 @@ export default abstract class OutputTarget implements OutputTargetInterface { } buildTranscriptionFrom(original: OutputTarget, keyEvent: KeyEvent, readonly: boolean, alternates?: Alternate[]): Transcription { - let transform = this.buildTransformFrom(original); + const transform = this.buildTransformFrom(original); // If we ever decide to re-add deadkey tracking, this is the place for it. diff --git a/web/src/engine/js-processor/src/ruleBehavior.ts b/web/src/engine/js-processor/src/ruleBehavior.ts index fd736f0fd8..16e11cbe55 100644 --- a/web/src/engine/js-processor/src/ruleBehavior.ts +++ b/web/src/engine/js-processor/src/ruleBehavior.ts @@ -74,8 +74,8 @@ export default class RuleBehavior { processor.beepHandler(outputTarget); } - for(let storeID in this.setStore) { - let sysStore = processor.keyboardInterface.systemStores[storeID]; + for(const storeID in this.setStore) { + const sysStore = processor.keyboardInterface.systemStores[storeID]; if(sysStore) { try { sysStore.set(this.setStore[storeID]); @@ -92,13 +92,13 @@ export default class RuleBehavior { processor.keyboardInterface.applyVariableStores(this.variableStores); if(processor.keyboardInterface.variableStoreSerializer) { - for(let storeID in this.saveStore) { + for(const storeID in this.saveStore) { processor.keyboardInterface.variableStoreSerializer.saveStore(processor.activeKeyboard.id, storeID, this.saveStore[storeID]); } } if(this.triggersDefaultCommand) { - let keyEvent = this.transcription.keystroke; + const keyEvent = this.transcription.keystroke; processor.defaultRules.applyCommand(keyEvent, outputTarget); } @@ -121,15 +121,15 @@ export default class RuleBehavior { * @param other */ mergeInDefaults(other: RuleBehavior) { - let keystroke = this.transcription.keystroke; - let keyFromOther = other.transcription.keystroke; + const keystroke = this.transcription.keystroke; + const keyFromOther = other.transcription.keystroke; if(keystroke.Lcode != keyFromOther.Lcode || keystroke.Lmodifiers != keyFromOther.Lmodifiers) { throw "RuleBehavior default-merge not supported unless keystrokes are identical!"; } this.triggersDefaultCommand = this.triggersDefaultCommand || other.triggersDefaultCommand; - let mergingMock = Mock.from(this.transcription.preInput, false); + const mergingMock = Mock.from(this.transcription.preInput, false); mergingMock.apply(this.transcription.transform); mergingMock.apply(other.transcription.transform); diff --git a/web/src/engine/js-processor/src/systemStores.ts b/web/src/engine/js-processor/src/systemStores.ts index 3288c9feff..e191e78bd2 100644 --- a/web/src/engine/js-processor/src/systemStores.ts +++ b/web/src/engine/js-processor/src/systemStores.ts @@ -96,11 +96,11 @@ export class PlatformSystemStore extends SystemStore { } matches(value: string) { - var i,constraint,constraints=value.split(' '); - let device = this.kbdInterface.activeDevice; + const constraints=value.split(' '); + const device = this.kbdInterface.activeDevice; - for(i=0; i