@lithent/lithent-template-parser 0.1.0 → 0.1.1
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/README.md +1 -1
- package/dist/codegen/createElement.d.cts +10 -0
- package/dist/codegen/createElement.d.ts +1 -1
- package/dist/codegen/index.d.cts +1 -0
- package/dist/codegen/index.d.ts +1 -1
- package/dist/compiler.d.cts +26 -0
- package/dist/compiler.d.ts +8 -8
- package/dist/docPipe/index.d.cts +40 -0
- package/dist/docPipe/index.d.ts +2 -2
- package/dist/docPipe/scan.d.cts +8 -0
- package/dist/docPipe/scan.d.ts +2 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.mjs +955 -1192
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.cjs +12 -12
- package/dist/index.umd.cjs.map +1 -1
- package/dist/parser/ast.d.cts +207 -0
- package/dist/parser/ast.d.ts +1 -1
- package/dist/parser/lexer.d.cts +109 -0
- package/dist/parser/lexer.d.ts +1 -1
- package/dist/parser/parser.d.cts +80 -0
- package/dist/parser/parser.d.ts +5 -4
- package/dist/parser/tokens.d.cts +51 -0
- package/dist/transform/directives.d.cts +30 -0
- package/dist/transform/directives.d.ts +1 -1
- package/dist/transform/index.d.cts +14 -0
- package/dist/transform/index.d.ts +5 -5
- package/dist/transform/optimize.d.cts +21 -0
- package/dist/transform/optimize.d.ts +1 -1
- package/package.json +2 -2
- package/src/codegen/createElement.ts +48 -332
- package/src/compiler.ts +1 -1
- package/src/docPipe/scan.ts +209 -246
- package/src/parser/lexer.ts +41 -91
- package/src/parser/parser.ts +45 -39
- package/src/tests/compiler.test.ts +2 -2
- package/src/tests/parser.test.ts +2 -2
- package/src/tests/regressions.test.ts +200 -0
- package/src/transform/directives.ts +25 -2
- package/src/transform/optimize.ts +37 -25
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,200 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var it = Object.defineProperty;
|
|
2
|
+
var nt = (n, t, e) => t in n ? it(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var p = (n, t, e) => nt(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
const rt = (n) => /[A-Za-z_$]/.test(n), st = (n) => /[\w$]/.test(n), ot = /* @__PURE__ */ new Set([
|
|
5
|
+
"return",
|
|
6
|
+
"throw",
|
|
7
|
+
"yield",
|
|
8
|
+
"await",
|
|
9
|
+
"case",
|
|
10
|
+
"delete",
|
|
11
|
+
"void",
|
|
12
|
+
"typeof",
|
|
13
|
+
"new",
|
|
14
|
+
"in",
|
|
15
|
+
"instanceof",
|
|
16
|
+
"else",
|
|
17
|
+
"do"
|
|
18
|
+
]), U = (n, t, e) => {
|
|
19
|
+
let i = t + 1;
|
|
20
|
+
for (; i < n.length; )
|
|
21
|
+
if (n[i] === "\\") i += 2;
|
|
22
|
+
else if (n[i++] === e) return i;
|
|
23
|
+
return n.length;
|
|
24
|
+
}, ht = (n, t) => {
|
|
25
|
+
let e = t;
|
|
26
|
+
for (; e < n.length && !/[\r\n]/.test(n[e]); ) e++;
|
|
27
|
+
return e;
|
|
28
|
+
}, lt = (n, t) => {
|
|
29
|
+
const e = n.indexOf("*/", t + 2);
|
|
30
|
+
return e === -1 ? n.length : e + 2;
|
|
31
|
+
}, at = (n, t) => {
|
|
32
|
+
let e = t + 1, i = !1;
|
|
33
|
+
for (; e < n.length; ) {
|
|
34
|
+
const r = n[e++];
|
|
35
|
+
if (r === "\\") e++;
|
|
36
|
+
else if (r === "[") i = !0;
|
|
37
|
+
else if (r === "]") i = !1;
|
|
38
|
+
else if (r === "/" && !i) {
|
|
39
|
+
for (; e < n.length && /[a-z]/i.test(n[e]); ) e++;
|
|
40
|
+
return e;
|
|
41
|
+
} else if (r === `
|
|
42
|
+
` || r === "\r") return e;
|
|
43
|
+
}
|
|
44
|
+
return e;
|
|
45
|
+
}, ct = (n, t) => {
|
|
46
|
+
let e = t + 1;
|
|
47
|
+
for (; e < n.length; )
|
|
48
|
+
if (n[e] === "\\") e += 2;
|
|
49
|
+
else {
|
|
50
|
+
if (n[e] === "`") return e + 1;
|
|
51
|
+
if (n[e] === "$" && n[e + 1] === "{") {
|
|
52
|
+
const i = R(n, e + 2);
|
|
53
|
+
if (i === null) return n.length;
|
|
54
|
+
e = i;
|
|
55
|
+
} else e++;
|
|
56
|
+
}
|
|
57
|
+
return e;
|
|
58
|
+
}, V = (n) => ({
|
|
59
|
+
controlParentheses: [],
|
|
60
|
+
controlKeyword: !1,
|
|
61
|
+
blocks: [],
|
|
62
|
+
previous: "",
|
|
63
|
+
statementStart: n
|
|
64
|
+
}), j = (n, t, e, i) => {
|
|
65
|
+
const r = n[t];
|
|
66
|
+
if (/\s/.test(r)) return { end: t + 1, expressionAllowed: e };
|
|
67
|
+
if (r === "/" && n[t + 1] === "/")
|
|
68
|
+
return { end: ht(n, t + 2), expressionAllowed: e };
|
|
69
|
+
if (r === "/" && n[t + 1] === "*")
|
|
70
|
+
return { end: lt(n, t), expressionAllowed: e };
|
|
71
|
+
if (r === '"' || r === "'")
|
|
72
|
+
return i.previous = "literal", i.statementStart = !1, { end: U(n, t, r), expressionAllowed: !1 };
|
|
73
|
+
if (r === "`")
|
|
74
|
+
return {
|
|
75
|
+
end: ct(n, t),
|
|
76
|
+
expressionAllowed: !1
|
|
77
|
+
};
|
|
78
|
+
if (r === "/" && e)
|
|
79
|
+
return { end: at(n, t), expressionAllowed: !1 };
|
|
80
|
+
if (rt(r)) {
|
|
81
|
+
let s = t + 1;
|
|
82
|
+
for (; s < n.length && st(n[s]); ) s++;
|
|
83
|
+
const o = n.slice(t, s);
|
|
84
|
+
return i.controlKeyword = /^(if|while|for|with|switch|catch)$/.test(o), i.previous = o, i.statementStart = /^(else|do|try|finally)$/.test(o), { end: s, expressionAllowed: ot.has(o) };
|
|
85
|
+
}
|
|
86
|
+
if (/[0-9]/.test(r)) {
|
|
87
|
+
let s = t + 1;
|
|
88
|
+
for (; s < n.length && /[\w.]/.test(n[s]); ) s++;
|
|
89
|
+
return { end: s, expressionAllowed: !1 };
|
|
90
|
+
}
|
|
91
|
+
if (r === "(")
|
|
92
|
+
return i.controlParentheses.push(i.controlKeyword), i.controlKeyword = !1, i.previous = r, i.statementStart = !1, { end: t + 1, expressionAllowed: !0 };
|
|
93
|
+
if (r === ")") {
|
|
94
|
+
const s = i.controlParentheses.pop() ?? !1;
|
|
95
|
+
return i.previous = r, i.statementStart = s, { end: t + 1, expressionAllowed: s };
|
|
96
|
+
}
|
|
97
|
+
if (r === "{") {
|
|
98
|
+
const s = i.statementStart || i.previous === ")" || i.previous === ">";
|
|
99
|
+
return i.blocks.push(s), i.previous = r, i.statementStart = s, { end: t + 1, expressionAllowed: !0 };
|
|
100
|
+
}
|
|
101
|
+
if (r === "}") {
|
|
102
|
+
const s = i.blocks.pop() ?? !1;
|
|
103
|
+
return i.previous = r, i.statementStart = s, { end: t + 1, expressionAllowed: s };
|
|
104
|
+
}
|
|
105
|
+
return i.previous = r, i.statementStart = r === ";", (r === "+" || r === "-") && n[t + 1] === r ? { end: t + 2, expressionAllowed: e } : { end: t + 1, expressionAllowed: !/[)\]}.]/.test(r) };
|
|
106
|
+
}, R = (n, t) => {
|
|
107
|
+
let e = 1, i = t, r = !0;
|
|
108
|
+
const s = V(!1);
|
|
109
|
+
for (; i < n.length; ) {
|
|
110
|
+
const o = n[i];
|
|
111
|
+
if (o === "<" && r) {
|
|
112
|
+
const l = z(n, i);
|
|
113
|
+
if (l) {
|
|
114
|
+
i = l.end, r = !1, s.previous = "template", s.statementStart = !1;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (o === "{") e++;
|
|
119
|
+
else if (o === "}" && --e === 0) return i + 1;
|
|
120
|
+
const h = j(n, i, r, s);
|
|
121
|
+
i = h.end, r = h.expressionAllowed;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}, ut = (n, t) => {
|
|
125
|
+
let e = t;
|
|
126
|
+
for (; e < n.length; ) {
|
|
127
|
+
const i = n[e];
|
|
128
|
+
if (i === '"' || i === "'") e = U(n, e, i);
|
|
129
|
+
else if (i === "{") {
|
|
130
|
+
const r = R(n, e + 1);
|
|
131
|
+
if (r === null) return null;
|
|
132
|
+
e = r;
|
|
133
|
+
} else {
|
|
134
|
+
if (i === ">") return e + 1;
|
|
135
|
+
e++;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}, z = (n, t) => {
|
|
140
|
+
if (n[t] !== "<" || !/[A-Za-z_$>!]/.test(n[t + 1] ?? ""))
|
|
141
|
+
return null;
|
|
142
|
+
let e = t, i = 0;
|
|
143
|
+
for (; e < n.length; ) {
|
|
144
|
+
if (n.startsWith("<!--", e)) {
|
|
145
|
+
const r = n.indexOf("-->", e + 4);
|
|
146
|
+
if (r === -1) return null;
|
|
147
|
+
e = r + 3;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (n[e] === "{") {
|
|
151
|
+
const r = R(n, e + 1);
|
|
152
|
+
if (r !== null) {
|
|
153
|
+
e = r;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (n[e] === "<") {
|
|
158
|
+
const r = n[e + 1] === "/", s = ut(n, e + (r ? 2 : 1));
|
|
159
|
+
if (s === null) return null;
|
|
160
|
+
if (i += r ? -1 : 1, !r && n[s - 2] === "/" && i--, e = s, i === 0)
|
|
161
|
+
return { start: t, end: e, snippet: n.slice(t, e) };
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
e++;
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}, B = (n) => {
|
|
168
|
+
const t = [];
|
|
169
|
+
let e = 0, i = !0;
|
|
170
|
+
const r = V(!0);
|
|
171
|
+
for (; e < n.length; ) {
|
|
172
|
+
if (n[e] === "<" && i) {
|
|
173
|
+
const o = z(n, e);
|
|
174
|
+
if (o) {
|
|
175
|
+
t.push(o), e = o.end, i = !1, r.previous = "template", r.statementStart = !1;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const s = j(n, e, i, r);
|
|
180
|
+
e = s.end, i = s.expressionAllowed;
|
|
181
|
+
}
|
|
182
|
+
return t;
|
|
183
|
+
};
|
|
184
|
+
var a = /* @__PURE__ */ ((n) => (n.TAG_OPEN_START = "TAG_OPEN_START", n.TAG_OPEN_END = "TAG_OPEN_END", n.TAG_CLOSE_START = "TAG_CLOSE_START", n.TAG_SELF_CLOSE = "TAG_SELF_CLOSE", n.IDENTIFIER = "IDENTIFIER", n.ATTRIBUTE_EQUALS = "ATTRIBUTE_EQUALS", n.STRING_LITERAL = "STRING_LITERAL", n.EXPRESSION_START = "EXPRESSION_START", n.EXPRESSION_END = "EXPRESSION_END", n.EXPRESSION_CONTENT = "EXPRESSION_CONTENT", n.DIRECTIVE_IF = "DIRECTIVE_IF", n.DIRECTIVE_ELSE_IF = "DIRECTIVE_ELSE_IF", n.DIRECTIVE_ELSE = "DIRECTIVE_ELSE", n.DIRECTIVE_FOR = "DIRECTIVE_FOR", n.FRAGMENT_OPEN = "FRAGMENT_OPEN", n.FRAGMENT_CLOSE = "FRAGMENT_CLOSE", n.KEYWORD_REF = "KEYWORD_REF", n.TEXT = "TEXT", n.COMMENT = "COMMENT", n.WHITESPACE = "WHITESPACE", n.EOF = "EOF", n))(a || {});
|
|
185
|
+
function ft(n, t, e) {
|
|
186
|
+
return { line: n, column: t, offset: e };
|
|
7
187
|
}
|
|
8
|
-
function
|
|
9
|
-
return { type:
|
|
188
|
+
function d(n, t, e, i) {
|
|
189
|
+
return { type: n, value: t, start: e, end: i };
|
|
10
190
|
}
|
|
11
|
-
class
|
|
191
|
+
class dt {
|
|
12
192
|
constructor(t) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
193
|
+
p(this, "input");
|
|
194
|
+
p(this, "position", 0);
|
|
195
|
+
p(this, "line", 1);
|
|
196
|
+
p(this, "column", 1);
|
|
197
|
+
p(this, "tokens", []);
|
|
18
198
|
this.input = t;
|
|
19
199
|
}
|
|
20
200
|
/**
|
|
@@ -24,13 +204,13 @@ class at {
|
|
|
24
204
|
for (; this.position < this.input.length; )
|
|
25
205
|
this.readToken();
|
|
26
206
|
const t = this.getCurrentPosition();
|
|
27
|
-
return this.tokens.push(
|
|
207
|
+
return this.tokens.push(d(a.EOF, "", t, t)), this.tokens;
|
|
28
208
|
}
|
|
29
209
|
/**
|
|
30
210
|
* Get current position
|
|
31
211
|
*/
|
|
32
212
|
getCurrentPosition() {
|
|
33
|
-
return
|
|
213
|
+
return ft(this.line, this.column, this.position);
|
|
34
214
|
}
|
|
35
215
|
/**
|
|
36
216
|
* Peek at character without consuming
|
|
@@ -89,15 +269,22 @@ class at {
|
|
|
89
269
|
readComment() {
|
|
90
270
|
const t = this.getCurrentPosition();
|
|
91
271
|
let e = "";
|
|
92
|
-
|
|
272
|
+
e += this.advance() + this.advance() + this.advance() + this.advance();
|
|
273
|
+
let i = !1;
|
|
274
|
+
for (; !this.isEOF(); ) {
|
|
93
275
|
if (this.peek() === "-" && this.peek(1) === "-" && this.peek(2) === ">") {
|
|
94
|
-
e += this.advance() + this.advance() + this.advance();
|
|
276
|
+
e += this.advance() + this.advance() + this.advance(), i = !0;
|
|
95
277
|
break;
|
|
96
278
|
}
|
|
97
279
|
e += this.advance();
|
|
98
280
|
}
|
|
99
|
-
const
|
|
100
|
-
|
|
281
|
+
const r = this.getCurrentPosition();
|
|
282
|
+
if (!i)
|
|
283
|
+
throw Object.assign(new Error("Unclosed comment"), {
|
|
284
|
+
line: t.line,
|
|
285
|
+
column: t.column
|
|
286
|
+
});
|
|
287
|
+
this.tokens.push(d(a.COMMENT, e, t, r));
|
|
101
288
|
}
|
|
102
289
|
/**
|
|
103
290
|
* Read opening tag <
|
|
@@ -106,7 +293,7 @@ class at {
|
|
|
106
293
|
const t = this.getCurrentPosition();
|
|
107
294
|
this.advance();
|
|
108
295
|
const e = this.getCurrentPosition();
|
|
109
|
-
this.tokens.push(
|
|
296
|
+
this.tokens.push(d(a.TAG_OPEN_START, "<", t, e)), this.readTagContent();
|
|
110
297
|
}
|
|
111
298
|
/**
|
|
112
299
|
* Read closing tag </
|
|
@@ -115,11 +302,11 @@ class at {
|
|
|
115
302
|
const t = this.getCurrentPosition();
|
|
116
303
|
this.advance(), this.advance();
|
|
117
304
|
const e = this.getCurrentPosition();
|
|
118
|
-
if (this.tokens.push(
|
|
119
|
-
const
|
|
305
|
+
if (this.tokens.push(d(a.TAG_CLOSE_START, "</", t, e)), this.skipWhitespace(), this.readIdentifier(), this.skipWhitespace(), this.peek() === ">") {
|
|
306
|
+
const i = this.getCurrentPosition();
|
|
120
307
|
this.advance();
|
|
121
308
|
const r = this.getCurrentPosition();
|
|
122
|
-
this.tokens.push(
|
|
309
|
+
this.tokens.push(d(a.TAG_OPEN_END, ">", i, r));
|
|
123
310
|
}
|
|
124
311
|
}
|
|
125
312
|
/**
|
|
@@ -132,17 +319,17 @@ class at {
|
|
|
132
319
|
if (t === "/" && this.peek(1) === ">") {
|
|
133
320
|
const e = this.getCurrentPosition();
|
|
134
321
|
this.advance(), this.advance();
|
|
135
|
-
const
|
|
322
|
+
const i = this.getCurrentPosition();
|
|
136
323
|
this.tokens.push(
|
|
137
|
-
|
|
324
|
+
d(a.TAG_SELF_CLOSE, "/>", e, i)
|
|
138
325
|
);
|
|
139
326
|
return;
|
|
140
327
|
}
|
|
141
328
|
if (t === ">") {
|
|
142
329
|
const e = this.getCurrentPosition();
|
|
143
330
|
this.advance();
|
|
144
|
-
const
|
|
145
|
-
this.tokens.push(
|
|
331
|
+
const i = this.getCurrentPosition();
|
|
332
|
+
this.tokens.push(d(a.TAG_OPEN_END, ">", e, i));
|
|
146
333
|
return;
|
|
147
334
|
}
|
|
148
335
|
this.readAttribute();
|
|
@@ -155,9 +342,9 @@ class at {
|
|
|
155
342
|
if (this.readIdentifier() && (this.skipWhitespace(), this.peek() === "=")) {
|
|
156
343
|
const e = this.getCurrentPosition();
|
|
157
344
|
this.advance();
|
|
158
|
-
const
|
|
345
|
+
const i = this.getCurrentPosition();
|
|
159
346
|
this.tokens.push(
|
|
160
|
-
|
|
347
|
+
d(a.ATTRIBUTE_EQUALS, "=", e, i)
|
|
161
348
|
), this.skipWhitespace();
|
|
162
349
|
const r = this.peek();
|
|
163
350
|
r === '"' || r === "'" ? this.readStringLiteral() : r === "{" && this.readExpression();
|
|
@@ -169,19 +356,19 @@ class at {
|
|
|
169
356
|
readIdentifier() {
|
|
170
357
|
const t = this.getCurrentPosition();
|
|
171
358
|
let e = "";
|
|
172
|
-
const
|
|
173
|
-
if (this.isIdentifierStart(
|
|
359
|
+
const i = this.peek();
|
|
360
|
+
if (this.isIdentifierStart(i))
|
|
174
361
|
e += this.advance();
|
|
175
362
|
else {
|
|
176
|
-
const o = this.getCurrentPosition(),
|
|
363
|
+
const o = this.getCurrentPosition(), h = this.advance(), l = this.getCurrentPosition();
|
|
177
364
|
return this.tokens.push(
|
|
178
|
-
|
|
365
|
+
d(a.TEXT, h, o, l)
|
|
179
366
|
), "";
|
|
180
367
|
}
|
|
181
368
|
for (; !this.isEOF() && this.isIdentifierPart(this.peek()); )
|
|
182
369
|
e += this.advance();
|
|
183
370
|
const r = this.getCurrentPosition(), s = this.getIdentifierTokenType(e);
|
|
184
|
-
return this.tokens.push(
|
|
371
|
+
return this.tokens.push(d(s, e, t, r)), e;
|
|
185
372
|
}
|
|
186
373
|
/**
|
|
187
374
|
* Determine token type for identifier
|
|
@@ -189,17 +376,17 @@ class at {
|
|
|
189
376
|
getIdentifierTokenType(t) {
|
|
190
377
|
switch (t) {
|
|
191
378
|
case "l-if":
|
|
192
|
-
return
|
|
379
|
+
return a.DIRECTIVE_IF;
|
|
193
380
|
case "l-else-if":
|
|
194
|
-
return
|
|
381
|
+
return a.DIRECTIVE_ELSE_IF;
|
|
195
382
|
case "l-else":
|
|
196
|
-
return
|
|
383
|
+
return a.DIRECTIVE_ELSE;
|
|
197
384
|
case "l-for":
|
|
198
|
-
return
|
|
385
|
+
return a.DIRECTIVE_FOR;
|
|
199
386
|
case "ref":
|
|
200
|
-
return
|
|
387
|
+
return a.KEYWORD_REF;
|
|
201
388
|
default:
|
|
202
|
-
return
|
|
389
|
+
return a.IDENTIFIER;
|
|
203
390
|
}
|
|
204
391
|
}
|
|
205
392
|
/**
|
|
@@ -207,25 +394,30 @@ class at {
|
|
|
207
394
|
*/
|
|
208
395
|
readStringLiteral() {
|
|
209
396
|
const t = this.getCurrentPosition(), e = this.advance();
|
|
210
|
-
let
|
|
397
|
+
let i = e, r = !1, s = !1;
|
|
211
398
|
for (; !this.isEOF(); ) {
|
|
212
|
-
const
|
|
399
|
+
const h = this.peek();
|
|
213
400
|
if (r) {
|
|
214
|
-
|
|
401
|
+
i += this.advance(), r = !1;
|
|
215
402
|
continue;
|
|
216
403
|
}
|
|
217
|
-
if (
|
|
218
|
-
r = !0,
|
|
404
|
+
if (h === "\\") {
|
|
405
|
+
r = !0, i += this.advance();
|
|
219
406
|
continue;
|
|
220
407
|
}
|
|
221
|
-
if (
|
|
222
|
-
|
|
408
|
+
if (h === e) {
|
|
409
|
+
i += this.advance(), s = !0;
|
|
223
410
|
break;
|
|
224
411
|
}
|
|
225
|
-
|
|
412
|
+
i += this.advance();
|
|
226
413
|
}
|
|
227
|
-
const
|
|
228
|
-
|
|
414
|
+
const o = this.getCurrentPosition();
|
|
415
|
+
if (!s)
|
|
416
|
+
throw Object.assign(new Error("Unclosed attribute string"), {
|
|
417
|
+
line: t.line,
|
|
418
|
+
column: t.column
|
|
419
|
+
});
|
|
420
|
+
this.tokens.push(d(a.STRING_LITERAL, i, t, o));
|
|
229
421
|
}
|
|
230
422
|
/**
|
|
231
423
|
* Read fragment open <>
|
|
@@ -234,7 +426,7 @@ class at {
|
|
|
234
426
|
const t = this.getCurrentPosition();
|
|
235
427
|
this.advance(), this.advance();
|
|
236
428
|
const e = this.getCurrentPosition();
|
|
237
|
-
this.tokens.push(
|
|
429
|
+
this.tokens.push(d(a.FRAGMENT_OPEN, "<>", t, e));
|
|
238
430
|
}
|
|
239
431
|
/**
|
|
240
432
|
* Read fragment close </>
|
|
@@ -243,7 +435,7 @@ class at {
|
|
|
243
435
|
const t = this.getCurrentPosition();
|
|
244
436
|
this.advance(), this.advance(), this.advance();
|
|
245
437
|
const e = this.getCurrentPosition();
|
|
246
|
-
this.tokens.push(
|
|
438
|
+
this.tokens.push(d(a.FRAGMENT_CLOSE, "</>", t, e));
|
|
247
439
|
}
|
|
248
440
|
/**
|
|
249
441
|
* Read expression content inside {}
|
|
@@ -253,66 +445,32 @@ class at {
|
|
|
253
445
|
this.advance();
|
|
254
446
|
const e = this.getCurrentPosition();
|
|
255
447
|
this.tokens.push(
|
|
256
|
-
|
|
448
|
+
d(a.EXPRESSION_START, "{", t, e)
|
|
449
|
+
);
|
|
450
|
+
const i = this.getCurrentPosition(), r = R(this.input, this.position);
|
|
451
|
+
if (r === null)
|
|
452
|
+
throw Object.assign(new Error("Unclosed expression"), {
|
|
453
|
+
line: t.line,
|
|
454
|
+
column: t.column
|
|
455
|
+
});
|
|
456
|
+
const s = this.input.slice(this.position, r - 1);
|
|
457
|
+
for (; this.position < r - 1; ) this.advance();
|
|
458
|
+
const o = this.getCurrentPosition();
|
|
459
|
+
s.trim() && this.tokens.push(
|
|
460
|
+
d(
|
|
461
|
+
a.EXPRESSION_CONTENT,
|
|
462
|
+
s,
|
|
463
|
+
i,
|
|
464
|
+
o
|
|
465
|
+
)
|
|
466
|
+
), this.advance(), this.tokens.push(
|
|
467
|
+
d(
|
|
468
|
+
a.EXPRESSION_END,
|
|
469
|
+
"}",
|
|
470
|
+
o,
|
|
471
|
+
this.getCurrentPosition()
|
|
472
|
+
)
|
|
257
473
|
);
|
|
258
|
-
let n = "", r = 1, s = null, o = !1, l = null, h = e;
|
|
259
|
-
const a = () => {
|
|
260
|
-
const u = this.getCurrentPosition(), d = this.advance(), y = this.getCurrentPosition();
|
|
261
|
-
return n += d, l || (l = u), h = y, d;
|
|
262
|
-
};
|
|
263
|
-
for (; !this.isEOF() && r > 0; ) {
|
|
264
|
-
const u = this.peek();
|
|
265
|
-
if (s) {
|
|
266
|
-
if (o) {
|
|
267
|
-
a(), o = !1;
|
|
268
|
-
continue;
|
|
269
|
-
}
|
|
270
|
-
if (u === "\\") {
|
|
271
|
-
o = !0, a();
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
if (u === s) {
|
|
275
|
-
a(), s = null;
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
a();
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
if (u === '"' || u === "'" || u === "`") {
|
|
282
|
-
s = u, a();
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
if (u === "{") {
|
|
286
|
-
r++, a();
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
if (u === "}") {
|
|
290
|
-
if (r--, r === 0) {
|
|
291
|
-
if (n.trim()) {
|
|
292
|
-
const st = l ?? e, ot = h;
|
|
293
|
-
this.tokens.push(
|
|
294
|
-
p(c.EXPRESSION_CONTENT, n, st, ot)
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
const d = this.getCurrentPosition();
|
|
298
|
-
this.advance();
|
|
299
|
-
const y = this.getCurrentPosition();
|
|
300
|
-
this.tokens.push(
|
|
301
|
-
p(c.EXPRESSION_END, "}", d, y)
|
|
302
|
-
);
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
a();
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
a();
|
|
309
|
-
}
|
|
310
|
-
if (n.trim()) {
|
|
311
|
-
const u = l ?? e, d = l ? h : this.getCurrentPosition();
|
|
312
|
-
this.tokens.push(
|
|
313
|
-
p(c.EXPRESSION_CONTENT, n, u, d)
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
474
|
}
|
|
317
475
|
/**
|
|
318
476
|
* Read text content
|
|
@@ -321,14 +479,14 @@ class at {
|
|
|
321
479
|
const t = this.getCurrentPosition();
|
|
322
480
|
let e = "";
|
|
323
481
|
for (; !this.isEOF(); ) {
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
482
|
+
const i = this.peek();
|
|
483
|
+
if (i === "<" || i === "{")
|
|
326
484
|
break;
|
|
327
485
|
e += this.advance();
|
|
328
486
|
}
|
|
329
487
|
if (e) {
|
|
330
|
-
const
|
|
331
|
-
this.tokens.push(
|
|
488
|
+
const i = this.getCurrentPosition();
|
|
489
|
+
this.tokens.push(d(a.TEXT, e, t, i));
|
|
332
490
|
}
|
|
333
491
|
}
|
|
334
492
|
/**
|
|
@@ -339,8 +497,8 @@ class at {
|
|
|
339
497
|
let e = "";
|
|
340
498
|
for (; !this.isEOF() && this.isWhitespace(this.peek()); )
|
|
341
499
|
e += this.advance();
|
|
342
|
-
const
|
|
343
|
-
this.tokens.push(
|
|
500
|
+
const i = this.getCurrentPosition();
|
|
501
|
+
this.tokens.push(d(a.WHITESPACE, e, t, i));
|
|
344
502
|
}
|
|
345
503
|
/**
|
|
346
504
|
* Skip whitespace without creating tokens
|
|
@@ -368,168 +526,168 @@ class at {
|
|
|
368
526
|
return /[a-zA-Z0-9_$:.-]/.test(t);
|
|
369
527
|
}
|
|
370
528
|
}
|
|
371
|
-
function
|
|
372
|
-
return new
|
|
529
|
+
function K(n) {
|
|
530
|
+
return new dt(n).tokenize();
|
|
373
531
|
}
|
|
374
|
-
var f = /* @__PURE__ */ ((
|
|
375
|
-
function
|
|
376
|
-
return
|
|
532
|
+
var f = /* @__PURE__ */ ((n) => (n.ROOT = "Root", n.ELEMENT = "Element", n.FRAGMENT = "Fragment", n.TEXT = "Text", n.INTERPOLATION = "Interpolation", n.COMMENT = "Comment", n.ATTRIBUTE = "Attribute", n.DIRECTIVE_IF = "DirectiveIf", n.DIRECTIVE_ELSE_IF = "DirectiveElseIf", n.DIRECTIVE_ELSE = "DirectiveElse", n.DIRECTIVE_FOR = "DirectiveFor", n))(f || {});
|
|
533
|
+
function qt(n) {
|
|
534
|
+
return n.type === "Element";
|
|
377
535
|
}
|
|
378
|
-
function
|
|
379
|
-
return
|
|
536
|
+
function te(n) {
|
|
537
|
+
return n.type === "Fragment";
|
|
380
538
|
}
|
|
381
|
-
function
|
|
382
|
-
return
|
|
539
|
+
function ee(n) {
|
|
540
|
+
return n.type === "Text";
|
|
383
541
|
}
|
|
384
|
-
function
|
|
385
|
-
return
|
|
542
|
+
function ie(n) {
|
|
543
|
+
return n.type === "Interpolation";
|
|
386
544
|
}
|
|
387
|
-
function
|
|
388
|
-
return
|
|
545
|
+
function ne(n) {
|
|
546
|
+
return n.type === "Comment";
|
|
389
547
|
}
|
|
390
|
-
function
|
|
391
|
-
return
|
|
548
|
+
function re(n) {
|
|
549
|
+
return n.type === "DirectiveIf" || n.type === "DirectiveElseIf" || n.type === "DirectiveElse" || n.type === "DirectiveFor";
|
|
392
550
|
}
|
|
393
|
-
function
|
|
551
|
+
function pt(n, t, e) {
|
|
394
552
|
return {
|
|
395
553
|
type: "Root",
|
|
396
|
-
children:
|
|
554
|
+
children: n,
|
|
397
555
|
start: t,
|
|
398
556
|
end: e
|
|
399
557
|
};
|
|
400
558
|
}
|
|
401
|
-
function
|
|
402
|
-
const
|
|
559
|
+
function F(n, t, e, i, r, s, o) {
|
|
560
|
+
const h = /^[A-Z]/.test(n) || n.includes("."), l = t.find((u) => u.name === "ref"), c = l != null && l.value ? typeof l.value == "string" ? l.value : l.value.expression : void 0;
|
|
403
561
|
return {
|
|
404
562
|
type: "Element",
|
|
405
|
-
tag:
|
|
406
|
-
isComponent:
|
|
563
|
+
tag: n,
|
|
564
|
+
isComponent: h,
|
|
407
565
|
isSelfClosing: r,
|
|
408
566
|
attributes: t,
|
|
409
567
|
directives: e,
|
|
410
|
-
children:
|
|
411
|
-
ref:
|
|
568
|
+
children: i,
|
|
569
|
+
ref: c,
|
|
412
570
|
start: s,
|
|
413
571
|
end: o
|
|
414
572
|
};
|
|
415
573
|
}
|
|
416
|
-
function
|
|
574
|
+
function gt(n, t, e) {
|
|
417
575
|
return {
|
|
418
576
|
type: "Fragment",
|
|
419
|
-
children:
|
|
577
|
+
children: n,
|
|
420
578
|
start: t,
|
|
421
579
|
end: e
|
|
422
580
|
};
|
|
423
581
|
}
|
|
424
|
-
function Z(
|
|
582
|
+
function Z(n, t, e) {
|
|
425
583
|
return {
|
|
426
584
|
type: "Text",
|
|
427
|
-
content:
|
|
585
|
+
content: n,
|
|
428
586
|
start: t,
|
|
429
587
|
end: e
|
|
430
588
|
};
|
|
431
589
|
}
|
|
432
|
-
function
|
|
590
|
+
function Et(n, t, e) {
|
|
433
591
|
return {
|
|
434
592
|
type: "Interpolation",
|
|
435
|
-
expression:
|
|
593
|
+
expression: n,
|
|
436
594
|
start: t,
|
|
437
595
|
end: e
|
|
438
596
|
};
|
|
439
597
|
}
|
|
440
|
-
function
|
|
598
|
+
function mt(n, t, e) {
|
|
441
599
|
return {
|
|
442
600
|
type: "Comment",
|
|
443
|
-
content:
|
|
601
|
+
content: n,
|
|
444
602
|
start: t,
|
|
445
603
|
end: e
|
|
446
604
|
};
|
|
447
605
|
}
|
|
448
|
-
function
|
|
606
|
+
function x(n, t, e, i, r) {
|
|
449
607
|
return {
|
|
450
608
|
type: "Attribute",
|
|
451
|
-
name:
|
|
609
|
+
name: n,
|
|
452
610
|
value: t,
|
|
453
611
|
isDynamic: e,
|
|
454
|
-
start:
|
|
612
|
+
start: i,
|
|
455
613
|
end: r
|
|
456
614
|
};
|
|
457
615
|
}
|
|
458
|
-
function
|
|
616
|
+
function wt(n, t, e) {
|
|
459
617
|
return {
|
|
460
618
|
type: "DirectiveIf",
|
|
461
|
-
condition:
|
|
619
|
+
condition: n,
|
|
462
620
|
start: t,
|
|
463
621
|
end: e
|
|
464
622
|
};
|
|
465
623
|
}
|
|
466
|
-
function
|
|
624
|
+
function Ct(n, t, e) {
|
|
467
625
|
return {
|
|
468
626
|
type: "DirectiveElseIf",
|
|
469
|
-
condition:
|
|
627
|
+
condition: n,
|
|
470
628
|
start: t,
|
|
471
629
|
end: e
|
|
472
630
|
};
|
|
473
631
|
}
|
|
474
|
-
function
|
|
632
|
+
function Tt(n, t) {
|
|
475
633
|
return {
|
|
476
634
|
type: "DirectiveElse",
|
|
477
|
-
start:
|
|
635
|
+
start: n,
|
|
478
636
|
end: t
|
|
479
637
|
};
|
|
480
638
|
}
|
|
481
|
-
function
|
|
639
|
+
function vt(n, t, e, i, r) {
|
|
482
640
|
return {
|
|
483
641
|
type: "DirectiveFor",
|
|
484
|
-
item:
|
|
642
|
+
item: n,
|
|
485
643
|
index: e,
|
|
486
644
|
list: t,
|
|
487
|
-
start:
|
|
645
|
+
start: i,
|
|
488
646
|
end: r
|
|
489
647
|
};
|
|
490
648
|
}
|
|
491
|
-
function
|
|
492
|
-
|
|
493
|
-
t(e),
|
|
494
|
-
}) : (
|
|
495
|
-
t(e),
|
|
649
|
+
function D(n, t) {
|
|
650
|
+
n.type === "Root" ? n.children.forEach((e) => {
|
|
651
|
+
t(e), D(e, t);
|
|
652
|
+
}) : (n.type === "Element" || n.type === "Fragment") && n.children.forEach((e) => {
|
|
653
|
+
t(e), D(e, t);
|
|
496
654
|
});
|
|
497
655
|
}
|
|
498
|
-
function
|
|
499
|
-
if (
|
|
656
|
+
function N(n, t) {
|
|
657
|
+
if (n.type === "Root")
|
|
500
658
|
return {
|
|
501
|
-
...
|
|
502
|
-
children:
|
|
503
|
-
const
|
|
504
|
-
return
|
|
659
|
+
...n,
|
|
660
|
+
children: n.children.map((e) => {
|
|
661
|
+
const i = t(e);
|
|
662
|
+
return N(i, t);
|
|
505
663
|
})
|
|
506
664
|
};
|
|
507
|
-
if (
|
|
508
|
-
const e = t(
|
|
665
|
+
if (n.type === "Element") {
|
|
666
|
+
const e = t(n);
|
|
509
667
|
return e.type === "Element" ? {
|
|
510
668
|
...e,
|
|
511
|
-
children: e.children.map((
|
|
512
|
-
const r = t(
|
|
513
|
-
return
|
|
669
|
+
children: e.children.map((i) => {
|
|
670
|
+
const r = t(i);
|
|
671
|
+
return N(r, t);
|
|
514
672
|
})
|
|
515
673
|
} : e;
|
|
516
|
-
} else if (
|
|
517
|
-
const e = t(
|
|
674
|
+
} else if (n.type === "Fragment") {
|
|
675
|
+
const e = t(n);
|
|
518
676
|
return e.type === "Fragment" ? {
|
|
519
677
|
...e,
|
|
520
|
-
children: e.children.map((
|
|
521
|
-
const r = t(
|
|
522
|
-
return
|
|
678
|
+
children: e.children.map((i) => {
|
|
679
|
+
const r = t(i);
|
|
680
|
+
return N(r, t);
|
|
523
681
|
})
|
|
524
682
|
} : e;
|
|
525
683
|
}
|
|
526
|
-
return t(
|
|
684
|
+
return t(n);
|
|
527
685
|
}
|
|
528
|
-
class
|
|
529
|
-
constructor(t) {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
this.tokens = t.filter((
|
|
686
|
+
class St {
|
|
687
|
+
constructor(t, e = !1) {
|
|
688
|
+
p(this, "tokens");
|
|
689
|
+
p(this, "position", 0);
|
|
690
|
+
this.tokens = e ? t : t.filter((i) => i.type !== a.WHITESPACE);
|
|
533
691
|
}
|
|
534
692
|
/**
|
|
535
693
|
* Parse tokens into AST
|
|
@@ -540,29 +698,31 @@ class Tt {
|
|
|
540
698
|
const r = this.parseTemplateNode();
|
|
541
699
|
r && t.push(r);
|
|
542
700
|
}
|
|
543
|
-
const e = t.length > 0 ? t[0].start : { line: 1, column: 1, offset: 0 },
|
|
544
|
-
return
|
|
701
|
+
const e = t.length > 0 ? t[0].start : { line: 1, column: 1, offset: 0 }, i = t.length > 0 ? t[t.length - 1].end : { line: 1, column: 1, offset: 0 };
|
|
702
|
+
return pt(t, e, i);
|
|
545
703
|
}
|
|
546
704
|
/**
|
|
547
705
|
* Parse a single template node
|
|
548
706
|
*/
|
|
549
707
|
parseTemplateNode() {
|
|
550
|
-
|
|
551
|
-
|
|
708
|
+
const t = this.peek();
|
|
709
|
+
switch (t.type) {
|
|
710
|
+
case a.TAG_OPEN_START:
|
|
552
711
|
return this.parseElement();
|
|
553
|
-
case
|
|
712
|
+
case a.FRAGMENT_OPEN:
|
|
554
713
|
return this.parseFragment();
|
|
555
|
-
case
|
|
714
|
+
case a.TEXT:
|
|
715
|
+
case a.WHITESPACE:
|
|
556
716
|
return this.parseText();
|
|
557
|
-
case
|
|
717
|
+
case a.EXPRESSION_START:
|
|
558
718
|
return this.parseInterpolation();
|
|
559
|
-
case
|
|
719
|
+
case a.COMMENT:
|
|
560
720
|
return this.parseComment();
|
|
561
|
-
case
|
|
562
|
-
|
|
563
|
-
case
|
|
564
|
-
|
|
565
|
-
case
|
|
721
|
+
case a.TAG_CLOSE_START:
|
|
722
|
+
throw this.error("Unexpected closing tag", t);
|
|
723
|
+
case a.FRAGMENT_CLOSE:
|
|
724
|
+
throw this.error("Unexpected fragment closing tag", t);
|
|
725
|
+
case a.EOF:
|
|
566
726
|
return null;
|
|
567
727
|
default:
|
|
568
728
|
return this.advance(), null;
|
|
@@ -573,38 +733,39 @@ class Tt {
|
|
|
573
733
|
*/
|
|
574
734
|
parseFragment() {
|
|
575
735
|
const t = this.peek().start;
|
|
576
|
-
this.expect(
|
|
736
|
+
this.expect(a.FRAGMENT_OPEN);
|
|
577
737
|
const e = [];
|
|
578
|
-
for (; !this.isEOF() && !this.check(
|
|
579
|
-
const
|
|
580
|
-
|
|
738
|
+
for (; !this.isEOF() && !this.check(a.FRAGMENT_CLOSE); ) {
|
|
739
|
+
const i = this.parseTemplateNode();
|
|
740
|
+
i && e.push(i);
|
|
581
741
|
}
|
|
582
|
-
if (this.check(
|
|
583
|
-
const
|
|
584
|
-
return
|
|
742
|
+
if (this.check(a.FRAGMENT_CLOSE)) {
|
|
743
|
+
const i = this.expect(a.FRAGMENT_CLOSE);
|
|
744
|
+
return gt(e, t, i.end);
|
|
585
745
|
}
|
|
586
|
-
throw new Error(
|
|
587
|
-
|
|
588
|
-
|
|
746
|
+
throw Object.assign(new Error("Unclosed fragment"), {
|
|
747
|
+
line: t.line,
|
|
748
|
+
column: t.column
|
|
749
|
+
});
|
|
589
750
|
}
|
|
590
751
|
/**
|
|
591
752
|
* Parse element
|
|
592
753
|
*/
|
|
593
754
|
parseElement() {
|
|
594
755
|
const t = this.peek().start;
|
|
595
|
-
this.expect(
|
|
756
|
+
this.expect(a.TAG_OPEN_START);
|
|
596
757
|
const e = this.peek();
|
|
597
|
-
if (e.type !==
|
|
758
|
+
if (e.type !== a.IDENTIFIER)
|
|
598
759
|
throw new Error(
|
|
599
760
|
`Expected tag name at line ${e.start.line}, column ${e.start.column}`
|
|
600
761
|
);
|
|
601
|
-
const
|
|
762
|
+
const i = e.value;
|
|
602
763
|
this.advance();
|
|
603
764
|
const { attributes: r, directives: s } = this.parseAttributesAndDirectives();
|
|
604
|
-
if (this.check(
|
|
765
|
+
if (this.check(a.TAG_SELF_CLOSE)) {
|
|
605
766
|
const h = this.peek().end;
|
|
606
|
-
return this.advance(),
|
|
607
|
-
|
|
767
|
+
return this.advance(), F(
|
|
768
|
+
i,
|
|
608
769
|
r,
|
|
609
770
|
s,
|
|
610
771
|
[],
|
|
@@ -613,62 +774,53 @@ class Tt {
|
|
|
613
774
|
h
|
|
614
775
|
);
|
|
615
776
|
}
|
|
616
|
-
this.expect(
|
|
777
|
+
this.expect(a.TAG_OPEN_END);
|
|
617
778
|
const o = [];
|
|
618
|
-
for (; !this.isEOF() && !this.check(
|
|
779
|
+
for (; !this.isEOF() && !this.check(a.TAG_CLOSE_START); ) {
|
|
619
780
|
const h = this.parseTemplateNode();
|
|
620
781
|
h && o.push(h);
|
|
621
782
|
}
|
|
622
|
-
if (this.check(
|
|
783
|
+
if (this.check(a.TAG_CLOSE_START)) {
|
|
623
784
|
this.advance();
|
|
624
785
|
const h = this.peek();
|
|
625
|
-
if (h.type !==
|
|
626
|
-
const
|
|
786
|
+
if (h.type !== a.IDENTIFIER) {
|
|
787
|
+
const u = new Error(
|
|
627
788
|
`Expected closing tag name at line ${h.start.line}, column ${h.start.column}`
|
|
628
789
|
);
|
|
629
|
-
throw
|
|
790
|
+
throw u.line = h.start.line, u.column = h.start.column, u;
|
|
630
791
|
}
|
|
631
|
-
const
|
|
632
|
-
if (
|
|
633
|
-
const
|
|
634
|
-
`Mismatched closing tag: expected </${
|
|
792
|
+
const l = h.value;
|
|
793
|
+
if (l !== i) {
|
|
794
|
+
const u = new Error(
|
|
795
|
+
`Mismatched closing tag: expected </${i}> but got </${l}> at line ${h.start.line}, column ${h.start.column}`
|
|
635
796
|
);
|
|
636
|
-
throw
|
|
797
|
+
throw u.line = h.start.line, u.column = h.start.column, u;
|
|
637
798
|
}
|
|
638
799
|
this.advance();
|
|
639
|
-
const
|
|
640
|
-
return this.expect(
|
|
641
|
-
|
|
800
|
+
const c = this.peek().end;
|
|
801
|
+
return this.expect(a.TAG_OPEN_END), F(
|
|
802
|
+
i,
|
|
642
803
|
r,
|
|
643
804
|
s,
|
|
644
805
|
o,
|
|
645
806
|
!1,
|
|
646
807
|
t,
|
|
647
|
-
|
|
808
|
+
c
|
|
648
809
|
);
|
|
649
810
|
}
|
|
650
|
-
|
|
651
|
-
return x(
|
|
652
|
-
n,
|
|
653
|
-
r,
|
|
654
|
-
s,
|
|
655
|
-
o,
|
|
656
|
-
!1,
|
|
657
|
-
t,
|
|
658
|
-
l
|
|
659
|
-
);
|
|
811
|
+
throw this.error(`Unclosed tag <${i}>`, e);
|
|
660
812
|
}
|
|
661
813
|
/**
|
|
662
814
|
* Parse attributes and directives
|
|
663
815
|
*/
|
|
664
816
|
parseAttributesAndDirectives() {
|
|
665
817
|
const t = [], e = [];
|
|
666
|
-
for (; !this.isEOF() && !this.check(
|
|
667
|
-
const
|
|
668
|
-
if (
|
|
818
|
+
for (; !this.isEOF() && !this.check(a.TAG_OPEN_END) && !this.check(a.TAG_SELF_CLOSE); ) {
|
|
819
|
+
const i = this.peek();
|
|
820
|
+
if (i.type === a.DIRECTIVE_IF || i.type === a.DIRECTIVE_ELSE_IF || i.type === a.DIRECTIVE_ELSE || i.type === a.DIRECTIVE_FOR) {
|
|
669
821
|
const r = this.parseDirective();
|
|
670
822
|
r && e.push(r);
|
|
671
|
-
} else if (
|
|
823
|
+
} else if (i.type === a.IDENTIFIER || i.type === a.KEYWORD_REF) {
|
|
672
824
|
const r = this.parseAttribute();
|
|
673
825
|
r && t.push(r);
|
|
674
826
|
} else
|
|
@@ -680,21 +832,28 @@ class Tt {
|
|
|
680
832
|
* Parse attribute
|
|
681
833
|
*/
|
|
682
834
|
parseAttribute() {
|
|
683
|
-
const t = this.peek().start, e = this.advance(),
|
|
684
|
-
if (!this.check(
|
|
685
|
-
return
|
|
835
|
+
const t = this.peek().start, e = this.advance(), i = e.value;
|
|
836
|
+
if (!this.check(a.ATTRIBUTE_EQUALS))
|
|
837
|
+
return x(i, null, !1, t, e.end);
|
|
686
838
|
this.advance();
|
|
687
839
|
const r = this.peek();
|
|
688
|
-
let s, o = !1,
|
|
689
|
-
if (r.type ===
|
|
840
|
+
let s, o = !1, h = r.end;
|
|
841
|
+
if (r.type === a.STRING_LITERAL)
|
|
690
842
|
s = r.value.slice(1, -1), this.advance();
|
|
691
|
-
else if (r.type ===
|
|
843
|
+
else if (r.type === a.EXPRESSION_START) {
|
|
692
844
|
this.advance();
|
|
693
|
-
const
|
|
694
|
-
|
|
845
|
+
const l = this.peek();
|
|
846
|
+
if (l.type === a.EXPRESSION_CONTENT)
|
|
847
|
+
s = { expression: l.value.trim() }, o = !0, this.advance();
|
|
848
|
+
else
|
|
849
|
+
throw this.error(
|
|
850
|
+
"Expected a non-empty attribute expression",
|
|
851
|
+
l
|
|
852
|
+
);
|
|
853
|
+
h = this.expect(a.EXPRESSION_END).end;
|
|
695
854
|
} else
|
|
696
|
-
|
|
697
|
-
return
|
|
855
|
+
throw this.error("Expected a quoted attribute or expression", r);
|
|
856
|
+
return x(i, s, o, t, h);
|
|
698
857
|
}
|
|
699
858
|
/**
|
|
700
859
|
* Parse directive
|
|
@@ -702,28 +861,32 @@ class Tt {
|
|
|
702
861
|
parseDirective() {
|
|
703
862
|
const t = this.peek().start, e = this.advance();
|
|
704
863
|
switch (e.type) {
|
|
705
|
-
case
|
|
706
|
-
case
|
|
707
|
-
this.expect(
|
|
708
|
-
const
|
|
864
|
+
case a.DIRECTIVE_IF:
|
|
865
|
+
case a.DIRECTIVE_ELSE_IF: {
|
|
866
|
+
this.expect(a.ATTRIBUTE_EQUALS), this.expect(a.EXPRESSION_START);
|
|
867
|
+
const i = this.peek();
|
|
709
868
|
let r = "";
|
|
710
|
-
|
|
869
|
+
if (i.type === a.EXPRESSION_CONTENT && (r = i.value.trim(), this.advance()), !r)
|
|
870
|
+
throw this.error("Expected a non-empty condition", i);
|
|
711
871
|
const s = this.peek().end;
|
|
712
|
-
return this.expect(
|
|
872
|
+
return this.expect(a.EXPRESSION_END), e.type === a.DIRECTIVE_IF ? wt(r, t, s) : Ct(r, t, s);
|
|
713
873
|
}
|
|
714
|
-
case
|
|
715
|
-
const
|
|
716
|
-
return
|
|
874
|
+
case a.DIRECTIVE_ELSE: {
|
|
875
|
+
const i = e.end;
|
|
876
|
+
return Tt(t, i);
|
|
717
877
|
}
|
|
718
|
-
case
|
|
719
|
-
this.expect(
|
|
720
|
-
const
|
|
878
|
+
case a.DIRECTIVE_FOR: {
|
|
879
|
+
this.expect(a.ATTRIBUTE_EQUALS), this.expect(a.EXPRESSION_START);
|
|
880
|
+
const i = this.peek();
|
|
721
881
|
let r = "";
|
|
722
|
-
|
|
882
|
+
i.type === a.EXPRESSION_CONTENT && (r = i.value.trim(), this.advance());
|
|
723
883
|
const s = this.peek().end;
|
|
724
|
-
this.expect(
|
|
725
|
-
const { item: o, index:
|
|
726
|
-
|
|
884
|
+
this.expect(a.EXPRESSION_END);
|
|
885
|
+
const { item: o, index: h, list: l } = this.parseForExpression(
|
|
886
|
+
r,
|
|
887
|
+
i
|
|
888
|
+
);
|
|
889
|
+
return vt(o, l, h, t, s);
|
|
727
890
|
}
|
|
728
891
|
default:
|
|
729
892
|
return null;
|
|
@@ -732,26 +895,28 @@ class Tt {
|
|
|
732
895
|
/**
|
|
733
896
|
* Parse l-for expression
|
|
734
897
|
*/
|
|
735
|
-
parseForExpression(t) {
|
|
736
|
-
const
|
|
737
|
-
`^\\s*\\(\\s*(${
|
|
738
|
-
),
|
|
739
|
-
`^\\s*(${
|
|
740
|
-
),
|
|
741
|
-
if (
|
|
898
|
+
parseForExpression(t, e) {
|
|
899
|
+
const i = "[A-Za-z_$][\\w$]*", r = new RegExp(
|
|
900
|
+
`^\\s*\\(\\s*(${i})\\s*,\\s*(${i})\\s*\\)\\s+in\\s+([\\s\\S]+)$`
|
|
901
|
+
), s = new RegExp(
|
|
902
|
+
`^\\s*(${i})\\s+in\\s+([\\s\\S]+)$`
|
|
903
|
+
), o = t.match(r);
|
|
904
|
+
if (o)
|
|
742
905
|
return {
|
|
743
|
-
item:
|
|
744
|
-
index:
|
|
745
|
-
list:
|
|
906
|
+
item: o[1],
|
|
907
|
+
index: o[2],
|
|
908
|
+
list: o[3].trim()
|
|
746
909
|
};
|
|
747
|
-
const
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
910
|
+
const h = t.match(s);
|
|
911
|
+
if (h)
|
|
912
|
+
return {
|
|
913
|
+
item: h[1],
|
|
914
|
+
list: h[2].trim()
|
|
915
|
+
};
|
|
916
|
+
throw this.error(
|
|
917
|
+
"Invalid l-for: expected item in list or (item, index) in list",
|
|
918
|
+
e
|
|
919
|
+
);
|
|
755
920
|
}
|
|
756
921
|
/**
|
|
757
922
|
* Parse text node
|
|
@@ -765,19 +930,28 @@ class Tt {
|
|
|
765
930
|
*/
|
|
766
931
|
parseInterpolation() {
|
|
767
932
|
const t = this.peek().start;
|
|
768
|
-
this.expect(
|
|
933
|
+
this.expect(a.EXPRESSION_START);
|
|
769
934
|
const e = this.peek();
|
|
770
|
-
let
|
|
771
|
-
e.type ===
|
|
935
|
+
let i = "";
|
|
936
|
+
if (e.type === a.EXPRESSION_CONTENT && (i = e.value.trim(), this.advance()), !i)
|
|
937
|
+
throw this.error("Expected a non-empty interpolation", e);
|
|
772
938
|
const r = this.peek().end;
|
|
773
|
-
return this.expect(
|
|
939
|
+
return this.expect(a.EXPRESSION_END), Et(i, t, r);
|
|
774
940
|
}
|
|
775
941
|
/**
|
|
776
942
|
* Parse comment node
|
|
777
943
|
*/
|
|
778
944
|
parseComment() {
|
|
779
945
|
const t = this.advance(), e = t.value.replace(/^<!--\s*|\s*-->$/g, "");
|
|
780
|
-
return
|
|
946
|
+
return mt(e, t.start, t.end);
|
|
947
|
+
}
|
|
948
|
+
error(t, e) {
|
|
949
|
+
return Object.assign(
|
|
950
|
+
new Error(
|
|
951
|
+
`${t} at line ${e.start.line}, column ${e.start.column}`
|
|
952
|
+
),
|
|
953
|
+
{ line: e.start.line, column: e.start.column }
|
|
954
|
+
);
|
|
781
955
|
}
|
|
782
956
|
/**
|
|
783
957
|
* Peek at current token without consuming
|
|
@@ -804,10 +978,10 @@ class Tt {
|
|
|
804
978
|
expect(t) {
|
|
805
979
|
const e = this.peek();
|
|
806
980
|
if (e.type !== t) {
|
|
807
|
-
const
|
|
981
|
+
const i = new Error(
|
|
808
982
|
`Expected token ${t} but got ${e.type} at line ${e.start.line}, column ${e.start.column}`
|
|
809
983
|
);
|
|
810
|
-
throw
|
|
984
|
+
throw i.line = e.start.line, i.column = e.start.column, i;
|
|
811
985
|
}
|
|
812
986
|
return this.advance();
|
|
813
987
|
}
|
|
@@ -815,80 +989,91 @@ class Tt {
|
|
|
815
989
|
* Check if we've reached EOF
|
|
816
990
|
*/
|
|
817
991
|
isEOF() {
|
|
818
|
-
return this.position >= this.tokens.length || this.peek().type ===
|
|
992
|
+
return this.position >= this.tokens.length || this.peek().type === a.EOF;
|
|
819
993
|
}
|
|
820
994
|
}
|
|
821
|
-
function
|
|
822
|
-
return new
|
|
995
|
+
function Q(n, t = !1) {
|
|
996
|
+
return new St(n, t).parse();
|
|
823
997
|
}
|
|
824
|
-
function
|
|
998
|
+
function It(n) {
|
|
825
999
|
return {
|
|
826
|
-
...
|
|
827
|
-
children:
|
|
1000
|
+
...n,
|
|
1001
|
+
children: C(n.children)
|
|
828
1002
|
};
|
|
829
1003
|
}
|
|
830
|
-
function
|
|
1004
|
+
function C(n) {
|
|
831
1005
|
const t = [];
|
|
832
|
-
for (let e = 0; e <
|
|
833
|
-
const
|
|
834
|
-
if (
|
|
1006
|
+
for (let e = 0; e < n.length; e++) {
|
|
1007
|
+
const i = n[e];
|
|
1008
|
+
if (i.type === f.ELEMENT) {
|
|
835
1009
|
const r = {
|
|
836
|
-
...
|
|
837
|
-
children:
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
|
|
1010
|
+
...i,
|
|
1011
|
+
children: C(i.children)
|
|
1012
|
+
}, s = i.directives.find(
|
|
1013
|
+
(h) => h.type === f.DIRECTIVE_ELSE_IF || h.type === f.DIRECTIVE_ELSE
|
|
1014
|
+
);
|
|
1015
|
+
if (s)
|
|
1016
|
+
throw Object.assign(
|
|
1017
|
+
new Error("l-else-if/l-else must follow l-if or l-else-if"),
|
|
1018
|
+
{ line: s.start.line, column: s.start.column }
|
|
1019
|
+
);
|
|
1020
|
+
if (i.directives.find(
|
|
1021
|
+
(h) => h.type === f.DIRECTIVE_IF
|
|
841
1022
|
)) {
|
|
842
|
-
const
|
|
843
|
-
if: r,
|
|
1023
|
+
const h = {
|
|
1024
|
+
if: { ...r },
|
|
844
1025
|
elseIfs: []
|
|
845
1026
|
};
|
|
846
|
-
let l = e + 1;
|
|
847
|
-
for (; l <
|
|
848
|
-
const
|
|
849
|
-
if (
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
1027
|
+
let l = e + 1, c = e;
|
|
1028
|
+
for (; l < n.length; ) {
|
|
1029
|
+
const u = n[l];
|
|
1030
|
+
if (u.type === f.COMMENT || u.type === f.TEXT && !u.content.trim()) {
|
|
1031
|
+
l++;
|
|
1032
|
+
continue;
|
|
1033
|
+
}
|
|
1034
|
+
if (u.type === f.ELEMENT) {
|
|
1035
|
+
const E = u.directives.find(
|
|
1036
|
+
(k) => k.type === f.DIRECTIVE_ELSE_IF
|
|
1037
|
+
), et = u.directives.find(
|
|
1038
|
+
(k) => k.type === f.DIRECTIVE_ELSE
|
|
854
1039
|
);
|
|
855
|
-
if (
|
|
856
|
-
|
|
857
|
-
...
|
|
858
|
-
children:
|
|
859
|
-
}), l++;
|
|
1040
|
+
if (E) {
|
|
1041
|
+
h.elseIfs.push({
|
|
1042
|
+
...u,
|
|
1043
|
+
children: C(u.children)
|
|
1044
|
+
}), c = l, l++;
|
|
860
1045
|
continue;
|
|
861
1046
|
}
|
|
862
|
-
if (
|
|
863
|
-
|
|
864
|
-
...
|
|
865
|
-
children:
|
|
866
|
-
}, l++;
|
|
1047
|
+
if (et) {
|
|
1048
|
+
h.else = {
|
|
1049
|
+
...u,
|
|
1050
|
+
children: C(u.children)
|
|
1051
|
+
}, c = l, l++;
|
|
867
1052
|
break;
|
|
868
1053
|
}
|
|
869
1054
|
}
|
|
870
1055
|
break;
|
|
871
1056
|
}
|
|
872
|
-
r.__conditionalGroup =
|
|
1057
|
+
r.__conditionalGroup = h, e = c;
|
|
873
1058
|
}
|
|
874
1059
|
t.push(r);
|
|
875
|
-
} else
|
|
876
|
-
...
|
|
877
|
-
children:
|
|
878
|
-
}) : t.push(
|
|
1060
|
+
} else i.type === f.FRAGMENT ? t.push({
|
|
1061
|
+
...i,
|
|
1062
|
+
children: C(i.children)
|
|
1063
|
+
}) : t.push(i);
|
|
879
1064
|
}
|
|
880
1065
|
return t;
|
|
881
1066
|
}
|
|
882
|
-
function
|
|
883
|
-
return
|
|
1067
|
+
function O(n) {
|
|
1068
|
+
return n.__conditionalGroup;
|
|
884
1069
|
}
|
|
885
|
-
function
|
|
886
|
-
return
|
|
1070
|
+
function se(n, t) {
|
|
1071
|
+
return n.directives.some((e) => e.type === t);
|
|
887
1072
|
}
|
|
888
|
-
function
|
|
889
|
-
return
|
|
1073
|
+
function P(n, t) {
|
|
1074
|
+
return n.directives.find((e) => e.type === t);
|
|
890
1075
|
}
|
|
891
|
-
function
|
|
1076
|
+
function _t(n, t) {
|
|
892
1077
|
const e = {
|
|
893
1078
|
mergeTextNodes: !0,
|
|
894
1079
|
removeWhitespace: !0,
|
|
@@ -896,494 +1081,298 @@ function It(i, t) {
|
|
|
896
1081
|
...t
|
|
897
1082
|
};
|
|
898
1083
|
return {
|
|
899
|
-
...
|
|
900
|
-
children:
|
|
1084
|
+
...n,
|
|
1085
|
+
children: b(n.children, e)
|
|
901
1086
|
};
|
|
902
1087
|
}
|
|
903
|
-
function
|
|
904
|
-
let e =
|
|
905
|
-
return t.mergeTextNodes && (e = Nt(e)), t.removeWhitespace && (e =
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1088
|
+
function b(n, t) {
|
|
1089
|
+
let e = n.map((i) => Rt(i, t));
|
|
1090
|
+
return t.mergeTextNodes && (e = Nt(e)), t.removeWhitespace && (e = yt(e)), t.trimText && (e = e.map(
|
|
1091
|
+
(i, r) => i.type === f.TEXT ? {
|
|
1092
|
+
...i,
|
|
1093
|
+
content: e.length === 1 ? i.content.trim() : r === 0 ? i.content.trimStart() : r === e.length - 1 ? i.content.trimEnd() : i.content
|
|
1094
|
+
} : i
|
|
1095
|
+
)), e;
|
|
1096
|
+
}
|
|
1097
|
+
function Rt(n, t) {
|
|
1098
|
+
return n.type === f.ELEMENT ? I(n, t) : n.type === f.FRAGMENT ? kt(n, t) : (n.type === f.TEXT, n);
|
|
1099
|
+
}
|
|
1100
|
+
function I(n, t) {
|
|
1101
|
+
const e = /^(pre|textarea)$/.test(n.tag) ? { ...t, trimText: !1, removeWhitespace: !1 } : t, i = {
|
|
1102
|
+
...n,
|
|
1103
|
+
children: b(n.children, e)
|
|
1104
|
+
}, r = O(n);
|
|
1105
|
+
return r && (i.__conditionalGroup = {
|
|
1106
|
+
if: I(r.if, t),
|
|
1107
|
+
elseIfs: r.elseIfs.map(
|
|
1108
|
+
(s) => I(s, t)
|
|
1109
|
+
),
|
|
1110
|
+
else: r.else ? I(r.else, t) : void 0
|
|
1111
|
+
}), i;
|
|
1112
|
+
}
|
|
1113
|
+
function kt(n, t) {
|
|
917
1114
|
return {
|
|
918
|
-
...
|
|
919
|
-
children:
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
|
-
function kt(i, t) {
|
|
923
|
-
let e = i.content;
|
|
924
|
-
return t.trimText && (e = e.trim()), {
|
|
925
|
-
...i,
|
|
926
|
-
content: e
|
|
1115
|
+
...n,
|
|
1116
|
+
children: b(n.children, t)
|
|
927
1117
|
};
|
|
928
1118
|
}
|
|
929
|
-
function Nt(
|
|
1119
|
+
function Nt(n) {
|
|
930
1120
|
const t = [];
|
|
931
1121
|
let e = null;
|
|
932
|
-
for (const
|
|
933
|
-
|
|
934
|
-
e.content +
|
|
1122
|
+
for (const i of n)
|
|
1123
|
+
i.type === f.TEXT ? e ? e = Z(
|
|
1124
|
+
e.content + i.content,
|
|
935
1125
|
e.start,
|
|
936
|
-
|
|
937
|
-
) : e =
|
|
1126
|
+
i.end
|
|
1127
|
+
) : e = i : (e && (t.push(e), e = null), t.push(i));
|
|
938
1128
|
return e && t.push(e), t;
|
|
939
1129
|
}
|
|
940
|
-
function
|
|
941
|
-
return
|
|
1130
|
+
function yt(n) {
|
|
1131
|
+
return n.filter((t) => t.type === f.TEXT ? t.content.trim().length > 0 || !/[\r\n]/.test(t.content) : !0);
|
|
942
1132
|
}
|
|
943
|
-
function
|
|
944
|
-
return
|
|
1133
|
+
function oe(n) {
|
|
1134
|
+
return n.content.trim().length === 0;
|
|
945
1135
|
}
|
|
946
|
-
function
|
|
1136
|
+
function $(n) {
|
|
947
1137
|
let t = 1;
|
|
948
|
-
return
|
|
949
|
-
t +=
|
|
950
|
-
}) : (
|
|
951
|
-
t +=
|
|
1138
|
+
return n.type === f.ROOT ? n.children.forEach((e) => {
|
|
1139
|
+
t += $(e);
|
|
1140
|
+
}) : (n.type === f.ELEMENT || n.type === f.FRAGMENT) && n.children.forEach((e) => {
|
|
1141
|
+
t += $(e);
|
|
952
1142
|
}), t;
|
|
953
1143
|
}
|
|
954
|
-
function
|
|
955
|
-
let e =
|
|
956
|
-
return e =
|
|
1144
|
+
function H(n, t) {
|
|
1145
|
+
let e = n;
|
|
1146
|
+
return e = It(e), (t == null ? void 0 : t.optimize) !== !1 && (e = _t(e, t == null ? void 0 : t.optimizeOptions)), e;
|
|
957
1147
|
}
|
|
958
|
-
function
|
|
1148
|
+
function Y(n, t) {
|
|
959
1149
|
const e = {
|
|
960
1150
|
templateFactory: "h",
|
|
961
1151
|
templateFragmentFactory: "Fragment",
|
|
962
1152
|
...t
|
|
963
1153
|
};
|
|
964
|
-
return
|
|
1154
|
+
return Ot(n.children, e);
|
|
965
1155
|
}
|
|
966
|
-
function
|
|
967
|
-
const e =
|
|
1156
|
+
function Ot(n, t) {
|
|
1157
|
+
const e = n.map((i) => A(i, t)).filter((i) => i !== "");
|
|
968
1158
|
return e.length === 0 ? "null" : e.length === 1 ? e[0] : `[${e.join(", ")}]`;
|
|
969
1159
|
}
|
|
970
|
-
function
|
|
971
|
-
switch (
|
|
1160
|
+
function A(n, t) {
|
|
1161
|
+
switch (n.type) {
|
|
972
1162
|
case f.ELEMENT:
|
|
973
|
-
return
|
|
1163
|
+
return T(n, t);
|
|
974
1164
|
case f.FRAGMENT:
|
|
975
|
-
return
|
|
1165
|
+
return bt(n, t);
|
|
976
1166
|
case f.TEXT:
|
|
977
|
-
return Lt(
|
|
1167
|
+
return Lt(n);
|
|
978
1168
|
case f.INTERPOLATION:
|
|
979
|
-
return Ft(
|
|
1169
|
+
return Ft(n, t);
|
|
980
1170
|
case f.COMMENT:
|
|
981
1171
|
return "";
|
|
982
1172
|
default:
|
|
983
1173
|
return "";
|
|
984
1174
|
}
|
|
985
1175
|
}
|
|
986
|
-
function
|
|
987
|
-
const e =
|
|
988
|
-
if (e)
|
|
989
|
-
return Pt(e, t);
|
|
990
|
-
const n = i.directives.find(
|
|
1176
|
+
function T(n, t) {
|
|
1177
|
+
const e = n.directives.find(
|
|
991
1178
|
(r) => r.type === f.DIRECTIVE_FOR
|
|
992
1179
|
);
|
|
993
|
-
|
|
1180
|
+
if (e)
|
|
1181
|
+
return xt(n, e, t);
|
|
1182
|
+
const i = O(n);
|
|
1183
|
+
return i ? Dt(i, t) : J(n, t);
|
|
994
1184
|
}
|
|
995
|
-
function
|
|
996
|
-
const e = t.templateFactory,
|
|
997
|
-
return s.length === 0 ? `${e}(${
|
|
1185
|
+
function J(n, t) {
|
|
1186
|
+
const e = t.templateFactory, i = n.isComponent ? n.tag : `'${n.tag}'`, r = At(n, t), s = n.children.map((o) => A(o, t)).filter((o) => o !== "");
|
|
1187
|
+
return s.length === 0 ? `${e}(${i}, ${r})` : `${e}(${i}, ${r}, ${s.join(", ")})`;
|
|
998
1188
|
}
|
|
999
|
-
function
|
|
1000
|
-
const e = t.templateFactory,
|
|
1001
|
-
return r.length === 0 ? `${e}(${
|
|
1189
|
+
function bt(n, t) {
|
|
1190
|
+
const e = t.templateFactory, i = t.templateFragmentFactory, r = n.children.map((s) => A(s, t)).filter((s) => s !== "");
|
|
1191
|
+
return r.length === 0 ? `${e}(${i}, null)` : `${e}(${i}, null, ${r.join(", ")})`;
|
|
1002
1192
|
}
|
|
1003
|
-
function At(
|
|
1004
|
-
return
|
|
1005
|
-
const r =
|
|
1193
|
+
function At(n, t) {
|
|
1194
|
+
return n.attributes.length === 0 ? "null" : `{ ${n.attributes.map((i) => {
|
|
1195
|
+
const r = /^[A-Za-z_$][\w$]*$/.test(i.name) && i.name !== "__proto__" ? i.name : `[${y(i.name)}]`;
|
|
1006
1196
|
let s;
|
|
1007
|
-
return
|
|
1197
|
+
return i.value === null ? s = "true" : typeof i.value == "string" ? s = y(i.value) : s = q(
|
|
1198
|
+
v(i.value.expression, t)
|
|
1199
|
+
), `${r}: ${s}`;
|
|
1008
1200
|
}).join(", ")} }`;
|
|
1009
1201
|
}
|
|
1010
|
-
function Lt(
|
|
1011
|
-
return
|
|
1012
|
-
}
|
|
1013
|
-
function Ft(
|
|
1014
|
-
return
|
|
1015
|
-
}
|
|
1016
|
-
function
|
|
1017
|
-
const { item:
|
|
1018
|
-
...
|
|
1019
|
-
directives:
|
|
1020
|
-
}, l =
|
|
1021
|
-
|
|
1202
|
+
function Lt(n) {
|
|
1203
|
+
return y(n.content);
|
|
1204
|
+
}
|
|
1205
|
+
function Ft(n, t) {
|
|
1206
|
+
return q(v(n.expression, t));
|
|
1207
|
+
}
|
|
1208
|
+
function xt(n, t, e) {
|
|
1209
|
+
const { item: i, index: r, list: s } = t, o = v(s, e), h = {
|
|
1210
|
+
...n,
|
|
1211
|
+
directives: n.directives.filter((u) => u.type !== f.DIRECTIVE_FOR)
|
|
1212
|
+
}, l = O(n);
|
|
1213
|
+
l && (h.__conditionalGroup = {
|
|
1214
|
+
...l,
|
|
1215
|
+
if: {
|
|
1216
|
+
...l.if,
|
|
1217
|
+
directives: l.if.directives.filter(
|
|
1218
|
+
(u) => u.type !== f.DIRECTIVE_FOR
|
|
1219
|
+
)
|
|
1220
|
+
}
|
|
1221
|
+
});
|
|
1222
|
+
const c = T(h, e);
|
|
1223
|
+
return r ? `(${o}).map((${i}, ${r}) => ${c})` : `(${o}).map(${i} => ${c})`;
|
|
1022
1224
|
}
|
|
1023
|
-
function
|
|
1024
|
-
const e =
|
|
1225
|
+
function Dt(n, t) {
|
|
1226
|
+
const e = P(n.if, f.DIRECTIVE_IF);
|
|
1025
1227
|
if (!e)
|
|
1026
|
-
return
|
|
1027
|
-
const
|
|
1028
|
-
...
|
|
1029
|
-
directives:
|
|
1228
|
+
return J(n.if, t);
|
|
1229
|
+
const i = {
|
|
1230
|
+
...n.if,
|
|
1231
|
+
directives: n.if.directives.filter(
|
|
1030
1232
|
(s) => s.type !== f.DIRECTIVE_IF
|
|
1031
1233
|
)
|
|
1032
1234
|
};
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1235
|
+
delete i.__conditionalGroup;
|
|
1236
|
+
let r = `(${v(e.condition, t)}) ? ${T(i, t)}`;
|
|
1237
|
+
for (const s of n.elseIfs || []) {
|
|
1238
|
+
const o = P(
|
|
1036
1239
|
s,
|
|
1037
1240
|
f.DIRECTIVE_ELSE_IF
|
|
1038
1241
|
);
|
|
1039
1242
|
if (!o) continue;
|
|
1040
|
-
const
|
|
1243
|
+
const h = {
|
|
1041
1244
|
...s,
|
|
1042
1245
|
directives: s.directives.filter(
|
|
1043
|
-
(
|
|
1246
|
+
(l) => l.type !== f.DIRECTIVE_ELSE_IF
|
|
1044
1247
|
)
|
|
1045
1248
|
};
|
|
1046
|
-
r += ` : (${o.condition}) ? ${
|
|
1249
|
+
r += ` : (${v(o.condition, t)}) ? ${T(h, t)}`;
|
|
1047
1250
|
}
|
|
1048
|
-
if (
|
|
1251
|
+
if (n.else) {
|
|
1049
1252
|
const s = {
|
|
1050
|
-
...
|
|
1051
|
-
directives:
|
|
1253
|
+
...n.else,
|
|
1254
|
+
directives: n.else.directives.filter(
|
|
1052
1255
|
(o) => o.type !== f.DIRECTIVE_ELSE
|
|
1053
1256
|
)
|
|
1054
1257
|
};
|
|
1055
|
-
r += ` : ${
|
|
1258
|
+
r += ` : ${T(s, t)}`;
|
|
1056
1259
|
} else
|
|
1057
1260
|
r += " : null";
|
|
1058
1261
|
return r;
|
|
1059
1262
|
}
|
|
1060
|
-
function
|
|
1061
|
-
return
|
|
1263
|
+
function he(n) {
|
|
1264
|
+
return n;
|
|
1062
1265
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
e
|
|
1073
|
-
e === 33 || // !
|
|
1074
|
-
W(e)))
|
|
1075
|
-
return !1;
|
|
1076
|
-
let r = t - 1;
|
|
1077
|
-
for (; r >= 0; ) {
|
|
1078
|
-
const s = i.charCodeAt(r);
|
|
1079
|
-
if (s === 32 || s === 9 || s === 10 || s === 13) {
|
|
1080
|
-
r--;
|
|
1081
|
-
continue;
|
|
1082
|
-
}
|
|
1083
|
-
if (W(s))
|
|
1084
|
-
return !1;
|
|
1085
|
-
break;
|
|
1086
|
-
}
|
|
1087
|
-
return !0;
|
|
1088
|
-
}, _ = (i, t, e) => {
|
|
1089
|
-
let n = t + 1;
|
|
1090
|
-
for (; n < i.length; ) {
|
|
1091
|
-
const r = i[n];
|
|
1092
|
-
if (r === "\\") {
|
|
1093
|
-
n += 2;
|
|
1094
|
-
continue;
|
|
1095
|
-
}
|
|
1096
|
-
if (r === e)
|
|
1097
|
-
return n + 1;
|
|
1098
|
-
n++;
|
|
1099
|
-
}
|
|
1100
|
-
return i.length;
|
|
1101
|
-
}, R = (i, t) => {
|
|
1102
|
-
let e = t + 1;
|
|
1103
|
-
for (; e < i.length; ) {
|
|
1104
|
-
const n = i[e];
|
|
1105
|
-
if (n === "\\") {
|
|
1106
|
-
e += 2;
|
|
1107
|
-
continue;
|
|
1108
|
-
}
|
|
1109
|
-
if (n === "`")
|
|
1110
|
-
return e + 1;
|
|
1111
|
-
if (n === "$" && i[e + 1] === "{") {
|
|
1112
|
-
e = et(i, e + 2);
|
|
1113
|
-
continue;
|
|
1114
|
-
}
|
|
1115
|
-
e++;
|
|
1116
|
-
}
|
|
1117
|
-
return i.length;
|
|
1118
|
-
}, k = (i, t) => {
|
|
1119
|
-
let e = t;
|
|
1120
|
-
for (; e < i.length && i[e] !== "\\n"; )
|
|
1121
|
-
e++;
|
|
1122
|
-
return e;
|
|
1123
|
-
}, N = (i, t) => {
|
|
1124
|
-
const e = i.indexOf("*/", t);
|
|
1125
|
-
return e === -1 ? i.length : e + 2;
|
|
1126
|
-
}, Gt = (i, t) => {
|
|
1127
|
-
const e = i.indexOf("-->", t);
|
|
1128
|
-
return e === -1 ? i.length : e + 3;
|
|
1129
|
-
}, et = (i, t) => {
|
|
1130
|
-
let e = 1, n = t;
|
|
1131
|
-
for (; n < i.length; ) {
|
|
1132
|
-
const r = i[n];
|
|
1133
|
-
if (r === "\\") {
|
|
1134
|
-
n += 2;
|
|
1135
|
-
continue;
|
|
1136
|
-
}
|
|
1137
|
-
if (r === "'" || r === '"') {
|
|
1138
|
-
n = _(i, n, r);
|
|
1139
|
-
continue;
|
|
1140
|
-
}
|
|
1141
|
-
if (r === "`") {
|
|
1142
|
-
n = R(i, n);
|
|
1143
|
-
continue;
|
|
1144
|
-
}
|
|
1145
|
-
if (r === "/" && i[n + 1] === "*") {
|
|
1146
|
-
n = N(i, n + 2);
|
|
1147
|
-
continue;
|
|
1148
|
-
}
|
|
1149
|
-
if (r === "/" && i[n + 1] === "/") {
|
|
1150
|
-
n = k(i, n + 2);
|
|
1151
|
-
continue;
|
|
1152
|
-
}
|
|
1153
|
-
if (r === "{") {
|
|
1154
|
-
e++, n++;
|
|
1155
|
-
continue;
|
|
1156
|
-
}
|
|
1157
|
-
if (r === "}") {
|
|
1158
|
-
if (e--, n++, e === 0)
|
|
1159
|
-
return n;
|
|
1160
|
-
continue;
|
|
1161
|
-
}
|
|
1162
|
-
n++;
|
|
1163
|
-
}
|
|
1164
|
-
return i.length;
|
|
1165
|
-
}, U = (i, t, e) => {
|
|
1166
|
-
let n = t;
|
|
1167
|
-
for (; n < i.length; ) {
|
|
1168
|
-
const r = i[n];
|
|
1169
|
-
if (r === "'" || r === '"') {
|
|
1170
|
-
n = _(i, n, r);
|
|
1171
|
-
continue;
|
|
1172
|
-
}
|
|
1173
|
-
if (r === "`") {
|
|
1174
|
-
n = R(i, n);
|
|
1175
|
-
continue;
|
|
1176
|
-
}
|
|
1177
|
-
if (r === "{") {
|
|
1178
|
-
n = et(i, n + 1);
|
|
1179
|
-
continue;
|
|
1180
|
-
}
|
|
1181
|
-
if (r === "/" && i[n + 1] === "*") {
|
|
1182
|
-
n = N(i, n + 2);
|
|
1183
|
-
continue;
|
|
1184
|
-
}
|
|
1185
|
-
if (r === "/" && i[n + 1] === "/") {
|
|
1186
|
-
n = k(i, n + 2);
|
|
1187
|
-
continue;
|
|
1188
|
-
}
|
|
1189
|
-
if (r === ">") {
|
|
1190
|
-
const s = !e && i[n - 1] === "/";
|
|
1191
|
-
return { position: n + 1, selfClosing: s };
|
|
1192
|
-
}
|
|
1193
|
-
n++;
|
|
1194
|
-
}
|
|
1195
|
-
return null;
|
|
1196
|
-
}, Mt = (i, t) => {
|
|
1197
|
-
const e = i.length;
|
|
1198
|
-
let n = t, r = 0;
|
|
1199
|
-
for (; n < e; ) {
|
|
1200
|
-
const s = i[n];
|
|
1201
|
-
if (s === "'" || s === '"') {
|
|
1202
|
-
n = _(i, n, s);
|
|
1203
|
-
continue;
|
|
1204
|
-
}
|
|
1205
|
-
if (s === "`") {
|
|
1206
|
-
n = R(i, n);
|
|
1207
|
-
continue;
|
|
1208
|
-
}
|
|
1209
|
-
if (s === "/" && i[n + 1] === "*") {
|
|
1210
|
-
n = N(i, n + 2);
|
|
1211
|
-
continue;
|
|
1212
|
-
}
|
|
1213
|
-
if (s === "/" && i[n + 1] === "/") {
|
|
1214
|
-
n = k(i, n + 2);
|
|
1215
|
-
continue;
|
|
1216
|
-
}
|
|
1217
|
-
if (s === "<") {
|
|
1218
|
-
if (i.startsWith("<!--", n)) {
|
|
1219
|
-
n = Gt(i, n + 4);
|
|
1220
|
-
continue;
|
|
1221
|
-
}
|
|
1222
|
-
if (i[n + 1] === "/") {
|
|
1223
|
-
r--;
|
|
1224
|
-
const o = U(i, n + 2, !0);
|
|
1225
|
-
if (!o)
|
|
1226
|
-
return null;
|
|
1227
|
-
if (n = o.position, r === 0)
|
|
1228
|
-
return {
|
|
1229
|
-
start: t,
|
|
1230
|
-
end: n,
|
|
1231
|
-
snippet: i.slice(t, n)
|
|
1232
|
-
};
|
|
1233
|
-
continue;
|
|
1234
|
-
} else {
|
|
1235
|
-
r++;
|
|
1236
|
-
const o = U(i, n + 1, !1);
|
|
1237
|
-
if (!o)
|
|
1238
|
-
return null;
|
|
1239
|
-
if (n = o.position, o.selfClosing && (r--, r === 0))
|
|
1240
|
-
return {
|
|
1241
|
-
start: t,
|
|
1242
|
-
end: n,
|
|
1243
|
-
snippet: i.slice(t, n)
|
|
1244
|
-
};
|
|
1245
|
-
continue;
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
n++;
|
|
1249
|
-
}
|
|
1250
|
-
return null;
|
|
1251
|
-
}, Xt = (i) => {
|
|
1252
|
-
const t = [], e = i.length;
|
|
1253
|
-
let n = 0;
|
|
1254
|
-
for (; n < e; ) {
|
|
1255
|
-
const r = i[n];
|
|
1256
|
-
if (r === "'" || r === '"') {
|
|
1257
|
-
n = _(i, n, r);
|
|
1258
|
-
continue;
|
|
1259
|
-
}
|
|
1260
|
-
if (r === "`") {
|
|
1261
|
-
n = R(i, n);
|
|
1262
|
-
continue;
|
|
1263
|
-
}
|
|
1264
|
-
if (r === "/" && i[n + 1] === "*") {
|
|
1265
|
-
n = N(i, n + 2);
|
|
1266
|
-
continue;
|
|
1267
|
-
}
|
|
1268
|
-
if (r === "/" && i[n + 1] === "/") {
|
|
1269
|
-
n = k(i, n + 2);
|
|
1270
|
-
continue;
|
|
1271
|
-
}
|
|
1272
|
-
if (r === "<" && $t(i, n)) {
|
|
1273
|
-
const s = Mt(i, n);
|
|
1274
|
-
if (s) {
|
|
1275
|
-
t.push(s), n = s.end;
|
|
1276
|
-
continue;
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
n++;
|
|
1280
|
-
}
|
|
1281
|
-
return t;
|
|
1282
|
-
};
|
|
1283
|
-
function nt(i, t) {
|
|
1284
|
-
if (!i.includes("<"))
|
|
1285
|
-
return i;
|
|
1286
|
-
const e = Xt(i);
|
|
1266
|
+
function y(n) {
|
|
1267
|
+
return `'${n.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029")}'`;
|
|
1268
|
+
}
|
|
1269
|
+
function q(n) {
|
|
1270
|
+
return /^[A-Za-z_$][\w$]*$/.test(n) ? n : `(${n})`;
|
|
1271
|
+
}
|
|
1272
|
+
function v(n, t) {
|
|
1273
|
+
if (!n.includes("<"))
|
|
1274
|
+
return n;
|
|
1275
|
+
const e = B(n);
|
|
1287
1276
|
if (e.length === 0)
|
|
1288
|
-
return
|
|
1289
|
-
let
|
|
1277
|
+
return n;
|
|
1278
|
+
let i = "", r = 0, s = !1;
|
|
1290
1279
|
for (const o of e) {
|
|
1291
|
-
let
|
|
1280
|
+
let h = null;
|
|
1292
1281
|
try {
|
|
1293
|
-
|
|
1282
|
+
h = Pt(o.snippet, t);
|
|
1294
1283
|
} catch {
|
|
1295
|
-
|
|
1284
|
+
h = null;
|
|
1296
1285
|
}
|
|
1297
|
-
if (!
|
|
1298
|
-
|
|
1286
|
+
if (!h) {
|
|
1287
|
+
i += n.slice(r, o.end), r = o.end;
|
|
1299
1288
|
continue;
|
|
1300
1289
|
}
|
|
1301
|
-
|
|
1290
|
+
i += n.slice(r, o.start) + h, r = o.end, s = !0;
|
|
1302
1291
|
}
|
|
1303
|
-
return
|
|
1292
|
+
return i += n.slice(r), s ? i : n;
|
|
1304
1293
|
}
|
|
1305
|
-
function
|
|
1306
|
-
const e =
|
|
1307
|
-
return
|
|
1294
|
+
function Pt(n, t) {
|
|
1295
|
+
const e = K(n), i = Q(e, !0), r = H(i);
|
|
1296
|
+
return Y(r, t);
|
|
1308
1297
|
}
|
|
1309
|
-
function
|
|
1298
|
+
function $t(n, t) {
|
|
1310
1299
|
try {
|
|
1311
|
-
const e =
|
|
1300
|
+
const e = K(n), i = Q(e, !0), r = H(i, t == null ? void 0 : t.transform);
|
|
1312
1301
|
return {
|
|
1313
|
-
code:
|
|
1302
|
+
code: Y(r, t == null ? void 0 : t.generate),
|
|
1314
1303
|
ast: r,
|
|
1315
1304
|
errors: []
|
|
1316
1305
|
};
|
|
1317
1306
|
} catch (e) {
|
|
1318
|
-
const
|
|
1307
|
+
const i = e;
|
|
1319
1308
|
return {
|
|
1320
1309
|
code: "",
|
|
1321
1310
|
ast: null,
|
|
1322
1311
|
errors: [
|
|
1323
1312
|
{
|
|
1324
1313
|
message: e instanceof Error ? e.message : String(e),
|
|
1325
|
-
line:
|
|
1326
|
-
column:
|
|
1314
|
+
line: i.line ?? 0,
|
|
1315
|
+
column: i.column ?? 0
|
|
1327
1316
|
}
|
|
1328
1317
|
]
|
|
1329
1318
|
};
|
|
1330
1319
|
}
|
|
1331
1320
|
}
|
|
1332
|
-
var
|
|
1333
|
-
for (let
|
|
1334
|
-
const t =
|
|
1335
|
-
|
|
1321
|
+
var Gt = 44, Mt = 59, G = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", tt = new Uint8Array(64), Xt = new Uint8Array(128);
|
|
1322
|
+
for (let n = 0; n < G.length; n++) {
|
|
1323
|
+
const t = G.charCodeAt(n);
|
|
1324
|
+
tt[n] = t, Xt[t] = n;
|
|
1336
1325
|
}
|
|
1337
|
-
function
|
|
1338
|
-
let
|
|
1339
|
-
|
|
1326
|
+
function m(n, t, e) {
|
|
1327
|
+
let i = t - e;
|
|
1328
|
+
i = i < 0 ? -i << 1 | 1 : i << 1;
|
|
1340
1329
|
do {
|
|
1341
|
-
let r =
|
|
1342
|
-
|
|
1343
|
-
} while (
|
|
1330
|
+
let r = i & 31;
|
|
1331
|
+
i >>>= 5, i > 0 && (r |= 32), n.write(tt[r]);
|
|
1332
|
+
} while (i > 0);
|
|
1344
1333
|
return t;
|
|
1345
1334
|
}
|
|
1346
|
-
var
|
|
1347
|
-
decode(
|
|
1348
|
-
return Buffer.from(
|
|
1335
|
+
var M = 1024 * 16, X = typeof TextDecoder < "u" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer < "u" ? {
|
|
1336
|
+
decode(n) {
|
|
1337
|
+
return Buffer.from(n.buffer, n.byteOffset, n.byteLength).toString();
|
|
1349
1338
|
}
|
|
1350
1339
|
} : {
|
|
1351
|
-
decode(
|
|
1340
|
+
decode(n) {
|
|
1352
1341
|
let t = "";
|
|
1353
|
-
for (let e = 0; e <
|
|
1354
|
-
t += String.fromCharCode(
|
|
1342
|
+
for (let e = 0; e < n.length; e++)
|
|
1343
|
+
t += String.fromCharCode(n[e]);
|
|
1355
1344
|
return t;
|
|
1356
1345
|
}
|
|
1357
|
-
},
|
|
1346
|
+
}, Wt = class {
|
|
1358
1347
|
constructor() {
|
|
1359
|
-
this.pos = 0, this.out = "", this.buffer = new Uint8Array(
|
|
1348
|
+
this.pos = 0, this.out = "", this.buffer = new Uint8Array(M);
|
|
1360
1349
|
}
|
|
1361
|
-
write(
|
|
1350
|
+
write(n) {
|
|
1362
1351
|
const { buffer: t } = this;
|
|
1363
|
-
t[this.pos++] =
|
|
1352
|
+
t[this.pos++] = n, this.pos === M && (this.out += X.decode(t), this.pos = 0);
|
|
1364
1353
|
}
|
|
1365
1354
|
flush() {
|
|
1366
|
-
const { buffer:
|
|
1367
|
-
return e > 0 ? t +
|
|
1355
|
+
const { buffer: n, out: t, pos: e } = this;
|
|
1356
|
+
return e > 0 ? t + X.decode(n.subarray(0, e)) : t;
|
|
1368
1357
|
}
|
|
1369
1358
|
};
|
|
1370
|
-
function
|
|
1371
|
-
const t = new
|
|
1372
|
-
let e = 0,
|
|
1373
|
-
for (let o = 0; o <
|
|
1374
|
-
const
|
|
1375
|
-
if (o > 0 && t.write(
|
|
1376
|
-
let
|
|
1377
|
-
for (let
|
|
1378
|
-
const u =
|
|
1379
|
-
|
|
1359
|
+
function Ut(n) {
|
|
1360
|
+
const t = new Wt();
|
|
1361
|
+
let e = 0, i = 0, r = 0, s = 0;
|
|
1362
|
+
for (let o = 0; o < n.length; o++) {
|
|
1363
|
+
const h = n[o];
|
|
1364
|
+
if (o > 0 && t.write(Mt), h.length === 0) continue;
|
|
1365
|
+
let l = 0;
|
|
1366
|
+
for (let c = 0; c < h.length; c++) {
|
|
1367
|
+
const u = h[c];
|
|
1368
|
+
c > 0 && t.write(Gt), l = m(t, u[0], l), u.length !== 1 && (e = m(t, u[1], e), i = m(t, u[2], i), r = m(t, u[3], r), u.length !== 4 && (s = m(t, u[4], s)));
|
|
1380
1369
|
}
|
|
1381
1370
|
}
|
|
1382
1371
|
return t.flush();
|
|
1383
1372
|
}
|
|
1384
|
-
class
|
|
1373
|
+
class _ {
|
|
1385
1374
|
constructor(t) {
|
|
1386
|
-
this.bits = t instanceof
|
|
1375
|
+
this.bits = t instanceof _ ? t.bits.slice() : [];
|
|
1387
1376
|
}
|
|
1388
1377
|
add(t) {
|
|
1389
1378
|
this.bits[t >> 5] |= 1 << (t & 31);
|
|
@@ -1392,9 +1381,9 @@ class S {
|
|
|
1392
1381
|
return !!(this.bits[t >> 5] & 1 << (t & 31));
|
|
1393
1382
|
}
|
|
1394
1383
|
}
|
|
1395
|
-
class
|
|
1396
|
-
constructor(t, e,
|
|
1397
|
-
this.start = t, this.end = e, this.original =
|
|
1384
|
+
class S {
|
|
1385
|
+
constructor(t, e, i) {
|
|
1386
|
+
this.start = t, this.end = e, this.original = i, this.intro = "", this.outro = "", this.content = i, this.storeName = !1, this.edited = !1, this.previous = null, this.next = null;
|
|
1398
1387
|
}
|
|
1399
1388
|
appendLeft(t) {
|
|
1400
1389
|
this.outro += t;
|
|
@@ -1403,7 +1392,7 @@ class I {
|
|
|
1403
1392
|
this.intro = this.intro + t;
|
|
1404
1393
|
}
|
|
1405
1394
|
clone() {
|
|
1406
|
-
const t = new
|
|
1395
|
+
const t = new S(this.start, this.end, this.original);
|
|
1407
1396
|
return t.intro = this.intro, t.outro = this.outro, t.content = this.content, t.storeName = this.storeName, t.edited = this.edited, t;
|
|
1408
1397
|
}
|
|
1409
1398
|
contains(t) {
|
|
@@ -1419,8 +1408,8 @@ class I {
|
|
|
1419
1408
|
for (; e; )
|
|
1420
1409
|
t(e), e = e.previous;
|
|
1421
1410
|
}
|
|
1422
|
-
edit(t, e,
|
|
1423
|
-
return this.content = t,
|
|
1411
|
+
edit(t, e, i) {
|
|
1412
|
+
return this.content = t, i || (this.intro = "", this.outro = ""), this.storeName = e, this.edited = !0, this;
|
|
1424
1413
|
}
|
|
1425
1414
|
prependLeft(t) {
|
|
1426
1415
|
this.outro = t + this.outro;
|
|
@@ -1432,10 +1421,10 @@ class I {
|
|
|
1432
1421
|
this.intro = "", this.outro = "", this.edited && (this.content = this.original, this.storeName = !1, this.edited = !1);
|
|
1433
1422
|
}
|
|
1434
1423
|
split(t) {
|
|
1435
|
-
const e = t - this.start,
|
|
1436
|
-
this.original =
|
|
1437
|
-
const s = new
|
|
1438
|
-
return s.outro = this.outro, this.outro = "", this.end = t, this.edited ? (s.edit("", !1), this.content = "") : this.content =
|
|
1424
|
+
const e = t - this.start, i = this.original.slice(0, e), r = this.original.slice(e);
|
|
1425
|
+
this.original = i;
|
|
1426
|
+
const s = new S(t, this.end, r);
|
|
1427
|
+
return s.outro = this.outro, this.outro = "", this.end = t, this.edited ? (s.edit("", !1), this.content = "") : this.content = i, s.next = this.next, s.next && (s.next.previous = s), s.previous = this, this.next = s, s;
|
|
1439
1428
|
}
|
|
1440
1429
|
toString() {
|
|
1441
1430
|
return this.intro + this.content + this.outro;
|
|
@@ -1452,104 +1441,104 @@ class I {
|
|
|
1452
1441
|
const e = this.content.replace(t, "");
|
|
1453
1442
|
if (e.length) {
|
|
1454
1443
|
if (e !== this.content) {
|
|
1455
|
-
const
|
|
1456
|
-
this.edited &&
|
|
1444
|
+
const i = this.split(this.end - e.length);
|
|
1445
|
+
this.edited && i.edit(e, this.storeName, !0), this.edit("", void 0, !0);
|
|
1457
1446
|
}
|
|
1458
1447
|
return !0;
|
|
1459
1448
|
} else if (this.edit("", void 0, !0), this.outro = this.outro.replace(t, ""), this.outro.length) return !0;
|
|
1460
1449
|
}
|
|
1461
1450
|
}
|
|
1462
|
-
function
|
|
1463
|
-
return typeof globalThis < "u" && typeof globalThis.btoa == "function" ? (
|
|
1451
|
+
function Vt() {
|
|
1452
|
+
return typeof globalThis < "u" && typeof globalThis.btoa == "function" ? (n) => globalThis.btoa(unescape(encodeURIComponent(n))) : typeof Buffer == "function" ? (n) => Buffer.from(n, "utf-8").toString("base64") : () => {
|
|
1464
1453
|
throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
|
|
1465
1454
|
};
|
|
1466
1455
|
}
|
|
1467
|
-
const
|
|
1468
|
-
class
|
|
1456
|
+
const jt = /* @__PURE__ */ Vt();
|
|
1457
|
+
class zt {
|
|
1469
1458
|
constructor(t) {
|
|
1470
|
-
this.version = 3, this.file = t.file, this.sources = t.sources, this.sourcesContent = t.sourcesContent, this.names = t.names, this.mappings =
|
|
1459
|
+
this.version = 3, this.file = t.file, this.sources = t.sources, this.sourcesContent = t.sourcesContent, this.names = t.names, this.mappings = Ut(t.mappings), typeof t.x_google_ignoreList < "u" && (this.x_google_ignoreList = t.x_google_ignoreList), typeof t.debugId < "u" && (this.debugId = t.debugId);
|
|
1471
1460
|
}
|
|
1472
1461
|
toString() {
|
|
1473
1462
|
return JSON.stringify(this);
|
|
1474
1463
|
}
|
|
1475
1464
|
toUrl() {
|
|
1476
|
-
return "data:application/json;charset=utf-8;base64," +
|
|
1465
|
+
return "data:application/json;charset=utf-8;base64," + jt(this.toString());
|
|
1477
1466
|
}
|
|
1478
1467
|
}
|
|
1479
|
-
function
|
|
1480
|
-
const t =
|
|
1481
|
-
`), e = t.filter((s) => /^\t+/.test(s)),
|
|
1482
|
-
if (e.length === 0 &&
|
|
1468
|
+
function Bt(n) {
|
|
1469
|
+
const t = n.split(`
|
|
1470
|
+
`), e = t.filter((s) => /^\t+/.test(s)), i = t.filter((s) => /^ {2,}/.test(s));
|
|
1471
|
+
if (e.length === 0 && i.length === 0)
|
|
1483
1472
|
return null;
|
|
1484
|
-
if (e.length >=
|
|
1473
|
+
if (e.length >= i.length)
|
|
1485
1474
|
return " ";
|
|
1486
|
-
const r =
|
|
1487
|
-
const
|
|
1488
|
-
return Math.min(
|
|
1475
|
+
const r = i.reduce((s, o) => {
|
|
1476
|
+
const h = /^ +/.exec(o)[0].length;
|
|
1477
|
+
return Math.min(h, s);
|
|
1489
1478
|
}, 1 / 0);
|
|
1490
1479
|
return new Array(r + 1).join(" ");
|
|
1491
1480
|
}
|
|
1492
|
-
function
|
|
1493
|
-
const e =
|
|
1494
|
-
for (e.pop(); e[0] ===
|
|
1495
|
-
e.shift(),
|
|
1481
|
+
function Kt(n, t) {
|
|
1482
|
+
const e = n.split(/[/\\]/), i = t.split(/[/\\]/);
|
|
1483
|
+
for (e.pop(); e[0] === i[0]; )
|
|
1484
|
+
e.shift(), i.shift();
|
|
1496
1485
|
if (e.length) {
|
|
1497
1486
|
let r = e.length;
|
|
1498
1487
|
for (; r--; ) e[r] = "..";
|
|
1499
1488
|
}
|
|
1500
|
-
return e.concat(
|
|
1489
|
+
return e.concat(i).join("/");
|
|
1501
1490
|
}
|
|
1502
|
-
const
|
|
1503
|
-
function
|
|
1504
|
-
return
|
|
1491
|
+
const Zt = Object.prototype.toString;
|
|
1492
|
+
function Qt(n) {
|
|
1493
|
+
return Zt.call(n) === "[object Object]";
|
|
1505
1494
|
}
|
|
1506
|
-
function
|
|
1507
|
-
const t =
|
|
1495
|
+
function W(n) {
|
|
1496
|
+
const t = n.split(`
|
|
1508
1497
|
`), e = [];
|
|
1509
|
-
for (let
|
|
1510
|
-
e.push(r), r += t[
|
|
1498
|
+
for (let i = 0, r = 0; i < t.length; i++)
|
|
1499
|
+
e.push(r), r += t[i].length + 1;
|
|
1511
1500
|
return function(r) {
|
|
1512
1501
|
let s = 0, o = e.length;
|
|
1513
1502
|
for (; s < o; ) {
|
|
1514
|
-
const
|
|
1515
|
-
r < e[
|
|
1503
|
+
const c = s + o >> 1;
|
|
1504
|
+
r < e[c] ? o = c : s = c + 1;
|
|
1516
1505
|
}
|
|
1517
|
-
const
|
|
1518
|
-
return { line:
|
|
1506
|
+
const h = s - 1, l = r - e[h];
|
|
1507
|
+
return { line: h, column: l };
|
|
1519
1508
|
};
|
|
1520
1509
|
}
|
|
1521
|
-
const
|
|
1522
|
-
class
|
|
1510
|
+
const Ht = /\w/;
|
|
1511
|
+
class Yt {
|
|
1523
1512
|
constructor(t) {
|
|
1524
1513
|
this.hires = t, this.generatedCodeLine = 0, this.generatedCodeColumn = 0, this.raw = [], this.rawSegments = this.raw[this.generatedCodeLine] = [], this.pending = null;
|
|
1525
1514
|
}
|
|
1526
|
-
addEdit(t, e,
|
|
1515
|
+
addEdit(t, e, i, r) {
|
|
1527
1516
|
if (e.length) {
|
|
1528
1517
|
const s = e.length - 1;
|
|
1529
1518
|
let o = e.indexOf(`
|
|
1530
|
-
`, 0),
|
|
1519
|
+
`, 0), h = -1;
|
|
1531
1520
|
for (; o >= 0 && s > o; ) {
|
|
1532
|
-
const
|
|
1533
|
-
r >= 0 &&
|
|
1521
|
+
const c = [this.generatedCodeColumn, t, i.line, i.column];
|
|
1522
|
+
r >= 0 && c.push(r), this.rawSegments.push(c), this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, h = o, o = e.indexOf(`
|
|
1534
1523
|
`, o + 1);
|
|
1535
1524
|
}
|
|
1536
|
-
const
|
|
1537
|
-
r >= 0 &&
|
|
1525
|
+
const l = [this.generatedCodeColumn, t, i.line, i.column];
|
|
1526
|
+
r >= 0 && l.push(r), this.rawSegments.push(l), this.advance(e.slice(h + 1));
|
|
1538
1527
|
} else this.pending && (this.rawSegments.push(this.pending), this.advance(e));
|
|
1539
1528
|
this.pending = null;
|
|
1540
1529
|
}
|
|
1541
|
-
addUneditedChunk(t, e,
|
|
1542
|
-
let o = e.start,
|
|
1530
|
+
addUneditedChunk(t, e, i, r, s) {
|
|
1531
|
+
let o = e.start, h = !0, l = !1;
|
|
1543
1532
|
for (; o < e.end; ) {
|
|
1544
|
-
if (
|
|
1533
|
+
if (i[o] === `
|
|
1545
1534
|
`)
|
|
1546
|
-
r.line += 1, r.column = 0, this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0,
|
|
1535
|
+
r.line += 1, r.column = 0, this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, h = !0, l = !1;
|
|
1547
1536
|
else {
|
|
1548
|
-
if (this.hires ||
|
|
1549
|
-
const
|
|
1550
|
-
this.hires === "boundary" ?
|
|
1537
|
+
if (this.hires || h || s.has(o)) {
|
|
1538
|
+
const c = [this.generatedCodeColumn, t, r.line, r.column];
|
|
1539
|
+
this.hires === "boundary" ? Ht.test(i[o]) ? l || (this.rawSegments.push(c), l = !0) : (this.rawSegments.push(c), l = !1) : this.rawSegments.push(c);
|
|
1551
1540
|
}
|
|
1552
|
-
r.column += 1, this.generatedCodeColumn += 1,
|
|
1541
|
+
r.column += 1, this.generatedCodeColumn += 1, h = !1;
|
|
1553
1542
|
}
|
|
1554
1543
|
o += 1;
|
|
1555
1544
|
}
|
|
@@ -1560,7 +1549,7 @@ class ne {
|
|
|
1560
1549
|
const e = t.split(`
|
|
1561
1550
|
`);
|
|
1562
1551
|
if (e.length > 1) {
|
|
1563
|
-
for (let
|
|
1552
|
+
for (let i = 0; i < e.length - 1; i++)
|
|
1564
1553
|
this.generatedCodeLine++, this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
1565
1554
|
this.generatedCodeColumn = 0;
|
|
1566
1555
|
}
|
|
@@ -1568,31 +1557,31 @@ class ne {
|
|
|
1568
1557
|
}
|
|
1569
1558
|
}
|
|
1570
1559
|
const w = `
|
|
1571
|
-
`,
|
|
1560
|
+
`, g = {
|
|
1572
1561
|
insertLeft: !1,
|
|
1573
1562
|
insertRight: !1,
|
|
1574
1563
|
storeName: !1
|
|
1575
1564
|
};
|
|
1576
|
-
class
|
|
1565
|
+
class L {
|
|
1577
1566
|
constructor(t, e = {}) {
|
|
1578
|
-
const
|
|
1567
|
+
const i = new S(0, t.length, t);
|
|
1579
1568
|
Object.defineProperties(this, {
|
|
1580
1569
|
original: { writable: !0, value: t },
|
|
1581
1570
|
outro: { writable: !0, value: "" },
|
|
1582
1571
|
intro: { writable: !0, value: "" },
|
|
1583
|
-
firstChunk: { writable: !0, value:
|
|
1584
|
-
lastChunk: { writable: !0, value:
|
|
1585
|
-
lastSearchedChunk: { writable: !0, value:
|
|
1572
|
+
firstChunk: { writable: !0, value: i },
|
|
1573
|
+
lastChunk: { writable: !0, value: i },
|
|
1574
|
+
lastSearchedChunk: { writable: !0, value: i },
|
|
1586
1575
|
byStart: { writable: !0, value: {} },
|
|
1587
1576
|
byEnd: { writable: !0, value: {} },
|
|
1588
1577
|
filename: { writable: !0, value: e.filename },
|
|
1589
1578
|
indentExclusionRanges: { writable: !0, value: e.indentExclusionRanges },
|
|
1590
|
-
sourcemapLocations: { writable: !0, value: new
|
|
1579
|
+
sourcemapLocations: { writable: !0, value: new _() },
|
|
1591
1580
|
storedNames: { writable: !0, value: {} },
|
|
1592
1581
|
indentStr: { writable: !0, value: void 0 },
|
|
1593
1582
|
ignoreList: { writable: !0, value: e.ignoreList },
|
|
1594
1583
|
offset: { writable: !0, value: e.offset || 0 }
|
|
1595
|
-
}), this.byStart[0] =
|
|
1584
|
+
}), this.byStart[0] = i, this.byEnd[t.length] = i;
|
|
1596
1585
|
}
|
|
1597
1586
|
addSourcemapLocation(t) {
|
|
1598
1587
|
this.sourcemapLocations.add(t);
|
|
@@ -1604,52 +1593,52 @@ class P {
|
|
|
1604
1593
|
appendLeft(t, e) {
|
|
1605
1594
|
if (t = t + this.offset, typeof e != "string") throw new TypeError("inserted content must be a string");
|
|
1606
1595
|
this._split(t);
|
|
1607
|
-
const
|
|
1608
|
-
return
|
|
1596
|
+
const i = this.byEnd[t];
|
|
1597
|
+
return i ? i.appendLeft(e) : this.intro += e, this;
|
|
1609
1598
|
}
|
|
1610
1599
|
appendRight(t, e) {
|
|
1611
1600
|
if (t = t + this.offset, typeof e != "string") throw new TypeError("inserted content must be a string");
|
|
1612
1601
|
this._split(t);
|
|
1613
|
-
const
|
|
1614
|
-
return
|
|
1602
|
+
const i = this.byStart[t];
|
|
1603
|
+
return i ? i.appendRight(e) : this.outro += e, this;
|
|
1615
1604
|
}
|
|
1616
1605
|
clone() {
|
|
1617
|
-
const t = new
|
|
1618
|
-
let e = this.firstChunk,
|
|
1606
|
+
const t = new L(this.original, { filename: this.filename, offset: this.offset });
|
|
1607
|
+
let e = this.firstChunk, i = t.firstChunk = t.lastSearchedChunk = e.clone();
|
|
1619
1608
|
for (; e; ) {
|
|
1620
|
-
t.byStart[
|
|
1609
|
+
t.byStart[i.start] = i, t.byEnd[i.end] = i;
|
|
1621
1610
|
const r = e.next, s = r && r.clone();
|
|
1622
|
-
s && (
|
|
1611
|
+
s && (i.next = s, s.previous = i, i = s), e = r;
|
|
1623
1612
|
}
|
|
1624
|
-
return t.lastChunk =
|
|
1613
|
+
return t.lastChunk = i, this.indentExclusionRanges && (t.indentExclusionRanges = this.indentExclusionRanges.slice()), t.sourcemapLocations = new _(this.sourcemapLocations), t.intro = this.intro, t.outro = this.outro, t;
|
|
1625
1614
|
}
|
|
1626
1615
|
generateDecodedMap(t) {
|
|
1627
1616
|
t = t || {};
|
|
1628
|
-
const e = 0,
|
|
1617
|
+
const e = 0, i = Object.keys(this.storedNames), r = new Yt(t.hires), s = W(this.original);
|
|
1629
1618
|
return this.intro && r.advance(this.intro), this.firstChunk.eachNext((o) => {
|
|
1630
|
-
const
|
|
1619
|
+
const h = s(o.start);
|
|
1631
1620
|
o.intro.length && r.advance(o.intro), o.edited ? r.addEdit(
|
|
1632
1621
|
e,
|
|
1633
1622
|
o.content,
|
|
1634
|
-
|
|
1635
|
-
o.storeName ?
|
|
1636
|
-
) : r.addUneditedChunk(e, o, this.original,
|
|
1623
|
+
h,
|
|
1624
|
+
o.storeName ? i.indexOf(o.original) : -1
|
|
1625
|
+
) : r.addUneditedChunk(e, o, this.original, h, this.sourcemapLocations), o.outro.length && r.advance(o.outro);
|
|
1637
1626
|
}), this.outro && r.advance(this.outro), {
|
|
1638
1627
|
file: t.file ? t.file.split(/[/\\]/).pop() : void 0,
|
|
1639
1628
|
sources: [
|
|
1640
|
-
t.source ?
|
|
1629
|
+
t.source ? Kt(t.file || "", t.source) : t.file || ""
|
|
1641
1630
|
],
|
|
1642
1631
|
sourcesContent: t.includeContent ? [this.original] : void 0,
|
|
1643
|
-
names:
|
|
1632
|
+
names: i,
|
|
1644
1633
|
mappings: r.raw,
|
|
1645
1634
|
x_google_ignoreList: this.ignoreList ? [e] : void 0
|
|
1646
1635
|
};
|
|
1647
1636
|
}
|
|
1648
1637
|
generateMap(t) {
|
|
1649
|
-
return new
|
|
1638
|
+
return new zt(this.generateDecodedMap(t));
|
|
1650
1639
|
}
|
|
1651
1640
|
_ensureindentStr() {
|
|
1652
|
-
this.indentStr === void 0 && (this.indentStr =
|
|
1641
|
+
this.indentStr === void 0 && (this.indentStr = Bt(this.original));
|
|
1653
1642
|
}
|
|
1654
1643
|
_getRawIndentString() {
|
|
1655
1644
|
return this._ensureindentStr(), this.indentStr;
|
|
@@ -1658,35 +1647,35 @@ class P {
|
|
|
1658
1647
|
return this._ensureindentStr(), this.indentStr === null ? " " : this.indentStr;
|
|
1659
1648
|
}
|
|
1660
1649
|
indent(t, e) {
|
|
1661
|
-
const
|
|
1662
|
-
if (
|
|
1650
|
+
const i = /^[^\r\n]/gm;
|
|
1651
|
+
if (Qt(t) && (e = t, t = void 0), t === void 0 && (this._ensureindentStr(), t = this.indentStr || " "), t === "") return this;
|
|
1663
1652
|
e = e || {};
|
|
1664
1653
|
const r = {};
|
|
1665
1654
|
e.exclude && (typeof e.exclude[0] == "number" ? [e.exclude] : e.exclude).forEach((u) => {
|
|
1666
|
-
for (let
|
|
1667
|
-
r[
|
|
1655
|
+
for (let E = u[0]; E < u[1]; E += 1)
|
|
1656
|
+
r[E] = !0;
|
|
1668
1657
|
});
|
|
1669
1658
|
let s = e.indentStart !== !1;
|
|
1670
|
-
const o = (
|
|
1671
|
-
this.intro = this.intro.replace(
|
|
1672
|
-
let
|
|
1673
|
-
for (;
|
|
1674
|
-
const
|
|
1675
|
-
if (
|
|
1676
|
-
r[
|
|
1659
|
+
const o = (c) => s ? `${t}${c}` : (s = !0, c);
|
|
1660
|
+
this.intro = this.intro.replace(i, o);
|
|
1661
|
+
let h = 0, l = this.firstChunk;
|
|
1662
|
+
for (; l; ) {
|
|
1663
|
+
const c = l.end;
|
|
1664
|
+
if (l.edited)
|
|
1665
|
+
r[h] || (l.content = l.content.replace(i, o), l.content.length && (s = l.content[l.content.length - 1] === `
|
|
1677
1666
|
`));
|
|
1678
1667
|
else
|
|
1679
|
-
for (
|
|
1680
|
-
if (!r[
|
|
1681
|
-
const u = this.original[
|
|
1668
|
+
for (h = l.start; h < c; ) {
|
|
1669
|
+
if (!r[h]) {
|
|
1670
|
+
const u = this.original[h];
|
|
1682
1671
|
u === `
|
|
1683
|
-
` ? s = !0 : u !== "\r" && s && (s = !1,
|
|
1672
|
+
` ? s = !0 : u !== "\r" && s && (s = !1, h === l.start || (this._splitChunk(l, h), l = l.next), l.prependRight(t));
|
|
1684
1673
|
}
|
|
1685
|
-
|
|
1674
|
+
h += 1;
|
|
1686
1675
|
}
|
|
1687
|
-
|
|
1676
|
+
h = l.end, l = l.next;
|
|
1688
1677
|
}
|
|
1689
|
-
return this.outro = this.outro.replace(
|
|
1678
|
+
return this.outro = this.outro.replace(i, o), this;
|
|
1690
1679
|
}
|
|
1691
1680
|
insert() {
|
|
1692
1681
|
throw new Error(
|
|
@@ -1694,28 +1683,28 @@ class P {
|
|
|
1694
1683
|
);
|
|
1695
1684
|
}
|
|
1696
1685
|
insertLeft(t, e) {
|
|
1697
|
-
return
|
|
1686
|
+
return g.insertLeft || (console.warn(
|
|
1698
1687
|
"magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
|
|
1699
|
-
),
|
|
1688
|
+
), g.insertLeft = !0), this.appendLeft(t, e);
|
|
1700
1689
|
}
|
|
1701
1690
|
insertRight(t, e) {
|
|
1702
|
-
return
|
|
1691
|
+
return g.insertRight || (console.warn(
|
|
1703
1692
|
"magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
|
|
1704
|
-
),
|
|
1693
|
+
), g.insertRight = !0), this.prependRight(t, e);
|
|
1705
1694
|
}
|
|
1706
|
-
move(t, e,
|
|
1707
|
-
if (t = t + this.offset, e = e + this.offset,
|
|
1708
|
-
this._split(t), this._split(e), this._split(
|
|
1709
|
-
const r = this.byStart[t], s = this.byEnd[e], o = r.previous,
|
|
1710
|
-
if (!
|
|
1711
|
-
const
|
|
1712
|
-
return o && (o.next =
|
|
1695
|
+
move(t, e, i) {
|
|
1696
|
+
if (t = t + this.offset, e = e + this.offset, i = i + this.offset, i >= t && i <= e) throw new Error("Cannot move a selection inside itself");
|
|
1697
|
+
this._split(t), this._split(e), this._split(i);
|
|
1698
|
+
const r = this.byStart[t], s = this.byEnd[e], o = r.previous, h = s.next, l = this.byStart[i];
|
|
1699
|
+
if (!l && s === this.lastChunk) return this;
|
|
1700
|
+
const c = l ? l.previous : this.lastChunk;
|
|
1701
|
+
return o && (o.next = h), h && (h.previous = o), c && (c.next = r), l && (l.previous = s), r.previous || (this.firstChunk = s.next), s.next || (this.lastChunk = r.previous, this.lastChunk.next = null), r.previous = c, s.next = l || null, c || (this.firstChunk = r), l || (this.lastChunk = s), this;
|
|
1713
1702
|
}
|
|
1714
|
-
overwrite(t, e,
|
|
1715
|
-
return r = r || {}, this.update(t, e,
|
|
1703
|
+
overwrite(t, e, i, r) {
|
|
1704
|
+
return r = r || {}, this.update(t, e, i, { ...r, overwrite: !r.contentOnly });
|
|
1716
1705
|
}
|
|
1717
|
-
update(t, e,
|
|
1718
|
-
if (t = t + this.offset, e = e + this.offset, typeof
|
|
1706
|
+
update(t, e, i, r) {
|
|
1707
|
+
if (t = t + this.offset, e = e + this.offset, typeof i != "string") throw new TypeError("replacement content must be a string");
|
|
1719
1708
|
if (this.original.length !== 0) {
|
|
1720
1709
|
for (; t < 0; ) t += this.original.length;
|
|
1721
1710
|
for (; e < 0; ) e += this.original.length;
|
|
@@ -1725,30 +1714,30 @@ class P {
|
|
|
1725
1714
|
throw new Error(
|
|
1726
1715
|
"Cannot overwrite a zero-length range – use appendLeft or prependRight instead"
|
|
1727
1716
|
);
|
|
1728
|
-
this._split(t), this._split(e), r === !0 && (
|
|
1717
|
+
this._split(t), this._split(e), r === !0 && (g.storeName || (console.warn(
|
|
1729
1718
|
"The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
|
|
1730
|
-
),
|
|
1719
|
+
), g.storeName = !0), r = { storeName: !0 });
|
|
1731
1720
|
const s = r !== void 0 ? r.storeName : !1, o = r !== void 0 ? r.overwrite : !1;
|
|
1732
1721
|
if (s) {
|
|
1733
|
-
const
|
|
1734
|
-
Object.defineProperty(this.storedNames,
|
|
1722
|
+
const c = this.original.slice(t, e);
|
|
1723
|
+
Object.defineProperty(this.storedNames, c, {
|
|
1735
1724
|
writable: !0,
|
|
1736
1725
|
value: !0,
|
|
1737
1726
|
enumerable: !0
|
|
1738
1727
|
});
|
|
1739
1728
|
}
|
|
1740
|
-
const
|
|
1741
|
-
if (
|
|
1742
|
-
let
|
|
1743
|
-
for (;
|
|
1744
|
-
if (
|
|
1729
|
+
const h = this.byStart[t], l = this.byEnd[e];
|
|
1730
|
+
if (h) {
|
|
1731
|
+
let c = h;
|
|
1732
|
+
for (; c !== l; ) {
|
|
1733
|
+
if (c.next !== this.byStart[c.end])
|
|
1745
1734
|
throw new Error("Cannot overwrite across a split point");
|
|
1746
|
-
|
|
1735
|
+
c = c.next, c.edit("", !1);
|
|
1747
1736
|
}
|
|
1748
|
-
|
|
1737
|
+
h.edit(i, s, !o);
|
|
1749
1738
|
} else {
|
|
1750
|
-
const
|
|
1751
|
-
|
|
1739
|
+
const c = new S(t, e, "").edit(i, s);
|
|
1740
|
+
l.next = c, c.previous = l;
|
|
1752
1741
|
}
|
|
1753
1742
|
return this;
|
|
1754
1743
|
}
|
|
@@ -1759,14 +1748,14 @@ class P {
|
|
|
1759
1748
|
prependLeft(t, e) {
|
|
1760
1749
|
if (t = t + this.offset, typeof e != "string") throw new TypeError("inserted content must be a string");
|
|
1761
1750
|
this._split(t);
|
|
1762
|
-
const
|
|
1763
|
-
return
|
|
1751
|
+
const i = this.byEnd[t];
|
|
1752
|
+
return i ? i.prependLeft(e) : this.intro = e + this.intro, this;
|
|
1764
1753
|
}
|
|
1765
1754
|
prependRight(t, e) {
|
|
1766
1755
|
if (t = t + this.offset, typeof e != "string") throw new TypeError("inserted content must be a string");
|
|
1767
1756
|
this._split(t);
|
|
1768
|
-
const
|
|
1769
|
-
return
|
|
1757
|
+
const i = this.byStart[t];
|
|
1758
|
+
return i ? i.prependRight(e) : this.outro = e + this.outro, this;
|
|
1770
1759
|
}
|
|
1771
1760
|
remove(t, e) {
|
|
1772
1761
|
if (t = t + this.offset, e = e + this.offset, this.original.length !== 0) {
|
|
@@ -1777,9 +1766,9 @@ class P {
|
|
|
1777
1766
|
if (t < 0 || e > this.original.length) throw new Error("Character is out of bounds");
|
|
1778
1767
|
if (t > e) throw new Error("end must be greater than start");
|
|
1779
1768
|
this._split(t), this._split(e);
|
|
1780
|
-
let
|
|
1781
|
-
for (;
|
|
1782
|
-
|
|
1769
|
+
let i = this.byStart[t];
|
|
1770
|
+
for (; i; )
|
|
1771
|
+
i.intro = "", i.outro = "", i.edit(""), i = e > i.end ? this.byStart[i.end] : null;
|
|
1783
1772
|
return this;
|
|
1784
1773
|
}
|
|
1785
1774
|
reset(t, e) {
|
|
@@ -1791,9 +1780,9 @@ class P {
|
|
|
1791
1780
|
if (t < 0 || e > this.original.length) throw new Error("Character is out of bounds");
|
|
1792
1781
|
if (t > e) throw new Error("end must be greater than start");
|
|
1793
1782
|
this._split(t), this._split(e);
|
|
1794
|
-
let
|
|
1795
|
-
for (;
|
|
1796
|
-
|
|
1783
|
+
let i = this.byStart[t];
|
|
1784
|
+
for (; i; )
|
|
1785
|
+
i.reset(), i = e > i.end ? this.byStart[i.end] : null;
|
|
1797
1786
|
return this;
|
|
1798
1787
|
}
|
|
1799
1788
|
lastChar() {
|
|
@@ -1809,21 +1798,21 @@ class P {
|
|
|
1809
1798
|
lastLine() {
|
|
1810
1799
|
let t = this.outro.lastIndexOf(w);
|
|
1811
1800
|
if (t !== -1) return this.outro.substr(t + 1);
|
|
1812
|
-
let e = this.outro,
|
|
1801
|
+
let e = this.outro, i = this.lastChunk;
|
|
1813
1802
|
do {
|
|
1814
|
-
if (
|
|
1815
|
-
if (t =
|
|
1816
|
-
e =
|
|
1803
|
+
if (i.outro.length > 0) {
|
|
1804
|
+
if (t = i.outro.lastIndexOf(w), t !== -1) return i.outro.substr(t + 1) + e;
|
|
1805
|
+
e = i.outro + e;
|
|
1817
1806
|
}
|
|
1818
|
-
if (
|
|
1819
|
-
if (t =
|
|
1820
|
-
e =
|
|
1807
|
+
if (i.content.length > 0) {
|
|
1808
|
+
if (t = i.content.lastIndexOf(w), t !== -1) return i.content.substr(t + 1) + e;
|
|
1809
|
+
e = i.content + e;
|
|
1821
1810
|
}
|
|
1822
|
-
if (
|
|
1823
|
-
if (t =
|
|
1824
|
-
e =
|
|
1811
|
+
if (i.intro.length > 0) {
|
|
1812
|
+
if (t = i.intro.lastIndexOf(w), t !== -1) return i.intro.substr(t + 1) + e;
|
|
1813
|
+
e = i.intro + e;
|
|
1825
1814
|
}
|
|
1826
|
-
} while (
|
|
1815
|
+
} while (i = i.previous);
|
|
1827
1816
|
return t = this.intro.lastIndexOf(w), t !== -1 ? this.intro.substr(t + 1) + e : this.intro + e;
|
|
1828
1817
|
}
|
|
1829
1818
|
slice(t = 0, e = this.original.length - this.offset) {
|
|
@@ -1831,51 +1820,51 @@ class P {
|
|
|
1831
1820
|
for (; t < 0; ) t += this.original.length;
|
|
1832
1821
|
for (; e < 0; ) e += this.original.length;
|
|
1833
1822
|
}
|
|
1834
|
-
let
|
|
1823
|
+
let i = "", r = this.firstChunk;
|
|
1835
1824
|
for (; r && (r.start > t || r.end <= t); ) {
|
|
1836
1825
|
if (r.start < e && r.end >= e)
|
|
1837
|
-
return
|
|
1826
|
+
return i;
|
|
1838
1827
|
r = r.next;
|
|
1839
1828
|
}
|
|
1840
1829
|
if (r && r.edited && r.start !== t)
|
|
1841
1830
|
throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);
|
|
1842
1831
|
const s = r;
|
|
1843
1832
|
for (; r; ) {
|
|
1844
|
-
r.intro && (s !== r || r.start === t) && (
|
|
1833
|
+
r.intro && (s !== r || r.start === t) && (i += r.intro);
|
|
1845
1834
|
const o = r.start < e && r.end >= e;
|
|
1846
1835
|
if (o && r.edited && r.end !== e)
|
|
1847
1836
|
throw new Error(`Cannot use replaced character ${e} as slice end anchor.`);
|
|
1848
|
-
const
|
|
1849
|
-
if (
|
|
1837
|
+
const h = s === r ? t - r.start : 0, l = o ? r.content.length + e - r.end : r.content.length;
|
|
1838
|
+
if (i += r.content.slice(h, l), r.outro && (!o || r.end === e) && (i += r.outro), o)
|
|
1850
1839
|
break;
|
|
1851
1840
|
r = r.next;
|
|
1852
1841
|
}
|
|
1853
|
-
return
|
|
1842
|
+
return i;
|
|
1854
1843
|
}
|
|
1855
1844
|
// TODO deprecate this? not really very useful
|
|
1856
1845
|
snip(t, e) {
|
|
1857
|
-
const
|
|
1858
|
-
return
|
|
1846
|
+
const i = this.clone();
|
|
1847
|
+
return i.remove(0, t), i.remove(e, i.original.length), i;
|
|
1859
1848
|
}
|
|
1860
1849
|
_split(t) {
|
|
1861
1850
|
if (this.byStart[t] || this.byEnd[t]) return;
|
|
1862
|
-
let e = this.lastSearchedChunk,
|
|
1851
|
+
let e = this.lastSearchedChunk, i = e;
|
|
1863
1852
|
const r = t > e.end;
|
|
1864
1853
|
for (; e; ) {
|
|
1865
1854
|
if (e.contains(t)) return this._splitChunk(e, t);
|
|
1866
|
-
if (e = r ? this.byStart[e.end] : this.byEnd[e.start], e ===
|
|
1867
|
-
|
|
1855
|
+
if (e = r ? this.byStart[e.end] : this.byEnd[e.start], e === i) return;
|
|
1856
|
+
i = e;
|
|
1868
1857
|
}
|
|
1869
1858
|
}
|
|
1870
1859
|
_splitChunk(t, e) {
|
|
1871
1860
|
if (t.edited && t.content.length) {
|
|
1872
|
-
const r =
|
|
1861
|
+
const r = W(this.original)(e);
|
|
1873
1862
|
throw new Error(
|
|
1874
1863
|
`Cannot split a chunk that has already been edited (${r.line}:${r.column} – "${t.original}")`
|
|
1875
1864
|
);
|
|
1876
1865
|
}
|
|
1877
|
-
const
|
|
1878
|
-
return this.byEnd[e] = t, this.byStart[e] =
|
|
1866
|
+
const i = t.split(e);
|
|
1867
|
+
return this.byEnd[e] = t, this.byStart[e] = i, this.byEnd[i.end] = i, t === this.lastChunk && (this.lastChunk = i), this.lastSearchedChunk = t, !0;
|
|
1879
1868
|
}
|
|
1880
1869
|
toString() {
|
|
1881
1870
|
let t = this.intro, e = this.firstChunk;
|
|
@@ -1907,12 +1896,12 @@ class P {
|
|
|
1907
1896
|
trimEndAborted(t) {
|
|
1908
1897
|
const e = new RegExp((t || "\\s") + "+$");
|
|
1909
1898
|
if (this.outro = this.outro.replace(e, ""), this.outro.length) return !0;
|
|
1910
|
-
let
|
|
1899
|
+
let i = this.lastChunk;
|
|
1911
1900
|
do {
|
|
1912
|
-
const r =
|
|
1913
|
-
if (
|
|
1914
|
-
|
|
1915
|
-
} while (
|
|
1901
|
+
const r = i.end, s = i.trimEnd(e);
|
|
1902
|
+
if (i.end !== r && (this.lastChunk === i && (this.lastChunk = i.next), this.byEnd[i.end] = i, this.byStart[i.next.start] = i.next, this.byEnd[i.next.end] = i.next), s) return !0;
|
|
1903
|
+
i = i.previous;
|
|
1904
|
+
} while (i);
|
|
1916
1905
|
return !1;
|
|
1917
1906
|
}
|
|
1918
1907
|
trimEnd(t) {
|
|
@@ -1921,12 +1910,12 @@ class P {
|
|
|
1921
1910
|
trimStartAborted(t) {
|
|
1922
1911
|
const e = new RegExp("^" + (t || "\\s") + "+");
|
|
1923
1912
|
if (this.intro = this.intro.replace(e, ""), this.intro.length) return !0;
|
|
1924
|
-
let
|
|
1913
|
+
let i = this.firstChunk;
|
|
1925
1914
|
do {
|
|
1926
|
-
const r =
|
|
1927
|
-
if (
|
|
1928
|
-
|
|
1929
|
-
} while (
|
|
1915
|
+
const r = i.end, s = i.trimStart(e);
|
|
1916
|
+
if (i.end !== r && (i === this.lastChunk && (this.lastChunk = i.next), this.byEnd[i.end] = i, this.byStart[i.next.start] = i.next, this.byEnd[i.next.end] = i.next), s) return !0;
|
|
1917
|
+
i = i.next;
|
|
1918
|
+
} while (i);
|
|
1930
1919
|
return !1;
|
|
1931
1920
|
}
|
|
1932
1921
|
trimStart(t) {
|
|
@@ -1936,45 +1925,45 @@ class P {
|
|
|
1936
1925
|
return this.original !== this.toString();
|
|
1937
1926
|
}
|
|
1938
1927
|
_replaceRegexp(t, e) {
|
|
1939
|
-
function
|
|
1940
|
-
return typeof e == "string" ? e.replace(/\$(\$|&|\d+)/g, (
|
|
1928
|
+
function i(s, o) {
|
|
1929
|
+
return typeof e == "string" ? e.replace(/\$(\$|&|\d+)/g, (h, l) => l === "$" ? "$" : l === "&" ? s[0] : +l < s.length ? s[+l] : `$${l}`) : e(...s, s.index, o, s.groups);
|
|
1941
1930
|
}
|
|
1942
1931
|
function r(s, o) {
|
|
1943
|
-
let
|
|
1944
|
-
const
|
|
1945
|
-
for (;
|
|
1946
|
-
|
|
1947
|
-
return
|
|
1932
|
+
let h;
|
|
1933
|
+
const l = [];
|
|
1934
|
+
for (; h = s.exec(o); )
|
|
1935
|
+
l.push(h);
|
|
1936
|
+
return l;
|
|
1948
1937
|
}
|
|
1949
1938
|
if (t.global)
|
|
1950
1939
|
r(t, this.original).forEach((o) => {
|
|
1951
1940
|
if (o.index != null) {
|
|
1952
|
-
const
|
|
1953
|
-
|
|
1941
|
+
const h = i(o, this.original);
|
|
1942
|
+
h !== o[0] && this.overwrite(o.index, o.index + o[0].length, h);
|
|
1954
1943
|
}
|
|
1955
1944
|
});
|
|
1956
1945
|
else {
|
|
1957
1946
|
const s = this.original.match(t);
|
|
1958
1947
|
if (s && s.index != null) {
|
|
1959
|
-
const o =
|
|
1948
|
+
const o = i(s, this.original);
|
|
1960
1949
|
o !== s[0] && this.overwrite(s.index, s.index + s[0].length, o);
|
|
1961
1950
|
}
|
|
1962
1951
|
}
|
|
1963
1952
|
return this;
|
|
1964
1953
|
}
|
|
1965
1954
|
_replaceString(t, e) {
|
|
1966
|
-
const { original:
|
|
1967
|
-
return r !== -1 && (typeof e == "function" && (e = e(t, r,
|
|
1955
|
+
const { original: i } = this, r = i.indexOf(t);
|
|
1956
|
+
return r !== -1 && (typeof e == "function" && (e = e(t, r, i)), t !== e && this.overwrite(r, r + t.length, e)), this;
|
|
1968
1957
|
}
|
|
1969
1958
|
replace(t, e) {
|
|
1970
1959
|
return typeof t == "string" ? this._replaceString(t, e) : this._replaceRegexp(t, e);
|
|
1971
1960
|
}
|
|
1972
1961
|
_replaceAllString(t, e) {
|
|
1973
|
-
const { original:
|
|
1974
|
-
for (let s =
|
|
1975
|
-
const o =
|
|
1976
|
-
let
|
|
1977
|
-
typeof e == "function" && (
|
|
1962
|
+
const { original: i } = this, r = t.length;
|
|
1963
|
+
for (let s = i.indexOf(t); s !== -1; s = i.indexOf(t, s + r)) {
|
|
1964
|
+
const o = i.slice(s, s + r);
|
|
1965
|
+
let h = e;
|
|
1966
|
+
typeof e == "function" && (h = e(o, s, i)), o !== h && this.overwrite(s, s + r, h);
|
|
1978
1967
|
}
|
|
1979
1968
|
return this;
|
|
1980
1969
|
}
|
|
@@ -1988,315 +1977,89 @@ class P {
|
|
|
1988
1977
|
return this._replaceRegexp(t, e);
|
|
1989
1978
|
}
|
|
1990
1979
|
}
|
|
1991
|
-
const
|
|
1992
|
-
|
|
1993
|
-
C.add(i);
|
|
1994
|
-
for (let i = 65; i <= 90; i++)
|
|
1995
|
-
C.add(i);
|
|
1996
|
-
for (let i = 97; i <= 122; i++)
|
|
1997
|
-
C.add(i);
|
|
1998
|
-
C.add(95);
|
|
1999
|
-
C.add(36);
|
|
2000
|
-
const Q = (i) => C.has(i), ie = (i, t) => {
|
|
2001
|
-
if (i[t] !== "<")
|
|
2002
|
-
return !1;
|
|
2003
|
-
const e = i.charCodeAt(t + 1);
|
|
2004
|
-
if (Number.isNaN(e) || !(e === 47 || // /
|
|
2005
|
-
e === 62 || // >
|
|
2006
|
-
e === 33 || // ! (e.g. <!-- -->)
|
|
2007
|
-
Q(e)))
|
|
2008
|
-
return !1;
|
|
2009
|
-
let r = t - 1;
|
|
2010
|
-
for (; r >= 0; ) {
|
|
2011
|
-
const s = i.charCodeAt(r);
|
|
2012
|
-
if (s === 32 || s === 9 || s === 10 || s === 13) {
|
|
2013
|
-
r--;
|
|
2014
|
-
continue;
|
|
2015
|
-
}
|
|
2016
|
-
if (Q(s))
|
|
2017
|
-
return !1;
|
|
2018
|
-
break;
|
|
2019
|
-
}
|
|
2020
|
-
return !0;
|
|
2021
|
-
}, $ = (i, t, e) => {
|
|
2022
|
-
let n = t + 1;
|
|
2023
|
-
for (; n < i.length; ) {
|
|
2024
|
-
const r = i[n];
|
|
2025
|
-
if (r === "\\") {
|
|
2026
|
-
n += 2;
|
|
2027
|
-
continue;
|
|
2028
|
-
}
|
|
2029
|
-
if (r === e)
|
|
2030
|
-
return n + 1;
|
|
2031
|
-
n++;
|
|
2032
|
-
}
|
|
2033
|
-
return i.length;
|
|
2034
|
-
}, rt = (i, t) => {
|
|
2035
|
-
let e = t + 1;
|
|
2036
|
-
for (; e < i.length; ) {
|
|
2037
|
-
const n = i[e];
|
|
2038
|
-
if (n === "\\") {
|
|
2039
|
-
e += 2;
|
|
2040
|
-
continue;
|
|
2041
|
-
}
|
|
2042
|
-
if (n === "`")
|
|
2043
|
-
return e + 1;
|
|
2044
|
-
if (n === "$" && i[e + 1] === "{") {
|
|
2045
|
-
const r = G(i, e + 2);
|
|
2046
|
-
if (r == null)
|
|
2047
|
-
return i.length;
|
|
2048
|
-
e = r;
|
|
2049
|
-
continue;
|
|
2050
|
-
}
|
|
2051
|
-
e++;
|
|
2052
|
-
}
|
|
2053
|
-
return i.length;
|
|
2054
|
-
}, O = (i, t) => {
|
|
2055
|
-
let e = t;
|
|
2056
|
-
for (; e < i.length && i[e] !== `
|
|
2057
|
-
`; )
|
|
2058
|
-
e++;
|
|
2059
|
-
return e;
|
|
2060
|
-
}, b = (i, t) => {
|
|
2061
|
-
const e = i.indexOf("*/", t);
|
|
2062
|
-
return e === -1 ? i.length : e + 2;
|
|
2063
|
-
}, re = (i, t) => {
|
|
2064
|
-
const e = i.indexOf("-->", t);
|
|
2065
|
-
return e === -1 ? i.length : e + 3;
|
|
2066
|
-
}, G = (i, t) => {
|
|
2067
|
-
let e = 1, n = t;
|
|
2068
|
-
for (; n < i.length; ) {
|
|
2069
|
-
const r = i[n];
|
|
2070
|
-
if (r === "\\") {
|
|
2071
|
-
n += 2;
|
|
2072
|
-
continue;
|
|
2073
|
-
}
|
|
2074
|
-
if (r === "'" || r === '"') {
|
|
2075
|
-
n = $(i, n, r);
|
|
2076
|
-
continue;
|
|
2077
|
-
}
|
|
2078
|
-
if (r === "`") {
|
|
2079
|
-
n = rt(i, n);
|
|
2080
|
-
continue;
|
|
2081
|
-
}
|
|
2082
|
-
if (r === "/" && i[n + 1] === "*") {
|
|
2083
|
-
n = b(i, n + 2);
|
|
2084
|
-
continue;
|
|
2085
|
-
}
|
|
2086
|
-
if (r === "/" && i[n + 1] === "/") {
|
|
2087
|
-
n = O(i, n + 2);
|
|
2088
|
-
continue;
|
|
2089
|
-
}
|
|
2090
|
-
if (r === "{") {
|
|
2091
|
-
e++, n++;
|
|
2092
|
-
continue;
|
|
2093
|
-
}
|
|
2094
|
-
if (r === "}") {
|
|
2095
|
-
if (e--, n++, e === 0)
|
|
2096
|
-
return n;
|
|
2097
|
-
continue;
|
|
2098
|
-
}
|
|
2099
|
-
n++;
|
|
2100
|
-
}
|
|
2101
|
-
return null;
|
|
2102
|
-
}, K = (i, t, e) => {
|
|
2103
|
-
let n = t;
|
|
2104
|
-
for (; n < i.length; ) {
|
|
2105
|
-
const r = i[n];
|
|
2106
|
-
if (r === "'" || r === '"') {
|
|
2107
|
-
n = $(i, n, r);
|
|
2108
|
-
continue;
|
|
2109
|
-
}
|
|
2110
|
-
if (r === "{") {
|
|
2111
|
-
const s = G(i, n + 1);
|
|
2112
|
-
if (s == null)
|
|
2113
|
-
return null;
|
|
2114
|
-
n = s;
|
|
2115
|
-
continue;
|
|
2116
|
-
}
|
|
2117
|
-
if (r === "/" && i[n + 1] === "*") {
|
|
2118
|
-
n = b(i, n + 2);
|
|
2119
|
-
continue;
|
|
2120
|
-
}
|
|
2121
|
-
if (r === "/" && i[n + 1] === "/") {
|
|
2122
|
-
n = O(i, n + 2);
|
|
2123
|
-
continue;
|
|
2124
|
-
}
|
|
2125
|
-
if (r === ">") {
|
|
2126
|
-
const s = !e && i[n - 1] === "/";
|
|
2127
|
-
return { position: n + 1, selfClosing: s };
|
|
2128
|
-
}
|
|
2129
|
-
n++;
|
|
2130
|
-
}
|
|
2131
|
-
return null;
|
|
2132
|
-
}, se = (i, t) => {
|
|
2133
|
-
const e = i.length;
|
|
2134
|
-
let n = t, r = 0;
|
|
2135
|
-
for (; n < e; ) {
|
|
2136
|
-
const s = i[n];
|
|
2137
|
-
if (s === "/" && i[n + 1] === "*") {
|
|
2138
|
-
n = b(i, n + 2);
|
|
2139
|
-
continue;
|
|
2140
|
-
}
|
|
2141
|
-
if (s === "/" && i[n + 1] === "/") {
|
|
2142
|
-
n = O(i, n + 2);
|
|
2143
|
-
continue;
|
|
2144
|
-
}
|
|
2145
|
-
if (s === "{") {
|
|
2146
|
-
const o = G(i, n + 1);
|
|
2147
|
-
if (o != null) {
|
|
2148
|
-
n = o;
|
|
2149
|
-
continue;
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
2152
|
-
if (s === "<") {
|
|
2153
|
-
if (i.startsWith("<!--", n)) {
|
|
2154
|
-
n = re(i, n + 4);
|
|
2155
|
-
continue;
|
|
2156
|
-
}
|
|
2157
|
-
if (i[n + 1] === "/") {
|
|
2158
|
-
r--;
|
|
2159
|
-
const o = K(i, n + 2, !0);
|
|
2160
|
-
if (!o)
|
|
2161
|
-
return null;
|
|
2162
|
-
if (n = o.position, r === 0)
|
|
2163
|
-
return {
|
|
2164
|
-
start: t,
|
|
2165
|
-
end: n,
|
|
2166
|
-
snippet: i.slice(t, n)
|
|
2167
|
-
};
|
|
2168
|
-
continue;
|
|
2169
|
-
} else {
|
|
2170
|
-
r++;
|
|
2171
|
-
const o = K(i, n + 1, !1);
|
|
2172
|
-
if (!o)
|
|
2173
|
-
return null;
|
|
2174
|
-
if (n = o.position, o.selfClosing && (r--, r === 0))
|
|
2175
|
-
return {
|
|
2176
|
-
start: t,
|
|
2177
|
-
end: n,
|
|
2178
|
-
snippet: i.slice(t, n)
|
|
2179
|
-
};
|
|
2180
|
-
continue;
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
n++;
|
|
2184
|
-
}
|
|
2185
|
-
return null;
|
|
2186
|
-
}, oe = (i) => {
|
|
2187
|
-
const t = [], e = i.length;
|
|
2188
|
-
let n = 0;
|
|
2189
|
-
for (; n < e; ) {
|
|
2190
|
-
const r = i[n];
|
|
2191
|
-
if (r === "'" || r === '"') {
|
|
2192
|
-
n = $(i, n, r);
|
|
2193
|
-
continue;
|
|
2194
|
-
}
|
|
2195
|
-
if (r === "`") {
|
|
2196
|
-
n = rt(i, n);
|
|
2197
|
-
continue;
|
|
2198
|
-
}
|
|
2199
|
-
if (r === "/" && i[n + 1] === "*") {
|
|
2200
|
-
n = b(i, n + 2);
|
|
2201
|
-
continue;
|
|
2202
|
-
}
|
|
2203
|
-
if (r === "/" && i[n + 1] === "/") {
|
|
2204
|
-
n = O(i, n + 2);
|
|
2205
|
-
continue;
|
|
2206
|
-
}
|
|
2207
|
-
if (r === "<" && ie(i, n)) {
|
|
2208
|
-
const s = se(i, n);
|
|
2209
|
-
if (s) {
|
|
2210
|
-
t.push(s), n = s.end;
|
|
2211
|
-
continue;
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
n++;
|
|
2215
|
-
}
|
|
2216
|
-
return t;
|
|
2217
|
-
}, me = (i, t = {}) => {
|
|
2218
|
-
const e = oe(i);
|
|
1980
|
+
const le = (n, t = {}) => {
|
|
1981
|
+
const e = B(n);
|
|
2219
1982
|
if (e.length === 0)
|
|
2220
1983
|
return {
|
|
2221
|
-
code:
|
|
1984
|
+
code: n,
|
|
2222
1985
|
map: null,
|
|
2223
1986
|
transformed: !1,
|
|
2224
1987
|
errors: [],
|
|
2225
1988
|
matches: []
|
|
2226
1989
|
};
|
|
2227
|
-
const
|
|
1990
|
+
const i = new L(n), r = [];
|
|
2228
1991
|
let s = !1;
|
|
2229
|
-
for (const
|
|
2230
|
-
const
|
|
2231
|
-
if (
|
|
2232
|
-
for (const u of
|
|
2233
|
-
r.push({ match:
|
|
1992
|
+
for (const l of e) {
|
|
1993
|
+
const c = $t(l.snippet, t.compileOptions);
|
|
1994
|
+
if (c.errors.length > 0 || !c.code) {
|
|
1995
|
+
for (const u of c.errors)
|
|
1996
|
+
r.push({ match: l, error: u });
|
|
2234
1997
|
continue;
|
|
2235
1998
|
}
|
|
2236
|
-
|
|
1999
|
+
i.overwrite(l.start, l.end, c.code), s = !0;
|
|
2237
2000
|
}
|
|
2238
2001
|
if (!s)
|
|
2239
2002
|
return {
|
|
2240
|
-
code:
|
|
2003
|
+
code: n,
|
|
2241
2004
|
map: null,
|
|
2242
2005
|
transformed: !1,
|
|
2243
2006
|
errors: r,
|
|
2244
2007
|
matches: e
|
|
2245
2008
|
};
|
|
2246
|
-
const o =
|
|
2247
|
-
let
|
|
2009
|
+
const o = i.toString();
|
|
2010
|
+
let h = null;
|
|
2248
2011
|
if (t.generateSourceMap) {
|
|
2249
|
-
const
|
|
2250
|
-
|
|
2012
|
+
const l = t.source ? { source: t.source, hires: !0 } : { hires: !0 };
|
|
2013
|
+
h = i.generateMap(l);
|
|
2251
2014
|
}
|
|
2252
2015
|
return {
|
|
2253
2016
|
code: o,
|
|
2254
|
-
map:
|
|
2017
|
+
map: h,
|
|
2255
2018
|
transformed: !0,
|
|
2256
2019
|
errors: r,
|
|
2257
2020
|
matches: e
|
|
2258
2021
|
};
|
|
2259
2022
|
};
|
|
2260
2023
|
export {
|
|
2261
|
-
|
|
2024
|
+
dt as Lexer,
|
|
2262
2025
|
f as NodeType,
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2026
|
+
St as Parser,
|
|
2027
|
+
a as TokenType,
|
|
2028
|
+
$t as compile,
|
|
2029
|
+
$ as countNodes,
|
|
2030
|
+
x as createAttributeNode,
|
|
2031
|
+
mt as createCommentNode,
|
|
2032
|
+
Ct as createDirectiveElseIfNode,
|
|
2033
|
+
Tt as createDirectiveElseNode,
|
|
2034
|
+
vt as createDirectiveForNode,
|
|
2035
|
+
wt as createDirectiveIfNode,
|
|
2036
|
+
F as createElementNode,
|
|
2037
|
+
gt as createFragmentNode,
|
|
2038
|
+
Et as createInterpolationNode,
|
|
2039
|
+
ft as createPosition,
|
|
2040
|
+
pt as createRootNode,
|
|
2278
2041
|
Z as createTextNode,
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2042
|
+
d as createToken,
|
|
2043
|
+
he as formatCode,
|
|
2044
|
+
Y as generate,
|
|
2045
|
+
O as getConditionalGroup,
|
|
2046
|
+
P as getDirective,
|
|
2047
|
+
se as hasDirective,
|
|
2048
|
+
ne as isCommentNode,
|
|
2049
|
+
re as isDirective,
|
|
2050
|
+
qt as isElementNode,
|
|
2051
|
+
te as isFragmentNode,
|
|
2052
|
+
ie as isInterpolationNode,
|
|
2053
|
+
ee as isTextNode,
|
|
2054
|
+
oe as isWhitespaceOnly,
|
|
2055
|
+
_t as optimize,
|
|
2056
|
+
Q as parse,
|
|
2057
|
+
B as scanTemplates,
|
|
2058
|
+
K as tokenize,
|
|
2059
|
+
H as transform,
|
|
2060
|
+
It as transformDirectives,
|
|
2061
|
+
le as transformDocument,
|
|
2062
|
+
N as transformTree,
|
|
2063
|
+
D as walk
|
|
2301
2064
|
};
|
|
2302
2065
|
//# sourceMappingURL=index.mjs.map
|