@b4moss/hyogen-md 0.10.1 → 0.12.0
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 +6 -6
- package/README_ja.md +6 -6
- package/dist/client.js +977 -758
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1017 -632
- package/package.json +3 -2
package/dist/client.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { parse as
|
|
2
|
-
const
|
|
3
|
-
errors:
|
|
4
|
-
warnings:
|
|
5
|
-
warningReasons:
|
|
6
|
-
},
|
|
7
|
-
function
|
|
8
|
-
return t === void 0 ? "" : t.replace(/\{([^}]+)\}/g, (n,
|
|
9
|
-
if (e === void 0 || !(
|
|
1
|
+
import { parse as Pe } from "yaml";
|
|
2
|
+
const Ie = { file_not_found: "File not found: {path} (referenced from {from} via {via})", frontmatter_too_large: "Front matter exceeds size limit in {path} ({size} bytes, limit {limit})", duplicate_component_alias: 'Duplicate component alias "{alias}" in {path}', alias_collision: 'Component alias "{alias}" collides with an existing binding in {path}', forbidden_property_access: 'Forbidden property access "{property}" in {path}', parse_error: "Parse error in {path}: {message}", component_multiline_output: 'Component "{alias}" returned multiline output (single line required)', server_context_on_client: "serverContext is not allowed with renderClient", load_failed: "Failed to load {path}: {reason}", data_sources_on_client: "dataSources is not allowed with renderClient", data_source_too_large: "Data source exceeds size limit in {path} ({size} bytes, limit {limit})" }, ze = { circular_include: "Circular reference detected; skipped {path} (referenced from {from} via {via})", nest_limit_exceeded: "Nesting limit exceeded ({limit}); skipped block in {path}", extend_in_component: "extend is not allowed inside a component; skipped in {path}", prop_type_mismatch: 'Prop "{prop}" type mismatch in component "{component}"; expected {expected}, got {actual}', prop_missing: 'Required prop "{prop}" is missing for component "{component}"', prop_unknown: 'Unknown prop "{prop}" passed to component "{component}"; ignored', suspicious_context_value: 'Suspicious value in context key "{key}" ({reason})' }, Ue = { contains_html_script_tag: "contains HTML script tag", contains_event_handler: "contains inline event handler", contains_dangerous_scheme: "contains dangerous URL scheme", contains_embed_tag: "contains embeddable HTML tag", contains_meta_refresh: "contains meta refresh" }, J = {
|
|
3
|
+
errors: Ie,
|
|
4
|
+
warnings: ze,
|
|
5
|
+
warningReasons: Ue
|
|
6
|
+
}, Ze = J.errors, qe = J.warnings;
|
|
7
|
+
function ye(t, e) {
|
|
8
|
+
return t === void 0 ? "" : t.replace(/\{([^}]+)\}/g, (n, r) => {
|
|
9
|
+
if (e === void 0 || !(r in e))
|
|
10
10
|
return n;
|
|
11
|
-
const s = e[
|
|
11
|
+
const s = e[r];
|
|
12
12
|
return s == null ? "" : String(s);
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function Ve(t, e) {
|
|
16
|
+
return ye(Ze[t], e);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
18
|
+
function R(t, e) {
|
|
19
|
+
return ye(qe[t], e);
|
|
20
20
|
}
|
|
21
21
|
function u(t) {
|
|
22
|
-
const e = t.message ??
|
|
22
|
+
const e = t.message ?? Ve(t.code, t.details), n = new Error(e);
|
|
23
23
|
return n.name = "HyogenError", n.code = t.code, n.message = e, n.path = t.path, n.details = t.details, n;
|
|
24
24
|
}
|
|
25
25
|
function _(...t) {
|
|
@@ -28,19 +28,19 @@ function _(...t) {
|
|
|
28
28
|
n != null && Object.assign(e, n);
|
|
29
29
|
return e;
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class _e {
|
|
32
32
|
components = /* @__PURE__ */ new Map();
|
|
33
|
-
register(e, n,
|
|
33
|
+
register(e, n, r) {
|
|
34
34
|
if (this.components.has(e.alias))
|
|
35
35
|
throw u({
|
|
36
36
|
code: "duplicate_component_alias",
|
|
37
|
-
path:
|
|
37
|
+
path: r ?? e.definedAt,
|
|
38
38
|
details: { alias: e.alias }
|
|
39
39
|
});
|
|
40
40
|
if (n.includes(e.alias))
|
|
41
41
|
throw u({
|
|
42
42
|
code: "alias_collision",
|
|
43
|
-
path:
|
|
43
|
+
path: r ?? e.definedAt,
|
|
44
44
|
details: { alias: e.alias }
|
|
45
45
|
});
|
|
46
46
|
this.components.set(e.alias, e);
|
|
@@ -52,26 +52,26 @@ class be {
|
|
|
52
52
|
return this.components.has(e);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
function
|
|
55
|
+
const de = 64 * 1024;
|
|
56
|
+
function P(t, e) {
|
|
57
57
|
if (!t.startsWith("---"))
|
|
58
58
|
return { context: {}, body: t };
|
|
59
59
|
const n = t.indexOf(`
|
|
60
60
|
`);
|
|
61
61
|
if (n === -1)
|
|
62
62
|
return { context: {}, body: t };
|
|
63
|
-
const
|
|
63
|
+
const r = t.indexOf(`
|
|
64
64
|
---`, n);
|
|
65
|
-
if (
|
|
65
|
+
if (r === -1)
|
|
66
66
|
return { context: {}, body: t };
|
|
67
|
-
const s = t.slice(n + 1,
|
|
68
|
-
if (
|
|
67
|
+
const s = t.slice(n + 1, r), i = Buffer.byteLength(s, "utf8");
|
|
68
|
+
if (i > de)
|
|
69
69
|
throw u({
|
|
70
70
|
code: "frontmatter_too_large",
|
|
71
71
|
path: e,
|
|
72
72
|
details: {
|
|
73
|
-
size:
|
|
74
|
-
limit:
|
|
73
|
+
size: i,
|
|
74
|
+
limit: de
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
if (s.trim().length === 0)
|
|
@@ -82,7 +82,7 @@ function H(t, e) {
|
|
|
82
82
|
});
|
|
83
83
|
let o;
|
|
84
84
|
try {
|
|
85
|
-
const h =
|
|
85
|
+
const h = Pe(s);
|
|
86
86
|
if (h == null)
|
|
87
87
|
o = {};
|
|
88
88
|
else if (typeof h == "object" && !Array.isArray(h))
|
|
@@ -98,7 +98,7 @@ function H(t, e) {
|
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
const a =
|
|
101
|
+
const a = r + 4;
|
|
102
102
|
let c = t.slice(a);
|
|
103
103
|
return c.startsWith(`
|
|
104
104
|
`) ? c = c.slice(1) : c.startsWith(`\r
|
|
@@ -110,14 +110,14 @@ ${s}
|
|
|
110
110
|
---`
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
const
|
|
113
|
+
const Ke = /* @__PURE__ */ new Set([
|
|
114
114
|
"string",
|
|
115
115
|
"number",
|
|
116
116
|
"boolean",
|
|
117
117
|
"object",
|
|
118
118
|
"array"
|
|
119
119
|
]);
|
|
120
|
-
function
|
|
120
|
+
function Ye(t, e) {
|
|
121
121
|
const n = t.props;
|
|
122
122
|
if (n === void 0)
|
|
123
123
|
return {};
|
|
@@ -127,22 +127,22 @@ function qe(t, e) {
|
|
|
127
127
|
path: e,
|
|
128
128
|
details: { message: "props must be a YAML mapping" }
|
|
129
129
|
});
|
|
130
|
-
const
|
|
131
|
-
for (const [s,
|
|
132
|
-
if (typeof
|
|
133
|
-
|
|
130
|
+
const r = {};
|
|
131
|
+
for (const [s, i] of Object.entries(n)) {
|
|
132
|
+
if (typeof i != "object" || i === null || Array.isArray(i)) {
|
|
133
|
+
r[s] = {};
|
|
134
134
|
continue;
|
|
135
135
|
}
|
|
136
|
-
const o =
|
|
136
|
+
const o = i, a = {};
|
|
137
137
|
if ("type" in o && o.type !== void 0) {
|
|
138
138
|
const c = String(o.type);
|
|
139
|
-
|
|
139
|
+
Ke.has(c) ? a.type = c : a.type = void 0;
|
|
140
140
|
}
|
|
141
|
-
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default),
|
|
141
|
+
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[s] = a;
|
|
142
142
|
}
|
|
143
|
-
return
|
|
143
|
+
return r;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function Xe(t) {
|
|
146
146
|
if (t != null) {
|
|
147
147
|
if (typeof t == "string") return "string";
|
|
148
148
|
if (typeof t == "number") return "number";
|
|
@@ -151,29 +151,29 @@ function Ve(t) {
|
|
|
151
151
|
if (typeof t == "object") return "object";
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Ge(t, e) {
|
|
155
155
|
return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
|
|
156
156
|
}
|
|
157
157
|
function U(t, e) {
|
|
158
158
|
return {
|
|
159
159
|
code: t,
|
|
160
|
-
message:
|
|
160
|
+
message: R(t, e),
|
|
161
161
|
details: e
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
const
|
|
164
|
+
function Je(t, e, n) {
|
|
165
|
+
const r = [], s = {}, i = new Set(Object.keys(e));
|
|
166
166
|
for (const [o, a] of Object.entries(e)) {
|
|
167
167
|
const c = Object.prototype.hasOwnProperty.call(t, o);
|
|
168
168
|
let h = c ? t[o] : void 0;
|
|
169
|
-
if (c || (a.default !== void 0 ? h = a.default : (a.isRequired &&
|
|
169
|
+
if (c || (a.default !== void 0 ? h = a.default : (a.isRequired && r.push(
|
|
170
170
|
U("prop_missing", {
|
|
171
171
|
prop: o,
|
|
172
172
|
component: n
|
|
173
173
|
})
|
|
174
174
|
), h = void 0)), c && h !== void 0 && h !== null) {
|
|
175
|
-
const l = a.type ??
|
|
176
|
-
l && !
|
|
175
|
+
const l = a.type ?? Xe(h);
|
|
176
|
+
l && !Ge(h, l) && (r.push(
|
|
177
177
|
U("prop_type_mismatch", {
|
|
178
178
|
prop: o,
|
|
179
179
|
component: n,
|
|
@@ -185,29 +185,29 @@ function Ye(t, e, n) {
|
|
|
185
185
|
s[o] = h;
|
|
186
186
|
}
|
|
187
187
|
for (const o of Object.keys(t))
|
|
188
|
-
|
|
188
|
+
i.has(o) || (Object.keys(e).length > 0 ? r.push(
|
|
189
189
|
U("prop_unknown", {
|
|
190
190
|
prop: o,
|
|
191
191
|
component: n
|
|
192
192
|
})
|
|
193
193
|
) : s[o] = t[o]);
|
|
194
|
-
return { values: s, warnings:
|
|
194
|
+
return { values: s, warnings: r };
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function Se(t) {
|
|
197
197
|
return /^https?:\/\//i.test(t);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function Qe(t) {
|
|
200
200
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
201
201
|
}
|
|
202
|
-
var Z,
|
|
203
|
-
function
|
|
204
|
-
if (
|
|
205
|
-
|
|
202
|
+
var Z, ue;
|
|
203
|
+
function et() {
|
|
204
|
+
if (ue) return Z;
|
|
205
|
+
ue = 1;
|
|
206
206
|
function t(s) {
|
|
207
207
|
if (typeof s != "string")
|
|
208
208
|
throw new TypeError("Path must be a string. Received " + JSON.stringify(s));
|
|
209
209
|
}
|
|
210
|
-
function e(s,
|
|
210
|
+
function e(s, i) {
|
|
211
211
|
for (var o = "", a = 0, c = -1, h = 0, l, d = 0; d <= s.length; ++d) {
|
|
212
212
|
if (d < s.length)
|
|
213
213
|
l = s.charCodeAt(d);
|
|
@@ -230,7 +230,7 @@ function Je() {
|
|
|
230
230
|
continue;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
|
|
233
|
+
i && (o.length > 0 ? o += "/.." : o = "..", a = 2);
|
|
234
234
|
} else
|
|
235
235
|
o.length > 0 ? o += "/" + s.slice(c + 1, d) : o = s.slice(c + 1, d), a = d - c - 1;
|
|
236
236
|
c = d, h = 0;
|
|
@@ -238,41 +238,41 @@ function Je() {
|
|
|
238
238
|
}
|
|
239
239
|
return o;
|
|
240
240
|
}
|
|
241
|
-
function n(s,
|
|
242
|
-
var o =
|
|
243
|
-
return o ? o ===
|
|
241
|
+
function n(s, i) {
|
|
242
|
+
var o = i.dir || i.root, a = i.base || (i.name || "") + (i.ext || "");
|
|
243
|
+
return o ? o === i.root ? o + a : o + s + a : a;
|
|
244
244
|
}
|
|
245
|
-
var
|
|
245
|
+
var r = {
|
|
246
246
|
// path.resolve([from ...], to)
|
|
247
247
|
resolve: function() {
|
|
248
|
-
for (var
|
|
248
|
+
for (var i = "", o = !1, a, c = arguments.length - 1; c >= -1 && !o; c--) {
|
|
249
249
|
var h;
|
|
250
|
-
c >= 0 ? h = arguments[c] : (a === void 0 && (a = process.cwd()), h = a), t(h), h.length !== 0 && (
|
|
250
|
+
c >= 0 ? h = arguments[c] : (a === void 0 && (a = process.cwd()), h = a), t(h), h.length !== 0 && (i = h + "/" + i, o = h.charCodeAt(0) === 47);
|
|
251
251
|
}
|
|
252
|
-
return
|
|
252
|
+
return i = e(i, !o), o ? i.length > 0 ? "/" + i : "/" : i.length > 0 ? i : ".";
|
|
253
253
|
},
|
|
254
|
-
normalize: function(
|
|
255
|
-
if (t(
|
|
256
|
-
var o =
|
|
257
|
-
return
|
|
254
|
+
normalize: function(i) {
|
|
255
|
+
if (t(i), i.length === 0) return ".";
|
|
256
|
+
var o = i.charCodeAt(0) === 47, a = i.charCodeAt(i.length - 1) === 47;
|
|
257
|
+
return i = e(i, !o), i.length === 0 && !o && (i = "."), i.length > 0 && a && (i += "/"), o ? "/" + i : i;
|
|
258
258
|
},
|
|
259
|
-
isAbsolute: function(
|
|
260
|
-
return t(
|
|
259
|
+
isAbsolute: function(i) {
|
|
260
|
+
return t(i), i.length > 0 && i.charCodeAt(0) === 47;
|
|
261
261
|
},
|
|
262
262
|
join: function() {
|
|
263
263
|
if (arguments.length === 0)
|
|
264
264
|
return ".";
|
|
265
|
-
for (var
|
|
265
|
+
for (var i, o = 0; o < arguments.length; ++o) {
|
|
266
266
|
var a = arguments[o];
|
|
267
|
-
t(a), a.length > 0 && (
|
|
267
|
+
t(a), a.length > 0 && (i === void 0 ? i = a : i += "/" + a);
|
|
268
268
|
}
|
|
269
|
-
return
|
|
269
|
+
return i === void 0 ? "." : r.normalize(i);
|
|
270
270
|
},
|
|
271
|
-
relative: function(
|
|
272
|
-
if (t(
|
|
273
|
-
for (var a = 1; a <
|
|
271
|
+
relative: function(i, o) {
|
|
272
|
+
if (t(i), t(o), i === o || (i = r.resolve(i), o = r.resolve(o), i === o)) return "";
|
|
273
|
+
for (var a = 1; a < i.length && i.charCodeAt(a) === 47; ++a)
|
|
274
274
|
;
|
|
275
|
-
for (var c =
|
|
275
|
+
for (var c = i.length, h = c - a, l = 1; l < o.length && o.charCodeAt(l) === 47; ++l)
|
|
276
276
|
;
|
|
277
277
|
for (var d = o.length, f = d - l, g = h < f ? h : f, m = -1, p = 0; p <= g; ++p) {
|
|
278
278
|
if (p === g) {
|
|
@@ -281,43 +281,43 @@ function Je() {
|
|
|
281
281
|
return o.slice(l + p + 1);
|
|
282
282
|
if (p === 0)
|
|
283
283
|
return o.slice(l + p);
|
|
284
|
-
} else h > g && (
|
|
284
|
+
} else h > g && (i.charCodeAt(a + p) === 47 ? m = p : p === 0 && (m = 0));
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
|
-
var
|
|
288
|
-
if (
|
|
287
|
+
var $ = i.charCodeAt(a + p), D = o.charCodeAt(l + p);
|
|
288
|
+
if ($ !== D)
|
|
289
289
|
break;
|
|
290
|
-
|
|
290
|
+
$ === 47 && (m = p);
|
|
291
291
|
}
|
|
292
292
|
var b = "";
|
|
293
293
|
for (p = a + m + 1; p <= c; ++p)
|
|
294
|
-
(p === c ||
|
|
294
|
+
(p === c || i.charCodeAt(p) === 47) && (b.length === 0 ? b += ".." : b += "/..");
|
|
295
295
|
return b.length > 0 ? b + o.slice(l + m) : (l += m, o.charCodeAt(l) === 47 && ++l, o.slice(l));
|
|
296
296
|
},
|
|
297
|
-
_makeLong: function(
|
|
298
|
-
return
|
|
297
|
+
_makeLong: function(i) {
|
|
298
|
+
return i;
|
|
299
299
|
},
|
|
300
|
-
dirname: function(
|
|
301
|
-
if (t(
|
|
302
|
-
for (var o =
|
|
303
|
-
if (o =
|
|
300
|
+
dirname: function(i) {
|
|
301
|
+
if (t(i), i.length === 0) return ".";
|
|
302
|
+
for (var o = i.charCodeAt(0), a = o === 47, c = -1, h = !0, l = i.length - 1; l >= 1; --l)
|
|
303
|
+
if (o = i.charCodeAt(l), o === 47) {
|
|
304
304
|
if (!h) {
|
|
305
305
|
c = l;
|
|
306
306
|
break;
|
|
307
307
|
}
|
|
308
308
|
} else
|
|
309
309
|
h = !1;
|
|
310
|
-
return c === -1 ? a ? "/" : "." : a && c === 1 ? "//" :
|
|
310
|
+
return c === -1 ? a ? "/" : "." : a && c === 1 ? "//" : i.slice(0, c);
|
|
311
311
|
},
|
|
312
|
-
basename: function(
|
|
312
|
+
basename: function(i, o) {
|
|
313
313
|
if (o !== void 0 && typeof o != "string") throw new TypeError('"ext" argument must be a string');
|
|
314
|
-
t(
|
|
314
|
+
t(i);
|
|
315
315
|
var a = 0, c = -1, h = !0, l;
|
|
316
|
-
if (o !== void 0 && o.length > 0 && o.length <=
|
|
317
|
-
if (o.length ===
|
|
316
|
+
if (o !== void 0 && o.length > 0 && o.length <= i.length) {
|
|
317
|
+
if (o.length === i.length && o === i) return "";
|
|
318
318
|
var d = o.length - 1, f = -1;
|
|
319
|
-
for (l =
|
|
320
|
-
var g =
|
|
319
|
+
for (l = i.length - 1; l >= 0; --l) {
|
|
320
|
+
var g = i.charCodeAt(l);
|
|
321
321
|
if (g === 47) {
|
|
322
322
|
if (!h) {
|
|
323
323
|
a = l + 1;
|
|
@@ -326,22 +326,22 @@ function Je() {
|
|
|
326
326
|
} else
|
|
327
327
|
f === -1 && (h = !1, f = l + 1), d >= 0 && (g === o.charCodeAt(d) ? --d === -1 && (c = l) : (d = -1, c = f));
|
|
328
328
|
}
|
|
329
|
-
return a === c ? c = f : c === -1 && (c =
|
|
329
|
+
return a === c ? c = f : c === -1 && (c = i.length), i.slice(a, c);
|
|
330
330
|
} else {
|
|
331
|
-
for (l =
|
|
332
|
-
if (
|
|
331
|
+
for (l = i.length - 1; l >= 0; --l)
|
|
332
|
+
if (i.charCodeAt(l) === 47) {
|
|
333
333
|
if (!h) {
|
|
334
334
|
a = l + 1;
|
|
335
335
|
break;
|
|
336
336
|
}
|
|
337
337
|
} else c === -1 && (h = !1, c = l + 1);
|
|
338
|
-
return c === -1 ? "" :
|
|
338
|
+
return c === -1 ? "" : i.slice(a, c);
|
|
339
339
|
}
|
|
340
340
|
},
|
|
341
|
-
extname: function(
|
|
342
|
-
t(
|
|
343
|
-
for (var o = -1, a = 0, c = -1, h = !0, l = 0, d =
|
|
344
|
-
var f =
|
|
341
|
+
extname: function(i) {
|
|
342
|
+
t(i);
|
|
343
|
+
for (var o = -1, a = 0, c = -1, h = !0, l = 0, d = i.length - 1; d >= 0; --d) {
|
|
344
|
+
var f = i.charCodeAt(d);
|
|
345
345
|
if (f === 47) {
|
|
346
346
|
if (!h) {
|
|
347
347
|
a = d + 1;
|
|
@@ -353,21 +353,21 @@ function Je() {
|
|
|
353
353
|
}
|
|
354
354
|
return o === -1 || c === -1 || // We saw a non-dot character immediately before the dot
|
|
355
355
|
l === 0 || // The (right-most) trimmed path component is exactly '..'
|
|
356
|
-
l === 1 && o === c - 1 && o === a + 1 ? "" :
|
|
356
|
+
l === 1 && o === c - 1 && o === a + 1 ? "" : i.slice(o, c);
|
|
357
357
|
},
|
|
358
|
-
format: function(
|
|
359
|
-
if (
|
|
360
|
-
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof
|
|
361
|
-
return n("/",
|
|
358
|
+
format: function(i) {
|
|
359
|
+
if (i === null || typeof i != "object")
|
|
360
|
+
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof i);
|
|
361
|
+
return n("/", i);
|
|
362
362
|
},
|
|
363
|
-
parse: function(
|
|
364
|
-
t(
|
|
363
|
+
parse: function(i) {
|
|
364
|
+
t(i);
|
|
365
365
|
var o = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
366
|
-
if (
|
|
367
|
-
var a =
|
|
366
|
+
if (i.length === 0) return o;
|
|
367
|
+
var a = i.charCodeAt(0), c = a === 47, h;
|
|
368
368
|
c ? (o.root = "/", h = 1) : h = 0;
|
|
369
|
-
for (var l = -1, d = 0, f = -1, g = !0, m =
|
|
370
|
-
if (a =
|
|
369
|
+
for (var l = -1, d = 0, f = -1, g = !0, m = i.length - 1, p = 0; m >= h; --m) {
|
|
370
|
+
if (a = i.charCodeAt(m), a === 47) {
|
|
371
371
|
if (!g) {
|
|
372
372
|
d = m + 1;
|
|
373
373
|
break;
|
|
@@ -378,32 +378,32 @@ function Je() {
|
|
|
378
378
|
}
|
|
379
379
|
return l === -1 || f === -1 || // We saw a non-dot character immediately before the dot
|
|
380
380
|
p === 0 || // The (right-most) trimmed path component is exactly '..'
|
|
381
|
-
p === 1 && l === f - 1 && l === d + 1 ? f !== -1 && (d === 0 && c ? o.base = o.name =
|
|
381
|
+
p === 1 && l === f - 1 && l === d + 1 ? f !== -1 && (d === 0 && c ? o.base = o.name = i.slice(1, f) : o.base = o.name = i.slice(d, f)) : (d === 0 && c ? (o.name = i.slice(1, l), o.base = i.slice(1, f)) : (o.name = i.slice(d, l), o.base = i.slice(d, f)), o.ext = i.slice(l, f)), d > 0 ? o.dir = i.slice(0, d - 1) : c && (o.dir = "/"), o;
|
|
382
382
|
},
|
|
383
383
|
sep: "/",
|
|
384
384
|
delimiter: ":",
|
|
385
385
|
win32: null,
|
|
386
386
|
posix: null
|
|
387
387
|
};
|
|
388
|
-
return
|
|
388
|
+
return r.posix = r, Z = r, Z;
|
|
389
389
|
}
|
|
390
|
-
var
|
|
391
|
-
const y = /* @__PURE__ */
|
|
392
|
-
function
|
|
390
|
+
var tt = et();
|
|
391
|
+
const y = /* @__PURE__ */ Qe(tt);
|
|
392
|
+
function nt(t, e) {
|
|
393
393
|
const n = y.relative(e, t);
|
|
394
394
|
return n === "" || !n.startsWith("..") && !y.isAbsolute(n);
|
|
395
395
|
}
|
|
396
|
-
function
|
|
397
|
-
const
|
|
398
|
-
if (!
|
|
396
|
+
function rt(t, e, n) {
|
|
397
|
+
const r = y.resolve(e), s = y.resolve(t);
|
|
398
|
+
if (!nt(s, r))
|
|
399
399
|
throw u({
|
|
400
400
|
code: "parse_error",
|
|
401
401
|
path: n,
|
|
402
402
|
details: { message: "path resolves outside root directory" }
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
|
-
function
|
|
406
|
-
const { rootDir: n, fromPath:
|
|
405
|
+
function Ce(t, e = {}) {
|
|
406
|
+
const { rootDir: n, fromPath: r, documentPath: s, constrainToRoot: i = !1, hyogenPath: o = !1 } = e;
|
|
407
407
|
if (t.length === 0)
|
|
408
408
|
throw u({
|
|
409
409
|
code: "parse_error",
|
|
@@ -431,8 +431,8 @@ function ve(t, e = {}) {
|
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
433
|
else if (t.startsWith("./") || t.startsWith("../"))
|
|
434
|
-
if (
|
|
435
|
-
a = y.resolve(y.dirname(
|
|
434
|
+
if (r)
|
|
435
|
+
a = y.resolve(y.dirname(r), t);
|
|
436
436
|
else if (n)
|
|
437
437
|
a = y.resolve(n, t);
|
|
438
438
|
else
|
|
@@ -451,9 +451,9 @@ function ve(t, e = {}) {
|
|
|
451
451
|
path: s,
|
|
452
452
|
details: { message: "root is required for relative template paths" }
|
|
453
453
|
});
|
|
454
|
-
return n &&
|
|
454
|
+
return n && i && rt(a, n, s), a;
|
|
455
455
|
}
|
|
456
|
-
async function
|
|
456
|
+
async function it(t) {
|
|
457
457
|
const e = t.registry.get(t.alias);
|
|
458
458
|
if (!e)
|
|
459
459
|
throw u({
|
|
@@ -463,13 +463,13 @@ async function tt(t) {
|
|
|
463
463
|
message: `unregistered component: ${t.alias}`
|
|
464
464
|
}
|
|
465
465
|
});
|
|
466
|
-
const n =
|
|
466
|
+
const n = Se(e.componentPath) ? e.componentPath : Ce(e.componentPath, {
|
|
467
467
|
rootDir: t.rootDir,
|
|
468
468
|
fromPath: e.definedAt,
|
|
469
469
|
documentPath: t.path,
|
|
470
470
|
constrainToRoot: t.constrainToRoot,
|
|
471
471
|
hyogenPath: !0
|
|
472
|
-
}),
|
|
472
|
+
}), r = await t.loader(n), { context: s, body: i } = P(r, n), o = Ye(s, n), { values: a, warnings: c } = Je(
|
|
473
473
|
t.props,
|
|
474
474
|
o,
|
|
475
475
|
t.alias
|
|
@@ -479,7 +479,7 @@ async function tt(t) {
|
|
|
479
479
|
t.parentContext,
|
|
480
480
|
l,
|
|
481
481
|
a
|
|
482
|
-
), g = (await
|
|
482
|
+
), g = (await le(i, {
|
|
483
483
|
context: d,
|
|
484
484
|
loader: t.loader,
|
|
485
485
|
root: t.rootDir,
|
|
@@ -501,17 +501,17 @@ async function tt(t) {
|
|
|
501
501
|
});
|
|
502
502
|
return g;
|
|
503
503
|
}
|
|
504
|
-
const
|
|
504
|
+
const st = /* @__PURE__ */ new Set([
|
|
505
505
|
"__proto__",
|
|
506
506
|
"prototype",
|
|
507
507
|
"constructor",
|
|
508
508
|
"__defineGetter__"
|
|
509
509
|
]);
|
|
510
|
-
function
|
|
511
|
-
return
|
|
510
|
+
function ot(t) {
|
|
511
|
+
return st.has(t);
|
|
512
512
|
}
|
|
513
|
-
function
|
|
514
|
-
if (
|
|
513
|
+
function fe(t, e) {
|
|
514
|
+
if (ot(t))
|
|
515
515
|
throw u({
|
|
516
516
|
code: "forbidden_property_access",
|
|
517
517
|
path: e,
|
|
@@ -521,11 +521,15 @@ function de(t, e) {
|
|
|
521
521
|
function M(t) {
|
|
522
522
|
return !t;
|
|
523
523
|
}
|
|
524
|
-
function
|
|
525
|
-
if (t != null
|
|
526
|
-
|
|
524
|
+
function at(t, e) {
|
|
525
|
+
if (t != null) {
|
|
526
|
+
if (typeof t == "string")
|
|
527
|
+
return e === "length" ? t.length : void 0;
|
|
528
|
+
if (typeof t == "object")
|
|
529
|
+
return t[e];
|
|
530
|
+
}
|
|
527
531
|
}
|
|
528
|
-
function
|
|
532
|
+
function ct(t, e, n) {
|
|
529
533
|
switch (t) {
|
|
530
534
|
case "+":
|
|
531
535
|
return e + n;
|
|
@@ -559,43 +563,43 @@ function st(t, e, n) {
|
|
|
559
563
|
return;
|
|
560
564
|
}
|
|
561
565
|
}
|
|
562
|
-
async function
|
|
563
|
-
const { context: n, path:
|
|
566
|
+
async function k(t, e) {
|
|
567
|
+
const { context: n, path: r } = e;
|
|
564
568
|
switch (t.type) {
|
|
565
569
|
case "literal":
|
|
566
570
|
return t.value;
|
|
567
571
|
case "identifier":
|
|
568
|
-
return
|
|
572
|
+
return fe(t.name, r), n[t.name];
|
|
569
573
|
case "member": {
|
|
570
|
-
|
|
571
|
-
const s = await
|
|
572
|
-
return
|
|
574
|
+
fe(t.property, r);
|
|
575
|
+
const s = await k(t.object, e);
|
|
576
|
+
return at(s, t.property);
|
|
573
577
|
}
|
|
574
578
|
case "default": {
|
|
575
|
-
const s = await
|
|
576
|
-
return M(s) ?
|
|
579
|
+
const s = await k(t.left, e);
|
|
580
|
+
return M(s) ? k(t.right, e) : s;
|
|
577
581
|
}
|
|
578
582
|
case "unary": {
|
|
579
|
-
const s = await
|
|
583
|
+
const s = await k(t.operand, e);
|
|
580
584
|
return t.op === "!" ? !s : void 0;
|
|
581
585
|
}
|
|
582
586
|
case "binary": {
|
|
583
587
|
if (t.op === "&&") {
|
|
584
|
-
const o = await
|
|
585
|
-
return M(o) ? o :
|
|
588
|
+
const o = await k(t.left, e);
|
|
589
|
+
return M(o) ? o : k(t.right, e);
|
|
586
590
|
}
|
|
587
591
|
if (t.op === "||") {
|
|
588
|
-
const o = await
|
|
589
|
-
return M(o) ?
|
|
592
|
+
const o = await k(t.left, e);
|
|
593
|
+
return M(o) ? k(t.right, e) : o;
|
|
590
594
|
}
|
|
591
|
-
const s = await
|
|
592
|
-
return
|
|
595
|
+
const s = await k(t.left, e), i = await k(t.right, e);
|
|
596
|
+
return ct(t.op, s, i);
|
|
593
597
|
}
|
|
594
598
|
case "call": {
|
|
595
599
|
if (!e.registry || !e.loader || !e.visitStack)
|
|
596
600
|
throw u({
|
|
597
601
|
code: "parse_error",
|
|
598
|
-
path:
|
|
602
|
+
path: r,
|
|
599
603
|
details: {
|
|
600
604
|
message: `function calls are not allowed: ${t.callee}()`
|
|
601
605
|
}
|
|
@@ -603,22 +607,22 @@ async function w(t, e) {
|
|
|
603
607
|
if (!e.registry.has(t.callee))
|
|
604
608
|
throw u({
|
|
605
609
|
code: "parse_error",
|
|
606
|
-
path:
|
|
610
|
+
path: r,
|
|
607
611
|
details: {
|
|
608
612
|
message: `unregistered component: ${t.callee}`
|
|
609
613
|
}
|
|
610
614
|
});
|
|
611
615
|
const s = {};
|
|
612
|
-
for (const [
|
|
613
|
-
s[
|
|
614
|
-
return
|
|
616
|
+
for (const [i, o] of Object.entries(t.args))
|
|
617
|
+
s[i] = await k(o, e);
|
|
618
|
+
return it({
|
|
615
619
|
alias: t.callee,
|
|
616
620
|
props: s,
|
|
617
621
|
parentContext: e.parentContext ?? n,
|
|
618
622
|
registry: e.registry,
|
|
619
623
|
loader: e.loader,
|
|
620
624
|
rootDir: e.rootDir,
|
|
621
|
-
path:
|
|
625
|
+
path: r,
|
|
622
626
|
warnings: e.warnings ?? [],
|
|
623
627
|
visitStack: e.visitStack,
|
|
624
628
|
preserveHgComments: e.preserveHgComments,
|
|
@@ -629,25 +633,25 @@ async function w(t, e) {
|
|
|
629
633
|
if (t.method !== "toLocaleString")
|
|
630
634
|
throw u({
|
|
631
635
|
code: "parse_error",
|
|
632
|
-
path:
|
|
636
|
+
path: r,
|
|
633
637
|
details: { message: `unsupported method: ${t.method}()` }
|
|
634
638
|
});
|
|
635
|
-
const s = await
|
|
639
|
+
const s = await k(t.object, e);
|
|
636
640
|
return s == null || typeof s.toLocaleString != "function" ? void 0 : s.toLocaleString(
|
|
637
641
|
...t.args
|
|
638
642
|
);
|
|
639
643
|
}
|
|
640
644
|
case "ternary": {
|
|
641
|
-
const s = await
|
|
642
|
-
return M(s) ?
|
|
645
|
+
const s = await k(t.condition, e);
|
|
646
|
+
return M(s) ? k(t.alternate, e) : k(t.consequent, e);
|
|
643
647
|
}
|
|
644
648
|
case "template": {
|
|
645
649
|
let s = "";
|
|
646
|
-
for (const
|
|
647
|
-
if (typeof
|
|
648
|
-
s +=
|
|
650
|
+
for (const i of t.parts)
|
|
651
|
+
if (typeof i == "string")
|
|
652
|
+
s += i;
|
|
649
653
|
else {
|
|
650
|
-
const o = await
|
|
654
|
+
const o = await k(i, e);
|
|
651
655
|
o != null && (s += String(o));
|
|
652
656
|
}
|
|
653
657
|
return s;
|
|
@@ -659,17 +663,17 @@ async function w(t, e) {
|
|
|
659
663
|
function q(t) {
|
|
660
664
|
return /[A-Za-z_$]/.test(t);
|
|
661
665
|
}
|
|
662
|
-
function
|
|
666
|
+
function lt(t) {
|
|
663
667
|
return /[A-Za-z0-9_$]/.test(t);
|
|
664
668
|
}
|
|
665
669
|
function C(t, e, n = {}) {
|
|
666
|
-
const
|
|
667
|
-
if (
|
|
670
|
+
const r = t.trim();
|
|
671
|
+
if (r.length === 0)
|
|
668
672
|
throw x(e, "empty expression");
|
|
669
|
-
const s = new
|
|
673
|
+
const s = new ht(r, e, n), i = s.parseExpression();
|
|
670
674
|
if (s.skipWhitespace(), s.hasMore())
|
|
671
675
|
throw x(e, `unexpected token at position ${s.position}`);
|
|
672
|
-
return
|
|
676
|
+
return i;
|
|
673
677
|
}
|
|
674
678
|
function x(t, e) {
|
|
675
679
|
throw u({
|
|
@@ -678,9 +682,9 @@ function x(t, e) {
|
|
|
678
682
|
details: { message: e }
|
|
679
683
|
});
|
|
680
684
|
}
|
|
681
|
-
class
|
|
682
|
-
constructor(e, n,
|
|
683
|
-
this.input = e, this.path = n, this.allowCalls =
|
|
685
|
+
class ht {
|
|
686
|
+
constructor(e, n, r = {}) {
|
|
687
|
+
this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
|
|
684
688
|
}
|
|
685
689
|
input;
|
|
686
690
|
path;
|
|
@@ -717,8 +721,8 @@ class at {
|
|
|
717
721
|
if (this.skipWhitespace(), this.peek() !== ":")
|
|
718
722
|
throw x(this.path, "expected ':' in ternary expression");
|
|
719
723
|
this.index++;
|
|
720
|
-
const
|
|
721
|
-
return { type: "ternary", condition: e, consequent: n, alternate:
|
|
724
|
+
const r = this.parseTernary();
|
|
725
|
+
return { type: "ternary", condition: e, consequent: n, alternate: r };
|
|
722
726
|
}
|
|
723
727
|
parseLogicalOr() {
|
|
724
728
|
let e = this.parseLogicalAnd();
|
|
@@ -743,8 +747,8 @@ class at {
|
|
|
743
747
|
const n = this.readComparisonOp();
|
|
744
748
|
if (!n)
|
|
745
749
|
break;
|
|
746
|
-
const
|
|
747
|
-
e = { type: "binary", op: n, left: e, right:
|
|
750
|
+
const r = this.parseAdditive();
|
|
751
|
+
e = { type: "binary", op: n, left: e, right: r };
|
|
748
752
|
}
|
|
749
753
|
return e;
|
|
750
754
|
}
|
|
@@ -772,8 +776,8 @@ class at {
|
|
|
772
776
|
if (n !== "+" && n !== "-")
|
|
773
777
|
break;
|
|
774
778
|
this.index++;
|
|
775
|
-
const
|
|
776
|
-
e = { type: "binary", op: n, left: e, right:
|
|
779
|
+
const r = this.parseMultiplicative();
|
|
780
|
+
e = { type: "binary", op: n, left: e, right: r };
|
|
777
781
|
}
|
|
778
782
|
return e;
|
|
779
783
|
}
|
|
@@ -785,8 +789,8 @@ class at {
|
|
|
785
789
|
if (n !== "*" && n !== "/")
|
|
786
790
|
break;
|
|
787
791
|
this.index++;
|
|
788
|
-
const
|
|
789
|
-
e = { type: "binary", op: n, left: e, right:
|
|
792
|
+
const r = this.parseUnary();
|
|
793
|
+
e = { type: "binary", op: n, left: e, right: r };
|
|
790
794
|
}
|
|
791
795
|
return e;
|
|
792
796
|
}
|
|
@@ -813,8 +817,8 @@ class at {
|
|
|
813
817
|
if (n !== "toLocaleString")
|
|
814
818
|
throw x(this.path, `unsupported method: ${n}()`);
|
|
815
819
|
this.index++;
|
|
816
|
-
const
|
|
817
|
-
return { type: "method", object: e, method: n, args:
|
|
820
|
+
const r = this.parseMethodArgs();
|
|
821
|
+
return { type: "method", object: e, method: n, args: r };
|
|
818
822
|
}
|
|
819
823
|
return { type: "member", object: e, property: n };
|
|
820
824
|
}
|
|
@@ -860,8 +864,8 @@ class at {
|
|
|
860
864
|
"component calls are not allowed in template literals"
|
|
861
865
|
);
|
|
862
866
|
this.index++;
|
|
863
|
-
const
|
|
864
|
-
return { type: "call", callee: n, args:
|
|
867
|
+
const r = this.parseCallArgs();
|
|
868
|
+
return { type: "call", callee: n, args: r };
|
|
865
869
|
}
|
|
866
870
|
if (this.peek() === "[")
|
|
867
871
|
throw x(this.path, "bracket access is not allowed");
|
|
@@ -874,43 +878,43 @@ class at {
|
|
|
874
878
|
const e = [];
|
|
875
879
|
let n = "";
|
|
876
880
|
for (; this.index < this.input.length; ) {
|
|
877
|
-
const
|
|
878
|
-
if (
|
|
881
|
+
const r = this.input[this.index];
|
|
882
|
+
if (r === "`")
|
|
879
883
|
return this.index++, e.push(n), { type: "template", parts: e };
|
|
880
|
-
if (
|
|
884
|
+
if (r === "\\") {
|
|
881
885
|
if (this.index++, this.index >= this.input.length)
|
|
882
886
|
throw x(this.path, "unterminated template literal escape");
|
|
883
887
|
n += this.input[this.index], this.index++;
|
|
884
888
|
continue;
|
|
885
889
|
}
|
|
886
|
-
if (
|
|
890
|
+
if (r === "$" && this.input[this.index + 1] === "{") {
|
|
887
891
|
e.push(n), n = "", this.index += 2;
|
|
888
|
-
const s = this.readTemplateExpression(),
|
|
892
|
+
const s = this.readTemplateExpression(), i = C(s, this.path, {
|
|
889
893
|
allowCalls: !1
|
|
890
894
|
});
|
|
891
|
-
e.push(
|
|
895
|
+
e.push(i);
|
|
892
896
|
continue;
|
|
893
897
|
}
|
|
894
|
-
n +=
|
|
898
|
+
n += r, this.index++;
|
|
895
899
|
}
|
|
896
900
|
throw x(this.path, "unterminated template literal");
|
|
897
901
|
}
|
|
898
902
|
readTemplateExpression() {
|
|
899
903
|
let e = 1;
|
|
900
904
|
const n = this.index;
|
|
901
|
-
let
|
|
905
|
+
let r = null;
|
|
902
906
|
for (; this.index < this.input.length; ) {
|
|
903
907
|
const s = this.input[this.index];
|
|
904
|
-
if (
|
|
908
|
+
if (r) {
|
|
905
909
|
if (s === "\\") {
|
|
906
910
|
this.index += 2;
|
|
907
911
|
continue;
|
|
908
912
|
}
|
|
909
|
-
s ===
|
|
913
|
+
s === r && (r = null), this.index++;
|
|
910
914
|
continue;
|
|
911
915
|
}
|
|
912
916
|
if (s === '"' || s === "'" || s === "`") {
|
|
913
|
-
|
|
917
|
+
r = s, this.index++;
|
|
914
918
|
continue;
|
|
915
919
|
}
|
|
916
920
|
if (s === "{") {
|
|
@@ -919,8 +923,8 @@ class at {
|
|
|
919
923
|
}
|
|
920
924
|
if (s === "}") {
|
|
921
925
|
if (e--, e === 0) {
|
|
922
|
-
const
|
|
923
|
-
return this.index++,
|
|
926
|
+
const i = this.input.slice(n, this.index);
|
|
927
|
+
return this.index++, i;
|
|
924
928
|
}
|
|
925
929
|
this.index++;
|
|
926
930
|
continue;
|
|
@@ -1046,7 +1050,7 @@ class at {
|
|
|
1046
1050
|
const e = this.index;
|
|
1047
1051
|
if (!q(this.peek()))
|
|
1048
1052
|
return "";
|
|
1049
|
-
for (this.index++; this.index < this.input.length &&
|
|
1053
|
+
for (this.index++; this.index < this.input.length && lt(this.peek()); )
|
|
1050
1054
|
this.index++;
|
|
1051
1055
|
return this.input.slice(e, this.index);
|
|
1052
1056
|
}
|
|
@@ -1055,17 +1059,17 @@ class at {
|
|
|
1055
1059
|
this.index++;
|
|
1056
1060
|
let n = "";
|
|
1057
1061
|
for (; this.index < this.input.length; ) {
|
|
1058
|
-
const
|
|
1059
|
-
if (
|
|
1062
|
+
const r = this.input[this.index];
|
|
1063
|
+
if (r === e)
|
|
1060
1064
|
return this.index++, n;
|
|
1061
|
-
if (
|
|
1065
|
+
if (r === "\\") {
|
|
1062
1066
|
if (this.index++, this.index >= this.input.length)
|
|
1063
1067
|
throw x(this.path, "unterminated string escape");
|
|
1064
1068
|
const s = this.input[this.index];
|
|
1065
1069
|
n += s, this.index++;
|
|
1066
1070
|
continue;
|
|
1067
1071
|
}
|
|
1068
|
-
n +=
|
|
1072
|
+
n += r, this.index++;
|
|
1069
1073
|
}
|
|
1070
1074
|
throw x(this.path, "unterminated string literal");
|
|
1071
1075
|
}
|
|
@@ -1073,143 +1077,143 @@ class at {
|
|
|
1073
1077
|
const e = this.index;
|
|
1074
1078
|
for (this.peek() === "-" && this.index++; this.index < this.input.length && /[0-9.]/.test(this.peek()); )
|
|
1075
1079
|
this.index++;
|
|
1076
|
-
const n = this.input.slice(e, this.index),
|
|
1077
|
-
if (Number.isNaN(
|
|
1080
|
+
const n = this.input.slice(e, this.index), r = Number(n);
|
|
1081
|
+
if (Number.isNaN(r))
|
|
1078
1082
|
throw x(this.path, `invalid number '${n}'`);
|
|
1079
|
-
return
|
|
1083
|
+
return r;
|
|
1080
1084
|
}
|
|
1081
1085
|
}
|
|
1082
|
-
async function
|
|
1083
|
-
const
|
|
1084
|
-
let s = "",
|
|
1085
|
-
for (;
|
|
1086
|
-
const o = t.indexOf("{",
|
|
1086
|
+
async function We(t, e, n = {}) {
|
|
1087
|
+
const r = n.path;
|
|
1088
|
+
let s = "", i = 0;
|
|
1089
|
+
for (; i < t.length; ) {
|
|
1090
|
+
const o = t.indexOf("{", i);
|
|
1087
1091
|
if (o === -1) {
|
|
1088
|
-
s += t.slice(
|
|
1092
|
+
s += t.slice(i);
|
|
1089
1093
|
break;
|
|
1090
1094
|
}
|
|
1091
|
-
s += t.slice(
|
|
1095
|
+
s += t.slice(i, o);
|
|
1092
1096
|
const a = t[o + 1] === "{" && t[o + 2] === "{" && (o === 0 || t[o - 1] !== "\\");
|
|
1093
1097
|
if (!(!a && t[o + 1] === "{" && (o === 0 || t[o - 1] !== "\\")) && !a) {
|
|
1094
|
-
s += "{",
|
|
1098
|
+
s += "{", i = o + 1;
|
|
1095
1099
|
continue;
|
|
1096
1100
|
}
|
|
1097
1101
|
const h = a ? 3 : 2, l = a ? "}}}" : "}}", d = t.indexOf(l, o + h);
|
|
1098
1102
|
if (d === -1)
|
|
1099
1103
|
throw u({
|
|
1100
1104
|
code: "parse_error",
|
|
1101
|
-
path:
|
|
1105
|
+
path: r,
|
|
1102
1106
|
details: { message: "unclosed expression" }
|
|
1103
1107
|
});
|
|
1104
|
-
const f = t.slice(o + h, d).trim(), g = C(f,
|
|
1108
|
+
const f = t.slice(o + h, d).trim(), g = C(f, r), m = await k(g, {
|
|
1105
1109
|
...n,
|
|
1106
1110
|
context: e,
|
|
1107
|
-
path:
|
|
1111
|
+
path: r,
|
|
1108
1112
|
parentContext: n.parentContext ?? e
|
|
1109
1113
|
});
|
|
1110
|
-
s += m == null ? "" : String(m),
|
|
1114
|
+
s += m == null ? "" : String(m), i = d + l.length;
|
|
1111
1115
|
}
|
|
1112
1116
|
return s;
|
|
1113
1117
|
}
|
|
1114
|
-
function
|
|
1115
|
-
let n = 0,
|
|
1116
|
-
for (;
|
|
1117
|
-
const s = t.indexOf(e,
|
|
1118
|
+
function dt(t, e) {
|
|
1119
|
+
let n = 0, r = 0;
|
|
1120
|
+
for (; r < t.length; ) {
|
|
1121
|
+
const s = t.indexOf(e, r);
|
|
1118
1122
|
if (s === -1)
|
|
1119
1123
|
break;
|
|
1120
|
-
n++,
|
|
1124
|
+
n++, r = s + e.length;
|
|
1121
1125
|
}
|
|
1122
1126
|
return n;
|
|
1123
1127
|
}
|
|
1124
|
-
function X(t) {
|
|
1125
|
-
const e = t.includes("@hg"), n = t.includes("@endhg"), i = ct(t, "@@");
|
|
1126
|
-
return e && n ? i > 0 ? "mixed" : "hg" : i >= 2 && !e && !n ? "at-at" : (e || n) && i > 0 ? "mixed" : e && !n || i === 1 && !n ? "unclosed" : "none";
|
|
1127
|
-
}
|
|
1128
1128
|
function Q(t) {
|
|
1129
|
+
const e = t.includes("@hg"), n = t.includes("@endhg"), r = dt(t, "@@");
|
|
1130
|
+
return e && n ? r > 0 ? "mixed" : "hg" : r >= 2 && !e && !n ? "at-at" : (e || n) && r > 0 ? "mixed" : e && !n || r === 1 && !n ? "unclosed" : "none";
|
|
1131
|
+
}
|
|
1132
|
+
function ee(t) {
|
|
1129
1133
|
return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
|
|
1130
1134
|
}
|
|
1131
|
-
function
|
|
1132
|
-
let n = 0,
|
|
1135
|
+
function te(t, e) {
|
|
1136
|
+
let n = 0, r = !1;
|
|
1133
1137
|
for (; n < e; ) {
|
|
1134
1138
|
const s = t.indexOf("```", n);
|
|
1135
1139
|
if (s === -1 || s >= e)
|
|
1136
1140
|
break;
|
|
1137
|
-
|
|
1141
|
+
r = !r, n = s + 3;
|
|
1138
1142
|
}
|
|
1139
|
-
return
|
|
1143
|
+
return r;
|
|
1140
1144
|
}
|
|
1141
|
-
function
|
|
1145
|
+
function E(t) {
|
|
1142
1146
|
const e = [];
|
|
1143
1147
|
let n = 0;
|
|
1144
1148
|
for (; n < t.length; ) {
|
|
1145
|
-
const
|
|
1146
|
-
if (
|
|
1149
|
+
const r = t.indexOf("<!--", n);
|
|
1150
|
+
if (r === -1)
|
|
1147
1151
|
break;
|
|
1148
|
-
if (
|
|
1149
|
-
n =
|
|
1152
|
+
if (te(t, r)) {
|
|
1153
|
+
n = r + 4;
|
|
1150
1154
|
continue;
|
|
1151
1155
|
}
|
|
1152
|
-
const s = t.indexOf("-->",
|
|
1156
|
+
const s = t.indexOf("-->", r + 4);
|
|
1153
1157
|
if (s === -1)
|
|
1154
1158
|
break;
|
|
1155
|
-
const
|
|
1159
|
+
const i = t.slice(r, s + 3), o = i.slice(4, i.length - 3), a = Q(o);
|
|
1156
1160
|
(a === "hg" || a === "at-at") && e.push({
|
|
1157
|
-
start:
|
|
1161
|
+
start: r,
|
|
1158
1162
|
end: s + 3,
|
|
1159
1163
|
inner: o,
|
|
1160
|
-
raw:
|
|
1164
|
+
raw: i
|
|
1161
1165
|
}), n = s + 3;
|
|
1162
1166
|
}
|
|
1163
1167
|
return e;
|
|
1164
1168
|
}
|
|
1165
|
-
function
|
|
1169
|
+
function Ae(t) {
|
|
1166
1170
|
let e = 0;
|
|
1167
1171
|
for (; e < t.length; ) {
|
|
1168
1172
|
const n = t.indexOf("<!--", e);
|
|
1169
1173
|
if (n === -1)
|
|
1170
1174
|
return !1;
|
|
1171
|
-
if (
|
|
1175
|
+
if (te(t, n)) {
|
|
1172
1176
|
e = n + 4;
|
|
1173
1177
|
continue;
|
|
1174
1178
|
}
|
|
1175
|
-
const
|
|
1176
|
-
if (
|
|
1179
|
+
const r = t.indexOf("-->", n + 4);
|
|
1180
|
+
if (r === -1)
|
|
1177
1181
|
return !1;
|
|
1178
|
-
const s = t.slice(n + 4,
|
|
1179
|
-
if (
|
|
1182
|
+
const s = t.slice(n + 4, r), i = Q(s);
|
|
1183
|
+
if (i === "unclosed" || i === "mixed")
|
|
1180
1184
|
return !0;
|
|
1181
|
-
e =
|
|
1185
|
+
e = r + 3;
|
|
1182
1186
|
}
|
|
1183
1187
|
return !1;
|
|
1184
1188
|
}
|
|
1185
|
-
function
|
|
1189
|
+
function $e(t) {
|
|
1186
1190
|
let e = 0;
|
|
1187
1191
|
for (; e < t.length; ) {
|
|
1188
1192
|
const n = t.indexOf("<!--", e);
|
|
1189
1193
|
if (n === -1)
|
|
1190
1194
|
return null;
|
|
1191
|
-
if (
|
|
1195
|
+
if (te(t, n)) {
|
|
1192
1196
|
e = n + 4;
|
|
1193
1197
|
continue;
|
|
1194
1198
|
}
|
|
1195
|
-
const
|
|
1196
|
-
if (
|
|
1199
|
+
const r = t.indexOf("-->", n + 4);
|
|
1200
|
+
if (r === -1)
|
|
1197
1201
|
return null;
|
|
1198
|
-
const s = t.slice(n + 4,
|
|
1199
|
-
if (
|
|
1202
|
+
const s = t.slice(n + 4, r), i = Q(s);
|
|
1203
|
+
if (i === "mixed")
|
|
1200
1204
|
return "mixed @hg and @@ markers are not allowed";
|
|
1201
|
-
if (
|
|
1205
|
+
if (i === "unclosed")
|
|
1202
1206
|
return "unclosed hyogen block (missing closing marker)";
|
|
1203
|
-
e =
|
|
1207
|
+
e = r + 3;
|
|
1204
1208
|
}
|
|
1205
1209
|
return null;
|
|
1206
1210
|
}
|
|
1207
|
-
function
|
|
1208
|
-
return
|
|
1211
|
+
function A(t) {
|
|
1212
|
+
return ee(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
|
|
1209
1213
|
}
|
|
1210
|
-
const
|
|
1211
|
-
function
|
|
1212
|
-
return
|
|
1214
|
+
const ut = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
|
|
1215
|
+
function Ee(t) {
|
|
1216
|
+
return ut.test(t.trim());
|
|
1213
1217
|
}
|
|
1214
1218
|
function V(t, e) {
|
|
1215
1219
|
throw u({
|
|
@@ -1218,99 +1222,99 @@ function V(t, e) {
|
|
|
1218
1222
|
details: { message: e }
|
|
1219
1223
|
});
|
|
1220
1224
|
}
|
|
1221
|
-
function
|
|
1225
|
+
function ft(t, e) {
|
|
1222
1226
|
let n = t;
|
|
1223
|
-
const
|
|
1224
|
-
|
|
1225
|
-
const s =
|
|
1227
|
+
const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
|
|
1228
|
+
r && (n = r[1]);
|
|
1229
|
+
const s = A(n);
|
|
1226
1230
|
if (s.length !== 1)
|
|
1227
1231
|
return null;
|
|
1228
|
-
const
|
|
1229
|
-
if (/^include\s+/i.test(
|
|
1232
|
+
const i = s[0];
|
|
1233
|
+
if (/^include\s+/i.test(i) || /^component\s+/i.test(i) || /^const\s+/i.test(i) || /^let\s+/i.test(i) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(i))
|
|
1230
1234
|
return null;
|
|
1231
|
-
if (
|
|
1235
|
+
if (i === "else")
|
|
1232
1236
|
return { kind: "else" };
|
|
1233
|
-
if (
|
|
1237
|
+
if (i === "endif")
|
|
1234
1238
|
return { kind: "endif" };
|
|
1235
|
-
if (
|
|
1239
|
+
if (i === "endeach")
|
|
1236
1240
|
return { kind: "endeach" };
|
|
1237
|
-
if (/^IF\b/.test(
|
|
1241
|
+
if (/^IF\b/.test(i) || /^ELSE\b/.test(i) || /^ENDIF\b/.test(i))
|
|
1238
1242
|
throw V(e, "control keywords must be lowercase");
|
|
1239
|
-
const o = /^else\s+if\s+(.+)$/.exec(
|
|
1243
|
+
const o = /^else\s+if\s+(.+)$/.exec(i);
|
|
1240
1244
|
if (o)
|
|
1241
1245
|
return {
|
|
1242
1246
|
kind: "else_if",
|
|
1243
1247
|
expr: C(o[1], e)
|
|
1244
1248
|
};
|
|
1245
|
-
const a = /^if\s+(.+)$/.exec(
|
|
1249
|
+
const a = /^if\s+(.+)$/.exec(i);
|
|
1246
1250
|
if (a)
|
|
1247
1251
|
return {
|
|
1248
1252
|
kind: "if",
|
|
1249
1253
|
expr: C(a[1], e)
|
|
1250
1254
|
};
|
|
1251
|
-
const c = /^each\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+in\s+(.+)$/.exec(
|
|
1255
|
+
const c = /^each\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+in\s+(.+)$/.exec(i);
|
|
1252
1256
|
if (c)
|
|
1253
1257
|
return {
|
|
1254
1258
|
kind: "each",
|
|
1255
1259
|
item: c[1],
|
|
1256
1260
|
expr: C(c[2], e)
|
|
1257
1261
|
};
|
|
1258
|
-
if (
|
|
1262
|
+
if (i === "if")
|
|
1259
1263
|
throw V(e, "if requires an expression");
|
|
1260
|
-
if (/^each\s+/.test(
|
|
1264
|
+
if (/^each\s+/.test(i))
|
|
1261
1265
|
throw V(e, "invalid each directive");
|
|
1262
1266
|
return null;
|
|
1263
1267
|
}
|
|
1264
|
-
function
|
|
1268
|
+
function O(t) {
|
|
1265
1269
|
return { start: t.start, end: t.end, raw: t.raw };
|
|
1266
1270
|
}
|
|
1267
|
-
function
|
|
1271
|
+
function W(t, e) {
|
|
1268
1272
|
throw u({
|
|
1269
1273
|
code: "parse_error",
|
|
1270
1274
|
path: t,
|
|
1271
1275
|
details: { message: e }
|
|
1272
1276
|
});
|
|
1273
1277
|
}
|
|
1274
|
-
function
|
|
1278
|
+
function pt(t, e) {
|
|
1275
1279
|
const n = [];
|
|
1276
|
-
for (const
|
|
1277
|
-
const s =
|
|
1280
|
+
for (const r of E(t)) {
|
|
1281
|
+
const s = ft(r.inner, e);
|
|
1278
1282
|
s && n.push({
|
|
1279
|
-
start:
|
|
1280
|
-
end:
|
|
1281
|
-
raw:
|
|
1283
|
+
start: r.start,
|
|
1284
|
+
end: r.end,
|
|
1285
|
+
raw: r.raw,
|
|
1282
1286
|
opener: s
|
|
1283
1287
|
});
|
|
1284
1288
|
}
|
|
1285
1289
|
return n;
|
|
1286
1290
|
}
|
|
1287
|
-
function
|
|
1291
|
+
function Te(t) {
|
|
1288
1292
|
return t.kind === "if" || t.kind === "each";
|
|
1289
1293
|
}
|
|
1290
|
-
function
|
|
1291
|
-
const n =
|
|
1294
|
+
function mt(t, e) {
|
|
1295
|
+
const n = pt(t, e);
|
|
1292
1296
|
if (n.length === 0)
|
|
1293
1297
|
return t.length > 0 ? [{ kind: "text", content: t }] : [];
|
|
1294
|
-
const { nodes:
|
|
1298
|
+
const { nodes: r, nextIndex: s } = B(t, n, 0, n.length, e);
|
|
1295
1299
|
if (s < n.length) {
|
|
1296
|
-
const
|
|
1297
|
-
if (
|
|
1298
|
-
throw
|
|
1299
|
-
if (
|
|
1300
|
-
throw
|
|
1301
|
-
if (
|
|
1302
|
-
throw
|
|
1300
|
+
const i = n[s];
|
|
1301
|
+
if (i.opener.kind === "endif")
|
|
1302
|
+
throw W(e, "endif without matching if");
|
|
1303
|
+
if (i.opener.kind === "endeach")
|
|
1304
|
+
throw W(e, "endeach without matching each");
|
|
1305
|
+
if (i.opener.kind === "else" || i.opener.kind === "else_if")
|
|
1306
|
+
throw W(e, "else without matching if");
|
|
1303
1307
|
}
|
|
1304
|
-
return
|
|
1308
|
+
return r;
|
|
1305
1309
|
}
|
|
1306
|
-
function
|
|
1310
|
+
function B(t, e, n, r, s, i = 0, o) {
|
|
1307
1311
|
const a = o ?? t.length, c = [];
|
|
1308
|
-
let h =
|
|
1309
|
-
for (; l <
|
|
1312
|
+
let h = i, l = n;
|
|
1313
|
+
for (; l < r; ) {
|
|
1310
1314
|
const d = e[l];
|
|
1311
1315
|
if (d.start >= a)
|
|
1312
1316
|
break;
|
|
1313
|
-
if (d.end <=
|
|
1317
|
+
if (d.end <= i) {
|
|
1314
1318
|
l++;
|
|
1315
1319
|
continue;
|
|
1316
1320
|
}
|
|
@@ -1318,51 +1322,51 @@ function j(t, e, n, i, s, r = 0, o) {
|
|
|
1318
1322
|
kind: "text",
|
|
1319
1323
|
content: t.slice(h, d.start)
|
|
1320
1324
|
}), d.opener.kind === "if") {
|
|
1321
|
-
const f =
|
|
1325
|
+
const f = gt(t, e, l, r, s);
|
|
1322
1326
|
c.push(f.node), h = f.endPos, l = f.nextIndex;
|
|
1323
1327
|
continue;
|
|
1324
1328
|
}
|
|
1325
1329
|
if (d.opener.kind === "each") {
|
|
1326
|
-
const f =
|
|
1330
|
+
const f = xt(t, e, l, r, s);
|
|
1327
1331
|
c.push(f.node), h = f.endPos, l = f.nextIndex;
|
|
1328
1332
|
continue;
|
|
1329
1333
|
}
|
|
1330
1334
|
if (d.opener.kind === "else" || d.opener.kind === "else_if")
|
|
1331
|
-
throw
|
|
1335
|
+
throw W(s, "else without matching if");
|
|
1332
1336
|
if (d.opener.kind === "endif")
|
|
1333
|
-
throw
|
|
1337
|
+
throw W(s, "endif without matching if");
|
|
1334
1338
|
if (d.opener.kind === "endeach")
|
|
1335
|
-
throw
|
|
1339
|
+
throw W(s, "endeach without matching each");
|
|
1336
1340
|
l++;
|
|
1337
1341
|
}
|
|
1338
1342
|
return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
|
|
1339
1343
|
}
|
|
1340
|
-
function
|
|
1341
|
-
const
|
|
1342
|
-
if (
|
|
1343
|
-
throw
|
|
1344
|
+
function gt(t, e, n, r, s) {
|
|
1345
|
+
const i = e[n];
|
|
1346
|
+
if (i.opener.kind !== "if")
|
|
1347
|
+
throw W(s, "expected if");
|
|
1344
1348
|
const o = [];
|
|
1345
|
-
let a = n, c =
|
|
1346
|
-
for (; a <
|
|
1349
|
+
let a = n, c = i.end, h = 0;
|
|
1350
|
+
for (; a < r; ) {
|
|
1347
1351
|
const l = e[a];
|
|
1348
1352
|
if (a === n) {
|
|
1349
1353
|
if (l.opener.kind !== "if")
|
|
1350
|
-
throw
|
|
1354
|
+
throw W(s, "expected if");
|
|
1351
1355
|
o.push({
|
|
1352
1356
|
kind: "if",
|
|
1353
1357
|
expr: l.opener.expr,
|
|
1354
|
-
opener:
|
|
1358
|
+
opener: O(l),
|
|
1355
1359
|
body: []
|
|
1356
1360
|
}), a++;
|
|
1357
1361
|
continue;
|
|
1358
1362
|
}
|
|
1359
|
-
if (
|
|
1363
|
+
if (Te(l.opener)) {
|
|
1360
1364
|
h++, a++;
|
|
1361
1365
|
continue;
|
|
1362
1366
|
}
|
|
1363
1367
|
if (l.opener.kind === "endif") {
|
|
1364
1368
|
if (h === 0)
|
|
1365
|
-
return o[o.length - 1].body =
|
|
1369
|
+
return o[o.length - 1].body = B(
|
|
1366
1370
|
t,
|
|
1367
1371
|
e,
|
|
1368
1372
|
n + 1,
|
|
@@ -1371,7 +1375,7 @@ function ft(t, e, n, i, s) {
|
|
|
1371
1375
|
c,
|
|
1372
1376
|
l.start
|
|
1373
1377
|
).nodes, {
|
|
1374
|
-
node: { kind: "if", branches: o, closer:
|
|
1378
|
+
node: { kind: "if", branches: o, closer: O(l) },
|
|
1375
1379
|
nextIndex: a + 1,
|
|
1376
1380
|
endPos: l.end
|
|
1377
1381
|
};
|
|
@@ -1384,7 +1388,7 @@ function ft(t, e, n, i, s) {
|
|
|
1384
1388
|
}
|
|
1385
1389
|
if (h === 0) {
|
|
1386
1390
|
if (l.opener.kind === "else_if") {
|
|
1387
|
-
o[o.length - 1].body =
|
|
1391
|
+
o[o.length - 1].body = B(
|
|
1388
1392
|
t,
|
|
1389
1393
|
e,
|
|
1390
1394
|
n + 1,
|
|
@@ -1395,13 +1399,13 @@ function ft(t, e, n, i, s) {
|
|
|
1395
1399
|
).nodes, o.push({
|
|
1396
1400
|
kind: "else_if",
|
|
1397
1401
|
expr: l.opener.expr,
|
|
1398
|
-
opener:
|
|
1402
|
+
opener: O(l),
|
|
1399
1403
|
body: []
|
|
1400
1404
|
}), c = l.end, a++;
|
|
1401
1405
|
continue;
|
|
1402
1406
|
}
|
|
1403
1407
|
if (l.opener.kind === "else") {
|
|
1404
|
-
o[o.length - 1].body =
|
|
1408
|
+
o[o.length - 1].body = B(
|
|
1405
1409
|
t,
|
|
1406
1410
|
e,
|
|
1407
1411
|
n + 1,
|
|
@@ -1411,7 +1415,7 @@ function ft(t, e, n, i, s) {
|
|
|
1411
1415
|
l.start
|
|
1412
1416
|
).nodes, o.push({
|
|
1413
1417
|
kind: "else",
|
|
1414
|
-
opener:
|
|
1418
|
+
opener: O(l),
|
|
1415
1419
|
body: []
|
|
1416
1420
|
}), c = l.end, a++;
|
|
1417
1421
|
continue;
|
|
@@ -1419,24 +1423,24 @@ function ft(t, e, n, i, s) {
|
|
|
1419
1423
|
}
|
|
1420
1424
|
a++;
|
|
1421
1425
|
}
|
|
1422
|
-
throw
|
|
1426
|
+
throw W(s, "unclosed if block (missing endif)");
|
|
1423
1427
|
}
|
|
1424
|
-
function
|
|
1425
|
-
const
|
|
1426
|
-
if (
|
|
1427
|
-
throw
|
|
1428
|
+
function xt(t, e, n, r, s) {
|
|
1429
|
+
const i = e[n];
|
|
1430
|
+
if (i.opener.kind !== "each")
|
|
1431
|
+
throw W(s, "expected each");
|
|
1428
1432
|
let o = n + 1;
|
|
1429
|
-
const a =
|
|
1433
|
+
const a = i.end;
|
|
1430
1434
|
let c = 0;
|
|
1431
|
-
for (; o <
|
|
1435
|
+
for (; o < r; ) {
|
|
1432
1436
|
const h = e[o];
|
|
1433
|
-
if (
|
|
1437
|
+
if (Te(h.opener)) {
|
|
1434
1438
|
c++, o++;
|
|
1435
1439
|
continue;
|
|
1436
1440
|
}
|
|
1437
1441
|
if (h.opener.kind === "endeach") {
|
|
1438
1442
|
if (c === 0) {
|
|
1439
|
-
const l =
|
|
1443
|
+
const l = B(
|
|
1440
1444
|
t,
|
|
1441
1445
|
e,
|
|
1442
1446
|
n + 1,
|
|
@@ -1448,11 +1452,11 @@ function pt(t, e, n, i, s) {
|
|
|
1448
1452
|
return {
|
|
1449
1453
|
node: {
|
|
1450
1454
|
kind: "each",
|
|
1451
|
-
item:
|
|
1452
|
-
expr:
|
|
1453
|
-
opener:
|
|
1455
|
+
item: i.opener.item,
|
|
1456
|
+
expr: i.opener.expr,
|
|
1457
|
+
opener: O(i),
|
|
1454
1458
|
body: l,
|
|
1455
|
-
closer:
|
|
1459
|
+
closer: O(h)
|
|
1456
1460
|
},
|
|
1457
1461
|
nextIndex: o + 1,
|
|
1458
1462
|
endPos: h.end
|
|
@@ -1467,28 +1471,28 @@ function pt(t, e, n, i, s) {
|
|
|
1467
1471
|
}
|
|
1468
1472
|
o++;
|
|
1469
1473
|
}
|
|
1470
|
-
throw
|
|
1474
|
+
throw W(s, "unclosed each block (missing endeach)");
|
|
1471
1475
|
}
|
|
1472
|
-
const
|
|
1473
|
-
class
|
|
1476
|
+
const pe = 20;
|
|
1477
|
+
class wt {
|
|
1474
1478
|
depth = 0;
|
|
1475
1479
|
get currentDepth() {
|
|
1476
1480
|
return this.depth;
|
|
1477
1481
|
}
|
|
1478
1482
|
enter() {
|
|
1479
|
-
return this.depth >=
|
|
1483
|
+
return this.depth >= pe ? { exceeded: !0, limit: pe } : (this.depth++, { exceeded: !1, depth: this.depth });
|
|
1480
1484
|
}
|
|
1481
1485
|
exit() {
|
|
1482
1486
|
this.depth > 0 && this.depth--;
|
|
1483
1487
|
}
|
|
1484
1488
|
}
|
|
1485
|
-
function
|
|
1489
|
+
function kt(t) {
|
|
1486
1490
|
return !!t;
|
|
1487
1491
|
}
|
|
1488
|
-
function
|
|
1492
|
+
function bt(t) {
|
|
1489
1493
|
return t != null && typeof t[Symbol.iterator] == "function";
|
|
1490
1494
|
}
|
|
1491
|
-
function
|
|
1495
|
+
function Le(t) {
|
|
1492
1496
|
return {
|
|
1493
1497
|
code: "nest_limit_exceeded",
|
|
1494
1498
|
message: "structure nest limit exceeded",
|
|
@@ -1496,49 +1500,49 @@ function $e(t) {
|
|
|
1496
1500
|
details: { limit: 20 }
|
|
1497
1501
|
};
|
|
1498
1502
|
}
|
|
1499
|
-
function
|
|
1503
|
+
function ne(t) {
|
|
1500
1504
|
return t.startsWith(`
|
|
1501
1505
|
`) ? t.slice(1) : t;
|
|
1502
1506
|
}
|
|
1503
|
-
async function
|
|
1504
|
-
const n = e.path,
|
|
1505
|
-
return
|
|
1507
|
+
async function vt(t, e) {
|
|
1508
|
+
const n = e.path, r = e.warnings ?? [], s = mt(t, n), i = new wt();
|
|
1509
|
+
return re(s, e, i, r);
|
|
1506
1510
|
}
|
|
1507
|
-
async function
|
|
1511
|
+
async function re(t, e, n, r) {
|
|
1508
1512
|
const s = e.preserveHgComments === !0;
|
|
1509
|
-
let
|
|
1513
|
+
let i = "", o = !1;
|
|
1510
1514
|
for (const a of t) {
|
|
1511
|
-
let c = await
|
|
1512
|
-
o && (c =
|
|
1515
|
+
let c = await yt(a, e, n, r);
|
|
1516
|
+
o && (c = ne(c)), i += c, o = !s && (a.kind === "if" || a.kind === "each");
|
|
1513
1517
|
}
|
|
1514
|
-
return
|
|
1518
|
+
return i;
|
|
1515
1519
|
}
|
|
1516
|
-
async function
|
|
1520
|
+
async function yt(t, e, n, r) {
|
|
1517
1521
|
switch (t.kind) {
|
|
1518
1522
|
case "text":
|
|
1519
1523
|
return t.content;
|
|
1520
1524
|
case "if":
|
|
1521
|
-
return
|
|
1525
|
+
return _t(t, e, n, r);
|
|
1522
1526
|
case "each":
|
|
1523
|
-
return
|
|
1527
|
+
return St(t, e, n, r);
|
|
1524
1528
|
default:
|
|
1525
1529
|
return "";
|
|
1526
1530
|
}
|
|
1527
1531
|
}
|
|
1528
|
-
async function
|
|
1532
|
+
async function _t(t, e, n, r) {
|
|
1529
1533
|
if (n.enter().exceeded)
|
|
1530
|
-
return
|
|
1534
|
+
return r.push(Le(e.path)), "";
|
|
1531
1535
|
try {
|
|
1532
|
-
let
|
|
1536
|
+
let i = -1;
|
|
1533
1537
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1534
1538
|
const h = t.branches[c];
|
|
1535
1539
|
if (h.kind === "else") {
|
|
1536
|
-
|
|
1540
|
+
i = c;
|
|
1537
1541
|
break;
|
|
1538
1542
|
}
|
|
1539
|
-
const l = await
|
|
1540
|
-
if (
|
|
1541
|
-
|
|
1543
|
+
const l = await k(h.expr, e);
|
|
1544
|
+
if (kt(l)) {
|
|
1545
|
+
i = c;
|
|
1542
1546
|
break;
|
|
1543
1547
|
}
|
|
1544
1548
|
}
|
|
@@ -1546,9 +1550,9 @@ async function bt(t, e, n, i) {
|
|
|
1546
1550
|
let a = "";
|
|
1547
1551
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1548
1552
|
const h = t.branches[c];
|
|
1549
|
-
if (o && (a += h.opener.raw), c ===
|
|
1550
|
-
let l = await
|
|
1551
|
-
o || (l =
|
|
1553
|
+
if (o && (a += h.opener.raw), c === i) {
|
|
1554
|
+
let l = await re(h.body, e, n, r);
|
|
1555
|
+
o || (l = ne(l)), a += l;
|
|
1552
1556
|
}
|
|
1553
1557
|
}
|
|
1554
1558
|
return o && (a += t.closer.raw), a;
|
|
@@ -1556,29 +1560,29 @@ async function bt(t, e, n, i) {
|
|
|
1556
1560
|
n.exit();
|
|
1557
1561
|
}
|
|
1558
1562
|
}
|
|
1559
|
-
async function
|
|
1563
|
+
async function St(t, e, n, r) {
|
|
1560
1564
|
if (n.enter().exceeded)
|
|
1561
|
-
return
|
|
1565
|
+
return r.push(Le(e.path)), "";
|
|
1562
1566
|
try {
|
|
1563
|
-
const
|
|
1564
|
-
if (!
|
|
1567
|
+
const i = await k(t.expr, e);
|
|
1568
|
+
if (!bt(i))
|
|
1565
1569
|
return "";
|
|
1566
1570
|
const o = e.preserveHgComments === !0;
|
|
1567
1571
|
let a = "";
|
|
1568
|
-
for (const c of
|
|
1572
|
+
for (const c of i) {
|
|
1569
1573
|
const h = { ...e.context, [t.item]: c };
|
|
1570
1574
|
o && (a += t.opener.raw);
|
|
1571
|
-
let l = await
|
|
1575
|
+
let l = await re(t.body, {
|
|
1572
1576
|
...e,
|
|
1573
1577
|
context: h
|
|
1574
|
-
}, n,
|
|
1575
|
-
o || (l =
|
|
1576
|
-
const d = await
|
|
1578
|
+
}, n, r);
|
|
1579
|
+
o || (l = ne(l));
|
|
1580
|
+
const d = await We(l, h, {
|
|
1577
1581
|
path: e.path,
|
|
1578
1582
|
registry: e.registry,
|
|
1579
1583
|
loader: e.loader,
|
|
1580
1584
|
rootDir: e.rootDir,
|
|
1581
|
-
warnings:
|
|
1585
|
+
warnings: r,
|
|
1582
1586
|
visitStack: e.visitStack,
|
|
1583
1587
|
parentContext: e.parentContext ?? e.context,
|
|
1584
1588
|
preserveHgComments: e.preserveHgComments,
|
|
@@ -1591,49 +1595,49 @@ async function yt(t, e, n, i) {
|
|
|
1591
1595
|
n.exit();
|
|
1592
1596
|
}
|
|
1593
1597
|
}
|
|
1594
|
-
function Y(t, e, n,
|
|
1595
|
-
return
|
|
1598
|
+
function Y(t, e, n, r, s = !1, i = !1) {
|
|
1599
|
+
return Se(e) ? e : Ce(e, {
|
|
1596
1600
|
rootDir: t,
|
|
1597
|
-
fromPath:
|
|
1601
|
+
fromPath: r,
|
|
1598
1602
|
documentPath: n,
|
|
1599
1603
|
constrainToRoot: s,
|
|
1600
|
-
hyogenPath:
|
|
1604
|
+
hyogenPath: i
|
|
1601
1605
|
});
|
|
1602
1606
|
}
|
|
1603
|
-
function
|
|
1607
|
+
function Me(t) {
|
|
1604
1608
|
let e = 0;
|
|
1605
1609
|
for (let n = t.length - 1; n >= 0 && t[n] === `
|
|
1606
1610
|
`; n--)
|
|
1607
1611
|
e++;
|
|
1608
1612
|
return e;
|
|
1609
1613
|
}
|
|
1610
|
-
function
|
|
1614
|
+
function Oe(t) {
|
|
1611
1615
|
let e = 0;
|
|
1612
1616
|
for (; e < t.length && t[e] === `
|
|
1613
1617
|
`; )
|
|
1614
1618
|
e++;
|
|
1615
1619
|
return e;
|
|
1616
1620
|
}
|
|
1617
|
-
function
|
|
1618
|
-
const n =
|
|
1621
|
+
function T(t, e) {
|
|
1622
|
+
const n = Me(t), r = Oe(e), s = Math.max(n, r);
|
|
1619
1623
|
return t.slice(0, t.length - n) + `
|
|
1620
|
-
`.repeat(s) + e.slice(
|
|
1624
|
+
`.repeat(s) + e.slice(r);
|
|
1621
1625
|
}
|
|
1622
1626
|
function ie(t, e) {
|
|
1623
|
-
const n =
|
|
1624
|
-
return n +
|
|
1627
|
+
const n = Me(t), r = Oe(e);
|
|
1628
|
+
return n + r - Math.max(n, r);
|
|
1625
1629
|
}
|
|
1626
|
-
function
|
|
1627
|
-
const
|
|
1628
|
-
if (
|
|
1630
|
+
function me(t, e, n) {
|
|
1631
|
+
const r = t.indexOf(e);
|
|
1632
|
+
if (r < 0)
|
|
1629
1633
|
return t;
|
|
1630
|
-
const s = t.slice(0,
|
|
1631
|
-
return
|
|
1634
|
+
const s = t.slice(0, r), i = t.slice(r + e.length);
|
|
1635
|
+
return T(T(s, n), i);
|
|
1632
1636
|
}
|
|
1633
|
-
async function
|
|
1637
|
+
async function Ct(t) {
|
|
1634
1638
|
let e = t.source;
|
|
1635
1639
|
for (const n of t.directives) {
|
|
1636
|
-
const
|
|
1640
|
+
const r = Y(
|
|
1637
1641
|
t.root,
|
|
1638
1642
|
n.path,
|
|
1639
1643
|
t.path,
|
|
@@ -1642,47 +1646,47 @@ async function vt(t) {
|
|
|
1642
1646
|
!0
|
|
1643
1647
|
);
|
|
1644
1648
|
if (t.visitStack) {
|
|
1645
|
-
const s = t.visitStack.check(
|
|
1649
|
+
const s = t.visitStack.check(r);
|
|
1646
1650
|
if (s.circular) {
|
|
1647
1651
|
t.warnings?.push({
|
|
1648
1652
|
code: "circular_include",
|
|
1649
|
-
message:
|
|
1650
|
-
path:
|
|
1653
|
+
message: R("circular_include", {
|
|
1654
|
+
path: r,
|
|
1651
1655
|
from: s.from,
|
|
1652
1656
|
via: "include"
|
|
1653
1657
|
}),
|
|
1654
1658
|
path: t.path,
|
|
1655
1659
|
details: {
|
|
1656
|
-
path:
|
|
1660
|
+
path: r,
|
|
1657
1661
|
from: s.from,
|
|
1658
1662
|
via: "include"
|
|
1659
1663
|
}
|
|
1660
|
-
}), e =
|
|
1664
|
+
}), e = me(e, n.marker, "");
|
|
1661
1665
|
continue;
|
|
1662
1666
|
}
|
|
1663
|
-
t.visitStack.push(
|
|
1667
|
+
t.visitStack.push(r);
|
|
1664
1668
|
}
|
|
1665
1669
|
try {
|
|
1666
|
-
const s = await t.loader(
|
|
1670
|
+
const s = await t.loader(r), i = await fn(s, {
|
|
1667
1671
|
context: t.context,
|
|
1668
1672
|
loader: t.loader,
|
|
1669
1673
|
root: t.root,
|
|
1670
|
-
path:
|
|
1674
|
+
path: r,
|
|
1671
1675
|
preserveFrontMatter: t.preserveFrontMatter,
|
|
1672
1676
|
preserveHgComments: t.preserveHgComments,
|
|
1673
1677
|
visitStack: t.visitStack,
|
|
1674
1678
|
warnings: t.warnings,
|
|
1675
1679
|
registry: t.registry
|
|
1676
1680
|
}), o = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1677
|
-
${
|
|
1678
|
-
e =
|
|
1681
|
+
${i}` : i;
|
|
1682
|
+
e = me(e, n.marker, o);
|
|
1679
1683
|
} finally {
|
|
1680
1684
|
t.visitStack?.pop();
|
|
1681
1685
|
}
|
|
1682
1686
|
}
|
|
1683
1687
|
return e;
|
|
1684
1688
|
}
|
|
1685
|
-
class
|
|
1689
|
+
class Re {
|
|
1686
1690
|
stack = [];
|
|
1687
1691
|
check(e) {
|
|
1688
1692
|
return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
|
|
@@ -1698,30 +1702,30 @@ class Le {
|
|
|
1698
1702
|
this.stack.pop();
|
|
1699
1703
|
}
|
|
1700
1704
|
}
|
|
1701
|
-
async function
|
|
1702
|
-
const { path:
|
|
1705
|
+
async function Wt(t, e, n = {}) {
|
|
1706
|
+
const { path: r, constBindings: s = /* @__PURE__ */ new Set() } = n, i = await k(t.expr, { context: e, path: r });
|
|
1703
1707
|
switch (t.kind) {
|
|
1704
1708
|
case "const": {
|
|
1705
1709
|
if (s.has(t.name))
|
|
1706
1710
|
throw u({
|
|
1707
1711
|
code: "parse_error",
|
|
1708
|
-
path:
|
|
1712
|
+
path: r,
|
|
1709
1713
|
details: {
|
|
1710
1714
|
message: `cannot reassign const binding: ${t.name}`
|
|
1711
1715
|
}
|
|
1712
1716
|
});
|
|
1713
|
-
e[t.name] =
|
|
1717
|
+
e[t.name] = i, s.add(t.name);
|
|
1714
1718
|
break;
|
|
1715
1719
|
}
|
|
1716
1720
|
case "let": {
|
|
1717
|
-
e[t.name] =
|
|
1721
|
+
e[t.name] = i;
|
|
1718
1722
|
break;
|
|
1719
1723
|
}
|
|
1720
1724
|
case "assign": {
|
|
1721
1725
|
if (s.has(t.name))
|
|
1722
1726
|
throw u({
|
|
1723
1727
|
code: "parse_error",
|
|
1724
|
-
path:
|
|
1728
|
+
path: r,
|
|
1725
1729
|
details: {
|
|
1726
1730
|
message: `cannot reassign const binding: ${t.name}`
|
|
1727
1731
|
}
|
|
@@ -1729,33 +1733,33 @@ async function _t(t, e, n = {}) {
|
|
|
1729
1733
|
if (!(t.name in e))
|
|
1730
1734
|
throw u({
|
|
1731
1735
|
code: "parse_error",
|
|
1732
|
-
path:
|
|
1736
|
+
path: r,
|
|
1733
1737
|
details: {
|
|
1734
1738
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1735
1739
|
}
|
|
1736
1740
|
});
|
|
1737
|
-
e[t.name] =
|
|
1741
|
+
e[t.name] = i;
|
|
1738
1742
|
break;
|
|
1739
1743
|
}
|
|
1740
1744
|
}
|
|
1741
1745
|
}
|
|
1742
|
-
function
|
|
1746
|
+
function ge(t) {
|
|
1743
1747
|
return !t;
|
|
1744
1748
|
}
|
|
1745
|
-
async function
|
|
1746
|
-
const { path:
|
|
1749
|
+
async function N(t, e, n = {}) {
|
|
1750
|
+
const { path: r, constBindings: s = /* @__PURE__ */ new Set(), onUpdate: i, echoChunks: o } = n;
|
|
1747
1751
|
switch (t.kind) {
|
|
1748
1752
|
case "const":
|
|
1749
1753
|
case "let":
|
|
1750
1754
|
case "assign": {
|
|
1751
|
-
await
|
|
1755
|
+
await Wt(t, e, { path: r, constBindings: s }), i?.(t.name);
|
|
1752
1756
|
return;
|
|
1753
1757
|
}
|
|
1754
1758
|
case "update": {
|
|
1755
1759
|
if (s.has(t.name))
|
|
1756
1760
|
throw u({
|
|
1757
1761
|
code: "parse_error",
|
|
1758
|
-
path:
|
|
1762
|
+
path: r,
|
|
1759
1763
|
details: {
|
|
1760
1764
|
message: `cannot reassign const binding: ${t.name}`
|
|
1761
1765
|
}
|
|
@@ -1763,20 +1767,20 @@ async function B(t, e, n = {}) {
|
|
|
1763
1767
|
if (!(t.name in e))
|
|
1764
1768
|
throw u({
|
|
1765
1769
|
code: "parse_error",
|
|
1766
|
-
path:
|
|
1770
|
+
path: r,
|
|
1767
1771
|
details: {
|
|
1768
1772
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1769
1773
|
}
|
|
1770
1774
|
});
|
|
1771
|
-
const
|
|
1772
|
-
e[t.name] =
|
|
1775
|
+
const a = Number(e[t.name]), c = t.op === "++" ? a + 1 : a - 1;
|
|
1776
|
+
e[t.name] = c, i?.(t.name);
|
|
1773
1777
|
return;
|
|
1774
1778
|
}
|
|
1775
1779
|
case "compound_assign": {
|
|
1776
1780
|
if (s.has(t.name))
|
|
1777
1781
|
throw u({
|
|
1778
1782
|
code: "parse_error",
|
|
1779
|
-
path:
|
|
1783
|
+
path: r,
|
|
1780
1784
|
details: {
|
|
1781
1785
|
message: `cannot reassign const binding: ${t.name}`
|
|
1782
1786
|
}
|
|
@@ -1784,64 +1788,72 @@ async function B(t, e, n = {}) {
|
|
|
1784
1788
|
if (!(t.name in e))
|
|
1785
1789
|
throw u({
|
|
1786
1790
|
code: "parse_error",
|
|
1787
|
-
path:
|
|
1791
|
+
path: r,
|
|
1788
1792
|
details: {
|
|
1789
1793
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1790
1794
|
}
|
|
1791
1795
|
});
|
|
1792
|
-
const
|
|
1793
|
-
let
|
|
1796
|
+
const a = await k(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
|
|
1797
|
+
let l;
|
|
1794
1798
|
switch (t.op) {
|
|
1795
1799
|
case "+=":
|
|
1796
|
-
|
|
1800
|
+
l = c + h;
|
|
1797
1801
|
break;
|
|
1798
1802
|
case "-=":
|
|
1799
|
-
|
|
1803
|
+
l = c - h;
|
|
1800
1804
|
break;
|
|
1801
1805
|
case "*=":
|
|
1802
|
-
|
|
1806
|
+
l = c * h;
|
|
1803
1807
|
break;
|
|
1804
1808
|
case "/=":
|
|
1805
|
-
|
|
1809
|
+
l = c / h;
|
|
1806
1810
|
break;
|
|
1807
1811
|
}
|
|
1808
|
-
e[t.name] =
|
|
1812
|
+
e[t.name] = l, i?.(t.name);
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
case "echo": {
|
|
1816
|
+
const a = await k(t.expr, {
|
|
1817
|
+
context: e,
|
|
1818
|
+
path: r
|
|
1819
|
+
}), c = a == null ? "" : String(a);
|
|
1820
|
+
o?.push(c);
|
|
1809
1821
|
return;
|
|
1810
1822
|
}
|
|
1811
1823
|
case "for": {
|
|
1812
|
-
for (t.init && await
|
|
1813
|
-
const
|
|
1824
|
+
for (t.init && await N(t.init, e, n); ; ) {
|
|
1825
|
+
const a = await k(t.cond, {
|
|
1814
1826
|
context: e,
|
|
1815
|
-
path:
|
|
1827
|
+
path: r
|
|
1816
1828
|
});
|
|
1817
|
-
if (
|
|
1829
|
+
if (ge(a))
|
|
1818
1830
|
break;
|
|
1819
|
-
for (const
|
|
1820
|
-
await
|
|
1821
|
-
t.update && await
|
|
1831
|
+
for (const c of t.body)
|
|
1832
|
+
await N(c, e, n);
|
|
1833
|
+
t.update && await N(t.update, e, n);
|
|
1822
1834
|
}
|
|
1823
1835
|
return;
|
|
1824
1836
|
}
|
|
1825
1837
|
case "do_while": {
|
|
1826
1838
|
do {
|
|
1827
|
-
for (const
|
|
1828
|
-
await
|
|
1829
|
-
const
|
|
1839
|
+
for (const c of t.body)
|
|
1840
|
+
await N(c, e, n);
|
|
1841
|
+
const a = await k(t.cond, {
|
|
1830
1842
|
context: e,
|
|
1831
|
-
path:
|
|
1843
|
+
path: r
|
|
1832
1844
|
});
|
|
1833
|
-
if (
|
|
1845
|
+
if (ge(a))
|
|
1834
1846
|
break;
|
|
1835
1847
|
} while (!0);
|
|
1836
1848
|
return;
|
|
1837
1849
|
}
|
|
1838
1850
|
}
|
|
1839
1851
|
}
|
|
1840
|
-
async function
|
|
1841
|
-
for (const
|
|
1842
|
-
await
|
|
1852
|
+
async function xe(t, e, n = {}) {
|
|
1853
|
+
for (const r of t)
|
|
1854
|
+
await N(r, e, n);
|
|
1843
1855
|
}
|
|
1844
|
-
const
|
|
1856
|
+
const At = /* @__PURE__ */ new Set([
|
|
1845
1857
|
"if",
|
|
1846
1858
|
"else",
|
|
1847
1859
|
"endif",
|
|
@@ -1857,25 +1869,26 @@ const St = /* @__PURE__ */ new Set([
|
|
|
1857
1869
|
"extend",
|
|
1858
1870
|
"include",
|
|
1859
1871
|
"component",
|
|
1860
|
-
"as"
|
|
1872
|
+
"as",
|
|
1873
|
+
"echo"
|
|
1861
1874
|
]);
|
|
1862
|
-
function
|
|
1863
|
-
return
|
|
1875
|
+
function De(t) {
|
|
1876
|
+
return At.has(t);
|
|
1864
1877
|
}
|
|
1865
|
-
function
|
|
1866
|
-
let e = "", n = 0,
|
|
1878
|
+
function se(t) {
|
|
1879
|
+
let e = "", n = 0, r = null;
|
|
1867
1880
|
for (; n < t.length; ) {
|
|
1868
1881
|
const s = t[n];
|
|
1869
|
-
if (
|
|
1882
|
+
if (r) {
|
|
1870
1883
|
if (e += s, s === "\\" && n + 1 < t.length) {
|
|
1871
1884
|
e += t[++n], n++;
|
|
1872
1885
|
continue;
|
|
1873
1886
|
}
|
|
1874
|
-
s ===
|
|
1887
|
+
s === r && (r = null), n++;
|
|
1875
1888
|
continue;
|
|
1876
1889
|
}
|
|
1877
1890
|
if (s === '"' || s === "'" || s === "`") {
|
|
1878
|
-
|
|
1891
|
+
r = s, e += s, n++;
|
|
1879
1892
|
continue;
|
|
1880
1893
|
}
|
|
1881
1894
|
if (t.startsWith("//", n)) {
|
|
@@ -1885,42 +1898,42 @@ function re(t) {
|
|
|
1885
1898
|
continue;
|
|
1886
1899
|
}
|
|
1887
1900
|
if (t.startsWith("/*", n)) {
|
|
1888
|
-
const
|
|
1889
|
-
if (
|
|
1901
|
+
const i = t.indexOf("*/", n + 2);
|
|
1902
|
+
if (i === -1)
|
|
1890
1903
|
break;
|
|
1891
|
-
n =
|
|
1904
|
+
n = i + 2;
|
|
1892
1905
|
continue;
|
|
1893
1906
|
}
|
|
1894
1907
|
e += s, n++;
|
|
1895
1908
|
}
|
|
1896
1909
|
return e;
|
|
1897
1910
|
}
|
|
1898
|
-
function
|
|
1911
|
+
function w(t, e) {
|
|
1899
1912
|
throw u({
|
|
1900
1913
|
code: "parse_error",
|
|
1901
1914
|
path: t,
|
|
1902
1915
|
details: { message: e }
|
|
1903
1916
|
});
|
|
1904
1917
|
}
|
|
1905
|
-
function
|
|
1906
|
-
const n =
|
|
1918
|
+
function we(t, e) {
|
|
1919
|
+
const n = se(t).trim();
|
|
1907
1920
|
if (n.length === 0)
|
|
1908
|
-
throw
|
|
1909
|
-
const
|
|
1910
|
-
if (
|
|
1911
|
-
throw
|
|
1921
|
+
throw w(e, "empty statement block");
|
|
1922
|
+
const r = new oe(n, e), s = r.parseStatementList();
|
|
1923
|
+
if (r.skipWhitespace(), r.hasMore())
|
|
1924
|
+
throw w(
|
|
1912
1925
|
e,
|
|
1913
|
-
`unexpected token at position ${
|
|
1926
|
+
`unexpected token at position ${r.position}`
|
|
1914
1927
|
);
|
|
1915
1928
|
if (s.length === 0)
|
|
1916
|
-
throw
|
|
1929
|
+
throw w(e, "empty statement block");
|
|
1917
1930
|
return s;
|
|
1918
1931
|
}
|
|
1919
|
-
function
|
|
1920
|
-
const e =
|
|
1921
|
-
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^for\s*\(/.test(e) || /^do\b/.test(e) || /^(\+\+|--)/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*(\+\+|--|[+\-*/]=|=)/.test(e);
|
|
1932
|
+
function He(t) {
|
|
1933
|
+
const e = se(t).trim();
|
|
1934
|
+
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^echo\b/.test(e) || /^for\s*\(/.test(e) || /^do\b/.test(e) || /^(\+\+|--)/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*(\+\+|--|[+\-*/]=|=)/.test(e);
|
|
1922
1935
|
}
|
|
1923
|
-
class
|
|
1936
|
+
class oe {
|
|
1924
1937
|
constructor(e, n) {
|
|
1925
1938
|
this.input = e, this.path = n;
|
|
1926
1939
|
}
|
|
@@ -1949,11 +1962,11 @@ class se {
|
|
|
1949
1962
|
if (this.matchWord("do"))
|
|
1950
1963
|
return this.parseDoWhile();
|
|
1951
1964
|
if (this.matchWord("while"))
|
|
1952
|
-
throw
|
|
1965
|
+
throw w(
|
|
1953
1966
|
this.path,
|
|
1954
1967
|
"bare while loops are not allowed (use do…while)"
|
|
1955
1968
|
);
|
|
1956
|
-
return this.parseSimpleStatement();
|
|
1969
|
+
return this.matchWord("echo") ? this.parseEcho() : this.parseSimpleStatement();
|
|
1957
1970
|
}
|
|
1958
1971
|
parseSimpleStatement() {
|
|
1959
1972
|
this.skipWhitespace();
|
|
@@ -1966,24 +1979,24 @@ class se {
|
|
|
1966
1979
|
return this.parseBindingDeclaration("let");
|
|
1967
1980
|
const n = this.readIdentifier();
|
|
1968
1981
|
if (!n)
|
|
1969
|
-
throw
|
|
1982
|
+
throw w(this.path, "expected statement");
|
|
1970
1983
|
if (this.assertAssignableName(n), this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
1971
1984
|
const s = this.input.slice(this.index - 2, this.index);
|
|
1972
1985
|
return { kind: "update", name: n, op: s, position: "postfix" };
|
|
1973
1986
|
}
|
|
1974
|
-
const
|
|
1975
|
-
if (
|
|
1987
|
+
const r = this.readCompoundOp();
|
|
1988
|
+
if (r) {
|
|
1976
1989
|
const s = this.readExpressionSourceUntilTerminator();
|
|
1977
1990
|
return {
|
|
1978
1991
|
kind: "compound_assign",
|
|
1979
1992
|
name: n,
|
|
1980
|
-
op:
|
|
1993
|
+
op: r,
|
|
1981
1994
|
expr: C(s, this.path)
|
|
1982
1995
|
};
|
|
1983
1996
|
}
|
|
1984
1997
|
if (this.match("=")) {
|
|
1985
1998
|
if (this.peek() === "=")
|
|
1986
|
-
throw
|
|
1999
|
+
throw w(this.path, "unexpected '==' in assignment");
|
|
1987
2000
|
const s = this.readExpressionSourceUntilTerminator();
|
|
1988
2001
|
return {
|
|
1989
2002
|
kind: "assign",
|
|
@@ -1991,13 +2004,21 @@ class se {
|
|
|
1991
2004
|
expr: C(s, this.path)
|
|
1992
2005
|
};
|
|
1993
2006
|
}
|
|
1994
|
-
throw
|
|
2007
|
+
throw w(this.path, `invalid statement starting with: ${n}`);
|
|
2008
|
+
}
|
|
2009
|
+
parseEcho() {
|
|
2010
|
+
this.skipWhitespace();
|
|
2011
|
+
const e = this.readExpressionSourceUntilTerminator();
|
|
2012
|
+
return {
|
|
2013
|
+
kind: "echo",
|
|
2014
|
+
expr: C(e, this.path)
|
|
2015
|
+
};
|
|
1995
2016
|
}
|
|
1996
2017
|
readPrefixUpdate() {
|
|
1997
2018
|
if (this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
1998
2019
|
const e = this.input.slice(this.index - 2, this.index), n = this.readIdentifier();
|
|
1999
2020
|
if (!n)
|
|
2000
|
-
throw
|
|
2021
|
+
throw w(this.path, `expected identifier after ${e}`);
|
|
2001
2022
|
return this.assertAssignableName(n), { kind: "update", name: n, op: e, position: "prefix" };
|
|
2002
2023
|
}
|
|
2003
2024
|
return null;
|
|
@@ -2005,69 +2026,69 @@ class se {
|
|
|
2005
2026
|
parseBindingDeclaration(e) {
|
|
2006
2027
|
const n = this.readIdentifier();
|
|
2007
2028
|
if (!n)
|
|
2008
|
-
throw
|
|
2029
|
+
throw w(this.path, `expected identifier after ${e}`);
|
|
2009
2030
|
if (this.assertAssignableName(n), this.skipWhitespace(), !this.match("="))
|
|
2010
|
-
throw
|
|
2011
|
-
const
|
|
2031
|
+
throw w(this.path, `expected '=' in ${e} declaration`);
|
|
2032
|
+
const r = this.readExpressionSourceUntilTerminator();
|
|
2012
2033
|
return {
|
|
2013
2034
|
kind: e,
|
|
2014
2035
|
name: n,
|
|
2015
|
-
expr: C(
|
|
2036
|
+
expr: C(r, this.path)
|
|
2016
2037
|
};
|
|
2017
2038
|
}
|
|
2018
2039
|
parseFor() {
|
|
2019
2040
|
if (this.skipWhitespace(), !this.match("("))
|
|
2020
|
-
throw
|
|
2021
|
-
const e = this.readBalanced(")"), n =
|
|
2041
|
+
throw w(this.path, "expected '(' after for");
|
|
2042
|
+
const e = this.readBalanced(")"), n = $t(e);
|
|
2022
2043
|
if (n.length !== 3)
|
|
2023
|
-
throw
|
|
2044
|
+
throw w(
|
|
2024
2045
|
this.path,
|
|
2025
2046
|
"for…of / for…in are not allowed; use for (init; cond; update)"
|
|
2026
2047
|
);
|
|
2027
|
-
const [
|
|
2048
|
+
const [r, s, i] = n;
|
|
2028
2049
|
if (s.trim().length === 0)
|
|
2029
|
-
throw
|
|
2030
|
-
if (/^\s*[A-Za-z_$][A-Za-z0-9_$]*\s+(of|in)\s+/.test(
|
|
2031
|
-
throw
|
|
2050
|
+
throw w(this.path, "for loop condition cannot be empty");
|
|
2051
|
+
if (/^\s*[A-Za-z_$][A-Za-z0-9_$]*\s+(of|in)\s+/.test(r))
|
|
2052
|
+
throw w(
|
|
2032
2053
|
this.path,
|
|
2033
2054
|
"for…of / for…in are not allowed; use for (init; cond; update)"
|
|
2034
2055
|
);
|
|
2035
|
-
const o =
|
|
2056
|
+
const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a = C(s.trim(), this.path), c = i.trim().length === 0 ? null : this.parseClauseStatement(i.trim());
|
|
2036
2057
|
if (this.skipWhitespace(), !this.match("{"))
|
|
2037
|
-
throw
|
|
2058
|
+
throw w(this.path, "expected '{' after for (...)");
|
|
2038
2059
|
const h = this.parseStatementList();
|
|
2039
2060
|
if (this.skipWhitespace(), !this.match("}"))
|
|
2040
|
-
throw
|
|
2061
|
+
throw w(this.path, "expected '}' to close for body");
|
|
2041
2062
|
return { kind: "for", init: o, cond: a, update: c, body: h };
|
|
2042
2063
|
}
|
|
2043
2064
|
parseDoWhile() {
|
|
2044
2065
|
if (this.skipWhitespace(), !this.match("{"))
|
|
2045
|
-
throw
|
|
2066
|
+
throw w(this.path, "expected '{' after do");
|
|
2046
2067
|
const e = this.parseStatementList();
|
|
2047
2068
|
if (this.skipWhitespace(), !this.match("}"))
|
|
2048
|
-
throw
|
|
2069
|
+
throw w(this.path, "expected '}' to close do body");
|
|
2049
2070
|
if (this.skipWhitespace(), !this.matchWord("while"))
|
|
2050
|
-
throw
|
|
2071
|
+
throw w(this.path, "expected 'while' after do body");
|
|
2051
2072
|
if (this.skipWhitespace(), !this.match("("))
|
|
2052
|
-
throw
|
|
2073
|
+
throw w(this.path, "expected '(' after while");
|
|
2053
2074
|
const n = this.readBalanced(")");
|
|
2054
2075
|
if (n.trim().length === 0)
|
|
2055
|
-
throw
|
|
2056
|
-
const
|
|
2057
|
-
return { kind: "do_while", body: e, cond:
|
|
2076
|
+
throw w(this.path, "do…while condition cannot be empty");
|
|
2077
|
+
const r = C(n.trim(), this.path);
|
|
2078
|
+
return { kind: "do_while", body: e, cond: r };
|
|
2058
2079
|
}
|
|
2059
2080
|
parseClauseStatement(e) {
|
|
2060
|
-
const n = new
|
|
2081
|
+
const n = new oe(e, this.path), r = n.parseSimpleStatement();
|
|
2061
2082
|
if (n.skipWhitespace(), n.hasMore())
|
|
2062
|
-
throw
|
|
2083
|
+
throw w(
|
|
2063
2084
|
this.path,
|
|
2064
2085
|
`unexpected token in for clause at position ${n.position}`
|
|
2065
2086
|
);
|
|
2066
|
-
return
|
|
2087
|
+
return r;
|
|
2067
2088
|
}
|
|
2068
2089
|
assertAssignableName(e) {
|
|
2069
|
-
if (
|
|
2070
|
-
throw
|
|
2090
|
+
if (De(e))
|
|
2091
|
+
throw w(
|
|
2071
2092
|
this.path,
|
|
2072
2093
|
`reserved word cannot be used as identifier: ${e}`
|
|
2073
2094
|
);
|
|
@@ -2075,61 +2096,61 @@ class se {
|
|
|
2075
2096
|
readExpressionSourceUntilTerminator() {
|
|
2076
2097
|
this.skipWhitespace();
|
|
2077
2098
|
const e = this.index;
|
|
2078
|
-
let n = 0,
|
|
2099
|
+
let n = 0, r = 0, s = 0, i = null;
|
|
2079
2100
|
for (; this.index < this.input.length; ) {
|
|
2080
2101
|
const a = this.input[this.index];
|
|
2081
|
-
if (
|
|
2102
|
+
if (i) {
|
|
2082
2103
|
if (a === "\\") {
|
|
2083
2104
|
this.index += 2;
|
|
2084
2105
|
continue;
|
|
2085
2106
|
}
|
|
2086
|
-
a ===
|
|
2107
|
+
a === i && (i = null), this.index++;
|
|
2087
2108
|
continue;
|
|
2088
2109
|
}
|
|
2089
2110
|
if (a === '"' || a === "'" || a === "`") {
|
|
2090
|
-
|
|
2111
|
+
i = a, this.index++;
|
|
2091
2112
|
continue;
|
|
2092
2113
|
}
|
|
2093
|
-
if (a === "(" && n++, a === ")" && (n = Math.max(0, n - 1)), a === "{" &&
|
|
2094
|
-
if (
|
|
2114
|
+
if (a === "(" && n++, a === ")" && (n = Math.max(0, n - 1)), a === "{" && r++, a === "}") {
|
|
2115
|
+
if (r === 0 && n === 0 && s === 0)
|
|
2095
2116
|
break;
|
|
2096
|
-
|
|
2117
|
+
r = Math.max(0, r - 1);
|
|
2097
2118
|
}
|
|
2098
2119
|
if (a === "[" && s++, a === "]" && (s = Math.max(0, s - 1)), (a === ";" || a === `
|
|
2099
|
-
`) && n === 0 &&
|
|
2120
|
+
`) && n === 0 && r === 0 && s === 0)
|
|
2100
2121
|
break;
|
|
2101
2122
|
this.index++;
|
|
2102
2123
|
}
|
|
2103
2124
|
const o = this.input.slice(e, this.index).trim();
|
|
2104
2125
|
if (o.length === 0)
|
|
2105
|
-
throw
|
|
2126
|
+
throw w(this.path, "expected expression");
|
|
2106
2127
|
return o;
|
|
2107
2128
|
}
|
|
2108
2129
|
readBalanced(e) {
|
|
2109
2130
|
const n = e === ")" ? "(" : "{";
|
|
2110
|
-
let
|
|
2131
|
+
let r = 1;
|
|
2111
2132
|
const s = this.index;
|
|
2112
|
-
let
|
|
2133
|
+
let i = null;
|
|
2113
2134
|
for (; this.index < this.input.length; ) {
|
|
2114
2135
|
const o = this.input[this.index];
|
|
2115
|
-
if (
|
|
2136
|
+
if (i) {
|
|
2116
2137
|
if (o === "\\") {
|
|
2117
2138
|
this.index += 2;
|
|
2118
2139
|
continue;
|
|
2119
2140
|
}
|
|
2120
|
-
o ===
|
|
2141
|
+
o === i && (i = null), this.index++;
|
|
2121
2142
|
continue;
|
|
2122
2143
|
}
|
|
2123
2144
|
if (o === '"' || o === "'" || o === "`") {
|
|
2124
|
-
|
|
2145
|
+
i = o, this.index++;
|
|
2125
2146
|
continue;
|
|
2126
2147
|
}
|
|
2127
2148
|
if (o === n) {
|
|
2128
|
-
|
|
2149
|
+
r++, this.index++;
|
|
2129
2150
|
continue;
|
|
2130
2151
|
}
|
|
2131
2152
|
if (o === e) {
|
|
2132
|
-
if (
|
|
2153
|
+
if (r--, r === 0) {
|
|
2133
2154
|
const a = this.input.slice(s, this.index);
|
|
2134
2155
|
return this.index++, a;
|
|
2135
2156
|
}
|
|
@@ -2138,7 +2159,7 @@ class se {
|
|
|
2138
2159
|
}
|
|
2139
2160
|
this.index++;
|
|
2140
2161
|
}
|
|
2141
|
-
throw
|
|
2162
|
+
throw w(this.path, `expected '${e}'`);
|
|
2142
2163
|
}
|
|
2143
2164
|
readCompoundOp() {
|
|
2144
2165
|
this.skipWhitespace();
|
|
@@ -2173,14 +2194,14 @@ class se {
|
|
|
2173
2194
|
return this.input.slice(e, this.index);
|
|
2174
2195
|
}
|
|
2175
2196
|
}
|
|
2176
|
-
function
|
|
2197
|
+
function $t(t) {
|
|
2177
2198
|
const e = [];
|
|
2178
|
-
let n = "",
|
|
2179
|
-
for (let
|
|
2180
|
-
const o = t[
|
|
2199
|
+
let n = "", r = 0, s = null;
|
|
2200
|
+
for (let i = 0; i < t.length; i++) {
|
|
2201
|
+
const o = t[i];
|
|
2181
2202
|
if (s) {
|
|
2182
|
-
if (n += o, o === "\\" &&
|
|
2183
|
-
n += t[++
|
|
2203
|
+
if (n += o, o === "\\" && i + 1 < t.length) {
|
|
2204
|
+
n += t[++i];
|
|
2184
2205
|
continue;
|
|
2185
2206
|
}
|
|
2186
2207
|
o === s && (s = null);
|
|
@@ -2191,14 +2212,14 @@ function Ct(t) {
|
|
|
2191
2212
|
continue;
|
|
2192
2213
|
}
|
|
2193
2214
|
if (o === "(" || o === "[" || o === "{") {
|
|
2194
|
-
|
|
2215
|
+
r++, n += o;
|
|
2195
2216
|
continue;
|
|
2196
2217
|
}
|
|
2197
2218
|
if (o === ")" || o === "]" || o === "}") {
|
|
2198
|
-
|
|
2219
|
+
r = Math.max(0, r - 1), n += o;
|
|
2199
2220
|
continue;
|
|
2200
2221
|
}
|
|
2201
|
-
if (o === ";" &&
|
|
2222
|
+
if (o === ";" && r === 0) {
|
|
2202
2223
|
e.push(n), n = "";
|
|
2203
2224
|
continue;
|
|
2204
2225
|
}
|
|
@@ -2206,7 +2227,7 @@ function Ct(t) {
|
|
|
2206
2227
|
}
|
|
2207
2228
|
return e.push(n), e;
|
|
2208
2229
|
}
|
|
2209
|
-
function
|
|
2230
|
+
function ae(t, e) {
|
|
2210
2231
|
const n = t.trim();
|
|
2211
2232
|
if (!/^extend\b/i.test(n)) return null;
|
|
2212
2233
|
if (!/^extend\s+/i.test(n))
|
|
@@ -2215,14 +2236,14 @@ function oe(t, e) {
|
|
|
2215
2236
|
path: e,
|
|
2216
2237
|
details: { message: "missing extend path" }
|
|
2217
2238
|
});
|
|
2218
|
-
const
|
|
2219
|
-
if (!
|
|
2239
|
+
const r = /^extend\s+(\S+)\s*$/.exec(n);
|
|
2240
|
+
if (!r)
|
|
2220
2241
|
throw u({
|
|
2221
2242
|
code: "parse_error",
|
|
2222
2243
|
path: e,
|
|
2223
2244
|
details: { message: "invalid extend directive" }
|
|
2224
2245
|
});
|
|
2225
|
-
const s =
|
|
2246
|
+
const s = r[1];
|
|
2226
2247
|
if (s.length === 0)
|
|
2227
2248
|
throw u({
|
|
2228
2249
|
code: "parse_error",
|
|
@@ -2231,13 +2252,13 @@ function oe(t, e) {
|
|
|
2231
2252
|
});
|
|
2232
2253
|
return { path: s };
|
|
2233
2254
|
}
|
|
2234
|
-
function
|
|
2235
|
-
const n =
|
|
2255
|
+
function Et(t, e) {
|
|
2256
|
+
const n = A(t);
|
|
2236
2257
|
if (n.length === 0) return null;
|
|
2237
|
-
const
|
|
2258
|
+
const r = n[0], s = ae(r, e);
|
|
2238
2259
|
if (!s) return null;
|
|
2239
|
-
for (const
|
|
2240
|
-
if (/^extend\s+/i.test(
|
|
2260
|
+
for (const i of n.slice(1))
|
|
2261
|
+
if (/^extend\s+/i.test(i))
|
|
2241
2262
|
throw u({
|
|
2242
2263
|
code: "parse_error",
|
|
2243
2264
|
path: e,
|
|
@@ -2249,49 +2270,83 @@ function At(t, e) {
|
|
|
2249
2270
|
`)
|
|
2250
2271
|
};
|
|
2251
2272
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2273
|
+
function ce(t) {
|
|
2274
|
+
return /^toc(\(.*\))?$/.test(t.trim());
|
|
2275
|
+
}
|
|
2276
|
+
function Tt(t, e) {
|
|
2277
|
+
const n = A(t);
|
|
2278
|
+
if (n.length !== 1)
|
|
2279
|
+
throw u({
|
|
2280
|
+
code: "parse_error",
|
|
2281
|
+
path: e,
|
|
2282
|
+
details: {
|
|
2283
|
+
message: "toc directive must be a single line"
|
|
2284
|
+
}
|
|
2285
|
+
});
|
|
2286
|
+
const r = n[0];
|
|
2287
|
+
if (r === "toc")
|
|
2288
|
+
return { maxLevel: 6 };
|
|
2289
|
+
const s = /^toc\((.*)\)$/.exec(r);
|
|
2290
|
+
if (!s)
|
|
2291
|
+
throw u({
|
|
2292
|
+
code: "parse_error",
|
|
2293
|
+
path: e,
|
|
2294
|
+
details: { message: `invalid toc directive: ${r}` }
|
|
2295
|
+
});
|
|
2296
|
+
const i = s[1];
|
|
2297
|
+
if (!/^[1-6]$/.test(i))
|
|
2298
|
+
throw u({
|
|
2299
|
+
code: "parse_error",
|
|
2300
|
+
path: e,
|
|
2301
|
+
details: {
|
|
2302
|
+
message: `invalid toc max level: ${i || "(empty)"} (expected integer 1–6)`
|
|
2303
|
+
}
|
|
2304
|
+
});
|
|
2305
|
+
return { maxLevel: Number(i) };
|
|
2306
|
+
}
|
|
2307
|
+
async function Lt(t, e = {}) {
|
|
2308
|
+
const n = e.path, r = e.context ?? {};
|
|
2309
|
+
if (Ae(t))
|
|
2255
2310
|
throw u({
|
|
2256
2311
|
code: "parse_error",
|
|
2257
2312
|
path: n,
|
|
2258
2313
|
details: {
|
|
2259
|
-
message:
|
|
2314
|
+
message: $e(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2260
2315
|
}
|
|
2261
2316
|
});
|
|
2262
|
-
const s =
|
|
2317
|
+
const s = E(t);
|
|
2263
2318
|
if (s.length === 0)
|
|
2264
|
-
return { source: t, context:
|
|
2265
|
-
const
|
|
2266
|
-
o[l] =
|
|
2319
|
+
return { source: t, context: r, declarationUpdates: {} };
|
|
2320
|
+
const i = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
|
|
2321
|
+
o[l] = r[l];
|
|
2267
2322
|
};
|
|
2268
2323
|
let c = t, h = 0;
|
|
2269
2324
|
for (const l of s) {
|
|
2270
|
-
const d =
|
|
2271
|
-
if (d.length === 1 &&
|
|
2325
|
+
const d = A(l.inner);
|
|
2326
|
+
if (d.length === 1 && Ee(d[0]) || d.length === 1 && ce(d[0]) || d.length === 1 && /^include\s+/i.test(d[0]) || d.length === 1 && /^component\s+/i.test(d[0]))
|
|
2272
2327
|
continue;
|
|
2273
|
-
const f =
|
|
2328
|
+
const f = Et(l.inner, n);
|
|
2274
2329
|
if (f) {
|
|
2275
2330
|
if (f.declarationsSource.trim().length > 0) {
|
|
2276
|
-
const
|
|
2331
|
+
const H = we(
|
|
2277
2332
|
f.declarationsSource,
|
|
2278
2333
|
n
|
|
2279
2334
|
);
|
|
2280
|
-
await
|
|
2335
|
+
await xe(H, r, {
|
|
2281
2336
|
path: n,
|
|
2282
|
-
constBindings:
|
|
2337
|
+
constBindings: i,
|
|
2283
2338
|
onUpdate: a
|
|
2284
2339
|
});
|
|
2285
2340
|
}
|
|
2286
|
-
const
|
|
2341
|
+
const S = l.start - h, L = l.end - h, j = `<!--@hg
|
|
2287
2342
|
extend ${f.path}
|
|
2288
2343
|
@endhg-->`;
|
|
2289
|
-
c = c.slice(0,
|
|
2344
|
+
c = c.slice(0, S) + j + c.slice(L), h += l.raw.length - j.length;
|
|
2290
2345
|
continue;
|
|
2291
2346
|
}
|
|
2292
2347
|
const g = d.join(`
|
|
2293
2348
|
`);
|
|
2294
|
-
if (!
|
|
2349
|
+
if (!He(g)) {
|
|
2295
2350
|
if (d.length === 1)
|
|
2296
2351
|
continue;
|
|
2297
2352
|
throw u({
|
|
@@ -2300,28 +2355,33 @@ extend ${f.path}
|
|
|
2300
2355
|
details: { message: `unsupported hyogen directive: ${d[0]}` }
|
|
2301
2356
|
});
|
|
2302
2357
|
}
|
|
2303
|
-
const m =
|
|
2304
|
-
await
|
|
2358
|
+
const m = we(g, n), p = [];
|
|
2359
|
+
await xe(m, r, {
|
|
2305
2360
|
path: n,
|
|
2306
|
-
constBindings:
|
|
2307
|
-
onUpdate: a
|
|
2361
|
+
constBindings: i,
|
|
2362
|
+
onUpdate: a,
|
|
2363
|
+
echoChunks: p
|
|
2308
2364
|
});
|
|
2309
|
-
const
|
|
2310
|
-
|
|
2365
|
+
const $ = l.start - h, D = l.end - h, b = c.slice(0, $), v = c.slice(D);
|
|
2366
|
+
if (p.length > 0) {
|
|
2367
|
+
const S = p.join("");
|
|
2368
|
+
c = b + S + v, h += l.raw.length - S.length;
|
|
2369
|
+
} else
|
|
2370
|
+
c = T(b, v), h += l.raw.length + ie(b, v);
|
|
2311
2371
|
}
|
|
2312
|
-
return { source: c, context:
|
|
2372
|
+
return { source: c, context: r, declarationUpdates: o };
|
|
2313
2373
|
}
|
|
2314
|
-
const
|
|
2315
|
-
function
|
|
2316
|
-
const n =
|
|
2374
|
+
const Mt = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
|
|
2375
|
+
function Ot(t, e) {
|
|
2376
|
+
const n = ee(t).trim();
|
|
2317
2377
|
if (n.length === 0)
|
|
2318
2378
|
throw u({
|
|
2319
2379
|
code: "parse_error",
|
|
2320
2380
|
path: e,
|
|
2321
2381
|
details: { message: "empty hyogen block" }
|
|
2322
2382
|
});
|
|
2323
|
-
const
|
|
2324
|
-
if (
|
|
2383
|
+
const r = n.split(/\r?\n/).map((a) => a.trim()).filter((a) => a.length > 0);
|
|
2384
|
+
if (r.length !== 1)
|
|
2325
2385
|
throw u({
|
|
2326
2386
|
code: "parse_error",
|
|
2327
2387
|
path: e,
|
|
@@ -2329,21 +2389,21 @@ function Tt(t, e) {
|
|
|
2329
2389
|
message: "hyogen block must contain a single component directive"
|
|
2330
2390
|
}
|
|
2331
2391
|
});
|
|
2332
|
-
const s =
|
|
2392
|
+
const s = r[0];
|
|
2333
2393
|
if (/^include\s+/i.test(s))
|
|
2334
2394
|
throw u({
|
|
2335
2395
|
code: "parse_error",
|
|
2336
2396
|
path: e,
|
|
2337
2397
|
details: { message: "include and component cannot coexist in one block" }
|
|
2338
2398
|
});
|
|
2339
|
-
const
|
|
2340
|
-
if (!
|
|
2399
|
+
const i = Mt.exec(s);
|
|
2400
|
+
if (!i)
|
|
2341
2401
|
throw u({
|
|
2342
2402
|
code: "parse_error",
|
|
2343
2403
|
path: e,
|
|
2344
2404
|
details: { message: `unsupported component directive: ${s}` }
|
|
2345
2405
|
});
|
|
2346
|
-
const o =
|
|
2406
|
+
const o = i[1];
|
|
2347
2407
|
if (o.length === 0)
|
|
2348
2408
|
throw u({
|
|
2349
2409
|
code: "parse_error",
|
|
@@ -2353,46 +2413,46 @@ function Tt(t, e) {
|
|
|
2353
2413
|
return {
|
|
2354
2414
|
kind: "component",
|
|
2355
2415
|
path: o,
|
|
2356
|
-
alias:
|
|
2416
|
+
alias: i[2]
|
|
2357
2417
|
};
|
|
2358
2418
|
}
|
|
2359
|
-
function
|
|
2360
|
-
const n =
|
|
2419
|
+
function Rt(t, e) {
|
|
2420
|
+
const n = ee(t).trim();
|
|
2361
2421
|
if (n.length === 0)
|
|
2362
2422
|
throw u({
|
|
2363
2423
|
code: "parse_error",
|
|
2364
2424
|
path: e,
|
|
2365
2425
|
details: { message: "empty hyogen block" }
|
|
2366
2426
|
});
|
|
2367
|
-
const
|
|
2368
|
-
if (
|
|
2427
|
+
const r = n.split(/\r?\n/).map((o) => o.trim()).filter((o) => o.length > 0);
|
|
2428
|
+
if (r.length !== 1)
|
|
2369
2429
|
throw u({
|
|
2370
2430
|
code: "parse_error",
|
|
2371
2431
|
path: e,
|
|
2372
2432
|
details: { message: "hyogen block must contain a single include directive" }
|
|
2373
2433
|
});
|
|
2374
|
-
const s =
|
|
2375
|
-
if (
|
|
2376
|
-
return { kind: "include", path:
|
|
2434
|
+
const s = r[0], i = /^include\s+(\S+)\s*$/.exec(s);
|
|
2435
|
+
if (i)
|
|
2436
|
+
return { kind: "include", path: i[1] };
|
|
2377
2437
|
throw u({
|
|
2378
2438
|
code: "parse_error",
|
|
2379
2439
|
path: e,
|
|
2380
2440
|
details: { message: `unsupported hyogen directive: ${s}` }
|
|
2381
2441
|
});
|
|
2382
2442
|
}
|
|
2383
|
-
function
|
|
2384
|
-
const e =
|
|
2443
|
+
function Dt(t) {
|
|
2444
|
+
const e = se(t).trim();
|
|
2385
2445
|
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
|
|
2386
2446
|
}
|
|
2387
|
-
const
|
|
2388
|
-
function
|
|
2389
|
-
return `${
|
|
2447
|
+
const Ht = "\0HYOGEN_INCLUDE_";
|
|
2448
|
+
function Nt(t) {
|
|
2449
|
+
return `${Ht}${t}\0`;
|
|
2390
2450
|
}
|
|
2391
|
-
function
|
|
2392
|
-
const n =
|
|
2393
|
-
if (n.length === 1 &&
|
|
2451
|
+
function Bt(t, e) {
|
|
2452
|
+
const n = A(t);
|
|
2453
|
+
if (n.length === 1 && Ee(n[0]))
|
|
2394
2454
|
return { kind: "control" };
|
|
2395
|
-
if (n.length === 1 && (
|
|
2455
|
+
if (n.length === 1 && ce(n[0]) || n.length === 1 && (Dt(n[0]) || He(n[0])))
|
|
2396
2456
|
return null;
|
|
2397
2457
|
if (n.length !== 1)
|
|
2398
2458
|
throw u({
|
|
@@ -2400,42 +2460,42 @@ function Ot(t, e) {
|
|
|
2400
2460
|
path: e,
|
|
2401
2461
|
details: { message: "hyogen block must contain a single directive" }
|
|
2402
2462
|
});
|
|
2403
|
-
const
|
|
2404
|
-
if (/^include\s+/i.test(
|
|
2463
|
+
const r = n[0];
|
|
2464
|
+
if (/^include\s+/i.test(r) && /\bcomponent\s+/i.test(r))
|
|
2405
2465
|
throw u({
|
|
2406
2466
|
code: "parse_error",
|
|
2407
2467
|
path: e,
|
|
2408
2468
|
details: { message: "include and component cannot coexist in one block" }
|
|
2409
2469
|
});
|
|
2410
|
-
if (/^include\s+/i.test(
|
|
2411
|
-
return
|
|
2412
|
-
if (/^component\s+/i.test(
|
|
2413
|
-
return
|
|
2414
|
-
if (
|
|
2470
|
+
if (/^include\s+/i.test(r))
|
|
2471
|
+
return Rt(t, e);
|
|
2472
|
+
if (/^component\s+/i.test(r))
|
|
2473
|
+
return Ot(t, e);
|
|
2474
|
+
if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
|
|
2415
2475
|
return null;
|
|
2416
2476
|
throw u({
|
|
2417
2477
|
code: "parse_error",
|
|
2418
2478
|
path: e,
|
|
2419
|
-
details: { message: `unsupported hyogen directive: ${
|
|
2479
|
+
details: { message: `unsupported hyogen directive: ${r}` }
|
|
2420
2480
|
});
|
|
2421
2481
|
}
|
|
2422
|
-
function
|
|
2482
|
+
function jt(t, e = {}) {
|
|
2423
2483
|
const n = e.path;
|
|
2424
|
-
if (
|
|
2484
|
+
if (Ae(t))
|
|
2425
2485
|
throw u({
|
|
2426
2486
|
code: "parse_error",
|
|
2427
2487
|
path: n,
|
|
2428
2488
|
details: {
|
|
2429
|
-
message:
|
|
2489
|
+
message: $e(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2430
2490
|
}
|
|
2431
2491
|
});
|
|
2432
|
-
const
|
|
2433
|
-
if (
|
|
2492
|
+
const r = E(t);
|
|
2493
|
+
if (r.length === 0)
|
|
2434
2494
|
return { source: t, directives: [] };
|
|
2435
2495
|
const s = [];
|
|
2436
|
-
let
|
|
2437
|
-
for (const c of
|
|
2438
|
-
const h =
|
|
2496
|
+
let i = t, o = 0, a = 0;
|
|
2497
|
+
for (const c of r) {
|
|
2498
|
+
const h = Bt(c.inner, n);
|
|
2439
2499
|
if (!h || h.kind === "control")
|
|
2440
2500
|
continue;
|
|
2441
2501
|
const l = c.start - o, d = c.end - o;
|
|
@@ -2449,47 +2509,47 @@ function Dt(t, e = {}) {
|
|
|
2449
2509
|
Object.keys(e.context ?? {}),
|
|
2450
2510
|
n
|
|
2451
2511
|
);
|
|
2452
|
-
const g =
|
|
2453
|
-
|
|
2512
|
+
const g = i.slice(0, l), m = i.slice(d);
|
|
2513
|
+
i = T(g, m), o += c.raw.length + ie(g, m);
|
|
2454
2514
|
continue;
|
|
2455
2515
|
}
|
|
2456
|
-
const f =
|
|
2457
|
-
s.push({ ...h, marker: f, raw: c.raw }),
|
|
2516
|
+
const f = Nt(a++);
|
|
2517
|
+
s.push({ ...h, marker: f, raw: c.raw }), i = i.slice(0, l) + f + i.slice(d), o += c.raw.length - f.length;
|
|
2458
2518
|
}
|
|
2459
|
-
return { source:
|
|
2519
|
+
return { source: i, directives: s };
|
|
2460
2520
|
}
|
|
2461
|
-
function
|
|
2521
|
+
function Ft(t, e) {
|
|
2462
2522
|
return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
|
|
2463
2523
|
` : `${e.rawFrontMatter}
|
|
2464
2524
|
${t}`;
|
|
2465
2525
|
}
|
|
2466
|
-
function
|
|
2526
|
+
function Pt(t, e = !1) {
|
|
2467
2527
|
if (e)
|
|
2468
2528
|
return t;
|
|
2469
|
-
const n =
|
|
2529
|
+
const n = E(t);
|
|
2470
2530
|
if (n.length === 0)
|
|
2471
2531
|
return t;
|
|
2472
|
-
let
|
|
2473
|
-
for (const
|
|
2474
|
-
const o =
|
|
2475
|
-
|
|
2532
|
+
let r = t, s = 0;
|
|
2533
|
+
for (const i of n) {
|
|
2534
|
+
const o = i.start - s, a = i.end - s, c = r.slice(0, o), h = r.slice(a);
|
|
2535
|
+
r = T(c, h), s += i.raw.length + ie(c, h);
|
|
2476
2536
|
}
|
|
2477
|
-
return
|
|
2537
|
+
return r;
|
|
2478
2538
|
}
|
|
2479
|
-
const
|
|
2480
|
-
function
|
|
2539
|
+
const It = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
2540
|
+
function zt(t, e) {
|
|
2481
2541
|
const n = t.trim();
|
|
2482
2542
|
if (n === "endblock")
|
|
2483
2543
|
return { kind: "endblock" };
|
|
2484
|
-
const
|
|
2485
|
-
if (!
|
|
2544
|
+
const r = It.exec(n);
|
|
2545
|
+
if (!r)
|
|
2486
2546
|
throw u({
|
|
2487
2547
|
code: "parse_error",
|
|
2488
2548
|
path: e,
|
|
2489
2549
|
details: { message: "invalid block directive" }
|
|
2490
2550
|
});
|
|
2491
|
-
const s =
|
|
2492
|
-
if (
|
|
2551
|
+
const s = r[1];
|
|
2552
|
+
if (De(s))
|
|
2493
2553
|
throw u({
|
|
2494
2554
|
code: "parse_error",
|
|
2495
2555
|
path: e,
|
|
@@ -2497,22 +2557,22 @@ function Ht(t, e) {
|
|
|
2497
2557
|
});
|
|
2498
2558
|
return { kind: "block", name: s };
|
|
2499
2559
|
}
|
|
2500
|
-
function
|
|
2501
|
-
const { path: n, mode:
|
|
2502
|
-
if (
|
|
2560
|
+
function ke(t, e) {
|
|
2561
|
+
const { path: n, mode: r, hasExtend: s = !1 } = e, i = E(t);
|
|
2562
|
+
if (i.length === 0) return [];
|
|
2503
2563
|
const o = [], a = [], c = /* @__PURE__ */ new Set();
|
|
2504
|
-
for (const h of
|
|
2505
|
-
const l =
|
|
2564
|
+
for (const h of i) {
|
|
2565
|
+
const l = A(h.inner);
|
|
2506
2566
|
if (l.length !== 1) continue;
|
|
2507
2567
|
const d = l[0];
|
|
2508
2568
|
if (!(d === "endblock" || d.startsWith("block "))) continue;
|
|
2509
|
-
if (
|
|
2569
|
+
if (r === "child" && !s)
|
|
2510
2570
|
throw u({
|
|
2511
2571
|
code: "parse_error",
|
|
2512
2572
|
path: n,
|
|
2513
2573
|
details: { message: "orphan block without extend" }
|
|
2514
2574
|
});
|
|
2515
|
-
const g =
|
|
2575
|
+
const g = zt(d, n);
|
|
2516
2576
|
if (g.kind === "endblock") {
|
|
2517
2577
|
const m = a.pop();
|
|
2518
2578
|
if (!m)
|
|
@@ -2556,22 +2616,22 @@ function xe(t, e) {
|
|
|
2556
2616
|
});
|
|
2557
2617
|
return o;
|
|
2558
2618
|
}
|
|
2559
|
-
function
|
|
2560
|
-
const e =
|
|
2561
|
-
for (const
|
|
2562
|
-
const s =
|
|
2619
|
+
function be(t) {
|
|
2620
|
+
const e = E(t), n = [];
|
|
2621
|
+
for (const r of e) {
|
|
2622
|
+
const s = A(r.inner);
|
|
2563
2623
|
if (s.length === 0) continue;
|
|
2564
|
-
const
|
|
2565
|
-
|
|
2624
|
+
const i = ae(s[0]);
|
|
2625
|
+
i && n.push({ path: i.path, start: r.start });
|
|
2566
2626
|
}
|
|
2567
2627
|
return n;
|
|
2568
2628
|
}
|
|
2569
|
-
function
|
|
2570
|
-
const e =
|
|
2629
|
+
function Ut(t) {
|
|
2630
|
+
const e = E(t);
|
|
2571
2631
|
for (const n of e) {
|
|
2572
|
-
const
|
|
2573
|
-
if (
|
|
2574
|
-
const s =
|
|
2632
|
+
const r = A(n.inner);
|
|
2633
|
+
if (r.length !== 1) continue;
|
|
2634
|
+
const s = r[0];
|
|
2575
2635
|
if (s === "endblock" || s.startsWith("block ")) return !0;
|
|
2576
2636
|
}
|
|
2577
2637
|
return !1;
|
|
@@ -2579,14 +2639,14 @@ function Pt(t) {
|
|
|
2579
2639
|
function K(t) {
|
|
2580
2640
|
return t.map((e) => e.body).join("");
|
|
2581
2641
|
}
|
|
2582
|
-
function
|
|
2583
|
-
const
|
|
2584
|
-
let
|
|
2585
|
-
for (const o of
|
|
2586
|
-
s.push(t.slice(
|
|
2587
|
-
return s.push(t.slice(
|
|
2642
|
+
function Zt(t, e, n) {
|
|
2643
|
+
const r = [...e].sort((o, a) => o.start - a.start), s = [];
|
|
2644
|
+
let i = 0;
|
|
2645
|
+
for (const o of r)
|
|
2646
|
+
s.push(t.slice(i, o.start)), s.push(n.get(o.name) ?? o.body), i = o.end;
|
|
2647
|
+
return s.push(t.slice(i)), s.reduce((o, a) => T(o, a));
|
|
2588
2648
|
}
|
|
2589
|
-
function
|
|
2649
|
+
function qt(t) {
|
|
2590
2650
|
if (t instanceof Error && "code" in t && "details" in t) {
|
|
2591
2651
|
const e = t;
|
|
2592
2652
|
if (e.code === "file_not_found" && e.details && e.details.via === "include")
|
|
@@ -2594,34 +2654,34 @@ function It(t) {
|
|
|
2594
2654
|
}
|
|
2595
2655
|
return { errorToThrow: t, adjusted: !1 };
|
|
2596
2656
|
}
|
|
2597
|
-
async function
|
|
2657
|
+
async function Vt(t, e) {
|
|
2598
2658
|
const {
|
|
2599
2659
|
path: n,
|
|
2600
|
-
context:
|
|
2660
|
+
context: r,
|
|
2601
2661
|
declarationUpdates: s,
|
|
2602
|
-
loader:
|
|
2662
|
+
loader: i,
|
|
2603
2663
|
root: o,
|
|
2604
2664
|
constrainToRoot: a,
|
|
2605
2665
|
visitStack: c,
|
|
2606
2666
|
warnings: h,
|
|
2607
2667
|
inComponent: l = !1
|
|
2608
|
-
} = e, d =
|
|
2668
|
+
} = e, d = be(t);
|
|
2609
2669
|
if (d.length === 0) {
|
|
2610
|
-
if (
|
|
2670
|
+
if (Ut(t))
|
|
2611
2671
|
throw u({
|
|
2612
2672
|
code: "parse_error",
|
|
2613
2673
|
path: n,
|
|
2614
2674
|
details: { message: "orphan block without extend" }
|
|
2615
2675
|
});
|
|
2616
|
-
return { source: t, context: _(
|
|
2676
|
+
return { source: t, context: _(r, s) };
|
|
2617
2677
|
}
|
|
2618
|
-
const g =
|
|
2678
|
+
const g = E(t)[0];
|
|
2619
2679
|
if (!g)
|
|
2620
|
-
return { source: t, context: _(
|
|
2621
|
-
if (!
|
|
2680
|
+
return { source: t, context: _(r, s) };
|
|
2681
|
+
if (!i)
|
|
2622
2682
|
throw new Error("loader is required when processing extend directives");
|
|
2623
|
-
const m =
|
|
2624
|
-
if (!(m.length > 0 ?
|
|
2683
|
+
const m = A(g.inner);
|
|
2684
|
+
if (!(m.length > 0 ? ae(m[0]) : null))
|
|
2625
2685
|
throw u({
|
|
2626
2686
|
code: "parse_error",
|
|
2627
2687
|
path: n,
|
|
@@ -2633,7 +2693,7 @@ async function zt(t, e) {
|
|
|
2633
2693
|
path: n,
|
|
2634
2694
|
details: { message: "multiple extend directives are not supported" }
|
|
2635
2695
|
});
|
|
2636
|
-
const
|
|
2696
|
+
const $ = ke(t, {
|
|
2637
2697
|
path: n,
|
|
2638
2698
|
mode: "child",
|
|
2639
2699
|
hasExtend: !0
|
|
@@ -2641,16 +2701,16 @@ async function zt(t, e) {
|
|
|
2641
2701
|
if (l)
|
|
2642
2702
|
return h?.push({
|
|
2643
2703
|
code: "extend_in_component",
|
|
2644
|
-
message:
|
|
2704
|
+
message: R("extend_in_component", { path: n }),
|
|
2645
2705
|
path: n,
|
|
2646
2706
|
details: { path: n }
|
|
2647
2707
|
}), {
|
|
2648
|
-
source: K(
|
|
2649
|
-
context: _(
|
|
2708
|
+
source: K($),
|
|
2709
|
+
context: _(r, s)
|
|
2650
2710
|
};
|
|
2651
|
-
const
|
|
2711
|
+
const D = d[0].path, b = n, v = Y(
|
|
2652
2712
|
o,
|
|
2653
|
-
|
|
2713
|
+
D,
|
|
2654
2714
|
n,
|
|
2655
2715
|
n,
|
|
2656
2716
|
a,
|
|
@@ -2658,34 +2718,34 @@ async function zt(t, e) {
|
|
|
2658
2718
|
);
|
|
2659
2719
|
b && c.push(b);
|
|
2660
2720
|
try {
|
|
2661
|
-
const
|
|
2662
|
-
if (
|
|
2721
|
+
const S = b ? c.check(v) : { circular: !1 };
|
|
2722
|
+
if (S.circular)
|
|
2663
2723
|
return h?.push({
|
|
2664
2724
|
code: "circular_include",
|
|
2665
|
-
message:
|
|
2725
|
+
message: R("circular_include", {
|
|
2666
2726
|
path: v,
|
|
2667
|
-
from:
|
|
2727
|
+
from: S.from,
|
|
2668
2728
|
via: "extend"
|
|
2669
2729
|
}),
|
|
2670
2730
|
path: n,
|
|
2671
|
-
details: { path: v, from:
|
|
2731
|
+
details: { path: v, from: S.from, via: "extend" }
|
|
2672
2732
|
}), {
|
|
2673
|
-
source: K(
|
|
2674
|
-
context: _(
|
|
2733
|
+
source: K($),
|
|
2734
|
+
context: _(r, s)
|
|
2675
2735
|
};
|
|
2676
2736
|
c.push(v);
|
|
2677
2737
|
try {
|
|
2678
|
-
const
|
|
2679
|
-
if (
|
|
2738
|
+
const L = await i(v);
|
|
2739
|
+
if (L === void 0)
|
|
2680
2740
|
throw new Error("loader returned undefined");
|
|
2681
|
-
const { context:
|
|
2682
|
-
|
|
2741
|
+
const { context: j, body: H } = P(
|
|
2742
|
+
L,
|
|
2683
2743
|
v
|
|
2684
|
-
),
|
|
2685
|
-
if (
|
|
2686
|
-
const
|
|
2744
|
+
), he = be(H);
|
|
2745
|
+
if (he.length > 0) {
|
|
2746
|
+
const F = he[0].path, I = Y(
|
|
2687
2747
|
o,
|
|
2688
|
-
|
|
2748
|
+
F,
|
|
2689
2749
|
v,
|
|
2690
2750
|
v,
|
|
2691
2751
|
a,
|
|
@@ -2694,7 +2754,7 @@ async function zt(t, e) {
|
|
|
2694
2754
|
if (z.circular)
|
|
2695
2755
|
return h?.push({
|
|
2696
2756
|
code: "circular_include",
|
|
2697
|
-
message:
|
|
2757
|
+
message: R("circular_include", {
|
|
2698
2758
|
path: I,
|
|
2699
2759
|
from: z.from,
|
|
2700
2760
|
via: "extend"
|
|
@@ -2702,8 +2762,8 @@ async function zt(t, e) {
|
|
|
2702
2762
|
path: n,
|
|
2703
2763
|
details: { path: I, from: z.from, via: "extend" }
|
|
2704
2764
|
}), {
|
|
2705
|
-
source: K(
|
|
2706
|
-
context: _(
|
|
2765
|
+
source: K($),
|
|
2766
|
+
context: _(r, s)
|
|
2707
2767
|
};
|
|
2708
2768
|
throw u({
|
|
2709
2769
|
code: "parse_error",
|
|
@@ -2711,32 +2771,32 @@ async function zt(t, e) {
|
|
|
2711
2771
|
details: { message: "layout extend is not supported" }
|
|
2712
2772
|
});
|
|
2713
2773
|
}
|
|
2714
|
-
const
|
|
2774
|
+
const Ne = ke(H, {
|
|
2715
2775
|
path: v,
|
|
2716
2776
|
mode: "layout"
|
|
2717
|
-
}),
|
|
2718
|
-
|
|
2719
|
-
),
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
),
|
|
2724
|
-
|
|
2725
|
-
|
|
2777
|
+
}), Be = new Map(
|
|
2778
|
+
$.map((F) => [F.name, F.body])
|
|
2779
|
+
), je = Zt(
|
|
2780
|
+
H,
|
|
2781
|
+
Ne,
|
|
2782
|
+
Be
|
|
2783
|
+
), Fe = _(
|
|
2784
|
+
r,
|
|
2785
|
+
j,
|
|
2726
2786
|
s
|
|
2727
2787
|
);
|
|
2728
|
-
return { source:
|
|
2788
|
+
return { source: je, context: Fe };
|
|
2729
2789
|
} finally {
|
|
2730
2790
|
c.pop();
|
|
2731
2791
|
}
|
|
2732
|
-
} catch (
|
|
2733
|
-
const
|
|
2734
|
-
throw
|
|
2792
|
+
} catch (S) {
|
|
2793
|
+
const L = qt(S);
|
|
2794
|
+
throw L.adjusted ? L.errorToThrow : S;
|
|
2735
2795
|
} finally {
|
|
2736
2796
|
b && c.pop();
|
|
2737
2797
|
}
|
|
2738
2798
|
}
|
|
2739
|
-
const
|
|
2799
|
+
const Kt = J.warningReasons, Yt = [
|
|
2740
2800
|
{
|
|
2741
2801
|
reason: "contains_html_script_tag",
|
|
2742
2802
|
test: (t) => /<\/?script\b/i.test(t)
|
|
@@ -2758,19 +2818,19 @@ const Ut = J.warningReasons, Zt = [
|
|
|
2758
2818
|
test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
|
|
2759
2819
|
}
|
|
2760
2820
|
];
|
|
2761
|
-
function
|
|
2762
|
-
return
|
|
2821
|
+
function Xt(t) {
|
|
2822
|
+
return Kt[t] ?? t;
|
|
2763
2823
|
}
|
|
2764
|
-
function
|
|
2824
|
+
function X(t, e, n, r) {
|
|
2765
2825
|
if (typeof t == "string") {
|
|
2766
|
-
for (const s of
|
|
2826
|
+
for (const s of Yt)
|
|
2767
2827
|
s.test(t) && n.push({
|
|
2768
2828
|
code: "suspicious_context_value",
|
|
2769
|
-
message:
|
|
2829
|
+
message: R("suspicious_context_value", {
|
|
2770
2830
|
key: e,
|
|
2771
|
-
reason:
|
|
2831
|
+
reason: Xt(s.reason)
|
|
2772
2832
|
}),
|
|
2773
|
-
path:
|
|
2833
|
+
path: r,
|
|
2774
2834
|
details: { key: e, reason: s.reason }
|
|
2775
2835
|
});
|
|
2776
2836
|
return;
|
|
@@ -2778,43 +2838,198 @@ function G(t, e, n, i) {
|
|
|
2778
2838
|
if (t != null) {
|
|
2779
2839
|
if (Array.isArray(t)) {
|
|
2780
2840
|
for (let s = 0; s < t.length; s++)
|
|
2781
|
-
|
|
2841
|
+
X(t[s], `${e}[${s}]`, n, r);
|
|
2782
2842
|
return;
|
|
2783
2843
|
}
|
|
2784
2844
|
if (typeof t == "object")
|
|
2785
|
-
for (const [s,
|
|
2845
|
+
for (const [s, i] of Object.entries(
|
|
2786
2846
|
t
|
|
2787
2847
|
)) {
|
|
2788
2848
|
const o = e.length > 0 ? `${e}.${s}` : s;
|
|
2789
|
-
|
|
2849
|
+
X(i, o, n, r);
|
|
2790
2850
|
}
|
|
2791
2851
|
}
|
|
2792
2852
|
}
|
|
2793
|
-
function
|
|
2794
|
-
for (const [
|
|
2795
|
-
|
|
2853
|
+
function Gt(t, e, n) {
|
|
2854
|
+
for (const [r, s] of Object.entries(t))
|
|
2855
|
+
X(s, r, e, n);
|
|
2856
|
+
}
|
|
2857
|
+
const Jt = /^=+[ \t]*$/, Qt = /^-+[ \t]*$/, en = /^(```|~~~)/, tn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
|
|
2858
|
+
function G(t) {
|
|
2859
|
+
const e = tn.exec(t);
|
|
2860
|
+
return e && e.index !== void 0 ? {
|
|
2861
|
+
text: t.slice(0, e.index).trim(),
|
|
2862
|
+
explicitId: e[1]
|
|
2863
|
+
} : { text: t.trim() };
|
|
2864
|
+
}
|
|
2865
|
+
function nn(t) {
|
|
2866
|
+
let e = 0;
|
|
2867
|
+
for (; e < t.length && e < 6 && t[e] === "#"; )
|
|
2868
|
+
e += 1;
|
|
2869
|
+
if (e === 0 || e === 6 && e < t.length && t[e] === "#" || e >= t.length || t[e] !== " " && t[e] !== " ")
|
|
2870
|
+
return null;
|
|
2871
|
+
let n = e;
|
|
2872
|
+
for (; n < t.length && (t[n] === " " || t[n] === " "); )
|
|
2873
|
+
n += 1;
|
|
2874
|
+
if (n >= t.length)
|
|
2875
|
+
return null;
|
|
2876
|
+
let r = t.length;
|
|
2877
|
+
for (; r > n && (t[r - 1] === " " || t[r - 1] === " "); )
|
|
2878
|
+
r -= 1;
|
|
2879
|
+
let s = r;
|
|
2880
|
+
if (r > n && t[r - 1] === "#") {
|
|
2881
|
+
let o = r - 1;
|
|
2882
|
+
for (; o > n && t[o - 1] === "#"; )
|
|
2883
|
+
o -= 1;
|
|
2884
|
+
if (o > n && (t[o - 1] === " " || t[o - 1] === " ")) {
|
|
2885
|
+
let a = o - 1;
|
|
2886
|
+
for (; a >= n && (t[a] === " " || t[a] === " "); )
|
|
2887
|
+
a -= 1;
|
|
2888
|
+
s = a + 1;
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
if (s <= n)
|
|
2892
|
+
return null;
|
|
2893
|
+
const i = G(t.slice(n, s));
|
|
2894
|
+
return { level: e, ...i };
|
|
2895
|
+
}
|
|
2896
|
+
function ve(t, e, n) {
|
|
2897
|
+
let r = n;
|
|
2898
|
+
for (; r < t.length; ) {
|
|
2899
|
+
if (!e.inHtmlComment) {
|
|
2900
|
+
const i = t.indexOf("<!--", r);
|
|
2901
|
+
if (i === -1)
|
|
2902
|
+
return;
|
|
2903
|
+
e.inHtmlComment = !0, r = i + 4;
|
|
2904
|
+
continue;
|
|
2905
|
+
}
|
|
2906
|
+
const s = t.indexOf("-->", r);
|
|
2907
|
+
if (s === -1)
|
|
2908
|
+
return;
|
|
2909
|
+
e.inHtmlComment = !1, r = s + 3;
|
|
2910
|
+
}
|
|
2796
2911
|
}
|
|
2797
|
-
|
|
2798
|
-
|
|
2912
|
+
function rn(t, e) {
|
|
2913
|
+
if (e.inFence || e.inHtmlComment)
|
|
2914
|
+
return !0;
|
|
2915
|
+
const n = t.trim();
|
|
2916
|
+
return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
|
|
2917
|
+
}
|
|
2918
|
+
function sn(t) {
|
|
2919
|
+
const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
|
|
2920
|
+
for (let s = 0; s < e.length; s++) {
|
|
2921
|
+
const i = e[s];
|
|
2922
|
+
if (r.inFence) {
|
|
2923
|
+
const l = i.trim();
|
|
2924
|
+
l.startsWith(r.inFence.marker) && /^(`{3,}|~{3,})\s*$/.test(l) && (r.inFence = !1);
|
|
2925
|
+
continue;
|
|
2926
|
+
}
|
|
2927
|
+
if (r.inHtmlComment) {
|
|
2928
|
+
ve(i, r, 0);
|
|
2929
|
+
continue;
|
|
2930
|
+
}
|
|
2931
|
+
const o = en.exec(i.trimStart());
|
|
2932
|
+
if (o) {
|
|
2933
|
+
const l = o[1];
|
|
2934
|
+
i.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
|
|
2935
|
+
continue;
|
|
2936
|
+
}
|
|
2937
|
+
if (i.trim().startsWith("<!--")) {
|
|
2938
|
+
ve(i, r, i.indexOf("<!--"));
|
|
2939
|
+
continue;
|
|
2940
|
+
}
|
|
2941
|
+
if (rn(i, r))
|
|
2942
|
+
continue;
|
|
2943
|
+
const c = nn(i);
|
|
2944
|
+
if (c) {
|
|
2945
|
+
n.push(c);
|
|
2946
|
+
continue;
|
|
2947
|
+
}
|
|
2948
|
+
const h = e[s + 1];
|
|
2949
|
+
if (h !== void 0 && i.trim().length > 0 && !i.trimStart().startsWith("#") && !i.trimStart().startsWith(">") && !i.trimStart().startsWith("|")) {
|
|
2950
|
+
if (Jt.test(h)) {
|
|
2951
|
+
const l = G(i.trim());
|
|
2952
|
+
n.push({ level: 1, ...l }), s += 1;
|
|
2953
|
+
continue;
|
|
2954
|
+
}
|
|
2955
|
+
if (Qt.test(h) && h.trim().length >= 1) {
|
|
2956
|
+
const l = G(i.trim());
|
|
2957
|
+
n.push({ level: 2, ...l }), s += 1;
|
|
2958
|
+
continue;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
return n;
|
|
2963
|
+
}
|
|
2964
|
+
const on = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
|
|
2965
|
+
function an() {
|
|
2966
|
+
const t = /* @__PURE__ */ new Map();
|
|
2967
|
+
return {
|
|
2968
|
+
slug(e, n) {
|
|
2969
|
+
const r = n !== void 0 && n.length > 0 ? n : cn(e), s = t.get(r) ?? 0;
|
|
2970
|
+
return t.set(r, s + 1), s === 0 ? r : `${r}-${s}`;
|
|
2971
|
+
}
|
|
2972
|
+
};
|
|
2973
|
+
}
|
|
2974
|
+
function cn(t) {
|
|
2975
|
+
return t.toLowerCase().replace(on, "").replace(/\s+/g, "-");
|
|
2976
|
+
}
|
|
2977
|
+
function ln(t) {
|
|
2978
|
+
let e = t.trim();
|
|
2979
|
+
e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
|
|
2980
|
+
for (let n = 0; n < 3; n++)
|
|
2981
|
+
e = e.replace(/\*\*([^*]+)\*\*/g, "$1"), e = e.replace(/__([^_]+)__/g, "$1"), e = e.replace(/~~([^~]+)~~/g, "$1"), e = e.replace(/\*([^*]+)\*/g, "$1"), e = e.replace(/_([^_]+)_/g, "$1"), e = e.replace(/`([^`]+)`/g, "$1");
|
|
2982
|
+
return e.trim();
|
|
2983
|
+
}
|
|
2984
|
+
function hn(t, e) {
|
|
2985
|
+
if (t.length === 0)
|
|
2986
|
+
return "";
|
|
2987
|
+
const n = an(), s = t.map((o) => {
|
|
2988
|
+
const a = ln(o.text), c = n.slug(a, o.explicitId);
|
|
2989
|
+
return { level: o.level, text: a, anchor: c };
|
|
2990
|
+
}).filter((o) => o.level <= e);
|
|
2991
|
+
if (s.length === 0)
|
|
2992
|
+
return "";
|
|
2993
|
+
const i = Math.min(...s.map((o) => o.level));
|
|
2994
|
+
return s.map((o) => `${" ".repeat((o.level - i) * 2)}- [${o.text}](#${o.anchor})`).join(`
|
|
2995
|
+
`);
|
|
2996
|
+
}
|
|
2997
|
+
function dn(t, e = {}) {
|
|
2998
|
+
const r = E(t).filter((o) => {
|
|
2999
|
+
const a = A(o.inner);
|
|
3000
|
+
return a.length === 1 && ce(a[0]);
|
|
3001
|
+
});
|
|
3002
|
+
if (r.length === 0)
|
|
3003
|
+
return t;
|
|
3004
|
+
const s = sn(t);
|
|
3005
|
+
let i = t;
|
|
3006
|
+
for (let o = r.length - 1; o >= 0; o--) {
|
|
3007
|
+
const a = r[o], { maxLevel: c } = Tt(a.inner, e.path), h = hn(s, c), l = i.slice(0, a.start), d = i.slice(a.end);
|
|
3008
|
+
i = T(T(l, h), d);
|
|
3009
|
+
}
|
|
3010
|
+
return i;
|
|
3011
|
+
}
|
|
3012
|
+
async function le(t, e) {
|
|
3013
|
+
const n = e.path, r = e.context, s = e.registry ?? new _e(), i = e.warnings ?? [], o = e.visitStack ?? new Re(), {
|
|
2799
3014
|
source: a,
|
|
2800
3015
|
declarationUpdates: c
|
|
2801
|
-
} = await
|
|
2802
|
-
|
|
2803
|
-
_(
|
|
2804
|
-
|
|
3016
|
+
} = await Lt(t, { path: n, context: { ...r } });
|
|
3017
|
+
Gt(
|
|
3018
|
+
_(r, c ?? {}),
|
|
3019
|
+
i,
|
|
2805
3020
|
n
|
|
2806
3021
|
);
|
|
2807
|
-
const h = await
|
|
3022
|
+
const h = await Vt(a, {
|
|
2808
3023
|
path: n,
|
|
2809
|
-
context:
|
|
3024
|
+
context: r,
|
|
2810
3025
|
declarationUpdates: c ?? {},
|
|
2811
3026
|
loader: e.loader,
|
|
2812
3027
|
root: e.root,
|
|
2813
3028
|
constrainToRoot: e.constrainToRoot,
|
|
2814
3029
|
visitStack: o,
|
|
2815
|
-
warnings:
|
|
3030
|
+
warnings: i,
|
|
2816
3031
|
inComponent: e.inComponent ?? !1
|
|
2817
|
-
}), { source: l, context: d } = h, { source: f, directives: g } =
|
|
3032
|
+
}), { source: l, context: d } = h, { source: f, directives: g } = jt(l, {
|
|
2818
3033
|
path: n,
|
|
2819
3034
|
registry: s,
|
|
2820
3035
|
context: d
|
|
@@ -2822,7 +3037,7 @@ async function ae(t, e) {
|
|
|
2822
3037
|
if (g.length > 0 && !m)
|
|
2823
3038
|
throw new Error("loader is required when processing include directives");
|
|
2824
3039
|
let p = f;
|
|
2825
|
-
return g.length > 0 && m && (p = await
|
|
3040
|
+
return g.length > 0 && m && (p = await Ct({
|
|
2826
3041
|
source: f,
|
|
2827
3042
|
directives: g,
|
|
2828
3043
|
context: d,
|
|
@@ -2832,99 +3047,103 @@ async function ae(t, e) {
|
|
|
2832
3047
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
2833
3048
|
preserveHgComments: e.preserveHgComments,
|
|
2834
3049
|
visitStack: o,
|
|
2835
|
-
warnings:
|
|
3050
|
+
warnings: i,
|
|
2836
3051
|
registry: s,
|
|
2837
3052
|
constrainToRoot: e.constrainToRoot
|
|
2838
|
-
})), p = await
|
|
3053
|
+
})), p = await vt(p, {
|
|
2839
3054
|
context: d,
|
|
2840
3055
|
path: n,
|
|
2841
3056
|
registry: s,
|
|
2842
3057
|
loader: m,
|
|
2843
3058
|
rootDir: e.root,
|
|
2844
|
-
warnings:
|
|
3059
|
+
warnings: i,
|
|
2845
3060
|
visitStack: o,
|
|
2846
3061
|
parentContext: d,
|
|
2847
3062
|
preserveHgComments: e.preserveHgComments,
|
|
2848
3063
|
constrainToRoot: e.constrainToRoot
|
|
2849
|
-
}), p = await
|
|
3064
|
+
}), p = await We(p, d, {
|
|
2850
3065
|
path: n,
|
|
2851
3066
|
registry: s,
|
|
2852
3067
|
loader: m,
|
|
2853
3068
|
rootDir: e.root,
|
|
2854
|
-
warnings:
|
|
3069
|
+
warnings: i,
|
|
2855
3070
|
visitStack: o,
|
|
2856
3071
|
parentContext: d,
|
|
2857
3072
|
preserveHgComments: e.preserveHgComments,
|
|
2858
3073
|
constrainToRoot: e.constrainToRoot
|
|
2859
|
-
}), p =
|
|
3074
|
+
}), p = dn(p, { path: n }), p = Pt(p, e.preserveHgComments), p;
|
|
2860
3075
|
}
|
|
2861
|
-
async function
|
|
2862
|
-
const n = e.path,
|
|
3076
|
+
async function un(t, e = {}) {
|
|
3077
|
+
const n = e.path, r = _(e.context), s = e.registry ?? new _e(), i = e.warnings ?? [], o = e.visitStack ?? new Re(), { context: a, body: c, rawFrontMatter: h } = P(
|
|
2863
3078
|
t,
|
|
2864
3079
|
n
|
|
2865
|
-
), l = _(
|
|
2866
|
-
let d = await
|
|
3080
|
+
), l = _(r, a);
|
|
3081
|
+
let d = await le(c, {
|
|
2867
3082
|
...e,
|
|
2868
3083
|
context: l,
|
|
2869
3084
|
registry: s,
|
|
2870
|
-
warnings:
|
|
3085
|
+
warnings: i,
|
|
2871
3086
|
visitStack: o
|
|
2872
3087
|
});
|
|
2873
|
-
return d =
|
|
3088
|
+
return d = Ft(d, {
|
|
2874
3089
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
2875
3090
|
rawFrontMatter: h
|
|
2876
3091
|
}), {
|
|
2877
3092
|
markdown: d,
|
|
2878
|
-
warnings:
|
|
3093
|
+
warnings: i
|
|
2879
3094
|
};
|
|
2880
3095
|
}
|
|
2881
|
-
async function
|
|
2882
|
-
const n = e.path, { context:
|
|
2883
|
-
return
|
|
3096
|
+
async function fn(t, e) {
|
|
3097
|
+
const n = e.path, { context: r, body: s } = P(t, n), i = _(e.context, r);
|
|
3098
|
+
return le(s, {
|
|
2884
3099
|
...e,
|
|
2885
|
-
context:
|
|
3100
|
+
context: i,
|
|
2886
3101
|
preserveFrontMatter: !1
|
|
2887
3102
|
});
|
|
2888
3103
|
}
|
|
2889
|
-
async function
|
|
3104
|
+
async function mn(t, e, n) {
|
|
2890
3105
|
if (n != null && "serverContext" in n && n.serverContext != null)
|
|
2891
3106
|
throw u({
|
|
2892
3107
|
code: "server_context_on_client"
|
|
2893
3108
|
});
|
|
2894
|
-
|
|
2895
|
-
|
|
3109
|
+
if (n != null && "dataSources" in n && n.dataSources != null && Object.keys(n.dataSources).length > 0)
|
|
3110
|
+
throw u({
|
|
3111
|
+
code: "data_sources_on_client"
|
|
3112
|
+
});
|
|
3113
|
+
const r = n?.loader;
|
|
3114
|
+
if (!r)
|
|
2896
3115
|
throw u({
|
|
2897
3116
|
code: "parse_error",
|
|
2898
3117
|
details: { message: "loader is required for renderClient" }
|
|
2899
3118
|
});
|
|
2900
|
-
let s,
|
|
2901
|
-
typeof t == "string" ? s = t : (
|
|
3119
|
+
let s, i;
|
|
3120
|
+
typeof t == "string" ? s = t : (i = t.path, s = await r(t.path));
|
|
2902
3121
|
const o = _(e);
|
|
2903
|
-
return
|
|
3122
|
+
return un(s, {
|
|
2904
3123
|
context: o,
|
|
2905
|
-
loader:
|
|
3124
|
+
loader: r,
|
|
2906
3125
|
root: n?.root,
|
|
2907
|
-
path:
|
|
3126
|
+
path: i ?? n?.path,
|
|
2908
3127
|
preserveFrontMatter: n?.preserveFrontMatter,
|
|
2909
3128
|
preserveHgComments: n?.preserveHgComments,
|
|
2910
3129
|
constrainToRoot: n?.constrainToRoot
|
|
2911
3130
|
});
|
|
2912
3131
|
}
|
|
2913
|
-
function
|
|
2914
|
-
const n = [`[hyogen:${t}] ${e.code}`],
|
|
3132
|
+
function gn(t, e) {
|
|
3133
|
+
const n = [`[hyogen:${t}] ${e.code}`], r = {};
|
|
2915
3134
|
if (e.details)
|
|
2916
|
-
for (const [s,
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
for (const [s,
|
|
2920
|
-
n.push(` ${s}: ${String(
|
|
3135
|
+
for (const [s, i] of Object.entries(e.details))
|
|
3136
|
+
i !== void 0 && (r[s] = i);
|
|
3137
|
+
r.path === void 0 && e.path !== void 0 && (r.path = e.path);
|
|
3138
|
+
for (const [s, i] of Object.entries(r))
|
|
3139
|
+
n.push(` ${s}: ${String(i)}`);
|
|
2921
3140
|
return n.join(`
|
|
2922
3141
|
`);
|
|
2923
3142
|
}
|
|
2924
3143
|
export {
|
|
2925
3144
|
u as createHyogenError,
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
3145
|
+
gn as formatDiagnosticLog,
|
|
3146
|
+
Ve as formatMessage,
|
|
3147
|
+
mn as renderClient
|
|
2929
3148
|
};
|
|
2930
3149
|
//# sourceMappingURL=client.js.map
|