diff --git a/developer/docs/api/etc/kmc-convert.api.md b/developer/docs/api/etc/kmc-convert.api.md index d13c779d7a2..da7ddee4100 100644 --- a/developer/docs/api/etc/kmc-convert.api.md +++ b/developer/docs/api/etc/kmc-convert.api.md @@ -8,18 +8,21 @@ import { CompilerCallbacks } from '@keymanapp/developer-utils'; import { CompilerEvent } from '@keymanapp/developer-utils'; import { CompilerOptions } from '@keymanapp/developer-utils'; import { KeymanCompiler } from '@keymanapp/developer-utils'; +import { KeymanCompilerArtifactOptional } from '@keymanapp/developer-utils'; import { KeymanCompilerArtifacts } from '@keymanapp/developer-utils'; import { KeymanCompilerResult } from '@keymanapp/developer-utils'; // @public export class Converter implements KeymanCompiler { init(callbacks: CompilerCallbacks, options: CompilerOptions): Promise; - // Warning: (ae-forgotten-export) The symbol "ConverterResult" needs to be exported by the entry point main.d.ts run(inputFilename: string, outputFilename?: string): Promise; - // Warning: (ae-forgotten-export) The symbol "ConverterArtifacts" needs to be exported by the entry point main.d.ts write(artifacts: ConverterArtifacts): Promise; } +// @public (undocumented) +export interface ConverterArtifacts extends KeymanCompilerArtifacts { +} + // Warning: (ae-internal-missing-underscore) The name "ConverterMessages" should be prefixed with an underscore because the declaration is marked as @internal // // @internal (undocumented) @@ -96,6 +99,23 @@ export interface ConverterOptions extends CompilerOptions { failIfIncomplete?: boolean; } +// @public (undocumented) +export interface ConverterResult extends KeymanCompilerResult { + artifacts: ConverterArtifacts; +} + +// @public +export interface ConverterToKmnArtifacts extends ConverterArtifacts { + keymanTouchLayout?: KeymanCompilerArtifactOptional; + kmn?: KeymanCompilerArtifactOptional; + kvks?: KeymanCompilerArtifactOptional; +} + +// @public (undocumented) +export interface ConverterToKmnResult extends ConverterResult { + artifacts: ConverterToKmnArtifacts; +} + // (No @packageDocumentation comment for this package) ``` diff --git a/developer/docs/help/reference/api/index.md b/developer/docs/help/reference/api/index.md index caac7457fed..d26265f817a 100644 --- a/developer/docs/help/reference/api/index.md +++ b/developer/docs/help/reference/api/index.md @@ -9,6 +9,7 @@ | Package | Description | | --- | --- | | [@keymanapp/kmc-analyze](./kmc-analyze.md) | kmc-analyze - keyboard analysis classes, including tools for &displayMap. | +| [@keymanapp/kmc-convert](./kmc-convert.md) | kmc-convert - conversion tool between keyboard layouts (e.g. .keylayout -> .kmn). | | [@keymanapp/kmc-keyboard-info](./kmc-keyboard-info.md) | | | [@keymanapp/kmc-kmn](./kmc-kmn.md) | kmc-kmn - Keyman keyboard compiler | | [@keymanapp/kmc-ldml](./kmc-ldml.md) | | diff --git a/developer/docs/help/reference/api/kmc-convert.md b/developer/docs/help/reference/api/kmc-convert.md new file mode 100644 index 00000000000..a1fa965e2c6 --- /dev/null +++ b/developer/docs/help/reference/api/kmc-convert.md @@ -0,0 +1,3 @@ +# kmc-convert + +no entry at present \ No newline at end of file diff --git a/developer/docs/help/reference/kmc/api/index.md b/developer/docs/help/reference/kmc/api/index.md index e39a04f8aa6..fcda59f72ff 100644 --- a/developer/docs/help/reference/kmc/api/index.md +++ b/developer/docs/help/reference/kmc/api/index.md @@ -15,6 +15,7 @@ Module Name | NPM Package -------------------------------------------------|-------------------------------------------------------|------------------------------------|--------------- [kmc](../cli) | [@keymanapp/kmc][kmc-npm] | [GitHub][kmc-github] | The official command-line interface for all of the various compilers in Keyman Developer. [kmc-analyze](../../api/kmc-analyze) | [@keymanapp/kmc-analyze][kmc-analyze-npm] | [GitHub][kmc-analyze-github] | Provides Keyman keyboard analysis tools. +[kmc-convert](../../api/kmc-convert) | [@keymanapp/kmc-convert][kmc-convert-npm] | [GitHub][kmc-convert-github] | Converts between keyboard layouts (e.g. .keylayout -> .kmn) [kmc-keyboard-info](../../api/kmc-keyboard-info) | [@keymanapp/kmc-keyboard-info][kmc-keyboard-info-npm] | [GitHub][kmc-keyboard-info-github] | Builds a .keyboard_info file from a Keyman keyboard project. [kmc-kmn](../../api/kmc-kmn) | [@keymanapp/kmc-kmn][kmc-kmn-npm] | [GitHub][kmc-kmn-github] | Builds .kmn keyboards into .kmx binary keyboard files. [kmc-ldml](../../api/kmc-ldml) | [@keymanapp/kmc-ldml][kmc-ldml-npm] | [GitHub][kmc-ldml-github] | Builds LDML .xml keyboards into Keyman .kmx binary keyboard files. @@ -24,6 +25,7 @@ Module Name | NPM Package [kmc-npm]: https://npmjs.com/package/@keymanapp/kmc [kmc-analyze-npm]: https://npmjs.com/package/@keymanapp/kmc-analyze +[kmc-convert-npm]: https://npmjs.com/package/@keymanapp/kmc-convert [kmc-keyboard-info-npm]: https://npmjs.com/package/@keymanapp/kmc-keyboard-info [kmc-kmn-npm]: https://npmjs.com/package/@keymanapp/kmc-kmn [kmc-ldml-npm]: https://npmjs.com/package/@keymanapp/kmc-ldml @@ -34,6 +36,7 @@ Module Name | NPM Package [kmc-github]: https://github.com/keymanapp/keyman/tree/master/developer/src/kmc [kmc-analyze-github]: https://github.com/keymanapp/keyman/tree/master/developer/src/kmc-analyze +[kmc-convert-github]: https://github.com/keymanapp/keyman/tree/master/developer/src/kmc-convert [kmc-keyboard-info-github]: https://github.com/keymanapp/keyman/tree/master/developer/src/kmc-keyboard-info [kmc-kmn-github]: https://github.com/keymanapp/keyman/tree/master/developer/src/kmc-kmn [kmc-ldml-github]: https://github.com/keymanapp/keyman/tree/master/developer/src/kmc-ldml diff --git a/developer/docs/help/reference/kmc/cli/reference.md b/developer/docs/help/reference/kmc/cli/reference.md index 943e181ba5d..ce3fd219828 100644 --- a/developer/docs/help/reference/kmc/cli/reference.md +++ b/developer/docs/help/reference/kmc/cli/reference.md @@ -505,6 +505,14 @@ folder, and the files in that folder will follow the : A short description of the project, in Markdown. (default: lexical model name) +## `kmc convert` options + +Converts keyboard source files between formats e.g. .keylayout -> .kmn keeping the original name and saving the output with new extention + +`-p, --out-path ` + +: The target folder to write the copied project. + ## `kmc copy` options Copies a keyboard or lexical model project, renaming files matching the original diff --git a/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-file-reader.ts b/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-file-reader.ts index 7f95dfbcd59..34798d9a137 100644 --- a/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-file-reader.ts +++ b/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-file-reader.ts @@ -24,7 +24,7 @@ export class KeylayoutFileReader { * @param keyMapSelect the keyMapSelect element to find in keyMapSet * @return true if the keyMapSet element is found, false if not */ - public findMapIndexinKeymap(jsonObj: Keylayout.KeylayoutXMLSourceFile, keyMapSelect: Keylayout.KL_KeyMapSelect): boolean { + private findMapIndexinKeymap(jsonObj: Keylayout.KeylayoutXMLSourceFile, keyMapSelect: Keylayout.KL_KeyMapSelect): boolean { for (const keyMapSet of jsonObj.keyboard.keyMapSet) { for (const keyMap of keyMapSet.keyMap) { if (keyMap['index'] === keyMapSelect.mapIndex) { @@ -43,7 +43,7 @@ export class KeylayoutFileReader { * @param keyMap the keyMap element to find in modifierMap * @return true if the keyMap element is found, false if not */ - public findIndexinKeymapSelect(jsonObj: Keylayout.KeylayoutXMLSourceFile, keyMap: Keylayout.KL_KeyMap): boolean { + private findIndexinKeymapSelect(jsonObj: Keylayout.KeylayoutXMLSourceFile, keyMap: Keylayout.KL_KeyMap): boolean { for (const modifierMap of jsonObj.keyboard.modifierMap) { for (const keyMapSelect of modifierMap.keyMapSelect) { if (keyMapSelect['mapIndex'] === keyMap.index) { @@ -61,7 +61,7 @@ export class KeylayoutFileReader { * @param jsonObj the read keylayout data to be checked * @return true if all keyMapSelect elements have a corresponding keyMap element, false if not */ - public checkForCorrespondingElements(jsonObj: Keylayout.KeylayoutXMLSourceFile): boolean { + private checkForCorrespondingElements(jsonObj: Keylayout.KeylayoutXMLSourceFile): boolean { let available = true; // check if all keyMapSelect elements have a corresponding keyMap element in the .keylayout file @@ -83,7 +83,7 @@ export class KeylayoutFileReader { /** * @returns true if valid, false if invalid */ - public validate(source: Keylayout.KeylayoutXMLSourceFile, inputFilename: string): boolean { + private validate(source: Keylayout.KeylayoutXMLSourceFile, inputFilename: string): boolean { if (!source) { this.callbacks.reportMessage(ConverterMessages.Error_UnableToReadFile({ inputFilename: inputFilename })); return false; @@ -110,7 +110,7 @@ export class KeylayoutFileReader { * @param source the object to be changed * @return object that contain only boxed arrays */ - public boxArray(source: any) { + private boxArray(source: any) { boxXmlArray(source, 'modifierMap'); @@ -172,4 +172,13 @@ export class KeylayoutFileReader { return null; } } + + /** @internal */ + public unitTestEndpoints = { + findMapIndexinKeymap: this.findMapIndexinKeymap.bind(this), + findIndexinKeymapSelect: this.findIndexinKeymapSelect.bind(this), + checkForCorrespondingElements: this.checkForCorrespondingElements.bind(this), + validate: this.validate.bind(this), + boxArray: this.boxArray.bind(this), + }; }; diff --git a/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-to-kmn-converter.ts b/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-to-kmn-converter.ts index de678657340..b13756b5c99 100644 --- a/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-to-kmn-converter.ts +++ b/developer/src/kmc-convert/src/keylayout-to-kmn/keylayout-to-kmn-converter.ts @@ -108,7 +108,7 @@ export class KeylayoutToKmnConverter { return null; } try { - if (!KeylayoutReader.validate(jsonO, inputFilename)) { + if (!KeylayoutReader.unitTestEndpoints.validate(jsonO, inputFilename)) { return null; } } catch (e: any) { @@ -184,7 +184,7 @@ export class KeylayoutToKmnConverter { * @param jsonObj: json Object containing all data read from a keylayout file * @return an object containing the name of the input file, an array of behaviors and a populated array of Rules[] */ - public createRuleData(dataUkelele: ProcessedData, jsonObj: Keylayout.KeylayoutXMLSourceFile): ProcessedData | null { + private createRuleData(dataUkelele: ProcessedData, jsonObj: Keylayout.KeylayoutXMLSourceFile): ProcessedData | null { const rules: Rule[] = []; let dkCounterC3: number = 0; @@ -518,7 +518,7 @@ export class KeylayoutToKmnConverter { * @param dataUkelele: an object containing the name of the in/output file, an array of behaviors and an array of Rules * @return an object containing the name of the input file, an array of behaviors and the revised array of Rule[] */ - public reviewRuleInputData(dataUkelele: ProcessedData): ProcessedData { + private reviewRuleInputData(dataUkelele: ProcessedData): ProcessedData { // check for duplicate C2 and C3 rules in rules (e.g. [NCAPS RALT K_8] > dk(C12) ): create a separate array of unique rules, // then compare to rules and mark first occurrence of a rule in rules @@ -626,7 +626,7 @@ export class KeylayoutToKmnConverter { * @param isCAPSused : boolean flag to indicate if CAPS is used in a keylayout file or not * @return string - a modifier value suitable for use in a .kmn-file */ - public createKmnModifier(keylayoutModifier: string, isCAPSused: boolean): string { + private createKmnModifier(keylayoutModifier: string, isCAPSused: boolean): string { const kmnModifier: string[] = []; const modifierState = keylayoutModifier.split(" "); @@ -708,7 +708,7 @@ export class KeylayoutToKmnConverter { * @param keylayoutModifier the modifier string used in the .keylayout-file * @return "caps" or undefined if "caps" is not found */ - public checkIfCapsIsUsed(keylayoutModifier: string[][]): boolean { + private checkIfCapsIsUsed(keylayoutModifier: string[][]): boolean { if (!keylayoutModifier) return false; // make sure we always have a whitespace before and after each modifier( to distinguish from caps? ) @@ -716,11 +716,11 @@ export class KeylayoutToKmnConverter { } /** - * @brief member function to check if a modifier can be used in Keyman - * @param keylayoutModifier the modifier string used in the .keylayout-file - * @return true if the modifier can be used in keyman; false if not - */ - public isAcceptableKeymanModifier(keylayoutModifier: string): boolean { + * @brief member function to check if a modifier can be used in Keyman + * @param keylayoutModifier the modifier string used in the .keylayout-file + * @return true if the modifier can be used in keyman; false if not + */ + private isAcceptableKeymanModifier(keylayoutModifier: string): boolean { if (keylayoutModifier === null) return false; const modifierSingle = keylayoutModifier.toUpperCase().split(" "); @@ -737,7 +737,7 @@ export class KeylayoutToKmnConverter { * @param pos Ukelele (=mac) keycodes * @return VK */ - public mapUkeleleKeycodeToVK(pos: number): string { + private mapUkeleleKeycodeToVK(pos: number): string { const vk = [ "K_A" /* A */, "K_S" /* S */, @@ -799,12 +799,12 @@ export class KeylayoutToKmnConverter { } /** - * @brief member function to return an index for a given actionID - * @param data an object containing all data read from a .keylayout file - * @param search :string - value 'id' to be found - * @return a number specifying the index of an actionId - */ - public getActionIndexFromActionId(data: Keylayout.KeylayoutXMLSourceFile, search: string): number { + * @brief member function to return an index for a given actionID + * @param data an object containing all data read from a .keylayout file + * @param search :string - value 'id' to be found + * @return a number specifying the index of an actionId + */ + private getActionIndexFromActionId(data: Keylayout.KeylayoutXMLSourceFile, search: string): number { if (!data.keyboard?.actions?.action) { return -1; } @@ -817,12 +817,12 @@ export class KeylayoutToKmnConverter { } /** - * @brief member function to find the actionID of a certain state-next pair - * @param data an object containing all data read from a .keylayout file - * @param search :string value 'next' to be found - * @return a string containing the actionId of a certain state(none)-next pair - */ - public getActionIdFromActionNext(data: Keylayout.KeylayoutXMLSourceFile, search: string): string { + * @brief member function to find the actionID of a certain state-next pair + * @param data an object containing all data read from a .keylayout file + * @param search :string value 'next' to be found + * @return a string containing the actionId of a certain state(none)-next pair + */ + private getActionIdFromActionNext(data: Keylayout.KeylayoutXMLSourceFile, search: string): string { if (search !== "none" && data.keyboard?.actions?.action) { for (const action of data.keyboard.actions.action) { if (action.when) { @@ -843,7 +843,7 @@ export class KeylayoutToKmnConverter { * @param search : KeylayoutFileData[] - an array[{keycode,modifier}] to be found * @return a string[] containing modifiers */ - public getModifierArrayFromKeyModifierArray(data: ProcessedData["modifiers"], search: KeylayoutFileData[]): string[][] | [null] { + private getModifierArrayFromKeyModifierArray(data: ProcessedData["modifiers"], search: KeylayoutFileData[]): string[][] | [null] { const returnString1D: string[][] = []; for (let i = 0; i < search.length; i++) { if (search[i].behavior === undefined || search[i].behavior === null) { @@ -860,7 +860,7 @@ export class KeylayoutToKmnConverter { * @param search :string an actionId to be found * @return a string containing the output character */ - public getOutputFromActionIdNone(data: Keylayout.KeylayoutXMLSourceFile, search: string): string { + private getOutputFromActionIdNone(data: Keylayout.KeylayoutXMLSourceFile, search: string): string { let OutputValue: string = ""; if (!data.keyboard?.actions?.action) { @@ -880,12 +880,12 @@ export class KeylayoutToKmnConverter { } /** - * @brief member function to return array of [Keycode,Keyname,actionId,actionIDIndex, output] for a given actionID in of [ actionID,state,output] - * @param data an object containing all data read from a .keylayout file - * @param search :idStateOutputObject[] - array of [{ actionID,state,output }] - * @return a KeylayoutFileData[] containing [{Keycode,Keyname,actionId,actionID, output}] - */ - public getKeyActionOutputArrayFromActionStateOutputArray(data: Keylayout.KeylayoutXMLSourceFile, search: ActionStateOutput[]): KeylayoutFileData[] { + * @brief member function to return array of [Keycode,Keyname,actionId,actionIDIndex, output] for a given actionID in of [ actionID,state,output] + * @param data an object containing all data read from a .keylayout file + * @param search :idStateOutputObject[] - array of [{ actionID,state,output }] + * @return a KeylayoutFileData[] containing [{Keycode,Keyname,actionId,actionID, output}] + */ + private getKeyActionOutputArrayFromActionStateOutputArray(data: Keylayout.KeylayoutXMLSourceFile, search: ActionStateOutput[]): KeylayoutFileData[] { if ((search === undefined) || (search === null)) return []; @@ -918,7 +918,7 @@ export class KeylayoutToKmnConverter { * @param search : string a 'state' to be found * @return an array: idStateOutputObject[] containing all [{actionId, state, output}] for a certain state */ - public getActionStateOutputArrayFromActionState(data: Keylayout.KeylayoutXMLSourceFile, search: string): ActionStateOutput[] { + private getActionStateOutputArrayFromActionState(data: Keylayout.KeylayoutXMLSourceFile, search: string): ActionStateOutput[] { const actionStateOutput: ActionStateOutput[] = []; if (search !== "none" && data.keyboard?.actions?.action) { for (const action of data.keyboard.actions.action) { @@ -948,7 +948,7 @@ export class KeylayoutToKmnConverter { * @return an array: KeylayoutFileData[] containing [{KeyName,actionId,behavior,modifier,output}] */ - public getKeyBehaviorModOutputArrayFromKeyActionBehaviorOutputArray(data: Keylayout.KeylayoutXMLSourceFile, search: KeylayoutFileData[], isCAPSused: boolean): KeylayoutFileData[] { + private getKeyBehaviorModOutputArrayFromKeyActionBehaviorOutputArray(data: Keylayout.KeylayoutXMLSourceFile, search: KeylayoutFileData[], isCAPSused: boolean): KeylayoutFileData[] { const keyBehaviorModOutput = []; if (!((search === undefined) || (search === null) || (search.length === 0))) { for (let i = 0; i < search.length; i++) { @@ -990,7 +990,7 @@ export class KeylayoutToKmnConverter { * @param isCAPSused : boolean - flag to indicate if CAPS is used in a keylayout file or not * @return an array: KeylayoutFileData[] containing [{actionID,output, behavior,keyname,modifier}] */ - public getActionOutputBehaviorKeyModiFromActionIDStateOutput(data: Keylayout.KeylayoutXMLSourceFile, modi: string[][], search: string, outchar: string, isCapsused: boolean): KeylayoutFileData[] { + private getActionOutputBehaviorKeyModiFromActionIDStateOutput(data: Keylayout.KeylayoutXMLSourceFile, modi: string[][], search: string, outchar: string, isCapsused: boolean): KeylayoutFileData[] { const actionOutputBehaviorKeyModi = []; if ((!modi) || (search === "") || (search === undefined)) { return []; @@ -1037,7 +1037,7 @@ export class KeylayoutToKmnConverter { * @param search : string - an actionId to be found * @return an array: KeylayoutFileData[] containing [{keycode,behavior}] */ - public getKeyModifierArrayFromActionID(data: Keylayout.KeylayoutXMLSourceFile, search: string): KeylayoutFileData[] { + private getKeyModifierArrayFromActionID(data: Keylayout.KeylayoutXMLSourceFile, search: string): KeylayoutFileData[] { const mapIndexObject1D: KeylayoutFileData[] = []; for (let i = 0; i < data.keyboard.keyMapSet[0].keyMap.length; i++) { for (let j = 0; j < data.keyboard.keyMapSet[0].keyMap[i].key.length; j++) { @@ -1056,5 +1056,21 @@ export class KeylayoutToKmnConverter { /** @internal */ public unitTestEndpoints = { convert: this.convert.bind(this), + + reviewRuleInputData: this.reviewRuleInputData.bind(this), + createKmnModifier: this.createKmnModifier.bind(this), + checkIfCapsIsUsed: this.checkIfCapsIsUsed.bind(this), + isAcceptableKeymanModifier: this.isAcceptableKeymanModifier.bind(this), + mapUkeleleKeycodeToVK: this.mapUkeleleKeycodeToVK.bind(this), + + getActionIndexFromActionId: this.getActionIndexFromActionId.bind(this), + getActionIdFromActionNext: this.getActionIdFromActionNext.bind(this), + getModifierArrayFromKeyModifierArray: this.getModifierArrayFromKeyModifierArray.bind(this), + getOutputFromActionIdNone: this.getOutputFromActionIdNone.bind(this), + getKeyActionOutputArrayFromActionStateOutputArray: this.getKeyActionOutputArrayFromActionStateOutputArray.bind(this), + getActionStateOutputArrayFromActionState: this.getActionStateOutputArrayFromActionState.bind(this), + getKeyBehaviorModOutputArrayFromKeyActionBehaviorOutputArray: this.getKeyBehaviorModOutputArrayFromKeyActionBehaviorOutputArray.bind(this), + getActionOutputBehaviorKeyModiFromActionIDStateOutput: this.getActionOutputBehaviorKeyModiFromActionIDStateOutput.bind(this), + getKeyModifierArrayFromActionID: this.getKeyModifierArrayFromActionID.bind(this), }; } diff --git a/developer/src/kmc-convert/src/keylayout-to-kmn/kmn-file-writer.ts b/developer/src/kmc-convert/src/keylayout-to-kmn/kmn-file-writer.ts index a844488b658..148eb09783a 100644 --- a/developer/src/kmc-convert/src/keylayout-to-kmn/kmn-file-writer.ts +++ b/developer/src/kmc-convert/src/keylayout-to-kmn/kmn-file-writer.ts @@ -247,7 +247,7 @@ export class KmnFileWriter { * @param dataUkelele an object containing all data read from a .keylayout file * @return string - all stores to be printed */ - public writeKmnFileHeader(dataUkelele: ProcessedData | null): string { + private writeKmnFileHeader(dataUkelele: ProcessedData | null): string { if (!dataUkelele) { return ""; } @@ -277,7 +277,7 @@ export class KmnFileWriter { * @param dataUkelele an object containing all data read from a .keylayout file * @return string - all rules to be printed */ - public writeDataRules(dataUkelele: ProcessedData | null): string { + private writeDataRules(dataUkelele: ProcessedData | null): string { if (!dataUkelele) { return ""; } @@ -325,7 +325,7 @@ export class KmnFileWriter { // lookup key nr of the key which is being processed let keyNr: number = 0; for (let j = 0; j <= KeylayoutToKmnConverter.MAX_KEY_IDENTIFIER; j++) { - if (keylayoutKmnConverter.mapUkeleleKeycodeToVK(j) === uniqueDataRules[k].key) { + if (keylayoutKmnConverter.unitTestEndpoints.mapUkeleleKeycodeToVK(j) === uniqueDataRules[k].key) { keyNr = j; break; } @@ -588,7 +588,7 @@ export class KmnFileWriter { * https://docs.google.com/document/d/12J3NGO6RxIthCpZDTR8FYSRjiMgXJDLwPY2z9xqKzJ0/edit?tab=t.0#heading=h.16sx096j6jmy * @return outMsg the warning message array for all parts */ - public createWarningText(inObj: RuleReview, posWarning: number = 2): string[] { + private createWarningText(inObj: RuleReview, posWarning: number = 2): string[] { const outMsg = [...inObj.warningMessages]; @@ -653,7 +653,7 @@ export class KmnFileWriter { // if the dk is unavailable, the modifiers of the dependant C0 rule will get a warning 'unavailable superior rule ' if (inObj.Dk_modifier) { - const mod_OK = new KeylayoutToKmnConverter(this.callbacks, this.options).isAcceptableKeymanModifier(inObj.Dk_modifier); + const mod_OK = new KeylayoutToKmnConverter(this.callbacks, this.options).unitTestEndpoints.isAcceptableKeymanModifier(inObj.Dk_modifier); if ((outMsg[1].lastIndexOf('unavailable modifier') < 0)) outMsg[1] += (!mod_OK) ? 'unavailable modifier ' : ''; @@ -768,7 +768,7 @@ export class KmnFileWriter { * @param index the index of a rule in Rule[] * @return a string[] containing possible warnings for a rule */ - public reviewRules(rule: Rule[], index: number): RuleReview { + private reviewRules(rule: Rule[], index: number): RuleReview { const unavailableModiWarnings = { type: 'UnavailableModifier', @@ -803,7 +803,7 @@ export class KmnFileWriter { // ------------------------- check unavailable modifiers ------------------------- if ((rule[index].ruleType === "C0") || (rule[index].ruleType === "C1")) { - if (!keylayoutKmnConverter.isAcceptableKeymanModifier(rule[index].modifierKey)) { + if (!keylayoutKmnConverter.unitTestEndpoints.isAcceptableKeymanModifier(rule[index].modifierKey)) { unavailableModiWarnings.compare_type = 'unav_C0_C1'; unavailableModiWarnings.warningMessages = this.createWarningText(unavailableModiWarnings); } @@ -811,7 +811,7 @@ export class KmnFileWriter { else if (rule[index].ruleType === "C2") { - if (!keylayoutKmnConverter.isAcceptableKeymanModifier(rule[index].modifierDeadkey)) { + if (!keylayoutKmnConverter.unitTestEndpoints.isAcceptableKeymanModifier(rule[index].modifierDeadkey)) { unavailableSuperiWarnings.compare_type = 'unav_C2'; unavailableSuperiWarnings.dk_prefix = ['C', 'A']; unavailableSuperiWarnings.dk_id = [rule[index].idPrevDeadkey, rule[index].idDeadkey]; @@ -820,7 +820,7 @@ export class KmnFileWriter { unavailableSuperiWarnings.warningMessages = this.createWarningText(unavailableSuperiWarnings); } - if (!keylayoutKmnConverter.isAcceptableKeymanModifier(rule[index].modifierKey)) { + if (!keylayoutKmnConverter.unitTestEndpoints.isAcceptableKeymanModifier(rule[index].modifierKey)) { unavailableModiWarnings.compare_type = 'unav_C2'; unavailableModiWarnings.modifier = rule[index].modifierKey; unavailableModiWarnings.key = rule[index].key; @@ -830,7 +830,7 @@ export class KmnFileWriter { else if (rule[index].ruleType === "C3") { - if (!keylayoutKmnConverter.isAcceptableKeymanModifier(rule[index].modifierPrevDeadkey)) { + if (!keylayoutKmnConverter.unitTestEndpoints.isAcceptableKeymanModifier(rule[index].modifierPrevDeadkey)) { unavailableSuperiWarnings.compare_type = 'unav_C3'; unavailableSuperiWarnings.dk_prefix = ['A', 'B']; unavailableSuperiWarnings.dk_id = [rule[index].idPrevDeadkey, rule[index].idDeadkey]; @@ -841,7 +841,7 @@ export class KmnFileWriter { unavailableSuperiWarnings.warningMessages = this.createWarningText(unavailableSuperiWarnings, 2); } - if (!keylayoutKmnConverter.isAcceptableKeymanModifier(rule[index].modifierDeadkey)) { + if (!keylayoutKmnConverter.unitTestEndpoints.isAcceptableKeymanModifier(rule[index].modifierDeadkey)) { unavailableSuperiWarnings.compare_type = 'unav_C3'; unavailableSuperiWarnings.prevDk_modifier = rule[index].modifierPrevDeadkey; unavailableSuperiWarnings.prevDk_key = rule[index].prevDeadkey; @@ -852,7 +852,7 @@ export class KmnFileWriter { unavailableSuperiWarnings.warningMessages = this.createWarningText(unavailableSuperiWarnings, 2); } - if (!keylayoutKmnConverter.isAcceptableKeymanModifier(rule[index].modifierKey)) { + if (!keylayoutKmnConverter.unitTestEndpoints.isAcceptableKeymanModifier(rule[index].modifierKey)) { unavailableModiWarnings.compare_type = 'unav_C3'; unavailableModiWarnings.modifier = rule[index].modifierKey; unavailableModiWarnings.key = rule[index].key; @@ -1298,7 +1298,7 @@ export class KmnFileWriter { * a non-control character will be written as itself ( 'A', '1', '፩', '😎') * null in case of an empty string or null or undefined input */ - public writeCharacterOrUnicode(ctr: string, msg: string = ""): MessageCharacter | null { + private writeCharacterOrUnicode(ctr: string, msg: string = ""): MessageCharacter | null { if ((ctr === null) || (ctr === undefined)) { return null; @@ -1355,7 +1355,7 @@ export class KmnFileWriter { rest_string: ctr as string, carryOver: '' }; - out.character = (UnicodeCharacterConversion.processXmlValue(xmlOutputData)).replaced_string ?? ""; + out.character = UnicodeCharacterConversion.processXmlValue(xmlOutputData).replaced_string ?? ""; // msg if a possibly invalid html will be written e.g. @ > &123 &abc ሴ if ((out.character.indexOf('&') > -1) && (out.character.length > 1)) { @@ -1378,10 +1378,13 @@ export class KmnFileWriter { return out; } - /** @internal */ public unitTestEndpoints = { + writeKmnFileHeader: this.writeKmnFileHeader.bind(this), + writeDataRules: this.writeDataRules.bind(this), + createWarningText: this.createWarningText.bind(this), reviewRules: this.reviewRules.bind(this), + writeCharacterOrUnicode: this.writeCharacterOrUnicode.bind(this), }; } diff --git a/developer/src/kmc-convert/test/keylayout-file-reader.tests.ts b/developer/src/kmc-convert/test/keylayout-file-reader.tests.ts index 7760fc13db9..0f98513867e 100644 --- a/developer/src/kmc-convert/test/keylayout-file-reader.tests.ts +++ b/developer/src/kmc-convert/test/keylayout-file-reader.tests.ts @@ -25,7 +25,7 @@ describe('KeylayoutFileReader', function () { const sutR = new KeylayoutFileReader(compilerTestCallbacks); const inputFilename = makePathToFixture('../data/Test.keylayout'); const result: Keylayout.KeylayoutXMLSourceFile | null = sutR.read(compilerTestCallbacks.loadFile(inputFilename)); - const validated = sutR.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); + const validated = sutR.unitTestEndpoints.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); assert.isTrue(validated); }); @@ -33,7 +33,7 @@ describe('KeylayoutFileReader', function () { const sutR = new KeylayoutFileReader(compilerTestCallbacks); const inputFilename = makePathToFixture('../data/Test_unknownTags.keylayout'); const result: Keylayout.KeylayoutXMLSourceFile | null = sutR.read(compilerTestCallbacks.loadFile(inputFilename)); - const validated = sutR.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); + const validated = sutR.unitTestEndpoints.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); assert.isFalse(validated); }); @@ -41,33 +41,33 @@ describe('KeylayoutFileReader', function () { const sutR = new KeylayoutFileReader(compilerTestCallbacks); const inputFilename = makePathToFixture('../data/Test_additionalTags.keylayout'); const result: Keylayout.KeylayoutXMLSourceFile | null = sutR.read(compilerTestCallbacks.loadFile(inputFilename)); - const validated = sutR.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); + const validated = sutR.unitTestEndpoints.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); assert.isFalse(validated); }); it('validate() should return false on inputfile with missing tags', async function () { const sutR = new KeylayoutFileReader(compilerTestCallbacks); const inputFilename = makePathToFixture('../data/Test_missingTags.keylayout'); const result: Keylayout.KeylayoutXMLSourceFile | null = sutR.read(compilerTestCallbacks.loadFile(inputFilename)); - const validated = sutR.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); + const validated = sutR.unitTestEndpoints.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); assert.isFalse(validated); }); it('validate() should return false on no entries in action-when', async function () { const sutR = new KeylayoutFileReader(compilerTestCallbacks); const inputFilename = makePathToFixture('../data/Test_noActionWhen.keylayout'); const result: Keylayout.KeylayoutXMLSourceFile | null = sutR.read(compilerTestCallbacks.loadFile(inputFilename)); - const validated = sutR.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); + const validated = sutR.unitTestEndpoints.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); assert.isFalse(validated); }); it('validate() should return false on null as input', async function () { const sutR = new KeylayoutFileReader(compilerTestCallbacks); const inputFilename = makePathToFixture('../data/Test_noActionWhen.keylayout'); - const validated = sutR.validate(null, inputFilename); + const validated = sutR.unitTestEndpoints.validate(null, inputFilename); assert.isFalse(validated); }); it('validate() should return false on undefined as input', async function () { const sutR = new KeylayoutFileReader(compilerTestCallbacks); const inputFilename = makePathToFixture('../data/Test_noActionWhen.keylayout'); - const validated = sutR.validate(undefined, inputFilename); + const validated = sutR.unitTestEndpoints.validate(undefined, inputFilename); assert.isFalse(validated); }); }); @@ -76,7 +76,7 @@ describe('KeylayoutFileReader', function () { const sutR = new KeylayoutFileReader(compilerTestCallbacks); const inputFilename = makePathToFixture('../data/Test_unknownTags.keylayout'); const result: Keylayout.KeylayoutXMLSourceFile | null = sutR.read(compilerTestCallbacks.loadFile(inputFilename)); - const validated = sutR.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); + const validated = sutR.unitTestEndpoints.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); assert.isFalse(validated); }); @@ -84,7 +84,7 @@ describe('KeylayoutFileReader', function () { const sutR = new KeylayoutFileReader(compilerTestCallbacks); const inputFilename = makePathToFixture('../data/Test_additionalTags.keylayout'); const result: Keylayout.KeylayoutXMLSourceFile | null = sutR.read(compilerTestCallbacks.loadFile(inputFilename)); - const validated = sutR.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); + const validated = sutR.unitTestEndpoints.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); assert.isFalse(validated); }); @@ -92,7 +92,7 @@ describe('KeylayoutFileReader', function () { const sutR = new KeylayoutFileReader(compilerTestCallbacks); const inputFilename = makePathToFixture('../data/Test_missingTags.keylayout'); const result: Keylayout.KeylayoutXMLSourceFile | null = sutR.read(compilerTestCallbacks.loadFile(inputFilename)); - const validated = sutR.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); + const validated = sutR.unitTestEndpoints.validate(result as Keylayout.KeylayoutXMLSourceFile, inputFilename); assert.isFalse(validated); }); }); @@ -153,7 +153,7 @@ describe('findMapIndexinKeymap ', function () { ].forEach(function (values) { it(("findMapIndexinKeymap(keyMapSelect.mapIndex = '" + values[0] + "')").padEnd(40, " ") + "should return " + "'" + values[1] + "'", async function () { keyMapSelect.mapIndex = values[0] as string; - const result = sutR.findMapIndexinKeymap(jsonO as Keylayout.KeylayoutXMLSourceFile, keyMapSelect); + const result = sutR.unitTestEndpoints.findMapIndexinKeymap(jsonO as Keylayout.KeylayoutXMLSourceFile, keyMapSelect); assert.isTrue(result === values[1]); }); }); @@ -183,7 +183,7 @@ describe('findIndexinKeymapSelect ', function () { ].forEach(function (values) { it(("findIndexinKeymapSelect(keyMap.index = '" + values[0] + "')").padEnd(40, " ") + "should return " + "'" + values[1] + "'", async function () { keyMap.index = values[0] as string; - const result = sutR.findIndexinKeymapSelect(jsonO as Keylayout.KeylayoutXMLSourceFile, keyMap); + const result = sutR.unitTestEndpoints.findIndexinKeymapSelect(jsonO as Keylayout.KeylayoutXMLSourceFile, keyMap); assert.isTrue(result === values[1]); }); }); @@ -200,7 +200,7 @@ describe('checkForCorrespondingElements ', function () { ].forEach(function (values) { it(("checkForCorrespondingElements in " + values[0]).padEnd(40, " ") + " should return " + "'" + values[1] + "'", async function () { const jsonO: Keylayout.KeylayoutXMLSourceFile | null = sutR.read(compilerTestCallbacks.loadFile(makePathToFixture(values[0] as string))); - const result = sutR.checkForCorrespondingElements(jsonO as Keylayout.KeylayoutXMLSourceFile); + const result = sutR.unitTestEndpoints.checkForCorrespondingElements(jsonO as Keylayout.KeylayoutXMLSourceFile); assert.isTrue(result === values[1]); }); }); diff --git a/developer/src/kmc-convert/test/keylayout-to-kmn-converter.tests.ts b/developer/src/kmc-convert/test/keylayout-to-kmn-converter.tests.ts index 16406876672..635c19d838f 100644 --- a/developer/src/kmc-convert/test/keylayout-to-kmn-converter.tests.ts +++ b/developer/src/kmc-convert/test/keylayout-to-kmn-converter.tests.ts @@ -257,7 +257,7 @@ describe('KeylayoutToKmnConverter', function () { ['roption', true, 'NCAPS RALT'], ].forEach(function (values) { it(('should convert "' + values[0] + '"').padEnd(36, " ") + 'to "' + values[2] + '"', async function () { - const result = sut.createKmnModifier(values[0] as string, values[1] as boolean); + const result = sut.unitTestEndpoints.createKmnModifier(values[0] as string, values[1] as boolean); assert.equal(result, values[2]); }); }); @@ -281,7 +281,7 @@ describe('KeylayoutToKmnConverter', function () { [null, false], ].forEach(function (values) { it(("isAcceptableKeymanModifier(" + values[0] + ")").padEnd(38, " ") + ' should return ' + values[1], async function () { - const result = sut.isAcceptableKeymanModifier(values[0] as string); + const result = sut.unitTestEndpoints.isAcceptableKeymanModifier(values[0] as string); assert.equal(result, values[1]); }); }); @@ -303,7 +303,7 @@ describe('KeylayoutToKmnConverter', function () { [, ''], ].forEach(function (values) { it(("mapUkeleleKeycodeToVK(" + values[0] + ")").padEnd(26, " ") + "should return " + "'" + values[1] + "'", async function () { - const result = sut.mapUkeleleKeycodeToVK(values[0] as number); + const result = sut.unitTestEndpoints.mapUkeleleKeycodeToVK(values[0] as number); assert.equal(result, values[1]); }); }); @@ -328,7 +328,7 @@ describe('KeylayoutToKmnConverter', function () { [[[' ', ' '], [' ']], false], ].forEach(function (values) { it(("checkIfCapsIsUsed(" + values[0] + ")").padEnd(40, " ") + "should return " + "'" + values[1] + "'", async function () { - const result = sut.checkIfCapsIsUsed(values[0] as string[][]); + const result = sut.unitTestEndpoints.checkIfCapsIsUsed(values[0] as string[][]); assert.equal(result, values[1]); }); }); @@ -356,7 +356,7 @@ describe('KeylayoutToKmnConverter', function () { it((values[1] !== null) ? ("getModifierArrayFromKeyModifierArray('" + JSON.stringify(values[0]) + "')").padEnd(68, " ") + " should return '" + JSON.stringify(values[1]) + "'" : ("getModifierArrayFromKeyModifierArray('" + JSON.stringify(values[0]) + "')").padEnd(68, " ") + " should return '" + "null" + "'", async function () { - const result = sut.getModifierArrayFromKeyModifierArray(converted?.modifiers as string[][], values[0] as unknown as KeylayoutFileData[]); + const result = sut.unitTestEndpoints.getModifierArrayFromKeyModifierArray(converted?.modifiers as string[][], values[0] as unknown as KeylayoutFileData[]); assert.deepStrictEqual(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -384,7 +384,7 @@ describe('KeylayoutToKmnConverter', function () { } } it(("getKeyModifierArrayFromActionID('" + values[0] + "')").padEnd(57, " ") + ' should return ' + outstring.substring(0, outstring.lastIndexOf(']') + 2) + " ]", async function () { - const result = sut.getKeyModifierArrayFromActionID(read as KeylayoutXMLSourceFile, String(values[0])); + const result = sut.unitTestEndpoints.getKeyModifierArrayFromActionID(read as KeylayoutXMLSourceFile, String(values[0])); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -410,7 +410,7 @@ describe('KeylayoutToKmnConverter', function () { ['unknown', ''], ].forEach(function (values) { it(("getActionIdFromActionNext('" + values[0] + "')").padEnd(49, " ") + ' should return ' + "'" + values[1] + "'", async function () { - const result = sut.getActionIdFromActionNext(read as KeylayoutXMLSourceFile, String(values[0])); + const result = sut.unitTestEndpoints.getActionIdFromActionNext(read as KeylayoutXMLSourceFile, String(values[0])); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -434,7 +434,7 @@ describe('KeylayoutToKmnConverter', function () { ['unknown', -1], ].forEach(function (values) { it(("getActionIndexFromActionId('" + values[0] + "')").padEnd(50, " ") + ' should return ' + values[1], async function () { - const result = sut.getActionIndexFromActionId(read as KeylayoutXMLSourceFile, String(values[0])); + const result = sut.unitTestEndpoints.getActionIndexFromActionId(read as KeylayoutXMLSourceFile, String(values[0])); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -454,7 +454,7 @@ describe('KeylayoutToKmnConverter', function () { ].forEach(function (values) { it( ("getOutputFromActionIdNone('" + values[0] + "')").padEnd(56, " ") + ' should return ' + "'" + values[1] + "'", async function () { - const result = sut.getOutputFromActionIdNone(read as KeylayoutXMLSourceFile, String(values[0])); + const result = sut.unitTestEndpoints.getOutputFromActionIdNone(read as KeylayoutXMLSourceFile, String(values[0])); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -464,7 +464,7 @@ describe('KeylayoutToKmnConverter', function () { [99, ''], ].forEach(function (values) { it(("getOutputFromActionIdNone('" + values[0] + "')").padEnd(56, " ") + ' should return ' + values[1], async function () { - const result = sut.getOutputFromActionIdNone(read as KeylayoutXMLSourceFile, String(values[0])); + const result = sut.unitTestEndpoints.getOutputFromActionIdNone(read as KeylayoutXMLSourceFile, String(values[0])); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -547,7 +547,7 @@ describe('KeylayoutToKmnConverter', function () { it((JSON.stringify(values[1]).length > 60) ? 'an array of objects should return an array of objects' : stringIn.padEnd(74, " ") + ' should return ' + stringOut, async function () { - const result = sut.getKeyBehaviorModOutputArrayFromKeyActionBehaviorOutputArray(read as KeylayoutXMLSourceFile, values[0], isCapsUsed); + const result = sut.unitTestEndpoints.getKeyBehaviorModOutputArrayFromKeyActionBehaviorOutputArray(read as KeylayoutXMLSourceFile, values[0], isCapsUsed); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -561,7 +561,7 @@ describe('KeylayoutToKmnConverter', function () { const stringOut = "['" + values[1].actionId + "', '" + "', '" + values[1].modifier + "', '" + values[1].key + "', '" + values[1].outchar + "']"; it(stringIn.padEnd(74, " ") + ' should return ' + stringOut, async function () { - const result = sut.getKeyBehaviorModOutputArrayFromKeyActionBehaviorOutputArray(read as KeylayoutXMLSourceFile, [values[0]], isCapsUsed); + const result = sut.unitTestEndpoints.getKeyBehaviorModOutputArrayFromKeyActionBehaviorOutputArray(read as KeylayoutXMLSourceFile, [values[0]], isCapsUsed); assert.equal(JSON.stringify(result), JSON.stringify([values[1]])); }); }); @@ -572,7 +572,7 @@ describe('KeylayoutToKmnConverter', function () { ].forEach(function (values) { const isCaps = true; it(("getKeybehaviorModOutputArrayFromKeyActionbehaviorOutputArray([" + values[0] + "])").padEnd(74, " ") + ' should return ' + "[" + values[1] + "]", async function () { - const result = sut.getKeyBehaviorModOutputArrayFromKeyActionBehaviorOutputArray(read as KeylayoutXMLSourceFile, values[0] ?? [], isCaps); + const result = sut.unitTestEndpoints.getKeyBehaviorModOutputArrayFromKeyActionBehaviorOutputArray(read as KeylayoutXMLSourceFile, values[0] ?? [], isCaps); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -619,7 +619,7 @@ describe('KeylayoutToKmnConverter', function () { it((JSON.stringify(values[1]).length > 30) ? ("getActionStateOutputArrayFromActionState('" + values[0] + "')").padEnd(60, " ") + ' should return an array of objects' : ("getActionStateOutputArrayFromActionState('" + values[0] + "')").padEnd(60, " ") + ' should return ' + "'" + JSON.stringify(values[1]) + "'", async function () { - const result = sut.getActionStateOutputArrayFromActionState(read as KeylayoutXMLSourceFile, String(values[0])); + const result = sut.unitTestEndpoints.getActionStateOutputArrayFromActionState(read as KeylayoutXMLSourceFile, String(values[0])); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -656,7 +656,7 @@ describe('KeylayoutToKmnConverter', function () { it((JSON.stringify(values[3]).length > 35) ? ("getActionOutputbehaviorKeyModiFromActionIDStateOutput('" + values[0] + "', '" + values[1] + "', " + values[2] + ")").padEnd(67, " ") + ' should return an array of objects' : ("getActionOutputbehaviorKeyModiFromActionIDStateOutput('" + values[0] + "', '" + values[1] + "', " + values[2] + ")").padEnd(67, " ") + ' should return ' + "'" + JSON.stringify(values[3]) + "'", async function () { - const result = sut.getActionOutputBehaviorKeyModiFromActionIDStateOutput(read as KeylayoutXMLSourceFile, converted.modifiers, String(values[0]), String(values[1]), Boolean(values[2])); + const result = sut.unitTestEndpoints.getActionOutputBehaviorKeyModiFromActionIDStateOutput(read as KeylayoutXMLSourceFile, converted.modifiers, String(values[0]), String(values[1]), Boolean(values[2])); assert.equal(JSON.stringify(result), JSON.stringify(values[3])); }); }); @@ -710,7 +710,7 @@ describe('KeylayoutToKmnConverter', function () { [[b6ActionIdArr, b1KeycodeArr], ].forEach(function (values) { it(("getKeyActionOutputArrayFromActionStateOutputArray([['" + JSON.stringify(values[0]) + "'],..])").padEnd(73, " ") + '1 should return an array of objects', async function () { - const result = sut.getKeyActionOutputArrayFromActionStateOutputArray(read as KeylayoutXMLSourceFile, values[0] as ActionStateOutput[]); + const result = sut.unitTestEndpoints.getKeyActionOutputArrayFromActionStateOutputArray(read as KeylayoutXMLSourceFile, values[0] as ActionStateOutput[]); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -740,7 +740,7 @@ describe('KeylayoutToKmnConverter', function () { [[{ "id": "A_0", "state": "", "output": "ˆ" }], oneEntryResult], ].forEach(function (values) { it(("getKeyActionOutputArrayFromActionStateOutputArray(['" + JSON.stringify(values[0]) + "'])").padEnd(73, " ") + ' should return an array of objects', async function () { - const result = sut.getKeyActionOutputArrayFromActionStateOutputArray(read as KeylayoutXMLSourceFile, values[0] as ActionStateOutput[]); + const result = sut.unitTestEndpoints.getKeyActionOutputArrayFromActionStateOutputArray(read as KeylayoutXMLSourceFile, values[0] as ActionStateOutput[]); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -751,7 +751,7 @@ describe('KeylayoutToKmnConverter', function () { ].forEach(function (values) { it(("getKeyActionOutputArrayFromActionStateOutputArray(" + JSON.stringify(values[0]) + ")").padEnd(73, " ") + ' should return ' + "'[" + JSON.stringify(values[1]) + "]'", async function () { - const result = sut.getKeyActionOutputArrayFromActionStateOutputArray(read as KeylayoutXMLSourceFile, values[0] as ActionStateOutput[]); + const result = sut.unitTestEndpoints.getKeyActionOutputArrayFromActionStateOutputArray(read as KeylayoutXMLSourceFile, values[0] as ActionStateOutput[]); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); @@ -761,7 +761,7 @@ describe('KeylayoutToKmnConverter', function () { [null, []], ].forEach(function (values) { it(("getKeyActionOutputArrayFromActionStateOutputArray(" + JSON.stringify(values[0]) + ")").padEnd(73, " ") + ' should return ' + "'[" + JSON.stringify(values[1]) + "]'", async function () { - const result = sut.getKeyActionOutputArrayFromActionStateOutputArray(read as KeylayoutXMLSourceFile, values[0] as ActionStateOutput[]); + const result = sut.unitTestEndpoints.getKeyActionOutputArrayFromActionStateOutputArray(read as KeylayoutXMLSourceFile, values[0] as ActionStateOutput[]); assert.equal(JSON.stringify(result), JSON.stringify(values[1])); }); }); diff --git a/developer/src/kmc-convert/test/kmn-file-writer.tests.ts b/developer/src/kmc-convert/test/kmn-file-writer.tests.ts index fba3d3f3d8d..0bf5a3201c1 100644 --- a/developer/src/kmc-convert/test/kmn-file-writer.tests.ts +++ b/developer/src/kmc-convert/test/kmn-file-writer.tests.ts @@ -31,7 +31,7 @@ describe('KmnFileWriter', function () { const converted = sut.unitTestEndpoints.convert(read as Keylayout.KeylayoutXMLSourceFile, inputFilename.replace(/\.keylayout$/, '.kmn')); it('writeDataRules() should return true (no error) if written', async function () { - const result = sutW.writeDataRules(converted); + const result = sutW.unitTestEndpoints.writeDataRules(converted); assert.isTrue(result.length > 0); }); @@ -63,7 +63,7 @@ describe('KmnFileWriter', function () { + "\n"; it(('writeKmnFileHeader should return store text with filename ').padEnd(62, " ") + 'on correct input', async function () { - const writtenCorrectName = sutW.writeKmnFileHeader(converted); + const writtenCorrectName = sutW.unitTestEndpoints.writeKmnFileHeader(converted); assert.equal(writtenCorrectName, (outExpectedFirst + (converted?.keylayoutFilename ?? "") + outExpectedLast)); }); }); @@ -403,7 +403,7 @@ describe('KmnFileWriter', function () { modifiers: [[]], rules: values[0] as Rule[] }; - const result1 = sutW.writeDataRules(data); + const result1 = sutW.unitTestEndpoints.writeDataRules(data); assert.isTrue(result1 === values[1][0]); }); }); @@ -427,7 +427,7 @@ describe('KmnFileWriter', function () { ['', '', 'Msg empty output or unsupported numerical html entity '], ].forEach(function (values) { it(('should convert "' + values[0] + '"').padEnd(25, " ") + 'to "' + values[1] + '"', async function () { - const result = sutW.writeCharacterOrUnicode(values[0] as string, "Msg "); + const result = sutW.unitTestEndpoints.writeCharacterOrUnicode(values[0] as string, "Msg "); assert.isNotNull(result); assert.equal(result?.character, values[1]); assert.equal(result?.message, values[2]);