From a3e672e808a8728483c242c8288cc293bc76ec51 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 24 Aug 2022 13:43:09 +1000 Subject: [PATCH 1/3] feat(developer): LDML compiler kmx-builder Generates a valid .kmx file (legacy structures only) from an intermediate in-memory structure. Included for completeness, although it is anticipated that LDML keyboards will not have any groups, though they will probably have some metadata stores. --- developer/src/kmldmlc/package.json | 1 + .../src/kmldmlc/src/keyman/kmx/kmx-builder.ts | 236 ++++++++++++++++-- developer/src/kmldmlc/src/keyman/kmx/kmx.ts | 35 +-- .../src/keyman/ldmlkeyboard/compiler.ts | 2 +- package-lock.json | 26 +- 5 files changed, 257 insertions(+), 43 deletions(-) diff --git a/developer/src/kmldmlc/package.json b/developer/src/kmldmlc/package.json index 295bb94f8f..2bbe69a6f5 100644 --- a/developer/src/kmldmlc/package.json +++ b/developer/src/kmldmlc/package.json @@ -20,6 +20,7 @@ }, "dependencies": { "commander": "^3.0.0", + "crc-32": "^1.2.2", "restructure": "^3.0.0", "typescript": "^4.5.4", "xml2js": "^0.4.19" diff --git a/developer/src/kmldmlc/src/keyman/kmx/kmx-builder.ts b/developer/src/kmldmlc/src/keyman/kmx/kmx-builder.ts index 6165561afa..63565f313e 100644 --- a/developer/src/kmldmlc/src/keyman/kmx/kmx-builder.ts +++ b/developer/src/kmldmlc/src/keyman/kmx/kmx-builder.ts @@ -1,4 +1,6 @@ -import KMXFile from './kmx'; +import * as r from 'restructure'; +import * as crc32 from 'crc-32'; +import KMXFile, { GROUP, KEY, STORE } from './kmx'; // These type-checking structures are here to ensure that // we match the structures from kmx.ts in the generator @@ -35,56 +37,244 @@ interface BUILDER_COMP_KEYBOARD_KMXPLUSINFO { dwKMXPlusSize: number; }; +interface BUILDER_COMP_STORE { + dwSystemID: number; + dpName: number; + dpString: number; +}; + +interface BUILDER_COMP_KEY { + Key: number; + _padding: number; + Line: number; + ShiftFlags: number; + dpOutput: number; + dpContext: number; +}; + +interface BUILDER_COMP_GROUP { + dpName: number; + dpKeyArray: number; + dpMatch: number; + dpNoMatch: number; + cxKeyArray: number; + fUsingKeys: number; +}; + + export default class KMXBuilder { file: KMXFile; - constructor(file: KMXFile) { + base_keyboard: number = 0; + base_kmxplus: number = 0; + comp_header: BUILDER_COMP_KEYBOARD; + comp_kmxplus: BUILDER_COMP_KEYBOARD_KMXPLUSINFO; + comp_stores: {base: number, store: STORE, obj: BUILDER_COMP_STORE}[] = []; + comp_groups: {base: number, group: GROUP, obj: BUILDER_COMP_GROUP, keys: {base: number, key: KEY, obj: BUILDER_COMP_KEY}[]}[] = []; + writeDebug: boolean = false; + + constructor(file: KMXFile, writeDebug: boolean) { this.file = file; + this.writeDebug = writeDebug; } - compiledHeader(): BUILDER_COMP_KEYBOARD { - return { + calculateStringOffsetAndSize(string: string, base: number, requireString: boolean = false) { + if(string.length == 0 && !requireString) { + // Zero length strings take up no space in the file, and + // are treated as a 'null string' + return [0, base]; + } + return [base, base + string.length * 2 + 2]; // include trailing zero + } + + prepareFileBuffers() { + this.base_keyboard = 0; + this.base_kmxplus = 0; + + // Header + + this.comp_header = { dwIdentifier: KMXFile.FILEID_COMPILED, dwFileVersion: KMXFile.VERSION_160, dwCheckSum: 0, KeyboardID: 0, IsRegistered: 1, version: 0, - cxStoreArray: this.file.keyboard.stores.length, - cxGroupArray: this.file.keyboard.groups.length, + cxStoreArray: 0, + cxGroupArray: 0, dpStoreArray: 0, dpGroupArray: 0, StartGroup_ANSI: 0xFFFFFFFF, StartGroup_Unicode: 0xFFFFFFFF, - dwFlags: this.file.keyboard.isKMXPlus ? KMXFile.KF_KMXPLUS : 0, + dwFlags: 0, dwHotKey: 0, dpBitmapOffset: 0, dwBitmapSize: 0 }; + + let size = KMXFile.COMP_KEYBOARD_SIZE; + + if(this.file.keyboard.isKMXPlus) { + this.base_kmxplus = size; + + this.comp_kmxplus = { + dpKMXPlus: 0, + dwKMXPlusSize: 0 + }; + + size += KMXFile.COMP_KEYBOARD_KMXPLUSINFO_SIZE; + } + + // Stores + + this.comp_header.cxStoreArray = this.file.keyboard.stores.length; + 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 = { + dwSystemID: store.dwSystemID, + dpName: 0, + dpString: 0 + }; + this.comp_stores.push({base: storeBase, store: store, obj: comp_store}); + if(this.writeDebug /*TODO: || store.isOption*/) { + [comp_store.dpName, size] = this.calculateStringOffsetAndSize(store.dpName, size); + } + + [comp_store.dpString, size] = this.calculateStringOffsetAndSize(store.dpString, size); + storeBase += KMXFile.COMP_STORE_SIZE; + } + + // Groups + + this.comp_header.cxGroupArray = this.file.keyboard.groups.length; + 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 = { + dpName: 0, + dpKeyArray: 0, + dpMatch: 0, + dpNoMatch: 0, + cxKeyArray: group.keys.length, + fUsingKeys: group.fUsingKeys ? 1 : 0 + }; + + let comp_keys: {base: number, key: KEY, obj: BUILDER_COMP_KEY}[] = []; + + this.comp_groups.push({base: groupBase, group: group, obj: comp_group, keys: comp_keys}); + + if(this.writeDebug) { + [comp_group.dpName, size] = this.calculateStringOffsetAndSize(group.dpName, size); + } + [comp_group.dpMatch, size] = this.calculateStringOffsetAndSize(group.dpMatch, size); + [comp_group.dpNoMatch, size] = this.calculateStringOffsetAndSize(group.dpNoMatch, size); + + // Keys within a group + + comp_group.dpKeyArray = group.keys.length ? size : 0; + + let keyBase = size; + size += group.keys.length * KMXFile.COMP_KEY_SIZE; + for(let key of group.keys) { + let comp_key: BUILDER_COMP_KEY = { + Key: key.Key, + _padding: 0, + Line: key.Line, + ShiftFlags: key.ShiftFlags, + dpOutput: 0, + dpContext: 0 + }; + comp_keys.push({base: keyBase, key: key, obj: comp_key}); + [comp_key.dpOutput, size] = this.calculateStringOffsetAndSize(key.dpOutput, size, true); + [comp_key.dpContext, size] = this.calculateStringOffsetAndSize(key.dpContext, size, true); + keyBase += KMXFile.COMP_KEY_SIZE; + } + + groupBase += KMXFile.COMP_GROUP_SIZE; + } + + size += this.calculateBitmapSize(); + size += this.calculateKMXPlusSize(); + + return size; } - compiledKMXPlusHeader(): BUILDER_COMP_KEYBOARD_KMXPLUSINFO { - return { - dpKMXPlus: 0, - dwKMXPlusSize: 0 - }; + calculateBitmapSize() { + // TODO + return 0; } - concat(a: Uint8Array, b: Uint8Array): Uint8Array { - let c = new Uint8Array(a.length + b.length); - c.set(a); - c.set(b, a.length); - return c; + calculateKMXPlusSize() { + // TODO + return 0; + } + + setString(file: Uint8Array, pos: number, str: string, requireString: boolean = false): void { + if(requireString && !str.length) { + // Just write zero terminator, as r.String for a zero-length string + // seems to fail. + let sbuf = r.uint16le; + file.set(sbuf.toBuffer(0), pos); + } + else if(pos && str.length) { + let sbuf = new r.String(null, 'utf16le'); // null-terminated string + file.set(sbuf.toBuffer(str), pos); + } + } + + calculateCRC32(file: Uint8Array): number { + return ~crc32.buf(file, 0); } compile(): Uint8Array { - let file: Uint8Array = this.file.COMP_KEYBOARD.toBuffer(this.compiledHeader()); + const fileSize = this.prepareFileBuffers(); + let file: Uint8Array = new Uint8Array(fileSize); + + // Write headers + + const header = this.file.COMP_KEYBOARD.toBuffer(this.comp_header); + file.set(header, this.base_keyboard); + if(this.file.keyboard.isKMXPlus) { - let kmxplus: Uint8Array = this.file.COMP_KEYBOARD_KMXPLUSINFO.toBuffer(this.compiledKMXPlusHeader()); - file = this.concat(file, kmxplus); + const kmxplus: Uint8Array = this.file.COMP_KEYBOARD_KMXPLUSINFO.toBuffer(this.comp_kmxplus); + file.set(kmxplus, this.base_kmxplus); } - // TODO once we have the final buffer, we need to do a CRC32 of the entire contents - // TODO suggest using a single buffer that grows exponentially to save masses of allocs - // header.set + + // Write store array and data + + for(let 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); + } + this.setString(file, store.obj.dpString, store.store.dpString); + } + + // Write group array and data + + for(let 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); + } + this.setString(file, group.obj.dpMatch, group.group.dpMatch); + this.setString(file, group.obj.dpNoMatch, group.group.dpNoMatch); + + for(let 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); + this.setString(file, key.obj.dpOutput, key.key.dpOutput, true); + } + } + + // Finally, calculate and write the checksum + + this.comp_header.dwCheckSum = this.calculateCRC32(file); + file.set(this.file.COMP_KEYBOARD.toBuffer(this.comp_header), this.base_keyboard); + return file; } } \ No newline at end of file diff --git a/developer/src/kmldmlc/src/keyman/kmx/kmx.ts b/developer/src/kmldmlc/src/keyman/kmx/kmx.ts index cdcfeb519a..c453582926 100644 --- a/developer/src/kmldmlc/src/keyman/kmx/kmx.ts +++ b/developer/src/kmldmlc/src/keyman/kmx/kmx.ts @@ -263,10 +263,11 @@ export default class KMXFile { public static readonly K_MODIFIERFLAG = 0x007F; public static readonly K_NOTMODIFIERFLAG = 0xFF00; // I4548 - public static readonly KEYBOARDFILEHEADER_SIZE = 64; - public static readonly KEYBOARDFILESTORE_SIZE = 12; - public static readonly KEYBOARDFILEGROUP_SIZE = 24; - public static readonly KEYBOARDFILEKEY_SIZE = 20; + public static readonly COMP_KEYBOARD_SIZE = 64; + public static readonly COMP_KEYBOARD_KMXPLUSINFO_SIZE = 8; + public static readonly COMP_STORE_SIZE = 12; + public static readonly COMP_GROUP_SIZE = 24; + public static readonly COMP_KEY_SIZE = 20; /* In-memory representation of the keyboard */ @@ -281,13 +282,13 @@ export default class KMXFile { // Binary-correct structures matching kmx_file.h this.COMP_STORE = new r.Struct({ - dwSystemID: r.uint32, - dpName: r.uint32, - dpString: r.uint32 + dwSystemID: r.uint32le, + dpName: r.uint32le, + dpString: r.uint32le }); - if(this.COMP_STORE.size() != KMXFile.KEYBOARDFILESTORE_SIZE) { - throw "COMP_STORE size is "+this.COMP_STORE.size()+" but should be "+KMXFile.KEYBOARDFILESTORE_SIZE+" bytes"; + if(this.COMP_STORE.size() != KMXFile.COMP_STORE_SIZE) { + throw "COMP_STORE size is "+this.COMP_STORE.size()+" but should be "+KMXFile.COMP_STORE_SIZE+" bytes"; } this.COMP_KEY = new r.Struct({ @@ -299,8 +300,8 @@ export default class KMXFile { dpContext: r.uint32le }); - if(this.COMP_KEY.size() != KMXFile.KEYBOARDFILEKEY_SIZE) { - throw "COMP_KEY size is "+this.COMP_KEY.size()+" but should be "+KMXFile.KEYBOARDFILEKEY_SIZE+" bytes"; + if(this.COMP_KEY.size() != KMXFile.COMP_KEY_SIZE) { + throw "COMP_KEY size is "+this.COMP_KEY.size()+" but should be "+KMXFile.COMP_KEY_SIZE+" bytes"; } this.COMP_GROUP = new r.Struct({ @@ -312,8 +313,8 @@ export default class KMXFile { fUsingKeys: r.uint32le // group(xx) [using keys] <-- specified or not }); - if(this.COMP_GROUP.size() != KMXFile.KEYBOARDFILEGROUP_SIZE) { - throw "COMP_GROUP size is "+this.COMP_GROUP.size()+" but should be "+KMXFile.KEYBOARDFILEGROUP_SIZE+" bytes"; + if(this.COMP_GROUP.size() != KMXFile.COMP_GROUP_SIZE) { + throw "COMP_GROUP size is "+this.COMP_GROUP.size()+" but should be "+KMXFile.COMP_GROUP_SIZE+" bytes"; } this.COMP_KEYBOARD_KMXPLUSINFO = new r.Struct({ @@ -321,6 +322,10 @@ export default class KMXFile { dwKMXPlusSize: r.uint32le // 0044 size in bytes of entire KMXPlus data }); + if(this.COMP_KEYBOARD_KMXPLUSINFO.size() != KMXFile.COMP_KEYBOARD_KMXPLUSINFO_SIZE) { + throw "COMP_KEYBOARD_KMXPLUSINFO size is "+this.COMP_KEYBOARD_KMXPLUSINFO.size()+" but should be "+KMXFile.COMP_KEYBOARD_KMXPLUSINFO_SIZE+" bytes"; + } + this.COMP_KEYBOARD = new r.Struct({ dwIdentifier: r.uint32le, // 0000 Keyman compiled keyboard id @@ -348,8 +353,8 @@ export default class KMXFile { dwBitmapSize: r.uint32le // 003C size in bytes of the bitmaps }); - if(this.COMP_KEYBOARD.size() != KMXFile.KEYBOARDFILEHEADER_SIZE) { - throw "COMP_KEYBOARD size is "+this.COMP_KEYBOARD.size()+" but should be "+KMXFile.KEYBOARDFILEHEADER_SIZE+" bytes"; + if(this.COMP_KEYBOARD.size() != KMXFile.COMP_KEYBOARD_SIZE) { + throw "COMP_KEYBOARD size is "+this.COMP_KEYBOARD.size()+" but should be "+KMXFile.COMP_KEYBOARD_SIZE+" bytes"; } } } \ No newline at end of file diff --git a/developer/src/kmldmlc/src/keyman/ldmlkeyboard/compiler.ts b/developer/src/kmldmlc/src/keyman/ldmlkeyboard/compiler.ts index a3989ff323..1ff93e49b1 100644 --- a/developer/src/kmldmlc/src/keyman/ldmlkeyboard/compiler.ts +++ b/developer/src/kmldmlc/src/keyman/ldmlkeyboard/compiler.ts @@ -27,7 +27,7 @@ export default class Compiler { // TODO: transform LDMLXMLSourceFile to the kmx data // Use the builder to generate the binary output file - let builder = new KMXBuilder(kmx); + let builder = new KMXBuilder(kmx, true); return builder.compile(); } } diff --git a/package-lock.json b/package-lock.json index f2a76a6cae..8fc6dbd502 100644 --- a/package-lock.json +++ b/package-lock.json @@ -448,6 +448,7 @@ "license": "MIT", "dependencies": { "commander": "^3.0.0", + "crc-32": "^1.2.2", "restructure": "^3.0.0", "typescript": "^4.5.4", "xml2js": "^0.4.19" @@ -676,8 +677,8 @@ "typescript": "^4.5.4" }, "optionalDependencies": { - "hetrodo-node-hide-console-window-napi": "git+ssh://git@github.com/keymanapp/hetrodo-node-hide-console-window-napi.git#858b23036a9963b40ad6ff3c5bacd421e5839b92", - "node-windows-trayicon": "git+ssh://git@github.com/keymanapp/node-windows-trayicon.git#1e46786082213f3edcddd5953e33f5abdc7ea05f" + "hetrodo-node-hide-console-window-napi": "keymanapp/hetrodo-node-hide-console-window-napi#keyman-15.0", + "node-windows-trayicon": "keymanapp/node-windows-trayicon#keyman-15.0" } }, "developer/src/server/node_modules/@cspotcode/source-map-support": { @@ -2680,6 +2681,17 @@ "node": ">= 0.10" } }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -7465,11 +7477,11 @@ "chalk": "^4.1.2", "copyfiles": "^2.4.1", "express": "^4.17.2", - "hetrodo-node-hide-console-window-napi": "git+ssh://git@github.com/keymanapp/hetrodo-node-hide-console-window-napi.git#858b23036a9963b40ad6ff3c5bacd421e5839b92", + "hetrodo-node-hide-console-window-napi": "keymanapp/hetrodo-node-hide-console-window-napi#keyman-15.0", "mocha": "^9.1.4", "multer": "^1.4.4", "ngrok": "^4.2.2", - "node-windows-trayicon": "git+ssh://git@github.com/keymanapp/node-windows-trayicon.git#1e46786082213f3edcddd5953e33f5abdc7ea05f", + "node-windows-trayicon": "keymanapp/node-windows-trayicon#keyman-15.0", "open": "^8.4.0", "ts-node": "^10.4.0", "tsc-watch": "^4.5.0", @@ -7723,6 +7735,7 @@ "chai": "^4.3.4", "chalk": "^2.4.2", "commander": "^3.0.0", + "crc-32": "*", "mocha": "^8.4.0", "restructure": "^3.0.0", "ts-node": "^9.1.1", @@ -9422,6 +9435,11 @@ "vary": "^1" } }, + "crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" + }, "create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", From 5e296c98afbdcf28b376c3227a1bb289b6439b8e Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 24 Aug 2022 14:10:20 +1000 Subject: [PATCH 2/3] feat(core): turn @keymanapp/ldml-keyboard-constants into a module Splits the building of keyboardprocessor_ldml.h into a separate tsconfig.build.json, and designates keyboardprocessor_ldml.ts as a new Typescript/Node module @keymanapp/ldml-keyboard-constants. Includes an example usage in the (currently unused) kmx-plus.ts. --- core/include/ldml/.gitignore | 1 + core/include/ldml/package.json | 16 ++++++++++++++++ core/include/ldml/tsconfig.build.json | 18 ++++++++++++++++++ core/include/ldml/tsconfig.json | 4 ++-- core/tools/ldml-const-builder/build.sh | 4 ++-- .../src/kmldmlc/src/keyman/kmx/kmx-plus.ts | 11 +++++++++++ developer/src/kmldmlc/tsconfig.json | 1 + package-lock.json | 14 +++++++++++++- package.json | 1 + 9 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 core/include/ldml/.gitignore create mode 100644 core/include/ldml/package.json create mode 100644 core/include/ldml/tsconfig.build.json create mode 100644 developer/src/kmldmlc/src/keyman/kmx/kmx-plus.ts diff --git a/core/include/ldml/.gitignore b/core/include/ldml/.gitignore new file mode 100644 index 0000000000..3e39f0a460 --- /dev/null +++ b/core/include/ldml/.gitignore @@ -0,0 +1 @@ +ldml-const-builder/ \ No newline at end of file diff --git a/core/include/ldml/package.json b/core/include/ldml/package.json new file mode 100644 index 0000000000..61b71870d9 --- /dev/null +++ b/core/include/ldml/package.json @@ -0,0 +1,16 @@ +{ + "name": "@keymanapp/ldml-keyboard-constants", + "description": "Keyman LDML keyboard constants", + "keywords": [ + "keyboard", + "keyman", + "ldml", + "unicode" + ], + "license": "MIT", + "main": "build/keyboardprocessor_ldml.js", + "repository": { + "type": "git", + "url": "git+https://github.com/keymanapp/keyman.git" + } +} diff --git a/core/include/ldml/tsconfig.build.json b/core/include/ldml/tsconfig.build.json new file mode 100644 index 0000000000..1a7b9fdfbb --- /dev/null +++ b/core/include/ldml/tsconfig.build.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig-base.json", + "compilerOptions": { + "composite": true, + "declaration": true, + "module": "CommonJS", + "moduleResolution": "node", + "rootDir": ".", + "outDir": "ldml-const-builder/", + }, + "exclude": [ + "node_modules" + ], + "files": [ + "keyboardprocessor_ldml.ts", + "ldml-const-builder.ts" + ] +} diff --git a/core/include/ldml/tsconfig.json b/core/include/ldml/tsconfig.json index 01411ba39e..f8a56d0687 100644 --- a/core/include/ldml/tsconfig.json +++ b/core/include/ldml/tsconfig.json @@ -5,13 +5,13 @@ "declaration": true, "module": "CommonJS", "moduleResolution": "node", + "rootDir": ".", "outDir": "build/", }, "exclude": [ "node_modules" ], "files": [ - "keyboardprocessor_ldml.ts", - "ldml-const-builder.ts" + "keyboardprocessor_ldml.ts" ] } diff --git a/core/tools/ldml-const-builder/build.sh b/core/tools/ldml-const-builder/build.sh index c19e34e27c..d231d2967d 100755 --- a/core/tools/ldml-const-builder/build.sh +++ b/core/tools/ldml-const-builder/build.sh @@ -36,13 +36,13 @@ fi if builder_has_action build; then # Generate index.ts - npx tsc -b ../../include/ldml/ + npx tsc -b ../../include/ldml/tsconfig.build.json builder_report success build fi if builder_has_action run; then - node ../../include/ldml/build/core/include/ldml/ldml-const-builder.js > ${KBP_LDML_H_FILE} + node ../../include/ldml/ldml-const-builder/ldml-const-builder.js > ${KBP_LDML_H_FILE} echo "Updated ${KBP_LDML_H_FILE}" builder_report success run diff --git a/developer/src/kmldmlc/src/keyman/kmx/kmx-plus.ts b/developer/src/kmldmlc/src/keyman/kmx/kmx-plus.ts new file mode 100644 index 0000000000..f464a05272 --- /dev/null +++ b/developer/src/kmldmlc/src/keyman/kmx/kmx-plus.ts @@ -0,0 +1,11 @@ +// import * as r from 'restructure'; + +import { constants } from '@keymanapp/ldml-keyboard-constants'; + +// Uses defns from ... + +export default class KMXPlusFile { + constructor() { + console.log(constants); + } +} \ No newline at end of file diff --git a/developer/src/kmldmlc/tsconfig.json b/developer/src/kmldmlc/tsconfig.json index ccdb2efcfe..d6f6004769 100644 --- a/developer/src/kmldmlc/tsconfig.json +++ b/developer/src/kmldmlc/tsconfig.json @@ -22,5 +22,6 @@ ], "references": [ { "path": "../../../common/web/keyman-version" }, + { "path": "../../../core/include/ldml/"} ] } diff --git a/package-lock.json b/package-lock.json index 8fc6dbd502..027c55279f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "workspaces": [ "resources/gosh", "resources/build/version", + "core/include/ldml", "developer/src/kmlmc", "developer/src/kmldmlc", "developer/src/server", @@ -376,6 +377,10 @@ "integrity": "sha512-B9EoJFjhqcQ9OmQrNorItO+OwEOORNn3S31WuiHvZY/dm9ajkB7AKD/8toessEtHHNL+58jofbq7hMMY9v4yig==", "dev": true }, + "core/include/ldml": { + "name": "@keymanapp/ldml-keyboard-constants", + "license": "MIT" + }, "developer/js": { "name": "@keymanapp/lexical-model-compiler", "extraneous": true, @@ -1057,6 +1062,10 @@ "resolved": "developer/src/kmldmlc", "link": true }, + "node_modules/@keymanapp/ldml-keyboard-constants": { + "resolved": "core/include/ldml", + "link": true + }, "node_modules/@keymanapp/lexical-model-compiler": { "resolved": "developer/src/kmlmc", "link": true @@ -7735,7 +7744,7 @@ "chai": "^4.3.4", "chalk": "^2.4.2", "commander": "^3.0.0", - "crc-32": "*", + "crc-32": "^1.2.2", "mocha": "^8.4.0", "restructure": "^3.0.0", "ts-node": "^9.1.1", @@ -7807,6 +7816,9 @@ } } }, + "@keymanapp/ldml-keyboard-constants": { + "version": "file:core/include/ldml" + }, "@keymanapp/lexical-model-compiler": { "version": "file:developer/src/kmlmc", "requires": { diff --git a/package.json b/package.json index f6d54cb36d..fadefef382 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "workspaces": [ "resources/gosh", "resources/build/version", + "core/include/ldml", "developer/src/kmlmc", "developer/src/kmldmlc", "developer/src/server", From 8ebae9515e04a097d31bd8b762c14485d119fb4a Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 24 Aug 2022 14:26:44 +1000 Subject: [PATCH 3/3] =?UTF-8?q?Revert=20"feat(core):=20turn=20@keymanapp/l?= =?UTF-8?q?dml-keyboard-constants=20into=20a=20module=20=F0=9F=99=80"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/include/ldml/.gitignore | 1 - core/include/ldml/package.json | 16 ---------------- core/include/ldml/tsconfig.build.json | 18 ------------------ core/include/ldml/tsconfig.json | 4 ++-- core/tools/ldml-const-builder/build.sh | 4 ++-- .../src/kmldmlc/src/keyman/kmx/kmx-plus.ts | 11 ----------- developer/src/kmldmlc/tsconfig.json | 1 - package-lock.json | 14 +------------- package.json | 1 - 9 files changed, 5 insertions(+), 65 deletions(-) delete mode 100644 core/include/ldml/.gitignore delete mode 100644 core/include/ldml/package.json delete mode 100644 core/include/ldml/tsconfig.build.json delete mode 100644 developer/src/kmldmlc/src/keyman/kmx/kmx-plus.ts diff --git a/core/include/ldml/.gitignore b/core/include/ldml/.gitignore deleted file mode 100644 index 3e39f0a460..0000000000 --- a/core/include/ldml/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ldml-const-builder/ \ No newline at end of file diff --git a/core/include/ldml/package.json b/core/include/ldml/package.json deleted file mode 100644 index 61b71870d9..0000000000 --- a/core/include/ldml/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "@keymanapp/ldml-keyboard-constants", - "description": "Keyman LDML keyboard constants", - "keywords": [ - "keyboard", - "keyman", - "ldml", - "unicode" - ], - "license": "MIT", - "main": "build/keyboardprocessor_ldml.js", - "repository": { - "type": "git", - "url": "git+https://github.com/keymanapp/keyman.git" - } -} diff --git a/core/include/ldml/tsconfig.build.json b/core/include/ldml/tsconfig.build.json deleted file mode 100644 index 1a7b9fdfbb..0000000000 --- a/core/include/ldml/tsconfig.build.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": "../../../tsconfig-base.json", - "compilerOptions": { - "composite": true, - "declaration": true, - "module": "CommonJS", - "moduleResolution": "node", - "rootDir": ".", - "outDir": "ldml-const-builder/", - }, - "exclude": [ - "node_modules" - ], - "files": [ - "keyboardprocessor_ldml.ts", - "ldml-const-builder.ts" - ] -} diff --git a/core/include/ldml/tsconfig.json b/core/include/ldml/tsconfig.json index f8a56d0687..01411ba39e 100644 --- a/core/include/ldml/tsconfig.json +++ b/core/include/ldml/tsconfig.json @@ -5,13 +5,13 @@ "declaration": true, "module": "CommonJS", "moduleResolution": "node", - "rootDir": ".", "outDir": "build/", }, "exclude": [ "node_modules" ], "files": [ - "keyboardprocessor_ldml.ts" + "keyboardprocessor_ldml.ts", + "ldml-const-builder.ts" ] } diff --git a/core/tools/ldml-const-builder/build.sh b/core/tools/ldml-const-builder/build.sh index d231d2967d..c19e34e27c 100755 --- a/core/tools/ldml-const-builder/build.sh +++ b/core/tools/ldml-const-builder/build.sh @@ -36,13 +36,13 @@ fi if builder_has_action build; then # Generate index.ts - npx tsc -b ../../include/ldml/tsconfig.build.json + npx tsc -b ../../include/ldml/ builder_report success build fi if builder_has_action run; then - node ../../include/ldml/ldml-const-builder/ldml-const-builder.js > ${KBP_LDML_H_FILE} + node ../../include/ldml/build/core/include/ldml/ldml-const-builder.js > ${KBP_LDML_H_FILE} echo "Updated ${KBP_LDML_H_FILE}" builder_report success run diff --git a/developer/src/kmldmlc/src/keyman/kmx/kmx-plus.ts b/developer/src/kmldmlc/src/keyman/kmx/kmx-plus.ts deleted file mode 100644 index f464a05272..0000000000 --- a/developer/src/kmldmlc/src/keyman/kmx/kmx-plus.ts +++ /dev/null @@ -1,11 +0,0 @@ -// import * as r from 'restructure'; - -import { constants } from '@keymanapp/ldml-keyboard-constants'; - -// Uses defns from ... - -export default class KMXPlusFile { - constructor() { - console.log(constants); - } -} \ No newline at end of file diff --git a/developer/src/kmldmlc/tsconfig.json b/developer/src/kmldmlc/tsconfig.json index d6f6004769..ccdb2efcfe 100644 --- a/developer/src/kmldmlc/tsconfig.json +++ b/developer/src/kmldmlc/tsconfig.json @@ -22,6 +22,5 @@ ], "references": [ { "path": "../../../common/web/keyman-version" }, - { "path": "../../../core/include/ldml/"} ] } diff --git a/package-lock.json b/package-lock.json index 027c55279f..8fc6dbd502 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,6 @@ "workspaces": [ "resources/gosh", "resources/build/version", - "core/include/ldml", "developer/src/kmlmc", "developer/src/kmldmlc", "developer/src/server", @@ -377,10 +376,6 @@ "integrity": "sha512-B9EoJFjhqcQ9OmQrNorItO+OwEOORNn3S31WuiHvZY/dm9ajkB7AKD/8toessEtHHNL+58jofbq7hMMY9v4yig==", "dev": true }, - "core/include/ldml": { - "name": "@keymanapp/ldml-keyboard-constants", - "license": "MIT" - }, "developer/js": { "name": "@keymanapp/lexical-model-compiler", "extraneous": true, @@ -1062,10 +1057,6 @@ "resolved": "developer/src/kmldmlc", "link": true }, - "node_modules/@keymanapp/ldml-keyboard-constants": { - "resolved": "core/include/ldml", - "link": true - }, "node_modules/@keymanapp/lexical-model-compiler": { "resolved": "developer/src/kmlmc", "link": true @@ -7744,7 +7735,7 @@ "chai": "^4.3.4", "chalk": "^2.4.2", "commander": "^3.0.0", - "crc-32": "^1.2.2", + "crc-32": "*", "mocha": "^8.4.0", "restructure": "^3.0.0", "ts-node": "^9.1.1", @@ -7816,9 +7807,6 @@ } } }, - "@keymanapp/ldml-keyboard-constants": { - "version": "file:core/include/ldml" - }, "@keymanapp/lexical-model-compiler": { "version": "file:developer/src/kmlmc", "requires": { diff --git a/package.json b/package.json index fadefef382..f6d54cb36d 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ "workspaces": [ "resources/gosh", "resources/build/version", - "core/include/ldml", "developer/src/kmlmc", "developer/src/kmldmlc", "developer/src/server",