@cloud-cli/on 0.1.1 → 0.1.3
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/dist/on.js +1017 -947
- package/package.json +2 -1
- package/dist/package.json +0 -26
package/dist/on.js
CHANGED
|
@@ -2,22 +2,61 @@
|
|
|
2
2
|
import { createServer as ms } from "node:http";
|
|
3
3
|
import { parseArgs as gs } from "node:util";
|
|
4
4
|
import { spawn as ys } from "node:child_process";
|
|
5
|
-
import { readFile as
|
|
6
|
-
import
|
|
7
|
-
|
|
5
|
+
import { readFile as tt, mkdtemp as bs, rm as ws } from "node:fs/promises";
|
|
6
|
+
import wt, { join as ks } from "node:path";
|
|
7
|
+
import { existsSync as Ss } from "node:fs";
|
|
8
|
+
import { tmpdir as Ns } from "node:os";
|
|
9
|
+
async function Os(s) {
|
|
10
|
+
const e = [];
|
|
11
|
+
for await (const t of s)
|
|
12
|
+
e.push(Buffer.isBuffer(t) ? t : Buffer.from(t));
|
|
13
|
+
return Buffer.concat(e).toString("utf8");
|
|
14
|
+
}
|
|
15
|
+
function Re(s, e, t) {
|
|
16
|
+
s.writeHead(e, { "content-type": "application/json" }).end(JSON.stringify(t));
|
|
17
|
+
}
|
|
18
|
+
function As(s) {
|
|
19
|
+
const e = Number.parseInt(s, 10);
|
|
20
|
+
if (!Number.isInteger(e) || e < 0 || e > 65535)
|
|
21
|
+
throw new Error(
|
|
22
|
+
`Invalid --port value '${s}'. Expected an integer from 0 to 65535.`
|
|
23
|
+
);
|
|
24
|
+
return e;
|
|
25
|
+
}
|
|
26
|
+
function st(s) {
|
|
27
|
+
if (!s || typeof s != "object" || Array.isArray(s))
|
|
28
|
+
throw new Error("Incoming webhook payload must be a JSON object.");
|
|
29
|
+
return s;
|
|
30
|
+
}
|
|
31
|
+
function Ce(s, e) {
|
|
32
|
+
const t = Function(
|
|
33
|
+
"context",
|
|
34
|
+
"const { secrets = {}, inputs = {}, step = {}, env } = context;return `" + s + "`;"
|
|
35
|
+
);
|
|
36
|
+
return String(t(e) || "");
|
|
37
|
+
}
|
|
38
|
+
function Es(s, e) {
|
|
39
|
+
if (!e)
|
|
40
|
+
return { ...s };
|
|
41
|
+
const t = { inputs: s };
|
|
42
|
+
for (const [n, i] of Object.entries(e))
|
|
43
|
+
t.inputs[n] = Ce(`\${${i}}`, t);
|
|
44
|
+
return t.inputs;
|
|
45
|
+
}
|
|
46
|
+
const nt = /* @__PURE__ */ Symbol.for("yaml.alias"), Qe = /* @__PURE__ */ Symbol.for("yaml.document"), J = /* @__PURE__ */ Symbol.for("yaml.map"), Ct = /* @__PURE__ */ Symbol.for("yaml.pair"), q = /* @__PURE__ */ Symbol.for("yaml.scalar"), oe = /* @__PURE__ */ Symbol.for("yaml.seq"), P = /* @__PURE__ */ Symbol.for("yaml.node.type"), Q = (s) => !!s && typeof s == "object" && s[P] === nt, _e = (s) => !!s && typeof s == "object" && s[P] === Qe, ye = (s) => !!s && typeof s == "object" && s[P] === J, L = (s) => !!s && typeof s == "object" && s[P] === Ct, T = (s) => !!s && typeof s == "object" && s[P] === q, be = (s) => !!s && typeof s == "object" && s[P] === oe;
|
|
8
47
|
function I(s) {
|
|
9
48
|
if (s && typeof s == "object")
|
|
10
|
-
switch (s[
|
|
49
|
+
switch (s[P]) {
|
|
11
50
|
case J:
|
|
12
51
|
case oe:
|
|
13
52
|
return !0;
|
|
14
53
|
}
|
|
15
54
|
return !1;
|
|
16
55
|
}
|
|
17
|
-
function
|
|
56
|
+
function $(s) {
|
|
18
57
|
if (s && typeof s == "object")
|
|
19
|
-
switch (s[
|
|
20
|
-
case
|
|
58
|
+
switch (s[P]) {
|
|
59
|
+
case nt:
|
|
21
60
|
case J:
|
|
22
61
|
case q:
|
|
23
62
|
case oe:
|
|
@@ -25,18 +64,18 @@ function L(s) {
|
|
|
25
64
|
}
|
|
26
65
|
return !1;
|
|
27
66
|
}
|
|
28
|
-
const
|
|
29
|
-
function
|
|
30
|
-
const t =
|
|
31
|
-
|
|
67
|
+
const _t = (s) => (T(s) || I(s)) && !!s.anchor, Y = /* @__PURE__ */ Symbol("break visit"), Ts = /* @__PURE__ */ Symbol("skip children"), de = /* @__PURE__ */ Symbol("remove node");
|
|
68
|
+
function ae(s, e) {
|
|
69
|
+
const t = Is(e);
|
|
70
|
+
_e(s) ? Z(null, s.contents, t, Object.freeze([s])) === de && (s.contents = null) : Z(null, s, t, Object.freeze([]));
|
|
32
71
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
72
|
+
ae.BREAK = Y;
|
|
73
|
+
ae.SKIP = Ts;
|
|
74
|
+
ae.REMOVE = de;
|
|
36
75
|
function Z(s, e, t, n) {
|
|
37
|
-
const i =
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
76
|
+
const i = $s(s, e, t, n);
|
|
77
|
+
if ($(i) || L(i))
|
|
78
|
+
return Ls(s, n, i), Z(s, i, t, n);
|
|
40
79
|
if (typeof i != "symbol") {
|
|
41
80
|
if (I(e)) {
|
|
42
81
|
n = Object.freeze(n.concat(e));
|
|
@@ -50,7 +89,7 @@ function Z(s, e, t, n) {
|
|
|
50
89
|
o === de && (e.items.splice(r, 1), r -= 1);
|
|
51
90
|
}
|
|
52
91
|
}
|
|
53
|
-
} else if (
|
|
92
|
+
} else if (L(e)) {
|
|
54
93
|
n = Object.freeze(n.concat(e));
|
|
55
94
|
const r = Z("key", e.key, t, n);
|
|
56
95
|
if (r === Y)
|
|
@@ -64,7 +103,7 @@ function Z(s, e, t, n) {
|
|
|
64
103
|
}
|
|
65
104
|
return i;
|
|
66
105
|
}
|
|
67
|
-
function
|
|
106
|
+
function Is(s) {
|
|
68
107
|
return typeof s == "object" && (s.Collection || s.Node || s.Value) ? Object.assign({
|
|
69
108
|
Alias: s.Node,
|
|
70
109
|
Map: s.Node,
|
|
@@ -79,41 +118,41 @@ function ws(s) {
|
|
|
79
118
|
Seq: s.Collection
|
|
80
119
|
}, s) : s;
|
|
81
120
|
}
|
|
82
|
-
function
|
|
121
|
+
function $s(s, e, t, n) {
|
|
83
122
|
if (typeof t == "function")
|
|
84
123
|
return t(s, e, n);
|
|
85
124
|
if (ye(e))
|
|
86
125
|
return t.Map?.(s, e, n);
|
|
87
126
|
if (be(e))
|
|
88
127
|
return t.Seq?.(s, e, n);
|
|
89
|
-
if (
|
|
128
|
+
if (L(e))
|
|
90
129
|
return t.Pair?.(s, e, n);
|
|
91
|
-
if (
|
|
130
|
+
if (T(e))
|
|
92
131
|
return t.Scalar?.(s, e, n);
|
|
93
132
|
if (Q(e))
|
|
94
133
|
return t.Alias?.(s, e, n);
|
|
95
134
|
}
|
|
96
|
-
function
|
|
135
|
+
function Ls(s, e, t) {
|
|
97
136
|
const n = e[e.length - 1];
|
|
98
137
|
if (I(n))
|
|
99
138
|
n.items[s] = t;
|
|
100
|
-
else if (
|
|
139
|
+
else if (L(n))
|
|
101
140
|
s === "key" ? n.key = t : n.value = t;
|
|
102
|
-
else if (
|
|
141
|
+
else if (_e(n))
|
|
103
142
|
n.contents = t;
|
|
104
143
|
else {
|
|
105
144
|
const i = Q(n) ? "alias" : "scalar";
|
|
106
145
|
throw new Error(`Cannot replace node with ${i} parent`);
|
|
107
146
|
}
|
|
108
147
|
}
|
|
109
|
-
const
|
|
148
|
+
const vs = {
|
|
110
149
|
"!": "%21",
|
|
111
150
|
",": "%2C",
|
|
112
151
|
"[": "%5B",
|
|
113
152
|
"]": "%5D",
|
|
114
153
|
"{": "%7B",
|
|
115
154
|
"}": "%7D"
|
|
116
|
-
},
|
|
155
|
+
}, Cs = (s) => s.replace(/[!,[\]{}]/g, (e) => vs[e]);
|
|
117
156
|
class _ {
|
|
118
157
|
constructor(e, t) {
|
|
119
158
|
this.docStart = null, this.docEnd = !1, this.yaml = Object.assign({}, _.defaultYaml, e), this.tags = Object.assign({}, _.defaultTags, t);
|
|
@@ -203,56 +242,56 @@ class _ {
|
|
|
203
242
|
tagString(e) {
|
|
204
243
|
for (const [t, n] of Object.entries(this.tags))
|
|
205
244
|
if (e.startsWith(n))
|
|
206
|
-
return t +
|
|
245
|
+
return t + Cs(e.substring(n.length));
|
|
207
246
|
return e[0] === "!" ? e : `!<${e}>`;
|
|
208
247
|
}
|
|
209
248
|
toString(e) {
|
|
210
249
|
const t = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : [], n = Object.entries(this.tags);
|
|
211
250
|
let i;
|
|
212
|
-
if (e && n.length > 0 &&
|
|
251
|
+
if (e && n.length > 0 && $(e.contents)) {
|
|
213
252
|
const r = {};
|
|
214
|
-
|
|
215
|
-
|
|
253
|
+
ae(e.contents, (o, a) => {
|
|
254
|
+
$(a) && a.tag && (r[a.tag] = !0);
|
|
216
255
|
}), i = Object.keys(r);
|
|
217
256
|
} else
|
|
218
257
|
i = [];
|
|
219
258
|
for (const [r, o] of n)
|
|
220
|
-
r === "!!" && o === "tag:yaml.org,2002:" || (!e || i.some((
|
|
259
|
+
r === "!!" && o === "tag:yaml.org,2002:" || (!e || i.some((a) => a.startsWith(o))) && t.push(`%TAG ${r} ${o}`);
|
|
221
260
|
return t.join(`
|
|
222
261
|
`);
|
|
223
262
|
}
|
|
224
263
|
}
|
|
225
264
|
_.defaultYaml = { explicit: !1, version: "1.2" };
|
|
226
265
|
_.defaultTags = { "!!": "tag:yaml.org,2002:" };
|
|
227
|
-
function
|
|
266
|
+
function Bt(s) {
|
|
228
267
|
if (/[\x00-\x19\s,[\]{}]/.test(s)) {
|
|
229
268
|
const t = `Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;
|
|
230
269
|
throw new Error(t);
|
|
231
270
|
}
|
|
232
271
|
return !0;
|
|
233
272
|
}
|
|
234
|
-
function
|
|
273
|
+
function Mt(s) {
|
|
235
274
|
const e = /* @__PURE__ */ new Set();
|
|
236
|
-
return
|
|
275
|
+
return ae(s, {
|
|
237
276
|
Value(t, n) {
|
|
238
277
|
n.anchor && e.add(n.anchor);
|
|
239
278
|
}
|
|
240
279
|
}), e;
|
|
241
280
|
}
|
|
242
|
-
function
|
|
281
|
+
function jt(s, e) {
|
|
243
282
|
for (let t = 1; ; ++t) {
|
|
244
283
|
const n = `${s}${t}`;
|
|
245
284
|
if (!e.has(n))
|
|
246
285
|
return n;
|
|
247
286
|
}
|
|
248
287
|
}
|
|
249
|
-
function
|
|
288
|
+
function _s(s, e) {
|
|
250
289
|
const t = [], n = /* @__PURE__ */ new Map();
|
|
251
290
|
let i = null;
|
|
252
291
|
return {
|
|
253
292
|
onAnchor: (r) => {
|
|
254
|
-
t.push(r), i ?? (i =
|
|
255
|
-
const o =
|
|
293
|
+
t.push(r), i ?? (i = Mt(s));
|
|
294
|
+
const o = jt(e, i);
|
|
256
295
|
return i.add(o), o;
|
|
257
296
|
},
|
|
258
297
|
/**
|
|
@@ -263,11 +302,11 @@ function As(s, e) {
|
|
|
263
302
|
setAnchors: () => {
|
|
264
303
|
for (const r of t) {
|
|
265
304
|
const o = n.get(r);
|
|
266
|
-
if (typeof o == "object" && o.anchor && (
|
|
305
|
+
if (typeof o == "object" && o.anchor && (T(o.node) || I(o.node)))
|
|
267
306
|
o.node.anchor = o.anchor;
|
|
268
307
|
else {
|
|
269
|
-
const
|
|
270
|
-
throw
|
|
308
|
+
const a = new Error("Failed to resolve repeated object (this should not happen)");
|
|
309
|
+
throw a.source = r, a;
|
|
271
310
|
}
|
|
272
311
|
}
|
|
273
312
|
},
|
|
@@ -278,8 +317,8 @@ function ee(s, e, t, n) {
|
|
|
278
317
|
if (n && typeof n == "object")
|
|
279
318
|
if (Array.isArray(n))
|
|
280
319
|
for (let i = 0, r = n.length; i < r; ++i) {
|
|
281
|
-
const o = n[i],
|
|
282
|
-
|
|
320
|
+
const o = n[i], a = ee(s, n, String(i), o);
|
|
321
|
+
a === void 0 ? delete n[i] : a !== o && (n[i] = a);
|
|
283
322
|
}
|
|
284
323
|
else if (n instanceof Map)
|
|
285
324
|
for (const i of Array.from(n.keys())) {
|
|
@@ -298,11 +337,11 @@ function ee(s, e, t, n) {
|
|
|
298
337
|
}
|
|
299
338
|
return s.call(e, t, n);
|
|
300
339
|
}
|
|
301
|
-
function
|
|
340
|
+
function j(s, e, t) {
|
|
302
341
|
if (Array.isArray(s))
|
|
303
|
-
return s.map((n, i) =>
|
|
342
|
+
return s.map((n, i) => j(n, String(i), t));
|
|
304
343
|
if (s && typeof s.toJSON == "function") {
|
|
305
|
-
if (!t || !
|
|
344
|
+
if (!t || !_t(s))
|
|
306
345
|
return s.toJSON(e, t);
|
|
307
346
|
const n = { aliasCount: 0, count: 1, res: void 0 };
|
|
308
347
|
t.anchors.set(s, n), t.onCreate = (r) => {
|
|
@@ -313,9 +352,9 @@ function P(s, e, t) {
|
|
|
313
352
|
}
|
|
314
353
|
return typeof s == "bigint" && !t?.keep ? Number(s) : s;
|
|
315
354
|
}
|
|
316
|
-
class
|
|
355
|
+
class it {
|
|
317
356
|
constructor(e) {
|
|
318
|
-
Object.defineProperty(this,
|
|
357
|
+
Object.defineProperty(this, P, { value: e });
|
|
319
358
|
}
|
|
320
359
|
/** Create a copy of this node. */
|
|
321
360
|
clone() {
|
|
@@ -324,7 +363,7 @@ class st {
|
|
|
324
363
|
}
|
|
325
364
|
/** A plain JavaScript representation of this node. */
|
|
326
365
|
toJS(e, { mapAsMap: t, maxAliasCount: n, onAnchor: i, reviver: r } = {}) {
|
|
327
|
-
if (!
|
|
366
|
+
if (!_e(e))
|
|
328
367
|
throw new TypeError("A document argument is required");
|
|
329
368
|
const o = {
|
|
330
369
|
anchors: /* @__PURE__ */ new Map(),
|
|
@@ -333,16 +372,16 @@ class st {
|
|
|
333
372
|
mapAsMap: t === !0,
|
|
334
373
|
mapKeyWarned: !1,
|
|
335
374
|
maxAliasCount: typeof n == "number" ? n : 100
|
|
336
|
-
},
|
|
375
|
+
}, a = j(this, "", o);
|
|
337
376
|
if (typeof i == "function")
|
|
338
|
-
for (const { count:
|
|
339
|
-
i(c,
|
|
340
|
-
return typeof r == "function" ? ee(r, { "":
|
|
377
|
+
for (const { count: l, res: c } of o.anchors.values())
|
|
378
|
+
i(c, l);
|
|
379
|
+
return typeof r == "function" ? ee(r, { "": a }, "", a) : a;
|
|
341
380
|
}
|
|
342
381
|
}
|
|
343
|
-
class
|
|
382
|
+
class rt extends it {
|
|
344
383
|
constructor(e) {
|
|
345
|
-
super(
|
|
384
|
+
super(nt), this.source = e, Object.defineProperty(this, "tag", {
|
|
346
385
|
set() {
|
|
347
386
|
throw new Error("Alias nodes cannot have tags");
|
|
348
387
|
}
|
|
@@ -354,9 +393,9 @@ class nt extends st {
|
|
|
354
393
|
*/
|
|
355
394
|
resolve(e, t) {
|
|
356
395
|
let n;
|
|
357
|
-
t?.aliasResolveCache ? n = t.aliasResolveCache : (n = [],
|
|
396
|
+
t?.aliasResolveCache ? n = t.aliasResolveCache : (n = [], ae(e, {
|
|
358
397
|
Node: (r, o) => {
|
|
359
|
-
(Q(o) ||
|
|
398
|
+
(Q(o) || _t(o)) && n.push(o);
|
|
360
399
|
}
|
|
361
400
|
}), t && (t.aliasResolveCache = n));
|
|
362
401
|
let i;
|
|
@@ -372,24 +411,24 @@ class nt extends st {
|
|
|
372
411
|
return { source: this.source };
|
|
373
412
|
const { anchors: n, doc: i, maxAliasCount: r } = t, o = this.resolve(i, t);
|
|
374
413
|
if (!o) {
|
|
375
|
-
const
|
|
376
|
-
throw new ReferenceError(
|
|
414
|
+
const l = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
415
|
+
throw new ReferenceError(l);
|
|
377
416
|
}
|
|
378
|
-
let
|
|
379
|
-
if (
|
|
380
|
-
const
|
|
381
|
-
throw new ReferenceError(
|
|
417
|
+
let a = n.get(o);
|
|
418
|
+
if (a || (j(o, null, t), a = n.get(o)), a?.res === void 0) {
|
|
419
|
+
const l = "This should not happen: Alias anchor was not resolved?";
|
|
420
|
+
throw new ReferenceError(l);
|
|
382
421
|
}
|
|
383
|
-
if (r >= 0 && (
|
|
384
|
-
const
|
|
385
|
-
throw new ReferenceError(
|
|
422
|
+
if (r >= 0 && (a.count += 1, a.aliasCount === 0 && (a.aliasCount = Te(i, o, n)), a.count * a.aliasCount > r)) {
|
|
423
|
+
const l = "Excessive alias count indicates a resource exhaustion attack";
|
|
424
|
+
throw new ReferenceError(l);
|
|
386
425
|
}
|
|
387
|
-
return
|
|
426
|
+
return a.res;
|
|
388
427
|
}
|
|
389
428
|
toString(e, t, n) {
|
|
390
429
|
const i = `*${this.source}`;
|
|
391
430
|
if (e) {
|
|
392
|
-
if (
|
|
431
|
+
if (Bt(this.source), e.options.verifyAliasOrder && !e.anchors.has(this.source)) {
|
|
393
432
|
const r = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
394
433
|
throw new Error(r);
|
|
395
434
|
}
|
|
@@ -399,30 +438,30 @@ class nt extends st {
|
|
|
399
438
|
return i;
|
|
400
439
|
}
|
|
401
440
|
}
|
|
402
|
-
function
|
|
441
|
+
function Te(s, e, t) {
|
|
403
442
|
if (Q(e)) {
|
|
404
443
|
const n = e.resolve(s), i = t && n && t.get(n);
|
|
405
444
|
return i ? i.count * i.aliasCount : 0;
|
|
406
445
|
} else if (I(e)) {
|
|
407
446
|
let n = 0;
|
|
408
447
|
for (const i of e.items) {
|
|
409
|
-
const r =
|
|
448
|
+
const r = Te(s, i, t);
|
|
410
449
|
r > n && (n = r);
|
|
411
450
|
}
|
|
412
451
|
return n;
|
|
413
|
-
} else if (
|
|
414
|
-
const n =
|
|
452
|
+
} else if (L(e)) {
|
|
453
|
+
const n = Te(s, e.key, t), i = Te(s, e.value, t);
|
|
415
454
|
return Math.max(n, i);
|
|
416
455
|
}
|
|
417
456
|
return 1;
|
|
418
457
|
}
|
|
419
458
|
const Pt = (s) => !s || typeof s != "function" && typeof s != "object";
|
|
420
|
-
class O extends
|
|
459
|
+
class O extends it {
|
|
421
460
|
constructor(e) {
|
|
422
461
|
super(q), this.value = e;
|
|
423
462
|
}
|
|
424
463
|
toJSON(e, t) {
|
|
425
|
-
return t?.keep ? this.value :
|
|
464
|
+
return t?.keep ? this.value : j(this.value, e, t);
|
|
426
465
|
}
|
|
427
466
|
toString() {
|
|
428
467
|
return String(this.value);
|
|
@@ -433,8 +472,8 @@ O.BLOCK_LITERAL = "BLOCK_LITERAL";
|
|
|
433
472
|
O.PLAIN = "PLAIN";
|
|
434
473
|
O.QUOTE_DOUBLE = "QUOTE_DOUBLE";
|
|
435
474
|
O.QUOTE_SINGLE = "QUOTE_SINGLE";
|
|
436
|
-
const
|
|
437
|
-
function
|
|
475
|
+
const Bs = "tag:yaml.org,2002:";
|
|
476
|
+
function Ms(s, e, t) {
|
|
438
477
|
if (e) {
|
|
439
478
|
const n = t.filter((r) => r.tag === e), i = n.find((r) => !r.format) ?? n[0];
|
|
440
479
|
if (!i)
|
|
@@ -444,34 +483,34 @@ function Es(s, e, t) {
|
|
|
444
483
|
return t.find((n) => n.identify?.(s) && !n.format);
|
|
445
484
|
}
|
|
446
485
|
function me(s, e, t) {
|
|
447
|
-
if (
|
|
486
|
+
if (_e(s) && (s = s.contents), $(s))
|
|
448
487
|
return s;
|
|
449
|
-
if (
|
|
450
|
-
const
|
|
451
|
-
return
|
|
488
|
+
if (L(s)) {
|
|
489
|
+
const u = t.schema[J].createNode?.(t.schema, null, t);
|
|
490
|
+
return u.items.push(s), u;
|
|
452
491
|
}
|
|
453
492
|
(s instanceof String || s instanceof Number || s instanceof Boolean || typeof BigInt < "u" && s instanceof BigInt) && (s = s.valueOf());
|
|
454
|
-
const { aliasDuplicateObjects: n, onAnchor: i, onTagObj: r, schema: o, sourceObjects:
|
|
455
|
-
let
|
|
493
|
+
const { aliasDuplicateObjects: n, onAnchor: i, onTagObj: r, schema: o, sourceObjects: a } = t;
|
|
494
|
+
let l;
|
|
456
495
|
if (n && s && typeof s == "object") {
|
|
457
|
-
if (
|
|
458
|
-
return
|
|
459
|
-
|
|
496
|
+
if (l = a.get(s), l)
|
|
497
|
+
return l.anchor ?? (l.anchor = i(s)), new rt(l.anchor);
|
|
498
|
+
l = { anchor: null, node: null }, a.set(s, l);
|
|
460
499
|
}
|
|
461
|
-
e?.startsWith("!!") && (e =
|
|
462
|
-
let c =
|
|
500
|
+
e?.startsWith("!!") && (e = Bs + e.slice(2));
|
|
501
|
+
let c = Ms(s, e, o.tags);
|
|
463
502
|
if (!c) {
|
|
464
503
|
if (s && typeof s.toJSON == "function" && (s = s.toJSON()), !s || typeof s != "object") {
|
|
465
|
-
const
|
|
466
|
-
return
|
|
504
|
+
const u = new O(s);
|
|
505
|
+
return l && (l.node = u), u;
|
|
467
506
|
}
|
|
468
507
|
c = s instanceof Map ? o[J] : Symbol.iterator in Object(s) ? o[oe] : o[J];
|
|
469
508
|
}
|
|
470
509
|
r && (r(c), delete t.onTagObj);
|
|
471
510
|
const d = c?.createNode ? c.createNode(t.schema, s, t) : typeof c?.nodeClass?.from == "function" ? c.nodeClass.from(t.schema, s, t) : new O(s);
|
|
472
|
-
return e ? d.tag = e : c.default || (d.tag = c.tag),
|
|
511
|
+
return e ? d.tag = e : c.default || (d.tag = c.tag), l && (l.node = d), d;
|
|
473
512
|
}
|
|
474
|
-
function
|
|
513
|
+
function Le(s, e, t) {
|
|
475
514
|
let n = t;
|
|
476
515
|
for (let i = e.length - 1; i >= 0; --i) {
|
|
477
516
|
const r = e[i];
|
|
@@ -492,7 +531,7 @@ function $e(s, e, t) {
|
|
|
492
531
|
});
|
|
493
532
|
}
|
|
494
533
|
const ue = (s) => s == null || typeof s == "object" && !!s[Symbol.iterator]().next().done;
|
|
495
|
-
class
|
|
534
|
+
class Kt extends it {
|
|
496
535
|
constructor(e, t) {
|
|
497
536
|
super(e), Object.defineProperty(this, "schema", {
|
|
498
537
|
value: t,
|
|
@@ -508,7 +547,7 @@ class jt extends st {
|
|
|
508
547
|
*/
|
|
509
548
|
clone(e) {
|
|
510
549
|
const t = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
511
|
-
return e && (t.schema = e), t.items = t.items.map((n) =>
|
|
550
|
+
return e && (t.schema = e), t.items = t.items.map((n) => $(n) || L(n) ? n.clone(e) : n), this.range && (t.range = this.range.slice()), t;
|
|
512
551
|
}
|
|
513
552
|
/**
|
|
514
553
|
* Adds a value to the collection. For `!!map` and `!!omap` the value must
|
|
@@ -523,7 +562,7 @@ class jt extends st {
|
|
|
523
562
|
if (I(r))
|
|
524
563
|
r.addIn(i, t);
|
|
525
564
|
else if (r === void 0 && this.schema)
|
|
526
|
-
this.set(n,
|
|
565
|
+
this.set(n, Le(this.schema, i, t));
|
|
527
566
|
else
|
|
528
567
|
throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);
|
|
529
568
|
}
|
|
@@ -548,14 +587,14 @@ class jt extends st {
|
|
|
548
587
|
*/
|
|
549
588
|
getIn(e, t) {
|
|
550
589
|
const [n, ...i] = e, r = this.get(n, !0);
|
|
551
|
-
return i.length === 0 ? !t &&
|
|
590
|
+
return i.length === 0 ? !t && T(r) ? r.value : r : I(r) ? r.getIn(i, t) : void 0;
|
|
552
591
|
}
|
|
553
592
|
hasAllNullValues(e) {
|
|
554
593
|
return this.items.every((t) => {
|
|
555
|
-
if (
|
|
594
|
+
if (!L(t))
|
|
556
595
|
return !1;
|
|
557
596
|
const n = t.value;
|
|
558
|
-
return n == null || e &&
|
|
597
|
+
return n == null || e && T(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag;
|
|
559
598
|
});
|
|
560
599
|
}
|
|
561
600
|
/**
|
|
@@ -581,32 +620,32 @@ class jt extends st {
|
|
|
581
620
|
if (I(r))
|
|
582
621
|
r.setIn(i, t);
|
|
583
622
|
else if (r === void 0 && this.schema)
|
|
584
|
-
this.set(n,
|
|
623
|
+
this.set(n, Le(this.schema, i, t));
|
|
585
624
|
else
|
|
586
625
|
throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);
|
|
587
626
|
}
|
|
588
627
|
}
|
|
589
628
|
}
|
|
590
|
-
const
|
|
591
|
-
function
|
|
629
|
+
const js = (s) => s.replace(/^(?!$)(?: $)?/gm, "#");
|
|
630
|
+
function F(s, e) {
|
|
592
631
|
return /^\n+$/.test(s) ? s.substring(1) : e ? s.replace(/^(?! *$)/gm, e) : s;
|
|
593
632
|
}
|
|
594
633
|
const G = (s, e, t) => s.endsWith(`
|
|
595
|
-
`) ?
|
|
634
|
+
`) ? F(t, e) : t.includes(`
|
|
596
635
|
`) ? `
|
|
597
|
-
` +
|
|
598
|
-
function
|
|
636
|
+
` + F(t, e) : (s.endsWith(" ") ? "" : " ") + t, Dt = "flow", Xe = "block", Ie = "quoted";
|
|
637
|
+
function Be(s, e, t = "flow", { indentAtStart: n, lineWidth: i = 80, minContentWidth: r = 20, onFold: o, onOverflow: a } = {}) {
|
|
599
638
|
if (!i || i < 0)
|
|
600
639
|
return s;
|
|
601
640
|
i < r && (r = 0);
|
|
602
|
-
const
|
|
603
|
-
if (s.length <=
|
|
641
|
+
const l = Math.max(1 + r, 1 + i - e.length);
|
|
642
|
+
if (s.length <= l)
|
|
604
643
|
return s;
|
|
605
644
|
const c = [], d = {};
|
|
606
|
-
let
|
|
607
|
-
typeof n == "number" && (n > i - Math.max(2, r) ? c.push(0) :
|
|
608
|
-
let
|
|
609
|
-
t ===
|
|
645
|
+
let u = i - e.length;
|
|
646
|
+
typeof n == "number" && (n > i - Math.max(2, r) ? c.push(0) : u = i - n);
|
|
647
|
+
let f, m, g = !1, h = -1, p = -1, b = -1;
|
|
648
|
+
t === Xe && (h = kt(s, h, e.length), h !== -1 && (u = h + l));
|
|
610
649
|
for (let k; k = s[h += 1]; ) {
|
|
611
650
|
if (t === Ie && k === "\\") {
|
|
612
651
|
switch (p = h, s[h + 1]) {
|
|
@@ -626,30 +665,30 @@ function _e(s, e, t = "flow", { indentAtStart: n, lineWidth: i = 80, minContentW
|
|
|
626
665
|
}
|
|
627
666
|
if (k === `
|
|
628
667
|
`)
|
|
629
|
-
t ===
|
|
668
|
+
t === Xe && (h = kt(s, h, e.length)), u = h + e.length + l, f = void 0;
|
|
630
669
|
else {
|
|
631
670
|
if (k === " " && m && m !== " " && m !== `
|
|
632
671
|
` && m !== " ") {
|
|
633
672
|
const S = s[h + 1];
|
|
634
673
|
S && S !== " " && S !== `
|
|
635
|
-
` && S !== " " && (
|
|
674
|
+
` && S !== " " && (f = h);
|
|
636
675
|
}
|
|
637
|
-
if (h >=
|
|
638
|
-
if (
|
|
639
|
-
c.push(
|
|
676
|
+
if (h >= u)
|
|
677
|
+
if (f)
|
|
678
|
+
c.push(f), u = f + l, f = void 0;
|
|
640
679
|
else if (t === Ie) {
|
|
641
680
|
for (; m === " " || m === " "; )
|
|
642
681
|
m = k, k = s[h += 1], g = !0;
|
|
643
682
|
const S = h > b + 1 ? h - 2 : p - 1;
|
|
644
683
|
if (d[S])
|
|
645
684
|
return s;
|
|
646
|
-
c.push(S), d[S] = !0,
|
|
685
|
+
c.push(S), d[S] = !0, u = S + l, f = void 0;
|
|
647
686
|
} else
|
|
648
687
|
g = !0;
|
|
649
688
|
}
|
|
650
689
|
m = k;
|
|
651
690
|
}
|
|
652
|
-
if (g &&
|
|
691
|
+
if (g && a && a(), c.length === 0)
|
|
653
692
|
return s;
|
|
654
693
|
o && o();
|
|
655
694
|
let w = s.slice(0, c[0]);
|
|
@@ -661,7 +700,7 @@ ${e}${s.slice(S + 1, N)}`);
|
|
|
661
700
|
}
|
|
662
701
|
return w;
|
|
663
702
|
}
|
|
664
|
-
function
|
|
703
|
+
function kt(s, e, t) {
|
|
665
704
|
let n = e, i = e + 1, r = s[i];
|
|
666
705
|
for (; r === " " || r === " "; )
|
|
667
706
|
if (e < i + t)
|
|
@@ -675,12 +714,12 @@ function wt(s, e, t) {
|
|
|
675
714
|
}
|
|
676
715
|
return n;
|
|
677
716
|
}
|
|
678
|
-
const
|
|
717
|
+
const Me = (s, e) => ({
|
|
679
718
|
indentAtStart: e ? s.indent.length : s.indentAtStart,
|
|
680
719
|
lineWidth: s.options.lineWidth,
|
|
681
720
|
minContentWidth: s.options.minContentWidth
|
|
682
|
-
}),
|
|
683
|
-
function
|
|
721
|
+
}), je = (s) => /^(%|---|\.\.\.)/m.test(s);
|
|
722
|
+
function Ps(s, e, t) {
|
|
684
723
|
if (!e || e < 0)
|
|
685
724
|
return !1;
|
|
686
725
|
const n = e - t, i = s.length;
|
|
@@ -700,15 +739,15 @@ function pe(s, e) {
|
|
|
700
739
|
const t = JSON.stringify(s);
|
|
701
740
|
if (e.options.doubleQuotedAsJSON)
|
|
702
741
|
return t;
|
|
703
|
-
const { implicitKey: n } = e, i = e.options.doubleQuotedMinMultiLineLength, r = e.indent || (
|
|
704
|
-
let o = "",
|
|
705
|
-
for (let
|
|
706
|
-
if (c === " " && t[
|
|
707
|
-
switch (t[
|
|
742
|
+
const { implicitKey: n } = e, i = e.options.doubleQuotedMinMultiLineLength, r = e.indent || (je(s) ? " " : "");
|
|
743
|
+
let o = "", a = 0;
|
|
744
|
+
for (let l = 0, c = t[l]; c; c = t[++l])
|
|
745
|
+
if (c === " " && t[l + 1] === "\\" && t[l + 2] === "n" && (o += t.slice(a, l) + "\\ ", l += 1, a = l, c = "\\"), c === "\\")
|
|
746
|
+
switch (t[l + 1]) {
|
|
708
747
|
case "u":
|
|
709
748
|
{
|
|
710
|
-
o += t.slice(
|
|
711
|
-
const d = t.substr(
|
|
749
|
+
o += t.slice(a, l);
|
|
750
|
+
const d = t.substr(l + 2, 4);
|
|
712
751
|
switch (d) {
|
|
713
752
|
case "0000":
|
|
714
753
|
o += "\\0";
|
|
@@ -735,35 +774,35 @@ function pe(s, e) {
|
|
|
735
774
|
o += "\\P";
|
|
736
775
|
break;
|
|
737
776
|
default:
|
|
738
|
-
d.substr(0, 2) === "00" ? o += "\\x" + d.substr(2) : o += t.substr(
|
|
777
|
+
d.substr(0, 2) === "00" ? o += "\\x" + d.substr(2) : o += t.substr(l, 6);
|
|
739
778
|
}
|
|
740
|
-
|
|
779
|
+
l += 5, a = l + 1;
|
|
741
780
|
}
|
|
742
781
|
break;
|
|
743
782
|
case "n":
|
|
744
|
-
if (n || t[
|
|
745
|
-
|
|
783
|
+
if (n || t[l + 2] === '"' || t.length < i)
|
|
784
|
+
l += 1;
|
|
746
785
|
else {
|
|
747
|
-
for (o += t.slice(
|
|
786
|
+
for (o += t.slice(a, l) + `
|
|
748
787
|
|
|
749
|
-
`; t[
|
|
788
|
+
`; t[l + 2] === "\\" && t[l + 3] === "n" && t[l + 4] !== '"'; )
|
|
750
789
|
o += `
|
|
751
|
-
`,
|
|
752
|
-
o += r, t[
|
|
790
|
+
`, l += 2;
|
|
791
|
+
o += r, t[l + 2] === " " && (o += "\\"), l += 1, a = l + 1;
|
|
753
792
|
}
|
|
754
793
|
break;
|
|
755
794
|
default:
|
|
756
|
-
|
|
795
|
+
l += 1;
|
|
757
796
|
}
|
|
758
|
-
return o =
|
|
797
|
+
return o = a ? o + t.slice(a) : t, n ? o : Be(o, r, Ie, Me(e, !1));
|
|
759
798
|
}
|
|
760
|
-
function
|
|
799
|
+
function xe(s, e) {
|
|
761
800
|
if (e.options.singleQuote === !1 || e.implicitKey && s.includes(`
|
|
762
801
|
`) || /[ \t]\n|\n[ \t]/.test(s))
|
|
763
802
|
return pe(s, e);
|
|
764
|
-
const t = e.indent || (
|
|
803
|
+
const t = e.indent || (je(s) ? " " : ""), n = "'" + s.replace(/'/g, "''").replace(/\n+/g, `$&
|
|
765
804
|
${t}`) + "'";
|
|
766
|
-
return e.implicitKey ? n :
|
|
805
|
+
return e.implicitKey ? n : Be(n, t, Dt, Me(e, !1));
|
|
767
806
|
}
|
|
768
807
|
function te(s, e) {
|
|
769
808
|
const { singleQuote: t } = e.options;
|
|
@@ -772,40 +811,40 @@ function te(s, e) {
|
|
|
772
811
|
n = pe;
|
|
773
812
|
else {
|
|
774
813
|
const i = s.includes('"'), r = s.includes("'");
|
|
775
|
-
i && !r ? n =
|
|
814
|
+
i && !r ? n = xe : r && !i ? n = pe : n = t ? xe : pe;
|
|
776
815
|
}
|
|
777
816
|
return n(s, e);
|
|
778
817
|
}
|
|
779
|
-
let
|
|
818
|
+
let ze;
|
|
780
819
|
try {
|
|
781
|
-
|
|
820
|
+
ze = new RegExp(`(^|(?<!
|
|
782
821
|
))
|
|
783
822
|
+(?!
|
|
784
823
|
|$)`, "g");
|
|
785
824
|
} catch {
|
|
786
|
-
|
|
825
|
+
ze = /\n+(?!\n|$)/g;
|
|
787
826
|
}
|
|
788
|
-
function
|
|
789
|
-
const { blockQuote: o, commentString:
|
|
827
|
+
function $e({ comment: s, type: e, value: t }, n, i, r) {
|
|
828
|
+
const { blockQuote: o, commentString: a, lineWidth: l } = n.options;
|
|
790
829
|
if (!o || /\n[\t ]+$/.test(t))
|
|
791
830
|
return te(t, n);
|
|
792
|
-
const c = n.indent || (n.forceBlockIndent ||
|
|
831
|
+
const c = n.indent || (n.forceBlockIndent || je(t) ? " " : ""), d = o === "literal" ? !0 : o === "folded" || e === O.BLOCK_FOLDED ? !1 : e === O.BLOCK_LITERAL ? !0 : !Ps(t, l, c.length);
|
|
793
832
|
if (!t)
|
|
794
833
|
return d ? `|
|
|
795
834
|
` : `>
|
|
796
835
|
`;
|
|
797
|
-
let
|
|
798
|
-
for (
|
|
799
|
-
const N = t[
|
|
836
|
+
let u, f;
|
|
837
|
+
for (f = t.length; f > 0; --f) {
|
|
838
|
+
const N = t[f - 1];
|
|
800
839
|
if (N !== `
|
|
801
840
|
` && N !== " " && N !== " ")
|
|
802
841
|
break;
|
|
803
842
|
}
|
|
804
|
-
let m = t.substring(
|
|
843
|
+
let m = t.substring(f);
|
|
805
844
|
const g = m.indexOf(`
|
|
806
845
|
`);
|
|
807
|
-
g === -1 ?
|
|
808
|
-
` && (m = m.slice(0, -1)), m = m.replace(
|
|
846
|
+
g === -1 ? u = "-" : t === m || g !== m.length - 1 ? (u = "+", r && r()) : u = "", m && (t = t.slice(0, -m.length), m[m.length - 1] === `
|
|
847
|
+
` && (m = m.slice(0, -1)), m = m.replace(ze, `$&${c}`));
|
|
809
848
|
let h = !1, p, b = -1;
|
|
810
849
|
for (p = 0; p < t.length; ++p) {
|
|
811
850
|
const N = t[p];
|
|
@@ -819,16 +858,16 @@ function Le({ comment: s, type: e, value: t }, n, i, r) {
|
|
|
819
858
|
}
|
|
820
859
|
let w = t.substring(0, b < p ? b + 1 : p);
|
|
821
860
|
w && (t = t.substring(w.length), w = w.replace(/\n+/g, `$&${c}`));
|
|
822
|
-
let S = (h ? c ? "2" : "1" : "") +
|
|
823
|
-
if (s && (S += " " +
|
|
861
|
+
let S = (h ? c ? "2" : "1" : "") + u;
|
|
862
|
+
if (s && (S += " " + a(s.replace(/ ?[\r\n]+/g, " ")), i && i()), !d) {
|
|
824
863
|
const N = t.replace(/\n+/g, `
|
|
825
864
|
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${c}`);
|
|
826
865
|
let A = !1;
|
|
827
|
-
const
|
|
828
|
-
o !== "folded" && e !== O.BLOCK_FOLDED && (
|
|
866
|
+
const E = Me(n, !0);
|
|
867
|
+
o !== "folded" && e !== O.BLOCK_FOLDED && (E.onOverflow = () => {
|
|
829
868
|
A = !0;
|
|
830
869
|
});
|
|
831
|
-
const y =
|
|
870
|
+
const y = Be(`${w}${N}${m}`, c, Xe, E);
|
|
832
871
|
if (!A)
|
|
833
872
|
return `>${S}
|
|
834
873
|
${c}${y}`;
|
|
@@ -836,63 +875,63 @@ ${c}${y}`;
|
|
|
836
875
|
return t = t.replace(/\n+/g, `$&${c}`), `|${S}
|
|
837
876
|
${c}${w}${t}${m}`;
|
|
838
877
|
}
|
|
839
|
-
function
|
|
840
|
-
const { type: i, value: r } = s, { actualString: o, implicitKey:
|
|
841
|
-
if (
|
|
878
|
+
function Ks(s, e, t, n) {
|
|
879
|
+
const { type: i, value: r } = s, { actualString: o, implicitKey: a, indent: l, indentStep: c, inFlow: d } = e;
|
|
880
|
+
if (a && r.includes(`
|
|
842
881
|
`) || d && /[[\]{},]/.test(r))
|
|
843
882
|
return te(r, e);
|
|
844
883
|
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))
|
|
845
|
-
return
|
|
846
|
-
`) ? te(r, e) :
|
|
847
|
-
if (!
|
|
884
|
+
return a || d || !r.includes(`
|
|
885
|
+
`) ? te(r, e) : $e(s, e, t, n);
|
|
886
|
+
if (!a && !d && i !== O.PLAIN && r.includes(`
|
|
848
887
|
`))
|
|
849
|
-
return
|
|
850
|
-
if (
|
|
851
|
-
if (
|
|
852
|
-
return e.forceBlockIndent = !0,
|
|
853
|
-
if (
|
|
888
|
+
return $e(s, e, t, n);
|
|
889
|
+
if (je(r)) {
|
|
890
|
+
if (l === "")
|
|
891
|
+
return e.forceBlockIndent = !0, $e(s, e, t, n);
|
|
892
|
+
if (a && l === c)
|
|
854
893
|
return te(r, e);
|
|
855
894
|
}
|
|
856
|
-
const
|
|
857
|
-
${
|
|
895
|
+
const u = r.replace(/\n+/g, `$&
|
|
896
|
+
${l}`);
|
|
858
897
|
if (o) {
|
|
859
|
-
const
|
|
860
|
-
if (g.some(
|
|
898
|
+
const f = (h) => h.default && h.tag !== "tag:yaml.org,2002:str" && h.test?.test(u), { compat: m, tags: g } = e.doc.schema;
|
|
899
|
+
if (g.some(f) || m?.some(f))
|
|
861
900
|
return te(r, e);
|
|
862
901
|
}
|
|
863
|
-
return
|
|
902
|
+
return a ? u : Be(u, l, Dt, Me(e, !1));
|
|
864
903
|
}
|
|
865
|
-
function
|
|
904
|
+
function ot(s, e, t, n) {
|
|
866
905
|
const { implicitKey: i, inFlow: r } = e, o = typeof s.value == "string" ? s : Object.assign({}, s, { value: String(s.value) });
|
|
867
|
-
let { type:
|
|
868
|
-
|
|
869
|
-
const
|
|
906
|
+
let { type: a } = s;
|
|
907
|
+
a !== O.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value) && (a = O.QUOTE_DOUBLE);
|
|
908
|
+
const l = (d) => {
|
|
870
909
|
switch (d) {
|
|
871
910
|
case O.BLOCK_FOLDED:
|
|
872
911
|
case O.BLOCK_LITERAL:
|
|
873
|
-
return i || r ? te(o.value, e) :
|
|
912
|
+
return i || r ? te(o.value, e) : $e(o, e, t, n);
|
|
874
913
|
case O.QUOTE_DOUBLE:
|
|
875
914
|
return pe(o.value, e);
|
|
876
915
|
case O.QUOTE_SINGLE:
|
|
877
|
-
return
|
|
916
|
+
return xe(o.value, e);
|
|
878
917
|
case O.PLAIN:
|
|
879
|
-
return
|
|
918
|
+
return Ks(o, e, t, n);
|
|
880
919
|
default:
|
|
881
920
|
return null;
|
|
882
921
|
}
|
|
883
922
|
};
|
|
884
|
-
let c = a
|
|
923
|
+
let c = l(a);
|
|
885
924
|
if (c === null) {
|
|
886
|
-
const { defaultKeyType: d, defaultStringType:
|
|
887
|
-
if (c =
|
|
888
|
-
throw new Error(`Unsupported default string type ${
|
|
925
|
+
const { defaultKeyType: d, defaultStringType: u } = e.options, f = i && d || u;
|
|
926
|
+
if (c = l(f), c === null)
|
|
927
|
+
throw new Error(`Unsupported default string type ${f}`);
|
|
889
928
|
}
|
|
890
929
|
return c;
|
|
891
930
|
}
|
|
892
|
-
function
|
|
931
|
+
function qt(s, e) {
|
|
893
932
|
const t = Object.assign({
|
|
894
933
|
blockQuote: !0,
|
|
895
|
-
commentString:
|
|
934
|
+
commentString: js,
|
|
896
935
|
defaultKeyType: null,
|
|
897
936
|
defaultStringType: "PLAIN",
|
|
898
937
|
directives: null,
|
|
@@ -930,14 +969,14 @@ function Dt(s, e) {
|
|
|
930
969
|
options: t
|
|
931
970
|
};
|
|
932
971
|
}
|
|
933
|
-
function
|
|
972
|
+
function Ds(s, e) {
|
|
934
973
|
if (e.tag) {
|
|
935
974
|
const i = s.filter((r) => r.tag === e.tag);
|
|
936
975
|
if (i.length > 0)
|
|
937
976
|
return i.find((r) => r.format === e.format) ?? i[0];
|
|
938
977
|
}
|
|
939
978
|
let t, n;
|
|
940
|
-
if (
|
|
979
|
+
if (T(e)) {
|
|
941
980
|
n = e.value;
|
|
942
981
|
let i = s.filter((r) => r.identify?.(n));
|
|
943
982
|
if (i.length > 1) {
|
|
@@ -953,16 +992,16 @@ function vs(s, e) {
|
|
|
953
992
|
}
|
|
954
993
|
return t;
|
|
955
994
|
}
|
|
956
|
-
function
|
|
995
|
+
function qs(s, e, { anchors: t, doc: n }) {
|
|
957
996
|
if (!n.directives)
|
|
958
997
|
return "";
|
|
959
|
-
const i = [], r = (
|
|
960
|
-
r &&
|
|
998
|
+
const i = [], r = (T(s) || I(s)) && s.anchor;
|
|
999
|
+
r && Bt(r) && (t.add(r), i.push(`&${r}`));
|
|
961
1000
|
const o = s.tag ?? (e.default ? null : e.tag);
|
|
962
1001
|
return o && i.push(n.directives.tagString(o)), i.join(" ");
|
|
963
1002
|
}
|
|
964
1003
|
function ie(s, e, t, n) {
|
|
965
|
-
if (
|
|
1004
|
+
if (L(s))
|
|
966
1005
|
return s.toString(e, t, n);
|
|
967
1006
|
if (Q(s)) {
|
|
968
1007
|
if (e.doc.directives)
|
|
@@ -972,55 +1011,55 @@ function ie(s, e, t, n) {
|
|
|
972
1011
|
e.resolvedAliases ? e.resolvedAliases.add(s) : e.resolvedAliases = /* @__PURE__ */ new Set([s]), s = s.resolve(e.doc);
|
|
973
1012
|
}
|
|
974
1013
|
let i;
|
|
975
|
-
const r =
|
|
976
|
-
i ?? (i =
|
|
977
|
-
const o =
|
|
1014
|
+
const r = $(s) ? s : e.doc.createNode(s, { onTagObj: (l) => i = l });
|
|
1015
|
+
i ?? (i = Ds(e.doc.schema.tags, r));
|
|
1016
|
+
const o = qs(r, i, e);
|
|
978
1017
|
o.length > 0 && (e.indentAtStart = (e.indentAtStart ?? 0) + o.length + 1);
|
|
979
|
-
const
|
|
980
|
-
return o ?
|
|
981
|
-
${e.indent}${
|
|
982
|
-
}
|
|
983
|
-
function
|
|
984
|
-
const { allNullValues: r, doc: o, indent:
|
|
985
|
-
let
|
|
986
|
-
if (
|
|
987
|
-
if (
|
|
1018
|
+
const a = typeof i.stringify == "function" ? i.stringify(r, e, t, n) : T(r) ? ot(r, e, t, n) : r.toString(e, t, n);
|
|
1019
|
+
return o ? T(r) || a[0] === "{" || a[0] === "[" ? `${o} ${a}` : `${o}
|
|
1020
|
+
${e.indent}${a}` : a;
|
|
1021
|
+
}
|
|
1022
|
+
function Fs({ key: s, value: e }, t, n, i) {
|
|
1023
|
+
const { allNullValues: r, doc: o, indent: a, indentStep: l, options: { commentString: c, indentSeq: d, simpleKeys: u } } = t;
|
|
1024
|
+
let f = $(s) && s.comment || null;
|
|
1025
|
+
if (u) {
|
|
1026
|
+
if (f)
|
|
988
1027
|
throw new Error("With simple keys, key nodes cannot have comments");
|
|
989
|
-
if (I(s) ||
|
|
990
|
-
const
|
|
991
|
-
throw new Error(
|
|
1028
|
+
if (I(s) || !$(s) && typeof s == "object") {
|
|
1029
|
+
const E = "With simple keys, collection cannot be used as a key value";
|
|
1030
|
+
throw new Error(E);
|
|
992
1031
|
}
|
|
993
1032
|
}
|
|
994
|
-
let m = !
|
|
1033
|
+
let m = !u && (!s || f && e == null && !t.inFlow || I(s) || (T(s) ? s.type === O.BLOCK_FOLDED || s.type === O.BLOCK_LITERAL : typeof s == "object"));
|
|
995
1034
|
t = Object.assign({}, t, {
|
|
996
1035
|
allNullValues: !1,
|
|
997
|
-
implicitKey: !m && (
|
|
998
|
-
indent:
|
|
1036
|
+
implicitKey: !m && (u || !r),
|
|
1037
|
+
indent: a + l
|
|
999
1038
|
});
|
|
1000
1039
|
let g = !1, h = !1, p = ie(s, t, () => g = !0, () => h = !0);
|
|
1001
1040
|
if (!m && !t.inFlow && p.length > 1024) {
|
|
1002
|
-
if (
|
|
1041
|
+
if (u)
|
|
1003
1042
|
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
1004
1043
|
m = !0;
|
|
1005
1044
|
}
|
|
1006
1045
|
if (t.inFlow) {
|
|
1007
1046
|
if (r || e == null)
|
|
1008
1047
|
return g && n && n(), p === "" ? "?" : m ? `? ${p}` : p;
|
|
1009
|
-
} else if (r && !
|
|
1010
|
-
return p = `? ${p}`,
|
|
1011
|
-
g && (
|
|
1012
|
-
${
|
|
1048
|
+
} else if (r && !u || e == null && m)
|
|
1049
|
+
return p = `? ${p}`, f && !g ? p += G(p, t.indent, c(f)) : h && i && i(), p;
|
|
1050
|
+
g && (f = null), m ? (f && (p += G(p, t.indent, c(f))), p = `? ${p}
|
|
1051
|
+
${a}:`) : (p = `${p}:`, f && (p += G(p, t.indent, c(f))));
|
|
1013
1052
|
let b, w, k;
|
|
1014
|
-
|
|
1053
|
+
$(e) ? (b = !!e.spaceBefore, w = e.commentBefore, k = e.comment) : (b = !1, w = null, k = null, e && typeof e == "object" && (e = o.createNode(e))), t.implicitKey = !1, !m && !f && T(e) && (t.indentAtStart = p.length + 1), h = !1, !d && l.length >= 2 && !t.inFlow && !m && be(e) && !e.flow && !e.tag && !e.anchor && (t.indent = t.indent.substring(2));
|
|
1015
1054
|
let S = !1;
|
|
1016
1055
|
const N = ie(e, t, () => S = !0, () => h = !0);
|
|
1017
1056
|
let A = " ";
|
|
1018
|
-
if (
|
|
1057
|
+
if (f || b || w) {
|
|
1019
1058
|
if (A = b ? `
|
|
1020
1059
|
` : "", w) {
|
|
1021
|
-
const
|
|
1060
|
+
const E = c(w);
|
|
1022
1061
|
A += `
|
|
1023
|
-
${
|
|
1062
|
+
${F(E, t.indent)}`;
|
|
1024
1063
|
}
|
|
1025
1064
|
N === "" && !t.inFlow ? A === `
|
|
1026
1065
|
` && k && (A = `
|
|
@@ -1028,13 +1067,13 @@ ${U(T, t.indent)}`;
|
|
|
1028
1067
|
`) : A += `
|
|
1029
1068
|
${t.indent}`;
|
|
1030
1069
|
} else if (!m && I(e)) {
|
|
1031
|
-
const
|
|
1070
|
+
const E = N[0], y = N.indexOf(`
|
|
1032
1071
|
`), v = y !== -1, R = t.inFlow ?? e.flow ?? e.items.length === 0;
|
|
1033
1072
|
if (v || !R) {
|
|
1034
1073
|
let X = !1;
|
|
1035
|
-
if (v && (
|
|
1074
|
+
if (v && (E === "&" || E === "!")) {
|
|
1036
1075
|
let C = N.indexOf(" ");
|
|
1037
|
-
|
|
1076
|
+
E === "&" && C !== -1 && C < y && N[C + 1] === "!" && (C = N.indexOf(" ", C + 1)), (C === -1 || y < C) && (X = !0);
|
|
1038
1077
|
}
|
|
1039
1078
|
X || (A = `
|
|
1040
1079
|
${t.indent}`);
|
|
@@ -1043,10 +1082,10 @@ ${t.indent}`);
|
|
|
1043
1082
|
`) && (A = "");
|
|
1044
1083
|
return p += A + N, t.inFlow ? S && n && n() : k && !S ? p += G(p, t.indent, c(k)) : h && i && i(), p;
|
|
1045
1084
|
}
|
|
1046
|
-
function
|
|
1085
|
+
function Ft(s, e) {
|
|
1047
1086
|
(s === "debug" || s === "warn") && console.warn(e);
|
|
1048
1087
|
}
|
|
1049
|
-
const Se = "<<",
|
|
1088
|
+
const Se = "<<", U = {
|
|
1050
1089
|
identify: (s) => s === Se || typeof s == "symbol" && s.description === Se,
|
|
1051
1090
|
default: "key",
|
|
1052
1091
|
tag: "tag:yaml.org,2002:merge",
|
|
@@ -1055,18 +1094,18 @@ const Se = "<<", F = {
|
|
|
1055
1094
|
addToJSMap: Ut
|
|
1056
1095
|
}),
|
|
1057
1096
|
stringify: () => Se
|
|
1058
|
-
},
|
|
1097
|
+
}, Us = (s, e) => (U.identify(e) || T(e) && (!e.type || e.type === O.PLAIN) && U.identify(e.value)) && s?.doc.schema.tags.some((t) => t.tag === U.tag && t.default);
|
|
1059
1098
|
function Ut(s, e, t) {
|
|
1060
1099
|
if (t = s && Q(t) ? t.resolve(s.doc) : t, be(t))
|
|
1061
1100
|
for (const n of t.items)
|
|
1062
|
-
|
|
1101
|
+
Ve(s, e, n);
|
|
1063
1102
|
else if (Array.isArray(t))
|
|
1064
1103
|
for (const n of t)
|
|
1065
|
-
|
|
1104
|
+
Ve(s, e, n);
|
|
1066
1105
|
else
|
|
1067
|
-
|
|
1106
|
+
Ve(s, e, t);
|
|
1068
1107
|
}
|
|
1069
|
-
function
|
|
1108
|
+
function Ve(s, e, t) {
|
|
1070
1109
|
const n = s && Q(t) ? t.resolve(s.doc) : t;
|
|
1071
1110
|
if (!ye(n))
|
|
1072
1111
|
throw new Error("Merge sources must be maps or map aliases");
|
|
@@ -1080,19 +1119,19 @@ function Fe(s, e, t) {
|
|
|
1080
1119
|
});
|
|
1081
1120
|
return e;
|
|
1082
1121
|
}
|
|
1083
|
-
function
|
|
1084
|
-
if (
|
|
1122
|
+
function Rt(s, e, { key: t, value: n }) {
|
|
1123
|
+
if ($(t) && t.addToJSMap)
|
|
1085
1124
|
t.addToJSMap(s, e, n);
|
|
1086
|
-
else if (
|
|
1125
|
+
else if (Us(s, t))
|
|
1087
1126
|
Ut(s, e, n);
|
|
1088
1127
|
else {
|
|
1089
|
-
const i =
|
|
1128
|
+
const i = j(t, "", s);
|
|
1090
1129
|
if (e instanceof Map)
|
|
1091
|
-
e.set(i,
|
|
1130
|
+
e.set(i, j(n, i, s));
|
|
1092
1131
|
else if (e instanceof Set)
|
|
1093
1132
|
e.add(i);
|
|
1094
1133
|
else {
|
|
1095
|
-
const r =
|
|
1134
|
+
const r = Rs(t, i, s), o = j(n, r, s);
|
|
1096
1135
|
r in e ? Object.defineProperty(e, r, {
|
|
1097
1136
|
value: o,
|
|
1098
1137
|
writable: !0,
|
|
@@ -1103,13 +1142,13 @@ function Ft(s, e, { key: t, value: n }) {
|
|
|
1103
1142
|
}
|
|
1104
1143
|
return e;
|
|
1105
1144
|
}
|
|
1106
|
-
function
|
|
1145
|
+
function Rs(s, e, t) {
|
|
1107
1146
|
if (e === null)
|
|
1108
1147
|
return "";
|
|
1109
1148
|
if (typeof e != "object")
|
|
1110
1149
|
return String(e);
|
|
1111
|
-
if (
|
|
1112
|
-
const n =
|
|
1150
|
+
if ($(s) && t?.doc) {
|
|
1151
|
+
const n = qt(t.doc, {});
|
|
1113
1152
|
n.anchors = /* @__PURE__ */ new Set();
|
|
1114
1153
|
for (const r of t.anchors.keys())
|
|
1115
1154
|
n.anchors.add(r.anchor);
|
|
@@ -1117,124 +1156,124 @@ function Ms(s, e, t) {
|
|
|
1117
1156
|
const i = s.toString(n);
|
|
1118
1157
|
if (!t.mapKeyWarned) {
|
|
1119
1158
|
let r = JSON.stringify(i);
|
|
1120
|
-
r.length > 40 && (r = r.substring(0, 36) + '..."'),
|
|
1159
|
+
r.length > 40 && (r = r.substring(0, 36) + '..."'), Ft(t.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`), t.mapKeyWarned = !0;
|
|
1121
1160
|
}
|
|
1122
1161
|
return i;
|
|
1123
1162
|
}
|
|
1124
1163
|
return JSON.stringify(e);
|
|
1125
1164
|
}
|
|
1126
|
-
function
|
|
1165
|
+
function at(s, e, t) {
|
|
1127
1166
|
const n = me(s, void 0, t), i = me(e, void 0, t);
|
|
1128
1167
|
return new B(n, i);
|
|
1129
1168
|
}
|
|
1130
1169
|
class B {
|
|
1131
1170
|
constructor(e, t = null) {
|
|
1132
|
-
Object.defineProperty(this,
|
|
1171
|
+
Object.defineProperty(this, P, { value: Ct }), this.key = e, this.value = t;
|
|
1133
1172
|
}
|
|
1134
1173
|
clone(e) {
|
|
1135
1174
|
let { key: t, value: n } = this;
|
|
1136
|
-
return
|
|
1175
|
+
return $(t) && (t = t.clone(e)), $(n) && (n = n.clone(e)), new B(t, n);
|
|
1137
1176
|
}
|
|
1138
1177
|
toJSON(e, t) {
|
|
1139
1178
|
const n = t?.mapAsMap ? /* @__PURE__ */ new Map() : {};
|
|
1140
|
-
return
|
|
1179
|
+
return Rt(t, n, this);
|
|
1141
1180
|
}
|
|
1142
1181
|
toString(e, t, n) {
|
|
1143
|
-
return e?.doc ?
|
|
1182
|
+
return e?.doc ? Fs(this, e, t, n) : JSON.stringify(this);
|
|
1144
1183
|
}
|
|
1145
1184
|
}
|
|
1146
|
-
function
|
|
1147
|
-
return (e.inFlow ?? s.flow ?
|
|
1185
|
+
function Vt(s, e, t) {
|
|
1186
|
+
return (e.inFlow ?? s.flow ? Js : Vs)(s, e, t);
|
|
1148
1187
|
}
|
|
1149
|
-
function
|
|
1150
|
-
const { indent:
|
|
1151
|
-
let
|
|
1152
|
-
const
|
|
1188
|
+
function Vs({ comment: s, items: e }, t, { blockItemPrefix: n, flowChars: i, itemIndent: r, onChompKeep: o, onComment: a }) {
|
|
1189
|
+
const { indent: l, options: { commentString: c } } = t, d = Object.assign({}, t, { indent: r, type: null });
|
|
1190
|
+
let u = !1;
|
|
1191
|
+
const f = [];
|
|
1153
1192
|
for (let g = 0; g < e.length; ++g) {
|
|
1154
1193
|
const h = e[g];
|
|
1155
1194
|
let p = null;
|
|
1156
|
-
if (
|
|
1157
|
-
!
|
|
1158
|
-
else if (
|
|
1159
|
-
const w =
|
|
1160
|
-
w && (!
|
|
1195
|
+
if ($(h))
|
|
1196
|
+
!u && h.spaceBefore && f.push(""), ve(t, f, h.commentBefore, u), h.comment && (p = h.comment);
|
|
1197
|
+
else if (L(h)) {
|
|
1198
|
+
const w = $(h.key) ? h.key : null;
|
|
1199
|
+
w && (!u && w.spaceBefore && f.push(""), ve(t, f, w.commentBefore, u));
|
|
1161
1200
|
}
|
|
1162
|
-
|
|
1163
|
-
let b = ie(h, d, () => p = null, () =>
|
|
1164
|
-
p && (b += G(b, r, c(p))),
|
|
1201
|
+
u = !1;
|
|
1202
|
+
let b = ie(h, d, () => p = null, () => u = !0);
|
|
1203
|
+
p && (b += G(b, r, c(p))), u && p && (u = !1), f.push(n + b);
|
|
1165
1204
|
}
|
|
1166
1205
|
let m;
|
|
1167
|
-
if (
|
|
1206
|
+
if (f.length === 0)
|
|
1168
1207
|
m = i.start + i.end;
|
|
1169
1208
|
else {
|
|
1170
|
-
m =
|
|
1171
|
-
for (let g = 1; g <
|
|
1172
|
-
const h =
|
|
1209
|
+
m = f[0];
|
|
1210
|
+
for (let g = 1; g < f.length; ++g) {
|
|
1211
|
+
const h = f[g];
|
|
1173
1212
|
m += h ? `
|
|
1174
|
-
${
|
|
1213
|
+
${l}${h}` : `
|
|
1175
1214
|
`;
|
|
1176
1215
|
}
|
|
1177
1216
|
}
|
|
1178
1217
|
return s ? (m += `
|
|
1179
|
-
` +
|
|
1218
|
+
` + F(c(s), l), a && a()) : u && o && o(), m;
|
|
1180
1219
|
}
|
|
1181
|
-
function
|
|
1182
|
-
const { indent: i, indentStep: r, flowCollectionPadding: o, options: { commentString:
|
|
1220
|
+
function Js({ items: s }, e, { flowChars: t, itemIndent: n }) {
|
|
1221
|
+
const { indent: i, indentStep: r, flowCollectionPadding: o, options: { commentString: a } } = e;
|
|
1183
1222
|
n += r;
|
|
1184
|
-
const
|
|
1223
|
+
const l = Object.assign({}, e, {
|
|
1185
1224
|
indent: n,
|
|
1186
1225
|
inFlow: !0,
|
|
1187
1226
|
type: null
|
|
1188
1227
|
});
|
|
1189
1228
|
let c = !1, d = 0;
|
|
1190
|
-
const
|
|
1229
|
+
const u = [];
|
|
1191
1230
|
for (let g = 0; g < s.length; ++g) {
|
|
1192
1231
|
const h = s[g];
|
|
1193
1232
|
let p = null;
|
|
1194
|
-
if (
|
|
1195
|
-
h.spaceBefore &&
|
|
1196
|
-
else if (
|
|
1197
|
-
const w =
|
|
1198
|
-
w && (w.spaceBefore &&
|
|
1199
|
-
const k =
|
|
1233
|
+
if ($(h))
|
|
1234
|
+
h.spaceBefore && u.push(""), ve(e, u, h.commentBefore, !1), h.comment && (p = h.comment);
|
|
1235
|
+
else if (L(h)) {
|
|
1236
|
+
const w = $(h.key) ? h.key : null;
|
|
1237
|
+
w && (w.spaceBefore && u.push(""), ve(e, u, w.commentBefore, !1), w.comment && (c = !0));
|
|
1238
|
+
const k = $(h.value) ? h.value : null;
|
|
1200
1239
|
k ? (k.comment && (p = k.comment), k.commentBefore && (c = !0)) : h.value == null && w?.comment && (p = w.comment);
|
|
1201
1240
|
}
|
|
1202
1241
|
p && (c = !0);
|
|
1203
|
-
let b = ie(h,
|
|
1204
|
-
g < s.length - 1 && (b += ","), p && (b += G(b, n,
|
|
1205
|
-
`)) && (c = !0),
|
|
1242
|
+
let b = ie(h, l, () => p = null);
|
|
1243
|
+
g < s.length - 1 && (b += ","), p && (b += G(b, n, a(p))), !c && (u.length > d || b.includes(`
|
|
1244
|
+
`)) && (c = !0), u.push(b), d = u.length;
|
|
1206
1245
|
}
|
|
1207
|
-
const { start:
|
|
1208
|
-
if (
|
|
1209
|
-
return
|
|
1246
|
+
const { start: f, end: m } = t;
|
|
1247
|
+
if (u.length === 0)
|
|
1248
|
+
return f + m;
|
|
1210
1249
|
if (!c) {
|
|
1211
|
-
const g =
|
|
1250
|
+
const g = u.reduce((h, p) => h + p.length + 2, 2);
|
|
1212
1251
|
c = e.options.lineWidth > 0 && g > e.options.lineWidth;
|
|
1213
1252
|
}
|
|
1214
1253
|
if (c) {
|
|
1215
|
-
let g =
|
|
1216
|
-
for (const h of
|
|
1254
|
+
let g = f;
|
|
1255
|
+
for (const h of u)
|
|
1217
1256
|
g += h ? `
|
|
1218
1257
|
${r}${i}${h}` : `
|
|
1219
1258
|
`;
|
|
1220
1259
|
return `${g}
|
|
1221
1260
|
${i}${m}`;
|
|
1222
1261
|
} else
|
|
1223
|
-
return `${
|
|
1262
|
+
return `${f}${o}${u.join(" ")}${o}${m}`;
|
|
1224
1263
|
}
|
|
1225
1264
|
function ve({ indent: s, options: { commentString: e } }, t, n, i) {
|
|
1226
1265
|
if (n && i && (n = n.replace(/^\n+/, "")), n) {
|
|
1227
|
-
const r =
|
|
1266
|
+
const r = F(e(n), s);
|
|
1228
1267
|
t.push(r.trimStart());
|
|
1229
1268
|
}
|
|
1230
1269
|
}
|
|
1231
1270
|
function H(s, e) {
|
|
1232
|
-
const t =
|
|
1271
|
+
const t = T(e) ? e.value : e;
|
|
1233
1272
|
for (const n of s)
|
|
1234
|
-
if (
|
|
1273
|
+
if (L(n) && (n.key === e || n.key === t || T(n.key) && n.key.value === t))
|
|
1235
1274
|
return n;
|
|
1236
1275
|
}
|
|
1237
|
-
class M extends
|
|
1276
|
+
class M extends Kt {
|
|
1238
1277
|
static get tagName() {
|
|
1239
1278
|
return "tag:yaml.org,2002:map";
|
|
1240
1279
|
}
|
|
@@ -1246,19 +1285,19 @@ class M extends jt {
|
|
|
1246
1285
|
* to other node classes that inherit from YAMLMap
|
|
1247
1286
|
*/
|
|
1248
1287
|
static from(e, t, n) {
|
|
1249
|
-
const { keepUndefined: i, replacer: r } = n, o = new this(e),
|
|
1288
|
+
const { keepUndefined: i, replacer: r } = n, o = new this(e), a = (l, c) => {
|
|
1250
1289
|
if (typeof r == "function")
|
|
1251
|
-
c = r.call(t,
|
|
1252
|
-
else if (Array.isArray(r) && !r.includes(
|
|
1290
|
+
c = r.call(t, l, c);
|
|
1291
|
+
else if (Array.isArray(r) && !r.includes(l))
|
|
1253
1292
|
return;
|
|
1254
|
-
(c !== void 0 || i) && o.items.push(
|
|
1293
|
+
(c !== void 0 || i) && o.items.push(at(l, c, n));
|
|
1255
1294
|
};
|
|
1256
1295
|
if (t instanceof Map)
|
|
1257
|
-
for (const [
|
|
1258
|
-
l
|
|
1296
|
+
for (const [l, c] of t)
|
|
1297
|
+
a(l, c);
|
|
1259
1298
|
else if (t && typeof t == "object")
|
|
1260
|
-
for (const
|
|
1261
|
-
l
|
|
1299
|
+
for (const l of Object.keys(t))
|
|
1300
|
+
a(l, t[l]);
|
|
1262
1301
|
return typeof e.sortMapEntries == "function" && o.items.sort(e.sortMapEntries), o;
|
|
1263
1302
|
}
|
|
1264
1303
|
/**
|
|
@@ -1269,14 +1308,14 @@ class M extends jt {
|
|
|
1269
1308
|
*/
|
|
1270
1309
|
add(e, t) {
|
|
1271
1310
|
let n;
|
|
1272
|
-
|
|
1311
|
+
L(e) ? n = e : !e || typeof e != "object" || !("key" in e) ? n = new B(e, e?.value) : n = new B(e.key, e.value);
|
|
1273
1312
|
const i = H(this.items, n.key), r = this.schema?.sortMapEntries;
|
|
1274
1313
|
if (i) {
|
|
1275
1314
|
if (!t)
|
|
1276
1315
|
throw new Error(`Key ${n.key} already set`);
|
|
1277
|
-
|
|
1316
|
+
T(i.value) && Pt(n.value) ? i.value.value = n.value : i.value = n.value;
|
|
1278
1317
|
} else if (r) {
|
|
1279
|
-
const o = this.items.findIndex((
|
|
1318
|
+
const o = this.items.findIndex((a) => r(n, a) < 0);
|
|
1280
1319
|
o === -1 ? this.items.push(n) : this.items.splice(o, 0, n);
|
|
1281
1320
|
} else
|
|
1282
1321
|
this.items.push(n);
|
|
@@ -1287,7 +1326,7 @@ class M extends jt {
|
|
|
1287
1326
|
}
|
|
1288
1327
|
get(e, t) {
|
|
1289
1328
|
const i = H(this.items, e)?.value;
|
|
1290
|
-
return (!t &&
|
|
1329
|
+
return (!t && T(i) ? i.value : i) ?? void 0;
|
|
1291
1330
|
}
|
|
1292
1331
|
has(e) {
|
|
1293
1332
|
return !!H(this.items, e);
|
|
@@ -1304,16 +1343,16 @@ class M extends jt {
|
|
|
1304
1343
|
const i = n ? new n() : t?.mapAsMap ? /* @__PURE__ */ new Map() : {};
|
|
1305
1344
|
t?.onCreate && t.onCreate(i);
|
|
1306
1345
|
for (const r of this.items)
|
|
1307
|
-
|
|
1346
|
+
Rt(t, i, r);
|
|
1308
1347
|
return i;
|
|
1309
1348
|
}
|
|
1310
1349
|
toString(e, t, n) {
|
|
1311
1350
|
if (!e)
|
|
1312
1351
|
return JSON.stringify(this);
|
|
1313
1352
|
for (const i of this.items)
|
|
1314
|
-
if (
|
|
1353
|
+
if (!L(i))
|
|
1315
1354
|
throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);
|
|
1316
|
-
return !e.allNullValues && this.hasAllNullValues(!1) && (e = Object.assign({}, e, { allNullValues: !0 })),
|
|
1355
|
+
return !e.allNullValues && this.hasAllNullValues(!1) && (e = Object.assign({}, e, { allNullValues: !0 })), Vt(this, e, {
|
|
1317
1356
|
blockItemPrefix: "",
|
|
1318
1357
|
flowChars: { start: "{", end: "}" },
|
|
1319
1358
|
itemIndent: e.indent || "",
|
|
@@ -1322,7 +1361,7 @@ class M extends jt {
|
|
|
1322
1361
|
});
|
|
1323
1362
|
}
|
|
1324
1363
|
}
|
|
1325
|
-
const
|
|
1364
|
+
const le = {
|
|
1326
1365
|
collection: "map",
|
|
1327
1366
|
default: !0,
|
|
1328
1367
|
nodeClass: M,
|
|
@@ -1332,7 +1371,7 @@ const ae = {
|
|
|
1332
1371
|
},
|
|
1333
1372
|
createNode: (s, e, t) => M.from(s, e, t)
|
|
1334
1373
|
};
|
|
1335
|
-
class W extends
|
|
1374
|
+
class W extends Kt {
|
|
1336
1375
|
static get tagName() {
|
|
1337
1376
|
return "tag:yaml.org,2002:seq";
|
|
1338
1377
|
}
|
|
@@ -1359,7 +1398,7 @@ class W extends jt {
|
|
|
1359
1398
|
if (typeof n != "number")
|
|
1360
1399
|
return;
|
|
1361
1400
|
const i = this.items[n];
|
|
1362
|
-
return !t &&
|
|
1401
|
+
return !t && T(i) ? i.value : i;
|
|
1363
1402
|
}
|
|
1364
1403
|
/**
|
|
1365
1404
|
* Checks if the collection includes a value with the key `key`.
|
|
@@ -1383,18 +1422,18 @@ class W extends jt {
|
|
|
1383
1422
|
if (typeof n != "number")
|
|
1384
1423
|
throw new Error(`Expected a valid index, not ${e}.`);
|
|
1385
1424
|
const i = this.items[n];
|
|
1386
|
-
|
|
1425
|
+
T(i) && Pt(t) ? i.value = t : this.items[n] = t;
|
|
1387
1426
|
}
|
|
1388
1427
|
toJSON(e, t) {
|
|
1389
1428
|
const n = [];
|
|
1390
1429
|
t?.onCreate && t.onCreate(n);
|
|
1391
1430
|
let i = 0;
|
|
1392
1431
|
for (const r of this.items)
|
|
1393
|
-
n.push(
|
|
1432
|
+
n.push(j(r, String(i++), t));
|
|
1394
1433
|
return n;
|
|
1395
1434
|
}
|
|
1396
1435
|
toString(e, t, n) {
|
|
1397
|
-
return e ?
|
|
1436
|
+
return e ? Vt(this, e, {
|
|
1398
1437
|
blockItemPrefix: "- ",
|
|
1399
1438
|
flowChars: { start: "[", end: "]" },
|
|
1400
1439
|
itemIndent: (e.indent || "") + " ",
|
|
@@ -1406,19 +1445,19 @@ class W extends jt {
|
|
|
1406
1445
|
const { replacer: i } = n, r = new this(e);
|
|
1407
1446
|
if (t && Symbol.iterator in Object(t)) {
|
|
1408
1447
|
let o = 0;
|
|
1409
|
-
for (let
|
|
1448
|
+
for (let a of t) {
|
|
1410
1449
|
if (typeof i == "function") {
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1450
|
+
const l = t instanceof Set ? a : String(o++);
|
|
1451
|
+
a = i.call(t, l, a);
|
|
1413
1452
|
}
|
|
1414
|
-
r.items.push(me(
|
|
1453
|
+
r.items.push(me(a, void 0, n));
|
|
1415
1454
|
}
|
|
1416
1455
|
}
|
|
1417
1456
|
return r;
|
|
1418
1457
|
}
|
|
1419
1458
|
}
|
|
1420
1459
|
function Ne(s) {
|
|
1421
|
-
let e =
|
|
1460
|
+
let e = T(s) ? s.value : s;
|
|
1422
1461
|
return e && typeof e == "string" && (e = Number(e)), typeof e == "number" && Number.isInteger(e) && e >= 0 ? e : null;
|
|
1423
1462
|
}
|
|
1424
1463
|
const ce = {
|
|
@@ -1436,24 +1475,24 @@ const ce = {
|
|
|
1436
1475
|
tag: "tag:yaml.org,2002:str",
|
|
1437
1476
|
resolve: (s) => s,
|
|
1438
1477
|
stringify(s, e, t, n) {
|
|
1439
|
-
return e = Object.assign({ actualString: !0 }, e),
|
|
1478
|
+
return e = Object.assign({ actualString: !0 }, e), ot(s, e, t, n);
|
|
1440
1479
|
}
|
|
1441
|
-
},
|
|
1480
|
+
}, Ke = {
|
|
1442
1481
|
identify: (s) => s == null,
|
|
1443
1482
|
createNode: () => new O(null),
|
|
1444
1483
|
default: !0,
|
|
1445
1484
|
tag: "tag:yaml.org,2002:null",
|
|
1446
1485
|
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
1447
1486
|
resolve: () => new O(null),
|
|
1448
|
-
stringify: ({ source: s }, e) => typeof s == "string" &&
|
|
1449
|
-
},
|
|
1487
|
+
stringify: ({ source: s }, e) => typeof s == "string" && Ke.test.test(s) ? s : e.options.nullStr
|
|
1488
|
+
}, lt = {
|
|
1450
1489
|
identify: (s) => typeof s == "boolean",
|
|
1451
1490
|
default: !0,
|
|
1452
1491
|
tag: "tag:yaml.org,2002:bool",
|
|
1453
1492
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
1454
1493
|
resolve: (s) => new O(s[0] === "t" || s[0] === "T"),
|
|
1455
1494
|
stringify({ source: s, value: e }, t) {
|
|
1456
|
-
if (s &&
|
|
1495
|
+
if (s && lt.test.test(s)) {
|
|
1457
1496
|
const n = s[0] === "t" || s[0] === "T";
|
|
1458
1497
|
if (e === n)
|
|
1459
1498
|
return s;
|
|
@@ -1471,20 +1510,20 @@ function D({ format: s, minFractionDigits: e, tag: t, value: n }) {
|
|
|
1471
1510
|
if (!s && e && (!t || t === "tag:yaml.org,2002:float") && /^\d/.test(r)) {
|
|
1472
1511
|
let o = r.indexOf(".");
|
|
1473
1512
|
o < 0 && (o = r.length, r += ".");
|
|
1474
|
-
let
|
|
1475
|
-
for (;
|
|
1513
|
+
let a = e - (r.length - o - 1);
|
|
1514
|
+
for (; a-- > 0; )
|
|
1476
1515
|
r += "0";
|
|
1477
1516
|
}
|
|
1478
1517
|
return r;
|
|
1479
1518
|
}
|
|
1480
|
-
const
|
|
1519
|
+
const Jt = {
|
|
1481
1520
|
identify: (s) => typeof s == "number",
|
|
1482
1521
|
default: !0,
|
|
1483
1522
|
tag: "tag:yaml.org,2002:float",
|
|
1484
1523
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
1485
1524
|
resolve: (s) => s.slice(-3).toLowerCase() === "nan" ? NaN : s[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
1486
1525
|
stringify: D
|
|
1487
|
-
},
|
|
1526
|
+
}, Yt = {
|
|
1488
1527
|
identify: (s) => typeof s == "number",
|
|
1489
1528
|
default: !0,
|
|
1490
1529
|
tag: "tag:yaml.org,2002:float",
|
|
@@ -1495,7 +1534,7 @@ const Vt = {
|
|
|
1495
1534
|
const e = Number(s.value);
|
|
1496
1535
|
return isFinite(e) ? e.toExponential() : D(s);
|
|
1497
1536
|
}
|
|
1498
|
-
},
|
|
1537
|
+
}, Gt = {
|
|
1499
1538
|
identify: (s) => typeof s == "number",
|
|
1500
1539
|
default: !0,
|
|
1501
1540
|
tag: "tag:yaml.org,2002:float",
|
|
@@ -1505,51 +1544,51 @@ const Vt = {
|
|
|
1505
1544
|
return t !== -1 && s[s.length - 1] === "0" && (e.minFractionDigits = s.length - t - 1), e;
|
|
1506
1545
|
},
|
|
1507
1546
|
stringify: D
|
|
1508
|
-
},
|
|
1509
|
-
function
|
|
1547
|
+
}, De = (s) => typeof s == "bigint" || Number.isInteger(s), ct = (s, e, t, { intAsBigInt: n }) => n ? BigInt(s) : parseInt(s.substring(e), t);
|
|
1548
|
+
function Ht(s, e, t) {
|
|
1510
1549
|
const { value: n } = s;
|
|
1511
|
-
return
|
|
1550
|
+
return De(n) && n >= 0 ? t + n.toString(e) : D(s);
|
|
1512
1551
|
}
|
|
1513
|
-
const
|
|
1514
|
-
identify: (s) =>
|
|
1552
|
+
const Wt = {
|
|
1553
|
+
identify: (s) => De(s) && s >= 0,
|
|
1515
1554
|
default: !0,
|
|
1516
1555
|
tag: "tag:yaml.org,2002:int",
|
|
1517
1556
|
format: "OCT",
|
|
1518
1557
|
test: /^0o[0-7]+$/,
|
|
1519
|
-
resolve: (s, e, t) =>
|
|
1520
|
-
stringify: (s) =>
|
|
1521
|
-
},
|
|
1522
|
-
identify:
|
|
1558
|
+
resolve: (s, e, t) => ct(s, 2, 8, t),
|
|
1559
|
+
stringify: (s) => Ht(s, 8, "0o")
|
|
1560
|
+
}, Qt = {
|
|
1561
|
+
identify: De,
|
|
1523
1562
|
default: !0,
|
|
1524
1563
|
tag: "tag:yaml.org,2002:int",
|
|
1525
1564
|
test: /^[-+]?[0-9]+$/,
|
|
1526
|
-
resolve: (s, e, t) =>
|
|
1565
|
+
resolve: (s, e, t) => ct(s, 0, 10, t),
|
|
1527
1566
|
stringify: D
|
|
1528
|
-
},
|
|
1529
|
-
identify: (s) =>
|
|
1567
|
+
}, Xt = {
|
|
1568
|
+
identify: (s) => De(s) && s >= 0,
|
|
1530
1569
|
default: !0,
|
|
1531
1570
|
tag: "tag:yaml.org,2002:int",
|
|
1532
1571
|
format: "HEX",
|
|
1533
1572
|
test: /^0x[0-9a-fA-F]+$/,
|
|
1534
|
-
resolve: (s, e, t) =>
|
|
1535
|
-
stringify: (s) =>
|
|
1536
|
-
},
|
|
1537
|
-
|
|
1573
|
+
resolve: (s, e, t) => ct(s, 2, 16, t),
|
|
1574
|
+
stringify: (s) => Ht(s, 16, "0x")
|
|
1575
|
+
}, Ys = [
|
|
1576
|
+
le,
|
|
1538
1577
|
ce,
|
|
1539
1578
|
Pe,
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
Ht,
|
|
1579
|
+
Ke,
|
|
1580
|
+
lt,
|
|
1543
1581
|
Wt,
|
|
1544
1582
|
Qt,
|
|
1545
|
-
|
|
1583
|
+
Xt,
|
|
1546
1584
|
Jt,
|
|
1547
|
-
Yt
|
|
1585
|
+
Yt,
|
|
1586
|
+
Gt
|
|
1548
1587
|
];
|
|
1549
|
-
function
|
|
1588
|
+
function St(s) {
|
|
1550
1589
|
return typeof s == "bigint" || Number.isInteger(s);
|
|
1551
1590
|
}
|
|
1552
|
-
const Oe = ({ value: s }) => JSON.stringify(s),
|
|
1591
|
+
const Oe = ({ value: s }) => JSON.stringify(s), Gs = [
|
|
1553
1592
|
{
|
|
1554
1593
|
identify: (s) => typeof s == "string",
|
|
1555
1594
|
default: !0,
|
|
@@ -1575,12 +1614,12 @@ const Oe = ({ value: s }) => JSON.stringify(s), Ds = [
|
|
|
1575
1614
|
stringify: Oe
|
|
1576
1615
|
},
|
|
1577
1616
|
{
|
|
1578
|
-
identify:
|
|
1617
|
+
identify: St,
|
|
1579
1618
|
default: !0,
|
|
1580
1619
|
tag: "tag:yaml.org,2002:int",
|
|
1581
1620
|
test: /^-?(?:0|[1-9][0-9]*)$/,
|
|
1582
1621
|
resolve: (s, e, { intAsBigInt: t }) => t ? BigInt(s) : parseInt(s, 10),
|
|
1583
|
-
stringify: ({ value: s }) =>
|
|
1622
|
+
stringify: ({ value: s }) => St(s) ? s.toString() : JSON.stringify(s)
|
|
1584
1623
|
},
|
|
1585
1624
|
{
|
|
1586
1625
|
identify: (s) => typeof s == "number",
|
|
@@ -1590,14 +1629,14 @@ const Oe = ({ value: s }) => JSON.stringify(s), Ds = [
|
|
|
1590
1629
|
resolve: (s) => parseFloat(s),
|
|
1591
1630
|
stringify: Oe
|
|
1592
1631
|
}
|
|
1593
|
-
],
|
|
1632
|
+
], Hs = {
|
|
1594
1633
|
default: !0,
|
|
1595
1634
|
tag: "",
|
|
1596
1635
|
test: /^/,
|
|
1597
1636
|
resolve(s, e) {
|
|
1598
1637
|
return e(`Unresolved plain scalar ${JSON.stringify(s)}`), s;
|
|
1599
1638
|
}
|
|
1600
|
-
},
|
|
1639
|
+
}, Ws = [le, ce].concat(Gs, Hs), ft = {
|
|
1601
1640
|
identify: (s) => s instanceof Uint8Array,
|
|
1602
1641
|
// Buffer inherits from Uint8Array
|
|
1603
1642
|
default: !1,
|
|
@@ -1623,29 +1662,29 @@ const Oe = ({ value: s }) => JSON.stringify(s), Ds = [
|
|
|
1623
1662
|
if (!t)
|
|
1624
1663
|
return "";
|
|
1625
1664
|
const o = t;
|
|
1626
|
-
let
|
|
1665
|
+
let a;
|
|
1627
1666
|
if (typeof btoa == "function") {
|
|
1628
|
-
let
|
|
1667
|
+
let l = "";
|
|
1629
1668
|
for (let c = 0; c < o.length; ++c)
|
|
1630
|
-
|
|
1631
|
-
|
|
1669
|
+
l += String.fromCharCode(o[c]);
|
|
1670
|
+
a = btoa(l);
|
|
1632
1671
|
} else
|
|
1633
1672
|
throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
1634
1673
|
if (e ?? (e = O.BLOCK_LITERAL), e !== O.QUOTE_DOUBLE) {
|
|
1635
|
-
const
|
|
1636
|
-
for (let
|
|
1637
|
-
d[
|
|
1638
|
-
|
|
1674
|
+
const l = Math.max(n.options.lineWidth - n.indent.length, n.options.minContentWidth), c = Math.ceil(a.length / l), d = new Array(c);
|
|
1675
|
+
for (let u = 0, f = 0; u < c; ++u, f += l)
|
|
1676
|
+
d[u] = a.substr(f, l);
|
|
1677
|
+
a = d.join(e === O.BLOCK_LITERAL ? `
|
|
1639
1678
|
` : " ");
|
|
1640
1679
|
}
|
|
1641
|
-
return
|
|
1680
|
+
return ot({ comment: s, type: e, value: a }, n, i, r);
|
|
1642
1681
|
}
|
|
1643
1682
|
};
|
|
1644
|
-
function
|
|
1683
|
+
function xt(s, e) {
|
|
1645
1684
|
if (be(s))
|
|
1646
1685
|
for (let t = 0; t < s.items.length; ++t) {
|
|
1647
1686
|
let n = s.items[t];
|
|
1648
|
-
if (
|
|
1687
|
+
if (!L(n)) {
|
|
1649
1688
|
if (ye(n)) {
|
|
1650
1689
|
n.items.length > 1 && e("Each pair must have its own sequence indicator");
|
|
1651
1690
|
const i = n.items[0] || new B(new O(null));
|
|
@@ -1657,44 +1696,44 @@ ${r.comment}` : n.comment;
|
|
|
1657
1696
|
}
|
|
1658
1697
|
n = i;
|
|
1659
1698
|
}
|
|
1660
|
-
s.items[t] =
|
|
1699
|
+
s.items[t] = L(n) ? n : new B(n);
|
|
1661
1700
|
}
|
|
1662
1701
|
}
|
|
1663
1702
|
else
|
|
1664
1703
|
e("Expected a sequence for this tag");
|
|
1665
1704
|
return s;
|
|
1666
1705
|
}
|
|
1667
|
-
function
|
|
1706
|
+
function zt(s, e, t) {
|
|
1668
1707
|
const { replacer: n } = t, i = new W(s);
|
|
1669
1708
|
i.tag = "tag:yaml.org,2002:pairs";
|
|
1670
1709
|
let r = 0;
|
|
1671
1710
|
if (e && Symbol.iterator in Object(e))
|
|
1672
1711
|
for (let o of e) {
|
|
1673
1712
|
typeof n == "function" && (o = n.call(e, String(r++), o));
|
|
1674
|
-
let
|
|
1713
|
+
let a, l;
|
|
1675
1714
|
if (Array.isArray(o))
|
|
1676
1715
|
if (o.length === 2)
|
|
1677
|
-
|
|
1716
|
+
a = o[0], l = o[1];
|
|
1678
1717
|
else
|
|
1679
1718
|
throw new TypeError(`Expected [key, value] tuple: ${o}`);
|
|
1680
1719
|
else if (o && o instanceof Object) {
|
|
1681
1720
|
const c = Object.keys(o);
|
|
1682
1721
|
if (c.length === 1)
|
|
1683
|
-
|
|
1722
|
+
a = c[0], l = o[a];
|
|
1684
1723
|
else
|
|
1685
1724
|
throw new TypeError(`Expected tuple with one key, not ${c.length} keys`);
|
|
1686
1725
|
} else
|
|
1687
|
-
|
|
1688
|
-
i.items.push(
|
|
1726
|
+
a = o;
|
|
1727
|
+
i.items.push(at(a, l, t));
|
|
1689
1728
|
}
|
|
1690
1729
|
return i;
|
|
1691
1730
|
}
|
|
1692
|
-
const
|
|
1731
|
+
const ut = {
|
|
1693
1732
|
collection: "seq",
|
|
1694
1733
|
default: !1,
|
|
1695
1734
|
tag: "tag:yaml.org,2002:pairs",
|
|
1696
|
-
resolve:
|
|
1697
|
-
createNode:
|
|
1735
|
+
resolve: xt,
|
|
1736
|
+
createNode: zt
|
|
1698
1737
|
};
|
|
1699
1738
|
class se extends W {
|
|
1700
1739
|
constructor() {
|
|
@@ -1711,57 +1750,57 @@ class se extends W {
|
|
|
1711
1750
|
t?.onCreate && t.onCreate(n);
|
|
1712
1751
|
for (const i of this.items) {
|
|
1713
1752
|
let r, o;
|
|
1714
|
-
if (
|
|
1753
|
+
if (L(i) ? (r = j(i.key, "", t), o = j(i.value, r, t)) : r = j(i, "", t), n.has(r))
|
|
1715
1754
|
throw new Error("Ordered maps must not include duplicate keys");
|
|
1716
1755
|
n.set(r, o);
|
|
1717
1756
|
}
|
|
1718
1757
|
return n;
|
|
1719
1758
|
}
|
|
1720
1759
|
static from(e, t, n) {
|
|
1721
|
-
const i =
|
|
1760
|
+
const i = zt(e, t, n), r = new this();
|
|
1722
1761
|
return r.items = i.items, r;
|
|
1723
1762
|
}
|
|
1724
1763
|
}
|
|
1725
1764
|
se.tag = "tag:yaml.org,2002:omap";
|
|
1726
|
-
const
|
|
1765
|
+
const ht = {
|
|
1727
1766
|
collection: "seq",
|
|
1728
1767
|
identify: (s) => s instanceof Map,
|
|
1729
1768
|
nodeClass: se,
|
|
1730
1769
|
default: !1,
|
|
1731
1770
|
tag: "tag:yaml.org,2002:omap",
|
|
1732
1771
|
resolve(s, e) {
|
|
1733
|
-
const t =
|
|
1772
|
+
const t = xt(s, e), n = [];
|
|
1734
1773
|
for (const { key: i } of t.items)
|
|
1735
|
-
|
|
1774
|
+
T(i) && (n.includes(i.value) ? e(`Ordered maps must not include duplicate keys: ${i.value}`) : n.push(i.value));
|
|
1736
1775
|
return Object.assign(new se(), t);
|
|
1737
1776
|
},
|
|
1738
1777
|
createNode: (s, e, t) => se.from(s, e, t)
|
|
1739
1778
|
};
|
|
1740
|
-
function
|
|
1741
|
-
return e && (s ?
|
|
1779
|
+
function Zt({ value: s, source: e }, t) {
|
|
1780
|
+
return e && (s ? es : ts).test.test(e) ? e : s ? t.options.trueStr : t.options.falseStr;
|
|
1742
1781
|
}
|
|
1743
|
-
const
|
|
1782
|
+
const es = {
|
|
1744
1783
|
identify: (s) => s === !0,
|
|
1745
1784
|
default: !0,
|
|
1746
1785
|
tag: "tag:yaml.org,2002:bool",
|
|
1747
1786
|
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
1748
1787
|
resolve: () => new O(!0),
|
|
1749
|
-
stringify:
|
|
1750
|
-
},
|
|
1788
|
+
stringify: Zt
|
|
1789
|
+
}, ts = {
|
|
1751
1790
|
identify: (s) => s === !1,
|
|
1752
1791
|
default: !0,
|
|
1753
1792
|
tag: "tag:yaml.org,2002:bool",
|
|
1754
1793
|
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
|
|
1755
1794
|
resolve: () => new O(!1),
|
|
1756
|
-
stringify:
|
|
1757
|
-
},
|
|
1795
|
+
stringify: Zt
|
|
1796
|
+
}, Qs = {
|
|
1758
1797
|
identify: (s) => typeof s == "number",
|
|
1759
1798
|
default: !0,
|
|
1760
1799
|
tag: "tag:yaml.org,2002:float",
|
|
1761
1800
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
1762
1801
|
resolve: (s) => s.slice(-3).toLowerCase() === "nan" ? NaN : s[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
1763
1802
|
stringify: D
|
|
1764
|
-
},
|
|
1803
|
+
}, Xs = {
|
|
1765
1804
|
identify: (s) => typeof s == "number",
|
|
1766
1805
|
default: !0,
|
|
1767
1806
|
tag: "tag:yaml.org,2002:float",
|
|
@@ -1772,7 +1811,7 @@ const Zt = {
|
|
|
1772
1811
|
const e = Number(s.value);
|
|
1773
1812
|
return isFinite(e) ? e.toExponential() : D(s);
|
|
1774
1813
|
}
|
|
1775
|
-
},
|
|
1814
|
+
}, xs = {
|
|
1776
1815
|
identify: (s) => typeof s == "number",
|
|
1777
1816
|
default: !0,
|
|
1778
1817
|
tag: "tag:yaml.org,2002:float",
|
|
@@ -1787,7 +1826,7 @@ const Zt = {
|
|
|
1787
1826
|
},
|
|
1788
1827
|
stringify: D
|
|
1789
1828
|
}, we = (s) => typeof s == "bigint" || Number.isInteger(s);
|
|
1790
|
-
function
|
|
1829
|
+
function qe(s, e, t, { intAsBigInt: n }) {
|
|
1791
1830
|
const i = s[0];
|
|
1792
1831
|
if ((i === "-" || i === "+") && (e += 1), s = s.substring(e).replace(/_/g, ""), n) {
|
|
1793
1832
|
switch (t) {
|
|
@@ -1807,7 +1846,7 @@ function De(s, e, t, { intAsBigInt: n }) {
|
|
|
1807
1846
|
const r = parseInt(s, t);
|
|
1808
1847
|
return i === "-" ? -1 * r : r;
|
|
1809
1848
|
}
|
|
1810
|
-
function
|
|
1849
|
+
function dt(s, e, t) {
|
|
1811
1850
|
const { value: n } = s;
|
|
1812
1851
|
if (we(n)) {
|
|
1813
1852
|
const i = n.toString(e);
|
|
@@ -1815,37 +1854,37 @@ function ut(s, e, t) {
|
|
|
1815
1854
|
}
|
|
1816
1855
|
return D(s);
|
|
1817
1856
|
}
|
|
1818
|
-
const
|
|
1857
|
+
const zs = {
|
|
1819
1858
|
identify: we,
|
|
1820
1859
|
default: !0,
|
|
1821
1860
|
tag: "tag:yaml.org,2002:int",
|
|
1822
1861
|
format: "BIN",
|
|
1823
1862
|
test: /^[-+]?0b[0-1_]+$/,
|
|
1824
|
-
resolve: (s, e, t) =>
|
|
1825
|
-
stringify: (s) =>
|
|
1826
|
-
},
|
|
1863
|
+
resolve: (s, e, t) => qe(s, 2, 2, t),
|
|
1864
|
+
stringify: (s) => dt(s, 2, "0b")
|
|
1865
|
+
}, Zs = {
|
|
1827
1866
|
identify: we,
|
|
1828
1867
|
default: !0,
|
|
1829
1868
|
tag: "tag:yaml.org,2002:int",
|
|
1830
1869
|
format: "OCT",
|
|
1831
1870
|
test: /^[-+]?0[0-7_]+$/,
|
|
1832
|
-
resolve: (s, e, t) =>
|
|
1833
|
-
stringify: (s) =>
|
|
1834
|
-
},
|
|
1871
|
+
resolve: (s, e, t) => qe(s, 1, 8, t),
|
|
1872
|
+
stringify: (s) => dt(s, 8, "0")
|
|
1873
|
+
}, en = {
|
|
1835
1874
|
identify: we,
|
|
1836
1875
|
default: !0,
|
|
1837
1876
|
tag: "tag:yaml.org,2002:int",
|
|
1838
1877
|
test: /^[-+]?[0-9][0-9_]*$/,
|
|
1839
|
-
resolve: (s, e, t) =>
|
|
1878
|
+
resolve: (s, e, t) => qe(s, 0, 10, t),
|
|
1840
1879
|
stringify: D
|
|
1841
|
-
},
|
|
1880
|
+
}, tn = {
|
|
1842
1881
|
identify: we,
|
|
1843
1882
|
default: !0,
|
|
1844
1883
|
tag: "tag:yaml.org,2002:int",
|
|
1845
1884
|
format: "HEX",
|
|
1846
1885
|
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
1847
|
-
resolve: (s, e, t) =>
|
|
1848
|
-
stringify: (s) =>
|
|
1886
|
+
resolve: (s, e, t) => qe(s, 2, 16, t),
|
|
1887
|
+
stringify: (s) => dt(s, 16, "0x")
|
|
1849
1888
|
};
|
|
1850
1889
|
class ne extends M {
|
|
1851
1890
|
constructor(e) {
|
|
@@ -1853,7 +1892,7 @@ class ne extends M {
|
|
|
1853
1892
|
}
|
|
1854
1893
|
add(e) {
|
|
1855
1894
|
let t;
|
|
1856
|
-
|
|
1895
|
+
L(e) ? t = e : e && typeof e == "object" && "key" in e && "value" in e && e.value === null ? t = new B(e.key, null) : t = new B(e, null), H(this.items, t.key) || this.items.push(t);
|
|
1857
1896
|
}
|
|
1858
1897
|
/**
|
|
1859
1898
|
* If `keepPair` is `true`, returns the Pair matching `key`.
|
|
@@ -1861,7 +1900,7 @@ class ne extends M {
|
|
|
1861
1900
|
*/
|
|
1862
1901
|
get(e, t) {
|
|
1863
1902
|
const n = H(this.items, e);
|
|
1864
|
-
return !t &&
|
|
1903
|
+
return !t && L(n) ? T(n.key) ? n.key.value : n.key : n;
|
|
1865
1904
|
}
|
|
1866
1905
|
set(e, t) {
|
|
1867
1906
|
if (typeof t != "boolean")
|
|
@@ -1883,12 +1922,12 @@ class ne extends M {
|
|
|
1883
1922
|
const { replacer: i } = n, r = new this(e);
|
|
1884
1923
|
if (t && Symbol.iterator in Object(t))
|
|
1885
1924
|
for (let o of t)
|
|
1886
|
-
typeof i == "function" && (o = i.call(t, o, o)), r.items.push(
|
|
1925
|
+
typeof i == "function" && (o = i.call(t, o, o)), r.items.push(at(o, null, n));
|
|
1887
1926
|
return r;
|
|
1888
1927
|
}
|
|
1889
1928
|
}
|
|
1890
1929
|
ne.tag = "tag:yaml.org,2002:set";
|
|
1891
|
-
const
|
|
1930
|
+
const pt = {
|
|
1892
1931
|
collection: "map",
|
|
1893
1932
|
identify: (s) => s instanceof Set,
|
|
1894
1933
|
nodeClass: ne,
|
|
@@ -1905,11 +1944,11 @@ const ht = {
|
|
|
1905
1944
|
return s;
|
|
1906
1945
|
}
|
|
1907
1946
|
};
|
|
1908
|
-
function
|
|
1909
|
-
const t = s[0], n = t === "-" || t === "+" ? s.substring(1) : s, i = (o) => e ? BigInt(o) : Number(o), r = n.replace(/_/g, "").split(":").reduce((o,
|
|
1947
|
+
function mt(s, e) {
|
|
1948
|
+
const t = s[0], n = t === "-" || t === "+" ? s.substring(1) : s, i = (o) => e ? BigInt(o) : Number(o), r = n.replace(/_/g, "").split(":").reduce((o, a) => o * i(60) + i(a), i(0));
|
|
1910
1949
|
return t === "-" ? i(-1) * r : r;
|
|
1911
1950
|
}
|
|
1912
|
-
function
|
|
1951
|
+
function ss(s) {
|
|
1913
1952
|
let { value: e } = s, t = (o) => o;
|
|
1914
1953
|
if (typeof e == "bigint")
|
|
1915
1954
|
t = (o) => BigInt(o);
|
|
@@ -1920,23 +1959,23 @@ function ts(s) {
|
|
|
1920
1959
|
const i = t(60), r = [e % i];
|
|
1921
1960
|
return e < 60 ? r.unshift(0) : (e = (e - r[0]) / i, r.unshift(e % i), e >= 60 && (e = (e - r[0]) / i, r.unshift(e))), n + r.map((o) => String(o).padStart(2, "0")).join(":").replace(/000000\d*$/, "");
|
|
1922
1961
|
}
|
|
1923
|
-
const
|
|
1962
|
+
const ns = {
|
|
1924
1963
|
identify: (s) => typeof s == "bigint" || Number.isInteger(s),
|
|
1925
1964
|
default: !0,
|
|
1926
1965
|
tag: "tag:yaml.org,2002:int",
|
|
1927
1966
|
format: "TIME",
|
|
1928
1967
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
1929
|
-
resolve: (s, e, { intAsBigInt: t }) =>
|
|
1930
|
-
stringify:
|
|
1931
|
-
},
|
|
1968
|
+
resolve: (s, e, { intAsBigInt: t }) => mt(s, t),
|
|
1969
|
+
stringify: ss
|
|
1970
|
+
}, is = {
|
|
1932
1971
|
identify: (s) => typeof s == "number",
|
|
1933
1972
|
default: !0,
|
|
1934
1973
|
tag: "tag:yaml.org,2002:float",
|
|
1935
1974
|
format: "TIME",
|
|
1936
1975
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
1937
|
-
resolve: (s) =>
|
|
1938
|
-
stringify:
|
|
1939
|
-
},
|
|
1976
|
+
resolve: (s) => mt(s, !1),
|
|
1977
|
+
stringify: ss
|
|
1978
|
+
}, Fe = {
|
|
1940
1979
|
identify: (s) => s instanceof Date,
|
|
1941
1980
|
default: !0,
|
|
1942
1981
|
tag: "tag:yaml.org,2002:timestamp",
|
|
@@ -1945,147 +1984,147 @@ const ss = {
|
|
|
1945
1984
|
// assumed to be 00:00:00Z (start of day, UTC).
|
|
1946
1985
|
test: RegExp("^([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})?))?)?$"),
|
|
1947
1986
|
resolve(s) {
|
|
1948
|
-
const e = s.match(
|
|
1987
|
+
const e = s.match(Fe.test);
|
|
1949
1988
|
if (!e)
|
|
1950
1989
|
throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
1951
|
-
const [, t, n, i, r, o,
|
|
1952
|
-
let c = Date.UTC(t, n - 1, i, r || 0, o || 0,
|
|
1990
|
+
const [, t, n, i, r, o, a] = e.map(Number), l = e[7] ? Number((e[7] + "00").substr(1, 3)) : 0;
|
|
1991
|
+
let c = Date.UTC(t, n - 1, i, r || 0, o || 0, a || 0, l);
|
|
1953
1992
|
const d = e[8];
|
|
1954
1993
|
if (d && d !== "Z") {
|
|
1955
|
-
let
|
|
1956
|
-
Math.abs(
|
|
1994
|
+
let u = mt(d, !1);
|
|
1995
|
+
Math.abs(u) < 30 && (u *= 60), c -= 6e4 * u;
|
|
1957
1996
|
}
|
|
1958
1997
|
return new Date(c);
|
|
1959
1998
|
},
|
|
1960
1999
|
stringify: ({ value: s }) => s?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? ""
|
|
1961
|
-
},
|
|
1962
|
-
|
|
2000
|
+
}, Nt = [
|
|
2001
|
+
le,
|
|
1963
2002
|
ce,
|
|
1964
2003
|
Pe,
|
|
1965
|
-
|
|
1966
|
-
Zt,
|
|
2004
|
+
Ke,
|
|
1967
2005
|
es,
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
F,
|
|
2006
|
+
ts,
|
|
2007
|
+
zs,
|
|
2008
|
+
Zs,
|
|
2009
|
+
en,
|
|
2010
|
+
tn,
|
|
2011
|
+
Qs,
|
|
2012
|
+
Xs,
|
|
2013
|
+
xs,
|
|
1977
2014
|
ft,
|
|
1978
|
-
|
|
2015
|
+
U,
|
|
1979
2016
|
ht,
|
|
1980
|
-
|
|
2017
|
+
ut,
|
|
2018
|
+
pt,
|
|
1981
2019
|
ns,
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
["
|
|
1986
|
-
["
|
|
1987
|
-
["
|
|
1988
|
-
["
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2020
|
+
is,
|
|
2021
|
+
Fe
|
|
2022
|
+
], Ot = /* @__PURE__ */ new Map([
|
|
2023
|
+
["core", Ys],
|
|
2024
|
+
["failsafe", [le, ce, Pe]],
|
|
2025
|
+
["json", Ws],
|
|
2026
|
+
["yaml11", Nt],
|
|
2027
|
+
["yaml-1.1", Nt]
|
|
2028
|
+
]), At = {
|
|
2029
|
+
binary: ft,
|
|
2030
|
+
bool: lt,
|
|
2031
|
+
float: Gt,
|
|
2032
|
+
floatExp: Yt,
|
|
2033
|
+
floatNaN: Jt,
|
|
2034
|
+
floatTime: is,
|
|
2035
|
+
int: Qt,
|
|
2036
|
+
intHex: Xt,
|
|
2037
|
+
intOct: Wt,
|
|
2038
|
+
intTime: ns,
|
|
2039
|
+
map: le,
|
|
2040
|
+
merge: U,
|
|
2041
|
+
null: Ke,
|
|
2042
|
+
omap: ht,
|
|
2043
|
+
pairs: ut,
|
|
2005
2044
|
seq: ce,
|
|
2006
|
-
set:
|
|
2007
|
-
timestamp:
|
|
2008
|
-
},
|
|
2009
|
-
"tag:yaml.org,2002:binary":
|
|
2010
|
-
"tag:yaml.org,2002:merge":
|
|
2011
|
-
"tag:yaml.org,2002:omap":
|
|
2012
|
-
"tag:yaml.org,2002:pairs":
|
|
2013
|
-
"tag:yaml.org,2002:set":
|
|
2014
|
-
"tag:yaml.org,2002:timestamp":
|
|
2045
|
+
set: pt,
|
|
2046
|
+
timestamp: Fe
|
|
2047
|
+
}, sn = {
|
|
2048
|
+
"tag:yaml.org,2002:binary": ft,
|
|
2049
|
+
"tag:yaml.org,2002:merge": U,
|
|
2050
|
+
"tag:yaml.org,2002:omap": ht,
|
|
2051
|
+
"tag:yaml.org,2002:pairs": ut,
|
|
2052
|
+
"tag:yaml.org,2002:set": pt,
|
|
2053
|
+
"tag:yaml.org,2002:timestamp": Fe
|
|
2015
2054
|
};
|
|
2016
|
-
function
|
|
2017
|
-
const n =
|
|
2055
|
+
function Je(s, e, t) {
|
|
2056
|
+
const n = Ot.get(e);
|
|
2018
2057
|
if (n && !s)
|
|
2019
|
-
return t && !n.includes(
|
|
2058
|
+
return t && !n.includes(U) ? n.concat(U) : n.slice();
|
|
2020
2059
|
let i = n;
|
|
2021
2060
|
if (!i)
|
|
2022
2061
|
if (Array.isArray(s))
|
|
2023
2062
|
i = [];
|
|
2024
2063
|
else {
|
|
2025
|
-
const r = Array.from(
|
|
2064
|
+
const r = Array.from(Ot.keys()).filter((o) => o !== "yaml11").map((o) => JSON.stringify(o)).join(", ");
|
|
2026
2065
|
throw new Error(`Unknown schema "${e}"; use one of ${r} or define customTags array`);
|
|
2027
2066
|
}
|
|
2028
2067
|
if (Array.isArray(s))
|
|
2029
2068
|
for (const r of s)
|
|
2030
2069
|
i = i.concat(r);
|
|
2031
2070
|
else typeof s == "function" && (i = s(i.slice()));
|
|
2032
|
-
return t && (i = i.concat(
|
|
2033
|
-
const
|
|
2034
|
-
if (!
|
|
2035
|
-
const
|
|
2036
|
-
throw new Error(`Unknown custom tag ${
|
|
2071
|
+
return t && (i = i.concat(U)), i.reduce((r, o) => {
|
|
2072
|
+
const a = typeof o == "string" ? At[o] : o;
|
|
2073
|
+
if (!a) {
|
|
2074
|
+
const l = JSON.stringify(o), c = Object.keys(At).map((d) => JSON.stringify(d)).join(", ");
|
|
2075
|
+
throw new Error(`Unknown custom tag ${l}; use one of ${c}`);
|
|
2037
2076
|
}
|
|
2038
|
-
return r.includes(
|
|
2077
|
+
return r.includes(a) || r.push(a), r;
|
|
2039
2078
|
}, []);
|
|
2040
2079
|
}
|
|
2041
|
-
const
|
|
2042
|
-
class
|
|
2043
|
-
constructor({ compat: e, customTags: t, merge: n, resolveKnownTags: i, schema: r, sortMapEntries: o, toStringDefaults:
|
|
2044
|
-
this.compat = Array.isArray(e) ?
|
|
2080
|
+
const nn = (s, e) => s.key < e.key ? -1 : s.key > e.key ? 1 : 0;
|
|
2081
|
+
class gt {
|
|
2082
|
+
constructor({ compat: e, customTags: t, merge: n, resolveKnownTags: i, schema: r, sortMapEntries: o, toStringDefaults: a }) {
|
|
2083
|
+
this.compat = Array.isArray(e) ? Je(e, "compat") : e ? Je(null, e) : null, this.name = typeof r == "string" && r || "core", this.knownTags = i ? sn : {}, this.tags = Je(t, this.name, n), this.toStringOptions = a ?? null, Object.defineProperty(this, J, { value: le }), Object.defineProperty(this, q, { value: Pe }), Object.defineProperty(this, oe, { value: ce }), this.sortMapEntries = typeof o == "function" ? o : o === !0 ? nn : null;
|
|
2045
2084
|
}
|
|
2046
2085
|
clone() {
|
|
2047
|
-
const e = Object.create(
|
|
2086
|
+
const e = Object.create(gt.prototype, Object.getOwnPropertyDescriptors(this));
|
|
2048
2087
|
return e.tags = this.tags.slice(), e;
|
|
2049
2088
|
}
|
|
2050
2089
|
}
|
|
2051
|
-
function
|
|
2090
|
+
function rn(s, e) {
|
|
2052
2091
|
const t = [];
|
|
2053
2092
|
let n = e.directives === !0;
|
|
2054
2093
|
if (e.directives !== !1 && s.directives) {
|
|
2055
|
-
const
|
|
2056
|
-
|
|
2094
|
+
const l = s.directives.toString(s);
|
|
2095
|
+
l ? (t.push(l), n = !0) : s.directives.docStart && (n = !0);
|
|
2057
2096
|
}
|
|
2058
2097
|
n && t.push("---");
|
|
2059
|
-
const i =
|
|
2098
|
+
const i = qt(s, e), { commentString: r } = i.options;
|
|
2060
2099
|
if (s.commentBefore) {
|
|
2061
2100
|
t.length !== 1 && t.unshift("");
|
|
2062
|
-
const
|
|
2063
|
-
t.unshift(
|
|
2101
|
+
const l = r(s.commentBefore);
|
|
2102
|
+
t.unshift(F(l, ""));
|
|
2064
2103
|
}
|
|
2065
|
-
let o = !1,
|
|
2104
|
+
let o = !1, a = null;
|
|
2066
2105
|
if (s.contents) {
|
|
2067
|
-
if (
|
|
2106
|
+
if ($(s.contents)) {
|
|
2068
2107
|
if (s.contents.spaceBefore && n && t.push(""), s.contents.commentBefore) {
|
|
2069
2108
|
const d = r(s.contents.commentBefore);
|
|
2070
|
-
t.push(
|
|
2109
|
+
t.push(F(d, ""));
|
|
2071
2110
|
}
|
|
2072
|
-
i.forceBlockIndent = !!s.comment,
|
|
2111
|
+
i.forceBlockIndent = !!s.comment, a = s.contents.comment;
|
|
2073
2112
|
}
|
|
2074
|
-
const
|
|
2075
|
-
let c = ie(s.contents, i, () =>
|
|
2076
|
-
|
|
2113
|
+
const l = a ? void 0 : () => o = !0;
|
|
2114
|
+
let c = ie(s.contents, i, () => a = null, l);
|
|
2115
|
+
a && (c += G(c, "", r(a))), (c[0] === "|" || c[0] === ">") && t[t.length - 1] === "---" ? t[t.length - 1] = `--- ${c}` : t.push(c);
|
|
2077
2116
|
} else
|
|
2078
2117
|
t.push(ie(s.contents, i));
|
|
2079
2118
|
if (s.directives?.docEnd)
|
|
2080
2119
|
if (s.comment) {
|
|
2081
|
-
const
|
|
2082
|
-
|
|
2083
|
-
`) ? (t.push("..."), t.push(
|
|
2120
|
+
const l = r(s.comment);
|
|
2121
|
+
l.includes(`
|
|
2122
|
+
`) ? (t.push("..."), t.push(F(l, ""))) : t.push(`... ${l}`);
|
|
2084
2123
|
} else
|
|
2085
2124
|
t.push("...");
|
|
2086
2125
|
else {
|
|
2087
|
-
let
|
|
2088
|
-
|
|
2126
|
+
let l = s.comment;
|
|
2127
|
+
l && o && (l = l.replace(/^\n+/, "")), l && ((!o || a) && t[t.length - 1] !== "" && t.push(""), t.push(F(r(l), "")));
|
|
2089
2128
|
}
|
|
2090
2129
|
return t.join(`
|
|
2091
2130
|
`) + `
|
|
@@ -2093,7 +2132,7 @@ function Xs(s, e) {
|
|
|
2093
2132
|
}
|
|
2094
2133
|
class Ue {
|
|
2095
2134
|
constructor(e, t, n) {
|
|
2096
|
-
this.commentBefore = null, this.comment = null, this.errors = [], this.warnings = [], Object.defineProperty(this,
|
|
2135
|
+
this.commentBefore = null, this.comment = null, this.errors = [], this.warnings = [], Object.defineProperty(this, P, { value: Qe });
|
|
2097
2136
|
let i = null;
|
|
2098
2137
|
typeof t == "function" || Array.isArray(t) ? i = t : n === void 0 && t && (n = t, t = void 0);
|
|
2099
2138
|
const r = Object.assign({
|
|
@@ -2117,9 +2156,9 @@ class Ue {
|
|
|
2117
2156
|
*/
|
|
2118
2157
|
clone() {
|
|
2119
2158
|
const e = Object.create(Ue.prototype, {
|
|
2120
|
-
[
|
|
2159
|
+
[P]: { value: Qe }
|
|
2121
2160
|
});
|
|
2122
|
-
return e.commentBefore = this.commentBefore, e.comment = this.comment, e.errors = this.errors.slice(), e.warnings = this.warnings.slice(), e.options = Object.assign({}, this.options), this.directives && (e.directives = this.directives.clone()), e.schema = this.schema.clone(), e.contents =
|
|
2161
|
+
return e.commentBefore = this.commentBefore, e.comment = this.comment, e.errors = this.errors.slice(), e.warnings = this.warnings.slice(), e.options = Object.assign({}, this.options), this.directives && (e.directives = this.directives.clone()), e.schema = this.schema.clone(), e.contents = $(this.contents) ? this.contents.clone(e.schema) : this.contents, this.range && (e.range = this.range.slice()), e;
|
|
2123
2162
|
}
|
|
2124
2163
|
/** Adds a value to the document. */
|
|
2125
2164
|
add(e) {
|
|
@@ -2140,11 +2179,11 @@ class Ue {
|
|
|
2140
2179
|
*/
|
|
2141
2180
|
createAlias(e, t) {
|
|
2142
2181
|
if (!e.anchor) {
|
|
2143
|
-
const n =
|
|
2182
|
+
const n = Mt(this);
|
|
2144
2183
|
e.anchor = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
2145
|
-
!t || n.has(t) ?
|
|
2184
|
+
!t || n.has(t) ? jt(t || "a", n) : t;
|
|
2146
2185
|
}
|
|
2147
|
-
return new
|
|
2186
|
+
return new rt(e.anchor);
|
|
2148
2187
|
}
|
|
2149
2188
|
createNode(e, t, n) {
|
|
2150
2189
|
let i;
|
|
@@ -2154,20 +2193,20 @@ class Ue {
|
|
|
2154
2193
|
const p = (w) => typeof w == "number" || w instanceof String || w instanceof Number, b = t.filter(p).map(String);
|
|
2155
2194
|
b.length > 0 && (t = t.concat(b)), i = t;
|
|
2156
2195
|
} else n === void 0 && t && (n = t, t = void 0);
|
|
2157
|
-
const { aliasDuplicateObjects: r, anchorPrefix: o, flow:
|
|
2196
|
+
const { aliasDuplicateObjects: r, anchorPrefix: o, flow: a, keepUndefined: l, onTagObj: c, tag: d } = n ?? {}, { onAnchor: u, setAnchors: f, sourceObjects: m } = _s(
|
|
2158
2197
|
this,
|
|
2159
2198
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
2160
2199
|
o || "a"
|
|
2161
2200
|
), g = {
|
|
2162
2201
|
aliasDuplicateObjects: r ?? !0,
|
|
2163
|
-
keepUndefined:
|
|
2164
|
-
onAnchor:
|
|
2202
|
+
keepUndefined: l ?? !1,
|
|
2203
|
+
onAnchor: u,
|
|
2165
2204
|
onTagObj: c,
|
|
2166
2205
|
replacer: i,
|
|
2167
2206
|
schema: this.schema,
|
|
2168
2207
|
sourceObjects: m
|
|
2169
2208
|
}, h = me(e, d, g);
|
|
2170
|
-
return
|
|
2209
|
+
return a && I(h) && (h.flow = !0), f(), h;
|
|
2171
2210
|
}
|
|
2172
2211
|
/**
|
|
2173
2212
|
* Convert a key and a value into a `Pair` using the current schema,
|
|
@@ -2205,7 +2244,7 @@ class Ue {
|
|
|
2205
2244
|
* `true` (collections are always returned intact).
|
|
2206
2245
|
*/
|
|
2207
2246
|
getIn(e, t) {
|
|
2208
|
-
return ue(e) ? !t &&
|
|
2247
|
+
return ue(e) ? !t && T(this.contents) ? this.contents.value : this.contents : I(this.contents) ? this.contents.getIn(e, t) : void 0;
|
|
2209
2248
|
}
|
|
2210
2249
|
/**
|
|
2211
2250
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -2224,14 +2263,14 @@ class Ue {
|
|
|
2224
2263
|
* boolean to add/remove the item from the set.
|
|
2225
2264
|
*/
|
|
2226
2265
|
set(e, t) {
|
|
2227
|
-
this.contents == null ? this.contents =
|
|
2266
|
+
this.contents == null ? this.contents = Le(this.schema, [e], t) : x(this.contents) && this.contents.set(e, t);
|
|
2228
2267
|
}
|
|
2229
2268
|
/**
|
|
2230
2269
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
2231
2270
|
* boolean to add/remove the item from the set.
|
|
2232
2271
|
*/
|
|
2233
2272
|
setIn(e, t) {
|
|
2234
|
-
ue(e) ? this.contents = t : this.contents == null ? this.contents =
|
|
2273
|
+
ue(e) ? this.contents = t : this.contents == null ? this.contents = Le(this.schema, Array.from(e), t) : x(this.contents) && this.contents.setIn(e, t);
|
|
2235
2274
|
}
|
|
2236
2275
|
/**
|
|
2237
2276
|
* Change the YAML version and schema used by the document.
|
|
@@ -2262,24 +2301,24 @@ class Ue {
|
|
|
2262
2301
|
if (t.schema instanceof Object)
|
|
2263
2302
|
this.schema = t.schema;
|
|
2264
2303
|
else if (n)
|
|
2265
|
-
this.schema = new
|
|
2304
|
+
this.schema = new gt(Object.assign(n, t));
|
|
2266
2305
|
else
|
|
2267
2306
|
throw new Error("With a null YAML version, the { schema: Schema } option is required");
|
|
2268
2307
|
}
|
|
2269
2308
|
// json & jsonArg are only used from toJSON()
|
|
2270
2309
|
toJS({ json: e, jsonArg: t, mapAsMap: n, maxAliasCount: i, onAnchor: r, reviver: o } = {}) {
|
|
2271
|
-
const
|
|
2310
|
+
const a = {
|
|
2272
2311
|
anchors: /* @__PURE__ */ new Map(),
|
|
2273
2312
|
doc: this,
|
|
2274
2313
|
keep: !e,
|
|
2275
2314
|
mapAsMap: n === !0,
|
|
2276
2315
|
mapKeyWarned: !1,
|
|
2277
2316
|
maxAliasCount: typeof i == "number" ? i : 100
|
|
2278
|
-
},
|
|
2317
|
+
}, l = j(this.contents, t ?? "", a);
|
|
2279
2318
|
if (typeof r == "function")
|
|
2280
|
-
for (const { count: c, res: d } of
|
|
2319
|
+
for (const { count: c, res: d } of a.anchors.values())
|
|
2281
2320
|
r(d, c);
|
|
2282
|
-
return typeof o == "function" ? ee(o, { "":
|
|
2321
|
+
return typeof o == "function" ? ee(o, { "": l }, "", l) : l;
|
|
2283
2322
|
}
|
|
2284
2323
|
/**
|
|
2285
2324
|
* A JSON representation of the document `contents`.
|
|
@@ -2298,7 +2337,7 @@ class Ue {
|
|
|
2298
2337
|
const t = JSON.stringify(e.indent);
|
|
2299
2338
|
throw new Error(`"indent" option must be a positive integer, not ${t}`);
|
|
2300
2339
|
}
|
|
2301
|
-
return
|
|
2340
|
+
return rn(this, e);
|
|
2302
2341
|
}
|
|
2303
2342
|
}
|
|
2304
2343
|
function x(s) {
|
|
@@ -2306,42 +2345,42 @@ function x(s) {
|
|
|
2306
2345
|
return !0;
|
|
2307
2346
|
throw new Error("Expected a YAML collection as document contents");
|
|
2308
2347
|
}
|
|
2309
|
-
class
|
|
2348
|
+
class rs extends Error {
|
|
2310
2349
|
constructor(e, t, n, i) {
|
|
2311
2350
|
super(), this.name = e, this.code = n, this.message = i, this.pos = t;
|
|
2312
2351
|
}
|
|
2313
2352
|
}
|
|
2314
|
-
class he extends
|
|
2353
|
+
class he extends rs {
|
|
2315
2354
|
constructor(e, t, n) {
|
|
2316
2355
|
super("YAMLParseError", e, t, n);
|
|
2317
2356
|
}
|
|
2318
2357
|
}
|
|
2319
|
-
class
|
|
2358
|
+
class on extends rs {
|
|
2320
2359
|
constructor(e, t, n) {
|
|
2321
2360
|
super("YAMLWarning", e, t, n);
|
|
2322
2361
|
}
|
|
2323
2362
|
}
|
|
2324
|
-
const
|
|
2363
|
+
const Et = (s, e) => (t) => {
|
|
2325
2364
|
if (t.pos[0] === -1)
|
|
2326
2365
|
return;
|
|
2327
|
-
t.linePos = t.pos.map((
|
|
2366
|
+
t.linePos = t.pos.map((a) => e.linePos(a));
|
|
2328
2367
|
const { line: n, col: i } = t.linePos[0];
|
|
2329
2368
|
t.message += ` at line ${n}, column ${i}`;
|
|
2330
2369
|
let r = i - 1, o = s.substring(e.lineStarts[n - 1], e.lineStarts[n]).replace(/[\n\r]+$/, "");
|
|
2331
2370
|
if (r >= 60 && o.length > 80) {
|
|
2332
|
-
const
|
|
2333
|
-
o = "…" + o.substring(
|
|
2371
|
+
const a = Math.min(r - 39, o.length - 79);
|
|
2372
|
+
o = "…" + o.substring(a), r -= a - 1;
|
|
2334
2373
|
}
|
|
2335
2374
|
if (o.length > 80 && (o = o.substring(0, 79) + "…"), n > 1 && /^ *$/.test(o.substring(0, r))) {
|
|
2336
|
-
let
|
|
2337
|
-
|
|
2338
|
-
`), o =
|
|
2375
|
+
let a = s.substring(e.lineStarts[n - 2], e.lineStarts[n - 1]);
|
|
2376
|
+
a.length > 80 && (a = a.substring(0, 79) + `…
|
|
2377
|
+
`), o = a + o;
|
|
2339
2378
|
}
|
|
2340
2379
|
if (/[^ ]/.test(o)) {
|
|
2341
|
-
let
|
|
2342
|
-
const
|
|
2343
|
-
|
|
2344
|
-
const c = " ".repeat(r) + "^".repeat(
|
|
2380
|
+
let a = 1;
|
|
2381
|
+
const l = t.linePos[1];
|
|
2382
|
+
l?.line === n && l.col > i && (a = Math.max(1, Math.min(l.col - i, 80 - r)));
|
|
2383
|
+
const c = " ".repeat(r) + "^".repeat(a);
|
|
2345
2384
|
t.message += `:
|
|
2346
2385
|
|
|
2347
2386
|
${o}
|
|
@@ -2349,8 +2388,8 @@ ${c}
|
|
|
2349
2388
|
`;
|
|
2350
2389
|
}
|
|
2351
2390
|
};
|
|
2352
|
-
function re(s, { flow: e, indicator: t, next: n, offset: i, onError: r, parentIndent: o, startOnNewline:
|
|
2353
|
-
let
|
|
2391
|
+
function re(s, { flow: e, indicator: t, next: n, offset: i, onError: r, parentIndent: o, startOnNewline: a }) {
|
|
2392
|
+
let l = !1, c = a, d = a, u = "", f = "", m = !1, g = !1, h = null, p = null, b = null, w = null, k = null, S = null, N = null;
|
|
2354
2393
|
for (const y of s)
|
|
2355
2394
|
switch (g && (y.type !== "space" && y.type !== "newline" && y.type !== "comma" && r(y.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"), g = !1), h && (c && y.type !== "comment" && y.type !== "newline" && r(h, "TAB_AS_INDENT", "Tabs are not allowed as indentation"), h = null), y.type) {
|
|
2356
2395
|
case "space":
|
|
@@ -2359,11 +2398,11 @@ function re(s, { flow: e, indicator: t, next: n, offset: i, onError: r, parentIn
|
|
|
2359
2398
|
case "comment": {
|
|
2360
2399
|
d || r(y, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
|
|
2361
2400
|
const v = y.source.substring(1) || " ";
|
|
2362
|
-
|
|
2401
|
+
u ? u += f + v : u = v, f = "", c = !1;
|
|
2363
2402
|
break;
|
|
2364
2403
|
}
|
|
2365
2404
|
case "newline":
|
|
2366
|
-
c ?
|
|
2405
|
+
c ? u ? u += y.source : (!S || t !== "seq-item-ind") && (l = !0) : f += y.source, c = !0, m = !0, (p || b) && (w = y), d = !0;
|
|
2367
2406
|
break;
|
|
2368
2407
|
case "anchor":
|
|
2369
2408
|
p && r(y, "MULTIPLE_ANCHORS", "A node can have at most one anchor"), y.source.endsWith(":") && r(y.offset + y.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", !0), p = y, N ?? (N = y.offset), c = !1, d = !1, g = !0;
|
|
@@ -2384,18 +2423,18 @@ function re(s, { flow: e, indicator: t, next: n, offset: i, onError: r, parentIn
|
|
|
2384
2423
|
default:
|
|
2385
2424
|
r(y, "UNEXPECTED_TOKEN", `Unexpected ${y.type} token`), c = !1, d = !1;
|
|
2386
2425
|
}
|
|
2387
|
-
const A = s[s.length - 1],
|
|
2426
|
+
const A = s[s.length - 1], E = A ? A.offset + A.source.length : i;
|
|
2388
2427
|
return g && n && n.type !== "space" && n.type !== "newline" && n.type !== "comma" && (n.type !== "scalar" || n.source !== "") && r(n.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"), h && (c && h.indent <= o || n?.type === "block-map" || n?.type === "block-seq") && r(h, "TAB_AS_INDENT", "Tabs are not allowed as indentation"), {
|
|
2389
2428
|
comma: k,
|
|
2390
2429
|
found: S,
|
|
2391
|
-
spaceBefore:
|
|
2392
|
-
comment:
|
|
2430
|
+
spaceBefore: l,
|
|
2431
|
+
comment: u,
|
|
2393
2432
|
hasNewline: m,
|
|
2394
2433
|
anchor: p,
|
|
2395
2434
|
tag: b,
|
|
2396
2435
|
newlineAfterProp: w,
|
|
2397
|
-
end:
|
|
2398
|
-
start: N ??
|
|
2436
|
+
end: E,
|
|
2437
|
+
start: N ?? E
|
|
2399
2438
|
};
|
|
2400
2439
|
}
|
|
2401
2440
|
function ge(s) {
|
|
@@ -2433,140 +2472,140 @@ function ge(s) {
|
|
|
2433
2472
|
return !0;
|
|
2434
2473
|
}
|
|
2435
2474
|
}
|
|
2436
|
-
function
|
|
2475
|
+
function Ze(s, e, t) {
|
|
2437
2476
|
if (e?.type === "flow-collection") {
|
|
2438
2477
|
const n = e.end[0];
|
|
2439
2478
|
n.indent === s && (n.source === "]" || n.source === "}") && ge(e) && t(n, "BAD_INDENT", "Flow end indicator should be more indented than parent", !0);
|
|
2440
2479
|
}
|
|
2441
2480
|
}
|
|
2442
|
-
function
|
|
2481
|
+
function os(s, e, t) {
|
|
2443
2482
|
const { uniqueKeys: n } = s.options;
|
|
2444
2483
|
if (n === !1)
|
|
2445
2484
|
return !1;
|
|
2446
|
-
const i = typeof n == "function" ? n : (r, o) => r === o ||
|
|
2485
|
+
const i = typeof n == "function" ? n : (r, o) => r === o || T(r) && T(o) && r.value === o.value;
|
|
2447
2486
|
return e.some((r) => i(r.key, t));
|
|
2448
2487
|
}
|
|
2449
2488
|
const Tt = "All mapping items must start at the same column";
|
|
2450
|
-
function
|
|
2451
|
-
const o = r?.nodeClass ?? M,
|
|
2489
|
+
function an({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
2490
|
+
const o = r?.nodeClass ?? M, a = new o(t.schema);
|
|
2452
2491
|
t.atRoot && (t.atRoot = !1);
|
|
2453
|
-
let
|
|
2492
|
+
let l = n.offset, c = null;
|
|
2454
2493
|
for (const d of n.items) {
|
|
2455
|
-
const { start:
|
|
2494
|
+
const { start: u, key: f, sep: m, value: g } = d, h = re(u, {
|
|
2456
2495
|
indicator: "explicit-key-ind",
|
|
2457
|
-
next:
|
|
2458
|
-
offset:
|
|
2496
|
+
next: f ?? m?.[0],
|
|
2497
|
+
offset: l,
|
|
2459
2498
|
onError: i,
|
|
2460
2499
|
parentIndent: n.indent,
|
|
2461
2500
|
startOnNewline: !0
|
|
2462
2501
|
}), p = !h.found;
|
|
2463
2502
|
if (p) {
|
|
2464
|
-
if (
|
|
2465
|
-
c = h.end, h.comment && (
|
|
2466
|
-
` + h.comment :
|
|
2503
|
+
if (f && (f.type === "block-seq" ? i(l, "BLOCK_AS_IMPLICIT_KEY", "A block sequence may not be used as an implicit map key") : "indent" in f && f.indent !== n.indent && i(l, "BAD_INDENT", Tt)), !h.anchor && !h.tag && !m) {
|
|
2504
|
+
c = h.end, h.comment && (a.comment ? a.comment += `
|
|
2505
|
+
` + h.comment : a.comment = h.comment);
|
|
2467
2506
|
continue;
|
|
2468
2507
|
}
|
|
2469
|
-
(h.newlineAfterProp || ge(
|
|
2470
|
-
} else h.found?.indent !== n.indent && i(
|
|
2508
|
+
(h.newlineAfterProp || ge(f)) && i(f ?? u[u.length - 1], "MULTILINE_IMPLICIT_KEY", "Implicit keys need to be on a single line");
|
|
2509
|
+
} else h.found?.indent !== n.indent && i(l, "BAD_INDENT", Tt);
|
|
2471
2510
|
t.atKey = !0;
|
|
2472
|
-
const b = h.end, w =
|
|
2473
|
-
t.schema.compat &&
|
|
2511
|
+
const b = h.end, w = f ? s(t, f, h, i) : e(t, b, u, null, h, i);
|
|
2512
|
+
t.schema.compat && Ze(n.indent, f, i), t.atKey = !1, os(t, a.items, w) && i(b, "DUPLICATE_KEY", "Map keys must be unique");
|
|
2474
2513
|
const k = re(m ?? [], {
|
|
2475
2514
|
indicator: "map-value-ind",
|
|
2476
2515
|
next: g,
|
|
2477
2516
|
offset: w.range[2],
|
|
2478
2517
|
onError: i,
|
|
2479
2518
|
parentIndent: n.indent,
|
|
2480
|
-
startOnNewline: !
|
|
2519
|
+
startOnNewline: !f || f.type === "block-scalar"
|
|
2481
2520
|
});
|
|
2482
|
-
if (
|
|
2483
|
-
p && (g?.type === "block-map" && !k.hasNewline && i(
|
|
2484
|
-
const S = g ? s(t, g, k, i) : e(t,
|
|
2485
|
-
t.schema.compat &&
|
|
2521
|
+
if (l = k.end, k.found) {
|
|
2522
|
+
p && (g?.type === "block-map" && !k.hasNewline && i(l, "BLOCK_AS_IMPLICIT_KEY", "Nested mappings are not allowed in compact mappings"), t.options.strict && h.start < k.found.offset - 1024 && i(w.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));
|
|
2523
|
+
const S = g ? s(t, g, k, i) : e(t, l, m, null, k, i);
|
|
2524
|
+
t.schema.compat && Ze(n.indent, g, i), l = S.range[2];
|
|
2486
2525
|
const N = new B(w, S);
|
|
2487
|
-
t.options.keepSourceTokens && (N.srcToken = d),
|
|
2526
|
+
t.options.keepSourceTokens && (N.srcToken = d), a.items.push(N);
|
|
2488
2527
|
} else {
|
|
2489
2528
|
p && i(w.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values"), k.comment && (w.comment ? w.comment += `
|
|
2490
2529
|
` + k.comment : w.comment = k.comment);
|
|
2491
2530
|
const S = new B(w);
|
|
2492
|
-
t.options.keepSourceTokens && (S.srcToken = d),
|
|
2531
|
+
t.options.keepSourceTokens && (S.srcToken = d), a.items.push(S);
|
|
2493
2532
|
}
|
|
2494
2533
|
}
|
|
2495
|
-
return c && c <
|
|
2534
|
+
return c && c < l && i(c, "IMPOSSIBLE", "Map comment with trailing content"), a.range = [n.offset, l, c ?? l], a;
|
|
2496
2535
|
}
|
|
2497
|
-
function
|
|
2498
|
-
const o = r?.nodeClass ?? W,
|
|
2536
|
+
function ln({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
2537
|
+
const o = r?.nodeClass ?? W, a = new o(t.schema);
|
|
2499
2538
|
t.atRoot && (t.atRoot = !1), t.atKey && (t.atKey = !1);
|
|
2500
|
-
let
|
|
2501
|
-
for (const { start: d, value:
|
|
2502
|
-
const
|
|
2539
|
+
let l = n.offset, c = null;
|
|
2540
|
+
for (const { start: d, value: u } of n.items) {
|
|
2541
|
+
const f = re(d, {
|
|
2503
2542
|
indicator: "seq-item-ind",
|
|
2504
|
-
next:
|
|
2505
|
-
offset:
|
|
2543
|
+
next: u,
|
|
2544
|
+
offset: l,
|
|
2506
2545
|
onError: i,
|
|
2507
2546
|
parentIndent: n.indent,
|
|
2508
2547
|
startOnNewline: !0
|
|
2509
2548
|
});
|
|
2510
|
-
if (!
|
|
2511
|
-
if (
|
|
2512
|
-
|
|
2549
|
+
if (!f.found)
|
|
2550
|
+
if (f.anchor || f.tag || u)
|
|
2551
|
+
u?.type === "block-seq" ? i(f.end, "BAD_INDENT", "All sequence items must start at the same column") : i(l, "MISSING_CHAR", "Sequence item without - indicator");
|
|
2513
2552
|
else {
|
|
2514
|
-
c =
|
|
2553
|
+
c = f.end, f.comment && (a.comment = f.comment);
|
|
2515
2554
|
continue;
|
|
2516
2555
|
}
|
|
2517
|
-
const m =
|
|
2518
|
-
t.schema.compat &&
|
|
2556
|
+
const m = u ? s(t, u, f, i) : e(t, f.end, d, null, f, i);
|
|
2557
|
+
t.schema.compat && Ze(n.indent, u, i), l = m.range[2], a.items.push(m);
|
|
2519
2558
|
}
|
|
2520
|
-
return
|
|
2559
|
+
return a.range = [n.offset, l, c ?? l], a;
|
|
2521
2560
|
}
|
|
2522
2561
|
function ke(s, e, t, n) {
|
|
2523
2562
|
let i = "";
|
|
2524
2563
|
if (s) {
|
|
2525
2564
|
let r = !1, o = "";
|
|
2526
|
-
for (const
|
|
2527
|
-
const { source:
|
|
2565
|
+
for (const a of s) {
|
|
2566
|
+
const { source: l, type: c } = a;
|
|
2528
2567
|
switch (c) {
|
|
2529
2568
|
case "space":
|
|
2530
2569
|
r = !0;
|
|
2531
2570
|
break;
|
|
2532
2571
|
case "comment": {
|
|
2533
|
-
t && !r && n(
|
|
2534
|
-
const d =
|
|
2572
|
+
t && !r && n(a, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
|
|
2573
|
+
const d = l.substring(1) || " ";
|
|
2535
2574
|
i ? i += o + d : i = d, o = "";
|
|
2536
2575
|
break;
|
|
2537
2576
|
}
|
|
2538
2577
|
case "newline":
|
|
2539
|
-
i && (o +=
|
|
2578
|
+
i && (o += l), r = !0;
|
|
2540
2579
|
break;
|
|
2541
2580
|
default:
|
|
2542
|
-
n(
|
|
2581
|
+
n(a, "UNEXPECTED_TOKEN", `Unexpected ${c} at node end`);
|
|
2543
2582
|
}
|
|
2544
|
-
e +=
|
|
2583
|
+
e += l.length;
|
|
2545
2584
|
}
|
|
2546
2585
|
}
|
|
2547
2586
|
return { comment: i, offset: e };
|
|
2548
2587
|
}
|
|
2549
|
-
const
|
|
2550
|
-
function
|
|
2551
|
-
const o = n.start.source === "{",
|
|
2588
|
+
const Ye = "Block collections are not allowed within flow collections", Ge = (s) => s && (s.type === "block-map" || s.type === "block-seq");
|
|
2589
|
+
function cn({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
2590
|
+
const o = n.start.source === "{", a = o ? "flow map" : "flow sequence", l = r?.nodeClass ?? (o ? M : W), c = new l(t.schema);
|
|
2552
2591
|
c.flow = !0;
|
|
2553
2592
|
const d = t.atRoot;
|
|
2554
2593
|
d && (t.atRoot = !1), t.atKey && (t.atKey = !1);
|
|
2555
|
-
let
|
|
2594
|
+
let u = n.offset + n.start.source.length;
|
|
2556
2595
|
for (let p = 0; p < n.items.length; ++p) {
|
|
2557
2596
|
const b = n.items[p], { start: w, key: k, sep: S, value: N } = b, A = re(w, {
|
|
2558
|
-
flow:
|
|
2597
|
+
flow: a,
|
|
2559
2598
|
indicator: "explicit-key-ind",
|
|
2560
2599
|
next: k ?? S?.[0],
|
|
2561
|
-
offset:
|
|
2600
|
+
offset: u,
|
|
2562
2601
|
onError: i,
|
|
2563
2602
|
parentIndent: n.indent,
|
|
2564
2603
|
startOnNewline: !1
|
|
2565
2604
|
});
|
|
2566
2605
|
if (!A.found) {
|
|
2567
2606
|
if (!A.anchor && !A.tag && !S && !N) {
|
|
2568
|
-
p === 0 && A.comma ? i(A.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${
|
|
2569
|
-
` + A.comment : c.comment = A.comment),
|
|
2607
|
+
p === 0 && A.comma ? i(A.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${a}`) : p < n.items.length - 1 && i(A.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${a}`), A.comment && (c.comment ? c.comment += `
|
|
2608
|
+
` + A.comment : c.comment = A.comment), u = A.end;
|
|
2570
2609
|
continue;
|
|
2571
2610
|
}
|
|
2572
2611
|
!o && t.options.strict && ge(k) && i(
|
|
@@ -2577,35 +2616,35 @@ function en({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
|
2577
2616
|
);
|
|
2578
2617
|
}
|
|
2579
2618
|
if (p === 0)
|
|
2580
|
-
A.comma && i(A.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${
|
|
2581
|
-
else if (A.comma || i(A.start, "MISSING_CHAR", `Missing , between ${
|
|
2582
|
-
let
|
|
2619
|
+
A.comma && i(A.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${a}`);
|
|
2620
|
+
else if (A.comma || i(A.start, "MISSING_CHAR", `Missing , between ${a} items`), A.comment) {
|
|
2621
|
+
let E = "";
|
|
2583
2622
|
e: for (const y of w)
|
|
2584
2623
|
switch (y.type) {
|
|
2585
2624
|
case "comma":
|
|
2586
2625
|
case "space":
|
|
2587
2626
|
break;
|
|
2588
2627
|
case "comment":
|
|
2589
|
-
|
|
2628
|
+
E = y.source.substring(1);
|
|
2590
2629
|
break e;
|
|
2591
2630
|
default:
|
|
2592
2631
|
break e;
|
|
2593
2632
|
}
|
|
2594
|
-
if (
|
|
2633
|
+
if (E) {
|
|
2595
2634
|
let y = c.items[c.items.length - 1];
|
|
2596
|
-
|
|
2597
|
-
` +
|
|
2635
|
+
L(y) && (y = y.value ?? y.key), y.comment ? y.comment += `
|
|
2636
|
+
` + E : y.comment = E, A.comment = A.comment.substring(E.length + 1);
|
|
2598
2637
|
}
|
|
2599
2638
|
}
|
|
2600
2639
|
if (!o && !S && !A.found) {
|
|
2601
|
-
const
|
|
2602
|
-
c.items.push(
|
|
2640
|
+
const E = N ? s(t, N, A, i) : e(t, A.end, S, null, A, i);
|
|
2641
|
+
c.items.push(E), u = E.range[2], Ge(N) && i(E.range, "BLOCK_IN_FLOW", Ye);
|
|
2603
2642
|
} else {
|
|
2604
2643
|
t.atKey = !0;
|
|
2605
|
-
const
|
|
2606
|
-
|
|
2644
|
+
const E = A.end, y = k ? s(t, k, A, i) : e(t, E, w, null, A, i);
|
|
2645
|
+
Ge(k) && i(y.range, "BLOCK_IN_FLOW", Ye), t.atKey = !1;
|
|
2607
2646
|
const v = re(S ?? [], {
|
|
2608
|
-
flow:
|
|
2647
|
+
flow: a,
|
|
2609
2648
|
indicator: "map-value-ind",
|
|
2610
2649
|
next: N,
|
|
2611
2650
|
offset: y.range[2],
|
|
@@ -2626,30 +2665,30 @@ function en({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
|
2626
2665
|
}
|
|
2627
2666
|
A.start < v.found.offset - 1024 && i(v.found, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit flow sequence key");
|
|
2628
2667
|
}
|
|
2629
|
-
} else N && ("source" in N && N.source?.[0] === ":" ? i(N, "MISSING_CHAR", `Missing space after : in ${
|
|
2668
|
+
} else N && ("source" in N && N.source?.[0] === ":" ? i(N, "MISSING_CHAR", `Missing space after : in ${a}`) : i(v.start, "MISSING_CHAR", `Missing , or : between ${a} items`));
|
|
2630
2669
|
const R = N ? s(t, N, v, i) : v.found ? e(t, v.end, S, null, v, i) : null;
|
|
2631
|
-
R ?
|
|
2670
|
+
R ? Ge(N) && i(R.range, "BLOCK_IN_FLOW", Ye) : v.comment && (y.comment ? y.comment += `
|
|
2632
2671
|
` + v.comment : y.comment = v.comment);
|
|
2633
2672
|
const X = new B(y, R);
|
|
2634
2673
|
if (t.options.keepSourceTokens && (X.srcToken = b), o) {
|
|
2635
2674
|
const C = c;
|
|
2636
|
-
|
|
2675
|
+
os(t, C.items, y) && i(E, "DUPLICATE_KEY", "Map keys must be unique"), C.items.push(X);
|
|
2637
2676
|
} else {
|
|
2638
2677
|
const C = new M(t.schema);
|
|
2639
2678
|
C.flow = !0, C.items.push(X);
|
|
2640
|
-
const
|
|
2641
|
-
C.range = [y.range[0],
|
|
2679
|
+
const bt = (R ?? y).range;
|
|
2680
|
+
C.range = [y.range[0], bt[1], bt[2]], c.items.push(C);
|
|
2642
2681
|
}
|
|
2643
|
-
|
|
2682
|
+
u = R ? R.range[2] : v.end;
|
|
2644
2683
|
}
|
|
2645
2684
|
}
|
|
2646
|
-
const
|
|
2647
|
-
let h =
|
|
2648
|
-
if (m?.source ===
|
|
2685
|
+
const f = o ? "}" : "]", [m, ...g] = n.end;
|
|
2686
|
+
let h = u;
|
|
2687
|
+
if (m?.source === f)
|
|
2649
2688
|
h = m.offset + m.source.length;
|
|
2650
2689
|
else {
|
|
2651
|
-
const p =
|
|
2652
|
-
i(
|
|
2690
|
+
const p = a[0].toUpperCase() + a.substring(1), b = d ? `${p} must end with a ${f}` : `${p} in block collection must be sufficiently indented and end with a ${f}`;
|
|
2691
|
+
i(u, d ? "MISSING_CHAR" : "BAD_INDENT", b), m && m.source.length !== 1 && g.unshift(m);
|
|
2653
2692
|
}
|
|
2654
2693
|
if (g.length > 0) {
|
|
2655
2694
|
const p = ke(g, h, t.options.strict, i);
|
|
@@ -2659,164 +2698,164 @@ function en({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
|
2659
2698
|
c.range = [n.offset, h, h];
|
|
2660
2699
|
return c;
|
|
2661
2700
|
}
|
|
2662
|
-
function
|
|
2663
|
-
const o = t.type === "block-map" ?
|
|
2664
|
-
return i === "!" || i ===
|
|
2701
|
+
function He(s, e, t, n, i, r) {
|
|
2702
|
+
const o = t.type === "block-map" ? an(s, e, t, n, r) : t.type === "block-seq" ? ln(s, e, t, n, r) : cn(s, e, t, n, r), a = o.constructor;
|
|
2703
|
+
return i === "!" || i === a.tagName ? (o.tag = a.tagName, o) : (i && (o.tag = i), o);
|
|
2665
2704
|
}
|
|
2666
|
-
function
|
|
2667
|
-
const r = n.tag, o = r ? e.directives.tagName(r.source, (
|
|
2705
|
+
function fn(s, e, t, n, i) {
|
|
2706
|
+
const r = n.tag, o = r ? e.directives.tagName(r.source, (f) => i(r, "TAG_RESOLVE_FAILED", f)) : null;
|
|
2668
2707
|
if (t.type === "block-seq") {
|
|
2669
|
-
const { anchor:
|
|
2708
|
+
const { anchor: f, newlineAfterProp: m } = n, g = f && r ? f.offset > r.offset ? f : r : f ?? r;
|
|
2670
2709
|
g && (!m || m.offset < g.offset) && i(g, "MISSING_CHAR", "Missing newline after block sequence props");
|
|
2671
2710
|
}
|
|
2672
|
-
const
|
|
2673
|
-
if (!r || !o || o === "!" || o === M.tagName &&
|
|
2674
|
-
return
|
|
2675
|
-
let
|
|
2676
|
-
if (!
|
|
2677
|
-
const
|
|
2678
|
-
if (
|
|
2679
|
-
e.schema.tags.push(Object.assign({},
|
|
2711
|
+
const a = t.type === "block-map" ? "map" : t.type === "block-seq" ? "seq" : t.start.source === "{" ? "map" : "seq";
|
|
2712
|
+
if (!r || !o || o === "!" || o === M.tagName && a === "map" || o === W.tagName && a === "seq")
|
|
2713
|
+
return He(s, e, t, i, o);
|
|
2714
|
+
let l = e.schema.tags.find((f) => f.tag === o && f.collection === a);
|
|
2715
|
+
if (!l) {
|
|
2716
|
+
const f = e.schema.knownTags[o];
|
|
2717
|
+
if (f?.collection === a)
|
|
2718
|
+
e.schema.tags.push(Object.assign({}, f, { default: !1 })), l = f;
|
|
2680
2719
|
else
|
|
2681
|
-
return
|
|
2720
|
+
return f ? i(r, "BAD_COLLECTION_TYPE", `${f.tag} used for ${a} collection, but expects ${f.collection ?? "scalar"}`, !0) : i(r, "TAG_RESOLVE_FAILED", `Unresolved tag: ${o}`, !0), He(s, e, t, i, o);
|
|
2682
2721
|
}
|
|
2683
|
-
const c =
|
|
2684
|
-
return
|
|
2722
|
+
const c = He(s, e, t, i, o, l), d = l.resolve?.(c, (f) => i(r, "TAG_RESOLVE_FAILED", f), e.options) ?? c, u = $(d) ? d : new O(d);
|
|
2723
|
+
return u.range = c.range, u.tag = o, l?.format && (u.format = l.format), u;
|
|
2685
2724
|
}
|
|
2686
|
-
function
|
|
2687
|
-
const n = e.offset, i =
|
|
2725
|
+
function un(s, e, t) {
|
|
2726
|
+
const n = e.offset, i = hn(e, s.options.strict, t);
|
|
2688
2727
|
if (!i)
|
|
2689
2728
|
return { value: "", type: null, comment: "", range: [n, n, n] };
|
|
2690
|
-
const r = i.mode === ">" ? O.BLOCK_FOLDED : O.BLOCK_LITERAL, o = e.source ?
|
|
2691
|
-
let
|
|
2729
|
+
const r = i.mode === ">" ? O.BLOCK_FOLDED : O.BLOCK_LITERAL, o = e.source ? dn(e.source) : [];
|
|
2730
|
+
let a = o.length;
|
|
2692
2731
|
for (let h = o.length - 1; h >= 0; --h) {
|
|
2693
2732
|
const p = o[h][1];
|
|
2694
2733
|
if (p === "" || p === "\r")
|
|
2695
|
-
|
|
2734
|
+
a = h;
|
|
2696
2735
|
else
|
|
2697
2736
|
break;
|
|
2698
2737
|
}
|
|
2699
|
-
if (
|
|
2738
|
+
if (a === 0) {
|
|
2700
2739
|
const h = i.chomp === "+" && o.length > 0 ? `
|
|
2701
2740
|
`.repeat(Math.max(1, o.length - 1)) : "";
|
|
2702
2741
|
let p = n + i.length;
|
|
2703
2742
|
return e.source && (p += e.source.length), { value: h, type: r, comment: i.comment, range: [n, p, p] };
|
|
2704
2743
|
}
|
|
2705
|
-
let
|
|
2706
|
-
for (let h = 0; h <
|
|
2744
|
+
let l = e.indent + i.indent, c = e.offset + i.length, d = 0;
|
|
2745
|
+
for (let h = 0; h < a; ++h) {
|
|
2707
2746
|
const [p, b] = o[h];
|
|
2708
2747
|
if (b === "" || b === "\r")
|
|
2709
|
-
i.indent === 0 && p.length >
|
|
2748
|
+
i.indent === 0 && p.length > l && (l = p.length);
|
|
2710
2749
|
else {
|
|
2711
|
-
p.length <
|
|
2750
|
+
p.length < l && t(c + p.length, "MISSING_CHAR", "Block scalars with more-indented leading empty lines must use an explicit indentation indicator"), i.indent === 0 && (l = p.length), d = h, l === 0 && !s.atRoot && t(c, "BAD_INDENT", "Block scalar values in collections must be indented");
|
|
2712
2751
|
break;
|
|
2713
2752
|
}
|
|
2714
2753
|
c += p.length + b.length + 1;
|
|
2715
2754
|
}
|
|
2716
|
-
for (let h = o.length - 1; h >=
|
|
2717
|
-
o[h][0].length >
|
|
2718
|
-
let
|
|
2755
|
+
for (let h = o.length - 1; h >= a; --h)
|
|
2756
|
+
o[h][0].length > l && (a = h + 1);
|
|
2757
|
+
let u = "", f = "", m = !1;
|
|
2719
2758
|
for (let h = 0; h < d; ++h)
|
|
2720
|
-
|
|
2759
|
+
u += o[h][0].slice(l) + `
|
|
2721
2760
|
`;
|
|
2722
|
-
for (let h = d; h <
|
|
2761
|
+
for (let h = d; h < a; ++h) {
|
|
2723
2762
|
let [p, b] = o[h];
|
|
2724
2763
|
c += p.length + b.length + 1;
|
|
2725
2764
|
const w = b[b.length - 1] === "\r";
|
|
2726
|
-
if (w && (b = b.slice(0, -1)), b && p.length <
|
|
2765
|
+
if (w && (b = b.slice(0, -1)), b && p.length < l) {
|
|
2727
2766
|
const S = `Block scalar lines must not be less indented than their ${i.indent ? "explicit indentation indicator" : "first line"}`;
|
|
2728
2767
|
t(c - b.length - (w ? 2 : 1), "BAD_INDENT", S), p = "";
|
|
2729
2768
|
}
|
|
2730
|
-
r === O.BLOCK_LITERAL ? (
|
|
2731
|
-
`) : p.length >
|
|
2732
|
-
` : !m &&
|
|
2733
|
-
` && (
|
|
2769
|
+
r === O.BLOCK_LITERAL ? (u += f + p.slice(l) + b, f = `
|
|
2770
|
+
`) : p.length > l || b[0] === " " ? (f === " " ? f = `
|
|
2771
|
+
` : !m && f === `
|
|
2772
|
+
` && (f = `
|
|
2734
2773
|
|
|
2735
|
-
`),
|
|
2736
|
-
`, m = !0) : b === "" ?
|
|
2737
|
-
` ?
|
|
2738
|
-
` :
|
|
2739
|
-
` : (
|
|
2774
|
+
`), u += f + p.slice(l) + b, f = `
|
|
2775
|
+
`, m = !0) : b === "" ? f === `
|
|
2776
|
+
` ? u += `
|
|
2777
|
+
` : f = `
|
|
2778
|
+
` : (u += f + b, f = " ", m = !1);
|
|
2740
2779
|
}
|
|
2741
2780
|
switch (i.chomp) {
|
|
2742
2781
|
case "-":
|
|
2743
2782
|
break;
|
|
2744
2783
|
case "+":
|
|
2745
|
-
for (let h =
|
|
2746
|
-
|
|
2747
|
-
` + o[h][0].slice(
|
|
2748
|
-
|
|
2749
|
-
` && (
|
|
2784
|
+
for (let h = a; h < o.length; ++h)
|
|
2785
|
+
u += `
|
|
2786
|
+
` + o[h][0].slice(l);
|
|
2787
|
+
u[u.length - 1] !== `
|
|
2788
|
+
` && (u += `
|
|
2750
2789
|
`);
|
|
2751
2790
|
break;
|
|
2752
2791
|
default:
|
|
2753
|
-
|
|
2792
|
+
u += `
|
|
2754
2793
|
`;
|
|
2755
2794
|
}
|
|
2756
2795
|
const g = n + i.length + e.source.length;
|
|
2757
|
-
return { value:
|
|
2796
|
+
return { value: u, type: r, comment: i.comment, range: [n, g, g] };
|
|
2758
2797
|
}
|
|
2759
|
-
function
|
|
2798
|
+
function hn({ offset: s, props: e }, t, n) {
|
|
2760
2799
|
if (e[0].type !== "block-scalar-header")
|
|
2761
2800
|
return n(e[0], "IMPOSSIBLE", "Block scalar header not found"), null;
|
|
2762
2801
|
const { source: i } = e[0], r = i[0];
|
|
2763
|
-
let o = 0,
|
|
2764
|
-
for (let
|
|
2765
|
-
const m = i[
|
|
2766
|
-
if (!
|
|
2767
|
-
|
|
2802
|
+
let o = 0, a = "", l = -1;
|
|
2803
|
+
for (let f = 1; f < i.length; ++f) {
|
|
2804
|
+
const m = i[f];
|
|
2805
|
+
if (!a && (m === "-" || m === "+"))
|
|
2806
|
+
a = m;
|
|
2768
2807
|
else {
|
|
2769
2808
|
const g = Number(m);
|
|
2770
|
-
!o && g ? o = g :
|
|
2809
|
+
!o && g ? o = g : l === -1 && (l = s + f);
|
|
2771
2810
|
}
|
|
2772
2811
|
}
|
|
2773
|
-
|
|
2774
|
-
let c = !1, d = "",
|
|
2775
|
-
for (let
|
|
2776
|
-
const m = e[
|
|
2812
|
+
l !== -1 && n(l, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${i}`);
|
|
2813
|
+
let c = !1, d = "", u = i.length;
|
|
2814
|
+
for (let f = 1; f < e.length; ++f) {
|
|
2815
|
+
const m = e[f];
|
|
2777
2816
|
switch (m.type) {
|
|
2778
2817
|
case "space":
|
|
2779
2818
|
c = !0;
|
|
2780
2819
|
// fallthrough
|
|
2781
2820
|
case "newline":
|
|
2782
|
-
|
|
2821
|
+
u += m.source.length;
|
|
2783
2822
|
break;
|
|
2784
2823
|
case "comment":
|
|
2785
|
-
t && !c && n(m, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"),
|
|
2824
|
+
t && !c && n(m, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"), u += m.source.length, d = m.source.substring(1);
|
|
2786
2825
|
break;
|
|
2787
2826
|
case "error":
|
|
2788
|
-
n(m, "UNEXPECTED_TOKEN", m.message),
|
|
2827
|
+
n(m, "UNEXPECTED_TOKEN", m.message), u += m.source.length;
|
|
2789
2828
|
break;
|
|
2790
2829
|
/* istanbul ignore next should not happen */
|
|
2791
2830
|
default: {
|
|
2792
2831
|
const g = `Unexpected token in block scalar header: ${m.type}`;
|
|
2793
2832
|
n(m, "UNEXPECTED_TOKEN", g);
|
|
2794
2833
|
const h = m.source;
|
|
2795
|
-
h && typeof h == "string" && (
|
|
2834
|
+
h && typeof h == "string" && (u += h.length);
|
|
2796
2835
|
}
|
|
2797
2836
|
}
|
|
2798
2837
|
}
|
|
2799
|
-
return { mode: r, indent: o, chomp:
|
|
2838
|
+
return { mode: r, indent: o, chomp: a, comment: d, length: u };
|
|
2800
2839
|
}
|
|
2801
|
-
function
|
|
2840
|
+
function dn(s) {
|
|
2802
2841
|
const e = s.split(/\n( *)/), t = e[0], n = t.match(/^( *)/), r = [n?.[1] ? [n[1], t.slice(n[1].length)] : ["", t]];
|
|
2803
2842
|
for (let o = 1; o < e.length; o += 2)
|
|
2804
2843
|
r.push([e[o], e[o + 1]]);
|
|
2805
2844
|
return r;
|
|
2806
2845
|
}
|
|
2807
|
-
function
|
|
2846
|
+
function pn(s, e, t) {
|
|
2808
2847
|
const { offset: n, type: i, source: r, end: o } = s;
|
|
2809
|
-
let
|
|
2810
|
-
const c = (
|
|
2848
|
+
let a, l;
|
|
2849
|
+
const c = (f, m, g) => t(n + f, m, g);
|
|
2811
2850
|
switch (i) {
|
|
2812
2851
|
case "scalar":
|
|
2813
|
-
|
|
2852
|
+
a = O.PLAIN, l = mn(r, c);
|
|
2814
2853
|
break;
|
|
2815
2854
|
case "single-quoted-scalar":
|
|
2816
|
-
|
|
2855
|
+
a = O.QUOTE_SINGLE, l = gn(r, c);
|
|
2817
2856
|
break;
|
|
2818
2857
|
case "double-quoted-scalar":
|
|
2819
|
-
|
|
2858
|
+
a = O.QUOTE_DOUBLE, l = yn(r, c);
|
|
2820
2859
|
break;
|
|
2821
2860
|
/* istanbul ignore next should not happen */
|
|
2822
2861
|
default:
|
|
@@ -2827,15 +2866,15 @@ function on(s, e, t) {
|
|
|
2827
2866
|
range: [n, n + r.length, n + r.length]
|
|
2828
2867
|
};
|
|
2829
2868
|
}
|
|
2830
|
-
const d = n + r.length,
|
|
2869
|
+
const d = n + r.length, u = ke(o, d, e, t);
|
|
2831
2870
|
return {
|
|
2832
|
-
value:
|
|
2833
|
-
type:
|
|
2834
|
-
comment:
|
|
2835
|
-
range: [n, d,
|
|
2871
|
+
value: l,
|
|
2872
|
+
type: a,
|
|
2873
|
+
comment: u.comment,
|
|
2874
|
+
range: [n, d, u.offset]
|
|
2836
2875
|
};
|
|
2837
2876
|
}
|
|
2838
|
-
function
|
|
2877
|
+
function mn(s, e) {
|
|
2839
2878
|
let t = "";
|
|
2840
2879
|
switch (s[0]) {
|
|
2841
2880
|
/* istanbul ignore next should not happen */
|
|
@@ -2859,12 +2898,12 @@ function ln(s, e) {
|
|
|
2859
2898
|
break;
|
|
2860
2899
|
}
|
|
2861
2900
|
}
|
|
2862
|
-
return t && e(0, "BAD_SCALAR_START", `Plain value cannot start with ${t}`),
|
|
2901
|
+
return t && e(0, "BAD_SCALAR_START", `Plain value cannot start with ${t}`), as(s);
|
|
2863
2902
|
}
|
|
2864
|
-
function
|
|
2865
|
-
return (s[s.length - 1] !== "'" || s.length === 1) && e(s.length, "MISSING_CHAR", "Missing closing 'quote"),
|
|
2903
|
+
function gn(s, e) {
|
|
2904
|
+
return (s[s.length - 1] !== "'" || s.length === 1) && e(s.length, "MISSING_CHAR", "Missing closing 'quote"), as(s.slice(1, -1)).replace(/''/g, "'");
|
|
2866
2905
|
}
|
|
2867
|
-
function
|
|
2906
|
+
function as(s) {
|
|
2868
2907
|
let e, t;
|
|
2869
2908
|
try {
|
|
2870
2909
|
e = new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
@@ -2881,10 +2920,10 @@ function os(s) {
|
|
|
2881
2920
|
n[1] === "" ? r === `
|
|
2882
2921
|
` ? i += r : r = `
|
|
2883
2922
|
` : (i += r + n[1], r = " "), o = t.lastIndex;
|
|
2884
|
-
const
|
|
2885
|
-
return
|
|
2923
|
+
const a = /[ \t]*(.*)/sy;
|
|
2924
|
+
return a.lastIndex = o, n = a.exec(s), i + r + (n?.[1] ?? "");
|
|
2886
2925
|
}
|
|
2887
|
-
function
|
|
2926
|
+
function yn(s, e) {
|
|
2888
2927
|
let t = "";
|
|
2889
2928
|
for (let n = 1; n < s.length - 1; ++n) {
|
|
2890
2929
|
const i = s[n];
|
|
@@ -2892,11 +2931,11 @@ function cn(s, e) {
|
|
|
2892
2931
|
`))
|
|
2893
2932
|
if (i === `
|
|
2894
2933
|
`) {
|
|
2895
|
-
const { fold: r, offset: o } =
|
|
2934
|
+
const { fold: r, offset: o } = bn(s, n);
|
|
2896
2935
|
t += r, n = o;
|
|
2897
2936
|
} else if (i === "\\") {
|
|
2898
2937
|
let r = s[++n];
|
|
2899
|
-
const o =
|
|
2938
|
+
const o = wn[r];
|
|
2900
2939
|
if (o)
|
|
2901
2940
|
t += o;
|
|
2902
2941
|
else if (r === `
|
|
@@ -2908,11 +2947,11 @@ function cn(s, e) {
|
|
|
2908
2947
|
for (r = s[++n + 1]; r === " " || r === " "; )
|
|
2909
2948
|
r = s[++n + 1];
|
|
2910
2949
|
else if (r === "x" || r === "u" || r === "U") {
|
|
2911
|
-
const
|
|
2912
|
-
t +=
|
|
2950
|
+
const a = { x: 2, u: 4, U: 8 }[r];
|
|
2951
|
+
t += kn(s, n + 1, a, e), n += a;
|
|
2913
2952
|
} else {
|
|
2914
|
-
const
|
|
2915
|
-
e(n - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${
|
|
2953
|
+
const a = s.substr(n - 1, 2);
|
|
2954
|
+
e(n - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${a}`), t += a;
|
|
2916
2955
|
}
|
|
2917
2956
|
} else if (i === " " || i === " ") {
|
|
2918
2957
|
const r = n;
|
|
@@ -2927,7 +2966,7 @@ function cn(s, e) {
|
|
|
2927
2966
|
}
|
|
2928
2967
|
return (s[s.length - 1] !== '"' || s.length === 1) && e(s.length, "MISSING_CHAR", 'Missing closing "quote'), t;
|
|
2929
2968
|
}
|
|
2930
|
-
function
|
|
2969
|
+
function bn(s, e) {
|
|
2931
2970
|
let t = "", n = s[e + 1];
|
|
2932
2971
|
for (; (n === " " || n === " " || n === `
|
|
2933
2972
|
` || n === "\r") && !(n === "\r" && s[e + 2] !== `
|
|
@@ -2937,7 +2976,7 @@ function fn(s, e) {
|
|
|
2937
2976
|
`), e += 1, n = s[e + 1];
|
|
2938
2977
|
return t || (t = " "), { fold: t, offset: e };
|
|
2939
2978
|
}
|
|
2940
|
-
const
|
|
2979
|
+
const wn = {
|
|
2941
2980
|
0: "\0",
|
|
2942
2981
|
// null character
|
|
2943
2982
|
a: "\x07",
|
|
@@ -2971,56 +3010,56 @@ const un = {
|
|
|
2971
3010
|
"\\": "\\",
|
|
2972
3011
|
" ": " "
|
|
2973
3012
|
};
|
|
2974
|
-
function
|
|
3013
|
+
function kn(s, e, t, n) {
|
|
2975
3014
|
const i = s.substr(e, t), o = i.length === t && /^[0-9a-fA-F]+$/.test(i) ? parseInt(i, 16) : NaN;
|
|
2976
3015
|
if (isNaN(o)) {
|
|
2977
|
-
const
|
|
2978
|
-
return n(e - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${
|
|
3016
|
+
const a = s.substr(e - 2, t + 2);
|
|
3017
|
+
return n(e - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${a}`), a;
|
|
2979
3018
|
}
|
|
2980
3019
|
return String.fromCodePoint(o);
|
|
2981
3020
|
}
|
|
2982
3021
|
function ls(s, e, t, n) {
|
|
2983
|
-
const { value: i, type: r, comment: o, range:
|
|
3022
|
+
const { value: i, type: r, comment: o, range: a } = e.type === "block-scalar" ? un(s, e, n) : pn(e, s.options.strict, n), l = t ? s.directives.tagName(t.source, (u) => n(t, "TAG_RESOLVE_FAILED", u)) : null;
|
|
2984
3023
|
let c;
|
|
2985
|
-
s.options.stringKeys && s.atKey ? c = s.schema[q] :
|
|
3024
|
+
s.options.stringKeys && s.atKey ? c = s.schema[q] : l ? c = Sn(s.schema, i, l, t, n) : e.type === "scalar" ? c = Nn(s, i, e, n) : c = s.schema[q];
|
|
2986
3025
|
let d;
|
|
2987
3026
|
try {
|
|
2988
|
-
const
|
|
2989
|
-
d =
|
|
2990
|
-
} catch (
|
|
2991
|
-
const
|
|
2992
|
-
n(t ?? e, "TAG_RESOLVE_FAILED",
|
|
3027
|
+
const u = c.resolve(i, (f) => n(t ?? e, "TAG_RESOLVE_FAILED", f), s.options);
|
|
3028
|
+
d = T(u) ? u : new O(u);
|
|
3029
|
+
} catch (u) {
|
|
3030
|
+
const f = u instanceof Error ? u.message : String(u);
|
|
3031
|
+
n(t ?? e, "TAG_RESOLVE_FAILED", f), d = new O(i);
|
|
2993
3032
|
}
|
|
2994
|
-
return d.range =
|
|
3033
|
+
return d.range = a, d.source = i, r && (d.type = r), l && (d.tag = l), c.format && (d.format = c.format), o && (d.comment = o), d;
|
|
2995
3034
|
}
|
|
2996
|
-
function
|
|
3035
|
+
function Sn(s, e, t, n, i) {
|
|
2997
3036
|
if (t === "!")
|
|
2998
3037
|
return s[q];
|
|
2999
3038
|
const r = [];
|
|
3000
|
-
for (const
|
|
3001
|
-
if (!
|
|
3002
|
-
if (
|
|
3003
|
-
r.push(
|
|
3039
|
+
for (const a of s.tags)
|
|
3040
|
+
if (!a.collection && a.tag === t)
|
|
3041
|
+
if (a.default && a.test)
|
|
3042
|
+
r.push(a);
|
|
3004
3043
|
else
|
|
3005
|
-
return
|
|
3006
|
-
for (const
|
|
3007
|
-
if (
|
|
3008
|
-
return
|
|
3044
|
+
return a;
|
|
3045
|
+
for (const a of r)
|
|
3046
|
+
if (a.test?.test(e))
|
|
3047
|
+
return a;
|
|
3009
3048
|
const o = s.knownTags[t];
|
|
3010
3049
|
return o && !o.collection ? (s.tags.push(Object.assign({}, o, { default: !1, test: void 0 })), o) : (i(n, "TAG_RESOLVE_FAILED", `Unresolved tag: ${t}`, t !== "tag:yaml.org,2002:str"), s[q]);
|
|
3011
3050
|
}
|
|
3012
|
-
function
|
|
3013
|
-
const o = t.tags.find((
|
|
3051
|
+
function Nn({ atKey: s, directives: e, schema: t }, n, i, r) {
|
|
3052
|
+
const o = t.tags.find((a) => (a.default === !0 || s && a.default === "key") && a.test?.test(n)) || t[q];
|
|
3014
3053
|
if (t.compat) {
|
|
3015
|
-
const
|
|
3016
|
-
if (o.tag !==
|
|
3017
|
-
const
|
|
3054
|
+
const a = t.compat.find((l) => l.default && l.test?.test(n)) ?? t[q];
|
|
3055
|
+
if (o.tag !== a.tag) {
|
|
3056
|
+
const l = e.tagString(o.tag), c = e.tagString(a.tag), d = `Value may be parsed as either ${l} or ${c}`;
|
|
3018
3057
|
r(i, "TAG_RESOLVE_FAILED", d, !0);
|
|
3019
3058
|
}
|
|
3020
3059
|
}
|
|
3021
3060
|
return o;
|
|
3022
3061
|
}
|
|
3023
|
-
function
|
|
3062
|
+
function On(s, e, t) {
|
|
3024
3063
|
if (e) {
|
|
3025
3064
|
t ?? (t = e.length);
|
|
3026
3065
|
for (let n = t - 1; n >= 0; --n) {
|
|
@@ -3039,54 +3078,54 @@ function mn(s, e, t) {
|
|
|
3039
3078
|
}
|
|
3040
3079
|
return s;
|
|
3041
3080
|
}
|
|
3042
|
-
const
|
|
3043
|
-
function
|
|
3044
|
-
const i = s.atKey, { spaceBefore: r, comment: o, anchor:
|
|
3081
|
+
const An = { composeNode: cs, composeEmptyNode: yt };
|
|
3082
|
+
function cs(s, e, t, n) {
|
|
3083
|
+
const i = s.atKey, { spaceBefore: r, comment: o, anchor: a, tag: l } = t;
|
|
3045
3084
|
let c, d = !0;
|
|
3046
3085
|
switch (e.type) {
|
|
3047
3086
|
case "alias":
|
|
3048
|
-
c =
|
|
3087
|
+
c = En(s, e, n), (a || l) && n(e, "ALIAS_PROPS", "An alias node must not specify any properties");
|
|
3049
3088
|
break;
|
|
3050
3089
|
case "scalar":
|
|
3051
3090
|
case "single-quoted-scalar":
|
|
3052
3091
|
case "double-quoted-scalar":
|
|
3053
3092
|
case "block-scalar":
|
|
3054
|
-
c = ls(s, e,
|
|
3093
|
+
c = ls(s, e, l, n), a && (c.anchor = a.source.substring(1));
|
|
3055
3094
|
break;
|
|
3056
3095
|
case "block-map":
|
|
3057
3096
|
case "block-seq":
|
|
3058
3097
|
case "flow-collection":
|
|
3059
|
-
c =
|
|
3098
|
+
c = fn(An, s, e, t, n), a && (c.anchor = a.source.substring(1));
|
|
3060
3099
|
break;
|
|
3061
3100
|
default: {
|
|
3062
|
-
const
|
|
3063
|
-
n(e, "UNEXPECTED_TOKEN",
|
|
3101
|
+
const u = e.type === "error" ? e.message : `Unsupported token (type: ${e.type})`;
|
|
3102
|
+
n(e, "UNEXPECTED_TOKEN", u), c = yt(s, e.offset, void 0, null, t, n), d = !1;
|
|
3064
3103
|
}
|
|
3065
3104
|
}
|
|
3066
|
-
return
|
|
3105
|
+
return a && c.anchor === "" && n(a, "BAD_ALIAS", "Anchor cannot be an empty string"), i && s.options.stringKeys && (!T(c) || typeof c.value != "string" || c.tag && c.tag !== "tag:yaml.org,2002:str") && n(l ?? e, "NON_STRING_KEY", "With stringKeys, all keys must be strings"), r && (c.spaceBefore = !0), o && (e.type === "scalar" && e.source === "" ? c.comment = o : c.commentBefore = o), s.options.keepSourceTokens && d && (c.srcToken = e), c;
|
|
3067
3106
|
}
|
|
3068
|
-
function
|
|
3107
|
+
function yt(s, e, t, n, { spaceBefore: i, comment: r, anchor: o, tag: a, end: l }, c) {
|
|
3069
3108
|
const d = {
|
|
3070
3109
|
type: "scalar",
|
|
3071
|
-
offset:
|
|
3110
|
+
offset: On(e, t, n),
|
|
3072
3111
|
indent: -1,
|
|
3073
3112
|
source: ""
|
|
3074
|
-
},
|
|
3075
|
-
return o && (
|
|
3113
|
+
}, u = ls(s, d, a, c);
|
|
3114
|
+
return o && (u.anchor = o.source.substring(1), u.anchor === "" && c(o, "BAD_ALIAS", "Anchor cannot be an empty string")), i && (u.spaceBefore = !0), r && (u.comment = r, u.range[2] = l), u;
|
|
3076
3115
|
}
|
|
3077
|
-
function
|
|
3078
|
-
const r = new
|
|
3116
|
+
function En({ options: s }, { offset: e, source: t, end: n }, i) {
|
|
3117
|
+
const r = new rt(t.substring(1));
|
|
3079
3118
|
r.source === "" && i(e, "BAD_ALIAS", "Alias cannot be an empty string"), r.source.endsWith(":") && i(e + t.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", !0);
|
|
3080
|
-
const o = e + t.length,
|
|
3081
|
-
return r.range = [e, o,
|
|
3119
|
+
const o = e + t.length, a = ke(n, o, s.strict, i);
|
|
3120
|
+
return r.range = [e, o, a.offset], a.comment && (r.comment = a.comment), r;
|
|
3082
3121
|
}
|
|
3083
|
-
function
|
|
3084
|
-
const
|
|
3122
|
+
function Tn(s, e, { offset: t, start: n, value: i, end: r }, o) {
|
|
3123
|
+
const a = Object.assign({ _directives: e }, s), l = new Ue(void 0, a), c = {
|
|
3085
3124
|
atKey: !1,
|
|
3086
3125
|
atRoot: !0,
|
|
3087
|
-
directives:
|
|
3088
|
-
options:
|
|
3089
|
-
schema:
|
|
3126
|
+
directives: l.directives,
|
|
3127
|
+
options: l.options,
|
|
3128
|
+
schema: l.schema
|
|
3090
3129
|
}, d = re(n, {
|
|
3091
3130
|
indicator: "doc-start",
|
|
3092
3131
|
next: i ?? r?.[0],
|
|
@@ -3095,9 +3134,9 @@ function bn(s, e, { offset: t, start: n, value: i, end: r }, o) {
|
|
|
3095
3134
|
parentIndent: 0,
|
|
3096
3135
|
startOnNewline: !0
|
|
3097
3136
|
});
|
|
3098
|
-
d.found && (
|
|
3099
|
-
const
|
|
3100
|
-
return
|
|
3137
|
+
d.found && (l.directives.docStart = !0, i && (i.type === "block-map" || i.type === "block-seq") && !d.hasNewline && o(d.end, "MISSING_CHAR", "Block collection cannot start on same line with directives-end marker")), l.contents = i ? cs(c, i, d, o) : yt(c, d.end, n, null, d, o);
|
|
3138
|
+
const u = l.contents.range[2], f = ke(r, u, !1, o);
|
|
3139
|
+
return f.comment && (l.comment = f.comment), l.range = [t, u, f.offset], l;
|
|
3101
3140
|
}
|
|
3102
3141
|
function fe(s) {
|
|
3103
3142
|
if (typeof s == "number")
|
|
@@ -3107,7 +3146,7 @@ function fe(s) {
|
|
|
3107
3146
|
const { offset: e, source: t } = s;
|
|
3108
3147
|
return [e, e + (typeof t == "string" ? t.length : 1)];
|
|
3109
3148
|
}
|
|
3110
|
-
function
|
|
3149
|
+
function It(s) {
|
|
3111
3150
|
let e = "", t = !1, n = !1;
|
|
3112
3151
|
for (let i = 0; i < s.length; ++i) {
|
|
3113
3152
|
const r = s[i];
|
|
@@ -3127,15 +3166,15 @@ function Et(s) {
|
|
|
3127
3166
|
}
|
|
3128
3167
|
return { comment: e, afterEmptyLine: n };
|
|
3129
3168
|
}
|
|
3130
|
-
class
|
|
3169
|
+
class In {
|
|
3131
3170
|
constructor(e = {}) {
|
|
3132
3171
|
this.doc = null, this.atDirectives = !1, this.prelude = [], this.errors = [], this.warnings = [], this.onError = (t, n, i, r) => {
|
|
3133
3172
|
const o = fe(t);
|
|
3134
|
-
r ? this.warnings.push(new
|
|
3173
|
+
r ? this.warnings.push(new on(o, n, i)) : this.errors.push(new he(o, n, i));
|
|
3135
3174
|
}, this.directives = new _({ version: e.version || "1.2" }), this.options = e;
|
|
3136
3175
|
}
|
|
3137
3176
|
decorate(e, t) {
|
|
3138
|
-
const { comment: n, afterEmptyLine: i } =
|
|
3177
|
+
const { comment: n, afterEmptyLine: i } = It(this.prelude);
|
|
3139
3178
|
if (n) {
|
|
3140
3179
|
const r = e.contents;
|
|
3141
3180
|
if (t)
|
|
@@ -3145,10 +3184,10 @@ ${n}` : n;
|
|
|
3145
3184
|
e.commentBefore = n;
|
|
3146
3185
|
else if (I(r) && !r.flow && r.items.length > 0) {
|
|
3147
3186
|
let o = r.items[0];
|
|
3148
|
-
|
|
3149
|
-
const
|
|
3150
|
-
o.commentBefore =
|
|
3151
|
-
${
|
|
3187
|
+
L(o) && (o = o.key);
|
|
3188
|
+
const a = o.commentBefore;
|
|
3189
|
+
o.commentBefore = a ? `${n}
|
|
3190
|
+
${a}` : n;
|
|
3152
3191
|
} else {
|
|
3153
3192
|
const o = r.commentBefore;
|
|
3154
3193
|
r.commentBefore = o ? `${n}
|
|
@@ -3164,7 +3203,7 @@ ${o}` : n;
|
|
|
3164
3203
|
*/
|
|
3165
3204
|
streamInfo() {
|
|
3166
3205
|
return {
|
|
3167
|
-
comment:
|
|
3206
|
+
comment: It(this.prelude).comment,
|
|
3168
3207
|
directives: this.directives,
|
|
3169
3208
|
errors: this.errors,
|
|
3170
3209
|
warnings: this.warnings
|
|
@@ -3191,7 +3230,7 @@ ${o}` : n;
|
|
|
3191
3230
|
}), this.prelude.push(e.source), this.atDirectives = !0;
|
|
3192
3231
|
break;
|
|
3193
3232
|
case "document": {
|
|
3194
|
-
const t =
|
|
3233
|
+
const t = Tn(this.options, this.directives, e, this.onError);
|
|
3195
3234
|
this.atDirectives && !t.directives.docStart && this.onError(e, "MISSING_CHAR", "Missing directives-end/doc-start indicator line"), this.decorate(t, !1), this.doc && (yield this.doc), this.doc = t, this.atDirectives = !1;
|
|
3196
3235
|
break;
|
|
3197
3236
|
}
|
|
@@ -3242,16 +3281,16 @@ ${t.comment}` : t.comment;
|
|
|
3242
3281
|
}
|
|
3243
3282
|
}
|
|
3244
3283
|
}
|
|
3245
|
-
const
|
|
3246
|
-
function
|
|
3284
|
+
const fs = "\uFEFF", us = "", hs = "", et = "";
|
|
3285
|
+
function $n(s) {
|
|
3247
3286
|
switch (s) {
|
|
3248
|
-
case cs:
|
|
3249
|
-
return "byte-order-mark";
|
|
3250
3287
|
case fs:
|
|
3251
|
-
return "
|
|
3288
|
+
return "byte-order-mark";
|
|
3252
3289
|
case us:
|
|
3290
|
+
return "doc-mode";
|
|
3291
|
+
case hs:
|
|
3253
3292
|
return "flow-error-end";
|
|
3254
|
-
case
|
|
3293
|
+
case et:
|
|
3255
3294
|
return "scalar";
|
|
3256
3295
|
case "---":
|
|
3257
3296
|
return "doc-start";
|
|
@@ -3317,9 +3356,9 @@ function K(s) {
|
|
|
3317
3356
|
return !1;
|
|
3318
3357
|
}
|
|
3319
3358
|
}
|
|
3320
|
-
const
|
|
3321
|
-
\r `),
|
|
3322
|
-
class
|
|
3359
|
+
const $t = new Set("0123456789ABCDEFabcdef"), Ln = new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"), Ae = new Set(",[]{}"), vn = new Set(` ,[]{}
|
|
3360
|
+
\r `), We = (s) => !s || vn.has(s);
|
|
3361
|
+
class Cn {
|
|
3323
3362
|
constructor() {
|
|
3324
3363
|
this.atEnd = !1, this.blockScalarIndent = -1, this.blockScalarKeep = !1, this.buffer = "", this.flowKey = !1, this.flowLevel = 0, this.indentNext = 0, this.indentValue = 0, this.lineEndPos = null, this.next = null, this.pos = 0;
|
|
3325
3364
|
}
|
|
@@ -3411,7 +3450,7 @@ class On {
|
|
|
3411
3450
|
let e = this.getLine();
|
|
3412
3451
|
if (e === null)
|
|
3413
3452
|
return this.setNext("stream");
|
|
3414
|
-
if (e[0] ===
|
|
3453
|
+
if (e[0] === fs && (yield* this.pushCount(1), e = e.substring(1)), e[0] === "%") {
|
|
3415
3454
|
let t = e.length, n = e.indexOf("#");
|
|
3416
3455
|
for (; n !== -1; ) {
|
|
3417
3456
|
const r = e[n - 1];
|
|
@@ -3435,7 +3474,7 @@ class On {
|
|
|
3435
3474
|
const t = yield* this.pushSpaces(!0);
|
|
3436
3475
|
return yield* this.pushCount(e.length - t), yield* this.pushNewline(), "stream";
|
|
3437
3476
|
}
|
|
3438
|
-
return yield
|
|
3477
|
+
return yield us, yield* this.parseLineStart();
|
|
3439
3478
|
}
|
|
3440
3479
|
*parseLineStart() {
|
|
3441
3480
|
const e = this.charAt(0);
|
|
@@ -3479,7 +3518,7 @@ class On {
|
|
|
3479
3518
|
case "]":
|
|
3480
3519
|
return yield* this.pushCount(1), "doc";
|
|
3481
3520
|
case "*":
|
|
3482
|
-
return yield* this.pushUntil(
|
|
3521
|
+
return yield* this.pushUntil(We), "doc";
|
|
3483
3522
|
case '"':
|
|
3484
3523
|
case "'":
|
|
3485
3524
|
return yield* this.parseQuotedScalar();
|
|
@@ -3499,7 +3538,7 @@ class On {
|
|
|
3499
3538
|
if (i === null)
|
|
3500
3539
|
return this.setNext("flow");
|
|
3501
3540
|
if ((n !== -1 && n < this.indentNext && i[0] !== "#" || n === 0 && (i.startsWith("---") || i.startsWith("...")) && K(i[3])) && !(n === this.indentNext - 1 && this.flowLevel === 1 && (i[0] === "]" || i[0] === "}")))
|
|
3502
|
-
return this.flowLevel = 0, yield
|
|
3541
|
+
return this.flowLevel = 0, yield hs, yield* this.parseLineStart();
|
|
3503
3542
|
let r = 0;
|
|
3504
3543
|
for (; i[r] === ","; )
|
|
3505
3544
|
r += yield* this.pushCount(1), r += yield* this.pushSpaces(!0), this.flowKey = !1;
|
|
@@ -3515,7 +3554,7 @@ class On {
|
|
|
3515
3554
|
case "]":
|
|
3516
3555
|
return yield* this.pushCount(1), this.flowKey = !0, this.flowLevel -= 1, this.flowLevel ? "flow" : "doc";
|
|
3517
3556
|
case "*":
|
|
3518
|
-
return yield* this.pushUntil(
|
|
3557
|
+
return yield* this.pushUntil(We), "flow";
|
|
3519
3558
|
case '"':
|
|
3520
3559
|
case "'":
|
|
3521
3560
|
return this.flowKey = !0, yield* this.parseQuotedScalar();
|
|
@@ -3630,16 +3669,16 @@ class On {
|
|
|
3630
3669
|
do {
|
|
3631
3670
|
let r = e - 1, o = this.buffer[r];
|
|
3632
3671
|
o === "\r" && (o = this.buffer[--r]);
|
|
3633
|
-
const
|
|
3672
|
+
const a = r;
|
|
3634
3673
|
for (; o === " "; )
|
|
3635
3674
|
o = this.buffer[--r];
|
|
3636
3675
|
if (o === `
|
|
3637
|
-
` && r >= this.pos && r + 1 + t >
|
|
3676
|
+
` && r >= this.pos && r + 1 + t > a)
|
|
3638
3677
|
e = r;
|
|
3639
3678
|
else
|
|
3640
3679
|
break;
|
|
3641
3680
|
} while (!0);
|
|
3642
|
-
return yield
|
|
3681
|
+
return yield et, yield* this.pushToIndex(e + 1, !0), yield* this.parseLineStart();
|
|
3643
3682
|
}
|
|
3644
3683
|
*parsePlainScalar() {
|
|
3645
3684
|
const e = this.flowLevel > 0;
|
|
@@ -3668,7 +3707,7 @@ class On {
|
|
|
3668
3707
|
break;
|
|
3669
3708
|
t = n;
|
|
3670
3709
|
}
|
|
3671
|
-
return !i && !this.atEnd ? this.setNext("plain-scalar") : (yield
|
|
3710
|
+
return !i && !this.atEnd ? this.setNext("plain-scalar") : (yield et, yield* this.pushToIndex(t + 1, !0), e ? "flow" : "doc");
|
|
3672
3711
|
}
|
|
3673
3712
|
*pushCount(e) {
|
|
3674
3713
|
return e > 0 ? (yield this.buffer.substr(this.pos, e), this.pos += e, e) : 0;
|
|
@@ -3682,7 +3721,7 @@ class On {
|
|
|
3682
3721
|
case "!":
|
|
3683
3722
|
return (yield* this.pushTag()) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators());
|
|
3684
3723
|
case "&":
|
|
3685
|
-
return (yield* this.pushUntil(
|
|
3724
|
+
return (yield* this.pushUntil(We)) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators());
|
|
3686
3725
|
case "-":
|
|
3687
3726
|
// this is an error
|
|
3688
3727
|
case "?":
|
|
@@ -3704,9 +3743,9 @@ class On {
|
|
|
3704
3743
|
} else {
|
|
3705
3744
|
let e = this.pos + 1, t = this.buffer[e];
|
|
3706
3745
|
for (; t; )
|
|
3707
|
-
if (
|
|
3746
|
+
if (Ln.has(t))
|
|
3708
3747
|
t = this.buffer[++e];
|
|
3709
|
-
else if (t === "%" &&
|
|
3748
|
+
else if (t === "%" && $t.has(this.buffer[e + 1]) && $t.has(this.buffer[e + 2]))
|
|
3710
3749
|
t = this.buffer[e += 3];
|
|
3711
3750
|
else
|
|
3712
3751
|
break;
|
|
@@ -3734,7 +3773,7 @@ class On {
|
|
|
3734
3773
|
return yield* this.pushToIndex(t, !1);
|
|
3735
3774
|
}
|
|
3736
3775
|
}
|
|
3737
|
-
class
|
|
3776
|
+
class _n {
|
|
3738
3777
|
constructor() {
|
|
3739
3778
|
this.lineStarts = [], this.addNewLine = (e) => this.lineStarts.push(e), this.linePos = (e) => {
|
|
3740
3779
|
let t = 0, n = this.lineStarts.length;
|
|
@@ -3769,7 +3808,7 @@ function Lt(s) {
|
|
|
3769
3808
|
}
|
|
3770
3809
|
return -1;
|
|
3771
3810
|
}
|
|
3772
|
-
function
|
|
3811
|
+
function ds(s) {
|
|
3773
3812
|
switch (s?.type) {
|
|
3774
3813
|
case "alias":
|
|
3775
3814
|
case "scalar":
|
|
@@ -3781,7 +3820,7 @@ function hs(s) {
|
|
|
3781
3820
|
return !1;
|
|
3782
3821
|
}
|
|
3783
3822
|
}
|
|
3784
|
-
function
|
|
3823
|
+
function Ee(s) {
|
|
3785
3824
|
switch (s.type) {
|
|
3786
3825
|
case "document":
|
|
3787
3826
|
return s.start;
|
|
@@ -3813,18 +3852,18 @@ function z(s) {
|
|
|
3813
3852
|
;
|
|
3814
3853
|
return s.splice(e, s.length);
|
|
3815
3854
|
}
|
|
3816
|
-
function
|
|
3855
|
+
function vt(s) {
|
|
3817
3856
|
if (s.start.type === "flow-seq-start")
|
|
3818
3857
|
for (const e of s.items)
|
|
3819
|
-
e.sep && !e.value && !V(e.start, "explicit-key-ind") && !V(e.sep, "map-value-ind") && (e.key && (e.value = e.key), delete e.key,
|
|
3858
|
+
e.sep && !e.value && !V(e.start, "explicit-key-ind") && !V(e.sep, "map-value-ind") && (e.key && (e.value = e.key), delete e.key, ds(e.value) ? e.value.end ? Array.prototype.push.apply(e.value.end, e.sep) : e.value.end = e.sep : Array.prototype.push.apply(e.start, e.sep), delete e.sep);
|
|
3820
3859
|
}
|
|
3821
|
-
class
|
|
3860
|
+
class Bn {
|
|
3822
3861
|
/**
|
|
3823
3862
|
* @param onNewLine - If defined, called separately with the start position of
|
|
3824
3863
|
* each new line (in `parse()`, including the start of input).
|
|
3825
3864
|
*/
|
|
3826
3865
|
constructor(e) {
|
|
3827
|
-
this.atNewLine = !0, this.atScalar = !1, this.indent = 0, this.offset = 0, this.onKeyLine = !1, this.stack = [], this.source = "", this.type = "", this.lexer = new
|
|
3866
|
+
this.atNewLine = !0, this.atScalar = !1, this.indent = 0, this.offset = 0, this.onKeyLine = !1, this.stack = [], this.source = "", this.type = "", this.lexer = new Cn(), this.onNewLine = e;
|
|
3828
3867
|
}
|
|
3829
3868
|
/**
|
|
3830
3869
|
* Parse `source` as a YAML stream.
|
|
@@ -3848,7 +3887,7 @@ class Tn {
|
|
|
3848
3887
|
this.atScalar = !1, yield* this.step(), this.offset += e.length;
|
|
3849
3888
|
return;
|
|
3850
3889
|
}
|
|
3851
|
-
const t =
|
|
3890
|
+
const t = $n(e);
|
|
3852
3891
|
if (t)
|
|
3853
3892
|
if (t === "scalar")
|
|
3854
3893
|
this.atNewLine = !1, this.atScalar = !0, this.type = "scalar";
|
|
@@ -3937,7 +3976,7 @@ class Tn {
|
|
|
3937
3976
|
yield t;
|
|
3938
3977
|
else {
|
|
3939
3978
|
const n = this.peek(1);
|
|
3940
|
-
switch (t.type === "block-scalar" ? t.indent = "indent" in n ? n.indent : 0 : t.type === "flow-collection" && n.type === "document" && (t.indent = 0), t.type === "flow-collection" &&
|
|
3979
|
+
switch (t.type === "block-scalar" ? t.indent = "indent" in n ? n.indent : 0 : t.type === "flow-collection" && n.type === "document" && (t.indent = 0), t.type === "flow-collection" && vt(t), n.type) {
|
|
3941
3980
|
case "document":
|
|
3942
3981
|
n.value = t;
|
|
3943
3982
|
break;
|
|
@@ -4032,7 +4071,7 @@ class Tn {
|
|
|
4032
4071
|
}
|
|
4033
4072
|
*scalar(e) {
|
|
4034
4073
|
if (this.type === "map-value-ind") {
|
|
4035
|
-
const t =
|
|
4074
|
+
const t = Ee(this.peek(2)), n = z(t);
|
|
4036
4075
|
let i;
|
|
4037
4076
|
e.end ? (i = e.end, i.push(this.sourceToken), delete e.end) : i = [this.sourceToken];
|
|
4038
4077
|
const r = {
|
|
@@ -4099,16 +4138,16 @@ class Tn {
|
|
|
4099
4138
|
let r = [];
|
|
4100
4139
|
if (i && t.sep && !t.value) {
|
|
4101
4140
|
const o = [];
|
|
4102
|
-
for (let
|
|
4103
|
-
const
|
|
4104
|
-
switch (
|
|
4141
|
+
for (let a = 0; a < t.sep.length; ++a) {
|
|
4142
|
+
const l = t.sep[a];
|
|
4143
|
+
switch (l.type) {
|
|
4105
4144
|
case "newline":
|
|
4106
|
-
o.push(
|
|
4145
|
+
o.push(a);
|
|
4107
4146
|
break;
|
|
4108
4147
|
case "space":
|
|
4109
4148
|
break;
|
|
4110
4149
|
case "comment":
|
|
4111
|
-
|
|
4150
|
+
l.indent > e.indent && (o.length = 0);
|
|
4112
4151
|
break;
|
|
4113
4152
|
default:
|
|
4114
4153
|
o.length = 0;
|
|
@@ -4141,13 +4180,13 @@ class Tn {
|
|
|
4141
4180
|
indent: this.indent,
|
|
4142
4181
|
items: [{ start: r, key: null, sep: [this.sourceToken] }]
|
|
4143
4182
|
});
|
|
4144
|
-
else if (
|
|
4145
|
-
const o = z(t.start),
|
|
4146
|
-
|
|
4183
|
+
else if (ds(t.key) && !V(t.sep, "newline")) {
|
|
4184
|
+
const o = z(t.start), a = t.key, l = t.sep;
|
|
4185
|
+
l.push(this.sourceToken), delete t.key, delete t.sep, this.stack.push({
|
|
4147
4186
|
type: "block-map",
|
|
4148
4187
|
offset: this.offset,
|
|
4149
4188
|
indent: this.indent,
|
|
4150
|
-
items: [{ start: o, key:
|
|
4189
|
+
items: [{ start: o, key: a, sep: l }]
|
|
4151
4190
|
});
|
|
4152
4191
|
} else r.length > 0 ? t.sep = t.sep.concat(r, this.sourceToken) : t.sep.push(this.sourceToken);
|
|
4153
4192
|
else if (V(t.start, "newline"))
|
|
@@ -4289,17 +4328,17 @@ class Tn {
|
|
|
4289
4328
|
if (n.type === "block-map" && (this.type === "map-value-ind" && n.indent === e.indent || this.type === "newline" && !n.items[n.items.length - 1].sep))
|
|
4290
4329
|
yield* this.pop(), yield* this.step();
|
|
4291
4330
|
else if (this.type === "map-value-ind" && n.type !== "flow-collection") {
|
|
4292
|
-
const i =
|
|
4293
|
-
|
|
4331
|
+
const i = Ee(n), r = z(i);
|
|
4332
|
+
vt(e);
|
|
4294
4333
|
const o = e.end.splice(1, e.end.length);
|
|
4295
4334
|
o.push(this.sourceToken);
|
|
4296
|
-
const
|
|
4335
|
+
const a = {
|
|
4297
4336
|
type: "block-map",
|
|
4298
4337
|
offset: e.offset,
|
|
4299
4338
|
indent: e.indent,
|
|
4300
4339
|
items: [{ start: r, key: e, sep: o }]
|
|
4301
4340
|
};
|
|
4302
|
-
this.onKeyLine = !0, this.stack[this.stack.length - 1] =
|
|
4341
|
+
this.onKeyLine = !0, this.stack[this.stack.length - 1] = a;
|
|
4303
4342
|
} else
|
|
4304
4343
|
yield* this.lineEnd(e);
|
|
4305
4344
|
}
|
|
@@ -4353,7 +4392,7 @@ class Tn {
|
|
|
4353
4392
|
};
|
|
4354
4393
|
case "explicit-key-ind": {
|
|
4355
4394
|
this.onKeyLine = !0;
|
|
4356
|
-
const t =
|
|
4395
|
+
const t = Ee(e), n = z(t);
|
|
4357
4396
|
return n.push(this.sourceToken), {
|
|
4358
4397
|
type: "block-map",
|
|
4359
4398
|
offset: this.offset,
|
|
@@ -4363,7 +4402,7 @@ class Tn {
|
|
|
4363
4402
|
}
|
|
4364
4403
|
case "map-value-ind": {
|
|
4365
4404
|
this.onKeyLine = !0;
|
|
4366
|
-
const t =
|
|
4405
|
+
const t = Ee(e), n = z(t);
|
|
4367
4406
|
return {
|
|
4368
4407
|
type: "block-map",
|
|
4369
4408
|
offset: this.offset,
|
|
@@ -4397,91 +4436,44 @@ class Tn {
|
|
|
4397
4436
|
}
|
|
4398
4437
|
}
|
|
4399
4438
|
}
|
|
4400
|
-
function
|
|
4439
|
+
function Mn(s) {
|
|
4401
4440
|
const e = s.prettyErrors !== !1;
|
|
4402
|
-
return { lineCounter: s.lineCounter || e && new
|
|
4441
|
+
return { lineCounter: s.lineCounter || e && new _n() || null, prettyErrors: e };
|
|
4403
4442
|
}
|
|
4404
|
-
function
|
|
4405
|
-
const { lineCounter: t, prettyErrors: n } =
|
|
4443
|
+
function jn(s, e = {}) {
|
|
4444
|
+
const { lineCounter: t, prettyErrors: n } = Mn(e), i = new Bn(t?.addNewLine), r = new In(e);
|
|
4406
4445
|
let o = null;
|
|
4407
|
-
for (const
|
|
4446
|
+
for (const a of r.compose(i.parse(s), !0, s.length))
|
|
4408
4447
|
if (!o)
|
|
4409
|
-
o =
|
|
4448
|
+
o = a;
|
|
4410
4449
|
else if (o.options.logLevel !== "silent") {
|
|
4411
|
-
o.errors.push(new he(
|
|
4450
|
+
o.errors.push(new he(a.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
|
|
4412
4451
|
break;
|
|
4413
4452
|
}
|
|
4414
|
-
return n && t && (o.errors.forEach(
|
|
4453
|
+
return n && t && (o.errors.forEach(Et(s, t)), o.warnings.forEach(Et(s, t))), o;
|
|
4415
4454
|
}
|
|
4416
|
-
function
|
|
4455
|
+
function Pn(s, e, t) {
|
|
4417
4456
|
let n;
|
|
4418
|
-
const i =
|
|
4457
|
+
const i = jn(s, t);
|
|
4419
4458
|
if (!i)
|
|
4420
4459
|
return null;
|
|
4421
|
-
if (i.warnings.forEach((r) =>
|
|
4460
|
+
if (i.warnings.forEach((r) => Ft(i.options.logLevel, r)), i.errors.length > 0) {
|
|
4422
4461
|
if (i.options.logLevel !== "silent")
|
|
4423
4462
|
throw i.errors[0];
|
|
4424
4463
|
i.errors = [];
|
|
4425
4464
|
}
|
|
4426
4465
|
return i.toJS(Object.assign({ reviver: n }, t));
|
|
4427
4466
|
}
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
Usage:
|
|
4431
|
-
on --port <port> [--host <host>] [--config <path>]
|
|
4432
|
-
|
|
4433
|
-
Options:
|
|
4434
|
-
--port, -p HTTP port for incoming webhooks (required)
|
|
4435
|
-
--host, -H Host binding for the HTTP server (default: 127.0.0.1)
|
|
4436
|
-
--config, -c Path to a YAML/JSON config file
|
|
4437
|
-
--help, -h Show this help message
|
|
4438
|
-
`;
|
|
4439
|
-
async function vn(s) {
|
|
4440
|
-
const e = [];
|
|
4441
|
-
for await (const t of s)
|
|
4442
|
-
e.push(Buffer.isBuffer(t) ? t : Buffer.from(t));
|
|
4443
|
-
return Buffer.concat(e).toString("utf8");
|
|
4444
|
-
}
|
|
4445
|
-
function He(s, e, t) {
|
|
4446
|
-
s.statusCode = e, s.setHeader("content-type", "application/json"), s.end(JSON.stringify(t));
|
|
4447
|
-
}
|
|
4448
|
-
function Cn(s) {
|
|
4449
|
-
return bt.isAbsolute(s) ? s : bt.resolve(process.cwd(), s);
|
|
4467
|
+
function Kn(s) {
|
|
4468
|
+
return wt.isAbsolute(s) ? s : wt.resolve(process.cwd(), s);
|
|
4450
4469
|
}
|
|
4451
|
-
async function
|
|
4470
|
+
async function Dn(s) {
|
|
4452
4471
|
if (!s)
|
|
4453
|
-
return {};
|
|
4454
|
-
const e =
|
|
4455
|
-
return e.endsWith(".yaml") || e.endsWith(".yml") ?
|
|
4456
|
-
}
|
|
4457
|
-
function Bn(s) {
|
|
4458
|
-
const e = Number.parseInt(s, 10);
|
|
4459
|
-
if (!Number.isInteger(e) || e < 0 || e > 65535)
|
|
4460
|
-
throw new Error(`Invalid --port value '${s}'. Expected an integer from 0 to 65535.`);
|
|
4461
|
-
return e;
|
|
4462
|
-
}
|
|
4463
|
-
function gt(s) {
|
|
4464
|
-
if (!s || typeof s != "object" || Array.isArray(s))
|
|
4465
|
-
throw new Error("Incoming webhook payload must be a JSON object.");
|
|
4466
|
-
return s;
|
|
4472
|
+
return { on: {} };
|
|
4473
|
+
const e = Kn(s), t = await tt(e, "utf8");
|
|
4474
|
+
return e.endsWith(".yaml") || e.endsWith(".yml") ? Pn(t) ?? { on: {} } : JSON.parse(t);
|
|
4467
4475
|
}
|
|
4468
|
-
function
|
|
4469
|
-
const n = e.trim().replace(/^\$\{/, "").replace(/}$/, "").split(".").filter(Boolean);
|
|
4470
|
-
let i = s;
|
|
4471
|
-
for (const r of n) {
|
|
4472
|
-
if (typeof i != "object" || i === null || !(r in i))
|
|
4473
|
-
return;
|
|
4474
|
-
i = i[r];
|
|
4475
|
-
}
|
|
4476
|
-
return i;
|
|
4477
|
-
}
|
|
4478
|
-
function Mn(s, e) {
|
|
4479
|
-
return s.replace(/\$\{([^}]+)}/g, (t, n) => {
|
|
4480
|
-
const i = ds(e, n);
|
|
4481
|
-
return i == null ? "" : String(i);
|
|
4482
|
-
});
|
|
4483
|
-
}
|
|
4484
|
-
function Pn(s) {
|
|
4476
|
+
function qn(s) {
|
|
4485
4477
|
return s.split(/\r?\n/u).map((e) => e.trim()).filter((e) => e.length > 0 && !e.startsWith("#")).reduce((e, t) => {
|
|
4486
4478
|
const n = t.indexOf("=");
|
|
4487
4479
|
if (n <= 0)
|
|
@@ -4490,72 +4482,147 @@ function Pn(s) {
|
|
|
4490
4482
|
return e[i] = r, e;
|
|
4491
4483
|
}, {});
|
|
4492
4484
|
}
|
|
4493
|
-
async function
|
|
4485
|
+
async function Fn(s) {
|
|
4494
4486
|
const e = {};
|
|
4495
4487
|
for (const [t, n] of Object.entries(process.env))
|
|
4496
4488
|
typeof n == "string" && (e[t] = n);
|
|
4497
4489
|
for (const t of s ?? []) {
|
|
4498
|
-
const n = await
|
|
4490
|
+
const n = await tt(t, "utf8");
|
|
4499
4491
|
if (t.endsWith(".json")) {
|
|
4500
|
-
const i =
|
|
4492
|
+
const i = st(JSON.parse(n));
|
|
4501
4493
|
for (const [r, o] of Object.entries(i))
|
|
4502
4494
|
o != null && (e[r] = String(o));
|
|
4503
4495
|
continue;
|
|
4504
4496
|
}
|
|
4505
|
-
Object.assign(e,
|
|
4497
|
+
Object.assign(e, qn(n));
|
|
4506
4498
|
}
|
|
4507
4499
|
return e;
|
|
4508
4500
|
}
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4501
|
+
const Un = "/workspace", Rn = `on - daemonized webhook runner
|
|
4502
|
+
|
|
4503
|
+
Usage:
|
|
4504
|
+
on --port <port> [--host <host>] [--config <path>]
|
|
4505
|
+
|
|
4506
|
+
Options:
|
|
4507
|
+
--port, -p HTTP port for incoming webhooks (required)
|
|
4508
|
+
--host, -H Host binding for the HTTP server (default: 127.0.0.1)
|
|
4509
|
+
--config, -c Path to a YAML/JSON config file
|
|
4510
|
+
--help, -h Show this help message
|
|
4511
|
+
`;
|
|
4512
|
+
function Vn(s, e) {
|
|
4513
|
+
if (typeof s.run != "string")
|
|
4514
|
+
throw new Error("Each workflow step must have a 'run' command string.");
|
|
4515
|
+
const t = e.workflow.defaults || {};
|
|
4516
|
+
return s.image ||= t.image, s.volumes ||= t.volumes || {}, s.args ||= t.args, s.run = Ce(s.run, { ...e, step: s }), s;
|
|
4517
|
+
}
|
|
4518
|
+
function Jn(s, e) {
|
|
4519
|
+
return (s || []).flatMap(
|
|
4520
|
+
(t) => Object.entries(t).flatMap(([n, i]) => [
|
|
4521
|
+
`--${n}`,
|
|
4522
|
+
Ce(String(i), e)
|
|
4523
|
+
])
|
|
4524
|
+
);
|
|
4525
|
+
}
|
|
4526
|
+
function Yn(s, e) {
|
|
4527
|
+
return s["."] ||= Un, Object.entries(s).flatMap(([t, n]) => [
|
|
4528
|
+
"-v",
|
|
4529
|
+
`${t === "." ? e.workingDir : t}:${n}`
|
|
4530
|
+
]);
|
|
4531
|
+
}
|
|
4532
|
+
function Gn(s) {
|
|
4533
|
+
const { workflow: e, secrets: t } = s, n = {
|
|
4534
|
+
...process.env,
|
|
4535
|
+
...Object.fromEntries(
|
|
4536
|
+
Object.entries(t).map(([i, r]) => [i, String(r)])
|
|
4537
|
+
),
|
|
4538
|
+
PWD: s.workingDir
|
|
4539
|
+
};
|
|
4540
|
+
if (e.env) {
|
|
4541
|
+
if (typeof e.env != "object")
|
|
4542
|
+
throw new Error("Workflow env field must be an object.");
|
|
4543
|
+
for (const [i, r] of Object.entries(e.env))
|
|
4544
|
+
n[i] = Ce(r, s);
|
|
4545
|
+
}
|
|
4546
|
+
s.env = n;
|
|
4547
|
+
}
|
|
4548
|
+
async function Hn(s, e) {
|
|
4549
|
+
typeof s == "string" && (s = { run: s });
|
|
4550
|
+
const t = Vn(s, e), { args: n, image: i, volumes: r } = t, o = Yn(r, e), a = Jn(n, e), l = r["."], c = [
|
|
4551
|
+
"run",
|
|
4552
|
+
"-i",
|
|
4553
|
+
"--rm",
|
|
4554
|
+
...o,
|
|
4555
|
+
...a,
|
|
4556
|
+
"-w",
|
|
4557
|
+
l,
|
|
4558
|
+
"--entrypoint",
|
|
4559
|
+
"sh",
|
|
4560
|
+
i
|
|
4561
|
+
];
|
|
4562
|
+
await new Promise((d, u) => {
|
|
4563
|
+
const f = ys("docker", c, { env: e.env });
|
|
4564
|
+
f.stdout?.pipe(process.stdout), f.stderr?.pipe(process.stderr), f.once("error", u), f.once("exit", (m) => {
|
|
4565
|
+
if (m === 0) {
|
|
4566
|
+
d();
|
|
4529
4567
|
return;
|
|
4530
4568
|
}
|
|
4531
|
-
|
|
4532
|
-
})
|
|
4569
|
+
u(new Error(`Step failed with exit code ${m}: ${s}`));
|
|
4570
|
+
}), f.stdin?.write(t.run), f.stdin?.write(`
|
|
4571
|
+
exit $?;
|
|
4572
|
+
`), f.stdin?.end();
|
|
4533
4573
|
});
|
|
4534
4574
|
}
|
|
4575
|
+
function Wn(s, e) {
|
|
4576
|
+
const t = Object.keys(s), n = Object.keys(e.on), i = n.find((a) => s[a]), r = i ? e.on[i] : null;
|
|
4577
|
+
if (!r)
|
|
4578
|
+
return console.log(
|
|
4579
|
+
`No workflow defined for event keys: ${t.join(", ")}, only accepting ${n.join(", ")}.`
|
|
4580
|
+
), null;
|
|
4581
|
+
if (!r.steps || r.steps.length === 0)
|
|
4582
|
+
return console.warn(
|
|
4583
|
+
`Workflow for event ${s.source}:${s.event} has no steps defined, skipping.`
|
|
4584
|
+
), null;
|
|
4585
|
+
const o = s[i];
|
|
4586
|
+
return {
|
|
4587
|
+
workflow: r,
|
|
4588
|
+
event: o
|
|
4589
|
+
};
|
|
4590
|
+
}
|
|
4535
4591
|
async function ps(s, e) {
|
|
4536
|
-
|
|
4537
|
-
throw new Error("Incoming payload must include string fields 'source' and 'event'.");
|
|
4538
|
-
const t = e.on?.[s.source]?.[s.event];
|
|
4592
|
+
const t = Wn(s, e);
|
|
4539
4593
|
if (!t)
|
|
4540
|
-
|
|
4541
|
-
const n =
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4594
|
+
return;
|
|
4595
|
+
const { workflow: n, event: i } = t, r = Es(i, n.mappings), o = await Fn(n.secrets), a = await bs(ks(Ns(), "workflow")), l = {
|
|
4596
|
+
inputs: r,
|
|
4597
|
+
secrets: o,
|
|
4598
|
+
workflow: n,
|
|
4599
|
+
env: {},
|
|
4600
|
+
outputs: {},
|
|
4601
|
+
workingDir: a
|
|
4547
4602
|
};
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4603
|
+
Gn(l);
|
|
4604
|
+
try {
|
|
4605
|
+
for (const c of n.steps ?? [])
|
|
4606
|
+
await Hn(c, l);
|
|
4607
|
+
for (const c of n.triggers ?? [])
|
|
4608
|
+
await Qn(c, e);
|
|
4609
|
+
} catch (c) {
|
|
4610
|
+
const d = c instanceof Error ? c.message : String(c);
|
|
4611
|
+
console.error(`Error processing event: ${d}`), console.debug(JSON.stringify(i));
|
|
4612
|
+
} finally {
|
|
4613
|
+
await ws(l.workingDir, { recursive: !0, force: !0 });
|
|
4614
|
+
}
|
|
4615
|
+
return l.outputs;
|
|
4616
|
+
}
|
|
4617
|
+
async function Qn(s, e) {
|
|
4618
|
+
if (!Ss(s)) {
|
|
4619
|
+
console.warn(`Trigger file does not exist: ${s}`);
|
|
4620
|
+
return;
|
|
4556
4621
|
}
|
|
4622
|
+
const t = await tt(s, "utf8"), n = st(JSON.parse(t));
|
|
4623
|
+
await ps(n, e);
|
|
4557
4624
|
}
|
|
4558
|
-
function
|
|
4625
|
+
function Xn(s) {
|
|
4559
4626
|
const { values: e } = gs({
|
|
4560
4627
|
args: s,
|
|
4561
4628
|
options: {
|
|
@@ -4567,55 +4634,58 @@ function qn(s) {
|
|
|
4567
4634
|
allowPositionals: !1
|
|
4568
4635
|
});
|
|
4569
4636
|
if (e.help)
|
|
4570
|
-
return console.log(
|
|
4637
|
+
return console.log(Rn), null;
|
|
4571
4638
|
if (!e.port)
|
|
4572
4639
|
throw new Error("Missing required option --port.");
|
|
4573
4640
|
return {
|
|
4574
|
-
port:
|
|
4641
|
+
port: As(e.port),
|
|
4575
4642
|
host: e.host,
|
|
4576
4643
|
configPath: e.config
|
|
4577
4644
|
};
|
|
4578
4645
|
}
|
|
4579
|
-
async function
|
|
4580
|
-
const e = await
|
|
4646
|
+
async function xn(s) {
|
|
4647
|
+
const e = await Dn(s.configPath), t = ms(async (i, r) => {
|
|
4581
4648
|
if (i.method !== "POST") {
|
|
4582
|
-
|
|
4649
|
+
Re(r, 405, { error: "Only POST webhooks are supported." });
|
|
4583
4650
|
return;
|
|
4584
4651
|
}
|
|
4585
4652
|
try {
|
|
4586
|
-
const o = await
|
|
4587
|
-
|
|
4653
|
+
const o = await Os(i), a = st(
|
|
4654
|
+
o.length > 0 ? JSON.parse(o) : {}
|
|
4655
|
+
), l = await ps(a, e);
|
|
4656
|
+
Re(r, 202, {
|
|
4588
4657
|
status: "accepted",
|
|
4589
|
-
|
|
4590
|
-
event: l.event
|
|
4658
|
+
outputs: l
|
|
4591
4659
|
});
|
|
4592
4660
|
} catch (o) {
|
|
4593
|
-
const
|
|
4594
|
-
|
|
4661
|
+
const a = o instanceof Error ? o.message : "Unknown error";
|
|
4662
|
+
Re(r, 400, { error: a });
|
|
4595
4663
|
}
|
|
4596
4664
|
});
|
|
4597
4665
|
await new Promise((i, r) => {
|
|
4598
4666
|
t.once("error", r), t.listen(s.port, s.host, () => i());
|
|
4599
4667
|
});
|
|
4600
4668
|
const n = t.address();
|
|
4601
|
-
return n && typeof n == "object" && console.log(
|
|
4669
|
+
return n && typeof n == "object" && console.log(
|
|
4670
|
+
`on daemon listening on http://${n.address}:${n.port}`
|
|
4671
|
+
), t;
|
|
4602
4672
|
}
|
|
4603
|
-
async function
|
|
4673
|
+
async function zn() {
|
|
4604
4674
|
try {
|
|
4605
|
-
const s =
|
|
4675
|
+
const s = Xn(process.argv.slice(2));
|
|
4606
4676
|
if (!s) {
|
|
4607
4677
|
process.exitCode = 0;
|
|
4608
4678
|
return;
|
|
4609
4679
|
}
|
|
4610
|
-
await
|
|
4680
|
+
await xn(s);
|
|
4611
4681
|
} catch (s) {
|
|
4612
4682
|
const e = s instanceof Error ? s.message : String(s);
|
|
4613
4683
|
console.error(`on: ${e}`), process.exitCode = 1;
|
|
4614
4684
|
}
|
|
4615
4685
|
}
|
|
4616
|
-
|
|
4686
|
+
zn();
|
|
4617
4687
|
export {
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4688
|
+
zn as main,
|
|
4689
|
+
Xn as parseCliOptions,
|
|
4690
|
+
xn as startDaemon
|
|
4621
4691
|
};
|