@b4moss/hyogen-md 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README_ja.md +1 -1
- package/dist/client.js +604 -389
- package/dist/index.js +997 -757
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { stat as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
function
|
|
1
|
+
import { stat as ie, readFile as Me, mkdir as Xe, writeFile as Je } from "node:fs/promises";
|
|
2
|
+
import p from "node:path";
|
|
3
|
+
import { parse as Oe } from "yaml";
|
|
4
|
+
import { Readable as Qe } from "node:stream";
|
|
5
|
+
import et from "csv-parser";
|
|
6
|
+
import { existsSync as ye, statSync as tt } from "node:fs";
|
|
7
|
+
import nt from "fast-glob";
|
|
8
|
+
import rt from "picomatch";
|
|
9
|
+
function v(...t) {
|
|
10
10
|
const e = {};
|
|
11
11
|
for (const n of t)
|
|
12
12
|
n != null && Object.assign(e, n);
|
|
13
13
|
return e;
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
errors:
|
|
17
|
-
warnings:
|
|
18
|
-
warningReasons:
|
|
19
|
-
},
|
|
20
|
-
function
|
|
15
|
+
const it = { file_not_found: "File not found: {path} (referenced from {from} via {via})", frontmatter_too_large: "Front matter exceeds size limit in {path} ({size} bytes, limit {limit})", duplicate_component_alias: 'Duplicate component alias "{alias}" in {path}', alias_collision: 'Component alias "{alias}" collides with an existing binding in {path}', forbidden_property_access: 'Forbidden property access "{property}" in {path}', parse_error: "Parse error in {path}: {message}", component_multiline_output: 'Component "{alias}" returned multiline output (single line required)', server_context_on_client: "serverContext is not allowed with renderClient", load_failed: "Failed to load {path}: {reason}", data_sources_on_client: "dataSources is not allowed with renderClient", data_source_too_large: "Data source exceeds size limit in {path} ({size} bytes, limit {limit})" }, st = { circular_include: "Circular reference detected; skipped {path} (referenced from {from} via {via})", nest_limit_exceeded: "Nesting limit exceeded ({limit}); skipped block in {path}", extend_in_component: "extend is not allowed inside a component; skipped in {path}", prop_type_mismatch: 'Prop "{prop}" type mismatch in component "{component}"; expected {expected}, got {actual}', prop_missing: 'Required prop "{prop}" is missing for component "{component}"', prop_unknown: 'Unknown prop "{prop}" passed to component "{component}"; ignored', suspicious_context_value: 'Suspicious value in context key "{key}" ({reason})' }, ot = { contains_html_script_tag: "contains HTML script tag", contains_event_handler: "contains inline event handler", contains_dangerous_scheme: "contains dangerous URL scheme", contains_embed_tag: "contains embeddable HTML tag", contains_meta_refresh: "contains meta refresh" }, se = {
|
|
16
|
+
errors: it,
|
|
17
|
+
warnings: st,
|
|
18
|
+
warningReasons: ot
|
|
19
|
+
}, at = se.errors, ct = se.warnings;
|
|
20
|
+
function Le(t, e) {
|
|
21
21
|
return t === void 0 ? "" : t.replace(/\{([^}]+)\}/g, (n, r) => {
|
|
22
22
|
if (e === void 0 || !(r in e))
|
|
23
23
|
return n;
|
|
@@ -25,24 +25,24 @@ function Ae(t, e) {
|
|
|
25
25
|
return i == null ? "" : String(i);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
28
|
+
function lt(t, e) {
|
|
29
|
+
return Le(at[t], e);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
31
|
+
function L(t, e) {
|
|
32
|
+
return Le(ct[t], e);
|
|
33
33
|
}
|
|
34
34
|
function d(t) {
|
|
35
|
-
const e = t.message ??
|
|
35
|
+
const e = t.message ?? lt(t.code, t.details), n = new Error(e);
|
|
36
36
|
return n.name = "HyogenError", n.code = t.code, n.message = e, n.path = t.path, n.details = t.details, n;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function ht(t) {
|
|
39
39
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function dt(t = {}) {
|
|
42
42
|
const { from: e, via: n = "include" } = t;
|
|
43
43
|
return async (r) => {
|
|
44
44
|
try {
|
|
45
|
-
if (!(await
|
|
45
|
+
if (!(await ie(r)).isFile())
|
|
46
46
|
throw d({
|
|
47
47
|
code: "load_failed",
|
|
48
48
|
path: e,
|
|
@@ -51,9 +51,9 @@ function ot(t = {}) {
|
|
|
51
51
|
reason: "not a file"
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
return await
|
|
54
|
+
return await Me(r, "utf8");
|
|
55
55
|
} catch (i) {
|
|
56
|
-
if (
|
|
56
|
+
if (ht(i))
|
|
57
57
|
throw i;
|
|
58
58
|
const s = i;
|
|
59
59
|
throw s.code === "ENOENT" ? d({
|
|
@@ -75,16 +75,16 @@ function ot(t = {}) {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function H(t) {
|
|
79
79
|
return /^https?:\/\//i.test(t);
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function ut(t) {
|
|
82
82
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
83
83
|
}
|
|
84
|
-
function
|
|
85
|
-
const { from: e, via: n = "include" } = t, r =
|
|
84
|
+
function oe(t = {}) {
|
|
85
|
+
const { from: e, via: n = "include" } = t, r = dt(t);
|
|
86
86
|
return async (i) => {
|
|
87
|
-
if (!
|
|
87
|
+
if (!H(i))
|
|
88
88
|
return r(i);
|
|
89
89
|
try {
|
|
90
90
|
const s = await fetch(i);
|
|
@@ -107,7 +107,7 @@ function ie(t = {}) {
|
|
|
107
107
|
});
|
|
108
108
|
return await s.text();
|
|
109
109
|
} catch (s) {
|
|
110
|
-
if (
|
|
110
|
+
if (ut(s))
|
|
111
111
|
throw s;
|
|
112
112
|
const o = s instanceof Error ? s.message : "unknown fetch error";
|
|
113
113
|
throw d({
|
|
@@ -121,29 +121,252 @@ function ie(t = {}) {
|
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
function pt(t) {
|
|
125
|
+
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
126
|
+
}
|
|
127
|
+
function ft(t) {
|
|
128
|
+
return Object.keys(t).sort((e, n) => Number(e) - Number(n)).map((e) => t[e] ?? "");
|
|
129
|
+
}
|
|
130
|
+
function mt(t) {
|
|
131
|
+
return t.every((e) => e === "");
|
|
132
|
+
}
|
|
133
|
+
async function gt(t) {
|
|
134
|
+
return new Promise((e, n) => {
|
|
135
|
+
const r = [];
|
|
136
|
+
Qe.from([t]).pipe(et({ headers: !1 })).on("data", (i) => {
|
|
137
|
+
const s = ft(i);
|
|
138
|
+
mt(s) || r.push(s);
|
|
139
|
+
}).on("end", () => e(r)).on("error", (i) => n(i));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async function wt(t, e) {
|
|
143
|
+
if (t.length === 0 || t.trim().length === 0)
|
|
144
|
+
throw d({
|
|
145
|
+
code: "parse_error",
|
|
146
|
+
path: e,
|
|
147
|
+
details: { message: "empty CSV" }
|
|
148
|
+
});
|
|
149
|
+
let n;
|
|
150
|
+
try {
|
|
151
|
+
n = await gt(t);
|
|
152
|
+
} catch (o) {
|
|
153
|
+
throw pt(o) ? o : d({
|
|
154
|
+
code: "parse_error",
|
|
155
|
+
path: e,
|
|
156
|
+
details: {
|
|
157
|
+
message: o instanceof Error ? o.message : "invalid CSV"
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (n.length === 0)
|
|
162
|
+
throw d({
|
|
163
|
+
code: "parse_error",
|
|
164
|
+
path: e,
|
|
165
|
+
details: { message: "empty CSV" }
|
|
166
|
+
});
|
|
167
|
+
const [r, ...i] = n, s = r.length;
|
|
168
|
+
for (const o of i)
|
|
169
|
+
if (o.length !== s)
|
|
170
|
+
throw d({
|
|
171
|
+
code: "parse_error",
|
|
172
|
+
path: e,
|
|
173
|
+
details: { message: "CSV row column count mismatch" }
|
|
174
|
+
});
|
|
175
|
+
return i.map((o) => {
|
|
176
|
+
const a = {};
|
|
177
|
+
for (let c = 0; c < r.length; c++)
|
|
178
|
+
a[r[c]] = o[c] ?? "";
|
|
179
|
+
return a;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function xt(t) {
|
|
183
|
+
return p.extname(t).slice(1).toLowerCase();
|
|
184
|
+
}
|
|
185
|
+
function kt(t, e) {
|
|
186
|
+
if (t.length === 0)
|
|
187
|
+
throw d({
|
|
188
|
+
code: "parse_error",
|
|
189
|
+
path: e,
|
|
190
|
+
details: { message: "empty data file" }
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
async function yt(t, e) {
|
|
194
|
+
kt(t, e);
|
|
195
|
+
const n = xt(e);
|
|
196
|
+
switch (n) {
|
|
197
|
+
case "json":
|
|
198
|
+
try {
|
|
199
|
+
return JSON.parse(t);
|
|
200
|
+
} catch (r) {
|
|
201
|
+
throw d({
|
|
202
|
+
code: "parse_error",
|
|
203
|
+
path: e,
|
|
204
|
+
details: {
|
|
205
|
+
message: r instanceof Error ? r.message : "invalid JSON"
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
case "yaml":
|
|
210
|
+
case "yml":
|
|
211
|
+
try {
|
|
212
|
+
return Oe(t);
|
|
213
|
+
} catch (r) {
|
|
214
|
+
throw d({
|
|
215
|
+
code: "parse_error",
|
|
216
|
+
path: e,
|
|
217
|
+
details: {
|
|
218
|
+
message: r instanceof Error ? r.message : "invalid YAML"
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
case "csv":
|
|
223
|
+
return wt(t, e);
|
|
224
|
+
default:
|
|
225
|
+
throw d({
|
|
226
|
+
code: "parse_error",
|
|
227
|
+
path: e,
|
|
228
|
+
details: {
|
|
229
|
+
format: n,
|
|
230
|
+
message: `unsupported data file format: ${n}`
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const bt = ".doc_root";
|
|
236
|
+
function B(t) {
|
|
126
237
|
let e;
|
|
127
|
-
for (
|
|
128
|
-
const n =
|
|
129
|
-
if (
|
|
238
|
+
for (ye(t) ? e = tt(t).isFile() ? p.dirname(t) : p.resolve(t) : e = p.dirname(p.resolve(t)); ; ) {
|
|
239
|
+
const n = p.join(e, bt);
|
|
240
|
+
if (ye(n))
|
|
130
241
|
return e;
|
|
131
|
-
const r =
|
|
242
|
+
const r = p.dirname(e);
|
|
132
243
|
if (r === e)
|
|
133
244
|
return;
|
|
134
245
|
e = r;
|
|
135
246
|
}
|
|
136
247
|
}
|
|
137
|
-
|
|
248
|
+
function vt(t, e) {
|
|
249
|
+
const n = p.relative(e, t);
|
|
250
|
+
return n === "" || !n.startsWith("..") && !p.isAbsolute(n);
|
|
251
|
+
}
|
|
252
|
+
function _t(t, e, n) {
|
|
253
|
+
const r = p.resolve(e), i = p.resolve(t);
|
|
254
|
+
if (!vt(i, r))
|
|
255
|
+
throw d({
|
|
256
|
+
code: "parse_error",
|
|
257
|
+
path: n,
|
|
258
|
+
details: { message: "path resolves outside root directory" }
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function Z(t, e = {}) {
|
|
262
|
+
const { rootDir: n, fromPath: r, documentPath: i, constrainToRoot: s = !1, hyogenPath: o = !1 } = e;
|
|
263
|
+
if (t.length === 0)
|
|
264
|
+
throw d({
|
|
265
|
+
code: "parse_error",
|
|
266
|
+
path: i,
|
|
267
|
+
details: { message: "empty template path" }
|
|
268
|
+
});
|
|
269
|
+
let a;
|
|
270
|
+
if (t.startsWith("/"))
|
|
271
|
+
if (n)
|
|
272
|
+
a = p.resolve(n, t.slice(1));
|
|
273
|
+
else {
|
|
274
|
+
if (o)
|
|
275
|
+
throw d({
|
|
276
|
+
code: "parse_error",
|
|
277
|
+
path: i,
|
|
278
|
+
details: { message: "root-relative paths require a doc root" }
|
|
279
|
+
});
|
|
280
|
+
if (p.isAbsolute(t))
|
|
281
|
+
a = p.resolve(t);
|
|
282
|
+
else
|
|
283
|
+
throw d({
|
|
284
|
+
code: "parse_error",
|
|
285
|
+
path: i,
|
|
286
|
+
details: { message: "root-relative paths require a doc root" }
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
else if (t.startsWith("./") || t.startsWith("../"))
|
|
290
|
+
if (r)
|
|
291
|
+
a = p.resolve(p.dirname(r), t);
|
|
292
|
+
else if (n)
|
|
293
|
+
a = p.resolve(n, t);
|
|
294
|
+
else
|
|
295
|
+
throw d({
|
|
296
|
+
code: "parse_error",
|
|
297
|
+
path: i,
|
|
298
|
+
details: { message: "root is required for relative template paths" }
|
|
299
|
+
});
|
|
300
|
+
else if (p.isAbsolute(t))
|
|
301
|
+
a = p.resolve(t);
|
|
302
|
+
else if (n)
|
|
303
|
+
a = p.resolve(n, t);
|
|
304
|
+
else
|
|
305
|
+
throw d({
|
|
306
|
+
code: "parse_error",
|
|
307
|
+
path: i,
|
|
308
|
+
details: { message: "root is required for relative template paths" }
|
|
309
|
+
});
|
|
310
|
+
return n && s && _t(a, n, i), a;
|
|
311
|
+
}
|
|
312
|
+
const be = 5 * 1024 * 1024;
|
|
313
|
+
function St(t) {
|
|
314
|
+
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
315
|
+
}
|
|
316
|
+
function Ct(t) {
|
|
317
|
+
return t?.root ? p.resolve(t.root) : B(process.cwd()) ?? process.cwd();
|
|
318
|
+
}
|
|
319
|
+
async function He(t, e) {
|
|
320
|
+
const n = Ct(e), r = e?.loader ?? oe(), i = {};
|
|
321
|
+
for (const [s, o] of Object.entries(t)) {
|
|
322
|
+
if (H(o))
|
|
323
|
+
throw d({
|
|
324
|
+
code: "load_failed",
|
|
325
|
+
path: o,
|
|
326
|
+
details: {
|
|
327
|
+
path: o,
|
|
328
|
+
reason: "remote data sources are not supported"
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
const a = Z(o, { rootDir: n });
|
|
332
|
+
let c;
|
|
333
|
+
try {
|
|
334
|
+
c = await r(a);
|
|
335
|
+
} catch (l) {
|
|
336
|
+
throw St(l) ? l : d({
|
|
337
|
+
code: "load_failed",
|
|
338
|
+
path: a,
|
|
339
|
+
details: {
|
|
340
|
+
path: a,
|
|
341
|
+
reason: l instanceof Error ? l.message : "unknown load error"
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
const h = Buffer.byteLength(c, "utf8");
|
|
346
|
+
if (h > be)
|
|
347
|
+
throw d({
|
|
348
|
+
code: "data_source_too_large",
|
|
349
|
+
path: a,
|
|
350
|
+
details: {
|
|
351
|
+
path: a,
|
|
352
|
+
size: h,
|
|
353
|
+
limit: be
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
i[s] = await yt(c, a);
|
|
357
|
+
}
|
|
358
|
+
return i;
|
|
359
|
+
}
|
|
360
|
+
async function Et(t, e) {
|
|
138
361
|
if (typeof t == "string")
|
|
139
362
|
return {
|
|
140
363
|
source: t,
|
|
141
364
|
rootDir: e?.root
|
|
142
365
|
};
|
|
143
|
-
const n =
|
|
366
|
+
const n = p.resolve(t.path);
|
|
144
367
|
let r;
|
|
145
368
|
try {
|
|
146
|
-
r = await
|
|
369
|
+
r = await ie(n);
|
|
147
370
|
} catch (a) {
|
|
148
371
|
const c = a;
|
|
149
372
|
throw c.code === "ENOENT" ? d({
|
|
@@ -171,7 +394,7 @@ async function ht(t, e) {
|
|
|
171
394
|
});
|
|
172
395
|
let i;
|
|
173
396
|
try {
|
|
174
|
-
i = await
|
|
397
|
+
i = await Me(n, "utf8");
|
|
175
398
|
} catch (a) {
|
|
176
399
|
throw d({
|
|
177
400
|
code: "load_failed",
|
|
@@ -182,7 +405,7 @@ async function ht(t, e) {
|
|
|
182
405
|
}
|
|
183
406
|
});
|
|
184
407
|
}
|
|
185
|
-
const s =
|
|
408
|
+
const s = B(n), o = e?.root ?? s;
|
|
186
409
|
return {
|
|
187
410
|
source: i,
|
|
188
411
|
rootDir: o,
|
|
@@ -190,7 +413,7 @@ async function ht(t, e) {
|
|
|
190
413
|
constrainToRoot: s !== void 0
|
|
191
414
|
};
|
|
192
415
|
}
|
|
193
|
-
class
|
|
416
|
+
class De {
|
|
194
417
|
components = /* @__PURE__ */ new Map();
|
|
195
418
|
register(e, n, r) {
|
|
196
419
|
if (this.components.has(e.alias))
|
|
@@ -214,8 +437,8 @@ class Re {
|
|
|
214
437
|
return this.components.has(e);
|
|
215
438
|
}
|
|
216
439
|
}
|
|
217
|
-
const
|
|
218
|
-
function
|
|
440
|
+
const ve = 64 * 1024;
|
|
441
|
+
function V(t, e) {
|
|
219
442
|
if (!t.startsWith("---"))
|
|
220
443
|
return { context: {}, body: t };
|
|
221
444
|
const n = t.indexOf(`
|
|
@@ -227,13 +450,13 @@ function U(t, e) {
|
|
|
227
450
|
if (r === -1)
|
|
228
451
|
return { context: {}, body: t };
|
|
229
452
|
const i = t.slice(n + 1, r), s = Buffer.byteLength(i, "utf8");
|
|
230
|
-
if (s >
|
|
453
|
+
if (s > ve)
|
|
231
454
|
throw d({
|
|
232
455
|
code: "frontmatter_too_large",
|
|
233
456
|
path: e,
|
|
234
457
|
details: {
|
|
235
458
|
size: s,
|
|
236
|
-
limit:
|
|
459
|
+
limit: ve
|
|
237
460
|
}
|
|
238
461
|
});
|
|
239
462
|
if (i.trim().length === 0)
|
|
@@ -244,7 +467,7 @@ function U(t, e) {
|
|
|
244
467
|
});
|
|
245
468
|
let o;
|
|
246
469
|
try {
|
|
247
|
-
const h =
|
|
470
|
+
const h = Oe(i);
|
|
248
471
|
if (h == null)
|
|
249
472
|
o = {};
|
|
250
473
|
else if (typeof h == "object" && !Array.isArray(h))
|
|
@@ -272,14 +495,14 @@ ${i}
|
|
|
272
495
|
---`
|
|
273
496
|
};
|
|
274
497
|
}
|
|
275
|
-
const
|
|
498
|
+
const $t = /* @__PURE__ */ new Set([
|
|
276
499
|
"string",
|
|
277
500
|
"number",
|
|
278
501
|
"boolean",
|
|
279
502
|
"object",
|
|
280
503
|
"array"
|
|
281
504
|
]);
|
|
282
|
-
function
|
|
505
|
+
function Wt(t, e) {
|
|
283
506
|
const n = t.props;
|
|
284
507
|
if (n === void 0)
|
|
285
508
|
return {};
|
|
@@ -298,13 +521,13 @@ function dt(t, e) {
|
|
|
298
521
|
const o = s, a = {};
|
|
299
522
|
if ("type" in o && o.type !== void 0) {
|
|
300
523
|
const c = String(o.type);
|
|
301
|
-
|
|
524
|
+
$t.has(c) ? a.type = c : a.type = void 0;
|
|
302
525
|
}
|
|
303
526
|
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[i] = a;
|
|
304
527
|
}
|
|
305
528
|
return r;
|
|
306
529
|
}
|
|
307
|
-
function
|
|
530
|
+
function Tt(t) {
|
|
308
531
|
if (t != null) {
|
|
309
532
|
if (typeof t == "string") return "string";
|
|
310
533
|
if (typeof t == "number") return "number";
|
|
@@ -313,30 +536,30 @@ function pt(t) {
|
|
|
313
536
|
if (typeof t == "object") return "object";
|
|
314
537
|
}
|
|
315
538
|
}
|
|
316
|
-
function
|
|
539
|
+
function At(t, e) {
|
|
317
540
|
return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
|
|
318
541
|
}
|
|
319
|
-
function
|
|
542
|
+
function G(t, e) {
|
|
320
543
|
return {
|
|
321
544
|
code: t,
|
|
322
|
-
message:
|
|
545
|
+
message: L(t, e),
|
|
323
546
|
details: e
|
|
324
547
|
};
|
|
325
548
|
}
|
|
326
|
-
function
|
|
549
|
+
function Rt(t, e, n) {
|
|
327
550
|
const r = [], i = {}, s = new Set(Object.keys(e));
|
|
328
551
|
for (const [o, a] of Object.entries(e)) {
|
|
329
552
|
const c = Object.prototype.hasOwnProperty.call(t, o);
|
|
330
553
|
let h = c ? t[o] : void 0;
|
|
331
554
|
if (c || (a.default !== void 0 ? h = a.default : (a.isRequired && r.push(
|
|
332
|
-
|
|
555
|
+
G("prop_missing", {
|
|
333
556
|
prop: o,
|
|
334
557
|
component: n
|
|
335
558
|
})
|
|
336
559
|
), h = void 0)), c && h !== void 0 && h !== null) {
|
|
337
|
-
const l = a.type ??
|
|
338
|
-
l && !
|
|
339
|
-
|
|
560
|
+
const l = a.type ?? Tt(h);
|
|
561
|
+
l && !At(h, l) && (r.push(
|
|
562
|
+
G("prop_type_mismatch", {
|
|
340
563
|
prop: o,
|
|
341
564
|
component: n,
|
|
342
565
|
expected: l,
|
|
@@ -348,78 +571,14 @@ function ft(t, e, n) {
|
|
|
348
571
|
}
|
|
349
572
|
for (const o of Object.keys(t))
|
|
350
573
|
s.has(o) || (Object.keys(e).length > 0 ? r.push(
|
|
351
|
-
|
|
574
|
+
G("prop_unknown", {
|
|
352
575
|
prop: o,
|
|
353
576
|
component: n
|
|
354
577
|
})
|
|
355
578
|
) : i[o] = t[o]);
|
|
356
579
|
return { values: i, warnings: r };
|
|
357
580
|
}
|
|
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) {
|
|
581
|
+
async function Mt(t) {
|
|
423
582
|
const e = t.registry.get(t.alias);
|
|
424
583
|
if (!e)
|
|
425
584
|
throw d({
|
|
@@ -429,24 +588,24 @@ async function wt(t) {
|
|
|
429
588
|
message: `unregistered component: ${t.alias}`
|
|
430
589
|
}
|
|
431
590
|
});
|
|
432
|
-
const n =
|
|
591
|
+
const n = H(e.componentPath) ? e.componentPath : Z(e.componentPath, {
|
|
433
592
|
rootDir: t.rootDir,
|
|
434
593
|
fromPath: e.definedAt,
|
|
435
594
|
documentPath: t.path,
|
|
436
595
|
constrainToRoot: t.constrainToRoot,
|
|
437
596
|
hyogenPath: !0
|
|
438
|
-
}), r = await t.loader(n), { context: i, body: s } =
|
|
597
|
+
}), r = await t.loader(n), { context: i, body: s } = V(r, n), o = Wt(i, n), { values: a, warnings: c } = Rt(
|
|
439
598
|
t.props,
|
|
440
599
|
o,
|
|
441
600
|
t.alias
|
|
442
601
|
);
|
|
443
602
|
t.warnings.push(...c);
|
|
444
|
-
const { props: h, ...l } = i,
|
|
603
|
+
const { props: h, ...l } = i, u = v(
|
|
445
604
|
t.parentContext,
|
|
446
605
|
l,
|
|
447
606
|
a
|
|
448
|
-
),
|
|
449
|
-
context:
|
|
607
|
+
), m = (await xe(s, {
|
|
608
|
+
context: u,
|
|
450
609
|
loader: t.loader,
|
|
451
610
|
root: t.rootDir,
|
|
452
611
|
path: n,
|
|
@@ -458,40 +617,44 @@ async function wt(t) {
|
|
|
458
617
|
preserveHgComments: t.preserveHgComments,
|
|
459
618
|
constrainToRoot: t.constrainToRoot
|
|
460
619
|
})).trim();
|
|
461
|
-
if (
|
|
620
|
+
if (m.includes(`
|
|
462
621
|
`))
|
|
463
622
|
throw d({
|
|
464
623
|
code: "component_multiline_output",
|
|
465
624
|
path: n,
|
|
466
625
|
details: { alias: t.alias }
|
|
467
626
|
});
|
|
468
|
-
return
|
|
627
|
+
return m;
|
|
469
628
|
}
|
|
470
|
-
const
|
|
629
|
+
const Ot = /* @__PURE__ */ new Set([
|
|
471
630
|
"__proto__",
|
|
472
631
|
"prototype",
|
|
473
632
|
"constructor",
|
|
474
633
|
"__defineGetter__"
|
|
475
634
|
]);
|
|
476
|
-
function
|
|
477
|
-
return
|
|
635
|
+
function Lt(t) {
|
|
636
|
+
return Ot.has(t);
|
|
478
637
|
}
|
|
479
|
-
function
|
|
480
|
-
if (
|
|
638
|
+
function _e(t, e) {
|
|
639
|
+
if (Lt(t))
|
|
481
640
|
throw d({
|
|
482
641
|
code: "forbidden_property_access",
|
|
483
642
|
path: e,
|
|
484
643
|
details: { property: t }
|
|
485
644
|
});
|
|
486
645
|
}
|
|
487
|
-
function
|
|
646
|
+
function M(t) {
|
|
488
647
|
return !t;
|
|
489
648
|
}
|
|
490
|
-
function
|
|
491
|
-
if (t != null
|
|
492
|
-
|
|
649
|
+
function Ht(t, e) {
|
|
650
|
+
if (t != null) {
|
|
651
|
+
if (typeof t == "string")
|
|
652
|
+
return e === "length" ? t.length : void 0;
|
|
653
|
+
if (typeof t == "object")
|
|
654
|
+
return t[e];
|
|
655
|
+
}
|
|
493
656
|
}
|
|
494
|
-
function
|
|
657
|
+
function Dt(t, e, n) {
|
|
495
658
|
switch (t) {
|
|
496
659
|
case "+":
|
|
497
660
|
return e + n;
|
|
@@ -518,9 +681,9 @@ function bt(t, e, n) {
|
|
|
518
681
|
case "<":
|
|
519
682
|
return e < n;
|
|
520
683
|
case "&&":
|
|
521
|
-
return
|
|
684
|
+
return M(e) ? e : n;
|
|
522
685
|
case "||":
|
|
523
|
-
return
|
|
686
|
+
return M(e) ? n : e;
|
|
524
687
|
default:
|
|
525
688
|
return;
|
|
526
689
|
}
|
|
@@ -531,15 +694,15 @@ async function k(t, e) {
|
|
|
531
694
|
case "literal":
|
|
532
695
|
return t.value;
|
|
533
696
|
case "identifier":
|
|
534
|
-
return
|
|
697
|
+
return _e(t.name, r), n[t.name];
|
|
535
698
|
case "member": {
|
|
536
|
-
|
|
699
|
+
_e(t.property, r);
|
|
537
700
|
const i = await k(t.object, e);
|
|
538
|
-
return
|
|
701
|
+
return Ht(i, t.property);
|
|
539
702
|
}
|
|
540
703
|
case "default": {
|
|
541
704
|
const i = await k(t.left, e);
|
|
542
|
-
return
|
|
705
|
+
return M(i) ? k(t.right, e) : i;
|
|
543
706
|
}
|
|
544
707
|
case "unary": {
|
|
545
708
|
const i = await k(t.operand, e);
|
|
@@ -548,14 +711,14 @@ async function k(t, e) {
|
|
|
548
711
|
case "binary": {
|
|
549
712
|
if (t.op === "&&") {
|
|
550
713
|
const o = await k(t.left, e);
|
|
551
|
-
return
|
|
714
|
+
return M(o) ? o : k(t.right, e);
|
|
552
715
|
}
|
|
553
716
|
if (t.op === "||") {
|
|
554
717
|
const o = await k(t.left, e);
|
|
555
|
-
return
|
|
718
|
+
return M(o) ? k(t.right, e) : o;
|
|
556
719
|
}
|
|
557
720
|
const i = await k(t.left, e), s = await k(t.right, e);
|
|
558
|
-
return
|
|
721
|
+
return Dt(t.op, i, s);
|
|
559
722
|
}
|
|
560
723
|
case "call": {
|
|
561
724
|
if (!e.registry || !e.loader || !e.visitStack)
|
|
@@ -577,7 +740,7 @@ async function k(t, e) {
|
|
|
577
740
|
const i = {};
|
|
578
741
|
for (const [s, o] of Object.entries(t.args))
|
|
579
742
|
i[s] = await k(o, e);
|
|
580
|
-
return
|
|
743
|
+
return Mt({
|
|
581
744
|
alias: t.callee,
|
|
582
745
|
props: i,
|
|
583
746
|
parentContext: e.parentContext ?? n,
|
|
@@ -605,7 +768,7 @@ async function k(t, e) {
|
|
|
605
768
|
}
|
|
606
769
|
case "ternary": {
|
|
607
770
|
const i = await k(t.condition, e);
|
|
608
|
-
return
|
|
771
|
+
return M(i) ? k(t.alternate, e) : k(t.consequent, e);
|
|
609
772
|
}
|
|
610
773
|
case "template": {
|
|
611
774
|
let i = "";
|
|
@@ -622,29 +785,29 @@ async function k(t, e) {
|
|
|
622
785
|
return;
|
|
623
786
|
}
|
|
624
787
|
}
|
|
625
|
-
function
|
|
788
|
+
function X(t) {
|
|
626
789
|
return /[A-Za-z_$]/.test(t);
|
|
627
790
|
}
|
|
628
|
-
function
|
|
791
|
+
function Nt(t) {
|
|
629
792
|
return /[A-Za-z0-9_$]/.test(t);
|
|
630
793
|
}
|
|
631
794
|
function S(t, e, n = {}) {
|
|
632
795
|
const r = t.trim();
|
|
633
796
|
if (r.length === 0)
|
|
634
|
-
throw
|
|
635
|
-
const i = new
|
|
797
|
+
throw g(e, "empty expression");
|
|
798
|
+
const i = new Ft(r, e, n), s = i.parseExpression();
|
|
636
799
|
if (i.skipWhitespace(), i.hasMore())
|
|
637
|
-
throw
|
|
800
|
+
throw g(e, `unexpected token at position ${i.position}`);
|
|
638
801
|
return s;
|
|
639
802
|
}
|
|
640
|
-
function
|
|
803
|
+
function g(t, e) {
|
|
641
804
|
throw d({
|
|
642
805
|
code: "parse_error",
|
|
643
806
|
path: t,
|
|
644
807
|
details: { message: e }
|
|
645
808
|
});
|
|
646
809
|
}
|
|
647
|
-
class
|
|
810
|
+
class Ft {
|
|
648
811
|
constructor(e, n, r = {}) {
|
|
649
812
|
this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
|
|
650
813
|
}
|
|
@@ -681,7 +844,7 @@ class _t {
|
|
|
681
844
|
this.index++;
|
|
682
845
|
const n = this.parseTernary();
|
|
683
846
|
if (this.skipWhitespace(), this.peek() !== ":")
|
|
684
|
-
throw
|
|
847
|
+
throw g(this.path, "expected ':' in ternary expression");
|
|
685
848
|
this.index++;
|
|
686
849
|
const r = this.parseTernary();
|
|
687
850
|
return { type: "ternary", condition: e, consequent: n, alternate: r };
|
|
@@ -774,10 +937,10 @@ class _t {
|
|
|
774
937
|
this.skipWhitespace();
|
|
775
938
|
const n = this.readIdentifier();
|
|
776
939
|
if (!n)
|
|
777
|
-
throw
|
|
940
|
+
throw g(this.path, "expected property name after '.'");
|
|
778
941
|
if (this.skipWhitespace(), this.peek() === "(") {
|
|
779
942
|
if (n !== "toLocaleString")
|
|
780
|
-
throw
|
|
943
|
+
throw g(this.path, `unsupported method: ${n}()`);
|
|
781
944
|
this.index++;
|
|
782
945
|
const r = this.parseMethodArgs();
|
|
783
946
|
return { type: "method", object: e, method: n, args: r };
|
|
@@ -792,7 +955,7 @@ class _t {
|
|
|
792
955
|
for (e.push(this.parseLiteralValue()), this.skipWhitespace(); this.peek() === ","; )
|
|
793
956
|
this.index++, e.push(this.parseLiteralValue()), this.skipWhitespace();
|
|
794
957
|
if (this.peek() !== ")")
|
|
795
|
-
throw
|
|
958
|
+
throw g(this.path, "expected ')' after method arguments");
|
|
796
959
|
return this.index++, e;
|
|
797
960
|
}
|
|
798
961
|
parsePrimary() {
|
|
@@ -802,7 +965,7 @@ class _t {
|
|
|
802
965
|
this.index++;
|
|
803
966
|
const n = this.parseExpression();
|
|
804
967
|
if (this.skipWhitespace(), this.peek() !== ")")
|
|
805
|
-
throw
|
|
968
|
+
throw g(this.path, "expected ')'");
|
|
806
969
|
return this.index++, n;
|
|
807
970
|
}
|
|
808
971
|
if (e === "`")
|
|
@@ -815,13 +978,13 @@ class _t {
|
|
|
815
978
|
return { type: "literal", value: this.parseObjectLiteral() };
|
|
816
979
|
if (e === "[")
|
|
817
980
|
return { type: "literal", value: this.parseArrayLiteral() };
|
|
818
|
-
if (
|
|
981
|
+
if (X(e)) {
|
|
819
982
|
const n = this.readIdentifier();
|
|
820
983
|
if (n === "true" || n === "false" || n === "null" || n === "undefined")
|
|
821
984
|
return { type: "literal", value: n === "true" ? !0 : n === "false" ? !1 : n === "null" ? null : void 0 };
|
|
822
985
|
if (this.skipWhitespace(), this.peek() === "(") {
|
|
823
986
|
if (!this.allowCalls)
|
|
824
|
-
throw
|
|
987
|
+
throw g(
|
|
825
988
|
this.path,
|
|
826
989
|
"component calls are not allowed in template literals"
|
|
827
990
|
);
|
|
@@ -830,10 +993,10 @@ class _t {
|
|
|
830
993
|
return { type: "call", callee: n, args: r };
|
|
831
994
|
}
|
|
832
995
|
if (this.peek() === "[")
|
|
833
|
-
throw
|
|
996
|
+
throw g(this.path, "bracket access is not allowed");
|
|
834
997
|
return { type: "identifier", name: n };
|
|
835
998
|
}
|
|
836
|
-
throw
|
|
999
|
+
throw g(this.path, `unexpected character '${e}'`);
|
|
837
1000
|
}
|
|
838
1001
|
parseTemplateLiteral() {
|
|
839
1002
|
this.index++;
|
|
@@ -845,7 +1008,7 @@ class _t {
|
|
|
845
1008
|
return this.index++, e.push(n), { type: "template", parts: e };
|
|
846
1009
|
if (r === "\\") {
|
|
847
1010
|
if (this.index++, this.index >= this.input.length)
|
|
848
|
-
throw
|
|
1011
|
+
throw g(this.path, "unterminated template literal escape");
|
|
849
1012
|
n += this.input[this.index], this.index++;
|
|
850
1013
|
continue;
|
|
851
1014
|
}
|
|
@@ -859,7 +1022,7 @@ class _t {
|
|
|
859
1022
|
}
|
|
860
1023
|
n += r, this.index++;
|
|
861
1024
|
}
|
|
862
|
-
throw
|
|
1025
|
+
throw g(this.path, "unterminated template literal");
|
|
863
1026
|
}
|
|
864
1027
|
readTemplateExpression() {
|
|
865
1028
|
let e = 1;
|
|
@@ -893,27 +1056,27 @@ class _t {
|
|
|
893
1056
|
}
|
|
894
1057
|
this.index++;
|
|
895
1058
|
}
|
|
896
|
-
throw
|
|
1059
|
+
throw g(this.path, "unterminated template expression");
|
|
897
1060
|
}
|
|
898
1061
|
parseCallArgs() {
|
|
899
1062
|
if (this.skipWhitespace(), this.peek() === ")")
|
|
900
1063
|
return this.index++, {};
|
|
901
1064
|
if (this.peek() !== "{")
|
|
902
|
-
throw
|
|
1065
|
+
throw g(this.path, "expected object literal");
|
|
903
1066
|
this.index++, this.skipWhitespace();
|
|
904
1067
|
const e = {};
|
|
905
1068
|
if (this.peek() === "}") {
|
|
906
1069
|
if (this.index++, this.skipWhitespace(), this.peek() !== ")")
|
|
907
|
-
throw
|
|
1070
|
+
throw g(this.path, "expected ')' after call arguments");
|
|
908
1071
|
return this.index++, e;
|
|
909
1072
|
}
|
|
910
1073
|
for (; ; ) {
|
|
911
1074
|
this.skipWhitespace();
|
|
912
1075
|
const n = this.readIdentifier();
|
|
913
1076
|
if (!n)
|
|
914
|
-
throw
|
|
1077
|
+
throw g(this.path, "expected property name in object literal");
|
|
915
1078
|
if (this.skipWhitespace(), this.peek() !== ":")
|
|
916
|
-
throw
|
|
1079
|
+
throw g(this.path, "expected ':' in object literal");
|
|
917
1080
|
if (this.index++, this.skipWhitespace(), e[n] = this.parseTernary(), this.skipWhitespace(), this.peek() === "}") {
|
|
918
1081
|
this.index++;
|
|
919
1082
|
break;
|
|
@@ -925,15 +1088,15 @@ class _t {
|
|
|
925
1088
|
}
|
|
926
1089
|
continue;
|
|
927
1090
|
}
|
|
928
|
-
throw
|
|
1091
|
+
throw g(this.path, "expected ',' or '}' in object literal");
|
|
929
1092
|
}
|
|
930
1093
|
if (this.skipWhitespace(), this.peek() !== ")")
|
|
931
|
-
throw
|
|
1094
|
+
throw g(this.path, "expected ')' after call arguments");
|
|
932
1095
|
return this.index++, e;
|
|
933
1096
|
}
|
|
934
1097
|
parseObjectLiteral() {
|
|
935
1098
|
if (this.peek() !== "{")
|
|
936
|
-
throw
|
|
1099
|
+
throw g(this.path, "expected object literal");
|
|
937
1100
|
this.index++, this.skipWhitespace();
|
|
938
1101
|
const e = {};
|
|
939
1102
|
if (this.peek() === "}")
|
|
@@ -942,9 +1105,9 @@ class _t {
|
|
|
942
1105
|
this.skipWhitespace();
|
|
943
1106
|
const n = this.readIdentifier();
|
|
944
1107
|
if (!n)
|
|
945
|
-
throw
|
|
1108
|
+
throw g(this.path, "expected property name in object literal");
|
|
946
1109
|
if (this.skipWhitespace(), this.peek() !== ":")
|
|
947
|
-
throw
|
|
1110
|
+
throw g(this.path, "expected ':' in object literal");
|
|
948
1111
|
if (this.index++, this.skipWhitespace(), e[n] = this.parseLiteralValue(), this.skipWhitespace(), this.peek() === "}") {
|
|
949
1112
|
this.index++;
|
|
950
1113
|
break;
|
|
@@ -955,13 +1118,13 @@ class _t {
|
|
|
955
1118
|
break;
|
|
956
1119
|
}
|
|
957
1120
|
} else
|
|
958
|
-
throw
|
|
1121
|
+
throw g(this.path, "expected ',' or '}' in object literal");
|
|
959
1122
|
}
|
|
960
1123
|
return e;
|
|
961
1124
|
}
|
|
962
1125
|
parseArrayLiteral() {
|
|
963
1126
|
if (this.peek() !== "[")
|
|
964
|
-
throw
|
|
1127
|
+
throw g(this.path, "expected array literal");
|
|
965
1128
|
this.index++, this.skipWhitespace();
|
|
966
1129
|
const e = [];
|
|
967
1130
|
if (this.peek() === "]")
|
|
@@ -977,7 +1140,7 @@ class _t {
|
|
|
977
1140
|
break;
|
|
978
1141
|
}
|
|
979
1142
|
} else
|
|
980
|
-
throw
|
|
1143
|
+
throw g(this.path, "expected ',' or ']' in array literal");
|
|
981
1144
|
}
|
|
982
1145
|
return e;
|
|
983
1146
|
}
|
|
@@ -992,14 +1155,14 @@ class _t {
|
|
|
992
1155
|
return this.parseObjectLiteral();
|
|
993
1156
|
if (e === "[")
|
|
994
1157
|
return this.parseArrayLiteral();
|
|
995
|
-
if (
|
|
1158
|
+
if (X(e)) {
|
|
996
1159
|
const n = this.readIdentifier();
|
|
997
1160
|
if (n === "true") return !0;
|
|
998
1161
|
if (n === "false") return !1;
|
|
999
1162
|
if (n === "null") return null;
|
|
1000
|
-
throw
|
|
1163
|
+
throw g(this.path, "object literal values must be literals");
|
|
1001
1164
|
}
|
|
1002
|
-
throw
|
|
1165
|
+
throw g(this.path, "object literal values must be literals");
|
|
1003
1166
|
}
|
|
1004
1167
|
match(e) {
|
|
1005
1168
|
return this.skipWhitespace(), this.input.startsWith(e, this.index) ? (this.index += e.length, !0) : !1;
|
|
@@ -1010,9 +1173,9 @@ class _t {
|
|
|
1010
1173
|
readIdentifier() {
|
|
1011
1174
|
this.skipWhitespace();
|
|
1012
1175
|
const e = this.index;
|
|
1013
|
-
if (!
|
|
1176
|
+
if (!X(this.peek()))
|
|
1014
1177
|
return "";
|
|
1015
|
-
for (this.index++; this.index < this.input.length &&
|
|
1178
|
+
for (this.index++; this.index < this.input.length && Nt(this.peek()); )
|
|
1016
1179
|
this.index++;
|
|
1017
1180
|
return this.input.slice(e, this.index);
|
|
1018
1181
|
}
|
|
@@ -1026,14 +1189,14 @@ class _t {
|
|
|
1026
1189
|
return this.index++, n;
|
|
1027
1190
|
if (r === "\\") {
|
|
1028
1191
|
if (this.index++, this.index >= this.input.length)
|
|
1029
|
-
throw
|
|
1192
|
+
throw g(this.path, "unterminated string escape");
|
|
1030
1193
|
const i = this.input[this.index];
|
|
1031
1194
|
n += i, this.index++;
|
|
1032
1195
|
continue;
|
|
1033
1196
|
}
|
|
1034
1197
|
n += r, this.index++;
|
|
1035
1198
|
}
|
|
1036
|
-
throw
|
|
1199
|
+
throw g(this.path, "unterminated string literal");
|
|
1037
1200
|
}
|
|
1038
1201
|
readNumber() {
|
|
1039
1202
|
const e = this.index;
|
|
@@ -1041,11 +1204,11 @@ class _t {
|
|
|
1041
1204
|
this.index++;
|
|
1042
1205
|
const n = this.input.slice(e, this.index), r = Number(n);
|
|
1043
1206
|
if (Number.isNaN(r))
|
|
1044
|
-
throw
|
|
1207
|
+
throw g(this.path, `invalid number '${n}'`);
|
|
1045
1208
|
return r;
|
|
1046
1209
|
}
|
|
1047
1210
|
}
|
|
1048
|
-
async function
|
|
1211
|
+
async function Ne(t, e, n = {}) {
|
|
1049
1212
|
const r = n.path;
|
|
1050
1213
|
let i = "", s = 0;
|
|
1051
1214
|
for (; s < t.length; ) {
|
|
@@ -1060,24 +1223,24 @@ async function Me(t, e, n = {}) {
|
|
|
1060
1223
|
i += "{", s = o + 1;
|
|
1061
1224
|
continue;
|
|
1062
1225
|
}
|
|
1063
|
-
const h = a ? 3 : 2, l = a ? "}}}" : "}}",
|
|
1064
|
-
if (
|
|
1226
|
+
const h = a ? 3 : 2, l = a ? "}}}" : "}}", u = t.indexOf(l, o + h);
|
|
1227
|
+
if (u === -1)
|
|
1065
1228
|
throw d({
|
|
1066
1229
|
code: "parse_error",
|
|
1067
1230
|
path: r,
|
|
1068
1231
|
details: { message: "unclosed expression" }
|
|
1069
1232
|
});
|
|
1070
|
-
const
|
|
1233
|
+
const w = t.slice(o + h, u).trim(), m = S(w, r), f = await k(m, {
|
|
1071
1234
|
...n,
|
|
1072
1235
|
context: e,
|
|
1073
1236
|
path: r,
|
|
1074
1237
|
parentContext: n.parentContext ?? e
|
|
1075
1238
|
});
|
|
1076
|
-
i +=
|
|
1239
|
+
i += f == null ? "" : String(f), s = u + l.length;
|
|
1077
1240
|
}
|
|
1078
1241
|
return i;
|
|
1079
1242
|
}
|
|
1080
|
-
function
|
|
1243
|
+
function jt(t, e) {
|
|
1081
1244
|
let n = 0, r = 0;
|
|
1082
1245
|
for (; r < t.length; ) {
|
|
1083
1246
|
const i = t.indexOf(e, r);
|
|
@@ -1087,14 +1250,14 @@ function St(t, e) {
|
|
|
1087
1250
|
}
|
|
1088
1251
|
return n;
|
|
1089
1252
|
}
|
|
1090
|
-
function
|
|
1091
|
-
const e = t.includes("@hg"), n = t.includes("@endhg"), r =
|
|
1253
|
+
function ae(t) {
|
|
1254
|
+
const e = t.includes("@hg"), n = t.includes("@endhg"), r = jt(t, "@@");
|
|
1092
1255
|
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
1256
|
}
|
|
1094
|
-
function
|
|
1257
|
+
function ce(t) {
|
|
1095
1258
|
return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
|
|
1096
1259
|
}
|
|
1097
|
-
function
|
|
1260
|
+
function le(t, e) {
|
|
1098
1261
|
let n = 0, r = !1;
|
|
1099
1262
|
for (; n < e; ) {
|
|
1100
1263
|
const i = t.indexOf("```", n);
|
|
@@ -1104,21 +1267,21 @@ function ae(t, e) {
|
|
|
1104
1267
|
}
|
|
1105
1268
|
return r;
|
|
1106
1269
|
}
|
|
1107
|
-
function
|
|
1270
|
+
function $(t) {
|
|
1108
1271
|
const e = [];
|
|
1109
1272
|
let n = 0;
|
|
1110
1273
|
for (; n < t.length; ) {
|
|
1111
1274
|
const r = t.indexOf("<!--", n);
|
|
1112
1275
|
if (r === -1)
|
|
1113
1276
|
break;
|
|
1114
|
-
if (
|
|
1277
|
+
if (le(t, r)) {
|
|
1115
1278
|
n = r + 4;
|
|
1116
1279
|
continue;
|
|
1117
1280
|
}
|
|
1118
1281
|
const i = t.indexOf("-->", r + 4);
|
|
1119
1282
|
if (i === -1)
|
|
1120
1283
|
break;
|
|
1121
|
-
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a =
|
|
1284
|
+
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = ae(o);
|
|
1122
1285
|
(a === "hg" || a === "at-at") && e.push({
|
|
1123
1286
|
start: r,
|
|
1124
1287
|
end: i + 3,
|
|
@@ -1128,40 +1291,40 @@ function C(t) {
|
|
|
1128
1291
|
}
|
|
1129
1292
|
return e;
|
|
1130
1293
|
}
|
|
1131
|
-
function
|
|
1294
|
+
function he(t) {
|
|
1132
1295
|
let e = 0;
|
|
1133
1296
|
for (; e < t.length; ) {
|
|
1134
1297
|
const n = t.indexOf("<!--", e);
|
|
1135
1298
|
if (n === -1)
|
|
1136
1299
|
return !1;
|
|
1137
|
-
if (
|
|
1300
|
+
if (le(t, n)) {
|
|
1138
1301
|
e = n + 4;
|
|
1139
1302
|
continue;
|
|
1140
1303
|
}
|
|
1141
1304
|
const r = t.indexOf("-->", n + 4);
|
|
1142
1305
|
if (r === -1)
|
|
1143
1306
|
return !1;
|
|
1144
|
-
const i = t.slice(n + 4, r), s =
|
|
1307
|
+
const i = t.slice(n + 4, r), s = ae(i);
|
|
1145
1308
|
if (s === "unclosed" || s === "mixed")
|
|
1146
1309
|
return !0;
|
|
1147
1310
|
e = r + 3;
|
|
1148
1311
|
}
|
|
1149
1312
|
return !1;
|
|
1150
1313
|
}
|
|
1151
|
-
function
|
|
1314
|
+
function de(t) {
|
|
1152
1315
|
let e = 0;
|
|
1153
1316
|
for (; e < t.length; ) {
|
|
1154
1317
|
const n = t.indexOf("<!--", e);
|
|
1155
1318
|
if (n === -1)
|
|
1156
1319
|
return null;
|
|
1157
|
-
if (
|
|
1320
|
+
if (le(t, n)) {
|
|
1158
1321
|
e = n + 4;
|
|
1159
1322
|
continue;
|
|
1160
1323
|
}
|
|
1161
1324
|
const r = t.indexOf("-->", n + 4);
|
|
1162
1325
|
if (r === -1)
|
|
1163
1326
|
return null;
|
|
1164
|
-
const i = t.slice(n + 4, r), s =
|
|
1327
|
+
const i = t.slice(n + 4, r), s = ae(i);
|
|
1165
1328
|
if (s === "mixed")
|
|
1166
1329
|
return "mixed @hg and @@ markers are not allowed";
|
|
1167
1330
|
if (s === "unclosed")
|
|
@@ -1171,11 +1334,11 @@ function he(t) {
|
|
|
1171
1334
|
return null;
|
|
1172
1335
|
}
|
|
1173
1336
|
function E(t) {
|
|
1174
|
-
return
|
|
1337
|
+
return ce(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
|
|
1175
1338
|
}
|
|
1176
|
-
const
|
|
1177
|
-
function
|
|
1178
|
-
return
|
|
1339
|
+
const Bt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
|
|
1340
|
+
function ue(t) {
|
|
1341
|
+
return Bt.test(t.trim());
|
|
1179
1342
|
}
|
|
1180
1343
|
function J(t, e) {
|
|
1181
1344
|
throw d({
|
|
@@ -1184,7 +1347,7 @@ function J(t, e) {
|
|
|
1184
1347
|
details: { message: e }
|
|
1185
1348
|
});
|
|
1186
1349
|
}
|
|
1187
|
-
function
|
|
1350
|
+
function It(t, e) {
|
|
1188
1351
|
let n = t;
|
|
1189
1352
|
const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
|
|
1190
1353
|
r && (n = r[1]);
|
|
@@ -1227,20 +1390,20 @@ function Et(t, e) {
|
|
|
1227
1390
|
throw J(e, "invalid each directive");
|
|
1228
1391
|
return null;
|
|
1229
1392
|
}
|
|
1230
|
-
function
|
|
1393
|
+
function O(t) {
|
|
1231
1394
|
return { start: t.start, end: t.end, raw: t.raw };
|
|
1232
1395
|
}
|
|
1233
|
-
function
|
|
1396
|
+
function C(t, e) {
|
|
1234
1397
|
throw d({
|
|
1235
1398
|
code: "parse_error",
|
|
1236
1399
|
path: t,
|
|
1237
1400
|
details: { message: e }
|
|
1238
1401
|
});
|
|
1239
1402
|
}
|
|
1240
|
-
function
|
|
1403
|
+
function Ut(t, e) {
|
|
1241
1404
|
const n = [];
|
|
1242
|
-
for (const r of
|
|
1243
|
-
const i =
|
|
1405
|
+
for (const r of $(t)) {
|
|
1406
|
+
const i = It(r.inner, e);
|
|
1244
1407
|
i && n.push({
|
|
1245
1408
|
start: r.start,
|
|
1246
1409
|
end: r.end,
|
|
@@ -1250,85 +1413,85 @@ function Wt(t, e) {
|
|
|
1250
1413
|
}
|
|
1251
1414
|
return n;
|
|
1252
1415
|
}
|
|
1253
|
-
function
|
|
1416
|
+
function Fe(t) {
|
|
1254
1417
|
return t.kind === "if" || t.kind === "each";
|
|
1255
1418
|
}
|
|
1256
|
-
function
|
|
1257
|
-
const n =
|
|
1419
|
+
function zt(t, e) {
|
|
1420
|
+
const n = Ut(t, e);
|
|
1258
1421
|
if (n.length === 0)
|
|
1259
1422
|
return t.length > 0 ? [{ kind: "text", content: t }] : [];
|
|
1260
|
-
const { nodes: r, nextIndex: i } =
|
|
1423
|
+
const { nodes: r, nextIndex: i } = F(t, n, 0, n.length, e);
|
|
1261
1424
|
if (i < n.length) {
|
|
1262
1425
|
const s = n[i];
|
|
1263
1426
|
if (s.opener.kind === "endif")
|
|
1264
|
-
throw
|
|
1427
|
+
throw C(e, "endif without matching if");
|
|
1265
1428
|
if (s.opener.kind === "endeach")
|
|
1266
|
-
throw
|
|
1429
|
+
throw C(e, "endeach without matching each");
|
|
1267
1430
|
if (s.opener.kind === "else" || s.opener.kind === "else_if")
|
|
1268
|
-
throw
|
|
1431
|
+
throw C(e, "else without matching if");
|
|
1269
1432
|
}
|
|
1270
1433
|
return r;
|
|
1271
1434
|
}
|
|
1272
|
-
function
|
|
1435
|
+
function F(t, e, n, r, i, s = 0, o) {
|
|
1273
1436
|
const a = o ?? t.length, c = [];
|
|
1274
1437
|
let h = s, l = n;
|
|
1275
1438
|
for (; l < r; ) {
|
|
1276
|
-
const
|
|
1277
|
-
if (
|
|
1439
|
+
const u = e[l];
|
|
1440
|
+
if (u.start >= a)
|
|
1278
1441
|
break;
|
|
1279
|
-
if (
|
|
1442
|
+
if (u.end <= s) {
|
|
1280
1443
|
l++;
|
|
1281
1444
|
continue;
|
|
1282
1445
|
}
|
|
1283
|
-
if (
|
|
1446
|
+
if (u.start > h && c.push({
|
|
1284
1447
|
kind: "text",
|
|
1285
|
-
content: t.slice(h,
|
|
1286
|
-
}),
|
|
1287
|
-
const
|
|
1288
|
-
c.push(
|
|
1448
|
+
content: t.slice(h, u.start)
|
|
1449
|
+
}), u.opener.kind === "if") {
|
|
1450
|
+
const w = Zt(t, e, l, r, i);
|
|
1451
|
+
c.push(w.node), h = w.endPos, l = w.nextIndex;
|
|
1289
1452
|
continue;
|
|
1290
1453
|
}
|
|
1291
|
-
if (
|
|
1292
|
-
const
|
|
1293
|
-
c.push(
|
|
1454
|
+
if (u.opener.kind === "each") {
|
|
1455
|
+
const w = Vt(t, e, l, r, i);
|
|
1456
|
+
c.push(w.node), h = w.endPos, l = w.nextIndex;
|
|
1294
1457
|
continue;
|
|
1295
1458
|
}
|
|
1296
|
-
if (
|
|
1297
|
-
throw
|
|
1298
|
-
if (
|
|
1299
|
-
throw
|
|
1300
|
-
if (
|
|
1301
|
-
throw
|
|
1459
|
+
if (u.opener.kind === "else" || u.opener.kind === "else_if")
|
|
1460
|
+
throw C(i, "else without matching if");
|
|
1461
|
+
if (u.opener.kind === "endif")
|
|
1462
|
+
throw C(i, "endif without matching if");
|
|
1463
|
+
if (u.opener.kind === "endeach")
|
|
1464
|
+
throw C(i, "endeach without matching each");
|
|
1302
1465
|
l++;
|
|
1303
1466
|
}
|
|
1304
1467
|
return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
|
|
1305
1468
|
}
|
|
1306
|
-
function
|
|
1469
|
+
function Zt(t, e, n, r, i) {
|
|
1307
1470
|
const s = e[n];
|
|
1308
1471
|
if (s.opener.kind !== "if")
|
|
1309
|
-
throw
|
|
1472
|
+
throw C(i, "expected if");
|
|
1310
1473
|
const o = [];
|
|
1311
1474
|
let a = n, c = s.end, h = 0;
|
|
1312
1475
|
for (; a < r; ) {
|
|
1313
1476
|
const l = e[a];
|
|
1314
1477
|
if (a === n) {
|
|
1315
1478
|
if (l.opener.kind !== "if")
|
|
1316
|
-
throw
|
|
1479
|
+
throw C(i, "expected if");
|
|
1317
1480
|
o.push({
|
|
1318
1481
|
kind: "if",
|
|
1319
1482
|
expr: l.opener.expr,
|
|
1320
|
-
opener:
|
|
1483
|
+
opener: O(l),
|
|
1321
1484
|
body: []
|
|
1322
1485
|
}), a++;
|
|
1323
1486
|
continue;
|
|
1324
1487
|
}
|
|
1325
|
-
if (
|
|
1488
|
+
if (Fe(l.opener)) {
|
|
1326
1489
|
h++, a++;
|
|
1327
1490
|
continue;
|
|
1328
1491
|
}
|
|
1329
1492
|
if (l.opener.kind === "endif") {
|
|
1330
1493
|
if (h === 0)
|
|
1331
|
-
return o[o.length - 1].body =
|
|
1494
|
+
return o[o.length - 1].body = F(
|
|
1332
1495
|
t,
|
|
1333
1496
|
e,
|
|
1334
1497
|
n + 1,
|
|
@@ -1337,7 +1500,7 @@ function Tt(t, e, n, r, i) {
|
|
|
1337
1500
|
c,
|
|
1338
1501
|
l.start
|
|
1339
1502
|
).nodes, {
|
|
1340
|
-
node: { kind: "if", branches: o, closer:
|
|
1503
|
+
node: { kind: "if", branches: o, closer: O(l) },
|
|
1341
1504
|
nextIndex: a + 1,
|
|
1342
1505
|
endPos: l.end
|
|
1343
1506
|
};
|
|
@@ -1350,7 +1513,7 @@ function Tt(t, e, n, r, i) {
|
|
|
1350
1513
|
}
|
|
1351
1514
|
if (h === 0) {
|
|
1352
1515
|
if (l.opener.kind === "else_if") {
|
|
1353
|
-
o[o.length - 1].body =
|
|
1516
|
+
o[o.length - 1].body = F(
|
|
1354
1517
|
t,
|
|
1355
1518
|
e,
|
|
1356
1519
|
n + 1,
|
|
@@ -1361,13 +1524,13 @@ function Tt(t, e, n, r, i) {
|
|
|
1361
1524
|
).nodes, o.push({
|
|
1362
1525
|
kind: "else_if",
|
|
1363
1526
|
expr: l.opener.expr,
|
|
1364
|
-
opener:
|
|
1527
|
+
opener: O(l),
|
|
1365
1528
|
body: []
|
|
1366
1529
|
}), c = l.end, a++;
|
|
1367
1530
|
continue;
|
|
1368
1531
|
}
|
|
1369
1532
|
if (l.opener.kind === "else") {
|
|
1370
|
-
o[o.length - 1].body =
|
|
1533
|
+
o[o.length - 1].body = F(
|
|
1371
1534
|
t,
|
|
1372
1535
|
e,
|
|
1373
1536
|
n + 1,
|
|
@@ -1377,7 +1540,7 @@ function Tt(t, e, n, r, i) {
|
|
|
1377
1540
|
l.start
|
|
1378
1541
|
).nodes, o.push({
|
|
1379
1542
|
kind: "else",
|
|
1380
|
-
opener:
|
|
1543
|
+
opener: O(l),
|
|
1381
1544
|
body: []
|
|
1382
1545
|
}), c = l.end, a++;
|
|
1383
1546
|
continue;
|
|
@@ -1385,24 +1548,24 @@ function Tt(t, e, n, r, i) {
|
|
|
1385
1548
|
}
|
|
1386
1549
|
a++;
|
|
1387
1550
|
}
|
|
1388
|
-
throw
|
|
1551
|
+
throw C(i, "unclosed if block (missing endif)");
|
|
1389
1552
|
}
|
|
1390
|
-
function
|
|
1553
|
+
function Vt(t, e, n, r, i) {
|
|
1391
1554
|
const s = e[n];
|
|
1392
1555
|
if (s.opener.kind !== "each")
|
|
1393
|
-
throw
|
|
1556
|
+
throw C(i, "expected each");
|
|
1394
1557
|
let o = n + 1;
|
|
1395
1558
|
const a = s.end;
|
|
1396
1559
|
let c = 0;
|
|
1397
1560
|
for (; o < r; ) {
|
|
1398
1561
|
const h = e[o];
|
|
1399
|
-
if (
|
|
1562
|
+
if (Fe(h.opener)) {
|
|
1400
1563
|
c++, o++;
|
|
1401
1564
|
continue;
|
|
1402
1565
|
}
|
|
1403
1566
|
if (h.opener.kind === "endeach") {
|
|
1404
1567
|
if (c === 0) {
|
|
1405
|
-
const l =
|
|
1568
|
+
const l = F(
|
|
1406
1569
|
t,
|
|
1407
1570
|
e,
|
|
1408
1571
|
n + 1,
|
|
@@ -1416,9 +1579,9 @@ function At(t, e, n, r, i) {
|
|
|
1416
1579
|
kind: "each",
|
|
1417
1580
|
item: s.opener.item,
|
|
1418
1581
|
expr: s.opener.expr,
|
|
1419
|
-
opener:
|
|
1582
|
+
opener: O(s),
|
|
1420
1583
|
body: l,
|
|
1421
|
-
closer:
|
|
1584
|
+
closer: O(h)
|
|
1422
1585
|
},
|
|
1423
1586
|
nextIndex: o + 1,
|
|
1424
1587
|
endPos: h.end
|
|
@@ -1433,28 +1596,28 @@ function At(t, e, n, r, i) {
|
|
|
1433
1596
|
}
|
|
1434
1597
|
o++;
|
|
1435
1598
|
}
|
|
1436
|
-
throw
|
|
1599
|
+
throw C(i, "unclosed each block (missing endeach)");
|
|
1437
1600
|
}
|
|
1438
|
-
const
|
|
1439
|
-
class
|
|
1601
|
+
const Se = 20;
|
|
1602
|
+
class qt {
|
|
1440
1603
|
depth = 0;
|
|
1441
1604
|
get currentDepth() {
|
|
1442
1605
|
return this.depth;
|
|
1443
1606
|
}
|
|
1444
1607
|
enter() {
|
|
1445
|
-
return this.depth >=
|
|
1608
|
+
return this.depth >= Se ? { exceeded: !0, limit: Se } : (this.depth++, { exceeded: !1, depth: this.depth });
|
|
1446
1609
|
}
|
|
1447
1610
|
exit() {
|
|
1448
1611
|
this.depth > 0 && this.depth--;
|
|
1449
1612
|
}
|
|
1450
1613
|
}
|
|
1451
|
-
function
|
|
1614
|
+
function Pt(t) {
|
|
1452
1615
|
return !!t;
|
|
1453
1616
|
}
|
|
1454
|
-
function
|
|
1617
|
+
function Kt(t) {
|
|
1455
1618
|
return t != null && typeof t[Symbol.iterator] == "function";
|
|
1456
1619
|
}
|
|
1457
|
-
function
|
|
1620
|
+
function je(t) {
|
|
1458
1621
|
return {
|
|
1459
1622
|
code: "nest_limit_exceeded",
|
|
1460
1623
|
message: "structure nest limit exceeded",
|
|
@@ -1462,38 +1625,38 @@ function Le(t) {
|
|
|
1462
1625
|
details: { limit: 20 }
|
|
1463
1626
|
};
|
|
1464
1627
|
}
|
|
1465
|
-
function
|
|
1628
|
+
function pe(t) {
|
|
1466
1629
|
return t.startsWith(`
|
|
1467
1630
|
`) ? t.slice(1) : t;
|
|
1468
1631
|
}
|
|
1469
|
-
async function
|
|
1470
|
-
const n = e.path, r = e.warnings ?? [], i =
|
|
1471
|
-
return
|
|
1632
|
+
async function Yt(t, e) {
|
|
1633
|
+
const n = e.path, r = e.warnings ?? [], i = zt(t, n), s = new qt();
|
|
1634
|
+
return fe(i, e, s, r);
|
|
1472
1635
|
}
|
|
1473
|
-
async function
|
|
1636
|
+
async function fe(t, e, n, r) {
|
|
1474
1637
|
const i = e.preserveHgComments === !0;
|
|
1475
1638
|
let s = "", o = !1;
|
|
1476
1639
|
for (const a of t) {
|
|
1477
|
-
let c = await
|
|
1478
|
-
o && (c =
|
|
1640
|
+
let c = await Gt(a, e, n, r);
|
|
1641
|
+
o && (c = pe(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
|
|
1479
1642
|
}
|
|
1480
1643
|
return s;
|
|
1481
1644
|
}
|
|
1482
|
-
async function
|
|
1645
|
+
async function Gt(t, e, n, r) {
|
|
1483
1646
|
switch (t.kind) {
|
|
1484
1647
|
case "text":
|
|
1485
1648
|
return t.content;
|
|
1486
1649
|
case "if":
|
|
1487
|
-
return
|
|
1650
|
+
return Xt(t, e, n, r);
|
|
1488
1651
|
case "each":
|
|
1489
|
-
return
|
|
1652
|
+
return Jt(t, e, n, r);
|
|
1490
1653
|
default:
|
|
1491
1654
|
return "";
|
|
1492
1655
|
}
|
|
1493
1656
|
}
|
|
1494
|
-
async function
|
|
1657
|
+
async function Xt(t, e, n, r) {
|
|
1495
1658
|
if (n.enter().exceeded)
|
|
1496
|
-
return r.push(
|
|
1659
|
+
return r.push(je(e.path)), "";
|
|
1497
1660
|
try {
|
|
1498
1661
|
let s = -1;
|
|
1499
1662
|
for (let c = 0; c < t.branches.length; c++) {
|
|
@@ -1503,7 +1666,7 @@ async function Nt(t, e, n, r) {
|
|
|
1503
1666
|
break;
|
|
1504
1667
|
}
|
|
1505
1668
|
const l = await k(h.expr, e);
|
|
1506
|
-
if (
|
|
1669
|
+
if (Pt(l)) {
|
|
1507
1670
|
s = c;
|
|
1508
1671
|
break;
|
|
1509
1672
|
}
|
|
@@ -1513,8 +1676,8 @@ async function Nt(t, e, n, r) {
|
|
|
1513
1676
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1514
1677
|
const h = t.branches[c];
|
|
1515
1678
|
if (o && (a += h.opener.raw), c === s) {
|
|
1516
|
-
let l = await
|
|
1517
|
-
o || (l =
|
|
1679
|
+
let l = await fe(h.body, e, n, r);
|
|
1680
|
+
o || (l = pe(l)), a += l;
|
|
1518
1681
|
}
|
|
1519
1682
|
}
|
|
1520
1683
|
return o && (a += t.closer.raw), a;
|
|
@@ -1522,24 +1685,24 @@ async function Nt(t, e, n, r) {
|
|
|
1522
1685
|
n.exit();
|
|
1523
1686
|
}
|
|
1524
1687
|
}
|
|
1525
|
-
async function
|
|
1688
|
+
async function Jt(t, e, n, r) {
|
|
1526
1689
|
if (n.enter().exceeded)
|
|
1527
|
-
return r.push(
|
|
1690
|
+
return r.push(je(e.path)), "";
|
|
1528
1691
|
try {
|
|
1529
1692
|
const s = await k(t.expr, e);
|
|
1530
|
-
if (!
|
|
1693
|
+
if (!Kt(s))
|
|
1531
1694
|
return "";
|
|
1532
1695
|
const o = e.preserveHgComments === !0;
|
|
1533
1696
|
let a = "";
|
|
1534
1697
|
for (const c of s) {
|
|
1535
1698
|
const h = { ...e.context, [t.item]: c };
|
|
1536
1699
|
o && (a += t.opener.raw);
|
|
1537
|
-
let l = await
|
|
1700
|
+
let l = await fe(t.body, {
|
|
1538
1701
|
...e,
|
|
1539
1702
|
context: h
|
|
1540
1703
|
}, n, r);
|
|
1541
|
-
o || (l =
|
|
1542
|
-
const
|
|
1704
|
+
o || (l = pe(l));
|
|
1705
|
+
const u = await Ne(l, h, {
|
|
1543
1706
|
path: e.path,
|
|
1544
1707
|
registry: e.registry,
|
|
1545
1708
|
loader: e.loader,
|
|
@@ -1550,15 +1713,15 @@ async function Ht(t, e, n, r) {
|
|
|
1550
1713
|
preserveHgComments: e.preserveHgComments,
|
|
1551
1714
|
constrainToRoot: e.constrainToRoot
|
|
1552
1715
|
});
|
|
1553
|
-
a +=
|
|
1716
|
+
a += u, o && (a += t.closer.raw);
|
|
1554
1717
|
}
|
|
1555
1718
|
return a;
|
|
1556
1719
|
} finally {
|
|
1557
1720
|
n.exit();
|
|
1558
1721
|
}
|
|
1559
1722
|
}
|
|
1560
|
-
function
|
|
1561
|
-
return
|
|
1723
|
+
function ee(t, e, n, r, i = !1, s = !1) {
|
|
1724
|
+
return H(e) ? e : Z(e, {
|
|
1562
1725
|
rootDir: t,
|
|
1563
1726
|
fromPath: r,
|
|
1564
1727
|
documentPath: n,
|
|
@@ -1566,40 +1729,40 @@ function Q(t, e, n, r, i = !1, s = !1) {
|
|
|
1566
1729
|
hyogenPath: s
|
|
1567
1730
|
});
|
|
1568
1731
|
}
|
|
1569
|
-
function
|
|
1732
|
+
function Be(t) {
|
|
1570
1733
|
let e = 0;
|
|
1571
1734
|
for (let n = t.length - 1; n >= 0 && t[n] === `
|
|
1572
1735
|
`; n--)
|
|
1573
1736
|
e++;
|
|
1574
1737
|
return e;
|
|
1575
1738
|
}
|
|
1576
|
-
function
|
|
1739
|
+
function Ie(t) {
|
|
1577
1740
|
let e = 0;
|
|
1578
1741
|
for (; e < t.length && t[e] === `
|
|
1579
1742
|
`; )
|
|
1580
1743
|
e++;
|
|
1581
1744
|
return e;
|
|
1582
1745
|
}
|
|
1583
|
-
function
|
|
1584
|
-
const n =
|
|
1746
|
+
function A(t, e) {
|
|
1747
|
+
const n = Be(t), r = Ie(e), i = Math.max(n, r);
|
|
1585
1748
|
return t.slice(0, t.length - n) + `
|
|
1586
1749
|
`.repeat(i) + e.slice(r);
|
|
1587
1750
|
}
|
|
1588
|
-
function
|
|
1589
|
-
const n =
|
|
1751
|
+
function me(t, e) {
|
|
1752
|
+
const n = Be(t), r = Ie(e);
|
|
1590
1753
|
return n + r - Math.max(n, r);
|
|
1591
1754
|
}
|
|
1592
|
-
function
|
|
1755
|
+
function Ce(t, e, n) {
|
|
1593
1756
|
const r = t.indexOf(e);
|
|
1594
1757
|
if (r < 0)
|
|
1595
1758
|
return t;
|
|
1596
1759
|
const i = t.slice(0, r), s = t.slice(r + e.length);
|
|
1597
|
-
return
|
|
1760
|
+
return A(A(i, n), s);
|
|
1598
1761
|
}
|
|
1599
|
-
async function
|
|
1762
|
+
async function Qt(t) {
|
|
1600
1763
|
let e = t.source;
|
|
1601
1764
|
for (const n of t.directives) {
|
|
1602
|
-
const r =
|
|
1765
|
+
const r = ee(
|
|
1603
1766
|
t.root,
|
|
1604
1767
|
n.path,
|
|
1605
1768
|
t.path,
|
|
@@ -1612,7 +1775,7 @@ async function jt(t) {
|
|
|
1612
1775
|
if (i.circular) {
|
|
1613
1776
|
t.warnings?.push({
|
|
1614
1777
|
code: "circular_include",
|
|
1615
|
-
message:
|
|
1778
|
+
message: L("circular_include", {
|
|
1616
1779
|
path: r,
|
|
1617
1780
|
from: i.from,
|
|
1618
1781
|
via: "include"
|
|
@@ -1623,13 +1786,13 @@ async function jt(t) {
|
|
|
1623
1786
|
from: i.from,
|
|
1624
1787
|
via: "include"
|
|
1625
1788
|
}
|
|
1626
|
-
}), e =
|
|
1789
|
+
}), e = Ce(e, n.marker, "");
|
|
1627
1790
|
continue;
|
|
1628
1791
|
}
|
|
1629
1792
|
t.visitStack.push(r);
|
|
1630
1793
|
}
|
|
1631
1794
|
try {
|
|
1632
|
-
const i = await t.loader(r), s = await
|
|
1795
|
+
const i = await t.loader(r), s = await Nn(i, {
|
|
1633
1796
|
context: t.context,
|
|
1634
1797
|
loader: t.loader,
|
|
1635
1798
|
root: t.root,
|
|
@@ -1641,14 +1804,14 @@ async function jt(t) {
|
|
|
1641
1804
|
registry: t.registry
|
|
1642
1805
|
}), o = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1643
1806
|
${s}` : s;
|
|
1644
|
-
e =
|
|
1807
|
+
e = Ce(e, n.marker, o);
|
|
1645
1808
|
} finally {
|
|
1646
1809
|
t.visitStack?.pop();
|
|
1647
1810
|
}
|
|
1648
1811
|
}
|
|
1649
1812
|
return e;
|
|
1650
1813
|
}
|
|
1651
|
-
class
|
|
1814
|
+
class Ue {
|
|
1652
1815
|
stack = [];
|
|
1653
1816
|
check(e) {
|
|
1654
1817
|
return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
|
|
@@ -1664,7 +1827,7 @@ class He {
|
|
|
1664
1827
|
this.stack.pop();
|
|
1665
1828
|
}
|
|
1666
1829
|
}
|
|
1667
|
-
async function
|
|
1830
|
+
async function en(t, e, n = {}) {
|
|
1668
1831
|
const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await k(t.expr, { context: e, path: r });
|
|
1669
1832
|
switch (t.kind) {
|
|
1670
1833
|
case "const": {
|
|
@@ -1705,16 +1868,16 @@ async function Ft(t, e, n = {}) {
|
|
|
1705
1868
|
}
|
|
1706
1869
|
}
|
|
1707
1870
|
}
|
|
1708
|
-
function
|
|
1871
|
+
function Ee(t) {
|
|
1709
1872
|
return !t;
|
|
1710
1873
|
}
|
|
1711
|
-
async function
|
|
1712
|
-
const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s } = n;
|
|
1874
|
+
async function N(t, e, n = {}) {
|
|
1875
|
+
const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s, echoChunks: o } = n;
|
|
1713
1876
|
switch (t.kind) {
|
|
1714
1877
|
case "const":
|
|
1715
1878
|
case "let":
|
|
1716
1879
|
case "assign": {
|
|
1717
|
-
await
|
|
1880
|
+
await en(t, e, { path: r, constBindings: i }), s?.(t.name);
|
|
1718
1881
|
return;
|
|
1719
1882
|
}
|
|
1720
1883
|
case "update": {
|
|
@@ -1734,8 +1897,8 @@ async function D(t, e, n = {}) {
|
|
|
1734
1897
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1735
1898
|
}
|
|
1736
1899
|
});
|
|
1737
|
-
const
|
|
1738
|
-
e[t.name] =
|
|
1900
|
+
const a = Number(e[t.name]), c = t.op === "++" ? a + 1 : a - 1;
|
|
1901
|
+
e[t.name] = c, s?.(t.name);
|
|
1739
1902
|
return;
|
|
1740
1903
|
}
|
|
1741
1904
|
case "compound_assign": {
|
|
@@ -1755,59 +1918,67 @@ async function D(t, e, n = {}) {
|
|
|
1755
1918
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1756
1919
|
}
|
|
1757
1920
|
});
|
|
1758
|
-
const
|
|
1759
|
-
let
|
|
1921
|
+
const a = await k(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
|
|
1922
|
+
let l;
|
|
1760
1923
|
switch (t.op) {
|
|
1761
1924
|
case "+=":
|
|
1762
|
-
|
|
1925
|
+
l = c + h;
|
|
1763
1926
|
break;
|
|
1764
1927
|
case "-=":
|
|
1765
|
-
|
|
1928
|
+
l = c - h;
|
|
1766
1929
|
break;
|
|
1767
1930
|
case "*=":
|
|
1768
|
-
|
|
1931
|
+
l = c * h;
|
|
1769
1932
|
break;
|
|
1770
1933
|
case "/=":
|
|
1771
|
-
|
|
1934
|
+
l = c / h;
|
|
1772
1935
|
break;
|
|
1773
1936
|
}
|
|
1774
|
-
e[t.name] =
|
|
1937
|
+
e[t.name] = l, s?.(t.name);
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
case "echo": {
|
|
1941
|
+
const a = await k(t.expr, {
|
|
1942
|
+
context: e,
|
|
1943
|
+
path: r
|
|
1944
|
+
}), c = a == null ? "" : String(a);
|
|
1945
|
+
o?.push(c);
|
|
1775
1946
|
return;
|
|
1776
1947
|
}
|
|
1777
1948
|
case "for": {
|
|
1778
|
-
for (t.init && await
|
|
1779
|
-
const
|
|
1949
|
+
for (t.init && await N(t.init, e, n); ; ) {
|
|
1950
|
+
const a = await k(t.cond, {
|
|
1780
1951
|
context: e,
|
|
1781
1952
|
path: r
|
|
1782
1953
|
});
|
|
1783
|
-
if (
|
|
1954
|
+
if (Ee(a))
|
|
1784
1955
|
break;
|
|
1785
|
-
for (const
|
|
1786
|
-
await
|
|
1787
|
-
t.update && await
|
|
1956
|
+
for (const c of t.body)
|
|
1957
|
+
await N(c, e, n);
|
|
1958
|
+
t.update && await N(t.update, e, n);
|
|
1788
1959
|
}
|
|
1789
1960
|
return;
|
|
1790
1961
|
}
|
|
1791
1962
|
case "do_while": {
|
|
1792
1963
|
do {
|
|
1793
|
-
for (const
|
|
1794
|
-
await
|
|
1795
|
-
const
|
|
1964
|
+
for (const c of t.body)
|
|
1965
|
+
await N(c, e, n);
|
|
1966
|
+
const a = await k(t.cond, {
|
|
1796
1967
|
context: e,
|
|
1797
1968
|
path: r
|
|
1798
1969
|
});
|
|
1799
|
-
if (
|
|
1970
|
+
if (Ee(a))
|
|
1800
1971
|
break;
|
|
1801
1972
|
} while (!0);
|
|
1802
1973
|
return;
|
|
1803
1974
|
}
|
|
1804
1975
|
}
|
|
1805
1976
|
}
|
|
1806
|
-
async function
|
|
1977
|
+
async function $e(t, e, n = {}) {
|
|
1807
1978
|
for (const r of t)
|
|
1808
|
-
await
|
|
1979
|
+
await N(r, e, n);
|
|
1809
1980
|
}
|
|
1810
|
-
const
|
|
1981
|
+
const tn = /* @__PURE__ */ new Set([
|
|
1811
1982
|
"if",
|
|
1812
1983
|
"else",
|
|
1813
1984
|
"endif",
|
|
@@ -1823,12 +1994,13 @@ const Bt = /* @__PURE__ */ new Set([
|
|
|
1823
1994
|
"extend",
|
|
1824
1995
|
"include",
|
|
1825
1996
|
"component",
|
|
1826
|
-
"as"
|
|
1997
|
+
"as",
|
|
1998
|
+
"echo"
|
|
1827
1999
|
]);
|
|
1828
|
-
function
|
|
1829
|
-
return
|
|
2000
|
+
function ze(t) {
|
|
2001
|
+
return tn.has(t);
|
|
1830
2002
|
}
|
|
1831
|
-
function
|
|
2003
|
+
function ge(t) {
|
|
1832
2004
|
let e = "", n = 0, r = null;
|
|
1833
2005
|
for (; n < t.length; ) {
|
|
1834
2006
|
const i = t[n];
|
|
@@ -1868,11 +2040,11 @@ function x(t, e) {
|
|
|
1868
2040
|
details: { message: e }
|
|
1869
2041
|
});
|
|
1870
2042
|
}
|
|
1871
|
-
function
|
|
1872
|
-
const n =
|
|
2043
|
+
function We(t, e) {
|
|
2044
|
+
const n = ge(t).trim();
|
|
1873
2045
|
if (n.length === 0)
|
|
1874
2046
|
throw x(e, "empty statement block");
|
|
1875
|
-
const r = new
|
|
2047
|
+
const r = new we(n, e), i = r.parseStatementList();
|
|
1876
2048
|
if (r.skipWhitespace(), r.hasMore())
|
|
1877
2049
|
throw x(
|
|
1878
2050
|
e,
|
|
@@ -1883,10 +2055,10 @@ function Ce(t, e) {
|
|
|
1883
2055
|
return i;
|
|
1884
2056
|
}
|
|
1885
2057
|
function z(t) {
|
|
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);
|
|
2058
|
+
const e = ge(t).trim();
|
|
2059
|
+
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
2060
|
}
|
|
1889
|
-
class
|
|
2061
|
+
class we {
|
|
1890
2062
|
constructor(e, n) {
|
|
1891
2063
|
this.input = e, this.path = n;
|
|
1892
2064
|
}
|
|
@@ -1919,7 +2091,7 @@ class me {
|
|
|
1919
2091
|
this.path,
|
|
1920
2092
|
"bare while loops are not allowed (use do…while)"
|
|
1921
2093
|
);
|
|
1922
|
-
return this.parseSimpleStatement();
|
|
2094
|
+
return this.matchWord("echo") ? this.parseEcho() : this.parseSimpleStatement();
|
|
1923
2095
|
}
|
|
1924
2096
|
parseSimpleStatement() {
|
|
1925
2097
|
this.skipWhitespace();
|
|
@@ -1959,6 +2131,14 @@ class me {
|
|
|
1959
2131
|
}
|
|
1960
2132
|
throw x(this.path, `invalid statement starting with: ${n}`);
|
|
1961
2133
|
}
|
|
2134
|
+
parseEcho() {
|
|
2135
|
+
this.skipWhitespace();
|
|
2136
|
+
const e = this.readExpressionSourceUntilTerminator();
|
|
2137
|
+
return {
|
|
2138
|
+
kind: "echo",
|
|
2139
|
+
expr: S(e, this.path)
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
1962
2142
|
readPrefixUpdate() {
|
|
1963
2143
|
if (this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
1964
2144
|
const e = this.input.slice(this.index - 2, this.index), n = this.readIdentifier();
|
|
@@ -1984,7 +2164,7 @@ class me {
|
|
|
1984
2164
|
parseFor() {
|
|
1985
2165
|
if (this.skipWhitespace(), !this.match("("))
|
|
1986
2166
|
throw x(this.path, "expected '(' after for");
|
|
1987
|
-
const e = this.readBalanced(")"), n =
|
|
2167
|
+
const e = this.readBalanced(")"), n = nn(e);
|
|
1988
2168
|
if (n.length !== 3)
|
|
1989
2169
|
throw x(
|
|
1990
2170
|
this.path,
|
|
@@ -2023,7 +2203,7 @@ class me {
|
|
|
2023
2203
|
return { kind: "do_while", body: e, cond: r };
|
|
2024
2204
|
}
|
|
2025
2205
|
parseClauseStatement(e) {
|
|
2026
|
-
const n = new
|
|
2206
|
+
const n = new we(e, this.path), r = n.parseSimpleStatement();
|
|
2027
2207
|
if (n.skipWhitespace(), n.hasMore())
|
|
2028
2208
|
throw x(
|
|
2029
2209
|
this.path,
|
|
@@ -2032,7 +2212,7 @@ class me {
|
|
|
2032
2212
|
return r;
|
|
2033
2213
|
}
|
|
2034
2214
|
assertAssignableName(e) {
|
|
2035
|
-
if (
|
|
2215
|
+
if (ze(e))
|
|
2036
2216
|
throw x(
|
|
2037
2217
|
this.path,
|
|
2038
2218
|
`reserved word cannot be used as identifier: ${e}`
|
|
@@ -2139,7 +2319,7 @@ class me {
|
|
|
2139
2319
|
return this.input.slice(e, this.index);
|
|
2140
2320
|
}
|
|
2141
2321
|
}
|
|
2142
|
-
function
|
|
2322
|
+
function nn(t) {
|
|
2143
2323
|
const e = [];
|
|
2144
2324
|
let n = "", r = 0, i = null;
|
|
2145
2325
|
for (let s = 0; s < t.length; s++) {
|
|
@@ -2172,7 +2352,7 @@ function It(t) {
|
|
|
2172
2352
|
}
|
|
2173
2353
|
return e.push(n), e;
|
|
2174
2354
|
}
|
|
2175
|
-
function
|
|
2355
|
+
function j(t, e) {
|
|
2176
2356
|
const n = t.trim();
|
|
2177
2357
|
if (!/^extend\b/i.test(n)) return null;
|
|
2178
2358
|
if (!/^extend\s+/i.test(n))
|
|
@@ -2197,10 +2377,10 @@ function H(t, e) {
|
|
|
2197
2377
|
});
|
|
2198
2378
|
return { path: i };
|
|
2199
2379
|
}
|
|
2200
|
-
function
|
|
2380
|
+
function rn(t, e) {
|
|
2201
2381
|
const n = E(t);
|
|
2202
2382
|
if (n.length === 0) return null;
|
|
2203
|
-
const r = n[0], i =
|
|
2383
|
+
const r = n[0], i = j(r, e);
|
|
2204
2384
|
if (!i) return null;
|
|
2205
2385
|
for (const s of n.slice(1))
|
|
2206
2386
|
if (/^extend\s+/i.test(s))
|
|
@@ -2215,17 +2395,51 @@ function zt(t, e) {
|
|
|
2215
2395
|
`)
|
|
2216
2396
|
};
|
|
2217
2397
|
}
|
|
2218
|
-
|
|
2398
|
+
function q(t) {
|
|
2399
|
+
return /^toc(\(.*\))?$/.test(t.trim());
|
|
2400
|
+
}
|
|
2401
|
+
function sn(t, e) {
|
|
2402
|
+
const n = E(t);
|
|
2403
|
+
if (n.length !== 1)
|
|
2404
|
+
throw d({
|
|
2405
|
+
code: "parse_error",
|
|
2406
|
+
path: e,
|
|
2407
|
+
details: {
|
|
2408
|
+
message: "toc directive must be a single line"
|
|
2409
|
+
}
|
|
2410
|
+
});
|
|
2411
|
+
const r = n[0];
|
|
2412
|
+
if (r === "toc")
|
|
2413
|
+
return { maxLevel: 6 };
|
|
2414
|
+
const i = /^toc\((.*)\)$/.exec(r);
|
|
2415
|
+
if (!i)
|
|
2416
|
+
throw d({
|
|
2417
|
+
code: "parse_error",
|
|
2418
|
+
path: e,
|
|
2419
|
+
details: { message: `invalid toc directive: ${r}` }
|
|
2420
|
+
});
|
|
2421
|
+
const s = i[1];
|
|
2422
|
+
if (!/^[1-6]$/.test(s))
|
|
2423
|
+
throw d({
|
|
2424
|
+
code: "parse_error",
|
|
2425
|
+
path: e,
|
|
2426
|
+
details: {
|
|
2427
|
+
message: `invalid toc max level: ${s || "(empty)"} (expected integer 1–6)`
|
|
2428
|
+
}
|
|
2429
|
+
});
|
|
2430
|
+
return { maxLevel: Number(s) };
|
|
2431
|
+
}
|
|
2432
|
+
async function on(t, e = {}) {
|
|
2219
2433
|
const n = e.path, r = e.context ?? {};
|
|
2220
|
-
if (
|
|
2434
|
+
if (he(t))
|
|
2221
2435
|
throw d({
|
|
2222
2436
|
code: "parse_error",
|
|
2223
2437
|
path: n,
|
|
2224
2438
|
details: {
|
|
2225
|
-
message:
|
|
2439
|
+
message: de(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2226
2440
|
}
|
|
2227
2441
|
});
|
|
2228
|
-
const i =
|
|
2442
|
+
const i = $(t);
|
|
2229
2443
|
if (i.length === 0)
|
|
2230
2444
|
return { source: t, context: r, declarationUpdates: {} };
|
|
2231
2445
|
const s = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
|
|
@@ -2233,53 +2447,58 @@ async function Ut(t, e = {}) {
|
|
|
2233
2447
|
};
|
|
2234
2448
|
let c = t, h = 0;
|
|
2235
2449
|
for (const l of i) {
|
|
2236
|
-
const
|
|
2237
|
-
if (
|
|
2450
|
+
const u = E(l.inner);
|
|
2451
|
+
if (u.length === 1 && ue(u[0]) || u.length === 1 && q(u[0]) || u.length === 1 && /^include\s+/i.test(u[0]) || u.length === 1 && /^component\s+/i.test(u[0]))
|
|
2238
2452
|
continue;
|
|
2239
|
-
const
|
|
2240
|
-
if (
|
|
2241
|
-
if (
|
|
2242
|
-
const
|
|
2243
|
-
|
|
2453
|
+
const w = rn(l.inner, n);
|
|
2454
|
+
if (w) {
|
|
2455
|
+
if (w.declarationsSource.trim().length > 0) {
|
|
2456
|
+
const D = We(
|
|
2457
|
+
w.declarationsSource,
|
|
2244
2458
|
n
|
|
2245
2459
|
);
|
|
2246
|
-
await
|
|
2460
|
+
await $e(D, r, {
|
|
2247
2461
|
path: n,
|
|
2248
2462
|
constBindings: s,
|
|
2249
2463
|
onUpdate: a
|
|
2250
2464
|
});
|
|
2251
2465
|
}
|
|
2252
|
-
const
|
|
2253
|
-
extend ${
|
|
2466
|
+
const _ = l.start - h, R = l.end - h, I = `<!--@hg
|
|
2467
|
+
extend ${w.path}
|
|
2254
2468
|
@endhg-->`;
|
|
2255
|
-
c = c.slice(0,
|
|
2469
|
+
c = c.slice(0, _) + I + c.slice(R), h += l.raw.length - I.length;
|
|
2256
2470
|
continue;
|
|
2257
2471
|
}
|
|
2258
|
-
const
|
|
2472
|
+
const m = u.join(`
|
|
2259
2473
|
`);
|
|
2260
|
-
if (!z(
|
|
2261
|
-
if (
|
|
2474
|
+
if (!z(m)) {
|
|
2475
|
+
if (u.length === 1)
|
|
2262
2476
|
continue;
|
|
2263
2477
|
throw d({
|
|
2264
2478
|
code: "parse_error",
|
|
2265
2479
|
path: n,
|
|
2266
|
-
details: { message: `unsupported hyogen directive: ${
|
|
2480
|
+
details: { message: `unsupported hyogen directive: ${u[0]}` }
|
|
2267
2481
|
});
|
|
2268
2482
|
}
|
|
2269
|
-
const
|
|
2270
|
-
await
|
|
2483
|
+
const f = We(m, n), y = [];
|
|
2484
|
+
await $e(f, r, {
|
|
2271
2485
|
path: n,
|
|
2272
2486
|
constBindings: s,
|
|
2273
|
-
onUpdate: a
|
|
2487
|
+
onUpdate: a,
|
|
2488
|
+
echoChunks: y
|
|
2274
2489
|
});
|
|
2275
|
-
const
|
|
2276
|
-
|
|
2490
|
+
const W = l.start - h, P = l.end - h, T = c.slice(0, W), b = c.slice(P);
|
|
2491
|
+
if (y.length > 0) {
|
|
2492
|
+
const _ = y.join("");
|
|
2493
|
+
c = T + _ + b, h += l.raw.length - _.length;
|
|
2494
|
+
} else
|
|
2495
|
+
c = A(T, b), h += l.raw.length + me(T, b);
|
|
2277
2496
|
}
|
|
2278
2497
|
return { source: c, context: r, declarationUpdates: o };
|
|
2279
2498
|
}
|
|
2280
|
-
const
|
|
2281
|
-
function
|
|
2282
|
-
const n =
|
|
2499
|
+
const an = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
|
|
2500
|
+
function Ze(t, e) {
|
|
2501
|
+
const n = ce(t).trim();
|
|
2283
2502
|
if (n.length === 0)
|
|
2284
2503
|
throw d({
|
|
2285
2504
|
code: "parse_error",
|
|
@@ -2302,7 +2521,7 @@ function Fe(t, e) {
|
|
|
2302
2521
|
path: e,
|
|
2303
2522
|
details: { message: "include and component cannot coexist in one block" }
|
|
2304
2523
|
});
|
|
2305
|
-
const s =
|
|
2524
|
+
const s = an.exec(i);
|
|
2306
2525
|
if (!s)
|
|
2307
2526
|
throw d({
|
|
2308
2527
|
code: "parse_error",
|
|
@@ -2322,8 +2541,8 @@ function Fe(t, e) {
|
|
|
2322
2541
|
alias: s[2]
|
|
2323
2542
|
};
|
|
2324
2543
|
}
|
|
2325
|
-
function
|
|
2326
|
-
const n =
|
|
2544
|
+
function Ve(t, e) {
|
|
2545
|
+
const n = ce(t).trim();
|
|
2327
2546
|
if (n.length === 0)
|
|
2328
2547
|
throw d({
|
|
2329
2548
|
code: "parse_error",
|
|
@@ -2346,19 +2565,19 @@ function Be(t, e) {
|
|
|
2346
2565
|
details: { message: `unsupported hyogen directive: ${i}` }
|
|
2347
2566
|
});
|
|
2348
2567
|
}
|
|
2349
|
-
function
|
|
2350
|
-
const e =
|
|
2568
|
+
function te(t) {
|
|
2569
|
+
const e = ge(t).trim();
|
|
2351
2570
|
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
|
|
2352
2571
|
}
|
|
2353
|
-
const
|
|
2354
|
-
function
|
|
2355
|
-
return `${
|
|
2572
|
+
const cn = "\0HYOGEN_INCLUDE_";
|
|
2573
|
+
function ln(t) {
|
|
2574
|
+
return `${cn}${t}\0`;
|
|
2356
2575
|
}
|
|
2357
|
-
function
|
|
2576
|
+
function hn(t, e) {
|
|
2358
2577
|
const n = E(t);
|
|
2359
|
-
if (n.length === 1 &&
|
|
2578
|
+
if (n.length === 1 && ue(n[0]))
|
|
2360
2579
|
return { kind: "control" };
|
|
2361
|
-
if (n.length === 1 && (
|
|
2580
|
+
if (n.length === 1 && q(n[0]) || n.length === 1 && (te(n[0]) || z(n[0])))
|
|
2362
2581
|
return null;
|
|
2363
2582
|
if (n.length !== 1)
|
|
2364
2583
|
throw d({
|
|
@@ -2374,9 +2593,9 @@ function Pt(t, e) {
|
|
|
2374
2593
|
details: { message: "include and component cannot coexist in one block" }
|
|
2375
2594
|
});
|
|
2376
2595
|
if (/^include\s+/i.test(r))
|
|
2377
|
-
return
|
|
2596
|
+
return Ve(t, e);
|
|
2378
2597
|
if (/^component\s+/i.test(r))
|
|
2379
|
-
return
|
|
2598
|
+
return Ze(t, e);
|
|
2380
2599
|
if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
|
|
2381
2600
|
return null;
|
|
2382
2601
|
throw d({
|
|
@@ -2385,26 +2604,26 @@ function Pt(t, e) {
|
|
|
2385
2604
|
details: { message: `unsupported hyogen directive: ${r}` }
|
|
2386
2605
|
});
|
|
2387
2606
|
}
|
|
2388
|
-
function
|
|
2607
|
+
function dn(t, e = {}) {
|
|
2389
2608
|
const n = e.path;
|
|
2390
|
-
if (
|
|
2609
|
+
if (he(t))
|
|
2391
2610
|
throw d({
|
|
2392
2611
|
code: "parse_error",
|
|
2393
2612
|
path: n,
|
|
2394
2613
|
details: {
|
|
2395
|
-
message:
|
|
2614
|
+
message: de(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2396
2615
|
}
|
|
2397
2616
|
});
|
|
2398
|
-
const r =
|
|
2617
|
+
const r = $(t);
|
|
2399
2618
|
if (r.length === 0)
|
|
2400
2619
|
return { source: t, directives: [] };
|
|
2401
2620
|
const i = [];
|
|
2402
2621
|
let s = t, o = 0, a = 0;
|
|
2403
2622
|
for (const c of r) {
|
|
2404
|
-
const h =
|
|
2623
|
+
const h = hn(c.inner, n);
|
|
2405
2624
|
if (!h || h.kind === "control")
|
|
2406
2625
|
continue;
|
|
2407
|
-
const l = c.start - o,
|
|
2626
|
+
const l = c.start - o, u = c.end - o;
|
|
2408
2627
|
if (h.kind === "component") {
|
|
2409
2628
|
e.registry && e.registry.register(
|
|
2410
2629
|
{
|
|
@@ -2415,39 +2634,39 @@ function Kt(t, e = {}) {
|
|
|
2415
2634
|
Object.keys(e.context ?? {}),
|
|
2416
2635
|
n
|
|
2417
2636
|
);
|
|
2418
|
-
const
|
|
2419
|
-
s =
|
|
2637
|
+
const m = s.slice(0, l), f = s.slice(u);
|
|
2638
|
+
s = A(m, f), o += c.raw.length + me(m, f);
|
|
2420
2639
|
continue;
|
|
2421
2640
|
}
|
|
2422
|
-
const
|
|
2423
|
-
i.push({ ...h, marker:
|
|
2641
|
+
const w = ln(a++);
|
|
2642
|
+
i.push({ ...h, marker: w, raw: c.raw }), s = s.slice(0, l) + w + s.slice(u), o += c.raw.length - w.length;
|
|
2424
2643
|
}
|
|
2425
2644
|
return { source: s, directives: i };
|
|
2426
2645
|
}
|
|
2427
|
-
function
|
|
2646
|
+
function un(t, e) {
|
|
2428
2647
|
return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
|
|
2429
2648
|
` : `${e.rawFrontMatter}
|
|
2430
2649
|
${t}`;
|
|
2431
2650
|
}
|
|
2432
|
-
function
|
|
2651
|
+
function pn(t, e = !1) {
|
|
2433
2652
|
if (e)
|
|
2434
2653
|
return t;
|
|
2435
|
-
const n =
|
|
2654
|
+
const n = $(t);
|
|
2436
2655
|
if (n.length === 0)
|
|
2437
2656
|
return t;
|
|
2438
2657
|
let r = t, i = 0;
|
|
2439
2658
|
for (const s of n) {
|
|
2440
2659
|
const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
|
|
2441
|
-
r =
|
|
2660
|
+
r = A(c, h), i += s.raw.length + me(c, h);
|
|
2442
2661
|
}
|
|
2443
2662
|
return r;
|
|
2444
2663
|
}
|
|
2445
|
-
const
|
|
2446
|
-
function
|
|
2664
|
+
const fn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
2665
|
+
function mn(t, e) {
|
|
2447
2666
|
const n = t.trim();
|
|
2448
2667
|
if (n === "endblock")
|
|
2449
2668
|
return { kind: "endblock" };
|
|
2450
|
-
const r =
|
|
2669
|
+
const r = fn.exec(n);
|
|
2451
2670
|
if (!r)
|
|
2452
2671
|
throw d({
|
|
2453
2672
|
code: "parse_error",
|
|
@@ -2455,7 +2674,7 @@ function Xt(t, e) {
|
|
|
2455
2674
|
details: { message: "invalid block directive" }
|
|
2456
2675
|
});
|
|
2457
2676
|
const i = r[1];
|
|
2458
|
-
if (
|
|
2677
|
+
if (ze(i))
|
|
2459
2678
|
throw d({
|
|
2460
2679
|
code: "parse_error",
|
|
2461
2680
|
path: e,
|
|
@@ -2463,35 +2682,35 @@ function Xt(t, e) {
|
|
|
2463
2682
|
});
|
|
2464
2683
|
return { kind: "block", name: i };
|
|
2465
2684
|
}
|
|
2466
|
-
function
|
|
2467
|
-
const { path: n, mode: r, hasExtend: i = !1 } = e, s =
|
|
2685
|
+
function Te(t, e) {
|
|
2686
|
+
const { path: n, mode: r, hasExtend: i = !1 } = e, s = $(t);
|
|
2468
2687
|
if (s.length === 0) return [];
|
|
2469
2688
|
const o = [], a = [], c = /* @__PURE__ */ new Set();
|
|
2470
2689
|
for (const h of s) {
|
|
2471
2690
|
const l = E(h.inner);
|
|
2472
2691
|
if (l.length !== 1) continue;
|
|
2473
|
-
const
|
|
2474
|
-
if (!(
|
|
2692
|
+
const u = l[0];
|
|
2693
|
+
if (!(u === "endblock" || u.startsWith("block "))) continue;
|
|
2475
2694
|
if (r === "child" && !i)
|
|
2476
2695
|
throw d({
|
|
2477
2696
|
code: "parse_error",
|
|
2478
2697
|
path: n,
|
|
2479
2698
|
details: { message: "orphan block without extend" }
|
|
2480
2699
|
});
|
|
2481
|
-
const
|
|
2482
|
-
if (
|
|
2483
|
-
const
|
|
2484
|
-
if (!
|
|
2700
|
+
const m = mn(u, n);
|
|
2701
|
+
if (m.kind === "endblock") {
|
|
2702
|
+
const f = a.pop();
|
|
2703
|
+
if (!f)
|
|
2485
2704
|
throw d({
|
|
2486
2705
|
code: "parse_error",
|
|
2487
2706
|
path: n,
|
|
2488
2707
|
details: { message: "endblock without matching block opener" }
|
|
2489
2708
|
});
|
|
2490
|
-
const y = t.slice(
|
|
2709
|
+
const y = t.slice(f.openerEnd, h.start);
|
|
2491
2710
|
o.push({
|
|
2492
|
-
name:
|
|
2711
|
+
name: f.name,
|
|
2493
2712
|
body: y,
|
|
2494
|
-
start:
|
|
2713
|
+
start: f.start,
|
|
2495
2714
|
end: h.end
|
|
2496
2715
|
});
|
|
2497
2716
|
continue;
|
|
@@ -2502,14 +2721,14 @@ function Ee(t, e) {
|
|
|
2502
2721
|
path: n,
|
|
2503
2722
|
details: { message: "nested block structures are not supported" }
|
|
2504
2723
|
});
|
|
2505
|
-
if (c.has(
|
|
2724
|
+
if (c.has(m.name))
|
|
2506
2725
|
throw d({
|
|
2507
2726
|
code: "parse_error",
|
|
2508
2727
|
path: n,
|
|
2509
|
-
details: { message: `duplicate block: ${
|
|
2728
|
+
details: { message: `duplicate block: ${m.name}` }
|
|
2510
2729
|
});
|
|
2511
|
-
c.add(
|
|
2512
|
-
name:
|
|
2730
|
+
c.add(m.name), a.push({
|
|
2731
|
+
name: m.name,
|
|
2513
2732
|
openerEnd: h.end,
|
|
2514
2733
|
start: h.start
|
|
2515
2734
|
});
|
|
@@ -2522,18 +2741,18 @@ function Ee(t, e) {
|
|
|
2522
2741
|
});
|
|
2523
2742
|
return o;
|
|
2524
2743
|
}
|
|
2525
|
-
function
|
|
2526
|
-
const e =
|
|
2744
|
+
function Ae(t) {
|
|
2745
|
+
const e = $(t), n = [];
|
|
2527
2746
|
for (const r of e) {
|
|
2528
2747
|
const i = E(r.inner);
|
|
2529
2748
|
if (i.length === 0) continue;
|
|
2530
|
-
const s =
|
|
2749
|
+
const s = j(i[0]);
|
|
2531
2750
|
s && n.push({ path: s.path, start: r.start });
|
|
2532
2751
|
}
|
|
2533
2752
|
return n;
|
|
2534
2753
|
}
|
|
2535
|
-
function
|
|
2536
|
-
const e =
|
|
2754
|
+
function gn(t) {
|
|
2755
|
+
const e = $(t);
|
|
2537
2756
|
for (const n of e) {
|
|
2538
2757
|
const r = E(n.inner);
|
|
2539
2758
|
if (r.length !== 1) continue;
|
|
@@ -2542,17 +2761,17 @@ function Qt(t) {
|
|
|
2542
2761
|
}
|
|
2543
2762
|
return !1;
|
|
2544
2763
|
}
|
|
2545
|
-
function
|
|
2764
|
+
function Q(t) {
|
|
2546
2765
|
return t.map((e) => e.body).join("");
|
|
2547
2766
|
}
|
|
2548
|
-
function
|
|
2767
|
+
function wn(t, e, n) {
|
|
2549
2768
|
const r = [...e].sort((o, a) => o.start - a.start), i = [];
|
|
2550
2769
|
let s = 0;
|
|
2551
2770
|
for (const o of r)
|
|
2552
2771
|
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) =>
|
|
2772
|
+
return i.push(t.slice(s)), i.reduce((o, a) => A(o, a));
|
|
2554
2773
|
}
|
|
2555
|
-
function
|
|
2774
|
+
function xn(t) {
|
|
2556
2775
|
if (t instanceof Error && "code" in t && "details" in t) {
|
|
2557
2776
|
const e = t;
|
|
2558
2777
|
if (e.code === "file_not_found" && e.details && e.details.via === "include")
|
|
@@ -2560,7 +2779,7 @@ function tn(t) {
|
|
|
2560
2779
|
}
|
|
2561
2780
|
return { errorToThrow: t, adjusted: !1 };
|
|
2562
2781
|
}
|
|
2563
|
-
async function
|
|
2782
|
+
async function kn(t, e) {
|
|
2564
2783
|
const {
|
|
2565
2784
|
path: n,
|
|
2566
2785
|
context: r,
|
|
@@ -2571,35 +2790,35 @@ async function nn(t, e) {
|
|
|
2571
2790
|
visitStack: c,
|
|
2572
2791
|
warnings: h,
|
|
2573
2792
|
inComponent: l = !1
|
|
2574
|
-
} = e,
|
|
2575
|
-
if (
|
|
2576
|
-
if (
|
|
2793
|
+
} = e, u = Ae(t);
|
|
2794
|
+
if (u.length === 0) {
|
|
2795
|
+
if (gn(t))
|
|
2577
2796
|
throw d({
|
|
2578
2797
|
code: "parse_error",
|
|
2579
2798
|
path: n,
|
|
2580
2799
|
details: { message: "orphan block without extend" }
|
|
2581
2800
|
});
|
|
2582
|
-
return { source: t, context:
|
|
2801
|
+
return { source: t, context: v(r, i) };
|
|
2583
2802
|
}
|
|
2584
|
-
const
|
|
2585
|
-
if (!
|
|
2586
|
-
return { source: t, context:
|
|
2803
|
+
const m = $(t)[0];
|
|
2804
|
+
if (!m)
|
|
2805
|
+
return { source: t, context: v(r, i) };
|
|
2587
2806
|
if (!s)
|
|
2588
2807
|
throw new Error("loader is required when processing extend directives");
|
|
2589
|
-
const
|
|
2590
|
-
if (!(
|
|
2808
|
+
const f = E(m.inner);
|
|
2809
|
+
if (!(f.length > 0 ? j(f[0]) : null))
|
|
2591
2810
|
throw d({
|
|
2592
2811
|
code: "parse_error",
|
|
2593
2812
|
path: n,
|
|
2594
2813
|
details: { message: "extend must be the first hyogen block" }
|
|
2595
2814
|
});
|
|
2596
|
-
if (
|
|
2815
|
+
if (u.length > 1)
|
|
2597
2816
|
throw d({
|
|
2598
2817
|
code: "parse_error",
|
|
2599
2818
|
path: n,
|
|
2600
2819
|
details: { message: "multiple extend directives are not supported" }
|
|
2601
2820
|
});
|
|
2602
|
-
const
|
|
2821
|
+
const W = Te(t, {
|
|
2603
2822
|
path: n,
|
|
2604
2823
|
mode: "child",
|
|
2605
2824
|
hasExtend: !0
|
|
@@ -2607,16 +2826,16 @@ async function nn(t, e) {
|
|
|
2607
2826
|
if (l)
|
|
2608
2827
|
return h?.push({
|
|
2609
2828
|
code: "extend_in_component",
|
|
2610
|
-
message:
|
|
2829
|
+
message: L("extend_in_component", { path: n }),
|
|
2611
2830
|
path: n,
|
|
2612
2831
|
details: { path: n }
|
|
2613
2832
|
}), {
|
|
2614
|
-
source:
|
|
2615
|
-
context:
|
|
2833
|
+
source: Q(W),
|
|
2834
|
+
context: v(r, i)
|
|
2616
2835
|
};
|
|
2617
|
-
const
|
|
2836
|
+
const P = u[0].path, T = n, b = ee(
|
|
2618
2837
|
o,
|
|
2619
|
-
|
|
2838
|
+
P,
|
|
2620
2839
|
n,
|
|
2621
2840
|
n,
|
|
2622
2841
|
a,
|
|
@@ -2624,85 +2843,85 @@ async function nn(t, e) {
|
|
|
2624
2843
|
);
|
|
2625
2844
|
T && c.push(T);
|
|
2626
2845
|
try {
|
|
2627
|
-
const
|
|
2628
|
-
if (
|
|
2846
|
+
const _ = T ? c.check(b) : { circular: !1 };
|
|
2847
|
+
if (_.circular)
|
|
2629
2848
|
return h?.push({
|
|
2630
2849
|
code: "circular_include",
|
|
2631
|
-
message:
|
|
2632
|
-
path:
|
|
2633
|
-
from:
|
|
2850
|
+
message: L("circular_include", {
|
|
2851
|
+
path: b,
|
|
2852
|
+
from: _.from,
|
|
2634
2853
|
via: "extend"
|
|
2635
2854
|
}),
|
|
2636
2855
|
path: n,
|
|
2637
|
-
details: { path:
|
|
2856
|
+
details: { path: b, from: _.from, via: "extend" }
|
|
2638
2857
|
}), {
|
|
2639
|
-
source:
|
|
2640
|
-
context:
|
|
2858
|
+
source: Q(W),
|
|
2859
|
+
context: v(r, i)
|
|
2641
2860
|
};
|
|
2642
|
-
c.push(
|
|
2861
|
+
c.push(b);
|
|
2643
2862
|
try {
|
|
2644
|
-
const
|
|
2645
|
-
if (
|
|
2863
|
+
const R = await s(b);
|
|
2864
|
+
if (R === void 0)
|
|
2646
2865
|
throw new Error("loader returned undefined");
|
|
2647
|
-
const { context:
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
),
|
|
2651
|
-
if (
|
|
2652
|
-
const
|
|
2866
|
+
const { context: I, body: D } = V(
|
|
2867
|
+
R,
|
|
2868
|
+
b
|
|
2869
|
+
), ke = Ae(D);
|
|
2870
|
+
if (ke.length > 0) {
|
|
2871
|
+
const U = ke[0].path, K = ee(
|
|
2653
2872
|
o,
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2873
|
+
U,
|
|
2874
|
+
b,
|
|
2875
|
+
b,
|
|
2657
2876
|
a,
|
|
2658
2877
|
!0
|
|
2659
|
-
),
|
|
2660
|
-
if (
|
|
2878
|
+
), Y = c.check(K);
|
|
2879
|
+
if (Y.circular)
|
|
2661
2880
|
return h?.push({
|
|
2662
2881
|
code: "circular_include",
|
|
2663
|
-
message:
|
|
2664
|
-
path:
|
|
2665
|
-
from:
|
|
2882
|
+
message: L("circular_include", {
|
|
2883
|
+
path: K,
|
|
2884
|
+
from: Y.from,
|
|
2666
2885
|
via: "extend"
|
|
2667
2886
|
}),
|
|
2668
2887
|
path: n,
|
|
2669
|
-
details: { path:
|
|
2888
|
+
details: { path: K, from: Y.from, via: "extend" }
|
|
2670
2889
|
}), {
|
|
2671
|
-
source:
|
|
2672
|
-
context:
|
|
2890
|
+
source: Q(W),
|
|
2891
|
+
context: v(r, i)
|
|
2673
2892
|
};
|
|
2674
2893
|
throw d({
|
|
2675
2894
|
code: "parse_error",
|
|
2676
|
-
path:
|
|
2895
|
+
path: b,
|
|
2677
2896
|
details: { message: "layout extend is not supported" }
|
|
2678
2897
|
});
|
|
2679
2898
|
}
|
|
2680
|
-
const
|
|
2681
|
-
path:
|
|
2899
|
+
const Pe = Te(D, {
|
|
2900
|
+
path: b,
|
|
2682
2901
|
mode: "layout"
|
|
2683
|
-
}),
|
|
2684
|
-
|
|
2685
|
-
),
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
),
|
|
2902
|
+
}), Ke = new Map(
|
|
2903
|
+
W.map((U) => [U.name, U.body])
|
|
2904
|
+
), Ye = wn(
|
|
2905
|
+
D,
|
|
2906
|
+
Pe,
|
|
2907
|
+
Ke
|
|
2908
|
+
), Ge = v(
|
|
2690
2909
|
r,
|
|
2691
|
-
|
|
2910
|
+
I,
|
|
2692
2911
|
i
|
|
2693
2912
|
);
|
|
2694
|
-
return { source:
|
|
2913
|
+
return { source: Ye, context: Ge };
|
|
2695
2914
|
} finally {
|
|
2696
2915
|
c.pop();
|
|
2697
2916
|
}
|
|
2698
|
-
} catch (
|
|
2699
|
-
const
|
|
2700
|
-
throw
|
|
2917
|
+
} catch (_) {
|
|
2918
|
+
const R = xn(_);
|
|
2919
|
+
throw R.adjusted ? R.errorToThrow : _;
|
|
2701
2920
|
} finally {
|
|
2702
2921
|
T && c.pop();
|
|
2703
2922
|
}
|
|
2704
2923
|
}
|
|
2705
|
-
const
|
|
2924
|
+
const yn = se.warningReasons, bn = [
|
|
2706
2925
|
{
|
|
2707
2926
|
reason: "contains_html_script_tag",
|
|
2708
2927
|
test: (t) => /<\/?script\b/i.test(t)
|
|
@@ -2724,17 +2943,17 @@ const rn = re.warningReasons, sn = [
|
|
|
2724
2943
|
test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
|
|
2725
2944
|
}
|
|
2726
2945
|
];
|
|
2727
|
-
function
|
|
2728
|
-
return
|
|
2946
|
+
function vn(t) {
|
|
2947
|
+
return yn[t] ?? t;
|
|
2729
2948
|
}
|
|
2730
|
-
function
|
|
2949
|
+
function ne(t, e, n, r) {
|
|
2731
2950
|
if (typeof t == "string") {
|
|
2732
|
-
for (const i of
|
|
2951
|
+
for (const i of bn)
|
|
2733
2952
|
i.test(t) && n.push({
|
|
2734
2953
|
code: "suspicious_context_value",
|
|
2735
|
-
message:
|
|
2954
|
+
message: L("suspicious_context_value", {
|
|
2736
2955
|
key: e,
|
|
2737
|
-
reason:
|
|
2956
|
+
reason: vn(i.reason)
|
|
2738
2957
|
}),
|
|
2739
2958
|
path: r,
|
|
2740
2959
|
details: { key: e, reason: i.reason }
|
|
@@ -2744,7 +2963,7 @@ function te(t, e, n, r) {
|
|
|
2744
2963
|
if (t != null) {
|
|
2745
2964
|
if (Array.isArray(t)) {
|
|
2746
2965
|
for (let i = 0; i < t.length; i++)
|
|
2747
|
-
|
|
2966
|
+
ne(t[i], `${e}[${i}]`, n, r);
|
|
2748
2967
|
return;
|
|
2749
2968
|
}
|
|
2750
2969
|
if (typeof t == "object")
|
|
@@ -2752,25 +2971,180 @@ function te(t, e, n, r) {
|
|
|
2752
2971
|
t
|
|
2753
2972
|
)) {
|
|
2754
2973
|
const o = e.length > 0 ? `${e}.${i}` : i;
|
|
2755
|
-
|
|
2974
|
+
ne(s, o, n, r);
|
|
2756
2975
|
}
|
|
2757
2976
|
}
|
|
2758
2977
|
}
|
|
2759
|
-
function
|
|
2978
|
+
function _n(t, e, n) {
|
|
2760
2979
|
for (const [r, i] of Object.entries(t))
|
|
2761
|
-
|
|
2980
|
+
ne(i, r, e, n);
|
|
2981
|
+
}
|
|
2982
|
+
const Sn = /^=+[ \t]*$/, Cn = /^-+[ \t]*$/, En = /^(```|~~~)/, $n = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
|
|
2983
|
+
function re(t) {
|
|
2984
|
+
const e = $n.exec(t);
|
|
2985
|
+
return e && e.index !== void 0 ? {
|
|
2986
|
+
text: t.slice(0, e.index).trim(),
|
|
2987
|
+
explicitId: e[1]
|
|
2988
|
+
} : { text: t.trim() };
|
|
2989
|
+
}
|
|
2990
|
+
function Wn(t) {
|
|
2991
|
+
let e = 0;
|
|
2992
|
+
for (; e < t.length && e < 6 && t[e] === "#"; )
|
|
2993
|
+
e += 1;
|
|
2994
|
+
if (e === 0 || e === 6 && e < t.length && t[e] === "#" || e >= t.length || t[e] !== " " && t[e] !== " ")
|
|
2995
|
+
return null;
|
|
2996
|
+
let n = e;
|
|
2997
|
+
for (; n < t.length && (t[n] === " " || t[n] === " "); )
|
|
2998
|
+
n += 1;
|
|
2999
|
+
if (n >= t.length)
|
|
3000
|
+
return null;
|
|
3001
|
+
let r = t.length;
|
|
3002
|
+
for (; r > n && (t[r - 1] === " " || t[r - 1] === " "); )
|
|
3003
|
+
r -= 1;
|
|
3004
|
+
let i = r;
|
|
3005
|
+
if (r > n && t[r - 1] === "#") {
|
|
3006
|
+
let o = r - 1;
|
|
3007
|
+
for (; o > n && t[o - 1] === "#"; )
|
|
3008
|
+
o -= 1;
|
|
3009
|
+
if (o > n && (t[o - 1] === " " || t[o - 1] === " ")) {
|
|
3010
|
+
let a = o - 1;
|
|
3011
|
+
for (; a >= n && (t[a] === " " || t[a] === " "); )
|
|
3012
|
+
a -= 1;
|
|
3013
|
+
i = a + 1;
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
if (i <= n)
|
|
3017
|
+
return null;
|
|
3018
|
+
const s = re(t.slice(n, i));
|
|
3019
|
+
return { level: e, ...s };
|
|
3020
|
+
}
|
|
3021
|
+
function Re(t, e, n) {
|
|
3022
|
+
let r = n;
|
|
3023
|
+
for (; r < t.length; ) {
|
|
3024
|
+
if (!e.inHtmlComment) {
|
|
3025
|
+
const s = t.indexOf("<!--", r);
|
|
3026
|
+
if (s === -1)
|
|
3027
|
+
return;
|
|
3028
|
+
e.inHtmlComment = !0, r = s + 4;
|
|
3029
|
+
continue;
|
|
3030
|
+
}
|
|
3031
|
+
const i = t.indexOf("-->", r);
|
|
3032
|
+
if (i === -1)
|
|
3033
|
+
return;
|
|
3034
|
+
e.inHtmlComment = !1, r = i + 3;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
function Tn(t, e) {
|
|
3038
|
+
if (e.inFence || e.inHtmlComment)
|
|
3039
|
+
return !0;
|
|
3040
|
+
const n = t.trim();
|
|
3041
|
+
return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
|
|
3042
|
+
}
|
|
3043
|
+
function An(t) {
|
|
3044
|
+
const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
|
|
3045
|
+
for (let i = 0; i < e.length; i++) {
|
|
3046
|
+
const s = e[i];
|
|
3047
|
+
if (r.inFence) {
|
|
3048
|
+
const l = s.trim();
|
|
3049
|
+
l.startsWith(r.inFence.marker) && /^(`{3,}|~{3,})\s*$/.test(l) && (r.inFence = !1);
|
|
3050
|
+
continue;
|
|
3051
|
+
}
|
|
3052
|
+
if (r.inHtmlComment) {
|
|
3053
|
+
Re(s, r, 0);
|
|
3054
|
+
continue;
|
|
3055
|
+
}
|
|
3056
|
+
const o = En.exec(s.trimStart());
|
|
3057
|
+
if (o) {
|
|
3058
|
+
const l = o[1];
|
|
3059
|
+
s.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
|
|
3060
|
+
continue;
|
|
3061
|
+
}
|
|
3062
|
+
if (s.trim().startsWith("<!--")) {
|
|
3063
|
+
Re(s, r, s.indexOf("<!--"));
|
|
3064
|
+
continue;
|
|
3065
|
+
}
|
|
3066
|
+
if (Tn(s, r))
|
|
3067
|
+
continue;
|
|
3068
|
+
const c = Wn(s);
|
|
3069
|
+
if (c) {
|
|
3070
|
+
n.push(c);
|
|
3071
|
+
continue;
|
|
3072
|
+
}
|
|
3073
|
+
const h = e[i + 1];
|
|
3074
|
+
if (h !== void 0 && s.trim().length > 0 && !s.trimStart().startsWith("#") && !s.trimStart().startsWith(">") && !s.trimStart().startsWith("|")) {
|
|
3075
|
+
if (Sn.test(h)) {
|
|
3076
|
+
const l = re(s.trim());
|
|
3077
|
+
n.push({ level: 1, ...l }), i += 1;
|
|
3078
|
+
continue;
|
|
3079
|
+
}
|
|
3080
|
+
if (Cn.test(h) && h.trim().length >= 1) {
|
|
3081
|
+
const l = re(s.trim());
|
|
3082
|
+
n.push({ level: 2, ...l }), i += 1;
|
|
3083
|
+
continue;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
return n;
|
|
3088
|
+
}
|
|
3089
|
+
const Rn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
|
|
3090
|
+
function Mn() {
|
|
3091
|
+
const t = /* @__PURE__ */ new Map();
|
|
3092
|
+
return {
|
|
3093
|
+
slug(e, n) {
|
|
3094
|
+
const r = n !== void 0 && n.length > 0 ? n : On(e), i = t.get(r) ?? 0;
|
|
3095
|
+
return t.set(r, i + 1), i === 0 ? r : `${r}-${i}`;
|
|
3096
|
+
}
|
|
3097
|
+
};
|
|
3098
|
+
}
|
|
3099
|
+
function On(t) {
|
|
3100
|
+
return t.toLowerCase().replace(Rn, "").replace(/\s+/g, "-");
|
|
3101
|
+
}
|
|
3102
|
+
function Ln(t) {
|
|
3103
|
+
let e = t.trim();
|
|
3104
|
+
e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
|
|
3105
|
+
for (let n = 0; n < 3; n++)
|
|
3106
|
+
e = e.replace(/\*\*([^*]+)\*\*/g, "$1"), e = e.replace(/__([^_]+)__/g, "$1"), e = e.replace(/~~([^~]+)~~/g, "$1"), e = e.replace(/\*([^*]+)\*/g, "$1"), e = e.replace(/_([^_]+)_/g, "$1"), e = e.replace(/`([^`]+)`/g, "$1");
|
|
3107
|
+
return e.trim();
|
|
3108
|
+
}
|
|
3109
|
+
function Hn(t, e) {
|
|
3110
|
+
if (t.length === 0)
|
|
3111
|
+
return "";
|
|
3112
|
+
const n = Mn(), i = t.map((o) => {
|
|
3113
|
+
const a = Ln(o.text), c = n.slug(a, o.explicitId);
|
|
3114
|
+
return { level: o.level, text: a, anchor: c };
|
|
3115
|
+
}).filter((o) => o.level <= e);
|
|
3116
|
+
if (i.length === 0)
|
|
3117
|
+
return "";
|
|
3118
|
+
const s = Math.min(...i.map((o) => o.level));
|
|
3119
|
+
return i.map((o) => `${" ".repeat((o.level - s) * 2)}- [${o.text}](#${o.anchor})`).join(`
|
|
3120
|
+
`);
|
|
2762
3121
|
}
|
|
2763
|
-
|
|
2764
|
-
const
|
|
3122
|
+
function Dn(t, e = {}) {
|
|
3123
|
+
const r = $(t).filter((o) => {
|
|
3124
|
+
const a = E(o.inner);
|
|
3125
|
+
return a.length === 1 && q(a[0]);
|
|
3126
|
+
});
|
|
3127
|
+
if (r.length === 0)
|
|
3128
|
+
return t;
|
|
3129
|
+
const i = An(t);
|
|
3130
|
+
let s = t;
|
|
3131
|
+
for (let o = r.length - 1; o >= 0; o--) {
|
|
3132
|
+
const a = r[o], { maxLevel: c } = sn(a.inner, e.path), h = Hn(i, c), l = s.slice(0, a.start), u = s.slice(a.end);
|
|
3133
|
+
s = A(A(l, h), u);
|
|
3134
|
+
}
|
|
3135
|
+
return s;
|
|
3136
|
+
}
|
|
3137
|
+
async function xe(t, e) {
|
|
3138
|
+
const n = e.path, r = e.context, i = e.registry ?? new De(), s = e.warnings ?? [], o = e.visitStack ?? new Ue(), {
|
|
2765
3139
|
source: a,
|
|
2766
3140
|
declarationUpdates: c
|
|
2767
|
-
} = await
|
|
2768
|
-
|
|
2769
|
-
|
|
3141
|
+
} = await on(t, { path: n, context: { ...r } });
|
|
3142
|
+
_n(
|
|
3143
|
+
v(r, c ?? {}),
|
|
2770
3144
|
s,
|
|
2771
3145
|
n
|
|
2772
3146
|
);
|
|
2773
|
-
const h = await
|
|
3147
|
+
const h = await kn(a, {
|
|
2774
3148
|
path: n,
|
|
2775
3149
|
context: r,
|
|
2776
3150
|
declarationUpdates: c ?? {},
|
|
@@ -2780,19 +3154,19 @@ async function ge(t, e) {
|
|
|
2780
3154
|
visitStack: o,
|
|
2781
3155
|
warnings: s,
|
|
2782
3156
|
inComponent: e.inComponent ?? !1
|
|
2783
|
-
}), { source: l, context:
|
|
3157
|
+
}), { source: l, context: u } = h, { source: w, directives: m } = dn(l, {
|
|
2784
3158
|
path: n,
|
|
2785
3159
|
registry: i,
|
|
2786
|
-
context:
|
|
2787
|
-
}),
|
|
2788
|
-
if (
|
|
3160
|
+
context: u
|
|
3161
|
+
}), f = e.loader;
|
|
3162
|
+
if (m.length > 0 && !f)
|
|
2789
3163
|
throw new Error("loader is required when processing include directives");
|
|
2790
|
-
let y =
|
|
2791
|
-
return
|
|
2792
|
-
source:
|
|
2793
|
-
directives:
|
|
2794
|
-
context:
|
|
2795
|
-
loader:
|
|
3164
|
+
let y = w;
|
|
3165
|
+
return m.length > 0 && f && (y = await Qt({
|
|
3166
|
+
source: w,
|
|
3167
|
+
directives: m,
|
|
3168
|
+
context: u,
|
|
3169
|
+
loader: f,
|
|
2796
3170
|
root: e.root,
|
|
2797
3171
|
path: n,
|
|
2798
3172
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
@@ -2801,70 +3175,74 @@ async function ge(t, e) {
|
|
|
2801
3175
|
warnings: s,
|
|
2802
3176
|
registry: i,
|
|
2803
3177
|
constrainToRoot: e.constrainToRoot
|
|
2804
|
-
})), y = await
|
|
2805
|
-
context:
|
|
3178
|
+
})), y = await Yt(y, {
|
|
3179
|
+
context: u,
|
|
2806
3180
|
path: n,
|
|
2807
3181
|
registry: i,
|
|
2808
|
-
loader:
|
|
3182
|
+
loader: f,
|
|
2809
3183
|
rootDir: e.root,
|
|
2810
3184
|
warnings: s,
|
|
2811
3185
|
visitStack: o,
|
|
2812
|
-
parentContext:
|
|
3186
|
+
parentContext: u,
|
|
2813
3187
|
preserveHgComments: e.preserveHgComments,
|
|
2814
3188
|
constrainToRoot: e.constrainToRoot
|
|
2815
|
-
}), y = await
|
|
3189
|
+
}), y = await Ne(y, u, {
|
|
2816
3190
|
path: n,
|
|
2817
3191
|
registry: i,
|
|
2818
|
-
loader:
|
|
3192
|
+
loader: f,
|
|
2819
3193
|
rootDir: e.root,
|
|
2820
3194
|
warnings: s,
|
|
2821
3195
|
visitStack: o,
|
|
2822
|
-
parentContext:
|
|
3196
|
+
parentContext: u,
|
|
2823
3197
|
preserveHgComments: e.preserveHgComments,
|
|
2824
3198
|
constrainToRoot: e.constrainToRoot
|
|
2825
|
-
}), y =
|
|
3199
|
+
}), y = Dn(y, { path: n }), y = pn(y, e.preserveHgComments), y;
|
|
2826
3200
|
}
|
|
2827
|
-
async function
|
|
2828
|
-
const n = e.path, r =
|
|
3201
|
+
async function qe(t, e = {}) {
|
|
3202
|
+
const n = e.path, r = v(e.context), i = e.registry ?? new De(), s = e.warnings ?? [], o = e.visitStack ?? new Ue(), { context: a, body: c, rawFrontMatter: h } = V(
|
|
2829
3203
|
t,
|
|
2830
3204
|
n
|
|
2831
|
-
), l =
|
|
2832
|
-
let
|
|
3205
|
+
), l = v(r, a);
|
|
3206
|
+
let u = await xe(c, {
|
|
2833
3207
|
...e,
|
|
2834
3208
|
context: l,
|
|
2835
3209
|
registry: i,
|
|
2836
3210
|
warnings: s,
|
|
2837
3211
|
visitStack: o
|
|
2838
3212
|
});
|
|
2839
|
-
return
|
|
3213
|
+
return u = un(u, {
|
|
2840
3214
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
2841
3215
|
rawFrontMatter: h
|
|
2842
3216
|
}), {
|
|
2843
|
-
markdown:
|
|
3217
|
+
markdown: u,
|
|
2844
3218
|
warnings: s
|
|
2845
3219
|
};
|
|
2846
3220
|
}
|
|
2847
|
-
async function
|
|
2848
|
-
const n = e.path, { context: r, body: i } =
|
|
2849
|
-
return
|
|
3221
|
+
async function Nn(t, e) {
|
|
3222
|
+
const n = e.path, { context: r, body: i } = V(t, n), s = v(e.context, r);
|
|
3223
|
+
return xe(i, {
|
|
2850
3224
|
...e,
|
|
2851
3225
|
context: s,
|
|
2852
3226
|
preserveFrontMatter: !1
|
|
2853
3227
|
});
|
|
2854
3228
|
}
|
|
2855
|
-
async function
|
|
2856
|
-
const r =
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
3229
|
+
async function Fn(t, e, n) {
|
|
3230
|
+
const r = n?.loader ?? oe(), i = await Et(t, { root: n?.root }), s = i.rootDir ?? n?.root, o = n?.dataSources, a = o && Object.keys(o).length > 0 ? await He(o, { root: s, loader: r }) : {}, c = v(
|
|
3231
|
+
a,
|
|
3232
|
+
e,
|
|
3233
|
+
n?.serverContext
|
|
3234
|
+
);
|
|
3235
|
+
return qe(i.source, {
|
|
3236
|
+
context: c,
|
|
3237
|
+
loader: r,
|
|
3238
|
+
root: s,
|
|
3239
|
+
path: i.entryPath ?? n?.path,
|
|
3240
|
+
constrainToRoot: i.constrainToRoot,
|
|
2863
3241
|
preserveFrontMatter: n?.preserveFrontMatter,
|
|
2864
3242
|
preserveHgComments: n?.preserveHgComments
|
|
2865
3243
|
});
|
|
2866
3244
|
}
|
|
2867
|
-
async function
|
|
3245
|
+
async function nr(t, e, n) {
|
|
2868
3246
|
if (n != null && "serverContext" in n && n.serverContext != null)
|
|
2869
3247
|
throw d({
|
|
2870
3248
|
code: "server_context_on_client"
|
|
@@ -2881,8 +3259,8 @@ async function Hn(t, e, n) {
|
|
|
2881
3259
|
});
|
|
2882
3260
|
let i, s;
|
|
2883
3261
|
typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
|
|
2884
|
-
const o =
|
|
2885
|
-
return
|
|
3262
|
+
const o = v(e);
|
|
3263
|
+
return qe(i, {
|
|
2886
3264
|
context: o,
|
|
2887
3265
|
loader: r,
|
|
2888
3266
|
root: n?.root,
|
|
@@ -2892,16 +3270,16 @@ async function Hn(t, e, n) {
|
|
|
2892
3270
|
constrainToRoot: n?.constrainToRoot
|
|
2893
3271
|
});
|
|
2894
3272
|
}
|
|
2895
|
-
function
|
|
2896
|
-
if (
|
|
3273
|
+
function jn(t, e) {
|
|
3274
|
+
if (he(t))
|
|
2897
3275
|
throw d({
|
|
2898
3276
|
code: "parse_error",
|
|
2899
3277
|
path: e,
|
|
2900
3278
|
details: {
|
|
2901
|
-
message:
|
|
3279
|
+
message: de(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2902
3280
|
}
|
|
2903
3281
|
});
|
|
2904
|
-
const n = [], r =
|
|
3282
|
+
const n = [], r = $(t);
|
|
2905
3283
|
for (const i of r) {
|
|
2906
3284
|
const s = E(i.inner);
|
|
2907
3285
|
if (s.length === 0)
|
|
@@ -2910,12 +3288,12 @@ function ln(t, e) {
|
|
|
2910
3288
|
path: e,
|
|
2911
3289
|
details: { message: "empty hyogen block" }
|
|
2912
3290
|
});
|
|
2913
|
-
if (s.length === 1 &&
|
|
3291
|
+
if (s.length === 1 && ue(s[0]) || s.length === 1 && q(s[0]) || s.length === 1 && (te(s[0]) || z(s[0])))
|
|
2914
3292
|
continue;
|
|
2915
3293
|
const o = s[0];
|
|
2916
3294
|
if (o === "endblock" || /^block\s+/.test(o))
|
|
2917
3295
|
continue;
|
|
2918
|
-
const a =
|
|
3296
|
+
const a = j(o, e);
|
|
2919
3297
|
if (a) {
|
|
2920
3298
|
n.push({ kind: "extend", path: a.path });
|
|
2921
3299
|
continue;
|
|
@@ -2924,7 +3302,7 @@ function ln(t, e) {
|
|
|
2924
3302
|
const c = s.join(`
|
|
2925
3303
|
`);
|
|
2926
3304
|
if (z(c) || s.every(
|
|
2927
|
-
(l) =>
|
|
3305
|
+
(l) => te(l) || j(l) !== null
|
|
2928
3306
|
))
|
|
2929
3307
|
continue;
|
|
2930
3308
|
throw d({
|
|
@@ -2934,12 +3312,12 @@ function ln(t, e) {
|
|
|
2934
3312
|
});
|
|
2935
3313
|
}
|
|
2936
3314
|
if (/^include\s+/i.test(o)) {
|
|
2937
|
-
const c =
|
|
3315
|
+
const c = Ve(i.inner, e);
|
|
2938
3316
|
n.push({ kind: "include", path: c.path });
|
|
2939
3317
|
continue;
|
|
2940
3318
|
}
|
|
2941
3319
|
if (/^component\s+/i.test(o)) {
|
|
2942
|
-
const c =
|
|
3320
|
+
const c = Ze(i.inner, e);
|
|
2943
3321
|
n.push({ kind: "component", path: c.path });
|
|
2944
3322
|
continue;
|
|
2945
3323
|
}
|
|
@@ -2951,8 +3329,8 @@ function ln(t, e) {
|
|
|
2951
3329
|
}
|
|
2952
3330
|
return n;
|
|
2953
3331
|
}
|
|
2954
|
-
function
|
|
2955
|
-
return
|
|
3332
|
+
function Bn(t, e, n) {
|
|
3333
|
+
return H(t) ? t : Z(t, {
|
|
2956
3334
|
rootDir: n.root,
|
|
2957
3335
|
fromPath: e,
|
|
2958
3336
|
documentPath: e,
|
|
@@ -2960,19 +3338,19 @@ function dn(t, e, n) {
|
|
|
2960
3338
|
hyogenPath: !0
|
|
2961
3339
|
});
|
|
2962
3340
|
}
|
|
2963
|
-
async function
|
|
3341
|
+
async function In(t, e, n = {}) {
|
|
2964
3342
|
const r = t.map(
|
|
2965
|
-
(l) =>
|
|
3343
|
+
(l) => H(l) ? l : p.resolve(l)
|
|
2966
3344
|
), i = new Set(r), s = /* @__PURE__ */ new Set(), o = [], a = [...r];
|
|
2967
3345
|
for (; a.length > 0; ) {
|
|
2968
3346
|
const l = a.shift();
|
|
2969
3347
|
if (s.has(l))
|
|
2970
3348
|
continue;
|
|
2971
3349
|
s.add(l);
|
|
2972
|
-
const
|
|
2973
|
-
for (const
|
|
2974
|
-
const
|
|
2975
|
-
o.push({ from: l, to:
|
|
3350
|
+
const u = await e(l), w = jn(u, l);
|
|
3351
|
+
for (const m of w) {
|
|
3352
|
+
const f = Bn(m.path, l, n);
|
|
3353
|
+
o.push({ from: l, to: f, kind: m.kind }), s.has(f) || a.push(f);
|
|
2976
3354
|
}
|
|
2977
3355
|
}
|
|
2978
3356
|
const c = [...s], h = c.filter((l) => !i.has(l));
|
|
@@ -2983,22 +3361,22 @@ async function pn(t, e, n = {}) {
|
|
|
2983
3361
|
edges: o
|
|
2984
3362
|
};
|
|
2985
3363
|
}
|
|
2986
|
-
function
|
|
3364
|
+
function Un(t) {
|
|
2987
3365
|
return t.replace(/\\/g, "/").split("/").filter((r) => r.length > 0).some((r) => r.startsWith("_"));
|
|
2988
3366
|
}
|
|
2989
|
-
function
|
|
2990
|
-
return
|
|
3367
|
+
function zn(t) {
|
|
3368
|
+
return rt.scan(t).isGlob;
|
|
2991
3369
|
}
|
|
2992
|
-
function
|
|
2993
|
-
return t.root ?
|
|
3370
|
+
function Zn(t) {
|
|
3371
|
+
return t.root ? p.resolve(t.root) : t.cwd ? p.resolve(t.cwd) : B(process.cwd()) ?? process.cwd();
|
|
2994
3372
|
}
|
|
2995
|
-
async function
|
|
2996
|
-
const n = Array.isArray(t) ? t : [t], r =
|
|
3373
|
+
async function Vn(t, e = {}) {
|
|
3374
|
+
const n = Array.isArray(t) ? t : [t], r = Zn(e), i = e.includeUnderscoreEntries === !0, s = /* @__PURE__ */ new Map();
|
|
2997
3375
|
for (const o of n) {
|
|
2998
|
-
if (!
|
|
2999
|
-
const c =
|
|
3376
|
+
if (!zn(o)) {
|
|
3377
|
+
const c = p.isAbsolute(o) ? p.resolve(o) : p.resolve(r, o);
|
|
3000
3378
|
try {
|
|
3001
|
-
if (!(await
|
|
3379
|
+
if (!(await ie(c)).isFile())
|
|
3002
3380
|
throw d({
|
|
3003
3381
|
code: "file_not_found",
|
|
3004
3382
|
path: c,
|
|
@@ -3019,50 +3397,50 @@ async function gn(t, e = {}) {
|
|
|
3019
3397
|
}
|
|
3020
3398
|
}) : l;
|
|
3021
3399
|
}
|
|
3022
|
-
const h =
|
|
3400
|
+
const h = p.relative(r, c).replace(/\\/g, "/");
|
|
3023
3401
|
s.set(h, c);
|
|
3024
3402
|
continue;
|
|
3025
3403
|
}
|
|
3026
|
-
const a = await
|
|
3404
|
+
const a = await nt(o, {
|
|
3027
3405
|
cwd: r,
|
|
3028
3406
|
absolute: !0,
|
|
3029
3407
|
onlyFiles: !0,
|
|
3030
3408
|
dot: !1
|
|
3031
3409
|
});
|
|
3032
3410
|
for (const c of a) {
|
|
3033
|
-
const h =
|
|
3034
|
-
!i &&
|
|
3411
|
+
const h = p.relative(r, c).replace(/\\/g, "/");
|
|
3412
|
+
!i && Un(h) || s.set(h, p.resolve(c));
|
|
3035
3413
|
}
|
|
3036
3414
|
}
|
|
3037
3415
|
return [...s.values()];
|
|
3038
3416
|
}
|
|
3039
|
-
function
|
|
3417
|
+
function qn(t) {
|
|
3040
3418
|
return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
|
|
3041
3419
|
}
|
|
3042
|
-
function
|
|
3420
|
+
function Pn(t, e) {
|
|
3043
3421
|
if (t)
|
|
3044
|
-
return
|
|
3422
|
+
return p.resolve(t);
|
|
3045
3423
|
for (const n of e) {
|
|
3046
|
-
const r =
|
|
3424
|
+
const r = B(n);
|
|
3047
3425
|
if (r)
|
|
3048
3426
|
return r;
|
|
3049
3427
|
}
|
|
3050
|
-
return e.length > 0 ?
|
|
3428
|
+
return e.length > 0 ? p.dirname(p.resolve(e[0])) : process.cwd();
|
|
3051
3429
|
}
|
|
3052
|
-
async function
|
|
3053
|
-
const e = await
|
|
3430
|
+
async function rr(t) {
|
|
3431
|
+
const e = await Vn(t.input, {
|
|
3054
3432
|
root: t.root,
|
|
3055
3433
|
includeUnderscoreEntries: t.includeUnderscoreEntries
|
|
3056
|
-
}), n =
|
|
3057
|
-
e.length > 0 && await
|
|
3434
|
+
}), n = Pn(t.root, e), r = t.loader ?? oe(), i = B(n) !== void 0;
|
|
3435
|
+
e.length > 0 && await In(e, r, {
|
|
3058
3436
|
root: n,
|
|
3059
3437
|
constrainToRoot: i
|
|
3060
3438
|
});
|
|
3061
|
-
const s = [],
|
|
3062
|
-
for (const
|
|
3063
|
-
const
|
|
3064
|
-
{ path:
|
|
3065
|
-
|
|
3439
|
+
const s = t.dataSources, o = s && Object.keys(s).length > 0 ? await He(s, { root: n, loader: r }) : {}, a = v(o, t.context), c = [], h = [];
|
|
3440
|
+
for (const l of e) {
|
|
3441
|
+
const u = p.resolve(l), w = p.relative(n, u).replace(/\\/g, "/"), m = await Fn(
|
|
3442
|
+
{ path: u },
|
|
3443
|
+
a,
|
|
3066
3444
|
{
|
|
3067
3445
|
loader: r,
|
|
3068
3446
|
root: n,
|
|
@@ -3070,165 +3448,27 @@ async function jn(t) {
|
|
|
3070
3448
|
preserveFrontMatter: t.preserveFrontMatter,
|
|
3071
3449
|
preserveHgComments: t.preserveHgComments
|
|
3072
3450
|
}
|
|
3073
|
-
),
|
|
3451
|
+
), f = p.join(t.outDir, w);
|
|
3074
3452
|
try {
|
|
3075
|
-
await
|
|
3076
|
-
} catch (
|
|
3077
|
-
if (
|
|
3078
|
-
throw
|
|
3079
|
-
const
|
|
3080
|
-
throw d({
|
|
3081
|
-
code: "load_failed",
|
|
3082
|
-
path: p,
|
|
3083
|
-
details: {
|
|
3084
|
-
path: p,
|
|
3085
|
-
reason: g
|
|
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:
|
|
3453
|
+
await Xe(p.dirname(f), { recursive: !0 }), await Je(f, m.markdown, "utf8");
|
|
3454
|
+
} catch (y) {
|
|
3455
|
+
if (qn(y))
|
|
3456
|
+
throw y;
|
|
3457
|
+
const W = y instanceof Error ? y.message : "unknown write error";
|
|
3194
3458
|
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
3459
|
code: "load_failed",
|
|
3220
|
-
path:
|
|
3460
|
+
path: f,
|
|
3221
3461
|
details: {
|
|
3222
|
-
path:
|
|
3223
|
-
reason:
|
|
3462
|
+
path: f,
|
|
3463
|
+
reason: W
|
|
3224
3464
|
}
|
|
3225
3465
|
});
|
|
3226
3466
|
}
|
|
3227
|
-
|
|
3467
|
+
c.push({ path: w, markdown: m.markdown }), h.push(...m.warnings);
|
|
3228
3468
|
}
|
|
3229
|
-
return
|
|
3469
|
+
return { files: c, warnings: h };
|
|
3230
3470
|
}
|
|
3231
|
-
function
|
|
3471
|
+
function ir(t, e) {
|
|
3232
3472
|
const n = [`[hyogen:${t}] ${e.code}`], r = {};
|
|
3233
3473
|
if (e.details)
|
|
3234
3474
|
for (const [i, s] of Object.entries(e.details))
|
|
@@ -3240,15 +3480,15 @@ function Bn(t, e) {
|
|
|
3240
3480
|
`);
|
|
3241
3481
|
}
|
|
3242
3482
|
export {
|
|
3243
|
-
|
|
3244
|
-
|
|
3483
|
+
rr as build,
|
|
3484
|
+
dt as createFsLoader,
|
|
3245
3485
|
d as createHyogenError,
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3486
|
+
oe as createNodeLoader,
|
|
3487
|
+
ir as formatDiagnosticLog,
|
|
3488
|
+
lt as formatMessage,
|
|
3489
|
+
H as isRemotePath,
|
|
3490
|
+
He as loadDataSources,
|
|
3491
|
+
nr as renderClient,
|
|
3492
|
+
Fn as renderServer
|
|
3253
3493
|
};
|
|
3254
3494
|
//# sourceMappingURL=index.js.map
|