@dev-blinq/cucumber_client 1.0.1237-dev → 1.0.1237-stage
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/bin/assets/bundled_scripts/recorder.js +220 -0
- package/bin/assets/preload/recorderv3.js +5 -3
- package/bin/assets/preload/unique_locators.js +1 -1
- package/bin/assets/scripts/aria_snapshot.js +235 -0
- package/bin/assets/scripts/dom_attr.js +372 -0
- package/bin/assets/scripts/dom_element.js +0 -0
- package/bin/assets/scripts/dom_parent.js +185 -0
- package/bin/assets/scripts/event_utils.js +105 -0
- package/bin/assets/scripts/pw.js +7886 -0
- package/bin/assets/scripts/recorder.js +1147 -0
- package/bin/assets/scripts/snapshot_capturer.js +155 -0
- package/bin/assets/scripts/unique_locators.js +852 -0
- package/bin/assets/scripts/yaml.js +4770 -0
- package/bin/assets/templates/_hooks_template.txt +37 -0
- package/bin/assets/templates/page_template.txt +2 -16
- package/bin/assets/templates/utils_template.txt +44 -71
- package/bin/client/apiTest/apiTest.js +6 -0
- package/bin/client/cli_helpers.js +11 -13
- package/bin/client/code_cleanup/utils.js +36 -13
- package/bin/client/code_gen/code_inversion.js +68 -10
- package/bin/client/code_gen/page_reflection.js +12 -15
- package/bin/client/code_gen/playwright_codeget.js +127 -34
- package/bin/client/cucumber/feature.js +85 -27
- package/bin/client/cucumber/steps_definitions.js +84 -76
- package/bin/client/cucumber_selector.js +13 -1
- package/bin/client/local_agent.js +3 -3
- package/bin/client/project.js +7 -1
- package/bin/client/recorderv3/bvt_recorder.js +267 -87
- package/bin/client/recorderv3/implemented_steps.js +74 -12
- package/bin/client/recorderv3/index.js +58 -8
- package/bin/client/recorderv3/network.js +299 -0
- package/bin/client/recorderv3/step_runner.js +319 -67
- package/bin/client/recorderv3/step_utils.js +152 -5
- package/bin/client/recorderv3/update_feature.js +58 -30
- package/bin/client/recording.js +5 -0
- package/bin/client/run_cucumber.js +5 -1
- package/bin/client/scenario_report.js +0 -5
- package/bin/client/test_scenario.js +0 -1
- package/bin/index.js +1 -0
- package/package.json +17 -9
|
@@ -0,0 +1,4770 @@
|
|
|
1
|
+
var Yaml = (function (e) {
|
|
2
|
+
"use strict";
|
|
3
|
+
const t = Symbol.for("yaml.alias"),
|
|
4
|
+
n = Symbol.for("yaml.document"),
|
|
5
|
+
s = Symbol.for("yaml.map"),
|
|
6
|
+
i = Symbol.for("yaml.pair"),
|
|
7
|
+
o = Symbol.for("yaml.scalar"),
|
|
8
|
+
r = Symbol.for("yaml.seq"),
|
|
9
|
+
a = Symbol.for("yaml.node.type"),
|
|
10
|
+
c = (e) => !!e && "object" == typeof e && e[a] === t,
|
|
11
|
+
l = (e) => !!e && "object" == typeof e && e[a] === n,
|
|
12
|
+
u = (e) => !!e && "object" == typeof e && e[a] === s,
|
|
13
|
+
f = (e) => !!e && "object" == typeof e && e[a] === i,
|
|
14
|
+
h = (e) => !!e && "object" == typeof e && e[a] === o,
|
|
15
|
+
d = (e) => !!e && "object" == typeof e && e[a] === r;
|
|
16
|
+
function p(e) {
|
|
17
|
+
if (e && "object" == typeof e)
|
|
18
|
+
switch (e[a]) {
|
|
19
|
+
case s:
|
|
20
|
+
case r:
|
|
21
|
+
return !0;
|
|
22
|
+
}
|
|
23
|
+
return !1;
|
|
24
|
+
}
|
|
25
|
+
function m(e) {
|
|
26
|
+
if (e && "object" == typeof e)
|
|
27
|
+
switch (e[a]) {
|
|
28
|
+
case t:
|
|
29
|
+
case s:
|
|
30
|
+
case o:
|
|
31
|
+
case r:
|
|
32
|
+
return !0;
|
|
33
|
+
}
|
|
34
|
+
return !1;
|
|
35
|
+
}
|
|
36
|
+
const y = (e) => (h(e) || p(e)) && !!e.anchor,
|
|
37
|
+
g = Symbol("break visit"),
|
|
38
|
+
b = Symbol("skip children"),
|
|
39
|
+
k = Symbol("remove node");
|
|
40
|
+
function w(e, t) {
|
|
41
|
+
const n = N(t);
|
|
42
|
+
if (l(e)) {
|
|
43
|
+
v(null, e.contents, n, Object.freeze([e])) === k && (e.contents = null);
|
|
44
|
+
} else v(null, e, n, Object.freeze([]));
|
|
45
|
+
}
|
|
46
|
+
function v(e, t, n, s) {
|
|
47
|
+
const i = O(e, t, n, s);
|
|
48
|
+
if (m(i) || f(i)) return A(e, s, i), v(e, i, n, s);
|
|
49
|
+
if ("symbol" != typeof i)
|
|
50
|
+
if (p(t)) {
|
|
51
|
+
s = Object.freeze(s.concat(t));
|
|
52
|
+
for (let e = 0; e < t.items.length; ++e) {
|
|
53
|
+
const i = v(e, t.items[e], n, s);
|
|
54
|
+
if ("number" == typeof i) e = i - 1;
|
|
55
|
+
else {
|
|
56
|
+
if (i === g) return g;
|
|
57
|
+
i === k && (t.items.splice(e, 1), (e -= 1));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} else if (f(t)) {
|
|
61
|
+
s = Object.freeze(s.concat(t));
|
|
62
|
+
const e = v("key", t.key, n, s);
|
|
63
|
+
if (e === g) return g;
|
|
64
|
+
e === k && (t.key = null);
|
|
65
|
+
const i = v("value", t.value, n, s);
|
|
66
|
+
if (i === g) return g;
|
|
67
|
+
i === k && (t.value = null);
|
|
68
|
+
}
|
|
69
|
+
return i;
|
|
70
|
+
}
|
|
71
|
+
async function S(e, t) {
|
|
72
|
+
const n = N(t);
|
|
73
|
+
if (l(e)) {
|
|
74
|
+
(await E(null, e.contents, n, Object.freeze([e]))) === k && (e.contents = null);
|
|
75
|
+
} else await E(null, e, n, Object.freeze([]));
|
|
76
|
+
}
|
|
77
|
+
async function E(e, t, n, s) {
|
|
78
|
+
const i = await O(e, t, n, s);
|
|
79
|
+
if (m(i) || f(i)) return A(e, s, i), E(e, i, n, s);
|
|
80
|
+
if ("symbol" != typeof i)
|
|
81
|
+
if (p(t)) {
|
|
82
|
+
s = Object.freeze(s.concat(t));
|
|
83
|
+
for (let e = 0; e < t.items.length; ++e) {
|
|
84
|
+
const i = await E(e, t.items[e], n, s);
|
|
85
|
+
if ("number" == typeof i) e = i - 1;
|
|
86
|
+
else {
|
|
87
|
+
if (i === g) return g;
|
|
88
|
+
i === k && (t.items.splice(e, 1), (e -= 1));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} else if (f(t)) {
|
|
92
|
+
s = Object.freeze(s.concat(t));
|
|
93
|
+
const e = await E("key", t.key, n, s);
|
|
94
|
+
if (e === g) return g;
|
|
95
|
+
e === k && (t.key = null);
|
|
96
|
+
const i = await E("value", t.value, n, s);
|
|
97
|
+
if (i === g) return g;
|
|
98
|
+
i === k && (t.value = null);
|
|
99
|
+
}
|
|
100
|
+
return i;
|
|
101
|
+
}
|
|
102
|
+
function N(e) {
|
|
103
|
+
return "object" == typeof e && (e.Collection || e.Node || e.Value)
|
|
104
|
+
? Object.assign(
|
|
105
|
+
{ Alias: e.Node, Map: e.Node, Scalar: e.Node, Seq: e.Node },
|
|
106
|
+
e.Value && { Map: e.Value, Scalar: e.Value, Seq: e.Value },
|
|
107
|
+
e.Collection && { Map: e.Collection, Seq: e.Collection },
|
|
108
|
+
e
|
|
109
|
+
)
|
|
110
|
+
: e;
|
|
111
|
+
}
|
|
112
|
+
function O(e, t, n, s) {
|
|
113
|
+
return "function" == typeof n
|
|
114
|
+
? n(e, t, s)
|
|
115
|
+
: u(t)
|
|
116
|
+
? n.Map?.(e, t, s)
|
|
117
|
+
: d(t)
|
|
118
|
+
? n.Seq?.(e, t, s)
|
|
119
|
+
: f(t)
|
|
120
|
+
? n.Pair?.(e, t, s)
|
|
121
|
+
: h(t)
|
|
122
|
+
? n.Scalar?.(e, t, s)
|
|
123
|
+
: c(t)
|
|
124
|
+
? n.Alias?.(e, t, s)
|
|
125
|
+
: void 0;
|
|
126
|
+
}
|
|
127
|
+
function A(e, t, n) {
|
|
128
|
+
const s = t[t.length - 1];
|
|
129
|
+
if (p(s)) s.items[e] = n;
|
|
130
|
+
else if (f(s)) "key" === e ? (s.key = n) : (s.value = n);
|
|
131
|
+
else {
|
|
132
|
+
if (!l(s)) {
|
|
133
|
+
const e = c(s) ? "alias" : "scalar";
|
|
134
|
+
throw new Error(`Cannot replace node with ${e} parent`);
|
|
135
|
+
}
|
|
136
|
+
s.contents = n;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
(w.BREAK = g), (w.SKIP = b), (w.REMOVE = k), (S.BREAK = g), (S.SKIP = b), (S.REMOVE = k);
|
|
140
|
+
const I = { "!": "%21", ",": "%2C", "[": "%5B", "]": "%5D", "{": "%7B", "}": "%7D" };
|
|
141
|
+
class T {
|
|
142
|
+
constructor(e, t) {
|
|
143
|
+
(this.docStart = null),
|
|
144
|
+
(this.docEnd = !1),
|
|
145
|
+
(this.yaml = Object.assign({}, T.defaultYaml, e)),
|
|
146
|
+
(this.tags = Object.assign({}, T.defaultTags, t));
|
|
147
|
+
}
|
|
148
|
+
clone() {
|
|
149
|
+
const e = new T(this.yaml, this.tags);
|
|
150
|
+
return (e.docStart = this.docStart), e;
|
|
151
|
+
}
|
|
152
|
+
atDocument() {
|
|
153
|
+
const e = new T(this.yaml, this.tags);
|
|
154
|
+
switch (this.yaml.version) {
|
|
155
|
+
case "1.1":
|
|
156
|
+
this.atNextDocument = !0;
|
|
157
|
+
break;
|
|
158
|
+
case "1.2":
|
|
159
|
+
(this.atNextDocument = !1),
|
|
160
|
+
(this.yaml = { explicit: T.defaultYaml.explicit, version: "1.2" }),
|
|
161
|
+
(this.tags = Object.assign({}, T.defaultTags));
|
|
162
|
+
}
|
|
163
|
+
return e;
|
|
164
|
+
}
|
|
165
|
+
add(e, t) {
|
|
166
|
+
this.atNextDocument &&
|
|
167
|
+
((this.yaml = { explicit: T.defaultYaml.explicit, version: "1.1" }),
|
|
168
|
+
(this.tags = Object.assign({}, T.defaultTags)),
|
|
169
|
+
(this.atNextDocument = !1));
|
|
170
|
+
const n = e.trim().split(/[ \t]+/),
|
|
171
|
+
s = n.shift();
|
|
172
|
+
switch (s) {
|
|
173
|
+
case "%TAG": {
|
|
174
|
+
if (2 !== n.length && (t(0, "%TAG directive should contain exactly two parts"), n.length < 2)) return !1;
|
|
175
|
+
const [e, s] = n;
|
|
176
|
+
return (this.tags[e] = s), !0;
|
|
177
|
+
}
|
|
178
|
+
case "%YAML": {
|
|
179
|
+
if (((this.yaml.explicit = !0), 1 !== n.length))
|
|
180
|
+
return t(0, "%YAML directive should contain exactly one part"), !1;
|
|
181
|
+
const [e] = n;
|
|
182
|
+
if ("1.1" === e || "1.2" === e) return (this.yaml.version = e), !0;
|
|
183
|
+
return t(6, `Unsupported YAML version ${e}`, /^\d+\.\d+$/.test(e)), !1;
|
|
184
|
+
}
|
|
185
|
+
default:
|
|
186
|
+
return t(0, `Unknown directive ${s}`, !0), !1;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
tagName(e, t) {
|
|
190
|
+
if ("!" === e) return "!";
|
|
191
|
+
if ("!" !== e[0]) return t(`Not a valid tag: ${e}`), null;
|
|
192
|
+
if ("<" === e[1]) {
|
|
193
|
+
const n = e.slice(2, -1);
|
|
194
|
+
return "!" === n || "!!" === n
|
|
195
|
+
? (t(`Verbatim tags aren't resolved, so ${e} is invalid.`), null)
|
|
196
|
+
: (">" !== e[e.length - 1] && t("Verbatim tags must end with a >"), n);
|
|
197
|
+
}
|
|
198
|
+
const [, n, s] = e.match(/^(.*!)([^!]*)$/s);
|
|
199
|
+
s || t(`The ${e} tag has no suffix`);
|
|
200
|
+
const i = this.tags[n];
|
|
201
|
+
if (i)
|
|
202
|
+
try {
|
|
203
|
+
return i + decodeURIComponent(s);
|
|
204
|
+
} catch (e) {
|
|
205
|
+
return t(String(e)), null;
|
|
206
|
+
}
|
|
207
|
+
return "!" === n ? e : (t(`Could not resolve tag: ${e}`), null);
|
|
208
|
+
}
|
|
209
|
+
tagString(e) {
|
|
210
|
+
for (const [t, n] of Object.entries(this.tags))
|
|
211
|
+
if (e.startsWith(n)) return t + e.substring(n.length).replace(/[!,[\]{}]/g, (e) => I[e]);
|
|
212
|
+
return "!" === e[0] ? e : `!<${e}>`;
|
|
213
|
+
}
|
|
214
|
+
toString(e) {
|
|
215
|
+
const t = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : [],
|
|
216
|
+
n = Object.entries(this.tags);
|
|
217
|
+
let s;
|
|
218
|
+
if (e && n.length > 0 && m(e.contents)) {
|
|
219
|
+
const t = {};
|
|
220
|
+
w(e.contents, (e, n) => {
|
|
221
|
+
m(n) && n.tag && (t[n.tag] = !0);
|
|
222
|
+
}),
|
|
223
|
+
(s = Object.keys(t));
|
|
224
|
+
} else s = [];
|
|
225
|
+
for (const [i, o] of n)
|
|
226
|
+
("!!" === i && "tag:yaml.org,2002:" === o) ||
|
|
227
|
+
(e && !s.some((e) => e.startsWith(o))) ||
|
|
228
|
+
t.push(`%TAG ${i} ${o}`);
|
|
229
|
+
return t.join("\n");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function L(e) {
|
|
233
|
+
if (/[\x00-\x19\s,[\]{}]/.test(e)) {
|
|
234
|
+
const t = JSON.stringify(e);
|
|
235
|
+
throw new Error(`Anchor must not contain whitespace or control characters: ${t}`);
|
|
236
|
+
}
|
|
237
|
+
return !0;
|
|
238
|
+
}
|
|
239
|
+
function x(e) {
|
|
240
|
+
const t = new Set();
|
|
241
|
+
return (
|
|
242
|
+
w(e, {
|
|
243
|
+
Value(e, n) {
|
|
244
|
+
n.anchor && t.add(n.anchor);
|
|
245
|
+
},
|
|
246
|
+
}),
|
|
247
|
+
t
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
function $(e, t) {
|
|
251
|
+
for (let n = 1; ; ++n) {
|
|
252
|
+
const s = `${e}${n}`;
|
|
253
|
+
if (!t.has(s)) return s;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function C(e, t, n, s) {
|
|
257
|
+
if (s && "object" == typeof s)
|
|
258
|
+
if (Array.isArray(s))
|
|
259
|
+
for (let t = 0, n = s.length; t < n; ++t) {
|
|
260
|
+
const n = s[t],
|
|
261
|
+
i = C(e, s, String(t), n);
|
|
262
|
+
void 0 === i ? delete s[t] : i !== n && (s[t] = i);
|
|
263
|
+
}
|
|
264
|
+
else if (s instanceof Map)
|
|
265
|
+
for (const t of Array.from(s.keys())) {
|
|
266
|
+
const n = s.get(t),
|
|
267
|
+
i = C(e, s, t, n);
|
|
268
|
+
void 0 === i ? s.delete(t) : i !== n && s.set(t, i);
|
|
269
|
+
}
|
|
270
|
+
else if (s instanceof Set)
|
|
271
|
+
for (const t of Array.from(s)) {
|
|
272
|
+
const n = C(e, s, t, t);
|
|
273
|
+
void 0 === n ? s.delete(t) : n !== t && (s.delete(t), s.add(n));
|
|
274
|
+
}
|
|
275
|
+
else
|
|
276
|
+
for (const [t, n] of Object.entries(s)) {
|
|
277
|
+
const i = C(e, s, t, n);
|
|
278
|
+
void 0 === i ? delete s[t] : i !== n && (s[t] = i);
|
|
279
|
+
}
|
|
280
|
+
return e.call(t, n, s);
|
|
281
|
+
}
|
|
282
|
+
function _(e, t, n) {
|
|
283
|
+
if (Array.isArray(e)) return e.map((e, t) => _(e, String(t), n));
|
|
284
|
+
if (e && "function" == typeof e.toJSON) {
|
|
285
|
+
if (!n || !y(e)) return e.toJSON(t, n);
|
|
286
|
+
const s = { aliasCount: 0, count: 1, res: void 0 };
|
|
287
|
+
n.anchors.set(e, s),
|
|
288
|
+
(n.onCreate = (e) => {
|
|
289
|
+
(s.res = e), delete n.onCreate;
|
|
290
|
+
});
|
|
291
|
+
const i = e.toJSON(t, n);
|
|
292
|
+
return n.onCreate && n.onCreate(i), i;
|
|
293
|
+
}
|
|
294
|
+
return "bigint" != typeof e || n?.keep ? e : Number(e);
|
|
295
|
+
}
|
|
296
|
+
(T.defaultYaml = { explicit: !1, version: "1.2" }), (T.defaultTags = { "!!": "tag:yaml.org,2002:" });
|
|
297
|
+
class K {
|
|
298
|
+
constructor(e) {
|
|
299
|
+
Object.defineProperty(this, a, { value: e });
|
|
300
|
+
}
|
|
301
|
+
clone() {
|
|
302
|
+
const e = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
303
|
+
return this.range && (e.range = this.range.slice()), e;
|
|
304
|
+
}
|
|
305
|
+
toJS(e, { mapAsMap: t, maxAliasCount: n, onAnchor: s, reviver: i } = {}) {
|
|
306
|
+
if (!l(e)) throw new TypeError("A document argument is required");
|
|
307
|
+
const o = {
|
|
308
|
+
anchors: new Map(),
|
|
309
|
+
doc: e,
|
|
310
|
+
keep: !0,
|
|
311
|
+
mapAsMap: !0 === t,
|
|
312
|
+
mapKeyWarned: !1,
|
|
313
|
+
maxAliasCount: "number" == typeof n ? n : 100,
|
|
314
|
+
},
|
|
315
|
+
r = _(this, "", o);
|
|
316
|
+
if ("function" == typeof s) for (const { count: e, res: t } of o.anchors.values()) s(t, e);
|
|
317
|
+
return "function" == typeof i ? C(i, { "": r }, "", r) : r;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
class B extends K {
|
|
321
|
+
constructor(e) {
|
|
322
|
+
super(t),
|
|
323
|
+
(this.source = e),
|
|
324
|
+
Object.defineProperty(this, "tag", {
|
|
325
|
+
set() {
|
|
326
|
+
throw new Error("Alias nodes cannot have tags");
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
resolve(e, t) {
|
|
331
|
+
let n, s;
|
|
332
|
+
t?.aliasResolveCache
|
|
333
|
+
? (n = t.aliasResolveCache)
|
|
334
|
+
: ((n = []),
|
|
335
|
+
w(e, {
|
|
336
|
+
Node: (e, t) => {
|
|
337
|
+
(c(t) || y(t)) && n.push(t);
|
|
338
|
+
},
|
|
339
|
+
}),
|
|
340
|
+
t && (t.aliasResolveCache = n));
|
|
341
|
+
for (const e of n) {
|
|
342
|
+
if (e === this) break;
|
|
343
|
+
e.anchor === this.source && (s = e);
|
|
344
|
+
}
|
|
345
|
+
return s;
|
|
346
|
+
}
|
|
347
|
+
toJSON(e, t) {
|
|
348
|
+
if (!t) return { source: this.source };
|
|
349
|
+
const { anchors: n, doc: s, maxAliasCount: i } = t,
|
|
350
|
+
o = this.resolve(s, t);
|
|
351
|
+
if (!o) {
|
|
352
|
+
const e = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
353
|
+
throw new ReferenceError(e);
|
|
354
|
+
}
|
|
355
|
+
let r = n.get(o);
|
|
356
|
+
if ((r || (_(o, null, t), (r = n.get(o))), !r || void 0 === r.res)) {
|
|
357
|
+
throw new ReferenceError("This should not happen: Alias anchor was not resolved?");
|
|
358
|
+
}
|
|
359
|
+
if (i >= 0 && ((r.count += 1), 0 === r.aliasCount && (r.aliasCount = j(s, o, n)), r.count * r.aliasCount > i)) {
|
|
360
|
+
throw new ReferenceError("Excessive alias count indicates a resource exhaustion attack");
|
|
361
|
+
}
|
|
362
|
+
return r.res;
|
|
363
|
+
}
|
|
364
|
+
toString(e, t, n) {
|
|
365
|
+
const s = `*${this.source}`;
|
|
366
|
+
if (e) {
|
|
367
|
+
if ((L(this.source), e.options.verifyAliasOrder && !e.anchors.has(this.source))) {
|
|
368
|
+
const e = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
369
|
+
throw new Error(e);
|
|
370
|
+
}
|
|
371
|
+
if (e.implicitKey) return `${s} `;
|
|
372
|
+
}
|
|
373
|
+
return s;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function j(e, t, n) {
|
|
377
|
+
if (c(t)) {
|
|
378
|
+
const s = t.resolve(e),
|
|
379
|
+
i = n && s && n.get(s);
|
|
380
|
+
return i ? i.count * i.aliasCount : 0;
|
|
381
|
+
}
|
|
382
|
+
if (p(t)) {
|
|
383
|
+
let s = 0;
|
|
384
|
+
for (const i of t.items) {
|
|
385
|
+
const t = j(e, i, n);
|
|
386
|
+
t > s && (s = t);
|
|
387
|
+
}
|
|
388
|
+
return s;
|
|
389
|
+
}
|
|
390
|
+
if (f(t)) {
|
|
391
|
+
const s = j(e, t.key, n),
|
|
392
|
+
i = j(e, t.value, n);
|
|
393
|
+
return Math.max(s, i);
|
|
394
|
+
}
|
|
395
|
+
return 1;
|
|
396
|
+
}
|
|
397
|
+
const M = (e) => !e || ("function" != typeof e && "object" != typeof e);
|
|
398
|
+
class D extends K {
|
|
399
|
+
constructor(e) {
|
|
400
|
+
super(o), (this.value = e);
|
|
401
|
+
}
|
|
402
|
+
toJSON(e, t) {
|
|
403
|
+
return t?.keep ? this.value : _(this.value, e, t);
|
|
404
|
+
}
|
|
405
|
+
toString() {
|
|
406
|
+
return String(this.value);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
(D.BLOCK_FOLDED = "BLOCK_FOLDED"),
|
|
410
|
+
(D.BLOCK_LITERAL = "BLOCK_LITERAL"),
|
|
411
|
+
(D.PLAIN = "PLAIN"),
|
|
412
|
+
(D.QUOTE_DOUBLE = "QUOTE_DOUBLE"),
|
|
413
|
+
(D.QUOTE_SINGLE = "QUOTE_SINGLE");
|
|
414
|
+
function q(e, t, n) {
|
|
415
|
+
if ((l(e) && (e = e.contents), m(e))) return e;
|
|
416
|
+
if (f(e)) {
|
|
417
|
+
const t = n.schema[s].createNode?.(n.schema, null, n);
|
|
418
|
+
return t.items.push(e), t;
|
|
419
|
+
}
|
|
420
|
+
(e instanceof String ||
|
|
421
|
+
e instanceof Number ||
|
|
422
|
+
e instanceof Boolean ||
|
|
423
|
+
("undefined" != typeof BigInt && e instanceof BigInt)) &&
|
|
424
|
+
(e = e.valueOf());
|
|
425
|
+
const { aliasDuplicateObjects: i, onAnchor: o, onTagObj: a, schema: c, sourceObjects: u } = n;
|
|
426
|
+
let h;
|
|
427
|
+
if (i && e && "object" == typeof e) {
|
|
428
|
+
if (((h = u.get(e)), h)) return h.anchor || (h.anchor = o(e)), new B(h.anchor);
|
|
429
|
+
(h = { anchor: null, node: null }), u.set(e, h);
|
|
430
|
+
}
|
|
431
|
+
t?.startsWith("!!") && (t = "tag:yaml.org,2002:" + t.slice(2));
|
|
432
|
+
let d = (function (e, t, n) {
|
|
433
|
+
if (t) {
|
|
434
|
+
const e = n.filter((e) => e.tag === t),
|
|
435
|
+
s = e.find((e) => !e.format) ?? e[0];
|
|
436
|
+
if (!s) throw new Error(`Tag ${t} not found`);
|
|
437
|
+
return s;
|
|
438
|
+
}
|
|
439
|
+
return n.find((t) => t.identify?.(e) && !t.format);
|
|
440
|
+
})(e, t, c.tags);
|
|
441
|
+
if (!d) {
|
|
442
|
+
if ((e && "function" == typeof e.toJSON && (e = e.toJSON()), !e || "object" != typeof e)) {
|
|
443
|
+
const t = new D(e);
|
|
444
|
+
return h && (h.node = t), t;
|
|
445
|
+
}
|
|
446
|
+
d = e instanceof Map ? c[s] : Symbol.iterator in Object(e) ? c[r] : c[s];
|
|
447
|
+
}
|
|
448
|
+
a && (a(d), delete n.onTagObj);
|
|
449
|
+
const p = d?.createNode
|
|
450
|
+
? d.createNode(n.schema, e, n)
|
|
451
|
+
: "function" == typeof d?.nodeClass?.from
|
|
452
|
+
? d.nodeClass.from(n.schema, e, n)
|
|
453
|
+
: new D(e);
|
|
454
|
+
return t ? (p.tag = t) : d.default || (p.tag = d.tag), h && (h.node = p), p;
|
|
455
|
+
}
|
|
456
|
+
function P(e, t, n) {
|
|
457
|
+
let s = n;
|
|
458
|
+
for (let e = t.length - 1; e >= 0; --e) {
|
|
459
|
+
const n = t[e];
|
|
460
|
+
if ("number" == typeof n && Number.isInteger(n) && n >= 0) {
|
|
461
|
+
const e = [];
|
|
462
|
+
(e[n] = s), (s = e);
|
|
463
|
+
} else s = new Map([[n, s]]);
|
|
464
|
+
}
|
|
465
|
+
return q(s, void 0, {
|
|
466
|
+
aliasDuplicateObjects: !1,
|
|
467
|
+
keepUndefined: !1,
|
|
468
|
+
onAnchor: () => {
|
|
469
|
+
throw new Error("This should not happen, please report a bug.");
|
|
470
|
+
},
|
|
471
|
+
schema: e,
|
|
472
|
+
sourceObjects: new Map(),
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
const U = (e) => null == e || ("object" == typeof e && !!e[Symbol.iterator]().next().done);
|
|
476
|
+
class R extends K {
|
|
477
|
+
constructor(e, t) {
|
|
478
|
+
super(e), Object.defineProperty(this, "schema", { value: t, configurable: !0, enumerable: !1, writable: !0 });
|
|
479
|
+
}
|
|
480
|
+
clone(e) {
|
|
481
|
+
const t = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
482
|
+
return (
|
|
483
|
+
e && (t.schema = e),
|
|
484
|
+
(t.items = t.items.map((t) => (m(t) || f(t) ? t.clone(e) : t))),
|
|
485
|
+
this.range && (t.range = this.range.slice()),
|
|
486
|
+
t
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
addIn(e, t) {
|
|
490
|
+
if (U(e)) this.add(t);
|
|
491
|
+
else {
|
|
492
|
+
const [n, ...s] = e,
|
|
493
|
+
i = this.get(n, !0);
|
|
494
|
+
if (p(i)) i.addIn(s, t);
|
|
495
|
+
else {
|
|
496
|
+
if (void 0 !== i || !this.schema) throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`);
|
|
497
|
+
this.set(n, P(this.schema, s, t));
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
deleteIn(e) {
|
|
502
|
+
const [t, ...n] = e;
|
|
503
|
+
if (0 === n.length) return this.delete(t);
|
|
504
|
+
const s = this.get(t, !0);
|
|
505
|
+
if (p(s)) return s.deleteIn(n);
|
|
506
|
+
throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`);
|
|
507
|
+
}
|
|
508
|
+
getIn(e, t) {
|
|
509
|
+
const [n, ...s] = e,
|
|
510
|
+
i = this.get(n, !0);
|
|
511
|
+
return 0 === s.length ? (!t && h(i) ? i.value : i) : p(i) ? i.getIn(s, t) : void 0;
|
|
512
|
+
}
|
|
513
|
+
hasAllNullValues(e) {
|
|
514
|
+
return this.items.every((t) => {
|
|
515
|
+
if (!f(t)) return !1;
|
|
516
|
+
const n = t.value;
|
|
517
|
+
return null == n || (e && h(n) && null == n.value && !n.commentBefore && !n.comment && !n.tag);
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
hasIn(e) {
|
|
521
|
+
const [t, ...n] = e;
|
|
522
|
+
if (0 === n.length) return this.has(t);
|
|
523
|
+
const s = this.get(t, !0);
|
|
524
|
+
return !!p(s) && s.hasIn(n);
|
|
525
|
+
}
|
|
526
|
+
setIn(e, t) {
|
|
527
|
+
const [n, ...s] = e;
|
|
528
|
+
if (0 === s.length) this.set(n, t);
|
|
529
|
+
else {
|
|
530
|
+
const e = this.get(n, !0);
|
|
531
|
+
if (p(e)) e.setIn(s, t);
|
|
532
|
+
else {
|
|
533
|
+
if (void 0 !== e || !this.schema) throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`);
|
|
534
|
+
this.set(n, P(this.schema, s, t));
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
const F = (e) => e.replace(/^(?!$)(?: $)?/gm, "#");
|
|
540
|
+
function V(e, t) {
|
|
541
|
+
return /^\n+$/.test(e) ? e.substring(1) : t ? e.replace(/^(?! *$)/gm, t) : e;
|
|
542
|
+
}
|
|
543
|
+
const J = (e, t, n) =>
|
|
544
|
+
e.endsWith("\n") ? V(n, t) : n.includes("\n") ? "\n" + V(n, t) : (e.endsWith(" ") ? "" : " ") + n,
|
|
545
|
+
Y = "flow",
|
|
546
|
+
W = "block",
|
|
547
|
+
G = "quoted";
|
|
548
|
+
function Q(
|
|
549
|
+
e,
|
|
550
|
+
t,
|
|
551
|
+
n = "flow",
|
|
552
|
+
{ indentAtStart: s, lineWidth: i = 80, minContentWidth: o = 20, onFold: r, onOverflow: a } = {}
|
|
553
|
+
) {
|
|
554
|
+
if (!i || i < 0) return e;
|
|
555
|
+
i < o && (o = 0);
|
|
556
|
+
const c = Math.max(1 + o, 1 + i - t.length);
|
|
557
|
+
if (e.length <= c) return e;
|
|
558
|
+
const l = [],
|
|
559
|
+
u = {};
|
|
560
|
+
let f,
|
|
561
|
+
h,
|
|
562
|
+
d = i - t.length;
|
|
563
|
+
"number" == typeof s && (s > i - Math.max(2, o) ? l.push(0) : (d = i - s));
|
|
564
|
+
let p = !1,
|
|
565
|
+
m = -1,
|
|
566
|
+
y = -1,
|
|
567
|
+
g = -1;
|
|
568
|
+
n === W && ((m = H(e, m, t.length)), -1 !== m && (d = m + c));
|
|
569
|
+
for (let s; (s = e[(m += 1)]);) {
|
|
570
|
+
if (n === G && "\\" === s) {
|
|
571
|
+
switch (((y = m), e[m + 1])) {
|
|
572
|
+
case "x":
|
|
573
|
+
m += 3;
|
|
574
|
+
break;
|
|
575
|
+
case "u":
|
|
576
|
+
m += 5;
|
|
577
|
+
break;
|
|
578
|
+
case "U":
|
|
579
|
+
m += 9;
|
|
580
|
+
break;
|
|
581
|
+
default:
|
|
582
|
+
m += 1;
|
|
583
|
+
}
|
|
584
|
+
g = m;
|
|
585
|
+
}
|
|
586
|
+
if ("\n" === s) n === W && (m = H(e, m, t.length)), (d = m + t.length + c), (f = void 0);
|
|
587
|
+
else {
|
|
588
|
+
if (" " === s && h && " " !== h && "\n" !== h && "\t" !== h) {
|
|
589
|
+
const t = e[m + 1];
|
|
590
|
+
t && " " !== t && "\n" !== t && "\t" !== t && (f = m);
|
|
591
|
+
}
|
|
592
|
+
if (m >= d)
|
|
593
|
+
if (f) l.push(f), (d = f + c), (f = void 0);
|
|
594
|
+
else if (n === G) {
|
|
595
|
+
for (; " " === h || "\t" === h;) (h = s), (s = e[(m += 1)]), (p = !0);
|
|
596
|
+
const t = m > g + 1 ? m - 2 : y - 1;
|
|
597
|
+
if (u[t]) return e;
|
|
598
|
+
l.push(t), (u[t] = !0), (d = t + c), (f = void 0);
|
|
599
|
+
} else p = !0;
|
|
600
|
+
}
|
|
601
|
+
h = s;
|
|
602
|
+
}
|
|
603
|
+
if ((p && a && a(), 0 === l.length)) return e;
|
|
604
|
+
r && r();
|
|
605
|
+
let b = e.slice(0, l[0]);
|
|
606
|
+
for (let s = 0; s < l.length; ++s) {
|
|
607
|
+
const i = l[s],
|
|
608
|
+
o = l[s + 1] || e.length;
|
|
609
|
+
0 === i
|
|
610
|
+
? (b = `\n${t}${e.slice(0, o)}`)
|
|
611
|
+
: (n === G && u[i] && (b += `${e[i]}\\`), (b += `\n${t}${e.slice(i + 1, o)}`));
|
|
612
|
+
}
|
|
613
|
+
return b;
|
|
614
|
+
}
|
|
615
|
+
function H(e, t, n) {
|
|
616
|
+
let s = t,
|
|
617
|
+
i = t + 1,
|
|
618
|
+
o = e[i];
|
|
619
|
+
for (; " " === o || "\t" === o;)
|
|
620
|
+
if (t < i + n) o = e[++t];
|
|
621
|
+
else {
|
|
622
|
+
do {
|
|
623
|
+
o = e[++t];
|
|
624
|
+
} while (o && "\n" !== o);
|
|
625
|
+
(s = t), (i = t + 1), (o = e[i]);
|
|
626
|
+
}
|
|
627
|
+
return s;
|
|
628
|
+
}
|
|
629
|
+
const X = (e, t) => ({
|
|
630
|
+
indentAtStart: t ? e.indent.length : e.indentAtStart,
|
|
631
|
+
lineWidth: e.options.lineWidth,
|
|
632
|
+
minContentWidth: e.options.minContentWidth,
|
|
633
|
+
}),
|
|
634
|
+
z = (e) => /^(%|---|\.\.\.)/m.test(e);
|
|
635
|
+
function Z(e, t) {
|
|
636
|
+
const n = JSON.stringify(e);
|
|
637
|
+
if (t.options.doubleQuotedAsJSON) return n;
|
|
638
|
+
const { implicitKey: s } = t,
|
|
639
|
+
i = t.options.doubleQuotedMinMultiLineLength,
|
|
640
|
+
o = t.indent || (z(e) ? " " : "");
|
|
641
|
+
let r = "",
|
|
642
|
+
a = 0;
|
|
643
|
+
for (let e = 0, t = n[e]; t; t = n[++e])
|
|
644
|
+
if (
|
|
645
|
+
(" " === t &&
|
|
646
|
+
"\\" === n[e + 1] &&
|
|
647
|
+
"n" === n[e + 2] &&
|
|
648
|
+
((r += n.slice(a, e) + "\\ "), (e += 1), (a = e), (t = "\\")),
|
|
649
|
+
"\\" === t)
|
|
650
|
+
)
|
|
651
|
+
switch (n[e + 1]) {
|
|
652
|
+
case "u":
|
|
653
|
+
{
|
|
654
|
+
r += n.slice(a, e);
|
|
655
|
+
const t = n.substr(e + 2, 4);
|
|
656
|
+
switch (t) {
|
|
657
|
+
case "0000":
|
|
658
|
+
r += "\\0";
|
|
659
|
+
break;
|
|
660
|
+
case "0007":
|
|
661
|
+
r += "\\a";
|
|
662
|
+
break;
|
|
663
|
+
case "000b":
|
|
664
|
+
r += "\\v";
|
|
665
|
+
break;
|
|
666
|
+
case "001b":
|
|
667
|
+
r += "\\e";
|
|
668
|
+
break;
|
|
669
|
+
case "0085":
|
|
670
|
+
r += "\\N";
|
|
671
|
+
break;
|
|
672
|
+
case "00a0":
|
|
673
|
+
r += "\\_";
|
|
674
|
+
break;
|
|
675
|
+
case "2028":
|
|
676
|
+
r += "\\L";
|
|
677
|
+
break;
|
|
678
|
+
case "2029":
|
|
679
|
+
r += "\\P";
|
|
680
|
+
break;
|
|
681
|
+
default:
|
|
682
|
+
"00" === t.substr(0, 2) ? (r += "\\x" + t.substr(2)) : (r += n.substr(e, 6));
|
|
683
|
+
}
|
|
684
|
+
(e += 5), (a = e + 1);
|
|
685
|
+
}
|
|
686
|
+
break;
|
|
687
|
+
case "n":
|
|
688
|
+
if (s || '"' === n[e + 2] || n.length < i) e += 1;
|
|
689
|
+
else {
|
|
690
|
+
for (r += n.slice(a, e) + "\n\n"; "\\" === n[e + 2] && "n" === n[e + 3] && '"' !== n[e + 4];)
|
|
691
|
+
(r += "\n"), (e += 2);
|
|
692
|
+
(r += o), " " === n[e + 2] && (r += "\\"), (e += 1), (a = e + 1);
|
|
693
|
+
}
|
|
694
|
+
break;
|
|
695
|
+
default:
|
|
696
|
+
e += 1;
|
|
697
|
+
}
|
|
698
|
+
return (r = a ? r + n.slice(a) : n), s ? r : Q(r, o, G, X(t, !1));
|
|
699
|
+
}
|
|
700
|
+
function ee(e, t) {
|
|
701
|
+
if (!1 === t.options.singleQuote || (t.implicitKey && e.includes("\n")) || /[ \t]\n|\n[ \t]/.test(e))
|
|
702
|
+
return Z(e, t);
|
|
703
|
+
const n = t.indent || (z(e) ? " " : ""),
|
|
704
|
+
s = "'" + e.replace(/'/g, "''").replace(/\n+/g, `$&\n${n}`) + "'";
|
|
705
|
+
return t.implicitKey ? s : Q(s, n, Y, X(t, !1));
|
|
706
|
+
}
|
|
707
|
+
function te(e, t) {
|
|
708
|
+
const { singleQuote: n } = t.options;
|
|
709
|
+
let s;
|
|
710
|
+
if (!1 === n) s = Z;
|
|
711
|
+
else {
|
|
712
|
+
const t = e.includes('"'),
|
|
713
|
+
i = e.includes("'");
|
|
714
|
+
s = t && !i ? ee : i && !t ? Z : n ? ee : Z;
|
|
715
|
+
}
|
|
716
|
+
return s(e, t);
|
|
717
|
+
}
|
|
718
|
+
let ne;
|
|
719
|
+
try {
|
|
720
|
+
ne = new RegExp("(^|(?<!\n))\n+(?!\n|$)", "g");
|
|
721
|
+
} catch {
|
|
722
|
+
ne = /\n+(?!\n|$)/g;
|
|
723
|
+
}
|
|
724
|
+
function se({ comment: e, type: t, value: n }, s, i, o) {
|
|
725
|
+
const { blockQuote: r, commentString: a, lineWidth: c } = s.options;
|
|
726
|
+
if (!r || /\n[\t ]+$/.test(n) || /^\s*$/.test(n)) return te(n, s);
|
|
727
|
+
const l = s.indent || (s.forceBlockIndent || z(n) ? " " : ""),
|
|
728
|
+
u =
|
|
729
|
+
"literal" === r ||
|
|
730
|
+
("folded" !== r &&
|
|
731
|
+
t !== D.BLOCK_FOLDED &&
|
|
732
|
+
(t === D.BLOCK_LITERAL ||
|
|
733
|
+
!(function (e, t, n) {
|
|
734
|
+
if (!t || t < 0) return !1;
|
|
735
|
+
const s = t - n,
|
|
736
|
+
i = e.length;
|
|
737
|
+
if (i <= s) return !1;
|
|
738
|
+
for (let t = 0, n = 0; t < i; ++t)
|
|
739
|
+
if ("\n" === e[t]) {
|
|
740
|
+
if (t - n > s) return !0;
|
|
741
|
+
if (((n = t + 1), i - n <= s)) return !1;
|
|
742
|
+
}
|
|
743
|
+
return !0;
|
|
744
|
+
})(n, c, l.length)));
|
|
745
|
+
if (!n) return u ? "|\n" : ">\n";
|
|
746
|
+
let f, h;
|
|
747
|
+
for (h = n.length; h > 0; --h) {
|
|
748
|
+
const e = n[h - 1];
|
|
749
|
+
if ("\n" !== e && "\t" !== e && " " !== e) break;
|
|
750
|
+
}
|
|
751
|
+
let d = n.substring(h);
|
|
752
|
+
const p = d.indexOf("\n");
|
|
753
|
+
-1 === p ? (f = "-") : n === d || p !== d.length - 1 ? ((f = "+"), o && o()) : (f = ""),
|
|
754
|
+
d &&
|
|
755
|
+
((n = n.slice(0, -d.length)), "\n" === d[d.length - 1] && (d = d.slice(0, -1)), (d = d.replace(ne, `$&${l}`)));
|
|
756
|
+
let m,
|
|
757
|
+
y = !1,
|
|
758
|
+
g = -1;
|
|
759
|
+
for (m = 0; m < n.length; ++m) {
|
|
760
|
+
const e = n[m];
|
|
761
|
+
if (" " === e) y = !0;
|
|
762
|
+
else {
|
|
763
|
+
if ("\n" !== e) break;
|
|
764
|
+
g = m;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
let b = n.substring(0, g < m ? g + 1 : m);
|
|
768
|
+
b && ((n = n.substring(b.length)), (b = b.replace(/\n+/g, `$&${l}`)));
|
|
769
|
+
let k = (y ? (l ? "2" : "1") : "") + f;
|
|
770
|
+
if ((e && ((k += " " + a(e.replace(/ ?[\r\n]+/g, " "))), i && i()), !u)) {
|
|
771
|
+
const e = n
|
|
772
|
+
.replace(/\n+/g, "\n$&")
|
|
773
|
+
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2")
|
|
774
|
+
.replace(/\n+/g, `$&${l}`);
|
|
775
|
+
let i = !1;
|
|
776
|
+
const o = X(s, !0);
|
|
777
|
+
"folded" !== r &&
|
|
778
|
+
t !== D.BLOCK_FOLDED &&
|
|
779
|
+
(o.onOverflow = () => {
|
|
780
|
+
i = !0;
|
|
781
|
+
});
|
|
782
|
+
const a = Q(`${b}${e}${d}`, l, W, o);
|
|
783
|
+
if (!i) return `>${k}\n${l}${a}`;
|
|
784
|
+
}
|
|
785
|
+
return `|${k}\n${l}${b}${(n = n.replace(/\n+/g, `$&${l}`))}${d}`;
|
|
786
|
+
}
|
|
787
|
+
function ie(e, t, n, s) {
|
|
788
|
+
const { implicitKey: i, inFlow: o } = t,
|
|
789
|
+
r = "string" == typeof e.value ? e : Object.assign({}, e, { value: String(e.value) });
|
|
790
|
+
let { type: a } = e;
|
|
791
|
+
a !== D.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(r.value) && (a = D.QUOTE_DOUBLE);
|
|
792
|
+
const c = (e) => {
|
|
793
|
+
switch (e) {
|
|
794
|
+
case D.BLOCK_FOLDED:
|
|
795
|
+
case D.BLOCK_LITERAL:
|
|
796
|
+
return i || o ? te(r.value, t) : se(r, t, n, s);
|
|
797
|
+
case D.QUOTE_DOUBLE:
|
|
798
|
+
return Z(r.value, t);
|
|
799
|
+
case D.QUOTE_SINGLE:
|
|
800
|
+
return ee(r.value, t);
|
|
801
|
+
case D.PLAIN:
|
|
802
|
+
return (function (e, t, n, s) {
|
|
803
|
+
const { type: i, value: o } = e,
|
|
804
|
+
{ actualString: r, implicitKey: a, indent: c, indentStep: l, inFlow: u } = t;
|
|
805
|
+
if ((a && o.includes("\n")) || (u && /[[\]{},]/.test(o))) return te(o, t);
|
|
806
|
+
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))
|
|
807
|
+
return a || u || !o.includes("\n") ? te(o, t) : se(e, t, n, s);
|
|
808
|
+
if (!a && !u && i !== D.PLAIN && o.includes("\n")) return se(e, t, n, s);
|
|
809
|
+
if (z(o)) {
|
|
810
|
+
if ("" === c) return (t.forceBlockIndent = !0), se(e, t, n, s);
|
|
811
|
+
if (a && c === l) return te(o, t);
|
|
812
|
+
}
|
|
813
|
+
const f = o.replace(/\n+/g, `$&\n${c}`);
|
|
814
|
+
if (r) {
|
|
815
|
+
const e = (e) => e.default && "tag:yaml.org,2002:str" !== e.tag && e.test?.test(f),
|
|
816
|
+
{ compat: n, tags: s } = t.doc.schema;
|
|
817
|
+
if (s.some(e) || n?.some(e)) return te(o, t);
|
|
818
|
+
}
|
|
819
|
+
return a ? f : Q(f, c, Y, X(t, !1));
|
|
820
|
+
})(r, t, n, s);
|
|
821
|
+
default:
|
|
822
|
+
return null;
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
let l = c(a);
|
|
826
|
+
if (null === l) {
|
|
827
|
+
const { defaultKeyType: e, defaultStringType: n } = t.options,
|
|
828
|
+
s = (i && e) || n;
|
|
829
|
+
if (((l = c(s)), null === l)) throw new Error(`Unsupported default string type ${s}`);
|
|
830
|
+
}
|
|
831
|
+
return l;
|
|
832
|
+
}
|
|
833
|
+
function oe(e, t) {
|
|
834
|
+
const n = Object.assign(
|
|
835
|
+
{
|
|
836
|
+
blockQuote: !0,
|
|
837
|
+
commentString: F,
|
|
838
|
+
defaultKeyType: null,
|
|
839
|
+
defaultStringType: "PLAIN",
|
|
840
|
+
directives: null,
|
|
841
|
+
doubleQuotedAsJSON: !1,
|
|
842
|
+
doubleQuotedMinMultiLineLength: 40,
|
|
843
|
+
falseStr: "false",
|
|
844
|
+
flowCollectionPadding: !0,
|
|
845
|
+
indentSeq: !0,
|
|
846
|
+
lineWidth: 80,
|
|
847
|
+
minContentWidth: 20,
|
|
848
|
+
nullStr: "null",
|
|
849
|
+
simpleKeys: !1,
|
|
850
|
+
singleQuote: null,
|
|
851
|
+
trueStr: "true",
|
|
852
|
+
verifyAliasOrder: !0,
|
|
853
|
+
},
|
|
854
|
+
e.schema.toStringOptions,
|
|
855
|
+
t
|
|
856
|
+
);
|
|
857
|
+
let s;
|
|
858
|
+
switch (n.collectionStyle) {
|
|
859
|
+
case "block":
|
|
860
|
+
s = !1;
|
|
861
|
+
break;
|
|
862
|
+
case "flow":
|
|
863
|
+
s = !0;
|
|
864
|
+
break;
|
|
865
|
+
default:
|
|
866
|
+
s = null;
|
|
867
|
+
}
|
|
868
|
+
return {
|
|
869
|
+
anchors: new Set(),
|
|
870
|
+
doc: e,
|
|
871
|
+
flowCollectionPadding: n.flowCollectionPadding ? " " : "",
|
|
872
|
+
indent: "",
|
|
873
|
+
indentStep: "number" == typeof n.indent ? " ".repeat(n.indent) : " ",
|
|
874
|
+
inFlow: s,
|
|
875
|
+
options: n,
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
function re(e, t, n, s) {
|
|
879
|
+
if (f(e)) return e.toString(t, n, s);
|
|
880
|
+
if (c(e)) {
|
|
881
|
+
if (t.doc.directives) return e.toString(t);
|
|
882
|
+
if (t.resolvedAliases?.has(e)) throw new TypeError("Cannot stringify circular structure without alias nodes");
|
|
883
|
+
t.resolvedAliases ? t.resolvedAliases.add(e) : (t.resolvedAliases = new Set([e])), (e = e.resolve(t.doc));
|
|
884
|
+
}
|
|
885
|
+
let i;
|
|
886
|
+
const o = m(e) ? e : t.doc.createNode(e, { onTagObj: (e) => (i = e) });
|
|
887
|
+
i ||
|
|
888
|
+
(i = (function (e, t) {
|
|
889
|
+
if (t.tag) {
|
|
890
|
+
const n = e.filter((e) => e.tag === t.tag);
|
|
891
|
+
if (n.length > 0) return n.find((e) => e.format === t.format) ?? n[0];
|
|
892
|
+
}
|
|
893
|
+
let n, s;
|
|
894
|
+
if (h(t)) {
|
|
895
|
+
s = t.value;
|
|
896
|
+
let i = e.filter((e) => e.identify?.(s));
|
|
897
|
+
if (i.length > 1) {
|
|
898
|
+
const e = i.filter((e) => e.test);
|
|
899
|
+
e.length > 0 && (i = e);
|
|
900
|
+
}
|
|
901
|
+
n = i.find((e) => e.format === t.format) ?? i.find((e) => !e.format);
|
|
902
|
+
} else (s = t), (n = e.find((e) => e.nodeClass && s instanceof e.nodeClass));
|
|
903
|
+
if (!n)
|
|
904
|
+
throw new Error(`Tag not resolved for ${s?.constructor?.name ?? (null === s ? "null" : typeof s)} value`);
|
|
905
|
+
return n;
|
|
906
|
+
})(t.doc.schema.tags, o));
|
|
907
|
+
const r = (function (e, t, { anchors: n, doc: s }) {
|
|
908
|
+
if (!s.directives) return "";
|
|
909
|
+
const i = [],
|
|
910
|
+
o = (h(e) || p(e)) && e.anchor;
|
|
911
|
+
o && L(o) && (n.add(o), i.push(`&${o}`));
|
|
912
|
+
const r = e.tag ? e.tag : t.default ? null : t.tag;
|
|
913
|
+
return r && i.push(s.directives.tagString(r)), i.join(" ");
|
|
914
|
+
})(o, i, t);
|
|
915
|
+
r.length > 0 && (t.indentAtStart = (t.indentAtStart ?? 0) + r.length + 1);
|
|
916
|
+
const a = "function" == typeof i.stringify ? i.stringify(o, t, n, s) : h(o) ? ie(o, t, n, s) : o.toString(t, n, s);
|
|
917
|
+
return r ? (h(o) || "{" === a[0] || "[" === a[0] ? `${r} ${a}` : `${r}\n${t.indent}${a}`) : a;
|
|
918
|
+
}
|
|
919
|
+
function ae(e, t) {
|
|
920
|
+
("debug" !== e && "warn" !== e) || console.warn(t);
|
|
921
|
+
}
|
|
922
|
+
const ce = "<<",
|
|
923
|
+
le = {
|
|
924
|
+
identify: (e) => e === ce || ("symbol" == typeof e && e.description === ce),
|
|
925
|
+
default: "key",
|
|
926
|
+
tag: "tag:yaml.org,2002:merge",
|
|
927
|
+
test: /^<<$/,
|
|
928
|
+
resolve: () => Object.assign(new D(Symbol(ce)), { addToJSMap: ue }),
|
|
929
|
+
stringify: () => ce,
|
|
930
|
+
};
|
|
931
|
+
function ue(e, t, n) {
|
|
932
|
+
if (((n = e && c(n) ? n.resolve(e.doc) : n), d(n))) for (const s of n.items) fe(e, t, s);
|
|
933
|
+
else if (Array.isArray(n)) for (const s of n) fe(e, t, s);
|
|
934
|
+
else fe(e, t, n);
|
|
935
|
+
}
|
|
936
|
+
function fe(e, t, n) {
|
|
937
|
+
const s = e && c(n) ? n.resolve(e.doc) : n;
|
|
938
|
+
if (!u(s)) throw new Error("Merge sources must be maps or map aliases");
|
|
939
|
+
const i = s.toJSON(null, e, Map);
|
|
940
|
+
for (const [e, n] of i)
|
|
941
|
+
t instanceof Map
|
|
942
|
+
? t.has(e) || t.set(e, n)
|
|
943
|
+
: t instanceof Set
|
|
944
|
+
? t.add(e)
|
|
945
|
+
: Object.prototype.hasOwnProperty.call(t, e) ||
|
|
946
|
+
Object.defineProperty(t, e, { value: n, writable: !0, enumerable: !0, configurable: !0 });
|
|
947
|
+
return t;
|
|
948
|
+
}
|
|
949
|
+
function he(e, t, { key: n, value: s }) {
|
|
950
|
+
if (m(n) && n.addToJSMap) n.addToJSMap(e, t, s);
|
|
951
|
+
else if (
|
|
952
|
+
((e, t) =>
|
|
953
|
+
(le.identify(t) || (h(t) && (!t.type || t.type === D.PLAIN) && le.identify(t.value))) &&
|
|
954
|
+
e?.doc.schema.tags.some((e) => e.tag === le.tag && e.default))(e, n)
|
|
955
|
+
)
|
|
956
|
+
ue(e, t, s);
|
|
957
|
+
else {
|
|
958
|
+
const i = _(n, "", e);
|
|
959
|
+
if (t instanceof Map) t.set(i, _(s, i, e));
|
|
960
|
+
else if (t instanceof Set) t.add(i);
|
|
961
|
+
else {
|
|
962
|
+
const o = (function (e, t, n) {
|
|
963
|
+
if (null === t) return "";
|
|
964
|
+
if ("object" != typeof t) return String(t);
|
|
965
|
+
if (m(e) && n?.doc) {
|
|
966
|
+
const t = oe(n.doc, {});
|
|
967
|
+
t.anchors = new Set();
|
|
968
|
+
for (const e of n.anchors.keys()) t.anchors.add(e.anchor);
|
|
969
|
+
(t.inFlow = !0), (t.inStringifyKey = !0);
|
|
970
|
+
const s = e.toString(t);
|
|
971
|
+
if (!n.mapKeyWarned) {
|
|
972
|
+
let e = JSON.stringify(s);
|
|
973
|
+
e.length > 40 && (e = e.substring(0, 36) + '..."'),
|
|
974
|
+
ae(
|
|
975
|
+
n.doc.options.logLevel,
|
|
976
|
+
`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`
|
|
977
|
+
),
|
|
978
|
+
(n.mapKeyWarned = !0);
|
|
979
|
+
}
|
|
980
|
+
return s;
|
|
981
|
+
}
|
|
982
|
+
return JSON.stringify(t);
|
|
983
|
+
})(n, i, e),
|
|
984
|
+
r = _(s, o, e);
|
|
985
|
+
o in t ? Object.defineProperty(t, o, { value: r, writable: !0, enumerable: !0, configurable: !0 }) : (t[o] = r);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
return t;
|
|
989
|
+
}
|
|
990
|
+
function de(e, t, n) {
|
|
991
|
+
const s = q(e, void 0, n),
|
|
992
|
+
i = q(t, void 0, n);
|
|
993
|
+
return new pe(s, i);
|
|
994
|
+
}
|
|
995
|
+
class pe {
|
|
996
|
+
constructor(e, t = null) {
|
|
997
|
+
Object.defineProperty(this, a, { value: i }), (this.key = e), (this.value = t);
|
|
998
|
+
}
|
|
999
|
+
clone(e) {
|
|
1000
|
+
let { key: t, value: n } = this;
|
|
1001
|
+
return m(t) && (t = t.clone(e)), m(n) && (n = n.clone(e)), new pe(t, n);
|
|
1002
|
+
}
|
|
1003
|
+
toJSON(e, t) {
|
|
1004
|
+
return he(t, t?.mapAsMap ? new Map() : {}, this);
|
|
1005
|
+
}
|
|
1006
|
+
toString(e, t, n) {
|
|
1007
|
+
return e?.doc
|
|
1008
|
+
? (function ({ key: e, value: t }, n, s, i) {
|
|
1009
|
+
const {
|
|
1010
|
+
allNullValues: o,
|
|
1011
|
+
doc: r,
|
|
1012
|
+
indent: a,
|
|
1013
|
+
indentStep: c,
|
|
1014
|
+
options: { commentString: l, indentSeq: u, simpleKeys: f },
|
|
1015
|
+
} = n;
|
|
1016
|
+
let y = (m(e) && e.comment) || null;
|
|
1017
|
+
if (f) {
|
|
1018
|
+
if (y) throw new Error("With simple keys, key nodes cannot have comments");
|
|
1019
|
+
if (p(e) || (!m(e) && "object" == typeof e))
|
|
1020
|
+
throw new Error("With simple keys, collection cannot be used as a key value");
|
|
1021
|
+
}
|
|
1022
|
+
let g =
|
|
1023
|
+
!f &&
|
|
1024
|
+
(!e ||
|
|
1025
|
+
(y && null == t && !n.inFlow) ||
|
|
1026
|
+
p(e) ||
|
|
1027
|
+
(h(e) ? e.type === D.BLOCK_FOLDED || e.type === D.BLOCK_LITERAL : "object" == typeof e));
|
|
1028
|
+
n = Object.assign({}, n, { allNullValues: !1, implicitKey: !g && (f || !o), indent: a + c });
|
|
1029
|
+
let b,
|
|
1030
|
+
k,
|
|
1031
|
+
w,
|
|
1032
|
+
v = !1,
|
|
1033
|
+
S = !1,
|
|
1034
|
+
E = re(
|
|
1035
|
+
e,
|
|
1036
|
+
n,
|
|
1037
|
+
() => (v = !0),
|
|
1038
|
+
() => (S = !0)
|
|
1039
|
+
);
|
|
1040
|
+
if (!g && !n.inFlow && E.length > 1024) {
|
|
1041
|
+
if (f) throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
1042
|
+
g = !0;
|
|
1043
|
+
}
|
|
1044
|
+
if (n.inFlow) {
|
|
1045
|
+
if (o || null == t) return v && s && s(), "" === E ? "?" : g ? `? ${E}` : E;
|
|
1046
|
+
} else if ((o && !f) || (null == t && g))
|
|
1047
|
+
return (E = `? ${E}`), y && !v ? (E += J(E, n.indent, l(y))) : S && i && i(), E;
|
|
1048
|
+
v && (y = null),
|
|
1049
|
+
g
|
|
1050
|
+
? (y && (E += J(E, n.indent, l(y))), (E = `? ${E}\n${a}:`))
|
|
1051
|
+
: ((E = `${E}:`), y && (E += J(E, n.indent, l(y)))),
|
|
1052
|
+
m(t)
|
|
1053
|
+
? ((b = !!t.spaceBefore), (k = t.commentBefore), (w = t.comment))
|
|
1054
|
+
: ((b = !1), (k = null), (w = null), t && "object" == typeof t && (t = r.createNode(t))),
|
|
1055
|
+
(n.implicitKey = !1),
|
|
1056
|
+
g || y || !h(t) || (n.indentAtStart = E.length + 1),
|
|
1057
|
+
(S = !1),
|
|
1058
|
+
u ||
|
|
1059
|
+
!(c.length >= 2) ||
|
|
1060
|
+
n.inFlow ||
|
|
1061
|
+
g ||
|
|
1062
|
+
!d(t) ||
|
|
1063
|
+
t.flow ||
|
|
1064
|
+
t.tag ||
|
|
1065
|
+
t.anchor ||
|
|
1066
|
+
(n.indent = n.indent.substring(2));
|
|
1067
|
+
let N = !1;
|
|
1068
|
+
const O = re(
|
|
1069
|
+
t,
|
|
1070
|
+
n,
|
|
1071
|
+
() => (N = !0),
|
|
1072
|
+
() => (S = !0)
|
|
1073
|
+
);
|
|
1074
|
+
let A = " ";
|
|
1075
|
+
if (y || b || k)
|
|
1076
|
+
(A = b ? "\n" : ""),
|
|
1077
|
+
k && (A += `\n${V(l(k), n.indent)}`),
|
|
1078
|
+
"" !== O || n.inFlow ? (A += `\n${n.indent}`) : "\n" === A && (A = "\n\n");
|
|
1079
|
+
else if (!g && p(t)) {
|
|
1080
|
+
const e = O[0],
|
|
1081
|
+
s = O.indexOf("\n"),
|
|
1082
|
+
i = -1 !== s,
|
|
1083
|
+
o = n.inFlow ?? t.flow ?? 0 === t.items.length;
|
|
1084
|
+
if (i || !o) {
|
|
1085
|
+
let t = !1;
|
|
1086
|
+
if (i && ("&" === e || "!" === e)) {
|
|
1087
|
+
let n = O.indexOf(" ");
|
|
1088
|
+
"&" === e && -1 !== n && n < s && "!" === O[n + 1] && (n = O.indexOf(" ", n + 1)),
|
|
1089
|
+
(-1 === n || s < n) && (t = !0);
|
|
1090
|
+
}
|
|
1091
|
+
t || (A = `\n${n.indent}`);
|
|
1092
|
+
}
|
|
1093
|
+
} else ("" !== O && "\n" !== O[0]) || (A = "");
|
|
1094
|
+
return (E += A + O), n.inFlow ? N && s && s() : w && !N ? (E += J(E, n.indent, l(w))) : S && i && i(), E;
|
|
1095
|
+
})(this, e, t, n)
|
|
1096
|
+
: JSON.stringify(this);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function me(e, t, n) {
|
|
1100
|
+
return (t.inFlow ?? e.flow ? ge : ye)(e, t, n);
|
|
1101
|
+
}
|
|
1102
|
+
function ye(
|
|
1103
|
+
{ comment: e, items: t },
|
|
1104
|
+
n,
|
|
1105
|
+
{ blockItemPrefix: s, flowChars: i, itemIndent: o, onChompKeep: r, onComment: a }
|
|
1106
|
+
) {
|
|
1107
|
+
const {
|
|
1108
|
+
indent: c,
|
|
1109
|
+
options: { commentString: l },
|
|
1110
|
+
} = n,
|
|
1111
|
+
u = Object.assign({}, n, { indent: o, type: null });
|
|
1112
|
+
let h = !1;
|
|
1113
|
+
const d = [];
|
|
1114
|
+
for (let e = 0; e < t.length; ++e) {
|
|
1115
|
+
const i = t[e];
|
|
1116
|
+
let r = null;
|
|
1117
|
+
if (m(i)) !h && i.spaceBefore && d.push(""), be(n, d, i.commentBefore, h), i.comment && (r = i.comment);
|
|
1118
|
+
else if (f(i)) {
|
|
1119
|
+
const e = m(i.key) ? i.key : null;
|
|
1120
|
+
e && (!h && e.spaceBefore && d.push(""), be(n, d, e.commentBefore, h));
|
|
1121
|
+
}
|
|
1122
|
+
h = !1;
|
|
1123
|
+
let a = re(
|
|
1124
|
+
i,
|
|
1125
|
+
u,
|
|
1126
|
+
() => (r = null),
|
|
1127
|
+
() => (h = !0)
|
|
1128
|
+
);
|
|
1129
|
+
r && (a += J(a, o, l(r))), h && r && (h = !1), d.push(s + a);
|
|
1130
|
+
}
|
|
1131
|
+
let p;
|
|
1132
|
+
if (0 === d.length) p = i.start + i.end;
|
|
1133
|
+
else {
|
|
1134
|
+
p = d[0];
|
|
1135
|
+
for (let e = 1; e < d.length; ++e) {
|
|
1136
|
+
const t = d[e];
|
|
1137
|
+
p += t ? `\n${c}${t}` : "\n";
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
return e ? ((p += "\n" + V(l(e), c)), a && a()) : h && r && r(), p;
|
|
1141
|
+
}
|
|
1142
|
+
function ge({ items: e }, t, { flowChars: n, itemIndent: s }) {
|
|
1143
|
+
const {
|
|
1144
|
+
indent: i,
|
|
1145
|
+
indentStep: o,
|
|
1146
|
+
flowCollectionPadding: r,
|
|
1147
|
+
options: { commentString: a },
|
|
1148
|
+
} = t;
|
|
1149
|
+
s += o;
|
|
1150
|
+
const c = Object.assign({}, t, { indent: s, inFlow: !0, type: null });
|
|
1151
|
+
let l = !1,
|
|
1152
|
+
u = 0;
|
|
1153
|
+
const h = [];
|
|
1154
|
+
for (let n = 0; n < e.length; ++n) {
|
|
1155
|
+
const i = e[n];
|
|
1156
|
+
let o = null;
|
|
1157
|
+
if (m(i)) i.spaceBefore && h.push(""), be(t, h, i.commentBefore, !1), i.comment && (o = i.comment);
|
|
1158
|
+
else if (f(i)) {
|
|
1159
|
+
const e = m(i.key) ? i.key : null;
|
|
1160
|
+
e && (e.spaceBefore && h.push(""), be(t, h, e.commentBefore, !1), e.comment && (l = !0));
|
|
1161
|
+
const n = m(i.value) ? i.value : null;
|
|
1162
|
+
n
|
|
1163
|
+
? (n.comment && (o = n.comment), n.commentBefore && (l = !0))
|
|
1164
|
+
: null == i.value && e?.comment && (o = e.comment);
|
|
1165
|
+
}
|
|
1166
|
+
o && (l = !0);
|
|
1167
|
+
let r = re(i, c, () => (o = null));
|
|
1168
|
+
n < e.length - 1 && (r += ","),
|
|
1169
|
+
o && (r += J(r, s, a(o))),
|
|
1170
|
+
!l && (h.length > u || r.includes("\n")) && (l = !0),
|
|
1171
|
+
h.push(r),
|
|
1172
|
+
(u = h.length);
|
|
1173
|
+
}
|
|
1174
|
+
const { start: d, end: p } = n;
|
|
1175
|
+
if (0 === h.length) return d + p;
|
|
1176
|
+
if (!l) {
|
|
1177
|
+
const e = h.reduce((e, t) => e + t.length + 2, 2);
|
|
1178
|
+
l = t.options.lineWidth > 0 && e > t.options.lineWidth;
|
|
1179
|
+
}
|
|
1180
|
+
if (l) {
|
|
1181
|
+
let e = d;
|
|
1182
|
+
for (const t of h) e += t ? `\n${o}${i}${t}` : "\n";
|
|
1183
|
+
return `${e}\n${i}${p}`;
|
|
1184
|
+
}
|
|
1185
|
+
return `${d}${r}${h.join(" ")}${r}${p}`;
|
|
1186
|
+
}
|
|
1187
|
+
function be({ indent: e, options: { commentString: t } }, n, s, i) {
|
|
1188
|
+
if ((s && i && (s = s.replace(/^\n+/, "")), s)) {
|
|
1189
|
+
const i = V(t(s), e);
|
|
1190
|
+
n.push(i.trimStart());
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
function ke(e, t) {
|
|
1194
|
+
const n = h(t) ? t.value : t;
|
|
1195
|
+
for (const s of e)
|
|
1196
|
+
if (f(s)) {
|
|
1197
|
+
if (s.key === t || s.key === n) return s;
|
|
1198
|
+
if (h(s.key) && s.key.value === n) return s;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
class we extends R {
|
|
1202
|
+
static get tagName() {
|
|
1203
|
+
return "tag:yaml.org,2002:map";
|
|
1204
|
+
}
|
|
1205
|
+
constructor(e) {
|
|
1206
|
+
super(s, e), (this.items = []);
|
|
1207
|
+
}
|
|
1208
|
+
static from(e, t, n) {
|
|
1209
|
+
const { keepUndefined: s, replacer: i } = n,
|
|
1210
|
+
o = new this(e),
|
|
1211
|
+
r = (e, r) => {
|
|
1212
|
+
if ("function" == typeof i) r = i.call(t, e, r);
|
|
1213
|
+
else if (Array.isArray(i) && !i.includes(e)) return;
|
|
1214
|
+
(void 0 !== r || s) && o.items.push(de(e, r, n));
|
|
1215
|
+
};
|
|
1216
|
+
if (t instanceof Map) for (const [e, n] of t) r(e, n);
|
|
1217
|
+
else if (t && "object" == typeof t) for (const e of Object.keys(t)) r(e, t[e]);
|
|
1218
|
+
return "function" == typeof e.sortMapEntries && o.items.sort(e.sortMapEntries), o;
|
|
1219
|
+
}
|
|
1220
|
+
add(e, t) {
|
|
1221
|
+
let n;
|
|
1222
|
+
n = f(e) ? e : e && "object" == typeof e && "key" in e ? new pe(e.key, e.value) : new pe(e, e?.value);
|
|
1223
|
+
const s = ke(this.items, n.key),
|
|
1224
|
+
i = this.schema?.sortMapEntries;
|
|
1225
|
+
if (s) {
|
|
1226
|
+
if (!t) throw new Error(`Key ${n.key} already set`);
|
|
1227
|
+
h(s.value) && M(n.value) ? (s.value.value = n.value) : (s.value = n.value);
|
|
1228
|
+
} else if (i) {
|
|
1229
|
+
const e = this.items.findIndex((e) => i(n, e) < 0);
|
|
1230
|
+
-1 === e ? this.items.push(n) : this.items.splice(e, 0, n);
|
|
1231
|
+
} else this.items.push(n);
|
|
1232
|
+
}
|
|
1233
|
+
delete(e) {
|
|
1234
|
+
const t = ke(this.items, e);
|
|
1235
|
+
if (!t) return !1;
|
|
1236
|
+
return this.items.splice(this.items.indexOf(t), 1).length > 0;
|
|
1237
|
+
}
|
|
1238
|
+
get(e, t) {
|
|
1239
|
+
const n = ke(this.items, e),
|
|
1240
|
+
s = n?.value;
|
|
1241
|
+
return (!t && h(s) ? s.value : s) ?? void 0;
|
|
1242
|
+
}
|
|
1243
|
+
has(e) {
|
|
1244
|
+
return !!ke(this.items, e);
|
|
1245
|
+
}
|
|
1246
|
+
set(e, t) {
|
|
1247
|
+
this.add(new pe(e, t), !0);
|
|
1248
|
+
}
|
|
1249
|
+
toJSON(e, t, n) {
|
|
1250
|
+
const s = n ? new n() : t?.mapAsMap ? new Map() : {};
|
|
1251
|
+
t?.onCreate && t.onCreate(s);
|
|
1252
|
+
for (const e of this.items) he(t, s, e);
|
|
1253
|
+
return s;
|
|
1254
|
+
}
|
|
1255
|
+
toString(e, t, n) {
|
|
1256
|
+
if (!e) return JSON.stringify(this);
|
|
1257
|
+
for (const e of this.items)
|
|
1258
|
+
if (!f(e)) throw new Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);
|
|
1259
|
+
return (
|
|
1260
|
+
!e.allNullValues && this.hasAllNullValues(!1) && (e = Object.assign({}, e, { allNullValues: !0 })),
|
|
1261
|
+
me(this, e, {
|
|
1262
|
+
blockItemPrefix: "",
|
|
1263
|
+
flowChars: { start: "{", end: "}" },
|
|
1264
|
+
itemIndent: e.indent || "",
|
|
1265
|
+
onChompKeep: n,
|
|
1266
|
+
onComment: t,
|
|
1267
|
+
})
|
|
1268
|
+
);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
const ve = {
|
|
1272
|
+
collection: "map",
|
|
1273
|
+
default: !0,
|
|
1274
|
+
nodeClass: we,
|
|
1275
|
+
tag: "tag:yaml.org,2002:map",
|
|
1276
|
+
resolve: (e, t) => (u(e) || t("Expected a mapping for this tag"), e),
|
|
1277
|
+
createNode: (e, t, n) => we.from(e, t, n),
|
|
1278
|
+
};
|
|
1279
|
+
class Se extends R {
|
|
1280
|
+
static get tagName() {
|
|
1281
|
+
return "tag:yaml.org,2002:seq";
|
|
1282
|
+
}
|
|
1283
|
+
constructor(e) {
|
|
1284
|
+
super(r, e), (this.items = []);
|
|
1285
|
+
}
|
|
1286
|
+
add(e) {
|
|
1287
|
+
this.items.push(e);
|
|
1288
|
+
}
|
|
1289
|
+
delete(e) {
|
|
1290
|
+
const t = Ee(e);
|
|
1291
|
+
if ("number" != typeof t) return !1;
|
|
1292
|
+
return this.items.splice(t, 1).length > 0;
|
|
1293
|
+
}
|
|
1294
|
+
get(e, t) {
|
|
1295
|
+
const n = Ee(e);
|
|
1296
|
+
if ("number" != typeof n) return;
|
|
1297
|
+
const s = this.items[n];
|
|
1298
|
+
return !t && h(s) ? s.value : s;
|
|
1299
|
+
}
|
|
1300
|
+
has(e) {
|
|
1301
|
+
const t = Ee(e);
|
|
1302
|
+
return "number" == typeof t && t < this.items.length;
|
|
1303
|
+
}
|
|
1304
|
+
set(e, t) {
|
|
1305
|
+
const n = Ee(e);
|
|
1306
|
+
if ("number" != typeof n) throw new Error(`Expected a valid index, not ${e}.`);
|
|
1307
|
+
const s = this.items[n];
|
|
1308
|
+
h(s) && M(t) ? (s.value = t) : (this.items[n] = t);
|
|
1309
|
+
}
|
|
1310
|
+
toJSON(e, t) {
|
|
1311
|
+
const n = [];
|
|
1312
|
+
t?.onCreate && t.onCreate(n);
|
|
1313
|
+
let s = 0;
|
|
1314
|
+
for (const e of this.items) n.push(_(e, String(s++), t));
|
|
1315
|
+
return n;
|
|
1316
|
+
}
|
|
1317
|
+
toString(e, t, n) {
|
|
1318
|
+
return e
|
|
1319
|
+
? me(this, e, {
|
|
1320
|
+
blockItemPrefix: "- ",
|
|
1321
|
+
flowChars: { start: "[", end: "]" },
|
|
1322
|
+
itemIndent: (e.indent || "") + " ",
|
|
1323
|
+
onChompKeep: n,
|
|
1324
|
+
onComment: t,
|
|
1325
|
+
})
|
|
1326
|
+
: JSON.stringify(this);
|
|
1327
|
+
}
|
|
1328
|
+
static from(e, t, n) {
|
|
1329
|
+
const { replacer: s } = n,
|
|
1330
|
+
i = new this(e);
|
|
1331
|
+
if (t && Symbol.iterator in Object(t)) {
|
|
1332
|
+
let e = 0;
|
|
1333
|
+
for (let o of t) {
|
|
1334
|
+
if ("function" == typeof s) {
|
|
1335
|
+
const n = t instanceof Set ? o : String(e++);
|
|
1336
|
+
o = s.call(t, n, o);
|
|
1337
|
+
}
|
|
1338
|
+
i.items.push(q(o, void 0, n));
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
return i;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
function Ee(e) {
|
|
1345
|
+
let t = h(e) ? e.value : e;
|
|
1346
|
+
return (
|
|
1347
|
+
t && "string" == typeof t && (t = Number(t)), "number" == typeof t && Number.isInteger(t) && t >= 0 ? t : null
|
|
1348
|
+
);
|
|
1349
|
+
}
|
|
1350
|
+
const Ne = {
|
|
1351
|
+
collection: "seq",
|
|
1352
|
+
default: !0,
|
|
1353
|
+
nodeClass: Se,
|
|
1354
|
+
tag: "tag:yaml.org,2002:seq",
|
|
1355
|
+
resolve: (e, t) => (d(e) || t("Expected a sequence for this tag"), e),
|
|
1356
|
+
createNode: (e, t, n) => Se.from(e, t, n),
|
|
1357
|
+
},
|
|
1358
|
+
Oe = {
|
|
1359
|
+
identify: (e) => "string" == typeof e,
|
|
1360
|
+
default: !0,
|
|
1361
|
+
tag: "tag:yaml.org,2002:str",
|
|
1362
|
+
resolve: (e) => e,
|
|
1363
|
+
stringify: (e, t, n, s) => ie(e, (t = Object.assign({ actualString: !0 }, t)), n, s),
|
|
1364
|
+
},
|
|
1365
|
+
Ae = {
|
|
1366
|
+
identify: (e) => null == e,
|
|
1367
|
+
createNode: () => new D(null),
|
|
1368
|
+
default: !0,
|
|
1369
|
+
tag: "tag:yaml.org,2002:null",
|
|
1370
|
+
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
1371
|
+
resolve: () => new D(null),
|
|
1372
|
+
stringify: ({ source: e }, t) => ("string" == typeof e && Ae.test.test(e) ? e : t.options.nullStr),
|
|
1373
|
+
},
|
|
1374
|
+
Ie = {
|
|
1375
|
+
identify: (e) => "boolean" == typeof e,
|
|
1376
|
+
default: !0,
|
|
1377
|
+
tag: "tag:yaml.org,2002:bool",
|
|
1378
|
+
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
1379
|
+
resolve: (e) => new D("t" === e[0] || "T" === e[0]),
|
|
1380
|
+
stringify({ source: e, value: t }, n) {
|
|
1381
|
+
if (e && Ie.test.test(e)) {
|
|
1382
|
+
if (t === ("t" === e[0] || "T" === e[0])) return e;
|
|
1383
|
+
}
|
|
1384
|
+
return t ? n.options.trueStr : n.options.falseStr;
|
|
1385
|
+
},
|
|
1386
|
+
};
|
|
1387
|
+
function Te({ format: e, minFractionDigits: t, tag: n, value: s }) {
|
|
1388
|
+
if ("bigint" == typeof s) return String(s);
|
|
1389
|
+
const i = "number" == typeof s ? s : Number(s);
|
|
1390
|
+
if (!isFinite(i)) return isNaN(i) ? ".nan" : i < 0 ? "-.inf" : ".inf";
|
|
1391
|
+
let o = JSON.stringify(s);
|
|
1392
|
+
if (!e && t && (!n || "tag:yaml.org,2002:float" === n) && /^\d/.test(o)) {
|
|
1393
|
+
let e = o.indexOf(".");
|
|
1394
|
+
e < 0 && ((e = o.length), (o += "."));
|
|
1395
|
+
let n = t - (o.length - e - 1);
|
|
1396
|
+
for (; n-- > 0;) o += "0";
|
|
1397
|
+
}
|
|
1398
|
+
return o;
|
|
1399
|
+
}
|
|
1400
|
+
const Le = {
|
|
1401
|
+
identify: (e) => "number" == typeof e,
|
|
1402
|
+
default: !0,
|
|
1403
|
+
tag: "tag:yaml.org,2002:float",
|
|
1404
|
+
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
1405
|
+
resolve: (e) =>
|
|
1406
|
+
"nan" === e.slice(-3).toLowerCase() ? NaN : "-" === e[0] ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
1407
|
+
stringify: Te,
|
|
1408
|
+
},
|
|
1409
|
+
xe = {
|
|
1410
|
+
identify: (e) => "number" == typeof e,
|
|
1411
|
+
default: !0,
|
|
1412
|
+
tag: "tag:yaml.org,2002:float",
|
|
1413
|
+
format: "EXP",
|
|
1414
|
+
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
1415
|
+
resolve: (e) => parseFloat(e),
|
|
1416
|
+
stringify(e) {
|
|
1417
|
+
const t = Number(e.value);
|
|
1418
|
+
return isFinite(t) ? t.toExponential() : Te(e);
|
|
1419
|
+
},
|
|
1420
|
+
},
|
|
1421
|
+
$e = {
|
|
1422
|
+
identify: (e) => "number" == typeof e,
|
|
1423
|
+
default: !0,
|
|
1424
|
+
tag: "tag:yaml.org,2002:float",
|
|
1425
|
+
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
1426
|
+
resolve(e) {
|
|
1427
|
+
const t = new D(parseFloat(e)),
|
|
1428
|
+
n = e.indexOf(".");
|
|
1429
|
+
return -1 !== n && "0" === e[e.length - 1] && (t.minFractionDigits = e.length - n - 1), t;
|
|
1430
|
+
},
|
|
1431
|
+
stringify: Te,
|
|
1432
|
+
},
|
|
1433
|
+
Ce = (e) => "bigint" == typeof e || Number.isInteger(e),
|
|
1434
|
+
_e = (e, t, n, { intAsBigInt: s }) => (s ? BigInt(e) : parseInt(e.substring(t), n));
|
|
1435
|
+
function Ke(e, t, n) {
|
|
1436
|
+
const { value: s } = e;
|
|
1437
|
+
return Ce(s) && s >= 0 ? n + s.toString(t) : Te(e);
|
|
1438
|
+
}
|
|
1439
|
+
const Be = {
|
|
1440
|
+
identify: (e) => Ce(e) && e >= 0,
|
|
1441
|
+
default: !0,
|
|
1442
|
+
tag: "tag:yaml.org,2002:int",
|
|
1443
|
+
format: "OCT",
|
|
1444
|
+
test: /^0o[0-7]+$/,
|
|
1445
|
+
resolve: (e, t, n) => _e(e, 2, 8, n),
|
|
1446
|
+
stringify: (e) => Ke(e, 8, "0o"),
|
|
1447
|
+
},
|
|
1448
|
+
je = {
|
|
1449
|
+
identify: Ce,
|
|
1450
|
+
default: !0,
|
|
1451
|
+
tag: "tag:yaml.org,2002:int",
|
|
1452
|
+
test: /^[-+]?[0-9]+$/,
|
|
1453
|
+
resolve: (e, t, n) => _e(e, 0, 10, n),
|
|
1454
|
+
stringify: Te,
|
|
1455
|
+
},
|
|
1456
|
+
Me = {
|
|
1457
|
+
identify: (e) => Ce(e) && e >= 0,
|
|
1458
|
+
default: !0,
|
|
1459
|
+
tag: "tag:yaml.org,2002:int",
|
|
1460
|
+
format: "HEX",
|
|
1461
|
+
test: /^0x[0-9a-fA-F]+$/,
|
|
1462
|
+
resolve: (e, t, n) => _e(e, 2, 16, n),
|
|
1463
|
+
stringify: (e) => Ke(e, 16, "0x"),
|
|
1464
|
+
},
|
|
1465
|
+
De = [ve, Ne, Oe, Ae, Ie, Be, je, Me, Le, xe, $e];
|
|
1466
|
+
function qe(e) {
|
|
1467
|
+
return "bigint" == typeof e || Number.isInteger(e);
|
|
1468
|
+
}
|
|
1469
|
+
const Pe = ({ value: e }) => JSON.stringify(e),
|
|
1470
|
+
Ue = [ve, Ne].concat(
|
|
1471
|
+
[
|
|
1472
|
+
{
|
|
1473
|
+
identify: (e) => "string" == typeof e,
|
|
1474
|
+
default: !0,
|
|
1475
|
+
tag: "tag:yaml.org,2002:str",
|
|
1476
|
+
resolve: (e) => e,
|
|
1477
|
+
stringify: Pe,
|
|
1478
|
+
},
|
|
1479
|
+
{
|
|
1480
|
+
identify: (e) => null == e,
|
|
1481
|
+
createNode: () => new D(null),
|
|
1482
|
+
default: !0,
|
|
1483
|
+
tag: "tag:yaml.org,2002:null",
|
|
1484
|
+
test: /^null$/,
|
|
1485
|
+
resolve: () => null,
|
|
1486
|
+
stringify: Pe,
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
identify: (e) => "boolean" == typeof e,
|
|
1490
|
+
default: !0,
|
|
1491
|
+
tag: "tag:yaml.org,2002:bool",
|
|
1492
|
+
test: /^true$|^false$/,
|
|
1493
|
+
resolve: (e) => "true" === e,
|
|
1494
|
+
stringify: Pe,
|
|
1495
|
+
},
|
|
1496
|
+
{
|
|
1497
|
+
identify: qe,
|
|
1498
|
+
default: !0,
|
|
1499
|
+
tag: "tag:yaml.org,2002:int",
|
|
1500
|
+
test: /^-?(?:0|[1-9][0-9]*)$/,
|
|
1501
|
+
resolve: (e, t, { intAsBigInt: n }) => (n ? BigInt(e) : parseInt(e, 10)),
|
|
1502
|
+
stringify: ({ value: e }) => (qe(e) ? e.toString() : JSON.stringify(e)),
|
|
1503
|
+
},
|
|
1504
|
+
{
|
|
1505
|
+
identify: (e) => "number" == typeof e,
|
|
1506
|
+
default: !0,
|
|
1507
|
+
tag: "tag:yaml.org,2002:float",
|
|
1508
|
+
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
|
|
1509
|
+
resolve: (e) => parseFloat(e),
|
|
1510
|
+
stringify: Pe,
|
|
1511
|
+
},
|
|
1512
|
+
],
|
|
1513
|
+
{ default: !0, tag: "", test: /^/, resolve: (e, t) => (t(`Unresolved plain scalar ${JSON.stringify(e)}`), e) }
|
|
1514
|
+
),
|
|
1515
|
+
Re = {
|
|
1516
|
+
identify: (e) => e instanceof Uint8Array,
|
|
1517
|
+
default: !1,
|
|
1518
|
+
tag: "tag:yaml.org,2002:binary",
|
|
1519
|
+
resolve(e, t) {
|
|
1520
|
+
if ("function" == typeof atob) {
|
|
1521
|
+
const t = atob(e.replace(/[\n\r]/g, "")),
|
|
1522
|
+
n = new Uint8Array(t.length);
|
|
1523
|
+
for (let e = 0; e < t.length; ++e) n[e] = t.charCodeAt(e);
|
|
1524
|
+
return n;
|
|
1525
|
+
}
|
|
1526
|
+
return t("This environment does not support reading binary tags; either Buffer or atob is required"), e;
|
|
1527
|
+
},
|
|
1528
|
+
stringify({ comment: e, type: t, value: n }, s, i, o) {
|
|
1529
|
+
if (!n) return "";
|
|
1530
|
+
const r = n;
|
|
1531
|
+
let a;
|
|
1532
|
+
if ("function" != typeof btoa)
|
|
1533
|
+
throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
1534
|
+
{
|
|
1535
|
+
let e = "";
|
|
1536
|
+
for (let t = 0; t < r.length; ++t) e += String.fromCharCode(r[t]);
|
|
1537
|
+
a = btoa(e);
|
|
1538
|
+
}
|
|
1539
|
+
if ((t || (t = D.BLOCK_LITERAL), t !== D.QUOTE_DOUBLE)) {
|
|
1540
|
+
const e = Math.max(s.options.lineWidth - s.indent.length, s.options.minContentWidth),
|
|
1541
|
+
n = Math.ceil(a.length / e),
|
|
1542
|
+
i = new Array(n);
|
|
1543
|
+
for (let t = 0, s = 0; t < n; ++t, s += e) i[t] = a.substr(s, e);
|
|
1544
|
+
a = i.join(t === D.BLOCK_LITERAL ? "\n" : " ");
|
|
1545
|
+
}
|
|
1546
|
+
return ie({ comment: e, type: t, value: a }, s, i, o);
|
|
1547
|
+
},
|
|
1548
|
+
};
|
|
1549
|
+
function Fe(e, t) {
|
|
1550
|
+
if (d(e))
|
|
1551
|
+
for (let n = 0; n < e.items.length; ++n) {
|
|
1552
|
+
let s = e.items[n];
|
|
1553
|
+
if (!f(s)) {
|
|
1554
|
+
if (u(s)) {
|
|
1555
|
+
s.items.length > 1 && t("Each pair must have its own sequence indicator");
|
|
1556
|
+
const e = s.items[0] || new pe(new D(null));
|
|
1557
|
+
if (
|
|
1558
|
+
(s.commentBefore &&
|
|
1559
|
+
(e.key.commentBefore = e.key.commentBefore
|
|
1560
|
+
? `${s.commentBefore}\n${e.key.commentBefore}`
|
|
1561
|
+
: s.commentBefore),
|
|
1562
|
+
s.comment)
|
|
1563
|
+
) {
|
|
1564
|
+
const t = e.value ?? e.key;
|
|
1565
|
+
t.comment = t.comment ? `${s.comment}\n${t.comment}` : s.comment;
|
|
1566
|
+
}
|
|
1567
|
+
s = e;
|
|
1568
|
+
}
|
|
1569
|
+
e.items[n] = f(s) ? s : new pe(s);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
else t("Expected a sequence for this tag");
|
|
1573
|
+
return e;
|
|
1574
|
+
}
|
|
1575
|
+
function Ve(e, t, n) {
|
|
1576
|
+
const { replacer: s } = n,
|
|
1577
|
+
i = new Se(e);
|
|
1578
|
+
i.tag = "tag:yaml.org,2002:pairs";
|
|
1579
|
+
let o = 0;
|
|
1580
|
+
if (t && Symbol.iterator in Object(t))
|
|
1581
|
+
for (let e of t) {
|
|
1582
|
+
let r, a;
|
|
1583
|
+
if (("function" == typeof s && (e = s.call(t, String(o++), e)), Array.isArray(e))) {
|
|
1584
|
+
if (2 !== e.length) throw new TypeError(`Expected [key, value] tuple: ${e}`);
|
|
1585
|
+
(r = e[0]), (a = e[1]);
|
|
1586
|
+
} else if (e && e instanceof Object) {
|
|
1587
|
+
const t = Object.keys(e);
|
|
1588
|
+
if (1 !== t.length) throw new TypeError(`Expected tuple with one key, not ${t.length} keys`);
|
|
1589
|
+
(r = t[0]), (a = e[r]);
|
|
1590
|
+
} else r = e;
|
|
1591
|
+
i.items.push(de(r, a, n));
|
|
1592
|
+
}
|
|
1593
|
+
return i;
|
|
1594
|
+
}
|
|
1595
|
+
const Je = { collection: "seq", default: !1, tag: "tag:yaml.org,2002:pairs", resolve: Fe, createNode: Ve };
|
|
1596
|
+
class Ye extends Se {
|
|
1597
|
+
constructor() {
|
|
1598
|
+
super(),
|
|
1599
|
+
(this.add = we.prototype.add.bind(this)),
|
|
1600
|
+
(this.delete = we.prototype.delete.bind(this)),
|
|
1601
|
+
(this.get = we.prototype.get.bind(this)),
|
|
1602
|
+
(this.has = we.prototype.has.bind(this)),
|
|
1603
|
+
(this.set = we.prototype.set.bind(this)),
|
|
1604
|
+
(this.tag = Ye.tag);
|
|
1605
|
+
}
|
|
1606
|
+
toJSON(e, t) {
|
|
1607
|
+
if (!t) return super.toJSON(e);
|
|
1608
|
+
const n = new Map();
|
|
1609
|
+
t?.onCreate && t.onCreate(n);
|
|
1610
|
+
for (const e of this.items) {
|
|
1611
|
+
let s, i;
|
|
1612
|
+
if ((f(e) ? ((s = _(e.key, "", t)), (i = _(e.value, s, t))) : (s = _(e, "", t)), n.has(s)))
|
|
1613
|
+
throw new Error("Ordered maps must not include duplicate keys");
|
|
1614
|
+
n.set(s, i);
|
|
1615
|
+
}
|
|
1616
|
+
return n;
|
|
1617
|
+
}
|
|
1618
|
+
static from(e, t, n) {
|
|
1619
|
+
const s = Ve(e, t, n),
|
|
1620
|
+
i = new this();
|
|
1621
|
+
return (i.items = s.items), i;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
Ye.tag = "tag:yaml.org,2002:omap";
|
|
1625
|
+
const We = {
|
|
1626
|
+
collection: "seq",
|
|
1627
|
+
identify: (e) => e instanceof Map,
|
|
1628
|
+
nodeClass: Ye,
|
|
1629
|
+
default: !1,
|
|
1630
|
+
tag: "tag:yaml.org,2002:omap",
|
|
1631
|
+
resolve(e, t) {
|
|
1632
|
+
const n = Fe(e, t),
|
|
1633
|
+
s = [];
|
|
1634
|
+
for (const { key: e } of n.items)
|
|
1635
|
+
h(e) && (s.includes(e.value) ? t(`Ordered maps must not include duplicate keys: ${e.value}`) : s.push(e.value));
|
|
1636
|
+
return Object.assign(new Ye(), n);
|
|
1637
|
+
},
|
|
1638
|
+
createNode: (e, t, n) => Ye.from(e, t, n),
|
|
1639
|
+
};
|
|
1640
|
+
function Ge({ value: e, source: t }, n) {
|
|
1641
|
+
return t && (e ? Qe : He).test.test(t) ? t : e ? n.options.trueStr : n.options.falseStr;
|
|
1642
|
+
}
|
|
1643
|
+
const Qe = {
|
|
1644
|
+
identify: (e) => !0 === e,
|
|
1645
|
+
default: !0,
|
|
1646
|
+
tag: "tag:yaml.org,2002:bool",
|
|
1647
|
+
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
1648
|
+
resolve: () => new D(!0),
|
|
1649
|
+
stringify: Ge,
|
|
1650
|
+
},
|
|
1651
|
+
He = {
|
|
1652
|
+
identify: (e) => !1 === e,
|
|
1653
|
+
default: !0,
|
|
1654
|
+
tag: "tag:yaml.org,2002:bool",
|
|
1655
|
+
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
|
|
1656
|
+
resolve: () => new D(!1),
|
|
1657
|
+
stringify: Ge,
|
|
1658
|
+
},
|
|
1659
|
+
Xe = {
|
|
1660
|
+
identify: (e) => "number" == typeof e,
|
|
1661
|
+
default: !0,
|
|
1662
|
+
tag: "tag:yaml.org,2002:float",
|
|
1663
|
+
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
1664
|
+
resolve: (e) =>
|
|
1665
|
+
"nan" === e.slice(-3).toLowerCase() ? NaN : "-" === e[0] ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
1666
|
+
stringify: Te,
|
|
1667
|
+
},
|
|
1668
|
+
ze = {
|
|
1669
|
+
identify: (e) => "number" == typeof e,
|
|
1670
|
+
default: !0,
|
|
1671
|
+
tag: "tag:yaml.org,2002:float",
|
|
1672
|
+
format: "EXP",
|
|
1673
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
1674
|
+
resolve: (e) => parseFloat(e.replace(/_/g, "")),
|
|
1675
|
+
stringify(e) {
|
|
1676
|
+
const t = Number(e.value);
|
|
1677
|
+
return isFinite(t) ? t.toExponential() : Te(e);
|
|
1678
|
+
},
|
|
1679
|
+
},
|
|
1680
|
+
Ze = {
|
|
1681
|
+
identify: (e) => "number" == typeof e,
|
|
1682
|
+
default: !0,
|
|
1683
|
+
tag: "tag:yaml.org,2002:float",
|
|
1684
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
1685
|
+
resolve(e) {
|
|
1686
|
+
const t = new D(parseFloat(e.replace(/_/g, ""))),
|
|
1687
|
+
n = e.indexOf(".");
|
|
1688
|
+
if (-1 !== n) {
|
|
1689
|
+
const s = e.substring(n + 1).replace(/_/g, "");
|
|
1690
|
+
"0" === s[s.length - 1] && (t.minFractionDigits = s.length);
|
|
1691
|
+
}
|
|
1692
|
+
return t;
|
|
1693
|
+
},
|
|
1694
|
+
stringify: Te,
|
|
1695
|
+
},
|
|
1696
|
+
et = (e) => "bigint" == typeof e || Number.isInteger(e);
|
|
1697
|
+
function tt(e, t, n, { intAsBigInt: s }) {
|
|
1698
|
+
const i = e[0];
|
|
1699
|
+
if ((("-" !== i && "+" !== i) || (t += 1), (e = e.substring(t).replace(/_/g, "")), s)) {
|
|
1700
|
+
switch (n) {
|
|
1701
|
+
case 2:
|
|
1702
|
+
e = `0b${e}`;
|
|
1703
|
+
break;
|
|
1704
|
+
case 8:
|
|
1705
|
+
e = `0o${e}`;
|
|
1706
|
+
break;
|
|
1707
|
+
case 16:
|
|
1708
|
+
e = `0x${e}`;
|
|
1709
|
+
}
|
|
1710
|
+
const t = BigInt(e);
|
|
1711
|
+
return "-" === i ? BigInt(-1) * t : t;
|
|
1712
|
+
}
|
|
1713
|
+
const o = parseInt(e, n);
|
|
1714
|
+
return "-" === i ? -1 * o : o;
|
|
1715
|
+
}
|
|
1716
|
+
function nt(e, t, n) {
|
|
1717
|
+
const { value: s } = e;
|
|
1718
|
+
if (et(s)) {
|
|
1719
|
+
const e = s.toString(t);
|
|
1720
|
+
return s < 0 ? "-" + n + e.substr(1) : n + e;
|
|
1721
|
+
}
|
|
1722
|
+
return Te(e);
|
|
1723
|
+
}
|
|
1724
|
+
const st = {
|
|
1725
|
+
identify: et,
|
|
1726
|
+
default: !0,
|
|
1727
|
+
tag: "tag:yaml.org,2002:int",
|
|
1728
|
+
format: "BIN",
|
|
1729
|
+
test: /^[-+]?0b[0-1_]+$/,
|
|
1730
|
+
resolve: (e, t, n) => tt(e, 2, 2, n),
|
|
1731
|
+
stringify: (e) => nt(e, 2, "0b"),
|
|
1732
|
+
},
|
|
1733
|
+
it = {
|
|
1734
|
+
identify: et,
|
|
1735
|
+
default: !0,
|
|
1736
|
+
tag: "tag:yaml.org,2002:int",
|
|
1737
|
+
format: "OCT",
|
|
1738
|
+
test: /^[-+]?0[0-7_]+$/,
|
|
1739
|
+
resolve: (e, t, n) => tt(e, 1, 8, n),
|
|
1740
|
+
stringify: (e) => nt(e, 8, "0"),
|
|
1741
|
+
},
|
|
1742
|
+
ot = {
|
|
1743
|
+
identify: et,
|
|
1744
|
+
default: !0,
|
|
1745
|
+
tag: "tag:yaml.org,2002:int",
|
|
1746
|
+
test: /^[-+]?[0-9][0-9_]*$/,
|
|
1747
|
+
resolve: (e, t, n) => tt(e, 0, 10, n),
|
|
1748
|
+
stringify: Te,
|
|
1749
|
+
},
|
|
1750
|
+
rt = {
|
|
1751
|
+
identify: et,
|
|
1752
|
+
default: !0,
|
|
1753
|
+
tag: "tag:yaml.org,2002:int",
|
|
1754
|
+
format: "HEX",
|
|
1755
|
+
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
1756
|
+
resolve: (e, t, n) => tt(e, 2, 16, n),
|
|
1757
|
+
stringify: (e) => nt(e, 16, "0x"),
|
|
1758
|
+
};
|
|
1759
|
+
class at extends we {
|
|
1760
|
+
constructor(e) {
|
|
1761
|
+
super(e), (this.tag = at.tag);
|
|
1762
|
+
}
|
|
1763
|
+
add(e) {
|
|
1764
|
+
let t;
|
|
1765
|
+
t = f(e)
|
|
1766
|
+
? e
|
|
1767
|
+
: e && "object" == typeof e && "key" in e && "value" in e && null === e.value
|
|
1768
|
+
? new pe(e.key, null)
|
|
1769
|
+
: new pe(e, null);
|
|
1770
|
+
ke(this.items, t.key) || this.items.push(t);
|
|
1771
|
+
}
|
|
1772
|
+
get(e, t) {
|
|
1773
|
+
const n = ke(this.items, e);
|
|
1774
|
+
return !t && f(n) ? (h(n.key) ? n.key.value : n.key) : n;
|
|
1775
|
+
}
|
|
1776
|
+
set(e, t) {
|
|
1777
|
+
if ("boolean" != typeof t)
|
|
1778
|
+
throw new Error("Expected boolean value for set(key, value) in a YAML set, not " + typeof t);
|
|
1779
|
+
const n = ke(this.items, e);
|
|
1780
|
+
n && !t ? this.items.splice(this.items.indexOf(n), 1) : !n && t && this.items.push(new pe(e));
|
|
1781
|
+
}
|
|
1782
|
+
toJSON(e, t) {
|
|
1783
|
+
return super.toJSON(e, t, Set);
|
|
1784
|
+
}
|
|
1785
|
+
toString(e, t, n) {
|
|
1786
|
+
if (!e) return JSON.stringify(this);
|
|
1787
|
+
if (this.hasAllNullValues(!0)) return super.toString(Object.assign({}, e, { allNullValues: !0 }), t, n);
|
|
1788
|
+
throw new Error("Set items must all have null values");
|
|
1789
|
+
}
|
|
1790
|
+
static from(e, t, n) {
|
|
1791
|
+
const { replacer: s } = n,
|
|
1792
|
+
i = new this(e);
|
|
1793
|
+
if (t && Symbol.iterator in Object(t))
|
|
1794
|
+
for (let e of t) "function" == typeof s && (e = s.call(t, e, e)), i.items.push(de(e, null, n));
|
|
1795
|
+
return i;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
at.tag = "tag:yaml.org,2002:set";
|
|
1799
|
+
const ct = {
|
|
1800
|
+
collection: "map",
|
|
1801
|
+
identify: (e) => e instanceof Set,
|
|
1802
|
+
nodeClass: at,
|
|
1803
|
+
default: !1,
|
|
1804
|
+
tag: "tag:yaml.org,2002:set",
|
|
1805
|
+
createNode: (e, t, n) => at.from(e, t, n),
|
|
1806
|
+
resolve(e, t) {
|
|
1807
|
+
if (u(e)) {
|
|
1808
|
+
if (e.hasAllNullValues(!0)) return Object.assign(new at(), e);
|
|
1809
|
+
t("Set items must all have null values");
|
|
1810
|
+
} else t("Expected a mapping for this tag");
|
|
1811
|
+
return e;
|
|
1812
|
+
},
|
|
1813
|
+
};
|
|
1814
|
+
function lt(e, t) {
|
|
1815
|
+
const n = e[0],
|
|
1816
|
+
s = "-" === n || "+" === n ? e.substring(1) : e,
|
|
1817
|
+
i = (e) => (t ? BigInt(e) : Number(e)),
|
|
1818
|
+
o = s
|
|
1819
|
+
.replace(/_/g, "")
|
|
1820
|
+
.split(":")
|
|
1821
|
+
.reduce((e, t) => e * i(60) + i(t), i(0));
|
|
1822
|
+
return "-" === n ? i(-1) * o : o;
|
|
1823
|
+
}
|
|
1824
|
+
function ut(e) {
|
|
1825
|
+
let { value: t } = e,
|
|
1826
|
+
n = (e) => e;
|
|
1827
|
+
if ("bigint" == typeof t) n = (e) => BigInt(e);
|
|
1828
|
+
else if (isNaN(t) || !isFinite(t)) return Te(e);
|
|
1829
|
+
let s = "";
|
|
1830
|
+
t < 0 && ((s = "-"), (t *= n(-1)));
|
|
1831
|
+
const i = n(60),
|
|
1832
|
+
o = [t % i];
|
|
1833
|
+
return (
|
|
1834
|
+
t < 60 ? o.unshift(0) : ((t = (t - o[0]) / i), o.unshift(t % i), t >= 60 && ((t = (t - o[0]) / i), o.unshift(t))),
|
|
1835
|
+
s +
|
|
1836
|
+
o
|
|
1837
|
+
.map((e) => String(e).padStart(2, "0"))
|
|
1838
|
+
.join(":")
|
|
1839
|
+
.replace(/000000\d*$/, "")
|
|
1840
|
+
);
|
|
1841
|
+
}
|
|
1842
|
+
const ft = {
|
|
1843
|
+
identify: (e) => "bigint" == typeof e || Number.isInteger(e),
|
|
1844
|
+
default: !0,
|
|
1845
|
+
tag: "tag:yaml.org,2002:int",
|
|
1846
|
+
format: "TIME",
|
|
1847
|
+
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
1848
|
+
resolve: (e, t, { intAsBigInt: n }) => lt(e, n),
|
|
1849
|
+
stringify: ut,
|
|
1850
|
+
},
|
|
1851
|
+
ht = {
|
|
1852
|
+
identify: (e) => "number" == typeof e,
|
|
1853
|
+
default: !0,
|
|
1854
|
+
tag: "tag:yaml.org,2002:float",
|
|
1855
|
+
format: "TIME",
|
|
1856
|
+
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
1857
|
+
resolve: (e) => lt(e, !1),
|
|
1858
|
+
stringify: ut,
|
|
1859
|
+
},
|
|
1860
|
+
dt = {
|
|
1861
|
+
identify: (e) => e instanceof Date,
|
|
1862
|
+
default: !0,
|
|
1863
|
+
tag: "tag:yaml.org,2002:timestamp",
|
|
1864
|
+
test: RegExp(
|
|
1865
|
+
"^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"
|
|
1866
|
+
),
|
|
1867
|
+
resolve(e) {
|
|
1868
|
+
const t = e.match(dt.test);
|
|
1869
|
+
if (!t) throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
1870
|
+
const [, n, s, i, o, r, a] = t.map(Number),
|
|
1871
|
+
c = t[7] ? Number((t[7] + "00").substr(1, 3)) : 0;
|
|
1872
|
+
let l = Date.UTC(n, s - 1, i, o || 0, r || 0, a || 0, c);
|
|
1873
|
+
const u = t[8];
|
|
1874
|
+
if (u && "Z" !== u) {
|
|
1875
|
+
let e = lt(u, !1);
|
|
1876
|
+
Math.abs(e) < 30 && (e *= 60), (l -= 6e4 * e);
|
|
1877
|
+
}
|
|
1878
|
+
return new Date(l);
|
|
1879
|
+
},
|
|
1880
|
+
stringify: ({ value: e }) => e?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? "",
|
|
1881
|
+
},
|
|
1882
|
+
pt = [ve, Ne, Oe, Ae, Qe, He, st, it, ot, rt, Xe, ze, Ze, Re, le, We, Je, ct, ft, ht, dt],
|
|
1883
|
+
mt = new Map([
|
|
1884
|
+
["core", De],
|
|
1885
|
+
["failsafe", [ve, Ne, Oe]],
|
|
1886
|
+
["json", Ue],
|
|
1887
|
+
["yaml11", pt],
|
|
1888
|
+
["yaml-1.1", pt],
|
|
1889
|
+
]),
|
|
1890
|
+
yt = {
|
|
1891
|
+
binary: Re,
|
|
1892
|
+
bool: Ie,
|
|
1893
|
+
float: $e,
|
|
1894
|
+
floatExp: xe,
|
|
1895
|
+
floatNaN: Le,
|
|
1896
|
+
floatTime: ht,
|
|
1897
|
+
int: je,
|
|
1898
|
+
intHex: Me,
|
|
1899
|
+
intOct: Be,
|
|
1900
|
+
intTime: ft,
|
|
1901
|
+
map: ve,
|
|
1902
|
+
merge: le,
|
|
1903
|
+
null: Ae,
|
|
1904
|
+
omap: We,
|
|
1905
|
+
pairs: Je,
|
|
1906
|
+
seq: Ne,
|
|
1907
|
+
set: ct,
|
|
1908
|
+
timestamp: dt,
|
|
1909
|
+
},
|
|
1910
|
+
gt = {
|
|
1911
|
+
"tag:yaml.org,2002:binary": Re,
|
|
1912
|
+
"tag:yaml.org,2002:merge": le,
|
|
1913
|
+
"tag:yaml.org,2002:omap": We,
|
|
1914
|
+
"tag:yaml.org,2002:pairs": Je,
|
|
1915
|
+
"tag:yaml.org,2002:set": ct,
|
|
1916
|
+
"tag:yaml.org,2002:timestamp": dt,
|
|
1917
|
+
};
|
|
1918
|
+
function bt(e, t, n) {
|
|
1919
|
+
const s = mt.get(t);
|
|
1920
|
+
if (s && !e) return n && !s.includes(le) ? s.concat(le) : s.slice();
|
|
1921
|
+
let i = s;
|
|
1922
|
+
if (!i) {
|
|
1923
|
+
if (!Array.isArray(e)) {
|
|
1924
|
+
const e = Array.from(mt.keys())
|
|
1925
|
+
.filter((e) => "yaml11" !== e)
|
|
1926
|
+
.map((e) => JSON.stringify(e))
|
|
1927
|
+
.join(", ");
|
|
1928
|
+
throw new Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`);
|
|
1929
|
+
}
|
|
1930
|
+
i = [];
|
|
1931
|
+
}
|
|
1932
|
+
if (Array.isArray(e)) for (const t of e) i = i.concat(t);
|
|
1933
|
+
else "function" == typeof e && (i = e(i.slice()));
|
|
1934
|
+
return (
|
|
1935
|
+
n && (i = i.concat(le)),
|
|
1936
|
+
i.reduce((e, t) => {
|
|
1937
|
+
const n = "string" == typeof t ? yt[t] : t;
|
|
1938
|
+
if (!n) {
|
|
1939
|
+
const e = JSON.stringify(t),
|
|
1940
|
+
n = Object.keys(yt)
|
|
1941
|
+
.map((e) => JSON.stringify(e))
|
|
1942
|
+
.join(", ");
|
|
1943
|
+
throw new Error(`Unknown custom tag ${e}; use one of ${n}`);
|
|
1944
|
+
}
|
|
1945
|
+
return e.includes(n) || e.push(n), e;
|
|
1946
|
+
}, [])
|
|
1947
|
+
);
|
|
1948
|
+
}
|
|
1949
|
+
const kt = (e, t) => (e.key < t.key ? -1 : e.key > t.key ? 1 : 0);
|
|
1950
|
+
class wt {
|
|
1951
|
+
constructor({
|
|
1952
|
+
compat: e,
|
|
1953
|
+
customTags: t,
|
|
1954
|
+
merge: n,
|
|
1955
|
+
resolveKnownTags: i,
|
|
1956
|
+
schema: a,
|
|
1957
|
+
sortMapEntries: c,
|
|
1958
|
+
toStringDefaults: l,
|
|
1959
|
+
}) {
|
|
1960
|
+
(this.compat = Array.isArray(e) ? bt(e, "compat") : e ? bt(null, e) : null),
|
|
1961
|
+
(this.name = ("string" == typeof a && a) || "core"),
|
|
1962
|
+
(this.knownTags = i ? gt : {}),
|
|
1963
|
+
(this.tags = bt(t, this.name, n)),
|
|
1964
|
+
(this.toStringOptions = l ?? null),
|
|
1965
|
+
Object.defineProperty(this, s, { value: ve }),
|
|
1966
|
+
Object.defineProperty(this, o, { value: Oe }),
|
|
1967
|
+
Object.defineProperty(this, r, { value: Ne }),
|
|
1968
|
+
(this.sortMapEntries = "function" == typeof c ? c : !0 === c ? kt : null);
|
|
1969
|
+
}
|
|
1970
|
+
clone() {
|
|
1971
|
+
const e = Object.create(wt.prototype, Object.getOwnPropertyDescriptors(this));
|
|
1972
|
+
return (e.tags = this.tags.slice()), e;
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
class vt {
|
|
1976
|
+
constructor(e, t, s) {
|
|
1977
|
+
(this.commentBefore = null),
|
|
1978
|
+
(this.comment = null),
|
|
1979
|
+
(this.errors = []),
|
|
1980
|
+
(this.warnings = []),
|
|
1981
|
+
Object.defineProperty(this, a, { value: n });
|
|
1982
|
+
let i = null;
|
|
1983
|
+
"function" == typeof t || Array.isArray(t) ? (i = t) : void 0 === s && t && ((s = t), (t = void 0));
|
|
1984
|
+
const o = Object.assign(
|
|
1985
|
+
{
|
|
1986
|
+
intAsBigInt: !1,
|
|
1987
|
+
keepSourceTokens: !1,
|
|
1988
|
+
logLevel: "warn",
|
|
1989
|
+
prettyErrors: !0,
|
|
1990
|
+
strict: !0,
|
|
1991
|
+
stringKeys: !1,
|
|
1992
|
+
uniqueKeys: !0,
|
|
1993
|
+
version: "1.2",
|
|
1994
|
+
},
|
|
1995
|
+
s
|
|
1996
|
+
);
|
|
1997
|
+
this.options = o;
|
|
1998
|
+
let { version: r } = o;
|
|
1999
|
+
s?._directives
|
|
2000
|
+
? ((this.directives = s._directives.atDocument()),
|
|
2001
|
+
this.directives.yaml.explicit && (r = this.directives.yaml.version))
|
|
2002
|
+
: (this.directives = new T({ version: r })),
|
|
2003
|
+
this.setSchema(r, s),
|
|
2004
|
+
(this.contents = void 0 === e ? null : this.createNode(e, i, s));
|
|
2005
|
+
}
|
|
2006
|
+
clone() {
|
|
2007
|
+
const e = Object.create(vt.prototype, { [a]: { value: n } });
|
|
2008
|
+
return (
|
|
2009
|
+
(e.commentBefore = this.commentBefore),
|
|
2010
|
+
(e.comment = this.comment),
|
|
2011
|
+
(e.errors = this.errors.slice()),
|
|
2012
|
+
(e.warnings = this.warnings.slice()),
|
|
2013
|
+
(e.options = Object.assign({}, this.options)),
|
|
2014
|
+
this.directives && (e.directives = this.directives.clone()),
|
|
2015
|
+
(e.schema = this.schema.clone()),
|
|
2016
|
+
(e.contents = m(this.contents) ? this.contents.clone(e.schema) : this.contents),
|
|
2017
|
+
this.range && (e.range = this.range.slice()),
|
|
2018
|
+
e
|
|
2019
|
+
);
|
|
2020
|
+
}
|
|
2021
|
+
add(e) {
|
|
2022
|
+
St(this.contents) && this.contents.add(e);
|
|
2023
|
+
}
|
|
2024
|
+
addIn(e, t) {
|
|
2025
|
+
St(this.contents) && this.contents.addIn(e, t);
|
|
2026
|
+
}
|
|
2027
|
+
createAlias(e, t) {
|
|
2028
|
+
if (!e.anchor) {
|
|
2029
|
+
const n = x(this);
|
|
2030
|
+
e.anchor = !t || n.has(t) ? $(t || "a", n) : t;
|
|
2031
|
+
}
|
|
2032
|
+
return new B(e.anchor);
|
|
2033
|
+
}
|
|
2034
|
+
createNode(e, t, n) {
|
|
2035
|
+
let s;
|
|
2036
|
+
if ("function" == typeof t) (e = t.call({ "": e }, "", e)), (s = t);
|
|
2037
|
+
else if (Array.isArray(t)) {
|
|
2038
|
+
const e = (e) => "number" == typeof e || e instanceof String || e instanceof Number,
|
|
2039
|
+
n = t.filter(e).map(String);
|
|
2040
|
+
n.length > 0 && (t = t.concat(n)), (s = t);
|
|
2041
|
+
} else void 0 === n && t && ((n = t), (t = void 0));
|
|
2042
|
+
const { aliasDuplicateObjects: i, anchorPrefix: o, flow: r, keepUndefined: a, onTagObj: c, tag: l } = n ?? {},
|
|
2043
|
+
{
|
|
2044
|
+
onAnchor: u,
|
|
2045
|
+
setAnchors: f,
|
|
2046
|
+
sourceObjects: d,
|
|
2047
|
+
} = (function (e, t) {
|
|
2048
|
+
const n = [],
|
|
2049
|
+
s = new Map();
|
|
2050
|
+
let i = null;
|
|
2051
|
+
return {
|
|
2052
|
+
onAnchor: (s) => {
|
|
2053
|
+
n.push(s), i || (i = x(e));
|
|
2054
|
+
const o = $(t, i);
|
|
2055
|
+
return i.add(o), o;
|
|
2056
|
+
},
|
|
2057
|
+
setAnchors: () => {
|
|
2058
|
+
for (const e of n) {
|
|
2059
|
+
const t = s.get(e);
|
|
2060
|
+
if ("object" != typeof t || !t.anchor || (!h(t.node) && !p(t.node))) {
|
|
2061
|
+
const t = new Error("Failed to resolve repeated object (this should not happen)");
|
|
2062
|
+
throw ((t.source = e), t);
|
|
2063
|
+
}
|
|
2064
|
+
t.node.anchor = t.anchor;
|
|
2065
|
+
}
|
|
2066
|
+
},
|
|
2067
|
+
sourceObjects: s,
|
|
2068
|
+
};
|
|
2069
|
+
})(this, o || "a"),
|
|
2070
|
+
m = q(e, l, {
|
|
2071
|
+
aliasDuplicateObjects: i ?? !0,
|
|
2072
|
+
keepUndefined: a ?? !1,
|
|
2073
|
+
onAnchor: u,
|
|
2074
|
+
onTagObj: c,
|
|
2075
|
+
replacer: s,
|
|
2076
|
+
schema: this.schema,
|
|
2077
|
+
sourceObjects: d,
|
|
2078
|
+
});
|
|
2079
|
+
return r && p(m) && (m.flow = !0), f(), m;
|
|
2080
|
+
}
|
|
2081
|
+
createPair(e, t, n = {}) {
|
|
2082
|
+
const s = this.createNode(e, null, n),
|
|
2083
|
+
i = this.createNode(t, null, n);
|
|
2084
|
+
return new pe(s, i);
|
|
2085
|
+
}
|
|
2086
|
+
delete(e) {
|
|
2087
|
+
return !!St(this.contents) && this.contents.delete(e);
|
|
2088
|
+
}
|
|
2089
|
+
deleteIn(e) {
|
|
2090
|
+
return U(e)
|
|
2091
|
+
? null != this.contents && ((this.contents = null), !0)
|
|
2092
|
+
: !!St(this.contents) && this.contents.deleteIn(e);
|
|
2093
|
+
}
|
|
2094
|
+
get(e, t) {
|
|
2095
|
+
return p(this.contents) ? this.contents.get(e, t) : void 0;
|
|
2096
|
+
}
|
|
2097
|
+
getIn(e, t) {
|
|
2098
|
+
return U(e)
|
|
2099
|
+
? !t && h(this.contents)
|
|
2100
|
+
? this.contents.value
|
|
2101
|
+
: this.contents
|
|
2102
|
+
: p(this.contents)
|
|
2103
|
+
? this.contents.getIn(e, t)
|
|
2104
|
+
: void 0;
|
|
2105
|
+
}
|
|
2106
|
+
has(e) {
|
|
2107
|
+
return !!p(this.contents) && this.contents.has(e);
|
|
2108
|
+
}
|
|
2109
|
+
hasIn(e) {
|
|
2110
|
+
return U(e) ? void 0 !== this.contents : !!p(this.contents) && this.contents.hasIn(e);
|
|
2111
|
+
}
|
|
2112
|
+
set(e, t) {
|
|
2113
|
+
null == this.contents ? (this.contents = P(this.schema, [e], t)) : St(this.contents) && this.contents.set(e, t);
|
|
2114
|
+
}
|
|
2115
|
+
setIn(e, t) {
|
|
2116
|
+
U(e)
|
|
2117
|
+
? (this.contents = t)
|
|
2118
|
+
: null == this.contents
|
|
2119
|
+
? (this.contents = P(this.schema, Array.from(e), t))
|
|
2120
|
+
: St(this.contents) && this.contents.setIn(e, t);
|
|
2121
|
+
}
|
|
2122
|
+
setSchema(e, t = {}) {
|
|
2123
|
+
let n;
|
|
2124
|
+
switch (("number" == typeof e && (e = String(e)), e)) {
|
|
2125
|
+
case "1.1":
|
|
2126
|
+
this.directives ? (this.directives.yaml.version = "1.1") : (this.directives = new T({ version: "1.1" })),
|
|
2127
|
+
(n = { resolveKnownTags: !1, schema: "yaml-1.1" });
|
|
2128
|
+
break;
|
|
2129
|
+
case "1.2":
|
|
2130
|
+
case "next":
|
|
2131
|
+
this.directives ? (this.directives.yaml.version = e) : (this.directives = new T({ version: e })),
|
|
2132
|
+
(n = { resolveKnownTags: !0, schema: "core" });
|
|
2133
|
+
break;
|
|
2134
|
+
case null:
|
|
2135
|
+
this.directives && delete this.directives, (n = null);
|
|
2136
|
+
break;
|
|
2137
|
+
default: {
|
|
2138
|
+
const t = JSON.stringify(e);
|
|
2139
|
+
throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`);
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
if (t.schema instanceof Object) this.schema = t.schema;
|
|
2143
|
+
else {
|
|
2144
|
+
if (!n) throw new Error("With a null YAML version, the { schema: Schema } option is required");
|
|
2145
|
+
this.schema = new wt(Object.assign(n, t));
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
toJS({ json: e, jsonArg: t, mapAsMap: n, maxAliasCount: s, onAnchor: i, reviver: o } = {}) {
|
|
2149
|
+
const r = {
|
|
2150
|
+
anchors: new Map(),
|
|
2151
|
+
doc: this,
|
|
2152
|
+
keep: !e,
|
|
2153
|
+
mapAsMap: !0 === n,
|
|
2154
|
+
mapKeyWarned: !1,
|
|
2155
|
+
maxAliasCount: "number" == typeof s ? s : 100,
|
|
2156
|
+
},
|
|
2157
|
+
a = _(this.contents, t ?? "", r);
|
|
2158
|
+
if ("function" == typeof i) for (const { count: e, res: t } of r.anchors.values()) i(t, e);
|
|
2159
|
+
return "function" == typeof o ? C(o, { "": a }, "", a) : a;
|
|
2160
|
+
}
|
|
2161
|
+
toJSON(e, t) {
|
|
2162
|
+
return this.toJS({ json: !0, jsonArg: e, mapAsMap: !1, onAnchor: t });
|
|
2163
|
+
}
|
|
2164
|
+
toString(e = {}) {
|
|
2165
|
+
if (this.errors.length > 0) throw new Error("Document with errors cannot be stringified");
|
|
2166
|
+
if ("indent" in e && (!Number.isInteger(e.indent) || Number(e.indent) <= 0)) {
|
|
2167
|
+
const t = JSON.stringify(e.indent);
|
|
2168
|
+
throw new Error(`"indent" option must be a positive integer, not ${t}`);
|
|
2169
|
+
}
|
|
2170
|
+
return (function (e, t) {
|
|
2171
|
+
const n = [];
|
|
2172
|
+
let s = !0 === t.directives;
|
|
2173
|
+
if (!1 !== t.directives && e.directives) {
|
|
2174
|
+
const t = e.directives.toString(e);
|
|
2175
|
+
t ? (n.push(t), (s = !0)) : e.directives.docStart && (s = !0);
|
|
2176
|
+
}
|
|
2177
|
+
s && n.push("---");
|
|
2178
|
+
const i = oe(e, t),
|
|
2179
|
+
{ commentString: o } = i.options;
|
|
2180
|
+
if (e.commentBefore) {
|
|
2181
|
+
1 !== n.length && n.unshift("");
|
|
2182
|
+
const t = o(e.commentBefore);
|
|
2183
|
+
n.unshift(V(t, ""));
|
|
2184
|
+
}
|
|
2185
|
+
let r = !1,
|
|
2186
|
+
a = null;
|
|
2187
|
+
if (e.contents) {
|
|
2188
|
+
if (m(e.contents)) {
|
|
2189
|
+
if ((e.contents.spaceBefore && s && n.push(""), e.contents.commentBefore)) {
|
|
2190
|
+
const t = o(e.contents.commentBefore);
|
|
2191
|
+
n.push(V(t, ""));
|
|
2192
|
+
}
|
|
2193
|
+
(i.forceBlockIndent = !!e.comment), (a = e.contents.comment);
|
|
2194
|
+
}
|
|
2195
|
+
const t = a ? void 0 : () => (r = !0);
|
|
2196
|
+
let c = re(e.contents, i, () => (a = null), t);
|
|
2197
|
+
a && (c += J(c, "", o(a))),
|
|
2198
|
+
("|" !== c[0] && ">" !== c[0]) || "---" !== n[n.length - 1] ? n.push(c) : (n[n.length - 1] = `--- ${c}`);
|
|
2199
|
+
} else n.push(re(e.contents, i));
|
|
2200
|
+
if (e.directives?.docEnd)
|
|
2201
|
+
if (e.comment) {
|
|
2202
|
+
const t = o(e.comment);
|
|
2203
|
+
t.includes("\n") ? (n.push("..."), n.push(V(t, ""))) : n.push(`... ${t}`);
|
|
2204
|
+
} else n.push("...");
|
|
2205
|
+
else {
|
|
2206
|
+
let t = e.comment;
|
|
2207
|
+
t && r && (t = t.replace(/^\n+/, "")),
|
|
2208
|
+
t && ((r && !a) || "" === n[n.length - 1] || n.push(""), n.push(V(o(t), "")));
|
|
2209
|
+
}
|
|
2210
|
+
return n.join("\n") + "\n";
|
|
2211
|
+
})(this, e);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
function St(e) {
|
|
2215
|
+
if (p(e)) return !0;
|
|
2216
|
+
throw new Error("Expected a YAML collection as document contents");
|
|
2217
|
+
}
|
|
2218
|
+
class Et extends Error {
|
|
2219
|
+
constructor(e, t, n, s) {
|
|
2220
|
+
super(), (this.name = e), (this.code = n), (this.message = s), (this.pos = t);
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
class Nt extends Et {
|
|
2224
|
+
constructor(e, t, n) {
|
|
2225
|
+
super("YAMLParseError", e, t, n);
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
class Ot extends Et {
|
|
2229
|
+
constructor(e, t, n) {
|
|
2230
|
+
super("YAMLWarning", e, t, n);
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
const At = (e, t) => (n) => {
|
|
2234
|
+
if (-1 === n.pos[0]) return;
|
|
2235
|
+
n.linePos = n.pos.map((e) => t.linePos(e));
|
|
2236
|
+
const { line: s, col: i } = n.linePos[0];
|
|
2237
|
+
n.message += ` at line ${s}, column ${i}`;
|
|
2238
|
+
let o = i - 1,
|
|
2239
|
+
r = e.substring(t.lineStarts[s - 1], t.lineStarts[s]).replace(/[\n\r]+$/, "");
|
|
2240
|
+
if (o >= 60 && r.length > 80) {
|
|
2241
|
+
const e = Math.min(o - 39, r.length - 79);
|
|
2242
|
+
(r = "…" + r.substring(e)), (o -= e - 1);
|
|
2243
|
+
}
|
|
2244
|
+
if ((r.length > 80 && (r = r.substring(0, 79) + "…"), s > 1 && /^ *$/.test(r.substring(0, o)))) {
|
|
2245
|
+
let n = e.substring(t.lineStarts[s - 2], t.lineStarts[s - 1]);
|
|
2246
|
+
n.length > 80 && (n = n.substring(0, 79) + "…\n"), (r = n + r);
|
|
2247
|
+
}
|
|
2248
|
+
if (/[^ ]/.test(r)) {
|
|
2249
|
+
let e = 1;
|
|
2250
|
+
const t = n.linePos[1];
|
|
2251
|
+
t && t.line === s && t.col > i && (e = Math.max(1, Math.min(t.col - i, 80 - o)));
|
|
2252
|
+
const a = " ".repeat(o) + "^".repeat(e);
|
|
2253
|
+
n.message += `:\n\n${r}\n${a}\n`;
|
|
2254
|
+
}
|
|
2255
|
+
};
|
|
2256
|
+
function It(e, { flow: t, indicator: n, next: s, offset: i, onError: o, parentIndent: r, startOnNewline: a }) {
|
|
2257
|
+
let c = !1,
|
|
2258
|
+
l = a,
|
|
2259
|
+
u = a,
|
|
2260
|
+
f = "",
|
|
2261
|
+
h = "",
|
|
2262
|
+
d = !1,
|
|
2263
|
+
p = !1,
|
|
2264
|
+
m = null,
|
|
2265
|
+
y = null,
|
|
2266
|
+
g = null,
|
|
2267
|
+
b = null,
|
|
2268
|
+
k = null,
|
|
2269
|
+
w = null,
|
|
2270
|
+
v = null;
|
|
2271
|
+
for (const i of e)
|
|
2272
|
+
switch (
|
|
2273
|
+
(p &&
|
|
2274
|
+
("space" !== i.type &&
|
|
2275
|
+
"newline" !== i.type &&
|
|
2276
|
+
"comma" !== i.type &&
|
|
2277
|
+
o(i.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"),
|
|
2278
|
+
(p = !1)),
|
|
2279
|
+
m &&
|
|
2280
|
+
(l &&
|
|
2281
|
+
"comment" !== i.type &&
|
|
2282
|
+
"newline" !== i.type &&
|
|
2283
|
+
o(m, "TAB_AS_INDENT", "Tabs are not allowed as indentation"),
|
|
2284
|
+
(m = null)),
|
|
2285
|
+
i.type)
|
|
2286
|
+
) {
|
|
2287
|
+
case "space":
|
|
2288
|
+
t || ("doc-start" === n && "flow-collection" === s?.type) || !i.source.includes("\t") || (m = i), (u = !0);
|
|
2289
|
+
break;
|
|
2290
|
+
case "comment": {
|
|
2291
|
+
u || o(i, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
|
|
2292
|
+
const e = i.source.substring(1) || " ";
|
|
2293
|
+
f ? (f += h + e) : (f = e), (h = ""), (l = !1);
|
|
2294
|
+
break;
|
|
2295
|
+
}
|
|
2296
|
+
case "newline":
|
|
2297
|
+
l ? (f ? (f += i.source) : (w && "seq-item-ind" === n) || (c = !0)) : (h += i.source),
|
|
2298
|
+
(l = !0),
|
|
2299
|
+
(d = !0),
|
|
2300
|
+
(y || g) && (b = i),
|
|
2301
|
+
(u = !0);
|
|
2302
|
+
break;
|
|
2303
|
+
case "anchor":
|
|
2304
|
+
y && o(i, "MULTIPLE_ANCHORS", "A node can have at most one anchor"),
|
|
2305
|
+
i.source.endsWith(":") &&
|
|
2306
|
+
o(i.offset + i.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", !0),
|
|
2307
|
+
(y = i),
|
|
2308
|
+
null === v && (v = i.offset),
|
|
2309
|
+
(l = !1),
|
|
2310
|
+
(u = !1),
|
|
2311
|
+
(p = !0);
|
|
2312
|
+
break;
|
|
2313
|
+
case "tag":
|
|
2314
|
+
g && o(i, "MULTIPLE_TAGS", "A node can have at most one tag"),
|
|
2315
|
+
(g = i),
|
|
2316
|
+
null === v && (v = i.offset),
|
|
2317
|
+
(l = !1),
|
|
2318
|
+
(u = !1),
|
|
2319
|
+
(p = !0);
|
|
2320
|
+
break;
|
|
2321
|
+
case n:
|
|
2322
|
+
(y || g) && o(i, "BAD_PROP_ORDER", `Anchors and tags must be after the ${i.source} indicator`),
|
|
2323
|
+
w && o(i, "UNEXPECTED_TOKEN", `Unexpected ${i.source} in ${t ?? "collection"}`),
|
|
2324
|
+
(w = i),
|
|
2325
|
+
(l = "seq-item-ind" === n || "explicit-key-ind" === n),
|
|
2326
|
+
(u = !1);
|
|
2327
|
+
break;
|
|
2328
|
+
case "comma":
|
|
2329
|
+
if (t) {
|
|
2330
|
+
k && o(i, "UNEXPECTED_TOKEN", `Unexpected , in ${t}`), (k = i), (l = !1), (u = !1);
|
|
2331
|
+
break;
|
|
2332
|
+
}
|
|
2333
|
+
default:
|
|
2334
|
+
o(i, "UNEXPECTED_TOKEN", `Unexpected ${i.type} token`), (l = !1), (u = !1);
|
|
2335
|
+
}
|
|
2336
|
+
const S = e[e.length - 1],
|
|
2337
|
+
E = S ? S.offset + S.source.length : i;
|
|
2338
|
+
return (
|
|
2339
|
+
p &&
|
|
2340
|
+
s &&
|
|
2341
|
+
"space" !== s.type &&
|
|
2342
|
+
"newline" !== s.type &&
|
|
2343
|
+
"comma" !== s.type &&
|
|
2344
|
+
("scalar" !== s.type || "" !== s.source) &&
|
|
2345
|
+
o(s.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"),
|
|
2346
|
+
m &&
|
|
2347
|
+
((l && m.indent <= r) || "block-map" === s?.type || "block-seq" === s?.type) &&
|
|
2348
|
+
o(m, "TAB_AS_INDENT", "Tabs are not allowed as indentation"),
|
|
2349
|
+
{
|
|
2350
|
+
comma: k,
|
|
2351
|
+
found: w,
|
|
2352
|
+
spaceBefore: c,
|
|
2353
|
+
comment: f,
|
|
2354
|
+
hasNewline: d,
|
|
2355
|
+
anchor: y,
|
|
2356
|
+
tag: g,
|
|
2357
|
+
newlineAfterProp: b,
|
|
2358
|
+
end: E,
|
|
2359
|
+
start: v ?? E,
|
|
2360
|
+
}
|
|
2361
|
+
);
|
|
2362
|
+
}
|
|
2363
|
+
function Tt(e) {
|
|
2364
|
+
if (!e) return null;
|
|
2365
|
+
switch (e.type) {
|
|
2366
|
+
case "alias":
|
|
2367
|
+
case "scalar":
|
|
2368
|
+
case "double-quoted-scalar":
|
|
2369
|
+
case "single-quoted-scalar":
|
|
2370
|
+
if (e.source.includes("\n")) return !0;
|
|
2371
|
+
if (e.end) for (const t of e.end) if ("newline" === t.type) return !0;
|
|
2372
|
+
return !1;
|
|
2373
|
+
case "flow-collection":
|
|
2374
|
+
for (const t of e.items) {
|
|
2375
|
+
for (const e of t.start) if ("newline" === e.type) return !0;
|
|
2376
|
+
if (t.sep) for (const e of t.sep) if ("newline" === e.type) return !0;
|
|
2377
|
+
if (Tt(t.key) || Tt(t.value)) return !0;
|
|
2378
|
+
}
|
|
2379
|
+
return !1;
|
|
2380
|
+
default:
|
|
2381
|
+
return !0;
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
function Lt(e, t, n) {
|
|
2385
|
+
if ("flow-collection" === t?.type) {
|
|
2386
|
+
const s = t.end[0];
|
|
2387
|
+
if (s.indent === e && ("]" === s.source || "}" === s.source) && Tt(t)) {
|
|
2388
|
+
n(s, "BAD_INDENT", "Flow end indicator should be more indented than parent", !0);
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
function xt(e, t, n) {
|
|
2393
|
+
const { uniqueKeys: s } = e.options;
|
|
2394
|
+
if (!1 === s) return !1;
|
|
2395
|
+
const i = "function" == typeof s ? s : (e, t) => e === t || (h(e) && h(t) && e.value === t.value);
|
|
2396
|
+
return t.some((e) => i(e.key, n));
|
|
2397
|
+
}
|
|
2398
|
+
const $t = "All mapping items must start at the same column";
|
|
2399
|
+
function Ct(e, t, n, s) {
|
|
2400
|
+
let i = "";
|
|
2401
|
+
if (e) {
|
|
2402
|
+
let o = !1,
|
|
2403
|
+
r = "";
|
|
2404
|
+
for (const a of e) {
|
|
2405
|
+
const { source: e, type: c } = a;
|
|
2406
|
+
switch (c) {
|
|
2407
|
+
case "space":
|
|
2408
|
+
o = !0;
|
|
2409
|
+
break;
|
|
2410
|
+
case "comment": {
|
|
2411
|
+
n && !o && s(a, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
|
|
2412
|
+
const t = e.substring(1) || " ";
|
|
2413
|
+
i ? (i += r + t) : (i = t), (r = "");
|
|
2414
|
+
break;
|
|
2415
|
+
}
|
|
2416
|
+
case "newline":
|
|
2417
|
+
i && (r += e), (o = !0);
|
|
2418
|
+
break;
|
|
2419
|
+
default:
|
|
2420
|
+
s(a, "UNEXPECTED_TOKEN", `Unexpected ${c} at node end`);
|
|
2421
|
+
}
|
|
2422
|
+
t += e.length;
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
return { comment: i, offset: t };
|
|
2426
|
+
}
|
|
2427
|
+
const _t = "Block collections are not allowed within flow collections",
|
|
2428
|
+
Kt = (e) => e && ("block-map" === e.type || "block-seq" === e.type);
|
|
2429
|
+
function Bt(e, t, n, s, i, o) {
|
|
2430
|
+
const r =
|
|
2431
|
+
"block-map" === n.type
|
|
2432
|
+
? (function ({ composeNode: e, composeEmptyNode: t }, n, s, i, o) {
|
|
2433
|
+
const r = new (o?.nodeClass ?? we)(n.schema);
|
|
2434
|
+
n.atRoot && (n.atRoot = !1);
|
|
2435
|
+
let a = s.offset,
|
|
2436
|
+
c = null;
|
|
2437
|
+
for (const o of s.items) {
|
|
2438
|
+
const { start: l, key: u, sep: f, value: h } = o,
|
|
2439
|
+
d = It(l, {
|
|
2440
|
+
indicator: "explicit-key-ind",
|
|
2441
|
+
next: u ?? f?.[0],
|
|
2442
|
+
offset: a,
|
|
2443
|
+
onError: i,
|
|
2444
|
+
parentIndent: s.indent,
|
|
2445
|
+
startOnNewline: !0,
|
|
2446
|
+
}),
|
|
2447
|
+
p = !d.found;
|
|
2448
|
+
if (p) {
|
|
2449
|
+
if (
|
|
2450
|
+
(u &&
|
|
2451
|
+
("block-seq" === u.type
|
|
2452
|
+
? i(a, "BLOCK_AS_IMPLICIT_KEY", "A block sequence may not be used as an implicit map key")
|
|
2453
|
+
: "indent" in u && u.indent !== s.indent && i(a, "BAD_INDENT", $t)),
|
|
2454
|
+
!d.anchor && !d.tag && !f)
|
|
2455
|
+
) {
|
|
2456
|
+
(c = d.end), d.comment && (r.comment ? (r.comment += "\n" + d.comment) : (r.comment = d.comment));
|
|
2457
|
+
continue;
|
|
2458
|
+
}
|
|
2459
|
+
(d.newlineAfterProp || Tt(u)) &&
|
|
2460
|
+
i(u ?? l[l.length - 1], "MULTILINE_IMPLICIT_KEY", "Implicit keys need to be on a single line");
|
|
2461
|
+
} else d.found?.indent !== s.indent && i(a, "BAD_INDENT", $t);
|
|
2462
|
+
n.atKey = !0;
|
|
2463
|
+
const m = d.end,
|
|
2464
|
+
y = u ? e(n, u, d, i) : t(n, m, l, null, d, i);
|
|
2465
|
+
n.schema.compat && Lt(s.indent, u, i),
|
|
2466
|
+
(n.atKey = !1),
|
|
2467
|
+
xt(n, r.items, y) && i(m, "DUPLICATE_KEY", "Map keys must be unique");
|
|
2468
|
+
const g = It(f ?? [], {
|
|
2469
|
+
indicator: "map-value-ind",
|
|
2470
|
+
next: h,
|
|
2471
|
+
offset: y.range[2],
|
|
2472
|
+
onError: i,
|
|
2473
|
+
parentIndent: s.indent,
|
|
2474
|
+
startOnNewline: !u || "block-scalar" === u.type,
|
|
2475
|
+
});
|
|
2476
|
+
if (((a = g.end), g.found)) {
|
|
2477
|
+
p &&
|
|
2478
|
+
("block-map" !== h?.type ||
|
|
2479
|
+
g.hasNewline ||
|
|
2480
|
+
i(a, "BLOCK_AS_IMPLICIT_KEY", "Nested mappings are not allowed in compact mappings"),
|
|
2481
|
+
n.options.strict &&
|
|
2482
|
+
d.start < g.found.offset - 1024 &&
|
|
2483
|
+
i(
|
|
2484
|
+
y.range,
|
|
2485
|
+
"KEY_OVER_1024_CHARS",
|
|
2486
|
+
"The : indicator must be at most 1024 chars after the start of an implicit block mapping key"
|
|
2487
|
+
));
|
|
2488
|
+
const c = h ? e(n, h, g, i) : t(n, a, f, null, g, i);
|
|
2489
|
+
n.schema.compat && Lt(s.indent, h, i), (a = c.range[2]);
|
|
2490
|
+
const l = new pe(y, c);
|
|
2491
|
+
n.options.keepSourceTokens && (l.srcToken = o), r.items.push(l);
|
|
2492
|
+
} else {
|
|
2493
|
+
p && i(y.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values"),
|
|
2494
|
+
g.comment && (y.comment ? (y.comment += "\n" + g.comment) : (y.comment = g.comment));
|
|
2495
|
+
const e = new pe(y);
|
|
2496
|
+
n.options.keepSourceTokens && (e.srcToken = o), r.items.push(e);
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
return (
|
|
2500
|
+
c && c < a && i(c, "IMPOSSIBLE", "Map comment with trailing content"),
|
|
2501
|
+
(r.range = [s.offset, a, c ?? a]),
|
|
2502
|
+
r
|
|
2503
|
+
);
|
|
2504
|
+
})(e, t, n, s, o)
|
|
2505
|
+
: "block-seq" === n.type
|
|
2506
|
+
? (function ({ composeNode: e, composeEmptyNode: t }, n, s, i, o) {
|
|
2507
|
+
const r = new (o?.nodeClass ?? Se)(n.schema);
|
|
2508
|
+
n.atRoot && (n.atRoot = !1), n.atKey && (n.atKey = !1);
|
|
2509
|
+
let a = s.offset,
|
|
2510
|
+
c = null;
|
|
2511
|
+
for (const { start: o, value: l } of s.items) {
|
|
2512
|
+
const u = It(o, {
|
|
2513
|
+
indicator: "seq-item-ind",
|
|
2514
|
+
next: l,
|
|
2515
|
+
offset: a,
|
|
2516
|
+
onError: i,
|
|
2517
|
+
parentIndent: s.indent,
|
|
2518
|
+
startOnNewline: !0,
|
|
2519
|
+
});
|
|
2520
|
+
if (!u.found) {
|
|
2521
|
+
if (!(u.anchor || u.tag || l)) {
|
|
2522
|
+
(c = u.end), u.comment && (r.comment = u.comment);
|
|
2523
|
+
continue;
|
|
2524
|
+
}
|
|
2525
|
+
l && "block-seq" === l.type
|
|
2526
|
+
? i(u.end, "BAD_INDENT", "All sequence items must start at the same column")
|
|
2527
|
+
: i(a, "MISSING_CHAR", "Sequence item without - indicator");
|
|
2528
|
+
}
|
|
2529
|
+
const f = l ? e(n, l, u, i) : t(n, u.end, o, null, u, i);
|
|
2530
|
+
n.schema.compat && Lt(s.indent, l, i), (a = f.range[2]), r.items.push(f);
|
|
2531
|
+
}
|
|
2532
|
+
return (r.range = [s.offset, a, c ?? a]), r;
|
|
2533
|
+
})(e, t, n, s, o)
|
|
2534
|
+
: (function ({ composeNode: e, composeEmptyNode: t }, n, s, i, o) {
|
|
2535
|
+
const r = "{" === s.start.source,
|
|
2536
|
+
a = r ? "flow map" : "flow sequence",
|
|
2537
|
+
c = new (o?.nodeClass ?? (r ? we : Se))(n.schema);
|
|
2538
|
+
c.flow = !0;
|
|
2539
|
+
const l = n.atRoot;
|
|
2540
|
+
l && (n.atRoot = !1), n.atKey && (n.atKey = !1);
|
|
2541
|
+
let u = s.offset + s.start.source.length;
|
|
2542
|
+
for (let o = 0; o < s.items.length; ++o) {
|
|
2543
|
+
const l = s.items[o],
|
|
2544
|
+
{ start: h, key: d, sep: p, value: m } = l,
|
|
2545
|
+
y = It(h, {
|
|
2546
|
+
flow: a,
|
|
2547
|
+
indicator: "explicit-key-ind",
|
|
2548
|
+
next: d ?? p?.[0],
|
|
2549
|
+
offset: u,
|
|
2550
|
+
onError: i,
|
|
2551
|
+
parentIndent: s.indent,
|
|
2552
|
+
startOnNewline: !1,
|
|
2553
|
+
});
|
|
2554
|
+
if (!y.found) {
|
|
2555
|
+
if (!(y.anchor || y.tag || p || m)) {
|
|
2556
|
+
0 === o && y.comma
|
|
2557
|
+
? i(y.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${a}`)
|
|
2558
|
+
: o < s.items.length - 1 && i(y.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${a}`),
|
|
2559
|
+
y.comment && (c.comment ? (c.comment += "\n" + y.comment) : (c.comment = y.comment)),
|
|
2560
|
+
(u = y.end);
|
|
2561
|
+
continue;
|
|
2562
|
+
}
|
|
2563
|
+
!r &&
|
|
2564
|
+
n.options.strict &&
|
|
2565
|
+
Tt(d) &&
|
|
2566
|
+
i(
|
|
2567
|
+
d,
|
|
2568
|
+
"MULTILINE_IMPLICIT_KEY",
|
|
2569
|
+
"Implicit keys of flow sequence pairs need to be on a single line"
|
|
2570
|
+
);
|
|
2571
|
+
}
|
|
2572
|
+
if (0 === o) y.comma && i(y.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${a}`);
|
|
2573
|
+
else if ((y.comma || i(y.start, "MISSING_CHAR", `Missing , between ${a} items`), y.comment)) {
|
|
2574
|
+
let e = "";
|
|
2575
|
+
e: for (const t of h)
|
|
2576
|
+
switch (t.type) {
|
|
2577
|
+
case "comma":
|
|
2578
|
+
case "space":
|
|
2579
|
+
break;
|
|
2580
|
+
case "comment":
|
|
2581
|
+
e = t.source.substring(1);
|
|
2582
|
+
break e;
|
|
2583
|
+
default:
|
|
2584
|
+
break e;
|
|
2585
|
+
}
|
|
2586
|
+
if (e) {
|
|
2587
|
+
let t = c.items[c.items.length - 1];
|
|
2588
|
+
f(t) && (t = t.value ?? t.key),
|
|
2589
|
+
t.comment ? (t.comment += "\n" + e) : (t.comment = e),
|
|
2590
|
+
(y.comment = y.comment.substring(e.length + 1));
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
if (r || p || y.found) {
|
|
2594
|
+
n.atKey = !0;
|
|
2595
|
+
const o = y.end,
|
|
2596
|
+
f = d ? e(n, d, y, i) : t(n, o, h, null, y, i);
|
|
2597
|
+
Kt(d) && i(f.range, "BLOCK_IN_FLOW", _t), (n.atKey = !1);
|
|
2598
|
+
const g = It(p ?? [], {
|
|
2599
|
+
flow: a,
|
|
2600
|
+
indicator: "map-value-ind",
|
|
2601
|
+
next: m,
|
|
2602
|
+
offset: f.range[2],
|
|
2603
|
+
onError: i,
|
|
2604
|
+
parentIndent: s.indent,
|
|
2605
|
+
startOnNewline: !1,
|
|
2606
|
+
});
|
|
2607
|
+
if (g.found) {
|
|
2608
|
+
if (!r && !y.found && n.options.strict) {
|
|
2609
|
+
if (p)
|
|
2610
|
+
for (const e of p) {
|
|
2611
|
+
if (e === g.found) break;
|
|
2612
|
+
if ("newline" === e.type) {
|
|
2613
|
+
i(
|
|
2614
|
+
e,
|
|
2615
|
+
"MULTILINE_IMPLICIT_KEY",
|
|
2616
|
+
"Implicit keys of flow sequence pairs need to be on a single line"
|
|
2617
|
+
);
|
|
2618
|
+
break;
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
y.start < g.found.offset - 1024 &&
|
|
2622
|
+
i(
|
|
2623
|
+
g.found,
|
|
2624
|
+
"KEY_OVER_1024_CHARS",
|
|
2625
|
+
"The : indicator must be at most 1024 chars after the start of an implicit flow sequence key"
|
|
2626
|
+
);
|
|
2627
|
+
}
|
|
2628
|
+
} else
|
|
2629
|
+
m &&
|
|
2630
|
+
("source" in m && m.source && ":" === m.source[0]
|
|
2631
|
+
? i(m, "MISSING_CHAR", `Missing space after : in ${a}`)
|
|
2632
|
+
: i(g.start, "MISSING_CHAR", `Missing , or : between ${a} items`));
|
|
2633
|
+
const b = m ? e(n, m, g, i) : g.found ? t(n, g.end, p, null, g, i) : null;
|
|
2634
|
+
b
|
|
2635
|
+
? Kt(m) && i(b.range, "BLOCK_IN_FLOW", _t)
|
|
2636
|
+
: g.comment && (f.comment ? (f.comment += "\n" + g.comment) : (f.comment = g.comment));
|
|
2637
|
+
const k = new pe(f, b);
|
|
2638
|
+
if ((n.options.keepSourceTokens && (k.srcToken = l), r)) {
|
|
2639
|
+
const e = c;
|
|
2640
|
+
xt(n, e.items, f) && i(o, "DUPLICATE_KEY", "Map keys must be unique"), e.items.push(k);
|
|
2641
|
+
} else {
|
|
2642
|
+
const e = new we(n.schema);
|
|
2643
|
+
(e.flow = !0), e.items.push(k);
|
|
2644
|
+
const t = (b ?? f).range;
|
|
2645
|
+
(e.range = [f.range[0], t[1], t[2]]), c.items.push(e);
|
|
2646
|
+
}
|
|
2647
|
+
u = b ? b.range[2] : g.end;
|
|
2648
|
+
} else {
|
|
2649
|
+
const s = m ? e(n, m, y, i) : t(n, y.end, p, null, y, i);
|
|
2650
|
+
c.items.push(s), (u = s.range[2]), Kt(m) && i(s.range, "BLOCK_IN_FLOW", _t);
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
const h = r ? "}" : "]",
|
|
2654
|
+
[d, ...p] = s.end;
|
|
2655
|
+
let m = u;
|
|
2656
|
+
if (d && d.source === h) m = d.offset + d.source.length;
|
|
2657
|
+
else {
|
|
2658
|
+
const e = a[0].toUpperCase() + a.substring(1);
|
|
2659
|
+
i(
|
|
2660
|
+
u,
|
|
2661
|
+
l ? "MISSING_CHAR" : "BAD_INDENT",
|
|
2662
|
+
l
|
|
2663
|
+
? `${e} must end with a ${h}`
|
|
2664
|
+
: `${e} in block collection must be sufficiently indented and end with a ${h}`
|
|
2665
|
+
),
|
|
2666
|
+
d && 1 !== d.source.length && p.unshift(d);
|
|
2667
|
+
}
|
|
2668
|
+
if (p.length > 0) {
|
|
2669
|
+
const e = Ct(p, m, n.options.strict, i);
|
|
2670
|
+
e.comment && (c.comment ? (c.comment += "\n" + e.comment) : (c.comment = e.comment)),
|
|
2671
|
+
(c.range = [s.offset, m, e.offset]);
|
|
2672
|
+
} else c.range = [s.offset, m, m];
|
|
2673
|
+
return c;
|
|
2674
|
+
})(e, t, n, s, o),
|
|
2675
|
+
a = r.constructor;
|
|
2676
|
+
return "!" === i || i === a.tagName ? ((r.tag = a.tagName), r) : (i && (r.tag = i), r);
|
|
2677
|
+
}
|
|
2678
|
+
function jt(e, t, n) {
|
|
2679
|
+
const s = t.offset,
|
|
2680
|
+
i = (function ({ offset: e, props: t }, n, s) {
|
|
2681
|
+
if ("block-scalar-header" !== t[0].type) return s(t[0], "IMPOSSIBLE", "Block scalar header not found"), null;
|
|
2682
|
+
const { source: i } = t[0],
|
|
2683
|
+
o = i[0];
|
|
2684
|
+
let r = 0,
|
|
2685
|
+
a = "",
|
|
2686
|
+
c = -1;
|
|
2687
|
+
for (let t = 1; t < i.length; ++t) {
|
|
2688
|
+
const n = i[t];
|
|
2689
|
+
if (a || ("-" !== n && "+" !== n)) {
|
|
2690
|
+
const s = Number(n);
|
|
2691
|
+
!r && s ? (r = s) : -1 === c && (c = e + t);
|
|
2692
|
+
} else a = n;
|
|
2693
|
+
}
|
|
2694
|
+
-1 !== c && s(c, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${i}`);
|
|
2695
|
+
let l = !1,
|
|
2696
|
+
u = "",
|
|
2697
|
+
f = i.length;
|
|
2698
|
+
for (let e = 1; e < t.length; ++e) {
|
|
2699
|
+
const i = t[e];
|
|
2700
|
+
switch (i.type) {
|
|
2701
|
+
case "space":
|
|
2702
|
+
l = !0;
|
|
2703
|
+
case "newline":
|
|
2704
|
+
f += i.source.length;
|
|
2705
|
+
break;
|
|
2706
|
+
case "comment":
|
|
2707
|
+
if (n && !l) {
|
|
2708
|
+
s(i, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
|
|
2709
|
+
}
|
|
2710
|
+
(f += i.source.length), (u = i.source.substring(1));
|
|
2711
|
+
break;
|
|
2712
|
+
case "error":
|
|
2713
|
+
s(i, "UNEXPECTED_TOKEN", i.message), (f += i.source.length);
|
|
2714
|
+
break;
|
|
2715
|
+
default: {
|
|
2716
|
+
s(i, "UNEXPECTED_TOKEN", `Unexpected token in block scalar header: ${i.type}`);
|
|
2717
|
+
const e = i.source;
|
|
2718
|
+
e && "string" == typeof e && (f += e.length);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
return { mode: o, indent: r, chomp: a, comment: u, length: f };
|
|
2723
|
+
})(t, e.options.strict, n);
|
|
2724
|
+
if (!i) return { value: "", type: null, comment: "", range: [s, s, s] };
|
|
2725
|
+
const o = ">" === i.mode ? D.BLOCK_FOLDED : D.BLOCK_LITERAL,
|
|
2726
|
+
r = t.source
|
|
2727
|
+
? (function (e) {
|
|
2728
|
+
const t = e.split(/\n( *)/),
|
|
2729
|
+
n = t[0],
|
|
2730
|
+
s = n.match(/^( *)/),
|
|
2731
|
+
i = [s?.[1] ? [s[1], n.slice(s[1].length)] : ["", n]];
|
|
2732
|
+
for (let e = 1; e < t.length; e += 2) i.push([t[e], t[e + 1]]);
|
|
2733
|
+
return i;
|
|
2734
|
+
})(t.source)
|
|
2735
|
+
: [];
|
|
2736
|
+
let a = r.length;
|
|
2737
|
+
for (let e = r.length - 1; e >= 0; --e) {
|
|
2738
|
+
const t = r[e][1];
|
|
2739
|
+
if ("" !== t && "\r" !== t) break;
|
|
2740
|
+
a = e;
|
|
2741
|
+
}
|
|
2742
|
+
if (0 === a) {
|
|
2743
|
+
const e = "+" === i.chomp && r.length > 0 ? "\n".repeat(Math.max(1, r.length - 1)) : "";
|
|
2744
|
+
let n = s + i.length;
|
|
2745
|
+
return t.source && (n += t.source.length), { value: e, type: o, comment: i.comment, range: [s, n, n] };
|
|
2746
|
+
}
|
|
2747
|
+
let c = t.indent + i.indent,
|
|
2748
|
+
l = t.offset + i.length,
|
|
2749
|
+
u = 0;
|
|
2750
|
+
for (let t = 0; t < a; ++t) {
|
|
2751
|
+
const [s, o] = r[t];
|
|
2752
|
+
if ("" !== o && "\r" !== o) {
|
|
2753
|
+
if (s.length < c) {
|
|
2754
|
+
const e = "Block scalars with more-indented leading empty lines must use an explicit indentation indicator";
|
|
2755
|
+
n(l + s.length, "MISSING_CHAR", e);
|
|
2756
|
+
}
|
|
2757
|
+
if ((0 === i.indent && (c = s.length), (u = t), 0 === c && !e.atRoot)) {
|
|
2758
|
+
n(l, "BAD_INDENT", "Block scalar values in collections must be indented");
|
|
2759
|
+
}
|
|
2760
|
+
break;
|
|
2761
|
+
}
|
|
2762
|
+
0 === i.indent && s.length > c && (c = s.length), (l += s.length + o.length + 1);
|
|
2763
|
+
}
|
|
2764
|
+
for (let e = r.length - 1; e >= a; --e) r[e][0].length > c && (a = e + 1);
|
|
2765
|
+
let f = "",
|
|
2766
|
+
h = "",
|
|
2767
|
+
d = !1;
|
|
2768
|
+
for (let e = 0; e < u; ++e) f += r[e][0].slice(c) + "\n";
|
|
2769
|
+
for (let e = u; e < a; ++e) {
|
|
2770
|
+
let [t, s] = r[e];
|
|
2771
|
+
l += t.length + s.length + 1;
|
|
2772
|
+
const a = "\r" === s[s.length - 1];
|
|
2773
|
+
if ((a && (s = s.slice(0, -1)), s && t.length < c)) {
|
|
2774
|
+
const e = `Block scalar lines must not be less indented than their ${i.indent ? "explicit indentation indicator" : "first line"}`;
|
|
2775
|
+
n(l - s.length - (a ? 2 : 1), "BAD_INDENT", e), (t = "");
|
|
2776
|
+
}
|
|
2777
|
+
o === D.BLOCK_LITERAL
|
|
2778
|
+
? ((f += h + t.slice(c) + s), (h = "\n"))
|
|
2779
|
+
: t.length > c || "\t" === s[0]
|
|
2780
|
+
? (" " === h ? (h = "\n") : d || "\n" !== h || (h = "\n\n"), (f += h + t.slice(c) + s), (h = "\n"), (d = !0))
|
|
2781
|
+
: "" === s
|
|
2782
|
+
? "\n" === h
|
|
2783
|
+
? (f += "\n")
|
|
2784
|
+
: (h = "\n")
|
|
2785
|
+
: ((f += h + s), (h = " "), (d = !1));
|
|
2786
|
+
}
|
|
2787
|
+
switch (i.chomp) {
|
|
2788
|
+
case "-":
|
|
2789
|
+
break;
|
|
2790
|
+
case "+":
|
|
2791
|
+
for (let e = a; e < r.length; ++e) f += "\n" + r[e][0].slice(c);
|
|
2792
|
+
"\n" !== f[f.length - 1] && (f += "\n");
|
|
2793
|
+
break;
|
|
2794
|
+
default:
|
|
2795
|
+
f += "\n";
|
|
2796
|
+
}
|
|
2797
|
+
const p = s + i.length + t.source.length;
|
|
2798
|
+
return { value: f, type: o, comment: i.comment, range: [s, p, p] };
|
|
2799
|
+
}
|
|
2800
|
+
function Mt(e, t, n) {
|
|
2801
|
+
const { offset: s, type: i, source: o, end: r } = e;
|
|
2802
|
+
let a, c;
|
|
2803
|
+
const l = (e, t, i) => n(s + e, t, i);
|
|
2804
|
+
switch (i) {
|
|
2805
|
+
case "scalar":
|
|
2806
|
+
(a = D.PLAIN),
|
|
2807
|
+
(c = (function (e, t) {
|
|
2808
|
+
let n = "";
|
|
2809
|
+
switch (e[0]) {
|
|
2810
|
+
case "\t":
|
|
2811
|
+
n = "a tab character";
|
|
2812
|
+
break;
|
|
2813
|
+
case ",":
|
|
2814
|
+
n = "flow indicator character ,";
|
|
2815
|
+
break;
|
|
2816
|
+
case "%":
|
|
2817
|
+
n = "directive indicator character %";
|
|
2818
|
+
break;
|
|
2819
|
+
case "|":
|
|
2820
|
+
case ">":
|
|
2821
|
+
n = `block scalar indicator ${e[0]}`;
|
|
2822
|
+
break;
|
|
2823
|
+
case "@":
|
|
2824
|
+
case "`":
|
|
2825
|
+
n = `reserved character ${e[0]}`;
|
|
2826
|
+
}
|
|
2827
|
+
n && t(0, "BAD_SCALAR_START", `Plain value cannot start with ${n}`);
|
|
2828
|
+
return Dt(e);
|
|
2829
|
+
})(o, l));
|
|
2830
|
+
break;
|
|
2831
|
+
case "single-quoted-scalar":
|
|
2832
|
+
(a = D.QUOTE_SINGLE),
|
|
2833
|
+
(c = (function (e, t) {
|
|
2834
|
+
("'" === e[e.length - 1] && 1 !== e.length) || t(e.length, "MISSING_CHAR", "Missing closing 'quote");
|
|
2835
|
+
return Dt(e.slice(1, -1)).replace(/''/g, "'");
|
|
2836
|
+
})(o, l));
|
|
2837
|
+
break;
|
|
2838
|
+
case "double-quoted-scalar":
|
|
2839
|
+
(a = D.QUOTE_DOUBLE),
|
|
2840
|
+
(c = (function (e, t) {
|
|
2841
|
+
let n = "";
|
|
2842
|
+
for (let s = 1; s < e.length - 1; ++s) {
|
|
2843
|
+
const i = e[s];
|
|
2844
|
+
if ("\r" !== i || "\n" !== e[s + 1])
|
|
2845
|
+
if ("\n" === i) {
|
|
2846
|
+
const { fold: t, offset: i } = qt(e, s);
|
|
2847
|
+
(n += t), (s = i);
|
|
2848
|
+
} else if ("\\" === i) {
|
|
2849
|
+
let i = e[++s];
|
|
2850
|
+
const o = Pt[i];
|
|
2851
|
+
if (o) n += o;
|
|
2852
|
+
else if ("\n" === i) for (i = e[s + 1]; " " === i || "\t" === i;) i = e[1 + ++s];
|
|
2853
|
+
else if ("\r" === i && "\n" === e[s + 1])
|
|
2854
|
+
for (i = e[1 + ++s]; " " === i || "\t" === i;) i = e[1 + ++s];
|
|
2855
|
+
else if ("x" === i || "u" === i || "U" === i) {
|
|
2856
|
+
const o = { x: 2, u: 4, U: 8 }[i];
|
|
2857
|
+
(n += Ut(e, s + 1, o, t)), (s += o);
|
|
2858
|
+
} else {
|
|
2859
|
+
const i = e.substr(s - 1, 2);
|
|
2860
|
+
t(s - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${i}`), (n += i);
|
|
2861
|
+
}
|
|
2862
|
+
} else if (" " === i || "\t" === i) {
|
|
2863
|
+
const t = s;
|
|
2864
|
+
let o = e[s + 1];
|
|
2865
|
+
for (; " " === o || "\t" === o;) o = e[1 + ++s];
|
|
2866
|
+
"\n" === o || ("\r" === o && "\n" === e[s + 2]) || (n += s > t ? e.slice(t, s + 1) : i);
|
|
2867
|
+
} else n += i;
|
|
2868
|
+
}
|
|
2869
|
+
('"' === e[e.length - 1] && 1 !== e.length) || t(e.length, "MISSING_CHAR", 'Missing closing "quote');
|
|
2870
|
+
return n;
|
|
2871
|
+
})(o, l));
|
|
2872
|
+
break;
|
|
2873
|
+
default:
|
|
2874
|
+
return (
|
|
2875
|
+
n(e, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${i}`),
|
|
2876
|
+
{ value: "", type: null, comment: "", range: [s, s + o.length, s + o.length] }
|
|
2877
|
+
);
|
|
2878
|
+
}
|
|
2879
|
+
const u = s + o.length,
|
|
2880
|
+
f = Ct(r, u, t, n);
|
|
2881
|
+
return { value: c, type: a, comment: f.comment, range: [s, u, f.offset] };
|
|
2882
|
+
}
|
|
2883
|
+
function Dt(e) {
|
|
2884
|
+
let t, n;
|
|
2885
|
+
try {
|
|
2886
|
+
(t = new RegExp("(.*?)(?<![ \t])[ \t]*\r?\n", "sy")),
|
|
2887
|
+
(n = new RegExp("[ \t]*(.*?)(?:(?<![ \t])[ \t]*)?\r?\n", "sy"));
|
|
2888
|
+
} catch {
|
|
2889
|
+
(t = /(.*?)[ \t]*\r?\n/sy), (n = /[ \t]*(.*?)[ \t]*\r?\n/sy);
|
|
2890
|
+
}
|
|
2891
|
+
let s = t.exec(e);
|
|
2892
|
+
if (!s) return e;
|
|
2893
|
+
let i = s[1],
|
|
2894
|
+
o = " ",
|
|
2895
|
+
r = t.lastIndex;
|
|
2896
|
+
for (n.lastIndex = r; (s = n.exec(e));)
|
|
2897
|
+
"" === s[1] ? ("\n" === o ? (i += o) : (o = "\n")) : ((i += o + s[1]), (o = " ")), (r = n.lastIndex);
|
|
2898
|
+
const a = /[ \t]*(.*)/sy;
|
|
2899
|
+
return (a.lastIndex = r), (s = a.exec(e)), i + o + (s?.[1] ?? "");
|
|
2900
|
+
}
|
|
2901
|
+
function qt(e, t) {
|
|
2902
|
+
let n = "",
|
|
2903
|
+
s = e[t + 1];
|
|
2904
|
+
for (; !((" " !== s && "\t" !== s && "\n" !== s && "\r" !== s) || ("\r" === s && "\n" !== e[t + 2]));)
|
|
2905
|
+
"\n" === s && (n += "\n"), (s = e[(t += 1) + 1]);
|
|
2906
|
+
return n || (n = " "), { fold: n, offset: t };
|
|
2907
|
+
}
|
|
2908
|
+
const Pt = {
|
|
2909
|
+
0: "\0",
|
|
2910
|
+
a: "",
|
|
2911
|
+
b: "\b",
|
|
2912
|
+
e: "",
|
|
2913
|
+
f: "\f",
|
|
2914
|
+
n: "\n",
|
|
2915
|
+
r: "\r",
|
|
2916
|
+
t: "\t",
|
|
2917
|
+
v: "\v",
|
|
2918
|
+
N: "
",
|
|
2919
|
+
_: " ",
|
|
2920
|
+
L: "\u2028",
|
|
2921
|
+
P: "\u2029",
|
|
2922
|
+
" ": " ",
|
|
2923
|
+
'"': '"',
|
|
2924
|
+
"/": "/",
|
|
2925
|
+
"\\": "\\",
|
|
2926
|
+
"\t": "\t",
|
|
2927
|
+
};
|
|
2928
|
+
function Ut(e, t, n, s) {
|
|
2929
|
+
const i = e.substr(t, n),
|
|
2930
|
+
o = i.length === n && /^[0-9a-fA-F]+$/.test(i) ? parseInt(i, 16) : NaN;
|
|
2931
|
+
if (isNaN(o)) {
|
|
2932
|
+
const i = e.substr(t - 2, n + 2);
|
|
2933
|
+
return s(t - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${i}`), i;
|
|
2934
|
+
}
|
|
2935
|
+
return String.fromCodePoint(o);
|
|
2936
|
+
}
|
|
2937
|
+
function Rt(e, t, n, s) {
|
|
2938
|
+
const {
|
|
2939
|
+
value: i,
|
|
2940
|
+
type: r,
|
|
2941
|
+
comment: a,
|
|
2942
|
+
range: c,
|
|
2943
|
+
} = "block-scalar" === t.type ? jt(e, t, s) : Mt(t, e.options.strict, s),
|
|
2944
|
+
l = n ? e.directives.tagName(n.source, (e) => s(n, "TAG_RESOLVE_FAILED", e)) : null;
|
|
2945
|
+
let u, f;
|
|
2946
|
+
u =
|
|
2947
|
+
e.options.stringKeys && e.atKey
|
|
2948
|
+
? e.schema[o]
|
|
2949
|
+
: l
|
|
2950
|
+
? (function (e, t, n, s, i) {
|
|
2951
|
+
if ("!" === n) return e[o];
|
|
2952
|
+
const r = [];
|
|
2953
|
+
for (const t of e.tags)
|
|
2954
|
+
if (!t.collection && t.tag === n) {
|
|
2955
|
+
if (!t.default || !t.test) return t;
|
|
2956
|
+
r.push(t);
|
|
2957
|
+
}
|
|
2958
|
+
for (const e of r) if (e.test?.test(t)) return e;
|
|
2959
|
+
const a = e.knownTags[n];
|
|
2960
|
+
if (a && !a.collection) return e.tags.push(Object.assign({}, a, { default: !1, test: void 0 })), a;
|
|
2961
|
+
return i(s, "TAG_RESOLVE_FAILED", `Unresolved tag: ${n}`, "tag:yaml.org,2002:str" !== n), e[o];
|
|
2962
|
+
})(e.schema, i, l, n, s)
|
|
2963
|
+
: "scalar" === t.type
|
|
2964
|
+
? (function ({ atKey: e, directives: t, schema: n }, s, i, r) {
|
|
2965
|
+
const a =
|
|
2966
|
+
n.tags.find((t) => (!0 === t.default || (e && "key" === t.default)) && t.test?.test(s)) || n[o];
|
|
2967
|
+
if (n.compat) {
|
|
2968
|
+
const e = n.compat.find((e) => e.default && e.test?.test(s)) ?? n[o];
|
|
2969
|
+
if (a.tag !== e.tag) {
|
|
2970
|
+
r(
|
|
2971
|
+
i,
|
|
2972
|
+
"TAG_RESOLVE_FAILED",
|
|
2973
|
+
`Value may be parsed as either ${t.tagString(a.tag)} or ${t.tagString(e.tag)}`,
|
|
2974
|
+
!0
|
|
2975
|
+
);
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
return a;
|
|
2979
|
+
})(e, i, t, s)
|
|
2980
|
+
: e.schema[o];
|
|
2981
|
+
try {
|
|
2982
|
+
const o = u.resolve(i, (e) => s(n ?? t, "TAG_RESOLVE_FAILED", e), e.options);
|
|
2983
|
+
f = h(o) ? o : new D(o);
|
|
2984
|
+
} catch (e) {
|
|
2985
|
+
const o = e instanceof Error ? e.message : String(e);
|
|
2986
|
+
s(n ?? t, "TAG_RESOLVE_FAILED", o), (f = new D(i));
|
|
2987
|
+
}
|
|
2988
|
+
return (
|
|
2989
|
+
(f.range = c),
|
|
2990
|
+
(f.source = i),
|
|
2991
|
+
r && (f.type = r),
|
|
2992
|
+
l && (f.tag = l),
|
|
2993
|
+
u.format && (f.format = u.format),
|
|
2994
|
+
a && (f.comment = a),
|
|
2995
|
+
f
|
|
2996
|
+
);
|
|
2997
|
+
}
|
|
2998
|
+
function Ft(e, t, n) {
|
|
2999
|
+
if (t) {
|
|
3000
|
+
null === n && (n = t.length);
|
|
3001
|
+
for (let s = n - 1; s >= 0; --s) {
|
|
3002
|
+
let n = t[s];
|
|
3003
|
+
switch (n.type) {
|
|
3004
|
+
case "space":
|
|
3005
|
+
case "comment":
|
|
3006
|
+
case "newline":
|
|
3007
|
+
e -= n.source.length;
|
|
3008
|
+
continue;
|
|
3009
|
+
}
|
|
3010
|
+
for (n = t[++s]; "space" === n?.type;) (e += n.source.length), (n = t[++s]);
|
|
3011
|
+
break;
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
return e;
|
|
3015
|
+
}
|
|
3016
|
+
const Vt = { composeNode: Jt, composeEmptyNode: Yt };
|
|
3017
|
+
function Jt(e, t, n, s) {
|
|
3018
|
+
const i = e.atKey,
|
|
3019
|
+
{ spaceBefore: o, comment: r, anchor: a, tag: c } = n;
|
|
3020
|
+
let l,
|
|
3021
|
+
u = !0;
|
|
3022
|
+
switch (t.type) {
|
|
3023
|
+
case "alias":
|
|
3024
|
+
(l = (function ({ options: e }, { offset: t, source: n, end: s }, i) {
|
|
3025
|
+
const o = new B(n.substring(1));
|
|
3026
|
+
"" === o.source && i(t, "BAD_ALIAS", "Alias cannot be an empty string");
|
|
3027
|
+
o.source.endsWith(":") && i(t + n.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", !0);
|
|
3028
|
+
const r = t + n.length,
|
|
3029
|
+
a = Ct(s, r, e.strict, i);
|
|
3030
|
+
(o.range = [t, r, a.offset]), a.comment && (o.comment = a.comment);
|
|
3031
|
+
return o;
|
|
3032
|
+
})(e, t, s)),
|
|
3033
|
+
(a || c) && s(t, "ALIAS_PROPS", "An alias node must not specify any properties");
|
|
3034
|
+
break;
|
|
3035
|
+
case "scalar":
|
|
3036
|
+
case "single-quoted-scalar":
|
|
3037
|
+
case "double-quoted-scalar":
|
|
3038
|
+
case "block-scalar":
|
|
3039
|
+
(l = Rt(e, t, c, s)), a && (l.anchor = a.source.substring(1));
|
|
3040
|
+
break;
|
|
3041
|
+
case "block-map":
|
|
3042
|
+
case "block-seq":
|
|
3043
|
+
case "flow-collection":
|
|
3044
|
+
(l = (function (e, t, n, s, i) {
|
|
3045
|
+
const o = s.tag,
|
|
3046
|
+
r = o ? t.directives.tagName(o.source, (e) => i(o, "TAG_RESOLVE_FAILED", e)) : null;
|
|
3047
|
+
if ("block-seq" === n.type) {
|
|
3048
|
+
const { anchor: e, newlineAfterProp: t } = s,
|
|
3049
|
+
n = e && o ? (e.offset > o.offset ? e : o) : e ?? o;
|
|
3050
|
+
n && (!t || t.offset < n.offset) && i(n, "MISSING_CHAR", "Missing newline after block sequence props");
|
|
3051
|
+
}
|
|
3052
|
+
const a =
|
|
3053
|
+
"block-map" === n.type ? "map" : "block-seq" === n.type ? "seq" : "{" === n.start.source ? "map" : "seq";
|
|
3054
|
+
if (!o || !r || "!" === r || (r === we.tagName && "map" === a) || (r === Se.tagName && "seq" === a))
|
|
3055
|
+
return Bt(e, t, n, i, r);
|
|
3056
|
+
let c = t.schema.tags.find((e) => e.tag === r && e.collection === a);
|
|
3057
|
+
if (!c) {
|
|
3058
|
+
const s = t.schema.knownTags[r];
|
|
3059
|
+
if (!s || s.collection !== a)
|
|
3060
|
+
return (
|
|
3061
|
+
s
|
|
3062
|
+
? i(
|
|
3063
|
+
o,
|
|
3064
|
+
"BAD_COLLECTION_TYPE",
|
|
3065
|
+
`${s.tag} used for ${a} collection, but expects ${s.collection ?? "scalar"}`,
|
|
3066
|
+
!0
|
|
3067
|
+
)
|
|
3068
|
+
: i(o, "TAG_RESOLVE_FAILED", `Unresolved tag: ${r}`, !0),
|
|
3069
|
+
Bt(e, t, n, i, r)
|
|
3070
|
+
);
|
|
3071
|
+
t.schema.tags.push(Object.assign({}, s, { default: !1 })), (c = s);
|
|
3072
|
+
}
|
|
3073
|
+
const l = Bt(e, t, n, i, r, c),
|
|
3074
|
+
u = c.resolve?.(l, (e) => i(o, "TAG_RESOLVE_FAILED", e), t.options) ?? l,
|
|
3075
|
+
f = m(u) ? u : new D(u);
|
|
3076
|
+
return (f.range = l.range), (f.tag = r), c?.format && (f.format = c.format), f;
|
|
3077
|
+
})(Vt, e, t, n, s)),
|
|
3078
|
+
a && (l.anchor = a.source.substring(1));
|
|
3079
|
+
break;
|
|
3080
|
+
default:
|
|
3081
|
+
s(t, "UNEXPECTED_TOKEN", "error" === t.type ? t.message : `Unsupported token (type: ${t.type})`),
|
|
3082
|
+
(l = Yt(e, t.offset, void 0, null, n, s)),
|
|
3083
|
+
(u = !1);
|
|
3084
|
+
}
|
|
3085
|
+
if (
|
|
3086
|
+
(a && "" === l.anchor && s(a, "BAD_ALIAS", "Anchor cannot be an empty string"),
|
|
3087
|
+
i &&
|
|
3088
|
+
e.options.stringKeys &&
|
|
3089
|
+
(!h(l) || "string" != typeof l.value || (l.tag && "tag:yaml.org,2002:str" !== l.tag)))
|
|
3090
|
+
) {
|
|
3091
|
+
s(c ?? t, "NON_STRING_KEY", "With stringKeys, all keys must be strings");
|
|
3092
|
+
}
|
|
3093
|
+
return (
|
|
3094
|
+
o && (l.spaceBefore = !0),
|
|
3095
|
+
r && ("scalar" === t.type && "" === t.source ? (l.comment = r) : (l.commentBefore = r)),
|
|
3096
|
+
e.options.keepSourceTokens && u && (l.srcToken = t),
|
|
3097
|
+
l
|
|
3098
|
+
);
|
|
3099
|
+
}
|
|
3100
|
+
function Yt(e, t, n, s, { spaceBefore: i, comment: o, anchor: r, tag: a, end: c }, l) {
|
|
3101
|
+
const u = Rt(e, { type: "scalar", offset: Ft(t, n, s), indent: -1, source: "" }, a, l);
|
|
3102
|
+
return (
|
|
3103
|
+
r &&
|
|
3104
|
+
((u.anchor = r.source.substring(1)), "" === u.anchor && l(r, "BAD_ALIAS", "Anchor cannot be an empty string")),
|
|
3105
|
+
i && (u.spaceBefore = !0),
|
|
3106
|
+
o && ((u.comment = o), (u.range[2] = c)),
|
|
3107
|
+
u
|
|
3108
|
+
);
|
|
3109
|
+
}
|
|
3110
|
+
function Wt(e) {
|
|
3111
|
+
if ("number" == typeof e) return [e, e + 1];
|
|
3112
|
+
if (Array.isArray(e)) return 2 === e.length ? e : [e[0], e[1]];
|
|
3113
|
+
const { offset: t, source: n } = e;
|
|
3114
|
+
return [t, t + ("string" == typeof n ? n.length : 1)];
|
|
3115
|
+
}
|
|
3116
|
+
function Gt(e) {
|
|
3117
|
+
let t = "",
|
|
3118
|
+
n = !1,
|
|
3119
|
+
s = !1;
|
|
3120
|
+
for (let i = 0; i < e.length; ++i) {
|
|
3121
|
+
const o = e[i];
|
|
3122
|
+
switch (o[0]) {
|
|
3123
|
+
case "#":
|
|
3124
|
+
(t += ("" === t ? "" : s ? "\n\n" : "\n") + (o.substring(1) || " ")), (n = !0), (s = !1);
|
|
3125
|
+
break;
|
|
3126
|
+
case "%":
|
|
3127
|
+
"#" !== e[i + 1]?.[0] && (i += 1), (n = !1);
|
|
3128
|
+
break;
|
|
3129
|
+
default:
|
|
3130
|
+
n || (s = !0), (n = !1);
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
return { comment: t, afterEmptyLine: s };
|
|
3134
|
+
}
|
|
3135
|
+
class Qt {
|
|
3136
|
+
constructor(e = {}) {
|
|
3137
|
+
(this.doc = null),
|
|
3138
|
+
(this.atDirectives = !1),
|
|
3139
|
+
(this.prelude = []),
|
|
3140
|
+
(this.errors = []),
|
|
3141
|
+
(this.warnings = []),
|
|
3142
|
+
(this.onError = (e, t, n, s) => {
|
|
3143
|
+
const i = Wt(e);
|
|
3144
|
+
s ? this.warnings.push(new Ot(i, t, n)) : this.errors.push(new Nt(i, t, n));
|
|
3145
|
+
}),
|
|
3146
|
+
(this.directives = new T({ version: e.version || "1.2" })),
|
|
3147
|
+
(this.options = e);
|
|
3148
|
+
}
|
|
3149
|
+
decorate(e, t) {
|
|
3150
|
+
const { comment: n, afterEmptyLine: s } = Gt(this.prelude);
|
|
3151
|
+
if (n) {
|
|
3152
|
+
const i = e.contents;
|
|
3153
|
+
if (t) e.comment = e.comment ? `${e.comment}\n${n}` : n;
|
|
3154
|
+
else if (s || e.directives.docStart || !i) e.commentBefore = n;
|
|
3155
|
+
else if (p(i) && !i.flow && i.items.length > 0) {
|
|
3156
|
+
let e = i.items[0];
|
|
3157
|
+
f(e) && (e = e.key);
|
|
3158
|
+
const t = e.commentBefore;
|
|
3159
|
+
e.commentBefore = t ? `${n}\n${t}` : n;
|
|
3160
|
+
} else {
|
|
3161
|
+
const e = i.commentBefore;
|
|
3162
|
+
i.commentBefore = e ? `${n}\n${e}` : n;
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
t
|
|
3166
|
+
? (Array.prototype.push.apply(e.errors, this.errors), Array.prototype.push.apply(e.warnings, this.warnings))
|
|
3167
|
+
: ((e.errors = this.errors), (e.warnings = this.warnings)),
|
|
3168
|
+
(this.prelude = []),
|
|
3169
|
+
(this.errors = []),
|
|
3170
|
+
(this.warnings = []);
|
|
3171
|
+
}
|
|
3172
|
+
streamInfo() {
|
|
3173
|
+
return {
|
|
3174
|
+
comment: Gt(this.prelude).comment,
|
|
3175
|
+
directives: this.directives,
|
|
3176
|
+
errors: this.errors,
|
|
3177
|
+
warnings: this.warnings,
|
|
3178
|
+
};
|
|
3179
|
+
}
|
|
3180
|
+
*compose(e, t = !1, n = -1) {
|
|
3181
|
+
for (const t of e) yield* this.next(t);
|
|
3182
|
+
yield* this.end(t, n);
|
|
3183
|
+
}
|
|
3184
|
+
*next(e) {
|
|
3185
|
+
switch (e.type) {
|
|
3186
|
+
case "directive":
|
|
3187
|
+
this.directives.add(e.source, (t, n, s) => {
|
|
3188
|
+
const i = Wt(e);
|
|
3189
|
+
(i[0] += t), this.onError(i, "BAD_DIRECTIVE", n, s);
|
|
3190
|
+
}),
|
|
3191
|
+
this.prelude.push(e.source),
|
|
3192
|
+
(this.atDirectives = !0);
|
|
3193
|
+
break;
|
|
3194
|
+
case "document": {
|
|
3195
|
+
const t = (function (e, t, { offset: n, start: s, value: i, end: o }, r) {
|
|
3196
|
+
const a = Object.assign({ _directives: t }, e),
|
|
3197
|
+
c = new vt(void 0, a),
|
|
3198
|
+
l = { atKey: !1, atRoot: !0, directives: c.directives, options: c.options, schema: c.schema },
|
|
3199
|
+
u = It(s, {
|
|
3200
|
+
indicator: "doc-start",
|
|
3201
|
+
next: i ?? o?.[0],
|
|
3202
|
+
offset: n,
|
|
3203
|
+
onError: r,
|
|
3204
|
+
parentIndent: 0,
|
|
3205
|
+
startOnNewline: !0,
|
|
3206
|
+
});
|
|
3207
|
+
u.found &&
|
|
3208
|
+
((c.directives.docStart = !0),
|
|
3209
|
+
!i ||
|
|
3210
|
+
("block-map" !== i.type && "block-seq" !== i.type) ||
|
|
3211
|
+
u.hasNewline ||
|
|
3212
|
+
r(u.end, "MISSING_CHAR", "Block collection cannot start on same line with directives-end marker")),
|
|
3213
|
+
(c.contents = i ? Jt(l, i, u, r) : Yt(l, u.end, s, null, u, r));
|
|
3214
|
+
const f = c.contents.range[2],
|
|
3215
|
+
h = Ct(o, f, !1, r);
|
|
3216
|
+
return h.comment && (c.comment = h.comment), (c.range = [n, f, h.offset]), c;
|
|
3217
|
+
})(this.options, this.directives, e, this.onError);
|
|
3218
|
+
this.atDirectives &&
|
|
3219
|
+
!t.directives.docStart &&
|
|
3220
|
+
this.onError(e, "MISSING_CHAR", "Missing directives-end/doc-start indicator line"),
|
|
3221
|
+
this.decorate(t, !1),
|
|
3222
|
+
this.doc && (yield this.doc),
|
|
3223
|
+
(this.doc = t),
|
|
3224
|
+
(this.atDirectives = !1);
|
|
3225
|
+
break;
|
|
3226
|
+
}
|
|
3227
|
+
case "byte-order-mark":
|
|
3228
|
+
case "space":
|
|
3229
|
+
break;
|
|
3230
|
+
case "comment":
|
|
3231
|
+
case "newline":
|
|
3232
|
+
this.prelude.push(e.source);
|
|
3233
|
+
break;
|
|
3234
|
+
case "error": {
|
|
3235
|
+
const t = e.source ? `${e.message}: ${JSON.stringify(e.source)}` : e.message,
|
|
3236
|
+
n = new Nt(Wt(e), "UNEXPECTED_TOKEN", t);
|
|
3237
|
+
this.atDirectives || !this.doc ? this.errors.push(n) : this.doc.errors.push(n);
|
|
3238
|
+
break;
|
|
3239
|
+
}
|
|
3240
|
+
case "doc-end": {
|
|
3241
|
+
if (!this.doc) {
|
|
3242
|
+
const t = "Unexpected doc-end without preceding document";
|
|
3243
|
+
this.errors.push(new Nt(Wt(e), "UNEXPECTED_TOKEN", t));
|
|
3244
|
+
break;
|
|
3245
|
+
}
|
|
3246
|
+
this.doc.directives.docEnd = !0;
|
|
3247
|
+
const t = Ct(e.end, e.offset + e.source.length, this.doc.options.strict, this.onError);
|
|
3248
|
+
if ((this.decorate(this.doc, !0), t.comment)) {
|
|
3249
|
+
const e = this.doc.comment;
|
|
3250
|
+
this.doc.comment = e ? `${e}\n${t.comment}` : t.comment;
|
|
3251
|
+
}
|
|
3252
|
+
this.doc.range[2] = t.offset;
|
|
3253
|
+
break;
|
|
3254
|
+
}
|
|
3255
|
+
default:
|
|
3256
|
+
this.errors.push(new Nt(Wt(e), "UNEXPECTED_TOKEN", `Unsupported token ${e.type}`));
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
*end(e = !1, t = -1) {
|
|
3260
|
+
if (this.doc) this.decorate(this.doc, !0), yield this.doc, (this.doc = null);
|
|
3261
|
+
else if (e) {
|
|
3262
|
+
const e = Object.assign({ _directives: this.directives }, this.options),
|
|
3263
|
+
n = new vt(void 0, e);
|
|
3264
|
+
this.atDirectives && this.onError(t, "MISSING_CHAR", "Missing directives-end indicator line"),
|
|
3265
|
+
(n.range = [0, t, t]),
|
|
3266
|
+
this.decorate(n, !1),
|
|
3267
|
+
yield n;
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
function Ht(e, t) {
|
|
3272
|
+
if (t)
|
|
3273
|
+
for (const n of t)
|
|
3274
|
+
switch (n.type) {
|
|
3275
|
+
case "space":
|
|
3276
|
+
case "comment":
|
|
3277
|
+
e.push(n);
|
|
3278
|
+
break;
|
|
3279
|
+
case "newline":
|
|
3280
|
+
return e.push(n), !0;
|
|
3281
|
+
}
|
|
3282
|
+
return !1;
|
|
3283
|
+
}
|
|
3284
|
+
function Xt(e, t, n) {
|
|
3285
|
+
switch (e.type) {
|
|
3286
|
+
case "scalar":
|
|
3287
|
+
case "double-quoted-scalar":
|
|
3288
|
+
case "single-quoted-scalar":
|
|
3289
|
+
(e.type = n), (e.source = t);
|
|
3290
|
+
break;
|
|
3291
|
+
case "block-scalar": {
|
|
3292
|
+
const s = e.props.slice(1);
|
|
3293
|
+
let i = t.length;
|
|
3294
|
+
"block-scalar-header" === e.props[0].type && (i -= e.props[0].source.length);
|
|
3295
|
+
for (const e of s) e.offset += i;
|
|
3296
|
+
delete e.props, Object.assign(e, { type: n, source: t, end: s });
|
|
3297
|
+
break;
|
|
3298
|
+
}
|
|
3299
|
+
case "block-map":
|
|
3300
|
+
case "block-seq": {
|
|
3301
|
+
const s = { type: "newline", offset: e.offset + t.length, indent: e.indent, source: "\n" };
|
|
3302
|
+
delete e.items, Object.assign(e, { type: n, source: t, end: [s] });
|
|
3303
|
+
break;
|
|
3304
|
+
}
|
|
3305
|
+
default: {
|
|
3306
|
+
const s = "indent" in e ? e.indent : -1,
|
|
3307
|
+
i =
|
|
3308
|
+
"end" in e && Array.isArray(e.end)
|
|
3309
|
+
? e.end.filter((e) => "space" === e.type || "comment" === e.type || "newline" === e.type)
|
|
3310
|
+
: [];
|
|
3311
|
+
for (const t of Object.keys(e)) "type" !== t && "offset" !== t && delete e[t];
|
|
3312
|
+
Object.assign(e, { type: n, indent: s, source: t, end: i });
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
function zt(e) {
|
|
3317
|
+
switch (e.type) {
|
|
3318
|
+
case "block-scalar": {
|
|
3319
|
+
let t = "";
|
|
3320
|
+
for (const n of e.props) t += zt(n);
|
|
3321
|
+
return t + e.source;
|
|
3322
|
+
}
|
|
3323
|
+
case "block-map":
|
|
3324
|
+
case "block-seq": {
|
|
3325
|
+
let t = "";
|
|
3326
|
+
for (const n of e.items) t += Zt(n);
|
|
3327
|
+
return t;
|
|
3328
|
+
}
|
|
3329
|
+
case "flow-collection": {
|
|
3330
|
+
let t = e.start.source;
|
|
3331
|
+
for (const n of e.items) t += Zt(n);
|
|
3332
|
+
for (const n of e.end) t += n.source;
|
|
3333
|
+
return t;
|
|
3334
|
+
}
|
|
3335
|
+
case "document": {
|
|
3336
|
+
let t = Zt(e);
|
|
3337
|
+
if (e.end) for (const n of e.end) t += n.source;
|
|
3338
|
+
return t;
|
|
3339
|
+
}
|
|
3340
|
+
default: {
|
|
3341
|
+
let t = e.source;
|
|
3342
|
+
if ("end" in e && e.end) for (const n of e.end) t += n.source;
|
|
3343
|
+
return t;
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
function Zt({ start: e, key: t, sep: n, value: s }) {
|
|
3348
|
+
let i = "";
|
|
3349
|
+
for (const t of e) i += t.source;
|
|
3350
|
+
if ((t && (i += zt(t)), n)) for (const e of n) i += e.source;
|
|
3351
|
+
return s && (i += zt(s)), i;
|
|
3352
|
+
}
|
|
3353
|
+
const en = Symbol("break visit"),
|
|
3354
|
+
tn = Symbol("skip children"),
|
|
3355
|
+
nn = Symbol("remove item");
|
|
3356
|
+
function sn(e, t) {
|
|
3357
|
+
"type" in e && "document" === e.type && (e = { start: e.start, value: e.value }), on(Object.freeze([]), e, t);
|
|
3358
|
+
}
|
|
3359
|
+
function on(e, t, n) {
|
|
3360
|
+
let s = n(t, e);
|
|
3361
|
+
if ("symbol" == typeof s) return s;
|
|
3362
|
+
for (const i of ["key", "value"]) {
|
|
3363
|
+
const o = t[i];
|
|
3364
|
+
if (o && "items" in o) {
|
|
3365
|
+
for (let t = 0; t < o.items.length; ++t) {
|
|
3366
|
+
const s = on(Object.freeze(e.concat([[i, t]])), o.items[t], n);
|
|
3367
|
+
if ("number" == typeof s) t = s - 1;
|
|
3368
|
+
else {
|
|
3369
|
+
if (s === en) return en;
|
|
3370
|
+
s === nn && (o.items.splice(t, 1), (t -= 1));
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
"function" == typeof s && "key" === i && (s = s(t, e));
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
return "function" == typeof s ? s(t, e) : s;
|
|
3377
|
+
}
|
|
3378
|
+
(sn.BREAK = en),
|
|
3379
|
+
(sn.SKIP = tn),
|
|
3380
|
+
(sn.REMOVE = nn),
|
|
3381
|
+
(sn.itemAtPath = (e, t) => {
|
|
3382
|
+
let n = e;
|
|
3383
|
+
for (const [e, s] of t) {
|
|
3384
|
+
const t = n?.[e];
|
|
3385
|
+
if (!t || !("items" in t)) return;
|
|
3386
|
+
n = t.items[s];
|
|
3387
|
+
}
|
|
3388
|
+
return n;
|
|
3389
|
+
}),
|
|
3390
|
+
(sn.parentCollection = (e, t) => {
|
|
3391
|
+
const n = sn.itemAtPath(e, t.slice(0, -1)),
|
|
3392
|
+
s = t[t.length - 1][0],
|
|
3393
|
+
i = n?.[s];
|
|
3394
|
+
if (i && "items" in i) return i;
|
|
3395
|
+
throw new Error("Parent collection not found");
|
|
3396
|
+
});
|
|
3397
|
+
const rn = "\ufeff",
|
|
3398
|
+
an = "",
|
|
3399
|
+
cn = "",
|
|
3400
|
+
ln = "";
|
|
3401
|
+
function un(e) {
|
|
3402
|
+
switch (e) {
|
|
3403
|
+
case rn:
|
|
3404
|
+
return "byte-order-mark";
|
|
3405
|
+
case an:
|
|
3406
|
+
return "doc-mode";
|
|
3407
|
+
case cn:
|
|
3408
|
+
return "flow-error-end";
|
|
3409
|
+
case ln:
|
|
3410
|
+
return "scalar";
|
|
3411
|
+
case "---":
|
|
3412
|
+
return "doc-start";
|
|
3413
|
+
case "...":
|
|
3414
|
+
return "doc-end";
|
|
3415
|
+
case "":
|
|
3416
|
+
case "\n":
|
|
3417
|
+
case "\r\n":
|
|
3418
|
+
return "newline";
|
|
3419
|
+
case "-":
|
|
3420
|
+
return "seq-item-ind";
|
|
3421
|
+
case "?":
|
|
3422
|
+
return "explicit-key-ind";
|
|
3423
|
+
case ":":
|
|
3424
|
+
return "map-value-ind";
|
|
3425
|
+
case "{":
|
|
3426
|
+
return "flow-map-start";
|
|
3427
|
+
case "}":
|
|
3428
|
+
return "flow-map-end";
|
|
3429
|
+
case "[":
|
|
3430
|
+
return "flow-seq-start";
|
|
3431
|
+
case "]":
|
|
3432
|
+
return "flow-seq-end";
|
|
3433
|
+
case ",":
|
|
3434
|
+
return "comma";
|
|
3435
|
+
}
|
|
3436
|
+
switch (e[0]) {
|
|
3437
|
+
case " ":
|
|
3438
|
+
case "\t":
|
|
3439
|
+
return "space";
|
|
3440
|
+
case "#":
|
|
3441
|
+
return "comment";
|
|
3442
|
+
case "%":
|
|
3443
|
+
return "directive-line";
|
|
3444
|
+
case "*":
|
|
3445
|
+
return "alias";
|
|
3446
|
+
case "&":
|
|
3447
|
+
return "anchor";
|
|
3448
|
+
case "!":
|
|
3449
|
+
return "tag";
|
|
3450
|
+
case "'":
|
|
3451
|
+
return "single-quoted-scalar";
|
|
3452
|
+
case '"':
|
|
3453
|
+
return "double-quoted-scalar";
|
|
3454
|
+
case "|":
|
|
3455
|
+
case ">":
|
|
3456
|
+
return "block-scalar-header";
|
|
3457
|
+
}
|
|
3458
|
+
return null;
|
|
3459
|
+
}
|
|
3460
|
+
var fn = Object.freeze({
|
|
3461
|
+
__proto__: null,
|
|
3462
|
+
BOM: rn,
|
|
3463
|
+
DOCUMENT: an,
|
|
3464
|
+
FLOW_END: cn,
|
|
3465
|
+
SCALAR: ln,
|
|
3466
|
+
createScalarToken: function (e, t) {
|
|
3467
|
+
const { implicitKey: n = !1, indent: s, inFlow: i = !1, offset: o = -1, type: r = "PLAIN" } = t,
|
|
3468
|
+
a = ie(
|
|
3469
|
+
{ type: r, value: e },
|
|
3470
|
+
{ implicitKey: n, indent: s > 0 ? " ".repeat(s) : "", inFlow: i, options: { blockQuote: !0, lineWidth: -1 } }
|
|
3471
|
+
),
|
|
3472
|
+
c = t.end ?? [{ type: "newline", offset: -1, indent: s, source: "\n" }];
|
|
3473
|
+
switch (a[0]) {
|
|
3474
|
+
case "|":
|
|
3475
|
+
case ">": {
|
|
3476
|
+
const e = a.indexOf("\n"),
|
|
3477
|
+
t = a.substring(0, e),
|
|
3478
|
+
n = a.substring(e + 1) + "\n",
|
|
3479
|
+
i = [{ type: "block-scalar-header", offset: o, indent: s, source: t }];
|
|
3480
|
+
return (
|
|
3481
|
+
Ht(i, c) || i.push({ type: "newline", offset: -1, indent: s, source: "\n" }),
|
|
3482
|
+
{ type: "block-scalar", offset: o, indent: s, props: i, source: n }
|
|
3483
|
+
);
|
|
3484
|
+
}
|
|
3485
|
+
case '"':
|
|
3486
|
+
return { type: "double-quoted-scalar", offset: o, indent: s, source: a, end: c };
|
|
3487
|
+
case "'":
|
|
3488
|
+
return { type: "single-quoted-scalar", offset: o, indent: s, source: a, end: c };
|
|
3489
|
+
default:
|
|
3490
|
+
return { type: "scalar", offset: o, indent: s, source: a, end: c };
|
|
3491
|
+
}
|
|
3492
|
+
},
|
|
3493
|
+
isCollection: (e) => !!e && "items" in e,
|
|
3494
|
+
isScalar: (e) =>
|
|
3495
|
+
!!e &&
|
|
3496
|
+
("scalar" === e.type ||
|
|
3497
|
+
"single-quoted-scalar" === e.type ||
|
|
3498
|
+
"double-quoted-scalar" === e.type ||
|
|
3499
|
+
"block-scalar" === e.type),
|
|
3500
|
+
prettyToken: function (e) {
|
|
3501
|
+
switch (e) {
|
|
3502
|
+
case rn:
|
|
3503
|
+
return "<BOM>";
|
|
3504
|
+
case an:
|
|
3505
|
+
return "<DOC>";
|
|
3506
|
+
case cn:
|
|
3507
|
+
return "<FLOW_END>";
|
|
3508
|
+
case ln:
|
|
3509
|
+
return "<SCALAR>";
|
|
3510
|
+
default:
|
|
3511
|
+
return JSON.stringify(e);
|
|
3512
|
+
}
|
|
3513
|
+
},
|
|
3514
|
+
resolveAsScalar: function (e, t = !0, n) {
|
|
3515
|
+
if (e) {
|
|
3516
|
+
const s = (e, t, s) => {
|
|
3517
|
+
const i = "number" == typeof e ? e : Array.isArray(e) ? e[0] : e.offset;
|
|
3518
|
+
if (!n) throw new Nt([i, i + 1], t, s);
|
|
3519
|
+
n(i, t, s);
|
|
3520
|
+
};
|
|
3521
|
+
switch (e.type) {
|
|
3522
|
+
case "scalar":
|
|
3523
|
+
case "single-quoted-scalar":
|
|
3524
|
+
case "double-quoted-scalar":
|
|
3525
|
+
return Mt(e, t, s);
|
|
3526
|
+
case "block-scalar":
|
|
3527
|
+
return jt({ options: { strict: t } }, e, s);
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
return null;
|
|
3531
|
+
},
|
|
3532
|
+
setScalarValue: function (e, t, n = {}) {
|
|
3533
|
+
let { afterKey: s = !1, implicitKey: i = !1, inFlow: o = !1, type: r } = n,
|
|
3534
|
+
a = "indent" in e ? e.indent : null;
|
|
3535
|
+
if ((s && "number" == typeof a && (a += 2), !r))
|
|
3536
|
+
switch (e.type) {
|
|
3537
|
+
case "single-quoted-scalar":
|
|
3538
|
+
r = "QUOTE_SINGLE";
|
|
3539
|
+
break;
|
|
3540
|
+
case "double-quoted-scalar":
|
|
3541
|
+
r = "QUOTE_DOUBLE";
|
|
3542
|
+
break;
|
|
3543
|
+
case "block-scalar": {
|
|
3544
|
+
const t = e.props[0];
|
|
3545
|
+
if ("block-scalar-header" !== t.type) throw new Error("Invalid block scalar header");
|
|
3546
|
+
r = ">" === t.source[0] ? "BLOCK_FOLDED" : "BLOCK_LITERAL";
|
|
3547
|
+
break;
|
|
3548
|
+
}
|
|
3549
|
+
default:
|
|
3550
|
+
r = "PLAIN";
|
|
3551
|
+
}
|
|
3552
|
+
const c = ie(
|
|
3553
|
+
{ type: r, value: t },
|
|
3554
|
+
{
|
|
3555
|
+
implicitKey: i || null === a,
|
|
3556
|
+
indent: null !== a && a > 0 ? " ".repeat(a) : "",
|
|
3557
|
+
inFlow: o,
|
|
3558
|
+
options: { blockQuote: !0, lineWidth: -1 },
|
|
3559
|
+
}
|
|
3560
|
+
);
|
|
3561
|
+
switch (c[0]) {
|
|
3562
|
+
case "|":
|
|
3563
|
+
case ">":
|
|
3564
|
+
!(function (e, t) {
|
|
3565
|
+
const n = t.indexOf("\n"),
|
|
3566
|
+
s = t.substring(0, n),
|
|
3567
|
+
i = t.substring(n + 1) + "\n";
|
|
3568
|
+
if ("block-scalar" === e.type) {
|
|
3569
|
+
const t = e.props[0];
|
|
3570
|
+
if ("block-scalar-header" !== t.type) throw new Error("Invalid block scalar header");
|
|
3571
|
+
(t.source = s), (e.source = i);
|
|
3572
|
+
} else {
|
|
3573
|
+
const { offset: t } = e,
|
|
3574
|
+
n = "indent" in e ? e.indent : -1,
|
|
3575
|
+
o = [{ type: "block-scalar-header", offset: t, indent: n, source: s }];
|
|
3576
|
+
Ht(o, "end" in e ? e.end : void 0) || o.push({ type: "newline", offset: -1, indent: n, source: "\n" });
|
|
3577
|
+
for (const t of Object.keys(e)) "type" !== t && "offset" !== t && delete e[t];
|
|
3578
|
+
Object.assign(e, { type: "block-scalar", indent: n, props: o, source: i });
|
|
3579
|
+
}
|
|
3580
|
+
})(e, c);
|
|
3581
|
+
break;
|
|
3582
|
+
case '"':
|
|
3583
|
+
Xt(e, c, "double-quoted-scalar");
|
|
3584
|
+
break;
|
|
3585
|
+
case "'":
|
|
3586
|
+
Xt(e, c, "single-quoted-scalar");
|
|
3587
|
+
break;
|
|
3588
|
+
default:
|
|
3589
|
+
Xt(e, c, "scalar");
|
|
3590
|
+
}
|
|
3591
|
+
},
|
|
3592
|
+
stringify: (e) => ("type" in e ? zt(e) : Zt(e)),
|
|
3593
|
+
tokenType: un,
|
|
3594
|
+
visit: sn,
|
|
3595
|
+
});
|
|
3596
|
+
function hn(e) {
|
|
3597
|
+
switch (e) {
|
|
3598
|
+
case void 0:
|
|
3599
|
+
case " ":
|
|
3600
|
+
case "\n":
|
|
3601
|
+
case "\r":
|
|
3602
|
+
case "\t":
|
|
3603
|
+
return !0;
|
|
3604
|
+
default:
|
|
3605
|
+
return !1;
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
const dn = new Set("0123456789ABCDEFabcdef"),
|
|
3609
|
+
pn = new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),
|
|
3610
|
+
mn = new Set(",[]{}"),
|
|
3611
|
+
yn = new Set(" ,[]{}\n\r\t"),
|
|
3612
|
+
gn = (e) => !e || yn.has(e);
|
|
3613
|
+
class bn {
|
|
3614
|
+
constructor() {
|
|
3615
|
+
(this.atEnd = !1),
|
|
3616
|
+
(this.blockScalarIndent = -1),
|
|
3617
|
+
(this.blockScalarKeep = !1),
|
|
3618
|
+
(this.buffer = ""),
|
|
3619
|
+
(this.flowKey = !1),
|
|
3620
|
+
(this.flowLevel = 0),
|
|
3621
|
+
(this.indentNext = 0),
|
|
3622
|
+
(this.indentValue = 0),
|
|
3623
|
+
(this.lineEndPos = null),
|
|
3624
|
+
(this.next = null),
|
|
3625
|
+
(this.pos = 0);
|
|
3626
|
+
}
|
|
3627
|
+
*lex(e, t = !1) {
|
|
3628
|
+
if (e) {
|
|
3629
|
+
if ("string" != typeof e) throw TypeError("source is not a string");
|
|
3630
|
+
(this.buffer = this.buffer ? this.buffer + e : e), (this.lineEndPos = null);
|
|
3631
|
+
}
|
|
3632
|
+
this.atEnd = !t;
|
|
3633
|
+
let n = this.next ?? "stream";
|
|
3634
|
+
for (; n && (t || this.hasChars(1));) n = yield* this.parseNext(n);
|
|
3635
|
+
}
|
|
3636
|
+
atLineEnd() {
|
|
3637
|
+
let e = this.pos,
|
|
3638
|
+
t = this.buffer[e];
|
|
3639
|
+
for (; " " === t || "\t" === t;) t = this.buffer[++e];
|
|
3640
|
+
return !t || "#" === t || "\n" === t || ("\r" === t && "\n" === this.buffer[e + 1]);
|
|
3641
|
+
}
|
|
3642
|
+
charAt(e) {
|
|
3643
|
+
return this.buffer[this.pos + e];
|
|
3644
|
+
}
|
|
3645
|
+
continueScalar(e) {
|
|
3646
|
+
let t = this.buffer[e];
|
|
3647
|
+
if (this.indentNext > 0) {
|
|
3648
|
+
let n = 0;
|
|
3649
|
+
for (; " " === t;) t = this.buffer[++n + e];
|
|
3650
|
+
if ("\r" === t) {
|
|
3651
|
+
const t = this.buffer[n + e + 1];
|
|
3652
|
+
if ("\n" === t || (!t && !this.atEnd)) return e + n + 1;
|
|
3653
|
+
}
|
|
3654
|
+
return "\n" === t || n >= this.indentNext || (!t && !this.atEnd) ? e + n : -1;
|
|
3655
|
+
}
|
|
3656
|
+
if ("-" === t || "." === t) {
|
|
3657
|
+
const t = this.buffer.substr(e, 3);
|
|
3658
|
+
if (("---" === t || "..." === t) && hn(this.buffer[e + 3])) return -1;
|
|
3659
|
+
}
|
|
3660
|
+
return e;
|
|
3661
|
+
}
|
|
3662
|
+
getLine() {
|
|
3663
|
+
let e = this.lineEndPos;
|
|
3664
|
+
return (
|
|
3665
|
+
("number" != typeof e || (-1 !== e && e < this.pos)) &&
|
|
3666
|
+
((e = this.buffer.indexOf("\n", this.pos)), (this.lineEndPos = e)),
|
|
3667
|
+
-1 === e
|
|
3668
|
+
? this.atEnd
|
|
3669
|
+
? this.buffer.substring(this.pos)
|
|
3670
|
+
: null
|
|
3671
|
+
: ("\r" === this.buffer[e - 1] && (e -= 1), this.buffer.substring(this.pos, e))
|
|
3672
|
+
);
|
|
3673
|
+
}
|
|
3674
|
+
hasChars(e) {
|
|
3675
|
+
return this.pos + e <= this.buffer.length;
|
|
3676
|
+
}
|
|
3677
|
+
setNext(e) {
|
|
3678
|
+
return (
|
|
3679
|
+
(this.buffer = this.buffer.substring(this.pos)), (this.pos = 0), (this.lineEndPos = null), (this.next = e), null
|
|
3680
|
+
);
|
|
3681
|
+
}
|
|
3682
|
+
peek(e) {
|
|
3683
|
+
return this.buffer.substr(this.pos, e);
|
|
3684
|
+
}
|
|
3685
|
+
*parseNext(e) {
|
|
3686
|
+
switch (e) {
|
|
3687
|
+
case "stream":
|
|
3688
|
+
return yield* this.parseStream();
|
|
3689
|
+
case "line-start":
|
|
3690
|
+
return yield* this.parseLineStart();
|
|
3691
|
+
case "block-start":
|
|
3692
|
+
return yield* this.parseBlockStart();
|
|
3693
|
+
case "doc":
|
|
3694
|
+
return yield* this.parseDocument();
|
|
3695
|
+
case "flow":
|
|
3696
|
+
return yield* this.parseFlowCollection();
|
|
3697
|
+
case "quoted-scalar":
|
|
3698
|
+
return yield* this.parseQuotedScalar();
|
|
3699
|
+
case "block-scalar":
|
|
3700
|
+
return yield* this.parseBlockScalar();
|
|
3701
|
+
case "plain-scalar":
|
|
3702
|
+
return yield* this.parsePlainScalar();
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
*parseStream() {
|
|
3706
|
+
let e = this.getLine();
|
|
3707
|
+
if (null === e) return this.setNext("stream");
|
|
3708
|
+
if ((e[0] === rn && (yield* this.pushCount(1), (e = e.substring(1))), "%" === e[0])) {
|
|
3709
|
+
let t = e.length,
|
|
3710
|
+
n = e.indexOf("#");
|
|
3711
|
+
for (; -1 !== n;) {
|
|
3712
|
+
const s = e[n - 1];
|
|
3713
|
+
if (" " === s || "\t" === s) {
|
|
3714
|
+
t = n - 1;
|
|
3715
|
+
break;
|
|
3716
|
+
}
|
|
3717
|
+
n = e.indexOf("#", n + 1);
|
|
3718
|
+
}
|
|
3719
|
+
for (; ;) {
|
|
3720
|
+
const n = e[t - 1];
|
|
3721
|
+
if (" " !== n && "\t" !== n) break;
|
|
3722
|
+
t -= 1;
|
|
3723
|
+
}
|
|
3724
|
+
const s = (yield* this.pushCount(t)) + (yield* this.pushSpaces(!0));
|
|
3725
|
+
return yield* this.pushCount(e.length - s), this.pushNewline(), "stream";
|
|
3726
|
+
}
|
|
3727
|
+
if (this.atLineEnd()) {
|
|
3728
|
+
const t = yield* this.pushSpaces(!0);
|
|
3729
|
+
return yield* this.pushCount(e.length - t), yield* this.pushNewline(), "stream";
|
|
3730
|
+
}
|
|
3731
|
+
return yield an, yield* this.parseLineStart();
|
|
3732
|
+
}
|
|
3733
|
+
*parseLineStart() {
|
|
3734
|
+
const e = this.charAt(0);
|
|
3735
|
+
if (!e && !this.atEnd) return this.setNext("line-start");
|
|
3736
|
+
if ("-" === e || "." === e) {
|
|
3737
|
+
if (!this.atEnd && !this.hasChars(4)) return this.setNext("line-start");
|
|
3738
|
+
const e = this.peek(3);
|
|
3739
|
+
if (("---" === e || "..." === e) && hn(this.charAt(3)))
|
|
3740
|
+
return (
|
|
3741
|
+
yield* this.pushCount(3), (this.indentValue = 0), (this.indentNext = 0), "---" === e ? "doc" : "stream"
|
|
3742
|
+
);
|
|
3743
|
+
}
|
|
3744
|
+
return (
|
|
3745
|
+
(this.indentValue = yield* this.pushSpaces(!1)),
|
|
3746
|
+
this.indentNext > this.indentValue && !hn(this.charAt(1)) && (this.indentNext = this.indentValue),
|
|
3747
|
+
yield* this.parseBlockStart()
|
|
3748
|
+
);
|
|
3749
|
+
}
|
|
3750
|
+
*parseBlockStart() {
|
|
3751
|
+
const [e, t] = this.peek(2);
|
|
3752
|
+
if (!t && !this.atEnd) return this.setNext("block-start");
|
|
3753
|
+
if (("-" === e || "?" === e || ":" === e) && hn(t)) {
|
|
3754
|
+
const e = (yield* this.pushCount(1)) + (yield* this.pushSpaces(!0));
|
|
3755
|
+
return (this.indentNext = this.indentValue + 1), (this.indentValue += e), yield* this.parseBlockStart();
|
|
3756
|
+
}
|
|
3757
|
+
return "doc";
|
|
3758
|
+
}
|
|
3759
|
+
*parseDocument() {
|
|
3760
|
+
yield* this.pushSpaces(!0);
|
|
3761
|
+
const e = this.getLine();
|
|
3762
|
+
if (null === e) return this.setNext("doc");
|
|
3763
|
+
let t = yield* this.pushIndicators();
|
|
3764
|
+
switch (e[t]) {
|
|
3765
|
+
case "#":
|
|
3766
|
+
yield* this.pushCount(e.length - t);
|
|
3767
|
+
case void 0:
|
|
3768
|
+
return yield* this.pushNewline(), yield* this.parseLineStart();
|
|
3769
|
+
case "{":
|
|
3770
|
+
case "[":
|
|
3771
|
+
return yield* this.pushCount(1), (this.flowKey = !1), (this.flowLevel = 1), "flow";
|
|
3772
|
+
case "}":
|
|
3773
|
+
case "]":
|
|
3774
|
+
return yield* this.pushCount(1), "doc";
|
|
3775
|
+
case "*":
|
|
3776
|
+
return yield* this.pushUntil(gn), "doc";
|
|
3777
|
+
case '"':
|
|
3778
|
+
case "'":
|
|
3779
|
+
return yield* this.parseQuotedScalar();
|
|
3780
|
+
case "|":
|
|
3781
|
+
case ">":
|
|
3782
|
+
return (
|
|
3783
|
+
(t += yield* this.parseBlockScalarHeader()),
|
|
3784
|
+
(t += yield* this.pushSpaces(!0)),
|
|
3785
|
+
yield* this.pushCount(e.length - t),
|
|
3786
|
+
yield* this.pushNewline(),
|
|
3787
|
+
yield* this.parseBlockScalar()
|
|
3788
|
+
);
|
|
3789
|
+
default:
|
|
3790
|
+
return yield* this.parsePlainScalar();
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
*parseFlowCollection() {
|
|
3794
|
+
let e,
|
|
3795
|
+
t,
|
|
3796
|
+
n = -1;
|
|
3797
|
+
do {
|
|
3798
|
+
(e = yield* this.pushNewline()),
|
|
3799
|
+
e > 0 ? ((t = yield* this.pushSpaces(!1)), (this.indentValue = n = t)) : (t = 0),
|
|
3800
|
+
(t += yield* this.pushSpaces(!0));
|
|
3801
|
+
} while (e + t > 0);
|
|
3802
|
+
const s = this.getLine();
|
|
3803
|
+
if (null === s) return this.setNext("flow");
|
|
3804
|
+
if (
|
|
3805
|
+
(-1 !== n && n < this.indentNext && "#" !== s[0]) ||
|
|
3806
|
+
(0 === n && (s.startsWith("---") || s.startsWith("...")) && hn(s[3]))
|
|
3807
|
+
) {
|
|
3808
|
+
if (!(n === this.indentNext - 1 && 1 === this.flowLevel && ("]" === s[0] || "}" === s[0])))
|
|
3809
|
+
return (this.flowLevel = 0), yield cn, yield* this.parseLineStart();
|
|
3810
|
+
}
|
|
3811
|
+
let i = 0;
|
|
3812
|
+
for (; "," === s[i];) (i += yield* this.pushCount(1)), (i += yield* this.pushSpaces(!0)), (this.flowKey = !1);
|
|
3813
|
+
switch (((i += yield* this.pushIndicators()), s[i])) {
|
|
3814
|
+
case void 0:
|
|
3815
|
+
return "flow";
|
|
3816
|
+
case "#":
|
|
3817
|
+
return yield* this.pushCount(s.length - i), "flow";
|
|
3818
|
+
case "{":
|
|
3819
|
+
case "[":
|
|
3820
|
+
return yield* this.pushCount(1), (this.flowKey = !1), (this.flowLevel += 1), "flow";
|
|
3821
|
+
case "}":
|
|
3822
|
+
case "]":
|
|
3823
|
+
return yield* this.pushCount(1), (this.flowKey = !0), (this.flowLevel -= 1), this.flowLevel ? "flow" : "doc";
|
|
3824
|
+
case "*":
|
|
3825
|
+
return yield* this.pushUntil(gn), "flow";
|
|
3826
|
+
case '"':
|
|
3827
|
+
case "'":
|
|
3828
|
+
return (this.flowKey = !0), yield* this.parseQuotedScalar();
|
|
3829
|
+
case ":": {
|
|
3830
|
+
const e = this.charAt(1);
|
|
3831
|
+
if (this.flowKey || hn(e) || "," === e)
|
|
3832
|
+
return (this.flowKey = !1), yield* this.pushCount(1), yield* this.pushSpaces(!0), "flow";
|
|
3833
|
+
}
|
|
3834
|
+
default:
|
|
3835
|
+
return (this.flowKey = !1), yield* this.parsePlainScalar();
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
*parseQuotedScalar() {
|
|
3839
|
+
const e = this.charAt(0);
|
|
3840
|
+
let t = this.buffer.indexOf(e, this.pos + 1);
|
|
3841
|
+
if ("'" === e) for (; -1 !== t && "'" === this.buffer[t + 1];) t = this.buffer.indexOf("'", t + 2);
|
|
3842
|
+
else
|
|
3843
|
+
for (; -1 !== t;) {
|
|
3844
|
+
let e = 0;
|
|
3845
|
+
for (; "\\" === this.buffer[t - 1 - e];) e += 1;
|
|
3846
|
+
if (e % 2 == 0) break;
|
|
3847
|
+
t = this.buffer.indexOf('"', t + 1);
|
|
3848
|
+
}
|
|
3849
|
+
const n = this.buffer.substring(0, t);
|
|
3850
|
+
let s = n.indexOf("\n", this.pos);
|
|
3851
|
+
if (-1 !== s) {
|
|
3852
|
+
for (; -1 !== s;) {
|
|
3853
|
+
const e = this.continueScalar(s + 1);
|
|
3854
|
+
if (-1 === e) break;
|
|
3855
|
+
s = n.indexOf("\n", e);
|
|
3856
|
+
}
|
|
3857
|
+
-1 !== s && (t = s - ("\r" === n[s - 1] ? 2 : 1));
|
|
3858
|
+
}
|
|
3859
|
+
if (-1 === t) {
|
|
3860
|
+
if (!this.atEnd) return this.setNext("quoted-scalar");
|
|
3861
|
+
t = this.buffer.length;
|
|
3862
|
+
}
|
|
3863
|
+
return yield* this.pushToIndex(t + 1, !1), this.flowLevel ? "flow" : "doc";
|
|
3864
|
+
}
|
|
3865
|
+
*parseBlockScalarHeader() {
|
|
3866
|
+
(this.blockScalarIndent = -1), (this.blockScalarKeep = !1);
|
|
3867
|
+
let e = this.pos;
|
|
3868
|
+
for (; ;) {
|
|
3869
|
+
const t = this.buffer[++e];
|
|
3870
|
+
if ("+" === t) this.blockScalarKeep = !0;
|
|
3871
|
+
else if (t > "0" && t <= "9") this.blockScalarIndent = Number(t) - 1;
|
|
3872
|
+
else if ("-" !== t) break;
|
|
3873
|
+
}
|
|
3874
|
+
return yield* this.pushUntil((e) => hn(e) || "#" === e);
|
|
3875
|
+
}
|
|
3876
|
+
*parseBlockScalar() {
|
|
3877
|
+
let e,
|
|
3878
|
+
t = this.pos - 1,
|
|
3879
|
+
n = 0;
|
|
3880
|
+
e: for (let s = this.pos; (e = this.buffer[s]); ++s)
|
|
3881
|
+
switch (e) {
|
|
3882
|
+
case " ":
|
|
3883
|
+
n += 1;
|
|
3884
|
+
break;
|
|
3885
|
+
case "\n":
|
|
3886
|
+
(t = s), (n = 0);
|
|
3887
|
+
break;
|
|
3888
|
+
case "\r": {
|
|
3889
|
+
const e = this.buffer[s + 1];
|
|
3890
|
+
if (!e && !this.atEnd) return this.setNext("block-scalar");
|
|
3891
|
+
if ("\n" === e) break;
|
|
3892
|
+
}
|
|
3893
|
+
default:
|
|
3894
|
+
break e;
|
|
3895
|
+
}
|
|
3896
|
+
if (!e && !this.atEnd) return this.setNext("block-scalar");
|
|
3897
|
+
if (n >= this.indentNext) {
|
|
3898
|
+
-1 === this.blockScalarIndent
|
|
3899
|
+
? (this.indentNext = n)
|
|
3900
|
+
: (this.indentNext = this.blockScalarIndent + (0 === this.indentNext ? 1 : this.indentNext));
|
|
3901
|
+
do {
|
|
3902
|
+
const e = this.continueScalar(t + 1);
|
|
3903
|
+
if (-1 === e) break;
|
|
3904
|
+
t = this.buffer.indexOf("\n", e);
|
|
3905
|
+
} while (-1 !== t);
|
|
3906
|
+
if (-1 === t) {
|
|
3907
|
+
if (!this.atEnd) return this.setNext("block-scalar");
|
|
3908
|
+
t = this.buffer.length;
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
let s = t + 1;
|
|
3912
|
+
for (e = this.buffer[s]; " " === e;) e = this.buffer[++s];
|
|
3913
|
+
if ("\t" === e) {
|
|
3914
|
+
for (; "\t" === e || " " === e || "\r" === e || "\n" === e;) e = this.buffer[++s];
|
|
3915
|
+
t = s - 1;
|
|
3916
|
+
} else if (!this.blockScalarKeep)
|
|
3917
|
+
for (; ;) {
|
|
3918
|
+
let e = t - 1,
|
|
3919
|
+
s = this.buffer[e];
|
|
3920
|
+
"\r" === s && (s = this.buffer[--e]);
|
|
3921
|
+
const i = e;
|
|
3922
|
+
for (; " " === s;) s = this.buffer[--e];
|
|
3923
|
+
if (!("\n" === s && e >= this.pos && e + 1 + n > i)) break;
|
|
3924
|
+
t = e;
|
|
3925
|
+
}
|
|
3926
|
+
return yield ln, yield* this.pushToIndex(t + 1, !0), yield* this.parseLineStart();
|
|
3927
|
+
}
|
|
3928
|
+
*parsePlainScalar() {
|
|
3929
|
+
const e = this.flowLevel > 0;
|
|
3930
|
+
let t,
|
|
3931
|
+
n = this.pos - 1,
|
|
3932
|
+
s = this.pos - 1;
|
|
3933
|
+
for (; (t = this.buffer[++s]);)
|
|
3934
|
+
if (":" === t) {
|
|
3935
|
+
const t = this.buffer[s + 1];
|
|
3936
|
+
if (hn(t) || (e && mn.has(t))) break;
|
|
3937
|
+
n = s;
|
|
3938
|
+
} else if (hn(t)) {
|
|
3939
|
+
let i = this.buffer[s + 1];
|
|
3940
|
+
if (
|
|
3941
|
+
("\r" === t && ("\n" === i ? ((s += 1), (t = "\n"), (i = this.buffer[s + 1])) : (n = s)),
|
|
3942
|
+
"#" === i || (e && mn.has(i)))
|
|
3943
|
+
)
|
|
3944
|
+
break;
|
|
3945
|
+
if ("\n" === t) {
|
|
3946
|
+
const e = this.continueScalar(s + 1);
|
|
3947
|
+
if (-1 === e) break;
|
|
3948
|
+
s = Math.max(s, e - 2);
|
|
3949
|
+
}
|
|
3950
|
+
} else {
|
|
3951
|
+
if (e && mn.has(t)) break;
|
|
3952
|
+
n = s;
|
|
3953
|
+
}
|
|
3954
|
+
return t || this.atEnd
|
|
3955
|
+
? (yield ln, yield* this.pushToIndex(n + 1, !0), e ? "flow" : "doc")
|
|
3956
|
+
: this.setNext("plain-scalar");
|
|
3957
|
+
}
|
|
3958
|
+
*pushCount(e) {
|
|
3959
|
+
return e > 0 ? (yield this.buffer.substr(this.pos, e), (this.pos += e), e) : 0;
|
|
3960
|
+
}
|
|
3961
|
+
*pushToIndex(e, t) {
|
|
3962
|
+
const n = this.buffer.slice(this.pos, e);
|
|
3963
|
+
return n ? (yield n, (this.pos += n.length), n.length) : (t && (yield ""), 0);
|
|
3964
|
+
}
|
|
3965
|
+
*pushIndicators() {
|
|
3966
|
+
switch (this.charAt(0)) {
|
|
3967
|
+
case "!":
|
|
3968
|
+
return (yield* this.pushTag()) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators());
|
|
3969
|
+
case "&":
|
|
3970
|
+
return (yield* this.pushUntil(gn)) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators());
|
|
3971
|
+
case "-":
|
|
3972
|
+
case "?":
|
|
3973
|
+
case ":": {
|
|
3974
|
+
const e = this.flowLevel > 0,
|
|
3975
|
+
t = this.charAt(1);
|
|
3976
|
+
if (hn(t) || (e && mn.has(t)))
|
|
3977
|
+
return (
|
|
3978
|
+
e ? this.flowKey && (this.flowKey = !1) : (this.indentNext = this.indentValue + 1),
|
|
3979
|
+
(yield* this.pushCount(1)) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators())
|
|
3980
|
+
);
|
|
3981
|
+
}
|
|
3982
|
+
}
|
|
3983
|
+
return 0;
|
|
3984
|
+
}
|
|
3985
|
+
*pushTag() {
|
|
3986
|
+
if ("<" === this.charAt(1)) {
|
|
3987
|
+
let e = this.pos + 2,
|
|
3988
|
+
t = this.buffer[e];
|
|
3989
|
+
for (; !hn(t) && ">" !== t;) t = this.buffer[++e];
|
|
3990
|
+
return yield* this.pushToIndex(">" === t ? e + 1 : e, !1);
|
|
3991
|
+
}
|
|
3992
|
+
{
|
|
3993
|
+
let e = this.pos + 1,
|
|
3994
|
+
t = this.buffer[e];
|
|
3995
|
+
for (; t;)
|
|
3996
|
+
if (pn.has(t)) t = this.buffer[++e];
|
|
3997
|
+
else {
|
|
3998
|
+
if ("%" !== t || !dn.has(this.buffer[e + 1]) || !dn.has(this.buffer[e + 2])) break;
|
|
3999
|
+
t = this.buffer[(e += 3)];
|
|
4000
|
+
}
|
|
4001
|
+
return yield* this.pushToIndex(e, !1);
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
*pushNewline() {
|
|
4005
|
+
const e = this.buffer[this.pos];
|
|
4006
|
+
return "\n" === e
|
|
4007
|
+
? yield* this.pushCount(1)
|
|
4008
|
+
: "\r" === e && "\n" === this.charAt(1)
|
|
4009
|
+
? yield* this.pushCount(2)
|
|
4010
|
+
: 0;
|
|
4011
|
+
}
|
|
4012
|
+
*pushSpaces(e) {
|
|
4013
|
+
let t,
|
|
4014
|
+
n = this.pos - 1;
|
|
4015
|
+
do {
|
|
4016
|
+
t = this.buffer[++n];
|
|
4017
|
+
} while (" " === t || (e && "\t" === t));
|
|
4018
|
+
const s = n - this.pos;
|
|
4019
|
+
return s > 0 && (yield this.buffer.substr(this.pos, s), (this.pos = n)), s;
|
|
4020
|
+
}
|
|
4021
|
+
*pushUntil(e) {
|
|
4022
|
+
let t = this.pos,
|
|
4023
|
+
n = this.buffer[t];
|
|
4024
|
+
for (; !e(n);) n = this.buffer[++t];
|
|
4025
|
+
return yield* this.pushToIndex(t, !1);
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
class kn {
|
|
4029
|
+
constructor() {
|
|
4030
|
+
(this.lineStarts = []),
|
|
4031
|
+
(this.addNewLine = (e) => this.lineStarts.push(e)),
|
|
4032
|
+
(this.linePos = (e) => {
|
|
4033
|
+
let t = 0,
|
|
4034
|
+
n = this.lineStarts.length;
|
|
4035
|
+
for (; t < n;) {
|
|
4036
|
+
const s = (t + n) >> 1;
|
|
4037
|
+
this.lineStarts[s] < e ? (t = s + 1) : (n = s);
|
|
4038
|
+
}
|
|
4039
|
+
if (this.lineStarts[t] === e) return { line: t + 1, col: 1 };
|
|
4040
|
+
if (0 === t) return { line: 0, col: e };
|
|
4041
|
+
return { line: t, col: e - this.lineStarts[t - 1] + 1 };
|
|
4042
|
+
});
|
|
4043
|
+
}
|
|
4044
|
+
}
|
|
4045
|
+
function wn(e, t) {
|
|
4046
|
+
for (let n = 0; n < e.length; ++n) if (e[n].type === t) return !0;
|
|
4047
|
+
return !1;
|
|
4048
|
+
}
|
|
4049
|
+
function vn(e) {
|
|
4050
|
+
for (let t = 0; t < e.length; ++t)
|
|
4051
|
+
switch (e[t].type) {
|
|
4052
|
+
case "space":
|
|
4053
|
+
case "comment":
|
|
4054
|
+
case "newline":
|
|
4055
|
+
break;
|
|
4056
|
+
default:
|
|
4057
|
+
return t;
|
|
4058
|
+
}
|
|
4059
|
+
return -1;
|
|
4060
|
+
}
|
|
4061
|
+
function Sn(e) {
|
|
4062
|
+
switch (e?.type) {
|
|
4063
|
+
case "alias":
|
|
4064
|
+
case "scalar":
|
|
4065
|
+
case "single-quoted-scalar":
|
|
4066
|
+
case "double-quoted-scalar":
|
|
4067
|
+
case "flow-collection":
|
|
4068
|
+
return !0;
|
|
4069
|
+
default:
|
|
4070
|
+
return !1;
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
function En(e) {
|
|
4074
|
+
switch (e.type) {
|
|
4075
|
+
case "document":
|
|
4076
|
+
return e.start;
|
|
4077
|
+
case "block-map": {
|
|
4078
|
+
const t = e.items[e.items.length - 1];
|
|
4079
|
+
return t.sep ?? t.start;
|
|
4080
|
+
}
|
|
4081
|
+
case "block-seq":
|
|
4082
|
+
return e.items[e.items.length - 1].start;
|
|
4083
|
+
default:
|
|
4084
|
+
return [];
|
|
4085
|
+
}
|
|
4086
|
+
}
|
|
4087
|
+
function Nn(e) {
|
|
4088
|
+
if (0 === e.length) return [];
|
|
4089
|
+
let t = e.length;
|
|
4090
|
+
e: for (; --t >= 0;)
|
|
4091
|
+
switch (e[t].type) {
|
|
4092
|
+
case "doc-start":
|
|
4093
|
+
case "explicit-key-ind":
|
|
4094
|
+
case "map-value-ind":
|
|
4095
|
+
case "seq-item-ind":
|
|
4096
|
+
case "newline":
|
|
4097
|
+
break e;
|
|
4098
|
+
}
|
|
4099
|
+
for (; "space" === e[++t]?.type;);
|
|
4100
|
+
return e.splice(t, e.length);
|
|
4101
|
+
}
|
|
4102
|
+
function On(e) {
|
|
4103
|
+
if ("flow-seq-start" === e.start.type)
|
|
4104
|
+
for (const t of e.items)
|
|
4105
|
+
!t.sep ||
|
|
4106
|
+
t.value ||
|
|
4107
|
+
wn(t.start, "explicit-key-ind") ||
|
|
4108
|
+
wn(t.sep, "map-value-ind") ||
|
|
4109
|
+
(t.key && (t.value = t.key),
|
|
4110
|
+
delete t.key,
|
|
4111
|
+
Sn(t.value)
|
|
4112
|
+
? t.value.end
|
|
4113
|
+
? Array.prototype.push.apply(t.value.end, t.sep)
|
|
4114
|
+
: (t.value.end = t.sep)
|
|
4115
|
+
: Array.prototype.push.apply(t.start, t.sep),
|
|
4116
|
+
delete t.sep);
|
|
4117
|
+
}
|
|
4118
|
+
class An {
|
|
4119
|
+
constructor(e) {
|
|
4120
|
+
(this.atNewLine = !0),
|
|
4121
|
+
(this.atScalar = !1),
|
|
4122
|
+
(this.indent = 0),
|
|
4123
|
+
(this.offset = 0),
|
|
4124
|
+
(this.onKeyLine = !1),
|
|
4125
|
+
(this.stack = []),
|
|
4126
|
+
(this.source = ""),
|
|
4127
|
+
(this.type = ""),
|
|
4128
|
+
(this.lexer = new bn()),
|
|
4129
|
+
(this.onNewLine = e);
|
|
4130
|
+
}
|
|
4131
|
+
*parse(e, t = !1) {
|
|
4132
|
+
this.onNewLine && 0 === this.offset && this.onNewLine(0);
|
|
4133
|
+
for (const n of this.lexer.lex(e, t)) yield* this.next(n);
|
|
4134
|
+
t || (yield* this.end());
|
|
4135
|
+
}
|
|
4136
|
+
*next(e) {
|
|
4137
|
+
if (((this.source = e), this.atScalar))
|
|
4138
|
+
return (this.atScalar = !1), yield* this.step(), void (this.offset += e.length);
|
|
4139
|
+
const t = un(e);
|
|
4140
|
+
if (t)
|
|
4141
|
+
if ("scalar" === t) (this.atNewLine = !1), (this.atScalar = !0), (this.type = "scalar");
|
|
4142
|
+
else {
|
|
4143
|
+
switch (((this.type = t), yield* this.step(), t)) {
|
|
4144
|
+
case "newline":
|
|
4145
|
+
(this.atNewLine = !0), (this.indent = 0), this.onNewLine && this.onNewLine(this.offset + e.length);
|
|
4146
|
+
break;
|
|
4147
|
+
case "space":
|
|
4148
|
+
this.atNewLine && " " === e[0] && (this.indent += e.length);
|
|
4149
|
+
break;
|
|
4150
|
+
case "explicit-key-ind":
|
|
4151
|
+
case "map-value-ind":
|
|
4152
|
+
case "seq-item-ind":
|
|
4153
|
+
this.atNewLine && (this.indent += e.length);
|
|
4154
|
+
break;
|
|
4155
|
+
case "doc-mode":
|
|
4156
|
+
case "flow-error-end":
|
|
4157
|
+
return;
|
|
4158
|
+
default:
|
|
4159
|
+
this.atNewLine = !1;
|
|
4160
|
+
}
|
|
4161
|
+
this.offset += e.length;
|
|
4162
|
+
}
|
|
4163
|
+
else {
|
|
4164
|
+
const t = `Not a YAML token: ${e}`;
|
|
4165
|
+
yield* this.pop({ type: "error", offset: this.offset, message: t, source: e }), (this.offset += e.length);
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4168
|
+
*end() {
|
|
4169
|
+
for (; this.stack.length > 0;) yield* this.pop();
|
|
4170
|
+
}
|
|
4171
|
+
get sourceToken() {
|
|
4172
|
+
return { type: this.type, offset: this.offset, indent: this.indent, source: this.source };
|
|
4173
|
+
}
|
|
4174
|
+
*step() {
|
|
4175
|
+
const e = this.peek(1);
|
|
4176
|
+
if ("doc-end" !== this.type || (e && "doc-end" === e.type)) {
|
|
4177
|
+
if (!e) return yield* this.stream();
|
|
4178
|
+
switch (e.type) {
|
|
4179
|
+
case "document":
|
|
4180
|
+
return yield* this.document(e);
|
|
4181
|
+
case "alias":
|
|
4182
|
+
case "scalar":
|
|
4183
|
+
case "single-quoted-scalar":
|
|
4184
|
+
case "double-quoted-scalar":
|
|
4185
|
+
return yield* this.scalar(e);
|
|
4186
|
+
case "block-scalar":
|
|
4187
|
+
return yield* this.blockScalar(e);
|
|
4188
|
+
case "block-map":
|
|
4189
|
+
return yield* this.blockMap(e);
|
|
4190
|
+
case "block-seq":
|
|
4191
|
+
return yield* this.blockSequence(e);
|
|
4192
|
+
case "flow-collection":
|
|
4193
|
+
return yield* this.flowCollection(e);
|
|
4194
|
+
case "doc-end":
|
|
4195
|
+
return yield* this.documentEnd(e);
|
|
4196
|
+
}
|
|
4197
|
+
yield* this.pop();
|
|
4198
|
+
} else {
|
|
4199
|
+
for (; this.stack.length > 0;) yield* this.pop();
|
|
4200
|
+
this.stack.push({ type: "doc-end", offset: this.offset, source: this.source });
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
peek(e) {
|
|
4204
|
+
return this.stack[this.stack.length - e];
|
|
4205
|
+
}
|
|
4206
|
+
*pop(e) {
|
|
4207
|
+
const t = e ?? this.stack.pop();
|
|
4208
|
+
if (t)
|
|
4209
|
+
if (0 === this.stack.length) yield t;
|
|
4210
|
+
else {
|
|
4211
|
+
const e = this.peek(1);
|
|
4212
|
+
switch (
|
|
4213
|
+
("block-scalar" === t.type
|
|
4214
|
+
? (t.indent = "indent" in e ? e.indent : 0)
|
|
4215
|
+
: "flow-collection" === t.type && "document" === e.type && (t.indent = 0),
|
|
4216
|
+
"flow-collection" === t.type && On(t),
|
|
4217
|
+
e.type)
|
|
4218
|
+
) {
|
|
4219
|
+
case "document":
|
|
4220
|
+
e.value = t;
|
|
4221
|
+
break;
|
|
4222
|
+
case "block-scalar":
|
|
4223
|
+
e.props.push(t);
|
|
4224
|
+
break;
|
|
4225
|
+
case "block-map": {
|
|
4226
|
+
const n = e.items[e.items.length - 1];
|
|
4227
|
+
if (n.value) return e.items.push({ start: [], key: t, sep: [] }), void (this.onKeyLine = !0);
|
|
4228
|
+
if (!n.sep) return Object.assign(n, { key: t, sep: [] }), void (this.onKeyLine = !n.explicitKey);
|
|
4229
|
+
n.value = t;
|
|
4230
|
+
break;
|
|
4231
|
+
}
|
|
4232
|
+
case "block-seq": {
|
|
4233
|
+
const n = e.items[e.items.length - 1];
|
|
4234
|
+
n.value ? e.items.push({ start: [], value: t }) : (n.value = t);
|
|
4235
|
+
break;
|
|
4236
|
+
}
|
|
4237
|
+
case "flow-collection": {
|
|
4238
|
+
const n = e.items[e.items.length - 1];
|
|
4239
|
+
return void (!n || n.value
|
|
4240
|
+
? e.items.push({ start: [], key: t, sep: [] })
|
|
4241
|
+
: n.sep
|
|
4242
|
+
? (n.value = t)
|
|
4243
|
+
: Object.assign(n, { key: t, sep: [] }));
|
|
4244
|
+
}
|
|
4245
|
+
default:
|
|
4246
|
+
yield* this.pop(), yield* this.pop(t);
|
|
4247
|
+
}
|
|
4248
|
+
if (
|
|
4249
|
+
!(
|
|
4250
|
+
("document" !== e.type && "block-map" !== e.type && "block-seq" !== e.type) ||
|
|
4251
|
+
("block-map" !== t.type && "block-seq" !== t.type)
|
|
4252
|
+
)
|
|
4253
|
+
) {
|
|
4254
|
+
const n = t.items[t.items.length - 1];
|
|
4255
|
+
n &&
|
|
4256
|
+
!n.sep &&
|
|
4257
|
+
!n.value &&
|
|
4258
|
+
n.start.length > 0 &&
|
|
4259
|
+
-1 === vn(n.start) &&
|
|
4260
|
+
(0 === t.indent || n.start.every((e) => "comment" !== e.type || e.indent < t.indent)) &&
|
|
4261
|
+
("document" === e.type ? (e.end = n.start) : e.items.push({ start: n.start }), t.items.splice(-1, 1));
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
else {
|
|
4265
|
+
const e = "Tried to pop an empty stack";
|
|
4266
|
+
yield { type: "error", offset: this.offset, source: "", message: e };
|
|
4267
|
+
}
|
|
4268
|
+
}
|
|
4269
|
+
*stream() {
|
|
4270
|
+
switch (this.type) {
|
|
4271
|
+
case "directive-line":
|
|
4272
|
+
return void (yield { type: "directive", offset: this.offset, source: this.source });
|
|
4273
|
+
case "byte-order-mark":
|
|
4274
|
+
case "space":
|
|
4275
|
+
case "comment":
|
|
4276
|
+
case "newline":
|
|
4277
|
+
return void (yield this.sourceToken);
|
|
4278
|
+
case "doc-mode":
|
|
4279
|
+
case "doc-start": {
|
|
4280
|
+
const e = { type: "document", offset: this.offset, start: [] };
|
|
4281
|
+
return "doc-start" === this.type && e.start.push(this.sourceToken), void this.stack.push(e);
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
yield {
|
|
4285
|
+
type: "error",
|
|
4286
|
+
offset: this.offset,
|
|
4287
|
+
message: `Unexpected ${this.type} token in YAML stream`,
|
|
4288
|
+
source: this.source,
|
|
4289
|
+
};
|
|
4290
|
+
}
|
|
4291
|
+
*document(e) {
|
|
4292
|
+
if (e.value) return yield* this.lineEnd(e);
|
|
4293
|
+
switch (this.type) {
|
|
4294
|
+
case "doc-start":
|
|
4295
|
+
return void (-1 !== vn(e.start) ? (yield* this.pop(), yield* this.step()) : e.start.push(this.sourceToken));
|
|
4296
|
+
case "anchor":
|
|
4297
|
+
case "tag":
|
|
4298
|
+
case "space":
|
|
4299
|
+
case "comment":
|
|
4300
|
+
case "newline":
|
|
4301
|
+
return void e.start.push(this.sourceToken);
|
|
4302
|
+
}
|
|
4303
|
+
const t = this.startBlockValue(e);
|
|
4304
|
+
t
|
|
4305
|
+
? this.stack.push(t)
|
|
4306
|
+
: yield {
|
|
4307
|
+
type: "error",
|
|
4308
|
+
offset: this.offset,
|
|
4309
|
+
message: `Unexpected ${this.type} token in YAML document`,
|
|
4310
|
+
source: this.source,
|
|
4311
|
+
};
|
|
4312
|
+
}
|
|
4313
|
+
*scalar(e) {
|
|
4314
|
+
if ("map-value-ind" === this.type) {
|
|
4315
|
+
const t = Nn(En(this.peek(2)));
|
|
4316
|
+
let n;
|
|
4317
|
+
e.end ? ((n = e.end), n.push(this.sourceToken), delete e.end) : (n = [this.sourceToken]);
|
|
4318
|
+
const s = { type: "block-map", offset: e.offset, indent: e.indent, items: [{ start: t, key: e, sep: n }] };
|
|
4319
|
+
(this.onKeyLine = !0), (this.stack[this.stack.length - 1] = s);
|
|
4320
|
+
} else yield* this.lineEnd(e);
|
|
4321
|
+
}
|
|
4322
|
+
*blockScalar(e) {
|
|
4323
|
+
switch (this.type) {
|
|
4324
|
+
case "space":
|
|
4325
|
+
case "comment":
|
|
4326
|
+
case "newline":
|
|
4327
|
+
return void e.props.push(this.sourceToken);
|
|
4328
|
+
case "scalar":
|
|
4329
|
+
if (((e.source = this.source), (this.atNewLine = !0), (this.indent = 0), this.onNewLine)) {
|
|
4330
|
+
let e = this.source.indexOf("\n") + 1;
|
|
4331
|
+
for (; 0 !== e;) this.onNewLine(this.offset + e), (e = this.source.indexOf("\n", e) + 1);
|
|
4332
|
+
}
|
|
4333
|
+
yield* this.pop();
|
|
4334
|
+
break;
|
|
4335
|
+
default:
|
|
4336
|
+
yield* this.pop(), yield* this.step();
|
|
4337
|
+
}
|
|
4338
|
+
}
|
|
4339
|
+
*blockMap(e) {
|
|
4340
|
+
const t = e.items[e.items.length - 1];
|
|
4341
|
+
switch (this.type) {
|
|
4342
|
+
case "newline":
|
|
4343
|
+
if (((this.onKeyLine = !1), t.value)) {
|
|
4344
|
+
const n = "end" in t.value ? t.value.end : void 0,
|
|
4345
|
+
s = Array.isArray(n) ? n[n.length - 1] : void 0;
|
|
4346
|
+
"comment" === s?.type ? n?.push(this.sourceToken) : e.items.push({ start: [this.sourceToken] });
|
|
4347
|
+
} else t.sep ? t.sep.push(this.sourceToken) : t.start.push(this.sourceToken);
|
|
4348
|
+
return;
|
|
4349
|
+
case "space":
|
|
4350
|
+
case "comment":
|
|
4351
|
+
if (t.value) e.items.push({ start: [this.sourceToken] });
|
|
4352
|
+
else if (t.sep) t.sep.push(this.sourceToken);
|
|
4353
|
+
else {
|
|
4354
|
+
if (this.atIndentedComment(t.start, e.indent)) {
|
|
4355
|
+
const n = e.items[e.items.length - 2],
|
|
4356
|
+
s = n?.value?.end;
|
|
4357
|
+
if (Array.isArray(s))
|
|
4358
|
+
return Array.prototype.push.apply(s, t.start), s.push(this.sourceToken), void e.items.pop();
|
|
4359
|
+
}
|
|
4360
|
+
t.start.push(this.sourceToken);
|
|
4361
|
+
}
|
|
4362
|
+
return;
|
|
4363
|
+
}
|
|
4364
|
+
if (this.indent >= e.indent) {
|
|
4365
|
+
const n = !this.onKeyLine && this.indent === e.indent,
|
|
4366
|
+
s = n && (t.sep || t.explicitKey) && "seq-item-ind" !== this.type;
|
|
4367
|
+
let i = [];
|
|
4368
|
+
if (s && t.sep && !t.value) {
|
|
4369
|
+
const n = [];
|
|
4370
|
+
for (let s = 0; s < t.sep.length; ++s) {
|
|
4371
|
+
const i = t.sep[s];
|
|
4372
|
+
switch (i.type) {
|
|
4373
|
+
case "newline":
|
|
4374
|
+
n.push(s);
|
|
4375
|
+
break;
|
|
4376
|
+
case "space":
|
|
4377
|
+
break;
|
|
4378
|
+
case "comment":
|
|
4379
|
+
i.indent > e.indent && (n.length = 0);
|
|
4380
|
+
break;
|
|
4381
|
+
default:
|
|
4382
|
+
n.length = 0;
|
|
4383
|
+
}
|
|
4384
|
+
}
|
|
4385
|
+
n.length >= 2 && (i = t.sep.splice(n[1]));
|
|
4386
|
+
}
|
|
4387
|
+
switch (this.type) {
|
|
4388
|
+
case "anchor":
|
|
4389
|
+
case "tag":
|
|
4390
|
+
return void (s || t.value
|
|
4391
|
+
? (i.push(this.sourceToken), e.items.push({ start: i }), (this.onKeyLine = !0))
|
|
4392
|
+
: t.sep
|
|
4393
|
+
? t.sep.push(this.sourceToken)
|
|
4394
|
+
: t.start.push(this.sourceToken));
|
|
4395
|
+
case "explicit-key-ind":
|
|
4396
|
+
return (
|
|
4397
|
+
t.sep || t.explicitKey
|
|
4398
|
+
? s || t.value
|
|
4399
|
+
? (i.push(this.sourceToken), e.items.push({ start: i, explicitKey: !0 }))
|
|
4400
|
+
: this.stack.push({
|
|
4401
|
+
type: "block-map",
|
|
4402
|
+
offset: this.offset,
|
|
4403
|
+
indent: this.indent,
|
|
4404
|
+
items: [{ start: [this.sourceToken], explicitKey: !0 }],
|
|
4405
|
+
})
|
|
4406
|
+
: (t.start.push(this.sourceToken), (t.explicitKey = !0)),
|
|
4407
|
+
void (this.onKeyLine = !0)
|
|
4408
|
+
);
|
|
4409
|
+
case "map-value-ind":
|
|
4410
|
+
if (t.explicitKey)
|
|
4411
|
+
if (t.sep)
|
|
4412
|
+
if (t.value) e.items.push({ start: [], key: null, sep: [this.sourceToken] });
|
|
4413
|
+
else if (wn(t.sep, "map-value-ind"))
|
|
4414
|
+
this.stack.push({
|
|
4415
|
+
type: "block-map",
|
|
4416
|
+
offset: this.offset,
|
|
4417
|
+
indent: this.indent,
|
|
4418
|
+
items: [{ start: i, key: null, sep: [this.sourceToken] }],
|
|
4419
|
+
});
|
|
4420
|
+
else if (Sn(t.key) && !wn(t.sep, "newline")) {
|
|
4421
|
+
const e = Nn(t.start),
|
|
4422
|
+
n = t.key,
|
|
4423
|
+
s = t.sep;
|
|
4424
|
+
s.push(this.sourceToken),
|
|
4425
|
+
delete t.key,
|
|
4426
|
+
delete t.sep,
|
|
4427
|
+
this.stack.push({
|
|
4428
|
+
type: "block-map",
|
|
4429
|
+
offset: this.offset,
|
|
4430
|
+
indent: this.indent,
|
|
4431
|
+
items: [{ start: e, key: n, sep: s }],
|
|
4432
|
+
});
|
|
4433
|
+
} else i.length > 0 ? (t.sep = t.sep.concat(i, this.sourceToken)) : t.sep.push(this.sourceToken);
|
|
4434
|
+
else if (wn(t.start, "newline")) Object.assign(t, { key: null, sep: [this.sourceToken] });
|
|
4435
|
+
else {
|
|
4436
|
+
const e = Nn(t.start);
|
|
4437
|
+
this.stack.push({
|
|
4438
|
+
type: "block-map",
|
|
4439
|
+
offset: this.offset,
|
|
4440
|
+
indent: this.indent,
|
|
4441
|
+
items: [{ start: e, key: null, sep: [this.sourceToken] }],
|
|
4442
|
+
});
|
|
4443
|
+
}
|
|
4444
|
+
else
|
|
4445
|
+
t.sep
|
|
4446
|
+
? t.value || s
|
|
4447
|
+
? e.items.push({ start: i, key: null, sep: [this.sourceToken] })
|
|
4448
|
+
: wn(t.sep, "map-value-ind")
|
|
4449
|
+
? this.stack.push({
|
|
4450
|
+
type: "block-map",
|
|
4451
|
+
offset: this.offset,
|
|
4452
|
+
indent: this.indent,
|
|
4453
|
+
items: [{ start: [], key: null, sep: [this.sourceToken] }],
|
|
4454
|
+
})
|
|
4455
|
+
: t.sep.push(this.sourceToken)
|
|
4456
|
+
: Object.assign(t, { key: null, sep: [this.sourceToken] });
|
|
4457
|
+
return void (this.onKeyLine = !0);
|
|
4458
|
+
case "alias":
|
|
4459
|
+
case "scalar":
|
|
4460
|
+
case "single-quoted-scalar":
|
|
4461
|
+
case "double-quoted-scalar": {
|
|
4462
|
+
const n = this.flowScalar(this.type);
|
|
4463
|
+
return void (s || t.value
|
|
4464
|
+
? (e.items.push({ start: i, key: n, sep: [] }), (this.onKeyLine = !0))
|
|
4465
|
+
: t.sep
|
|
4466
|
+
? this.stack.push(n)
|
|
4467
|
+
: (Object.assign(t, { key: n, sep: [] }), (this.onKeyLine = !0)));
|
|
4468
|
+
}
|
|
4469
|
+
default: {
|
|
4470
|
+
const s = this.startBlockValue(e);
|
|
4471
|
+
if (s) {
|
|
4472
|
+
if ("block-seq" === s.type) {
|
|
4473
|
+
if (!t.explicitKey && t.sep && !wn(t.sep, "newline"))
|
|
4474
|
+
return void (yield* this.pop({
|
|
4475
|
+
type: "error",
|
|
4476
|
+
offset: this.offset,
|
|
4477
|
+
message: "Unexpected block-seq-ind on same line with key",
|
|
4478
|
+
source: this.source,
|
|
4479
|
+
}));
|
|
4480
|
+
} else n && e.items.push({ start: i });
|
|
4481
|
+
return void this.stack.push(s);
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4484
|
+
}
|
|
4485
|
+
}
|
|
4486
|
+
yield* this.pop(), yield* this.step();
|
|
4487
|
+
}
|
|
4488
|
+
*blockSequence(e) {
|
|
4489
|
+
const t = e.items[e.items.length - 1];
|
|
4490
|
+
switch (this.type) {
|
|
4491
|
+
case "newline":
|
|
4492
|
+
if (t.value) {
|
|
4493
|
+
const n = "end" in t.value ? t.value.end : void 0,
|
|
4494
|
+
s = Array.isArray(n) ? n[n.length - 1] : void 0;
|
|
4495
|
+
"comment" === s?.type ? n?.push(this.sourceToken) : e.items.push({ start: [this.sourceToken] });
|
|
4496
|
+
} else t.start.push(this.sourceToken);
|
|
4497
|
+
return;
|
|
4498
|
+
case "space":
|
|
4499
|
+
case "comment":
|
|
4500
|
+
if (t.value) e.items.push({ start: [this.sourceToken] });
|
|
4501
|
+
else {
|
|
4502
|
+
if (this.atIndentedComment(t.start, e.indent)) {
|
|
4503
|
+
const n = e.items[e.items.length - 2],
|
|
4504
|
+
s = n?.value?.end;
|
|
4505
|
+
if (Array.isArray(s))
|
|
4506
|
+
return Array.prototype.push.apply(s, t.start), s.push(this.sourceToken), void e.items.pop();
|
|
4507
|
+
}
|
|
4508
|
+
t.start.push(this.sourceToken);
|
|
4509
|
+
}
|
|
4510
|
+
return;
|
|
4511
|
+
case "anchor":
|
|
4512
|
+
case "tag":
|
|
4513
|
+
if (t.value || this.indent <= e.indent) break;
|
|
4514
|
+
return void t.start.push(this.sourceToken);
|
|
4515
|
+
case "seq-item-ind":
|
|
4516
|
+
if (this.indent !== e.indent) break;
|
|
4517
|
+
return void (t.value || wn(t.start, "seq-item-ind")
|
|
4518
|
+
? e.items.push({ start: [this.sourceToken] })
|
|
4519
|
+
: t.start.push(this.sourceToken));
|
|
4520
|
+
}
|
|
4521
|
+
if (this.indent > e.indent) {
|
|
4522
|
+
const t = this.startBlockValue(e);
|
|
4523
|
+
if (t) return void this.stack.push(t);
|
|
4524
|
+
}
|
|
4525
|
+
yield* this.pop(), yield* this.step();
|
|
4526
|
+
}
|
|
4527
|
+
*flowCollection(e) {
|
|
4528
|
+
const t = e.items[e.items.length - 1];
|
|
4529
|
+
if ("flow-error-end" === this.type) {
|
|
4530
|
+
let e;
|
|
4531
|
+
do {
|
|
4532
|
+
yield* this.pop(), (e = this.peek(1));
|
|
4533
|
+
} while (e && "flow-collection" === e.type);
|
|
4534
|
+
} else if (0 === e.end.length) {
|
|
4535
|
+
switch (this.type) {
|
|
4536
|
+
case "comma":
|
|
4537
|
+
case "explicit-key-ind":
|
|
4538
|
+
return void (!t || t.sep ? e.items.push({ start: [this.sourceToken] }) : t.start.push(this.sourceToken));
|
|
4539
|
+
case "map-value-ind":
|
|
4540
|
+
return void (!t || t.value
|
|
4541
|
+
? e.items.push({ start: [], key: null, sep: [this.sourceToken] })
|
|
4542
|
+
: t.sep
|
|
4543
|
+
? t.sep.push(this.sourceToken)
|
|
4544
|
+
: Object.assign(t, { key: null, sep: [this.sourceToken] }));
|
|
4545
|
+
case "space":
|
|
4546
|
+
case "comment":
|
|
4547
|
+
case "newline":
|
|
4548
|
+
case "anchor":
|
|
4549
|
+
case "tag":
|
|
4550
|
+
return void (!t || t.value
|
|
4551
|
+
? e.items.push({ start: [this.sourceToken] })
|
|
4552
|
+
: t.sep
|
|
4553
|
+
? t.sep.push(this.sourceToken)
|
|
4554
|
+
: t.start.push(this.sourceToken));
|
|
4555
|
+
case "alias":
|
|
4556
|
+
case "scalar":
|
|
4557
|
+
case "single-quoted-scalar":
|
|
4558
|
+
case "double-quoted-scalar": {
|
|
4559
|
+
const n = this.flowScalar(this.type);
|
|
4560
|
+
return void (!t || t.value
|
|
4561
|
+
? e.items.push({ start: [], key: n, sep: [] })
|
|
4562
|
+
: t.sep
|
|
4563
|
+
? this.stack.push(n)
|
|
4564
|
+
: Object.assign(t, { key: n, sep: [] }));
|
|
4565
|
+
}
|
|
4566
|
+
case "flow-map-end":
|
|
4567
|
+
case "flow-seq-end":
|
|
4568
|
+
return void e.end.push(this.sourceToken);
|
|
4569
|
+
}
|
|
4570
|
+
const n = this.startBlockValue(e);
|
|
4571
|
+
n ? this.stack.push(n) : (yield* this.pop(), yield* this.step());
|
|
4572
|
+
} else {
|
|
4573
|
+
const t = this.peek(2);
|
|
4574
|
+
if (
|
|
4575
|
+
"block-map" === t.type &&
|
|
4576
|
+
(("map-value-ind" === this.type && t.indent === e.indent) ||
|
|
4577
|
+
("newline" === this.type && !t.items[t.items.length - 1].sep))
|
|
4578
|
+
)
|
|
4579
|
+
yield* this.pop(), yield* this.step();
|
|
4580
|
+
else if ("map-value-ind" === this.type && "flow-collection" !== t.type) {
|
|
4581
|
+
const n = Nn(En(t));
|
|
4582
|
+
On(e);
|
|
4583
|
+
const s = e.end.splice(1, e.end.length);
|
|
4584
|
+
s.push(this.sourceToken);
|
|
4585
|
+
const i = { type: "block-map", offset: e.offset, indent: e.indent, items: [{ start: n, key: e, sep: s }] };
|
|
4586
|
+
(this.onKeyLine = !0), (this.stack[this.stack.length - 1] = i);
|
|
4587
|
+
} else yield* this.lineEnd(e);
|
|
4588
|
+
}
|
|
4589
|
+
}
|
|
4590
|
+
flowScalar(e) {
|
|
4591
|
+
if (this.onNewLine) {
|
|
4592
|
+
let e = this.source.indexOf("\n") + 1;
|
|
4593
|
+
for (; 0 !== e;) this.onNewLine(this.offset + e), (e = this.source.indexOf("\n", e) + 1);
|
|
4594
|
+
}
|
|
4595
|
+
return { type: e, offset: this.offset, indent: this.indent, source: this.source };
|
|
4596
|
+
}
|
|
4597
|
+
startBlockValue(e) {
|
|
4598
|
+
switch (this.type) {
|
|
4599
|
+
case "alias":
|
|
4600
|
+
case "scalar":
|
|
4601
|
+
case "single-quoted-scalar":
|
|
4602
|
+
case "double-quoted-scalar":
|
|
4603
|
+
return this.flowScalar(this.type);
|
|
4604
|
+
case "block-scalar-header":
|
|
4605
|
+
return {
|
|
4606
|
+
type: "block-scalar",
|
|
4607
|
+
offset: this.offset,
|
|
4608
|
+
indent: this.indent,
|
|
4609
|
+
props: [this.sourceToken],
|
|
4610
|
+
source: "",
|
|
4611
|
+
};
|
|
4612
|
+
case "flow-map-start":
|
|
4613
|
+
case "flow-seq-start":
|
|
4614
|
+
return {
|
|
4615
|
+
type: "flow-collection",
|
|
4616
|
+
offset: this.offset,
|
|
4617
|
+
indent: this.indent,
|
|
4618
|
+
start: this.sourceToken,
|
|
4619
|
+
items: [],
|
|
4620
|
+
end: [],
|
|
4621
|
+
};
|
|
4622
|
+
case "seq-item-ind":
|
|
4623
|
+
return {
|
|
4624
|
+
type: "block-seq",
|
|
4625
|
+
offset: this.offset,
|
|
4626
|
+
indent: this.indent,
|
|
4627
|
+
items: [{ start: [this.sourceToken] }],
|
|
4628
|
+
};
|
|
4629
|
+
case "explicit-key-ind": {
|
|
4630
|
+
this.onKeyLine = !0;
|
|
4631
|
+
const t = Nn(En(e));
|
|
4632
|
+
return (
|
|
4633
|
+
t.push(this.sourceToken),
|
|
4634
|
+
{ type: "block-map", offset: this.offset, indent: this.indent, items: [{ start: t, explicitKey: !0 }] }
|
|
4635
|
+
);
|
|
4636
|
+
}
|
|
4637
|
+
case "map-value-ind": {
|
|
4638
|
+
this.onKeyLine = !0;
|
|
4639
|
+
const t = Nn(En(e));
|
|
4640
|
+
return {
|
|
4641
|
+
type: "block-map",
|
|
4642
|
+
offset: this.offset,
|
|
4643
|
+
indent: this.indent,
|
|
4644
|
+
items: [{ start: t, key: null, sep: [this.sourceToken] }],
|
|
4645
|
+
};
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
return null;
|
|
4649
|
+
}
|
|
4650
|
+
atIndentedComment(e, t) {
|
|
4651
|
+
return (
|
|
4652
|
+
"comment" === this.type && !(this.indent <= t) && e.every((e) => "newline" === e.type || "space" === e.type)
|
|
4653
|
+
);
|
|
4654
|
+
}
|
|
4655
|
+
*documentEnd(e) {
|
|
4656
|
+
"doc-mode" !== this.type &&
|
|
4657
|
+
(e.end ? e.end.push(this.sourceToken) : (e.end = [this.sourceToken]),
|
|
4658
|
+
"newline" === this.type && (yield* this.pop()));
|
|
4659
|
+
}
|
|
4660
|
+
*lineEnd(e) {
|
|
4661
|
+
switch (this.type) {
|
|
4662
|
+
case "comma":
|
|
4663
|
+
case "doc-start":
|
|
4664
|
+
case "doc-end":
|
|
4665
|
+
case "flow-seq-end":
|
|
4666
|
+
case "flow-map-end":
|
|
4667
|
+
case "map-value-ind":
|
|
4668
|
+
yield* this.pop(), yield* this.step();
|
|
4669
|
+
break;
|
|
4670
|
+
case "newline":
|
|
4671
|
+
this.onKeyLine = !1;
|
|
4672
|
+
default:
|
|
4673
|
+
e.end ? e.end.push(this.sourceToken) : (e.end = [this.sourceToken]),
|
|
4674
|
+
"newline" === this.type && (yield* this.pop());
|
|
4675
|
+
}
|
|
4676
|
+
}
|
|
4677
|
+
}
|
|
4678
|
+
function In(e) {
|
|
4679
|
+
const t = !1 !== e.prettyErrors;
|
|
4680
|
+
return { lineCounter: e.lineCounter || (t && new kn()) || null, prettyErrors: t };
|
|
4681
|
+
}
|
|
4682
|
+
function Tn(e, t = {}) {
|
|
4683
|
+
const { lineCounter: n, prettyErrors: s } = In(t),
|
|
4684
|
+
i = new An(n?.addNewLine),
|
|
4685
|
+
o = new Qt(t);
|
|
4686
|
+
let r = null;
|
|
4687
|
+
for (const t of o.compose(i.parse(e), !0, e.length))
|
|
4688
|
+
if (r) {
|
|
4689
|
+
if ("silent" !== r.options.logLevel) {
|
|
4690
|
+
r.errors.push(
|
|
4691
|
+
new Nt(
|
|
4692
|
+
t.range.slice(0, 2),
|
|
4693
|
+
"MULTIPLE_DOCS",
|
|
4694
|
+
"Source contains multiple documents; please use YAML.parseAllDocuments()"
|
|
4695
|
+
)
|
|
4696
|
+
);
|
|
4697
|
+
break;
|
|
4698
|
+
}
|
|
4699
|
+
} else r = t;
|
|
4700
|
+
return s && n && (r.errors.forEach(At(e, n)), r.warnings.forEach(At(e, n))), r;
|
|
4701
|
+
}
|
|
4702
|
+
return (
|
|
4703
|
+
(e.Alias = B),
|
|
4704
|
+
(e.CST = fn),
|
|
4705
|
+
(e.Composer = Qt),
|
|
4706
|
+
(e.Document = vt),
|
|
4707
|
+
(e.Lexer = bn),
|
|
4708
|
+
(e.LineCounter = kn),
|
|
4709
|
+
(e.Pair = pe),
|
|
4710
|
+
(e.Parser = An),
|
|
4711
|
+
(e.Scalar = D),
|
|
4712
|
+
(e.Schema = wt),
|
|
4713
|
+
(e.YAMLError = Et),
|
|
4714
|
+
(e.YAMLMap = we),
|
|
4715
|
+
(e.YAMLParseError = Nt),
|
|
4716
|
+
(e.YAMLSeq = Se),
|
|
4717
|
+
(e.YAMLWarning = Ot),
|
|
4718
|
+
(e.isAlias = c),
|
|
4719
|
+
(e.isCollection = p),
|
|
4720
|
+
(e.isDocument = l),
|
|
4721
|
+
(e.isMap = u),
|
|
4722
|
+
(e.isNode = m),
|
|
4723
|
+
(e.isPair = f),
|
|
4724
|
+
(e.isScalar = h),
|
|
4725
|
+
(e.isSeq = d),
|
|
4726
|
+
(e.parse = function (e, t, n) {
|
|
4727
|
+
let s;
|
|
4728
|
+
"function" == typeof t ? (s = t) : void 0 === n && t && "object" == typeof t && (n = t);
|
|
4729
|
+
const i = Tn(e, n);
|
|
4730
|
+
if (!i) return null;
|
|
4731
|
+
if ((i.warnings.forEach((e) => ae(i.options.logLevel, e)), i.errors.length > 0)) {
|
|
4732
|
+
if ("silent" !== i.options.logLevel) throw i.errors[0];
|
|
4733
|
+
i.errors = [];
|
|
4734
|
+
}
|
|
4735
|
+
return i.toJS(Object.assign({ reviver: s }, n));
|
|
4736
|
+
}),
|
|
4737
|
+
(e.parseAllDocuments = function (e, t = {}) {
|
|
4738
|
+
const { lineCounter: n, prettyErrors: s } = In(t),
|
|
4739
|
+
i = new An(n?.addNewLine),
|
|
4740
|
+
o = new Qt(t),
|
|
4741
|
+
r = Array.from(o.compose(i.parse(e)));
|
|
4742
|
+
if (s && n) for (const t of r) t.errors.forEach(At(e, n)), t.warnings.forEach(At(e, n));
|
|
4743
|
+
return r.length > 0 ? r : Object.assign([], { empty: !0 }, o.streamInfo());
|
|
4744
|
+
}),
|
|
4745
|
+
(e.parseDocument = Tn),
|
|
4746
|
+
(e.stringify = function (e, t, n) {
|
|
4747
|
+
let s = null;
|
|
4748
|
+
if (
|
|
4749
|
+
("function" == typeof t || Array.isArray(t) ? (s = t) : void 0 === n && t && (n = t),
|
|
4750
|
+
"string" == typeof n && (n = n.length),
|
|
4751
|
+
"number" == typeof n)
|
|
4752
|
+
) {
|
|
4753
|
+
const e = Math.round(n);
|
|
4754
|
+
n = e < 1 ? void 0 : e > 8 ? { indent: 8 } : { indent: e };
|
|
4755
|
+
}
|
|
4756
|
+
if (void 0 === e) {
|
|
4757
|
+
const { keepUndefined: e } = n ?? t ?? {};
|
|
4758
|
+
if (!e) return;
|
|
4759
|
+
}
|
|
4760
|
+
return l(e) && !s ? e.toString(n) : new vt(e, s, n).toString(n);
|
|
4761
|
+
}),
|
|
4762
|
+
(e.visit = w),
|
|
4763
|
+
(e.visitAsync = S),
|
|
4764
|
+
e
|
|
4765
|
+
);
|
|
4766
|
+
})({});
|
|
4767
|
+
//# sourceMappingURL=bundle.min.js.map
|
|
4768
|
+
// window.Yaml = Yaml;
|
|
4769
|
+
|
|
4770
|
+
export default Yaml;
|