xmlui 0.7.30 → 0.7.32

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.
@@ -0,0 +1,407 @@
1
+ import { K as A } from "./lint-DgP_MIP6.mjs";
2
+ import { ag as $, M as v, a2 as j, _ as O, Y as P, a1 as T, X as V, $ as L, O as I, a0 as w, Z as z, U as M, R as Q, W as k, Q as B, D as R, E as F, a4 as K, C as W, a7 as H, S as q, ae as G, A as Y, z as Z, a9 as J, n as ee, N as te, a8 as re, aj as ae, B as se, ad as ie, aa as ne, ac as le, ab as ce, a5 as de, F as me, H as he, a3 as ue, p as fe, af as oe, a6 as pe, G as Ee, ai as Ne, ah as ye } from "./lint-DgP_MIP6.mjs";
3
+ const p = /[\r\n<>'"&]/;
4
+ class D {
5
+ /**
6
+ * Serialize the specified XML fragment into a string
7
+ * @param xml XML fragment to serialize
8
+ * @param options Formatting options to use
9
+ */
10
+ serialize(t, e) {
11
+ const r = Array.isArray(t) ? t : [t];
12
+ return s(r, 0);
13
+ function s(i, d) {
14
+ return i.map((l) => a(l, d)).join(e != null && e.prettify ? `
15
+ ` + n(d) : "");
16
+ }
17
+ function a(i, d) {
18
+ switch (i.type) {
19
+ case "XmlUiComment":
20
+ return c(i, d);
21
+ case "XmlUiElement":
22
+ return h(i, d);
23
+ default:
24
+ return "";
25
+ }
26
+ }
27
+ function n(i) {
28
+ return e != null && e.prettify ? "".padEnd(((e == null ? void 0 : e.indents) ?? 2) * i, " ") : "";
29
+ }
30
+ function c(i, d) {
31
+ return `${n(d)}<!--${i.text}-->`;
32
+ }
33
+ function h(i, d) {
34
+ var y, g;
35
+ let l = `${n(d)}<${N()}`;
36
+ const E = (((y = i.attributes) == null ? void 0 : y.length) ?? 0) > 0, o = (((g = i.childNodes) == null ? void 0 : g.length) ?? 0) > 0;
37
+ if (i.text || E || o) {
38
+ if (E) {
39
+ const m = i.attributes.map((u) => b(u));
40
+ e != null && e.prettify && l.length + 1 + // --- Space after
41
+ m.join(" ").length + // --- Attributes total length
42
+ (o ? 1 : (e == null ? void 0 : e.useSpaceBeforeClose) ?? !1 ? 3 : 2) > ((e == null ? void 0 : e.lineLength) ?? 80) ? (m.forEach((_) => {
43
+ l += `
44
+ ` + n(d + 1) + _;
45
+ }), ((e == null ? void 0 : e.breakClosingTag) ?? !1) && (l += `
46
+ ` + n(d))) : l += " " + m.join(" ");
47
+ }
48
+ if (i.text || o) {
49
+ if (l += ">", i.text) {
50
+ const m = i.preserveSpaces ? f(i.text) : C(i.text);
51
+ e != null && e.prettify && l.length + m.length + i.name.length + 3 > ((e == null ? void 0 : e.lineLength) ?? 80) ? l += `
52
+ ` + n(d + 1) + m + `
53
+ ` : l += m;
54
+ }
55
+ if (o) {
56
+ const m = i.childNodes.map((u) => a(u, d + 1));
57
+ e != null && e.prettify ? (m.forEach((u) => {
58
+ l += `
59
+ ` + u;
60
+ }), l += `
61
+ `) : l += m.join("");
62
+ }
63
+ l += `${n(d)}</${i.name}>`;
64
+ } else
65
+ l += ((e == null ? void 0 : e.useSpaceBeforeClose) ?? !1 ? " " : "") + "/>";
66
+ } else
67
+ l += ((e == null ? void 0 : e.useSpaceBeforeClose) ?? !1 ? " " : "") + "/>", i.text === "" && (l += `""</${N()}>`);
68
+ return l;
69
+ function N() {
70
+ return i.namespace ? `${i.namespace}:${i.name}` : i.name;
71
+ }
72
+ }
73
+ function b(i) {
74
+ if (i.value === void 0 || i.value === null)
75
+ return `${l()}`;
76
+ if (i.preserveSpaces)
77
+ return `${l()}=${f(i.value)}`;
78
+ const d = i.value ?? "";
79
+ return `${l()}=${f(d)}`;
80
+ function l() {
81
+ return i.namespace ? `${i.namespace}:${i.name}` : i.name;
82
+ }
83
+ }
84
+ function C(i) {
85
+ return e != null && e.useQuotes || p.test(i) ? f(i) : i;
86
+ }
87
+ function f(i) {
88
+ const d = i.indexOf("'") >= 0, l = i.indexOf('"') >= 0;
89
+ return !d && !l || d && !l ? `"${i.replaceAll("`", "\\`")}"` : l && !d ? `'${i.replaceAll("`", "\\`")}'` : `\`${i.replaceAll("`", "\\`")}\``;
90
+ }
91
+ }
92
+ /**
93
+ * Transform the specified component definition into an UEML node
94
+ * @param def Component definitions
95
+ * @param options Transformation options
96
+ */
97
+ transformComponentDefinition(t, e) {
98
+ return t.type ? this.transformSimpleComponentDefinition(t, e) : this.transformCompoundComponentDefinition(t, e);
99
+ }
100
+ /**
101
+ * Transform the specified object into an UEML nodes
102
+ * @param def Object definition
103
+ * @param options Transformation options
104
+ */
105
+ transformObject(t, e) {
106
+ const r = this.transformValue("Object", "", t, e);
107
+ return r ? r.childNodes ?? [] : null;
108
+ }
109
+ /**
110
+ * Transforms the specified simple component definition into an UEML node
111
+ * @param def Component definition
112
+ * @param options Transformation options
113
+ */
114
+ transformSimpleComponentDefinition(t, e) {
115
+ const r = {
116
+ type: "XmlUiElement",
117
+ name: t.type
118
+ };
119
+ return t.uid !== void 0 && this.addProperty(r, "id", t.uid, e), t.testId !== void 0 && this.addProperty(r, "testId", t.testId, e), t.when !== void 0 && this.addProperty(r, "when", t.when, e), t.vars && Object.keys(t.vars).forEach((s) => {
120
+ const a = this.transformValue("var", s, t.vars[s], e);
121
+ a !== null && (r.childNodes ?? (r.childNodes = []), r.childNodes.push(a));
122
+ }), t.props && Object.keys(t.props).forEach((s) => {
123
+ const a = t.props[s];
124
+ if (s.endsWith("Template") && a.type) {
125
+ r.childNodes ?? (r.childNodes = []);
126
+ const n = {
127
+ type: "XmlUiElement",
128
+ name: "property",
129
+ attributes: [
130
+ {
131
+ type: "XmlUiAttribute",
132
+ name: "name",
133
+ value: s
134
+ }
135
+ ]
136
+ };
137
+ this.addComponentElement(n, a), r.childNodes.push(n);
138
+ } else {
139
+ if (a === void 0)
140
+ return;
141
+ if (a === null) {
142
+ const n = {
143
+ type: "XmlUiElement",
144
+ name: "property",
145
+ attributes: [
146
+ {
147
+ type: "XmlUiAttribute",
148
+ name: "name",
149
+ value: s
150
+ }
151
+ ]
152
+ };
153
+ r.childNodes ?? (r.childNodes = []), r.childNodes.push(n);
154
+ return;
155
+ }
156
+ if (s === "id" || s === "when" || s === "testId" || e != null && e.extractProps) {
157
+ const n = {
158
+ type: "XmlUiElement",
159
+ name: "property"
160
+ };
161
+ this.addProperty(n, s, a, e), r.childNodes ?? (r.childNodes = []), r.childNodes.push(n);
162
+ return;
163
+ }
164
+ this.addProperty(r, s, a, e);
165
+ }
166
+ }), t.events && Object.keys(t.events).forEach((s) => {
167
+ const a = this.transformValue("event", s, t.events[s], e);
168
+ a !== null && (r.childNodes ?? (r.childNodes = []), r.childNodes.push(a));
169
+ }), t.loaders && this.addComponentList(r, "loaders", t.loaders), t.api && Object.keys(t.api).forEach((s) => {
170
+ const a = this.transformValue("api", s, t.api[s], e);
171
+ a !== null && (r.childNodes ?? (r.childNodes = []), r.childNodes.push(a));
172
+ }), t.uses && this.addList(r, "uses", "", t.uses, e), t.children && (typeof t.children == "string" ? this.addProperty(r, "children", t.children, e) : t.children.forEach((s) => {
173
+ this.addComponentElement(r, s);
174
+ })), r;
175
+ }
176
+ /**
177
+ * Transforms the specified simple component definition into an Xml node
178
+ * @param def Compound component definition
179
+ * @param options Transformation options
180
+ */
181
+ transformCompoundComponentDefinition(t, e) {
182
+ if (typeof t == "string")
183
+ return {
184
+ type: "XmlUiElement",
185
+ name: t
186
+ };
187
+ const r = this.transformSimpleComponentDefinition(
188
+ t.component,
189
+ e
190
+ ), s = {
191
+ type: "XmlUiElement",
192
+ name: A,
193
+ attributes: [
194
+ {
195
+ type: "XmlUiAttribute",
196
+ name: "name",
197
+ value: t.name
198
+ }
199
+ ],
200
+ childNodes: Array.isArray(r) ? [...r] : [r]
201
+ };
202
+ return t.api && Object.keys(t.api).forEach((a) => {
203
+ const n = this.transformValue("api", a, t.api[a], e);
204
+ n !== null && (s.childNodes ?? (s.childNodes = []), s.childNodes.push(n));
205
+ }), s;
206
+ }
207
+ /**
208
+ * Transforms a value into an UEML element
209
+ * @param nodeName Name of the value node
210
+ * @param name Optional (property) name
211
+ * @param value Value to transform
212
+ * @param options Transformation options
213
+ */
214
+ transformValue(t, e, r, s) {
215
+ if (r === void 0) return null;
216
+ const a = {
217
+ type: "XmlUiElement",
218
+ name: t
219
+ };
220
+ if (e && (a.attributes = [
221
+ {
222
+ type: "XmlUiAttribute",
223
+ name: "name",
224
+ value: e
225
+ }
226
+ ]), r === null)
227
+ return a;
228
+ if (typeof r == "string" || typeof r == "number" || typeof r == "boolean") {
229
+ const n = typeof r == "string" ? r.toString() : `{${r.toString()}}`, c = p.test(n) || n.trim().length != n.length;
230
+ return s != null && s.preferTextToValue ? (a.text = n, a.preserveSpaces = c) : (a.attributes ?? (a.attributes = []), a.attributes.push({
231
+ type: "XmlUiAttribute",
232
+ name: "value",
233
+ value: n,
234
+ preserveSpaces: c
235
+ })), a;
236
+ }
237
+ if (Array.isArray(r))
238
+ r.length === 0 ? (a.attributes ?? (a.attributes = []), a.attributes.push({
239
+ type: "XmlUiAttribute",
240
+ name: "value",
241
+ value: "{[]}"
242
+ })) : r.forEach((n) => {
243
+ const c = this.transformValue("item", void 0, n, s);
244
+ c && (a.childNodes ?? (a.childNodes = []), a.childNodes.push(c));
245
+ });
246
+ else if (typeof r == "object") {
247
+ const n = Object.keys(r);
248
+ n.length === 0 ? (a.attributes ?? (a.attributes = []), a.attributes.push({
249
+ type: "XmlUiAttribute",
250
+ name: "value",
251
+ value: "{{}}"
252
+ })) : n.forEach((c) => {
253
+ const h = this.transformValue("field", c, r[c], s);
254
+ h && (a.childNodes ?? (a.childNodes = []), a.childNodes.push(h));
255
+ });
256
+ } else
257
+ throw new Error(`Cannot serialize '${typeof r}' value`);
258
+ return a;
259
+ }
260
+ /**
261
+ * Transforms the specified simple component definition into an Xml node
262
+ * @param name Element name
263
+ * @param value Value to transform
264
+ * @param options Transformation options
265
+ */
266
+ transformObjectValue(t, e, r) {
267
+ const s = {
268
+ type: "XmlUiElement",
269
+ name: t
270
+ };
271
+ return e && Object.keys(e).forEach(
272
+ (a) => this.addProperty(s, a, e[a], r)
273
+ ), s;
274
+ }
275
+ /**
276
+ * Add a property to the specified UEML element
277
+ * @param element XML element
278
+ * @param name Element name
279
+ * @param value Element value
280
+ * @param options Transformation options
281
+ */
282
+ addProperty(t, e, r, s) {
283
+ switch (typeof r) {
284
+ case "undefined":
285
+ break;
286
+ case "string":
287
+ t.attributes ?? (t.attributes = []), t.attributes.push({
288
+ type: "XmlUiAttribute",
289
+ name: e,
290
+ value: r == null ? void 0 : r.toString(),
291
+ preserveQuotes: (s == null ? void 0 : s.removeQuotes) ?? !1,
292
+ preserveSpaces: p.test(r.toString())
293
+ });
294
+ break;
295
+ case "boolean":
296
+ case "number":
297
+ case "object":
298
+ const a = this.transformValue("property", e, r, s);
299
+ a && (t.childNodes ?? (t.childNodes = []), t.childNodes.push(a));
300
+ break;
301
+ default:
302
+ throw new Error(`'${typeof r}' transformation is not implemented yet`);
303
+ }
304
+ }
305
+ addComponentElement(t, e) {
306
+ t.childNodes ?? (t.childNodes = []);
307
+ const r = this.transformComponentDefinition(e);
308
+ Array.isArray(r) ? t.childNodes.push(...r) : t.childNodes.push(r);
309
+ }
310
+ /**
311
+ * Adds a list to the specified XML element
312
+ * @param element XML element
313
+ * @param name Name of the list (child in `element`)
314
+ * @param prefix Prefix to use for the list
315
+ * @param list List with items
316
+ * @param options Transformation options
317
+ */
318
+ addList(t, e, r, s, a) {
319
+ const n = `${r ? r + "." : ""}${e}`;
320
+ t.childNodes ?? (t.childNodes = []), s.forEach((c) => {
321
+ if (typeof c == "string")
322
+ t.childNodes.push({
323
+ type: "XmlUiElement",
324
+ name: n,
325
+ text: c,
326
+ preserveSpaces: p.test(c) || c !== c.trim() || c === ""
327
+ });
328
+ else if (c === null)
329
+ t.childNodes.push({
330
+ type: "XmlUiElement",
331
+ name: n
332
+ });
333
+ else {
334
+ const h = this.transformObjectValue(n, c, a);
335
+ Array.isArray(h) ? t.childNodes.push(...h) : t.childNodes.push(h);
336
+ }
337
+ });
338
+ }
339
+ /**
340
+ * Adds a component list to the specified element
341
+ * @param element XML element
342
+ * @param name Name to use for the wrapper element
343
+ * @param list List with component items
344
+ * @private
345
+ */
346
+ addComponentList(t, e, r) {
347
+ const s = [];
348
+ r.forEach((n) => {
349
+ const c = this.transformSimpleComponentDefinition(n);
350
+ Array.isArray(c) ? s.push(...c) : s.push(c);
351
+ });
352
+ const a = {
353
+ type: "XmlUiElement",
354
+ name: e,
355
+ childNodes: s
356
+ };
357
+ t.childNodes ?? (t.childNodes = []), t.childNodes.push(a);
358
+ }
359
+ }
360
+ export {
361
+ A as COMPOUND_COMP_ID,
362
+ $ as CORE_NAMESPACE_VALUE,
363
+ v as CharacterCodes,
364
+ j as Diag_Attr_Identifier_Expected,
365
+ O as Diag_Attr_Value_Expected,
366
+ P as Diag_CloseNodeStart_Token_Expected,
367
+ T as Diag_End_Or_Close_Token_Expected,
368
+ V as Diag_End_Token_Expected,
369
+ L as Diag_Eq_Token_Expected,
370
+ I as Diag_Invalid_Character,
371
+ w as Diag_OpenNodeStart_Token_Expected,
372
+ z as Diag_Tag_Identifier_Expected,
373
+ M as Diag_Unterminated_CData,
374
+ Q as Diag_Unterminated_Comment,
375
+ k as Diag_Unterminated_Script,
376
+ B as Diag_Unterminated_String_Literal,
377
+ R as DiagnosticCategory,
378
+ F as ErrCodes,
379
+ K as LintDiagKind,
380
+ W as LintSeverity,
381
+ H as ParserError,
382
+ q as SyntaxKind,
383
+ G as UCRegex,
384
+ D as XmlUiHelper,
385
+ Y as codeBehindFileExtension,
386
+ Z as componentFileExtension,
387
+ J as createScanner,
388
+ ee as createXmlUiParser,
389
+ te as diagnosticCategoryName,
390
+ re as errorMessages,
391
+ ae as findTokenAtPos,
392
+ se as getLintSeverity,
393
+ ie as getSyntaxKindStrRepr,
394
+ ne as isIdentifierStart,
395
+ le as isInnerNode,
396
+ ce as isTrivia,
397
+ de as lint,
398
+ me as lintApp,
399
+ he as lintErrorsComponent,
400
+ ue as moduleFileExtension,
401
+ fe as nodeToComponentDef,
402
+ oe as onPrefixRegex,
403
+ pe as parseXmlUiMarkup,
404
+ Ee as printComponentLints,
405
+ Ne as tagNameNodesWithoutErrorsMatch,
406
+ ye as toDbgString
407
+ };