@keymanapp/common-types 18.0.41-alpha → 18.0.46-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/consts/virtual-key-constants.d.ts +191 -191
- package/build/src/consts/virtual-key-constants.js +221 -221
- package/build/src/consts/virtual-key-constants.js.map +1 -1
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts +5 -5
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js +72 -72
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js.map +1 -1
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts +28 -28
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js +120 -120
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js.map +1 -1
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts +95 -95
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.js +52 -52
- package/build/src/kmx/element-string.d.ts +23 -23
- package/build/src/kmx/element-string.js +125 -125
- package/build/src/kmx/element-string.js.map +1 -1
- package/build/src/kmx/keyman-targets.d.ts +20 -20
- package/build/src/kmx/keyman-targets.js +79 -79
- package/build/src/kmx/keyman-targets.js.map +1 -1
- package/build/src/kmx/kmx-builder.d.ts +32 -32
- package/build/src/kmx/kmx-builder.js +189 -189
- package/build/src/kmx/kmx-builder.js.map +1 -1
- package/build/src/kmx/kmx-file-reader.d.ts +13 -13
- package/build/src/kmx/kmx-file-reader.js +134 -134
- package/build/src/kmx/kmx-file-reader.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-disp.d.ts +18 -18
- package/build/src/kmx/kmx-plus-builder/build-disp.js +27 -27
- package/build/src/kmx/kmx-plus-builder/build-disp.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-elem.d.ts +28 -28
- package/build/src/kmx/kmx-plus-builder/build-elem.js +89 -89
- package/build/src/kmx/kmx-plus-builder/build-elem.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-keys.d.ts +56 -56
- package/build/src/kmx/kmx-plus-builder/build-keys.js +107 -107
- package/build/src/kmx/kmx-plus-builder/build-keys.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-layr.d.ts +53 -53
- package/build/src/kmx/kmx-plus-builder/build-layr.js +101 -101
- package/build/src/kmx/kmx-plus-builder/build-layr.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-list.d.ts +35 -35
- package/build/src/kmx/kmx-plus-builder/build-list.js +66 -66
- package/build/src/kmx/kmx-plus-builder/build-list.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-loca.d.ts +11 -11
- package/build/src/kmx/kmx-plus-builder/build-loca.js +21 -21
- package/build/src/kmx/kmx-plus-builder/build-loca.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-meta.d.ts +16 -16
- package/build/src/kmx/kmx-plus-builder/build-meta.js +20 -20
- package/build/src/kmx/kmx-plus-builder/build-sect.d.ts +15 -15
- package/build/src/kmx/kmx-plus-builder/build-sect.js +15 -15
- package/build/src/kmx/kmx-plus-builder/build-sect.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-strs.d.ts +22 -22
- package/build/src/kmx/kmx-plus-builder/build-strs.js +46 -46
- package/build/src/kmx/kmx-plus-builder/build-strs.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-tran.d.ts +32 -32
- package/build/src/kmx/kmx-plus-builder/build-tran.js +69 -69
- package/build/src/kmx/kmx-plus-builder/build-tran.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-uset.d.ts +30 -30
- package/build/src/kmx/kmx-plus-builder/build-uset.js +60 -60
- package/build/src/kmx/kmx-plus-builder/build-uset.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/build-vars.d.ts +21 -21
- package/build/src/kmx/kmx-plus-builder/build-vars.js +48 -48
- package/build/src/kmx/kmx-plus-builder/build-vars.js.map +1 -1
- package/build/src/kmx/kmx-plus-builder/builder-section.d.ts +9 -9
- package/build/src/kmx/kmx-plus-builder/builder-section.js +2 -2
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts +42 -42
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js +137 -137
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js.map +1 -1
- package/build/src/kmx/kmx-plus.d.ts +322 -322
- package/build/src/kmx/kmx-plus.js +830 -830
- package/build/src/kmx/kmx-plus.js.map +1 -1
- package/build/src/kmx/kmx.d.ts +233 -233
- package/build/src/kmx/kmx.js +302 -302
- package/build/src/kmx/kmx.js.map +1 -1
- package/build/src/kmx/string-list.d.ts +35 -35
- package/build/src/kmx/string-list.js +88 -88
- package/build/src/kmx/string-list.js.map +1 -1
- package/build/src/kpj/keyman-developer-project.d.ts +78 -78
- package/build/src/kpj/keyman-developer-project.js +195 -195
- package/build/src/kpj/keyman-developer-project.js.map +1 -1
- package/build/src/kpj/kpj-file-reader.d.ts +18 -18
- package/build/src/kpj/kpj-file-reader.js +119 -119
- package/build/src/kpj/kpj-file-reader.js.map +1 -1
- package/build/src/kpj/kpj-file.d.ts +39 -39
- package/build/src/kpj/kpj-file.js +10 -10
- package/build/src/kvk/kvk-file-reader.d.ts +4 -4
- package/build/src/kvk/kvk-file-reader.js +37 -37
- package/build/src/kvk/kvk-file-reader.js.map +1 -1
- package/build/src/kvk/kvk-file-writer.d.ts +19 -19
- package/build/src/kvk/kvk-file-writer.js +77 -77
- package/build/src/kvk/kvk-file-writer.js.map +1 -1
- package/build/src/kvk/kvk-file.d.ts +66 -66
- package/build/src/kvk/kvk-file.d.ts.map +1 -1
- package/build/src/kvk/kvk-file.js +90 -90
- package/build/src/kvk/kvk-file.js.map +1 -1
- package/build/src/kvk/kvks-file-reader.d.ts +23 -23
- package/build/src/kvk/kvks-file-reader.js +175 -175
- package/build/src/kvk/kvks-file-reader.js.map +1 -1
- package/build/src/kvk/kvks-file-writer.d.ts +6 -6
- package/build/src/kvk/kvks-file-writer.js +106 -106
- package/build/src/kvk/kvks-file-writer.js.map +1 -1
- package/build/src/kvk/kvks-file.d.ts +43 -43
- package/build/src/kvk/kvks-file.js +9 -9
- package/build/src/kvk/visual-keyboard.d.ts +44 -44
- package/build/src/kvk/visual-keyboard.js +75 -75
- package/build/src/kvk/visual-keyboard.js.map +1 -1
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts +60 -60
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js +19 -19
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts +95 -95
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js +409 -409
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js.map +1 -1
- package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts +170 -170
- package/build/src/ldml-keyboard/ldml-keyboard-xml.js +55 -55
- package/build/src/ldml-keyboard/pattern-parser.d.ts +201 -201
- package/build/src/ldml-keyboard/pattern-parser.js +490 -490
- package/build/src/ldml-keyboard/pattern-parser.js.map +1 -1
- package/build/src/ldml-keyboard/unicodeset-parser-api.d.ts +37 -37
- package/build/src/ldml-keyboard/unicodeset-parser-api.js +27 -27
- package/build/src/main.d.ts +33 -33
- package/build/src/main.js +32 -32
- package/build/src/package/kmp-json-file.d.ts +115 -115
- package/build/src/package/kmp-json-file.js +1 -1
- package/build/src/package/kps-file.d.ts +175 -175
- package/build/src/package/kps-file.js +15 -15
- package/build/src/schema-validators.d.ts +13 -13
- package/build/src/schema-validators.js +25 -25
- package/build/src/schemas/displaymap.schema.d.ts +57 -57
- package/build/src/schemas/displaymap.schema.js +35 -35
- package/build/src/schemas/displaymap.schema.validator.d.mts +2 -2
- package/build/src/schemas/displaymap.schema.validator.mjs +266 -266
- package/build/src/schemas/displaymap.schema.validator.mjs.map +1 -1
- package/build/src/schemas/keyboard_info.schema.d.ts +209 -209
- package/build/src/schemas/keyboard_info.schema.js +98 -98
- package/build/src/schemas/keyboard_info.schema.validator.d.mts +2 -2
- package/build/src/schemas/keyboard_info.schema.validator.mjs +1160 -1160
- package/build/src/schemas/keyboard_info.schema.validator.mjs.map +1 -1
- package/build/src/schemas/keyman-touch-layout.clean.spec.d.ts +227 -227
- package/build/src/schemas/keyman-touch-layout.clean.spec.js +151 -151
- package/build/src/schemas/keyman-touch-layout.clean.spec.validator.d.mts +2 -2
- package/build/src/schemas/keyman-touch-layout.clean.spec.validator.mjs +1094 -1094
- package/build/src/schemas/keyman-touch-layout.clean.spec.validator.mjs.map +1 -1
- package/build/src/schemas/keyman-touch-layout.spec.d.ts +229 -229
- package/build/src/schemas/keyman-touch-layout.spec.js +140 -140
- package/build/src/schemas/keyman-touch-layout.spec.validator.d.mts +2 -2
- package/build/src/schemas/keyman-touch-layout.spec.validator.mjs +1436 -1436
- package/build/src/schemas/keyman-touch-layout.spec.validator.mjs.map +1 -1
- package/build/src/schemas/kmp.schema.d.ts +324 -324
- package/build/src/schemas/kmp.schema.js +353 -353
- package/build/src/schemas/kmp.schema.validator.d.mts +2 -2
- package/build/src/schemas/kmp.schema.validator.mjs +1627 -1627
- package/build/src/schemas/kmp.schema.validator.mjs.map +1 -1
- package/build/src/schemas/kpj-9.0.schema.d.ts +152 -152
- package/build/src/schemas/kpj-9.0.schema.js +131 -131
- package/build/src/schemas/kpj-9.0.schema.validator.d.mts +2 -2
- package/build/src/schemas/kpj-9.0.schema.validator.mjs +655 -655
- package/build/src/schemas/kpj-9.0.schema.validator.mjs.map +1 -1
- package/build/src/schemas/kpj.schema.d.ts +122 -122
- package/build/src/schemas/kpj.schema.js +129 -129
- package/build/src/schemas/kpj.schema.validator.d.mts +2 -2
- package/build/src/schemas/kpj.schema.validator.mjs +515 -515
- package/build/src/schemas/kpj.schema.validator.mjs.map +1 -1
- package/build/src/schemas/kvks.schema.d.ts +160 -160
- package/build/src/schemas/kvks.schema.js +182 -182
- package/build/src/schemas/kvks.schema.validator.d.mts +2 -2
- package/build/src/schemas/kvks.schema.validator.mjs +625 -625
- package/build/src/schemas/kvks.schema.validator.mjs.map +1 -1
- package/build/src/schemas/ldml-keyboard3.schema.d.ts +635 -635
- package/build/src/schemas/ldml-keyboard3.schema.js +696 -696
- package/build/src/schemas/ldml-keyboard3.schema.validator.d.mts +2 -2
- package/build/src/schemas/ldml-keyboard3.schema.validator.mjs +3117 -3117
- package/build/src/schemas/ldml-keyboard3.schema.validator.mjs.map +1 -1
- package/build/src/schemas/ldml-keyboardtest3.schema.d.ts +192 -192
- package/build/src/schemas/ldml-keyboardtest3.schema.js +225 -225
- package/build/src/schemas/ldml-keyboardtest3.schema.validator.d.mts +2 -2
- package/build/src/schemas/ldml-keyboardtest3.schema.validator.mjs +744 -744
- package/build/src/schemas/ldml-keyboardtest3.schema.validator.mjs.map +1 -1
- package/build/src/schemas.d.ts +2300 -2300
- package/build/src/schemas.js +23 -23
- package/build/src/util/common-events.d.ts +44 -44
- package/build/src/util/common-events.js +26 -26
- package/build/src/util/compiler-interfaces.d.ts +371 -371
- package/build/src/util/compiler-interfaces.d.ts.map +1 -1
- package/build/src/util/compiler-interfaces.js +380 -380
- package/build/src/util/compiler-interfaces.js.map +1 -1
- package/build/src/util/errors.d.ts +5 -5
- package/build/src/util/errors.js +5 -5
- package/build/src/util/file-types.d.ts +93 -93
- package/build/src/util/file-types.d.ts.map +1 -1
- package/build/src/util/file-types.js +142 -142
- package/build/src/util/file-types.js.map +1 -1
- package/build/src/util/util.d.ts +98 -98
- package/build/src/util/util.js +368 -368
- package/build/src/util/util.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,382 +1,382 @@
|
|
|
1
1
|
|
|
2
|
-
!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]="
|
|
3
|
-
;
|
|
4
|
-
export var CompilerErrorSeverity;
|
|
5
|
-
(function (CompilerErrorSeverity) {
|
|
6
|
-
CompilerErrorSeverity[CompilerErrorSeverity["Info"] = 0] = "Info";
|
|
7
|
-
CompilerErrorSeverity[CompilerErrorSeverity["Hint"] = 1048576] = "Hint";
|
|
8
|
-
CompilerErrorSeverity[CompilerErrorSeverity["Warn"] = 2097152] = "Warn";
|
|
9
|
-
CompilerErrorSeverity[CompilerErrorSeverity["Error"] = 3145728] = "Error";
|
|
10
|
-
CompilerErrorSeverity[CompilerErrorSeverity["Fatal"] = 4194304] = "Fatal";
|
|
11
|
-
})(CompilerErrorSeverity || (CompilerErrorSeverity = {}));
|
|
12
|
-
;
|
|
13
|
-
export const CompilerErrorSeverityValues = [
|
|
14
|
-
CompilerErrorSeverity.Info,
|
|
15
|
-
CompilerErrorSeverity.Hint,
|
|
16
|
-
CompilerErrorSeverity.Warn,
|
|
17
|
-
CompilerErrorSeverity.Error,
|
|
18
|
-
CompilerErrorSeverity.Fatal,
|
|
19
|
-
];
|
|
20
|
-
/**
|
|
21
|
-
* Mask values for mapping compiler errors
|
|
22
|
-
*/
|
|
23
|
-
export var CompilerErrorMask;
|
|
24
|
-
(function (CompilerErrorMask) {
|
|
25
|
-
CompilerErrorMask[CompilerErrorMask["Severity"] = 15728640] = "Severity";
|
|
26
|
-
CompilerErrorMask[CompilerErrorMask["Error"] = 1048575] = "Error";
|
|
27
|
-
CompilerErrorMask[CompilerErrorMask["Namespace"] = 1044480] = "Namespace";
|
|
28
|
-
CompilerErrorMask[CompilerErrorMask["BaseError"] = 4095] = "BaseError";
|
|
29
|
-
CompilerErrorMask[CompilerErrorMask["Reserved"] = 4278190080] = "Reserved";
|
|
30
|
-
})(CompilerErrorMask || (CompilerErrorMask = {}));
|
|
31
|
-
;
|
|
32
|
-
const errorSeverityName = {
|
|
33
|
-
[CompilerErrorSeverity.Info]: 'info',
|
|
34
|
-
[CompilerErrorSeverity.Hint]: 'hint',
|
|
35
|
-
[CompilerErrorSeverity.Warn]: 'warn',
|
|
36
|
-
[CompilerErrorSeverity.Error]: 'error',
|
|
37
|
-
[CompilerErrorSeverity.Fatal]: 'fatal',
|
|
38
|
-
};
|
|
39
|
-
export class CompilerError {
|
|
40
|
-
static severity(code) {
|
|
41
|
-
return code & CompilerErrorMask.Severity;
|
|
42
|
-
}
|
|
43
|
-
static error(code) {
|
|
44
|
-
return code & CompilerErrorMask.Error;
|
|
45
|
-
}
|
|
46
|
-
static baseError(code) {
|
|
47
|
-
return code & CompilerErrorMask.BaseError;
|
|
48
|
-
}
|
|
49
|
-
static namespace(code) {
|
|
50
|
-
return code & CompilerErrorMask.Namespace;
|
|
51
|
-
}
|
|
52
|
-
static formatSeverity(code) {
|
|
53
|
-
return errorSeverityName[CompilerError.severity(code)] ?? 'UNKNOWN';
|
|
54
|
-
}
|
|
55
|
-
/** true if events has at least one message of the atLeast severity */
|
|
56
|
-
static hasSeverity(events, atLeast) {
|
|
57
|
-
for (const { code } of events) {
|
|
58
|
-
if (CompilerError.severity(code) >= atLeast) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
/** true if events has at least one Error or worse */
|
|
65
|
-
static hasError(events) {
|
|
66
|
-
return CompilerError.hasSeverity(events, CompilerErrorSeverity.Error);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Format an error code number. The error code number does not include
|
|
70
|
-
* the severity mask, as this is reported in text form separately; see
|
|
71
|
-
* `severityName`.
|
|
72
|
-
* @example
|
|
73
|
-
*
|
|
74
|
-
* The following call returns `KM03004`
|
|
75
|
-
* ```
|
|
76
|
-
* formatCode(CompilerMessage.ERROR_InvalidDisplayMapFile)
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
static formatCode(code) {
|
|
80
|
-
return Number.isInteger(code) ? 'KM' + CompilerError.error(code).toString(16).toUpperCase().padStart(5, '0') : 'KM?????';
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Formats an event filename for an error report,
|
|
84
|
-
* stripping off path component
|
|
85
|
-
* @param filename
|
|
86
|
-
* @returns
|
|
87
|
-
*/
|
|
88
|
-
static formatFilename(filename, options) {
|
|
89
|
-
if (!filename) {
|
|
90
|
-
return '';
|
|
91
|
-
}
|
|
92
|
-
if (options?.fullPath) {
|
|
93
|
-
return options?.forwardSlashes ?
|
|
94
|
-
filename.replaceAll(/\\/g, '/') :
|
|
95
|
-
filename.replaceAll(/\//g, '\\');
|
|
96
|
-
}
|
|
97
|
-
let x = filename.lastIndexOf('/');
|
|
98
|
-
if (x < 0) {
|
|
99
|
-
x = filename.lastIndexOf('\\');
|
|
100
|
-
}
|
|
101
|
-
return x >= 0 ? filename.substring(x + 1) : filename;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Formats an event line for an error report
|
|
105
|
-
* @param line
|
|
106
|
-
* @returns
|
|
107
|
-
*/
|
|
108
|
-
static formatLine(line) {
|
|
109
|
-
return line ? line.toString() : '';
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Formats an event message for an error report
|
|
113
|
-
* @param message
|
|
114
|
-
* @returns
|
|
115
|
-
*/
|
|
116
|
-
static formatMessage(message) {
|
|
117
|
-
return message ?? '';
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Formats a compiler message, without coloring; an ANSI color version is
|
|
121
|
-
* implemented in NodeCompilerCallbacks.
|
|
122
|
-
* @param event event or array of events
|
|
123
|
-
*/
|
|
124
|
-
static formatEvent(event) {
|
|
125
|
-
if (!event) {
|
|
126
|
-
return "";
|
|
127
|
-
}
|
|
128
|
-
if (Array.isArray(event)) {
|
|
129
|
-
return event.map(item => CompilerError.formatEvent(item)).join('\n') + '\n';
|
|
130
|
-
}
|
|
131
|
-
return (event.filename
|
|
132
|
-
? CompilerError.formatFilename(event.filename) +
|
|
133
|
-
(event.line ? ':' + CompilerError.formatLine(event.line) : '') + ' - '
|
|
134
|
-
: '') +
|
|
135
|
-
CompilerError.formatSeverity(event.code) + ' ' +
|
|
136
|
-
CompilerError.formatCode(event.code) + ': ' +
|
|
137
|
-
CompilerError.formatMessage(event.message);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* @param e Error-like
|
|
141
|
-
*/
|
|
142
|
-
static exceptionToString(e) {
|
|
143
|
-
return `${(e ?? 'unknown error').toString()}\n\nCall stack:\n${(e instanceof Error ? e.stack : (new Error()).stack)}`;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Returns the corresponding error severity value from a partial name match,
|
|
147
|
-
* e.g. 'inf' returns CompilerErrorSeverity.Info, or returns null if not found
|
|
148
|
-
* @param name
|
|
149
|
-
* @returns
|
|
150
|
-
*/
|
|
151
|
-
static severityNameToValue(name) {
|
|
152
|
-
name = name.toLowerCase();
|
|
153
|
-
for (let level of CompilerErrorSeverityValues) {
|
|
154
|
-
if (errorSeverityName[level].startsWith(name)) {
|
|
155
|
-
return level;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
;
|
|
162
|
-
/** @deprecated use `CompilerError.severity` instead */
|
|
163
|
-
export function compilerErrorSeverity(code) {
|
|
164
|
-
return CompilerError.severity(code);
|
|
165
|
-
}
|
|
166
|
-
/** @deprecated use `CompilerError.formatSeverity` instead */
|
|
167
|
-
export function compilerErrorSeverityName(code) {
|
|
168
|
-
return CompilerError.formatSeverity(code);
|
|
169
|
-
}
|
|
170
|
-
/** @deprecated use `CompilerError.formatCode` instead */
|
|
171
|
-
export function compilerErrorFormatCode(code) {
|
|
172
|
-
return CompilerError.formatCode(code);
|
|
173
|
-
}
|
|
174
|
-
/** @deprecated use `CompilerError.formatEvent` instead */
|
|
175
|
-
export function compilerEventFormat(e) {
|
|
176
|
-
return CompilerError.formatEvent(e);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Defines the error code ranges for various compilers. Once defined, these
|
|
180
|
-
* ranges must not be changed as external modules may depend on specific error
|
|
181
|
-
* codes. Individual errors are defined at a compiler level, for example,
|
|
182
|
-
* kmc-ldml/src/compiler/messages.ts.
|
|
183
|
-
*
|
|
184
|
-
* kmc defines a mapping between each namespace and the corresponding compiler's
|
|
185
|
-
* error reporting class in kmc/src/messages/messageNamespaces.ts
|
|
186
|
-
*/
|
|
187
|
-
export var CompilerErrorNamespace;
|
|
188
|
-
(function (CompilerErrorNamespace) {
|
|
189
|
-
/**
|
|
190
|
-
* kmc-ldml errors between 0x0000…0x0FFF
|
|
191
|
-
*/
|
|
192
|
-
CompilerErrorNamespace[CompilerErrorNamespace["LdmlKeyboardCompiler"] = 0] = "LdmlKeyboardCompiler";
|
|
193
|
-
/**
|
|
194
|
-
* common/web/types errors between 0x1000…0x1FFF
|
|
195
|
-
*/
|
|
196
|
-
CompilerErrorNamespace[CompilerErrorNamespace["CommonTypes"] = 4096] = "CommonTypes";
|
|
197
|
-
/**
|
|
198
|
-
* kmc-kmn errors between 0x2000…0x2FFF; these map to
|
|
199
|
-
* the base codes found in kmn_compiler_errors.h, exclusive severity flags
|
|
200
|
-
*/
|
|
201
|
-
CompilerErrorNamespace[CompilerErrorNamespace["KmnCompiler"] = 8192] = "KmnCompiler";
|
|
202
|
-
/**
|
|
203
|
-
* kmc-model errors between 0x3000…0x3FFF
|
|
204
|
-
*/
|
|
205
|
-
CompilerErrorNamespace[CompilerErrorNamespace["ModelCompiler"] = 12288] = "ModelCompiler";
|
|
206
|
-
/**
|
|
207
|
-
* kmc-package errors between 0x4000…0x4FFF
|
|
208
|
-
*/
|
|
209
|
-
CompilerErrorNamespace[CompilerErrorNamespace["PackageCompiler"] = 16384] = "PackageCompiler";
|
|
210
|
-
/**
|
|
211
|
-
* kmc and related infrastructure errors between 0x5000…0x5FFF
|
|
212
|
-
*/
|
|
213
|
-
CompilerErrorNamespace[CompilerErrorNamespace["Infrastructure"] = 20480] = "Infrastructure";
|
|
214
|
-
/**
|
|
215
|
-
* kmc-analyze 0x6000…0x6FFF
|
|
216
|
-
*/
|
|
217
|
-
CompilerErrorNamespace[CompilerErrorNamespace["Analyzer"] = 24576] = "Analyzer";
|
|
218
|
-
/**
|
|
219
|
-
* kmc-kmn/kmw-compiler errors between 0x7000…0x7FFF; note that some errors
|
|
220
|
-
* generated by kmc-kmn/kmw-compiler are from kmc-kmn namespace for legacy
|
|
221
|
-
* reasons
|
|
222
|
-
*/
|
|
223
|
-
CompilerErrorNamespace[CompilerErrorNamespace["KmwCompiler"] = 28672] = "KmwCompiler";
|
|
224
|
-
/**
|
|
225
|
-
* kmc-model-info 0x8000…0x8FFF
|
|
226
|
-
*/
|
|
227
|
-
CompilerErrorNamespace[CompilerErrorNamespace["ModelInfoCompiler"] = 32768] = "ModelInfoCompiler";
|
|
228
|
-
/**
|
|
229
|
-
* kmc-keyboard-info 0x9000…0x9FFF
|
|
230
|
-
*/
|
|
231
|
-
CompilerErrorNamespace[CompilerErrorNamespace["KeyboardInfoCompiler"] = 36864] = "KeyboardInfoCompiler";
|
|
232
|
-
})(CompilerErrorNamespace || (CompilerErrorNamespace = {}));
|
|
233
|
-
;
|
|
234
|
-
;
|
|
235
|
-
;
|
|
236
|
-
;
|
|
237
|
-
;
|
|
238
|
-
;
|
|
239
|
-
;
|
|
240
|
-
;
|
|
241
|
-
;
|
|
242
|
-
/**
|
|
243
|
-
* Wrapper class for CompilerCallbacks for a given input file
|
|
244
|
-
*/
|
|
245
|
-
export class CompilerFileCallbacks {
|
|
246
|
-
filename;
|
|
247
|
-
options;
|
|
248
|
-
parent;
|
|
249
|
-
messages = [];
|
|
250
|
-
constructor(filename, options, parent) {
|
|
251
|
-
this.filename = filename;
|
|
252
|
-
this.options = options;
|
|
253
|
-
this.parent = parent;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Returns `true` if any message in the `messages` array is a Fatal or Error
|
|
257
|
-
* message, and if `compilerWarningsAsErrors` is `true`, then also returns
|
|
258
|
-
* `true` if any message is a Warning.
|
|
259
|
-
*/
|
|
260
|
-
static hasFailureMessage(messages, compilerWarningsAsErrors) {
|
|
261
|
-
const failureCodes = [
|
|
262
|
-
CompilerErrorSeverity.Fatal, CompilerErrorSeverity.Error
|
|
263
|
-
].concat(compilerWarningsAsErrors ? [CompilerErrorSeverity.Warn] : []);
|
|
264
|
-
return messages.find(m => failureCodes.includes(CompilerError.severity(m.code))) != undefined;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
*
|
|
268
|
-
* @param event
|
|
269
|
-
* @param overrides
|
|
270
|
-
* @returns true if event has been suppressed
|
|
271
|
-
*/
|
|
272
|
-
static applyMessageOverridesToEvent(event, overrides) {
|
|
273
|
-
// Override event severity from user preference -- this will not override
|
|
274
|
-
// fatal or error events
|
|
275
|
-
const severity = overrides?.[CompilerError.error(event.code)] ??
|
|
276
|
-
CompilerError.severity(event.code);
|
|
277
|
-
if (severity == 'disable') {
|
|
278
|
-
return true;
|
|
279
|
-
}
|
|
280
|
-
// Override the default event severity with the command line option
|
|
281
|
-
event.code = severity | (event.code & ~CompilerErrorMask.Severity);
|
|
282
|
-
return false;
|
|
283
|
-
}
|
|
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) {
|
|
294
|
-
return CompilerFileCallbacks.hasFailureMessage(this.messages, compilerWarningsAsErrors ?? this.options.compilerWarningsAsErrors ?? false);
|
|
295
|
-
}
|
|
296
|
-
clear() {
|
|
297
|
-
this.messages = [];
|
|
298
|
-
}
|
|
299
|
-
loadFile(filename) {
|
|
300
|
-
return this.parent.loadFile(filename);
|
|
301
|
-
}
|
|
302
|
-
fileSize(filename) {
|
|
303
|
-
return this.parent.fileSize(filename);
|
|
304
|
-
}
|
|
305
|
-
get path() {
|
|
306
|
-
return this.parent.path;
|
|
307
|
-
}
|
|
308
|
-
get fs() {
|
|
309
|
-
return this.parent.fs;
|
|
310
|
-
}
|
|
311
|
-
resolveFilename(baseFilename, filename) {
|
|
312
|
-
return this.parent.resolveFilename(baseFilename, filename);
|
|
313
|
-
}
|
|
314
|
-
reportMessage(event) {
|
|
315
|
-
const disable = CompilerFileCallbacks.applyMessageOverridesToEvent(event, this.options.messageOverrides);
|
|
316
|
-
this.messages.push(event);
|
|
317
|
-
if (!disable) {
|
|
318
|
-
this.parent.reportMessage({ filename: this.filename, ...event });
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
debug(msg) {
|
|
322
|
-
return this.parent.debug(msg);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
;
|
|
326
|
-
export const defaultCompilerOptions = {
|
|
327
|
-
logLevel: 'info',
|
|
328
|
-
logFormat: 'formatted',
|
|
329
|
-
// outFile: (undefined)
|
|
330
|
-
saveDebug: false,
|
|
331
|
-
shouldAddCompilerVersion: true,
|
|
332
|
-
compilerWarningsAsErrors: false,
|
|
333
|
-
warnDeprecatedCode: true,
|
|
334
|
-
checkFilenameConventions: false,
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* Convenience function for constructing CompilerEvents
|
|
338
|
-
* @param code Unique numeric value of the event
|
|
339
|
-
* @param message A short description of the error presented to the user
|
|
340
|
-
* @param detail Detailed Markdown-formatted description of the error
|
|
341
|
-
* including references to documentation, remediation options.
|
|
342
|
-
* @returns
|
|
343
|
-
*/
|
|
344
|
-
export const CompilerMessageSpec = (code, message, detail) => ({
|
|
345
|
-
code,
|
|
346
|
-
message,
|
|
347
|
-
detail,
|
|
348
|
-
});
|
|
349
|
-
export const CompilerMessageDef = (param) => String(param ?? `<param>`);
|
|
350
|
-
export const CompilerMessageSpecWithException = (code, message, exceptionVar, detail) => ({
|
|
351
|
-
code,
|
|
352
|
-
message: exceptionVar
|
|
353
|
-
? (message ?? `Unexpected exception`) + `: ${exceptionVar.toString()}\n\nCall stack:\n${(exceptionVar instanceof Error ? exceptionVar.stack : (new Error()).stack)}` :
|
|
354
|
-
message,
|
|
355
|
-
detail,
|
|
356
|
-
exceptionVar,
|
|
357
|
-
});
|
|
358
|
-
/**
|
|
359
|
-
* Compiler logging level and correspondence to severity
|
|
360
|
-
*/
|
|
361
|
-
export const ALL_COMPILER_LOG_LEVELS = [
|
|
362
|
-
'silent',
|
|
363
|
-
'error',
|
|
364
|
-
'warn',
|
|
365
|
-
'hint',
|
|
366
|
-
'info',
|
|
367
|
-
'debug' /// All messages: errors + warnings + hints + info, plus debug logs
|
|
368
|
-
];
|
|
369
|
-
export const compilerLogLevelToSeverity = {
|
|
370
|
-
'silent': CompilerErrorMask.Severity,
|
|
371
|
-
'error': CompilerErrorSeverity.Error,
|
|
372
|
-
'warn': CompilerErrorSeverity.Warn,
|
|
373
|
-
'hint': CompilerErrorSeverity.Hint,
|
|
374
|
-
'info': CompilerErrorSeverity.Info,
|
|
375
|
-
'debug': CompilerErrorSeverity.Info
|
|
376
|
-
};
|
|
377
|
-
export const ALL_COMPILER_LOG_FORMATS = [
|
|
378
|
-
'tsv',
|
|
379
|
-
'formatted'
|
|
380
|
-
];
|
|
2
|
+
!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]="700d18cd-bca6-5162-a68e-85e89dc556ea")}catch(e){}}();
|
|
3
|
+
;
|
|
4
|
+
export var CompilerErrorSeverity;
|
|
5
|
+
(function (CompilerErrorSeverity) {
|
|
6
|
+
CompilerErrorSeverity[CompilerErrorSeverity["Info"] = 0] = "Info";
|
|
7
|
+
CompilerErrorSeverity[CompilerErrorSeverity["Hint"] = 1048576] = "Hint";
|
|
8
|
+
CompilerErrorSeverity[CompilerErrorSeverity["Warn"] = 2097152] = "Warn";
|
|
9
|
+
CompilerErrorSeverity[CompilerErrorSeverity["Error"] = 3145728] = "Error";
|
|
10
|
+
CompilerErrorSeverity[CompilerErrorSeverity["Fatal"] = 4194304] = "Fatal";
|
|
11
|
+
})(CompilerErrorSeverity || (CompilerErrorSeverity = {}));
|
|
12
|
+
;
|
|
13
|
+
export const CompilerErrorSeverityValues = [
|
|
14
|
+
CompilerErrorSeverity.Info,
|
|
15
|
+
CompilerErrorSeverity.Hint,
|
|
16
|
+
CompilerErrorSeverity.Warn,
|
|
17
|
+
CompilerErrorSeverity.Error,
|
|
18
|
+
CompilerErrorSeverity.Fatal,
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Mask values for mapping compiler errors
|
|
22
|
+
*/
|
|
23
|
+
export var CompilerErrorMask;
|
|
24
|
+
(function (CompilerErrorMask) {
|
|
25
|
+
CompilerErrorMask[CompilerErrorMask["Severity"] = 15728640] = "Severity";
|
|
26
|
+
CompilerErrorMask[CompilerErrorMask["Error"] = 1048575] = "Error";
|
|
27
|
+
CompilerErrorMask[CompilerErrorMask["Namespace"] = 1044480] = "Namespace";
|
|
28
|
+
CompilerErrorMask[CompilerErrorMask["BaseError"] = 4095] = "BaseError";
|
|
29
|
+
CompilerErrorMask[CompilerErrorMask["Reserved"] = 4278190080] = "Reserved";
|
|
30
|
+
})(CompilerErrorMask || (CompilerErrorMask = {}));
|
|
31
|
+
;
|
|
32
|
+
const errorSeverityName = {
|
|
33
|
+
[CompilerErrorSeverity.Info]: 'info',
|
|
34
|
+
[CompilerErrorSeverity.Hint]: 'hint',
|
|
35
|
+
[CompilerErrorSeverity.Warn]: 'warn',
|
|
36
|
+
[CompilerErrorSeverity.Error]: 'error',
|
|
37
|
+
[CompilerErrorSeverity.Fatal]: 'fatal',
|
|
38
|
+
};
|
|
39
|
+
export class CompilerError {
|
|
40
|
+
static severity(code) {
|
|
41
|
+
return code & CompilerErrorMask.Severity;
|
|
42
|
+
}
|
|
43
|
+
static error(code) {
|
|
44
|
+
return code & CompilerErrorMask.Error;
|
|
45
|
+
}
|
|
46
|
+
static baseError(code) {
|
|
47
|
+
return code & CompilerErrorMask.BaseError;
|
|
48
|
+
}
|
|
49
|
+
static namespace(code) {
|
|
50
|
+
return code & CompilerErrorMask.Namespace;
|
|
51
|
+
}
|
|
52
|
+
static formatSeverity(code) {
|
|
53
|
+
return errorSeverityName[CompilerError.severity(code)] ?? 'UNKNOWN';
|
|
54
|
+
}
|
|
55
|
+
/** true if events has at least one message of the atLeast severity */
|
|
56
|
+
static hasSeverity(events, atLeast) {
|
|
57
|
+
for (const { code } of events) {
|
|
58
|
+
if (CompilerError.severity(code) >= atLeast) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
/** true if events has at least one Error or worse */
|
|
65
|
+
static hasError(events) {
|
|
66
|
+
return CompilerError.hasSeverity(events, CompilerErrorSeverity.Error);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Format an error code number. The error code number does not include
|
|
70
|
+
* the severity mask, as this is reported in text form separately; see
|
|
71
|
+
* `severityName`.
|
|
72
|
+
* @example
|
|
73
|
+
*
|
|
74
|
+
* The following call returns `KM03004`
|
|
75
|
+
* ```
|
|
76
|
+
* formatCode(CompilerMessage.ERROR_InvalidDisplayMapFile)
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
static formatCode(code) {
|
|
80
|
+
return Number.isInteger(code) ? 'KM' + CompilerError.error(code).toString(16).toUpperCase().padStart(5, '0') : 'KM?????';
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Formats an event filename for an error report,
|
|
84
|
+
* stripping off path component
|
|
85
|
+
* @param filename
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
static formatFilename(filename, options) {
|
|
89
|
+
if (!filename) {
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
92
|
+
if (options?.fullPath) {
|
|
93
|
+
return options?.forwardSlashes ?
|
|
94
|
+
filename.replaceAll(/\\/g, '/') :
|
|
95
|
+
filename.replaceAll(/\//g, '\\');
|
|
96
|
+
}
|
|
97
|
+
let x = filename.lastIndexOf('/');
|
|
98
|
+
if (x < 0) {
|
|
99
|
+
x = filename.lastIndexOf('\\');
|
|
100
|
+
}
|
|
101
|
+
return x >= 0 ? filename.substring(x + 1) : filename;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Formats an event line for an error report
|
|
105
|
+
* @param line
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
static formatLine(line) {
|
|
109
|
+
return line ? line.toString() : '';
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Formats an event message for an error report
|
|
113
|
+
* @param message
|
|
114
|
+
* @returns
|
|
115
|
+
*/
|
|
116
|
+
static formatMessage(message) {
|
|
117
|
+
return message ?? '';
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Formats a compiler message, without coloring; an ANSI color version is
|
|
121
|
+
* implemented in NodeCompilerCallbacks.
|
|
122
|
+
* @param event event or array of events
|
|
123
|
+
*/
|
|
124
|
+
static formatEvent(event) {
|
|
125
|
+
if (!event) {
|
|
126
|
+
return "";
|
|
127
|
+
}
|
|
128
|
+
if (Array.isArray(event)) {
|
|
129
|
+
return event.map(item => CompilerError.formatEvent(item)).join('\n') + '\n';
|
|
130
|
+
}
|
|
131
|
+
return (event.filename
|
|
132
|
+
? CompilerError.formatFilename(event.filename) +
|
|
133
|
+
(event.line ? ':' + CompilerError.formatLine(event.line) : '') + ' - '
|
|
134
|
+
: '') +
|
|
135
|
+
CompilerError.formatSeverity(event.code) + ' ' +
|
|
136
|
+
CompilerError.formatCode(event.code) + ': ' +
|
|
137
|
+
CompilerError.formatMessage(event.message);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @param e Error-like
|
|
141
|
+
*/
|
|
142
|
+
static exceptionToString(e) {
|
|
143
|
+
return `${(e ?? 'unknown error').toString()}\n\nCall stack:\n${(e instanceof Error ? e.stack : (new Error()).stack)}`;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Returns the corresponding error severity value from a partial name match,
|
|
147
|
+
* e.g. 'inf' returns CompilerErrorSeverity.Info, or returns null if not found
|
|
148
|
+
* @param name
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
static severityNameToValue(name) {
|
|
152
|
+
name = name.toLowerCase();
|
|
153
|
+
for (let level of CompilerErrorSeverityValues) {
|
|
154
|
+
if (errorSeverityName[level].startsWith(name)) {
|
|
155
|
+
return level;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
;
|
|
162
|
+
/** @deprecated use `CompilerError.severity` instead */
|
|
163
|
+
export function compilerErrorSeverity(code) {
|
|
164
|
+
return CompilerError.severity(code);
|
|
165
|
+
}
|
|
166
|
+
/** @deprecated use `CompilerError.formatSeverity` instead */
|
|
167
|
+
export function compilerErrorSeverityName(code) {
|
|
168
|
+
return CompilerError.formatSeverity(code);
|
|
169
|
+
}
|
|
170
|
+
/** @deprecated use `CompilerError.formatCode` instead */
|
|
171
|
+
export function compilerErrorFormatCode(code) {
|
|
172
|
+
return CompilerError.formatCode(code);
|
|
173
|
+
}
|
|
174
|
+
/** @deprecated use `CompilerError.formatEvent` instead */
|
|
175
|
+
export function compilerEventFormat(e) {
|
|
176
|
+
return CompilerError.formatEvent(e);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Defines the error code ranges for various compilers. Once defined, these
|
|
180
|
+
* ranges must not be changed as external modules may depend on specific error
|
|
181
|
+
* codes. Individual errors are defined at a compiler level, for example,
|
|
182
|
+
* kmc-ldml/src/compiler/messages.ts.
|
|
183
|
+
*
|
|
184
|
+
* kmc defines a mapping between each namespace and the corresponding compiler's
|
|
185
|
+
* error reporting class in kmc/src/messages/messageNamespaces.ts
|
|
186
|
+
*/
|
|
187
|
+
export var CompilerErrorNamespace;
|
|
188
|
+
(function (CompilerErrorNamespace) {
|
|
189
|
+
/**
|
|
190
|
+
* kmc-ldml errors between 0x0000…0x0FFF
|
|
191
|
+
*/
|
|
192
|
+
CompilerErrorNamespace[CompilerErrorNamespace["LdmlKeyboardCompiler"] = 0] = "LdmlKeyboardCompiler";
|
|
193
|
+
/**
|
|
194
|
+
* common/web/types errors between 0x1000…0x1FFF
|
|
195
|
+
*/
|
|
196
|
+
CompilerErrorNamespace[CompilerErrorNamespace["CommonTypes"] = 4096] = "CommonTypes";
|
|
197
|
+
/**
|
|
198
|
+
* kmc-kmn errors between 0x2000…0x2FFF; these map to
|
|
199
|
+
* the base codes found in kmn_compiler_errors.h, exclusive severity flags
|
|
200
|
+
*/
|
|
201
|
+
CompilerErrorNamespace[CompilerErrorNamespace["KmnCompiler"] = 8192] = "KmnCompiler";
|
|
202
|
+
/**
|
|
203
|
+
* kmc-model errors between 0x3000…0x3FFF
|
|
204
|
+
*/
|
|
205
|
+
CompilerErrorNamespace[CompilerErrorNamespace["ModelCompiler"] = 12288] = "ModelCompiler";
|
|
206
|
+
/**
|
|
207
|
+
* kmc-package errors between 0x4000…0x4FFF
|
|
208
|
+
*/
|
|
209
|
+
CompilerErrorNamespace[CompilerErrorNamespace["PackageCompiler"] = 16384] = "PackageCompiler";
|
|
210
|
+
/**
|
|
211
|
+
* kmc and related infrastructure errors between 0x5000…0x5FFF
|
|
212
|
+
*/
|
|
213
|
+
CompilerErrorNamespace[CompilerErrorNamespace["Infrastructure"] = 20480] = "Infrastructure";
|
|
214
|
+
/**
|
|
215
|
+
* kmc-analyze 0x6000…0x6FFF
|
|
216
|
+
*/
|
|
217
|
+
CompilerErrorNamespace[CompilerErrorNamespace["Analyzer"] = 24576] = "Analyzer";
|
|
218
|
+
/**
|
|
219
|
+
* kmc-kmn/kmw-compiler errors between 0x7000…0x7FFF; note that some errors
|
|
220
|
+
* generated by kmc-kmn/kmw-compiler are from kmc-kmn namespace for legacy
|
|
221
|
+
* reasons
|
|
222
|
+
*/
|
|
223
|
+
CompilerErrorNamespace[CompilerErrorNamespace["KmwCompiler"] = 28672] = "KmwCompiler";
|
|
224
|
+
/**
|
|
225
|
+
* kmc-model-info 0x8000…0x8FFF
|
|
226
|
+
*/
|
|
227
|
+
CompilerErrorNamespace[CompilerErrorNamespace["ModelInfoCompiler"] = 32768] = "ModelInfoCompiler";
|
|
228
|
+
/**
|
|
229
|
+
* kmc-keyboard-info 0x9000…0x9FFF
|
|
230
|
+
*/
|
|
231
|
+
CompilerErrorNamespace[CompilerErrorNamespace["KeyboardInfoCompiler"] = 36864] = "KeyboardInfoCompiler";
|
|
232
|
+
})(CompilerErrorNamespace || (CompilerErrorNamespace = {}));
|
|
233
|
+
;
|
|
234
|
+
;
|
|
235
|
+
;
|
|
236
|
+
;
|
|
237
|
+
;
|
|
238
|
+
;
|
|
239
|
+
;
|
|
240
|
+
;
|
|
241
|
+
;
|
|
242
|
+
/**
|
|
243
|
+
* Wrapper class for CompilerCallbacks for a given input file
|
|
244
|
+
*/
|
|
245
|
+
export class CompilerFileCallbacks {
|
|
246
|
+
filename;
|
|
247
|
+
options;
|
|
248
|
+
parent;
|
|
249
|
+
messages = [];
|
|
250
|
+
constructor(filename, options, parent) {
|
|
251
|
+
this.filename = filename;
|
|
252
|
+
this.options = options;
|
|
253
|
+
this.parent = parent;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Returns `true` if any message in the `messages` array is a Fatal or Error
|
|
257
|
+
* message, and if `compilerWarningsAsErrors` is `true`, then also returns
|
|
258
|
+
* `true` if any message is a Warning.
|
|
259
|
+
*/
|
|
260
|
+
static hasFailureMessage(messages, compilerWarningsAsErrors) {
|
|
261
|
+
const failureCodes = [
|
|
262
|
+
CompilerErrorSeverity.Fatal, CompilerErrorSeverity.Error
|
|
263
|
+
].concat(compilerWarningsAsErrors ? [CompilerErrorSeverity.Warn] : []);
|
|
264
|
+
return messages.find(m => failureCodes.includes(CompilerError.severity(m.code))) != undefined;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
*
|
|
268
|
+
* @param event
|
|
269
|
+
* @param overrides
|
|
270
|
+
* @returns true if event has been suppressed
|
|
271
|
+
*/
|
|
272
|
+
static applyMessageOverridesToEvent(event, overrides) {
|
|
273
|
+
// Override event severity from user preference -- this will not override
|
|
274
|
+
// fatal or error events
|
|
275
|
+
const severity = overrides?.[CompilerError.error(event.code)] ??
|
|
276
|
+
CompilerError.severity(event.code);
|
|
277
|
+
if (severity == 'disable') {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
// Override the default event severity with the command line option
|
|
281
|
+
event.code = severity | (event.code & ~CompilerErrorMask.Severity);
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
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) {
|
|
294
|
+
return CompilerFileCallbacks.hasFailureMessage(this.messages, compilerWarningsAsErrors ?? this.options.compilerWarningsAsErrors ?? false);
|
|
295
|
+
}
|
|
296
|
+
clear() {
|
|
297
|
+
this.messages = [];
|
|
298
|
+
}
|
|
299
|
+
loadFile(filename) {
|
|
300
|
+
return this.parent.loadFile(filename);
|
|
301
|
+
}
|
|
302
|
+
fileSize(filename) {
|
|
303
|
+
return this.parent.fileSize(filename);
|
|
304
|
+
}
|
|
305
|
+
get path() {
|
|
306
|
+
return this.parent.path;
|
|
307
|
+
}
|
|
308
|
+
get fs() {
|
|
309
|
+
return this.parent.fs;
|
|
310
|
+
}
|
|
311
|
+
resolveFilename(baseFilename, filename) {
|
|
312
|
+
return this.parent.resolveFilename(baseFilename, filename);
|
|
313
|
+
}
|
|
314
|
+
reportMessage(event) {
|
|
315
|
+
const disable = CompilerFileCallbacks.applyMessageOverridesToEvent(event, this.options.messageOverrides);
|
|
316
|
+
this.messages.push(event);
|
|
317
|
+
if (!disable) {
|
|
318
|
+
this.parent.reportMessage({ filename: this.filename, ...event });
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
debug(msg) {
|
|
322
|
+
return this.parent.debug(msg);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
;
|
|
326
|
+
export const defaultCompilerOptions = {
|
|
327
|
+
logLevel: 'info',
|
|
328
|
+
logFormat: 'formatted',
|
|
329
|
+
// outFile: (undefined)
|
|
330
|
+
saveDebug: false,
|
|
331
|
+
shouldAddCompilerVersion: true,
|
|
332
|
+
compilerWarningsAsErrors: false,
|
|
333
|
+
warnDeprecatedCode: true,
|
|
334
|
+
checkFilenameConventions: false,
|
|
335
|
+
};
|
|
336
|
+
/**
|
|
337
|
+
* Convenience function for constructing CompilerEvents
|
|
338
|
+
* @param code Unique numeric value of the event
|
|
339
|
+
* @param message A short description of the error presented to the user
|
|
340
|
+
* @param detail Detailed Markdown-formatted description of the error
|
|
341
|
+
* including references to documentation, remediation options.
|
|
342
|
+
* @returns
|
|
343
|
+
*/
|
|
344
|
+
export const CompilerMessageSpec = (code, message, detail) => ({
|
|
345
|
+
code,
|
|
346
|
+
message,
|
|
347
|
+
detail,
|
|
348
|
+
});
|
|
349
|
+
export const CompilerMessageDef = (param) => String(param ?? `<param>`);
|
|
350
|
+
export const CompilerMessageSpecWithException = (code, message, exceptionVar, detail) => ({
|
|
351
|
+
code,
|
|
352
|
+
message: exceptionVar
|
|
353
|
+
? (message ?? `Unexpected exception`) + `: ${exceptionVar.toString()}\n\nCall stack:\n${(exceptionVar instanceof Error ? exceptionVar.stack : (new Error()).stack)}` :
|
|
354
|
+
message,
|
|
355
|
+
detail,
|
|
356
|
+
exceptionVar,
|
|
357
|
+
});
|
|
358
|
+
/**
|
|
359
|
+
* Compiler logging level and correspondence to severity
|
|
360
|
+
*/
|
|
361
|
+
export const ALL_COMPILER_LOG_LEVELS = [
|
|
362
|
+
'silent', /// Nothing is emitted to stdout, not even errors (fatal exceptions may still emit to stdout)
|
|
363
|
+
'error', /// Only errors emitted
|
|
364
|
+
'warn', /// Errors + warnings
|
|
365
|
+
'hint', /// Errors + warnings + hints
|
|
366
|
+
'info', /// All messages: errors + warnings + hints + info
|
|
367
|
+
'debug' /// All messages: errors + warnings + hints + info, plus debug logs
|
|
368
|
+
];
|
|
369
|
+
export const compilerLogLevelToSeverity = {
|
|
370
|
+
'silent': CompilerErrorMask.Severity, // effectively excludes all reporting
|
|
371
|
+
'error': CompilerErrorSeverity.Error,
|
|
372
|
+
'warn': CompilerErrorSeverity.Warn,
|
|
373
|
+
'hint': CompilerErrorSeverity.Hint,
|
|
374
|
+
'info': CompilerErrorSeverity.Info,
|
|
375
|
+
'debug': CompilerErrorSeverity.Info
|
|
376
|
+
};
|
|
377
|
+
export const ALL_COMPILER_LOG_FORMATS = [
|
|
378
|
+
'tsv',
|
|
379
|
+
'formatted'
|
|
380
|
+
];
|
|
381
381
|
//# sourceMappingURL=compiler-interfaces.js.map
|
|
382
|
-
//# debugId=
|
|
382
|
+
//# debugId=700d18cd-bca6-5162-a68e-85e89dc556ea
|