@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,146 +1,165 @@
1
- //
2
- // Version 1.0 of Keyman Developer Project .kpj file
3
- //
4
- export class KeymanDeveloperProject {
5
- projectFilename;
6
- callbacks;
7
- options;
8
- files;
9
- projectPath = '';
10
- constructor(projectFilename, version, callbacks) {
11
- this.projectFilename = projectFilename;
12
- this.callbacks = callbacks;
13
- this.projectPath = this.callbacks.path.dirname(this.projectFilename);
14
- this.options = new KeymanDeveloperProjectOptions(version);
15
- this.files = [];
16
- }
17
- /**
18
- * Adds .kmn, .xml, .kps to project based on options.sourcePath
19
- * @param projectFilename Full path to project.kpj (even if the file doesn't exist)
20
- */
21
- populateFiles() {
22
- if (this.options.version != '2.0') {
23
- throw new Error('populateFiles can only be called on a v2.0 project');
24
- }
25
- let sourcePath = this.resolveProjectPath(this.options.sourcePath);
26
- let files = this.callbacks.fs.readdirSync(sourcePath);
27
- for (let filename of files) {
28
- let fullPath = this.callbacks.path.join(sourcePath, filename);
29
- if (filename.match(/\.xml$/i)) {
30
- if (!this.callbacks.fs.readFileSync(fullPath, 'utf-8').match(/ldmlKeyboard\.dtd/)) {
31
- // Skip this .xml because we assume it isn't really a keyboard .xml
32
- continue;
33
- }
34
- }
35
- if (filename.match(/\.(kmn|kps|xml|model\.ts)$/i)) {
36
- let file = new KeymanDeveloperProjectFile20(fullPath, this.callbacks);
37
- this.files.push(file);
38
- }
39
- }
40
- }
41
- resolveProjectPath(p) {
42
- // Replace placeholders in the target path
43
- return p.replace('$PROJECTPATH', this.projectPath);
44
- }
45
- resolveInputFilePath(file) {
46
- return this.callbacks.resolveFilename(this.projectFilename, file.filePath);
47
- }
48
- resolveOutputFilePath(file, sourceExt, targetExt) {
49
- // Roughly corresponds to Delphi TProject.GetTargetFileName
50
- let p = this.options.version == '1.0' ?
51
- this.options.buildPath || '$SOURCEPATH' :
52
- this.options.buildPath;
53
- // Replace placeholders in the target path
54
- if (this.options.version == '1.0') {
55
- // TODO: do we need to support $VERSION?
56
- // $SOURCEPATH only supported in 1.0 projects
57
- p = p.replace('$SOURCEPATH', this.callbacks.path.dirname(this.resolveInputFilePath(file)));
58
- }
59
- p = this.resolveProjectPath(p);
60
- let f = file.filename.replace(new RegExp(`\\${sourceExt}$`, 'i'), targetExt);
61
- return this.callbacks.path.normalize(this.callbacks.path.join(p, f));
62
- }
63
- }
64
- ;
65
- export var KeymanDeveloperProjectType;
66
- (function (KeymanDeveloperProjectType) {
67
- KeymanDeveloperProjectType[KeymanDeveloperProjectType["Keyboard"] = 0] = "Keyboard";
68
- KeymanDeveloperProjectType[KeymanDeveloperProjectType["LexicalModel"] = 1] = "LexicalModel";
69
- })(KeymanDeveloperProjectType || (KeymanDeveloperProjectType = {}));
70
- ;
71
- export class KeymanDeveloperProjectOptions {
72
- buildPath;
73
- sourcePath;
74
- compilerWarningsAsErrors = false;
75
- warnDeprecatedCode = true;
76
- checkFilenameConventions = true;
77
- projectType = KeymanDeveloperProjectType.Keyboard;
78
- version;
79
- constructor(version) {
80
- this.version = version;
81
- switch (version) {
82
- case "1.0":
83
- this.buildPath = '';
84
- this.sourcePath = '';
85
- break;
86
- case "2.0":
87
- this.buildPath = '$PROJECTPATH/build';
88
- this.sourcePath = '$PROJECTPATH/source';
89
- break;
90
- default:
91
- throw new Error('Invalid version');
92
- }
93
- }
94
- }
95
- ;
96
- export class KeymanDeveloperProjectFile10 {
97
- id; // 1.0 only
98
- filename;
99
- filePath;
100
- fileVersion; // 1.0 only
101
- fileType; // file extension of filename, but .model.ts is technically not the ext because of 2 periods
102
- details; // 1.0 only
103
- childFiles; // 1.0 only
104
- constructor(id, filename, filePath, fileVersion, fileType) {
105
- this.details = {};
106
- this.childFiles = [];
107
- this.id = id;
108
- this.filename = filename;
109
- this.filePath = filePath;
110
- this.fileVersion = fileVersion;
111
- this.fileType = fileType;
112
- }
113
- }
114
- ;
115
- export class KeymanDeveloperProjectFile20 {
116
- callbacks;
117
- filename;
118
- filePath;
119
- fileType; // file extension of filename, but .model.ts is technically not the ext because of 2 periods
120
- constructor(filePath, callbacks) {
121
- this.callbacks = callbacks;
122
- this.filename = this.callbacks.path.basename(filePath);
123
- this.filePath = filePath;
124
- if (this.filename.match(/\.model\.ts$/)) {
125
- // .model.ts is a bit of a hassle...
126
- this.fileType = '.model.ts';
127
- }
128
- else {
129
- this.fileType = this.callbacks.path.extname(this.filename);
130
- }
131
- }
132
- }
133
- ;
134
- export class KeymanDeveloperProjectFileDetail_Kps {
135
- name;
136
- copyright;
137
- version;
138
- }
139
- ;
140
- export class KeymanDeveloperProjectFileDetail_Kmn {
141
- name;
142
- copyright;
143
- message;
144
- }
145
- ;
146
- //# sourceMappingURL=keyman-developer-project.js.map
1
+ //
2
+ // Version 1.0 of Keyman Developer Project .kpj file
3
+ //
4
+ !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]="835476e3-1010-5be5-81cd-250fb33235c1")}catch(e){}}();
5
+ import { KeymanFileTypes } from '../main.js';
6
+ export class KeymanDeveloperProject {
7
+ projectFilename;
8
+ callbacks;
9
+ options;
10
+ files;
11
+ projectPath = '';
12
+ constructor(projectFilename, version, callbacks) {
13
+ this.projectFilename = projectFilename;
14
+ this.callbacks = callbacks;
15
+ this.projectPath = this.callbacks.path.dirname(this.projectFilename);
16
+ this.options = new KeymanDeveloperProjectOptions(version);
17
+ this.files = [];
18
+ }
19
+ /**
20
+ * Adds .kmn, .xml, .kps to project based on options.sourcePath
21
+ * @param projectFilename Full path to project.kpj (even if the file doesn't exist)
22
+ */
23
+ populateFiles() {
24
+ if (this.options.version != '2.0') {
25
+ throw new Error('populateFiles can only be called on a v2.0 project');
26
+ }
27
+ let sourcePath = this.resolveProjectPath(this.options.sourcePath);
28
+ let files = this.callbacks.fs.readdirSync(sourcePath);
29
+ for (let filename of files) {
30
+ let fullPath = this.callbacks.path.join(sourcePath, filename);
31
+ if (KeymanFileTypes.filenameIs(filename, ".xml" /* KeymanFileTypes.Source.LdmlKeyboard */)) {
32
+ if (!this.callbacks.fs.readFileSync(fullPath, 'utf-8').match(/ldmlKeyboard\.dtd/)) {
33
+ // Skip this .xml because we assume it isn't really a keyboard .xml
34
+ continue;
35
+ }
36
+ }
37
+ if (KeymanFileTypes.sourceTypeFromFilename(filename) !== null) {
38
+ let file = new KeymanDeveloperProjectFile20(fullPath, this.callbacks);
39
+ this.files.push(file);
40
+ }
41
+ }
42
+ this.addMetadataFile();
43
+ }
44
+ isKeyboardProject() {
45
+ return !!this.files.find(file => file.fileType == ".kmn" /* KeymanFileTypes.Source.KeymanKeyboard */ || file.fileType == ".xml" /* KeymanFileTypes.Source.LdmlKeyboard */);
46
+ }
47
+ isLexicalModelProject() {
48
+ return !!this.files.find(file => file.fileType == ".model.ts" /* KeymanFileTypes.Source.Model */);
49
+ }
50
+ addMetadataFile() {
51
+ const ext = this.isLexicalModelProject() ? ".model_info" /* KeymanFileTypes.Source.ModelInfo */ : ".keyboard_info" /* KeymanFileTypes.Source.KeyboardInfo */;
52
+ if (this.files.find(file => KeymanFileTypes.filenameIs(file.filename, ext))) {
53
+ return;
54
+ }
55
+ const infoFile = this.callbacks.path.join(this.projectPath, this.callbacks.path.basename(this.projectFilename, ".kpj" /* KeymanFileTypes.Source.Project */) + ext);
56
+ this.files.push(new KeymanDeveloperProjectFile20(infoFile, this.callbacks));
57
+ }
58
+ resolveProjectPath(p) {
59
+ // Replace placeholders in the target path
60
+ return p.replace('$PROJECTPATH', this.projectPath);
61
+ }
62
+ resolveInputFilePath(file) {
63
+ return this.callbacks.resolveFilename(this.projectFilename, file.filePath);
64
+ }
65
+ resolveOutputFilePath(file, sourceExt, targetExt) {
66
+ // Roughly corresponds to Delphi TProject.GetTargetFileName
67
+ let p = this.options.version == '1.0' ?
68
+ this.options.buildPath || '$SOURCEPATH' :
69
+ this.options.buildPath;
70
+ // Replace placeholders in the target path
71
+ if (this.options.version == '1.0') {
72
+ // TODO: do we need to support $VERSION?
73
+ // $SOURCEPATH only supported in 1.0 projects
74
+ p = p.replace('$SOURCEPATH', this.callbacks.path.dirname(this.resolveInputFilePath(file)));
75
+ }
76
+ p = this.resolveProjectPath(p);
77
+ let f = file.filename.replace(new RegExp(`\\${sourceExt}$`, 'i'), targetExt);
78
+ return this.callbacks.path.normalize(this.callbacks.path.join(p, f));
79
+ }
80
+ }
81
+ ;
82
+ export var KeymanDeveloperProjectType;
83
+ (function (KeymanDeveloperProjectType) {
84
+ KeymanDeveloperProjectType[KeymanDeveloperProjectType["Keyboard"] = 0] = "Keyboard";
85
+ KeymanDeveloperProjectType[KeymanDeveloperProjectType["LexicalModel"] = 1] = "LexicalModel";
86
+ })(KeymanDeveloperProjectType || (KeymanDeveloperProjectType = {}));
87
+ ;
88
+ export class KeymanDeveloperProjectOptions {
89
+ buildPath;
90
+ sourcePath;
91
+ compilerWarningsAsErrors = false;
92
+ warnDeprecatedCode = true;
93
+ checkFilenameConventions = false; // missing option defaults to False
94
+ projectType = KeymanDeveloperProjectType.Keyboard;
95
+ version;
96
+ constructor(version) {
97
+ this.version = version;
98
+ switch (version) {
99
+ case "1.0":
100
+ this.buildPath = '';
101
+ this.sourcePath = '';
102
+ break;
103
+ case "2.0":
104
+ this.buildPath = '$PROJECTPATH/build';
105
+ this.sourcePath = '$PROJECTPATH/source';
106
+ break;
107
+ default:
108
+ throw new Error('Invalid version');
109
+ }
110
+ }
111
+ }
112
+ ;
113
+ ;
114
+ export class KeymanDeveloperProjectFile10 {
115
+ id;
116
+ filePath;
117
+ fileVersion;
118
+ callbacks;
119
+ get filename() {
120
+ return this.callbacks.path.basename(this.filePath);
121
+ }
122
+ get fileType() {
123
+ return KeymanFileTypes.fromFilename(this.filename);
124
+ }
125
+ details; // 1.0 only
126
+ childFiles; // 1.0 only
127
+ constructor(id, filePath, fileVersion, callbacks) {
128
+ this.id = id;
129
+ this.filePath = filePath;
130
+ this.fileVersion = fileVersion;
131
+ this.callbacks = callbacks;
132
+ this.details = {};
133
+ this.childFiles = [];
134
+ }
135
+ }
136
+ ;
137
+ export class KeymanDeveloperProjectFile20 {
138
+ filePath;
139
+ callbacks;
140
+ get filename() {
141
+ return this.callbacks.path.basename(this.filePath);
142
+ }
143
+ get fileType() {
144
+ return KeymanFileTypes.fromFilename(this.filename);
145
+ }
146
+ constructor(filePath, callbacks) {
147
+ this.filePath = filePath;
148
+ this.callbacks = callbacks;
149
+ }
150
+ }
151
+ ;
152
+ export class KeymanDeveloperProjectFileDetail_Kps {
153
+ name;
154
+ copyright;
155
+ version;
156
+ }
157
+ ;
158
+ export class KeymanDeveloperProjectFileDetail_Kmn {
159
+ name;
160
+ copyright;
161
+ message;
162
+ }
163
+ ;
164
+ //# debugId=835476e3-1010-5be5-81cd-250fb33235c1
165
+ //# sourceMappingURL=keyman-developer-project.js.map
@@ -1 +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;AAIF,MAAM,OAAO,sBAAsB;IAKb;IAAyE;IAJ7F,OAAO,CAAgC;IACvC,KAAK,CAA+B;IACpC,WAAW,GAAW,EAAE,CAAC;IAEzB,YAAoB,eAAuB,EAAE,OAAsC,EAAU,SAA4B;QAArG,oBAAe,GAAf,eAAe,CAAQ;QAAkD,cAAS,GAAT,SAAS,CAAmB;QACvH,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACrE,IAAI,CAAC,OAAO,GAAG,IAAI,6BAA6B,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IACD;;;OAGG;IACH,aAAa;QACX,IAAG,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,KAAK,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;SACvE;QACD,IAAI,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SAAS,CAAU;IACnB,OAAO,CAAU;CAClB;AAAA,CAAC","names":[],"sourceRoot":"","sources":["../../../src/kpj/keyman-developer-project.ts"],"version":3}
@@ -1,19 +1,21 @@
1
- import { KPJFile } from './kpj-file.js';
2
- import { KeymanDeveloperProject } from './keyman-developer-project.js';
3
- import { CompilerCallbacks } from '../util/compiler-interfaces.js';
4
- export declare class KPJFileReader {
5
- private callbacks;
6
- constructor(callbacks: CompilerCallbacks);
7
- read(file: Uint8Array): KPJFile;
8
- validate(source: KPJFile, schemaBuffer: Uint8Array): void;
9
- private boolFromString;
10
- transform(projectFilename: string, source: KPJFile): KeymanDeveloperProject;
11
- private transformFilesVersion10;
12
- /**
13
- * xml2js will not place single-entry objects into arrays.
14
- * Easiest way to fix this is to box them ourselves as needed
15
- * @param source KVKSourceFile
16
- */
17
- private boxArrays;
18
- }
19
- //# sourceMappingURL=kpj-file-reader.d.ts.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]="ec62180e-bfad-5ec5-aed9-a0e814bc07bd")}catch(e){}}();
2
+ import { KPJFile } from './kpj-file.js';
3
+ import { KeymanDeveloperProject } from './keyman-developer-project.js';
4
+ import { CompilerCallbacks } from '../util/compiler-interfaces.js';
5
+ export declare class KPJFileReader {
6
+ private callbacks;
7
+ constructor(callbacks: CompilerCallbacks);
8
+ read(file: Uint8Array): KPJFile;
9
+ validate(source: KPJFile): void;
10
+ private boolFromString;
11
+ transform(projectFilename: string, source: KPJFile): KeymanDeveloperProject;
12
+ private transformFilesVersion10;
13
+ /**
14
+ * xml2js will not place single-entry objects into arrays.
15
+ * Easiest way to fix this is to box them ourselves as needed
16
+ * @param source KVKSourceFile
17
+ */
18
+ private boxArrays;
19
+ }
20
+ //# debugId=ec62180e-bfad-5ec5-aed9-a0e814bc07bd
21
+ //# sourceMappingURL=kpj-file-reader.d.ts.map
@@ -1 +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;AACjI,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,qBAAa,aAAa;IACZ,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,iBAAiB;IAIzC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO;IAgB/B,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,GAAG,IAAI;IAQhE,OAAO,CAAC,cAAc;IAOf,SAAS,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,sBAAsB;IA6BlF,OAAO,CAAC,uBAAuB;IAyB/B;;;;OAIG;IACH,OAAO,CAAC,SAAS;CAIlB"}
1
+ {"debug_id":"ec62180e-bfad-5ec5-aed9-a0e814bc07bd","file":"kpj-file-reader.d.ts","mappings":";AACA,OAAO,EAAE,OAAO,EAAkB,MAAM,eAAe,CAAC;AAIxD,OAAO,EAAE,sBAAsB,EAA4D,MAAM,+BAA+B,CAAC;AACjI,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,qBAAa,aAAa;IACZ,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,iBAAiB;IAIzC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO;IAsB/B,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAYtC,OAAO,CAAC,cAAc;IAOf,SAAS,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,sBAAsB;IA8BlF,OAAO,CAAC,uBAAuB;IAwB/B;;;;OAIG;IACH,OAAO,CAAC,SAAS;CAIlB","names":[],"sourceRoot":"","sources":["../../../src/kpj/kpj-file-reader.ts"],"version":3}
@@ -1,96 +1,110 @@
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
- callbacks;
8
- constructor(callbacks) {
9
- this.callbacks = callbacks;
10
- }
11
- read(file) {
12
- let data;
13
- const parser = new xml2js.Parser({
14
- explicitArray: false,
15
- mergeAttrs: false,
16
- includeWhiteChars: false,
17
- normalize: false,
18
- emptyTag: ''
19
- });
20
- parser.parseString(file, (e, r) => { data = r; });
21
- data = this.boxArrays(data);
22
- return data;
23
- }
24
- validate(source, schemaBuffer) {
25
- const schema = JSON.parse(new TextDecoder().decode(schemaBuffer));
26
- const ajv = new Ajv();
27
- if (!ajv.validate(schema, source)) {
28
- throw new Error(ajv.errorsText());
29
- }
30
- }
31
- boolFromString(value, def) {
32
- value = (value || '').toLowerCase();
33
- if (value === 'true')
34
- return true;
35
- if (value === 'false')
36
- return false;
37
- return def;
38
- }
39
- transform(projectFilename, source) {
40
- // NOTE: at this point, the xml should have been validated
41
- // and matched the schema result so we can assume the source
42
- // is a valid shape
43
- let project = source.KeymanDeveloperProject;
44
- let result = new KeymanDeveloperProject(projectFilename, project.Options?.Version || "1.0", this.callbacks);
45
- if (result.options.version == '2.0') {
46
- result.options.buildPath = (project.Options?.BuildPath || result.options.buildPath).replace(/\\/g, '/');
47
- result.options.sourcePath = (project.Options?.SourcePath || result.options.sourcePath).replace(/\\/g, '/');
48
- }
49
- else {
50
- result.options.buildPath = (project.Options?.BuildPath || '').replace(/\\/g, '/');
51
- }
52
- result.options.checkFilenameConventions = this.boolFromString(project.Options?.CheckFilenameConventions, true);
53
- result.options.compilerWarningsAsErrors = this.boolFromString(project.Options?.CompilerWarningsAsErrors, false);
54
- result.options.warnDeprecatedCode = this.boolFromString(project.Options?.WarnDeprecatedCode, true);
55
- result.options.projectType =
56
- project.Options?.ProjectType == 'keyboard' ? KeymanDeveloperProjectType.Keyboard :
57
- project.Options?.ProjectType == 'lexicalmodel' ? KeymanDeveloperProjectType.LexicalModel :
58
- KeymanDeveloperProjectType.Keyboard; // Default is keyboard if missing
59
- if (result.options.version == '1.0') {
60
- this.transformFilesVersion10(project, result);
61
- }
62
- else {
63
- result.populateFiles();
64
- }
65
- return result;
66
- }
67
- transformFilesVersion10(project, result) {
68
- let ids = {};
69
- for (let sourceFile of project.Files?.File) {
70
- let file = new KeymanDeveloperProjectFile10(sourceFile.ID || '', sourceFile.Filename || '', (sourceFile.Filepath || '').replace(/\\/g, '/'), sourceFile.FileVersion || '', sourceFile.FileType || '');
71
- if (sourceFile.Details) {
72
- file.details.copyright = sourceFile.Details.Copyright;
73
- file.details.name = sourceFile.Details.Name;
74
- file.details.message = sourceFile.Details.Message;
75
- file.details.version = sourceFile.Details.Version;
76
- }
77
- if (sourceFile.ParentFileID && ids[sourceFile.ParentFileID]) {
78
- ids[sourceFile.ParentFileID].childFiles.push(file);
79
- }
80
- else {
81
- result.files.push(file);
82
- ids[file.id] = file;
83
- }
84
- }
85
- }
86
- /**
87
- * xml2js will not place single-entry objects into arrays.
88
- * Easiest way to fix this is to box them ourselves as needed
89
- * @param source KVKSourceFile
90
- */
91
- boxArrays(source) {
92
- boxXmlArray(source.KeymanDeveloperProject?.Files, 'File');
93
- return source;
94
- }
95
- }
96
- //# sourceMappingURL=kpj-file-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]="ac2a96ae-38af-5a97-9ebb-d663369706eb")}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 { KeymanDeveloperProject, KeymanDeveloperProjectFile10, KeymanDeveloperProjectType } from './keyman-developer-project.js';
7
+ import Schemas from '../schemas.js';
8
+ export class KPJFileReader {
9
+ callbacks;
10
+ constructor(callbacks) {
11
+ this.callbacks = callbacks;
12
+ }
13
+ read(file) {
14
+ let data;
15
+ const parser = new xml2js.Parser({
16
+ explicitArray: false,
17
+ mergeAttrs: false,
18
+ includeWhiteChars: false,
19
+ normalize: false,
20
+ emptyTag: ''
21
+ });
22
+ parser.parseString(file, (e, r) => { data = r; });
23
+ data = this.boxArrays(data);
24
+ for (let file of data.KeymanDeveloperProject?.Files?.File) {
25
+ // xml2js imports <Details/> as '' so we will just delete the empty string
26
+ if (typeof file.Details == 'string') {
27
+ delete file.Details;
28
+ }
29
+ }
30
+ return data;
31
+ }
32
+ validate(source) {
33
+ const ajv = new Ajv();
34
+ if (!ajv.validate(Schemas.kpj, source)) {
35
+ const ajvLegacy = new Ajv();
36
+ if (!ajvLegacy.validate(Schemas.kpj90, source)) {
37
+ // If the legacy schema also does not validate, then we will only report
38
+ // the errors against the modern schema
39
+ throw new Error(ajv.errorsText());
40
+ }
41
+ }
42
+ }
43
+ boolFromString(value, def) {
44
+ value = (value || '').toLowerCase();
45
+ if (value === 'true')
46
+ return true;
47
+ if (value === 'false')
48
+ return false;
49
+ return def;
50
+ }
51
+ transform(projectFilename, source) {
52
+ // NOTE: at this point, the xml should have been validated
53
+ // and matched the schema result so we can assume the source
54
+ // is a valid shape
55
+ let project = source.KeymanDeveloperProject;
56
+ let result = new KeymanDeveloperProject(projectFilename, project.Options?.Version || "1.0", this.callbacks);
57
+ if (result.options.version == '2.0') {
58
+ result.options.buildPath = (project.Options?.BuildPath || result.options.buildPath).replace(/\\/g, '/');
59
+ result.options.sourcePath = (project.Options?.SourcePath || result.options.sourcePath).replace(/\\/g, '/');
60
+ }
61
+ else {
62
+ result.options.buildPath = (project.Options?.BuildPath || '').replace(/\\/g, '/');
63
+ }
64
+ result.options.checkFilenameConventions = this.boolFromString(project.Options?.CheckFilenameConventions, false);
65
+ result.options.compilerWarningsAsErrors = this.boolFromString(project.Options?.CompilerWarningsAsErrors, false);
66
+ result.options.warnDeprecatedCode = this.boolFromString(project.Options?.WarnDeprecatedCode, true);
67
+ result.options.projectType =
68
+ project.Options?.ProjectType == 'keyboard' ? KeymanDeveloperProjectType.Keyboard :
69
+ project.Options?.ProjectType == 'lexicalmodel' ? KeymanDeveloperProjectType.LexicalModel :
70
+ KeymanDeveloperProjectType.Keyboard; // Default is keyboard if missing
71
+ if (result.options.version == '1.0') {
72
+ this.transformFilesVersion10(project, result);
73
+ result.addMetadataFile();
74
+ }
75
+ else {
76
+ result.populateFiles();
77
+ }
78
+ return result;
79
+ }
80
+ transformFilesVersion10(project, result) {
81
+ let ids = {};
82
+ for (let sourceFile of project.Files?.File) {
83
+ let file = new KeymanDeveloperProjectFile10(sourceFile.ID || '', (sourceFile.Filepath || '').replace(/\\/g, '/'), sourceFile.FileVersion || '', this.callbacks);
84
+ if (sourceFile.Details) {
85
+ file.details.copyright = sourceFile.Details.Copyright;
86
+ file.details.name = sourceFile.Details.Name;
87
+ file.details.message = sourceFile.Details.Message;
88
+ file.details.version = sourceFile.Details.Version;
89
+ }
90
+ if (sourceFile.ParentFileID && ids[sourceFile.ParentFileID]) {
91
+ ids[sourceFile.ParentFileID].childFiles.push(file);
92
+ }
93
+ else {
94
+ result.files.push(file);
95
+ ids[file.id] = file;
96
+ }
97
+ }
98
+ }
99
+ /**
100
+ * xml2js will not place single-entry objects into arrays.
101
+ * Easiest way to fix this is to box them ourselves as needed
102
+ * @param source KVKSourceFile
103
+ */
104
+ boxArrays(source) {
105
+ boxXmlArray(source.KeymanDeveloperProject?.Files, 'File');
106
+ return source;
107
+ }
108
+ }
109
+ //# debugId=ac2a96ae-38af-5a97-9ebb-d663369706eb
110
+ //# sourceMappingURL=kpj-file-reader.js.map