@b4moss/hyogen-md 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -3
- package/README_ja.md +24 -3
- package/dist/build/build.d.ts +2 -0
- package/dist/build/buildDependencyGraph.d.ts +22 -0
- package/dist/build/collectDependencies.d.ts +8 -0
- package/dist/build/collectEntryPaths.d.ts +10 -0
- package/dist/build/isUnderscorePartial.d.ts +4 -0
- package/dist/cli.js +5587 -0
- package/dist/client.js +1163 -821
- package/dist/component/ComponentRegistry.d.ts +11 -0
- package/dist/component/parsePropsContract.d.ts +10 -0
- package/dist/component/renderComponent.d.ts +17 -0
- package/dist/component/validateProps.d.ts +7 -0
- package/dist/config/defineConfig.d.ts +5 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +143 -0
- package/dist/config/loadConfig.d.ts +13 -0
- package/dist/config/types.d.ts +26 -0
- package/dist/context/mergeContext.d.ts +3 -0
- package/dist/control/StructureNestTracker.d.ts +14 -0
- package/dist/control/expandControlStructures.d.ts +3 -0
- package/dist/control/parseControlOpener.d.ts +2 -0
- package/dist/control/parseControlStructures.d.ts +2 -0
- package/dist/createError-WZmAl05N.js +30 -0
- package/dist/errors/createError.d.ts +7 -0
- package/dist/errors/formatDiagnosticLog.d.ts +6 -0
- package/dist/errors/formatMessage.d.ts +3 -0
- package/dist/expr/evaluateExpression.d.ts +4 -0
- package/dist/expr/interpolateExpressions.d.ts +4 -0
- package/dist/expr/parseExpression.d.ts +4 -0
- package/dist/frontmatter/parseFrontMatter.d.ts +3 -0
- package/dist/include/VisitStack.d.ts +13 -0
- package/dist/include/expandIncludes.d.ts +18 -0
- package/dist/index.d.ts +11 -113
- package/dist/index.js +1162 -794
- package/dist/io/createFsLoader.d.ts +6 -0
- package/dist/io/createNodeLoader.d.ts +4 -0
- package/dist/io/isRemotePath.d.ts +2 -0
- package/dist/io/loadDataSources.d.ts +8 -0
- package/dist/io/parseCsvFromString.d.ts +1 -0
- package/dist/io/parseDataFile.d.ts +1 -0
- package/dist/io/resolveIncludePath.d.ts +1 -0
- package/dist/layout/expandExtendsAndBlocks.d.ts +19 -0
- package/dist/layout/parseBlockOpener.d.ts +8 -0
- package/dist/layout/parseBlockStructures.d.ts +15 -0
- package/dist/layout/parseExtendBlock.d.ts +12 -0
- package/dist/layout/parseExtendDirective.d.ts +5 -0
- package/dist/logic/executeDeclaration.d.ts +6 -0
- package/dist/logic/executeDeclarations.d.ts +6 -0
- package/dist/logic/executeStatement.d.ts +10 -0
- package/dist/logic/hgBlockUtils.d.ts +3 -0
- package/dist/logic/parseDeclaration.d.ts +5 -0
- package/dist/logic/parseStatement.d.ts +3 -0
- package/dist/logic/reservedWords.d.ts +2 -0
- package/dist/logic/stripComments.d.ts +2 -0
- package/dist/markdown/shiftHeadings.d.ts +25 -0
- package/dist/parse/hgMarkers.d.ts +5 -0
- package/dist/parse/parseComponentDirective.d.ts +6 -0
- package/dist/parse/parseIncludeDirective.d.ts +2 -0
- package/dist/parse/scanHgBlocks.d.ts +10 -0
- package/dist/paths/assertWithinRootDir.d.ts +2 -0
- package/dist/paths/findDocRoot.d.ts +1 -0
- package/dist/paths/resolveRenderInput.d.ts +11 -0
- package/dist/paths/resolveTemplatePath.d.ts +9 -0
- package/dist/pipeline/applyFrontMatterOutputOption.d.ts +4 -0
- package/dist/pipeline/executeHgBlocks.d.ts +9 -0
- package/dist/pipeline/joinRemovalSeam.d.ts +12 -0
- package/dist/pipeline/renderDocument.d.ts +22 -0
- package/dist/pipeline/stripHgComments.d.ts +7 -0
- package/dist/renderClient.d.ts +15 -0
- package/dist/renderServer.d.ts +4 -0
- package/dist/security/forbiddenKeys.d.ts +3 -0
- package/dist/security/scanSuspiciousContext.d.ts +6 -0
- package/dist/shims/fs-browser.d.ts +6 -0
- package/dist/shims/fs-promises-browser.d.ts +5 -0
- package/dist/toc/expandToc.d.ts +8 -0
- package/dist/toc/extractHeadings.d.ts +10 -0
- package/dist/toc/formatTocMarkdown.d.ts +7 -0
- package/dist/toc/githubHeadingSlug.d.ts +11 -0
- package/dist/toc/parseTocDirective.d.ts +10 -0
- package/dist/toc/plainifyHeadingText.d.ts +2 -0
- package/dist/types.d.ts +211 -0
- package/package.json +17 -4
package/dist/client.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { parse as
|
|
2
|
-
const
|
|
3
|
-
errors:
|
|
4
|
-
warnings:
|
|
5
|
-
warningReasons:
|
|
6
|
-
},
|
|
7
|
-
function
|
|
1
|
+
import { parse as Je } from "yaml";
|
|
2
|
+
const Qe = { 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}", 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})" }, et = { 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})' }, tt = { 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" }, Q = {
|
|
3
|
+
errors: Qe,
|
|
4
|
+
warnings: et,
|
|
5
|
+
warningReasons: tt
|
|
6
|
+
}, nt = Q.errors, rt = Q.warnings;
|
|
7
|
+
function Se(t, e) {
|
|
8
8
|
return t === void 0 ? "" : t.replace(/\{([^}]+)\}/g, (n, r) => {
|
|
9
9
|
if (e === void 0 || !(r in e))
|
|
10
10
|
return n;
|
|
11
|
-
const
|
|
12
|
-
return
|
|
11
|
+
const i = e[r];
|
|
12
|
+
return i == null ? "" : String(i);
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function it(t, e) {
|
|
16
|
+
return Se(nt[t], e);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
18
|
+
function H(t, e) {
|
|
19
|
+
return Se(rt[t], e);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const e = t.message ??
|
|
21
|
+
function d(t) {
|
|
22
|
+
const e = t.message ?? it(t.code, t.details), n = new Error(e);
|
|
23
23
|
return n.name = "HyogenError", n.code = t.code, n.message = e, n.path = t.path, n.details = t.details, n;
|
|
24
24
|
}
|
|
25
25
|
function _(...t) {
|
|
@@ -28,17 +28,17 @@ function _(...t) {
|
|
|
28
28
|
n != null && Object.assign(e, n);
|
|
29
29
|
return e;
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class Ce {
|
|
32
32
|
components = /* @__PURE__ */ new Map();
|
|
33
33
|
register(e, n, r) {
|
|
34
34
|
if (this.components.has(e.alias))
|
|
35
|
-
throw
|
|
35
|
+
throw d({
|
|
36
36
|
code: "duplicate_component_alias",
|
|
37
37
|
path: r ?? e.definedAt,
|
|
38
38
|
details: { alias: e.alias }
|
|
39
39
|
});
|
|
40
40
|
if (n.includes(e.alias))
|
|
41
|
-
throw
|
|
41
|
+
throw d({
|
|
42
42
|
code: "alias_collision",
|
|
43
43
|
path: r ?? e.definedAt,
|
|
44
44
|
details: { alias: e.alias }
|
|
@@ -52,8 +52,8 @@ class be {
|
|
|
52
52
|
return this.components.has(e);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
function
|
|
55
|
+
const de = 64 * 1024;
|
|
56
|
+
function I(t, e) {
|
|
57
57
|
if (!t.startsWith("---"))
|
|
58
58
|
return { context: {}, body: t };
|
|
59
59
|
const n = t.indexOf(`
|
|
@@ -64,25 +64,25 @@ function H(t, e) {
|
|
|
64
64
|
---`, n);
|
|
65
65
|
if (r === -1)
|
|
66
66
|
return { context: {}, body: t };
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
throw
|
|
67
|
+
const i = t.slice(n + 1, r), s = Buffer.byteLength(i, "utf8");
|
|
68
|
+
if (s > de)
|
|
69
|
+
throw d({
|
|
70
70
|
code: "frontmatter_too_large",
|
|
71
71
|
path: e,
|
|
72
72
|
details: {
|
|
73
|
-
size:
|
|
74
|
-
limit:
|
|
73
|
+
size: s,
|
|
74
|
+
limit: de
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
|
-
if (
|
|
78
|
-
throw
|
|
77
|
+
if (i.trim().length === 0)
|
|
78
|
+
throw d({
|
|
79
79
|
code: "parse_error",
|
|
80
80
|
path: e,
|
|
81
81
|
details: { message: "empty front matter" }
|
|
82
82
|
});
|
|
83
83
|
let o;
|
|
84
84
|
try {
|
|
85
|
-
const h =
|
|
85
|
+
const h = Je(i);
|
|
86
86
|
if (h == null)
|
|
87
87
|
o = {};
|
|
88
88
|
else if (typeof h == "object" && !Array.isArray(h))
|
|
@@ -90,7 +90,7 @@ function H(t, e) {
|
|
|
90
90
|
else
|
|
91
91
|
throw new Error("front matter must be a YAML mapping");
|
|
92
92
|
} catch (h) {
|
|
93
|
-
throw
|
|
93
|
+
throw d({
|
|
94
94
|
code: "parse_error",
|
|
95
95
|
path: e,
|
|
96
96
|
details: {
|
|
@@ -106,43 +106,43 @@ function H(t, e) {
|
|
|
106
106
|
context: o,
|
|
107
107
|
body: c,
|
|
108
108
|
rawFrontMatter: `---
|
|
109
|
-
${
|
|
109
|
+
${i}
|
|
110
110
|
---`
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
const
|
|
113
|
+
const st = /* @__PURE__ */ new Set([
|
|
114
114
|
"string",
|
|
115
115
|
"number",
|
|
116
116
|
"boolean",
|
|
117
117
|
"object",
|
|
118
118
|
"array"
|
|
119
119
|
]);
|
|
120
|
-
function
|
|
120
|
+
function ot(t, e) {
|
|
121
121
|
const n = t.props;
|
|
122
122
|
if (n === void 0)
|
|
123
123
|
return {};
|
|
124
124
|
if (typeof n != "object" || n === null || Array.isArray(n))
|
|
125
|
-
throw
|
|
125
|
+
throw d({
|
|
126
126
|
code: "parse_error",
|
|
127
127
|
path: e,
|
|
128
128
|
details: { message: "props must be a YAML mapping" }
|
|
129
129
|
});
|
|
130
130
|
const r = {};
|
|
131
|
-
for (const [
|
|
132
|
-
if (typeof
|
|
133
|
-
r[
|
|
131
|
+
for (const [i, s] of Object.entries(n)) {
|
|
132
|
+
if (typeof s != "object" || s === null || Array.isArray(s)) {
|
|
133
|
+
r[i] = {};
|
|
134
134
|
continue;
|
|
135
135
|
}
|
|
136
|
-
const o =
|
|
136
|
+
const o = s, a = {};
|
|
137
137
|
if ("type" in o && o.type !== void 0) {
|
|
138
138
|
const c = String(o.type);
|
|
139
|
-
|
|
139
|
+
st.has(c) ? a.type = c : a.type = void 0;
|
|
140
140
|
}
|
|
141
|
-
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[
|
|
141
|
+
"isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[i] = a;
|
|
142
142
|
}
|
|
143
143
|
return r;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function at(t) {
|
|
146
146
|
if (t != null) {
|
|
147
147
|
if (typeof t == "string") return "string";
|
|
148
148
|
if (typeof t == "number") return "number";
|
|
@@ -151,30 +151,30 @@ function Ve(t) {
|
|
|
151
151
|
if (typeof t == "object") return "object";
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function ct(t, e) {
|
|
155
155
|
return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Z(t, e) {
|
|
158
158
|
return {
|
|
159
159
|
code: t,
|
|
160
|
-
message:
|
|
160
|
+
message: H(t, e),
|
|
161
161
|
details: e
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
const r = [],
|
|
164
|
+
function lt(t, e, n) {
|
|
165
|
+
const r = [], i = {}, s = new Set(Object.keys(e));
|
|
166
166
|
for (const [o, a] of Object.entries(e)) {
|
|
167
167
|
const c = Object.prototype.hasOwnProperty.call(t, o);
|
|
168
168
|
let h = c ? t[o] : void 0;
|
|
169
169
|
if (c || (a.default !== void 0 ? h = a.default : (a.isRequired && r.push(
|
|
170
|
-
|
|
170
|
+
Z("prop_missing", {
|
|
171
171
|
prop: o,
|
|
172
172
|
component: n
|
|
173
173
|
})
|
|
174
174
|
), h = void 0)), c && h !== void 0 && h !== null) {
|
|
175
|
-
const l = a.type ??
|
|
176
|
-
l && !
|
|
177
|
-
|
|
175
|
+
const l = a.type ?? at(h);
|
|
176
|
+
l && !ct(h, l) && (r.push(
|
|
177
|
+
Z("prop_type_mismatch", {
|
|
178
178
|
prop: o,
|
|
179
179
|
component: n,
|
|
180
180
|
expected: l,
|
|
@@ -182,194 +182,194 @@ function Ye(t, e, n) {
|
|
|
182
182
|
})
|
|
183
183
|
), h = void 0);
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
i[o] = h;
|
|
186
186
|
}
|
|
187
187
|
for (const o of Object.keys(t))
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
s.has(o) || (Object.keys(e).length > 0 ? r.push(
|
|
189
|
+
Z("prop_unknown", {
|
|
190
190
|
prop: o,
|
|
191
191
|
component: n
|
|
192
192
|
})
|
|
193
|
-
) :
|
|
194
|
-
return { values:
|
|
193
|
+
) : i[o] = t[o]);
|
|
194
|
+
return { values: i, warnings: r };
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function We(t) {
|
|
197
197
|
return /^https?:\/\//i.test(t);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function ht(t) {
|
|
200
200
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
201
201
|
}
|
|
202
|
-
var
|
|
203
|
-
function
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
function t(
|
|
207
|
-
if (typeof
|
|
208
|
-
throw new TypeError("Path must be a string. Received " + JSON.stringify(
|
|
209
|
-
}
|
|
210
|
-
function e(
|
|
211
|
-
for (var o = "", a = 0, c = -1, h = 0, l,
|
|
212
|
-
if (
|
|
213
|
-
l =
|
|
202
|
+
var q, fe;
|
|
203
|
+
function ut() {
|
|
204
|
+
if (fe) return q;
|
|
205
|
+
fe = 1;
|
|
206
|
+
function t(i) {
|
|
207
|
+
if (typeof i != "string")
|
|
208
|
+
throw new TypeError("Path must be a string. Received " + JSON.stringify(i));
|
|
209
|
+
}
|
|
210
|
+
function e(i, s) {
|
|
211
|
+
for (var o = "", a = 0, c = -1, h = 0, l, u = 0; u <= i.length; ++u) {
|
|
212
|
+
if (u < i.length)
|
|
213
|
+
l = i.charCodeAt(u);
|
|
214
214
|
else {
|
|
215
215
|
if (l === 47)
|
|
216
216
|
break;
|
|
217
217
|
l = 47;
|
|
218
218
|
}
|
|
219
219
|
if (l === 47) {
|
|
220
|
-
if (!(c ===
|
|
220
|
+
if (!(c === u - 1 || h === 1)) if (c !== u - 1 && h === 2) {
|
|
221
221
|
if (o.length < 2 || a !== 2 || o.charCodeAt(o.length - 1) !== 46 || o.charCodeAt(o.length - 2) !== 46) {
|
|
222
222
|
if (o.length > 2) {
|
|
223
223
|
var f = o.lastIndexOf("/");
|
|
224
224
|
if (f !== o.length - 1) {
|
|
225
|
-
f === -1 ? (o = "", a = 0) : (o = o.slice(0, f), a = o.length - 1 - o.lastIndexOf("/")), c =
|
|
225
|
+
f === -1 ? (o = "", a = 0) : (o = o.slice(0, f), a = o.length - 1 - o.lastIndexOf("/")), c = u, h = 0;
|
|
226
226
|
continue;
|
|
227
227
|
}
|
|
228
228
|
} else if (o.length === 2 || o.length === 1) {
|
|
229
|
-
o = "", a = 0, c =
|
|
229
|
+
o = "", a = 0, c = u, h = 0;
|
|
230
230
|
continue;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
|
|
233
|
+
s && (o.length > 0 ? o += "/.." : o = "..", a = 2);
|
|
234
234
|
} else
|
|
235
|
-
o.length > 0 ? o += "/" +
|
|
236
|
-
c =
|
|
235
|
+
o.length > 0 ? o += "/" + i.slice(c + 1, u) : o = i.slice(c + 1, u), a = u - c - 1;
|
|
236
|
+
c = u, h = 0;
|
|
237
237
|
} else l === 46 && h !== -1 ? ++h : h = -1;
|
|
238
238
|
}
|
|
239
239
|
return o;
|
|
240
240
|
}
|
|
241
|
-
function n(
|
|
242
|
-
var o =
|
|
243
|
-
return o ? o ===
|
|
241
|
+
function n(i, s) {
|
|
242
|
+
var o = s.dir || s.root, a = s.base || (s.name || "") + (s.ext || "");
|
|
243
|
+
return o ? o === s.root ? o + a : o + i + a : a;
|
|
244
244
|
}
|
|
245
245
|
var r = {
|
|
246
246
|
// path.resolve([from ...], to)
|
|
247
247
|
resolve: function() {
|
|
248
|
-
for (var
|
|
248
|
+
for (var s = "", o = !1, a, c = arguments.length - 1; c >= -1 && !o; c--) {
|
|
249
249
|
var h;
|
|
250
|
-
c >= 0 ? h = arguments[c] : (a === void 0 && (a = process.cwd()), h = a), t(h), h.length !== 0 && (
|
|
250
|
+
c >= 0 ? h = arguments[c] : (a === void 0 && (a = process.cwd()), h = a), t(h), h.length !== 0 && (s = h + "/" + s, o = h.charCodeAt(0) === 47);
|
|
251
251
|
}
|
|
252
|
-
return
|
|
252
|
+
return s = e(s, !o), o ? s.length > 0 ? "/" + s : "/" : s.length > 0 ? s : ".";
|
|
253
253
|
},
|
|
254
|
-
normalize: function(
|
|
255
|
-
if (t(
|
|
256
|
-
var o =
|
|
257
|
-
return
|
|
254
|
+
normalize: function(s) {
|
|
255
|
+
if (t(s), s.length === 0) return ".";
|
|
256
|
+
var o = s.charCodeAt(0) === 47, a = s.charCodeAt(s.length - 1) === 47;
|
|
257
|
+
return s = e(s, !o), s.length === 0 && !o && (s = "."), s.length > 0 && a && (s += "/"), o ? "/" + s : s;
|
|
258
258
|
},
|
|
259
|
-
isAbsolute: function(
|
|
260
|
-
return t(
|
|
259
|
+
isAbsolute: function(s) {
|
|
260
|
+
return t(s), s.length > 0 && s.charCodeAt(0) === 47;
|
|
261
261
|
},
|
|
262
262
|
join: function() {
|
|
263
263
|
if (arguments.length === 0)
|
|
264
264
|
return ".";
|
|
265
|
-
for (var
|
|
265
|
+
for (var s, o = 0; o < arguments.length; ++o) {
|
|
266
266
|
var a = arguments[o];
|
|
267
|
-
t(a), a.length > 0 && (
|
|
267
|
+
t(a), a.length > 0 && (s === void 0 ? s = a : s += "/" + a);
|
|
268
268
|
}
|
|
269
|
-
return
|
|
269
|
+
return s === void 0 ? "." : r.normalize(s);
|
|
270
270
|
},
|
|
271
|
-
relative: function(
|
|
272
|
-
if (t(
|
|
273
|
-
for (var a = 1; a <
|
|
271
|
+
relative: function(s, o) {
|
|
272
|
+
if (t(s), t(o), s === o || (s = r.resolve(s), o = r.resolve(o), s === o)) return "";
|
|
273
|
+
for (var a = 1; a < s.length && s.charCodeAt(a) === 47; ++a)
|
|
274
274
|
;
|
|
275
|
-
for (var c =
|
|
275
|
+
for (var c = s.length, h = c - a, l = 1; l < o.length && o.charCodeAt(l) === 47; ++l)
|
|
276
276
|
;
|
|
277
|
-
for (var
|
|
277
|
+
for (var u = o.length, f = u - l, g = h < f ? h : f, m = -1, p = 0; p <= g; ++p) {
|
|
278
278
|
if (p === g) {
|
|
279
279
|
if (f > g) {
|
|
280
280
|
if (o.charCodeAt(l + p) === 47)
|
|
281
281
|
return o.slice(l + p + 1);
|
|
282
282
|
if (p === 0)
|
|
283
283
|
return o.slice(l + p);
|
|
284
|
-
} else h > g && (
|
|
284
|
+
} else h > g && (s.charCodeAt(a + p) === 47 ? m = p : p === 0 && (m = 0));
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
|
-
var
|
|
288
|
-
if (
|
|
287
|
+
var S = s.charCodeAt(a + p), D = o.charCodeAt(l + p);
|
|
288
|
+
if (S !== D)
|
|
289
289
|
break;
|
|
290
|
-
|
|
290
|
+
S === 47 && (m = p);
|
|
291
291
|
}
|
|
292
|
-
var
|
|
292
|
+
var v = "";
|
|
293
293
|
for (p = a + m + 1; p <= c; ++p)
|
|
294
|
-
(p === c ||
|
|
295
|
-
return
|
|
294
|
+
(p === c || s.charCodeAt(p) === 47) && (v.length === 0 ? v += ".." : v += "/..");
|
|
295
|
+
return v.length > 0 ? v + o.slice(l + m) : (l += m, o.charCodeAt(l) === 47 && ++l, o.slice(l));
|
|
296
296
|
},
|
|
297
|
-
_makeLong: function(
|
|
298
|
-
return
|
|
297
|
+
_makeLong: function(s) {
|
|
298
|
+
return s;
|
|
299
299
|
},
|
|
300
|
-
dirname: function(
|
|
301
|
-
if (t(
|
|
302
|
-
for (var o =
|
|
303
|
-
if (o =
|
|
300
|
+
dirname: function(s) {
|
|
301
|
+
if (t(s), s.length === 0) return ".";
|
|
302
|
+
for (var o = s.charCodeAt(0), a = o === 47, c = -1, h = !0, l = s.length - 1; l >= 1; --l)
|
|
303
|
+
if (o = s.charCodeAt(l), o === 47) {
|
|
304
304
|
if (!h) {
|
|
305
305
|
c = l;
|
|
306
306
|
break;
|
|
307
307
|
}
|
|
308
308
|
} else
|
|
309
309
|
h = !1;
|
|
310
|
-
return c === -1 ? a ? "/" : "." : a && c === 1 ? "//" :
|
|
310
|
+
return c === -1 ? a ? "/" : "." : a && c === 1 ? "//" : s.slice(0, c);
|
|
311
311
|
},
|
|
312
|
-
basename: function(
|
|
312
|
+
basename: function(s, o) {
|
|
313
313
|
if (o !== void 0 && typeof o != "string") throw new TypeError('"ext" argument must be a string');
|
|
314
|
-
t(
|
|
314
|
+
t(s);
|
|
315
315
|
var a = 0, c = -1, h = !0, l;
|
|
316
|
-
if (o !== void 0 && o.length > 0 && o.length <=
|
|
317
|
-
if (o.length ===
|
|
318
|
-
var
|
|
319
|
-
for (l =
|
|
320
|
-
var g =
|
|
316
|
+
if (o !== void 0 && o.length > 0 && o.length <= s.length) {
|
|
317
|
+
if (o.length === s.length && o === s) return "";
|
|
318
|
+
var u = o.length - 1, f = -1;
|
|
319
|
+
for (l = s.length - 1; l >= 0; --l) {
|
|
320
|
+
var g = s.charCodeAt(l);
|
|
321
321
|
if (g === 47) {
|
|
322
322
|
if (!h) {
|
|
323
323
|
a = l + 1;
|
|
324
324
|
break;
|
|
325
325
|
}
|
|
326
326
|
} else
|
|
327
|
-
f === -1 && (h = !1, f = l + 1),
|
|
327
|
+
f === -1 && (h = !1, f = l + 1), u >= 0 && (g === o.charCodeAt(u) ? --u === -1 && (c = l) : (u = -1, c = f));
|
|
328
328
|
}
|
|
329
|
-
return a === c ? c = f : c === -1 && (c =
|
|
329
|
+
return a === c ? c = f : c === -1 && (c = s.length), s.slice(a, c);
|
|
330
330
|
} else {
|
|
331
|
-
for (l =
|
|
332
|
-
if (
|
|
331
|
+
for (l = s.length - 1; l >= 0; --l)
|
|
332
|
+
if (s.charCodeAt(l) === 47) {
|
|
333
333
|
if (!h) {
|
|
334
334
|
a = l + 1;
|
|
335
335
|
break;
|
|
336
336
|
}
|
|
337
337
|
} else c === -1 && (h = !1, c = l + 1);
|
|
338
|
-
return c === -1 ? "" :
|
|
338
|
+
return c === -1 ? "" : s.slice(a, c);
|
|
339
339
|
}
|
|
340
340
|
},
|
|
341
|
-
extname: function(
|
|
342
|
-
t(
|
|
343
|
-
for (var o = -1, a = 0, c = -1, h = !0, l = 0,
|
|
344
|
-
var f =
|
|
341
|
+
extname: function(s) {
|
|
342
|
+
t(s);
|
|
343
|
+
for (var o = -1, a = 0, c = -1, h = !0, l = 0, u = s.length - 1; u >= 0; --u) {
|
|
344
|
+
var f = s.charCodeAt(u);
|
|
345
345
|
if (f === 47) {
|
|
346
346
|
if (!h) {
|
|
347
|
-
a =
|
|
347
|
+
a = u + 1;
|
|
348
348
|
break;
|
|
349
349
|
}
|
|
350
350
|
continue;
|
|
351
351
|
}
|
|
352
|
-
c === -1 && (h = !1, c =
|
|
352
|
+
c === -1 && (h = !1, c = u + 1), f === 46 ? o === -1 ? o = u : l !== 1 && (l = 1) : o !== -1 && (l = -1);
|
|
353
353
|
}
|
|
354
354
|
return o === -1 || c === -1 || // We saw a non-dot character immediately before the dot
|
|
355
355
|
l === 0 || // The (right-most) trimmed path component is exactly '..'
|
|
356
|
-
l === 1 && o === c - 1 && o === a + 1 ? "" :
|
|
356
|
+
l === 1 && o === c - 1 && o === a + 1 ? "" : s.slice(o, c);
|
|
357
357
|
},
|
|
358
|
-
format: function(
|
|
359
|
-
if (
|
|
360
|
-
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof
|
|
361
|
-
return n("/",
|
|
358
|
+
format: function(s) {
|
|
359
|
+
if (s === null || typeof s != "object")
|
|
360
|
+
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof s);
|
|
361
|
+
return n("/", s);
|
|
362
362
|
},
|
|
363
|
-
parse: function(
|
|
364
|
-
t(
|
|
363
|
+
parse: function(s) {
|
|
364
|
+
t(s);
|
|
365
365
|
var o = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
366
|
-
if (
|
|
367
|
-
var a =
|
|
366
|
+
if (s.length === 0) return o;
|
|
367
|
+
var a = s.charCodeAt(0), c = a === 47, h;
|
|
368
368
|
c ? (o.root = "/", h = 1) : h = 0;
|
|
369
|
-
for (var l = -1,
|
|
370
|
-
if (a =
|
|
369
|
+
for (var l = -1, u = 0, f = -1, g = !0, m = s.length - 1, p = 0; m >= h; --m) {
|
|
370
|
+
if (a = s.charCodeAt(m), a === 47) {
|
|
371
371
|
if (!g) {
|
|
372
|
-
|
|
372
|
+
u = m + 1;
|
|
373
373
|
break;
|
|
374
374
|
}
|
|
375
375
|
continue;
|
|
@@ -378,36 +378,36 @@ function Je() {
|
|
|
378
378
|
}
|
|
379
379
|
return l === -1 || f === -1 || // We saw a non-dot character immediately before the dot
|
|
380
380
|
p === 0 || // The (right-most) trimmed path component is exactly '..'
|
|
381
|
-
p === 1 && l === f - 1 && l ===
|
|
381
|
+
p === 1 && l === f - 1 && l === u + 1 ? f !== -1 && (u === 0 && c ? o.base = o.name = s.slice(1, f) : o.base = o.name = s.slice(u, f)) : (u === 0 && c ? (o.name = s.slice(1, l), o.base = s.slice(1, f)) : (o.name = s.slice(u, l), o.base = s.slice(u, f)), o.ext = s.slice(l, f)), u > 0 ? o.dir = s.slice(0, u - 1) : c && (o.dir = "/"), o;
|
|
382
382
|
},
|
|
383
383
|
sep: "/",
|
|
384
384
|
delimiter: ":",
|
|
385
385
|
win32: null,
|
|
386
386
|
posix: null
|
|
387
387
|
};
|
|
388
|
-
return r.posix = r,
|
|
388
|
+
return r.posix = r, q = r, q;
|
|
389
389
|
}
|
|
390
|
-
var
|
|
391
|
-
const y = /* @__PURE__ */
|
|
392
|
-
function
|
|
390
|
+
var dt = ut();
|
|
391
|
+
const y = /* @__PURE__ */ ht(dt);
|
|
392
|
+
function ft(t, e) {
|
|
393
393
|
const n = y.relative(e, t);
|
|
394
394
|
return n === "" || !n.startsWith("..") && !y.isAbsolute(n);
|
|
395
395
|
}
|
|
396
|
-
function
|
|
397
|
-
const r = y.resolve(e),
|
|
398
|
-
if (!
|
|
399
|
-
throw
|
|
396
|
+
function pt(t, e, n) {
|
|
397
|
+
const r = y.resolve(e), i = y.resolve(t);
|
|
398
|
+
if (!ft(i, r))
|
|
399
|
+
throw d({
|
|
400
400
|
code: "parse_error",
|
|
401
401
|
path: n,
|
|
402
402
|
details: { message: "path resolves outside root directory" }
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
|
-
function
|
|
406
|
-
const { rootDir: n, fromPath: r, documentPath:
|
|
405
|
+
function $e(t, e = {}) {
|
|
406
|
+
const { rootDir: n, fromPath: r, documentPath: i, constrainToRoot: s = !1, hyogenPath: o = !1 } = e;
|
|
407
407
|
if (t.length === 0)
|
|
408
|
-
throw
|
|
408
|
+
throw d({
|
|
409
409
|
code: "parse_error",
|
|
410
|
-
path:
|
|
410
|
+
path: i,
|
|
411
411
|
details: { message: "empty template path" }
|
|
412
412
|
});
|
|
413
413
|
let a;
|
|
@@ -416,17 +416,17 @@ function ve(t, e = {}) {
|
|
|
416
416
|
a = y.resolve(n, t.slice(1));
|
|
417
417
|
else {
|
|
418
418
|
if (o)
|
|
419
|
-
throw
|
|
419
|
+
throw d({
|
|
420
420
|
code: "parse_error",
|
|
421
|
-
path:
|
|
421
|
+
path: i,
|
|
422
422
|
details: { message: "root-relative paths require a doc root" }
|
|
423
423
|
});
|
|
424
424
|
if (y.isAbsolute(t))
|
|
425
425
|
a = y.resolve(t);
|
|
426
426
|
else
|
|
427
|
-
throw
|
|
427
|
+
throw d({
|
|
428
428
|
code: "parse_error",
|
|
429
|
-
path:
|
|
429
|
+
path: i,
|
|
430
430
|
details: { message: "root-relative paths require a doc root" }
|
|
431
431
|
});
|
|
432
432
|
}
|
|
@@ -436,9 +436,9 @@ function ve(t, e = {}) {
|
|
|
436
436
|
else if (n)
|
|
437
437
|
a = y.resolve(n, t);
|
|
438
438
|
else
|
|
439
|
-
throw
|
|
439
|
+
throw d({
|
|
440
440
|
code: "parse_error",
|
|
441
|
-
path:
|
|
441
|
+
path: i,
|
|
442
442
|
details: { message: "root is required for relative template paths" }
|
|
443
443
|
});
|
|
444
444
|
else if (y.isAbsolute(t))
|
|
@@ -446,41 +446,42 @@ function ve(t, e = {}) {
|
|
|
446
446
|
else if (n)
|
|
447
447
|
a = y.resolve(n, t);
|
|
448
448
|
else
|
|
449
|
-
throw
|
|
449
|
+
throw d({
|
|
450
450
|
code: "parse_error",
|
|
451
|
-
path:
|
|
451
|
+
path: i,
|
|
452
452
|
details: { message: "root is required for relative template paths" }
|
|
453
453
|
});
|
|
454
|
-
return n &&
|
|
454
|
+
return n && s && pt(a, n, i), a;
|
|
455
455
|
}
|
|
456
|
-
async function
|
|
456
|
+
async function mt(t) {
|
|
457
457
|
const e = t.registry.get(t.alias);
|
|
458
458
|
if (!e)
|
|
459
|
-
throw
|
|
459
|
+
throw d({
|
|
460
460
|
code: "parse_error",
|
|
461
461
|
path: t.path,
|
|
462
462
|
details: {
|
|
463
463
|
message: `unregistered component: ${t.alias}`
|
|
464
464
|
}
|
|
465
465
|
});
|
|
466
|
-
const n =
|
|
466
|
+
const n = We(e.componentPath) ? e.componentPath : $e(e.componentPath, {
|
|
467
467
|
rootDir: t.rootDir,
|
|
468
468
|
fromPath: e.definedAt,
|
|
469
469
|
documentPath: t.path,
|
|
470
470
|
constrainToRoot: t.constrainToRoot,
|
|
471
471
|
hyogenPath: !0
|
|
472
|
-
}), r = await t.loader(n), { context:
|
|
472
|
+
}), r = await t.loader(n), { context: i, body: s } = I(r, n), o = ot(i, n), { values: a, warnings: c } = lt(
|
|
473
473
|
t.props,
|
|
474
474
|
o,
|
|
475
475
|
t.alias
|
|
476
476
|
);
|
|
477
477
|
t.warnings.push(...c);
|
|
478
|
-
const { props: h, ...l } =
|
|
478
|
+
const { props: h, ...l } = i, u = _(
|
|
479
479
|
t.parentContext,
|
|
480
480
|
l,
|
|
481
481
|
a
|
|
482
|
-
)
|
|
483
|
-
|
|
482
|
+
);
|
|
483
|
+
return (await he(s, {
|
|
484
|
+
context: u,
|
|
484
485
|
loader: t.loader,
|
|
485
486
|
root: t.rootDir,
|
|
486
487
|
path: n,
|
|
@@ -492,40 +493,36 @@ async function tt(t) {
|
|
|
492
493
|
preserveHgComments: t.preserveHgComments,
|
|
493
494
|
constrainToRoot: t.constrainToRoot
|
|
494
495
|
})).trim();
|
|
495
|
-
if (g.includes(`
|
|
496
|
-
`))
|
|
497
|
-
throw u({
|
|
498
|
-
code: "component_multiline_output",
|
|
499
|
-
path: n,
|
|
500
|
-
details: { alias: t.alias }
|
|
501
|
-
});
|
|
502
|
-
return g;
|
|
503
496
|
}
|
|
504
|
-
const
|
|
497
|
+
const gt = /* @__PURE__ */ new Set([
|
|
505
498
|
"__proto__",
|
|
506
499
|
"prototype",
|
|
507
500
|
"constructor",
|
|
508
501
|
"__defineGetter__"
|
|
509
502
|
]);
|
|
510
|
-
function
|
|
511
|
-
return
|
|
503
|
+
function xt(t) {
|
|
504
|
+
return gt.has(t);
|
|
512
505
|
}
|
|
513
|
-
function
|
|
514
|
-
if (
|
|
515
|
-
throw
|
|
506
|
+
function pe(t, e) {
|
|
507
|
+
if (xt(t))
|
|
508
|
+
throw d({
|
|
516
509
|
code: "forbidden_property_access",
|
|
517
510
|
path: e,
|
|
518
511
|
details: { property: t }
|
|
519
512
|
});
|
|
520
513
|
}
|
|
521
|
-
function
|
|
514
|
+
function O(t) {
|
|
522
515
|
return !t;
|
|
523
516
|
}
|
|
524
|
-
function
|
|
525
|
-
if (t != null
|
|
526
|
-
|
|
517
|
+
function kt(t, e) {
|
|
518
|
+
if (t != null) {
|
|
519
|
+
if (typeof t == "string")
|
|
520
|
+
return e === "length" ? t.length : void 0;
|
|
521
|
+
if (typeof t == "object")
|
|
522
|
+
return t[e];
|
|
523
|
+
}
|
|
527
524
|
}
|
|
528
|
-
function
|
|
525
|
+
function wt(t, e, n) {
|
|
529
526
|
switch (t) {
|
|
530
527
|
case "+":
|
|
531
528
|
return e + n;
|
|
@@ -552,9 +549,9 @@ function st(t, e, n) {
|
|
|
552
549
|
case "<":
|
|
553
550
|
return e < n;
|
|
554
551
|
case "&&":
|
|
555
|
-
return
|
|
552
|
+
return O(e) ? e : n;
|
|
556
553
|
case "||":
|
|
557
|
-
return
|
|
554
|
+
return O(e) ? n : e;
|
|
558
555
|
default:
|
|
559
556
|
return;
|
|
560
557
|
}
|
|
@@ -565,35 +562,35 @@ async function w(t, e) {
|
|
|
565
562
|
case "literal":
|
|
566
563
|
return t.value;
|
|
567
564
|
case "identifier":
|
|
568
|
-
return
|
|
565
|
+
return pe(t.name, r), n[t.name];
|
|
569
566
|
case "member": {
|
|
570
|
-
|
|
571
|
-
const
|
|
572
|
-
return
|
|
567
|
+
pe(t.property, r);
|
|
568
|
+
const i = await w(t.object, e);
|
|
569
|
+
return kt(i, t.property);
|
|
573
570
|
}
|
|
574
571
|
case "default": {
|
|
575
|
-
const
|
|
576
|
-
return
|
|
572
|
+
const i = await w(t.left, e);
|
|
573
|
+
return O(i) ? w(t.right, e) : i;
|
|
577
574
|
}
|
|
578
575
|
case "unary": {
|
|
579
|
-
const
|
|
580
|
-
return t.op === "!" ? !
|
|
576
|
+
const i = await w(t.operand, e);
|
|
577
|
+
return t.op === "!" ? !i : void 0;
|
|
581
578
|
}
|
|
582
579
|
case "binary": {
|
|
583
580
|
if (t.op === "&&") {
|
|
584
581
|
const o = await w(t.left, e);
|
|
585
|
-
return
|
|
582
|
+
return O(o) ? o : w(t.right, e);
|
|
586
583
|
}
|
|
587
584
|
if (t.op === "||") {
|
|
588
585
|
const o = await w(t.left, e);
|
|
589
|
-
return
|
|
586
|
+
return O(o) ? w(t.right, e) : o;
|
|
590
587
|
}
|
|
591
|
-
const
|
|
592
|
-
return
|
|
588
|
+
const i = await w(t.left, e), s = await w(t.right, e);
|
|
589
|
+
return wt(t.op, i, s);
|
|
593
590
|
}
|
|
594
591
|
case "call": {
|
|
595
592
|
if (!e.registry || !e.loader || !e.visitStack)
|
|
596
|
-
throw
|
|
593
|
+
throw d({
|
|
597
594
|
code: "parse_error",
|
|
598
595
|
path: r,
|
|
599
596
|
details: {
|
|
@@ -601,19 +598,19 @@ async function w(t, e) {
|
|
|
601
598
|
}
|
|
602
599
|
});
|
|
603
600
|
if (!e.registry.has(t.callee))
|
|
604
|
-
throw
|
|
601
|
+
throw d({
|
|
605
602
|
code: "parse_error",
|
|
606
603
|
path: r,
|
|
607
604
|
details: {
|
|
608
605
|
message: `unregistered component: ${t.callee}`
|
|
609
606
|
}
|
|
610
607
|
});
|
|
611
|
-
const
|
|
612
|
-
for (const [
|
|
613
|
-
s
|
|
614
|
-
return
|
|
608
|
+
const i = {};
|
|
609
|
+
for (const [s, o] of Object.entries(t.args))
|
|
610
|
+
i[s] = await w(o, e);
|
|
611
|
+
return mt({
|
|
615
612
|
alias: t.callee,
|
|
616
|
-
props:
|
|
613
|
+
props: i,
|
|
617
614
|
parentContext: e.parentContext ?? n,
|
|
618
615
|
registry: e.registry,
|
|
619
616
|
loader: e.loader,
|
|
@@ -627,58 +624,58 @@ async function w(t, e) {
|
|
|
627
624
|
}
|
|
628
625
|
case "method": {
|
|
629
626
|
if (t.method !== "toLocaleString")
|
|
630
|
-
throw
|
|
627
|
+
throw d({
|
|
631
628
|
code: "parse_error",
|
|
632
629
|
path: r,
|
|
633
630
|
details: { message: `unsupported method: ${t.method}()` }
|
|
634
631
|
});
|
|
635
|
-
const
|
|
636
|
-
return
|
|
632
|
+
const i = await w(t.object, e);
|
|
633
|
+
return i == null || typeof i.toLocaleString != "function" ? void 0 : i.toLocaleString(
|
|
637
634
|
...t.args
|
|
638
635
|
);
|
|
639
636
|
}
|
|
640
637
|
case "ternary": {
|
|
641
|
-
const
|
|
642
|
-
return
|
|
638
|
+
const i = await w(t.condition, e);
|
|
639
|
+
return O(i) ? w(t.alternate, e) : w(t.consequent, e);
|
|
643
640
|
}
|
|
644
641
|
case "template": {
|
|
645
|
-
let
|
|
646
|
-
for (const
|
|
647
|
-
if (typeof
|
|
648
|
-
|
|
642
|
+
let i = "";
|
|
643
|
+
for (const s of t.parts)
|
|
644
|
+
if (typeof s == "string")
|
|
645
|
+
i += s;
|
|
649
646
|
else {
|
|
650
|
-
const o = await w(
|
|
651
|
-
o != null && (
|
|
647
|
+
const o = await w(s, e);
|
|
648
|
+
o != null && (i += String(o));
|
|
652
649
|
}
|
|
653
|
-
return
|
|
650
|
+
return i;
|
|
654
651
|
}
|
|
655
652
|
default:
|
|
656
653
|
return;
|
|
657
654
|
}
|
|
658
655
|
}
|
|
659
|
-
function
|
|
656
|
+
function V(t) {
|
|
660
657
|
return /[A-Za-z_$]/.test(t);
|
|
661
658
|
}
|
|
662
|
-
function
|
|
659
|
+
function vt(t) {
|
|
663
660
|
return /[A-Za-z0-9_$]/.test(t);
|
|
664
661
|
}
|
|
665
|
-
function
|
|
662
|
+
function W(t, e, n = {}) {
|
|
666
663
|
const r = t.trim();
|
|
667
664
|
if (r.length === 0)
|
|
668
665
|
throw x(e, "empty expression");
|
|
669
|
-
const
|
|
670
|
-
if (
|
|
671
|
-
throw x(e, `unexpected token at position ${
|
|
672
|
-
return
|
|
666
|
+
const i = new bt(r, e, n), s = i.parseExpression();
|
|
667
|
+
if (i.skipWhitespace(), i.hasMore())
|
|
668
|
+
throw x(e, `unexpected token at position ${i.position}`);
|
|
669
|
+
return s;
|
|
673
670
|
}
|
|
674
671
|
function x(t, e) {
|
|
675
|
-
throw
|
|
672
|
+
throw d({
|
|
676
673
|
code: "parse_error",
|
|
677
674
|
path: t,
|
|
678
675
|
details: { message: e }
|
|
679
676
|
});
|
|
680
677
|
}
|
|
681
|
-
class
|
|
678
|
+
class bt {
|
|
682
679
|
constructor(e, n, r = {}) {
|
|
683
680
|
this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
|
|
684
681
|
}
|
|
@@ -849,7 +846,7 @@ class at {
|
|
|
849
846
|
return { type: "literal", value: this.parseObjectLiteral() };
|
|
850
847
|
if (e === "[")
|
|
851
848
|
return { type: "literal", value: this.parseArrayLiteral() };
|
|
852
|
-
if (
|
|
849
|
+
if (V(e)) {
|
|
853
850
|
const n = this.readIdentifier();
|
|
854
851
|
if (n === "true" || n === "false" || n === "null" || n === "undefined")
|
|
855
852
|
return { type: "literal", value: n === "true" ? !0 : n === "false" ? !1 : n === "null" ? null : void 0 };
|
|
@@ -885,10 +882,10 @@ class at {
|
|
|
885
882
|
}
|
|
886
883
|
if (r === "$" && this.input[this.index + 1] === "{") {
|
|
887
884
|
e.push(n), n = "", this.index += 2;
|
|
888
|
-
const
|
|
885
|
+
const i = this.readTemplateExpression(), s = W(i, this.path, {
|
|
889
886
|
allowCalls: !1
|
|
890
887
|
});
|
|
891
|
-
e.push(
|
|
888
|
+
e.push(s);
|
|
892
889
|
continue;
|
|
893
890
|
}
|
|
894
891
|
n += r, this.index++;
|
|
@@ -900,27 +897,27 @@ class at {
|
|
|
900
897
|
const n = this.index;
|
|
901
898
|
let r = null;
|
|
902
899
|
for (; this.index < this.input.length; ) {
|
|
903
|
-
const
|
|
900
|
+
const i = this.input[this.index];
|
|
904
901
|
if (r) {
|
|
905
|
-
if (
|
|
902
|
+
if (i === "\\") {
|
|
906
903
|
this.index += 2;
|
|
907
904
|
continue;
|
|
908
905
|
}
|
|
909
|
-
|
|
906
|
+
i === r && (r = null), this.index++;
|
|
910
907
|
continue;
|
|
911
908
|
}
|
|
912
|
-
if (
|
|
913
|
-
r =
|
|
909
|
+
if (i === '"' || i === "'" || i === "`") {
|
|
910
|
+
r = i, this.index++;
|
|
914
911
|
continue;
|
|
915
912
|
}
|
|
916
|
-
if (
|
|
913
|
+
if (i === "{") {
|
|
917
914
|
e++, this.index++;
|
|
918
915
|
continue;
|
|
919
916
|
}
|
|
920
|
-
if (
|
|
917
|
+
if (i === "}") {
|
|
921
918
|
if (e--, e === 0) {
|
|
922
|
-
const
|
|
923
|
-
return this.index++,
|
|
919
|
+
const s = this.input.slice(n, this.index);
|
|
920
|
+
return this.index++, s;
|
|
924
921
|
}
|
|
925
922
|
this.index++;
|
|
926
923
|
continue;
|
|
@@ -1026,7 +1023,7 @@ class at {
|
|
|
1026
1023
|
return this.parseObjectLiteral();
|
|
1027
1024
|
if (e === "[")
|
|
1028
1025
|
return this.parseArrayLiteral();
|
|
1029
|
-
if (
|
|
1026
|
+
if (V(e)) {
|
|
1030
1027
|
const n = this.readIdentifier();
|
|
1031
1028
|
if (n === "true") return !0;
|
|
1032
1029
|
if (n === "false") return !1;
|
|
@@ -1044,9 +1041,9 @@ class at {
|
|
|
1044
1041
|
readIdentifier() {
|
|
1045
1042
|
this.skipWhitespace();
|
|
1046
1043
|
const e = this.index;
|
|
1047
|
-
if (!
|
|
1044
|
+
if (!V(this.peek()))
|
|
1048
1045
|
return "";
|
|
1049
|
-
for (this.index++; this.index < this.input.length &&
|
|
1046
|
+
for (this.index++; this.index < this.input.length && vt(this.peek()); )
|
|
1050
1047
|
this.index++;
|
|
1051
1048
|
return this.input.slice(e, this.index);
|
|
1052
1049
|
}
|
|
@@ -1061,8 +1058,8 @@ class at {
|
|
|
1061
1058
|
if (r === "\\") {
|
|
1062
1059
|
if (this.index++, this.index >= this.input.length)
|
|
1063
1060
|
throw x(this.path, "unterminated string escape");
|
|
1064
|
-
const
|
|
1065
|
-
n +=
|
|
1061
|
+
const i = this.input[this.index];
|
|
1062
|
+
n += i, this.index++;
|
|
1066
1063
|
continue;
|
|
1067
1064
|
}
|
|
1068
1065
|
n += r, this.index++;
|
|
@@ -1079,275 +1076,409 @@ class at {
|
|
|
1079
1076
|
return r;
|
|
1080
1077
|
}
|
|
1081
1078
|
}
|
|
1082
|
-
|
|
1079
|
+
const yt = /^( {0,3})(=+|-+)[ \t]*$/, Ae = /^( {0,3})(`{3,}|~{3,})(.*)$/;
|
|
1080
|
+
function M(t) {
|
|
1081
|
+
return t === " " || t === " ";
|
|
1082
|
+
}
|
|
1083
|
+
function Ee(t) {
|
|
1084
|
+
let e = 0;
|
|
1085
|
+
for (; e < t.length && e < 3 && t[e] === " "; )
|
|
1086
|
+
e += 1;
|
|
1087
|
+
const n = t.slice(0, e);
|
|
1088
|
+
let r = 0;
|
|
1089
|
+
for (; e < t.length && r < 6 && t[e] === "#"; )
|
|
1090
|
+
r += 1, e += 1;
|
|
1091
|
+
if (r === 0 || r === 6 && e < t.length && t[e] === "#")
|
|
1092
|
+
return null;
|
|
1093
|
+
if (e >= t.length)
|
|
1094
|
+
return { indent: n, level: r, text: "" };
|
|
1095
|
+
if (!M(t[e]))
|
|
1096
|
+
return null;
|
|
1097
|
+
for (; e < t.length && M(t[e]); )
|
|
1098
|
+
e += 1;
|
|
1099
|
+
let i = t.length;
|
|
1100
|
+
for (; i > e && M(t[i - 1]); )
|
|
1101
|
+
i -= 1;
|
|
1102
|
+
let s = i;
|
|
1103
|
+
if (i > e && t[i - 1] === "#") {
|
|
1104
|
+
let o = i - 1;
|
|
1105
|
+
for (; o > e && t[o - 1] === "#"; )
|
|
1106
|
+
o -= 1;
|
|
1107
|
+
if (o > e && M(t[o - 1])) {
|
|
1108
|
+
let a = o - 1;
|
|
1109
|
+
for (; a >= e && M(t[a]); )
|
|
1110
|
+
a -= 1;
|
|
1111
|
+
s = a + 1;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
return { indent: n, level: r, text: t.slice(e, s) };
|
|
1115
|
+
}
|
|
1116
|
+
function Te() {
|
|
1117
|
+
return { active: !1, marker: null, length: 0 };
|
|
1118
|
+
}
|
|
1119
|
+
function Le(t, e) {
|
|
1120
|
+
const n = Ae.exec(e);
|
|
1121
|
+
if (!t.active) {
|
|
1122
|
+
if (n) {
|
|
1123
|
+
const r = n[2];
|
|
1124
|
+
return t.active = !0, t.marker = r[0], t.length = r.length, !0;
|
|
1125
|
+
}
|
|
1126
|
+
return !1;
|
|
1127
|
+
}
|
|
1128
|
+
if (n) {
|
|
1129
|
+
const r = n[2], i = (n[3] ?? "").trim();
|
|
1130
|
+
r[0] === t.marker && r.length >= t.length && i.length === 0 && (t.active = !1, t.marker = null, t.length = 0);
|
|
1131
|
+
}
|
|
1132
|
+
return !0;
|
|
1133
|
+
}
|
|
1134
|
+
function Me(t) {
|
|
1135
|
+
const e = Ee(t);
|
|
1136
|
+
return e ? e.level : null;
|
|
1137
|
+
}
|
|
1138
|
+
function Oe(t) {
|
|
1139
|
+
const e = yt.exec(t);
|
|
1140
|
+
return e ? e[2][0] === "=" ? 1 : 2 : null;
|
|
1141
|
+
}
|
|
1142
|
+
function _t(t) {
|
|
1143
|
+
for (let e = 0; e < t.length; e++)
|
|
1144
|
+
if (!M(t[e]))
|
|
1145
|
+
return !1;
|
|
1146
|
+
return !0;
|
|
1147
|
+
}
|
|
1148
|
+
function Re(t) {
|
|
1149
|
+
return !(_t(t) || Me(t) !== null || Ae.test(t) || t.startsWith(" ") || t.startsWith(" "));
|
|
1150
|
+
}
|
|
1151
|
+
function He(t) {
|
|
1152
|
+
const e = t.split(`
|
|
1153
|
+
`), n = Te();
|
|
1154
|
+
let r = 0;
|
|
1155
|
+
for (let i = 0; i < e.length; i++) {
|
|
1156
|
+
const s = e[i];
|
|
1157
|
+
if (Le(n, s))
|
|
1158
|
+
continue;
|
|
1159
|
+
const o = Me(s);
|
|
1160
|
+
if (o !== null) {
|
|
1161
|
+
r = o;
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1164
|
+
const a = Oe(s);
|
|
1165
|
+
if (a !== null && i > 0) {
|
|
1166
|
+
const c = e[i - 1];
|
|
1167
|
+
Re(c) && (r = a);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
return r;
|
|
1171
|
+
}
|
|
1172
|
+
function St(t) {
|
|
1173
|
+
return t < 1 ? 1 : t > 6 ? 6 : t;
|
|
1174
|
+
}
|
|
1175
|
+
function me(t, e) {
|
|
1176
|
+
const n = e.trim(), r = "#".repeat(St(t));
|
|
1177
|
+
return n.length === 0 ? r : `${r} ${n}`;
|
|
1178
|
+
}
|
|
1179
|
+
function De(t, e) {
|
|
1180
|
+
if (e <= 0 || t.length === 0)
|
|
1181
|
+
return t;
|
|
1182
|
+
const n = t.split(`
|
|
1183
|
+
`), r = Te(), i = [];
|
|
1184
|
+
for (let s = 0; s < n.length; s++) {
|
|
1185
|
+
const o = n[s];
|
|
1186
|
+
if (Le(r, o)) {
|
|
1187
|
+
i.push(o);
|
|
1188
|
+
continue;
|
|
1189
|
+
}
|
|
1190
|
+
const a = Oe(o);
|
|
1191
|
+
if (a !== null && i.length > 0) {
|
|
1192
|
+
const h = i[i.length - 1];
|
|
1193
|
+
if (Re(h)) {
|
|
1194
|
+
i[i.length - 1] = me(a + e, h);
|
|
1195
|
+
continue;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
const c = Ee(o);
|
|
1199
|
+
if (c !== null) {
|
|
1200
|
+
i.push(c.indent + me(c.level + e, c.text));
|
|
1201
|
+
continue;
|
|
1202
|
+
}
|
|
1203
|
+
i.push(o);
|
|
1204
|
+
}
|
|
1205
|
+
return i.join(`
|
|
1206
|
+
`);
|
|
1207
|
+
}
|
|
1208
|
+
async function Ne(t, e, n = {}) {
|
|
1083
1209
|
const r = n.path;
|
|
1084
|
-
let
|
|
1085
|
-
for (;
|
|
1086
|
-
const o = t.indexOf("{",
|
|
1210
|
+
let i = "", s = 0;
|
|
1211
|
+
for (; s < t.length; ) {
|
|
1212
|
+
const o = t.indexOf("{", s);
|
|
1087
1213
|
if (o === -1) {
|
|
1088
|
-
|
|
1214
|
+
i += t.slice(s);
|
|
1089
1215
|
break;
|
|
1090
1216
|
}
|
|
1091
|
-
|
|
1217
|
+
i += t.slice(s, o);
|
|
1092
1218
|
const a = t[o + 1] === "{" && t[o + 2] === "{" && (o === 0 || t[o - 1] !== "\\");
|
|
1093
1219
|
if (!(!a && t[o + 1] === "{" && (o === 0 || t[o - 1] !== "\\")) && !a) {
|
|
1094
|
-
|
|
1220
|
+
i += "{", s = o + 1;
|
|
1095
1221
|
continue;
|
|
1096
1222
|
}
|
|
1097
|
-
const h = a ? 3 : 2, l = a ? "}}}" : "}}",
|
|
1098
|
-
if (
|
|
1099
|
-
throw
|
|
1223
|
+
const h = a ? 3 : 2, l = a ? "}}}" : "}}", u = t.indexOf(l, o + h);
|
|
1224
|
+
if (u === -1)
|
|
1225
|
+
throw d({
|
|
1100
1226
|
code: "parse_error",
|
|
1101
1227
|
path: r,
|
|
1102
1228
|
details: { message: "unclosed expression" }
|
|
1103
1229
|
});
|
|
1104
|
-
const f = t.slice(o + h,
|
|
1230
|
+
const f = t.slice(o + h, u).trim(), g = W(f, r), m = await w(g, {
|
|
1105
1231
|
...n,
|
|
1106
1232
|
context: e,
|
|
1107
1233
|
path: r,
|
|
1108
1234
|
parentContext: n.parentContext ?? e
|
|
1109
1235
|
});
|
|
1110
|
-
|
|
1236
|
+
let p = m == null ? "" : String(m);
|
|
1237
|
+
if (g.type === "call" && p.length > 0) {
|
|
1238
|
+
const S = He(i);
|
|
1239
|
+
p = De(p, S);
|
|
1240
|
+
}
|
|
1241
|
+
i += p, s = u + l.length;
|
|
1111
1242
|
}
|
|
1112
|
-
return
|
|
1243
|
+
return i;
|
|
1113
1244
|
}
|
|
1114
|
-
function
|
|
1245
|
+
function Ct(t, e) {
|
|
1115
1246
|
let n = 0, r = 0;
|
|
1116
1247
|
for (; r < t.length; ) {
|
|
1117
|
-
const
|
|
1118
|
-
if (
|
|
1248
|
+
const i = t.indexOf(e, r);
|
|
1249
|
+
if (i === -1)
|
|
1119
1250
|
break;
|
|
1120
|
-
n++, r =
|
|
1251
|
+
n++, r = i + e.length;
|
|
1121
1252
|
}
|
|
1122
1253
|
return n;
|
|
1123
1254
|
}
|
|
1124
|
-
function
|
|
1125
|
-
const e = t.includes("@hg"), n = t.includes("@endhg"), r =
|
|
1255
|
+
function ee(t) {
|
|
1256
|
+
const e = t.includes("@hg"), n = t.includes("@endhg"), r = Ct(t, "@@");
|
|
1126
1257
|
return e && n ? r > 0 ? "mixed" : "hg" : r >= 2 && !e && !n ? "at-at" : (e || n) && r > 0 ? "mixed" : e && !n || r === 1 && !n ? "unclosed" : "none";
|
|
1127
1258
|
}
|
|
1128
|
-
function
|
|
1259
|
+
function te(t) {
|
|
1129
1260
|
return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
|
|
1130
1261
|
}
|
|
1131
|
-
function
|
|
1262
|
+
function ne(t, e) {
|
|
1132
1263
|
let n = 0, r = !1;
|
|
1133
1264
|
for (; n < e; ) {
|
|
1134
|
-
const
|
|
1135
|
-
if (
|
|
1265
|
+
const i = t.indexOf("```", n);
|
|
1266
|
+
if (i === -1 || i >= e)
|
|
1136
1267
|
break;
|
|
1137
|
-
r = !r, n =
|
|
1268
|
+
r = !r, n = i + 3;
|
|
1138
1269
|
}
|
|
1139
1270
|
return r;
|
|
1140
1271
|
}
|
|
1141
|
-
function
|
|
1272
|
+
function E(t) {
|
|
1142
1273
|
const e = [];
|
|
1143
1274
|
let n = 0;
|
|
1144
1275
|
for (; n < t.length; ) {
|
|
1145
1276
|
const r = t.indexOf("<!--", n);
|
|
1146
1277
|
if (r === -1)
|
|
1147
1278
|
break;
|
|
1148
|
-
if (
|
|
1279
|
+
if (ne(t, r)) {
|
|
1149
1280
|
n = r + 4;
|
|
1150
1281
|
continue;
|
|
1151
1282
|
}
|
|
1152
|
-
const
|
|
1153
|
-
if (
|
|
1283
|
+
const i = t.indexOf("-->", r + 4);
|
|
1284
|
+
if (i === -1)
|
|
1154
1285
|
break;
|
|
1155
|
-
const
|
|
1286
|
+
const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = ee(o);
|
|
1156
1287
|
(a === "hg" || a === "at-at") && e.push({
|
|
1157
1288
|
start: r,
|
|
1158
|
-
end:
|
|
1289
|
+
end: i + 3,
|
|
1159
1290
|
inner: o,
|
|
1160
|
-
raw:
|
|
1161
|
-
}), n =
|
|
1291
|
+
raw: s
|
|
1292
|
+
}), n = i + 3;
|
|
1162
1293
|
}
|
|
1163
1294
|
return e;
|
|
1164
1295
|
}
|
|
1165
|
-
function
|
|
1296
|
+
function Be(t) {
|
|
1166
1297
|
let e = 0;
|
|
1167
1298
|
for (; e < t.length; ) {
|
|
1168
1299
|
const n = t.indexOf("<!--", e);
|
|
1169
1300
|
if (n === -1)
|
|
1170
1301
|
return !1;
|
|
1171
|
-
if (
|
|
1302
|
+
if (ne(t, n)) {
|
|
1172
1303
|
e = n + 4;
|
|
1173
1304
|
continue;
|
|
1174
1305
|
}
|
|
1175
1306
|
const r = t.indexOf("-->", n + 4);
|
|
1176
1307
|
if (r === -1)
|
|
1177
1308
|
return !1;
|
|
1178
|
-
const
|
|
1179
|
-
if (
|
|
1309
|
+
const i = t.slice(n + 4, r), s = ee(i);
|
|
1310
|
+
if (s === "unclosed" || s === "mixed")
|
|
1180
1311
|
return !0;
|
|
1181
1312
|
e = r + 3;
|
|
1182
1313
|
}
|
|
1183
1314
|
return !1;
|
|
1184
1315
|
}
|
|
1185
|
-
function
|
|
1316
|
+
function Fe(t) {
|
|
1186
1317
|
let e = 0;
|
|
1187
1318
|
for (; e < t.length; ) {
|
|
1188
1319
|
const n = t.indexOf("<!--", e);
|
|
1189
1320
|
if (n === -1)
|
|
1190
1321
|
return null;
|
|
1191
|
-
if (
|
|
1322
|
+
if (ne(t, n)) {
|
|
1192
1323
|
e = n + 4;
|
|
1193
1324
|
continue;
|
|
1194
1325
|
}
|
|
1195
1326
|
const r = t.indexOf("-->", n + 4);
|
|
1196
1327
|
if (r === -1)
|
|
1197
1328
|
return null;
|
|
1198
|
-
const
|
|
1199
|
-
if (
|
|
1329
|
+
const i = t.slice(n + 4, r), s = ee(i);
|
|
1330
|
+
if (s === "mixed")
|
|
1200
1331
|
return "mixed @hg and @@ markers are not allowed";
|
|
1201
|
-
if (
|
|
1332
|
+
if (s === "unclosed")
|
|
1202
1333
|
return "unclosed hyogen block (missing closing marker)";
|
|
1203
1334
|
e = r + 3;
|
|
1204
1335
|
}
|
|
1205
1336
|
return null;
|
|
1206
1337
|
}
|
|
1207
|
-
function
|
|
1208
|
-
return
|
|
1338
|
+
function A(t) {
|
|
1339
|
+
return te(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
|
|
1209
1340
|
}
|
|
1210
|
-
const
|
|
1211
|
-
function
|
|
1212
|
-
return
|
|
1341
|
+
const Wt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
|
|
1342
|
+
function je(t) {
|
|
1343
|
+
return Wt.test(t.trim());
|
|
1213
1344
|
}
|
|
1214
|
-
function
|
|
1215
|
-
throw
|
|
1345
|
+
function K(t, e) {
|
|
1346
|
+
throw d({
|
|
1216
1347
|
code: "parse_error",
|
|
1217
1348
|
path: t,
|
|
1218
1349
|
details: { message: e }
|
|
1219
1350
|
});
|
|
1220
1351
|
}
|
|
1221
|
-
function
|
|
1352
|
+
function $t(t, e) {
|
|
1222
1353
|
let n = t;
|
|
1223
1354
|
const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
|
|
1224
1355
|
r && (n = r[1]);
|
|
1225
|
-
const
|
|
1226
|
-
if (
|
|
1356
|
+
const i = A(n);
|
|
1357
|
+
if (i.length !== 1)
|
|
1227
1358
|
return null;
|
|
1228
|
-
const
|
|
1229
|
-
if (/^include\s+/i.test(
|
|
1359
|
+
const s = i[0];
|
|
1360
|
+
if (/^include\s+/i.test(s) || /^component\s+/i.test(s) || /^const\s+/i.test(s) || /^let\s+/i.test(s) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(s))
|
|
1230
1361
|
return null;
|
|
1231
|
-
if (
|
|
1362
|
+
if (s === "else")
|
|
1232
1363
|
return { kind: "else" };
|
|
1233
|
-
if (
|
|
1364
|
+
if (s === "endif")
|
|
1234
1365
|
return { kind: "endif" };
|
|
1235
|
-
if (
|
|
1366
|
+
if (s === "endeach")
|
|
1236
1367
|
return { kind: "endeach" };
|
|
1237
|
-
if (/^IF\b/.test(
|
|
1238
|
-
throw
|
|
1239
|
-
const o = /^else\s+if\s+(.+)$/.exec(
|
|
1368
|
+
if (/^IF\b/.test(s) || /^ELSE\b/.test(s) || /^ENDIF\b/.test(s))
|
|
1369
|
+
throw K(e, "control keywords must be lowercase");
|
|
1370
|
+
const o = /^else\s+if\s+(.+)$/.exec(s);
|
|
1240
1371
|
if (o)
|
|
1241
1372
|
return {
|
|
1242
1373
|
kind: "else_if",
|
|
1243
|
-
expr:
|
|
1374
|
+
expr: W(o[1], e)
|
|
1244
1375
|
};
|
|
1245
|
-
const a = /^if\s+(.+)$/.exec(
|
|
1376
|
+
const a = /^if\s+(.+)$/.exec(s);
|
|
1246
1377
|
if (a)
|
|
1247
1378
|
return {
|
|
1248
1379
|
kind: "if",
|
|
1249
|
-
expr:
|
|
1380
|
+
expr: W(a[1], e)
|
|
1250
1381
|
};
|
|
1251
|
-
const c = /^each\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+in\s+(.+)$/.exec(
|
|
1382
|
+
const c = /^each\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+in\s+(.+)$/.exec(s);
|
|
1252
1383
|
if (c)
|
|
1253
1384
|
return {
|
|
1254
1385
|
kind: "each",
|
|
1255
1386
|
item: c[1],
|
|
1256
|
-
expr:
|
|
1387
|
+
expr: W(c[2], e)
|
|
1257
1388
|
};
|
|
1258
|
-
if (
|
|
1259
|
-
throw
|
|
1260
|
-
if (/^each\s+/.test(
|
|
1261
|
-
throw
|
|
1389
|
+
if (s === "if")
|
|
1390
|
+
throw K(e, "if requires an expression");
|
|
1391
|
+
if (/^each\s+/.test(s))
|
|
1392
|
+
throw K(e, "invalid each directive");
|
|
1262
1393
|
return null;
|
|
1263
1394
|
}
|
|
1264
1395
|
function R(t) {
|
|
1265
1396
|
return { start: t.start, end: t.end, raw: t.raw };
|
|
1266
1397
|
}
|
|
1267
|
-
function
|
|
1268
|
-
throw
|
|
1398
|
+
function $(t, e) {
|
|
1399
|
+
throw d({
|
|
1269
1400
|
code: "parse_error",
|
|
1270
1401
|
path: t,
|
|
1271
1402
|
details: { message: e }
|
|
1272
1403
|
});
|
|
1273
1404
|
}
|
|
1274
|
-
function
|
|
1405
|
+
function At(t, e) {
|
|
1275
1406
|
const n = [];
|
|
1276
|
-
for (const r of
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1407
|
+
for (const r of E(t)) {
|
|
1408
|
+
const i = $t(r.inner, e);
|
|
1409
|
+
i && n.push({
|
|
1279
1410
|
start: r.start,
|
|
1280
1411
|
end: r.end,
|
|
1281
1412
|
raw: r.raw,
|
|
1282
|
-
opener:
|
|
1413
|
+
opener: i
|
|
1283
1414
|
});
|
|
1284
1415
|
}
|
|
1285
1416
|
return n;
|
|
1286
1417
|
}
|
|
1287
|
-
function
|
|
1418
|
+
function Pe(t) {
|
|
1288
1419
|
return t.kind === "if" || t.kind === "each";
|
|
1289
1420
|
}
|
|
1290
|
-
function
|
|
1291
|
-
const n =
|
|
1421
|
+
function Et(t, e) {
|
|
1422
|
+
const n = At(t, e);
|
|
1292
1423
|
if (n.length === 0)
|
|
1293
1424
|
return t.length > 0 ? [{ kind: "text", content: t }] : [];
|
|
1294
|
-
const { nodes: r, nextIndex:
|
|
1295
|
-
if (
|
|
1296
|
-
const
|
|
1297
|
-
if (
|
|
1298
|
-
throw
|
|
1299
|
-
if (
|
|
1300
|
-
throw
|
|
1301
|
-
if (
|
|
1302
|
-
throw
|
|
1425
|
+
const { nodes: r, nextIndex: i } = F(t, n, 0, n.length, e);
|
|
1426
|
+
if (i < n.length) {
|
|
1427
|
+
const s = n[i];
|
|
1428
|
+
if (s.opener.kind === "endif")
|
|
1429
|
+
throw $(e, "endif without matching if");
|
|
1430
|
+
if (s.opener.kind === "endeach")
|
|
1431
|
+
throw $(e, "endeach without matching each");
|
|
1432
|
+
if (s.opener.kind === "else" || s.opener.kind === "else_if")
|
|
1433
|
+
throw $(e, "else without matching if");
|
|
1303
1434
|
}
|
|
1304
1435
|
return r;
|
|
1305
1436
|
}
|
|
1306
|
-
function
|
|
1437
|
+
function F(t, e, n, r, i, s = 0, o) {
|
|
1307
1438
|
const a = o ?? t.length, c = [];
|
|
1308
|
-
let h =
|
|
1439
|
+
let h = s, l = n;
|
|
1309
1440
|
for (; l < r; ) {
|
|
1310
|
-
const
|
|
1311
|
-
if (
|
|
1441
|
+
const u = e[l];
|
|
1442
|
+
if (u.start >= a)
|
|
1312
1443
|
break;
|
|
1313
|
-
if (
|
|
1444
|
+
if (u.end <= s) {
|
|
1314
1445
|
l++;
|
|
1315
1446
|
continue;
|
|
1316
1447
|
}
|
|
1317
|
-
if (
|
|
1448
|
+
if (u.start > h && c.push({
|
|
1318
1449
|
kind: "text",
|
|
1319
|
-
content: t.slice(h,
|
|
1320
|
-
}),
|
|
1321
|
-
const f =
|
|
1450
|
+
content: t.slice(h, u.start)
|
|
1451
|
+
}), u.opener.kind === "if") {
|
|
1452
|
+
const f = Tt(t, e, l, r, i);
|
|
1322
1453
|
c.push(f.node), h = f.endPos, l = f.nextIndex;
|
|
1323
1454
|
continue;
|
|
1324
1455
|
}
|
|
1325
|
-
if (
|
|
1326
|
-
const f =
|
|
1456
|
+
if (u.opener.kind === "each") {
|
|
1457
|
+
const f = Lt(t, e, l, r, i);
|
|
1327
1458
|
c.push(f.node), h = f.endPos, l = f.nextIndex;
|
|
1328
1459
|
continue;
|
|
1329
1460
|
}
|
|
1330
|
-
if (
|
|
1331
|
-
throw
|
|
1332
|
-
if (
|
|
1333
|
-
throw
|
|
1334
|
-
if (
|
|
1335
|
-
throw
|
|
1461
|
+
if (u.opener.kind === "else" || u.opener.kind === "else_if")
|
|
1462
|
+
throw $(i, "else without matching if");
|
|
1463
|
+
if (u.opener.kind === "endif")
|
|
1464
|
+
throw $(i, "endif without matching if");
|
|
1465
|
+
if (u.opener.kind === "endeach")
|
|
1466
|
+
throw $(i, "endeach without matching each");
|
|
1336
1467
|
l++;
|
|
1337
1468
|
}
|
|
1338
1469
|
return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
|
|
1339
1470
|
}
|
|
1340
|
-
function
|
|
1341
|
-
const
|
|
1342
|
-
if (
|
|
1343
|
-
throw
|
|
1471
|
+
function Tt(t, e, n, r, i) {
|
|
1472
|
+
const s = e[n];
|
|
1473
|
+
if (s.opener.kind !== "if")
|
|
1474
|
+
throw $(i, "expected if");
|
|
1344
1475
|
const o = [];
|
|
1345
|
-
let a = n, c =
|
|
1476
|
+
let a = n, c = s.end, h = 0;
|
|
1346
1477
|
for (; a < r; ) {
|
|
1347
1478
|
const l = e[a];
|
|
1348
1479
|
if (a === n) {
|
|
1349
1480
|
if (l.opener.kind !== "if")
|
|
1350
|
-
throw
|
|
1481
|
+
throw $(i, "expected if");
|
|
1351
1482
|
o.push({
|
|
1352
1483
|
kind: "if",
|
|
1353
1484
|
expr: l.opener.expr,
|
|
@@ -1356,18 +1487,18 @@ function ft(t, e, n, r, s) {
|
|
|
1356
1487
|
}), a++;
|
|
1357
1488
|
continue;
|
|
1358
1489
|
}
|
|
1359
|
-
if (
|
|
1490
|
+
if (Pe(l.opener)) {
|
|
1360
1491
|
h++, a++;
|
|
1361
1492
|
continue;
|
|
1362
1493
|
}
|
|
1363
1494
|
if (l.opener.kind === "endif") {
|
|
1364
1495
|
if (h === 0)
|
|
1365
|
-
return o[o.length - 1].body =
|
|
1496
|
+
return o[o.length - 1].body = F(
|
|
1366
1497
|
t,
|
|
1367
1498
|
e,
|
|
1368
1499
|
n + 1,
|
|
1369
1500
|
a,
|
|
1370
|
-
|
|
1501
|
+
i,
|
|
1371
1502
|
c,
|
|
1372
1503
|
l.start
|
|
1373
1504
|
).nodes, {
|
|
@@ -1384,12 +1515,12 @@ function ft(t, e, n, r, s) {
|
|
|
1384
1515
|
}
|
|
1385
1516
|
if (h === 0) {
|
|
1386
1517
|
if (l.opener.kind === "else_if") {
|
|
1387
|
-
o[o.length - 1].body =
|
|
1518
|
+
o[o.length - 1].body = F(
|
|
1388
1519
|
t,
|
|
1389
1520
|
e,
|
|
1390
1521
|
n + 1,
|
|
1391
1522
|
a,
|
|
1392
|
-
|
|
1523
|
+
i,
|
|
1393
1524
|
c,
|
|
1394
1525
|
l.start
|
|
1395
1526
|
).nodes, o.push({
|
|
@@ -1401,12 +1532,12 @@ function ft(t, e, n, r, s) {
|
|
|
1401
1532
|
continue;
|
|
1402
1533
|
}
|
|
1403
1534
|
if (l.opener.kind === "else") {
|
|
1404
|
-
o[o.length - 1].body =
|
|
1535
|
+
o[o.length - 1].body = F(
|
|
1405
1536
|
t,
|
|
1406
1537
|
e,
|
|
1407
1538
|
n + 1,
|
|
1408
1539
|
a,
|
|
1409
|
-
|
|
1540
|
+
i,
|
|
1410
1541
|
c,
|
|
1411
1542
|
l.start
|
|
1412
1543
|
).nodes, o.push({
|
|
@@ -1419,38 +1550,38 @@ function ft(t, e, n, r, s) {
|
|
|
1419
1550
|
}
|
|
1420
1551
|
a++;
|
|
1421
1552
|
}
|
|
1422
|
-
throw
|
|
1553
|
+
throw $(i, "unclosed if block (missing endif)");
|
|
1423
1554
|
}
|
|
1424
|
-
function
|
|
1425
|
-
const
|
|
1426
|
-
if (
|
|
1427
|
-
throw
|
|
1555
|
+
function Lt(t, e, n, r, i) {
|
|
1556
|
+
const s = e[n];
|
|
1557
|
+
if (s.opener.kind !== "each")
|
|
1558
|
+
throw $(i, "expected each");
|
|
1428
1559
|
let o = n + 1;
|
|
1429
|
-
const a =
|
|
1560
|
+
const a = s.end;
|
|
1430
1561
|
let c = 0;
|
|
1431
1562
|
for (; o < r; ) {
|
|
1432
1563
|
const h = e[o];
|
|
1433
|
-
if (
|
|
1564
|
+
if (Pe(h.opener)) {
|
|
1434
1565
|
c++, o++;
|
|
1435
1566
|
continue;
|
|
1436
1567
|
}
|
|
1437
1568
|
if (h.opener.kind === "endeach") {
|
|
1438
1569
|
if (c === 0) {
|
|
1439
|
-
const l =
|
|
1570
|
+
const l = F(
|
|
1440
1571
|
t,
|
|
1441
1572
|
e,
|
|
1442
1573
|
n + 1,
|
|
1443
1574
|
o,
|
|
1444
|
-
|
|
1575
|
+
i,
|
|
1445
1576
|
a,
|
|
1446
1577
|
h.start
|
|
1447
1578
|
).nodes;
|
|
1448
1579
|
return {
|
|
1449
1580
|
node: {
|
|
1450
1581
|
kind: "each",
|
|
1451
|
-
item:
|
|
1452
|
-
expr:
|
|
1453
|
-
opener: R(
|
|
1582
|
+
item: s.opener.item,
|
|
1583
|
+
expr: s.opener.expr,
|
|
1584
|
+
opener: R(s),
|
|
1454
1585
|
body: l,
|
|
1455
1586
|
closer: R(h)
|
|
1456
1587
|
},
|
|
@@ -1467,28 +1598,28 @@ function pt(t, e, n, r, s) {
|
|
|
1467
1598
|
}
|
|
1468
1599
|
o++;
|
|
1469
1600
|
}
|
|
1470
|
-
throw
|
|
1601
|
+
throw $(i, "unclosed each block (missing endeach)");
|
|
1471
1602
|
}
|
|
1472
|
-
const
|
|
1473
|
-
class
|
|
1603
|
+
const ge = 20;
|
|
1604
|
+
class Mt {
|
|
1474
1605
|
depth = 0;
|
|
1475
1606
|
get currentDepth() {
|
|
1476
1607
|
return this.depth;
|
|
1477
1608
|
}
|
|
1478
1609
|
enter() {
|
|
1479
|
-
return this.depth >=
|
|
1610
|
+
return this.depth >= ge ? { exceeded: !0, limit: ge } : (this.depth++, { exceeded: !1, depth: this.depth });
|
|
1480
1611
|
}
|
|
1481
1612
|
exit() {
|
|
1482
1613
|
this.depth > 0 && this.depth--;
|
|
1483
1614
|
}
|
|
1484
1615
|
}
|
|
1485
|
-
function
|
|
1616
|
+
function Ot(t) {
|
|
1486
1617
|
return !!t;
|
|
1487
1618
|
}
|
|
1488
|
-
function
|
|
1619
|
+
function Rt(t) {
|
|
1489
1620
|
return t != null && typeof t[Symbol.iterator] == "function";
|
|
1490
1621
|
}
|
|
1491
|
-
function
|
|
1622
|
+
function Ie(t) {
|
|
1492
1623
|
return {
|
|
1493
1624
|
code: "nest_limit_exceeded",
|
|
1494
1625
|
message: "structure nest limit exceeded",
|
|
@@ -1496,49 +1627,49 @@ function $e(t) {
|
|
|
1496
1627
|
details: { limit: 20 }
|
|
1497
1628
|
};
|
|
1498
1629
|
}
|
|
1499
|
-
function
|
|
1630
|
+
function re(t) {
|
|
1500
1631
|
return t.startsWith(`
|
|
1501
1632
|
`) ? t.slice(1) : t;
|
|
1502
1633
|
}
|
|
1503
|
-
async function
|
|
1504
|
-
const n = e.path, r = e.warnings ?? [],
|
|
1505
|
-
return
|
|
1634
|
+
async function Ht(t, e) {
|
|
1635
|
+
const n = e.path, r = e.warnings ?? [], i = Et(t, n), s = new Mt();
|
|
1636
|
+
return ie(i, e, s, r);
|
|
1506
1637
|
}
|
|
1507
|
-
async function
|
|
1508
|
-
const
|
|
1509
|
-
let
|
|
1638
|
+
async function ie(t, e, n, r) {
|
|
1639
|
+
const i = e.preserveHgComments === !0;
|
|
1640
|
+
let s = "", o = !1;
|
|
1510
1641
|
for (const a of t) {
|
|
1511
|
-
let c = await
|
|
1512
|
-
o && (c =
|
|
1642
|
+
let c = await Dt(a, e, n, r);
|
|
1643
|
+
o && (c = re(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
|
|
1513
1644
|
}
|
|
1514
|
-
return
|
|
1645
|
+
return s;
|
|
1515
1646
|
}
|
|
1516
|
-
async function
|
|
1647
|
+
async function Dt(t, e, n, r) {
|
|
1517
1648
|
switch (t.kind) {
|
|
1518
1649
|
case "text":
|
|
1519
1650
|
return t.content;
|
|
1520
1651
|
case "if":
|
|
1521
|
-
return
|
|
1652
|
+
return Nt(t, e, n, r);
|
|
1522
1653
|
case "each":
|
|
1523
|
-
return
|
|
1654
|
+
return Bt(t, e, n, r);
|
|
1524
1655
|
default:
|
|
1525
1656
|
return "";
|
|
1526
1657
|
}
|
|
1527
1658
|
}
|
|
1528
|
-
async function
|
|
1659
|
+
async function Nt(t, e, n, r) {
|
|
1529
1660
|
if (n.enter().exceeded)
|
|
1530
|
-
return r.push(
|
|
1661
|
+
return r.push(Ie(e.path)), "";
|
|
1531
1662
|
try {
|
|
1532
|
-
let
|
|
1663
|
+
let s = -1;
|
|
1533
1664
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1534
1665
|
const h = t.branches[c];
|
|
1535
1666
|
if (h.kind === "else") {
|
|
1536
|
-
|
|
1667
|
+
s = c;
|
|
1537
1668
|
break;
|
|
1538
1669
|
}
|
|
1539
1670
|
const l = await w(h.expr, e);
|
|
1540
|
-
if (
|
|
1541
|
-
|
|
1671
|
+
if (Ot(l)) {
|
|
1672
|
+
s = c;
|
|
1542
1673
|
break;
|
|
1543
1674
|
}
|
|
1544
1675
|
}
|
|
@@ -1546,9 +1677,9 @@ async function bt(t, e, n, r) {
|
|
|
1546
1677
|
let a = "";
|
|
1547
1678
|
for (let c = 0; c < t.branches.length; c++) {
|
|
1548
1679
|
const h = t.branches[c];
|
|
1549
|
-
if (o && (a += h.opener.raw), c ===
|
|
1550
|
-
let l = await
|
|
1551
|
-
o || (l =
|
|
1680
|
+
if (o && (a += h.opener.raw), c === s) {
|
|
1681
|
+
let l = await ie(h.body, e, n, r);
|
|
1682
|
+
o || (l = re(l)), a += l;
|
|
1552
1683
|
}
|
|
1553
1684
|
}
|
|
1554
1685
|
return o && (a += t.closer.raw), a;
|
|
@@ -1556,24 +1687,24 @@ async function bt(t, e, n, r) {
|
|
|
1556
1687
|
n.exit();
|
|
1557
1688
|
}
|
|
1558
1689
|
}
|
|
1559
|
-
async function
|
|
1690
|
+
async function Bt(t, e, n, r) {
|
|
1560
1691
|
if (n.enter().exceeded)
|
|
1561
|
-
return r.push(
|
|
1692
|
+
return r.push(Ie(e.path)), "";
|
|
1562
1693
|
try {
|
|
1563
|
-
const
|
|
1564
|
-
if (!
|
|
1694
|
+
const s = await w(t.expr, e);
|
|
1695
|
+
if (!Rt(s))
|
|
1565
1696
|
return "";
|
|
1566
1697
|
const o = e.preserveHgComments === !0;
|
|
1567
1698
|
let a = "";
|
|
1568
|
-
for (const c of
|
|
1699
|
+
for (const c of s) {
|
|
1569
1700
|
const h = { ...e.context, [t.item]: c };
|
|
1570
1701
|
o && (a += t.opener.raw);
|
|
1571
|
-
let l = await
|
|
1702
|
+
let l = await ie(t.body, {
|
|
1572
1703
|
...e,
|
|
1573
1704
|
context: h
|
|
1574
1705
|
}, n, r);
|
|
1575
|
-
o || (l =
|
|
1576
|
-
const
|
|
1706
|
+
o || (l = re(l));
|
|
1707
|
+
const u = await Ne(l, h, {
|
|
1577
1708
|
path: e.path,
|
|
1578
1709
|
registry: e.registry,
|
|
1579
1710
|
loader: e.loader,
|
|
@@ -1584,56 +1715,56 @@ async function yt(t, e, n, r) {
|
|
|
1584
1715
|
preserveHgComments: e.preserveHgComments,
|
|
1585
1716
|
constrainToRoot: e.constrainToRoot
|
|
1586
1717
|
});
|
|
1587
|
-
a +=
|
|
1718
|
+
a += u, o && (a += t.closer.raw);
|
|
1588
1719
|
}
|
|
1589
1720
|
return a;
|
|
1590
1721
|
} finally {
|
|
1591
1722
|
n.exit();
|
|
1592
1723
|
}
|
|
1593
1724
|
}
|
|
1594
|
-
function
|
|
1595
|
-
return
|
|
1725
|
+
function X(t, e, n, r, i = !1, s = !1) {
|
|
1726
|
+
return We(e) ? e : $e(e, {
|
|
1596
1727
|
rootDir: t,
|
|
1597
1728
|
fromPath: r,
|
|
1598
1729
|
documentPath: n,
|
|
1599
|
-
constrainToRoot:
|
|
1600
|
-
hyogenPath:
|
|
1730
|
+
constrainToRoot: i,
|
|
1731
|
+
hyogenPath: s
|
|
1601
1732
|
});
|
|
1602
1733
|
}
|
|
1603
|
-
function
|
|
1734
|
+
function ze(t) {
|
|
1604
1735
|
let e = 0;
|
|
1605
1736
|
for (let n = t.length - 1; n >= 0 && t[n] === `
|
|
1606
1737
|
`; n--)
|
|
1607
1738
|
e++;
|
|
1608
1739
|
return e;
|
|
1609
1740
|
}
|
|
1610
|
-
function
|
|
1741
|
+
function Ue(t) {
|
|
1611
1742
|
let e = 0;
|
|
1612
1743
|
for (; e < t.length && t[e] === `
|
|
1613
1744
|
`; )
|
|
1614
1745
|
e++;
|
|
1615
1746
|
return e;
|
|
1616
1747
|
}
|
|
1617
|
-
function
|
|
1618
|
-
const n =
|
|
1748
|
+
function T(t, e) {
|
|
1749
|
+
const n = ze(t), r = Ue(e), i = Math.max(n, r);
|
|
1619
1750
|
return t.slice(0, t.length - n) + `
|
|
1620
|
-
`.repeat(
|
|
1751
|
+
`.repeat(i) + e.slice(r);
|
|
1621
1752
|
}
|
|
1622
|
-
function
|
|
1623
|
-
const n =
|
|
1753
|
+
function se(t, e) {
|
|
1754
|
+
const n = ze(t), r = Ue(e);
|
|
1624
1755
|
return n + r - Math.max(n, r);
|
|
1625
1756
|
}
|
|
1626
|
-
function
|
|
1757
|
+
function xe(t, e, n) {
|
|
1627
1758
|
const r = t.indexOf(e);
|
|
1628
1759
|
if (r < 0)
|
|
1629
1760
|
return t;
|
|
1630
|
-
const
|
|
1631
|
-
return
|
|
1761
|
+
const i = t.slice(0, r), s = t.slice(r + e.length);
|
|
1762
|
+
return T(T(i, n), s);
|
|
1632
1763
|
}
|
|
1633
|
-
async function
|
|
1764
|
+
async function Ft(t) {
|
|
1634
1765
|
let e = t.source;
|
|
1635
1766
|
for (const n of t.directives) {
|
|
1636
|
-
const r =
|
|
1767
|
+
const r = X(
|
|
1637
1768
|
t.root,
|
|
1638
1769
|
n.path,
|
|
1639
1770
|
t.path,
|
|
@@ -1642,28 +1773,28 @@ async function vt(t) {
|
|
|
1642
1773
|
!0
|
|
1643
1774
|
);
|
|
1644
1775
|
if (t.visitStack) {
|
|
1645
|
-
const
|
|
1646
|
-
if (
|
|
1776
|
+
const i = t.visitStack.check(r);
|
|
1777
|
+
if (i.circular) {
|
|
1647
1778
|
t.warnings?.push({
|
|
1648
1779
|
code: "circular_include",
|
|
1649
|
-
message:
|
|
1780
|
+
message: H("circular_include", {
|
|
1650
1781
|
path: r,
|
|
1651
|
-
from:
|
|
1782
|
+
from: i.from,
|
|
1652
1783
|
via: "include"
|
|
1653
1784
|
}),
|
|
1654
1785
|
path: t.path,
|
|
1655
1786
|
details: {
|
|
1656
1787
|
path: r,
|
|
1657
|
-
from:
|
|
1788
|
+
from: i.from,
|
|
1658
1789
|
via: "include"
|
|
1659
1790
|
}
|
|
1660
|
-
}), e =
|
|
1791
|
+
}), e = xe(e, n.marker, "");
|
|
1661
1792
|
continue;
|
|
1662
1793
|
}
|
|
1663
1794
|
t.visitStack.push(r);
|
|
1664
1795
|
}
|
|
1665
1796
|
try {
|
|
1666
|
-
const
|
|
1797
|
+
const i = await t.loader(r), s = await $n(i, {
|
|
1667
1798
|
context: t.context,
|
|
1668
1799
|
loader: t.loader,
|
|
1669
1800
|
root: t.root,
|
|
@@ -1673,16 +1804,16 @@ async function vt(t) {
|
|
|
1673
1804
|
visitStack: t.visitStack,
|
|
1674
1805
|
warnings: t.warnings,
|
|
1675
1806
|
registry: t.registry
|
|
1676
|
-
}), o = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1677
|
-
${
|
|
1678
|
-
e =
|
|
1807
|
+
}), o = e.indexOf(n.marker), a = o >= 0 ? e.slice(0, o) : e, c = He(a), h = De(s, c), l = t.preserveHgComments && n.raw ? `${n.raw}
|
|
1808
|
+
${h}` : h;
|
|
1809
|
+
e = xe(e, n.marker, l);
|
|
1679
1810
|
} finally {
|
|
1680
1811
|
t.visitStack?.pop();
|
|
1681
1812
|
}
|
|
1682
1813
|
}
|
|
1683
1814
|
return e;
|
|
1684
1815
|
}
|
|
1685
|
-
class
|
|
1816
|
+
class Ze {
|
|
1686
1817
|
stack = [];
|
|
1687
1818
|
check(e) {
|
|
1688
1819
|
return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
|
|
@@ -1698,28 +1829,28 @@ class Le {
|
|
|
1698
1829
|
this.stack.pop();
|
|
1699
1830
|
}
|
|
1700
1831
|
}
|
|
1701
|
-
async function
|
|
1702
|
-
const { path: r, constBindings:
|
|
1832
|
+
async function jt(t, e, n = {}) {
|
|
1833
|
+
const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await w(t.expr, { context: e, path: r });
|
|
1703
1834
|
switch (t.kind) {
|
|
1704
1835
|
case "const": {
|
|
1705
|
-
if (
|
|
1706
|
-
throw
|
|
1836
|
+
if (i.has(t.name))
|
|
1837
|
+
throw d({
|
|
1707
1838
|
code: "parse_error",
|
|
1708
1839
|
path: r,
|
|
1709
1840
|
details: {
|
|
1710
1841
|
message: `cannot reassign const binding: ${t.name}`
|
|
1711
1842
|
}
|
|
1712
1843
|
});
|
|
1713
|
-
e[t.name] =
|
|
1844
|
+
e[t.name] = s, i.add(t.name);
|
|
1714
1845
|
break;
|
|
1715
1846
|
}
|
|
1716
1847
|
case "let": {
|
|
1717
|
-
e[t.name] =
|
|
1848
|
+
e[t.name] = s;
|
|
1718
1849
|
break;
|
|
1719
1850
|
}
|
|
1720
1851
|
case "assign": {
|
|
1721
|
-
if (
|
|
1722
|
-
throw
|
|
1852
|
+
if (i.has(t.name))
|
|
1853
|
+
throw d({
|
|
1723
1854
|
code: "parse_error",
|
|
1724
1855
|
path: r,
|
|
1725
1856
|
details: {
|
|
@@ -1727,33 +1858,33 @@ async function _t(t, e, n = {}) {
|
|
|
1727
1858
|
}
|
|
1728
1859
|
});
|
|
1729
1860
|
if (!(t.name in e))
|
|
1730
|
-
throw
|
|
1861
|
+
throw d({
|
|
1731
1862
|
code: "parse_error",
|
|
1732
1863
|
path: r,
|
|
1733
1864
|
details: {
|
|
1734
1865
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1735
1866
|
}
|
|
1736
1867
|
});
|
|
1737
|
-
e[t.name] =
|
|
1868
|
+
e[t.name] = s;
|
|
1738
1869
|
break;
|
|
1739
1870
|
}
|
|
1740
1871
|
}
|
|
1741
1872
|
}
|
|
1742
|
-
function
|
|
1873
|
+
function ke(t) {
|
|
1743
1874
|
return !t;
|
|
1744
1875
|
}
|
|
1745
|
-
async function
|
|
1746
|
-
const { path: r, constBindings:
|
|
1876
|
+
async function B(t, e, n = {}) {
|
|
1877
|
+
const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s, echoChunks: o } = n;
|
|
1747
1878
|
switch (t.kind) {
|
|
1748
1879
|
case "const":
|
|
1749
1880
|
case "let":
|
|
1750
1881
|
case "assign": {
|
|
1751
|
-
await
|
|
1882
|
+
await jt(t, e, { path: r, constBindings: i }), s?.(t.name);
|
|
1752
1883
|
return;
|
|
1753
1884
|
}
|
|
1754
1885
|
case "update": {
|
|
1755
|
-
if (
|
|
1756
|
-
throw
|
|
1886
|
+
if (i.has(t.name))
|
|
1887
|
+
throw d({
|
|
1757
1888
|
code: "parse_error",
|
|
1758
1889
|
path: r,
|
|
1759
1890
|
details: {
|
|
@@ -1761,20 +1892,20 @@ async function j(t, e, n = {}) {
|
|
|
1761
1892
|
}
|
|
1762
1893
|
});
|
|
1763
1894
|
if (!(t.name in e))
|
|
1764
|
-
throw
|
|
1895
|
+
throw d({
|
|
1765
1896
|
code: "parse_error",
|
|
1766
1897
|
path: r,
|
|
1767
1898
|
details: {
|
|
1768
1899
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1769
1900
|
}
|
|
1770
1901
|
});
|
|
1771
|
-
const
|
|
1772
|
-
e[t.name] =
|
|
1902
|
+
const a = Number(e[t.name]), c = t.op === "++" ? a + 1 : a - 1;
|
|
1903
|
+
e[t.name] = c, s?.(t.name);
|
|
1773
1904
|
return;
|
|
1774
1905
|
}
|
|
1775
1906
|
case "compound_assign": {
|
|
1776
|
-
if (
|
|
1777
|
-
throw
|
|
1907
|
+
if (i.has(t.name))
|
|
1908
|
+
throw d({
|
|
1778
1909
|
code: "parse_error",
|
|
1779
1910
|
path: r,
|
|
1780
1911
|
details: {
|
|
@@ -1782,66 +1913,74 @@ async function j(t, e, n = {}) {
|
|
|
1782
1913
|
}
|
|
1783
1914
|
});
|
|
1784
1915
|
if (!(t.name in e))
|
|
1785
|
-
throw
|
|
1916
|
+
throw d({
|
|
1786
1917
|
code: "parse_error",
|
|
1787
1918
|
path: r,
|
|
1788
1919
|
details: {
|
|
1789
1920
|
message: `assignment to undeclared variable: ${t.name}`
|
|
1790
1921
|
}
|
|
1791
1922
|
});
|
|
1792
|
-
const
|
|
1793
|
-
let
|
|
1923
|
+
const a = await w(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
|
|
1924
|
+
let l;
|
|
1794
1925
|
switch (t.op) {
|
|
1795
1926
|
case "+=":
|
|
1796
|
-
|
|
1927
|
+
l = c + h;
|
|
1797
1928
|
break;
|
|
1798
1929
|
case "-=":
|
|
1799
|
-
|
|
1930
|
+
l = c - h;
|
|
1800
1931
|
break;
|
|
1801
1932
|
case "*=":
|
|
1802
|
-
|
|
1933
|
+
l = c * h;
|
|
1803
1934
|
break;
|
|
1804
1935
|
case "/=":
|
|
1805
|
-
|
|
1936
|
+
l = c / h;
|
|
1806
1937
|
break;
|
|
1807
1938
|
}
|
|
1808
|
-
e[t.name] =
|
|
1939
|
+
e[t.name] = l, s?.(t.name);
|
|
1940
|
+
return;
|
|
1941
|
+
}
|
|
1942
|
+
case "echo": {
|
|
1943
|
+
const a = await w(t.expr, {
|
|
1944
|
+
context: e,
|
|
1945
|
+
path: r
|
|
1946
|
+
}), c = a == null ? "" : String(a);
|
|
1947
|
+
o?.push(c);
|
|
1809
1948
|
return;
|
|
1810
1949
|
}
|
|
1811
1950
|
case "for": {
|
|
1812
|
-
for (t.init && await
|
|
1813
|
-
const
|
|
1951
|
+
for (t.init && await B(t.init, e, n); ; ) {
|
|
1952
|
+
const a = await w(t.cond, {
|
|
1814
1953
|
context: e,
|
|
1815
1954
|
path: r
|
|
1816
1955
|
});
|
|
1817
|
-
if (
|
|
1956
|
+
if (ke(a))
|
|
1818
1957
|
break;
|
|
1819
|
-
for (const
|
|
1820
|
-
await
|
|
1821
|
-
t.update && await
|
|
1958
|
+
for (const c of t.body)
|
|
1959
|
+
await B(c, e, n);
|
|
1960
|
+
t.update && await B(t.update, e, n);
|
|
1822
1961
|
}
|
|
1823
1962
|
return;
|
|
1824
1963
|
}
|
|
1825
1964
|
case "do_while": {
|
|
1826
1965
|
do {
|
|
1827
|
-
for (const
|
|
1828
|
-
await
|
|
1829
|
-
const
|
|
1966
|
+
for (const c of t.body)
|
|
1967
|
+
await B(c, e, n);
|
|
1968
|
+
const a = await w(t.cond, {
|
|
1830
1969
|
context: e,
|
|
1831
1970
|
path: r
|
|
1832
1971
|
});
|
|
1833
|
-
if (
|
|
1972
|
+
if (ke(a))
|
|
1834
1973
|
break;
|
|
1835
1974
|
} while (!0);
|
|
1836
1975
|
return;
|
|
1837
1976
|
}
|
|
1838
1977
|
}
|
|
1839
1978
|
}
|
|
1840
|
-
async function
|
|
1979
|
+
async function we(t, e, n = {}) {
|
|
1841
1980
|
for (const r of t)
|
|
1842
|
-
await
|
|
1981
|
+
await B(r, e, n);
|
|
1843
1982
|
}
|
|
1844
|
-
const
|
|
1983
|
+
const Pt = /* @__PURE__ */ new Set([
|
|
1845
1984
|
"if",
|
|
1846
1985
|
"else",
|
|
1847
1986
|
"endif",
|
|
@@ -1857,25 +1996,26 @@ const St = /* @__PURE__ */ new Set([
|
|
|
1857
1996
|
"extend",
|
|
1858
1997
|
"include",
|
|
1859
1998
|
"component",
|
|
1860
|
-
"as"
|
|
1999
|
+
"as",
|
|
2000
|
+
"echo"
|
|
1861
2001
|
]);
|
|
1862
|
-
function
|
|
1863
|
-
return
|
|
2002
|
+
function qe(t) {
|
|
2003
|
+
return Pt.has(t);
|
|
1864
2004
|
}
|
|
1865
|
-
function
|
|
2005
|
+
function oe(t) {
|
|
1866
2006
|
let e = "", n = 0, r = null;
|
|
1867
2007
|
for (; n < t.length; ) {
|
|
1868
|
-
const
|
|
2008
|
+
const i = t[n];
|
|
1869
2009
|
if (r) {
|
|
1870
|
-
if (e +=
|
|
2010
|
+
if (e += i, i === "\\" && n + 1 < t.length) {
|
|
1871
2011
|
e += t[++n], n++;
|
|
1872
2012
|
continue;
|
|
1873
2013
|
}
|
|
1874
|
-
|
|
2014
|
+
i === r && (r = null), n++;
|
|
1875
2015
|
continue;
|
|
1876
2016
|
}
|
|
1877
|
-
if (
|
|
1878
|
-
r =
|
|
2017
|
+
if (i === '"' || i === "'" || i === "`") {
|
|
2018
|
+
r = i, e += i, n++;
|
|
1879
2019
|
continue;
|
|
1880
2020
|
}
|
|
1881
2021
|
if (t.startsWith("//", n)) {
|
|
@@ -1885,42 +2025,42 @@ function ie(t) {
|
|
|
1885
2025
|
continue;
|
|
1886
2026
|
}
|
|
1887
2027
|
if (t.startsWith("/*", n)) {
|
|
1888
|
-
const
|
|
1889
|
-
if (
|
|
2028
|
+
const s = t.indexOf("*/", n + 2);
|
|
2029
|
+
if (s === -1)
|
|
1890
2030
|
break;
|
|
1891
|
-
n =
|
|
2031
|
+
n = s + 2;
|
|
1892
2032
|
continue;
|
|
1893
2033
|
}
|
|
1894
|
-
e +=
|
|
2034
|
+
e += i, n++;
|
|
1895
2035
|
}
|
|
1896
2036
|
return e;
|
|
1897
2037
|
}
|
|
1898
2038
|
function k(t, e) {
|
|
1899
|
-
throw
|
|
2039
|
+
throw d({
|
|
1900
2040
|
code: "parse_error",
|
|
1901
2041
|
path: t,
|
|
1902
2042
|
details: { message: e }
|
|
1903
2043
|
});
|
|
1904
2044
|
}
|
|
1905
|
-
function
|
|
1906
|
-
const n =
|
|
2045
|
+
function ve(t, e) {
|
|
2046
|
+
const n = oe(t).trim();
|
|
1907
2047
|
if (n.length === 0)
|
|
1908
2048
|
throw k(e, "empty statement block");
|
|
1909
|
-
const r = new
|
|
2049
|
+
const r = new ae(n, e), i = r.parseStatementList();
|
|
1910
2050
|
if (r.skipWhitespace(), r.hasMore())
|
|
1911
2051
|
throw k(
|
|
1912
2052
|
e,
|
|
1913
2053
|
`unexpected token at position ${r.position}`
|
|
1914
2054
|
);
|
|
1915
|
-
if (
|
|
2055
|
+
if (i.length === 0)
|
|
1916
2056
|
throw k(e, "empty statement block");
|
|
1917
|
-
return
|
|
2057
|
+
return i;
|
|
1918
2058
|
}
|
|
1919
|
-
function
|
|
1920
|
-
const e =
|
|
1921
|
-
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^for\s*\(/.test(e) || /^do\b/.test(e) || /^(\+\+|--)/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*(\+\+|--|[+\-*/]=|=)/.test(e);
|
|
2059
|
+
function Ve(t) {
|
|
2060
|
+
const e = oe(t).trim();
|
|
2061
|
+
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^echo\b/.test(e) || /^for\s*\(/.test(e) || /^do\b/.test(e) || /^(\+\+|--)/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*(\+\+|--|[+\-*/]=|=)/.test(e);
|
|
1922
2062
|
}
|
|
1923
|
-
class
|
|
2063
|
+
class ae {
|
|
1924
2064
|
constructor(e, n) {
|
|
1925
2065
|
this.input = e, this.path = n;
|
|
1926
2066
|
}
|
|
@@ -1953,7 +2093,7 @@ class se {
|
|
|
1953
2093
|
this.path,
|
|
1954
2094
|
"bare while loops are not allowed (use do…while)"
|
|
1955
2095
|
);
|
|
1956
|
-
return this.parseSimpleStatement();
|
|
2096
|
+
return this.matchWord("echo") ? this.parseEcho() : this.parseSimpleStatement();
|
|
1957
2097
|
}
|
|
1958
2098
|
parseSimpleStatement() {
|
|
1959
2099
|
this.skipWhitespace();
|
|
@@ -1968,31 +2108,39 @@ class se {
|
|
|
1968
2108
|
if (!n)
|
|
1969
2109
|
throw k(this.path, "expected statement");
|
|
1970
2110
|
if (this.assertAssignableName(n), this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
1971
|
-
const
|
|
1972
|
-
return { kind: "update", name: n, op:
|
|
2111
|
+
const i = this.input.slice(this.index - 2, this.index);
|
|
2112
|
+
return { kind: "update", name: n, op: i, position: "postfix" };
|
|
1973
2113
|
}
|
|
1974
2114
|
const r = this.readCompoundOp();
|
|
1975
2115
|
if (r) {
|
|
1976
|
-
const
|
|
2116
|
+
const i = this.readExpressionSourceUntilTerminator();
|
|
1977
2117
|
return {
|
|
1978
2118
|
kind: "compound_assign",
|
|
1979
2119
|
name: n,
|
|
1980
2120
|
op: r,
|
|
1981
|
-
expr:
|
|
2121
|
+
expr: W(i, this.path)
|
|
1982
2122
|
};
|
|
1983
2123
|
}
|
|
1984
2124
|
if (this.match("=")) {
|
|
1985
2125
|
if (this.peek() === "=")
|
|
1986
2126
|
throw k(this.path, "unexpected '==' in assignment");
|
|
1987
|
-
const
|
|
2127
|
+
const i = this.readExpressionSourceUntilTerminator();
|
|
1988
2128
|
return {
|
|
1989
2129
|
kind: "assign",
|
|
1990
2130
|
name: n,
|
|
1991
|
-
expr:
|
|
2131
|
+
expr: W(i, this.path)
|
|
1992
2132
|
};
|
|
1993
2133
|
}
|
|
1994
2134
|
throw k(this.path, `invalid statement starting with: ${n}`);
|
|
1995
2135
|
}
|
|
2136
|
+
parseEcho() {
|
|
2137
|
+
this.skipWhitespace();
|
|
2138
|
+
const e = this.readExpressionSourceUntilTerminator();
|
|
2139
|
+
return {
|
|
2140
|
+
kind: "echo",
|
|
2141
|
+
expr: W(e, this.path)
|
|
2142
|
+
};
|
|
2143
|
+
}
|
|
1996
2144
|
readPrefixUpdate() {
|
|
1997
2145
|
if (this.skipWhitespace(), this.match("++") || this.match("--")) {
|
|
1998
2146
|
const e = this.input.slice(this.index - 2, this.index), n = this.readIdentifier();
|
|
@@ -2012,27 +2160,27 @@ class se {
|
|
|
2012
2160
|
return {
|
|
2013
2161
|
kind: e,
|
|
2014
2162
|
name: n,
|
|
2015
|
-
expr:
|
|
2163
|
+
expr: W(r, this.path)
|
|
2016
2164
|
};
|
|
2017
2165
|
}
|
|
2018
2166
|
parseFor() {
|
|
2019
2167
|
if (this.skipWhitespace(), !this.match("("))
|
|
2020
2168
|
throw k(this.path, "expected '(' after for");
|
|
2021
|
-
const e = this.readBalanced(")"), n =
|
|
2169
|
+
const e = this.readBalanced(")"), n = It(e);
|
|
2022
2170
|
if (n.length !== 3)
|
|
2023
2171
|
throw k(
|
|
2024
2172
|
this.path,
|
|
2025
2173
|
"for…of / for…in are not allowed; use for (init; cond; update)"
|
|
2026
2174
|
);
|
|
2027
|
-
const [r,
|
|
2028
|
-
if (
|
|
2175
|
+
const [r, i, s] = n;
|
|
2176
|
+
if (i.trim().length === 0)
|
|
2029
2177
|
throw k(this.path, "for loop condition cannot be empty");
|
|
2030
2178
|
if (/^\s*[A-Za-z_$][A-Za-z0-9_$]*\s+(of|in)\s+/.test(r))
|
|
2031
2179
|
throw k(
|
|
2032
2180
|
this.path,
|
|
2033
2181
|
"for…of / for…in are not allowed; use for (init; cond; update)"
|
|
2034
2182
|
);
|
|
2035
|
-
const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a =
|
|
2183
|
+
const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a = W(i.trim(), this.path), c = s.trim().length === 0 ? null : this.parseClauseStatement(s.trim());
|
|
2036
2184
|
if (this.skipWhitespace(), !this.match("{"))
|
|
2037
2185
|
throw k(this.path, "expected '{' after for (...)");
|
|
2038
2186
|
const h = this.parseStatementList();
|
|
@@ -2053,11 +2201,11 @@ class se {
|
|
|
2053
2201
|
const n = this.readBalanced(")");
|
|
2054
2202
|
if (n.trim().length === 0)
|
|
2055
2203
|
throw k(this.path, "do…while condition cannot be empty");
|
|
2056
|
-
const r =
|
|
2204
|
+
const r = W(n.trim(), this.path);
|
|
2057
2205
|
return { kind: "do_while", body: e, cond: r };
|
|
2058
2206
|
}
|
|
2059
2207
|
parseClauseStatement(e) {
|
|
2060
|
-
const n = new
|
|
2208
|
+
const n = new ae(e, this.path), r = n.parseSimpleStatement();
|
|
2061
2209
|
if (n.skipWhitespace(), n.hasMore())
|
|
2062
2210
|
throw k(
|
|
2063
2211
|
this.path,
|
|
@@ -2066,7 +2214,7 @@ class se {
|
|
|
2066
2214
|
return r;
|
|
2067
2215
|
}
|
|
2068
2216
|
assertAssignableName(e) {
|
|
2069
|
-
if (
|
|
2217
|
+
if (qe(e))
|
|
2070
2218
|
throw k(
|
|
2071
2219
|
this.path,
|
|
2072
2220
|
`reserved word cannot be used as identifier: ${e}`
|
|
@@ -2075,28 +2223,28 @@ class se {
|
|
|
2075
2223
|
readExpressionSourceUntilTerminator() {
|
|
2076
2224
|
this.skipWhitespace();
|
|
2077
2225
|
const e = this.index;
|
|
2078
|
-
let n = 0, r = 0,
|
|
2226
|
+
let n = 0, r = 0, i = 0, s = null;
|
|
2079
2227
|
for (; this.index < this.input.length; ) {
|
|
2080
2228
|
const a = this.input[this.index];
|
|
2081
|
-
if (
|
|
2229
|
+
if (s) {
|
|
2082
2230
|
if (a === "\\") {
|
|
2083
2231
|
this.index += 2;
|
|
2084
2232
|
continue;
|
|
2085
2233
|
}
|
|
2086
|
-
a ===
|
|
2234
|
+
a === s && (s = null), this.index++;
|
|
2087
2235
|
continue;
|
|
2088
2236
|
}
|
|
2089
2237
|
if (a === '"' || a === "'" || a === "`") {
|
|
2090
|
-
|
|
2238
|
+
s = a, this.index++;
|
|
2091
2239
|
continue;
|
|
2092
2240
|
}
|
|
2093
2241
|
if (a === "(" && n++, a === ")" && (n = Math.max(0, n - 1)), a === "{" && r++, a === "}") {
|
|
2094
|
-
if (r === 0 && n === 0 &&
|
|
2242
|
+
if (r === 0 && n === 0 && i === 0)
|
|
2095
2243
|
break;
|
|
2096
2244
|
r = Math.max(0, r - 1);
|
|
2097
2245
|
}
|
|
2098
|
-
if (a === "[" &&
|
|
2099
|
-
`) && n === 0 && r === 0 &&
|
|
2246
|
+
if (a === "[" && i++, a === "]" && (i = Math.max(0, i - 1)), (a === ";" || a === `
|
|
2247
|
+
`) && n === 0 && r === 0 && i === 0)
|
|
2100
2248
|
break;
|
|
2101
2249
|
this.index++;
|
|
2102
2250
|
}
|
|
@@ -2108,20 +2256,20 @@ class se {
|
|
|
2108
2256
|
readBalanced(e) {
|
|
2109
2257
|
const n = e === ")" ? "(" : "{";
|
|
2110
2258
|
let r = 1;
|
|
2111
|
-
const
|
|
2112
|
-
let
|
|
2259
|
+
const i = this.index;
|
|
2260
|
+
let s = null;
|
|
2113
2261
|
for (; this.index < this.input.length; ) {
|
|
2114
2262
|
const o = this.input[this.index];
|
|
2115
|
-
if (
|
|
2263
|
+
if (s) {
|
|
2116
2264
|
if (o === "\\") {
|
|
2117
2265
|
this.index += 2;
|
|
2118
2266
|
continue;
|
|
2119
2267
|
}
|
|
2120
|
-
o ===
|
|
2268
|
+
o === s && (s = null), this.index++;
|
|
2121
2269
|
continue;
|
|
2122
2270
|
}
|
|
2123
2271
|
if (o === '"' || o === "'" || o === "`") {
|
|
2124
|
-
|
|
2272
|
+
s = o, this.index++;
|
|
2125
2273
|
continue;
|
|
2126
2274
|
}
|
|
2127
2275
|
if (o === n) {
|
|
@@ -2130,7 +2278,7 @@ class se {
|
|
|
2130
2278
|
}
|
|
2131
2279
|
if (o === e) {
|
|
2132
2280
|
if (r--, r === 0) {
|
|
2133
|
-
const a = this.input.slice(
|
|
2281
|
+
const a = this.input.slice(i, this.index);
|
|
2134
2282
|
return this.index++, a;
|
|
2135
2283
|
}
|
|
2136
2284
|
this.index++;
|
|
@@ -2173,21 +2321,21 @@ class se {
|
|
|
2173
2321
|
return this.input.slice(e, this.index);
|
|
2174
2322
|
}
|
|
2175
2323
|
}
|
|
2176
|
-
function
|
|
2324
|
+
function It(t) {
|
|
2177
2325
|
const e = [];
|
|
2178
|
-
let n = "", r = 0,
|
|
2179
|
-
for (let
|
|
2180
|
-
const o = t[
|
|
2181
|
-
if (
|
|
2182
|
-
if (n += o, o === "\\" &&
|
|
2183
|
-
n += t[++
|
|
2326
|
+
let n = "", r = 0, i = null;
|
|
2327
|
+
for (let s = 0; s < t.length; s++) {
|
|
2328
|
+
const o = t[s];
|
|
2329
|
+
if (i) {
|
|
2330
|
+
if (n += o, o === "\\" && s + 1 < t.length) {
|
|
2331
|
+
n += t[++s];
|
|
2184
2332
|
continue;
|
|
2185
2333
|
}
|
|
2186
|
-
o ===
|
|
2334
|
+
o === i && (i = null);
|
|
2187
2335
|
continue;
|
|
2188
2336
|
}
|
|
2189
2337
|
if (o === '"' || o === "'" || o === "`") {
|
|
2190
|
-
|
|
2338
|
+
i = o, n += o;
|
|
2191
2339
|
continue;
|
|
2192
2340
|
}
|
|
2193
2341
|
if (o === "(" || o === "[" || o === "{") {
|
|
@@ -2206,146 +2354,185 @@ function Ct(t) {
|
|
|
2206
2354
|
}
|
|
2207
2355
|
return e.push(n), e;
|
|
2208
2356
|
}
|
|
2209
|
-
function
|
|
2357
|
+
function ce(t, e) {
|
|
2210
2358
|
const n = t.trim();
|
|
2211
2359
|
if (!/^extend\b/i.test(n)) return null;
|
|
2212
2360
|
if (!/^extend\s+/i.test(n))
|
|
2213
|
-
throw
|
|
2361
|
+
throw d({
|
|
2214
2362
|
code: "parse_error",
|
|
2215
2363
|
path: e,
|
|
2216
2364
|
details: { message: "missing extend path" }
|
|
2217
2365
|
});
|
|
2218
2366
|
const r = /^extend\s+(\S+)\s*$/.exec(n);
|
|
2219
2367
|
if (!r)
|
|
2220
|
-
throw
|
|
2368
|
+
throw d({
|
|
2221
2369
|
code: "parse_error",
|
|
2222
2370
|
path: e,
|
|
2223
2371
|
details: { message: "invalid extend directive" }
|
|
2224
2372
|
});
|
|
2225
|
-
const
|
|
2226
|
-
if (
|
|
2227
|
-
throw
|
|
2373
|
+
const i = r[1];
|
|
2374
|
+
if (i.length === 0)
|
|
2375
|
+
throw d({
|
|
2228
2376
|
code: "parse_error",
|
|
2229
2377
|
path: e,
|
|
2230
2378
|
details: { message: "invalid extend path" }
|
|
2231
2379
|
});
|
|
2232
|
-
return { path:
|
|
2380
|
+
return { path: i };
|
|
2233
2381
|
}
|
|
2234
|
-
function
|
|
2235
|
-
const n =
|
|
2382
|
+
function zt(t, e) {
|
|
2383
|
+
const n = A(t);
|
|
2236
2384
|
if (n.length === 0) return null;
|
|
2237
|
-
const r = n[0],
|
|
2238
|
-
if (!
|
|
2239
|
-
for (const
|
|
2240
|
-
if (/^extend\s+/i.test(
|
|
2241
|
-
throw
|
|
2385
|
+
const r = n[0], i = ce(r, e);
|
|
2386
|
+
if (!i) return null;
|
|
2387
|
+
for (const s of n.slice(1))
|
|
2388
|
+
if (/^extend\s+/i.test(s))
|
|
2389
|
+
throw d({
|
|
2242
2390
|
code: "parse_error",
|
|
2243
2391
|
path: e,
|
|
2244
2392
|
details: { message: "extend must be the first line of extend block" }
|
|
2245
2393
|
});
|
|
2246
2394
|
return {
|
|
2247
|
-
path:
|
|
2395
|
+
path: i.path,
|
|
2248
2396
|
declarationsSource: n.slice(1).join(`
|
|
2249
2397
|
`)
|
|
2250
2398
|
};
|
|
2251
2399
|
}
|
|
2252
|
-
|
|
2400
|
+
function le(t) {
|
|
2401
|
+
return /^toc(\(.*\))?$/.test(t.trim());
|
|
2402
|
+
}
|
|
2403
|
+
function Ut(t, e) {
|
|
2404
|
+
const n = A(t);
|
|
2405
|
+
if (n.length !== 1)
|
|
2406
|
+
throw d({
|
|
2407
|
+
code: "parse_error",
|
|
2408
|
+
path: e,
|
|
2409
|
+
details: {
|
|
2410
|
+
message: "toc directive must be a single line"
|
|
2411
|
+
}
|
|
2412
|
+
});
|
|
2413
|
+
const r = n[0];
|
|
2414
|
+
if (r === "toc")
|
|
2415
|
+
return { maxLevel: 6 };
|
|
2416
|
+
const i = /^toc\((.*)\)$/.exec(r);
|
|
2417
|
+
if (!i)
|
|
2418
|
+
throw d({
|
|
2419
|
+
code: "parse_error",
|
|
2420
|
+
path: e,
|
|
2421
|
+
details: { message: `invalid toc directive: ${r}` }
|
|
2422
|
+
});
|
|
2423
|
+
const s = i[1];
|
|
2424
|
+
if (!/^[1-6]$/.test(s))
|
|
2425
|
+
throw d({
|
|
2426
|
+
code: "parse_error",
|
|
2427
|
+
path: e,
|
|
2428
|
+
details: {
|
|
2429
|
+
message: `invalid toc max level: ${s || "(empty)"} (expected integer 1–6)`
|
|
2430
|
+
}
|
|
2431
|
+
});
|
|
2432
|
+
return { maxLevel: Number(s) };
|
|
2433
|
+
}
|
|
2434
|
+
async function Zt(t, e = {}) {
|
|
2253
2435
|
const n = e.path, r = e.context ?? {};
|
|
2254
|
-
if (
|
|
2255
|
-
throw
|
|
2436
|
+
if (Be(t))
|
|
2437
|
+
throw d({
|
|
2256
2438
|
code: "parse_error",
|
|
2257
2439
|
path: n,
|
|
2258
2440
|
details: {
|
|
2259
|
-
message:
|
|
2441
|
+
message: Fe(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2260
2442
|
}
|
|
2261
2443
|
});
|
|
2262
|
-
const
|
|
2263
|
-
if (
|
|
2444
|
+
const i = E(t);
|
|
2445
|
+
if (i.length === 0)
|
|
2264
2446
|
return { source: t, context: r, declarationUpdates: {} };
|
|
2265
|
-
const
|
|
2447
|
+
const s = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
|
|
2266
2448
|
o[l] = r[l];
|
|
2267
2449
|
};
|
|
2268
2450
|
let c = t, h = 0;
|
|
2269
|
-
for (const l of
|
|
2270
|
-
const
|
|
2271
|
-
if (
|
|
2451
|
+
for (const l of i) {
|
|
2452
|
+
const u = A(l.inner);
|
|
2453
|
+
if (u.length === 1 && je(u[0]) || u.length === 1 && le(u[0]) || u.length === 1 && /^include\s+/i.test(u[0]) || u.length === 1 && /^component\s+/i.test(u[0]))
|
|
2272
2454
|
continue;
|
|
2273
|
-
const f =
|
|
2455
|
+
const f = zt(l.inner, n);
|
|
2274
2456
|
if (f) {
|
|
2275
2457
|
if (f.declarationsSource.trim().length > 0) {
|
|
2276
|
-
const
|
|
2458
|
+
const N = ve(
|
|
2277
2459
|
f.declarationsSource,
|
|
2278
2460
|
n
|
|
2279
2461
|
);
|
|
2280
|
-
await
|
|
2462
|
+
await we(N, r, {
|
|
2281
2463
|
path: n,
|
|
2282
|
-
constBindings:
|
|
2464
|
+
constBindings: s,
|
|
2283
2465
|
onUpdate: a
|
|
2284
2466
|
});
|
|
2285
2467
|
}
|
|
2286
|
-
const
|
|
2468
|
+
const C = l.start - h, L = l.end - h, j = `<!--@hg
|
|
2287
2469
|
extend ${f.path}
|
|
2288
2470
|
@endhg-->`;
|
|
2289
|
-
c = c.slice(0,
|
|
2471
|
+
c = c.slice(0, C) + j + c.slice(L), h += l.raw.length - j.length;
|
|
2290
2472
|
continue;
|
|
2291
2473
|
}
|
|
2292
|
-
const g =
|
|
2474
|
+
const g = u.join(`
|
|
2293
2475
|
`);
|
|
2294
|
-
if (!
|
|
2295
|
-
if (
|
|
2476
|
+
if (!Ve(g)) {
|
|
2477
|
+
if (u.length === 1)
|
|
2296
2478
|
continue;
|
|
2297
|
-
throw
|
|
2479
|
+
throw d({
|
|
2298
2480
|
code: "parse_error",
|
|
2299
2481
|
path: n,
|
|
2300
|
-
details: { message: `unsupported hyogen directive: ${
|
|
2482
|
+
details: { message: `unsupported hyogen directive: ${u[0]}` }
|
|
2301
2483
|
});
|
|
2302
2484
|
}
|
|
2303
|
-
const m =
|
|
2304
|
-
await
|
|
2485
|
+
const m = ve(g, n), p = [];
|
|
2486
|
+
await we(m, r, {
|
|
2305
2487
|
path: n,
|
|
2306
|
-
constBindings:
|
|
2307
|
-
onUpdate: a
|
|
2488
|
+
constBindings: s,
|
|
2489
|
+
onUpdate: a,
|
|
2490
|
+
echoChunks: p
|
|
2308
2491
|
});
|
|
2309
|
-
const
|
|
2310
|
-
|
|
2492
|
+
const S = l.start - h, D = l.end - h, v = c.slice(0, S), b = c.slice(D);
|
|
2493
|
+
if (p.length > 0) {
|
|
2494
|
+
const C = p.join("");
|
|
2495
|
+
c = v + C + b, h += l.raw.length - C.length;
|
|
2496
|
+
} else
|
|
2497
|
+
c = T(v, b), h += l.raw.length + se(v, b);
|
|
2311
2498
|
}
|
|
2312
2499
|
return { source: c, context: r, declarationUpdates: o };
|
|
2313
2500
|
}
|
|
2314
|
-
const
|
|
2315
|
-
function
|
|
2316
|
-
const n =
|
|
2501
|
+
const qt = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
|
|
2502
|
+
function Vt(t, e) {
|
|
2503
|
+
const n = te(t).trim();
|
|
2317
2504
|
if (n.length === 0)
|
|
2318
|
-
throw
|
|
2505
|
+
throw d({
|
|
2319
2506
|
code: "parse_error",
|
|
2320
2507
|
path: e,
|
|
2321
2508
|
details: { message: "empty hyogen block" }
|
|
2322
2509
|
});
|
|
2323
2510
|
const r = n.split(/\r?\n/).map((a) => a.trim()).filter((a) => a.length > 0);
|
|
2324
2511
|
if (r.length !== 1)
|
|
2325
|
-
throw
|
|
2512
|
+
throw d({
|
|
2326
2513
|
code: "parse_error",
|
|
2327
2514
|
path: e,
|
|
2328
2515
|
details: {
|
|
2329
2516
|
message: "hyogen block must contain a single component directive"
|
|
2330
2517
|
}
|
|
2331
2518
|
});
|
|
2332
|
-
const
|
|
2333
|
-
if (/^include\s+/i.test(
|
|
2334
|
-
throw
|
|
2519
|
+
const i = r[0];
|
|
2520
|
+
if (/^include\s+/i.test(i))
|
|
2521
|
+
throw d({
|
|
2335
2522
|
code: "parse_error",
|
|
2336
2523
|
path: e,
|
|
2337
2524
|
details: { message: "include and component cannot coexist in one block" }
|
|
2338
2525
|
});
|
|
2339
|
-
const
|
|
2340
|
-
if (!
|
|
2341
|
-
throw
|
|
2526
|
+
const s = qt.exec(i);
|
|
2527
|
+
if (!s)
|
|
2528
|
+
throw d({
|
|
2342
2529
|
code: "parse_error",
|
|
2343
2530
|
path: e,
|
|
2344
|
-
details: { message: `unsupported component directive: ${
|
|
2531
|
+
details: { message: `unsupported component directive: ${i}` }
|
|
2345
2532
|
});
|
|
2346
|
-
const o =
|
|
2533
|
+
const o = s[1];
|
|
2347
2534
|
if (o.length === 0)
|
|
2348
|
-
throw
|
|
2535
|
+
throw d({
|
|
2349
2536
|
code: "parse_error",
|
|
2350
2537
|
path: e,
|
|
2351
2538
|
details: { message: "empty component path" }
|
|
@@ -2353,92 +2540,92 @@ function Tt(t, e) {
|
|
|
2353
2540
|
return {
|
|
2354
2541
|
kind: "component",
|
|
2355
2542
|
path: o,
|
|
2356
|
-
alias:
|
|
2543
|
+
alias: s[2]
|
|
2357
2544
|
};
|
|
2358
2545
|
}
|
|
2359
|
-
function
|
|
2360
|
-
const n =
|
|
2546
|
+
function Kt(t, e) {
|
|
2547
|
+
const n = te(t).trim();
|
|
2361
2548
|
if (n.length === 0)
|
|
2362
|
-
throw
|
|
2549
|
+
throw d({
|
|
2363
2550
|
code: "parse_error",
|
|
2364
2551
|
path: e,
|
|
2365
2552
|
details: { message: "empty hyogen block" }
|
|
2366
2553
|
});
|
|
2367
2554
|
const r = n.split(/\r?\n/).map((o) => o.trim()).filter((o) => o.length > 0);
|
|
2368
2555
|
if (r.length !== 1)
|
|
2369
|
-
throw
|
|
2556
|
+
throw d({
|
|
2370
2557
|
code: "parse_error",
|
|
2371
2558
|
path: e,
|
|
2372
2559
|
details: { message: "hyogen block must contain a single include directive" }
|
|
2373
2560
|
});
|
|
2374
|
-
const
|
|
2375
|
-
if (
|
|
2376
|
-
return { kind: "include", path:
|
|
2377
|
-
throw
|
|
2561
|
+
const i = r[0], s = /^include\s+(\S+)\s*$/.exec(i);
|
|
2562
|
+
if (s)
|
|
2563
|
+
return { kind: "include", path: s[1] };
|
|
2564
|
+
throw d({
|
|
2378
2565
|
code: "parse_error",
|
|
2379
2566
|
path: e,
|
|
2380
|
-
details: { message: `unsupported hyogen directive: ${
|
|
2567
|
+
details: { message: `unsupported hyogen directive: ${i}` }
|
|
2381
2568
|
});
|
|
2382
2569
|
}
|
|
2383
|
-
function
|
|
2384
|
-
const e =
|
|
2570
|
+
function Yt(t) {
|
|
2571
|
+
const e = oe(t).trim();
|
|
2385
2572
|
return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
|
|
2386
2573
|
}
|
|
2387
|
-
const
|
|
2388
|
-
function
|
|
2389
|
-
return `${
|
|
2574
|
+
const Xt = "\0HYOGEN_INCLUDE_";
|
|
2575
|
+
function Gt(t) {
|
|
2576
|
+
return `${Xt}${t}\0`;
|
|
2390
2577
|
}
|
|
2391
|
-
function
|
|
2392
|
-
const n =
|
|
2393
|
-
if (n.length === 1 &&
|
|
2578
|
+
function Jt(t, e) {
|
|
2579
|
+
const n = A(t);
|
|
2580
|
+
if (n.length === 1 && je(n[0]))
|
|
2394
2581
|
return { kind: "control" };
|
|
2395
|
-
if (n.length === 1 && (
|
|
2582
|
+
if (n.length === 1 && le(n[0]) || n.length === 1 && (Yt(n[0]) || Ve(n[0])))
|
|
2396
2583
|
return null;
|
|
2397
2584
|
if (n.length !== 1)
|
|
2398
|
-
throw
|
|
2585
|
+
throw d({
|
|
2399
2586
|
code: "parse_error",
|
|
2400
2587
|
path: e,
|
|
2401
2588
|
details: { message: "hyogen block must contain a single directive" }
|
|
2402
2589
|
});
|
|
2403
2590
|
const r = n[0];
|
|
2404
2591
|
if (/^include\s+/i.test(r) && /\bcomponent\s+/i.test(r))
|
|
2405
|
-
throw
|
|
2592
|
+
throw d({
|
|
2406
2593
|
code: "parse_error",
|
|
2407
2594
|
path: e,
|
|
2408
2595
|
details: { message: "include and component cannot coexist in one block" }
|
|
2409
2596
|
});
|
|
2410
2597
|
if (/^include\s+/i.test(r))
|
|
2411
|
-
return
|
|
2598
|
+
return Kt(t, e);
|
|
2412
2599
|
if (/^component\s+/i.test(r))
|
|
2413
|
-
return
|
|
2600
|
+
return Vt(t, e);
|
|
2414
2601
|
if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
|
|
2415
2602
|
return null;
|
|
2416
|
-
throw
|
|
2603
|
+
throw d({
|
|
2417
2604
|
code: "parse_error",
|
|
2418
2605
|
path: e,
|
|
2419
2606
|
details: { message: `unsupported hyogen directive: ${r}` }
|
|
2420
2607
|
});
|
|
2421
2608
|
}
|
|
2422
|
-
function
|
|
2609
|
+
function Qt(t, e = {}) {
|
|
2423
2610
|
const n = e.path;
|
|
2424
|
-
if (
|
|
2425
|
-
throw
|
|
2611
|
+
if (Be(t))
|
|
2612
|
+
throw d({
|
|
2426
2613
|
code: "parse_error",
|
|
2427
2614
|
path: n,
|
|
2428
2615
|
details: {
|
|
2429
|
-
message:
|
|
2616
|
+
message: Fe(t) ?? "unclosed hyogen block (missing closing marker)"
|
|
2430
2617
|
}
|
|
2431
2618
|
});
|
|
2432
|
-
const r =
|
|
2619
|
+
const r = E(t);
|
|
2433
2620
|
if (r.length === 0)
|
|
2434
2621
|
return { source: t, directives: [] };
|
|
2435
|
-
const
|
|
2436
|
-
let
|
|
2622
|
+
const i = [];
|
|
2623
|
+
let s = t, o = 0, a = 0;
|
|
2437
2624
|
for (const c of r) {
|
|
2438
|
-
const h =
|
|
2625
|
+
const h = Jt(c.inner, n);
|
|
2439
2626
|
if (!h || h.kind === "control")
|
|
2440
2627
|
continue;
|
|
2441
|
-
const l = c.start - o,
|
|
2628
|
+
const l = c.start - o, u = c.end - o;
|
|
2442
2629
|
if (h.kind === "component") {
|
|
2443
2630
|
e.registry && e.registry.register(
|
|
2444
2631
|
{
|
|
@@ -2449,74 +2636,74 @@ function Dt(t, e = {}) {
|
|
|
2449
2636
|
Object.keys(e.context ?? {}),
|
|
2450
2637
|
n
|
|
2451
2638
|
);
|
|
2452
|
-
const g =
|
|
2453
|
-
|
|
2639
|
+
const g = s.slice(0, l), m = s.slice(u);
|
|
2640
|
+
s = T(g, m), o += c.raw.length + se(g, m);
|
|
2454
2641
|
continue;
|
|
2455
2642
|
}
|
|
2456
|
-
const f =
|
|
2457
|
-
|
|
2643
|
+
const f = Gt(a++);
|
|
2644
|
+
i.push({ ...h, marker: f, raw: c.raw }), s = s.slice(0, l) + f + s.slice(u), o += c.raw.length - f.length;
|
|
2458
2645
|
}
|
|
2459
|
-
return { source:
|
|
2646
|
+
return { source: s, directives: i };
|
|
2460
2647
|
}
|
|
2461
|
-
function
|
|
2648
|
+
function en(t, e) {
|
|
2462
2649
|
return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
|
|
2463
2650
|
` : `${e.rawFrontMatter}
|
|
2464
2651
|
${t}`;
|
|
2465
2652
|
}
|
|
2466
|
-
function
|
|
2653
|
+
function tn(t, e = !1) {
|
|
2467
2654
|
if (e)
|
|
2468
2655
|
return t;
|
|
2469
|
-
const n =
|
|
2656
|
+
const n = E(t);
|
|
2470
2657
|
if (n.length === 0)
|
|
2471
2658
|
return t;
|
|
2472
|
-
let r = t,
|
|
2473
|
-
for (const
|
|
2474
|
-
const o =
|
|
2475
|
-
r =
|
|
2659
|
+
let r = t, i = 0;
|
|
2660
|
+
for (const s of n) {
|
|
2661
|
+
const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
|
|
2662
|
+
r = T(c, h), i += s.raw.length + se(c, h);
|
|
2476
2663
|
}
|
|
2477
2664
|
return r;
|
|
2478
2665
|
}
|
|
2479
|
-
const
|
|
2480
|
-
function
|
|
2666
|
+
const nn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
2667
|
+
function rn(t, e) {
|
|
2481
2668
|
const n = t.trim();
|
|
2482
2669
|
if (n === "endblock")
|
|
2483
2670
|
return { kind: "endblock" };
|
|
2484
|
-
const r =
|
|
2671
|
+
const r = nn.exec(n);
|
|
2485
2672
|
if (!r)
|
|
2486
|
-
throw
|
|
2673
|
+
throw d({
|
|
2487
2674
|
code: "parse_error",
|
|
2488
2675
|
path: e,
|
|
2489
2676
|
details: { message: "invalid block directive" }
|
|
2490
2677
|
});
|
|
2491
|
-
const
|
|
2492
|
-
if (
|
|
2493
|
-
throw
|
|
2678
|
+
const i = r[1];
|
|
2679
|
+
if (qe(i))
|
|
2680
|
+
throw d({
|
|
2494
2681
|
code: "parse_error",
|
|
2495
2682
|
path: e,
|
|
2496
|
-
details: { message: `reserved word cannot be used as block name: ${
|
|
2683
|
+
details: { message: `reserved word cannot be used as block name: ${i}` }
|
|
2497
2684
|
});
|
|
2498
|
-
return { kind: "block", name:
|
|
2685
|
+
return { kind: "block", name: i };
|
|
2499
2686
|
}
|
|
2500
|
-
function
|
|
2501
|
-
const { path: n, mode: r, hasExtend:
|
|
2502
|
-
if (
|
|
2687
|
+
function be(t, e) {
|
|
2688
|
+
const { path: n, mode: r, hasExtend: i = !1 } = e, s = E(t);
|
|
2689
|
+
if (s.length === 0) return [];
|
|
2503
2690
|
const o = [], a = [], c = /* @__PURE__ */ new Set();
|
|
2504
|
-
for (const h of
|
|
2505
|
-
const l =
|
|
2691
|
+
for (const h of s) {
|
|
2692
|
+
const l = A(h.inner);
|
|
2506
2693
|
if (l.length !== 1) continue;
|
|
2507
|
-
const
|
|
2508
|
-
if (!(
|
|
2509
|
-
if (r === "child" && !
|
|
2510
|
-
throw
|
|
2694
|
+
const u = l[0];
|
|
2695
|
+
if (!(u === "endblock" || u.startsWith("block "))) continue;
|
|
2696
|
+
if (r === "child" && !i)
|
|
2697
|
+
throw d({
|
|
2511
2698
|
code: "parse_error",
|
|
2512
2699
|
path: n,
|
|
2513
2700
|
details: { message: "orphan block without extend" }
|
|
2514
2701
|
});
|
|
2515
|
-
const g =
|
|
2702
|
+
const g = rn(u, n);
|
|
2516
2703
|
if (g.kind === "endblock") {
|
|
2517
2704
|
const m = a.pop();
|
|
2518
2705
|
if (!m)
|
|
2519
|
-
throw
|
|
2706
|
+
throw d({
|
|
2520
2707
|
code: "parse_error",
|
|
2521
2708
|
path: n,
|
|
2522
2709
|
details: { message: "endblock without matching block opener" }
|
|
@@ -2531,13 +2718,13 @@ function xe(t, e) {
|
|
|
2531
2718
|
continue;
|
|
2532
2719
|
}
|
|
2533
2720
|
if (a.length > 0)
|
|
2534
|
-
throw
|
|
2721
|
+
throw d({
|
|
2535
2722
|
code: "parse_error",
|
|
2536
2723
|
path: n,
|
|
2537
2724
|
details: { message: "nested block structures are not supported" }
|
|
2538
2725
|
});
|
|
2539
2726
|
if (c.has(g.name))
|
|
2540
|
-
throw
|
|
2727
|
+
throw d({
|
|
2541
2728
|
code: "parse_error",
|
|
2542
2729
|
path: n,
|
|
2543
2730
|
details: { message: `duplicate block: ${g.name}` }
|
|
@@ -2549,44 +2736,44 @@ function xe(t, e) {
|
|
|
2549
2736
|
});
|
|
2550
2737
|
}
|
|
2551
2738
|
if (a.length > 0)
|
|
2552
|
-
throw
|
|
2739
|
+
throw d({
|
|
2553
2740
|
code: "parse_error",
|
|
2554
2741
|
path: n,
|
|
2555
2742
|
details: { message: "missing endblock" }
|
|
2556
2743
|
});
|
|
2557
2744
|
return o;
|
|
2558
2745
|
}
|
|
2559
|
-
function
|
|
2560
|
-
const e =
|
|
2746
|
+
function ye(t) {
|
|
2747
|
+
const e = E(t), n = [];
|
|
2561
2748
|
for (const r of e) {
|
|
2562
|
-
const
|
|
2563
|
-
if (
|
|
2564
|
-
const
|
|
2565
|
-
|
|
2749
|
+
const i = A(r.inner);
|
|
2750
|
+
if (i.length === 0) continue;
|
|
2751
|
+
const s = ce(i[0]);
|
|
2752
|
+
s && n.push({ path: s.path, start: r.start });
|
|
2566
2753
|
}
|
|
2567
2754
|
return n;
|
|
2568
2755
|
}
|
|
2569
|
-
function
|
|
2570
|
-
const e =
|
|
2756
|
+
function sn(t) {
|
|
2757
|
+
const e = E(t);
|
|
2571
2758
|
for (const n of e) {
|
|
2572
|
-
const r =
|
|
2759
|
+
const r = A(n.inner);
|
|
2573
2760
|
if (r.length !== 1) continue;
|
|
2574
|
-
const
|
|
2575
|
-
if (
|
|
2761
|
+
const i = r[0];
|
|
2762
|
+
if (i === "endblock" || i.startsWith("block ")) return !0;
|
|
2576
2763
|
}
|
|
2577
2764
|
return !1;
|
|
2578
2765
|
}
|
|
2579
|
-
function
|
|
2766
|
+
function Y(t) {
|
|
2580
2767
|
return t.map((e) => e.body).join("");
|
|
2581
2768
|
}
|
|
2582
|
-
function
|
|
2583
|
-
const r = [...e].sort((o, a) => o.start - a.start),
|
|
2584
|
-
let
|
|
2769
|
+
function on(t, e, n) {
|
|
2770
|
+
const r = [...e].sort((o, a) => o.start - a.start), i = [];
|
|
2771
|
+
let s = 0;
|
|
2585
2772
|
for (const o of r)
|
|
2586
|
-
|
|
2587
|
-
return
|
|
2773
|
+
i.push(t.slice(s, o.start)), i.push(n.get(o.name) ?? o.body), s = o.end;
|
|
2774
|
+
return i.push(t.slice(s)), i.reduce((o, a) => T(o, a));
|
|
2588
2775
|
}
|
|
2589
|
-
function
|
|
2776
|
+
function an(t) {
|
|
2590
2777
|
if (t instanceof Error && "code" in t && "details" in t) {
|
|
2591
2778
|
const e = t;
|
|
2592
2779
|
if (e.code === "file_not_found" && e.details && e.details.via === "include")
|
|
@@ -2594,46 +2781,46 @@ function It(t) {
|
|
|
2594
2781
|
}
|
|
2595
2782
|
return { errorToThrow: t, adjusted: !1 };
|
|
2596
2783
|
}
|
|
2597
|
-
async function
|
|
2784
|
+
async function cn(t, e) {
|
|
2598
2785
|
const {
|
|
2599
2786
|
path: n,
|
|
2600
2787
|
context: r,
|
|
2601
|
-
declarationUpdates:
|
|
2602
|
-
loader:
|
|
2788
|
+
declarationUpdates: i,
|
|
2789
|
+
loader: s,
|
|
2603
2790
|
root: o,
|
|
2604
2791
|
constrainToRoot: a,
|
|
2605
2792
|
visitStack: c,
|
|
2606
2793
|
warnings: h,
|
|
2607
2794
|
inComponent: l = !1
|
|
2608
|
-
} = e,
|
|
2609
|
-
if (
|
|
2610
|
-
if (
|
|
2611
|
-
throw
|
|
2795
|
+
} = e, u = ye(t);
|
|
2796
|
+
if (u.length === 0) {
|
|
2797
|
+
if (sn(t))
|
|
2798
|
+
throw d({
|
|
2612
2799
|
code: "parse_error",
|
|
2613
2800
|
path: n,
|
|
2614
2801
|
details: { message: "orphan block without extend" }
|
|
2615
2802
|
});
|
|
2616
|
-
return { source: t, context: _(r,
|
|
2803
|
+
return { source: t, context: _(r, i) };
|
|
2617
2804
|
}
|
|
2618
|
-
const g =
|
|
2805
|
+
const g = E(t)[0];
|
|
2619
2806
|
if (!g)
|
|
2620
|
-
return { source: t, context: _(r,
|
|
2621
|
-
if (!
|
|
2807
|
+
return { source: t, context: _(r, i) };
|
|
2808
|
+
if (!s)
|
|
2622
2809
|
throw new Error("loader is required when processing extend directives");
|
|
2623
|
-
const m =
|
|
2624
|
-
if (!(m.length > 0 ?
|
|
2625
|
-
throw
|
|
2810
|
+
const m = A(g.inner);
|
|
2811
|
+
if (!(m.length > 0 ? ce(m[0]) : null))
|
|
2812
|
+
throw d({
|
|
2626
2813
|
code: "parse_error",
|
|
2627
2814
|
path: n,
|
|
2628
2815
|
details: { message: "extend must be the first hyogen block" }
|
|
2629
2816
|
});
|
|
2630
|
-
if (
|
|
2631
|
-
throw
|
|
2817
|
+
if (u.length > 1)
|
|
2818
|
+
throw d({
|
|
2632
2819
|
code: "parse_error",
|
|
2633
2820
|
path: n,
|
|
2634
2821
|
details: { message: "multiple extend directives are not supported" }
|
|
2635
2822
|
});
|
|
2636
|
-
const
|
|
2823
|
+
const S = be(t, {
|
|
2637
2824
|
path: n,
|
|
2638
2825
|
mode: "child",
|
|
2639
2826
|
hasExtend: !0
|
|
@@ -2641,102 +2828,102 @@ async function zt(t, e) {
|
|
|
2641
2828
|
if (l)
|
|
2642
2829
|
return h?.push({
|
|
2643
2830
|
code: "extend_in_component",
|
|
2644
|
-
message:
|
|
2831
|
+
message: H("extend_in_component", { path: n }),
|
|
2645
2832
|
path: n,
|
|
2646
2833
|
details: { path: n }
|
|
2647
2834
|
}), {
|
|
2648
|
-
source:
|
|
2649
|
-
context: _(r,
|
|
2835
|
+
source: Y(S),
|
|
2836
|
+
context: _(r, i)
|
|
2650
2837
|
};
|
|
2651
|
-
const
|
|
2838
|
+
const D = u[0].path, v = n, b = X(
|
|
2652
2839
|
o,
|
|
2653
|
-
|
|
2840
|
+
D,
|
|
2654
2841
|
n,
|
|
2655
2842
|
n,
|
|
2656
2843
|
a,
|
|
2657
2844
|
!0
|
|
2658
2845
|
);
|
|
2659
|
-
|
|
2846
|
+
v && c.push(v);
|
|
2660
2847
|
try {
|
|
2661
|
-
const
|
|
2662
|
-
if (
|
|
2848
|
+
const C = v ? c.check(b) : { circular: !1 };
|
|
2849
|
+
if (C.circular)
|
|
2663
2850
|
return h?.push({
|
|
2664
2851
|
code: "circular_include",
|
|
2665
|
-
message:
|
|
2666
|
-
path:
|
|
2667
|
-
from:
|
|
2852
|
+
message: H("circular_include", {
|
|
2853
|
+
path: b,
|
|
2854
|
+
from: C.from,
|
|
2668
2855
|
via: "extend"
|
|
2669
2856
|
}),
|
|
2670
2857
|
path: n,
|
|
2671
|
-
details: { path:
|
|
2858
|
+
details: { path: b, from: C.from, via: "extend" }
|
|
2672
2859
|
}), {
|
|
2673
|
-
source:
|
|
2674
|
-
context: _(r,
|
|
2860
|
+
source: Y(S),
|
|
2861
|
+
context: _(r, i)
|
|
2675
2862
|
};
|
|
2676
|
-
c.push(
|
|
2863
|
+
c.push(b);
|
|
2677
2864
|
try {
|
|
2678
|
-
const
|
|
2679
|
-
if (
|
|
2865
|
+
const L = await s(b);
|
|
2866
|
+
if (L === void 0)
|
|
2680
2867
|
throw new Error("loader returned undefined");
|
|
2681
|
-
const { context:
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
),
|
|
2685
|
-
if (
|
|
2686
|
-
const
|
|
2868
|
+
const { context: j, body: N } = I(
|
|
2869
|
+
L,
|
|
2870
|
+
b
|
|
2871
|
+
), ue = ye(N);
|
|
2872
|
+
if (ue.length > 0) {
|
|
2873
|
+
const P = ue[0].path, z = X(
|
|
2687
2874
|
o,
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2875
|
+
P,
|
|
2876
|
+
b,
|
|
2877
|
+
b,
|
|
2691
2878
|
a,
|
|
2692
2879
|
!0
|
|
2693
|
-
),
|
|
2694
|
-
if (
|
|
2880
|
+
), U = c.check(z);
|
|
2881
|
+
if (U.circular)
|
|
2695
2882
|
return h?.push({
|
|
2696
2883
|
code: "circular_include",
|
|
2697
|
-
message:
|
|
2698
|
-
path:
|
|
2699
|
-
from:
|
|
2884
|
+
message: H("circular_include", {
|
|
2885
|
+
path: z,
|
|
2886
|
+
from: U.from,
|
|
2700
2887
|
via: "extend"
|
|
2701
2888
|
}),
|
|
2702
2889
|
path: n,
|
|
2703
|
-
details: { path:
|
|
2890
|
+
details: { path: z, from: U.from, via: "extend" }
|
|
2704
2891
|
}), {
|
|
2705
|
-
source:
|
|
2706
|
-
context: _(r,
|
|
2892
|
+
source: Y(S),
|
|
2893
|
+
context: _(r, i)
|
|
2707
2894
|
};
|
|
2708
|
-
throw
|
|
2895
|
+
throw d({
|
|
2709
2896
|
code: "parse_error",
|
|
2710
|
-
path:
|
|
2897
|
+
path: b,
|
|
2711
2898
|
details: { message: "layout extend is not supported" }
|
|
2712
2899
|
});
|
|
2713
2900
|
}
|
|
2714
|
-
const
|
|
2715
|
-
path:
|
|
2901
|
+
const Ke = be(N, {
|
|
2902
|
+
path: b,
|
|
2716
2903
|
mode: "layout"
|
|
2717
|
-
}),
|
|
2718
|
-
|
|
2719
|
-
),
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
),
|
|
2904
|
+
}), Ye = new Map(
|
|
2905
|
+
S.map((P) => [P.name, P.body])
|
|
2906
|
+
), Xe = on(
|
|
2907
|
+
N,
|
|
2908
|
+
Ke,
|
|
2909
|
+
Ye
|
|
2910
|
+
), Ge = _(
|
|
2724
2911
|
r,
|
|
2725
|
-
|
|
2726
|
-
|
|
2912
|
+
j,
|
|
2913
|
+
i
|
|
2727
2914
|
);
|
|
2728
|
-
return { source:
|
|
2915
|
+
return { source: Xe, context: Ge };
|
|
2729
2916
|
} finally {
|
|
2730
2917
|
c.pop();
|
|
2731
2918
|
}
|
|
2732
|
-
} catch (
|
|
2733
|
-
const
|
|
2734
|
-
throw
|
|
2919
|
+
} catch (C) {
|
|
2920
|
+
const L = an(C);
|
|
2921
|
+
throw L.adjusted ? L.errorToThrow : C;
|
|
2735
2922
|
} finally {
|
|
2736
|
-
|
|
2923
|
+
v && c.pop();
|
|
2737
2924
|
}
|
|
2738
2925
|
}
|
|
2739
|
-
const
|
|
2926
|
+
const ln = Q.warningReasons, hn = [
|
|
2740
2927
|
{
|
|
2741
2928
|
reason: "contains_html_script_tag",
|
|
2742
2929
|
test: (t) => /<\/?script\b/i.test(t)
|
|
@@ -2758,53 +2945,208 @@ const Ut = J.warningReasons, Zt = [
|
|
|
2758
2945
|
test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
|
|
2759
2946
|
}
|
|
2760
2947
|
];
|
|
2761
|
-
function
|
|
2762
|
-
return
|
|
2948
|
+
function un(t) {
|
|
2949
|
+
return ln[t] ?? t;
|
|
2763
2950
|
}
|
|
2764
2951
|
function G(t, e, n, r) {
|
|
2765
2952
|
if (typeof t == "string") {
|
|
2766
|
-
for (const
|
|
2767
|
-
|
|
2953
|
+
for (const i of hn)
|
|
2954
|
+
i.test(t) && n.push({
|
|
2768
2955
|
code: "suspicious_context_value",
|
|
2769
|
-
message:
|
|
2956
|
+
message: H("suspicious_context_value", {
|
|
2770
2957
|
key: e,
|
|
2771
|
-
reason:
|
|
2958
|
+
reason: un(i.reason)
|
|
2772
2959
|
}),
|
|
2773
2960
|
path: r,
|
|
2774
|
-
details: { key: e, reason:
|
|
2961
|
+
details: { key: e, reason: i.reason }
|
|
2775
2962
|
});
|
|
2776
2963
|
return;
|
|
2777
2964
|
}
|
|
2778
2965
|
if (t != null) {
|
|
2779
2966
|
if (Array.isArray(t)) {
|
|
2780
|
-
for (let
|
|
2781
|
-
G(t[
|
|
2967
|
+
for (let i = 0; i < t.length; i++)
|
|
2968
|
+
G(t[i], `${e}[${i}]`, n, r);
|
|
2782
2969
|
return;
|
|
2783
2970
|
}
|
|
2784
2971
|
if (typeof t == "object")
|
|
2785
|
-
for (const [
|
|
2972
|
+
for (const [i, s] of Object.entries(
|
|
2786
2973
|
t
|
|
2787
2974
|
)) {
|
|
2788
|
-
const o = e.length > 0 ? `${e}.${
|
|
2789
|
-
G(
|
|
2975
|
+
const o = e.length > 0 ? `${e}.${i}` : i;
|
|
2976
|
+
G(s, o, n, r);
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
function dn(t, e, n) {
|
|
2981
|
+
for (const [r, i] of Object.entries(t))
|
|
2982
|
+
G(i, r, e, n);
|
|
2983
|
+
}
|
|
2984
|
+
const fn = /^=+[ \t]*$/, pn = /^-+[ \t]*$/, mn = /^(```|~~~)/, gn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
|
|
2985
|
+
function J(t) {
|
|
2986
|
+
const e = gn.exec(t);
|
|
2987
|
+
return e && e.index !== void 0 ? {
|
|
2988
|
+
text: t.slice(0, e.index).trim(),
|
|
2989
|
+
explicitId: e[1]
|
|
2990
|
+
} : { text: t.trim() };
|
|
2991
|
+
}
|
|
2992
|
+
function xn(t) {
|
|
2993
|
+
let e = 0;
|
|
2994
|
+
for (; e < t.length && e < 6 && t[e] === "#"; )
|
|
2995
|
+
e += 1;
|
|
2996
|
+
if (e === 0 || e === 6 && e < t.length && t[e] === "#" || e >= t.length || t[e] !== " " && t[e] !== " ")
|
|
2997
|
+
return null;
|
|
2998
|
+
let n = e;
|
|
2999
|
+
for (; n < t.length && (t[n] === " " || t[n] === " "); )
|
|
3000
|
+
n += 1;
|
|
3001
|
+
if (n >= t.length)
|
|
3002
|
+
return null;
|
|
3003
|
+
let r = t.length;
|
|
3004
|
+
for (; r > n && (t[r - 1] === " " || t[r - 1] === " "); )
|
|
3005
|
+
r -= 1;
|
|
3006
|
+
let i = r;
|
|
3007
|
+
if (r > n && t[r - 1] === "#") {
|
|
3008
|
+
let o = r - 1;
|
|
3009
|
+
for (; o > n && t[o - 1] === "#"; )
|
|
3010
|
+
o -= 1;
|
|
3011
|
+
if (o > n && (t[o - 1] === " " || t[o - 1] === " ")) {
|
|
3012
|
+
let a = o - 1;
|
|
3013
|
+
for (; a >= n && (t[a] === " " || t[a] === " "); )
|
|
3014
|
+
a -= 1;
|
|
3015
|
+
i = a + 1;
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
if (i <= n)
|
|
3019
|
+
return null;
|
|
3020
|
+
const s = J(t.slice(n, i));
|
|
3021
|
+
return { level: e, ...s };
|
|
3022
|
+
}
|
|
3023
|
+
function _e(t, e, n) {
|
|
3024
|
+
let r = n;
|
|
3025
|
+
for (; r < t.length; ) {
|
|
3026
|
+
if (!e.inHtmlComment) {
|
|
3027
|
+
const s = t.indexOf("<!--", r);
|
|
3028
|
+
if (s === -1)
|
|
3029
|
+
return;
|
|
3030
|
+
e.inHtmlComment = !0, r = s + 4;
|
|
3031
|
+
continue;
|
|
3032
|
+
}
|
|
3033
|
+
const i = t.indexOf("-->", r);
|
|
3034
|
+
if (i === -1)
|
|
3035
|
+
return;
|
|
3036
|
+
e.inHtmlComment = !1, r = i + 3;
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
function kn(t, e) {
|
|
3040
|
+
if (e.inFence || e.inHtmlComment)
|
|
3041
|
+
return !0;
|
|
3042
|
+
const n = t.trim();
|
|
3043
|
+
return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
|
|
3044
|
+
}
|
|
3045
|
+
function wn(t) {
|
|
3046
|
+
const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
|
|
3047
|
+
for (let i = 0; i < e.length; i++) {
|
|
3048
|
+
const s = e[i];
|
|
3049
|
+
if (r.inFence) {
|
|
3050
|
+
const l = s.trim();
|
|
3051
|
+
l.startsWith(r.inFence.marker) && /^(`{3,}|~{3,})\s*$/.test(l) && (r.inFence = !1);
|
|
3052
|
+
continue;
|
|
3053
|
+
}
|
|
3054
|
+
if (r.inHtmlComment) {
|
|
3055
|
+
_e(s, r, 0);
|
|
3056
|
+
continue;
|
|
3057
|
+
}
|
|
3058
|
+
const o = mn.exec(s.trimStart());
|
|
3059
|
+
if (o) {
|
|
3060
|
+
const l = o[1];
|
|
3061
|
+
s.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
|
|
3062
|
+
continue;
|
|
3063
|
+
}
|
|
3064
|
+
if (s.trim().startsWith("<!--")) {
|
|
3065
|
+
_e(s, r, s.indexOf("<!--"));
|
|
3066
|
+
continue;
|
|
3067
|
+
}
|
|
3068
|
+
if (kn(s, r))
|
|
3069
|
+
continue;
|
|
3070
|
+
const c = xn(s);
|
|
3071
|
+
if (c) {
|
|
3072
|
+
n.push(c);
|
|
3073
|
+
continue;
|
|
3074
|
+
}
|
|
3075
|
+
const h = e[i + 1];
|
|
3076
|
+
if (h !== void 0 && s.trim().length > 0 && !s.trimStart().startsWith("#") && !s.trimStart().startsWith(">") && !s.trimStart().startsWith("|")) {
|
|
3077
|
+
if (fn.test(h)) {
|
|
3078
|
+
const l = J(s.trim());
|
|
3079
|
+
n.push({ level: 1, ...l }), i += 1;
|
|
3080
|
+
continue;
|
|
2790
3081
|
}
|
|
3082
|
+
if (pn.test(h) && h.trim().length >= 1) {
|
|
3083
|
+
const l = J(s.trim());
|
|
3084
|
+
n.push({ level: 2, ...l }), i += 1;
|
|
3085
|
+
continue;
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
2791
3088
|
}
|
|
3089
|
+
return n;
|
|
3090
|
+
}
|
|
3091
|
+
const vn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
|
|
3092
|
+
function bn() {
|
|
3093
|
+
const t = /* @__PURE__ */ new Map();
|
|
3094
|
+
return {
|
|
3095
|
+
slug(e, n) {
|
|
3096
|
+
const r = n !== void 0 && n.length > 0 ? n : yn(e), i = t.get(r) ?? 0;
|
|
3097
|
+
return t.set(r, i + 1), i === 0 ? r : `${r}-${i}`;
|
|
3098
|
+
}
|
|
3099
|
+
};
|
|
2792
3100
|
}
|
|
2793
|
-
function
|
|
2794
|
-
|
|
2795
|
-
|
|
3101
|
+
function yn(t) {
|
|
3102
|
+
return t.toLowerCase().replace(vn, "").replace(/\s+/g, "-");
|
|
3103
|
+
}
|
|
3104
|
+
function _n(t) {
|
|
3105
|
+
let e = t.trim();
|
|
3106
|
+
e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
|
|
3107
|
+
for (let n = 0; n < 3; n++)
|
|
3108
|
+
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");
|
|
3109
|
+
return e.trim();
|
|
3110
|
+
}
|
|
3111
|
+
function Sn(t, e) {
|
|
3112
|
+
if (t.length === 0)
|
|
3113
|
+
return "";
|
|
3114
|
+
const n = bn(), i = t.map((o) => {
|
|
3115
|
+
const a = _n(o.text), c = n.slug(a, o.explicitId);
|
|
3116
|
+
return { level: o.level, text: a, anchor: c };
|
|
3117
|
+
}).filter((o) => o.level <= e);
|
|
3118
|
+
if (i.length === 0)
|
|
3119
|
+
return "";
|
|
3120
|
+
const s = Math.min(...i.map((o) => o.level));
|
|
3121
|
+
return i.map((o) => `${" ".repeat((o.level - s) * 2)}- [${o.text}](#${o.anchor})`).join(`
|
|
3122
|
+
`);
|
|
3123
|
+
}
|
|
3124
|
+
function Cn(t, e = {}) {
|
|
3125
|
+
const r = E(t).filter((o) => {
|
|
3126
|
+
const a = A(o.inner);
|
|
3127
|
+
return a.length === 1 && le(a[0]);
|
|
3128
|
+
});
|
|
3129
|
+
if (r.length === 0)
|
|
3130
|
+
return t;
|
|
3131
|
+
const i = wn(t);
|
|
3132
|
+
let s = t;
|
|
3133
|
+
for (let o = r.length - 1; o >= 0; o--) {
|
|
3134
|
+
const a = r[o], { maxLevel: c } = Ut(a.inner, e.path), h = Sn(i, c), l = s.slice(0, a.start), u = s.slice(a.end);
|
|
3135
|
+
s = T(T(l, h), u);
|
|
3136
|
+
}
|
|
3137
|
+
return s;
|
|
2796
3138
|
}
|
|
2797
|
-
async function
|
|
2798
|
-
const n = e.path, r = e.context,
|
|
3139
|
+
async function he(t, e) {
|
|
3140
|
+
const n = e.path, r = e.context, i = e.registry ?? new Ce(), s = e.warnings ?? [], o = e.visitStack ?? new Ze(), {
|
|
2799
3141
|
source: a,
|
|
2800
3142
|
declarationUpdates: c
|
|
2801
|
-
} = await
|
|
2802
|
-
|
|
3143
|
+
} = await Zt(t, { path: n, context: { ...r } });
|
|
3144
|
+
dn(
|
|
2803
3145
|
_(r, c ?? {}),
|
|
2804
|
-
|
|
3146
|
+
s,
|
|
2805
3147
|
n
|
|
2806
3148
|
);
|
|
2807
|
-
const h = await
|
|
3149
|
+
const h = await cn(a, {
|
|
2808
3150
|
path: n,
|
|
2809
3151
|
context: r,
|
|
2810
3152
|
declarationUpdates: c ?? {},
|
|
@@ -2812,123 +3154,123 @@ async function ae(t, e) {
|
|
|
2812
3154
|
root: e.root,
|
|
2813
3155
|
constrainToRoot: e.constrainToRoot,
|
|
2814
3156
|
visitStack: o,
|
|
2815
|
-
warnings:
|
|
3157
|
+
warnings: s,
|
|
2816
3158
|
inComponent: e.inComponent ?? !1
|
|
2817
|
-
}), { source: l, context:
|
|
3159
|
+
}), { source: l, context: u } = h, { source: f, directives: g } = Qt(l, {
|
|
2818
3160
|
path: n,
|
|
2819
|
-
registry:
|
|
2820
|
-
context:
|
|
3161
|
+
registry: i,
|
|
3162
|
+
context: u
|
|
2821
3163
|
}), m = e.loader;
|
|
2822
3164
|
if (g.length > 0 && !m)
|
|
2823
3165
|
throw new Error("loader is required when processing include directives");
|
|
2824
3166
|
let p = f;
|
|
2825
|
-
return g.length > 0 && m && (p = await
|
|
3167
|
+
return g.length > 0 && m && (p = await Ft({
|
|
2826
3168
|
source: f,
|
|
2827
3169
|
directives: g,
|
|
2828
|
-
context:
|
|
3170
|
+
context: u,
|
|
2829
3171
|
loader: m,
|
|
2830
3172
|
root: e.root,
|
|
2831
3173
|
path: n,
|
|
2832
3174
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
2833
3175
|
preserveHgComments: e.preserveHgComments,
|
|
2834
3176
|
visitStack: o,
|
|
2835
|
-
warnings:
|
|
2836
|
-
registry:
|
|
3177
|
+
warnings: s,
|
|
3178
|
+
registry: i,
|
|
2837
3179
|
constrainToRoot: e.constrainToRoot
|
|
2838
|
-
})), p = await
|
|
2839
|
-
context:
|
|
3180
|
+
})), p = await Ht(p, {
|
|
3181
|
+
context: u,
|
|
2840
3182
|
path: n,
|
|
2841
|
-
registry:
|
|
3183
|
+
registry: i,
|
|
2842
3184
|
loader: m,
|
|
2843
3185
|
rootDir: e.root,
|
|
2844
|
-
warnings:
|
|
3186
|
+
warnings: s,
|
|
2845
3187
|
visitStack: o,
|
|
2846
|
-
parentContext:
|
|
3188
|
+
parentContext: u,
|
|
2847
3189
|
preserveHgComments: e.preserveHgComments,
|
|
2848
3190
|
constrainToRoot: e.constrainToRoot
|
|
2849
|
-
}), p = await
|
|
3191
|
+
}), p = await Ne(p, u, {
|
|
2850
3192
|
path: n,
|
|
2851
|
-
registry:
|
|
3193
|
+
registry: i,
|
|
2852
3194
|
loader: m,
|
|
2853
3195
|
rootDir: e.root,
|
|
2854
|
-
warnings:
|
|
3196
|
+
warnings: s,
|
|
2855
3197
|
visitStack: o,
|
|
2856
|
-
parentContext:
|
|
3198
|
+
parentContext: u,
|
|
2857
3199
|
preserveHgComments: e.preserveHgComments,
|
|
2858
3200
|
constrainToRoot: e.constrainToRoot
|
|
2859
|
-
}), p =
|
|
3201
|
+
}), p = Cn(p, { path: n }), p = tn(p, e.preserveHgComments), p;
|
|
2860
3202
|
}
|
|
2861
|
-
async function
|
|
2862
|
-
const n = e.path, r = _(e.context),
|
|
3203
|
+
async function Wn(t, e = {}) {
|
|
3204
|
+
const n = e.path, r = _(e.context), i = e.registry ?? new Ce(), s = e.warnings ?? [], o = e.visitStack ?? new Ze(), { context: a, body: c, rawFrontMatter: h } = I(
|
|
2863
3205
|
t,
|
|
2864
3206
|
n
|
|
2865
3207
|
), l = _(r, a);
|
|
2866
|
-
let
|
|
3208
|
+
let u = await he(c, {
|
|
2867
3209
|
...e,
|
|
2868
3210
|
context: l,
|
|
2869
|
-
registry:
|
|
2870
|
-
warnings:
|
|
3211
|
+
registry: i,
|
|
3212
|
+
warnings: s,
|
|
2871
3213
|
visitStack: o
|
|
2872
3214
|
});
|
|
2873
|
-
return
|
|
3215
|
+
return u = en(u, {
|
|
2874
3216
|
preserveFrontMatter: e.preserveFrontMatter,
|
|
2875
3217
|
rawFrontMatter: h
|
|
2876
3218
|
}), {
|
|
2877
|
-
markdown:
|
|
2878
|
-
warnings:
|
|
3219
|
+
markdown: u,
|
|
3220
|
+
warnings: s
|
|
2879
3221
|
};
|
|
2880
3222
|
}
|
|
2881
|
-
async function
|
|
2882
|
-
const n = e.path, { context: r, body:
|
|
2883
|
-
return
|
|
3223
|
+
async function $n(t, e) {
|
|
3224
|
+
const n = e.path, { context: r, body: i } = I(t, n), s = _(e.context, r);
|
|
3225
|
+
return he(i, {
|
|
2884
3226
|
...e,
|
|
2885
|
-
context:
|
|
3227
|
+
context: s,
|
|
2886
3228
|
preserveFrontMatter: !1
|
|
2887
3229
|
});
|
|
2888
3230
|
}
|
|
2889
|
-
async function
|
|
3231
|
+
async function En(t, e, n) {
|
|
2890
3232
|
if (n != null && "serverContext" in n && n.serverContext != null)
|
|
2891
|
-
throw
|
|
3233
|
+
throw d({
|
|
2892
3234
|
code: "server_context_on_client"
|
|
2893
3235
|
});
|
|
2894
3236
|
if (n != null && "dataSources" in n && n.dataSources != null && Object.keys(n.dataSources).length > 0)
|
|
2895
|
-
throw
|
|
3237
|
+
throw d({
|
|
2896
3238
|
code: "data_sources_on_client"
|
|
2897
3239
|
});
|
|
2898
3240
|
const r = n?.loader;
|
|
2899
3241
|
if (!r)
|
|
2900
|
-
throw
|
|
3242
|
+
throw d({
|
|
2901
3243
|
code: "parse_error",
|
|
2902
3244
|
details: { message: "loader is required for renderClient" }
|
|
2903
3245
|
});
|
|
2904
|
-
let
|
|
2905
|
-
typeof t == "string" ?
|
|
3246
|
+
let i, s;
|
|
3247
|
+
typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
|
|
2906
3248
|
const o = _(e);
|
|
2907
|
-
return
|
|
3249
|
+
return Wn(i, {
|
|
2908
3250
|
context: o,
|
|
2909
3251
|
loader: r,
|
|
2910
3252
|
root: n?.root,
|
|
2911
|
-
path:
|
|
3253
|
+
path: s ?? n?.path,
|
|
2912
3254
|
preserveFrontMatter: n?.preserveFrontMatter,
|
|
2913
3255
|
preserveHgComments: n?.preserveHgComments,
|
|
2914
3256
|
constrainToRoot: n?.constrainToRoot
|
|
2915
3257
|
});
|
|
2916
3258
|
}
|
|
2917
|
-
function
|
|
3259
|
+
function Tn(t, e) {
|
|
2918
3260
|
const n = [`[hyogen:${t}] ${e.code}`], r = {};
|
|
2919
3261
|
if (e.details)
|
|
2920
|
-
for (const [
|
|
2921
|
-
|
|
3262
|
+
for (const [i, s] of Object.entries(e.details))
|
|
3263
|
+
s !== void 0 && (r[i] = s);
|
|
2922
3264
|
r.path === void 0 && e.path !== void 0 && (r.path = e.path);
|
|
2923
|
-
for (const [
|
|
2924
|
-
n.push(` ${
|
|
3265
|
+
for (const [i, s] of Object.entries(r))
|
|
3266
|
+
n.push(` ${i}: ${String(s)}`);
|
|
2925
3267
|
return n.join(`
|
|
2926
3268
|
`);
|
|
2927
3269
|
}
|
|
2928
3270
|
export {
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
3271
|
+
d as createHyogenError,
|
|
3272
|
+
Tn as formatDiagnosticLog,
|
|
3273
|
+
it as formatMessage,
|
|
3274
|
+
En as renderClient
|
|
2933
3275
|
};
|
|
2934
3276
|
//# sourceMappingURL=client.js.map
|