@keymanapp/common-types 18.0.41-alpha → 18.0.46-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/consts/virtual-key-constants.d.ts +191 -191
- package/build/src/consts/virtual-key-constants.js +221 -221
- package/build/src/consts/virtual-key-constants.js.map +1 -1
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts +5 -5
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js +72 -72
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js.map +1 -1
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts +28 -28
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js +120 -120
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js.map +1 -1
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts +95 -95
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.js +52 -52
- package/build/src/kmx/element-string.d.ts +23 -23
- package/build/src/kmx/element-string.js +125 -125
- package/build/src/kmx/element-string.js.map +1 -1
- package/build/src/kmx/keyman-targets.d.ts +20 -20
- package/build/src/kmx/keyman-targets.js +79 -79
- package/build/src/kmx/keyman-targets.js.map +1 -1
- package/build/src/kmx/kmx-builder.d.ts +32 -32
- package/build/src/kmx/kmx-builder.js +189 -189
- package/build/src/kmx/kmx-builder.js.map +1 -1
- package/build/src/kmx/kmx-file-reader.d.ts +13 -13
- package/build/src/kmx/kmx-file-reader.js +134 -134
- package/build/src/kmx/kmx-file-reader.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-disp.d.ts +18 -18
- package/build/src/kmx/kmx-plus-builder/build-disp.js +27 -27
- package/build/src/kmx/kmx-plus-builder/build-disp.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-elem.d.ts +28 -28
- package/build/src/kmx/kmx-plus-builder/build-elem.js +89 -89
- package/build/src/kmx/kmx-plus-builder/build-elem.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-keys.d.ts +56 -56
- package/build/src/kmx/kmx-plus-builder/build-keys.js +107 -107
- package/build/src/kmx/kmx-plus-builder/build-keys.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-layr.d.ts +53 -53
- package/build/src/kmx/kmx-plus-builder/build-layr.js +101 -101
- package/build/src/kmx/kmx-plus-builder/build-layr.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-list.d.ts +35 -35
- package/build/src/kmx/kmx-plus-builder/build-list.js +66 -66
- package/build/src/kmx/kmx-plus-builder/build-list.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-loca.d.ts +11 -11
- package/build/src/kmx/kmx-plus-builder/build-loca.js +21 -21
- package/build/src/kmx/kmx-plus-builder/build-loca.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-meta.d.ts +16 -16
- package/build/src/kmx/kmx-plus-builder/build-meta.js +20 -20
- package/build/src/kmx/kmx-plus-builder/build-sect.d.ts +15 -15
- package/build/src/kmx/kmx-plus-builder/build-sect.js +15 -15
- package/build/src/kmx/kmx-plus-builder/build-sect.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-strs.d.ts +22 -22
- package/build/src/kmx/kmx-plus-builder/build-strs.js +46 -46
- package/build/src/kmx/kmx-plus-builder/build-strs.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-tran.d.ts +32 -32
- package/build/src/kmx/kmx-plus-builder/build-tran.js +69 -69
- package/build/src/kmx/kmx-plus-builder/build-tran.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-uset.d.ts +30 -30
- package/build/src/kmx/kmx-plus-builder/build-uset.js +60 -60
- package/build/src/kmx/kmx-plus-builder/build-uset.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-vars.d.ts +21 -21
- package/build/src/kmx/kmx-plus-builder/build-vars.js +48 -48
- package/build/src/kmx/kmx-plus-builder/build-vars.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/builder-section.d.ts +9 -9
- package/build/src/kmx/kmx-plus-builder/builder-section.js +2 -2
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts +42 -42
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js +137 -137
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js.map +1 -1
- package/build/src/kmx/kmx-plus.d.ts +322 -322
- package/build/src/kmx/kmx-plus.js +830 -830
- package/build/src/kmx/kmx-plus.js.map +1 -1
- package/build/src/kmx/kmx.d.ts +233 -233
- package/build/src/kmx/kmx.js +302 -302
- package/build/src/kmx/kmx.js.map +1 -1
- package/build/src/kmx/string-list.d.ts +35 -35
- package/build/src/kmx/string-list.js +88 -88
- package/build/src/kmx/string-list.js.map +1 -1
- package/build/src/kpj/keyman-developer-project.d.ts +78 -78
- package/build/src/kpj/keyman-developer-project.js +195 -195
- package/build/src/kpj/keyman-developer-project.js.map +1 -1
- package/build/src/kpj/kpj-file-reader.d.ts +18 -18
- package/build/src/kpj/kpj-file-reader.js +119 -119
- package/build/src/kpj/kpj-file-reader.js.map +1 -1
- package/build/src/kpj/kpj-file.d.ts +39 -39
- package/build/src/kpj/kpj-file.js +10 -10
- package/build/src/kvk/kvk-file-reader.d.ts +4 -4
- package/build/src/kvk/kvk-file-reader.js +37 -37
- package/build/src/kvk/kvk-file-reader.js.map +1 -1
- package/build/src/kvk/kvk-file-writer.d.ts +19 -19
- package/build/src/kvk/kvk-file-writer.js +77 -77
- package/build/src/kvk/kvk-file-writer.js.map +1 -1
- package/build/src/kvk/kvk-file.d.ts +66 -66
- package/build/src/kvk/kvk-file.d.ts.map +1 -1
- package/build/src/kvk/kvk-file.js +90 -90
- package/build/src/kvk/kvk-file.js.map +1 -1
- package/build/src/kvk/kvks-file-reader.d.ts +23 -23
- package/build/src/kvk/kvks-file-reader.js +175 -175
- package/build/src/kvk/kvks-file-reader.js.map +1 -1
- package/build/src/kvk/kvks-file-writer.d.ts +6 -6
- package/build/src/kvk/kvks-file-writer.js +106 -106
- package/build/src/kvk/kvks-file-writer.js.map +1 -1
- package/build/src/kvk/kvks-file.d.ts +43 -43
- package/build/src/kvk/kvks-file.js +9 -9
- package/build/src/kvk/visual-keyboard.d.ts +44 -44
- package/build/src/kvk/visual-keyboard.js +75 -75
- package/build/src/kvk/visual-keyboard.js.map +1 -1
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts +60 -60
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js +19 -19
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts +95 -95
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js +409 -409
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js.map +1 -1
- package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts +170 -170
- package/build/src/ldml-keyboard/ldml-keyboard-xml.js +55 -55
- package/build/src/ldml-keyboard/pattern-parser.d.ts +201 -201
- package/build/src/ldml-keyboard/pattern-parser.js +490 -490
- package/build/src/ldml-keyboard/pattern-parser.js.map +1 -1
- package/build/src/ldml-keyboard/unicodeset-parser-api.d.ts +37 -37
- package/build/src/ldml-keyboard/unicodeset-parser-api.js +27 -27
- package/build/src/main.d.ts +33 -33
- package/build/src/main.js +32 -32
- package/build/src/package/kmp-json-file.d.ts +115 -115
- package/build/src/package/kmp-json-file.js +1 -1
- package/build/src/package/kps-file.d.ts +175 -175
- package/build/src/package/kps-file.js +15 -15
- package/build/src/schema-validators.d.ts +13 -13
- package/build/src/schema-validators.js +25 -25
- package/build/src/schemas/displaymap.schema.d.ts +57 -57
- package/build/src/schemas/displaymap.schema.js +35 -35
- package/build/src/schemas/displaymap.schema.validator.d.mts +2 -2
- package/build/src/schemas/displaymap.schema.validator.mjs +266 -266
- package/build/src/schemas/displaymap.schema.validator.mjs.map +1 -1
- package/build/src/schemas/keyboard_info.schema.d.ts +209 -209
- package/build/src/schemas/keyboard_info.schema.js +98 -98
- package/build/src/schemas/keyboard_info.schema.validator.d.mts +2 -2
- package/build/src/schemas/keyboard_info.schema.validator.mjs +1160 -1160
- package/build/src/schemas/keyboard_info.schema.validator.mjs.map +1 -1
- package/build/src/schemas/keyman-touch-layout.clean.spec.d.ts +227 -227
- package/build/src/schemas/keyman-touch-layout.clean.spec.js +151 -151
- package/build/src/schemas/keyman-touch-layout.clean.spec.validator.d.mts +2 -2
- package/build/src/schemas/keyman-touch-layout.clean.spec.validator.mjs +1094 -1094
- package/build/src/schemas/keyman-touch-layout.clean.spec.validator.mjs.map +1 -1
- package/build/src/schemas/keyman-touch-layout.spec.d.ts +229 -229
- package/build/src/schemas/keyman-touch-layout.spec.js +140 -140
- package/build/src/schemas/keyman-touch-layout.spec.validator.d.mts +2 -2
- package/build/src/schemas/keyman-touch-layout.spec.validator.mjs +1436 -1436
- package/build/src/schemas/keyman-touch-layout.spec.validator.mjs.map +1 -1
- package/build/src/schemas/kmp.schema.d.ts +324 -324
- package/build/src/schemas/kmp.schema.js +353 -353
- package/build/src/schemas/kmp.schema.validator.d.mts +2 -2
- package/build/src/schemas/kmp.schema.validator.mjs +1627 -1627
- package/build/src/schemas/kmp.schema.validator.mjs.map +1 -1
- package/build/src/schemas/kpj-9.0.schema.d.ts +152 -152
- package/build/src/schemas/kpj-9.0.schema.js +131 -131
- package/build/src/schemas/kpj-9.0.schema.validator.d.mts +2 -2
- package/build/src/schemas/kpj-9.0.schema.validator.mjs +655 -655
- package/build/src/schemas/kpj-9.0.schema.validator.mjs.map +1 -1
- package/build/src/schemas/kpj.schema.d.ts +122 -122
- package/build/src/schemas/kpj.schema.js +129 -129
- package/build/src/schemas/kpj.schema.validator.d.mts +2 -2
- package/build/src/schemas/kpj.schema.validator.mjs +515 -515
- package/build/src/schemas/kpj.schema.validator.mjs.map +1 -1
- package/build/src/schemas/kvks.schema.d.ts +160 -160
- package/build/src/schemas/kvks.schema.js +182 -182
- package/build/src/schemas/kvks.schema.validator.d.mts +2 -2
- package/build/src/schemas/kvks.schema.validator.mjs +625 -625
- package/build/src/schemas/kvks.schema.validator.mjs.map +1 -1
- package/build/src/schemas/ldml-keyboard3.schema.d.ts +635 -635
- package/build/src/schemas/ldml-keyboard3.schema.js +696 -696
- package/build/src/schemas/ldml-keyboard3.schema.validator.d.mts +2 -2
- package/build/src/schemas/ldml-keyboard3.schema.validator.mjs +3117 -3117
- package/build/src/schemas/ldml-keyboard3.schema.validator.mjs.map +1 -1
- package/build/src/schemas/ldml-keyboardtest3.schema.d.ts +192 -192
- package/build/src/schemas/ldml-keyboardtest3.schema.js +225 -225
- package/build/src/schemas/ldml-keyboardtest3.schema.validator.d.mts +2 -2
- package/build/src/schemas/ldml-keyboardtest3.schema.validator.mjs +744 -744
- package/build/src/schemas/ldml-keyboardtest3.schema.validator.mjs.map +1 -1
- package/build/src/schemas.d.ts +2300 -2300
- package/build/src/schemas.js +23 -23
- package/build/src/util/common-events.d.ts +44 -44
- package/build/src/util/common-events.js +26 -26
- package/build/src/util/compiler-interfaces.d.ts +371 -371
- package/build/src/util/compiler-interfaces.d.ts.map +1 -1
- package/build/src/util/compiler-interfaces.js +380 -380
- package/build/src/util/compiler-interfaces.js.map +1 -1
- package/build/src/util/errors.d.ts +5 -5
- package/build/src/util/errors.js +5 -5
- package/build/src/util/file-types.d.ts +93 -93
- package/build/src/util/file-types.d.ts.map +1 -1
- package/build/src/util/file-types.js +142 -142
- package/build/src/util/file-types.js.map +1 -1
- package/build/src/util/util.d.ts +98 -98
- package/build/src/util/util.js +368 -368
- package/build/src/util/util.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,136 +1,136 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { KMXFile, KEYBOARD, STORE, GROUP, KEY } from "./kmx.js";
|
|
4
|
-
import * as r from 'restructure';
|
|
5
|
-
import { KeymanTypesError } from "../util/errors.js";
|
|
6
|
-
export class KmxFileReaderError extends KeymanTypesError {
|
|
7
|
-
}
|
|
8
|
-
export class KmxFileReader {
|
|
9
|
-
rString = new r.String(null, 'utf16le');
|
|
10
|
-
readString(source, offset) {
|
|
11
|
-
if (offset == 0) {
|
|
12
|
-
// the file has a null string here, which is not the same as an empty
|
|
13
|
-
// string ('')
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
// The following two lines are equivalent to :
|
|
17
|
-
// return this.rString.fromBuffer(source.slice(offset));
|
|
18
|
-
// but is much faster because it is a read-only view into
|
|
19
|
-
// the data rather than a copy
|
|
20
|
-
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
|
|
21
|
-
return this.rString.fromBuffer(data);
|
|
22
|
-
}
|
|
23
|
-
isValidCodeUse(s, keyboard) {
|
|
24
|
-
return (s.length == 3 &&
|
|
25
|
-
s.charCodeAt(0) == KMXFile.UC_SENTINEL &&
|
|
26
|
-
s.charCodeAt(1) == KMXFile.CODE_USE &&
|
|
27
|
-
s.charCodeAt(2) > 0 &&
|
|
28
|
-
s.charCodeAt(2) <= keyboard.groups.length);
|
|
29
|
-
}
|
|
30
|
-
processSystemStore(store, result) {
|
|
31
|
-
switch (store.dwSystemID) {
|
|
32
|
-
case KMXFile.TSS_MNEMONIC:
|
|
33
|
-
result.isMnemonic = store.dpString == '1';
|
|
34
|
-
break;
|
|
35
|
-
case KMXFile.TSS_KEYBOARDVERSION:
|
|
36
|
-
result.keyboardVersion = store.dpString;
|
|
37
|
-
break;
|
|
38
|
-
case KMXFile.TSS_TARGETS:
|
|
39
|
-
result.targets = store.dpString;
|
|
40
|
-
break;
|
|
41
|
-
case KMXFile.TSS_BEGIN_NEWCONTEXT:
|
|
42
|
-
if (!this.isValidCodeUse(store.dpString, result)) {
|
|
43
|
-
throw new KmxFileReaderError(`Invalid TSS_BEGIN_NEWCONTEXT system store`);
|
|
44
|
-
}
|
|
45
|
-
result.startGroup.newContext = store.dpString.charCodeAt(2) - 1;
|
|
46
|
-
break;
|
|
47
|
-
case KMXFile.TSS_BEGIN_POSTKEYSTROKE:
|
|
48
|
-
if (!this.isValidCodeUse(store.dpString, result)) {
|
|
49
|
-
throw new KmxFileReaderError(`Invalid TSS_BEGIN_POSTKEYSTROKE system store`);
|
|
50
|
-
}
|
|
51
|
-
result.startGroup.postKeystroke = store.dpString.charCodeAt(2) - 1;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
read(source) {
|
|
56
|
-
let binaryKeyboard;
|
|
57
|
-
let kmx = new KMXFile();
|
|
58
|
-
binaryKeyboard = kmx.COMP_KEYBOARD.fromBuffer(source);
|
|
59
|
-
if (binaryKeyboard.dwIdentifier != KMXFile.FILEID_COMPILED) {
|
|
60
|
-
throw new KmxFileReaderError(`Not a .kmx file: header does not contain FILEID_COMPILED`);
|
|
61
|
-
}
|
|
62
|
-
let result = new KEYBOARD();
|
|
63
|
-
result.fileVersion = binaryKeyboard.dwFileVersion;
|
|
64
|
-
result.flags = binaryKeyboard.dwFlags;
|
|
65
|
-
result.hotkey = binaryKeyboard.dwHotKey;
|
|
66
|
-
result.startGroup = {
|
|
67
|
-
ansi: binaryKeyboard.StartGroup_ANSI == 0xFFFFFFFF ? -1 : binaryKeyboard.StartGroup_ANSI,
|
|
68
|
-
unicode: binaryKeyboard.StartGroup_Unicode == 0xFFFFFFFF ? -1 : binaryKeyboard.StartGroup_Unicode,
|
|
69
|
-
newContext: -1,
|
|
70
|
-
postKeystroke: -1
|
|
71
|
-
};
|
|
72
|
-
// Informative data
|
|
73
|
-
result.keyboardVersion = '';
|
|
74
|
-
result.isMnemonic = false;
|
|
75
|
-
result.targets = 'desktop';
|
|
76
|
-
this.readStores(binaryKeyboard, kmx, source, result);
|
|
77
|
-
this.readGroupsAndRules(binaryKeyboard, kmx, source, result);
|
|
78
|
-
// Process system stores once we have all stores and groups loaded
|
|
79
|
-
for (let store of result.stores) {
|
|
80
|
-
this.processSystemStore(store, result);
|
|
81
|
-
}
|
|
82
|
-
// TODO: KMXPlusFile
|
|
83
|
-
// Validate startGroup offsets
|
|
84
|
-
let gp;
|
|
85
|
-
for (gp in result.startGroup) {
|
|
86
|
-
if (result.startGroup[gp] < -1 || result.startGroup[gp] >= result.groups.length) {
|
|
87
|
-
throw new KmxFileReaderError(`Invalid begin group reference`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
readGroupsAndRules(binaryKeyboard, kmx, source, result) {
|
|
93
|
-
let offset = binaryKeyboard.dpGroupArray;
|
|
94
|
-
for (let i = 0; i < binaryKeyboard.cxGroupArray; i++) {
|
|
95
|
-
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
|
|
96
|
-
let binaryGroup = kmx.COMP_GROUP.fromBuffer(data);
|
|
97
|
-
let group = new GROUP();
|
|
98
|
-
group.dpMatch = this.readString(source, binaryGroup.dpMatch);
|
|
99
|
-
group.dpName = this.readString(source, binaryGroup.dpName);
|
|
100
|
-
group.dpNoMatch = this.readString(source, binaryGroup.dpNoMatch);
|
|
101
|
-
group.fUsingKeys = binaryGroup.fUsingKeys;
|
|
102
|
-
group.keys = [];
|
|
103
|
-
let keyOffset = binaryGroup.dpKeyArray;
|
|
104
|
-
for (let j = 0; j < binaryGroup.cxKeyArray; j++) {
|
|
105
|
-
const keyData = new Uint8Array(source.buffer, source.byteOffset + keyOffset);
|
|
106
|
-
let binaryKey = kmx.COMP_KEY.fromBuffer(keyData);
|
|
107
|
-
let key = new KEY();
|
|
108
|
-
key.Key = binaryKey.Key;
|
|
109
|
-
key.Line = binaryKey.Line;
|
|
110
|
-
key.ShiftFlags = binaryKey.ShiftFlags;
|
|
111
|
-
key.dpContext = this.readString(source, binaryKey.dpContext);
|
|
112
|
-
key.dpOutput = this.readString(source, binaryKey.dpOutput);
|
|
113
|
-
group.keys.push(key);
|
|
114
|
-
keyOffset += KMXFile.COMP_KEY_SIZE;
|
|
115
|
-
}
|
|
116
|
-
result.groups.push(group);
|
|
117
|
-
offset += KMXFile.COMP_GROUP_SIZE;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
readStores(binaryKeyboard, kmx, source, result) {
|
|
121
|
-
let offset = binaryKeyboard.dpStoreArray;
|
|
122
|
-
for (let i = 0; i < binaryKeyboard.cxStoreArray; i++) {
|
|
123
|
-
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
|
|
124
|
-
let binaryStore = kmx.COMP_STORE.fromBuffer(data);
|
|
125
|
-
let store = new STORE();
|
|
126
|
-
store.dwSystemID = binaryStore.dwSystemID;
|
|
127
|
-
store.dpName = this.readString(source, binaryStore.dpName);
|
|
128
|
-
store.dpString = this.readString(source, binaryStore.dpString);
|
|
129
|
-
result.stores.push(store);
|
|
130
|
-
offset += KMXFile.COMP_STORE_SIZE;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
;
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="aaa82bd9-03b0-5314-a915-07486e4ed66e")}catch(e){}}();
|
|
3
|
+
import { KMXFile, KEYBOARD, STORE, GROUP, KEY } from "./kmx.js";
|
|
4
|
+
import * as r from 'restructure';
|
|
5
|
+
import { KeymanTypesError } from "../util/errors.js";
|
|
6
|
+
export class KmxFileReaderError extends KeymanTypesError {
|
|
7
|
+
}
|
|
8
|
+
export class KmxFileReader {
|
|
9
|
+
rString = new r.String(null, 'utf16le');
|
|
10
|
+
readString(source, offset) {
|
|
11
|
+
if (offset == 0) {
|
|
12
|
+
// the file has a null string here, which is not the same as an empty
|
|
13
|
+
// string ('')
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
// The following two lines are equivalent to :
|
|
17
|
+
// return this.rString.fromBuffer(source.slice(offset));
|
|
18
|
+
// but is much faster because it is a read-only view into
|
|
19
|
+
// the data rather than a copy
|
|
20
|
+
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
|
|
21
|
+
return this.rString.fromBuffer(data);
|
|
22
|
+
}
|
|
23
|
+
isValidCodeUse(s, keyboard) {
|
|
24
|
+
return (s.length == 3 &&
|
|
25
|
+
s.charCodeAt(0) == KMXFile.UC_SENTINEL &&
|
|
26
|
+
s.charCodeAt(1) == KMXFile.CODE_USE &&
|
|
27
|
+
s.charCodeAt(2) > 0 &&
|
|
28
|
+
s.charCodeAt(2) <= keyboard.groups.length);
|
|
29
|
+
}
|
|
30
|
+
processSystemStore(store, result) {
|
|
31
|
+
switch (store.dwSystemID) {
|
|
32
|
+
case KMXFile.TSS_MNEMONIC:
|
|
33
|
+
result.isMnemonic = store.dpString == '1';
|
|
34
|
+
break;
|
|
35
|
+
case KMXFile.TSS_KEYBOARDVERSION:
|
|
36
|
+
result.keyboardVersion = store.dpString;
|
|
37
|
+
break;
|
|
38
|
+
case KMXFile.TSS_TARGETS:
|
|
39
|
+
result.targets = store.dpString;
|
|
40
|
+
break;
|
|
41
|
+
case KMXFile.TSS_BEGIN_NEWCONTEXT:
|
|
42
|
+
if (!this.isValidCodeUse(store.dpString, result)) {
|
|
43
|
+
throw new KmxFileReaderError(`Invalid TSS_BEGIN_NEWCONTEXT system store`);
|
|
44
|
+
}
|
|
45
|
+
result.startGroup.newContext = store.dpString.charCodeAt(2) - 1;
|
|
46
|
+
break;
|
|
47
|
+
case KMXFile.TSS_BEGIN_POSTKEYSTROKE:
|
|
48
|
+
if (!this.isValidCodeUse(store.dpString, result)) {
|
|
49
|
+
throw new KmxFileReaderError(`Invalid TSS_BEGIN_POSTKEYSTROKE system store`);
|
|
50
|
+
}
|
|
51
|
+
result.startGroup.postKeystroke = store.dpString.charCodeAt(2) - 1;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
read(source) {
|
|
56
|
+
let binaryKeyboard;
|
|
57
|
+
let kmx = new KMXFile();
|
|
58
|
+
binaryKeyboard = kmx.COMP_KEYBOARD.fromBuffer(source);
|
|
59
|
+
if (binaryKeyboard.dwIdentifier != KMXFile.FILEID_COMPILED) {
|
|
60
|
+
throw new KmxFileReaderError(`Not a .kmx file: header does not contain FILEID_COMPILED`);
|
|
61
|
+
}
|
|
62
|
+
let result = new KEYBOARD();
|
|
63
|
+
result.fileVersion = binaryKeyboard.dwFileVersion;
|
|
64
|
+
result.flags = binaryKeyboard.dwFlags;
|
|
65
|
+
result.hotkey = binaryKeyboard.dwHotKey;
|
|
66
|
+
result.startGroup = {
|
|
67
|
+
ansi: binaryKeyboard.StartGroup_ANSI == 0xFFFFFFFF ? -1 : binaryKeyboard.StartGroup_ANSI,
|
|
68
|
+
unicode: binaryKeyboard.StartGroup_Unicode == 0xFFFFFFFF ? -1 : binaryKeyboard.StartGroup_Unicode,
|
|
69
|
+
newContext: -1,
|
|
70
|
+
postKeystroke: -1
|
|
71
|
+
};
|
|
72
|
+
// Informative data
|
|
73
|
+
result.keyboardVersion = '';
|
|
74
|
+
result.isMnemonic = false;
|
|
75
|
+
result.targets = 'desktop';
|
|
76
|
+
this.readStores(binaryKeyboard, kmx, source, result);
|
|
77
|
+
this.readGroupsAndRules(binaryKeyboard, kmx, source, result);
|
|
78
|
+
// Process system stores once we have all stores and groups loaded
|
|
79
|
+
for (let store of result.stores) {
|
|
80
|
+
this.processSystemStore(store, result);
|
|
81
|
+
}
|
|
82
|
+
// TODO: KMXPlusFile
|
|
83
|
+
// Validate startGroup offsets
|
|
84
|
+
let gp;
|
|
85
|
+
for (gp in result.startGroup) {
|
|
86
|
+
if (result.startGroup[gp] < -1 || result.startGroup[gp] >= result.groups.length) {
|
|
87
|
+
throw new KmxFileReaderError(`Invalid begin group reference`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
readGroupsAndRules(binaryKeyboard, kmx, source, result) {
|
|
93
|
+
let offset = binaryKeyboard.dpGroupArray;
|
|
94
|
+
for (let i = 0; i < binaryKeyboard.cxGroupArray; i++) {
|
|
95
|
+
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
|
|
96
|
+
let binaryGroup = kmx.COMP_GROUP.fromBuffer(data);
|
|
97
|
+
let group = new GROUP();
|
|
98
|
+
group.dpMatch = this.readString(source, binaryGroup.dpMatch);
|
|
99
|
+
group.dpName = this.readString(source, binaryGroup.dpName);
|
|
100
|
+
group.dpNoMatch = this.readString(source, binaryGroup.dpNoMatch);
|
|
101
|
+
group.fUsingKeys = binaryGroup.fUsingKeys;
|
|
102
|
+
group.keys = [];
|
|
103
|
+
let keyOffset = binaryGroup.dpKeyArray;
|
|
104
|
+
for (let j = 0; j < binaryGroup.cxKeyArray; j++) {
|
|
105
|
+
const keyData = new Uint8Array(source.buffer, source.byteOffset + keyOffset);
|
|
106
|
+
let binaryKey = kmx.COMP_KEY.fromBuffer(keyData);
|
|
107
|
+
let key = new KEY();
|
|
108
|
+
key.Key = binaryKey.Key;
|
|
109
|
+
key.Line = binaryKey.Line;
|
|
110
|
+
key.ShiftFlags = binaryKey.ShiftFlags;
|
|
111
|
+
key.dpContext = this.readString(source, binaryKey.dpContext);
|
|
112
|
+
key.dpOutput = this.readString(source, binaryKey.dpOutput);
|
|
113
|
+
group.keys.push(key);
|
|
114
|
+
keyOffset += KMXFile.COMP_KEY_SIZE;
|
|
115
|
+
}
|
|
116
|
+
result.groups.push(group);
|
|
117
|
+
offset += KMXFile.COMP_GROUP_SIZE;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
readStores(binaryKeyboard, kmx, source, result) {
|
|
121
|
+
let offset = binaryKeyboard.dpStoreArray;
|
|
122
|
+
for (let i = 0; i < binaryKeyboard.cxStoreArray; i++) {
|
|
123
|
+
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
|
|
124
|
+
let binaryStore = kmx.COMP_STORE.fromBuffer(data);
|
|
125
|
+
let store = new STORE();
|
|
126
|
+
store.dwSystemID = binaryStore.dwSystemID;
|
|
127
|
+
store.dpName = this.readString(source, binaryStore.dpName);
|
|
128
|
+
store.dpString = this.readString(source, binaryStore.dpString);
|
|
129
|
+
result.stores.push(store);
|
|
130
|
+
offset += KMXFile.COMP_STORE_SIZE;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
;
|
|
135
135
|
//# sourceMappingURL=kmx-file-reader.js.map
|
|
136
|
-
//# debugId=
|
|
136
|
+
//# debugId=aaa82bd9-03b0-5314-a915-07486e4ed66e
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kmx-file-reader.js","sources":["../../../src/kmx/kmx-file-reader.ts"],"sourceRoot":"","names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAAyB,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACvF,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,OAAO,kBAAmB,SAAQ,gBAAgB;CAEvD;AAED,MAAM,OAAO,aAAa;IACP,OAAO,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAEjD,UAAU,CAAC,MAAkB,EAAE,MAAc;QACnD,IAAG,MAAM,IAAI,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"kmx-file-reader.js","sources":["../../../src/kmx/kmx-file-reader.ts"],"sourceRoot":"","names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAAyB,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACvF,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,OAAO,kBAAmB,SAAQ,gBAAgB;CAEvD;AAED,MAAM,OAAO,aAAa;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C,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC;QACpC,CAAC;IACH,CAAC;CACF;AAAA,CAAC","debug_id":"aaa82bd9-03b0-5314-a915-07486e4ed66e"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { KMXPlusData } from "../kmx-plus.js";
|
|
2
|
-
import { BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js";
|
|
3
|
-
import { BUILDER_SECTION } from './builder-section.js';
|
|
4
|
-
/**
|
|
5
|
-
* Builder for the 'disp' section
|
|
6
|
-
*/
|
|
7
|
-
interface BUILDER_DISP_ITEM {
|
|
8
|
-
to: BUILDER_STR_REF;
|
|
9
|
-
id: BUILDER_STR_REF;
|
|
10
|
-
display: BUILDER_STR_REF;
|
|
11
|
-
}
|
|
12
|
-
export interface BUILDER_DISP extends BUILDER_SECTION {
|
|
13
|
-
count: number;
|
|
14
|
-
baseCharacter: BUILDER_STR_REF;
|
|
15
|
-
items: BUILDER_DISP_ITEM[];
|
|
16
|
-
}
|
|
17
|
-
export declare function build_disp(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS): BUILDER_DISP;
|
|
18
|
-
export {};
|
|
1
|
+
import { KMXPlusData } from "../kmx-plus.js";
|
|
2
|
+
import { BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js";
|
|
3
|
+
import { BUILDER_SECTION } from './builder-section.js';
|
|
4
|
+
/**
|
|
5
|
+
* Builder for the 'disp' section
|
|
6
|
+
*/
|
|
7
|
+
interface BUILDER_DISP_ITEM {
|
|
8
|
+
to: BUILDER_STR_REF;
|
|
9
|
+
id: BUILDER_STR_REF;
|
|
10
|
+
display: BUILDER_STR_REF;
|
|
11
|
+
}
|
|
12
|
+
export interface BUILDER_DISP extends BUILDER_SECTION {
|
|
13
|
+
count: number;
|
|
14
|
+
baseCharacter: BUILDER_STR_REF;
|
|
15
|
+
items: BUILDER_DISP_ITEM[];
|
|
16
|
+
}
|
|
17
|
+
export declare function build_disp(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS): BUILDER_DISP;
|
|
18
|
+
export {};
|
|
19
19
|
//# sourceMappingURL=build-disp.d.ts.map
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { constants } from '@keymanapp/ldml-keyboard-constants';
|
|
4
|
-
import { build_strs_index } from "./build-strs.js";
|
|
5
|
-
;
|
|
6
|
-
;
|
|
7
|
-
export function build_disp(kmxplus, sect_strs) {
|
|
8
|
-
if (!kmxplus.disp.disps.length && !kmxplus.disp.baseCharacter.value) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
let disp = {
|
|
12
|
-
ident: constants.hex_section_id(constants.section.disp),
|
|
13
|
-
size: constants.length_disp + constants.length_disp_item * kmxplus.disp.disps.length,
|
|
14
|
-
_offset: 0,
|
|
15
|
-
count: kmxplus.disp.disps.length,
|
|
16
|
-
baseCharacter: build_strs_index(sect_strs, kmxplus.disp.baseCharacter),
|
|
17
|
-
items: []
|
|
18
|
-
};
|
|
19
|
-
for (let item of kmxplus.disp.disps) {
|
|
20
|
-
disp.items.push({
|
|
21
|
-
to: build_strs_index(sect_strs, item.to),
|
|
22
|
-
id: build_strs_index(sect_strs, item.id),
|
|
23
|
-
display: build_strs_index(sect_strs, item.display),
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return disp;
|
|
27
|
-
}
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f5abacd4-0a47-5c5f-814c-dcf752595efe")}catch(e){}}();
|
|
3
|
+
import { constants } from '@keymanapp/ldml-keyboard-constants';
|
|
4
|
+
import { build_strs_index } from "./build-strs.js";
|
|
5
|
+
;
|
|
6
|
+
;
|
|
7
|
+
export function build_disp(kmxplus, sect_strs) {
|
|
8
|
+
if (!kmxplus.disp.disps.length && !kmxplus.disp.baseCharacter.value) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
let disp = {
|
|
12
|
+
ident: constants.hex_section_id(constants.section.disp),
|
|
13
|
+
size: constants.length_disp + constants.length_disp_item * kmxplus.disp.disps.length,
|
|
14
|
+
_offset: 0,
|
|
15
|
+
count: kmxplus.disp.disps.length,
|
|
16
|
+
baseCharacter: build_strs_index(sect_strs, kmxplus.disp.baseCharacter),
|
|
17
|
+
items: []
|
|
18
|
+
};
|
|
19
|
+
for (let item of kmxplus.disp.disps) {
|
|
20
|
+
disp.items.push({
|
|
21
|
+
to: build_strs_index(sect_strs, item.to),
|
|
22
|
+
id: build_strs_index(sect_strs, item.id),
|
|
23
|
+
display: build_strs_index(sect_strs, item.display),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return disp;
|
|
27
|
+
}
|
|
28
28
|
//# sourceMappingURL=build-disp.js.map
|
|
29
|
-
//# debugId=
|
|
29
|
+
//# debugId=f5abacd4-0a47-5c5f-814c-dcf752595efe
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-disp.js","sources":["../../../../src/kmx/kmx-plus-builder/build-disp.ts"],"sourceRoot":"","names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAiC,MAAM,iBAAiB,CAAC;AAcjF,CAAC;AAMD,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,OAAoB,EAAE,SAAuB;IACtE,IAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;
|
|
1
|
+
{"version":3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a47-5c5f-814c-dcf752595efe"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { ElementString } from "../element-string.js";
|
|
2
|
-
import { Elem } from "../kmx-plus.js";
|
|
3
|
-
import { BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js";
|
|
4
|
-
import { BUILDER_SECTION, BUILDER_U32CHAR } from "./builder-section.js";
|
|
5
|
-
import { BUILDER_USET, BUILDER_USET_REF } from "./build-uset.js";
|
|
6
|
-
/** return from build_elem_index */
|
|
7
|
-
export type BUILDER_ELEM_REF = number;
|
|
8
|
-
interface BUILDER_ELEM_ELEMENT {
|
|
9
|
-
element: BUILDER_STR_REF | BUILDER_USET_REF | BUILDER_U32CHAR;
|
|
10
|
-
flags: number;
|
|
11
|
-
_value: string;
|
|
12
|
-
}
|
|
13
|
-
interface BUILDER_ELEM_STRING {
|
|
14
|
-
offset: number;
|
|
15
|
-
length: number;
|
|
16
|
-
items: BUILDER_ELEM_ELEMENT[];
|
|
17
|
-
_value: ElementString;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Builder for the 'elem' section
|
|
21
|
-
*/
|
|
22
|
-
export interface BUILDER_ELEM extends BUILDER_SECTION {
|
|
23
|
-
count: number;
|
|
24
|
-
strings: BUILDER_ELEM_STRING[];
|
|
25
|
-
}
|
|
26
|
-
export declare function build_elem(source_elem: Elem, sect_strs: BUILDER_STRS, sect_uset: BUILDER_USET): BUILDER_ELEM;
|
|
27
|
-
export declare function build_elem_index(sect_elem: BUILDER_ELEM, value: ElementString): BUILDER_ELEM_REF;
|
|
28
|
-
export {};
|
|
1
|
+
import { ElementString } from "../element-string.js";
|
|
2
|
+
import { Elem } from "../kmx-plus.js";
|
|
3
|
+
import { BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js";
|
|
4
|
+
import { BUILDER_SECTION, BUILDER_U32CHAR } from "./builder-section.js";
|
|
5
|
+
import { BUILDER_USET, BUILDER_USET_REF } from "./build-uset.js";
|
|
6
|
+
/** return from build_elem_index */
|
|
7
|
+
export type BUILDER_ELEM_REF = number;
|
|
8
|
+
interface BUILDER_ELEM_ELEMENT {
|
|
9
|
+
element: BUILDER_STR_REF | BUILDER_USET_REF | BUILDER_U32CHAR;
|
|
10
|
+
flags: number;
|
|
11
|
+
_value: string;
|
|
12
|
+
}
|
|
13
|
+
interface BUILDER_ELEM_STRING {
|
|
14
|
+
offset: number;
|
|
15
|
+
length: number;
|
|
16
|
+
items: BUILDER_ELEM_ELEMENT[];
|
|
17
|
+
_value: ElementString;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Builder for the 'elem' section
|
|
21
|
+
*/
|
|
22
|
+
export interface BUILDER_ELEM extends BUILDER_SECTION {
|
|
23
|
+
count: number;
|
|
24
|
+
strings: BUILDER_ELEM_STRING[];
|
|
25
|
+
}
|
|
26
|
+
export declare function build_elem(source_elem: Elem, sect_strs: BUILDER_STRS, sect_uset: BUILDER_USET): BUILDER_ELEM;
|
|
27
|
+
export declare function build_elem_index(sect_elem: BUILDER_ELEM, value: ElementString): BUILDER_ELEM_REF;
|
|
28
|
+
export {};
|
|
29
29
|
//# sourceMappingURL=build-elem.d.ts.map
|
|
@@ -1,91 +1,91 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { constants } from "@keymanapp/ldml-keyboard-constants";
|
|
4
|
-
import { ElementString } from "../element-string.js";
|
|
5
|
-
import { build_strs_index } from "./build-strs.js";
|
|
6
|
-
import { build_uset_index } from "./build-uset.js";
|
|
7
|
-
;
|
|
8
|
-
;
|
|
9
|
-
;
|
|
10
|
-
function binaryElemCompare(a, b) {
|
|
11
|
-
for (let i = 0; i < a.items.length && i < b.items.length; i++) {
|
|
12
|
-
if (a.items[i]._value < b.items[i]._value)
|
|
13
|
-
return -1;
|
|
14
|
-
if (a.items[i]._value > b.items[i]._value)
|
|
15
|
-
return 1;
|
|
16
|
-
if (a.items[i].flags < b.items[i].flags)
|
|
17
|
-
return -1;
|
|
18
|
-
if (a.items[i].flags > b.items[i].flags)
|
|
19
|
-
return 1;
|
|
20
|
-
}
|
|
21
|
-
if (a.items.length < b.items.length)
|
|
22
|
-
return -1;
|
|
23
|
-
if (a.items.length > b.items.length)
|
|
24
|
-
return 1;
|
|
25
|
-
return 0;
|
|
26
|
-
}
|
|
27
|
-
export function build_elem(source_elem, sect_strs, sect_uset) {
|
|
28
|
-
let result = {
|
|
29
|
-
ident: constants.hex_section_id(constants.section.elem),
|
|
30
|
-
size: 0,
|
|
31
|
-
_offset: 0,
|
|
32
|
-
count: source_elem.strings.length,
|
|
33
|
-
strings: [], // finalized below
|
|
34
|
-
};
|
|
35
|
-
result.strings = source_elem.strings.map(item => {
|
|
36
|
-
let res = {
|
|
37
|
-
offset: 0,
|
|
38
|
-
length: item.length,
|
|
39
|
-
items: [],
|
|
40
|
-
_value: item
|
|
41
|
-
};
|
|
42
|
-
res.items = item.map(v => {
|
|
43
|
-
let element;
|
|
44
|
-
const type = (v.flags & constants.elem_flags_type);
|
|
45
|
-
if (type === constants.elem_flags_type_char || type == constants.elem_flags_type_str) {
|
|
46
|
-
element = build_strs_index(sect_strs, v.value);
|
|
47
|
-
}
|
|
48
|
-
else if (type == constants.elem_flags_type_uset) {
|
|
49
|
-
element = build_uset_index(sect_uset, v.uset);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
throw Error(`Internal Error: Unknown element type 0x${type.toString(16)}`);
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
element,
|
|
56
|
-
flags: v.flags | //
|
|
57
|
-
((v.order ?? 0) << constants.elem_flags_order_bitshift) | // -128 to +127; used only by reorder element values
|
|
58
|
-
((v.tertiary ?? 0) << constants.elem_flags_tertiary_bitshift),
|
|
59
|
-
_value: v.value.value
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
return res;
|
|
63
|
-
});
|
|
64
|
-
result.strings.sort((a, b) => binaryElemCompare(a, b));
|
|
65
|
-
/* Calculate offsets and total size */
|
|
66
|
-
let offset = constants.length_elem + constants.length_elem_item * result.count;
|
|
67
|
-
for (let item of result.strings) {
|
|
68
|
-
if (item.length === 0) {
|
|
69
|
-
// no length gets a zero offset
|
|
70
|
-
item.offset = 0;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
item.offset = offset;
|
|
74
|
-
offset += item.length * constants.length_elem_item_element;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
result.size = offset;
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
export function build_elem_index(sect_elem, value) {
|
|
81
|
-
if (!(value instanceof ElementString)) {
|
|
82
|
-
throw new Error('unexpected value ' + value);
|
|
83
|
-
}
|
|
84
|
-
const result = sect_elem.strings.findIndex(v => value.isEqual(v._value));
|
|
85
|
-
if (result < 0) {
|
|
86
|
-
throw new Error('unexpectedly missing StrsItem ' + value);
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c85e79ac-9a84-5b6b-aaab-5bc3c0d4e762")}catch(e){}}();
|
|
3
|
+
import { constants } from "@keymanapp/ldml-keyboard-constants";
|
|
4
|
+
import { ElementString } from "../element-string.js";
|
|
5
|
+
import { build_strs_index } from "./build-strs.js";
|
|
6
|
+
import { build_uset_index } from "./build-uset.js";
|
|
7
|
+
;
|
|
8
|
+
;
|
|
9
|
+
;
|
|
10
|
+
function binaryElemCompare(a, b) {
|
|
11
|
+
for (let i = 0; i < a.items.length && i < b.items.length; i++) {
|
|
12
|
+
if (a.items[i]._value < b.items[i]._value)
|
|
13
|
+
return -1;
|
|
14
|
+
if (a.items[i]._value > b.items[i]._value)
|
|
15
|
+
return 1;
|
|
16
|
+
if (a.items[i].flags < b.items[i].flags)
|
|
17
|
+
return -1;
|
|
18
|
+
if (a.items[i].flags > b.items[i].flags)
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
if (a.items.length < b.items.length)
|
|
22
|
+
return -1;
|
|
23
|
+
if (a.items.length > b.items.length)
|
|
24
|
+
return 1;
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
export function build_elem(source_elem, sect_strs, sect_uset) {
|
|
28
|
+
let result = {
|
|
29
|
+
ident: constants.hex_section_id(constants.section.elem),
|
|
30
|
+
size: 0, // finalized below
|
|
31
|
+
_offset: 0,
|
|
32
|
+
count: source_elem.strings.length,
|
|
33
|
+
strings: [], // finalized below
|
|
34
|
+
};
|
|
35
|
+
result.strings = source_elem.strings.map(item => {
|
|
36
|
+
let res = {
|
|
37
|
+
offset: 0, // finalized below
|
|
38
|
+
length: item.length,
|
|
39
|
+
items: [],
|
|
40
|
+
_value: item
|
|
41
|
+
};
|
|
42
|
+
res.items = item.map(v => {
|
|
43
|
+
let element;
|
|
44
|
+
const type = (v.flags & constants.elem_flags_type);
|
|
45
|
+
if (type === constants.elem_flags_type_char || type == constants.elem_flags_type_str) {
|
|
46
|
+
element = build_strs_index(sect_strs, v.value);
|
|
47
|
+
}
|
|
48
|
+
else if (type == constants.elem_flags_type_uset) {
|
|
49
|
+
element = build_uset_index(sect_uset, v.uset);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
throw Error(`Internal Error: Unknown element type 0x${type.toString(16)}`);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
element,
|
|
56
|
+
flags: v.flags | //
|
|
57
|
+
((v.order ?? 0) << constants.elem_flags_order_bitshift) | // -128 to +127; used only by reorder element values
|
|
58
|
+
((v.tertiary ?? 0) << constants.elem_flags_tertiary_bitshift), // -128 to +127; used only by reorder element values
|
|
59
|
+
_value: v.value.value
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
return res;
|
|
63
|
+
});
|
|
64
|
+
result.strings.sort((a, b) => binaryElemCompare(a, b));
|
|
65
|
+
/* Calculate offsets and total size */
|
|
66
|
+
let offset = constants.length_elem + constants.length_elem_item * result.count;
|
|
67
|
+
for (let item of result.strings) {
|
|
68
|
+
if (item.length === 0) {
|
|
69
|
+
// no length gets a zero offset
|
|
70
|
+
item.offset = 0;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
item.offset = offset;
|
|
74
|
+
offset += item.length * constants.length_elem_item_element;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
result.size = offset;
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
export function build_elem_index(sect_elem, value) {
|
|
81
|
+
if (!(value instanceof ElementString)) {
|
|
82
|
+
throw new Error('unexpected value ' + value);
|
|
83
|
+
}
|
|
84
|
+
const result = sect_elem.strings.findIndex(v => value.isEqual(v._value));
|
|
85
|
+
if (result < 0) {
|
|
86
|
+
throw new Error('unexpectedly missing StrsItem ' + value);
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
90
|
//# sourceMappingURL=build-elem.js.map
|
|
91
|
-
//# debugId=
|
|
91
|
+
//# debugId=c85e79ac-9a84-5b6b-aaab-5bc3c0d4e762
|