@b4moss/hyogen-md 0.11.0 → 0.13.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 +5587 -0
- package/dist/client.js +1163 -821
- 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/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 +1162 -794
- 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
|
|
9
|
-
|
|
1
|
+
import { stat as se, readFile as Oe, mkdir as at, writeFile as ct } from "node:fs/promises";
|
|
2
|
+
import { c as d, f as H, m as lt } from "./createError-WZmAl05N.js";
|
|
3
|
+
import { a as mr } from "./createError-WZmAl05N.js";
|
|
4
|
+
import f from "node:path";
|
|
5
|
+
import { parse as Re } from "yaml";
|
|
6
|
+
import { Readable as ht } from "node:stream";
|
|
7
|
+
import dt from "csv-parser";
|
|
8
|
+
import { existsSync as ke, statSync as ut } from "node:fs";
|
|
9
|
+
import ft from "fast-glob";
|
|
10
|
+
import pt from "picomatch";
|
|
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: Qe,
|
|
17
|
-
warnings: et,
|
|
18
|
-
warningReasons: tt
|
|
19
|
-
}, nt = re.errors, rt = re.warnings;
|
|
20
|
-
function Ae(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 it(t, e) {
|
|
29
|
-
return Ae(nt[t], e);
|
|
30
|
-
}
|
|
31
|
-
function O(t, e) {
|
|
32
|
-
return Ae(rt[t], e);
|
|
33
|
-
}
|
|
34
|
-
function d(t) {
|
|
35
|
-
const e = t.message ?? it(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 st(t) {
|
|
17
|
+
function mt(t) {
|
|
39
18
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
40
19
|
}
|
|
41
|
-
function
|
|
20
|
+
function Me(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,
|
|
@@ -51,9 +30,9 @@ function ot(t = {}) {
|
|
|
51
30
|
reason: "not a file"
|
|
52
31
|
}
|
|
53
32
|
});
|
|
54
|
-
return await
|
|
33
|
+
return await Oe(r, "utf8");
|
|
55
34
|
} catch (i) {
|
|
56
|
-
if (
|
|
35
|
+
if (mt(i))
|
|
57
36
|
throw i;
|
|
58
37
|
const s = i;
|
|
59
38
|
throw s.code === "ENOENT" ? d({
|
|
@@ -75,21 +54,43 @@ function ot(t = {}) {
|
|
|
75
54
|
}
|
|
76
55
|
};
|
|
77
56
|
}
|
|
78
|
-
function
|
|
57
|
+
function N(t) {
|
|
79
58
|
return /^https?:\/\//i.test(t);
|
|
80
59
|
}
|
|
81
|
-
function
|
|
60
|
+
function gt(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 He(t = {}) {
|
|
64
|
+
const { from: e, via: n = "include" } = t, r = Me(t);
|
|
86
65
|
return async (i) => {
|
|
87
|
-
if (!
|
|
66
|
+
if (!N(i))
|
|
88
67
|
return r(i);
|
|
68
|
+
let s;
|
|
89
69
|
try {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
+
});
|
|
90
|
+
try {
|
|
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,48 +103,271 @@ function ie(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 (gt(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
|
-
|
|
125
|
-
|
|
125
|
+
function wt(t) {
|
|
126
|
+
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
127
|
+
}
|
|
128
|
+
function xt(t) {
|
|
129
|
+
return Object.keys(t).sort((e, n) => Number(e) - Number(n)).map((e) => t[e] ?? "");
|
|
130
|
+
}
|
|
131
|
+
function kt(t) {
|
|
132
|
+
return t.every((e) => e === "");
|
|
133
|
+
}
|
|
134
|
+
async function yt(t) {
|
|
135
|
+
return new Promise((e, n) => {
|
|
136
|
+
const r = [];
|
|
137
|
+
ht.from([t]).pipe(dt({ headers: !1 })).on("data", (i) => {
|
|
138
|
+
const s = xt(i);
|
|
139
|
+
kt(s) || r.push(s);
|
|
140
|
+
}).on("end", () => e(r)).on("error", (i) => n(i));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async function bt(t, e) {
|
|
144
|
+
if (t.length === 0 || t.trim().length === 0)
|
|
145
|
+
throw d({
|
|
146
|
+
code: "parse_error",
|
|
147
|
+
path: e,
|
|
148
|
+
details: { message: "empty CSV" }
|
|
149
|
+
});
|
|
150
|
+
let n;
|
|
151
|
+
try {
|
|
152
|
+
n = await yt(t);
|
|
153
|
+
} catch (o) {
|
|
154
|
+
throw wt(o) ? o : d({
|
|
155
|
+
code: "parse_error",
|
|
156
|
+
path: e,
|
|
157
|
+
details: {
|
|
158
|
+
message: o instanceof Error ? o.message : "invalid CSV"
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
if (n.length === 0)
|
|
163
|
+
throw d({
|
|
164
|
+
code: "parse_error",
|
|
165
|
+
path: e,
|
|
166
|
+
details: { message: "empty CSV" }
|
|
167
|
+
});
|
|
168
|
+
const [r, ...i] = n, s = r.length;
|
|
169
|
+
for (const o of i)
|
|
170
|
+
if (o.length !== s)
|
|
171
|
+
throw d({
|
|
172
|
+
code: "parse_error",
|
|
173
|
+
path: e,
|
|
174
|
+
details: { message: "CSV row column count mismatch" }
|
|
175
|
+
});
|
|
176
|
+
return i.map((o) => {
|
|
177
|
+
const a = {};
|
|
178
|
+
for (let c = 0; c < r.length; c++)
|
|
179
|
+
a[r[c]] = o[c] ?? "";
|
|
180
|
+
return a;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
function vt(t) {
|
|
184
|
+
return f.extname(t).slice(1).toLowerCase();
|
|
185
|
+
}
|
|
186
|
+
function _t(t, e) {
|
|
187
|
+
if (t.length === 0)
|
|
188
|
+
throw d({
|
|
189
|
+
code: "parse_error",
|
|
190
|
+
path: e,
|
|
191
|
+
details: { message: "empty data file" }
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
async function St(t, e) {
|
|
195
|
+
_t(t, e);
|
|
196
|
+
const n = vt(e);
|
|
197
|
+
switch (n) {
|
|
198
|
+
case "json":
|
|
199
|
+
try {
|
|
200
|
+
return JSON.parse(t);
|
|
201
|
+
} catch (r) {
|
|
202
|
+
throw d({
|
|
203
|
+
code: "parse_error",
|
|
204
|
+
path: e,
|
|
205
|
+
details: {
|
|
206
|
+
message: r instanceof Error ? r.message : "invalid JSON"
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
case "yaml":
|
|
211
|
+
case "yml":
|
|
212
|
+
try {
|
|
213
|
+
return Re(t);
|
|
214
|
+
} catch (r) {
|
|
215
|
+
throw d({
|
|
216
|
+
code: "parse_error",
|
|
217
|
+
path: e,
|
|
218
|
+
details: {
|
|
219
|
+
message: r instanceof Error ? r.message : "invalid YAML"
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
case "csv":
|
|
224
|
+
return bt(t, e);
|
|
225
|
+
default:
|
|
226
|
+
throw d({
|
|
227
|
+
code: "parse_error",
|
|
228
|
+
path: e,
|
|
229
|
+
details: {
|
|
230
|
+
format: n,
|
|
231
|
+
message: `unsupported data file format: ${n}`
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const Et = ".doc_root";
|
|
237
|
+
function I(t) {
|
|
126
238
|
let e;
|
|
127
|
-
for (
|
|
128
|
-
const n =
|
|
129
|
-
if (
|
|
239
|
+
for (ke(t) ? e = ut(t).isFile() ? f.dirname(t) : f.resolve(t) : e = f.dirname(f.resolve(t)); ; ) {
|
|
240
|
+
const n = f.join(e, Et);
|
|
241
|
+
if (ke(n))
|
|
130
242
|
return e;
|
|
131
|
-
const r =
|
|
243
|
+
const r = f.dirname(e);
|
|
132
244
|
if (r === e)
|
|
133
245
|
return;
|
|
134
246
|
e = r;
|
|
135
247
|
}
|
|
136
248
|
}
|
|
137
|
-
|
|
249
|
+
function Ct(t, e) {
|
|
250
|
+
const n = f.relative(e, t);
|
|
251
|
+
return n === "" || !n.startsWith("..") && !f.isAbsolute(n);
|
|
252
|
+
}
|
|
253
|
+
function $t(t, e, n) {
|
|
254
|
+
const r = f.resolve(e), i = f.resolve(t);
|
|
255
|
+
if (!Ct(i, r))
|
|
256
|
+
throw d({
|
|
257
|
+
code: "parse_error",
|
|
258
|
+
path: n,
|
|
259
|
+
details: { message: "path resolves outside root directory" }
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function Z(t, e = {}) {
|
|
263
|
+
const { rootDir: n, fromPath: r, documentPath: i, constrainToRoot: s = !1, hyogenPath: o = !1 } = e;
|
|
264
|
+
if (t.length === 0)
|
|
265
|
+
throw d({
|
|
266
|
+
code: "parse_error",
|
|
267
|
+
path: i,
|
|
268
|
+
details: { message: "empty template path" }
|
|
269
|
+
});
|
|
270
|
+
let a;
|
|
271
|
+
if (t.startsWith("/"))
|
|
272
|
+
if (n)
|
|
273
|
+
a = f.resolve(n, t.slice(1));
|
|
274
|
+
else {
|
|
275
|
+
if (o)
|
|
276
|
+
throw d({
|
|
277
|
+
code: "parse_error",
|
|
278
|
+
path: i,
|
|
279
|
+
details: { message: "root-relative paths require a doc root" }
|
|
280
|
+
});
|
|
281
|
+
if (f.isAbsolute(t))
|
|
282
|
+
a = f.resolve(t);
|
|
283
|
+
else
|
|
284
|
+
throw d({
|
|
285
|
+
code: "parse_error",
|
|
286
|
+
path: i,
|
|
287
|
+
details: { message: "root-relative paths require a doc root" }
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
else if (t.startsWith("./") || t.startsWith("../"))
|
|
291
|
+
if (r)
|
|
292
|
+
a = f.resolve(f.dirname(r), t);
|
|
293
|
+
else if (n)
|
|
294
|
+
a = f.resolve(n, t);
|
|
295
|
+
else
|
|
296
|
+
throw d({
|
|
297
|
+
code: "parse_error",
|
|
298
|
+
path: i,
|
|
299
|
+
details: { message: "root is required for relative template paths" }
|
|
300
|
+
});
|
|
301
|
+
else if (f.isAbsolute(t))
|
|
302
|
+
a = f.resolve(t);
|
|
303
|
+
else if (n)
|
|
304
|
+
a = f.resolve(n, t);
|
|
305
|
+
else
|
|
306
|
+
throw d({
|
|
307
|
+
code: "parse_error",
|
|
308
|
+
path: i,
|
|
309
|
+
details: { message: "root is required for relative template paths" }
|
|
310
|
+
});
|
|
311
|
+
return n && s && $t(a, n, i), a;
|
|
312
|
+
}
|
|
313
|
+
const ye = 5 * 1024 * 1024;
|
|
314
|
+
function Wt(t) {
|
|
315
|
+
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
316
|
+
}
|
|
317
|
+
function Tt(t) {
|
|
318
|
+
return t?.root ? f.resolve(t.root) : I(process.cwd()) ?? process.cwd();
|
|
319
|
+
}
|
|
320
|
+
async function Ne(t, e) {
|
|
321
|
+
const n = Tt(e), r = e?.loader ?? Me(), i = {};
|
|
322
|
+
for (const [s, o] of Object.entries(t)) {
|
|
323
|
+
if (N(o))
|
|
324
|
+
throw d({
|
|
325
|
+
code: "load_failed",
|
|
326
|
+
path: o,
|
|
327
|
+
details: {
|
|
328
|
+
path: o,
|
|
329
|
+
reason: "remote data sources are not supported"
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
const a = Z(o, { rootDir: n });
|
|
333
|
+
let c;
|
|
334
|
+
try {
|
|
335
|
+
c = await r(a);
|
|
336
|
+
} catch (l) {
|
|
337
|
+
throw Wt(l) ? l : d({
|
|
338
|
+
code: "load_failed",
|
|
339
|
+
path: a,
|
|
340
|
+
details: {
|
|
341
|
+
path: a,
|
|
342
|
+
reason: l instanceof Error ? l.message : "unknown load error"
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
const h = Buffer.byteLength(c, "utf8");
|
|
347
|
+
if (h > ye)
|
|
348
|
+
throw d({
|
|
349
|
+
code: "data_source_too_large",
|
|
350
|
+
path: a,
|
|
351
|
+
details: {
|
|
352
|
+
path: a,
|
|
353
|
+
size: h,
|
|
354
|
+
limit: ye
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
i[s] = await St(c, a);
|
|
358
|
+
}
|
|
359
|
+
return i;
|
|
360
|
+
}
|
|
361
|
+
async function At(t, e) {
|
|
138
362
|
if (typeof t == "string")
|
|
139
363
|
return {
|
|
140
364
|
source: t,
|
|
141
365
|
rootDir: e?.root
|
|
142
366
|
};
|
|
143
|
-
const n =
|
|
367
|
+
const n = f.resolve(t.path);
|
|
144
368
|
let r;
|
|
145
369
|
try {
|
|
146
|
-
r = await
|
|
370
|
+
r = await se(n);
|
|
147
371
|
} catch (a) {
|
|
148
372
|
const c = a;
|
|
149
373
|
throw c.code === "ENOENT" ? d({
|
|
@@ -171,7 +395,7 @@ async function ht(t, e) {
|
|
|
171
395
|
});
|
|
172
396
|
let i;
|
|
173
397
|
try {
|
|
174
|
-
i = await
|
|
398
|
+
i = await Oe(n, "utf8");
|
|
175
399
|
} catch (a) {
|
|
176
400
|
throw d({
|
|
177
401
|
code: "load_failed",
|
|
@@ -182,7 +406,7 @@ async function ht(t, e) {
|
|
|
182
406
|
}
|
|
183
407
|
});
|
|
184
408
|
}
|
|
185
|
-
const s =
|
|
409
|
+
const s = I(n), o = e?.root ?? s;
|
|
186
410
|
return {
|
|
187
411
|
source: i,
|
|
188
412
|
rootDir: o,
|
|
@@ -190,7 +414,7 @@ async function ht(t, e) {
|
|
|
190
414
|
constrainToRoot: s !== void 0
|
|
191
415
|
};
|
|
192
416
|
}
|
|
193
|
-
class
|
|
417
|
+
class De {
|
|
194
418
|
components = /* @__PURE__ */ new Map();
|
|
195
419
|
register(e, n, r) {
|
|
196
420
|
if (this.components.has(e.alias))
|
|
@@ -214,8 +438,8 @@ class Re {
|
|
|
214
438
|
return this.components.has(e);
|
|
215
439
|
}
|
|
216
440
|
}
|
|
217
|
-
const
|
|
218
|
-
function
|
|
441
|
+
const be = 64 * 1024;
|
|
442
|
+
function q(t, e) {
|
|
219
443
|
if (!t.startsWith("---"))
|
|
220
444
|
return { context: {}, body: t };
|
|
221
445
|
const n = t.indexOf(`
|
|
@@ -227,13 +451,13 @@ function U(t, e) {
|
|
|
227
451
|
if (r === -1)
|
|
228
452
|
return { context: {}, body: t };
|
|
229
453
|
const i = t.slice(n + 1, r), s = Buffer.byteLength(i, "utf8");
|
|
230
|
-
if (s >
|
|
454
|
+
if (s > be)
|
|
231
455
|
throw d({
|
|
232
456
|
code: "frontmatter_too_large",
|
|
233
457
|
path: e,
|
|
234
458
|
details: {
|
|
235
459
|
size: s,
|
|
236
|
-
limit:
|
|
460
|
+
limit: be
|
|
237
461
|
}
|
|
238
462
|
});
|
|
239
463
|
if (i.trim().length === 0)
|
|
@@ -244,7 +468,7 @@ function U(t, e) {
|
|
|
244
468
|
});
|
|
245
469
|
let o;
|
|
246
470
|
try {
|
|
247
|
-
const h =
|
|
471
|
+
const h = Re(i);
|
|
248
472
|
if (h == null)
|
|
249
473
|
o = {};
|
|
250
474
|
else if (typeof h == "object" && !Array.isArray(h))
|
|
@@ -272,14 +496,14 @@ ${i}
|
|
|
272
496
|
---`
|
|
273
497
|
};
|
|
274
498
|
}
|
|
275
|
-
const
|
|
499
|
+
const Lt = /* @__PURE__ */ new Set([
|
|
276
500
|
"string",
|
|
277
501
|
"number",
|
|
278
502
|
"boolean",
|
|
279
503
|
"object",
|
|
280
504
|
"array"
|
|
281
505
|
]);
|
|
282
|
-
function
|
|
506
|
+
function Ot(t, e) {
|
|
283
507
|
const n = t.props;
|
|
284
508
|
if (n === void 0)
|
|
285
509
|
return {};
|
|
@@ -298,13 +522,13 @@ function dt(t, e) {
|
|
|
298
522
|
const o = s, a = {};
|
|
299
523
|
if ("type" in o && o.type !== void 0) {
|
|
300
524
|
const c = String(o.type);
|
|
301
|
-
|
|
525
|
+
Lt.has(c) ? a.type = c : a.type = void 0;
|
|
302
526
|
}
|
|
303
527
|
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[i] = a;
|
|
304
528
|
}
|
|
305
529
|
return r;
|
|
306
530
|
}
|
|
307
|
-
function
|
|
531
|
+
function Rt(t) {
|
|
308
532
|
if (t != null) {
|
|
309
533
|
if (typeof t == "string") return "string";
|
|
310
534
|
if (typeof t == "number") return "number";
|
|
@@ -313,30 +537,30 @@ function pt(t) {
|
|
|
313
537
|
if (typeof t == "object") return "object";
|
|
314
538
|
}
|
|
315
539
|
}
|
|
316
|
-
function
|
|
540
|
+
function Mt(t, e) {
|
|
317
541
|
return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
|
|
318
542
|
}
|
|
319
|
-
function
|
|
543
|
+
function G(t, e) {
|
|
320
544
|
return {
|
|
321
545
|
code: t,
|
|
322
|
-
message:
|
|
546
|
+
message: H(t, e),
|
|
323
547
|
details: e
|
|
324
548
|
};
|
|
325
549
|
}
|
|
326
|
-
function
|
|
550
|
+
function Ht(t, e, n) {
|
|
327
551
|
const r = [], i = {}, s = new Set(Object.keys(e));
|
|
328
552
|
for (const [o, a] of Object.entries(e)) {
|
|
329
553
|
const c = Object.prototype.hasOwnProperty.call(t, o);
|
|
330
554
|
let h = c ? t[o] : void 0;
|
|
331
555
|
if (c || (a.default !== void 0 ? h = a.default : (a.isRequired && r.push(
|
|
332
|
-
|
|
556
|
+
G("prop_missing", {
|
|
333
557
|
prop: o,
|
|
334
558
|
component: n
|
|
335
559
|
})
|
|
336
560
|
), h = void 0)), c && h !== void 0 && h !== null) {
|
|
337
|
-
const l = a.type ??
|
|
338
|
-
l && !
|
|
339
|
-
|
|
561
|
+
const l = a.type ?? Rt(h);
|
|
562
|
+
l && !Mt(h, l) && (r.push(
|
|
563
|
+
G("prop_type_mismatch", {
|
|
340
564
|
prop: o,
|
|
341
565
|
component: n,
|
|
342
566
|
expected: l,
|
|
@@ -348,78 +572,14 @@ function ft(t, e, n) {
|
|
|
348
572
|
}
|
|
349
573
|
for (const o of Object.keys(t))
|
|
350
574
|
s.has(o) || (Object.keys(e).length > 0 ? r.push(
|
|
351
|
-
|
|
575
|
+
G("prop_unknown", {
|
|
352
576
|
prop: o,
|
|
353
577
|
component: n
|
|
354
578
|
})
|
|
355
579
|
) : i[o] = t[o]);
|
|
356
580
|
return { values: i, warnings: r };
|
|
357
581
|
}
|
|
358
|
-
function
|
|
359
|
-
const n = u.relative(e, t);
|
|
360
|
-
return n === "" || !n.startsWith("..") && !u.isAbsolute(n);
|
|
361
|
-
}
|
|
362
|
-
function gt(t, e, n) {
|
|
363
|
-
const r = u.resolve(e), i = u.resolve(t);
|
|
364
|
-
if (!mt(i, r))
|
|
365
|
-
throw d({
|
|
366
|
-
code: "parse_error",
|
|
367
|
-
path: n,
|
|
368
|
-
details: { message: "path resolves outside root directory" }
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
function V(t, e = {}) {
|
|
372
|
-
const { rootDir: n, fromPath: r, documentPath: i, constrainToRoot: s = !1, hyogenPath: o = !1 } = e;
|
|
373
|
-
if (t.length === 0)
|
|
374
|
-
throw d({
|
|
375
|
-
code: "parse_error",
|
|
376
|
-
path: i,
|
|
377
|
-
details: { message: "empty template path" }
|
|
378
|
-
});
|
|
379
|
-
let a;
|
|
380
|
-
if (t.startsWith("/"))
|
|
381
|
-
if (n)
|
|
382
|
-
a = u.resolve(n, t.slice(1));
|
|
383
|
-
else {
|
|
384
|
-
if (o)
|
|
385
|
-
throw d({
|
|
386
|
-
code: "parse_error",
|
|
387
|
-
path: i,
|
|
388
|
-
details: { message: "root-relative paths require a doc root" }
|
|
389
|
-
});
|
|
390
|
-
if (u.isAbsolute(t))
|
|
391
|
-
a = u.resolve(t);
|
|
392
|
-
else
|
|
393
|
-
throw d({
|
|
394
|
-
code: "parse_error",
|
|
395
|
-
path: i,
|
|
396
|
-
details: { message: "root-relative paths require a doc root" }
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
else if (t.startsWith("./") || t.startsWith("../"))
|
|
400
|
-
if (r)
|
|
401
|
-
a = u.resolve(u.dirname(r), t);
|
|
402
|
-
else if (n)
|
|
403
|
-
a = u.resolve(n, t);
|
|
404
|
-
else
|
|
405
|
-
throw d({
|
|
406
|
-
code: "parse_error",
|
|
407
|
-
path: i,
|
|
408
|
-
details: { message: "root is required for relative template paths" }
|
|
409
|
-
});
|
|
410
|
-
else if (u.isAbsolute(t))
|
|
411
|
-
a = u.resolve(t);
|
|
412
|
-
else if (n)
|
|
413
|
-
a = u.resolve(n, t);
|
|
414
|
-
else
|
|
415
|
-
throw d({
|
|
416
|
-
code: "parse_error",
|
|
417
|
-
path: i,
|
|
418
|
-
details: { message: "root is required for relative template paths" }
|
|
419
|
-
});
|
|
420
|
-
return n && s && gt(a, n, i), a;
|
|
421
|
-
}
|
|
422
|
-
async function wt(t) {
|
|
582
|
+
async function Nt(t) {
|
|
423
583
|
const e = t.registry.get(t.alias);
|
|
424
584
|
if (!e)
|
|
425
585
|
throw d({
|
|
@@ -429,24 +589,25 @@ async function wt(t) {
|
|
|
429
589
|
message: `unregistered component: ${t.alias}`
|
|
430
590
|
}
|
|
431
591
|
});
|
|
432
|
-
const n =
|
|
592
|
+
const n = N(e.componentPath) ? e.componentPath : Z(e.componentPath, {
|
|
433
593
|
rootDir: t.rootDir,
|
|
434
594
|
fromPath: e.definedAt,
|
|
435
595
|
documentPath: t.path,
|
|
436
596
|
constrainToRoot: t.constrainToRoot,
|
|
437
597
|
hyogenPath: !0
|
|
438
|
-
}), r = await t.loader(n), { context: i, body: s } =
|
|
598
|
+
}), r = await t.loader(n), { context: i, body: s } = q(r, n), o = Ot(i, n), { values: a, warnings: c } = Ht(
|
|
439
599
|
t.props,
|
|
440
600
|
o,
|
|
441
601
|
t.alias
|
|
442
602
|
);
|
|
443
603
|
t.warnings.push(...c);
|
|
444
|
-
const { props: h, ...l } = i,
|
|
604
|
+
const { props: h, ...l } = i, u = v(
|
|
445
605
|
t.parentContext,
|
|
446
606
|
l,
|
|
447
607
|
a
|
|
448
|
-
)
|
|
449
|
-
|
|
608
|
+
);
|
|
609
|
+
return (await we(s, {
|
|
610
|
+
context: u,
|
|
450
611
|
loader: t.loader,
|
|
451
612
|
root: t.rootDir,
|
|
452
613
|
path: n,
|
|
@@ -458,26 +619,18 @@ async function wt(t) {
|
|
|
458
619
|
preserveHgComments: t.preserveHgComments,
|
|
459
620
|
constrainToRoot: t.constrainToRoot
|
|
460
621
|
})).trim();
|
|
461
|
-
if (g.includes(`
|
|
462
|
-
`))
|
|
463
|
-
throw d({
|
|
464
|
-
code: "component_multiline_output",
|
|
465
|
-
path: n,
|
|
466
|
-
details: { alias: t.alias }
|
|
467
|
-
});
|
|
468
|
-
return g;
|
|
469
622
|
}
|
|
470
|
-
const
|
|
623
|
+
const Dt = /* @__PURE__ */ new Set([
|
|
471
624
|
"__proto__",
|
|
472
625
|
"prototype",
|
|
473
626
|
"constructor",
|
|
474
627
|
"__defineGetter__"
|
|
475
628
|
]);
|
|
476
|
-
function
|
|
477
|
-
return
|
|
629
|
+
function Ft(t) {
|
|
630
|
+
return Dt.has(t);
|
|
478
631
|
}
|
|
479
|
-
function
|
|
480
|
-
if (
|
|
632
|
+
function ve(t, e) {
|
|
633
|
+
if (Ft(t))
|
|
481
634
|
throw d({
|
|
482
635
|
code: "forbidden_property_access",
|
|
483
636
|
path: e,
|
|
@@ -487,11 +640,15 @@ function ye(t, e) {
|
|
|
487
640
|
function R(t) {
|
|
488
641
|
return !t;
|
|
489
642
|
}
|
|
490
|
-
function
|
|
491
|
-
if (t != null
|
|
492
|
-
|
|
643
|
+
function jt(t, e) {
|
|
644
|
+
if (t != null) {
|
|
645
|
+
if (typeof t == "string")
|
|
646
|
+
return e === "length" ? t.length : void 0;
|
|
647
|
+
if (typeof t == "object")
|
|
648
|
+
return t[e];
|
|
649
|
+
}
|
|
493
650
|
}
|
|
494
|
-
function
|
|
651
|
+
function Bt(t, e, n) {
|
|
495
652
|
switch (t) {
|
|
496
653
|
case "+":
|
|
497
654
|
return e + n;
|
|
@@ -525,37 +682,37 @@ function bt(t, e, n) {
|
|
|
525
682
|
return;
|
|
526
683
|
}
|
|
527
684
|
}
|
|
528
|
-
async function
|
|
685
|
+
async function y(t, e) {
|
|
529
686
|
const { context: n, path: r } = e;
|
|
530
687
|
switch (t.type) {
|
|
531
688
|
case "literal":
|
|
532
689
|
return t.value;
|
|
533
690
|
case "identifier":
|
|
534
|
-
return
|
|
691
|
+
return ve(t.name, r), n[t.name];
|
|
535
692
|
case "member": {
|
|
536
|
-
|
|
537
|
-
const i = await
|
|
538
|
-
return
|
|
693
|
+
ve(t.property, r);
|
|
694
|
+
const i = await y(t.object, e);
|
|
695
|
+
return jt(i, t.property);
|
|
539
696
|
}
|
|
540
697
|
case "default": {
|
|
541
|
-
const i = await
|
|
542
|
-
return R(i) ?
|
|
698
|
+
const i = await y(t.left, e);
|
|
699
|
+
return R(i) ? y(t.right, e) : i;
|
|
543
700
|
}
|
|
544
701
|
case "unary": {
|
|
545
|
-
const i = await
|
|
702
|
+
const i = await y(t.operand, e);
|
|
546
703
|
return t.op === "!" ? !i : void 0;
|
|
547
704
|
}
|
|
548
705
|
case "binary": {
|
|
549
706
|
if (t.op === "&&") {
|
|
550
|
-
const o = await
|
|
551
|
-
return R(o) ? o :
|
|
707
|
+
const o = await y(t.left, e);
|
|
708
|
+
return R(o) ? o : y(t.right, e);
|
|
552
709
|
}
|
|
553
710
|
if (t.op === "||") {
|
|
554
|
-
const o = await
|
|
555
|
-
return R(o) ?
|
|
711
|
+
const o = await y(t.left, e);
|
|
712
|
+
return R(o) ? y(t.right, e) : o;
|
|
556
713
|
}
|
|
557
|
-
const i = await
|
|
558
|
-
return
|
|
714
|
+
const i = await y(t.left, e), s = await y(t.right, e);
|
|
715
|
+
return Bt(t.op, i, s);
|
|
559
716
|
}
|
|
560
717
|
case "call": {
|
|
561
718
|
if (!e.registry || !e.loader || !e.visitStack)
|
|
@@ -576,8 +733,8 @@ async function k(t, e) {
|
|
|
576
733
|
});
|
|
577
734
|
const i = {};
|
|
578
735
|
for (const [s, o] of Object.entries(t.args))
|
|
579
|
-
i[s] = await
|
|
580
|
-
return
|
|
736
|
+
i[s] = await y(o, e);
|
|
737
|
+
return Nt({
|
|
581
738
|
alias: t.callee,
|
|
582
739
|
props: i,
|
|
583
740
|
parentContext: e.parentContext ?? n,
|
|
@@ -598,14 +755,14 @@ async function k(t, e) {
|
|
|
598
755
|
path: r,
|
|
599
756
|
details: { message: `unsupported method: ${t.method}()` }
|
|
600
757
|
});
|
|
601
|
-
const i = await
|
|
758
|
+
const i = await y(t.object, e);
|
|
602
759
|
return i == null || typeof i.toLocaleString != "function" ? void 0 : i.toLocaleString(
|
|
603
760
|
...t.args
|
|
604
761
|
);
|
|
605
762
|
}
|
|
606
763
|
case "ternary": {
|
|
607
|
-
const i = await
|
|
608
|
-
return R(i) ?
|
|
764
|
+
const i = await y(t.condition, e);
|
|
765
|
+
return R(i) ? y(t.alternate, e) : y(t.consequent, e);
|
|
609
766
|
}
|
|
610
767
|
case "template": {
|
|
611
768
|
let i = "";
|
|
@@ -613,7 +770,7 @@ async function k(t, e) {
|
|
|
613
770
|
if (typeof s == "string")
|
|
614
771
|
i += s;
|
|
615
772
|
else {
|
|
616
|
-
const o = await
|
|
773
|
+
const o = await y(s, e);
|
|
617
774
|
o != null && (i += String(o));
|
|
618
775
|
}
|
|
619
776
|
return i;
|
|
@@ -622,17 +779,17 @@ async function k(t, e) {
|
|
|
622
779
|
return;
|
|
623
780
|
}
|
|
624
781
|
}
|
|
625
|
-
function
|
|
782
|
+
function J(t) {
|
|
626
783
|
return /[A-Za-z_$]/.test(t);
|
|
627
784
|
}
|
|
628
|
-
function
|
|
785
|
+
function It(t) {
|
|
629
786
|
return /[A-Za-z0-9_$]/.test(t);
|
|
630
787
|
}
|
|
631
788
|
function S(t, e, n = {}) {
|
|
632
789
|
const r = t.trim();
|
|
633
790
|
if (r.length === 0)
|
|
634
791
|
throw m(e, "empty expression");
|
|
635
|
-
const i = new
|
|
792
|
+
const i = new Ut(r, e, n), s = i.parseExpression();
|
|
636
793
|
if (i.skipWhitespace(), i.hasMore())
|
|
637
794
|
throw m(e, `unexpected token at position ${i.position}`);
|
|
638
795
|
return s;
|
|
@@ -644,7 +801,7 @@ function m(t, e) {
|
|
|
644
801
|
details: { message: e }
|
|
645
802
|
});
|
|
646
803
|
}
|
|
647
|
-
class
|
|
804
|
+
class Ut {
|
|
648
805
|
constructor(e, n, r = {}) {
|
|
649
806
|
this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
|
|
650
807
|
}
|
|
@@ -815,7 +972,7 @@ class _t {
|
|
|
815
972
|
return { type: "literal", value: this.parseObjectLiteral() };
|
|
816
973
|
if (e === "[")
|
|
817
974
|
return { type: "literal", value: this.parseArrayLiteral() };
|
|
818
|
-
if (
|
|
975
|
+
if (J(e)) {
|
|
819
976
|
const n = this.readIdentifier();
|
|
820
977
|
if (n === "true" || n === "false" || n === "null" || n === "undefined")
|
|
821
978
|
return { type: "literal", value: n === "true" ? !0 : n === "false" ? !1 : n === "null" ? null : void 0 };
|
|
@@ -992,7 +1149,7 @@ class _t {
|
|
|
992
1149
|
return this.parseObjectLiteral();
|
|
993
1150
|
if (e === "[")
|
|
994
1151
|
return this.parseArrayLiteral();
|
|
995
|
-
if (
|
|
1152
|
+
if (J(e)) {
|
|
996
1153
|
const n = this.readIdentifier();
|
|
997
1154
|
if (n === "true") return !0;
|
|
998
1155
|
if (n === "false") return !1;
|
|
@@ -1010,9 +1167,9 @@ class _t {
|
|
|
1010
1167
|
readIdentifier() {
|
|
1011
1168
|
this.skipWhitespace();
|
|
1012
1169
|
const e = this.index;
|
|
1013
|
-
if (!
|
|
1170
|
+
if (!J(this.peek()))
|
|
1014
1171
|
return "";
|
|
1015
|
-
for (this.index++; this.index < this.input.length &&
|
|
1172
|
+
for (this.index++; this.index < this.input.length && It(this.peek()); )
|
|
1016
1173
|
this.index++;
|
|
1017
1174
|
return this.input.slice(e, this.index);
|
|
1018
1175
|
}
|
|
@@ -1045,7 +1202,136 @@ class _t {
|
|
|
1045
1202
|
return r;
|
|
1046
1203
|
}
|
|
1047
1204
|
}
|
|
1048
|
-
|
|
1205
|
+
const zt = /^( {0,3})(=+|-+)[ \t]*$/, Fe = /^( {0,3})(`{3,}|~{3,})(.*)$/;
|
|
1206
|
+
function O(t) {
|
|
1207
|
+
return t === " " || t === " ";
|
|
1208
|
+
}
|
|
1209
|
+
function je(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 Be() {
|
|
1243
|
+
return { active: !1, marker: null, length: 0 };
|
|
1244
|
+
}
|
|
1245
|
+
function Ie(t, e) {
|
|
1246
|
+
const n = Fe.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 = je(t);
|
|
1262
|
+
return e ? e.level : null;
|
|
1263
|
+
}
|
|
1264
|
+
function ze(t) {
|
|
1265
|
+
const e = zt.exec(t);
|
|
1266
|
+
return e ? e[2][0] === "=" ? 1 : 2 : null;
|
|
1267
|
+
}
|
|
1268
|
+
function Vt(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 !(Vt(t) || Ue(t) !== null || Fe.test(t) || t.startsWith(" ") || t.startsWith(" "));
|
|
1276
|
+
}
|
|
1277
|
+
function Ze(t) {
|
|
1278
|
+
const e = t.split(`
|
|
1279
|
+
`), n = Be();
|
|
1280
|
+
let r = 0;
|
|
1281
|
+
for (let i = 0; i < e.length; i++) {
|
|
1282
|
+
const s = e[i];
|
|
1283
|
+
if (Ie(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 Zt(t) {
|
|
1299
|
+
return t < 1 ? 1 : t > 6 ? 6 : t;
|
|
1300
|
+
}
|
|
1301
|
+
function _e(t, e) {
|
|
1302
|
+
const n = e.trim(), r = "#".repeat(Zt(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 = Be(), i = [];
|
|
1310
|
+
for (let s = 0; s < n.length; s++) {
|
|
1311
|
+
const o = n[s];
|
|
1312
|
+
if (Ie(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] = _e(a + e, h);
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
const c = je(o);
|
|
1325
|
+
if (c !== null) {
|
|
1326
|
+
i.push(c.indent + _e(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 = {}) {
|
|
1049
1335
|
const r = n.path;
|
|
1050
1336
|
let i = "", s = 0;
|
|
1051
1337
|
for (; s < t.length; ) {
|
|
@@ -1060,24 +1346,29 @@ async function Me(t, e, n = {}) {
|
|
|
1060
1346
|
i += "{", s = o + 1;
|
|
1061
1347
|
continue;
|
|
1062
1348
|
}
|
|
1063
|
-
const h = a ? 3 : 2, l = a ? "}}}" : "}}",
|
|
1064
|
-
if (
|
|
1349
|
+
const h = a ? 3 : 2, l = a ? "}}}" : "}}", u = t.indexOf(l, o + h);
|
|
1350
|
+
if (u === -1)
|
|
1065
1351
|
throw d({
|
|
1066
1352
|
code: "parse_error",
|
|
1067
1353
|
path: r,
|
|
1068
1354
|
details: { message: "unclosed expression" }
|
|
1069
1355
|
});
|
|
1070
|
-
const
|
|
1356
|
+
const g = t.slice(o + h, u).trim(), w = S(g, r), p = await y(w, {
|
|
1071
1357
|
...n,
|
|
1072
1358
|
context: e,
|
|
1073
1359
|
path: r,
|
|
1074
1360
|
parentContext: n.parentContext ?? e
|
|
1075
1361
|
});
|
|
1076
|
-
|
|
1362
|
+
let x = p == null ? "" : String(p);
|
|
1363
|
+
if (w.type === "call" && x.length > 0) {
|
|
1364
|
+
const $ = Ze(i);
|
|
1365
|
+
x = qe(x, $);
|
|
1366
|
+
}
|
|
1367
|
+
i += x, s = u + l.length;
|
|
1077
1368
|
}
|
|
1078
1369
|
return i;
|
|
1079
1370
|
}
|
|
1080
|
-
function
|
|
1371
|
+
function qt(t, e) {
|
|
1081
1372
|
let n = 0, r = 0;
|
|
1082
1373
|
for (; r < t.length; ) {
|
|
1083
1374
|
const i = t.indexOf(e, r);
|
|
@@ -1087,14 +1378,14 @@ function St(t, e) {
|
|
|
1087
1378
|
}
|
|
1088
1379
|
return n;
|
|
1089
1380
|
}
|
|
1090
|
-
function
|
|
1091
|
-
const e = t.includes("@hg"), n = t.includes("@endhg"), r =
|
|
1381
|
+
function oe(t) {
|
|
1382
|
+
const e = t.includes("@hg"), n = t.includes("@endhg"), r = qt(t, "@@");
|
|
1092
1383
|
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";
|
|
1093
1384
|
}
|
|
1094
|
-
function
|
|
1385
|
+
function ae(t) {
|
|
1095
1386
|
return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
|
|
1096
1387
|
}
|
|
1097
|
-
function
|
|
1388
|
+
function ce(t, e) {
|
|
1098
1389
|
let n = 0, r = !1;
|
|
1099
1390
|
for (; n < e; ) {
|
|
1100
1391
|
const i = t.indexOf("```", n);
|
|
@@ -1104,21 +1395,21 @@ function ae(t, e) {
|
|
|
1104
1395
|
}
|
|
1105
1396
|
return r;
|
|
1106
1397
|
}
|
|
1107
|
-
function
|
|
1398
|
+
function W(t) {
|
|
1108
1399
|
const e = [];
|
|
1109
1400
|
let n = 0;
|
|
1110
1401
|
for (; n < t.length; ) {
|
|
1111
1402
|
const r = t.indexOf("<!--", n);
|
|
1112
1403
|
if (r === -1)
|
|
1113
1404
|
break;
|
|
1114
|
-
if (
|
|
1405
|
+
if (ce(t, r)) {
|
|
1115
1406
|
n = r + 4;
|
|
1116
1407
|
continue;
|
|
1117
1408
|
}
|
|
1118
1409
|
const i = t.indexOf("-->", r + 4);
|
|
1119
1410
|
if (i === -1)
|
|
1120
1411
|
break;
|
|
1121
|
-
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a =
|
|
1412
|
+
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = oe(o);
|
|
1122
1413
|
(a === "hg" || a === "at-at") && e.push({
|
|
1123
1414
|
start: r,
|
|
1124
1415
|
end: i + 3,
|
|
@@ -1128,20 +1419,20 @@ function C(t) {
|
|
|
1128
1419
|
}
|
|
1129
1420
|
return e;
|
|
1130
1421
|
}
|
|
1131
|
-
function
|
|
1422
|
+
function le(t) {
|
|
1132
1423
|
let e = 0;
|
|
1133
1424
|
for (; e < t.length; ) {
|
|
1134
1425
|
const n = t.indexOf("<!--", e);
|
|
1135
1426
|
if (n === -1)
|
|
1136
1427
|
return !1;
|
|
1137
|
-
if (
|
|
1428
|
+
if (ce(t, n)) {
|
|
1138
1429
|
e = n + 4;
|
|
1139
1430
|
continue;
|
|
1140
1431
|
}
|
|
1141
1432
|
const r = t.indexOf("-->", n + 4);
|
|
1142
1433
|
if (r === -1)
|
|
1143
1434
|
return !1;
|
|
1144
|
-
const i = t.slice(n + 4, r), s =
|
|
1435
|
+
const i = t.slice(n + 4, r), s = oe(i);
|
|
1145
1436
|
if (s === "unclosed" || s === "mixed")
|
|
1146
1437
|
return !0;
|
|
1147
1438
|
e = r + 3;
|
|
@@ -1154,14 +1445,14 @@ function he(t) {
|
|
|
1154
1445
|
const n = t.indexOf("<!--", e);
|
|
1155
1446
|
if (n === -1)
|
|
1156
1447
|
return null;
|
|
1157
|
-
if (
|
|
1448
|
+
if (ce(t, n)) {
|
|
1158
1449
|
e = n + 4;
|
|
1159
1450
|
continue;
|
|
1160
1451
|
}
|
|
1161
1452
|
const r = t.indexOf("-->", n + 4);
|
|
1162
1453
|
if (r === -1)
|
|
1163
1454
|
return null;
|
|
1164
|
-
const i = t.slice(n + 4, r), s =
|
|
1455
|
+
const i = t.slice(n + 4, r), s = oe(i);
|
|
1165
1456
|
if (s === "mixed")
|
|
1166
1457
|
return "mixed @hg and @@ markers are not allowed";
|
|
1167
1458
|
if (s === "unclosed")
|
|
@@ -1170,25 +1461,25 @@ function he(t) {
|
|
|
1170
1461
|
}
|
|
1171
1462
|
return null;
|
|
1172
1463
|
}
|
|
1173
|
-
function
|
|
1174
|
-
return
|
|
1464
|
+
function C(t) {
|
|
1465
|
+
return ae(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
|
|
1175
1466
|
}
|
|
1176
|
-
const
|
|
1177
|
-
function
|
|
1178
|
-
return
|
|
1467
|
+
const Pt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
|
|
1468
|
+
function de(t) {
|
|
1469
|
+
return Pt.test(t.trim());
|
|
1179
1470
|
}
|
|
1180
|
-
function
|
|
1471
|
+
function Q(t, e) {
|
|
1181
1472
|
throw d({
|
|
1182
1473
|
code: "parse_error",
|
|
1183
1474
|
path: t,
|
|
1184
1475
|
details: { message: e }
|
|
1185
1476
|
});
|
|
1186
1477
|
}
|
|
1187
|
-
function
|
|
1478
|
+
function Kt(t, e) {
|
|
1188
1479
|
let n = t;
|
|
1189
1480
|
const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
|
|
1190
1481
|
r && (n = r[1]);
|
|
1191
|
-
const i =
|
|
1482
|
+
const i = C(n);
|
|
1192
1483
|
if (i.length !== 1)
|
|
1193
1484
|
return null;
|
|
1194
1485
|
const s = i[0];
|
|
@@ -1201,7 +1492,7 @@ function Et(t, e) {
|
|
|
1201
1492
|
if (s === "endeach")
|
|
1202
1493
|
return { kind: "endeach" };
|
|
1203
1494
|
if (/^IF\b/.test(s) || /^ELSE\b/.test(s) || /^ENDIF\b/.test(s))
|
|
1204
|
-
throw
|
|
1495
|
+
throw Q(e, "control keywords must be lowercase");
|
|
1205
1496
|
const o = /^else\s+if\s+(.+)$/.exec(s);
|
|
1206
1497
|
if (o)
|
|
1207
1498
|
return {
|
|
@@ -1222,25 +1513,25 @@ function Et(t, e) {
|
|
|
1222
1513
|
expr: S(c[2], e)
|
|
1223
1514
|
};
|
|
1224
1515
|
if (s === "if")
|
|
1225
|
-
throw
|
|
1516
|
+
throw Q(e, "if requires an expression");
|
|
1226
1517
|
if (/^each\s+/.test(s))
|
|
1227
|
-
throw
|
|
1518
|
+
throw Q(e, "invalid each directive");
|
|
1228
1519
|
return null;
|
|
1229
1520
|
}
|
|
1230
1521
|
function M(t) {
|
|
1231
1522
|
return { start: t.start, end: t.end, raw: t.raw };
|
|
1232
1523
|
}
|
|
1233
|
-
function
|
|
1524
|
+
function E(t, e) {
|
|
1234
1525
|
throw d({
|
|
1235
1526
|
code: "parse_error",
|
|
1236
1527
|
path: t,
|
|
1237
1528
|
details: { message: e }
|
|
1238
1529
|
});
|
|
1239
1530
|
}
|
|
1240
|
-
function
|
|
1531
|
+
function Yt(t, e) {
|
|
1241
1532
|
const n = [];
|
|
1242
|
-
for (const r of
|
|
1243
|
-
const i =
|
|
1533
|
+
for (const r of W(t)) {
|
|
1534
|
+
const i = Kt(r.inner, e);
|
|
1244
1535
|
i && n.push({
|
|
1245
1536
|
start: r.start,
|
|
1246
1537
|
end: r.end,
|
|
@@ -1250,70 +1541,70 @@ function Wt(t, e) {
|
|
|
1250
1541
|
}
|
|
1251
1542
|
return n;
|
|
1252
1543
|
}
|
|
1253
|
-
function
|
|
1544
|
+
function Ke(t) {
|
|
1254
1545
|
return t.kind === "if" || t.kind === "each";
|
|
1255
1546
|
}
|
|
1256
|
-
function
|
|
1257
|
-
const n =
|
|
1547
|
+
function Xt(t, e) {
|
|
1548
|
+
const n = Yt(t, e);
|
|
1258
1549
|
if (n.length === 0)
|
|
1259
1550
|
return t.length > 0 ? [{ kind: "text", content: t }] : [];
|
|
1260
|
-
const { nodes: r, nextIndex: i } =
|
|
1551
|
+
const { nodes: r, nextIndex: i } = j(t, n, 0, n.length, e);
|
|
1261
1552
|
if (i < n.length) {
|
|
1262
1553
|
const s = n[i];
|
|
1263
1554
|
if (s.opener.kind === "endif")
|
|
1264
|
-
throw
|
|
1555
|
+
throw E(e, "endif without matching if");
|
|
1265
1556
|
if (s.opener.kind === "endeach")
|
|
1266
|
-
throw
|
|
1557
|
+
throw E(e, "endeach without matching each");
|
|
1267
1558
|
if (s.opener.kind === "else" || s.opener.kind === "else_if")
|
|
1268
|
-
throw
|
|
1559
|
+
throw E(e, "else without matching if");
|
|
1269
1560
|
}
|
|
1270
1561
|
return r;
|
|
1271
1562
|
}
|
|
1272
|
-
function
|
|
1563
|
+
function j(t, e, n, r, i, s = 0, o) {
|
|
1273
1564
|
const a = o ?? t.length, c = [];
|
|
1274
1565
|
let h = s, l = n;
|
|
1275
1566
|
for (; l < r; ) {
|
|
1276
|
-
const
|
|
1277
|
-
if (
|
|
1567
|
+
const u = e[l];
|
|
1568
|
+
if (u.start >= a)
|
|
1278
1569
|
break;
|
|
1279
|
-
if (
|
|
1570
|
+
if (u.end <= s) {
|
|
1280
1571
|
l++;
|
|
1281
1572
|
continue;
|
|
1282
1573
|
}
|
|
1283
|
-
if (
|
|
1574
|
+
if (u.start > h && c.push({
|
|
1284
1575
|
kind: "text",
|
|
1285
|
-
content: t.slice(h,
|
|
1286
|
-
}),
|
|
1287
|
-
const
|
|
1288
|
-
c.push(
|
|
1576
|
+
content: t.slice(h, u.start)
|
|
1577
|
+
}), u.opener.kind === "if") {
|
|
1578
|
+
const g = Gt(t, e, l, r, i);
|
|
1579
|
+
c.push(g.node), h = g.endPos, l = g.nextIndex;
|
|
1289
1580
|
continue;
|
|
1290
1581
|
}
|
|
1291
|
-
if (
|
|
1292
|
-
const
|
|
1293
|
-
c.push(
|
|
1582
|
+
if (u.opener.kind === "each") {
|
|
1583
|
+
const g = Jt(t, e, l, r, i);
|
|
1584
|
+
c.push(g.node), h = g.endPos, l = g.nextIndex;
|
|
1294
1585
|
continue;
|
|
1295
1586
|
}
|
|
1296
|
-
if (
|
|
1297
|
-
throw
|
|
1298
|
-
if (
|
|
1299
|
-
throw
|
|
1300
|
-
if (
|
|
1301
|
-
throw
|
|
1587
|
+
if (u.opener.kind === "else" || u.opener.kind === "else_if")
|
|
1588
|
+
throw E(i, "else without matching if");
|
|
1589
|
+
if (u.opener.kind === "endif")
|
|
1590
|
+
throw E(i, "endif without matching if");
|
|
1591
|
+
if (u.opener.kind === "endeach")
|
|
1592
|
+
throw E(i, "endeach without matching each");
|
|
1302
1593
|
l++;
|
|
1303
1594
|
}
|
|
1304
1595
|
return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
|
|
1305
1596
|
}
|
|
1306
|
-
function
|
|
1597
|
+
function Gt(t, e, n, r, i) {
|
|
1307
1598
|
const s = e[n];
|
|
1308
1599
|
if (s.opener.kind !== "if")
|
|
1309
|
-
throw
|
|
1600
|
+
throw E(i, "expected if");
|
|
1310
1601
|
const o = [];
|
|
1311
1602
|
let a = n, c = s.end, h = 0;
|
|
1312
1603
|
for (; a < r; ) {
|
|
1313
1604
|
const l = e[a];
|
|
1314
1605
|
if (a === n) {
|
|
1315
1606
|
if (l.opener.kind !== "if")
|
|
1316
|
-
throw
|
|
1607
|
+
throw E(i, "expected if");
|
|
1317
1608
|
o.push({
|
|
1318
1609
|
kind: "if",
|
|
1319
1610
|
expr: l.opener.expr,
|
|
@@ -1322,13 +1613,13 @@ function Tt(t, e, n, r, i) {
|
|
|
1322
1613
|
}), a++;
|
|
1323
1614
|
continue;
|
|
1324
1615
|
}
|
|
1325
|
-
if (
|
|
1616
|
+
if (Ke(l.opener)) {
|
|
1326
1617
|
h++, a++;
|
|
1327
1618
|
continue;
|
|
1328
1619
|
}
|
|
1329
1620
|
if (l.opener.kind === "endif") {
|
|
1330
1621
|
if (h === 0)
|
|
1331
|
-
return o[o.length - 1].body =
|
|
1622
|
+
return o[o.length - 1].body = j(
|
|
1332
1623
|
t,
|
|
1333
1624
|
e,
|
|
1334
1625
|
n + 1,
|
|
@@ -1350,7 +1641,7 @@ function Tt(t, e, n, r, i) {
|
|
|
1350
1641
|
}
|
|
1351
1642
|
if (h === 0) {
|
|
1352
1643
|
if (l.opener.kind === "else_if") {
|
|
1353
|
-
o[o.length - 1].body =
|
|
1644
|
+
o[o.length - 1].body = j(
|
|
1354
1645
|
t,
|
|
1355
1646
|
e,
|
|
1356
1647
|
n + 1,
|
|
@@ -1367,7 +1658,7 @@ function Tt(t, e, n, r, i) {
|
|
|
1367
1658
|
continue;
|
|
1368
1659
|
}
|
|
1369
1660
|
if (l.opener.kind === "else") {
|
|
1370
|
-
o[o.length - 1].body =
|
|
1661
|
+
o[o.length - 1].body = j(
|
|
1371
1662
|
t,
|
|
1372
1663
|
e,
|
|
1373
1664
|
n + 1,
|
|
@@ -1385,24 +1676,24 @@ function Tt(t, e, n, r, i) {
|
|
|
1385
1676
|
}
|
|
1386
1677
|
a++;
|
|
1387
1678
|
}
|
|
1388
|
-
throw
|
|
1679
|
+
throw E(i, "unclosed if block (missing endif)");
|
|
1389
1680
|
}
|
|
1390
|
-
function
|
|
1681
|
+
function Jt(t, e, n, r, i) {
|
|
1391
1682
|
const s = e[n];
|
|
1392
1683
|
if (s.opener.kind !== "each")
|
|
1393
|
-
throw
|
|
1684
|
+
throw E(i, "expected each");
|
|
1394
1685
|
let o = n + 1;
|
|
1395
1686
|
const a = s.end;
|
|
1396
1687
|
let c = 0;
|
|
1397
1688
|
for (; o < r; ) {
|
|
1398
1689
|
const h = e[o];
|
|
1399
|
-
if (
|
|
1690
|
+
if (Ke(h.opener)) {
|
|
1400
1691
|
c++, o++;
|
|
1401
1692
|
continue;
|
|
1402
1693
|
}
|
|
1403
1694
|
if (h.opener.kind === "endeach") {
|
|
1404
1695
|
if (c === 0) {
|
|
1405
|
-
const l =
|
|
1696
|
+
const l = j(
|
|
1406
1697
|
t,
|
|
1407
1698
|
e,
|
|
1408
1699
|
n + 1,
|
|
@@ -1433,28 +1724,28 @@ function At(t, e, n, r, i) {
|
|
|
1433
1724
|
}
|
|
1434
1725
|
o++;
|
|
1435
1726
|
}
|
|
1436
|
-
throw
|
|
1727
|
+
throw E(i, "unclosed each block (missing endeach)");
|
|
1437
1728
|
}
|
|
1438
|
-
const
|
|
1439
|
-
class
|
|
1729
|
+
const Se = 20;
|
|
1730
|
+
class Qt {
|
|
1440
1731
|
depth = 0;
|
|
1441
1732
|
get currentDepth() {
|
|
1442
1733
|
return this.depth;
|
|
1443
1734
|
}
|
|
1444
1735
|
enter() {
|
|
1445
|
-
return this.depth >=
|
|
1736
|
+
return this.depth >= Se ? { exceeded: !0, limit: Se } : (this.depth++, { exceeded: !1, depth: this.depth });
|
|
1446
1737
|
}
|
|
1447
1738
|
exit() {
|
|
1448
1739
|
this.depth > 0 && this.depth--;
|
|
1449
1740
|
}
|
|
1450
1741
|
}
|
|
1451
|
-
function
|
|
1742
|
+
function en(t) {
|
|
1452
1743
|
return !!t;
|
|
1453
1744
|
}
|
|
1454
|
-
function
|
|
1745
|
+
function tn(t) {
|
|
1455
1746
|
return t != null && typeof t[Symbol.iterator] == "function";
|
|
1456
1747
|
}
|
|
1457
|
-
function
|
|
1748
|
+
function Ye(t) {
|
|
1458
1749
|
return {
|
|
1459
1750
|
code: "nest_limit_exceeded",
|
|
1460
1751
|
message: "structure nest limit exceeded",
|
|
@@ -1462,38 +1753,38 @@ function Le(t) {
|
|
|
1462
1753
|
details: { limit: 20 }
|
|
1463
1754
|
};
|
|
1464
1755
|
}
|
|
1465
|
-
function
|
|
1756
|
+
function ue(t) {
|
|
1466
1757
|
return t.startsWith(`
|
|
1467
1758
|
`) ? t.slice(1) : t;
|
|
1468
1759
|
}
|
|
1469
|
-
async function
|
|
1470
|
-
const n = e.path, r = e.warnings ?? [], i =
|
|
1471
|
-
return
|
|
1760
|
+
async function nn(t, e) {
|
|
1761
|
+
const n = e.path, r = e.warnings ?? [], i = Xt(t, n), s = new Qt();
|
|
1762
|
+
return fe(i, e, s, r);
|
|
1472
1763
|
}
|
|
1473
|
-
async function
|
|
1764
|
+
async function fe(t, e, n, r) {
|
|
1474
1765
|
const i = e.preserveHgComments === !0;
|
|
1475
1766
|
let s = "", o = !1;
|
|
1476
1767
|
for (const a of t) {
|
|
1477
|
-
let c = await
|
|
1478
|
-
o && (c =
|
|
1768
|
+
let c = await rn(a, e, n, r);
|
|
1769
|
+
o && (c = ue(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
|
|
1479
1770
|
}
|
|
1480
1771
|
return s;
|
|
1481
1772
|
}
|
|
1482
|
-
async function
|
|
1773
|
+
async function rn(t, e, n, r) {
|
|
1483
1774
|
switch (t.kind) {
|
|
1484
1775
|
case "text":
|
|
1485
1776
|
return t.content;
|
|
1486
1777
|
case "if":
|
|
1487
|
-
return
|
|
1778
|
+
return sn(t, e, n, r);
|
|
1488
1779
|
case "each":
|
|
1489
|
-
return
|
|
1780
|
+
return on(t, e, n, r);
|
|
1490
1781
|
default:
|
|
1491
1782
|
return "";
|
|
1492
1783
|
}
|
|
1493
1784
|
}
|
|
1494
|
-
async function
|
|
1785
|
+
async function sn(t, e, n, r) {
|
|
1495
1786
|
if (n.enter().exceeded)
|
|
1496
|
-
return r.push(
|
|
1787
|
+
return r.push(Ye(e.path)), "";
|
|
1497
1788
|
try {
|
|
1498
1789
|
let s = -1;
|
|
1499
1790
|
for (let c = 0; c < t.branches.length; c++) {
|
|
@@ -1502,8 +1793,8 @@ async function Nt(t, e, n, r) {
|
|
|
1502
1793
|
s = c;
|
|
1503
1794
|
break;
|
|
1504
1795
|
}
|
|
1505
|
-
const l = await
|
|
1506
|
-
if (
|
|
1796
|
+
const l = await y(h.expr, e);
|
|
1797
|
+
if (en(l)) {
|
|
1507
1798
|
s = c;
|
|
1508
1799
|
break;
|
|
1509
1800
|
}
|
|
@@ -1513,8 +1804,8 @@ async function Nt(t, e, n, r) {
|
|
|
1513
1804
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1514
1805
|
const h = t.branches[c];
|
|
1515
1806
|
if (o && (a += h.opener.raw), c === s) {
|
|
1516
|
-
let l = await
|
|
1517
|
-
o || (l =
|
|
1807
|
+
let l = await fe(h.body, e, n, r);
|
|
1808
|
+
o || (l = ue(l)), a += l;
|
|
1518
1809
|
}
|
|
1519
1810
|
}
|
|
1520
1811
|
return o && (a += t.closer.raw), a;
|
|
@@ -1522,24 +1813,24 @@ async function Nt(t, e, n, r) {
|
|
|
1522
1813
|
n.exit();
|
|
1523
1814
|
}
|
|
1524
1815
|
}
|
|
1525
|
-
async function
|
|
1816
|
+
async function on(t, e, n, r) {
|
|
1526
1817
|
if (n.enter().exceeded)
|
|
1527
|
-
return r.push(
|
|
1818
|
+
return r.push(Ye(e.path)), "";
|
|
1528
1819
|
try {
|
|
1529
|
-
const s = await
|
|
1530
|
-
if (!
|
|
1820
|
+
const s = await y(t.expr, e);
|
|
1821
|
+
if (!tn(s))
|
|
1531
1822
|
return "";
|
|
1532
1823
|
const o = e.preserveHgComments === !0;
|
|
1533
1824
|
let a = "";
|
|
1534
1825
|
for (const c of s) {
|
|
1535
1826
|
const h = { ...e.context, [t.item]: c };
|
|
1536
1827
|
o && (a += t.opener.raw);
|
|
1537
|
-
let l = await
|
|
1828
|
+
let l = await fe(t.body, {
|
|
1538
1829
|
...e,
|
|
1539
1830
|
context: h
|
|
1540
1831
|
}, n, r);
|
|
1541
|
-
o || (l =
|
|
1542
|
-
const
|
|
1832
|
+
o || (l = ue(l));
|
|
1833
|
+
const u = await Pe(l, h, {
|
|
1543
1834
|
path: e.path,
|
|
1544
1835
|
registry: e.registry,
|
|
1545
1836
|
loader: e.loader,
|
|
@@ -1550,15 +1841,15 @@ async function Ht(t, e, n, r) {
|
|
|
1550
1841
|
preserveHgComments: e.preserveHgComments,
|
|
1551
1842
|
constrainToRoot: e.constrainToRoot
|
|
1552
1843
|
});
|
|
1553
|
-
a +=
|
|
1844
|
+
a += u, o && (a += t.closer.raw);
|
|
1554
1845
|
}
|
|
1555
1846
|
return a;
|
|
1556
1847
|
} finally {
|
|
1557
1848
|
n.exit();
|
|
1558
1849
|
}
|
|
1559
1850
|
}
|
|
1560
|
-
function
|
|
1561
|
-
return
|
|
1851
|
+
function te(t, e, n, r, i = !1, s = !1) {
|
|
1852
|
+
return N(e) ? e : Z(e, {
|
|
1562
1853
|
rootDir: t,
|
|
1563
1854
|
fromPath: r,
|
|
1564
1855
|
documentPath: n,
|
|
@@ -1566,40 +1857,40 @@ function Q(t, e, n, r, i = !1, s = !1) {
|
|
|
1566
1857
|
hyogenPath: s
|
|
1567
1858
|
});
|
|
1568
1859
|
}
|
|
1569
|
-
function
|
|
1860
|
+
function Xe(t) {
|
|
1570
1861
|
let e = 0;
|
|
1571
1862
|
for (let n = t.length - 1; n >= 0 && t[n] === `
|
|
1572
1863
|
`; n--)
|
|
1573
1864
|
e++;
|
|
1574
1865
|
return e;
|
|
1575
1866
|
}
|
|
1576
|
-
function
|
|
1867
|
+
function Ge(t) {
|
|
1577
1868
|
let e = 0;
|
|
1578
1869
|
for (; e < t.length && t[e] === `
|
|
1579
1870
|
`; )
|
|
1580
1871
|
e++;
|
|
1581
1872
|
return e;
|
|
1582
1873
|
}
|
|
1583
|
-
function
|
|
1584
|
-
const n =
|
|
1874
|
+
function A(t, e) {
|
|
1875
|
+
const n = Xe(t), r = Ge(e), i = Math.max(n, r);
|
|
1585
1876
|
return t.slice(0, t.length - n) + `
|
|
1586
1877
|
`.repeat(i) + e.slice(r);
|
|
1587
1878
|
}
|
|
1588
|
-
function
|
|
1589
|
-
const n =
|
|
1879
|
+
function pe(t, e) {
|
|
1880
|
+
const n = Xe(t), r = Ge(e);
|
|
1590
1881
|
return n + r - Math.max(n, r);
|
|
1591
1882
|
}
|
|
1592
|
-
function
|
|
1883
|
+
function Ee(t, e, n) {
|
|
1593
1884
|
const r = t.indexOf(e);
|
|
1594
1885
|
if (r < 0)
|
|
1595
1886
|
return t;
|
|
1596
1887
|
const i = t.slice(0, r), s = t.slice(r + e.length);
|
|
1597
|
-
return
|
|
1888
|
+
return A(A(i, n), s);
|
|
1598
1889
|
}
|
|
1599
|
-
async function
|
|
1890
|
+
async function an(t) {
|
|
1600
1891
|
let e = t.source;
|
|
1601
1892
|
for (const n of t.directives) {
|
|
1602
|
-
const r =
|
|
1893
|
+
const r = te(
|
|
1603
1894
|
t.root,
|
|
1604
1895
|
n.path,
|
|
1605
1896
|
t.path,
|
|
@@ -1612,7 +1903,7 @@ async function jt(t) {
|
|
|
1612
1903
|
if (i.circular) {
|
|
1613
1904
|
t.warnings?.push({
|
|
1614
1905
|
code: "circular_include",
|
|
1615
|
-
message:
|
|
1906
|
+
message: H("circular_include", {
|
|
1616
1907
|
path: r,
|
|
1617
1908
|
from: i.from,
|
|
1618
1909
|
via: "include"
|
|
@@ -1623,13 +1914,13 @@ async function jt(t) {
|
|
|
1623
1914
|
from: i.from,
|
|
1624
1915
|
via: "include"
|
|
1625
1916
|
}
|
|
1626
|
-
}), e =
|
|
1917
|
+
}), e = Ee(e, n.marker, "");
|
|
1627
1918
|
continue;
|
|
1628
1919
|
}
|
|
1629
1920
|
t.visitStack.push(r);
|
|
1630
1921
|
}
|
|
1631
1922
|
try {
|
|
1632
|
-
const i = await t.loader(r), s = await
|
|
1923
|
+
const i = await t.loader(r), s = await Vn(i, {
|
|
1633
1924
|
context: t.context,
|
|
1634
1925
|
loader: t.loader,
|
|
1635
1926
|
root: t.root,
|
|
@@ -1639,16 +1930,16 @@ async function jt(t) {
|
|
|
1639
1930
|
visitStack: t.visitStack,
|
|
1640
1931
|
warnings: t.warnings,
|
|
1641
1932
|
registry: t.registry
|
|
1642
|
-
}), o = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1643
|
-
${
|
|
1644
|
-
e =
|
|
1933
|
+
}), o = e.indexOf(n.marker), a = o >= 0 ? e.slice(0, o) : e, c = Ze(a), h = qe(s, c), l = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1934
|
+
${h}` : h;
|
|
1935
|
+
e = Ee(e, n.marker, l);
|
|
1645
1936
|
} finally {
|
|
1646
1937
|
t.visitStack?.pop();
|
|
1647
1938
|
}
|
|
1648
1939
|
}
|
|
1649
1940
|
return e;
|
|
1650
1941
|
}
|
|
1651
|
-
class
|
|
1942
|
+
class Je {
|
|
1652
1943
|
stack = [];
|
|
1653
1944
|
check(e) {
|
|
1654
1945
|
return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
|
|
@@ -1664,8 +1955,8 @@ class He {
|
|
|
1664
1955
|
this.stack.pop();
|
|
1665
1956
|
}
|
|
1666
1957
|
}
|
|
1667
|
-
async function
|
|
1668
|
-
const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await
|
|
1958
|
+
async function cn(t, e, n = {}) {
|
|
1959
|
+
const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await y(t.expr, { context: e, path: r });
|
|
1669
1960
|
switch (t.kind) {
|
|
1670
1961
|
case "const": {
|
|
1671
1962
|
if (i.has(t.name))
|
|
@@ -1705,16 +1996,16 @@ async function Ft(t, e, n = {}) {
|
|
|
1705
1996
|
}
|
|
1706
1997
|
}
|
|
1707
1998
|
}
|
|
1708
|
-
function
|
|
1999
|
+
function Ce(t) {
|
|
1709
2000
|
return !t;
|
|
1710
2001
|
}
|
|
1711
|
-
async function
|
|
1712
|
-
const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s } = n;
|
|
2002
|
+
async function F(t, e, n = {}) {
|
|
2003
|
+
const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s, echoChunks: o } = n;
|
|
1713
2004
|
switch (t.kind) {
|
|
1714
2005
|
case "const":
|
|
1715
2006
|
case "let":
|
|
1716
2007
|
case "assign": {
|
|
1717
|
-
await
|
|
2008
|
+
await cn(t, e, { path: r, constBindings: i }), s?.(t.name);
|
|
1718
2009
|
return;
|
|
1719
2010
|
}
|
|
1720
2011
|
case "update": {
|
|
@@ -1734,8 +2025,8 @@ async function D(t, e, n = {}) {
|
|
|
1734
2025
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1735
2026
|
}
|
|
1736
2027
|
});
|
|
1737
|
-
const
|
|
1738
|
-
e[t.name] =
|
|
2028
|
+
const a = Number(e[t.name]), c = t.op === "++" ? a + 1 : a - 1;
|
|
2029
|
+
e[t.name] = c, s?.(t.name);
|
|
1739
2030
|
return;
|
|
1740
2031
|
}
|
|
1741
2032
|
case "compound_assign": {
|
|
@@ -1755,59 +2046,67 @@ async function D(t, e, n = {}) {
|
|
|
1755
2046
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1756
2047
|
}
|
|
1757
2048
|
});
|
|
1758
|
-
const
|
|
1759
|
-
let
|
|
2049
|
+
const a = await y(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
|
|
2050
|
+
let l;
|
|
1760
2051
|
switch (t.op) {
|
|
1761
2052
|
case "+=":
|
|
1762
|
-
|
|
2053
|
+
l = c + h;
|
|
1763
2054
|
break;
|
|
1764
2055
|
case "-=":
|
|
1765
|
-
|
|
2056
|
+
l = c - h;
|
|
1766
2057
|
break;
|
|
1767
2058
|
case "*=":
|
|
1768
|
-
|
|
2059
|
+
l = c * h;
|
|
1769
2060
|
break;
|
|
1770
2061
|
case "/=":
|
|
1771
|
-
|
|
2062
|
+
l = c / h;
|
|
1772
2063
|
break;
|
|
1773
2064
|
}
|
|
1774
|
-
e[t.name] =
|
|
2065
|
+
e[t.name] = l, s?.(t.name);
|
|
2066
|
+
return;
|
|
2067
|
+
}
|
|
2068
|
+
case "echo": {
|
|
2069
|
+
const a = await y(t.expr, {
|
|
2070
|
+
context: e,
|
|
2071
|
+
path: r
|
|
2072
|
+
}), c = a == null ? "" : String(a);
|
|
2073
|
+
o?.push(c);
|
|
1775
2074
|
return;
|
|
1776
2075
|
}
|
|
1777
2076
|
case "for": {
|
|
1778
|
-
for (t.init && await
|
|
1779
|
-
const
|
|
2077
|
+
for (t.init && await F(t.init, e, n); ; ) {
|
|
2078
|
+
const a = await y(t.cond, {
|
|
1780
2079
|
context: e,
|
|
1781
2080
|
path: r
|
|
1782
2081
|
});
|
|
1783
|
-
if (
|
|
2082
|
+
if (Ce(a))
|
|
1784
2083
|
break;
|
|
1785
|
-
for (const
|
|
1786
|
-
await
|
|
1787
|
-
t.update && await
|
|
2084
|
+
for (const c of t.body)
|
|
2085
|
+
await F(c, e, n);
|
|
2086
|
+
t.update && await F(t.update, e, n);
|
|
1788
2087
|
}
|
|
1789
2088
|
return;
|
|
1790
2089
|
}
|
|
1791
2090
|
case "do_while": {
|
|
1792
2091
|
do {
|
|
1793
|
-
for (const
|
|
1794
|
-
await
|
|
1795
|
-
const
|
|
2092
|
+
for (const c of t.body)
|
|
2093
|
+
await F(c, e, n);
|
|
2094
|
+
const a = await y(t.cond, {
|
|
1796
2095
|
context: e,
|
|
1797
2096
|
path: r
|
|
1798
2097
|
});
|
|
1799
|
-
if (
|
|
2098
|
+
if (Ce(a))
|
|
1800
2099
|
break;
|
|
1801
2100
|
} while (!0);
|
|
1802
2101
|
return;
|
|
1803
2102
|
}
|
|
1804
2103
|
}
|
|
1805
2104
|
}
|
|
1806
|
-
async function
|
|
2105
|
+
async function $e(t, e, n = {}) {
|
|
1807
2106
|
for (const r of t)
|
|
1808
|
-
await
|
|
2107
|
+
await F(r, e, n);
|
|
1809
2108
|
}
|
|
1810
|
-
const
|
|
2109
|
+
const ln = /* @__PURE__ */ new Set([
|
|
1811
2110
|
"if",
|
|
1812
2111
|
"else",
|
|
1813
2112
|
"endif",
|
|
@@ -1823,12 +2122,13 @@ const Bt = /* @__PURE__ */ new Set([
|
|
|
1823
2122
|
"extend",
|
|
1824
2123
|
"include",
|
|
1825
2124
|
"component",
|
|
1826
|
-
"as"
|
|
2125
|
+
"as",
|
|
2126
|
+
"echo"
|
|
1827
2127
|
]);
|
|
1828
|
-
function
|
|
1829
|
-
return
|
|
2128
|
+
function Qe(t) {
|
|
2129
|
+
return ln.has(t);
|
|
1830
2130
|
}
|
|
1831
|
-
function
|
|
2131
|
+
function me(t) {
|
|
1832
2132
|
let e = "", n = 0, r = null;
|
|
1833
2133
|
for (; n < t.length; ) {
|
|
1834
2134
|
const i = t[n];
|
|
@@ -1861,32 +2161,32 @@ function fe(t) {
|
|
|
1861
2161
|
}
|
|
1862
2162
|
return e;
|
|
1863
2163
|
}
|
|
1864
|
-
function
|
|
2164
|
+
function k(t, e) {
|
|
1865
2165
|
throw d({
|
|
1866
2166
|
code: "parse_error",
|
|
1867
2167
|
path: t,
|
|
1868
2168
|
details: { message: e }
|
|
1869
2169
|
});
|
|
1870
2170
|
}
|
|
1871
|
-
function
|
|
1872
|
-
const n =
|
|
2171
|
+
function We(t, e) {
|
|
2172
|
+
const n = me(t).trim();
|
|
1873
2173
|
if (n.length === 0)
|
|
1874
|
-
throw
|
|
1875
|
-
const r = new
|
|
2174
|
+
throw k(e, "empty statement block");
|
|
2175
|
+
const r = new ge(n, e), i = r.parseStatementList();
|
|
1876
2176
|
if (r.skipWhitespace(), r.hasMore())
|
|
1877
|
-
throw
|
|
2177
|
+
throw k(
|
|
1878
2178
|
e,
|
|
1879
2179
|
`unexpected token at position ${r.position}`
|
|
1880
2180
|
);
|
|
1881
2181
|
if (i.length === 0)
|
|
1882
|
-
throw
|
|
2182
|
+
throw k(e, "empty statement block");
|
|
1883
2183
|
return i;
|
|
1884
2184
|
}
|
|
1885
|
-
function
|
|
1886
|
-
const e =
|
|
1887
|
-
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^for\s*\(/.test(e) || /^do\b/.test(e) || /^(\+\+|--)/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*(\+\+|--|[+\-*/]=|=)/.test(e);
|
|
2185
|
+
function V(t) {
|
|
2186
|
+
const e = me(t).trim();
|
|
2187
|
+
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);
|
|
1888
2188
|
}
|
|
1889
|
-
class
|
|
2189
|
+
class ge {
|
|
1890
2190
|
constructor(e, n) {
|
|
1891
2191
|
this.input = e, this.path = n;
|
|
1892
2192
|
}
|
|
@@ -1915,11 +2215,11 @@ class me {
|
|
|
1915
2215
|
if (this.matchWord("do"))
|
|
1916
2216
|
return this.parseDoWhile();
|
|
1917
2217
|
if (this.matchWord("while"))
|
|
1918
|
-
throw
|
|
2218
|
+
throw k(
|
|
1919
2219
|
this.path,
|
|
1920
2220
|
"bare while loops are not allowed (use do…while)"
|
|
1921
2221
|
);
|
|
1922
|
-
return this.parseSimpleStatement();
|
|
2222
|
+
return this.matchWord("echo") ? this.parseEcho() : this.parseSimpleStatement();
|
|
1923
2223
|
}
|
|
1924
2224
|
parseSimpleStatement() {
|
|
1925
2225
|
this.skipWhitespace();
|
|
@@ -1932,7 +2232,7 @@ class me {
|
|
|
1932
2232
|
return this.parseBindingDeclaration("let");
|
|
1933
2233
|
const n = this.readIdentifier();
|
|
1934
2234
|
if (!n)
|
|
1935
|
-
throw
|
|
2235
|
+
throw k(this.path, "expected statement");
|
|
1936
2236
|
if (this.assertAssignableName(n), this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
1937
2237
|
const i = this.input.slice(this.index - 2, this.index);
|
|
1938
2238
|
return { kind: "update", name: n, op: i, position: "postfix" };
|
|
@@ -1949,7 +2249,7 @@ class me {
|
|
|
1949
2249
|
}
|
|
1950
2250
|
if (this.match("=")) {
|
|
1951
2251
|
if (this.peek() === "=")
|
|
1952
|
-
throw
|
|
2252
|
+
throw k(this.path, "unexpected '==' in assignment");
|
|
1953
2253
|
const i = this.readExpressionSourceUntilTerminator();
|
|
1954
2254
|
return {
|
|
1955
2255
|
kind: "assign",
|
|
@@ -1957,13 +2257,21 @@ class me {
|
|
|
1957
2257
|
expr: S(i, this.path)
|
|
1958
2258
|
};
|
|
1959
2259
|
}
|
|
1960
|
-
throw
|
|
2260
|
+
throw k(this.path, `invalid statement starting with: ${n}`);
|
|
2261
|
+
}
|
|
2262
|
+
parseEcho() {
|
|
2263
|
+
this.skipWhitespace();
|
|
2264
|
+
const e = this.readExpressionSourceUntilTerminator();
|
|
2265
|
+
return {
|
|
2266
|
+
kind: "echo",
|
|
2267
|
+
expr: S(e, this.path)
|
|
2268
|
+
};
|
|
1961
2269
|
}
|
|
1962
2270
|
readPrefixUpdate() {
|
|
1963
2271
|
if (this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
1964
2272
|
const e = this.input.slice(this.index - 2, this.index), n = this.readIdentifier();
|
|
1965
2273
|
if (!n)
|
|
1966
|
-
throw
|
|
2274
|
+
throw k(this.path, `expected identifier after ${e}`);
|
|
1967
2275
|
return this.assertAssignableName(n), { kind: "update", name: n, op: e, position: "prefix" };
|
|
1968
2276
|
}
|
|
1969
2277
|
return null;
|
|
@@ -1971,9 +2279,9 @@ class me {
|
|
|
1971
2279
|
parseBindingDeclaration(e) {
|
|
1972
2280
|
const n = this.readIdentifier();
|
|
1973
2281
|
if (!n)
|
|
1974
|
-
throw
|
|
2282
|
+
throw k(this.path, `expected identifier after ${e}`);
|
|
1975
2283
|
if (this.assertAssignableName(n), this.skipWhitespace(), !this.match("="))
|
|
1976
|
-
throw
|
|
2284
|
+
throw k(this.path, `expected '=' in ${e} declaration`);
|
|
1977
2285
|
const r = this.readExpressionSourceUntilTerminator();
|
|
1978
2286
|
return {
|
|
1979
2287
|
kind: e,
|
|
@@ -1983,57 +2291,57 @@ class me {
|
|
|
1983
2291
|
}
|
|
1984
2292
|
parseFor() {
|
|
1985
2293
|
if (this.skipWhitespace(), !this.match("("))
|
|
1986
|
-
throw
|
|
1987
|
-
const e = this.readBalanced(")"), n =
|
|
2294
|
+
throw k(this.path, "expected '(' after for");
|
|
2295
|
+
const e = this.readBalanced(")"), n = hn(e);
|
|
1988
2296
|
if (n.length !== 3)
|
|
1989
|
-
throw
|
|
2297
|
+
throw k(
|
|
1990
2298
|
this.path,
|
|
1991
2299
|
"for…of / for…in are not allowed; use for (init; cond; update)"
|
|
1992
2300
|
);
|
|
1993
2301
|
const [r, i, s] = n;
|
|
1994
2302
|
if (i.trim().length === 0)
|
|
1995
|
-
throw
|
|
2303
|
+
throw k(this.path, "for loop condition cannot be empty");
|
|
1996
2304
|
if (/^\s*[A-Za-z_$][A-Za-z0-9_$]*\s+(of|in)\s+/.test(r))
|
|
1997
|
-
throw
|
|
2305
|
+
throw k(
|
|
1998
2306
|
this.path,
|
|
1999
2307
|
"for…of / for…in are not allowed; use for (init; cond; update)"
|
|
2000
2308
|
);
|
|
2001
2309
|
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());
|
|
2002
2310
|
if (this.skipWhitespace(), !this.match("{"))
|
|
2003
|
-
throw
|
|
2311
|
+
throw k(this.path, "expected '{' after for (...)");
|
|
2004
2312
|
const h = this.parseStatementList();
|
|
2005
2313
|
if (this.skipWhitespace(), !this.match("}"))
|
|
2006
|
-
throw
|
|
2314
|
+
throw k(this.path, "expected '}' to close for body");
|
|
2007
2315
|
return { kind: "for", init: o, cond: a, update: c, body: h };
|
|
2008
2316
|
}
|
|
2009
2317
|
parseDoWhile() {
|
|
2010
2318
|
if (this.skipWhitespace(), !this.match("{"))
|
|
2011
|
-
throw
|
|
2319
|
+
throw k(this.path, "expected '{' after do");
|
|
2012
2320
|
const e = this.parseStatementList();
|
|
2013
2321
|
if (this.skipWhitespace(), !this.match("}"))
|
|
2014
|
-
throw
|
|
2322
|
+
throw k(this.path, "expected '}' to close do body");
|
|
2015
2323
|
if (this.skipWhitespace(), !this.matchWord("while"))
|
|
2016
|
-
throw
|
|
2324
|
+
throw k(this.path, "expected 'while' after do body");
|
|
2017
2325
|
if (this.skipWhitespace(), !this.match("("))
|
|
2018
|
-
throw
|
|
2326
|
+
throw k(this.path, "expected '(' after while");
|
|
2019
2327
|
const n = this.readBalanced(")");
|
|
2020
2328
|
if (n.trim().length === 0)
|
|
2021
|
-
throw
|
|
2329
|
+
throw k(this.path, "do…while condition cannot be empty");
|
|
2022
2330
|
const r = S(n.trim(), this.path);
|
|
2023
2331
|
return { kind: "do_while", body: e, cond: r };
|
|
2024
2332
|
}
|
|
2025
2333
|
parseClauseStatement(e) {
|
|
2026
|
-
const n = new
|
|
2334
|
+
const n = new ge(e, this.path), r = n.parseSimpleStatement();
|
|
2027
2335
|
if (n.skipWhitespace(), n.hasMore())
|
|
2028
|
-
throw
|
|
2336
|
+
throw k(
|
|
2029
2337
|
this.path,
|
|
2030
2338
|
`unexpected token in for clause at position ${n.position}`
|
|
2031
2339
|
);
|
|
2032
2340
|
return r;
|
|
2033
2341
|
}
|
|
2034
2342
|
assertAssignableName(e) {
|
|
2035
|
-
if (
|
|
2036
|
-
throw
|
|
2343
|
+
if (Qe(e))
|
|
2344
|
+
throw k(
|
|
2037
2345
|
this.path,
|
|
2038
2346
|
`reserved word cannot be used as identifier: ${e}`
|
|
2039
2347
|
);
|
|
@@ -2068,7 +2376,7 @@ class me {
|
|
|
2068
2376
|
}
|
|
2069
2377
|
const o = this.input.slice(e, this.index).trim();
|
|
2070
2378
|
if (o.length === 0)
|
|
2071
|
-
throw
|
|
2379
|
+
throw k(this.path, "expected expression");
|
|
2072
2380
|
return o;
|
|
2073
2381
|
}
|
|
2074
2382
|
readBalanced(e) {
|
|
@@ -2104,7 +2412,7 @@ class me {
|
|
|
2104
2412
|
}
|
|
2105
2413
|
this.index++;
|
|
2106
2414
|
}
|
|
2107
|
-
throw
|
|
2415
|
+
throw k(this.path, `expected '${e}'`);
|
|
2108
2416
|
}
|
|
2109
2417
|
readCompoundOp() {
|
|
2110
2418
|
this.skipWhitespace();
|
|
@@ -2139,7 +2447,7 @@ class me {
|
|
|
2139
2447
|
return this.input.slice(e, this.index);
|
|
2140
2448
|
}
|
|
2141
2449
|
}
|
|
2142
|
-
function
|
|
2450
|
+
function hn(t) {
|
|
2143
2451
|
const e = [];
|
|
2144
2452
|
let n = "", r = 0, i = null;
|
|
2145
2453
|
for (let s = 0; s < t.length; s++) {
|
|
@@ -2172,7 +2480,7 @@ function It(t) {
|
|
|
2172
2480
|
}
|
|
2173
2481
|
return e.push(n), e;
|
|
2174
2482
|
}
|
|
2175
|
-
function
|
|
2483
|
+
function B(t, e) {
|
|
2176
2484
|
const n = t.trim();
|
|
2177
2485
|
if (!/^extend\b/i.test(n)) return null;
|
|
2178
2486
|
if (!/^extend\s+/i.test(n))
|
|
@@ -2197,10 +2505,10 @@ function H(t, e) {
|
|
|
2197
2505
|
});
|
|
2198
2506
|
return { path: i };
|
|
2199
2507
|
}
|
|
2200
|
-
function
|
|
2201
|
-
const n =
|
|
2508
|
+
function dn(t, e) {
|
|
2509
|
+
const n = C(t);
|
|
2202
2510
|
if (n.length === 0) return null;
|
|
2203
|
-
const r = n[0], i =
|
|
2511
|
+
const r = n[0], i = B(r, e);
|
|
2204
2512
|
if (!i) return null;
|
|
2205
2513
|
for (const s of n.slice(1))
|
|
2206
2514
|
if (/^extend\s+/i.test(s))
|
|
@@ -2215,9 +2523,43 @@ function zt(t, e) {
|
|
|
2215
2523
|
`)
|
|
2216
2524
|
};
|
|
2217
2525
|
}
|
|
2218
|
-
|
|
2526
|
+
function P(t) {
|
|
2527
|
+
return /^toc(\(.*\))?$/.test(t.trim());
|
|
2528
|
+
}
|
|
2529
|
+
function un(t, e) {
|
|
2530
|
+
const n = C(t);
|
|
2531
|
+
if (n.length !== 1)
|
|
2532
|
+
throw d({
|
|
2533
|
+
code: "parse_error",
|
|
2534
|
+
path: e,
|
|
2535
|
+
details: {
|
|
2536
|
+
message: "toc directive must be a single line"
|
|
2537
|
+
}
|
|
2538
|
+
});
|
|
2539
|
+
const r = n[0];
|
|
2540
|
+
if (r === "toc")
|
|
2541
|
+
return { maxLevel: 6 };
|
|
2542
|
+
const i = /^toc\((.*)\)$/.exec(r);
|
|
2543
|
+
if (!i)
|
|
2544
|
+
throw d({
|
|
2545
|
+
code: "parse_error",
|
|
2546
|
+
path: e,
|
|
2547
|
+
details: { message: `invalid toc directive: ${r}` }
|
|
2548
|
+
});
|
|
2549
|
+
const s = i[1];
|
|
2550
|
+
if (!/^[1-6]$/.test(s))
|
|
2551
|
+
throw d({
|
|
2552
|
+
code: "parse_error",
|
|
2553
|
+
path: e,
|
|
2554
|
+
details: {
|
|
2555
|
+
message: `invalid toc max level: ${s || "(empty)"} (expected integer 1–6)`
|
|
2556
|
+
}
|
|
2557
|
+
});
|
|
2558
|
+
return { maxLevel: Number(s) };
|
|
2559
|
+
}
|
|
2560
|
+
async function fn(t, e = {}) {
|
|
2219
2561
|
const n = e.path, r = e.context ?? {};
|
|
2220
|
-
if (
|
|
2562
|
+
if (le(t))
|
|
2221
2563
|
throw d({
|
|
2222
2564
|
code: "parse_error",
|
|
2223
2565
|
path: n,
|
|
@@ -2225,7 +2567,7 @@ async function Ut(t, e = {}) {
|
|
|
2225
2567
|
message: he(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2226
2568
|
}
|
|
2227
2569
|
});
|
|
2228
|
-
const i =
|
|
2570
|
+
const i = W(t);
|
|
2229
2571
|
if (i.length === 0)
|
|
2230
2572
|
return { source: t, context: r, declarationUpdates: {} };
|
|
2231
2573
|
const s = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
|
|
@@ -2233,53 +2575,58 @@ async function Ut(t, e = {}) {
|
|
|
2233
2575
|
};
|
|
2234
2576
|
let c = t, h = 0;
|
|
2235
2577
|
for (const l of i) {
|
|
2236
|
-
const
|
|
2237
|
-
if (
|
|
2578
|
+
const u = C(l.inner);
|
|
2579
|
+
if (u.length === 1 && de(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]))
|
|
2238
2580
|
continue;
|
|
2239
|
-
const
|
|
2240
|
-
if (
|
|
2241
|
-
if (
|
|
2242
|
-
const
|
|
2243
|
-
|
|
2581
|
+
const g = dn(l.inner, n);
|
|
2582
|
+
if (g) {
|
|
2583
|
+
if (g.declarationsSource.trim().length > 0) {
|
|
2584
|
+
const D = We(
|
|
2585
|
+
g.declarationsSource,
|
|
2244
2586
|
n
|
|
2245
2587
|
);
|
|
2246
|
-
await
|
|
2588
|
+
await $e(D, r, {
|
|
2247
2589
|
path: n,
|
|
2248
2590
|
constBindings: s,
|
|
2249
2591
|
onUpdate: a
|
|
2250
2592
|
});
|
|
2251
2593
|
}
|
|
2252
|
-
const
|
|
2253
|
-
extend ${
|
|
2594
|
+
const _ = l.start - h, L = l.end - h, U = `<!--@hg
|
|
2595
|
+
extend ${g.path}
|
|
2254
2596
|
@endhg-->`;
|
|
2255
|
-
c = c.slice(0,
|
|
2597
|
+
c = c.slice(0, _) + U + c.slice(L), h += l.raw.length - U.length;
|
|
2256
2598
|
continue;
|
|
2257
2599
|
}
|
|
2258
|
-
const
|
|
2600
|
+
const w = u.join(`
|
|
2259
2601
|
`);
|
|
2260
|
-
if (!
|
|
2261
|
-
if (
|
|
2602
|
+
if (!V(w)) {
|
|
2603
|
+
if (u.length === 1)
|
|
2262
2604
|
continue;
|
|
2263
2605
|
throw d({
|
|
2264
2606
|
code: "parse_error",
|
|
2265
2607
|
path: n,
|
|
2266
|
-
details: { message: `unsupported hyogen directive: ${
|
|
2608
|
+
details: { message: `unsupported hyogen directive: ${u[0]}` }
|
|
2267
2609
|
});
|
|
2268
2610
|
}
|
|
2269
|
-
const
|
|
2270
|
-
await
|
|
2611
|
+
const p = We(w, n), x = [];
|
|
2612
|
+
await $e(p, r, {
|
|
2271
2613
|
path: n,
|
|
2272
2614
|
constBindings: s,
|
|
2273
|
-
onUpdate: a
|
|
2615
|
+
onUpdate: a,
|
|
2616
|
+
echoChunks: x
|
|
2274
2617
|
});
|
|
2275
|
-
const
|
|
2276
|
-
|
|
2618
|
+
const $ = l.start - h, K = l.end - h, T = c.slice(0, $), b = c.slice(K);
|
|
2619
|
+
if (x.length > 0) {
|
|
2620
|
+
const _ = x.join("");
|
|
2621
|
+
c = T + _ + b, h += l.raw.length - _.length;
|
|
2622
|
+
} else
|
|
2623
|
+
c = A(T, b), h += l.raw.length + pe(T, b);
|
|
2277
2624
|
}
|
|
2278
2625
|
return { source: c, context: r, declarationUpdates: o };
|
|
2279
2626
|
}
|
|
2280
|
-
const
|
|
2281
|
-
function
|
|
2282
|
-
const n =
|
|
2627
|
+
const pn = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
|
|
2628
|
+
function et(t, e) {
|
|
2629
|
+
const n = ae(t).trim();
|
|
2283
2630
|
if (n.length === 0)
|
|
2284
2631
|
throw d({
|
|
2285
2632
|
code: "parse_error",
|
|
@@ -2302,7 +2649,7 @@ function Fe(t, e) {
|
|
|
2302
2649
|
path: e,
|
|
2303
2650
|
details: { message: "include and component cannot coexist in one block" }
|
|
2304
2651
|
});
|
|
2305
|
-
const s =
|
|
2652
|
+
const s = pn.exec(i);
|
|
2306
2653
|
if (!s)
|
|
2307
2654
|
throw d({
|
|
2308
2655
|
code: "parse_error",
|
|
@@ -2322,8 +2669,8 @@ function Fe(t, e) {
|
|
|
2322
2669
|
alias: s[2]
|
|
2323
2670
|
};
|
|
2324
2671
|
}
|
|
2325
|
-
function
|
|
2326
|
-
const n =
|
|
2672
|
+
function tt(t, e) {
|
|
2673
|
+
const n = ae(t).trim();
|
|
2327
2674
|
if (n.length === 0)
|
|
2328
2675
|
throw d({
|
|
2329
2676
|
code: "parse_error",
|
|
@@ -2346,19 +2693,19 @@ function Be(t, e) {
|
|
|
2346
2693
|
details: { message: `unsupported hyogen directive: ${i}` }
|
|
2347
2694
|
});
|
|
2348
2695
|
}
|
|
2349
|
-
function
|
|
2350
|
-
const e =
|
|
2696
|
+
function ne(t) {
|
|
2697
|
+
const e = me(t).trim();
|
|
2351
2698
|
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
|
|
2352
2699
|
}
|
|
2353
|
-
const
|
|
2354
|
-
function
|
|
2355
|
-
return `${
|
|
2700
|
+
const mn = "\0HYOGEN_INCLUDE_";
|
|
2701
|
+
function gn(t) {
|
|
2702
|
+
return `${mn}${t}\0`;
|
|
2356
2703
|
}
|
|
2357
|
-
function
|
|
2358
|
-
const n =
|
|
2359
|
-
if (n.length === 1 &&
|
|
2704
|
+
function wn(t, e) {
|
|
2705
|
+
const n = C(t);
|
|
2706
|
+
if (n.length === 1 && de(n[0]))
|
|
2360
2707
|
return { kind: "control" };
|
|
2361
|
-
if (n.length === 1 && (
|
|
2708
|
+
if (n.length === 1 && P(n[0]) || n.length === 1 && (ne(n[0]) || V(n[0])))
|
|
2362
2709
|
return null;
|
|
2363
2710
|
if (n.length !== 1)
|
|
2364
2711
|
throw d({
|
|
@@ -2374,9 +2721,9 @@ function Pt(t, e) {
|
|
|
2374
2721
|
details: { message: "include and component cannot coexist in one block" }
|
|
2375
2722
|
});
|
|
2376
2723
|
if (/^include\s+/i.test(r))
|
|
2377
|
-
return
|
|
2724
|
+
return tt(t, e);
|
|
2378
2725
|
if (/^component\s+/i.test(r))
|
|
2379
|
-
return
|
|
2726
|
+
return et(t, e);
|
|
2380
2727
|
if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
|
|
2381
2728
|
return null;
|
|
2382
2729
|
throw d({
|
|
@@ -2385,9 +2732,9 @@ function Pt(t, e) {
|
|
|
2385
2732
|
details: { message: `unsupported hyogen directive: ${r}` }
|
|
2386
2733
|
});
|
|
2387
2734
|
}
|
|
2388
|
-
function
|
|
2735
|
+
function xn(t, e = {}) {
|
|
2389
2736
|
const n = e.path;
|
|
2390
|
-
if (
|
|
2737
|
+
if (le(t))
|
|
2391
2738
|
throw d({
|
|
2392
2739
|
code: "parse_error",
|
|
2393
2740
|
path: n,
|
|
@@ -2395,16 +2742,16 @@ function Kt(t, e = {}) {
|
|
|
2395
2742
|
message: he(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2396
2743
|
}
|
|
2397
2744
|
});
|
|
2398
|
-
const r =
|
|
2745
|
+
const r = W(t);
|
|
2399
2746
|
if (r.length === 0)
|
|
2400
2747
|
return { source: t, directives: [] };
|
|
2401
2748
|
const i = [];
|
|
2402
2749
|
let s = t, o = 0, a = 0;
|
|
2403
2750
|
for (const c of r) {
|
|
2404
|
-
const h =
|
|
2751
|
+
const h = wn(c.inner, n);
|
|
2405
2752
|
if (!h || h.kind === "control")
|
|
2406
2753
|
continue;
|
|
2407
|
-
const l = c.start - o,
|
|
2754
|
+
const l = c.start - o, u = c.end - o;
|
|
2408
2755
|
if (h.kind === "component") {
|
|
2409
2756
|
e.registry && e.registry.register(
|
|
2410
2757
|
{
|
|
@@ -2415,39 +2762,39 @@ function Kt(t, e = {}) {
|
|
|
2415
2762
|
Object.keys(e.context ?? {}),
|
|
2416
2763
|
n
|
|
2417
2764
|
);
|
|
2418
|
-
const
|
|
2419
|
-
s =
|
|
2765
|
+
const w = s.slice(0, l), p = s.slice(u);
|
|
2766
|
+
s = A(w, p), o += c.raw.length + pe(w, p);
|
|
2420
2767
|
continue;
|
|
2421
2768
|
}
|
|
2422
|
-
const
|
|
2423
|
-
i.push({ ...h, marker:
|
|
2769
|
+
const g = gn(a++);
|
|
2770
|
+
i.push({ ...h, marker: g, raw: c.raw }), s = s.slice(0, l) + g + s.slice(u), o += c.raw.length - g.length;
|
|
2424
2771
|
}
|
|
2425
2772
|
return { source: s, directives: i };
|
|
2426
2773
|
}
|
|
2427
|
-
function
|
|
2774
|
+
function kn(t, e) {
|
|
2428
2775
|
return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
|
|
2429
2776
|
` : `${e.rawFrontMatter}
|
|
2430
2777
|
${t}`;
|
|
2431
2778
|
}
|
|
2432
|
-
function
|
|
2779
|
+
function yn(t, e = !1) {
|
|
2433
2780
|
if (e)
|
|
2434
2781
|
return t;
|
|
2435
|
-
const n =
|
|
2782
|
+
const n = W(t);
|
|
2436
2783
|
if (n.length === 0)
|
|
2437
2784
|
return t;
|
|
2438
2785
|
let r = t, i = 0;
|
|
2439
2786
|
for (const s of n) {
|
|
2440
2787
|
const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
|
|
2441
|
-
r =
|
|
2788
|
+
r = A(c, h), i += s.raw.length + pe(c, h);
|
|
2442
2789
|
}
|
|
2443
2790
|
return r;
|
|
2444
2791
|
}
|
|
2445
|
-
const
|
|
2446
|
-
function
|
|
2792
|
+
const bn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
2793
|
+
function vn(t, e) {
|
|
2447
2794
|
const n = t.trim();
|
|
2448
2795
|
if (n === "endblock")
|
|
2449
2796
|
return { kind: "endblock" };
|
|
2450
|
-
const r =
|
|
2797
|
+
const r = bn.exec(n);
|
|
2451
2798
|
if (!r)
|
|
2452
2799
|
throw d({
|
|
2453
2800
|
code: "parse_error",
|
|
@@ -2455,7 +2802,7 @@ function Xt(t, e) {
|
|
|
2455
2802
|
details: { message: "invalid block directive" }
|
|
2456
2803
|
});
|
|
2457
2804
|
const i = r[1];
|
|
2458
|
-
if (
|
|
2805
|
+
if (Qe(i))
|
|
2459
2806
|
throw d({
|
|
2460
2807
|
code: "parse_error",
|
|
2461
2808
|
path: e,
|
|
@@ -2463,35 +2810,35 @@ function Xt(t, e) {
|
|
|
2463
2810
|
});
|
|
2464
2811
|
return { kind: "block", name: i };
|
|
2465
2812
|
}
|
|
2466
|
-
function
|
|
2467
|
-
const { path: n, mode: r, hasExtend: i = !1 } = e, s =
|
|
2813
|
+
function Te(t, e) {
|
|
2814
|
+
const { path: n, mode: r, hasExtend: i = !1 } = e, s = W(t);
|
|
2468
2815
|
if (s.length === 0) return [];
|
|
2469
2816
|
const o = [], a = [], c = /* @__PURE__ */ new Set();
|
|
2470
2817
|
for (const h of s) {
|
|
2471
|
-
const l =
|
|
2818
|
+
const l = C(h.inner);
|
|
2472
2819
|
if (l.length !== 1) continue;
|
|
2473
|
-
const
|
|
2474
|
-
if (!(
|
|
2820
|
+
const u = l[0];
|
|
2821
|
+
if (!(u === "endblock" || u.startsWith("block "))) continue;
|
|
2475
2822
|
if (r === "child" && !i)
|
|
2476
2823
|
throw d({
|
|
2477
2824
|
code: "parse_error",
|
|
2478
2825
|
path: n,
|
|
2479
2826
|
details: { message: "orphan block without extend" }
|
|
2480
2827
|
});
|
|
2481
|
-
const
|
|
2482
|
-
if (
|
|
2483
|
-
const
|
|
2484
|
-
if (!
|
|
2828
|
+
const w = vn(u, n);
|
|
2829
|
+
if (w.kind === "endblock") {
|
|
2830
|
+
const p = a.pop();
|
|
2831
|
+
if (!p)
|
|
2485
2832
|
throw d({
|
|
2486
2833
|
code: "parse_error",
|
|
2487
2834
|
path: n,
|
|
2488
2835
|
details: { message: "endblock without matching block opener" }
|
|
2489
2836
|
});
|
|
2490
|
-
const
|
|
2837
|
+
const x = t.slice(p.openerEnd, h.start);
|
|
2491
2838
|
o.push({
|
|
2492
|
-
name:
|
|
2493
|
-
body:
|
|
2494
|
-
start:
|
|
2839
|
+
name: p.name,
|
|
2840
|
+
body: x,
|
|
2841
|
+
start: p.start,
|
|
2495
2842
|
end: h.end
|
|
2496
2843
|
});
|
|
2497
2844
|
continue;
|
|
@@ -2502,14 +2849,14 @@ function Ee(t, e) {
|
|
|
2502
2849
|
path: n,
|
|
2503
2850
|
details: { message: "nested block structures are not supported" }
|
|
2504
2851
|
});
|
|
2505
|
-
if (c.has(
|
|
2852
|
+
if (c.has(w.name))
|
|
2506
2853
|
throw d({
|
|
2507
2854
|
code: "parse_error",
|
|
2508
2855
|
path: n,
|
|
2509
|
-
details: { message: `duplicate block: ${
|
|
2856
|
+
details: { message: `duplicate block: ${w.name}` }
|
|
2510
2857
|
});
|
|
2511
|
-
c.add(
|
|
2512
|
-
name:
|
|
2858
|
+
c.add(w.name), a.push({
|
|
2859
|
+
name: w.name,
|
|
2513
2860
|
openerEnd: h.end,
|
|
2514
2861
|
start: h.start
|
|
2515
2862
|
});
|
|
@@ -2522,37 +2869,37 @@ function Ee(t, e) {
|
|
|
2522
2869
|
});
|
|
2523
2870
|
return o;
|
|
2524
2871
|
}
|
|
2525
|
-
function
|
|
2526
|
-
const e =
|
|
2872
|
+
function Ae(t) {
|
|
2873
|
+
const e = W(t), n = [];
|
|
2527
2874
|
for (const r of e) {
|
|
2528
|
-
const i =
|
|
2875
|
+
const i = C(r.inner);
|
|
2529
2876
|
if (i.length === 0) continue;
|
|
2530
|
-
const s =
|
|
2877
|
+
const s = B(i[0]);
|
|
2531
2878
|
s && n.push({ path: s.path, start: r.start });
|
|
2532
2879
|
}
|
|
2533
2880
|
return n;
|
|
2534
2881
|
}
|
|
2535
|
-
function
|
|
2536
|
-
const e =
|
|
2882
|
+
function _n(t) {
|
|
2883
|
+
const e = W(t);
|
|
2537
2884
|
for (const n of e) {
|
|
2538
|
-
const r =
|
|
2885
|
+
const r = C(n.inner);
|
|
2539
2886
|
if (r.length !== 1) continue;
|
|
2540
2887
|
const i = r[0];
|
|
2541
2888
|
if (i === "endblock" || i.startsWith("block ")) return !0;
|
|
2542
2889
|
}
|
|
2543
2890
|
return !1;
|
|
2544
2891
|
}
|
|
2545
|
-
function
|
|
2892
|
+
function ee(t) {
|
|
2546
2893
|
return t.map((e) => e.body).join("");
|
|
2547
2894
|
}
|
|
2548
|
-
function
|
|
2895
|
+
function Sn(t, e, n) {
|
|
2549
2896
|
const r = [...e].sort((o, a) => o.start - a.start), i = [];
|
|
2550
2897
|
let s = 0;
|
|
2551
2898
|
for (const o of r)
|
|
2552
2899
|
i.push(t.slice(s, o.start)), i.push(n.get(o.name) ?? o.body), s = o.end;
|
|
2553
|
-
return i.push(t.slice(s)), i.reduce((o, a) =>
|
|
2900
|
+
return i.push(t.slice(s)), i.reduce((o, a) => A(o, a));
|
|
2554
2901
|
}
|
|
2555
|
-
function
|
|
2902
|
+
function En(t) {
|
|
2556
2903
|
if (t instanceof Error && "code" in t && "details" in t) {
|
|
2557
2904
|
const e = t;
|
|
2558
2905
|
if (e.code === "file_not_found" && e.details && e.details.via === "include")
|
|
@@ -2560,7 +2907,7 @@ function tn(t) {
|
|
|
2560
2907
|
}
|
|
2561
2908
|
return { errorToThrow: t, adjusted: !1 };
|
|
2562
2909
|
}
|
|
2563
|
-
async function
|
|
2910
|
+
async function Cn(t, e) {
|
|
2564
2911
|
const {
|
|
2565
2912
|
path: n,
|
|
2566
2913
|
context: r,
|
|
@@ -2571,35 +2918,35 @@ async function nn(t, e) {
|
|
|
2571
2918
|
visitStack: c,
|
|
2572
2919
|
warnings: h,
|
|
2573
2920
|
inComponent: l = !1
|
|
2574
|
-
} = e,
|
|
2575
|
-
if (
|
|
2576
|
-
if (
|
|
2921
|
+
} = e, u = Ae(t);
|
|
2922
|
+
if (u.length === 0) {
|
|
2923
|
+
if (_n(t))
|
|
2577
2924
|
throw d({
|
|
2578
2925
|
code: "parse_error",
|
|
2579
2926
|
path: n,
|
|
2580
2927
|
details: { message: "orphan block without extend" }
|
|
2581
2928
|
});
|
|
2582
|
-
return { source: t, context:
|
|
2929
|
+
return { source: t, context: v(r, i) };
|
|
2583
2930
|
}
|
|
2584
|
-
const
|
|
2585
|
-
if (!
|
|
2586
|
-
return { source: t, context:
|
|
2931
|
+
const w = W(t)[0];
|
|
2932
|
+
if (!w)
|
|
2933
|
+
return { source: t, context: v(r, i) };
|
|
2587
2934
|
if (!s)
|
|
2588
2935
|
throw new Error("loader is required when processing extend directives");
|
|
2589
|
-
const
|
|
2590
|
-
if (!(
|
|
2936
|
+
const p = C(w.inner);
|
|
2937
|
+
if (!(p.length > 0 ? B(p[0]) : null))
|
|
2591
2938
|
throw d({
|
|
2592
2939
|
code: "parse_error",
|
|
2593
2940
|
path: n,
|
|
2594
2941
|
details: { message: "extend must be the first hyogen block" }
|
|
2595
2942
|
});
|
|
2596
|
-
if (
|
|
2943
|
+
if (u.length > 1)
|
|
2597
2944
|
throw d({
|
|
2598
2945
|
code: "parse_error",
|
|
2599
2946
|
path: n,
|
|
2600
2947
|
details: { message: "multiple extend directives are not supported" }
|
|
2601
2948
|
});
|
|
2602
|
-
const
|
|
2949
|
+
const $ = Te(t, {
|
|
2603
2950
|
path: n,
|
|
2604
2951
|
mode: "child",
|
|
2605
2952
|
hasExtend: !0
|
|
@@ -2607,16 +2954,16 @@ async function nn(t, e) {
|
|
|
2607
2954
|
if (l)
|
|
2608
2955
|
return h?.push({
|
|
2609
2956
|
code: "extend_in_component",
|
|
2610
|
-
message:
|
|
2957
|
+
message: H("extend_in_component", { path: n }),
|
|
2611
2958
|
path: n,
|
|
2612
2959
|
details: { path: n }
|
|
2613
2960
|
}), {
|
|
2614
|
-
source:
|
|
2615
|
-
context:
|
|
2961
|
+
source: ee($),
|
|
2962
|
+
context: v(r, i)
|
|
2616
2963
|
};
|
|
2617
|
-
const
|
|
2964
|
+
const K = u[0].path, T = n, b = te(
|
|
2618
2965
|
o,
|
|
2619
|
-
|
|
2966
|
+
K,
|
|
2620
2967
|
n,
|
|
2621
2968
|
n,
|
|
2622
2969
|
a,
|
|
@@ -2624,85 +2971,85 @@ async function nn(t, e) {
|
|
|
2624
2971
|
);
|
|
2625
2972
|
T && c.push(T);
|
|
2626
2973
|
try {
|
|
2627
|
-
const
|
|
2628
|
-
if (
|
|
2974
|
+
const _ = T ? c.check(b) : { circular: !1 };
|
|
2975
|
+
if (_.circular)
|
|
2629
2976
|
return h?.push({
|
|
2630
2977
|
code: "circular_include",
|
|
2631
|
-
message:
|
|
2632
|
-
path:
|
|
2633
|
-
from:
|
|
2978
|
+
message: H("circular_include", {
|
|
2979
|
+
path: b,
|
|
2980
|
+
from: _.from,
|
|
2634
2981
|
via: "extend"
|
|
2635
2982
|
}),
|
|
2636
2983
|
path: n,
|
|
2637
|
-
details: { path:
|
|
2984
|
+
details: { path: b, from: _.from, via: "extend" }
|
|
2638
2985
|
}), {
|
|
2639
|
-
source:
|
|
2640
|
-
context:
|
|
2986
|
+
source: ee($),
|
|
2987
|
+
context: v(r, i)
|
|
2641
2988
|
};
|
|
2642
|
-
c.push(
|
|
2989
|
+
c.push(b);
|
|
2643
2990
|
try {
|
|
2644
|
-
const
|
|
2645
|
-
if (
|
|
2991
|
+
const L = await s(b);
|
|
2992
|
+
if (L === void 0)
|
|
2646
2993
|
throw new Error("loader returned undefined");
|
|
2647
|
-
const { context:
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
),
|
|
2651
|
-
if (
|
|
2652
|
-
const
|
|
2994
|
+
const { context: U, body: D } = q(
|
|
2995
|
+
L,
|
|
2996
|
+
b
|
|
2997
|
+
), xe = Ae(D);
|
|
2998
|
+
if (xe.length > 0) {
|
|
2999
|
+
const z = xe[0].path, Y = te(
|
|
2653
3000
|
o,
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
3001
|
+
z,
|
|
3002
|
+
b,
|
|
3003
|
+
b,
|
|
2657
3004
|
a,
|
|
2658
3005
|
!0
|
|
2659
|
-
),
|
|
2660
|
-
if (
|
|
3006
|
+
), X = c.check(Y);
|
|
3007
|
+
if (X.circular)
|
|
2661
3008
|
return h?.push({
|
|
2662
3009
|
code: "circular_include",
|
|
2663
|
-
message:
|
|
2664
|
-
path:
|
|
2665
|
-
from:
|
|
3010
|
+
message: H("circular_include", {
|
|
3011
|
+
path: Y,
|
|
3012
|
+
from: X.from,
|
|
2666
3013
|
via: "extend"
|
|
2667
3014
|
}),
|
|
2668
3015
|
path: n,
|
|
2669
|
-
details: { path:
|
|
3016
|
+
details: { path: Y, from: X.from, via: "extend" }
|
|
2670
3017
|
}), {
|
|
2671
|
-
source:
|
|
2672
|
-
context:
|
|
3018
|
+
source: ee($),
|
|
3019
|
+
context: v(r, i)
|
|
2673
3020
|
};
|
|
2674
3021
|
throw d({
|
|
2675
3022
|
code: "parse_error",
|
|
2676
|
-
path:
|
|
3023
|
+
path: b,
|
|
2677
3024
|
details: { message: "layout extend is not supported" }
|
|
2678
3025
|
});
|
|
2679
3026
|
}
|
|
2680
|
-
const
|
|
2681
|
-
path:
|
|
3027
|
+
const rt = Te(D, {
|
|
3028
|
+
path: b,
|
|
2682
3029
|
mode: "layout"
|
|
2683
|
-
}),
|
|
2684
|
-
|
|
2685
|
-
),
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
),
|
|
3030
|
+
}), it = new Map(
|
|
3031
|
+
$.map((z) => [z.name, z.body])
|
|
3032
|
+
), st = Sn(
|
|
3033
|
+
D,
|
|
3034
|
+
rt,
|
|
3035
|
+
it
|
|
3036
|
+
), ot = v(
|
|
2690
3037
|
r,
|
|
2691
|
-
|
|
3038
|
+
U,
|
|
2692
3039
|
i
|
|
2693
3040
|
);
|
|
2694
|
-
return { source:
|
|
3041
|
+
return { source: st, context: ot };
|
|
2695
3042
|
} finally {
|
|
2696
3043
|
c.pop();
|
|
2697
3044
|
}
|
|
2698
|
-
} catch (
|
|
2699
|
-
const
|
|
2700
|
-
throw
|
|
3045
|
+
} catch (_) {
|
|
3046
|
+
const L = En(_);
|
|
3047
|
+
throw L.adjusted ? L.errorToThrow : _;
|
|
2701
3048
|
} finally {
|
|
2702
3049
|
T && c.pop();
|
|
2703
3050
|
}
|
|
2704
3051
|
}
|
|
2705
|
-
const
|
|
3052
|
+
const $n = lt.warningReasons, Wn = [
|
|
2706
3053
|
{
|
|
2707
3054
|
reason: "contains_html_script_tag",
|
|
2708
3055
|
test: (t) => /<\/?script\b/i.test(t)
|
|
@@ -2724,17 +3071,17 @@ const rn = re.warningReasons, sn = [
|
|
|
2724
3071
|
test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
|
|
2725
3072
|
}
|
|
2726
3073
|
];
|
|
2727
|
-
function
|
|
2728
|
-
return
|
|
3074
|
+
function Tn(t) {
|
|
3075
|
+
return $n[t] ?? t;
|
|
2729
3076
|
}
|
|
2730
|
-
function
|
|
3077
|
+
function re(t, e, n, r) {
|
|
2731
3078
|
if (typeof t == "string") {
|
|
2732
|
-
for (const i of
|
|
3079
|
+
for (const i of Wn)
|
|
2733
3080
|
i.test(t) && n.push({
|
|
2734
3081
|
code: "suspicious_context_value",
|
|
2735
|
-
message:
|
|
3082
|
+
message: H("suspicious_context_value", {
|
|
2736
3083
|
key: e,
|
|
2737
|
-
reason:
|
|
3084
|
+
reason: Tn(i.reason)
|
|
2738
3085
|
}),
|
|
2739
3086
|
path: r,
|
|
2740
3087
|
details: { key: e, reason: i.reason }
|
|
@@ -2744,7 +3091,7 @@ function te(t, e, n, r) {
|
|
|
2744
3091
|
if (t != null) {
|
|
2745
3092
|
if (Array.isArray(t)) {
|
|
2746
3093
|
for (let i = 0; i < t.length; i++)
|
|
2747
|
-
|
|
3094
|
+
re(t[i], `${e}[${i}]`, n, r);
|
|
2748
3095
|
return;
|
|
2749
3096
|
}
|
|
2750
3097
|
if (typeof t == "object")
|
|
@@ -2752,25 +3099,180 @@ function te(t, e, n, r) {
|
|
|
2752
3099
|
t
|
|
2753
3100
|
)) {
|
|
2754
3101
|
const o = e.length > 0 ? `${e}.${i}` : i;
|
|
2755
|
-
|
|
3102
|
+
re(s, o, n, r);
|
|
2756
3103
|
}
|
|
2757
3104
|
}
|
|
2758
3105
|
}
|
|
2759
|
-
function
|
|
3106
|
+
function An(t, e, n) {
|
|
2760
3107
|
for (const [r, i] of Object.entries(t))
|
|
2761
|
-
|
|
3108
|
+
re(i, r, e, n);
|
|
3109
|
+
}
|
|
3110
|
+
const Ln = /^=+[ \t]*$/, On = /^-+[ \t]*$/, Rn = /^(```|~~~)/, Mn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
|
|
3111
|
+
function ie(t) {
|
|
3112
|
+
const e = Mn.exec(t);
|
|
3113
|
+
return e && e.index !== void 0 ? {
|
|
3114
|
+
text: t.slice(0, e.index).trim(),
|
|
3115
|
+
explicitId: e[1]
|
|
3116
|
+
} : { text: t.trim() };
|
|
2762
3117
|
}
|
|
2763
|
-
|
|
2764
|
-
|
|
3118
|
+
function Hn(t) {
|
|
3119
|
+
let e = 0;
|
|
3120
|
+
for (; e < t.length && e < 6 && t[e] === "#"; )
|
|
3121
|
+
e += 1;
|
|
3122
|
+
if (e === 0 || e === 6 && e < t.length && t[e] === "#" || e >= t.length || t[e] !== " " && t[e] !== " ")
|
|
3123
|
+
return null;
|
|
3124
|
+
let n = e;
|
|
3125
|
+
for (; n < t.length && (t[n] === " " || t[n] === " "); )
|
|
3126
|
+
n += 1;
|
|
3127
|
+
if (n >= t.length)
|
|
3128
|
+
return null;
|
|
3129
|
+
let r = t.length;
|
|
3130
|
+
for (; r > n && (t[r - 1] === " " || t[r - 1] === " "); )
|
|
3131
|
+
r -= 1;
|
|
3132
|
+
let i = r;
|
|
3133
|
+
if (r > n && t[r - 1] === "#") {
|
|
3134
|
+
let o = r - 1;
|
|
3135
|
+
for (; o > n && t[o - 1] === "#"; )
|
|
3136
|
+
o -= 1;
|
|
3137
|
+
if (o > n && (t[o - 1] === " " || t[o - 1] === " ")) {
|
|
3138
|
+
let a = o - 1;
|
|
3139
|
+
for (; a >= n && (t[a] === " " || t[a] === " "); )
|
|
3140
|
+
a -= 1;
|
|
3141
|
+
i = a + 1;
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3144
|
+
if (i <= n)
|
|
3145
|
+
return null;
|
|
3146
|
+
const s = ie(t.slice(n, i));
|
|
3147
|
+
return { level: e, ...s };
|
|
3148
|
+
}
|
|
3149
|
+
function Le(t, e, n) {
|
|
3150
|
+
let r = n;
|
|
3151
|
+
for (; r < t.length; ) {
|
|
3152
|
+
if (!e.inHtmlComment) {
|
|
3153
|
+
const s = t.indexOf("<!--", r);
|
|
3154
|
+
if (s === -1)
|
|
3155
|
+
return;
|
|
3156
|
+
e.inHtmlComment = !0, r = s + 4;
|
|
3157
|
+
continue;
|
|
3158
|
+
}
|
|
3159
|
+
const i = t.indexOf("-->", r);
|
|
3160
|
+
if (i === -1)
|
|
3161
|
+
return;
|
|
3162
|
+
e.inHtmlComment = !1, r = i + 3;
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
function Nn(t, e) {
|
|
3166
|
+
if (e.inFence || e.inHtmlComment)
|
|
3167
|
+
return !0;
|
|
3168
|
+
const n = t.trim();
|
|
3169
|
+
return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
|
|
3170
|
+
}
|
|
3171
|
+
function Dn(t) {
|
|
3172
|
+
const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
|
|
3173
|
+
for (let i = 0; i < e.length; i++) {
|
|
3174
|
+
const s = e[i];
|
|
3175
|
+
if (r.inFence) {
|
|
3176
|
+
const l = s.trim();
|
|
3177
|
+
l.startsWith(r.inFence.marker) && /^(`{3,}|~{3,})\s*$/.test(l) && (r.inFence = !1);
|
|
3178
|
+
continue;
|
|
3179
|
+
}
|
|
3180
|
+
if (r.inHtmlComment) {
|
|
3181
|
+
Le(s, r, 0);
|
|
3182
|
+
continue;
|
|
3183
|
+
}
|
|
3184
|
+
const o = Rn.exec(s.trimStart());
|
|
3185
|
+
if (o) {
|
|
3186
|
+
const l = o[1];
|
|
3187
|
+
s.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
|
|
3188
|
+
continue;
|
|
3189
|
+
}
|
|
3190
|
+
if (s.trim().startsWith("<!--")) {
|
|
3191
|
+
Le(s, r, s.indexOf("<!--"));
|
|
3192
|
+
continue;
|
|
3193
|
+
}
|
|
3194
|
+
if (Nn(s, r))
|
|
3195
|
+
continue;
|
|
3196
|
+
const c = Hn(s);
|
|
3197
|
+
if (c) {
|
|
3198
|
+
n.push(c);
|
|
3199
|
+
continue;
|
|
3200
|
+
}
|
|
3201
|
+
const h = e[i + 1];
|
|
3202
|
+
if (h !== void 0 && s.trim().length > 0 && !s.trimStart().startsWith("#") && !s.trimStart().startsWith(">") && !s.trimStart().startsWith("|")) {
|
|
3203
|
+
if (Ln.test(h)) {
|
|
3204
|
+
const l = ie(s.trim());
|
|
3205
|
+
n.push({ level: 1, ...l }), i += 1;
|
|
3206
|
+
continue;
|
|
3207
|
+
}
|
|
3208
|
+
if (On.test(h) && h.trim().length >= 1) {
|
|
3209
|
+
const l = ie(s.trim());
|
|
3210
|
+
n.push({ level: 2, ...l }), i += 1;
|
|
3211
|
+
continue;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
return n;
|
|
3216
|
+
}
|
|
3217
|
+
const Fn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
|
|
3218
|
+
function jn() {
|
|
3219
|
+
const t = /* @__PURE__ */ new Map();
|
|
3220
|
+
return {
|
|
3221
|
+
slug(e, n) {
|
|
3222
|
+
const r = n !== void 0 && n.length > 0 ? n : Bn(e), i = t.get(r) ?? 0;
|
|
3223
|
+
return t.set(r, i + 1), i === 0 ? r : `${r}-${i}`;
|
|
3224
|
+
}
|
|
3225
|
+
};
|
|
3226
|
+
}
|
|
3227
|
+
function Bn(t) {
|
|
3228
|
+
return t.toLowerCase().replace(Fn, "").replace(/\s+/g, "-");
|
|
3229
|
+
}
|
|
3230
|
+
function In(t) {
|
|
3231
|
+
let e = t.trim();
|
|
3232
|
+
e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
|
|
3233
|
+
for (let n = 0; n < 3; n++)
|
|
3234
|
+
e = e.replace(/\*\*([^*]+)\*\*/g, "$1"), e = e.replace(/__([^_]+)__/g, "$1"), e = e.replace(/~~([^~]+)~~/g, "$1"), e = e.replace(/\*([^*]+)\*/g, "$1"), e = e.replace(/_([^_]+)_/g, "$1"), e = e.replace(/`([^`]+)`/g, "$1");
|
|
3235
|
+
return e.trim();
|
|
3236
|
+
}
|
|
3237
|
+
function Un(t, e) {
|
|
3238
|
+
if (t.length === 0)
|
|
3239
|
+
return "";
|
|
3240
|
+
const n = jn(), i = t.map((o) => {
|
|
3241
|
+
const a = In(o.text), c = n.slug(a, o.explicitId);
|
|
3242
|
+
return { level: o.level, text: a, anchor: c };
|
|
3243
|
+
}).filter((o) => o.level <= e);
|
|
3244
|
+
if (i.length === 0)
|
|
3245
|
+
return "";
|
|
3246
|
+
const s = Math.min(...i.map((o) => o.level));
|
|
3247
|
+
return i.map((o) => `${" ".repeat((o.level - s) * 2)}- [${o.text}](#${o.anchor})`).join(`
|
|
3248
|
+
`);
|
|
3249
|
+
}
|
|
3250
|
+
function zn(t, e = {}) {
|
|
3251
|
+
const r = W(t).filter((o) => {
|
|
3252
|
+
const a = C(o.inner);
|
|
3253
|
+
return a.length === 1 && P(a[0]);
|
|
3254
|
+
});
|
|
3255
|
+
if (r.length === 0)
|
|
3256
|
+
return t;
|
|
3257
|
+
const i = Dn(t);
|
|
3258
|
+
let s = t;
|
|
3259
|
+
for (let o = r.length - 1; o >= 0; o--) {
|
|
3260
|
+
const a = r[o], { maxLevel: c } = un(a.inner, e.path), h = Un(i, c), l = s.slice(0, a.start), u = s.slice(a.end);
|
|
3261
|
+
s = A(A(l, h), u);
|
|
3262
|
+
}
|
|
3263
|
+
return s;
|
|
3264
|
+
}
|
|
3265
|
+
async function we(t, e) {
|
|
3266
|
+
const n = e.path, r = e.context, i = e.registry ?? new De(), s = e.warnings ?? [], o = e.visitStack ?? new Je(), {
|
|
2765
3267
|
source: a,
|
|
2766
3268
|
declarationUpdates: c
|
|
2767
|
-
} = await
|
|
2768
|
-
|
|
2769
|
-
|
|
3269
|
+
} = await fn(t, { path: n, context: { ...r } });
|
|
3270
|
+
An(
|
|
3271
|
+
v(r, c ?? {}),
|
|
2770
3272
|
s,
|
|
2771
3273
|
n
|
|
2772
3274
|
);
|
|
2773
|
-
const h = await
|
|
3275
|
+
const h = await Cn(a, {
|
|
2774
3276
|
path: n,
|
|
2775
3277
|
context: r,
|
|
2776
3278
|
declarationUpdates: c ?? {},
|
|
@@ -2780,19 +3282,19 @@ async function ge(t, e) {
|
|
|
2780
3282
|
visitStack: o,
|
|
2781
3283
|
warnings: s,
|
|
2782
3284
|
inComponent: e.inComponent ?? !1
|
|
2783
|
-
}), { source: l, context:
|
|
3285
|
+
}), { source: l, context: u } = h, { source: g, directives: w } = xn(l, {
|
|
2784
3286
|
path: n,
|
|
2785
3287
|
registry: i,
|
|
2786
|
-
context:
|
|
2787
|
-
}),
|
|
2788
|
-
if (
|
|
3288
|
+
context: u
|
|
3289
|
+
}), p = e.loader;
|
|
3290
|
+
if (w.length > 0 && !p)
|
|
2789
3291
|
throw new Error("loader is required when processing include directives");
|
|
2790
|
-
let
|
|
2791
|
-
return
|
|
2792
|
-
source:
|
|
2793
|
-
directives:
|
|
2794
|
-
context:
|
|
2795
|
-
loader:
|
|
3292
|
+
let x = g;
|
|
3293
|
+
return w.length > 0 && p && (x = await an({
|
|
3294
|
+
source: g,
|
|
3295
|
+
directives: w,
|
|
3296
|
+
context: u,
|
|
3297
|
+
loader: p,
|
|
2796
3298
|
root: e.root,
|
|
2797
3299
|
path: n,
|
|
2798
3300
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
@@ -2801,70 +3303,74 @@ async function ge(t, e) {
|
|
|
2801
3303
|
warnings: s,
|
|
2802
3304
|
registry: i,
|
|
2803
3305
|
constrainToRoot: e.constrainToRoot
|
|
2804
|
-
})),
|
|
2805
|
-
context:
|
|
3306
|
+
})), x = await nn(x, {
|
|
3307
|
+
context: u,
|
|
2806
3308
|
path: n,
|
|
2807
3309
|
registry: i,
|
|
2808
|
-
loader:
|
|
3310
|
+
loader: p,
|
|
2809
3311
|
rootDir: e.root,
|
|
2810
3312
|
warnings: s,
|
|
2811
3313
|
visitStack: o,
|
|
2812
|
-
parentContext:
|
|
3314
|
+
parentContext: u,
|
|
2813
3315
|
preserveHgComments: e.preserveHgComments,
|
|
2814
3316
|
constrainToRoot: e.constrainToRoot
|
|
2815
|
-
}),
|
|
3317
|
+
}), x = await Pe(x, u, {
|
|
2816
3318
|
path: n,
|
|
2817
3319
|
registry: i,
|
|
2818
|
-
loader:
|
|
3320
|
+
loader: p,
|
|
2819
3321
|
rootDir: e.root,
|
|
2820
3322
|
warnings: s,
|
|
2821
3323
|
visitStack: o,
|
|
2822
|
-
parentContext:
|
|
3324
|
+
parentContext: u,
|
|
2823
3325
|
preserveHgComments: e.preserveHgComments,
|
|
2824
3326
|
constrainToRoot: e.constrainToRoot
|
|
2825
|
-
}),
|
|
3327
|
+
}), x = zn(x, { path: n }), x = yn(x, e.preserveHgComments), x;
|
|
2826
3328
|
}
|
|
2827
|
-
async function
|
|
2828
|
-
const n = e.path, r =
|
|
3329
|
+
async function nt(t, e = {}) {
|
|
3330
|
+
const n = e.path, r = v(e.context), i = e.registry ?? new De(), s = e.warnings ?? [], o = e.visitStack ?? new Je(), { context: a, body: c, rawFrontMatter: h } = q(
|
|
2829
3331
|
t,
|
|
2830
3332
|
n
|
|
2831
|
-
), l =
|
|
2832
|
-
let
|
|
3333
|
+
), l = v(r, a);
|
|
3334
|
+
let u = await we(c, {
|
|
2833
3335
|
...e,
|
|
2834
3336
|
context: l,
|
|
2835
3337
|
registry: i,
|
|
2836
3338
|
warnings: s,
|
|
2837
3339
|
visitStack: o
|
|
2838
3340
|
});
|
|
2839
|
-
return
|
|
3341
|
+
return u = kn(u, {
|
|
2840
3342
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
2841
3343
|
rawFrontMatter: h
|
|
2842
3344
|
}), {
|
|
2843
|
-
markdown:
|
|
3345
|
+
markdown: u,
|
|
2844
3346
|
warnings: s
|
|
2845
3347
|
};
|
|
2846
3348
|
}
|
|
2847
|
-
async function
|
|
2848
|
-
const n = e.path, { context: r, body: i } =
|
|
2849
|
-
return
|
|
3349
|
+
async function Vn(t, e) {
|
|
3350
|
+
const n = e.path, { context: r, body: i } = q(t, n), s = v(e.context, r);
|
|
3351
|
+
return we(i, {
|
|
2850
3352
|
...e,
|
|
2851
3353
|
context: s,
|
|
2852
3354
|
preserveFrontMatter: !1
|
|
2853
3355
|
});
|
|
2854
3356
|
}
|
|
2855
|
-
async function
|
|
2856
|
-
const r =
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
3357
|
+
async function Zn(t, e, n) {
|
|
3358
|
+
const r = n?.loader ?? He(), i = await At(t, { root: n?.root }), s = i.rootDir ?? n?.root, o = n?.dataSources, a = o && Object.keys(o).length > 0 ? await Ne(o, { root: s, loader: r }) : {}, c = v(
|
|
3359
|
+
a,
|
|
3360
|
+
e,
|
|
3361
|
+
n?.serverContext
|
|
3362
|
+
);
|
|
3363
|
+
return nt(i.source, {
|
|
3364
|
+
context: c,
|
|
3365
|
+
loader: r,
|
|
3366
|
+
root: s,
|
|
3367
|
+
path: i.entryPath ?? n?.path,
|
|
3368
|
+
constrainToRoot: i.constrainToRoot,
|
|
2863
3369
|
preserveFrontMatter: n?.preserveFrontMatter,
|
|
2864
3370
|
preserveHgComments: n?.preserveHgComments
|
|
2865
3371
|
});
|
|
2866
3372
|
}
|
|
2867
|
-
async function
|
|
3373
|
+
async function hr(t, e, n) {
|
|
2868
3374
|
if (n != null && "serverContext" in n && n.serverContext != null)
|
|
2869
3375
|
throw d({
|
|
2870
3376
|
code: "server_context_on_client"
|
|
@@ -2881,8 +3387,8 @@ async function Hn(t, e, n) {
|
|
|
2881
3387
|
});
|
|
2882
3388
|
let i, s;
|
|
2883
3389
|
typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
|
|
2884
|
-
const o =
|
|
2885
|
-
return
|
|
3390
|
+
const o = v(e);
|
|
3391
|
+
return nt(i, {
|
|
2886
3392
|
context: o,
|
|
2887
3393
|
loader: r,
|
|
2888
3394
|
root: n?.root,
|
|
@@ -2892,8 +3398,8 @@ async function Hn(t, e, n) {
|
|
|
2892
3398
|
constrainToRoot: n?.constrainToRoot
|
|
2893
3399
|
});
|
|
2894
3400
|
}
|
|
2895
|
-
function
|
|
2896
|
-
if (
|
|
3401
|
+
function qn(t, e) {
|
|
3402
|
+
if (le(t))
|
|
2897
3403
|
throw d({
|
|
2898
3404
|
code: "parse_error",
|
|
2899
3405
|
path: e,
|
|
@@ -2901,21 +3407,21 @@ function ln(t, e) {
|
|
|
2901
3407
|
message: he(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2902
3408
|
}
|
|
2903
3409
|
});
|
|
2904
|
-
const n = [], r =
|
|
3410
|
+
const n = [], r = W(t);
|
|
2905
3411
|
for (const i of r) {
|
|
2906
|
-
const s =
|
|
3412
|
+
const s = C(i.inner);
|
|
2907
3413
|
if (s.length === 0)
|
|
2908
3414
|
throw d({
|
|
2909
3415
|
code: "parse_error",
|
|
2910
3416
|
path: e,
|
|
2911
3417
|
details: { message: "empty hyogen block" }
|
|
2912
3418
|
});
|
|
2913
|
-
if (s.length === 1 &&
|
|
3419
|
+
if (s.length === 1 && de(s[0]) || s.length === 1 && P(s[0]) || s.length === 1 && (ne(s[0]) || V(s[0])))
|
|
2914
3420
|
continue;
|
|
2915
3421
|
const o = s[0];
|
|
2916
3422
|
if (o === "endblock" || /^block\s+/.test(o))
|
|
2917
3423
|
continue;
|
|
2918
|
-
const a =
|
|
3424
|
+
const a = B(o, e);
|
|
2919
3425
|
if (a) {
|
|
2920
3426
|
n.push({ kind: "extend", path: a.path });
|
|
2921
3427
|
continue;
|
|
@@ -2923,8 +3429,8 @@ function ln(t, e) {
|
|
|
2923
3429
|
if (s.length !== 1) {
|
|
2924
3430
|
const c = s.join(`
|
|
2925
3431
|
`);
|
|
2926
|
-
if (
|
|
2927
|
-
(l) =>
|
|
3432
|
+
if (V(c) || s.every(
|
|
3433
|
+
(l) => ne(l) || B(l) !== null
|
|
2928
3434
|
))
|
|
2929
3435
|
continue;
|
|
2930
3436
|
throw d({
|
|
@@ -2934,12 +3440,12 @@ function ln(t, e) {
|
|
|
2934
3440
|
});
|
|
2935
3441
|
}
|
|
2936
3442
|
if (/^include\s+/i.test(o)) {
|
|
2937
|
-
const c =
|
|
3443
|
+
const c = tt(i.inner, e);
|
|
2938
3444
|
n.push({ kind: "include", path: c.path });
|
|
2939
3445
|
continue;
|
|
2940
3446
|
}
|
|
2941
3447
|
if (/^component\s+/i.test(o)) {
|
|
2942
|
-
const c =
|
|
3448
|
+
const c = et(i.inner, e);
|
|
2943
3449
|
n.push({ kind: "component", path: c.path });
|
|
2944
3450
|
continue;
|
|
2945
3451
|
}
|
|
@@ -2951,8 +3457,8 @@ function ln(t, e) {
|
|
|
2951
3457
|
}
|
|
2952
3458
|
return n;
|
|
2953
3459
|
}
|
|
2954
|
-
function
|
|
2955
|
-
return
|
|
3460
|
+
function Pn(t, e, n) {
|
|
3461
|
+
return N(t) ? t : Z(t, {
|
|
2956
3462
|
rootDir: n.root,
|
|
2957
3463
|
fromPath: e,
|
|
2958
3464
|
documentPath: e,
|
|
@@ -2960,19 +3466,19 @@ function dn(t, e, n) {
|
|
|
2960
3466
|
hyogenPath: !0
|
|
2961
3467
|
});
|
|
2962
3468
|
}
|
|
2963
|
-
async function
|
|
3469
|
+
async function Kn(t, e, n = {}) {
|
|
2964
3470
|
const r = t.map(
|
|
2965
|
-
(l) =>
|
|
3471
|
+
(l) => N(l) ? l : f.resolve(l)
|
|
2966
3472
|
), i = new Set(r), s = /* @__PURE__ */ new Set(), o = [], a = [...r];
|
|
2967
3473
|
for (; a.length > 0; ) {
|
|
2968
3474
|
const l = a.shift();
|
|
2969
3475
|
if (s.has(l))
|
|
2970
3476
|
continue;
|
|
2971
3477
|
s.add(l);
|
|
2972
|
-
const
|
|
2973
|
-
for (const
|
|
2974
|
-
const
|
|
2975
|
-
o.push({ from: l, to:
|
|
3478
|
+
const u = await e(l), g = qn(u, l);
|
|
3479
|
+
for (const w of g) {
|
|
3480
|
+
const p = Pn(w.path, l, n);
|
|
3481
|
+
o.push({ from: l, to: p, kind: w.kind }), s.has(p) || a.push(p);
|
|
2976
3482
|
}
|
|
2977
3483
|
}
|
|
2978
3484
|
const c = [...s], h = c.filter((l) => !i.has(l));
|
|
@@ -2983,22 +3489,22 @@ async function pn(t, e, n = {}) {
|
|
|
2983
3489
|
edges: o
|
|
2984
3490
|
};
|
|
2985
3491
|
}
|
|
2986
|
-
function
|
|
3492
|
+
function Yn(t) {
|
|
2987
3493
|
return t.replace(/\\/g, "/").split("/").filter((r) => r.length > 0).some((r) => r.startsWith("_"));
|
|
2988
3494
|
}
|
|
2989
|
-
function
|
|
2990
|
-
return
|
|
3495
|
+
function Xn(t) {
|
|
3496
|
+
return pt.scan(t).isGlob;
|
|
2991
3497
|
}
|
|
2992
|
-
function
|
|
2993
|
-
return t.root ?
|
|
3498
|
+
function Gn(t) {
|
|
3499
|
+
return t.root ? f.resolve(t.root) : t.cwd ? f.resolve(t.cwd) : I(process.cwd()) ?? process.cwd();
|
|
2994
3500
|
}
|
|
2995
|
-
async function
|
|
2996
|
-
const n = Array.isArray(t) ? t : [t], r =
|
|
3501
|
+
async function Jn(t, e = {}) {
|
|
3502
|
+
const n = Array.isArray(t) ? t : [t], r = Gn(e), i = e.includeUnderscoreEntries === !0, s = /* @__PURE__ */ new Map();
|
|
2997
3503
|
for (const o of n) {
|
|
2998
|
-
if (!
|
|
2999
|
-
const c =
|
|
3504
|
+
if (!Xn(o)) {
|
|
3505
|
+
const c = f.isAbsolute(o) ? f.resolve(o) : f.resolve(r, o);
|
|
3000
3506
|
try {
|
|
3001
|
-
if (!(await
|
|
3507
|
+
if (!(await se(c)).isFile())
|
|
3002
3508
|
throw d({
|
|
3003
3509
|
code: "file_not_found",
|
|
3004
3510
|
path: c,
|
|
@@ -3019,50 +3525,50 @@ async function gn(t, e = {}) {
|
|
|
3019
3525
|
}
|
|
3020
3526
|
}) : l;
|
|
3021
3527
|
}
|
|
3022
|
-
const h =
|
|
3528
|
+
const h = f.relative(r, c).replace(/\\/g, "/");
|
|
3023
3529
|
s.set(h, c);
|
|
3024
3530
|
continue;
|
|
3025
3531
|
}
|
|
3026
|
-
const a = await
|
|
3532
|
+
const a = await ft(o, {
|
|
3027
3533
|
cwd: r,
|
|
3028
3534
|
absolute: !0,
|
|
3029
3535
|
onlyFiles: !0,
|
|
3030
3536
|
dot: !1
|
|
3031
3537
|
});
|
|
3032
3538
|
for (const c of a) {
|
|
3033
|
-
const h =
|
|
3034
|
-
!i &&
|
|
3539
|
+
const h = f.relative(r, c).replace(/\\/g, "/");
|
|
3540
|
+
!i && Yn(h) || s.set(h, f.resolve(c));
|
|
3035
3541
|
}
|
|
3036
3542
|
}
|
|
3037
3543
|
return [...s.values()];
|
|
3038
3544
|
}
|
|
3039
|
-
function
|
|
3545
|
+
function Qn(t) {
|
|
3040
3546
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
3041
3547
|
}
|
|
3042
|
-
function
|
|
3548
|
+
function er(t, e) {
|
|
3043
3549
|
if (t)
|
|
3044
|
-
return
|
|
3550
|
+
return f.resolve(t);
|
|
3045
3551
|
for (const n of e) {
|
|
3046
|
-
const r =
|
|
3552
|
+
const r = I(n);
|
|
3047
3553
|
if (r)
|
|
3048
3554
|
return r;
|
|
3049
3555
|
}
|
|
3050
|
-
return e.length > 0 ?
|
|
3556
|
+
return e.length > 0 ? f.dirname(f.resolve(e[0])) : process.cwd();
|
|
3051
3557
|
}
|
|
3052
|
-
async function
|
|
3053
|
-
const e = await
|
|
3558
|
+
async function dr(t) {
|
|
3559
|
+
const e = await Jn(t.input, {
|
|
3054
3560
|
root: t.root,
|
|
3055
3561
|
includeUnderscoreEntries: t.includeUnderscoreEntries
|
|
3056
|
-
}), n =
|
|
3057
|
-
e.length > 0 && await
|
|
3562
|
+
}), n = er(t.root, e), r = t.loader ?? He(), i = I(n) !== void 0;
|
|
3563
|
+
e.length > 0 && await Kn(e, r, {
|
|
3058
3564
|
root: n,
|
|
3059
3565
|
constrainToRoot: i
|
|
3060
3566
|
});
|
|
3061
|
-
const s = [],
|
|
3062
|
-
for (const
|
|
3063
|
-
const
|
|
3064
|
-
{ path:
|
|
3065
|
-
|
|
3567
|
+
const s = t.dataSources, o = s && Object.keys(s).length > 0 ? await Ne(s, { root: n, loader: r }) : {}, a = v(o, t.context), c = [], h = [];
|
|
3568
|
+
for (const l of e) {
|
|
3569
|
+
const u = f.resolve(l), g = f.relative(n, u).replace(/\\/g, "/"), w = await Zn(
|
|
3570
|
+
{ path: u },
|
|
3571
|
+
a,
|
|
3066
3572
|
{
|
|
3067
3573
|
loader: r,
|
|
3068
3574
|
root: n,
|
|
@@ -3070,165 +3576,27 @@ async function jn(t) {
|
|
|
3070
3576
|
preserveFrontMatter: t.preserveFrontMatter,
|
|
3071
3577
|
preserveHgComments: t.preserveHgComments
|
|
3072
3578
|
}
|
|
3073
|
-
), p =
|
|
3579
|
+
), p = f.join(t.outDir, g);
|
|
3074
3580
|
try {
|
|
3075
|
-
await
|
|
3076
|
-
} catch (
|
|
3077
|
-
if (
|
|
3078
|
-
throw
|
|
3079
|
-
const
|
|
3581
|
+
await at(f.dirname(p), { recursive: !0 }), await ct(p, w.markdown, "utf8");
|
|
3582
|
+
} catch (x) {
|
|
3583
|
+
if (Qn(x))
|
|
3584
|
+
throw x;
|
|
3585
|
+
const $ = x instanceof Error ? x.message : "unknown write error";
|
|
3080
3586
|
throw d({
|
|
3081
3587
|
code: "load_failed",
|
|
3082
3588
|
path: p,
|
|
3083
3589
|
details: {
|
|
3084
3590
|
path: p,
|
|
3085
|
-
reason:
|
|
3086
|
-
}
|
|
3087
|
-
});
|
|
3088
|
-
}
|
|
3089
|
-
s.push({ path: h, markdown: l.markdown }), o.push(...l.warnings);
|
|
3090
|
-
}
|
|
3091
|
-
return { files: s, warnings: o };
|
|
3092
|
-
}
|
|
3093
|
-
function kn(t) {
|
|
3094
|
-
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
3095
|
-
}
|
|
3096
|
-
function yn(t) {
|
|
3097
|
-
return Object.keys(t).sort((e, n) => Number(e) - Number(n)).map((e) => t[e] ?? "");
|
|
3098
|
-
}
|
|
3099
|
-
function bn(t) {
|
|
3100
|
-
return t.every((e) => e === "");
|
|
3101
|
-
}
|
|
3102
|
-
async function vn(t) {
|
|
3103
|
-
return new Promise((e, n) => {
|
|
3104
|
-
const r = [];
|
|
3105
|
-
Je.from([t]).pipe(Xe({ headers: !1 })).on("data", (i) => {
|
|
3106
|
-
const s = yn(i);
|
|
3107
|
-
bn(s) || r.push(s);
|
|
3108
|
-
}).on("end", () => e(r)).on("error", (i) => n(i));
|
|
3109
|
-
});
|
|
3110
|
-
}
|
|
3111
|
-
async function _n(t, e) {
|
|
3112
|
-
if (t.length === 0 || t.trim().length === 0)
|
|
3113
|
-
throw d({
|
|
3114
|
-
code: "parse_error",
|
|
3115
|
-
path: e,
|
|
3116
|
-
details: { message: "empty CSV" }
|
|
3117
|
-
});
|
|
3118
|
-
let n;
|
|
3119
|
-
try {
|
|
3120
|
-
n = await vn(t);
|
|
3121
|
-
} catch (o) {
|
|
3122
|
-
throw kn(o) ? o : d({
|
|
3123
|
-
code: "parse_error",
|
|
3124
|
-
path: e,
|
|
3125
|
-
details: {
|
|
3126
|
-
message: o instanceof Error ? o.message : "invalid CSV"
|
|
3127
|
-
}
|
|
3128
|
-
});
|
|
3129
|
-
}
|
|
3130
|
-
if (n.length === 0)
|
|
3131
|
-
throw d({
|
|
3132
|
-
code: "parse_error",
|
|
3133
|
-
path: e,
|
|
3134
|
-
details: { message: "empty CSV" }
|
|
3135
|
-
});
|
|
3136
|
-
const [r, ...i] = n, s = r.length;
|
|
3137
|
-
for (const o of i)
|
|
3138
|
-
if (o.length !== s)
|
|
3139
|
-
throw d({
|
|
3140
|
-
code: "parse_error",
|
|
3141
|
-
path: e,
|
|
3142
|
-
details: { message: "CSV row column count mismatch" }
|
|
3143
|
-
});
|
|
3144
|
-
return i.map((o) => {
|
|
3145
|
-
const a = {};
|
|
3146
|
-
for (let c = 0; c < r.length; c++)
|
|
3147
|
-
a[r[c]] = o[c] ?? "";
|
|
3148
|
-
return a;
|
|
3149
|
-
});
|
|
3150
|
-
}
|
|
3151
|
-
function Sn(t) {
|
|
3152
|
-
return u.extname(t).slice(1).toLowerCase();
|
|
3153
|
-
}
|
|
3154
|
-
function Cn(t, e) {
|
|
3155
|
-
if (t.length === 0)
|
|
3156
|
-
throw d({
|
|
3157
|
-
code: "parse_error",
|
|
3158
|
-
path: e,
|
|
3159
|
-
details: { message: "empty data file" }
|
|
3160
|
-
});
|
|
3161
|
-
}
|
|
3162
|
-
async function En(t, e) {
|
|
3163
|
-
Cn(t, e);
|
|
3164
|
-
const n = Sn(e);
|
|
3165
|
-
switch (n) {
|
|
3166
|
-
case "json":
|
|
3167
|
-
try {
|
|
3168
|
-
return JSON.parse(t);
|
|
3169
|
-
} catch (r) {
|
|
3170
|
-
throw d({
|
|
3171
|
-
code: "parse_error",
|
|
3172
|
-
path: e,
|
|
3173
|
-
details: {
|
|
3174
|
-
message: r instanceof Error ? r.message : "invalid JSON"
|
|
3175
|
-
}
|
|
3176
|
-
});
|
|
3177
|
-
}
|
|
3178
|
-
case "yaml":
|
|
3179
|
-
case "yml":
|
|
3180
|
-
try {
|
|
3181
|
-
return Te(t);
|
|
3182
|
-
} catch (r) {
|
|
3183
|
-
throw d({
|
|
3184
|
-
code: "parse_error",
|
|
3185
|
-
path: e,
|
|
3186
|
-
details: {
|
|
3187
|
-
message: r instanceof Error ? r.message : "invalid YAML"
|
|
3188
|
-
}
|
|
3189
|
-
});
|
|
3190
|
-
}
|
|
3191
|
-
case "csv":
|
|
3192
|
-
return _n(t, e);
|
|
3193
|
-
default:
|
|
3194
|
-
throw d({
|
|
3195
|
-
code: "parse_error",
|
|
3196
|
-
path: e,
|
|
3197
|
-
details: {
|
|
3198
|
-
format: n,
|
|
3199
|
-
message: `unsupported data file format: ${n}`
|
|
3200
|
-
}
|
|
3201
|
-
});
|
|
3202
|
-
}
|
|
3203
|
-
}
|
|
3204
|
-
function Wn(t) {
|
|
3205
|
-
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
3206
|
-
}
|
|
3207
|
-
function $n(t) {
|
|
3208
|
-
return t?.root ? u.resolve(t.root) : F(process.cwd()) ?? process.cwd();
|
|
3209
|
-
}
|
|
3210
|
-
async function Fn(t, e) {
|
|
3211
|
-
const n = $n(e), r = e?.loader ?? ie(), i = {};
|
|
3212
|
-
for (const [s, o] of Object.entries(t)) {
|
|
3213
|
-
const a = V(o, { rootDir: n });
|
|
3214
|
-
let c;
|
|
3215
|
-
try {
|
|
3216
|
-
c = await r(a);
|
|
3217
|
-
} catch (h) {
|
|
3218
|
-
throw Wn(h) ? h : d({
|
|
3219
|
-
code: "load_failed",
|
|
3220
|
-
path: a,
|
|
3221
|
-
details: {
|
|
3222
|
-
path: a,
|
|
3223
|
-
reason: h instanceof Error ? h.message : "unknown load error"
|
|
3591
|
+
reason: $
|
|
3224
3592
|
}
|
|
3225
3593
|
});
|
|
3226
3594
|
}
|
|
3227
|
-
|
|
3595
|
+
c.push({ path: g, markdown: w.markdown }), h.push(...w.warnings);
|
|
3228
3596
|
}
|
|
3229
|
-
return
|
|
3597
|
+
return { files: c, warnings: h };
|
|
3230
3598
|
}
|
|
3231
|
-
function
|
|
3599
|
+
function ur(t, e) {
|
|
3232
3600
|
const n = [`[hyogen:${t}] ${e.code}`], r = {};
|
|
3233
3601
|
if (e.details)
|
|
3234
3602
|
for (const [i, s] of Object.entries(e.details))
|
|
@@ -3240,15 +3608,15 @@ function Bn(t, e) {
|
|
|
3240
3608
|
`);
|
|
3241
3609
|
}
|
|
3242
3610
|
export {
|
|
3243
|
-
|
|
3244
|
-
|
|
3611
|
+
dr as build,
|
|
3612
|
+
Me as createFsLoader,
|
|
3245
3613
|
d as createHyogenError,
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3614
|
+
He as createNodeLoader,
|
|
3615
|
+
ur as formatDiagnosticLog,
|
|
3616
|
+
mr as formatMessage,
|
|
3617
|
+
N as isRemotePath,
|
|
3618
|
+
Ne as loadDataSources,
|
|
3619
|
+
hr as renderClient,
|
|
3620
|
+
Zn as renderServer
|
|
3253
3621
|
};
|
|
3254
3622
|
//# sourceMappingURL=index.js.map
|