@keymanapp/common-types 17.0.155-alpha → 17.0.157-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 +144 -138
- package/build/src/consts/virtual-key-constants.d.ts.map +1 -1
- package/build/src/consts/virtual-key-constants.js +258 -252
- package/build/src/consts/virtual-key-constants.js.map +1 -1
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts +8 -7
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts.map +1 -1
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js +76 -74
- 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 +31 -24
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts.map +1 -1
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js +119 -75
- 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 +78 -76
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts.map +1 -1
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.js +28 -26
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.js.map +1 -1
- package/build/src/kmx/element-string.d.ts +26 -24
- package/build/src/kmx/element-string.d.ts.map +1 -1
- package/build/src/kmx/element-string.js +121 -119
- package/build/src/kmx/element-string.js.map +1 -1
- package/build/src/kmx/keyman-targets.d.ts +23 -0
- package/build/src/kmx/keyman-targets.d.ts.map +1 -0
- package/build/src/kmx/keyman-targets.js +80 -0
- package/build/src/kmx/keyman-targets.js.map +1 -0
- package/build/src/kmx/kmx-builder.d.ts +35 -33
- package/build/src/kmx/kmx-builder.d.ts.map +1 -1
- package/build/src/kmx/kmx-builder.js +190 -188
- package/build/src/kmx/kmx-builder.js.map +1 -1
- package/build/src/kmx/kmx-file-reader.d.ts +16 -7
- package/build/src/kmx/kmx-file-reader.d.ts.map +1 -1
- package/build/src/kmx/kmx-file-reader.js +135 -38
- package/build/src/kmx/kmx-file-reader.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-disp.d.ts +20 -18
- package/build/src/kmx/kmx-plus-builder/build-disp.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-disp.js +27 -25
- package/build/src/kmx/kmx-plus-builder/build-disp.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-elem.d.ts +31 -29
- package/build/src/kmx/kmx-plus-builder/build-elem.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-elem.js +90 -88
- package/build/src/kmx/kmx-plus-builder/build-elem.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-keys.d.ts +60 -58
- package/build/src/kmx/kmx-plus-builder/build-keys.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-keys.js +109 -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 +56 -54
- package/build/src/kmx/kmx-plus-builder/build-layr.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-layr.js +101 -99
- package/build/src/kmx/kmx-plus-builder/build-layr.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-list.d.ts +38 -36
- package/build/src/kmx/kmx-plus-builder/build-list.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-list.js +67 -65
- package/build/src/kmx/kmx-plus-builder/build-list.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-loca.d.ts +14 -12
- package/build/src/kmx/kmx-plus-builder/build-loca.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-loca.js +22 -20
- package/build/src/kmx/kmx-plus-builder/build-loca.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-meta.d.ts +19 -17
- package/build/src/kmx/kmx-plus-builder/build-meta.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-meta.js +23 -21
- package/build/src/kmx/kmx-plus-builder/build-meta.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-name.d.ts +14 -12
- package/build/src/kmx/kmx-plus-builder/build-name.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-name.js +25 -23
- package/build/src/kmx/kmx-plus-builder/build-name.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-sect.d.ts +18 -16
- package/build/src/kmx/kmx-plus-builder/build-sect.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-sect.js +16 -14
- package/build/src/kmx/kmx-plus-builder/build-sect.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-strs.d.ts +25 -23
- package/build/src/kmx/kmx-plus-builder/build-strs.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-strs.js +47 -45
- package/build/src/kmx/kmx-plus-builder/build-strs.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-tran.d.ts +35 -33
- package/build/src/kmx/kmx-plus-builder/build-tran.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-tran.js +70 -68
- package/build/src/kmx/kmx-plus-builder/build-tran.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-uset.d.ts +33 -31
- package/build/src/kmx/kmx-plus-builder/build-uset.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-uset.js +61 -59
- package/build/src/kmx/kmx-plus-builder/build-uset.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-vars.d.ts +24 -22
- package/build/src/kmx/kmx-plus-builder/build-vars.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-vars.js +49 -47
- package/build/src/kmx/kmx-plus-builder/build-vars.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-vkey.d.ts +18 -16
- package/build/src/kmx/kmx-plus-builder/build-vkey.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-vkey.js +25 -23
- package/build/src/kmx/kmx-plus-builder/build-vkey.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/builder-section.d.ts +12 -10
- package/build/src/kmx/kmx-plus-builder/builder-section.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/builder-section.js +5 -3
- package/build/src/kmx/kmx-plus-builder/builder-section.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts +49 -47
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js +146 -144
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js.map +1 -1
- package/build/src/kmx/kmx-plus.d.ts +331 -329
- package/build/src/kmx/kmx-plus.d.ts.map +1 -1
- package/build/src/kmx/kmx-plus.js +835 -833
- package/build/src/kmx/kmx-plus.js.map +1 -1
- package/build/src/kmx/kmx.d.ts +235 -209
- package/build/src/kmx/kmx.d.ts.map +1 -1
- package/build/src/kmx/kmx.js +299 -276
- package/build/src/kmx/kmx.js.map +1 -1
- package/build/src/kmx/string-list.d.ts +36 -34
- package/build/src/kmx/string-list.d.ts.map +1 -1
- package/build/src/kmx/string-list.js +85 -83
- package/build/src/kmx/string-list.js.map +1 -1
- package/build/src/kpj/keyman-developer-project.d.ts +74 -63
- package/build/src/kpj/keyman-developer-project.d.ts.map +1 -1
- package/build/src/kpj/keyman-developer-project.js +165 -146
- package/build/src/kpj/keyman-developer-project.js.map +1 -1
- package/build/src/kpj/kpj-file-reader.d.ts +21 -19
- package/build/src/kpj/kpj-file-reader.d.ts.map +1 -1
- package/build/src/kpj/kpj-file-reader.js +110 -96
- package/build/src/kpj/kpj-file-reader.js.map +1 -1
- package/build/src/kpj/kpj-file.d.ts +41 -39
- package/build/src/kpj/kpj-file.d.ts.map +1 -1
- package/build/src/kpj/kpj-file.js +13 -11
- package/build/src/kpj/kpj-file.js.map +1 -1
- package/build/src/kvk/kvk-file-reader.d.ts +7 -5
- package/build/src/kvk/kvk-file-reader.d.ts.map +1 -1
- package/build/src/kvk/kvk-file-reader.js +38 -35
- package/build/src/kvk/kvk-file-reader.js.map +1 -1
- package/build/src/kvk/kvk-file-writer.d.ts +22 -20
- package/build/src/kvk/kvk-file-writer.d.ts.map +1 -1
- package/build/src/kvk/kvk-file-writer.js +78 -67
- package/build/src/kvk/kvk-file-writer.js.map +1 -1
- package/build/src/kvk/kvk-file.d.ts +68 -65
- package/build/src/kvk/kvk-file.d.ts.map +1 -1
- package/build/src/kvk/kvk-file.js +67 -64
- package/build/src/kvk/kvk-file.js.map +1 -1
- package/build/src/kvk/kvks-file-reader.d.ts +26 -23
- package/build/src/kvk/kvks-file-reader.d.ts.map +1 -1
- package/build/src/kvk/kvks-file-reader.js +179 -151
- package/build/src/kvk/kvks-file-reader.js.map +1 -1
- package/build/src/kvk/kvks-file-writer.d.ts +9 -6
- package/build/src/kvk/kvks-file-writer.d.ts.map +1 -1
- package/build/src/kvk/kvks-file-writer.js +107 -98
- package/build/src/kvk/kvks-file-writer.js.map +1 -1
- package/build/src/kvk/kvks-file.d.ts +46 -44
- package/build/src/kvk/kvks-file.d.ts.map +1 -1
- package/build/src/kvk/kvks-file.js +12 -10
- package/build/src/kvk/kvks-file.js.map +1 -1
- package/build/src/kvk/visual-keyboard.d.ts +47 -35
- package/build/src/kvk/visual-keyboard.d.ts.map +1 -1
- package/build/src/kvk/visual-keyboard.js +73 -61
- package/build/src/kvk/visual-keyboard.js.map +1 -1
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts +58 -56
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts.map +1 -1
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js +22 -20
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js.map +1 -1
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts +97 -95
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts.map +1 -1
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js +387 -385
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js.map +1 -1
- package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts +163 -161
- package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts.map +1 -1
- package/build/src/ldml-keyboard/ldml-keyboard-xml.js +41 -39
- package/build/src/ldml-keyboard/ldml-keyboard-xml.js.map +1 -1
- package/build/src/ldml-keyboard/pattern-parser.d.ts +138 -136
- package/build/src/ldml-keyboard/pattern-parser.d.ts.map +1 -1
- package/build/src/ldml-keyboard/pattern-parser.js +245 -243
- package/build/src/ldml-keyboard/pattern-parser.js.map +1 -1
- package/build/src/ldml-keyboard/unicodeset-parser-api.d.ts +40 -38
- package/build/src/ldml-keyboard/unicodeset-parser-api.d.ts.map +1 -1
- package/build/src/ldml-keyboard/unicodeset-parser-api.js +30 -28
- package/build/src/ldml-keyboard/unicodeset-parser-api.js.map +1 -1
- package/build/src/main.d.ts +36 -29
- package/build/src/main.d.ts.map +1 -1
- package/build/src/main.js +35 -28
- package/build/src/main.js.map +1 -1
- package/build/src/osk/osk.d.ts +25 -0
- package/build/src/osk/osk.d.ts.map +1 -0
- package/build/src/osk/osk.js +89 -0
- package/build/src/osk/osk.js.map +1 -0
- package/build/src/package/kmp-json-file.d.ts +69 -68
- package/build/src/package/kmp-json-file.d.ts.map +1 -1
- package/build/src/package/kmp-json-file.js +4 -2
- package/build/src/package/kmp-json-file.js.map +1 -1
- package/build/src/package/kps-file.d.ts +100 -98
- package/build/src/package/kps-file.d.ts.map +1 -1
- package/build/src/package/kps-file.js +18 -16
- package/build/src/package/kps-file.js.map +1 -1
- package/build/src/schemas/displaymap.schema.d.ts +60 -0
- package/build/src/schemas/displaymap.schema.d.ts.map +1 -0
- package/build/src/schemas/displaymap.schema.js +38 -0
- package/build/src/schemas/displaymap.schema.js.map +1 -0
- package/build/src/schemas/keyman-touch-layout.clean.spec.d.ts +230 -0
- package/build/src/schemas/keyman-touch-layout.clean.spec.d.ts.map +1 -0
- package/build/src/schemas/keyman-touch-layout.clean.spec.js +154 -0
- package/build/src/schemas/keyman-touch-layout.clean.spec.js.map +1 -0
- package/build/src/schemas/keyman-touch-layout.spec.d.ts +229 -0
- package/build/src/schemas/keyman-touch-layout.spec.d.ts.map +1 -0
- package/build/src/schemas/keyman-touch-layout.spec.js +142 -0
- package/build/src/schemas/keyman-touch-layout.spec.js.map +1 -0
- package/build/src/schemas/kpj-9.0.schema.d.ts +155 -0
- package/build/src/schemas/kpj-9.0.schema.d.ts.map +1 -0
- package/build/src/schemas/kpj-9.0.schema.js +134 -0
- package/build/src/schemas/kpj-9.0.schema.js.map +1 -0
- package/build/src/schemas/kpj.schema.d.ts +121 -0
- package/build/src/schemas/kpj.schema.d.ts.map +1 -0
- package/build/src/schemas/kpj.schema.js +128 -0
- package/build/src/schemas/kpj.schema.js.map +1 -0
- package/build/src/schemas/kvks.schema.d.ts +163 -0
- package/build/src/schemas/kvks.schema.d.ts.map +1 -0
- package/build/src/schemas/kvks.schema.js +185 -0
- package/build/src/schemas/kvks.schema.js.map +1 -0
- package/build/src/schemas/ldml-keyboard.schema.d.ts +634 -0
- package/build/src/schemas/ldml-keyboard.schema.d.ts.map +1 -0
- package/build/src/schemas/ldml-keyboard.schema.js +705 -0
- package/build/src/schemas/ldml-keyboard.schema.js.map +1 -0
- package/build/src/schemas/ldml-keyboardtest.schema.d.ts +191 -0
- package/build/src/schemas/ldml-keyboardtest.schema.d.ts.map +1 -0
- package/build/src/schemas/ldml-keyboardtest.schema.js +224 -0
- package/build/src/schemas/ldml-keyboardtest.schema.js.map +1 -0
- package/build/src/schemas.d.ts +1757 -0
- package/build/src/schemas.d.ts.map +1 -0
- package/build/src/schemas.js +22 -0
- package/build/src/schemas.js.map +1 -0
- package/build/src/util/common-events.d.ts +51 -49
- package/build/src/util/common-events.d.ts.map +1 -1
- package/build/src/util/common-events.js +31 -29
- package/build/src/util/common-events.js.map +1 -1
- package/build/src/util/compiler-interfaces.d.ts +296 -136
- package/build/src/util/compiler-interfaces.d.ts.map +1 -1
- package/build/src/util/compiler-interfaces.js +294 -104
- package/build/src/util/compiler-interfaces.js.map +1 -1
- package/build/src/util/errors.d.ts +8 -0
- package/build/src/util/errors.d.ts.map +1 -0
- package/build/src/util/errors.js +8 -0
- package/build/src/util/errors.js.map +1 -0
- package/build/src/util/file-types.d.ts +98 -0
- package/build/src/util/file-types.d.ts.map +1 -0
- package/build/src/util/file-types.js +117 -0
- package/build/src/util/file-types.js.map +1 -0
- package/build/src/util/util.d.ts +32 -30
- package/build/src/util/util.d.ts.map +1 -1
- package/build/src/util/util.js +98 -96
- package/build/src/util/util.js.map +1 -1
- package/package.json +23 -4
- package/build/src/keyman-touch-layout.clean.spec.json +0 -170
- package/build/src/kpj.schema.json +0 -127
- package/build/src/kvks.schema.json +0 -182
- package/build/src/ldml-keyboard.schema.json +0 -702
- package/build/src/ldml-keyboardtest.schema.json +0 -221
|
@@ -1,188 +1,190 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.comp_header.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.comp_header.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
[comp_group.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
[comp_key.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
size += this.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
//
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
file.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
file.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.setString(file, group.obj.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
this.setString(file, key.obj.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
1
|
+
!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]="6f1d5f72-d546-577e-9ae0-75d5a165027a")}catch(e){}}();
|
|
2
|
+
import * as r from 'restructure';
|
|
3
|
+
import { KMXFile } from './kmx.js';
|
|
4
|
+
import { KMXPlusFile } from './kmx-plus.js';
|
|
5
|
+
import KMXPlusBuilder from './kmx-plus-builder/kmx-plus-builder.js';
|
|
6
|
+
export default class KMXBuilder {
|
|
7
|
+
file;
|
|
8
|
+
base_keyboard = 0;
|
|
9
|
+
base_kmxplus = 0;
|
|
10
|
+
comp_header;
|
|
11
|
+
comp_kmxplus;
|
|
12
|
+
comp_stores = [];
|
|
13
|
+
comp_groups = [];
|
|
14
|
+
comp_kmxplus_data;
|
|
15
|
+
writeDebug = false;
|
|
16
|
+
constructor(file, writeDebug) {
|
|
17
|
+
this.file = file;
|
|
18
|
+
this.writeDebug = writeDebug;
|
|
19
|
+
}
|
|
20
|
+
calculateStringOffsetAndSize(string, base, requireString = false) {
|
|
21
|
+
if (string.length == 0 && !requireString) {
|
|
22
|
+
// Zero length strings take up no space in the file, and
|
|
23
|
+
// are treated as a 'null string'
|
|
24
|
+
return [0, base];
|
|
25
|
+
}
|
|
26
|
+
return [base, base + string.length * 2 + 2]; // include trailing zero
|
|
27
|
+
}
|
|
28
|
+
build() {
|
|
29
|
+
this.base_keyboard = 0;
|
|
30
|
+
this.base_kmxplus = 0;
|
|
31
|
+
// Header
|
|
32
|
+
this.comp_header = {
|
|
33
|
+
dwIdentifier: KMXFile.FILEID_COMPILED,
|
|
34
|
+
dwFileVersion: KMXFile.VERSION_160,
|
|
35
|
+
dwCheckSum: 0,
|
|
36
|
+
KeyboardID: 0,
|
|
37
|
+
IsRegistered: 1,
|
|
38
|
+
version: 0,
|
|
39
|
+
cxStoreArray: 0,
|
|
40
|
+
cxGroupArray: 0,
|
|
41
|
+
dpStoreArray: 0,
|
|
42
|
+
dpGroupArray: 0,
|
|
43
|
+
StartGroup_ANSI: 0xFFFFFFFF,
|
|
44
|
+
StartGroup_Unicode: 0xFFFFFFFF,
|
|
45
|
+
dwFlags: 0,
|
|
46
|
+
dwHotKey: 0,
|
|
47
|
+
dpBitmapOffset: 0,
|
|
48
|
+
dwBitmapSize: 0
|
|
49
|
+
};
|
|
50
|
+
let size = KMXFile.COMP_KEYBOARD_SIZE;
|
|
51
|
+
if (this.file instanceof KMXPlusFile) {
|
|
52
|
+
// Reserve space for KMXPlus header; we'll come back and fill in details
|
|
53
|
+
// once we know base kmx file size.
|
|
54
|
+
this.comp_header.dwFlags |= KMXFile.KF_KMXPLUS;
|
|
55
|
+
this.base_kmxplus = size;
|
|
56
|
+
size += KMXFile.COMP_KEYBOARD_KMXPLUSINFO_SIZE;
|
|
57
|
+
}
|
|
58
|
+
// Stores
|
|
59
|
+
this.comp_header.cxStoreArray = this.file.keyboard.stores.length;
|
|
60
|
+
this.comp_header.dpStoreArray = this.comp_header.cxStoreArray ? size : 0;
|
|
61
|
+
let storeBase = size;
|
|
62
|
+
size += this.file.keyboard.stores.length * KMXFile.COMP_STORE_SIZE;
|
|
63
|
+
for (let store of this.file.keyboard.stores) {
|
|
64
|
+
let comp_store = {
|
|
65
|
+
dwSystemID: store.dwSystemID,
|
|
66
|
+
dpName: 0,
|
|
67
|
+
dpString: 0
|
|
68
|
+
};
|
|
69
|
+
this.comp_stores.push({ base: storeBase, store: store, obj: comp_store });
|
|
70
|
+
if (this.writeDebug /*TODO: || store.isOption*/) {
|
|
71
|
+
[comp_store.dpName, size] = this.calculateStringOffsetAndSize(store.dpName, size);
|
|
72
|
+
}
|
|
73
|
+
[comp_store.dpString, size] = this.calculateStringOffsetAndSize(store.dpString, size);
|
|
74
|
+
storeBase += KMXFile.COMP_STORE_SIZE;
|
|
75
|
+
}
|
|
76
|
+
// Groups
|
|
77
|
+
this.comp_header.cxGroupArray = this.file.keyboard.groups.length;
|
|
78
|
+
this.comp_header.dpGroupArray = this.comp_header.cxGroupArray ? size : 0;
|
|
79
|
+
let groupBase = size;
|
|
80
|
+
size += this.file.keyboard.groups.length * KMXFile.COMP_GROUP_SIZE;
|
|
81
|
+
for (let group of this.file.keyboard.groups) {
|
|
82
|
+
let comp_group = {
|
|
83
|
+
dpName: 0,
|
|
84
|
+
dpKeyArray: 0,
|
|
85
|
+
dpMatch: 0,
|
|
86
|
+
dpNoMatch: 0,
|
|
87
|
+
cxKeyArray: group.keys.length,
|
|
88
|
+
fUsingKeys: group.fUsingKeys ? 1 : 0
|
|
89
|
+
};
|
|
90
|
+
let comp_keys = [];
|
|
91
|
+
this.comp_groups.push({ base: groupBase, group: group, obj: comp_group, keys: comp_keys });
|
|
92
|
+
if (this.writeDebug) {
|
|
93
|
+
[comp_group.dpName, size] = this.calculateStringOffsetAndSize(group.dpName, size);
|
|
94
|
+
}
|
|
95
|
+
[comp_group.dpMatch, size] = this.calculateStringOffsetAndSize(group.dpMatch, size);
|
|
96
|
+
[comp_group.dpNoMatch, size] = this.calculateStringOffsetAndSize(group.dpNoMatch, size);
|
|
97
|
+
// Keys within a group
|
|
98
|
+
comp_group.dpKeyArray = group.keys.length ? size : 0;
|
|
99
|
+
let keyBase = size;
|
|
100
|
+
size += group.keys.length * KMXFile.COMP_KEY_SIZE;
|
|
101
|
+
for (let key of group.keys) {
|
|
102
|
+
let comp_key = {
|
|
103
|
+
Key: key.Key,
|
|
104
|
+
_padding: 0,
|
|
105
|
+
Line: key.Line,
|
|
106
|
+
ShiftFlags: key.ShiftFlags,
|
|
107
|
+
dpOutput: 0,
|
|
108
|
+
dpContext: 0
|
|
109
|
+
};
|
|
110
|
+
comp_keys.push({ base: keyBase, key: key, obj: comp_key });
|
|
111
|
+
[comp_key.dpOutput, size] = this.calculateStringOffsetAndSize(key.dpOutput, size, true);
|
|
112
|
+
[comp_key.dpContext, size] = this.calculateStringOffsetAndSize(key.dpContext, size, true);
|
|
113
|
+
keyBase += KMXFile.COMP_KEY_SIZE;
|
|
114
|
+
}
|
|
115
|
+
groupBase += KMXFile.COMP_GROUP_SIZE;
|
|
116
|
+
}
|
|
117
|
+
size += this.buildBitmap();
|
|
118
|
+
size += this.buildKMXPlus(size);
|
|
119
|
+
return size;
|
|
120
|
+
}
|
|
121
|
+
buildBitmap() {
|
|
122
|
+
// TODO
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
buildKMXPlus(base) {
|
|
126
|
+
if (!(this.file instanceof KMXPlusFile)) {
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
const plusbuilder = new KMXPlusBuilder(this.file, this.writeDebug);
|
|
130
|
+
this.comp_kmxplus_data = plusbuilder.compile();
|
|
131
|
+
this.comp_kmxplus = {
|
|
132
|
+
dpKMXPlus: base,
|
|
133
|
+
dwKMXPlusSize: this.comp_kmxplus_data.length
|
|
134
|
+
};
|
|
135
|
+
return this.comp_kmxplus.dwKMXPlusSize;
|
|
136
|
+
}
|
|
137
|
+
setString(file, pos, str, requireString = false) {
|
|
138
|
+
if (requireString && !str.length) {
|
|
139
|
+
// Just write zero terminator, as r.String for a zero-length string
|
|
140
|
+
// seems to fail.
|
|
141
|
+
let sbuf = r.uint16le;
|
|
142
|
+
file.set(sbuf.toBuffer(0), pos);
|
|
143
|
+
}
|
|
144
|
+
else if (pos && str.length) {
|
|
145
|
+
let sbuf = new r.String(null, 'utf16le'); // null-terminated string
|
|
146
|
+
file.set(sbuf.toBuffer(str), pos);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
compile() {
|
|
150
|
+
const fileSize = this.build();
|
|
151
|
+
let file = new Uint8Array(fileSize);
|
|
152
|
+
// Write headers
|
|
153
|
+
const header = this.file.COMP_KEYBOARD.toBuffer(this.comp_header);
|
|
154
|
+
file.set(header, this.base_keyboard);
|
|
155
|
+
if (this.file instanceof KMXPlusFile) {
|
|
156
|
+
const kmxplus = this.file.COMP_KEYBOARD_KMXPLUSINFO.toBuffer(this.comp_kmxplus);
|
|
157
|
+
file.set(kmxplus, this.base_kmxplus);
|
|
158
|
+
}
|
|
159
|
+
// Write store array and data
|
|
160
|
+
for (let store of this.comp_stores) {
|
|
161
|
+
file.set(this.file.COMP_STORE.toBuffer(store.obj), store.base);
|
|
162
|
+
if (this.writeDebug) {
|
|
163
|
+
this.setString(file, store.obj.dpName, store.store.dpName);
|
|
164
|
+
}
|
|
165
|
+
this.setString(file, store.obj.dpString, store.store.dpString);
|
|
166
|
+
}
|
|
167
|
+
// Write group array and data
|
|
168
|
+
for (let group of this.comp_groups) {
|
|
169
|
+
file.set(this.file.COMP_GROUP.toBuffer(group.obj), group.base);
|
|
170
|
+
if (this.writeDebug) {
|
|
171
|
+
this.setString(file, group.obj.dpName, group.group.dpName);
|
|
172
|
+
}
|
|
173
|
+
this.setString(file, group.obj.dpMatch, group.group.dpMatch);
|
|
174
|
+
this.setString(file, group.obj.dpNoMatch, group.group.dpNoMatch);
|
|
175
|
+
for (let key of group.keys) {
|
|
176
|
+
file.set(this.file.COMP_KEY.toBuffer(key.obj), key.base);
|
|
177
|
+
// for back-compat reasons, these are never NULL strings
|
|
178
|
+
this.setString(file, key.obj.dpContext, key.key.dpContext, true);
|
|
179
|
+
this.setString(file, key.obj.dpOutput, key.key.dpOutput, true);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Write KMXPlus data stream
|
|
183
|
+
if (this.file instanceof KMXPlusFile) {
|
|
184
|
+
file.set(this.comp_kmxplus_data, this.comp_kmxplus.dpKMXPlus);
|
|
185
|
+
}
|
|
186
|
+
return file;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//# debugId=6f1d5f72-d546-577e-9ae0-75d5a165027a
|
|
190
|
+
//# sourceMappingURL=kmx-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"6f1d5f72-d546-577e-9ae0-75d5a165027a","file":"kmx-builder.js","mappings":";AAAA,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,OAAO,EAAyI,MAAM,UAAU,CAAC;AAC1K,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,cAAc,MAAM,wCAAwC,CAAC;AAEpE,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,IAAI,CAAU;IACd,aAAa,GAAW,CAAC,CAAC;IAC1B,YAAY,GAAW,CAAC,CAAC;IACzB,WAAW,CAAwB;IACnC,YAAY,CAAoC;IAChD,WAAW,GAA4D,EAAE,CAAC;IAC1E,WAAW,GAAqH,EAAE,CAAC;IACnI,iBAAiB,CAAa;IAC9B,UAAU,GAAY,KAAK,CAAC;IAE5B,YAAY,IAAa,EAAE,UAAmB;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,4BAA4B,CAAC,MAAc,EAAE,IAAY,EAAE,gBAAyB,KAAK;QACvF,IAAG,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI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,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE;gBACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;gBACzD,wDAAwD;gBACxD,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;gBACjE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;aAChE;SACF;QAED,4BAA4B;QAE5B,IAAG,IAAI,CAAC,IAAI,YAAY,WAAW,EAAE;YACnC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;SAC/D;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","names":[],"sourceRoot":"","sources":["../../../src/kmx/kmx-builder.ts"],"version":3}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
!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]="d628ab5e-90a5-5148-9135-724078a72d14")}catch(e){}}();
|
|
2
|
+
import { KEYBOARD } from "./kmx.js";
|
|
3
|
+
import { KeymanTypesError } from "../util/errors.js";
|
|
4
|
+
export declare class KmxFileReaderError extends KeymanTypesError {
|
|
5
|
+
}
|
|
6
|
+
export declare class KmxFileReader {
|
|
7
|
+
private readonly rString;
|
|
8
|
+
private readString;
|
|
9
|
+
private isValidCodeUse;
|
|
10
|
+
private processSystemStore;
|
|
11
|
+
read(source: Uint8Array): KEYBOARD;
|
|
12
|
+
private readGroupsAndRules;
|
|
13
|
+
private readStores;
|
|
14
|
+
}
|
|
15
|
+
//# debugId=d628ab5e-90a5-5148-9135-724078a72d14
|
|
16
|
+
//# sourceMappingURL=kmx-file-reader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"d628ab5e-90a5-5148-9135-724078a72d14","file":"kmx-file-reader.d.ts","mappings":";AAAA,OAAO,EAAkC,QAAQ,EAAqB,MAAM,UAAU,CAAC;AAEvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,qBAAa,kBAAmB,SAAQ,gBAAgB;CAEvD;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IAEzD,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,kBAAkB;IA0BnB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ;IA8CzC,OAAO,CAAC,kBAAkB;IA+B1B,OAAO,CAAC,UAAU;CAanB","names":[],"sourceRoot":"","sources":["../../../src/kmx/kmx-file-reader.ts"],"version":3}
|
|
@@ -1,38 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
!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]="53e79e43-6cbf-57f1-923b-d1cf2f5db698")}catch(e){}}();
|
|
2
|
+
import { KMXFile, KEYBOARD, STORE, GROUP, KEY } from "./kmx.js";
|
|
3
|
+
import * as r from 'restructure';
|
|
4
|
+
import { KeymanTypesError } from "../util/errors.js";
|
|
5
|
+
export class KmxFileReaderError extends KeymanTypesError {
|
|
6
|
+
}
|
|
7
|
+
export class KmxFileReader {
|
|
8
|
+
rString = new r.String(null, 'utf16le');
|
|
9
|
+
readString(source, offset) {
|
|
10
|
+
if (offset == 0) {
|
|
11
|
+
// the file has a null string here, which is not the same as an empty
|
|
12
|
+
// string ('')
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
// The following two lines are equivalent to :
|
|
16
|
+
// return this.rString.fromBuffer(source.slice(offset));
|
|
17
|
+
// but is much faster because it is a read-only view into
|
|
18
|
+
// the data rather than a copy
|
|
19
|
+
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
|
|
20
|
+
return this.rString.fromBuffer(data);
|
|
21
|
+
}
|
|
22
|
+
isValidCodeUse(s, keyboard) {
|
|
23
|
+
return (s.length == 3 &&
|
|
24
|
+
s.charCodeAt(0) == KMXFile.UC_SENTINEL &&
|
|
25
|
+
s.charCodeAt(1) == KMXFile.CODE_USE &&
|
|
26
|
+
s.charCodeAt(2) > 0 &&
|
|
27
|
+
s.charCodeAt(2) <= keyboard.groups.length);
|
|
28
|
+
}
|
|
29
|
+
processSystemStore(store, result) {
|
|
30
|
+
switch (store.dwSystemID) {
|
|
31
|
+
case KMXFile.TSS_MNEMONIC:
|
|
32
|
+
result.isMnemonic = store.dpString == '1';
|
|
33
|
+
break;
|
|
34
|
+
case KMXFile.TSS_KEYBOARDVERSION:
|
|
35
|
+
result.keyboardVersion = store.dpString;
|
|
36
|
+
break;
|
|
37
|
+
case KMXFile.TSS_TARGETS:
|
|
38
|
+
result.targets = store.dpString;
|
|
39
|
+
break;
|
|
40
|
+
case KMXFile.TSS_BEGIN_NEWCONTEXT:
|
|
41
|
+
if (!this.isValidCodeUse(store.dpString, result)) {
|
|
42
|
+
throw new KmxFileReaderError(`Invalid TSS_BEGIN_NEWCONTEXT system store`);
|
|
43
|
+
}
|
|
44
|
+
result.startGroup.newContext = store.dpString.charCodeAt(2) - 1;
|
|
45
|
+
break;
|
|
46
|
+
case KMXFile.TSS_BEGIN_POSTKEYSTROKE:
|
|
47
|
+
if (!this.isValidCodeUse(store.dpString, result)) {
|
|
48
|
+
throw new KmxFileReaderError(`Invalid TSS_BEGIN_POSTKEYSTROKE system store`);
|
|
49
|
+
}
|
|
50
|
+
result.startGroup.postKeystroke = store.dpString.charCodeAt(2) - 1;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
read(source) {
|
|
55
|
+
let binaryKeyboard;
|
|
56
|
+
let kmx = new KMXFile();
|
|
57
|
+
binaryKeyboard = kmx.COMP_KEYBOARD.fromBuffer(source);
|
|
58
|
+
if (binaryKeyboard.dwIdentifier != KMXFile.FILEID_COMPILED) {
|
|
59
|
+
throw new KmxFileReaderError(`Not a .kmx file: header does not contain FILEID_COMPILED`);
|
|
60
|
+
}
|
|
61
|
+
let result = new KEYBOARD();
|
|
62
|
+
result.fileVersion = binaryKeyboard.dwFileVersion;
|
|
63
|
+
result.flags = binaryKeyboard.dwFlags;
|
|
64
|
+
result.hotkey = binaryKeyboard.dwHotKey;
|
|
65
|
+
result.startGroup = {
|
|
66
|
+
ansi: binaryKeyboard.StartGroup_ANSI == 0xFFFFFFFF ? -1 : binaryKeyboard.StartGroup_ANSI,
|
|
67
|
+
unicode: binaryKeyboard.StartGroup_Unicode == 0xFFFFFFFF ? -1 : binaryKeyboard.StartGroup_Unicode,
|
|
68
|
+
newContext: -1,
|
|
69
|
+
postKeystroke: -1
|
|
70
|
+
};
|
|
71
|
+
// Informative data
|
|
72
|
+
result.keyboardVersion = '';
|
|
73
|
+
result.isMnemonic = false;
|
|
74
|
+
result.targets = 'desktop';
|
|
75
|
+
this.readStores(binaryKeyboard, kmx, source, result);
|
|
76
|
+
this.readGroupsAndRules(binaryKeyboard, kmx, source, result);
|
|
77
|
+
// Process system stores once we have all stores and groups loaded
|
|
78
|
+
for (let store of result.stores) {
|
|
79
|
+
this.processSystemStore(store, result);
|
|
80
|
+
}
|
|
81
|
+
// TODO: KMXPlusFile
|
|
82
|
+
// Validate startGroup offsets
|
|
83
|
+
let gp;
|
|
84
|
+
for (gp in result.startGroup) {
|
|
85
|
+
if (result.startGroup[gp] < -1 || result.startGroup[gp] >= result.groups.length) {
|
|
86
|
+
throw new KmxFileReaderError(`Invalid begin group reference`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
readGroupsAndRules(binaryKeyboard, kmx, source, result) {
|
|
92
|
+
let offset = binaryKeyboard.dpGroupArray;
|
|
93
|
+
for (let i = 0; i < binaryKeyboard.cxGroupArray; i++) {
|
|
94
|
+
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
|
|
95
|
+
let binaryGroup = kmx.COMP_GROUP.fromBuffer(data);
|
|
96
|
+
let group = new GROUP();
|
|
97
|
+
group.dpMatch = this.readString(source, binaryGroup.dpMatch);
|
|
98
|
+
group.dpName = this.readString(source, binaryGroup.dpName);
|
|
99
|
+
group.dpNoMatch = this.readString(source, binaryGroup.dpNoMatch);
|
|
100
|
+
group.fUsingKeys = binaryGroup.fUsingKeys;
|
|
101
|
+
group.keys = [];
|
|
102
|
+
let keyOffset = binaryGroup.dpKeyArray;
|
|
103
|
+
for (let j = 0; j < binaryGroup.cxKeyArray; j++) {
|
|
104
|
+
const keyData = new Uint8Array(source.buffer, source.byteOffset + keyOffset);
|
|
105
|
+
let binaryKey = kmx.COMP_KEY.fromBuffer(keyData);
|
|
106
|
+
let key = new KEY();
|
|
107
|
+
key.Key = binaryKey.Key;
|
|
108
|
+
key.Line = binaryKey.Line;
|
|
109
|
+
key.ShiftFlags = binaryKey.ShiftFlags;
|
|
110
|
+
key.dpContext = this.readString(source, binaryKey.dpContext);
|
|
111
|
+
key.dpOutput = this.readString(source, binaryKey.dpOutput);
|
|
112
|
+
group.keys.push(key);
|
|
113
|
+
keyOffset += KMXFile.COMP_KEY_SIZE;
|
|
114
|
+
}
|
|
115
|
+
result.groups.push(group);
|
|
116
|
+
offset += KMXFile.COMP_GROUP_SIZE;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
readStores(binaryKeyboard, kmx, source, result) {
|
|
120
|
+
let offset = binaryKeyboard.dpStoreArray;
|
|
121
|
+
for (let i = 0; i < binaryKeyboard.cxStoreArray; i++) {
|
|
122
|
+
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
|
|
123
|
+
let binaryStore = kmx.COMP_STORE.fromBuffer(data);
|
|
124
|
+
let store = new STORE();
|
|
125
|
+
store.dwSystemID = binaryStore.dwSystemID;
|
|
126
|
+
store.dpName = this.readString(source, binaryStore.dpName);
|
|
127
|
+
store.dpString = this.readString(source, binaryStore.dpString);
|
|
128
|
+
result.stores.push(store);
|
|
129
|
+
offset += KMXFile.COMP_STORE_SIZE;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
;
|
|
134
|
+
//# debugId=53e79e43-6cbf-57f1-923b-d1cf2f5db698
|
|
135
|
+
//# sourceMappingURL=kmx-file-reader.js.map
|