@b4moss/hyogen-md 0.13.0 → 0.14.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 +2 -2
- package/README_ja.md +2 -2
- package/dist/cli.js +161 -6
- package/dist/client.js +517 -403
- package/dist/expr/interpolateFenceExpressions.d.ts +8 -0
- package/dist/index.js +585 -471
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { stat as se, readFile as
|
|
2
|
-
import { c as d, f as H, m as
|
|
3
|
-
import { a as
|
|
1
|
+
import { stat as se, readFile as Me, mkdir as ct, writeFile as lt } from "node:fs/promises";
|
|
2
|
+
import { c as d, f as H, m as ht } from "./createError-WZmAl05N.js";
|
|
3
|
+
import { a as yr } from "./createError-WZmAl05N.js";
|
|
4
4
|
import f from "node:path";
|
|
5
|
-
import { parse as
|
|
6
|
-
import { Readable as
|
|
7
|
-
import
|
|
8
|
-
import { existsSync as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
5
|
+
import { parse as He } from "yaml";
|
|
6
|
+
import { Readable as dt } from "node:stream";
|
|
7
|
+
import ut from "csv-parser";
|
|
8
|
+
import { existsSync as be, statSync as ft } from "node:fs";
|
|
9
|
+
import pt from "fast-glob";
|
|
10
|
+
import mt from "picomatch";
|
|
11
11
|
function v(...t) {
|
|
12
12
|
const e = {};
|
|
13
13
|
for (const n of t)
|
|
14
14
|
n != null && Object.assign(e, n);
|
|
15
15
|
return e;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function gt(t) {
|
|
18
18
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function De(t = {}) {
|
|
21
21
|
const { from: e, via: n = "include" } = t;
|
|
22
22
|
return async (r) => {
|
|
23
23
|
try {
|
|
@@ -30,9 +30,9 @@ function Me(t = {}) {
|
|
|
30
30
|
reason: "not a file"
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
return await
|
|
33
|
+
return await Me(r, "utf8");
|
|
34
34
|
} catch (i) {
|
|
35
|
-
if (
|
|
35
|
+
if (gt(i))
|
|
36
36
|
throw i;
|
|
37
37
|
const s = i;
|
|
38
38
|
throw s.code === "ENOENT" ? d({
|
|
@@ -54,16 +54,16 @@ function Me(t = {}) {
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function D(t) {
|
|
58
58
|
return /^https?:\/\//i.test(t);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function wt(t) {
|
|
61
61
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
const { from: e, via: n = "include" } = t, r =
|
|
63
|
+
function Ne(t = {}) {
|
|
64
|
+
const { from: e, via: n = "include" } = t, r = De(t);
|
|
65
65
|
return async (i) => {
|
|
66
|
-
if (!
|
|
66
|
+
if (!D(i))
|
|
67
67
|
return r(i);
|
|
68
68
|
let s;
|
|
69
69
|
try {
|
|
@@ -108,7 +108,7 @@ function He(t = {}) {
|
|
|
108
108
|
});
|
|
109
109
|
return await o.text();
|
|
110
110
|
} catch (o) {
|
|
111
|
-
if (
|
|
111
|
+
if (wt(o))
|
|
112
112
|
throw o;
|
|
113
113
|
const a = o instanceof Error ? o.message : "unknown fetch error";
|
|
114
114
|
throw d({
|
|
@@ -122,25 +122,25 @@ function He(t = {}) {
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function xt(t) {
|
|
126
126
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function kt(t) {
|
|
129
129
|
return Object.keys(t).sort((e, n) => Number(e) - Number(n)).map((e) => t[e] ?? "");
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function yt(t) {
|
|
132
132
|
return t.every((e) => e === "");
|
|
133
133
|
}
|
|
134
|
-
async function
|
|
134
|
+
async function bt(t) {
|
|
135
135
|
return new Promise((e, n) => {
|
|
136
136
|
const r = [];
|
|
137
|
-
|
|
138
|
-
const s =
|
|
139
|
-
|
|
137
|
+
dt.from([t]).pipe(ut({ headers: !1 })).on("data", (i) => {
|
|
138
|
+
const s = kt(i);
|
|
139
|
+
yt(s) || r.push(s);
|
|
140
140
|
}).on("end", () => e(r)).on("error", (i) => n(i));
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
async function
|
|
143
|
+
async function vt(t, e) {
|
|
144
144
|
if (t.length === 0 || t.trim().length === 0)
|
|
145
145
|
throw d({
|
|
146
146
|
code: "parse_error",
|
|
@@ -149,9 +149,9 @@ async function bt(t, e) {
|
|
|
149
149
|
});
|
|
150
150
|
let n;
|
|
151
151
|
try {
|
|
152
|
-
n = await
|
|
152
|
+
n = await bt(t);
|
|
153
153
|
} catch (o) {
|
|
154
|
-
throw
|
|
154
|
+
throw xt(o) ? o : d({
|
|
155
155
|
code: "parse_error",
|
|
156
156
|
path: e,
|
|
157
157
|
details: {
|
|
@@ -180,10 +180,10 @@ async function bt(t, e) {
|
|
|
180
180
|
return a;
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function _t(t) {
|
|
184
184
|
return f.extname(t).slice(1).toLowerCase();
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function St(t, e) {
|
|
187
187
|
if (t.length === 0)
|
|
188
188
|
throw d({
|
|
189
189
|
code: "parse_error",
|
|
@@ -191,9 +191,9 @@ function _t(t, e) {
|
|
|
191
191
|
details: { message: "empty data file" }
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
-
async function
|
|
195
|
-
|
|
196
|
-
const n =
|
|
194
|
+
async function Et(t, e) {
|
|
195
|
+
St(t, e);
|
|
196
|
+
const n = _t(e);
|
|
197
197
|
switch (n) {
|
|
198
198
|
case "json":
|
|
199
199
|
try {
|
|
@@ -210,7 +210,7 @@ async function St(t, e) {
|
|
|
210
210
|
case "yaml":
|
|
211
211
|
case "yml":
|
|
212
212
|
try {
|
|
213
|
-
return
|
|
213
|
+
return He(t);
|
|
214
214
|
} catch (r) {
|
|
215
215
|
throw d({
|
|
216
216
|
code: "parse_error",
|
|
@@ -221,7 +221,7 @@ async function St(t, e) {
|
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
223
|
case "csv":
|
|
224
|
-
return
|
|
224
|
+
return vt(t, e);
|
|
225
225
|
default:
|
|
226
226
|
throw d({
|
|
227
227
|
code: "parse_error",
|
|
@@ -233,12 +233,12 @@ async function St(t, e) {
|
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
const
|
|
236
|
+
const Ct = ".doc_root";
|
|
237
237
|
function I(t) {
|
|
238
238
|
let e;
|
|
239
|
-
for (
|
|
240
|
-
const n = f.join(e,
|
|
241
|
-
if (
|
|
239
|
+
for (be(t) ? e = ft(t).isFile() ? f.dirname(t) : f.resolve(t) : e = f.dirname(f.resolve(t)); ; ) {
|
|
240
|
+
const n = f.join(e, Ct);
|
|
241
|
+
if (be(n))
|
|
242
242
|
return e;
|
|
243
243
|
const r = f.dirname(e);
|
|
244
244
|
if (r === e)
|
|
@@ -246,13 +246,13 @@ function I(t) {
|
|
|
246
246
|
e = r;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function $t(t, e) {
|
|
250
250
|
const n = f.relative(e, t);
|
|
251
251
|
return n === "" || !n.startsWith("..") && !f.isAbsolute(n);
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function Wt(t, e, n) {
|
|
254
254
|
const r = f.resolve(e), i = f.resolve(t);
|
|
255
|
-
if (
|
|
255
|
+
if (!$t(i, r))
|
|
256
256
|
throw d({
|
|
257
257
|
code: "parse_error",
|
|
258
258
|
path: n,
|
|
@@ -308,19 +308,19 @@ function Z(t, e = {}) {
|
|
|
308
308
|
path: i,
|
|
309
309
|
details: { message: "root is required for relative template paths" }
|
|
310
310
|
});
|
|
311
|
-
return n && s &&
|
|
311
|
+
return n && s && Wt(a, n, i), a;
|
|
312
312
|
}
|
|
313
|
-
const
|
|
314
|
-
function
|
|
313
|
+
const ve = 5 * 1024 * 1024;
|
|
314
|
+
function Tt(t) {
|
|
315
315
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
316
316
|
}
|
|
317
|
-
function
|
|
317
|
+
function At(t) {
|
|
318
318
|
return t?.root ? f.resolve(t.root) : I(process.cwd()) ?? process.cwd();
|
|
319
319
|
}
|
|
320
|
-
async function
|
|
321
|
-
const n =
|
|
320
|
+
async function Fe(t, e) {
|
|
321
|
+
const n = At(e), r = e?.loader ?? De(), i = {};
|
|
322
322
|
for (const [s, o] of Object.entries(t)) {
|
|
323
|
-
if (
|
|
323
|
+
if (D(o))
|
|
324
324
|
throw d({
|
|
325
325
|
code: "load_failed",
|
|
326
326
|
path: o,
|
|
@@ -334,7 +334,7 @@ async function Ne(t, e) {
|
|
|
334
334
|
try {
|
|
335
335
|
c = await r(a);
|
|
336
336
|
} catch (l) {
|
|
337
|
-
throw
|
|
337
|
+
throw Tt(l) ? l : d({
|
|
338
338
|
code: "load_failed",
|
|
339
339
|
path: a,
|
|
340
340
|
details: {
|
|
@@ -344,21 +344,21 @@ async function Ne(t, e) {
|
|
|
344
344
|
});
|
|
345
345
|
}
|
|
346
346
|
const h = Buffer.byteLength(c, "utf8");
|
|
347
|
-
if (h >
|
|
347
|
+
if (h > ve)
|
|
348
348
|
throw d({
|
|
349
349
|
code: "data_source_too_large",
|
|
350
350
|
path: a,
|
|
351
351
|
details: {
|
|
352
352
|
path: a,
|
|
353
353
|
size: h,
|
|
354
|
-
limit:
|
|
354
|
+
limit: ve
|
|
355
355
|
}
|
|
356
356
|
});
|
|
357
|
-
i[s] = await
|
|
357
|
+
i[s] = await Et(c, a);
|
|
358
358
|
}
|
|
359
359
|
return i;
|
|
360
360
|
}
|
|
361
|
-
async function
|
|
361
|
+
async function Lt(t, e) {
|
|
362
362
|
if (typeof t == "string")
|
|
363
363
|
return {
|
|
364
364
|
source: t,
|
|
@@ -395,7 +395,7 @@ async function At(t, e) {
|
|
|
395
395
|
});
|
|
396
396
|
let i;
|
|
397
397
|
try {
|
|
398
|
-
i = await
|
|
398
|
+
i = await Me(n, "utf8");
|
|
399
399
|
} catch (a) {
|
|
400
400
|
throw d({
|
|
401
401
|
code: "load_failed",
|
|
@@ -414,7 +414,7 @@ async function At(t, e) {
|
|
|
414
414
|
constrainToRoot: s !== void 0
|
|
415
415
|
};
|
|
416
416
|
}
|
|
417
|
-
class
|
|
417
|
+
class je {
|
|
418
418
|
components = /* @__PURE__ */ new Map();
|
|
419
419
|
register(e, n, r) {
|
|
420
420
|
if (this.components.has(e.alias))
|
|
@@ -438,7 +438,7 @@ class De {
|
|
|
438
438
|
return this.components.has(e);
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
const
|
|
441
|
+
const _e = 64 * 1024;
|
|
442
442
|
function q(t, e) {
|
|
443
443
|
if (!t.startsWith("---"))
|
|
444
444
|
return { context: {}, body: t };
|
|
@@ -451,13 +451,13 @@ function q(t, e) {
|
|
|
451
451
|
if (r === -1)
|
|
452
452
|
return { context: {}, body: t };
|
|
453
453
|
const i = t.slice(n + 1, r), s = Buffer.byteLength(i, "utf8");
|
|
454
|
-
if (s >
|
|
454
|
+
if (s > _e)
|
|
455
455
|
throw d({
|
|
456
456
|
code: "frontmatter_too_large",
|
|
457
457
|
path: e,
|
|
458
458
|
details: {
|
|
459
459
|
size: s,
|
|
460
|
-
limit:
|
|
460
|
+
limit: _e
|
|
461
461
|
}
|
|
462
462
|
});
|
|
463
463
|
if (i.trim().length === 0)
|
|
@@ -468,7 +468,7 @@ function q(t, e) {
|
|
|
468
468
|
});
|
|
469
469
|
let o;
|
|
470
470
|
try {
|
|
471
|
-
const h =
|
|
471
|
+
const h = He(i);
|
|
472
472
|
if (h == null)
|
|
473
473
|
o = {};
|
|
474
474
|
else if (typeof h == "object" && !Array.isArray(h))
|
|
@@ -496,14 +496,14 @@ ${i}
|
|
|
496
496
|
---`
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
|
-
const
|
|
499
|
+
const Ot = /* @__PURE__ */ new Set([
|
|
500
500
|
"string",
|
|
501
501
|
"number",
|
|
502
502
|
"boolean",
|
|
503
503
|
"object",
|
|
504
504
|
"array"
|
|
505
505
|
]);
|
|
506
|
-
function
|
|
506
|
+
function Rt(t, e) {
|
|
507
507
|
const n = t.props;
|
|
508
508
|
if (n === void 0)
|
|
509
509
|
return {};
|
|
@@ -522,13 +522,13 @@ function Ot(t, e) {
|
|
|
522
522
|
const o = s, a = {};
|
|
523
523
|
if ("type" in o && o.type !== void 0) {
|
|
524
524
|
const c = String(o.type);
|
|
525
|
-
|
|
525
|
+
Ot.has(c) ? a.type = c : a.type = void 0;
|
|
526
526
|
}
|
|
527
527
|
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[i] = a;
|
|
528
528
|
}
|
|
529
529
|
return r;
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function Mt(t) {
|
|
532
532
|
if (t != null) {
|
|
533
533
|
if (typeof t == "string") return "string";
|
|
534
534
|
if (typeof t == "number") return "number";
|
|
@@ -537,7 +537,7 @@ function Rt(t) {
|
|
|
537
537
|
if (typeof t == "object") return "object";
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
|
-
function
|
|
540
|
+
function Ht(t, e) {
|
|
541
541
|
return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
|
|
542
542
|
}
|
|
543
543
|
function G(t, e) {
|
|
@@ -547,7 +547,7 @@ function G(t, e) {
|
|
|
547
547
|
details: e
|
|
548
548
|
};
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function Dt(t, e, n) {
|
|
551
551
|
const r = [], i = {}, s = new Set(Object.keys(e));
|
|
552
552
|
for (const [o, a] of Object.entries(e)) {
|
|
553
553
|
const c = Object.prototype.hasOwnProperty.call(t, o);
|
|
@@ -558,8 +558,8 @@ function Ht(t, e, n) {
|
|
|
558
558
|
component: n
|
|
559
559
|
})
|
|
560
560
|
), h = void 0)), c && h !== void 0 && h !== null) {
|
|
561
|
-
const l = a.type ??
|
|
562
|
-
l && !
|
|
561
|
+
const l = a.type ?? Mt(h);
|
|
562
|
+
l && !Ht(h, l) && (r.push(
|
|
563
563
|
G("prop_type_mismatch", {
|
|
564
564
|
prop: o,
|
|
565
565
|
component: n,
|
|
@@ -589,13 +589,13 @@ async function Nt(t) {
|
|
|
589
589
|
message: `unregistered component: ${t.alias}`
|
|
590
590
|
}
|
|
591
591
|
});
|
|
592
|
-
const n =
|
|
592
|
+
const n = D(e.componentPath) ? e.componentPath : Z(e.componentPath, {
|
|
593
593
|
rootDir: t.rootDir,
|
|
594
594
|
fromPath: e.definedAt,
|
|
595
595
|
documentPath: t.path,
|
|
596
596
|
constrainToRoot: t.constrainToRoot,
|
|
597
597
|
hyogenPath: !0
|
|
598
|
-
}), r = await t.loader(n), { context: i, body: s } = q(r, n), o =
|
|
598
|
+
}), r = await t.loader(n), { context: i, body: s } = q(r, n), o = Rt(i, n), { values: a, warnings: c } = Dt(
|
|
599
599
|
t.props,
|
|
600
600
|
o,
|
|
601
601
|
t.alias
|
|
@@ -606,7 +606,7 @@ async function Nt(t) {
|
|
|
606
606
|
l,
|
|
607
607
|
a
|
|
608
608
|
);
|
|
609
|
-
return (await
|
|
609
|
+
return (await ke(s, {
|
|
610
610
|
context: u,
|
|
611
611
|
loader: t.loader,
|
|
612
612
|
root: t.rootDir,
|
|
@@ -620,17 +620,17 @@ async function Nt(t) {
|
|
|
620
620
|
constrainToRoot: t.constrainToRoot
|
|
621
621
|
})).trim();
|
|
622
622
|
}
|
|
623
|
-
const
|
|
623
|
+
const Ft = /* @__PURE__ */ new Set([
|
|
624
624
|
"__proto__",
|
|
625
625
|
"prototype",
|
|
626
626
|
"constructor",
|
|
627
627
|
"__defineGetter__"
|
|
628
628
|
]);
|
|
629
|
-
function
|
|
630
|
-
return
|
|
629
|
+
function jt(t) {
|
|
630
|
+
return Ft.has(t);
|
|
631
631
|
}
|
|
632
|
-
function
|
|
633
|
-
if (
|
|
632
|
+
function Se(t, e) {
|
|
633
|
+
if (jt(t))
|
|
634
634
|
throw d({
|
|
635
635
|
code: "forbidden_property_access",
|
|
636
636
|
path: e,
|
|
@@ -640,7 +640,7 @@ function ve(t, e) {
|
|
|
640
640
|
function R(t) {
|
|
641
641
|
return !t;
|
|
642
642
|
}
|
|
643
|
-
function
|
|
643
|
+
function Bt(t, e) {
|
|
644
644
|
if (t != null) {
|
|
645
645
|
if (typeof t == "string")
|
|
646
646
|
return e === "length" ? t.length : void 0;
|
|
@@ -648,7 +648,7 @@ function jt(t, e) {
|
|
|
648
648
|
return t[e];
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
-
function
|
|
651
|
+
function It(t, e, n) {
|
|
652
652
|
switch (t) {
|
|
653
653
|
case "+":
|
|
654
654
|
return e + n;
|
|
@@ -688,11 +688,11 @@ async function y(t, e) {
|
|
|
688
688
|
case "literal":
|
|
689
689
|
return t.value;
|
|
690
690
|
case "identifier":
|
|
691
|
-
return
|
|
691
|
+
return Se(t.name, r), n[t.name];
|
|
692
692
|
case "member": {
|
|
693
|
-
|
|
693
|
+
Se(t.property, r);
|
|
694
694
|
const i = await y(t.object, e);
|
|
695
|
-
return
|
|
695
|
+
return Bt(i, t.property);
|
|
696
696
|
}
|
|
697
697
|
case "default": {
|
|
698
698
|
const i = await y(t.left, e);
|
|
@@ -712,7 +712,7 @@ async function y(t, e) {
|
|
|
712
712
|
return R(o) ? y(t.right, e) : o;
|
|
713
713
|
}
|
|
714
714
|
const i = await y(t.left, e), s = await y(t.right, e);
|
|
715
|
-
return
|
|
715
|
+
return It(t.op, i, s);
|
|
716
716
|
}
|
|
717
717
|
case "call": {
|
|
718
718
|
if (!e.registry || !e.loader || !e.visitStack)
|
|
@@ -782,26 +782,26 @@ async function y(t, e) {
|
|
|
782
782
|
function J(t) {
|
|
783
783
|
return /[A-Za-z_$]/.test(t);
|
|
784
784
|
}
|
|
785
|
-
function
|
|
785
|
+
function Ut(t) {
|
|
786
786
|
return /[A-Za-z0-9_$]/.test(t);
|
|
787
787
|
}
|
|
788
788
|
function S(t, e, n = {}) {
|
|
789
789
|
const r = t.trim();
|
|
790
790
|
if (r.length === 0)
|
|
791
|
-
throw
|
|
792
|
-
const i = new
|
|
791
|
+
throw g(e, "empty expression");
|
|
792
|
+
const i = new zt(r, e, n), s = i.parseExpression();
|
|
793
793
|
if (i.skipWhitespace(), i.hasMore())
|
|
794
|
-
throw
|
|
794
|
+
throw g(e, `unexpected token at position ${i.position}`);
|
|
795
795
|
return s;
|
|
796
796
|
}
|
|
797
|
-
function
|
|
797
|
+
function g(t, e) {
|
|
798
798
|
throw d({
|
|
799
799
|
code: "parse_error",
|
|
800
800
|
path: t,
|
|
801
801
|
details: { message: e }
|
|
802
802
|
});
|
|
803
803
|
}
|
|
804
|
-
class
|
|
804
|
+
class zt {
|
|
805
805
|
constructor(e, n, r = {}) {
|
|
806
806
|
this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
|
|
807
807
|
}
|
|
@@ -838,7 +838,7 @@ class Ut {
|
|
|
838
838
|
this.index++;
|
|
839
839
|
const n = this.parseTernary();
|
|
840
840
|
if (this.skipWhitespace(), this.peek() !== ":")
|
|
841
|
-
throw
|
|
841
|
+
throw g(this.path, "expected ':' in ternary expression");
|
|
842
842
|
this.index++;
|
|
843
843
|
const r = this.parseTernary();
|
|
844
844
|
return { type: "ternary", condition: e, consequent: n, alternate: r };
|
|
@@ -931,10 +931,10 @@ class Ut {
|
|
|
931
931
|
this.skipWhitespace();
|
|
932
932
|
const n = this.readIdentifier();
|
|
933
933
|
if (!n)
|
|
934
|
-
throw
|
|
934
|
+
throw g(this.path, "expected property name after '.'");
|
|
935
935
|
if (this.skipWhitespace(), this.peek() === "(") {
|
|
936
936
|
if (n !== "toLocaleString")
|
|
937
|
-
throw
|
|
937
|
+
throw g(this.path, `unsupported method: ${n}()`);
|
|
938
938
|
this.index++;
|
|
939
939
|
const r = this.parseMethodArgs();
|
|
940
940
|
return { type: "method", object: e, method: n, args: r };
|
|
@@ -949,7 +949,7 @@ class Ut {
|
|
|
949
949
|
for (e.push(this.parseLiteralValue()), this.skipWhitespace(); this.peek() === ","; )
|
|
950
950
|
this.index++, e.push(this.parseLiteralValue()), this.skipWhitespace();
|
|
951
951
|
if (this.peek() !== ")")
|
|
952
|
-
throw
|
|
952
|
+
throw g(this.path, "expected ')' after method arguments");
|
|
953
953
|
return this.index++, e;
|
|
954
954
|
}
|
|
955
955
|
parsePrimary() {
|
|
@@ -959,7 +959,7 @@ class Ut {
|
|
|
959
959
|
this.index++;
|
|
960
960
|
const n = this.parseExpression();
|
|
961
961
|
if (this.skipWhitespace(), this.peek() !== ")")
|
|
962
|
-
throw
|
|
962
|
+
throw g(this.path, "expected ')'");
|
|
963
963
|
return this.index++, n;
|
|
964
964
|
}
|
|
965
965
|
if (e === "`")
|
|
@@ -978,7 +978,7 @@ class Ut {
|
|
|
978
978
|
return { type: "literal", value: n === "true" ? !0 : n === "false" ? !1 : n === "null" ? null : void 0 };
|
|
979
979
|
if (this.skipWhitespace(), this.peek() === "(") {
|
|
980
980
|
if (!this.allowCalls)
|
|
981
|
-
throw
|
|
981
|
+
throw g(
|
|
982
982
|
this.path,
|
|
983
983
|
"component calls are not allowed in template literals"
|
|
984
984
|
);
|
|
@@ -987,10 +987,10 @@ class Ut {
|
|
|
987
987
|
return { type: "call", callee: n, args: r };
|
|
988
988
|
}
|
|
989
989
|
if (this.peek() === "[")
|
|
990
|
-
throw
|
|
990
|
+
throw g(this.path, "bracket access is not allowed");
|
|
991
991
|
return { type: "identifier", name: n };
|
|
992
992
|
}
|
|
993
|
-
throw
|
|
993
|
+
throw g(this.path, `unexpected character '${e}'`);
|
|
994
994
|
}
|
|
995
995
|
parseTemplateLiteral() {
|
|
996
996
|
this.index++;
|
|
@@ -1002,7 +1002,7 @@ class Ut {
|
|
|
1002
1002
|
return this.index++, e.push(n), { type: "template", parts: e };
|
|
1003
1003
|
if (r === "\\") {
|
|
1004
1004
|
if (this.index++, this.index >= this.input.length)
|
|
1005
|
-
throw
|
|
1005
|
+
throw g(this.path, "unterminated template literal escape");
|
|
1006
1006
|
n += this.input[this.index], this.index++;
|
|
1007
1007
|
continue;
|
|
1008
1008
|
}
|
|
@@ -1016,7 +1016,7 @@ class Ut {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
n += r, this.index++;
|
|
1018
1018
|
}
|
|
1019
|
-
throw
|
|
1019
|
+
throw g(this.path, "unterminated template literal");
|
|
1020
1020
|
}
|
|
1021
1021
|
readTemplateExpression() {
|
|
1022
1022
|
let e = 1;
|
|
@@ -1050,27 +1050,27 @@ class Ut {
|
|
|
1050
1050
|
}
|
|
1051
1051
|
this.index++;
|
|
1052
1052
|
}
|
|
1053
|
-
throw
|
|
1053
|
+
throw g(this.path, "unterminated template expression");
|
|
1054
1054
|
}
|
|
1055
1055
|
parseCallArgs() {
|
|
1056
1056
|
if (this.skipWhitespace(), this.peek() === ")")
|
|
1057
1057
|
return this.index++, {};
|
|
1058
1058
|
if (this.peek() !== "{")
|
|
1059
|
-
throw
|
|
1059
|
+
throw g(this.path, "expected object literal");
|
|
1060
1060
|
this.index++, this.skipWhitespace();
|
|
1061
1061
|
const e = {};
|
|
1062
1062
|
if (this.peek() === "}") {
|
|
1063
1063
|
if (this.index++, this.skipWhitespace(), this.peek() !== ")")
|
|
1064
|
-
throw
|
|
1064
|
+
throw g(this.path, "expected ')' after call arguments");
|
|
1065
1065
|
return this.index++, e;
|
|
1066
1066
|
}
|
|
1067
1067
|
for (; ; ) {
|
|
1068
1068
|
this.skipWhitespace();
|
|
1069
1069
|
const n = this.readIdentifier();
|
|
1070
1070
|
if (!n)
|
|
1071
|
-
throw
|
|
1071
|
+
throw g(this.path, "expected property name in object literal");
|
|
1072
1072
|
if (this.skipWhitespace(), this.peek() !== ":")
|
|
1073
|
-
throw
|
|
1073
|
+
throw g(this.path, "expected ':' in object literal");
|
|
1074
1074
|
if (this.index++, this.skipWhitespace(), e[n] = this.parseTernary(), this.skipWhitespace(), this.peek() === "}") {
|
|
1075
1075
|
this.index++;
|
|
1076
1076
|
break;
|
|
@@ -1082,15 +1082,15 @@ class Ut {
|
|
|
1082
1082
|
}
|
|
1083
1083
|
continue;
|
|
1084
1084
|
}
|
|
1085
|
-
throw
|
|
1085
|
+
throw g(this.path, "expected ',' or '}' in object literal");
|
|
1086
1086
|
}
|
|
1087
1087
|
if (this.skipWhitespace(), this.peek() !== ")")
|
|
1088
|
-
throw
|
|
1088
|
+
throw g(this.path, "expected ')' after call arguments");
|
|
1089
1089
|
return this.index++, e;
|
|
1090
1090
|
}
|
|
1091
1091
|
parseObjectLiteral() {
|
|
1092
1092
|
if (this.peek() !== "{")
|
|
1093
|
-
throw
|
|
1093
|
+
throw g(this.path, "expected object literal");
|
|
1094
1094
|
this.index++, this.skipWhitespace();
|
|
1095
1095
|
const e = {};
|
|
1096
1096
|
if (this.peek() === "}")
|
|
@@ -1099,9 +1099,9 @@ class Ut {
|
|
|
1099
1099
|
this.skipWhitespace();
|
|
1100
1100
|
const n = this.readIdentifier();
|
|
1101
1101
|
if (!n)
|
|
1102
|
-
throw
|
|
1102
|
+
throw g(this.path, "expected property name in object literal");
|
|
1103
1103
|
if (this.skipWhitespace(), this.peek() !== ":")
|
|
1104
|
-
throw
|
|
1104
|
+
throw g(this.path, "expected ':' in object literal");
|
|
1105
1105
|
if (this.index++, this.skipWhitespace(), e[n] = this.parseLiteralValue(), this.skipWhitespace(), this.peek() === "}") {
|
|
1106
1106
|
this.index++;
|
|
1107
1107
|
break;
|
|
@@ -1112,13 +1112,13 @@ class Ut {
|
|
|
1112
1112
|
break;
|
|
1113
1113
|
}
|
|
1114
1114
|
} else
|
|
1115
|
-
throw
|
|
1115
|
+
throw g(this.path, "expected ',' or '}' in object literal");
|
|
1116
1116
|
}
|
|
1117
1117
|
return e;
|
|
1118
1118
|
}
|
|
1119
1119
|
parseArrayLiteral() {
|
|
1120
1120
|
if (this.peek() !== "[")
|
|
1121
|
-
throw
|
|
1121
|
+
throw g(this.path, "expected array literal");
|
|
1122
1122
|
this.index++, this.skipWhitespace();
|
|
1123
1123
|
const e = [];
|
|
1124
1124
|
if (this.peek() === "]")
|
|
@@ -1134,7 +1134,7 @@ class Ut {
|
|
|
1134
1134
|
break;
|
|
1135
1135
|
}
|
|
1136
1136
|
} else
|
|
1137
|
-
throw
|
|
1137
|
+
throw g(this.path, "expected ',' or ']' in array literal");
|
|
1138
1138
|
}
|
|
1139
1139
|
return e;
|
|
1140
1140
|
}
|
|
@@ -1154,9 +1154,9 @@ class Ut {
|
|
|
1154
1154
|
if (n === "true") return !0;
|
|
1155
1155
|
if (n === "false") return !1;
|
|
1156
1156
|
if (n === "null") return null;
|
|
1157
|
-
throw
|
|
1157
|
+
throw g(this.path, "object literal values must be literals");
|
|
1158
1158
|
}
|
|
1159
|
-
throw
|
|
1159
|
+
throw g(this.path, "object literal values must be literals");
|
|
1160
1160
|
}
|
|
1161
1161
|
match(e) {
|
|
1162
1162
|
return this.skipWhitespace(), this.input.startsWith(e, this.index) ? (this.index += e.length, !0) : !1;
|
|
@@ -1169,7 +1169,7 @@ class Ut {
|
|
|
1169
1169
|
const e = this.index;
|
|
1170
1170
|
if (!J(this.peek()))
|
|
1171
1171
|
return "";
|
|
1172
|
-
for (this.index++; this.index < this.input.length &&
|
|
1172
|
+
for (this.index++; this.index < this.input.length && Ut(this.peek()); )
|
|
1173
1173
|
this.index++;
|
|
1174
1174
|
return this.input.slice(e, this.index);
|
|
1175
1175
|
}
|
|
@@ -1183,14 +1183,14 @@ class Ut {
|
|
|
1183
1183
|
return this.index++, n;
|
|
1184
1184
|
if (r === "\\") {
|
|
1185
1185
|
if (this.index++, this.index >= this.input.length)
|
|
1186
|
-
throw
|
|
1186
|
+
throw g(this.path, "unterminated string escape");
|
|
1187
1187
|
const i = this.input[this.index];
|
|
1188
1188
|
n += i, this.index++;
|
|
1189
1189
|
continue;
|
|
1190
1190
|
}
|
|
1191
1191
|
n += r, this.index++;
|
|
1192
1192
|
}
|
|
1193
|
-
throw
|
|
1193
|
+
throw g(this.path, "unterminated string literal");
|
|
1194
1194
|
}
|
|
1195
1195
|
readNumber() {
|
|
1196
1196
|
const e = this.index;
|
|
@@ -1198,15 +1198,15 @@ class Ut {
|
|
|
1198
1198
|
this.index++;
|
|
1199
1199
|
const n = this.input.slice(e, this.index), r = Number(n);
|
|
1200
1200
|
if (Number.isNaN(r))
|
|
1201
|
-
throw
|
|
1201
|
+
throw g(this.path, `invalid number '${n}'`);
|
|
1202
1202
|
return r;
|
|
1203
1203
|
}
|
|
1204
1204
|
}
|
|
1205
|
-
const
|
|
1205
|
+
const Vt = /^( {0,3})(=+|-+)[ \t]*$/, Be = /^( {0,3})(`{3,}|~{3,})(.*)$/;
|
|
1206
1206
|
function O(t) {
|
|
1207
1207
|
return t === " " || t === " ";
|
|
1208
1208
|
}
|
|
1209
|
-
function
|
|
1209
|
+
function Ie(t) {
|
|
1210
1210
|
let e = 0;
|
|
1211
1211
|
for (; e < t.length && e < 3 && t[e] === " "; )
|
|
1212
1212
|
e += 1;
|
|
@@ -1239,11 +1239,11 @@ function je(t) {
|
|
|
1239
1239
|
}
|
|
1240
1240
|
return { indent: n, level: r, text: t.slice(e, s) };
|
|
1241
1241
|
}
|
|
1242
|
-
function
|
|
1242
|
+
function oe() {
|
|
1243
1243
|
return { active: !1, marker: null, length: 0 };
|
|
1244
1244
|
}
|
|
1245
|
-
function
|
|
1246
|
-
const n =
|
|
1245
|
+
function ae(t, e) {
|
|
1246
|
+
const n = Be.exec(e);
|
|
1247
1247
|
if (!t.active) {
|
|
1248
1248
|
if (n) {
|
|
1249
1249
|
const r = n[2];
|
|
@@ -1258,29 +1258,29 @@ function Ie(t, e) {
|
|
|
1258
1258
|
return !0;
|
|
1259
1259
|
}
|
|
1260
1260
|
function Ue(t) {
|
|
1261
|
-
const e =
|
|
1261
|
+
const e = Ie(t);
|
|
1262
1262
|
return e ? e.level : null;
|
|
1263
1263
|
}
|
|
1264
1264
|
function ze(t) {
|
|
1265
|
-
const e =
|
|
1265
|
+
const e = Vt.exec(t);
|
|
1266
1266
|
return e ? e[2][0] === "=" ? 1 : 2 : null;
|
|
1267
1267
|
}
|
|
1268
|
-
function
|
|
1268
|
+
function Zt(t) {
|
|
1269
1269
|
for (let e = 0; e < t.length; e++)
|
|
1270
1270
|
if (!O(t[e]))
|
|
1271
1271
|
return !1;
|
|
1272
1272
|
return !0;
|
|
1273
1273
|
}
|
|
1274
1274
|
function Ve(t) {
|
|
1275
|
-
return !(
|
|
1275
|
+
return !(Zt(t) || Ue(t) !== null || Be.test(t) || t.startsWith(" ") || t.startsWith(" "));
|
|
1276
1276
|
}
|
|
1277
1277
|
function Ze(t) {
|
|
1278
1278
|
const e = t.split(`
|
|
1279
|
-
`), n =
|
|
1279
|
+
`), n = oe();
|
|
1280
1280
|
let r = 0;
|
|
1281
1281
|
for (let i = 0; i < e.length; i++) {
|
|
1282
1282
|
const s = e[i];
|
|
1283
|
-
if (
|
|
1283
|
+
if (ae(n, s))
|
|
1284
1284
|
continue;
|
|
1285
1285
|
const o = Ue(s);
|
|
1286
1286
|
if (o !== null) {
|
|
@@ -1295,21 +1295,21 @@ function Ze(t) {
|
|
|
1295
1295
|
}
|
|
1296
1296
|
return r;
|
|
1297
1297
|
}
|
|
1298
|
-
function
|
|
1298
|
+
function qt(t) {
|
|
1299
1299
|
return t < 1 ? 1 : t > 6 ? 6 : t;
|
|
1300
1300
|
}
|
|
1301
|
-
function
|
|
1302
|
-
const n = e.trim(), r = "#".repeat(
|
|
1301
|
+
function Ee(t, e) {
|
|
1302
|
+
const n = e.trim(), r = "#".repeat(qt(t));
|
|
1303
1303
|
return n.length === 0 ? r : `${r} ${n}`;
|
|
1304
1304
|
}
|
|
1305
1305
|
function qe(t, e) {
|
|
1306
1306
|
if (e <= 0 || t.length === 0)
|
|
1307
1307
|
return t;
|
|
1308
1308
|
const n = t.split(`
|
|
1309
|
-
`), r =
|
|
1309
|
+
`), r = oe(), i = [];
|
|
1310
1310
|
for (let s = 0; s < n.length; s++) {
|
|
1311
1311
|
const o = n[s];
|
|
1312
|
-
if (
|
|
1312
|
+
if (ae(r, o)) {
|
|
1313
1313
|
i.push(o);
|
|
1314
1314
|
continue;
|
|
1315
1315
|
}
|
|
@@ -1317,13 +1317,13 @@ function qe(t, e) {
|
|
|
1317
1317
|
if (a !== null && i.length > 0) {
|
|
1318
1318
|
const h = i[i.length - 1];
|
|
1319
1319
|
if (Ve(h)) {
|
|
1320
|
-
i[i.length - 1] =
|
|
1320
|
+
i[i.length - 1] = Ee(a + e, h);
|
|
1321
1321
|
continue;
|
|
1322
1322
|
}
|
|
1323
1323
|
}
|
|
1324
|
-
const c =
|
|
1324
|
+
const c = Ie(o);
|
|
1325
1325
|
if (c !== null) {
|
|
1326
|
-
i.push(c.indent +
|
|
1326
|
+
i.push(c.indent + Ee(c.level + e, c.text));
|
|
1327
1327
|
continue;
|
|
1328
1328
|
}
|
|
1329
1329
|
i.push(o);
|
|
@@ -1353,22 +1353,121 @@ async function Pe(t, e, n = {}) {
|
|
|
1353
1353
|
path: r,
|
|
1354
1354
|
details: { message: "unclosed expression" }
|
|
1355
1355
|
});
|
|
1356
|
-
const
|
|
1356
|
+
const p = t.slice(o + h, u).trim(), x = S(p, r), m = await y(x, {
|
|
1357
1357
|
...n,
|
|
1358
1358
|
context: e,
|
|
1359
1359
|
path: r,
|
|
1360
1360
|
parentContext: n.parentContext ?? e
|
|
1361
1361
|
});
|
|
1362
|
-
let
|
|
1363
|
-
if (
|
|
1364
|
-
const
|
|
1365
|
-
|
|
1362
|
+
let w = m == null ? "" : String(m);
|
|
1363
|
+
if (x.type === "call" && w.length > 0) {
|
|
1364
|
+
const _ = Ze(i);
|
|
1365
|
+
w = qe(w, _);
|
|
1366
1366
|
}
|
|
1367
|
-
i +=
|
|
1367
|
+
i += w, s = u + l.length;
|
|
1368
1368
|
}
|
|
1369
1369
|
return i;
|
|
1370
1370
|
}
|
|
1371
|
-
function
|
|
1371
|
+
function Pt(t) {
|
|
1372
|
+
const e = [];
|
|
1373
|
+
let n = 0;
|
|
1374
|
+
for (; n < t.length; ) {
|
|
1375
|
+
const r = t.indexOf(`
|
|
1376
|
+
`, n);
|
|
1377
|
+
if (r === -1) {
|
|
1378
|
+
e.push({ content: t.slice(n), eol: "" });
|
|
1379
|
+
break;
|
|
1380
|
+
}
|
|
1381
|
+
let i = t.slice(n, r), s = `
|
|
1382
|
+
`;
|
|
1383
|
+
i.endsWith("\r") && (i = i.slice(0, -1), s = `\r
|
|
1384
|
+
`), e.push({ content: i, eol: s }), n = r + 1;
|
|
1385
|
+
}
|
|
1386
|
+
return e;
|
|
1387
|
+
}
|
|
1388
|
+
function Kt(t, e, n) {
|
|
1389
|
+
let r = 1, i = e, s = null;
|
|
1390
|
+
for (; i < t.length; ) {
|
|
1391
|
+
const o = t[i];
|
|
1392
|
+
if (s) {
|
|
1393
|
+
if (o === "\\") {
|
|
1394
|
+
i += 2;
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
o === s && (s = null), i++;
|
|
1398
|
+
continue;
|
|
1399
|
+
}
|
|
1400
|
+
if (o === '"' || o === "'" || o === "`") {
|
|
1401
|
+
s = o, i++;
|
|
1402
|
+
continue;
|
|
1403
|
+
}
|
|
1404
|
+
if (o === "{") {
|
|
1405
|
+
r++, i++;
|
|
1406
|
+
continue;
|
|
1407
|
+
}
|
|
1408
|
+
if (o === "}") {
|
|
1409
|
+
if (r--, r === 0)
|
|
1410
|
+
return {
|
|
1411
|
+
expr: t.slice(e, i),
|
|
1412
|
+
end: i + 1
|
|
1413
|
+
};
|
|
1414
|
+
i++;
|
|
1415
|
+
continue;
|
|
1416
|
+
}
|
|
1417
|
+
i++;
|
|
1418
|
+
}
|
|
1419
|
+
throw d({
|
|
1420
|
+
code: "parse_error",
|
|
1421
|
+
path: n,
|
|
1422
|
+
details: { message: "unclosed template expression" }
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
function Yt(t, e) {
|
|
1426
|
+
let n = 0, r = e - 1;
|
|
1427
|
+
for (; r >= 0 && t[r] === "\\"; )
|
|
1428
|
+
n++, r--;
|
|
1429
|
+
return n % 2 === 1;
|
|
1430
|
+
}
|
|
1431
|
+
async function Xt(t, e, n) {
|
|
1432
|
+
const r = n.path;
|
|
1433
|
+
let i = "", s = 0;
|
|
1434
|
+
for (; s < t.length; ) {
|
|
1435
|
+
const o = t.indexOf("${", s);
|
|
1436
|
+
if (o === -1) {
|
|
1437
|
+
i += t.slice(s);
|
|
1438
|
+
break;
|
|
1439
|
+
}
|
|
1440
|
+
if (Yt(t, o)) {
|
|
1441
|
+
i += t.slice(s, o - 1), i += "${", s = o + 2;
|
|
1442
|
+
continue;
|
|
1443
|
+
}
|
|
1444
|
+
i += t.slice(s, o);
|
|
1445
|
+
const { expr: a, end: c } = Kt(t, o + 2, r), h = S(a.trim(), r, { allowCalls: !1 }), l = await y(h, {
|
|
1446
|
+
...n,
|
|
1447
|
+
context: e,
|
|
1448
|
+
path: r,
|
|
1449
|
+
parentContext: n.parentContext ?? e
|
|
1450
|
+
});
|
|
1451
|
+
i += l == null ? "" : String(l), s = c;
|
|
1452
|
+
}
|
|
1453
|
+
return i;
|
|
1454
|
+
}
|
|
1455
|
+
async function Ke(t, e, n = {}) {
|
|
1456
|
+
const r = Pt(t);
|
|
1457
|
+
if (r.length === 0)
|
|
1458
|
+
return t;
|
|
1459
|
+
const i = oe();
|
|
1460
|
+
let s = "", o = "", a = !1;
|
|
1461
|
+
const c = async () => {
|
|
1462
|
+
a && (s += await Xt(o, e, n), o = "", a = !1);
|
|
1463
|
+
};
|
|
1464
|
+
for (const { content: h, eol: l } of r) {
|
|
1465
|
+
const u = ae(i, h), p = h + l;
|
|
1466
|
+
u ? (a || (a = !0, o = ""), o += p) : (await c(), s += p);
|
|
1467
|
+
}
|
|
1468
|
+
return await c(), s;
|
|
1469
|
+
}
|
|
1470
|
+
function Gt(t, e) {
|
|
1372
1471
|
let n = 0, r = 0;
|
|
1373
1472
|
for (; r < t.length; ) {
|
|
1374
1473
|
const i = t.indexOf(e, r);
|
|
@@ -1378,14 +1477,14 @@ function qt(t, e) {
|
|
|
1378
1477
|
}
|
|
1379
1478
|
return n;
|
|
1380
1479
|
}
|
|
1381
|
-
function
|
|
1382
|
-
const e = t.includes("@hg"), n = t.includes("@endhg"), r =
|
|
1480
|
+
function ce(t) {
|
|
1481
|
+
const e = t.includes("@hg"), n = t.includes("@endhg"), r = Gt(t, "@@");
|
|
1383
1482
|
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";
|
|
1384
1483
|
}
|
|
1385
|
-
function
|
|
1484
|
+
function le(t) {
|
|
1386
1485
|
return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
|
|
1387
1486
|
}
|
|
1388
|
-
function
|
|
1487
|
+
function he(t, e) {
|
|
1389
1488
|
let n = 0, r = !1;
|
|
1390
1489
|
for (; n < e; ) {
|
|
1391
1490
|
const i = t.indexOf("```", n);
|
|
@@ -1402,14 +1501,14 @@ function W(t) {
|
|
|
1402
1501
|
const r = t.indexOf("<!--", n);
|
|
1403
1502
|
if (r === -1)
|
|
1404
1503
|
break;
|
|
1405
|
-
if (
|
|
1504
|
+
if (he(t, r)) {
|
|
1406
1505
|
n = r + 4;
|
|
1407
1506
|
continue;
|
|
1408
1507
|
}
|
|
1409
1508
|
const i = t.indexOf("-->", r + 4);
|
|
1410
1509
|
if (i === -1)
|
|
1411
1510
|
break;
|
|
1412
|
-
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a =
|
|
1511
|
+
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = ce(o);
|
|
1413
1512
|
(a === "hg" || a === "at-at") && e.push({
|
|
1414
1513
|
start: r,
|
|
1415
1514
|
end: i + 3,
|
|
@@ -1419,40 +1518,40 @@ function W(t) {
|
|
|
1419
1518
|
}
|
|
1420
1519
|
return e;
|
|
1421
1520
|
}
|
|
1422
|
-
function
|
|
1521
|
+
function de(t) {
|
|
1423
1522
|
let e = 0;
|
|
1424
1523
|
for (; e < t.length; ) {
|
|
1425
1524
|
const n = t.indexOf("<!--", e);
|
|
1426
1525
|
if (n === -1)
|
|
1427
1526
|
return !1;
|
|
1428
|
-
if (
|
|
1527
|
+
if (he(t, n)) {
|
|
1429
1528
|
e = n + 4;
|
|
1430
1529
|
continue;
|
|
1431
1530
|
}
|
|
1432
1531
|
const r = t.indexOf("-->", n + 4);
|
|
1433
1532
|
if (r === -1)
|
|
1434
1533
|
return !1;
|
|
1435
|
-
const i = t.slice(n + 4, r), s =
|
|
1534
|
+
const i = t.slice(n + 4, r), s = ce(i);
|
|
1436
1535
|
if (s === "unclosed" || s === "mixed")
|
|
1437
1536
|
return !0;
|
|
1438
1537
|
e = r + 3;
|
|
1439
1538
|
}
|
|
1440
1539
|
return !1;
|
|
1441
1540
|
}
|
|
1442
|
-
function
|
|
1541
|
+
function ue(t) {
|
|
1443
1542
|
let e = 0;
|
|
1444
1543
|
for (; e < t.length; ) {
|
|
1445
1544
|
const n = t.indexOf("<!--", e);
|
|
1446
1545
|
if (n === -1)
|
|
1447
1546
|
return null;
|
|
1448
|
-
if (
|
|
1547
|
+
if (he(t, n)) {
|
|
1449
1548
|
e = n + 4;
|
|
1450
1549
|
continue;
|
|
1451
1550
|
}
|
|
1452
1551
|
const r = t.indexOf("-->", n + 4);
|
|
1453
1552
|
if (r === -1)
|
|
1454
1553
|
return null;
|
|
1455
|
-
const i = t.slice(n + 4, r), s =
|
|
1554
|
+
const i = t.slice(n + 4, r), s = ce(i);
|
|
1456
1555
|
if (s === "mixed")
|
|
1457
1556
|
return "mixed @hg and @@ markers are not allowed";
|
|
1458
1557
|
if (s === "unclosed")
|
|
@@ -1461,12 +1560,12 @@ function he(t) {
|
|
|
1461
1560
|
}
|
|
1462
1561
|
return null;
|
|
1463
1562
|
}
|
|
1464
|
-
function
|
|
1465
|
-
return
|
|
1563
|
+
function $(t) {
|
|
1564
|
+
return le(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
|
|
1466
1565
|
}
|
|
1467
|
-
const
|
|
1468
|
-
function
|
|
1469
|
-
return
|
|
1566
|
+
const Jt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
|
|
1567
|
+
function fe(t) {
|
|
1568
|
+
return Jt.test(t.trim());
|
|
1470
1569
|
}
|
|
1471
1570
|
function Q(t, e) {
|
|
1472
1571
|
throw d({
|
|
@@ -1475,11 +1574,11 @@ function Q(t, e) {
|
|
|
1475
1574
|
details: { message: e }
|
|
1476
1575
|
});
|
|
1477
1576
|
}
|
|
1478
|
-
function
|
|
1577
|
+
function Qt(t, e) {
|
|
1479
1578
|
let n = t;
|
|
1480
1579
|
const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
|
|
1481
1580
|
r && (n = r[1]);
|
|
1482
|
-
const i =
|
|
1581
|
+
const i = $(n);
|
|
1483
1582
|
if (i.length !== 1)
|
|
1484
1583
|
return null;
|
|
1485
1584
|
const s = i[0];
|
|
@@ -1521,17 +1620,17 @@ function Kt(t, e) {
|
|
|
1521
1620
|
function M(t) {
|
|
1522
1621
|
return { start: t.start, end: t.end, raw: t.raw };
|
|
1523
1622
|
}
|
|
1524
|
-
function
|
|
1623
|
+
function C(t, e) {
|
|
1525
1624
|
throw d({
|
|
1526
1625
|
code: "parse_error",
|
|
1527
1626
|
path: t,
|
|
1528
1627
|
details: { message: e }
|
|
1529
1628
|
});
|
|
1530
1629
|
}
|
|
1531
|
-
function
|
|
1630
|
+
function en(t, e) {
|
|
1532
1631
|
const n = [];
|
|
1533
1632
|
for (const r of W(t)) {
|
|
1534
|
-
const i =
|
|
1633
|
+
const i = Qt(r.inner, e);
|
|
1535
1634
|
i && n.push({
|
|
1536
1635
|
start: r.start,
|
|
1537
1636
|
end: r.end,
|
|
@@ -1541,22 +1640,22 @@ function Yt(t, e) {
|
|
|
1541
1640
|
}
|
|
1542
1641
|
return n;
|
|
1543
1642
|
}
|
|
1544
|
-
function
|
|
1643
|
+
function Ye(t) {
|
|
1545
1644
|
return t.kind === "if" || t.kind === "each";
|
|
1546
1645
|
}
|
|
1547
|
-
function
|
|
1548
|
-
const n =
|
|
1646
|
+
function tn(t, e) {
|
|
1647
|
+
const n = en(t, e);
|
|
1549
1648
|
if (n.length === 0)
|
|
1550
1649
|
return t.length > 0 ? [{ kind: "text", content: t }] : [];
|
|
1551
1650
|
const { nodes: r, nextIndex: i } = j(t, n, 0, n.length, e);
|
|
1552
1651
|
if (i < n.length) {
|
|
1553
1652
|
const s = n[i];
|
|
1554
1653
|
if (s.opener.kind === "endif")
|
|
1555
|
-
throw
|
|
1654
|
+
throw C(e, "endif without matching if");
|
|
1556
1655
|
if (s.opener.kind === "endeach")
|
|
1557
|
-
throw
|
|
1656
|
+
throw C(e, "endeach without matching each");
|
|
1558
1657
|
if (s.opener.kind === "else" || s.opener.kind === "else_if")
|
|
1559
|
-
throw
|
|
1658
|
+
throw C(e, "else without matching if");
|
|
1560
1659
|
}
|
|
1561
1660
|
return r;
|
|
1562
1661
|
}
|
|
@@ -1575,36 +1674,36 @@ function j(t, e, n, r, i, s = 0, o) {
|
|
|
1575
1674
|
kind: "text",
|
|
1576
1675
|
content: t.slice(h, u.start)
|
|
1577
1676
|
}), u.opener.kind === "if") {
|
|
1578
|
-
const
|
|
1579
|
-
c.push(
|
|
1677
|
+
const p = nn(t, e, l, r, i);
|
|
1678
|
+
c.push(p.node), h = p.endPos, l = p.nextIndex;
|
|
1580
1679
|
continue;
|
|
1581
1680
|
}
|
|
1582
1681
|
if (u.opener.kind === "each") {
|
|
1583
|
-
const
|
|
1584
|
-
c.push(
|
|
1682
|
+
const p = rn(t, e, l, r, i);
|
|
1683
|
+
c.push(p.node), h = p.endPos, l = p.nextIndex;
|
|
1585
1684
|
continue;
|
|
1586
1685
|
}
|
|
1587
1686
|
if (u.opener.kind === "else" || u.opener.kind === "else_if")
|
|
1588
|
-
throw
|
|
1687
|
+
throw C(i, "else without matching if");
|
|
1589
1688
|
if (u.opener.kind === "endif")
|
|
1590
|
-
throw
|
|
1689
|
+
throw C(i, "endif without matching if");
|
|
1591
1690
|
if (u.opener.kind === "endeach")
|
|
1592
|
-
throw
|
|
1691
|
+
throw C(i, "endeach without matching each");
|
|
1593
1692
|
l++;
|
|
1594
1693
|
}
|
|
1595
1694
|
return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
|
|
1596
1695
|
}
|
|
1597
|
-
function
|
|
1696
|
+
function nn(t, e, n, r, i) {
|
|
1598
1697
|
const s = e[n];
|
|
1599
1698
|
if (s.opener.kind !== "if")
|
|
1600
|
-
throw
|
|
1699
|
+
throw C(i, "expected if");
|
|
1601
1700
|
const o = [];
|
|
1602
1701
|
let a = n, c = s.end, h = 0;
|
|
1603
1702
|
for (; a < r; ) {
|
|
1604
1703
|
const l = e[a];
|
|
1605
1704
|
if (a === n) {
|
|
1606
1705
|
if (l.opener.kind !== "if")
|
|
1607
|
-
throw
|
|
1706
|
+
throw C(i, "expected if");
|
|
1608
1707
|
o.push({
|
|
1609
1708
|
kind: "if",
|
|
1610
1709
|
expr: l.opener.expr,
|
|
@@ -1613,7 +1712,7 @@ function Gt(t, e, n, r, i) {
|
|
|
1613
1712
|
}), a++;
|
|
1614
1713
|
continue;
|
|
1615
1714
|
}
|
|
1616
|
-
if (
|
|
1715
|
+
if (Ye(l.opener)) {
|
|
1617
1716
|
h++, a++;
|
|
1618
1717
|
continue;
|
|
1619
1718
|
}
|
|
@@ -1676,18 +1775,18 @@ function Gt(t, e, n, r, i) {
|
|
|
1676
1775
|
}
|
|
1677
1776
|
a++;
|
|
1678
1777
|
}
|
|
1679
|
-
throw
|
|
1778
|
+
throw C(i, "unclosed if block (missing endif)");
|
|
1680
1779
|
}
|
|
1681
|
-
function
|
|
1780
|
+
function rn(t, e, n, r, i) {
|
|
1682
1781
|
const s = e[n];
|
|
1683
1782
|
if (s.opener.kind !== "each")
|
|
1684
|
-
throw
|
|
1783
|
+
throw C(i, "expected each");
|
|
1685
1784
|
let o = n + 1;
|
|
1686
1785
|
const a = s.end;
|
|
1687
1786
|
let c = 0;
|
|
1688
1787
|
for (; o < r; ) {
|
|
1689
1788
|
const h = e[o];
|
|
1690
|
-
if (
|
|
1789
|
+
if (Ye(h.opener)) {
|
|
1691
1790
|
c++, o++;
|
|
1692
1791
|
continue;
|
|
1693
1792
|
}
|
|
@@ -1724,28 +1823,28 @@ function Jt(t, e, n, r, i) {
|
|
|
1724
1823
|
}
|
|
1725
1824
|
o++;
|
|
1726
1825
|
}
|
|
1727
|
-
throw
|
|
1826
|
+
throw C(i, "unclosed each block (missing endeach)");
|
|
1728
1827
|
}
|
|
1729
|
-
const
|
|
1730
|
-
class
|
|
1828
|
+
const Ce = 20;
|
|
1829
|
+
class sn {
|
|
1731
1830
|
depth = 0;
|
|
1732
1831
|
get currentDepth() {
|
|
1733
1832
|
return this.depth;
|
|
1734
1833
|
}
|
|
1735
1834
|
enter() {
|
|
1736
|
-
return this.depth >=
|
|
1835
|
+
return this.depth >= Ce ? { exceeded: !0, limit: Ce } : (this.depth++, { exceeded: !1, depth: this.depth });
|
|
1737
1836
|
}
|
|
1738
1837
|
exit() {
|
|
1739
1838
|
this.depth > 0 && this.depth--;
|
|
1740
1839
|
}
|
|
1741
1840
|
}
|
|
1742
|
-
function
|
|
1841
|
+
function on(t) {
|
|
1743
1842
|
return !!t;
|
|
1744
1843
|
}
|
|
1745
|
-
function
|
|
1844
|
+
function an(t) {
|
|
1746
1845
|
return t != null && typeof t[Symbol.iterator] == "function";
|
|
1747
1846
|
}
|
|
1748
|
-
function
|
|
1847
|
+
function Xe(t) {
|
|
1749
1848
|
return {
|
|
1750
1849
|
code: "nest_limit_exceeded",
|
|
1751
1850
|
message: "structure nest limit exceeded",
|
|
@@ -1753,38 +1852,38 @@ function Ye(t) {
|
|
|
1753
1852
|
details: { limit: 20 }
|
|
1754
1853
|
};
|
|
1755
1854
|
}
|
|
1756
|
-
function
|
|
1855
|
+
function pe(t) {
|
|
1757
1856
|
return t.startsWith(`
|
|
1758
1857
|
`) ? t.slice(1) : t;
|
|
1759
1858
|
}
|
|
1760
|
-
async function
|
|
1761
|
-
const n = e.path, r = e.warnings ?? [], i =
|
|
1762
|
-
return
|
|
1859
|
+
async function cn(t, e) {
|
|
1860
|
+
const n = e.path, r = e.warnings ?? [], i = tn(t, n), s = new sn();
|
|
1861
|
+
return me(i, e, s, r);
|
|
1763
1862
|
}
|
|
1764
|
-
async function
|
|
1863
|
+
async function me(t, e, n, r) {
|
|
1765
1864
|
const i = e.preserveHgComments === !0;
|
|
1766
1865
|
let s = "", o = !1;
|
|
1767
1866
|
for (const a of t) {
|
|
1768
|
-
let c = await
|
|
1769
|
-
o && (c =
|
|
1867
|
+
let c = await ln(a, e, n, r);
|
|
1868
|
+
o && (c = pe(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
|
|
1770
1869
|
}
|
|
1771
1870
|
return s;
|
|
1772
1871
|
}
|
|
1773
|
-
async function
|
|
1872
|
+
async function ln(t, e, n, r) {
|
|
1774
1873
|
switch (t.kind) {
|
|
1775
1874
|
case "text":
|
|
1776
1875
|
return t.content;
|
|
1777
1876
|
case "if":
|
|
1778
|
-
return
|
|
1877
|
+
return hn(t, e, n, r);
|
|
1779
1878
|
case "each":
|
|
1780
|
-
return
|
|
1879
|
+
return dn(t, e, n, r);
|
|
1781
1880
|
default:
|
|
1782
1881
|
return "";
|
|
1783
1882
|
}
|
|
1784
1883
|
}
|
|
1785
|
-
async function
|
|
1884
|
+
async function hn(t, e, n, r) {
|
|
1786
1885
|
if (n.enter().exceeded)
|
|
1787
|
-
return r.push(
|
|
1886
|
+
return r.push(Xe(e.path)), "";
|
|
1788
1887
|
try {
|
|
1789
1888
|
let s = -1;
|
|
1790
1889
|
for (let c = 0; c < t.branches.length; c++) {
|
|
@@ -1794,7 +1893,7 @@ async function sn(t, e, n, r) {
|
|
|
1794
1893
|
break;
|
|
1795
1894
|
}
|
|
1796
1895
|
const l = await y(h.expr, e);
|
|
1797
|
-
if (
|
|
1896
|
+
if (on(l)) {
|
|
1798
1897
|
s = c;
|
|
1799
1898
|
break;
|
|
1800
1899
|
}
|
|
@@ -1804,8 +1903,8 @@ async function sn(t, e, n, r) {
|
|
|
1804
1903
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1805
1904
|
const h = t.branches[c];
|
|
1806
1905
|
if (o && (a += h.opener.raw), c === s) {
|
|
1807
|
-
let l = await
|
|
1808
|
-
o || (l =
|
|
1906
|
+
let l = await me(h.body, e, n, r);
|
|
1907
|
+
o || (l = pe(l)), a += l;
|
|
1809
1908
|
}
|
|
1810
1909
|
}
|
|
1811
1910
|
return o && (a += t.closer.raw), a;
|
|
@@ -1813,24 +1912,24 @@ async function sn(t, e, n, r) {
|
|
|
1813
1912
|
n.exit();
|
|
1814
1913
|
}
|
|
1815
1914
|
}
|
|
1816
|
-
async function
|
|
1915
|
+
async function dn(t, e, n, r) {
|
|
1817
1916
|
if (n.enter().exceeded)
|
|
1818
|
-
return r.push(
|
|
1917
|
+
return r.push(Xe(e.path)), "";
|
|
1819
1918
|
try {
|
|
1820
1919
|
const s = await y(t.expr, e);
|
|
1821
|
-
if (!
|
|
1920
|
+
if (!an(s))
|
|
1822
1921
|
return "";
|
|
1823
1922
|
const o = e.preserveHgComments === !0;
|
|
1824
1923
|
let a = "";
|
|
1825
1924
|
for (const c of s) {
|
|
1826
1925
|
const h = { ...e.context, [t.item]: c };
|
|
1827
1926
|
o && (a += t.opener.raw);
|
|
1828
|
-
let l = await
|
|
1927
|
+
let l = await me(t.body, {
|
|
1829
1928
|
...e,
|
|
1830
1929
|
context: h
|
|
1831
1930
|
}, n, r);
|
|
1832
|
-
o || (l =
|
|
1833
|
-
const u =
|
|
1931
|
+
o || (l = pe(l));
|
|
1932
|
+
const u = {
|
|
1834
1933
|
path: e.path,
|
|
1835
1934
|
registry: e.registry,
|
|
1836
1935
|
loader: e.loader,
|
|
@@ -1840,8 +1939,17 @@ async function on(t, e, n, r) {
|
|
|
1840
1939
|
parentContext: e.parentContext ?? e.context,
|
|
1841
1940
|
preserveHgComments: e.preserveHgComments,
|
|
1842
1941
|
constrainToRoot: e.constrainToRoot
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1942
|
+
};
|
|
1943
|
+
let p = await Pe(
|
|
1944
|
+
l,
|
|
1945
|
+
h,
|
|
1946
|
+
u
|
|
1947
|
+
);
|
|
1948
|
+
p = await Ke(
|
|
1949
|
+
p,
|
|
1950
|
+
h,
|
|
1951
|
+
u
|
|
1952
|
+
), a += p, o && (a += t.closer.raw);
|
|
1845
1953
|
}
|
|
1846
1954
|
return a;
|
|
1847
1955
|
} finally {
|
|
@@ -1849,7 +1957,7 @@ async function on(t, e, n, r) {
|
|
|
1849
1957
|
}
|
|
1850
1958
|
}
|
|
1851
1959
|
function te(t, e, n, r, i = !1, s = !1) {
|
|
1852
|
-
return
|
|
1960
|
+
return D(e) ? e : Z(e, {
|
|
1853
1961
|
rootDir: t,
|
|
1854
1962
|
fromPath: r,
|
|
1855
1963
|
documentPath: n,
|
|
@@ -1857,14 +1965,14 @@ function te(t, e, n, r, i = !1, s = !1) {
|
|
|
1857
1965
|
hyogenPath: s
|
|
1858
1966
|
});
|
|
1859
1967
|
}
|
|
1860
|
-
function
|
|
1968
|
+
function Ge(t) {
|
|
1861
1969
|
let e = 0;
|
|
1862
1970
|
for (let n = t.length - 1; n >= 0 && t[n] === `
|
|
1863
1971
|
`; n--)
|
|
1864
1972
|
e++;
|
|
1865
1973
|
return e;
|
|
1866
1974
|
}
|
|
1867
|
-
function
|
|
1975
|
+
function Je(t) {
|
|
1868
1976
|
let e = 0;
|
|
1869
1977
|
for (; e < t.length && t[e] === `
|
|
1870
1978
|
`; )
|
|
@@ -1872,22 +1980,22 @@ function Ge(t) {
|
|
|
1872
1980
|
return e;
|
|
1873
1981
|
}
|
|
1874
1982
|
function A(t, e) {
|
|
1875
|
-
const n =
|
|
1983
|
+
const n = Ge(t), r = Je(e), i = Math.max(n, r);
|
|
1876
1984
|
return t.slice(0, t.length - n) + `
|
|
1877
1985
|
`.repeat(i) + e.slice(r);
|
|
1878
1986
|
}
|
|
1879
|
-
function
|
|
1880
|
-
const n =
|
|
1987
|
+
function ge(t, e) {
|
|
1988
|
+
const n = Ge(t), r = Je(e);
|
|
1881
1989
|
return n + r - Math.max(n, r);
|
|
1882
1990
|
}
|
|
1883
|
-
function
|
|
1991
|
+
function $e(t, e, n) {
|
|
1884
1992
|
const r = t.indexOf(e);
|
|
1885
1993
|
if (r < 0)
|
|
1886
1994
|
return t;
|
|
1887
1995
|
const i = t.slice(0, r), s = t.slice(r + e.length);
|
|
1888
1996
|
return A(A(i, n), s);
|
|
1889
1997
|
}
|
|
1890
|
-
async function
|
|
1998
|
+
async function un(t) {
|
|
1891
1999
|
let e = t.source;
|
|
1892
2000
|
for (const n of t.directives) {
|
|
1893
2001
|
const r = te(
|
|
@@ -1914,13 +2022,13 @@ async function an(t) {
|
|
|
1914
2022
|
from: i.from,
|
|
1915
2023
|
via: "include"
|
|
1916
2024
|
}
|
|
1917
|
-
}), e =
|
|
2025
|
+
}), e = $e(e, n.marker, "");
|
|
1918
2026
|
continue;
|
|
1919
2027
|
}
|
|
1920
2028
|
t.visitStack.push(r);
|
|
1921
2029
|
}
|
|
1922
2030
|
try {
|
|
1923
|
-
const i = await t.loader(r), s = await
|
|
2031
|
+
const i = await t.loader(r), s = await Yn(i, {
|
|
1924
2032
|
context: t.context,
|
|
1925
2033
|
loader: t.loader,
|
|
1926
2034
|
root: t.root,
|
|
@@ -1932,14 +2040,14 @@ async function an(t) {
|
|
|
1932
2040
|
registry: t.registry
|
|
1933
2041
|
}), o = e.indexOf(n.marker), a = o >= 0 ? e.slice(0, o) : e, c = Ze(a), h = qe(s, c), l = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1934
2042
|
${h}` : h;
|
|
1935
|
-
e =
|
|
2043
|
+
e = $e(e, n.marker, l);
|
|
1936
2044
|
} finally {
|
|
1937
2045
|
t.visitStack?.pop();
|
|
1938
2046
|
}
|
|
1939
2047
|
}
|
|
1940
2048
|
return e;
|
|
1941
2049
|
}
|
|
1942
|
-
class
|
|
2050
|
+
class Qe {
|
|
1943
2051
|
stack = [];
|
|
1944
2052
|
check(e) {
|
|
1945
2053
|
return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
|
|
@@ -1955,7 +2063,7 @@ class Je {
|
|
|
1955
2063
|
this.stack.pop();
|
|
1956
2064
|
}
|
|
1957
2065
|
}
|
|
1958
|
-
async function
|
|
2066
|
+
async function fn(t, e, n = {}) {
|
|
1959
2067
|
const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await y(t.expr, { context: e, path: r });
|
|
1960
2068
|
switch (t.kind) {
|
|
1961
2069
|
case "const": {
|
|
@@ -1996,7 +2104,7 @@ async function cn(t, e, n = {}) {
|
|
|
1996
2104
|
}
|
|
1997
2105
|
}
|
|
1998
2106
|
}
|
|
1999
|
-
function
|
|
2107
|
+
function We(t) {
|
|
2000
2108
|
return !t;
|
|
2001
2109
|
}
|
|
2002
2110
|
async function F(t, e, n = {}) {
|
|
@@ -2005,7 +2113,7 @@ async function F(t, e, n = {}) {
|
|
|
2005
2113
|
case "const":
|
|
2006
2114
|
case "let":
|
|
2007
2115
|
case "assign": {
|
|
2008
|
-
await
|
|
2116
|
+
await fn(t, e, { path: r, constBindings: i }), s?.(t.name);
|
|
2009
2117
|
return;
|
|
2010
2118
|
}
|
|
2011
2119
|
case "update": {
|
|
@@ -2079,7 +2187,7 @@ async function F(t, e, n = {}) {
|
|
|
2079
2187
|
context: e,
|
|
2080
2188
|
path: r
|
|
2081
2189
|
});
|
|
2082
|
-
if (
|
|
2190
|
+
if (We(a))
|
|
2083
2191
|
break;
|
|
2084
2192
|
for (const c of t.body)
|
|
2085
2193
|
await F(c, e, n);
|
|
@@ -2095,18 +2203,18 @@ async function F(t, e, n = {}) {
|
|
|
2095
2203
|
context: e,
|
|
2096
2204
|
path: r
|
|
2097
2205
|
});
|
|
2098
|
-
if (
|
|
2206
|
+
if (We(a))
|
|
2099
2207
|
break;
|
|
2100
2208
|
} while (!0);
|
|
2101
2209
|
return;
|
|
2102
2210
|
}
|
|
2103
2211
|
}
|
|
2104
2212
|
}
|
|
2105
|
-
async function
|
|
2213
|
+
async function Te(t, e, n = {}) {
|
|
2106
2214
|
for (const r of t)
|
|
2107
2215
|
await F(r, e, n);
|
|
2108
2216
|
}
|
|
2109
|
-
const
|
|
2217
|
+
const pn = /* @__PURE__ */ new Set([
|
|
2110
2218
|
"if",
|
|
2111
2219
|
"else",
|
|
2112
2220
|
"endif",
|
|
@@ -2125,10 +2233,10 @@ const ln = /* @__PURE__ */ new Set([
|
|
|
2125
2233
|
"as",
|
|
2126
2234
|
"echo"
|
|
2127
2235
|
]);
|
|
2128
|
-
function
|
|
2129
|
-
return
|
|
2236
|
+
function et(t) {
|
|
2237
|
+
return pn.has(t);
|
|
2130
2238
|
}
|
|
2131
|
-
function
|
|
2239
|
+
function we(t) {
|
|
2132
2240
|
let e = "", n = 0, r = null;
|
|
2133
2241
|
for (; n < t.length; ) {
|
|
2134
2242
|
const i = t[n];
|
|
@@ -2168,11 +2276,11 @@ function k(t, e) {
|
|
|
2168
2276
|
details: { message: e }
|
|
2169
2277
|
});
|
|
2170
2278
|
}
|
|
2171
|
-
function
|
|
2172
|
-
const n =
|
|
2279
|
+
function Ae(t, e) {
|
|
2280
|
+
const n = we(t).trim();
|
|
2173
2281
|
if (n.length === 0)
|
|
2174
2282
|
throw k(e, "empty statement block");
|
|
2175
|
-
const r = new
|
|
2283
|
+
const r = new xe(n, e), i = r.parseStatementList();
|
|
2176
2284
|
if (r.skipWhitespace(), r.hasMore())
|
|
2177
2285
|
throw k(
|
|
2178
2286
|
e,
|
|
@@ -2183,10 +2291,10 @@ function We(t, e) {
|
|
|
2183
2291
|
return i;
|
|
2184
2292
|
}
|
|
2185
2293
|
function V(t) {
|
|
2186
|
-
const e =
|
|
2294
|
+
const e = we(t).trim();
|
|
2187
2295
|
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);
|
|
2188
2296
|
}
|
|
2189
|
-
class
|
|
2297
|
+
class xe {
|
|
2190
2298
|
constructor(e, n) {
|
|
2191
2299
|
this.input = e, this.path = n;
|
|
2192
2300
|
}
|
|
@@ -2292,7 +2400,7 @@ class ge {
|
|
|
2292
2400
|
parseFor() {
|
|
2293
2401
|
if (this.skipWhitespace(), !this.match("("))
|
|
2294
2402
|
throw k(this.path, "expected '(' after for");
|
|
2295
|
-
const e = this.readBalanced(")"), n =
|
|
2403
|
+
const e = this.readBalanced(")"), n = mn(e);
|
|
2296
2404
|
if (n.length !== 3)
|
|
2297
2405
|
throw k(
|
|
2298
2406
|
this.path,
|
|
@@ -2331,7 +2439,7 @@ class ge {
|
|
|
2331
2439
|
return { kind: "do_while", body: e, cond: r };
|
|
2332
2440
|
}
|
|
2333
2441
|
parseClauseStatement(e) {
|
|
2334
|
-
const n = new
|
|
2442
|
+
const n = new xe(e, this.path), r = n.parseSimpleStatement();
|
|
2335
2443
|
if (n.skipWhitespace(), n.hasMore())
|
|
2336
2444
|
throw k(
|
|
2337
2445
|
this.path,
|
|
@@ -2340,7 +2448,7 @@ class ge {
|
|
|
2340
2448
|
return r;
|
|
2341
2449
|
}
|
|
2342
2450
|
assertAssignableName(e) {
|
|
2343
|
-
if (
|
|
2451
|
+
if (et(e))
|
|
2344
2452
|
throw k(
|
|
2345
2453
|
this.path,
|
|
2346
2454
|
`reserved word cannot be used as identifier: ${e}`
|
|
@@ -2447,7 +2555,7 @@ class ge {
|
|
|
2447
2555
|
return this.input.slice(e, this.index);
|
|
2448
2556
|
}
|
|
2449
2557
|
}
|
|
2450
|
-
function
|
|
2558
|
+
function mn(t) {
|
|
2451
2559
|
const e = [];
|
|
2452
2560
|
let n = "", r = 0, i = null;
|
|
2453
2561
|
for (let s = 0; s < t.length; s++) {
|
|
@@ -2505,8 +2613,8 @@ function B(t, e) {
|
|
|
2505
2613
|
});
|
|
2506
2614
|
return { path: i };
|
|
2507
2615
|
}
|
|
2508
|
-
function
|
|
2509
|
-
const n =
|
|
2616
|
+
function gn(t, e) {
|
|
2617
|
+
const n = $(t);
|
|
2510
2618
|
if (n.length === 0) return null;
|
|
2511
2619
|
const r = n[0], i = B(r, e);
|
|
2512
2620
|
if (!i) return null;
|
|
@@ -2526,8 +2634,8 @@ function dn(t, e) {
|
|
|
2526
2634
|
function P(t) {
|
|
2527
2635
|
return /^toc(\(.*\))?$/.test(t.trim());
|
|
2528
2636
|
}
|
|
2529
|
-
function
|
|
2530
|
-
const n =
|
|
2637
|
+
function wn(t, e) {
|
|
2638
|
+
const n = $(t);
|
|
2531
2639
|
if (n.length !== 1)
|
|
2532
2640
|
throw d({
|
|
2533
2641
|
code: "parse_error",
|
|
@@ -2557,14 +2665,14 @@ function un(t, e) {
|
|
|
2557
2665
|
});
|
|
2558
2666
|
return { maxLevel: Number(s) };
|
|
2559
2667
|
}
|
|
2560
|
-
async function
|
|
2668
|
+
async function xn(t, e = {}) {
|
|
2561
2669
|
const n = e.path, r = e.context ?? {};
|
|
2562
|
-
if (
|
|
2670
|
+
if (de(t))
|
|
2563
2671
|
throw d({
|
|
2564
2672
|
code: "parse_error",
|
|
2565
2673
|
path: n,
|
|
2566
2674
|
details: {
|
|
2567
|
-
message:
|
|
2675
|
+
message: ue(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2568
2676
|
}
|
|
2569
2677
|
});
|
|
2570
2678
|
const i = W(t);
|
|
@@ -2575,31 +2683,31 @@ async function fn(t, e = {}) {
|
|
|
2575
2683
|
};
|
|
2576
2684
|
let c = t, h = 0;
|
|
2577
2685
|
for (const l of i) {
|
|
2578
|
-
const u =
|
|
2579
|
-
if (u.length === 1 &&
|
|
2686
|
+
const u = $(l.inner);
|
|
2687
|
+
if (u.length === 1 && fe(u[0]) || u.length === 1 && P(u[0]) || u.length === 1 && /^include\s+/i.test(u[0]) || u.length === 1 && /^component\s+/i.test(u[0]))
|
|
2580
2688
|
continue;
|
|
2581
|
-
const
|
|
2582
|
-
if (
|
|
2583
|
-
if (
|
|
2584
|
-
const
|
|
2585
|
-
|
|
2689
|
+
const p = gn(l.inner, n);
|
|
2690
|
+
if (p) {
|
|
2691
|
+
if (p.declarationsSource.trim().length > 0) {
|
|
2692
|
+
const N = Ae(
|
|
2693
|
+
p.declarationsSource,
|
|
2586
2694
|
n
|
|
2587
2695
|
);
|
|
2588
|
-
await
|
|
2696
|
+
await Te(N, r, {
|
|
2589
2697
|
path: n,
|
|
2590
2698
|
constBindings: s,
|
|
2591
2699
|
onUpdate: a
|
|
2592
2700
|
});
|
|
2593
2701
|
}
|
|
2594
|
-
const
|
|
2595
|
-
extend ${
|
|
2702
|
+
const E = l.start - h, L = l.end - h, U = `<!--@hg
|
|
2703
|
+
extend ${p.path}
|
|
2596
2704
|
@endhg-->`;
|
|
2597
|
-
c = c.slice(0,
|
|
2705
|
+
c = c.slice(0, E) + U + c.slice(L), h += l.raw.length - U.length;
|
|
2598
2706
|
continue;
|
|
2599
2707
|
}
|
|
2600
|
-
const
|
|
2708
|
+
const x = u.join(`
|
|
2601
2709
|
`);
|
|
2602
|
-
if (!V(
|
|
2710
|
+
if (!V(x)) {
|
|
2603
2711
|
if (u.length === 1)
|
|
2604
2712
|
continue;
|
|
2605
2713
|
throw d({
|
|
@@ -2608,25 +2716,25 @@ extend ${g.path}
|
|
|
2608
2716
|
details: { message: `unsupported hyogen directive: ${u[0]}` }
|
|
2609
2717
|
});
|
|
2610
2718
|
}
|
|
2611
|
-
const
|
|
2612
|
-
await
|
|
2719
|
+
const m = Ae(x, n), w = [];
|
|
2720
|
+
await Te(m, r, {
|
|
2613
2721
|
path: n,
|
|
2614
2722
|
constBindings: s,
|
|
2615
2723
|
onUpdate: a,
|
|
2616
|
-
echoChunks:
|
|
2724
|
+
echoChunks: w
|
|
2617
2725
|
});
|
|
2618
|
-
const
|
|
2619
|
-
if (
|
|
2620
|
-
const
|
|
2621
|
-
c = T +
|
|
2726
|
+
const _ = l.start - h, K = l.end - h, T = c.slice(0, _), b = c.slice(K);
|
|
2727
|
+
if (w.length > 0) {
|
|
2728
|
+
const E = w.join("");
|
|
2729
|
+
c = T + E + b, h += l.raw.length - E.length;
|
|
2622
2730
|
} else
|
|
2623
|
-
c = A(T, b), h += l.raw.length +
|
|
2731
|
+
c = A(T, b), h += l.raw.length + ge(T, b);
|
|
2624
2732
|
}
|
|
2625
2733
|
return { source: c, context: r, declarationUpdates: o };
|
|
2626
2734
|
}
|
|
2627
|
-
const
|
|
2628
|
-
function
|
|
2629
|
-
const n =
|
|
2735
|
+
const kn = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
|
|
2736
|
+
function tt(t, e) {
|
|
2737
|
+
const n = le(t).trim();
|
|
2630
2738
|
if (n.length === 0)
|
|
2631
2739
|
throw d({
|
|
2632
2740
|
code: "parse_error",
|
|
@@ -2649,7 +2757,7 @@ function et(t, e) {
|
|
|
2649
2757
|
path: e,
|
|
2650
2758
|
details: { message: "include and component cannot coexist in one block" }
|
|
2651
2759
|
});
|
|
2652
|
-
const s =
|
|
2760
|
+
const s = kn.exec(i);
|
|
2653
2761
|
if (!s)
|
|
2654
2762
|
throw d({
|
|
2655
2763
|
code: "parse_error",
|
|
@@ -2669,8 +2777,8 @@ function et(t, e) {
|
|
|
2669
2777
|
alias: s[2]
|
|
2670
2778
|
};
|
|
2671
2779
|
}
|
|
2672
|
-
function
|
|
2673
|
-
const n =
|
|
2780
|
+
function nt(t, e) {
|
|
2781
|
+
const n = le(t).trim();
|
|
2674
2782
|
if (n.length === 0)
|
|
2675
2783
|
throw d({
|
|
2676
2784
|
code: "parse_error",
|
|
@@ -2694,16 +2802,16 @@ function tt(t, e) {
|
|
|
2694
2802
|
});
|
|
2695
2803
|
}
|
|
2696
2804
|
function ne(t) {
|
|
2697
|
-
const e =
|
|
2805
|
+
const e = we(t).trim();
|
|
2698
2806
|
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
|
|
2699
2807
|
}
|
|
2700
|
-
const
|
|
2701
|
-
function
|
|
2702
|
-
return `${
|
|
2808
|
+
const yn = "\0HYOGEN_INCLUDE_";
|
|
2809
|
+
function bn(t) {
|
|
2810
|
+
return `${yn}${t}\0`;
|
|
2703
2811
|
}
|
|
2704
|
-
function
|
|
2705
|
-
const n =
|
|
2706
|
-
if (n.length === 1 &&
|
|
2812
|
+
function vn(t, e) {
|
|
2813
|
+
const n = $(t);
|
|
2814
|
+
if (n.length === 1 && fe(n[0]))
|
|
2707
2815
|
return { kind: "control" };
|
|
2708
2816
|
if (n.length === 1 && P(n[0]) || n.length === 1 && (ne(n[0]) || V(n[0])))
|
|
2709
2817
|
return null;
|
|
@@ -2721,9 +2829,9 @@ function wn(t, e) {
|
|
|
2721
2829
|
details: { message: "include and component cannot coexist in one block" }
|
|
2722
2830
|
});
|
|
2723
2831
|
if (/^include\s+/i.test(r))
|
|
2724
|
-
return
|
|
2832
|
+
return nt(t, e);
|
|
2725
2833
|
if (/^component\s+/i.test(r))
|
|
2726
|
-
return
|
|
2834
|
+
return tt(t, e);
|
|
2727
2835
|
if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
|
|
2728
2836
|
return null;
|
|
2729
2837
|
throw d({
|
|
@@ -2732,14 +2840,14 @@ function wn(t, e) {
|
|
|
2732
2840
|
details: { message: `unsupported hyogen directive: ${r}` }
|
|
2733
2841
|
});
|
|
2734
2842
|
}
|
|
2735
|
-
function
|
|
2843
|
+
function _n(t, e = {}) {
|
|
2736
2844
|
const n = e.path;
|
|
2737
|
-
if (
|
|
2845
|
+
if (de(t))
|
|
2738
2846
|
throw d({
|
|
2739
2847
|
code: "parse_error",
|
|
2740
2848
|
path: n,
|
|
2741
2849
|
details: {
|
|
2742
|
-
message:
|
|
2850
|
+
message: ue(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2743
2851
|
}
|
|
2744
2852
|
});
|
|
2745
2853
|
const r = W(t);
|
|
@@ -2748,7 +2856,7 @@ function xn(t, e = {}) {
|
|
|
2748
2856
|
const i = [];
|
|
2749
2857
|
let s = t, o = 0, a = 0;
|
|
2750
2858
|
for (const c of r) {
|
|
2751
|
-
const h =
|
|
2859
|
+
const h = vn(c.inner, n);
|
|
2752
2860
|
if (!h || h.kind === "control")
|
|
2753
2861
|
continue;
|
|
2754
2862
|
const l = c.start - o, u = c.end - o;
|
|
@@ -2762,21 +2870,21 @@ function xn(t, e = {}) {
|
|
|
2762
2870
|
Object.keys(e.context ?? {}),
|
|
2763
2871
|
n
|
|
2764
2872
|
);
|
|
2765
|
-
const
|
|
2766
|
-
s = A(
|
|
2873
|
+
const x = s.slice(0, l), m = s.slice(u);
|
|
2874
|
+
s = A(x, m), o += c.raw.length + ge(x, m);
|
|
2767
2875
|
continue;
|
|
2768
2876
|
}
|
|
2769
|
-
const
|
|
2770
|
-
i.push({ ...h, marker:
|
|
2877
|
+
const p = bn(a++);
|
|
2878
|
+
i.push({ ...h, marker: p, raw: c.raw }), s = s.slice(0, l) + p + s.slice(u), o += c.raw.length - p.length;
|
|
2771
2879
|
}
|
|
2772
2880
|
return { source: s, directives: i };
|
|
2773
2881
|
}
|
|
2774
|
-
function
|
|
2882
|
+
function Sn(t, e) {
|
|
2775
2883
|
return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
|
|
2776
2884
|
` : `${e.rawFrontMatter}
|
|
2777
2885
|
${t}`;
|
|
2778
2886
|
}
|
|
2779
|
-
function
|
|
2887
|
+
function En(t, e = !1) {
|
|
2780
2888
|
if (e)
|
|
2781
2889
|
return t;
|
|
2782
2890
|
const n = W(t);
|
|
@@ -2785,16 +2893,16 @@ function yn(t, e = !1) {
|
|
|
2785
2893
|
let r = t, i = 0;
|
|
2786
2894
|
for (const s of n) {
|
|
2787
2895
|
const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
|
|
2788
|
-
r = A(c, h), i += s.raw.length +
|
|
2896
|
+
r = A(c, h), i += s.raw.length + ge(c, h);
|
|
2789
2897
|
}
|
|
2790
2898
|
return r;
|
|
2791
2899
|
}
|
|
2792
|
-
const
|
|
2793
|
-
function
|
|
2900
|
+
const Cn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
2901
|
+
function $n(t, e) {
|
|
2794
2902
|
const n = t.trim();
|
|
2795
2903
|
if (n === "endblock")
|
|
2796
2904
|
return { kind: "endblock" };
|
|
2797
|
-
const r =
|
|
2905
|
+
const r = Cn.exec(n);
|
|
2798
2906
|
if (!r)
|
|
2799
2907
|
throw d({
|
|
2800
2908
|
code: "parse_error",
|
|
@@ -2802,7 +2910,7 @@ function vn(t, e) {
|
|
|
2802
2910
|
details: { message: "invalid block directive" }
|
|
2803
2911
|
});
|
|
2804
2912
|
const i = r[1];
|
|
2805
|
-
if (
|
|
2913
|
+
if (et(i))
|
|
2806
2914
|
throw d({
|
|
2807
2915
|
code: "parse_error",
|
|
2808
2916
|
path: e,
|
|
@@ -2810,12 +2918,12 @@ function vn(t, e) {
|
|
|
2810
2918
|
});
|
|
2811
2919
|
return { kind: "block", name: i };
|
|
2812
2920
|
}
|
|
2813
|
-
function
|
|
2921
|
+
function Le(t, e) {
|
|
2814
2922
|
const { path: n, mode: r, hasExtend: i = !1 } = e, s = W(t);
|
|
2815
2923
|
if (s.length === 0) return [];
|
|
2816
2924
|
const o = [], a = [], c = /* @__PURE__ */ new Set();
|
|
2817
2925
|
for (const h of s) {
|
|
2818
|
-
const l =
|
|
2926
|
+
const l = $(h.inner);
|
|
2819
2927
|
if (l.length !== 1) continue;
|
|
2820
2928
|
const u = l[0];
|
|
2821
2929
|
if (!(u === "endblock" || u.startsWith("block "))) continue;
|
|
@@ -2825,20 +2933,20 @@ function Te(t, e) {
|
|
|
2825
2933
|
path: n,
|
|
2826
2934
|
details: { message: "orphan block without extend" }
|
|
2827
2935
|
});
|
|
2828
|
-
const
|
|
2829
|
-
if (
|
|
2830
|
-
const
|
|
2831
|
-
if (!
|
|
2936
|
+
const x = $n(u, n);
|
|
2937
|
+
if (x.kind === "endblock") {
|
|
2938
|
+
const m = a.pop();
|
|
2939
|
+
if (!m)
|
|
2832
2940
|
throw d({
|
|
2833
2941
|
code: "parse_error",
|
|
2834
2942
|
path: n,
|
|
2835
2943
|
details: { message: "endblock without matching block opener" }
|
|
2836
2944
|
});
|
|
2837
|
-
const
|
|
2945
|
+
const w = t.slice(m.openerEnd, h.start);
|
|
2838
2946
|
o.push({
|
|
2839
|
-
name:
|
|
2840
|
-
body:
|
|
2841
|
-
start:
|
|
2947
|
+
name: m.name,
|
|
2948
|
+
body: w,
|
|
2949
|
+
start: m.start,
|
|
2842
2950
|
end: h.end
|
|
2843
2951
|
});
|
|
2844
2952
|
continue;
|
|
@@ -2849,14 +2957,14 @@ function Te(t, e) {
|
|
|
2849
2957
|
path: n,
|
|
2850
2958
|
details: { message: "nested block structures are not supported" }
|
|
2851
2959
|
});
|
|
2852
|
-
if (c.has(
|
|
2960
|
+
if (c.has(x.name))
|
|
2853
2961
|
throw d({
|
|
2854
2962
|
code: "parse_error",
|
|
2855
2963
|
path: n,
|
|
2856
|
-
details: { message: `duplicate block: ${
|
|
2964
|
+
details: { message: `duplicate block: ${x.name}` }
|
|
2857
2965
|
});
|
|
2858
|
-
c.add(
|
|
2859
|
-
name:
|
|
2966
|
+
c.add(x.name), a.push({
|
|
2967
|
+
name: x.name,
|
|
2860
2968
|
openerEnd: h.end,
|
|
2861
2969
|
start: h.start
|
|
2862
2970
|
});
|
|
@@ -2869,20 +2977,20 @@ function Te(t, e) {
|
|
|
2869
2977
|
});
|
|
2870
2978
|
return o;
|
|
2871
2979
|
}
|
|
2872
|
-
function
|
|
2980
|
+
function Oe(t) {
|
|
2873
2981
|
const e = W(t), n = [];
|
|
2874
2982
|
for (const r of e) {
|
|
2875
|
-
const i =
|
|
2983
|
+
const i = $(r.inner);
|
|
2876
2984
|
if (i.length === 0) continue;
|
|
2877
2985
|
const s = B(i[0]);
|
|
2878
2986
|
s && n.push({ path: s.path, start: r.start });
|
|
2879
2987
|
}
|
|
2880
2988
|
return n;
|
|
2881
2989
|
}
|
|
2882
|
-
function
|
|
2990
|
+
function Wn(t) {
|
|
2883
2991
|
const e = W(t);
|
|
2884
2992
|
for (const n of e) {
|
|
2885
|
-
const r =
|
|
2993
|
+
const r = $(n.inner);
|
|
2886
2994
|
if (r.length !== 1) continue;
|
|
2887
2995
|
const i = r[0];
|
|
2888
2996
|
if (i === "endblock" || i.startsWith("block ")) return !0;
|
|
@@ -2892,14 +3000,14 @@ function _n(t) {
|
|
|
2892
3000
|
function ee(t) {
|
|
2893
3001
|
return t.map((e) => e.body).join("");
|
|
2894
3002
|
}
|
|
2895
|
-
function
|
|
3003
|
+
function Tn(t, e, n) {
|
|
2896
3004
|
const r = [...e].sort((o, a) => o.start - a.start), i = [];
|
|
2897
3005
|
let s = 0;
|
|
2898
3006
|
for (const o of r)
|
|
2899
3007
|
i.push(t.slice(s, o.start)), i.push(n.get(o.name) ?? o.body), s = o.end;
|
|
2900
3008
|
return i.push(t.slice(s)), i.reduce((o, a) => A(o, a));
|
|
2901
3009
|
}
|
|
2902
|
-
function
|
|
3010
|
+
function An(t) {
|
|
2903
3011
|
if (t instanceof Error && "code" in t && "details" in t) {
|
|
2904
3012
|
const e = t;
|
|
2905
3013
|
if (e.code === "file_not_found" && e.details && e.details.via === "include")
|
|
@@ -2907,7 +3015,7 @@ function En(t) {
|
|
|
2907
3015
|
}
|
|
2908
3016
|
return { errorToThrow: t, adjusted: !1 };
|
|
2909
3017
|
}
|
|
2910
|
-
async function
|
|
3018
|
+
async function Ln(t, e) {
|
|
2911
3019
|
const {
|
|
2912
3020
|
path: n,
|
|
2913
3021
|
context: r,
|
|
@@ -2918,9 +3026,9 @@ async function Cn(t, e) {
|
|
|
2918
3026
|
visitStack: c,
|
|
2919
3027
|
warnings: h,
|
|
2920
3028
|
inComponent: l = !1
|
|
2921
|
-
} = e, u =
|
|
3029
|
+
} = e, u = Oe(t);
|
|
2922
3030
|
if (u.length === 0) {
|
|
2923
|
-
if (
|
|
3031
|
+
if (Wn(t))
|
|
2924
3032
|
throw d({
|
|
2925
3033
|
code: "parse_error",
|
|
2926
3034
|
path: n,
|
|
@@ -2928,13 +3036,13 @@ async function Cn(t, e) {
|
|
|
2928
3036
|
});
|
|
2929
3037
|
return { source: t, context: v(r, i) };
|
|
2930
3038
|
}
|
|
2931
|
-
const
|
|
2932
|
-
if (!
|
|
3039
|
+
const x = W(t)[0];
|
|
3040
|
+
if (!x)
|
|
2933
3041
|
return { source: t, context: v(r, i) };
|
|
2934
3042
|
if (!s)
|
|
2935
3043
|
throw new Error("loader is required when processing extend directives");
|
|
2936
|
-
const
|
|
2937
|
-
if (!(
|
|
3044
|
+
const m = $(x.inner);
|
|
3045
|
+
if (!(m.length > 0 ? B(m[0]) : null))
|
|
2938
3046
|
throw d({
|
|
2939
3047
|
code: "parse_error",
|
|
2940
3048
|
path: n,
|
|
@@ -2946,7 +3054,7 @@ async function Cn(t, e) {
|
|
|
2946
3054
|
path: n,
|
|
2947
3055
|
details: { message: "multiple extend directives are not supported" }
|
|
2948
3056
|
});
|
|
2949
|
-
const
|
|
3057
|
+
const _ = Le(t, {
|
|
2950
3058
|
path: n,
|
|
2951
3059
|
mode: "child",
|
|
2952
3060
|
hasExtend: !0
|
|
@@ -2958,7 +3066,7 @@ async function Cn(t, e) {
|
|
|
2958
3066
|
path: n,
|
|
2959
3067
|
details: { path: n }
|
|
2960
3068
|
}), {
|
|
2961
|
-
source: ee(
|
|
3069
|
+
source: ee(_),
|
|
2962
3070
|
context: v(r, i)
|
|
2963
3071
|
};
|
|
2964
3072
|
const K = u[0].path, T = n, b = te(
|
|
@@ -2971,19 +3079,19 @@ async function Cn(t, e) {
|
|
|
2971
3079
|
);
|
|
2972
3080
|
T && c.push(T);
|
|
2973
3081
|
try {
|
|
2974
|
-
const
|
|
2975
|
-
if (
|
|
3082
|
+
const E = T ? c.check(b) : { circular: !1 };
|
|
3083
|
+
if (E.circular)
|
|
2976
3084
|
return h?.push({
|
|
2977
3085
|
code: "circular_include",
|
|
2978
3086
|
message: H("circular_include", {
|
|
2979
3087
|
path: b,
|
|
2980
|
-
from:
|
|
3088
|
+
from: E.from,
|
|
2981
3089
|
via: "extend"
|
|
2982
3090
|
}),
|
|
2983
3091
|
path: n,
|
|
2984
|
-
details: { path: b, from:
|
|
3092
|
+
details: { path: b, from: E.from, via: "extend" }
|
|
2985
3093
|
}), {
|
|
2986
|
-
source: ee(
|
|
3094
|
+
source: ee(_),
|
|
2987
3095
|
context: v(r, i)
|
|
2988
3096
|
};
|
|
2989
3097
|
c.push(b);
|
|
@@ -2991,12 +3099,12 @@ async function Cn(t, e) {
|
|
|
2991
3099
|
const L = await s(b);
|
|
2992
3100
|
if (L === void 0)
|
|
2993
3101
|
throw new Error("loader returned undefined");
|
|
2994
|
-
const { context: U, body:
|
|
3102
|
+
const { context: U, body: N } = q(
|
|
2995
3103
|
L,
|
|
2996
3104
|
b
|
|
2997
|
-
),
|
|
2998
|
-
if (
|
|
2999
|
-
const z =
|
|
3105
|
+
), ye = Oe(N);
|
|
3106
|
+
if (ye.length > 0) {
|
|
3107
|
+
const z = ye[0].path, Y = te(
|
|
3000
3108
|
o,
|
|
3001
3109
|
z,
|
|
3002
3110
|
b,
|
|
@@ -3015,7 +3123,7 @@ async function Cn(t, e) {
|
|
|
3015
3123
|
path: n,
|
|
3016
3124
|
details: { path: Y, from: X.from, via: "extend" }
|
|
3017
3125
|
}), {
|
|
3018
|
-
source: ee(
|
|
3126
|
+
source: ee(_),
|
|
3019
3127
|
context: v(r, i)
|
|
3020
3128
|
};
|
|
3021
3129
|
throw d({
|
|
@@ -3024,32 +3132,32 @@ async function Cn(t, e) {
|
|
|
3024
3132
|
details: { message: "layout extend is not supported" }
|
|
3025
3133
|
});
|
|
3026
3134
|
}
|
|
3027
|
-
const
|
|
3135
|
+
const it = Le(N, {
|
|
3028
3136
|
path: b,
|
|
3029
3137
|
mode: "layout"
|
|
3030
|
-
}),
|
|
3031
|
-
|
|
3032
|
-
),
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
),
|
|
3138
|
+
}), st = new Map(
|
|
3139
|
+
_.map((z) => [z.name, z.body])
|
|
3140
|
+
), ot = Tn(
|
|
3141
|
+
N,
|
|
3142
|
+
it,
|
|
3143
|
+
st
|
|
3144
|
+
), at = v(
|
|
3037
3145
|
r,
|
|
3038
3146
|
U,
|
|
3039
3147
|
i
|
|
3040
3148
|
);
|
|
3041
|
-
return { source:
|
|
3149
|
+
return { source: ot, context: at };
|
|
3042
3150
|
} finally {
|
|
3043
3151
|
c.pop();
|
|
3044
3152
|
}
|
|
3045
|
-
} catch (
|
|
3046
|
-
const L =
|
|
3047
|
-
throw L.adjusted ? L.errorToThrow :
|
|
3153
|
+
} catch (E) {
|
|
3154
|
+
const L = An(E);
|
|
3155
|
+
throw L.adjusted ? L.errorToThrow : E;
|
|
3048
3156
|
} finally {
|
|
3049
3157
|
T && c.pop();
|
|
3050
3158
|
}
|
|
3051
3159
|
}
|
|
3052
|
-
const
|
|
3160
|
+
const On = ht.warningReasons, Rn = [
|
|
3053
3161
|
{
|
|
3054
3162
|
reason: "contains_html_script_tag",
|
|
3055
3163
|
test: (t) => /<\/?script\b/i.test(t)
|
|
@@ -3071,17 +3179,17 @@ const $n = lt.warningReasons, Wn = [
|
|
|
3071
3179
|
test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
|
|
3072
3180
|
}
|
|
3073
3181
|
];
|
|
3074
|
-
function
|
|
3075
|
-
return
|
|
3182
|
+
function Mn(t) {
|
|
3183
|
+
return On[t] ?? t;
|
|
3076
3184
|
}
|
|
3077
3185
|
function re(t, e, n, r) {
|
|
3078
3186
|
if (typeof t == "string") {
|
|
3079
|
-
for (const i of
|
|
3187
|
+
for (const i of Rn)
|
|
3080
3188
|
i.test(t) && n.push({
|
|
3081
3189
|
code: "suspicious_context_value",
|
|
3082
3190
|
message: H("suspicious_context_value", {
|
|
3083
3191
|
key: e,
|
|
3084
|
-
reason:
|
|
3192
|
+
reason: Mn(i.reason)
|
|
3085
3193
|
}),
|
|
3086
3194
|
path: r,
|
|
3087
3195
|
details: { key: e, reason: i.reason }
|
|
@@ -3103,19 +3211,19 @@ function re(t, e, n, r) {
|
|
|
3103
3211
|
}
|
|
3104
3212
|
}
|
|
3105
3213
|
}
|
|
3106
|
-
function
|
|
3214
|
+
function Hn(t, e, n) {
|
|
3107
3215
|
for (const [r, i] of Object.entries(t))
|
|
3108
3216
|
re(i, r, e, n);
|
|
3109
3217
|
}
|
|
3110
|
-
const
|
|
3218
|
+
const Dn = /^=+[ \t]*$/, Nn = /^-+[ \t]*$/, Fn = /^(```|~~~)/, jn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
|
|
3111
3219
|
function ie(t) {
|
|
3112
|
-
const e =
|
|
3220
|
+
const e = jn.exec(t);
|
|
3113
3221
|
return e && e.index !== void 0 ? {
|
|
3114
3222
|
text: t.slice(0, e.index).trim(),
|
|
3115
3223
|
explicitId: e[1]
|
|
3116
3224
|
} : { text: t.trim() };
|
|
3117
3225
|
}
|
|
3118
|
-
function
|
|
3226
|
+
function Bn(t) {
|
|
3119
3227
|
let e = 0;
|
|
3120
3228
|
for (; e < t.length && e < 6 && t[e] === "#"; )
|
|
3121
3229
|
e += 1;
|
|
@@ -3146,7 +3254,7 @@ function Hn(t) {
|
|
|
3146
3254
|
const s = ie(t.slice(n, i));
|
|
3147
3255
|
return { level: e, ...s };
|
|
3148
3256
|
}
|
|
3149
|
-
function
|
|
3257
|
+
function Re(t, e, n) {
|
|
3150
3258
|
let r = n;
|
|
3151
3259
|
for (; r < t.length; ) {
|
|
3152
3260
|
if (!e.inHtmlComment) {
|
|
@@ -3162,13 +3270,13 @@ function Le(t, e, n) {
|
|
|
3162
3270
|
e.inHtmlComment = !1, r = i + 3;
|
|
3163
3271
|
}
|
|
3164
3272
|
}
|
|
3165
|
-
function
|
|
3273
|
+
function In(t, e) {
|
|
3166
3274
|
if (e.inFence || e.inHtmlComment)
|
|
3167
3275
|
return !0;
|
|
3168
3276
|
const n = t.trim();
|
|
3169
3277
|
return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
|
|
3170
3278
|
}
|
|
3171
|
-
function
|
|
3279
|
+
function Un(t) {
|
|
3172
3280
|
const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
|
|
3173
3281
|
for (let i = 0; i < e.length; i++) {
|
|
3174
3282
|
const s = e[i];
|
|
@@ -3178,34 +3286,34 @@ function Dn(t) {
|
|
|
3178
3286
|
continue;
|
|
3179
3287
|
}
|
|
3180
3288
|
if (r.inHtmlComment) {
|
|
3181
|
-
|
|
3289
|
+
Re(s, r, 0);
|
|
3182
3290
|
continue;
|
|
3183
3291
|
}
|
|
3184
|
-
const o =
|
|
3292
|
+
const o = Fn.exec(s.trimStart());
|
|
3185
3293
|
if (o) {
|
|
3186
3294
|
const l = o[1];
|
|
3187
3295
|
s.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
|
|
3188
3296
|
continue;
|
|
3189
3297
|
}
|
|
3190
3298
|
if (s.trim().startsWith("<!--")) {
|
|
3191
|
-
|
|
3299
|
+
Re(s, r, s.indexOf("<!--"));
|
|
3192
3300
|
continue;
|
|
3193
3301
|
}
|
|
3194
|
-
if (
|
|
3302
|
+
if (In(s, r))
|
|
3195
3303
|
continue;
|
|
3196
|
-
const c =
|
|
3304
|
+
const c = Bn(s);
|
|
3197
3305
|
if (c) {
|
|
3198
3306
|
n.push(c);
|
|
3199
3307
|
continue;
|
|
3200
3308
|
}
|
|
3201
3309
|
const h = e[i + 1];
|
|
3202
3310
|
if (h !== void 0 && s.trim().length > 0 && !s.trimStart().startsWith("#") && !s.trimStart().startsWith(">") && !s.trimStart().startsWith("|")) {
|
|
3203
|
-
if (
|
|
3311
|
+
if (Dn.test(h)) {
|
|
3204
3312
|
const l = ie(s.trim());
|
|
3205
3313
|
n.push({ level: 1, ...l }), i += 1;
|
|
3206
3314
|
continue;
|
|
3207
3315
|
}
|
|
3208
|
-
if (
|
|
3316
|
+
if (Nn.test(h) && h.trim().length >= 1) {
|
|
3209
3317
|
const l = ie(s.trim());
|
|
3210
3318
|
n.push({ level: 2, ...l }), i += 1;
|
|
3211
3319
|
continue;
|
|
@@ -3214,31 +3322,31 @@ function Dn(t) {
|
|
|
3214
3322
|
}
|
|
3215
3323
|
return n;
|
|
3216
3324
|
}
|
|
3217
|
-
const
|
|
3218
|
-
function
|
|
3325
|
+
const zn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
|
|
3326
|
+
function Vn() {
|
|
3219
3327
|
const t = /* @__PURE__ */ new Map();
|
|
3220
3328
|
return {
|
|
3221
3329
|
slug(e, n) {
|
|
3222
|
-
const r = n !== void 0 && n.length > 0 ? n :
|
|
3330
|
+
const r = n !== void 0 && n.length > 0 ? n : Zn(e), i = t.get(r) ?? 0;
|
|
3223
3331
|
return t.set(r, i + 1), i === 0 ? r : `${r}-${i}`;
|
|
3224
3332
|
}
|
|
3225
3333
|
};
|
|
3226
3334
|
}
|
|
3227
|
-
function
|
|
3228
|
-
return t.toLowerCase().replace(
|
|
3335
|
+
function Zn(t) {
|
|
3336
|
+
return t.toLowerCase().replace(zn, "").replace(/\s+/g, "-");
|
|
3229
3337
|
}
|
|
3230
|
-
function
|
|
3338
|
+
function qn(t) {
|
|
3231
3339
|
let e = t.trim();
|
|
3232
3340
|
e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
|
|
3233
3341
|
for (let n = 0; n < 3; n++)
|
|
3234
3342
|
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");
|
|
3235
3343
|
return e.trim();
|
|
3236
3344
|
}
|
|
3237
|
-
function
|
|
3345
|
+
function Pn(t, e) {
|
|
3238
3346
|
if (t.length === 0)
|
|
3239
3347
|
return "";
|
|
3240
|
-
const n =
|
|
3241
|
-
const a =
|
|
3348
|
+
const n = Vn(), i = t.map((o) => {
|
|
3349
|
+
const a = qn(o.text), c = n.slug(a, o.explicitId);
|
|
3242
3350
|
return { level: o.level, text: a, anchor: c };
|
|
3243
3351
|
}).filter((o) => o.level <= e);
|
|
3244
3352
|
if (i.length === 0)
|
|
@@ -3247,32 +3355,32 @@ function Un(t, e) {
|
|
|
3247
3355
|
return i.map((o) => `${" ".repeat((o.level - s) * 2)}- [${o.text}](#${o.anchor})`).join(`
|
|
3248
3356
|
`);
|
|
3249
3357
|
}
|
|
3250
|
-
function
|
|
3358
|
+
function Kn(t, e = {}) {
|
|
3251
3359
|
const r = W(t).filter((o) => {
|
|
3252
|
-
const a =
|
|
3360
|
+
const a = $(o.inner);
|
|
3253
3361
|
return a.length === 1 && P(a[0]);
|
|
3254
3362
|
});
|
|
3255
3363
|
if (r.length === 0)
|
|
3256
3364
|
return t;
|
|
3257
|
-
const i =
|
|
3365
|
+
const i = Un(t);
|
|
3258
3366
|
let s = t;
|
|
3259
3367
|
for (let o = r.length - 1; o >= 0; o--) {
|
|
3260
|
-
const a = r[o], { maxLevel: c } =
|
|
3368
|
+
const a = r[o], { maxLevel: c } = wn(a.inner, e.path), h = Pn(i, c), l = s.slice(0, a.start), u = s.slice(a.end);
|
|
3261
3369
|
s = A(A(l, h), u);
|
|
3262
3370
|
}
|
|
3263
3371
|
return s;
|
|
3264
3372
|
}
|
|
3265
|
-
async function
|
|
3266
|
-
const n = e.path, r = e.context, i = e.registry ?? new
|
|
3373
|
+
async function ke(t, e) {
|
|
3374
|
+
const n = e.path, r = e.context, i = e.registry ?? new je(), s = e.warnings ?? [], o = e.visitStack ?? new Qe(), {
|
|
3267
3375
|
source: a,
|
|
3268
3376
|
declarationUpdates: c
|
|
3269
|
-
} = await
|
|
3270
|
-
|
|
3377
|
+
} = await xn(t, { path: n, context: { ...r } });
|
|
3378
|
+
Hn(
|
|
3271
3379
|
v(r, c ?? {}),
|
|
3272
3380
|
s,
|
|
3273
3381
|
n
|
|
3274
3382
|
);
|
|
3275
|
-
const h = await
|
|
3383
|
+
const h = await Ln(a, {
|
|
3276
3384
|
path: n,
|
|
3277
3385
|
context: r,
|
|
3278
3386
|
declarationUpdates: c ?? {},
|
|
@@ -3282,19 +3390,19 @@ async function we(t, e) {
|
|
|
3282
3390
|
visitStack: o,
|
|
3283
3391
|
warnings: s,
|
|
3284
3392
|
inComponent: e.inComponent ?? !1
|
|
3285
|
-
}), { source: l, context: u } = h, { source:
|
|
3393
|
+
}), { source: l, context: u } = h, { source: p, directives: x } = _n(l, {
|
|
3286
3394
|
path: n,
|
|
3287
3395
|
registry: i,
|
|
3288
3396
|
context: u
|
|
3289
|
-
}),
|
|
3290
|
-
if (
|
|
3397
|
+
}), m = e.loader;
|
|
3398
|
+
if (x.length > 0 && !m)
|
|
3291
3399
|
throw new Error("loader is required when processing include directives");
|
|
3292
|
-
let
|
|
3293
|
-
|
|
3294
|
-
source:
|
|
3295
|
-
directives:
|
|
3400
|
+
let w = p;
|
|
3401
|
+
x.length > 0 && m && (w = await un({
|
|
3402
|
+
source: p,
|
|
3403
|
+
directives: x,
|
|
3296
3404
|
context: u,
|
|
3297
|
-
loader:
|
|
3405
|
+
loader: m,
|
|
3298
3406
|
root: e.root,
|
|
3299
3407
|
path: n,
|
|
3300
3408
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
@@ -3303,42 +3411,48 @@ async function we(t, e) {
|
|
|
3303
3411
|
warnings: s,
|
|
3304
3412
|
registry: i,
|
|
3305
3413
|
constrainToRoot: e.constrainToRoot
|
|
3306
|
-
})),
|
|
3414
|
+
})), w = await cn(w, {
|
|
3307
3415
|
context: u,
|
|
3308
3416
|
path: n,
|
|
3309
3417
|
registry: i,
|
|
3310
|
-
loader:
|
|
3418
|
+
loader: m,
|
|
3311
3419
|
rootDir: e.root,
|
|
3312
3420
|
warnings: s,
|
|
3313
3421
|
visitStack: o,
|
|
3314
3422
|
parentContext: u,
|
|
3315
3423
|
preserveHgComments: e.preserveHgComments,
|
|
3316
3424
|
constrainToRoot: e.constrainToRoot
|
|
3317
|
-
})
|
|
3425
|
+
});
|
|
3426
|
+
const _ = {
|
|
3318
3427
|
path: n,
|
|
3319
3428
|
registry: i,
|
|
3320
|
-
loader:
|
|
3429
|
+
loader: m,
|
|
3321
3430
|
rootDir: e.root,
|
|
3322
3431
|
warnings: s,
|
|
3323
3432
|
visitStack: o,
|
|
3324
3433
|
parentContext: u,
|
|
3325
3434
|
preserveHgComments: e.preserveHgComments,
|
|
3326
3435
|
constrainToRoot: e.constrainToRoot
|
|
3327
|
-
}
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3436
|
+
};
|
|
3437
|
+
return w = await Pe(w, u, _), w = await Ke(
|
|
3438
|
+
w,
|
|
3439
|
+
u,
|
|
3440
|
+
_
|
|
3441
|
+
), w = Kn(w, { path: n }), w = En(w, e.preserveHgComments), w;
|
|
3442
|
+
}
|
|
3443
|
+
async function rt(t, e = {}) {
|
|
3444
|
+
const n = e.path, r = v(e.context), i = e.registry ?? new je(), s = e.warnings ?? [], o = e.visitStack ?? new Qe(), { context: a, body: c, rawFrontMatter: h } = q(
|
|
3331
3445
|
t,
|
|
3332
3446
|
n
|
|
3333
3447
|
), l = v(r, a);
|
|
3334
|
-
let u = await
|
|
3448
|
+
let u = await ke(c, {
|
|
3335
3449
|
...e,
|
|
3336
3450
|
context: l,
|
|
3337
3451
|
registry: i,
|
|
3338
3452
|
warnings: s,
|
|
3339
3453
|
visitStack: o
|
|
3340
3454
|
});
|
|
3341
|
-
return u =
|
|
3455
|
+
return u = Sn(u, {
|
|
3342
3456
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
3343
3457
|
rawFrontMatter: h
|
|
3344
3458
|
}), {
|
|
@@ -3346,21 +3460,21 @@ async function nt(t, e = {}) {
|
|
|
3346
3460
|
warnings: s
|
|
3347
3461
|
};
|
|
3348
3462
|
}
|
|
3349
|
-
async function
|
|
3463
|
+
async function Yn(t, e) {
|
|
3350
3464
|
const n = e.path, { context: r, body: i } = q(t, n), s = v(e.context, r);
|
|
3351
|
-
return
|
|
3465
|
+
return ke(i, {
|
|
3352
3466
|
...e,
|
|
3353
3467
|
context: s,
|
|
3354
3468
|
preserveFrontMatter: !1
|
|
3355
3469
|
});
|
|
3356
3470
|
}
|
|
3357
|
-
async function
|
|
3358
|
-
const r = n?.loader ??
|
|
3471
|
+
async function Xn(t, e, n) {
|
|
3472
|
+
const r = n?.loader ?? Ne(), i = await Lt(t, { root: n?.root }), s = i.rootDir ?? n?.root, o = n?.dataSources, a = o && Object.keys(o).length > 0 ? await Fe(o, { root: s, loader: r }) : {}, c = v(
|
|
3359
3473
|
a,
|
|
3360
3474
|
e,
|
|
3361
3475
|
n?.serverContext
|
|
3362
3476
|
);
|
|
3363
|
-
return
|
|
3477
|
+
return rt(i.source, {
|
|
3364
3478
|
context: c,
|
|
3365
3479
|
loader: r,
|
|
3366
3480
|
root: s,
|
|
@@ -3370,7 +3484,7 @@ async function Zn(t, e, n) {
|
|
|
3370
3484
|
preserveHgComments: n?.preserveHgComments
|
|
3371
3485
|
});
|
|
3372
3486
|
}
|
|
3373
|
-
async function
|
|
3487
|
+
async function mr(t, e, n) {
|
|
3374
3488
|
if (n != null && "serverContext" in n && n.serverContext != null)
|
|
3375
3489
|
throw d({
|
|
3376
3490
|
code: "server_context_on_client"
|
|
@@ -3388,7 +3502,7 @@ async function hr(t, e, n) {
|
|
|
3388
3502
|
let i, s;
|
|
3389
3503
|
typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
|
|
3390
3504
|
const o = v(e);
|
|
3391
|
-
return
|
|
3505
|
+
return rt(i, {
|
|
3392
3506
|
context: o,
|
|
3393
3507
|
loader: r,
|
|
3394
3508
|
root: n?.root,
|
|
@@ -3398,25 +3512,25 @@ async function hr(t, e, n) {
|
|
|
3398
3512
|
constrainToRoot: n?.constrainToRoot
|
|
3399
3513
|
});
|
|
3400
3514
|
}
|
|
3401
|
-
function
|
|
3402
|
-
if (
|
|
3515
|
+
function Gn(t, e) {
|
|
3516
|
+
if (de(t))
|
|
3403
3517
|
throw d({
|
|
3404
3518
|
code: "parse_error",
|
|
3405
3519
|
path: e,
|
|
3406
3520
|
details: {
|
|
3407
|
-
message:
|
|
3521
|
+
message: ue(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
3408
3522
|
}
|
|
3409
3523
|
});
|
|
3410
3524
|
const n = [], r = W(t);
|
|
3411
3525
|
for (const i of r) {
|
|
3412
|
-
const s =
|
|
3526
|
+
const s = $(i.inner);
|
|
3413
3527
|
if (s.length === 0)
|
|
3414
3528
|
throw d({
|
|
3415
3529
|
code: "parse_error",
|
|
3416
3530
|
path: e,
|
|
3417
3531
|
details: { message: "empty hyogen block" }
|
|
3418
3532
|
});
|
|
3419
|
-
if (s.length === 1 &&
|
|
3533
|
+
if (s.length === 1 && fe(s[0]) || s.length === 1 && P(s[0]) || s.length === 1 && (ne(s[0]) || V(s[0])))
|
|
3420
3534
|
continue;
|
|
3421
3535
|
const o = s[0];
|
|
3422
3536
|
if (o === "endblock" || /^block\s+/.test(o))
|
|
@@ -3440,12 +3554,12 @@ function qn(t, e) {
|
|
|
3440
3554
|
});
|
|
3441
3555
|
}
|
|
3442
3556
|
if (/^include\s+/i.test(o)) {
|
|
3443
|
-
const c =
|
|
3557
|
+
const c = nt(i.inner, e);
|
|
3444
3558
|
n.push({ kind: "include", path: c.path });
|
|
3445
3559
|
continue;
|
|
3446
3560
|
}
|
|
3447
3561
|
if (/^component\s+/i.test(o)) {
|
|
3448
|
-
const c =
|
|
3562
|
+
const c = tt(i.inner, e);
|
|
3449
3563
|
n.push({ kind: "component", path: c.path });
|
|
3450
3564
|
continue;
|
|
3451
3565
|
}
|
|
@@ -3457,8 +3571,8 @@ function qn(t, e) {
|
|
|
3457
3571
|
}
|
|
3458
3572
|
return n;
|
|
3459
3573
|
}
|
|
3460
|
-
function
|
|
3461
|
-
return
|
|
3574
|
+
function Jn(t, e, n) {
|
|
3575
|
+
return D(t) ? t : Z(t, {
|
|
3462
3576
|
rootDir: n.root,
|
|
3463
3577
|
fromPath: e,
|
|
3464
3578
|
documentPath: e,
|
|
@@ -3466,19 +3580,19 @@ function Pn(t, e, n) {
|
|
|
3466
3580
|
hyogenPath: !0
|
|
3467
3581
|
});
|
|
3468
3582
|
}
|
|
3469
|
-
async function
|
|
3583
|
+
async function Qn(t, e, n = {}) {
|
|
3470
3584
|
const r = t.map(
|
|
3471
|
-
(l) =>
|
|
3585
|
+
(l) => D(l) ? l : f.resolve(l)
|
|
3472
3586
|
), i = new Set(r), s = /* @__PURE__ */ new Set(), o = [], a = [...r];
|
|
3473
3587
|
for (; a.length > 0; ) {
|
|
3474
3588
|
const l = a.shift();
|
|
3475
3589
|
if (s.has(l))
|
|
3476
3590
|
continue;
|
|
3477
3591
|
s.add(l);
|
|
3478
|
-
const u = await e(l),
|
|
3479
|
-
for (const
|
|
3480
|
-
const
|
|
3481
|
-
o.push({ from: l, to:
|
|
3592
|
+
const u = await e(l), p = Gn(u, l);
|
|
3593
|
+
for (const x of p) {
|
|
3594
|
+
const m = Jn(x.path, l, n);
|
|
3595
|
+
o.push({ from: l, to: m, kind: x.kind }), s.has(m) || a.push(m);
|
|
3482
3596
|
}
|
|
3483
3597
|
}
|
|
3484
3598
|
const c = [...s], h = c.filter((l) => !i.has(l));
|
|
@@ -3489,19 +3603,19 @@ async function Kn(t, e, n = {}) {
|
|
|
3489
3603
|
edges: o
|
|
3490
3604
|
};
|
|
3491
3605
|
}
|
|
3492
|
-
function
|
|
3606
|
+
function er(t) {
|
|
3493
3607
|
return t.replace(/\\/g, "/").split("/").filter((r) => r.length > 0).some((r) => r.startsWith("_"));
|
|
3494
3608
|
}
|
|
3495
|
-
function
|
|
3496
|
-
return
|
|
3609
|
+
function tr(t) {
|
|
3610
|
+
return mt.scan(t).isGlob;
|
|
3497
3611
|
}
|
|
3498
|
-
function
|
|
3612
|
+
function nr(t) {
|
|
3499
3613
|
return t.root ? f.resolve(t.root) : t.cwd ? f.resolve(t.cwd) : I(process.cwd()) ?? process.cwd();
|
|
3500
3614
|
}
|
|
3501
|
-
async function
|
|
3502
|
-
const n = Array.isArray(t) ? t : [t], r =
|
|
3615
|
+
async function rr(t, e = {}) {
|
|
3616
|
+
const n = Array.isArray(t) ? t : [t], r = nr(e), i = e.includeUnderscoreEntries === !0, s = /* @__PURE__ */ new Map();
|
|
3503
3617
|
for (const o of n) {
|
|
3504
|
-
if (!
|
|
3618
|
+
if (!tr(o)) {
|
|
3505
3619
|
const c = f.isAbsolute(o) ? f.resolve(o) : f.resolve(r, o);
|
|
3506
3620
|
try {
|
|
3507
3621
|
if (!(await se(c)).isFile())
|
|
@@ -3529,7 +3643,7 @@ async function Jn(t, e = {}) {
|
|
|
3529
3643
|
s.set(h, c);
|
|
3530
3644
|
continue;
|
|
3531
3645
|
}
|
|
3532
|
-
const a = await
|
|
3646
|
+
const a = await pt(o, {
|
|
3533
3647
|
cwd: r,
|
|
3534
3648
|
absolute: !0,
|
|
3535
3649
|
onlyFiles: !0,
|
|
@@ -3537,15 +3651,15 @@ async function Jn(t, e = {}) {
|
|
|
3537
3651
|
});
|
|
3538
3652
|
for (const c of a) {
|
|
3539
3653
|
const h = f.relative(r, c).replace(/\\/g, "/");
|
|
3540
|
-
!i &&
|
|
3654
|
+
!i && er(h) || s.set(h, f.resolve(c));
|
|
3541
3655
|
}
|
|
3542
3656
|
}
|
|
3543
3657
|
return [...s.values()];
|
|
3544
3658
|
}
|
|
3545
|
-
function
|
|
3659
|
+
function ir(t) {
|
|
3546
3660
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
3547
3661
|
}
|
|
3548
|
-
function
|
|
3662
|
+
function sr(t, e) {
|
|
3549
3663
|
if (t)
|
|
3550
3664
|
return f.resolve(t);
|
|
3551
3665
|
for (const n of e) {
|
|
@@ -3555,18 +3669,18 @@ function er(t, e) {
|
|
|
3555
3669
|
}
|
|
3556
3670
|
return e.length > 0 ? f.dirname(f.resolve(e[0])) : process.cwd();
|
|
3557
3671
|
}
|
|
3558
|
-
async function
|
|
3559
|
-
const e = await
|
|
3672
|
+
async function gr(t) {
|
|
3673
|
+
const e = await rr(t.input, {
|
|
3560
3674
|
root: t.root,
|
|
3561
3675
|
includeUnderscoreEntries: t.includeUnderscoreEntries
|
|
3562
|
-
}), n =
|
|
3563
|
-
e.length > 0 && await
|
|
3676
|
+
}), n = sr(t.root, e), r = t.loader ?? Ne(), i = I(n) !== void 0;
|
|
3677
|
+
e.length > 0 && await Qn(e, r, {
|
|
3564
3678
|
root: n,
|
|
3565
3679
|
constrainToRoot: i
|
|
3566
3680
|
});
|
|
3567
|
-
const s = t.dataSources, o = s && Object.keys(s).length > 0 ? await
|
|
3681
|
+
const s = t.dataSources, o = s && Object.keys(s).length > 0 ? await Fe(s, { root: n, loader: r }) : {}, a = v(o, t.context), c = [], h = [];
|
|
3568
3682
|
for (const l of e) {
|
|
3569
|
-
const u = f.resolve(l),
|
|
3683
|
+
const u = f.resolve(l), p = f.relative(n, u).replace(/\\/g, "/"), x = await Xn(
|
|
3570
3684
|
{ path: u },
|
|
3571
3685
|
a,
|
|
3572
3686
|
{
|
|
@@ -3576,27 +3690,27 @@ async function dr(t) {
|
|
|
3576
3690
|
preserveFrontMatter: t.preserveFrontMatter,
|
|
3577
3691
|
preserveHgComments: t.preserveHgComments
|
|
3578
3692
|
}
|
|
3579
|
-
),
|
|
3693
|
+
), m = f.join(t.outDir, p);
|
|
3580
3694
|
try {
|
|
3581
|
-
await
|
|
3582
|
-
} catch (
|
|
3583
|
-
if (
|
|
3584
|
-
throw
|
|
3585
|
-
const
|
|
3695
|
+
await ct(f.dirname(m), { recursive: !0 }), await lt(m, x.markdown, "utf8");
|
|
3696
|
+
} catch (w) {
|
|
3697
|
+
if (ir(w))
|
|
3698
|
+
throw w;
|
|
3699
|
+
const _ = w instanceof Error ? w.message : "unknown write error";
|
|
3586
3700
|
throw d({
|
|
3587
3701
|
code: "load_failed",
|
|
3588
|
-
path:
|
|
3702
|
+
path: m,
|
|
3589
3703
|
details: {
|
|
3590
|
-
path:
|
|
3591
|
-
reason:
|
|
3704
|
+
path: m,
|
|
3705
|
+
reason: _
|
|
3592
3706
|
}
|
|
3593
3707
|
});
|
|
3594
3708
|
}
|
|
3595
|
-
c.push({ path:
|
|
3709
|
+
c.push({ path: p, markdown: x.markdown }), h.push(...x.warnings);
|
|
3596
3710
|
}
|
|
3597
3711
|
return { files: c, warnings: h };
|
|
3598
3712
|
}
|
|
3599
|
-
function
|
|
3713
|
+
function wr(t, e) {
|
|
3600
3714
|
const n = [`[hyogen:${t}] ${e.code}`], r = {};
|
|
3601
3715
|
if (e.details)
|
|
3602
3716
|
for (const [i, s] of Object.entries(e.details))
|
|
@@ -3608,15 +3722,15 @@ function ur(t, e) {
|
|
|
3608
3722
|
`);
|
|
3609
3723
|
}
|
|
3610
3724
|
export {
|
|
3611
|
-
|
|
3612
|
-
|
|
3725
|
+
gr as build,
|
|
3726
|
+
De as createFsLoader,
|
|
3613
3727
|
d as createHyogenError,
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3728
|
+
Ne as createNodeLoader,
|
|
3729
|
+
wr as formatDiagnosticLog,
|
|
3730
|
+
yr as formatMessage,
|
|
3731
|
+
D as isRemotePath,
|
|
3732
|
+
Fe as loadDataSources,
|
|
3733
|
+
mr as renderClient,
|
|
3734
|
+
Xn as renderServer
|
|
3621
3735
|
};
|
|
3622
3736
|
//# sourceMappingURL=index.js.map
|