diff --git a/common/web/types/build.sh b/common/web/types/build.sh index 44696964d5..457c7938a5 100755 --- a/common/web/types/build.sh +++ b/common/web/types/build.sh @@ -73,34 +73,16 @@ function compile_schemas() { node tools/schema-bundler.js } -function copy_cldr_imports() { - # Store CLDR imports - # load all versions that have a cldr_info.json - for CLDR_INFO_PATH in "$KEYMAN_ROOT/resources/standards-data/ldml-keyboards/"*/cldr_info.json - do - # TODO-LDML: developer/src/inst/download.in.mak needs these also... - CLDR_PATH=$(dirname "$CLDR_INFO_PATH") - CLDR_VER=$(basename "$CLDR_PATH") - mkdir -p "$THIS_SCRIPT_PATH/build/src/import/$CLDR_VER" - # TODO-LDML: When these are copied, the DOCTYPE will break due to the wrong path. We don't use the DTD so it should be OK. - cp "$CLDR_INFO_PATH" "$CLDR_PATH/import/"*.xml "$THIS_SCRIPT_PATH/build/src/import/$CLDR_VER/" - done -} function do_configure() { compile_schemas verify_npm_setup } -function do_build() { - copy_cldr_imports - tsc --build -} - function do_test() { eslint . tsc --build test - readonly C8_THRESHOLD=70 + readonly C8_THRESHOLD=40 c8 -skip-full --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha "${builder_extra_params[@]}" builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal." builder_echo warning "Please increase threshold in build.sh as test coverage improves." @@ -110,6 +92,6 @@ function do_test() { builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo builder_run_action configure do_configure -builder_run_action build do_build +builder_run_action build tsc --build builder_run_action test do_test builder_run_action publish builder_publish_npm diff --git a/common/web/types/src/kmx/element-string.ts b/common/web/types/src/kmx/kmx-plus/element-string.ts similarity index 94% rename from common/web/types/src/kmx/element-string.ts rename to common/web/types/src/kmx/kmx-plus/element-string.ts index 1b24c3eb45..c7597b4f6b 100644 --- a/common/web/types/src/kmx/element-string.ts +++ b/common/web/types/src/kmx/kmx-plus/element-string.ts @@ -1,8 +1,9 @@ import { constants } from '@keymanapp/ldml-keyboard-constants'; import { DependencySections, StrsItem, UsetItem } from './kmx-plus.js'; -import { ElementParser, ElementSegment, ElementType } from '../ldml-keyboard/pattern-parser.js'; -import { MATCH_HEX_ESCAPE } from '../util/consts.js'; -import { unescapeOneQuadString } from '../util/util.js'; +import { ElementParser, ElementSegment, ElementType } from '../../ldml-keyboard/pattern-parser.js'; +import { util } from '@keymanapp/common-types'; +import MATCH_HEX_ESCAPE = util.MATCH_HEX_ESCAPE; +import unescapeOneQuadString = util.unescapeOneQuadString; export enum ElemElementFlags { none = 0, diff --git a/common/web/types/src/kmx/kmx-plus.ts b/common/web/types/src/kmx/kmx-plus/kmx-plus.ts similarity index 97% rename from common/web/types/src/kmx/kmx-plus.ts rename to common/web/types/src/kmx/kmx-plus/kmx-plus.ts index 6e3c73d33c..1d19cdd4d0 100644 --- a/common/web/types/src/kmx/kmx-plus.ts +++ b/common/web/types/src/kmx/kmx-plus/kmx-plus.ts @@ -1,12 +1,18 @@ import { constants } from '@keymanapp/ldml-keyboard-constants'; import * as r from 'restructure'; import { ElementString } from './element-string.js'; -import { ListItem } from './string-list.js'; -import { isOneChar, toOneChar, unescapeString, escapeStringForRegex } from '../util/util.js'; -import { KMXFile } from './kmx.js'; -import { UnicodeSetParser, UnicodeSet } from '@keymanapp/common-types'; -import { VariableParser } from '../ldml-keyboard/pattern-parser.js'; -import { MarkerParser } from '../ldml-keyboard/pattern-parser.js'; +import { ListItem } from '../../ldml-keyboard/string-list.js'; +import { util } from '@keymanapp/common-types'; +import { KMX } from '@keymanapp/common-types'; +import { UnicodeSetParser, UnicodeSet } from '../../ldml-keyboard/unicodeset-parser-api.js'; +import { VariableParser } from '../../ldml-keyboard/pattern-parser.js'; +import { MarkerParser } from '../../ldml-keyboard/pattern-parser.js'; + +import isOneChar = util.isOneChar; +import toOneChar = util.toOneChar; +import unescapeString = util.unescapeString; +import escapeStringForRegex = util.escapeStringForRegex; +import KMXFile = KMX.KMXFile; // Implementation of file structures from /core/src/ldml/C7043_ldml.md // Writer in kmx-builder.ts diff --git a/common/web/types/src/kmx/string-list.ts b/common/web/types/src/ldml-keyboard/string-list.ts similarity index 94% rename from common/web/types/src/kmx/string-list.ts rename to common/web/types/src/ldml-keyboard/string-list.ts index f68e905369..5d11a5ca7c 100644 --- a/common/web/types/src/kmx/string-list.ts +++ b/common/web/types/src/ldml-keyboard/string-list.ts @@ -1,5 +1,5 @@ -import { OrderedStringList } from '../ldml-keyboard/pattern-parser.js'; -import { DependencySections, StrsItem, StrsOptions } from './kmx-plus.js'; +import { OrderedStringList } from './pattern-parser.js'; +import { DependencySections, StrsItem, StrsOptions } from '../kmx/kmx-plus/kmx-plus.js'; /** * A single entry in a ListItem. diff --git a/common/web/types/src/main.ts b/common/web/types/src/main.ts index 4792e3e09c..3b0759d66f 100644 --- a/common/web/types/src/main.ts +++ b/common/web/types/src/main.ts @@ -1,21 +1,12 @@ export * as KMX from './kmx/kmx.js'; -export * as KMXPlus from './kmx/kmx-plus.js'; -export { default as KMXBuilder } from './kmx/kmx-builder.js'; export { KmxFileReader, KmxFileReaderError } from './kmx/kmx-file-reader.js'; export * as KeymanTargets from './kmx/keyman-targets.js'; export * as VisualKeyboard from './kvk/visual-keyboard.js'; -export { default as KMXPlusBuilder} from './kmx/kmx-plus-builder/kmx-plus-builder.js'; export { default as KvkFileReader } from './kvk/kvk-file-reader.js'; export { default as KvkFileWriter } from './kvk/kvk-file-writer.js'; export * as KvkFile from './kvk/kvk-file.js'; -export * as LDMLKeyboard from './ldml-keyboard/ldml-keyboard-xml.js'; -export { LDMLKeyboardTestDataXMLSourceFile } from './ldml-keyboard/ldml-keyboard-testdata-xml.js'; -export { UnicodeSetParser, UnicodeSet } from './ldml-keyboard/unicodeset-parser-api.js'; -export { VariableParser, MarkerParser } from './ldml-keyboard/pattern-parser.js'; -export { LDMLKeyboardXMLSourceFileReader, LDMLKeyboardXMLSourceFileReaderOptions } from './ldml-keyboard/ldml-keyboard-xml-reader.js'; - export * as Constants from './consts/virtual-key-constants.js'; export { defaultCompilerOptions, CompilerBaseOptions, CompilerCallbacks, CompilerOptions, CompilerEvent, CompilerErrorNamespace, @@ -34,6 +25,7 @@ export { defaultCompilerOptions, CompilerBaseOptions, CompilerCallbacks, Compile KeymanCompiler } from './util/compiler-interfaces.js'; + export { CommonTypesMessages } from './util/common-events.js'; export * as TouchLayout from './keyman-touch-layout/keyman-touch-layout-file.js'; @@ -48,4 +40,10 @@ export * as KeymanFileTypes from './util/file-types.js'; export * as Schemas from './schemas.js'; export * as SchemaValidators from './schema-validators.js'; -export * as xml2js from './deps/xml2js/xml2js.js'; \ No newline at end of file +export * as xml2js from './deps/xml2js/xml2js.js'; + +export * as KMXPlus from './kmx/kmx-plus/kmx-plus.js'; +// TODO: these exports are really not well named +export { UnicodeSetParser, UnicodeSet } from './ldml-keyboard/unicodeset-parser-api.js'; +export { VariableParser, MarkerParser } from './ldml-keyboard/pattern-parser.js'; +export { ElementString } from './kmx/kmx-plus/element-string.js'; \ No newline at end of file diff --git a/developer/src/common/web/utils/build.sh b/developer/src/common/web/utils/build.sh index 13f590070a..56ae38b7a9 100755 --- a/developer/src/common/web/utils/build.sh +++ b/developer/src/common/web/utils/build.sh @@ -27,9 +27,28 @@ builder_parse "$@" #------------------------------------------------------------------------------------------------------------------- +function copy_cldr_imports() { + # Store CLDR imports + # load all versions that have a cldr_info.json + for CLDR_INFO_PATH in "$KEYMAN_ROOT/resources/standards-data/ldml-keyboards/"*/cldr_info.json + do + # TODO-LDML: developer/src/inst/download.in.mak needs these also... + CLDR_PATH=$(dirname "$CLDR_INFO_PATH") + CLDR_VER=$(basename "$CLDR_PATH") + mkdir -p "$THIS_SCRIPT_PATH/build/src/import/$CLDR_VER" + # TODO-LDML: When these are copied, the DOCTYPE will break due to the wrong path. We don't use the DTD so it should be OK. + cp "$CLDR_INFO_PATH" "$CLDR_PATH/import/"*.xml "$THIS_SCRIPT_PATH/build/src/import/$CLDR_VER/" + done +} + +function do_build() { + copy_cldr_imports + tsc --build +} + builder_run_action clean rm -rf ./build/ builder_run_action configure verify_npm_setup -builder_run_action build tsc --build +builder_run_action build do_build if builder_start_action test; then eslint . diff --git a/developer/src/common/web/utils/package.json b/developer/src/common/web/utils/package.json index ad3b796a21..f839d886ea 100644 --- a/developer/src/common/web/utils/package.json +++ b/developer/src/common/web/utils/package.json @@ -9,13 +9,14 @@ "/build/" ], "dependencies": { - "@sentry/node": "^7.57.0" + "@sentry/node": "^7.57.0", + "restructure": "^3.0.1" }, "devDependencies": { "@types/node": "^20.4.1", - "typescript": "^5.4.5", "c8": "^7.12.0", - "mocha": "^8.4.0" + "mocha": "^8.4.0", + "typescript": "^5.4.5" }, "scripts": { "build": "tsc -b" diff --git a/developer/src/common/web/utils/src/index.ts b/developer/src/common/web/utils/src/index.ts index 2769cd9c58..149f9bcfc9 100644 --- a/developer/src/common/web/utils/src/index.ts +++ b/developer/src/common/web/utils/src/index.ts @@ -17,3 +17,10 @@ export * as KvksFile from './types/kvks/kvks-file.js'; export { TouchLayoutFileReader } from './types/keyman-touch-layout/keyman-touch-layout-file-reader.js'; export { TouchLayoutFileWriter, TouchLayoutFileWriterOptions } from './types/keyman-touch-layout/keyman-touch-layout-file-writer.js'; + +export { default as KMXBuilder } from './types/kmx/kmx-builder.js'; +export { default as KMXPlusBuilder} from './types/kmx/kmx-plus-builder/kmx-plus-builder.js'; + +export * as LDMLKeyboard from './types/ldml-keyboard/ldml-keyboard-xml.js'; +export { LDMLKeyboardTestDataXMLSourceFile } from './types/ldml-keyboard/ldml-keyboard-testdata-xml.js'; +export { LDMLKeyboardXMLSourceFileReader, LDMLKeyboardXMLSourceFileReaderOptions } from './types/ldml-keyboard/ldml-keyboard-xml-reader.js'; diff --git a/developer/src/common/web/utils/src/restructure.d.ts b/developer/src/common/web/utils/src/restructure.d.ts new file mode 100644 index 0000000000..9750d24473 --- /dev/null +++ b/developer/src/common/web/utils/src/restructure.d.ts @@ -0,0 +1,2 @@ +// TODO: consider defining more types? +declare module 'restructure'; \ No newline at end of file diff --git a/common/web/types/src/kmx/kmx-builder.ts b/developer/src/common/web/utils/src/types/kmx/kmx-builder.ts similarity index 85% rename from common/web/types/src/kmx/kmx-builder.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-builder.ts index 4a319bfe45..a8ce169d30 100644 --- a/common/web/types/src/kmx/kmx-builder.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-builder.ts @@ -1,8 +1,18 @@ +import { KMXPlus, KMX } from '@keymanapp/common-types'; import * as r from 'restructure'; -import { KMXFile, GROUP, KEY, STORE, BUILDER_COMP_KEYBOARD, BUILDER_COMP_KEYBOARD_KMXPLUSINFO, BUILDER_COMP_STORE, BUILDER_COMP_GROUP, BUILDER_COMP_KEY } from './kmx.js'; -import { KMXPlusFile } from './kmx-plus.js'; import KMXPlusBuilder from './kmx-plus-builder/kmx-plus-builder.js'; +import KMXPlusFile = KMXPlus.KMXPlusFile; +import KMXFile = KMX.KMXFile; +import GROUP = KMX.GROUP; +import KEY = KMX.KEY; +import STORE = KMX.STORE; +import BUILDER_COMP_KEYBOARD = KMX.BUILDER_COMP_KEYBOARD; +import BUILDER_COMP_KEYBOARD_KMXPLUSINFO = KMX.BUILDER_COMP_KEYBOARD_KMXPLUSINFO; +import BUILDER_COMP_STORE = KMX.BUILDER_COMP_STORE; +import BUILDER_COMP_GROUP = KMX.BUILDER_COMP_GROUP; +import BUILDER_COMP_KEY = KMX.BUILDER_COMP_KEY; + export default class KMXBuilder { file: KMXFile; base_keyboard: number = 0; @@ -69,8 +79,8 @@ export default class KMXBuilder { this.comp_header.dpStoreArray = this.comp_header.cxStoreArray ? size : 0; let storeBase = size; size += this.file.keyboard.stores.length * KMXFile.COMP_STORE_SIZE; - for(let store of this.file.keyboard.stores) { - let comp_store: BUILDER_COMP_STORE = { + for(const store of this.file.keyboard.stores) { + const comp_store: BUILDER_COMP_STORE = { dwSystemID: store.dwSystemID, dpName: 0, dpString: 0 @@ -90,8 +100,8 @@ export default class KMXBuilder { this.comp_header.dpGroupArray = this.comp_header.cxGroupArray ? size : 0; let groupBase = size; size += this.file.keyboard.groups.length * KMXFile.COMP_GROUP_SIZE; - for(let group of this.file.keyboard.groups) { - let comp_group: BUILDER_COMP_GROUP = { + for(const group of this.file.keyboard.groups) { + const comp_group: BUILDER_COMP_GROUP = { dpName: 0, dpKeyArray: 0, dpMatch: 0, @@ -100,7 +110,7 @@ export default class KMXBuilder { fUsingKeys: group.fUsingKeys ? 1 : 0 }; - let comp_keys: {base: number, key: KEY, obj: BUILDER_COMP_KEY}[] = []; + const comp_keys: {base: number, key: KEY, obj: BUILDER_COMP_KEY}[] = []; this.comp_groups.push({base: groupBase, group: group, obj: comp_group, keys: comp_keys}); @@ -116,8 +126,8 @@ export default class KMXBuilder { let keyBase = size; size += group.keys.length * KMXFile.COMP_KEY_SIZE; - for(let key of group.keys) { - let comp_key: BUILDER_COMP_KEY = { + for(const key of group.keys) { + const comp_key: BUILDER_COMP_KEY = { Key: key.Key, _padding: 0, Line: key.Line, @@ -164,11 +174,11 @@ export default class KMXBuilder { if(requireString && !str.length) { // Just write zero terminator, as r.String for a zero-length string // seems to fail. - let sbuf = r.uint16le; + const sbuf = r.uint16le; file.set(sbuf.toBuffer(0), pos); } else if(pos && str.length) { - let sbuf = new r.String(null, 'utf16le'); // null-terminated string + const sbuf = new r.String(null, 'utf16le'); // null-terminated string file.set(sbuf.toBuffer(str), pos); } } @@ -176,7 +186,7 @@ export default class KMXBuilder { compile(): Uint8Array { const fileSize = this.build(); - let file: Uint8Array = new Uint8Array(fileSize); + const file: Uint8Array = new Uint8Array(fileSize); // Write headers @@ -190,7 +200,7 @@ export default class KMXBuilder { // Write store array and data - for(let store of this.comp_stores) { + for(const store of this.comp_stores) { file.set(this.file.COMP_STORE.toBuffer(store.obj), store.base); if(this.writeDebug) { this.setString(file, store.obj.dpName, store.store.dpName); @@ -200,7 +210,7 @@ export default class KMXBuilder { // Write group array and data - for(let group of this.comp_groups) { + for(const group of this.comp_groups) { file.set(this.file.COMP_GROUP.toBuffer(group.obj), group.base); if(this.writeDebug) { this.setString(file, group.obj.dpName, group.group.dpName); @@ -208,7 +218,7 @@ export default class KMXBuilder { this.setString(file, group.obj.dpMatch, group.group.dpMatch); this.setString(file, group.obj.dpNoMatch, group.group.dpNoMatch); - for(let key of group.keys) { + for(const key of group.keys) { file.set(this.file.COMP_KEY.toBuffer(key.obj), key.base); // for back-compat reasons, these are never NULL strings this.setString(file, key.obj.dpContext, key.key.dpContext, true); diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-disp.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-disp.ts similarity index 88% rename from common/web/types/src/kmx/kmx-plus-builder/build-disp.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-disp.ts index 712dafac27..6984aa2cfa 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-disp.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-disp.ts @@ -1,8 +1,10 @@ import { constants } from '@keymanapp/ldml-keyboard-constants'; -import { KMXPlusData } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { build_strs_index, BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js"; import { BUILDER_SECTION } from './builder-section.js'; +import KMXPlusData = KMXPlus.KMXPlusData; + /* ------------------------------------------------------------------ * disp section ------------------------------------------------------------------ */ @@ -27,7 +29,7 @@ export function build_disp(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS): BUILD return null; } - let disp: BUILDER_DISP = { + const disp: BUILDER_DISP = { ident: constants.hex_section_id(constants.section.disp), size: constants.length_disp + constants.length_disp_item * kmxplus.disp.disps.length, _offset: 0, @@ -36,7 +38,7 @@ export function build_disp(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS): BUILD items: [] }; - for(let item of kmxplus.disp.disps) { + for(const item of kmxplus.disp.disps) { disp.items.push({ to: build_strs_index(sect_strs, item.to), id: build_strs_index(sect_strs, item.id), diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-elem.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-elem.ts similarity index 94% rename from common/web/types/src/kmx/kmx-plus-builder/build-elem.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-elem.ts index 8e325f9591..8dafccced2 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-elem.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-elem.ts @@ -1,10 +1,11 @@ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { ElementString } from "../element-string.js"; -import { Elem } from "../kmx-plus.js"; +import { KMXPlus, ElementString } from "@keymanapp/common-types"; import { build_strs_index, BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js"; import { BUILDER_SECTION, BUILDER_U32CHAR } from "./builder-section.js"; import { build_uset_index, BUILDER_USET, BUILDER_USET_REF } from "./build-uset.js"; +import Elem = KMXPlus.Elem; + /* ------------------------------------------------------------------ * elem section ------------------------------------------------------------------ */ @@ -46,7 +47,7 @@ function binaryElemCompare(a: BUILDER_ELEM_STRING, b: BUILDER_ELEM_STRING): numb } export function build_elem(source_elem: Elem, sect_strs: BUILDER_STRS, sect_uset: BUILDER_USET): BUILDER_ELEM { - let result: BUILDER_ELEM = { + const result: BUILDER_ELEM = { ident: constants.hex_section_id(constants.section.elem), size: 0, // finalized below _offset: 0, @@ -55,7 +56,7 @@ export function build_elem(source_elem: Elem, sect_strs: BUILDER_STRS, sect_uset }; result.strings = source_elem.strings.map(item => { - let res: BUILDER_ELEM_STRING = { + const res: BUILDER_ELEM_STRING = { offset: 0, // finalized below length: item.length, items: [], @@ -87,7 +88,7 @@ export function build_elem(source_elem: Elem, sect_strs: BUILDER_STRS, sect_uset /* Calculate offsets and total size */ let offset = constants.length_elem + constants.length_elem_item * result.count; - for(let item of result.strings) { + for(const item of result.strings) { if (item.length === 0) { // no length gets a zero offset item.offset = 0; diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-keys.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-keys.ts similarity index 93% rename from common/web/types/src/kmx/kmx-plus-builder/build-keys.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-keys.ts index ec7e505c57..fd48ec49ec 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-keys.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-keys.ts @@ -1,10 +1,14 @@ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { KeysFlick, KMXPlusData, StrsItem } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { build_strs_index, BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js"; import { build_list_index, BUILDER_LIST, BUILDER_LIST_REF } from "./build-list.js"; import { BUILDER_SECTION, BUILDER_U32CHAR } from "./builder-section.js"; +import KeysFlick = KMXPlus.KeysFlick; +import KMXPlusData = KMXPlus.KMXPlusData; +import StrsItem = KMXPlus.StrsItem; + /* ------------------------------------------------------------------ * keys section ------------------------------------------------------------------ */ @@ -71,7 +75,7 @@ export function build_keys(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS, sect_l return null; } - let keys: BUILDER_KEYS = { + const keys: BUILDER_KEYS = { ident: constants.hex_section_id(constants.section.keys), size: 0, keyCount: kmxplus.keys.keys.length, @@ -89,7 +93,7 @@ export function build_keys(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS, sect_l // Note that per the Keys class and spec, there is always a flicks=0 meaning 'no flicks' keys.flicks = kmxplus.keys.flicks.map((flicks) => { - let result : BUILDER_KEYS_FLICKS = { + const result : BUILDER_KEYS_FLICKS = { count: flicks.flicks.length, flick: keys.flick.length, // index of first flick id: build_strs_index(sect_strs, flicks.id), @@ -113,7 +117,7 @@ export function build_keys(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS, sect_l // now, keys keys.keys = kmxplus.keys.keys.map((key) => { - let result : BUILDER_KEYS_KEY = { + const result : BUILDER_KEYS_KEY = { to: build_strs_index(sect_strs, key.to), flags: key.flags, id: build_strs_index(sect_strs, key.id), @@ -136,7 +140,7 @@ export function build_keys(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS, sect_l // finally, kmap keys.kmap = kmxplus.keys.kmap.map(({vkey, mod, key}) => { - let result : BUILDER_KEYS_KMAP = { + const result : BUILDER_KEYS_KMAP = { vkey, mod, key: keys.keys.findIndex(k => k._id === key), @@ -160,7 +164,7 @@ export function build_keys(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS, sect_l return rc; }); - let offset = constants.length_keys + + const offset = constants.length_keys + (constants.length_keys_key * keys.keyCount) + (constants.length_keys_flick_element * keys.flickCount) + (constants.length_keys_flick_list * keys.flicksCount) + diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-layr.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-layr.ts similarity index 94% rename from common/web/types/src/kmx/kmx-plus-builder/build-layr.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-layr.ts index c0038246e2..07249368f4 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-layr.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-layr.ts @@ -1,10 +1,15 @@ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { KMXPlusData, LayrEntry, LayrRow, StrsItem } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { build_strs_index, BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js"; import { BUILDER_LIST } from "./build-list.js"; import { BUILDER_SECTION } from "./builder-section.js"; +import KMXPlusData = KMXPlus.KMXPlusData; +import LayrEntry = KMXPlus.LayrEntry; +import LayrRow = KMXPlus.LayrRow; +import StrsItem = KMXPlus.StrsItem; + /* ------------------------------------------------------------------ * layr section - ------------------------------------------------------------------ */ @@ -66,7 +71,7 @@ export function build_layr(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS, sect_l return null; // if there aren't any layers at all (which should be an invalid keyboard) } - let layr: BUILDER_LAYR = { + const layr: BUILDER_LAYR = { ident: constants.hex_section_id(constants.section.layr), size: constants.length_layr, _offset: 0, @@ -145,7 +150,7 @@ export function build_layr(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS, sect_l layr.rowCount = layr.rows.length; layr.keyCount = layr.keys.length; - let offset = constants.length_layr + + const offset = constants.length_layr + (constants.length_layr_list * layr.listCount) + (constants.length_layr_entry * layr.layerCount) + (constants.length_layr_row * layr.rowCount) + diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-list.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-list.ts similarity index 88% rename from common/web/types/src/kmx/kmx-plus-builder/build-list.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-list.ts index 26659f8eb6..759f6498f4 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-list.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-list.ts @@ -1,8 +1,11 @@ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { List, ListItem } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { build_strs_index, BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js"; import { BUILDER_SECTION } from "./builder-section.js"; +import List = KMXPlus.List; +import ListItem = KMXPlus.ListItem; + /* ------------------------------------------------------------------ * list section ------------------------------------------------------------------ */ @@ -40,7 +43,7 @@ export function build_list(source_list: List, sect_strs: BUILDER_STRS): BUILDER_ return null; } - let result: BUILDER_LIST = { + const result: BUILDER_LIST = { ident: constants.hex_section_id(constants.section.list), size: 0, _offset: 0, @@ -51,13 +54,13 @@ export function build_list(source_list: List, sect_strs: BUILDER_STRS): BUILDER_ }; result.lists = source_list.lists.map(array => { - let list : BUILDER_LIST_LIST = { + const list : BUILDER_LIST_LIST = { index: result.indices.length, // the next indexcount count: array.length, _value: array }; array.forEach((i) => { - let index : BUILDER_LIST_INDEX = { + const index : BUILDER_LIST_INDEX = { // Get the final string index str: build_strs_index(sect_strs, i.value), _value: i.value.value, // unwrap the actual string value @@ -71,7 +74,7 @@ export function build_list(source_list: List, sect_strs: BUILDER_STRS): BUILDER_ // Sort the lists. result.lists.sort((a,b) => a._value.compareTo(b._value)); - let offset = constants.length_list + + const offset = constants.length_list + (constants.length_list_item * result.listCount) + (constants.length_list_index * result.indexCount); result.size = offset; @@ -86,14 +89,14 @@ export function build_list(source_list: List, sect_strs: BUILDER_STRS): BUILDER_ * @returns */ export function build_list_index(sect_list: BUILDER_LIST, value: ListItem) : BUILDER_LIST_REF { - if (!value) { + if (!value) { return 0; // empty list } if(!(value instanceof ListItem)) { throw new Error('unexpected value '+ value); } - let result = sect_list.lists.findIndex(v => v._value === value); + const result = sect_list.lists.findIndex(v => v._value === value); if(result < 0) { throw new Error('unexpectedly missing ListItem ' + value); // TODO-LDML: it's an array of strs } diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-loca.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-loca.ts similarity index 84% rename from common/web/types/src/kmx/kmx-plus-builder/build-loca.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-loca.ts index 9a72402c8c..4a81fcd9ab 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-loca.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-loca.ts @@ -4,10 +4,12 @@ ------------------------------------------------------------------ */ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { KMXPlusData } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { build_strs_index, BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js"; import { BUILDER_SECTION } from "./builder-section.js"; +import KMXPlusData = KMXPlus.KMXPlusData; + /** * Builder for the 'loca' section */ @@ -17,7 +19,7 @@ export interface BUILDER_LOCA extends BUILDER_SECTION { }; export function build_loca(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS): BUILDER_LOCA { - let loca: BUILDER_LOCA = { + const loca: BUILDER_LOCA = { ident: constants.hex_section_id(constants.section.loca), size: constants.length_loca + constants.length_loca_item * kmxplus.loca.locales.length, _offset: 0, @@ -25,7 +27,7 @@ export function build_loca(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS): BUILD items: [] }; - for(let item of kmxplus.loca.locales) { + for(const item of kmxplus.loca.locales) { loca.items.push(build_strs_index(sect_strs, item)); } diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-meta.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-meta.ts similarity index 93% rename from common/web/types/src/kmx/kmx-plus-builder/build-meta.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-meta.ts index 23dd303a7d..208051356e 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-meta.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-meta.ts @@ -4,10 +4,12 @@ ------------------------------------------------------------------ */ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { KMXPlusData } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { build_strs_index, BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js"; import { BUILDER_SECTION } from "./builder-section.js"; +import KMXPlusData = KMXPlus.KMXPlusData; + /** * Builder for the 'meta' section */ diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-sect.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-sect.ts similarity index 100% rename from common/web/types/src/kmx/kmx-plus-builder/build-sect.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-sect.ts diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-strs.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-strs.ts similarity index 89% rename from common/web/types/src/kmx/kmx-plus-builder/build-strs.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-strs.ts index 503de2d404..89d733f22d 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-strs.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-strs.ts @@ -1,7 +1,10 @@ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { Strs, StrsItem } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { BUILDER_SECTION } from "./builder-section.js"; +import Strs = KMXPlus.Strs; +import StrsItem = KMXPlus.StrsItem; + /** reference from build_strs_index */ export type BUILDER_STR_REF = number; @@ -26,7 +29,7 @@ export interface BUILDER_STRS extends BUILDER_SECTION { }; export function build_strs(source_strs: Strs): BUILDER_STRS { - let result: BUILDER_STRS = { + const result: BUILDER_STRS = { ident: constants.hex_section_id(constants.section.strs), size: 0, // finalized later _offset: 0, @@ -39,7 +42,7 @@ export function build_strs(source_strs: Strs): BUILDER_STRS { let offset = constants.length_strs + constants.length_strs_item * result.count; // TODO: consider padding - for(let item of result.items) { + for(const item of result.items) { item.offset = offset; offset += item.length * 2 + 2; /* UTF-16 code units + sizeof null terminator */ } @@ -64,7 +67,7 @@ export function build_strs_index(sect_strs: BUILDER_STRS, value: StrsItem) : BUI return value.char; } - let result = sect_strs.items.findIndex(v => v._value === value.value); + const result = sect_strs.items.findIndex(v => v._value === value.value); if(result < 0) { throw new Error('unexpectedly missing StrsItem '+value.value); } diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-tran.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-tran.ts similarity index 91% rename from common/web/types/src/kmx/kmx-plus-builder/build-tran.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-tran.ts index 316df69853..2473651b88 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-tran.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-tran.ts @@ -1,10 +1,13 @@ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { Bksp, Tran } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { BUILDER_ELEM, BUILDER_ELEM_REF, build_elem_index } from "./build-elem.js"; import { BUILDER_STRS, BUILDER_STR_REF, build_strs_index } from "./build-strs.js"; import { BUILDER_SECTION } from "./builder-section.js"; +import Bksp = KMXPlus.Bksp; +import Tran = KMXPlus.Tran; + /* ------------------------------------------------------------------ * tran section ------------------------------------------------------------------ */ @@ -44,7 +47,7 @@ export function build_tran(source_tran: Tran | Bksp, sect_strs: BUILDER_STRS, se return null; } - let tran: BUILDER_TRAN = { + const tran: BUILDER_TRAN = { ident: constants.hex_section_id(source_tran.id), size: 0, // need to compute total transforms + reorders _offset: 0, @@ -56,14 +59,14 @@ export function build_tran(source_tran: Tran | Bksp, sect_strs: BUILDER_STRS, se reorders: [], }; - for (let group of source_tran.groups) { + for (const group of source_tran.groups) { if (group.type === constants.tran_group_type_transform) { tran.groups.push({ type: group.type, count: group.transforms.length, index: tran.transforms.length, // index of first item }); - for (let transform of group.transforms) { + for (const transform of group.transforms) { tran.transforms.push({ from: build_strs_index(sect_strs, transform.from), to: build_strs_index(sect_strs, transform.to), @@ -77,7 +80,7 @@ export function build_tran(source_tran: Tran | Bksp, sect_strs: BUILDER_STRS, se count: group.reorders.length, index: tran.reorders.length, // index of first item }); - for (let reorder of group.reorders) { + for (const reorder of group.reorders) { tran.reorders.push({ elements: build_elem_index(sect_elem, reorder.elements), before: build_elem_index(sect_elem, reorder.before), diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-uset.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-uset.ts similarity index 89% rename from common/web/types/src/kmx/kmx-plus-builder/build-uset.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-uset.ts index 8c73afb796..1edd4d339f 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-uset.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-uset.ts @@ -1,8 +1,12 @@ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { KMXPlusData, StrsItem, UsetItem } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { build_strs_index, BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js"; import { BUILDER_SECTION, BUILDER_U32CHAR } from "./builder-section.js"; +import KMXPlusData = KMXPlus.KMXPlusData; +import StrsItem = KMXPlus.StrsItem; +import UsetItem = KMXPlus.UsetItem; + /** reference from build_uset_index */ export type BUILDER_USET_REF = number; @@ -80,7 +84,7 @@ export function build_uset_index(sect_uset: BUILDER_USET, value: UsetItem) { } } - let result = sect_uset.usets.findIndex(v => v._pattern.value === value.str.value); + const result = sect_uset.usets.findIndex(v => v._pattern.value === value.str.value); if(result < 0) { throw new Error('unexpectedly missing UsetItem ' + value.uset.toString()); } diff --git a/common/web/types/src/kmx/kmx-plus-builder/build-vars.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-vars.ts similarity index 95% rename from common/web/types/src/kmx/kmx-plus-builder/build-vars.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-vars.ts index 8c09a169f6..92acbba9be 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/build-vars.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/build-vars.ts @@ -1,10 +1,11 @@ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { KMXPlusData } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { build_strs_index, BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js"; import { BUILDER_SECTION } from "./builder-section.js"; import { build_list_index, BUILDER_LIST, BUILDER_LIST_REF } from "./build-list.js"; import { build_elem_index, BUILDER_ELEM, BUILDER_ELEM_REF } from "./build-elem.js"; +import KMXPlusData = KMXPlus.KMXPlusData; interface BUILDER_VARS_ITEM { type: number; diff --git a/common/web/types/src/kmx/kmx-plus-builder/builder-section.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/builder-section.ts similarity index 100% rename from common/web/types/src/kmx/kmx-plus-builder/builder-section.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/builder-section.ts diff --git a/common/web/types/src/kmx/kmx-plus-builder/kmx-plus-builder.ts b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/kmx-plus-builder.ts similarity index 93% rename from common/web/types/src/kmx/kmx-plus-builder/kmx-plus-builder.ts rename to developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/kmx-plus-builder.ts index 381e1d6d19..acc732c932 100644 --- a/common/web/types/src/kmx/kmx-plus-builder/kmx-plus-builder.ts +++ b/developer/src/common/web/utils/src/types/kmx/kmx-plus-builder/kmx-plus-builder.ts @@ -1,5 +1,5 @@ import * as r from 'restructure'; -import { KMXPlusFile } from "../kmx-plus.js"; +import { KMXPlus } from "@keymanapp/common-types"; import { constants, SectionIdent } from '@keymanapp/ldml-keyboard-constants'; import { BUILDER_SECTION } from './builder-section.js'; import { BUILDER_SECT, build_sect } from './build-sect.js'; @@ -15,6 +15,8 @@ import { BUILDER_TRAN, build_tran } from './build-tran.js'; import { BUILDER_USET, build_uset } from './build-uset.js'; import { BUILDER_VARS, build_vars } from './build-vars.js'; +import KMXPlusFile = KMXPlus.KMXPlusFile; + type BUILDER_BKSP = BUILDER_TRAN; // type BUILDER_FINL = BUILDER_TRAN; @@ -50,7 +52,7 @@ export default class KMXPlusBuilder { public compile(): Uint8Array { const fileSize = this.build(); - let file: Uint8Array = new Uint8Array(fileSize); + const file: Uint8Array = new Uint8Array(fileSize); this.emitSection(file, this.file.COMP_PLUS_SECT, this.sect.sect); // Keep the rest of these in order. @@ -155,13 +157,13 @@ export default class KMXPlusBuilder { } private emitStrings(file: Uint8Array) { - for(let item of this.sect.strs.items) { + for(const item of this.sect.strs.items) { if(item._value === '') { // We have a special case for the zero-length string - let sbuf = r.uint16le; + const sbuf = r.uint16le; file.set(sbuf.toBuffer(0), item.offset + this.sect.strs._offset); } else { - let sbuf = new r.String(null, 'utf16le'); + const sbuf = new r.String(null, 'utf16le'); file.set(sbuf.toBuffer(item._value), item.offset + this.sect.strs._offset); } } @@ -169,9 +171,9 @@ export default class KMXPlusBuilder { private emitElements(file: Uint8Array) { if(this.sect.elem) { - for(let str of this.sect.elem.strings) { + for(const str of this.sect.elem.strings) { if(str.items.length > 0) { - let COMP_PLUS_ELEM_ELEMENTS = new r.Array(this.file.COMP_PLUS_ELEM_ELEMENT, str.items.length); + const COMP_PLUS_ELEM_ELEMENTS = new r.Array(this.file.COMP_PLUS_ELEM_ELEMENT, str.items.length); file.set(COMP_PLUS_ELEM_ELEMENTS.toBuffer(str.items), str.offset + this.sect.elem._offset); } } diff --git a/common/web/types/src/ldml-keyboard/ldml-keyboard-testdata-xml.ts b/developer/src/common/web/utils/src/types/ldml-keyboard/ldml-keyboard-testdata-xml.ts similarity index 100% rename from common/web/types/src/ldml-keyboard/ldml-keyboard-testdata-xml.ts rename to developer/src/common/web/utils/src/types/ldml-keyboard/ldml-keyboard-testdata-xml.ts diff --git a/common/web/types/src/ldml-keyboard/ldml-keyboard-xml-reader.ts b/developer/src/common/web/utils/src/types/ldml-keyboard/ldml-keyboard-xml-reader.ts similarity index 93% rename from common/web/types/src/ldml-keyboard/ldml-keyboard-xml-reader.ts rename to developer/src/common/web/utils/src/types/ldml-keyboard/ldml-keyboard-xml-reader.ts index 9055e8ed1d..7c7925cce2 100644 --- a/common/web/types/src/ldml-keyboard/ldml-keyboard-xml-reader.ts +++ b/developer/src/common/web/utils/src/types/ldml-keyboard/ldml-keyboard-xml-reader.ts @@ -1,11 +1,9 @@ -import * as xml2js from '../deps/xml2js/xml2js.js'; +import { SchemaValidators, CommonTypesMessages, CompilerCallbacks, util, xml2js } from '@keymanapp/common-types'; import { LDMLKeyboardXMLSourceFile, LKImport, ImportStatus } from './ldml-keyboard-xml.js'; -import { boxXmlArray } from '../util/util.js'; -import { CompilerCallbacks } from '../util/compiler-interfaces.js'; import { constants } from '@keymanapp/ldml-keyboard-constants'; -import { CommonTypesMessages } from '../util/common-events.js'; import { LDMLKeyboardTestDataXMLSourceFile, LKTTest, LKTTests } from './ldml-keyboard-testdata-xml.js'; -import SchemaValidators from '../schema-validators.js'; + +import boxXmlArray = util.boxXmlArray; interface NameAndProps { '$'?: any; // content @@ -22,7 +20,7 @@ export class LDMLKeyboardXMLSourceFileReader { } static get defaultImportsURL(): [string,string] { - return ['../import/', import.meta.url]; + return ['../../import/', import.meta.url]; } readImportFile(version: string, subpath: string): Uint8Array { @@ -63,10 +61,10 @@ export class LDMLKeyboardXMLSourceFileReader { boxXmlArray(source?.keyboard3?.locales, 'locale'); boxXmlArray(source?.keyboard3, 'transforms'); if(source?.keyboard3?.layers) { - for(let layers of source?.keyboard3?.layers) { + for(const layers of source?.keyboard3?.layers) { boxXmlArray(layers, 'layer'); if(layers?.layer) { - for(let layer of layers?.layer) { + for(const layer of layers?.layer) { boxXmlArray(layer, 'row'); } } @@ -74,13 +72,13 @@ export class LDMLKeyboardXMLSourceFileReader { } if(source?.keyboard3?.forms?.form) { boxXmlArray(source?.keyboard3?.forms, 'form'); - for(let form of source?.keyboard3?.forms?.form) { + for(const form of source?.keyboard3?.forms?.form) { boxXmlArray(form, 'scanCodes'); } } if(source?.keyboard3?.flicks) { boxXmlArray(source?.keyboard3?.flicks, 'flick'); - for(let flick of source?.keyboard3?.flicks?.flick) { + for(const flick of source?.keyboard3?.flicks?.flick) { boxXmlArray(flick, 'flickSegment'); } } @@ -90,9 +88,9 @@ export class LDMLKeyboardXMLSourceFileReader { boxXmlArray(source?.keyboard3?.variables, 'uset'); } if(source?.keyboard3?.transforms) { - for(let transforms of source.keyboard3.transforms) { + for(const transforms of source.keyboard3.transforms) { boxXmlArray(transforms, 'transformGroup'); - for (let transformGroup of transforms.transformGroup) { + for (const transformGroup of transforms.transformGroup) { boxXmlArray(transformGroup, 'transform'); boxXmlArray(transformGroup, 'reorder'); } @@ -235,8 +233,8 @@ export class LDMLKeyboardXMLSourceFileReader { * @returns true if valid, false if invalid */ public validate(source: LDMLKeyboardXMLSourceFile | LDMLKeyboardTestDataXMLSourceFile): boolean { - if(!SchemaValidators.ldmlKeyboard3(source)) { - for (let err of (SchemaValidators.ldmlKeyboard3).errors) { + if(!SchemaValidators.default.ldmlKeyboard3(source)) { + for (const err of (SchemaValidators.default.ldmlKeyboard3).errors) { this.callbacks.reportMessage(CommonTypesMessages.Error_SchemaValidationError({ instancePath: err.instancePath, keyword: err.keyword, @@ -250,9 +248,9 @@ export class LDMLKeyboardXMLSourceFileReader { } loadUnboxed(file: Uint8Array): LDMLKeyboardXMLSourceFile { - let source = (() => { + const source = (() => { let a: LDMLKeyboardXMLSourceFile; - let parser = new xml2js.Parser({ + const parser = new xml2js.Parser({ explicitArray: false, mergeAttrs: true, includeWhiteChars: false, @@ -289,9 +287,9 @@ export class LDMLKeyboardXMLSourceFileReader { } loadTestDataUnboxed(file: Uint8Array): any { - let source = (() => { + const source = (() => { let a: any; - let parser = new xml2js.Parser({ + const parser = new xml2js.Parser({ // explicitArray: false, preserveChildrenOrder:true, // needed for test data explicitChildren: true, // needed for test data diff --git a/common/web/types/src/ldml-keyboard/ldml-keyboard-xml.ts b/developer/src/common/web/utils/src/types/ldml-keyboard/ldml-keyboard-xml.ts similarity index 100% rename from common/web/types/src/ldml-keyboard/ldml-keyboard-xml.ts rename to developer/src/common/web/utils/src/types/ldml-keyboard/ldml-keyboard-xml.ts diff --git a/common/web/types/test/fixtures/import-minimal.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/import-minimal.xml similarity index 100% rename from common/web/types/test/fixtures/import-minimal.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/import-minimal.xml diff --git a/common/web/types/test/fixtures/import-minimal1.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/import-minimal1.xml similarity index 100% rename from common/web/types/test/fixtures/import-minimal1.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/import-minimal1.xml diff --git a/common/web/types/test/fixtures/import-minimal2.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/import-minimal2.xml similarity index 100% rename from common/web/types/test/fixtures/import-minimal2.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/import-minimal2.xml diff --git a/common/web/types/test/fixtures/import-symbols.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/import-symbols.xml similarity index 100% rename from common/web/types/test/fixtures/import-symbols.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/import-symbols.xml diff --git a/common/web/types/test/fixtures/invalid-conforms-to.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-conforms-to.xml similarity index 100% rename from common/web/types/test/fixtures/invalid-conforms-to.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-conforms-to.xml diff --git a/common/web/types/test/fixtures/invalid-import-base.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-import-base.xml similarity index 100% rename from common/web/types/test/fixtures/invalid-import-base.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-import-base.xml diff --git a/common/web/types/test/fixtures/invalid-import-path.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-import-path.xml similarity index 100% rename from common/web/types/test/fixtures/invalid-import-path.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-import-path.xml diff --git a/common/web/types/test/fixtures/invalid-import-readfail.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-import-readfail.xml similarity index 100% rename from common/web/types/test/fixtures/invalid-import-readfail.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-import-readfail.xml diff --git a/common/web/types/test/fixtures/invalid-import-wrongroot.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-import-wrongroot.xml similarity index 100% rename from common/web/types/test/fixtures/invalid-import-wrongroot.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-import-wrongroot.xml diff --git a/common/web/types/test/fixtures/invalid-structure-per-dtd.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-structure-per-dtd.xml similarity index 100% rename from common/web/types/test/fixtures/invalid-structure-per-dtd.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/invalid-structure-per-dtd.xml diff --git a/common/web/types/test/fixtures/test-fr.xml b/developer/src/common/web/utils/test/fixtures/ldml-keyboard/test-fr.xml similarity index 100% rename from common/web/types/test/fixtures/test-fr.xml rename to developer/src/common/web/utils/test/fixtures/ldml-keyboard/test-fr.xml diff --git a/developer/src/common/web/utils/test/helpers/index.ts b/developer/src/common/web/utils/test/helpers/index.ts index 9968fbfea6..773a9f93ff 100644 --- a/developer/src/common/web/utils/test/helpers/index.ts +++ b/developer/src/common/web/utils/test/helpers/index.ts @@ -2,6 +2,7 @@ * Helpers and utilities for the Mocha tests. */ import * as path from 'path'; +import * as fs from "fs"; import { fileURLToPath } from 'url'; /** @@ -16,3 +17,6 @@ import { fileURLToPath } from 'url'; return fileURLToPath(new URL(path.join('..', '..', '..', 'test', 'fixtures', ...components), import.meta.url)); } +export function loadFile(filename: string | URL): Buffer { + return fs.readFileSync(filename); +} diff --git a/common/web/types/test/helpers/reader-callback-test.ts b/developer/src/common/web/utils/test/helpers/reader-callback-test.ts similarity index 88% rename from common/web/types/test/helpers/reader-callback-test.ts rename to developer/src/common/web/utils/test/helpers/reader-callback-test.ts index 907793cdf7..61c71ac79e 100644 --- a/common/web/types/test/helpers/reader-callback-test.ts +++ b/developer/src/common/web/utils/test/helpers/reader-callback-test.ts @@ -1,11 +1,11 @@ import 'mocha'; import {assert} from 'chai'; -import { loadFile, makePathToFixture } from '../helpers/index.js'; -import { LDMLKeyboardXMLSourceFileReader, LDMLKeyboardXMLSourceFileReaderOptions } from '../../src/ldml-keyboard/ldml-keyboard-xml-reader.js'; -import { CompilerEvent } from '../../src/util/compiler-interfaces.js'; -import { LDMLKeyboardXMLSourceFile } from '../../src/ldml-keyboard/ldml-keyboard-xml.js'; -import { LDMLKeyboardTestDataXMLSourceFile } from '../ldml-keyboard/ldml-keyboard-testdata-xml.js'; -import { TestCompilerCallbacks } from './TestCompilerCallbacks.js'; +import { loadFile, makePathToFixture } from './index.js'; +import { LDMLKeyboardXMLSourceFileReader, LDMLKeyboardXMLSourceFileReaderOptions } from '../../src/types/ldml-keyboard/ldml-keyboard-xml-reader.js'; +import { CompilerEvent } from '@keymanapp/common-types'; +import { LDMLKeyboardXMLSourceFile } from '../../src/types/ldml-keyboard/ldml-keyboard-xml.js'; +import { LDMLKeyboardTestDataXMLSourceFile } from '../../src/types/ldml-keyboard/ldml-keyboard-testdata-xml.js'; +import { TestCompilerCallbacks } from '@keymanapp/developer-test-helpers'; import { fileURLToPath } from 'url'; const readerOptions: LDMLKeyboardXMLSourceFileReaderOptions = { @@ -77,14 +77,14 @@ export function testReaderCases(cases : CompilationCase[]) { // we need our own callbacks rather than using the global so messages don't get mixed const callbacks = new TestCompilerCallbacks(); const reader = new LDMLKeyboardXMLSourceFileReader(readerOptions, callbacks); - for (let testcase of cases) { + for (const testcase of cases) { const expectFailure = testcase.throws || !!(testcase.errors); // if true, we expect this to fail const testHeading = expectFailure ? `should fail to load: ${testcase.subpath}`: `should load: ${testcase.subpath}`; it(testHeading, function () { callbacks.clear(); - const data = loadFile(makePathToFixture(testcase.subpath)); + const data = loadFile(makePathToFixture('ldml-keyboard', testcase.subpath)); assert.ok(data, `reading ${testcase.subpath}`); const source = reader.load(data); if (!testcase.loadfail) { @@ -128,14 +128,14 @@ export function testTestdataReaderCases(cases : TestDataCase[]) { // we need our own callbacks rather than using the global so messages don't get mixed const callbacks = new TestCompilerCallbacks(); const reader = new LDMLKeyboardXMLSourceFileReader(readerOptions, callbacks); - for (let testcase of cases) { + for (const testcase of cases) { const expectFailure = testcase.throws || !!(testcase.errors); // if true, we expect this to fail const testHeading = expectFailure ? `should fail to load: ${testcase.subpath}`: `should load: ${testcase.subpath}`; it(testHeading, function () { callbacks.clear(); - const data = loadFile(makePathToFixture(testcase.subpath)); + const data = loadFile(makePathToFixture('ldml-keyboard', testcase.subpath)); assert.ok(data, `reading ${testcase.subpath}`); const source = reader.loadTestData(data); if (!testcase.loadfail) { diff --git a/common/web/types/test/ldml-keyboard/test-ldml-keyboard-testdata-reader.ts b/developer/src/common/web/utils/test/kmx/test-ldml-keyboard-testdata-reader.ts similarity index 96% rename from common/web/types/test/ldml-keyboard/test-ldml-keyboard-testdata-reader.ts rename to developer/src/common/web/utils/test/kmx/test-ldml-keyboard-testdata-reader.ts index 794adbbe66..d2ce6dc72a 100644 --- a/common/web/types/test/ldml-keyboard/test-ldml-keyboard-testdata-reader.ts +++ b/developer/src/common/web/utils/test/kmx/test-ldml-keyboard-testdata-reader.ts @@ -2,7 +2,7 @@ import { constants } from '@keymanapp/ldml-keyboard-constants'; import { assert } from 'chai'; import 'mocha'; import { testTestdataReaderCases } from '../helpers/reader-callback-test.js'; -import { LKTAnyAction } from './ldml-keyboard-testdata-xml.js'; +import { LKTAnyAction } from '../../src/types/ldml-keyboard/ldml-keyboard-testdata-xml.js'; describe('ldml keyboard xml reader tests', function () { this.slow(500); // 0.5 sec -- json schema validation takes a while diff --git a/common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts b/developer/src/common/web/utils/test/kmx/test-ldml-keyboard-xml-reader.ts similarity index 95% rename from common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts rename to developer/src/common/web/utils/test/kmx/test-ldml-keyboard-xml-reader.ts index fa99be5267..d5f814abcb 100644 --- a/common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts +++ b/developer/src/common/web/utils/test/kmx/test-ldml-keyboard-xml-reader.ts @@ -1,9 +1,13 @@ -import { LKKey, ImportStatus } from './../../src/ldml-keyboard/ldml-keyboard-xml.js'; +import { LKKey, ImportStatus } from '../../src/types/ldml-keyboard/ldml-keyboard-xml.js'; import 'mocha'; import {assert} from 'chai'; -import { CommonTypesMessages } from '../../src/util/common-events.js'; +import { CommonTypesMessages } from '@keymanapp/common-types'; import { testReaderCases } from '../helpers/reader-callback-test.js'; -import { CLDRScanToVkey, CLDRScanToKeyMap, USVirtualKeyCodes } from '../../src/consts/virtual-key-constants.js'; +import { Constants } from '@keymanapp/common-types'; + +import CLDRScanToVkey = Constants.CLDRScanToVkey; +import CLDRScanToKeyMap = Constants.CLDRScanToKeyMap; +import USVirtualKeyCodes = Constants.USVirtualKeyCodes; function pluckKeysFromKeybag(keys: LKKey[], ids: string[]) { return keys.filter(({id}) => ids.indexOf(id) !== -1); diff --git a/developer/src/kmc-kmn/src/compiler/compiler.ts b/developer/src/kmc-kmn/src/compiler/compiler.ts index 296cc7462b..19181b82ba 100644 --- a/developer/src/kmc-kmn/src/compiler/compiler.ts +++ b/developer/src/kmc-kmn/src/compiler/compiler.ts @@ -6,8 +6,8 @@ TODO: implement additional interfaces: */ // TODO: rename wasm-host? -import { UnicodeSetParser, UnicodeSet, VisualKeyboard, KvkFileReader, KeymanCompiler, KeymanCompilerArtifacts, KeymanCompilerArtifactOptional, KeymanCompilerResult, KeymanCompilerArtifact } from '@keymanapp/common-types'; -import { CompilerCallbacks, CompilerEvent, CompilerOptions, KeymanFileTypes, KvkFileWriter } from '@keymanapp/common-types'; +import { VisualKeyboard, KvkFileReader, KeymanCompiler, KeymanCompilerArtifacts, KeymanCompilerArtifactOptional, KeymanCompilerResult, KeymanCompilerArtifact } from '@keymanapp/common-types'; +import { UnicodeSetParser, UnicodeSet, CompilerCallbacks, CompilerEvent, CompilerOptions, KeymanFileTypes, KvkFileWriter } from '@keymanapp/common-types'; import { KvksFileReader } from '@keymanapp/developer-utils'; import * as Osk from './osk.js'; import loadWasmHost from '../import/kmcmplib/wasm-host.js'; diff --git a/developer/src/kmc-ldml/src/compiler/compiler.ts b/developer/src/kmc-ldml/src/compiler/compiler.ts index 59ed5f9a07..c3a96cec18 100644 --- a/developer/src/kmc-ldml/src/compiler/compiler.ts +++ b/developer/src/kmc-ldml/src/compiler/compiler.ts @@ -1,4 +1,5 @@ -import { LDMLKeyboardXMLSourceFileReader, LDMLKeyboard, KMXPlus, CompilerCallbacks, LDMLKeyboardTestDataXMLSourceFile, UnicodeSetParser, KeymanCompiler, KeymanCompilerResult, KeymanCompilerArtifacts, defaultCompilerOptions, KMXBuilder, KvkFileWriter, KeymanCompilerArtifactOptional } from '@keymanapp/common-types'; +import { KMXPlus, UnicodeSetParser, CompilerCallbacks, KeymanCompiler, KeymanCompilerResult, KeymanCompilerArtifacts, defaultCompilerOptions, KvkFileWriter, KeymanCompilerArtifactOptional } from '@keymanapp/common-types'; +import { LDMLKeyboardXMLSourceFileReader, LDMLKeyboard, LDMLKeyboardTestDataXMLSourceFile, KMXBuilder, } from "@keymanapp/developer-utils" import { LdmlCompilerOptions } from './ldml-compiler-options.js'; import { LdmlCompilerMessages } from './ldml-compiler-messages.js'; import { BkspCompiler, TranCompiler } from './tran.js'; diff --git a/developer/src/kmc-ldml/src/compiler/disp.ts b/developer/src/kmc-ldml/src/compiler/disp.ts index 769a1a1788..03c411ce8d 100644 --- a/developer/src/kmc-ldml/src/compiler/disp.ts +++ b/developer/src/kmc-ldml/src/compiler/disp.ts @@ -1,5 +1,6 @@ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { KMXPlus, LDMLKeyboard } from '@keymanapp/common-types'; +import { LDMLKeyboard } from '@keymanapp/developer-utils'; +import { KMXPlus } from "@keymanapp/common-types"; import { LdmlCompilerMessages } from "./ldml-compiler-messages.js"; import { SectionCompiler } from "./section-compiler.js"; diff --git a/developer/src/kmc-ldml/src/compiler/empty-compiler.ts b/developer/src/kmc-ldml/src/compiler/empty-compiler.ts index 78dc771ff6..b369bf6a3b 100644 --- a/developer/src/kmc-ldml/src/compiler/empty-compiler.ts +++ b/developer/src/kmc-ldml/src/compiler/empty-compiler.ts @@ -1,6 +1,7 @@ import { SectionIdent, constants } from '@keymanapp/ldml-keyboard-constants'; import { SectionCompiler } from "./section-compiler.js"; -import { util, LDMLKeyboard, KMXPlus, CompilerCallbacks, MarkerParser } from "@keymanapp/common-types"; +import { util, KMXPlus, MarkerParser, CompilerCallbacks } from "@keymanapp/common-types"; +import { LDMLKeyboard } from "@keymanapp/developer-utils"; import { VarsCompiler } from './vars.js'; import { LdmlCompilerMessages } from './ldml-compiler-messages.js'; diff --git a/developer/src/kmc-ldml/src/compiler/keymanweb-compiler.ts b/developer/src/kmc-ldml/src/compiler/keymanweb-compiler.ts index 0f159556df..605cfb3905 100644 --- a/developer/src/kmc-ldml/src/compiler/keymanweb-compiler.ts +++ b/developer/src/kmc-ldml/src/compiler/keymanweb-compiler.ts @@ -1,5 +1,5 @@ -import { CompilerCallbacks, VisualKeyboard, LDMLKeyboard, KeymanFileTypes } from "@keymanapp/common-types"; -import { TouchLayoutFileWriter } from "@keymanapp/developer-utils"; +import { CompilerCallbacks, VisualKeyboard, KeymanFileTypes } from "@keymanapp/common-types"; +import { LDMLKeyboard, TouchLayoutFileWriter } from "@keymanapp/developer-utils"; import { LdmlCompilerOptions } from "./ldml-compiler-options.js"; import { TouchLayoutCompiler } from "./touch-layout-compiler.js"; import { LdmlKeyboardVisualKeyboardCompiler } from "./visual-keyboard-compiler.js"; diff --git a/developer/src/kmc-ldml/src/compiler/keys.ts b/developer/src/kmc-ldml/src/compiler/keys.ts index 9e5de13246..e341f3ac87 100644 --- a/developer/src/kmc-ldml/src/compiler/keys.ts +++ b/developer/src/kmc-ldml/src/compiler/keys.ts @@ -1,5 +1,6 @@ import { SectionIdent, constants } from '@keymanapp/ldml-keyboard-constants'; -import { LDMLKeyboard, KMXPlus, Constants } from '@keymanapp/common-types'; +import { KMXPlus, Constants } from '@keymanapp/common-types'; +import { LDMLKeyboard } from '@keymanapp/developer-utils'; import { LdmlCompilerMessages } from './ldml-compiler-messages.js'; import { SectionCompiler } from "./section-compiler.js"; diff --git a/developer/src/kmc-ldml/src/compiler/ldml-compiler-options.ts b/developer/src/kmc-ldml/src/compiler/ldml-compiler-options.ts index 9ea0f043bb..9468a3a091 100644 --- a/developer/src/kmc-ldml/src/compiler/ldml-compiler-options.ts +++ b/developer/src/kmc-ldml/src/compiler/ldml-compiler-options.ts @@ -1,4 +1,5 @@ -import { CompilerOptions, LDMLKeyboardXMLSourceFileReaderOptions } from "@keymanapp/common-types"; +import { CompilerOptions } from "@keymanapp/common-types"; +import { LDMLKeyboardXMLSourceFileReaderOptions } from "@keymanapp/developer-utils"; /** * @public diff --git a/developer/src/kmc-ldml/src/compiler/linter.ts b/developer/src/kmc-ldml/src/compiler/linter.ts index 2a74dfd0b5..42d642b2ae 100644 --- a/developer/src/kmc-ldml/src/compiler/linter.ts +++ b/developer/src/kmc-ldml/src/compiler/linter.ts @@ -1,4 +1,5 @@ -import { LDMLKeyboard, KMXPlus, CompilerCallbacks } from "@keymanapp/common-types"; +import { CompilerCallbacks, KMXPlus } from "@keymanapp/common-types"; +import { LDMLKeyboard } from "@keymanapp/developer-utils"; /** newable interface to Linter c'tor */ export type LinterNew = new (source: LDMLKeyboard.LDMLKeyboardXMLSourceFile, kmx: KMXPlus.KMXPlusFile, callbacks: CompilerCallbacks) => Linter; diff --git a/developer/src/kmc-ldml/src/compiler/loca.ts b/developer/src/kmc-ldml/src/compiler/loca.ts index 3a46475581..fea8cc4338 100644 --- a/developer/src/kmc-ldml/src/compiler/loca.ts +++ b/developer/src/kmc-ldml/src/compiler/loca.ts @@ -1,5 +1,6 @@ import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { LDMLKeyboard, KMXPlus } from '@keymanapp/common-types'; +import { KMXPlus } from '@keymanapp/common-types'; +import { LDMLKeyboard } from '@keymanapp/developer-utils'; import { SectionCompiler } from "./section-compiler.js"; import { LdmlCompilerMessages } from "./ldml-compiler-messages.js"; diff --git a/developer/src/kmc-ldml/src/compiler/section-compiler.ts b/developer/src/kmc-ldml/src/compiler/section-compiler.ts index f2b14e56a3..95d76cdc3f 100644 --- a/developer/src/kmc-ldml/src/compiler/section-compiler.ts +++ b/developer/src/kmc-ldml/src/compiler/section-compiler.ts @@ -1,4 +1,5 @@ -import { LDMLKeyboard, KMXPlus, CompilerCallbacks } from "@keymanapp/common-types"; +import { KMXPlus, CompilerCallbacks } from "@keymanapp/common-types"; +import { LDMLKeyboard } from "@keymanapp/developer-utils"; import { SectionIdent, constants } from '@keymanapp/ldml-keyboard-constants'; /** newable interface to SectionCompiler c'tor */ diff --git a/developer/src/kmc-ldml/src/compiler/touch-layout-compiler.ts b/developer/src/kmc-ldml/src/compiler/touch-layout-compiler.ts index 5c5c7eb194..a36ab9c097 100644 --- a/developer/src/kmc-ldml/src/compiler/touch-layout-compiler.ts +++ b/developer/src/kmc-ldml/src/compiler/touch-layout-compiler.ts @@ -1,4 +1,5 @@ -import { TouchLayout, LDMLKeyboard } from "@keymanapp/common-types"; +import { TouchLayout } from "@keymanapp/common-types"; +import { LDMLKeyboard } from "@keymanapp/developer-utils"; export class TouchLayoutCompiler { public compileToJavascript(source: LDMLKeyboard.LDMLKeyboardXMLSourceFile): TouchLayout.TouchLayoutFile { diff --git a/developer/src/kmc-ldml/src/compiler/tran.ts b/developer/src/kmc-ldml/src/compiler/tran.ts index 84a0bc264f..6e9cc406b8 100644 --- a/developer/src/kmc-ldml/src/compiler/tran.ts +++ b/developer/src/kmc-ldml/src/compiler/tran.ts @@ -1,5 +1,6 @@ import { constants, SectionIdent } from "@keymanapp/ldml-keyboard-constants"; -import { util, KMXPlus, LDMLKeyboard, CompilerCallbacks, VariableParser, MarkerParser } from '@keymanapp/common-types'; +import { KMXPlus, VariableParser, MarkerParser, util, CompilerCallbacks } from '@keymanapp/common-types'; +import { LDMLKeyboard } from "@keymanapp/developer-utils"; import { SectionCompiler } from "./section-compiler.js"; import Bksp = KMXPlus.Bksp; diff --git a/developer/src/kmc-ldml/src/compiler/vars.ts b/developer/src/kmc-ldml/src/compiler/vars.ts index c54081292f..9ef9b30dbb 100644 --- a/developer/src/kmc-ldml/src/compiler/vars.ts +++ b/developer/src/kmc-ldml/src/compiler/vars.ts @@ -1,6 +1,6 @@ import { SectionIdent, constants } from "@keymanapp/ldml-keyboard-constants"; -import { KMXPlus, LDMLKeyboard, CompilerCallbacks, MarkerParser } from '@keymanapp/common-types'; -import { VariableParser } from '@keymanapp/common-types'; +import { KMXPlus, VariableParser, MarkerParser, CompilerCallbacks } from '@keymanapp/common-types'; +import { LDMLKeyboard, } from '@keymanapp/developer-utils'; import { SectionCompiler } from "./section-compiler.js"; import Vars = KMXPlus.Vars; import StringVarItem = KMXPlus.StringVarItem; diff --git a/developer/src/kmc-ldml/src/compiler/visual-keyboard-compiler.ts b/developer/src/kmc-ldml/src/compiler/visual-keyboard-compiler.ts index e662b923e4..f8fc0dd2e1 100644 --- a/developer/src/kmc-ldml/src/compiler/visual-keyboard-compiler.ts +++ b/developer/src/kmc-ldml/src/compiler/visual-keyboard-compiler.ts @@ -1,4 +1,5 @@ -import { VisualKeyboard, LDMLKeyboard, CompilerCallbacks } from "@keymanapp/common-types"; +import { VisualKeyboard, CompilerCallbacks } from "@keymanapp/common-types"; +import { LDMLKeyboard } from "@keymanapp/developer-utils"; import { KeysCompiler } from "./keys.js"; import { LdmlCompilerMessages } from "./ldml-compiler-messages.js"; diff --git a/developer/src/kmc-ldml/src/util/util.ts b/developer/src/kmc-ldml/src/util/util.ts index 21409e7299..dbb5dc0531 100644 --- a/developer/src/kmc-ldml/src/util/util.ts +++ b/developer/src/kmc-ldml/src/util/util.ts @@ -1,4 +1,4 @@ -import { LDMLKeyboard } from "@keymanapp/common-types"; +import { LDMLKeyboard } from "@keymanapp/developer-utils"; import { constants } from "@keymanapp/ldml-keyboard-constants"; /** * Verifies that value is an item in the enumeration. diff --git a/developer/src/kmc-ldml/test/helpers/index.ts b/developer/src/kmc-ldml/test/helpers/index.ts index 2e9e16ff6a..74f6fff52a 100644 --- a/developer/src/kmc-ldml/test/helpers/index.ts +++ b/developer/src/kmc-ldml/test/helpers/index.ts @@ -5,7 +5,8 @@ import 'mocha'; import * as path from 'path'; import { fileURLToPath } from 'url'; import { SectionCompiler, SectionCompilerNew } from '../../src/compiler/section-compiler.js'; -import { util, KMXPlus, LDMLKeyboardXMLSourceFileReader, VisualKeyboard, CompilerEvent, LDMLKeyboardTestDataXMLSourceFile, compilerEventFormat, LDMLKeyboard, UnicodeSetParser, CompilerCallbacks } from '@keymanapp/common-types'; +import { util, KMXPlus, UnicodeSetParser, VisualKeyboard, CompilerEvent, compilerEventFormat, CompilerCallbacks } from '@keymanapp/common-types'; +import { LDMLKeyboardXMLSourceFileReader, LDMLKeyboardTestDataXMLSourceFile, LDMLKeyboard, } from "@keymanapp/developer-utils"; import { LdmlKeyboardCompiler } from '../../src/main.js'; // make sure main.js compiles import { assert } from 'chai'; import { KMXPlusMetadataCompiler } from '../../src/compiler/metadata-compiler.js'; diff --git a/developer/src/kmc-ldml/test/test-compiler-e2e.ts b/developer/src/kmc-ldml/test/test-compiler-e2e.ts index e6bc3f52e2..1f87e55a22 100644 --- a/developer/src/kmc-ldml/test/test-compiler-e2e.ts +++ b/developer/src/kmc-ldml/test/test-compiler-e2e.ts @@ -1,7 +1,7 @@ import 'mocha'; import {assert} from 'chai'; import hextobin from '@keymanapp/hextobin'; -import { KMXBuilder } from '@keymanapp/common-types'; +import { KMXBuilder } from '@keymanapp/developer-utils'; import {checkMessages, compileKeyboard, compilerTestCallbacks, compilerTestOptions, makePathToFixture} from './helpers/index.js'; import { LdmlKeyboardCompiler } from '../src/compiler/compiler.js'; diff --git a/developer/src/kmc-ldml/test/test-utils.ts b/developer/src/kmc-ldml/test/test-utils.ts index fcf1f78683..3b89e3c2af 100644 --- a/developer/src/kmc-ldml/test/test-utils.ts +++ b/developer/src/kmc-ldml/test/test-utils.ts @@ -5,7 +5,7 @@ import { isValidEnumValue, calculateUniqueKeys, allUsedKeyIdsInLayers, translateLayerAttrToModifier, validModifier, verifyValidAndUnique } from '../src/util/util.js'; import { constants } from "@keymanapp/ldml-keyboard-constants"; -import { LDMLKeyboard } from '@keymanapp/common-types'; +import { LDMLKeyboard } from '@keymanapp/developer-utils'; describe('test of util/util.ts', () => { describe('isValidEnumValue()', () => { diff --git a/package-lock.json b/package-lock.json index 3464e33524..38259c51f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -504,7 +504,8 @@ "name": "@keymanapp/developer-utils", "license": "MIT", "dependencies": { - "@sentry/node": "^7.57.0" + "@sentry/node": "^7.57.0", + "restructure": "^3.0.1" }, "devDependencies": { "@types/node": "^20.4.1", @@ -12615,7 +12616,8 @@ "node_modules/restructure": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/restructure/-/restructure-3.0.1.tgz", - "integrity": "sha512-6neDpI/yE9eogQo22qmWwKIA9wFPRyYjQleDEh6zaNAf2ZPqLJYUvNBJBWEWNoBlCeQMQkvIOe2YI/K2GOag+g==" + "integrity": "sha512-6neDpI/yE9eogQo22qmWwKIA9wFPRyYjQleDEh6zaNAf2ZPqLJYUvNBJBWEWNoBlCeQMQkvIOe2YI/K2GOag+g==", + "license": "MIT" }, "node_modules/retry": { "version": "0.12.0",