@b4moss/hyogen-md 0.11.0 → 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 +1 -1
- package/README_ja.md +1 -1
- package/dist/client.js +604 -389
- package/dist/index.js +997 -757
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { parse as
|
|
2
|
-
const
|
|
3
|
-
errors:
|
|
4
|
-
warnings:
|
|
5
|
-
warningReasons:
|
|
6
|
-
},
|
|
7
|
-
function
|
|
1
|
+
import { parse as Pe } from "yaml";
|
|
2
|
+
const Ie = { file_not_found: "File not found: {path} (referenced from {from} via {via})", frontmatter_too_large: "Front matter exceeds size limit in {path} ({size} bytes, limit {limit})", duplicate_component_alias: 'Duplicate component alias "{alias}" in {path}', alias_collision: 'Component alias "{alias}" collides with an existing binding in {path}', forbidden_property_access: 'Forbidden property access "{property}" in {path}', parse_error: "Parse error in {path}: {message}", component_multiline_output: 'Component "{alias}" returned multiline output (single line required)', server_context_on_client: "serverContext is not allowed with renderClient", load_failed: "Failed to load {path}: {reason}", data_sources_on_client: "dataSources is not allowed with renderClient", data_source_too_large: "Data source exceeds size limit in {path} ({size} bytes, limit {limit})" }, ze = { circular_include: "Circular reference detected; skipped {path} (referenced from {from} via {via})", nest_limit_exceeded: "Nesting limit exceeded ({limit}); skipped block in {path}", extend_in_component: "extend is not allowed inside a component; skipped in {path}", prop_type_mismatch: 'Prop "{prop}" type mismatch in component "{component}"; expected {expected}, got {actual}', prop_missing: 'Required prop "{prop}" is missing for component "{component}"', prop_unknown: 'Unknown prop "{prop}" passed to component "{component}"; ignored', suspicious_context_value: 'Suspicious value in context key "{key}" ({reason})' }, Ue = { contains_html_script_tag: "contains HTML script tag", contains_event_handler: "contains inline event handler", contains_dangerous_scheme: "contains dangerous URL scheme", contains_embed_tag: "contains embeddable HTML tag", contains_meta_refresh: "contains meta refresh" }, J = {
|
|
3
|
+
errors: Ie,
|
|
4
|
+
warnings: ze,
|
|
5
|
+
warningReasons: Ue
|
|
6
|
+
}, Ze = J.errors, qe = J.warnings;
|
|
7
|
+
function ye(t, e) {
|
|
8
8
|
return t === void 0 ? "" : t.replace(/\{([^}]+)\}/g, (n, r) => {
|
|
9
9
|
if (e === void 0 || !(r in e))
|
|
10
10
|
return n;
|
|
@@ -12,14 +12,14 @@ function we(t, e) {
|
|
|
12
12
|
return s == null ? "" : String(s);
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function Ve(t, e) {
|
|
16
|
+
return ye(Ze[t], e);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
18
|
+
function R(t, e) {
|
|
19
|
+
return ye(qe[t], e);
|
|
20
20
|
}
|
|
21
21
|
function u(t) {
|
|
22
|
-
const e = t.message ??
|
|
22
|
+
const e = t.message ?? Ve(t.code, t.details), n = new Error(e);
|
|
23
23
|
return n.name = "HyogenError", n.code = t.code, n.message = e, n.path = t.path, n.details = t.details, n;
|
|
24
24
|
}
|
|
25
25
|
function _(...t) {
|
|
@@ -28,7 +28,7 @@ function _(...t) {
|
|
|
28
28
|
n != null && Object.assign(e, n);
|
|
29
29
|
return e;
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class _e {
|
|
32
32
|
components = /* @__PURE__ */ new Map();
|
|
33
33
|
register(e, n, r) {
|
|
34
34
|
if (this.components.has(e.alias))
|
|
@@ -52,8 +52,8 @@ class be {
|
|
|
52
52
|
return this.components.has(e);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
function
|
|
55
|
+
const de = 64 * 1024;
|
|
56
|
+
function P(t, e) {
|
|
57
57
|
if (!t.startsWith("---"))
|
|
58
58
|
return { context: {}, body: t };
|
|
59
59
|
const n = t.indexOf(`
|
|
@@ -65,13 +65,13 @@ function H(t, e) {
|
|
|
65
65
|
if (r === -1)
|
|
66
66
|
return { context: {}, body: t };
|
|
67
67
|
const s = t.slice(n + 1, r), i = Buffer.byteLength(s, "utf8");
|
|
68
|
-
if (i >
|
|
68
|
+
if (i > de)
|
|
69
69
|
throw u({
|
|
70
70
|
code: "frontmatter_too_large",
|
|
71
71
|
path: e,
|
|
72
72
|
details: {
|
|
73
73
|
size: i,
|
|
74
|
-
limit:
|
|
74
|
+
limit: de
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
if (s.trim().length === 0)
|
|
@@ -82,7 +82,7 @@ function H(t, e) {
|
|
|
82
82
|
});
|
|
83
83
|
let o;
|
|
84
84
|
try {
|
|
85
|
-
const h =
|
|
85
|
+
const h = Pe(s);
|
|
86
86
|
if (h == null)
|
|
87
87
|
o = {};
|
|
88
88
|
else if (typeof h == "object" && !Array.isArray(h))
|
|
@@ -110,14 +110,14 @@ ${s}
|
|
|
110
110
|
---`
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
const
|
|
113
|
+
const Ke = /* @__PURE__ */ new Set([
|
|
114
114
|
"string",
|
|
115
115
|
"number",
|
|
116
116
|
"boolean",
|
|
117
117
|
"object",
|
|
118
118
|
"array"
|
|
119
119
|
]);
|
|
120
|
-
function
|
|
120
|
+
function Ye(t, e) {
|
|
121
121
|
const n = t.props;
|
|
122
122
|
if (n === void 0)
|
|
123
123
|
return {};
|
|
@@ -136,13 +136,13 @@ function qe(t, e) {
|
|
|
136
136
|
const o = i, a = {};
|
|
137
137
|
if ("type" in o && o.type !== void 0) {
|
|
138
138
|
const c = String(o.type);
|
|
139
|
-
|
|
139
|
+
Ke.has(c) ? a.type = c : a.type = void 0;
|
|
140
140
|
}
|
|
141
141
|
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[s] = a;
|
|
142
142
|
}
|
|
143
143
|
return r;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function Xe(t) {
|
|
146
146
|
if (t != null) {
|
|
147
147
|
if (typeof t == "string") return "string";
|
|
148
148
|
if (typeof t == "number") return "number";
|
|
@@ -151,17 +151,17 @@ function Ve(t) {
|
|
|
151
151
|
if (typeof t == "object") return "object";
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Ge(t, e) {
|
|
155
155
|
return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
|
|
156
156
|
}
|
|
157
157
|
function U(t, e) {
|
|
158
158
|
return {
|
|
159
159
|
code: t,
|
|
160
|
-
message:
|
|
160
|
+
message: R(t, e),
|
|
161
161
|
details: e
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function Je(t, e, n) {
|
|
165
165
|
const r = [], s = {}, i = new Set(Object.keys(e));
|
|
166
166
|
for (const [o, a] of Object.entries(e)) {
|
|
167
167
|
const c = Object.prototype.hasOwnProperty.call(t, o);
|
|
@@ -172,8 +172,8 @@ function Ye(t, e, n) {
|
|
|
172
172
|
component: n
|
|
173
173
|
})
|
|
174
174
|
), h = void 0)), c && h !== void 0 && h !== null) {
|
|
175
|
-
const l = a.type ??
|
|
176
|
-
l && !
|
|
175
|
+
const l = a.type ?? Xe(h);
|
|
176
|
+
l && !Ge(h, l) && (r.push(
|
|
177
177
|
U("prop_type_mismatch", {
|
|
178
178
|
prop: o,
|
|
179
179
|
component: n,
|
|
@@ -193,16 +193,16 @@ function Ye(t, e, n) {
|
|
|
193
193
|
) : s[o] = t[o]);
|
|
194
194
|
return { values: s, warnings: r };
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function Se(t) {
|
|
197
197
|
return /^https?:\/\//i.test(t);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function Qe(t) {
|
|
200
200
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
201
201
|
}
|
|
202
|
-
var Z,
|
|
203
|
-
function
|
|
204
|
-
if (
|
|
205
|
-
|
|
202
|
+
var Z, ue;
|
|
203
|
+
function et() {
|
|
204
|
+
if (ue) return Z;
|
|
205
|
+
ue = 1;
|
|
206
206
|
function t(s) {
|
|
207
207
|
if (typeof s != "string")
|
|
208
208
|
throw new TypeError("Path must be a string. Received " + JSON.stringify(s));
|
|
@@ -284,10 +284,10 @@ function Je() {
|
|
|
284
284
|
} else h > g && (i.charCodeAt(a + p) === 47 ? m = p : p === 0 && (m = 0));
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
|
-
var
|
|
288
|
-
if (
|
|
287
|
+
var $ = i.charCodeAt(a + p), D = o.charCodeAt(l + p);
|
|
288
|
+
if ($ !== D)
|
|
289
289
|
break;
|
|
290
|
-
|
|
290
|
+
$ === 47 && (m = p);
|
|
291
291
|
}
|
|
292
292
|
var b = "";
|
|
293
293
|
for (p = a + m + 1; p <= c; ++p)
|
|
@@ -387,22 +387,22 @@ function Je() {
|
|
|
387
387
|
};
|
|
388
388
|
return r.posix = r, Z = r, Z;
|
|
389
389
|
}
|
|
390
|
-
var
|
|
391
|
-
const y = /* @__PURE__ */
|
|
392
|
-
function
|
|
390
|
+
var tt = et();
|
|
391
|
+
const y = /* @__PURE__ */ Qe(tt);
|
|
392
|
+
function nt(t, e) {
|
|
393
393
|
const n = y.relative(e, t);
|
|
394
394
|
return n === "" || !n.startsWith("..") && !y.isAbsolute(n);
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function rt(t, e, n) {
|
|
397
397
|
const r = y.resolve(e), s = y.resolve(t);
|
|
398
|
-
if (!
|
|
398
|
+
if (!nt(s, r))
|
|
399
399
|
throw u({
|
|
400
400
|
code: "parse_error",
|
|
401
401
|
path: n,
|
|
402
402
|
details: { message: "path resolves outside root directory" }
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
|
-
function
|
|
405
|
+
function Ce(t, e = {}) {
|
|
406
406
|
const { rootDir: n, fromPath: r, documentPath: s, constrainToRoot: i = !1, hyogenPath: o = !1 } = e;
|
|
407
407
|
if (t.length === 0)
|
|
408
408
|
throw u({
|
|
@@ -451,9 +451,9 @@ function ve(t, e = {}) {
|
|
|
451
451
|
path: s,
|
|
452
452
|
details: { message: "root is required for relative template paths" }
|
|
453
453
|
});
|
|
454
|
-
return n && i &&
|
|
454
|
+
return n && i && rt(a, n, s), a;
|
|
455
455
|
}
|
|
456
|
-
async function
|
|
456
|
+
async function it(t) {
|
|
457
457
|
const e = t.registry.get(t.alias);
|
|
458
458
|
if (!e)
|
|
459
459
|
throw u({
|
|
@@ -463,13 +463,13 @@ async function tt(t) {
|
|
|
463
463
|
message: `unregistered component: ${t.alias}`
|
|
464
464
|
}
|
|
465
465
|
});
|
|
466
|
-
const n =
|
|
466
|
+
const n = Se(e.componentPath) ? e.componentPath : Ce(e.componentPath, {
|
|
467
467
|
rootDir: t.rootDir,
|
|
468
468
|
fromPath: e.definedAt,
|
|
469
469
|
documentPath: t.path,
|
|
470
470
|
constrainToRoot: t.constrainToRoot,
|
|
471
471
|
hyogenPath: !0
|
|
472
|
-
}), r = await t.loader(n), { context: s, body: i } =
|
|
472
|
+
}), r = await t.loader(n), { context: s, body: i } = P(r, n), o = Ye(s, n), { values: a, warnings: c } = Je(
|
|
473
473
|
t.props,
|
|
474
474
|
o,
|
|
475
475
|
t.alias
|
|
@@ -479,7 +479,7 @@ async function tt(t) {
|
|
|
479
479
|
t.parentContext,
|
|
480
480
|
l,
|
|
481
481
|
a
|
|
482
|
-
), g = (await
|
|
482
|
+
), g = (await le(i, {
|
|
483
483
|
context: d,
|
|
484
484
|
loader: t.loader,
|
|
485
485
|
root: t.rootDir,
|
|
@@ -501,17 +501,17 @@ async function tt(t) {
|
|
|
501
501
|
});
|
|
502
502
|
return g;
|
|
503
503
|
}
|
|
504
|
-
const
|
|
504
|
+
const st = /* @__PURE__ */ new Set([
|
|
505
505
|
"__proto__",
|
|
506
506
|
"prototype",
|
|
507
507
|
"constructor",
|
|
508
508
|
"__defineGetter__"
|
|
509
509
|
]);
|
|
510
|
-
function
|
|
511
|
-
return
|
|
510
|
+
function ot(t) {
|
|
511
|
+
return st.has(t);
|
|
512
512
|
}
|
|
513
|
-
function
|
|
514
|
-
if (
|
|
513
|
+
function fe(t, e) {
|
|
514
|
+
if (ot(t))
|
|
515
515
|
throw u({
|
|
516
516
|
code: "forbidden_property_access",
|
|
517
517
|
path: e,
|
|
@@ -521,11 +521,15 @@ function de(t, e) {
|
|
|
521
521
|
function M(t) {
|
|
522
522
|
return !t;
|
|
523
523
|
}
|
|
524
|
-
function
|
|
525
|
-
if (t != null
|
|
526
|
-
|
|
524
|
+
function at(t, e) {
|
|
525
|
+
if (t != null) {
|
|
526
|
+
if (typeof t == "string")
|
|
527
|
+
return e === "length" ? t.length : void 0;
|
|
528
|
+
if (typeof t == "object")
|
|
529
|
+
return t[e];
|
|
530
|
+
}
|
|
527
531
|
}
|
|
528
|
-
function
|
|
532
|
+
function ct(t, e, n) {
|
|
529
533
|
switch (t) {
|
|
530
534
|
case "+":
|
|
531
535
|
return e + n;
|
|
@@ -559,37 +563,37 @@ function st(t, e, n) {
|
|
|
559
563
|
return;
|
|
560
564
|
}
|
|
561
565
|
}
|
|
562
|
-
async function
|
|
566
|
+
async function k(t, e) {
|
|
563
567
|
const { context: n, path: r } = e;
|
|
564
568
|
switch (t.type) {
|
|
565
569
|
case "literal":
|
|
566
570
|
return t.value;
|
|
567
571
|
case "identifier":
|
|
568
|
-
return
|
|
572
|
+
return fe(t.name, r), n[t.name];
|
|
569
573
|
case "member": {
|
|
570
|
-
|
|
571
|
-
const s = await
|
|
572
|
-
return
|
|
574
|
+
fe(t.property, r);
|
|
575
|
+
const s = await k(t.object, e);
|
|
576
|
+
return at(s, t.property);
|
|
573
577
|
}
|
|
574
578
|
case "default": {
|
|
575
|
-
const s = await
|
|
576
|
-
return M(s) ?
|
|
579
|
+
const s = await k(t.left, e);
|
|
580
|
+
return M(s) ? k(t.right, e) : s;
|
|
577
581
|
}
|
|
578
582
|
case "unary": {
|
|
579
|
-
const s = await
|
|
583
|
+
const s = await k(t.operand, e);
|
|
580
584
|
return t.op === "!" ? !s : void 0;
|
|
581
585
|
}
|
|
582
586
|
case "binary": {
|
|
583
587
|
if (t.op === "&&") {
|
|
584
|
-
const o = await
|
|
585
|
-
return M(o) ? o :
|
|
588
|
+
const o = await k(t.left, e);
|
|
589
|
+
return M(o) ? o : k(t.right, e);
|
|
586
590
|
}
|
|
587
591
|
if (t.op === "||") {
|
|
588
|
-
const o = await
|
|
589
|
-
return M(o) ?
|
|
592
|
+
const o = await k(t.left, e);
|
|
593
|
+
return M(o) ? k(t.right, e) : o;
|
|
590
594
|
}
|
|
591
|
-
const s = await
|
|
592
|
-
return
|
|
595
|
+
const s = await k(t.left, e), i = await k(t.right, e);
|
|
596
|
+
return ct(t.op, s, i);
|
|
593
597
|
}
|
|
594
598
|
case "call": {
|
|
595
599
|
if (!e.registry || !e.loader || !e.visitStack)
|
|
@@ -610,8 +614,8 @@ async function w(t, e) {
|
|
|
610
614
|
});
|
|
611
615
|
const s = {};
|
|
612
616
|
for (const [i, o] of Object.entries(t.args))
|
|
613
|
-
s[i] = await
|
|
614
|
-
return
|
|
617
|
+
s[i] = await k(o, e);
|
|
618
|
+
return it({
|
|
615
619
|
alias: t.callee,
|
|
616
620
|
props: s,
|
|
617
621
|
parentContext: e.parentContext ?? n,
|
|
@@ -632,14 +636,14 @@ async function w(t, e) {
|
|
|
632
636
|
path: r,
|
|
633
637
|
details: { message: `unsupported method: ${t.method}()` }
|
|
634
638
|
});
|
|
635
|
-
const s = await
|
|
639
|
+
const s = await k(t.object, e);
|
|
636
640
|
return s == null || typeof s.toLocaleString != "function" ? void 0 : s.toLocaleString(
|
|
637
641
|
...t.args
|
|
638
642
|
);
|
|
639
643
|
}
|
|
640
644
|
case "ternary": {
|
|
641
|
-
const s = await
|
|
642
|
-
return M(s) ?
|
|
645
|
+
const s = await k(t.condition, e);
|
|
646
|
+
return M(s) ? k(t.alternate, e) : k(t.consequent, e);
|
|
643
647
|
}
|
|
644
648
|
case "template": {
|
|
645
649
|
let s = "";
|
|
@@ -647,7 +651,7 @@ async function w(t, e) {
|
|
|
647
651
|
if (typeof i == "string")
|
|
648
652
|
s += i;
|
|
649
653
|
else {
|
|
650
|
-
const o = await
|
|
654
|
+
const o = await k(i, e);
|
|
651
655
|
o != null && (s += String(o));
|
|
652
656
|
}
|
|
653
657
|
return s;
|
|
@@ -659,14 +663,14 @@ async function w(t, e) {
|
|
|
659
663
|
function q(t) {
|
|
660
664
|
return /[A-Za-z_$]/.test(t);
|
|
661
665
|
}
|
|
662
|
-
function
|
|
666
|
+
function lt(t) {
|
|
663
667
|
return /[A-Za-z0-9_$]/.test(t);
|
|
664
668
|
}
|
|
665
669
|
function C(t, e, n = {}) {
|
|
666
670
|
const r = t.trim();
|
|
667
671
|
if (r.length === 0)
|
|
668
672
|
throw x(e, "empty expression");
|
|
669
|
-
const s = new
|
|
673
|
+
const s = new ht(r, e, n), i = s.parseExpression();
|
|
670
674
|
if (s.skipWhitespace(), s.hasMore())
|
|
671
675
|
throw x(e, `unexpected token at position ${s.position}`);
|
|
672
676
|
return i;
|
|
@@ -678,7 +682,7 @@ function x(t, e) {
|
|
|
678
682
|
details: { message: e }
|
|
679
683
|
});
|
|
680
684
|
}
|
|
681
|
-
class
|
|
685
|
+
class ht {
|
|
682
686
|
constructor(e, n, r = {}) {
|
|
683
687
|
this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
|
|
684
688
|
}
|
|
@@ -1046,7 +1050,7 @@ class at {
|
|
|
1046
1050
|
const e = this.index;
|
|
1047
1051
|
if (!q(this.peek()))
|
|
1048
1052
|
return "";
|
|
1049
|
-
for (this.index++; this.index < this.input.length &&
|
|
1053
|
+
for (this.index++; this.index < this.input.length && lt(this.peek()); )
|
|
1050
1054
|
this.index++;
|
|
1051
1055
|
return this.input.slice(e, this.index);
|
|
1052
1056
|
}
|
|
@@ -1079,7 +1083,7 @@ class at {
|
|
|
1079
1083
|
return r;
|
|
1080
1084
|
}
|
|
1081
1085
|
}
|
|
1082
|
-
async function
|
|
1086
|
+
async function We(t, e, n = {}) {
|
|
1083
1087
|
const r = n.path;
|
|
1084
1088
|
let s = "", i = 0;
|
|
1085
1089
|
for (; i < t.length; ) {
|
|
@@ -1101,7 +1105,7 @@ async function _e(t, e, n = {}) {
|
|
|
1101
1105
|
path: r,
|
|
1102
1106
|
details: { message: "unclosed expression" }
|
|
1103
1107
|
});
|
|
1104
|
-
const f = t.slice(o + h, d).trim(), g = C(f, r), m = await
|
|
1108
|
+
const f = t.slice(o + h, d).trim(), g = C(f, r), m = await k(g, {
|
|
1105
1109
|
...n,
|
|
1106
1110
|
context: e,
|
|
1107
1111
|
path: r,
|
|
@@ -1111,7 +1115,7 @@ async function _e(t, e, n = {}) {
|
|
|
1111
1115
|
}
|
|
1112
1116
|
return s;
|
|
1113
1117
|
}
|
|
1114
|
-
function
|
|
1118
|
+
function dt(t, e) {
|
|
1115
1119
|
let n = 0, r = 0;
|
|
1116
1120
|
for (; r < t.length; ) {
|
|
1117
1121
|
const s = t.indexOf(e, r);
|
|
@@ -1121,14 +1125,14 @@ function ct(t, e) {
|
|
|
1121
1125
|
}
|
|
1122
1126
|
return n;
|
|
1123
1127
|
}
|
|
1124
|
-
function
|
|
1125
|
-
const e = t.includes("@hg"), n = t.includes("@endhg"), r =
|
|
1128
|
+
function Q(t) {
|
|
1129
|
+
const e = t.includes("@hg"), n = t.includes("@endhg"), r = dt(t, "@@");
|
|
1126
1130
|
return e && n ? r > 0 ? "mixed" : "hg" : r >= 2 && !e && !n ? "at-at" : (e || n) && r > 0 ? "mixed" : e && !n || r === 1 && !n ? "unclosed" : "none";
|
|
1127
1131
|
}
|
|
1128
|
-
function
|
|
1132
|
+
function ee(t) {
|
|
1129
1133
|
return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
|
|
1130
1134
|
}
|
|
1131
|
-
function
|
|
1135
|
+
function te(t, e) {
|
|
1132
1136
|
let n = 0, r = !1;
|
|
1133
1137
|
for (; n < e; ) {
|
|
1134
1138
|
const s = t.indexOf("```", n);
|
|
@@ -1138,21 +1142,21 @@ function ee(t, e) {
|
|
|
1138
1142
|
}
|
|
1139
1143
|
return r;
|
|
1140
1144
|
}
|
|
1141
|
-
function
|
|
1145
|
+
function E(t) {
|
|
1142
1146
|
const e = [];
|
|
1143
1147
|
let n = 0;
|
|
1144
1148
|
for (; n < t.length; ) {
|
|
1145
1149
|
const r = t.indexOf("<!--", n);
|
|
1146
1150
|
if (r === -1)
|
|
1147
1151
|
break;
|
|
1148
|
-
if (
|
|
1152
|
+
if (te(t, r)) {
|
|
1149
1153
|
n = r + 4;
|
|
1150
1154
|
continue;
|
|
1151
1155
|
}
|
|
1152
1156
|
const s = t.indexOf("-->", r + 4);
|
|
1153
1157
|
if (s === -1)
|
|
1154
1158
|
break;
|
|
1155
|
-
const i = t.slice(r, s + 3), o = i.slice(4, i.length - 3), a =
|
|
1159
|
+
const i = t.slice(r, s + 3), o = i.slice(4, i.length - 3), a = Q(o);
|
|
1156
1160
|
(a === "hg" || a === "at-at") && e.push({
|
|
1157
1161
|
start: r,
|
|
1158
1162
|
end: s + 3,
|
|
@@ -1162,40 +1166,40 @@ function T(t) {
|
|
|
1162
1166
|
}
|
|
1163
1167
|
return e;
|
|
1164
1168
|
}
|
|
1165
|
-
function
|
|
1169
|
+
function Ae(t) {
|
|
1166
1170
|
let e = 0;
|
|
1167
1171
|
for (; e < t.length; ) {
|
|
1168
1172
|
const n = t.indexOf("<!--", e);
|
|
1169
1173
|
if (n === -1)
|
|
1170
1174
|
return !1;
|
|
1171
|
-
if (
|
|
1175
|
+
if (te(t, n)) {
|
|
1172
1176
|
e = n + 4;
|
|
1173
1177
|
continue;
|
|
1174
1178
|
}
|
|
1175
1179
|
const r = t.indexOf("-->", n + 4);
|
|
1176
1180
|
if (r === -1)
|
|
1177
1181
|
return !1;
|
|
1178
|
-
const s = t.slice(n + 4, r), i =
|
|
1182
|
+
const s = t.slice(n + 4, r), i = Q(s);
|
|
1179
1183
|
if (i === "unclosed" || i === "mixed")
|
|
1180
1184
|
return !0;
|
|
1181
1185
|
e = r + 3;
|
|
1182
1186
|
}
|
|
1183
1187
|
return !1;
|
|
1184
1188
|
}
|
|
1185
|
-
function
|
|
1189
|
+
function $e(t) {
|
|
1186
1190
|
let e = 0;
|
|
1187
1191
|
for (; e < t.length; ) {
|
|
1188
1192
|
const n = t.indexOf("<!--", e);
|
|
1189
1193
|
if (n === -1)
|
|
1190
1194
|
return null;
|
|
1191
|
-
if (
|
|
1195
|
+
if (te(t, n)) {
|
|
1192
1196
|
e = n + 4;
|
|
1193
1197
|
continue;
|
|
1194
1198
|
}
|
|
1195
1199
|
const r = t.indexOf("-->", n + 4);
|
|
1196
1200
|
if (r === -1)
|
|
1197
1201
|
return null;
|
|
1198
|
-
const s = t.slice(n + 4, r), i =
|
|
1202
|
+
const s = t.slice(n + 4, r), i = Q(s);
|
|
1199
1203
|
if (i === "mixed")
|
|
1200
1204
|
return "mixed @hg and @@ markers are not allowed";
|
|
1201
1205
|
if (i === "unclosed")
|
|
@@ -1204,12 +1208,12 @@ function Ce(t) {
|
|
|
1204
1208
|
}
|
|
1205
1209
|
return null;
|
|
1206
1210
|
}
|
|
1207
|
-
function
|
|
1208
|
-
return
|
|
1211
|
+
function A(t) {
|
|
1212
|
+
return ee(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
|
|
1209
1213
|
}
|
|
1210
|
-
const
|
|
1211
|
-
function
|
|
1212
|
-
return
|
|
1214
|
+
const ut = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
|
|
1215
|
+
function Ee(t) {
|
|
1216
|
+
return ut.test(t.trim());
|
|
1213
1217
|
}
|
|
1214
1218
|
function V(t, e) {
|
|
1215
1219
|
throw u({
|
|
@@ -1218,11 +1222,11 @@ function V(t, e) {
|
|
|
1218
1222
|
details: { message: e }
|
|
1219
1223
|
});
|
|
1220
1224
|
}
|
|
1221
|
-
function
|
|
1225
|
+
function ft(t, e) {
|
|
1222
1226
|
let n = t;
|
|
1223
1227
|
const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
|
|
1224
1228
|
r && (n = r[1]);
|
|
1225
|
-
const s =
|
|
1229
|
+
const s = A(n);
|
|
1226
1230
|
if (s.length !== 1)
|
|
1227
1231
|
return null;
|
|
1228
1232
|
const i = s[0];
|
|
@@ -1261,20 +1265,20 @@ function ht(t, e) {
|
|
|
1261
1265
|
throw V(e, "invalid each directive");
|
|
1262
1266
|
return null;
|
|
1263
1267
|
}
|
|
1264
|
-
function
|
|
1268
|
+
function O(t) {
|
|
1265
1269
|
return { start: t.start, end: t.end, raw: t.raw };
|
|
1266
1270
|
}
|
|
1267
|
-
function
|
|
1271
|
+
function W(t, e) {
|
|
1268
1272
|
throw u({
|
|
1269
1273
|
code: "parse_error",
|
|
1270
1274
|
path: t,
|
|
1271
1275
|
details: { message: e }
|
|
1272
1276
|
});
|
|
1273
1277
|
}
|
|
1274
|
-
function
|
|
1278
|
+
function pt(t, e) {
|
|
1275
1279
|
const n = [];
|
|
1276
|
-
for (const r of
|
|
1277
|
-
const s =
|
|
1280
|
+
for (const r of E(t)) {
|
|
1281
|
+
const s = ft(r.inner, e);
|
|
1278
1282
|
s && n.push({
|
|
1279
1283
|
start: r.start,
|
|
1280
1284
|
end: r.end,
|
|
@@ -1284,22 +1288,22 @@ function dt(t, e) {
|
|
|
1284
1288
|
}
|
|
1285
1289
|
return n;
|
|
1286
1290
|
}
|
|
1287
|
-
function
|
|
1291
|
+
function Te(t) {
|
|
1288
1292
|
return t.kind === "if" || t.kind === "each";
|
|
1289
1293
|
}
|
|
1290
|
-
function
|
|
1291
|
-
const n =
|
|
1294
|
+
function mt(t, e) {
|
|
1295
|
+
const n = pt(t, e);
|
|
1292
1296
|
if (n.length === 0)
|
|
1293
1297
|
return t.length > 0 ? [{ kind: "text", content: t }] : [];
|
|
1294
1298
|
const { nodes: r, nextIndex: s } = B(t, n, 0, n.length, e);
|
|
1295
1299
|
if (s < n.length) {
|
|
1296
1300
|
const i = n[s];
|
|
1297
1301
|
if (i.opener.kind === "endif")
|
|
1298
|
-
throw
|
|
1302
|
+
throw W(e, "endif without matching if");
|
|
1299
1303
|
if (i.opener.kind === "endeach")
|
|
1300
|
-
throw
|
|
1304
|
+
throw W(e, "endeach without matching each");
|
|
1301
1305
|
if (i.opener.kind === "else" || i.opener.kind === "else_if")
|
|
1302
|
-
throw
|
|
1306
|
+
throw W(e, "else without matching if");
|
|
1303
1307
|
}
|
|
1304
1308
|
return r;
|
|
1305
1309
|
}
|
|
@@ -1318,45 +1322,45 @@ function B(t, e, n, r, s, i = 0, o) {
|
|
|
1318
1322
|
kind: "text",
|
|
1319
1323
|
content: t.slice(h, d.start)
|
|
1320
1324
|
}), d.opener.kind === "if") {
|
|
1321
|
-
const f =
|
|
1325
|
+
const f = gt(t, e, l, r, s);
|
|
1322
1326
|
c.push(f.node), h = f.endPos, l = f.nextIndex;
|
|
1323
1327
|
continue;
|
|
1324
1328
|
}
|
|
1325
1329
|
if (d.opener.kind === "each") {
|
|
1326
|
-
const f =
|
|
1330
|
+
const f = xt(t, e, l, r, s);
|
|
1327
1331
|
c.push(f.node), h = f.endPos, l = f.nextIndex;
|
|
1328
1332
|
continue;
|
|
1329
1333
|
}
|
|
1330
1334
|
if (d.opener.kind === "else" || d.opener.kind === "else_if")
|
|
1331
|
-
throw
|
|
1335
|
+
throw W(s, "else without matching if");
|
|
1332
1336
|
if (d.opener.kind === "endif")
|
|
1333
|
-
throw
|
|
1337
|
+
throw W(s, "endif without matching if");
|
|
1334
1338
|
if (d.opener.kind === "endeach")
|
|
1335
|
-
throw
|
|
1339
|
+
throw W(s, "endeach without matching each");
|
|
1336
1340
|
l++;
|
|
1337
1341
|
}
|
|
1338
1342
|
return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
|
|
1339
1343
|
}
|
|
1340
|
-
function
|
|
1344
|
+
function gt(t, e, n, r, s) {
|
|
1341
1345
|
const i = e[n];
|
|
1342
1346
|
if (i.opener.kind !== "if")
|
|
1343
|
-
throw
|
|
1347
|
+
throw W(s, "expected if");
|
|
1344
1348
|
const o = [];
|
|
1345
1349
|
let a = n, c = i.end, h = 0;
|
|
1346
1350
|
for (; a < r; ) {
|
|
1347
1351
|
const l = e[a];
|
|
1348
1352
|
if (a === n) {
|
|
1349
1353
|
if (l.opener.kind !== "if")
|
|
1350
|
-
throw
|
|
1354
|
+
throw W(s, "expected if");
|
|
1351
1355
|
o.push({
|
|
1352
1356
|
kind: "if",
|
|
1353
1357
|
expr: l.opener.expr,
|
|
1354
|
-
opener:
|
|
1358
|
+
opener: O(l),
|
|
1355
1359
|
body: []
|
|
1356
1360
|
}), a++;
|
|
1357
1361
|
continue;
|
|
1358
1362
|
}
|
|
1359
|
-
if (
|
|
1363
|
+
if (Te(l.opener)) {
|
|
1360
1364
|
h++, a++;
|
|
1361
1365
|
continue;
|
|
1362
1366
|
}
|
|
@@ -1371,7 +1375,7 @@ function ft(t, e, n, r, s) {
|
|
|
1371
1375
|
c,
|
|
1372
1376
|
l.start
|
|
1373
1377
|
).nodes, {
|
|
1374
|
-
node: { kind: "if", branches: o, closer:
|
|
1378
|
+
node: { kind: "if", branches: o, closer: O(l) },
|
|
1375
1379
|
nextIndex: a + 1,
|
|
1376
1380
|
endPos: l.end
|
|
1377
1381
|
};
|
|
@@ -1395,7 +1399,7 @@ function ft(t, e, n, r, s) {
|
|
|
1395
1399
|
).nodes, o.push({
|
|
1396
1400
|
kind: "else_if",
|
|
1397
1401
|
expr: l.opener.expr,
|
|
1398
|
-
opener:
|
|
1402
|
+
opener: O(l),
|
|
1399
1403
|
body: []
|
|
1400
1404
|
}), c = l.end, a++;
|
|
1401
1405
|
continue;
|
|
@@ -1411,7 +1415,7 @@ function ft(t, e, n, r, s) {
|
|
|
1411
1415
|
l.start
|
|
1412
1416
|
).nodes, o.push({
|
|
1413
1417
|
kind: "else",
|
|
1414
|
-
opener:
|
|
1418
|
+
opener: O(l),
|
|
1415
1419
|
body: []
|
|
1416
1420
|
}), c = l.end, a++;
|
|
1417
1421
|
continue;
|
|
@@ -1419,18 +1423,18 @@ function ft(t, e, n, r, s) {
|
|
|
1419
1423
|
}
|
|
1420
1424
|
a++;
|
|
1421
1425
|
}
|
|
1422
|
-
throw
|
|
1426
|
+
throw W(s, "unclosed if block (missing endif)");
|
|
1423
1427
|
}
|
|
1424
|
-
function
|
|
1428
|
+
function xt(t, e, n, r, s) {
|
|
1425
1429
|
const i = e[n];
|
|
1426
1430
|
if (i.opener.kind !== "each")
|
|
1427
|
-
throw
|
|
1431
|
+
throw W(s, "expected each");
|
|
1428
1432
|
let o = n + 1;
|
|
1429
1433
|
const a = i.end;
|
|
1430
1434
|
let c = 0;
|
|
1431
1435
|
for (; o < r; ) {
|
|
1432
1436
|
const h = e[o];
|
|
1433
|
-
if (
|
|
1437
|
+
if (Te(h.opener)) {
|
|
1434
1438
|
c++, o++;
|
|
1435
1439
|
continue;
|
|
1436
1440
|
}
|
|
@@ -1450,9 +1454,9 @@ function pt(t, e, n, r, s) {
|
|
|
1450
1454
|
kind: "each",
|
|
1451
1455
|
item: i.opener.item,
|
|
1452
1456
|
expr: i.opener.expr,
|
|
1453
|
-
opener:
|
|
1457
|
+
opener: O(i),
|
|
1454
1458
|
body: l,
|
|
1455
|
-
closer:
|
|
1459
|
+
closer: O(h)
|
|
1456
1460
|
},
|
|
1457
1461
|
nextIndex: o + 1,
|
|
1458
1462
|
endPos: h.end
|
|
@@ -1467,28 +1471,28 @@ function pt(t, e, n, r, s) {
|
|
|
1467
1471
|
}
|
|
1468
1472
|
o++;
|
|
1469
1473
|
}
|
|
1470
|
-
throw
|
|
1474
|
+
throw W(s, "unclosed each block (missing endeach)");
|
|
1471
1475
|
}
|
|
1472
|
-
const
|
|
1473
|
-
class
|
|
1476
|
+
const pe = 20;
|
|
1477
|
+
class wt {
|
|
1474
1478
|
depth = 0;
|
|
1475
1479
|
get currentDepth() {
|
|
1476
1480
|
return this.depth;
|
|
1477
1481
|
}
|
|
1478
1482
|
enter() {
|
|
1479
|
-
return this.depth >=
|
|
1483
|
+
return this.depth >= pe ? { exceeded: !0, limit: pe } : (this.depth++, { exceeded: !1, depth: this.depth });
|
|
1480
1484
|
}
|
|
1481
1485
|
exit() {
|
|
1482
1486
|
this.depth > 0 && this.depth--;
|
|
1483
1487
|
}
|
|
1484
1488
|
}
|
|
1485
|
-
function
|
|
1489
|
+
function kt(t) {
|
|
1486
1490
|
return !!t;
|
|
1487
1491
|
}
|
|
1488
|
-
function
|
|
1492
|
+
function bt(t) {
|
|
1489
1493
|
return t != null && typeof t[Symbol.iterator] == "function";
|
|
1490
1494
|
}
|
|
1491
|
-
function
|
|
1495
|
+
function Le(t) {
|
|
1492
1496
|
return {
|
|
1493
1497
|
code: "nest_limit_exceeded",
|
|
1494
1498
|
message: "structure nest limit exceeded",
|
|
@@ -1496,38 +1500,38 @@ function $e(t) {
|
|
|
1496
1500
|
details: { limit: 20 }
|
|
1497
1501
|
};
|
|
1498
1502
|
}
|
|
1499
|
-
function
|
|
1503
|
+
function ne(t) {
|
|
1500
1504
|
return t.startsWith(`
|
|
1501
1505
|
`) ? t.slice(1) : t;
|
|
1502
1506
|
}
|
|
1503
|
-
async function
|
|
1504
|
-
const n = e.path, r = e.warnings ?? [], s =
|
|
1505
|
-
return
|
|
1507
|
+
async function vt(t, e) {
|
|
1508
|
+
const n = e.path, r = e.warnings ?? [], s = mt(t, n), i = new wt();
|
|
1509
|
+
return re(s, e, i, r);
|
|
1506
1510
|
}
|
|
1507
|
-
async function
|
|
1511
|
+
async function re(t, e, n, r) {
|
|
1508
1512
|
const s = e.preserveHgComments === !0;
|
|
1509
1513
|
let i = "", o = !1;
|
|
1510
1514
|
for (const a of t) {
|
|
1511
|
-
let c = await
|
|
1512
|
-
o && (c =
|
|
1515
|
+
let c = await yt(a, e, n, r);
|
|
1516
|
+
o && (c = ne(c)), i += c, o = !s && (a.kind === "if" || a.kind === "each");
|
|
1513
1517
|
}
|
|
1514
1518
|
return i;
|
|
1515
1519
|
}
|
|
1516
|
-
async function
|
|
1520
|
+
async function yt(t, e, n, r) {
|
|
1517
1521
|
switch (t.kind) {
|
|
1518
1522
|
case "text":
|
|
1519
1523
|
return t.content;
|
|
1520
1524
|
case "if":
|
|
1521
|
-
return
|
|
1525
|
+
return _t(t, e, n, r);
|
|
1522
1526
|
case "each":
|
|
1523
|
-
return
|
|
1527
|
+
return St(t, e, n, r);
|
|
1524
1528
|
default:
|
|
1525
1529
|
return "";
|
|
1526
1530
|
}
|
|
1527
1531
|
}
|
|
1528
|
-
async function
|
|
1532
|
+
async function _t(t, e, n, r) {
|
|
1529
1533
|
if (n.enter().exceeded)
|
|
1530
|
-
return r.push(
|
|
1534
|
+
return r.push(Le(e.path)), "";
|
|
1531
1535
|
try {
|
|
1532
1536
|
let i = -1;
|
|
1533
1537
|
for (let c = 0; c < t.branches.length; c++) {
|
|
@@ -1536,8 +1540,8 @@ async function bt(t, e, n, r) {
|
|
|
1536
1540
|
i = c;
|
|
1537
1541
|
break;
|
|
1538
1542
|
}
|
|
1539
|
-
const l = await
|
|
1540
|
-
if (
|
|
1543
|
+
const l = await k(h.expr, e);
|
|
1544
|
+
if (kt(l)) {
|
|
1541
1545
|
i = c;
|
|
1542
1546
|
break;
|
|
1543
1547
|
}
|
|
@@ -1547,8 +1551,8 @@ async function bt(t, e, n, r) {
|
|
|
1547
1551
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1548
1552
|
const h = t.branches[c];
|
|
1549
1553
|
if (o && (a += h.opener.raw), c === i) {
|
|
1550
|
-
let l = await
|
|
1551
|
-
o || (l =
|
|
1554
|
+
let l = await re(h.body, e, n, r);
|
|
1555
|
+
o || (l = ne(l)), a += l;
|
|
1552
1556
|
}
|
|
1553
1557
|
}
|
|
1554
1558
|
return o && (a += t.closer.raw), a;
|
|
@@ -1556,24 +1560,24 @@ async function bt(t, e, n, r) {
|
|
|
1556
1560
|
n.exit();
|
|
1557
1561
|
}
|
|
1558
1562
|
}
|
|
1559
|
-
async function
|
|
1563
|
+
async function St(t, e, n, r) {
|
|
1560
1564
|
if (n.enter().exceeded)
|
|
1561
|
-
return r.push(
|
|
1565
|
+
return r.push(Le(e.path)), "";
|
|
1562
1566
|
try {
|
|
1563
|
-
const i = await
|
|
1564
|
-
if (!
|
|
1567
|
+
const i = await k(t.expr, e);
|
|
1568
|
+
if (!bt(i))
|
|
1565
1569
|
return "";
|
|
1566
1570
|
const o = e.preserveHgComments === !0;
|
|
1567
1571
|
let a = "";
|
|
1568
1572
|
for (const c of i) {
|
|
1569
1573
|
const h = { ...e.context, [t.item]: c };
|
|
1570
1574
|
o && (a += t.opener.raw);
|
|
1571
|
-
let l = await
|
|
1575
|
+
let l = await re(t.body, {
|
|
1572
1576
|
...e,
|
|
1573
1577
|
context: h
|
|
1574
1578
|
}, n, r);
|
|
1575
|
-
o || (l =
|
|
1576
|
-
const d = await
|
|
1579
|
+
o || (l = ne(l));
|
|
1580
|
+
const d = await We(l, h, {
|
|
1577
1581
|
path: e.path,
|
|
1578
1582
|
registry: e.registry,
|
|
1579
1583
|
loader: e.loader,
|
|
@@ -1592,7 +1596,7 @@ async function yt(t, e, n, r) {
|
|
|
1592
1596
|
}
|
|
1593
1597
|
}
|
|
1594
1598
|
function Y(t, e, n, r, s = !1, i = !1) {
|
|
1595
|
-
return
|
|
1599
|
+
return Se(e) ? e : Ce(e, {
|
|
1596
1600
|
rootDir: t,
|
|
1597
1601
|
fromPath: r,
|
|
1598
1602
|
documentPath: n,
|
|
@@ -1600,37 +1604,37 @@ function Y(t, e, n, r, s = !1, i = !1) {
|
|
|
1600
1604
|
hyogenPath: i
|
|
1601
1605
|
});
|
|
1602
1606
|
}
|
|
1603
|
-
function
|
|
1607
|
+
function Me(t) {
|
|
1604
1608
|
let e = 0;
|
|
1605
1609
|
for (let n = t.length - 1; n >= 0 && t[n] === `
|
|
1606
1610
|
`; n--)
|
|
1607
1611
|
e++;
|
|
1608
1612
|
return e;
|
|
1609
1613
|
}
|
|
1610
|
-
function
|
|
1614
|
+
function Oe(t) {
|
|
1611
1615
|
let e = 0;
|
|
1612
1616
|
for (; e < t.length && t[e] === `
|
|
1613
1617
|
`; )
|
|
1614
1618
|
e++;
|
|
1615
1619
|
return e;
|
|
1616
1620
|
}
|
|
1617
|
-
function
|
|
1618
|
-
const n =
|
|
1621
|
+
function T(t, e) {
|
|
1622
|
+
const n = Me(t), r = Oe(e), s = Math.max(n, r);
|
|
1619
1623
|
return t.slice(0, t.length - n) + `
|
|
1620
1624
|
`.repeat(s) + e.slice(r);
|
|
1621
1625
|
}
|
|
1622
|
-
function
|
|
1623
|
-
const n =
|
|
1626
|
+
function ie(t, e) {
|
|
1627
|
+
const n = Me(t), r = Oe(e);
|
|
1624
1628
|
return n + r - Math.max(n, r);
|
|
1625
1629
|
}
|
|
1626
|
-
function
|
|
1630
|
+
function me(t, e, n) {
|
|
1627
1631
|
const r = t.indexOf(e);
|
|
1628
1632
|
if (r < 0)
|
|
1629
1633
|
return t;
|
|
1630
1634
|
const s = t.slice(0, r), i = t.slice(r + e.length);
|
|
1631
|
-
return
|
|
1635
|
+
return T(T(s, n), i);
|
|
1632
1636
|
}
|
|
1633
|
-
async function
|
|
1637
|
+
async function Ct(t) {
|
|
1634
1638
|
let e = t.source;
|
|
1635
1639
|
for (const n of t.directives) {
|
|
1636
1640
|
const r = Y(
|
|
@@ -1646,7 +1650,7 @@ async function vt(t) {
|
|
|
1646
1650
|
if (s.circular) {
|
|
1647
1651
|
t.warnings?.push({
|
|
1648
1652
|
code: "circular_include",
|
|
1649
|
-
message:
|
|
1653
|
+
message: R("circular_include", {
|
|
1650
1654
|
path: r,
|
|
1651
1655
|
from: s.from,
|
|
1652
1656
|
via: "include"
|
|
@@ -1657,13 +1661,13 @@ async function vt(t) {
|
|
|
1657
1661
|
from: s.from,
|
|
1658
1662
|
via: "include"
|
|
1659
1663
|
}
|
|
1660
|
-
}), e =
|
|
1664
|
+
}), e = me(e, n.marker, "");
|
|
1661
1665
|
continue;
|
|
1662
1666
|
}
|
|
1663
1667
|
t.visitStack.push(r);
|
|
1664
1668
|
}
|
|
1665
1669
|
try {
|
|
1666
|
-
const s = await t.loader(r), i = await
|
|
1670
|
+
const s = await t.loader(r), i = await fn(s, {
|
|
1667
1671
|
context: t.context,
|
|
1668
1672
|
loader: t.loader,
|
|
1669
1673
|
root: t.root,
|
|
@@ -1675,14 +1679,14 @@ async function vt(t) {
|
|
|
1675
1679
|
registry: t.registry
|
|
1676
1680
|
}), o = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1677
1681
|
${i}` : i;
|
|
1678
|
-
e =
|
|
1682
|
+
e = me(e, n.marker, o);
|
|
1679
1683
|
} finally {
|
|
1680
1684
|
t.visitStack?.pop();
|
|
1681
1685
|
}
|
|
1682
1686
|
}
|
|
1683
1687
|
return e;
|
|
1684
1688
|
}
|
|
1685
|
-
class
|
|
1689
|
+
class Re {
|
|
1686
1690
|
stack = [];
|
|
1687
1691
|
check(e) {
|
|
1688
1692
|
return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
|
|
@@ -1698,8 +1702,8 @@ class Le {
|
|
|
1698
1702
|
this.stack.pop();
|
|
1699
1703
|
}
|
|
1700
1704
|
}
|
|
1701
|
-
async function
|
|
1702
|
-
const { path: r, constBindings: s = /* @__PURE__ */ new Set() } = n, i = await
|
|
1705
|
+
async function Wt(t, e, n = {}) {
|
|
1706
|
+
const { path: r, constBindings: s = /* @__PURE__ */ new Set() } = n, i = await k(t.expr, { context: e, path: r });
|
|
1703
1707
|
switch (t.kind) {
|
|
1704
1708
|
case "const": {
|
|
1705
1709
|
if (s.has(t.name))
|
|
@@ -1739,16 +1743,16 @@ async function _t(t, e, n = {}) {
|
|
|
1739
1743
|
}
|
|
1740
1744
|
}
|
|
1741
1745
|
}
|
|
1742
|
-
function
|
|
1746
|
+
function ge(t) {
|
|
1743
1747
|
return !t;
|
|
1744
1748
|
}
|
|
1745
|
-
async function
|
|
1746
|
-
const { path: r, constBindings: s = /* @__PURE__ */ new Set(), onUpdate: i } = n;
|
|
1749
|
+
async function N(t, e, n = {}) {
|
|
1750
|
+
const { path: r, constBindings: s = /* @__PURE__ */ new Set(), onUpdate: i, echoChunks: o } = n;
|
|
1747
1751
|
switch (t.kind) {
|
|
1748
1752
|
case "const":
|
|
1749
1753
|
case "let":
|
|
1750
1754
|
case "assign": {
|
|
1751
|
-
await
|
|
1755
|
+
await Wt(t, e, { path: r, constBindings: s }), i?.(t.name);
|
|
1752
1756
|
return;
|
|
1753
1757
|
}
|
|
1754
1758
|
case "update": {
|
|
@@ -1768,8 +1772,8 @@ async function j(t, e, n = {}) {
|
|
|
1768
1772
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1769
1773
|
}
|
|
1770
1774
|
});
|
|
1771
|
-
const
|
|
1772
|
-
e[t.name] =
|
|
1775
|
+
const a = Number(e[t.name]), c = t.op === "++" ? a + 1 : a - 1;
|
|
1776
|
+
e[t.name] = c, i?.(t.name);
|
|
1773
1777
|
return;
|
|
1774
1778
|
}
|
|
1775
1779
|
case "compound_assign": {
|
|
@@ -1789,59 +1793,67 @@ async function j(t, e, n = {}) {
|
|
|
1789
1793
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1790
1794
|
}
|
|
1791
1795
|
});
|
|
1792
|
-
const
|
|
1793
|
-
let
|
|
1796
|
+
const a = await k(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
|
|
1797
|
+
let l;
|
|
1794
1798
|
switch (t.op) {
|
|
1795
1799
|
case "+=":
|
|
1796
|
-
|
|
1800
|
+
l = c + h;
|
|
1797
1801
|
break;
|
|
1798
1802
|
case "-=":
|
|
1799
|
-
|
|
1803
|
+
l = c - h;
|
|
1800
1804
|
break;
|
|
1801
1805
|
case "*=":
|
|
1802
|
-
|
|
1806
|
+
l = c * h;
|
|
1803
1807
|
break;
|
|
1804
1808
|
case "/=":
|
|
1805
|
-
|
|
1809
|
+
l = c / h;
|
|
1806
1810
|
break;
|
|
1807
1811
|
}
|
|
1808
|
-
e[t.name] =
|
|
1812
|
+
e[t.name] = l, i?.(t.name);
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
case "echo": {
|
|
1816
|
+
const a = await k(t.expr, {
|
|
1817
|
+
context: e,
|
|
1818
|
+
path: r
|
|
1819
|
+
}), c = a == null ? "" : String(a);
|
|
1820
|
+
o?.push(c);
|
|
1809
1821
|
return;
|
|
1810
1822
|
}
|
|
1811
1823
|
case "for": {
|
|
1812
|
-
for (t.init && await
|
|
1813
|
-
const
|
|
1824
|
+
for (t.init && await N(t.init, e, n); ; ) {
|
|
1825
|
+
const a = await k(t.cond, {
|
|
1814
1826
|
context: e,
|
|
1815
1827
|
path: r
|
|
1816
1828
|
});
|
|
1817
|
-
if (
|
|
1829
|
+
if (ge(a))
|
|
1818
1830
|
break;
|
|
1819
|
-
for (const
|
|
1820
|
-
await
|
|
1821
|
-
t.update && await
|
|
1831
|
+
for (const c of t.body)
|
|
1832
|
+
await N(c, e, n);
|
|
1833
|
+
t.update && await N(t.update, e, n);
|
|
1822
1834
|
}
|
|
1823
1835
|
return;
|
|
1824
1836
|
}
|
|
1825
1837
|
case "do_while": {
|
|
1826
1838
|
do {
|
|
1827
|
-
for (const
|
|
1828
|
-
await
|
|
1829
|
-
const
|
|
1839
|
+
for (const c of t.body)
|
|
1840
|
+
await N(c, e, n);
|
|
1841
|
+
const a = await k(t.cond, {
|
|
1830
1842
|
context: e,
|
|
1831
1843
|
path: r
|
|
1832
1844
|
});
|
|
1833
|
-
if (
|
|
1845
|
+
if (ge(a))
|
|
1834
1846
|
break;
|
|
1835
1847
|
} while (!0);
|
|
1836
1848
|
return;
|
|
1837
1849
|
}
|
|
1838
1850
|
}
|
|
1839
1851
|
}
|
|
1840
|
-
async function
|
|
1852
|
+
async function xe(t, e, n = {}) {
|
|
1841
1853
|
for (const r of t)
|
|
1842
|
-
await
|
|
1854
|
+
await N(r, e, n);
|
|
1843
1855
|
}
|
|
1844
|
-
const
|
|
1856
|
+
const At = /* @__PURE__ */ new Set([
|
|
1845
1857
|
"if",
|
|
1846
1858
|
"else",
|
|
1847
1859
|
"endif",
|
|
@@ -1857,12 +1869,13 @@ const St = /* @__PURE__ */ new Set([
|
|
|
1857
1869
|
"extend",
|
|
1858
1870
|
"include",
|
|
1859
1871
|
"component",
|
|
1860
|
-
"as"
|
|
1872
|
+
"as",
|
|
1873
|
+
"echo"
|
|
1861
1874
|
]);
|
|
1862
|
-
function
|
|
1863
|
-
return
|
|
1875
|
+
function De(t) {
|
|
1876
|
+
return At.has(t);
|
|
1864
1877
|
}
|
|
1865
|
-
function
|
|
1878
|
+
function se(t) {
|
|
1866
1879
|
let e = "", n = 0, r = null;
|
|
1867
1880
|
for (; n < t.length; ) {
|
|
1868
1881
|
const s = t[n];
|
|
@@ -1895,32 +1908,32 @@ function ie(t) {
|
|
|
1895
1908
|
}
|
|
1896
1909
|
return e;
|
|
1897
1910
|
}
|
|
1898
|
-
function
|
|
1911
|
+
function w(t, e) {
|
|
1899
1912
|
throw u({
|
|
1900
1913
|
code: "parse_error",
|
|
1901
1914
|
path: t,
|
|
1902
1915
|
details: { message: e }
|
|
1903
1916
|
});
|
|
1904
1917
|
}
|
|
1905
|
-
function
|
|
1906
|
-
const n =
|
|
1918
|
+
function we(t, e) {
|
|
1919
|
+
const n = se(t).trim();
|
|
1907
1920
|
if (n.length === 0)
|
|
1908
|
-
throw
|
|
1909
|
-
const r = new
|
|
1921
|
+
throw w(e, "empty statement block");
|
|
1922
|
+
const r = new oe(n, e), s = r.parseStatementList();
|
|
1910
1923
|
if (r.skipWhitespace(), r.hasMore())
|
|
1911
|
-
throw
|
|
1924
|
+
throw w(
|
|
1912
1925
|
e,
|
|
1913
1926
|
`unexpected token at position ${r.position}`
|
|
1914
1927
|
);
|
|
1915
1928
|
if (s.length === 0)
|
|
1916
|
-
throw
|
|
1929
|
+
throw w(e, "empty statement block");
|
|
1917
1930
|
return s;
|
|
1918
1931
|
}
|
|
1919
|
-
function
|
|
1920
|
-
const e =
|
|
1921
|
-
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^for\s*\(/.test(e) || /^do\b/.test(e) || /^(\+\+|--)/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*(\+\+|--|[+\-*/]=|=)/.test(e);
|
|
1932
|
+
function He(t) {
|
|
1933
|
+
const e = se(t).trim();
|
|
1934
|
+
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^echo\b/.test(e) || /^for\s*\(/.test(e) || /^do\b/.test(e) || /^(\+\+|--)/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*(\+\+|--|[+\-*/]=|=)/.test(e);
|
|
1922
1935
|
}
|
|
1923
|
-
class
|
|
1936
|
+
class oe {
|
|
1924
1937
|
constructor(e, n) {
|
|
1925
1938
|
this.input = e, this.path = n;
|
|
1926
1939
|
}
|
|
@@ -1949,11 +1962,11 @@ class se {
|
|
|
1949
1962
|
if (this.matchWord("do"))
|
|
1950
1963
|
return this.parseDoWhile();
|
|
1951
1964
|
if (this.matchWord("while"))
|
|
1952
|
-
throw
|
|
1965
|
+
throw w(
|
|
1953
1966
|
this.path,
|
|
1954
1967
|
"bare while loops are not allowed (use do…while)"
|
|
1955
1968
|
);
|
|
1956
|
-
return this.parseSimpleStatement();
|
|
1969
|
+
return this.matchWord("echo") ? this.parseEcho() : this.parseSimpleStatement();
|
|
1957
1970
|
}
|
|
1958
1971
|
parseSimpleStatement() {
|
|
1959
1972
|
this.skipWhitespace();
|
|
@@ -1966,7 +1979,7 @@ class se {
|
|
|
1966
1979
|
return this.parseBindingDeclaration("let");
|
|
1967
1980
|
const n = this.readIdentifier();
|
|
1968
1981
|
if (!n)
|
|
1969
|
-
throw
|
|
1982
|
+
throw w(this.path, "expected statement");
|
|
1970
1983
|
if (this.assertAssignableName(n), this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
1971
1984
|
const s = this.input.slice(this.index - 2, this.index);
|
|
1972
1985
|
return { kind: "update", name: n, op: s, position: "postfix" };
|
|
@@ -1983,7 +1996,7 @@ class se {
|
|
|
1983
1996
|
}
|
|
1984
1997
|
if (this.match("=")) {
|
|
1985
1998
|
if (this.peek() === "=")
|
|
1986
|
-
throw
|
|
1999
|
+
throw w(this.path, "unexpected '==' in assignment");
|
|
1987
2000
|
const s = this.readExpressionSourceUntilTerminator();
|
|
1988
2001
|
return {
|
|
1989
2002
|
kind: "assign",
|
|
@@ -1991,13 +2004,21 @@ class se {
|
|
|
1991
2004
|
expr: C(s, this.path)
|
|
1992
2005
|
};
|
|
1993
2006
|
}
|
|
1994
|
-
throw
|
|
2007
|
+
throw w(this.path, `invalid statement starting with: ${n}`);
|
|
2008
|
+
}
|
|
2009
|
+
parseEcho() {
|
|
2010
|
+
this.skipWhitespace();
|
|
2011
|
+
const e = this.readExpressionSourceUntilTerminator();
|
|
2012
|
+
return {
|
|
2013
|
+
kind: "echo",
|
|
2014
|
+
expr: C(e, this.path)
|
|
2015
|
+
};
|
|
1995
2016
|
}
|
|
1996
2017
|
readPrefixUpdate() {
|
|
1997
2018
|
if (this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
1998
2019
|
const e = this.input.slice(this.index - 2, this.index), n = this.readIdentifier();
|
|
1999
2020
|
if (!n)
|
|
2000
|
-
throw
|
|
2021
|
+
throw w(this.path, `expected identifier after ${e}`);
|
|
2001
2022
|
return this.assertAssignableName(n), { kind: "update", name: n, op: e, position: "prefix" };
|
|
2002
2023
|
}
|
|
2003
2024
|
return null;
|
|
@@ -2005,9 +2026,9 @@ class se {
|
|
|
2005
2026
|
parseBindingDeclaration(e) {
|
|
2006
2027
|
const n = this.readIdentifier();
|
|
2007
2028
|
if (!n)
|
|
2008
|
-
throw
|
|
2029
|
+
throw w(this.path, `expected identifier after ${e}`);
|
|
2009
2030
|
if (this.assertAssignableName(n), this.skipWhitespace(), !this.match("="))
|
|
2010
|
-
throw
|
|
2031
|
+
throw w(this.path, `expected '=' in ${e} declaration`);
|
|
2011
2032
|
const r = this.readExpressionSourceUntilTerminator();
|
|
2012
2033
|
return {
|
|
2013
2034
|
kind: e,
|
|
@@ -2017,57 +2038,57 @@ class se {
|
|
|
2017
2038
|
}
|
|
2018
2039
|
parseFor() {
|
|
2019
2040
|
if (this.skipWhitespace(), !this.match("("))
|
|
2020
|
-
throw
|
|
2021
|
-
const e = this.readBalanced(")"), n =
|
|
2041
|
+
throw w(this.path, "expected '(' after for");
|
|
2042
|
+
const e = this.readBalanced(")"), n = $t(e);
|
|
2022
2043
|
if (n.length !== 3)
|
|
2023
|
-
throw
|
|
2044
|
+
throw w(
|
|
2024
2045
|
this.path,
|
|
2025
2046
|
"for…of / for…in are not allowed; use for (init; cond; update)"
|
|
2026
2047
|
);
|
|
2027
2048
|
const [r, s, i] = n;
|
|
2028
2049
|
if (s.trim().length === 0)
|
|
2029
|
-
throw
|
|
2050
|
+
throw w(this.path, "for loop condition cannot be empty");
|
|
2030
2051
|
if (/^\s*[A-Za-z_$][A-Za-z0-9_$]*\s+(of|in)\s+/.test(r))
|
|
2031
|
-
throw
|
|
2052
|
+
throw w(
|
|
2032
2053
|
this.path,
|
|
2033
2054
|
"for…of / for…in are not allowed; use for (init; cond; update)"
|
|
2034
2055
|
);
|
|
2035
2056
|
const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a = C(s.trim(), this.path), c = i.trim().length === 0 ? null : this.parseClauseStatement(i.trim());
|
|
2036
2057
|
if (this.skipWhitespace(), !this.match("{"))
|
|
2037
|
-
throw
|
|
2058
|
+
throw w(this.path, "expected '{' after for (...)");
|
|
2038
2059
|
const h = this.parseStatementList();
|
|
2039
2060
|
if (this.skipWhitespace(), !this.match("}"))
|
|
2040
|
-
throw
|
|
2061
|
+
throw w(this.path, "expected '}' to close for body");
|
|
2041
2062
|
return { kind: "for", init: o, cond: a, update: c, body: h };
|
|
2042
2063
|
}
|
|
2043
2064
|
parseDoWhile() {
|
|
2044
2065
|
if (this.skipWhitespace(), !this.match("{"))
|
|
2045
|
-
throw
|
|
2066
|
+
throw w(this.path, "expected '{' after do");
|
|
2046
2067
|
const e = this.parseStatementList();
|
|
2047
2068
|
if (this.skipWhitespace(), !this.match("}"))
|
|
2048
|
-
throw
|
|
2069
|
+
throw w(this.path, "expected '}' to close do body");
|
|
2049
2070
|
if (this.skipWhitespace(), !this.matchWord("while"))
|
|
2050
|
-
throw
|
|
2071
|
+
throw w(this.path, "expected 'while' after do body");
|
|
2051
2072
|
if (this.skipWhitespace(), !this.match("("))
|
|
2052
|
-
throw
|
|
2073
|
+
throw w(this.path, "expected '(' after while");
|
|
2053
2074
|
const n = this.readBalanced(")");
|
|
2054
2075
|
if (n.trim().length === 0)
|
|
2055
|
-
throw
|
|
2076
|
+
throw w(this.path, "do…while condition cannot be empty");
|
|
2056
2077
|
const r = C(n.trim(), this.path);
|
|
2057
2078
|
return { kind: "do_while", body: e, cond: r };
|
|
2058
2079
|
}
|
|
2059
2080
|
parseClauseStatement(e) {
|
|
2060
|
-
const n = new
|
|
2081
|
+
const n = new oe(e, this.path), r = n.parseSimpleStatement();
|
|
2061
2082
|
if (n.skipWhitespace(), n.hasMore())
|
|
2062
|
-
throw
|
|
2083
|
+
throw w(
|
|
2063
2084
|
this.path,
|
|
2064
2085
|
`unexpected token in for clause at position ${n.position}`
|
|
2065
2086
|
);
|
|
2066
2087
|
return r;
|
|
2067
2088
|
}
|
|
2068
2089
|
assertAssignableName(e) {
|
|
2069
|
-
if (
|
|
2070
|
-
throw
|
|
2090
|
+
if (De(e))
|
|
2091
|
+
throw w(
|
|
2071
2092
|
this.path,
|
|
2072
2093
|
`reserved word cannot be used as identifier: ${e}`
|
|
2073
2094
|
);
|
|
@@ -2102,7 +2123,7 @@ class se {
|
|
|
2102
2123
|
}
|
|
2103
2124
|
const o = this.input.slice(e, this.index).trim();
|
|
2104
2125
|
if (o.length === 0)
|
|
2105
|
-
throw
|
|
2126
|
+
throw w(this.path, "expected expression");
|
|
2106
2127
|
return o;
|
|
2107
2128
|
}
|
|
2108
2129
|
readBalanced(e) {
|
|
@@ -2138,7 +2159,7 @@ class se {
|
|
|
2138
2159
|
}
|
|
2139
2160
|
this.index++;
|
|
2140
2161
|
}
|
|
2141
|
-
throw
|
|
2162
|
+
throw w(this.path, `expected '${e}'`);
|
|
2142
2163
|
}
|
|
2143
2164
|
readCompoundOp() {
|
|
2144
2165
|
this.skipWhitespace();
|
|
@@ -2173,7 +2194,7 @@ class se {
|
|
|
2173
2194
|
return this.input.slice(e, this.index);
|
|
2174
2195
|
}
|
|
2175
2196
|
}
|
|
2176
|
-
function
|
|
2197
|
+
function $t(t) {
|
|
2177
2198
|
const e = [];
|
|
2178
2199
|
let n = "", r = 0, s = null;
|
|
2179
2200
|
for (let i = 0; i < t.length; i++) {
|
|
@@ -2206,7 +2227,7 @@ function Ct(t) {
|
|
|
2206
2227
|
}
|
|
2207
2228
|
return e.push(n), e;
|
|
2208
2229
|
}
|
|
2209
|
-
function
|
|
2230
|
+
function ae(t, e) {
|
|
2210
2231
|
const n = t.trim();
|
|
2211
2232
|
if (!/^extend\b/i.test(n)) return null;
|
|
2212
2233
|
if (!/^extend\s+/i.test(n))
|
|
@@ -2231,10 +2252,10 @@ function oe(t, e) {
|
|
|
2231
2252
|
});
|
|
2232
2253
|
return { path: s };
|
|
2233
2254
|
}
|
|
2234
|
-
function
|
|
2235
|
-
const n =
|
|
2255
|
+
function Et(t, e) {
|
|
2256
|
+
const n = A(t);
|
|
2236
2257
|
if (n.length === 0) return null;
|
|
2237
|
-
const r = n[0], s =
|
|
2258
|
+
const r = n[0], s = ae(r, e);
|
|
2238
2259
|
if (!s) return null;
|
|
2239
2260
|
for (const i of n.slice(1))
|
|
2240
2261
|
if (/^extend\s+/i.test(i))
|
|
@@ -2249,17 +2270,51 @@ function At(t, e) {
|
|
|
2249
2270
|
`)
|
|
2250
2271
|
};
|
|
2251
2272
|
}
|
|
2252
|
-
|
|
2273
|
+
function ce(t) {
|
|
2274
|
+
return /^toc(\(.*\))?$/.test(t.trim());
|
|
2275
|
+
}
|
|
2276
|
+
function Tt(t, e) {
|
|
2277
|
+
const n = A(t);
|
|
2278
|
+
if (n.length !== 1)
|
|
2279
|
+
throw u({
|
|
2280
|
+
code: "parse_error",
|
|
2281
|
+
path: e,
|
|
2282
|
+
details: {
|
|
2283
|
+
message: "toc directive must be a single line"
|
|
2284
|
+
}
|
|
2285
|
+
});
|
|
2286
|
+
const r = n[0];
|
|
2287
|
+
if (r === "toc")
|
|
2288
|
+
return { maxLevel: 6 };
|
|
2289
|
+
const s = /^toc\((.*)\)$/.exec(r);
|
|
2290
|
+
if (!s)
|
|
2291
|
+
throw u({
|
|
2292
|
+
code: "parse_error",
|
|
2293
|
+
path: e,
|
|
2294
|
+
details: { message: `invalid toc directive: ${r}` }
|
|
2295
|
+
});
|
|
2296
|
+
const i = s[1];
|
|
2297
|
+
if (!/^[1-6]$/.test(i))
|
|
2298
|
+
throw u({
|
|
2299
|
+
code: "parse_error",
|
|
2300
|
+
path: e,
|
|
2301
|
+
details: {
|
|
2302
|
+
message: `invalid toc max level: ${i || "(empty)"} (expected integer 1–6)`
|
|
2303
|
+
}
|
|
2304
|
+
});
|
|
2305
|
+
return { maxLevel: Number(i) };
|
|
2306
|
+
}
|
|
2307
|
+
async function Lt(t, e = {}) {
|
|
2253
2308
|
const n = e.path, r = e.context ?? {};
|
|
2254
|
-
if (
|
|
2309
|
+
if (Ae(t))
|
|
2255
2310
|
throw u({
|
|
2256
2311
|
code: "parse_error",
|
|
2257
2312
|
path: n,
|
|
2258
2313
|
details: {
|
|
2259
|
-
message:
|
|
2314
|
+
message: $e(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2260
2315
|
}
|
|
2261
2316
|
});
|
|
2262
|
-
const s =
|
|
2317
|
+
const s = E(t);
|
|
2263
2318
|
if (s.length === 0)
|
|
2264
2319
|
return { source: t, context: r, declarationUpdates: {} };
|
|
2265
2320
|
const i = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
|
|
@@ -2267,31 +2322,31 @@ async function Wt(t, e = {}) {
|
|
|
2267
2322
|
};
|
|
2268
2323
|
let c = t, h = 0;
|
|
2269
2324
|
for (const l of s) {
|
|
2270
|
-
const d =
|
|
2271
|
-
if (d.length === 1 &&
|
|
2325
|
+
const d = A(l.inner);
|
|
2326
|
+
if (d.length === 1 && Ee(d[0]) || d.length === 1 && ce(d[0]) || d.length === 1 && /^include\s+/i.test(d[0]) || d.length === 1 && /^component\s+/i.test(d[0]))
|
|
2272
2327
|
continue;
|
|
2273
|
-
const f =
|
|
2328
|
+
const f = Et(l.inner, n);
|
|
2274
2329
|
if (f) {
|
|
2275
2330
|
if (f.declarationsSource.trim().length > 0) {
|
|
2276
|
-
const
|
|
2331
|
+
const H = we(
|
|
2277
2332
|
f.declarationsSource,
|
|
2278
2333
|
n
|
|
2279
2334
|
);
|
|
2280
|
-
await
|
|
2335
|
+
await xe(H, r, {
|
|
2281
2336
|
path: n,
|
|
2282
2337
|
constBindings: i,
|
|
2283
2338
|
onUpdate: a
|
|
2284
2339
|
});
|
|
2285
2340
|
}
|
|
2286
|
-
const
|
|
2341
|
+
const S = l.start - h, L = l.end - h, j = `<!--@hg
|
|
2287
2342
|
extend ${f.path}
|
|
2288
2343
|
@endhg-->`;
|
|
2289
|
-
c = c.slice(0,
|
|
2344
|
+
c = c.slice(0, S) + j + c.slice(L), h += l.raw.length - j.length;
|
|
2290
2345
|
continue;
|
|
2291
2346
|
}
|
|
2292
2347
|
const g = d.join(`
|
|
2293
2348
|
`);
|
|
2294
|
-
if (!
|
|
2349
|
+
if (!He(g)) {
|
|
2295
2350
|
if (d.length === 1)
|
|
2296
2351
|
continue;
|
|
2297
2352
|
throw u({
|
|
@@ -2300,20 +2355,25 @@ extend ${f.path}
|
|
|
2300
2355
|
details: { message: `unsupported hyogen directive: ${d[0]}` }
|
|
2301
2356
|
});
|
|
2302
2357
|
}
|
|
2303
|
-
const m =
|
|
2304
|
-
await
|
|
2358
|
+
const m = we(g, n), p = [];
|
|
2359
|
+
await xe(m, r, {
|
|
2305
2360
|
path: n,
|
|
2306
2361
|
constBindings: i,
|
|
2307
|
-
onUpdate: a
|
|
2362
|
+
onUpdate: a,
|
|
2363
|
+
echoChunks: p
|
|
2308
2364
|
});
|
|
2309
|
-
const
|
|
2310
|
-
|
|
2365
|
+
const $ = l.start - h, D = l.end - h, b = c.slice(0, $), v = c.slice(D);
|
|
2366
|
+
if (p.length > 0) {
|
|
2367
|
+
const S = p.join("");
|
|
2368
|
+
c = b + S + v, h += l.raw.length - S.length;
|
|
2369
|
+
} else
|
|
2370
|
+
c = T(b, v), h += l.raw.length + ie(b, v);
|
|
2311
2371
|
}
|
|
2312
2372
|
return { source: c, context: r, declarationUpdates: o };
|
|
2313
2373
|
}
|
|
2314
|
-
const
|
|
2315
|
-
function
|
|
2316
|
-
const n =
|
|
2374
|
+
const Mt = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
|
|
2375
|
+
function Ot(t, e) {
|
|
2376
|
+
const n = ee(t).trim();
|
|
2317
2377
|
if (n.length === 0)
|
|
2318
2378
|
throw u({
|
|
2319
2379
|
code: "parse_error",
|
|
@@ -2336,7 +2396,7 @@ function Tt(t, e) {
|
|
|
2336
2396
|
path: e,
|
|
2337
2397
|
details: { message: "include and component cannot coexist in one block" }
|
|
2338
2398
|
});
|
|
2339
|
-
const i =
|
|
2399
|
+
const i = Mt.exec(s);
|
|
2340
2400
|
if (!i)
|
|
2341
2401
|
throw u({
|
|
2342
2402
|
code: "parse_error",
|
|
@@ -2356,8 +2416,8 @@ function Tt(t, e) {
|
|
|
2356
2416
|
alias: i[2]
|
|
2357
2417
|
};
|
|
2358
2418
|
}
|
|
2359
|
-
function
|
|
2360
|
-
const n =
|
|
2419
|
+
function Rt(t, e) {
|
|
2420
|
+
const n = ee(t).trim();
|
|
2361
2421
|
if (n.length === 0)
|
|
2362
2422
|
throw u({
|
|
2363
2423
|
code: "parse_error",
|
|
@@ -2380,19 +2440,19 @@ function Et(t, e) {
|
|
|
2380
2440
|
details: { message: `unsupported hyogen directive: ${s}` }
|
|
2381
2441
|
});
|
|
2382
2442
|
}
|
|
2383
|
-
function
|
|
2384
|
-
const e =
|
|
2443
|
+
function Dt(t) {
|
|
2444
|
+
const e = se(t).trim();
|
|
2385
2445
|
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
|
|
2386
2446
|
}
|
|
2387
|
-
const
|
|
2388
|
-
function
|
|
2389
|
-
return `${
|
|
2447
|
+
const Ht = "\0HYOGEN_INCLUDE_";
|
|
2448
|
+
function Nt(t) {
|
|
2449
|
+
return `${Ht}${t}\0`;
|
|
2390
2450
|
}
|
|
2391
|
-
function
|
|
2392
|
-
const n =
|
|
2393
|
-
if (n.length === 1 &&
|
|
2451
|
+
function Bt(t, e) {
|
|
2452
|
+
const n = A(t);
|
|
2453
|
+
if (n.length === 1 && Ee(n[0]))
|
|
2394
2454
|
return { kind: "control" };
|
|
2395
|
-
if (n.length === 1 && (
|
|
2455
|
+
if (n.length === 1 && ce(n[0]) || n.length === 1 && (Dt(n[0]) || He(n[0])))
|
|
2396
2456
|
return null;
|
|
2397
2457
|
if (n.length !== 1)
|
|
2398
2458
|
throw u({
|
|
@@ -2408,9 +2468,9 @@ function Ot(t, e) {
|
|
|
2408
2468
|
details: { message: "include and component cannot coexist in one block" }
|
|
2409
2469
|
});
|
|
2410
2470
|
if (/^include\s+/i.test(r))
|
|
2411
|
-
return
|
|
2471
|
+
return Rt(t, e);
|
|
2412
2472
|
if (/^component\s+/i.test(r))
|
|
2413
|
-
return
|
|
2473
|
+
return Ot(t, e);
|
|
2414
2474
|
if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
|
|
2415
2475
|
return null;
|
|
2416
2476
|
throw u({
|
|
@@ -2419,23 +2479,23 @@ function Ot(t, e) {
|
|
|
2419
2479
|
details: { message: `unsupported hyogen directive: ${r}` }
|
|
2420
2480
|
});
|
|
2421
2481
|
}
|
|
2422
|
-
function
|
|
2482
|
+
function jt(t, e = {}) {
|
|
2423
2483
|
const n = e.path;
|
|
2424
|
-
if (
|
|
2484
|
+
if (Ae(t))
|
|
2425
2485
|
throw u({
|
|
2426
2486
|
code: "parse_error",
|
|
2427
2487
|
path: n,
|
|
2428
2488
|
details: {
|
|
2429
|
-
message:
|
|
2489
|
+
message: $e(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2430
2490
|
}
|
|
2431
2491
|
});
|
|
2432
|
-
const r =
|
|
2492
|
+
const r = E(t);
|
|
2433
2493
|
if (r.length === 0)
|
|
2434
2494
|
return { source: t, directives: [] };
|
|
2435
2495
|
const s = [];
|
|
2436
2496
|
let i = t, o = 0, a = 0;
|
|
2437
2497
|
for (const c of r) {
|
|
2438
|
-
const h =
|
|
2498
|
+
const h = Bt(c.inner, n);
|
|
2439
2499
|
if (!h || h.kind === "control")
|
|
2440
2500
|
continue;
|
|
2441
2501
|
const l = c.start - o, d = c.end - o;
|
|
@@ -2450,38 +2510,38 @@ function Dt(t, e = {}) {
|
|
|
2450
2510
|
n
|
|
2451
2511
|
);
|
|
2452
2512
|
const g = i.slice(0, l), m = i.slice(d);
|
|
2453
|
-
i =
|
|
2513
|
+
i = T(g, m), o += c.raw.length + ie(g, m);
|
|
2454
2514
|
continue;
|
|
2455
2515
|
}
|
|
2456
|
-
const f =
|
|
2516
|
+
const f = Nt(a++);
|
|
2457
2517
|
s.push({ ...h, marker: f, raw: c.raw }), i = i.slice(0, l) + f + i.slice(d), o += c.raw.length - f.length;
|
|
2458
2518
|
}
|
|
2459
2519
|
return { source: i, directives: s };
|
|
2460
2520
|
}
|
|
2461
|
-
function
|
|
2521
|
+
function Ft(t, e) {
|
|
2462
2522
|
return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
|
|
2463
2523
|
` : `${e.rawFrontMatter}
|
|
2464
2524
|
${t}`;
|
|
2465
2525
|
}
|
|
2466
|
-
function
|
|
2526
|
+
function Pt(t, e = !1) {
|
|
2467
2527
|
if (e)
|
|
2468
2528
|
return t;
|
|
2469
|
-
const n =
|
|
2529
|
+
const n = E(t);
|
|
2470
2530
|
if (n.length === 0)
|
|
2471
2531
|
return t;
|
|
2472
2532
|
let r = t, s = 0;
|
|
2473
2533
|
for (const i of n) {
|
|
2474
2534
|
const o = i.start - s, a = i.end - s, c = r.slice(0, o), h = r.slice(a);
|
|
2475
|
-
r =
|
|
2535
|
+
r = T(c, h), s += i.raw.length + ie(c, h);
|
|
2476
2536
|
}
|
|
2477
2537
|
return r;
|
|
2478
2538
|
}
|
|
2479
|
-
const
|
|
2480
|
-
function
|
|
2539
|
+
const It = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
2540
|
+
function zt(t, e) {
|
|
2481
2541
|
const n = t.trim();
|
|
2482
2542
|
if (n === "endblock")
|
|
2483
2543
|
return { kind: "endblock" };
|
|
2484
|
-
const r =
|
|
2544
|
+
const r = It.exec(n);
|
|
2485
2545
|
if (!r)
|
|
2486
2546
|
throw u({
|
|
2487
2547
|
code: "parse_error",
|
|
@@ -2489,7 +2549,7 @@ function Ht(t, e) {
|
|
|
2489
2549
|
details: { message: "invalid block directive" }
|
|
2490
2550
|
});
|
|
2491
2551
|
const s = r[1];
|
|
2492
|
-
if (
|
|
2552
|
+
if (De(s))
|
|
2493
2553
|
throw u({
|
|
2494
2554
|
code: "parse_error",
|
|
2495
2555
|
path: e,
|
|
@@ -2497,12 +2557,12 @@ function Ht(t, e) {
|
|
|
2497
2557
|
});
|
|
2498
2558
|
return { kind: "block", name: s };
|
|
2499
2559
|
}
|
|
2500
|
-
function
|
|
2501
|
-
const { path: n, mode: r, hasExtend: s = !1 } = e, i =
|
|
2560
|
+
function ke(t, e) {
|
|
2561
|
+
const { path: n, mode: r, hasExtend: s = !1 } = e, i = E(t);
|
|
2502
2562
|
if (i.length === 0) return [];
|
|
2503
2563
|
const o = [], a = [], c = /* @__PURE__ */ new Set();
|
|
2504
2564
|
for (const h of i) {
|
|
2505
|
-
const l =
|
|
2565
|
+
const l = A(h.inner);
|
|
2506
2566
|
if (l.length !== 1) continue;
|
|
2507
2567
|
const d = l[0];
|
|
2508
2568
|
if (!(d === "endblock" || d.startsWith("block "))) continue;
|
|
@@ -2512,7 +2572,7 @@ function xe(t, e) {
|
|
|
2512
2572
|
path: n,
|
|
2513
2573
|
details: { message: "orphan block without extend" }
|
|
2514
2574
|
});
|
|
2515
|
-
const g =
|
|
2575
|
+
const g = zt(d, n);
|
|
2516
2576
|
if (g.kind === "endblock") {
|
|
2517
2577
|
const m = a.pop();
|
|
2518
2578
|
if (!m)
|
|
@@ -2556,20 +2616,20 @@ function xe(t, e) {
|
|
|
2556
2616
|
});
|
|
2557
2617
|
return o;
|
|
2558
2618
|
}
|
|
2559
|
-
function
|
|
2560
|
-
const e =
|
|
2619
|
+
function be(t) {
|
|
2620
|
+
const e = E(t), n = [];
|
|
2561
2621
|
for (const r of e) {
|
|
2562
|
-
const s =
|
|
2622
|
+
const s = A(r.inner);
|
|
2563
2623
|
if (s.length === 0) continue;
|
|
2564
|
-
const i =
|
|
2624
|
+
const i = ae(s[0]);
|
|
2565
2625
|
i && n.push({ path: i.path, start: r.start });
|
|
2566
2626
|
}
|
|
2567
2627
|
return n;
|
|
2568
2628
|
}
|
|
2569
|
-
function
|
|
2570
|
-
const e =
|
|
2629
|
+
function Ut(t) {
|
|
2630
|
+
const e = E(t);
|
|
2571
2631
|
for (const n of e) {
|
|
2572
|
-
const r =
|
|
2632
|
+
const r = A(n.inner);
|
|
2573
2633
|
if (r.length !== 1) continue;
|
|
2574
2634
|
const s = r[0];
|
|
2575
2635
|
if (s === "endblock" || s.startsWith("block ")) return !0;
|
|
@@ -2579,14 +2639,14 @@ function Pt(t) {
|
|
|
2579
2639
|
function K(t) {
|
|
2580
2640
|
return t.map((e) => e.body).join("");
|
|
2581
2641
|
}
|
|
2582
|
-
function
|
|
2642
|
+
function Zt(t, e, n) {
|
|
2583
2643
|
const r = [...e].sort((o, a) => o.start - a.start), s = [];
|
|
2584
2644
|
let i = 0;
|
|
2585
2645
|
for (const o of r)
|
|
2586
2646
|
s.push(t.slice(i, o.start)), s.push(n.get(o.name) ?? o.body), i = o.end;
|
|
2587
|
-
return s.push(t.slice(i)), s.reduce((o, a) =>
|
|
2647
|
+
return s.push(t.slice(i)), s.reduce((o, a) => T(o, a));
|
|
2588
2648
|
}
|
|
2589
|
-
function
|
|
2649
|
+
function qt(t) {
|
|
2590
2650
|
if (t instanceof Error && "code" in t && "details" in t) {
|
|
2591
2651
|
const e = t;
|
|
2592
2652
|
if (e.code === "file_not_found" && e.details && e.details.via === "include")
|
|
@@ -2594,7 +2654,7 @@ function It(t) {
|
|
|
2594
2654
|
}
|
|
2595
2655
|
return { errorToThrow: t, adjusted: !1 };
|
|
2596
2656
|
}
|
|
2597
|
-
async function
|
|
2657
|
+
async function Vt(t, e) {
|
|
2598
2658
|
const {
|
|
2599
2659
|
path: n,
|
|
2600
2660
|
context: r,
|
|
@@ -2605,9 +2665,9 @@ async function zt(t, e) {
|
|
|
2605
2665
|
visitStack: c,
|
|
2606
2666
|
warnings: h,
|
|
2607
2667
|
inComponent: l = !1
|
|
2608
|
-
} = e, d =
|
|
2668
|
+
} = e, d = be(t);
|
|
2609
2669
|
if (d.length === 0) {
|
|
2610
|
-
if (
|
|
2670
|
+
if (Ut(t))
|
|
2611
2671
|
throw u({
|
|
2612
2672
|
code: "parse_error",
|
|
2613
2673
|
path: n,
|
|
@@ -2615,13 +2675,13 @@ async function zt(t, e) {
|
|
|
2615
2675
|
});
|
|
2616
2676
|
return { source: t, context: _(r, s) };
|
|
2617
2677
|
}
|
|
2618
|
-
const g =
|
|
2678
|
+
const g = E(t)[0];
|
|
2619
2679
|
if (!g)
|
|
2620
2680
|
return { source: t, context: _(r, s) };
|
|
2621
2681
|
if (!i)
|
|
2622
2682
|
throw new Error("loader is required when processing extend directives");
|
|
2623
|
-
const m =
|
|
2624
|
-
if (!(m.length > 0 ?
|
|
2683
|
+
const m = A(g.inner);
|
|
2684
|
+
if (!(m.length > 0 ? ae(m[0]) : null))
|
|
2625
2685
|
throw u({
|
|
2626
2686
|
code: "parse_error",
|
|
2627
2687
|
path: n,
|
|
@@ -2633,7 +2693,7 @@ async function zt(t, e) {
|
|
|
2633
2693
|
path: n,
|
|
2634
2694
|
details: { message: "multiple extend directives are not supported" }
|
|
2635
2695
|
});
|
|
2636
|
-
const
|
|
2696
|
+
const $ = ke(t, {
|
|
2637
2697
|
path: n,
|
|
2638
2698
|
mode: "child",
|
|
2639
2699
|
hasExtend: !0
|
|
@@ -2641,16 +2701,16 @@ async function zt(t, e) {
|
|
|
2641
2701
|
if (l)
|
|
2642
2702
|
return h?.push({
|
|
2643
2703
|
code: "extend_in_component",
|
|
2644
|
-
message:
|
|
2704
|
+
message: R("extend_in_component", { path: n }),
|
|
2645
2705
|
path: n,
|
|
2646
2706
|
details: { path: n }
|
|
2647
2707
|
}), {
|
|
2648
|
-
source: K(
|
|
2708
|
+
source: K($),
|
|
2649
2709
|
context: _(r, s)
|
|
2650
2710
|
};
|
|
2651
|
-
const
|
|
2711
|
+
const D = d[0].path, b = n, v = Y(
|
|
2652
2712
|
o,
|
|
2653
|
-
|
|
2713
|
+
D,
|
|
2654
2714
|
n,
|
|
2655
2715
|
n,
|
|
2656
2716
|
a,
|
|
@@ -2658,34 +2718,34 @@ async function zt(t, e) {
|
|
|
2658
2718
|
);
|
|
2659
2719
|
b && c.push(b);
|
|
2660
2720
|
try {
|
|
2661
|
-
const
|
|
2662
|
-
if (
|
|
2721
|
+
const S = b ? c.check(v) : { circular: !1 };
|
|
2722
|
+
if (S.circular)
|
|
2663
2723
|
return h?.push({
|
|
2664
2724
|
code: "circular_include",
|
|
2665
|
-
message:
|
|
2725
|
+
message: R("circular_include", {
|
|
2666
2726
|
path: v,
|
|
2667
|
-
from:
|
|
2727
|
+
from: S.from,
|
|
2668
2728
|
via: "extend"
|
|
2669
2729
|
}),
|
|
2670
2730
|
path: n,
|
|
2671
|
-
details: { path: v, from:
|
|
2731
|
+
details: { path: v, from: S.from, via: "extend" }
|
|
2672
2732
|
}), {
|
|
2673
|
-
source: K(
|
|
2733
|
+
source: K($),
|
|
2674
2734
|
context: _(r, s)
|
|
2675
2735
|
};
|
|
2676
2736
|
c.push(v);
|
|
2677
2737
|
try {
|
|
2678
|
-
const
|
|
2679
|
-
if (
|
|
2738
|
+
const L = await i(v);
|
|
2739
|
+
if (L === void 0)
|
|
2680
2740
|
throw new Error("loader returned undefined");
|
|
2681
|
-
const { context:
|
|
2682
|
-
|
|
2741
|
+
const { context: j, body: H } = P(
|
|
2742
|
+
L,
|
|
2683
2743
|
v
|
|
2684
|
-
),
|
|
2685
|
-
if (
|
|
2686
|
-
const
|
|
2744
|
+
), he = be(H);
|
|
2745
|
+
if (he.length > 0) {
|
|
2746
|
+
const F = he[0].path, I = Y(
|
|
2687
2747
|
o,
|
|
2688
|
-
|
|
2748
|
+
F,
|
|
2689
2749
|
v,
|
|
2690
2750
|
v,
|
|
2691
2751
|
a,
|
|
@@ -2694,7 +2754,7 @@ async function zt(t, e) {
|
|
|
2694
2754
|
if (z.circular)
|
|
2695
2755
|
return h?.push({
|
|
2696
2756
|
code: "circular_include",
|
|
2697
|
-
message:
|
|
2757
|
+
message: R("circular_include", {
|
|
2698
2758
|
path: I,
|
|
2699
2759
|
from: z.from,
|
|
2700
2760
|
via: "extend"
|
|
@@ -2702,7 +2762,7 @@ async function zt(t, e) {
|
|
|
2702
2762
|
path: n,
|
|
2703
2763
|
details: { path: I, from: z.from, via: "extend" }
|
|
2704
2764
|
}), {
|
|
2705
|
-
source: K(
|
|
2765
|
+
source: K($),
|
|
2706
2766
|
context: _(r, s)
|
|
2707
2767
|
};
|
|
2708
2768
|
throw u({
|
|
@@ -2711,32 +2771,32 @@ async function zt(t, e) {
|
|
|
2711
2771
|
details: { message: "layout extend is not supported" }
|
|
2712
2772
|
});
|
|
2713
2773
|
}
|
|
2714
|
-
const
|
|
2774
|
+
const Ne = ke(H, {
|
|
2715
2775
|
path: v,
|
|
2716
2776
|
mode: "layout"
|
|
2717
|
-
}),
|
|
2718
|
-
|
|
2719
|
-
), je =
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
),
|
|
2777
|
+
}), Be = new Map(
|
|
2778
|
+
$.map((F) => [F.name, F.body])
|
|
2779
|
+
), je = Zt(
|
|
2780
|
+
H,
|
|
2781
|
+
Ne,
|
|
2782
|
+
Be
|
|
2783
|
+
), Fe = _(
|
|
2724
2784
|
r,
|
|
2725
|
-
|
|
2785
|
+
j,
|
|
2726
2786
|
s
|
|
2727
2787
|
);
|
|
2728
|
-
return { source: je, context:
|
|
2788
|
+
return { source: je, context: Fe };
|
|
2729
2789
|
} finally {
|
|
2730
2790
|
c.pop();
|
|
2731
2791
|
}
|
|
2732
|
-
} catch (
|
|
2733
|
-
const
|
|
2734
|
-
throw
|
|
2792
|
+
} catch (S) {
|
|
2793
|
+
const L = qt(S);
|
|
2794
|
+
throw L.adjusted ? L.errorToThrow : S;
|
|
2735
2795
|
} finally {
|
|
2736
2796
|
b && c.pop();
|
|
2737
2797
|
}
|
|
2738
2798
|
}
|
|
2739
|
-
const
|
|
2799
|
+
const Kt = J.warningReasons, Yt = [
|
|
2740
2800
|
{
|
|
2741
2801
|
reason: "contains_html_script_tag",
|
|
2742
2802
|
test: (t) => /<\/?script\b/i.test(t)
|
|
@@ -2758,17 +2818,17 @@ const Ut = J.warningReasons, Zt = [
|
|
|
2758
2818
|
test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
|
|
2759
2819
|
}
|
|
2760
2820
|
];
|
|
2761
|
-
function
|
|
2762
|
-
return
|
|
2821
|
+
function Xt(t) {
|
|
2822
|
+
return Kt[t] ?? t;
|
|
2763
2823
|
}
|
|
2764
|
-
function
|
|
2824
|
+
function X(t, e, n, r) {
|
|
2765
2825
|
if (typeof t == "string") {
|
|
2766
|
-
for (const s of
|
|
2826
|
+
for (const s of Yt)
|
|
2767
2827
|
s.test(t) && n.push({
|
|
2768
2828
|
code: "suspicious_context_value",
|
|
2769
|
-
message:
|
|
2829
|
+
message: R("suspicious_context_value", {
|
|
2770
2830
|
key: e,
|
|
2771
|
-
reason:
|
|
2831
|
+
reason: Xt(s.reason)
|
|
2772
2832
|
}),
|
|
2773
2833
|
path: r,
|
|
2774
2834
|
details: { key: e, reason: s.reason }
|
|
@@ -2778,7 +2838,7 @@ function G(t, e, n, r) {
|
|
|
2778
2838
|
if (t != null) {
|
|
2779
2839
|
if (Array.isArray(t)) {
|
|
2780
2840
|
for (let s = 0; s < t.length; s++)
|
|
2781
|
-
|
|
2841
|
+
X(t[s], `${e}[${s}]`, n, r);
|
|
2782
2842
|
return;
|
|
2783
2843
|
}
|
|
2784
2844
|
if (typeof t == "object")
|
|
@@ -2786,25 +2846,180 @@ function G(t, e, n, r) {
|
|
|
2786
2846
|
t
|
|
2787
2847
|
)) {
|
|
2788
2848
|
const o = e.length > 0 ? `${e}.${s}` : s;
|
|
2789
|
-
|
|
2849
|
+
X(i, o, n, r);
|
|
2790
2850
|
}
|
|
2791
2851
|
}
|
|
2792
2852
|
}
|
|
2793
|
-
function
|
|
2853
|
+
function Gt(t, e, n) {
|
|
2794
2854
|
for (const [r, s] of Object.entries(t))
|
|
2795
|
-
|
|
2855
|
+
X(s, r, e, n);
|
|
2856
|
+
}
|
|
2857
|
+
const Jt = /^=+[ \t]*$/, Qt = /^-+[ \t]*$/, en = /^(```|~~~)/, tn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
|
|
2858
|
+
function G(t) {
|
|
2859
|
+
const e = tn.exec(t);
|
|
2860
|
+
return e && e.index !== void 0 ? {
|
|
2861
|
+
text: t.slice(0, e.index).trim(),
|
|
2862
|
+
explicitId: e[1]
|
|
2863
|
+
} : { text: t.trim() };
|
|
2864
|
+
}
|
|
2865
|
+
function nn(t) {
|
|
2866
|
+
let e = 0;
|
|
2867
|
+
for (; e < t.length && e < 6 && t[e] === "#"; )
|
|
2868
|
+
e += 1;
|
|
2869
|
+
if (e === 0 || e === 6 && e < t.length && t[e] === "#" || e >= t.length || t[e] !== " " && t[e] !== " ")
|
|
2870
|
+
return null;
|
|
2871
|
+
let n = e;
|
|
2872
|
+
for (; n < t.length && (t[n] === " " || t[n] === " "); )
|
|
2873
|
+
n += 1;
|
|
2874
|
+
if (n >= t.length)
|
|
2875
|
+
return null;
|
|
2876
|
+
let r = t.length;
|
|
2877
|
+
for (; r > n && (t[r - 1] === " " || t[r - 1] === " "); )
|
|
2878
|
+
r -= 1;
|
|
2879
|
+
let s = r;
|
|
2880
|
+
if (r > n && t[r - 1] === "#") {
|
|
2881
|
+
let o = r - 1;
|
|
2882
|
+
for (; o > n && t[o - 1] === "#"; )
|
|
2883
|
+
o -= 1;
|
|
2884
|
+
if (o > n && (t[o - 1] === " " || t[o - 1] === " ")) {
|
|
2885
|
+
let a = o - 1;
|
|
2886
|
+
for (; a >= n && (t[a] === " " || t[a] === " "); )
|
|
2887
|
+
a -= 1;
|
|
2888
|
+
s = a + 1;
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
if (s <= n)
|
|
2892
|
+
return null;
|
|
2893
|
+
const i = G(t.slice(n, s));
|
|
2894
|
+
return { level: e, ...i };
|
|
2895
|
+
}
|
|
2896
|
+
function ve(t, e, n) {
|
|
2897
|
+
let r = n;
|
|
2898
|
+
for (; r < t.length; ) {
|
|
2899
|
+
if (!e.inHtmlComment) {
|
|
2900
|
+
const i = t.indexOf("<!--", r);
|
|
2901
|
+
if (i === -1)
|
|
2902
|
+
return;
|
|
2903
|
+
e.inHtmlComment = !0, r = i + 4;
|
|
2904
|
+
continue;
|
|
2905
|
+
}
|
|
2906
|
+
const s = t.indexOf("-->", r);
|
|
2907
|
+
if (s === -1)
|
|
2908
|
+
return;
|
|
2909
|
+
e.inHtmlComment = !1, r = s + 3;
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
function rn(t, e) {
|
|
2913
|
+
if (e.inFence || e.inHtmlComment)
|
|
2914
|
+
return !0;
|
|
2915
|
+
const n = t.trim();
|
|
2916
|
+
return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
|
|
2917
|
+
}
|
|
2918
|
+
function sn(t) {
|
|
2919
|
+
const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
|
|
2920
|
+
for (let s = 0; s < e.length; s++) {
|
|
2921
|
+
const i = e[s];
|
|
2922
|
+
if (r.inFence) {
|
|
2923
|
+
const l = i.trim();
|
|
2924
|
+
l.startsWith(r.inFence.marker) && /^(`{3,}|~{3,})\s*$/.test(l) && (r.inFence = !1);
|
|
2925
|
+
continue;
|
|
2926
|
+
}
|
|
2927
|
+
if (r.inHtmlComment) {
|
|
2928
|
+
ve(i, r, 0);
|
|
2929
|
+
continue;
|
|
2930
|
+
}
|
|
2931
|
+
const o = en.exec(i.trimStart());
|
|
2932
|
+
if (o) {
|
|
2933
|
+
const l = o[1];
|
|
2934
|
+
i.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
|
|
2935
|
+
continue;
|
|
2936
|
+
}
|
|
2937
|
+
if (i.trim().startsWith("<!--")) {
|
|
2938
|
+
ve(i, r, i.indexOf("<!--"));
|
|
2939
|
+
continue;
|
|
2940
|
+
}
|
|
2941
|
+
if (rn(i, r))
|
|
2942
|
+
continue;
|
|
2943
|
+
const c = nn(i);
|
|
2944
|
+
if (c) {
|
|
2945
|
+
n.push(c);
|
|
2946
|
+
continue;
|
|
2947
|
+
}
|
|
2948
|
+
const h = e[s + 1];
|
|
2949
|
+
if (h !== void 0 && i.trim().length > 0 && !i.trimStart().startsWith("#") && !i.trimStart().startsWith(">") && !i.trimStart().startsWith("|")) {
|
|
2950
|
+
if (Jt.test(h)) {
|
|
2951
|
+
const l = G(i.trim());
|
|
2952
|
+
n.push({ level: 1, ...l }), s += 1;
|
|
2953
|
+
continue;
|
|
2954
|
+
}
|
|
2955
|
+
if (Qt.test(h) && h.trim().length >= 1) {
|
|
2956
|
+
const l = G(i.trim());
|
|
2957
|
+
n.push({ level: 2, ...l }), s += 1;
|
|
2958
|
+
continue;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
return n;
|
|
2963
|
+
}
|
|
2964
|
+
const on = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
|
|
2965
|
+
function an() {
|
|
2966
|
+
const t = /* @__PURE__ */ new Map();
|
|
2967
|
+
return {
|
|
2968
|
+
slug(e, n) {
|
|
2969
|
+
const r = n !== void 0 && n.length > 0 ? n : cn(e), s = t.get(r) ?? 0;
|
|
2970
|
+
return t.set(r, s + 1), s === 0 ? r : `${r}-${s}`;
|
|
2971
|
+
}
|
|
2972
|
+
};
|
|
2973
|
+
}
|
|
2974
|
+
function cn(t) {
|
|
2975
|
+
return t.toLowerCase().replace(on, "").replace(/\s+/g, "-");
|
|
2976
|
+
}
|
|
2977
|
+
function ln(t) {
|
|
2978
|
+
let e = t.trim();
|
|
2979
|
+
e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
|
|
2980
|
+
for (let n = 0; n < 3; n++)
|
|
2981
|
+
e = e.replace(/\*\*([^*]+)\*\*/g, "$1"), e = e.replace(/__([^_]+)__/g, "$1"), e = e.replace(/~~([^~]+)~~/g, "$1"), e = e.replace(/\*([^*]+)\*/g, "$1"), e = e.replace(/_([^_]+)_/g, "$1"), e = e.replace(/`([^`]+)`/g, "$1");
|
|
2982
|
+
return e.trim();
|
|
2983
|
+
}
|
|
2984
|
+
function hn(t, e) {
|
|
2985
|
+
if (t.length === 0)
|
|
2986
|
+
return "";
|
|
2987
|
+
const n = an(), s = t.map((o) => {
|
|
2988
|
+
const a = ln(o.text), c = n.slug(a, o.explicitId);
|
|
2989
|
+
return { level: o.level, text: a, anchor: c };
|
|
2990
|
+
}).filter((o) => o.level <= e);
|
|
2991
|
+
if (s.length === 0)
|
|
2992
|
+
return "";
|
|
2993
|
+
const i = Math.min(...s.map((o) => o.level));
|
|
2994
|
+
return s.map((o) => `${" ".repeat((o.level - i) * 2)}- [${o.text}](#${o.anchor})`).join(`
|
|
2995
|
+
`);
|
|
2996
|
+
}
|
|
2997
|
+
function dn(t, e = {}) {
|
|
2998
|
+
const r = E(t).filter((o) => {
|
|
2999
|
+
const a = A(o.inner);
|
|
3000
|
+
return a.length === 1 && ce(a[0]);
|
|
3001
|
+
});
|
|
3002
|
+
if (r.length === 0)
|
|
3003
|
+
return t;
|
|
3004
|
+
const s = sn(t);
|
|
3005
|
+
let i = t;
|
|
3006
|
+
for (let o = r.length - 1; o >= 0; o--) {
|
|
3007
|
+
const a = r[o], { maxLevel: c } = Tt(a.inner, e.path), h = hn(s, c), l = i.slice(0, a.start), d = i.slice(a.end);
|
|
3008
|
+
i = T(T(l, h), d);
|
|
3009
|
+
}
|
|
3010
|
+
return i;
|
|
2796
3011
|
}
|
|
2797
|
-
async function
|
|
2798
|
-
const n = e.path, r = e.context, s = e.registry ?? new
|
|
3012
|
+
async function le(t, e) {
|
|
3013
|
+
const n = e.path, r = e.context, s = e.registry ?? new _e(), i = e.warnings ?? [], o = e.visitStack ?? new Re(), {
|
|
2799
3014
|
source: a,
|
|
2800
3015
|
declarationUpdates: c
|
|
2801
|
-
} = await
|
|
2802
|
-
|
|
3016
|
+
} = await Lt(t, { path: n, context: { ...r } });
|
|
3017
|
+
Gt(
|
|
2803
3018
|
_(r, c ?? {}),
|
|
2804
3019
|
i,
|
|
2805
3020
|
n
|
|
2806
3021
|
);
|
|
2807
|
-
const h = await
|
|
3022
|
+
const h = await Vt(a, {
|
|
2808
3023
|
path: n,
|
|
2809
3024
|
context: r,
|
|
2810
3025
|
declarationUpdates: c ?? {},
|
|
@@ -2814,7 +3029,7 @@ async function ae(t, e) {
|
|
|
2814
3029
|
visitStack: o,
|
|
2815
3030
|
warnings: i,
|
|
2816
3031
|
inComponent: e.inComponent ?? !1
|
|
2817
|
-
}), { source: l, context: d } = h, { source: f, directives: g } =
|
|
3032
|
+
}), { source: l, context: d } = h, { source: f, directives: g } = jt(l, {
|
|
2818
3033
|
path: n,
|
|
2819
3034
|
registry: s,
|
|
2820
3035
|
context: d
|
|
@@ -2822,7 +3037,7 @@ async function ae(t, e) {
|
|
|
2822
3037
|
if (g.length > 0 && !m)
|
|
2823
3038
|
throw new Error("loader is required when processing include directives");
|
|
2824
3039
|
let p = f;
|
|
2825
|
-
return g.length > 0 && m && (p = await
|
|
3040
|
+
return g.length > 0 && m && (p = await Ct({
|
|
2826
3041
|
source: f,
|
|
2827
3042
|
directives: g,
|
|
2828
3043
|
context: d,
|
|
@@ -2835,7 +3050,7 @@ async function ae(t, e) {
|
|
|
2835
3050
|
warnings: i,
|
|
2836
3051
|
registry: s,
|
|
2837
3052
|
constrainToRoot: e.constrainToRoot
|
|
2838
|
-
})), p = await
|
|
3053
|
+
})), p = await vt(p, {
|
|
2839
3054
|
context: d,
|
|
2840
3055
|
path: n,
|
|
2841
3056
|
registry: s,
|
|
@@ -2846,7 +3061,7 @@ async function ae(t, e) {
|
|
|
2846
3061
|
parentContext: d,
|
|
2847
3062
|
preserveHgComments: e.preserveHgComments,
|
|
2848
3063
|
constrainToRoot: e.constrainToRoot
|
|
2849
|
-
}), p = await
|
|
3064
|
+
}), p = await We(p, d, {
|
|
2850
3065
|
path: n,
|
|
2851
3066
|
registry: s,
|
|
2852
3067
|
loader: m,
|
|
@@ -2856,21 +3071,21 @@ async function ae(t, e) {
|
|
|
2856
3071
|
parentContext: d,
|
|
2857
3072
|
preserveHgComments: e.preserveHgComments,
|
|
2858
3073
|
constrainToRoot: e.constrainToRoot
|
|
2859
|
-
}), p =
|
|
3074
|
+
}), p = dn(p, { path: n }), p = Pt(p, e.preserveHgComments), p;
|
|
2860
3075
|
}
|
|
2861
|
-
async function
|
|
2862
|
-
const n = e.path, r = _(e.context), s = e.registry ?? new
|
|
3076
|
+
async function un(t, e = {}) {
|
|
3077
|
+
const n = e.path, r = _(e.context), s = e.registry ?? new _e(), i = e.warnings ?? [], o = e.visitStack ?? new Re(), { context: a, body: c, rawFrontMatter: h } = P(
|
|
2863
3078
|
t,
|
|
2864
3079
|
n
|
|
2865
3080
|
), l = _(r, a);
|
|
2866
|
-
let d = await
|
|
3081
|
+
let d = await le(c, {
|
|
2867
3082
|
...e,
|
|
2868
3083
|
context: l,
|
|
2869
3084
|
registry: s,
|
|
2870
3085
|
warnings: i,
|
|
2871
3086
|
visitStack: o
|
|
2872
3087
|
});
|
|
2873
|
-
return d =
|
|
3088
|
+
return d = Ft(d, {
|
|
2874
3089
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
2875
3090
|
rawFrontMatter: h
|
|
2876
3091
|
}), {
|
|
@@ -2878,15 +3093,15 @@ async function Kt(t, e = {}) {
|
|
|
2878
3093
|
warnings: i
|
|
2879
3094
|
};
|
|
2880
3095
|
}
|
|
2881
|
-
async function
|
|
2882
|
-
const n = e.path, { context: r, body: s } =
|
|
2883
|
-
return
|
|
3096
|
+
async function fn(t, e) {
|
|
3097
|
+
const n = e.path, { context: r, body: s } = P(t, n), i = _(e.context, r);
|
|
3098
|
+
return le(s, {
|
|
2884
3099
|
...e,
|
|
2885
3100
|
context: i,
|
|
2886
3101
|
preserveFrontMatter: !1
|
|
2887
3102
|
});
|
|
2888
3103
|
}
|
|
2889
|
-
async function
|
|
3104
|
+
async function mn(t, e, n) {
|
|
2890
3105
|
if (n != null && "serverContext" in n && n.serverContext != null)
|
|
2891
3106
|
throw u({
|
|
2892
3107
|
code: "server_context_on_client"
|
|
@@ -2904,7 +3119,7 @@ async function Jt(t, e, n) {
|
|
|
2904
3119
|
let s, i;
|
|
2905
3120
|
typeof t == "string" ? s = t : (i = t.path, s = await r(t.path));
|
|
2906
3121
|
const o = _(e);
|
|
2907
|
-
return
|
|
3122
|
+
return un(s, {
|
|
2908
3123
|
context: o,
|
|
2909
3124
|
loader: r,
|
|
2910
3125
|
root: n?.root,
|
|
@@ -2914,7 +3129,7 @@ async function Jt(t, e, n) {
|
|
|
2914
3129
|
constrainToRoot: n?.constrainToRoot
|
|
2915
3130
|
});
|
|
2916
3131
|
}
|
|
2917
|
-
function
|
|
3132
|
+
function gn(t, e) {
|
|
2918
3133
|
const n = [`[hyogen:${t}] ${e.code}`], r = {};
|
|
2919
3134
|
if (e.details)
|
|
2920
3135
|
for (const [s, i] of Object.entries(e.details))
|
|
@@ -2927,8 +3142,8 @@ function Xt(t, e) {
|
|
|
2927
3142
|
}
|
|
2928
3143
|
export {
|
|
2929
3144
|
u as createHyogenError,
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
3145
|
+
gn as formatDiagnosticLog,
|
|
3146
|
+
Ve as formatMessage,
|
|
3147
|
+
mn as renderClient
|
|
2933
3148
|
};
|
|
2934
3149
|
//# sourceMappingURL=client.js.map
|