@b4moss/hyogen-md 0.10.0 → 0.11.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 +22 -14
- package/README_ja.md +22 -14
- package/dist/client.js +473 -469
- package/dist/index.d.ts +14 -0
- package/dist/index.js +477 -332
- package/package.json +11 -8
package/dist/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { stat as
|
|
1
|
+
import { stat as ne, readFile as $e, mkdir as qe, writeFile as Pe } from "node:fs/promises";
|
|
2
2
|
import u from "node:path";
|
|
3
|
-
import { existsSync as
|
|
4
|
-
import { parse as
|
|
3
|
+
import { existsSync as xe, statSync as Ke } from "node:fs";
|
|
4
|
+
import { parse as Te } from "yaml";
|
|
5
5
|
import Ye from "fast-glob";
|
|
6
6
|
import Ge from "picomatch";
|
|
7
|
+
import { Readable as Je } from "node:stream";
|
|
8
|
+
import Xe from "csv-parser";
|
|
7
9
|
function b(...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 Qe = { 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}" }, et = { 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})' }, tt = { 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" }, re = {
|
|
16
|
+
errors: Qe,
|
|
17
|
+
warnings: et,
|
|
18
|
+
warningReasons: tt
|
|
19
|
+
}, nt = re.errors, rt = re.warnings;
|
|
20
|
+
function Ae(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 it(t, e) {
|
|
29
|
+
return Ae(nt[t], e);
|
|
28
30
|
}
|
|
29
31
|
function O(t, e) {
|
|
30
|
-
return
|
|
32
|
+
return Ae(rt[t], e);
|
|
31
33
|
}
|
|
32
34
|
function d(t) {
|
|
33
|
-
const e = t.message ??
|
|
35
|
+
const e = t.message ?? it(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 st(t) {
|
|
37
39
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
38
40
|
}
|
|
39
|
-
function
|
|
41
|
+
function ot(t = {}) {
|
|
40
42
|
const { from: e, via: n = "include" } = t;
|
|
41
43
|
return async (r) => {
|
|
42
44
|
try {
|
|
43
|
-
if (!(await
|
|
45
|
+
if (!(await ne(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 $e(r, "utf8");
|
|
53
55
|
} catch (i) {
|
|
54
|
-
if (
|
|
56
|
+
if (st(i))
|
|
55
57
|
throw i;
|
|
56
58
|
const s = i;
|
|
57
59
|
throw s.code === "ENOENT" ? d({
|
|
@@ -76,11 +78,11 @@ function it(t = {}) {
|
|
|
76
78
|
function j(t) {
|
|
77
79
|
return /^https?:\/\//i.test(t);
|
|
78
80
|
}
|
|
79
|
-
function
|
|
81
|
+
function at(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 ie(t = {}) {
|
|
85
|
+
const { from: e, via: n = "include" } = t, r = ot(t);
|
|
84
86
|
return async (i) => {
|
|
85
87
|
if (!j(i))
|
|
86
88
|
return r(i);
|
|
@@ -105,7 +107,7 @@ function $e(t = {}) {
|
|
|
105
107
|
});
|
|
106
108
|
return await s.text();
|
|
107
109
|
} catch (s) {
|
|
108
|
-
if (
|
|
110
|
+
if (at(s))
|
|
109
111
|
throw s;
|
|
110
112
|
const o = s instanceof Error ? s.message : "unknown fetch error";
|
|
111
113
|
throw d({
|
|
@@ -119,12 +121,12 @@ function $e(t = {}) {
|
|
|
119
121
|
}
|
|
120
122
|
};
|
|
121
123
|
}
|
|
122
|
-
const
|
|
123
|
-
function
|
|
124
|
+
const ct = ".doc_root";
|
|
125
|
+
function F(t) {
|
|
124
126
|
let e;
|
|
125
|
-
for (
|
|
126
|
-
const n = u.join(e,
|
|
127
|
-
if (
|
|
127
|
+
for (xe(t) ? e = Ke(t).isFile() ? u.dirname(t) : u.resolve(t) : e = u.dirname(u.resolve(t)); ; ) {
|
|
128
|
+
const n = u.join(e, ct);
|
|
129
|
+
if (xe(n))
|
|
128
130
|
return e;
|
|
129
131
|
const r = u.dirname(e);
|
|
130
132
|
if (r === e)
|
|
@@ -132,7 +134,7 @@ function z(t) {
|
|
|
132
134
|
e = r;
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
|
-
async function
|
|
137
|
+
async function ht(t, e) {
|
|
136
138
|
if (typeof t == "string")
|
|
137
139
|
return {
|
|
138
140
|
source: t,
|
|
@@ -141,7 +143,7 @@ async function at(t, e) {
|
|
|
141
143
|
const n = u.resolve(t.path);
|
|
142
144
|
let r;
|
|
143
145
|
try {
|
|
144
|
-
r = await
|
|
146
|
+
r = await ne(n);
|
|
145
147
|
} catch (a) {
|
|
146
148
|
const c = a;
|
|
147
149
|
throw c.code === "ENOENT" ? d({
|
|
@@ -169,7 +171,7 @@ async function at(t, e) {
|
|
|
169
171
|
});
|
|
170
172
|
let i;
|
|
171
173
|
try {
|
|
172
|
-
i = await
|
|
174
|
+
i = await $e(n, "utf8");
|
|
173
175
|
} catch (a) {
|
|
174
176
|
throw d({
|
|
175
177
|
code: "load_failed",
|
|
@@ -180,7 +182,7 @@ async function at(t, e) {
|
|
|
180
182
|
}
|
|
181
183
|
});
|
|
182
184
|
}
|
|
183
|
-
const s =
|
|
185
|
+
const s = F(n), o = e?.root ?? s;
|
|
184
186
|
return {
|
|
185
187
|
source: i,
|
|
186
188
|
rootDir: o,
|
|
@@ -188,7 +190,7 @@ async function at(t, e) {
|
|
|
188
190
|
constrainToRoot: s !== void 0
|
|
189
191
|
};
|
|
190
192
|
}
|
|
191
|
-
class
|
|
193
|
+
class Re {
|
|
192
194
|
components = /* @__PURE__ */ new Map();
|
|
193
195
|
register(e, n, r) {
|
|
194
196
|
if (this.components.has(e.alias))
|
|
@@ -212,7 +214,7 @@ class Ae {
|
|
|
212
214
|
return this.components.has(e);
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
|
-
const
|
|
217
|
+
const ke = 64 * 1024;
|
|
216
218
|
function U(t, e) {
|
|
217
219
|
if (!t.startsWith("---"))
|
|
218
220
|
return { context: {}, body: t };
|
|
@@ -225,13 +227,13 @@ function U(t, e) {
|
|
|
225
227
|
if (r === -1)
|
|
226
228
|
return { context: {}, body: t };
|
|
227
229
|
const i = t.slice(n + 1, r), s = Buffer.byteLength(i, "utf8");
|
|
228
|
-
if (s >
|
|
230
|
+
if (s > ke)
|
|
229
231
|
throw d({
|
|
230
232
|
code: "frontmatter_too_large",
|
|
231
233
|
path: e,
|
|
232
234
|
details: {
|
|
233
235
|
size: s,
|
|
234
|
-
limit:
|
|
236
|
+
limit: ke
|
|
235
237
|
}
|
|
236
238
|
});
|
|
237
239
|
if (i.trim().length === 0)
|
|
@@ -242,7 +244,7 @@ function U(t, e) {
|
|
|
242
244
|
});
|
|
243
245
|
let o;
|
|
244
246
|
try {
|
|
245
|
-
const h =
|
|
247
|
+
const h = Te(i);
|
|
246
248
|
if (h == null)
|
|
247
249
|
o = {};
|
|
248
250
|
else if (typeof h == "object" && !Array.isArray(h))
|
|
@@ -270,14 +272,14 @@ ${i}
|
|
|
270
272
|
---`
|
|
271
273
|
};
|
|
272
274
|
}
|
|
273
|
-
const
|
|
275
|
+
const lt = /* @__PURE__ */ new Set([
|
|
274
276
|
"string",
|
|
275
277
|
"number",
|
|
276
278
|
"boolean",
|
|
277
279
|
"object",
|
|
278
280
|
"array"
|
|
279
281
|
]);
|
|
280
|
-
function
|
|
282
|
+
function dt(t, e) {
|
|
281
283
|
const n = t.props;
|
|
282
284
|
if (n === void 0)
|
|
283
285
|
return {};
|
|
@@ -296,13 +298,13 @@ function ht(t, e) {
|
|
|
296
298
|
const o = s, a = {};
|
|
297
299
|
if ("type" in o && o.type !== void 0) {
|
|
298
300
|
const c = String(o.type);
|
|
299
|
-
|
|
301
|
+
lt.has(c) ? a.type = c : a.type = void 0;
|
|
300
302
|
}
|
|
301
303
|
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[i] = a;
|
|
302
304
|
}
|
|
303
305
|
return r;
|
|
304
306
|
}
|
|
305
|
-
function
|
|
307
|
+
function pt(t) {
|
|
306
308
|
if (t != null) {
|
|
307
309
|
if (typeof t == "string") return "string";
|
|
308
310
|
if (typeof t == "number") return "number";
|
|
@@ -311,30 +313,30 @@ function lt(t) {
|
|
|
311
313
|
if (typeof t == "object") return "object";
|
|
312
314
|
}
|
|
313
315
|
}
|
|
314
|
-
function
|
|
316
|
+
function ut(t, e) {
|
|
315
317
|
return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
|
|
316
318
|
}
|
|
317
|
-
function
|
|
319
|
+
function Y(t, e) {
|
|
318
320
|
return {
|
|
319
321
|
code: t,
|
|
320
322
|
message: O(t, e),
|
|
321
323
|
details: e
|
|
322
324
|
};
|
|
323
325
|
}
|
|
324
|
-
function
|
|
326
|
+
function ft(t, e, n) {
|
|
325
327
|
const r = [], i = {}, s = new Set(Object.keys(e));
|
|
326
328
|
for (const [o, a] of Object.entries(e)) {
|
|
327
329
|
const c = Object.prototype.hasOwnProperty.call(t, o);
|
|
328
330
|
let h = c ? t[o] : void 0;
|
|
329
331
|
if (c || (a.default !== void 0 ? h = a.default : (a.isRequired && r.push(
|
|
330
|
-
|
|
332
|
+
Y("prop_missing", {
|
|
331
333
|
prop: o,
|
|
332
334
|
component: n
|
|
333
335
|
})
|
|
334
336
|
), h = void 0)), c && h !== void 0 && h !== null) {
|
|
335
|
-
const l = a.type ??
|
|
336
|
-
l && !
|
|
337
|
-
|
|
337
|
+
const l = a.type ?? pt(h);
|
|
338
|
+
l && !ut(h, l) && (r.push(
|
|
339
|
+
Y("prop_type_mismatch", {
|
|
338
340
|
prop: o,
|
|
339
341
|
component: n,
|
|
340
342
|
expected: l,
|
|
@@ -346,27 +348,27 @@ function pt(t, e, n) {
|
|
|
346
348
|
}
|
|
347
349
|
for (const o of Object.keys(t))
|
|
348
350
|
s.has(o) || (Object.keys(e).length > 0 ? r.push(
|
|
349
|
-
|
|
351
|
+
Y("prop_unknown", {
|
|
350
352
|
prop: o,
|
|
351
353
|
component: n
|
|
352
354
|
})
|
|
353
355
|
) : i[o] = t[o]);
|
|
354
356
|
return { values: i, warnings: r };
|
|
355
357
|
}
|
|
356
|
-
function
|
|
358
|
+
function mt(t, e) {
|
|
357
359
|
const n = u.relative(e, t);
|
|
358
360
|
return n === "" || !n.startsWith("..") && !u.isAbsolute(n);
|
|
359
361
|
}
|
|
360
|
-
function
|
|
362
|
+
function gt(t, e, n) {
|
|
361
363
|
const r = u.resolve(e), i = u.resolve(t);
|
|
362
|
-
if (!
|
|
364
|
+
if (!mt(i, r))
|
|
363
365
|
throw d({
|
|
364
366
|
code: "parse_error",
|
|
365
367
|
path: n,
|
|
366
368
|
details: { message: "path resolves outside root directory" }
|
|
367
369
|
});
|
|
368
370
|
}
|
|
369
|
-
function
|
|
371
|
+
function V(t, e = {}) {
|
|
370
372
|
const { rootDir: n, fromPath: r, documentPath: i, constrainToRoot: s = !1, hyogenPath: o = !1 } = e;
|
|
371
373
|
if (t.length === 0)
|
|
372
374
|
throw d({
|
|
@@ -415,9 +417,9 @@ function re(t, e = {}) {
|
|
|
415
417
|
path: i,
|
|
416
418
|
details: { message: "root is required for relative template paths" }
|
|
417
419
|
});
|
|
418
|
-
return n && s &&
|
|
420
|
+
return n && s && gt(a, n, i), a;
|
|
419
421
|
}
|
|
420
|
-
async function
|
|
422
|
+
async function wt(t) {
|
|
421
423
|
const e = t.registry.get(t.alias);
|
|
422
424
|
if (!e)
|
|
423
425
|
throw d({
|
|
@@ -427,13 +429,13 @@ async function mt(t) {
|
|
|
427
429
|
message: `unregistered component: ${t.alias}`
|
|
428
430
|
}
|
|
429
431
|
});
|
|
430
|
-
const n = j(e.componentPath) ? e.componentPath :
|
|
432
|
+
const n = j(e.componentPath) ? e.componentPath : V(e.componentPath, {
|
|
431
433
|
rootDir: t.rootDir,
|
|
432
434
|
fromPath: e.definedAt,
|
|
433
435
|
documentPath: t.path,
|
|
434
436
|
constrainToRoot: t.constrainToRoot,
|
|
435
437
|
hyogenPath: !0
|
|
436
|
-
}), r = await t.loader(n), { context: i, body: s } = U(r, n), o =
|
|
438
|
+
}), r = await t.loader(n), { context: i, body: s } = U(r, n), o = dt(i, n), { values: a, warnings: c } = ft(
|
|
437
439
|
t.props,
|
|
438
440
|
o,
|
|
439
441
|
t.alias
|
|
@@ -443,7 +445,7 @@ async function mt(t) {
|
|
|
443
445
|
t.parentContext,
|
|
444
446
|
l,
|
|
445
447
|
a
|
|
446
|
-
), g = (await
|
|
448
|
+
), g = (await ge(s, {
|
|
447
449
|
context: p,
|
|
448
450
|
loader: t.loader,
|
|
449
451
|
root: t.rootDir,
|
|
@@ -465,17 +467,17 @@ async function mt(t) {
|
|
|
465
467
|
});
|
|
466
468
|
return g;
|
|
467
469
|
}
|
|
468
|
-
const
|
|
470
|
+
const xt = /* @__PURE__ */ new Set([
|
|
469
471
|
"__proto__",
|
|
470
472
|
"prototype",
|
|
471
473
|
"constructor",
|
|
472
474
|
"__defineGetter__"
|
|
473
475
|
]);
|
|
474
|
-
function
|
|
475
|
-
return
|
|
476
|
+
function kt(t) {
|
|
477
|
+
return xt.has(t);
|
|
476
478
|
}
|
|
477
|
-
function
|
|
478
|
-
if (
|
|
479
|
+
function ye(t, e) {
|
|
480
|
+
if (kt(t))
|
|
479
481
|
throw d({
|
|
480
482
|
code: "forbidden_property_access",
|
|
481
483
|
path: e,
|
|
@@ -485,11 +487,11 @@ function ke(t, e) {
|
|
|
485
487
|
function R(t) {
|
|
486
488
|
return !t;
|
|
487
489
|
}
|
|
488
|
-
function
|
|
490
|
+
function yt(t, e) {
|
|
489
491
|
if (t != null && typeof t == "object")
|
|
490
492
|
return t[e];
|
|
491
493
|
}
|
|
492
|
-
function
|
|
494
|
+
function bt(t, e, n) {
|
|
493
495
|
switch (t) {
|
|
494
496
|
case "+":
|
|
495
497
|
return e + n;
|
|
@@ -529,11 +531,11 @@ async function k(t, e) {
|
|
|
529
531
|
case "literal":
|
|
530
532
|
return t.value;
|
|
531
533
|
case "identifier":
|
|
532
|
-
return
|
|
534
|
+
return ye(t.name, r), n[t.name];
|
|
533
535
|
case "member": {
|
|
534
|
-
|
|
536
|
+
ye(t.property, r);
|
|
535
537
|
const i = await k(t.object, e);
|
|
536
|
-
return
|
|
538
|
+
return yt(i, t.property);
|
|
537
539
|
}
|
|
538
540
|
case "default": {
|
|
539
541
|
const i = await k(t.left, e);
|
|
@@ -553,7 +555,7 @@ async function k(t, e) {
|
|
|
553
555
|
return R(o) ? k(t.right, e) : o;
|
|
554
556
|
}
|
|
555
557
|
const i = await k(t.left, e), s = await k(t.right, e);
|
|
556
|
-
return
|
|
558
|
+
return bt(t.op, i, s);
|
|
557
559
|
}
|
|
558
560
|
case "call": {
|
|
559
561
|
if (!e.registry || !e.loader || !e.visitStack)
|
|
@@ -575,7 +577,7 @@ async function k(t, e) {
|
|
|
575
577
|
const i = {};
|
|
576
578
|
for (const [s, o] of Object.entries(t.args))
|
|
577
579
|
i[s] = await k(o, e);
|
|
578
|
-
return
|
|
580
|
+
return wt({
|
|
579
581
|
alias: t.callee,
|
|
580
582
|
props: i,
|
|
581
583
|
parentContext: e.parentContext ?? n,
|
|
@@ -620,17 +622,17 @@ async function k(t, e) {
|
|
|
620
622
|
return;
|
|
621
623
|
}
|
|
622
624
|
}
|
|
623
|
-
function
|
|
625
|
+
function G(t) {
|
|
624
626
|
return /[A-Za-z_$]/.test(t);
|
|
625
627
|
}
|
|
626
|
-
function
|
|
628
|
+
function vt(t) {
|
|
627
629
|
return /[A-Za-z0-9_$]/.test(t);
|
|
628
630
|
}
|
|
629
631
|
function S(t, e, n = {}) {
|
|
630
632
|
const r = t.trim();
|
|
631
633
|
if (r.length === 0)
|
|
632
634
|
throw m(e, "empty expression");
|
|
633
|
-
const i = new
|
|
635
|
+
const i = new _t(r, e, n), s = i.parseExpression();
|
|
634
636
|
if (i.skipWhitespace(), i.hasMore())
|
|
635
637
|
throw m(e, `unexpected token at position ${i.position}`);
|
|
636
638
|
return s;
|
|
@@ -642,7 +644,7 @@ function m(t, e) {
|
|
|
642
644
|
details: { message: e }
|
|
643
645
|
});
|
|
644
646
|
}
|
|
645
|
-
class
|
|
647
|
+
class _t {
|
|
646
648
|
constructor(e, n, r = {}) {
|
|
647
649
|
this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
|
|
648
650
|
}
|
|
@@ -813,7 +815,7 @@ class bt {
|
|
|
813
815
|
return { type: "literal", value: this.parseObjectLiteral() };
|
|
814
816
|
if (e === "[")
|
|
815
817
|
return { type: "literal", value: this.parseArrayLiteral() };
|
|
816
|
-
if (
|
|
818
|
+
if (G(e)) {
|
|
817
819
|
const n = this.readIdentifier();
|
|
818
820
|
if (n === "true" || n === "false" || n === "null" || n === "undefined")
|
|
819
821
|
return { type: "literal", value: n === "true" ? !0 : n === "false" ? !1 : n === "null" ? null : void 0 };
|
|
@@ -990,7 +992,7 @@ class bt {
|
|
|
990
992
|
return this.parseObjectLiteral();
|
|
991
993
|
if (e === "[")
|
|
992
994
|
return this.parseArrayLiteral();
|
|
993
|
-
if (
|
|
995
|
+
if (G(e)) {
|
|
994
996
|
const n = this.readIdentifier();
|
|
995
997
|
if (n === "true") return !0;
|
|
996
998
|
if (n === "false") return !1;
|
|
@@ -1008,9 +1010,9 @@ class bt {
|
|
|
1008
1010
|
readIdentifier() {
|
|
1009
1011
|
this.skipWhitespace();
|
|
1010
1012
|
const e = this.index;
|
|
1011
|
-
if (!
|
|
1013
|
+
if (!G(this.peek()))
|
|
1012
1014
|
return "";
|
|
1013
|
-
for (this.index++; this.index < this.input.length &&
|
|
1015
|
+
for (this.index++; this.index < this.input.length && vt(this.peek()); )
|
|
1014
1016
|
this.index++;
|
|
1015
1017
|
return this.input.slice(e, this.index);
|
|
1016
1018
|
}
|
|
@@ -1043,7 +1045,7 @@ class bt {
|
|
|
1043
1045
|
return r;
|
|
1044
1046
|
}
|
|
1045
1047
|
}
|
|
1046
|
-
async function
|
|
1048
|
+
async function Me(t, e, n = {}) {
|
|
1047
1049
|
const r = n.path;
|
|
1048
1050
|
let i = "", s = 0;
|
|
1049
1051
|
for (; s < t.length; ) {
|
|
@@ -1075,7 +1077,7 @@ async function Re(t, e, n = {}) {
|
|
|
1075
1077
|
}
|
|
1076
1078
|
return i;
|
|
1077
1079
|
}
|
|
1078
|
-
function
|
|
1080
|
+
function St(t, e) {
|
|
1079
1081
|
let n = 0, r = 0;
|
|
1080
1082
|
for (; r < t.length; ) {
|
|
1081
1083
|
const i = t.indexOf(e, r);
|
|
@@ -1085,14 +1087,14 @@ function vt(t, e) {
|
|
|
1085
1087
|
}
|
|
1086
1088
|
return n;
|
|
1087
1089
|
}
|
|
1088
|
-
function
|
|
1089
|
-
const e = t.includes("@hg"), n = t.includes("@endhg"), r =
|
|
1090
|
+
function se(t) {
|
|
1091
|
+
const e = t.includes("@hg"), n = t.includes("@endhg"), r = St(t, "@@");
|
|
1090
1092
|
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
1093
|
}
|
|
1092
|
-
function
|
|
1094
|
+
function oe(t) {
|
|
1093
1095
|
return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
|
|
1094
1096
|
}
|
|
1095
|
-
function
|
|
1097
|
+
function ae(t, e) {
|
|
1096
1098
|
let n = 0, r = !1;
|
|
1097
1099
|
for (; n < e; ) {
|
|
1098
1100
|
const i = t.indexOf("```", n);
|
|
@@ -1109,14 +1111,14 @@ function C(t) {
|
|
|
1109
1111
|
const r = t.indexOf("<!--", n);
|
|
1110
1112
|
if (r === -1)
|
|
1111
1113
|
break;
|
|
1112
|
-
if (
|
|
1114
|
+
if (ae(t, r)) {
|
|
1113
1115
|
n = r + 4;
|
|
1114
1116
|
continue;
|
|
1115
1117
|
}
|
|
1116
1118
|
const i = t.indexOf("-->", r + 4);
|
|
1117
1119
|
if (i === -1)
|
|
1118
1120
|
break;
|
|
1119
|
-
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a =
|
|
1121
|
+
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = se(o);
|
|
1120
1122
|
(a === "hg" || a === "at-at") && e.push({
|
|
1121
1123
|
start: r,
|
|
1122
1124
|
end: i + 3,
|
|
@@ -1126,40 +1128,40 @@ function C(t) {
|
|
|
1126
1128
|
}
|
|
1127
1129
|
return e;
|
|
1128
1130
|
}
|
|
1129
|
-
function
|
|
1131
|
+
function ce(t) {
|
|
1130
1132
|
let e = 0;
|
|
1131
1133
|
for (; e < t.length; ) {
|
|
1132
1134
|
const n = t.indexOf("<!--", e);
|
|
1133
1135
|
if (n === -1)
|
|
1134
1136
|
return !1;
|
|
1135
|
-
if (
|
|
1137
|
+
if (ae(t, n)) {
|
|
1136
1138
|
e = n + 4;
|
|
1137
1139
|
continue;
|
|
1138
1140
|
}
|
|
1139
1141
|
const r = t.indexOf("-->", n + 4);
|
|
1140
1142
|
if (r === -1)
|
|
1141
1143
|
return !1;
|
|
1142
|
-
const i = t.slice(n + 4, r), s =
|
|
1144
|
+
const i = t.slice(n + 4, r), s = se(i);
|
|
1143
1145
|
if (s === "unclosed" || s === "mixed")
|
|
1144
1146
|
return !0;
|
|
1145
1147
|
e = r + 3;
|
|
1146
1148
|
}
|
|
1147
1149
|
return !1;
|
|
1148
1150
|
}
|
|
1149
|
-
function
|
|
1151
|
+
function he(t) {
|
|
1150
1152
|
let e = 0;
|
|
1151
1153
|
for (; e < t.length; ) {
|
|
1152
1154
|
const n = t.indexOf("<!--", e);
|
|
1153
1155
|
if (n === -1)
|
|
1154
1156
|
return null;
|
|
1155
|
-
if (
|
|
1157
|
+
if (ae(t, n)) {
|
|
1156
1158
|
e = n + 4;
|
|
1157
1159
|
continue;
|
|
1158
1160
|
}
|
|
1159
1161
|
const r = t.indexOf("-->", n + 4);
|
|
1160
1162
|
if (r === -1)
|
|
1161
1163
|
return null;
|
|
1162
|
-
const i = t.slice(n + 4, r), s =
|
|
1164
|
+
const i = t.slice(n + 4, r), s = se(i);
|
|
1163
1165
|
if (s === "mixed")
|
|
1164
1166
|
return "mixed @hg and @@ markers are not allowed";
|
|
1165
1167
|
if (s === "unclosed")
|
|
@@ -1168,25 +1170,25 @@ function ce(t) {
|
|
|
1168
1170
|
}
|
|
1169
1171
|
return null;
|
|
1170
1172
|
}
|
|
1171
|
-
function
|
|
1172
|
-
return
|
|
1173
|
+
function E(t) {
|
|
1174
|
+
return oe(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
|
|
1173
1175
|
}
|
|
1174
|
-
const
|
|
1175
|
-
function
|
|
1176
|
-
return
|
|
1176
|
+
const Ct = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
|
|
1177
|
+
function le(t) {
|
|
1178
|
+
return Ct.test(t.trim());
|
|
1177
1179
|
}
|
|
1178
|
-
function
|
|
1180
|
+
function J(t, e) {
|
|
1179
1181
|
throw d({
|
|
1180
1182
|
code: "parse_error",
|
|
1181
1183
|
path: t,
|
|
1182
1184
|
details: { message: e }
|
|
1183
1185
|
});
|
|
1184
1186
|
}
|
|
1185
|
-
function
|
|
1187
|
+
function Et(t, e) {
|
|
1186
1188
|
let n = t;
|
|
1187
1189
|
const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
|
|
1188
1190
|
r && (n = r[1]);
|
|
1189
|
-
const i =
|
|
1191
|
+
const i = E(n);
|
|
1190
1192
|
if (i.length !== 1)
|
|
1191
1193
|
return null;
|
|
1192
1194
|
const s = i[0];
|
|
@@ -1199,7 +1201,7 @@ function St(t, e) {
|
|
|
1199
1201
|
if (s === "endeach")
|
|
1200
1202
|
return { kind: "endeach" };
|
|
1201
1203
|
if (/^IF\b/.test(s) || /^ELSE\b/.test(s) || /^ENDIF\b/.test(s))
|
|
1202
|
-
throw
|
|
1204
|
+
throw J(e, "control keywords must be lowercase");
|
|
1203
1205
|
const o = /^else\s+if\s+(.+)$/.exec(s);
|
|
1204
1206
|
if (o)
|
|
1205
1207
|
return {
|
|
@@ -1220,9 +1222,9 @@ function St(t, e) {
|
|
|
1220
1222
|
expr: S(c[2], e)
|
|
1221
1223
|
};
|
|
1222
1224
|
if (s === "if")
|
|
1223
|
-
throw
|
|
1225
|
+
throw J(e, "if requires an expression");
|
|
1224
1226
|
if (/^each\s+/.test(s))
|
|
1225
|
-
throw
|
|
1227
|
+
throw J(e, "invalid each directive");
|
|
1226
1228
|
return null;
|
|
1227
1229
|
}
|
|
1228
1230
|
function M(t) {
|
|
@@ -1235,10 +1237,10 @@ function _(t, e) {
|
|
|
1235
1237
|
details: { message: e }
|
|
1236
1238
|
});
|
|
1237
1239
|
}
|
|
1238
|
-
function
|
|
1240
|
+
function Wt(t, e) {
|
|
1239
1241
|
const n = [];
|
|
1240
1242
|
for (const r of C(t)) {
|
|
1241
|
-
const i =
|
|
1243
|
+
const i = Et(r.inner, e);
|
|
1242
1244
|
i && n.push({
|
|
1243
1245
|
start: r.start,
|
|
1244
1246
|
end: r.end,
|
|
@@ -1248,11 +1250,11 @@ function Ct(t, e) {
|
|
|
1248
1250
|
}
|
|
1249
1251
|
return n;
|
|
1250
1252
|
}
|
|
1251
|
-
function
|
|
1253
|
+
function Oe(t) {
|
|
1252
1254
|
return t.kind === "if" || t.kind === "each";
|
|
1253
1255
|
}
|
|
1254
|
-
function
|
|
1255
|
-
const n =
|
|
1256
|
+
function $t(t, e) {
|
|
1257
|
+
const n = Wt(t, e);
|
|
1256
1258
|
if (n.length === 0)
|
|
1257
1259
|
return t.length > 0 ? [{ kind: "text", content: t }] : [];
|
|
1258
1260
|
const { nodes: r, nextIndex: i } = N(t, n, 0, n.length, e);
|
|
@@ -1282,12 +1284,12 @@ function N(t, e, n, r, i, s = 0, o) {
|
|
|
1282
1284
|
kind: "text",
|
|
1283
1285
|
content: t.slice(h, p.start)
|
|
1284
1286
|
}), p.opener.kind === "if") {
|
|
1285
|
-
const f =
|
|
1287
|
+
const f = Tt(t, e, l, r, i);
|
|
1286
1288
|
c.push(f.node), h = f.endPos, l = f.nextIndex;
|
|
1287
1289
|
continue;
|
|
1288
1290
|
}
|
|
1289
1291
|
if (p.opener.kind === "each") {
|
|
1290
|
-
const f =
|
|
1292
|
+
const f = At(t, e, l, r, i);
|
|
1291
1293
|
c.push(f.node), h = f.endPos, l = f.nextIndex;
|
|
1292
1294
|
continue;
|
|
1293
1295
|
}
|
|
@@ -1301,7 +1303,7 @@ function N(t, e, n, r, i, s = 0, o) {
|
|
|
1301
1303
|
}
|
|
1302
1304
|
return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
|
|
1303
1305
|
}
|
|
1304
|
-
function
|
|
1306
|
+
function Tt(t, e, n, r, i) {
|
|
1305
1307
|
const s = e[n];
|
|
1306
1308
|
if (s.opener.kind !== "if")
|
|
1307
1309
|
throw _(i, "expected if");
|
|
@@ -1320,7 +1322,7 @@ function Et(t, e, n, r, i) {
|
|
|
1320
1322
|
}), a++;
|
|
1321
1323
|
continue;
|
|
1322
1324
|
}
|
|
1323
|
-
if (
|
|
1325
|
+
if (Oe(l.opener)) {
|
|
1324
1326
|
h++, a++;
|
|
1325
1327
|
continue;
|
|
1326
1328
|
}
|
|
@@ -1385,7 +1387,7 @@ function Et(t, e, n, r, i) {
|
|
|
1385
1387
|
}
|
|
1386
1388
|
throw _(i, "unclosed if block (missing endif)");
|
|
1387
1389
|
}
|
|
1388
|
-
function
|
|
1390
|
+
function At(t, e, n, r, i) {
|
|
1389
1391
|
const s = e[n];
|
|
1390
1392
|
if (s.opener.kind !== "each")
|
|
1391
1393
|
throw _(i, "expected each");
|
|
@@ -1394,7 +1396,7 @@ function Tt(t, e, n, r, i) {
|
|
|
1394
1396
|
let c = 0;
|
|
1395
1397
|
for (; o < r; ) {
|
|
1396
1398
|
const h = e[o];
|
|
1397
|
-
if (
|
|
1399
|
+
if (Oe(h.opener)) {
|
|
1398
1400
|
c++, o++;
|
|
1399
1401
|
continue;
|
|
1400
1402
|
}
|
|
@@ -1433,26 +1435,26 @@ function Tt(t, e, n, r, i) {
|
|
|
1433
1435
|
}
|
|
1434
1436
|
throw _(i, "unclosed each block (missing endeach)");
|
|
1435
1437
|
}
|
|
1436
|
-
const
|
|
1437
|
-
class
|
|
1438
|
+
const be = 20;
|
|
1439
|
+
class Rt {
|
|
1438
1440
|
depth = 0;
|
|
1439
1441
|
get currentDepth() {
|
|
1440
1442
|
return this.depth;
|
|
1441
1443
|
}
|
|
1442
1444
|
enter() {
|
|
1443
|
-
return this.depth >=
|
|
1445
|
+
return this.depth >= be ? { exceeded: !0, limit: be } : (this.depth++, { exceeded: !1, depth: this.depth });
|
|
1444
1446
|
}
|
|
1445
1447
|
exit() {
|
|
1446
1448
|
this.depth > 0 && this.depth--;
|
|
1447
1449
|
}
|
|
1448
1450
|
}
|
|
1449
|
-
function
|
|
1451
|
+
function Mt(t) {
|
|
1450
1452
|
return !!t;
|
|
1451
1453
|
}
|
|
1452
|
-
function
|
|
1454
|
+
function Ot(t) {
|
|
1453
1455
|
return t != null && typeof t[Symbol.iterator] == "function";
|
|
1454
1456
|
}
|
|
1455
|
-
function
|
|
1457
|
+
function Le(t) {
|
|
1456
1458
|
return {
|
|
1457
1459
|
code: "nest_limit_exceeded",
|
|
1458
1460
|
message: "structure nest limit exceeded",
|
|
@@ -1460,38 +1462,38 @@ function Oe(t) {
|
|
|
1460
1462
|
details: { limit: 20 }
|
|
1461
1463
|
};
|
|
1462
1464
|
}
|
|
1463
|
-
function
|
|
1465
|
+
function de(t) {
|
|
1464
1466
|
return t.startsWith(`
|
|
1465
1467
|
`) ? t.slice(1) : t;
|
|
1466
1468
|
}
|
|
1467
|
-
async function
|
|
1468
|
-
const n = e.path, r = e.warnings ?? [], i =
|
|
1469
|
-
return
|
|
1469
|
+
async function Lt(t, e) {
|
|
1470
|
+
const n = e.path, r = e.warnings ?? [], i = $t(t, n), s = new Rt();
|
|
1471
|
+
return pe(i, e, s, r);
|
|
1470
1472
|
}
|
|
1471
|
-
async function
|
|
1473
|
+
async function pe(t, e, n, r) {
|
|
1472
1474
|
const i = e.preserveHgComments === !0;
|
|
1473
1475
|
let s = "", o = !1;
|
|
1474
1476
|
for (const a of t) {
|
|
1475
|
-
let c = await
|
|
1476
|
-
o && (c =
|
|
1477
|
+
let c = await Dt(a, e, n, r);
|
|
1478
|
+
o && (c = de(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
|
|
1477
1479
|
}
|
|
1478
1480
|
return s;
|
|
1479
1481
|
}
|
|
1480
|
-
async function
|
|
1482
|
+
async function Dt(t, e, n, r) {
|
|
1481
1483
|
switch (t.kind) {
|
|
1482
1484
|
case "text":
|
|
1483
1485
|
return t.content;
|
|
1484
1486
|
case "if":
|
|
1485
|
-
return
|
|
1487
|
+
return Nt(t, e, n, r);
|
|
1486
1488
|
case "each":
|
|
1487
|
-
return
|
|
1489
|
+
return Ht(t, e, n, r);
|
|
1488
1490
|
default:
|
|
1489
1491
|
return "";
|
|
1490
1492
|
}
|
|
1491
1493
|
}
|
|
1492
|
-
async function
|
|
1494
|
+
async function Nt(t, e, n, r) {
|
|
1493
1495
|
if (n.enter().exceeded)
|
|
1494
|
-
return r.push(
|
|
1496
|
+
return r.push(Le(e.path)), "";
|
|
1495
1497
|
try {
|
|
1496
1498
|
let s = -1;
|
|
1497
1499
|
for (let c = 0; c < t.branches.length; c++) {
|
|
@@ -1501,7 +1503,7 @@ async function Lt(t, e, n, r) {
|
|
|
1501
1503
|
break;
|
|
1502
1504
|
}
|
|
1503
1505
|
const l = await k(h.expr, e);
|
|
1504
|
-
if (
|
|
1506
|
+
if (Mt(l)) {
|
|
1505
1507
|
s = c;
|
|
1506
1508
|
break;
|
|
1507
1509
|
}
|
|
@@ -1511,8 +1513,8 @@ async function Lt(t, e, n, r) {
|
|
|
1511
1513
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1512
1514
|
const h = t.branches[c];
|
|
1513
1515
|
if (o && (a += h.opener.raw), c === s) {
|
|
1514
|
-
let l = await
|
|
1515
|
-
o || (l =
|
|
1516
|
+
let l = await pe(h.body, e, n, r);
|
|
1517
|
+
o || (l = de(l)), a += l;
|
|
1516
1518
|
}
|
|
1517
1519
|
}
|
|
1518
1520
|
return o && (a += t.closer.raw), a;
|
|
@@ -1520,24 +1522,24 @@ async function Lt(t, e, n, r) {
|
|
|
1520
1522
|
n.exit();
|
|
1521
1523
|
}
|
|
1522
1524
|
}
|
|
1523
|
-
async function
|
|
1525
|
+
async function Ht(t, e, n, r) {
|
|
1524
1526
|
if (n.enter().exceeded)
|
|
1525
|
-
return r.push(
|
|
1527
|
+
return r.push(Le(e.path)), "";
|
|
1526
1528
|
try {
|
|
1527
1529
|
const s = await k(t.expr, e);
|
|
1528
|
-
if (!
|
|
1530
|
+
if (!Ot(s))
|
|
1529
1531
|
return "";
|
|
1530
1532
|
const o = e.preserveHgComments === !0;
|
|
1531
1533
|
let a = "";
|
|
1532
1534
|
for (const c of s) {
|
|
1533
1535
|
const h = { ...e.context, [t.item]: c };
|
|
1534
1536
|
o && (a += t.opener.raw);
|
|
1535
|
-
let l = await
|
|
1537
|
+
let l = await pe(t.body, {
|
|
1536
1538
|
...e,
|
|
1537
1539
|
context: h
|
|
1538
1540
|
}, n, r);
|
|
1539
|
-
o || (l =
|
|
1540
|
-
const p = await
|
|
1541
|
+
o || (l = de(l));
|
|
1542
|
+
const p = await Me(l, h, {
|
|
1541
1543
|
path: e.path,
|
|
1542
1544
|
registry: e.registry,
|
|
1543
1545
|
loader: e.loader,
|
|
@@ -1555,8 +1557,8 @@ async function Dt(t, e, n, r) {
|
|
|
1555
1557
|
n.exit();
|
|
1556
1558
|
}
|
|
1557
1559
|
}
|
|
1558
|
-
function
|
|
1559
|
-
return j(e) ? e :
|
|
1560
|
+
function Q(t, e, n, r, i = !1, s = !1) {
|
|
1561
|
+
return j(e) ? e : V(e, {
|
|
1560
1562
|
rootDir: t,
|
|
1561
1563
|
fromPath: r,
|
|
1562
1564
|
documentPath: n,
|
|
@@ -1564,14 +1566,14 @@ function J(t, e, n, r, i = !1, s = !1) {
|
|
|
1564
1566
|
hyogenPath: s
|
|
1565
1567
|
});
|
|
1566
1568
|
}
|
|
1567
|
-
function
|
|
1569
|
+
function De(t) {
|
|
1568
1570
|
let e = 0;
|
|
1569
1571
|
for (let n = t.length - 1; n >= 0 && t[n] === `
|
|
1570
1572
|
`; n--)
|
|
1571
1573
|
e++;
|
|
1572
1574
|
return e;
|
|
1573
1575
|
}
|
|
1574
|
-
function
|
|
1576
|
+
function Ne(t) {
|
|
1575
1577
|
let e = 0;
|
|
1576
1578
|
for (; e < t.length && t[e] === `
|
|
1577
1579
|
`; )
|
|
@@ -1579,25 +1581,25 @@ function De(t) {
|
|
|
1579
1581
|
return e;
|
|
1580
1582
|
}
|
|
1581
1583
|
function L(t, e) {
|
|
1582
|
-
const n =
|
|
1584
|
+
const n = De(t), r = Ne(e), i = Math.max(n, r);
|
|
1583
1585
|
return t.slice(0, t.length - n) + `
|
|
1584
1586
|
`.repeat(i) + e.slice(r);
|
|
1585
1587
|
}
|
|
1586
|
-
function
|
|
1587
|
-
const n =
|
|
1588
|
+
function ue(t, e) {
|
|
1589
|
+
const n = De(t), r = Ne(e);
|
|
1588
1590
|
return n + r - Math.max(n, r);
|
|
1589
1591
|
}
|
|
1590
|
-
function
|
|
1592
|
+
function ve(t, e, n) {
|
|
1591
1593
|
const r = t.indexOf(e);
|
|
1592
1594
|
if (r < 0)
|
|
1593
1595
|
return t;
|
|
1594
1596
|
const i = t.slice(0, r), s = t.slice(r + e.length);
|
|
1595
1597
|
return L(L(i, n), s);
|
|
1596
1598
|
}
|
|
1597
|
-
async function
|
|
1599
|
+
async function jt(t) {
|
|
1598
1600
|
let e = t.source;
|
|
1599
1601
|
for (const n of t.directives) {
|
|
1600
|
-
const r =
|
|
1602
|
+
const r = Q(
|
|
1601
1603
|
t.root,
|
|
1602
1604
|
n.path,
|
|
1603
1605
|
t.path,
|
|
@@ -1621,13 +1623,13 @@ async function Nt(t) {
|
|
|
1621
1623
|
from: i.from,
|
|
1622
1624
|
via: "include"
|
|
1623
1625
|
}
|
|
1624
|
-
}), e =
|
|
1626
|
+
}), e = ve(e, n.marker, "");
|
|
1625
1627
|
continue;
|
|
1626
1628
|
}
|
|
1627
1629
|
t.visitStack.push(r);
|
|
1628
1630
|
}
|
|
1629
1631
|
try {
|
|
1630
|
-
const i = await t.loader(r), s = await
|
|
1632
|
+
const i = await t.loader(r), s = await cn(i, {
|
|
1631
1633
|
context: t.context,
|
|
1632
1634
|
loader: t.loader,
|
|
1633
1635
|
root: t.root,
|
|
@@ -1639,14 +1641,14 @@ async function Nt(t) {
|
|
|
1639
1641
|
registry: t.registry
|
|
1640
1642
|
}), o = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1641
1643
|
${s}` : s;
|
|
1642
|
-
e =
|
|
1644
|
+
e = ve(e, n.marker, o);
|
|
1643
1645
|
} finally {
|
|
1644
1646
|
t.visitStack?.pop();
|
|
1645
1647
|
}
|
|
1646
1648
|
}
|
|
1647
1649
|
return e;
|
|
1648
1650
|
}
|
|
1649
|
-
class
|
|
1651
|
+
class He {
|
|
1650
1652
|
stack = [];
|
|
1651
1653
|
check(e) {
|
|
1652
1654
|
return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
|
|
@@ -1662,7 +1664,7 @@ class Ne {
|
|
|
1662
1664
|
this.stack.pop();
|
|
1663
1665
|
}
|
|
1664
1666
|
}
|
|
1665
|
-
async function
|
|
1667
|
+
async function Ft(t, e, n = {}) {
|
|
1666
1668
|
const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await k(t.expr, { context: e, path: r });
|
|
1667
1669
|
switch (t.kind) {
|
|
1668
1670
|
case "const": {
|
|
@@ -1703,7 +1705,7 @@ async function Ht(t, e, n = {}) {
|
|
|
1703
1705
|
}
|
|
1704
1706
|
}
|
|
1705
1707
|
}
|
|
1706
|
-
function
|
|
1708
|
+
function _e(t) {
|
|
1707
1709
|
return !t;
|
|
1708
1710
|
}
|
|
1709
1711
|
async function D(t, e, n = {}) {
|
|
@@ -1712,7 +1714,7 @@ async function D(t, e, n = {}) {
|
|
|
1712
1714
|
case "const":
|
|
1713
1715
|
case "let":
|
|
1714
1716
|
case "assign": {
|
|
1715
|
-
await
|
|
1717
|
+
await Ft(t, e, { path: r, constBindings: i }), s?.(t.name);
|
|
1716
1718
|
return;
|
|
1717
1719
|
}
|
|
1718
1720
|
case "update": {
|
|
@@ -1778,7 +1780,7 @@ async function D(t, e, n = {}) {
|
|
|
1778
1780
|
context: e,
|
|
1779
1781
|
path: r
|
|
1780
1782
|
});
|
|
1781
|
-
if (
|
|
1783
|
+
if (_e(o))
|
|
1782
1784
|
break;
|
|
1783
1785
|
for (const a of t.body)
|
|
1784
1786
|
await D(a, e, n);
|
|
@@ -1794,18 +1796,18 @@ async function D(t, e, n = {}) {
|
|
|
1794
1796
|
context: e,
|
|
1795
1797
|
path: r
|
|
1796
1798
|
});
|
|
1797
|
-
if (
|
|
1799
|
+
if (_e(o))
|
|
1798
1800
|
break;
|
|
1799
1801
|
} while (!0);
|
|
1800
1802
|
return;
|
|
1801
1803
|
}
|
|
1802
1804
|
}
|
|
1803
1805
|
}
|
|
1804
|
-
async function
|
|
1806
|
+
async function Se(t, e, n = {}) {
|
|
1805
1807
|
for (const r of t)
|
|
1806
1808
|
await D(r, e, n);
|
|
1807
1809
|
}
|
|
1808
|
-
const
|
|
1810
|
+
const Bt = /* @__PURE__ */ new Set([
|
|
1809
1811
|
"if",
|
|
1810
1812
|
"else",
|
|
1811
1813
|
"endif",
|
|
@@ -1823,10 +1825,10 @@ const jt = /* @__PURE__ */ new Set([
|
|
|
1823
1825
|
"component",
|
|
1824
1826
|
"as"
|
|
1825
1827
|
]);
|
|
1826
|
-
function
|
|
1827
|
-
return
|
|
1828
|
+
function je(t) {
|
|
1829
|
+
return Bt.has(t);
|
|
1828
1830
|
}
|
|
1829
|
-
function
|
|
1831
|
+
function fe(t) {
|
|
1830
1832
|
let e = "", n = 0, r = null;
|
|
1831
1833
|
for (; n < t.length; ) {
|
|
1832
1834
|
const i = t[n];
|
|
@@ -1866,11 +1868,11 @@ function x(t, e) {
|
|
|
1866
1868
|
details: { message: e }
|
|
1867
1869
|
});
|
|
1868
1870
|
}
|
|
1869
|
-
function
|
|
1870
|
-
const n =
|
|
1871
|
+
function Ce(t, e) {
|
|
1872
|
+
const n = fe(t).trim();
|
|
1871
1873
|
if (n.length === 0)
|
|
1872
1874
|
throw x(e, "empty statement block");
|
|
1873
|
-
const r = new
|
|
1875
|
+
const r = new me(n, e), i = r.parseStatementList();
|
|
1874
1876
|
if (r.skipWhitespace(), r.hasMore())
|
|
1875
1877
|
throw x(
|
|
1876
1878
|
e,
|
|
@@ -1880,11 +1882,11 @@ function Se(t, e) {
|
|
|
1880
1882
|
throw x(e, "empty statement block");
|
|
1881
1883
|
return i;
|
|
1882
1884
|
}
|
|
1883
|
-
function
|
|
1884
|
-
const e =
|
|
1885
|
+
function z(t) {
|
|
1886
|
+
const e = fe(t).trim();
|
|
1885
1887
|
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);
|
|
1886
1888
|
}
|
|
1887
|
-
class
|
|
1889
|
+
class me {
|
|
1888
1890
|
constructor(e, n) {
|
|
1889
1891
|
this.input = e, this.path = n;
|
|
1890
1892
|
}
|
|
@@ -1982,7 +1984,7 @@ class fe {
|
|
|
1982
1984
|
parseFor() {
|
|
1983
1985
|
if (this.skipWhitespace(), !this.match("("))
|
|
1984
1986
|
throw x(this.path, "expected '(' after for");
|
|
1985
|
-
const e = this.readBalanced(")"), n =
|
|
1987
|
+
const e = this.readBalanced(")"), n = It(e);
|
|
1986
1988
|
if (n.length !== 3)
|
|
1987
1989
|
throw x(
|
|
1988
1990
|
this.path,
|
|
@@ -2021,7 +2023,7 @@ class fe {
|
|
|
2021
2023
|
return { kind: "do_while", body: e, cond: r };
|
|
2022
2024
|
}
|
|
2023
2025
|
parseClauseStatement(e) {
|
|
2024
|
-
const n = new
|
|
2026
|
+
const n = new me(e, this.path), r = n.parseSimpleStatement();
|
|
2025
2027
|
if (n.skipWhitespace(), n.hasMore())
|
|
2026
2028
|
throw x(
|
|
2027
2029
|
this.path,
|
|
@@ -2030,7 +2032,7 @@ class fe {
|
|
|
2030
2032
|
return r;
|
|
2031
2033
|
}
|
|
2032
2034
|
assertAssignableName(e) {
|
|
2033
|
-
if (
|
|
2035
|
+
if (je(e))
|
|
2034
2036
|
throw x(
|
|
2035
2037
|
this.path,
|
|
2036
2038
|
`reserved word cannot be used as identifier: ${e}`
|
|
@@ -2137,7 +2139,7 @@ class fe {
|
|
|
2137
2139
|
return this.input.slice(e, this.index);
|
|
2138
2140
|
}
|
|
2139
2141
|
}
|
|
2140
|
-
function
|
|
2142
|
+
function It(t) {
|
|
2141
2143
|
const e = [];
|
|
2142
2144
|
let n = "", r = 0, i = null;
|
|
2143
2145
|
for (let s = 0; s < t.length; s++) {
|
|
@@ -2195,8 +2197,8 @@ function H(t, e) {
|
|
|
2195
2197
|
});
|
|
2196
2198
|
return { path: i };
|
|
2197
2199
|
}
|
|
2198
|
-
function
|
|
2199
|
-
const n =
|
|
2200
|
+
function zt(t, e) {
|
|
2201
|
+
const n = E(t);
|
|
2200
2202
|
if (n.length === 0) return null;
|
|
2201
2203
|
const r = n[0], i = H(r, e);
|
|
2202
2204
|
if (!i) return null;
|
|
@@ -2213,14 +2215,14 @@ function Bt(t, e) {
|
|
|
2213
2215
|
`)
|
|
2214
2216
|
};
|
|
2215
2217
|
}
|
|
2216
|
-
async function
|
|
2218
|
+
async function Ut(t, e = {}) {
|
|
2217
2219
|
const n = e.path, r = e.context ?? {};
|
|
2218
|
-
if (
|
|
2220
|
+
if (ce(t))
|
|
2219
2221
|
throw d({
|
|
2220
2222
|
code: "parse_error",
|
|
2221
2223
|
path: n,
|
|
2222
2224
|
details: {
|
|
2223
|
-
message:
|
|
2225
|
+
message: he(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2224
2226
|
}
|
|
2225
2227
|
});
|
|
2226
2228
|
const i = C(t);
|
|
@@ -2231,31 +2233,31 @@ async function It(t, e = {}) {
|
|
|
2231
2233
|
};
|
|
2232
2234
|
let c = t, h = 0;
|
|
2233
2235
|
for (const l of i) {
|
|
2234
|
-
const p =
|
|
2235
|
-
if (p.length === 1 &&
|
|
2236
|
+
const p = E(l.inner);
|
|
2237
|
+
if (p.length === 1 && le(p[0]) || p.length === 1 && /^include\s+/i.test(p[0]) || p.length === 1 && /^component\s+/i.test(p[0]))
|
|
2236
2238
|
continue;
|
|
2237
|
-
const f =
|
|
2239
|
+
const f = zt(l.inner, n);
|
|
2238
2240
|
if (f) {
|
|
2239
2241
|
if (f.declarationsSource.trim().length > 0) {
|
|
2240
|
-
const Z =
|
|
2242
|
+
const Z = Ce(
|
|
2241
2243
|
f.declarationsSource,
|
|
2242
2244
|
n
|
|
2243
2245
|
);
|
|
2244
|
-
await
|
|
2246
|
+
await Se(Z, r, {
|
|
2245
2247
|
path: n,
|
|
2246
2248
|
constBindings: s,
|
|
2247
2249
|
onUpdate: a
|
|
2248
2250
|
});
|
|
2249
2251
|
}
|
|
2250
|
-
const v = l.start - h,
|
|
2252
|
+
const v = l.start - h, W = l.end - h, $ = `<!--@hg
|
|
2251
2253
|
extend ${f.path}
|
|
2252
2254
|
@endhg-->`;
|
|
2253
|
-
c = c.slice(0, v) +
|
|
2255
|
+
c = c.slice(0, v) + $ + c.slice(W), h += l.raw.length - $.length;
|
|
2254
2256
|
continue;
|
|
2255
2257
|
}
|
|
2256
2258
|
const g = p.join(`
|
|
2257
2259
|
`);
|
|
2258
|
-
if (!
|
|
2260
|
+
if (!z(g)) {
|
|
2259
2261
|
if (p.length === 1)
|
|
2260
2262
|
continue;
|
|
2261
2263
|
throw d({
|
|
@@ -2264,20 +2266,20 @@ extend ${f.path}
|
|
|
2264
2266
|
details: { message: `unsupported hyogen directive: ${p[0]}` }
|
|
2265
2267
|
});
|
|
2266
2268
|
}
|
|
2267
|
-
const w =
|
|
2268
|
-
await
|
|
2269
|
+
const w = Ce(g, n);
|
|
2270
|
+
await Se(w, r, {
|
|
2269
2271
|
path: n,
|
|
2270
2272
|
constBindings: s,
|
|
2271
2273
|
onUpdate: a
|
|
2272
2274
|
});
|
|
2273
|
-
const y = l.start - h, A = l.end - h,
|
|
2274
|
-
c = L(
|
|
2275
|
+
const y = l.start - h, A = l.end - h, B = c.slice(0, y), T = c.slice(A);
|
|
2276
|
+
c = L(B, T), h += l.raw.length + ue(B, T);
|
|
2275
2277
|
}
|
|
2276
2278
|
return { source: c, context: r, declarationUpdates: o };
|
|
2277
2279
|
}
|
|
2278
|
-
const
|
|
2279
|
-
function
|
|
2280
|
-
const n =
|
|
2280
|
+
const Vt = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
|
|
2281
|
+
function Fe(t, e) {
|
|
2282
|
+
const n = oe(t).trim();
|
|
2281
2283
|
if (n.length === 0)
|
|
2282
2284
|
throw d({
|
|
2283
2285
|
code: "parse_error",
|
|
@@ -2300,7 +2302,7 @@ function je(t, e) {
|
|
|
2300
2302
|
path: e,
|
|
2301
2303
|
details: { message: "include and component cannot coexist in one block" }
|
|
2302
2304
|
});
|
|
2303
|
-
const s =
|
|
2305
|
+
const s = Vt.exec(i);
|
|
2304
2306
|
if (!s)
|
|
2305
2307
|
throw d({
|
|
2306
2308
|
code: "parse_error",
|
|
@@ -2320,8 +2322,8 @@ function je(t, e) {
|
|
|
2320
2322
|
alias: s[2]
|
|
2321
2323
|
};
|
|
2322
2324
|
}
|
|
2323
|
-
function
|
|
2324
|
-
const n =
|
|
2325
|
+
function Be(t, e) {
|
|
2326
|
+
const n = oe(t).trim();
|
|
2325
2327
|
if (n.length === 0)
|
|
2326
2328
|
throw d({
|
|
2327
2329
|
code: "parse_error",
|
|
@@ -2344,19 +2346,19 @@ function Fe(t, e) {
|
|
|
2344
2346
|
details: { message: `unsupported hyogen directive: ${i}` }
|
|
2345
2347
|
});
|
|
2346
2348
|
}
|
|
2347
|
-
function
|
|
2348
|
-
const e =
|
|
2349
|
+
function ee(t) {
|
|
2350
|
+
const e = fe(t).trim();
|
|
2349
2351
|
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
|
|
2350
2352
|
}
|
|
2351
|
-
const
|
|
2352
|
-
function
|
|
2353
|
-
return `${
|
|
2353
|
+
const Zt = "\0HYOGEN_INCLUDE_";
|
|
2354
|
+
function qt(t) {
|
|
2355
|
+
return `${Zt}${t}\0`;
|
|
2354
2356
|
}
|
|
2355
|
-
function
|
|
2356
|
-
const n =
|
|
2357
|
-
if (n.length === 1 &&
|
|
2357
|
+
function Pt(t, e) {
|
|
2358
|
+
const n = E(t);
|
|
2359
|
+
if (n.length === 1 && le(n[0]))
|
|
2358
2360
|
return { kind: "control" };
|
|
2359
|
-
if (n.length === 1 && (
|
|
2361
|
+
if (n.length === 1 && (ee(n[0]) || z(n[0])))
|
|
2360
2362
|
return null;
|
|
2361
2363
|
if (n.length !== 1)
|
|
2362
2364
|
throw d({
|
|
@@ -2372,9 +2374,9 @@ function qt(t, e) {
|
|
|
2372
2374
|
details: { message: "include and component cannot coexist in one block" }
|
|
2373
2375
|
});
|
|
2374
2376
|
if (/^include\s+/i.test(r))
|
|
2375
|
-
return
|
|
2377
|
+
return Be(t, e);
|
|
2376
2378
|
if (/^component\s+/i.test(r))
|
|
2377
|
-
return
|
|
2379
|
+
return Fe(t, e);
|
|
2378
2380
|
if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
|
|
2379
2381
|
return null;
|
|
2380
2382
|
throw d({
|
|
@@ -2383,14 +2385,14 @@ function qt(t, e) {
|
|
|
2383
2385
|
details: { message: `unsupported hyogen directive: ${r}` }
|
|
2384
2386
|
});
|
|
2385
2387
|
}
|
|
2386
|
-
function
|
|
2388
|
+
function Kt(t, e = {}) {
|
|
2387
2389
|
const n = e.path;
|
|
2388
|
-
if (
|
|
2390
|
+
if (ce(t))
|
|
2389
2391
|
throw d({
|
|
2390
2392
|
code: "parse_error",
|
|
2391
2393
|
path: n,
|
|
2392
2394
|
details: {
|
|
2393
|
-
message:
|
|
2395
|
+
message: he(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2394
2396
|
}
|
|
2395
2397
|
});
|
|
2396
2398
|
const r = C(t);
|
|
@@ -2399,7 +2401,7 @@ function Pt(t, e = {}) {
|
|
|
2399
2401
|
const i = [];
|
|
2400
2402
|
let s = t, o = 0, a = 0;
|
|
2401
2403
|
for (const c of r) {
|
|
2402
|
-
const h =
|
|
2404
|
+
const h = Pt(c.inner, n);
|
|
2403
2405
|
if (!h || h.kind === "control")
|
|
2404
2406
|
continue;
|
|
2405
2407
|
const l = c.start - o, p = c.end - o;
|
|
@@ -2414,20 +2416,20 @@ function Pt(t, e = {}) {
|
|
|
2414
2416
|
n
|
|
2415
2417
|
);
|
|
2416
2418
|
const g = s.slice(0, l), w = s.slice(p);
|
|
2417
|
-
s = L(g, w), o += c.raw.length +
|
|
2419
|
+
s = L(g, w), o += c.raw.length + ue(g, w);
|
|
2418
2420
|
continue;
|
|
2419
2421
|
}
|
|
2420
|
-
const f =
|
|
2422
|
+
const f = qt(a++);
|
|
2421
2423
|
i.push({ ...h, marker: f, raw: c.raw }), s = s.slice(0, l) + f + s.slice(p), o += c.raw.length - f.length;
|
|
2422
2424
|
}
|
|
2423
2425
|
return { source: s, directives: i };
|
|
2424
2426
|
}
|
|
2425
|
-
function
|
|
2427
|
+
function Yt(t, e) {
|
|
2426
2428
|
return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
|
|
2427
2429
|
` : `${e.rawFrontMatter}
|
|
2428
2430
|
${t}`;
|
|
2429
2431
|
}
|
|
2430
|
-
function
|
|
2432
|
+
function Gt(t, e = !1) {
|
|
2431
2433
|
if (e)
|
|
2432
2434
|
return t;
|
|
2433
2435
|
const n = C(t);
|
|
@@ -2436,16 +2438,16 @@ function Kt(t, e = !1) {
|
|
|
2436
2438
|
let r = t, i = 0;
|
|
2437
2439
|
for (const s of n) {
|
|
2438
2440
|
const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
|
|
2439
|
-
r = L(c, h), i += s.raw.length +
|
|
2441
|
+
r = L(c, h), i += s.raw.length + ue(c, h);
|
|
2440
2442
|
}
|
|
2441
2443
|
return r;
|
|
2442
2444
|
}
|
|
2443
|
-
const
|
|
2444
|
-
function
|
|
2445
|
+
const Jt = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
2446
|
+
function Xt(t, e) {
|
|
2445
2447
|
const n = t.trim();
|
|
2446
2448
|
if (n === "endblock")
|
|
2447
2449
|
return { kind: "endblock" };
|
|
2448
|
-
const r =
|
|
2450
|
+
const r = Jt.exec(n);
|
|
2449
2451
|
if (!r)
|
|
2450
2452
|
throw d({
|
|
2451
2453
|
code: "parse_error",
|
|
@@ -2453,7 +2455,7 @@ function Gt(t, e) {
|
|
|
2453
2455
|
details: { message: "invalid block directive" }
|
|
2454
2456
|
});
|
|
2455
2457
|
const i = r[1];
|
|
2456
|
-
if (
|
|
2458
|
+
if (je(i))
|
|
2457
2459
|
throw d({
|
|
2458
2460
|
code: "parse_error",
|
|
2459
2461
|
path: e,
|
|
@@ -2461,12 +2463,12 @@ function Gt(t, e) {
|
|
|
2461
2463
|
});
|
|
2462
2464
|
return { kind: "block", name: i };
|
|
2463
2465
|
}
|
|
2464
|
-
function
|
|
2466
|
+
function Ee(t, e) {
|
|
2465
2467
|
const { path: n, mode: r, hasExtend: i = !1 } = e, s = C(t);
|
|
2466
2468
|
if (s.length === 0) return [];
|
|
2467
2469
|
const o = [], a = [], c = /* @__PURE__ */ new Set();
|
|
2468
2470
|
for (const h of s) {
|
|
2469
|
-
const l =
|
|
2471
|
+
const l = E(h.inner);
|
|
2470
2472
|
if (l.length !== 1) continue;
|
|
2471
2473
|
const p = l[0];
|
|
2472
2474
|
if (!(p === "endblock" || p.startsWith("block "))) continue;
|
|
@@ -2476,7 +2478,7 @@ function Ce(t, e) {
|
|
|
2476
2478
|
path: n,
|
|
2477
2479
|
details: { message: "orphan block without extend" }
|
|
2478
2480
|
});
|
|
2479
|
-
const g =
|
|
2481
|
+
const g = Xt(p, n);
|
|
2480
2482
|
if (g.kind === "endblock") {
|
|
2481
2483
|
const w = a.pop();
|
|
2482
2484
|
if (!w)
|
|
@@ -2523,17 +2525,17 @@ function Ce(t, e) {
|
|
|
2523
2525
|
function We(t) {
|
|
2524
2526
|
const e = C(t), n = [];
|
|
2525
2527
|
for (const r of e) {
|
|
2526
|
-
const i =
|
|
2528
|
+
const i = E(r.inner);
|
|
2527
2529
|
if (i.length === 0) continue;
|
|
2528
2530
|
const s = H(i[0]);
|
|
2529
2531
|
s && n.push({ path: s.path, start: r.start });
|
|
2530
2532
|
}
|
|
2531
2533
|
return n;
|
|
2532
2534
|
}
|
|
2533
|
-
function
|
|
2535
|
+
function Qt(t) {
|
|
2534
2536
|
const e = C(t);
|
|
2535
2537
|
for (const n of e) {
|
|
2536
|
-
const r =
|
|
2538
|
+
const r = E(n.inner);
|
|
2537
2539
|
if (r.length !== 1) continue;
|
|
2538
2540
|
const i = r[0];
|
|
2539
2541
|
if (i === "endblock" || i.startsWith("block ")) return !0;
|
|
@@ -2543,14 +2545,14 @@ function Xt(t) {
|
|
|
2543
2545
|
function X(t) {
|
|
2544
2546
|
return t.map((e) => e.body).join("");
|
|
2545
2547
|
}
|
|
2546
|
-
function
|
|
2548
|
+
function en(t, e, n) {
|
|
2547
2549
|
const r = [...e].sort((o, a) => o.start - a.start), i = [];
|
|
2548
2550
|
let s = 0;
|
|
2549
2551
|
for (const o of r)
|
|
2550
2552
|
i.push(t.slice(s, o.start)), i.push(n.get(o.name) ?? o.body), s = o.end;
|
|
2551
2553
|
return i.push(t.slice(s)), i.reduce((o, a) => L(o, a));
|
|
2552
2554
|
}
|
|
2553
|
-
function
|
|
2555
|
+
function tn(t) {
|
|
2554
2556
|
if (t instanceof Error && "code" in t && "details" in t) {
|
|
2555
2557
|
const e = t;
|
|
2556
2558
|
if (e.code === "file_not_found" && e.details && e.details.via === "include")
|
|
@@ -2558,7 +2560,7 @@ function Qt(t) {
|
|
|
2558
2560
|
}
|
|
2559
2561
|
return { errorToThrow: t, adjusted: !1 };
|
|
2560
2562
|
}
|
|
2561
|
-
async function
|
|
2563
|
+
async function nn(t, e) {
|
|
2562
2564
|
const {
|
|
2563
2565
|
path: n,
|
|
2564
2566
|
context: r,
|
|
@@ -2571,7 +2573,7 @@ async function en(t, e) {
|
|
|
2571
2573
|
inComponent: l = !1
|
|
2572
2574
|
} = e, p = We(t);
|
|
2573
2575
|
if (p.length === 0) {
|
|
2574
|
-
if (
|
|
2576
|
+
if (Qt(t))
|
|
2575
2577
|
throw d({
|
|
2576
2578
|
code: "parse_error",
|
|
2577
2579
|
path: n,
|
|
@@ -2584,7 +2586,7 @@ async function en(t, e) {
|
|
|
2584
2586
|
return { source: t, context: b(r, i) };
|
|
2585
2587
|
if (!s)
|
|
2586
2588
|
throw new Error("loader is required when processing extend directives");
|
|
2587
|
-
const w =
|
|
2589
|
+
const w = E(g.inner);
|
|
2588
2590
|
if (!(w.length > 0 ? H(w[0]) : null))
|
|
2589
2591
|
throw d({
|
|
2590
2592
|
code: "parse_error",
|
|
@@ -2597,7 +2599,7 @@ async function en(t, e) {
|
|
|
2597
2599
|
path: n,
|
|
2598
2600
|
details: { message: "multiple extend directives are not supported" }
|
|
2599
2601
|
});
|
|
2600
|
-
const A =
|
|
2602
|
+
const A = Ee(t, {
|
|
2601
2603
|
path: n,
|
|
2602
2604
|
mode: "child",
|
|
2603
2605
|
hasExtend: !0
|
|
@@ -2612,59 +2614,59 @@ async function en(t, e) {
|
|
|
2612
2614
|
source: X(A),
|
|
2613
2615
|
context: b(r, i)
|
|
2614
2616
|
};
|
|
2615
|
-
const
|
|
2617
|
+
const B = p[0].path, T = n, v = Q(
|
|
2616
2618
|
o,
|
|
2617
|
-
|
|
2619
|
+
B,
|
|
2618
2620
|
n,
|
|
2619
2621
|
n,
|
|
2620
2622
|
a,
|
|
2621
2623
|
!0
|
|
2622
2624
|
);
|
|
2623
|
-
|
|
2625
|
+
T && c.push(T);
|
|
2624
2626
|
try {
|
|
2625
|
-
const
|
|
2626
|
-
if (
|
|
2627
|
+
const W = T ? c.check(v) : { circular: !1 };
|
|
2628
|
+
if (W.circular)
|
|
2627
2629
|
return h?.push({
|
|
2628
2630
|
code: "circular_include",
|
|
2629
2631
|
message: O("circular_include", {
|
|
2630
2632
|
path: v,
|
|
2631
|
-
from:
|
|
2633
|
+
from: W.from,
|
|
2632
2634
|
via: "extend"
|
|
2633
2635
|
}),
|
|
2634
2636
|
path: n,
|
|
2635
|
-
details: { path: v, from:
|
|
2637
|
+
details: { path: v, from: W.from, via: "extend" }
|
|
2636
2638
|
}), {
|
|
2637
2639
|
source: X(A),
|
|
2638
2640
|
context: b(r, i)
|
|
2639
2641
|
};
|
|
2640
2642
|
c.push(v);
|
|
2641
2643
|
try {
|
|
2642
|
-
const
|
|
2643
|
-
if (
|
|
2644
|
+
const $ = await s(v);
|
|
2645
|
+
if ($ === void 0)
|
|
2644
2646
|
throw new Error("loader returned undefined");
|
|
2645
2647
|
const { context: Z, body: q } = U(
|
|
2646
|
-
|
|
2648
|
+
$,
|
|
2647
2649
|
v
|
|
2648
|
-
),
|
|
2649
|
-
if (
|
|
2650
|
-
const
|
|
2650
|
+
), we = We(q);
|
|
2651
|
+
if (we.length > 0) {
|
|
2652
|
+
const I = we[0].path, P = Q(
|
|
2651
2653
|
o,
|
|
2652
|
-
|
|
2654
|
+
I,
|
|
2653
2655
|
v,
|
|
2654
2656
|
v,
|
|
2655
2657
|
a,
|
|
2656
2658
|
!0
|
|
2657
|
-
),
|
|
2658
|
-
if (
|
|
2659
|
+
), K = c.check(P);
|
|
2660
|
+
if (K.circular)
|
|
2659
2661
|
return h?.push({
|
|
2660
2662
|
code: "circular_include",
|
|
2661
2663
|
message: O("circular_include", {
|
|
2662
2664
|
path: P,
|
|
2663
|
-
from:
|
|
2665
|
+
from: K.from,
|
|
2664
2666
|
via: "extend"
|
|
2665
2667
|
}),
|
|
2666
2668
|
path: n,
|
|
2667
|
-
details: { path: P, from:
|
|
2669
|
+
details: { path: P, from: K.from, via: "extend" }
|
|
2668
2670
|
}), {
|
|
2669
2671
|
source: X(A),
|
|
2670
2672
|
context: b(r, i)
|
|
@@ -2675,32 +2677,32 @@ async function en(t, e) {
|
|
|
2675
2677
|
details: { message: "layout extend is not supported" }
|
|
2676
2678
|
});
|
|
2677
2679
|
}
|
|
2678
|
-
const
|
|
2680
|
+
const ze = Ee(q, {
|
|
2679
2681
|
path: v,
|
|
2680
2682
|
mode: "layout"
|
|
2681
|
-
}),
|
|
2682
|
-
A.map((
|
|
2683
|
-
),
|
|
2683
|
+
}), Ue = new Map(
|
|
2684
|
+
A.map((I) => [I.name, I.body])
|
|
2685
|
+
), Ve = en(
|
|
2684
2686
|
q,
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
+
ze,
|
|
2688
|
+
Ue
|
|
2687
2689
|
), Ze = b(
|
|
2688
2690
|
r,
|
|
2689
2691
|
Z,
|
|
2690
2692
|
i
|
|
2691
2693
|
);
|
|
2692
|
-
return { source:
|
|
2694
|
+
return { source: Ve, context: Ze };
|
|
2693
2695
|
} finally {
|
|
2694
2696
|
c.pop();
|
|
2695
2697
|
}
|
|
2696
|
-
} catch (
|
|
2697
|
-
const
|
|
2698
|
-
throw
|
|
2698
|
+
} catch (W) {
|
|
2699
|
+
const $ = tn(W);
|
|
2700
|
+
throw $.adjusted ? $.errorToThrow : W;
|
|
2699
2701
|
} finally {
|
|
2700
|
-
|
|
2702
|
+
T && c.pop();
|
|
2701
2703
|
}
|
|
2702
2704
|
}
|
|
2703
|
-
const
|
|
2705
|
+
const rn = re.warningReasons, sn = [
|
|
2704
2706
|
{
|
|
2705
2707
|
reason: "contains_html_script_tag",
|
|
2706
2708
|
test: (t) => /<\/?script\b/i.test(t)
|
|
@@ -2722,17 +2724,17 @@ const tn = ne.warningReasons, nn = [
|
|
|
2722
2724
|
test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
|
|
2723
2725
|
}
|
|
2724
2726
|
];
|
|
2725
|
-
function
|
|
2726
|
-
return
|
|
2727
|
+
function on(t) {
|
|
2728
|
+
return rn[t] ?? t;
|
|
2727
2729
|
}
|
|
2728
|
-
function
|
|
2730
|
+
function te(t, e, n, r) {
|
|
2729
2731
|
if (typeof t == "string") {
|
|
2730
|
-
for (const i of
|
|
2732
|
+
for (const i of sn)
|
|
2731
2733
|
i.test(t) && n.push({
|
|
2732
2734
|
code: "suspicious_context_value",
|
|
2733
2735
|
message: O("suspicious_context_value", {
|
|
2734
2736
|
key: e,
|
|
2735
|
-
reason:
|
|
2737
|
+
reason: on(i.reason)
|
|
2736
2738
|
}),
|
|
2737
2739
|
path: r,
|
|
2738
2740
|
details: { key: e, reason: i.reason }
|
|
@@ -2742,7 +2744,7 @@ function ee(t, e, n, r) {
|
|
|
2742
2744
|
if (t != null) {
|
|
2743
2745
|
if (Array.isArray(t)) {
|
|
2744
2746
|
for (let i = 0; i < t.length; i++)
|
|
2745
|
-
|
|
2747
|
+
te(t[i], `${e}[${i}]`, n, r);
|
|
2746
2748
|
return;
|
|
2747
2749
|
}
|
|
2748
2750
|
if (typeof t == "object")
|
|
@@ -2750,25 +2752,25 @@ function ee(t, e, n, r) {
|
|
|
2750
2752
|
t
|
|
2751
2753
|
)) {
|
|
2752
2754
|
const o = e.length > 0 ? `${e}.${i}` : i;
|
|
2753
|
-
|
|
2755
|
+
te(s, o, n, r);
|
|
2754
2756
|
}
|
|
2755
2757
|
}
|
|
2756
2758
|
}
|
|
2757
|
-
function
|
|
2759
|
+
function an(t, e, n) {
|
|
2758
2760
|
for (const [r, i] of Object.entries(t))
|
|
2759
|
-
|
|
2761
|
+
te(i, r, e, n);
|
|
2760
2762
|
}
|
|
2761
|
-
async function
|
|
2762
|
-
const n = e.path, r = e.context, i = e.registry ?? new
|
|
2763
|
+
async function ge(t, e) {
|
|
2764
|
+
const n = e.path, r = e.context, i = e.registry ?? new Re(), s = e.warnings ?? [], o = e.visitStack ?? new He(), {
|
|
2763
2765
|
source: a,
|
|
2764
2766
|
declarationUpdates: c
|
|
2765
|
-
} = await
|
|
2766
|
-
|
|
2767
|
+
} = await Ut(t, { path: n, context: { ...r } });
|
|
2768
|
+
an(
|
|
2767
2769
|
b(r, c ?? {}),
|
|
2768
2770
|
s,
|
|
2769
2771
|
n
|
|
2770
2772
|
);
|
|
2771
|
-
const h = await
|
|
2773
|
+
const h = await nn(a, {
|
|
2772
2774
|
path: n,
|
|
2773
2775
|
context: r,
|
|
2774
2776
|
declarationUpdates: c ?? {},
|
|
@@ -2778,7 +2780,7 @@ async function me(t, e) {
|
|
|
2778
2780
|
visitStack: o,
|
|
2779
2781
|
warnings: s,
|
|
2780
2782
|
inComponent: e.inComponent ?? !1
|
|
2781
|
-
}), { source: l, context: p } = h, { source: f, directives: g } =
|
|
2783
|
+
}), { source: l, context: p } = h, { source: f, directives: g } = Kt(l, {
|
|
2782
2784
|
path: n,
|
|
2783
2785
|
registry: i,
|
|
2784
2786
|
context: p
|
|
@@ -2786,7 +2788,7 @@ async function me(t, e) {
|
|
|
2786
2788
|
if (g.length > 0 && !w)
|
|
2787
2789
|
throw new Error("loader is required when processing include directives");
|
|
2788
2790
|
let y = f;
|
|
2789
|
-
return g.length > 0 && w && (y = await
|
|
2791
|
+
return g.length > 0 && w && (y = await jt({
|
|
2790
2792
|
source: f,
|
|
2791
2793
|
directives: g,
|
|
2792
2794
|
context: p,
|
|
@@ -2799,7 +2801,7 @@ async function me(t, e) {
|
|
|
2799
2801
|
warnings: s,
|
|
2800
2802
|
registry: i,
|
|
2801
2803
|
constrainToRoot: e.constrainToRoot
|
|
2802
|
-
})), y = await
|
|
2804
|
+
})), y = await Lt(y, {
|
|
2803
2805
|
context: p,
|
|
2804
2806
|
path: n,
|
|
2805
2807
|
registry: i,
|
|
@@ -2810,7 +2812,7 @@ async function me(t, e) {
|
|
|
2810
2812
|
parentContext: p,
|
|
2811
2813
|
preserveHgComments: e.preserveHgComments,
|
|
2812
2814
|
constrainToRoot: e.constrainToRoot
|
|
2813
|
-
}), y = await
|
|
2815
|
+
}), y = await Me(y, p, {
|
|
2814
2816
|
path: n,
|
|
2815
2817
|
registry: i,
|
|
2816
2818
|
loader: w,
|
|
@@ -2820,21 +2822,21 @@ async function me(t, e) {
|
|
|
2820
2822
|
parentContext: p,
|
|
2821
2823
|
preserveHgComments: e.preserveHgComments,
|
|
2822
2824
|
constrainToRoot: e.constrainToRoot
|
|
2823
|
-
}), y =
|
|
2825
|
+
}), y = Gt(y, e.preserveHgComments), y;
|
|
2824
2826
|
}
|
|
2825
|
-
async function
|
|
2826
|
-
const n = e.path, r = b(e.context), i = e.registry ?? new
|
|
2827
|
+
async function Ie(t, e = {}) {
|
|
2828
|
+
const n = e.path, r = b(e.context), i = e.registry ?? new Re(), s = e.warnings ?? [], o = e.visitStack ?? new He(), { context: a, body: c, rawFrontMatter: h } = U(
|
|
2827
2829
|
t,
|
|
2828
2830
|
n
|
|
2829
2831
|
), l = b(r, a);
|
|
2830
|
-
let p = await
|
|
2832
|
+
let p = await ge(c, {
|
|
2831
2833
|
...e,
|
|
2832
2834
|
context: l,
|
|
2833
2835
|
registry: i,
|
|
2834
2836
|
warnings: s,
|
|
2835
2837
|
visitStack: o
|
|
2836
2838
|
});
|
|
2837
|
-
return p =
|
|
2839
|
+
return p = Yt(p, {
|
|
2838
2840
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
2839
2841
|
rawFrontMatter: h
|
|
2840
2842
|
}), {
|
|
@@ -2842,17 +2844,17 @@ async function Be(t, e = {}) {
|
|
|
2842
2844
|
warnings: s
|
|
2843
2845
|
};
|
|
2844
2846
|
}
|
|
2845
|
-
async function
|
|
2847
|
+
async function cn(t, e) {
|
|
2846
2848
|
const n = e.path, { context: r, body: i } = U(t, n), s = b(e.context, r);
|
|
2847
|
-
return
|
|
2849
|
+
return ge(i, {
|
|
2848
2850
|
...e,
|
|
2849
2851
|
context: s,
|
|
2850
2852
|
preserveFrontMatter: !1
|
|
2851
2853
|
});
|
|
2852
2854
|
}
|
|
2853
|
-
async function
|
|
2854
|
-
const r = b(e, n?.serverContext), i = n?.loader ??
|
|
2855
|
-
return
|
|
2855
|
+
async function hn(t, e, n) {
|
|
2856
|
+
const r = b(e, n?.serverContext), i = n?.loader ?? ie(), s = await ht(t, { root: n?.root });
|
|
2857
|
+
return Ie(s.source, {
|
|
2856
2858
|
context: r,
|
|
2857
2859
|
loader: i,
|
|
2858
2860
|
root: s.rootDir ?? n?.root,
|
|
@@ -2862,11 +2864,15 @@ async function an(t, e, n) {
|
|
|
2862
2864
|
preserveHgComments: n?.preserveHgComments
|
|
2863
2865
|
});
|
|
2864
2866
|
}
|
|
2865
|
-
async function
|
|
2867
|
+
async function Hn(t, e, n) {
|
|
2866
2868
|
if (n != null && "serverContext" in n && n.serverContext != null)
|
|
2867
2869
|
throw d({
|
|
2868
2870
|
code: "server_context_on_client"
|
|
2869
2871
|
});
|
|
2872
|
+
if (n != null && "dataSources" in n && n.dataSources != null && Object.keys(n.dataSources).length > 0)
|
|
2873
|
+
throw d({
|
|
2874
|
+
code: "data_sources_on_client"
|
|
2875
|
+
});
|
|
2870
2876
|
const r = n?.loader;
|
|
2871
2877
|
if (!r)
|
|
2872
2878
|
throw d({
|
|
@@ -2876,7 +2882,7 @@ async function _n(t, e, n) {
|
|
|
2876
2882
|
let i, s;
|
|
2877
2883
|
typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
|
|
2878
2884
|
const o = b(e);
|
|
2879
|
-
return
|
|
2885
|
+
return Ie(i, {
|
|
2880
2886
|
context: o,
|
|
2881
2887
|
loader: r,
|
|
2882
2888
|
root: n?.root,
|
|
@@ -2886,25 +2892,25 @@ async function _n(t, e, n) {
|
|
|
2886
2892
|
constrainToRoot: n?.constrainToRoot
|
|
2887
2893
|
});
|
|
2888
2894
|
}
|
|
2889
|
-
function
|
|
2890
|
-
if (
|
|
2895
|
+
function ln(t, e) {
|
|
2896
|
+
if (ce(t))
|
|
2891
2897
|
throw d({
|
|
2892
2898
|
code: "parse_error",
|
|
2893
2899
|
path: e,
|
|
2894
2900
|
details: {
|
|
2895
|
-
message:
|
|
2901
|
+
message: he(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2896
2902
|
}
|
|
2897
2903
|
});
|
|
2898
2904
|
const n = [], r = C(t);
|
|
2899
2905
|
for (const i of r) {
|
|
2900
|
-
const s =
|
|
2906
|
+
const s = E(i.inner);
|
|
2901
2907
|
if (s.length === 0)
|
|
2902
2908
|
throw d({
|
|
2903
2909
|
code: "parse_error",
|
|
2904
2910
|
path: e,
|
|
2905
2911
|
details: { message: "empty hyogen block" }
|
|
2906
2912
|
});
|
|
2907
|
-
if (s.length === 1 &&
|
|
2913
|
+
if (s.length === 1 && le(s[0]) || s.length === 1 && (ee(s[0]) || z(s[0])))
|
|
2908
2914
|
continue;
|
|
2909
2915
|
const o = s[0];
|
|
2910
2916
|
if (o === "endblock" || /^block\s+/.test(o))
|
|
@@ -2917,8 +2923,8 @@ function cn(t, e) {
|
|
|
2917
2923
|
if (s.length !== 1) {
|
|
2918
2924
|
const c = s.join(`
|
|
2919
2925
|
`);
|
|
2920
|
-
if (
|
|
2921
|
-
(l) =>
|
|
2926
|
+
if (z(c) || s.every(
|
|
2927
|
+
(l) => ee(l) || H(l) !== null
|
|
2922
2928
|
))
|
|
2923
2929
|
continue;
|
|
2924
2930
|
throw d({
|
|
@@ -2928,12 +2934,12 @@ function cn(t, e) {
|
|
|
2928
2934
|
});
|
|
2929
2935
|
}
|
|
2930
2936
|
if (/^include\s+/i.test(o)) {
|
|
2931
|
-
const c =
|
|
2937
|
+
const c = Be(i.inner, e);
|
|
2932
2938
|
n.push({ kind: "include", path: c.path });
|
|
2933
2939
|
continue;
|
|
2934
2940
|
}
|
|
2935
2941
|
if (/^component\s+/i.test(o)) {
|
|
2936
|
-
const c =
|
|
2942
|
+
const c = Fe(i.inner, e);
|
|
2937
2943
|
n.push({ kind: "component", path: c.path });
|
|
2938
2944
|
continue;
|
|
2939
2945
|
}
|
|
@@ -2945,8 +2951,8 @@ function cn(t, e) {
|
|
|
2945
2951
|
}
|
|
2946
2952
|
return n;
|
|
2947
2953
|
}
|
|
2948
|
-
function
|
|
2949
|
-
return j(t) ? t :
|
|
2954
|
+
function dn(t, e, n) {
|
|
2955
|
+
return j(t) ? t : V(t, {
|
|
2950
2956
|
rootDir: n.root,
|
|
2951
2957
|
fromPath: e,
|
|
2952
2958
|
documentPath: e,
|
|
@@ -2954,7 +2960,7 @@ function hn(t, e, n) {
|
|
|
2954
2960
|
hyogenPath: !0
|
|
2955
2961
|
});
|
|
2956
2962
|
}
|
|
2957
|
-
async function
|
|
2963
|
+
async function pn(t, e, n = {}) {
|
|
2958
2964
|
const r = t.map(
|
|
2959
2965
|
(l) => j(l) ? l : u.resolve(l)
|
|
2960
2966
|
), i = new Set(r), s = /* @__PURE__ */ new Set(), o = [], a = [...r];
|
|
@@ -2963,9 +2969,9 @@ async function ln(t, e, n = {}) {
|
|
|
2963
2969
|
if (s.has(l))
|
|
2964
2970
|
continue;
|
|
2965
2971
|
s.add(l);
|
|
2966
|
-
const p = await e(l), f =
|
|
2972
|
+
const p = await e(l), f = ln(p, l);
|
|
2967
2973
|
for (const g of f) {
|
|
2968
|
-
const w =
|
|
2974
|
+
const w = dn(g.path, l, n);
|
|
2969
2975
|
o.push({ from: l, to: w, kind: g.kind }), s.has(w) || a.push(w);
|
|
2970
2976
|
}
|
|
2971
2977
|
}
|
|
@@ -2977,22 +2983,22 @@ async function ln(t, e, n = {}) {
|
|
|
2977
2983
|
edges: o
|
|
2978
2984
|
};
|
|
2979
2985
|
}
|
|
2980
|
-
function
|
|
2986
|
+
function un(t) {
|
|
2981
2987
|
return t.replace(/\\/g, "/").split("/").filter((r) => r.length > 0).some((r) => r.startsWith("_"));
|
|
2982
2988
|
}
|
|
2983
|
-
function
|
|
2989
|
+
function fn(t) {
|
|
2984
2990
|
return Ge.scan(t).isGlob;
|
|
2985
2991
|
}
|
|
2986
|
-
function
|
|
2987
|
-
return t.root ? u.resolve(t.root) : t.cwd ? u.resolve(t.cwd) :
|
|
2992
|
+
function mn(t) {
|
|
2993
|
+
return t.root ? u.resolve(t.root) : t.cwd ? u.resolve(t.cwd) : F(process.cwd()) ?? process.cwd();
|
|
2988
2994
|
}
|
|
2989
|
-
async function
|
|
2990
|
-
const n = Array.isArray(t) ? t : [t], r =
|
|
2995
|
+
async function gn(t, e = {}) {
|
|
2996
|
+
const n = Array.isArray(t) ? t : [t], r = mn(e), i = e.includeUnderscoreEntries === !0, s = /* @__PURE__ */ new Map();
|
|
2991
2997
|
for (const o of n) {
|
|
2992
|
-
if (!
|
|
2998
|
+
if (!fn(o)) {
|
|
2993
2999
|
const c = u.isAbsolute(o) ? u.resolve(o) : u.resolve(r, o);
|
|
2994
3000
|
try {
|
|
2995
|
-
if (!(await
|
|
3001
|
+
if (!(await ne(c)).isFile())
|
|
2996
3002
|
throw d({
|
|
2997
3003
|
code: "file_not_found",
|
|
2998
3004
|
path: c,
|
|
@@ -3025,36 +3031,36 @@ async function fn(t, e = {}) {
|
|
|
3025
3031
|
});
|
|
3026
3032
|
for (const c of a) {
|
|
3027
3033
|
const h = u.relative(r, c).replace(/\\/g, "/");
|
|
3028
|
-
!i &&
|
|
3034
|
+
!i && un(h) || s.set(h, u.resolve(c));
|
|
3029
3035
|
}
|
|
3030
3036
|
}
|
|
3031
3037
|
return [...s.values()];
|
|
3032
3038
|
}
|
|
3033
|
-
function
|
|
3039
|
+
function wn(t) {
|
|
3034
3040
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
3035
3041
|
}
|
|
3036
|
-
function
|
|
3042
|
+
function xn(t, e) {
|
|
3037
3043
|
if (t)
|
|
3038
3044
|
return u.resolve(t);
|
|
3039
3045
|
for (const n of e) {
|
|
3040
|
-
const r =
|
|
3046
|
+
const r = F(n);
|
|
3041
3047
|
if (r)
|
|
3042
3048
|
return r;
|
|
3043
3049
|
}
|
|
3044
3050
|
return e.length > 0 ? u.dirname(u.resolve(e[0])) : process.cwd();
|
|
3045
3051
|
}
|
|
3046
|
-
async function
|
|
3047
|
-
const e = await
|
|
3052
|
+
async function jn(t) {
|
|
3053
|
+
const e = await gn(t.input, {
|
|
3048
3054
|
root: t.root,
|
|
3049
3055
|
includeUnderscoreEntries: t.includeUnderscoreEntries
|
|
3050
|
-
}), n =
|
|
3051
|
-
e.length > 0 && await
|
|
3056
|
+
}), n = xn(t.root, e), r = t.loader ?? ie(), i = F(n) !== void 0;
|
|
3057
|
+
e.length > 0 && await pn(e, r, {
|
|
3052
3058
|
root: n,
|
|
3053
3059
|
constrainToRoot: i
|
|
3054
3060
|
});
|
|
3055
3061
|
const s = [], o = [];
|
|
3056
3062
|
for (const a of e) {
|
|
3057
|
-
const c = u.resolve(a), h = u.relative(n, c).replace(/\\/g, "/"), l = await
|
|
3063
|
+
const c = u.resolve(a), h = u.relative(n, c).replace(/\\/g, "/"), l = await hn(
|
|
3058
3064
|
{ path: c },
|
|
3059
3065
|
t.context,
|
|
3060
3066
|
{
|
|
@@ -3068,7 +3074,7 @@ async function Sn(t) {
|
|
|
3068
3074
|
try {
|
|
3069
3075
|
await qe(u.dirname(p), { recursive: !0 }), await Pe(p, l.markdown, "utf8");
|
|
3070
3076
|
} catch (f) {
|
|
3071
|
-
if (
|
|
3077
|
+
if (wn(f))
|
|
3072
3078
|
throw f;
|
|
3073
3079
|
const g = f instanceof Error ? f.message : "unknown write error";
|
|
3074
3080
|
throw d({
|
|
@@ -3084,7 +3090,145 @@ async function Sn(t) {
|
|
|
3084
3090
|
}
|
|
3085
3091
|
return { files: s, warnings: o };
|
|
3086
3092
|
}
|
|
3093
|
+
function kn(t) {
|
|
3094
|
+
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
3095
|
+
}
|
|
3096
|
+
function yn(t) {
|
|
3097
|
+
return Object.keys(t).sort((e, n) => Number(e) - Number(n)).map((e) => t[e] ?? "");
|
|
3098
|
+
}
|
|
3099
|
+
function bn(t) {
|
|
3100
|
+
return t.every((e) => e === "");
|
|
3101
|
+
}
|
|
3102
|
+
async function vn(t) {
|
|
3103
|
+
return new Promise((e, n) => {
|
|
3104
|
+
const r = [];
|
|
3105
|
+
Je.from([t]).pipe(Xe({ headers: !1 })).on("data", (i) => {
|
|
3106
|
+
const s = yn(i);
|
|
3107
|
+
bn(s) || r.push(s);
|
|
3108
|
+
}).on("end", () => e(r)).on("error", (i) => n(i));
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
async function _n(t, e) {
|
|
3112
|
+
if (t.length === 0 || t.trim().length === 0)
|
|
3113
|
+
throw d({
|
|
3114
|
+
code: "parse_error",
|
|
3115
|
+
path: e,
|
|
3116
|
+
details: { message: "empty CSV" }
|
|
3117
|
+
});
|
|
3118
|
+
let n;
|
|
3119
|
+
try {
|
|
3120
|
+
n = await vn(t);
|
|
3121
|
+
} catch (o) {
|
|
3122
|
+
throw kn(o) ? o : d({
|
|
3123
|
+
code: "parse_error",
|
|
3124
|
+
path: e,
|
|
3125
|
+
details: {
|
|
3126
|
+
message: o instanceof Error ? o.message : "invalid CSV"
|
|
3127
|
+
}
|
|
3128
|
+
});
|
|
3129
|
+
}
|
|
3130
|
+
if (n.length === 0)
|
|
3131
|
+
throw d({
|
|
3132
|
+
code: "parse_error",
|
|
3133
|
+
path: e,
|
|
3134
|
+
details: { message: "empty CSV" }
|
|
3135
|
+
});
|
|
3136
|
+
const [r, ...i] = n, s = r.length;
|
|
3137
|
+
for (const o of i)
|
|
3138
|
+
if (o.length !== s)
|
|
3139
|
+
throw d({
|
|
3140
|
+
code: "parse_error",
|
|
3141
|
+
path: e,
|
|
3142
|
+
details: { message: "CSV row column count mismatch" }
|
|
3143
|
+
});
|
|
3144
|
+
return i.map((o) => {
|
|
3145
|
+
const a = {};
|
|
3146
|
+
for (let c = 0; c < r.length; c++)
|
|
3147
|
+
a[r[c]] = o[c] ?? "";
|
|
3148
|
+
return a;
|
|
3149
|
+
});
|
|
3150
|
+
}
|
|
3151
|
+
function Sn(t) {
|
|
3152
|
+
return u.extname(t).slice(1).toLowerCase();
|
|
3153
|
+
}
|
|
3087
3154
|
function Cn(t, e) {
|
|
3155
|
+
if (t.length === 0)
|
|
3156
|
+
throw d({
|
|
3157
|
+
code: "parse_error",
|
|
3158
|
+
path: e,
|
|
3159
|
+
details: { message: "empty data file" }
|
|
3160
|
+
});
|
|
3161
|
+
}
|
|
3162
|
+
async function En(t, e) {
|
|
3163
|
+
Cn(t, e);
|
|
3164
|
+
const n = Sn(e);
|
|
3165
|
+
switch (n) {
|
|
3166
|
+
case "json":
|
|
3167
|
+
try {
|
|
3168
|
+
return JSON.parse(t);
|
|
3169
|
+
} catch (r) {
|
|
3170
|
+
throw d({
|
|
3171
|
+
code: "parse_error",
|
|
3172
|
+
path: e,
|
|
3173
|
+
details: {
|
|
3174
|
+
message: r instanceof Error ? r.message : "invalid JSON"
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
}
|
|
3178
|
+
case "yaml":
|
|
3179
|
+
case "yml":
|
|
3180
|
+
try {
|
|
3181
|
+
return Te(t);
|
|
3182
|
+
} catch (r) {
|
|
3183
|
+
throw d({
|
|
3184
|
+
code: "parse_error",
|
|
3185
|
+
path: e,
|
|
3186
|
+
details: {
|
|
3187
|
+
message: r instanceof Error ? r.message : "invalid YAML"
|
|
3188
|
+
}
|
|
3189
|
+
});
|
|
3190
|
+
}
|
|
3191
|
+
case "csv":
|
|
3192
|
+
return _n(t, e);
|
|
3193
|
+
default:
|
|
3194
|
+
throw d({
|
|
3195
|
+
code: "parse_error",
|
|
3196
|
+
path: e,
|
|
3197
|
+
details: {
|
|
3198
|
+
format: n,
|
|
3199
|
+
message: `unsupported data file format: ${n}`
|
|
3200
|
+
}
|
|
3201
|
+
});
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
function Wn(t) {
|
|
3205
|
+
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
3206
|
+
}
|
|
3207
|
+
function $n(t) {
|
|
3208
|
+
return t?.root ? u.resolve(t.root) : F(process.cwd()) ?? process.cwd();
|
|
3209
|
+
}
|
|
3210
|
+
async function Fn(t, e) {
|
|
3211
|
+
const n = $n(e), r = e?.loader ?? ie(), i = {};
|
|
3212
|
+
for (const [s, o] of Object.entries(t)) {
|
|
3213
|
+
const a = V(o, { rootDir: n });
|
|
3214
|
+
let c;
|
|
3215
|
+
try {
|
|
3216
|
+
c = await r(a);
|
|
3217
|
+
} catch (h) {
|
|
3218
|
+
throw Wn(h) ? h : d({
|
|
3219
|
+
code: "load_failed",
|
|
3220
|
+
path: a,
|
|
3221
|
+
details: {
|
|
3222
|
+
path: a,
|
|
3223
|
+
reason: h instanceof Error ? h.message : "unknown load error"
|
|
3224
|
+
}
|
|
3225
|
+
});
|
|
3226
|
+
}
|
|
3227
|
+
i[s] = await En(c, a);
|
|
3228
|
+
}
|
|
3229
|
+
return i;
|
|
3230
|
+
}
|
|
3231
|
+
function Bn(t, e) {
|
|
3088
3232
|
const n = [`[hyogen:${t}] ${e.code}`], r = {};
|
|
3089
3233
|
if (e.details)
|
|
3090
3234
|
for (const [i, s] of Object.entries(e.details))
|
|
@@ -3096,14 +3240,15 @@ function Cn(t, e) {
|
|
|
3096
3240
|
`);
|
|
3097
3241
|
}
|
|
3098
3242
|
export {
|
|
3099
|
-
|
|
3100
|
-
|
|
3243
|
+
jn as build,
|
|
3244
|
+
ot as createFsLoader,
|
|
3101
3245
|
d as createHyogenError,
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3246
|
+
ie as createNodeLoader,
|
|
3247
|
+
Bn as formatDiagnosticLog,
|
|
3248
|
+
it as formatMessage,
|
|
3105
3249
|
j as isRemotePath,
|
|
3106
|
-
|
|
3107
|
-
|
|
3250
|
+
Fn as loadDataSources,
|
|
3251
|
+
Hn as renderClient,
|
|
3252
|
+
hn as renderServer
|
|
3108
3253
|
};
|
|
3109
3254
|
//# sourceMappingURL=index.js.map
|