@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.
Files changed (246) hide show
  1. package/build/src/consts/virtual-key-constants.d.ts +144 -138
  2. package/build/src/consts/virtual-key-constants.d.ts.map +1 -1
  3. package/build/src/consts/virtual-key-constants.js +258 -252
  4. package/build/src/consts/virtual-key-constants.js.map +1 -1
  5. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts +8 -7
  6. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts.map +1 -1
  7. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js +76 -74
  8. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js.map +1 -1
  9. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts +31 -24
  10. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts.map +1 -1
  11. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js +119 -75
  12. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js.map +1 -1
  13. package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts +78 -76
  14. package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts.map +1 -1
  15. package/build/src/keyman-touch-layout/keyman-touch-layout-file.js +28 -26
  16. package/build/src/keyman-touch-layout/keyman-touch-layout-file.js.map +1 -1
  17. package/build/src/kmx/element-string.d.ts +26 -24
  18. package/build/src/kmx/element-string.d.ts.map +1 -1
  19. package/build/src/kmx/element-string.js +121 -119
  20. package/build/src/kmx/element-string.js.map +1 -1
  21. package/build/src/kmx/keyman-targets.d.ts +23 -0
  22. package/build/src/kmx/keyman-targets.d.ts.map +1 -0
  23. package/build/src/kmx/keyman-targets.js +80 -0
  24. package/build/src/kmx/keyman-targets.js.map +1 -0
  25. package/build/src/kmx/kmx-builder.d.ts +35 -33
  26. package/build/src/kmx/kmx-builder.d.ts.map +1 -1
  27. package/build/src/kmx/kmx-builder.js +190 -188
  28. package/build/src/kmx/kmx-builder.js.map +1 -1
  29. package/build/src/kmx/kmx-file-reader.d.ts +16 -7
  30. package/build/src/kmx/kmx-file-reader.d.ts.map +1 -1
  31. package/build/src/kmx/kmx-file-reader.js +135 -38
  32. package/build/src/kmx/kmx-file-reader.js.map +1 -1
  33. package/build/src/kmx/kmx-plus-builder/build-disp.d.ts +20 -18
  34. package/build/src/kmx/kmx-plus-builder/build-disp.d.ts.map +1 -1
  35. package/build/src/kmx/kmx-plus-builder/build-disp.js +27 -25
  36. package/build/src/kmx/kmx-plus-builder/build-disp.js.map +1 -1
  37. package/build/src/kmx/kmx-plus-builder/build-elem.d.ts +31 -29
  38. package/build/src/kmx/kmx-plus-builder/build-elem.d.ts.map +1 -1
  39. package/build/src/kmx/kmx-plus-builder/build-elem.js +90 -88
  40. package/build/src/kmx/kmx-plus-builder/build-elem.js.map +1 -1
  41. package/build/src/kmx/kmx-plus-builder/build-keys.d.ts +60 -58
  42. package/build/src/kmx/kmx-plus-builder/build-keys.d.ts.map +1 -1
  43. package/build/src/kmx/kmx-plus-builder/build-keys.js +109 -107
  44. package/build/src/kmx/kmx-plus-builder/build-keys.js.map +1 -1
  45. package/build/src/kmx/kmx-plus-builder/build-layr.d.ts +56 -54
  46. package/build/src/kmx/kmx-plus-builder/build-layr.d.ts.map +1 -1
  47. package/build/src/kmx/kmx-plus-builder/build-layr.js +101 -99
  48. package/build/src/kmx/kmx-plus-builder/build-layr.js.map +1 -1
  49. package/build/src/kmx/kmx-plus-builder/build-list.d.ts +38 -36
  50. package/build/src/kmx/kmx-plus-builder/build-list.d.ts.map +1 -1
  51. package/build/src/kmx/kmx-plus-builder/build-list.js +67 -65
  52. package/build/src/kmx/kmx-plus-builder/build-list.js.map +1 -1
  53. package/build/src/kmx/kmx-plus-builder/build-loca.d.ts +14 -12
  54. package/build/src/kmx/kmx-plus-builder/build-loca.d.ts.map +1 -1
  55. package/build/src/kmx/kmx-plus-builder/build-loca.js +22 -20
  56. package/build/src/kmx/kmx-plus-builder/build-loca.js.map +1 -1
  57. package/build/src/kmx/kmx-plus-builder/build-meta.d.ts +19 -17
  58. package/build/src/kmx/kmx-plus-builder/build-meta.d.ts.map +1 -1
  59. package/build/src/kmx/kmx-plus-builder/build-meta.js +23 -21
  60. package/build/src/kmx/kmx-plus-builder/build-meta.js.map +1 -1
  61. package/build/src/kmx/kmx-plus-builder/build-name.d.ts +14 -12
  62. package/build/src/kmx/kmx-plus-builder/build-name.d.ts.map +1 -1
  63. package/build/src/kmx/kmx-plus-builder/build-name.js +25 -23
  64. package/build/src/kmx/kmx-plus-builder/build-name.js.map +1 -1
  65. package/build/src/kmx/kmx-plus-builder/build-sect.d.ts +18 -16
  66. package/build/src/kmx/kmx-plus-builder/build-sect.d.ts.map +1 -1
  67. package/build/src/kmx/kmx-plus-builder/build-sect.js +16 -14
  68. package/build/src/kmx/kmx-plus-builder/build-sect.js.map +1 -1
  69. package/build/src/kmx/kmx-plus-builder/build-strs.d.ts +25 -23
  70. package/build/src/kmx/kmx-plus-builder/build-strs.d.ts.map +1 -1
  71. package/build/src/kmx/kmx-plus-builder/build-strs.js +47 -45
  72. package/build/src/kmx/kmx-plus-builder/build-strs.js.map +1 -1
  73. package/build/src/kmx/kmx-plus-builder/build-tran.d.ts +35 -33
  74. package/build/src/kmx/kmx-plus-builder/build-tran.d.ts.map +1 -1
  75. package/build/src/kmx/kmx-plus-builder/build-tran.js +70 -68
  76. package/build/src/kmx/kmx-plus-builder/build-tran.js.map +1 -1
  77. package/build/src/kmx/kmx-plus-builder/build-uset.d.ts +33 -31
  78. package/build/src/kmx/kmx-plus-builder/build-uset.d.ts.map +1 -1
  79. package/build/src/kmx/kmx-plus-builder/build-uset.js +61 -59
  80. package/build/src/kmx/kmx-plus-builder/build-uset.js.map +1 -1
  81. package/build/src/kmx/kmx-plus-builder/build-vars.d.ts +24 -22
  82. package/build/src/kmx/kmx-plus-builder/build-vars.d.ts.map +1 -1
  83. package/build/src/kmx/kmx-plus-builder/build-vars.js +49 -47
  84. package/build/src/kmx/kmx-plus-builder/build-vars.js.map +1 -1
  85. package/build/src/kmx/kmx-plus-builder/build-vkey.d.ts +18 -16
  86. package/build/src/kmx/kmx-plus-builder/build-vkey.d.ts.map +1 -1
  87. package/build/src/kmx/kmx-plus-builder/build-vkey.js +25 -23
  88. package/build/src/kmx/kmx-plus-builder/build-vkey.js.map +1 -1
  89. package/build/src/kmx/kmx-plus-builder/builder-section.d.ts +12 -10
  90. package/build/src/kmx/kmx-plus-builder/builder-section.d.ts.map +1 -1
  91. package/build/src/kmx/kmx-plus-builder/builder-section.js +5 -3
  92. package/build/src/kmx/kmx-plus-builder/builder-section.js.map +1 -1
  93. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts +49 -47
  94. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts.map +1 -1
  95. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js +146 -144
  96. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js.map +1 -1
  97. package/build/src/kmx/kmx-plus.d.ts +331 -329
  98. package/build/src/kmx/kmx-plus.d.ts.map +1 -1
  99. package/build/src/kmx/kmx-plus.js +835 -833
  100. package/build/src/kmx/kmx-plus.js.map +1 -1
  101. package/build/src/kmx/kmx.d.ts +235 -209
  102. package/build/src/kmx/kmx.d.ts.map +1 -1
  103. package/build/src/kmx/kmx.js +299 -276
  104. package/build/src/kmx/kmx.js.map +1 -1
  105. package/build/src/kmx/string-list.d.ts +36 -34
  106. package/build/src/kmx/string-list.d.ts.map +1 -1
  107. package/build/src/kmx/string-list.js +85 -83
  108. package/build/src/kmx/string-list.js.map +1 -1
  109. package/build/src/kpj/keyman-developer-project.d.ts +74 -63
  110. package/build/src/kpj/keyman-developer-project.d.ts.map +1 -1
  111. package/build/src/kpj/keyman-developer-project.js +165 -146
  112. package/build/src/kpj/keyman-developer-project.js.map +1 -1
  113. package/build/src/kpj/kpj-file-reader.d.ts +21 -19
  114. package/build/src/kpj/kpj-file-reader.d.ts.map +1 -1
  115. package/build/src/kpj/kpj-file-reader.js +110 -96
  116. package/build/src/kpj/kpj-file-reader.js.map +1 -1
  117. package/build/src/kpj/kpj-file.d.ts +41 -39
  118. package/build/src/kpj/kpj-file.d.ts.map +1 -1
  119. package/build/src/kpj/kpj-file.js +13 -11
  120. package/build/src/kpj/kpj-file.js.map +1 -1
  121. package/build/src/kvk/kvk-file-reader.d.ts +7 -5
  122. package/build/src/kvk/kvk-file-reader.d.ts.map +1 -1
  123. package/build/src/kvk/kvk-file-reader.js +38 -35
  124. package/build/src/kvk/kvk-file-reader.js.map +1 -1
  125. package/build/src/kvk/kvk-file-writer.d.ts +22 -20
  126. package/build/src/kvk/kvk-file-writer.d.ts.map +1 -1
  127. package/build/src/kvk/kvk-file-writer.js +78 -67
  128. package/build/src/kvk/kvk-file-writer.js.map +1 -1
  129. package/build/src/kvk/kvk-file.d.ts +68 -65
  130. package/build/src/kvk/kvk-file.d.ts.map +1 -1
  131. package/build/src/kvk/kvk-file.js +67 -64
  132. package/build/src/kvk/kvk-file.js.map +1 -1
  133. package/build/src/kvk/kvks-file-reader.d.ts +26 -23
  134. package/build/src/kvk/kvks-file-reader.d.ts.map +1 -1
  135. package/build/src/kvk/kvks-file-reader.js +179 -151
  136. package/build/src/kvk/kvks-file-reader.js.map +1 -1
  137. package/build/src/kvk/kvks-file-writer.d.ts +9 -6
  138. package/build/src/kvk/kvks-file-writer.d.ts.map +1 -1
  139. package/build/src/kvk/kvks-file-writer.js +107 -98
  140. package/build/src/kvk/kvks-file-writer.js.map +1 -1
  141. package/build/src/kvk/kvks-file.d.ts +46 -44
  142. package/build/src/kvk/kvks-file.d.ts.map +1 -1
  143. package/build/src/kvk/kvks-file.js +12 -10
  144. package/build/src/kvk/kvks-file.js.map +1 -1
  145. package/build/src/kvk/visual-keyboard.d.ts +47 -35
  146. package/build/src/kvk/visual-keyboard.d.ts.map +1 -1
  147. package/build/src/kvk/visual-keyboard.js +73 -61
  148. package/build/src/kvk/visual-keyboard.js.map +1 -1
  149. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts +58 -56
  150. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts.map +1 -1
  151. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js +22 -20
  152. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js.map +1 -1
  153. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts +97 -95
  154. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts.map +1 -1
  155. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js +387 -385
  156. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js.map +1 -1
  157. package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts +163 -161
  158. package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts.map +1 -1
  159. package/build/src/ldml-keyboard/ldml-keyboard-xml.js +41 -39
  160. package/build/src/ldml-keyboard/ldml-keyboard-xml.js.map +1 -1
  161. package/build/src/ldml-keyboard/pattern-parser.d.ts +138 -136
  162. package/build/src/ldml-keyboard/pattern-parser.d.ts.map +1 -1
  163. package/build/src/ldml-keyboard/pattern-parser.js +245 -243
  164. package/build/src/ldml-keyboard/pattern-parser.js.map +1 -1
  165. package/build/src/ldml-keyboard/unicodeset-parser-api.d.ts +40 -38
  166. package/build/src/ldml-keyboard/unicodeset-parser-api.d.ts.map +1 -1
  167. package/build/src/ldml-keyboard/unicodeset-parser-api.js +30 -28
  168. package/build/src/ldml-keyboard/unicodeset-parser-api.js.map +1 -1
  169. package/build/src/main.d.ts +36 -29
  170. package/build/src/main.d.ts.map +1 -1
  171. package/build/src/main.js +35 -28
  172. package/build/src/main.js.map +1 -1
  173. package/build/src/osk/osk.d.ts +25 -0
  174. package/build/src/osk/osk.d.ts.map +1 -0
  175. package/build/src/osk/osk.js +89 -0
  176. package/build/src/osk/osk.js.map +1 -0
  177. package/build/src/package/kmp-json-file.d.ts +69 -68
  178. package/build/src/package/kmp-json-file.d.ts.map +1 -1
  179. package/build/src/package/kmp-json-file.js +4 -2
  180. package/build/src/package/kmp-json-file.js.map +1 -1
  181. package/build/src/package/kps-file.d.ts +100 -98
  182. package/build/src/package/kps-file.d.ts.map +1 -1
  183. package/build/src/package/kps-file.js +18 -16
  184. package/build/src/package/kps-file.js.map +1 -1
  185. package/build/src/schemas/displaymap.schema.d.ts +60 -0
  186. package/build/src/schemas/displaymap.schema.d.ts.map +1 -0
  187. package/build/src/schemas/displaymap.schema.js +38 -0
  188. package/build/src/schemas/displaymap.schema.js.map +1 -0
  189. package/build/src/schemas/keyman-touch-layout.clean.spec.d.ts +230 -0
  190. package/build/src/schemas/keyman-touch-layout.clean.spec.d.ts.map +1 -0
  191. package/build/src/schemas/keyman-touch-layout.clean.spec.js +154 -0
  192. package/build/src/schemas/keyman-touch-layout.clean.spec.js.map +1 -0
  193. package/build/src/schemas/keyman-touch-layout.spec.d.ts +229 -0
  194. package/build/src/schemas/keyman-touch-layout.spec.d.ts.map +1 -0
  195. package/build/src/schemas/keyman-touch-layout.spec.js +142 -0
  196. package/build/src/schemas/keyman-touch-layout.spec.js.map +1 -0
  197. package/build/src/schemas/kpj-9.0.schema.d.ts +155 -0
  198. package/build/src/schemas/kpj-9.0.schema.d.ts.map +1 -0
  199. package/build/src/schemas/kpj-9.0.schema.js +134 -0
  200. package/build/src/schemas/kpj-9.0.schema.js.map +1 -0
  201. package/build/src/schemas/kpj.schema.d.ts +121 -0
  202. package/build/src/schemas/kpj.schema.d.ts.map +1 -0
  203. package/build/src/schemas/kpj.schema.js +128 -0
  204. package/build/src/schemas/kpj.schema.js.map +1 -0
  205. package/build/src/schemas/kvks.schema.d.ts +163 -0
  206. package/build/src/schemas/kvks.schema.d.ts.map +1 -0
  207. package/build/src/schemas/kvks.schema.js +185 -0
  208. package/build/src/schemas/kvks.schema.js.map +1 -0
  209. package/build/src/schemas/ldml-keyboard.schema.d.ts +634 -0
  210. package/build/src/schemas/ldml-keyboard.schema.d.ts.map +1 -0
  211. package/build/src/schemas/ldml-keyboard.schema.js +705 -0
  212. package/build/src/schemas/ldml-keyboard.schema.js.map +1 -0
  213. package/build/src/schemas/ldml-keyboardtest.schema.d.ts +191 -0
  214. package/build/src/schemas/ldml-keyboardtest.schema.d.ts.map +1 -0
  215. package/build/src/schemas/ldml-keyboardtest.schema.js +224 -0
  216. package/build/src/schemas/ldml-keyboardtest.schema.js.map +1 -0
  217. package/build/src/schemas.d.ts +1757 -0
  218. package/build/src/schemas.d.ts.map +1 -0
  219. package/build/src/schemas.js +22 -0
  220. package/build/src/schemas.js.map +1 -0
  221. package/build/src/util/common-events.d.ts +51 -49
  222. package/build/src/util/common-events.d.ts.map +1 -1
  223. package/build/src/util/common-events.js +31 -29
  224. package/build/src/util/common-events.js.map +1 -1
  225. package/build/src/util/compiler-interfaces.d.ts +296 -136
  226. package/build/src/util/compiler-interfaces.d.ts.map +1 -1
  227. package/build/src/util/compiler-interfaces.js +294 -104
  228. package/build/src/util/compiler-interfaces.js.map +1 -1
  229. package/build/src/util/errors.d.ts +8 -0
  230. package/build/src/util/errors.d.ts.map +1 -0
  231. package/build/src/util/errors.js +8 -0
  232. package/build/src/util/errors.js.map +1 -0
  233. package/build/src/util/file-types.d.ts +98 -0
  234. package/build/src/util/file-types.d.ts.map +1 -0
  235. package/build/src/util/file-types.js +117 -0
  236. package/build/src/util/file-types.js.map +1 -0
  237. package/build/src/util/util.d.ts +32 -30
  238. package/build/src/util/util.d.ts.map +1 -1
  239. package/build/src/util/util.js +98 -96
  240. package/build/src/util/util.js.map +1 -1
  241. package/package.json +23 -4
  242. package/build/src/keyman-touch-layout.clean.spec.json +0 -170
  243. package/build/src/kpj.schema.json +0 -127
  244. package/build/src/kvks.schema.json +0 -182
  245. package/build/src/ldml-keyboard.schema.json +0 -702
  246. package/build/src/ldml-keyboardtest.schema.json +0 -221
@@ -1,385 +1,387 @@
1
- import * as xml2js from 'xml2js';
2
- import { default as AjvModule } from 'ajv';
3
- const Ajv = AjvModule.default; // The actual expected Ajv type.
4
- import { boxXmlArray } from '../util/util.js';
5
- import { constants } from '@keymanapp/ldml-keyboard-constants';
6
- import { CommonTypesMessages } from '../util/common-events.js';
7
- ;
8
- export class LDMLKeyboardXMLSourceFileReaderOptions {
9
- importsPath;
10
- }
11
- ;
12
- export class LDMLKeyboardXMLSourceFileReader {
13
- options;
14
- callbacks;
15
- constructor(options, callbacks) {
16
- this.options = options;
17
- this.callbacks = callbacks;
18
- }
19
- static get defaultImportsURL() {
20
- return new URL(`../import/`, import.meta.url);
21
- }
22
- readImportFile(version, subpath) {
23
- const importPath = this.callbacks.resolveFilename(this.options.importsPath, `${version}/${subpath}`);
24
- return this.callbacks.loadFile(importPath);
25
- }
26
- /**
27
- * xml2js will not place single-entry objects into arrays.
28
- * Easiest way to fix this is to box them ourselves as needed
29
- * @param source any
30
- * @returns true on success, false on failure
31
- */
32
- boxArrays(source) {
33
- if (source?.keyboard) {
34
- if (!source.keyboard.keys) {
35
- source.keyboard.keys = {
36
- key: [],
37
- flicks: [],
38
- };
39
- }
40
- if (!source.keyboard.keys.import) {
41
- source.keyboard.keys.import = [];
42
- }
43
- }
44
- boxXmlArray(source?.keyboard, 'layers');
45
- boxXmlArray(source?.keyboard?.displays, 'display');
46
- boxXmlArray(source?.keyboard?.names, 'name');
47
- boxXmlArray(source?.keyboard?.vkeys, 'vkey');
48
- boxXmlArray(source?.keyboard?.keys, 'key');
49
- boxXmlArray(source?.keyboard?.keys, 'flicks');
50
- boxXmlArray(source?.keyboard?.locales, 'locale');
51
- boxXmlArray(source?.keyboard, 'transforms');
52
- if (source?.keyboard?.layers) {
53
- for (let layers of source?.keyboard?.layers) {
54
- boxXmlArray(layers, 'layer');
55
- if (layers?.layer) {
56
- for (let layer of layers?.layer) {
57
- boxXmlArray(layer, 'row');
58
- }
59
- }
60
- }
61
- }
62
- if (source?.keyboard?.keys?.flicks) {
63
- for (let flicks of source?.keyboard?.keys?.flicks) {
64
- boxXmlArray(flicks, 'flick');
65
- }
66
- }
67
- if (source?.keyboard?.variables) {
68
- boxXmlArray(source?.keyboard?.variables, 'set');
69
- boxXmlArray(source?.keyboard?.variables, 'string');
70
- boxXmlArray(source?.keyboard?.variables, 'unicodeSet');
71
- }
72
- if (source?.keyboard?.transforms) {
73
- for (let transforms of source.keyboard.transforms) {
74
- boxXmlArray(transforms, 'transformGroup');
75
- for (let transformGroup of transforms.transformGroup) {
76
- boxXmlArray(transformGroup, 'transform');
77
- boxXmlArray(transformGroup, 'reorder');
78
- }
79
- }
80
- }
81
- return this.boxImportsAndSpecials(source, 'keyboard');
82
- }
83
- /**
84
- * Recurse over object, boxing up any specials or imports
85
- * @param obj any object to be traversed
86
- * @param subtag the leafmost enclosing tag such as 'keyboard'
87
- * @returns true on success, false on failure
88
- */
89
- boxImportsAndSpecials(obj, subtag) {
90
- if (!obj)
91
- return true;
92
- if (Array.isArray(obj)) {
93
- for (const sub of obj) {
94
- // retain the same subtag
95
- if (!this.boxImportsAndSpecials(sub, subtag)) {
96
- return false;
97
- }
98
- }
99
- }
100
- else if (typeof obj === 'object') {
101
- for (const key of Object.keys(obj)) {
102
- if (key === 'special') {
103
- boxXmlArray(obj, key);
104
- }
105
- else if (key === 'import') {
106
- // Need to 'box it up' first for processing
107
- boxXmlArray(obj, key);
108
- // Now, resolve the import
109
- if (!this.resolveImports(obj, subtag)) {
110
- return false;
111
- }
112
- // now delete the import array we so carefully constructed, the caller does not
113
- // want to see it.
114
- delete obj['import'];
115
- }
116
- else {
117
- if (!this.boxImportsAndSpecials(obj[key], key)) {
118
- return false;
119
- }
120
- }
121
- }
122
- }
123
- return true;
124
- }
125
- /**
126
- *
127
- * @param obj object to be imported into
128
- * @param subtag obj's element tag, e.g. `keys`
129
- * @returns true on success, false on failure
130
- */
131
- resolveImports(obj, subtag) {
132
- // These are in reverse order, because the imports insert at the beginning of the array.
133
- // first, the explicit imports
134
- for (const asImport of ([...obj['import']].reverse())) {
135
- if (!this.resolveOneImport(obj, subtag, asImport)) {
136
- return false;
137
- }
138
- }
139
- // then, the implied imports
140
- if (subtag === 'keys') {
141
- // <import base="cldr" path="techpreview/keys-Latn-implied.xml"/>
142
- if (!this.resolveOneImport(obj, subtag, {
143
- base: constants.cldr_import_base,
144
- path: constants.cldr_implied_keys_import
145
- })) {
146
- return false;
147
- }
148
- }
149
- return true;
150
- }
151
- /**
152
- * @param obj the object being imported into
153
- * @param subtag obj's element tag, e.g. `keys`
154
- * @param asImport the import structure
155
- * @returns true on success, false on failure
156
- */
157
- resolveOneImport(obj, subtag, asImport) {
158
- const { base, path } = asImport;
159
- if (base !== constants.cldr_import_base) {
160
- this.callbacks.reportMessage(CommonTypesMessages.Error_ImportInvalidBase({ base, path, subtag }));
161
- return false;
162
- }
163
- const paths = path.split('/');
164
- if (paths[0] == '' || paths[1] == '' || paths.length !== 2) {
165
- this.callbacks.reportMessage(CommonTypesMessages.Error_ImportInvalidPath({ base, path, subtag }));
166
- return false;
167
- }
168
- const importData = this.readImportFile(paths[0], paths[1]);
169
- if (!importData || !importData.length) {
170
- this.callbacks.reportMessage(CommonTypesMessages.Error_ImportReadFail({ base, path, subtag }));
171
- return false;
172
- }
173
- const importXml = this.loadUnboxed(importData); // TODO-LDML: have to load as any because it is an arbitrary part
174
- const importRootNode = importXml[subtag]; // e.g. <keys/>
175
- // importXml will have one property: the root element.
176
- if (!importRootNode) {
177
- this.callbacks.reportMessage(CommonTypesMessages.Error_ImportWrongRoot({ base, path, subtag }));
178
- return false;
179
- }
180
- // pull all children of importXml[subtag] into obj
181
- for (const subsubtag of Object.keys(importRootNode).reverse()) { // e.g. <key/>
182
- const subsubval = importRootNode[subsubtag];
183
- if (!Array.isArray(subsubval)) {
184
- // This is somewhat of an internal error, indicating that a non-mergeable XML file was imported
185
- // Not exercisable with the standard LDML imports.
186
- this.callbacks.reportMessage(CommonTypesMessages.Error_ImportMergeFail({ base, path, subtag, subsubtag }));
187
- return false;
188
- }
189
- if (!obj[subsubtag]) {
190
- obj[subsubtag] = []; // start with empty array
191
- }
192
- obj[subsubtag] = [...subsubval, ...obj[subsubtag]];
193
- }
194
- return true;
195
- }
196
- /**
197
- * @returns true if valid, false if invalid
198
- */
199
- validate(source, schemaSource) {
200
- const schema = JSON.parse(new TextDecoder().decode(schemaSource));
201
- const ajv = new Ajv();
202
- if (!ajv.validate(schema, source)) {
203
- for (let err of ajv.errors) {
204
- this.callbacks.reportMessage(CommonTypesMessages.Error_SchemaValidationError({
205
- instancePath: err.instancePath,
206
- keyword: err.keyword,
207
- message: err.message || 'Unknown AJV Error',
208
- params: Object.entries(err.params || {}).sort().map(([k, v]) => `${k}="${v}"`).join(' '),
209
- }));
210
- }
211
- return false;
212
- }
213
- return true;
214
- }
215
- loadUnboxed(file) {
216
- let source = (() => {
217
- let a;
218
- let parser = new xml2js.Parser({
219
- explicitArray: false,
220
- mergeAttrs: true,
221
- includeWhiteChars: false,
222
- emptyTag: {}
223
- // Why "as any"? xml2js is broken:
224
- // https://github.com/Leonidas-from-XIV/node-xml2js/issues/648 means
225
- // that an old version of `emptyTag` is used which doesn't support
226
- // functions, but DefinitelyTyped is requiring use of function or a
227
- // string. See also notes at
228
- // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/59259#issuecomment-1254405470
229
- // An alternative fix would be to pull xml2js directly from github
230
- // rather than using the version tagged on npmjs.com.
231
- });
232
- parser.parseString(file, (e, r) => { a = r; }); // TODO-LDML: isn't 'e' the error?
233
- return a;
234
- })();
235
- return source;
236
- }
237
- /**
238
- * @param file
239
- * @returns source on success, otherwise null
240
- */
241
- load(file) {
242
- if (!file) {
243
- return null;
244
- }
245
- const source = this.loadUnboxed(file);
246
- if (this.boxArrays(source)) {
247
- return source;
248
- }
249
- else {
250
- return null;
251
- }
252
- }
253
- loadTestDataUnboxed(file) {
254
- let source = (() => {
255
- let a;
256
- let parser = new xml2js.Parser({
257
- // explicitArray: false,
258
- preserveChildrenOrder: true,
259
- explicitChildren: true, // needed for test data
260
- // mergeAttrs: true,
261
- // includeWhiteChars: false,
262
- // emptyTag: {} as any
263
- // Why "as any"? xml2js is broken:
264
- // https://github.com/Leonidas-from-XIV/node-xml2js/issues/648 means
265
- // that an old version of `emptyTag` is used which doesn't support
266
- // functions, but DefinitelyTyped is requiring use of function or a
267
- // string. See also notes at
268
- // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/59259#issuecomment-1254405470
269
- // An alternative fix would be to pull xml2js directly from github
270
- // rather than using the version tagged on npmjs.com.
271
- });
272
- parser.parseString(file, (e, r) => { a = r; }); // TODO-LDML: isn't 'e' the error?
273
- return a; // Why 'any'? Because we need to box up the $'s into proper properties.
274
- })();
275
- return source;
276
- }
277
- /**
278
- * Filter the obj array for a subtag
279
- * @param source array of source objs
280
- * @param subtag subtag to filter on
281
- * @returns
282
- */
283
- findSubtagArray(source, subtag) {
284
- return source?.filter(o => o['#name'] === subtag);
285
- }
286
- /**
287
- * Get exactly one element
288
- * @param source
289
- * @param subtag
290
- * @returns
291
- */
292
- findSubtag(source, subtag) {
293
- const r = this.findSubtagArray(source, subtag);
294
- if (!r || r.length === 0) {
295
- return null;
296
- }
297
- else if (r.length === 1) {
298
- return r[0];
299
- }
300
- else {
301
- this.callbacks.reportMessage(CommonTypesMessages.Error_TestDataUnexpectedArray({ subtag }));
302
- return null; // ERROR
303
- }
304
- }
305
- /**
306
- * The default test data stuffer.
307
- * Just gets $ (the attrs) as the body.
308
- * Override to use something more complex, such as including child nodes.
309
- * @param o object to map
310
- * @param r back ref to reader
311
- */
312
- static defaultMapper = ((o, r) => o?.$);
313
- /**
314
- *
315
- * @param obj target object
316
- * @param source array of $/#name strings
317
- * @param subtag name to extract
318
- * @param mapper custom mapper function
319
- */
320
- stuffBoxes(obj, source, subtag, asArray, mapper) {
321
- if (!mapper) {
322
- mapper = LDMLKeyboardXMLSourceFileReader.defaultMapper;
323
- }
324
- if (asArray) {
325
- const r = this;
326
- obj[subtag] = this.findSubtagArray(source, subtag)?.map((v) => mapper(v, r)); // extract contents only
327
- }
328
- else {
329
- obj[subtag] = mapper(this.findSubtag(source, subtag), this); // run the mapper once
330
- }
331
- }
332
- boxTestDataArrays(raw) {
333
- if (!raw)
334
- return null;
335
- const a = {
336
- keyboardTest: {
337
- conformsTo: raw?.keyboardTest?.$?.conformsTo,
338
- }
339
- };
340
- const $$ = raw?.keyboardTest?.$$;
341
- this.stuffBoxes(a.keyboardTest, $$, 'info');
342
- this.stuffBoxes(a.keyboardTest, $$, 'repertoire', true);
343
- this.stuffBoxes(a.keyboardTest, $$, 'tests', true, (o, r) => {
344
- // start with basic unpack
345
- const tests = LDMLKeyboardXMLSourceFileReader.defaultMapper(o, r);
346
- // add ingredients
347
- r.stuffBoxes(tests, o.$$, 'test', true, (o, r) => {
348
- // start with basic unpack
349
- const test = LDMLKeyboardXMLSourceFileReader.defaultMapper(o, r);
350
- // add ingredients
351
- const $$ = o.$$;
352
- r.stuffBoxes(test, $$, 'startContext'); // singleton
353
- // now the actions
354
- test.actions = $$.map(v => {
355
- const subtag = v['#name'];
356
- const subv = LDMLKeyboardXMLSourceFileReader.defaultMapper(v, r);
357
- switch (subtag) {
358
- case 'keystroke': return { keystroke: subv };
359
- case 'check': return { check: subv };
360
- case 'emit': return { emit: subv };
361
- case 'startContext': return null; // handled above
362
- default:
363
- this.callbacks.reportMessage(CommonTypesMessages.Error_TestDataUnexpectedAction({ subtag }));
364
- return null;
365
- }
366
- }).filter(v => v !== null);
367
- return test;
368
- });
369
- return tests;
370
- });
371
- return a;
372
- }
373
- /**
374
- * @param file test file
375
- * @returns source on success, otherwise null
376
- */
377
- loadTestData(file) {
378
- if (!file) {
379
- return null;
380
- }
381
- const source = this.loadTestDataUnboxed(file);
382
- return this.boxTestDataArrays(source);
383
- }
384
- }
385
- //# sourceMappingURL=ldml-keyboard-xml-reader.js.map
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]="8cf3c80a-204a-50da-9a5f-2bd1380745a8")}catch(e){}}();
2
+ import * as xml2js from 'xml2js';
3
+ import { default as AjvModule } from 'ajv';
4
+ const Ajv = AjvModule.default; // The actual expected Ajv type.
5
+ import { boxXmlArray } from '../util/util.js';
6
+ import { constants } from '@keymanapp/ldml-keyboard-constants';
7
+ import { CommonTypesMessages } from '../util/common-events.js';
8
+ import Schemas from '../schemas.js';
9
+ ;
10
+ export class LDMLKeyboardXMLSourceFileReaderOptions {
11
+ importsPath;
12
+ }
13
+ ;
14
+ export class LDMLKeyboardXMLSourceFileReader {
15
+ options;
16
+ callbacks;
17
+ constructor(options, callbacks) {
18
+ this.options = options;
19
+ this.callbacks = callbacks;
20
+ }
21
+ static get defaultImportsURL() {
22
+ return new URL(`../import/`, import.meta.url);
23
+ }
24
+ readImportFile(version, subpath) {
25
+ const importPath = this.callbacks.resolveFilename(this.options.importsPath, `${version}/${subpath}`);
26
+ return this.callbacks.loadFile(importPath);
27
+ }
28
+ /**
29
+ * xml2js will not place single-entry objects into arrays.
30
+ * Easiest way to fix this is to box them ourselves as needed
31
+ * @param source any
32
+ * @returns true on success, false on failure
33
+ */
34
+ boxArrays(source) {
35
+ if (source?.keyboard) {
36
+ if (!source.keyboard.keys) {
37
+ source.keyboard.keys = {
38
+ key: [],
39
+ flicks: [],
40
+ };
41
+ }
42
+ if (!source.keyboard.keys.import) {
43
+ source.keyboard.keys.import = [];
44
+ }
45
+ }
46
+ boxXmlArray(source?.keyboard, 'layers');
47
+ boxXmlArray(source?.keyboard?.displays, 'display');
48
+ boxXmlArray(source?.keyboard?.names, 'name');
49
+ boxXmlArray(source?.keyboard?.vkeys, 'vkey');
50
+ boxXmlArray(source?.keyboard?.keys, 'key');
51
+ boxXmlArray(source?.keyboard?.keys, 'flicks');
52
+ boxXmlArray(source?.keyboard?.locales, 'locale');
53
+ boxXmlArray(source?.keyboard, 'transforms');
54
+ if (source?.keyboard?.layers) {
55
+ for (let layers of source?.keyboard?.layers) {
56
+ boxXmlArray(layers, 'layer');
57
+ if (layers?.layer) {
58
+ for (let layer of layers?.layer) {
59
+ boxXmlArray(layer, 'row');
60
+ }
61
+ }
62
+ }
63
+ }
64
+ if (source?.keyboard?.keys?.flicks) {
65
+ for (let flicks of source?.keyboard?.keys?.flicks) {
66
+ boxXmlArray(flicks, 'flick');
67
+ }
68
+ }
69
+ if (source?.keyboard?.variables) {
70
+ boxXmlArray(source?.keyboard?.variables, 'set');
71
+ boxXmlArray(source?.keyboard?.variables, 'string');
72
+ boxXmlArray(source?.keyboard?.variables, 'unicodeSet');
73
+ }
74
+ if (source?.keyboard?.transforms) {
75
+ for (let transforms of source.keyboard.transforms) {
76
+ boxXmlArray(transforms, 'transformGroup');
77
+ for (let transformGroup of transforms.transformGroup) {
78
+ boxXmlArray(transformGroup, 'transform');
79
+ boxXmlArray(transformGroup, 'reorder');
80
+ }
81
+ }
82
+ }
83
+ return this.boxImportsAndSpecials(source, 'keyboard');
84
+ }
85
+ /**
86
+ * Recurse over object, boxing up any specials or imports
87
+ * @param obj any object to be traversed
88
+ * @param subtag the leafmost enclosing tag such as 'keyboard'
89
+ * @returns true on success, false on failure
90
+ */
91
+ boxImportsAndSpecials(obj, subtag) {
92
+ if (!obj)
93
+ return true;
94
+ if (Array.isArray(obj)) {
95
+ for (const sub of obj) {
96
+ // retain the same subtag
97
+ if (!this.boxImportsAndSpecials(sub, subtag)) {
98
+ return false;
99
+ }
100
+ }
101
+ }
102
+ else if (typeof obj === 'object') {
103
+ for (const key of Object.keys(obj)) {
104
+ if (key === 'special') {
105
+ boxXmlArray(obj, key);
106
+ }
107
+ else if (key === 'import') {
108
+ // Need to 'box it up' first for processing
109
+ boxXmlArray(obj, key);
110
+ // Now, resolve the import
111
+ if (!this.resolveImports(obj, subtag)) {
112
+ return false;
113
+ }
114
+ // now delete the import array we so carefully constructed, the caller does not
115
+ // want to see it.
116
+ delete obj['import'];
117
+ }
118
+ else {
119
+ if (!this.boxImportsAndSpecials(obj[key], key)) {
120
+ return false;
121
+ }
122
+ }
123
+ }
124
+ }
125
+ return true;
126
+ }
127
+ /**
128
+ *
129
+ * @param obj object to be imported into
130
+ * @param subtag obj's element tag, e.g. `keys`
131
+ * @returns true on success, false on failure
132
+ */
133
+ resolveImports(obj, subtag) {
134
+ // These are in reverse order, because the imports insert at the beginning of the array.
135
+ // first, the explicit imports
136
+ for (const asImport of ([...obj['import']].reverse())) {
137
+ if (!this.resolveOneImport(obj, subtag, asImport)) {
138
+ return false;
139
+ }
140
+ }
141
+ // then, the implied imports
142
+ if (subtag === 'keys') {
143
+ // <import base="cldr" path="techpreview/keys-Latn-implied.xml"/>
144
+ if (!this.resolveOneImport(obj, subtag, {
145
+ base: constants.cldr_import_base,
146
+ path: constants.cldr_implied_keys_import
147
+ })) {
148
+ return false;
149
+ }
150
+ }
151
+ return true;
152
+ }
153
+ /**
154
+ * @param obj the object being imported into
155
+ * @param subtag obj's element tag, e.g. `keys`
156
+ * @param asImport the import structure
157
+ * @returns true on success, false on failure
158
+ */
159
+ resolveOneImport(obj, subtag, asImport) {
160
+ const { base, path } = asImport;
161
+ if (base !== constants.cldr_import_base) {
162
+ this.callbacks.reportMessage(CommonTypesMessages.Error_ImportInvalidBase({ base, path, subtag }));
163
+ return false;
164
+ }
165
+ const paths = path.split('/');
166
+ if (paths[0] == '' || paths[1] == '' || paths.length !== 2) {
167
+ this.callbacks.reportMessage(CommonTypesMessages.Error_ImportInvalidPath({ base, path, subtag }));
168
+ return false;
169
+ }
170
+ const importData = this.readImportFile(paths[0], paths[1]);
171
+ if (!importData || !importData.length) {
172
+ this.callbacks.reportMessage(CommonTypesMessages.Error_ImportReadFail({ base, path, subtag }));
173
+ return false;
174
+ }
175
+ const importXml = this.loadUnboxed(importData); // TODO-LDML: have to load as any because it is an arbitrary part
176
+ const importRootNode = importXml[subtag]; // e.g. <keys/>
177
+ // importXml will have one property: the root element.
178
+ if (!importRootNode) {
179
+ this.callbacks.reportMessage(CommonTypesMessages.Error_ImportWrongRoot({ base, path, subtag }));
180
+ return false;
181
+ }
182
+ // pull all children of importXml[subtag] into obj
183
+ for (const subsubtag of Object.keys(importRootNode).reverse()) { // e.g. <key/>
184
+ const subsubval = importRootNode[subsubtag];
185
+ if (!Array.isArray(subsubval)) {
186
+ // This is somewhat of an internal error, indicating that a non-mergeable XML file was imported
187
+ // Not exercisable with the standard LDML imports.
188
+ this.callbacks.reportMessage(CommonTypesMessages.Error_ImportMergeFail({ base, path, subtag, subsubtag }));
189
+ return false;
190
+ }
191
+ if (!obj[subsubtag]) {
192
+ obj[subsubtag] = []; // start with empty array
193
+ }
194
+ obj[subsubtag] = [...subsubval, ...obj[subsubtag]];
195
+ }
196
+ return true;
197
+ }
198
+ /**
199
+ * @returns true if valid, false if invalid
200
+ */
201
+ validate(source) {
202
+ const ajv = new Ajv();
203
+ if (!ajv.validate(Schemas.ldmlKeyboard, source)) {
204
+ for (let err of ajv.errors) {
205
+ this.callbacks.reportMessage(CommonTypesMessages.Error_SchemaValidationError({
206
+ instancePath: err.instancePath,
207
+ keyword: err.keyword,
208
+ message: err.message || 'Unknown AJV Error',
209
+ params: Object.entries(err.params || {}).sort().map(([k, v]) => `${k}="${v}"`).join(' '),
210
+ }));
211
+ }
212
+ return false;
213
+ }
214
+ return true;
215
+ }
216
+ loadUnboxed(file) {
217
+ let source = (() => {
218
+ let a;
219
+ let parser = new xml2js.Parser({
220
+ explicitArray: false,
221
+ mergeAttrs: true,
222
+ includeWhiteChars: false,
223
+ emptyTag: {}
224
+ // Why "as any"? xml2js is broken:
225
+ // https://github.com/Leonidas-from-XIV/node-xml2js/issues/648 means
226
+ // that an old version of `emptyTag` is used which doesn't support
227
+ // functions, but DefinitelyTyped is requiring use of function or a
228
+ // string. See also notes at
229
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/59259#issuecomment-1254405470
230
+ // An alternative fix would be to pull xml2js directly from github
231
+ // rather than using the version tagged on npmjs.com.
232
+ });
233
+ parser.parseString(file, (e, r) => { a = r; }); // TODO-LDML: isn't 'e' the error?
234
+ return a;
235
+ })();
236
+ return source;
237
+ }
238
+ /**
239
+ * @param file
240
+ * @returns source on success, otherwise null
241
+ */
242
+ load(file) {
243
+ if (!file) {
244
+ return null;
245
+ }
246
+ const source = this.loadUnboxed(file);
247
+ if (this.boxArrays(source)) {
248
+ return source;
249
+ }
250
+ else {
251
+ return null;
252
+ }
253
+ }
254
+ loadTestDataUnboxed(file) {
255
+ let source = (() => {
256
+ let a;
257
+ let parser = new xml2js.Parser({
258
+ // explicitArray: false,
259
+ preserveChildrenOrder: true,
260
+ explicitChildren: true, // needed for test data
261
+ // mergeAttrs: true,
262
+ // includeWhiteChars: false,
263
+ // emptyTag: {} as any
264
+ // Why "as any"? xml2js is broken:
265
+ // https://github.com/Leonidas-from-XIV/node-xml2js/issues/648 means
266
+ // that an old version of `emptyTag` is used which doesn't support
267
+ // functions, but DefinitelyTyped is requiring use of function or a
268
+ // string. See also notes at
269
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/59259#issuecomment-1254405470
270
+ // An alternative fix would be to pull xml2js directly from github
271
+ // rather than using the version tagged on npmjs.com.
272
+ });
273
+ parser.parseString(file, (e, r) => { a = r; }); // TODO-LDML: isn't 'e' the error?
274
+ return a; // Why 'any'? Because we need to box up the $'s into proper properties.
275
+ })();
276
+ return source;
277
+ }
278
+ /**
279
+ * Filter the obj array for a subtag
280
+ * @param source array of source objs
281
+ * @param subtag subtag to filter on
282
+ * @returns
283
+ */
284
+ findSubtagArray(source, subtag) {
285
+ return source?.filter(o => o['#name'] === subtag);
286
+ }
287
+ /**
288
+ * Get exactly one element
289
+ * @param source
290
+ * @param subtag
291
+ * @returns
292
+ */
293
+ findSubtag(source, subtag) {
294
+ const r = this.findSubtagArray(source, subtag);
295
+ if (!r || r.length === 0) {
296
+ return null;
297
+ }
298
+ else if (r.length === 1) {
299
+ return r[0];
300
+ }
301
+ else {
302
+ this.callbacks.reportMessage(CommonTypesMessages.Error_TestDataUnexpectedArray({ subtag }));
303
+ return null; // ERROR
304
+ }
305
+ }
306
+ /**
307
+ * The default test data stuffer.
308
+ * Just gets $ (the attrs) as the body.
309
+ * Override to use something more complex, such as including child nodes.
310
+ * @param o object to map
311
+ * @param r back ref to reader
312
+ */
313
+ static defaultMapper = ((o, r) => o?.$);
314
+ /**
315
+ *
316
+ * @param obj target object
317
+ * @param source array of $/#name strings
318
+ * @param subtag name to extract
319
+ * @param mapper custom mapper function
320
+ */
321
+ stuffBoxes(obj, source, subtag, asArray, mapper) {
322
+ if (!mapper) {
323
+ mapper = LDMLKeyboardXMLSourceFileReader.defaultMapper;
324
+ }
325
+ if (asArray) {
326
+ const r = this;
327
+ obj[subtag] = this.findSubtagArray(source, subtag)?.map((v) => mapper(v, r)); // extract contents only
328
+ }
329
+ else {
330
+ obj[subtag] = mapper(this.findSubtag(source, subtag), this); // run the mapper once
331
+ }
332
+ }
333
+ boxTestDataArrays(raw) {
334
+ if (!raw)
335
+ return null;
336
+ const a = {
337
+ keyboardTest: {
338
+ conformsTo: raw?.keyboardTest?.$?.conformsTo,
339
+ }
340
+ };
341
+ const $$ = raw?.keyboardTest?.$$;
342
+ this.stuffBoxes(a.keyboardTest, $$, 'info');
343
+ this.stuffBoxes(a.keyboardTest, $$, 'repertoire', true);
344
+ this.stuffBoxes(a.keyboardTest, $$, 'tests', true, (o, r) => {
345
+ // start with basic unpack
346
+ const tests = LDMLKeyboardXMLSourceFileReader.defaultMapper(o, r);
347
+ // add ingredients
348
+ r.stuffBoxes(tests, o.$$, 'test', true, (o, r) => {
349
+ // start with basic unpack
350
+ const test = LDMLKeyboardXMLSourceFileReader.defaultMapper(o, r);
351
+ // add ingredients
352
+ const $$ = o.$$;
353
+ r.stuffBoxes(test, $$, 'startContext'); // singleton
354
+ // now the actions
355
+ test.actions = $$.map(v => {
356
+ const subtag = v['#name'];
357
+ const subv = LDMLKeyboardXMLSourceFileReader.defaultMapper(v, r);
358
+ switch (subtag) {
359
+ case 'keystroke': return { keystroke: subv };
360
+ case 'check': return { check: subv };
361
+ case 'emit': return { emit: subv };
362
+ case 'startContext': return null; // handled above
363
+ default:
364
+ this.callbacks.reportMessage(CommonTypesMessages.Error_TestDataUnexpectedAction({ subtag }));
365
+ return null;
366
+ }
367
+ }).filter(v => v !== null);
368
+ return test;
369
+ });
370
+ return tests;
371
+ });
372
+ return a;
373
+ }
374
+ /**
375
+ * @param file test file
376
+ * @returns source on success, otherwise null
377
+ */
378
+ loadTestData(file) {
379
+ if (!file) {
380
+ return null;
381
+ }
382
+ const source = this.loadTestDataUnboxed(file);
383
+ return this.boxTestDataArrays(source);
384
+ }
385
+ }
386
+ //# debugId=8cf3c80a-204a-50da-9a5f-2bd1380745a8
387
+ //# sourceMappingURL=ldml-keyboard-xml-reader.js.map