@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.
Files changed (189) hide show
  1. package/build/src/consts/virtual-key-constants.d.ts +191 -191
  2. package/build/src/consts/virtual-key-constants.js +221 -221
  3. package/build/src/consts/virtual-key-constants.js.map +1 -1
  4. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts +5 -5
  5. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js +72 -72
  6. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js.map +1 -1
  7. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts +28 -28
  8. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js +120 -120
  9. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js.map +1 -1
  10. package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts +95 -95
  11. package/build/src/keyman-touch-layout/keyman-touch-layout-file.js +52 -52
  12. package/build/src/kmx/element-string.d.ts +23 -23
  13. package/build/src/kmx/element-string.js +125 -125
  14. package/build/src/kmx/element-string.js.map +1 -1
  15. package/build/src/kmx/keyman-targets.d.ts +20 -20
  16. package/build/src/kmx/keyman-targets.js +79 -79
  17. package/build/src/kmx/keyman-targets.js.map +1 -1
  18. package/build/src/kmx/kmx-builder.d.ts +32 -32
  19. package/build/src/kmx/kmx-builder.js +189 -189
  20. package/build/src/kmx/kmx-builder.js.map +1 -1
  21. package/build/src/kmx/kmx-file-reader.d.ts +13 -13
  22. package/build/src/kmx/kmx-file-reader.js +134 -134
  23. package/build/src/kmx/kmx-file-reader.js.map +1 -1
  24. package/build/src/kmx/kmx-plus-builder/build-disp.d.ts +18 -18
  25. package/build/src/kmx/kmx-plus-builder/build-disp.js +27 -27
  26. package/build/src/kmx/kmx-plus-builder/build-disp.js.map +1 -1
  27. package/build/src/kmx/kmx-plus-builder/build-elem.d.ts +28 -28
  28. package/build/src/kmx/kmx-plus-builder/build-elem.js +89 -89
  29. package/build/src/kmx/kmx-plus-builder/build-elem.js.map +1 -1
  30. package/build/src/kmx/kmx-plus-builder/build-keys.d.ts +56 -56
  31. package/build/src/kmx/kmx-plus-builder/build-keys.js +107 -107
  32. package/build/src/kmx/kmx-plus-builder/build-keys.js.map +1 -1
  33. package/build/src/kmx/kmx-plus-builder/build-layr.d.ts +53 -53
  34. package/build/src/kmx/kmx-plus-builder/build-layr.js +101 -101
  35. package/build/src/kmx/kmx-plus-builder/build-layr.js.map +1 -1
  36. package/build/src/kmx/kmx-plus-builder/build-list.d.ts +35 -35
  37. package/build/src/kmx/kmx-plus-builder/build-list.js +66 -66
  38. package/build/src/kmx/kmx-plus-builder/build-list.js.map +1 -1
  39. package/build/src/kmx/kmx-plus-builder/build-loca.d.ts +11 -11
  40. package/build/src/kmx/kmx-plus-builder/build-loca.js +21 -21
  41. package/build/src/kmx/kmx-plus-builder/build-loca.js.map +1 -1
  42. package/build/src/kmx/kmx-plus-builder/build-meta.d.ts +16 -16
  43. package/build/src/kmx/kmx-plus-builder/build-meta.js +20 -20
  44. package/build/src/kmx/kmx-plus-builder/build-sect.d.ts +15 -15
  45. package/build/src/kmx/kmx-plus-builder/build-sect.js +15 -15
  46. package/build/src/kmx/kmx-plus-builder/build-sect.js.map +1 -1
  47. package/build/src/kmx/kmx-plus-builder/build-strs.d.ts +22 -22
  48. package/build/src/kmx/kmx-plus-builder/build-strs.js +46 -46
  49. package/build/src/kmx/kmx-plus-builder/build-strs.js.map +1 -1
  50. package/build/src/kmx/kmx-plus-builder/build-tran.d.ts +32 -32
  51. package/build/src/kmx/kmx-plus-builder/build-tran.js +69 -69
  52. package/build/src/kmx/kmx-plus-builder/build-tran.js.map +1 -1
  53. package/build/src/kmx/kmx-plus-builder/build-uset.d.ts +30 -30
  54. package/build/src/kmx/kmx-plus-builder/build-uset.js +60 -60
  55. package/build/src/kmx/kmx-plus-builder/build-uset.js.map +1 -1
  56. package/build/src/kmx/kmx-plus-builder/build-vars.d.ts +21 -21
  57. package/build/src/kmx/kmx-plus-builder/build-vars.js +48 -48
  58. package/build/src/kmx/kmx-plus-builder/build-vars.js.map +1 -1
  59. package/build/src/kmx/kmx-plus-builder/builder-section.d.ts +9 -9
  60. package/build/src/kmx/kmx-plus-builder/builder-section.js +2 -2
  61. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts +42 -42
  62. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js +137 -137
  63. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js.map +1 -1
  64. package/build/src/kmx/kmx-plus.d.ts +322 -322
  65. package/build/src/kmx/kmx-plus.js +830 -830
  66. package/build/src/kmx/kmx-plus.js.map +1 -1
  67. package/build/src/kmx/kmx.d.ts +233 -233
  68. package/build/src/kmx/kmx.js +302 -302
  69. package/build/src/kmx/kmx.js.map +1 -1
  70. package/build/src/kmx/string-list.d.ts +35 -35
  71. package/build/src/kmx/string-list.js +88 -88
  72. package/build/src/kmx/string-list.js.map +1 -1
  73. package/build/src/kpj/keyman-developer-project.d.ts +78 -78
  74. package/build/src/kpj/keyman-developer-project.js +195 -195
  75. package/build/src/kpj/keyman-developer-project.js.map +1 -1
  76. package/build/src/kpj/kpj-file-reader.d.ts +18 -18
  77. package/build/src/kpj/kpj-file-reader.js +119 -119
  78. package/build/src/kpj/kpj-file-reader.js.map +1 -1
  79. package/build/src/kpj/kpj-file.d.ts +39 -39
  80. package/build/src/kpj/kpj-file.js +10 -10
  81. package/build/src/kvk/kvk-file-reader.d.ts +4 -4
  82. package/build/src/kvk/kvk-file-reader.js +37 -37
  83. package/build/src/kvk/kvk-file-reader.js.map +1 -1
  84. package/build/src/kvk/kvk-file-writer.d.ts +19 -19
  85. package/build/src/kvk/kvk-file-writer.js +77 -77
  86. package/build/src/kvk/kvk-file-writer.js.map +1 -1
  87. package/build/src/kvk/kvk-file.d.ts +66 -66
  88. package/build/src/kvk/kvk-file.d.ts.map +1 -1
  89. package/build/src/kvk/kvk-file.js +90 -90
  90. package/build/src/kvk/kvk-file.js.map +1 -1
  91. package/build/src/kvk/kvks-file-reader.d.ts +23 -23
  92. package/build/src/kvk/kvks-file-reader.js +175 -175
  93. package/build/src/kvk/kvks-file-reader.js.map +1 -1
  94. package/build/src/kvk/kvks-file-writer.d.ts +6 -6
  95. package/build/src/kvk/kvks-file-writer.js +106 -106
  96. package/build/src/kvk/kvks-file-writer.js.map +1 -1
  97. package/build/src/kvk/kvks-file.d.ts +43 -43
  98. package/build/src/kvk/kvks-file.js +9 -9
  99. package/build/src/kvk/visual-keyboard.d.ts +44 -44
  100. package/build/src/kvk/visual-keyboard.js +75 -75
  101. package/build/src/kvk/visual-keyboard.js.map +1 -1
  102. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts +60 -60
  103. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js +19 -19
  104. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts +95 -95
  105. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js +409 -409
  106. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js.map +1 -1
  107. package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts +170 -170
  108. package/build/src/ldml-keyboard/ldml-keyboard-xml.js +55 -55
  109. package/build/src/ldml-keyboard/pattern-parser.d.ts +201 -201
  110. package/build/src/ldml-keyboard/pattern-parser.js +490 -490
  111. package/build/src/ldml-keyboard/pattern-parser.js.map +1 -1
  112. package/build/src/ldml-keyboard/unicodeset-parser-api.d.ts +37 -37
  113. package/build/src/ldml-keyboard/unicodeset-parser-api.js +27 -27
  114. package/build/src/main.d.ts +33 -33
  115. package/build/src/main.js +32 -32
  116. package/build/src/package/kmp-json-file.d.ts +115 -115
  117. package/build/src/package/kmp-json-file.js +1 -1
  118. package/build/src/package/kps-file.d.ts +175 -175
  119. package/build/src/package/kps-file.js +15 -15
  120. package/build/src/schema-validators.d.ts +13 -13
  121. package/build/src/schema-validators.js +25 -25
  122. package/build/src/schemas/displaymap.schema.d.ts +57 -57
  123. package/build/src/schemas/displaymap.schema.js +35 -35
  124. package/build/src/schemas/displaymap.schema.validator.d.mts +2 -2
  125. package/build/src/schemas/displaymap.schema.validator.mjs +266 -266
  126. package/build/src/schemas/displaymap.schema.validator.mjs.map +1 -1
  127. package/build/src/schemas/keyboard_info.schema.d.ts +209 -209
  128. package/build/src/schemas/keyboard_info.schema.js +98 -98
  129. package/build/src/schemas/keyboard_info.schema.validator.d.mts +2 -2
  130. package/build/src/schemas/keyboard_info.schema.validator.mjs +1160 -1160
  131. package/build/src/schemas/keyboard_info.schema.validator.mjs.map +1 -1
  132. package/build/src/schemas/keyman-touch-layout.clean.spec.d.ts +227 -227
  133. package/build/src/schemas/keyman-touch-layout.clean.spec.js +151 -151
  134. package/build/src/schemas/keyman-touch-layout.clean.spec.validator.d.mts +2 -2
  135. package/build/src/schemas/keyman-touch-layout.clean.spec.validator.mjs +1094 -1094
  136. package/build/src/schemas/keyman-touch-layout.clean.spec.validator.mjs.map +1 -1
  137. package/build/src/schemas/keyman-touch-layout.spec.d.ts +229 -229
  138. package/build/src/schemas/keyman-touch-layout.spec.js +140 -140
  139. package/build/src/schemas/keyman-touch-layout.spec.validator.d.mts +2 -2
  140. package/build/src/schemas/keyman-touch-layout.spec.validator.mjs +1436 -1436
  141. package/build/src/schemas/keyman-touch-layout.spec.validator.mjs.map +1 -1
  142. package/build/src/schemas/kmp.schema.d.ts +324 -324
  143. package/build/src/schemas/kmp.schema.js +353 -353
  144. package/build/src/schemas/kmp.schema.validator.d.mts +2 -2
  145. package/build/src/schemas/kmp.schema.validator.mjs +1627 -1627
  146. package/build/src/schemas/kmp.schema.validator.mjs.map +1 -1
  147. package/build/src/schemas/kpj-9.0.schema.d.ts +152 -152
  148. package/build/src/schemas/kpj-9.0.schema.js +131 -131
  149. package/build/src/schemas/kpj-9.0.schema.validator.d.mts +2 -2
  150. package/build/src/schemas/kpj-9.0.schema.validator.mjs +655 -655
  151. package/build/src/schemas/kpj-9.0.schema.validator.mjs.map +1 -1
  152. package/build/src/schemas/kpj.schema.d.ts +122 -122
  153. package/build/src/schemas/kpj.schema.js +129 -129
  154. package/build/src/schemas/kpj.schema.validator.d.mts +2 -2
  155. package/build/src/schemas/kpj.schema.validator.mjs +515 -515
  156. package/build/src/schemas/kpj.schema.validator.mjs.map +1 -1
  157. package/build/src/schemas/kvks.schema.d.ts +160 -160
  158. package/build/src/schemas/kvks.schema.js +182 -182
  159. package/build/src/schemas/kvks.schema.validator.d.mts +2 -2
  160. package/build/src/schemas/kvks.schema.validator.mjs +625 -625
  161. package/build/src/schemas/kvks.schema.validator.mjs.map +1 -1
  162. package/build/src/schemas/ldml-keyboard3.schema.d.ts +635 -635
  163. package/build/src/schemas/ldml-keyboard3.schema.js +696 -696
  164. package/build/src/schemas/ldml-keyboard3.schema.validator.d.mts +2 -2
  165. package/build/src/schemas/ldml-keyboard3.schema.validator.mjs +3117 -3117
  166. package/build/src/schemas/ldml-keyboard3.schema.validator.mjs.map +1 -1
  167. package/build/src/schemas/ldml-keyboardtest3.schema.d.ts +192 -192
  168. package/build/src/schemas/ldml-keyboardtest3.schema.js +225 -225
  169. package/build/src/schemas/ldml-keyboardtest3.schema.validator.d.mts +2 -2
  170. package/build/src/schemas/ldml-keyboardtest3.schema.validator.mjs +744 -744
  171. package/build/src/schemas/ldml-keyboardtest3.schema.validator.mjs.map +1 -1
  172. package/build/src/schemas.d.ts +2300 -2300
  173. package/build/src/schemas.js +23 -23
  174. package/build/src/util/common-events.d.ts +44 -44
  175. package/build/src/util/common-events.js +26 -26
  176. package/build/src/util/compiler-interfaces.d.ts +371 -371
  177. package/build/src/util/compiler-interfaces.d.ts.map +1 -1
  178. package/build/src/util/compiler-interfaces.js +380 -380
  179. package/build/src/util/compiler-interfaces.js.map +1 -1
  180. package/build/src/util/errors.d.ts +5 -5
  181. package/build/src/util/errors.js +5 -5
  182. package/build/src/util/file-types.d.ts +93 -93
  183. package/build/src/util/file-types.d.ts.map +1 -1
  184. package/build/src/util/file-types.js +142 -142
  185. package/build/src/util/file-types.js.map +1 -1
  186. package/build/src/util/util.d.ts +98 -98
  187. package/build/src/util/util.js +368 -368
  188. package/build/src/util/util.js.map +1 -1
  189. package/package.json +3 -3
@@ -1,832 +1,832 @@
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]="13f36df0-a89d-554b-8fe1-c2f2e8d02022")}catch(e){}}();
3
- import { constants } from '@keymanapp/ldml-keyboard-constants';
4
- import * as r from 'restructure';
5
- import { ElementString } from './element-string.js';
6
- import { ListItem } from './string-list.js';
7
- import { isOneChar, toOneChar, unescapeString, escapeStringForRegex } from '../util/util.js';
8
- import { KMXFile } from './kmx.js';
9
- import { VariableParser } from '../ldml-keyboard/pattern-parser.js';
10
- import { MarkerParser } from '../ldml-keyboard/pattern-parser.js';
11
- // Implementation of file structures from /core/src/ldml/C7043_ldml.md
12
- // Writer in kmx-builder.ts
13
- // Reader in kmx-loader.ts
14
- export class Section {
15
- }
16
- // 'sect'
17
- export class Sect extends Section {
18
- }
19
- ;
20
- // 'bksp' -- see 'tran'
21
- // 'elem'
22
- export class Elem extends Section {
23
- strings = [];
24
- constructor(sections) {
25
- super();
26
- this.strings.push(ElementString.fromStrings(sections, '')); // C7043: null element string
27
- }
28
- /**
29
- * @param source if a string array, does not get reinterpreted as UnicodeSet. This is used with vars, etc. Or pass `["str"]` for an explicit 1-element elem.
30
- * If it is a string, will be interpreted per reorder element ruls.
31
- */
32
- allocElementString(sections, source, order, tertiary, tertiary_base, prebase) {
33
- let s = ElementString.fromStrings(sections, source, order, tertiary, tertiary_base, prebase);
34
- if (!s)
35
- return s;
36
- let result = this.strings.find(item => item.isEqual(s));
37
- if (result === undefined) {
38
- result = s;
39
- this.strings.push(result);
40
- }
41
- return result;
42
- }
43
- }
44
- ;
45
- // 'keys' is now `keys2.kmap`
46
- // 'loca'
47
- export class Loca extends Section {
48
- locales = [];
49
- }
50
- ;
51
- // 'meta'
52
- export var KeyboardSettings;
53
- (function (KeyboardSettings) {
54
- KeyboardSettings[KeyboardSettings["none"] = 0] = "none";
55
- KeyboardSettings[KeyboardSettings["normalizationDisabled"] = constants.meta_settings_normalization_disabled] = "normalizationDisabled";
56
- })(KeyboardSettings || (KeyboardSettings = {}));
57
- ;
58
- export class Meta extends Section {
59
- author;
60
- conform;
61
- layout;
62
- name;
63
- indicator;
64
- version; // semver version string, defaults to "0"
65
- settings;
66
- /** convenience for checking settings */
67
- get normalizationDisabled() {
68
- return this?.settings & KeyboardSettings.normalizationDisabled;
69
- }
70
- }
71
- ;
72
- // 'strs'
73
- /**
74
- * A string item in memory. This will be replaced with an index
75
- * into the string table at finalization.
76
- */
77
- export class StrsItem {
78
- /** string value */
79
- value;
80
- /** char value if this is a single-char placeholder item (CharStrsItem) */
81
- char;
82
- constructor(value, char) {
83
- if (char !== undefined) {
84
- if (!isOneChar(value)) {
85
- throw new Error(`StrsItem: ${value} is not a single char`);
86
- }
87
- if (char !== toOneChar(value)) {
88
- throw new Error(`StrsItem: ${char} is not the right codepoint for ${value}`);
89
- }
90
- }
91
- this.value = value;
92
- this.char = char;
93
- }
94
- compareTo(o) {
95
- return StrsItem.binaryStringCompare(this.value, o.value);
96
- }
97
- static binaryStringCompare(a, b) {
98
- // https://tc39.es/ecma262/multipage/abstract-operations.html#sec-islessthan
99
- if (typeof a != 'string' || typeof b != 'string') {
100
- throw new Error('binaryStringCompare: inputs must be strings');
101
- }
102
- if (a < b)
103
- return -1;
104
- if (a > b)
105
- return 1;
106
- return 0;
107
- }
108
- get isOneChar() {
109
- return this.char !== undefined;
110
- }
111
- }
112
- ;
113
- /**
114
- * A StrsItem for a single char. Used as a placeholder and hint to the builder
115
- */
116
- export class CharStrsItem extends StrsItem {
117
- constructor(value) {
118
- if (!isOneChar(value)) {
119
- throw RangeError(`not a 1-char string`);
120
- }
121
- super(value, toOneChar(value));
122
- }
123
- }
124
- ;
125
- ;
126
- export class Strs extends Section {
127
- /** the in-memory string table */
128
- strings = [new StrsItem('')]; // C7043: The null string is always required
129
- /** for validating */
130
- allProcessedStrings = new Set();
131
- /**
132
- * Allocate a StrsItem given the string, unescaping if necessary.
133
- * @param s escaped string
134
- * @param opts options for allocation
135
- * @param sections other sections, if needed
136
- * @returns StrsItem
137
- */
138
- allocString(s, opts, sections) {
139
- // Run the string processing pipeline
140
- s = Strs.processString(s, opts, sections);
141
- // add to the set, for testing
142
- if (s) {
143
- this.allProcessedStrings.add(s);
144
- }
145
- // if it's a single char, don't push it into the strs table
146
- if (opts?.singleOk && isOneChar(s)) {
147
- return new CharStrsItem(s);
148
- }
149
- // default: look to see if the string is already present
150
- let result = this.strings.find(item => item.value === s);
151
- if (result === undefined) {
152
- // only add if not already present
153
- result = new StrsItem(s);
154
- this.strings.push(result);
155
- }
156
- return result;
157
- }
158
- /** process everything according to opts */
159
- static processString(s, opts, sections) {
160
- s = s ?? '';
161
- // type check everything else
162
- if (typeof s !== 'string') {
163
- throw new Error('alloc_string: s must be a string, undefined, or null.');
164
- }
165
- // substitute variables
166
- if (opts?.stringVariables) {
167
- s = sections.vars.substituteStrings(s, sections);
168
- }
169
- // substitute markers
170
- if (opts?.markers) {
171
- s = sections.vars.substituteMarkerString(s);
172
- }
173
- // unescape \u{…}
174
- if (opts?.unescape) {
175
- s = unescapeString(s);
176
- }
177
- // nfd
178
- if (opts?.nfd) {
179
- if (!sections?.meta?.normalizationDisabled) {
180
- if (opts?.markers) {
181
- s = MarkerParser.nfd_markers(s, false);
182
- }
183
- else {
184
- s = s.normalize("NFD");
185
- }
186
- }
187
- }
188
- return s;
189
- }
190
- }
191
- ;
192
- /**
193
- * See LKVariables
194
- */
195
- export class Vars extends Section {
196
- totalCount() {
197
- return this.strings.length + this.sets.length + this.usets.length;
198
- }
199
- markers;
200
- strings = []; // ≠ StrsItem
201
- sets = [];
202
- usets = [];
203
- /**
204
- *
205
- * @returns false if any invalid variables
206
- */
207
- valid() {
208
- for (const t of [this.sets, this.strings, this.usets]) {
209
- for (const i of t) {
210
- if (!i.valid()) {
211
- return false;
212
- }
213
- }
214
- }
215
- return true;
216
- }
217
- // utilities for making use of Vars in other sections
218
- substituteSets(str, sections) {
219
- return str.replaceAll(VariableParser.SET_REFERENCE, (_entire, id) => {
220
- const val = Vars.findVariable(this.sets, id);
221
- if (val === null) {
222
- // Should have been caught during validation.
223
- throw Error(`Internal Error: reference to missing set variable ${id}`);
224
- }
225
- return val.value.value;
226
- });
227
- }
228
- substituteUnicodeSets(value, sections) {
229
- return value.replaceAll(VariableParser.SET_REFERENCE, (_entire, id) => {
230
- const v = Vars.findVariable(this.usets, id);
231
- if (v === null) {
232
- // Should have been caught during validation.
233
- throw Error(`Internal Error: reference to missing UnicodeSet variable ${id}`);
234
- }
235
- return v.value.value; // string value
236
- });
237
- }
238
- substituteStrings(str, sections, forMatch) {
239
- if (!str)
240
- return str;
241
- return str.replaceAll(VariableParser.STRING_REFERENCE, (_entire, id) => {
242
- const val = this.findStringVariableValue(id);
243
- if (val === null) {
244
- // Should have been caught during validation.
245
- throw Error(`Internal Error: reference to missing string variable ${id}`);
246
- }
247
- if (forMatch)
248
- return escapeStringForRegex(val);
249
- return val;
250
- });
251
- }
252
- findStringVariableValue(id) {
253
- return Vars.findVariable(this.strings, id)?.value?.value; // Unwrap: Variable, StrsItem
254
- }
255
- substituteSetRegex(str, sections) {
256
- return str.replaceAll(VariableParser.SET_REFERENCE, (_entire, id) => {
257
- // try as set
258
- const set = Vars.findVariable(this.sets, id);
259
- if (set !== null) {
260
- const { items } = set;
261
- const escapedStrings = items.map(v => escapeStringForRegex(v.value.value));
262
- const inner = escapedStrings.join('|');
263
- return `(?:${inner})`;
264
- }
265
- // try as unicodeset
266
- const uset = Vars.findVariable(this.usets, id);
267
- if (uset !== null) {
268
- const { unicodeSet } = uset;
269
- const inner = unicodeSet.ranges.map(([start, end]) => {
270
- const s = String.fromCodePoint(start);
271
- if (start === end) {
272
- return s;
273
- }
274
- else {
275
- const e = String.fromCodePoint(end);
276
- return `${s}-${e}`;
277
- }
278
- }).join('');
279
- return `[${inner}]`;
280
- }
281
- // else, missing
282
- throw Error(`Internal Error: reference to missing set variable ${id}`);
283
- });
284
- }
285
- /**
286
- * Variable locator facility
287
- * @param array
288
- * @param id
289
- * @returns
290
- */
291
- static findVariable(array, id) {
292
- const v = array.filter(e => e.id.value === id);
293
- if (v.length === 0) {
294
- return null;
295
- }
296
- else if (v.length !== 1) {
297
- // Should have been caught during validation
298
- throw Error(`Internal Error: Duplicate variable id ${id} crept into a variable list.`);
299
- }
300
- else {
301
- return v[0];
302
- }
303
- }
304
- substituteMarkerString(s, forMatch) {
305
- return MarkerParser.toSentinelString(s, this.markers, forMatch);
306
- }
307
- }
308
- ;
309
- /**
310
- * Common base for variable sections
311
- * See Variable
312
- */
313
- export class VarsItem extends Section {
314
- id;
315
- value;
316
- constructor(id, value, sections) {
317
- super();
318
- this.id = sections.strs.allocString(id);
319
- this.value = sections.strs.allocString(value, { unescape: true });
320
- }
321
- valid() {
322
- return true;
323
- }
324
- }
325
- ;
326
- export class UnicodeSetItem extends VarsItem {
327
- constructor(id, value, sections, usetparser) {
328
- super(id, value, sections);
329
- const needRanges = sections.usetparser.sizeUnicodeSet(value);
330
- if (needRanges >= 0) {
331
- this.unicodeSet = sections.usetparser.parseUnicodeSet(value, needRanges);
332
- } // otherwise: error (was recorded via callback)
333
- }
334
- unicodeSet;
335
- valid() {
336
- return !!this.unicodeSet;
337
- }
338
- }
339
- ;
340
- export class SetVarItem extends VarsItem {
341
- constructor(id, value, sections, rawItems) {
342
- super(id, value.join(' '), sections);
343
- this.items = sections.elem.allocElementString(sections, value);
344
- this.rawItems = rawItems;
345
- }
346
- // element string array
347
- items;
348
- // like items, but with unprocessed marker strings
349
- rawItems;
350
- valid() {
351
- return !!this.items;
352
- }
353
- }
354
- ;
355
- export class StringVarItem extends VarsItem {
356
- constructor(id, value, sections) {
357
- super(id, value, sections);
358
- }
359
- }
360
- ;
361
- // 'tran'
362
- export class TranTransform {
363
- from;
364
- to;
365
- mapFrom; // var name
366
- mapTo; // var name
367
- }
368
- export class TranGroup {
369
- type; // tran_group_type_transform | tran_group_type_reorder
370
- transforms = [];
371
- reorders = [];
372
- }
373
- export class TranReorder {
374
- elements;
375
- before;
376
- }
377
- ;
378
- export class Tran extends Section {
379
- groups = [];
380
- get id() {
381
- return constants.section.tran;
382
- }
383
- }
384
- ;
385
- export class UsetItem {
386
- uset;
387
- str;
388
- constructor(uset, str) {
389
- this.uset = uset;
390
- this.str = str;
391
- }
392
- compareTo(other) {
393
- return this.str.compareTo(other.str);
394
- }
395
- }
396
- ;
397
- export class Uset extends Section {
398
- usets = [];
399
- allocUset(set, sections) {
400
- // match the same pattern
401
- let result = this.usets.find(s => set.pattern == s.uset.pattern);
402
- if (result === undefined) {
403
- result = new UsetItem(set, sections.strs.allocString(set.pattern));
404
- this.usets.push(result);
405
- }
406
- return result;
407
- }
408
- }
409
- ;
410
- // alias type for 'bksp'
411
- export class Bksp extends Tran {
412
- get id() {
413
- return constants.section.bksp;
414
- }
415
- }
416
- ;
417
- // 'disp'
418
- export class DispItem {
419
- to;
420
- id;
421
- display;
422
- }
423
- ;
424
- export class Disp extends Section {
425
- baseCharacter;
426
- disps = [];
427
- }
428
- ;
429
- // 'layr'
430
- /**
431
- * In-memory `<layers>`
432
- */
433
- export class LayrList {
434
- hardware;
435
- layers = [];
436
- minDeviceWidth; // millimeters
437
- }
438
- ;
439
- /**
440
- * In-memory `<layer>`
441
- */
442
- export class LayrEntry {
443
- id;
444
- mod;
445
- rows = [];
446
- }
447
- ;
448
- /**
449
- * In-memory `<row>`
450
- */
451
- export class LayrRow {
452
- keys = [];
453
- }
454
- ;
455
- export class Layr extends Section {
456
- lists = [];
457
- }
458
- ;
459
- export class KeysKeys {
460
- flags;
461
- flicks; // for in-memory only
462
- id;
463
- longPress;
464
- longPressDefault;
465
- multiTap;
466
- switch;
467
- to;
468
- width;
469
- }
470
- ;
471
- export class KeysKmap {
472
- vkey;
473
- mod;
474
- key; // for in-memory only
475
- }
476
- ;
477
- export class KeysFlicks {
478
- flicks = [];
479
- id;
480
- compareTo(b) {
481
- return this.id.compareTo(b.id);
482
- }
483
- constructor(id) {
484
- this.id = id;
485
- }
486
- }
487
- ;
488
- export class KeysFlick {
489
- directions;
490
- keyId;
491
- }
492
- ;
493
- export class Keys extends Section {
494
- keys = [];
495
- flicks = [];
496
- kmap = [];
497
- constructor(strs) {
498
- super();
499
- let nullFlicks = new KeysFlicks(strs.allocString(''));
500
- this.flicks.push(nullFlicks); // C7043: null element string
501
- }
502
- }
503
- ;
504
- export class List extends Section {
505
- /**
506
- * Allocate a list from a space-separated list of items.
507
- * Note that passing undefined or null or `''` will
508
- * end up being the same as the empty list `[]`
509
- * @param s space-separated list of items
510
- * @param opts string options
511
- * @param sections sections
512
- * @returns a List object
513
- */
514
- allocListFromSpaces(s, opts, sections) {
515
- s = s ?? '';
516
- return this.allocList(s.split(' '), opts, sections);
517
- }
518
- /**
519
- * Return a List object referring to the string list.
520
- * Note that a falsy list, or a list containing only an empty string
521
- * `['']` will be stored as an empty list `[]`.
522
- * @param strs Strs section for allocation
523
- * @param s string list to allocate
524
- * @returns
525
- */
526
- allocList(s, opts, sections) {
527
- // Special case the 'null' list for [] or ['']
528
- if (!s || (s.length === 1 && s[0] === '')) {
529
- return this.lists[0];
530
- }
531
- let result = this.lists.find(item => item.isEqual(s));
532
- if (result === undefined) {
533
- // allocate a new ListItem
534
- result = ListItem.fromStrings(s, opts, sections);
535
- this.lists.push(result);
536
- }
537
- return result;
538
- }
539
- constructor(strs) {
540
- super();
541
- this.lists.push(ListItem.fromStrings([], {}, { strs })); // C7043: null element string
542
- }
543
- lists = [];
544
- }
545
- ;
546
- export { ListItem as ListItem };
547
- ;
548
- export class KMXPlusFile extends KMXFile {
549
- /* KMXPlus file structures */
550
- COMP_PLUS_SECT_ITEM;
551
- COMP_PLUS_SECT;
552
- // COMP_PLUS_BKSP == COMP_PLUS_TRAN
553
- COMP_PLUS_BKSP_ITEM;
554
- COMP_PLUS_BKSP;
555
- COMP_PLUS_DISP_ITEM;
556
- COMP_PLUS_DISP;
557
- COMP_PLUS_ELEM_ELEMENT;
558
- COMP_PLUS_ELEM_STRING;
559
- COMP_PLUS_ELEM;
560
- // COMP_PLUS_KEYS is now COMP_PLUS_KEYS_KMAP
561
- COMP_PLUS_LAYR_ENTRY;
562
- COMP_PLUS_LAYR_KEY;
563
- COMP_PLUS_LAYR_LIST;
564
- COMP_PLUS_LAYR_ROW;
565
- COMP_PLUS_LAYR;
566
- COMP_PLUS_KEYS_FLICK;
567
- COMP_PLUS_KEYS_FLICKS;
568
- COMP_PLUS_KEYS_KEY;
569
- COMP_PLUS_KEYS_KMAP;
570
- COMP_PLUS_KEYS;
571
- COMP_PLUS_LIST_LIST;
572
- COMP_PLUS_LIST_INDEX;
573
- COMP_PLUS_LIST;
574
- COMP_PLUS_LOCA_ITEM;
575
- COMP_PLUS_LOCA;
576
- COMP_PLUS_META;
577
- COMP_PLUS_STRS_ITEM;
578
- COMP_PLUS_STRS;
579
- COMP_PLUS_TRAN_GROUP;
580
- COMP_PLUS_TRAN_TRANSFORM;
581
- COMP_PLUS_TRAN_REORDER;
582
- COMP_PLUS_TRAN;
583
- COMP_PLUS_USET_USET;
584
- COMP_PLUS_USET_RANGE;
585
- COMP_PLUS_USET;
586
- COMP_PLUS_VKEY_ITEM;
587
- COMP_PLUS_VKEY;
588
- COMP_PLUS_VARS;
589
- COMP_PLUS_VARS_ITEM;
590
- /* File in-memory data */
591
- kmxplus = {};
592
- constructor() {
593
- super();
594
- // Binary-correct structures matching kmx_plus.h
595
- // helpers
596
- const STR_REF = r.uint32le;
597
- const ELEM_REF = r.uint32le;
598
- const LIST_REF = r.uint32le;
599
- const STR_OR_CHAR32 = r.uint32le;
600
- const CHAR32 = r.uint32le;
601
- const STR_OR_CHAR32_OR_USET = r.uint32le;
602
- const IDENT = r.uint32le;
603
- // 'sect'
604
- this.COMP_PLUS_SECT_ITEM = new r.Struct({
605
- sect: r.uint32le,
606
- offset: r.uint32le //? new r.VoidPointer(r.uint32le, {type: 'global'})
607
- });
608
- this.COMP_PLUS_SECT = new r.Struct({
609
- ident: IDENT,
610
- size: r.uint32le,
611
- total: r.uint32le,
612
- count: r.uint32le,
613
- items: new r.Array(this.COMP_PLUS_SECT_ITEM, 'count')
614
- });
615
- // 'bksp' - see 'tran'
616
- // 'disp'
617
- this.COMP_PLUS_DISP_ITEM = new r.Struct({
618
- to: STR_REF,
619
- id: STR_REF,
620
- display: STR_REF,
621
- });
622
- this.COMP_PLUS_DISP = new r.Struct({
623
- ident: IDENT,
624
- size: r.uint32le,
625
- count: r.uint32le,
626
- baseCharacter: CHAR32,
627
- items: new r.Array(this.COMP_PLUS_DISP_ITEM, 'count'),
628
- });
629
- // 'elem'
630
- this.COMP_PLUS_ELEM_ELEMENT = new r.Struct({
631
- element: STR_OR_CHAR32_OR_USET,
632
- flags: r.uint32le
633
- });
634
- this.COMP_PLUS_ELEM_STRING = new r.Struct({
635
- offset: r.uint32le,
636
- length: r.uint32le
637
- });
638
- this.COMP_PLUS_ELEM = new r.Struct({
639
- ident: IDENT,
640
- size: r.uint32le,
641
- count: r.uint32le,
642
- strings: new r.Array(this.COMP_PLUS_ELEM_STRING, 'count')
643
- // + variable subtable: Element data (see KMXPlusBuilder.emitElements())
644
- });
645
- // 'finl' - see 'tran'
646
- // 'keys' - see 'keys.kmap'
647
- // 'layr'
648
- this.COMP_PLUS_LAYR_ENTRY = new r.Struct({
649
- id: r.uint32le,
650
- mod: r.uint32le,
651
- row: r.uint32le,
652
- count: r.uint32le,
653
- });
654
- this.COMP_PLUS_LAYR_KEY = new r.Struct({
655
- key: r.uint32le, // str: key id
656
- });
657
- this.COMP_PLUS_LAYR_LIST = new r.Struct({
658
- hardware: STR_REF,
659
- layer: r.uint32le,
660
- count: r.uint32le,
661
- minDeviceWidth: r.uint32le, // integer: millimeters
662
- });
663
- this.COMP_PLUS_LAYR_ROW = new r.Struct({
664
- key: r.uint32le,
665
- count: r.uint32le,
666
- });
667
- this.COMP_PLUS_LAYR = new r.Struct({
668
- ident: IDENT,
669
- size: r.uint32le,
670
- listCount: r.uint32le,
671
- layerCount: r.uint32le,
672
- rowCount: r.uint32le,
673
- keyCount: r.uint32le,
674
- lists: new r.Array(this.COMP_PLUS_LAYR_LIST, 'listCount'),
675
- layers: new r.Array(this.COMP_PLUS_LAYR_ENTRY, 'layerCount'),
676
- rows: new r.Array(this.COMP_PLUS_LAYR_ROW, 'rowCount'),
677
- keys: new r.Array(this.COMP_PLUS_LAYR_KEY, 'keyCount'),
678
- });
679
- this.COMP_PLUS_KEYS_FLICK = new r.Struct({
680
- directions: LIST_REF,
681
- to: STR_OR_CHAR32, // str | codepoint
682
- });
683
- this.COMP_PLUS_KEYS_FLICKS = new r.Struct({
684
- count: r.uint32le,
685
- flick: r.uint32le,
686
- id: STR_REF, // str
687
- });
688
- this.COMP_PLUS_KEYS_KEY = new r.Struct({
689
- to: STR_OR_CHAR32,
690
- flags: r.uint32le,
691
- id: STR_REF,
692
- switch: STR_REF,
693
- width: r.uint32le,
694
- longPress: LIST_REF,
695
- longPressDefault: STR_REF,
696
- multiTap: LIST_REF,
697
- flicks: r.uint32le, // index into flicks table
698
- });
699
- this.COMP_PLUS_KEYS_KMAP = new r.Struct({
700
- vkey: r.uint32le,
701
- mod: r.uint32le,
702
- key: r.uint32le, // index into 'keys' subtable
703
- });
704
- this.COMP_PLUS_KEYS = new r.Struct({
705
- ident: IDENT,
706
- size: r.uint32le,
707
- keyCount: r.uint32le,
708
- flicksCount: r.uint32le,
709
- flickCount: r.uint32le,
710
- kmapCount: r.uint32le,
711
- keys: new r.Array(this.COMP_PLUS_KEYS_KEY, 'keyCount'),
712
- flicks: new r.Array(this.COMP_PLUS_KEYS_FLICKS, 'flicksCount'),
713
- flick: new r.Array(this.COMP_PLUS_KEYS_FLICK, 'flickCount'),
714
- kmap: new r.Array(this.COMP_PLUS_KEYS_KMAP, 'kmapCount'),
715
- });
716
- // 'list'
717
- this.COMP_PLUS_LIST_LIST = new r.Struct({
718
- index: r.uint32le,
719
- count: r.uint32le,
720
- });
721
- this.COMP_PLUS_LIST_INDEX = new r.Struct({
722
- str: STR_REF, // str
723
- });
724
- this.COMP_PLUS_LIST = new r.Struct({
725
- ident: IDENT,
726
- size: r.uint32le,
727
- listCount: r.uint32le,
728
- indexCount: r.uint32le,
729
- lists: new r.Array(this.COMP_PLUS_LIST_LIST, 'listCount'),
730
- indices: new r.Array(this.COMP_PLUS_LIST_INDEX, 'indexCount'),
731
- });
732
- // 'loca'
733
- this.COMP_PLUS_LOCA_ITEM = r.uint32le; //str
734
- this.COMP_PLUS_LOCA = new r.Struct({
735
- ident: IDENT,
736
- size: r.uint32le,
737
- count: r.uint32le,
738
- items: new r.Array(this.COMP_PLUS_LOCA_ITEM, 'count')
739
- });
740
- // 'meta'
741
- this.COMP_PLUS_META = new r.Struct({
742
- ident: IDENT,
743
- size: r.uint32le,
744
- author: STR_REF,
745
- conform: STR_REF,
746
- layout: STR_REF,
747
- name: STR_REF,
748
- indicator: STR_REF,
749
- version: STR_REF,
750
- settings: r.uint32le, //new r.Bitfield(r.uint32le, ['normalizationDisabled'])
751
- });
752
- // 'name' is gone
753
- // 'ordr' now part of 'tran'
754
- // 'strs'
755
- this.COMP_PLUS_STRS_ITEM = new r.Struct({
756
- // While we use length which is number of utf-16 code units excluding null terminator,
757
- // we always write a null terminator, so we can get restructure to do that for us here
758
- offset: r.uint32le,
759
- length: r.uint32le
760
- });
761
- this.COMP_PLUS_STRS = new r.Struct({
762
- ident: IDENT,
763
- size: r.uint32le,
764
- count: r.uint32le,
765
- items: new r.Array(this.COMP_PLUS_STRS_ITEM, 'count')
766
- // + variable subtable: String data (see KMXPlusBuilder.emitStrings())
767
- });
768
- // 'tran'
769
- this.COMP_PLUS_TRAN_GROUP = new r.Struct({
770
- type: r.uint32le,
771
- count: r.uint32le,
772
- index: r.uint32le, //index into subtable
773
- });
774
- this.COMP_PLUS_TRAN_TRANSFORM = new r.Struct({
775
- from: STR_REF,
776
- to: STR_REF,
777
- mapFrom: ELEM_REF,
778
- mapTo: ELEM_REF //elem
779
- });
780
- this.COMP_PLUS_TRAN_REORDER = new r.Struct({
781
- elements: ELEM_REF,
782
- before: ELEM_REF, //elem
783
- });
784
- this.COMP_PLUS_TRAN = new r.Struct({
785
- ident: IDENT,
786
- size: r.uint32le,
787
- groupCount: r.uint32le,
788
- transformCount: r.uint32le,
789
- reorderCount: r.uint32le,
790
- groups: new r.Array(this.COMP_PLUS_TRAN_GROUP, 'groupCount'),
791
- transforms: new r.Array(this.COMP_PLUS_TRAN_TRANSFORM, 'transformCount'),
792
- reorders: new r.Array(this.COMP_PLUS_TRAN_REORDER, 'reorderCount'),
793
- });
794
- // 'uset'
795
- this.COMP_PLUS_USET_USET = new r.Struct({
796
- range: r.uint32le,
797
- count: r.uint32le,
798
- pattern: STR_REF, // str
799
- });
800
- this.COMP_PLUS_USET_RANGE = new r.Struct({
801
- start: CHAR32,
802
- end: CHAR32,
803
- });
804
- this.COMP_PLUS_USET = new r.Struct({
805
- ident: IDENT,
806
- size: r.uint32le,
807
- usetCount: r.uint32le,
808
- rangeCount: r.uint32le,
809
- usets: new r.Array(this.COMP_PLUS_USET_USET, 'usetCount'),
810
- ranges: new r.Array(this.COMP_PLUS_USET_RANGE, 'rangeCount'),
811
- });
812
- // 'vars'
813
- this.COMP_PLUS_VARS_ITEM = new r.Struct({
814
- type: r.uint32le,
815
- id: STR_REF,
816
- value: STR_REF,
817
- elem: ELEM_REF,
818
- });
819
- this.COMP_PLUS_VARS = new r.Struct({
820
- ident: IDENT,
821
- size: r.uint32le,
822
- markers: LIST_REF,
823
- varCount: r.uint32le,
824
- varEntries: new r.Array(this.COMP_PLUS_VARS_ITEM, 'varCount'),
825
- });
826
- // 'vkey' is removed
827
- // Aliases
828
- this.COMP_PLUS_BKSP = this.COMP_PLUS_TRAN;
829
- }
830
- }
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]="462c24ab-41a5-5a83-a6f2-7a5b4b280d08")}catch(e){}}();
3
+ import { constants } from '@keymanapp/ldml-keyboard-constants';
4
+ import * as r from 'restructure';
5
+ import { ElementString } from './element-string.js';
6
+ import { ListItem } from './string-list.js';
7
+ import { isOneChar, toOneChar, unescapeString, escapeStringForRegex } from '../util/util.js';
8
+ import { KMXFile } from './kmx.js';
9
+ import { VariableParser } from '../ldml-keyboard/pattern-parser.js';
10
+ import { MarkerParser } from '../ldml-keyboard/pattern-parser.js';
11
+ // Implementation of file structures from /core/src/ldml/C7043_ldml.md
12
+ // Writer in kmx-builder.ts
13
+ // Reader in kmx-loader.ts
14
+ export class Section {
15
+ }
16
+ // 'sect'
17
+ export class Sect extends Section {
18
+ }
19
+ ;
20
+ // 'bksp' -- see 'tran'
21
+ // 'elem'
22
+ export class Elem extends Section {
23
+ strings = [];
24
+ constructor(sections) {
25
+ super();
26
+ this.strings.push(ElementString.fromStrings(sections, '')); // C7043: null element string
27
+ }
28
+ /**
29
+ * @param source if a string array, does not get reinterpreted as UnicodeSet. This is used with vars, etc. Or pass `["str"]` for an explicit 1-element elem.
30
+ * If it is a string, will be interpreted per reorder element ruls.
31
+ */
32
+ allocElementString(sections, source, order, tertiary, tertiary_base, prebase) {
33
+ let s = ElementString.fromStrings(sections, source, order, tertiary, tertiary_base, prebase);
34
+ if (!s)
35
+ return s;
36
+ let result = this.strings.find(item => item.isEqual(s));
37
+ if (result === undefined) {
38
+ result = s;
39
+ this.strings.push(result);
40
+ }
41
+ return result;
42
+ }
43
+ }
44
+ ;
45
+ // 'keys' is now `keys2.kmap`
46
+ // 'loca'
47
+ export class Loca extends Section {
48
+ locales = [];
49
+ }
50
+ ;
51
+ // 'meta'
52
+ export var KeyboardSettings;
53
+ (function (KeyboardSettings) {
54
+ KeyboardSettings[KeyboardSettings["none"] = 0] = "none";
55
+ KeyboardSettings[KeyboardSettings["normalizationDisabled"] = constants.meta_settings_normalization_disabled] = "normalizationDisabled";
56
+ })(KeyboardSettings || (KeyboardSettings = {}));
57
+ ;
58
+ export class Meta extends Section {
59
+ author;
60
+ conform;
61
+ layout;
62
+ name;
63
+ indicator;
64
+ version; // semver version string, defaults to "0"
65
+ settings;
66
+ /** convenience for checking settings */
67
+ get normalizationDisabled() {
68
+ return this?.settings & KeyboardSettings.normalizationDisabled;
69
+ }
70
+ }
71
+ ;
72
+ // 'strs'
73
+ /**
74
+ * A string item in memory. This will be replaced with an index
75
+ * into the string table at finalization.
76
+ */
77
+ export class StrsItem {
78
+ /** string value */
79
+ value;
80
+ /** char value if this is a single-char placeholder item (CharStrsItem) */
81
+ char;
82
+ constructor(value, char) {
83
+ if (char !== undefined) {
84
+ if (!isOneChar(value)) {
85
+ throw new Error(`StrsItem: ${value} is not a single char`);
86
+ }
87
+ if (char !== toOneChar(value)) {
88
+ throw new Error(`StrsItem: ${char} is not the right codepoint for ${value}`);
89
+ }
90
+ }
91
+ this.value = value;
92
+ this.char = char;
93
+ }
94
+ compareTo(o) {
95
+ return StrsItem.binaryStringCompare(this.value, o.value);
96
+ }
97
+ static binaryStringCompare(a, b) {
98
+ // https://tc39.es/ecma262/multipage/abstract-operations.html#sec-islessthan
99
+ if (typeof a != 'string' || typeof b != 'string') {
100
+ throw new Error('binaryStringCompare: inputs must be strings');
101
+ }
102
+ if (a < b)
103
+ return -1;
104
+ if (a > b)
105
+ return 1;
106
+ return 0;
107
+ }
108
+ get isOneChar() {
109
+ return this.char !== undefined;
110
+ }
111
+ }
112
+ ;
113
+ /**
114
+ * A StrsItem for a single char. Used as a placeholder and hint to the builder
115
+ */
116
+ export class CharStrsItem extends StrsItem {
117
+ constructor(value) {
118
+ if (!isOneChar(value)) {
119
+ throw RangeError(`not a 1-char string`);
120
+ }
121
+ super(value, toOneChar(value));
122
+ }
123
+ }
124
+ ;
125
+ ;
126
+ export class Strs extends Section {
127
+ /** the in-memory string table */
128
+ strings = [new StrsItem('')]; // C7043: The null string is always required
129
+ /** for validating */
130
+ allProcessedStrings = new Set();
131
+ /**
132
+ * Allocate a StrsItem given the string, unescaping if necessary.
133
+ * @param s escaped string
134
+ * @param opts options for allocation
135
+ * @param sections other sections, if needed
136
+ * @returns StrsItem
137
+ */
138
+ allocString(s, opts, sections) {
139
+ // Run the string processing pipeline
140
+ s = Strs.processString(s, opts, sections);
141
+ // add to the set, for testing
142
+ if (s) {
143
+ this.allProcessedStrings.add(s);
144
+ }
145
+ // if it's a single char, don't push it into the strs table
146
+ if (opts?.singleOk && isOneChar(s)) {
147
+ return new CharStrsItem(s);
148
+ }
149
+ // default: look to see if the string is already present
150
+ let result = this.strings.find(item => item.value === s);
151
+ if (result === undefined) {
152
+ // only add if not already present
153
+ result = new StrsItem(s);
154
+ this.strings.push(result);
155
+ }
156
+ return result;
157
+ }
158
+ /** process everything according to opts */
159
+ static processString(s, opts, sections) {
160
+ s = s ?? '';
161
+ // type check everything else
162
+ if (typeof s !== 'string') {
163
+ throw new Error('alloc_string: s must be a string, undefined, or null.');
164
+ }
165
+ // substitute variables
166
+ if (opts?.stringVariables) {
167
+ s = sections.vars.substituteStrings(s, sections);
168
+ }
169
+ // substitute markers
170
+ if (opts?.markers) {
171
+ s = sections.vars.substituteMarkerString(s);
172
+ }
173
+ // unescape \u{…}
174
+ if (opts?.unescape) {
175
+ s = unescapeString(s);
176
+ }
177
+ // nfd
178
+ if (opts?.nfd) {
179
+ if (!sections?.meta?.normalizationDisabled) {
180
+ if (opts?.markers) {
181
+ s = MarkerParser.nfd_markers(s, false);
182
+ }
183
+ else {
184
+ s = s.normalize("NFD");
185
+ }
186
+ }
187
+ }
188
+ return s;
189
+ }
190
+ }
191
+ ;
192
+ /**
193
+ * See LKVariables
194
+ */
195
+ export class Vars extends Section {
196
+ totalCount() {
197
+ return this.strings.length + this.sets.length + this.usets.length;
198
+ }
199
+ markers;
200
+ strings = []; // ≠ StrsItem
201
+ sets = [];
202
+ usets = [];
203
+ /**
204
+ *
205
+ * @returns false if any invalid variables
206
+ */
207
+ valid() {
208
+ for (const t of [this.sets, this.strings, this.usets]) {
209
+ for (const i of t) {
210
+ if (!i.valid()) {
211
+ return false;
212
+ }
213
+ }
214
+ }
215
+ return true;
216
+ }
217
+ // utilities for making use of Vars in other sections
218
+ substituteSets(str, sections) {
219
+ return str.replaceAll(VariableParser.SET_REFERENCE, (_entire, id) => {
220
+ const val = Vars.findVariable(this.sets, id);
221
+ if (val === null) {
222
+ // Should have been caught during validation.
223
+ throw Error(`Internal Error: reference to missing set variable ${id}`);
224
+ }
225
+ return val.value.value;
226
+ });
227
+ }
228
+ substituteUnicodeSets(value, sections) {
229
+ return value.replaceAll(VariableParser.SET_REFERENCE, (_entire, id) => {
230
+ const v = Vars.findVariable(this.usets, id);
231
+ if (v === null) {
232
+ // Should have been caught during validation.
233
+ throw Error(`Internal Error: reference to missing UnicodeSet variable ${id}`);
234
+ }
235
+ return v.value.value; // string value
236
+ });
237
+ }
238
+ substituteStrings(str, sections, forMatch) {
239
+ if (!str)
240
+ return str;
241
+ return str.replaceAll(VariableParser.STRING_REFERENCE, (_entire, id) => {
242
+ const val = this.findStringVariableValue(id);
243
+ if (val === null) {
244
+ // Should have been caught during validation.
245
+ throw Error(`Internal Error: reference to missing string variable ${id}`);
246
+ }
247
+ if (forMatch)
248
+ return escapeStringForRegex(val);
249
+ return val;
250
+ });
251
+ }
252
+ findStringVariableValue(id) {
253
+ return Vars.findVariable(this.strings, id)?.value?.value; // Unwrap: Variable, StrsItem
254
+ }
255
+ substituteSetRegex(str, sections) {
256
+ return str.replaceAll(VariableParser.SET_REFERENCE, (_entire, id) => {
257
+ // try as set
258
+ const set = Vars.findVariable(this.sets, id);
259
+ if (set !== null) {
260
+ const { items } = set;
261
+ const escapedStrings = items.map(v => escapeStringForRegex(v.value.value));
262
+ const inner = escapedStrings.join('|');
263
+ return `(?:${inner})`;
264
+ }
265
+ // try as unicodeset
266
+ const uset = Vars.findVariable(this.usets, id);
267
+ if (uset !== null) {
268
+ const { unicodeSet } = uset;
269
+ const inner = unicodeSet.ranges.map(([start, end]) => {
270
+ const s = String.fromCodePoint(start);
271
+ if (start === end) {
272
+ return s;
273
+ }
274
+ else {
275
+ const e = String.fromCodePoint(end);
276
+ return `${s}-${e}`;
277
+ }
278
+ }).join('');
279
+ return `[${inner}]`;
280
+ }
281
+ // else, missing
282
+ throw Error(`Internal Error: reference to missing set variable ${id}`);
283
+ });
284
+ }
285
+ /**
286
+ * Variable locator facility
287
+ * @param array
288
+ * @param id
289
+ * @returns
290
+ */
291
+ static findVariable(array, id) {
292
+ const v = array.filter(e => e.id.value === id);
293
+ if (v.length === 0) {
294
+ return null;
295
+ }
296
+ else if (v.length !== 1) {
297
+ // Should have been caught during validation
298
+ throw Error(`Internal Error: Duplicate variable id ${id} crept into a variable list.`);
299
+ }
300
+ else {
301
+ return v[0];
302
+ }
303
+ }
304
+ substituteMarkerString(s, forMatch) {
305
+ return MarkerParser.toSentinelString(s, this.markers, forMatch);
306
+ }
307
+ }
308
+ ;
309
+ /**
310
+ * Common base for variable sections
311
+ * See Variable
312
+ */
313
+ export class VarsItem extends Section {
314
+ id;
315
+ value;
316
+ constructor(id, value, sections) {
317
+ super();
318
+ this.id = sections.strs.allocString(id);
319
+ this.value = sections.strs.allocString(value, { unescape: true });
320
+ }
321
+ valid() {
322
+ return true;
323
+ }
324
+ }
325
+ ;
326
+ export class UnicodeSetItem extends VarsItem {
327
+ constructor(id, value, sections, usetparser) {
328
+ super(id, value, sections);
329
+ const needRanges = sections.usetparser.sizeUnicodeSet(value);
330
+ if (needRanges >= 0) {
331
+ this.unicodeSet = sections.usetparser.parseUnicodeSet(value, needRanges);
332
+ } // otherwise: error (was recorded via callback)
333
+ }
334
+ unicodeSet;
335
+ valid() {
336
+ return !!this.unicodeSet;
337
+ }
338
+ }
339
+ ;
340
+ export class SetVarItem extends VarsItem {
341
+ constructor(id, value, sections, rawItems) {
342
+ super(id, value.join(' '), sections);
343
+ this.items = sections.elem.allocElementString(sections, value);
344
+ this.rawItems = rawItems;
345
+ }
346
+ // element string array
347
+ items;
348
+ // like items, but with unprocessed marker strings
349
+ rawItems;
350
+ valid() {
351
+ return !!this.items;
352
+ }
353
+ }
354
+ ;
355
+ export class StringVarItem extends VarsItem {
356
+ constructor(id, value, sections) {
357
+ super(id, value, sections);
358
+ }
359
+ }
360
+ ;
361
+ // 'tran'
362
+ export class TranTransform {
363
+ from;
364
+ to;
365
+ mapFrom; // var name
366
+ mapTo; // var name
367
+ }
368
+ export class TranGroup {
369
+ type; // tran_group_type_transform | tran_group_type_reorder
370
+ transforms = [];
371
+ reorders = [];
372
+ }
373
+ export class TranReorder {
374
+ elements;
375
+ before;
376
+ }
377
+ ;
378
+ export class Tran extends Section {
379
+ groups = [];
380
+ get id() {
381
+ return constants.section.tran;
382
+ }
383
+ }
384
+ ;
385
+ export class UsetItem {
386
+ uset;
387
+ str;
388
+ constructor(uset, str) {
389
+ this.uset = uset;
390
+ this.str = str;
391
+ }
392
+ compareTo(other) {
393
+ return this.str.compareTo(other.str);
394
+ }
395
+ }
396
+ ;
397
+ export class Uset extends Section {
398
+ usets = [];
399
+ allocUset(set, sections) {
400
+ // match the same pattern
401
+ let result = this.usets.find(s => set.pattern == s.uset.pattern);
402
+ if (result === undefined) {
403
+ result = new UsetItem(set, sections.strs.allocString(set.pattern));
404
+ this.usets.push(result);
405
+ }
406
+ return result;
407
+ }
408
+ }
409
+ ;
410
+ // alias type for 'bksp'
411
+ export class Bksp extends Tran {
412
+ get id() {
413
+ return constants.section.bksp;
414
+ }
415
+ }
416
+ ;
417
+ // 'disp'
418
+ export class DispItem {
419
+ to;
420
+ id;
421
+ display;
422
+ }
423
+ ;
424
+ export class Disp extends Section {
425
+ baseCharacter;
426
+ disps = [];
427
+ }
428
+ ;
429
+ // 'layr'
430
+ /**
431
+ * In-memory `<layers>`
432
+ */
433
+ export class LayrList {
434
+ hardware;
435
+ layers = [];
436
+ minDeviceWidth; // millimeters
437
+ }
438
+ ;
439
+ /**
440
+ * In-memory `<layer>`
441
+ */
442
+ export class LayrEntry {
443
+ id;
444
+ mod;
445
+ rows = [];
446
+ }
447
+ ;
448
+ /**
449
+ * In-memory `<row>`
450
+ */
451
+ export class LayrRow {
452
+ keys = [];
453
+ }
454
+ ;
455
+ export class Layr extends Section {
456
+ lists = [];
457
+ }
458
+ ;
459
+ export class KeysKeys {
460
+ flags;
461
+ flicks; // for in-memory only
462
+ id;
463
+ longPress;
464
+ longPressDefault;
465
+ multiTap;
466
+ switch;
467
+ to;
468
+ width;
469
+ }
470
+ ;
471
+ export class KeysKmap {
472
+ vkey;
473
+ mod;
474
+ key; // for in-memory only
475
+ }
476
+ ;
477
+ export class KeysFlicks {
478
+ flicks = [];
479
+ id;
480
+ compareTo(b) {
481
+ return this.id.compareTo(b.id);
482
+ }
483
+ constructor(id) {
484
+ this.id = id;
485
+ }
486
+ }
487
+ ;
488
+ export class KeysFlick {
489
+ directions;
490
+ keyId;
491
+ }
492
+ ;
493
+ export class Keys extends Section {
494
+ keys = [];
495
+ flicks = [];
496
+ kmap = [];
497
+ constructor(strs) {
498
+ super();
499
+ let nullFlicks = new KeysFlicks(strs.allocString(''));
500
+ this.flicks.push(nullFlicks); // C7043: null element string
501
+ }
502
+ }
503
+ ;
504
+ export class List extends Section {
505
+ /**
506
+ * Allocate a list from a space-separated list of items.
507
+ * Note that passing undefined or null or `''` will
508
+ * end up being the same as the empty list `[]`
509
+ * @param s space-separated list of items
510
+ * @param opts string options
511
+ * @param sections sections
512
+ * @returns a List object
513
+ */
514
+ allocListFromSpaces(s, opts, sections) {
515
+ s = s ?? '';
516
+ return this.allocList(s.split(' '), opts, sections);
517
+ }
518
+ /**
519
+ * Return a List object referring to the string list.
520
+ * Note that a falsy list, or a list containing only an empty string
521
+ * `['']` will be stored as an empty list `[]`.
522
+ * @param strs Strs section for allocation
523
+ * @param s string list to allocate
524
+ * @returns
525
+ */
526
+ allocList(s, opts, sections) {
527
+ // Special case the 'null' list for [] or ['']
528
+ if (!s || (s.length === 1 && s[0] === '')) {
529
+ return this.lists[0];
530
+ }
531
+ let result = this.lists.find(item => item.isEqual(s));
532
+ if (result === undefined) {
533
+ // allocate a new ListItem
534
+ result = ListItem.fromStrings(s, opts, sections);
535
+ this.lists.push(result);
536
+ }
537
+ return result;
538
+ }
539
+ constructor(strs) {
540
+ super();
541
+ this.lists.push(ListItem.fromStrings([], {}, { strs })); // C7043: null element string
542
+ }
543
+ lists = [];
544
+ }
545
+ ;
546
+ export { ListItem as ListItem };
547
+ ;
548
+ export class KMXPlusFile extends KMXFile {
549
+ /* KMXPlus file structures */
550
+ COMP_PLUS_SECT_ITEM;
551
+ COMP_PLUS_SECT;
552
+ // COMP_PLUS_BKSP == COMP_PLUS_TRAN
553
+ COMP_PLUS_BKSP_ITEM;
554
+ COMP_PLUS_BKSP;
555
+ COMP_PLUS_DISP_ITEM;
556
+ COMP_PLUS_DISP;
557
+ COMP_PLUS_ELEM_ELEMENT;
558
+ COMP_PLUS_ELEM_STRING;
559
+ COMP_PLUS_ELEM;
560
+ // COMP_PLUS_KEYS is now COMP_PLUS_KEYS_KMAP
561
+ COMP_PLUS_LAYR_ENTRY;
562
+ COMP_PLUS_LAYR_KEY;
563
+ COMP_PLUS_LAYR_LIST;
564
+ COMP_PLUS_LAYR_ROW;
565
+ COMP_PLUS_LAYR;
566
+ COMP_PLUS_KEYS_FLICK;
567
+ COMP_PLUS_KEYS_FLICKS;
568
+ COMP_PLUS_KEYS_KEY;
569
+ COMP_PLUS_KEYS_KMAP;
570
+ COMP_PLUS_KEYS;
571
+ COMP_PLUS_LIST_LIST;
572
+ COMP_PLUS_LIST_INDEX;
573
+ COMP_PLUS_LIST;
574
+ COMP_PLUS_LOCA_ITEM;
575
+ COMP_PLUS_LOCA;
576
+ COMP_PLUS_META;
577
+ COMP_PLUS_STRS_ITEM;
578
+ COMP_PLUS_STRS;
579
+ COMP_PLUS_TRAN_GROUP;
580
+ COMP_PLUS_TRAN_TRANSFORM;
581
+ COMP_PLUS_TRAN_REORDER;
582
+ COMP_PLUS_TRAN;
583
+ COMP_PLUS_USET_USET;
584
+ COMP_PLUS_USET_RANGE;
585
+ COMP_PLUS_USET;
586
+ COMP_PLUS_VKEY_ITEM;
587
+ COMP_PLUS_VKEY;
588
+ COMP_PLUS_VARS;
589
+ COMP_PLUS_VARS_ITEM;
590
+ /* File in-memory data */
591
+ kmxplus = {};
592
+ constructor() {
593
+ super();
594
+ // Binary-correct structures matching kmx_plus.h
595
+ // helpers
596
+ const STR_REF = r.uint32le;
597
+ const ELEM_REF = r.uint32le;
598
+ const LIST_REF = r.uint32le;
599
+ const STR_OR_CHAR32 = r.uint32le;
600
+ const CHAR32 = r.uint32le;
601
+ const STR_OR_CHAR32_OR_USET = r.uint32le;
602
+ const IDENT = r.uint32le;
603
+ // 'sect'
604
+ this.COMP_PLUS_SECT_ITEM = new r.Struct({
605
+ sect: r.uint32le,
606
+ offset: r.uint32le //? new r.VoidPointer(r.uint32le, {type: 'global'})
607
+ });
608
+ this.COMP_PLUS_SECT = new r.Struct({
609
+ ident: IDENT,
610
+ size: r.uint32le,
611
+ total: r.uint32le,
612
+ count: r.uint32le,
613
+ items: new r.Array(this.COMP_PLUS_SECT_ITEM, 'count')
614
+ });
615
+ // 'bksp' - see 'tran'
616
+ // 'disp'
617
+ this.COMP_PLUS_DISP_ITEM = new r.Struct({
618
+ to: STR_REF,
619
+ id: STR_REF,
620
+ display: STR_REF,
621
+ });
622
+ this.COMP_PLUS_DISP = new r.Struct({
623
+ ident: IDENT,
624
+ size: r.uint32le,
625
+ count: r.uint32le,
626
+ baseCharacter: CHAR32,
627
+ items: new r.Array(this.COMP_PLUS_DISP_ITEM, 'count'),
628
+ });
629
+ // 'elem'
630
+ this.COMP_PLUS_ELEM_ELEMENT = new r.Struct({
631
+ element: STR_OR_CHAR32_OR_USET,
632
+ flags: r.uint32le
633
+ });
634
+ this.COMP_PLUS_ELEM_STRING = new r.Struct({
635
+ offset: r.uint32le,
636
+ length: r.uint32le
637
+ });
638
+ this.COMP_PLUS_ELEM = new r.Struct({
639
+ ident: IDENT,
640
+ size: r.uint32le,
641
+ count: r.uint32le,
642
+ strings: new r.Array(this.COMP_PLUS_ELEM_STRING, 'count')
643
+ // + variable subtable: Element data (see KMXPlusBuilder.emitElements())
644
+ });
645
+ // 'finl' - see 'tran'
646
+ // 'keys' - see 'keys.kmap'
647
+ // 'layr'
648
+ this.COMP_PLUS_LAYR_ENTRY = new r.Struct({
649
+ id: r.uint32le, // str
650
+ mod: r.uint32le, // bitfield
651
+ row: r.uint32le, // index into rows
652
+ count: r.uint32le,
653
+ });
654
+ this.COMP_PLUS_LAYR_KEY = new r.Struct({
655
+ key: r.uint32le, // str: key id
656
+ });
657
+ this.COMP_PLUS_LAYR_LIST = new r.Struct({
658
+ hardware: STR_REF, // str: hardware name
659
+ layer: r.uint32le, // index into layers
660
+ count: r.uint32le,
661
+ minDeviceWidth: r.uint32le, // integer: millimeters
662
+ });
663
+ this.COMP_PLUS_LAYR_ROW = new r.Struct({
664
+ key: r.uint32le,
665
+ count: r.uint32le,
666
+ });
667
+ this.COMP_PLUS_LAYR = new r.Struct({
668
+ ident: IDENT,
669
+ size: r.uint32le,
670
+ listCount: r.uint32le,
671
+ layerCount: r.uint32le,
672
+ rowCount: r.uint32le,
673
+ keyCount: r.uint32le,
674
+ lists: new r.Array(this.COMP_PLUS_LAYR_LIST, 'listCount'),
675
+ layers: new r.Array(this.COMP_PLUS_LAYR_ENTRY, 'layerCount'),
676
+ rows: new r.Array(this.COMP_PLUS_LAYR_ROW, 'rowCount'),
677
+ keys: new r.Array(this.COMP_PLUS_LAYR_KEY, 'keyCount'),
678
+ });
679
+ this.COMP_PLUS_KEYS_FLICK = new r.Struct({
680
+ directions: LIST_REF, // list
681
+ to: STR_OR_CHAR32, // str | codepoint
682
+ });
683
+ this.COMP_PLUS_KEYS_FLICKS = new r.Struct({
684
+ count: r.uint32le,
685
+ flick: r.uint32le,
686
+ id: STR_REF, // str
687
+ });
688
+ this.COMP_PLUS_KEYS_KEY = new r.Struct({
689
+ to: STR_OR_CHAR32, // str | codepoint
690
+ flags: r.uint32le,
691
+ id: STR_REF, // str
692
+ switch: STR_REF, // str
693
+ width: r.uint32le, // width*10 ( 1 = 0.1 keys)
694
+ longPress: LIST_REF, // list index
695
+ longPressDefault: STR_REF, // str
696
+ multiTap: LIST_REF, // list index
697
+ flicks: r.uint32le, // index into flicks table
698
+ });
699
+ this.COMP_PLUS_KEYS_KMAP = new r.Struct({
700
+ vkey: r.uint32le,
701
+ mod: r.uint32le,
702
+ key: r.uint32le, // index into 'keys' subtable
703
+ });
704
+ this.COMP_PLUS_KEYS = new r.Struct({
705
+ ident: IDENT,
706
+ size: r.uint32le,
707
+ keyCount: r.uint32le,
708
+ flicksCount: r.uint32le,
709
+ flickCount: r.uint32le,
710
+ kmapCount: r.uint32le,
711
+ keys: new r.Array(this.COMP_PLUS_KEYS_KEY, 'keyCount'),
712
+ flicks: new r.Array(this.COMP_PLUS_KEYS_FLICKS, 'flicksCount'),
713
+ flick: new r.Array(this.COMP_PLUS_KEYS_FLICK, 'flickCount'),
714
+ kmap: new r.Array(this.COMP_PLUS_KEYS_KMAP, 'kmapCount'),
715
+ });
716
+ // 'list'
717
+ this.COMP_PLUS_LIST_LIST = new r.Struct({
718
+ index: r.uint32le,
719
+ count: r.uint32le,
720
+ });
721
+ this.COMP_PLUS_LIST_INDEX = new r.Struct({
722
+ str: STR_REF, // str
723
+ });
724
+ this.COMP_PLUS_LIST = new r.Struct({
725
+ ident: IDENT,
726
+ size: r.uint32le,
727
+ listCount: r.uint32le,
728
+ indexCount: r.uint32le,
729
+ lists: new r.Array(this.COMP_PLUS_LIST_LIST, 'listCount'),
730
+ indices: new r.Array(this.COMP_PLUS_LIST_INDEX, 'indexCount'),
731
+ });
732
+ // 'loca'
733
+ this.COMP_PLUS_LOCA_ITEM = r.uint32le; //str
734
+ this.COMP_PLUS_LOCA = new r.Struct({
735
+ ident: IDENT,
736
+ size: r.uint32le,
737
+ count: r.uint32le,
738
+ items: new r.Array(this.COMP_PLUS_LOCA_ITEM, 'count')
739
+ });
740
+ // 'meta'
741
+ this.COMP_PLUS_META = new r.Struct({
742
+ ident: IDENT,
743
+ size: r.uint32le,
744
+ author: STR_REF, //str
745
+ conform: STR_REF, //str
746
+ layout: STR_REF, //str
747
+ name: STR_REF, //str
748
+ indicator: STR_REF, //str
749
+ version: STR_REF, //str
750
+ settings: r.uint32le, //new r.Bitfield(r.uint32le, ['normalizationDisabled'])
751
+ });
752
+ // 'name' is gone
753
+ // 'ordr' now part of 'tran'
754
+ // 'strs'
755
+ this.COMP_PLUS_STRS_ITEM = new r.Struct({
756
+ // While we use length which is number of utf-16 code units excluding null terminator,
757
+ // we always write a null terminator, so we can get restructure to do that for us here
758
+ offset: r.uint32le, //? new r.Pointer(r.uint32le, new r.String(null, 'utf16le')),
759
+ length: r.uint32le
760
+ });
761
+ this.COMP_PLUS_STRS = new r.Struct({
762
+ ident: IDENT,
763
+ size: r.uint32le,
764
+ count: r.uint32le,
765
+ items: new r.Array(this.COMP_PLUS_STRS_ITEM, 'count')
766
+ // + variable subtable: String data (see KMXPlusBuilder.emitStrings())
767
+ });
768
+ // 'tran'
769
+ this.COMP_PLUS_TRAN_GROUP = new r.Struct({
770
+ type: r.uint32le, //type of group
771
+ count: r.uint32le, //number of items
772
+ index: r.uint32le, //index into subtable
773
+ });
774
+ this.COMP_PLUS_TRAN_TRANSFORM = new r.Struct({
775
+ from: STR_REF, //str
776
+ to: STR_REF, //str
777
+ mapFrom: ELEM_REF, //elem
778
+ mapTo: ELEM_REF //elem
779
+ });
780
+ this.COMP_PLUS_TRAN_REORDER = new r.Struct({
781
+ elements: ELEM_REF, //elem
782
+ before: ELEM_REF, //elem
783
+ });
784
+ this.COMP_PLUS_TRAN = new r.Struct({
785
+ ident: IDENT,
786
+ size: r.uint32le,
787
+ groupCount: r.uint32le,
788
+ transformCount: r.uint32le,
789
+ reorderCount: r.uint32le,
790
+ groups: new r.Array(this.COMP_PLUS_TRAN_GROUP, 'groupCount'),
791
+ transforms: new r.Array(this.COMP_PLUS_TRAN_TRANSFORM, 'transformCount'),
792
+ reorders: new r.Array(this.COMP_PLUS_TRAN_REORDER, 'reorderCount'),
793
+ });
794
+ // 'uset'
795
+ this.COMP_PLUS_USET_USET = new r.Struct({
796
+ range: r.uint32le,
797
+ count: r.uint32le,
798
+ pattern: STR_REF, // str
799
+ });
800
+ this.COMP_PLUS_USET_RANGE = new r.Struct({
801
+ start: CHAR32,
802
+ end: CHAR32,
803
+ });
804
+ this.COMP_PLUS_USET = new r.Struct({
805
+ ident: IDENT,
806
+ size: r.uint32le,
807
+ usetCount: r.uint32le,
808
+ rangeCount: r.uint32le,
809
+ usets: new r.Array(this.COMP_PLUS_USET_USET, 'usetCount'),
810
+ ranges: new r.Array(this.COMP_PLUS_USET_RANGE, 'rangeCount'),
811
+ });
812
+ // 'vars'
813
+ this.COMP_PLUS_VARS_ITEM = new r.Struct({
814
+ type: r.uint32le,
815
+ id: STR_REF, // str
816
+ value: STR_REF, // str
817
+ elem: ELEM_REF,
818
+ });
819
+ this.COMP_PLUS_VARS = new r.Struct({
820
+ ident: IDENT,
821
+ size: r.uint32le,
822
+ markers: LIST_REF,
823
+ varCount: r.uint32le,
824
+ varEntries: new r.Array(this.COMP_PLUS_VARS_ITEM, 'varCount'),
825
+ });
826
+ // 'vkey' is removed
827
+ // Aliases
828
+ this.COMP_PLUS_BKSP = this.COMP_PLUS_TRAN;
829
+ }
830
+ }
831
831
  //# sourceMappingURL=kmx-plus.js.map
832
- //# debugId=13f36df0-a89d-554b-8fe1-c2f2e8d02022
832
+ //# debugId=462c24ab-41a5-5a83-a6f2-7a5b4b280d08