diff --git a/developer/src/kmc-kmn/src/compiler/kmn-compiler-messages.ts b/developer/src/kmc-kmn/src/compiler/kmn-compiler-messages.ts index b85a7086e6..06f74ae59f 100644 --- a/developer/src/kmc-kmn/src/compiler/kmn-compiler-messages.ts +++ b/developer/src/kmc-kmn/src/compiler/kmn-compiler-messages.ts @@ -1,4 +1,4 @@ -import { KeyAddress } from "../kmw-compiler/validate-layout-file.js"; +import { KeyAddress } from "../kmw-compiler/compile-layout-file.js"; import { kmnfile } from "../kmw-compiler/compiler-globals.js"; import { CompilerErrorNamespace, CompilerErrorSeverity, CompilerEvent, CompilerMessageSpec as m, CompilerMessageObjectSpec as mx, CompilerMessageDef as def, CompilerMessageSpecWithException, KeymanUrls } from "@keymanapp/developer-utils"; import { ObjectWithCompileContext } from "@keymanapp/common-types"; diff --git a/developer/src/kmc-kmn/src/kmw-compiler/validate-layout-file.ts b/developer/src/kmc-kmn/src/kmw-compiler/compile-layout-file.ts similarity index 95% rename from developer/src/kmc-kmn/src/kmw-compiler/validate-layout-file.ts rename to developer/src/kmc-kmn/src/kmw-compiler/compile-layout-file.ts index 1c904b9db8..b029e29f54 100644 --- a/developer/src/kmc-kmn/src/kmw-compiler/validate-layout-file.ts +++ b/developer/src/kmc-kmn/src/kmw-compiler/compile-layout-file.ts @@ -245,7 +245,18 @@ function TransformSpecialKeys17(FDebug: boolean, sLayoutFile: string): string { return sLayoutFile; } -export function ValidateLayoutFile(fk: KMX.KEYBOARD, FDebug: boolean, sLayoutFile: string, sVKDictionary: string, displayMap: Osk.PuaMap): VLFOutput { // I4060 // I4139 +/** + * Compile a .keyman-touch-layout file into the internal Javascript object that KeymanWeb expects + * @param data + * @param FDictionary + * @returns null if the file is structurally invalid; false if the file contains content errors, true otherwise + * + * This function performs several steps: + * - load and validate the touch layout file + * - remap the layout keys with displayMap + * - injects 'special keys' javascript transforms for downlevel support + */ +export function CompileLayoutFile(fk: KMX.KEYBOARD, FDebug: boolean, sLayoutFile: string, sVKDictionary: string, displayMap: Osk.PuaMap): VLFOutput { // I4060 // I4139 const FDictionary: string[] = sVKDictionary.split(/\s+/); CheckDictionaryKeyValidity(fk, FDictionary); // I4142 @@ -362,7 +373,7 @@ function validateLayoutFileContent(data: TouchLayout.TouchLayoutFile, FDictionar let direction: keyof TouchLayout.TouchLayoutFlick; if(key.flick) { if(typeof(key.flick) != "object") { - callbacks.reportMessage(KmwCompilerMessages.Error_InvalidTouchLayoutFileFormat({msg: 'platform.layer must be an array'})); + callbacks.reportMessage(KmwCompilerMessages.Error_InvalidTouchLayoutFileFormat({msg: 'key.flick must be an object'})); return null; } for(direction in key.flick) { diff --git a/developer/src/kmc-kmn/src/kmw-compiler/kmw-compiler-messages.ts b/developer/src/kmc-kmn/src/kmw-compiler/kmw-compiler-messages.ts index e58b5fb9bf..106b04bcfb 100644 --- a/developer/src/kmc-kmn/src/kmw-compiler/kmw-compiler-messages.ts +++ b/developer/src/kmc-kmn/src/kmw-compiler/kmw-compiler-messages.ts @@ -1,6 +1,6 @@ import { keyAddress, KmnCompilerMessages } from "../compiler/kmn-compiler-messages.js"; import { CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageDef as def, CompilerMessageSpec as m } from "@keymanapp/developer-utils"; -import { KeyAddress } from "./validate-layout-file.js"; +import { KeyAddress } from "./compile-layout-file.js"; const Namespace = CompilerErrorNamespace.KmwCompiler; const SevInfo = CompilerErrorSeverity.Info | Namespace; diff --git a/developer/src/kmc-kmn/src/kmw-compiler/kmw-compiler.ts b/developer/src/kmc-kmn/src/kmw-compiler/kmw-compiler.ts index 4319108bc7..37a5560840 100644 --- a/developer/src/kmc-kmn/src/kmw-compiler/kmw-compiler.ts +++ b/developer/src/kmc-kmn/src/kmw-compiler/kmw-compiler.ts @@ -4,7 +4,7 @@ import { ExpandSentinel, incxstr, xstrlen } from "./util.js"; import { options, nl, FTabStop, setupGlobals, callbacks, FFix183_LadderLength, FCallFunctions, fk, minimumKeymanVersionToString, isKeyboardVersion10OrLater, isKeyboardVersion17OrLater } from "./compiler-globals.js"; import { JavaScript_ContextMatch, JavaScript_KeyAsString, JavaScript_Name, JavaScript_OutputString, JavaScript_Rules, JavaScript_Shift, JavaScript_ShiftAsString, JavaScript_Store, zeroPadHex } from './javascript-strings.js'; import { KmwCompilerMessages } from "./kmw-compiler-messages.js"; -import { ValidateLayoutFile } from "./validate-layout-file.js"; +import { CompileLayoutFile } from "./compile-layout-file.js"; import { VisualKeyboardFromFile } from "./visual-keyboard-compiler.js"; import { KmnCompilerResult, STORETYPE_DEBUG, STORETYPE_OPTION, STORETYPE_RESERVED } from "../compiler/compiler.js"; @@ -166,7 +166,7 @@ export function WriteCompiledKeyboard( if (sLayoutFilename != '') { // I3483 sLayoutFilename = callbacks.resolveFilename(kmnfile, sLayoutFilename); - const result = ValidateLayoutFile(keyboard, options.saveDebug, sLayoutFilename, sVKDictionary, kmxResult.displayMap); + const result = CompileLayoutFile(keyboard, options.saveDebug, sLayoutFilename, sVKDictionary, kmxResult.displayMap); if(!result) { sLayoutFile = ''; return null; diff --git a/developer/src/kmc-kmn/test/kmw/validate-layout-file.tests.ts b/developer/src/kmc-kmn/test/kmw/compile-layout-file.tests.ts similarity index 93% rename from developer/src/kmc-kmn/test/kmw/validate-layout-file.tests.ts rename to developer/src/kmc-kmn/test/kmw/compile-layout-file.tests.ts index 07b2e828e8..350fb509df 100644 --- a/developer/src/kmc-kmn/test/kmw/validate-layout-file.tests.ts +++ b/developer/src/kmc-kmn/test/kmw/compile-layout-file.tests.ts @@ -9,10 +9,10 @@ import { TestCompilerCallbacks } from '@keymanapp/developer-test-helpers'; // import { KmnCompiler } from '../../src/compiler/compiler.js'; import { KMX, TouchLayout } from '@keymanapp/common-types'; import { KmwCompilerMessages } from '../../src/kmw-compiler/kmw-compiler-messages.js'; -import { unitTestEndpoints } from '../../src/kmw-compiler/validate-layout-file.js'; +import { unitTestEndpoints } from '../../src/kmw-compiler/compile-layout-file.js'; import { setupGlobals } from '../../src/kmw-compiler/compiler-globals.js'; -describe('validate-layout-file', function() { +describe('compile-layout-file', function() { const callbacks = new TestCompilerCallbacks(this); const options = { shouldAddCompilerVersion: false,