@cloud-cli/on 0.1.3 → 0.1.4
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 +873 -801
- package/package.json +1 -1
package/dist/on.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { existsSync as
|
|
8
|
-
import { tmpdir as
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
e.push(Buffer.isBuffer(t) ? t : Buffer.from(t));
|
|
13
|
-
return Buffer.concat(e).toString("utf8");
|
|
14
|
-
}
|
|
15
|
-
function Re(s, e, t) {
|
|
2
|
+
import { parseArgs as Ss } from "node:util";
|
|
3
|
+
import { createServer as Ns } from "node:http";
|
|
4
|
+
import { readFile as tt, mkdtemp as _t, writeFile as Os, rm as As } from "node:fs/promises";
|
|
5
|
+
import kt, { join as st } from "node:path";
|
|
6
|
+
import { spawn as jt } from "node:child_process";
|
|
7
|
+
import { existsSync as Es } from "node:fs";
|
|
8
|
+
import { tmpdir as Bt } from "node:os";
|
|
9
|
+
import { join as Ts } from "node:path/posix";
|
|
10
|
+
import { randomUUID as Is } from "node:crypto";
|
|
11
|
+
function x(s, e, t) {
|
|
16
12
|
s.writeHead(e, { "content-type": "application/json" }).end(JSON.stringify(t));
|
|
17
13
|
}
|
|
18
|
-
function
|
|
14
|
+
function $s(s) {
|
|
19
15
|
const e = Number.parseInt(s, 10);
|
|
20
16
|
if (!Number.isInteger(e) || e < 0 || e > 65535)
|
|
21
17
|
throw new Error(
|
|
@@ -23,32 +19,40 @@ function As(s) {
|
|
|
23
19
|
);
|
|
24
20
|
return e;
|
|
25
21
|
}
|
|
26
|
-
function
|
|
22
|
+
function nt(s) {
|
|
27
23
|
if (!s || typeof s != "object" || Array.isArray(s))
|
|
28
24
|
throw new Error("Incoming webhook payload must be a JSON object.");
|
|
29
25
|
return s;
|
|
30
26
|
}
|
|
31
|
-
function
|
|
27
|
+
function Mt(s) {
|
|
28
|
+
return typeof s == "object" && s !== null ? new Proxy(s, {
|
|
29
|
+
get(e, t) {
|
|
30
|
+
const n = Reflect.get(e, t);
|
|
31
|
+
return typeof n == "object" && n !== null ? Mt(n) : t === "toString" ? () => "'" + JSON.stringify(e) + "'" : n;
|
|
32
|
+
}
|
|
33
|
+
}) : s ?? "";
|
|
34
|
+
}
|
|
35
|
+
function _e(s, e) {
|
|
32
36
|
const t = Function(
|
|
33
37
|
"context",
|
|
34
38
|
"const { secrets = {}, inputs = {}, step = {}, env } = context;return `" + s + "`;"
|
|
35
39
|
);
|
|
36
40
|
return String(t(e) || "");
|
|
37
41
|
}
|
|
38
|
-
function
|
|
42
|
+
function Ls(s, e) {
|
|
39
43
|
if (!e)
|
|
40
44
|
return { ...s };
|
|
41
45
|
const t = { inputs: s };
|
|
42
46
|
for (const [n, i] of Object.entries(e))
|
|
43
|
-
t.inputs[n] =
|
|
47
|
+
t.inputs[n] = _e(`\${${i}}`, t);
|
|
44
48
|
return t.inputs;
|
|
45
49
|
}
|
|
46
|
-
const
|
|
50
|
+
const it = /* @__PURE__ */ Symbol.for("yaml.alias"), Qe = /* @__PURE__ */ Symbol.for("yaml.document"), J = /* @__PURE__ */ Symbol.for("yaml.map"), Pt = /* @__PURE__ */ Symbol.for("yaml.pair"), U = /* @__PURE__ */ Symbol.for("yaml.scalar"), ae = /* @__PURE__ */ Symbol.for("yaml.seq"), P = /* @__PURE__ */ Symbol.for("yaml.node.type"), Q = (s) => !!s && typeof s == "object" && s[P] === it, je = (s) => !!s && typeof s == "object" && s[P] === Qe, be = (s) => !!s && typeof s == "object" && s[P] === J, L = (s) => !!s && typeof s == "object" && s[P] === Pt, T = (s) => !!s && typeof s == "object" && s[P] === U, we = (s) => !!s && typeof s == "object" && s[P] === ae;
|
|
47
51
|
function I(s) {
|
|
48
52
|
if (s && typeof s == "object")
|
|
49
53
|
switch (s[P]) {
|
|
50
54
|
case J:
|
|
51
|
-
case
|
|
55
|
+
case ae:
|
|
52
56
|
return !0;
|
|
53
57
|
}
|
|
54
58
|
return !1;
|
|
@@ -56,54 +60,54 @@ function I(s) {
|
|
|
56
60
|
function $(s) {
|
|
57
61
|
if (s && typeof s == "object")
|
|
58
62
|
switch (s[P]) {
|
|
59
|
-
case
|
|
63
|
+
case it:
|
|
60
64
|
case J:
|
|
61
|
-
case
|
|
62
|
-
case
|
|
65
|
+
case U:
|
|
66
|
+
case ae:
|
|
63
67
|
return !0;
|
|
64
68
|
}
|
|
65
69
|
return !1;
|
|
66
70
|
}
|
|
67
|
-
const
|
|
68
|
-
function
|
|
69
|
-
const t =
|
|
70
|
-
|
|
71
|
+
const Kt = (s) => (T(s) || I(s)) && !!s.anchor, Y = /* @__PURE__ */ Symbol("break visit"), vs = /* @__PURE__ */ Symbol("skip children"), pe = /* @__PURE__ */ Symbol("remove node");
|
|
72
|
+
function le(s, e) {
|
|
73
|
+
const t = Cs(e);
|
|
74
|
+
je(s) ? ee(null, s.contents, t, Object.freeze([s])) === pe && (s.contents = null) : ee(null, s, t, Object.freeze([]));
|
|
71
75
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
function
|
|
76
|
-
const i =
|
|
76
|
+
le.BREAK = Y;
|
|
77
|
+
le.SKIP = vs;
|
|
78
|
+
le.REMOVE = pe;
|
|
79
|
+
function ee(s, e, t, n) {
|
|
80
|
+
const i = _s(s, e, t, n);
|
|
77
81
|
if ($(i) || L(i))
|
|
78
|
-
return
|
|
82
|
+
return js(s, n, i), ee(s, i, t, n);
|
|
79
83
|
if (typeof i != "symbol") {
|
|
80
84
|
if (I(e)) {
|
|
81
85
|
n = Object.freeze(n.concat(e));
|
|
82
86
|
for (let r = 0; r < e.items.length; ++r) {
|
|
83
|
-
const o =
|
|
87
|
+
const o = ee(r, e.items[r], t, n);
|
|
84
88
|
if (typeof o == "number")
|
|
85
89
|
r = o - 1;
|
|
86
90
|
else {
|
|
87
91
|
if (o === Y)
|
|
88
92
|
return Y;
|
|
89
|
-
o ===
|
|
93
|
+
o === pe && (e.items.splice(r, 1), r -= 1);
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
} else if (L(e)) {
|
|
93
97
|
n = Object.freeze(n.concat(e));
|
|
94
|
-
const r =
|
|
98
|
+
const r = ee("key", e.key, t, n);
|
|
95
99
|
if (r === Y)
|
|
96
100
|
return Y;
|
|
97
|
-
r ===
|
|
98
|
-
const o =
|
|
101
|
+
r === pe && (e.key = null);
|
|
102
|
+
const o = ee("value", e.value, t, n);
|
|
99
103
|
if (o === Y)
|
|
100
104
|
return Y;
|
|
101
|
-
o ===
|
|
105
|
+
o === pe && (e.value = null);
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
return i;
|
|
105
109
|
}
|
|
106
|
-
function
|
|
110
|
+
function Cs(s) {
|
|
107
111
|
return typeof s == "object" && (s.Collection || s.Node || s.Value) ? Object.assign({
|
|
108
112
|
Alias: s.Node,
|
|
109
113
|
Map: s.Node,
|
|
@@ -118,12 +122,12 @@ function Is(s) {
|
|
|
118
122
|
Seq: s.Collection
|
|
119
123
|
}, s) : s;
|
|
120
124
|
}
|
|
121
|
-
function
|
|
125
|
+
function _s(s, e, t, n) {
|
|
122
126
|
if (typeof t == "function")
|
|
123
127
|
return t(s, e, n);
|
|
124
|
-
if (ye(e))
|
|
125
|
-
return t.Map?.(s, e, n);
|
|
126
128
|
if (be(e))
|
|
129
|
+
return t.Map?.(s, e, n);
|
|
130
|
+
if (we(e))
|
|
127
131
|
return t.Seq?.(s, e, n);
|
|
128
132
|
if (L(e))
|
|
129
133
|
return t.Pair?.(s, e, n);
|
|
@@ -132,27 +136,27 @@ function $s(s, e, t, n) {
|
|
|
132
136
|
if (Q(e))
|
|
133
137
|
return t.Alias?.(s, e, n);
|
|
134
138
|
}
|
|
135
|
-
function
|
|
139
|
+
function js(s, e, t) {
|
|
136
140
|
const n = e[e.length - 1];
|
|
137
141
|
if (I(n))
|
|
138
142
|
n.items[s] = t;
|
|
139
143
|
else if (L(n))
|
|
140
144
|
s === "key" ? n.key = t : n.value = t;
|
|
141
|
-
else if (
|
|
145
|
+
else if (je(n))
|
|
142
146
|
n.contents = t;
|
|
143
147
|
else {
|
|
144
148
|
const i = Q(n) ? "alias" : "scalar";
|
|
145
149
|
throw new Error(`Cannot replace node with ${i} parent`);
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
|
-
const
|
|
152
|
+
const Bs = {
|
|
149
153
|
"!": "%21",
|
|
150
154
|
",": "%2C",
|
|
151
155
|
"[": "%5B",
|
|
152
156
|
"]": "%5D",
|
|
153
157
|
"{": "%7B",
|
|
154
158
|
"}": "%7D"
|
|
155
|
-
},
|
|
159
|
+
}, Ms = (s) => s.replace(/[!,[\]{}]/g, (e) => Bs[e]);
|
|
156
160
|
class _ {
|
|
157
161
|
constructor(e, t) {
|
|
158
162
|
this.docStart = null, this.docEnd = !1, this.yaml = Object.assign({}, _.defaultYaml, e), this.tags = Object.assign({}, _.defaultTags, t);
|
|
@@ -242,7 +246,7 @@ class _ {
|
|
|
242
246
|
tagString(e) {
|
|
243
247
|
for (const [t, n] of Object.entries(this.tags))
|
|
244
248
|
if (e.startsWith(n))
|
|
245
|
-
return t +
|
|
249
|
+
return t + Ms(e.substring(n.length));
|
|
246
250
|
return e[0] === "!" ? e : `!<${e}>`;
|
|
247
251
|
}
|
|
248
252
|
toString(e) {
|
|
@@ -250,7 +254,7 @@ class _ {
|
|
|
250
254
|
let i;
|
|
251
255
|
if (e && n.length > 0 && $(e.contents)) {
|
|
252
256
|
const r = {};
|
|
253
|
-
|
|
257
|
+
le(e.contents, (o, a) => {
|
|
254
258
|
$(a) && a.tag && (r[a.tag] = !0);
|
|
255
259
|
}), i = Object.keys(r);
|
|
256
260
|
} else
|
|
@@ -263,35 +267,35 @@ class _ {
|
|
|
263
267
|
}
|
|
264
268
|
_.defaultYaml = { explicit: !1, version: "1.2" };
|
|
265
269
|
_.defaultTags = { "!!": "tag:yaml.org,2002:" };
|
|
266
|
-
function
|
|
270
|
+
function Dt(s) {
|
|
267
271
|
if (/[\x00-\x19\s,[\]{}]/.test(s)) {
|
|
268
272
|
const t = `Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;
|
|
269
273
|
throw new Error(t);
|
|
270
274
|
}
|
|
271
275
|
return !0;
|
|
272
276
|
}
|
|
273
|
-
function
|
|
277
|
+
function Ut(s) {
|
|
274
278
|
const e = /* @__PURE__ */ new Set();
|
|
275
|
-
return
|
|
279
|
+
return le(s, {
|
|
276
280
|
Value(t, n) {
|
|
277
281
|
n.anchor && e.add(n.anchor);
|
|
278
282
|
}
|
|
279
283
|
}), e;
|
|
280
284
|
}
|
|
281
|
-
function
|
|
285
|
+
function Ft(s, e) {
|
|
282
286
|
for (let t = 1; ; ++t) {
|
|
283
287
|
const n = `${s}${t}`;
|
|
284
288
|
if (!e.has(n))
|
|
285
289
|
return n;
|
|
286
290
|
}
|
|
287
291
|
}
|
|
288
|
-
function
|
|
292
|
+
function Ps(s, e) {
|
|
289
293
|
const t = [], n = /* @__PURE__ */ new Map();
|
|
290
294
|
let i = null;
|
|
291
295
|
return {
|
|
292
296
|
onAnchor: (r) => {
|
|
293
|
-
t.push(r), i ?? (i =
|
|
294
|
-
const o =
|
|
297
|
+
t.push(r), i ?? (i = Ut(s));
|
|
298
|
+
const o = Ft(e, i);
|
|
295
299
|
return i.add(o), o;
|
|
296
300
|
},
|
|
297
301
|
/**
|
|
@@ -313,35 +317,35 @@ function _s(s, e) {
|
|
|
313
317
|
sourceObjects: n
|
|
314
318
|
};
|
|
315
319
|
}
|
|
316
|
-
function
|
|
320
|
+
function te(s, e, t, n) {
|
|
317
321
|
if (n && typeof n == "object")
|
|
318
322
|
if (Array.isArray(n))
|
|
319
323
|
for (let i = 0, r = n.length; i < r; ++i) {
|
|
320
|
-
const o = n[i], a =
|
|
324
|
+
const o = n[i], a = te(s, n, String(i), o);
|
|
321
325
|
a === void 0 ? delete n[i] : a !== o && (n[i] = a);
|
|
322
326
|
}
|
|
323
327
|
else if (n instanceof Map)
|
|
324
328
|
for (const i of Array.from(n.keys())) {
|
|
325
|
-
const r = n.get(i), o =
|
|
329
|
+
const r = n.get(i), o = te(s, n, i, r);
|
|
326
330
|
o === void 0 ? n.delete(i) : o !== r && n.set(i, o);
|
|
327
331
|
}
|
|
328
332
|
else if (n instanceof Set)
|
|
329
333
|
for (const i of Array.from(n)) {
|
|
330
|
-
const r =
|
|
334
|
+
const r = te(s, n, i, i);
|
|
331
335
|
r === void 0 ? n.delete(i) : r !== i && (n.delete(i), n.add(r));
|
|
332
336
|
}
|
|
333
337
|
else
|
|
334
338
|
for (const [i, r] of Object.entries(n)) {
|
|
335
|
-
const o =
|
|
339
|
+
const o = te(s, n, i, r);
|
|
336
340
|
o === void 0 ? delete n[i] : o !== r && (n[i] = o);
|
|
337
341
|
}
|
|
338
342
|
return s.call(e, t, n);
|
|
339
343
|
}
|
|
340
|
-
function
|
|
344
|
+
function M(s, e, t) {
|
|
341
345
|
if (Array.isArray(s))
|
|
342
|
-
return s.map((n, i) =>
|
|
346
|
+
return s.map((n, i) => M(n, String(i), t));
|
|
343
347
|
if (s && typeof s.toJSON == "function") {
|
|
344
|
-
if (!t || !
|
|
348
|
+
if (!t || !Kt(s))
|
|
345
349
|
return s.toJSON(e, t);
|
|
346
350
|
const n = { aliasCount: 0, count: 1, res: void 0 };
|
|
347
351
|
t.anchors.set(s, n), t.onCreate = (r) => {
|
|
@@ -352,7 +356,7 @@ function j(s, e, t) {
|
|
|
352
356
|
}
|
|
353
357
|
return typeof s == "bigint" && !t?.keep ? Number(s) : s;
|
|
354
358
|
}
|
|
355
|
-
class
|
|
359
|
+
class rt {
|
|
356
360
|
constructor(e) {
|
|
357
361
|
Object.defineProperty(this, P, { value: e });
|
|
358
362
|
}
|
|
@@ -363,7 +367,7 @@ class it {
|
|
|
363
367
|
}
|
|
364
368
|
/** A plain JavaScript representation of this node. */
|
|
365
369
|
toJS(e, { mapAsMap: t, maxAliasCount: n, onAnchor: i, reviver: r } = {}) {
|
|
366
|
-
if (!
|
|
370
|
+
if (!je(e))
|
|
367
371
|
throw new TypeError("A document argument is required");
|
|
368
372
|
const o = {
|
|
369
373
|
anchors: /* @__PURE__ */ new Map(),
|
|
@@ -372,16 +376,16 @@ class it {
|
|
|
372
376
|
mapAsMap: t === !0,
|
|
373
377
|
mapKeyWarned: !1,
|
|
374
378
|
maxAliasCount: typeof n == "number" ? n : 100
|
|
375
|
-
}, a =
|
|
379
|
+
}, a = M(this, "", o);
|
|
376
380
|
if (typeof i == "function")
|
|
377
381
|
for (const { count: l, res: c } of o.anchors.values())
|
|
378
382
|
i(c, l);
|
|
379
|
-
return typeof r == "function" ?
|
|
383
|
+
return typeof r == "function" ? te(r, { "": a }, "", a) : a;
|
|
380
384
|
}
|
|
381
385
|
}
|
|
382
|
-
class
|
|
386
|
+
class ot extends rt {
|
|
383
387
|
constructor(e) {
|
|
384
|
-
super(
|
|
388
|
+
super(it), this.source = e, Object.defineProperty(this, "tag", {
|
|
385
389
|
set() {
|
|
386
390
|
throw new Error("Alias nodes cannot have tags");
|
|
387
391
|
}
|
|
@@ -393,9 +397,9 @@ class rt extends it {
|
|
|
393
397
|
*/
|
|
394
398
|
resolve(e, t) {
|
|
395
399
|
let n;
|
|
396
|
-
t?.aliasResolveCache ? n = t.aliasResolveCache : (n = [],
|
|
400
|
+
t?.aliasResolveCache ? n = t.aliasResolveCache : (n = [], le(e, {
|
|
397
401
|
Node: (r, o) => {
|
|
398
|
-
(Q(o) ||
|
|
402
|
+
(Q(o) || Kt(o)) && n.push(o);
|
|
399
403
|
}
|
|
400
404
|
}), t && (t.aliasResolveCache = n));
|
|
401
405
|
let i;
|
|
@@ -415,11 +419,11 @@ class rt extends it {
|
|
|
415
419
|
throw new ReferenceError(l);
|
|
416
420
|
}
|
|
417
421
|
let a = n.get(o);
|
|
418
|
-
if (a || (
|
|
422
|
+
if (a || (M(o, null, t), a = n.get(o)), a?.res === void 0) {
|
|
419
423
|
const l = "This should not happen: Alias anchor was not resolved?";
|
|
420
424
|
throw new ReferenceError(l);
|
|
421
425
|
}
|
|
422
|
-
if (r >= 0 && (a.count += 1, a.aliasCount === 0 && (a.aliasCount =
|
|
426
|
+
if (r >= 0 && (a.count += 1, a.aliasCount === 0 && (a.aliasCount = Ie(i, o, n)), a.count * a.aliasCount > r)) {
|
|
423
427
|
const l = "Excessive alias count indicates a resource exhaustion attack";
|
|
424
428
|
throw new ReferenceError(l);
|
|
425
429
|
}
|
|
@@ -428,7 +432,7 @@ class rt extends it {
|
|
|
428
432
|
toString(e, t, n) {
|
|
429
433
|
const i = `*${this.source}`;
|
|
430
434
|
if (e) {
|
|
431
|
-
if (
|
|
435
|
+
if (Dt(this.source), e.options.verifyAliasOrder && !e.anchors.has(this.source)) {
|
|
432
436
|
const r = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
433
437
|
throw new Error(r);
|
|
434
438
|
}
|
|
@@ -438,30 +442,30 @@ class rt extends it {
|
|
|
438
442
|
return i;
|
|
439
443
|
}
|
|
440
444
|
}
|
|
441
|
-
function
|
|
445
|
+
function Ie(s, e, t) {
|
|
442
446
|
if (Q(e)) {
|
|
443
447
|
const n = e.resolve(s), i = t && n && t.get(n);
|
|
444
448
|
return i ? i.count * i.aliasCount : 0;
|
|
445
449
|
} else if (I(e)) {
|
|
446
450
|
let n = 0;
|
|
447
451
|
for (const i of e.items) {
|
|
448
|
-
const r =
|
|
452
|
+
const r = Ie(s, i, t);
|
|
449
453
|
r > n && (n = r);
|
|
450
454
|
}
|
|
451
455
|
return n;
|
|
452
456
|
} else if (L(e)) {
|
|
453
|
-
const n =
|
|
457
|
+
const n = Ie(s, e.key, t), i = Ie(s, e.value, t);
|
|
454
458
|
return Math.max(n, i);
|
|
455
459
|
}
|
|
456
460
|
return 1;
|
|
457
461
|
}
|
|
458
|
-
const
|
|
459
|
-
class O extends
|
|
462
|
+
const Rt = (s) => !s || typeof s != "function" && typeof s != "object";
|
|
463
|
+
class O extends rt {
|
|
460
464
|
constructor(e) {
|
|
461
|
-
super(
|
|
465
|
+
super(U), this.value = e;
|
|
462
466
|
}
|
|
463
467
|
toJSON(e, t) {
|
|
464
|
-
return t?.keep ? this.value :
|
|
468
|
+
return t?.keep ? this.value : M(this.value, e, t);
|
|
465
469
|
}
|
|
466
470
|
toString() {
|
|
467
471
|
return String(this.value);
|
|
@@ -472,8 +476,8 @@ O.BLOCK_LITERAL = "BLOCK_LITERAL";
|
|
|
472
476
|
O.PLAIN = "PLAIN";
|
|
473
477
|
O.QUOTE_DOUBLE = "QUOTE_DOUBLE";
|
|
474
478
|
O.QUOTE_SINGLE = "QUOTE_SINGLE";
|
|
475
|
-
const
|
|
476
|
-
function
|
|
479
|
+
const Ks = "tag:yaml.org,2002:";
|
|
480
|
+
function Ds(s, e, t) {
|
|
477
481
|
if (e) {
|
|
478
482
|
const n = t.filter((r) => r.tag === e), i = n.find((r) => !r.format) ?? n[0];
|
|
479
483
|
if (!i)
|
|
@@ -482,8 +486,8 @@ function Ms(s, e, t) {
|
|
|
482
486
|
}
|
|
483
487
|
return t.find((n) => n.identify?.(s) && !n.format);
|
|
484
488
|
}
|
|
485
|
-
function
|
|
486
|
-
if (
|
|
489
|
+
function ge(s, e, t) {
|
|
490
|
+
if (je(s) && (s = s.contents), $(s))
|
|
487
491
|
return s;
|
|
488
492
|
if (L(s)) {
|
|
489
493
|
const u = t.schema[J].createNode?.(t.schema, null, t);
|
|
@@ -494,23 +498,23 @@ function me(s, e, t) {
|
|
|
494
498
|
let l;
|
|
495
499
|
if (n && s && typeof s == "object") {
|
|
496
500
|
if (l = a.get(s), l)
|
|
497
|
-
return l.anchor ?? (l.anchor = i(s)), new
|
|
501
|
+
return l.anchor ?? (l.anchor = i(s)), new ot(l.anchor);
|
|
498
502
|
l = { anchor: null, node: null }, a.set(s, l);
|
|
499
503
|
}
|
|
500
|
-
e?.startsWith("!!") && (e =
|
|
501
|
-
let c =
|
|
504
|
+
e?.startsWith("!!") && (e = Ks + e.slice(2));
|
|
505
|
+
let c = Ds(s, e, o.tags);
|
|
502
506
|
if (!c) {
|
|
503
507
|
if (s && typeof s.toJSON == "function" && (s = s.toJSON()), !s || typeof s != "object") {
|
|
504
508
|
const u = new O(s);
|
|
505
509
|
return l && (l.node = u), u;
|
|
506
510
|
}
|
|
507
|
-
c = s instanceof Map ? o[J] : Symbol.iterator in Object(s) ? o[
|
|
511
|
+
c = s instanceof Map ? o[J] : Symbol.iterator in Object(s) ? o[ae] : o[J];
|
|
508
512
|
}
|
|
509
513
|
r && (r(c), delete t.onTagObj);
|
|
510
514
|
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);
|
|
511
515
|
return e ? d.tag = e : c.default || (d.tag = c.tag), l && (l.node = d), d;
|
|
512
516
|
}
|
|
513
|
-
function
|
|
517
|
+
function ve(s, e, t) {
|
|
514
518
|
let n = t;
|
|
515
519
|
for (let i = e.length - 1; i >= 0; --i) {
|
|
516
520
|
const r = e[i];
|
|
@@ -520,7 +524,7 @@ function Le(s, e, t) {
|
|
|
520
524
|
} else
|
|
521
525
|
n = /* @__PURE__ */ new Map([[r, n]]);
|
|
522
526
|
}
|
|
523
|
-
return
|
|
527
|
+
return ge(n, void 0, {
|
|
524
528
|
aliasDuplicateObjects: !1,
|
|
525
529
|
keepUndefined: !1,
|
|
526
530
|
onAnchor: () => {
|
|
@@ -530,8 +534,8 @@ function Le(s, e, t) {
|
|
|
530
534
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
531
535
|
});
|
|
532
536
|
}
|
|
533
|
-
const
|
|
534
|
-
class
|
|
537
|
+
const he = (s) => s == null || typeof s == "object" && !!s[Symbol.iterator]().next().done;
|
|
538
|
+
class qt extends rt {
|
|
535
539
|
constructor(e, t) {
|
|
536
540
|
super(e), Object.defineProperty(this, "schema", {
|
|
537
541
|
value: t,
|
|
@@ -555,14 +559,14 @@ class Kt extends it {
|
|
|
555
559
|
* that already exists in the map.
|
|
556
560
|
*/
|
|
557
561
|
addIn(e, t) {
|
|
558
|
-
if (
|
|
562
|
+
if (he(e))
|
|
559
563
|
this.add(t);
|
|
560
564
|
else {
|
|
561
565
|
const [n, ...i] = e, r = this.get(n, !0);
|
|
562
566
|
if (I(r))
|
|
563
567
|
r.addIn(i, t);
|
|
564
568
|
else if (r === void 0 && this.schema)
|
|
565
|
-
this.set(n,
|
|
569
|
+
this.set(n, ve(this.schema, i, t));
|
|
566
570
|
else
|
|
567
571
|
throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);
|
|
568
572
|
}
|
|
@@ -620,20 +624,20 @@ class Kt extends it {
|
|
|
620
624
|
if (I(r))
|
|
621
625
|
r.setIn(i, t);
|
|
622
626
|
else if (r === void 0 && this.schema)
|
|
623
|
-
this.set(n,
|
|
627
|
+
this.set(n, ve(this.schema, i, t));
|
|
624
628
|
else
|
|
625
629
|
throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);
|
|
626
630
|
}
|
|
627
631
|
}
|
|
628
632
|
}
|
|
629
|
-
const
|
|
633
|
+
const Us = (s) => s.replace(/^(?!$)(?: $)?/gm, "#");
|
|
630
634
|
function F(s, e) {
|
|
631
635
|
return /^\n+$/.test(s) ? s.substring(1) : e ? s.replace(/^(?! *$)/gm, e) : s;
|
|
632
636
|
}
|
|
633
637
|
const G = (s, e, t) => s.endsWith(`
|
|
634
638
|
`) ? F(t, e) : t.includes(`
|
|
635
639
|
`) ? `
|
|
636
|
-
` + F(t, e) : (s.endsWith(" ") ? "" : " ") + t,
|
|
640
|
+
` + F(t, e) : (s.endsWith(" ") ? "" : " ") + t, Vt = "flow", Xe = "block", $e = "quoted";
|
|
637
641
|
function Be(s, e, t = "flow", { indentAtStart: n, lineWidth: i = 80, minContentWidth: r = 20, onFold: o, onOverflow: a } = {}) {
|
|
638
642
|
if (!i || i < 0)
|
|
639
643
|
return s;
|
|
@@ -644,11 +648,11 @@ function Be(s, e, t = "flow", { indentAtStart: n, lineWidth: i = 80, minContentW
|
|
|
644
648
|
const c = [], d = {};
|
|
645
649
|
let u = i - e.length;
|
|
646
650
|
typeof n == "number" && (n > i - Math.max(2, r) ? c.push(0) : u = i - n);
|
|
647
|
-
let f,
|
|
648
|
-
t === Xe && (h =
|
|
651
|
+
let f, p, g = !1, h = -1, m = -1, b = -1;
|
|
652
|
+
t === Xe && (h = St(s, h, e.length), h !== -1 && (u = h + l));
|
|
649
653
|
for (let k; k = s[h += 1]; ) {
|
|
650
|
-
if (t ===
|
|
651
|
-
switch (
|
|
654
|
+
if (t === $e && k === "\\") {
|
|
655
|
+
switch (m = h, s[h + 1]) {
|
|
652
656
|
case "x":
|
|
653
657
|
h += 3;
|
|
654
658
|
break;
|
|
@@ -665,10 +669,10 @@ function Be(s, e, t = "flow", { indentAtStart: n, lineWidth: i = 80, minContentW
|
|
|
665
669
|
}
|
|
666
670
|
if (k === `
|
|
667
671
|
`)
|
|
668
|
-
t === Xe && (h =
|
|
672
|
+
t === Xe && (h = St(s, h, e.length)), u = h + e.length + l, f = void 0;
|
|
669
673
|
else {
|
|
670
|
-
if (k === " " &&
|
|
671
|
-
` &&
|
|
674
|
+
if (k === " " && p && p !== " " && p !== `
|
|
675
|
+
` && p !== " ") {
|
|
672
676
|
const S = s[h + 1];
|
|
673
677
|
S && S !== " " && S !== `
|
|
674
678
|
` && S !== " " && (f = h);
|
|
@@ -676,17 +680,17 @@ function Be(s, e, t = "flow", { indentAtStart: n, lineWidth: i = 80, minContentW
|
|
|
676
680
|
if (h >= u)
|
|
677
681
|
if (f)
|
|
678
682
|
c.push(f), u = f + l, f = void 0;
|
|
679
|
-
else if (t ===
|
|
680
|
-
for (;
|
|
681
|
-
|
|
682
|
-
const S = h > b + 1 ? h - 2 :
|
|
683
|
+
else if (t === $e) {
|
|
684
|
+
for (; p === " " || p === " "; )
|
|
685
|
+
p = k, k = s[h += 1], g = !0;
|
|
686
|
+
const S = h > b + 1 ? h - 2 : m - 1;
|
|
683
687
|
if (d[S])
|
|
684
688
|
return s;
|
|
685
689
|
c.push(S), d[S] = !0, u = S + l, f = void 0;
|
|
686
690
|
} else
|
|
687
691
|
g = !0;
|
|
688
692
|
}
|
|
689
|
-
|
|
693
|
+
p = k;
|
|
690
694
|
}
|
|
691
695
|
if (g && a && a(), c.length === 0)
|
|
692
696
|
return s;
|
|
@@ -695,12 +699,12 @@ function Be(s, e, t = "flow", { indentAtStart: n, lineWidth: i = 80, minContentW
|
|
|
695
699
|
for (let k = 0; k < c.length; ++k) {
|
|
696
700
|
const S = c[k], N = c[k + 1] || s.length;
|
|
697
701
|
S === 0 ? w = `
|
|
698
|
-
${e}${s.slice(0, N)}` : (t ===
|
|
702
|
+
${e}${s.slice(0, N)}` : (t === $e && d[S] && (w += `${s[S]}\\`), w += `
|
|
699
703
|
${e}${s.slice(S + 1, N)}`);
|
|
700
704
|
}
|
|
701
705
|
return w;
|
|
702
706
|
}
|
|
703
|
-
function
|
|
707
|
+
function St(s, e, t) {
|
|
704
708
|
let n = e, i = e + 1, r = s[i];
|
|
705
709
|
for (; r === " " || r === " "; )
|
|
706
710
|
if (e < i + t)
|
|
@@ -718,8 +722,8 @@ const Me = (s, e) => ({
|
|
|
718
722
|
indentAtStart: e ? s.indent.length : s.indentAtStart,
|
|
719
723
|
lineWidth: s.options.lineWidth,
|
|
720
724
|
minContentWidth: s.options.minContentWidth
|
|
721
|
-
}),
|
|
722
|
-
function
|
|
725
|
+
}), Pe = (s) => /^(%|---|\.\.\.)/m.test(s);
|
|
726
|
+
function Fs(s, e, t) {
|
|
723
727
|
if (!e || e < 0)
|
|
724
728
|
return !1;
|
|
725
729
|
const n = e - t, i = s.length;
|
|
@@ -735,11 +739,11 @@ function Ps(s, e, t) {
|
|
|
735
739
|
}
|
|
736
740
|
return !0;
|
|
737
741
|
}
|
|
738
|
-
function
|
|
742
|
+
function me(s, e) {
|
|
739
743
|
const t = JSON.stringify(s);
|
|
740
744
|
if (e.options.doubleQuotedAsJSON)
|
|
741
745
|
return t;
|
|
742
|
-
const { implicitKey: n } = e, i = e.options.doubleQuotedMinMultiLineLength, r = e.indent || (
|
|
746
|
+
const { implicitKey: n } = e, i = e.options.doubleQuotedMinMultiLineLength, r = e.indent || (Pe(s) ? " " : "");
|
|
743
747
|
let o = "", a = 0;
|
|
744
748
|
for (let l = 0, c = t[l]; c; c = t[++l])
|
|
745
749
|
if (c === " " && t[l + 1] === "\\" && t[l + 2] === "n" && (o += t.slice(a, l) + "\\ ", l += 1, a = l, c = "\\"), c === "\\")
|
|
@@ -794,24 +798,24 @@ function pe(s, e) {
|
|
|
794
798
|
default:
|
|
795
799
|
l += 1;
|
|
796
800
|
}
|
|
797
|
-
return o = a ? o + t.slice(a) : t, n ? o : Be(o, r,
|
|
801
|
+
return o = a ? o + t.slice(a) : t, n ? o : Be(o, r, $e, Me(e, !1));
|
|
798
802
|
}
|
|
799
803
|
function xe(s, e) {
|
|
800
804
|
if (e.options.singleQuote === !1 || e.implicitKey && s.includes(`
|
|
801
805
|
`) || /[ \t]\n|\n[ \t]/.test(s))
|
|
802
|
-
return
|
|
803
|
-
const t = e.indent || (
|
|
806
|
+
return me(s, e);
|
|
807
|
+
const t = e.indent || (Pe(s) ? " " : ""), n = "'" + s.replace(/'/g, "''").replace(/\n+/g, `$&
|
|
804
808
|
${t}`) + "'";
|
|
805
|
-
return e.implicitKey ? n : Be(n, t,
|
|
809
|
+
return e.implicitKey ? n : Be(n, t, Vt, Me(e, !1));
|
|
806
810
|
}
|
|
807
|
-
function
|
|
811
|
+
function se(s, e) {
|
|
808
812
|
const { singleQuote: t } = e.options;
|
|
809
813
|
let n;
|
|
810
814
|
if (t === !1)
|
|
811
|
-
n =
|
|
815
|
+
n = me;
|
|
812
816
|
else {
|
|
813
817
|
const i = s.includes('"'), r = s.includes("'");
|
|
814
|
-
i && !r ? n = xe : r && !i ? n =
|
|
818
|
+
i && !r ? n = xe : r && !i ? n = me : n = t ? xe : me;
|
|
815
819
|
}
|
|
816
820
|
return n(s, e);
|
|
817
821
|
}
|
|
@@ -824,11 +828,11 @@ try {
|
|
|
824
828
|
} catch {
|
|
825
829
|
ze = /\n+(?!\n|$)/g;
|
|
826
830
|
}
|
|
827
|
-
function
|
|
831
|
+
function Le({ comment: s, type: e, value: t }, n, i, r) {
|
|
828
832
|
const { blockQuote: o, commentString: a, lineWidth: l } = n.options;
|
|
829
833
|
if (!o || /\n[\t ]+$/.test(t))
|
|
830
|
-
return
|
|
831
|
-
const c = n.indent || (n.forceBlockIndent ||
|
|
834
|
+
return se(t, n);
|
|
835
|
+
const c = n.indent || (n.forceBlockIndent || Pe(t) ? " " : ""), d = o === "literal" ? !0 : o === "folded" || e === O.BLOCK_FOLDED ? !1 : e === O.BLOCK_LITERAL ? !0 : !Fs(t, l, c.length);
|
|
832
836
|
if (!t)
|
|
833
837
|
return d ? `|
|
|
834
838
|
` : `>
|
|
@@ -840,23 +844,23 @@ function $e({ comment: s, type: e, value: t }, n, i, r) {
|
|
|
840
844
|
` && N !== " " && N !== " ")
|
|
841
845
|
break;
|
|
842
846
|
}
|
|
843
|
-
let
|
|
844
|
-
const g =
|
|
847
|
+
let p = t.substring(f);
|
|
848
|
+
const g = p.indexOf(`
|
|
845
849
|
`);
|
|
846
|
-
g === -1 ? u = "-" : t ===
|
|
847
|
-
` && (
|
|
848
|
-
let h = !1,
|
|
849
|
-
for (
|
|
850
|
-
const N = t[
|
|
850
|
+
g === -1 ? u = "-" : t === p || g !== p.length - 1 ? (u = "+", r && r()) : u = "", p && (t = t.slice(0, -p.length), p[p.length - 1] === `
|
|
851
|
+
` && (p = p.slice(0, -1)), p = p.replace(ze, `$&${c}`));
|
|
852
|
+
let h = !1, m, b = -1;
|
|
853
|
+
for (m = 0; m < t.length; ++m) {
|
|
854
|
+
const N = t[m];
|
|
851
855
|
if (N === " ")
|
|
852
856
|
h = !0;
|
|
853
857
|
else if (N === `
|
|
854
858
|
`)
|
|
855
|
-
b =
|
|
859
|
+
b = m;
|
|
856
860
|
else
|
|
857
861
|
break;
|
|
858
862
|
}
|
|
859
|
-
let w = t.substring(0, b <
|
|
863
|
+
let w = t.substring(0, b < m ? b + 1 : m);
|
|
860
864
|
w && (t = t.substring(w.length), w = w.replace(/\n+/g, `$&${c}`));
|
|
861
865
|
let S = (h ? c ? "2" : "1" : "") + u;
|
|
862
866
|
if (s && (S += " " + a(s.replace(/ ?[\r\n]+/g, " ")), i && i()), !d) {
|
|
@@ -867,41 +871,41 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/
|
|
|
867
871
|
o !== "folded" && e !== O.BLOCK_FOLDED && (E.onOverflow = () => {
|
|
868
872
|
A = !0;
|
|
869
873
|
});
|
|
870
|
-
const y = Be(`${w}${N}${
|
|
874
|
+
const y = Be(`${w}${N}${p}`, c, Xe, E);
|
|
871
875
|
if (!A)
|
|
872
876
|
return `>${S}
|
|
873
877
|
${c}${y}`;
|
|
874
878
|
}
|
|
875
879
|
return t = t.replace(/\n+/g, `$&${c}`), `|${S}
|
|
876
|
-
${c}${w}${t}${
|
|
880
|
+
${c}${w}${t}${p}`;
|
|
877
881
|
}
|
|
878
|
-
function
|
|
882
|
+
function Rs(s, e, t, n) {
|
|
879
883
|
const { type: i, value: r } = s, { actualString: o, implicitKey: a, indent: l, indentStep: c, inFlow: d } = e;
|
|
880
884
|
if (a && r.includes(`
|
|
881
885
|
`) || d && /[[\]{},]/.test(r))
|
|
882
|
-
return
|
|
886
|
+
return se(r, e);
|
|
883
887
|
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))
|
|
884
888
|
return a || d || !r.includes(`
|
|
885
|
-
`) ?
|
|
889
|
+
`) ? se(r, e) : Le(s, e, t, n);
|
|
886
890
|
if (!a && !d && i !== O.PLAIN && r.includes(`
|
|
887
891
|
`))
|
|
888
|
-
return
|
|
889
|
-
if (
|
|
892
|
+
return Le(s, e, t, n);
|
|
893
|
+
if (Pe(r)) {
|
|
890
894
|
if (l === "")
|
|
891
|
-
return e.forceBlockIndent = !0,
|
|
895
|
+
return e.forceBlockIndent = !0, Le(s, e, t, n);
|
|
892
896
|
if (a && l === c)
|
|
893
|
-
return
|
|
897
|
+
return se(r, e);
|
|
894
898
|
}
|
|
895
899
|
const u = r.replace(/\n+/g, `$&
|
|
896
900
|
${l}`);
|
|
897
901
|
if (o) {
|
|
898
|
-
const f = (h) => h.default && h.tag !== "tag:yaml.org,2002:str" && h.test?.test(u), { compat:
|
|
899
|
-
if (g.some(f) ||
|
|
900
|
-
return
|
|
902
|
+
const f = (h) => h.default && h.tag !== "tag:yaml.org,2002:str" && h.test?.test(u), { compat: p, tags: g } = e.doc.schema;
|
|
903
|
+
if (g.some(f) || p?.some(f))
|
|
904
|
+
return se(r, e);
|
|
901
905
|
}
|
|
902
|
-
return a ? u : Be(u, l,
|
|
906
|
+
return a ? u : Be(u, l, Vt, Me(e, !1));
|
|
903
907
|
}
|
|
904
|
-
function
|
|
908
|
+
function at(s, e, t, n) {
|
|
905
909
|
const { implicitKey: i, inFlow: r } = e, o = typeof s.value == "string" ? s : Object.assign({}, s, { value: String(s.value) });
|
|
906
910
|
let { type: a } = s;
|
|
907
911
|
a !== O.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value) && (a = O.QUOTE_DOUBLE);
|
|
@@ -909,13 +913,13 @@ function ot(s, e, t, n) {
|
|
|
909
913
|
switch (d) {
|
|
910
914
|
case O.BLOCK_FOLDED:
|
|
911
915
|
case O.BLOCK_LITERAL:
|
|
912
|
-
return i || r ?
|
|
916
|
+
return i || r ? se(o.value, e) : Le(o, e, t, n);
|
|
913
917
|
case O.QUOTE_DOUBLE:
|
|
914
|
-
return
|
|
918
|
+
return me(o.value, e);
|
|
915
919
|
case O.QUOTE_SINGLE:
|
|
916
920
|
return xe(o.value, e);
|
|
917
921
|
case O.PLAIN:
|
|
918
|
-
return
|
|
922
|
+
return Rs(o, e, t, n);
|
|
919
923
|
default:
|
|
920
924
|
return null;
|
|
921
925
|
}
|
|
@@ -928,10 +932,10 @@ function ot(s, e, t, n) {
|
|
|
928
932
|
}
|
|
929
933
|
return c;
|
|
930
934
|
}
|
|
931
|
-
function
|
|
935
|
+
function Jt(s, e) {
|
|
932
936
|
const t = Object.assign({
|
|
933
937
|
blockQuote: !0,
|
|
934
|
-
commentString:
|
|
938
|
+
commentString: Us,
|
|
935
939
|
defaultKeyType: null,
|
|
936
940
|
defaultStringType: "PLAIN",
|
|
937
941
|
directives: null,
|
|
@@ -969,7 +973,7 @@ function qt(s, e) {
|
|
|
969
973
|
options: t
|
|
970
974
|
};
|
|
971
975
|
}
|
|
972
|
-
function
|
|
976
|
+
function qs(s, e) {
|
|
973
977
|
if (e.tag) {
|
|
974
978
|
const i = s.filter((r) => r.tag === e.tag);
|
|
975
979
|
if (i.length > 0)
|
|
@@ -992,15 +996,15 @@ function Ds(s, e) {
|
|
|
992
996
|
}
|
|
993
997
|
return t;
|
|
994
998
|
}
|
|
995
|
-
function
|
|
999
|
+
function Vs(s, e, { anchors: t, doc: n }) {
|
|
996
1000
|
if (!n.directives)
|
|
997
1001
|
return "";
|
|
998
1002
|
const i = [], r = (T(s) || I(s)) && s.anchor;
|
|
999
|
-
r &&
|
|
1003
|
+
r && Dt(r) && (t.add(r), i.push(`&${r}`));
|
|
1000
1004
|
const o = s.tag ?? (e.default ? null : e.tag);
|
|
1001
1005
|
return o && i.push(n.directives.tagString(o)), i.join(" ");
|
|
1002
1006
|
}
|
|
1003
|
-
function
|
|
1007
|
+
function re(s, e, t, n) {
|
|
1004
1008
|
if (L(s))
|
|
1005
1009
|
return s.toString(e, t, n);
|
|
1006
1010
|
if (Q(s)) {
|
|
@@ -1012,14 +1016,14 @@ function ie(s, e, t, n) {
|
|
|
1012
1016
|
}
|
|
1013
1017
|
let i;
|
|
1014
1018
|
const r = $(s) ? s : e.doc.createNode(s, { onTagObj: (l) => i = l });
|
|
1015
|
-
i ?? (i =
|
|
1016
|
-
const o =
|
|
1019
|
+
i ?? (i = qs(e.doc.schema.tags, r));
|
|
1020
|
+
const o = Vs(r, i, e);
|
|
1017
1021
|
o.length > 0 && (e.indentAtStart = (e.indentAtStart ?? 0) + o.length + 1);
|
|
1018
|
-
const a = typeof i.stringify == "function" ? i.stringify(r, e, t, n) : T(r) ?
|
|
1022
|
+
const a = typeof i.stringify == "function" ? i.stringify(r, e, t, n) : T(r) ? at(r, e, t, n) : r.toString(e, t, n);
|
|
1019
1023
|
return o ? T(r) || a[0] === "{" || a[0] === "[" ? `${o} ${a}` : `${o}
|
|
1020
1024
|
${e.indent}${a}` : a;
|
|
1021
1025
|
}
|
|
1022
|
-
function
|
|
1026
|
+
function Js({ key: s, value: e }, t, n, i) {
|
|
1023
1027
|
const { allNullValues: r, doc: o, indent: a, indentStep: l, options: { commentString: c, indentSeq: d, simpleKeys: u } } = t;
|
|
1024
1028
|
let f = $(s) && s.comment || null;
|
|
1025
1029
|
if (u) {
|
|
@@ -1030,29 +1034,29 @@ function Fs({ key: s, value: e }, t, n, i) {
|
|
|
1030
1034
|
throw new Error(E);
|
|
1031
1035
|
}
|
|
1032
1036
|
}
|
|
1033
|
-
let
|
|
1037
|
+
let p = !u && (!s || f && e == null && !t.inFlow || I(s) || (T(s) ? s.type === O.BLOCK_FOLDED || s.type === O.BLOCK_LITERAL : typeof s == "object"));
|
|
1034
1038
|
t = Object.assign({}, t, {
|
|
1035
1039
|
allNullValues: !1,
|
|
1036
|
-
implicitKey: !
|
|
1040
|
+
implicitKey: !p && (u || !r),
|
|
1037
1041
|
indent: a + l
|
|
1038
1042
|
});
|
|
1039
|
-
let g = !1, h = !1,
|
|
1040
|
-
if (!
|
|
1043
|
+
let g = !1, h = !1, m = re(s, t, () => g = !0, () => h = !0);
|
|
1044
|
+
if (!p && !t.inFlow && m.length > 1024) {
|
|
1041
1045
|
if (u)
|
|
1042
1046
|
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
1043
|
-
|
|
1047
|
+
p = !0;
|
|
1044
1048
|
}
|
|
1045
1049
|
if (t.inFlow) {
|
|
1046
1050
|
if (r || e == null)
|
|
1047
|
-
return g && n && n(),
|
|
1048
|
-
} else if (r && !u || e == null &&
|
|
1049
|
-
return
|
|
1050
|
-
g && (f = null),
|
|
1051
|
-
${a}:`) : (
|
|
1051
|
+
return g && n && n(), m === "" ? "?" : p ? `? ${m}` : m;
|
|
1052
|
+
} else if (r && !u || e == null && p)
|
|
1053
|
+
return m = `? ${m}`, f && !g ? m += G(m, t.indent, c(f)) : h && i && i(), m;
|
|
1054
|
+
g && (f = null), p ? (f && (m += G(m, t.indent, c(f))), m = `? ${m}
|
|
1055
|
+
${a}:`) : (m = `${m}:`, f && (m += G(m, t.indent, c(f))));
|
|
1052
1056
|
let b, w, k;
|
|
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, !
|
|
1057
|
+
$(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, !p && !f && T(e) && (t.indentAtStart = m.length + 1), h = !1, !d && l.length >= 2 && !t.inFlow && !p && we(e) && !e.flow && !e.tag && !e.anchor && (t.indent = t.indent.substring(2));
|
|
1054
1058
|
let S = !1;
|
|
1055
|
-
const N =
|
|
1059
|
+
const N = re(e, t, () => S = !0, () => h = !0);
|
|
1056
1060
|
let A = " ";
|
|
1057
1061
|
if (f || b || w) {
|
|
1058
1062
|
if (A = b ? `
|
|
@@ -1066,10 +1070,10 @@ ${F(E, t.indent)}`;
|
|
|
1066
1070
|
|
|
1067
1071
|
`) : A += `
|
|
1068
1072
|
${t.indent}`;
|
|
1069
|
-
} else if (!
|
|
1073
|
+
} else if (!p && I(e)) {
|
|
1070
1074
|
const E = N[0], y = N.indexOf(`
|
|
1071
|
-
`), v = y !== -1,
|
|
1072
|
-
if (v || !
|
|
1075
|
+
`), v = y !== -1, q = t.inFlow ?? e.flow ?? e.items.length === 0;
|
|
1076
|
+
if (v || !q) {
|
|
1073
1077
|
let X = !1;
|
|
1074
1078
|
if (v && (E === "&" || E === "!")) {
|
|
1075
1079
|
let C = N.indexOf(" ");
|
|
@@ -1080,23 +1084,23 @@ ${t.indent}`);
|
|
|
1080
1084
|
}
|
|
1081
1085
|
} else (N === "" || N[0] === `
|
|
1082
1086
|
`) && (A = "");
|
|
1083
|
-
return
|
|
1087
|
+
return m += A + N, t.inFlow ? S && n && n() : k && !S ? m += G(m, t.indent, c(k)) : h && i && i(), m;
|
|
1084
1088
|
}
|
|
1085
|
-
function
|
|
1089
|
+
function Yt(s, e) {
|
|
1086
1090
|
(s === "debug" || s === "warn") && console.warn(e);
|
|
1087
1091
|
}
|
|
1088
|
-
const
|
|
1089
|
-
identify: (s) => s ===
|
|
1092
|
+
const Ne = "<<", R = {
|
|
1093
|
+
identify: (s) => s === Ne || typeof s == "symbol" && s.description === Ne,
|
|
1090
1094
|
default: "key",
|
|
1091
1095
|
tag: "tag:yaml.org,2002:merge",
|
|
1092
1096
|
test: /^<<$/,
|
|
1093
|
-
resolve: () => Object.assign(new O(Symbol(
|
|
1094
|
-
addToJSMap:
|
|
1097
|
+
resolve: () => Object.assign(new O(Symbol(Ne)), {
|
|
1098
|
+
addToJSMap: Gt
|
|
1095
1099
|
}),
|
|
1096
|
-
stringify: () =>
|
|
1097
|
-
},
|
|
1098
|
-
function
|
|
1099
|
-
if (t = s && Q(t) ? t.resolve(s.doc) : t,
|
|
1100
|
+
stringify: () => Ne
|
|
1101
|
+
}, Ys = (s, e) => (R.identify(e) || T(e) && (!e.type || e.type === O.PLAIN) && R.identify(e.value)) && s?.doc.schema.tags.some((t) => t.tag === R.tag && t.default);
|
|
1102
|
+
function Gt(s, e, t) {
|
|
1103
|
+
if (t = s && Q(t) ? t.resolve(s.doc) : t, we(t))
|
|
1100
1104
|
for (const n of t.items)
|
|
1101
1105
|
Ve(s, e, n);
|
|
1102
1106
|
else if (Array.isArray(t))
|
|
@@ -1107,7 +1111,7 @@ function Ut(s, e, t) {
|
|
|
1107
1111
|
}
|
|
1108
1112
|
function Ve(s, e, t) {
|
|
1109
1113
|
const n = s && Q(t) ? t.resolve(s.doc) : t;
|
|
1110
|
-
if (!
|
|
1114
|
+
if (!be(n))
|
|
1111
1115
|
throw new Error("Merge sources must be maps or map aliases");
|
|
1112
1116
|
const i = n.toJSON(null, s, Map);
|
|
1113
1117
|
for (const [r, o] of i)
|
|
@@ -1119,19 +1123,19 @@ function Ve(s, e, t) {
|
|
|
1119
1123
|
});
|
|
1120
1124
|
return e;
|
|
1121
1125
|
}
|
|
1122
|
-
function
|
|
1126
|
+
function Wt(s, e, { key: t, value: n }) {
|
|
1123
1127
|
if ($(t) && t.addToJSMap)
|
|
1124
1128
|
t.addToJSMap(s, e, n);
|
|
1125
|
-
else if (
|
|
1126
|
-
|
|
1129
|
+
else if (Ys(s, t))
|
|
1130
|
+
Gt(s, e, n);
|
|
1127
1131
|
else {
|
|
1128
|
-
const i =
|
|
1132
|
+
const i = M(t, "", s);
|
|
1129
1133
|
if (e instanceof Map)
|
|
1130
|
-
e.set(i,
|
|
1134
|
+
e.set(i, M(n, i, s));
|
|
1131
1135
|
else if (e instanceof Set)
|
|
1132
1136
|
e.add(i);
|
|
1133
1137
|
else {
|
|
1134
|
-
const r =
|
|
1138
|
+
const r = Gs(t, i, s), o = M(n, r, s);
|
|
1135
1139
|
r in e ? Object.defineProperty(e, r, {
|
|
1136
1140
|
value: o,
|
|
1137
1141
|
writable: !0,
|
|
@@ -1142,13 +1146,13 @@ function Rt(s, e, { key: t, value: n }) {
|
|
|
1142
1146
|
}
|
|
1143
1147
|
return e;
|
|
1144
1148
|
}
|
|
1145
|
-
function
|
|
1149
|
+
function Gs(s, e, t) {
|
|
1146
1150
|
if (e === null)
|
|
1147
1151
|
return "";
|
|
1148
1152
|
if (typeof e != "object")
|
|
1149
1153
|
return String(e);
|
|
1150
1154
|
if ($(s) && t?.doc) {
|
|
1151
|
-
const n =
|
|
1155
|
+
const n = Jt(t.doc, {});
|
|
1152
1156
|
n.anchors = /* @__PURE__ */ new Set();
|
|
1153
1157
|
for (const r of t.anchors.keys())
|
|
1154
1158
|
n.anchors.add(r.anchor);
|
|
@@ -1156,68 +1160,68 @@ function Rs(s, e, t) {
|
|
|
1156
1160
|
const i = s.toString(n);
|
|
1157
1161
|
if (!t.mapKeyWarned) {
|
|
1158
1162
|
let r = JSON.stringify(i);
|
|
1159
|
-
r.length > 40 && (r = r.substring(0, 36) + '..."'),
|
|
1163
|
+
r.length > 40 && (r = r.substring(0, 36) + '..."'), Yt(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;
|
|
1160
1164
|
}
|
|
1161
1165
|
return i;
|
|
1162
1166
|
}
|
|
1163
1167
|
return JSON.stringify(e);
|
|
1164
1168
|
}
|
|
1165
|
-
function
|
|
1166
|
-
const n =
|
|
1167
|
-
return new
|
|
1169
|
+
function lt(s, e, t) {
|
|
1170
|
+
const n = ge(s, void 0, t), i = ge(e, void 0, t);
|
|
1171
|
+
return new j(n, i);
|
|
1168
1172
|
}
|
|
1169
|
-
class
|
|
1173
|
+
class j {
|
|
1170
1174
|
constructor(e, t = null) {
|
|
1171
|
-
Object.defineProperty(this, P, { value:
|
|
1175
|
+
Object.defineProperty(this, P, { value: Pt }), this.key = e, this.value = t;
|
|
1172
1176
|
}
|
|
1173
1177
|
clone(e) {
|
|
1174
1178
|
let { key: t, value: n } = this;
|
|
1175
|
-
return $(t) && (t = t.clone(e)), $(n) && (n = n.clone(e)), new
|
|
1179
|
+
return $(t) && (t = t.clone(e)), $(n) && (n = n.clone(e)), new j(t, n);
|
|
1176
1180
|
}
|
|
1177
1181
|
toJSON(e, t) {
|
|
1178
1182
|
const n = t?.mapAsMap ? /* @__PURE__ */ new Map() : {};
|
|
1179
|
-
return
|
|
1183
|
+
return Wt(t, n, this);
|
|
1180
1184
|
}
|
|
1181
1185
|
toString(e, t, n) {
|
|
1182
|
-
return e?.doc ?
|
|
1186
|
+
return e?.doc ? Js(this, e, t, n) : JSON.stringify(this);
|
|
1183
1187
|
}
|
|
1184
1188
|
}
|
|
1185
|
-
function
|
|
1186
|
-
return (e.inFlow ?? s.flow ?
|
|
1189
|
+
function Ht(s, e, t) {
|
|
1190
|
+
return (e.inFlow ?? s.flow ? Hs : Ws)(s, e, t);
|
|
1187
1191
|
}
|
|
1188
|
-
function
|
|
1192
|
+
function Ws({ comment: s, items: e }, t, { blockItemPrefix: n, flowChars: i, itemIndent: r, onChompKeep: o, onComment: a }) {
|
|
1189
1193
|
const { indent: l, options: { commentString: c } } = t, d = Object.assign({}, t, { indent: r, type: null });
|
|
1190
1194
|
let u = !1;
|
|
1191
1195
|
const f = [];
|
|
1192
1196
|
for (let g = 0; g < e.length; ++g) {
|
|
1193
1197
|
const h = e[g];
|
|
1194
|
-
let
|
|
1198
|
+
let m = null;
|
|
1195
1199
|
if ($(h))
|
|
1196
|
-
!u && h.spaceBefore && f.push(""),
|
|
1200
|
+
!u && h.spaceBefore && f.push(""), Ce(t, f, h.commentBefore, u), h.comment && (m = h.comment);
|
|
1197
1201
|
else if (L(h)) {
|
|
1198
1202
|
const w = $(h.key) ? h.key : null;
|
|
1199
|
-
w && (!u && w.spaceBefore && f.push(""),
|
|
1203
|
+
w && (!u && w.spaceBefore && f.push(""), Ce(t, f, w.commentBefore, u));
|
|
1200
1204
|
}
|
|
1201
1205
|
u = !1;
|
|
1202
|
-
let b =
|
|
1203
|
-
|
|
1206
|
+
let b = re(h, d, () => m = null, () => u = !0);
|
|
1207
|
+
m && (b += G(b, r, c(m))), u && m && (u = !1), f.push(n + b);
|
|
1204
1208
|
}
|
|
1205
|
-
let
|
|
1209
|
+
let p;
|
|
1206
1210
|
if (f.length === 0)
|
|
1207
|
-
|
|
1211
|
+
p = i.start + i.end;
|
|
1208
1212
|
else {
|
|
1209
|
-
|
|
1213
|
+
p = f[0];
|
|
1210
1214
|
for (let g = 1; g < f.length; ++g) {
|
|
1211
1215
|
const h = f[g];
|
|
1212
|
-
|
|
1216
|
+
p += h ? `
|
|
1213
1217
|
${l}${h}` : `
|
|
1214
1218
|
`;
|
|
1215
1219
|
}
|
|
1216
1220
|
}
|
|
1217
|
-
return s ? (
|
|
1218
|
-
` + F(c(s), l), a && a()) : u && o && o(),
|
|
1221
|
+
return s ? (p += `
|
|
1222
|
+
` + F(c(s), l), a && a()) : u && o && o(), p;
|
|
1219
1223
|
}
|
|
1220
|
-
function
|
|
1224
|
+
function Hs({ items: s }, e, { flowChars: t, itemIndent: n }) {
|
|
1221
1225
|
const { indent: i, indentStep: r, flowCollectionPadding: o, options: { commentString: a } } = e;
|
|
1222
1226
|
n += r;
|
|
1223
1227
|
const l = Object.assign({}, e, {
|
|
@@ -1229,25 +1233,25 @@ function Js({ items: s }, e, { flowChars: t, itemIndent: n }) {
|
|
|
1229
1233
|
const u = [];
|
|
1230
1234
|
for (let g = 0; g < s.length; ++g) {
|
|
1231
1235
|
const h = s[g];
|
|
1232
|
-
let
|
|
1236
|
+
let m = null;
|
|
1233
1237
|
if ($(h))
|
|
1234
|
-
h.spaceBefore && u.push(""),
|
|
1238
|
+
h.spaceBefore && u.push(""), Ce(e, u, h.commentBefore, !1), h.comment && (m = h.comment);
|
|
1235
1239
|
else if (L(h)) {
|
|
1236
1240
|
const w = $(h.key) ? h.key : null;
|
|
1237
|
-
w && (w.spaceBefore && u.push(""),
|
|
1241
|
+
w && (w.spaceBefore && u.push(""), Ce(e, u, w.commentBefore, !1), w.comment && (c = !0));
|
|
1238
1242
|
const k = $(h.value) ? h.value : null;
|
|
1239
|
-
k ? (k.comment && (
|
|
1243
|
+
k ? (k.comment && (m = k.comment), k.commentBefore && (c = !0)) : h.value == null && w?.comment && (m = w.comment);
|
|
1240
1244
|
}
|
|
1241
|
-
|
|
1242
|
-
let b =
|
|
1243
|
-
g < s.length - 1 && (b += ","),
|
|
1245
|
+
m && (c = !0);
|
|
1246
|
+
let b = re(h, l, () => m = null);
|
|
1247
|
+
g < s.length - 1 && (b += ","), m && (b += G(b, n, a(m))), !c && (u.length > d || b.includes(`
|
|
1244
1248
|
`)) && (c = !0), u.push(b), d = u.length;
|
|
1245
1249
|
}
|
|
1246
|
-
const { start: f, end:
|
|
1250
|
+
const { start: f, end: p } = t;
|
|
1247
1251
|
if (u.length === 0)
|
|
1248
|
-
return f +
|
|
1252
|
+
return f + p;
|
|
1249
1253
|
if (!c) {
|
|
1250
|
-
const g = u.reduce((h,
|
|
1254
|
+
const g = u.reduce((h, m) => h + m.length + 2, 2);
|
|
1251
1255
|
c = e.options.lineWidth > 0 && g > e.options.lineWidth;
|
|
1252
1256
|
}
|
|
1253
1257
|
if (c) {
|
|
@@ -1257,23 +1261,23 @@ function Js({ items: s }, e, { flowChars: t, itemIndent: n }) {
|
|
|
1257
1261
|
${r}${i}${h}` : `
|
|
1258
1262
|
`;
|
|
1259
1263
|
return `${g}
|
|
1260
|
-
${i}${
|
|
1264
|
+
${i}${p}`;
|
|
1261
1265
|
} else
|
|
1262
|
-
return `${f}${o}${u.join(" ")}${o}${
|
|
1266
|
+
return `${f}${o}${u.join(" ")}${o}${p}`;
|
|
1263
1267
|
}
|
|
1264
|
-
function
|
|
1268
|
+
function Ce({ indent: s, options: { commentString: e } }, t, n, i) {
|
|
1265
1269
|
if (n && i && (n = n.replace(/^\n+/, "")), n) {
|
|
1266
1270
|
const r = F(e(n), s);
|
|
1267
1271
|
t.push(r.trimStart());
|
|
1268
1272
|
}
|
|
1269
1273
|
}
|
|
1270
|
-
function
|
|
1274
|
+
function W(s, e) {
|
|
1271
1275
|
const t = T(e) ? e.value : e;
|
|
1272
1276
|
for (const n of s)
|
|
1273
1277
|
if (L(n) && (n.key === e || n.key === t || T(n.key) && n.key.value === t))
|
|
1274
1278
|
return n;
|
|
1275
1279
|
}
|
|
1276
|
-
class
|
|
1280
|
+
class B extends qt {
|
|
1277
1281
|
static get tagName() {
|
|
1278
1282
|
return "tag:yaml.org,2002:map";
|
|
1279
1283
|
}
|
|
@@ -1290,7 +1294,7 @@ class M extends Kt {
|
|
|
1290
1294
|
c = r.call(t, l, c);
|
|
1291
1295
|
else if (Array.isArray(r) && !r.includes(l))
|
|
1292
1296
|
return;
|
|
1293
|
-
(c !== void 0 || i) && o.items.push(
|
|
1297
|
+
(c !== void 0 || i) && o.items.push(lt(l, c, n));
|
|
1294
1298
|
};
|
|
1295
1299
|
if (t instanceof Map)
|
|
1296
1300
|
for (const [l, c] of t)
|
|
@@ -1308,12 +1312,12 @@ class M extends Kt {
|
|
|
1308
1312
|
*/
|
|
1309
1313
|
add(e, t) {
|
|
1310
1314
|
let n;
|
|
1311
|
-
L(e) ? n = e : !e || typeof e != "object" || !("key" in e) ? n = new
|
|
1312
|
-
const i =
|
|
1315
|
+
L(e) ? n = e : !e || typeof e != "object" || !("key" in e) ? n = new j(e, e?.value) : n = new j(e.key, e.value);
|
|
1316
|
+
const i = W(this.items, n.key), r = this.schema?.sortMapEntries;
|
|
1313
1317
|
if (i) {
|
|
1314
1318
|
if (!t)
|
|
1315
1319
|
throw new Error(`Key ${n.key} already set`);
|
|
1316
|
-
T(i.value) &&
|
|
1320
|
+
T(i.value) && Rt(n.value) ? i.value.value = n.value : i.value = n.value;
|
|
1317
1321
|
} else if (r) {
|
|
1318
1322
|
const o = this.items.findIndex((a) => r(n, a) < 0);
|
|
1319
1323
|
o === -1 ? this.items.push(n) : this.items.splice(o, 0, n);
|
|
@@ -1321,18 +1325,18 @@ class M extends Kt {
|
|
|
1321
1325
|
this.items.push(n);
|
|
1322
1326
|
}
|
|
1323
1327
|
delete(e) {
|
|
1324
|
-
const t =
|
|
1328
|
+
const t = W(this.items, e);
|
|
1325
1329
|
return t ? this.items.splice(this.items.indexOf(t), 1).length > 0 : !1;
|
|
1326
1330
|
}
|
|
1327
1331
|
get(e, t) {
|
|
1328
|
-
const i =
|
|
1332
|
+
const i = W(this.items, e)?.value;
|
|
1329
1333
|
return (!t && T(i) ? i.value : i) ?? void 0;
|
|
1330
1334
|
}
|
|
1331
1335
|
has(e) {
|
|
1332
|
-
return !!
|
|
1336
|
+
return !!W(this.items, e);
|
|
1333
1337
|
}
|
|
1334
1338
|
set(e, t) {
|
|
1335
|
-
this.add(new
|
|
1339
|
+
this.add(new j(e, t), !0);
|
|
1336
1340
|
}
|
|
1337
1341
|
/**
|
|
1338
1342
|
* @param ctx - Conversion context, originally set in Document#toJS()
|
|
@@ -1343,7 +1347,7 @@ class M extends Kt {
|
|
|
1343
1347
|
const i = n ? new n() : t?.mapAsMap ? /* @__PURE__ */ new Map() : {};
|
|
1344
1348
|
t?.onCreate && t.onCreate(i);
|
|
1345
1349
|
for (const r of this.items)
|
|
1346
|
-
|
|
1350
|
+
Wt(t, i, r);
|
|
1347
1351
|
return i;
|
|
1348
1352
|
}
|
|
1349
1353
|
toString(e, t, n) {
|
|
@@ -1352,7 +1356,7 @@ class M extends Kt {
|
|
|
1352
1356
|
for (const i of this.items)
|
|
1353
1357
|
if (!L(i))
|
|
1354
1358
|
throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);
|
|
1355
|
-
return !e.allNullValues && this.hasAllNullValues(!1) && (e = Object.assign({}, e, { allNullValues: !0 })),
|
|
1359
|
+
return !e.allNullValues && this.hasAllNullValues(!1) && (e = Object.assign({}, e, { allNullValues: !0 })), Ht(this, e, {
|
|
1356
1360
|
blockItemPrefix: "",
|
|
1357
1361
|
flowChars: { start: "{", end: "}" },
|
|
1358
1362
|
itemIndent: e.indent || "",
|
|
@@ -1361,22 +1365,22 @@ class M extends Kt {
|
|
|
1361
1365
|
});
|
|
1362
1366
|
}
|
|
1363
1367
|
}
|
|
1364
|
-
const
|
|
1368
|
+
const ce = {
|
|
1365
1369
|
collection: "map",
|
|
1366
1370
|
default: !0,
|
|
1367
|
-
nodeClass:
|
|
1371
|
+
nodeClass: B,
|
|
1368
1372
|
tag: "tag:yaml.org,2002:map",
|
|
1369
1373
|
resolve(s, e) {
|
|
1370
|
-
return
|
|
1374
|
+
return be(s) || e("Expected a mapping for this tag"), s;
|
|
1371
1375
|
},
|
|
1372
|
-
createNode: (s, e, t) =>
|
|
1376
|
+
createNode: (s, e, t) => B.from(s, e, t)
|
|
1373
1377
|
};
|
|
1374
|
-
class
|
|
1378
|
+
class H extends qt {
|
|
1375
1379
|
static get tagName() {
|
|
1376
1380
|
return "tag:yaml.org,2002:seq";
|
|
1377
1381
|
}
|
|
1378
1382
|
constructor(e) {
|
|
1379
|
-
super(
|
|
1383
|
+
super(ae, e), this.items = [];
|
|
1380
1384
|
}
|
|
1381
1385
|
add(e) {
|
|
1382
1386
|
this.items.push(e);
|
|
@@ -1390,11 +1394,11 @@ class W extends Kt {
|
|
|
1390
1394
|
* @returns `true` if the item was found and removed.
|
|
1391
1395
|
*/
|
|
1392
1396
|
delete(e) {
|
|
1393
|
-
const t =
|
|
1397
|
+
const t = Oe(e);
|
|
1394
1398
|
return typeof t != "number" ? !1 : this.items.splice(t, 1).length > 0;
|
|
1395
1399
|
}
|
|
1396
1400
|
get(e, t) {
|
|
1397
|
-
const n =
|
|
1401
|
+
const n = Oe(e);
|
|
1398
1402
|
if (typeof n != "number")
|
|
1399
1403
|
return;
|
|
1400
1404
|
const i = this.items[n];
|
|
@@ -1407,7 +1411,7 @@ class W extends Kt {
|
|
|
1407
1411
|
* It may be wrapped in a `Scalar`.
|
|
1408
1412
|
*/
|
|
1409
1413
|
has(e) {
|
|
1410
|
-
const t =
|
|
1414
|
+
const t = Oe(e);
|
|
1411
1415
|
return typeof t == "number" && t < this.items.length;
|
|
1412
1416
|
}
|
|
1413
1417
|
/**
|
|
@@ -1418,22 +1422,22 @@ class W extends Kt {
|
|
|
1418
1422
|
* It may be wrapped in a `Scalar`.
|
|
1419
1423
|
*/
|
|
1420
1424
|
set(e, t) {
|
|
1421
|
-
const n =
|
|
1425
|
+
const n = Oe(e);
|
|
1422
1426
|
if (typeof n != "number")
|
|
1423
1427
|
throw new Error(`Expected a valid index, not ${e}.`);
|
|
1424
1428
|
const i = this.items[n];
|
|
1425
|
-
T(i) &&
|
|
1429
|
+
T(i) && Rt(t) ? i.value = t : this.items[n] = t;
|
|
1426
1430
|
}
|
|
1427
1431
|
toJSON(e, t) {
|
|
1428
1432
|
const n = [];
|
|
1429
1433
|
t?.onCreate && t.onCreate(n);
|
|
1430
1434
|
let i = 0;
|
|
1431
1435
|
for (const r of this.items)
|
|
1432
|
-
n.push(
|
|
1436
|
+
n.push(M(r, String(i++), t));
|
|
1433
1437
|
return n;
|
|
1434
1438
|
}
|
|
1435
1439
|
toString(e, t, n) {
|
|
1436
|
-
return e ?
|
|
1440
|
+
return e ? Ht(this, e, {
|
|
1437
1441
|
blockItemPrefix: "- ",
|
|
1438
1442
|
flowChars: { start: "[", end: "]" },
|
|
1439
1443
|
itemIndent: (e.indent || "") + " ",
|
|
@@ -1450,49 +1454,49 @@ class W extends Kt {
|
|
|
1450
1454
|
const l = t instanceof Set ? a : String(o++);
|
|
1451
1455
|
a = i.call(t, l, a);
|
|
1452
1456
|
}
|
|
1453
|
-
r.items.push(
|
|
1457
|
+
r.items.push(ge(a, void 0, n));
|
|
1454
1458
|
}
|
|
1455
1459
|
}
|
|
1456
1460
|
return r;
|
|
1457
1461
|
}
|
|
1458
1462
|
}
|
|
1459
|
-
function
|
|
1463
|
+
function Oe(s) {
|
|
1460
1464
|
let e = T(s) ? s.value : s;
|
|
1461
1465
|
return e && typeof e == "string" && (e = Number(e)), typeof e == "number" && Number.isInteger(e) && e >= 0 ? e : null;
|
|
1462
1466
|
}
|
|
1463
|
-
const
|
|
1467
|
+
const fe = {
|
|
1464
1468
|
collection: "seq",
|
|
1465
1469
|
default: !0,
|
|
1466
|
-
nodeClass:
|
|
1470
|
+
nodeClass: H,
|
|
1467
1471
|
tag: "tag:yaml.org,2002:seq",
|
|
1468
1472
|
resolve(s, e) {
|
|
1469
|
-
return
|
|
1473
|
+
return we(s) || e("Expected a sequence for this tag"), s;
|
|
1470
1474
|
},
|
|
1471
|
-
createNode: (s, e, t) =>
|
|
1472
|
-
},
|
|
1475
|
+
createNode: (s, e, t) => H.from(s, e, t)
|
|
1476
|
+
}, Ke = {
|
|
1473
1477
|
identify: (s) => typeof s == "string",
|
|
1474
1478
|
default: !0,
|
|
1475
1479
|
tag: "tag:yaml.org,2002:str",
|
|
1476
1480
|
resolve: (s) => s,
|
|
1477
1481
|
stringify(s, e, t, n) {
|
|
1478
|
-
return e = Object.assign({ actualString: !0 }, e),
|
|
1482
|
+
return e = Object.assign({ actualString: !0 }, e), at(s, e, t, n);
|
|
1479
1483
|
}
|
|
1480
|
-
},
|
|
1484
|
+
}, De = {
|
|
1481
1485
|
identify: (s) => s == null,
|
|
1482
1486
|
createNode: () => new O(null),
|
|
1483
1487
|
default: !0,
|
|
1484
1488
|
tag: "tag:yaml.org,2002:null",
|
|
1485
1489
|
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
1486
1490
|
resolve: () => new O(null),
|
|
1487
|
-
stringify: ({ source: s }, e) => typeof s == "string" &&
|
|
1488
|
-
},
|
|
1491
|
+
stringify: ({ source: s }, e) => typeof s == "string" && De.test.test(s) ? s : e.options.nullStr
|
|
1492
|
+
}, ct = {
|
|
1489
1493
|
identify: (s) => typeof s == "boolean",
|
|
1490
1494
|
default: !0,
|
|
1491
1495
|
tag: "tag:yaml.org,2002:bool",
|
|
1492
1496
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
1493
1497
|
resolve: (s) => new O(s[0] === "t" || s[0] === "T"),
|
|
1494
1498
|
stringify({ source: s, value: e }, t) {
|
|
1495
|
-
if (s &&
|
|
1499
|
+
if (s && ct.test.test(s)) {
|
|
1496
1500
|
const n = s[0] === "t" || s[0] === "T";
|
|
1497
1501
|
if (e === n)
|
|
1498
1502
|
return s;
|
|
@@ -1516,14 +1520,14 @@ function D({ format: s, minFractionDigits: e, tag: t, value: n }) {
|
|
|
1516
1520
|
}
|
|
1517
1521
|
return r;
|
|
1518
1522
|
}
|
|
1519
|
-
const
|
|
1523
|
+
const Qt = {
|
|
1520
1524
|
identify: (s) => typeof s == "number",
|
|
1521
1525
|
default: !0,
|
|
1522
1526
|
tag: "tag:yaml.org,2002:float",
|
|
1523
1527
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
1524
1528
|
resolve: (s) => s.slice(-3).toLowerCase() === "nan" ? NaN : s[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
1525
1529
|
stringify: D
|
|
1526
|
-
},
|
|
1530
|
+
}, Xt = {
|
|
1527
1531
|
identify: (s) => typeof s == "number",
|
|
1528
1532
|
default: !0,
|
|
1529
1533
|
tag: "tag:yaml.org,2002:float",
|
|
@@ -1534,7 +1538,7 @@ const Jt = {
|
|
|
1534
1538
|
const e = Number(s.value);
|
|
1535
1539
|
return isFinite(e) ? e.toExponential() : D(s);
|
|
1536
1540
|
}
|
|
1537
|
-
},
|
|
1541
|
+
}, xt = {
|
|
1538
1542
|
identify: (s) => typeof s == "number",
|
|
1539
1543
|
default: !0,
|
|
1540
1544
|
tag: "tag:yaml.org,2002:float",
|
|
@@ -1544,57 +1548,57 @@ const Jt = {
|
|
|
1544
1548
|
return t !== -1 && s[s.length - 1] === "0" && (e.minFractionDigits = s.length - t - 1), e;
|
|
1545
1549
|
},
|
|
1546
1550
|
stringify: D
|
|
1547
|
-
},
|
|
1548
|
-
function
|
|
1551
|
+
}, Ue = (s) => typeof s == "bigint" || Number.isInteger(s), ft = (s, e, t, { intAsBigInt: n }) => n ? BigInt(s) : parseInt(s.substring(e), t);
|
|
1552
|
+
function zt(s, e, t) {
|
|
1549
1553
|
const { value: n } = s;
|
|
1550
|
-
return
|
|
1554
|
+
return Ue(n) && n >= 0 ? t + n.toString(e) : D(s);
|
|
1551
1555
|
}
|
|
1552
|
-
const
|
|
1553
|
-
identify: (s) =>
|
|
1556
|
+
const Zt = {
|
|
1557
|
+
identify: (s) => Ue(s) && s >= 0,
|
|
1554
1558
|
default: !0,
|
|
1555
1559
|
tag: "tag:yaml.org,2002:int",
|
|
1556
1560
|
format: "OCT",
|
|
1557
1561
|
test: /^0o[0-7]+$/,
|
|
1558
|
-
resolve: (s, e, t) =>
|
|
1559
|
-
stringify: (s) =>
|
|
1560
|
-
},
|
|
1561
|
-
identify:
|
|
1562
|
+
resolve: (s, e, t) => ft(s, 2, 8, t),
|
|
1563
|
+
stringify: (s) => zt(s, 8, "0o")
|
|
1564
|
+
}, es = {
|
|
1565
|
+
identify: Ue,
|
|
1562
1566
|
default: !0,
|
|
1563
1567
|
tag: "tag:yaml.org,2002:int",
|
|
1564
1568
|
test: /^[-+]?[0-9]+$/,
|
|
1565
|
-
resolve: (s, e, t) =>
|
|
1569
|
+
resolve: (s, e, t) => ft(s, 0, 10, t),
|
|
1566
1570
|
stringify: D
|
|
1567
|
-
},
|
|
1568
|
-
identify: (s) =>
|
|
1571
|
+
}, ts = {
|
|
1572
|
+
identify: (s) => Ue(s) && s >= 0,
|
|
1569
1573
|
default: !0,
|
|
1570
1574
|
tag: "tag:yaml.org,2002:int",
|
|
1571
1575
|
format: "HEX",
|
|
1572
1576
|
test: /^0x[0-9a-fA-F]+$/,
|
|
1573
|
-
resolve: (s, e, t) =>
|
|
1574
|
-
stringify: (s) =>
|
|
1575
|
-
},
|
|
1576
|
-
le,
|
|
1577
|
+
resolve: (s, e, t) => ft(s, 2, 16, t),
|
|
1578
|
+
stringify: (s) => zt(s, 16, "0x")
|
|
1579
|
+
}, Qs = [
|
|
1577
1580
|
ce,
|
|
1578
|
-
|
|
1581
|
+
fe,
|
|
1579
1582
|
Ke,
|
|
1580
|
-
|
|
1581
|
-
|
|
1583
|
+
De,
|
|
1584
|
+
ct,
|
|
1585
|
+
Zt,
|
|
1586
|
+
es,
|
|
1587
|
+
ts,
|
|
1582
1588
|
Qt,
|
|
1583
1589
|
Xt,
|
|
1584
|
-
|
|
1585
|
-
Yt,
|
|
1586
|
-
Gt
|
|
1590
|
+
xt
|
|
1587
1591
|
];
|
|
1588
|
-
function
|
|
1592
|
+
function Nt(s) {
|
|
1589
1593
|
return typeof s == "bigint" || Number.isInteger(s);
|
|
1590
1594
|
}
|
|
1591
|
-
const
|
|
1595
|
+
const Ae = ({ value: s }) => JSON.stringify(s), Xs = [
|
|
1592
1596
|
{
|
|
1593
1597
|
identify: (s) => typeof s == "string",
|
|
1594
1598
|
default: !0,
|
|
1595
1599
|
tag: "tag:yaml.org,2002:str",
|
|
1596
1600
|
resolve: (s) => s,
|
|
1597
|
-
stringify:
|
|
1601
|
+
stringify: Ae
|
|
1598
1602
|
},
|
|
1599
1603
|
{
|
|
1600
1604
|
identify: (s) => s == null,
|
|
@@ -1603,7 +1607,7 @@ const Oe = ({ value: s }) => JSON.stringify(s), Gs = [
|
|
|
1603
1607
|
tag: "tag:yaml.org,2002:null",
|
|
1604
1608
|
test: /^null$/,
|
|
1605
1609
|
resolve: () => null,
|
|
1606
|
-
stringify:
|
|
1610
|
+
stringify: Ae
|
|
1607
1611
|
},
|
|
1608
1612
|
{
|
|
1609
1613
|
identify: (s) => typeof s == "boolean",
|
|
@@ -1611,15 +1615,15 @@ const Oe = ({ value: s }) => JSON.stringify(s), Gs = [
|
|
|
1611
1615
|
tag: "tag:yaml.org,2002:bool",
|
|
1612
1616
|
test: /^true$|^false$/,
|
|
1613
1617
|
resolve: (s) => s === "true",
|
|
1614
|
-
stringify:
|
|
1618
|
+
stringify: Ae
|
|
1615
1619
|
},
|
|
1616
1620
|
{
|
|
1617
|
-
identify:
|
|
1621
|
+
identify: Nt,
|
|
1618
1622
|
default: !0,
|
|
1619
1623
|
tag: "tag:yaml.org,2002:int",
|
|
1620
1624
|
test: /^-?(?:0|[1-9][0-9]*)$/,
|
|
1621
1625
|
resolve: (s, e, { intAsBigInt: t }) => t ? BigInt(s) : parseInt(s, 10),
|
|
1622
|
-
stringify: ({ value: s }) =>
|
|
1626
|
+
stringify: ({ value: s }) => Nt(s) ? s.toString() : JSON.stringify(s)
|
|
1623
1627
|
},
|
|
1624
1628
|
{
|
|
1625
1629
|
identify: (s) => typeof s == "number",
|
|
@@ -1627,16 +1631,16 @@ const Oe = ({ value: s }) => JSON.stringify(s), Gs = [
|
|
|
1627
1631
|
tag: "tag:yaml.org,2002:float",
|
|
1628
1632
|
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
|
|
1629
1633
|
resolve: (s) => parseFloat(s),
|
|
1630
|
-
stringify:
|
|
1634
|
+
stringify: Ae
|
|
1631
1635
|
}
|
|
1632
|
-
],
|
|
1636
|
+
], xs = {
|
|
1633
1637
|
default: !0,
|
|
1634
1638
|
tag: "",
|
|
1635
1639
|
test: /^/,
|
|
1636
1640
|
resolve(s, e) {
|
|
1637
1641
|
return e(`Unresolved plain scalar ${JSON.stringify(s)}`), s;
|
|
1638
1642
|
}
|
|
1639
|
-
},
|
|
1643
|
+
}, zs = [ce, fe].concat(Xs, xs), ut = {
|
|
1640
1644
|
identify: (s) => s instanceof Uint8Array,
|
|
1641
1645
|
// Buffer inherits from Uint8Array
|
|
1642
1646
|
default: !1,
|
|
@@ -1677,17 +1681,17 @@ const Oe = ({ value: s }) => JSON.stringify(s), Gs = [
|
|
|
1677
1681
|
a = d.join(e === O.BLOCK_LITERAL ? `
|
|
1678
1682
|
` : " ");
|
|
1679
1683
|
}
|
|
1680
|
-
return
|
|
1684
|
+
return at({ comment: s, type: e, value: a }, n, i, r);
|
|
1681
1685
|
}
|
|
1682
1686
|
};
|
|
1683
|
-
function
|
|
1684
|
-
if (
|
|
1687
|
+
function ss(s, e) {
|
|
1688
|
+
if (we(s))
|
|
1685
1689
|
for (let t = 0; t < s.items.length; ++t) {
|
|
1686
1690
|
let n = s.items[t];
|
|
1687
1691
|
if (!L(n)) {
|
|
1688
|
-
if (
|
|
1692
|
+
if (be(n)) {
|
|
1689
1693
|
n.items.length > 1 && e("Each pair must have its own sequence indicator");
|
|
1690
|
-
const i = n.items[0] || new
|
|
1694
|
+
const i = n.items[0] || new j(new O(null));
|
|
1691
1695
|
if (n.commentBefore && (i.key.commentBefore = i.key.commentBefore ? `${n.commentBefore}
|
|
1692
1696
|
${i.key.commentBefore}` : n.commentBefore), n.comment) {
|
|
1693
1697
|
const r = i.value ?? i.key;
|
|
@@ -1696,15 +1700,15 @@ ${r.comment}` : n.comment;
|
|
|
1696
1700
|
}
|
|
1697
1701
|
n = i;
|
|
1698
1702
|
}
|
|
1699
|
-
s.items[t] = L(n) ? n : new
|
|
1703
|
+
s.items[t] = L(n) ? n : new j(n);
|
|
1700
1704
|
}
|
|
1701
1705
|
}
|
|
1702
1706
|
else
|
|
1703
1707
|
e("Expected a sequence for this tag");
|
|
1704
1708
|
return s;
|
|
1705
1709
|
}
|
|
1706
|
-
function
|
|
1707
|
-
const { replacer: n } = t, i = new
|
|
1710
|
+
function ns(s, e, t) {
|
|
1711
|
+
const { replacer: n } = t, i = new H(s);
|
|
1708
1712
|
i.tag = "tag:yaml.org,2002:pairs";
|
|
1709
1713
|
let r = 0;
|
|
1710
1714
|
if (e && Symbol.iterator in Object(e))
|
|
@@ -1724,20 +1728,20 @@ function zt(s, e, t) {
|
|
|
1724
1728
|
throw new TypeError(`Expected tuple with one key, not ${c.length} keys`);
|
|
1725
1729
|
} else
|
|
1726
1730
|
a = o;
|
|
1727
|
-
i.items.push(
|
|
1731
|
+
i.items.push(lt(a, l, t));
|
|
1728
1732
|
}
|
|
1729
1733
|
return i;
|
|
1730
1734
|
}
|
|
1731
|
-
const
|
|
1735
|
+
const ht = {
|
|
1732
1736
|
collection: "seq",
|
|
1733
1737
|
default: !1,
|
|
1734
1738
|
tag: "tag:yaml.org,2002:pairs",
|
|
1735
|
-
resolve:
|
|
1736
|
-
createNode:
|
|
1739
|
+
resolve: ss,
|
|
1740
|
+
createNode: ns
|
|
1737
1741
|
};
|
|
1738
|
-
class
|
|
1742
|
+
class ne extends H {
|
|
1739
1743
|
constructor() {
|
|
1740
|
-
super(), this.add =
|
|
1744
|
+
super(), this.add = B.prototype.add.bind(this), this.delete = B.prototype.delete.bind(this), this.get = B.prototype.get.bind(this), this.has = B.prototype.has.bind(this), this.set = B.prototype.set.bind(this), this.tag = ne.tag;
|
|
1741
1745
|
}
|
|
1742
1746
|
/**
|
|
1743
1747
|
* If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
|
|
@@ -1750,57 +1754,57 @@ class se extends W {
|
|
|
1750
1754
|
t?.onCreate && t.onCreate(n);
|
|
1751
1755
|
for (const i of this.items) {
|
|
1752
1756
|
let r, o;
|
|
1753
|
-
if (L(i) ? (r =
|
|
1757
|
+
if (L(i) ? (r = M(i.key, "", t), o = M(i.value, r, t)) : r = M(i, "", t), n.has(r))
|
|
1754
1758
|
throw new Error("Ordered maps must not include duplicate keys");
|
|
1755
1759
|
n.set(r, o);
|
|
1756
1760
|
}
|
|
1757
1761
|
return n;
|
|
1758
1762
|
}
|
|
1759
1763
|
static from(e, t, n) {
|
|
1760
|
-
const i =
|
|
1764
|
+
const i = ns(e, t, n), r = new this();
|
|
1761
1765
|
return r.items = i.items, r;
|
|
1762
1766
|
}
|
|
1763
1767
|
}
|
|
1764
|
-
|
|
1765
|
-
const
|
|
1768
|
+
ne.tag = "tag:yaml.org,2002:omap";
|
|
1769
|
+
const dt = {
|
|
1766
1770
|
collection: "seq",
|
|
1767
1771
|
identify: (s) => s instanceof Map,
|
|
1768
|
-
nodeClass:
|
|
1772
|
+
nodeClass: ne,
|
|
1769
1773
|
default: !1,
|
|
1770
1774
|
tag: "tag:yaml.org,2002:omap",
|
|
1771
1775
|
resolve(s, e) {
|
|
1772
|
-
const t =
|
|
1776
|
+
const t = ss(s, e), n = [];
|
|
1773
1777
|
for (const { key: i } of t.items)
|
|
1774
1778
|
T(i) && (n.includes(i.value) ? e(`Ordered maps must not include duplicate keys: ${i.value}`) : n.push(i.value));
|
|
1775
|
-
return Object.assign(new
|
|
1779
|
+
return Object.assign(new ne(), t);
|
|
1776
1780
|
},
|
|
1777
|
-
createNode: (s, e, t) =>
|
|
1781
|
+
createNode: (s, e, t) => ne.from(s, e, t)
|
|
1778
1782
|
};
|
|
1779
|
-
function
|
|
1780
|
-
return e && (s ?
|
|
1783
|
+
function is({ value: s, source: e }, t) {
|
|
1784
|
+
return e && (s ? rs : os).test.test(e) ? e : s ? t.options.trueStr : t.options.falseStr;
|
|
1781
1785
|
}
|
|
1782
|
-
const
|
|
1786
|
+
const rs = {
|
|
1783
1787
|
identify: (s) => s === !0,
|
|
1784
1788
|
default: !0,
|
|
1785
1789
|
tag: "tag:yaml.org,2002:bool",
|
|
1786
1790
|
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
1787
1791
|
resolve: () => new O(!0),
|
|
1788
|
-
stringify:
|
|
1789
|
-
},
|
|
1792
|
+
stringify: is
|
|
1793
|
+
}, os = {
|
|
1790
1794
|
identify: (s) => s === !1,
|
|
1791
1795
|
default: !0,
|
|
1792
1796
|
tag: "tag:yaml.org,2002:bool",
|
|
1793
1797
|
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
|
|
1794
1798
|
resolve: () => new O(!1),
|
|
1795
|
-
stringify:
|
|
1796
|
-
},
|
|
1799
|
+
stringify: is
|
|
1800
|
+
}, Zs = {
|
|
1797
1801
|
identify: (s) => typeof s == "number",
|
|
1798
1802
|
default: !0,
|
|
1799
1803
|
tag: "tag:yaml.org,2002:float",
|
|
1800
1804
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
1801
1805
|
resolve: (s) => s.slice(-3).toLowerCase() === "nan" ? NaN : s[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
1802
1806
|
stringify: D
|
|
1803
|
-
},
|
|
1807
|
+
}, en = {
|
|
1804
1808
|
identify: (s) => typeof s == "number",
|
|
1805
1809
|
default: !0,
|
|
1806
1810
|
tag: "tag:yaml.org,2002:float",
|
|
@@ -1811,7 +1815,7 @@ const es = {
|
|
|
1811
1815
|
const e = Number(s.value);
|
|
1812
1816
|
return isFinite(e) ? e.toExponential() : D(s);
|
|
1813
1817
|
}
|
|
1814
|
-
},
|
|
1818
|
+
}, tn = {
|
|
1815
1819
|
identify: (s) => typeof s == "number",
|
|
1816
1820
|
default: !0,
|
|
1817
1821
|
tag: "tag:yaml.org,2002:float",
|
|
@@ -1825,8 +1829,8 @@ const es = {
|
|
|
1825
1829
|
return e;
|
|
1826
1830
|
},
|
|
1827
1831
|
stringify: D
|
|
1828
|
-
},
|
|
1829
|
-
function
|
|
1832
|
+
}, ke = (s) => typeof s == "bigint" || Number.isInteger(s);
|
|
1833
|
+
function Fe(s, e, t, { intAsBigInt: n }) {
|
|
1830
1834
|
const i = s[0];
|
|
1831
1835
|
if ((i === "-" || i === "+") && (e += 1), s = s.substring(e).replace(/_/g, ""), n) {
|
|
1832
1836
|
switch (t) {
|
|
@@ -1846,67 +1850,67 @@ function qe(s, e, t, { intAsBigInt: n }) {
|
|
|
1846
1850
|
const r = parseInt(s, t);
|
|
1847
1851
|
return i === "-" ? -1 * r : r;
|
|
1848
1852
|
}
|
|
1849
|
-
function
|
|
1853
|
+
function pt(s, e, t) {
|
|
1850
1854
|
const { value: n } = s;
|
|
1851
|
-
if (
|
|
1855
|
+
if (ke(n)) {
|
|
1852
1856
|
const i = n.toString(e);
|
|
1853
1857
|
return n < 0 ? "-" + t + i.substr(1) : t + i;
|
|
1854
1858
|
}
|
|
1855
1859
|
return D(s);
|
|
1856
1860
|
}
|
|
1857
|
-
const
|
|
1858
|
-
identify:
|
|
1861
|
+
const sn = {
|
|
1862
|
+
identify: ke,
|
|
1859
1863
|
default: !0,
|
|
1860
1864
|
tag: "tag:yaml.org,2002:int",
|
|
1861
1865
|
format: "BIN",
|
|
1862
1866
|
test: /^[-+]?0b[0-1_]+$/,
|
|
1863
|
-
resolve: (s, e, t) =>
|
|
1864
|
-
stringify: (s) =>
|
|
1865
|
-
},
|
|
1866
|
-
identify:
|
|
1867
|
+
resolve: (s, e, t) => Fe(s, 2, 2, t),
|
|
1868
|
+
stringify: (s) => pt(s, 2, "0b")
|
|
1869
|
+
}, nn = {
|
|
1870
|
+
identify: ke,
|
|
1867
1871
|
default: !0,
|
|
1868
1872
|
tag: "tag:yaml.org,2002:int",
|
|
1869
1873
|
format: "OCT",
|
|
1870
1874
|
test: /^[-+]?0[0-7_]+$/,
|
|
1871
|
-
resolve: (s, e, t) =>
|
|
1872
|
-
stringify: (s) =>
|
|
1873
|
-
},
|
|
1874
|
-
identify:
|
|
1875
|
+
resolve: (s, e, t) => Fe(s, 1, 8, t),
|
|
1876
|
+
stringify: (s) => pt(s, 8, "0")
|
|
1877
|
+
}, rn = {
|
|
1878
|
+
identify: ke,
|
|
1875
1879
|
default: !0,
|
|
1876
1880
|
tag: "tag:yaml.org,2002:int",
|
|
1877
1881
|
test: /^[-+]?[0-9][0-9_]*$/,
|
|
1878
|
-
resolve: (s, e, t) =>
|
|
1882
|
+
resolve: (s, e, t) => Fe(s, 0, 10, t),
|
|
1879
1883
|
stringify: D
|
|
1880
|
-
},
|
|
1881
|
-
identify:
|
|
1884
|
+
}, on = {
|
|
1885
|
+
identify: ke,
|
|
1882
1886
|
default: !0,
|
|
1883
1887
|
tag: "tag:yaml.org,2002:int",
|
|
1884
1888
|
format: "HEX",
|
|
1885
1889
|
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
1886
|
-
resolve: (s, e, t) =>
|
|
1887
|
-
stringify: (s) =>
|
|
1890
|
+
resolve: (s, e, t) => Fe(s, 2, 16, t),
|
|
1891
|
+
stringify: (s) => pt(s, 16, "0x")
|
|
1888
1892
|
};
|
|
1889
|
-
class
|
|
1893
|
+
class ie extends B {
|
|
1890
1894
|
constructor(e) {
|
|
1891
|
-
super(e), this.tag =
|
|
1895
|
+
super(e), this.tag = ie.tag;
|
|
1892
1896
|
}
|
|
1893
1897
|
add(e) {
|
|
1894
1898
|
let t;
|
|
1895
|
-
L(e) ? t = e : e && typeof e == "object" && "key" in e && "value" in e && e.value === null ? t = new
|
|
1899
|
+
L(e) ? t = e : e && typeof e == "object" && "key" in e && "value" in e && e.value === null ? t = new j(e.key, null) : t = new j(e, null), W(this.items, t.key) || this.items.push(t);
|
|
1896
1900
|
}
|
|
1897
1901
|
/**
|
|
1898
1902
|
* If `keepPair` is `true`, returns the Pair matching `key`.
|
|
1899
1903
|
* Otherwise, returns the value of that Pair's key.
|
|
1900
1904
|
*/
|
|
1901
1905
|
get(e, t) {
|
|
1902
|
-
const n =
|
|
1906
|
+
const n = W(this.items, e);
|
|
1903
1907
|
return !t && L(n) ? T(n.key) ? n.key.value : n.key : n;
|
|
1904
1908
|
}
|
|
1905
1909
|
set(e, t) {
|
|
1906
1910
|
if (typeof t != "boolean")
|
|
1907
1911
|
throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);
|
|
1908
|
-
const n =
|
|
1909
|
-
n && !t ? this.items.splice(this.items.indexOf(n), 1) : !n && t && this.items.push(new
|
|
1912
|
+
const n = W(this.items, e);
|
|
1913
|
+
n && !t ? this.items.splice(this.items.indexOf(n), 1) : !n && t && this.items.push(new j(e));
|
|
1910
1914
|
}
|
|
1911
1915
|
toJSON(e, t) {
|
|
1912
1916
|
return super.toJSON(e, t, Set);
|
|
@@ -1922,33 +1926,33 @@ class ne extends M {
|
|
|
1922
1926
|
const { replacer: i } = n, r = new this(e);
|
|
1923
1927
|
if (t && Symbol.iterator in Object(t))
|
|
1924
1928
|
for (let o of t)
|
|
1925
|
-
typeof i == "function" && (o = i.call(t, o, o)), r.items.push(
|
|
1929
|
+
typeof i == "function" && (o = i.call(t, o, o)), r.items.push(lt(o, null, n));
|
|
1926
1930
|
return r;
|
|
1927
1931
|
}
|
|
1928
1932
|
}
|
|
1929
|
-
|
|
1930
|
-
const
|
|
1933
|
+
ie.tag = "tag:yaml.org,2002:set";
|
|
1934
|
+
const mt = {
|
|
1931
1935
|
collection: "map",
|
|
1932
1936
|
identify: (s) => s instanceof Set,
|
|
1933
|
-
nodeClass:
|
|
1937
|
+
nodeClass: ie,
|
|
1934
1938
|
default: !1,
|
|
1935
1939
|
tag: "tag:yaml.org,2002:set",
|
|
1936
|
-
createNode: (s, e, t) =>
|
|
1940
|
+
createNode: (s, e, t) => ie.from(s, e, t),
|
|
1937
1941
|
resolve(s, e) {
|
|
1938
|
-
if (
|
|
1942
|
+
if (be(s)) {
|
|
1939
1943
|
if (s.hasAllNullValues(!0))
|
|
1940
|
-
return Object.assign(new
|
|
1944
|
+
return Object.assign(new ie(), s);
|
|
1941
1945
|
e("Set items must all have null values");
|
|
1942
1946
|
} else
|
|
1943
1947
|
e("Expected a mapping for this tag");
|
|
1944
1948
|
return s;
|
|
1945
1949
|
}
|
|
1946
1950
|
};
|
|
1947
|
-
function
|
|
1951
|
+
function gt(s, e) {
|
|
1948
1952
|
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));
|
|
1949
1953
|
return t === "-" ? i(-1) * r : r;
|
|
1950
1954
|
}
|
|
1951
|
-
function
|
|
1955
|
+
function as(s) {
|
|
1952
1956
|
let { value: e } = s, t = (o) => o;
|
|
1953
1957
|
if (typeof e == "bigint")
|
|
1954
1958
|
t = (o) => BigInt(o);
|
|
@@ -1959,23 +1963,23 @@ function ss(s) {
|
|
|
1959
1963
|
const i = t(60), r = [e % i];
|
|
1960
1964
|
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*$/, "");
|
|
1961
1965
|
}
|
|
1962
|
-
const
|
|
1966
|
+
const ls = {
|
|
1963
1967
|
identify: (s) => typeof s == "bigint" || Number.isInteger(s),
|
|
1964
1968
|
default: !0,
|
|
1965
1969
|
tag: "tag:yaml.org,2002:int",
|
|
1966
1970
|
format: "TIME",
|
|
1967
1971
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
1968
|
-
resolve: (s, e, { intAsBigInt: t }) =>
|
|
1969
|
-
stringify:
|
|
1970
|
-
},
|
|
1972
|
+
resolve: (s, e, { intAsBigInt: t }) => gt(s, t),
|
|
1973
|
+
stringify: as
|
|
1974
|
+
}, cs = {
|
|
1971
1975
|
identify: (s) => typeof s == "number",
|
|
1972
1976
|
default: !0,
|
|
1973
1977
|
tag: "tag:yaml.org,2002:float",
|
|
1974
1978
|
format: "TIME",
|
|
1975
1979
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
1976
|
-
resolve: (s) =>
|
|
1977
|
-
stringify:
|
|
1978
|
-
},
|
|
1980
|
+
resolve: (s) => gt(s, !1),
|
|
1981
|
+
stringify: as
|
|
1982
|
+
}, Re = {
|
|
1979
1983
|
identify: (s) => s instanceof Date,
|
|
1980
1984
|
default: !0,
|
|
1981
1985
|
tag: "tag:yaml.org,2002:timestamp",
|
|
@@ -1984,110 +1988,110 @@ const ns = {
|
|
|
1984
1988
|
// assumed to be 00:00:00Z (start of day, UTC).
|
|
1985
1989
|
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})?))?)?$"),
|
|
1986
1990
|
resolve(s) {
|
|
1987
|
-
const e = s.match(
|
|
1991
|
+
const e = s.match(Re.test);
|
|
1988
1992
|
if (!e)
|
|
1989
1993
|
throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
1990
1994
|
const [, t, n, i, r, o, a] = e.map(Number), l = e[7] ? Number((e[7] + "00").substr(1, 3)) : 0;
|
|
1991
1995
|
let c = Date.UTC(t, n - 1, i, r || 0, o || 0, a || 0, l);
|
|
1992
1996
|
const d = e[8];
|
|
1993
1997
|
if (d && d !== "Z") {
|
|
1994
|
-
let u =
|
|
1998
|
+
let u = gt(d, !1);
|
|
1995
1999
|
Math.abs(u) < 30 && (u *= 60), c -= 6e4 * u;
|
|
1996
2000
|
}
|
|
1997
2001
|
return new Date(c);
|
|
1998
2002
|
},
|
|
1999
2003
|
stringify: ({ value: s }) => s?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? ""
|
|
2000
|
-
},
|
|
2001
|
-
le,
|
|
2004
|
+
}, Ot = [
|
|
2002
2005
|
ce,
|
|
2003
|
-
|
|
2006
|
+
fe,
|
|
2004
2007
|
Ke,
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
+
De,
|
|
2009
|
+
rs,
|
|
2010
|
+
os,
|
|
2011
|
+
sn,
|
|
2012
|
+
nn,
|
|
2013
|
+
rn,
|
|
2014
|
+
on,
|
|
2008
2015
|
Zs,
|
|
2009
2016
|
en,
|
|
2010
2017
|
tn,
|
|
2011
|
-
Qs,
|
|
2012
|
-
Xs,
|
|
2013
|
-
xs,
|
|
2014
|
-
ft,
|
|
2015
|
-
U,
|
|
2016
|
-
ht,
|
|
2017
2018
|
ut,
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
["
|
|
2027
|
-
["
|
|
2028
|
-
]
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
"tag:yaml.org,2002:
|
|
2052
|
-
"tag:yaml.org,2002:
|
|
2053
|
-
"tag:yaml.org,2002:
|
|
2019
|
+
R,
|
|
2020
|
+
dt,
|
|
2021
|
+
ht,
|
|
2022
|
+
mt,
|
|
2023
|
+
ls,
|
|
2024
|
+
cs,
|
|
2025
|
+
Re
|
|
2026
|
+
], At = /* @__PURE__ */ new Map([
|
|
2027
|
+
["core", Qs],
|
|
2028
|
+
["failsafe", [ce, fe, Ke]],
|
|
2029
|
+
["json", zs],
|
|
2030
|
+
["yaml11", Ot],
|
|
2031
|
+
["yaml-1.1", Ot]
|
|
2032
|
+
]), Et = {
|
|
2033
|
+
binary: ut,
|
|
2034
|
+
bool: ct,
|
|
2035
|
+
float: xt,
|
|
2036
|
+
floatExp: Xt,
|
|
2037
|
+
floatNaN: Qt,
|
|
2038
|
+
floatTime: cs,
|
|
2039
|
+
int: es,
|
|
2040
|
+
intHex: ts,
|
|
2041
|
+
intOct: Zt,
|
|
2042
|
+
intTime: ls,
|
|
2043
|
+
map: ce,
|
|
2044
|
+
merge: R,
|
|
2045
|
+
null: De,
|
|
2046
|
+
omap: dt,
|
|
2047
|
+
pairs: ht,
|
|
2048
|
+
seq: fe,
|
|
2049
|
+
set: mt,
|
|
2050
|
+
timestamp: Re
|
|
2051
|
+
}, an = {
|
|
2052
|
+
"tag:yaml.org,2002:binary": ut,
|
|
2053
|
+
"tag:yaml.org,2002:merge": R,
|
|
2054
|
+
"tag:yaml.org,2002:omap": dt,
|
|
2055
|
+
"tag:yaml.org,2002:pairs": ht,
|
|
2056
|
+
"tag:yaml.org,2002:set": mt,
|
|
2057
|
+
"tag:yaml.org,2002:timestamp": Re
|
|
2054
2058
|
};
|
|
2055
2059
|
function Je(s, e, t) {
|
|
2056
|
-
const n =
|
|
2060
|
+
const n = At.get(e);
|
|
2057
2061
|
if (n && !s)
|
|
2058
|
-
return t && !n.includes(
|
|
2062
|
+
return t && !n.includes(R) ? n.concat(R) : n.slice();
|
|
2059
2063
|
let i = n;
|
|
2060
2064
|
if (!i)
|
|
2061
2065
|
if (Array.isArray(s))
|
|
2062
2066
|
i = [];
|
|
2063
2067
|
else {
|
|
2064
|
-
const r = Array.from(
|
|
2068
|
+
const r = Array.from(At.keys()).filter((o) => o !== "yaml11").map((o) => JSON.stringify(o)).join(", ");
|
|
2065
2069
|
throw new Error(`Unknown schema "${e}"; use one of ${r} or define customTags array`);
|
|
2066
2070
|
}
|
|
2067
2071
|
if (Array.isArray(s))
|
|
2068
2072
|
for (const r of s)
|
|
2069
2073
|
i = i.concat(r);
|
|
2070
2074
|
else typeof s == "function" && (i = s(i.slice()));
|
|
2071
|
-
return t && (i = i.concat(
|
|
2072
|
-
const a = typeof o == "string" ?
|
|
2075
|
+
return t && (i = i.concat(R)), i.reduce((r, o) => {
|
|
2076
|
+
const a = typeof o == "string" ? Et[o] : o;
|
|
2073
2077
|
if (!a) {
|
|
2074
|
-
const l = JSON.stringify(o), c = Object.keys(
|
|
2078
|
+
const l = JSON.stringify(o), c = Object.keys(Et).map((d) => JSON.stringify(d)).join(", ");
|
|
2075
2079
|
throw new Error(`Unknown custom tag ${l}; use one of ${c}`);
|
|
2076
2080
|
}
|
|
2077
2081
|
return r.includes(a) || r.push(a), r;
|
|
2078
2082
|
}, []);
|
|
2079
2083
|
}
|
|
2080
|
-
const
|
|
2081
|
-
class
|
|
2084
|
+
const ln = (s, e) => s.key < e.key ? -1 : s.key > e.key ? 1 : 0;
|
|
2085
|
+
class yt {
|
|
2082
2086
|
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 ?
|
|
2087
|
+
this.compat = Array.isArray(e) ? Je(e, "compat") : e ? Je(null, e) : null, this.name = typeof r == "string" && r || "core", this.knownTags = i ? an : {}, this.tags = Je(t, this.name, n), this.toStringOptions = a ?? null, Object.defineProperty(this, J, { value: ce }), Object.defineProperty(this, U, { value: Ke }), Object.defineProperty(this, ae, { value: fe }), this.sortMapEntries = typeof o == "function" ? o : o === !0 ? ln : null;
|
|
2084
2088
|
}
|
|
2085
2089
|
clone() {
|
|
2086
|
-
const e = Object.create(
|
|
2090
|
+
const e = Object.create(yt.prototype, Object.getOwnPropertyDescriptors(this));
|
|
2087
2091
|
return e.tags = this.tags.slice(), e;
|
|
2088
2092
|
}
|
|
2089
2093
|
}
|
|
2090
|
-
function
|
|
2094
|
+
function cn(s, e) {
|
|
2091
2095
|
const t = [];
|
|
2092
2096
|
let n = e.directives === !0;
|
|
2093
2097
|
if (e.directives !== !1 && s.directives) {
|
|
@@ -2095,7 +2099,7 @@ function rn(s, e) {
|
|
|
2095
2099
|
l ? (t.push(l), n = !0) : s.directives.docStart && (n = !0);
|
|
2096
2100
|
}
|
|
2097
2101
|
n && t.push("---");
|
|
2098
|
-
const i =
|
|
2102
|
+
const i = Jt(s, e), { commentString: r } = i.options;
|
|
2099
2103
|
if (s.commentBefore) {
|
|
2100
2104
|
t.length !== 1 && t.unshift("");
|
|
2101
2105
|
const l = r(s.commentBefore);
|
|
@@ -2111,10 +2115,10 @@ function rn(s, e) {
|
|
|
2111
2115
|
i.forceBlockIndent = !!s.comment, a = s.contents.comment;
|
|
2112
2116
|
}
|
|
2113
2117
|
const l = a ? void 0 : () => o = !0;
|
|
2114
|
-
let c =
|
|
2118
|
+
let c = re(s.contents, i, () => a = null, l);
|
|
2115
2119
|
a && (c += G(c, "", r(a))), (c[0] === "|" || c[0] === ">") && t[t.length - 1] === "---" ? t[t.length - 1] = `--- ${c}` : t.push(c);
|
|
2116
2120
|
} else
|
|
2117
|
-
t.push(
|
|
2121
|
+
t.push(re(s.contents, i));
|
|
2118
2122
|
if (s.directives?.docEnd)
|
|
2119
2123
|
if (s.comment) {
|
|
2120
2124
|
const l = r(s.comment);
|
|
@@ -2130,7 +2134,7 @@ function rn(s, e) {
|
|
|
2130
2134
|
`) + `
|
|
2131
2135
|
`;
|
|
2132
2136
|
}
|
|
2133
|
-
class
|
|
2137
|
+
class qe {
|
|
2134
2138
|
constructor(e, t, n) {
|
|
2135
2139
|
this.commentBefore = null, this.comment = null, this.errors = [], this.warnings = [], Object.defineProperty(this, P, { value: Qe });
|
|
2136
2140
|
let i = null;
|
|
@@ -2155,18 +2159,18 @@ class Ue {
|
|
|
2155
2159
|
* Custom Node values that inherit from `Object` still refer to their original instances.
|
|
2156
2160
|
*/
|
|
2157
2161
|
clone() {
|
|
2158
|
-
const e = Object.create(
|
|
2162
|
+
const e = Object.create(qe.prototype, {
|
|
2159
2163
|
[P]: { value: Qe }
|
|
2160
2164
|
});
|
|
2161
2165
|
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;
|
|
2162
2166
|
}
|
|
2163
2167
|
/** Adds a value to the document. */
|
|
2164
2168
|
add(e) {
|
|
2165
|
-
|
|
2169
|
+
z(this.contents) && this.contents.add(e);
|
|
2166
2170
|
}
|
|
2167
2171
|
/** Adds a value to the document. */
|
|
2168
2172
|
addIn(e, t) {
|
|
2169
|
-
|
|
2173
|
+
z(this.contents) && this.contents.addIn(e, t);
|
|
2170
2174
|
}
|
|
2171
2175
|
/**
|
|
2172
2176
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -2179,21 +2183,21 @@ class Ue {
|
|
|
2179
2183
|
*/
|
|
2180
2184
|
createAlias(e, t) {
|
|
2181
2185
|
if (!e.anchor) {
|
|
2182
|
-
const n =
|
|
2186
|
+
const n = Ut(this);
|
|
2183
2187
|
e.anchor = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
2184
|
-
!t || n.has(t) ?
|
|
2188
|
+
!t || n.has(t) ? Ft(t || "a", n) : t;
|
|
2185
2189
|
}
|
|
2186
|
-
return new
|
|
2190
|
+
return new ot(e.anchor);
|
|
2187
2191
|
}
|
|
2188
2192
|
createNode(e, t, n) {
|
|
2189
2193
|
let i;
|
|
2190
2194
|
if (typeof t == "function")
|
|
2191
2195
|
e = t.call({ "": e }, "", e), i = t;
|
|
2192
2196
|
else if (Array.isArray(t)) {
|
|
2193
|
-
const
|
|
2197
|
+
const m = (w) => typeof w == "number" || w instanceof String || w instanceof Number, b = t.filter(m).map(String);
|
|
2194
2198
|
b.length > 0 && (t = t.concat(b)), i = t;
|
|
2195
2199
|
} else n === void 0 && t && (n = t, t = void 0);
|
|
2196
|
-
const { aliasDuplicateObjects: r, anchorPrefix: o, flow: a, keepUndefined: l, onTagObj: c, tag: d } = n ?? {}, { onAnchor: u, setAnchors: f, sourceObjects:
|
|
2200
|
+
const { aliasDuplicateObjects: r, anchorPrefix: o, flow: a, keepUndefined: l, onTagObj: c, tag: d } = n ?? {}, { onAnchor: u, setAnchors: f, sourceObjects: p } = Ps(
|
|
2197
2201
|
this,
|
|
2198
2202
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
2199
2203
|
o || "a"
|
|
@@ -2204,8 +2208,8 @@ class Ue {
|
|
|
2204
2208
|
onTagObj: c,
|
|
2205
2209
|
replacer: i,
|
|
2206
2210
|
schema: this.schema,
|
|
2207
|
-
sourceObjects:
|
|
2208
|
-
}, h =
|
|
2211
|
+
sourceObjects: p
|
|
2212
|
+
}, h = ge(e, d, g);
|
|
2209
2213
|
return a && I(h) && (h.flow = !0), f(), h;
|
|
2210
2214
|
}
|
|
2211
2215
|
/**
|
|
@@ -2214,21 +2218,21 @@ class Ue {
|
|
|
2214
2218
|
*/
|
|
2215
2219
|
createPair(e, t, n = {}) {
|
|
2216
2220
|
const i = this.createNode(e, null, n), r = this.createNode(t, null, n);
|
|
2217
|
-
return new
|
|
2221
|
+
return new j(i, r);
|
|
2218
2222
|
}
|
|
2219
2223
|
/**
|
|
2220
2224
|
* Removes a value from the document.
|
|
2221
2225
|
* @returns `true` if the item was found and removed.
|
|
2222
2226
|
*/
|
|
2223
2227
|
delete(e) {
|
|
2224
|
-
return
|
|
2228
|
+
return z(this.contents) ? this.contents.delete(e) : !1;
|
|
2225
2229
|
}
|
|
2226
2230
|
/**
|
|
2227
2231
|
* Removes a value from the document.
|
|
2228
2232
|
* @returns `true` if the item was found and removed.
|
|
2229
2233
|
*/
|
|
2230
2234
|
deleteIn(e) {
|
|
2231
|
-
return
|
|
2235
|
+
return he(e) ? this.contents == null ? !1 : (this.contents = null, !0) : z(this.contents) ? this.contents.deleteIn(e) : !1;
|
|
2232
2236
|
}
|
|
2233
2237
|
/**
|
|
2234
2238
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -2244,7 +2248,7 @@ class Ue {
|
|
|
2244
2248
|
* `true` (collections are always returned intact).
|
|
2245
2249
|
*/
|
|
2246
2250
|
getIn(e, t) {
|
|
2247
|
-
return
|
|
2251
|
+
return he(e) ? !t && T(this.contents) ? this.contents.value : this.contents : I(this.contents) ? this.contents.getIn(e, t) : void 0;
|
|
2248
2252
|
}
|
|
2249
2253
|
/**
|
|
2250
2254
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -2256,21 +2260,21 @@ class Ue {
|
|
|
2256
2260
|
* Checks if the document includes a value at `path`.
|
|
2257
2261
|
*/
|
|
2258
2262
|
hasIn(e) {
|
|
2259
|
-
return
|
|
2263
|
+
return he(e) ? this.contents !== void 0 : I(this.contents) ? this.contents.hasIn(e) : !1;
|
|
2260
2264
|
}
|
|
2261
2265
|
/**
|
|
2262
2266
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
2263
2267
|
* boolean to add/remove the item from the set.
|
|
2264
2268
|
*/
|
|
2265
2269
|
set(e, t) {
|
|
2266
|
-
this.contents == null ? this.contents =
|
|
2270
|
+
this.contents == null ? this.contents = ve(this.schema, [e], t) : z(this.contents) && this.contents.set(e, t);
|
|
2267
2271
|
}
|
|
2268
2272
|
/**
|
|
2269
2273
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
2270
2274
|
* boolean to add/remove the item from the set.
|
|
2271
2275
|
*/
|
|
2272
2276
|
setIn(e, t) {
|
|
2273
|
-
|
|
2277
|
+
he(e) ? this.contents = t : this.contents == null ? this.contents = ve(this.schema, Array.from(e), t) : z(this.contents) && this.contents.setIn(e, t);
|
|
2274
2278
|
}
|
|
2275
2279
|
/**
|
|
2276
2280
|
* Change the YAML version and schema used by the document.
|
|
@@ -2301,7 +2305,7 @@ class Ue {
|
|
|
2301
2305
|
if (t.schema instanceof Object)
|
|
2302
2306
|
this.schema = t.schema;
|
|
2303
2307
|
else if (n)
|
|
2304
|
-
this.schema = new
|
|
2308
|
+
this.schema = new yt(Object.assign(n, t));
|
|
2305
2309
|
else
|
|
2306
2310
|
throw new Error("With a null YAML version, the { schema: Schema } option is required");
|
|
2307
2311
|
}
|
|
@@ -2314,11 +2318,11 @@ class Ue {
|
|
|
2314
2318
|
mapAsMap: n === !0,
|
|
2315
2319
|
mapKeyWarned: !1,
|
|
2316
2320
|
maxAliasCount: typeof i == "number" ? i : 100
|
|
2317
|
-
}, l =
|
|
2321
|
+
}, l = M(this.contents, t ?? "", a);
|
|
2318
2322
|
if (typeof r == "function")
|
|
2319
2323
|
for (const { count: c, res: d } of a.anchors.values())
|
|
2320
2324
|
r(d, c);
|
|
2321
|
-
return typeof o == "function" ?
|
|
2325
|
+
return typeof o == "function" ? te(o, { "": l }, "", l) : l;
|
|
2322
2326
|
}
|
|
2323
2327
|
/**
|
|
2324
2328
|
* A JSON representation of the document `contents`.
|
|
@@ -2337,30 +2341,30 @@ class Ue {
|
|
|
2337
2341
|
const t = JSON.stringify(e.indent);
|
|
2338
2342
|
throw new Error(`"indent" option must be a positive integer, not ${t}`);
|
|
2339
2343
|
}
|
|
2340
|
-
return
|
|
2344
|
+
return cn(this, e);
|
|
2341
2345
|
}
|
|
2342
2346
|
}
|
|
2343
|
-
function
|
|
2347
|
+
function z(s) {
|
|
2344
2348
|
if (I(s))
|
|
2345
2349
|
return !0;
|
|
2346
2350
|
throw new Error("Expected a YAML collection as document contents");
|
|
2347
2351
|
}
|
|
2348
|
-
class
|
|
2352
|
+
class fs extends Error {
|
|
2349
2353
|
constructor(e, t, n, i) {
|
|
2350
2354
|
super(), this.name = e, this.code = n, this.message = i, this.pos = t;
|
|
2351
2355
|
}
|
|
2352
2356
|
}
|
|
2353
|
-
class
|
|
2357
|
+
class de extends fs {
|
|
2354
2358
|
constructor(e, t, n) {
|
|
2355
2359
|
super("YAMLParseError", e, t, n);
|
|
2356
2360
|
}
|
|
2357
2361
|
}
|
|
2358
|
-
class
|
|
2362
|
+
class fn extends fs {
|
|
2359
2363
|
constructor(e, t, n) {
|
|
2360
2364
|
super("YAMLWarning", e, t, n);
|
|
2361
2365
|
}
|
|
2362
2366
|
}
|
|
2363
|
-
const
|
|
2367
|
+
const Tt = (s, e) => (t) => {
|
|
2364
2368
|
if (t.pos[0] === -1)
|
|
2365
2369
|
return;
|
|
2366
2370
|
t.linePos = t.pos.map((a) => e.linePos(a));
|
|
@@ -2388,8 +2392,8 @@ ${c}
|
|
|
2388
2392
|
`;
|
|
2389
2393
|
}
|
|
2390
2394
|
};
|
|
2391
|
-
function
|
|
2392
|
-
let l = !1, c = a, d = a, u = "", f = "",
|
|
2395
|
+
function oe(s, { flow: e, indicator: t, next: n, offset: i, onError: r, parentIndent: o, startOnNewline: a }) {
|
|
2396
|
+
let l = !1, c = a, d = a, u = "", f = "", p = !1, g = !1, h = null, m = null, b = null, w = null, k = null, S = null, N = null;
|
|
2393
2397
|
for (const y of s)
|
|
2394
2398
|
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) {
|
|
2395
2399
|
case "space":
|
|
@@ -2402,17 +2406,17 @@ function re(s, { flow: e, indicator: t, next: n, offset: i, onError: r, parentIn
|
|
|
2402
2406
|
break;
|
|
2403
2407
|
}
|
|
2404
2408
|
case "newline":
|
|
2405
|
-
c ? u ? u += y.source : (!S || t !== "seq-item-ind") && (l = !0) : f += y.source, c = !0,
|
|
2409
|
+
c ? u ? u += y.source : (!S || t !== "seq-item-ind") && (l = !0) : f += y.source, c = !0, p = !0, (m || b) && (w = y), d = !0;
|
|
2406
2410
|
break;
|
|
2407
2411
|
case "anchor":
|
|
2408
|
-
|
|
2412
|
+
m && 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), m = y, N ?? (N = y.offset), c = !1, d = !1, g = !0;
|
|
2409
2413
|
break;
|
|
2410
2414
|
case "tag": {
|
|
2411
2415
|
b && r(y, "MULTIPLE_TAGS", "A node can have at most one tag"), b = y, N ?? (N = y.offset), c = !1, d = !1, g = !0;
|
|
2412
2416
|
break;
|
|
2413
2417
|
}
|
|
2414
2418
|
case t:
|
|
2415
|
-
(
|
|
2419
|
+
(m || b) && r(y, "BAD_PROP_ORDER", `Anchors and tags must be after the ${y.source} indicator`), S && r(y, "UNEXPECTED_TOKEN", `Unexpected ${y.source} in ${e ?? "collection"}`), S = y, c = t === "seq-item-ind" || t === "explicit-key-ind", d = !1;
|
|
2416
2420
|
break;
|
|
2417
2421
|
case "comma":
|
|
2418
2422
|
if (e) {
|
|
@@ -2429,15 +2433,15 @@ function re(s, { flow: e, indicator: t, next: n, offset: i, onError: r, parentIn
|
|
|
2429
2433
|
found: S,
|
|
2430
2434
|
spaceBefore: l,
|
|
2431
2435
|
comment: u,
|
|
2432
|
-
hasNewline:
|
|
2433
|
-
anchor:
|
|
2436
|
+
hasNewline: p,
|
|
2437
|
+
anchor: m,
|
|
2434
2438
|
tag: b,
|
|
2435
2439
|
newlineAfterProp: w,
|
|
2436
2440
|
end: E,
|
|
2437
2441
|
start: N ?? E
|
|
2438
2442
|
};
|
|
2439
2443
|
}
|
|
2440
|
-
function
|
|
2444
|
+
function ye(s) {
|
|
2441
2445
|
if (!s)
|
|
2442
2446
|
return null;
|
|
2443
2447
|
switch (s.type) {
|
|
@@ -2464,7 +2468,7 @@ function ge(s) {
|
|
|
2464
2468
|
if (t.type === "newline")
|
|
2465
2469
|
return !0;
|
|
2466
2470
|
}
|
|
2467
|
-
if (
|
|
2471
|
+
if (ye(e.key) || ye(e.value))
|
|
2468
2472
|
return !0;
|
|
2469
2473
|
}
|
|
2470
2474
|
return !1;
|
|
@@ -2475,42 +2479,42 @@ function ge(s) {
|
|
|
2475
2479
|
function Ze(s, e, t) {
|
|
2476
2480
|
if (e?.type === "flow-collection") {
|
|
2477
2481
|
const n = e.end[0];
|
|
2478
|
-
n.indent === s && (n.source === "]" || n.source === "}") &&
|
|
2482
|
+
n.indent === s && (n.source === "]" || n.source === "}") && ye(e) && t(n, "BAD_INDENT", "Flow end indicator should be more indented than parent", !0);
|
|
2479
2483
|
}
|
|
2480
2484
|
}
|
|
2481
|
-
function
|
|
2485
|
+
function us(s, e, t) {
|
|
2482
2486
|
const { uniqueKeys: n } = s.options;
|
|
2483
2487
|
if (n === !1)
|
|
2484
2488
|
return !1;
|
|
2485
2489
|
const i = typeof n == "function" ? n : (r, o) => r === o || T(r) && T(o) && r.value === o.value;
|
|
2486
2490
|
return e.some((r) => i(r.key, t));
|
|
2487
2491
|
}
|
|
2488
|
-
const
|
|
2489
|
-
function
|
|
2490
|
-
const o = r?.nodeClass ??
|
|
2492
|
+
const It = "All mapping items must start at the same column";
|
|
2493
|
+
function un({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
2494
|
+
const o = r?.nodeClass ?? B, a = new o(t.schema);
|
|
2491
2495
|
t.atRoot && (t.atRoot = !1);
|
|
2492
2496
|
let l = n.offset, c = null;
|
|
2493
2497
|
for (const d of n.items) {
|
|
2494
|
-
const { start: u, key: f, sep:
|
|
2498
|
+
const { start: u, key: f, sep: p, value: g } = d, h = oe(u, {
|
|
2495
2499
|
indicator: "explicit-key-ind",
|
|
2496
|
-
next: f ??
|
|
2500
|
+
next: f ?? p?.[0],
|
|
2497
2501
|
offset: l,
|
|
2498
2502
|
onError: i,
|
|
2499
2503
|
parentIndent: n.indent,
|
|
2500
2504
|
startOnNewline: !0
|
|
2501
|
-
}),
|
|
2502
|
-
if (
|
|
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",
|
|
2505
|
+
}), m = !h.found;
|
|
2506
|
+
if (m) {
|
|
2507
|
+
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", It)), !h.anchor && !h.tag && !p) {
|
|
2504
2508
|
c = h.end, h.comment && (a.comment ? a.comment += `
|
|
2505
2509
|
` + h.comment : a.comment = h.comment);
|
|
2506
2510
|
continue;
|
|
2507
2511
|
}
|
|
2508
|
-
(h.newlineAfterProp ||
|
|
2509
|
-
} else h.found?.indent !== n.indent && i(l, "BAD_INDENT",
|
|
2512
|
+
(h.newlineAfterProp || ye(f)) && i(f ?? u[u.length - 1], "MULTILINE_IMPLICIT_KEY", "Implicit keys need to be on a single line");
|
|
2513
|
+
} else h.found?.indent !== n.indent && i(l, "BAD_INDENT", It);
|
|
2510
2514
|
t.atKey = !0;
|
|
2511
2515
|
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,
|
|
2513
|
-
const k =
|
|
2516
|
+
t.schema.compat && Ze(n.indent, f, i), t.atKey = !1, us(t, a.items, w) && i(b, "DUPLICATE_KEY", "Map keys must be unique");
|
|
2517
|
+
const k = oe(p ?? [], {
|
|
2514
2518
|
indicator: "map-value-ind",
|
|
2515
2519
|
next: g,
|
|
2516
2520
|
offset: w.range[2],
|
|
@@ -2519,26 +2523,26 @@ function an({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
|
2519
2523
|
startOnNewline: !f || f.type === "block-scalar"
|
|
2520
2524
|
});
|
|
2521
2525
|
if (l = k.end, k.found) {
|
|
2522
|
-
|
|
2523
|
-
const S = g ? s(t, g, k, i) : e(t, l,
|
|
2526
|
+
m && (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"));
|
|
2527
|
+
const S = g ? s(t, g, k, i) : e(t, l, p, null, k, i);
|
|
2524
2528
|
t.schema.compat && Ze(n.indent, g, i), l = S.range[2];
|
|
2525
|
-
const N = new
|
|
2529
|
+
const N = new j(w, S);
|
|
2526
2530
|
t.options.keepSourceTokens && (N.srcToken = d), a.items.push(N);
|
|
2527
2531
|
} else {
|
|
2528
|
-
|
|
2532
|
+
m && i(w.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values"), k.comment && (w.comment ? w.comment += `
|
|
2529
2533
|
` + k.comment : w.comment = k.comment);
|
|
2530
|
-
const S = new
|
|
2534
|
+
const S = new j(w);
|
|
2531
2535
|
t.options.keepSourceTokens && (S.srcToken = d), a.items.push(S);
|
|
2532
2536
|
}
|
|
2533
2537
|
}
|
|
2534
2538
|
return c && c < l && i(c, "IMPOSSIBLE", "Map comment with trailing content"), a.range = [n.offset, l, c ?? l], a;
|
|
2535
2539
|
}
|
|
2536
|
-
function
|
|
2537
|
-
const o = r?.nodeClass ??
|
|
2540
|
+
function hn({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
2541
|
+
const o = r?.nodeClass ?? H, a = new o(t.schema);
|
|
2538
2542
|
t.atRoot && (t.atRoot = !1), t.atKey && (t.atKey = !1);
|
|
2539
2543
|
let l = n.offset, c = null;
|
|
2540
2544
|
for (const { start: d, value: u } of n.items) {
|
|
2541
|
-
const f =
|
|
2545
|
+
const f = oe(d, {
|
|
2542
2546
|
indicator: "seq-item-ind",
|
|
2543
2547
|
next: u,
|
|
2544
2548
|
offset: l,
|
|
@@ -2553,12 +2557,12 @@ function ln({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
|
2553
2557
|
c = f.end, f.comment && (a.comment = f.comment);
|
|
2554
2558
|
continue;
|
|
2555
2559
|
}
|
|
2556
|
-
const
|
|
2557
|
-
t.schema.compat && Ze(n.indent, u, i), l =
|
|
2560
|
+
const p = u ? s(t, u, f, i) : e(t, f.end, d, null, f, i);
|
|
2561
|
+
t.schema.compat && Ze(n.indent, u, i), l = p.range[2], a.items.push(p);
|
|
2558
2562
|
}
|
|
2559
2563
|
return a.range = [n.offset, l, c ?? l], a;
|
|
2560
2564
|
}
|
|
2561
|
-
function
|
|
2565
|
+
function Se(s, e, t, n) {
|
|
2562
2566
|
let i = "";
|
|
2563
2567
|
if (s) {
|
|
2564
2568
|
let r = !1, o = "";
|
|
@@ -2586,14 +2590,14 @@ function ke(s, e, t, n) {
|
|
|
2586
2590
|
return { comment: i, offset: e };
|
|
2587
2591
|
}
|
|
2588
2592
|
const Ye = "Block collections are not allowed within flow collections", Ge = (s) => s && (s.type === "block-map" || s.type === "block-seq");
|
|
2589
|
-
function
|
|
2590
|
-
const o = n.start.source === "{", a = o ? "flow map" : "flow sequence", l = r?.nodeClass ?? (o ?
|
|
2593
|
+
function dn({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
2594
|
+
const o = n.start.source === "{", a = o ? "flow map" : "flow sequence", l = r?.nodeClass ?? (o ? B : H), c = new l(t.schema);
|
|
2591
2595
|
c.flow = !0;
|
|
2592
2596
|
const d = t.atRoot;
|
|
2593
2597
|
d && (t.atRoot = !1), t.atKey && (t.atKey = !1);
|
|
2594
2598
|
let u = n.offset + n.start.source.length;
|
|
2595
|
-
for (let
|
|
2596
|
-
const b = n.items[
|
|
2599
|
+
for (let m = 0; m < n.items.length; ++m) {
|
|
2600
|
+
const b = n.items[m], { start: w, key: k, sep: S, value: N } = b, A = oe(w, {
|
|
2597
2601
|
flow: a,
|
|
2598
2602
|
indicator: "explicit-key-ind",
|
|
2599
2603
|
next: k ?? S?.[0],
|
|
@@ -2604,18 +2608,18 @@ function cn({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
|
2604
2608
|
});
|
|
2605
2609
|
if (!A.found) {
|
|
2606
2610
|
if (!A.anchor && !A.tag && !S && !N) {
|
|
2607
|
-
|
|
2611
|
+
m === 0 && A.comma ? i(A.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${a}`) : m < n.items.length - 1 && i(A.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${a}`), A.comment && (c.comment ? c.comment += `
|
|
2608
2612
|
` + A.comment : c.comment = A.comment), u = A.end;
|
|
2609
2613
|
continue;
|
|
2610
2614
|
}
|
|
2611
|
-
!o && t.options.strict &&
|
|
2615
|
+
!o && t.options.strict && ye(k) && i(
|
|
2612
2616
|
k,
|
|
2613
2617
|
// checked by containsNewline()
|
|
2614
2618
|
"MULTILINE_IMPLICIT_KEY",
|
|
2615
2619
|
"Implicit keys of flow sequence pairs need to be on a single line"
|
|
2616
2620
|
);
|
|
2617
2621
|
}
|
|
2618
|
-
if (
|
|
2622
|
+
if (m === 0)
|
|
2619
2623
|
A.comma && i(A.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${a}`);
|
|
2620
2624
|
else if (A.comma || i(A.start, "MISSING_CHAR", `Missing , between ${a} items`), A.comment) {
|
|
2621
2625
|
let E = "";
|
|
@@ -2643,7 +2647,7 @@ function cn({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
|
2643
2647
|
t.atKey = !0;
|
|
2644
2648
|
const E = A.end, y = k ? s(t, k, A, i) : e(t, E, w, null, A, i);
|
|
2645
2649
|
Ge(k) && i(y.range, "BLOCK_IN_FLOW", Ye), t.atKey = !1;
|
|
2646
|
-
const v =
|
|
2650
|
+
const v = oe(S ?? [], {
|
|
2647
2651
|
flow: a,
|
|
2648
2652
|
indicator: "map-value-ind",
|
|
2649
2653
|
next: N,
|
|
@@ -2666,71 +2670,71 @@ function cn({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
|
|
|
2666
2670
|
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");
|
|
2667
2671
|
}
|
|
2668
2672
|
} 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`));
|
|
2669
|
-
const
|
|
2670
|
-
|
|
2673
|
+
const q = N ? s(t, N, v, i) : v.found ? e(t, v.end, S, null, v, i) : null;
|
|
2674
|
+
q ? Ge(N) && i(q.range, "BLOCK_IN_FLOW", Ye) : v.comment && (y.comment ? y.comment += `
|
|
2671
2675
|
` + v.comment : y.comment = v.comment);
|
|
2672
|
-
const X = new
|
|
2676
|
+
const X = new j(y, q);
|
|
2673
2677
|
if (t.options.keepSourceTokens && (X.srcToken = b), o) {
|
|
2674
2678
|
const C = c;
|
|
2675
|
-
|
|
2679
|
+
us(t, C.items, y) && i(E, "DUPLICATE_KEY", "Map keys must be unique"), C.items.push(X);
|
|
2676
2680
|
} else {
|
|
2677
|
-
const C = new
|
|
2681
|
+
const C = new B(t.schema);
|
|
2678
2682
|
C.flow = !0, C.items.push(X);
|
|
2679
|
-
const
|
|
2680
|
-
C.range = [y.range[0],
|
|
2683
|
+
const wt = (q ?? y).range;
|
|
2684
|
+
C.range = [y.range[0], wt[1], wt[2]], c.items.push(C);
|
|
2681
2685
|
}
|
|
2682
|
-
u =
|
|
2686
|
+
u = q ? q.range[2] : v.end;
|
|
2683
2687
|
}
|
|
2684
2688
|
}
|
|
2685
|
-
const f = o ? "}" : "]", [
|
|
2689
|
+
const f = o ? "}" : "]", [p, ...g] = n.end;
|
|
2686
2690
|
let h = u;
|
|
2687
|
-
if (
|
|
2688
|
-
h =
|
|
2691
|
+
if (p?.source === f)
|
|
2692
|
+
h = p.offset + p.source.length;
|
|
2689
2693
|
else {
|
|
2690
|
-
const
|
|
2691
|
-
i(u, d ? "MISSING_CHAR" : "BAD_INDENT", b),
|
|
2694
|
+
const m = a[0].toUpperCase() + a.substring(1), b = d ? `${m} must end with a ${f}` : `${m} in block collection must be sufficiently indented and end with a ${f}`;
|
|
2695
|
+
i(u, d ? "MISSING_CHAR" : "BAD_INDENT", b), p && p.source.length !== 1 && g.unshift(p);
|
|
2692
2696
|
}
|
|
2693
2697
|
if (g.length > 0) {
|
|
2694
|
-
const
|
|
2695
|
-
|
|
2696
|
-
` +
|
|
2698
|
+
const m = Se(g, h, t.options.strict, i);
|
|
2699
|
+
m.comment && (c.comment ? c.comment += `
|
|
2700
|
+
` + m.comment : c.comment = m.comment), c.range = [n.offset, h, m.offset];
|
|
2697
2701
|
} else
|
|
2698
2702
|
c.range = [n.offset, h, h];
|
|
2699
2703
|
return c;
|
|
2700
2704
|
}
|
|
2701
|
-
function
|
|
2702
|
-
const o = t.type === "block-map" ?
|
|
2705
|
+
function We(s, e, t, n, i, r) {
|
|
2706
|
+
const o = t.type === "block-map" ? un(s, e, t, n, r) : t.type === "block-seq" ? hn(s, e, t, n, r) : dn(s, e, t, n, r), a = o.constructor;
|
|
2703
2707
|
return i === "!" || i === a.tagName ? (o.tag = a.tagName, o) : (i && (o.tag = i), o);
|
|
2704
2708
|
}
|
|
2705
|
-
function
|
|
2709
|
+
function pn(s, e, t, n, i) {
|
|
2706
2710
|
const r = n.tag, o = r ? e.directives.tagName(r.source, (f) => i(r, "TAG_RESOLVE_FAILED", f)) : null;
|
|
2707
2711
|
if (t.type === "block-seq") {
|
|
2708
|
-
const { anchor: f, newlineAfterProp:
|
|
2709
|
-
g && (!
|
|
2712
|
+
const { anchor: f, newlineAfterProp: p } = n, g = f && r ? f.offset > r.offset ? f : r : f ?? r;
|
|
2713
|
+
g && (!p || p.offset < g.offset) && i(g, "MISSING_CHAR", "Missing newline after block sequence props");
|
|
2710
2714
|
}
|
|
2711
2715
|
const a = t.type === "block-map" ? "map" : t.type === "block-seq" ? "seq" : t.start.source === "{" ? "map" : "seq";
|
|
2712
|
-
if (!r || !o || o === "!" || o ===
|
|
2713
|
-
return
|
|
2716
|
+
if (!r || !o || o === "!" || o === B.tagName && a === "map" || o === H.tagName && a === "seq")
|
|
2717
|
+
return We(s, e, t, i, o);
|
|
2714
2718
|
let l = e.schema.tags.find((f) => f.tag === o && f.collection === a);
|
|
2715
2719
|
if (!l) {
|
|
2716
2720
|
const f = e.schema.knownTags[o];
|
|
2717
2721
|
if (f?.collection === a)
|
|
2718
2722
|
e.schema.tags.push(Object.assign({}, f, { default: !1 })), l = f;
|
|
2719
2723
|
else
|
|
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),
|
|
2724
|
+
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), We(s, e, t, i, o);
|
|
2721
2725
|
}
|
|
2722
|
-
const c =
|
|
2726
|
+
const c = We(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
2727
|
return u.range = c.range, u.tag = o, l?.format && (u.format = l.format), u;
|
|
2724
2728
|
}
|
|
2725
|
-
function
|
|
2726
|
-
const n = e.offset, i =
|
|
2729
|
+
function mn(s, e, t) {
|
|
2730
|
+
const n = e.offset, i = gn(e, s.options.strict, t);
|
|
2727
2731
|
if (!i)
|
|
2728
2732
|
return { value: "", type: null, comment: "", range: [n, n, n] };
|
|
2729
|
-
const r = i.mode === ">" ? O.BLOCK_FOLDED : O.BLOCK_LITERAL, o = e.source ?
|
|
2733
|
+
const r = i.mode === ">" ? O.BLOCK_FOLDED : O.BLOCK_LITERAL, o = e.source ? yn(e.source) : [];
|
|
2730
2734
|
let a = o.length;
|
|
2731
2735
|
for (let h = o.length - 1; h >= 0; --h) {
|
|
2732
|
-
const
|
|
2733
|
-
if (
|
|
2736
|
+
const m = o[h][1];
|
|
2737
|
+
if (m === "" || m === "\r")
|
|
2734
2738
|
a = h;
|
|
2735
2739
|
else
|
|
2736
2740
|
break;
|
|
@@ -2738,44 +2742,44 @@ function un(s, e, t) {
|
|
|
2738
2742
|
if (a === 0) {
|
|
2739
2743
|
const h = i.chomp === "+" && o.length > 0 ? `
|
|
2740
2744
|
`.repeat(Math.max(1, o.length - 1)) : "";
|
|
2741
|
-
let
|
|
2742
|
-
return e.source && (
|
|
2745
|
+
let m = n + i.length;
|
|
2746
|
+
return e.source && (m += e.source.length), { value: h, type: r, comment: i.comment, range: [n, m, m] };
|
|
2743
2747
|
}
|
|
2744
2748
|
let l = e.indent + i.indent, c = e.offset + i.length, d = 0;
|
|
2745
2749
|
for (let h = 0; h < a; ++h) {
|
|
2746
|
-
const [
|
|
2750
|
+
const [m, b] = o[h];
|
|
2747
2751
|
if (b === "" || b === "\r")
|
|
2748
|
-
i.indent === 0 &&
|
|
2752
|
+
i.indent === 0 && m.length > l && (l = m.length);
|
|
2749
2753
|
else {
|
|
2750
|
-
|
|
2754
|
+
m.length < l && t(c + m.length, "MISSING_CHAR", "Block scalars with more-indented leading empty lines must use an explicit indentation indicator"), i.indent === 0 && (l = m.length), d = h, l === 0 && !s.atRoot && t(c, "BAD_INDENT", "Block scalar values in collections must be indented");
|
|
2751
2755
|
break;
|
|
2752
2756
|
}
|
|
2753
|
-
c +=
|
|
2757
|
+
c += m.length + b.length + 1;
|
|
2754
2758
|
}
|
|
2755
2759
|
for (let h = o.length - 1; h >= a; --h)
|
|
2756
2760
|
o[h][0].length > l && (a = h + 1);
|
|
2757
|
-
let u = "", f = "",
|
|
2761
|
+
let u = "", f = "", p = !1;
|
|
2758
2762
|
for (let h = 0; h < d; ++h)
|
|
2759
2763
|
u += o[h][0].slice(l) + `
|
|
2760
2764
|
`;
|
|
2761
2765
|
for (let h = d; h < a; ++h) {
|
|
2762
|
-
let [
|
|
2763
|
-
c +=
|
|
2766
|
+
let [m, b] = o[h];
|
|
2767
|
+
c += m.length + b.length + 1;
|
|
2764
2768
|
const w = b[b.length - 1] === "\r";
|
|
2765
|
-
if (w && (b = b.slice(0, -1)), b &&
|
|
2769
|
+
if (w && (b = b.slice(0, -1)), b && m.length < l) {
|
|
2766
2770
|
const S = `Block scalar lines must not be less indented than their ${i.indent ? "explicit indentation indicator" : "first line"}`;
|
|
2767
|
-
t(c - b.length - (w ? 2 : 1), "BAD_INDENT", S),
|
|
2771
|
+
t(c - b.length - (w ? 2 : 1), "BAD_INDENT", S), m = "";
|
|
2768
2772
|
}
|
|
2769
|
-
r === O.BLOCK_LITERAL ? (u += f +
|
|
2770
|
-
`) :
|
|
2771
|
-
` : !
|
|
2773
|
+
r === O.BLOCK_LITERAL ? (u += f + m.slice(l) + b, f = `
|
|
2774
|
+
`) : m.length > l || b[0] === " " ? (f === " " ? f = `
|
|
2775
|
+
` : !p && f === `
|
|
2772
2776
|
` && (f = `
|
|
2773
2777
|
|
|
2774
|
-
`), u += f +
|
|
2775
|
-
`,
|
|
2778
|
+
`), u += f + m.slice(l) + b, f = `
|
|
2779
|
+
`, p = !0) : b === "" ? f === `
|
|
2776
2780
|
` ? u += `
|
|
2777
2781
|
` : f = `
|
|
2778
|
-
` : (u += f + b, f = " ",
|
|
2782
|
+
` : (u += f + b, f = " ", p = !1);
|
|
2779
2783
|
}
|
|
2780
2784
|
switch (i.chomp) {
|
|
2781
2785
|
case "-":
|
|
@@ -2795,67 +2799,67 @@ function un(s, e, t) {
|
|
|
2795
2799
|
const g = n + i.length + e.source.length;
|
|
2796
2800
|
return { value: u, type: r, comment: i.comment, range: [n, g, g] };
|
|
2797
2801
|
}
|
|
2798
|
-
function
|
|
2802
|
+
function gn({ offset: s, props: e }, t, n) {
|
|
2799
2803
|
if (e[0].type !== "block-scalar-header")
|
|
2800
2804
|
return n(e[0], "IMPOSSIBLE", "Block scalar header not found"), null;
|
|
2801
2805
|
const { source: i } = e[0], r = i[0];
|
|
2802
2806
|
let o = 0, a = "", l = -1;
|
|
2803
2807
|
for (let f = 1; f < i.length; ++f) {
|
|
2804
|
-
const
|
|
2805
|
-
if (!a && (
|
|
2806
|
-
a =
|
|
2808
|
+
const p = i[f];
|
|
2809
|
+
if (!a && (p === "-" || p === "+"))
|
|
2810
|
+
a = p;
|
|
2807
2811
|
else {
|
|
2808
|
-
const g = Number(
|
|
2812
|
+
const g = Number(p);
|
|
2809
2813
|
!o && g ? o = g : l === -1 && (l = s + f);
|
|
2810
2814
|
}
|
|
2811
2815
|
}
|
|
2812
2816
|
l !== -1 && n(l, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${i}`);
|
|
2813
2817
|
let c = !1, d = "", u = i.length;
|
|
2814
2818
|
for (let f = 1; f < e.length; ++f) {
|
|
2815
|
-
const
|
|
2816
|
-
switch (
|
|
2819
|
+
const p = e[f];
|
|
2820
|
+
switch (p.type) {
|
|
2817
2821
|
case "space":
|
|
2818
2822
|
c = !0;
|
|
2819
2823
|
// fallthrough
|
|
2820
2824
|
case "newline":
|
|
2821
|
-
u +=
|
|
2825
|
+
u += p.source.length;
|
|
2822
2826
|
break;
|
|
2823
2827
|
case "comment":
|
|
2824
|
-
t && !c && n(
|
|
2828
|
+
t && !c && n(p, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"), u += p.source.length, d = p.source.substring(1);
|
|
2825
2829
|
break;
|
|
2826
2830
|
case "error":
|
|
2827
|
-
n(
|
|
2831
|
+
n(p, "UNEXPECTED_TOKEN", p.message), u += p.source.length;
|
|
2828
2832
|
break;
|
|
2829
2833
|
/* istanbul ignore next should not happen */
|
|
2830
2834
|
default: {
|
|
2831
|
-
const g = `Unexpected token in block scalar header: ${
|
|
2832
|
-
n(
|
|
2833
|
-
const h =
|
|
2835
|
+
const g = `Unexpected token in block scalar header: ${p.type}`;
|
|
2836
|
+
n(p, "UNEXPECTED_TOKEN", g);
|
|
2837
|
+
const h = p.source;
|
|
2834
2838
|
h && typeof h == "string" && (u += h.length);
|
|
2835
2839
|
}
|
|
2836
2840
|
}
|
|
2837
2841
|
}
|
|
2838
2842
|
return { mode: r, indent: o, chomp: a, comment: d, length: u };
|
|
2839
2843
|
}
|
|
2840
|
-
function
|
|
2844
|
+
function yn(s) {
|
|
2841
2845
|
const e = s.split(/\n( *)/), t = e[0], n = t.match(/^( *)/), r = [n?.[1] ? [n[1], t.slice(n[1].length)] : ["", t]];
|
|
2842
2846
|
for (let o = 1; o < e.length; o += 2)
|
|
2843
2847
|
r.push([e[o], e[o + 1]]);
|
|
2844
2848
|
return r;
|
|
2845
2849
|
}
|
|
2846
|
-
function
|
|
2850
|
+
function bn(s, e, t) {
|
|
2847
2851
|
const { offset: n, type: i, source: r, end: o } = s;
|
|
2848
2852
|
let a, l;
|
|
2849
|
-
const c = (f,
|
|
2853
|
+
const c = (f, p, g) => t(n + f, p, g);
|
|
2850
2854
|
switch (i) {
|
|
2851
2855
|
case "scalar":
|
|
2852
|
-
a = O.PLAIN, l =
|
|
2856
|
+
a = O.PLAIN, l = wn(r, c);
|
|
2853
2857
|
break;
|
|
2854
2858
|
case "single-quoted-scalar":
|
|
2855
|
-
a = O.QUOTE_SINGLE, l =
|
|
2859
|
+
a = O.QUOTE_SINGLE, l = kn(r, c);
|
|
2856
2860
|
break;
|
|
2857
2861
|
case "double-quoted-scalar":
|
|
2858
|
-
a = O.QUOTE_DOUBLE, l =
|
|
2862
|
+
a = O.QUOTE_DOUBLE, l = Sn(r, c);
|
|
2859
2863
|
break;
|
|
2860
2864
|
/* istanbul ignore next should not happen */
|
|
2861
2865
|
default:
|
|
@@ -2866,7 +2870,7 @@ function pn(s, e, t) {
|
|
|
2866
2870
|
range: [n, n + r.length, n + r.length]
|
|
2867
2871
|
};
|
|
2868
2872
|
}
|
|
2869
|
-
const d = n + r.length, u =
|
|
2873
|
+
const d = n + r.length, u = Se(o, d, e, t);
|
|
2870
2874
|
return {
|
|
2871
2875
|
value: l,
|
|
2872
2876
|
type: a,
|
|
@@ -2874,7 +2878,7 @@ function pn(s, e, t) {
|
|
|
2874
2878
|
range: [n, d, u.offset]
|
|
2875
2879
|
};
|
|
2876
2880
|
}
|
|
2877
|
-
function
|
|
2881
|
+
function wn(s, e) {
|
|
2878
2882
|
let t = "";
|
|
2879
2883
|
switch (s[0]) {
|
|
2880
2884
|
/* istanbul ignore next should not happen */
|
|
@@ -2898,12 +2902,12 @@ function mn(s, e) {
|
|
|
2898
2902
|
break;
|
|
2899
2903
|
}
|
|
2900
2904
|
}
|
|
2901
|
-
return t && e(0, "BAD_SCALAR_START", `Plain value cannot start with ${t}`),
|
|
2905
|
+
return t && e(0, "BAD_SCALAR_START", `Plain value cannot start with ${t}`), hs(s);
|
|
2902
2906
|
}
|
|
2903
|
-
function
|
|
2904
|
-
return (s[s.length - 1] !== "'" || s.length === 1) && e(s.length, "MISSING_CHAR", "Missing closing 'quote"),
|
|
2907
|
+
function kn(s, e) {
|
|
2908
|
+
return (s[s.length - 1] !== "'" || s.length === 1) && e(s.length, "MISSING_CHAR", "Missing closing 'quote"), hs(s.slice(1, -1)).replace(/''/g, "'");
|
|
2905
2909
|
}
|
|
2906
|
-
function
|
|
2910
|
+
function hs(s) {
|
|
2907
2911
|
let e, t;
|
|
2908
2912
|
try {
|
|
2909
2913
|
e = new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
@@ -2923,7 +2927,7 @@ function as(s) {
|
|
|
2923
2927
|
const a = /[ \t]*(.*)/sy;
|
|
2924
2928
|
return a.lastIndex = o, n = a.exec(s), i + r + (n?.[1] ?? "");
|
|
2925
2929
|
}
|
|
2926
|
-
function
|
|
2930
|
+
function Sn(s, e) {
|
|
2927
2931
|
let t = "";
|
|
2928
2932
|
for (let n = 1; n < s.length - 1; ++n) {
|
|
2929
2933
|
const i = s[n];
|
|
@@ -2931,11 +2935,11 @@ function yn(s, e) {
|
|
|
2931
2935
|
`))
|
|
2932
2936
|
if (i === `
|
|
2933
2937
|
`) {
|
|
2934
|
-
const { fold: r, offset: o } =
|
|
2938
|
+
const { fold: r, offset: o } = Nn(s, n);
|
|
2935
2939
|
t += r, n = o;
|
|
2936
2940
|
} else if (i === "\\") {
|
|
2937
2941
|
let r = s[++n];
|
|
2938
|
-
const o =
|
|
2942
|
+
const o = On[r];
|
|
2939
2943
|
if (o)
|
|
2940
2944
|
t += o;
|
|
2941
2945
|
else if (r === `
|
|
@@ -2948,7 +2952,7 @@ function yn(s, e) {
|
|
|
2948
2952
|
r = s[++n + 1];
|
|
2949
2953
|
else if (r === "x" || r === "u" || r === "U") {
|
|
2950
2954
|
const a = { x: 2, u: 4, U: 8 }[r];
|
|
2951
|
-
t +=
|
|
2955
|
+
t += An(s, n + 1, a, e), n += a;
|
|
2952
2956
|
} else {
|
|
2953
2957
|
const a = s.substr(n - 1, 2);
|
|
2954
2958
|
e(n - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${a}`), t += a;
|
|
@@ -2966,7 +2970,7 @@ function yn(s, e) {
|
|
|
2966
2970
|
}
|
|
2967
2971
|
return (s[s.length - 1] !== '"' || s.length === 1) && e(s.length, "MISSING_CHAR", 'Missing closing "quote'), t;
|
|
2968
2972
|
}
|
|
2969
|
-
function
|
|
2973
|
+
function Nn(s, e) {
|
|
2970
2974
|
let t = "", n = s[e + 1];
|
|
2971
2975
|
for (; (n === " " || n === " " || n === `
|
|
2972
2976
|
` || n === "\r") && !(n === "\r" && s[e + 2] !== `
|
|
@@ -2976,7 +2980,7 @@ function bn(s, e) {
|
|
|
2976
2980
|
`), e += 1, n = s[e + 1];
|
|
2977
2981
|
return t || (t = " "), { fold: t, offset: e };
|
|
2978
2982
|
}
|
|
2979
|
-
const
|
|
2983
|
+
const On = {
|
|
2980
2984
|
0: "\0",
|
|
2981
2985
|
// null character
|
|
2982
2986
|
a: "\x07",
|
|
@@ -3010,7 +3014,7 @@ const wn = {
|
|
|
3010
3014
|
"\\": "\\",
|
|
3011
3015
|
" ": " "
|
|
3012
3016
|
};
|
|
3013
|
-
function
|
|
3017
|
+
function An(s, e, t, n) {
|
|
3014
3018
|
const i = s.substr(e, t), o = i.length === t && /^[0-9a-fA-F]+$/.test(i) ? parseInt(i, 16) : NaN;
|
|
3015
3019
|
if (isNaN(o)) {
|
|
3016
3020
|
const a = s.substr(e - 2, t + 2);
|
|
@@ -3018,10 +3022,10 @@ function kn(s, e, t, n) {
|
|
|
3018
3022
|
}
|
|
3019
3023
|
return String.fromCodePoint(o);
|
|
3020
3024
|
}
|
|
3021
|
-
function
|
|
3022
|
-
const { value: i, type: r, comment: o, range: a } = e.type === "block-scalar" ?
|
|
3025
|
+
function ds(s, e, t, n) {
|
|
3026
|
+
const { value: i, type: r, comment: o, range: a } = e.type === "block-scalar" ? mn(s, e, n) : bn(e, s.options.strict, n), l = t ? s.directives.tagName(t.source, (u) => n(t, "TAG_RESOLVE_FAILED", u)) : null;
|
|
3023
3027
|
let c;
|
|
3024
|
-
s.options.stringKeys && s.atKey ? c = s.schema[
|
|
3028
|
+
s.options.stringKeys && s.atKey ? c = s.schema[U] : l ? c = En(s.schema, i, l, t, n) : e.type === "scalar" ? c = Tn(s, i, e, n) : c = s.schema[U];
|
|
3025
3029
|
let d;
|
|
3026
3030
|
try {
|
|
3027
3031
|
const u = c.resolve(i, (f) => n(t ?? e, "TAG_RESOLVE_FAILED", f), s.options);
|
|
@@ -3032,9 +3036,9 @@ function ls(s, e, t, n) {
|
|
|
3032
3036
|
}
|
|
3033
3037
|
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;
|
|
3034
3038
|
}
|
|
3035
|
-
function
|
|
3039
|
+
function En(s, e, t, n, i) {
|
|
3036
3040
|
if (t === "!")
|
|
3037
|
-
return s[
|
|
3041
|
+
return s[U];
|
|
3038
3042
|
const r = [];
|
|
3039
3043
|
for (const a of s.tags)
|
|
3040
3044
|
if (!a.collection && a.tag === t)
|
|
@@ -3046,12 +3050,12 @@ function Sn(s, e, t, n, i) {
|
|
|
3046
3050
|
if (a.test?.test(e))
|
|
3047
3051
|
return a;
|
|
3048
3052
|
const o = s.knownTags[t];
|
|
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[
|
|
3053
|
+
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[U]);
|
|
3050
3054
|
}
|
|
3051
|
-
function
|
|
3052
|
-
const o = t.tags.find((a) => (a.default === !0 || s && a.default === "key") && a.test?.test(n)) || t[
|
|
3055
|
+
function Tn({ atKey: s, directives: e, schema: t }, n, i, r) {
|
|
3056
|
+
const o = t.tags.find((a) => (a.default === !0 || s && a.default === "key") && a.test?.test(n)) || t[U];
|
|
3053
3057
|
if (t.compat) {
|
|
3054
|
-
const a = t.compat.find((l) => l.default && l.test?.test(n)) ?? t[
|
|
3058
|
+
const a = t.compat.find((l) => l.default && l.test?.test(n)) ?? t[U];
|
|
3055
3059
|
if (o.tag !== a.tag) {
|
|
3056
3060
|
const l = e.tagString(o.tag), c = e.tagString(a.tag), d = `Value may be parsed as either ${l} or ${c}`;
|
|
3057
3061
|
r(i, "TAG_RESOLVE_FAILED", d, !0);
|
|
@@ -3059,7 +3063,7 @@ function Nn({ atKey: s, directives: e, schema: t }, n, i, r) {
|
|
|
3059
3063
|
}
|
|
3060
3064
|
return o;
|
|
3061
3065
|
}
|
|
3062
|
-
function
|
|
3066
|
+
function In(s, e, t) {
|
|
3063
3067
|
if (e) {
|
|
3064
3068
|
t ?? (t = e.length);
|
|
3065
3069
|
for (let n = t - 1; n >= 0; --n) {
|
|
@@ -3078,55 +3082,55 @@ function On(s, e, t) {
|
|
|
3078
3082
|
}
|
|
3079
3083
|
return s;
|
|
3080
3084
|
}
|
|
3081
|
-
const
|
|
3082
|
-
function
|
|
3085
|
+
const $n = { composeNode: ps, composeEmptyNode: bt };
|
|
3086
|
+
function ps(s, e, t, n) {
|
|
3083
3087
|
const i = s.atKey, { spaceBefore: r, comment: o, anchor: a, tag: l } = t;
|
|
3084
3088
|
let c, d = !0;
|
|
3085
3089
|
switch (e.type) {
|
|
3086
3090
|
case "alias":
|
|
3087
|
-
c =
|
|
3091
|
+
c = Ln(s, e, n), (a || l) && n(e, "ALIAS_PROPS", "An alias node must not specify any properties");
|
|
3088
3092
|
break;
|
|
3089
3093
|
case "scalar":
|
|
3090
3094
|
case "single-quoted-scalar":
|
|
3091
3095
|
case "double-quoted-scalar":
|
|
3092
3096
|
case "block-scalar":
|
|
3093
|
-
c =
|
|
3097
|
+
c = ds(s, e, l, n), a && (c.anchor = a.source.substring(1));
|
|
3094
3098
|
break;
|
|
3095
3099
|
case "block-map":
|
|
3096
3100
|
case "block-seq":
|
|
3097
3101
|
case "flow-collection":
|
|
3098
|
-
c =
|
|
3102
|
+
c = pn($n, s, e, t, n), a && (c.anchor = a.source.substring(1));
|
|
3099
3103
|
break;
|
|
3100
3104
|
default: {
|
|
3101
3105
|
const u = e.type === "error" ? e.message : `Unsupported token (type: ${e.type})`;
|
|
3102
|
-
n(e, "UNEXPECTED_TOKEN", u), c =
|
|
3106
|
+
n(e, "UNEXPECTED_TOKEN", u), c = bt(s, e.offset, void 0, null, t, n), d = !1;
|
|
3103
3107
|
}
|
|
3104
3108
|
}
|
|
3105
3109
|
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;
|
|
3106
3110
|
}
|
|
3107
|
-
function
|
|
3111
|
+
function bt(s, e, t, n, { spaceBefore: i, comment: r, anchor: o, tag: a, end: l }, c) {
|
|
3108
3112
|
const d = {
|
|
3109
3113
|
type: "scalar",
|
|
3110
|
-
offset:
|
|
3114
|
+
offset: In(e, t, n),
|
|
3111
3115
|
indent: -1,
|
|
3112
3116
|
source: ""
|
|
3113
|
-
}, u =
|
|
3117
|
+
}, u = ds(s, d, a, c);
|
|
3114
3118
|
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;
|
|
3115
3119
|
}
|
|
3116
|
-
function
|
|
3117
|
-
const r = new
|
|
3120
|
+
function Ln({ options: s }, { offset: e, source: t, end: n }, i) {
|
|
3121
|
+
const r = new ot(t.substring(1));
|
|
3118
3122
|
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);
|
|
3119
|
-
const o = e + t.length, a =
|
|
3123
|
+
const o = e + t.length, a = Se(n, o, s.strict, i);
|
|
3120
3124
|
return r.range = [e, o, a.offset], a.comment && (r.comment = a.comment), r;
|
|
3121
3125
|
}
|
|
3122
|
-
function
|
|
3123
|
-
const a = Object.assign({ _directives: e }, s), l = new
|
|
3126
|
+
function vn(s, e, { offset: t, start: n, value: i, end: r }, o) {
|
|
3127
|
+
const a = Object.assign({ _directives: e }, s), l = new qe(void 0, a), c = {
|
|
3124
3128
|
atKey: !1,
|
|
3125
3129
|
atRoot: !0,
|
|
3126
3130
|
directives: l.directives,
|
|
3127
3131
|
options: l.options,
|
|
3128
3132
|
schema: l.schema
|
|
3129
|
-
}, d =
|
|
3133
|
+
}, d = oe(n, {
|
|
3130
3134
|
indicator: "doc-start",
|
|
3131
3135
|
next: i ?? r?.[0],
|
|
3132
3136
|
offset: t,
|
|
@@ -3134,11 +3138,11 @@ function Tn(s, e, { offset: t, start: n, value: i, end: r }, o) {
|
|
|
3134
3138
|
parentIndent: 0,
|
|
3135
3139
|
startOnNewline: !0
|
|
3136
3140
|
});
|
|
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 ?
|
|
3138
|
-
const u = l.contents.range[2], f =
|
|
3141
|
+
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 ? ps(c, i, d, o) : bt(c, d.end, n, null, d, o);
|
|
3142
|
+
const u = l.contents.range[2], f = Se(r, u, !1, o);
|
|
3139
3143
|
return f.comment && (l.comment = f.comment), l.range = [t, u, f.offset], l;
|
|
3140
3144
|
}
|
|
3141
|
-
function
|
|
3145
|
+
function ue(s) {
|
|
3142
3146
|
if (typeof s == "number")
|
|
3143
3147
|
return [s, s + 1];
|
|
3144
3148
|
if (Array.isArray(s))
|
|
@@ -3146,7 +3150,7 @@ function fe(s) {
|
|
|
3146
3150
|
const { offset: e, source: t } = s;
|
|
3147
3151
|
return [e, e + (typeof t == "string" ? t.length : 1)];
|
|
3148
3152
|
}
|
|
3149
|
-
function
|
|
3153
|
+
function $t(s) {
|
|
3150
3154
|
let e = "", t = !1, n = !1;
|
|
3151
3155
|
for (let i = 0; i < s.length; ++i) {
|
|
3152
3156
|
const r = s[i];
|
|
@@ -3166,15 +3170,15 @@ function It(s) {
|
|
|
3166
3170
|
}
|
|
3167
3171
|
return { comment: e, afterEmptyLine: n };
|
|
3168
3172
|
}
|
|
3169
|
-
class
|
|
3173
|
+
class Cn {
|
|
3170
3174
|
constructor(e = {}) {
|
|
3171
3175
|
this.doc = null, this.atDirectives = !1, this.prelude = [], this.errors = [], this.warnings = [], this.onError = (t, n, i, r) => {
|
|
3172
|
-
const o =
|
|
3173
|
-
r ? this.warnings.push(new
|
|
3176
|
+
const o = ue(t);
|
|
3177
|
+
r ? this.warnings.push(new fn(o, n, i)) : this.errors.push(new de(o, n, i));
|
|
3174
3178
|
}, this.directives = new _({ version: e.version || "1.2" }), this.options = e;
|
|
3175
3179
|
}
|
|
3176
3180
|
decorate(e, t) {
|
|
3177
|
-
const { comment: n, afterEmptyLine: i } =
|
|
3181
|
+
const { comment: n, afterEmptyLine: i } = $t(this.prelude);
|
|
3178
3182
|
if (n) {
|
|
3179
3183
|
const r = e.contents;
|
|
3180
3184
|
if (t)
|
|
@@ -3203,7 +3207,7 @@ ${o}` : n;
|
|
|
3203
3207
|
*/
|
|
3204
3208
|
streamInfo() {
|
|
3205
3209
|
return {
|
|
3206
|
-
comment:
|
|
3210
|
+
comment: $t(this.prelude).comment,
|
|
3207
3211
|
directives: this.directives,
|
|
3208
3212
|
errors: this.errors,
|
|
3209
3213
|
warnings: this.warnings
|
|
@@ -3225,12 +3229,12 @@ ${o}` : n;
|
|
|
3225
3229
|
switch (e.type) {
|
|
3226
3230
|
case "directive":
|
|
3227
3231
|
this.directives.add(e.source, (t, n, i) => {
|
|
3228
|
-
const r =
|
|
3232
|
+
const r = ue(e);
|
|
3229
3233
|
r[0] += t, this.onError(r, "BAD_DIRECTIVE", n, i);
|
|
3230
3234
|
}), this.prelude.push(e.source), this.atDirectives = !0;
|
|
3231
3235
|
break;
|
|
3232
3236
|
case "document": {
|
|
3233
|
-
const t =
|
|
3237
|
+
const t = vn(this.options, this.directives, e, this.onError);
|
|
3234
3238
|
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;
|
|
3235
3239
|
break;
|
|
3236
3240
|
}
|
|
@@ -3242,18 +3246,18 @@ ${o}` : n;
|
|
|
3242
3246
|
this.prelude.push(e.source);
|
|
3243
3247
|
break;
|
|
3244
3248
|
case "error": {
|
|
3245
|
-
const t = e.source ? `${e.message}: ${JSON.stringify(e.source)}` : e.message, n = new
|
|
3249
|
+
const t = e.source ? `${e.message}: ${JSON.stringify(e.source)}` : e.message, n = new de(ue(e), "UNEXPECTED_TOKEN", t);
|
|
3246
3250
|
this.atDirectives || !this.doc ? this.errors.push(n) : this.doc.errors.push(n);
|
|
3247
3251
|
break;
|
|
3248
3252
|
}
|
|
3249
3253
|
case "doc-end": {
|
|
3250
3254
|
if (!this.doc) {
|
|
3251
3255
|
const n = "Unexpected doc-end without preceding document";
|
|
3252
|
-
this.errors.push(new
|
|
3256
|
+
this.errors.push(new de(ue(e), "UNEXPECTED_TOKEN", n));
|
|
3253
3257
|
break;
|
|
3254
3258
|
}
|
|
3255
3259
|
this.doc.directives.docEnd = !0;
|
|
3256
|
-
const t =
|
|
3260
|
+
const t = Se(e.end, e.offset + e.source.length, this.doc.options.strict, this.onError);
|
|
3257
3261
|
if (this.decorate(this.doc, !0), t.comment) {
|
|
3258
3262
|
const n = this.doc.comment;
|
|
3259
3263
|
this.doc.comment = n ? `${n}
|
|
@@ -3263,7 +3267,7 @@ ${t.comment}` : t.comment;
|
|
|
3263
3267
|
break;
|
|
3264
3268
|
}
|
|
3265
3269
|
default:
|
|
3266
|
-
this.errors.push(new
|
|
3270
|
+
this.errors.push(new de(ue(e), "UNEXPECTED_TOKEN", `Unsupported token ${e.type}`));
|
|
3267
3271
|
}
|
|
3268
3272
|
}
|
|
3269
3273
|
/**
|
|
@@ -3276,19 +3280,19 @@ ${t.comment}` : t.comment;
|
|
|
3276
3280
|
if (this.doc)
|
|
3277
3281
|
this.decorate(this.doc, !0), yield this.doc, this.doc = null;
|
|
3278
3282
|
else if (e) {
|
|
3279
|
-
const n = Object.assign({ _directives: this.directives }, this.options), i = new
|
|
3283
|
+
const n = Object.assign({ _directives: this.directives }, this.options), i = new qe(void 0, n);
|
|
3280
3284
|
this.atDirectives && this.onError(t, "MISSING_CHAR", "Missing directives-end indicator line"), i.range = [0, t, t], this.decorate(i, !1), yield i;
|
|
3281
3285
|
}
|
|
3282
3286
|
}
|
|
3283
3287
|
}
|
|
3284
|
-
const
|
|
3285
|
-
function
|
|
3288
|
+
const ms = "\uFEFF", gs = "", ys = "", et = "";
|
|
3289
|
+
function _n(s) {
|
|
3286
3290
|
switch (s) {
|
|
3287
|
-
case
|
|
3291
|
+
case ms:
|
|
3288
3292
|
return "byte-order-mark";
|
|
3289
|
-
case
|
|
3293
|
+
case gs:
|
|
3290
3294
|
return "doc-mode";
|
|
3291
|
-
case
|
|
3295
|
+
case ys:
|
|
3292
3296
|
return "flow-error-end";
|
|
3293
3297
|
case et:
|
|
3294
3298
|
return "scalar";
|
|
@@ -3356,9 +3360,9 @@ function K(s) {
|
|
|
3356
3360
|
return !1;
|
|
3357
3361
|
}
|
|
3358
3362
|
}
|
|
3359
|
-
const
|
|
3360
|
-
\r `),
|
|
3361
|
-
class
|
|
3363
|
+
const Lt = new Set("0123456789ABCDEFabcdef"), jn = new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"), Ee = new Set(",[]{}"), Bn = new Set(` ,[]{}
|
|
3364
|
+
\r `), He = (s) => !s || Bn.has(s);
|
|
3365
|
+
class Mn {
|
|
3362
3366
|
constructor() {
|
|
3363
3367
|
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;
|
|
3364
3368
|
}
|
|
@@ -3450,7 +3454,7 @@ class Cn {
|
|
|
3450
3454
|
let e = this.getLine();
|
|
3451
3455
|
if (e === null)
|
|
3452
3456
|
return this.setNext("stream");
|
|
3453
|
-
if (e[0] ===
|
|
3457
|
+
if (e[0] === ms && (yield* this.pushCount(1), e = e.substring(1)), e[0] === "%") {
|
|
3454
3458
|
let t = e.length, n = e.indexOf("#");
|
|
3455
3459
|
for (; n !== -1; ) {
|
|
3456
3460
|
const r = e[n - 1];
|
|
@@ -3474,7 +3478,7 @@ class Cn {
|
|
|
3474
3478
|
const t = yield* this.pushSpaces(!0);
|
|
3475
3479
|
return yield* this.pushCount(e.length - t), yield* this.pushNewline(), "stream";
|
|
3476
3480
|
}
|
|
3477
|
-
return yield
|
|
3481
|
+
return yield gs, yield* this.parseLineStart();
|
|
3478
3482
|
}
|
|
3479
3483
|
*parseLineStart() {
|
|
3480
3484
|
const e = this.charAt(0);
|
|
@@ -3518,7 +3522,7 @@ class Cn {
|
|
|
3518
3522
|
case "]":
|
|
3519
3523
|
return yield* this.pushCount(1), "doc";
|
|
3520
3524
|
case "*":
|
|
3521
|
-
return yield* this.pushUntil(
|
|
3525
|
+
return yield* this.pushUntil(He), "doc";
|
|
3522
3526
|
case '"':
|
|
3523
3527
|
case "'":
|
|
3524
3528
|
return yield* this.parseQuotedScalar();
|
|
@@ -3538,7 +3542,7 @@ class Cn {
|
|
|
3538
3542
|
if (i === null)
|
|
3539
3543
|
return this.setNext("flow");
|
|
3540
3544
|
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] === "}")))
|
|
3541
|
-
return this.flowLevel = 0, yield
|
|
3545
|
+
return this.flowLevel = 0, yield ys, yield* this.parseLineStart();
|
|
3542
3546
|
let r = 0;
|
|
3543
3547
|
for (; i[r] === ","; )
|
|
3544
3548
|
r += yield* this.pushCount(1), r += yield* this.pushSpaces(!0), this.flowKey = !1;
|
|
@@ -3554,7 +3558,7 @@ class Cn {
|
|
|
3554
3558
|
case "]":
|
|
3555
3559
|
return yield* this.pushCount(1), this.flowKey = !0, this.flowLevel -= 1, this.flowLevel ? "flow" : "doc";
|
|
3556
3560
|
case "*":
|
|
3557
|
-
return yield* this.pushUntil(
|
|
3561
|
+
return yield* this.pushUntil(He), "flow";
|
|
3558
3562
|
case '"':
|
|
3559
3563
|
case "'":
|
|
3560
3564
|
return this.flowKey = !0, yield* this.parseQuotedScalar();
|
|
@@ -3686,14 +3690,14 @@ class Cn {
|
|
|
3686
3690
|
for (; i = this.buffer[++n]; )
|
|
3687
3691
|
if (i === ":") {
|
|
3688
3692
|
const r = this.buffer[n + 1];
|
|
3689
|
-
if (K(r) || e &&
|
|
3693
|
+
if (K(r) || e && Ee.has(r))
|
|
3690
3694
|
break;
|
|
3691
3695
|
t = n;
|
|
3692
3696
|
} else if (K(i)) {
|
|
3693
3697
|
let r = this.buffer[n + 1];
|
|
3694
3698
|
if (i === "\r" && (r === `
|
|
3695
3699
|
` ? (n += 1, i = `
|
|
3696
|
-
`, r = this.buffer[n + 1]) : t = n), r === "#" || e &&
|
|
3700
|
+
`, r = this.buffer[n + 1]) : t = n), r === "#" || e && Ee.has(r))
|
|
3697
3701
|
break;
|
|
3698
3702
|
if (i === `
|
|
3699
3703
|
`) {
|
|
@@ -3703,7 +3707,7 @@ class Cn {
|
|
|
3703
3707
|
n = Math.max(n, o - 2);
|
|
3704
3708
|
}
|
|
3705
3709
|
} else {
|
|
3706
|
-
if (e &&
|
|
3710
|
+
if (e && Ee.has(i))
|
|
3707
3711
|
break;
|
|
3708
3712
|
t = n;
|
|
3709
3713
|
}
|
|
@@ -3721,14 +3725,14 @@ class Cn {
|
|
|
3721
3725
|
case "!":
|
|
3722
3726
|
return (yield* this.pushTag()) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators());
|
|
3723
3727
|
case "&":
|
|
3724
|
-
return (yield* this.pushUntil(
|
|
3728
|
+
return (yield* this.pushUntil(He)) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators());
|
|
3725
3729
|
case "-":
|
|
3726
3730
|
// this is an error
|
|
3727
3731
|
case "?":
|
|
3728
3732
|
// this is an error outside flow collections
|
|
3729
3733
|
case ":": {
|
|
3730
3734
|
const e = this.flowLevel > 0, t = this.charAt(1);
|
|
3731
|
-
if (K(t) || e &&
|
|
3735
|
+
if (K(t) || e && Ee.has(t))
|
|
3732
3736
|
return e ? this.flowKey && (this.flowKey = !1) : this.indentNext = this.indentValue + 1, (yield* this.pushCount(1)) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators());
|
|
3733
3737
|
}
|
|
3734
3738
|
}
|
|
@@ -3743,9 +3747,9 @@ class Cn {
|
|
|
3743
3747
|
} else {
|
|
3744
3748
|
let e = this.pos + 1, t = this.buffer[e];
|
|
3745
3749
|
for (; t; )
|
|
3746
|
-
if (
|
|
3750
|
+
if (jn.has(t))
|
|
3747
3751
|
t = this.buffer[++e];
|
|
3748
|
-
else if (t === "%" &&
|
|
3752
|
+
else if (t === "%" && Lt.has(this.buffer[e + 1]) && Lt.has(this.buffer[e + 2]))
|
|
3749
3753
|
t = this.buffer[e += 3];
|
|
3750
3754
|
else
|
|
3751
3755
|
break;
|
|
@@ -3773,7 +3777,7 @@ class Cn {
|
|
|
3773
3777
|
return yield* this.pushToIndex(t, !1);
|
|
3774
3778
|
}
|
|
3775
3779
|
}
|
|
3776
|
-
class
|
|
3780
|
+
class Pn {
|
|
3777
3781
|
constructor() {
|
|
3778
3782
|
this.lineStarts = [], this.addNewLine = (e) => this.lineStarts.push(e), this.linePos = (e) => {
|
|
3779
3783
|
let t = 0, n = this.lineStarts.length;
|
|
@@ -3796,7 +3800,7 @@ function V(s, e) {
|
|
|
3796
3800
|
return !0;
|
|
3797
3801
|
return !1;
|
|
3798
3802
|
}
|
|
3799
|
-
function
|
|
3803
|
+
function vt(s) {
|
|
3800
3804
|
for (let e = 0; e < s.length; ++e)
|
|
3801
3805
|
switch (s[e].type) {
|
|
3802
3806
|
case "space":
|
|
@@ -3808,7 +3812,7 @@ function Lt(s) {
|
|
|
3808
3812
|
}
|
|
3809
3813
|
return -1;
|
|
3810
3814
|
}
|
|
3811
|
-
function
|
|
3815
|
+
function bs(s) {
|
|
3812
3816
|
switch (s?.type) {
|
|
3813
3817
|
case "alias":
|
|
3814
3818
|
case "scalar":
|
|
@@ -3820,7 +3824,7 @@ function ds(s) {
|
|
|
3820
3824
|
return !1;
|
|
3821
3825
|
}
|
|
3822
3826
|
}
|
|
3823
|
-
function
|
|
3827
|
+
function Te(s) {
|
|
3824
3828
|
switch (s.type) {
|
|
3825
3829
|
case "document":
|
|
3826
3830
|
return s.start;
|
|
@@ -3835,7 +3839,7 @@ function Ee(s) {
|
|
|
3835
3839
|
return [];
|
|
3836
3840
|
}
|
|
3837
3841
|
}
|
|
3838
|
-
function
|
|
3842
|
+
function Z(s) {
|
|
3839
3843
|
if (s.length === 0)
|
|
3840
3844
|
return [];
|
|
3841
3845
|
let e = s.length;
|
|
@@ -3852,18 +3856,18 @@ function z(s) {
|
|
|
3852
3856
|
;
|
|
3853
3857
|
return s.splice(e, s.length);
|
|
3854
3858
|
}
|
|
3855
|
-
function
|
|
3859
|
+
function Ct(s) {
|
|
3856
3860
|
if (s.start.type === "flow-seq-start")
|
|
3857
3861
|
for (const e of s.items)
|
|
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,
|
|
3862
|
+
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, bs(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);
|
|
3859
3863
|
}
|
|
3860
|
-
class
|
|
3864
|
+
class Kn {
|
|
3861
3865
|
/**
|
|
3862
3866
|
* @param onNewLine - If defined, called separately with the start position of
|
|
3863
3867
|
* each new line (in `parse()`, including the start of input).
|
|
3864
3868
|
*/
|
|
3865
3869
|
constructor(e) {
|
|
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
|
|
3870
|
+
this.atNewLine = !0, this.atScalar = !1, this.indent = 0, this.offset = 0, this.onKeyLine = !1, this.stack = [], this.source = "", this.type = "", this.lexer = new Mn(), this.onNewLine = e;
|
|
3867
3871
|
}
|
|
3868
3872
|
/**
|
|
3869
3873
|
* Parse `source` as a YAML stream.
|
|
@@ -3887,7 +3891,7 @@ class Bn {
|
|
|
3887
3891
|
this.atScalar = !1, yield* this.step(), this.offset += e.length;
|
|
3888
3892
|
return;
|
|
3889
3893
|
}
|
|
3890
|
-
const t =
|
|
3894
|
+
const t = _n(e);
|
|
3891
3895
|
if (t)
|
|
3892
3896
|
if (t === "scalar")
|
|
3893
3897
|
this.atNewLine = !1, this.atScalar = !0, this.type = "scalar";
|
|
@@ -3976,7 +3980,7 @@ class Bn {
|
|
|
3976
3980
|
yield t;
|
|
3977
3981
|
else {
|
|
3978
3982
|
const n = this.peek(1);
|
|
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" &&
|
|
3983
|
+
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" && Ct(t), n.type) {
|
|
3980
3984
|
case "document":
|
|
3981
3985
|
n.value = t;
|
|
3982
3986
|
break;
|
|
@@ -4012,7 +4016,7 @@ class Bn {
|
|
|
4012
4016
|
}
|
|
4013
4017
|
if ((n.type === "document" || n.type === "block-map" || n.type === "block-seq") && (t.type === "block-map" || t.type === "block-seq")) {
|
|
4014
4018
|
const i = t.items[t.items.length - 1];
|
|
4015
|
-
i && !i.sep && !i.value && i.start.length > 0 &&
|
|
4019
|
+
i && !i.sep && !i.value && i.start.length > 0 && vt(i.start) === -1 && (t.indent === 0 || i.start.every((r) => r.type !== "comment" || r.indent < t.indent)) && (n.type === "document" ? n.end = i.start : n.items.push({ start: i.start }), t.items.splice(-1, 1));
|
|
4016
4020
|
}
|
|
4017
4021
|
}
|
|
4018
4022
|
}
|
|
@@ -4050,7 +4054,7 @@ class Bn {
|
|
|
4050
4054
|
return yield* this.lineEnd(e);
|
|
4051
4055
|
switch (this.type) {
|
|
4052
4056
|
case "doc-start": {
|
|
4053
|
-
|
|
4057
|
+
vt(e.start) !== -1 ? (yield* this.pop(), yield* this.step()) : e.start.push(this.sourceToken);
|
|
4054
4058
|
return;
|
|
4055
4059
|
}
|
|
4056
4060
|
case "anchor":
|
|
@@ -4071,7 +4075,7 @@ class Bn {
|
|
|
4071
4075
|
}
|
|
4072
4076
|
*scalar(e) {
|
|
4073
4077
|
if (this.type === "map-value-ind") {
|
|
4074
|
-
const t =
|
|
4078
|
+
const t = Te(this.peek(2)), n = Z(t);
|
|
4075
4079
|
let i;
|
|
4076
4080
|
e.end ? (i = e.end, i.push(this.sourceToken), delete e.end) : i = [this.sourceToken];
|
|
4077
4081
|
const r = {
|
|
@@ -4180,8 +4184,8 @@ class Bn {
|
|
|
4180
4184
|
indent: this.indent,
|
|
4181
4185
|
items: [{ start: r, key: null, sep: [this.sourceToken] }]
|
|
4182
4186
|
});
|
|
4183
|
-
else if (
|
|
4184
|
-
const o =
|
|
4187
|
+
else if (bs(t.key) && !V(t.sep, "newline")) {
|
|
4188
|
+
const o = Z(t.start), a = t.key, l = t.sep;
|
|
4185
4189
|
l.push(this.sourceToken), delete t.key, delete t.sep, this.stack.push({
|
|
4186
4190
|
type: "block-map",
|
|
4187
4191
|
offset: this.offset,
|
|
@@ -4192,7 +4196,7 @@ class Bn {
|
|
|
4192
4196
|
else if (V(t.start, "newline"))
|
|
4193
4197
|
Object.assign(t, { key: null, sep: [this.sourceToken] });
|
|
4194
4198
|
else {
|
|
4195
|
-
const o =
|
|
4199
|
+
const o = Z(t.start);
|
|
4196
4200
|
this.stack.push({
|
|
4197
4201
|
type: "block-map",
|
|
4198
4202
|
offset: this.offset,
|
|
@@ -4328,8 +4332,8 @@ class Bn {
|
|
|
4328
4332
|
if (n.type === "block-map" && (this.type === "map-value-ind" && n.indent === e.indent || this.type === "newline" && !n.items[n.items.length - 1].sep))
|
|
4329
4333
|
yield* this.pop(), yield* this.step();
|
|
4330
4334
|
else if (this.type === "map-value-ind" && n.type !== "flow-collection") {
|
|
4331
|
-
const i =
|
|
4332
|
-
|
|
4335
|
+
const i = Te(n), r = Z(i);
|
|
4336
|
+
Ct(e);
|
|
4333
4337
|
const o = e.end.splice(1, e.end.length);
|
|
4334
4338
|
o.push(this.sourceToken);
|
|
4335
4339
|
const a = {
|
|
@@ -4392,7 +4396,7 @@ class Bn {
|
|
|
4392
4396
|
};
|
|
4393
4397
|
case "explicit-key-ind": {
|
|
4394
4398
|
this.onKeyLine = !0;
|
|
4395
|
-
const t =
|
|
4399
|
+
const t = Te(e), n = Z(t);
|
|
4396
4400
|
return n.push(this.sourceToken), {
|
|
4397
4401
|
type: "block-map",
|
|
4398
4402
|
offset: this.offset,
|
|
@@ -4402,7 +4406,7 @@ class Bn {
|
|
|
4402
4406
|
}
|
|
4403
4407
|
case "map-value-ind": {
|
|
4404
4408
|
this.onKeyLine = !0;
|
|
4405
|
-
const t =
|
|
4409
|
+
const t = Te(e), n = Z(t);
|
|
4406
4410
|
return {
|
|
4407
4411
|
type: "block-map",
|
|
4408
4412
|
offset: this.offset,
|
|
@@ -4436,44 +4440,44 @@ class Bn {
|
|
|
4436
4440
|
}
|
|
4437
4441
|
}
|
|
4438
4442
|
}
|
|
4439
|
-
function
|
|
4443
|
+
function Dn(s) {
|
|
4440
4444
|
const e = s.prettyErrors !== !1;
|
|
4441
|
-
return { lineCounter: s.lineCounter || e && new
|
|
4445
|
+
return { lineCounter: s.lineCounter || e && new Pn() || null, prettyErrors: e };
|
|
4442
4446
|
}
|
|
4443
|
-
function
|
|
4444
|
-
const { lineCounter: t, prettyErrors: n } =
|
|
4447
|
+
function Un(s, e = {}) {
|
|
4448
|
+
const { lineCounter: t, prettyErrors: n } = Dn(e), i = new Kn(t?.addNewLine), r = new Cn(e);
|
|
4445
4449
|
let o = null;
|
|
4446
4450
|
for (const a of r.compose(i.parse(s), !0, s.length))
|
|
4447
4451
|
if (!o)
|
|
4448
4452
|
o = a;
|
|
4449
4453
|
else if (o.options.logLevel !== "silent") {
|
|
4450
|
-
o.errors.push(new
|
|
4454
|
+
o.errors.push(new de(a.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
|
|
4451
4455
|
break;
|
|
4452
4456
|
}
|
|
4453
|
-
return n && t && (o.errors.forEach(
|
|
4457
|
+
return n && t && (o.errors.forEach(Tt(s, t)), o.warnings.forEach(Tt(s, t))), o;
|
|
4454
4458
|
}
|
|
4455
|
-
function
|
|
4459
|
+
function Fn(s, e, t) {
|
|
4456
4460
|
let n;
|
|
4457
|
-
const i =
|
|
4461
|
+
const i = Un(s, t);
|
|
4458
4462
|
if (!i)
|
|
4459
4463
|
return null;
|
|
4460
|
-
if (i.warnings.forEach((r) =>
|
|
4464
|
+
if (i.warnings.forEach((r) => Yt(i.options.logLevel, r)), i.errors.length > 0) {
|
|
4461
4465
|
if (i.options.logLevel !== "silent")
|
|
4462
4466
|
throw i.errors[0];
|
|
4463
4467
|
i.errors = [];
|
|
4464
4468
|
}
|
|
4465
4469
|
return i.toJS(Object.assign({ reviver: n }, t));
|
|
4466
4470
|
}
|
|
4467
|
-
function
|
|
4468
|
-
return
|
|
4471
|
+
function Rn(s) {
|
|
4472
|
+
return kt.isAbsolute(s) ? s : kt.resolve(process.cwd(), s);
|
|
4469
4473
|
}
|
|
4470
|
-
async function
|
|
4474
|
+
async function qn(s) {
|
|
4471
4475
|
if (!s)
|
|
4472
4476
|
return { on: {} };
|
|
4473
|
-
const e =
|
|
4474
|
-
return e.endsWith(".yaml") || e.endsWith(".yml") ?
|
|
4477
|
+
const e = Rn(s), t = await tt(e, "utf8");
|
|
4478
|
+
return e.endsWith(".yaml") || e.endsWith(".yml") ? Fn(t) ?? { on: {} } : JSON.parse(t);
|
|
4475
4479
|
}
|
|
4476
|
-
function
|
|
4480
|
+
function Vn(s) {
|
|
4477
4481
|
return s.split(/\r?\n/u).map((e) => e.trim()).filter((e) => e.length > 0 && !e.startsWith("#")).reduce((e, t) => {
|
|
4478
4482
|
const n = t.indexOf("=");
|
|
4479
4483
|
if (n <= 0)
|
|
@@ -4482,54 +4486,66 @@ function qn(s) {
|
|
|
4482
4486
|
return e[i] = r, e;
|
|
4483
4487
|
}, {});
|
|
4484
4488
|
}
|
|
4485
|
-
async function
|
|
4489
|
+
async function Jn(s) {
|
|
4486
4490
|
const e = {};
|
|
4487
4491
|
for (const [t, n] of Object.entries(process.env))
|
|
4488
4492
|
typeof n == "string" && (e[t] = n);
|
|
4489
4493
|
for (const t of s ?? []) {
|
|
4490
4494
|
const n = await tt(t, "utf8");
|
|
4491
4495
|
if (t.endsWith(".json")) {
|
|
4492
|
-
const i =
|
|
4496
|
+
const i = nt(JSON.parse(n));
|
|
4493
4497
|
for (const [r, o] of Object.entries(i))
|
|
4494
4498
|
o != null && (e[r] = String(o));
|
|
4495
4499
|
continue;
|
|
4496
4500
|
}
|
|
4497
|
-
Object.assign(e,
|
|
4501
|
+
Object.assign(e, Vn(n));
|
|
4498
4502
|
}
|
|
4499
4503
|
return e;
|
|
4500
4504
|
}
|
|
4501
|
-
const
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4505
|
+
const ws = await _t(st(Bt(), "workflow-reports"));
|
|
4506
|
+
async function Yn(s, e) {
|
|
4507
|
+
try {
|
|
4508
|
+
const t = st(ws, `${s.id}.json`);
|
|
4509
|
+
await Os(
|
|
4510
|
+
t,
|
|
4511
|
+
JSON.stringify({ ...s, outputs: e }, null, 2),
|
|
4512
|
+
"utf8"
|
|
4513
|
+
);
|
|
4514
|
+
} catch (t) {
|
|
4515
|
+
const n = t instanceof Error ? t.message : String(t);
|
|
4516
|
+
console.error("Error writing report:", n);
|
|
4517
|
+
}
|
|
4518
|
+
}
|
|
4519
|
+
async function Gn(s) {
|
|
4520
|
+
try {
|
|
4521
|
+
return await import(st(ws, `${s}.json`));
|
|
4522
|
+
} catch (e) {
|
|
4523
|
+
const t = e instanceof Error ? e.message : String(e);
|
|
4524
|
+
return console.error("Error reading report:", t), null;
|
|
4525
|
+
}
|
|
4526
|
+
}
|
|
4527
|
+
const Wn = "/workspace", Hn = "dhi.io/alpine-base:3.23-alpine3.23-dev";
|
|
4528
|
+
function Qn(s, e) {
|
|
4513
4529
|
if (typeof s.run != "string")
|
|
4514
4530
|
throw new Error("Each workflow step must have a 'run' command string.");
|
|
4515
4531
|
const t = e.workflow.defaults || {};
|
|
4516
|
-
return s.image ||= t.image, s.volumes ||= t.volumes || {}, s.args ||= t.args, s.run =
|
|
4532
|
+
return s.image ||= t.image || Hn, s.volumes ||= t.volumes || {}, s.args ||= t.args || [], s.run = _e(s.run, { ...e, step: s }), s;
|
|
4517
4533
|
}
|
|
4518
|
-
function
|
|
4534
|
+
function Xn(s, e) {
|
|
4519
4535
|
return (s || []).flatMap(
|
|
4520
4536
|
(t) => Object.entries(t).flatMap(([n, i]) => [
|
|
4521
4537
|
`--${n}`,
|
|
4522
|
-
|
|
4538
|
+
_e(String(i), e)
|
|
4523
4539
|
])
|
|
4524
4540
|
);
|
|
4525
4541
|
}
|
|
4526
|
-
function
|
|
4527
|
-
return s["."] ||=
|
|
4542
|
+
function xn(s, e) {
|
|
4543
|
+
return s["."] ||= Wn, Object.entries(s).flatMap(([t, n]) => [
|
|
4528
4544
|
"-v",
|
|
4529
4545
|
`${t === "." ? e.workingDir : t}:${n}`
|
|
4530
4546
|
]);
|
|
4531
4547
|
}
|
|
4532
|
-
function
|
|
4548
|
+
function zn(s) {
|
|
4533
4549
|
const { workflow: e, secrets: t } = s, n = {
|
|
4534
4550
|
...process.env,
|
|
4535
4551
|
...Object.fromEntries(
|
|
@@ -4541,13 +4557,29 @@ function Gn(s) {
|
|
|
4541
4557
|
if (typeof e.env != "object")
|
|
4542
4558
|
throw new Error("Workflow env field must be an object.");
|
|
4543
4559
|
for (const [i, r] of Object.entries(e.env))
|
|
4544
|
-
n[i] =
|
|
4560
|
+
n[i] = _e(r, s);
|
|
4545
4561
|
}
|
|
4546
|
-
s.env
|
|
4562
|
+
Object.assign(s.env, n);
|
|
4547
4563
|
}
|
|
4548
|
-
|
|
4564
|
+
function Zn(s, e) {
|
|
4565
|
+
const t = Object.keys(s), n = Object.keys(e.on), i = n.find((a) => s[a]), r = i ? e.on[i] : null;
|
|
4566
|
+
if (!r)
|
|
4567
|
+
return console.log(
|
|
4568
|
+
`No workflow defined for event keys: ${t.join(", ")}, only accepting ${n.join(", ")}.`
|
|
4569
|
+
), null;
|
|
4570
|
+
if (!r.steps || r.steps.length === 0)
|
|
4571
|
+
return console.warn(
|
|
4572
|
+
`Workflow for event ${s.source}:${s.event} has no steps defined, skipping.`
|
|
4573
|
+
), null;
|
|
4574
|
+
const o = s[i];
|
|
4575
|
+
return {
|
|
4576
|
+
workflow: r,
|
|
4577
|
+
event: o
|
|
4578
|
+
};
|
|
4579
|
+
}
|
|
4580
|
+
async function ei(s, e) {
|
|
4549
4581
|
typeof s == "string" && (s = { run: s });
|
|
4550
|
-
const t =
|
|
4582
|
+
const t = Qn(s, e), { args: n, image: i, volumes: r } = t, o = xn(r, e), a = Xn(n, e), l = r["."], c = [
|
|
4551
4583
|
"run",
|
|
4552
4584
|
"-i",
|
|
4553
4585
|
"--rm",
|
|
@@ -4559,133 +4591,173 @@ async function Hn(s, e) {
|
|
|
4559
4591
|
"sh",
|
|
4560
4592
|
i
|
|
4561
4593
|
];
|
|
4562
|
-
|
|
4563
|
-
const f =
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4594
|
+
return new Promise((d, u) => {
|
|
4595
|
+
const f = jt("docker", c, {
|
|
4596
|
+
env: e.env
|
|
4597
|
+
}), p = [], g = [];
|
|
4598
|
+
f.stdout?.on("data", (h) => {
|
|
4599
|
+
p.push(h);
|
|
4600
|
+
}), f.stderr?.on("data", (h) => {
|
|
4601
|
+
g.push(h);
|
|
4602
|
+
}), f.once("error", u), f.once("exit", (h) => {
|
|
4603
|
+
const m = {
|
|
4604
|
+
code: h ?? 0,
|
|
4605
|
+
cmd: t.run,
|
|
4606
|
+
stdout: Buffer.concat(p).toString("utf-8"),
|
|
4607
|
+
stderr: Buffer.concat(g).toString("utf-8")
|
|
4608
|
+
};
|
|
4609
|
+
d(m);
|
|
4570
4610
|
}), f.stdin?.write(t.run), f.stdin?.write(`
|
|
4571
4611
|
exit $?;
|
|
4572
4612
|
`), f.stdin?.end();
|
|
4573
4613
|
});
|
|
4574
4614
|
}
|
|
4575
|
-
function
|
|
4576
|
-
const
|
|
4577
|
-
if (!
|
|
4578
|
-
return
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
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 {
|
|
4615
|
+
async function ks(s, e, t) {
|
|
4616
|
+
const n = Is(), i = Zn(s, e);
|
|
4617
|
+
if (!i)
|
|
4618
|
+
return { id: n, parentId: t, outputs: [] };
|
|
4619
|
+
const { workflow: r, event: o } = i, a = Ls(o, r.mappings), l = await Jn(r.secrets), c = await _t(Ts(Bt(), "workflow")), d = Mt({
|
|
4620
|
+
inputs: a,
|
|
4621
|
+
secrets: l,
|
|
4587
4622
|
workflow: r,
|
|
4588
|
-
event: o
|
|
4589
|
-
};
|
|
4590
|
-
}
|
|
4591
|
-
async function ps(s, e) {
|
|
4592
|
-
const t = Wn(s, e);
|
|
4593
|
-
if (!t)
|
|
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
4623
|
env: {},
|
|
4600
|
-
outputs:
|
|
4601
|
-
workingDir:
|
|
4602
|
-
};
|
|
4603
|
-
|
|
4624
|
+
outputs: [],
|
|
4625
|
+
workingDir: c
|
|
4626
|
+
});
|
|
4627
|
+
zn(d);
|
|
4628
|
+
const u = [];
|
|
4604
4629
|
try {
|
|
4605
|
-
for (const
|
|
4606
|
-
await
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4630
|
+
for (const f of r.steps ?? []) {
|
|
4631
|
+
const p = await ei(f, d);
|
|
4632
|
+
if (p.code !== 0)
|
|
4633
|
+
throw new Error(
|
|
4634
|
+
`Step failed with code ${p.code}.
|
|
4635
|
+
stdout: ${p.stdout}
|
|
4636
|
+
stderr: ${p.stderr}`
|
|
4637
|
+
);
|
|
4638
|
+
d.outputs.push(p);
|
|
4639
|
+
}
|
|
4640
|
+
for (const f of r.triggers ?? []) {
|
|
4641
|
+
const p = await ti(f, e, t);
|
|
4642
|
+
p && u.push(p.id);
|
|
4643
|
+
}
|
|
4644
|
+
} catch (f) {
|
|
4645
|
+
const p = f instanceof Error ? f.message : String(f);
|
|
4646
|
+
console.error(`Error processing event: ${p}`), console.debug(JSON.stringify(o));
|
|
4612
4647
|
} finally {
|
|
4613
|
-
await
|
|
4648
|
+
await As(d.workingDir, { recursive: !0, force: !0 });
|
|
4614
4649
|
}
|
|
4615
|
-
return
|
|
4650
|
+
return await Yn({ id: n, parentId: t, children: u }, d.outputs), { id: n, parentId: t, children: u, outputs: d.outputs };
|
|
4616
4651
|
}
|
|
4617
|
-
async function
|
|
4618
|
-
if (!
|
|
4652
|
+
async function ti(s, e, t) {
|
|
4653
|
+
if (!Es(s)) {
|
|
4619
4654
|
console.warn(`Trigger file does not exist: ${s}`);
|
|
4620
4655
|
return;
|
|
4621
4656
|
}
|
|
4622
|
-
const
|
|
4623
|
-
await
|
|
4657
|
+
const n = await tt(s, "utf8"), i = nt(JSON.parse(n));
|
|
4658
|
+
return await ks(i, e, t);
|
|
4624
4659
|
}
|
|
4625
|
-
function
|
|
4626
|
-
|
|
4660
|
+
async function si(s) {
|
|
4661
|
+
if (s.daemon) {
|
|
4662
|
+
const i = process.argv.slice(1).filter((a) => a !== "--daemon" && a !== "-d"), r = process.execArgv.concat(i), o = jt(process.execPath, r, {
|
|
4663
|
+
detached: !0,
|
|
4664
|
+
stdio: "ignore"
|
|
4665
|
+
});
|
|
4666
|
+
return console.log(o.pid), o.unref(), null;
|
|
4667
|
+
}
|
|
4668
|
+
const e = await qn(s.configPath), t = Ns(async (i, r) => {
|
|
4669
|
+
if (i.method === "GET" && i.url === "/health") {
|
|
4670
|
+
x(r, 200, { status: "OK" });
|
|
4671
|
+
return;
|
|
4672
|
+
}
|
|
4673
|
+
if (i.method === "GET" && i.url?.startsWith("/logs/")) {
|
|
4674
|
+
const o = i.url.split("/logs/")[1], a = await Gn(o);
|
|
4675
|
+
a ? x(r, 200, {
|
|
4676
|
+
exitCode: a.outputs.slice(-1)[0]?.code ?? null,
|
|
4677
|
+
stdout: a.outputs.map((l) => l.stdout),
|
|
4678
|
+
stderr: a.outputs.map((l) => l.stderr)
|
|
4679
|
+
}) : x(r, 404, { error: "Report not found." });
|
|
4680
|
+
return;
|
|
4681
|
+
}
|
|
4682
|
+
if (i.method !== "POST") {
|
|
4683
|
+
x(r, 405, { error: "Only POST webhooks are supported." });
|
|
4684
|
+
return;
|
|
4685
|
+
}
|
|
4686
|
+
try {
|
|
4687
|
+
const o = Buffer.concat(await i.toArray()).toString(), a = nt(JSON.parse(o || "{}")), l = await ks(a, e), c = (d) => new URL("/logs/" + d, `http://${i.headers.host}`);
|
|
4688
|
+
x(r, 202, {
|
|
4689
|
+
id: l.id,
|
|
4690
|
+
logUrl: c(l.id).href,
|
|
4691
|
+
parent: l.parentId ? {
|
|
4692
|
+
id: l.parentId,
|
|
4693
|
+
logUrl: l.parentId ? c(l.parentId).href : void 0
|
|
4694
|
+
} : null,
|
|
4695
|
+
children: l.children?.map((d) => ({
|
|
4696
|
+
id: d,
|
|
4697
|
+
logUrl: c(d).href
|
|
4698
|
+
})) || []
|
|
4699
|
+
});
|
|
4700
|
+
} catch (o) {
|
|
4701
|
+
const a = o instanceof Error ? o.message : "Unknown error";
|
|
4702
|
+
console.error("Error processing webhook:", o), x(r, 400, { error: a });
|
|
4703
|
+
}
|
|
4704
|
+
});
|
|
4705
|
+
await new Promise((i, r) => {
|
|
4706
|
+
t.once("error", r), t.listen(s.port, s.host, () => i());
|
|
4707
|
+
});
|
|
4708
|
+
const n = t.address();
|
|
4709
|
+
return n && typeof n == "object" && console.log(`Started on http://${n.address}:${n.port}`), t;
|
|
4710
|
+
}
|
|
4711
|
+
const ni = `on - daemonized webhook runner
|
|
4712
|
+
|
|
4713
|
+
Usage:
|
|
4714
|
+
on --port <port> [--host <host>] [--config <path>]
|
|
4715
|
+
|
|
4716
|
+
Options:
|
|
4717
|
+
--daemon Run as a background service
|
|
4718
|
+
--port, -p HTTP port for incoming webhooks (required)
|
|
4719
|
+
--host, -H Host binding for the HTTP server (default: 127.0.0.1)
|
|
4720
|
+
--config, -c Path to a YAML/JSON config file
|
|
4721
|
+
--help, -h Show this help message
|
|
4722
|
+
`;
|
|
4723
|
+
function ii(s) {
|
|
4724
|
+
const { values: e } = Ss({
|
|
4627
4725
|
args: s,
|
|
4628
4726
|
options: {
|
|
4629
4727
|
port: { type: "string", short: "p" },
|
|
4630
4728
|
host: { type: "string", short: "H", default: "127.0.0.1" },
|
|
4631
4729
|
config: { type: "string", short: "c" },
|
|
4632
|
-
help: { type: "boolean", short: "h", default: !1 }
|
|
4730
|
+
help: { type: "boolean", short: "h", default: !1 },
|
|
4731
|
+
daemon: { type: "boolean", short: "d", default: !1 }
|
|
4633
4732
|
},
|
|
4634
4733
|
allowPositionals: !1
|
|
4635
4734
|
});
|
|
4636
4735
|
if (e.help)
|
|
4637
|
-
return console.log(
|
|
4736
|
+
return console.log(ni), null;
|
|
4638
4737
|
if (!e.port)
|
|
4639
4738
|
throw new Error("Missing required option --port.");
|
|
4640
4739
|
return {
|
|
4641
|
-
port:
|
|
4740
|
+
port: $s(e.port),
|
|
4642
4741
|
host: e.host,
|
|
4643
|
-
configPath: e.config
|
|
4742
|
+
configPath: e.config,
|
|
4743
|
+
daemon: e.daemon
|
|
4644
4744
|
};
|
|
4645
4745
|
}
|
|
4646
|
-
async function
|
|
4647
|
-
const e = await Dn(s.configPath), t = ms(async (i, r) => {
|
|
4648
|
-
if (i.method !== "POST") {
|
|
4649
|
-
Re(r, 405, { error: "Only POST webhooks are supported." });
|
|
4650
|
-
return;
|
|
4651
|
-
}
|
|
4652
|
-
try {
|
|
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, {
|
|
4657
|
-
status: "accepted",
|
|
4658
|
-
outputs: l
|
|
4659
|
-
});
|
|
4660
|
-
} catch (o) {
|
|
4661
|
-
const a = o instanceof Error ? o.message : "Unknown error";
|
|
4662
|
-
Re(r, 400, { error: a });
|
|
4663
|
-
}
|
|
4664
|
-
});
|
|
4665
|
-
await new Promise((i, r) => {
|
|
4666
|
-
t.once("error", r), t.listen(s.port, s.host, () => i());
|
|
4667
|
-
});
|
|
4668
|
-
const n = t.address();
|
|
4669
|
-
return n && typeof n == "object" && console.log(
|
|
4670
|
-
`on daemon listening on http://${n.address}:${n.port}`
|
|
4671
|
-
), t;
|
|
4672
|
-
}
|
|
4673
|
-
async function zn() {
|
|
4746
|
+
async function ri() {
|
|
4674
4747
|
try {
|
|
4675
|
-
const s =
|
|
4748
|
+
const s = ii(process.argv.slice(2));
|
|
4676
4749
|
if (!s) {
|
|
4677
4750
|
process.exitCode = 0;
|
|
4678
4751
|
return;
|
|
4679
4752
|
}
|
|
4680
|
-
await
|
|
4753
|
+
await si(s);
|
|
4681
4754
|
} catch (s) {
|
|
4682
4755
|
const e = s instanceof Error ? s.message : String(s);
|
|
4683
4756
|
console.error(`on: ${e}`), process.exitCode = 1;
|
|
4684
4757
|
}
|
|
4685
4758
|
}
|
|
4686
|
-
|
|
4759
|
+
ri();
|
|
4687
4760
|
export {
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
xn as startDaemon
|
|
4761
|
+
ri as main,
|
|
4762
|
+
ii as parseCliOptions
|
|
4691
4763
|
};
|