@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/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { stat as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
1
|
+
import { stat as ie, readFile as Me, mkdir as Xe, writeFile as Je } from "node:fs/promises";
|
|
2
|
+
import p from "node:path";
|
|
3
|
+
import { parse as Oe } from "yaml";
|
|
4
|
+
import { Readable as Qe } from "node:stream";
|
|
5
|
+
import et from "csv-parser";
|
|
6
|
+
import { existsSync as ye, statSync as tt } from "node:fs";
|
|
7
|
+
import nt from "fast-glob";
|
|
8
|
+
import rt from "picomatch";
|
|
9
|
+
function v(...t) {
|
|
8
10
|
const e = {};
|
|
9
11
|
for (const n of t)
|
|
10
12
|
n != null && Object.assign(e, n);
|
|
11
13
|
return e;
|
|
12
14
|
}
|
|
13
|
-
const
|
|
14
|
-
errors:
|
|
15
|
-
warnings:
|
|
16
|
-
warningReasons:
|
|
17
|
-
},
|
|
18
|
-
function
|
|
15
|
+
const it = { 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})" }, st = { 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})' }, ot = { 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" }, se = {
|
|
16
|
+
errors: it,
|
|
17
|
+
warnings: st,
|
|
18
|
+
warningReasons: ot
|
|
19
|
+
}, at = se.errors, ct = se.warnings;
|
|
20
|
+
function Le(t, e) {
|
|
19
21
|
return t === void 0 ? "" : t.replace(/\{([^}]+)\}/g, (n, r) => {
|
|
20
22
|
if (e === void 0 || !(r in e))
|
|
21
23
|
return n;
|
|
@@ -23,24 +25,24 @@ function Te(t, e) {
|
|
|
23
25
|
return i == null ? "" : String(i);
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
|
-
function
|
|
27
|
-
return
|
|
28
|
+
function lt(t, e) {
|
|
29
|
+
return Le(at[t], e);
|
|
28
30
|
}
|
|
29
|
-
function
|
|
30
|
-
return
|
|
31
|
+
function L(t, e) {
|
|
32
|
+
return Le(ct[t], e);
|
|
31
33
|
}
|
|
32
34
|
function d(t) {
|
|
33
|
-
const e = t.message ??
|
|
35
|
+
const e = t.message ?? lt(t.code, t.details), n = new Error(e);
|
|
34
36
|
return n.name = "HyogenError", n.code = t.code, n.message = e, n.path = t.path, n.details = t.details, n;
|
|
35
37
|
}
|
|
36
|
-
function
|
|
38
|
+
function ht(t) {
|
|
37
39
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
38
40
|
}
|
|
39
|
-
function
|
|
41
|
+
function dt(t = {}) {
|
|
40
42
|
const { from: e, via: n = "include" } = t;
|
|
41
43
|
return async (r) => {
|
|
42
44
|
try {
|
|
43
|
-
if (!(await
|
|
45
|
+
if (!(await ie(r)).isFile())
|
|
44
46
|
throw d({
|
|
45
47
|
code: "load_failed",
|
|
46
48
|
path: e,
|
|
@@ -49,9 +51,9 @@ function it(t = {}) {
|
|
|
49
51
|
reason: "not a file"
|
|
50
52
|
}
|
|
51
53
|
});
|
|
52
|
-
return await
|
|
54
|
+
return await Me(r, "utf8");
|
|
53
55
|
} catch (i) {
|
|
54
|
-
if (
|
|
56
|
+
if (ht(i))
|
|
55
57
|
throw i;
|
|
56
58
|
const s = i;
|
|
57
59
|
throw s.code === "ENOENT" ? d({
|
|
@@ -73,16 +75,16 @@ function it(t = {}) {
|
|
|
73
75
|
}
|
|
74
76
|
};
|
|
75
77
|
}
|
|
76
|
-
function
|
|
78
|
+
function H(t) {
|
|
77
79
|
return /^https?:\/\//i.test(t);
|
|
78
80
|
}
|
|
79
|
-
function
|
|
81
|
+
function ut(t) {
|
|
80
82
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
81
83
|
}
|
|
82
|
-
function
|
|
83
|
-
const { from: e, via: n = "include" } = t, r =
|
|
84
|
+
function oe(t = {}) {
|
|
85
|
+
const { from: e, via: n = "include" } = t, r = dt(t);
|
|
84
86
|
return async (i) => {
|
|
85
|
-
if (!
|
|
87
|
+
if (!H(i))
|
|
86
88
|
return r(i);
|
|
87
89
|
try {
|
|
88
90
|
const s = await fetch(i);
|
|
@@ -105,7 +107,7 @@ function $e(t = {}) {
|
|
|
105
107
|
});
|
|
106
108
|
return await s.text();
|
|
107
109
|
} catch (s) {
|
|
108
|
-
if (
|
|
110
|
+
if (ut(s))
|
|
109
111
|
throw s;
|
|
110
112
|
const o = s instanceof Error ? s.message : "unknown fetch error";
|
|
111
113
|
throw d({
|
|
@@ -119,29 +121,252 @@ function $e(t = {}) {
|
|
|
119
121
|
}
|
|
120
122
|
};
|
|
121
123
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
function pt(t) {
|
|
125
|
+
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
126
|
+
}
|
|
127
|
+
function ft(t) {
|
|
128
|
+
return Object.keys(t).sort((e, n) => Number(e) - Number(n)).map((e) => t[e] ?? "");
|
|
129
|
+
}
|
|
130
|
+
function mt(t) {
|
|
131
|
+
return t.every((e) => e === "");
|
|
132
|
+
}
|
|
133
|
+
async function gt(t) {
|
|
134
|
+
return new Promise((e, n) => {
|
|
135
|
+
const r = [];
|
|
136
|
+
Qe.from([t]).pipe(et({ headers: !1 })).on("data", (i) => {
|
|
137
|
+
const s = ft(i);
|
|
138
|
+
mt(s) || r.push(s);
|
|
139
|
+
}).on("end", () => e(r)).on("error", (i) => n(i));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async function wt(t, e) {
|
|
143
|
+
if (t.length === 0 || t.trim().length === 0)
|
|
144
|
+
throw d({
|
|
145
|
+
code: "parse_error",
|
|
146
|
+
path: e,
|
|
147
|
+
details: { message: "empty CSV" }
|
|
148
|
+
});
|
|
149
|
+
let n;
|
|
150
|
+
try {
|
|
151
|
+
n = await gt(t);
|
|
152
|
+
} catch (o) {
|
|
153
|
+
throw pt(o) ? o : d({
|
|
154
|
+
code: "parse_error",
|
|
155
|
+
path: e,
|
|
156
|
+
details: {
|
|
157
|
+
message: o instanceof Error ? o.message : "invalid CSV"
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (n.length === 0)
|
|
162
|
+
throw d({
|
|
163
|
+
code: "parse_error",
|
|
164
|
+
path: e,
|
|
165
|
+
details: { message: "empty CSV" }
|
|
166
|
+
});
|
|
167
|
+
const [r, ...i] = n, s = r.length;
|
|
168
|
+
for (const o of i)
|
|
169
|
+
if (o.length !== s)
|
|
170
|
+
throw d({
|
|
171
|
+
code: "parse_error",
|
|
172
|
+
path: e,
|
|
173
|
+
details: { message: "CSV row column count mismatch" }
|
|
174
|
+
});
|
|
175
|
+
return i.map((o) => {
|
|
176
|
+
const a = {};
|
|
177
|
+
for (let c = 0; c < r.length; c++)
|
|
178
|
+
a[r[c]] = o[c] ?? "";
|
|
179
|
+
return a;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function xt(t) {
|
|
183
|
+
return p.extname(t).slice(1).toLowerCase();
|
|
184
|
+
}
|
|
185
|
+
function kt(t, e) {
|
|
186
|
+
if (t.length === 0)
|
|
187
|
+
throw d({
|
|
188
|
+
code: "parse_error",
|
|
189
|
+
path: e,
|
|
190
|
+
details: { message: "empty data file" }
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
async function yt(t, e) {
|
|
194
|
+
kt(t, e);
|
|
195
|
+
const n = xt(e);
|
|
196
|
+
switch (n) {
|
|
197
|
+
case "json":
|
|
198
|
+
try {
|
|
199
|
+
return JSON.parse(t);
|
|
200
|
+
} catch (r) {
|
|
201
|
+
throw d({
|
|
202
|
+
code: "parse_error",
|
|
203
|
+
path: e,
|
|
204
|
+
details: {
|
|
205
|
+
message: r instanceof Error ? r.message : "invalid JSON"
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
case "yaml":
|
|
210
|
+
case "yml":
|
|
211
|
+
try {
|
|
212
|
+
return Oe(t);
|
|
213
|
+
} catch (r) {
|
|
214
|
+
throw d({
|
|
215
|
+
code: "parse_error",
|
|
216
|
+
path: e,
|
|
217
|
+
details: {
|
|
218
|
+
message: r instanceof Error ? r.message : "invalid YAML"
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
case "csv":
|
|
223
|
+
return wt(t, e);
|
|
224
|
+
default:
|
|
225
|
+
throw d({
|
|
226
|
+
code: "parse_error",
|
|
227
|
+
path: e,
|
|
228
|
+
details: {
|
|
229
|
+
format: n,
|
|
230
|
+
message: `unsupported data file format: ${n}`
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const bt = ".doc_root";
|
|
236
|
+
function B(t) {
|
|
124
237
|
let e;
|
|
125
|
-
for (
|
|
126
|
-
const n =
|
|
127
|
-
if (
|
|
238
|
+
for (ye(t) ? e = tt(t).isFile() ? p.dirname(t) : p.resolve(t) : e = p.dirname(p.resolve(t)); ; ) {
|
|
239
|
+
const n = p.join(e, bt);
|
|
240
|
+
if (ye(n))
|
|
128
241
|
return e;
|
|
129
|
-
const r =
|
|
242
|
+
const r = p.dirname(e);
|
|
130
243
|
if (r === e)
|
|
131
244
|
return;
|
|
132
245
|
e = r;
|
|
133
246
|
}
|
|
134
247
|
}
|
|
135
|
-
|
|
248
|
+
function vt(t, e) {
|
|
249
|
+
const n = p.relative(e, t);
|
|
250
|
+
return n === "" || !n.startsWith("..") && !p.isAbsolute(n);
|
|
251
|
+
}
|
|
252
|
+
function _t(t, e, n) {
|
|
253
|
+
const r = p.resolve(e), i = p.resolve(t);
|
|
254
|
+
if (!vt(i, r))
|
|
255
|
+
throw d({
|
|
256
|
+
code: "parse_error",
|
|
257
|
+
path: n,
|
|
258
|
+
details: { message: "path resolves outside root directory" }
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function Z(t, e = {}) {
|
|
262
|
+
const { rootDir: n, fromPath: r, documentPath: i, constrainToRoot: s = !1, hyogenPath: o = !1 } = e;
|
|
263
|
+
if (t.length === 0)
|
|
264
|
+
throw d({
|
|
265
|
+
code: "parse_error",
|
|
266
|
+
path: i,
|
|
267
|
+
details: { message: "empty template path" }
|
|
268
|
+
});
|
|
269
|
+
let a;
|
|
270
|
+
if (t.startsWith("/"))
|
|
271
|
+
if (n)
|
|
272
|
+
a = p.resolve(n, t.slice(1));
|
|
273
|
+
else {
|
|
274
|
+
if (o)
|
|
275
|
+
throw d({
|
|
276
|
+
code: "parse_error",
|
|
277
|
+
path: i,
|
|
278
|
+
details: { message: "root-relative paths require a doc root" }
|
|
279
|
+
});
|
|
280
|
+
if (p.isAbsolute(t))
|
|
281
|
+
a = p.resolve(t);
|
|
282
|
+
else
|
|
283
|
+
throw d({
|
|
284
|
+
code: "parse_error",
|
|
285
|
+
path: i,
|
|
286
|
+
details: { message: "root-relative paths require a doc root" }
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
else if (t.startsWith("./") || t.startsWith("../"))
|
|
290
|
+
if (r)
|
|
291
|
+
a = p.resolve(p.dirname(r), t);
|
|
292
|
+
else if (n)
|
|
293
|
+
a = p.resolve(n, t);
|
|
294
|
+
else
|
|
295
|
+
throw d({
|
|
296
|
+
code: "parse_error",
|
|
297
|
+
path: i,
|
|
298
|
+
details: { message: "root is required for relative template paths" }
|
|
299
|
+
});
|
|
300
|
+
else if (p.isAbsolute(t))
|
|
301
|
+
a = p.resolve(t);
|
|
302
|
+
else if (n)
|
|
303
|
+
a = p.resolve(n, t);
|
|
304
|
+
else
|
|
305
|
+
throw d({
|
|
306
|
+
code: "parse_error",
|
|
307
|
+
path: i,
|
|
308
|
+
details: { message: "root is required for relative template paths" }
|
|
309
|
+
});
|
|
310
|
+
return n && s && _t(a, n, i), a;
|
|
311
|
+
}
|
|
312
|
+
const be = 5 * 1024 * 1024;
|
|
313
|
+
function St(t) {
|
|
314
|
+
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
315
|
+
}
|
|
316
|
+
function Ct(t) {
|
|
317
|
+
return t?.root ? p.resolve(t.root) : B(process.cwd()) ?? process.cwd();
|
|
318
|
+
}
|
|
319
|
+
async function He(t, e) {
|
|
320
|
+
const n = Ct(e), r = e?.loader ?? oe(), i = {};
|
|
321
|
+
for (const [s, o] of Object.entries(t)) {
|
|
322
|
+
if (H(o))
|
|
323
|
+
throw d({
|
|
324
|
+
code: "load_failed",
|
|
325
|
+
path: o,
|
|
326
|
+
details: {
|
|
327
|
+
path: o,
|
|
328
|
+
reason: "remote data sources are not supported"
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
const a = Z(o, { rootDir: n });
|
|
332
|
+
let c;
|
|
333
|
+
try {
|
|
334
|
+
c = await r(a);
|
|
335
|
+
} catch (l) {
|
|
336
|
+
throw St(l) ? l : d({
|
|
337
|
+
code: "load_failed",
|
|
338
|
+
path: a,
|
|
339
|
+
details: {
|
|
340
|
+
path: a,
|
|
341
|
+
reason: l instanceof Error ? l.message : "unknown load error"
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
const h = Buffer.byteLength(c, "utf8");
|
|
346
|
+
if (h > be)
|
|
347
|
+
throw d({
|
|
348
|
+
code: "data_source_too_large",
|
|
349
|
+
path: a,
|
|
350
|
+
details: {
|
|
351
|
+
path: a,
|
|
352
|
+
size: h,
|
|
353
|
+
limit: be
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
i[s] = await yt(c, a);
|
|
357
|
+
}
|
|
358
|
+
return i;
|
|
359
|
+
}
|
|
360
|
+
async function Et(t, e) {
|
|
136
361
|
if (typeof t == "string")
|
|
137
362
|
return {
|
|
138
363
|
source: t,
|
|
139
364
|
rootDir: e?.root
|
|
140
365
|
};
|
|
141
|
-
const n =
|
|
366
|
+
const n = p.resolve(t.path);
|
|
142
367
|
let r;
|
|
143
368
|
try {
|
|
144
|
-
r = await
|
|
369
|
+
r = await ie(n);
|
|
145
370
|
} catch (a) {
|
|
146
371
|
const c = a;
|
|
147
372
|
throw c.code === "ENOENT" ? d({
|
|
@@ -169,7 +394,7 @@ async function at(t, e) {
|
|
|
169
394
|
});
|
|
170
395
|
let i;
|
|
171
396
|
try {
|
|
172
|
-
i = await
|
|
397
|
+
i = await Me(n, "utf8");
|
|
173
398
|
} catch (a) {
|
|
174
399
|
throw d({
|
|
175
400
|
code: "load_failed",
|
|
@@ -180,7 +405,7 @@ async function at(t, e) {
|
|
|
180
405
|
}
|
|
181
406
|
});
|
|
182
407
|
}
|
|
183
|
-
const s =
|
|
408
|
+
const s = B(n), o = e?.root ?? s;
|
|
184
409
|
return {
|
|
185
410
|
source: i,
|
|
186
411
|
rootDir: o,
|
|
@@ -188,7 +413,7 @@ async function at(t, e) {
|
|
|
188
413
|
constrainToRoot: s !== void 0
|
|
189
414
|
};
|
|
190
415
|
}
|
|
191
|
-
class
|
|
416
|
+
class De {
|
|
192
417
|
components = /* @__PURE__ */ new Map();
|
|
193
418
|
register(e, n, r) {
|
|
194
419
|
if (this.components.has(e.alias))
|
|
@@ -212,8 +437,8 @@ class Ae {
|
|
|
212
437
|
return this.components.has(e);
|
|
213
438
|
}
|
|
214
439
|
}
|
|
215
|
-
const
|
|
216
|
-
function
|
|
440
|
+
const ve = 64 * 1024;
|
|
441
|
+
function V(t, e) {
|
|
217
442
|
if (!t.startsWith("---"))
|
|
218
443
|
return { context: {}, body: t };
|
|
219
444
|
const n = t.indexOf(`
|
|
@@ -225,13 +450,13 @@ function U(t, e) {
|
|
|
225
450
|
if (r === -1)
|
|
226
451
|
return { context: {}, body: t };
|
|
227
452
|
const i = t.slice(n + 1, r), s = Buffer.byteLength(i, "utf8");
|
|
228
|
-
if (s >
|
|
453
|
+
if (s > ve)
|
|
229
454
|
throw d({
|
|
230
455
|
code: "frontmatter_too_large",
|
|
231
456
|
path: e,
|
|
232
457
|
details: {
|
|
233
458
|
size: s,
|
|
234
|
-
limit:
|
|
459
|
+
limit: ve
|
|
235
460
|
}
|
|
236
461
|
});
|
|
237
462
|
if (i.trim().length === 0)
|
|
@@ -242,7 +467,7 @@ function U(t, e) {
|
|
|
242
467
|
});
|
|
243
468
|
let o;
|
|
244
469
|
try {
|
|
245
|
-
const h =
|
|
470
|
+
const h = Oe(i);
|
|
246
471
|
if (h == null)
|
|
247
472
|
o = {};
|
|
248
473
|
else if (typeof h == "object" && !Array.isArray(h))
|
|
@@ -270,14 +495,14 @@ ${i}
|
|
|
270
495
|
---`
|
|
271
496
|
};
|
|
272
497
|
}
|
|
273
|
-
const
|
|
498
|
+
const $t = /* @__PURE__ */ new Set([
|
|
274
499
|
"string",
|
|
275
500
|
"number",
|
|
276
501
|
"boolean",
|
|
277
502
|
"object",
|
|
278
503
|
"array"
|
|
279
504
|
]);
|
|
280
|
-
function
|
|
505
|
+
function Wt(t, e) {
|
|
281
506
|
const n = t.props;
|
|
282
507
|
if (n === void 0)
|
|
283
508
|
return {};
|
|
@@ -296,13 +521,13 @@ function ht(t, e) {
|
|
|
296
521
|
const o = s, a = {};
|
|
297
522
|
if ("type" in o && o.type !== void 0) {
|
|
298
523
|
const c = String(o.type);
|
|
299
|
-
|
|
524
|
+
$t.has(c) ? a.type = c : a.type = void 0;
|
|
300
525
|
}
|
|
301
526
|
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[i] = a;
|
|
302
527
|
}
|
|
303
528
|
return r;
|
|
304
529
|
}
|
|
305
|
-
function
|
|
530
|
+
function Tt(t) {
|
|
306
531
|
if (t != null) {
|
|
307
532
|
if (typeof t == "string") return "string";
|
|
308
533
|
if (typeof t == "number") return "number";
|
|
@@ -311,30 +536,30 @@ function lt(t) {
|
|
|
311
536
|
if (typeof t == "object") return "object";
|
|
312
537
|
}
|
|
313
538
|
}
|
|
314
|
-
function
|
|
539
|
+
function At(t, e) {
|
|
315
540
|
return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
|
|
316
541
|
}
|
|
317
|
-
function
|
|
542
|
+
function G(t, e) {
|
|
318
543
|
return {
|
|
319
544
|
code: t,
|
|
320
|
-
message:
|
|
545
|
+
message: L(t, e),
|
|
321
546
|
details: e
|
|
322
547
|
};
|
|
323
548
|
}
|
|
324
|
-
function
|
|
549
|
+
function Rt(t, e, n) {
|
|
325
550
|
const r = [], i = {}, s = new Set(Object.keys(e));
|
|
326
551
|
for (const [o, a] of Object.entries(e)) {
|
|
327
552
|
const c = Object.prototype.hasOwnProperty.call(t, o);
|
|
328
553
|
let h = c ? t[o] : void 0;
|
|
329
554
|
if (c || (a.default !== void 0 ? h = a.default : (a.isRequired && r.push(
|
|
330
|
-
|
|
555
|
+
G("prop_missing", {
|
|
331
556
|
prop: o,
|
|
332
557
|
component: n
|
|
333
558
|
})
|
|
334
559
|
), h = void 0)), c && h !== void 0 && h !== null) {
|
|
335
|
-
const l = a.type ??
|
|
336
|
-
l && !
|
|
337
|
-
|
|
560
|
+
const l = a.type ?? Tt(h);
|
|
561
|
+
l && !At(h, l) && (r.push(
|
|
562
|
+
G("prop_type_mismatch", {
|
|
338
563
|
prop: o,
|
|
339
564
|
component: n,
|
|
340
565
|
expected: l,
|
|
@@ -346,78 +571,14 @@ function pt(t, e, n) {
|
|
|
346
571
|
}
|
|
347
572
|
for (const o of Object.keys(t))
|
|
348
573
|
s.has(o) || (Object.keys(e).length > 0 ? r.push(
|
|
349
|
-
|
|
574
|
+
G("prop_unknown", {
|
|
350
575
|
prop: o,
|
|
351
576
|
component: n
|
|
352
577
|
})
|
|
353
578
|
) : i[o] = t[o]);
|
|
354
579
|
return { values: i, warnings: r };
|
|
355
580
|
}
|
|
356
|
-
function
|
|
357
|
-
const n = u.relative(e, t);
|
|
358
|
-
return n === "" || !n.startsWith("..") && !u.isAbsolute(n);
|
|
359
|
-
}
|
|
360
|
-
function ft(t, e, n) {
|
|
361
|
-
const r = u.resolve(e), i = u.resolve(t);
|
|
362
|
-
if (!ut(i, r))
|
|
363
|
-
throw d({
|
|
364
|
-
code: "parse_error",
|
|
365
|
-
path: n,
|
|
366
|
-
details: { message: "path resolves outside root directory" }
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
function re(t, e = {}) {
|
|
370
|
-
const { rootDir: n, fromPath: r, documentPath: i, constrainToRoot: s = !1, hyogenPath: o = !1 } = e;
|
|
371
|
-
if (t.length === 0)
|
|
372
|
-
throw d({
|
|
373
|
-
code: "parse_error",
|
|
374
|
-
path: i,
|
|
375
|
-
details: { message: "empty template path" }
|
|
376
|
-
});
|
|
377
|
-
let a;
|
|
378
|
-
if (t.startsWith("/"))
|
|
379
|
-
if (n)
|
|
380
|
-
a = u.resolve(n, t.slice(1));
|
|
381
|
-
else {
|
|
382
|
-
if (o)
|
|
383
|
-
throw d({
|
|
384
|
-
code: "parse_error",
|
|
385
|
-
path: i,
|
|
386
|
-
details: { message: "root-relative paths require a doc root" }
|
|
387
|
-
});
|
|
388
|
-
if (u.isAbsolute(t))
|
|
389
|
-
a = u.resolve(t);
|
|
390
|
-
else
|
|
391
|
-
throw d({
|
|
392
|
-
code: "parse_error",
|
|
393
|
-
path: i,
|
|
394
|
-
details: { message: "root-relative paths require a doc root" }
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
else if (t.startsWith("./") || t.startsWith("../"))
|
|
398
|
-
if (r)
|
|
399
|
-
a = u.resolve(u.dirname(r), t);
|
|
400
|
-
else if (n)
|
|
401
|
-
a = u.resolve(n, t);
|
|
402
|
-
else
|
|
403
|
-
throw d({
|
|
404
|
-
code: "parse_error",
|
|
405
|
-
path: i,
|
|
406
|
-
details: { message: "root is required for relative template paths" }
|
|
407
|
-
});
|
|
408
|
-
else if (u.isAbsolute(t))
|
|
409
|
-
a = u.resolve(t);
|
|
410
|
-
else if (n)
|
|
411
|
-
a = u.resolve(n, t);
|
|
412
|
-
else
|
|
413
|
-
throw d({
|
|
414
|
-
code: "parse_error",
|
|
415
|
-
path: i,
|
|
416
|
-
details: { message: "root is required for relative template paths" }
|
|
417
|
-
});
|
|
418
|
-
return n && s && ft(a, n, i), a;
|
|
419
|
-
}
|
|
420
|
-
async function mt(t) {
|
|
581
|
+
async function Mt(t) {
|
|
421
582
|
const e = t.registry.get(t.alias);
|
|
422
583
|
if (!e)
|
|
423
584
|
throw d({
|
|
@@ -427,24 +588,24 @@ async function mt(t) {
|
|
|
427
588
|
message: `unregistered component: ${t.alias}`
|
|
428
589
|
}
|
|
429
590
|
});
|
|
430
|
-
const n =
|
|
591
|
+
const n = H(e.componentPath) ? e.componentPath : Z(e.componentPath, {
|
|
431
592
|
rootDir: t.rootDir,
|
|
432
593
|
fromPath: e.definedAt,
|
|
433
594
|
documentPath: t.path,
|
|
434
595
|
constrainToRoot: t.constrainToRoot,
|
|
435
596
|
hyogenPath: !0
|
|
436
|
-
}), r = await t.loader(n), { context: i, body: s } =
|
|
597
|
+
}), r = await t.loader(n), { context: i, body: s } = V(r, n), o = Wt(i, n), { values: a, warnings: c } = Rt(
|
|
437
598
|
t.props,
|
|
438
599
|
o,
|
|
439
600
|
t.alias
|
|
440
601
|
);
|
|
441
602
|
t.warnings.push(...c);
|
|
442
|
-
const { props: h, ...l } = i,
|
|
603
|
+
const { props: h, ...l } = i, u = v(
|
|
443
604
|
t.parentContext,
|
|
444
605
|
l,
|
|
445
606
|
a
|
|
446
|
-
),
|
|
447
|
-
context:
|
|
607
|
+
), m = (await xe(s, {
|
|
608
|
+
context: u,
|
|
448
609
|
loader: t.loader,
|
|
449
610
|
root: t.rootDir,
|
|
450
611
|
path: n,
|
|
@@ -456,40 +617,44 @@ async function mt(t) {
|
|
|
456
617
|
preserveHgComments: t.preserveHgComments,
|
|
457
618
|
constrainToRoot: t.constrainToRoot
|
|
458
619
|
})).trim();
|
|
459
|
-
if (
|
|
620
|
+
if (m.includes(`
|
|
460
621
|
`))
|
|
461
622
|
throw d({
|
|
462
623
|
code: "component_multiline_output",
|
|
463
624
|
path: n,
|
|
464
625
|
details: { alias: t.alias }
|
|
465
626
|
});
|
|
466
|
-
return
|
|
627
|
+
return m;
|
|
467
628
|
}
|
|
468
|
-
const
|
|
629
|
+
const Ot = /* @__PURE__ */ new Set([
|
|
469
630
|
"__proto__",
|
|
470
631
|
"prototype",
|
|
471
632
|
"constructor",
|
|
472
633
|
"__defineGetter__"
|
|
473
634
|
]);
|
|
474
|
-
function
|
|
475
|
-
return
|
|
635
|
+
function Lt(t) {
|
|
636
|
+
return Ot.has(t);
|
|
476
637
|
}
|
|
477
|
-
function
|
|
478
|
-
if (
|
|
638
|
+
function _e(t, e) {
|
|
639
|
+
if (Lt(t))
|
|
479
640
|
throw d({
|
|
480
641
|
code: "forbidden_property_access",
|
|
481
642
|
path: e,
|
|
482
643
|
details: { property: t }
|
|
483
644
|
});
|
|
484
645
|
}
|
|
485
|
-
function
|
|
646
|
+
function M(t) {
|
|
486
647
|
return !t;
|
|
487
648
|
}
|
|
488
|
-
function
|
|
489
|
-
if (t != null
|
|
490
|
-
|
|
649
|
+
function Ht(t, e) {
|
|
650
|
+
if (t != null) {
|
|
651
|
+
if (typeof t == "string")
|
|
652
|
+
return e === "length" ? t.length : void 0;
|
|
653
|
+
if (typeof t == "object")
|
|
654
|
+
return t[e];
|
|
655
|
+
}
|
|
491
656
|
}
|
|
492
|
-
function
|
|
657
|
+
function Dt(t, e, n) {
|
|
493
658
|
switch (t) {
|
|
494
659
|
case "+":
|
|
495
660
|
return e + n;
|
|
@@ -516,9 +681,9 @@ function kt(t, e, n) {
|
|
|
516
681
|
case "<":
|
|
517
682
|
return e < n;
|
|
518
683
|
case "&&":
|
|
519
|
-
return
|
|
684
|
+
return M(e) ? e : n;
|
|
520
685
|
case "||":
|
|
521
|
-
return
|
|
686
|
+
return M(e) ? n : e;
|
|
522
687
|
default:
|
|
523
688
|
return;
|
|
524
689
|
}
|
|
@@ -529,15 +694,15 @@ async function k(t, e) {
|
|
|
529
694
|
case "literal":
|
|
530
695
|
return t.value;
|
|
531
696
|
case "identifier":
|
|
532
|
-
return
|
|
697
|
+
return _e(t.name, r), n[t.name];
|
|
533
698
|
case "member": {
|
|
534
|
-
|
|
699
|
+
_e(t.property, r);
|
|
535
700
|
const i = await k(t.object, e);
|
|
536
|
-
return
|
|
701
|
+
return Ht(i, t.property);
|
|
537
702
|
}
|
|
538
703
|
case "default": {
|
|
539
704
|
const i = await k(t.left, e);
|
|
540
|
-
return
|
|
705
|
+
return M(i) ? k(t.right, e) : i;
|
|
541
706
|
}
|
|
542
707
|
case "unary": {
|
|
543
708
|
const i = await k(t.operand, e);
|
|
@@ -546,14 +711,14 @@ async function k(t, e) {
|
|
|
546
711
|
case "binary": {
|
|
547
712
|
if (t.op === "&&") {
|
|
548
713
|
const o = await k(t.left, e);
|
|
549
|
-
return
|
|
714
|
+
return M(o) ? o : k(t.right, e);
|
|
550
715
|
}
|
|
551
716
|
if (t.op === "||") {
|
|
552
717
|
const o = await k(t.left, e);
|
|
553
|
-
return
|
|
718
|
+
return M(o) ? k(t.right, e) : o;
|
|
554
719
|
}
|
|
555
720
|
const i = await k(t.left, e), s = await k(t.right, e);
|
|
556
|
-
return
|
|
721
|
+
return Dt(t.op, i, s);
|
|
557
722
|
}
|
|
558
723
|
case "call": {
|
|
559
724
|
if (!e.registry || !e.loader || !e.visitStack)
|
|
@@ -575,7 +740,7 @@ async function k(t, e) {
|
|
|
575
740
|
const i = {};
|
|
576
741
|
for (const [s, o] of Object.entries(t.args))
|
|
577
742
|
i[s] = await k(o, e);
|
|
578
|
-
return
|
|
743
|
+
return Mt({
|
|
579
744
|
alias: t.callee,
|
|
580
745
|
props: i,
|
|
581
746
|
parentContext: e.parentContext ?? n,
|
|
@@ -603,7 +768,7 @@ async function k(t, e) {
|
|
|
603
768
|
}
|
|
604
769
|
case "ternary": {
|
|
605
770
|
const i = await k(t.condition, e);
|
|
606
|
-
return
|
|
771
|
+
return M(i) ? k(t.alternate, e) : k(t.consequent, e);
|
|
607
772
|
}
|
|
608
773
|
case "template": {
|
|
609
774
|
let i = "";
|
|
@@ -620,29 +785,29 @@ async function k(t, e) {
|
|
|
620
785
|
return;
|
|
621
786
|
}
|
|
622
787
|
}
|
|
623
|
-
function
|
|
788
|
+
function X(t) {
|
|
624
789
|
return /[A-Za-z_$]/.test(t);
|
|
625
790
|
}
|
|
626
|
-
function
|
|
791
|
+
function Nt(t) {
|
|
627
792
|
return /[A-Za-z0-9_$]/.test(t);
|
|
628
793
|
}
|
|
629
794
|
function S(t, e, n = {}) {
|
|
630
795
|
const r = t.trim();
|
|
631
796
|
if (r.length === 0)
|
|
632
|
-
throw
|
|
633
|
-
const i = new
|
|
797
|
+
throw g(e, "empty expression");
|
|
798
|
+
const i = new Ft(r, e, n), s = i.parseExpression();
|
|
634
799
|
if (i.skipWhitespace(), i.hasMore())
|
|
635
|
-
throw
|
|
800
|
+
throw g(e, `unexpected token at position ${i.position}`);
|
|
636
801
|
return s;
|
|
637
802
|
}
|
|
638
|
-
function
|
|
803
|
+
function g(t, e) {
|
|
639
804
|
throw d({
|
|
640
805
|
code: "parse_error",
|
|
641
806
|
path: t,
|
|
642
807
|
details: { message: e }
|
|
643
808
|
});
|
|
644
809
|
}
|
|
645
|
-
class
|
|
810
|
+
class Ft {
|
|
646
811
|
constructor(e, n, r = {}) {
|
|
647
812
|
this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
|
|
648
813
|
}
|
|
@@ -679,7 +844,7 @@ class bt {
|
|
|
679
844
|
this.index++;
|
|
680
845
|
const n = this.parseTernary();
|
|
681
846
|
if (this.skipWhitespace(), this.peek() !== ":")
|
|
682
|
-
throw
|
|
847
|
+
throw g(this.path, "expected ':' in ternary expression");
|
|
683
848
|
this.index++;
|
|
684
849
|
const r = this.parseTernary();
|
|
685
850
|
return { type: "ternary", condition: e, consequent: n, alternate: r };
|
|
@@ -772,10 +937,10 @@ class bt {
|
|
|
772
937
|
this.skipWhitespace();
|
|
773
938
|
const n = this.readIdentifier();
|
|
774
939
|
if (!n)
|
|
775
|
-
throw
|
|
940
|
+
throw g(this.path, "expected property name after '.'");
|
|
776
941
|
if (this.skipWhitespace(), this.peek() === "(") {
|
|
777
942
|
if (n !== "toLocaleString")
|
|
778
|
-
throw
|
|
943
|
+
throw g(this.path, `unsupported method: ${n}()`);
|
|
779
944
|
this.index++;
|
|
780
945
|
const r = this.parseMethodArgs();
|
|
781
946
|
return { type: "method", object: e, method: n, args: r };
|
|
@@ -790,7 +955,7 @@ class bt {
|
|
|
790
955
|
for (e.push(this.parseLiteralValue()), this.skipWhitespace(); this.peek() === ","; )
|
|
791
956
|
this.index++, e.push(this.parseLiteralValue()), this.skipWhitespace();
|
|
792
957
|
if (this.peek() !== ")")
|
|
793
|
-
throw
|
|
958
|
+
throw g(this.path, "expected ')' after method arguments");
|
|
794
959
|
return this.index++, e;
|
|
795
960
|
}
|
|
796
961
|
parsePrimary() {
|
|
@@ -800,7 +965,7 @@ class bt {
|
|
|
800
965
|
this.index++;
|
|
801
966
|
const n = this.parseExpression();
|
|
802
967
|
if (this.skipWhitespace(), this.peek() !== ")")
|
|
803
|
-
throw
|
|
968
|
+
throw g(this.path, "expected ')'");
|
|
804
969
|
return this.index++, n;
|
|
805
970
|
}
|
|
806
971
|
if (e === "`")
|
|
@@ -813,13 +978,13 @@ class bt {
|
|
|
813
978
|
return { type: "literal", value: this.parseObjectLiteral() };
|
|
814
979
|
if (e === "[")
|
|
815
980
|
return { type: "literal", value: this.parseArrayLiteral() };
|
|
816
|
-
if (
|
|
981
|
+
if (X(e)) {
|
|
817
982
|
const n = this.readIdentifier();
|
|
818
983
|
if (n === "true" || n === "false" || n === "null" || n === "undefined")
|
|
819
984
|
return { type: "literal", value: n === "true" ? !0 : n === "false" ? !1 : n === "null" ? null : void 0 };
|
|
820
985
|
if (this.skipWhitespace(), this.peek() === "(") {
|
|
821
986
|
if (!this.allowCalls)
|
|
822
|
-
throw
|
|
987
|
+
throw g(
|
|
823
988
|
this.path,
|
|
824
989
|
"component calls are not allowed in template literals"
|
|
825
990
|
);
|
|
@@ -828,10 +993,10 @@ class bt {
|
|
|
828
993
|
return { type: "call", callee: n, args: r };
|
|
829
994
|
}
|
|
830
995
|
if (this.peek() === "[")
|
|
831
|
-
throw
|
|
996
|
+
throw g(this.path, "bracket access is not allowed");
|
|
832
997
|
return { type: "identifier", name: n };
|
|
833
998
|
}
|
|
834
|
-
throw
|
|
999
|
+
throw g(this.path, `unexpected character '${e}'`);
|
|
835
1000
|
}
|
|
836
1001
|
parseTemplateLiteral() {
|
|
837
1002
|
this.index++;
|
|
@@ -843,7 +1008,7 @@ class bt {
|
|
|
843
1008
|
return this.index++, e.push(n), { type: "template", parts: e };
|
|
844
1009
|
if (r === "\\") {
|
|
845
1010
|
if (this.index++, this.index >= this.input.length)
|
|
846
|
-
throw
|
|
1011
|
+
throw g(this.path, "unterminated template literal escape");
|
|
847
1012
|
n += this.input[this.index], this.index++;
|
|
848
1013
|
continue;
|
|
849
1014
|
}
|
|
@@ -857,7 +1022,7 @@ class bt {
|
|
|
857
1022
|
}
|
|
858
1023
|
n += r, this.index++;
|
|
859
1024
|
}
|
|
860
|
-
throw
|
|
1025
|
+
throw g(this.path, "unterminated template literal");
|
|
861
1026
|
}
|
|
862
1027
|
readTemplateExpression() {
|
|
863
1028
|
let e = 1;
|
|
@@ -891,27 +1056,27 @@ class bt {
|
|
|
891
1056
|
}
|
|
892
1057
|
this.index++;
|
|
893
1058
|
}
|
|
894
|
-
throw
|
|
1059
|
+
throw g(this.path, "unterminated template expression");
|
|
895
1060
|
}
|
|
896
1061
|
parseCallArgs() {
|
|
897
1062
|
if (this.skipWhitespace(), this.peek() === ")")
|
|
898
1063
|
return this.index++, {};
|
|
899
1064
|
if (this.peek() !== "{")
|
|
900
|
-
throw
|
|
1065
|
+
throw g(this.path, "expected object literal");
|
|
901
1066
|
this.index++, this.skipWhitespace();
|
|
902
1067
|
const e = {};
|
|
903
1068
|
if (this.peek() === "}") {
|
|
904
1069
|
if (this.index++, this.skipWhitespace(), this.peek() !== ")")
|
|
905
|
-
throw
|
|
1070
|
+
throw g(this.path, "expected ')' after call arguments");
|
|
906
1071
|
return this.index++, e;
|
|
907
1072
|
}
|
|
908
1073
|
for (; ; ) {
|
|
909
1074
|
this.skipWhitespace();
|
|
910
1075
|
const n = this.readIdentifier();
|
|
911
1076
|
if (!n)
|
|
912
|
-
throw
|
|
1077
|
+
throw g(this.path, "expected property name in object literal");
|
|
913
1078
|
if (this.skipWhitespace(), this.peek() !== ":")
|
|
914
|
-
throw
|
|
1079
|
+
throw g(this.path, "expected ':' in object literal");
|
|
915
1080
|
if (this.index++, this.skipWhitespace(), e[n] = this.parseTernary(), this.skipWhitespace(), this.peek() === "}") {
|
|
916
1081
|
this.index++;
|
|
917
1082
|
break;
|
|
@@ -923,15 +1088,15 @@ class bt {
|
|
|
923
1088
|
}
|
|
924
1089
|
continue;
|
|
925
1090
|
}
|
|
926
|
-
throw
|
|
1091
|
+
throw g(this.path, "expected ',' or '}' in object literal");
|
|
927
1092
|
}
|
|
928
1093
|
if (this.skipWhitespace(), this.peek() !== ")")
|
|
929
|
-
throw
|
|
1094
|
+
throw g(this.path, "expected ')' after call arguments");
|
|
930
1095
|
return this.index++, e;
|
|
931
1096
|
}
|
|
932
1097
|
parseObjectLiteral() {
|
|
933
1098
|
if (this.peek() !== "{")
|
|
934
|
-
throw
|
|
1099
|
+
throw g(this.path, "expected object literal");
|
|
935
1100
|
this.index++, this.skipWhitespace();
|
|
936
1101
|
const e = {};
|
|
937
1102
|
if (this.peek() === "}")
|
|
@@ -940,9 +1105,9 @@ class bt {
|
|
|
940
1105
|
this.skipWhitespace();
|
|
941
1106
|
const n = this.readIdentifier();
|
|
942
1107
|
if (!n)
|
|
943
|
-
throw
|
|
1108
|
+
throw g(this.path, "expected property name in object literal");
|
|
944
1109
|
if (this.skipWhitespace(), this.peek() !== ":")
|
|
945
|
-
throw
|
|
1110
|
+
throw g(this.path, "expected ':' in object literal");
|
|
946
1111
|
if (this.index++, this.skipWhitespace(), e[n] = this.parseLiteralValue(), this.skipWhitespace(), this.peek() === "}") {
|
|
947
1112
|
this.index++;
|
|
948
1113
|
break;
|
|
@@ -953,13 +1118,13 @@ class bt {
|
|
|
953
1118
|
break;
|
|
954
1119
|
}
|
|
955
1120
|
} else
|
|
956
|
-
throw
|
|
1121
|
+
throw g(this.path, "expected ',' or '}' in object literal");
|
|
957
1122
|
}
|
|
958
1123
|
return e;
|
|
959
1124
|
}
|
|
960
1125
|
parseArrayLiteral() {
|
|
961
1126
|
if (this.peek() !== "[")
|
|
962
|
-
throw
|
|
1127
|
+
throw g(this.path, "expected array literal");
|
|
963
1128
|
this.index++, this.skipWhitespace();
|
|
964
1129
|
const e = [];
|
|
965
1130
|
if (this.peek() === "]")
|
|
@@ -975,7 +1140,7 @@ class bt {
|
|
|
975
1140
|
break;
|
|
976
1141
|
}
|
|
977
1142
|
} else
|
|
978
|
-
throw
|
|
1143
|
+
throw g(this.path, "expected ',' or ']' in array literal");
|
|
979
1144
|
}
|
|
980
1145
|
return e;
|
|
981
1146
|
}
|
|
@@ -990,14 +1155,14 @@ class bt {
|
|
|
990
1155
|
return this.parseObjectLiteral();
|
|
991
1156
|
if (e === "[")
|
|
992
1157
|
return this.parseArrayLiteral();
|
|
993
|
-
if (
|
|
1158
|
+
if (X(e)) {
|
|
994
1159
|
const n = this.readIdentifier();
|
|
995
1160
|
if (n === "true") return !0;
|
|
996
1161
|
if (n === "false") return !1;
|
|
997
1162
|
if (n === "null") return null;
|
|
998
|
-
throw
|
|
1163
|
+
throw g(this.path, "object literal values must be literals");
|
|
999
1164
|
}
|
|
1000
|
-
throw
|
|
1165
|
+
throw g(this.path, "object literal values must be literals");
|
|
1001
1166
|
}
|
|
1002
1167
|
match(e) {
|
|
1003
1168
|
return this.skipWhitespace(), this.input.startsWith(e, this.index) ? (this.index += e.length, !0) : !1;
|
|
@@ -1008,9 +1173,9 @@ class bt {
|
|
|
1008
1173
|
readIdentifier() {
|
|
1009
1174
|
this.skipWhitespace();
|
|
1010
1175
|
const e = this.index;
|
|
1011
|
-
if (!
|
|
1176
|
+
if (!X(this.peek()))
|
|
1012
1177
|
return "";
|
|
1013
|
-
for (this.index++; this.index < this.input.length &&
|
|
1178
|
+
for (this.index++; this.index < this.input.length && Nt(this.peek()); )
|
|
1014
1179
|
this.index++;
|
|
1015
1180
|
return this.input.slice(e, this.index);
|
|
1016
1181
|
}
|
|
@@ -1024,14 +1189,14 @@ class bt {
|
|
|
1024
1189
|
return this.index++, n;
|
|
1025
1190
|
if (r === "\\") {
|
|
1026
1191
|
if (this.index++, this.index >= this.input.length)
|
|
1027
|
-
throw
|
|
1192
|
+
throw g(this.path, "unterminated string escape");
|
|
1028
1193
|
const i = this.input[this.index];
|
|
1029
1194
|
n += i, this.index++;
|
|
1030
1195
|
continue;
|
|
1031
1196
|
}
|
|
1032
1197
|
n += r, this.index++;
|
|
1033
1198
|
}
|
|
1034
|
-
throw
|
|
1199
|
+
throw g(this.path, "unterminated string literal");
|
|
1035
1200
|
}
|
|
1036
1201
|
readNumber() {
|
|
1037
1202
|
const e = this.index;
|
|
@@ -1039,11 +1204,11 @@ class bt {
|
|
|
1039
1204
|
this.index++;
|
|
1040
1205
|
const n = this.input.slice(e, this.index), r = Number(n);
|
|
1041
1206
|
if (Number.isNaN(r))
|
|
1042
|
-
throw
|
|
1207
|
+
throw g(this.path, `invalid number '${n}'`);
|
|
1043
1208
|
return r;
|
|
1044
1209
|
}
|
|
1045
1210
|
}
|
|
1046
|
-
async function
|
|
1211
|
+
async function Ne(t, e, n = {}) {
|
|
1047
1212
|
const r = n.path;
|
|
1048
1213
|
let i = "", s = 0;
|
|
1049
1214
|
for (; s < t.length; ) {
|
|
@@ -1058,24 +1223,24 @@ async function Re(t, e, n = {}) {
|
|
|
1058
1223
|
i += "{", s = o + 1;
|
|
1059
1224
|
continue;
|
|
1060
1225
|
}
|
|
1061
|
-
const h = a ? 3 : 2, l = a ? "}}}" : "}}",
|
|
1062
|
-
if (
|
|
1226
|
+
const h = a ? 3 : 2, l = a ? "}}}" : "}}", u = t.indexOf(l, o + h);
|
|
1227
|
+
if (u === -1)
|
|
1063
1228
|
throw d({
|
|
1064
1229
|
code: "parse_error",
|
|
1065
1230
|
path: r,
|
|
1066
1231
|
details: { message: "unclosed expression" }
|
|
1067
1232
|
});
|
|
1068
|
-
const
|
|
1233
|
+
const w = t.slice(o + h, u).trim(), m = S(w, r), f = await k(m, {
|
|
1069
1234
|
...n,
|
|
1070
1235
|
context: e,
|
|
1071
1236
|
path: r,
|
|
1072
1237
|
parentContext: n.parentContext ?? e
|
|
1073
1238
|
});
|
|
1074
|
-
i +=
|
|
1239
|
+
i += f == null ? "" : String(f), s = u + l.length;
|
|
1075
1240
|
}
|
|
1076
1241
|
return i;
|
|
1077
1242
|
}
|
|
1078
|
-
function
|
|
1243
|
+
function jt(t, e) {
|
|
1079
1244
|
let n = 0, r = 0;
|
|
1080
1245
|
for (; r < t.length; ) {
|
|
1081
1246
|
const i = t.indexOf(e, r);
|
|
@@ -1085,14 +1250,14 @@ function vt(t, e) {
|
|
|
1085
1250
|
}
|
|
1086
1251
|
return n;
|
|
1087
1252
|
}
|
|
1088
|
-
function
|
|
1089
|
-
const e = t.includes("@hg"), n = t.includes("@endhg"), r =
|
|
1253
|
+
function ae(t) {
|
|
1254
|
+
const e = t.includes("@hg"), n = t.includes("@endhg"), r = jt(t, "@@");
|
|
1090
1255
|
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";
|
|
1091
1256
|
}
|
|
1092
|
-
function
|
|
1257
|
+
function ce(t) {
|
|
1093
1258
|
return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
|
|
1094
1259
|
}
|
|
1095
|
-
function
|
|
1260
|
+
function le(t, e) {
|
|
1096
1261
|
let n = 0, r = !1;
|
|
1097
1262
|
for (; n < e; ) {
|
|
1098
1263
|
const i = t.indexOf("```", n);
|
|
@@ -1102,21 +1267,21 @@ function oe(t, e) {
|
|
|
1102
1267
|
}
|
|
1103
1268
|
return r;
|
|
1104
1269
|
}
|
|
1105
|
-
function
|
|
1270
|
+
function $(t) {
|
|
1106
1271
|
const e = [];
|
|
1107
1272
|
let n = 0;
|
|
1108
1273
|
for (; n < t.length; ) {
|
|
1109
1274
|
const r = t.indexOf("<!--", n);
|
|
1110
1275
|
if (r === -1)
|
|
1111
1276
|
break;
|
|
1112
|
-
if (
|
|
1277
|
+
if (le(t, r)) {
|
|
1113
1278
|
n = r + 4;
|
|
1114
1279
|
continue;
|
|
1115
1280
|
}
|
|
1116
1281
|
const i = t.indexOf("-->", r + 4);
|
|
1117
1282
|
if (i === -1)
|
|
1118
1283
|
break;
|
|
1119
|
-
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a =
|
|
1284
|
+
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = ae(o);
|
|
1120
1285
|
(a === "hg" || a === "at-at") && e.push({
|
|
1121
1286
|
start: r,
|
|
1122
1287
|
end: i + 3,
|
|
@@ -1126,40 +1291,40 @@ function C(t) {
|
|
|
1126
1291
|
}
|
|
1127
1292
|
return e;
|
|
1128
1293
|
}
|
|
1129
|
-
function
|
|
1294
|
+
function he(t) {
|
|
1130
1295
|
let e = 0;
|
|
1131
1296
|
for (; e < t.length; ) {
|
|
1132
1297
|
const n = t.indexOf("<!--", e);
|
|
1133
1298
|
if (n === -1)
|
|
1134
1299
|
return !1;
|
|
1135
|
-
if (
|
|
1300
|
+
if (le(t, n)) {
|
|
1136
1301
|
e = n + 4;
|
|
1137
1302
|
continue;
|
|
1138
1303
|
}
|
|
1139
1304
|
const r = t.indexOf("-->", n + 4);
|
|
1140
1305
|
if (r === -1)
|
|
1141
1306
|
return !1;
|
|
1142
|
-
const i = t.slice(n + 4, r), s =
|
|
1307
|
+
const i = t.slice(n + 4, r), s = ae(i);
|
|
1143
1308
|
if (s === "unclosed" || s === "mixed")
|
|
1144
1309
|
return !0;
|
|
1145
1310
|
e = r + 3;
|
|
1146
1311
|
}
|
|
1147
1312
|
return !1;
|
|
1148
1313
|
}
|
|
1149
|
-
function
|
|
1314
|
+
function de(t) {
|
|
1150
1315
|
let e = 0;
|
|
1151
1316
|
for (; e < t.length; ) {
|
|
1152
1317
|
const n = t.indexOf("<!--", e);
|
|
1153
1318
|
if (n === -1)
|
|
1154
1319
|
return null;
|
|
1155
|
-
if (
|
|
1320
|
+
if (le(t, n)) {
|
|
1156
1321
|
e = n + 4;
|
|
1157
1322
|
continue;
|
|
1158
1323
|
}
|
|
1159
1324
|
const r = t.indexOf("-->", n + 4);
|
|
1160
1325
|
if (r === -1)
|
|
1161
1326
|
return null;
|
|
1162
|
-
const i = t.slice(n + 4, r), s =
|
|
1327
|
+
const i = t.slice(n + 4, r), s = ae(i);
|
|
1163
1328
|
if (s === "mixed")
|
|
1164
1329
|
return "mixed @hg and @@ markers are not allowed";
|
|
1165
1330
|
if (s === "unclosed")
|
|
@@ -1168,25 +1333,25 @@ function ce(t) {
|
|
|
1168
1333
|
}
|
|
1169
1334
|
return null;
|
|
1170
1335
|
}
|
|
1171
|
-
function
|
|
1172
|
-
return
|
|
1336
|
+
function E(t) {
|
|
1337
|
+
return ce(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
|
|
1173
1338
|
}
|
|
1174
|
-
const
|
|
1175
|
-
function
|
|
1176
|
-
return
|
|
1339
|
+
const Bt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
|
|
1340
|
+
function ue(t) {
|
|
1341
|
+
return Bt.test(t.trim());
|
|
1177
1342
|
}
|
|
1178
|
-
function
|
|
1343
|
+
function J(t, e) {
|
|
1179
1344
|
throw d({
|
|
1180
1345
|
code: "parse_error",
|
|
1181
1346
|
path: t,
|
|
1182
1347
|
details: { message: e }
|
|
1183
1348
|
});
|
|
1184
1349
|
}
|
|
1185
|
-
function
|
|
1350
|
+
function It(t, e) {
|
|
1186
1351
|
let n = t;
|
|
1187
1352
|
const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
|
|
1188
1353
|
r && (n = r[1]);
|
|
1189
|
-
const i =
|
|
1354
|
+
const i = E(n);
|
|
1190
1355
|
if (i.length !== 1)
|
|
1191
1356
|
return null;
|
|
1192
1357
|
const s = i[0];
|
|
@@ -1199,7 +1364,7 @@ function St(t, e) {
|
|
|
1199
1364
|
if (s === "endeach")
|
|
1200
1365
|
return { kind: "endeach" };
|
|
1201
1366
|
if (/^IF\b/.test(s) || /^ELSE\b/.test(s) || /^ENDIF\b/.test(s))
|
|
1202
|
-
throw
|
|
1367
|
+
throw J(e, "control keywords must be lowercase");
|
|
1203
1368
|
const o = /^else\s+if\s+(.+)$/.exec(s);
|
|
1204
1369
|
if (o)
|
|
1205
1370
|
return {
|
|
@@ -1220,25 +1385,25 @@ function St(t, e) {
|
|
|
1220
1385
|
expr: S(c[2], e)
|
|
1221
1386
|
};
|
|
1222
1387
|
if (s === "if")
|
|
1223
|
-
throw
|
|
1388
|
+
throw J(e, "if requires an expression");
|
|
1224
1389
|
if (/^each\s+/.test(s))
|
|
1225
|
-
throw
|
|
1390
|
+
throw J(e, "invalid each directive");
|
|
1226
1391
|
return null;
|
|
1227
1392
|
}
|
|
1228
|
-
function
|
|
1393
|
+
function O(t) {
|
|
1229
1394
|
return { start: t.start, end: t.end, raw: t.raw };
|
|
1230
1395
|
}
|
|
1231
|
-
function
|
|
1396
|
+
function C(t, e) {
|
|
1232
1397
|
throw d({
|
|
1233
1398
|
code: "parse_error",
|
|
1234
1399
|
path: t,
|
|
1235
1400
|
details: { message: e }
|
|
1236
1401
|
});
|
|
1237
1402
|
}
|
|
1238
|
-
function
|
|
1403
|
+
function Ut(t, e) {
|
|
1239
1404
|
const n = [];
|
|
1240
|
-
for (const r of
|
|
1241
|
-
const i =
|
|
1405
|
+
for (const r of $(t)) {
|
|
1406
|
+
const i = It(r.inner, e);
|
|
1242
1407
|
i && n.push({
|
|
1243
1408
|
start: r.start,
|
|
1244
1409
|
end: r.end,
|
|
@@ -1248,85 +1413,85 @@ function Ct(t, e) {
|
|
|
1248
1413
|
}
|
|
1249
1414
|
return n;
|
|
1250
1415
|
}
|
|
1251
|
-
function
|
|
1416
|
+
function Fe(t) {
|
|
1252
1417
|
return t.kind === "if" || t.kind === "each";
|
|
1253
1418
|
}
|
|
1254
|
-
function
|
|
1255
|
-
const n =
|
|
1419
|
+
function zt(t, e) {
|
|
1420
|
+
const n = Ut(t, e);
|
|
1256
1421
|
if (n.length === 0)
|
|
1257
1422
|
return t.length > 0 ? [{ kind: "text", content: t }] : [];
|
|
1258
|
-
const { nodes: r, nextIndex: i } =
|
|
1423
|
+
const { nodes: r, nextIndex: i } = F(t, n, 0, n.length, e);
|
|
1259
1424
|
if (i < n.length) {
|
|
1260
1425
|
const s = n[i];
|
|
1261
1426
|
if (s.opener.kind === "endif")
|
|
1262
|
-
throw
|
|
1427
|
+
throw C(e, "endif without matching if");
|
|
1263
1428
|
if (s.opener.kind === "endeach")
|
|
1264
|
-
throw
|
|
1429
|
+
throw C(e, "endeach without matching each");
|
|
1265
1430
|
if (s.opener.kind === "else" || s.opener.kind === "else_if")
|
|
1266
|
-
throw
|
|
1431
|
+
throw C(e, "else without matching if");
|
|
1267
1432
|
}
|
|
1268
1433
|
return r;
|
|
1269
1434
|
}
|
|
1270
|
-
function
|
|
1435
|
+
function F(t, e, n, r, i, s = 0, o) {
|
|
1271
1436
|
const a = o ?? t.length, c = [];
|
|
1272
1437
|
let h = s, l = n;
|
|
1273
1438
|
for (; l < r; ) {
|
|
1274
|
-
const
|
|
1275
|
-
if (
|
|
1439
|
+
const u = e[l];
|
|
1440
|
+
if (u.start >= a)
|
|
1276
1441
|
break;
|
|
1277
|
-
if (
|
|
1442
|
+
if (u.end <= s) {
|
|
1278
1443
|
l++;
|
|
1279
1444
|
continue;
|
|
1280
1445
|
}
|
|
1281
|
-
if (
|
|
1446
|
+
if (u.start > h && c.push({
|
|
1282
1447
|
kind: "text",
|
|
1283
|
-
content: t.slice(h,
|
|
1284
|
-
}),
|
|
1285
|
-
const
|
|
1286
|
-
c.push(
|
|
1448
|
+
content: t.slice(h, u.start)
|
|
1449
|
+
}), u.opener.kind === "if") {
|
|
1450
|
+
const w = Zt(t, e, l, r, i);
|
|
1451
|
+
c.push(w.node), h = w.endPos, l = w.nextIndex;
|
|
1287
1452
|
continue;
|
|
1288
1453
|
}
|
|
1289
|
-
if (
|
|
1290
|
-
const
|
|
1291
|
-
c.push(
|
|
1454
|
+
if (u.opener.kind === "each") {
|
|
1455
|
+
const w = Vt(t, e, l, r, i);
|
|
1456
|
+
c.push(w.node), h = w.endPos, l = w.nextIndex;
|
|
1292
1457
|
continue;
|
|
1293
1458
|
}
|
|
1294
|
-
if (
|
|
1295
|
-
throw
|
|
1296
|
-
if (
|
|
1297
|
-
throw
|
|
1298
|
-
if (
|
|
1299
|
-
throw
|
|
1459
|
+
if (u.opener.kind === "else" || u.opener.kind === "else_if")
|
|
1460
|
+
throw C(i, "else without matching if");
|
|
1461
|
+
if (u.opener.kind === "endif")
|
|
1462
|
+
throw C(i, "endif without matching if");
|
|
1463
|
+
if (u.opener.kind === "endeach")
|
|
1464
|
+
throw C(i, "endeach without matching each");
|
|
1300
1465
|
l++;
|
|
1301
1466
|
}
|
|
1302
1467
|
return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
|
|
1303
1468
|
}
|
|
1304
|
-
function
|
|
1469
|
+
function Zt(t, e, n, r, i) {
|
|
1305
1470
|
const s = e[n];
|
|
1306
1471
|
if (s.opener.kind !== "if")
|
|
1307
|
-
throw
|
|
1472
|
+
throw C(i, "expected if");
|
|
1308
1473
|
const o = [];
|
|
1309
1474
|
let a = n, c = s.end, h = 0;
|
|
1310
1475
|
for (; a < r; ) {
|
|
1311
1476
|
const l = e[a];
|
|
1312
1477
|
if (a === n) {
|
|
1313
1478
|
if (l.opener.kind !== "if")
|
|
1314
|
-
throw
|
|
1479
|
+
throw C(i, "expected if");
|
|
1315
1480
|
o.push({
|
|
1316
1481
|
kind: "if",
|
|
1317
1482
|
expr: l.opener.expr,
|
|
1318
|
-
opener:
|
|
1483
|
+
opener: O(l),
|
|
1319
1484
|
body: []
|
|
1320
1485
|
}), a++;
|
|
1321
1486
|
continue;
|
|
1322
1487
|
}
|
|
1323
|
-
if (
|
|
1488
|
+
if (Fe(l.opener)) {
|
|
1324
1489
|
h++, a++;
|
|
1325
1490
|
continue;
|
|
1326
1491
|
}
|
|
1327
1492
|
if (l.opener.kind === "endif") {
|
|
1328
1493
|
if (h === 0)
|
|
1329
|
-
return o[o.length - 1].body =
|
|
1494
|
+
return o[o.length - 1].body = F(
|
|
1330
1495
|
t,
|
|
1331
1496
|
e,
|
|
1332
1497
|
n + 1,
|
|
@@ -1335,7 +1500,7 @@ function Et(t, e, n, r, i) {
|
|
|
1335
1500
|
c,
|
|
1336
1501
|
l.start
|
|
1337
1502
|
).nodes, {
|
|
1338
|
-
node: { kind: "if", branches: o, closer:
|
|
1503
|
+
node: { kind: "if", branches: o, closer: O(l) },
|
|
1339
1504
|
nextIndex: a + 1,
|
|
1340
1505
|
endPos: l.end
|
|
1341
1506
|
};
|
|
@@ -1348,7 +1513,7 @@ function Et(t, e, n, r, i) {
|
|
|
1348
1513
|
}
|
|
1349
1514
|
if (h === 0) {
|
|
1350
1515
|
if (l.opener.kind === "else_if") {
|
|
1351
|
-
o[o.length - 1].body =
|
|
1516
|
+
o[o.length - 1].body = F(
|
|
1352
1517
|
t,
|
|
1353
1518
|
e,
|
|
1354
1519
|
n + 1,
|
|
@@ -1359,13 +1524,13 @@ function Et(t, e, n, r, i) {
|
|
|
1359
1524
|
).nodes, o.push({
|
|
1360
1525
|
kind: "else_if",
|
|
1361
1526
|
expr: l.opener.expr,
|
|
1362
|
-
opener:
|
|
1527
|
+
opener: O(l),
|
|
1363
1528
|
body: []
|
|
1364
1529
|
}), c = l.end, a++;
|
|
1365
1530
|
continue;
|
|
1366
1531
|
}
|
|
1367
1532
|
if (l.opener.kind === "else") {
|
|
1368
|
-
o[o.length - 1].body =
|
|
1533
|
+
o[o.length - 1].body = F(
|
|
1369
1534
|
t,
|
|
1370
1535
|
e,
|
|
1371
1536
|
n + 1,
|
|
@@ -1375,7 +1540,7 @@ function Et(t, e, n, r, i) {
|
|
|
1375
1540
|
l.start
|
|
1376
1541
|
).nodes, o.push({
|
|
1377
1542
|
kind: "else",
|
|
1378
|
-
opener:
|
|
1543
|
+
opener: O(l),
|
|
1379
1544
|
body: []
|
|
1380
1545
|
}), c = l.end, a++;
|
|
1381
1546
|
continue;
|
|
@@ -1383,24 +1548,24 @@ function Et(t, e, n, r, i) {
|
|
|
1383
1548
|
}
|
|
1384
1549
|
a++;
|
|
1385
1550
|
}
|
|
1386
|
-
throw
|
|
1551
|
+
throw C(i, "unclosed if block (missing endif)");
|
|
1387
1552
|
}
|
|
1388
|
-
function
|
|
1553
|
+
function Vt(t, e, n, r, i) {
|
|
1389
1554
|
const s = e[n];
|
|
1390
1555
|
if (s.opener.kind !== "each")
|
|
1391
|
-
throw
|
|
1556
|
+
throw C(i, "expected each");
|
|
1392
1557
|
let o = n + 1;
|
|
1393
1558
|
const a = s.end;
|
|
1394
1559
|
let c = 0;
|
|
1395
1560
|
for (; o < r; ) {
|
|
1396
1561
|
const h = e[o];
|
|
1397
|
-
if (
|
|
1562
|
+
if (Fe(h.opener)) {
|
|
1398
1563
|
c++, o++;
|
|
1399
1564
|
continue;
|
|
1400
1565
|
}
|
|
1401
1566
|
if (h.opener.kind === "endeach") {
|
|
1402
1567
|
if (c === 0) {
|
|
1403
|
-
const l =
|
|
1568
|
+
const l = F(
|
|
1404
1569
|
t,
|
|
1405
1570
|
e,
|
|
1406
1571
|
n + 1,
|
|
@@ -1414,9 +1579,9 @@ function Tt(t, e, n, r, i) {
|
|
|
1414
1579
|
kind: "each",
|
|
1415
1580
|
item: s.opener.item,
|
|
1416
1581
|
expr: s.opener.expr,
|
|
1417
|
-
opener:
|
|
1582
|
+
opener: O(s),
|
|
1418
1583
|
body: l,
|
|
1419
|
-
closer:
|
|
1584
|
+
closer: O(h)
|
|
1420
1585
|
},
|
|
1421
1586
|
nextIndex: o + 1,
|
|
1422
1587
|
endPos: h.end
|
|
@@ -1431,28 +1596,28 @@ function Tt(t, e, n, r, i) {
|
|
|
1431
1596
|
}
|
|
1432
1597
|
o++;
|
|
1433
1598
|
}
|
|
1434
|
-
throw
|
|
1599
|
+
throw C(i, "unclosed each block (missing endeach)");
|
|
1435
1600
|
}
|
|
1436
|
-
const
|
|
1437
|
-
class
|
|
1601
|
+
const Se = 20;
|
|
1602
|
+
class qt {
|
|
1438
1603
|
depth = 0;
|
|
1439
1604
|
get currentDepth() {
|
|
1440
1605
|
return this.depth;
|
|
1441
1606
|
}
|
|
1442
1607
|
enter() {
|
|
1443
|
-
return this.depth >=
|
|
1608
|
+
return this.depth >= Se ? { exceeded: !0, limit: Se } : (this.depth++, { exceeded: !1, depth: this.depth });
|
|
1444
1609
|
}
|
|
1445
1610
|
exit() {
|
|
1446
1611
|
this.depth > 0 && this.depth--;
|
|
1447
1612
|
}
|
|
1448
1613
|
}
|
|
1449
|
-
function
|
|
1614
|
+
function Pt(t) {
|
|
1450
1615
|
return !!t;
|
|
1451
1616
|
}
|
|
1452
|
-
function
|
|
1617
|
+
function Kt(t) {
|
|
1453
1618
|
return t != null && typeof t[Symbol.iterator] == "function";
|
|
1454
1619
|
}
|
|
1455
|
-
function
|
|
1620
|
+
function je(t) {
|
|
1456
1621
|
return {
|
|
1457
1622
|
code: "nest_limit_exceeded",
|
|
1458
1623
|
message: "structure nest limit exceeded",
|
|
@@ -1460,38 +1625,38 @@ function Oe(t) {
|
|
|
1460
1625
|
details: { limit: 20 }
|
|
1461
1626
|
};
|
|
1462
1627
|
}
|
|
1463
|
-
function
|
|
1628
|
+
function pe(t) {
|
|
1464
1629
|
return t.startsWith(`
|
|
1465
1630
|
`) ? t.slice(1) : t;
|
|
1466
1631
|
}
|
|
1467
|
-
async function
|
|
1468
|
-
const n = e.path, r = e.warnings ?? [], i =
|
|
1469
|
-
return
|
|
1632
|
+
async function Yt(t, e) {
|
|
1633
|
+
const n = e.path, r = e.warnings ?? [], i = zt(t, n), s = new qt();
|
|
1634
|
+
return fe(i, e, s, r);
|
|
1470
1635
|
}
|
|
1471
|
-
async function
|
|
1636
|
+
async function fe(t, e, n, r) {
|
|
1472
1637
|
const i = e.preserveHgComments === !0;
|
|
1473
1638
|
let s = "", o = !1;
|
|
1474
1639
|
for (const a of t) {
|
|
1475
|
-
let c = await
|
|
1476
|
-
o && (c =
|
|
1640
|
+
let c = await Gt(a, e, n, r);
|
|
1641
|
+
o && (c = pe(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
|
|
1477
1642
|
}
|
|
1478
1643
|
return s;
|
|
1479
1644
|
}
|
|
1480
|
-
async function
|
|
1645
|
+
async function Gt(t, e, n, r) {
|
|
1481
1646
|
switch (t.kind) {
|
|
1482
1647
|
case "text":
|
|
1483
1648
|
return t.content;
|
|
1484
1649
|
case "if":
|
|
1485
|
-
return
|
|
1650
|
+
return Xt(t, e, n, r);
|
|
1486
1651
|
case "each":
|
|
1487
|
-
return
|
|
1652
|
+
return Jt(t, e, n, r);
|
|
1488
1653
|
default:
|
|
1489
1654
|
return "";
|
|
1490
1655
|
}
|
|
1491
1656
|
}
|
|
1492
|
-
async function
|
|
1657
|
+
async function Xt(t, e, n, r) {
|
|
1493
1658
|
if (n.enter().exceeded)
|
|
1494
|
-
return r.push(
|
|
1659
|
+
return r.push(je(e.path)), "";
|
|
1495
1660
|
try {
|
|
1496
1661
|
let s = -1;
|
|
1497
1662
|
for (let c = 0; c < t.branches.length; c++) {
|
|
@@ -1501,7 +1666,7 @@ async function Lt(t, e, n, r) {
|
|
|
1501
1666
|
break;
|
|
1502
1667
|
}
|
|
1503
1668
|
const l = await k(h.expr, e);
|
|
1504
|
-
if (
|
|
1669
|
+
if (Pt(l)) {
|
|
1505
1670
|
s = c;
|
|
1506
1671
|
break;
|
|
1507
1672
|
}
|
|
@@ -1511,8 +1676,8 @@ async function Lt(t, e, n, r) {
|
|
|
1511
1676
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1512
1677
|
const h = t.branches[c];
|
|
1513
1678
|
if (o && (a += h.opener.raw), c === s) {
|
|
1514
|
-
let l = await
|
|
1515
|
-
o || (l =
|
|
1679
|
+
let l = await fe(h.body, e, n, r);
|
|
1680
|
+
o || (l = pe(l)), a += l;
|
|
1516
1681
|
}
|
|
1517
1682
|
}
|
|
1518
1683
|
return o && (a += t.closer.raw), a;
|
|
@@ -1520,24 +1685,24 @@ async function Lt(t, e, n, r) {
|
|
|
1520
1685
|
n.exit();
|
|
1521
1686
|
}
|
|
1522
1687
|
}
|
|
1523
|
-
async function
|
|
1688
|
+
async function Jt(t, e, n, r) {
|
|
1524
1689
|
if (n.enter().exceeded)
|
|
1525
|
-
return r.push(
|
|
1690
|
+
return r.push(je(e.path)), "";
|
|
1526
1691
|
try {
|
|
1527
1692
|
const s = await k(t.expr, e);
|
|
1528
|
-
if (!
|
|
1693
|
+
if (!Kt(s))
|
|
1529
1694
|
return "";
|
|
1530
1695
|
const o = e.preserveHgComments === !0;
|
|
1531
1696
|
let a = "";
|
|
1532
1697
|
for (const c of s) {
|
|
1533
1698
|
const h = { ...e.context, [t.item]: c };
|
|
1534
1699
|
o && (a += t.opener.raw);
|
|
1535
|
-
let l = await
|
|
1700
|
+
let l = await fe(t.body, {
|
|
1536
1701
|
...e,
|
|
1537
1702
|
context: h
|
|
1538
1703
|
}, n, r);
|
|
1539
|
-
o || (l =
|
|
1540
|
-
const
|
|
1704
|
+
o || (l = pe(l));
|
|
1705
|
+
const u = await Ne(l, h, {
|
|
1541
1706
|
path: e.path,
|
|
1542
1707
|
registry: e.registry,
|
|
1543
1708
|
loader: e.loader,
|
|
@@ -1548,15 +1713,15 @@ async function Dt(t, e, n, r) {
|
|
|
1548
1713
|
preserveHgComments: e.preserveHgComments,
|
|
1549
1714
|
constrainToRoot: e.constrainToRoot
|
|
1550
1715
|
});
|
|
1551
|
-
a +=
|
|
1716
|
+
a += u, o && (a += t.closer.raw);
|
|
1552
1717
|
}
|
|
1553
1718
|
return a;
|
|
1554
1719
|
} finally {
|
|
1555
1720
|
n.exit();
|
|
1556
1721
|
}
|
|
1557
1722
|
}
|
|
1558
|
-
function
|
|
1559
|
-
return
|
|
1723
|
+
function ee(t, e, n, r, i = !1, s = !1) {
|
|
1724
|
+
return H(e) ? e : Z(e, {
|
|
1560
1725
|
rootDir: t,
|
|
1561
1726
|
fromPath: r,
|
|
1562
1727
|
documentPath: n,
|
|
@@ -1564,40 +1729,40 @@ function J(t, e, n, r, i = !1, s = !1) {
|
|
|
1564
1729
|
hyogenPath: s
|
|
1565
1730
|
});
|
|
1566
1731
|
}
|
|
1567
|
-
function
|
|
1732
|
+
function Be(t) {
|
|
1568
1733
|
let e = 0;
|
|
1569
1734
|
for (let n = t.length - 1; n >= 0 && t[n] === `
|
|
1570
1735
|
`; n--)
|
|
1571
1736
|
e++;
|
|
1572
1737
|
return e;
|
|
1573
1738
|
}
|
|
1574
|
-
function
|
|
1739
|
+
function Ie(t) {
|
|
1575
1740
|
let e = 0;
|
|
1576
1741
|
for (; e < t.length && t[e] === `
|
|
1577
1742
|
`; )
|
|
1578
1743
|
e++;
|
|
1579
1744
|
return e;
|
|
1580
1745
|
}
|
|
1581
|
-
function
|
|
1582
|
-
const n =
|
|
1746
|
+
function A(t, e) {
|
|
1747
|
+
const n = Be(t), r = Ie(e), i = Math.max(n, r);
|
|
1583
1748
|
return t.slice(0, t.length - n) + `
|
|
1584
1749
|
`.repeat(i) + e.slice(r);
|
|
1585
1750
|
}
|
|
1586
|
-
function
|
|
1587
|
-
const n =
|
|
1751
|
+
function me(t, e) {
|
|
1752
|
+
const n = Be(t), r = Ie(e);
|
|
1588
1753
|
return n + r - Math.max(n, r);
|
|
1589
1754
|
}
|
|
1590
|
-
function
|
|
1755
|
+
function Ce(t, e, n) {
|
|
1591
1756
|
const r = t.indexOf(e);
|
|
1592
1757
|
if (r < 0)
|
|
1593
1758
|
return t;
|
|
1594
1759
|
const i = t.slice(0, r), s = t.slice(r + e.length);
|
|
1595
|
-
return
|
|
1760
|
+
return A(A(i, n), s);
|
|
1596
1761
|
}
|
|
1597
|
-
async function
|
|
1762
|
+
async function Qt(t) {
|
|
1598
1763
|
let e = t.source;
|
|
1599
1764
|
for (const n of t.directives) {
|
|
1600
|
-
const r =
|
|
1765
|
+
const r = ee(
|
|
1601
1766
|
t.root,
|
|
1602
1767
|
n.path,
|
|
1603
1768
|
t.path,
|
|
@@ -1610,7 +1775,7 @@ async function Nt(t) {
|
|
|
1610
1775
|
if (i.circular) {
|
|
1611
1776
|
t.warnings?.push({
|
|
1612
1777
|
code: "circular_include",
|
|
1613
|
-
message:
|
|
1778
|
+
message: L("circular_include", {
|
|
1614
1779
|
path: r,
|
|
1615
1780
|
from: i.from,
|
|
1616
1781
|
via: "include"
|
|
@@ -1621,13 +1786,13 @@ async function Nt(t) {
|
|
|
1621
1786
|
from: i.from,
|
|
1622
1787
|
via: "include"
|
|
1623
1788
|
}
|
|
1624
|
-
}), e =
|
|
1789
|
+
}), e = Ce(e, n.marker, "");
|
|
1625
1790
|
continue;
|
|
1626
1791
|
}
|
|
1627
1792
|
t.visitStack.push(r);
|
|
1628
1793
|
}
|
|
1629
1794
|
try {
|
|
1630
|
-
const i = await t.loader(r), s = await
|
|
1795
|
+
const i = await t.loader(r), s = await Nn(i, {
|
|
1631
1796
|
context: t.context,
|
|
1632
1797
|
loader: t.loader,
|
|
1633
1798
|
root: t.root,
|
|
@@ -1639,14 +1804,14 @@ async function Nt(t) {
|
|
|
1639
1804
|
registry: t.registry
|
|
1640
1805
|
}), o = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1641
1806
|
${s}` : s;
|
|
1642
|
-
e =
|
|
1807
|
+
e = Ce(e, n.marker, o);
|
|
1643
1808
|
} finally {
|
|
1644
1809
|
t.visitStack?.pop();
|
|
1645
1810
|
}
|
|
1646
1811
|
}
|
|
1647
1812
|
return e;
|
|
1648
1813
|
}
|
|
1649
|
-
class
|
|
1814
|
+
class Ue {
|
|
1650
1815
|
stack = [];
|
|
1651
1816
|
check(e) {
|
|
1652
1817
|
return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
|
|
@@ -1662,7 +1827,7 @@ class Ne {
|
|
|
1662
1827
|
this.stack.pop();
|
|
1663
1828
|
}
|
|
1664
1829
|
}
|
|
1665
|
-
async function
|
|
1830
|
+
async function en(t, e, n = {}) {
|
|
1666
1831
|
const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await k(t.expr, { context: e, path: r });
|
|
1667
1832
|
switch (t.kind) {
|
|
1668
1833
|
case "const": {
|
|
@@ -1703,16 +1868,16 @@ async function Ht(t, e, n = {}) {
|
|
|
1703
1868
|
}
|
|
1704
1869
|
}
|
|
1705
1870
|
}
|
|
1706
|
-
function
|
|
1871
|
+
function Ee(t) {
|
|
1707
1872
|
return !t;
|
|
1708
1873
|
}
|
|
1709
|
-
async function
|
|
1710
|
-
const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s } = n;
|
|
1874
|
+
async function N(t, e, n = {}) {
|
|
1875
|
+
const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s, echoChunks: o } = n;
|
|
1711
1876
|
switch (t.kind) {
|
|
1712
1877
|
case "const":
|
|
1713
1878
|
case "let":
|
|
1714
1879
|
case "assign": {
|
|
1715
|
-
await
|
|
1880
|
+
await en(t, e, { path: r, constBindings: i }), s?.(t.name);
|
|
1716
1881
|
return;
|
|
1717
1882
|
}
|
|
1718
1883
|
case "update": {
|
|
@@ -1732,8 +1897,8 @@ async function D(t, e, n = {}) {
|
|
|
1732
1897
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1733
1898
|
}
|
|
1734
1899
|
});
|
|
1735
|
-
const
|
|
1736
|
-
e[t.name] =
|
|
1900
|
+
const a = Number(e[t.name]), c = t.op === "++" ? a + 1 : a - 1;
|
|
1901
|
+
e[t.name] = c, s?.(t.name);
|
|
1737
1902
|
return;
|
|
1738
1903
|
}
|
|
1739
1904
|
case "compound_assign": {
|
|
@@ -1753,59 +1918,67 @@ async function D(t, e, n = {}) {
|
|
|
1753
1918
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1754
1919
|
}
|
|
1755
1920
|
});
|
|
1756
|
-
const
|
|
1757
|
-
let
|
|
1921
|
+
const a = await k(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
|
|
1922
|
+
let l;
|
|
1758
1923
|
switch (t.op) {
|
|
1759
1924
|
case "+=":
|
|
1760
|
-
|
|
1925
|
+
l = c + h;
|
|
1761
1926
|
break;
|
|
1762
1927
|
case "-=":
|
|
1763
|
-
|
|
1928
|
+
l = c - h;
|
|
1764
1929
|
break;
|
|
1765
1930
|
case "*=":
|
|
1766
|
-
|
|
1931
|
+
l = c * h;
|
|
1767
1932
|
break;
|
|
1768
1933
|
case "/=":
|
|
1769
|
-
|
|
1934
|
+
l = c / h;
|
|
1770
1935
|
break;
|
|
1771
1936
|
}
|
|
1772
|
-
e[t.name] =
|
|
1937
|
+
e[t.name] = l, s?.(t.name);
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
case "echo": {
|
|
1941
|
+
const a = await k(t.expr, {
|
|
1942
|
+
context: e,
|
|
1943
|
+
path: r
|
|
1944
|
+
}), c = a == null ? "" : String(a);
|
|
1945
|
+
o?.push(c);
|
|
1773
1946
|
return;
|
|
1774
1947
|
}
|
|
1775
1948
|
case "for": {
|
|
1776
|
-
for (t.init && await
|
|
1777
|
-
const
|
|
1949
|
+
for (t.init && await N(t.init, e, n); ; ) {
|
|
1950
|
+
const a = await k(t.cond, {
|
|
1778
1951
|
context: e,
|
|
1779
1952
|
path: r
|
|
1780
1953
|
});
|
|
1781
|
-
if (
|
|
1954
|
+
if (Ee(a))
|
|
1782
1955
|
break;
|
|
1783
|
-
for (const
|
|
1784
|
-
await
|
|
1785
|
-
t.update && await
|
|
1956
|
+
for (const c of t.body)
|
|
1957
|
+
await N(c, e, n);
|
|
1958
|
+
t.update && await N(t.update, e, n);
|
|
1786
1959
|
}
|
|
1787
1960
|
return;
|
|
1788
1961
|
}
|
|
1789
1962
|
case "do_while": {
|
|
1790
1963
|
do {
|
|
1791
|
-
for (const
|
|
1792
|
-
await
|
|
1793
|
-
const
|
|
1964
|
+
for (const c of t.body)
|
|
1965
|
+
await N(c, e, n);
|
|
1966
|
+
const a = await k(t.cond, {
|
|
1794
1967
|
context: e,
|
|
1795
1968
|
path: r
|
|
1796
1969
|
});
|
|
1797
|
-
if (
|
|
1970
|
+
if (Ee(a))
|
|
1798
1971
|
break;
|
|
1799
1972
|
} while (!0);
|
|
1800
1973
|
return;
|
|
1801
1974
|
}
|
|
1802
1975
|
}
|
|
1803
1976
|
}
|
|
1804
|
-
async function
|
|
1977
|
+
async function $e(t, e, n = {}) {
|
|
1805
1978
|
for (const r of t)
|
|
1806
|
-
await
|
|
1979
|
+
await N(r, e, n);
|
|
1807
1980
|
}
|
|
1808
|
-
const
|
|
1981
|
+
const tn = /* @__PURE__ */ new Set([
|
|
1809
1982
|
"if",
|
|
1810
1983
|
"else",
|
|
1811
1984
|
"endif",
|
|
@@ -1821,12 +1994,13 @@ const jt = /* @__PURE__ */ new Set([
|
|
|
1821
1994
|
"extend",
|
|
1822
1995
|
"include",
|
|
1823
1996
|
"component",
|
|
1824
|
-
"as"
|
|
1997
|
+
"as",
|
|
1998
|
+
"echo"
|
|
1825
1999
|
]);
|
|
1826
|
-
function
|
|
1827
|
-
return
|
|
2000
|
+
function ze(t) {
|
|
2001
|
+
return tn.has(t);
|
|
1828
2002
|
}
|
|
1829
|
-
function
|
|
2003
|
+
function ge(t) {
|
|
1830
2004
|
let e = "", n = 0, r = null;
|
|
1831
2005
|
for (; n < t.length; ) {
|
|
1832
2006
|
const i = t[n];
|
|
@@ -1866,11 +2040,11 @@ function x(t, e) {
|
|
|
1866
2040
|
details: { message: e }
|
|
1867
2041
|
});
|
|
1868
2042
|
}
|
|
1869
|
-
function
|
|
1870
|
-
const n =
|
|
2043
|
+
function We(t, e) {
|
|
2044
|
+
const n = ge(t).trim();
|
|
1871
2045
|
if (n.length === 0)
|
|
1872
2046
|
throw x(e, "empty statement block");
|
|
1873
|
-
const r = new
|
|
2047
|
+
const r = new we(n, e), i = r.parseStatementList();
|
|
1874
2048
|
if (r.skipWhitespace(), r.hasMore())
|
|
1875
2049
|
throw x(
|
|
1876
2050
|
e,
|
|
@@ -1880,11 +2054,11 @@ function Se(t, e) {
|
|
|
1880
2054
|
throw x(e, "empty statement block");
|
|
1881
2055
|
return i;
|
|
1882
2056
|
}
|
|
1883
|
-
function
|
|
1884
|
-
const e =
|
|
1885
|
-
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);
|
|
2057
|
+
function z(t) {
|
|
2058
|
+
const e = ge(t).trim();
|
|
2059
|
+
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);
|
|
1886
2060
|
}
|
|
1887
|
-
class
|
|
2061
|
+
class we {
|
|
1888
2062
|
constructor(e, n) {
|
|
1889
2063
|
this.input = e, this.path = n;
|
|
1890
2064
|
}
|
|
@@ -1917,7 +2091,7 @@ class fe {
|
|
|
1917
2091
|
this.path,
|
|
1918
2092
|
"bare while loops are not allowed (use do…while)"
|
|
1919
2093
|
);
|
|
1920
|
-
return this.parseSimpleStatement();
|
|
2094
|
+
return this.matchWord("echo") ? this.parseEcho() : this.parseSimpleStatement();
|
|
1921
2095
|
}
|
|
1922
2096
|
parseSimpleStatement() {
|
|
1923
2097
|
this.skipWhitespace();
|
|
@@ -1957,6 +2131,14 @@ class fe {
|
|
|
1957
2131
|
}
|
|
1958
2132
|
throw x(this.path, `invalid statement starting with: ${n}`);
|
|
1959
2133
|
}
|
|
2134
|
+
parseEcho() {
|
|
2135
|
+
this.skipWhitespace();
|
|
2136
|
+
const e = this.readExpressionSourceUntilTerminator();
|
|
2137
|
+
return {
|
|
2138
|
+
kind: "echo",
|
|
2139
|
+
expr: S(e, this.path)
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
1960
2142
|
readPrefixUpdate() {
|
|
1961
2143
|
if (this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
1962
2144
|
const e = this.input.slice(this.index - 2, this.index), n = this.readIdentifier();
|
|
@@ -1982,7 +2164,7 @@ class fe {
|
|
|
1982
2164
|
parseFor() {
|
|
1983
2165
|
if (this.skipWhitespace(), !this.match("("))
|
|
1984
2166
|
throw x(this.path, "expected '(' after for");
|
|
1985
|
-
const e = this.readBalanced(")"), n =
|
|
2167
|
+
const e = this.readBalanced(")"), n = nn(e);
|
|
1986
2168
|
if (n.length !== 3)
|
|
1987
2169
|
throw x(
|
|
1988
2170
|
this.path,
|
|
@@ -2021,7 +2203,7 @@ class fe {
|
|
|
2021
2203
|
return { kind: "do_while", body: e, cond: r };
|
|
2022
2204
|
}
|
|
2023
2205
|
parseClauseStatement(e) {
|
|
2024
|
-
const n = new
|
|
2206
|
+
const n = new we(e, this.path), r = n.parseSimpleStatement();
|
|
2025
2207
|
if (n.skipWhitespace(), n.hasMore())
|
|
2026
2208
|
throw x(
|
|
2027
2209
|
this.path,
|
|
@@ -2030,7 +2212,7 @@ class fe {
|
|
|
2030
2212
|
return r;
|
|
2031
2213
|
}
|
|
2032
2214
|
assertAssignableName(e) {
|
|
2033
|
-
if (
|
|
2215
|
+
if (ze(e))
|
|
2034
2216
|
throw x(
|
|
2035
2217
|
this.path,
|
|
2036
2218
|
`reserved word cannot be used as identifier: ${e}`
|
|
@@ -2137,7 +2319,7 @@ class fe {
|
|
|
2137
2319
|
return this.input.slice(e, this.index);
|
|
2138
2320
|
}
|
|
2139
2321
|
}
|
|
2140
|
-
function
|
|
2322
|
+
function nn(t) {
|
|
2141
2323
|
const e = [];
|
|
2142
2324
|
let n = "", r = 0, i = null;
|
|
2143
2325
|
for (let s = 0; s < t.length; s++) {
|
|
@@ -2170,7 +2352,7 @@ function Ft(t) {
|
|
|
2170
2352
|
}
|
|
2171
2353
|
return e.push(n), e;
|
|
2172
2354
|
}
|
|
2173
|
-
function
|
|
2355
|
+
function j(t, e) {
|
|
2174
2356
|
const n = t.trim();
|
|
2175
2357
|
if (!/^extend\b/i.test(n)) return null;
|
|
2176
2358
|
if (!/^extend\s+/i.test(n))
|
|
@@ -2195,10 +2377,10 @@ function H(t, e) {
|
|
|
2195
2377
|
});
|
|
2196
2378
|
return { path: i };
|
|
2197
2379
|
}
|
|
2198
|
-
function
|
|
2199
|
-
const n =
|
|
2380
|
+
function rn(t, e) {
|
|
2381
|
+
const n = E(t);
|
|
2200
2382
|
if (n.length === 0) return null;
|
|
2201
|
-
const r = n[0], i =
|
|
2383
|
+
const r = n[0], i = j(r, e);
|
|
2202
2384
|
if (!i) return null;
|
|
2203
2385
|
for (const s of n.slice(1))
|
|
2204
2386
|
if (/^extend\s+/i.test(s))
|
|
@@ -2213,17 +2395,51 @@ function Bt(t, e) {
|
|
|
2213
2395
|
`)
|
|
2214
2396
|
};
|
|
2215
2397
|
}
|
|
2216
|
-
|
|
2398
|
+
function q(t) {
|
|
2399
|
+
return /^toc(\(.*\))?$/.test(t.trim());
|
|
2400
|
+
}
|
|
2401
|
+
function sn(t, e) {
|
|
2402
|
+
const n = E(t);
|
|
2403
|
+
if (n.length !== 1)
|
|
2404
|
+
throw d({
|
|
2405
|
+
code: "parse_error",
|
|
2406
|
+
path: e,
|
|
2407
|
+
details: {
|
|
2408
|
+
message: "toc directive must be a single line"
|
|
2409
|
+
}
|
|
2410
|
+
});
|
|
2411
|
+
const r = n[0];
|
|
2412
|
+
if (r === "toc")
|
|
2413
|
+
return { maxLevel: 6 };
|
|
2414
|
+
const i = /^toc\((.*)\)$/.exec(r);
|
|
2415
|
+
if (!i)
|
|
2416
|
+
throw d({
|
|
2417
|
+
code: "parse_error",
|
|
2418
|
+
path: e,
|
|
2419
|
+
details: { message: `invalid toc directive: ${r}` }
|
|
2420
|
+
});
|
|
2421
|
+
const s = i[1];
|
|
2422
|
+
if (!/^[1-6]$/.test(s))
|
|
2423
|
+
throw d({
|
|
2424
|
+
code: "parse_error",
|
|
2425
|
+
path: e,
|
|
2426
|
+
details: {
|
|
2427
|
+
message: `invalid toc max level: ${s || "(empty)"} (expected integer 1–6)`
|
|
2428
|
+
}
|
|
2429
|
+
});
|
|
2430
|
+
return { maxLevel: Number(s) };
|
|
2431
|
+
}
|
|
2432
|
+
async function on(t, e = {}) {
|
|
2217
2433
|
const n = e.path, r = e.context ?? {};
|
|
2218
|
-
if (
|
|
2434
|
+
if (he(t))
|
|
2219
2435
|
throw d({
|
|
2220
2436
|
code: "parse_error",
|
|
2221
2437
|
path: n,
|
|
2222
2438
|
details: {
|
|
2223
|
-
message:
|
|
2439
|
+
message: de(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2224
2440
|
}
|
|
2225
2441
|
});
|
|
2226
|
-
const i =
|
|
2442
|
+
const i = $(t);
|
|
2227
2443
|
if (i.length === 0)
|
|
2228
2444
|
return { source: t, context: r, declarationUpdates: {} };
|
|
2229
2445
|
const s = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
|
|
@@ -2231,53 +2447,58 @@ async function It(t, e = {}) {
|
|
|
2231
2447
|
};
|
|
2232
2448
|
let c = t, h = 0;
|
|
2233
2449
|
for (const l of i) {
|
|
2234
|
-
const
|
|
2235
|
-
if (
|
|
2450
|
+
const u = E(l.inner);
|
|
2451
|
+
if (u.length === 1 && ue(u[0]) || u.length === 1 && q(u[0]) || u.length === 1 && /^include\s+/i.test(u[0]) || u.length === 1 && /^component\s+/i.test(u[0]))
|
|
2236
2452
|
continue;
|
|
2237
|
-
const
|
|
2238
|
-
if (
|
|
2239
|
-
if (
|
|
2240
|
-
const
|
|
2241
|
-
|
|
2453
|
+
const w = rn(l.inner, n);
|
|
2454
|
+
if (w) {
|
|
2455
|
+
if (w.declarationsSource.trim().length > 0) {
|
|
2456
|
+
const D = We(
|
|
2457
|
+
w.declarationsSource,
|
|
2242
2458
|
n
|
|
2243
2459
|
);
|
|
2244
|
-
await
|
|
2460
|
+
await $e(D, r, {
|
|
2245
2461
|
path: n,
|
|
2246
2462
|
constBindings: s,
|
|
2247
2463
|
onUpdate: a
|
|
2248
2464
|
});
|
|
2249
2465
|
}
|
|
2250
|
-
const
|
|
2251
|
-
extend ${
|
|
2466
|
+
const _ = l.start - h, R = l.end - h, I = `<!--@hg
|
|
2467
|
+
extend ${w.path}
|
|
2252
2468
|
@endhg-->`;
|
|
2253
|
-
c = c.slice(0,
|
|
2469
|
+
c = c.slice(0, _) + I + c.slice(R), h += l.raw.length - I.length;
|
|
2254
2470
|
continue;
|
|
2255
2471
|
}
|
|
2256
|
-
const
|
|
2472
|
+
const m = u.join(`
|
|
2257
2473
|
`);
|
|
2258
|
-
if (!
|
|
2259
|
-
if (
|
|
2474
|
+
if (!z(m)) {
|
|
2475
|
+
if (u.length === 1)
|
|
2260
2476
|
continue;
|
|
2261
2477
|
throw d({
|
|
2262
2478
|
code: "parse_error",
|
|
2263
2479
|
path: n,
|
|
2264
|
-
details: { message: `unsupported hyogen directive: ${
|
|
2480
|
+
details: { message: `unsupported hyogen directive: ${u[0]}` }
|
|
2265
2481
|
});
|
|
2266
2482
|
}
|
|
2267
|
-
const
|
|
2268
|
-
await
|
|
2483
|
+
const f = We(m, n), y = [];
|
|
2484
|
+
await $e(f, r, {
|
|
2269
2485
|
path: n,
|
|
2270
2486
|
constBindings: s,
|
|
2271
|
-
onUpdate: a
|
|
2487
|
+
onUpdate: a,
|
|
2488
|
+
echoChunks: y
|
|
2272
2489
|
});
|
|
2273
|
-
const
|
|
2274
|
-
|
|
2490
|
+
const W = l.start - h, P = l.end - h, T = c.slice(0, W), b = c.slice(P);
|
|
2491
|
+
if (y.length > 0) {
|
|
2492
|
+
const _ = y.join("");
|
|
2493
|
+
c = T + _ + b, h += l.raw.length - _.length;
|
|
2494
|
+
} else
|
|
2495
|
+
c = A(T, b), h += l.raw.length + me(T, b);
|
|
2275
2496
|
}
|
|
2276
2497
|
return { source: c, context: r, declarationUpdates: o };
|
|
2277
2498
|
}
|
|
2278
|
-
const
|
|
2279
|
-
function
|
|
2280
|
-
const n =
|
|
2499
|
+
const an = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
|
|
2500
|
+
function Ze(t, e) {
|
|
2501
|
+
const n = ce(t).trim();
|
|
2281
2502
|
if (n.length === 0)
|
|
2282
2503
|
throw d({
|
|
2283
2504
|
code: "parse_error",
|
|
@@ -2300,7 +2521,7 @@ function je(t, e) {
|
|
|
2300
2521
|
path: e,
|
|
2301
2522
|
details: { message: "include and component cannot coexist in one block" }
|
|
2302
2523
|
});
|
|
2303
|
-
const s =
|
|
2524
|
+
const s = an.exec(i);
|
|
2304
2525
|
if (!s)
|
|
2305
2526
|
throw d({
|
|
2306
2527
|
code: "parse_error",
|
|
@@ -2320,8 +2541,8 @@ function je(t, e) {
|
|
|
2320
2541
|
alias: s[2]
|
|
2321
2542
|
};
|
|
2322
2543
|
}
|
|
2323
|
-
function
|
|
2324
|
-
const n =
|
|
2544
|
+
function Ve(t, e) {
|
|
2545
|
+
const n = ce(t).trim();
|
|
2325
2546
|
if (n.length === 0)
|
|
2326
2547
|
throw d({
|
|
2327
2548
|
code: "parse_error",
|
|
@@ -2344,19 +2565,19 @@ function Fe(t, e) {
|
|
|
2344
2565
|
details: { message: `unsupported hyogen directive: ${i}` }
|
|
2345
2566
|
});
|
|
2346
2567
|
}
|
|
2347
|
-
function
|
|
2348
|
-
const e =
|
|
2568
|
+
function te(t) {
|
|
2569
|
+
const e = ge(t).trim();
|
|
2349
2570
|
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
|
|
2350
2571
|
}
|
|
2351
|
-
const
|
|
2352
|
-
function
|
|
2353
|
-
return `${
|
|
2572
|
+
const cn = "\0HYOGEN_INCLUDE_";
|
|
2573
|
+
function ln(t) {
|
|
2574
|
+
return `${cn}${t}\0`;
|
|
2354
2575
|
}
|
|
2355
|
-
function
|
|
2356
|
-
const n =
|
|
2357
|
-
if (n.length === 1 &&
|
|
2576
|
+
function hn(t, e) {
|
|
2577
|
+
const n = E(t);
|
|
2578
|
+
if (n.length === 1 && ue(n[0]))
|
|
2358
2579
|
return { kind: "control" };
|
|
2359
|
-
if (n.length === 1 && (
|
|
2580
|
+
if (n.length === 1 && q(n[0]) || n.length === 1 && (te(n[0]) || z(n[0])))
|
|
2360
2581
|
return null;
|
|
2361
2582
|
if (n.length !== 1)
|
|
2362
2583
|
throw d({
|
|
@@ -2372,9 +2593,9 @@ function qt(t, e) {
|
|
|
2372
2593
|
details: { message: "include and component cannot coexist in one block" }
|
|
2373
2594
|
});
|
|
2374
2595
|
if (/^include\s+/i.test(r))
|
|
2375
|
-
return
|
|
2596
|
+
return Ve(t, e);
|
|
2376
2597
|
if (/^component\s+/i.test(r))
|
|
2377
|
-
return
|
|
2598
|
+
return Ze(t, e);
|
|
2378
2599
|
if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
|
|
2379
2600
|
return null;
|
|
2380
2601
|
throw d({
|
|
@@ -2383,26 +2604,26 @@ function qt(t, e) {
|
|
|
2383
2604
|
details: { message: `unsupported hyogen directive: ${r}` }
|
|
2384
2605
|
});
|
|
2385
2606
|
}
|
|
2386
|
-
function
|
|
2607
|
+
function dn(t, e = {}) {
|
|
2387
2608
|
const n = e.path;
|
|
2388
|
-
if (
|
|
2609
|
+
if (he(t))
|
|
2389
2610
|
throw d({
|
|
2390
2611
|
code: "parse_error",
|
|
2391
2612
|
path: n,
|
|
2392
2613
|
details: {
|
|
2393
|
-
message:
|
|
2614
|
+
message: de(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2394
2615
|
}
|
|
2395
2616
|
});
|
|
2396
|
-
const r =
|
|
2617
|
+
const r = $(t);
|
|
2397
2618
|
if (r.length === 0)
|
|
2398
2619
|
return { source: t, directives: [] };
|
|
2399
2620
|
const i = [];
|
|
2400
2621
|
let s = t, o = 0, a = 0;
|
|
2401
2622
|
for (const c of r) {
|
|
2402
|
-
const h =
|
|
2623
|
+
const h = hn(c.inner, n);
|
|
2403
2624
|
if (!h || h.kind === "control")
|
|
2404
2625
|
continue;
|
|
2405
|
-
const l = c.start - o,
|
|
2626
|
+
const l = c.start - o, u = c.end - o;
|
|
2406
2627
|
if (h.kind === "component") {
|
|
2407
2628
|
e.registry && e.registry.register(
|
|
2408
2629
|
{
|
|
@@ -2413,39 +2634,39 @@ function Pt(t, e = {}) {
|
|
|
2413
2634
|
Object.keys(e.context ?? {}),
|
|
2414
2635
|
n
|
|
2415
2636
|
);
|
|
2416
|
-
const
|
|
2417
|
-
s =
|
|
2637
|
+
const m = s.slice(0, l), f = s.slice(u);
|
|
2638
|
+
s = A(m, f), o += c.raw.length + me(m, f);
|
|
2418
2639
|
continue;
|
|
2419
2640
|
}
|
|
2420
|
-
const
|
|
2421
|
-
i.push({ ...h, marker:
|
|
2641
|
+
const w = ln(a++);
|
|
2642
|
+
i.push({ ...h, marker: w, raw: c.raw }), s = s.slice(0, l) + w + s.slice(u), o += c.raw.length - w.length;
|
|
2422
2643
|
}
|
|
2423
2644
|
return { source: s, directives: i };
|
|
2424
2645
|
}
|
|
2425
|
-
function
|
|
2646
|
+
function un(t, e) {
|
|
2426
2647
|
return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
|
|
2427
2648
|
` : `${e.rawFrontMatter}
|
|
2428
2649
|
${t}`;
|
|
2429
2650
|
}
|
|
2430
|
-
function
|
|
2651
|
+
function pn(t, e = !1) {
|
|
2431
2652
|
if (e)
|
|
2432
2653
|
return t;
|
|
2433
|
-
const n =
|
|
2654
|
+
const n = $(t);
|
|
2434
2655
|
if (n.length === 0)
|
|
2435
2656
|
return t;
|
|
2436
2657
|
let r = t, i = 0;
|
|
2437
2658
|
for (const s of n) {
|
|
2438
2659
|
const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
|
|
2439
|
-
r =
|
|
2660
|
+
r = A(c, h), i += s.raw.length + me(c, h);
|
|
2440
2661
|
}
|
|
2441
2662
|
return r;
|
|
2442
2663
|
}
|
|
2443
|
-
const
|
|
2444
|
-
function
|
|
2664
|
+
const fn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
2665
|
+
function mn(t, e) {
|
|
2445
2666
|
const n = t.trim();
|
|
2446
2667
|
if (n === "endblock")
|
|
2447
2668
|
return { kind: "endblock" };
|
|
2448
|
-
const r =
|
|
2669
|
+
const r = fn.exec(n);
|
|
2449
2670
|
if (!r)
|
|
2450
2671
|
throw d({
|
|
2451
2672
|
code: "parse_error",
|
|
@@ -2453,7 +2674,7 @@ function Gt(t, e) {
|
|
|
2453
2674
|
details: { message: "invalid block directive" }
|
|
2454
2675
|
});
|
|
2455
2676
|
const i = r[1];
|
|
2456
|
-
if (
|
|
2677
|
+
if (ze(i))
|
|
2457
2678
|
throw d({
|
|
2458
2679
|
code: "parse_error",
|
|
2459
2680
|
path: e,
|
|
@@ -2461,35 +2682,35 @@ function Gt(t, e) {
|
|
|
2461
2682
|
});
|
|
2462
2683
|
return { kind: "block", name: i };
|
|
2463
2684
|
}
|
|
2464
|
-
function
|
|
2465
|
-
const { path: n, mode: r, hasExtend: i = !1 } = e, s =
|
|
2685
|
+
function Te(t, e) {
|
|
2686
|
+
const { path: n, mode: r, hasExtend: i = !1 } = e, s = $(t);
|
|
2466
2687
|
if (s.length === 0) return [];
|
|
2467
2688
|
const o = [], a = [], c = /* @__PURE__ */ new Set();
|
|
2468
2689
|
for (const h of s) {
|
|
2469
|
-
const l =
|
|
2690
|
+
const l = E(h.inner);
|
|
2470
2691
|
if (l.length !== 1) continue;
|
|
2471
|
-
const
|
|
2472
|
-
if (!(
|
|
2692
|
+
const u = l[0];
|
|
2693
|
+
if (!(u === "endblock" || u.startsWith("block "))) continue;
|
|
2473
2694
|
if (r === "child" && !i)
|
|
2474
2695
|
throw d({
|
|
2475
2696
|
code: "parse_error",
|
|
2476
2697
|
path: n,
|
|
2477
2698
|
details: { message: "orphan block without extend" }
|
|
2478
2699
|
});
|
|
2479
|
-
const
|
|
2480
|
-
if (
|
|
2481
|
-
const
|
|
2482
|
-
if (!
|
|
2700
|
+
const m = mn(u, n);
|
|
2701
|
+
if (m.kind === "endblock") {
|
|
2702
|
+
const f = a.pop();
|
|
2703
|
+
if (!f)
|
|
2483
2704
|
throw d({
|
|
2484
2705
|
code: "parse_error",
|
|
2485
2706
|
path: n,
|
|
2486
2707
|
details: { message: "endblock without matching block opener" }
|
|
2487
2708
|
});
|
|
2488
|
-
const y = t.slice(
|
|
2709
|
+
const y = t.slice(f.openerEnd, h.start);
|
|
2489
2710
|
o.push({
|
|
2490
|
-
name:
|
|
2711
|
+
name: f.name,
|
|
2491
2712
|
body: y,
|
|
2492
|
-
start:
|
|
2713
|
+
start: f.start,
|
|
2493
2714
|
end: h.end
|
|
2494
2715
|
});
|
|
2495
2716
|
continue;
|
|
@@ -2500,14 +2721,14 @@ function Ce(t, e) {
|
|
|
2500
2721
|
path: n,
|
|
2501
2722
|
details: { message: "nested block structures are not supported" }
|
|
2502
2723
|
});
|
|
2503
|
-
if (c.has(
|
|
2724
|
+
if (c.has(m.name))
|
|
2504
2725
|
throw d({
|
|
2505
2726
|
code: "parse_error",
|
|
2506
2727
|
path: n,
|
|
2507
|
-
details: { message: `duplicate block: ${
|
|
2728
|
+
details: { message: `duplicate block: ${m.name}` }
|
|
2508
2729
|
});
|
|
2509
|
-
c.add(
|
|
2510
|
-
name:
|
|
2730
|
+
c.add(m.name), a.push({
|
|
2731
|
+
name: m.name,
|
|
2511
2732
|
openerEnd: h.end,
|
|
2512
2733
|
start: h.start
|
|
2513
2734
|
});
|
|
@@ -2520,37 +2741,37 @@ function Ce(t, e) {
|
|
|
2520
2741
|
});
|
|
2521
2742
|
return o;
|
|
2522
2743
|
}
|
|
2523
|
-
function
|
|
2524
|
-
const e =
|
|
2744
|
+
function Ae(t) {
|
|
2745
|
+
const e = $(t), n = [];
|
|
2525
2746
|
for (const r of e) {
|
|
2526
|
-
const i =
|
|
2747
|
+
const i = E(r.inner);
|
|
2527
2748
|
if (i.length === 0) continue;
|
|
2528
|
-
const s =
|
|
2749
|
+
const s = j(i[0]);
|
|
2529
2750
|
s && n.push({ path: s.path, start: r.start });
|
|
2530
2751
|
}
|
|
2531
2752
|
return n;
|
|
2532
2753
|
}
|
|
2533
|
-
function
|
|
2534
|
-
const e =
|
|
2754
|
+
function gn(t) {
|
|
2755
|
+
const e = $(t);
|
|
2535
2756
|
for (const n of e) {
|
|
2536
|
-
const r =
|
|
2757
|
+
const r = E(n.inner);
|
|
2537
2758
|
if (r.length !== 1) continue;
|
|
2538
2759
|
const i = r[0];
|
|
2539
2760
|
if (i === "endblock" || i.startsWith("block ")) return !0;
|
|
2540
2761
|
}
|
|
2541
2762
|
return !1;
|
|
2542
2763
|
}
|
|
2543
|
-
function
|
|
2764
|
+
function Q(t) {
|
|
2544
2765
|
return t.map((e) => e.body).join("");
|
|
2545
2766
|
}
|
|
2546
|
-
function
|
|
2767
|
+
function wn(t, e, n) {
|
|
2547
2768
|
const r = [...e].sort((o, a) => o.start - a.start), i = [];
|
|
2548
2769
|
let s = 0;
|
|
2549
2770
|
for (const o of r)
|
|
2550
2771
|
i.push(t.slice(s, o.start)), i.push(n.get(o.name) ?? o.body), s = o.end;
|
|
2551
|
-
return i.push(t.slice(s)), i.reduce((o, a) =>
|
|
2772
|
+
return i.push(t.slice(s)), i.reduce((o, a) => A(o, a));
|
|
2552
2773
|
}
|
|
2553
|
-
function
|
|
2774
|
+
function xn(t) {
|
|
2554
2775
|
if (t instanceof Error && "code" in t && "details" in t) {
|
|
2555
2776
|
const e = t;
|
|
2556
2777
|
if (e.code === "file_not_found" && e.details && e.details.via === "include")
|
|
@@ -2558,7 +2779,7 @@ function Qt(t) {
|
|
|
2558
2779
|
}
|
|
2559
2780
|
return { errorToThrow: t, adjusted: !1 };
|
|
2560
2781
|
}
|
|
2561
|
-
async function
|
|
2782
|
+
async function kn(t, e) {
|
|
2562
2783
|
const {
|
|
2563
2784
|
path: n,
|
|
2564
2785
|
context: r,
|
|
@@ -2569,35 +2790,35 @@ async function en(t, e) {
|
|
|
2569
2790
|
visitStack: c,
|
|
2570
2791
|
warnings: h,
|
|
2571
2792
|
inComponent: l = !1
|
|
2572
|
-
} = e,
|
|
2573
|
-
if (
|
|
2574
|
-
if (
|
|
2793
|
+
} = e, u = Ae(t);
|
|
2794
|
+
if (u.length === 0) {
|
|
2795
|
+
if (gn(t))
|
|
2575
2796
|
throw d({
|
|
2576
2797
|
code: "parse_error",
|
|
2577
2798
|
path: n,
|
|
2578
2799
|
details: { message: "orphan block without extend" }
|
|
2579
2800
|
});
|
|
2580
|
-
return { source: t, context:
|
|
2801
|
+
return { source: t, context: v(r, i) };
|
|
2581
2802
|
}
|
|
2582
|
-
const
|
|
2583
|
-
if (!
|
|
2584
|
-
return { source: t, context:
|
|
2803
|
+
const m = $(t)[0];
|
|
2804
|
+
if (!m)
|
|
2805
|
+
return { source: t, context: v(r, i) };
|
|
2585
2806
|
if (!s)
|
|
2586
2807
|
throw new Error("loader is required when processing extend directives");
|
|
2587
|
-
const
|
|
2588
|
-
if (!(
|
|
2808
|
+
const f = E(m.inner);
|
|
2809
|
+
if (!(f.length > 0 ? j(f[0]) : null))
|
|
2589
2810
|
throw d({
|
|
2590
2811
|
code: "parse_error",
|
|
2591
2812
|
path: n,
|
|
2592
2813
|
details: { message: "extend must be the first hyogen block" }
|
|
2593
2814
|
});
|
|
2594
|
-
if (
|
|
2815
|
+
if (u.length > 1)
|
|
2595
2816
|
throw d({
|
|
2596
2817
|
code: "parse_error",
|
|
2597
2818
|
path: n,
|
|
2598
2819
|
details: { message: "multiple extend directives are not supported" }
|
|
2599
2820
|
});
|
|
2600
|
-
const
|
|
2821
|
+
const W = Te(t, {
|
|
2601
2822
|
path: n,
|
|
2602
2823
|
mode: "child",
|
|
2603
2824
|
hasExtend: !0
|
|
@@ -2605,102 +2826,102 @@ async function en(t, e) {
|
|
|
2605
2826
|
if (l)
|
|
2606
2827
|
return h?.push({
|
|
2607
2828
|
code: "extend_in_component",
|
|
2608
|
-
message:
|
|
2829
|
+
message: L("extend_in_component", { path: n }),
|
|
2609
2830
|
path: n,
|
|
2610
2831
|
details: { path: n }
|
|
2611
2832
|
}), {
|
|
2612
|
-
source:
|
|
2613
|
-
context:
|
|
2833
|
+
source: Q(W),
|
|
2834
|
+
context: v(r, i)
|
|
2614
2835
|
};
|
|
2615
|
-
const
|
|
2836
|
+
const P = u[0].path, T = n, b = ee(
|
|
2616
2837
|
o,
|
|
2617
|
-
|
|
2838
|
+
P,
|
|
2618
2839
|
n,
|
|
2619
2840
|
n,
|
|
2620
2841
|
a,
|
|
2621
2842
|
!0
|
|
2622
2843
|
);
|
|
2623
|
-
|
|
2844
|
+
T && c.push(T);
|
|
2624
2845
|
try {
|
|
2625
|
-
const
|
|
2626
|
-
if (
|
|
2846
|
+
const _ = T ? c.check(b) : { circular: !1 };
|
|
2847
|
+
if (_.circular)
|
|
2627
2848
|
return h?.push({
|
|
2628
2849
|
code: "circular_include",
|
|
2629
|
-
message:
|
|
2630
|
-
path:
|
|
2631
|
-
from:
|
|
2850
|
+
message: L("circular_include", {
|
|
2851
|
+
path: b,
|
|
2852
|
+
from: _.from,
|
|
2632
2853
|
via: "extend"
|
|
2633
2854
|
}),
|
|
2634
2855
|
path: n,
|
|
2635
|
-
details: { path:
|
|
2856
|
+
details: { path: b, from: _.from, via: "extend" }
|
|
2636
2857
|
}), {
|
|
2637
|
-
source:
|
|
2638
|
-
context:
|
|
2858
|
+
source: Q(W),
|
|
2859
|
+
context: v(r, i)
|
|
2639
2860
|
};
|
|
2640
|
-
c.push(
|
|
2861
|
+
c.push(b);
|
|
2641
2862
|
try {
|
|
2642
|
-
const
|
|
2643
|
-
if (
|
|
2863
|
+
const R = await s(b);
|
|
2864
|
+
if (R === void 0)
|
|
2644
2865
|
throw new Error("loader returned undefined");
|
|
2645
|
-
const { context:
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
),
|
|
2649
|
-
if (
|
|
2650
|
-
const
|
|
2866
|
+
const { context: I, body: D } = V(
|
|
2867
|
+
R,
|
|
2868
|
+
b
|
|
2869
|
+
), ke = Ae(D);
|
|
2870
|
+
if (ke.length > 0) {
|
|
2871
|
+
const U = ke[0].path, K = ee(
|
|
2651
2872
|
o,
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2873
|
+
U,
|
|
2874
|
+
b,
|
|
2875
|
+
b,
|
|
2655
2876
|
a,
|
|
2656
2877
|
!0
|
|
2657
|
-
),
|
|
2658
|
-
if (
|
|
2878
|
+
), Y = c.check(K);
|
|
2879
|
+
if (Y.circular)
|
|
2659
2880
|
return h?.push({
|
|
2660
2881
|
code: "circular_include",
|
|
2661
|
-
message:
|
|
2662
|
-
path:
|
|
2663
|
-
from:
|
|
2882
|
+
message: L("circular_include", {
|
|
2883
|
+
path: K,
|
|
2884
|
+
from: Y.from,
|
|
2664
2885
|
via: "extend"
|
|
2665
2886
|
}),
|
|
2666
2887
|
path: n,
|
|
2667
|
-
details: { path:
|
|
2888
|
+
details: { path: K, from: Y.from, via: "extend" }
|
|
2668
2889
|
}), {
|
|
2669
|
-
source:
|
|
2670
|
-
context:
|
|
2890
|
+
source: Q(W),
|
|
2891
|
+
context: v(r, i)
|
|
2671
2892
|
};
|
|
2672
2893
|
throw d({
|
|
2673
2894
|
code: "parse_error",
|
|
2674
|
-
path:
|
|
2895
|
+
path: b,
|
|
2675
2896
|
details: { message: "layout extend is not supported" }
|
|
2676
2897
|
});
|
|
2677
2898
|
}
|
|
2678
|
-
const
|
|
2679
|
-
path:
|
|
2899
|
+
const Pe = Te(D, {
|
|
2900
|
+
path: b,
|
|
2680
2901
|
mode: "layout"
|
|
2681
|
-
}),
|
|
2682
|
-
|
|
2683
|
-
),
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
),
|
|
2902
|
+
}), Ke = new Map(
|
|
2903
|
+
W.map((U) => [U.name, U.body])
|
|
2904
|
+
), Ye = wn(
|
|
2905
|
+
D,
|
|
2906
|
+
Pe,
|
|
2907
|
+
Ke
|
|
2908
|
+
), Ge = v(
|
|
2688
2909
|
r,
|
|
2689
|
-
|
|
2910
|
+
I,
|
|
2690
2911
|
i
|
|
2691
2912
|
);
|
|
2692
|
-
return { source:
|
|
2913
|
+
return { source: Ye, context: Ge };
|
|
2693
2914
|
} finally {
|
|
2694
2915
|
c.pop();
|
|
2695
2916
|
}
|
|
2696
|
-
} catch (
|
|
2697
|
-
const
|
|
2698
|
-
throw
|
|
2917
|
+
} catch (_) {
|
|
2918
|
+
const R = xn(_);
|
|
2919
|
+
throw R.adjusted ? R.errorToThrow : _;
|
|
2699
2920
|
} finally {
|
|
2700
|
-
|
|
2921
|
+
T && c.pop();
|
|
2701
2922
|
}
|
|
2702
2923
|
}
|
|
2703
|
-
const
|
|
2924
|
+
const yn = se.warningReasons, bn = [
|
|
2704
2925
|
{
|
|
2705
2926
|
reason: "contains_html_script_tag",
|
|
2706
2927
|
test: (t) => /<\/?script\b/i.test(t)
|
|
@@ -2722,17 +2943,17 @@ const tn = ne.warningReasons, nn = [
|
|
|
2722
2943
|
test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
|
|
2723
2944
|
}
|
|
2724
2945
|
];
|
|
2725
|
-
function
|
|
2726
|
-
return
|
|
2946
|
+
function vn(t) {
|
|
2947
|
+
return yn[t] ?? t;
|
|
2727
2948
|
}
|
|
2728
|
-
function
|
|
2949
|
+
function ne(t, e, n, r) {
|
|
2729
2950
|
if (typeof t == "string") {
|
|
2730
|
-
for (const i of
|
|
2951
|
+
for (const i of bn)
|
|
2731
2952
|
i.test(t) && n.push({
|
|
2732
2953
|
code: "suspicious_context_value",
|
|
2733
|
-
message:
|
|
2954
|
+
message: L("suspicious_context_value", {
|
|
2734
2955
|
key: e,
|
|
2735
|
-
reason:
|
|
2956
|
+
reason: vn(i.reason)
|
|
2736
2957
|
}),
|
|
2737
2958
|
path: r,
|
|
2738
2959
|
details: { key: e, reason: i.reason }
|
|
@@ -2742,7 +2963,7 @@ function ee(t, e, n, r) {
|
|
|
2742
2963
|
if (t != null) {
|
|
2743
2964
|
if (Array.isArray(t)) {
|
|
2744
2965
|
for (let i = 0; i < t.length; i++)
|
|
2745
|
-
|
|
2966
|
+
ne(t[i], `${e}[${i}]`, n, r);
|
|
2746
2967
|
return;
|
|
2747
2968
|
}
|
|
2748
2969
|
if (typeof t == "object")
|
|
@@ -2750,25 +2971,180 @@ function ee(t, e, n, r) {
|
|
|
2750
2971
|
t
|
|
2751
2972
|
)) {
|
|
2752
2973
|
const o = e.length > 0 ? `${e}.${i}` : i;
|
|
2753
|
-
|
|
2974
|
+
ne(s, o, n, r);
|
|
2754
2975
|
}
|
|
2755
2976
|
}
|
|
2756
2977
|
}
|
|
2757
|
-
function
|
|
2978
|
+
function _n(t, e, n) {
|
|
2758
2979
|
for (const [r, i] of Object.entries(t))
|
|
2759
|
-
|
|
2980
|
+
ne(i, r, e, n);
|
|
2981
|
+
}
|
|
2982
|
+
const Sn = /^=+[ \t]*$/, Cn = /^-+[ \t]*$/, En = /^(```|~~~)/, $n = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
|
|
2983
|
+
function re(t) {
|
|
2984
|
+
const e = $n.exec(t);
|
|
2985
|
+
return e && e.index !== void 0 ? {
|
|
2986
|
+
text: t.slice(0, e.index).trim(),
|
|
2987
|
+
explicitId: e[1]
|
|
2988
|
+
} : { text: t.trim() };
|
|
2989
|
+
}
|
|
2990
|
+
function Wn(t) {
|
|
2991
|
+
let e = 0;
|
|
2992
|
+
for (; e < t.length && e < 6 && t[e] === "#"; )
|
|
2993
|
+
e += 1;
|
|
2994
|
+
if (e === 0 || e === 6 && e < t.length && t[e] === "#" || e >= t.length || t[e] !== " " && t[e] !== " ")
|
|
2995
|
+
return null;
|
|
2996
|
+
let n = e;
|
|
2997
|
+
for (; n < t.length && (t[n] === " " || t[n] === " "); )
|
|
2998
|
+
n += 1;
|
|
2999
|
+
if (n >= t.length)
|
|
3000
|
+
return null;
|
|
3001
|
+
let r = t.length;
|
|
3002
|
+
for (; r > n && (t[r - 1] === " " || t[r - 1] === " "); )
|
|
3003
|
+
r -= 1;
|
|
3004
|
+
let i = r;
|
|
3005
|
+
if (r > n && t[r - 1] === "#") {
|
|
3006
|
+
let o = r - 1;
|
|
3007
|
+
for (; o > n && t[o - 1] === "#"; )
|
|
3008
|
+
o -= 1;
|
|
3009
|
+
if (o > n && (t[o - 1] === " " || t[o - 1] === " ")) {
|
|
3010
|
+
let a = o - 1;
|
|
3011
|
+
for (; a >= n && (t[a] === " " || t[a] === " "); )
|
|
3012
|
+
a -= 1;
|
|
3013
|
+
i = a + 1;
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
if (i <= n)
|
|
3017
|
+
return null;
|
|
3018
|
+
const s = re(t.slice(n, i));
|
|
3019
|
+
return { level: e, ...s };
|
|
3020
|
+
}
|
|
3021
|
+
function Re(t, e, n) {
|
|
3022
|
+
let r = n;
|
|
3023
|
+
for (; r < t.length; ) {
|
|
3024
|
+
if (!e.inHtmlComment) {
|
|
3025
|
+
const s = t.indexOf("<!--", r);
|
|
3026
|
+
if (s === -1)
|
|
3027
|
+
return;
|
|
3028
|
+
e.inHtmlComment = !0, r = s + 4;
|
|
3029
|
+
continue;
|
|
3030
|
+
}
|
|
3031
|
+
const i = t.indexOf("-->", r);
|
|
3032
|
+
if (i === -1)
|
|
3033
|
+
return;
|
|
3034
|
+
e.inHtmlComment = !1, r = i + 3;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
function Tn(t, e) {
|
|
3038
|
+
if (e.inFence || e.inHtmlComment)
|
|
3039
|
+
return !0;
|
|
3040
|
+
const n = t.trim();
|
|
3041
|
+
return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
|
|
3042
|
+
}
|
|
3043
|
+
function An(t) {
|
|
3044
|
+
const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
|
|
3045
|
+
for (let i = 0; i < e.length; i++) {
|
|
3046
|
+
const s = e[i];
|
|
3047
|
+
if (r.inFence) {
|
|
3048
|
+
const l = s.trim();
|
|
3049
|
+
l.startsWith(r.inFence.marker) && /^(`{3,}|~{3,})\s*$/.test(l) && (r.inFence = !1);
|
|
3050
|
+
continue;
|
|
3051
|
+
}
|
|
3052
|
+
if (r.inHtmlComment) {
|
|
3053
|
+
Re(s, r, 0);
|
|
3054
|
+
continue;
|
|
3055
|
+
}
|
|
3056
|
+
const o = En.exec(s.trimStart());
|
|
3057
|
+
if (o) {
|
|
3058
|
+
const l = o[1];
|
|
3059
|
+
s.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
|
|
3060
|
+
continue;
|
|
3061
|
+
}
|
|
3062
|
+
if (s.trim().startsWith("<!--")) {
|
|
3063
|
+
Re(s, r, s.indexOf("<!--"));
|
|
3064
|
+
continue;
|
|
3065
|
+
}
|
|
3066
|
+
if (Tn(s, r))
|
|
3067
|
+
continue;
|
|
3068
|
+
const c = Wn(s);
|
|
3069
|
+
if (c) {
|
|
3070
|
+
n.push(c);
|
|
3071
|
+
continue;
|
|
3072
|
+
}
|
|
3073
|
+
const h = e[i + 1];
|
|
3074
|
+
if (h !== void 0 && s.trim().length > 0 && !s.trimStart().startsWith("#") && !s.trimStart().startsWith(">") && !s.trimStart().startsWith("|")) {
|
|
3075
|
+
if (Sn.test(h)) {
|
|
3076
|
+
const l = re(s.trim());
|
|
3077
|
+
n.push({ level: 1, ...l }), i += 1;
|
|
3078
|
+
continue;
|
|
3079
|
+
}
|
|
3080
|
+
if (Cn.test(h) && h.trim().length >= 1) {
|
|
3081
|
+
const l = re(s.trim());
|
|
3082
|
+
n.push({ level: 2, ...l }), i += 1;
|
|
3083
|
+
continue;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
return n;
|
|
3088
|
+
}
|
|
3089
|
+
const Rn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
|
|
3090
|
+
function Mn() {
|
|
3091
|
+
const t = /* @__PURE__ */ new Map();
|
|
3092
|
+
return {
|
|
3093
|
+
slug(e, n) {
|
|
3094
|
+
const r = n !== void 0 && n.length > 0 ? n : On(e), i = t.get(r) ?? 0;
|
|
3095
|
+
return t.set(r, i + 1), i === 0 ? r : `${r}-${i}`;
|
|
3096
|
+
}
|
|
3097
|
+
};
|
|
2760
3098
|
}
|
|
2761
|
-
|
|
2762
|
-
|
|
3099
|
+
function On(t) {
|
|
3100
|
+
return t.toLowerCase().replace(Rn, "").replace(/\s+/g, "-");
|
|
3101
|
+
}
|
|
3102
|
+
function Ln(t) {
|
|
3103
|
+
let e = t.trim();
|
|
3104
|
+
e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
|
|
3105
|
+
for (let n = 0; n < 3; n++)
|
|
3106
|
+
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");
|
|
3107
|
+
return e.trim();
|
|
3108
|
+
}
|
|
3109
|
+
function Hn(t, e) {
|
|
3110
|
+
if (t.length === 0)
|
|
3111
|
+
return "";
|
|
3112
|
+
const n = Mn(), i = t.map((o) => {
|
|
3113
|
+
const a = Ln(o.text), c = n.slug(a, o.explicitId);
|
|
3114
|
+
return { level: o.level, text: a, anchor: c };
|
|
3115
|
+
}).filter((o) => o.level <= e);
|
|
3116
|
+
if (i.length === 0)
|
|
3117
|
+
return "";
|
|
3118
|
+
const s = Math.min(...i.map((o) => o.level));
|
|
3119
|
+
return i.map((o) => `${" ".repeat((o.level - s) * 2)}- [${o.text}](#${o.anchor})`).join(`
|
|
3120
|
+
`);
|
|
3121
|
+
}
|
|
3122
|
+
function Dn(t, e = {}) {
|
|
3123
|
+
const r = $(t).filter((o) => {
|
|
3124
|
+
const a = E(o.inner);
|
|
3125
|
+
return a.length === 1 && q(a[0]);
|
|
3126
|
+
});
|
|
3127
|
+
if (r.length === 0)
|
|
3128
|
+
return t;
|
|
3129
|
+
const i = An(t);
|
|
3130
|
+
let s = t;
|
|
3131
|
+
for (let o = r.length - 1; o >= 0; o--) {
|
|
3132
|
+
const a = r[o], { maxLevel: c } = sn(a.inner, e.path), h = Hn(i, c), l = s.slice(0, a.start), u = s.slice(a.end);
|
|
3133
|
+
s = A(A(l, h), u);
|
|
3134
|
+
}
|
|
3135
|
+
return s;
|
|
3136
|
+
}
|
|
3137
|
+
async function xe(t, e) {
|
|
3138
|
+
const n = e.path, r = e.context, i = e.registry ?? new De(), s = e.warnings ?? [], o = e.visitStack ?? new Ue(), {
|
|
2763
3139
|
source: a,
|
|
2764
3140
|
declarationUpdates: c
|
|
2765
|
-
} = await
|
|
2766
|
-
|
|
2767
|
-
|
|
3141
|
+
} = await on(t, { path: n, context: { ...r } });
|
|
3142
|
+
_n(
|
|
3143
|
+
v(r, c ?? {}),
|
|
2768
3144
|
s,
|
|
2769
3145
|
n
|
|
2770
3146
|
);
|
|
2771
|
-
const h = await
|
|
3147
|
+
const h = await kn(a, {
|
|
2772
3148
|
path: n,
|
|
2773
3149
|
context: r,
|
|
2774
3150
|
declarationUpdates: c ?? {},
|
|
@@ -2778,19 +3154,19 @@ async function me(t, e) {
|
|
|
2778
3154
|
visitStack: o,
|
|
2779
3155
|
warnings: s,
|
|
2780
3156
|
inComponent: e.inComponent ?? !1
|
|
2781
|
-
}), { source: l, context:
|
|
3157
|
+
}), { source: l, context: u } = h, { source: w, directives: m } = dn(l, {
|
|
2782
3158
|
path: n,
|
|
2783
3159
|
registry: i,
|
|
2784
|
-
context:
|
|
2785
|
-
}),
|
|
2786
|
-
if (
|
|
3160
|
+
context: u
|
|
3161
|
+
}), f = e.loader;
|
|
3162
|
+
if (m.length > 0 && !f)
|
|
2787
3163
|
throw new Error("loader is required when processing include directives");
|
|
2788
|
-
let y =
|
|
2789
|
-
return
|
|
2790
|
-
source:
|
|
2791
|
-
directives:
|
|
2792
|
-
context:
|
|
2793
|
-
loader:
|
|
3164
|
+
let y = w;
|
|
3165
|
+
return m.length > 0 && f && (y = await Qt({
|
|
3166
|
+
source: w,
|
|
3167
|
+
directives: m,
|
|
3168
|
+
context: u,
|
|
3169
|
+
loader: f,
|
|
2794
3170
|
root: e.root,
|
|
2795
3171
|
path: n,
|
|
2796
3172
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
@@ -2799,74 +3175,82 @@ async function me(t, e) {
|
|
|
2799
3175
|
warnings: s,
|
|
2800
3176
|
registry: i,
|
|
2801
3177
|
constrainToRoot: e.constrainToRoot
|
|
2802
|
-
})), y = await
|
|
2803
|
-
context:
|
|
3178
|
+
})), y = await Yt(y, {
|
|
3179
|
+
context: u,
|
|
2804
3180
|
path: n,
|
|
2805
3181
|
registry: i,
|
|
2806
|
-
loader:
|
|
3182
|
+
loader: f,
|
|
2807
3183
|
rootDir: e.root,
|
|
2808
3184
|
warnings: s,
|
|
2809
3185
|
visitStack: o,
|
|
2810
|
-
parentContext:
|
|
3186
|
+
parentContext: u,
|
|
2811
3187
|
preserveHgComments: e.preserveHgComments,
|
|
2812
3188
|
constrainToRoot: e.constrainToRoot
|
|
2813
|
-
}), y = await
|
|
3189
|
+
}), y = await Ne(y, u, {
|
|
2814
3190
|
path: n,
|
|
2815
3191
|
registry: i,
|
|
2816
|
-
loader:
|
|
3192
|
+
loader: f,
|
|
2817
3193
|
rootDir: e.root,
|
|
2818
3194
|
warnings: s,
|
|
2819
3195
|
visitStack: o,
|
|
2820
|
-
parentContext:
|
|
3196
|
+
parentContext: u,
|
|
2821
3197
|
preserveHgComments: e.preserveHgComments,
|
|
2822
3198
|
constrainToRoot: e.constrainToRoot
|
|
2823
|
-
}), y =
|
|
3199
|
+
}), y = Dn(y, { path: n }), y = pn(y, e.preserveHgComments), y;
|
|
2824
3200
|
}
|
|
2825
|
-
async function
|
|
2826
|
-
const n = e.path, r =
|
|
3201
|
+
async function qe(t, e = {}) {
|
|
3202
|
+
const n = e.path, r = v(e.context), i = e.registry ?? new De(), s = e.warnings ?? [], o = e.visitStack ?? new Ue(), { context: a, body: c, rawFrontMatter: h } = V(
|
|
2827
3203
|
t,
|
|
2828
3204
|
n
|
|
2829
|
-
), l =
|
|
2830
|
-
let
|
|
3205
|
+
), l = v(r, a);
|
|
3206
|
+
let u = await xe(c, {
|
|
2831
3207
|
...e,
|
|
2832
3208
|
context: l,
|
|
2833
3209
|
registry: i,
|
|
2834
3210
|
warnings: s,
|
|
2835
3211
|
visitStack: o
|
|
2836
3212
|
});
|
|
2837
|
-
return
|
|
3213
|
+
return u = un(u, {
|
|
2838
3214
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
2839
3215
|
rawFrontMatter: h
|
|
2840
3216
|
}), {
|
|
2841
|
-
markdown:
|
|
3217
|
+
markdown: u,
|
|
2842
3218
|
warnings: s
|
|
2843
3219
|
};
|
|
2844
3220
|
}
|
|
2845
|
-
async function
|
|
2846
|
-
const n = e.path, { context: r, body: i } =
|
|
2847
|
-
return
|
|
3221
|
+
async function Nn(t, e) {
|
|
3222
|
+
const n = e.path, { context: r, body: i } = V(t, n), s = v(e.context, r);
|
|
3223
|
+
return xe(i, {
|
|
2848
3224
|
...e,
|
|
2849
3225
|
context: s,
|
|
2850
3226
|
preserveFrontMatter: !1
|
|
2851
3227
|
});
|
|
2852
3228
|
}
|
|
2853
|
-
async function
|
|
2854
|
-
const r =
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
3229
|
+
async function Fn(t, e, n) {
|
|
3230
|
+
const r = n?.loader ?? oe(), i = await Et(t, { root: n?.root }), s = i.rootDir ?? n?.root, o = n?.dataSources, a = o && Object.keys(o).length > 0 ? await He(o, { root: s, loader: r }) : {}, c = v(
|
|
3231
|
+
a,
|
|
3232
|
+
e,
|
|
3233
|
+
n?.serverContext
|
|
3234
|
+
);
|
|
3235
|
+
return qe(i.source, {
|
|
3236
|
+
context: c,
|
|
3237
|
+
loader: r,
|
|
3238
|
+
root: s,
|
|
3239
|
+
path: i.entryPath ?? n?.path,
|
|
3240
|
+
constrainToRoot: i.constrainToRoot,
|
|
2861
3241
|
preserveFrontMatter: n?.preserveFrontMatter,
|
|
2862
3242
|
preserveHgComments: n?.preserveHgComments
|
|
2863
3243
|
});
|
|
2864
3244
|
}
|
|
2865
|
-
async function
|
|
3245
|
+
async function nr(t, e, n) {
|
|
2866
3246
|
if (n != null && "serverContext" in n && n.serverContext != null)
|
|
2867
3247
|
throw d({
|
|
2868
3248
|
code: "server_context_on_client"
|
|
2869
3249
|
});
|
|
3250
|
+
if (n != null && "dataSources" in n && n.dataSources != null && Object.keys(n.dataSources).length > 0)
|
|
3251
|
+
throw d({
|
|
3252
|
+
code: "data_sources_on_client"
|
|
3253
|
+
});
|
|
2870
3254
|
const r = n?.loader;
|
|
2871
3255
|
if (!r)
|
|
2872
3256
|
throw d({
|
|
@@ -2875,8 +3259,8 @@ async function _n(t, e, n) {
|
|
|
2875
3259
|
});
|
|
2876
3260
|
let i, s;
|
|
2877
3261
|
typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
|
|
2878
|
-
const o =
|
|
2879
|
-
return
|
|
3262
|
+
const o = v(e);
|
|
3263
|
+
return qe(i, {
|
|
2880
3264
|
context: o,
|
|
2881
3265
|
loader: r,
|
|
2882
3266
|
root: n?.root,
|
|
@@ -2886,30 +3270,30 @@ async function _n(t, e, n) {
|
|
|
2886
3270
|
constrainToRoot: n?.constrainToRoot
|
|
2887
3271
|
});
|
|
2888
3272
|
}
|
|
2889
|
-
function
|
|
2890
|
-
if (
|
|
3273
|
+
function jn(t, e) {
|
|
3274
|
+
if (he(t))
|
|
2891
3275
|
throw d({
|
|
2892
3276
|
code: "parse_error",
|
|
2893
3277
|
path: e,
|
|
2894
3278
|
details: {
|
|
2895
|
-
message:
|
|
3279
|
+
message: de(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2896
3280
|
}
|
|
2897
3281
|
});
|
|
2898
|
-
const n = [], r =
|
|
3282
|
+
const n = [], r = $(t);
|
|
2899
3283
|
for (const i of r) {
|
|
2900
|
-
const s =
|
|
3284
|
+
const s = E(i.inner);
|
|
2901
3285
|
if (s.length === 0)
|
|
2902
3286
|
throw d({
|
|
2903
3287
|
code: "parse_error",
|
|
2904
3288
|
path: e,
|
|
2905
3289
|
details: { message: "empty hyogen block" }
|
|
2906
3290
|
});
|
|
2907
|
-
if (s.length === 1 &&
|
|
3291
|
+
if (s.length === 1 && ue(s[0]) || s.length === 1 && q(s[0]) || s.length === 1 && (te(s[0]) || z(s[0])))
|
|
2908
3292
|
continue;
|
|
2909
3293
|
const o = s[0];
|
|
2910
3294
|
if (o === "endblock" || /^block\s+/.test(o))
|
|
2911
3295
|
continue;
|
|
2912
|
-
const a =
|
|
3296
|
+
const a = j(o, e);
|
|
2913
3297
|
if (a) {
|
|
2914
3298
|
n.push({ kind: "extend", path: a.path });
|
|
2915
3299
|
continue;
|
|
@@ -2917,8 +3301,8 @@ function cn(t, e) {
|
|
|
2917
3301
|
if (s.length !== 1) {
|
|
2918
3302
|
const c = s.join(`
|
|
2919
3303
|
`);
|
|
2920
|
-
if (
|
|
2921
|
-
(l) =>
|
|
3304
|
+
if (z(c) || s.every(
|
|
3305
|
+
(l) => te(l) || j(l) !== null
|
|
2922
3306
|
))
|
|
2923
3307
|
continue;
|
|
2924
3308
|
throw d({
|
|
@@ -2928,12 +3312,12 @@ function cn(t, e) {
|
|
|
2928
3312
|
});
|
|
2929
3313
|
}
|
|
2930
3314
|
if (/^include\s+/i.test(o)) {
|
|
2931
|
-
const c =
|
|
3315
|
+
const c = Ve(i.inner, e);
|
|
2932
3316
|
n.push({ kind: "include", path: c.path });
|
|
2933
3317
|
continue;
|
|
2934
3318
|
}
|
|
2935
3319
|
if (/^component\s+/i.test(o)) {
|
|
2936
|
-
const c =
|
|
3320
|
+
const c = Ze(i.inner, e);
|
|
2937
3321
|
n.push({ kind: "component", path: c.path });
|
|
2938
3322
|
continue;
|
|
2939
3323
|
}
|
|
@@ -2945,8 +3329,8 @@ function cn(t, e) {
|
|
|
2945
3329
|
}
|
|
2946
3330
|
return n;
|
|
2947
3331
|
}
|
|
2948
|
-
function
|
|
2949
|
-
return
|
|
3332
|
+
function Bn(t, e, n) {
|
|
3333
|
+
return H(t) ? t : Z(t, {
|
|
2950
3334
|
rootDir: n.root,
|
|
2951
3335
|
fromPath: e,
|
|
2952
3336
|
documentPath: e,
|
|
@@ -2954,19 +3338,19 @@ function hn(t, e, n) {
|
|
|
2954
3338
|
hyogenPath: !0
|
|
2955
3339
|
});
|
|
2956
3340
|
}
|
|
2957
|
-
async function
|
|
3341
|
+
async function In(t, e, n = {}) {
|
|
2958
3342
|
const r = t.map(
|
|
2959
|
-
(l) =>
|
|
3343
|
+
(l) => H(l) ? l : p.resolve(l)
|
|
2960
3344
|
), i = new Set(r), s = /* @__PURE__ */ new Set(), o = [], a = [...r];
|
|
2961
3345
|
for (; a.length > 0; ) {
|
|
2962
3346
|
const l = a.shift();
|
|
2963
3347
|
if (s.has(l))
|
|
2964
3348
|
continue;
|
|
2965
3349
|
s.add(l);
|
|
2966
|
-
const
|
|
2967
|
-
for (const
|
|
2968
|
-
const
|
|
2969
|
-
o.push({ from: l, to:
|
|
3350
|
+
const u = await e(l), w = jn(u, l);
|
|
3351
|
+
for (const m of w) {
|
|
3352
|
+
const f = Bn(m.path, l, n);
|
|
3353
|
+
o.push({ from: l, to: f, kind: m.kind }), s.has(f) || a.push(f);
|
|
2970
3354
|
}
|
|
2971
3355
|
}
|
|
2972
3356
|
const c = [...s], h = c.filter((l) => !i.has(l));
|
|
@@ -2977,22 +3361,22 @@ async function ln(t, e, n = {}) {
|
|
|
2977
3361
|
edges: o
|
|
2978
3362
|
};
|
|
2979
3363
|
}
|
|
2980
|
-
function
|
|
3364
|
+
function Un(t) {
|
|
2981
3365
|
return t.replace(/\\/g, "/").split("/").filter((r) => r.length > 0).some((r) => r.startsWith("_"));
|
|
2982
3366
|
}
|
|
2983
|
-
function
|
|
2984
|
-
return
|
|
3367
|
+
function zn(t) {
|
|
3368
|
+
return rt.scan(t).isGlob;
|
|
2985
3369
|
}
|
|
2986
|
-
function
|
|
2987
|
-
return t.root ?
|
|
3370
|
+
function Zn(t) {
|
|
3371
|
+
return t.root ? p.resolve(t.root) : t.cwd ? p.resolve(t.cwd) : B(process.cwd()) ?? process.cwd();
|
|
2988
3372
|
}
|
|
2989
|
-
async function
|
|
2990
|
-
const n = Array.isArray(t) ? t : [t], r =
|
|
3373
|
+
async function Vn(t, e = {}) {
|
|
3374
|
+
const n = Array.isArray(t) ? t : [t], r = Zn(e), i = e.includeUnderscoreEntries === !0, s = /* @__PURE__ */ new Map();
|
|
2991
3375
|
for (const o of n) {
|
|
2992
|
-
if (!
|
|
2993
|
-
const c =
|
|
3376
|
+
if (!zn(o)) {
|
|
3377
|
+
const c = p.isAbsolute(o) ? p.resolve(o) : p.resolve(r, o);
|
|
2994
3378
|
try {
|
|
2995
|
-
if (!(await
|
|
3379
|
+
if (!(await ie(c)).isFile())
|
|
2996
3380
|
throw d({
|
|
2997
3381
|
code: "file_not_found",
|
|
2998
3382
|
path: c,
|
|
@@ -3013,50 +3397,50 @@ async function fn(t, e = {}) {
|
|
|
3013
3397
|
}
|
|
3014
3398
|
}) : l;
|
|
3015
3399
|
}
|
|
3016
|
-
const h =
|
|
3400
|
+
const h = p.relative(r, c).replace(/\\/g, "/");
|
|
3017
3401
|
s.set(h, c);
|
|
3018
3402
|
continue;
|
|
3019
3403
|
}
|
|
3020
|
-
const a = await
|
|
3404
|
+
const a = await nt(o, {
|
|
3021
3405
|
cwd: r,
|
|
3022
3406
|
absolute: !0,
|
|
3023
3407
|
onlyFiles: !0,
|
|
3024
3408
|
dot: !1
|
|
3025
3409
|
});
|
|
3026
3410
|
for (const c of a) {
|
|
3027
|
-
const h =
|
|
3028
|
-
!i &&
|
|
3411
|
+
const h = p.relative(r, c).replace(/\\/g, "/");
|
|
3412
|
+
!i && Un(h) || s.set(h, p.resolve(c));
|
|
3029
3413
|
}
|
|
3030
3414
|
}
|
|
3031
3415
|
return [...s.values()];
|
|
3032
3416
|
}
|
|
3033
|
-
function
|
|
3417
|
+
function qn(t) {
|
|
3034
3418
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
3035
3419
|
}
|
|
3036
|
-
function
|
|
3420
|
+
function Pn(t, e) {
|
|
3037
3421
|
if (t)
|
|
3038
|
-
return
|
|
3422
|
+
return p.resolve(t);
|
|
3039
3423
|
for (const n of e) {
|
|
3040
|
-
const r =
|
|
3424
|
+
const r = B(n);
|
|
3041
3425
|
if (r)
|
|
3042
3426
|
return r;
|
|
3043
3427
|
}
|
|
3044
|
-
return e.length > 0 ?
|
|
3428
|
+
return e.length > 0 ? p.dirname(p.resolve(e[0])) : process.cwd();
|
|
3045
3429
|
}
|
|
3046
|
-
async function
|
|
3047
|
-
const e = await
|
|
3430
|
+
async function rr(t) {
|
|
3431
|
+
const e = await Vn(t.input, {
|
|
3048
3432
|
root: t.root,
|
|
3049
3433
|
includeUnderscoreEntries: t.includeUnderscoreEntries
|
|
3050
|
-
}), n =
|
|
3051
|
-
e.length > 0 && await
|
|
3434
|
+
}), n = Pn(t.root, e), r = t.loader ?? oe(), i = B(n) !== void 0;
|
|
3435
|
+
e.length > 0 && await In(e, r, {
|
|
3052
3436
|
root: n,
|
|
3053
3437
|
constrainToRoot: i
|
|
3054
3438
|
});
|
|
3055
|
-
const s = [],
|
|
3056
|
-
for (const
|
|
3057
|
-
const
|
|
3058
|
-
{ path:
|
|
3059
|
-
|
|
3439
|
+
const s = t.dataSources, o = s && Object.keys(s).length > 0 ? await He(s, { root: n, loader: r }) : {}, a = v(o, t.context), c = [], h = [];
|
|
3440
|
+
for (const l of e) {
|
|
3441
|
+
const u = p.resolve(l), w = p.relative(n, u).replace(/\\/g, "/"), m = await Fn(
|
|
3442
|
+
{ path: u },
|
|
3443
|
+
a,
|
|
3060
3444
|
{
|
|
3061
3445
|
loader: r,
|
|
3062
3446
|
root: n,
|
|
@@ -3064,27 +3448,27 @@ async function Sn(t) {
|
|
|
3064
3448
|
preserveFrontMatter: t.preserveFrontMatter,
|
|
3065
3449
|
preserveHgComments: t.preserveHgComments
|
|
3066
3450
|
}
|
|
3067
|
-
),
|
|
3451
|
+
), f = p.join(t.outDir, w);
|
|
3068
3452
|
try {
|
|
3069
|
-
await
|
|
3070
|
-
} catch (
|
|
3071
|
-
if (
|
|
3072
|
-
throw
|
|
3073
|
-
const
|
|
3453
|
+
await Xe(p.dirname(f), { recursive: !0 }), await Je(f, m.markdown, "utf8");
|
|
3454
|
+
} catch (y) {
|
|
3455
|
+
if (qn(y))
|
|
3456
|
+
throw y;
|
|
3457
|
+
const W = y instanceof Error ? y.message : "unknown write error";
|
|
3074
3458
|
throw d({
|
|
3075
3459
|
code: "load_failed",
|
|
3076
|
-
path:
|
|
3460
|
+
path: f,
|
|
3077
3461
|
details: {
|
|
3078
|
-
path:
|
|
3079
|
-
reason:
|
|
3462
|
+
path: f,
|
|
3463
|
+
reason: W
|
|
3080
3464
|
}
|
|
3081
3465
|
});
|
|
3082
3466
|
}
|
|
3083
|
-
|
|
3467
|
+
c.push({ path: w, markdown: m.markdown }), h.push(...m.warnings);
|
|
3084
3468
|
}
|
|
3085
|
-
return { files:
|
|
3469
|
+
return { files: c, warnings: h };
|
|
3086
3470
|
}
|
|
3087
|
-
function
|
|
3471
|
+
function ir(t, e) {
|
|
3088
3472
|
const n = [`[hyogen:${t}] ${e.code}`], r = {};
|
|
3089
3473
|
if (e.details)
|
|
3090
3474
|
for (const [i, s] of Object.entries(e.details))
|
|
@@ -3096,14 +3480,15 @@ function Cn(t, e) {
|
|
|
3096
3480
|
`);
|
|
3097
3481
|
}
|
|
3098
3482
|
export {
|
|
3099
|
-
|
|
3100
|
-
|
|
3483
|
+
rr as build,
|
|
3484
|
+
dt as createFsLoader,
|
|
3101
3485
|
d as createHyogenError,
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3486
|
+
oe as createNodeLoader,
|
|
3487
|
+
ir as formatDiagnosticLog,
|
|
3488
|
+
lt as formatMessage,
|
|
3489
|
+
H as isRemotePath,
|
|
3490
|
+
He as loadDataSources,
|
|
3491
|
+
nr as renderClient,
|
|
3492
|
+
Fn as renderServer
|
|
3108
3493
|
};
|
|
3109
3494
|
//# sourceMappingURL=index.js.map
|