@keymanapp/common-types 17.0.256-alpha → 17.0.258-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 (131) hide show
  1. package/build/src/consts/virtual-key-constants.d.ts +192 -194
  2. package/build/src/consts/virtual-key-constants.d.ts.map +1 -1
  3. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts +6 -8
  4. package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts.map +1 -1
  5. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts +29 -31
  6. package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts.map +1 -1
  7. package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts +96 -98
  8. package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts.map +1 -1
  9. package/build/src/keyman-touch-layout/keyman-touch-layout-file.js +29 -5
  10. package/build/src/keyman-touch-layout/keyman-touch-layout-file.js.map +1 -1
  11. package/build/src/kmx/element-string.d.ts +24 -26
  12. package/build/src/kmx/element-string.d.ts.map +1 -1
  13. package/build/src/kmx/keyman-targets.d.ts +21 -23
  14. package/build/src/kmx/keyman-targets.d.ts.map +1 -1
  15. package/build/src/kmx/kmx-builder.d.ts +33 -35
  16. package/build/src/kmx/kmx-builder.d.ts.map +1 -1
  17. package/build/src/kmx/kmx-file-reader.d.ts +14 -16
  18. package/build/src/kmx/kmx-file-reader.d.ts.map +1 -1
  19. package/build/src/kmx/kmx-plus-builder/build-disp.d.ts +19 -21
  20. package/build/src/kmx/kmx-plus-builder/build-disp.d.ts.map +1 -1
  21. package/build/src/kmx/kmx-plus-builder/build-elem.d.ts +29 -31
  22. package/build/src/kmx/kmx-plus-builder/build-elem.d.ts.map +1 -1
  23. package/build/src/kmx/kmx-plus-builder/build-keys.d.ts +57 -59
  24. package/build/src/kmx/kmx-plus-builder/build-keys.d.ts.map +1 -1
  25. package/build/src/kmx/kmx-plus-builder/build-layr.d.ts +54 -56
  26. package/build/src/kmx/kmx-plus-builder/build-layr.d.ts.map +1 -1
  27. package/build/src/kmx/kmx-plus-builder/build-list.d.ts +36 -38
  28. package/build/src/kmx/kmx-plus-builder/build-list.d.ts.map +1 -1
  29. package/build/src/kmx/kmx-plus-builder/build-loca.d.ts +12 -14
  30. package/build/src/kmx/kmx-plus-builder/build-loca.d.ts.map +1 -1
  31. package/build/src/kmx/kmx-plus-builder/build-meta.d.ts +17 -19
  32. package/build/src/kmx/kmx-plus-builder/build-meta.d.ts.map +1 -1
  33. package/build/src/kmx/kmx-plus-builder/build-sect.d.ts +16 -18
  34. package/build/src/kmx/kmx-plus-builder/build-sect.d.ts.map +1 -1
  35. package/build/src/kmx/kmx-plus-builder/build-strs.d.ts +23 -25
  36. package/build/src/kmx/kmx-plus-builder/build-strs.d.ts.map +1 -1
  37. package/build/src/kmx/kmx-plus-builder/build-tran.d.ts +33 -35
  38. package/build/src/kmx/kmx-plus-builder/build-tran.d.ts.map +1 -1
  39. package/build/src/kmx/kmx-plus-builder/build-uset.d.ts +31 -33
  40. package/build/src/kmx/kmx-plus-builder/build-uset.d.ts.map +1 -1
  41. package/build/src/kmx/kmx-plus-builder/build-vars.d.ts +22 -24
  42. package/build/src/kmx/kmx-plus-builder/build-vars.d.ts.map +1 -1
  43. package/build/src/kmx/kmx-plus-builder/builder-section.d.ts +10 -12
  44. package/build/src/kmx/kmx-plus-builder/builder-section.d.ts.map +1 -1
  45. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts +43 -45
  46. package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts.map +1 -1
  47. package/build/src/kmx/kmx-plus.d.ts +320 -322
  48. package/build/src/kmx/kmx-plus.d.ts.map +1 -1
  49. package/build/src/kmx/kmx.d.ts +234 -236
  50. package/build/src/kmx/kmx.d.ts.map +1 -1
  51. package/build/src/kmx/string-list.d.ts +36 -38
  52. package/build/src/kmx/string-list.d.ts.map +1 -1
  53. package/build/src/kpj/keyman-developer-project.d.ts +79 -81
  54. package/build/src/kpj/keyman-developer-project.d.ts.map +1 -1
  55. package/build/src/kpj/kpj-file-reader.d.ts +19 -21
  56. package/build/src/kpj/kpj-file-reader.d.ts.map +1 -1
  57. package/build/src/kpj/kpj-file.d.ts +40 -42
  58. package/build/src/kpj/kpj-file.d.ts.map +1 -1
  59. package/build/src/kvk/kvk-file-reader.d.ts +5 -7
  60. package/build/src/kvk/kvk-file-reader.d.ts.map +1 -1
  61. package/build/src/kvk/kvk-file-writer.d.ts +20 -22
  62. package/build/src/kvk/kvk-file-writer.d.ts.map +1 -1
  63. package/build/src/kvk/kvk-file.d.ts +67 -69
  64. package/build/src/kvk/kvk-file.d.ts.map +1 -1
  65. package/build/src/kvk/kvk-file.js +26 -2
  66. package/build/src/kvk/kvk-file.js.map +1 -1
  67. package/build/src/kvk/kvks-file-reader.d.ts +24 -26
  68. package/build/src/kvk/kvks-file-reader.d.ts.map +1 -1
  69. package/build/src/kvk/kvks-file-writer.d.ts +7 -9
  70. package/build/src/kvk/kvks-file-writer.d.ts.map +1 -1
  71. package/build/src/kvk/kvks-file.d.ts +44 -46
  72. package/build/src/kvk/kvks-file.d.ts.map +1 -1
  73. package/build/src/kvk/visual-keyboard.d.ts +45 -47
  74. package/build/src/kvk/visual-keyboard.d.ts.map +1 -1
  75. package/build/src/kvk/visual-keyboard.js +5 -2
  76. package/build/src/kvk/visual-keyboard.js.map +1 -1
  77. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts +61 -63
  78. package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts.map +1 -1
  79. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts +96 -98
  80. package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts.map +1 -1
  81. package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts +171 -173
  82. package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts.map +1 -1
  83. package/build/src/ldml-keyboard/pattern-parser.d.ts +196 -198
  84. package/build/src/ldml-keyboard/pattern-parser.d.ts.map +1 -1
  85. package/build/src/ldml-keyboard/unicodeset-parser-api.d.ts +38 -40
  86. package/build/src/ldml-keyboard/unicodeset-parser-api.d.ts.map +1 -1
  87. package/build/src/main.d.ts +35 -37
  88. package/build/src/main.d.ts.map +1 -1
  89. package/build/src/osk/osk.d.ts +23 -25
  90. package/build/src/osk/osk.d.ts.map +1 -1
  91. package/build/src/package/kmp-json-file.d.ts +116 -118
  92. package/build/src/package/kmp-json-file.d.ts.map +1 -1
  93. package/build/src/package/kps-file.d.ts +176 -178
  94. package/build/src/package/kps-file.d.ts.map +1 -1
  95. package/build/src/schema-validators.d.ts +14 -16
  96. package/build/src/schema-validators.d.ts.map +1 -1
  97. package/build/src/schemas/displaymap.schema.d.ts +58 -60
  98. package/build/src/schemas/displaymap.schema.d.ts.map +1 -1
  99. package/build/src/schemas/keyboard_info.schema.d.ts +210 -212
  100. package/build/src/schemas/keyboard_info.schema.d.ts.map +1 -1
  101. package/build/src/schemas/keyman-touch-layout.clean.spec.d.ts +228 -230
  102. package/build/src/schemas/keyman-touch-layout.clean.spec.d.ts.map +1 -1
  103. package/build/src/schemas/keyman-touch-layout.spec.d.ts +230 -232
  104. package/build/src/schemas/keyman-touch-layout.spec.d.ts.map +1 -1
  105. package/build/src/schemas/kmp.schema.d.ts +325 -327
  106. package/build/src/schemas/kmp.schema.d.ts.map +1 -1
  107. package/build/src/schemas/kpj-9.0.schema.d.ts +153 -155
  108. package/build/src/schemas/kpj-9.0.schema.d.ts.map +1 -1
  109. package/build/src/schemas/kpj.schema.d.ts +123 -125
  110. package/build/src/schemas/kpj.schema.d.ts.map +1 -1
  111. package/build/src/schemas/kvks.schema.d.ts +161 -163
  112. package/build/src/schemas/kvks.schema.d.ts.map +1 -1
  113. package/build/src/schemas/ldml-keyboard3.schema.d.ts +633 -635
  114. package/build/src/schemas/ldml-keyboard3.schema.d.ts.map +1 -1
  115. package/build/src/schemas/ldml-keyboardtest3.schema.d.ts +190 -192
  116. package/build/src/schemas/ldml-keyboardtest3.schema.d.ts.map +1 -1
  117. package/build/src/schemas.d.ts +2295 -2297
  118. package/build/src/schemas.d.ts.map +1 -1
  119. package/build/src/util/common-events.d.ts +45 -47
  120. package/build/src/util/common-events.d.ts.map +1 -1
  121. package/build/src/util/compiler-interfaces.d.ts +367 -369
  122. package/build/src/util/compiler-interfaces.d.ts.map +1 -1
  123. package/build/src/util/errors.d.ts +6 -8
  124. package/build/src/util/errors.d.ts.map +1 -1
  125. package/build/src/util/file-types.d.ts +94 -96
  126. package/build/src/util/file-types.d.ts.map +1 -1
  127. package/build/src/util/file-types.js +30 -2
  128. package/build/src/util/file-types.js.map +1 -1
  129. package/build/src/util/util.d.ts +67 -69
  130. package/build/src/util/util.d.ts.map +1 -1
  131. package/package.json +2 -2
@@ -1,369 +1,367 @@
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]="efd73433-f1ea-5b91-9e57-c90d1baad20c")}catch(e){}}();
2
- /**
3
- * Abstract interface for compiler error and warning messages
4
- */
5
- export interface CompilerEvent {
6
- filename?: string;
7
- line?: number;
8
- code: number;
9
- message: string;
10
- /**
11
- * an internal error occurred that should be captured with a stack trace
12
- * e.g. to the Keyman sentry instance by kmc
13
- */
14
- exceptionVar?: any;
15
- }
16
- export declare enum CompilerErrorSeverity {
17
- Info = 0,
18
- Hint = 1048576,
19
- Warn = 2097152,
20
- Error = 3145728,
21
- Fatal = 4194304
22
- }
23
- export declare const CompilerErrorSeverityValues: CompilerErrorSeverity[];
24
- /**
25
- * Mask values for mapping compiler errors
26
- */
27
- export declare enum CompilerErrorMask {
28
- Severity = 15728640,
29
- Error = 1048575,
30
- Namespace = 1044480,
31
- BaseError = 4095,
32
- Reserved = 4278190080
33
- }
34
- export declare class CompilerError {
35
- static severity(code: number): CompilerErrorSeverity;
36
- static error(code: number): number;
37
- static baseError(code: number): number;
38
- static namespace(code: number): CompilerErrorNamespace;
39
- static formatSeverity(code: number): string;
40
- /** true if events has at least one message of the atLeast severity */
41
- static hasSeverity(events: CompilerEvent[], atLeast: CompilerErrorSeverity): boolean;
42
- /** true if events has at least one Error or worse */
43
- static hasError(events: CompilerEvent[]): boolean;
44
- /**
45
- * Format an error code number. The error code number does not include
46
- * the severity mask, as this is reported in text form separately; see
47
- * `severityName`.
48
- * @example
49
- *
50
- * The following call returns `KM03004`
51
- * ```
52
- * formatCode(CompilerMessage.ERROR_InvalidDisplayMapFile)
53
- * ```
54
- */
55
- static formatCode(code: number): string;
56
- /**
57
- * Formats an event filename for an error report,
58
- * stripping off path component
59
- * @param filename
60
- * @returns
61
- */
62
- static formatFilename(filename: string, options?: {
63
- fullPath?: boolean;
64
- forwardSlashes?: boolean;
65
- }): string;
66
- /**
67
- * Formats an event line for an error report
68
- * @param line
69
- * @returns
70
- */
71
- static formatLine(line: number): string;
72
- /**
73
- * Formats an event message for an error report
74
- * @param message
75
- * @returns
76
- */
77
- static formatMessage(message: string): string;
78
- /**
79
- * Formats a compiler message, without coloring; an ANSI color version is
80
- * implemented in NodeCompilerCallbacks.
81
- * @param event event or array of events
82
- */
83
- static formatEvent(event: CompilerEvent | CompilerEvent[]): string;
84
- /**
85
- * @param e Error-like
86
- */
87
- static exceptionToString(e?: any): string;
88
- /**
89
- * Returns the corresponding error severity value from a partial name match,
90
- * e.g. 'inf' returns CompilerErrorSeverity.Info, or returns null if not found
91
- * @param name
92
- * @returns
93
- */
94
- static severityNameToValue(name: string): CompilerErrorSeverity;
95
- }
96
- /** @deprecated use `CompilerError.severity` instead */
97
- export declare function compilerErrorSeverity(code: number): CompilerErrorSeverity;
98
- /** @deprecated use `CompilerError.formatSeverity` instead */
99
- export declare function compilerErrorSeverityName(code: number): string;
100
- /** @deprecated use `CompilerError.formatCode` instead */
101
- export declare function compilerErrorFormatCode(code: number): string;
102
- /** @deprecated use `CompilerError.formatEvent` instead */
103
- export declare function compilerEventFormat(e: CompilerEvent | CompilerEvent[]): string;
104
- /**
105
- * Defines the error code ranges for various compilers. Once defined, these
106
- * ranges must not be changed as external modules may depend on specific error
107
- * codes. Individual errors are defined at a compiler level, for example,
108
- * kmc-ldml/src/compiler/messages.ts.
109
- *
110
- * kmc defines a mapping between each namespace and the corresponding compiler's
111
- * error reporting class in kmc/src/messages/messageNamespaces.ts
112
- */
113
- export declare enum CompilerErrorNamespace {
114
- /**
115
- * kmc-ldml errors between 0x0000…0x0FFF
116
- */
117
- LdmlKeyboardCompiler = 0,
118
- /**
119
- * common/web/types errors between 0x1000…0x1FFF
120
- */
121
- CommonTypes = 4096,
122
- /**
123
- * kmc-kmn errors between 0x2000…0x2FFF; these map to
124
- * the base codes found in kmn_compiler_errors.h, exclusive severity flags
125
- */
126
- KmnCompiler = 8192,
127
- /**
128
- * kmc-model errors between 0x3000…0x3FFF
129
- */
130
- ModelCompiler = 12288,
131
- /**
132
- * kmc-package errors between 0x4000…0x4FFF
133
- */
134
- PackageCompiler = 16384,
135
- /**
136
- * kmc and related infrastructure errors between 0x5000…0x5FFF
137
- */
138
- Infrastructure = 20480,
139
- /**
140
- * kmc-analyze 0x6000…0x6FFF
141
- */
142
- Analyzer = 24576,
143
- /**
144
- * kmc-kmn/kmw-compiler errors between 0x7000…0x7FFF; note that some errors
145
- * generated by kmc-kmn/kmw-compiler are from kmc-kmn namespace for legacy
146
- * reasons
147
- */
148
- KmwCompiler = 28672,
149
- /**
150
- * kmc-model-info 0x8000…0x8FFF
151
- */
152
- ModelInfoCompiler = 32768,
153
- /**
154
- * kmc-keyboard-info 0x9000…0x9FFF
155
- */
156
- KeyboardInfoCompiler = 36864
157
- }
158
- /**
159
- * A mapping for common path operations, maps to Node path module. This only
160
- * defines the functions we are actually using, so that we can port more easily
161
- * between different systems.
162
- */
163
- export interface CompilerPathCallbacks {
164
- dirname(name: string): string;
165
- extname(name: string): string;
166
- basename(name: string, ext?: string): string;
167
- isAbsolute(name: string): boolean;
168
- join(...paths: string[]): string;
169
- normalize(p: string): string;
170
- }
171
- /**
172
- * A mapping for common filesystem operations, maps to Node fs module. This only
173
- * defines the functions we are actually using, so that we can port more easily
174
- * between different systems.
175
- */
176
- export interface CompilerFileSystemCallbacks {
177
- readdirSync(name: string): string[];
178
- readFileSync(path: string, options?: {
179
- encoding?: null;
180
- flag?: string;
181
- } | null): Uint8Array;
182
- readFileSync(path: string, options: {
183
- encoding: string;
184
- flag?: string;
185
- } | string): string;
186
- readFileSync(path: string, options?: {
187
- encoding?: string | null;
188
- flag?: string;
189
- } | string | null): string | Uint8Array;
190
- writeFileSync(path: string, data: Uint8Array): void;
191
- existsSync(name: string): boolean;
192
- }
193
- type CompilerErrorSeverityOverride = CompilerErrorSeverity | 'disable';
194
- export interface CompilerMessageOverrideMap {
195
- [code: number]: CompilerErrorSeverityOverride;
196
- }
197
- export interface CompilerMessageOverride {
198
- code: number;
199
- level: CompilerErrorSeverityOverride;
200
- }
201
- export interface CompilerCallbackOptions {
202
- logLevel?: CompilerLogLevel;
203
- logFormat?: CompilerLogFormat;
204
- color?: boolean;
205
- compilerWarningsAsErrors?: boolean;
206
- messageOverrides?: CompilerMessageOverrideMap;
207
- }
208
- export interface KeymanCompilerArtifact {
209
- data: Uint8Array;
210
- filename: string;
211
- }
212
- export type KeymanCompilerArtifactOptional = KeymanCompilerArtifact | undefined;
213
- export interface KeymanCompilerArtifacts {
214
- readonly [type: string]: KeymanCompilerArtifactOptional;
215
- }
216
- export interface KeymanCompilerResult {
217
- artifacts: KeymanCompilerArtifacts;
218
- }
219
- export interface KeymanCompiler {
220
- init(callbacks: CompilerCallbacks, options: CompilerOptions): Promise<boolean>;
221
- /**
222
- * Run the compiler, and save the result in memory arrays. Note that while
223
- * `outputFilename` is provided here, the output file is not written to in
224
- * this function.
225
- * @param inputFilename
226
- * @param outputFilename The intended output filename, optional, if missing,
227
- * calculated from inputFilename
228
- * @param data
229
- */
230
- run(inputFilename: string, outputFilename?: string): Promise<KeymanCompilerResult>;
231
- /**
232
- * Writes the compiled output files to disk
233
- * @param artifacts
234
- */
235
- write(artifacts: KeymanCompilerArtifacts): Promise<boolean>;
236
- }
237
- /**
238
- * Abstract interface for callbacks, to abstract out file i/o
239
- */
240
- export interface CompilerCallbacks {
241
- /**
242
- * Attempt to load a file. Return falsy if not found.
243
- * TODO: never return falsy, just throw if not found?
244
- * @param filename
245
- */
246
- loadFile(filename: string): Uint8Array;
247
- /**
248
- * Get file size, returns undefined if not found
249
- */
250
- fileSize(filename: string): number;
251
- get path(): CompilerPathCallbacks;
252
- get fs(): CompilerFileSystemCallbacks;
253
- /**
254
- * Resolves a file path relative to the baseFilename
255
- * @param baseFilename
256
- * @param filename
257
- */
258
- resolveFilename(baseFilename: string, filename: string): string;
259
- reportMessage(event: CompilerEvent): void;
260
- debug(msg: string): void;
261
- }
262
- /**
263
- * Wrapper class for CompilerCallbacks for a given input file
264
- */
265
- export declare class CompilerFileCallbacks implements CompilerCallbacks {
266
- private filename;
267
- private options;
268
- private parent;
269
- messages: CompilerEvent[];
270
- constructor(filename: string, options: CompilerCallbackOptions, parent: CompilerCallbacks);
271
- /**
272
- * Returns `true` if any message in the `messages` array is a Fatal or Error
273
- * message, and if `compilerWarningsAsErrors` is `true`, then also returns
274
- * `true` if any message is a Warning.
275
- */
276
- static hasFailureMessage(messages: CompilerEvent[], compilerWarningsAsErrors: boolean): boolean;
277
- /**
278
- *
279
- * @param event
280
- * @param overrides
281
- * @returns true if event has been suppressed
282
- */
283
- static applyMessageOverridesToEvent(event: CompilerEvent, overrides: CompilerMessageOverrideMap): boolean;
284
- /**
285
- * Returns `true` if any message in the `messages` array is a Fatal or Error
286
- * message, and if `compilerWarningsAsErrors` is `true`, then also returns
287
- * `true` if any message is a Warning.
288
- *
289
- * If passed a defined `compilerWarningsAsErrors` value, then uses that,
290
- * otherwise uses `options.compilerWarningsAsErrors`, or `false` if that is
291
- * also `undefined`.
292
- */
293
- hasFailureMessage(compilerWarningsAsErrors?: boolean): boolean;
294
- clear(): void;
295
- loadFile(filename: string): Uint8Array;
296
- fileSize(filename: string): number;
297
- get path(): CompilerPathCallbacks;
298
- get fs(): CompilerFileSystemCallbacks;
299
- resolveFilename(baseFilename: string, filename: string): string;
300
- reportMessage(event: CompilerEvent): void;
301
- debug(msg: string): void;
302
- }
303
- /**
304
- * Abstract interface for compiler options
305
- */
306
- export interface CompilerBaseOptions {
307
- /**
308
- * Reporting level to console, used by NodeCompilerCallbacks (not used in compiler modules;
309
- * all messages are still reported to the internal log)
310
- */
311
- logLevel?: CompilerLogLevel;
312
- /**
313
- * Format of output for log to console
314
- */
315
- logFormat?: CompilerLogFormat;
316
- /**
317
- * Colorize log output, default is detected from console
318
- */
319
- color?: boolean;
320
- }
321
- export interface CompilerOptions extends CompilerBaseOptions {
322
- /**
323
- * Add metadata about the compiler version to .kmx file when compiling
324
- */
325
- shouldAddCompilerVersion?: boolean;
326
- /**
327
- * Add debug information to the .kmx file when compiling
328
- */
329
- saveDebug?: boolean;
330
- /**
331
- * Upgrade any warnings produced in the compile to errors
332
- */
333
- compilerWarningsAsErrors?: boolean;
334
- /**
335
- * Emit warnings if deprecated code is encountered
336
- */
337
- warnDeprecatedCode?: boolean;
338
- /**
339
- * Check filename conventions in packages
340
- */
341
- checkFilenameConventions?: boolean;
342
- }
343
- export declare const defaultCompilerOptions: CompilerOptions;
344
- /**
345
- * Convenience function for constructing CompilerEvents
346
- * @param code
347
- * @param message
348
- * @returns
349
- */
350
- export declare const CompilerMessageSpec: (code: number, message: string, exceptionVar?: any) => CompilerEvent;
351
- /**
352
- * @deprecated use `CompilerError.exceptionToString` instead
353
- */
354
- export declare function compilerExceptionToString(e?: any): string;
355
- /**
356
- * Compiler logging level and correspondence to severity
357
- */
358
- export declare const ALL_COMPILER_LOG_LEVELS: readonly ["silent", "error", "warn", "hint", "info", "debug"];
359
- type CompilerLogLevelTuple = typeof ALL_COMPILER_LOG_LEVELS;
360
- export type CompilerLogLevel = CompilerLogLevelTuple[number];
361
- export declare const compilerLogLevelToSeverity: {
362
- [index in CompilerLogLevel]: number;
363
- };
364
- export declare const ALL_COMPILER_LOG_FORMATS: readonly ["tsv", "formatted"];
365
- type CompilerLogFormatTuple = typeof ALL_COMPILER_LOG_FORMATS;
366
- export type CompilerLogFormat = CompilerLogFormatTuple[number];
367
- export {};
368
- //# debugId=efd73433-f1ea-5b91-9e57-c90d1baad20c
369
- //# sourceMappingURL=compiler-interfaces.d.ts.map
1
+ /**
2
+ * Abstract interface for compiler error and warning messages
3
+ */
4
+ export interface CompilerEvent {
5
+ filename?: string;
6
+ line?: number;
7
+ code: number;
8
+ message: string;
9
+ /**
10
+ * an internal error occurred that should be captured with a stack trace
11
+ * e.g. to the Keyman sentry instance by kmc
12
+ */
13
+ exceptionVar?: any;
14
+ }
15
+ export declare enum CompilerErrorSeverity {
16
+ Info = 0,
17
+ Hint = 1048576,
18
+ Warn = 2097152,
19
+ Error = 3145728,
20
+ Fatal = 4194304
21
+ }
22
+ export declare const CompilerErrorSeverityValues: CompilerErrorSeverity[];
23
+ /**
24
+ * Mask values for mapping compiler errors
25
+ */
26
+ export declare enum CompilerErrorMask {
27
+ Severity = 15728640,
28
+ Error = 1048575,
29
+ Namespace = 1044480,
30
+ BaseError = 4095,
31
+ Reserved = 4278190080
32
+ }
33
+ export declare class CompilerError {
34
+ static severity(code: number): CompilerErrorSeverity;
35
+ static error(code: number): number;
36
+ static baseError(code: number): number;
37
+ static namespace(code: number): CompilerErrorNamespace;
38
+ static formatSeverity(code: number): string;
39
+ /** true if events has at least one message of the atLeast severity */
40
+ static hasSeverity(events: CompilerEvent[], atLeast: CompilerErrorSeverity): boolean;
41
+ /** true if events has at least one Error or worse */
42
+ static hasError(events: CompilerEvent[]): boolean;
43
+ /**
44
+ * Format an error code number. The error code number does not include
45
+ * the severity mask, as this is reported in text form separately; see
46
+ * `severityName`.
47
+ * @example
48
+ *
49
+ * The following call returns `KM03004`
50
+ * ```
51
+ * formatCode(CompilerMessage.ERROR_InvalidDisplayMapFile)
52
+ * ```
53
+ */
54
+ static formatCode(code: number): string;
55
+ /**
56
+ * Formats an event filename for an error report,
57
+ * stripping off path component
58
+ * @param filename
59
+ * @returns
60
+ */
61
+ static formatFilename(filename: string, options?: {
62
+ fullPath?: boolean;
63
+ forwardSlashes?: boolean;
64
+ }): string;
65
+ /**
66
+ * Formats an event line for an error report
67
+ * @param line
68
+ * @returns
69
+ */
70
+ static formatLine(line: number): string;
71
+ /**
72
+ * Formats an event message for an error report
73
+ * @param message
74
+ * @returns
75
+ */
76
+ static formatMessage(message: string): string;
77
+ /**
78
+ * Formats a compiler message, without coloring; an ANSI color version is
79
+ * implemented in NodeCompilerCallbacks.
80
+ * @param event event or array of events
81
+ */
82
+ static formatEvent(event: CompilerEvent | CompilerEvent[]): string;
83
+ /**
84
+ * @param e Error-like
85
+ */
86
+ static exceptionToString(e?: any): string;
87
+ /**
88
+ * Returns the corresponding error severity value from a partial name match,
89
+ * e.g. 'inf' returns CompilerErrorSeverity.Info, or returns null if not found
90
+ * @param name
91
+ * @returns
92
+ */
93
+ static severityNameToValue(name: string): CompilerErrorSeverity;
94
+ }
95
+ /** @deprecated use `CompilerError.severity` instead */
96
+ export declare function compilerErrorSeverity(code: number): CompilerErrorSeverity;
97
+ /** @deprecated use `CompilerError.formatSeverity` instead */
98
+ export declare function compilerErrorSeverityName(code: number): string;
99
+ /** @deprecated use `CompilerError.formatCode` instead */
100
+ export declare function compilerErrorFormatCode(code: number): string;
101
+ /** @deprecated use `CompilerError.formatEvent` instead */
102
+ export declare function compilerEventFormat(e: CompilerEvent | CompilerEvent[]): string;
103
+ /**
104
+ * Defines the error code ranges for various compilers. Once defined, these
105
+ * ranges must not be changed as external modules may depend on specific error
106
+ * codes. Individual errors are defined at a compiler level, for example,
107
+ * kmc-ldml/src/compiler/messages.ts.
108
+ *
109
+ * kmc defines a mapping between each namespace and the corresponding compiler's
110
+ * error reporting class in kmc/src/messages/messageNamespaces.ts
111
+ */
112
+ export declare enum CompilerErrorNamespace {
113
+ /**
114
+ * kmc-ldml errors between 0x0000…0x0FFF
115
+ */
116
+ LdmlKeyboardCompiler = 0,
117
+ /**
118
+ * common/web/types errors between 0x1000…0x1FFF
119
+ */
120
+ CommonTypes = 4096,
121
+ /**
122
+ * kmc-kmn errors between 0x2000…0x2FFF; these map to
123
+ * the base codes found in kmn_compiler_errors.h, exclusive severity flags
124
+ */
125
+ KmnCompiler = 8192,
126
+ /**
127
+ * kmc-model errors between 0x3000…0x3FFF
128
+ */
129
+ ModelCompiler = 12288,
130
+ /**
131
+ * kmc-package errors between 0x4000…0x4FFF
132
+ */
133
+ PackageCompiler = 16384,
134
+ /**
135
+ * kmc and related infrastructure errors between 0x5000…0x5FFF
136
+ */
137
+ Infrastructure = 20480,
138
+ /**
139
+ * kmc-analyze 0x6000…0x6FFF
140
+ */
141
+ Analyzer = 24576,
142
+ /**
143
+ * kmc-kmn/kmw-compiler errors between 0x7000…0x7FFF; note that some errors
144
+ * generated by kmc-kmn/kmw-compiler are from kmc-kmn namespace for legacy
145
+ * reasons
146
+ */
147
+ KmwCompiler = 28672,
148
+ /**
149
+ * kmc-model-info 0x8000…0x8FFF
150
+ */
151
+ ModelInfoCompiler = 32768,
152
+ /**
153
+ * kmc-keyboard-info 0x9000…0x9FFF
154
+ */
155
+ KeyboardInfoCompiler = 36864
156
+ }
157
+ /**
158
+ * A mapping for common path operations, maps to Node path module. This only
159
+ * defines the functions we are actually using, so that we can port more easily
160
+ * between different systems.
161
+ */
162
+ export interface CompilerPathCallbacks {
163
+ dirname(name: string): string;
164
+ extname(name: string): string;
165
+ basename(name: string, ext?: string): string;
166
+ isAbsolute(name: string): boolean;
167
+ join(...paths: string[]): string;
168
+ normalize(p: string): string;
169
+ }
170
+ /**
171
+ * A mapping for common filesystem operations, maps to Node fs module. This only
172
+ * defines the functions we are actually using, so that we can port more easily
173
+ * between different systems.
174
+ */
175
+ export interface CompilerFileSystemCallbacks {
176
+ readdirSync(name: string): string[];
177
+ readFileSync(path: string, options?: {
178
+ encoding?: null;
179
+ flag?: string;
180
+ } | null): Uint8Array;
181
+ readFileSync(path: string, options: {
182
+ encoding: string;
183
+ flag?: string;
184
+ } | string): string;
185
+ readFileSync(path: string, options?: {
186
+ encoding?: string | null;
187
+ flag?: string;
188
+ } | string | null): string | Uint8Array;
189
+ writeFileSync(path: string, data: Uint8Array): void;
190
+ existsSync(name: string): boolean;
191
+ }
192
+ type CompilerErrorSeverityOverride = CompilerErrorSeverity | 'disable';
193
+ export interface CompilerMessageOverrideMap {
194
+ [code: number]: CompilerErrorSeverityOverride;
195
+ }
196
+ export interface CompilerMessageOverride {
197
+ code: number;
198
+ level: CompilerErrorSeverityOverride;
199
+ }
200
+ export interface CompilerCallbackOptions {
201
+ logLevel?: CompilerLogLevel;
202
+ logFormat?: CompilerLogFormat;
203
+ color?: boolean;
204
+ compilerWarningsAsErrors?: boolean;
205
+ messageOverrides?: CompilerMessageOverrideMap;
206
+ }
207
+ export interface KeymanCompilerArtifact {
208
+ data: Uint8Array;
209
+ filename: string;
210
+ }
211
+ export type KeymanCompilerArtifactOptional = KeymanCompilerArtifact | undefined;
212
+ export interface KeymanCompilerArtifacts {
213
+ readonly [type: string]: KeymanCompilerArtifactOptional;
214
+ }
215
+ export interface KeymanCompilerResult {
216
+ artifacts: KeymanCompilerArtifacts;
217
+ }
218
+ export interface KeymanCompiler {
219
+ init(callbacks: CompilerCallbacks, options: CompilerOptions): Promise<boolean>;
220
+ /**
221
+ * Run the compiler, and save the result in memory arrays. Note that while
222
+ * `outputFilename` is provided here, the output file is not written to in
223
+ * this function.
224
+ * @param inputFilename
225
+ * @param outputFilename The intended output filename, optional, if missing,
226
+ * calculated from inputFilename
227
+ * @param data
228
+ */
229
+ run(inputFilename: string, outputFilename?: string): Promise<KeymanCompilerResult>;
230
+ /**
231
+ * Writes the compiled output files to disk
232
+ * @param artifacts
233
+ */
234
+ write(artifacts: KeymanCompilerArtifacts): Promise<boolean>;
235
+ }
236
+ /**
237
+ * Abstract interface for callbacks, to abstract out file i/o
238
+ */
239
+ export interface CompilerCallbacks {
240
+ /**
241
+ * Attempt to load a file. Return falsy if not found.
242
+ * TODO: never return falsy, just throw if not found?
243
+ * @param filename
244
+ */
245
+ loadFile(filename: string): Uint8Array;
246
+ /**
247
+ * Get file size, returns undefined if not found
248
+ */
249
+ fileSize(filename: string): number;
250
+ get path(): CompilerPathCallbacks;
251
+ get fs(): CompilerFileSystemCallbacks;
252
+ /**
253
+ * Resolves a file path relative to the baseFilename
254
+ * @param baseFilename
255
+ * @param filename
256
+ */
257
+ resolveFilename(baseFilename: string, filename: string): string;
258
+ reportMessage(event: CompilerEvent): void;
259
+ debug(msg: string): void;
260
+ }
261
+ /**
262
+ * Wrapper class for CompilerCallbacks for a given input file
263
+ */
264
+ export declare class CompilerFileCallbacks implements CompilerCallbacks {
265
+ private filename;
266
+ private options;
267
+ private parent;
268
+ messages: CompilerEvent[];
269
+ constructor(filename: string, options: CompilerCallbackOptions, parent: CompilerCallbacks);
270
+ /**
271
+ * Returns `true` if any message in the `messages` array is a Fatal or Error
272
+ * message, and if `compilerWarningsAsErrors` is `true`, then also returns
273
+ * `true` if any message is a Warning.
274
+ */
275
+ static hasFailureMessage(messages: CompilerEvent[], compilerWarningsAsErrors: boolean): boolean;
276
+ /**
277
+ *
278
+ * @param event
279
+ * @param overrides
280
+ * @returns true if event has been suppressed
281
+ */
282
+ static applyMessageOverridesToEvent(event: CompilerEvent, overrides: CompilerMessageOverrideMap): boolean;
283
+ /**
284
+ * Returns `true` if any message in the `messages` array is a Fatal or Error
285
+ * message, and if `compilerWarningsAsErrors` is `true`, then also returns
286
+ * `true` if any message is a Warning.
287
+ *
288
+ * If passed a defined `compilerWarningsAsErrors` value, then uses that,
289
+ * otherwise uses `options.compilerWarningsAsErrors`, or `false` if that is
290
+ * also `undefined`.
291
+ */
292
+ hasFailureMessage(compilerWarningsAsErrors?: boolean): boolean;
293
+ clear(): void;
294
+ loadFile(filename: string): Uint8Array;
295
+ fileSize(filename: string): number;
296
+ get path(): CompilerPathCallbacks;
297
+ get fs(): CompilerFileSystemCallbacks;
298
+ resolveFilename(baseFilename: string, filename: string): string;
299
+ reportMessage(event: CompilerEvent): void;
300
+ debug(msg: string): void;
301
+ }
302
+ /**
303
+ * Abstract interface for compiler options
304
+ */
305
+ export interface CompilerBaseOptions {
306
+ /**
307
+ * Reporting level to console, used by NodeCompilerCallbacks (not used in compiler modules;
308
+ * all messages are still reported to the internal log)
309
+ */
310
+ logLevel?: CompilerLogLevel;
311
+ /**
312
+ * Format of output for log to console
313
+ */
314
+ logFormat?: CompilerLogFormat;
315
+ /**
316
+ * Colorize log output, default is detected from console
317
+ */
318
+ color?: boolean;
319
+ }
320
+ export interface CompilerOptions extends CompilerBaseOptions {
321
+ /**
322
+ * Add metadata about the compiler version to .kmx file when compiling
323
+ */
324
+ shouldAddCompilerVersion?: boolean;
325
+ /**
326
+ * Add debug information to the .kmx file when compiling
327
+ */
328
+ saveDebug?: boolean;
329
+ /**
330
+ * Upgrade any warnings produced in the compile to errors
331
+ */
332
+ compilerWarningsAsErrors?: boolean;
333
+ /**
334
+ * Emit warnings if deprecated code is encountered
335
+ */
336
+ warnDeprecatedCode?: boolean;
337
+ /**
338
+ * Check filename conventions in packages
339
+ */
340
+ checkFilenameConventions?: boolean;
341
+ }
342
+ export declare const defaultCompilerOptions: CompilerOptions;
343
+ /**
344
+ * Convenience function for constructing CompilerEvents
345
+ * @param code
346
+ * @param message
347
+ * @returns
348
+ */
349
+ export declare const CompilerMessageSpec: (code: number, message: string, exceptionVar?: any) => CompilerEvent;
350
+ /**
351
+ * @deprecated use `CompilerError.exceptionToString` instead
352
+ */
353
+ export declare function compilerExceptionToString(e?: any): string;
354
+ /**
355
+ * Compiler logging level and correspondence to severity
356
+ */
357
+ export declare const ALL_COMPILER_LOG_LEVELS: readonly ["silent", "error", "warn", "hint", "info", "debug"];
358
+ type CompilerLogLevelTuple = typeof ALL_COMPILER_LOG_LEVELS;
359
+ export type CompilerLogLevel = CompilerLogLevelTuple[number];
360
+ export declare const compilerLogLevelToSeverity: {
361
+ [index in CompilerLogLevel]: number;
362
+ };
363
+ export declare const ALL_COMPILER_LOG_FORMATS: readonly ["tsv", "formatted"];
364
+ type CompilerLogFormatTuple = typeof ALL_COMPILER_LOG_FORMATS;
365
+ export type CompilerLogFormat = CompilerLogFormatTuple[number];
366
+ export {};
367
+ //# sourceMappingURL=compiler-interfaces.d.ts.map