@b4moss/hyogen-md 0.12.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 +24 -3
- package/README_ja.md +24 -3
- package/dist/build/build.d.ts +2 -0
- package/dist/build/buildDependencyGraph.d.ts +22 -0
- package/dist/build/collectDependencies.d.ts +8 -0
- package/dist/build/collectEntryPaths.d.ts +10 -0
- package/dist/build/isUnderscorePartial.d.ts +4 -0
- package/dist/cli.js +5742 -0
- package/dist/client.js +1111 -870
- package/dist/component/ComponentRegistry.d.ts +11 -0
- package/dist/component/parsePropsContract.d.ts +10 -0
- package/dist/component/renderComponent.d.ts +17 -0
- package/dist/component/validateProps.d.ts +7 -0
- package/dist/config/defineConfig.d.ts +5 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +143 -0
- package/dist/config/loadConfig.d.ts +13 -0
- package/dist/config/types.d.ts +26 -0
- package/dist/context/mergeContext.d.ts +3 -0
- package/dist/control/StructureNestTracker.d.ts +14 -0
- package/dist/control/expandControlStructures.d.ts +3 -0
- package/dist/control/parseControlOpener.d.ts +2 -0
- package/dist/control/parseControlStructures.d.ts +2 -0
- package/dist/createError-WZmAl05N.js +30 -0
- package/dist/errors/createError.d.ts +7 -0
- package/dist/errors/formatDiagnosticLog.d.ts +6 -0
- package/dist/errors/formatMessage.d.ts +3 -0
- package/dist/expr/evaluateExpression.d.ts +4 -0
- package/dist/expr/interpolateExpressions.d.ts +4 -0
- package/dist/expr/interpolateFenceExpressions.d.ts +8 -0
- package/dist/expr/parseExpression.d.ts +4 -0
- package/dist/frontmatter/parseFrontMatter.d.ts +3 -0
- package/dist/include/VisitStack.d.ts +13 -0
- package/dist/include/expandIncludes.d.ts +18 -0
- package/dist/index.d.ts +11 -113
- package/dist/index.js +839 -597
- package/dist/io/createFsLoader.d.ts +6 -0
- package/dist/io/createNodeLoader.d.ts +4 -0
- package/dist/io/isRemotePath.d.ts +2 -0
- package/dist/io/loadDataSources.d.ts +8 -0
- package/dist/io/parseCsvFromString.d.ts +1 -0
- package/dist/io/parseDataFile.d.ts +1 -0
- package/dist/io/resolveIncludePath.d.ts +1 -0
- package/dist/layout/expandExtendsAndBlocks.d.ts +19 -0
- package/dist/layout/parseBlockOpener.d.ts +8 -0
- package/dist/layout/parseBlockStructures.d.ts +15 -0
- package/dist/layout/parseExtendBlock.d.ts +12 -0
- package/dist/layout/parseExtendDirective.d.ts +5 -0
- package/dist/logic/executeDeclaration.d.ts +6 -0
- package/dist/logic/executeDeclarations.d.ts +6 -0
- package/dist/logic/executeStatement.d.ts +10 -0
- package/dist/logic/hgBlockUtils.d.ts +3 -0
- package/dist/logic/parseDeclaration.d.ts +5 -0
- package/dist/logic/parseStatement.d.ts +3 -0
- package/dist/logic/reservedWords.d.ts +2 -0
- package/dist/logic/stripComments.d.ts +2 -0
- package/dist/markdown/shiftHeadings.d.ts +25 -0
- package/dist/parse/hgMarkers.d.ts +5 -0
- package/dist/parse/parseComponentDirective.d.ts +6 -0
- package/dist/parse/parseIncludeDirective.d.ts +2 -0
- package/dist/parse/scanHgBlocks.d.ts +10 -0
- package/dist/paths/assertWithinRootDir.d.ts +2 -0
- package/dist/paths/findDocRoot.d.ts +1 -0
- package/dist/paths/resolveRenderInput.d.ts +11 -0
- package/dist/paths/resolveTemplatePath.d.ts +9 -0
- package/dist/pipeline/applyFrontMatterOutputOption.d.ts +4 -0
- package/dist/pipeline/executeHgBlocks.d.ts +9 -0
- package/dist/pipeline/joinRemovalSeam.d.ts +12 -0
- package/dist/pipeline/renderDocument.d.ts +22 -0
- package/dist/pipeline/stripHgComments.d.ts +7 -0
- package/dist/renderClient.d.ts +15 -0
- package/dist/renderServer.d.ts +4 -0
- package/dist/security/forbiddenKeys.d.ts +3 -0
- package/dist/security/scanSuspiciousContext.d.ts +6 -0
- package/dist/shims/fs-browser.d.ts +6 -0
- package/dist/shims/fs-promises-browser.d.ts +5 -0
- package/dist/toc/expandToc.d.ts +8 -0
- package/dist/toc/extractHeadings.d.ts +10 -0
- package/dist/toc/formatTocMarkdown.d.ts +7 -0
- package/dist/toc/githubHeadingSlug.d.ts +11 -0
- package/dist/toc/parseTocDirective.d.ts +10 -0
- package/dist/toc/plainifyHeadingText.d.ts +2 -0
- package/dist/types.d.ts +211 -0
- package/package.json +17 -4
package/dist/index.js
CHANGED
|
@@ -1,48 +1,27 @@
|
|
|
1
|
-
import { stat as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
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
|
+
import f from "node:path";
|
|
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";
|
|
9
11
|
function v(...t) {
|
|
10
12
|
const e = {};
|
|
11
13
|
for (const n of t)
|
|
12
14
|
n != null && Object.assign(e, n);
|
|
13
15
|
return e;
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
errors: it,
|
|
17
|
-
warnings: st,
|
|
18
|
-
warningReasons: ot
|
|
19
|
-
}, at = se.errors, ct = se.warnings;
|
|
20
|
-
function Le(t, e) {
|
|
21
|
-
return t === void 0 ? "" : t.replace(/\{([^}]+)\}/g, (n, r) => {
|
|
22
|
-
if (e === void 0 || !(r in e))
|
|
23
|
-
return n;
|
|
24
|
-
const i = e[r];
|
|
25
|
-
return i == null ? "" : String(i);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function lt(t, e) {
|
|
29
|
-
return Le(at[t], e);
|
|
30
|
-
}
|
|
31
|
-
function L(t, e) {
|
|
32
|
-
return Le(ct[t], e);
|
|
33
|
-
}
|
|
34
|
-
function d(t) {
|
|
35
|
-
const e = t.message ?? lt(t.code, t.details), n = new Error(e);
|
|
36
|
-
return n.name = "HyogenError", n.code = t.code, n.message = e, n.path = t.path, n.details = t.details, n;
|
|
37
|
-
}
|
|
38
|
-
function ht(t) {
|
|
17
|
+
function gt(t) {
|
|
39
18
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
40
19
|
}
|
|
41
|
-
function
|
|
20
|
+
function De(t = {}) {
|
|
42
21
|
const { from: e, via: n = "include" } = t;
|
|
43
22
|
return async (r) => {
|
|
44
23
|
try {
|
|
45
|
-
if (!(await
|
|
24
|
+
if (!(await se(r)).isFile())
|
|
46
25
|
throw d({
|
|
47
26
|
code: "load_failed",
|
|
48
27
|
path: e,
|
|
@@ -53,7 +32,7 @@ function dt(t = {}) {
|
|
|
53
32
|
});
|
|
54
33
|
return await Me(r, "utf8");
|
|
55
34
|
} catch (i) {
|
|
56
|
-
if (
|
|
35
|
+
if (gt(i))
|
|
57
36
|
throw i;
|
|
58
37
|
const s = i;
|
|
59
38
|
throw s.code === "ENOENT" ? d({
|
|
@@ -75,21 +54,43 @@ function dt(t = {}) {
|
|
|
75
54
|
}
|
|
76
55
|
};
|
|
77
56
|
}
|
|
78
|
-
function
|
|
57
|
+
function D(t) {
|
|
79
58
|
return /^https?:\/\//i.test(t);
|
|
80
59
|
}
|
|
81
|
-
function
|
|
60
|
+
function wt(t) {
|
|
82
61
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
83
62
|
}
|
|
84
|
-
function
|
|
85
|
-
const { from: e, via: n = "include" } = t, r =
|
|
63
|
+
function Ne(t = {}) {
|
|
64
|
+
const { from: e, via: n = "include" } = t, r = De(t);
|
|
86
65
|
return async (i) => {
|
|
87
|
-
if (!
|
|
66
|
+
if (!D(i))
|
|
88
67
|
return r(i);
|
|
68
|
+
let s;
|
|
69
|
+
try {
|
|
70
|
+
s = new URL(i);
|
|
71
|
+
} catch {
|
|
72
|
+
throw d({
|
|
73
|
+
code: "load_failed",
|
|
74
|
+
path: e,
|
|
75
|
+
details: {
|
|
76
|
+
path: i,
|
|
77
|
+
reason: "invalid remote URL"
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (s.protocol !== "http:" && s.protocol !== "https:")
|
|
82
|
+
throw d({
|
|
83
|
+
code: "load_failed",
|
|
84
|
+
path: e,
|
|
85
|
+
details: {
|
|
86
|
+
path: i,
|
|
87
|
+
reason: `unsupported protocol: ${s.protocol}`
|
|
88
|
+
}
|
|
89
|
+
});
|
|
89
90
|
try {
|
|
90
|
-
const
|
|
91
|
-
if (!
|
|
92
|
-
throw
|
|
91
|
+
const o = await fetch(s);
|
|
92
|
+
if (!o.ok)
|
|
93
|
+
throw o.status === 404 ? d({
|
|
93
94
|
code: "file_not_found",
|
|
94
95
|
path: e,
|
|
95
96
|
details: {
|
|
@@ -102,44 +103,44 @@ function oe(t = {}) {
|
|
|
102
103
|
path: e,
|
|
103
104
|
details: {
|
|
104
105
|
path: i,
|
|
105
|
-
reason: `HTTP ${
|
|
106
|
+
reason: `HTTP ${o.status}`
|
|
106
107
|
}
|
|
107
108
|
});
|
|
108
|
-
return await
|
|
109
|
-
} catch (
|
|
110
|
-
if (
|
|
111
|
-
throw
|
|
112
|
-
const
|
|
109
|
+
return await o.text();
|
|
110
|
+
} catch (o) {
|
|
111
|
+
if (wt(o))
|
|
112
|
+
throw o;
|
|
113
|
+
const a = o instanceof Error ? o.message : "unknown fetch error";
|
|
113
114
|
throw d({
|
|
114
115
|
code: "load_failed",
|
|
115
116
|
path: e,
|
|
116
117
|
details: {
|
|
117
118
|
path: i,
|
|
118
|
-
reason:
|
|
119
|
+
reason: a
|
|
119
120
|
}
|
|
120
121
|
});
|
|
121
122
|
}
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
+
function xt(t) {
|
|
125
126
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
126
127
|
}
|
|
127
|
-
function
|
|
128
|
+
function kt(t) {
|
|
128
129
|
return Object.keys(t).sort((e, n) => Number(e) - Number(n)).map((e) => t[e] ?? "");
|
|
129
130
|
}
|
|
130
|
-
function
|
|
131
|
+
function yt(t) {
|
|
131
132
|
return t.every((e) => e === "");
|
|
132
133
|
}
|
|
133
|
-
async function
|
|
134
|
+
async function bt(t) {
|
|
134
135
|
return new Promise((e, n) => {
|
|
135
136
|
const r = [];
|
|
136
|
-
|
|
137
|
-
const s =
|
|
138
|
-
|
|
137
|
+
dt.from([t]).pipe(ut({ headers: !1 })).on("data", (i) => {
|
|
138
|
+
const s = kt(i);
|
|
139
|
+
yt(s) || r.push(s);
|
|
139
140
|
}).on("end", () => e(r)).on("error", (i) => n(i));
|
|
140
141
|
});
|
|
141
142
|
}
|
|
142
|
-
async function
|
|
143
|
+
async function vt(t, e) {
|
|
143
144
|
if (t.length === 0 || t.trim().length === 0)
|
|
144
145
|
throw d({
|
|
145
146
|
code: "parse_error",
|
|
@@ -148,9 +149,9 @@ async function wt(t, e) {
|
|
|
148
149
|
});
|
|
149
150
|
let n;
|
|
150
151
|
try {
|
|
151
|
-
n = await
|
|
152
|
+
n = await bt(t);
|
|
152
153
|
} catch (o) {
|
|
153
|
-
throw
|
|
154
|
+
throw xt(o) ? o : d({
|
|
154
155
|
code: "parse_error",
|
|
155
156
|
path: e,
|
|
156
157
|
details: {
|
|
@@ -179,10 +180,10 @@ async function wt(t, e) {
|
|
|
179
180
|
return a;
|
|
180
181
|
});
|
|
181
182
|
}
|
|
182
|
-
function
|
|
183
|
-
return
|
|
183
|
+
function _t(t) {
|
|
184
|
+
return f.extname(t).slice(1).toLowerCase();
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
+
function St(t, e) {
|
|
186
187
|
if (t.length === 0)
|
|
187
188
|
throw d({
|
|
188
189
|
code: "parse_error",
|
|
@@ -190,9 +191,9 @@ function kt(t, e) {
|
|
|
190
191
|
details: { message: "empty data file" }
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
|
-
async function
|
|
194
|
-
|
|
195
|
-
const n =
|
|
194
|
+
async function Et(t, e) {
|
|
195
|
+
St(t, e);
|
|
196
|
+
const n = _t(e);
|
|
196
197
|
switch (n) {
|
|
197
198
|
case "json":
|
|
198
199
|
try {
|
|
@@ -209,7 +210,7 @@ async function yt(t, e) {
|
|
|
209
210
|
case "yaml":
|
|
210
211
|
case "yml":
|
|
211
212
|
try {
|
|
212
|
-
return
|
|
213
|
+
return He(t);
|
|
213
214
|
} catch (r) {
|
|
214
215
|
throw d({
|
|
215
216
|
code: "parse_error",
|
|
@@ -220,7 +221,7 @@ async function yt(t, e) {
|
|
|
220
221
|
});
|
|
221
222
|
}
|
|
222
223
|
case "csv":
|
|
223
|
-
return
|
|
224
|
+
return vt(t, e);
|
|
224
225
|
default:
|
|
225
226
|
throw d({
|
|
226
227
|
code: "parse_error",
|
|
@@ -232,26 +233,26 @@ async function yt(t, e) {
|
|
|
232
233
|
});
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
|
-
const
|
|
236
|
-
function
|
|
236
|
+
const Ct = ".doc_root";
|
|
237
|
+
function I(t) {
|
|
237
238
|
let e;
|
|
238
|
-
for (
|
|
239
|
-
const n =
|
|
240
|
-
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))
|
|
241
242
|
return e;
|
|
242
|
-
const r =
|
|
243
|
+
const r = f.dirname(e);
|
|
243
244
|
if (r === e)
|
|
244
245
|
return;
|
|
245
246
|
e = r;
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
|
-
function
|
|
249
|
-
const n =
|
|
250
|
-
return n === "" || !n.startsWith("..") && !
|
|
249
|
+
function $t(t, e) {
|
|
250
|
+
const n = f.relative(e, t);
|
|
251
|
+
return n === "" || !n.startsWith("..") && !f.isAbsolute(n);
|
|
251
252
|
}
|
|
252
|
-
function
|
|
253
|
-
const r =
|
|
254
|
-
if (
|
|
253
|
+
function Wt(t, e, n) {
|
|
254
|
+
const r = f.resolve(e), i = f.resolve(t);
|
|
255
|
+
if (!$t(i, r))
|
|
255
256
|
throw d({
|
|
256
257
|
code: "parse_error",
|
|
257
258
|
path: n,
|
|
@@ -269,7 +270,7 @@ function Z(t, e = {}) {
|
|
|
269
270
|
let a;
|
|
270
271
|
if (t.startsWith("/"))
|
|
271
272
|
if (n)
|
|
272
|
-
a =
|
|
273
|
+
a = f.resolve(n, t.slice(1));
|
|
273
274
|
else {
|
|
274
275
|
if (o)
|
|
275
276
|
throw d({
|
|
@@ -277,8 +278,8 @@ function Z(t, e = {}) {
|
|
|
277
278
|
path: i,
|
|
278
279
|
details: { message: "root-relative paths require a doc root" }
|
|
279
280
|
});
|
|
280
|
-
if (
|
|
281
|
-
a =
|
|
281
|
+
if (f.isAbsolute(t))
|
|
282
|
+
a = f.resolve(t);
|
|
282
283
|
else
|
|
283
284
|
throw d({
|
|
284
285
|
code: "parse_error",
|
|
@@ -288,38 +289,38 @@ function Z(t, e = {}) {
|
|
|
288
289
|
}
|
|
289
290
|
else if (t.startsWith("./") || t.startsWith("../"))
|
|
290
291
|
if (r)
|
|
291
|
-
a =
|
|
292
|
+
a = f.resolve(f.dirname(r), t);
|
|
292
293
|
else if (n)
|
|
293
|
-
a =
|
|
294
|
+
a = f.resolve(n, t);
|
|
294
295
|
else
|
|
295
296
|
throw d({
|
|
296
297
|
code: "parse_error",
|
|
297
298
|
path: i,
|
|
298
299
|
details: { message: "root is required for relative template paths" }
|
|
299
300
|
});
|
|
300
|
-
else if (
|
|
301
|
-
a =
|
|
301
|
+
else if (f.isAbsolute(t))
|
|
302
|
+
a = f.resolve(t);
|
|
302
303
|
else if (n)
|
|
303
|
-
a =
|
|
304
|
+
a = f.resolve(n, t);
|
|
304
305
|
else
|
|
305
306
|
throw d({
|
|
306
307
|
code: "parse_error",
|
|
307
308
|
path: i,
|
|
308
309
|
details: { message: "root is required for relative template paths" }
|
|
309
310
|
});
|
|
310
|
-
return n && s &&
|
|
311
|
+
return n && s && Wt(a, n, i), a;
|
|
311
312
|
}
|
|
312
|
-
const
|
|
313
|
-
function
|
|
313
|
+
const ve = 5 * 1024 * 1024;
|
|
314
|
+
function Tt(t) {
|
|
314
315
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
315
316
|
}
|
|
316
|
-
function
|
|
317
|
-
return t?.root ?
|
|
317
|
+
function At(t) {
|
|
318
|
+
return t?.root ? f.resolve(t.root) : I(process.cwd()) ?? process.cwd();
|
|
318
319
|
}
|
|
319
|
-
async function
|
|
320
|
-
const n =
|
|
320
|
+
async function Fe(t, e) {
|
|
321
|
+
const n = At(e), r = e?.loader ?? De(), i = {};
|
|
321
322
|
for (const [s, o] of Object.entries(t)) {
|
|
322
|
-
if (
|
|
323
|
+
if (D(o))
|
|
323
324
|
throw d({
|
|
324
325
|
code: "load_failed",
|
|
325
326
|
path: o,
|
|
@@ -333,7 +334,7 @@ async function He(t, e) {
|
|
|
333
334
|
try {
|
|
334
335
|
c = await r(a);
|
|
335
336
|
} catch (l) {
|
|
336
|
-
throw
|
|
337
|
+
throw Tt(l) ? l : d({
|
|
337
338
|
code: "load_failed",
|
|
338
339
|
path: a,
|
|
339
340
|
details: {
|
|
@@ -343,30 +344,30 @@ async function He(t, e) {
|
|
|
343
344
|
});
|
|
344
345
|
}
|
|
345
346
|
const h = Buffer.byteLength(c, "utf8");
|
|
346
|
-
if (h >
|
|
347
|
+
if (h > ve)
|
|
347
348
|
throw d({
|
|
348
349
|
code: "data_source_too_large",
|
|
349
350
|
path: a,
|
|
350
351
|
details: {
|
|
351
352
|
path: a,
|
|
352
353
|
size: h,
|
|
353
|
-
limit:
|
|
354
|
+
limit: ve
|
|
354
355
|
}
|
|
355
356
|
});
|
|
356
|
-
i[s] = await
|
|
357
|
+
i[s] = await Et(c, a);
|
|
357
358
|
}
|
|
358
359
|
return i;
|
|
359
360
|
}
|
|
360
|
-
async function
|
|
361
|
+
async function Lt(t, e) {
|
|
361
362
|
if (typeof t == "string")
|
|
362
363
|
return {
|
|
363
364
|
source: t,
|
|
364
365
|
rootDir: e?.root
|
|
365
366
|
};
|
|
366
|
-
const n =
|
|
367
|
+
const n = f.resolve(t.path);
|
|
367
368
|
let r;
|
|
368
369
|
try {
|
|
369
|
-
r = await
|
|
370
|
+
r = await se(n);
|
|
370
371
|
} catch (a) {
|
|
371
372
|
const c = a;
|
|
372
373
|
throw c.code === "ENOENT" ? d({
|
|
@@ -405,7 +406,7 @@ async function Et(t, e) {
|
|
|
405
406
|
}
|
|
406
407
|
});
|
|
407
408
|
}
|
|
408
|
-
const s =
|
|
409
|
+
const s = I(n), o = e?.root ?? s;
|
|
409
410
|
return {
|
|
410
411
|
source: i,
|
|
411
412
|
rootDir: o,
|
|
@@ -413,7 +414,7 @@ async function Et(t, e) {
|
|
|
413
414
|
constrainToRoot: s !== void 0
|
|
414
415
|
};
|
|
415
416
|
}
|
|
416
|
-
class
|
|
417
|
+
class je {
|
|
417
418
|
components = /* @__PURE__ */ new Map();
|
|
418
419
|
register(e, n, r) {
|
|
419
420
|
if (this.components.has(e.alias))
|
|
@@ -437,8 +438,8 @@ class De {
|
|
|
437
438
|
return this.components.has(e);
|
|
438
439
|
}
|
|
439
440
|
}
|
|
440
|
-
const
|
|
441
|
-
function
|
|
441
|
+
const _e = 64 * 1024;
|
|
442
|
+
function q(t, e) {
|
|
442
443
|
if (!t.startsWith("---"))
|
|
443
444
|
return { context: {}, body: t };
|
|
444
445
|
const n = t.indexOf(`
|
|
@@ -450,13 +451,13 @@ function V(t, e) {
|
|
|
450
451
|
if (r === -1)
|
|
451
452
|
return { context: {}, body: t };
|
|
452
453
|
const i = t.slice(n + 1, r), s = Buffer.byteLength(i, "utf8");
|
|
453
|
-
if (s >
|
|
454
|
+
if (s > _e)
|
|
454
455
|
throw d({
|
|
455
456
|
code: "frontmatter_too_large",
|
|
456
457
|
path: e,
|
|
457
458
|
details: {
|
|
458
459
|
size: s,
|
|
459
|
-
limit:
|
|
460
|
+
limit: _e
|
|
460
461
|
}
|
|
461
462
|
});
|
|
462
463
|
if (i.trim().length === 0)
|
|
@@ -467,7 +468,7 @@ function V(t, e) {
|
|
|
467
468
|
});
|
|
468
469
|
let o;
|
|
469
470
|
try {
|
|
470
|
-
const h =
|
|
471
|
+
const h = He(i);
|
|
471
472
|
if (h == null)
|
|
472
473
|
o = {};
|
|
473
474
|
else if (typeof h == "object" && !Array.isArray(h))
|
|
@@ -495,14 +496,14 @@ ${i}
|
|
|
495
496
|
---`
|
|
496
497
|
};
|
|
497
498
|
}
|
|
498
|
-
const
|
|
499
|
+
const Ot = /* @__PURE__ */ new Set([
|
|
499
500
|
"string",
|
|
500
501
|
"number",
|
|
501
502
|
"boolean",
|
|
502
503
|
"object",
|
|
503
504
|
"array"
|
|
504
505
|
]);
|
|
505
|
-
function
|
|
506
|
+
function Rt(t, e) {
|
|
506
507
|
const n = t.props;
|
|
507
508
|
if (n === void 0)
|
|
508
509
|
return {};
|
|
@@ -521,13 +522,13 @@ function Wt(t, e) {
|
|
|
521
522
|
const o = s, a = {};
|
|
522
523
|
if ("type" in o && o.type !== void 0) {
|
|
523
524
|
const c = String(o.type);
|
|
524
|
-
|
|
525
|
+
Ot.has(c) ? a.type = c : a.type = void 0;
|
|
525
526
|
}
|
|
526
527
|
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[i] = a;
|
|
527
528
|
}
|
|
528
529
|
return r;
|
|
529
530
|
}
|
|
530
|
-
function
|
|
531
|
+
function Mt(t) {
|
|
531
532
|
if (t != null) {
|
|
532
533
|
if (typeof t == "string") return "string";
|
|
533
534
|
if (typeof t == "number") return "number";
|
|
@@ -536,17 +537,17 @@ function Tt(t) {
|
|
|
536
537
|
if (typeof t == "object") return "object";
|
|
537
538
|
}
|
|
538
539
|
}
|
|
539
|
-
function
|
|
540
|
+
function Ht(t, e) {
|
|
540
541
|
return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
|
|
541
542
|
}
|
|
542
543
|
function G(t, e) {
|
|
543
544
|
return {
|
|
544
545
|
code: t,
|
|
545
|
-
message:
|
|
546
|
+
message: H(t, e),
|
|
546
547
|
details: e
|
|
547
548
|
};
|
|
548
549
|
}
|
|
549
|
-
function
|
|
550
|
+
function Dt(t, e, n) {
|
|
550
551
|
const r = [], i = {}, s = new Set(Object.keys(e));
|
|
551
552
|
for (const [o, a] of Object.entries(e)) {
|
|
552
553
|
const c = Object.prototype.hasOwnProperty.call(t, o);
|
|
@@ -557,8 +558,8 @@ function Rt(t, e, n) {
|
|
|
557
558
|
component: n
|
|
558
559
|
})
|
|
559
560
|
), h = void 0)), c && h !== void 0 && h !== null) {
|
|
560
|
-
const l = a.type ??
|
|
561
|
-
l && !
|
|
561
|
+
const l = a.type ?? Mt(h);
|
|
562
|
+
l && !Ht(h, l) && (r.push(
|
|
562
563
|
G("prop_type_mismatch", {
|
|
563
564
|
prop: o,
|
|
564
565
|
component: n,
|
|
@@ -578,7 +579,7 @@ function Rt(t, e, n) {
|
|
|
578
579
|
) : i[o] = t[o]);
|
|
579
580
|
return { values: i, warnings: r };
|
|
580
581
|
}
|
|
581
|
-
async function
|
|
582
|
+
async function Nt(t) {
|
|
582
583
|
const e = t.registry.get(t.alias);
|
|
583
584
|
if (!e)
|
|
584
585
|
throw d({
|
|
@@ -588,13 +589,13 @@ async function Mt(t) {
|
|
|
588
589
|
message: `unregistered component: ${t.alias}`
|
|
589
590
|
}
|
|
590
591
|
});
|
|
591
|
-
const n =
|
|
592
|
+
const n = D(e.componentPath) ? e.componentPath : Z(e.componentPath, {
|
|
592
593
|
rootDir: t.rootDir,
|
|
593
594
|
fromPath: e.definedAt,
|
|
594
595
|
documentPath: t.path,
|
|
595
596
|
constrainToRoot: t.constrainToRoot,
|
|
596
597
|
hyogenPath: !0
|
|
597
|
-
}), r = await t.loader(n), { context: i, body: s } =
|
|
598
|
+
}), r = await t.loader(n), { context: i, body: s } = q(r, n), o = Rt(i, n), { values: a, warnings: c } = Dt(
|
|
598
599
|
t.props,
|
|
599
600
|
o,
|
|
600
601
|
t.alias
|
|
@@ -604,7 +605,8 @@ async function Mt(t) {
|
|
|
604
605
|
t.parentContext,
|
|
605
606
|
l,
|
|
606
607
|
a
|
|
607
|
-
)
|
|
608
|
+
);
|
|
609
|
+
return (await ke(s, {
|
|
608
610
|
context: u,
|
|
609
611
|
loader: t.loader,
|
|
610
612
|
root: t.rootDir,
|
|
@@ -617,36 +619,28 @@ async function Mt(t) {
|
|
|
617
619
|
preserveHgComments: t.preserveHgComments,
|
|
618
620
|
constrainToRoot: t.constrainToRoot
|
|
619
621
|
})).trim();
|
|
620
|
-
if (m.includes(`
|
|
621
|
-
`))
|
|
622
|
-
throw d({
|
|
623
|
-
code: "component_multiline_output",
|
|
624
|
-
path: n,
|
|
625
|
-
details: { alias: t.alias }
|
|
626
|
-
});
|
|
627
|
-
return m;
|
|
628
622
|
}
|
|
629
|
-
const
|
|
623
|
+
const Ft = /* @__PURE__ */ new Set([
|
|
630
624
|
"__proto__",
|
|
631
625
|
"prototype",
|
|
632
626
|
"constructor",
|
|
633
627
|
"__defineGetter__"
|
|
634
628
|
]);
|
|
635
|
-
function
|
|
636
|
-
return
|
|
629
|
+
function jt(t) {
|
|
630
|
+
return Ft.has(t);
|
|
637
631
|
}
|
|
638
|
-
function
|
|
639
|
-
if (
|
|
632
|
+
function Se(t, e) {
|
|
633
|
+
if (jt(t))
|
|
640
634
|
throw d({
|
|
641
635
|
code: "forbidden_property_access",
|
|
642
636
|
path: e,
|
|
643
637
|
details: { property: t }
|
|
644
638
|
});
|
|
645
639
|
}
|
|
646
|
-
function
|
|
640
|
+
function R(t) {
|
|
647
641
|
return !t;
|
|
648
642
|
}
|
|
649
|
-
function
|
|
643
|
+
function Bt(t, e) {
|
|
650
644
|
if (t != null) {
|
|
651
645
|
if (typeof t == "string")
|
|
652
646
|
return e === "length" ? t.length : void 0;
|
|
@@ -654,7 +648,7 @@ function Ht(t, e) {
|
|
|
654
648
|
return t[e];
|
|
655
649
|
}
|
|
656
650
|
}
|
|
657
|
-
function
|
|
651
|
+
function It(t, e, n) {
|
|
658
652
|
switch (t) {
|
|
659
653
|
case "+":
|
|
660
654
|
return e + n;
|
|
@@ -681,44 +675,44 @@ function Dt(t, e, n) {
|
|
|
681
675
|
case "<":
|
|
682
676
|
return e < n;
|
|
683
677
|
case "&&":
|
|
684
|
-
return
|
|
678
|
+
return R(e) ? e : n;
|
|
685
679
|
case "||":
|
|
686
|
-
return
|
|
680
|
+
return R(e) ? n : e;
|
|
687
681
|
default:
|
|
688
682
|
return;
|
|
689
683
|
}
|
|
690
684
|
}
|
|
691
|
-
async function
|
|
685
|
+
async function y(t, e) {
|
|
692
686
|
const { context: n, path: r } = e;
|
|
693
687
|
switch (t.type) {
|
|
694
688
|
case "literal":
|
|
695
689
|
return t.value;
|
|
696
690
|
case "identifier":
|
|
697
|
-
return
|
|
691
|
+
return Se(t.name, r), n[t.name];
|
|
698
692
|
case "member": {
|
|
699
|
-
|
|
700
|
-
const i = await
|
|
701
|
-
return
|
|
693
|
+
Se(t.property, r);
|
|
694
|
+
const i = await y(t.object, e);
|
|
695
|
+
return Bt(i, t.property);
|
|
702
696
|
}
|
|
703
697
|
case "default": {
|
|
704
|
-
const i = await
|
|
705
|
-
return
|
|
698
|
+
const i = await y(t.left, e);
|
|
699
|
+
return R(i) ? y(t.right, e) : i;
|
|
706
700
|
}
|
|
707
701
|
case "unary": {
|
|
708
|
-
const i = await
|
|
702
|
+
const i = await y(t.operand, e);
|
|
709
703
|
return t.op === "!" ? !i : void 0;
|
|
710
704
|
}
|
|
711
705
|
case "binary": {
|
|
712
706
|
if (t.op === "&&") {
|
|
713
|
-
const o = await
|
|
714
|
-
return
|
|
707
|
+
const o = await y(t.left, e);
|
|
708
|
+
return R(o) ? o : y(t.right, e);
|
|
715
709
|
}
|
|
716
710
|
if (t.op === "||") {
|
|
717
|
-
const o = await
|
|
718
|
-
return
|
|
711
|
+
const o = await y(t.left, e);
|
|
712
|
+
return R(o) ? y(t.right, e) : o;
|
|
719
713
|
}
|
|
720
|
-
const i = await
|
|
721
|
-
return
|
|
714
|
+
const i = await y(t.left, e), s = await y(t.right, e);
|
|
715
|
+
return It(t.op, i, s);
|
|
722
716
|
}
|
|
723
717
|
case "call": {
|
|
724
718
|
if (!e.registry || !e.loader || !e.visitStack)
|
|
@@ -739,8 +733,8 @@ async function k(t, e) {
|
|
|
739
733
|
});
|
|
740
734
|
const i = {};
|
|
741
735
|
for (const [s, o] of Object.entries(t.args))
|
|
742
|
-
i[s] = await
|
|
743
|
-
return
|
|
736
|
+
i[s] = await y(o, e);
|
|
737
|
+
return Nt({
|
|
744
738
|
alias: t.callee,
|
|
745
739
|
props: i,
|
|
746
740
|
parentContext: e.parentContext ?? n,
|
|
@@ -761,14 +755,14 @@ async function k(t, e) {
|
|
|
761
755
|
path: r,
|
|
762
756
|
details: { message: `unsupported method: ${t.method}()` }
|
|
763
757
|
});
|
|
764
|
-
const i = await
|
|
758
|
+
const i = await y(t.object, e);
|
|
765
759
|
return i == null || typeof i.toLocaleString != "function" ? void 0 : i.toLocaleString(
|
|
766
760
|
...t.args
|
|
767
761
|
);
|
|
768
762
|
}
|
|
769
763
|
case "ternary": {
|
|
770
|
-
const i = await
|
|
771
|
-
return
|
|
764
|
+
const i = await y(t.condition, e);
|
|
765
|
+
return R(i) ? y(t.alternate, e) : y(t.consequent, e);
|
|
772
766
|
}
|
|
773
767
|
case "template": {
|
|
774
768
|
let i = "";
|
|
@@ -776,7 +770,7 @@ async function k(t, e) {
|
|
|
776
770
|
if (typeof s == "string")
|
|
777
771
|
i += s;
|
|
778
772
|
else {
|
|
779
|
-
const o = await
|
|
773
|
+
const o = await y(s, e);
|
|
780
774
|
o != null && (i += String(o));
|
|
781
775
|
}
|
|
782
776
|
return i;
|
|
@@ -785,17 +779,17 @@ async function k(t, e) {
|
|
|
785
779
|
return;
|
|
786
780
|
}
|
|
787
781
|
}
|
|
788
|
-
function
|
|
782
|
+
function J(t) {
|
|
789
783
|
return /[A-Za-z_$]/.test(t);
|
|
790
784
|
}
|
|
791
|
-
function
|
|
785
|
+
function Ut(t) {
|
|
792
786
|
return /[A-Za-z0-9_$]/.test(t);
|
|
793
787
|
}
|
|
794
788
|
function S(t, e, n = {}) {
|
|
795
789
|
const r = t.trim();
|
|
796
790
|
if (r.length === 0)
|
|
797
791
|
throw g(e, "empty expression");
|
|
798
|
-
const i = new
|
|
792
|
+
const i = new zt(r, e, n), s = i.parseExpression();
|
|
799
793
|
if (i.skipWhitespace(), i.hasMore())
|
|
800
794
|
throw g(e, `unexpected token at position ${i.position}`);
|
|
801
795
|
return s;
|
|
@@ -807,7 +801,7 @@ function g(t, e) {
|
|
|
807
801
|
details: { message: e }
|
|
808
802
|
});
|
|
809
803
|
}
|
|
810
|
-
class
|
|
804
|
+
class zt {
|
|
811
805
|
constructor(e, n, r = {}) {
|
|
812
806
|
this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
|
|
813
807
|
}
|
|
@@ -978,7 +972,7 @@ class Ft {
|
|
|
978
972
|
return { type: "literal", value: this.parseObjectLiteral() };
|
|
979
973
|
if (e === "[")
|
|
980
974
|
return { type: "literal", value: this.parseArrayLiteral() };
|
|
981
|
-
if (
|
|
975
|
+
if (J(e)) {
|
|
982
976
|
const n = this.readIdentifier();
|
|
983
977
|
if (n === "true" || n === "false" || n === "null" || n === "undefined")
|
|
984
978
|
return { type: "literal", value: n === "true" ? !0 : n === "false" ? !1 : n === "null" ? null : void 0 };
|
|
@@ -1155,7 +1149,7 @@ class Ft {
|
|
|
1155
1149
|
return this.parseObjectLiteral();
|
|
1156
1150
|
if (e === "[")
|
|
1157
1151
|
return this.parseArrayLiteral();
|
|
1158
|
-
if (
|
|
1152
|
+
if (J(e)) {
|
|
1159
1153
|
const n = this.readIdentifier();
|
|
1160
1154
|
if (n === "true") return !0;
|
|
1161
1155
|
if (n === "false") return !1;
|
|
@@ -1173,9 +1167,9 @@ class Ft {
|
|
|
1173
1167
|
readIdentifier() {
|
|
1174
1168
|
this.skipWhitespace();
|
|
1175
1169
|
const e = this.index;
|
|
1176
|
-
if (!
|
|
1170
|
+
if (!J(this.peek()))
|
|
1177
1171
|
return "";
|
|
1178
|
-
for (this.index++; this.index < this.input.length &&
|
|
1172
|
+
for (this.index++; this.index < this.input.length && Ut(this.peek()); )
|
|
1179
1173
|
this.index++;
|
|
1180
1174
|
return this.input.slice(e, this.index);
|
|
1181
1175
|
}
|
|
@@ -1208,7 +1202,136 @@ class Ft {
|
|
|
1208
1202
|
return r;
|
|
1209
1203
|
}
|
|
1210
1204
|
}
|
|
1211
|
-
|
|
1205
|
+
const Vt = /^( {0,3})(=+|-+)[ \t]*$/, Be = /^( {0,3})(`{3,}|~{3,})(.*)$/;
|
|
1206
|
+
function O(t) {
|
|
1207
|
+
return t === " " || t === " ";
|
|
1208
|
+
}
|
|
1209
|
+
function Ie(t) {
|
|
1210
|
+
let e = 0;
|
|
1211
|
+
for (; e < t.length && e < 3 && t[e] === " "; )
|
|
1212
|
+
e += 1;
|
|
1213
|
+
const n = t.slice(0, e);
|
|
1214
|
+
let r = 0;
|
|
1215
|
+
for (; e < t.length && r < 6 && t[e] === "#"; )
|
|
1216
|
+
r += 1, e += 1;
|
|
1217
|
+
if (r === 0 || r === 6 && e < t.length && t[e] === "#")
|
|
1218
|
+
return null;
|
|
1219
|
+
if (e >= t.length)
|
|
1220
|
+
return { indent: n, level: r, text: "" };
|
|
1221
|
+
if (!O(t[e]))
|
|
1222
|
+
return null;
|
|
1223
|
+
for (; e < t.length && O(t[e]); )
|
|
1224
|
+
e += 1;
|
|
1225
|
+
let i = t.length;
|
|
1226
|
+
for (; i > e && O(t[i - 1]); )
|
|
1227
|
+
i -= 1;
|
|
1228
|
+
let s = i;
|
|
1229
|
+
if (i > e && t[i - 1] === "#") {
|
|
1230
|
+
let o = i - 1;
|
|
1231
|
+
for (; o > e && t[o - 1] === "#"; )
|
|
1232
|
+
o -= 1;
|
|
1233
|
+
if (o > e && O(t[o - 1])) {
|
|
1234
|
+
let a = o - 1;
|
|
1235
|
+
for (; a >= e && O(t[a]); )
|
|
1236
|
+
a -= 1;
|
|
1237
|
+
s = a + 1;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
return { indent: n, level: r, text: t.slice(e, s) };
|
|
1241
|
+
}
|
|
1242
|
+
function oe() {
|
|
1243
|
+
return { active: !1, marker: null, length: 0 };
|
|
1244
|
+
}
|
|
1245
|
+
function ae(t, e) {
|
|
1246
|
+
const n = Be.exec(e);
|
|
1247
|
+
if (!t.active) {
|
|
1248
|
+
if (n) {
|
|
1249
|
+
const r = n[2];
|
|
1250
|
+
return t.active = !0, t.marker = r[0], t.length = r.length, !0;
|
|
1251
|
+
}
|
|
1252
|
+
return !1;
|
|
1253
|
+
}
|
|
1254
|
+
if (n) {
|
|
1255
|
+
const r = n[2], i = (n[3] ?? "").trim();
|
|
1256
|
+
r[0] === t.marker && r.length >= t.length && i.length === 0 && (t.active = !1, t.marker = null, t.length = 0);
|
|
1257
|
+
}
|
|
1258
|
+
return !0;
|
|
1259
|
+
}
|
|
1260
|
+
function Ue(t) {
|
|
1261
|
+
const e = Ie(t);
|
|
1262
|
+
return e ? e.level : null;
|
|
1263
|
+
}
|
|
1264
|
+
function ze(t) {
|
|
1265
|
+
const e = Vt.exec(t);
|
|
1266
|
+
return e ? e[2][0] === "=" ? 1 : 2 : null;
|
|
1267
|
+
}
|
|
1268
|
+
function Zt(t) {
|
|
1269
|
+
for (let e = 0; e < t.length; e++)
|
|
1270
|
+
if (!O(t[e]))
|
|
1271
|
+
return !1;
|
|
1272
|
+
return !0;
|
|
1273
|
+
}
|
|
1274
|
+
function Ve(t) {
|
|
1275
|
+
return !(Zt(t) || Ue(t) !== null || Be.test(t) || t.startsWith(" ") || t.startsWith(" "));
|
|
1276
|
+
}
|
|
1277
|
+
function Ze(t) {
|
|
1278
|
+
const e = t.split(`
|
|
1279
|
+
`), n = oe();
|
|
1280
|
+
let r = 0;
|
|
1281
|
+
for (let i = 0; i < e.length; i++) {
|
|
1282
|
+
const s = e[i];
|
|
1283
|
+
if (ae(n, s))
|
|
1284
|
+
continue;
|
|
1285
|
+
const o = Ue(s);
|
|
1286
|
+
if (o !== null) {
|
|
1287
|
+
r = o;
|
|
1288
|
+
continue;
|
|
1289
|
+
}
|
|
1290
|
+
const a = ze(s);
|
|
1291
|
+
if (a !== null && i > 0) {
|
|
1292
|
+
const c = e[i - 1];
|
|
1293
|
+
Ve(c) && (r = a);
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
return r;
|
|
1297
|
+
}
|
|
1298
|
+
function qt(t) {
|
|
1299
|
+
return t < 1 ? 1 : t > 6 ? 6 : t;
|
|
1300
|
+
}
|
|
1301
|
+
function Ee(t, e) {
|
|
1302
|
+
const n = e.trim(), r = "#".repeat(qt(t));
|
|
1303
|
+
return n.length === 0 ? r : `${r} ${n}`;
|
|
1304
|
+
}
|
|
1305
|
+
function qe(t, e) {
|
|
1306
|
+
if (e <= 0 || t.length === 0)
|
|
1307
|
+
return t;
|
|
1308
|
+
const n = t.split(`
|
|
1309
|
+
`), r = oe(), i = [];
|
|
1310
|
+
for (let s = 0; s < n.length; s++) {
|
|
1311
|
+
const o = n[s];
|
|
1312
|
+
if (ae(r, o)) {
|
|
1313
|
+
i.push(o);
|
|
1314
|
+
continue;
|
|
1315
|
+
}
|
|
1316
|
+
const a = ze(o);
|
|
1317
|
+
if (a !== null && i.length > 0) {
|
|
1318
|
+
const h = i[i.length - 1];
|
|
1319
|
+
if (Ve(h)) {
|
|
1320
|
+
i[i.length - 1] = Ee(a + e, h);
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
const c = Ie(o);
|
|
1325
|
+
if (c !== null) {
|
|
1326
|
+
i.push(c.indent + Ee(c.level + e, c.text));
|
|
1327
|
+
continue;
|
|
1328
|
+
}
|
|
1329
|
+
i.push(o);
|
|
1330
|
+
}
|
|
1331
|
+
return i.join(`
|
|
1332
|
+
`);
|
|
1333
|
+
}
|
|
1334
|
+
async function Pe(t, e, n = {}) {
|
|
1212
1335
|
const r = n.path;
|
|
1213
1336
|
let i = "", s = 0;
|
|
1214
1337
|
for (; s < t.length; ) {
|
|
@@ -1230,17 +1353,121 @@ async function Ne(t, e, n = {}) {
|
|
|
1230
1353
|
path: r,
|
|
1231
1354
|
details: { message: "unclosed expression" }
|
|
1232
1355
|
});
|
|
1233
|
-
const
|
|
1356
|
+
const p = t.slice(o + h, u).trim(), x = S(p, r), m = await y(x, {
|
|
1234
1357
|
...n,
|
|
1235
1358
|
context: e,
|
|
1236
1359
|
path: r,
|
|
1237
1360
|
parentContext: n.parentContext ?? e
|
|
1238
1361
|
});
|
|
1239
|
-
|
|
1362
|
+
let w = m == null ? "" : String(m);
|
|
1363
|
+
if (x.type === "call" && w.length > 0) {
|
|
1364
|
+
const _ = Ze(i);
|
|
1365
|
+
w = qe(w, _);
|
|
1366
|
+
}
|
|
1367
|
+
i += w, s = u + l.length;
|
|
1240
1368
|
}
|
|
1241
1369
|
return i;
|
|
1242
1370
|
}
|
|
1243
|
-
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) {
|
|
1244
1471
|
let n = 0, r = 0;
|
|
1245
1472
|
for (; r < t.length; ) {
|
|
1246
1473
|
const i = t.indexOf(e, r);
|
|
@@ -1250,14 +1477,14 @@ function jt(t, e) {
|
|
|
1250
1477
|
}
|
|
1251
1478
|
return n;
|
|
1252
1479
|
}
|
|
1253
|
-
function
|
|
1254
|
-
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, "@@");
|
|
1255
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";
|
|
1256
1483
|
}
|
|
1257
|
-
function
|
|
1484
|
+
function le(t) {
|
|
1258
1485
|
return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
|
|
1259
1486
|
}
|
|
1260
|
-
function
|
|
1487
|
+
function he(t, e) {
|
|
1261
1488
|
let n = 0, r = !1;
|
|
1262
1489
|
for (; n < e; ) {
|
|
1263
1490
|
const i = t.indexOf("```", n);
|
|
@@ -1267,21 +1494,21 @@ function le(t, e) {
|
|
|
1267
1494
|
}
|
|
1268
1495
|
return r;
|
|
1269
1496
|
}
|
|
1270
|
-
function
|
|
1497
|
+
function W(t) {
|
|
1271
1498
|
const e = [];
|
|
1272
1499
|
let n = 0;
|
|
1273
1500
|
for (; n < t.length; ) {
|
|
1274
1501
|
const r = t.indexOf("<!--", n);
|
|
1275
1502
|
if (r === -1)
|
|
1276
1503
|
break;
|
|
1277
|
-
if (
|
|
1504
|
+
if (he(t, r)) {
|
|
1278
1505
|
n = r + 4;
|
|
1279
1506
|
continue;
|
|
1280
1507
|
}
|
|
1281
1508
|
const i = t.indexOf("-->", r + 4);
|
|
1282
1509
|
if (i === -1)
|
|
1283
1510
|
break;
|
|
1284
|
-
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);
|
|
1285
1512
|
(a === "hg" || a === "at-at") && e.push({
|
|
1286
1513
|
start: r,
|
|
1287
1514
|
end: i + 3,
|
|
@@ -1291,40 +1518,40 @@ function $(t) {
|
|
|
1291
1518
|
}
|
|
1292
1519
|
return e;
|
|
1293
1520
|
}
|
|
1294
|
-
function
|
|
1521
|
+
function de(t) {
|
|
1295
1522
|
let e = 0;
|
|
1296
1523
|
for (; e < t.length; ) {
|
|
1297
1524
|
const n = t.indexOf("<!--", e);
|
|
1298
1525
|
if (n === -1)
|
|
1299
1526
|
return !1;
|
|
1300
|
-
if (
|
|
1527
|
+
if (he(t, n)) {
|
|
1301
1528
|
e = n + 4;
|
|
1302
1529
|
continue;
|
|
1303
1530
|
}
|
|
1304
1531
|
const r = t.indexOf("-->", n + 4);
|
|
1305
1532
|
if (r === -1)
|
|
1306
1533
|
return !1;
|
|
1307
|
-
const i = t.slice(n + 4, r), s =
|
|
1534
|
+
const i = t.slice(n + 4, r), s = ce(i);
|
|
1308
1535
|
if (s === "unclosed" || s === "mixed")
|
|
1309
1536
|
return !0;
|
|
1310
1537
|
e = r + 3;
|
|
1311
1538
|
}
|
|
1312
1539
|
return !1;
|
|
1313
1540
|
}
|
|
1314
|
-
function
|
|
1541
|
+
function ue(t) {
|
|
1315
1542
|
let e = 0;
|
|
1316
1543
|
for (; e < t.length; ) {
|
|
1317
1544
|
const n = t.indexOf("<!--", e);
|
|
1318
1545
|
if (n === -1)
|
|
1319
1546
|
return null;
|
|
1320
|
-
if (
|
|
1547
|
+
if (he(t, n)) {
|
|
1321
1548
|
e = n + 4;
|
|
1322
1549
|
continue;
|
|
1323
1550
|
}
|
|
1324
1551
|
const r = t.indexOf("-->", n + 4);
|
|
1325
1552
|
if (r === -1)
|
|
1326
1553
|
return null;
|
|
1327
|
-
const i = t.slice(n + 4, r), s =
|
|
1554
|
+
const i = t.slice(n + 4, r), s = ce(i);
|
|
1328
1555
|
if (s === "mixed")
|
|
1329
1556
|
return "mixed @hg and @@ markers are not allowed";
|
|
1330
1557
|
if (s === "unclosed")
|
|
@@ -1333,25 +1560,25 @@ function de(t) {
|
|
|
1333
1560
|
}
|
|
1334
1561
|
return null;
|
|
1335
1562
|
}
|
|
1336
|
-
function
|
|
1337
|
-
return
|
|
1563
|
+
function $(t) {
|
|
1564
|
+
return le(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
|
|
1338
1565
|
}
|
|
1339
|
-
const
|
|
1340
|
-
function
|
|
1341
|
-
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());
|
|
1342
1569
|
}
|
|
1343
|
-
function
|
|
1570
|
+
function Q(t, e) {
|
|
1344
1571
|
throw d({
|
|
1345
1572
|
code: "parse_error",
|
|
1346
1573
|
path: t,
|
|
1347
1574
|
details: { message: e }
|
|
1348
1575
|
});
|
|
1349
1576
|
}
|
|
1350
|
-
function
|
|
1577
|
+
function Qt(t, e) {
|
|
1351
1578
|
let n = t;
|
|
1352
1579
|
const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
|
|
1353
1580
|
r && (n = r[1]);
|
|
1354
|
-
const i =
|
|
1581
|
+
const i = $(n);
|
|
1355
1582
|
if (i.length !== 1)
|
|
1356
1583
|
return null;
|
|
1357
1584
|
const s = i[0];
|
|
@@ -1364,7 +1591,7 @@ function It(t, e) {
|
|
|
1364
1591
|
if (s === "endeach")
|
|
1365
1592
|
return { kind: "endeach" };
|
|
1366
1593
|
if (/^IF\b/.test(s) || /^ELSE\b/.test(s) || /^ENDIF\b/.test(s))
|
|
1367
|
-
throw
|
|
1594
|
+
throw Q(e, "control keywords must be lowercase");
|
|
1368
1595
|
const o = /^else\s+if\s+(.+)$/.exec(s);
|
|
1369
1596
|
if (o)
|
|
1370
1597
|
return {
|
|
@@ -1385,12 +1612,12 @@ function It(t, e) {
|
|
|
1385
1612
|
expr: S(c[2], e)
|
|
1386
1613
|
};
|
|
1387
1614
|
if (s === "if")
|
|
1388
|
-
throw
|
|
1615
|
+
throw Q(e, "if requires an expression");
|
|
1389
1616
|
if (/^each\s+/.test(s))
|
|
1390
|
-
throw
|
|
1617
|
+
throw Q(e, "invalid each directive");
|
|
1391
1618
|
return null;
|
|
1392
1619
|
}
|
|
1393
|
-
function
|
|
1620
|
+
function M(t) {
|
|
1394
1621
|
return { start: t.start, end: t.end, raw: t.raw };
|
|
1395
1622
|
}
|
|
1396
1623
|
function C(t, e) {
|
|
@@ -1400,10 +1627,10 @@ function C(t, e) {
|
|
|
1400
1627
|
details: { message: e }
|
|
1401
1628
|
});
|
|
1402
1629
|
}
|
|
1403
|
-
function
|
|
1630
|
+
function en(t, e) {
|
|
1404
1631
|
const n = [];
|
|
1405
|
-
for (const r of
|
|
1406
|
-
const i =
|
|
1632
|
+
for (const r of W(t)) {
|
|
1633
|
+
const i = Qt(r.inner, e);
|
|
1407
1634
|
i && n.push({
|
|
1408
1635
|
start: r.start,
|
|
1409
1636
|
end: r.end,
|
|
@@ -1413,14 +1640,14 @@ function Ut(t, e) {
|
|
|
1413
1640
|
}
|
|
1414
1641
|
return n;
|
|
1415
1642
|
}
|
|
1416
|
-
function
|
|
1643
|
+
function Ye(t) {
|
|
1417
1644
|
return t.kind === "if" || t.kind === "each";
|
|
1418
1645
|
}
|
|
1419
|
-
function
|
|
1420
|
-
const n =
|
|
1646
|
+
function tn(t, e) {
|
|
1647
|
+
const n = en(t, e);
|
|
1421
1648
|
if (n.length === 0)
|
|
1422
1649
|
return t.length > 0 ? [{ kind: "text", content: t }] : [];
|
|
1423
|
-
const { nodes: r, nextIndex: i } =
|
|
1650
|
+
const { nodes: r, nextIndex: i } = j(t, n, 0, n.length, e);
|
|
1424
1651
|
if (i < n.length) {
|
|
1425
1652
|
const s = n[i];
|
|
1426
1653
|
if (s.opener.kind === "endif")
|
|
@@ -1432,7 +1659,7 @@ function zt(t, e) {
|
|
|
1432
1659
|
}
|
|
1433
1660
|
return r;
|
|
1434
1661
|
}
|
|
1435
|
-
function
|
|
1662
|
+
function j(t, e, n, r, i, s = 0, o) {
|
|
1436
1663
|
const a = o ?? t.length, c = [];
|
|
1437
1664
|
let h = s, l = n;
|
|
1438
1665
|
for (; l < r; ) {
|
|
@@ -1447,13 +1674,13 @@ function F(t, e, n, r, i, s = 0, o) {
|
|
|
1447
1674
|
kind: "text",
|
|
1448
1675
|
content: t.slice(h, u.start)
|
|
1449
1676
|
}), u.opener.kind === "if") {
|
|
1450
|
-
const
|
|
1451
|
-
c.push(
|
|
1677
|
+
const p = nn(t, e, l, r, i);
|
|
1678
|
+
c.push(p.node), h = p.endPos, l = p.nextIndex;
|
|
1452
1679
|
continue;
|
|
1453
1680
|
}
|
|
1454
1681
|
if (u.opener.kind === "each") {
|
|
1455
|
-
const
|
|
1456
|
-
c.push(
|
|
1682
|
+
const p = rn(t, e, l, r, i);
|
|
1683
|
+
c.push(p.node), h = p.endPos, l = p.nextIndex;
|
|
1457
1684
|
continue;
|
|
1458
1685
|
}
|
|
1459
1686
|
if (u.opener.kind === "else" || u.opener.kind === "else_if")
|
|
@@ -1466,7 +1693,7 @@ function F(t, e, n, r, i, s = 0, o) {
|
|
|
1466
1693
|
}
|
|
1467
1694
|
return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
|
|
1468
1695
|
}
|
|
1469
|
-
function
|
|
1696
|
+
function nn(t, e, n, r, i) {
|
|
1470
1697
|
const s = e[n];
|
|
1471
1698
|
if (s.opener.kind !== "if")
|
|
1472
1699
|
throw C(i, "expected if");
|
|
@@ -1480,18 +1707,18 @@ function Zt(t, e, n, r, i) {
|
|
|
1480
1707
|
o.push({
|
|
1481
1708
|
kind: "if",
|
|
1482
1709
|
expr: l.opener.expr,
|
|
1483
|
-
opener:
|
|
1710
|
+
opener: M(l),
|
|
1484
1711
|
body: []
|
|
1485
1712
|
}), a++;
|
|
1486
1713
|
continue;
|
|
1487
1714
|
}
|
|
1488
|
-
if (
|
|
1715
|
+
if (Ye(l.opener)) {
|
|
1489
1716
|
h++, a++;
|
|
1490
1717
|
continue;
|
|
1491
1718
|
}
|
|
1492
1719
|
if (l.opener.kind === "endif") {
|
|
1493
1720
|
if (h === 0)
|
|
1494
|
-
return o[o.length - 1].body =
|
|
1721
|
+
return o[o.length - 1].body = j(
|
|
1495
1722
|
t,
|
|
1496
1723
|
e,
|
|
1497
1724
|
n + 1,
|
|
@@ -1500,7 +1727,7 @@ function Zt(t, e, n, r, i) {
|
|
|
1500
1727
|
c,
|
|
1501
1728
|
l.start
|
|
1502
1729
|
).nodes, {
|
|
1503
|
-
node: { kind: "if", branches: o, closer:
|
|
1730
|
+
node: { kind: "if", branches: o, closer: M(l) },
|
|
1504
1731
|
nextIndex: a + 1,
|
|
1505
1732
|
endPos: l.end
|
|
1506
1733
|
};
|
|
@@ -1513,7 +1740,7 @@ function Zt(t, e, n, r, i) {
|
|
|
1513
1740
|
}
|
|
1514
1741
|
if (h === 0) {
|
|
1515
1742
|
if (l.opener.kind === "else_if") {
|
|
1516
|
-
o[o.length - 1].body =
|
|
1743
|
+
o[o.length - 1].body = j(
|
|
1517
1744
|
t,
|
|
1518
1745
|
e,
|
|
1519
1746
|
n + 1,
|
|
@@ -1524,13 +1751,13 @@ function Zt(t, e, n, r, i) {
|
|
|
1524
1751
|
).nodes, o.push({
|
|
1525
1752
|
kind: "else_if",
|
|
1526
1753
|
expr: l.opener.expr,
|
|
1527
|
-
opener:
|
|
1754
|
+
opener: M(l),
|
|
1528
1755
|
body: []
|
|
1529
1756
|
}), c = l.end, a++;
|
|
1530
1757
|
continue;
|
|
1531
1758
|
}
|
|
1532
1759
|
if (l.opener.kind === "else") {
|
|
1533
|
-
o[o.length - 1].body =
|
|
1760
|
+
o[o.length - 1].body = j(
|
|
1534
1761
|
t,
|
|
1535
1762
|
e,
|
|
1536
1763
|
n + 1,
|
|
@@ -1540,7 +1767,7 @@ function Zt(t, e, n, r, i) {
|
|
|
1540
1767
|
l.start
|
|
1541
1768
|
).nodes, o.push({
|
|
1542
1769
|
kind: "else",
|
|
1543
|
-
opener:
|
|
1770
|
+
opener: M(l),
|
|
1544
1771
|
body: []
|
|
1545
1772
|
}), c = l.end, a++;
|
|
1546
1773
|
continue;
|
|
@@ -1550,7 +1777,7 @@ function Zt(t, e, n, r, i) {
|
|
|
1550
1777
|
}
|
|
1551
1778
|
throw C(i, "unclosed if block (missing endif)");
|
|
1552
1779
|
}
|
|
1553
|
-
function
|
|
1780
|
+
function rn(t, e, n, r, i) {
|
|
1554
1781
|
const s = e[n];
|
|
1555
1782
|
if (s.opener.kind !== "each")
|
|
1556
1783
|
throw C(i, "expected each");
|
|
@@ -1559,13 +1786,13 @@ function Vt(t, e, n, r, i) {
|
|
|
1559
1786
|
let c = 0;
|
|
1560
1787
|
for (; o < r; ) {
|
|
1561
1788
|
const h = e[o];
|
|
1562
|
-
if (
|
|
1789
|
+
if (Ye(h.opener)) {
|
|
1563
1790
|
c++, o++;
|
|
1564
1791
|
continue;
|
|
1565
1792
|
}
|
|
1566
1793
|
if (h.opener.kind === "endeach") {
|
|
1567
1794
|
if (c === 0) {
|
|
1568
|
-
const l =
|
|
1795
|
+
const l = j(
|
|
1569
1796
|
t,
|
|
1570
1797
|
e,
|
|
1571
1798
|
n + 1,
|
|
@@ -1579,9 +1806,9 @@ function Vt(t, e, n, r, i) {
|
|
|
1579
1806
|
kind: "each",
|
|
1580
1807
|
item: s.opener.item,
|
|
1581
1808
|
expr: s.opener.expr,
|
|
1582
|
-
opener:
|
|
1809
|
+
opener: M(s),
|
|
1583
1810
|
body: l,
|
|
1584
|
-
closer:
|
|
1811
|
+
closer: M(h)
|
|
1585
1812
|
},
|
|
1586
1813
|
nextIndex: o + 1,
|
|
1587
1814
|
endPos: h.end
|
|
@@ -1598,26 +1825,26 @@ function Vt(t, e, n, r, i) {
|
|
|
1598
1825
|
}
|
|
1599
1826
|
throw C(i, "unclosed each block (missing endeach)");
|
|
1600
1827
|
}
|
|
1601
|
-
const
|
|
1602
|
-
class
|
|
1828
|
+
const Ce = 20;
|
|
1829
|
+
class sn {
|
|
1603
1830
|
depth = 0;
|
|
1604
1831
|
get currentDepth() {
|
|
1605
1832
|
return this.depth;
|
|
1606
1833
|
}
|
|
1607
1834
|
enter() {
|
|
1608
|
-
return this.depth >=
|
|
1835
|
+
return this.depth >= Ce ? { exceeded: !0, limit: Ce } : (this.depth++, { exceeded: !1, depth: this.depth });
|
|
1609
1836
|
}
|
|
1610
1837
|
exit() {
|
|
1611
1838
|
this.depth > 0 && this.depth--;
|
|
1612
1839
|
}
|
|
1613
1840
|
}
|
|
1614
|
-
function
|
|
1841
|
+
function on(t) {
|
|
1615
1842
|
return !!t;
|
|
1616
1843
|
}
|
|
1617
|
-
function
|
|
1844
|
+
function an(t) {
|
|
1618
1845
|
return t != null && typeof t[Symbol.iterator] == "function";
|
|
1619
1846
|
}
|
|
1620
|
-
function
|
|
1847
|
+
function Xe(t) {
|
|
1621
1848
|
return {
|
|
1622
1849
|
code: "nest_limit_exceeded",
|
|
1623
1850
|
message: "structure nest limit exceeded",
|
|
@@ -1629,34 +1856,34 @@ function pe(t) {
|
|
|
1629
1856
|
return t.startsWith(`
|
|
1630
1857
|
`) ? t.slice(1) : t;
|
|
1631
1858
|
}
|
|
1632
|
-
async function
|
|
1633
|
-
const n = e.path, r = e.warnings ?? [], i =
|
|
1634
|
-
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);
|
|
1635
1862
|
}
|
|
1636
|
-
async function
|
|
1863
|
+
async function me(t, e, n, r) {
|
|
1637
1864
|
const i = e.preserveHgComments === !0;
|
|
1638
1865
|
let s = "", o = !1;
|
|
1639
1866
|
for (const a of t) {
|
|
1640
|
-
let c = await
|
|
1867
|
+
let c = await ln(a, e, n, r);
|
|
1641
1868
|
o && (c = pe(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
|
|
1642
1869
|
}
|
|
1643
1870
|
return s;
|
|
1644
1871
|
}
|
|
1645
|
-
async function
|
|
1872
|
+
async function ln(t, e, n, r) {
|
|
1646
1873
|
switch (t.kind) {
|
|
1647
1874
|
case "text":
|
|
1648
1875
|
return t.content;
|
|
1649
1876
|
case "if":
|
|
1650
|
-
return
|
|
1877
|
+
return hn(t, e, n, r);
|
|
1651
1878
|
case "each":
|
|
1652
|
-
return
|
|
1879
|
+
return dn(t, e, n, r);
|
|
1653
1880
|
default:
|
|
1654
1881
|
return "";
|
|
1655
1882
|
}
|
|
1656
1883
|
}
|
|
1657
|
-
async function
|
|
1884
|
+
async function hn(t, e, n, r) {
|
|
1658
1885
|
if (n.enter().exceeded)
|
|
1659
|
-
return r.push(
|
|
1886
|
+
return r.push(Xe(e.path)), "";
|
|
1660
1887
|
try {
|
|
1661
1888
|
let s = -1;
|
|
1662
1889
|
for (let c = 0; c < t.branches.length; c++) {
|
|
@@ -1665,8 +1892,8 @@ async function Xt(t, e, n, r) {
|
|
|
1665
1892
|
s = c;
|
|
1666
1893
|
break;
|
|
1667
1894
|
}
|
|
1668
|
-
const l = await
|
|
1669
|
-
if (
|
|
1895
|
+
const l = await y(h.expr, e);
|
|
1896
|
+
if (on(l)) {
|
|
1670
1897
|
s = c;
|
|
1671
1898
|
break;
|
|
1672
1899
|
}
|
|
@@ -1676,7 +1903,7 @@ async function Xt(t, e, n, r) {
|
|
|
1676
1903
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1677
1904
|
const h = t.branches[c];
|
|
1678
1905
|
if (o && (a += h.opener.raw), c === s) {
|
|
1679
|
-
let l = await
|
|
1906
|
+
let l = await me(h.body, e, n, r);
|
|
1680
1907
|
o || (l = pe(l)), a += l;
|
|
1681
1908
|
}
|
|
1682
1909
|
}
|
|
@@ -1685,24 +1912,24 @@ async function Xt(t, e, n, r) {
|
|
|
1685
1912
|
n.exit();
|
|
1686
1913
|
}
|
|
1687
1914
|
}
|
|
1688
|
-
async function
|
|
1915
|
+
async function dn(t, e, n, r) {
|
|
1689
1916
|
if (n.enter().exceeded)
|
|
1690
|
-
return r.push(
|
|
1917
|
+
return r.push(Xe(e.path)), "";
|
|
1691
1918
|
try {
|
|
1692
|
-
const s = await
|
|
1693
|
-
if (!
|
|
1919
|
+
const s = await y(t.expr, e);
|
|
1920
|
+
if (!an(s))
|
|
1694
1921
|
return "";
|
|
1695
1922
|
const o = e.preserveHgComments === !0;
|
|
1696
1923
|
let a = "";
|
|
1697
1924
|
for (const c of s) {
|
|
1698
1925
|
const h = { ...e.context, [t.item]: c };
|
|
1699
1926
|
o && (a += t.opener.raw);
|
|
1700
|
-
let l = await
|
|
1927
|
+
let l = await me(t.body, {
|
|
1701
1928
|
...e,
|
|
1702
1929
|
context: h
|
|
1703
1930
|
}, n, r);
|
|
1704
1931
|
o || (l = pe(l));
|
|
1705
|
-
const u =
|
|
1932
|
+
const u = {
|
|
1706
1933
|
path: e.path,
|
|
1707
1934
|
registry: e.registry,
|
|
1708
1935
|
loader: e.loader,
|
|
@@ -1712,16 +1939,25 @@ async function Jt(t, e, n, r) {
|
|
|
1712
1939
|
parentContext: e.parentContext ?? e.context,
|
|
1713
1940
|
preserveHgComments: e.preserveHgComments,
|
|
1714
1941
|
constrainToRoot: e.constrainToRoot
|
|
1715
|
-
}
|
|
1716
|
-
|
|
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);
|
|
1717
1953
|
}
|
|
1718
1954
|
return a;
|
|
1719
1955
|
} finally {
|
|
1720
1956
|
n.exit();
|
|
1721
1957
|
}
|
|
1722
1958
|
}
|
|
1723
|
-
function
|
|
1724
|
-
return
|
|
1959
|
+
function te(t, e, n, r, i = !1, s = !1) {
|
|
1960
|
+
return D(e) ? e : Z(e, {
|
|
1725
1961
|
rootDir: t,
|
|
1726
1962
|
fromPath: r,
|
|
1727
1963
|
documentPath: n,
|
|
@@ -1729,14 +1965,14 @@ function ee(t, e, n, r, i = !1, s = !1) {
|
|
|
1729
1965
|
hyogenPath: s
|
|
1730
1966
|
});
|
|
1731
1967
|
}
|
|
1732
|
-
function
|
|
1968
|
+
function Ge(t) {
|
|
1733
1969
|
let e = 0;
|
|
1734
1970
|
for (let n = t.length - 1; n >= 0 && t[n] === `
|
|
1735
1971
|
`; n--)
|
|
1736
1972
|
e++;
|
|
1737
1973
|
return e;
|
|
1738
1974
|
}
|
|
1739
|
-
function
|
|
1975
|
+
function Je(t) {
|
|
1740
1976
|
let e = 0;
|
|
1741
1977
|
for (; e < t.length && t[e] === `
|
|
1742
1978
|
`; )
|
|
@@ -1744,25 +1980,25 @@ function Ie(t) {
|
|
|
1744
1980
|
return e;
|
|
1745
1981
|
}
|
|
1746
1982
|
function A(t, e) {
|
|
1747
|
-
const n =
|
|
1983
|
+
const n = Ge(t), r = Je(e), i = Math.max(n, r);
|
|
1748
1984
|
return t.slice(0, t.length - n) + `
|
|
1749
1985
|
`.repeat(i) + e.slice(r);
|
|
1750
1986
|
}
|
|
1751
|
-
function
|
|
1752
|
-
const n =
|
|
1987
|
+
function ge(t, e) {
|
|
1988
|
+
const n = Ge(t), r = Je(e);
|
|
1753
1989
|
return n + r - Math.max(n, r);
|
|
1754
1990
|
}
|
|
1755
|
-
function
|
|
1991
|
+
function $e(t, e, n) {
|
|
1756
1992
|
const r = t.indexOf(e);
|
|
1757
1993
|
if (r < 0)
|
|
1758
1994
|
return t;
|
|
1759
1995
|
const i = t.slice(0, r), s = t.slice(r + e.length);
|
|
1760
1996
|
return A(A(i, n), s);
|
|
1761
1997
|
}
|
|
1762
|
-
async function
|
|
1998
|
+
async function un(t) {
|
|
1763
1999
|
let e = t.source;
|
|
1764
2000
|
for (const n of t.directives) {
|
|
1765
|
-
const r =
|
|
2001
|
+
const r = te(
|
|
1766
2002
|
t.root,
|
|
1767
2003
|
n.path,
|
|
1768
2004
|
t.path,
|
|
@@ -1775,7 +2011,7 @@ async function Qt(t) {
|
|
|
1775
2011
|
if (i.circular) {
|
|
1776
2012
|
t.warnings?.push({
|
|
1777
2013
|
code: "circular_include",
|
|
1778
|
-
message:
|
|
2014
|
+
message: H("circular_include", {
|
|
1779
2015
|
path: r,
|
|
1780
2016
|
from: i.from,
|
|
1781
2017
|
via: "include"
|
|
@@ -1786,13 +2022,13 @@ async function Qt(t) {
|
|
|
1786
2022
|
from: i.from,
|
|
1787
2023
|
via: "include"
|
|
1788
2024
|
}
|
|
1789
|
-
}), e =
|
|
2025
|
+
}), e = $e(e, n.marker, "");
|
|
1790
2026
|
continue;
|
|
1791
2027
|
}
|
|
1792
2028
|
t.visitStack.push(r);
|
|
1793
2029
|
}
|
|
1794
2030
|
try {
|
|
1795
|
-
const i = await t.loader(r), s = await
|
|
2031
|
+
const i = await t.loader(r), s = await Yn(i, {
|
|
1796
2032
|
context: t.context,
|
|
1797
2033
|
loader: t.loader,
|
|
1798
2034
|
root: t.root,
|
|
@@ -1802,16 +2038,16 @@ async function Qt(t) {
|
|
|
1802
2038
|
visitStack: t.visitStack,
|
|
1803
2039
|
warnings: t.warnings,
|
|
1804
2040
|
registry: t.registry
|
|
1805
|
-
}), o = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1806
|
-
${
|
|
1807
|
-
e =
|
|
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}
|
|
2042
|
+
${h}` : h;
|
|
2043
|
+
e = $e(e, n.marker, l);
|
|
1808
2044
|
} finally {
|
|
1809
2045
|
t.visitStack?.pop();
|
|
1810
2046
|
}
|
|
1811
2047
|
}
|
|
1812
2048
|
return e;
|
|
1813
2049
|
}
|
|
1814
|
-
class
|
|
2050
|
+
class Qe {
|
|
1815
2051
|
stack = [];
|
|
1816
2052
|
check(e) {
|
|
1817
2053
|
return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
|
|
@@ -1827,8 +2063,8 @@ class Ue {
|
|
|
1827
2063
|
this.stack.pop();
|
|
1828
2064
|
}
|
|
1829
2065
|
}
|
|
1830
|
-
async function
|
|
1831
|
-
const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await
|
|
2066
|
+
async function fn(t, e, n = {}) {
|
|
2067
|
+
const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await y(t.expr, { context: e, path: r });
|
|
1832
2068
|
switch (t.kind) {
|
|
1833
2069
|
case "const": {
|
|
1834
2070
|
if (i.has(t.name))
|
|
@@ -1868,16 +2104,16 @@ async function en(t, e, n = {}) {
|
|
|
1868
2104
|
}
|
|
1869
2105
|
}
|
|
1870
2106
|
}
|
|
1871
|
-
function
|
|
2107
|
+
function We(t) {
|
|
1872
2108
|
return !t;
|
|
1873
2109
|
}
|
|
1874
|
-
async function
|
|
2110
|
+
async function F(t, e, n = {}) {
|
|
1875
2111
|
const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s, echoChunks: o } = n;
|
|
1876
2112
|
switch (t.kind) {
|
|
1877
2113
|
case "const":
|
|
1878
2114
|
case "let":
|
|
1879
2115
|
case "assign": {
|
|
1880
|
-
await
|
|
2116
|
+
await fn(t, e, { path: r, constBindings: i }), s?.(t.name);
|
|
1881
2117
|
return;
|
|
1882
2118
|
}
|
|
1883
2119
|
case "update": {
|
|
@@ -1918,7 +2154,7 @@ async function N(t, e, n = {}) {
|
|
|
1918
2154
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1919
2155
|
}
|
|
1920
2156
|
});
|
|
1921
|
-
const a = await
|
|
2157
|
+
const a = await y(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
|
|
1922
2158
|
let l;
|
|
1923
2159
|
switch (t.op) {
|
|
1924
2160
|
case "+=":
|
|
@@ -1938,7 +2174,7 @@ async function N(t, e, n = {}) {
|
|
|
1938
2174
|
return;
|
|
1939
2175
|
}
|
|
1940
2176
|
case "echo": {
|
|
1941
|
-
const a = await
|
|
2177
|
+
const a = await y(t.expr, {
|
|
1942
2178
|
context: e,
|
|
1943
2179
|
path: r
|
|
1944
2180
|
}), c = a == null ? "" : String(a);
|
|
@@ -1946,39 +2182,39 @@ async function N(t, e, n = {}) {
|
|
|
1946
2182
|
return;
|
|
1947
2183
|
}
|
|
1948
2184
|
case "for": {
|
|
1949
|
-
for (t.init && await
|
|
1950
|
-
const a = await
|
|
2185
|
+
for (t.init && await F(t.init, e, n); ; ) {
|
|
2186
|
+
const a = await y(t.cond, {
|
|
1951
2187
|
context: e,
|
|
1952
2188
|
path: r
|
|
1953
2189
|
});
|
|
1954
|
-
if (
|
|
2190
|
+
if (We(a))
|
|
1955
2191
|
break;
|
|
1956
2192
|
for (const c of t.body)
|
|
1957
|
-
await
|
|
1958
|
-
t.update && await
|
|
2193
|
+
await F(c, e, n);
|
|
2194
|
+
t.update && await F(t.update, e, n);
|
|
1959
2195
|
}
|
|
1960
2196
|
return;
|
|
1961
2197
|
}
|
|
1962
2198
|
case "do_while": {
|
|
1963
2199
|
do {
|
|
1964
2200
|
for (const c of t.body)
|
|
1965
|
-
await
|
|
1966
|
-
const a = await
|
|
2201
|
+
await F(c, e, n);
|
|
2202
|
+
const a = await y(t.cond, {
|
|
1967
2203
|
context: e,
|
|
1968
2204
|
path: r
|
|
1969
2205
|
});
|
|
1970
|
-
if (
|
|
2206
|
+
if (We(a))
|
|
1971
2207
|
break;
|
|
1972
2208
|
} while (!0);
|
|
1973
2209
|
return;
|
|
1974
2210
|
}
|
|
1975
2211
|
}
|
|
1976
2212
|
}
|
|
1977
|
-
async function
|
|
2213
|
+
async function Te(t, e, n = {}) {
|
|
1978
2214
|
for (const r of t)
|
|
1979
|
-
await
|
|
2215
|
+
await F(r, e, n);
|
|
1980
2216
|
}
|
|
1981
|
-
const
|
|
2217
|
+
const pn = /* @__PURE__ */ new Set([
|
|
1982
2218
|
"if",
|
|
1983
2219
|
"else",
|
|
1984
2220
|
"endif",
|
|
@@ -1997,10 +2233,10 @@ const tn = /* @__PURE__ */ new Set([
|
|
|
1997
2233
|
"as",
|
|
1998
2234
|
"echo"
|
|
1999
2235
|
]);
|
|
2000
|
-
function
|
|
2001
|
-
return
|
|
2236
|
+
function et(t) {
|
|
2237
|
+
return pn.has(t);
|
|
2002
2238
|
}
|
|
2003
|
-
function
|
|
2239
|
+
function we(t) {
|
|
2004
2240
|
let e = "", n = 0, r = null;
|
|
2005
2241
|
for (; n < t.length; ) {
|
|
2006
2242
|
const i = t[n];
|
|
@@ -2033,32 +2269,32 @@ function ge(t) {
|
|
|
2033
2269
|
}
|
|
2034
2270
|
return e;
|
|
2035
2271
|
}
|
|
2036
|
-
function
|
|
2272
|
+
function k(t, e) {
|
|
2037
2273
|
throw d({
|
|
2038
2274
|
code: "parse_error",
|
|
2039
2275
|
path: t,
|
|
2040
2276
|
details: { message: e }
|
|
2041
2277
|
});
|
|
2042
2278
|
}
|
|
2043
|
-
function
|
|
2044
|
-
const n =
|
|
2279
|
+
function Ae(t, e) {
|
|
2280
|
+
const n = we(t).trim();
|
|
2045
2281
|
if (n.length === 0)
|
|
2046
|
-
throw
|
|
2047
|
-
const r = new
|
|
2282
|
+
throw k(e, "empty statement block");
|
|
2283
|
+
const r = new xe(n, e), i = r.parseStatementList();
|
|
2048
2284
|
if (r.skipWhitespace(), r.hasMore())
|
|
2049
|
-
throw
|
|
2285
|
+
throw k(
|
|
2050
2286
|
e,
|
|
2051
2287
|
`unexpected token at position ${r.position}`
|
|
2052
2288
|
);
|
|
2053
2289
|
if (i.length === 0)
|
|
2054
|
-
throw
|
|
2290
|
+
throw k(e, "empty statement block");
|
|
2055
2291
|
return i;
|
|
2056
2292
|
}
|
|
2057
|
-
function
|
|
2058
|
-
const e =
|
|
2293
|
+
function V(t) {
|
|
2294
|
+
const e = we(t).trim();
|
|
2059
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);
|
|
2060
2296
|
}
|
|
2061
|
-
class
|
|
2297
|
+
class xe {
|
|
2062
2298
|
constructor(e, n) {
|
|
2063
2299
|
this.input = e, this.path = n;
|
|
2064
2300
|
}
|
|
@@ -2087,7 +2323,7 @@ class we {
|
|
|
2087
2323
|
if (this.matchWord("do"))
|
|
2088
2324
|
return this.parseDoWhile();
|
|
2089
2325
|
if (this.matchWord("while"))
|
|
2090
|
-
throw
|
|
2326
|
+
throw k(
|
|
2091
2327
|
this.path,
|
|
2092
2328
|
"bare while loops are not allowed (use do…while)"
|
|
2093
2329
|
);
|
|
@@ -2104,7 +2340,7 @@ class we {
|
|
|
2104
2340
|
return this.parseBindingDeclaration("let");
|
|
2105
2341
|
const n = this.readIdentifier();
|
|
2106
2342
|
if (!n)
|
|
2107
|
-
throw
|
|
2343
|
+
throw k(this.path, "expected statement");
|
|
2108
2344
|
if (this.assertAssignableName(n), this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
2109
2345
|
const i = this.input.slice(this.index - 2, this.index);
|
|
2110
2346
|
return { kind: "update", name: n, op: i, position: "postfix" };
|
|
@@ -2121,7 +2357,7 @@ class we {
|
|
|
2121
2357
|
}
|
|
2122
2358
|
if (this.match("=")) {
|
|
2123
2359
|
if (this.peek() === "=")
|
|
2124
|
-
throw
|
|
2360
|
+
throw k(this.path, "unexpected '==' in assignment");
|
|
2125
2361
|
const i = this.readExpressionSourceUntilTerminator();
|
|
2126
2362
|
return {
|
|
2127
2363
|
kind: "assign",
|
|
@@ -2129,7 +2365,7 @@ class we {
|
|
|
2129
2365
|
expr: S(i, this.path)
|
|
2130
2366
|
};
|
|
2131
2367
|
}
|
|
2132
|
-
throw
|
|
2368
|
+
throw k(this.path, `invalid statement starting with: ${n}`);
|
|
2133
2369
|
}
|
|
2134
2370
|
parseEcho() {
|
|
2135
2371
|
this.skipWhitespace();
|
|
@@ -2143,7 +2379,7 @@ class we {
|
|
|
2143
2379
|
if (this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
2144
2380
|
const e = this.input.slice(this.index - 2, this.index), n = this.readIdentifier();
|
|
2145
2381
|
if (!n)
|
|
2146
|
-
throw
|
|
2382
|
+
throw k(this.path, `expected identifier after ${e}`);
|
|
2147
2383
|
return this.assertAssignableName(n), { kind: "update", name: n, op: e, position: "prefix" };
|
|
2148
2384
|
}
|
|
2149
2385
|
return null;
|
|
@@ -2151,9 +2387,9 @@ class we {
|
|
|
2151
2387
|
parseBindingDeclaration(e) {
|
|
2152
2388
|
const n = this.readIdentifier();
|
|
2153
2389
|
if (!n)
|
|
2154
|
-
throw
|
|
2390
|
+
throw k(this.path, `expected identifier after ${e}`);
|
|
2155
2391
|
if (this.assertAssignableName(n), this.skipWhitespace(), !this.match("="))
|
|
2156
|
-
throw
|
|
2392
|
+
throw k(this.path, `expected '=' in ${e} declaration`);
|
|
2157
2393
|
const r = this.readExpressionSourceUntilTerminator();
|
|
2158
2394
|
return {
|
|
2159
2395
|
kind: e,
|
|
@@ -2163,57 +2399,57 @@ class we {
|
|
|
2163
2399
|
}
|
|
2164
2400
|
parseFor() {
|
|
2165
2401
|
if (this.skipWhitespace(), !this.match("("))
|
|
2166
|
-
throw
|
|
2167
|
-
const e = this.readBalanced(")"), n =
|
|
2402
|
+
throw k(this.path, "expected '(' after for");
|
|
2403
|
+
const e = this.readBalanced(")"), n = mn(e);
|
|
2168
2404
|
if (n.length !== 3)
|
|
2169
|
-
throw
|
|
2405
|
+
throw k(
|
|
2170
2406
|
this.path,
|
|
2171
2407
|
"for…of / for…in are not allowed; use for (init; cond; update)"
|
|
2172
2408
|
);
|
|
2173
2409
|
const [r, i, s] = n;
|
|
2174
2410
|
if (i.trim().length === 0)
|
|
2175
|
-
throw
|
|
2411
|
+
throw k(this.path, "for loop condition cannot be empty");
|
|
2176
2412
|
if (/^\s*[A-Za-z_$][A-Za-z0-9_$]*\s+(of|in)\s+/.test(r))
|
|
2177
|
-
throw
|
|
2413
|
+
throw k(
|
|
2178
2414
|
this.path,
|
|
2179
2415
|
"for…of / for…in are not allowed; use for (init; cond; update)"
|
|
2180
2416
|
);
|
|
2181
2417
|
const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a = S(i.trim(), this.path), c = s.trim().length === 0 ? null : this.parseClauseStatement(s.trim());
|
|
2182
2418
|
if (this.skipWhitespace(), !this.match("{"))
|
|
2183
|
-
throw
|
|
2419
|
+
throw k(this.path, "expected '{' after for (...)");
|
|
2184
2420
|
const h = this.parseStatementList();
|
|
2185
2421
|
if (this.skipWhitespace(), !this.match("}"))
|
|
2186
|
-
throw
|
|
2422
|
+
throw k(this.path, "expected '}' to close for body");
|
|
2187
2423
|
return { kind: "for", init: o, cond: a, update: c, body: h };
|
|
2188
2424
|
}
|
|
2189
2425
|
parseDoWhile() {
|
|
2190
2426
|
if (this.skipWhitespace(), !this.match("{"))
|
|
2191
|
-
throw
|
|
2427
|
+
throw k(this.path, "expected '{' after do");
|
|
2192
2428
|
const e = this.parseStatementList();
|
|
2193
2429
|
if (this.skipWhitespace(), !this.match("}"))
|
|
2194
|
-
throw
|
|
2430
|
+
throw k(this.path, "expected '}' to close do body");
|
|
2195
2431
|
if (this.skipWhitespace(), !this.matchWord("while"))
|
|
2196
|
-
throw
|
|
2432
|
+
throw k(this.path, "expected 'while' after do body");
|
|
2197
2433
|
if (this.skipWhitespace(), !this.match("("))
|
|
2198
|
-
throw
|
|
2434
|
+
throw k(this.path, "expected '(' after while");
|
|
2199
2435
|
const n = this.readBalanced(")");
|
|
2200
2436
|
if (n.trim().length === 0)
|
|
2201
|
-
throw
|
|
2437
|
+
throw k(this.path, "do…while condition cannot be empty");
|
|
2202
2438
|
const r = S(n.trim(), this.path);
|
|
2203
2439
|
return { kind: "do_while", body: e, cond: r };
|
|
2204
2440
|
}
|
|
2205
2441
|
parseClauseStatement(e) {
|
|
2206
|
-
const n = new
|
|
2442
|
+
const n = new xe(e, this.path), r = n.parseSimpleStatement();
|
|
2207
2443
|
if (n.skipWhitespace(), n.hasMore())
|
|
2208
|
-
throw
|
|
2444
|
+
throw k(
|
|
2209
2445
|
this.path,
|
|
2210
2446
|
`unexpected token in for clause at position ${n.position}`
|
|
2211
2447
|
);
|
|
2212
2448
|
return r;
|
|
2213
2449
|
}
|
|
2214
2450
|
assertAssignableName(e) {
|
|
2215
|
-
if (
|
|
2216
|
-
throw
|
|
2451
|
+
if (et(e))
|
|
2452
|
+
throw k(
|
|
2217
2453
|
this.path,
|
|
2218
2454
|
`reserved word cannot be used as identifier: ${e}`
|
|
2219
2455
|
);
|
|
@@ -2248,7 +2484,7 @@ class we {
|
|
|
2248
2484
|
}
|
|
2249
2485
|
const o = this.input.slice(e, this.index).trim();
|
|
2250
2486
|
if (o.length === 0)
|
|
2251
|
-
throw
|
|
2487
|
+
throw k(this.path, "expected expression");
|
|
2252
2488
|
return o;
|
|
2253
2489
|
}
|
|
2254
2490
|
readBalanced(e) {
|
|
@@ -2284,7 +2520,7 @@ class we {
|
|
|
2284
2520
|
}
|
|
2285
2521
|
this.index++;
|
|
2286
2522
|
}
|
|
2287
|
-
throw
|
|
2523
|
+
throw k(this.path, `expected '${e}'`);
|
|
2288
2524
|
}
|
|
2289
2525
|
readCompoundOp() {
|
|
2290
2526
|
this.skipWhitespace();
|
|
@@ -2319,7 +2555,7 @@ class we {
|
|
|
2319
2555
|
return this.input.slice(e, this.index);
|
|
2320
2556
|
}
|
|
2321
2557
|
}
|
|
2322
|
-
function
|
|
2558
|
+
function mn(t) {
|
|
2323
2559
|
const e = [];
|
|
2324
2560
|
let n = "", r = 0, i = null;
|
|
2325
2561
|
for (let s = 0; s < t.length; s++) {
|
|
@@ -2352,7 +2588,7 @@ function nn(t) {
|
|
|
2352
2588
|
}
|
|
2353
2589
|
return e.push(n), e;
|
|
2354
2590
|
}
|
|
2355
|
-
function
|
|
2591
|
+
function B(t, e) {
|
|
2356
2592
|
const n = t.trim();
|
|
2357
2593
|
if (!/^extend\b/i.test(n)) return null;
|
|
2358
2594
|
if (!/^extend\s+/i.test(n))
|
|
@@ -2377,10 +2613,10 @@ function j(t, e) {
|
|
|
2377
2613
|
});
|
|
2378
2614
|
return { path: i };
|
|
2379
2615
|
}
|
|
2380
|
-
function
|
|
2381
|
-
const n =
|
|
2616
|
+
function gn(t, e) {
|
|
2617
|
+
const n = $(t);
|
|
2382
2618
|
if (n.length === 0) return null;
|
|
2383
|
-
const r = n[0], i =
|
|
2619
|
+
const r = n[0], i = B(r, e);
|
|
2384
2620
|
if (!i) return null;
|
|
2385
2621
|
for (const s of n.slice(1))
|
|
2386
2622
|
if (/^extend\s+/i.test(s))
|
|
@@ -2395,11 +2631,11 @@ function rn(t, e) {
|
|
|
2395
2631
|
`)
|
|
2396
2632
|
};
|
|
2397
2633
|
}
|
|
2398
|
-
function
|
|
2634
|
+
function P(t) {
|
|
2399
2635
|
return /^toc(\(.*\))?$/.test(t.trim());
|
|
2400
2636
|
}
|
|
2401
|
-
function
|
|
2402
|
-
const n =
|
|
2637
|
+
function wn(t, e) {
|
|
2638
|
+
const n = $(t);
|
|
2403
2639
|
if (n.length !== 1)
|
|
2404
2640
|
throw d({
|
|
2405
2641
|
code: "parse_error",
|
|
@@ -2429,17 +2665,17 @@ function sn(t, e) {
|
|
|
2429
2665
|
});
|
|
2430
2666
|
return { maxLevel: Number(s) };
|
|
2431
2667
|
}
|
|
2432
|
-
async function
|
|
2668
|
+
async function xn(t, e = {}) {
|
|
2433
2669
|
const n = e.path, r = e.context ?? {};
|
|
2434
|
-
if (
|
|
2670
|
+
if (de(t))
|
|
2435
2671
|
throw d({
|
|
2436
2672
|
code: "parse_error",
|
|
2437
2673
|
path: n,
|
|
2438
2674
|
details: {
|
|
2439
|
-
message:
|
|
2675
|
+
message: ue(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2440
2676
|
}
|
|
2441
2677
|
});
|
|
2442
|
-
const i =
|
|
2678
|
+
const i = W(t);
|
|
2443
2679
|
if (i.length === 0)
|
|
2444
2680
|
return { source: t, context: r, declarationUpdates: {} };
|
|
2445
2681
|
const s = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
|
|
@@ -2447,31 +2683,31 @@ async function on(t, e = {}) {
|
|
|
2447
2683
|
};
|
|
2448
2684
|
let c = t, h = 0;
|
|
2449
2685
|
for (const l of i) {
|
|
2450
|
-
const u =
|
|
2451
|
-
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]))
|
|
2452
2688
|
continue;
|
|
2453
|
-
const
|
|
2454
|
-
if (
|
|
2455
|
-
if (
|
|
2456
|
-
const
|
|
2457
|
-
|
|
2689
|
+
const p = gn(l.inner, n);
|
|
2690
|
+
if (p) {
|
|
2691
|
+
if (p.declarationsSource.trim().length > 0) {
|
|
2692
|
+
const N = Ae(
|
|
2693
|
+
p.declarationsSource,
|
|
2458
2694
|
n
|
|
2459
2695
|
);
|
|
2460
|
-
await
|
|
2696
|
+
await Te(N, r, {
|
|
2461
2697
|
path: n,
|
|
2462
2698
|
constBindings: s,
|
|
2463
2699
|
onUpdate: a
|
|
2464
2700
|
});
|
|
2465
2701
|
}
|
|
2466
|
-
const
|
|
2467
|
-
extend ${
|
|
2702
|
+
const E = l.start - h, L = l.end - h, U = `<!--@hg
|
|
2703
|
+
extend ${p.path}
|
|
2468
2704
|
@endhg-->`;
|
|
2469
|
-
c = c.slice(0,
|
|
2705
|
+
c = c.slice(0, E) + U + c.slice(L), h += l.raw.length - U.length;
|
|
2470
2706
|
continue;
|
|
2471
2707
|
}
|
|
2472
|
-
const
|
|
2708
|
+
const x = u.join(`
|
|
2473
2709
|
`);
|
|
2474
|
-
if (!
|
|
2710
|
+
if (!V(x)) {
|
|
2475
2711
|
if (u.length === 1)
|
|
2476
2712
|
continue;
|
|
2477
2713
|
throw d({
|
|
@@ -2480,25 +2716,25 @@ extend ${w.path}
|
|
|
2480
2716
|
details: { message: `unsupported hyogen directive: ${u[0]}` }
|
|
2481
2717
|
});
|
|
2482
2718
|
}
|
|
2483
|
-
const
|
|
2484
|
-
await
|
|
2719
|
+
const m = Ae(x, n), w = [];
|
|
2720
|
+
await Te(m, r, {
|
|
2485
2721
|
path: n,
|
|
2486
2722
|
constBindings: s,
|
|
2487
2723
|
onUpdate: a,
|
|
2488
|
-
echoChunks:
|
|
2724
|
+
echoChunks: w
|
|
2489
2725
|
});
|
|
2490
|
-
const
|
|
2491
|
-
if (
|
|
2492
|
-
const
|
|
2493
|
-
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;
|
|
2494
2730
|
} else
|
|
2495
|
-
c = A(T, b), h += l.raw.length +
|
|
2731
|
+
c = A(T, b), h += l.raw.length + ge(T, b);
|
|
2496
2732
|
}
|
|
2497
2733
|
return { source: c, context: r, declarationUpdates: o };
|
|
2498
2734
|
}
|
|
2499
|
-
const
|
|
2500
|
-
function
|
|
2501
|
-
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();
|
|
2502
2738
|
if (n.length === 0)
|
|
2503
2739
|
throw d({
|
|
2504
2740
|
code: "parse_error",
|
|
@@ -2521,7 +2757,7 @@ function Ze(t, e) {
|
|
|
2521
2757
|
path: e,
|
|
2522
2758
|
details: { message: "include and component cannot coexist in one block" }
|
|
2523
2759
|
});
|
|
2524
|
-
const s =
|
|
2760
|
+
const s = kn.exec(i);
|
|
2525
2761
|
if (!s)
|
|
2526
2762
|
throw d({
|
|
2527
2763
|
code: "parse_error",
|
|
@@ -2541,8 +2777,8 @@ function Ze(t, e) {
|
|
|
2541
2777
|
alias: s[2]
|
|
2542
2778
|
};
|
|
2543
2779
|
}
|
|
2544
|
-
function
|
|
2545
|
-
const n =
|
|
2780
|
+
function nt(t, e) {
|
|
2781
|
+
const n = le(t).trim();
|
|
2546
2782
|
if (n.length === 0)
|
|
2547
2783
|
throw d({
|
|
2548
2784
|
code: "parse_error",
|
|
@@ -2565,19 +2801,19 @@ function Ve(t, e) {
|
|
|
2565
2801
|
details: { message: `unsupported hyogen directive: ${i}` }
|
|
2566
2802
|
});
|
|
2567
2803
|
}
|
|
2568
|
-
function
|
|
2569
|
-
const e =
|
|
2804
|
+
function ne(t) {
|
|
2805
|
+
const e = we(t).trim();
|
|
2570
2806
|
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
|
|
2571
2807
|
}
|
|
2572
|
-
const
|
|
2573
|
-
function
|
|
2574
|
-
return `${
|
|
2808
|
+
const yn = "\0HYOGEN_INCLUDE_";
|
|
2809
|
+
function bn(t) {
|
|
2810
|
+
return `${yn}${t}\0`;
|
|
2575
2811
|
}
|
|
2576
|
-
function
|
|
2577
|
-
const n =
|
|
2578
|
-
if (n.length === 1 &&
|
|
2812
|
+
function vn(t, e) {
|
|
2813
|
+
const n = $(t);
|
|
2814
|
+
if (n.length === 1 && fe(n[0]))
|
|
2579
2815
|
return { kind: "control" };
|
|
2580
|
-
if (n.length === 1 &&
|
|
2816
|
+
if (n.length === 1 && P(n[0]) || n.length === 1 && (ne(n[0]) || V(n[0])))
|
|
2581
2817
|
return null;
|
|
2582
2818
|
if (n.length !== 1)
|
|
2583
2819
|
throw d({
|
|
@@ -2593,9 +2829,9 @@ function hn(t, e) {
|
|
|
2593
2829
|
details: { message: "include and component cannot coexist in one block" }
|
|
2594
2830
|
});
|
|
2595
2831
|
if (/^include\s+/i.test(r))
|
|
2596
|
-
return
|
|
2832
|
+
return nt(t, e);
|
|
2597
2833
|
if (/^component\s+/i.test(r))
|
|
2598
|
-
return
|
|
2834
|
+
return tt(t, e);
|
|
2599
2835
|
if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
|
|
2600
2836
|
return null;
|
|
2601
2837
|
throw d({
|
|
@@ -2604,23 +2840,23 @@ function hn(t, e) {
|
|
|
2604
2840
|
details: { message: `unsupported hyogen directive: ${r}` }
|
|
2605
2841
|
});
|
|
2606
2842
|
}
|
|
2607
|
-
function
|
|
2843
|
+
function _n(t, e = {}) {
|
|
2608
2844
|
const n = e.path;
|
|
2609
|
-
if (
|
|
2845
|
+
if (de(t))
|
|
2610
2846
|
throw d({
|
|
2611
2847
|
code: "parse_error",
|
|
2612
2848
|
path: n,
|
|
2613
2849
|
details: {
|
|
2614
|
-
message:
|
|
2850
|
+
message: ue(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2615
2851
|
}
|
|
2616
2852
|
});
|
|
2617
|
-
const r =
|
|
2853
|
+
const r = W(t);
|
|
2618
2854
|
if (r.length === 0)
|
|
2619
2855
|
return { source: t, directives: [] };
|
|
2620
2856
|
const i = [];
|
|
2621
2857
|
let s = t, o = 0, a = 0;
|
|
2622
2858
|
for (const c of r) {
|
|
2623
|
-
const h =
|
|
2859
|
+
const h = vn(c.inner, n);
|
|
2624
2860
|
if (!h || h.kind === "control")
|
|
2625
2861
|
continue;
|
|
2626
2862
|
const l = c.start - o, u = c.end - o;
|
|
@@ -2634,39 +2870,39 @@ function dn(t, e = {}) {
|
|
|
2634
2870
|
Object.keys(e.context ?? {}),
|
|
2635
2871
|
n
|
|
2636
2872
|
);
|
|
2637
|
-
const
|
|
2638
|
-
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);
|
|
2639
2875
|
continue;
|
|
2640
2876
|
}
|
|
2641
|
-
const
|
|
2642
|
-
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;
|
|
2643
2879
|
}
|
|
2644
2880
|
return { source: s, directives: i };
|
|
2645
2881
|
}
|
|
2646
|
-
function
|
|
2882
|
+
function Sn(t, e) {
|
|
2647
2883
|
return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
|
|
2648
2884
|
` : `${e.rawFrontMatter}
|
|
2649
2885
|
${t}`;
|
|
2650
2886
|
}
|
|
2651
|
-
function
|
|
2887
|
+
function En(t, e = !1) {
|
|
2652
2888
|
if (e)
|
|
2653
2889
|
return t;
|
|
2654
|
-
const n =
|
|
2890
|
+
const n = W(t);
|
|
2655
2891
|
if (n.length === 0)
|
|
2656
2892
|
return t;
|
|
2657
2893
|
let r = t, i = 0;
|
|
2658
2894
|
for (const s of n) {
|
|
2659
2895
|
const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
|
|
2660
|
-
r = A(c, h), i += s.raw.length +
|
|
2896
|
+
r = A(c, h), i += s.raw.length + ge(c, h);
|
|
2661
2897
|
}
|
|
2662
2898
|
return r;
|
|
2663
2899
|
}
|
|
2664
|
-
const
|
|
2665
|
-
function
|
|
2900
|
+
const Cn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
2901
|
+
function $n(t, e) {
|
|
2666
2902
|
const n = t.trim();
|
|
2667
2903
|
if (n === "endblock")
|
|
2668
2904
|
return { kind: "endblock" };
|
|
2669
|
-
const r =
|
|
2905
|
+
const r = Cn.exec(n);
|
|
2670
2906
|
if (!r)
|
|
2671
2907
|
throw d({
|
|
2672
2908
|
code: "parse_error",
|
|
@@ -2674,7 +2910,7 @@ function mn(t, e) {
|
|
|
2674
2910
|
details: { message: "invalid block directive" }
|
|
2675
2911
|
});
|
|
2676
2912
|
const i = r[1];
|
|
2677
|
-
if (
|
|
2913
|
+
if (et(i))
|
|
2678
2914
|
throw d({
|
|
2679
2915
|
code: "parse_error",
|
|
2680
2916
|
path: e,
|
|
@@ -2682,12 +2918,12 @@ function mn(t, e) {
|
|
|
2682
2918
|
});
|
|
2683
2919
|
return { kind: "block", name: i };
|
|
2684
2920
|
}
|
|
2685
|
-
function
|
|
2686
|
-
const { path: n, mode: r, hasExtend: i = !1 } = e, s =
|
|
2921
|
+
function Le(t, e) {
|
|
2922
|
+
const { path: n, mode: r, hasExtend: i = !1 } = e, s = W(t);
|
|
2687
2923
|
if (s.length === 0) return [];
|
|
2688
2924
|
const o = [], a = [], c = /* @__PURE__ */ new Set();
|
|
2689
2925
|
for (const h of s) {
|
|
2690
|
-
const l =
|
|
2926
|
+
const l = $(h.inner);
|
|
2691
2927
|
if (l.length !== 1) continue;
|
|
2692
2928
|
const u = l[0];
|
|
2693
2929
|
if (!(u === "endblock" || u.startsWith("block "))) continue;
|
|
@@ -2697,20 +2933,20 @@ function Te(t, e) {
|
|
|
2697
2933
|
path: n,
|
|
2698
2934
|
details: { message: "orphan block without extend" }
|
|
2699
2935
|
});
|
|
2700
|
-
const
|
|
2701
|
-
if (
|
|
2702
|
-
const
|
|
2703
|
-
if (!
|
|
2936
|
+
const x = $n(u, n);
|
|
2937
|
+
if (x.kind === "endblock") {
|
|
2938
|
+
const m = a.pop();
|
|
2939
|
+
if (!m)
|
|
2704
2940
|
throw d({
|
|
2705
2941
|
code: "parse_error",
|
|
2706
2942
|
path: n,
|
|
2707
2943
|
details: { message: "endblock without matching block opener" }
|
|
2708
2944
|
});
|
|
2709
|
-
const
|
|
2945
|
+
const w = t.slice(m.openerEnd, h.start);
|
|
2710
2946
|
o.push({
|
|
2711
|
-
name:
|
|
2712
|
-
body:
|
|
2713
|
-
start:
|
|
2947
|
+
name: m.name,
|
|
2948
|
+
body: w,
|
|
2949
|
+
start: m.start,
|
|
2714
2950
|
end: h.end
|
|
2715
2951
|
});
|
|
2716
2952
|
continue;
|
|
@@ -2721,14 +2957,14 @@ function Te(t, e) {
|
|
|
2721
2957
|
path: n,
|
|
2722
2958
|
details: { message: "nested block structures are not supported" }
|
|
2723
2959
|
});
|
|
2724
|
-
if (c.has(
|
|
2960
|
+
if (c.has(x.name))
|
|
2725
2961
|
throw d({
|
|
2726
2962
|
code: "parse_error",
|
|
2727
2963
|
path: n,
|
|
2728
|
-
details: { message: `duplicate block: ${
|
|
2964
|
+
details: { message: `duplicate block: ${x.name}` }
|
|
2729
2965
|
});
|
|
2730
|
-
c.add(
|
|
2731
|
-
name:
|
|
2966
|
+
c.add(x.name), a.push({
|
|
2967
|
+
name: x.name,
|
|
2732
2968
|
openerEnd: h.end,
|
|
2733
2969
|
start: h.start
|
|
2734
2970
|
});
|
|
@@ -2741,37 +2977,37 @@ function Te(t, e) {
|
|
|
2741
2977
|
});
|
|
2742
2978
|
return o;
|
|
2743
2979
|
}
|
|
2744
|
-
function
|
|
2745
|
-
const e =
|
|
2980
|
+
function Oe(t) {
|
|
2981
|
+
const e = W(t), n = [];
|
|
2746
2982
|
for (const r of e) {
|
|
2747
|
-
const i =
|
|
2983
|
+
const i = $(r.inner);
|
|
2748
2984
|
if (i.length === 0) continue;
|
|
2749
|
-
const s =
|
|
2985
|
+
const s = B(i[0]);
|
|
2750
2986
|
s && n.push({ path: s.path, start: r.start });
|
|
2751
2987
|
}
|
|
2752
2988
|
return n;
|
|
2753
2989
|
}
|
|
2754
|
-
function
|
|
2755
|
-
const e =
|
|
2990
|
+
function Wn(t) {
|
|
2991
|
+
const e = W(t);
|
|
2756
2992
|
for (const n of e) {
|
|
2757
|
-
const r =
|
|
2993
|
+
const r = $(n.inner);
|
|
2758
2994
|
if (r.length !== 1) continue;
|
|
2759
2995
|
const i = r[0];
|
|
2760
2996
|
if (i === "endblock" || i.startsWith("block ")) return !0;
|
|
2761
2997
|
}
|
|
2762
2998
|
return !1;
|
|
2763
2999
|
}
|
|
2764
|
-
function
|
|
3000
|
+
function ee(t) {
|
|
2765
3001
|
return t.map((e) => e.body).join("");
|
|
2766
3002
|
}
|
|
2767
|
-
function
|
|
3003
|
+
function Tn(t, e, n) {
|
|
2768
3004
|
const r = [...e].sort((o, a) => o.start - a.start), i = [];
|
|
2769
3005
|
let s = 0;
|
|
2770
3006
|
for (const o of r)
|
|
2771
3007
|
i.push(t.slice(s, o.start)), i.push(n.get(o.name) ?? o.body), s = o.end;
|
|
2772
3008
|
return i.push(t.slice(s)), i.reduce((o, a) => A(o, a));
|
|
2773
3009
|
}
|
|
2774
|
-
function
|
|
3010
|
+
function An(t) {
|
|
2775
3011
|
if (t instanceof Error && "code" in t && "details" in t) {
|
|
2776
3012
|
const e = t;
|
|
2777
3013
|
if (e.code === "file_not_found" && e.details && e.details.via === "include")
|
|
@@ -2779,7 +3015,7 @@ function xn(t) {
|
|
|
2779
3015
|
}
|
|
2780
3016
|
return { errorToThrow: t, adjusted: !1 };
|
|
2781
3017
|
}
|
|
2782
|
-
async function
|
|
3018
|
+
async function Ln(t, e) {
|
|
2783
3019
|
const {
|
|
2784
3020
|
path: n,
|
|
2785
3021
|
context: r,
|
|
@@ -2790,9 +3026,9 @@ async function kn(t, e) {
|
|
|
2790
3026
|
visitStack: c,
|
|
2791
3027
|
warnings: h,
|
|
2792
3028
|
inComponent: l = !1
|
|
2793
|
-
} = e, u =
|
|
3029
|
+
} = e, u = Oe(t);
|
|
2794
3030
|
if (u.length === 0) {
|
|
2795
|
-
if (
|
|
3031
|
+
if (Wn(t))
|
|
2796
3032
|
throw d({
|
|
2797
3033
|
code: "parse_error",
|
|
2798
3034
|
path: n,
|
|
@@ -2800,13 +3036,13 @@ async function kn(t, e) {
|
|
|
2800
3036
|
});
|
|
2801
3037
|
return { source: t, context: v(r, i) };
|
|
2802
3038
|
}
|
|
2803
|
-
const
|
|
2804
|
-
if (!
|
|
3039
|
+
const x = W(t)[0];
|
|
3040
|
+
if (!x)
|
|
2805
3041
|
return { source: t, context: v(r, i) };
|
|
2806
3042
|
if (!s)
|
|
2807
3043
|
throw new Error("loader is required when processing extend directives");
|
|
2808
|
-
const
|
|
2809
|
-
if (!(
|
|
3044
|
+
const m = $(x.inner);
|
|
3045
|
+
if (!(m.length > 0 ? B(m[0]) : null))
|
|
2810
3046
|
throw d({
|
|
2811
3047
|
code: "parse_error",
|
|
2812
3048
|
path: n,
|
|
@@ -2818,7 +3054,7 @@ async function kn(t, e) {
|
|
|
2818
3054
|
path: n,
|
|
2819
3055
|
details: { message: "multiple extend directives are not supported" }
|
|
2820
3056
|
});
|
|
2821
|
-
const
|
|
3057
|
+
const _ = Le(t, {
|
|
2822
3058
|
path: n,
|
|
2823
3059
|
mode: "child",
|
|
2824
3060
|
hasExtend: !0
|
|
@@ -2826,16 +3062,16 @@ async function kn(t, e) {
|
|
|
2826
3062
|
if (l)
|
|
2827
3063
|
return h?.push({
|
|
2828
3064
|
code: "extend_in_component",
|
|
2829
|
-
message:
|
|
3065
|
+
message: H("extend_in_component", { path: n }),
|
|
2830
3066
|
path: n,
|
|
2831
3067
|
details: { path: n }
|
|
2832
3068
|
}), {
|
|
2833
|
-
source:
|
|
3069
|
+
source: ee(_),
|
|
2834
3070
|
context: v(r, i)
|
|
2835
3071
|
};
|
|
2836
|
-
const
|
|
3072
|
+
const K = u[0].path, T = n, b = te(
|
|
2837
3073
|
o,
|
|
2838
|
-
|
|
3074
|
+
K,
|
|
2839
3075
|
n,
|
|
2840
3076
|
n,
|
|
2841
3077
|
a,
|
|
@@ -2843,51 +3079,51 @@ async function kn(t, e) {
|
|
|
2843
3079
|
);
|
|
2844
3080
|
T && c.push(T);
|
|
2845
3081
|
try {
|
|
2846
|
-
const
|
|
2847
|
-
if (
|
|
3082
|
+
const E = T ? c.check(b) : { circular: !1 };
|
|
3083
|
+
if (E.circular)
|
|
2848
3084
|
return h?.push({
|
|
2849
3085
|
code: "circular_include",
|
|
2850
|
-
message:
|
|
3086
|
+
message: H("circular_include", {
|
|
2851
3087
|
path: b,
|
|
2852
|
-
from:
|
|
3088
|
+
from: E.from,
|
|
2853
3089
|
via: "extend"
|
|
2854
3090
|
}),
|
|
2855
3091
|
path: n,
|
|
2856
|
-
details: { path: b, from:
|
|
3092
|
+
details: { path: b, from: E.from, via: "extend" }
|
|
2857
3093
|
}), {
|
|
2858
|
-
source:
|
|
3094
|
+
source: ee(_),
|
|
2859
3095
|
context: v(r, i)
|
|
2860
3096
|
};
|
|
2861
3097
|
c.push(b);
|
|
2862
3098
|
try {
|
|
2863
|
-
const
|
|
2864
|
-
if (
|
|
3099
|
+
const L = await s(b);
|
|
3100
|
+
if (L === void 0)
|
|
2865
3101
|
throw new Error("loader returned undefined");
|
|
2866
|
-
const { context:
|
|
2867
|
-
|
|
3102
|
+
const { context: U, body: N } = q(
|
|
3103
|
+
L,
|
|
2868
3104
|
b
|
|
2869
|
-
),
|
|
2870
|
-
if (
|
|
2871
|
-
const
|
|
3105
|
+
), ye = Oe(N);
|
|
3106
|
+
if (ye.length > 0) {
|
|
3107
|
+
const z = ye[0].path, Y = te(
|
|
2872
3108
|
o,
|
|
2873
|
-
|
|
3109
|
+
z,
|
|
2874
3110
|
b,
|
|
2875
3111
|
b,
|
|
2876
3112
|
a,
|
|
2877
3113
|
!0
|
|
2878
|
-
),
|
|
2879
|
-
if (
|
|
3114
|
+
), X = c.check(Y);
|
|
3115
|
+
if (X.circular)
|
|
2880
3116
|
return h?.push({
|
|
2881
3117
|
code: "circular_include",
|
|
2882
|
-
message:
|
|
2883
|
-
path:
|
|
2884
|
-
from:
|
|
3118
|
+
message: H("circular_include", {
|
|
3119
|
+
path: Y,
|
|
3120
|
+
from: X.from,
|
|
2885
3121
|
via: "extend"
|
|
2886
3122
|
}),
|
|
2887
3123
|
path: n,
|
|
2888
|
-
details: { path:
|
|
3124
|
+
details: { path: Y, from: X.from, via: "extend" }
|
|
2889
3125
|
}), {
|
|
2890
|
-
source:
|
|
3126
|
+
source: ee(_),
|
|
2891
3127
|
context: v(r, i)
|
|
2892
3128
|
};
|
|
2893
3129
|
throw d({
|
|
@@ -2896,32 +3132,32 @@ async function kn(t, e) {
|
|
|
2896
3132
|
details: { message: "layout extend is not supported" }
|
|
2897
3133
|
});
|
|
2898
3134
|
}
|
|
2899
|
-
const
|
|
3135
|
+
const it = Le(N, {
|
|
2900
3136
|
path: b,
|
|
2901
3137
|
mode: "layout"
|
|
2902
|
-
}),
|
|
2903
|
-
|
|
2904
|
-
),
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
),
|
|
3138
|
+
}), st = new Map(
|
|
3139
|
+
_.map((z) => [z.name, z.body])
|
|
3140
|
+
), ot = Tn(
|
|
3141
|
+
N,
|
|
3142
|
+
it,
|
|
3143
|
+
st
|
|
3144
|
+
), at = v(
|
|
2909
3145
|
r,
|
|
2910
|
-
|
|
3146
|
+
U,
|
|
2911
3147
|
i
|
|
2912
3148
|
);
|
|
2913
|
-
return { source:
|
|
3149
|
+
return { source: ot, context: at };
|
|
2914
3150
|
} finally {
|
|
2915
3151
|
c.pop();
|
|
2916
3152
|
}
|
|
2917
|
-
} catch (
|
|
2918
|
-
const
|
|
2919
|
-
throw
|
|
3153
|
+
} catch (E) {
|
|
3154
|
+
const L = An(E);
|
|
3155
|
+
throw L.adjusted ? L.errorToThrow : E;
|
|
2920
3156
|
} finally {
|
|
2921
3157
|
T && c.pop();
|
|
2922
3158
|
}
|
|
2923
3159
|
}
|
|
2924
|
-
const
|
|
3160
|
+
const On = ht.warningReasons, Rn = [
|
|
2925
3161
|
{
|
|
2926
3162
|
reason: "contains_html_script_tag",
|
|
2927
3163
|
test: (t) => /<\/?script\b/i.test(t)
|
|
@@ -2943,17 +3179,17 @@ const yn = se.warningReasons, bn = [
|
|
|
2943
3179
|
test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
|
|
2944
3180
|
}
|
|
2945
3181
|
];
|
|
2946
|
-
function
|
|
2947
|
-
return
|
|
3182
|
+
function Mn(t) {
|
|
3183
|
+
return On[t] ?? t;
|
|
2948
3184
|
}
|
|
2949
|
-
function
|
|
3185
|
+
function re(t, e, n, r) {
|
|
2950
3186
|
if (typeof t == "string") {
|
|
2951
|
-
for (const i of
|
|
3187
|
+
for (const i of Rn)
|
|
2952
3188
|
i.test(t) && n.push({
|
|
2953
3189
|
code: "suspicious_context_value",
|
|
2954
|
-
message:
|
|
3190
|
+
message: H("suspicious_context_value", {
|
|
2955
3191
|
key: e,
|
|
2956
|
-
reason:
|
|
3192
|
+
reason: Mn(i.reason)
|
|
2957
3193
|
}),
|
|
2958
3194
|
path: r,
|
|
2959
3195
|
details: { key: e, reason: i.reason }
|
|
@@ -2963,7 +3199,7 @@ function ne(t, e, n, r) {
|
|
|
2963
3199
|
if (t != null) {
|
|
2964
3200
|
if (Array.isArray(t)) {
|
|
2965
3201
|
for (let i = 0; i < t.length; i++)
|
|
2966
|
-
|
|
3202
|
+
re(t[i], `${e}[${i}]`, n, r);
|
|
2967
3203
|
return;
|
|
2968
3204
|
}
|
|
2969
3205
|
if (typeof t == "object")
|
|
@@ -2971,23 +3207,23 @@ function ne(t, e, n, r) {
|
|
|
2971
3207
|
t
|
|
2972
3208
|
)) {
|
|
2973
3209
|
const o = e.length > 0 ? `${e}.${i}` : i;
|
|
2974
|
-
|
|
3210
|
+
re(s, o, n, r);
|
|
2975
3211
|
}
|
|
2976
3212
|
}
|
|
2977
3213
|
}
|
|
2978
|
-
function
|
|
3214
|
+
function Hn(t, e, n) {
|
|
2979
3215
|
for (const [r, i] of Object.entries(t))
|
|
2980
|
-
|
|
3216
|
+
re(i, r, e, n);
|
|
2981
3217
|
}
|
|
2982
|
-
const
|
|
2983
|
-
function
|
|
2984
|
-
const e =
|
|
3218
|
+
const Dn = /^=+[ \t]*$/, Nn = /^-+[ \t]*$/, Fn = /^(```|~~~)/, jn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
|
|
3219
|
+
function ie(t) {
|
|
3220
|
+
const e = jn.exec(t);
|
|
2985
3221
|
return e && e.index !== void 0 ? {
|
|
2986
3222
|
text: t.slice(0, e.index).trim(),
|
|
2987
3223
|
explicitId: e[1]
|
|
2988
3224
|
} : { text: t.trim() };
|
|
2989
3225
|
}
|
|
2990
|
-
function
|
|
3226
|
+
function Bn(t) {
|
|
2991
3227
|
let e = 0;
|
|
2992
3228
|
for (; e < t.length && e < 6 && t[e] === "#"; )
|
|
2993
3229
|
e += 1;
|
|
@@ -3015,7 +3251,7 @@ function Wn(t) {
|
|
|
3015
3251
|
}
|
|
3016
3252
|
if (i <= n)
|
|
3017
3253
|
return null;
|
|
3018
|
-
const s =
|
|
3254
|
+
const s = ie(t.slice(n, i));
|
|
3019
3255
|
return { level: e, ...s };
|
|
3020
3256
|
}
|
|
3021
3257
|
function Re(t, e, n) {
|
|
@@ -3034,13 +3270,13 @@ function Re(t, e, n) {
|
|
|
3034
3270
|
e.inHtmlComment = !1, r = i + 3;
|
|
3035
3271
|
}
|
|
3036
3272
|
}
|
|
3037
|
-
function
|
|
3273
|
+
function In(t, e) {
|
|
3038
3274
|
if (e.inFence || e.inHtmlComment)
|
|
3039
3275
|
return !0;
|
|
3040
3276
|
const n = t.trim();
|
|
3041
3277
|
return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
|
|
3042
3278
|
}
|
|
3043
|
-
function
|
|
3279
|
+
function Un(t) {
|
|
3044
3280
|
const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
|
|
3045
3281
|
for (let i = 0; i < e.length; i++) {
|
|
3046
3282
|
const s = e[i];
|
|
@@ -3053,7 +3289,7 @@ function An(t) {
|
|
|
3053
3289
|
Re(s, r, 0);
|
|
3054
3290
|
continue;
|
|
3055
3291
|
}
|
|
3056
|
-
const o =
|
|
3292
|
+
const o = Fn.exec(s.trimStart());
|
|
3057
3293
|
if (o) {
|
|
3058
3294
|
const l = o[1];
|
|
3059
3295
|
s.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
|
|
@@ -3063,22 +3299,22 @@ function An(t) {
|
|
|
3063
3299
|
Re(s, r, s.indexOf("<!--"));
|
|
3064
3300
|
continue;
|
|
3065
3301
|
}
|
|
3066
|
-
if (
|
|
3302
|
+
if (In(s, r))
|
|
3067
3303
|
continue;
|
|
3068
|
-
const c =
|
|
3304
|
+
const c = Bn(s);
|
|
3069
3305
|
if (c) {
|
|
3070
3306
|
n.push(c);
|
|
3071
3307
|
continue;
|
|
3072
3308
|
}
|
|
3073
3309
|
const h = e[i + 1];
|
|
3074
3310
|
if (h !== void 0 && s.trim().length > 0 && !s.trimStart().startsWith("#") && !s.trimStart().startsWith(">") && !s.trimStart().startsWith("|")) {
|
|
3075
|
-
if (
|
|
3076
|
-
const l =
|
|
3311
|
+
if (Dn.test(h)) {
|
|
3312
|
+
const l = ie(s.trim());
|
|
3077
3313
|
n.push({ level: 1, ...l }), i += 1;
|
|
3078
3314
|
continue;
|
|
3079
3315
|
}
|
|
3080
|
-
if (
|
|
3081
|
-
const l =
|
|
3316
|
+
if (Nn.test(h) && h.trim().length >= 1) {
|
|
3317
|
+
const l = ie(s.trim());
|
|
3082
3318
|
n.push({ level: 2, ...l }), i += 1;
|
|
3083
3319
|
continue;
|
|
3084
3320
|
}
|
|
@@ -3086,31 +3322,31 @@ function An(t) {
|
|
|
3086
3322
|
}
|
|
3087
3323
|
return n;
|
|
3088
3324
|
}
|
|
3089
|
-
const
|
|
3090
|
-
function
|
|
3325
|
+
const zn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
|
|
3326
|
+
function Vn() {
|
|
3091
3327
|
const t = /* @__PURE__ */ new Map();
|
|
3092
3328
|
return {
|
|
3093
3329
|
slug(e, n) {
|
|
3094
|
-
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;
|
|
3095
3331
|
return t.set(r, i + 1), i === 0 ? r : `${r}-${i}`;
|
|
3096
3332
|
}
|
|
3097
3333
|
};
|
|
3098
3334
|
}
|
|
3099
|
-
function
|
|
3100
|
-
return t.toLowerCase().replace(
|
|
3335
|
+
function Zn(t) {
|
|
3336
|
+
return t.toLowerCase().replace(zn, "").replace(/\s+/g, "-");
|
|
3101
3337
|
}
|
|
3102
|
-
function
|
|
3338
|
+
function qn(t) {
|
|
3103
3339
|
let e = t.trim();
|
|
3104
3340
|
e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
|
|
3105
3341
|
for (let n = 0; n < 3; n++)
|
|
3106
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");
|
|
3107
3343
|
return e.trim();
|
|
3108
3344
|
}
|
|
3109
|
-
function
|
|
3345
|
+
function Pn(t, e) {
|
|
3110
3346
|
if (t.length === 0)
|
|
3111
3347
|
return "";
|
|
3112
|
-
const n =
|
|
3113
|
-
const a =
|
|
3348
|
+
const n = Vn(), i = t.map((o) => {
|
|
3349
|
+
const a = qn(o.text), c = n.slug(a, o.explicitId);
|
|
3114
3350
|
return { level: o.level, text: a, anchor: c };
|
|
3115
3351
|
}).filter((o) => o.level <= e);
|
|
3116
3352
|
if (i.length === 0)
|
|
@@ -3119,32 +3355,32 @@ function Hn(t, e) {
|
|
|
3119
3355
|
return i.map((o) => `${" ".repeat((o.level - s) * 2)}- [${o.text}](#${o.anchor})`).join(`
|
|
3120
3356
|
`);
|
|
3121
3357
|
}
|
|
3122
|
-
function
|
|
3123
|
-
const r =
|
|
3124
|
-
const a =
|
|
3125
|
-
return a.length === 1 &&
|
|
3358
|
+
function Kn(t, e = {}) {
|
|
3359
|
+
const r = W(t).filter((o) => {
|
|
3360
|
+
const a = $(o.inner);
|
|
3361
|
+
return a.length === 1 && P(a[0]);
|
|
3126
3362
|
});
|
|
3127
3363
|
if (r.length === 0)
|
|
3128
3364
|
return t;
|
|
3129
|
-
const i =
|
|
3365
|
+
const i = Un(t);
|
|
3130
3366
|
let s = t;
|
|
3131
3367
|
for (let o = r.length - 1; o >= 0; o--) {
|
|
3132
|
-
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);
|
|
3133
3369
|
s = A(A(l, h), u);
|
|
3134
3370
|
}
|
|
3135
3371
|
return s;
|
|
3136
3372
|
}
|
|
3137
|
-
async function
|
|
3138
|
-
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(), {
|
|
3139
3375
|
source: a,
|
|
3140
3376
|
declarationUpdates: c
|
|
3141
|
-
} = await
|
|
3142
|
-
|
|
3377
|
+
} = await xn(t, { path: n, context: { ...r } });
|
|
3378
|
+
Hn(
|
|
3143
3379
|
v(r, c ?? {}),
|
|
3144
3380
|
s,
|
|
3145
3381
|
n
|
|
3146
3382
|
);
|
|
3147
|
-
const h = await
|
|
3383
|
+
const h = await Ln(a, {
|
|
3148
3384
|
path: n,
|
|
3149
3385
|
context: r,
|
|
3150
3386
|
declarationUpdates: c ?? {},
|
|
@@ -3154,19 +3390,19 @@ async function xe(t, e) {
|
|
|
3154
3390
|
visitStack: o,
|
|
3155
3391
|
warnings: s,
|
|
3156
3392
|
inComponent: e.inComponent ?? !1
|
|
3157
|
-
}), { source: l, context: u } = h, { source:
|
|
3393
|
+
}), { source: l, context: u } = h, { source: p, directives: x } = _n(l, {
|
|
3158
3394
|
path: n,
|
|
3159
3395
|
registry: i,
|
|
3160
3396
|
context: u
|
|
3161
|
-
}),
|
|
3162
|
-
if (
|
|
3397
|
+
}), m = e.loader;
|
|
3398
|
+
if (x.length > 0 && !m)
|
|
3163
3399
|
throw new Error("loader is required when processing include directives");
|
|
3164
|
-
let
|
|
3165
|
-
|
|
3166
|
-
source:
|
|
3167
|
-
directives:
|
|
3400
|
+
let w = p;
|
|
3401
|
+
x.length > 0 && m && (w = await un({
|
|
3402
|
+
source: p,
|
|
3403
|
+
directives: x,
|
|
3168
3404
|
context: u,
|
|
3169
|
-
loader:
|
|
3405
|
+
loader: m,
|
|
3170
3406
|
root: e.root,
|
|
3171
3407
|
path: n,
|
|
3172
3408
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
@@ -3175,42 +3411,48 @@ async function xe(t, e) {
|
|
|
3175
3411
|
warnings: s,
|
|
3176
3412
|
registry: i,
|
|
3177
3413
|
constrainToRoot: e.constrainToRoot
|
|
3178
|
-
})),
|
|
3414
|
+
})), w = await cn(w, {
|
|
3179
3415
|
context: u,
|
|
3180
3416
|
path: n,
|
|
3181
3417
|
registry: i,
|
|
3182
|
-
loader:
|
|
3418
|
+
loader: m,
|
|
3183
3419
|
rootDir: e.root,
|
|
3184
3420
|
warnings: s,
|
|
3185
3421
|
visitStack: o,
|
|
3186
3422
|
parentContext: u,
|
|
3187
3423
|
preserveHgComments: e.preserveHgComments,
|
|
3188
3424
|
constrainToRoot: e.constrainToRoot
|
|
3189
|
-
})
|
|
3425
|
+
});
|
|
3426
|
+
const _ = {
|
|
3190
3427
|
path: n,
|
|
3191
3428
|
registry: i,
|
|
3192
|
-
loader:
|
|
3429
|
+
loader: m,
|
|
3193
3430
|
rootDir: e.root,
|
|
3194
3431
|
warnings: s,
|
|
3195
3432
|
visitStack: o,
|
|
3196
3433
|
parentContext: u,
|
|
3197
3434
|
preserveHgComments: e.preserveHgComments,
|
|
3198
3435
|
constrainToRoot: e.constrainToRoot
|
|
3199
|
-
}
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
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(
|
|
3203
3445
|
t,
|
|
3204
3446
|
n
|
|
3205
3447
|
), l = v(r, a);
|
|
3206
|
-
let u = await
|
|
3448
|
+
let u = await ke(c, {
|
|
3207
3449
|
...e,
|
|
3208
3450
|
context: l,
|
|
3209
3451
|
registry: i,
|
|
3210
3452
|
warnings: s,
|
|
3211
3453
|
visitStack: o
|
|
3212
3454
|
});
|
|
3213
|
-
return u =
|
|
3455
|
+
return u = Sn(u, {
|
|
3214
3456
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
3215
3457
|
rawFrontMatter: h
|
|
3216
3458
|
}), {
|
|
@@ -3218,21 +3460,21 @@ async function qe(t, e = {}) {
|
|
|
3218
3460
|
warnings: s
|
|
3219
3461
|
};
|
|
3220
3462
|
}
|
|
3221
|
-
async function
|
|
3222
|
-
const n = e.path, { context: r, body: i } =
|
|
3223
|
-
return
|
|
3463
|
+
async function Yn(t, e) {
|
|
3464
|
+
const n = e.path, { context: r, body: i } = q(t, n), s = v(e.context, r);
|
|
3465
|
+
return ke(i, {
|
|
3224
3466
|
...e,
|
|
3225
3467
|
context: s,
|
|
3226
3468
|
preserveFrontMatter: !1
|
|
3227
3469
|
});
|
|
3228
3470
|
}
|
|
3229
|
-
async function
|
|
3230
|
-
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(
|
|
3231
3473
|
a,
|
|
3232
3474
|
e,
|
|
3233
3475
|
n?.serverContext
|
|
3234
3476
|
);
|
|
3235
|
-
return
|
|
3477
|
+
return rt(i.source, {
|
|
3236
3478
|
context: c,
|
|
3237
3479
|
loader: r,
|
|
3238
3480
|
root: s,
|
|
@@ -3242,7 +3484,7 @@ async function Fn(t, e, n) {
|
|
|
3242
3484
|
preserveHgComments: n?.preserveHgComments
|
|
3243
3485
|
});
|
|
3244
3486
|
}
|
|
3245
|
-
async function
|
|
3487
|
+
async function mr(t, e, n) {
|
|
3246
3488
|
if (n != null && "serverContext" in n && n.serverContext != null)
|
|
3247
3489
|
throw d({
|
|
3248
3490
|
code: "server_context_on_client"
|
|
@@ -3260,7 +3502,7 @@ async function nr(t, e, n) {
|
|
|
3260
3502
|
let i, s;
|
|
3261
3503
|
typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
|
|
3262
3504
|
const o = v(e);
|
|
3263
|
-
return
|
|
3505
|
+
return rt(i, {
|
|
3264
3506
|
context: o,
|
|
3265
3507
|
loader: r,
|
|
3266
3508
|
root: n?.root,
|
|
@@ -3270,30 +3512,30 @@ async function nr(t, e, n) {
|
|
|
3270
3512
|
constrainToRoot: n?.constrainToRoot
|
|
3271
3513
|
});
|
|
3272
3514
|
}
|
|
3273
|
-
function
|
|
3274
|
-
if (
|
|
3515
|
+
function Gn(t, e) {
|
|
3516
|
+
if (de(t))
|
|
3275
3517
|
throw d({
|
|
3276
3518
|
code: "parse_error",
|
|
3277
3519
|
path: e,
|
|
3278
3520
|
details: {
|
|
3279
|
-
message:
|
|
3521
|
+
message: ue(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
3280
3522
|
}
|
|
3281
3523
|
});
|
|
3282
|
-
const n = [], r =
|
|
3524
|
+
const n = [], r = W(t);
|
|
3283
3525
|
for (const i of r) {
|
|
3284
|
-
const s =
|
|
3526
|
+
const s = $(i.inner);
|
|
3285
3527
|
if (s.length === 0)
|
|
3286
3528
|
throw d({
|
|
3287
3529
|
code: "parse_error",
|
|
3288
3530
|
path: e,
|
|
3289
3531
|
details: { message: "empty hyogen block" }
|
|
3290
3532
|
});
|
|
3291
|
-
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])))
|
|
3292
3534
|
continue;
|
|
3293
3535
|
const o = s[0];
|
|
3294
3536
|
if (o === "endblock" || /^block\s+/.test(o))
|
|
3295
3537
|
continue;
|
|
3296
|
-
const a =
|
|
3538
|
+
const a = B(o, e);
|
|
3297
3539
|
if (a) {
|
|
3298
3540
|
n.push({ kind: "extend", path: a.path });
|
|
3299
3541
|
continue;
|
|
@@ -3301,8 +3543,8 @@ function jn(t, e) {
|
|
|
3301
3543
|
if (s.length !== 1) {
|
|
3302
3544
|
const c = s.join(`
|
|
3303
3545
|
`);
|
|
3304
|
-
if (
|
|
3305
|
-
(l) =>
|
|
3546
|
+
if (V(c) || s.every(
|
|
3547
|
+
(l) => ne(l) || B(l) !== null
|
|
3306
3548
|
))
|
|
3307
3549
|
continue;
|
|
3308
3550
|
throw d({
|
|
@@ -3312,12 +3554,12 @@ function jn(t, e) {
|
|
|
3312
3554
|
});
|
|
3313
3555
|
}
|
|
3314
3556
|
if (/^include\s+/i.test(o)) {
|
|
3315
|
-
const c =
|
|
3557
|
+
const c = nt(i.inner, e);
|
|
3316
3558
|
n.push({ kind: "include", path: c.path });
|
|
3317
3559
|
continue;
|
|
3318
3560
|
}
|
|
3319
3561
|
if (/^component\s+/i.test(o)) {
|
|
3320
|
-
const c =
|
|
3562
|
+
const c = tt(i.inner, e);
|
|
3321
3563
|
n.push({ kind: "component", path: c.path });
|
|
3322
3564
|
continue;
|
|
3323
3565
|
}
|
|
@@ -3329,8 +3571,8 @@ function jn(t, e) {
|
|
|
3329
3571
|
}
|
|
3330
3572
|
return n;
|
|
3331
3573
|
}
|
|
3332
|
-
function
|
|
3333
|
-
return
|
|
3574
|
+
function Jn(t, e, n) {
|
|
3575
|
+
return D(t) ? t : Z(t, {
|
|
3334
3576
|
rootDir: n.root,
|
|
3335
3577
|
fromPath: e,
|
|
3336
3578
|
documentPath: e,
|
|
@@ -3338,19 +3580,19 @@ function Bn(t, e, n) {
|
|
|
3338
3580
|
hyogenPath: !0
|
|
3339
3581
|
});
|
|
3340
3582
|
}
|
|
3341
|
-
async function
|
|
3583
|
+
async function Qn(t, e, n = {}) {
|
|
3342
3584
|
const r = t.map(
|
|
3343
|
-
(l) =>
|
|
3585
|
+
(l) => D(l) ? l : f.resolve(l)
|
|
3344
3586
|
), i = new Set(r), s = /* @__PURE__ */ new Set(), o = [], a = [...r];
|
|
3345
3587
|
for (; a.length > 0; ) {
|
|
3346
3588
|
const l = a.shift();
|
|
3347
3589
|
if (s.has(l))
|
|
3348
3590
|
continue;
|
|
3349
3591
|
s.add(l);
|
|
3350
|
-
const u = await e(l),
|
|
3351
|
-
for (const
|
|
3352
|
-
const
|
|
3353
|
-
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);
|
|
3354
3596
|
}
|
|
3355
3597
|
}
|
|
3356
3598
|
const c = [...s], h = c.filter((l) => !i.has(l));
|
|
@@ -3361,22 +3603,22 @@ async function In(t, e, n = {}) {
|
|
|
3361
3603
|
edges: o
|
|
3362
3604
|
};
|
|
3363
3605
|
}
|
|
3364
|
-
function
|
|
3606
|
+
function er(t) {
|
|
3365
3607
|
return t.replace(/\\/g, "/").split("/").filter((r) => r.length > 0).some((r) => r.startsWith("_"));
|
|
3366
3608
|
}
|
|
3367
|
-
function
|
|
3368
|
-
return
|
|
3609
|
+
function tr(t) {
|
|
3610
|
+
return mt.scan(t).isGlob;
|
|
3369
3611
|
}
|
|
3370
|
-
function
|
|
3371
|
-
return t.root ?
|
|
3612
|
+
function nr(t) {
|
|
3613
|
+
return t.root ? f.resolve(t.root) : t.cwd ? f.resolve(t.cwd) : I(process.cwd()) ?? process.cwd();
|
|
3372
3614
|
}
|
|
3373
|
-
async function
|
|
3374
|
-
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();
|
|
3375
3617
|
for (const o of n) {
|
|
3376
|
-
if (!
|
|
3377
|
-
const c =
|
|
3618
|
+
if (!tr(o)) {
|
|
3619
|
+
const c = f.isAbsolute(o) ? f.resolve(o) : f.resolve(r, o);
|
|
3378
3620
|
try {
|
|
3379
|
-
if (!(await
|
|
3621
|
+
if (!(await se(c)).isFile())
|
|
3380
3622
|
throw d({
|
|
3381
3623
|
code: "file_not_found",
|
|
3382
3624
|
path: c,
|
|
@@ -3397,48 +3639,48 @@ async function Vn(t, e = {}) {
|
|
|
3397
3639
|
}
|
|
3398
3640
|
}) : l;
|
|
3399
3641
|
}
|
|
3400
|
-
const h =
|
|
3642
|
+
const h = f.relative(r, c).replace(/\\/g, "/");
|
|
3401
3643
|
s.set(h, c);
|
|
3402
3644
|
continue;
|
|
3403
3645
|
}
|
|
3404
|
-
const a = await
|
|
3646
|
+
const a = await pt(o, {
|
|
3405
3647
|
cwd: r,
|
|
3406
3648
|
absolute: !0,
|
|
3407
3649
|
onlyFiles: !0,
|
|
3408
3650
|
dot: !1
|
|
3409
3651
|
});
|
|
3410
3652
|
for (const c of a) {
|
|
3411
|
-
const h =
|
|
3412
|
-
!i &&
|
|
3653
|
+
const h = f.relative(r, c).replace(/\\/g, "/");
|
|
3654
|
+
!i && er(h) || s.set(h, f.resolve(c));
|
|
3413
3655
|
}
|
|
3414
3656
|
}
|
|
3415
3657
|
return [...s.values()];
|
|
3416
3658
|
}
|
|
3417
|
-
function
|
|
3659
|
+
function ir(t) {
|
|
3418
3660
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
3419
3661
|
}
|
|
3420
|
-
function
|
|
3662
|
+
function sr(t, e) {
|
|
3421
3663
|
if (t)
|
|
3422
|
-
return
|
|
3664
|
+
return f.resolve(t);
|
|
3423
3665
|
for (const n of e) {
|
|
3424
|
-
const r =
|
|
3666
|
+
const r = I(n);
|
|
3425
3667
|
if (r)
|
|
3426
3668
|
return r;
|
|
3427
3669
|
}
|
|
3428
|
-
return e.length > 0 ?
|
|
3670
|
+
return e.length > 0 ? f.dirname(f.resolve(e[0])) : process.cwd();
|
|
3429
3671
|
}
|
|
3430
|
-
async function
|
|
3431
|
-
const e = await
|
|
3672
|
+
async function gr(t) {
|
|
3673
|
+
const e = await rr(t.input, {
|
|
3432
3674
|
root: t.root,
|
|
3433
3675
|
includeUnderscoreEntries: t.includeUnderscoreEntries
|
|
3434
|
-
}), n =
|
|
3435
|
-
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, {
|
|
3436
3678
|
root: n,
|
|
3437
3679
|
constrainToRoot: i
|
|
3438
3680
|
});
|
|
3439
|
-
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 = [];
|
|
3440
3682
|
for (const l of e) {
|
|
3441
|
-
const u =
|
|
3683
|
+
const u = f.resolve(l), p = f.relative(n, u).replace(/\\/g, "/"), x = await Xn(
|
|
3442
3684
|
{ path: u },
|
|
3443
3685
|
a,
|
|
3444
3686
|
{
|
|
@@ -3448,27 +3690,27 @@ async function rr(t) {
|
|
|
3448
3690
|
preserveFrontMatter: t.preserveFrontMatter,
|
|
3449
3691
|
preserveHgComments: t.preserveHgComments
|
|
3450
3692
|
}
|
|
3451
|
-
),
|
|
3693
|
+
), m = f.join(t.outDir, p);
|
|
3452
3694
|
try {
|
|
3453
|
-
await
|
|
3454
|
-
} catch (
|
|
3455
|
-
if (
|
|
3456
|
-
throw
|
|
3457
|
-
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";
|
|
3458
3700
|
throw d({
|
|
3459
3701
|
code: "load_failed",
|
|
3460
|
-
path:
|
|
3702
|
+
path: m,
|
|
3461
3703
|
details: {
|
|
3462
|
-
path:
|
|
3463
|
-
reason:
|
|
3704
|
+
path: m,
|
|
3705
|
+
reason: _
|
|
3464
3706
|
}
|
|
3465
3707
|
});
|
|
3466
3708
|
}
|
|
3467
|
-
c.push({ path:
|
|
3709
|
+
c.push({ path: p, markdown: x.markdown }), h.push(...x.warnings);
|
|
3468
3710
|
}
|
|
3469
3711
|
return { files: c, warnings: h };
|
|
3470
3712
|
}
|
|
3471
|
-
function
|
|
3713
|
+
function wr(t, e) {
|
|
3472
3714
|
const n = [`[hyogen:${t}] ${e.code}`], r = {};
|
|
3473
3715
|
if (e.details)
|
|
3474
3716
|
for (const [i, s] of Object.entries(e.details))
|
|
@@ -3480,15 +3722,15 @@ function ir(t, e) {
|
|
|
3480
3722
|
`);
|
|
3481
3723
|
}
|
|
3482
3724
|
export {
|
|
3483
|
-
|
|
3484
|
-
|
|
3725
|
+
gr as build,
|
|
3726
|
+
De as createFsLoader,
|
|
3485
3727
|
d as createHyogenError,
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
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
|
|
3493
3735
|
};
|
|
3494
3736
|
//# sourceMappingURL=index.js.map
|