@keymanapp/common-types 17.0.85-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 (248) hide show
  1. package/build/src/consts/virtual-key-constants.d.ts +131 -0
  2. package/build/src/consts/virtual-key-constants.d.ts.map +1 -0
  3. package/build/src/consts/virtual-key-constants.js +245 -0
  4. package/build/src/consts/virtual-key-constants.js.map +1 -0
  5. package/build/src/import/techpreview/cldr_info.json +5 -0
  6. package/build/src/import/techpreview/keys-Latn-implied.xml +80 -0
  7. package/build/src/import/techpreview/keys-Zyyy-currency.xml +22 -0
  8. package/build/src/import/techpreview/keys-Zyyy-punctuation.xml +46 -0
  9. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts +7 -0
  10. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts.map +1 -0
  11. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js +74 -0
  12. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js.map +1 -0
  13. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts +24 -0
  14. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts.map +1 -0
  15. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js +75 -0
  16. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js.map +1 -0
  17. package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts +76 -0
  18. package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts.map +1 -0
  19. package/build/src/keyman-touch-layout/keyman-touch-layout-file.js +26 -0
  20. package/build/src/keyman-touch-layout/keyman-touch-layout-file.js.map +1 -0
  21. package/build/src/keyman-touch-layout.clean.spec.json +170 -0
  22. package/build/src/kmx/element-string.d.ts +19 -0
  23. package/build/src/kmx/element-string.d.ts.map +1 -0
  24. package/build/src/kmx/element-string.js +72 -0
  25. package/build/src/kmx/element-string.js.map +1 -0
  26. package/build/src/kmx/kmx-builder.d.ts +77 -0
  27. package/build/src/kmx/kmx-builder.d.ts.map +1 -0
  28. package/build/src/kmx/kmx-builder.js +193 -0
  29. package/build/src/kmx/kmx-builder.js.map +1 -0
  30. package/build/src/kmx/kmx-plus-builder/build-disp.d.ts +18 -0
  31. package/build/src/kmx/kmx-plus-builder/build-disp.d.ts.map +1 -0
  32. package/build/src/kmx/kmx-plus-builder/build-disp.js +25 -0
  33. package/build/src/kmx/kmx-plus-builder/build-disp.js.map +1 -0
  34. package/build/src/kmx/kmx-plus-builder/build-elem.d.ts +26 -0
  35. package/build/src/kmx/kmx-plus-builder/build-elem.d.ts.map +1 -0
  36. package/build/src/kmx/kmx-plus-builder/build-elem.js +78 -0
  37. package/build/src/kmx/kmx-plus-builder/build-elem.js.map +1 -0
  38. package/build/src/kmx/kmx-plus-builder/build-keys.d.ts +60 -0
  39. package/build/src/kmx/kmx-plus-builder/build-keys.d.ts.map +1 -0
  40. package/build/src/kmx/kmx-plus-builder/build-keys.js +107 -0
  41. package/build/src/kmx/kmx-plus-builder/build-keys.js.map +1 -0
  42. package/build/src/kmx/kmx-plus-builder/build-layr.d.ts +54 -0
  43. package/build/src/kmx/kmx-plus-builder/build-layr.d.ts.map +1 -0
  44. package/build/src/kmx/kmx-plus-builder/build-layr.js +99 -0
  45. package/build/src/kmx/kmx-plus-builder/build-layr.js.map +1 -0
  46. package/build/src/kmx/kmx-plus-builder/build-list.d.ts +34 -0
  47. package/build/src/kmx/kmx-plus-builder/build-list.d.ts.map +1 -0
  48. package/build/src/kmx/kmx-plus-builder/build-list.js +62 -0
  49. package/build/src/kmx/kmx-plus-builder/build-list.js.map +1 -0
  50. package/build/src/kmx/kmx-plus-builder/build-loca.d.ts +12 -0
  51. package/build/src/kmx/kmx-plus-builder/build-loca.d.ts.map +1 -0
  52. package/build/src/kmx/kmx-plus-builder/build-loca.js +20 -0
  53. package/build/src/kmx/kmx-plus-builder/build-loca.js.map +1 -0
  54. package/build/src/kmx/kmx-plus-builder/build-meta.d.ts +17 -0
  55. package/build/src/kmx/kmx-plus-builder/build-meta.d.ts.map +1 -0
  56. package/build/src/kmx/kmx-plus-builder/build-meta.js +21 -0
  57. package/build/src/kmx/kmx-plus-builder/build-meta.js.map +1 -0
  58. package/build/src/kmx/kmx-plus-builder/build-name.d.ts +12 -0
  59. package/build/src/kmx/kmx-plus-builder/build-name.d.ts.map +1 -0
  60. package/build/src/kmx/kmx-plus-builder/build-name.js +23 -0
  61. package/build/src/kmx/kmx-plus-builder/build-name.js.map +1 -0
  62. package/build/src/kmx/kmx-plus-builder/build-ordr.d.ts +18 -0
  63. package/build/src/kmx/kmx-plus-builder/build-ordr.d.ts.map +1 -0
  64. package/build/src/kmx/kmx-plus-builder/build-ordr.js +27 -0
  65. package/build/src/kmx/kmx-plus-builder/build-ordr.js.map +1 -0
  66. package/build/src/kmx/kmx-plus-builder/build-sect.d.ts +16 -0
  67. package/build/src/kmx/kmx-plus-builder/build-sect.d.ts.map +1 -0
  68. package/build/src/kmx/kmx-plus-builder/build-sect.js +14 -0
  69. package/build/src/kmx/kmx-plus-builder/build-sect.js.map +1 -0
  70. package/build/src/kmx/kmx-plus-builder/build-strs.d.ts +18 -0
  71. package/build/src/kmx/kmx-plus-builder/build-strs.d.ts.map +1 -0
  72. package/build/src/kmx/kmx-plus-builder/build-strs.js +34 -0
  73. package/build/src/kmx/kmx-plus-builder/build-strs.js.map +1 -0
  74. package/build/src/kmx/kmx-plus-builder/build-tran.d.ts +20 -0
  75. package/build/src/kmx/kmx-plus-builder/build-tran.d.ts.map +1 -0
  76. package/build/src/kmx/kmx-plus-builder/build-tran.js +30 -0
  77. package/build/src/kmx/kmx-plus-builder/build-tran.js.map +1 -0
  78. package/build/src/kmx/kmx-plus-builder/build-vkey.d.ts +16 -0
  79. package/build/src/kmx/kmx-plus-builder/build-vkey.d.ts.map +1 -0
  80. package/build/src/kmx/kmx-plus-builder/build-vkey.js +23 -0
  81. package/build/src/kmx/kmx-plus-builder/build-vkey.js.map +1 -0
  82. package/build/src/kmx/kmx-plus-builder/builder-section.d.ts +6 -0
  83. package/build/src/kmx/kmx-plus-builder/builder-section.d.ts.map +1 -0
  84. package/build/src/kmx/kmx-plus-builder/builder-section.js +3 -0
  85. package/build/src/kmx/kmx-plus-builder/builder-section.js.map +1 -0
  86. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts +47 -0
  87. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts.map +1 -0
  88. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js +143 -0
  89. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js.map +1 -0
  90. package/build/src/kmx/kmx-plus.d.ts +259 -0
  91. package/build/src/kmx/kmx-plus.d.ts.map +1 -0
  92. package/build/src/kmx/kmx-plus.js +594 -0
  93. package/build/src/kmx/kmx-plus.js.map +1 -0
  94. package/build/src/kmx/kmx.d.ts +166 -0
  95. package/build/src/kmx/kmx.d.ts.map +1 -0
  96. package/build/src/kmx/kmx.js +271 -0
  97. package/build/src/kmx/kmx.js.map +1 -0
  98. package/build/src/kmx/string-list.d.ts +29 -0
  99. package/build/src/kmx/string-list.d.ts.map +1 -0
  100. package/build/src/kmx/string-list.js +75 -0
  101. package/build/src/kmx/string-list.js.map +1 -0
  102. package/build/src/kpj/keyman-developer-project.d.ts +58 -0
  103. package/build/src/kpj/keyman-developer-project.d.ts.map +1 -0
  104. package/build/src/kpj/keyman-developer-project.js +141 -0
  105. package/build/src/kpj/keyman-developer-project.js.map +1 -0
  106. package/build/src/kpj/kpj-file-reader.d.ts +17 -0
  107. package/build/src/kpj/kpj-file-reader.d.ts.map +1 -0
  108. package/build/src/kpj/kpj-file-reader.js +92 -0
  109. package/build/src/kpj/kpj-file-reader.js.map +1 -0
  110. package/build/src/kpj/kpj-file.d.ts +39 -0
  111. package/build/src/kpj/kpj-file.d.ts.map +1 -0
  112. package/build/src/kpj/kpj-file.js +11 -0
  113. package/build/src/kpj/kpj-file.js.map +1 -0
  114. package/build/src/kpj.schema.json +127 -0
  115. package/build/src/kvk/kvk-file-reader.d.ts +5 -0
  116. package/build/src/kvk/kvk-file-reader.d.ts.map +1 -0
  117. package/build/src/kvk/kvk-file-reader.js +35 -0
  118. package/build/src/kvk/kvk-file-reader.js.map +1 -0
  119. package/build/src/kvk/kvk-file-writer.d.ts +20 -0
  120. package/build/src/kvk/kvk-file-writer.d.ts.map +1 -0
  121. package/build/src/kvk/kvk-file-writer.js +67 -0
  122. package/build/src/kvk/kvk-file-writer.js.map +1 -0
  123. package/build/src/kvk/kvk-file.d.ts +64 -0
  124. package/build/src/kvk/kvk-file.d.ts.map +1 -0
  125. package/build/src/kvk/kvk-file.js +63 -0
  126. package/build/src/kvk/kvk-file.js.map +1 -0
  127. package/build/src/kvk/kvks-file-reader.d.ts +30 -0
  128. package/build/src/kvk/kvks-file-reader.d.ts.map +1 -0
  129. package/build/src/kvk/kvks-file-reader.js +154 -0
  130. package/build/src/kvk/kvks-file-reader.js.map +1 -0
  131. package/build/src/kvk/kvks-file-writer.d.ts +6 -0
  132. package/build/src/kvk/kvks-file-writer.d.ts.map +1 -0
  133. package/build/src/kvk/kvks-file-writer.js +99 -0
  134. package/build/src/kvk/kvks-file-writer.js.map +1 -0
  135. package/build/src/kvk/kvks-file.d.ts +44 -0
  136. package/build/src/kvk/kvks-file.d.ts.map +1 -0
  137. package/build/src/kvk/kvks-file.js +10 -0
  138. package/build/src/kvk/kvks-file.js.map +1 -0
  139. package/build/src/kvk/visual-keyboard.d.ts +35 -0
  140. package/build/src/kvk/visual-keyboard.d.ts.map +1 -0
  141. package/build/src/kvk/visual-keyboard.js +61 -0
  142. package/build/src/kvk/visual-keyboard.js.map +1 -0
  143. package/build/src/kvks.schema.json +182 -0
  144. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts +56 -0
  145. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts.map +1 -0
  146. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js +20 -0
  147. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js.map +1 -0
  148. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts +91 -0
  149. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts.map +1 -0
  150. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js +370 -0
  151. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js.map +1 -0
  152. package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts +143 -0
  153. package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts.map +1 -0
  154. package/build/src/ldml-keyboard/ldml-keyboard-xml.js +34 -0
  155. package/build/src/ldml-keyboard/ldml-keyboard-xml.js.map +1 -0
  156. package/build/src/ldml-keyboard.schema.json +634 -0
  157. package/build/src/ldml-keyboardtest.schema.json +221 -0
  158. package/build/src/main.d.ts +21 -0
  159. package/build/src/main.d.ts.map +1 -0
  160. package/build/src/main.js +20 -0
  161. package/build/src/main.js.map +1 -0
  162. package/build/src/util/common-events.d.ts +49 -0
  163. package/build/src/util/common-events.d.ts.map +1 -0
  164. package/build/src/util/common-events.js +29 -0
  165. package/build/src/util/common-events.js.map +1 -0
  166. package/build/src/util/compiler-interfaces.d.ts +51 -0
  167. package/build/src/util/compiler-interfaces.d.ts.map +1 -0
  168. package/build/src/util/compiler-interfaces.js +33 -0
  169. package/build/src/util/compiler-interfaces.js.map +1 -0
  170. package/build/src/util/util.d.ts +17 -0
  171. package/build/src/util/util.d.ts.map +1 -0
  172. package/build/src/util/util.js +67 -0
  173. package/build/src/util/util.js.map +1 -0
  174. package/build/tsconfig.tsbuildinfo +1 -0
  175. package/build.sh +86 -0
  176. package/package.json +58 -0
  177. package/src/consts/virtual-key-constants.ts +257 -0
  178. package/src/keyman-touch-layout/keyman-touch-layout-file-reader.ts +81 -0
  179. package/src/keyman-touch-layout/keyman-touch-layout-file-writer.ts +84 -0
  180. package/src/keyman-touch-layout/keyman-touch-layout-file.ts +87 -0
  181. package/src/kmx/element-string.ts +79 -0
  182. package/src/kmx/kmx-builder.ts +287 -0
  183. package/src/kmx/kmx-plus-builder/build-disp.ts +46 -0
  184. package/src/kmx/kmx-plus-builder/build-elem.ts +103 -0
  185. package/src/kmx/kmx-plus-builder/build-keys.ts +175 -0
  186. package/src/kmx/kmx-plus-builder/build-layr.ts +154 -0
  187. package/src/kmx/kmx-plus-builder/build-list.ts +95 -0
  188. package/src/kmx/kmx-plus-builder/build-loca.ts +34 -0
  189. package/src/kmx/kmx-plus-builder/build-meta.ts +37 -0
  190. package/src/kmx/kmx-plus-builder/build-name.ts +37 -0
  191. package/src/kmx/kmx-plus-builder/build-ordr.ts +45 -0
  192. package/src/kmx/kmx-plus-builder/build-sect.ts +31 -0
  193. package/src/kmx/kmx-plus-builder/build-strs.ts +58 -0
  194. package/src/kmx/kmx-plus-builder/build-tran.ts +50 -0
  195. package/src/kmx/kmx-plus-builder/build-vkey.ts +43 -0
  196. package/src/kmx/kmx-plus-builder/builder-section.ts +6 -0
  197. package/src/kmx/kmx-plus-builder/kmx-plus-builder.ts +190 -0
  198. package/src/kmx/kmx-plus.ts +692 -0
  199. package/src/kmx/kmx.ts +360 -0
  200. package/src/kmx/string-list.ts +74 -0
  201. package/src/kpj/keyman-developer-project.ts +155 -0
  202. package/src/kpj/kpj-file-reader.ts +103 -0
  203. package/src/kpj/kpj-file.ts +52 -0
  204. package/src/kvk/kvk-file-reader.ts +34 -0
  205. package/src/kvk/kvk-file-writer.ts +72 -0
  206. package/src/kvk/kvk-file.ts +122 -0
  207. package/src/kvk/kvks-file-reader.ts +164 -0
  208. package/src/kvk/kvks-file-writer.ts +113 -0
  209. package/src/kvk/kvks-file.ts +53 -0
  210. package/src/kvk/visual-keyboard.ts +80 -0
  211. package/src/ldml-keyboard/ldml-keyboard-testdata-xml.ts +74 -0
  212. package/src/ldml-keyboard/ldml-keyboard-xml-reader.ts +387 -0
  213. package/src/ldml-keyboard/ldml-keyboard-xml.ts +177 -0
  214. package/src/main.ts +27 -0
  215. package/src/restructure.d.ts +2 -0
  216. package/src/util/common-events.ts +50 -0
  217. package/src/util/compiler-interfaces.ts +54 -0
  218. package/src/util/util.ts +68 -0
  219. package/test/fixtures/import-minimal.xml +8 -0
  220. package/test/fixtures/import-minimal1.xml +11 -0
  221. package/test/fixtures/import-minimal2.xml +11 -0
  222. package/test/fixtures/import-symbols.xml +13 -0
  223. package/test/fixtures/invalid-conforms-to.xml +19 -0
  224. package/test/fixtures/invalid-import-base.xml +16 -0
  225. package/test/fixtures/invalid-import-path.xml +16 -0
  226. package/test/fixtures/invalid-import-readfail.xml +16 -0
  227. package/test/fixtures/invalid-import-wrongroot.xml +16 -0
  228. package/test/fixtures/invalid-structure-per-dtd.xml +8 -0
  229. package/test/fixtures/keyman-touch-layout/khmer_angkor.keyman-touch-layout +1950 -0
  230. package/test/fixtures/keyman-touch-layout/legacy.keyman-touch-layout +36 -0
  231. package/test/fixtures/kpj/khmer_angkor.kpj +187 -0
  232. package/test/fixtures/kvk/khmer_angkor.kvk +0 -0
  233. package/test/fixtures/kvk/khmer_angkor.kvks +206 -0
  234. package/test/fixtures/test-fr.xml +22 -0
  235. package/test/helpers/index.ts +39 -0
  236. package/test/helpers/reader-callback-test.ts +199 -0
  237. package/test/keyman-touch-layout/test-keyman-touch-layout-file-reader.ts +71 -0
  238. package/test/keyman-touch-layout/test-keyman-touch-layout-round-trip.ts +35 -0
  239. package/test/kpj/test-kpj-file-reader.ts +123 -0
  240. package/test/kvk/test-kvk-file.ts +15 -0
  241. package/test/kvk/test-kvk-round-trip.ts +87 -0
  242. package/test/kvk/test-kvk-utils.ts +24 -0
  243. package/test/kvk/test-kvks-file.ts +45 -0
  244. package/test/ldml-keyboard/test-ldml-keyboard-testdata-reader.ts +51 -0
  245. package/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts +131 -0
  246. package/test/tsconfig.json +21 -0
  247. package/test/util/test-unescape.ts +38 -0
  248. package/tsconfig.json +17 -0
@@ -0,0 +1,141 @@
1
+ //
2
+ // Version 1.0 of Keyman Developer Project .kpj file
3
+ //
4
+ import * as path from 'path';
5
+ import * as fs from 'fs';
6
+ export class KeymanDeveloperProject {
7
+ options;
8
+ files;
9
+ constructor(version) {
10
+ this.options = new KeymanDeveloperProjectOptions(version);
11
+ this.files = [];
12
+ }
13
+ /**
14
+ * Adds .kmn, .xml, .kps to project based on options.sourcePath
15
+ * @param projectPath Full path to project.kpj (even if the file doesn't exist)
16
+ */
17
+ populateFiles(projectPath) {
18
+ if (this.options.version != '2.0') {
19
+ throw new Error('populateFiles can only be called on a v2.0 project');
20
+ }
21
+ let sourcePath = this.resolveProjectPath(projectPath, this.options.sourcePath);
22
+ let files = fs.readdirSync(sourcePath);
23
+ for (let filename of files) {
24
+ let fullPath = path.join(sourcePath, filename);
25
+ if (filename.match(/\.xml$/i)) {
26
+ if (!fs.readFileSync(fullPath, 'utf-8').match(/ldmlKeyboard\.dtd/)) {
27
+ // Skip this .xml because we assume it isn't really a keyboard .xml
28
+ continue;
29
+ }
30
+ }
31
+ if (filename.match(/\.(kmn|kps|xml|model\.ts)$/i)) {
32
+ let file = new KeymanDeveloperProjectFile20(fullPath);
33
+ this.files.push(file);
34
+ }
35
+ }
36
+ }
37
+ resolveProjectPath(projectPath, p) {
38
+ // Replace placeholders in the target path
39
+ return p.replace('$PROJECTPATH', path.dirname(projectPath));
40
+ }
41
+ resolveInputFilePath(projectPath, file) {
42
+ let p = path.dirname(projectPath);
43
+ return path.normalize(path.resolve(p, file.filePath));
44
+ }
45
+ resolveOutputFilePath(projectPath, file, sourceExt, targetExt) {
46
+ // Roughly corresponds to Delphi TProject.GetTargetFileName
47
+ let p = this.options.version == '1.0' ?
48
+ this.options.buildPath || '$SOURCEPATH' :
49
+ this.options.buildPath;
50
+ // Replace placeholders in the target path
51
+ if (this.options.version == '1.0') {
52
+ // TODO: do we need to support $VERSION?
53
+ // $SOURCEPATH only supported in 1.0 projects
54
+ p = p.replace('$SOURCEPATH', path.dirname(this.resolveInputFilePath(projectPath, file)));
55
+ }
56
+ p = this.resolveProjectPath(projectPath, p);
57
+ let f = file.filename.replace(new RegExp(`\\${sourceExt}$`, 'i'), targetExt);
58
+ return path.normalize(path.join(p, f));
59
+ }
60
+ }
61
+ ;
62
+ export var KeymanDeveloperProjectType;
63
+ (function (KeymanDeveloperProjectType) {
64
+ KeymanDeveloperProjectType[KeymanDeveloperProjectType["Keyboard"] = 0] = "Keyboard";
65
+ KeymanDeveloperProjectType[KeymanDeveloperProjectType["LexicalModel"] = 1] = "LexicalModel";
66
+ })(KeymanDeveloperProjectType || (KeymanDeveloperProjectType = {}));
67
+ ;
68
+ export class KeymanDeveloperProjectOptions {
69
+ buildPath;
70
+ sourcePath;
71
+ compilerWarningsAsErrors = false;
72
+ warnDeprecatedCode = true;
73
+ checkFilenameConventions = true;
74
+ projectType = KeymanDeveloperProjectType.Keyboard;
75
+ version;
76
+ constructor(version) {
77
+ this.version = version;
78
+ switch (version) {
79
+ case "1.0":
80
+ this.buildPath = '';
81
+ this.sourcePath = '';
82
+ break;
83
+ case "2.0":
84
+ this.buildPath = '$PROJECTPATH/build';
85
+ this.sourcePath = '$PROJECTPATH/source';
86
+ break;
87
+ default:
88
+ throw new Error('Invalid version');
89
+ }
90
+ }
91
+ }
92
+ ;
93
+ export class KeymanDeveloperProjectFile10 {
94
+ id; // 1.0 only
95
+ filename;
96
+ filePath;
97
+ fileVersion; // 1.0 only
98
+ fileType; // file extension of filename, but .model.ts is technically not the ext because of 2 periods
99
+ details; // 1.0 only
100
+ childFiles; // 1.0 only
101
+ constructor(id, filename, filePath, fileVersion, fileType) {
102
+ this.details = {};
103
+ this.childFiles = [];
104
+ this.id = id;
105
+ this.filename = filename;
106
+ this.filePath = filePath;
107
+ this.fileVersion = fileVersion;
108
+ this.fileType = fileType;
109
+ }
110
+ }
111
+ ;
112
+ export class KeymanDeveloperProjectFile20 {
113
+ filename;
114
+ filePath;
115
+ fileType; // file extension of filename, but .model.ts is technically not the ext because of 2 periods
116
+ constructor(filePath) {
117
+ this.filename = path.basename(filePath);
118
+ this.filePath = filePath;
119
+ if (this.filename.match(/\.model\.ts$/)) {
120
+ // .model.ts is a bit of a hassle...
121
+ this.fileType = '.model.ts';
122
+ }
123
+ else {
124
+ this.fileType = path.extname(this.filename);
125
+ }
126
+ }
127
+ }
128
+ ;
129
+ export class KeymanDeveloperProjectFileDetail_Kps {
130
+ name;
131
+ copyright;
132
+ version;
133
+ }
134
+ ;
135
+ export class KeymanDeveloperProjectFileDetail_Kmn {
136
+ name;
137
+ copyright;
138
+ message;
139
+ }
140
+ ;
141
+ //# sourceMappingURL=keyman-developer-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyman-developer-project.js","sourceRoot":"","sources":["../../../src/kpj/keyman-developer-project.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,oDAAoD;AACpD,EAAE;AAEF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,MAAM,OAAO,sBAAsB;IACjC,OAAO,CAAgC;IACvC,KAAK,CAA+B;IACpC,YAAY,OAAsC;QAChD,IAAI,CAAC,OAAO,GAAG,IAAI,6BAA6B,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IACD;;;OAGG;IACH,aAAa,CAAC,WAAmB;QAC/B,IAAG,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,KAAK,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;SACvE;QAED,IAAI,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC/E,IAAI,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QACvC,KAAI,IAAI,QAAQ,IAAI,KAAK,EAAE;YACzB,IAAI,QAAQ,GA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S,CAAU;IACnB,OAAO,CAAU;CAClB;AAAA,CAAC;AAEF,MAAM,OAAO,oCAAoC;IAC/C,IAAI,CAAU;IACd,SAAS,CAAU;IACnB,OAAO,CAAU;CAClB;AAAA,CAAC"}
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { KPJFile } from './kpj-file.js';
3
+ import { KeymanDeveloperProject } from './keyman-developer-project.js';
4
+ export declare class KPJFileReader {
5
+ read(file: Uint8Array): KPJFile;
6
+ validate(source: KPJFile, schemaBuffer: Buffer): void;
7
+ private boolFromString;
8
+ transform(projectPath: string, source: KPJFile): KeymanDeveloperProject;
9
+ private transformFilesVersion10;
10
+ /**
11
+ * xml2js will not place single-entry objects into arrays.
12
+ * Easiest way to fix this is to box them ourselves as needed
13
+ * @param source KVKSourceFile
14
+ */
15
+ private boxArrays;
16
+ }
17
+ //# sourceMappingURL=kpj-file-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kpj-file-reader.d.ts","sourceRoot":"","sources":["../../../src/kpj/kpj-file-reader.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAkB,MAAM,eAAe,CAAC;AAIxD,OAAO,EAAE,sBAAsB,EAA4D,MAAM,+BAA+B,CAAC;AAEjI,qBAAa,aAAa;IACjB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO;IAgB/B,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAQ5D,OAAO,CAAC,cAAc;IAOf,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,sBAAsB;IA6B9E,OAAO,CAAC,uBAAuB;IAyB/B;;;;OAIG;IACH,OAAO,CAAC,SAAS;CAIlB"}
@@ -0,0 +1,92 @@
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 { KeymanDeveloperProject, KeymanDeveloperProjectFile10, KeymanDeveloperProjectType } from './keyman-developer-project.js';
6
+ export class KPJFileReader {
7
+ read(file) {
8
+ let data;
9
+ const parser = new xml2js.Parser({
10
+ explicitArray: false,
11
+ mergeAttrs: false,
12
+ includeWhiteChars: false,
13
+ normalize: false,
14
+ emptyTag: ''
15
+ });
16
+ parser.parseString(file, (e, r) => { data = r; });
17
+ data = this.boxArrays(data);
18
+ return data;
19
+ }
20
+ validate(source, schemaBuffer) {
21
+ const schema = JSON.parse(schemaBuffer.toString('utf8'));
22
+ const ajv = new Ajv();
23
+ if (!ajv.validate(schema, source)) {
24
+ throw new Error(ajv.errorsText());
25
+ }
26
+ }
27
+ boolFromString(value, def) {
28
+ value = (value || '').toLowerCase();
29
+ if (value === 'true')
30
+ return true;
31
+ if (value === 'false')
32
+ return false;
33
+ return def;
34
+ }
35
+ transform(projectPath, source) {
36
+ // NOTE: at this point, the xml should have been validated
37
+ // and matched the schema result so we can assume the source
38
+ // is a valid shape
39
+ let project = source.KeymanDeveloperProject;
40
+ let result = new KeymanDeveloperProject(project.Options?.Version || "1.0");
41
+ if (result.options.version == '2.0') {
42
+ result.options.buildPath = (project.Options?.BuildPath || result.options.buildPath).replace(/\\/g, '/');
43
+ result.options.sourcePath = (project.Options?.SourcePath || result.options.sourcePath).replace(/\\/g, '/');
44
+ }
45
+ else {
46
+ result.options.buildPath = (project.Options?.BuildPath || '').replace(/\\/g, '/');
47
+ }
48
+ result.options.checkFilenameConventions = this.boolFromString(project.Options?.CheckFilenameConventions, true);
49
+ result.options.compilerWarningsAsErrors = this.boolFromString(project.Options?.CompilerWarningsAsErrors, false);
50
+ result.options.warnDeprecatedCode = this.boolFromString(project.Options?.WarnDeprecatedCode, true);
51
+ result.options.projectType =
52
+ project.Options?.ProjectType == 'keyboard' ? KeymanDeveloperProjectType.Keyboard :
53
+ project.Options?.ProjectType == 'lexicalmodel' ? KeymanDeveloperProjectType.LexicalModel :
54
+ KeymanDeveloperProjectType.Keyboard; // Default is keyboard if missing
55
+ if (result.options.version == '1.0') {
56
+ this.transformFilesVersion10(project, result);
57
+ }
58
+ else {
59
+ result.populateFiles(projectPath);
60
+ }
61
+ return result;
62
+ }
63
+ transformFilesVersion10(project, result) {
64
+ let ids = {};
65
+ for (let sourceFile of project.Files?.File) {
66
+ let file = new KeymanDeveloperProjectFile10(sourceFile.ID || '', sourceFile.Filename || '', (sourceFile.Filepath || '').replace(/\\/g, '/'), sourceFile.FileVersion || '', sourceFile.FileType || '');
67
+ if (sourceFile.Details) {
68
+ file.details.copyright = sourceFile.Details.Copyright;
69
+ file.details.name = sourceFile.Details.Name;
70
+ file.details.message = sourceFile.Details.Message;
71
+ file.details.version = sourceFile.Details.Version;
72
+ }
73
+ if (sourceFile.ParentFileID && ids[sourceFile.ParentFileID]) {
74
+ ids[sourceFile.ParentFileID].childFiles.push(file);
75
+ }
76
+ else {
77
+ result.files.push(file);
78
+ ids[file.id] = file;
79
+ }
80
+ }
81
+ }
82
+ /**
83
+ * xml2js will not place single-entry objects into arrays.
84
+ * Easiest way to fix this is to box them ourselves as needed
85
+ * @param source KVKSourceFile
86
+ */
87
+ boxArrays(source) {
88
+ boxXmlArray(source.KeymanDeveloperProject?.Files, 'File');
89
+ return source;
90
+ }
91
+ }
92
+ //# sourceMappingURL=kpj-file-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kpj-file-reader.js","sourceRoot":"","sources":["../../../src/kpj/kpj-file-reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,KAAK,CAAC;AAC3C,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,gCAAgC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,0BAA0B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AC,UAAU,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACpD;iBAAM;gBACL,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACxB,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;aACrB;SACF;IACH,CAAC;IAED;;;;OAIG;IACK,SAAS,CAAC,MAAe;QAC/B,WAAW,CAAC,MAAM,CAAC,sBAAsB,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1D,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,39 @@
1
+ export interface KPJFile {
2
+ KeymanDeveloperProject: KPJFileProject;
3
+ }
4
+ export interface KPJFileProject {
5
+ Options?: KPJFileOptions;
6
+ Files?: KPJFileFiles;
7
+ }
8
+ export interface KPJFileOptions {
9
+ BuildPath?: string;
10
+ SourcePath?: string;
11
+ CompilerWarningsAsErrors?: string;
12
+ WarnDeprecatedCode?: string;
13
+ CheckFilenameConventions?: string;
14
+ ProjectType?: 'keyboard' | 'lexicalmodel';
15
+ Version?: '1.0' | '2.0';
16
+ }
17
+ export interface KPJFileFiles {
18
+ File?: KPJFileFile[];
19
+ }
20
+ export interface KPJFileFile {
21
+ ID?: string;
22
+ Filename?: string;
23
+ Filepath?: string;
24
+ FileVersion?: string;
25
+ FileType?: string;
26
+ Details?: KPJFileFileDetail_Kmn & KPJFileFileDetail_Kps;
27
+ ParentFileID?: string;
28
+ }
29
+ export interface KPJFileFileDetail_Kmn {
30
+ Name?: string;
31
+ Copyright?: string;
32
+ Message?: string;
33
+ }
34
+ export interface KPJFileFileDetail_Kps {
35
+ Name?: string;
36
+ Copyright?: string;
37
+ Version?: string;
38
+ }
39
+ //# sourceMappingURL=kpj-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kpj-file.d.ts","sourceRoot":"","sources":["../../../src/kpj/kpj-file.ts"],"names":[],"mappings":"A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
+ ;
10
+ export {};
11
+ //# sourceMappingURL=kpj-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kpj-file.js","sourceRoot":"","sources":["../../../src/kpj/kpj-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaF,CAAC;AAUD,CAAC;AAID,CAAC;AAUD,CAAC;AAMD,CAAC;AAMD,CAAC"}
@@ -0,0 +1,127 @@
1
+ {
2
+ "title": "kpj.xsd",
3
+ "$schema": "http://json-schema.org/schema#",
4
+ "type": "object",
5
+ "properties": {
6
+ "KeymanDeveloperProject": {
7
+ "properties": {
8
+ "Options": {
9
+ "$ref": "#/definitions/Options"
10
+ },
11
+ "Files": {
12
+ "$ref": "#/definitions/Files"
13
+ }
14
+ },
15
+ "required": [
16
+ "Options"
17
+ ],
18
+ "additionalProperties": false,
19
+ "type": "object"
20
+ }
21
+ },
22
+ "required": [
23
+ "KeymanDeveloperProject"
24
+ ],
25
+ "additionalProperties": false,
26
+ "definitions": {
27
+ "Options": {
28
+ "type": "object",
29
+ "properties": {
30
+ "BuildPath": {
31
+ "type": "string"
32
+ },
33
+ "SourcePath": {
34
+ "type": "string"
35
+ },
36
+ "CompilerWarningsAsErrors": {
37
+ "type": "string",
38
+ "pattern": "^(True|False)$"
39
+ },
40
+ "WarnDeprecatedCode": {
41
+ "type": "string",
42
+ "pattern": "^(True|False)$"
43
+ },
44
+ "CheckFilenameConventions": {
45
+ "type": "string",
46
+ "pattern": "^(True|False)$"
47
+ },
48
+ "ProjectType": {
49
+ "type": "string",
50
+ "pattern": "^(keyboard|lexicalmodel)$"
51
+ },
52
+ "Version": {
53
+ "type": "string",
54
+ "pattern": "^(1\\.0|2\\.0)$"
55
+ }
56
+ },
57
+ "required": [
58
+ ],
59
+ "additionalProperties": false
60
+ },
61
+ "Files": {
62
+ "type": "object",
63
+ "properties": {
64
+ "File": {
65
+ "type": "array",
66
+ "items": {
67
+ "$ref": "#/definitions/File"
68
+ }
69
+ }
70
+ },
71
+ "additionalProperties": false,
72
+ "required": [
73
+ "File"
74
+ ]
75
+ },
76
+ "File": {
77
+ "type": "object",
78
+ "properties": {
79
+ "ID": {
80
+ "type": "string"
81
+ },
82
+ "Filename": {
83
+ "type": "string"
84
+ },
85
+ "Filepath": {
86
+ "type": "string"
87
+ },
88
+ "FileVersion": {
89
+ "type": "string"
90
+ },
91
+ "FileType": {
92
+ "type": "string"
93
+ },
94
+ "Details": {
95
+ "$ref": "#/definitions/FileDetails"
96
+ },
97
+ "ParentFileID": {
98
+ "type": "string"
99
+ }
100
+ },
101
+ "required": [
102
+ "Filename"
103
+ ],
104
+ "additionalProperties": false
105
+ },
106
+ "FileDetails": {
107
+ "type": "object",
108
+ "properties": {
109
+ "Name": {
110
+ "type": "string"
111
+ },
112
+ "Copyright": {
113
+ "type": "string"
114
+ },
115
+ "Message": {
116
+ "type": "string"
117
+ },
118
+ "Version": {
119
+ "type": "string"
120
+ }
121
+ },
122
+ "required": [
123
+ ],
124
+ "additionalProperties": false
125
+ }
126
+ }
127
+ }
@@ -0,0 +1,5 @@
1
+ import { VisualKeyboard } from "./visual-keyboard.js";
2
+ export default class KvkFileReader {
3
+ read(source: Uint8Array): VisualKeyboard;
4
+ }
5
+ //# sourceMappingURL=kvk-file-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kvk-file-reader.d.ts","sourceRoot":"","sources":["../../../src/kvk/kvk-file-reader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAqB,MAAM,sBAAsB,CAAC;AAEzE,MAAM,CAAC,OAAO,OAAO,aAAa;IACzB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,cAAc;CA6BhD"}
@@ -0,0 +1,35 @@
1
+ import KVKFile, { BUILDER_KVK_HEADER_IDENTIFIER, BUILDER_KVK_HEADER_VERSION } from "./kvk-file.js";
2
+ import { VisualKeyboard } from "./visual-keyboard.js";
3
+ export default class KvkFileReader {
4
+ read(source) {
5
+ let binary;
6
+ let kvk = new KVKFile();
7
+ binary = kvk.KVK_FILE.fromBuffer(source);
8
+ if (binary.header.identifier != BUILDER_KVK_HEADER_IDENTIFIER ||
9
+ binary.header.version != BUILDER_KVK_HEADER_VERSION) {
10
+ return null;
11
+ }
12
+ let result = new VisualKeyboard();
13
+ result.header.version = binary.header.version;
14
+ result.header.flags = binary.header.flags;
15
+ result.header.associatedKeyboard = binary.header.associatedKeyboard.str;
16
+ result.header.ansiFont.color = binary.header.ansiFont.color;
17
+ result.header.ansiFont.name = binary.header.ansiFont.name.str;
18
+ result.header.ansiFont.size = binary.header.ansiFont.size;
19
+ result.header.unicodeFont.color = binary.header.unicodeFont.color;
20
+ result.header.unicodeFont.name = binary.header.unicodeFont.name.str;
21
+ result.header.unicodeFont.size = binary.header.unicodeFont.size;
22
+ for (let binaryKey of binary.keys) {
23
+ let key = {
24
+ flags: binaryKey.flags,
25
+ vkey: binaryKey.vkey,
26
+ shift: binaryKey.shift,
27
+ text: binaryKey.text.str
28
+ };
29
+ result.keys.push(key);
30
+ }
31
+ return result;
32
+ }
33
+ }
34
+ ;
35
+ //# sourceMappingURL=kvk-file-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kvk-file-reader.js","sourceRoot":"","sources":["../../../src/kvk/kvk-file-reader.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAoB,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AACrH,OAAO,EAAE,cAAc,EAAqB,MAAM,sBAAsB,CAAC;AAEzE,MAAM,CAAC,OAAO,OAAO,aAAa;IACzB,IAAI,CAAC,MAAkB;QAC5B,IAAI,MAAwB,CAAC;QAC7B,IAAI,GAAG,GAAG,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzC,IAAG,MAAM,CAAC,MAAM,CAAC,UAAU,IAAI,6BAA6B;YACxD,MAAM,CAAC,MAAM,CAAC,OAAO,IA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GAAG;aACzB,CAAC;YACF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACvB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAAA,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { VisualKeyboard } from "./visual-keyboard.js";
2
+ export default class KvkFileWriter {
3
+ /**
4
+ * Writes the visual keyboard to a binary .kvk format byte array.
5
+ * @param source VisualKeyboard
6
+ * @returns Uint8Array, the .kvk file
7
+ */
8
+ write(source: VisualKeyboard): Uint8Array;
9
+ private build;
10
+ /**
11
+ * Fills a kvk string from a source string. Note that the format includes both
12
+ * a length word and zero termination.
13
+ *
14
+ * @param str
15
+ * @param value
16
+ * @returns number
17
+ */
18
+ private setString;
19
+ }
20
+ //# sourceMappingURL=kvk-file-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kvk-file-writer.d.ts","sourceRoot":"","sources":["../../../src/kvk/kvk-file-writer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU;IASzC,OAAO,CAAC,KAAK;IAyCb;;;;;;;OAOG;IACF,OAAO,CAAC,SAAS;CAInB"}
@@ -0,0 +1,67 @@
1
+ import KVKFile, { BUILDER_KVK_HEADER_IDENTIFIER, BUILDER_KVK_HEADER_VERSION } from "./kvk-file.js";
2
+ export default class KvkFileWriter {
3
+ /**
4
+ * Writes the visual keyboard to a binary .kvk format byte array.
5
+ * @param source VisualKeyboard
6
+ * @returns Uint8Array, the .kvk file
7
+ */
8
+ write(source) {
9
+ const binary = this.build(source);
10
+ const kvk = new KVKFile();
11
+ const file = new Uint8Array(kvk.KVK_FILE.size(binary));
12
+ const data = kvk.KVK_FILE.toBuffer(binary);
13
+ file.set(data, 0);
14
+ return file;
15
+ }
16
+ build(source) {
17
+ const binary = {
18
+ header: {
19
+ identifier: BUILDER_KVK_HEADER_IDENTIFIER,
20
+ version: BUILDER_KVK_HEADER_VERSION,
21
+ associatedKeyboard: { len: 0, str: '' },
22
+ flags: source.header.flags,
23
+ ansiFont: {
24
+ color: source.header.ansiFont.color,
25
+ size: source.header.ansiFont.size,
26
+ name: { len: 0, str: '' }
27
+ },
28
+ unicodeFont: {
29
+ color: source.header.unicodeFont.color,
30
+ size: source.header.unicodeFont.size,
31
+ name: { len: 0, str: '' }
32
+ },
33
+ },
34
+ keyCount: source.keys.length,
35
+ keys: []
36
+ };
37
+ this.setString(binary.header.associatedKeyboard, source.header.associatedKeyboard);
38
+ this.setString(binary.header.ansiFont.name, source.header.ansiFont.name);
39
+ this.setString(binary.header.unicodeFont.name, source.header.unicodeFont.name);
40
+ for (let sourceKey of source.keys) {
41
+ const binaryKey = {
42
+ flags: sourceKey.flags,
43
+ vkey: sourceKey.vkey,
44
+ shift: sourceKey.shift,
45
+ text: { len: 0, str: '' },
46
+ bitmap: 0
47
+ };
48
+ this.setString(binaryKey.text, sourceKey.text || '');
49
+ binary.keys.push(binaryKey);
50
+ }
51
+ return binary;
52
+ }
53
+ /**
54
+ * Fills a kvk string from a source string. Note that the format includes both
55
+ * a length word and zero termination.
56
+ *
57
+ * @param str
58
+ * @param value
59
+ * @returns number
60
+ */
61
+ setString(str, value) {
62
+ str.len = value.length + 1;
63
+ str.str = value;
64
+ }
65
+ }
66
+ ;
67
+ //# sourceMappingURL=kvk-file-writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kvk-file-writer.js","sourceRoot":"","sources":["../../../src/kvk/kvk-file-writer.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAoB,6BAA6B,EAAE,0BAA0B,EAAuC,MAAM,eAAe,CAAC;AAG1J,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;;OAIG;IACH,KAAK,CAAC,MAAsB;QAC1B,MAAM,MAAM,GAAG,IAAI,C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