ssqch 0.7.0 → 0.8.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 +6 -4
- package/bin/ssqch.js +14 -48
- package/bundled/README.md +1247 -0
- package/bundled/completions/bash +840 -0
- package/bundled/completions/elvish +286 -0
- package/bundled/completions/fish +182 -0
- package/bundled/completions/powershell +318 -0
- package/bundled/completions/zsh +510 -0
- package/bundled/ssqch.d.ts +532 -0
- package/bundled/starter/engines/index.edge +11 -0
- package/bundled/starter/engines/index.ejs +11 -0
- package/bundled/starter/engines/index.hbs +11 -0
- package/bundled/starter/engines/index.liquid +11 -0
- package/bundled/starter/engines/layout.edge +35 -0
- package/bundled/starter/engines/layout.ejs +35 -0
- package/bundled/starter/engines/layout.hbs +35 -0
- package/bundled/starter/engines/layout.liquid +35 -0
- package/bundled/starter/gitignore +3 -0
- package/bundled/starter/jsconfig.json +11 -0
- package/bundled/starter/src/404.md +8 -0
- package/bundled/starter/src/_blueprints/posts.md +5 -0
- package/bundled/starter/src/_data/site.json +4 -0
- package/bundled/starter/src/_includes/layout.jinja +35 -0
- package/bundled/starter/src/index.jinja +11 -0
- package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
- package/bundled/starter/src/posts/posts.json +4 -0
- package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
- package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
- package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
- package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
- package/bundled/starter/ssqch.config.js +29 -0
- package/bundled/starter-docs/engines/edge/base.edge +41 -0
- package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
- package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
- package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
- package/bundled/starter-docs/engines/edge/doc.edge +59 -0
- package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
- package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
- package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
- package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
- package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
- package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
- package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
- package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
- package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
- package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
- package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
- package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
- package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
- package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
- package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
- package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
- package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
- package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
- package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
- package/bundled/starter-docs/gitignore +4 -0
- package/bundled/starter-docs/src/404.md +12 -0
- package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
- package/bundled/starter-docs/src/_data/nav.yml +10 -0
- package/bundled/starter-docs/src/_data/site.json +5 -0
- package/bundled/starter-docs/src/_includes/base.jinja +41 -0
- package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
- package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
- package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
- package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
- package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
- package/bundled/starter-docs/src/assets/docs.css +257 -0
- package/bundled/starter-docs/src/assets/docs.js +67 -0
- package/bundled/starter-docs/src/docs/docs.json +1 -0
- package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
- package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
- package/bundled/starter-docs/src/docs/index.md +29 -0
- package/bundled/starter-docs/src/docs/install.md +42 -0
- package/bundled/starter-docs/src/index.md +13 -0
- package/bundled/starter-docs/ssqch.config.js +40 -0
- package/bundled/trailheads/from-component-frameworks.md +116 -0
- package/bundled/trailheads/from-docusaurus.md +55 -0
- package/bundled/trailheads/from-eleventy.md +140 -0
- package/bundled/trailheads/from-hexo.md +92 -0
- package/bundled/trailheads/from-mkdocs.md +45 -0
- package/bundled/trailheads/from-zola.md +71 -0
- package/lib/assets.js +235 -3
- package/lib/chunk-37KSIVNY.js +29 -0
- package/lib/chunk-3GYLOC6Y.js +1017 -0
- package/lib/chunk-3NYSSA2C.js +22 -0
- package/lib/chunk-3PHCFZEU.js +209 -0
- package/lib/chunk-4Q6WMTER.js +32 -0
- package/lib/chunk-6XYSFG6V.js +4423 -0
- package/lib/chunk-6XYSFG6V.js.LEGAL.txt +41 -0
- package/lib/chunk-AD3HAW3W.js +10 -0
- package/lib/chunk-AMBFWPZ4.js +118 -0
- package/lib/chunk-BOBPVAX2.js +37088 -0
- package/lib/chunk-BOBPVAX2.js.LEGAL.txt +27 -0
- package/lib/chunk-BRK4MXXO.js +565 -0
- package/lib/chunk-C35KIPAR.js +247 -0
- package/lib/chunk-CDEPYU7W.js +25 -0
- package/lib/chunk-CMUWRPSQ.js +113 -0
- package/lib/chunk-DDV6JEC2.js +46 -0
- package/lib/chunk-DHHQKW4F.js +71 -0
- package/lib/chunk-EIT4ZDT4.js +1485 -0
- package/lib/chunk-EZZUUPI4.js +20 -0
- package/lib/chunk-F65YUXZ7.js +334 -0
- package/lib/chunk-FVZ5JBRI.js +115 -0
- package/lib/chunk-FYGE634X.js +44 -0
- package/lib/chunk-GOE4ZSAB.js +75 -0
- package/lib/chunk-GSKVRAHF.js +44 -0
- package/lib/chunk-HR2RU2LY.js +999 -0
- package/lib/chunk-HXCLCXRT.js +20 -0
- package/lib/chunk-I3PS26CI.js +48 -0
- package/lib/chunk-IAFM5ITE.js +11 -0
- package/lib/chunk-IRHRK7XB.js +54 -0
- package/lib/chunk-JRT7TQQP.js +57 -0
- package/lib/chunk-JSPSMIJ2.js +217 -0
- package/lib/chunk-KBGE5MCY.js +175 -0
- package/lib/chunk-N5QTGQ5N.js +207 -0
- package/lib/chunk-NKXEPHRZ.js +136 -0
- package/lib/chunk-NUKCUDC4.js +146 -0
- package/lib/chunk-RI2L3VGO.js +376 -0
- package/lib/chunk-TDGBQNGW.js +251 -0
- package/lib/chunk-TN6EEDX2.js +3935 -0
- package/lib/chunk-TWCVHOKO.js +1229 -0
- package/lib/chunk-UGEGUUBT.js +29 -0
- package/lib/chunk-UU43WIZG.js +29 -0
- package/lib/chunk-VJWQSYEG.js +119 -0
- package/lib/chunk-VVPZ5PDP.js +160 -0
- package/lib/chunk-WMOVCQO6.js +1287 -0
- package/lib/chunk-WP3RPVUM.js +211 -0
- package/lib/chunk-YSH2NMIE.js +502 -0
- package/lib/cli.js +540 -0
- package/lib/elements.js +180 -3
- package/lib/image.js +27 -3
- package/lib/links.js +464 -3
- package/lib/minify.js +69 -3
- package/lib/redirects.js +152 -3
- package/lib/rss.js +139 -3
- package/lib/sass.js +221 -3
- package/lib/sitemap.js +88 -3
- package/lib/ssqch.js +28 -0
- package/package.json +83 -80
- package/src/serve/live.js +174 -0
- package/src/serve/not-found.html +31 -0
- package/types/globals.d.ts +3 -2
- package/types/image.d.ts +7 -3
- package/types/index.d.ts +18 -5
- package/types/links.d.ts +1 -1
- package/types/minify.d.ts +1 -1
- package/types/rss.d.ts +1 -1
- package/types/sass.d.ts +1 -1
- package/wasm/markdown.wasm +0 -0
- package/wasm/minify.wasm +0 -0
- package/wasm/sass.wasm +0 -0
- package/lib/index.js +0 -3
- package/platforms.json +0 -6
|
@@ -0,0 +1,4423 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
realPath
|
|
5
|
+
} from "./chunk-VJWQSYEG.js";
|
|
6
|
+
|
|
7
|
+
// node_modules/smol-toml/dist/error.js
|
|
8
|
+
function getLineColFromPtr(string, ptr) {
|
|
9
|
+
let lines = string.slice(0, ptr).split(/\r?\n/);
|
|
10
|
+
return [lines.length, lines.pop().length + 1];
|
|
11
|
+
}
|
|
12
|
+
function makeCodeBlock(string, line, column) {
|
|
13
|
+
let lines = string.split(/\r?\n/);
|
|
14
|
+
let codeblock = "";
|
|
15
|
+
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
16
|
+
for (let i2 = line - 1; i2 <= line + 1; i2++) {
|
|
17
|
+
let l = lines[i2 - 1];
|
|
18
|
+
if (!l)
|
|
19
|
+
continue;
|
|
20
|
+
codeblock += i2.toString().padEnd(numberLen, " ");
|
|
21
|
+
codeblock += ": ";
|
|
22
|
+
codeblock += l;
|
|
23
|
+
codeblock += "\n";
|
|
24
|
+
if (i2 === line) {
|
|
25
|
+
codeblock += " ".repeat(numberLen + column + 2);
|
|
26
|
+
codeblock += "^\n";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return codeblock;
|
|
30
|
+
}
|
|
31
|
+
var TomlError = class _TomlError extends Error {
|
|
32
|
+
line;
|
|
33
|
+
column;
|
|
34
|
+
codeblock;
|
|
35
|
+
constructor(message, options) {
|
|
36
|
+
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
37
|
+
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
38
|
+
super(`Invalid TOML document: ${message}
|
|
39
|
+
|
|
40
|
+
${codeblock}`, options);
|
|
41
|
+
this.line = line;
|
|
42
|
+
this.column = column;
|
|
43
|
+
this.codeblock = codeblock;
|
|
44
|
+
}
|
|
45
|
+
/** @internal */
|
|
46
|
+
static x(message, ctx, ptr) {
|
|
47
|
+
throw new _TomlError(message, { toml: ctx.s, ptr: ptr ?? ctx.p });
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// node_modules/smol-toml/dist/primitive.js
|
|
52
|
+
function parseString(ctx) {
|
|
53
|
+
let startPtr = ctx.p;
|
|
54
|
+
let c = ctx.s.charCodeAt(ctx.p++);
|
|
55
|
+
let first = c;
|
|
56
|
+
let isLiteral = c === 39;
|
|
57
|
+
let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
|
|
58
|
+
if (isMultiline) {
|
|
59
|
+
if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
|
|
60
|
+
ctx.p++;
|
|
61
|
+
else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
|
|
62
|
+
ctx.p += 2;
|
|
63
|
+
}
|
|
64
|
+
let parsed = "";
|
|
65
|
+
let sliceStart = ctx.p;
|
|
66
|
+
let state = 0;
|
|
67
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
68
|
+
c = ctx.s.charCodeAt(ctx.p);
|
|
69
|
+
if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
|
|
70
|
+
state = state && 3;
|
|
71
|
+
} else if (c < 32 && c !== 9 || c === 127) {
|
|
72
|
+
TomlError.x("control characters are not allowed in strings", ctx);
|
|
73
|
+
} else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
74
|
+
if (isMultiline) {
|
|
75
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
76
|
+
ctx.p++;
|
|
77
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
78
|
+
ctx.p++;
|
|
79
|
+
}
|
|
80
|
+
if (!state) {
|
|
81
|
+
let s = ctx.s.slice(sliceStart, ctx.p);
|
|
82
|
+
parsed = parsed ? parsed + s : s;
|
|
83
|
+
}
|
|
84
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
85
|
+
return parsed;
|
|
86
|
+
} else if (!state) {
|
|
87
|
+
if (!isLiteral && c === 92) {
|
|
88
|
+
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
89
|
+
state = 1;
|
|
90
|
+
}
|
|
91
|
+
} else if (state === 1) {
|
|
92
|
+
if (c === 120 || c === 117 || c === 85) {
|
|
93
|
+
let errPtr = ctx.p++ - 1;
|
|
94
|
+
let value = 0;
|
|
95
|
+
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
96
|
+
for (let j = 0; j < len; j++, ctx.p++) {
|
|
97
|
+
let hex = ctx.s.charCodeAt(ctx.p);
|
|
98
|
+
let digit = (
|
|
99
|
+
/* 0-9 */
|
|
100
|
+
hex >= 48 && hex <= 57 ? hex - 48 : (
|
|
101
|
+
/* A-F */
|
|
102
|
+
hex >= 65 && hex <= 70 ? hex - 65 + 10 : (
|
|
103
|
+
/* a-f */
|
|
104
|
+
hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
if (digit < 0)
|
|
109
|
+
TomlError.x("invalid non-hex character in unicode escape", ctx);
|
|
110
|
+
value = value << 4 | digit;
|
|
111
|
+
}
|
|
112
|
+
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
|
|
113
|
+
TomlError.x("invalid unicode escape", ctx, errPtr);
|
|
114
|
+
}
|
|
115
|
+
parsed += String.fromCodePoint(value);
|
|
116
|
+
sliceStart = ctx.p--;
|
|
117
|
+
state = 0;
|
|
118
|
+
} else if (isMultiline && (c === 32 || c === 9)) {
|
|
119
|
+
state = 2;
|
|
120
|
+
} else {
|
|
121
|
+
if (c === 98)
|
|
122
|
+
parsed += "\b";
|
|
123
|
+
else if (c === 116)
|
|
124
|
+
parsed += " ";
|
|
125
|
+
else if (c === 110)
|
|
126
|
+
parsed += "\n";
|
|
127
|
+
else if (c === 102)
|
|
128
|
+
parsed += "\f";
|
|
129
|
+
else if (c === 114)
|
|
130
|
+
parsed += "\r";
|
|
131
|
+
else if (c === 101)
|
|
132
|
+
parsed += "\x1B";
|
|
133
|
+
else if (c === 34)
|
|
134
|
+
parsed += '"';
|
|
135
|
+
else if (c === 92)
|
|
136
|
+
parsed += "\\";
|
|
137
|
+
else
|
|
138
|
+
TomlError.x("unrecognised escape sequence", ctx);
|
|
139
|
+
sliceStart = ctx.p + 1;
|
|
140
|
+
state = 0;
|
|
141
|
+
}
|
|
142
|
+
} else if (c !== 32 && c !== 9) {
|
|
143
|
+
if (state === 2)
|
|
144
|
+
TomlError.x("invalid escape: only line-ending whitespace may be escaped", ctx, sliceStart);
|
|
145
|
+
state = !isLiteral && c === 92 ? 1 : 0;
|
|
146
|
+
sliceStart = ctx.p;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
TomlError.x("unfinished string", ctx, startPtr);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// node_modules/smol-toml/dist/date.js
|
|
153
|
+
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;
|
|
154
|
+
var TomlDate = class _TomlDate extends Date {
|
|
155
|
+
#hasDate = false;
|
|
156
|
+
#hasTime = false;
|
|
157
|
+
#offset = null;
|
|
158
|
+
constructor(date, fasttype, unsafeDelim) {
|
|
159
|
+
let hasDate = true;
|
|
160
|
+
let hasTime = true;
|
|
161
|
+
let offset = "Z";
|
|
162
|
+
let c;
|
|
163
|
+
if (typeof date === "string") {
|
|
164
|
+
if (fasttype)
|
|
165
|
+
prep: {
|
|
166
|
+
if (fasttype < 3) {
|
|
167
|
+
if (+date.slice(11, 13) > 23) {
|
|
168
|
+
date = "";
|
|
169
|
+
break prep;
|
|
170
|
+
}
|
|
171
|
+
if (fasttype === 2) {
|
|
172
|
+
offset = null;
|
|
173
|
+
date += "Z";
|
|
174
|
+
} else if ((c = date.charCodeAt(date.length - 1)) !== 90 && c !== 122) {
|
|
175
|
+
offset = date.slice(date.length - 6);
|
|
176
|
+
}
|
|
177
|
+
if (unsafeDelim)
|
|
178
|
+
date = date.slice(0, 10) + "T" + date.slice(11);
|
|
179
|
+
} else if (fasttype === 4) {
|
|
180
|
+
date = +date.slice(0, 2) > 23 ? "" : `0000-01-01T${date}Z`;
|
|
181
|
+
}
|
|
182
|
+
hasDate = fasttype !== 4;
|
|
183
|
+
hasTime = fasttype !== 3;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
let match = date.match(DATE_TIME_RE);
|
|
187
|
+
if (match) {
|
|
188
|
+
if (!match[1]) {
|
|
189
|
+
hasDate = false;
|
|
190
|
+
date = `0000-01-01T${date}`;
|
|
191
|
+
}
|
|
192
|
+
hasTime = !!match[2];
|
|
193
|
+
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
194
|
+
if (match[2] && +match[2] > 23) {
|
|
195
|
+
date = "";
|
|
196
|
+
} else {
|
|
197
|
+
offset = match[3] || null;
|
|
198
|
+
if (!offset && hasTime)
|
|
199
|
+
date += "Z";
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
date = "";
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
super(date);
|
|
207
|
+
if (!isNaN(this.getTime())) {
|
|
208
|
+
this.#hasDate = hasDate;
|
|
209
|
+
this.#hasTime = hasTime;
|
|
210
|
+
this.#offset = offset;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
isDateTime() {
|
|
214
|
+
return this.#hasDate && this.#hasTime;
|
|
215
|
+
}
|
|
216
|
+
isLocal() {
|
|
217
|
+
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
218
|
+
}
|
|
219
|
+
isDate() {
|
|
220
|
+
return this.#hasDate && !this.#hasTime;
|
|
221
|
+
}
|
|
222
|
+
isTime() {
|
|
223
|
+
return this.#hasTime && !this.#hasDate;
|
|
224
|
+
}
|
|
225
|
+
isValid() {
|
|
226
|
+
return this.#hasDate || this.#hasTime;
|
|
227
|
+
}
|
|
228
|
+
toISOString() {
|
|
229
|
+
let iso = super.toISOString();
|
|
230
|
+
if (this.isDate())
|
|
231
|
+
return iso.slice(0, 10);
|
|
232
|
+
if (this.isTime())
|
|
233
|
+
return iso.slice(11, 23);
|
|
234
|
+
if (this.#offset === null)
|
|
235
|
+
return iso.slice(0, -1);
|
|
236
|
+
if (this.#offset === "Z" || this.#offset === "z")
|
|
237
|
+
return iso;
|
|
238
|
+
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
239
|
+
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
240
|
+
let offsetDate = new Date(this.getTime() - offset * 6e4);
|
|
241
|
+
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
242
|
+
}
|
|
243
|
+
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
244
|
+
let date = new _TomlDate(jsDate);
|
|
245
|
+
date.#offset = offset;
|
|
246
|
+
return date;
|
|
247
|
+
}
|
|
248
|
+
static wrapAsLocalDateTime(jsDate) {
|
|
249
|
+
let date = new _TomlDate(jsDate);
|
|
250
|
+
date.#offset = null;
|
|
251
|
+
return date;
|
|
252
|
+
}
|
|
253
|
+
static wrapAsLocalDate(jsDate) {
|
|
254
|
+
let date = new _TomlDate(jsDate);
|
|
255
|
+
date.#hasTime = false;
|
|
256
|
+
date.#offset = null;
|
|
257
|
+
return date;
|
|
258
|
+
}
|
|
259
|
+
static wrapAsLocalTime(jsDate) {
|
|
260
|
+
let date = new _TomlDate(jsDate);
|
|
261
|
+
date.#hasDate = false;
|
|
262
|
+
date.#offset = null;
|
|
263
|
+
return date;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// node_modules/smol-toml/dist/extract.js
|
|
268
|
+
function isDigit(char, base = 10) {
|
|
269
|
+
return base === 16 ? char > 47 && char < 58 || char > 64 && char < 71 || char > 96 && char < 103 : char > 47 && char < 48 + base;
|
|
270
|
+
}
|
|
271
|
+
function isEndOfValue(char, delim) {
|
|
272
|
+
return char === 32 || char === 9 || char === 10 || char === 13 || // Structure end or next value delimiter
|
|
273
|
+
delim && (char === delim || char === 44) || // Comment
|
|
274
|
+
char === 35;
|
|
275
|
+
}
|
|
276
|
+
function extractValue(ctx, end) {
|
|
277
|
+
let errPtr = ctx.p;
|
|
278
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
279
|
+
if (c === 91 || c === 123) {
|
|
280
|
+
ctx.d-- || TomlError.x("document contains excessively nested structures. aborting.", ctx);
|
|
281
|
+
let value = c === 91 ? parseArray(ctx) : parseInlineTable(ctx);
|
|
282
|
+
ctx.d++;
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
if (c === 34 || c === 39) {
|
|
286
|
+
return parseString(ctx);
|
|
287
|
+
}
|
|
288
|
+
if (c === 116) {
|
|
289
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
290
|
+
TomlError.x("invalid value", ctx, errPtr);
|
|
291
|
+
return ctx.p++, true;
|
|
292
|
+
}
|
|
293
|
+
if (c === 102) {
|
|
294
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
295
|
+
TomlError.x("invalid value", ctx, errPtr);
|
|
296
|
+
return ctx.p++, false;
|
|
297
|
+
}
|
|
298
|
+
if (c === 43 || c === 45) {
|
|
299
|
+
return parseNumber(ctx, ctx.p, ctx.s.charCodeAt(++ctx.p), 44 - c, end);
|
|
300
|
+
}
|
|
301
|
+
if (ctx.s.charCodeAt(ctx.p + 4) === 45 && ctx.s.charCodeAt(ctx.p + 7) === 45) {
|
|
302
|
+
return parseDate(ctx, c, end);
|
|
303
|
+
}
|
|
304
|
+
if (ctx.s.charCodeAt(ctx.p + 2) === 58) {
|
|
305
|
+
return parseTime(ctx, c, end);
|
|
306
|
+
}
|
|
307
|
+
return parseNumber(ctx, ctx.p, c, 0, end);
|
|
308
|
+
}
|
|
309
|
+
function parseNumber(ctx, startPtr, startChr, sign, endChr) {
|
|
310
|
+
let c = startChr;
|
|
311
|
+
let state = 0;
|
|
312
|
+
let hasUnderscores = false;
|
|
313
|
+
if (c === 105) {
|
|
314
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 110 || ctx.s.charCodeAt(++ctx.p) !== 102)
|
|
315
|
+
TomlError.x("invalid value", ctx, startPtr);
|
|
316
|
+
return ctx.p++, (sign || 1) / 0;
|
|
317
|
+
}
|
|
318
|
+
if (c === 110) {
|
|
319
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 110)
|
|
320
|
+
TomlError.x("invalid value", ctx, startPtr);
|
|
321
|
+
return ctx.p++, NaN;
|
|
322
|
+
}
|
|
323
|
+
if (c === 48) {
|
|
324
|
+
if (++ctx.p >= ctx.s.length || isEndOfValue(c = ctx.s.charCodeAt(ctx.p), endChr))
|
|
325
|
+
return ctx.bi === true ? 0n : 0;
|
|
326
|
+
if (!sign) {
|
|
327
|
+
if (c === 120)
|
|
328
|
+
return parseIntegerBaseN(ctx, startPtr, 16, endChr);
|
|
329
|
+
else if (c === 98)
|
|
330
|
+
return parseIntegerBaseN(ctx, startPtr, 2, endChr);
|
|
331
|
+
else if (c === 111)
|
|
332
|
+
return parseIntegerBaseN(ctx, startPtr, 8, endChr);
|
|
333
|
+
}
|
|
334
|
+
if (c === 46)
|
|
335
|
+
state = 2;
|
|
336
|
+
else if (c === 101 || c === 69)
|
|
337
|
+
state = 4;
|
|
338
|
+
else
|
|
339
|
+
TomlError.x("illegal leading zero", ctx, startPtr);
|
|
340
|
+
} else if (!isDigit(c))
|
|
341
|
+
TomlError.x("invalid value", ctx, startPtr);
|
|
342
|
+
while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
|
|
343
|
+
if (!state)
|
|
344
|
+
state = 1;
|
|
345
|
+
if (c === 95) {
|
|
346
|
+
if (!(state & 1))
|
|
347
|
+
TomlError.x("illegal underscore", ctx);
|
|
348
|
+
state += 11;
|
|
349
|
+
hasUnderscores = true;
|
|
350
|
+
} else if (state === 1 && c === 46)
|
|
351
|
+
state = 2;
|
|
352
|
+
else if ((state === 1 || state === 3) && (c === 101 || c === 69))
|
|
353
|
+
state = 4;
|
|
354
|
+
else if (state === 4 && (c === 43 || c === 45)) {
|
|
355
|
+
state = 6;
|
|
356
|
+
} else if (!isDigit(c))
|
|
357
|
+
TomlError.x(`illegal character in numeric literal`, ctx);
|
|
358
|
+
else if (state > 9)
|
|
359
|
+
state -= 11;
|
|
360
|
+
else if (!(state & 1))
|
|
361
|
+
state++;
|
|
362
|
+
}
|
|
363
|
+
if (!state) {
|
|
364
|
+
let val = (startChr - 48) * (sign || 1);
|
|
365
|
+
return ctx.bi === true ? BigInt(val) : val;
|
|
366
|
+
}
|
|
367
|
+
if (!(state & 1))
|
|
368
|
+
TomlError.x("unfinished numeric value", ctx, startPtr);
|
|
369
|
+
let str2 = ctx.s.slice(startPtr, ctx.p);
|
|
370
|
+
if (hasUnderscores)
|
|
371
|
+
str2 = str2.replaceAll("_", "");
|
|
372
|
+
return state > 1 ? parseFloat(str2) : parseInteger(ctx, str2, 10, startPtr);
|
|
373
|
+
}
|
|
374
|
+
function parseIntegerBaseN(ctx, startPtr, base, endChr) {
|
|
375
|
+
let c, underscore = 1;
|
|
376
|
+
while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
|
|
377
|
+
if (c === 95) {
|
|
378
|
+
if (underscore & 1)
|
|
379
|
+
TomlError.x("illegal underscore", ctx);
|
|
380
|
+
underscore = 3;
|
|
381
|
+
} else if (!isDigit(c, base))
|
|
382
|
+
TomlError.x(`illegal character in numeric literal`, ctx);
|
|
383
|
+
else if (underscore & 1)
|
|
384
|
+
underscore--;
|
|
385
|
+
}
|
|
386
|
+
if (underscore & 1)
|
|
387
|
+
TomlError.x("unfinished numeric value", ctx);
|
|
388
|
+
let str2 = ctx.s.slice(startPtr + 2, ctx.p);
|
|
389
|
+
if (underscore)
|
|
390
|
+
str2 = str2.replaceAll("_", "");
|
|
391
|
+
return parseInteger(ctx, str2, base, startPtr);
|
|
392
|
+
}
|
|
393
|
+
function parseInteger(ctx, str2, base, startPtr) {
|
|
394
|
+
if (ctx.bi !== true)
|
|
395
|
+
int: {
|
|
396
|
+
let val = parseInt(str2, base);
|
|
397
|
+
if (!Number.isSafeInteger(val)) {
|
|
398
|
+
if (ctx.bi)
|
|
399
|
+
break int;
|
|
400
|
+
TomlError.x("integer value cannot be represented losslessly", ctx, startPtr);
|
|
401
|
+
}
|
|
402
|
+
return val;
|
|
403
|
+
}
|
|
404
|
+
return base === 10 ? BigInt(str2) : BigInt((base === 2 ? "0b" : base === 8 ? "0o" : "0x") + str2);
|
|
405
|
+
}
|
|
406
|
+
function parseDate(ctx, c, endChr) {
|
|
407
|
+
let startPtr = ctx.p++, unsafeSeparator;
|
|
408
|
+
if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(ctx.p++)) || !isDigit(ctx.s.charCodeAt(ctx.p++)) || !isDigit(ctx.s.charCodeAt(ctx.p++))) {
|
|
409
|
+
return parseNumber(ctx, ctx.p = startPtr, c, 0, endChr);
|
|
410
|
+
}
|
|
411
|
+
ctx.p += 5;
|
|
412
|
+
if (!isDigit(ctx.s.charCodeAt(ctx.p++)))
|
|
413
|
+
TomlError.x("invalid date-time: date part is malformed", ctx, startPtr);
|
|
414
|
+
if (ctx.p >= ctx.s.length || ((c = ctx.s.charCodeAt(ctx.p)) !== 32 || (unsafeSeparator = true, !isDigit(ctx.s.charCodeAt(ctx.p + 1)))) && c !== 84 && c !== 116) {
|
|
415
|
+
let t2 = ctx.s.slice(startPtr, ctx.p);
|
|
416
|
+
return readDate(ctx, t2, 3, false, startPtr);
|
|
417
|
+
}
|
|
418
|
+
if (ctx.s.charCodeAt(ctx.p += 3) !== 58)
|
|
419
|
+
TomlError.x("invalid date-time: time part is malformed", ctx, startPtr);
|
|
420
|
+
if (ctx.s.charCodeAt(ctx.p += 3) === 58)
|
|
421
|
+
ctx.p += 3;
|
|
422
|
+
if (ctx.s.charCodeAt(ctx.p) === 46)
|
|
423
|
+
while (isDigit(ctx.s.charCodeAt(++ctx.p)))
|
|
424
|
+
;
|
|
425
|
+
if (c = ctx.s.charCodeAt(ctx.p)) {
|
|
426
|
+
if (c === 90 || c === 122) {
|
|
427
|
+
let t2 = ctx.s.slice(startPtr, ++ctx.p);
|
|
428
|
+
return readDate(ctx, t2, 1, unsafeSeparator, startPtr, "[+00:00]");
|
|
429
|
+
}
|
|
430
|
+
if (c === 43 || c === 45) {
|
|
431
|
+
let t2 = ctx.s.slice(startPtr, ctx.p += 6);
|
|
432
|
+
return readDate(ctx, t2, 1, unsafeSeparator, startPtr, !ctx.ld && "[" + ctx.s.slice(ctx.p - 6, ctx.p) + "]");
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
let t = ctx.s.slice(startPtr, ctx.p);
|
|
436
|
+
return readDate(ctx, t, 2, unsafeSeparator, startPtr);
|
|
437
|
+
}
|
|
438
|
+
function parseTime(ctx, c, endChr) {
|
|
439
|
+
let start = ctx.p;
|
|
440
|
+
if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(++ctx.p))) {
|
|
441
|
+
return parseNumber(ctx, --ctx.p, c, 0, endChr);
|
|
442
|
+
}
|
|
443
|
+
if (ctx.s.charCodeAt(ctx.p += 4) === 58)
|
|
444
|
+
ctx.p += 3;
|
|
445
|
+
if (ctx.s.charCodeAt(ctx.p) === 46)
|
|
446
|
+
while (isDigit(ctx.s.charCodeAt(++ctx.p)))
|
|
447
|
+
;
|
|
448
|
+
let t = ctx.s.slice(start, ctx.p);
|
|
449
|
+
return readDate(ctx, t, 4, false, start);
|
|
450
|
+
}
|
|
451
|
+
function readDate(ctx, str2, type2, unsafeDelim, errPtr, temporalSuffix) {
|
|
452
|
+
if (ctx.ld) {
|
|
453
|
+
let date = new TomlDate(str2, type2, unsafeDelim);
|
|
454
|
+
if (!date.isValid())
|
|
455
|
+
TomlError.x("invalid date", ctx, errPtr);
|
|
456
|
+
return date;
|
|
457
|
+
}
|
|
458
|
+
try {
|
|
459
|
+
if (temporalSuffix)
|
|
460
|
+
str2 += temporalSuffix;
|
|
461
|
+
switch (type2) {
|
|
462
|
+
case 1:
|
|
463
|
+
return Temporal.ZonedDateTime.from(str2);
|
|
464
|
+
case 2:
|
|
465
|
+
return Temporal.PlainDateTime.from(str2);
|
|
466
|
+
case 3:
|
|
467
|
+
return Temporal.PlainDate.from(str2);
|
|
468
|
+
case 4:
|
|
469
|
+
return Temporal.PlainTime.from(str2);
|
|
470
|
+
}
|
|
471
|
+
} catch (e) {
|
|
472
|
+
TomlError.x(e instanceof Error ? e.message : "" + e, ctx, errPtr);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// node_modules/smol-toml/dist/util.js
|
|
477
|
+
function skipComment(ctx) {
|
|
478
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
479
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
480
|
+
if (c === 10)
|
|
481
|
+
break;
|
|
482
|
+
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
483
|
+
ctx.p++;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
if (c < 32 && c !== 9 || c === 127) {
|
|
487
|
+
TomlError.x("control characters are not allowed in comments", ctx);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function skipVoid(ctx, banNewLines, banComments) {
|
|
492
|
+
let c;
|
|
493
|
+
while (ctx.p < ctx.s.length) {
|
|
494
|
+
while (ctx.p < ctx.s.length && ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)))
|
|
495
|
+
ctx.p++;
|
|
496
|
+
if (banComments || c !== 35)
|
|
497
|
+
break;
|
|
498
|
+
skipComment(ctx);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// node_modules/smol-toml/dist/struct.js
|
|
503
|
+
function parseKey(ctx, end = 61) {
|
|
504
|
+
let startPtr;
|
|
505
|
+
let state = 0;
|
|
506
|
+
let parsed = [];
|
|
507
|
+
let sliceStart;
|
|
508
|
+
let c = ctx.s.charCodeAt(startPtr = ctx.p);
|
|
509
|
+
do {
|
|
510
|
+
if (c === end) {
|
|
511
|
+
if (!state)
|
|
512
|
+
TomlError.x("unexpected end of key", ctx);
|
|
513
|
+
if (state === 1)
|
|
514
|
+
parsed.push(ctx.s.slice(sliceStart, ctx.p));
|
|
515
|
+
return ctx.p++, parsed;
|
|
516
|
+
} else if (c === 46) {
|
|
517
|
+
if (!state)
|
|
518
|
+
TomlError.x("illegal empty bare key", ctx);
|
|
519
|
+
if (state === 1)
|
|
520
|
+
parsed.push(ctx.s.slice(sliceStart, ctx.p));
|
|
521
|
+
state = 0;
|
|
522
|
+
} else if (!state && (c === 34 || c === 39)) {
|
|
523
|
+
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2))
|
|
524
|
+
TomlError.x("illegal quoted key: multiline strings are not allowed", ctx);
|
|
525
|
+
parsed.push(parseString(ctx));
|
|
526
|
+
state = 2;
|
|
527
|
+
ctx.p--;
|
|
528
|
+
} else if (c === 32 || c === 9) {
|
|
529
|
+
if (state === 1) {
|
|
530
|
+
parsed.push(ctx.s.slice(sliceStart, ctx.p));
|
|
531
|
+
state = 2;
|
|
532
|
+
}
|
|
533
|
+
} else if (state === 2 || c < 48 && c !== 45 || c > 57 && c < 65 || c > 90 && c < 97 && c !== 95 || c > 122) {
|
|
534
|
+
TomlError.x("illegal character in key", ctx);
|
|
535
|
+
} else if (!state) {
|
|
536
|
+
state = 1;
|
|
537
|
+
sliceStart = ctx.p;
|
|
538
|
+
}
|
|
539
|
+
} while (c = ctx.s.charCodeAt(++ctx.p));
|
|
540
|
+
TomlError.x("incomplete key-value: cannot find end of key", ctx, startPtr);
|
|
541
|
+
}
|
|
542
|
+
function parseInlineTable(ctx) {
|
|
543
|
+
let startPtr = ctx.p++;
|
|
544
|
+
let res = /* @__PURE__ */ Object.create(null);
|
|
545
|
+
let seen = /* @__PURE__ */ new Set();
|
|
546
|
+
let c;
|
|
547
|
+
while (ctx.p < ctx.s.length) {
|
|
548
|
+
skipVoid(ctx);
|
|
549
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
550
|
+
ctx.p++;
|
|
551
|
+
return res;
|
|
552
|
+
}
|
|
553
|
+
let k;
|
|
554
|
+
let t = res;
|
|
555
|
+
let hasOwn = false;
|
|
556
|
+
let errPtr = ctx.p;
|
|
557
|
+
let key = parseKey(ctx);
|
|
558
|
+
for (let i2 = 0; i2 < key.length; i2++) {
|
|
559
|
+
if (i2)
|
|
560
|
+
t = hasOwn ? t[k] : t[k] = /* @__PURE__ */ Object.create(null);
|
|
561
|
+
k = key[i2];
|
|
562
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
563
|
+
TomlError.x("trying to redefine an already defined value", ctx, errPtr);
|
|
564
|
+
}
|
|
565
|
+
let unsafe = k === "__proto__";
|
|
566
|
+
if (ctx.uk && (unsafe || k === "constructor")) {
|
|
567
|
+
t = ctx.uk !== 1 && TomlError.x("document contains an unsafe property", ctx, errPtr);
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
if (!hasOwn && unsafe) {
|
|
571
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (hasOwn) {
|
|
575
|
+
TomlError.x("trying to redefine an already defined value", ctx, errPtr);
|
|
576
|
+
}
|
|
577
|
+
skipVoid(ctx, true, true);
|
|
578
|
+
let value = extractValue(
|
|
579
|
+
ctx,
|
|
580
|
+
125
|
|
581
|
+
/* } */
|
|
582
|
+
);
|
|
583
|
+
if (t && typeof (t[k] = value) === "object")
|
|
584
|
+
seen.add(value);
|
|
585
|
+
skipVoid(ctx);
|
|
586
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
|
|
587
|
+
return res;
|
|
588
|
+
}
|
|
589
|
+
if (c !== 44)
|
|
590
|
+
TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
|
|
591
|
+
}
|
|
592
|
+
TomlError.x("unfinished table", ctx, startPtr);
|
|
593
|
+
}
|
|
594
|
+
function parseArray(ctx) {
|
|
595
|
+
let startPtr = ctx.p++;
|
|
596
|
+
let res = [];
|
|
597
|
+
let c;
|
|
598
|
+
while (ctx.p < ctx.s.length) {
|
|
599
|
+
skipVoid(ctx);
|
|
600
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
601
|
+
ctx.p++;
|
|
602
|
+
return res;
|
|
603
|
+
}
|
|
604
|
+
res.push(extractValue(
|
|
605
|
+
ctx,
|
|
606
|
+
93
|
|
607
|
+
/* ] */
|
|
608
|
+
));
|
|
609
|
+
skipVoid(ctx);
|
|
610
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
|
|
611
|
+
return res;
|
|
612
|
+
}
|
|
613
|
+
if (c !== 44)
|
|
614
|
+
TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
|
|
615
|
+
}
|
|
616
|
+
TomlError.x("unfinished array", ctx, startPtr);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// node_modules/smol-toml/dist/parse.js
|
|
620
|
+
function peekTable(ctx, key, table, meta, type2) {
|
|
621
|
+
let t = table;
|
|
622
|
+
let m = meta;
|
|
623
|
+
let k;
|
|
624
|
+
let hasOwn = false;
|
|
625
|
+
let state;
|
|
626
|
+
for (let i2 = 0; i2 < key.length; i2++) {
|
|
627
|
+
if (i2) {
|
|
628
|
+
t = hasOwn ? t[k] : t[k] = /* @__PURE__ */ Object.create(null);
|
|
629
|
+
m = (state = m[k]).c;
|
|
630
|
+
if (type2 === 0 && (state.t === 1 || state.t === 2)) {
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
if (state.t === 2) {
|
|
634
|
+
let l = t.length - 1;
|
|
635
|
+
t = t[l];
|
|
636
|
+
m = m[l].c;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
k = key[i2];
|
|
640
|
+
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
643
|
+
if (!hasOwn) {
|
|
644
|
+
let unsafe = k === "__proto__";
|
|
645
|
+
if (ctx.uk && (unsafe || k === "constructor"))
|
|
646
|
+
return false;
|
|
647
|
+
if (unsafe) {
|
|
648
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
649
|
+
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
|
|
650
|
+
}
|
|
651
|
+
m[k] = {
|
|
652
|
+
t: i2 < key.length - 1 && type2 === 2 ? 3 : type2,
|
|
653
|
+
d: false,
|
|
654
|
+
i: 0,
|
|
655
|
+
c: /* @__PURE__ */ Object.create(null)
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
state = m[k];
|
|
660
|
+
if (state.t !== type2 && !(type2 === 1 && state.t === 3)) {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
if (type2 === 2) {
|
|
664
|
+
if (!state.d) {
|
|
665
|
+
state.d = true;
|
|
666
|
+
t[k] = [];
|
|
667
|
+
}
|
|
668
|
+
t[k].push(t = /* @__PURE__ */ Object.create(null));
|
|
669
|
+
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: /* @__PURE__ */ Object.create(null) };
|
|
670
|
+
}
|
|
671
|
+
if (state.d) {
|
|
672
|
+
return null;
|
|
673
|
+
}
|
|
674
|
+
state.d = true;
|
|
675
|
+
if (type2 === 1) {
|
|
676
|
+
t = hasOwn ? t[k] : t[k] = /* @__PURE__ */ Object.create(null);
|
|
677
|
+
} else if (type2 === 0 && hasOwn) {
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
return [k, t, state.c];
|
|
681
|
+
}
|
|
682
|
+
function validateTablePeek(ctx, peek, ptr) {
|
|
683
|
+
if (peek === null || ctx.uk === 2)
|
|
684
|
+
TomlError.x(peek === null ? "trying to redefine an already defined table or value" : "document contains an unsafe property", ctx, ptr);
|
|
685
|
+
}
|
|
686
|
+
function parse(toml, options = {}) {
|
|
687
|
+
let ctx = {
|
|
688
|
+
s: toml,
|
|
689
|
+
p: 0,
|
|
690
|
+
d: options.maxDepth ?? 1e3,
|
|
691
|
+
bi: options.integersAsBigInt ?? false,
|
|
692
|
+
ld: options.useLegacyDate ?? true,
|
|
693
|
+
uk: options.unsafeKeyBehaviour === "throw" ? 2 : options.unsafeKeyBehaviour === "drop" ? 1 : 0
|
|
694
|
+
};
|
|
695
|
+
let res = /* @__PURE__ */ Object.create(null);
|
|
696
|
+
let meta = /* @__PURE__ */ Object.create(null);
|
|
697
|
+
let tmp;
|
|
698
|
+
let skipping = false;
|
|
699
|
+
let tbl = res;
|
|
700
|
+
let m = meta;
|
|
701
|
+
if (toml.charCodeAt(0) === 65279)
|
|
702
|
+
ctx.p++;
|
|
703
|
+
skipVoid(ctx);
|
|
704
|
+
while (ctx.p < toml.length) {
|
|
705
|
+
if (toml.charCodeAt(ctx.p) === 91) {
|
|
706
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
707
|
+
tmp = ctx.p += +isTableArray;
|
|
708
|
+
skipping = false;
|
|
709
|
+
let k = parseKey(
|
|
710
|
+
ctx,
|
|
711
|
+
93
|
|
712
|
+
/* ] */
|
|
713
|
+
);
|
|
714
|
+
if (isTableArray) {
|
|
715
|
+
if (toml.charCodeAt(ctx.p) !== 93) {
|
|
716
|
+
TomlError.x("expected end of table array declaration", ctx);
|
|
717
|
+
}
|
|
718
|
+
ctx.p++;
|
|
719
|
+
}
|
|
720
|
+
let p = peekTable(
|
|
721
|
+
ctx,
|
|
722
|
+
k,
|
|
723
|
+
res,
|
|
724
|
+
meta,
|
|
725
|
+
isTableArray ? 2 : 1
|
|
726
|
+
/* Type.EXPLICIT */
|
|
727
|
+
);
|
|
728
|
+
if (!p) {
|
|
729
|
+
validateTablePeek(ctx, p, tmp);
|
|
730
|
+
skipping = true;
|
|
731
|
+
} else {
|
|
732
|
+
m = p[2];
|
|
733
|
+
tbl = p[1];
|
|
734
|
+
}
|
|
735
|
+
} else {
|
|
736
|
+
tmp = ctx.p;
|
|
737
|
+
let k = parseKey(ctx);
|
|
738
|
+
let p = peekTable(
|
|
739
|
+
ctx,
|
|
740
|
+
k,
|
|
741
|
+
tbl,
|
|
742
|
+
m,
|
|
743
|
+
0
|
|
744
|
+
/* Type.DOTTED */
|
|
745
|
+
);
|
|
746
|
+
if (!p && !skipping)
|
|
747
|
+
validateTablePeek(ctx, p, tmp);
|
|
748
|
+
skipVoid(ctx, true, true);
|
|
749
|
+
let v = extractValue(ctx, void 0);
|
|
750
|
+
if (p && !skipping)
|
|
751
|
+
p[1][p[0]] = v;
|
|
752
|
+
}
|
|
753
|
+
skipVoid(ctx, true);
|
|
754
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && (tmp !== 13 || toml.charCodeAt(ctx.p + 1) !== 10)) {
|
|
755
|
+
TomlError.x("each key-value declaration must be followed by an end-of-line", ctx);
|
|
756
|
+
}
|
|
757
|
+
skipVoid(ctx);
|
|
758
|
+
}
|
|
759
|
+
return res;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// node_modules/smol-toml/dist/stringify.js
|
|
763
|
+
var HAS_WELLFORMED = !!"".isWellFormed;
|
|
764
|
+
|
|
765
|
+
// src/data.ts
|
|
766
|
+
import fs3 from "node:fs";
|
|
767
|
+
import path3 from "node:path";
|
|
768
|
+
|
|
769
|
+
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
770
|
+
function isNothing(subject) {
|
|
771
|
+
return typeof subject === "undefined" || subject === null;
|
|
772
|
+
}
|
|
773
|
+
function isObject(subject) {
|
|
774
|
+
return typeof subject === "object" && subject !== null;
|
|
775
|
+
}
|
|
776
|
+
function toArray(sequence) {
|
|
777
|
+
if (Array.isArray(sequence)) return sequence;
|
|
778
|
+
else if (isNothing(sequence)) return [];
|
|
779
|
+
return [sequence];
|
|
780
|
+
}
|
|
781
|
+
function extend(target, source) {
|
|
782
|
+
var index, length, key, sourceKeys;
|
|
783
|
+
if (source) {
|
|
784
|
+
sourceKeys = Object.keys(source);
|
|
785
|
+
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
786
|
+
key = sourceKeys[index];
|
|
787
|
+
target[key] = source[key];
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return target;
|
|
791
|
+
}
|
|
792
|
+
function repeat(string, count) {
|
|
793
|
+
var result = "", cycle;
|
|
794
|
+
for (cycle = 0; cycle < count; cycle += 1) {
|
|
795
|
+
result += string;
|
|
796
|
+
}
|
|
797
|
+
return result;
|
|
798
|
+
}
|
|
799
|
+
function isNegativeZero(number) {
|
|
800
|
+
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
801
|
+
}
|
|
802
|
+
var isNothing_1 = isNothing;
|
|
803
|
+
var isObject_1 = isObject;
|
|
804
|
+
var toArray_1 = toArray;
|
|
805
|
+
var repeat_1 = repeat;
|
|
806
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
807
|
+
var extend_1 = extend;
|
|
808
|
+
var common = {
|
|
809
|
+
isNothing: isNothing_1,
|
|
810
|
+
isObject: isObject_1,
|
|
811
|
+
toArray: toArray_1,
|
|
812
|
+
repeat: repeat_1,
|
|
813
|
+
isNegativeZero: isNegativeZero_1,
|
|
814
|
+
extend: extend_1
|
|
815
|
+
};
|
|
816
|
+
function formatError(exception2, compact) {
|
|
817
|
+
var where = "", message = exception2.reason || "(unknown reason)";
|
|
818
|
+
if (!exception2.mark) return message;
|
|
819
|
+
if (exception2.mark.name) {
|
|
820
|
+
where += 'in "' + exception2.mark.name + '" ';
|
|
821
|
+
}
|
|
822
|
+
where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
|
|
823
|
+
if (!compact && exception2.mark.snippet) {
|
|
824
|
+
where += "\n\n" + exception2.mark.snippet;
|
|
825
|
+
}
|
|
826
|
+
return message + " " + where;
|
|
827
|
+
}
|
|
828
|
+
function YAMLException$1(reason, mark) {
|
|
829
|
+
Error.call(this);
|
|
830
|
+
this.name = "YAMLException";
|
|
831
|
+
this.reason = reason;
|
|
832
|
+
this.mark = mark;
|
|
833
|
+
this.message = formatError(this, false);
|
|
834
|
+
if (Error.captureStackTrace) {
|
|
835
|
+
Error.captureStackTrace(this, this.constructor);
|
|
836
|
+
} else {
|
|
837
|
+
this.stack = new Error().stack || "";
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
841
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
842
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
843
|
+
return this.name + ": " + formatError(this, compact);
|
|
844
|
+
};
|
|
845
|
+
var exception = YAMLException$1;
|
|
846
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
847
|
+
var head = "";
|
|
848
|
+
var tail = "";
|
|
849
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
850
|
+
if (position - lineStart > maxHalfLength) {
|
|
851
|
+
head = " ... ";
|
|
852
|
+
lineStart = position - maxHalfLength + head.length;
|
|
853
|
+
}
|
|
854
|
+
if (lineEnd - position > maxHalfLength) {
|
|
855
|
+
tail = " ...";
|
|
856
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
857
|
+
}
|
|
858
|
+
return {
|
|
859
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
860
|
+
pos: position - lineStart + head.length
|
|
861
|
+
// relative position
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
function padStart(string, max) {
|
|
865
|
+
return common.repeat(" ", max - string.length) + string;
|
|
866
|
+
}
|
|
867
|
+
function makeSnippet(mark, options) {
|
|
868
|
+
options = Object.create(options || null);
|
|
869
|
+
if (!mark.buffer) return null;
|
|
870
|
+
if (!options.maxLength) options.maxLength = 79;
|
|
871
|
+
if (typeof options.indent !== "number") options.indent = 1;
|
|
872
|
+
if (typeof options.linesBefore !== "number") options.linesBefore = 3;
|
|
873
|
+
if (typeof options.linesAfter !== "number") options.linesAfter = 2;
|
|
874
|
+
var re = /\r?\n|\r|\0/g;
|
|
875
|
+
var lineStarts = [0];
|
|
876
|
+
var lineEnds = [];
|
|
877
|
+
var match;
|
|
878
|
+
var foundLineNo = -1;
|
|
879
|
+
while (match = re.exec(mark.buffer)) {
|
|
880
|
+
lineEnds.push(match.index);
|
|
881
|
+
lineStarts.push(match.index + match[0].length);
|
|
882
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
883
|
+
foundLineNo = lineStarts.length - 2;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
887
|
+
var result = "", i2, line;
|
|
888
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
889
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
890
|
+
for (i2 = 1; i2 <= options.linesBefore; i2++) {
|
|
891
|
+
if (foundLineNo - i2 < 0) break;
|
|
892
|
+
line = getLine(
|
|
893
|
+
mark.buffer,
|
|
894
|
+
lineStarts[foundLineNo - i2],
|
|
895
|
+
lineEnds[foundLineNo - i2],
|
|
896
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i2]),
|
|
897
|
+
maxLineLength
|
|
898
|
+
);
|
|
899
|
+
result = common.repeat(" ", options.indent) + padStart((mark.line - i2 + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
|
|
900
|
+
}
|
|
901
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
902
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
903
|
+
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
|
|
904
|
+
for (i2 = 1; i2 <= options.linesAfter; i2++) {
|
|
905
|
+
if (foundLineNo + i2 >= lineEnds.length) break;
|
|
906
|
+
line = getLine(
|
|
907
|
+
mark.buffer,
|
|
908
|
+
lineStarts[foundLineNo + i2],
|
|
909
|
+
lineEnds[foundLineNo + i2],
|
|
910
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i2]),
|
|
911
|
+
maxLineLength
|
|
912
|
+
);
|
|
913
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + i2 + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
914
|
+
}
|
|
915
|
+
return result.replace(/\n$/, "");
|
|
916
|
+
}
|
|
917
|
+
var snippet = makeSnippet;
|
|
918
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
919
|
+
"kind",
|
|
920
|
+
"multi",
|
|
921
|
+
"resolve",
|
|
922
|
+
"construct",
|
|
923
|
+
"instanceOf",
|
|
924
|
+
"predicate",
|
|
925
|
+
"represent",
|
|
926
|
+
"representName",
|
|
927
|
+
"defaultStyle",
|
|
928
|
+
"styleAliases"
|
|
929
|
+
];
|
|
930
|
+
var YAML_NODE_KINDS = [
|
|
931
|
+
"scalar",
|
|
932
|
+
"sequence",
|
|
933
|
+
"mapping"
|
|
934
|
+
];
|
|
935
|
+
function compileStyleAliases(map2) {
|
|
936
|
+
var result = {};
|
|
937
|
+
if (map2 !== null) {
|
|
938
|
+
Object.keys(map2).forEach(function(style) {
|
|
939
|
+
map2[style].forEach(function(alias) {
|
|
940
|
+
result[String(alias)] = style;
|
|
941
|
+
});
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
return result;
|
|
945
|
+
}
|
|
946
|
+
function Type$1(tag, options) {
|
|
947
|
+
options = options || {};
|
|
948
|
+
Object.keys(options).forEach(function(name) {
|
|
949
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
950
|
+
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
951
|
+
}
|
|
952
|
+
});
|
|
953
|
+
this.options = options;
|
|
954
|
+
this.tag = tag;
|
|
955
|
+
this.kind = options["kind"] || null;
|
|
956
|
+
this.resolve = options["resolve"] || function() {
|
|
957
|
+
return true;
|
|
958
|
+
};
|
|
959
|
+
this.construct = options["construct"] || function(data) {
|
|
960
|
+
return data;
|
|
961
|
+
};
|
|
962
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
963
|
+
this.predicate = options["predicate"] || null;
|
|
964
|
+
this.represent = options["represent"] || null;
|
|
965
|
+
this.representName = options["representName"] || null;
|
|
966
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
967
|
+
this.multi = options["multi"] || false;
|
|
968
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
969
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
970
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
var type = Type$1;
|
|
974
|
+
function compileList(schema2, name) {
|
|
975
|
+
var result = [];
|
|
976
|
+
schema2[name].forEach(function(currentType) {
|
|
977
|
+
var newIndex = result.length;
|
|
978
|
+
result.forEach(function(previousType, previousIndex) {
|
|
979
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
980
|
+
newIndex = previousIndex;
|
|
981
|
+
}
|
|
982
|
+
});
|
|
983
|
+
result[newIndex] = currentType;
|
|
984
|
+
});
|
|
985
|
+
return result;
|
|
986
|
+
}
|
|
987
|
+
function compileMap() {
|
|
988
|
+
var result = {
|
|
989
|
+
scalar: {},
|
|
990
|
+
sequence: {},
|
|
991
|
+
mapping: {},
|
|
992
|
+
fallback: {},
|
|
993
|
+
multi: {
|
|
994
|
+
scalar: [],
|
|
995
|
+
sequence: [],
|
|
996
|
+
mapping: [],
|
|
997
|
+
fallback: []
|
|
998
|
+
}
|
|
999
|
+
}, index, length;
|
|
1000
|
+
function collectType(type2) {
|
|
1001
|
+
if (type2.multi) {
|
|
1002
|
+
result.multi[type2.kind].push(type2);
|
|
1003
|
+
result.multi["fallback"].push(type2);
|
|
1004
|
+
} else {
|
|
1005
|
+
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
1009
|
+
arguments[index].forEach(collectType);
|
|
1010
|
+
}
|
|
1011
|
+
return result;
|
|
1012
|
+
}
|
|
1013
|
+
function Schema$1(definition) {
|
|
1014
|
+
return this.extend(definition);
|
|
1015
|
+
}
|
|
1016
|
+
Schema$1.prototype.extend = function extend2(definition) {
|
|
1017
|
+
var implicit = [];
|
|
1018
|
+
var explicit = [];
|
|
1019
|
+
if (definition instanceof type) {
|
|
1020
|
+
explicit.push(definition);
|
|
1021
|
+
} else if (Array.isArray(definition)) {
|
|
1022
|
+
explicit = explicit.concat(definition);
|
|
1023
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
1024
|
+
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
|
1025
|
+
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
|
1026
|
+
} else {
|
|
1027
|
+
throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
1028
|
+
}
|
|
1029
|
+
implicit.forEach(function(type$1) {
|
|
1030
|
+
if (!(type$1 instanceof type)) {
|
|
1031
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
1032
|
+
}
|
|
1033
|
+
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
1034
|
+
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
1035
|
+
}
|
|
1036
|
+
if (type$1.multi) {
|
|
1037
|
+
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
explicit.forEach(function(type$1) {
|
|
1041
|
+
if (!(type$1 instanceof type)) {
|
|
1042
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
var result = Object.create(Schema$1.prototype);
|
|
1046
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
1047
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
1048
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
1049
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
1050
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
1051
|
+
return result;
|
|
1052
|
+
};
|
|
1053
|
+
var schema = Schema$1;
|
|
1054
|
+
var str = new type("tag:yaml.org,2002:str", {
|
|
1055
|
+
kind: "scalar",
|
|
1056
|
+
construct: function(data) {
|
|
1057
|
+
return data !== null ? data : "";
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
var seq = new type("tag:yaml.org,2002:seq", {
|
|
1061
|
+
kind: "sequence",
|
|
1062
|
+
construct: function(data) {
|
|
1063
|
+
return data !== null ? data : [];
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
var map = new type("tag:yaml.org,2002:map", {
|
|
1067
|
+
kind: "mapping",
|
|
1068
|
+
construct: function(data) {
|
|
1069
|
+
return data !== null ? data : {};
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
var failsafe = new schema({
|
|
1073
|
+
explicit: [
|
|
1074
|
+
str,
|
|
1075
|
+
seq,
|
|
1076
|
+
map
|
|
1077
|
+
]
|
|
1078
|
+
});
|
|
1079
|
+
function resolveYamlNull(data) {
|
|
1080
|
+
if (data === null) return true;
|
|
1081
|
+
var max = data.length;
|
|
1082
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
1083
|
+
}
|
|
1084
|
+
function constructYamlNull() {
|
|
1085
|
+
return null;
|
|
1086
|
+
}
|
|
1087
|
+
function isNull(object) {
|
|
1088
|
+
return object === null;
|
|
1089
|
+
}
|
|
1090
|
+
var _null = new type("tag:yaml.org,2002:null", {
|
|
1091
|
+
kind: "scalar",
|
|
1092
|
+
resolve: resolveYamlNull,
|
|
1093
|
+
construct: constructYamlNull,
|
|
1094
|
+
predicate: isNull,
|
|
1095
|
+
represent: {
|
|
1096
|
+
canonical: function() {
|
|
1097
|
+
return "~";
|
|
1098
|
+
},
|
|
1099
|
+
lowercase: function() {
|
|
1100
|
+
return "null";
|
|
1101
|
+
},
|
|
1102
|
+
uppercase: function() {
|
|
1103
|
+
return "NULL";
|
|
1104
|
+
},
|
|
1105
|
+
camelcase: function() {
|
|
1106
|
+
return "Null";
|
|
1107
|
+
},
|
|
1108
|
+
empty: function() {
|
|
1109
|
+
return "";
|
|
1110
|
+
}
|
|
1111
|
+
},
|
|
1112
|
+
defaultStyle: "lowercase"
|
|
1113
|
+
});
|
|
1114
|
+
function resolveYamlBoolean(data) {
|
|
1115
|
+
if (data === null) return false;
|
|
1116
|
+
var max = data.length;
|
|
1117
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
1118
|
+
}
|
|
1119
|
+
function constructYamlBoolean(data) {
|
|
1120
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
1121
|
+
}
|
|
1122
|
+
function isBoolean(object) {
|
|
1123
|
+
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
1124
|
+
}
|
|
1125
|
+
var bool = new type("tag:yaml.org,2002:bool", {
|
|
1126
|
+
kind: "scalar",
|
|
1127
|
+
resolve: resolveYamlBoolean,
|
|
1128
|
+
construct: constructYamlBoolean,
|
|
1129
|
+
predicate: isBoolean,
|
|
1130
|
+
represent: {
|
|
1131
|
+
lowercase: function(object) {
|
|
1132
|
+
return object ? "true" : "false";
|
|
1133
|
+
},
|
|
1134
|
+
uppercase: function(object) {
|
|
1135
|
+
return object ? "TRUE" : "FALSE";
|
|
1136
|
+
},
|
|
1137
|
+
camelcase: function(object) {
|
|
1138
|
+
return object ? "True" : "False";
|
|
1139
|
+
}
|
|
1140
|
+
},
|
|
1141
|
+
defaultStyle: "lowercase"
|
|
1142
|
+
});
|
|
1143
|
+
function isHexCode(c) {
|
|
1144
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
1145
|
+
}
|
|
1146
|
+
function isOctCode(c) {
|
|
1147
|
+
return 48 <= c && c <= 55;
|
|
1148
|
+
}
|
|
1149
|
+
function isDecCode(c) {
|
|
1150
|
+
return 48 <= c && c <= 57;
|
|
1151
|
+
}
|
|
1152
|
+
function resolveYamlInteger(data) {
|
|
1153
|
+
if (data === null) return false;
|
|
1154
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
1155
|
+
if (!max) return false;
|
|
1156
|
+
ch = data[index];
|
|
1157
|
+
if (ch === "-" || ch === "+") {
|
|
1158
|
+
ch = data[++index];
|
|
1159
|
+
}
|
|
1160
|
+
if (ch === "0") {
|
|
1161
|
+
if (index + 1 === max) return true;
|
|
1162
|
+
ch = data[++index];
|
|
1163
|
+
if (ch === "b") {
|
|
1164
|
+
index++;
|
|
1165
|
+
for (; index < max; index++) {
|
|
1166
|
+
ch = data[index];
|
|
1167
|
+
if (ch === "_") continue;
|
|
1168
|
+
if (ch !== "0" && ch !== "1") return false;
|
|
1169
|
+
hasDigits = true;
|
|
1170
|
+
}
|
|
1171
|
+
return hasDigits && ch !== "_";
|
|
1172
|
+
}
|
|
1173
|
+
if (ch === "x") {
|
|
1174
|
+
index++;
|
|
1175
|
+
for (; index < max; index++) {
|
|
1176
|
+
ch = data[index];
|
|
1177
|
+
if (ch === "_") continue;
|
|
1178
|
+
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
1179
|
+
hasDigits = true;
|
|
1180
|
+
}
|
|
1181
|
+
return hasDigits && ch !== "_";
|
|
1182
|
+
}
|
|
1183
|
+
if (ch === "o") {
|
|
1184
|
+
index++;
|
|
1185
|
+
for (; index < max; index++) {
|
|
1186
|
+
ch = data[index];
|
|
1187
|
+
if (ch === "_") continue;
|
|
1188
|
+
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
1189
|
+
hasDigits = true;
|
|
1190
|
+
}
|
|
1191
|
+
return hasDigits && ch !== "_";
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
if (ch === "_") return false;
|
|
1195
|
+
for (; index < max; index++) {
|
|
1196
|
+
ch = data[index];
|
|
1197
|
+
if (ch === "_") continue;
|
|
1198
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
1199
|
+
return false;
|
|
1200
|
+
}
|
|
1201
|
+
hasDigits = true;
|
|
1202
|
+
}
|
|
1203
|
+
if (!hasDigits || ch === "_") return false;
|
|
1204
|
+
return true;
|
|
1205
|
+
}
|
|
1206
|
+
function constructYamlInteger(data) {
|
|
1207
|
+
var value = data, sign = 1, ch;
|
|
1208
|
+
if (value.indexOf("_") !== -1) {
|
|
1209
|
+
value = value.replace(/_/g, "");
|
|
1210
|
+
}
|
|
1211
|
+
ch = value[0];
|
|
1212
|
+
if (ch === "-" || ch === "+") {
|
|
1213
|
+
if (ch === "-") sign = -1;
|
|
1214
|
+
value = value.slice(1);
|
|
1215
|
+
ch = value[0];
|
|
1216
|
+
}
|
|
1217
|
+
if (value === "0") return 0;
|
|
1218
|
+
if (ch === "0") {
|
|
1219
|
+
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
1220
|
+
if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
|
|
1221
|
+
if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
|
|
1222
|
+
}
|
|
1223
|
+
return sign * parseInt(value, 10);
|
|
1224
|
+
}
|
|
1225
|
+
function isInteger(object) {
|
|
1226
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
1227
|
+
}
|
|
1228
|
+
var int = new type("tag:yaml.org,2002:int", {
|
|
1229
|
+
kind: "scalar",
|
|
1230
|
+
resolve: resolveYamlInteger,
|
|
1231
|
+
construct: constructYamlInteger,
|
|
1232
|
+
predicate: isInteger,
|
|
1233
|
+
represent: {
|
|
1234
|
+
binary: function(obj) {
|
|
1235
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
1236
|
+
},
|
|
1237
|
+
octal: function(obj) {
|
|
1238
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
1239
|
+
},
|
|
1240
|
+
decimal: function(obj) {
|
|
1241
|
+
return obj.toString(10);
|
|
1242
|
+
},
|
|
1243
|
+
/* eslint-disable max-len */
|
|
1244
|
+
hexadecimal: function(obj) {
|
|
1245
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
1246
|
+
}
|
|
1247
|
+
},
|
|
1248
|
+
defaultStyle: "decimal",
|
|
1249
|
+
styleAliases: {
|
|
1250
|
+
binary: [2, "bin"],
|
|
1251
|
+
octal: [8, "oct"],
|
|
1252
|
+
decimal: [10, "dec"],
|
|
1253
|
+
hexadecimal: [16, "hex"]
|
|
1254
|
+
}
|
|
1255
|
+
});
|
|
1256
|
+
var YAML_FLOAT_PATTERN = new RegExp(
|
|
1257
|
+
// 2.5e4, 2.5 and integers
|
|
1258
|
+
"^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
|
|
1259
|
+
);
|
|
1260
|
+
function resolveYamlFloat(data) {
|
|
1261
|
+
if (data === null) return false;
|
|
1262
|
+
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
1263
|
+
// Probably should update regexp & check speed
|
|
1264
|
+
data[data.length - 1] === "_") {
|
|
1265
|
+
return false;
|
|
1266
|
+
}
|
|
1267
|
+
return true;
|
|
1268
|
+
}
|
|
1269
|
+
function constructYamlFloat(data) {
|
|
1270
|
+
var value, sign;
|
|
1271
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
1272
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
1273
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
1274
|
+
value = value.slice(1);
|
|
1275
|
+
}
|
|
1276
|
+
if (value === ".inf") {
|
|
1277
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
1278
|
+
} else if (value === ".nan") {
|
|
1279
|
+
return NaN;
|
|
1280
|
+
}
|
|
1281
|
+
return sign * parseFloat(value, 10);
|
|
1282
|
+
}
|
|
1283
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
1284
|
+
function representYamlFloat(object, style) {
|
|
1285
|
+
var res;
|
|
1286
|
+
if (isNaN(object)) {
|
|
1287
|
+
switch (style) {
|
|
1288
|
+
case "lowercase":
|
|
1289
|
+
return ".nan";
|
|
1290
|
+
case "uppercase":
|
|
1291
|
+
return ".NAN";
|
|
1292
|
+
case "camelcase":
|
|
1293
|
+
return ".NaN";
|
|
1294
|
+
}
|
|
1295
|
+
} else if (Number.POSITIVE_INFINITY === object) {
|
|
1296
|
+
switch (style) {
|
|
1297
|
+
case "lowercase":
|
|
1298
|
+
return ".inf";
|
|
1299
|
+
case "uppercase":
|
|
1300
|
+
return ".INF";
|
|
1301
|
+
case "camelcase":
|
|
1302
|
+
return ".Inf";
|
|
1303
|
+
}
|
|
1304
|
+
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
1305
|
+
switch (style) {
|
|
1306
|
+
case "lowercase":
|
|
1307
|
+
return "-.inf";
|
|
1308
|
+
case "uppercase":
|
|
1309
|
+
return "-.INF";
|
|
1310
|
+
case "camelcase":
|
|
1311
|
+
return "-.Inf";
|
|
1312
|
+
}
|
|
1313
|
+
} else if (common.isNegativeZero(object)) {
|
|
1314
|
+
return "-0.0";
|
|
1315
|
+
}
|
|
1316
|
+
res = object.toString(10);
|
|
1317
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
1318
|
+
}
|
|
1319
|
+
function isFloat(object) {
|
|
1320
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
1321
|
+
}
|
|
1322
|
+
var float = new type("tag:yaml.org,2002:float", {
|
|
1323
|
+
kind: "scalar",
|
|
1324
|
+
resolve: resolveYamlFloat,
|
|
1325
|
+
construct: constructYamlFloat,
|
|
1326
|
+
predicate: isFloat,
|
|
1327
|
+
represent: representYamlFloat,
|
|
1328
|
+
defaultStyle: "lowercase"
|
|
1329
|
+
});
|
|
1330
|
+
var json = failsafe.extend({
|
|
1331
|
+
implicit: [
|
|
1332
|
+
_null,
|
|
1333
|
+
bool,
|
|
1334
|
+
int,
|
|
1335
|
+
float
|
|
1336
|
+
]
|
|
1337
|
+
});
|
|
1338
|
+
var core = json;
|
|
1339
|
+
var YAML_DATE_REGEXP = new RegExp(
|
|
1340
|
+
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
1341
|
+
);
|
|
1342
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
1343
|
+
"^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
|
|
1344
|
+
);
|
|
1345
|
+
function resolveYamlTimestamp(data) {
|
|
1346
|
+
if (data === null) return false;
|
|
1347
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
1348
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
1349
|
+
return false;
|
|
1350
|
+
}
|
|
1351
|
+
function constructYamlTimestamp(data) {
|
|
1352
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
1353
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
1354
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
1355
|
+
if (match === null) throw new Error("Date resolve error");
|
|
1356
|
+
year = +match[1];
|
|
1357
|
+
month = +match[2] - 1;
|
|
1358
|
+
day = +match[3];
|
|
1359
|
+
if (!match[4]) {
|
|
1360
|
+
return new Date(Date.UTC(year, month, day));
|
|
1361
|
+
}
|
|
1362
|
+
hour = +match[4];
|
|
1363
|
+
minute = +match[5];
|
|
1364
|
+
second = +match[6];
|
|
1365
|
+
if (match[7]) {
|
|
1366
|
+
fraction = match[7].slice(0, 3);
|
|
1367
|
+
while (fraction.length < 3) {
|
|
1368
|
+
fraction += "0";
|
|
1369
|
+
}
|
|
1370
|
+
fraction = +fraction;
|
|
1371
|
+
}
|
|
1372
|
+
if (match[9]) {
|
|
1373
|
+
tz_hour = +match[10];
|
|
1374
|
+
tz_minute = +(match[11] || 0);
|
|
1375
|
+
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
1376
|
+
if (match[9] === "-") delta = -delta;
|
|
1377
|
+
}
|
|
1378
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
1379
|
+
if (delta) date.setTime(date.getTime() - delta);
|
|
1380
|
+
return date;
|
|
1381
|
+
}
|
|
1382
|
+
function representYamlTimestamp(object) {
|
|
1383
|
+
return object.toISOString();
|
|
1384
|
+
}
|
|
1385
|
+
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
1386
|
+
kind: "scalar",
|
|
1387
|
+
resolve: resolveYamlTimestamp,
|
|
1388
|
+
construct: constructYamlTimestamp,
|
|
1389
|
+
instanceOf: Date,
|
|
1390
|
+
represent: representYamlTimestamp
|
|
1391
|
+
});
|
|
1392
|
+
function resolveYamlMerge(data) {
|
|
1393
|
+
return data === "<<" || data === null;
|
|
1394
|
+
}
|
|
1395
|
+
var merge = new type("tag:yaml.org,2002:merge", {
|
|
1396
|
+
kind: "scalar",
|
|
1397
|
+
resolve: resolveYamlMerge
|
|
1398
|
+
});
|
|
1399
|
+
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
1400
|
+
function resolveYamlBinary(data) {
|
|
1401
|
+
if (data === null) return false;
|
|
1402
|
+
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
1403
|
+
for (idx = 0; idx < max; idx++) {
|
|
1404
|
+
code = map2.indexOf(data.charAt(idx));
|
|
1405
|
+
if (code > 64) continue;
|
|
1406
|
+
if (code < 0) return false;
|
|
1407
|
+
bitlen += 6;
|
|
1408
|
+
}
|
|
1409
|
+
return bitlen % 8 === 0;
|
|
1410
|
+
}
|
|
1411
|
+
function constructYamlBinary(data) {
|
|
1412
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
1413
|
+
for (idx = 0; idx < max; idx++) {
|
|
1414
|
+
if (idx % 4 === 0 && idx) {
|
|
1415
|
+
result.push(bits >> 16 & 255);
|
|
1416
|
+
result.push(bits >> 8 & 255);
|
|
1417
|
+
result.push(bits & 255);
|
|
1418
|
+
}
|
|
1419
|
+
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
1420
|
+
}
|
|
1421
|
+
tailbits = max % 4 * 6;
|
|
1422
|
+
if (tailbits === 0) {
|
|
1423
|
+
result.push(bits >> 16 & 255);
|
|
1424
|
+
result.push(bits >> 8 & 255);
|
|
1425
|
+
result.push(bits & 255);
|
|
1426
|
+
} else if (tailbits === 18) {
|
|
1427
|
+
result.push(bits >> 10 & 255);
|
|
1428
|
+
result.push(bits >> 2 & 255);
|
|
1429
|
+
} else if (tailbits === 12) {
|
|
1430
|
+
result.push(bits >> 4 & 255);
|
|
1431
|
+
}
|
|
1432
|
+
return new Uint8Array(result);
|
|
1433
|
+
}
|
|
1434
|
+
function representYamlBinary(object) {
|
|
1435
|
+
var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
|
|
1436
|
+
for (idx = 0; idx < max; idx++) {
|
|
1437
|
+
if (idx % 3 === 0 && idx) {
|
|
1438
|
+
result += map2[bits >> 18 & 63];
|
|
1439
|
+
result += map2[bits >> 12 & 63];
|
|
1440
|
+
result += map2[bits >> 6 & 63];
|
|
1441
|
+
result += map2[bits & 63];
|
|
1442
|
+
}
|
|
1443
|
+
bits = (bits << 8) + object[idx];
|
|
1444
|
+
}
|
|
1445
|
+
tail = max % 3;
|
|
1446
|
+
if (tail === 0) {
|
|
1447
|
+
result += map2[bits >> 18 & 63];
|
|
1448
|
+
result += map2[bits >> 12 & 63];
|
|
1449
|
+
result += map2[bits >> 6 & 63];
|
|
1450
|
+
result += map2[bits & 63];
|
|
1451
|
+
} else if (tail === 2) {
|
|
1452
|
+
result += map2[bits >> 10 & 63];
|
|
1453
|
+
result += map2[bits >> 4 & 63];
|
|
1454
|
+
result += map2[bits << 2 & 63];
|
|
1455
|
+
result += map2[64];
|
|
1456
|
+
} else if (tail === 1) {
|
|
1457
|
+
result += map2[bits >> 2 & 63];
|
|
1458
|
+
result += map2[bits << 4 & 63];
|
|
1459
|
+
result += map2[64];
|
|
1460
|
+
result += map2[64];
|
|
1461
|
+
}
|
|
1462
|
+
return result;
|
|
1463
|
+
}
|
|
1464
|
+
function isBinary(obj) {
|
|
1465
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
1466
|
+
}
|
|
1467
|
+
var binary = new type("tag:yaml.org,2002:binary", {
|
|
1468
|
+
kind: "scalar",
|
|
1469
|
+
resolve: resolveYamlBinary,
|
|
1470
|
+
construct: constructYamlBinary,
|
|
1471
|
+
predicate: isBinary,
|
|
1472
|
+
represent: representYamlBinary
|
|
1473
|
+
});
|
|
1474
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1475
|
+
var _toString$2 = Object.prototype.toString;
|
|
1476
|
+
function resolveYamlOmap(data) {
|
|
1477
|
+
if (data === null) return true;
|
|
1478
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
1479
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1480
|
+
pair = object[index];
|
|
1481
|
+
pairHasKey = false;
|
|
1482
|
+
if (_toString$2.call(pair) !== "[object Object]") return false;
|
|
1483
|
+
for (pairKey in pair) {
|
|
1484
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
1485
|
+
if (!pairHasKey) pairHasKey = true;
|
|
1486
|
+
else return false;
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
if (!pairHasKey) return false;
|
|
1490
|
+
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
|
1491
|
+
else return false;
|
|
1492
|
+
}
|
|
1493
|
+
return true;
|
|
1494
|
+
}
|
|
1495
|
+
function constructYamlOmap(data) {
|
|
1496
|
+
return data !== null ? data : [];
|
|
1497
|
+
}
|
|
1498
|
+
var omap = new type("tag:yaml.org,2002:omap", {
|
|
1499
|
+
kind: "sequence",
|
|
1500
|
+
resolve: resolveYamlOmap,
|
|
1501
|
+
construct: constructYamlOmap
|
|
1502
|
+
});
|
|
1503
|
+
var _toString$1 = Object.prototype.toString;
|
|
1504
|
+
function resolveYamlPairs(data) {
|
|
1505
|
+
if (data === null) return true;
|
|
1506
|
+
var index, length, pair, keys, result, object = data;
|
|
1507
|
+
result = new Array(object.length);
|
|
1508
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1509
|
+
pair = object[index];
|
|
1510
|
+
if (_toString$1.call(pair) !== "[object Object]") return false;
|
|
1511
|
+
keys = Object.keys(pair);
|
|
1512
|
+
if (keys.length !== 1) return false;
|
|
1513
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
1514
|
+
}
|
|
1515
|
+
return true;
|
|
1516
|
+
}
|
|
1517
|
+
function constructYamlPairs(data) {
|
|
1518
|
+
if (data === null) return [];
|
|
1519
|
+
var index, length, pair, keys, result, object = data;
|
|
1520
|
+
result = new Array(object.length);
|
|
1521
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1522
|
+
pair = object[index];
|
|
1523
|
+
keys = Object.keys(pair);
|
|
1524
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
1525
|
+
}
|
|
1526
|
+
return result;
|
|
1527
|
+
}
|
|
1528
|
+
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
1529
|
+
kind: "sequence",
|
|
1530
|
+
resolve: resolveYamlPairs,
|
|
1531
|
+
construct: constructYamlPairs
|
|
1532
|
+
});
|
|
1533
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1534
|
+
function resolveYamlSet(data) {
|
|
1535
|
+
if (data === null) return true;
|
|
1536
|
+
var key, object = data;
|
|
1537
|
+
for (key in object) {
|
|
1538
|
+
if (_hasOwnProperty$2.call(object, key)) {
|
|
1539
|
+
if (object[key] !== null) return false;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
return true;
|
|
1543
|
+
}
|
|
1544
|
+
function constructYamlSet(data) {
|
|
1545
|
+
return data !== null ? data : {};
|
|
1546
|
+
}
|
|
1547
|
+
var set = new type("tag:yaml.org,2002:set", {
|
|
1548
|
+
kind: "mapping",
|
|
1549
|
+
resolve: resolveYamlSet,
|
|
1550
|
+
construct: constructYamlSet
|
|
1551
|
+
});
|
|
1552
|
+
var _default = core.extend({
|
|
1553
|
+
implicit: [
|
|
1554
|
+
timestamp,
|
|
1555
|
+
merge
|
|
1556
|
+
],
|
|
1557
|
+
explicit: [
|
|
1558
|
+
binary,
|
|
1559
|
+
omap,
|
|
1560
|
+
pairs,
|
|
1561
|
+
set
|
|
1562
|
+
]
|
|
1563
|
+
});
|
|
1564
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1565
|
+
var CONTEXT_FLOW_IN = 1;
|
|
1566
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
1567
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
1568
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
1569
|
+
var CHOMPING_CLIP = 1;
|
|
1570
|
+
var CHOMPING_STRIP = 2;
|
|
1571
|
+
var CHOMPING_KEEP = 3;
|
|
1572
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1573
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1574
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
1575
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
1576
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
1577
|
+
function _class(obj) {
|
|
1578
|
+
return Object.prototype.toString.call(obj);
|
|
1579
|
+
}
|
|
1580
|
+
function is_EOL(c) {
|
|
1581
|
+
return c === 10 || c === 13;
|
|
1582
|
+
}
|
|
1583
|
+
function is_WHITE_SPACE(c) {
|
|
1584
|
+
return c === 9 || c === 32;
|
|
1585
|
+
}
|
|
1586
|
+
function is_WS_OR_EOL(c) {
|
|
1587
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
1588
|
+
}
|
|
1589
|
+
function is_FLOW_INDICATOR(c) {
|
|
1590
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1591
|
+
}
|
|
1592
|
+
function fromHexCode(c) {
|
|
1593
|
+
var lc;
|
|
1594
|
+
if (48 <= c && c <= 57) {
|
|
1595
|
+
return c - 48;
|
|
1596
|
+
}
|
|
1597
|
+
lc = c | 32;
|
|
1598
|
+
if (97 <= lc && lc <= 102) {
|
|
1599
|
+
return lc - 97 + 10;
|
|
1600
|
+
}
|
|
1601
|
+
return -1;
|
|
1602
|
+
}
|
|
1603
|
+
function escapedHexLen(c) {
|
|
1604
|
+
if (c === 120) {
|
|
1605
|
+
return 2;
|
|
1606
|
+
}
|
|
1607
|
+
if (c === 117) {
|
|
1608
|
+
return 4;
|
|
1609
|
+
}
|
|
1610
|
+
if (c === 85) {
|
|
1611
|
+
return 8;
|
|
1612
|
+
}
|
|
1613
|
+
return 0;
|
|
1614
|
+
}
|
|
1615
|
+
function fromDecimalCode(c) {
|
|
1616
|
+
if (48 <= c && c <= 57) {
|
|
1617
|
+
return c - 48;
|
|
1618
|
+
}
|
|
1619
|
+
return -1;
|
|
1620
|
+
}
|
|
1621
|
+
function simpleEscapeSequence(c) {
|
|
1622
|
+
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
1623
|
+
}
|
|
1624
|
+
function charFromCodepoint(c) {
|
|
1625
|
+
if (c <= 65535) {
|
|
1626
|
+
return String.fromCharCode(c);
|
|
1627
|
+
}
|
|
1628
|
+
return String.fromCharCode(
|
|
1629
|
+
(c - 65536 >> 10) + 55296,
|
|
1630
|
+
(c - 65536 & 1023) + 56320
|
|
1631
|
+
);
|
|
1632
|
+
}
|
|
1633
|
+
function setProperty(object, key, value) {
|
|
1634
|
+
if (key === "__proto__") {
|
|
1635
|
+
Object.defineProperty(object, key, {
|
|
1636
|
+
configurable: true,
|
|
1637
|
+
enumerable: true,
|
|
1638
|
+
writable: true,
|
|
1639
|
+
value
|
|
1640
|
+
});
|
|
1641
|
+
} else {
|
|
1642
|
+
object[key] = value;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
var simpleEscapeCheck = new Array(256);
|
|
1646
|
+
var simpleEscapeMap = new Array(256);
|
|
1647
|
+
for (i = 0; i < 256; i++) {
|
|
1648
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1649
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1650
|
+
}
|
|
1651
|
+
var i;
|
|
1652
|
+
function State$1(input, options) {
|
|
1653
|
+
this.input = input;
|
|
1654
|
+
this.filename = options["filename"] || null;
|
|
1655
|
+
this.schema = options["schema"] || _default;
|
|
1656
|
+
this.onWarning = options["onWarning"] || null;
|
|
1657
|
+
this.legacy = options["legacy"] || false;
|
|
1658
|
+
this.json = options["json"] || false;
|
|
1659
|
+
this.listener = options["listener"] || null;
|
|
1660
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
1661
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
1662
|
+
this.length = input.length;
|
|
1663
|
+
this.position = 0;
|
|
1664
|
+
this.line = 0;
|
|
1665
|
+
this.lineStart = 0;
|
|
1666
|
+
this.lineIndent = 0;
|
|
1667
|
+
this.firstTabInLine = -1;
|
|
1668
|
+
this.documents = [];
|
|
1669
|
+
}
|
|
1670
|
+
function generateError(state, message) {
|
|
1671
|
+
var mark = {
|
|
1672
|
+
name: state.filename,
|
|
1673
|
+
buffer: state.input.slice(0, -1),
|
|
1674
|
+
// omit trailing \0
|
|
1675
|
+
position: state.position,
|
|
1676
|
+
line: state.line,
|
|
1677
|
+
column: state.position - state.lineStart
|
|
1678
|
+
};
|
|
1679
|
+
mark.snippet = snippet(mark);
|
|
1680
|
+
return new exception(message, mark);
|
|
1681
|
+
}
|
|
1682
|
+
function throwError(state, message) {
|
|
1683
|
+
throw generateError(state, message);
|
|
1684
|
+
}
|
|
1685
|
+
function throwWarning(state, message) {
|
|
1686
|
+
if (state.onWarning) {
|
|
1687
|
+
state.onWarning.call(null, generateError(state, message));
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
var directiveHandlers = {
|
|
1691
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
1692
|
+
var match, major, minor;
|
|
1693
|
+
if (state.version !== null) {
|
|
1694
|
+
throwError(state, "duplication of %YAML directive");
|
|
1695
|
+
}
|
|
1696
|
+
if (args.length !== 1) {
|
|
1697
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
1698
|
+
}
|
|
1699
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1700
|
+
if (match === null) {
|
|
1701
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
1702
|
+
}
|
|
1703
|
+
major = parseInt(match[1], 10);
|
|
1704
|
+
minor = parseInt(match[2], 10);
|
|
1705
|
+
if (major !== 1) {
|
|
1706
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
1707
|
+
}
|
|
1708
|
+
state.version = args[0];
|
|
1709
|
+
state.checkLineBreaks = minor < 2;
|
|
1710
|
+
if (minor !== 1 && minor !== 2) {
|
|
1711
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
1712
|
+
}
|
|
1713
|
+
},
|
|
1714
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
1715
|
+
var handle, prefix;
|
|
1716
|
+
if (args.length !== 2) {
|
|
1717
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
1718
|
+
}
|
|
1719
|
+
handle = args[0];
|
|
1720
|
+
prefix = args[1];
|
|
1721
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1722
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1723
|
+
}
|
|
1724
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
1725
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1726
|
+
}
|
|
1727
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1728
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1729
|
+
}
|
|
1730
|
+
try {
|
|
1731
|
+
prefix = decodeURIComponent(prefix);
|
|
1732
|
+
} catch (err) {
|
|
1733
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
1734
|
+
}
|
|
1735
|
+
state.tagMap[handle] = prefix;
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
function captureSegment(state, start, end, checkJson) {
|
|
1739
|
+
var _position, _length, _character, _result;
|
|
1740
|
+
if (start < end) {
|
|
1741
|
+
_result = state.input.slice(start, end);
|
|
1742
|
+
if (checkJson) {
|
|
1743
|
+
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
1744
|
+
_character = _result.charCodeAt(_position);
|
|
1745
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1746
|
+
throwError(state, "expected valid JSON character");
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1750
|
+
throwError(state, "the stream contains non-printable characters");
|
|
1751
|
+
}
|
|
1752
|
+
state.result += _result;
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1756
|
+
var sourceKeys, key, index, quantity;
|
|
1757
|
+
if (!common.isObject(source)) {
|
|
1758
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1759
|
+
}
|
|
1760
|
+
sourceKeys = Object.keys(source);
|
|
1761
|
+
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1762
|
+
key = sourceKeys[index];
|
|
1763
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
1764
|
+
setProperty(destination, key, source[key]);
|
|
1765
|
+
overridableKeys[key] = true;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
1770
|
+
var index, quantity;
|
|
1771
|
+
if (Array.isArray(keyNode)) {
|
|
1772
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
1773
|
+
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1774
|
+
if (Array.isArray(keyNode[index])) {
|
|
1775
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
1776
|
+
}
|
|
1777
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1778
|
+
keyNode[index] = "[object Object]";
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1783
|
+
keyNode = "[object Object]";
|
|
1784
|
+
}
|
|
1785
|
+
keyNode = String(keyNode);
|
|
1786
|
+
if (_result === null) {
|
|
1787
|
+
_result = {};
|
|
1788
|
+
}
|
|
1789
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1790
|
+
if (Array.isArray(valueNode)) {
|
|
1791
|
+
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1792
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1793
|
+
}
|
|
1794
|
+
} else {
|
|
1795
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1796
|
+
}
|
|
1797
|
+
} else {
|
|
1798
|
+
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
1799
|
+
state.line = startLine || state.line;
|
|
1800
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
1801
|
+
state.position = startPos || state.position;
|
|
1802
|
+
throwError(state, "duplicated mapping key");
|
|
1803
|
+
}
|
|
1804
|
+
setProperty(_result, keyNode, valueNode);
|
|
1805
|
+
delete overridableKeys[keyNode];
|
|
1806
|
+
}
|
|
1807
|
+
return _result;
|
|
1808
|
+
}
|
|
1809
|
+
function readLineBreak(state) {
|
|
1810
|
+
var ch;
|
|
1811
|
+
ch = state.input.charCodeAt(state.position);
|
|
1812
|
+
if (ch === 10) {
|
|
1813
|
+
state.position++;
|
|
1814
|
+
} else if (ch === 13) {
|
|
1815
|
+
state.position++;
|
|
1816
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
1817
|
+
state.position++;
|
|
1818
|
+
}
|
|
1819
|
+
} else {
|
|
1820
|
+
throwError(state, "a line break is expected");
|
|
1821
|
+
}
|
|
1822
|
+
state.line += 1;
|
|
1823
|
+
state.lineStart = state.position;
|
|
1824
|
+
state.firstTabInLine = -1;
|
|
1825
|
+
}
|
|
1826
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1827
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1828
|
+
while (ch !== 0) {
|
|
1829
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1830
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
1831
|
+
state.firstTabInLine = state.position;
|
|
1832
|
+
}
|
|
1833
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1834
|
+
}
|
|
1835
|
+
if (allowComments && ch === 35) {
|
|
1836
|
+
do {
|
|
1837
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1838
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1839
|
+
}
|
|
1840
|
+
if (is_EOL(ch)) {
|
|
1841
|
+
readLineBreak(state);
|
|
1842
|
+
ch = state.input.charCodeAt(state.position);
|
|
1843
|
+
lineBreaks++;
|
|
1844
|
+
state.lineIndent = 0;
|
|
1845
|
+
while (ch === 32) {
|
|
1846
|
+
state.lineIndent++;
|
|
1847
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1848
|
+
}
|
|
1849
|
+
} else {
|
|
1850
|
+
break;
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1854
|
+
throwWarning(state, "deficient indentation");
|
|
1855
|
+
}
|
|
1856
|
+
return lineBreaks;
|
|
1857
|
+
}
|
|
1858
|
+
function testDocumentSeparator(state) {
|
|
1859
|
+
var _position = state.position, ch;
|
|
1860
|
+
ch = state.input.charCodeAt(_position);
|
|
1861
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1862
|
+
_position += 3;
|
|
1863
|
+
ch = state.input.charCodeAt(_position);
|
|
1864
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1865
|
+
return true;
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
return false;
|
|
1869
|
+
}
|
|
1870
|
+
function writeFoldedLines(state, count) {
|
|
1871
|
+
if (count === 1) {
|
|
1872
|
+
state.result += " ";
|
|
1873
|
+
} else if (count > 1) {
|
|
1874
|
+
state.result += common.repeat("\n", count - 1);
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1878
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1879
|
+
ch = state.input.charCodeAt(state.position);
|
|
1880
|
+
if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
|
|
1881
|
+
return false;
|
|
1882
|
+
}
|
|
1883
|
+
if (ch === 63 || ch === 45) {
|
|
1884
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1885
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1886
|
+
return false;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
state.kind = "scalar";
|
|
1890
|
+
state.result = "";
|
|
1891
|
+
captureStart = captureEnd = state.position;
|
|
1892
|
+
hasPendingContent = false;
|
|
1893
|
+
while (ch !== 0) {
|
|
1894
|
+
if (ch === 58) {
|
|
1895
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1896
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1897
|
+
break;
|
|
1898
|
+
}
|
|
1899
|
+
} else if (ch === 35) {
|
|
1900
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
1901
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
1902
|
+
break;
|
|
1903
|
+
}
|
|
1904
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1905
|
+
break;
|
|
1906
|
+
} else if (is_EOL(ch)) {
|
|
1907
|
+
_line = state.line;
|
|
1908
|
+
_lineStart = state.lineStart;
|
|
1909
|
+
_lineIndent = state.lineIndent;
|
|
1910
|
+
skipSeparationSpace(state, false, -1);
|
|
1911
|
+
if (state.lineIndent >= nodeIndent) {
|
|
1912
|
+
hasPendingContent = true;
|
|
1913
|
+
ch = state.input.charCodeAt(state.position);
|
|
1914
|
+
continue;
|
|
1915
|
+
} else {
|
|
1916
|
+
state.position = captureEnd;
|
|
1917
|
+
state.line = _line;
|
|
1918
|
+
state.lineStart = _lineStart;
|
|
1919
|
+
state.lineIndent = _lineIndent;
|
|
1920
|
+
break;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
if (hasPendingContent) {
|
|
1924
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1925
|
+
writeFoldedLines(state, state.line - _line);
|
|
1926
|
+
captureStart = captureEnd = state.position;
|
|
1927
|
+
hasPendingContent = false;
|
|
1928
|
+
}
|
|
1929
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
1930
|
+
captureEnd = state.position + 1;
|
|
1931
|
+
}
|
|
1932
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1933
|
+
}
|
|
1934
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1935
|
+
if (state.result) {
|
|
1936
|
+
return true;
|
|
1937
|
+
}
|
|
1938
|
+
state.kind = _kind;
|
|
1939
|
+
state.result = _result;
|
|
1940
|
+
return false;
|
|
1941
|
+
}
|
|
1942
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1943
|
+
var ch, captureStart, captureEnd;
|
|
1944
|
+
ch = state.input.charCodeAt(state.position);
|
|
1945
|
+
if (ch !== 39) {
|
|
1946
|
+
return false;
|
|
1947
|
+
}
|
|
1948
|
+
state.kind = "scalar";
|
|
1949
|
+
state.result = "";
|
|
1950
|
+
state.position++;
|
|
1951
|
+
captureStart = captureEnd = state.position;
|
|
1952
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1953
|
+
if (ch === 39) {
|
|
1954
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1955
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1956
|
+
if (ch === 39) {
|
|
1957
|
+
captureStart = state.position;
|
|
1958
|
+
state.position++;
|
|
1959
|
+
captureEnd = state.position;
|
|
1960
|
+
} else {
|
|
1961
|
+
return true;
|
|
1962
|
+
}
|
|
1963
|
+
} else if (is_EOL(ch)) {
|
|
1964
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1965
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1966
|
+
captureStart = captureEnd = state.position;
|
|
1967
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1968
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1969
|
+
} else {
|
|
1970
|
+
state.position++;
|
|
1971
|
+
captureEnd = state.position;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1975
|
+
}
|
|
1976
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1977
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1978
|
+
ch = state.input.charCodeAt(state.position);
|
|
1979
|
+
if (ch !== 34) {
|
|
1980
|
+
return false;
|
|
1981
|
+
}
|
|
1982
|
+
state.kind = "scalar";
|
|
1983
|
+
state.result = "";
|
|
1984
|
+
state.position++;
|
|
1985
|
+
captureStart = captureEnd = state.position;
|
|
1986
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1987
|
+
if (ch === 34) {
|
|
1988
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1989
|
+
state.position++;
|
|
1990
|
+
return true;
|
|
1991
|
+
} else if (ch === 92) {
|
|
1992
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1993
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1994
|
+
if (is_EOL(ch)) {
|
|
1995
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
1996
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1997
|
+
state.result += simpleEscapeMap[ch];
|
|
1998
|
+
state.position++;
|
|
1999
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
2000
|
+
hexLength = tmp;
|
|
2001
|
+
hexResult = 0;
|
|
2002
|
+
for (; hexLength > 0; hexLength--) {
|
|
2003
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2004
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
2005
|
+
hexResult = (hexResult << 4) + tmp;
|
|
2006
|
+
} else {
|
|
2007
|
+
throwError(state, "expected hexadecimal character");
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
state.result += charFromCodepoint(hexResult);
|
|
2011
|
+
state.position++;
|
|
2012
|
+
} else {
|
|
2013
|
+
throwError(state, "unknown escape sequence");
|
|
2014
|
+
}
|
|
2015
|
+
captureStart = captureEnd = state.position;
|
|
2016
|
+
} else if (is_EOL(ch)) {
|
|
2017
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
2018
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
2019
|
+
captureStart = captureEnd = state.position;
|
|
2020
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2021
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
2022
|
+
} else {
|
|
2023
|
+
state.position++;
|
|
2024
|
+
captureEnd = state.position;
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
2028
|
+
}
|
|
2029
|
+
function readFlowCollection(state, nodeIndent) {
|
|
2030
|
+
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
2031
|
+
ch = state.input.charCodeAt(state.position);
|
|
2032
|
+
if (ch === 91) {
|
|
2033
|
+
terminator = 93;
|
|
2034
|
+
isMapping = false;
|
|
2035
|
+
_result = [];
|
|
2036
|
+
} else if (ch === 123) {
|
|
2037
|
+
terminator = 125;
|
|
2038
|
+
isMapping = true;
|
|
2039
|
+
_result = {};
|
|
2040
|
+
} else {
|
|
2041
|
+
return false;
|
|
2042
|
+
}
|
|
2043
|
+
if (state.anchor !== null) {
|
|
2044
|
+
state.anchorMap[state.anchor] = _result;
|
|
2045
|
+
}
|
|
2046
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2047
|
+
while (ch !== 0) {
|
|
2048
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
2049
|
+
ch = state.input.charCodeAt(state.position);
|
|
2050
|
+
if (ch === terminator) {
|
|
2051
|
+
state.position++;
|
|
2052
|
+
state.tag = _tag;
|
|
2053
|
+
state.anchor = _anchor;
|
|
2054
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
2055
|
+
state.result = _result;
|
|
2056
|
+
return true;
|
|
2057
|
+
} else if (!readNext) {
|
|
2058
|
+
throwError(state, "missed comma between flow collection entries");
|
|
2059
|
+
} else if (ch === 44) {
|
|
2060
|
+
throwError(state, "expected the node content, but found ','");
|
|
2061
|
+
}
|
|
2062
|
+
keyTag = keyNode = valueNode = null;
|
|
2063
|
+
isPair = isExplicitPair = false;
|
|
2064
|
+
if (ch === 63) {
|
|
2065
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
2066
|
+
if (is_WS_OR_EOL(following)) {
|
|
2067
|
+
isPair = isExplicitPair = true;
|
|
2068
|
+
state.position++;
|
|
2069
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
_line = state.line;
|
|
2073
|
+
_lineStart = state.lineStart;
|
|
2074
|
+
_pos = state.position;
|
|
2075
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
2076
|
+
keyTag = state.tag;
|
|
2077
|
+
keyNode = state.result;
|
|
2078
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
2079
|
+
ch = state.input.charCodeAt(state.position);
|
|
2080
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
2081
|
+
isPair = true;
|
|
2082
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2083
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
2084
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
2085
|
+
valueNode = state.result;
|
|
2086
|
+
}
|
|
2087
|
+
if (isMapping) {
|
|
2088
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
2089
|
+
} else if (isPair) {
|
|
2090
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
2091
|
+
} else {
|
|
2092
|
+
_result.push(keyNode);
|
|
2093
|
+
}
|
|
2094
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
2095
|
+
ch = state.input.charCodeAt(state.position);
|
|
2096
|
+
if (ch === 44) {
|
|
2097
|
+
readNext = true;
|
|
2098
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2099
|
+
} else {
|
|
2100
|
+
readNext = false;
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
2104
|
+
}
|
|
2105
|
+
function readBlockScalar(state, nodeIndent) {
|
|
2106
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
2107
|
+
ch = state.input.charCodeAt(state.position);
|
|
2108
|
+
if (ch === 124) {
|
|
2109
|
+
folding = false;
|
|
2110
|
+
} else if (ch === 62) {
|
|
2111
|
+
folding = true;
|
|
2112
|
+
} else {
|
|
2113
|
+
return false;
|
|
2114
|
+
}
|
|
2115
|
+
state.kind = "scalar";
|
|
2116
|
+
state.result = "";
|
|
2117
|
+
while (ch !== 0) {
|
|
2118
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2119
|
+
if (ch === 43 || ch === 45) {
|
|
2120
|
+
if (CHOMPING_CLIP === chomping) {
|
|
2121
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
2122
|
+
} else {
|
|
2123
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
2124
|
+
}
|
|
2125
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
2126
|
+
if (tmp === 0) {
|
|
2127
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
2128
|
+
} else if (!detectedIndent) {
|
|
2129
|
+
textIndent = nodeIndent + tmp - 1;
|
|
2130
|
+
detectedIndent = true;
|
|
2131
|
+
} else {
|
|
2132
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
2133
|
+
}
|
|
2134
|
+
} else {
|
|
2135
|
+
break;
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
if (is_WHITE_SPACE(ch)) {
|
|
2139
|
+
do {
|
|
2140
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2141
|
+
} while (is_WHITE_SPACE(ch));
|
|
2142
|
+
if (ch === 35) {
|
|
2143
|
+
do {
|
|
2144
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2145
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
while (ch !== 0) {
|
|
2149
|
+
readLineBreak(state);
|
|
2150
|
+
state.lineIndent = 0;
|
|
2151
|
+
ch = state.input.charCodeAt(state.position);
|
|
2152
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
2153
|
+
state.lineIndent++;
|
|
2154
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2155
|
+
}
|
|
2156
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
2157
|
+
textIndent = state.lineIndent;
|
|
2158
|
+
}
|
|
2159
|
+
if (is_EOL(ch)) {
|
|
2160
|
+
emptyLines++;
|
|
2161
|
+
continue;
|
|
2162
|
+
}
|
|
2163
|
+
if (state.lineIndent < textIndent) {
|
|
2164
|
+
if (chomping === CHOMPING_KEEP) {
|
|
2165
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
2166
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
2167
|
+
if (didReadContent) {
|
|
2168
|
+
state.result += "\n";
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
break;
|
|
2172
|
+
}
|
|
2173
|
+
if (folding) {
|
|
2174
|
+
if (is_WHITE_SPACE(ch)) {
|
|
2175
|
+
atMoreIndented = true;
|
|
2176
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
2177
|
+
} else if (atMoreIndented) {
|
|
2178
|
+
atMoreIndented = false;
|
|
2179
|
+
state.result += common.repeat("\n", emptyLines + 1);
|
|
2180
|
+
} else if (emptyLines === 0) {
|
|
2181
|
+
if (didReadContent) {
|
|
2182
|
+
state.result += " ";
|
|
2183
|
+
}
|
|
2184
|
+
} else {
|
|
2185
|
+
state.result += common.repeat("\n", emptyLines);
|
|
2186
|
+
}
|
|
2187
|
+
} else {
|
|
2188
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
2189
|
+
}
|
|
2190
|
+
didReadContent = true;
|
|
2191
|
+
detectedIndent = true;
|
|
2192
|
+
emptyLines = 0;
|
|
2193
|
+
captureStart = state.position;
|
|
2194
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
2195
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2196
|
+
}
|
|
2197
|
+
captureSegment(state, captureStart, state.position, false);
|
|
2198
|
+
}
|
|
2199
|
+
return true;
|
|
2200
|
+
}
|
|
2201
|
+
function readBlockSequence(state, nodeIndent) {
|
|
2202
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
2203
|
+
if (state.firstTabInLine !== -1) return false;
|
|
2204
|
+
if (state.anchor !== null) {
|
|
2205
|
+
state.anchorMap[state.anchor] = _result;
|
|
2206
|
+
}
|
|
2207
|
+
ch = state.input.charCodeAt(state.position);
|
|
2208
|
+
while (ch !== 0) {
|
|
2209
|
+
if (state.firstTabInLine !== -1) {
|
|
2210
|
+
state.position = state.firstTabInLine;
|
|
2211
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
2212
|
+
}
|
|
2213
|
+
if (ch !== 45) {
|
|
2214
|
+
break;
|
|
2215
|
+
}
|
|
2216
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
2217
|
+
if (!is_WS_OR_EOL(following)) {
|
|
2218
|
+
break;
|
|
2219
|
+
}
|
|
2220
|
+
detected = true;
|
|
2221
|
+
state.position++;
|
|
2222
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2223
|
+
if (state.lineIndent <= nodeIndent) {
|
|
2224
|
+
_result.push(null);
|
|
2225
|
+
ch = state.input.charCodeAt(state.position);
|
|
2226
|
+
continue;
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
_line = state.line;
|
|
2230
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
2231
|
+
_result.push(state.result);
|
|
2232
|
+
skipSeparationSpace(state, true, -1);
|
|
2233
|
+
ch = state.input.charCodeAt(state.position);
|
|
2234
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
2235
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
2236
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
2237
|
+
break;
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
if (detected) {
|
|
2241
|
+
state.tag = _tag;
|
|
2242
|
+
state.anchor = _anchor;
|
|
2243
|
+
state.kind = "sequence";
|
|
2244
|
+
state.result = _result;
|
|
2245
|
+
return true;
|
|
2246
|
+
}
|
|
2247
|
+
return false;
|
|
2248
|
+
}
|
|
2249
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
2250
|
+
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
2251
|
+
if (state.firstTabInLine !== -1) return false;
|
|
2252
|
+
if (state.anchor !== null) {
|
|
2253
|
+
state.anchorMap[state.anchor] = _result;
|
|
2254
|
+
}
|
|
2255
|
+
ch = state.input.charCodeAt(state.position);
|
|
2256
|
+
while (ch !== 0) {
|
|
2257
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
2258
|
+
state.position = state.firstTabInLine;
|
|
2259
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
2260
|
+
}
|
|
2261
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
2262
|
+
_line = state.line;
|
|
2263
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
2264
|
+
if (ch === 63) {
|
|
2265
|
+
if (atExplicitKey) {
|
|
2266
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
2267
|
+
keyTag = keyNode = valueNode = null;
|
|
2268
|
+
}
|
|
2269
|
+
detected = true;
|
|
2270
|
+
atExplicitKey = true;
|
|
2271
|
+
allowCompact = true;
|
|
2272
|
+
} else if (atExplicitKey) {
|
|
2273
|
+
atExplicitKey = false;
|
|
2274
|
+
allowCompact = true;
|
|
2275
|
+
} else {
|
|
2276
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
2277
|
+
}
|
|
2278
|
+
state.position += 1;
|
|
2279
|
+
ch = following;
|
|
2280
|
+
} else {
|
|
2281
|
+
_keyLine = state.line;
|
|
2282
|
+
_keyLineStart = state.lineStart;
|
|
2283
|
+
_keyPos = state.position;
|
|
2284
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
2285
|
+
break;
|
|
2286
|
+
}
|
|
2287
|
+
if (state.line === _line) {
|
|
2288
|
+
ch = state.input.charCodeAt(state.position);
|
|
2289
|
+
while (is_WHITE_SPACE(ch)) {
|
|
2290
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2291
|
+
}
|
|
2292
|
+
if (ch === 58) {
|
|
2293
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2294
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
2295
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
2296
|
+
}
|
|
2297
|
+
if (atExplicitKey) {
|
|
2298
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
2299
|
+
keyTag = keyNode = valueNode = null;
|
|
2300
|
+
}
|
|
2301
|
+
detected = true;
|
|
2302
|
+
atExplicitKey = false;
|
|
2303
|
+
allowCompact = false;
|
|
2304
|
+
keyTag = state.tag;
|
|
2305
|
+
keyNode = state.result;
|
|
2306
|
+
} else if (detected) {
|
|
2307
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
2308
|
+
} else {
|
|
2309
|
+
state.tag = _tag;
|
|
2310
|
+
state.anchor = _anchor;
|
|
2311
|
+
return true;
|
|
2312
|
+
}
|
|
2313
|
+
} else if (detected) {
|
|
2314
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
2315
|
+
} else {
|
|
2316
|
+
state.tag = _tag;
|
|
2317
|
+
state.anchor = _anchor;
|
|
2318
|
+
return true;
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
2322
|
+
if (atExplicitKey) {
|
|
2323
|
+
_keyLine = state.line;
|
|
2324
|
+
_keyLineStart = state.lineStart;
|
|
2325
|
+
_keyPos = state.position;
|
|
2326
|
+
}
|
|
2327
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
2328
|
+
if (atExplicitKey) {
|
|
2329
|
+
keyNode = state.result;
|
|
2330
|
+
} else {
|
|
2331
|
+
valueNode = state.result;
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
if (!atExplicitKey) {
|
|
2335
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
2336
|
+
keyTag = keyNode = valueNode = null;
|
|
2337
|
+
}
|
|
2338
|
+
skipSeparationSpace(state, true, -1);
|
|
2339
|
+
ch = state.input.charCodeAt(state.position);
|
|
2340
|
+
}
|
|
2341
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
2342
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
2343
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
2344
|
+
break;
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
if (atExplicitKey) {
|
|
2348
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
2349
|
+
}
|
|
2350
|
+
if (detected) {
|
|
2351
|
+
state.tag = _tag;
|
|
2352
|
+
state.anchor = _anchor;
|
|
2353
|
+
state.kind = "mapping";
|
|
2354
|
+
state.result = _result;
|
|
2355
|
+
}
|
|
2356
|
+
return detected;
|
|
2357
|
+
}
|
|
2358
|
+
function readTagProperty(state) {
|
|
2359
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName2, ch;
|
|
2360
|
+
ch = state.input.charCodeAt(state.position);
|
|
2361
|
+
if (ch !== 33) return false;
|
|
2362
|
+
if (state.tag !== null) {
|
|
2363
|
+
throwError(state, "duplication of a tag property");
|
|
2364
|
+
}
|
|
2365
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2366
|
+
if (ch === 60) {
|
|
2367
|
+
isVerbatim = true;
|
|
2368
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2369
|
+
} else if (ch === 33) {
|
|
2370
|
+
isNamed = true;
|
|
2371
|
+
tagHandle = "!!";
|
|
2372
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2373
|
+
} else {
|
|
2374
|
+
tagHandle = "!";
|
|
2375
|
+
}
|
|
2376
|
+
_position = state.position;
|
|
2377
|
+
if (isVerbatim) {
|
|
2378
|
+
do {
|
|
2379
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2380
|
+
} while (ch !== 0 && ch !== 62);
|
|
2381
|
+
if (state.position < state.length) {
|
|
2382
|
+
tagName2 = state.input.slice(_position, state.position);
|
|
2383
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2384
|
+
} else {
|
|
2385
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
2386
|
+
}
|
|
2387
|
+
} else {
|
|
2388
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2389
|
+
if (ch === 33) {
|
|
2390
|
+
if (!isNamed) {
|
|
2391
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
2392
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
2393
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
2394
|
+
}
|
|
2395
|
+
isNamed = true;
|
|
2396
|
+
_position = state.position + 1;
|
|
2397
|
+
} else {
|
|
2398
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2402
|
+
}
|
|
2403
|
+
tagName2 = state.input.slice(_position, state.position);
|
|
2404
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName2)) {
|
|
2405
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
if (tagName2 && !PATTERN_TAG_URI.test(tagName2)) {
|
|
2409
|
+
throwError(state, "tag name cannot contain such characters: " + tagName2);
|
|
2410
|
+
}
|
|
2411
|
+
try {
|
|
2412
|
+
tagName2 = decodeURIComponent(tagName2);
|
|
2413
|
+
} catch (err) {
|
|
2414
|
+
throwError(state, "tag name is malformed: " + tagName2);
|
|
2415
|
+
}
|
|
2416
|
+
if (isVerbatim) {
|
|
2417
|
+
state.tag = tagName2;
|
|
2418
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
2419
|
+
state.tag = state.tagMap[tagHandle] + tagName2;
|
|
2420
|
+
} else if (tagHandle === "!") {
|
|
2421
|
+
state.tag = "!" + tagName2;
|
|
2422
|
+
} else if (tagHandle === "!!") {
|
|
2423
|
+
state.tag = "tag:yaml.org,2002:" + tagName2;
|
|
2424
|
+
} else {
|
|
2425
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
2426
|
+
}
|
|
2427
|
+
return true;
|
|
2428
|
+
}
|
|
2429
|
+
function readAnchorProperty(state) {
|
|
2430
|
+
var _position, ch;
|
|
2431
|
+
ch = state.input.charCodeAt(state.position);
|
|
2432
|
+
if (ch !== 38) return false;
|
|
2433
|
+
if (state.anchor !== null) {
|
|
2434
|
+
throwError(state, "duplication of an anchor property");
|
|
2435
|
+
}
|
|
2436
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2437
|
+
_position = state.position;
|
|
2438
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2439
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2440
|
+
}
|
|
2441
|
+
if (state.position === _position) {
|
|
2442
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
2443
|
+
}
|
|
2444
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
2445
|
+
return true;
|
|
2446
|
+
}
|
|
2447
|
+
function readAlias(state) {
|
|
2448
|
+
var _position, alias, ch;
|
|
2449
|
+
ch = state.input.charCodeAt(state.position);
|
|
2450
|
+
if (ch !== 42) return false;
|
|
2451
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2452
|
+
_position = state.position;
|
|
2453
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2454
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2455
|
+
}
|
|
2456
|
+
if (state.position === _position) {
|
|
2457
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
2458
|
+
}
|
|
2459
|
+
alias = state.input.slice(_position, state.position);
|
|
2460
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
2461
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
2462
|
+
}
|
|
2463
|
+
state.result = state.anchorMap[alias];
|
|
2464
|
+
skipSeparationSpace(state, true, -1);
|
|
2465
|
+
return true;
|
|
2466
|
+
}
|
|
2467
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
2468
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
2469
|
+
if (state.listener !== null) {
|
|
2470
|
+
state.listener("open", state);
|
|
2471
|
+
}
|
|
2472
|
+
state.tag = null;
|
|
2473
|
+
state.anchor = null;
|
|
2474
|
+
state.kind = null;
|
|
2475
|
+
state.result = null;
|
|
2476
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
2477
|
+
if (allowToSeek) {
|
|
2478
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2479
|
+
atNewLine = true;
|
|
2480
|
+
if (state.lineIndent > parentIndent) {
|
|
2481
|
+
indentStatus = 1;
|
|
2482
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2483
|
+
indentStatus = 0;
|
|
2484
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2485
|
+
indentStatus = -1;
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
if (indentStatus === 1) {
|
|
2490
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
2491
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2492
|
+
atNewLine = true;
|
|
2493
|
+
allowBlockCollections = allowBlockStyles;
|
|
2494
|
+
if (state.lineIndent > parentIndent) {
|
|
2495
|
+
indentStatus = 1;
|
|
2496
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2497
|
+
indentStatus = 0;
|
|
2498
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2499
|
+
indentStatus = -1;
|
|
2500
|
+
}
|
|
2501
|
+
} else {
|
|
2502
|
+
allowBlockCollections = false;
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
if (allowBlockCollections) {
|
|
2507
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
2508
|
+
}
|
|
2509
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
2510
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
2511
|
+
flowIndent = parentIndent;
|
|
2512
|
+
} else {
|
|
2513
|
+
flowIndent = parentIndent + 1;
|
|
2514
|
+
}
|
|
2515
|
+
blockIndent = state.position - state.lineStart;
|
|
2516
|
+
if (indentStatus === 1) {
|
|
2517
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
2518
|
+
hasContent = true;
|
|
2519
|
+
} else {
|
|
2520
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
2521
|
+
hasContent = true;
|
|
2522
|
+
} else if (readAlias(state)) {
|
|
2523
|
+
hasContent = true;
|
|
2524
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
2525
|
+
throwError(state, "alias node should not have any properties");
|
|
2526
|
+
}
|
|
2527
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
2528
|
+
hasContent = true;
|
|
2529
|
+
if (state.tag === null) {
|
|
2530
|
+
state.tag = "?";
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
if (state.anchor !== null) {
|
|
2534
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
} else if (indentStatus === 0) {
|
|
2538
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
if (state.tag === null) {
|
|
2542
|
+
if (state.anchor !== null) {
|
|
2543
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2544
|
+
}
|
|
2545
|
+
} else if (state.tag === "?") {
|
|
2546
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
2547
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
2548
|
+
}
|
|
2549
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2550
|
+
type2 = state.implicitTypes[typeIndex];
|
|
2551
|
+
if (type2.resolve(state.result)) {
|
|
2552
|
+
state.result = type2.construct(state.result);
|
|
2553
|
+
state.tag = type2.tag;
|
|
2554
|
+
if (state.anchor !== null) {
|
|
2555
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2556
|
+
}
|
|
2557
|
+
break;
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
} else if (state.tag !== "!") {
|
|
2561
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
2562
|
+
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
2563
|
+
} else {
|
|
2564
|
+
type2 = null;
|
|
2565
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
2566
|
+
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2567
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
2568
|
+
type2 = typeList[typeIndex];
|
|
2569
|
+
break;
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
if (!type2) {
|
|
2574
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
2575
|
+
}
|
|
2576
|
+
if (state.result !== null && type2.kind !== state.kind) {
|
|
2577
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
2578
|
+
}
|
|
2579
|
+
if (!type2.resolve(state.result, state.tag)) {
|
|
2580
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
2581
|
+
} else {
|
|
2582
|
+
state.result = type2.construct(state.result, state.tag);
|
|
2583
|
+
if (state.anchor !== null) {
|
|
2584
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
if (state.listener !== null) {
|
|
2589
|
+
state.listener("close", state);
|
|
2590
|
+
}
|
|
2591
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
2592
|
+
}
|
|
2593
|
+
function readDocument(state) {
|
|
2594
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
2595
|
+
state.version = null;
|
|
2596
|
+
state.checkLineBreaks = state.legacy;
|
|
2597
|
+
state.tagMap = /* @__PURE__ */ Object.create(null);
|
|
2598
|
+
state.anchorMap = /* @__PURE__ */ Object.create(null);
|
|
2599
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2600
|
+
skipSeparationSpace(state, true, -1);
|
|
2601
|
+
ch = state.input.charCodeAt(state.position);
|
|
2602
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
2603
|
+
break;
|
|
2604
|
+
}
|
|
2605
|
+
hasDirectives = true;
|
|
2606
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2607
|
+
_position = state.position;
|
|
2608
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2609
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2610
|
+
}
|
|
2611
|
+
directiveName = state.input.slice(_position, state.position);
|
|
2612
|
+
directiveArgs = [];
|
|
2613
|
+
if (directiveName.length < 1) {
|
|
2614
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
2615
|
+
}
|
|
2616
|
+
while (ch !== 0) {
|
|
2617
|
+
while (is_WHITE_SPACE(ch)) {
|
|
2618
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2619
|
+
}
|
|
2620
|
+
if (ch === 35) {
|
|
2621
|
+
do {
|
|
2622
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2623
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
2624
|
+
break;
|
|
2625
|
+
}
|
|
2626
|
+
if (is_EOL(ch)) break;
|
|
2627
|
+
_position = state.position;
|
|
2628
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2629
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2630
|
+
}
|
|
2631
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2632
|
+
}
|
|
2633
|
+
if (ch !== 0) readLineBreak(state);
|
|
2634
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
2635
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2636
|
+
} else {
|
|
2637
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
skipSeparationSpace(state, true, -1);
|
|
2641
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
2642
|
+
state.position += 3;
|
|
2643
|
+
skipSeparationSpace(state, true, -1);
|
|
2644
|
+
} else if (hasDirectives) {
|
|
2645
|
+
throwError(state, "directives end mark is expected");
|
|
2646
|
+
}
|
|
2647
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2648
|
+
skipSeparationSpace(state, true, -1);
|
|
2649
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
2650
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
2651
|
+
}
|
|
2652
|
+
state.documents.push(state.result);
|
|
2653
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2654
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
2655
|
+
state.position += 3;
|
|
2656
|
+
skipSeparationSpace(state, true, -1);
|
|
2657
|
+
}
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
if (state.position < state.length - 1) {
|
|
2661
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
2662
|
+
} else {
|
|
2663
|
+
return;
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
function loadDocuments(input, options) {
|
|
2667
|
+
input = String(input);
|
|
2668
|
+
options = options || {};
|
|
2669
|
+
if (input.length !== 0) {
|
|
2670
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
2671
|
+
input += "\n";
|
|
2672
|
+
}
|
|
2673
|
+
if (input.charCodeAt(0) === 65279) {
|
|
2674
|
+
input = input.slice(1);
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
var state = new State$1(input, options);
|
|
2678
|
+
var nullpos = input.indexOf("\0");
|
|
2679
|
+
if (nullpos !== -1) {
|
|
2680
|
+
state.position = nullpos;
|
|
2681
|
+
throwError(state, "null byte is not allowed in input");
|
|
2682
|
+
}
|
|
2683
|
+
state.input += "\0";
|
|
2684
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
2685
|
+
state.lineIndent += 1;
|
|
2686
|
+
state.position += 1;
|
|
2687
|
+
}
|
|
2688
|
+
while (state.position < state.length - 1) {
|
|
2689
|
+
readDocument(state);
|
|
2690
|
+
}
|
|
2691
|
+
return state.documents;
|
|
2692
|
+
}
|
|
2693
|
+
function loadAll$1(input, iterator, options) {
|
|
2694
|
+
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
2695
|
+
options = iterator;
|
|
2696
|
+
iterator = null;
|
|
2697
|
+
}
|
|
2698
|
+
var documents = loadDocuments(input, options);
|
|
2699
|
+
if (typeof iterator !== "function") {
|
|
2700
|
+
return documents;
|
|
2701
|
+
}
|
|
2702
|
+
for (var index = 0, length = documents.length; index < length; index += 1) {
|
|
2703
|
+
iterator(documents[index]);
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
function load$1(input, options) {
|
|
2707
|
+
var documents = loadDocuments(input, options);
|
|
2708
|
+
if (documents.length === 0) {
|
|
2709
|
+
return void 0;
|
|
2710
|
+
} else if (documents.length === 1) {
|
|
2711
|
+
return documents[0];
|
|
2712
|
+
}
|
|
2713
|
+
throw new exception("expected a single document in the stream, but found more");
|
|
2714
|
+
}
|
|
2715
|
+
var loadAll_1 = loadAll$1;
|
|
2716
|
+
var load_1 = load$1;
|
|
2717
|
+
var loader = {
|
|
2718
|
+
loadAll: loadAll_1,
|
|
2719
|
+
load: load_1
|
|
2720
|
+
};
|
|
2721
|
+
var _toString = Object.prototype.toString;
|
|
2722
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2723
|
+
var CHAR_BOM = 65279;
|
|
2724
|
+
var CHAR_TAB = 9;
|
|
2725
|
+
var CHAR_LINE_FEED = 10;
|
|
2726
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
2727
|
+
var CHAR_SPACE = 32;
|
|
2728
|
+
var CHAR_EXCLAMATION = 33;
|
|
2729
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
2730
|
+
var CHAR_SHARP = 35;
|
|
2731
|
+
var CHAR_PERCENT = 37;
|
|
2732
|
+
var CHAR_AMPERSAND = 38;
|
|
2733
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
2734
|
+
var CHAR_ASTERISK = 42;
|
|
2735
|
+
var CHAR_COMMA = 44;
|
|
2736
|
+
var CHAR_MINUS = 45;
|
|
2737
|
+
var CHAR_COLON = 58;
|
|
2738
|
+
var CHAR_EQUALS = 61;
|
|
2739
|
+
var CHAR_GREATER_THAN = 62;
|
|
2740
|
+
var CHAR_QUESTION = 63;
|
|
2741
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
2742
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2743
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2744
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
2745
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2746
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
2747
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2748
|
+
var ESCAPE_SEQUENCES = {};
|
|
2749
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2750
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2751
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2752
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2753
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2754
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2755
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2756
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2757
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2758
|
+
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2759
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2760
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2761
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2762
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2763
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2764
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2765
|
+
"y",
|
|
2766
|
+
"Y",
|
|
2767
|
+
"yes",
|
|
2768
|
+
"Yes",
|
|
2769
|
+
"YES",
|
|
2770
|
+
"on",
|
|
2771
|
+
"On",
|
|
2772
|
+
"ON",
|
|
2773
|
+
"n",
|
|
2774
|
+
"N",
|
|
2775
|
+
"no",
|
|
2776
|
+
"No",
|
|
2777
|
+
"NO",
|
|
2778
|
+
"off",
|
|
2779
|
+
"Off",
|
|
2780
|
+
"OFF"
|
|
2781
|
+
];
|
|
2782
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2783
|
+
function compileStyleMap(schema2, map2) {
|
|
2784
|
+
var result, keys, index, length, tag, style, type2;
|
|
2785
|
+
if (map2 === null) return {};
|
|
2786
|
+
result = {};
|
|
2787
|
+
keys = Object.keys(map2);
|
|
2788
|
+
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
2789
|
+
tag = keys[index];
|
|
2790
|
+
style = String(map2[tag]);
|
|
2791
|
+
if (tag.slice(0, 2) === "!!") {
|
|
2792
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2793
|
+
}
|
|
2794
|
+
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
2795
|
+
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
2796
|
+
style = type2.styleAliases[style];
|
|
2797
|
+
}
|
|
2798
|
+
result[tag] = style;
|
|
2799
|
+
}
|
|
2800
|
+
return result;
|
|
2801
|
+
}
|
|
2802
|
+
function encodeHex(character) {
|
|
2803
|
+
var string, handle, length;
|
|
2804
|
+
string = character.toString(16).toUpperCase();
|
|
2805
|
+
if (character <= 255) {
|
|
2806
|
+
handle = "x";
|
|
2807
|
+
length = 2;
|
|
2808
|
+
} else if (character <= 65535) {
|
|
2809
|
+
handle = "u";
|
|
2810
|
+
length = 4;
|
|
2811
|
+
} else if (character <= 4294967295) {
|
|
2812
|
+
handle = "U";
|
|
2813
|
+
length = 8;
|
|
2814
|
+
} else {
|
|
2815
|
+
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2816
|
+
}
|
|
2817
|
+
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2818
|
+
}
|
|
2819
|
+
var QUOTING_TYPE_SINGLE = 1;
|
|
2820
|
+
var QUOTING_TYPE_DOUBLE = 2;
|
|
2821
|
+
function State(options) {
|
|
2822
|
+
this.schema = options["schema"] || _default;
|
|
2823
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
2824
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2825
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
2826
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2827
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2828
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
2829
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
2830
|
+
this.noRefs = options["noRefs"] || false;
|
|
2831
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
2832
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
2833
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2834
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
2835
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
2836
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
2837
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
2838
|
+
this.tag = null;
|
|
2839
|
+
this.result = "";
|
|
2840
|
+
this.duplicates = [];
|
|
2841
|
+
this.usedDuplicates = null;
|
|
2842
|
+
}
|
|
2843
|
+
function indentString(string, spaces) {
|
|
2844
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
2845
|
+
while (position < length) {
|
|
2846
|
+
next = string.indexOf("\n", position);
|
|
2847
|
+
if (next === -1) {
|
|
2848
|
+
line = string.slice(position);
|
|
2849
|
+
position = length;
|
|
2850
|
+
} else {
|
|
2851
|
+
line = string.slice(position, next + 1);
|
|
2852
|
+
position = next + 1;
|
|
2853
|
+
}
|
|
2854
|
+
if (line.length && line !== "\n") result += ind;
|
|
2855
|
+
result += line;
|
|
2856
|
+
}
|
|
2857
|
+
return result;
|
|
2858
|
+
}
|
|
2859
|
+
function generateNextLine(state, level) {
|
|
2860
|
+
return "\n" + common.repeat(" ", state.indent * level);
|
|
2861
|
+
}
|
|
2862
|
+
function testImplicitResolving(state, str2) {
|
|
2863
|
+
var index, length, type2;
|
|
2864
|
+
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
2865
|
+
type2 = state.implicitTypes[index];
|
|
2866
|
+
if (type2.resolve(str2)) {
|
|
2867
|
+
return true;
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
return false;
|
|
2871
|
+
}
|
|
2872
|
+
function isWhitespace(c) {
|
|
2873
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2874
|
+
}
|
|
2875
|
+
function isPrintable(c) {
|
|
2876
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
2877
|
+
}
|
|
2878
|
+
function isNsCharOrWhitespace(c) {
|
|
2879
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2880
|
+
}
|
|
2881
|
+
function isPlainSafe(c, prev, inblock) {
|
|
2882
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2883
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2884
|
+
return (
|
|
2885
|
+
// ns-plain-safe
|
|
2886
|
+
(inblock ? (
|
|
2887
|
+
// c = flow-in
|
|
2888
|
+
cIsNsCharOrWhitespace
|
|
2889
|
+
) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
|
|
2890
|
+
);
|
|
2891
|
+
}
|
|
2892
|
+
function isPlainSafeFirst(c) {
|
|
2893
|
+
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
|
|
2894
|
+
}
|
|
2895
|
+
function isPlainSafeLast(c) {
|
|
2896
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2897
|
+
}
|
|
2898
|
+
function codePointAt(string, pos) {
|
|
2899
|
+
var first = string.charCodeAt(pos), second;
|
|
2900
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
2901
|
+
second = string.charCodeAt(pos + 1);
|
|
2902
|
+
if (second >= 56320 && second <= 57343) {
|
|
2903
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
return first;
|
|
2907
|
+
}
|
|
2908
|
+
function needIndentIndicator(string) {
|
|
2909
|
+
var leadingSpaceRe = /^\n* /;
|
|
2910
|
+
return leadingSpaceRe.test(string);
|
|
2911
|
+
}
|
|
2912
|
+
var STYLE_PLAIN = 1;
|
|
2913
|
+
var STYLE_SINGLE = 2;
|
|
2914
|
+
var STYLE_LITERAL = 3;
|
|
2915
|
+
var STYLE_FOLDED = 4;
|
|
2916
|
+
var STYLE_DOUBLE = 5;
|
|
2917
|
+
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
2918
|
+
var i2;
|
|
2919
|
+
var char = 0;
|
|
2920
|
+
var prevChar = null;
|
|
2921
|
+
var hasLineBreak = false;
|
|
2922
|
+
var hasFoldableLine = false;
|
|
2923
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
2924
|
+
var previousLineBreak = -1;
|
|
2925
|
+
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
2926
|
+
if (singleLineOnly || forceQuotes) {
|
|
2927
|
+
for (i2 = 0; i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
2928
|
+
char = codePointAt(string, i2);
|
|
2929
|
+
if (!isPrintable(char)) {
|
|
2930
|
+
return STYLE_DOUBLE;
|
|
2931
|
+
}
|
|
2932
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2933
|
+
prevChar = char;
|
|
2934
|
+
}
|
|
2935
|
+
} else {
|
|
2936
|
+
for (i2 = 0; i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
2937
|
+
char = codePointAt(string, i2);
|
|
2938
|
+
if (char === CHAR_LINE_FEED) {
|
|
2939
|
+
hasLineBreak = true;
|
|
2940
|
+
if (shouldTrackWidth) {
|
|
2941
|
+
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
2942
|
+
i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2943
|
+
previousLineBreak = i2;
|
|
2944
|
+
}
|
|
2945
|
+
} else if (!isPrintable(char)) {
|
|
2946
|
+
return STYLE_DOUBLE;
|
|
2947
|
+
}
|
|
2948
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2949
|
+
prevChar = char;
|
|
2950
|
+
}
|
|
2951
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
2952
|
+
}
|
|
2953
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
2954
|
+
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
2955
|
+
return STYLE_PLAIN;
|
|
2956
|
+
}
|
|
2957
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2958
|
+
}
|
|
2959
|
+
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
2960
|
+
return STYLE_DOUBLE;
|
|
2961
|
+
}
|
|
2962
|
+
if (!forceQuotes) {
|
|
2963
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2964
|
+
}
|
|
2965
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2966
|
+
}
|
|
2967
|
+
function writeScalar(state, string, level, iskey, inblock) {
|
|
2968
|
+
state.dump = (function() {
|
|
2969
|
+
if (string.length === 0) {
|
|
2970
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
2971
|
+
}
|
|
2972
|
+
if (!state.noCompatMode) {
|
|
2973
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
2974
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
var indent = state.indent * Math.max(1, level);
|
|
2978
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2979
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2980
|
+
function testAmbiguity(string2) {
|
|
2981
|
+
return testImplicitResolving(state, string2);
|
|
2982
|
+
}
|
|
2983
|
+
switch (chooseScalarStyle(
|
|
2984
|
+
string,
|
|
2985
|
+
singleLineOnly,
|
|
2986
|
+
state.indent,
|
|
2987
|
+
lineWidth,
|
|
2988
|
+
testAmbiguity,
|
|
2989
|
+
state.quotingType,
|
|
2990
|
+
state.forceQuotes && !iskey,
|
|
2991
|
+
inblock
|
|
2992
|
+
)) {
|
|
2993
|
+
case STYLE_PLAIN:
|
|
2994
|
+
return string;
|
|
2995
|
+
case STYLE_SINGLE:
|
|
2996
|
+
return "'" + string.replace(/'/g, "''") + "'";
|
|
2997
|
+
case STYLE_LITERAL:
|
|
2998
|
+
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2999
|
+
case STYLE_FOLDED:
|
|
3000
|
+
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
3001
|
+
case STYLE_DOUBLE:
|
|
3002
|
+
return '"' + escapeString(string) + '"';
|
|
3003
|
+
default:
|
|
3004
|
+
throw new exception("impossible error: invalid scalar style");
|
|
3005
|
+
}
|
|
3006
|
+
})();
|
|
3007
|
+
}
|
|
3008
|
+
function blockHeader(string, indentPerLevel) {
|
|
3009
|
+
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
3010
|
+
var clip = string[string.length - 1] === "\n";
|
|
3011
|
+
var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
|
|
3012
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
3013
|
+
return indentIndicator + chomp + "\n";
|
|
3014
|
+
}
|
|
3015
|
+
function dropEndingNewline(string) {
|
|
3016
|
+
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
3017
|
+
}
|
|
3018
|
+
function foldString(string, width) {
|
|
3019
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
3020
|
+
var result = (function() {
|
|
3021
|
+
var nextLF = string.indexOf("\n");
|
|
3022
|
+
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
3023
|
+
lineRe.lastIndex = nextLF;
|
|
3024
|
+
return foldLine(string.slice(0, nextLF), width);
|
|
3025
|
+
})();
|
|
3026
|
+
var prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
3027
|
+
var moreIndented;
|
|
3028
|
+
var match;
|
|
3029
|
+
while (match = lineRe.exec(string)) {
|
|
3030
|
+
var prefix = match[1], line = match[2];
|
|
3031
|
+
moreIndented = line[0] === " ";
|
|
3032
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
3033
|
+
prevMoreIndented = moreIndented;
|
|
3034
|
+
}
|
|
3035
|
+
return result;
|
|
3036
|
+
}
|
|
3037
|
+
function foldLine(line, width) {
|
|
3038
|
+
if (line === "" || line[0] === " ") return line;
|
|
3039
|
+
var breakRe = / [^ ]/g;
|
|
3040
|
+
var match;
|
|
3041
|
+
var start = 0, end, curr = 0, next = 0;
|
|
3042
|
+
var result = "";
|
|
3043
|
+
while (match = breakRe.exec(line)) {
|
|
3044
|
+
next = match.index;
|
|
3045
|
+
if (next - start > width) {
|
|
3046
|
+
end = curr > start ? curr : next;
|
|
3047
|
+
result += "\n" + line.slice(start, end);
|
|
3048
|
+
start = end + 1;
|
|
3049
|
+
}
|
|
3050
|
+
curr = next;
|
|
3051
|
+
}
|
|
3052
|
+
result += "\n";
|
|
3053
|
+
if (line.length - start > width && curr > start) {
|
|
3054
|
+
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
3055
|
+
} else {
|
|
3056
|
+
result += line.slice(start);
|
|
3057
|
+
}
|
|
3058
|
+
return result.slice(1);
|
|
3059
|
+
}
|
|
3060
|
+
function escapeString(string) {
|
|
3061
|
+
var result = "";
|
|
3062
|
+
var char = 0;
|
|
3063
|
+
var escapeSeq;
|
|
3064
|
+
for (var i2 = 0; i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
3065
|
+
char = codePointAt(string, i2);
|
|
3066
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
3067
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
3068
|
+
result += string[i2];
|
|
3069
|
+
if (char >= 65536) result += string[i2 + 1];
|
|
3070
|
+
} else {
|
|
3071
|
+
result += escapeSeq || encodeHex(char);
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
return result;
|
|
3075
|
+
}
|
|
3076
|
+
function writeFlowSequence(state, level, object) {
|
|
3077
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
3078
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
3079
|
+
value = object[index];
|
|
3080
|
+
if (state.replacer) {
|
|
3081
|
+
value = state.replacer.call(object, String(index), value);
|
|
3082
|
+
}
|
|
3083
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
3084
|
+
if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
|
|
3085
|
+
_result += state.dump;
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
state.tag = _tag;
|
|
3089
|
+
state.dump = "[" + _result + "]";
|
|
3090
|
+
}
|
|
3091
|
+
function writeBlockSequence(state, level, object, compact) {
|
|
3092
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
3093
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
3094
|
+
value = object[index];
|
|
3095
|
+
if (state.replacer) {
|
|
3096
|
+
value = state.replacer.call(object, String(index), value);
|
|
3097
|
+
}
|
|
3098
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
3099
|
+
if (!compact || _result !== "") {
|
|
3100
|
+
_result += generateNextLine(state, level);
|
|
3101
|
+
}
|
|
3102
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
3103
|
+
_result += "-";
|
|
3104
|
+
} else {
|
|
3105
|
+
_result += "- ";
|
|
3106
|
+
}
|
|
3107
|
+
_result += state.dump;
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
state.tag = _tag;
|
|
3111
|
+
state.dump = _result || "[]";
|
|
3112
|
+
}
|
|
3113
|
+
function writeFlowMapping(state, level, object) {
|
|
3114
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
3115
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
3116
|
+
pairBuffer = "";
|
|
3117
|
+
if (_result !== "") pairBuffer += ", ";
|
|
3118
|
+
if (state.condenseFlow) pairBuffer += '"';
|
|
3119
|
+
objectKey = objectKeyList[index];
|
|
3120
|
+
objectValue = object[objectKey];
|
|
3121
|
+
if (state.replacer) {
|
|
3122
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
3123
|
+
}
|
|
3124
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
3125
|
+
continue;
|
|
3126
|
+
}
|
|
3127
|
+
if (state.dump.length > 1024) pairBuffer += "? ";
|
|
3128
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
3129
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
3130
|
+
continue;
|
|
3131
|
+
}
|
|
3132
|
+
pairBuffer += state.dump;
|
|
3133
|
+
_result += pairBuffer;
|
|
3134
|
+
}
|
|
3135
|
+
state.tag = _tag;
|
|
3136
|
+
state.dump = "{" + _result + "}";
|
|
3137
|
+
}
|
|
3138
|
+
function writeBlockMapping(state, level, object, compact) {
|
|
3139
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
3140
|
+
if (state.sortKeys === true) {
|
|
3141
|
+
objectKeyList.sort();
|
|
3142
|
+
} else if (typeof state.sortKeys === "function") {
|
|
3143
|
+
objectKeyList.sort(state.sortKeys);
|
|
3144
|
+
} else if (state.sortKeys) {
|
|
3145
|
+
throw new exception("sortKeys must be a boolean or a function");
|
|
3146
|
+
}
|
|
3147
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
3148
|
+
pairBuffer = "";
|
|
3149
|
+
if (!compact || _result !== "") {
|
|
3150
|
+
pairBuffer += generateNextLine(state, level);
|
|
3151
|
+
}
|
|
3152
|
+
objectKey = objectKeyList[index];
|
|
3153
|
+
objectValue = object[objectKey];
|
|
3154
|
+
if (state.replacer) {
|
|
3155
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
3156
|
+
}
|
|
3157
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
3158
|
+
continue;
|
|
3159
|
+
}
|
|
3160
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
3161
|
+
if (explicitPair) {
|
|
3162
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
3163
|
+
pairBuffer += "?";
|
|
3164
|
+
} else {
|
|
3165
|
+
pairBuffer += "? ";
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
pairBuffer += state.dump;
|
|
3169
|
+
if (explicitPair) {
|
|
3170
|
+
pairBuffer += generateNextLine(state, level);
|
|
3171
|
+
}
|
|
3172
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
3173
|
+
continue;
|
|
3174
|
+
}
|
|
3175
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
3176
|
+
pairBuffer += ":";
|
|
3177
|
+
} else {
|
|
3178
|
+
pairBuffer += ": ";
|
|
3179
|
+
}
|
|
3180
|
+
pairBuffer += state.dump;
|
|
3181
|
+
_result += pairBuffer;
|
|
3182
|
+
}
|
|
3183
|
+
state.tag = _tag;
|
|
3184
|
+
state.dump = _result || "{}";
|
|
3185
|
+
}
|
|
3186
|
+
function detectType(state, object, explicit) {
|
|
3187
|
+
var _result, typeList, index, length, type2, style;
|
|
3188
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
3189
|
+
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
3190
|
+
type2 = typeList[index];
|
|
3191
|
+
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
|
|
3192
|
+
if (explicit) {
|
|
3193
|
+
if (type2.multi && type2.representName) {
|
|
3194
|
+
state.tag = type2.representName(object);
|
|
3195
|
+
} else {
|
|
3196
|
+
state.tag = type2.tag;
|
|
3197
|
+
}
|
|
3198
|
+
} else {
|
|
3199
|
+
state.tag = "?";
|
|
3200
|
+
}
|
|
3201
|
+
if (type2.represent) {
|
|
3202
|
+
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
3203
|
+
if (_toString.call(type2.represent) === "[object Function]") {
|
|
3204
|
+
_result = type2.represent(object, style);
|
|
3205
|
+
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
3206
|
+
_result = type2.represent[style](object, style);
|
|
3207
|
+
} else {
|
|
3208
|
+
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
3209
|
+
}
|
|
3210
|
+
state.dump = _result;
|
|
3211
|
+
}
|
|
3212
|
+
return true;
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
return false;
|
|
3216
|
+
}
|
|
3217
|
+
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
3218
|
+
state.tag = null;
|
|
3219
|
+
state.dump = object;
|
|
3220
|
+
if (!detectType(state, object, false)) {
|
|
3221
|
+
detectType(state, object, true);
|
|
3222
|
+
}
|
|
3223
|
+
var type2 = _toString.call(state.dump);
|
|
3224
|
+
var inblock = block;
|
|
3225
|
+
var tagStr;
|
|
3226
|
+
if (block) {
|
|
3227
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
3228
|
+
}
|
|
3229
|
+
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
3230
|
+
if (objectOrArray) {
|
|
3231
|
+
duplicateIndex = state.duplicates.indexOf(object);
|
|
3232
|
+
duplicate = duplicateIndex !== -1;
|
|
3233
|
+
}
|
|
3234
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
3235
|
+
compact = false;
|
|
3236
|
+
}
|
|
3237
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
3238
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
3239
|
+
} else {
|
|
3240
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
3241
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
3242
|
+
}
|
|
3243
|
+
if (type2 === "[object Object]") {
|
|
3244
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
3245
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
3246
|
+
if (duplicate) {
|
|
3247
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
3248
|
+
}
|
|
3249
|
+
} else {
|
|
3250
|
+
writeFlowMapping(state, level, state.dump);
|
|
3251
|
+
if (duplicate) {
|
|
3252
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
} else if (type2 === "[object Array]") {
|
|
3256
|
+
if (block && state.dump.length !== 0) {
|
|
3257
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
3258
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
3259
|
+
} else {
|
|
3260
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
3261
|
+
}
|
|
3262
|
+
if (duplicate) {
|
|
3263
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
3264
|
+
}
|
|
3265
|
+
} else {
|
|
3266
|
+
writeFlowSequence(state, level, state.dump);
|
|
3267
|
+
if (duplicate) {
|
|
3268
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
} else if (type2 === "[object String]") {
|
|
3272
|
+
if (state.tag !== "?") {
|
|
3273
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
3274
|
+
}
|
|
3275
|
+
} else if (type2 === "[object Undefined]") {
|
|
3276
|
+
return false;
|
|
3277
|
+
} else {
|
|
3278
|
+
if (state.skipInvalid) return false;
|
|
3279
|
+
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
3280
|
+
}
|
|
3281
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
3282
|
+
tagStr = encodeURI(
|
|
3283
|
+
state.tag[0] === "!" ? state.tag.slice(1) : state.tag
|
|
3284
|
+
).replace(/!/g, "%21");
|
|
3285
|
+
if (state.tag[0] === "!") {
|
|
3286
|
+
tagStr = "!" + tagStr;
|
|
3287
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
3288
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
3289
|
+
} else {
|
|
3290
|
+
tagStr = "!<" + tagStr + ">";
|
|
3291
|
+
}
|
|
3292
|
+
state.dump = tagStr + " " + state.dump;
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
return true;
|
|
3296
|
+
}
|
|
3297
|
+
function getDuplicateReferences(object, state) {
|
|
3298
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
3299
|
+
inspectNode(object, objects, duplicatesIndexes);
|
|
3300
|
+
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
3301
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
3302
|
+
}
|
|
3303
|
+
state.usedDuplicates = new Array(length);
|
|
3304
|
+
}
|
|
3305
|
+
function inspectNode(object, objects, duplicatesIndexes) {
|
|
3306
|
+
var objectKeyList, index, length;
|
|
3307
|
+
if (object !== null && typeof object === "object") {
|
|
3308
|
+
index = objects.indexOf(object);
|
|
3309
|
+
if (index !== -1) {
|
|
3310
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
3311
|
+
duplicatesIndexes.push(index);
|
|
3312
|
+
}
|
|
3313
|
+
} else {
|
|
3314
|
+
objects.push(object);
|
|
3315
|
+
if (Array.isArray(object)) {
|
|
3316
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
3317
|
+
inspectNode(object[index], objects, duplicatesIndexes);
|
|
3318
|
+
}
|
|
3319
|
+
} else {
|
|
3320
|
+
objectKeyList = Object.keys(object);
|
|
3321
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
3322
|
+
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
function dump$1(input, options) {
|
|
3329
|
+
options = options || {};
|
|
3330
|
+
var state = new State(options);
|
|
3331
|
+
if (!state.noRefs) getDuplicateReferences(input, state);
|
|
3332
|
+
var value = input;
|
|
3333
|
+
if (state.replacer) {
|
|
3334
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
3335
|
+
}
|
|
3336
|
+
if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
|
|
3337
|
+
return "";
|
|
3338
|
+
}
|
|
3339
|
+
var dump_1 = dump$1;
|
|
3340
|
+
var dumper = {
|
|
3341
|
+
dump: dump_1
|
|
3342
|
+
};
|
|
3343
|
+
function renamed(from, to) {
|
|
3344
|
+
return function() {
|
|
3345
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
|
|
3346
|
+
};
|
|
3347
|
+
}
|
|
3348
|
+
var Type = type;
|
|
3349
|
+
var Schema = schema;
|
|
3350
|
+
var FAILSAFE_SCHEMA = failsafe;
|
|
3351
|
+
var JSON_SCHEMA = json;
|
|
3352
|
+
var CORE_SCHEMA = core;
|
|
3353
|
+
var DEFAULT_SCHEMA = _default;
|
|
3354
|
+
var load = loader.load;
|
|
3355
|
+
var loadAll = loader.loadAll;
|
|
3356
|
+
var dump = dumper.dump;
|
|
3357
|
+
var YAMLException = exception;
|
|
3358
|
+
var types = {
|
|
3359
|
+
binary,
|
|
3360
|
+
float,
|
|
3361
|
+
map,
|
|
3362
|
+
null: _null,
|
|
3363
|
+
pairs,
|
|
3364
|
+
set,
|
|
3365
|
+
timestamp,
|
|
3366
|
+
bool,
|
|
3367
|
+
int,
|
|
3368
|
+
merge,
|
|
3369
|
+
omap,
|
|
3370
|
+
seq,
|
|
3371
|
+
str
|
|
3372
|
+
};
|
|
3373
|
+
var safeLoad = renamed("safeLoad", "load");
|
|
3374
|
+
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
3375
|
+
var safeDump = renamed("safeDump", "dump");
|
|
3376
|
+
var jsYaml = {
|
|
3377
|
+
Type,
|
|
3378
|
+
Schema,
|
|
3379
|
+
FAILSAFE_SCHEMA,
|
|
3380
|
+
JSON_SCHEMA,
|
|
3381
|
+
CORE_SCHEMA,
|
|
3382
|
+
DEFAULT_SCHEMA,
|
|
3383
|
+
load,
|
|
3384
|
+
loadAll,
|
|
3385
|
+
dump,
|
|
3386
|
+
YAMLException,
|
|
3387
|
+
types,
|
|
3388
|
+
safeLoad,
|
|
3389
|
+
safeLoadAll,
|
|
3390
|
+
safeDump
|
|
3391
|
+
};
|
|
3392
|
+
|
|
3393
|
+
// src/diagnostics.ts
|
|
3394
|
+
import fs2 from "node:fs";
|
|
3395
|
+
import path2 from "node:path";
|
|
3396
|
+
|
|
3397
|
+
// src/equivalents.ts
|
|
3398
|
+
import fs from "node:fs";
|
|
3399
|
+
import path from "node:path";
|
|
3400
|
+
var SERVE = "ssqch's dev server is `ssqch serve`: it builds, watches and reloads the browser.";
|
|
3401
|
+
var TABLE = [
|
|
3402
|
+
// Commands.
|
|
3403
|
+
{ word: "dev", kind: "command", alias: true, from: [], ssqch: "serve", say: SERVE, more: "ssqch docs serve" },
|
|
3404
|
+
{ word: "start", kind: "command", alias: true, from: [], ssqch: "serve", say: SERVE, more: "ssqch docs serve" },
|
|
3405
|
+
{ word: "server", kind: "command", alias: true, from: ["Hugo", "Hexo", "Jekyll"], ssqch: "serve", say: SERVE, more: "ssqch docs serve" },
|
|
3406
|
+
{ word: "preview", kind: "command", alias: true, from: ["Astro", "VitePress"], ssqch: "serve --built", say: "Serving a production build as it is, without building or reloading, is `ssqch serve --built`.", more: "ssqch docs serve" },
|
|
3407
|
+
{ word: "watch", kind: "command", alias: true, from: [], ssqch: "serve", say: SERVE, more: "ssqch docs serve" },
|
|
3408
|
+
{ word: "check", kind: "command", alias: false, from: ["Zola", "Astro"], ssqch: "build", say: "`ssqch build` checks as it builds: content schemas on every build, and internal links with `linksPlugin()`.", more: 'ssqch docs "Content schemas"' },
|
|
3409
|
+
{ word: "clean", kind: "command", alias: false, from: ["Hexo", "Jekyll", "Gatsby"], ssqch: "leaveNoTrace", say: "ssqch has no clean command: `leaveNoTrace: true` in the config deletes what an earlier build wrote and this one didn't.", more: "ssqch docs leaveNoTrace" },
|
|
3410
|
+
{ word: "generate", kind: "command", alias: true, from: ["Hexo"], ssqch: "build", say: "To build the site: `ssqch build`.", more: "ssqch docs build" },
|
|
3411
|
+
{ word: "version", kind: "command", alias: false, from: ["Hugo"], ssqch: "--version", say: "The version is `ssqch --version`.", more: "ssqch --help" },
|
|
3412
|
+
{ word: "deploy", kind: "command", alias: false, from: ["Hexo"], ssqch: "build", say: "ssqch doesn't deploy: `ssqch build` writes the site, and your host serves the output folder.", more: "ssqch docs Deploying" },
|
|
3413
|
+
// Flags.
|
|
3414
|
+
{ word: "--watch", kind: "flag", alias: true, from: ["Eleventy", "Jekyll"], ssqch: "serve", say: SERVE, more: "ssqch docs serve" },
|
|
3415
|
+
{ word: "--serve", kind: "flag", alias: true, from: ["Eleventy"], ssqch: "serve", say: SERVE, more: "ssqch docs serve" },
|
|
3416
|
+
{ word: "--drafts", kind: "flag", alias: false, from: ["Jekyll"], ssqch: "--env", say: "Drafts (`draft: true`) are built with `--env development`, as `ssqch serve` does, and left out of production builds.", more: "ssqch docs draft" },
|
|
3417
|
+
{ word: "-D", kind: "flag", alias: false, from: ["Hugo"], ssqch: "--env", say: "Drafts (`draft: true`) are built with `--env development`, as `ssqch serve` does, and left out of production builds.", more: "ssqch docs draft" },
|
|
3418
|
+
{ word: "--buildDrafts", kind: "flag", alias: false, from: ["Hugo"], ssqch: "--env", say: "Drafts (`draft: true`) are built with `--env development`, as `ssqch serve` does, and left out of production builds.", more: "ssqch docs draft" },
|
|
3419
|
+
{ word: "-d", kind: "flag", alias: true, from: ["Hugo", "Jekyll"], ssqch: "--output", say: "The output folder is `-o, --output DIR` (or `dirs.output` in the config).", more: "ssqch build --help" },
|
|
3420
|
+
{ word: "--destination", kind: "flag", alias: true, from: ["Hugo", "Jekyll"], ssqch: "--output", say: "The output folder is `-o, --output DIR` (or `dirs.output` in the config).", more: "ssqch build --help" },
|
|
3421
|
+
{ word: "--input", kind: "flag", alias: false, from: ["Eleventy"], ssqch: "--root", say: "The input folder is `dirs.input` in the config; `--root DIR` is the project folder (where the config is).", more: "ssqch build --help" },
|
|
3422
|
+
{ word: "--pathprefix", kind: "flag", alias: true, from: ["Eleventy"], ssqch: "--base", say: "The path a site is served under is `--base /repo/` (or `base` in the config).", more: "ssqch docs base" },
|
|
3423
|
+
{ word: "--baseURL", kind: "flag", alias: false, from: ["Hugo"], ssqch: "--base", say: "The path a site is served under is `--base /repo/` (or `base` in the config); the domain isn't needed.", more: "ssqch docs base" },
|
|
3424
|
+
{ word: "--minify", kind: "flag", alias: false, from: ["Hugo"], ssqch: "minifyPlugin", say: 'Minifying is `minifyPlugin()` from "ssqch/minify", in the config\'s `plugins`.', more: "ssqch docs minifyPlugin" },
|
|
3425
|
+
{ word: "--incremental", kind: "flag", alias: false, from: ["Eleventy", "Jekyll"], ssqch: "serve", say: "There's nothing to turn on: a whole build is quick, and `ssqch serve` reloads only the pages that changed.", more: "ssqch docs serve" },
|
|
3426
|
+
{ word: "--kind", kind: "flag", alias: false, from: ["Hugo"], ssqch: "--blueprint", say: "What Hugo calls an archetype is a blueprint in ssqch: `ssqch new posts/pine.md --blueprint notes` starts from `_blueprints/notes.md`.", more: "ssqch new --help" },
|
|
3427
|
+
{ word: "--template", kind: "flag", alias: false, from: [], ssqch: "--starter", say: "`ssqch init --starter site|docs` picks the starter, and `--engine` its template language.", more: "ssqch init --help" },
|
|
3428
|
+
// Config options (and the methods of a config written as calls).
|
|
3429
|
+
{ word: "pathPrefix", kind: "config", alias: true, from: ["Eleventy"], ssqch: "base", say: 'In ssqch it\'s `base`: base: "/repo/".', more: "ssqch docs base" },
|
|
3430
|
+
{ word: "dir", kind: "config", alias: true, from: ["Eleventy"], ssqch: "dirs", say: 'In ssqch it\'s `dirs`: dirs: { input: "src", output: "dist" }.', more: "ssqch docs dirs" },
|
|
3431
|
+
{ word: "publishDir", kind: "config", alias: true, from: ["Hugo"], ssqch: "dirs.output", say: 'The output folder is `dirs.output`: dirs: { output: "public" }.', more: "ssqch docs dirs" },
|
|
3432
|
+
{ word: "outDir", kind: "config", alias: true, from: ["Astro", "VitePress"], ssqch: "dirs.output", say: 'The output folder is `dirs.output`: dirs: { output: "dist" }.', more: "ssqch docs dirs" },
|
|
3433
|
+
{ word: "integrations", kind: "config", alias: false, from: ["Astro"], ssqch: "plugins", say: "In ssqch it's `plugins`: plugins: [imagePlugin()].", more: "ssqch docs plugins" },
|
|
3434
|
+
{ word: "markdownTemplateEngine", kind: "config", alias: true, from: ["Eleventy"], ssqch: "markdownEngine", say: 'In ssqch it\'s `markdownEngine`: markdownEngine: "njk" (or false).', more: "ssqch docs markdownEngine" },
|
|
3435
|
+
{ word: "htmlTemplateEngine", kind: "config", alias: true, from: ["Eleventy"], ssqch: "htmlEngine", say: 'In ssqch it\'s `htmlEngine`: htmlEngine: "njk" (or false).', more: "ssqch docs htmlEngine" },
|
|
3436
|
+
{ word: "baseURL", kind: "config", alias: false, from: ["Hugo"], ssqch: "base", say: "ssqch's `base` is the path only (base: \"/repo/\"); the site's full URL goes in your data, for sitemapPlugin({ url }).", more: "ssqch docs base" },
|
|
3437
|
+
{ word: "title", kind: "config", alias: false, from: ["Hugo", "Zola", "Jekyll"], ssqch: "data", say: "The site's title is data: put it in `_data/site.json` and use `site.title` in templates.", more: "ssqch docs data" },
|
|
3438
|
+
{ word: "addPassthroughCopy", kind: "config", alias: false, from: ["Eleventy"], ssqch: "passthrough", say: 'In ssqch it\'s `passthrough`: passthrough: ["src/fonts", { "src/static": "static" }].', more: "ssqch docs passthrough" },
|
|
3439
|
+
{ word: "addFilter", kind: "config", alias: false, from: ["Eleventy"], ssqch: "filters", say: "In ssqch it's `filters`: filters: { shout: (s) => s.toUpperCase() }.", more: "ssqch docs filters" },
|
|
3440
|
+
{ word: "addShortcode", kind: "config", alias: false, from: ["Eleventy"], ssqch: "filters", say: "A shortcode is a function in `filters`: filters: { year: () => String(new Date().getFullYear()) }.", more: "ssqch docs filters" },
|
|
3441
|
+
{ word: "addCollection", kind: "config", alias: false, from: ["Eleventy"], ssqch: "collections", say: 'In ssqch it\'s `collections`: collections: { posts: (pages) => pages.byTag("post") }.', more: "ssqch docs collections" },
|
|
3442
|
+
{ word: "addTransform", kind: "config", alias: false, from: ["Eleventy"], ssqch: "transforms", say: "In ssqch it's `transforms`: transforms: { tidy: (content, page) => content }.", more: "ssqch docs transforms" },
|
|
3443
|
+
{ word: "addGlobalData", kind: "config", alias: false, from: ["Eleventy"], ssqch: "data", say: "In ssqch it's `data`: data: { buildTime: () => new Date() }.", more: "ssqch docs data" },
|
|
3444
|
+
{ word: "addWatchTarget", kind: "config", alias: false, from: ["Eleventy"], ssqch: "watch", say: 'In ssqch it\'s `watch`: watch: ["src/assets/"].', more: "ssqch docs watch" },
|
|
3445
|
+
{ word: "addPlugin", kind: "config", alias: false, from: ["Eleventy"], ssqch: "plugins", say: "In ssqch it's `plugins`: plugins: [rssPlugin()].", more: "ssqch docs plugins" },
|
|
3446
|
+
{ word: "setTemplateFormats", kind: "config", alias: false, from: ["Eleventy"], ssqch: "templateFormats", say: 'In ssqch it\'s `templateFormats`: templateFormats: ["njk", "md"].', more: "ssqch docs templateFormats" },
|
|
3447
|
+
// Front-matter keys that can't be a site's own.
|
|
3448
|
+
{ word: "eleventyComputed", kind: "frontMatter", alias: true, from: ["Eleventy"], ssqch: "computed", say: "ssqch's name is `computed`.", more: "ssqch docs computed" },
|
|
3449
|
+
{ word: "eleventyExcludeFromCollections", kind: "frontMatter", alias: true, from: ["Eleventy"], ssqch: "excludeFromCollections", say: "ssqch's name is `excludeFromCollections`.", more: "ssqch docs excludeFromCollections" },
|
|
3450
|
+
{ word: "eleventyNavigation", kind: "frontMatter", alias: false, from: ["Eleventy"], ssqch: "nav", say: "ssqch's own navigation (`pagesTree` and `navTree`) reads `nav`, so these pages aren't in it. Templates and filters that read `eleventyNavigation` (eleventy-navigation's `findNavigationEntries`) still get it as it is.", more: "ssqch docs nav" },
|
|
3451
|
+
{ word: "templateEngineOverride", kind: "frontMatter", alias: true, from: ["Eleventy"], ssqch: "render", say: "ssqch's name is `render`, a list: render: [njk, md].", more: "ssqch docs render" },
|
|
3452
|
+
{ word: "redirect_from", kind: "frontMatter", alias: true, from: ["Jekyll"], ssqch: "aliases", say: 'ssqch\'s name is `aliases`; `redirectsPlugin()` from "ssqch/redirects" writes the redirects.', more: "ssqch docs aliases" },
|
|
3453
|
+
{ word: "published", kind: "frontMatter", alias: false, from: ["Jekyll"], ssqch: "draft", say: "`published: false` doesn't hold a page back in ssqch, so it's published: use `draft: true`.", more: "ssqch docs draft" },
|
|
3454
|
+
// Filters.
|
|
3455
|
+
{ word: "url", kind: "filter", alias: true, from: ["Eleventy"], ssqch: "base", say: 'It returns the URL as it is: the build adds `base` to every URL from the site\'s root, so `href="/about/"` needs no filter (use `withBase()` outside HTML attributes).', more: "ssqch docs base" },
|
|
3456
|
+
{ word: "relative_url", kind: "filter", alias: true, from: ["Jekyll"], ssqch: "base", say: 'It returns the URL as it is: the build adds `base` to every URL from the site\'s root, so `href="/about/"` needs no filter (use `withBase()` outside HTML attributes).', more: "ssqch docs base" },
|
|
3457
|
+
{ word: "slug", kind: "filter", alias: false, from: ["Eleventy"], ssqch: "slugify", say: "ssqch's is `slugify`, which differs: Eleventy's `slug` (the `slugify` npm package) keeps `.` and some punctuation, so `Node.js` is `node.js` there and `node-js` in ssqch. To keep old URLs, define `slug` in `filters` with that package: slug: (s) => slugify(String(s), { lower: true }).", more: "ssqch docs slugify" },
|
|
3458
|
+
{ word: "absolute_url", kind: "filter", alias: false, from: ["Jekyll"], ssqch: "absoluteUrl", say: '`absoluteUrl(url, base)` comes with `rssPlugin()` from "ssqch/rss".', more: "ssqch docs absoluteUrl" },
|
|
3459
|
+
{ word: "markdownify", kind: "filter", alias: true, from: ["Jekyll", "Hugo"], ssqch: "markdown", say: 'ssqch\'s function is `markdown(text)` (or `markdown(text, "inline")`).', more: "ssqch docs markdown" },
|
|
3460
|
+
{ word: "jsonify", kind: "filter", alias: false, from: ["Jekyll"], ssqch: "dump", say: "Jinja's is `tojson` (`dump` in Nunjucks); Liquid's is `json`.", more: 'ssqch docs "Jinja and Nunjucks"' },
|
|
3461
|
+
// Template globals: the word as it's written in template code.
|
|
3462
|
+
{ word: "eleventy.", kind: "global", alias: false, from: ["Eleventy"], ssqch: "ssqch", say: "ssqch's is `ssqch`: `ssqch.generator`, `ssqch.version`, `ssqch.env` and `ssqch.serving`, so this prints nothing.", more: "ssqch docs ssqch.generator" },
|
|
3463
|
+
{ word: "site.posts", kind: "global", alias: false, from: ["Jekyll"], ssqch: "collections", say: "ssqch's lists of pages are `collections`: `collections.posts` is the pages tagged `posts`, so this is empty.", more: "ssqch docs collections" },
|
|
3464
|
+
{ word: "site.pages", kind: "global", alias: false, from: ["Jekyll"], ssqch: "collections", say: "ssqch's lists of pages are `collections`: `collections.all` is every page, so this is empty.", more: "ssqch docs collections" }
|
|
3465
|
+
];
|
|
3466
|
+
function find(word, kind) {
|
|
3467
|
+
return TABLE.find((e) => e.word === word && e.kind === kind);
|
|
3468
|
+
}
|
|
3469
|
+
function note(row) {
|
|
3470
|
+
if (row.kind === "filter" && row.ssqch === "base") return `${row.word} works, and isn't needed: the build adds base to URLs itself (${row.more})`;
|
|
3471
|
+
return `${row.word} works; ssqch calls it ${row.ssqch} (${row.more})`;
|
|
3472
|
+
}
|
|
3473
|
+
function hint(row) {
|
|
3474
|
+
return `${row.say}
|
|
3475
|
+
More: ${row.more}`;
|
|
3476
|
+
}
|
|
3477
|
+
function toJson(row) {
|
|
3478
|
+
return { word: row.word, kind: row.kind, use: row.ssqch, alias: row.alias, from: [...row.from], more: row.more };
|
|
3479
|
+
}
|
|
3480
|
+
function inMessage(message) {
|
|
3481
|
+
return TABLE.find((e) => message.includes(e.say));
|
|
3482
|
+
}
|
|
3483
|
+
var OTHER_CONFIGS = [
|
|
3484
|
+
[".eleventy.js", "Eleventy", "eleventy", "from-eleventy.md"],
|
|
3485
|
+
["eleventy.config.js", "Eleventy", "eleventy", "from-eleventy.md"],
|
|
3486
|
+
["eleventy.config.mjs", "Eleventy", "eleventy", "from-eleventy.md"],
|
|
3487
|
+
["eleventy.config.cjs", "Eleventy", "eleventy", "from-eleventy.md"],
|
|
3488
|
+
["hugo.toml", "Hugo", null, null],
|
|
3489
|
+
["hugo.yaml", "Hugo", null, null],
|
|
3490
|
+
["hugo.json", "Hugo", null, null],
|
|
3491
|
+
["mkdocs.yml", "MkDocs", null, "from-mkdocs.md"],
|
|
3492
|
+
["docusaurus.config.js", "Docusaurus", null, "from-docusaurus.md"],
|
|
3493
|
+
["docusaurus.config.ts", "Docusaurus", null, "from-docusaurus.md"],
|
|
3494
|
+
["astro.config.mjs", "Astro", null, "from-component-frameworks.md"],
|
|
3495
|
+
["astro.config.ts", "Astro", null, "from-component-frameworks.md"],
|
|
3496
|
+
["gatsby-config.js", "Gatsby", null, "from-component-frameworks.md"],
|
|
3497
|
+
[".vitepress/config.mts", "VitePress", null, "from-component-frameworks.md"],
|
|
3498
|
+
[".vitepress/config.js", "VitePress", null, "from-component-frameworks.md"]
|
|
3499
|
+
];
|
|
3500
|
+
function otherGenerator(root) {
|
|
3501
|
+
const isFile = (file2) => fs.statSync(path.join(root, file2), { throwIfNoEntry: false })?.isFile() ?? false;
|
|
3502
|
+
const read = (file2) => {
|
|
3503
|
+
try {
|
|
3504
|
+
return fs.readFileSync(path.join(root, file2), "utf8");
|
|
3505
|
+
} catch {
|
|
3506
|
+
return void 0;
|
|
3507
|
+
}
|
|
3508
|
+
};
|
|
3509
|
+
let found = OTHER_CONFIGS.find(([file2]) => isFile(file2));
|
|
3510
|
+
if (!found) {
|
|
3511
|
+
const toml = read("config.toml");
|
|
3512
|
+
if (toml?.includes("base_url")) found = ["config.toml", "Zola", "zola", "from-zola.md"];
|
|
3513
|
+
else if (toml?.includes("baseURL")) found = ["config.toml", "Hugo", null, null];
|
|
3514
|
+
else if (read("_config.yml") !== void 0) {
|
|
3515
|
+
const hexo = read("package.json")?.includes('"hexo"') ?? false;
|
|
3516
|
+
found = hexo ? ["_config.yml", "Hexo", null, "from-hexo.md"] : ["_config.yml", "Jekyll", null, null];
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
if (!found) return void 0;
|
|
3520
|
+
const [file, generator, importer] = found;
|
|
3521
|
+
const docs = `\`ssqch docs --from ${generator.toLowerCase()}\` says what maps to what`;
|
|
3522
|
+
const next = importer ? `\`ssqch import ${importer}\` drafts one from it, and ${docs}` : `\`ssqch init\` starts one, and ${docs}`;
|
|
3523
|
+
const article = /^[AEIOU]/.test(generator) ? "an" : "a";
|
|
3524
|
+
return `this folder has ${article} ${generator} config (${file}) and no ssqch.config.js, so ssqch builds it with its own defaults. ${next}.`;
|
|
3525
|
+
}
|
|
3526
|
+
|
|
3527
|
+
// src/diagnostics.ts
|
|
3528
|
+
var shownFile = (file) => file.replaceAll("\\", "/").replace(/^(\.\/)+/, "");
|
|
3529
|
+
function warning(code, message, extra = {}) {
|
|
3530
|
+
const found = { severity: "warning", code, message, ...extra };
|
|
3531
|
+
if (found.file !== void 0) found.file = shownFile(found.file);
|
|
3532
|
+
return found;
|
|
3533
|
+
}
|
|
3534
|
+
function error(code, message, extra = {}) {
|
|
3535
|
+
return { ...warning(code, message, extra), severity: "error" };
|
|
3536
|
+
}
|
|
3537
|
+
function toJson2(d) {
|
|
3538
|
+
const out = { code: d.code, message: d.message };
|
|
3539
|
+
const equivalent = inMessage(d.message);
|
|
3540
|
+
if (equivalent) out.hint = toJson(equivalent);
|
|
3541
|
+
if (d.file !== void 0) out.file = d.file;
|
|
3542
|
+
if (d.line !== void 0) out.line = d.line;
|
|
3543
|
+
if (d.field !== void 0) out.field = d.field;
|
|
3544
|
+
if (d.url !== void 0) out.url = d.url;
|
|
3545
|
+
return out;
|
|
3546
|
+
}
|
|
3547
|
+
var Diagnostics = class extends Error {
|
|
3548
|
+
items;
|
|
3549
|
+
constructor(message, items) {
|
|
3550
|
+
super(message);
|
|
3551
|
+
this.name = "Diagnostics";
|
|
3552
|
+
this.items = items;
|
|
3553
|
+
}
|
|
3554
|
+
};
|
|
3555
|
+
var BuildError = class extends Error {
|
|
3556
|
+
/** The problems apart, when the error was made from several (or from one with its file known). */
|
|
3557
|
+
items;
|
|
3558
|
+
constructor(message, items) {
|
|
3559
|
+
super(message);
|
|
3560
|
+
this.name = "BuildError";
|
|
3561
|
+
this.items = items;
|
|
3562
|
+
}
|
|
3563
|
+
};
|
|
3564
|
+
function messageOf(e) {
|
|
3565
|
+
if (e instanceof Error) return e.message;
|
|
3566
|
+
return String(e);
|
|
3567
|
+
}
|
|
3568
|
+
function context(e, words) {
|
|
3569
|
+
const items = e instanceof Diagnostics || e instanceof BuildError ? e.items : void 0;
|
|
3570
|
+
return new BuildError(`${words}: ${messageOf(e)}`, items);
|
|
3571
|
+
}
|
|
3572
|
+
function bail(message) {
|
|
3573
|
+
throw new BuildError(message);
|
|
3574
|
+
}
|
|
3575
|
+
var capturing = false;
|
|
3576
|
+
var quiet = false;
|
|
3577
|
+
var warnings = [];
|
|
3578
|
+
var aliases = [];
|
|
3579
|
+
function capture(on = true) {
|
|
3580
|
+
capturing = on;
|
|
3581
|
+
}
|
|
3582
|
+
function isCapturing() {
|
|
3583
|
+
return capturing;
|
|
3584
|
+
}
|
|
3585
|
+
function takeWarnings() {
|
|
3586
|
+
const taken = warnings;
|
|
3587
|
+
warnings = [];
|
|
3588
|
+
return taken;
|
|
3589
|
+
}
|
|
3590
|
+
function warn(diagnostic) {
|
|
3591
|
+
if (capturing) warnings.push(diagnostic);
|
|
3592
|
+
else process.stderr.write(`warn: ${diagnostic.message}
|
|
3593
|
+
`);
|
|
3594
|
+
}
|
|
3595
|
+
function setQuiet(on) {
|
|
3596
|
+
quiet = on;
|
|
3597
|
+
}
|
|
3598
|
+
function aliasUsed(row) {
|
|
3599
|
+
if (aliases.includes(row)) return;
|
|
3600
|
+
aliases.push(row);
|
|
3601
|
+
if (!capturing && !quiet) process.stderr.write(`note: ${note(row)}
|
|
3602
|
+
`);
|
|
3603
|
+
}
|
|
3604
|
+
function aliasesKnown(rows) {
|
|
3605
|
+
for (const row of rows) if (!aliases.includes(row)) aliases.push(row);
|
|
3606
|
+
}
|
|
3607
|
+
function aliasesUsed() {
|
|
3608
|
+
return [...aliases];
|
|
3609
|
+
}
|
|
3610
|
+
function progress(line) {
|
|
3611
|
+
(capturing ? process.stderr : process.stdout).write(line + "\n");
|
|
3612
|
+
}
|
|
3613
|
+
function red(label) {
|
|
3614
|
+
const set2 = (name) => (process.env[name] ?? "") !== "";
|
|
3615
|
+
const colour = !set2("NO_COLOR") && (set2("FORCE_COLOR") || process.stderr.isTTY === true && process.env.TERM !== "dumb");
|
|
3616
|
+
return colour ? `\x1B[31m${label}\x1B[0m` : label;
|
|
3617
|
+
}
|
|
3618
|
+
var Locator = class {
|
|
3619
|
+
root;
|
|
3620
|
+
dirs;
|
|
3621
|
+
constructor(root, dirs = []) {
|
|
3622
|
+
this.root = root;
|
|
3623
|
+
this.dirs = [root, ...dirs];
|
|
3624
|
+
}
|
|
3625
|
+
/** The file `name` means, and its path from the root. */
|
|
3626
|
+
find(name) {
|
|
3627
|
+
name = name.replace(/^["'`]+|["'`]+$/g, "");
|
|
3628
|
+
if (name === "") return void 0;
|
|
3629
|
+
for (const dir of this.dirs) {
|
|
3630
|
+
let file = path2.resolve(dir, name);
|
|
3631
|
+
if (!fs2.statSync(file, { throwIfNoEntry: false })?.isFile()) continue;
|
|
3632
|
+
file = realPath(file);
|
|
3633
|
+
const rel = path2.relative(realPath(this.root), file);
|
|
3634
|
+
const outside = rel === ".." || rel.startsWith(`..${path2.sep}`) || path2.isAbsolute(rel);
|
|
3635
|
+
const shown = (outside ? file : rel).split(path2.sep).join("/");
|
|
3636
|
+
return { path: file, shown };
|
|
3637
|
+
}
|
|
3638
|
+
return void 0;
|
|
3639
|
+
}
|
|
3640
|
+
};
|
|
3641
|
+
function linesBeforeBody(file) {
|
|
3642
|
+
try {
|
|
3643
|
+
const src = fs2.readFileSync(file, "utf8");
|
|
3644
|
+
const { body } = parseFrontMatter(src);
|
|
3645
|
+
return src.slice(0, src.length - body.length).split("\n").length - 1;
|
|
3646
|
+
} catch {
|
|
3647
|
+
return void 0;
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
var PATTERNS = [
|
|
3651
|
+
// A JavaScript stack frame: `at shout (ssqch.config.js:3:67)`.
|
|
3652
|
+
[/\(([^()\s:]+):(\d+):\d+\)/g, "fileLine"],
|
|
3653
|
+
// A data file: `invalid JSON in /site/src/_data/site.json: trailing comma at line 1 column 17`.
|
|
3654
|
+
[/invalid (?:JSON|YAML|TOML) in (.+?): [^\n]*?\bline (\d+)/g, "fileLine"],
|
|
3655
|
+
[/invalid (?:JSON|YAML|TOML) in (.+?): /g, "file"],
|
|
3656
|
+
// Front matter: its lines start after the opening fence.
|
|
3657
|
+
[/\bin (\S+): invalid (?:JSON|YAML|TOML) front matter: [^\n]*?\bline (\d+)/g, "frontMatterLine"],
|
|
3658
|
+
// A permalink or `computed` string: its line isn't a line of the file.
|
|
3659
|
+
[/parse error in (\S+) \(/g, "file"],
|
|
3660
|
+
// A template, innermost first: `parse error in bad.edge: line 3`, then `page.njk:2:`.
|
|
3661
|
+
[/parse error in (\S+): line (\d+)/g, "bodyLine"],
|
|
3662
|
+
[/(?:^|[\s:(])([^\s:()]+\.[A-Za-z0-9]+):(\d+): /g, "bodyLine"],
|
|
3663
|
+
[/rendering layout (\S+) for /g, "file"],
|
|
3664
|
+
[/rendering (\S+) with /g, "file"],
|
|
3665
|
+
[/(?:^|\n|- )in (\S+?): /g, "file"],
|
|
3666
|
+
// `ssqch.config.js: "ouput" isn't a config option`.
|
|
3667
|
+
[/^([^\s:]+\.[A-Za-z0-9]+): /g, "file"]
|
|
3668
|
+
];
|
|
3669
|
+
function locate(message, at) {
|
|
3670
|
+
for (const [pattern, kind] of PATTERNS) {
|
|
3671
|
+
const all = [...message.matchAll(pattern)];
|
|
3672
|
+
if (!all.length) continue;
|
|
3673
|
+
const found = kind === "bodyLine" ? all[all.length - 1] : all[0];
|
|
3674
|
+
const where = at.find(found[1]);
|
|
3675
|
+
if (!where) continue;
|
|
3676
|
+
const number = found[2] === void 0 ? void 0 : Number.parseInt(found[2], 10);
|
|
3677
|
+
let line;
|
|
3678
|
+
if (number !== void 0 && Number.isFinite(number)) {
|
|
3679
|
+
if (kind === "fileLine") line = number;
|
|
3680
|
+
else if (kind === "bodyLine") {
|
|
3681
|
+
const before = linesBeforeBody(where.path);
|
|
3682
|
+
line = before === void 0 ? void 0 : before + number;
|
|
3683
|
+
} else if (kind === "frontMatterLine") line = number + 1;
|
|
3684
|
+
}
|
|
3685
|
+
return { file: where.shown, line };
|
|
3686
|
+
}
|
|
3687
|
+
return {};
|
|
3688
|
+
}
|
|
3689
|
+
function codeFor(message, fallback) {
|
|
3690
|
+
if (message.includes("front matter")) return "front-matter";
|
|
3691
|
+
if (message.startsWith("output conflicts")) return "conflict";
|
|
3692
|
+
if (message.includes("rendering ") || message.includes("parse error in ") || message.includes("layout `") || message.includes(" loop: ")) return "template";
|
|
3693
|
+
if (message.startsWith("invalid JSON in ") || message.startsWith("invalid YAML in ") || message.startsWith("invalid TOML in ") || message.includes("_data/") || message.includes("global data `")) return "data";
|
|
3694
|
+
if (message.includes("hook failed") || message.startsWith("beforeBuild") || message.startsWith("afterBuild")) return "hook";
|
|
3695
|
+
return fallback;
|
|
3696
|
+
}
|
|
3697
|
+
function fromError(e, fallback, at) {
|
|
3698
|
+
const held = e instanceof Diagnostics || e instanceof BuildError ? e.items : void 0;
|
|
3699
|
+
const items = held ? held.map((item) => ({ ...item })) : [error("", messageOf(e))];
|
|
3700
|
+
for (const item of items) {
|
|
3701
|
+
if (item.code === "") item.code = codeFor(item.message, fallback);
|
|
3702
|
+
if (item.file === void 0) {
|
|
3703
|
+
const found = locate(item.message, at);
|
|
3704
|
+
if (found.file !== void 0) item.file = found.file;
|
|
3705
|
+
if (found.line !== void 0) item.line = found.line;
|
|
3706
|
+
}
|
|
3707
|
+
item.message = fileLines(item.message, at);
|
|
3708
|
+
}
|
|
3709
|
+
return items;
|
|
3710
|
+
}
|
|
3711
|
+
function fileLines(message, at) {
|
|
3712
|
+
const shift = (name, n) => {
|
|
3713
|
+
const where = at.find(name);
|
|
3714
|
+
if (!where) return void 0;
|
|
3715
|
+
const before = linesBeforeBody(where.path);
|
|
3716
|
+
if (!before) return void 0;
|
|
3717
|
+
return before + Number.parseInt(n, 10);
|
|
3718
|
+
};
|
|
3719
|
+
message = message.replace(/(^|[\s:(])([^\s:()]+\.[A-Za-z0-9]+):(\d+): /g, (whole, lead, name, n) => {
|
|
3720
|
+
const line = shift(name, n);
|
|
3721
|
+
return line === void 0 ? whole : `${lead}${name}:${line}: `;
|
|
3722
|
+
});
|
|
3723
|
+
return message.replace(/(parse error in )(\S+): line (\d+)/g, (whole, lead, name, n) => {
|
|
3724
|
+
const line = shift(name, n);
|
|
3725
|
+
return line === void 0 ? whole : `${lead}${name}: line ${line}`;
|
|
3726
|
+
});
|
|
3727
|
+
}
|
|
3728
|
+
function frames(e, fallback, at) {
|
|
3729
|
+
const found = [];
|
|
3730
|
+
for (const problem of fromError(e, fallback, at)) {
|
|
3731
|
+
const shown = frame(problem, at);
|
|
3732
|
+
if (shown !== void 0) found.push(shown);
|
|
3733
|
+
if (found.length === 3) break;
|
|
3734
|
+
}
|
|
3735
|
+
return found.length ? found.join("\n\n") : void 0;
|
|
3736
|
+
}
|
|
3737
|
+
function frame(problem, at) {
|
|
3738
|
+
const WIDEST = 160;
|
|
3739
|
+
if (problem.file === void 0) return void 0;
|
|
3740
|
+
let source;
|
|
3741
|
+
try {
|
|
3742
|
+
source = fs2.readFileSync(path2.resolve(at.root, problem.file), "utf8");
|
|
3743
|
+
} catch {
|
|
3744
|
+
return void 0;
|
|
3745
|
+
}
|
|
3746
|
+
const lines = splitLines(source);
|
|
3747
|
+
let number = problem.line;
|
|
3748
|
+
if (number === void 0) {
|
|
3749
|
+
if (problem.field === void 0) return void 0;
|
|
3750
|
+
number = fieldLine(lines, problem.field);
|
|
3751
|
+
if (number === void 0) return void 0;
|
|
3752
|
+
}
|
|
3753
|
+
if (number < 1 || number > lines.length) return void 0;
|
|
3754
|
+
const untab = (line) => line.replaceAll(" ", " ");
|
|
3755
|
+
const text = untab(lines[number - 1]);
|
|
3756
|
+
const quoted = [];
|
|
3757
|
+
for (const mark of ["`", "'"]) {
|
|
3758
|
+
let rest = problem.message;
|
|
3759
|
+
for (; ; ) {
|
|
3760
|
+
const start = rest.indexOf(mark);
|
|
3761
|
+
if (start === -1) break;
|
|
3762
|
+
const end = rest.indexOf(mark, start + 1);
|
|
3763
|
+
if (end === -1) break;
|
|
3764
|
+
quoted.push(rest.slice(start + 1, end));
|
|
3765
|
+
rest = rest.slice(end + 1);
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
quoted.sort((a, b) => Buffer.byteLength(b) - Buffer.byteLength(a));
|
|
3769
|
+
const field = problem.field?.split(".")[0];
|
|
3770
|
+
let under;
|
|
3771
|
+
for (const part of [...field === void 0 ? [] : [field], ...quoted]) {
|
|
3772
|
+
if (Buffer.byteLength(part.trim()) <= 1) continue;
|
|
3773
|
+
const at2 = text.indexOf(part);
|
|
3774
|
+
if (at2 === -1) continue;
|
|
3775
|
+
under = [[...text.slice(0, at2)].length, [...part].length];
|
|
3776
|
+
break;
|
|
3777
|
+
}
|
|
3778
|
+
const from = Math.max(number - 2, 1);
|
|
3779
|
+
const to = Math.min(number + 1, lines.length);
|
|
3780
|
+
const width = Math.max(String(to).length, 2);
|
|
3781
|
+
let out = ` --> ${problem.file}:${number}`;
|
|
3782
|
+
for (let n = from; n <= to; n++) {
|
|
3783
|
+
const line = n === number ? text : untab(lines[n - 1]);
|
|
3784
|
+
const chars = [...line];
|
|
3785
|
+
out += `
|
|
3786
|
+
${String(n).padStart(width)} | ${chars.slice(0, WIDEST).join("")}${chars.length > WIDEST ? "..." : ""}`.trimEnd();
|
|
3787
|
+
if (n === number && under && under[0] + under[1] <= WIDEST) {
|
|
3788
|
+
out += `
|
|
3789
|
+
${"".padStart(width)} | ${" ".repeat(under[0])}${"^".repeat(under[1])}`;
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
return out;
|
|
3793
|
+
}
|
|
3794
|
+
function splitLines(text) {
|
|
3795
|
+
const lines = text.split("\n").map((line) => line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
3796
|
+
if (lines.length && lines[lines.length - 1] === "" && text.endsWith("\n")) lines.pop();
|
|
3797
|
+
return lines;
|
|
3798
|
+
}
|
|
3799
|
+
function fieldLine(lines, field) {
|
|
3800
|
+
const key = field.split(".")[0];
|
|
3801
|
+
if (!lines.length) return void 0;
|
|
3802
|
+
const fence = lines[0].trimEnd();
|
|
3803
|
+
const close = fence === "+++" ? "+++" : fence.startsWith("---") ? "---" : void 0;
|
|
3804
|
+
if (close === void 0) return void 0;
|
|
3805
|
+
for (let i2 = 1; i2 < lines.length; i2++) {
|
|
3806
|
+
if (lines[i2].trimEnd() === close) break;
|
|
3807
|
+
const line = lines[i2].replace(/^["']+/, "");
|
|
3808
|
+
if (!line.startsWith(key)) continue;
|
|
3809
|
+
if (/^[:=]/.test(line.slice(key.length).replace(/^["']+/, "").trimStart())) return i2 + 1;
|
|
3810
|
+
}
|
|
3811
|
+
return void 0;
|
|
3812
|
+
}
|
|
3813
|
+
function describe(e, fallback, at) {
|
|
3814
|
+
const message = fileLines(messageOf(e), at);
|
|
3815
|
+
const lines = frames(e, fallback, at);
|
|
3816
|
+
return lines === void 0 ? message : `${message}
|
|
3817
|
+
|
|
3818
|
+
${lines}`;
|
|
3819
|
+
}
|
|
3820
|
+
function printError(label, e, fallback, at) {
|
|
3821
|
+
process.stderr.write(`${red(label)} ${describe(e, fallback, at)}
|
|
3822
|
+
`);
|
|
3823
|
+
}
|
|
3824
|
+
|
|
3825
|
+
// src/data.ts
|
|
3826
|
+
var isPlainObject = (v) => {
|
|
3827
|
+
if (v === null || typeof v !== "object") return false;
|
|
3828
|
+
const proto = Object.getPrototypeOf(v);
|
|
3829
|
+
return proto === Object.prototype || proto === null;
|
|
3830
|
+
};
|
|
3831
|
+
function parseFrontMatter(src) {
|
|
3832
|
+
let format;
|
|
3833
|
+
let fence;
|
|
3834
|
+
let rest;
|
|
3835
|
+
if (src.startsWith("+++")) {
|
|
3836
|
+
[format, fence, rest] = ["toml", "+++", src.slice(3)];
|
|
3837
|
+
} else if (src.startsWith("---")) {
|
|
3838
|
+
rest = src.slice(3);
|
|
3839
|
+
const end = rest.search(/[\r\n]/);
|
|
3840
|
+
const lang = (end === -1 ? rest : rest.slice(0, end)).trim();
|
|
3841
|
+
if (lang === "" || lang === "yaml" || lang === "yml") format = "yaml";
|
|
3842
|
+
else if (lang === "json") format = "json";
|
|
3843
|
+
else if (lang === "toml") format = "toml";
|
|
3844
|
+
else return { data: {}, body: src };
|
|
3845
|
+
fence = "---";
|
|
3846
|
+
rest = end === -1 ? "" : rest.slice(end);
|
|
3847
|
+
} else {
|
|
3848
|
+
return { data: {}, body: src };
|
|
3849
|
+
}
|
|
3850
|
+
if (rest.startsWith("\r\n")) rest = rest.slice(2);
|
|
3851
|
+
else if (rest.startsWith("\n")) rest = rest.slice(1);
|
|
3852
|
+
else return { data: {}, body: src };
|
|
3853
|
+
let offset = 0;
|
|
3854
|
+
while (offset < rest.length) {
|
|
3855
|
+
const newline = rest.indexOf("\n", offset);
|
|
3856
|
+
const next = newline === -1 ? rest.length : newline + 1;
|
|
3857
|
+
if (rest.slice(offset, next).trimEnd() === fence) {
|
|
3858
|
+
const text = rest.slice(0, offset);
|
|
3859
|
+
const body = rest.slice(next);
|
|
3860
|
+
if (format === "json") {
|
|
3861
|
+
let value;
|
|
3862
|
+
try {
|
|
3863
|
+
value = JSON.parse(text.trim() === "" ? "{}" : text);
|
|
3864
|
+
} catch (e) {
|
|
3865
|
+
throw new BuildError(`invalid JSON front matter: ${jsonReason(e, text)}`);
|
|
3866
|
+
}
|
|
3867
|
+
return { data: frontMatterObject(value, "JSON"), body };
|
|
3868
|
+
}
|
|
3869
|
+
if (format === "toml") {
|
|
3870
|
+
let value;
|
|
3871
|
+
try {
|
|
3872
|
+
value = readToml(text);
|
|
3873
|
+
} catch (e) {
|
|
3874
|
+
throw new BuildError(`invalid TOML front matter: ${tomlReason(e)}`);
|
|
3875
|
+
}
|
|
3876
|
+
return { data: frontMatterObject(value, "TOML"), body };
|
|
3877
|
+
}
|
|
3878
|
+
try {
|
|
3879
|
+
return { data: parseYaml(text), body };
|
|
3880
|
+
} catch (e) {
|
|
3881
|
+
throw new BuildError(`invalid YAML front matter: ${yamlReason(e)}`);
|
|
3882
|
+
}
|
|
3883
|
+
}
|
|
3884
|
+
offset = next;
|
|
3885
|
+
}
|
|
3886
|
+
throw new BuildError(`front matter is missing its closing \`${fence}\``);
|
|
3887
|
+
}
|
|
3888
|
+
function frontMatterObject(v, format) {
|
|
3889
|
+
if (isPlainObject(v)) return v;
|
|
3890
|
+
throw new BuildError(`${format} front matter must be an object, not ${Array.isArray(v) || v === null ? "object" : typeof v}`);
|
|
3891
|
+
}
|
|
3892
|
+
var types2 = jsYaml.types;
|
|
3893
|
+
var timestamp2 = types2.timestamp;
|
|
3894
|
+
var YAML_SCHEMA = jsYaml.CORE_SCHEMA.extend({
|
|
3895
|
+
implicit: [
|
|
3896
|
+
new jsYaml.Type("tag:yaml.org,2002:timestamp", {
|
|
3897
|
+
kind: "scalar",
|
|
3898
|
+
resolve: timestamp2.resolve,
|
|
3899
|
+
construct(text) {
|
|
3900
|
+
const [year, month, day] = text.slice(0, 10).split("-").map(Number);
|
|
3901
|
+
const real = new Date(Date.UTC(2e3, month - 1, day));
|
|
3902
|
+
if (month < 1 || month > 12 || real.getUTCMonth() !== month - 1 || month === 2 && day === 29 && !leapYear(year)) return text;
|
|
3903
|
+
const date = timestamp2.construct(text);
|
|
3904
|
+
if (year < 100) date.setUTCFullYear(date.getUTCFullYear() - 1900);
|
|
3905
|
+
return date;
|
|
3906
|
+
},
|
|
3907
|
+
instanceOf: Date,
|
|
3908
|
+
represent: timestamp2.represent
|
|
3909
|
+
}),
|
|
3910
|
+
types2.merge
|
|
3911
|
+
],
|
|
3912
|
+
explicit: [types2.binary, types2.omap, types2.pairs, types2.set]
|
|
3913
|
+
});
|
|
3914
|
+
var leapYear = (year) => year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
3915
|
+
function loadYaml(text) {
|
|
3916
|
+
return jsYaml.load(text, { schema: YAML_SCHEMA });
|
|
3917
|
+
}
|
|
3918
|
+
function parseYaml(src) {
|
|
3919
|
+
if (src.trim() === "") return {};
|
|
3920
|
+
const value = loadYaml(src);
|
|
3921
|
+
if (value === null || value === void 0) return {};
|
|
3922
|
+
if (isPlainObject(value)) return value;
|
|
3923
|
+
throw new BuildError("expected a mapping at the top level");
|
|
3924
|
+
}
|
|
3925
|
+
function yamlReason(e) {
|
|
3926
|
+
if (e instanceof jsYaml.YAMLException) {
|
|
3927
|
+
const where = e.mark ? ` at line ${e.mark.line + 1} column ${e.mark.column + 1}` : "";
|
|
3928
|
+
return `${e.reason}${where}`;
|
|
3929
|
+
}
|
|
3930
|
+
return e instanceof Error ? e.message : String(e);
|
|
3931
|
+
}
|
|
3932
|
+
function jsonReason(e, text) {
|
|
3933
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
3934
|
+
const found = /^(.*?)(?: in JSON)? at position \d+ \(line (\d+) column (\d+)\)$/s.exec(message);
|
|
3935
|
+
if (found) return `${found[1]} at line ${found[2]} column ${found[3]}`;
|
|
3936
|
+
const at = jsonErrorOffset(text);
|
|
3937
|
+
if (at === void 0) return message;
|
|
3938
|
+
const before = text.slice(0, at);
|
|
3939
|
+
const what = /^(Unexpected [^,]+|Unterminated [^,]+|Bad [^,]+)/.exec(message)?.[1] ?? message;
|
|
3940
|
+
return `${what} at line ${before.split("\n").length} column ${at - before.lastIndexOf("\n")}`;
|
|
3941
|
+
}
|
|
3942
|
+
function jsonErrorOffset(text) {
|
|
3943
|
+
let i2 = 0;
|
|
3944
|
+
const space = () => {
|
|
3945
|
+
while (i2 < text.length && " \n\r".includes(text[i2])) i2++;
|
|
3946
|
+
};
|
|
3947
|
+
const value = () => {
|
|
3948
|
+
space();
|
|
3949
|
+
const c = text[i2];
|
|
3950
|
+
if (c === "{") {
|
|
3951
|
+
i2++;
|
|
3952
|
+
space();
|
|
3953
|
+
if (text[i2] === "}") {
|
|
3954
|
+
i2++;
|
|
3955
|
+
return true;
|
|
3956
|
+
}
|
|
3957
|
+
for (; ; ) {
|
|
3958
|
+
space();
|
|
3959
|
+
if (text[i2] !== '"' || !string()) return false;
|
|
3960
|
+
space();
|
|
3961
|
+
if (text[i2] !== ":") return false;
|
|
3962
|
+
i2++;
|
|
3963
|
+
if (!value()) return false;
|
|
3964
|
+
space();
|
|
3965
|
+
if (text[i2] === ",") {
|
|
3966
|
+
i2++;
|
|
3967
|
+
continue;
|
|
3968
|
+
}
|
|
3969
|
+
if (text[i2] === "}") {
|
|
3970
|
+
i2++;
|
|
3971
|
+
return true;
|
|
3972
|
+
}
|
|
3973
|
+
return false;
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
if (c === "[") {
|
|
3977
|
+
i2++;
|
|
3978
|
+
space();
|
|
3979
|
+
if (text[i2] === "]") {
|
|
3980
|
+
i2++;
|
|
3981
|
+
return true;
|
|
3982
|
+
}
|
|
3983
|
+
for (; ; ) {
|
|
3984
|
+
if (!value()) return false;
|
|
3985
|
+
space();
|
|
3986
|
+
if (text[i2] === ",") {
|
|
3987
|
+
i2++;
|
|
3988
|
+
continue;
|
|
3989
|
+
}
|
|
3990
|
+
if (text[i2] === "]") {
|
|
3991
|
+
i2++;
|
|
3992
|
+
return true;
|
|
3993
|
+
}
|
|
3994
|
+
return false;
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
if (c === '"') return string();
|
|
3998
|
+
const literal = /^(?:true|false|null|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)/.exec(text.slice(i2, i2 + 400));
|
|
3999
|
+
if (!literal) return false;
|
|
4000
|
+
i2 += literal[0].length;
|
|
4001
|
+
return true;
|
|
4002
|
+
};
|
|
4003
|
+
const string = () => {
|
|
4004
|
+
i2++;
|
|
4005
|
+
for (; i2 < text.length; i2++) {
|
|
4006
|
+
const c = text[i2];
|
|
4007
|
+
if (c === '"') {
|
|
4008
|
+
i2++;
|
|
4009
|
+
return true;
|
|
4010
|
+
}
|
|
4011
|
+
if (c === "\\") {
|
|
4012
|
+
if (text[i2 + 1] === "u") {
|
|
4013
|
+
if (!/^[0-9a-fA-F]{4}$/.test(text.slice(i2 + 2, i2 + 6))) return false;
|
|
4014
|
+
i2 += 5;
|
|
4015
|
+
} else if ('"\\/bfnrt'.includes(text[i2 + 1] ?? "!")) i2++;
|
|
4016
|
+
else return false;
|
|
4017
|
+
} else if (c < " ") return false;
|
|
4018
|
+
}
|
|
4019
|
+
return false;
|
|
4020
|
+
};
|
|
4021
|
+
if (!value()) return i2;
|
|
4022
|
+
space();
|
|
4023
|
+
return i2 < text.length ? i2 : void 0;
|
|
4024
|
+
}
|
|
4025
|
+
function tomlReason(e) {
|
|
4026
|
+
if (e instanceof TomlError) {
|
|
4027
|
+
const what = e.message.split("\n")[0].replace(/^Invalid TOML document: /, "");
|
|
4028
|
+
return `${what} at line ${e.line} column ${e.column}`;
|
|
4029
|
+
}
|
|
4030
|
+
return e instanceof Error ? e.message : String(e);
|
|
4031
|
+
}
|
|
4032
|
+
function readToml(text) {
|
|
4033
|
+
const values = bareValues(text);
|
|
4034
|
+
let problem;
|
|
4035
|
+
const dates = [];
|
|
4036
|
+
let marker = "";
|
|
4037
|
+
let replaced = "";
|
|
4038
|
+
let last = 0;
|
|
4039
|
+
for (const { start, end } of values) {
|
|
4040
|
+
const literal = text.slice(start, end);
|
|
4041
|
+
const why = DATE_TIME.test(literal) ? dateProblem(literal) : numberProblem(literal);
|
|
4042
|
+
if (why === null) continue;
|
|
4043
|
+
if (why !== void 0) {
|
|
4044
|
+
problem ??= new TomlError(why, { toml: text, ptr: start });
|
|
4045
|
+
continue;
|
|
4046
|
+
}
|
|
4047
|
+
if (!marker) marker = placeholder(text);
|
|
4048
|
+
const stand = marker + dates.length.toString(36);
|
|
4049
|
+
replaced += text.slice(last, start) + JSON.stringify(stand.padEnd(Math.max(stand.length, literal.length - 2), marker));
|
|
4050
|
+
last = end;
|
|
4051
|
+
dates.push(dateText(literal));
|
|
4052
|
+
}
|
|
4053
|
+
let parsed;
|
|
4054
|
+
try {
|
|
4055
|
+
parsed = parse(dates.length ? replaced + text.slice(last) : text, { integersAsBigInt: "asNeeded" });
|
|
4056
|
+
} catch (e) {
|
|
4057
|
+
if (problem && !(e instanceof TomlError && (e.line < problem.line || e.line === problem.line && e.column < problem.column))) throw problem;
|
|
4058
|
+
throw e;
|
|
4059
|
+
}
|
|
4060
|
+
if (problem) throw problem;
|
|
4061
|
+
return tomlValue(parsed, marker, dates);
|
|
4062
|
+
}
|
|
4063
|
+
function placeholder(text) {
|
|
4064
|
+
for (let code = 57344; code <= 63743; code++) if (!text.includes(String.fromCharCode(code))) return String.fromCharCode(code);
|
|
4065
|
+
throw new Error("a TOML document with every private-use character can't have dates");
|
|
4066
|
+
}
|
|
4067
|
+
var DATE_TIME = /^(?:\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:[Zz]|[+-]\d{2}:\d{2})?)?|\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)$/;
|
|
4068
|
+
function dateProblem(literal) {
|
|
4069
|
+
const date = /^(\d{4})-(\d{2})-(\d{2})/.exec(literal);
|
|
4070
|
+
if (date) {
|
|
4071
|
+
const [year, month, day] = [Number(date[1]), Number(date[2]), Number(date[3])];
|
|
4072
|
+
if (month < 1 || month > 12) return "invalid date, expected month between 01 and 12";
|
|
4073
|
+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
4074
|
+
const days = month === 2 ? leap ? 29 : 28 : [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
4075
|
+
if (day < 1 || day > days) return `invalid date, expected day between 01 and ${days}`;
|
|
4076
|
+
}
|
|
4077
|
+
const time = /(?:^|[Tt ])(\d{2}):(\d{2})(?::(\d{2}))?/.exec(literal);
|
|
4078
|
+
if (time) {
|
|
4079
|
+
if (Number(time[1]) > 23) return "invalid time, expected hour between 00 and 23";
|
|
4080
|
+
if (Number(time[2]) > 59) return "invalid time, expected minute between 00 and 59";
|
|
4081
|
+
if (Number(time[3] ?? 0) > 60) return "invalid time, expected second between 00 and 60";
|
|
4082
|
+
}
|
|
4083
|
+
const offset = /[+-](\d{2}):(\d{2})$/.exec(date && time ? literal.slice(10) : "");
|
|
4084
|
+
if (offset) {
|
|
4085
|
+
if (Number(offset[1]) > 23) return "invalid offset, expected hours between 00 and 23";
|
|
4086
|
+
if (Number(offset[2]) > 59) return "invalid offset, expected minutes between 00 and 59";
|
|
4087
|
+
}
|
|
4088
|
+
return void 0;
|
|
4089
|
+
}
|
|
4090
|
+
function numberProblem(literal) {
|
|
4091
|
+
const plain = literal.replaceAll("_", "");
|
|
4092
|
+
if (/^[+-]?\d+$|^0[xob][0-9a-fA-F]+$/.test(plain)) {
|
|
4093
|
+
let n;
|
|
4094
|
+
try {
|
|
4095
|
+
n = BigInt(plain);
|
|
4096
|
+
} catch {
|
|
4097
|
+
return null;
|
|
4098
|
+
}
|
|
4099
|
+
return n > 0x7fffffffffffffffn || n < -0x8000000000000000n ? "integer number overflowed" : null;
|
|
4100
|
+
}
|
|
4101
|
+
if (/^[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(plain) && !Number.isFinite(Number(plain))) return "floating-point number overflowed";
|
|
4102
|
+
return null;
|
|
4103
|
+
}
|
|
4104
|
+
function dateText(literal) {
|
|
4105
|
+
const m = /^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}:\d{2})(?::(\d{2})(?:\.(\d+))?)?)?([Zz]|[+-]\d{2}:\d{2})?$/.exec(literal);
|
|
4106
|
+
const [, date, hm, seconds, fraction, offset] = m;
|
|
4107
|
+
let out = date ?? "";
|
|
4108
|
+
if (hm !== void 0) {
|
|
4109
|
+
out += (date ? "T" : "") + hm;
|
|
4110
|
+
if (seconds !== void 0) out += `:${seconds}`;
|
|
4111
|
+
if (fraction !== void 0) out += `.${fraction.slice(0, 9).padEnd(9, "0").replace(/0+$/, "") || "0"}`;
|
|
4112
|
+
}
|
|
4113
|
+
if (offset !== void 0) out += /^[Zz]$/.test(offset) ? "Z" : offset.slice(1) === "00:00" ? "+00:00" : offset;
|
|
4114
|
+
return out;
|
|
4115
|
+
}
|
|
4116
|
+
function bareValues(text) {
|
|
4117
|
+
const found = [];
|
|
4118
|
+
const n = text.length;
|
|
4119
|
+
let i2 = text.charCodeAt(0) === 65279 ? 1 : 0;
|
|
4120
|
+
const space = () => {
|
|
4121
|
+
while (text[i2] === " " || text[i2] === " ") i2++;
|
|
4122
|
+
};
|
|
4123
|
+
const blank = () => {
|
|
4124
|
+
for (; ; ) {
|
|
4125
|
+
space();
|
|
4126
|
+
if (text[i2] === "#") while (i2 < n && text[i2] !== "\n") i2++;
|
|
4127
|
+
else if (text[i2] === "\n" || text[i2] === "\r") i2++;
|
|
4128
|
+
else return;
|
|
4129
|
+
}
|
|
4130
|
+
};
|
|
4131
|
+
const string = () => {
|
|
4132
|
+
const q = text[i2];
|
|
4133
|
+
const fence = q.repeat(3);
|
|
4134
|
+
if (text.startsWith(fence, i2)) {
|
|
4135
|
+
for (i2 += 3; i2 < n; i2++) {
|
|
4136
|
+
if (q === '"' && text[i2] === "\\") i2++;
|
|
4137
|
+
else if (text.startsWith(fence, i2)) {
|
|
4138
|
+
i2 += 3;
|
|
4139
|
+
for (let extra = 0; extra < 2 && text[i2] === q; extra++) i2++;
|
|
4140
|
+
return;
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
4143
|
+
return;
|
|
4144
|
+
}
|
|
4145
|
+
for (i2++; i2 < n && text[i2] !== q && text[i2] !== "\n"; i2++) if (q === '"' && text[i2] === "\\") i2++;
|
|
4146
|
+
i2++;
|
|
4147
|
+
};
|
|
4148
|
+
const key = () => {
|
|
4149
|
+
for (; ; ) {
|
|
4150
|
+
space();
|
|
4151
|
+
if (i2 >= n || text[i2] === "=" || text[i2] === "\n" || text[i2] === "#") return;
|
|
4152
|
+
if (text[i2] === '"' || text[i2] === "'") string();
|
|
4153
|
+
else i2++;
|
|
4154
|
+
}
|
|
4155
|
+
};
|
|
4156
|
+
const ENDS = " \r\n,]}#";
|
|
4157
|
+
const value = () => {
|
|
4158
|
+
const c = text[i2];
|
|
4159
|
+
if (c === '"' || c === "'") return string();
|
|
4160
|
+
if (c === "[" || c === "{") {
|
|
4161
|
+
const close = c === "[" ? "]" : "}";
|
|
4162
|
+
for (i2++; ; ) {
|
|
4163
|
+
blank();
|
|
4164
|
+
if (i2 >= n) return;
|
|
4165
|
+
if (text[i2] === close) {
|
|
4166
|
+
i2++;
|
|
4167
|
+
return;
|
|
4168
|
+
}
|
|
4169
|
+
if (close === "}") {
|
|
4170
|
+
key();
|
|
4171
|
+
if (text[i2] !== "=") return;
|
|
4172
|
+
i2++;
|
|
4173
|
+
space();
|
|
4174
|
+
}
|
|
4175
|
+
value();
|
|
4176
|
+
blank();
|
|
4177
|
+
if (text[i2] === ",") i2++;
|
|
4178
|
+
else if (text[i2] === close) {
|
|
4179
|
+
i2++;
|
|
4180
|
+
return;
|
|
4181
|
+
} else return;
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4184
|
+
const start = i2;
|
|
4185
|
+
while (i2 < n && !ENDS.includes(text[i2])) i2++;
|
|
4186
|
+
if (i2 - start === 10 && text[i2] === " " && /^\d{4}-\d{2}-\d{2}$/.test(text.slice(start, i2)) && /^\d{2}:/.test(text.slice(i2 + 1, i2 + 4))) {
|
|
4187
|
+
for (i2++; i2 < n && !ENDS.includes(text[i2]); i2++) ;
|
|
4188
|
+
}
|
|
4189
|
+
if (i2 > start) found.push({ start, end: i2 });
|
|
4190
|
+
};
|
|
4191
|
+
while (i2 < n) {
|
|
4192
|
+
blank();
|
|
4193
|
+
if (i2 >= n) break;
|
|
4194
|
+
if (text[i2] === "[") {
|
|
4195
|
+
while (i2 < n && text[i2] !== "\n" && text[i2] !== "#") {
|
|
4196
|
+
if (text[i2] === '"' || text[i2] === "'") string();
|
|
4197
|
+
else i2++;
|
|
4198
|
+
}
|
|
4199
|
+
continue;
|
|
4200
|
+
}
|
|
4201
|
+
key();
|
|
4202
|
+
if (text[i2] !== "=") {
|
|
4203
|
+
while (i2 < n && text[i2] !== "\n") i2++;
|
|
4204
|
+
continue;
|
|
4205
|
+
}
|
|
4206
|
+
i2++;
|
|
4207
|
+
space();
|
|
4208
|
+
value();
|
|
4209
|
+
}
|
|
4210
|
+
return found;
|
|
4211
|
+
}
|
|
4212
|
+
function tomlValue(v, marker = "", dates = []) {
|
|
4213
|
+
if (typeof v === "string") return marker && v.startsWith(marker) ? dates[parseInt(v.replaceAll(marker, ""), 36)] : v;
|
|
4214
|
+
if (v instanceof TomlDate) return tomlDateText(v);
|
|
4215
|
+
if (Array.isArray(v)) return v.map((item) => tomlValue(item, marker, dates));
|
|
4216
|
+
if (isPlainObject(v)) {
|
|
4217
|
+
const out = {};
|
|
4218
|
+
for (const key of Object.keys(v).sort((a, b) => a < b ? -1 : a > b ? 1 : 0)) setOwn(out, key, tomlValue(v[key], marker, dates));
|
|
4219
|
+
return out;
|
|
4220
|
+
}
|
|
4221
|
+
if (typeof v === "bigint") return Number(v);
|
|
4222
|
+
return v;
|
|
4223
|
+
}
|
|
4224
|
+
function setOwn(target, key, value) {
|
|
4225
|
+
if (key === "__proto__") Object.defineProperty(target, key, { value, writable: true, enumerable: true, configurable: true });
|
|
4226
|
+
else target[key] = value;
|
|
4227
|
+
}
|
|
4228
|
+
function tomlDateText(d) {
|
|
4229
|
+
return d.toISOString().replace(/\.(\d*?)0+(?=$|Z|[+-]\d\d:\d\d$)/, (_, digits) => digits ? `.${digits}` : "");
|
|
4230
|
+
}
|
|
4231
|
+
function readText(file) {
|
|
4232
|
+
return decodeText(fs3.readFileSync(file));
|
|
4233
|
+
}
|
|
4234
|
+
var utf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
4235
|
+
function decodeText(bytes) {
|
|
4236
|
+
try {
|
|
4237
|
+
return stripBom(utf8.decode(bytes));
|
|
4238
|
+
} catch {
|
|
4239
|
+
throw new BuildError("stream did not contain valid UTF-8");
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
var stripBom = (text) => text.charCodeAt(0) === 65279 ? text.slice(1) : text;
|
|
4243
|
+
function loadStaticDataFile(file) {
|
|
4244
|
+
const ext = path3.extname(file).slice(1);
|
|
4245
|
+
const read = () => {
|
|
4246
|
+
try {
|
|
4247
|
+
return readText(file);
|
|
4248
|
+
} catch (e) {
|
|
4249
|
+
throw context(e, `reading ${file}`);
|
|
4250
|
+
}
|
|
4251
|
+
};
|
|
4252
|
+
if (ext === "json") {
|
|
4253
|
+
const text = read();
|
|
4254
|
+
try {
|
|
4255
|
+
return JSON.parse(text);
|
|
4256
|
+
} catch (e) {
|
|
4257
|
+
throw new BuildError(`invalid JSON in ${file}: ${jsonReason(e, text)}`);
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
if (ext === "yaml" || ext === "yml") {
|
|
4261
|
+
const text = read();
|
|
4262
|
+
try {
|
|
4263
|
+
return loadYaml(text) ?? null;
|
|
4264
|
+
} catch (e) {
|
|
4265
|
+
throw new BuildError(`invalid YAML in ${file}: ${yamlReason(e)}`);
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
if (ext === "toml") {
|
|
4269
|
+
const text = read();
|
|
4270
|
+
try {
|
|
4271
|
+
return readToml(text);
|
|
4272
|
+
} catch (e) {
|
|
4273
|
+
throw new BuildError(`invalid TOML in ${file}: ${tomlReason(e)}`);
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4276
|
+
return void 0;
|
|
4277
|
+
}
|
|
4278
|
+
var STATIC_DATA_EXTENSIONS = ["json", "yaml", "yml", "toml"];
|
|
4279
|
+
function loadDataFile(file, extra) {
|
|
4280
|
+
const ext = path3.extname(file).slice(1);
|
|
4281
|
+
if (STATIC_DATA_EXTENSIONS.includes(ext)) return loadStaticDataFile(file);
|
|
4282
|
+
const load2 = extra.get(ext);
|
|
4283
|
+
return load2 ? load2(file) : NOT_DATA;
|
|
4284
|
+
}
|
|
4285
|
+
var NOT_DATA = /* @__PURE__ */ Symbol("not a data file");
|
|
4286
|
+
var REPLACED = /* @__PURE__ */ new Set(["render"]);
|
|
4287
|
+
function merge2(base, over, deep = true) {
|
|
4288
|
+
return mergeLevel(base, over, deep, true);
|
|
4289
|
+
}
|
|
4290
|
+
function mergeLevel(base, over, deep, top) {
|
|
4291
|
+
const out = { ...base };
|
|
4292
|
+
for (const key of Object.keys(over)) {
|
|
4293
|
+
const existing = key === "__proto__" && !Object.hasOwn(out, key) ? void 0 : out[key], incoming = over[key];
|
|
4294
|
+
if (deep && isPlainObject(existing) && isPlainObject(incoming)) setOwn(out, key, mergeLevel(existing, incoming, deep, false));
|
|
4295
|
+
else if (deep && Array.isArray(existing) && Array.isArray(incoming) && !(top && REPLACED.has(key))) setOwn(out, key, existing.concat(incoming));
|
|
4296
|
+
else setOwn(out, key, incoming);
|
|
4297
|
+
}
|
|
4298
|
+
return out;
|
|
4299
|
+
}
|
|
4300
|
+
function normalizeTags(data) {
|
|
4301
|
+
if (!("tags" in data)) return;
|
|
4302
|
+
const value = data.tags;
|
|
4303
|
+
let tags;
|
|
4304
|
+
if (typeof value === "string") tags = [value];
|
|
4305
|
+
else if (Array.isArray(value)) tags = value.filter((v) => v !== null && v !== void 0).map(tagName);
|
|
4306
|
+
else if (value === null || value === void 0) tags = [];
|
|
4307
|
+
else tags = [tagName(value)];
|
|
4308
|
+
data.tags = [...new Set(tags)];
|
|
4309
|
+
}
|
|
4310
|
+
function tagName(value) {
|
|
4311
|
+
if (!(value instanceof Date) || Number.isNaN(value.getTime())) return String(value);
|
|
4312
|
+
const iso = value.toISOString();
|
|
4313
|
+
return iso.endsWith("T00:00:00.000Z") ? iso.slice(0, 10) : iso;
|
|
4314
|
+
}
|
|
4315
|
+
function sameValue(a, b) {
|
|
4316
|
+
return a === b || a instanceof Date && b instanceof Date && a.getTime() === b.getTime();
|
|
4317
|
+
}
|
|
4318
|
+
function getPath(value, dotted) {
|
|
4319
|
+
let v = value;
|
|
4320
|
+
for (const key of dotted.split(".")) {
|
|
4321
|
+
if (v === null || v === void 0) return void 0;
|
|
4322
|
+
v = v[key];
|
|
4323
|
+
}
|
|
4324
|
+
return v;
|
|
4325
|
+
}
|
|
4326
|
+
function toDate(value) {
|
|
4327
|
+
if (value instanceof Date) return Number.isNaN(value.getTime()) ? void 0 : value;
|
|
4328
|
+
if (typeof value === "number") {
|
|
4329
|
+
const d = new Date(Math.trunc(value));
|
|
4330
|
+
return Number.isNaN(d.getTime()) ? void 0 : d;
|
|
4331
|
+
}
|
|
4332
|
+
if (typeof value === "string") return parseDate2(value);
|
|
4333
|
+
return void 0;
|
|
4334
|
+
}
|
|
4335
|
+
var RFC3339 = /^(\d{4})-(\d{2})-(\d{2})[Tt ](\d{2}):(\d{2}):(\d{2})(\.\d+)?([Zz]|[+-]\d{2}:\d{2})$/;
|
|
4336
|
+
var DATE_ONLY = /^([+-]?\d{1,6})-(\d{1,2})-(\d{1,2})$/;
|
|
4337
|
+
var NAIVE = /^([+-]?\d{1,6})-(\d{1,2})-(\d{1,2})[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(\.\d+)?)?$/;
|
|
4338
|
+
function parseDate2(text) {
|
|
4339
|
+
const s = text.trim();
|
|
4340
|
+
let m = RFC3339.exec(s);
|
|
4341
|
+
if (m) {
|
|
4342
|
+
const utc = utcMs(m[1], m[2], m[3], m[4], m[5], m[6], m[7]);
|
|
4343
|
+
if (utc === void 0) return void 0;
|
|
4344
|
+
const zone = m[8];
|
|
4345
|
+
let offset = 0;
|
|
4346
|
+
if (zone !== "Z" && zone !== "z") {
|
|
4347
|
+
const minutes = Number(zone.slice(1, 3)) * 60 + Number(zone.slice(4, 6));
|
|
4348
|
+
offset = (zone[0] === "-" ? -minutes : minutes) * 6e4;
|
|
4349
|
+
}
|
|
4350
|
+
return new Date(utc - offset);
|
|
4351
|
+
}
|
|
4352
|
+
m = DATE_ONLY.exec(s);
|
|
4353
|
+
if (m) {
|
|
4354
|
+
const utc = utcMs(m[1], m[2], m[3]);
|
|
4355
|
+
return utc === void 0 ? void 0 : new Date(utc);
|
|
4356
|
+
}
|
|
4357
|
+
m = NAIVE.exec(s);
|
|
4358
|
+
if (m) {
|
|
4359
|
+
if (m[7] !== void 0 && !s.includes("T")) return void 0;
|
|
4360
|
+
if (m[6] === void 0 && s.includes("T")) return void 0;
|
|
4361
|
+
const utc = utcMs(m[1], m[2], m[3], m[4], m[5], m[6] ?? "0", m[7]);
|
|
4362
|
+
return utc === void 0 ? void 0 : new Date(utc);
|
|
4363
|
+
}
|
|
4364
|
+
return void 0;
|
|
4365
|
+
}
|
|
4366
|
+
function utcMs(y, mo, d, h = "0", mi = "0", s = "0", fraction) {
|
|
4367
|
+
const [year, month, day, hour, minute, second] = [y, mo, d, h, mi, s].map(Number);
|
|
4368
|
+
if (month < 1 || month > 12 || day < 1 || hour > 23 || minute > 59 || second > 60) return void 0;
|
|
4369
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
4370
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
4371
|
+
date.setUTCHours(hour, minute, Math.min(second, 59), fraction ? Math.floor(Number(`0${fraction}`) * 1e3) : 0);
|
|
4372
|
+
if (date.getUTCDate() !== day || Number.isNaN(date.getTime())) return void 0;
|
|
4373
|
+
return date.getTime();
|
|
4374
|
+
}
|
|
4375
|
+
|
|
4376
|
+
export {
|
|
4377
|
+
TomlError,
|
|
4378
|
+
isPlainObject,
|
|
4379
|
+
parseFrontMatter,
|
|
4380
|
+
tomlReason,
|
|
4381
|
+
readToml,
|
|
4382
|
+
setOwn,
|
|
4383
|
+
readText,
|
|
4384
|
+
decodeText,
|
|
4385
|
+
loadStaticDataFile,
|
|
4386
|
+
STATIC_DATA_EXTENSIONS,
|
|
4387
|
+
loadDataFile,
|
|
4388
|
+
NOT_DATA,
|
|
4389
|
+
merge2 as merge,
|
|
4390
|
+
normalizeTags,
|
|
4391
|
+
sameValue,
|
|
4392
|
+
getPath,
|
|
4393
|
+
toDate,
|
|
4394
|
+
TABLE,
|
|
4395
|
+
find,
|
|
4396
|
+
hint,
|
|
4397
|
+
toJson,
|
|
4398
|
+
OTHER_CONFIGS,
|
|
4399
|
+
otherGenerator,
|
|
4400
|
+
warning,
|
|
4401
|
+
error,
|
|
4402
|
+
toJson2,
|
|
4403
|
+
Diagnostics,
|
|
4404
|
+
BuildError,
|
|
4405
|
+
messageOf,
|
|
4406
|
+
context,
|
|
4407
|
+
bail,
|
|
4408
|
+
capture,
|
|
4409
|
+
isCapturing,
|
|
4410
|
+
takeWarnings,
|
|
4411
|
+
warn,
|
|
4412
|
+
setQuiet,
|
|
4413
|
+
aliasUsed,
|
|
4414
|
+
aliasesKnown,
|
|
4415
|
+
aliasesUsed,
|
|
4416
|
+
progress,
|
|
4417
|
+
red,
|
|
4418
|
+
Locator,
|
|
4419
|
+
fromError,
|
|
4420
|
+
describe,
|
|
4421
|
+
printError
|
|
4422
|
+
};
|
|
4423
|
+
/*! For license information please see chunk-6XYSFG6V.js.LEGAL.txt */
|