@quilted/create 0.1.18 → 0.1.21
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/CHANGELOG.md +18 -0
- package/build/cjs/app.cjs +525 -236
- package/build/cjs/index.cjs +1020 -233
- package/build/cjs/index3.cjs +577 -1205
- package/build/cjs/package-manager.cjs +801 -199
- package/build/cjs/package.cjs +702 -320
- package/build/esm/app.mjs +530 -241
- package/build/esm/index.mjs +1002 -219
- package/build/esm/index3.mjs +548 -1205
- package/build/esm/package-manager.mjs +801 -200
- package/build/esm/package.mjs +702 -320
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/package.d.ts +1 -1
- package/package.json +5 -3
- package/quilt.project.ts +19 -5
- package/source/create.ts +2 -2
- package/source/package.ts +1 -1
- package/templates/app-basic/quilt.project.ts +5 -5
- package/templates/app-basic/tsconfig.json +1 -1
- package/templates/app-single-file/quilt.project.ts +3 -4
- package/templates/app-single-file/tsconfig.json +1 -1
- package/templates/package/package.json +3 -2
- package/templates/package/quilt.project.ts +3 -4
- package/templates/package/tsconfig.json +1 -1
- package/templates/workspace/package.json +1 -1
- package/tsconfig.json +1 -1
package/build/esm/index3.mjs
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
function _mergeNamespaces(n, m) {
|
|
2
|
-
m.forEach(function (e) {
|
|
3
|
-
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
4
|
-
if (k !== 'default' && !(k in n)) {
|
|
5
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
6
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () { return e[k]; }
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
return Object.freeze(n);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
var dist = {};
|
|
17
|
-
|
|
18
|
-
var composer$2 = {};
|
|
19
|
-
|
|
20
|
-
var directives$2 = {};
|
|
21
|
-
|
|
22
|
-
var Node$t = {};
|
|
23
|
-
|
|
24
1
|
const ALIAS = Symbol.for('yaml.alias');
|
|
25
2
|
const DOC = Symbol.for('yaml.document');
|
|
26
3
|
const MAP = Symbol.for('yaml.map');
|
|
@@ -28,13 +5,13 @@ const PAIR = Symbol.for('yaml.pair');
|
|
|
28
5
|
const SCALAR$1 = Symbol.for('yaml.scalar');
|
|
29
6
|
const SEQ = Symbol.for('yaml.seq');
|
|
30
7
|
const NODE_TYPE = Symbol.for('yaml.node.type');
|
|
31
|
-
const isAlias
|
|
32
|
-
const isDocument
|
|
33
|
-
const isMap
|
|
34
|
-
const isPair
|
|
35
|
-
const isScalar$
|
|
36
|
-
const isSeq
|
|
37
|
-
function isCollection$
|
|
8
|
+
const isAlias = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === ALIAS;
|
|
9
|
+
const isDocument = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === DOC;
|
|
10
|
+
const isMap = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === MAP;
|
|
11
|
+
const isPair = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === PAIR;
|
|
12
|
+
const isScalar$1 = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === SCALAR$1;
|
|
13
|
+
const isSeq = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === SEQ;
|
|
14
|
+
function isCollection$1(node) {
|
|
38
15
|
if (node && typeof node === 'object')
|
|
39
16
|
switch (node[NODE_TYPE]) {
|
|
40
17
|
case MAP:
|
|
@@ -43,7 +20,7 @@ function isCollection$2(node) {
|
|
|
43
20
|
}
|
|
44
21
|
return false;
|
|
45
22
|
}
|
|
46
|
-
function isNode
|
|
23
|
+
function isNode(node) {
|
|
47
24
|
if (node && typeof node === 'object')
|
|
48
25
|
switch (node[NODE_TYPE]) {
|
|
49
26
|
case ALIAS:
|
|
@@ -54,7 +31,7 @@ function isNode$1(node) {
|
|
|
54
31
|
}
|
|
55
32
|
return false;
|
|
56
33
|
}
|
|
57
|
-
const hasAnchor = (node) => (isScalar$
|
|
34
|
+
const hasAnchor = (node) => (isScalar$1(node) || isCollection$1(node)) && !!node.anchor;
|
|
58
35
|
class NodeBase {
|
|
59
36
|
constructor(type) {
|
|
60
37
|
Object.defineProperty(this, NODE_TYPE, { value: type });
|
|
@@ -68,28 +45,6 @@ class NodeBase {
|
|
|
68
45
|
}
|
|
69
46
|
}
|
|
70
47
|
|
|
71
|
-
Node$t.ALIAS = ALIAS;
|
|
72
|
-
Node$t.DOC = DOC;
|
|
73
|
-
Node$t.MAP = MAP;
|
|
74
|
-
Node$t.NODE_TYPE = NODE_TYPE;
|
|
75
|
-
Node$t.NodeBase = NodeBase;
|
|
76
|
-
Node$t.PAIR = PAIR;
|
|
77
|
-
Node$t.SCALAR = SCALAR$1;
|
|
78
|
-
Node$t.SEQ = SEQ;
|
|
79
|
-
Node$t.hasAnchor = hasAnchor;
|
|
80
|
-
Node$t.isAlias = isAlias$1;
|
|
81
|
-
Node$t.isCollection = isCollection$2;
|
|
82
|
-
Node$t.isDocument = isDocument$1;
|
|
83
|
-
Node$t.isMap = isMap$1;
|
|
84
|
-
Node$t.isNode = isNode$1;
|
|
85
|
-
Node$t.isPair = isPair$1;
|
|
86
|
-
Node$t.isScalar = isScalar$2;
|
|
87
|
-
Node$t.isSeq = isSeq$1;
|
|
88
|
-
|
|
89
|
-
var visit$6 = {};
|
|
90
|
-
|
|
91
|
-
var Node$s = Node$t;
|
|
92
|
-
|
|
93
48
|
const BREAK$1 = Symbol('break visit');
|
|
94
49
|
const SKIP$1 = Symbol('skip children');
|
|
95
50
|
const REMOVE$1 = Symbol('remove node');
|
|
@@ -123,9 +78,9 @@ const REMOVE$1 = Symbol('remove node');
|
|
|
123
78
|
* and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
|
|
124
79
|
* specific defined one will be used for each node.
|
|
125
80
|
*/
|
|
126
|
-
function visit$
|
|
81
|
+
function visit$1(node, visitor) {
|
|
127
82
|
const visitor_ = initVisitor(visitor);
|
|
128
|
-
if (
|
|
83
|
+
if (isDocument(node)) {
|
|
129
84
|
const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
|
|
130
85
|
if (cd === REMOVE$1)
|
|
131
86
|
node.contents = null;
|
|
@@ -137,19 +92,19 @@ function visit$5(node, visitor) {
|
|
|
137
92
|
// namespace using `var`, but then complains about that because
|
|
138
93
|
// `unique symbol` must be `const`.
|
|
139
94
|
/** Terminate visit traversal completely */
|
|
140
|
-
visit$
|
|
95
|
+
visit$1.BREAK = BREAK$1;
|
|
141
96
|
/** Do not visit the children of the current node */
|
|
142
|
-
visit$
|
|
97
|
+
visit$1.SKIP = SKIP$1;
|
|
143
98
|
/** Remove the current node */
|
|
144
|
-
visit$
|
|
99
|
+
visit$1.REMOVE = REMOVE$1;
|
|
145
100
|
function visit_(key, node, visitor, path) {
|
|
146
101
|
const ctrl = callVisitor(key, node, visitor, path);
|
|
147
|
-
if (
|
|
102
|
+
if (isNode(ctrl) || isPair(ctrl)) {
|
|
148
103
|
replaceNode(key, path, ctrl);
|
|
149
104
|
return visit_(key, ctrl, visitor, path);
|
|
150
105
|
}
|
|
151
106
|
if (typeof ctrl !== 'symbol') {
|
|
152
|
-
if (
|
|
107
|
+
if (isCollection$1(node)) {
|
|
153
108
|
path = Object.freeze(path.concat(node));
|
|
154
109
|
for (let i = 0; i < node.items.length; ++i) {
|
|
155
110
|
const ci = visit_(i, node.items[i], visitor, path);
|
|
@@ -163,7 +118,7 @@ function visit_(key, node, visitor, path) {
|
|
|
163
118
|
}
|
|
164
119
|
}
|
|
165
120
|
}
|
|
166
|
-
else if (
|
|
121
|
+
else if (isPair(node)) {
|
|
167
122
|
path = Object.freeze(path.concat(node));
|
|
168
123
|
const ck = visit_('key', node.key, visitor, path);
|
|
169
124
|
if (ck === BREAK$1)
|
|
@@ -210,9 +165,9 @@ function visit_(key, node, visitor, path) {
|
|
|
210
165
|
* and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
|
|
211
166
|
* specific defined one will be used for each node.
|
|
212
167
|
*/
|
|
213
|
-
async function visitAsync
|
|
168
|
+
async function visitAsync(node, visitor) {
|
|
214
169
|
const visitor_ = initVisitor(visitor);
|
|
215
|
-
if (
|
|
170
|
+
if (isDocument(node)) {
|
|
216
171
|
const cd = await visitAsync_(null, node.contents, visitor_, Object.freeze([node]));
|
|
217
172
|
if (cd === REMOVE$1)
|
|
218
173
|
node.contents = null;
|
|
@@ -224,19 +179,19 @@ async function visitAsync$1(node, visitor) {
|
|
|
224
179
|
// namespace using `var`, but then complains about that because
|
|
225
180
|
// `unique symbol` must be `const`.
|
|
226
181
|
/** Terminate visit traversal completely */
|
|
227
|
-
visitAsync
|
|
182
|
+
visitAsync.BREAK = BREAK$1;
|
|
228
183
|
/** Do not visit the children of the current node */
|
|
229
|
-
visitAsync
|
|
184
|
+
visitAsync.SKIP = SKIP$1;
|
|
230
185
|
/** Remove the current node */
|
|
231
|
-
visitAsync
|
|
186
|
+
visitAsync.REMOVE = REMOVE$1;
|
|
232
187
|
async function visitAsync_(key, node, visitor, path) {
|
|
233
188
|
const ctrl = await callVisitor(key, node, visitor, path);
|
|
234
|
-
if (
|
|
189
|
+
if (isNode(ctrl) || isPair(ctrl)) {
|
|
235
190
|
replaceNode(key, path, ctrl);
|
|
236
191
|
return visitAsync_(key, ctrl, visitor, path);
|
|
237
192
|
}
|
|
238
193
|
if (typeof ctrl !== 'symbol') {
|
|
239
|
-
if (
|
|
194
|
+
if (isCollection$1(node)) {
|
|
240
195
|
path = Object.freeze(path.concat(node));
|
|
241
196
|
for (let i = 0; i < node.items.length; ++i) {
|
|
242
197
|
const ci = await visitAsync_(i, node.items[i], visitor, path);
|
|
@@ -250,7 +205,7 @@ async function visitAsync_(key, node, visitor, path) {
|
|
|
250
205
|
}
|
|
251
206
|
}
|
|
252
207
|
}
|
|
253
|
-
else if (
|
|
208
|
+
else if (isPair(node)) {
|
|
254
209
|
path = Object.freeze(path.concat(node));
|
|
255
210
|
const ck = await visitAsync_('key', node.key, visitor, path);
|
|
256
211
|
if (ck === BREAK$1)
|
|
@@ -288,44 +243,38 @@ function initVisitor(visitor) {
|
|
|
288
243
|
function callVisitor(key, node, visitor, path) {
|
|
289
244
|
if (typeof visitor === 'function')
|
|
290
245
|
return visitor(key, node, path);
|
|
291
|
-
if (
|
|
246
|
+
if (isMap(node))
|
|
292
247
|
return visitor.Map?.(key, node, path);
|
|
293
|
-
if (
|
|
248
|
+
if (isSeq(node))
|
|
294
249
|
return visitor.Seq?.(key, node, path);
|
|
295
|
-
if (
|
|
250
|
+
if (isPair(node))
|
|
296
251
|
return visitor.Pair?.(key, node, path);
|
|
297
|
-
if (
|
|
252
|
+
if (isScalar$1(node))
|
|
298
253
|
return visitor.Scalar?.(key, node, path);
|
|
299
|
-
if (
|
|
254
|
+
if (isAlias(node))
|
|
300
255
|
return visitor.Alias?.(key, node, path);
|
|
301
256
|
return undefined;
|
|
302
257
|
}
|
|
303
258
|
function replaceNode(key, path, node) {
|
|
304
259
|
const parent = path[path.length - 1];
|
|
305
|
-
if (
|
|
260
|
+
if (isCollection$1(parent)) {
|
|
306
261
|
parent.items[key] = node;
|
|
307
262
|
}
|
|
308
|
-
else if (
|
|
263
|
+
else if (isPair(parent)) {
|
|
309
264
|
if (key === 'key')
|
|
310
265
|
parent.key = node;
|
|
311
266
|
else
|
|
312
267
|
parent.value = node;
|
|
313
268
|
}
|
|
314
|
-
else if (
|
|
269
|
+
else if (isDocument(parent)) {
|
|
315
270
|
parent.contents = node;
|
|
316
271
|
}
|
|
317
272
|
else {
|
|
318
|
-
const pt =
|
|
273
|
+
const pt = isAlias(parent) ? 'alias' : 'scalar';
|
|
319
274
|
throw new Error(`Cannot replace node with ${pt} parent`);
|
|
320
275
|
}
|
|
321
276
|
}
|
|
322
277
|
|
|
323
|
-
visit$6.visit = visit$5;
|
|
324
|
-
visit$6.visitAsync = visitAsync$1;
|
|
325
|
-
|
|
326
|
-
var Node$r = Node$t;
|
|
327
|
-
var visit$4 = visit$6;
|
|
328
|
-
|
|
329
278
|
const escapeChars = {
|
|
330
279
|
'!': '%21',
|
|
331
280
|
',': '%2C',
|
|
@@ -469,10 +418,10 @@ class Directives {
|
|
|
469
418
|
: [];
|
|
470
419
|
const tagEntries = Object.entries(this.tags);
|
|
471
420
|
let tagNames;
|
|
472
|
-
if (doc && tagEntries.length > 0 &&
|
|
421
|
+
if (doc && tagEntries.length > 0 && isNode(doc.contents)) {
|
|
473
422
|
const tags = {};
|
|
474
|
-
visit$
|
|
475
|
-
if (
|
|
423
|
+
visit$1(doc.contents, (_key, node) => {
|
|
424
|
+
if (isNode(node) && node.tag)
|
|
476
425
|
tags[node.tag] = true;
|
|
477
426
|
});
|
|
478
427
|
tagNames = Object.keys(tags);
|
|
@@ -491,17 +440,6 @@ class Directives {
|
|
|
491
440
|
Directives.defaultYaml = { explicit: false, version: '1.2' };
|
|
492
441
|
Directives.defaultTags = { '!!': 'tag:yaml.org,2002:' };
|
|
493
442
|
|
|
494
|
-
directives$2.Directives = Directives;
|
|
495
|
-
|
|
496
|
-
var Document$5 = {};
|
|
497
|
-
|
|
498
|
-
var Alias$5 = {};
|
|
499
|
-
|
|
500
|
-
var anchors$3 = {};
|
|
501
|
-
|
|
502
|
-
var Node$q = Node$t;
|
|
503
|
-
var visit$3 = visit$6;
|
|
504
|
-
|
|
505
443
|
/**
|
|
506
444
|
* Verify that the input string is a valid anchor.
|
|
507
445
|
*
|
|
@@ -517,7 +455,7 @@ function anchorIsValid(anchor) {
|
|
|
517
455
|
}
|
|
518
456
|
function anchorNames(root) {
|
|
519
457
|
const anchors = new Set();
|
|
520
|
-
visit$
|
|
458
|
+
visit$1(root, {
|
|
521
459
|
Value(_key, node) {
|
|
522
460
|
if (node.anchor)
|
|
523
461
|
anchors.add(node.anchor);
|
|
@@ -556,7 +494,7 @@ function createNodeAnchors(doc, prefix) {
|
|
|
556
494
|
const ref = sourceObjects.get(source);
|
|
557
495
|
if (typeof ref === 'object' &&
|
|
558
496
|
ref.anchor &&
|
|
559
|
-
(
|
|
497
|
+
(isScalar$1(ref.node) || isCollection$1(ref.node))) {
|
|
560
498
|
ref.node.anchor = ref.anchor;
|
|
561
499
|
}
|
|
562
500
|
else {
|
|
@@ -570,18 +508,9 @@ function createNodeAnchors(doc, prefix) {
|
|
|
570
508
|
};
|
|
571
509
|
}
|
|
572
510
|
|
|
573
|
-
|
|
574
|
-
anchors$3.anchorNames = anchorNames;
|
|
575
|
-
anchors$3.createNodeAnchors = createNodeAnchors;
|
|
576
|
-
anchors$3.findNewAnchor = findNewAnchor;
|
|
577
|
-
|
|
578
|
-
var anchors$2 = anchors$3;
|
|
579
|
-
var visit$2 = visit$6;
|
|
580
|
-
var Node$p = Node$t;
|
|
581
|
-
|
|
582
|
-
class Alias$4 extends Node$p.NodeBase {
|
|
511
|
+
class Alias extends NodeBase {
|
|
583
512
|
constructor(source) {
|
|
584
|
-
super(
|
|
513
|
+
super(ALIAS);
|
|
585
514
|
this.source = source;
|
|
586
515
|
Object.defineProperty(this, 'tag', {
|
|
587
516
|
set() {
|
|
@@ -595,10 +524,10 @@ class Alias$4 extends Node$p.NodeBase {
|
|
|
595
524
|
*/
|
|
596
525
|
resolve(doc) {
|
|
597
526
|
let found = undefined;
|
|
598
|
-
visit$
|
|
527
|
+
visit$1(doc, {
|
|
599
528
|
Node: (_key, node) => {
|
|
600
529
|
if (node === this)
|
|
601
|
-
return visit$
|
|
530
|
+
return visit$1.BREAK;
|
|
602
531
|
if (node.anchor === this.source)
|
|
603
532
|
found = node;
|
|
604
533
|
}
|
|
@@ -634,7 +563,7 @@ class Alias$4 extends Node$p.NodeBase {
|
|
|
634
563
|
toString(ctx, _onComment, _onChompKeep) {
|
|
635
564
|
const src = `*${this.source}`;
|
|
636
565
|
if (ctx) {
|
|
637
|
-
|
|
566
|
+
anchorIsValid(this.source);
|
|
638
567
|
if (ctx.options.verifyAliasOrder && !ctx.anchors.has(this.source)) {
|
|
639
568
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
640
569
|
throw new Error(msg);
|
|
@@ -646,12 +575,12 @@ class Alias$4 extends Node$p.NodeBase {
|
|
|
646
575
|
}
|
|
647
576
|
}
|
|
648
577
|
function getAliasCount(doc, node, anchors) {
|
|
649
|
-
if (
|
|
578
|
+
if (isAlias(node)) {
|
|
650
579
|
const source = node.resolve(doc);
|
|
651
580
|
const anchor = anchors && source && anchors.get(source);
|
|
652
581
|
return anchor ? anchor.count * anchor.aliasCount : 0;
|
|
653
582
|
}
|
|
654
|
-
else if (
|
|
583
|
+
else if (isCollection$1(node)) {
|
|
655
584
|
let count = 0;
|
|
656
585
|
for (const item of node.items) {
|
|
657
586
|
const c = getAliasCount(doc, item, anchors);
|
|
@@ -660,7 +589,7 @@ function getAliasCount(doc, node, anchors) {
|
|
|
660
589
|
}
|
|
661
590
|
return count;
|
|
662
591
|
}
|
|
663
|
-
else if (
|
|
592
|
+
else if (isPair(node)) {
|
|
664
593
|
const kc = getAliasCount(doc, node.key, anchors);
|
|
665
594
|
const vc = getAliasCount(doc, node.value, anchors);
|
|
666
595
|
return Math.max(kc, vc);
|
|
@@ -668,18 +597,6 @@ function getAliasCount(doc, node, anchors) {
|
|
|
668
597
|
return 1;
|
|
669
598
|
}
|
|
670
599
|
|
|
671
|
-
Alias$5.Alias = Alias$4;
|
|
672
|
-
|
|
673
|
-
var Collection$5 = {};
|
|
674
|
-
|
|
675
|
-
var createNode$5 = {};
|
|
676
|
-
|
|
677
|
-
var Scalar$k = {};
|
|
678
|
-
|
|
679
|
-
var toJS$6 = {};
|
|
680
|
-
|
|
681
|
-
var Node$o = Node$t;
|
|
682
|
-
|
|
683
600
|
/**
|
|
684
601
|
* Recursively convert any node or its contents to native JavaScript
|
|
685
602
|
*
|
|
@@ -690,13 +607,13 @@ var Node$o = Node$t;
|
|
|
690
607
|
* `{ keep: true }` is not set, output should be suitable for JSON
|
|
691
608
|
* stringification.
|
|
692
609
|
*/
|
|
693
|
-
function toJS
|
|
610
|
+
function toJS(value, arg, ctx) {
|
|
694
611
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
695
612
|
if (Array.isArray(value))
|
|
696
|
-
return value.map((v, i) => toJS
|
|
613
|
+
return value.map((v, i) => toJS(v, String(i), ctx));
|
|
697
614
|
if (value && typeof value.toJSON === 'function') {
|
|
698
615
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
699
|
-
if (!ctx || !
|
|
616
|
+
if (!ctx || !hasAnchor(value))
|
|
700
617
|
return value.toJSON(arg, ctx);
|
|
701
618
|
const data = { aliasCount: 0, count: 1, res: undefined };
|
|
702
619
|
ctx.anchors.set(value, data);
|
|
@@ -714,36 +631,24 @@ function toJS$5(value, arg, ctx) {
|
|
|
714
631
|
return value;
|
|
715
632
|
}
|
|
716
633
|
|
|
717
|
-
toJS$6.toJS = toJS$5;
|
|
718
|
-
|
|
719
|
-
var Node$n = Node$t;
|
|
720
|
-
var toJS$4 = toJS$6;
|
|
721
|
-
|
|
722
634
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
|
723
|
-
class Scalar
|
|
635
|
+
class Scalar extends NodeBase {
|
|
724
636
|
constructor(value) {
|
|
725
|
-
super(
|
|
637
|
+
super(SCALAR$1);
|
|
726
638
|
this.value = value;
|
|
727
639
|
}
|
|
728
640
|
toJSON(arg, ctx) {
|
|
729
|
-
return ctx?.keep ? this.value : toJS
|
|
641
|
+
return ctx?.keep ? this.value : toJS(this.value, arg, ctx);
|
|
730
642
|
}
|
|
731
643
|
toString() {
|
|
732
644
|
return String(this.value);
|
|
733
645
|
}
|
|
734
646
|
}
|
|
735
|
-
Scalar
|
|
736
|
-
Scalar
|
|
737
|
-
Scalar
|
|
738
|
-
Scalar
|
|
739
|
-
Scalar
|
|
740
|
-
|
|
741
|
-
Scalar$k.Scalar = Scalar$j;
|
|
742
|
-
Scalar$k.isScalarValue = isScalarValue;
|
|
743
|
-
|
|
744
|
-
var Alias$3 = Alias$5;
|
|
745
|
-
var Node$m = Node$t;
|
|
746
|
-
var Scalar$i = Scalar$k;
|
|
647
|
+
Scalar.BLOCK_FOLDED = 'BLOCK_FOLDED';
|
|
648
|
+
Scalar.BLOCK_LITERAL = 'BLOCK_LITERAL';
|
|
649
|
+
Scalar.PLAIN = 'PLAIN';
|
|
650
|
+
Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
|
|
651
|
+
Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
|
|
747
652
|
|
|
748
653
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
749
654
|
function findTagObject(value, tagName, tags) {
|
|
@@ -756,13 +661,13 @@ function findTagObject(value, tagName, tags) {
|
|
|
756
661
|
}
|
|
757
662
|
return tags.find(t => t.identify?.(value) && !t.format);
|
|
758
663
|
}
|
|
759
|
-
function createNode
|
|
760
|
-
if (
|
|
664
|
+
function createNode(value, tagName, ctx) {
|
|
665
|
+
if (isDocument(value))
|
|
761
666
|
value = value.contents;
|
|
762
|
-
if (
|
|
667
|
+
if (isNode(value))
|
|
763
668
|
return value;
|
|
764
|
-
if (
|
|
765
|
-
const map = ctx.schema[
|
|
669
|
+
if (isPair(value)) {
|
|
670
|
+
const map = ctx.schema[MAP].createNode?.(ctx.schema, null, ctx);
|
|
766
671
|
map.items.push(value);
|
|
767
672
|
return map;
|
|
768
673
|
}
|
|
@@ -783,7 +688,7 @@ function createNode$4(value, tagName, ctx) {
|
|
|
783
688
|
if (ref) {
|
|
784
689
|
if (!ref.anchor)
|
|
785
690
|
ref.anchor = onAnchor(value);
|
|
786
|
-
return new Alias
|
|
691
|
+
return new Alias(ref.anchor);
|
|
787
692
|
}
|
|
788
693
|
else {
|
|
789
694
|
ref = { anchor: null, node: null };
|
|
@@ -799,17 +704,17 @@ function createNode$4(value, tagName, ctx) {
|
|
|
799
704
|
value = value.toJSON();
|
|
800
705
|
}
|
|
801
706
|
if (!value || typeof value !== 'object') {
|
|
802
|
-
const node = new Scalar
|
|
707
|
+
const node = new Scalar(value);
|
|
803
708
|
if (ref)
|
|
804
709
|
ref.node = node;
|
|
805
710
|
return node;
|
|
806
711
|
}
|
|
807
712
|
tagObj =
|
|
808
713
|
value instanceof Map
|
|
809
|
-
? schema[
|
|
714
|
+
? schema[MAP]
|
|
810
715
|
: Symbol.iterator in Object(value)
|
|
811
|
-
? schema[
|
|
812
|
-
: schema[
|
|
716
|
+
? schema[SEQ]
|
|
717
|
+
: schema[MAP];
|
|
813
718
|
}
|
|
814
719
|
if (onTagObj) {
|
|
815
720
|
onTagObj(tagObj);
|
|
@@ -817,7 +722,7 @@ function createNode$4(value, tagName, ctx) {
|
|
|
817
722
|
}
|
|
818
723
|
const node = tagObj?.createNode
|
|
819
724
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
820
|
-
: new Scalar
|
|
725
|
+
: new Scalar(value);
|
|
821
726
|
if (tagName)
|
|
822
727
|
node.tag = tagName;
|
|
823
728
|
if (ref)
|
|
@@ -825,11 +730,6 @@ function createNode$4(value, tagName, ctx) {
|
|
|
825
730
|
return node;
|
|
826
731
|
}
|
|
827
732
|
|
|
828
|
-
createNode$5.createNode = createNode$4;
|
|
829
|
-
|
|
830
|
-
var createNode$3 = createNode$5;
|
|
831
|
-
var Node$l = Node$t;
|
|
832
|
-
|
|
833
733
|
function collectionFromPath(schema, path, value) {
|
|
834
734
|
let v = value;
|
|
835
735
|
for (let i = path.length - 1; i >= 0; --i) {
|
|
@@ -843,7 +743,7 @@ function collectionFromPath(schema, path, value) {
|
|
|
843
743
|
v = new Map([[k, v]]);
|
|
844
744
|
}
|
|
845
745
|
}
|
|
846
|
-
return createNode
|
|
746
|
+
return createNode(v, undefined, {
|
|
847
747
|
aliasDuplicateObjects: false,
|
|
848
748
|
keepUndefined: false,
|
|
849
749
|
onAnchor: () => {
|
|
@@ -857,7 +757,7 @@ function collectionFromPath(schema, path, value) {
|
|
|
857
757
|
// as it does not cover untypable empty non-string iterables (e.g. []).
|
|
858
758
|
const isEmptyPath = (path) => path == null ||
|
|
859
759
|
(typeof path === 'object' && !!path[Symbol.iterator]().next().done);
|
|
860
|
-
class Collection
|
|
760
|
+
class Collection extends NodeBase {
|
|
861
761
|
constructor(type, schema) {
|
|
862
762
|
super(type);
|
|
863
763
|
Object.defineProperty(this, 'schema', {
|
|
@@ -876,7 +776,7 @@ class Collection$4 extends Node$l.NodeBase {
|
|
|
876
776
|
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
877
777
|
if (schema)
|
|
878
778
|
copy.schema = schema;
|
|
879
|
-
copy.items = copy.items.map(it =>
|
|
779
|
+
copy.items = copy.items.map(it => isNode(it) || isPair(it) ? it.clone(schema) : it);
|
|
880
780
|
if (this.range)
|
|
881
781
|
copy.range = this.range.slice();
|
|
882
782
|
return copy;
|
|
@@ -892,7 +792,7 @@ class Collection$4 extends Node$l.NodeBase {
|
|
|
892
792
|
else {
|
|
893
793
|
const [key, ...rest] = path;
|
|
894
794
|
const node = this.get(key, true);
|
|
895
|
-
if (
|
|
795
|
+
if (isCollection$1(node))
|
|
896
796
|
node.addIn(rest, value);
|
|
897
797
|
else if (node === undefined && this.schema)
|
|
898
798
|
this.set(key, collectionFromPath(this.schema, rest, value));
|
|
@@ -909,7 +809,7 @@ class Collection$4 extends Node$l.NodeBase {
|
|
|
909
809
|
if (rest.length === 0)
|
|
910
810
|
return this.delete(key);
|
|
911
811
|
const node = this.get(key, true);
|
|
912
|
-
if (
|
|
812
|
+
if (isCollection$1(node))
|
|
913
813
|
return node.deleteIn(rest);
|
|
914
814
|
else
|
|
915
815
|
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
|
@@ -923,18 +823,18 @@ class Collection$4 extends Node$l.NodeBase {
|
|
|
923
823
|
const [key, ...rest] = path;
|
|
924
824
|
const node = this.get(key, true);
|
|
925
825
|
if (rest.length === 0)
|
|
926
|
-
return !keepScalar &&
|
|
826
|
+
return !keepScalar && isScalar$1(node) ? node.value : node;
|
|
927
827
|
else
|
|
928
|
-
return
|
|
828
|
+
return isCollection$1(node) ? node.getIn(rest, keepScalar) : undefined;
|
|
929
829
|
}
|
|
930
830
|
hasAllNullValues(allowScalar) {
|
|
931
831
|
return this.items.every(node => {
|
|
932
|
-
if (!
|
|
832
|
+
if (!isPair(node))
|
|
933
833
|
return false;
|
|
934
834
|
const n = node.value;
|
|
935
835
|
return (n == null ||
|
|
936
836
|
(allowScalar &&
|
|
937
|
-
|
|
837
|
+
isScalar$1(n) &&
|
|
938
838
|
n.value == null &&
|
|
939
839
|
!n.commentBefore &&
|
|
940
840
|
!n.comment &&
|
|
@@ -949,7 +849,7 @@ class Collection$4 extends Node$l.NodeBase {
|
|
|
949
849
|
if (rest.length === 0)
|
|
950
850
|
return this.has(key);
|
|
951
851
|
const node = this.get(key, true);
|
|
952
|
-
return
|
|
852
|
+
return isCollection$1(node) ? node.hasIn(rest) : false;
|
|
953
853
|
}
|
|
954
854
|
/**
|
|
955
855
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
@@ -962,7 +862,7 @@ class Collection$4 extends Node$l.NodeBase {
|
|
|
962
862
|
}
|
|
963
863
|
else {
|
|
964
864
|
const node = this.get(key, true);
|
|
965
|
-
if (
|
|
865
|
+
if (isCollection$1(node))
|
|
966
866
|
node.setIn(rest, value);
|
|
967
867
|
else if (node === undefined && this.schema)
|
|
968
868
|
this.set(key, collectionFromPath(this.schema, rest, value));
|
|
@@ -971,19 +871,7 @@ class Collection$4 extends Node$l.NodeBase {
|
|
|
971
871
|
}
|
|
972
872
|
}
|
|
973
873
|
}
|
|
974
|
-
Collection
|
|
975
|
-
|
|
976
|
-
Collection$5.Collection = Collection$4;
|
|
977
|
-
Collection$5.collectionFromPath = collectionFromPath;
|
|
978
|
-
Collection$5.isEmptyPath = isEmptyPath;
|
|
979
|
-
|
|
980
|
-
var Pair$9 = {};
|
|
981
|
-
|
|
982
|
-
var stringifyPair$2 = {};
|
|
983
|
-
|
|
984
|
-
var stringify$9 = {};
|
|
985
|
-
|
|
986
|
-
var stringifyComment$5 = {};
|
|
874
|
+
Collection.maxFlowStringSingleLineLength = 60;
|
|
987
875
|
|
|
988
876
|
/**
|
|
989
877
|
* Stringifies a comment.
|
|
@@ -992,7 +880,7 @@ var stringifyComment$5 = {};
|
|
|
992
880
|
* lines consisting of a single space are replaced by `#`,
|
|
993
881
|
* and all other lines are prefixed with a `#`.
|
|
994
882
|
*/
|
|
995
|
-
const stringifyComment
|
|
883
|
+
const stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, '#');
|
|
996
884
|
function indentComment(comment, indent) {
|
|
997
885
|
if (/^\n+$/.test(comment))
|
|
998
886
|
return comment.substring(1);
|
|
@@ -1004,14 +892,6 @@ const lineComment = (str, indent, comment) => str.endsWith('\n')
|
|
|
1004
892
|
? '\n' + indentComment(comment, indent)
|
|
1005
893
|
: (str.endsWith(' ') ? '' : ' ') + comment;
|
|
1006
894
|
|
|
1007
|
-
stringifyComment$5.indentComment = indentComment;
|
|
1008
|
-
stringifyComment$5.lineComment = lineComment;
|
|
1009
|
-
stringifyComment$5.stringifyComment = stringifyComment$4;
|
|
1010
|
-
|
|
1011
|
-
var stringifyString$5 = {};
|
|
1012
|
-
|
|
1013
|
-
var foldFlowLines$2 = {};
|
|
1014
|
-
|
|
1015
895
|
const FOLD_FLOW = 'flow';
|
|
1016
896
|
const FOLD_BLOCK = 'block';
|
|
1017
897
|
const FOLD_QUOTED = 'quoted';
|
|
@@ -1020,7 +900,7 @@ const FOLD_QUOTED = 'quoted';
|
|
|
1020
900
|
* not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are
|
|
1021
901
|
* terminated with `\n` and started with `indent`.
|
|
1022
902
|
*/
|
|
1023
|
-
function foldFlowLines
|
|
903
|
+
function foldFlowLines(text, indent, mode, { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow }) {
|
|
1024
904
|
if (!lineWidth || lineWidth < 0)
|
|
1025
905
|
return text;
|
|
1026
906
|
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
|
|
@@ -1146,14 +1026,6 @@ function consumeMoreIndentedLines(text, i) {
|
|
|
1146
1026
|
return i;
|
|
1147
1027
|
}
|
|
1148
1028
|
|
|
1149
|
-
foldFlowLines$2.FOLD_BLOCK = FOLD_BLOCK;
|
|
1150
|
-
foldFlowLines$2.FOLD_FLOW = FOLD_FLOW;
|
|
1151
|
-
foldFlowLines$2.FOLD_QUOTED = FOLD_QUOTED;
|
|
1152
|
-
foldFlowLines$2.foldFlowLines = foldFlowLines$1;
|
|
1153
|
-
|
|
1154
|
-
var Scalar$h = Scalar$k;
|
|
1155
|
-
var foldFlowLines = foldFlowLines$2;
|
|
1156
|
-
|
|
1157
1029
|
const getFoldOptions = (ctx) => ({
|
|
1158
1030
|
indentAtStart: ctx.indentAtStart,
|
|
1159
1031
|
lineWidth: ctx.options.lineWidth,
|
|
@@ -1268,7 +1140,7 @@ function doubleQuotedString(value, ctx) {
|
|
|
1268
1140
|
str = start ? str + json.slice(start) : json;
|
|
1269
1141
|
return implicitKey
|
|
1270
1142
|
? str
|
|
1271
|
-
: foldFlowLines
|
|
1143
|
+
: foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx));
|
|
1272
1144
|
}
|
|
1273
1145
|
function singleQuotedString(value, ctx) {
|
|
1274
1146
|
if (ctx.options.singleQuote === false ||
|
|
@@ -1280,7 +1152,7 @@ function singleQuotedString(value, ctx) {
|
|
|
1280
1152
|
const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
|
|
1281
1153
|
return ctx.implicitKey
|
|
1282
1154
|
? res
|
|
1283
|
-
: foldFlowLines
|
|
1155
|
+
: foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx));
|
|
1284
1156
|
}
|
|
1285
1157
|
function quotedString(value, ctx) {
|
|
1286
1158
|
const { singleQuote } = ctx.options;
|
|
@@ -1310,9 +1182,9 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
|
1310
1182
|
(ctx.forceBlockIndent || containsDocumentMarker(value) ? ' ' : '');
|
|
1311
1183
|
const literal = blockQuote === 'literal'
|
|
1312
1184
|
? true
|
|
1313
|
-
: blockQuote === 'folded' || type === Scalar
|
|
1185
|
+
: blockQuote === 'folded' || type === Scalar.BLOCK_FOLDED
|
|
1314
1186
|
? false
|
|
1315
|
-
: type === Scalar
|
|
1187
|
+
: type === Scalar.BLOCK_LITERAL
|
|
1316
1188
|
? true
|
|
1317
1189
|
: !lineLengthOverLimit(value, lineWidth, indent.length);
|
|
1318
1190
|
if (!value)
|
|
@@ -1378,7 +1250,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
|
1378
1250
|
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
1379
1251
|
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
1380
1252
|
.replace(/\n+/g, `$&${indent}`);
|
|
1381
|
-
const body = foldFlowLines
|
|
1253
|
+
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx));
|
|
1382
1254
|
return `${header}\n${indent}${body}`;
|
|
1383
1255
|
}
|
|
1384
1256
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
@@ -1402,7 +1274,7 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
1402
1274
|
}
|
|
1403
1275
|
if (!implicitKey &&
|
|
1404
1276
|
!inFlow &&
|
|
1405
|
-
type !== Scalar
|
|
1277
|
+
type !== Scalar.PLAIN &&
|
|
1406
1278
|
value.includes('\n')) {
|
|
1407
1279
|
// Where allowed & type not set explicitly, prefer block style for multiline strings
|
|
1408
1280
|
return blockString(item, ctx, onComment, onChompKeep);
|
|
@@ -1423,31 +1295,31 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
1423
1295
|
}
|
|
1424
1296
|
return implicitKey
|
|
1425
1297
|
? str
|
|
1426
|
-
: foldFlowLines
|
|
1298
|
+
: foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx));
|
|
1427
1299
|
}
|
|
1428
|
-
function stringifyString
|
|
1300
|
+
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
1429
1301
|
const { implicitKey, inFlow } = ctx;
|
|
1430
1302
|
const ss = typeof item.value === 'string'
|
|
1431
1303
|
? item
|
|
1432
1304
|
: Object.assign({}, item, { value: String(item.value) });
|
|
1433
1305
|
let { type } = item;
|
|
1434
|
-
if (type !== Scalar
|
|
1306
|
+
if (type !== Scalar.QUOTE_DOUBLE) {
|
|
1435
1307
|
// force double quotes on control characters & unpaired surrogates
|
|
1436
1308
|
if (/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(ss.value))
|
|
1437
|
-
type = Scalar
|
|
1309
|
+
type = Scalar.QUOTE_DOUBLE;
|
|
1438
1310
|
}
|
|
1439
1311
|
const _stringify = (_type) => {
|
|
1440
1312
|
switch (_type) {
|
|
1441
|
-
case Scalar
|
|
1442
|
-
case Scalar
|
|
1313
|
+
case Scalar.BLOCK_FOLDED:
|
|
1314
|
+
case Scalar.BLOCK_LITERAL:
|
|
1443
1315
|
return implicitKey || inFlow
|
|
1444
1316
|
? quotedString(ss.value, ctx) // blocks are not valid inside flow containers
|
|
1445
1317
|
: blockString(ss, ctx, onComment, onChompKeep);
|
|
1446
|
-
case Scalar
|
|
1318
|
+
case Scalar.QUOTE_DOUBLE:
|
|
1447
1319
|
return doubleQuotedString(ss.value, ctx);
|
|
1448
|
-
case Scalar
|
|
1320
|
+
case Scalar.QUOTE_SINGLE:
|
|
1449
1321
|
return singleQuotedString(ss.value, ctx);
|
|
1450
|
-
case Scalar
|
|
1322
|
+
case Scalar.PLAIN:
|
|
1451
1323
|
return plainString(ss, ctx, onComment, onChompKeep);
|
|
1452
1324
|
default:
|
|
1453
1325
|
return null;
|
|
@@ -1464,17 +1336,10 @@ function stringifyString$4(item, ctx, onComment, onChompKeep) {
|
|
|
1464
1336
|
return res;
|
|
1465
1337
|
}
|
|
1466
1338
|
|
|
1467
|
-
stringifyString$5.stringifyString = stringifyString$4;
|
|
1468
|
-
|
|
1469
|
-
var anchors$1 = anchors$3;
|
|
1470
|
-
var Node$k = Node$t;
|
|
1471
|
-
var stringifyComment$3 = stringifyComment$5;
|
|
1472
|
-
var stringifyString$3 = stringifyString$5;
|
|
1473
|
-
|
|
1474
1339
|
function createStringifyContext(doc, options) {
|
|
1475
1340
|
const opt = Object.assign({
|
|
1476
1341
|
blockQuote: true,
|
|
1477
|
-
commentString: stringifyComment
|
|
1342
|
+
commentString: stringifyComment,
|
|
1478
1343
|
defaultKeyType: null,
|
|
1479
1344
|
defaultStringType: 'PLAIN',
|
|
1480
1345
|
directives: null,
|
|
@@ -1518,7 +1383,7 @@ function getTagObject(tags, item) {
|
|
|
1518
1383
|
}
|
|
1519
1384
|
let tagObj = undefined;
|
|
1520
1385
|
let obj;
|
|
1521
|
-
if (
|
|
1386
|
+
if (isScalar$1(item)) {
|
|
1522
1387
|
obj = item.value;
|
|
1523
1388
|
const match = tags.filter(t => t.identify?.(obj));
|
|
1524
1389
|
tagObj =
|
|
@@ -1535,13 +1400,13 @@ function getTagObject(tags, item) {
|
|
|
1535
1400
|
return tagObj;
|
|
1536
1401
|
}
|
|
1537
1402
|
// needs to be called before value stringifier to allow for circular anchor refs
|
|
1538
|
-
function stringifyProps(node, tagObj, { anchors
|
|
1403
|
+
function stringifyProps(node, tagObj, { anchors, doc }) {
|
|
1539
1404
|
if (!doc.directives)
|
|
1540
1405
|
return '';
|
|
1541
1406
|
const props = [];
|
|
1542
|
-
const anchor = (
|
|
1543
|
-
if (anchor &&
|
|
1544
|
-
anchors
|
|
1407
|
+
const anchor = (isScalar$1(node) || isCollection$1(node)) && node.anchor;
|
|
1408
|
+
if (anchor && anchorIsValid(anchor)) {
|
|
1409
|
+
anchors.add(anchor);
|
|
1545
1410
|
props.push(`&${anchor}`);
|
|
1546
1411
|
}
|
|
1547
1412
|
const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
|
|
@@ -1549,10 +1414,10 @@ function stringifyProps(node, tagObj, { anchors: anchors$1$1, doc }) {
|
|
|
1549
1414
|
props.push(doc.directives.tagString(tag));
|
|
1550
1415
|
return props.join(' ');
|
|
1551
1416
|
}
|
|
1552
|
-
function stringify$
|
|
1553
|
-
if (
|
|
1417
|
+
function stringify$2(item, ctx, onComment, onChompKeep) {
|
|
1418
|
+
if (isPair(item))
|
|
1554
1419
|
return item.toString(ctx, onComment, onChompKeep);
|
|
1555
|
-
if (
|
|
1420
|
+
if (isAlias(item)) {
|
|
1556
1421
|
if (ctx.doc.directives)
|
|
1557
1422
|
return item.toString(ctx);
|
|
1558
1423
|
if (ctx.resolvedAliases?.has(item)) {
|
|
@@ -1567,7 +1432,7 @@ function stringify$8(item, ctx, onComment, onChompKeep) {
|
|
|
1567
1432
|
}
|
|
1568
1433
|
}
|
|
1569
1434
|
let tagObj = undefined;
|
|
1570
|
-
const node =
|
|
1435
|
+
const node = isNode(item)
|
|
1571
1436
|
? item
|
|
1572
1437
|
: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
|
|
1573
1438
|
if (!tagObj)
|
|
@@ -1577,32 +1442,24 @@ function stringify$8(item, ctx, onComment, onChompKeep) {
|
|
|
1577
1442
|
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
1578
1443
|
const str = typeof tagObj.stringify === 'function'
|
|
1579
1444
|
? tagObj.stringify(node, ctx, onComment, onChompKeep)
|
|
1580
|
-
:
|
|
1581
|
-
? stringifyString
|
|
1445
|
+
: isScalar$1(node)
|
|
1446
|
+
? stringifyString(node, ctx, onComment, onChompKeep)
|
|
1582
1447
|
: node.toString(ctx, onComment, onChompKeep);
|
|
1583
1448
|
if (!props)
|
|
1584
1449
|
return str;
|
|
1585
|
-
return
|
|
1450
|
+
return isScalar$1(node) || str[0] === '{' || str[0] === '['
|
|
1586
1451
|
? `${props} ${str}`
|
|
1587
1452
|
: `${props}\n${ctx.indent}${str}`;
|
|
1588
1453
|
}
|
|
1589
1454
|
|
|
1590
|
-
|
|
1591
|
-
stringify$9.stringify = stringify$8;
|
|
1592
|
-
|
|
1593
|
-
var Node$j = Node$t;
|
|
1594
|
-
var Scalar$g = Scalar$k;
|
|
1595
|
-
var stringify$7 = stringify$9;
|
|
1596
|
-
var stringifyComment$2 = stringifyComment$5;
|
|
1597
|
-
|
|
1598
|
-
function stringifyPair$1({ key, value }, ctx, onComment, onChompKeep) {
|
|
1455
|
+
function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
1599
1456
|
const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
|
|
1600
|
-
let keyComment = (
|
|
1457
|
+
let keyComment = (isNode(key) && key.comment) || null;
|
|
1601
1458
|
if (simpleKeys) {
|
|
1602
1459
|
if (keyComment) {
|
|
1603
1460
|
throw new Error('With simple keys, key nodes cannot have comments');
|
|
1604
1461
|
}
|
|
1605
|
-
if (
|
|
1462
|
+
if (isCollection$1(key)) {
|
|
1606
1463
|
const msg = 'With simple keys, collection cannot be used as a key value';
|
|
1607
1464
|
throw new Error(msg);
|
|
1608
1465
|
}
|
|
@@ -1610,9 +1467,9 @@ function stringifyPair$1({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1610
1467
|
let explicitKey = !simpleKeys &&
|
|
1611
1468
|
(!key ||
|
|
1612
1469
|
(keyComment && value == null && !ctx.inFlow) ||
|
|
1613
|
-
|
|
1614
|
-
(
|
|
1615
|
-
? key.type === Scalar
|
|
1470
|
+
isCollection$1(key) ||
|
|
1471
|
+
(isScalar$1(key)
|
|
1472
|
+
? key.type === Scalar.BLOCK_FOLDED || key.type === Scalar.BLOCK_LITERAL
|
|
1616
1473
|
: typeof key === 'object'));
|
|
1617
1474
|
ctx = Object.assign({}, ctx, {
|
|
1618
1475
|
allNullValues: false,
|
|
@@ -1621,7 +1478,7 @@ function stringifyPair$1({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1621
1478
|
});
|
|
1622
1479
|
let keyCommentDone = false;
|
|
1623
1480
|
let chompKeep = false;
|
|
1624
|
-
let str = stringify$
|
|
1481
|
+
let str = stringify$2(key, ctx, () => (keyCommentDone = true), () => (chompKeep = true));
|
|
1625
1482
|
if (!explicitKey && !ctx.inFlow && str.length > 1024) {
|
|
1626
1483
|
if (simpleKeys)
|
|
1627
1484
|
throw new Error('With simple keys, single line scalar must not span more than 1024 characters');
|
|
@@ -1637,7 +1494,7 @@ function stringifyPair$1({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1637
1494
|
else if ((allNullValues && !simpleKeys) || (value == null && explicitKey)) {
|
|
1638
1495
|
str = `? ${str}`;
|
|
1639
1496
|
if (keyComment && !keyCommentDone) {
|
|
1640
|
-
str +=
|
|
1497
|
+
str += lineComment(str, ctx.indent, commentString(keyComment));
|
|
1641
1498
|
}
|
|
1642
1499
|
else if (chompKeep && onChompKeep)
|
|
1643
1500
|
onChompKeep();
|
|
@@ -1647,22 +1504,22 @@ function stringifyPair$1({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1647
1504
|
keyComment = null;
|
|
1648
1505
|
if (explicitKey) {
|
|
1649
1506
|
if (keyComment)
|
|
1650
|
-
str +=
|
|
1507
|
+
str += lineComment(str, ctx.indent, commentString(keyComment));
|
|
1651
1508
|
str = `? ${str}\n${indent}:`;
|
|
1652
1509
|
}
|
|
1653
1510
|
else {
|
|
1654
1511
|
str = `${str}:`;
|
|
1655
1512
|
if (keyComment)
|
|
1656
|
-
str +=
|
|
1513
|
+
str += lineComment(str, ctx.indent, commentString(keyComment));
|
|
1657
1514
|
}
|
|
1658
1515
|
let vcb = '';
|
|
1659
1516
|
let valueComment = null;
|
|
1660
|
-
if (
|
|
1517
|
+
if (isNode(value)) {
|
|
1661
1518
|
if (value.spaceBefore)
|
|
1662
1519
|
vcb = '\n';
|
|
1663
1520
|
if (value.commentBefore) {
|
|
1664
1521
|
const cs = commentString(value.commentBefore);
|
|
1665
|
-
vcb += `\n${
|
|
1522
|
+
vcb += `\n${indentComment(cs, ctx.indent)}`;
|
|
1666
1523
|
}
|
|
1667
1524
|
valueComment = value.comment;
|
|
1668
1525
|
}
|
|
@@ -1670,14 +1527,14 @@ function stringifyPair$1({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1670
1527
|
value = doc.createNode(value);
|
|
1671
1528
|
}
|
|
1672
1529
|
ctx.implicitKey = false;
|
|
1673
|
-
if (!explicitKey && !keyComment &&
|
|
1530
|
+
if (!explicitKey && !keyComment && isScalar$1(value))
|
|
1674
1531
|
ctx.indentAtStart = str.length + 1;
|
|
1675
1532
|
chompKeep = false;
|
|
1676
1533
|
if (!indentSeq &&
|
|
1677
1534
|
indentStep.length >= 2 &&
|
|
1678
1535
|
!ctx.inFlow &&
|
|
1679
1536
|
!explicitKey &&
|
|
1680
|
-
|
|
1537
|
+
isSeq(value) &&
|
|
1681
1538
|
!value.flow &&
|
|
1682
1539
|
!value.tag &&
|
|
1683
1540
|
!value.anchor) {
|
|
@@ -1685,7 +1542,7 @@ function stringifyPair$1({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1685
1542
|
ctx.indent = ctx.indent.substr(2);
|
|
1686
1543
|
}
|
|
1687
1544
|
let valueCommentDone = false;
|
|
1688
|
-
const valueStr = stringify$
|
|
1545
|
+
const valueStr = stringify$2(value, ctx, () => (valueCommentDone = true), () => (chompKeep = true));
|
|
1689
1546
|
let ws = ' ';
|
|
1690
1547
|
if (vcb || keyComment) {
|
|
1691
1548
|
if (valueStr === '' && !ctx.inFlow)
|
|
@@ -1693,7 +1550,7 @@ function stringifyPair$1({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1693
1550
|
else
|
|
1694
1551
|
ws = `${vcb}\n${ctx.indent}`;
|
|
1695
1552
|
}
|
|
1696
|
-
else if (!explicitKey &&
|
|
1553
|
+
else if (!explicitKey && isCollection$1(value)) {
|
|
1697
1554
|
const flow = valueStr[0] === '[' || valueStr[0] === '{';
|
|
1698
1555
|
if (!flow || valueStr.includes('\n'))
|
|
1699
1556
|
ws = `\n${ctx.indent}`;
|
|
@@ -1706,7 +1563,7 @@ function stringifyPair$1({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1706
1563
|
onComment();
|
|
1707
1564
|
}
|
|
1708
1565
|
else if (valueComment && !valueCommentDone) {
|
|
1709
|
-
str +=
|
|
1566
|
+
str += lineComment(str, ctx.indent, commentString(valueComment));
|
|
1710
1567
|
}
|
|
1711
1568
|
else if (chompKeep && onChompKeep) {
|
|
1712
1569
|
onChompKeep();
|
|
@@ -1714,16 +1571,6 @@ function stringifyPair$1({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1714
1571
|
return str;
|
|
1715
1572
|
}
|
|
1716
1573
|
|
|
1717
|
-
stringifyPair$2.stringifyPair = stringifyPair$1;
|
|
1718
|
-
|
|
1719
|
-
var addPairToJSMap$3 = {};
|
|
1720
|
-
|
|
1721
|
-
var log$2 = {};
|
|
1722
|
-
|
|
1723
|
-
function debug(logLevel, ...messages) {
|
|
1724
|
-
if (logLevel === 'debug')
|
|
1725
|
-
console.log(...messages);
|
|
1726
|
-
}
|
|
1727
1574
|
function warn(logLevel, warning) {
|
|
1728
1575
|
if (logLevel === 'debug' || logLevel === 'warn') {
|
|
1729
1576
|
if (typeof process !== 'undefined' && process.emitWarning)
|
|
@@ -1733,20 +1580,11 @@ function warn(logLevel, warning) {
|
|
|
1733
1580
|
}
|
|
1734
1581
|
}
|
|
1735
1582
|
|
|
1736
|
-
log$2.debug = debug;
|
|
1737
|
-
log$2.warn = warn;
|
|
1738
|
-
|
|
1739
|
-
var log$1 = log$2;
|
|
1740
|
-
var stringify$6 = stringify$9;
|
|
1741
|
-
var Node$i = Node$t;
|
|
1742
|
-
var Scalar$f = Scalar$k;
|
|
1743
|
-
var toJS$3 = toJS$6;
|
|
1744
|
-
|
|
1745
1583
|
const MERGE_KEY = '<<';
|
|
1746
|
-
function addPairToJSMap
|
|
1584
|
+
function addPairToJSMap(ctx, map, { key, value }) {
|
|
1747
1585
|
if (ctx?.doc.schema.merge && isMergeKey(key)) {
|
|
1748
|
-
value =
|
|
1749
|
-
if (
|
|
1586
|
+
value = isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
1587
|
+
if (isSeq(value))
|
|
1750
1588
|
for (const it of value.items)
|
|
1751
1589
|
mergeToJSMap(ctx, map, it);
|
|
1752
1590
|
else if (Array.isArray(value))
|
|
@@ -1756,16 +1594,16 @@ function addPairToJSMap$2(ctx, map, { key, value }) {
|
|
|
1756
1594
|
mergeToJSMap(ctx, map, value);
|
|
1757
1595
|
}
|
|
1758
1596
|
else {
|
|
1759
|
-
const jsKey = toJS
|
|
1597
|
+
const jsKey = toJS(key, '', ctx);
|
|
1760
1598
|
if (map instanceof Map) {
|
|
1761
|
-
map.set(jsKey, toJS
|
|
1599
|
+
map.set(jsKey, toJS(value, jsKey, ctx));
|
|
1762
1600
|
}
|
|
1763
1601
|
else if (map instanceof Set) {
|
|
1764
1602
|
map.add(jsKey);
|
|
1765
1603
|
}
|
|
1766
1604
|
else {
|
|
1767
1605
|
const stringKey = stringifyKey(key, jsKey, ctx);
|
|
1768
|
-
const jsValue = toJS
|
|
1606
|
+
const jsValue = toJS(value, stringKey, ctx);
|
|
1769
1607
|
if (stringKey in map)
|
|
1770
1608
|
Object.defineProperty(map, stringKey, {
|
|
1771
1609
|
value: jsValue,
|
|
@@ -1780,9 +1618,9 @@ function addPairToJSMap$2(ctx, map, { key, value }) {
|
|
|
1780
1618
|
return map;
|
|
1781
1619
|
}
|
|
1782
1620
|
const isMergeKey = (key) => key === MERGE_KEY ||
|
|
1783
|
-
(
|
|
1621
|
+
(isScalar$1(key) &&
|
|
1784
1622
|
key.value === MERGE_KEY &&
|
|
1785
|
-
(!key.type || key.type === Scalar
|
|
1623
|
+
(!key.type || key.type === Scalar.PLAIN));
|
|
1786
1624
|
// If the value associated with a merge key is a single mapping node, each of
|
|
1787
1625
|
// its key/value pairs is inserted into the current mapping, unless the key
|
|
1788
1626
|
// already exists in it. If the value associated with the merge key is a
|
|
@@ -1791,8 +1629,8 @@ const isMergeKey = (key) => key === MERGE_KEY ||
|
|
|
1791
1629
|
// Keys in mapping nodes earlier in the sequence override keys specified in
|
|
1792
1630
|
// later mapping nodes. -- http://yaml.org/type/merge.html
|
|
1793
1631
|
function mergeToJSMap(ctx, map, value) {
|
|
1794
|
-
const source = ctx &&
|
|
1795
|
-
if (!
|
|
1632
|
+
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
1633
|
+
if (!isMap(source))
|
|
1796
1634
|
throw new Error('Merge sources must be maps or map aliases');
|
|
1797
1635
|
const srcMap = source.toJSON(null, ctx, Map);
|
|
1798
1636
|
for (const [key, value] of srcMap) {
|
|
@@ -1819,8 +1657,8 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
1819
1657
|
return '';
|
|
1820
1658
|
if (typeof jsKey !== 'object')
|
|
1821
1659
|
return String(jsKey);
|
|
1822
|
-
if (
|
|
1823
|
-
const strCtx =
|
|
1660
|
+
if (isNode(key) && ctx && ctx.doc) {
|
|
1661
|
+
const strCtx = createStringifyContext(ctx.doc, {});
|
|
1824
1662
|
strCtx.anchors = new Set();
|
|
1825
1663
|
for (const node of ctx.anchors.keys())
|
|
1826
1664
|
strCtx.anchors.add(node.anchor);
|
|
@@ -1831,7 +1669,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
1831
1669
|
let jsonStr = JSON.stringify(strKey);
|
|
1832
1670
|
if (jsonStr.length > 40)
|
|
1833
1671
|
jsonStr = jsonStr.substring(0, 36) + '..."';
|
|
1834
|
-
|
|
1672
|
+
warn(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`);
|
|
1835
1673
|
ctx.mapKeyWarned = true;
|
|
1836
1674
|
}
|
|
1837
1675
|
return strKey;
|
|
@@ -1839,60 +1677,37 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
1839
1677
|
return JSON.stringify(jsKey);
|
|
1840
1678
|
}
|
|
1841
1679
|
|
|
1842
|
-
addPairToJSMap$3.addPairToJSMap = addPairToJSMap$2;
|
|
1843
|
-
|
|
1844
|
-
var createNode$2 = createNode$5;
|
|
1845
|
-
var stringifyPair = stringifyPair$2;
|
|
1846
|
-
var addPairToJSMap$1 = addPairToJSMap$3;
|
|
1847
|
-
var Node$h = Node$t;
|
|
1848
|
-
|
|
1849
1680
|
function createPair(key, value, ctx) {
|
|
1850
|
-
const k = createNode
|
|
1851
|
-
const v = createNode
|
|
1852
|
-
return new Pair
|
|
1681
|
+
const k = createNode(key, undefined, ctx);
|
|
1682
|
+
const v = createNode(value, undefined, ctx);
|
|
1683
|
+
return new Pair(k, v);
|
|
1853
1684
|
}
|
|
1854
|
-
class Pair
|
|
1685
|
+
class Pair {
|
|
1855
1686
|
constructor(key, value = null) {
|
|
1856
|
-
Object.defineProperty(this,
|
|
1687
|
+
Object.defineProperty(this, NODE_TYPE, { value: PAIR });
|
|
1857
1688
|
this.key = key;
|
|
1858
1689
|
this.value = value;
|
|
1859
1690
|
}
|
|
1860
1691
|
clone(schema) {
|
|
1861
1692
|
let { key, value } = this;
|
|
1862
|
-
if (
|
|
1693
|
+
if (isNode(key))
|
|
1863
1694
|
key = key.clone(schema);
|
|
1864
|
-
if (
|
|
1695
|
+
if (isNode(value))
|
|
1865
1696
|
value = value.clone(schema);
|
|
1866
|
-
return new Pair
|
|
1697
|
+
return new Pair(key, value);
|
|
1867
1698
|
}
|
|
1868
1699
|
toJSON(_, ctx) {
|
|
1869
1700
|
const pair = ctx?.mapAsMap ? new Map() : {};
|
|
1870
|
-
return addPairToJSMap
|
|
1701
|
+
return addPairToJSMap(ctx, pair, this);
|
|
1871
1702
|
}
|
|
1872
1703
|
toString(ctx, onComment, onChompKeep) {
|
|
1873
1704
|
return ctx?.doc
|
|
1874
|
-
? stringifyPair
|
|
1705
|
+
? stringifyPair(this, ctx, onComment, onChompKeep)
|
|
1875
1706
|
: JSON.stringify(this);
|
|
1876
1707
|
}
|
|
1877
1708
|
}
|
|
1878
1709
|
|
|
1879
|
-
|
|
1880
|
-
Pair$9.createPair = createPair;
|
|
1881
|
-
|
|
1882
|
-
var Schema$3 = {};
|
|
1883
|
-
|
|
1884
|
-
var map$6 = {};
|
|
1885
|
-
|
|
1886
|
-
var YAMLMap$7 = {};
|
|
1887
|
-
|
|
1888
|
-
var stringifyCollection$3 = {};
|
|
1889
|
-
|
|
1890
|
-
var Collection$3 = Collection$5;
|
|
1891
|
-
var Node$g = Node$t;
|
|
1892
|
-
var stringify$5 = stringify$9;
|
|
1893
|
-
var stringifyComment$1 = stringifyComment$5;
|
|
1894
|
-
|
|
1895
|
-
function stringifyCollection$2(collection, ctx, options) {
|
|
1710
|
+
function stringifyCollection(collection, ctx, options) {
|
|
1896
1711
|
const flow = ctx.inFlow ?? collection.flow;
|
|
1897
1712
|
const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
1898
1713
|
return stringify(collection, ctx, options);
|
|
@@ -1905,15 +1720,15 @@ function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, fl
|
|
|
1905
1720
|
for (let i = 0; i < items.length; ++i) {
|
|
1906
1721
|
const item = items[i];
|
|
1907
1722
|
let comment = null;
|
|
1908
|
-
if (
|
|
1723
|
+
if (isNode(item)) {
|
|
1909
1724
|
if (!chompKeep && item.spaceBefore)
|
|
1910
1725
|
lines.push('');
|
|
1911
1726
|
addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
|
|
1912
1727
|
if (item.comment)
|
|
1913
1728
|
comment = item.comment;
|
|
1914
1729
|
}
|
|
1915
|
-
else if (
|
|
1916
|
-
const ik =
|
|
1730
|
+
else if (isPair(item)) {
|
|
1731
|
+
const ik = isNode(item.key) ? item.key : null;
|
|
1917
1732
|
if (ik) {
|
|
1918
1733
|
if (!chompKeep && ik.spaceBefore)
|
|
1919
1734
|
lines.push('');
|
|
@@ -1921,9 +1736,9 @@ function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, fl
|
|
|
1921
1736
|
}
|
|
1922
1737
|
}
|
|
1923
1738
|
chompKeep = false;
|
|
1924
|
-
let str = stringify$
|
|
1739
|
+
let str = stringify$2(item, itemCtx, () => (comment = null), () => (chompKeep = true));
|
|
1925
1740
|
if (comment)
|
|
1926
|
-
str +=
|
|
1741
|
+
str += lineComment(str, itemIndent, commentString(comment));
|
|
1927
1742
|
if (chompKeep && comment)
|
|
1928
1743
|
chompKeep = false;
|
|
1929
1744
|
lines.push(blockItemPrefix + str);
|
|
@@ -1940,7 +1755,7 @@ function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, fl
|
|
|
1940
1755
|
}
|
|
1941
1756
|
}
|
|
1942
1757
|
if (comment) {
|
|
1943
|
-
str += '\n' +
|
|
1758
|
+
str += '\n' + indentComment(commentString(comment), indent);
|
|
1944
1759
|
if (onComment)
|
|
1945
1760
|
onComment();
|
|
1946
1761
|
}
|
|
@@ -1962,15 +1777,15 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
|
|
|
1962
1777
|
for (let i = 0; i < items.length; ++i) {
|
|
1963
1778
|
const item = items[i];
|
|
1964
1779
|
let comment = null;
|
|
1965
|
-
if (
|
|
1780
|
+
if (isNode(item)) {
|
|
1966
1781
|
if (item.spaceBefore)
|
|
1967
1782
|
lines.push('');
|
|
1968
1783
|
addCommentBefore(ctx, lines, item.commentBefore, false);
|
|
1969
1784
|
if (item.comment)
|
|
1970
1785
|
comment = item.comment;
|
|
1971
1786
|
}
|
|
1972
|
-
else if (
|
|
1973
|
-
const ik =
|
|
1787
|
+
else if (isPair(item)) {
|
|
1788
|
+
const ik = isNode(item.key) ? item.key : null;
|
|
1974
1789
|
if (ik) {
|
|
1975
1790
|
if (ik.spaceBefore)
|
|
1976
1791
|
lines.push('');
|
|
@@ -1978,7 +1793,7 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
|
|
|
1978
1793
|
if (ik.comment)
|
|
1979
1794
|
reqNewline = true;
|
|
1980
1795
|
}
|
|
1981
|
-
const iv =
|
|
1796
|
+
const iv = isNode(item.value) ? item.value : null;
|
|
1982
1797
|
if (iv) {
|
|
1983
1798
|
if (iv.comment)
|
|
1984
1799
|
comment = iv.comment;
|
|
@@ -1991,11 +1806,11 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
|
|
|
1991
1806
|
}
|
|
1992
1807
|
if (comment)
|
|
1993
1808
|
reqNewline = true;
|
|
1994
|
-
let str = stringify$
|
|
1809
|
+
let str = stringify$2(item, itemCtx, () => (comment = null));
|
|
1995
1810
|
if (i < items.length - 1)
|
|
1996
1811
|
str += ',';
|
|
1997
1812
|
if (comment)
|
|
1998
|
-
str +=
|
|
1813
|
+
str += lineComment(str, itemIndent, commentString(comment));
|
|
1999
1814
|
if (!reqNewline && (lines.length > linesAtValue || str.includes('\n')))
|
|
2000
1815
|
reqNewline = true;
|
|
2001
1816
|
lines.push(str);
|
|
@@ -2009,7 +1824,7 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
|
|
|
2009
1824
|
else {
|
|
2010
1825
|
if (!reqNewline) {
|
|
2011
1826
|
const len = lines.reduce((sum, line) => sum + line.length + 2, 2);
|
|
2012
|
-
reqNewline = len > Collection
|
|
1827
|
+
reqNewline = len > Collection.maxFlowStringSingleLineLength;
|
|
2013
1828
|
}
|
|
2014
1829
|
if (reqNewline) {
|
|
2015
1830
|
str = start;
|
|
@@ -2022,7 +1837,7 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
|
|
|
2022
1837
|
}
|
|
2023
1838
|
}
|
|
2024
1839
|
if (comment) {
|
|
2025
|
-
str +=
|
|
1840
|
+
str += lineComment(str, commentString(comment), indent);
|
|
2026
1841
|
if (onComment)
|
|
2027
1842
|
onComment();
|
|
2028
1843
|
}
|
|
@@ -2032,35 +1847,26 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
|
|
|
2032
1847
|
if (comment && chompKeep)
|
|
2033
1848
|
comment = comment.replace(/^\n+/, '');
|
|
2034
1849
|
if (comment) {
|
|
2035
|
-
const ic =
|
|
1850
|
+
const ic = indentComment(commentString(comment), indent);
|
|
2036
1851
|
lines.push(ic.trimStart()); // Avoid double indent on first line
|
|
2037
1852
|
}
|
|
2038
1853
|
}
|
|
2039
1854
|
|
|
2040
|
-
stringifyCollection$3.stringifyCollection = stringifyCollection$2;
|
|
2041
|
-
|
|
2042
|
-
var stringifyCollection$1 = stringifyCollection$3;
|
|
2043
|
-
var addPairToJSMap = addPairToJSMap$3;
|
|
2044
|
-
var Collection$2 = Collection$5;
|
|
2045
|
-
var Node$f = Node$t;
|
|
2046
|
-
var Pair$7 = Pair$9;
|
|
2047
|
-
var Scalar$e = Scalar$k;
|
|
2048
|
-
|
|
2049
1855
|
function findPair(items, key) {
|
|
2050
|
-
const k =
|
|
1856
|
+
const k = isScalar$1(key) ? key.value : key;
|
|
2051
1857
|
for (const it of items) {
|
|
2052
|
-
if (
|
|
1858
|
+
if (isPair(it)) {
|
|
2053
1859
|
if (it.key === key || it.key === k)
|
|
2054
1860
|
return it;
|
|
2055
|
-
if (
|
|
1861
|
+
if (isScalar$1(it.key) && it.key.value === k)
|
|
2056
1862
|
return it;
|
|
2057
1863
|
}
|
|
2058
1864
|
}
|
|
2059
1865
|
return undefined;
|
|
2060
1866
|
}
|
|
2061
|
-
class YAMLMap
|
|
1867
|
+
class YAMLMap extends Collection {
|
|
2062
1868
|
constructor(schema) {
|
|
2063
|
-
super(
|
|
1869
|
+
super(MAP, schema);
|
|
2064
1870
|
this.items = [];
|
|
2065
1871
|
}
|
|
2066
1872
|
static get tagName() {
|
|
@@ -2074,21 +1880,21 @@ class YAMLMap$6 extends Collection$2.Collection {
|
|
|
2074
1880
|
*/
|
|
2075
1881
|
add(pair, overwrite) {
|
|
2076
1882
|
let _pair;
|
|
2077
|
-
if (
|
|
1883
|
+
if (isPair(pair))
|
|
2078
1884
|
_pair = pair;
|
|
2079
1885
|
else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
|
|
2080
1886
|
// In TypeScript, this never happens.
|
|
2081
|
-
_pair = new Pair
|
|
1887
|
+
_pair = new Pair(pair, pair?.value);
|
|
2082
1888
|
}
|
|
2083
1889
|
else
|
|
2084
|
-
_pair = new Pair
|
|
1890
|
+
_pair = new Pair(pair.key, pair.value);
|
|
2085
1891
|
const prev = findPair(this.items, _pair.key);
|
|
2086
1892
|
const sortEntries = this.schema?.sortMapEntries;
|
|
2087
1893
|
if (prev) {
|
|
2088
1894
|
if (!overwrite)
|
|
2089
1895
|
throw new Error(`Key ${_pair.key} already set`);
|
|
2090
1896
|
// For scalars, keep the old node & its comments and anchors
|
|
2091
|
-
if (
|
|
1897
|
+
if (isScalar$1(prev.value) && isScalarValue(_pair.value))
|
|
2092
1898
|
prev.value.value = _pair.value;
|
|
2093
1899
|
else
|
|
2094
1900
|
prev.value = _pair.value;
|
|
@@ -2114,13 +1920,13 @@ class YAMLMap$6 extends Collection$2.Collection {
|
|
|
2114
1920
|
get(key, keepScalar) {
|
|
2115
1921
|
const it = findPair(this.items, key);
|
|
2116
1922
|
const node = it?.value;
|
|
2117
|
-
return (!keepScalar &&
|
|
1923
|
+
return (!keepScalar && isScalar$1(node) ? node.value : node) ?? undefined;
|
|
2118
1924
|
}
|
|
2119
1925
|
has(key) {
|
|
2120
1926
|
return !!findPair(this.items, key);
|
|
2121
1927
|
}
|
|
2122
1928
|
set(key, value) {
|
|
2123
|
-
this.add(new Pair
|
|
1929
|
+
this.add(new Pair(key, value), true);
|
|
2124
1930
|
}
|
|
2125
1931
|
/**
|
|
2126
1932
|
* @param ctx - Conversion context, originally set in Document#toJS()
|
|
@@ -2132,19 +1938,19 @@ class YAMLMap$6 extends Collection$2.Collection {
|
|
|
2132
1938
|
if (ctx?.onCreate)
|
|
2133
1939
|
ctx.onCreate(map);
|
|
2134
1940
|
for (const item of this.items)
|
|
2135
|
-
addPairToJSMap
|
|
1941
|
+
addPairToJSMap(ctx, map, item);
|
|
2136
1942
|
return map;
|
|
2137
1943
|
}
|
|
2138
1944
|
toString(ctx, onComment, onChompKeep) {
|
|
2139
1945
|
if (!ctx)
|
|
2140
1946
|
return JSON.stringify(this);
|
|
2141
1947
|
for (const item of this.items) {
|
|
2142
|
-
if (!
|
|
1948
|
+
if (!isPair(item))
|
|
2143
1949
|
throw new Error(`Map items must all be pairs; found ${JSON.stringify(item)} instead`);
|
|
2144
1950
|
}
|
|
2145
1951
|
if (!ctx.allNullValues && this.hasAllNullValues(false))
|
|
2146
1952
|
ctx = Object.assign({}, ctx, { allNullValues: true });
|
|
2147
|
-
return stringifyCollection
|
|
1953
|
+
return stringifyCollection(this, ctx, {
|
|
2148
1954
|
blockItemPrefix: '',
|
|
2149
1955
|
flowChars: { start: '{', end: '}' },
|
|
2150
1956
|
itemIndent: ctx.indent || '',
|
|
@@ -2154,23 +1960,16 @@ class YAMLMap$6 extends Collection$2.Collection {
|
|
|
2154
1960
|
}
|
|
2155
1961
|
}
|
|
2156
1962
|
|
|
2157
|
-
YAMLMap$7.YAMLMap = YAMLMap$6;
|
|
2158
|
-
YAMLMap$7.findPair = findPair;
|
|
2159
|
-
|
|
2160
|
-
var Node$e = Node$t;
|
|
2161
|
-
var Pair$6 = Pair$9;
|
|
2162
|
-
var YAMLMap$5 = YAMLMap$7;
|
|
2163
|
-
|
|
2164
1963
|
function createMap(schema, obj, ctx) {
|
|
2165
1964
|
const { keepUndefined, replacer } = ctx;
|
|
2166
|
-
const map = new YAMLMap
|
|
1965
|
+
const map = new YAMLMap(schema);
|
|
2167
1966
|
const add = (key, value) => {
|
|
2168
1967
|
if (typeof replacer === 'function')
|
|
2169
1968
|
value = replacer.call(obj, key, value);
|
|
2170
1969
|
else if (Array.isArray(replacer) && !replacer.includes(key))
|
|
2171
1970
|
return;
|
|
2172
1971
|
if (value !== undefined || keepUndefined)
|
|
2173
|
-
map.items.push(
|
|
1972
|
+
map.items.push(createPair(key, value, ctx));
|
|
2174
1973
|
};
|
|
2175
1974
|
if (obj instanceof Map) {
|
|
2176
1975
|
for (const [key, value] of obj)
|
|
@@ -2185,34 +1984,22 @@ function createMap(schema, obj, ctx) {
|
|
|
2185
1984
|
}
|
|
2186
1985
|
return map;
|
|
2187
1986
|
}
|
|
2188
|
-
const map
|
|
1987
|
+
const map = {
|
|
2189
1988
|
collection: 'map',
|
|
2190
1989
|
createNode: createMap,
|
|
2191
1990
|
default: true,
|
|
2192
|
-
nodeClass: YAMLMap
|
|
1991
|
+
nodeClass: YAMLMap,
|
|
2193
1992
|
tag: 'tag:yaml.org,2002:map',
|
|
2194
1993
|
resolve(map, onError) {
|
|
2195
|
-
if (!
|
|
1994
|
+
if (!isMap(map))
|
|
2196
1995
|
onError('Expected a mapping for this tag');
|
|
2197
1996
|
return map;
|
|
2198
1997
|
}
|
|
2199
1998
|
};
|
|
2200
1999
|
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
var seq$6 = {};
|
|
2204
|
-
|
|
2205
|
-
var YAMLSeq$7 = {};
|
|
2206
|
-
|
|
2207
|
-
var stringifyCollection = stringifyCollection$3;
|
|
2208
|
-
var Collection$1 = Collection$5;
|
|
2209
|
-
var Node$d = Node$t;
|
|
2210
|
-
var Scalar$d = Scalar$k;
|
|
2211
|
-
var toJS$2 = toJS$6;
|
|
2212
|
-
|
|
2213
|
-
class YAMLSeq$6 extends Collection$1.Collection {
|
|
2000
|
+
class YAMLSeq extends Collection {
|
|
2214
2001
|
constructor(schema) {
|
|
2215
|
-
super(
|
|
2002
|
+
super(SEQ, schema);
|
|
2216
2003
|
this.items = [];
|
|
2217
2004
|
}
|
|
2218
2005
|
static get tagName() {
|
|
@@ -2241,7 +2028,7 @@ class YAMLSeq$6 extends Collection$1.Collection {
|
|
|
2241
2028
|
if (typeof idx !== 'number')
|
|
2242
2029
|
return undefined;
|
|
2243
2030
|
const it = this.items[idx];
|
|
2244
|
-
return !keepScalar &&
|
|
2031
|
+
return !keepScalar && isScalar$1(it) ? it.value : it;
|
|
2245
2032
|
}
|
|
2246
2033
|
/**
|
|
2247
2034
|
* Checks if the collection includes a value with the key `key`.
|
|
@@ -2265,7 +2052,7 @@ class YAMLSeq$6 extends Collection$1.Collection {
|
|
|
2265
2052
|
if (typeof idx !== 'number')
|
|
2266
2053
|
throw new Error(`Expected a valid index, not ${key}.`);
|
|
2267
2054
|
const prev = this.items[idx];
|
|
2268
|
-
if (
|
|
2055
|
+
if (isScalar$1(prev) && isScalarValue(value))
|
|
2269
2056
|
prev.value = value;
|
|
2270
2057
|
else
|
|
2271
2058
|
this.items[idx] = value;
|
|
@@ -2276,13 +2063,13 @@ class YAMLSeq$6 extends Collection$1.Collection {
|
|
|
2276
2063
|
ctx.onCreate(seq);
|
|
2277
2064
|
let i = 0;
|
|
2278
2065
|
for (const item of this.items)
|
|
2279
|
-
seq.push(toJS
|
|
2066
|
+
seq.push(toJS(item, String(i++), ctx));
|
|
2280
2067
|
return seq;
|
|
2281
2068
|
}
|
|
2282
2069
|
toString(ctx, onComment, onChompKeep) {
|
|
2283
2070
|
if (!ctx)
|
|
2284
2071
|
return JSON.stringify(this);
|
|
2285
|
-
return stringifyCollection
|
|
2072
|
+
return stringifyCollection(this, ctx, {
|
|
2286
2073
|
blockItemPrefix: '- ',
|
|
2287
2074
|
flowChars: { start: '[', end: ']' },
|
|
2288
2075
|
itemIndent: (ctx.indent || '') + ' ',
|
|
@@ -2292,7 +2079,7 @@ class YAMLSeq$6 extends Collection$1.Collection {
|
|
|
2292
2079
|
}
|
|
2293
2080
|
}
|
|
2294
2081
|
function asItemIndex(key) {
|
|
2295
|
-
let idx =
|
|
2082
|
+
let idx = isScalar$1(key) ? key.value : key;
|
|
2296
2083
|
if (idx && typeof idx === 'string')
|
|
2297
2084
|
idx = Number(idx);
|
|
2298
2085
|
return typeof idx === 'number' && Number.isInteger(idx) && idx >= 0
|
|
@@ -2300,15 +2087,9 @@ function asItemIndex(key) {
|
|
|
2300
2087
|
: null;
|
|
2301
2088
|
}
|
|
2302
2089
|
|
|
2303
|
-
YAMLSeq$7.YAMLSeq = YAMLSeq$6;
|
|
2304
|
-
|
|
2305
|
-
var createNode$1 = createNode$5;
|
|
2306
|
-
var Node$c = Node$t;
|
|
2307
|
-
var YAMLSeq$5 = YAMLSeq$7;
|
|
2308
|
-
|
|
2309
2090
|
function createSeq(schema, obj, ctx) {
|
|
2310
2091
|
const { replacer } = ctx;
|
|
2311
|
-
const seq = new YAMLSeq
|
|
2092
|
+
const seq = new YAMLSeq(schema);
|
|
2312
2093
|
if (obj && Symbol.iterator in Object(obj)) {
|
|
2313
2094
|
let i = 0;
|
|
2314
2095
|
for (let it of obj) {
|
|
@@ -2316,73 +2097,53 @@ function createSeq(schema, obj, ctx) {
|
|
|
2316
2097
|
const key = obj instanceof Set ? it : String(i++);
|
|
2317
2098
|
it = replacer.call(obj, key, it);
|
|
2318
2099
|
}
|
|
2319
|
-
seq.items.push(createNode
|
|
2100
|
+
seq.items.push(createNode(it, undefined, ctx));
|
|
2320
2101
|
}
|
|
2321
2102
|
}
|
|
2322
2103
|
return seq;
|
|
2323
2104
|
}
|
|
2324
|
-
const seq
|
|
2105
|
+
const seq = {
|
|
2325
2106
|
collection: 'seq',
|
|
2326
2107
|
createNode: createSeq,
|
|
2327
2108
|
default: true,
|
|
2328
|
-
nodeClass: YAMLSeq
|
|
2109
|
+
nodeClass: YAMLSeq,
|
|
2329
2110
|
tag: 'tag:yaml.org,2002:seq',
|
|
2330
2111
|
resolve(seq, onError) {
|
|
2331
|
-
if (!
|
|
2112
|
+
if (!isSeq(seq))
|
|
2332
2113
|
onError('Expected a sequence for this tag');
|
|
2333
2114
|
return seq;
|
|
2334
2115
|
}
|
|
2335
2116
|
};
|
|
2336
2117
|
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
var string$5 = {};
|
|
2340
|
-
|
|
2341
|
-
var stringifyString$2 = stringifyString$5;
|
|
2342
|
-
|
|
2343
|
-
const string$4 = {
|
|
2118
|
+
const string = {
|
|
2344
2119
|
identify: value => typeof value === 'string',
|
|
2345
2120
|
default: true,
|
|
2346
2121
|
tag: 'tag:yaml.org,2002:str',
|
|
2347
2122
|
resolve: str => str,
|
|
2348
2123
|
stringify(item, ctx, onComment, onChompKeep) {
|
|
2349
2124
|
ctx = Object.assign({ actualString: true }, ctx);
|
|
2350
|
-
return stringifyString
|
|
2125
|
+
return stringifyString(item, ctx, onComment, onChompKeep);
|
|
2351
2126
|
}
|
|
2352
2127
|
};
|
|
2353
2128
|
|
|
2354
|
-
string$5.string = string$4;
|
|
2355
|
-
|
|
2356
|
-
var tags$1 = {};
|
|
2357
|
-
|
|
2358
|
-
var _null$3 = {};
|
|
2359
|
-
|
|
2360
|
-
var Scalar$c = Scalar$k;
|
|
2361
|
-
|
|
2362
2129
|
const nullTag = {
|
|
2363
2130
|
identify: value => value == null,
|
|
2364
|
-
createNode: () => new Scalar
|
|
2131
|
+
createNode: () => new Scalar(null),
|
|
2365
2132
|
default: true,
|
|
2366
2133
|
tag: 'tag:yaml.org,2002:null',
|
|
2367
2134
|
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
2368
|
-
resolve: () => new Scalar
|
|
2135
|
+
resolve: () => new Scalar(null),
|
|
2369
2136
|
stringify: ({ source }, ctx) => typeof source === 'string' && nullTag.test.test(source)
|
|
2370
2137
|
? source
|
|
2371
2138
|
: ctx.options.nullStr
|
|
2372
2139
|
};
|
|
2373
2140
|
|
|
2374
|
-
_null$3.nullTag = nullTag;
|
|
2375
|
-
|
|
2376
|
-
var bool$4 = {};
|
|
2377
|
-
|
|
2378
|
-
var Scalar$b = Scalar$k;
|
|
2379
|
-
|
|
2380
2141
|
const boolTag = {
|
|
2381
2142
|
identify: value => typeof value === 'boolean',
|
|
2382
2143
|
default: true,
|
|
2383
2144
|
tag: 'tag:yaml.org,2002:bool',
|
|
2384
2145
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
2385
|
-
resolve: str => new Scalar
|
|
2146
|
+
resolve: str => new Scalar(str[0] === 't' || str[0] === 'T'),
|
|
2386
2147
|
stringify({ source, value }, ctx) {
|
|
2387
2148
|
if (source && boolTag.test.test(source)) {
|
|
2388
2149
|
const sv = source[0] === 't' || source[0] === 'T';
|
|
@@ -2393,13 +2154,7 @@ const boolTag = {
|
|
|
2393
2154
|
}
|
|
2394
2155
|
};
|
|
2395
2156
|
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
var float$6 = {};
|
|
2399
|
-
|
|
2400
|
-
var stringifyNumber$6 = {};
|
|
2401
|
-
|
|
2402
|
-
function stringifyNumber$5({ format, minFractionDigits, tag, value }) {
|
|
2157
|
+
function stringifyNumber({ format, minFractionDigits, tag, value }) {
|
|
2403
2158
|
if (typeof value === 'bigint')
|
|
2404
2159
|
return String(value);
|
|
2405
2160
|
const num = typeof value === 'number' ? value : Number(value);
|
|
@@ -2422,11 +2177,6 @@ function stringifyNumber$5({ format, minFractionDigits, tag, value }) {
|
|
|
2422
2177
|
return n;
|
|
2423
2178
|
}
|
|
2424
2179
|
|
|
2425
|
-
stringifyNumber$6.stringifyNumber = stringifyNumber$5;
|
|
2426
|
-
|
|
2427
|
-
var Scalar$a = Scalar$k;
|
|
2428
|
-
var stringifyNumber$4 = stringifyNumber$6;
|
|
2429
|
-
|
|
2430
2180
|
const floatNaN$1 = {
|
|
2431
2181
|
identify: value => typeof value === 'number',
|
|
2432
2182
|
default: true,
|
|
@@ -2437,7 +2187,7 @@ const floatNaN$1 = {
|
|
|
2437
2187
|
: str[0] === '-'
|
|
2438
2188
|
? Number.NEGATIVE_INFINITY
|
|
2439
2189
|
: Number.POSITIVE_INFINITY,
|
|
2440
|
-
stringify: stringifyNumber
|
|
2190
|
+
stringify: stringifyNumber
|
|
2441
2191
|
};
|
|
2442
2192
|
const floatExp$1 = {
|
|
2443
2193
|
identify: value => typeof value === 'number',
|
|
@@ -2448,39 +2198,31 @@ const floatExp$1 = {
|
|
|
2448
2198
|
resolve: str => parseFloat(str),
|
|
2449
2199
|
stringify(node) {
|
|
2450
2200
|
const num = Number(node.value);
|
|
2451
|
-
return isFinite(num) ? num.toExponential() : stringifyNumber
|
|
2201
|
+
return isFinite(num) ? num.toExponential() : stringifyNumber(node);
|
|
2452
2202
|
}
|
|
2453
2203
|
};
|
|
2454
|
-
const float$
|
|
2204
|
+
const float$1 = {
|
|
2455
2205
|
identify: value => typeof value === 'number',
|
|
2456
2206
|
default: true,
|
|
2457
2207
|
tag: 'tag:yaml.org,2002:float',
|
|
2458
2208
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
2459
2209
|
resolve(str) {
|
|
2460
|
-
const node = new Scalar
|
|
2210
|
+
const node = new Scalar(parseFloat(str));
|
|
2461
2211
|
const dot = str.indexOf('.');
|
|
2462
2212
|
if (dot !== -1 && str[str.length - 1] === '0')
|
|
2463
2213
|
node.minFractionDigits = str.length - dot - 1;
|
|
2464
2214
|
return node;
|
|
2465
2215
|
},
|
|
2466
|
-
stringify: stringifyNumber
|
|
2216
|
+
stringify: stringifyNumber
|
|
2467
2217
|
};
|
|
2468
2218
|
|
|
2469
|
-
float$6.float = float$5;
|
|
2470
|
-
float$6.floatExp = floatExp$1;
|
|
2471
|
-
float$6.floatNaN = floatNaN$1;
|
|
2472
|
-
|
|
2473
|
-
var int$6 = {};
|
|
2474
|
-
|
|
2475
|
-
var stringifyNumber$3 = stringifyNumber$6;
|
|
2476
|
-
|
|
2477
2219
|
const intIdentify$2 = (value) => typeof value === 'bigint' || Number.isInteger(value);
|
|
2478
2220
|
const intResolve$1 = (str, offset, radix, { intAsBigInt }) => (intAsBigInt ? BigInt(str) : parseInt(str.substring(offset), radix));
|
|
2479
2221
|
function intStringify$1(node, radix, prefix) {
|
|
2480
2222
|
const { value } = node;
|
|
2481
2223
|
if (intIdentify$2(value) && value >= 0)
|
|
2482
2224
|
return prefix + value.toString(radix);
|
|
2483
|
-
return stringifyNumber
|
|
2225
|
+
return stringifyNumber(node);
|
|
2484
2226
|
}
|
|
2485
2227
|
const intOct$1 = {
|
|
2486
2228
|
identify: value => intIdentify$2(value) && value >= 0,
|
|
@@ -2491,13 +2233,13 @@ const intOct$1 = {
|
|
|
2491
2233
|
resolve: (str, _onError, opt) => intResolve$1(str, 2, 8, opt),
|
|
2492
2234
|
stringify: node => intStringify$1(node, 8, '0o')
|
|
2493
2235
|
};
|
|
2494
|
-
const int$
|
|
2236
|
+
const int$1 = {
|
|
2495
2237
|
identify: intIdentify$2,
|
|
2496
2238
|
default: true,
|
|
2497
2239
|
tag: 'tag:yaml.org,2002:int',
|
|
2498
2240
|
test: /^[-+]?[0-9]+$/,
|
|
2499
2241
|
resolve: (str, _onError, opt) => intResolve$1(str, 0, 10, opt),
|
|
2500
|
-
stringify: stringifyNumber
|
|
2242
|
+
stringify: stringifyNumber
|
|
2501
2243
|
};
|
|
2502
2244
|
const intHex$1 = {
|
|
2503
2245
|
identify: value => intIdentify$2(value) && value >= 0,
|
|
@@ -2509,42 +2251,20 @@ const intHex$1 = {
|
|
|
2509
2251
|
stringify: node => intStringify$1(node, 16, '0x')
|
|
2510
2252
|
};
|
|
2511
2253
|
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
var int$4 = int$6;
|
|
2525
|
-
|
|
2526
|
-
const schema$7 = [
|
|
2527
|
-
map$4.map,
|
|
2528
|
-
seq$4.seq,
|
|
2529
|
-
string$3.string,
|
|
2530
|
-
_null$2.nullTag,
|
|
2531
|
-
bool$3.boolTag,
|
|
2532
|
-
int$4.intOct,
|
|
2533
|
-
int$4.int,
|
|
2534
|
-
int$4.intHex,
|
|
2535
|
-
float$4.floatNaN,
|
|
2536
|
-
float$4.floatExp,
|
|
2537
|
-
float$4.float
|
|
2254
|
+
const schema$2 = [
|
|
2255
|
+
map,
|
|
2256
|
+
seq,
|
|
2257
|
+
string,
|
|
2258
|
+
nullTag,
|
|
2259
|
+
boolTag,
|
|
2260
|
+
intOct$1,
|
|
2261
|
+
int$1,
|
|
2262
|
+
intHex$1,
|
|
2263
|
+
floatNaN$1,
|
|
2264
|
+
floatExp$1,
|
|
2265
|
+
float$1
|
|
2538
2266
|
];
|
|
2539
2267
|
|
|
2540
|
-
schema$8.schema = schema$7;
|
|
2541
|
-
|
|
2542
|
-
var schema$6 = {};
|
|
2543
|
-
|
|
2544
|
-
var Scalar$9 = Scalar$k;
|
|
2545
|
-
var map$3 = map$6;
|
|
2546
|
-
var seq$3 = seq$6;
|
|
2547
|
-
|
|
2548
2268
|
function intIdentify$1(value) {
|
|
2549
2269
|
return typeof value === 'bigint' || Number.isInteger(value);
|
|
2550
2270
|
}
|
|
@@ -2559,7 +2279,7 @@ const jsonScalars = [
|
|
|
2559
2279
|
},
|
|
2560
2280
|
{
|
|
2561
2281
|
identify: value => value == null,
|
|
2562
|
-
createNode: () => new Scalar
|
|
2282
|
+
createNode: () => new Scalar(null),
|
|
2563
2283
|
default: true,
|
|
2564
2284
|
tag: 'tag:yaml.org,2002:null',
|
|
2565
2285
|
test: /^null$/,
|
|
@@ -2600,16 +2320,9 @@ const jsonError = {
|
|
|
2600
2320
|
return str;
|
|
2601
2321
|
}
|
|
2602
2322
|
};
|
|
2603
|
-
const schema$
|
|
2604
|
-
|
|
2605
|
-
schema$6.schema = schema$5;
|
|
2606
|
-
|
|
2607
|
-
var binary$3 = {};
|
|
2323
|
+
const schema$1 = [map, seq].concat(jsonScalars, jsonError);
|
|
2608
2324
|
|
|
2609
|
-
|
|
2610
|
-
var stringifyString$1 = stringifyString$5;
|
|
2611
|
-
|
|
2612
|
-
const binary$2 = {
|
|
2325
|
+
const binary = {
|
|
2613
2326
|
identify: value => value instanceof Uint8Array,
|
|
2614
2327
|
default: false,
|
|
2615
2328
|
tag: 'tag:yaml.org,2002:binary',
|
|
@@ -2657,41 +2370,30 @@ const binary$2 = {
|
|
|
2657
2370
|
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
|
|
2658
2371
|
}
|
|
2659
2372
|
if (!type)
|
|
2660
|
-
type = Scalar
|
|
2661
|
-
if (type !== Scalar
|
|
2373
|
+
type = Scalar.BLOCK_LITERAL;
|
|
2374
|
+
if (type !== Scalar.QUOTE_DOUBLE) {
|
|
2662
2375
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
2663
2376
|
const n = Math.ceil(str.length / lineWidth);
|
|
2664
2377
|
const lines = new Array(n);
|
|
2665
2378
|
for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
|
|
2666
2379
|
lines[i] = str.substr(o, lineWidth);
|
|
2667
2380
|
}
|
|
2668
|
-
str = lines.join(type === Scalar
|
|
2381
|
+
str = lines.join(type === Scalar.BLOCK_LITERAL ? '\n' : ' ');
|
|
2669
2382
|
}
|
|
2670
|
-
return stringifyString
|
|
2383
|
+
return stringifyString({ comment, type, value: str }, ctx, onComment, onChompKeep);
|
|
2671
2384
|
}
|
|
2672
2385
|
};
|
|
2673
2386
|
|
|
2674
|
-
binary$3.binary = binary$2;
|
|
2675
|
-
|
|
2676
|
-
var omap$3 = {};
|
|
2677
|
-
|
|
2678
|
-
var pairs$4 = {};
|
|
2679
|
-
|
|
2680
|
-
var Node$b = Node$t;
|
|
2681
|
-
var Pair$5 = Pair$9;
|
|
2682
|
-
var Scalar$7 = Scalar$k;
|
|
2683
|
-
var YAMLSeq$4 = YAMLSeq$7;
|
|
2684
|
-
|
|
2685
2387
|
function resolvePairs(seq, onError) {
|
|
2686
|
-
if (
|
|
2388
|
+
if (isSeq(seq)) {
|
|
2687
2389
|
for (let i = 0; i < seq.items.length; ++i) {
|
|
2688
2390
|
let item = seq.items[i];
|
|
2689
|
-
if (
|
|
2391
|
+
if (isPair(item))
|
|
2690
2392
|
continue;
|
|
2691
|
-
else if (
|
|
2393
|
+
else if (isMap(item)) {
|
|
2692
2394
|
if (item.items.length > 1)
|
|
2693
2395
|
onError('Each pair must have its own sequence indicator');
|
|
2694
|
-
const pair = item.items[0] || new Pair
|
|
2396
|
+
const pair = item.items[0] || new Pair(new Scalar(null));
|
|
2695
2397
|
if (item.commentBefore)
|
|
2696
2398
|
pair.key.commentBefore = pair.key.commentBefore
|
|
2697
2399
|
? `${item.commentBefore}\n${pair.key.commentBefore}`
|
|
@@ -2704,7 +2406,7 @@ function resolvePairs(seq, onError) {
|
|
|
2704
2406
|
}
|
|
2705
2407
|
item = pair;
|
|
2706
2408
|
}
|
|
2707
|
-
seq.items[i] =
|
|
2409
|
+
seq.items[i] = isPair(item) ? item : new Pair(item);
|
|
2708
2410
|
}
|
|
2709
2411
|
}
|
|
2710
2412
|
else
|
|
@@ -2713,7 +2415,7 @@ function resolvePairs(seq, onError) {
|
|
|
2713
2415
|
}
|
|
2714
2416
|
function createPairs(schema, iterable, ctx) {
|
|
2715
2417
|
const { replacer } = ctx;
|
|
2716
|
-
const pairs = new YAMLSeq
|
|
2418
|
+
const pairs = new YAMLSeq(schema);
|
|
2717
2419
|
pairs.tag = 'tag:yaml.org,2002:pairs';
|
|
2718
2420
|
let i = 0;
|
|
2719
2421
|
if (iterable && Symbol.iterator in Object(iterable))
|
|
@@ -2741,11 +2443,11 @@ function createPairs(schema, iterable, ctx) {
|
|
|
2741
2443
|
else {
|
|
2742
2444
|
key = it;
|
|
2743
2445
|
}
|
|
2744
|
-
pairs.items.push(
|
|
2446
|
+
pairs.items.push(createPair(key, value, ctx));
|
|
2745
2447
|
}
|
|
2746
2448
|
return pairs;
|
|
2747
2449
|
}
|
|
2748
|
-
const pairs
|
|
2450
|
+
const pairs = {
|
|
2749
2451
|
collection: 'seq',
|
|
2750
2452
|
default: false,
|
|
2751
2453
|
tag: 'tag:yaml.org,2002:pairs',
|
|
@@ -2753,24 +2455,14 @@ const pairs$3 = {
|
|
|
2753
2455
|
createNode: createPairs
|
|
2754
2456
|
};
|
|
2755
2457
|
|
|
2756
|
-
|
|
2757
|
-
pairs$4.pairs = pairs$3;
|
|
2758
|
-
pairs$4.resolvePairs = resolvePairs;
|
|
2759
|
-
|
|
2760
|
-
var YAMLSeq$3 = YAMLSeq$7;
|
|
2761
|
-
var toJS$1 = toJS$6;
|
|
2762
|
-
var Node$a = Node$t;
|
|
2763
|
-
var YAMLMap$4 = YAMLMap$7;
|
|
2764
|
-
var pairs$2 = pairs$4;
|
|
2765
|
-
|
|
2766
|
-
class YAMLOMap extends YAMLSeq$3.YAMLSeq {
|
|
2458
|
+
class YAMLOMap extends YAMLSeq {
|
|
2767
2459
|
constructor() {
|
|
2768
2460
|
super();
|
|
2769
|
-
this.add = YAMLMap
|
|
2770
|
-
this.delete = YAMLMap
|
|
2771
|
-
this.get = YAMLMap
|
|
2772
|
-
this.has = YAMLMap
|
|
2773
|
-
this.set = YAMLMap
|
|
2461
|
+
this.add = YAMLMap.prototype.add.bind(this);
|
|
2462
|
+
this.delete = YAMLMap.prototype.delete.bind(this);
|
|
2463
|
+
this.get = YAMLMap.prototype.get.bind(this);
|
|
2464
|
+
this.has = YAMLMap.prototype.has.bind(this);
|
|
2465
|
+
this.set = YAMLMap.prototype.set.bind(this);
|
|
2774
2466
|
this.tag = YAMLOMap.tag;
|
|
2775
2467
|
}
|
|
2776
2468
|
/**
|
|
@@ -2785,12 +2477,12 @@ class YAMLOMap extends YAMLSeq$3.YAMLSeq {
|
|
|
2785
2477
|
ctx.onCreate(map);
|
|
2786
2478
|
for (const pair of this.items) {
|
|
2787
2479
|
let key, value;
|
|
2788
|
-
if (
|
|
2789
|
-
key = toJS
|
|
2790
|
-
value = toJS
|
|
2480
|
+
if (isPair(pair)) {
|
|
2481
|
+
key = toJS(pair.key, '', ctx);
|
|
2482
|
+
value = toJS(pair.value, key, ctx);
|
|
2791
2483
|
}
|
|
2792
2484
|
else {
|
|
2793
|
-
key = toJS
|
|
2485
|
+
key = toJS(pair, '', ctx);
|
|
2794
2486
|
}
|
|
2795
2487
|
if (map.has(key))
|
|
2796
2488
|
throw new Error('Ordered maps must not include duplicate keys');
|
|
@@ -2800,17 +2492,17 @@ class YAMLOMap extends YAMLSeq$3.YAMLSeq {
|
|
|
2800
2492
|
}
|
|
2801
2493
|
}
|
|
2802
2494
|
YAMLOMap.tag = 'tag:yaml.org,2002:omap';
|
|
2803
|
-
const omap
|
|
2495
|
+
const omap = {
|
|
2804
2496
|
collection: 'seq',
|
|
2805
2497
|
identify: value => value instanceof Map,
|
|
2806
2498
|
nodeClass: YAMLOMap,
|
|
2807
2499
|
default: false,
|
|
2808
2500
|
tag: 'tag:yaml.org,2002:omap',
|
|
2809
2501
|
resolve(seq, onError) {
|
|
2810
|
-
const pairs
|
|
2502
|
+
const pairs = resolvePairs(seq, onError);
|
|
2811
2503
|
const seenKeys = [];
|
|
2812
|
-
for (const { key } of pairs
|
|
2813
|
-
if (
|
|
2504
|
+
for (const { key } of pairs.items) {
|
|
2505
|
+
if (isScalar$1(key)) {
|
|
2814
2506
|
if (seenKeys.includes(key.value)) {
|
|
2815
2507
|
onError(`Ordered maps must not include duplicate keys: ${key.value}`);
|
|
2816
2508
|
}
|
|
@@ -2819,25 +2511,16 @@ const omap$2 = {
|
|
|
2819
2511
|
}
|
|
2820
2512
|
}
|
|
2821
2513
|
}
|
|
2822
|
-
return Object.assign(new YAMLOMap(), pairs
|
|
2514
|
+
return Object.assign(new YAMLOMap(), pairs);
|
|
2823
2515
|
},
|
|
2824
2516
|
createNode(schema, iterable, ctx) {
|
|
2825
|
-
const pairs
|
|
2517
|
+
const pairs = createPairs(schema, iterable, ctx);
|
|
2826
2518
|
const omap = new YAMLOMap();
|
|
2827
|
-
omap.items = pairs
|
|
2519
|
+
omap.items = pairs.items;
|
|
2828
2520
|
return omap;
|
|
2829
2521
|
}
|
|
2830
2522
|
};
|
|
2831
2523
|
|
|
2832
|
-
omap$3.YAMLOMap = YAMLOMap;
|
|
2833
|
-
omap$3.omap = omap$2;
|
|
2834
|
-
|
|
2835
|
-
var schema$4 = {};
|
|
2836
|
-
|
|
2837
|
-
var bool$2 = {};
|
|
2838
|
-
|
|
2839
|
-
var Scalar$6 = Scalar$k;
|
|
2840
|
-
|
|
2841
2524
|
function boolStringify({ value, source }, ctx) {
|
|
2842
2525
|
const boolObj = value ? trueTag : falseTag;
|
|
2843
2526
|
if (source && boolObj.test.test(source))
|
|
@@ -2849,7 +2532,7 @@ const trueTag = {
|
|
|
2849
2532
|
default: true,
|
|
2850
2533
|
tag: 'tag:yaml.org,2002:bool',
|
|
2851
2534
|
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
2852
|
-
resolve: () => new Scalar
|
|
2535
|
+
resolve: () => new Scalar(true),
|
|
2853
2536
|
stringify: boolStringify
|
|
2854
2537
|
};
|
|
2855
2538
|
const falseTag = {
|
|
@@ -2857,18 +2540,10 @@ const falseTag = {
|
|
|
2857
2540
|
default: true,
|
|
2858
2541
|
tag: 'tag:yaml.org,2002:bool',
|
|
2859
2542
|
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
|
|
2860
|
-
resolve: () => new Scalar
|
|
2543
|
+
resolve: () => new Scalar(false),
|
|
2861
2544
|
stringify: boolStringify
|
|
2862
2545
|
};
|
|
2863
2546
|
|
|
2864
|
-
bool$2.falseTag = falseTag;
|
|
2865
|
-
bool$2.trueTag = trueTag;
|
|
2866
|
-
|
|
2867
|
-
var float$3 = {};
|
|
2868
|
-
|
|
2869
|
-
var Scalar$5 = Scalar$k;
|
|
2870
|
-
var stringifyNumber$2 = stringifyNumber$6;
|
|
2871
|
-
|
|
2872
2547
|
const floatNaN = {
|
|
2873
2548
|
identify: value => typeof value === 'number',
|
|
2874
2549
|
default: true,
|
|
@@ -2879,7 +2554,7 @@ const floatNaN = {
|
|
|
2879
2554
|
: str[0] === '-'
|
|
2880
2555
|
? Number.NEGATIVE_INFINITY
|
|
2881
2556
|
: Number.POSITIVE_INFINITY,
|
|
2882
|
-
stringify: stringifyNumber
|
|
2557
|
+
stringify: stringifyNumber
|
|
2883
2558
|
};
|
|
2884
2559
|
const floatExp = {
|
|
2885
2560
|
identify: value => typeof value === 'number',
|
|
@@ -2890,16 +2565,16 @@ const floatExp = {
|
|
|
2890
2565
|
resolve: (str) => parseFloat(str.replace(/_/g, '')),
|
|
2891
2566
|
stringify(node) {
|
|
2892
2567
|
const num = Number(node.value);
|
|
2893
|
-
return isFinite(num) ? num.toExponential() : stringifyNumber
|
|
2568
|
+
return isFinite(num) ? num.toExponential() : stringifyNumber(node);
|
|
2894
2569
|
}
|
|
2895
2570
|
};
|
|
2896
|
-
const float
|
|
2571
|
+
const float = {
|
|
2897
2572
|
identify: value => typeof value === 'number',
|
|
2898
2573
|
default: true,
|
|
2899
2574
|
tag: 'tag:yaml.org,2002:float',
|
|
2900
2575
|
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
2901
2576
|
resolve(str) {
|
|
2902
|
-
const node = new Scalar
|
|
2577
|
+
const node = new Scalar(parseFloat(str.replace(/_/g, '')));
|
|
2903
2578
|
const dot = str.indexOf('.');
|
|
2904
2579
|
if (dot !== -1) {
|
|
2905
2580
|
const f = str.substring(dot + 1).replace(/_/g, '');
|
|
@@ -2908,17 +2583,9 @@ const float$2 = {
|
|
|
2908
2583
|
}
|
|
2909
2584
|
return node;
|
|
2910
2585
|
},
|
|
2911
|
-
stringify: stringifyNumber
|
|
2586
|
+
stringify: stringifyNumber
|
|
2912
2587
|
};
|
|
2913
2588
|
|
|
2914
|
-
float$3.float = float$2;
|
|
2915
|
-
float$3.floatExp = floatExp;
|
|
2916
|
-
float$3.floatNaN = floatNaN;
|
|
2917
|
-
|
|
2918
|
-
var int$3 = {};
|
|
2919
|
-
|
|
2920
|
-
var stringifyNumber$1 = stringifyNumber$6;
|
|
2921
|
-
|
|
2922
2589
|
const intIdentify = (value) => typeof value === 'bigint' || Number.isInteger(value);
|
|
2923
2590
|
function intResolve(str, offset, radix, { intAsBigInt }) {
|
|
2924
2591
|
const sign = str[0];
|
|
@@ -2949,7 +2616,7 @@ function intStringify(node, radix, prefix) {
|
|
|
2949
2616
|
const str = value.toString(radix);
|
|
2950
2617
|
return value < 0 ? '-' + prefix + str.substr(1) : prefix + str;
|
|
2951
2618
|
}
|
|
2952
|
-
return stringifyNumber
|
|
2619
|
+
return stringifyNumber(node);
|
|
2953
2620
|
}
|
|
2954
2621
|
const intBin = {
|
|
2955
2622
|
identify: intIdentify,
|
|
@@ -2969,13 +2636,13 @@ const intOct = {
|
|
|
2969
2636
|
resolve: (str, _onError, opt) => intResolve(str, 1, 8, opt),
|
|
2970
2637
|
stringify: node => intStringify(node, 8, '0')
|
|
2971
2638
|
};
|
|
2972
|
-
const int
|
|
2639
|
+
const int = {
|
|
2973
2640
|
identify: intIdentify,
|
|
2974
2641
|
default: true,
|
|
2975
2642
|
tag: 'tag:yaml.org,2002:int',
|
|
2976
2643
|
test: /^[-+]?[0-9][0-9_]*$/,
|
|
2977
2644
|
resolve: (str, _onError, opt) => intResolve(str, 0, 10, opt),
|
|
2978
|
-
stringify: stringifyNumber
|
|
2645
|
+
stringify: stringifyNumber
|
|
2979
2646
|
};
|
|
2980
2647
|
const intHex = {
|
|
2981
2648
|
identify: intIdentify,
|
|
@@ -2987,34 +2654,23 @@ const intHex = {
|
|
|
2987
2654
|
stringify: node => intStringify(node, 16, '0x')
|
|
2988
2655
|
};
|
|
2989
2656
|
|
|
2990
|
-
|
|
2991
|
-
int$3.intBin = intBin;
|
|
2992
|
-
int$3.intHex = intHex;
|
|
2993
|
-
int$3.intOct = intOct;
|
|
2994
|
-
|
|
2995
|
-
var set$3 = {};
|
|
2996
|
-
|
|
2997
|
-
var Node$9 = Node$t;
|
|
2998
|
-
var Pair$4 = Pair$9;
|
|
2999
|
-
var YAMLMap$3 = YAMLMap$7;
|
|
3000
|
-
|
|
3001
|
-
class YAMLSet extends YAMLMap$3.YAMLMap {
|
|
2657
|
+
class YAMLSet extends YAMLMap {
|
|
3002
2658
|
constructor(schema) {
|
|
3003
2659
|
super(schema);
|
|
3004
2660
|
this.tag = YAMLSet.tag;
|
|
3005
2661
|
}
|
|
3006
2662
|
add(key) {
|
|
3007
2663
|
let pair;
|
|
3008
|
-
if (
|
|
2664
|
+
if (isPair(key))
|
|
3009
2665
|
pair = key;
|
|
3010
2666
|
else if (typeof key === 'object' &&
|
|
3011
2667
|
'key' in key &&
|
|
3012
2668
|
'value' in key &&
|
|
3013
2669
|
key.value === null)
|
|
3014
|
-
pair = new Pair
|
|
2670
|
+
pair = new Pair(key.key, null);
|
|
3015
2671
|
else
|
|
3016
|
-
pair = new Pair
|
|
3017
|
-
const prev =
|
|
2672
|
+
pair = new Pair(key, null);
|
|
2673
|
+
const prev = findPair(this.items, pair.key);
|
|
3018
2674
|
if (!prev)
|
|
3019
2675
|
this.items.push(pair);
|
|
3020
2676
|
}
|
|
@@ -3023,9 +2679,9 @@ class YAMLSet extends YAMLMap$3.YAMLMap {
|
|
|
3023
2679
|
* Otherwise, returns the value of that Pair's key.
|
|
3024
2680
|
*/
|
|
3025
2681
|
get(key, keepPair) {
|
|
3026
|
-
const pair =
|
|
3027
|
-
return !keepPair &&
|
|
3028
|
-
?
|
|
2682
|
+
const pair = findPair(this.items, key);
|
|
2683
|
+
return !keepPair && isPair(pair)
|
|
2684
|
+
? isScalar$1(pair.key)
|
|
3029
2685
|
? pair.key.value
|
|
3030
2686
|
: pair.key
|
|
3031
2687
|
: pair;
|
|
@@ -3033,12 +2689,12 @@ class YAMLSet extends YAMLMap$3.YAMLMap {
|
|
|
3033
2689
|
set(key, value) {
|
|
3034
2690
|
if (typeof value !== 'boolean')
|
|
3035
2691
|
throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`);
|
|
3036
|
-
const prev =
|
|
2692
|
+
const prev = findPair(this.items, key);
|
|
3037
2693
|
if (prev && !value) {
|
|
3038
2694
|
this.items.splice(this.items.indexOf(prev), 1);
|
|
3039
2695
|
}
|
|
3040
2696
|
else if (!prev && value) {
|
|
3041
|
-
this.items.push(new Pair
|
|
2697
|
+
this.items.push(new Pair(key));
|
|
3042
2698
|
}
|
|
3043
2699
|
}
|
|
3044
2700
|
toJSON(_, ctx) {
|
|
@@ -3054,14 +2710,14 @@ class YAMLSet extends YAMLMap$3.YAMLMap {
|
|
|
3054
2710
|
}
|
|
3055
2711
|
}
|
|
3056
2712
|
YAMLSet.tag = 'tag:yaml.org,2002:set';
|
|
3057
|
-
const set
|
|
2713
|
+
const set = {
|
|
3058
2714
|
collection: 'map',
|
|
3059
2715
|
identify: value => value instanceof Set,
|
|
3060
2716
|
nodeClass: YAMLSet,
|
|
3061
2717
|
default: false,
|
|
3062
2718
|
tag: 'tag:yaml.org,2002:set',
|
|
3063
2719
|
resolve(map, onError) {
|
|
3064
|
-
if (
|
|
2720
|
+
if (isMap(map)) {
|
|
3065
2721
|
if (map.hasAllNullValues(true))
|
|
3066
2722
|
return Object.assign(new YAMLSet(), map);
|
|
3067
2723
|
else
|
|
@@ -3078,19 +2734,12 @@ const set$2 = {
|
|
|
3078
2734
|
for (let value of iterable) {
|
|
3079
2735
|
if (typeof replacer === 'function')
|
|
3080
2736
|
value = replacer.call(iterable, value, value);
|
|
3081
|
-
set.items.push(
|
|
2737
|
+
set.items.push(createPair(value, null, ctx));
|
|
3082
2738
|
}
|
|
3083
2739
|
return set;
|
|
3084
2740
|
}
|
|
3085
2741
|
};
|
|
3086
2742
|
|
|
3087
|
-
set$3.YAMLSet = YAMLSet;
|
|
3088
|
-
set$3.set = set$2;
|
|
3089
|
-
|
|
3090
|
-
var timestamp$3 = {};
|
|
3091
|
-
|
|
3092
|
-
var stringifyNumber = stringifyNumber$6;
|
|
3093
|
-
|
|
3094
2743
|
/** Internal types handle bigint as number, because TS can't figure it out. */
|
|
3095
2744
|
function parseSexagesimal(str, asBigInt) {
|
|
3096
2745
|
const sign = str[0];
|
|
@@ -3113,7 +2762,7 @@ function stringifySexagesimal(node) {
|
|
|
3113
2762
|
if (typeof value === 'bigint')
|
|
3114
2763
|
num = n => BigInt(n);
|
|
3115
2764
|
else if (isNaN(value) || !isFinite(value))
|
|
3116
|
-
return stringifyNumber
|
|
2765
|
+
return stringifyNumber(node);
|
|
3117
2766
|
let sign = '';
|
|
3118
2767
|
if (value < 0) {
|
|
3119
2768
|
sign = '-';
|
|
@@ -3157,7 +2806,7 @@ const floatTime = {
|
|
|
3157
2806
|
resolve: str => parseSexagesimal(str, false),
|
|
3158
2807
|
stringify: stringifySexagesimal
|
|
3159
2808
|
};
|
|
3160
|
-
const timestamp
|
|
2809
|
+
const timestamp = {
|
|
3161
2810
|
identify: value => value instanceof Date,
|
|
3162
2811
|
default: true,
|
|
3163
2812
|
tag: 'tag:yaml.org,2002:timestamp',
|
|
@@ -3171,7 +2820,7 @@ const timestamp$2 = {
|
|
|
3171
2820
|
'(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30
|
|
3172
2821
|
')?$'),
|
|
3173
2822
|
resolve(str) {
|
|
3174
|
-
const match = str.match(timestamp
|
|
2823
|
+
const match = str.match(timestamp.test);
|
|
3175
2824
|
if (!match)
|
|
3176
2825
|
throw new Error('!!timestamp expects a date, starting with yyyy-mm-dd');
|
|
3177
2826
|
const [, year, month, day, hour, minute, second] = match.map(Number);
|
|
@@ -3189,96 +2838,61 @@ const timestamp$2 = {
|
|
|
3189
2838
|
stringify: ({ value }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
|
|
3190
2839
|
};
|
|
3191
2840
|
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
_null$1.nullTag,
|
|
3214
|
-
bool$1.trueTag,
|
|
3215
|
-
bool$1.falseTag,
|
|
3216
|
-
int$1.intBin,
|
|
3217
|
-
int$1.intOct,
|
|
3218
|
-
int$1.int,
|
|
3219
|
-
int$1.intHex,
|
|
3220
|
-
float$1.floatNaN,
|
|
3221
|
-
float$1.floatExp,
|
|
3222
|
-
float$1.float,
|
|
3223
|
-
binary$1.binary,
|
|
3224
|
-
omap$1.omap,
|
|
3225
|
-
pairs$1.pairs,
|
|
3226
|
-
set$1.set,
|
|
3227
|
-
timestamp$1.intTime,
|
|
3228
|
-
timestamp$1.floatTime,
|
|
3229
|
-
timestamp$1.timestamp
|
|
2841
|
+
const schema = [
|
|
2842
|
+
map,
|
|
2843
|
+
seq,
|
|
2844
|
+
string,
|
|
2845
|
+
nullTag,
|
|
2846
|
+
trueTag,
|
|
2847
|
+
falseTag,
|
|
2848
|
+
intBin,
|
|
2849
|
+
intOct,
|
|
2850
|
+
int,
|
|
2851
|
+
intHex,
|
|
2852
|
+
floatNaN,
|
|
2853
|
+
floatExp,
|
|
2854
|
+
float,
|
|
2855
|
+
binary,
|
|
2856
|
+
omap,
|
|
2857
|
+
pairs,
|
|
2858
|
+
set,
|
|
2859
|
+
intTime,
|
|
2860
|
+
floatTime,
|
|
2861
|
+
timestamp
|
|
3230
2862
|
];
|
|
3231
2863
|
|
|
3232
|
-
schema$4.schema = schema$3;
|
|
3233
|
-
|
|
3234
|
-
var map$1 = map$6;
|
|
3235
|
-
var _null = _null$3;
|
|
3236
|
-
var seq$1 = seq$6;
|
|
3237
|
-
var string$1 = string$5;
|
|
3238
|
-
var bool = bool$4;
|
|
3239
|
-
var float = float$6;
|
|
3240
|
-
var int = int$6;
|
|
3241
|
-
var schema = schema$8;
|
|
3242
|
-
var schema$1 = schema$6;
|
|
3243
|
-
var binary = binary$3;
|
|
3244
|
-
var omap = omap$3;
|
|
3245
|
-
var pairs = pairs$4;
|
|
3246
|
-
var schema$2 = schema$4;
|
|
3247
|
-
var set = set$3;
|
|
3248
|
-
var timestamp = timestamp$3;
|
|
3249
|
-
|
|
3250
2864
|
const schemas = new Map([
|
|
3251
|
-
['core', schema
|
|
3252
|
-
['failsafe', [map
|
|
3253
|
-
['json', schema$1
|
|
3254
|
-
['yaml11', schema
|
|
3255
|
-
['yaml-1.1', schema
|
|
2865
|
+
['core', schema$2],
|
|
2866
|
+
['failsafe', [map, seq, string]],
|
|
2867
|
+
['json', schema$1],
|
|
2868
|
+
['yaml11', schema],
|
|
2869
|
+
['yaml-1.1', schema]
|
|
3256
2870
|
]);
|
|
3257
2871
|
const tagsByName = {
|
|
3258
|
-
binary
|
|
3259
|
-
bool:
|
|
3260
|
-
float: float
|
|
3261
|
-
floatExp:
|
|
3262
|
-
floatNaN:
|
|
3263
|
-
floatTime
|
|
3264
|
-
int: int
|
|
3265
|
-
intHex:
|
|
3266
|
-
intOct:
|
|
3267
|
-
intTime
|
|
3268
|
-
map
|
|
3269
|
-
null:
|
|
3270
|
-
omap
|
|
3271
|
-
pairs
|
|
3272
|
-
seq
|
|
3273
|
-
set
|
|
3274
|
-
timestamp
|
|
2872
|
+
binary,
|
|
2873
|
+
bool: boolTag,
|
|
2874
|
+
float: float$1,
|
|
2875
|
+
floatExp: floatExp$1,
|
|
2876
|
+
floatNaN: floatNaN$1,
|
|
2877
|
+
floatTime,
|
|
2878
|
+
int: int$1,
|
|
2879
|
+
intHex: intHex$1,
|
|
2880
|
+
intOct: intOct$1,
|
|
2881
|
+
intTime,
|
|
2882
|
+
map,
|
|
2883
|
+
null: nullTag,
|
|
2884
|
+
omap,
|
|
2885
|
+
pairs,
|
|
2886
|
+
seq,
|
|
2887
|
+
set,
|
|
2888
|
+
timestamp
|
|
3275
2889
|
};
|
|
3276
2890
|
const coreKnownTags = {
|
|
3277
|
-
'tag:yaml.org,2002:binary': binary
|
|
3278
|
-
'tag:yaml.org,2002:omap': omap
|
|
3279
|
-
'tag:yaml.org,2002:pairs': pairs
|
|
3280
|
-
'tag:yaml.org,2002:set': set
|
|
3281
|
-
'tag:yaml.org,2002:timestamp': timestamp
|
|
2891
|
+
'tag:yaml.org,2002:binary': binary,
|
|
2892
|
+
'tag:yaml.org,2002:omap': omap,
|
|
2893
|
+
'tag:yaml.org,2002:pairs': pairs,
|
|
2894
|
+
'tag:yaml.org,2002:set': set,
|
|
2895
|
+
'tag:yaml.org,2002:timestamp': timestamp
|
|
3282
2896
|
};
|
|
3283
2897
|
function getTags(customTags, schemaName) {
|
|
3284
2898
|
let tags = schemas.get(schemaName);
|
|
@@ -3313,31 +2927,22 @@ function getTags(customTags, schemaName) {
|
|
|
3313
2927
|
});
|
|
3314
2928
|
}
|
|
3315
2929
|
|
|
3316
|
-
tags$1.coreKnownTags = coreKnownTags;
|
|
3317
|
-
tags$1.getTags = getTags;
|
|
3318
|
-
|
|
3319
|
-
var Node$8 = Node$t;
|
|
3320
|
-
var map = map$6;
|
|
3321
|
-
var seq = seq$6;
|
|
3322
|
-
var string = string$5;
|
|
3323
|
-
var tags = tags$1;
|
|
3324
|
-
|
|
3325
2930
|
const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
3326
|
-
class Schema
|
|
2931
|
+
class Schema {
|
|
3327
2932
|
constructor({ compat, customTags, merge, resolveKnownTags, schema, sortMapEntries, toStringDefaults }) {
|
|
3328
2933
|
this.compat = Array.isArray(compat)
|
|
3329
|
-
?
|
|
2934
|
+
? getTags(compat, 'compat')
|
|
3330
2935
|
: compat
|
|
3331
|
-
?
|
|
2936
|
+
? getTags(null, compat)
|
|
3332
2937
|
: null;
|
|
3333
2938
|
this.merge = !!merge;
|
|
3334
2939
|
this.name = (typeof schema === 'string' && schema) || 'core';
|
|
3335
|
-
this.knownTags = resolveKnownTags ?
|
|
3336
|
-
this.tags =
|
|
2940
|
+
this.knownTags = resolveKnownTags ? coreKnownTags : {};
|
|
2941
|
+
this.tags = getTags(customTags, this.name);
|
|
3337
2942
|
this.toStringOptions = toStringDefaults ?? null;
|
|
3338
|
-
Object.defineProperty(this,
|
|
3339
|
-
Object.defineProperty(this,
|
|
3340
|
-
Object.defineProperty(this,
|
|
2943
|
+
Object.defineProperty(this, MAP, { value: map });
|
|
2944
|
+
Object.defineProperty(this, SCALAR$1, { value: string });
|
|
2945
|
+
Object.defineProperty(this, SEQ, { value: seq });
|
|
3341
2946
|
// Used by createMap()
|
|
3342
2947
|
this.sortMapEntries =
|
|
3343
2948
|
typeof sortMapEntries === 'function'
|
|
@@ -3347,21 +2952,13 @@ class Schema$2 {
|
|
|
3347
2952
|
: null;
|
|
3348
2953
|
}
|
|
3349
2954
|
clone() {
|
|
3350
|
-
const copy = Object.create(Schema
|
|
2955
|
+
const copy = Object.create(Schema.prototype, Object.getOwnPropertyDescriptors(this));
|
|
3351
2956
|
copy.tags = this.tags.slice();
|
|
3352
2957
|
return copy;
|
|
3353
2958
|
}
|
|
3354
2959
|
}
|
|
3355
2960
|
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
var stringifyDocument$2 = {};
|
|
3359
|
-
|
|
3360
|
-
var Node$7 = Node$t;
|
|
3361
|
-
var stringify$4 = stringify$9;
|
|
3362
|
-
var stringifyComment = stringifyComment$5;
|
|
3363
|
-
|
|
3364
|
-
function stringifyDocument$1(doc, options) {
|
|
2961
|
+
function stringifyDocument(doc, options) {
|
|
3365
2962
|
const lines = [];
|
|
3366
2963
|
let hasDirectives = options.directives === true;
|
|
3367
2964
|
if (options.directives !== false && doc.directives) {
|
|
@@ -3375,32 +2972,32 @@ function stringifyDocument$1(doc, options) {
|
|
|
3375
2972
|
}
|
|
3376
2973
|
if (hasDirectives)
|
|
3377
2974
|
lines.push('---');
|
|
3378
|
-
const ctx =
|
|
2975
|
+
const ctx = createStringifyContext(doc, options);
|
|
3379
2976
|
const { commentString } = ctx.options;
|
|
3380
2977
|
if (doc.commentBefore) {
|
|
3381
2978
|
if (lines.length !== 1)
|
|
3382
2979
|
lines.unshift('');
|
|
3383
2980
|
const cs = commentString(doc.commentBefore);
|
|
3384
|
-
lines.unshift(
|
|
2981
|
+
lines.unshift(indentComment(cs, ''));
|
|
3385
2982
|
}
|
|
3386
2983
|
let chompKeep = false;
|
|
3387
2984
|
let contentComment = null;
|
|
3388
2985
|
if (doc.contents) {
|
|
3389
|
-
if (
|
|
2986
|
+
if (isNode(doc.contents)) {
|
|
3390
2987
|
if (doc.contents.spaceBefore && hasDirectives)
|
|
3391
2988
|
lines.push('');
|
|
3392
2989
|
if (doc.contents.commentBefore) {
|
|
3393
2990
|
const cs = commentString(doc.contents.commentBefore);
|
|
3394
|
-
lines.push(
|
|
2991
|
+
lines.push(indentComment(cs, ''));
|
|
3395
2992
|
}
|
|
3396
2993
|
// top-level block scalars need to be indented if followed by a comment
|
|
3397
2994
|
ctx.forceBlockIndent = !!doc.comment;
|
|
3398
2995
|
contentComment = doc.contents.comment;
|
|
3399
2996
|
}
|
|
3400
2997
|
const onChompKeep = contentComment ? undefined : () => (chompKeep = true);
|
|
3401
|
-
let body = stringify$
|
|
2998
|
+
let body = stringify$2(doc.contents, ctx, () => (contentComment = null), onChompKeep);
|
|
3402
2999
|
if (contentComment)
|
|
3403
|
-
body +=
|
|
3000
|
+
body += lineComment(body, '', commentString(contentComment));
|
|
3404
3001
|
if ((body[0] === '|' || body[0] === '>') &&
|
|
3405
3002
|
lines[lines.length - 1] === '---') {
|
|
3406
3003
|
// Top-level block scalars with a preceding doc marker ought to use the
|
|
@@ -3411,14 +3008,14 @@ function stringifyDocument$1(doc, options) {
|
|
|
3411
3008
|
lines.push(body);
|
|
3412
3009
|
}
|
|
3413
3010
|
else {
|
|
3414
|
-
lines.push(stringify$
|
|
3011
|
+
lines.push(stringify$2(doc.contents, ctx));
|
|
3415
3012
|
}
|
|
3416
3013
|
if (doc.directives?.docEnd) {
|
|
3417
3014
|
if (doc.comment) {
|
|
3418
3015
|
const cs = commentString(doc.comment);
|
|
3419
3016
|
if (cs.includes('\n')) {
|
|
3420
3017
|
lines.push('...');
|
|
3421
|
-
lines.push(
|
|
3018
|
+
lines.push(indentComment(cs, ''));
|
|
3422
3019
|
}
|
|
3423
3020
|
else {
|
|
3424
3021
|
lines.push(`... ${cs}`);
|
|
@@ -3435,16 +3032,12 @@ function stringifyDocument$1(doc, options) {
|
|
|
3435
3032
|
if (dc) {
|
|
3436
3033
|
if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '')
|
|
3437
3034
|
lines.push('');
|
|
3438
|
-
lines.push(
|
|
3035
|
+
lines.push(indentComment(commentString(dc), ''));
|
|
3439
3036
|
}
|
|
3440
3037
|
}
|
|
3441
3038
|
return lines.join('\n') + '\n';
|
|
3442
3039
|
}
|
|
3443
3040
|
|
|
3444
|
-
stringifyDocument$2.stringifyDocument = stringifyDocument$1;
|
|
3445
|
-
|
|
3446
|
-
var applyReviver$2 = {};
|
|
3447
|
-
|
|
3448
3041
|
/**
|
|
3449
3042
|
* Applies the JSON.parse reviver algorithm as defined in the ECMA-262 spec,
|
|
3450
3043
|
* in section 24.5.1.1 "Runtime Semantics: InternalizeJSONProperty" of the
|
|
@@ -3452,12 +3045,12 @@ var applyReviver$2 = {};
|
|
|
3452
3045
|
*
|
|
3453
3046
|
* Includes extensions for handling Map and Set objects.
|
|
3454
3047
|
*/
|
|
3455
|
-
function applyReviver
|
|
3048
|
+
function applyReviver(reviver, obj, key, val) {
|
|
3456
3049
|
if (val && typeof val === 'object') {
|
|
3457
3050
|
if (Array.isArray(val)) {
|
|
3458
3051
|
for (let i = 0, len = val.length; i < len; ++i) {
|
|
3459
3052
|
const v0 = val[i];
|
|
3460
|
-
const v1 = applyReviver
|
|
3053
|
+
const v1 = applyReviver(reviver, val, String(i), v0);
|
|
3461
3054
|
if (v1 === undefined)
|
|
3462
3055
|
delete val[i];
|
|
3463
3056
|
else if (v1 !== v0)
|
|
@@ -3467,7 +3060,7 @@ function applyReviver$1(reviver, obj, key, val) {
|
|
|
3467
3060
|
else if (val instanceof Map) {
|
|
3468
3061
|
for (const k of Array.from(val.keys())) {
|
|
3469
3062
|
const v0 = val.get(k);
|
|
3470
|
-
const v1 = applyReviver
|
|
3063
|
+
const v1 = applyReviver(reviver, val, k, v0);
|
|
3471
3064
|
if (v1 === undefined)
|
|
3472
3065
|
val.delete(k);
|
|
3473
3066
|
else if (v1 !== v0)
|
|
@@ -3476,7 +3069,7 @@ function applyReviver$1(reviver, obj, key, val) {
|
|
|
3476
3069
|
}
|
|
3477
3070
|
else if (val instanceof Set) {
|
|
3478
3071
|
for (const v0 of Array.from(val)) {
|
|
3479
|
-
const v1 = applyReviver
|
|
3072
|
+
const v1 = applyReviver(reviver, val, v0, v0);
|
|
3480
3073
|
if (v1 === undefined)
|
|
3481
3074
|
val.delete(v0);
|
|
3482
3075
|
else if (v1 !== v0) {
|
|
@@ -3487,7 +3080,7 @@ function applyReviver$1(reviver, obj, key, val) {
|
|
|
3487
3080
|
}
|
|
3488
3081
|
else {
|
|
3489
3082
|
for (const [k, v0] of Object.entries(val)) {
|
|
3490
|
-
const v1 = applyReviver
|
|
3083
|
+
const v1 = applyReviver(reviver, val, k, v0);
|
|
3491
3084
|
if (v1 === undefined)
|
|
3492
3085
|
delete val[k];
|
|
3493
3086
|
else if (v1 !== v0)
|
|
@@ -3498,22 +3091,7 @@ function applyReviver$1(reviver, obj, key, val) {
|
|
|
3498
3091
|
return reviver.call(obj, key, val);
|
|
3499
3092
|
}
|
|
3500
3093
|
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
var Alias$2 = Alias$5;
|
|
3504
|
-
var Collection = Collection$5;
|
|
3505
|
-
var Node$6 = Node$t;
|
|
3506
|
-
var Pair$3 = Pair$9;
|
|
3507
|
-
var toJS = toJS$6;
|
|
3508
|
-
var Schema$1 = Schema$3;
|
|
3509
|
-
var stringify$3 = stringify$9;
|
|
3510
|
-
var stringifyDocument = stringifyDocument$2;
|
|
3511
|
-
var anchors = anchors$3;
|
|
3512
|
-
var applyReviver = applyReviver$2;
|
|
3513
|
-
var createNode = createNode$5;
|
|
3514
|
-
var directives$1 = directives$2;
|
|
3515
|
-
|
|
3516
|
-
class Document$4 {
|
|
3094
|
+
class Document {
|
|
3517
3095
|
constructor(value, replacer, options) {
|
|
3518
3096
|
/** A comment before this Document */
|
|
3519
3097
|
this.commentBefore = null;
|
|
@@ -3523,7 +3101,7 @@ class Document$4 {
|
|
|
3523
3101
|
this.errors = [];
|
|
3524
3102
|
/** Warnings encountered during parsing. */
|
|
3525
3103
|
this.warnings = [];
|
|
3526
|
-
Object.defineProperty(this,
|
|
3104
|
+
Object.defineProperty(this, NODE_TYPE, { value: DOC });
|
|
3527
3105
|
let _replacer = null;
|
|
3528
3106
|
if (typeof replacer === 'function' || Array.isArray(replacer)) {
|
|
3529
3107
|
_replacer = replacer;
|
|
@@ -3549,7 +3127,7 @@ class Document$4 {
|
|
|
3549
3127
|
version = this.directives.yaml.version;
|
|
3550
3128
|
}
|
|
3551
3129
|
else
|
|
3552
|
-
this.directives = new
|
|
3130
|
+
this.directives = new Directives({ version });
|
|
3553
3131
|
this.setSchema(version, options);
|
|
3554
3132
|
if (value === undefined)
|
|
3555
3133
|
this.contents = null;
|
|
@@ -3563,8 +3141,8 @@ class Document$4 {
|
|
|
3563
3141
|
* Custom Node values that inherit from `Object` still refer to their original instances.
|
|
3564
3142
|
*/
|
|
3565
3143
|
clone() {
|
|
3566
|
-
const copy = Object.create(Document
|
|
3567
|
-
[
|
|
3144
|
+
const copy = Object.create(Document.prototype, {
|
|
3145
|
+
[NODE_TYPE]: { value: DOC }
|
|
3568
3146
|
});
|
|
3569
3147
|
copy.commentBefore = this.commentBefore;
|
|
3570
3148
|
copy.comment = this.comment;
|
|
@@ -3574,7 +3152,7 @@ class Document$4 {
|
|
|
3574
3152
|
if (this.directives)
|
|
3575
3153
|
copy.directives = this.directives.clone();
|
|
3576
3154
|
copy.schema = this.schema.clone();
|
|
3577
|
-
copy.contents =
|
|
3155
|
+
copy.contents = isNode(this.contents)
|
|
3578
3156
|
? this.contents.clone(copy.schema)
|
|
3579
3157
|
: this.contents;
|
|
3580
3158
|
if (this.range)
|
|
@@ -3602,12 +3180,12 @@ class Document$4 {
|
|
|
3602
3180
|
*/
|
|
3603
3181
|
createAlias(node, name) {
|
|
3604
3182
|
if (!node.anchor) {
|
|
3605
|
-
const prev =
|
|
3183
|
+
const prev = anchorNames(this);
|
|
3606
3184
|
node.anchor =
|
|
3607
3185
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
3608
|
-
!name || prev.has(name) ?
|
|
3186
|
+
!name || prev.has(name) ? findNewAnchor(name || 'a', prev) : name;
|
|
3609
3187
|
}
|
|
3610
|
-
return new Alias
|
|
3188
|
+
return new Alias(node.anchor);
|
|
3611
3189
|
}
|
|
3612
3190
|
createNode(value, replacer, options) {
|
|
3613
3191
|
let _replacer = undefined;
|
|
@@ -3627,7 +3205,7 @@ class Document$4 {
|
|
|
3627
3205
|
replacer = undefined;
|
|
3628
3206
|
}
|
|
3629
3207
|
const { aliasDuplicateObjects, anchorPrefix, flow, keepUndefined, onTagObj, tag } = options ?? {};
|
|
3630
|
-
const { onAnchor, setAnchors, sourceObjects } =
|
|
3208
|
+
const { onAnchor, setAnchors, sourceObjects } = createNodeAnchors(this,
|
|
3631
3209
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
3632
3210
|
anchorPrefix || 'a');
|
|
3633
3211
|
const ctx = {
|
|
@@ -3639,8 +3217,8 @@ class Document$4 {
|
|
|
3639
3217
|
schema: this.schema,
|
|
3640
3218
|
sourceObjects
|
|
3641
3219
|
};
|
|
3642
|
-
const node = createNode
|
|
3643
|
-
if (flow &&
|
|
3220
|
+
const node = createNode(value, tag, ctx);
|
|
3221
|
+
if (flow && isCollection$1(node))
|
|
3644
3222
|
node.flow = true;
|
|
3645
3223
|
setAnchors();
|
|
3646
3224
|
return node;
|
|
@@ -3652,7 +3230,7 @@ class Document$4 {
|
|
|
3652
3230
|
createPair(key, value, options = {}) {
|
|
3653
3231
|
const k = this.createNode(key, null, options);
|
|
3654
3232
|
const v = this.createNode(value, null, options);
|
|
3655
|
-
return new Pair
|
|
3233
|
+
return new Pair(k, v);
|
|
3656
3234
|
}
|
|
3657
3235
|
/**
|
|
3658
3236
|
* Removes a value from the document.
|
|
@@ -3666,7 +3244,7 @@ class Document$4 {
|
|
|
3666
3244
|
* @returns `true` if the item was found and removed.
|
|
3667
3245
|
*/
|
|
3668
3246
|
deleteIn(path) {
|
|
3669
|
-
if (
|
|
3247
|
+
if (isEmptyPath(path)) {
|
|
3670
3248
|
if (this.contents == null)
|
|
3671
3249
|
return false;
|
|
3672
3250
|
this.contents = null;
|
|
@@ -3682,7 +3260,7 @@ class Document$4 {
|
|
|
3682
3260
|
* `true` (collections are always returned intact).
|
|
3683
3261
|
*/
|
|
3684
3262
|
get(key, keepScalar) {
|
|
3685
|
-
return
|
|
3263
|
+
return isCollection$1(this.contents)
|
|
3686
3264
|
? this.contents.get(key, keepScalar)
|
|
3687
3265
|
: undefined;
|
|
3688
3266
|
}
|
|
@@ -3692,11 +3270,11 @@ class Document$4 {
|
|
|
3692
3270
|
* `true` (collections are always returned intact).
|
|
3693
3271
|
*/
|
|
3694
3272
|
getIn(path, keepScalar) {
|
|
3695
|
-
if (
|
|
3696
|
-
return !keepScalar &&
|
|
3273
|
+
if (isEmptyPath(path))
|
|
3274
|
+
return !keepScalar && isScalar$1(this.contents)
|
|
3697
3275
|
? this.contents.value
|
|
3698
3276
|
: this.contents;
|
|
3699
|
-
return
|
|
3277
|
+
return isCollection$1(this.contents)
|
|
3700
3278
|
? this.contents.getIn(path, keepScalar)
|
|
3701
3279
|
: undefined;
|
|
3702
3280
|
}
|
|
@@ -3704,15 +3282,15 @@ class Document$4 {
|
|
|
3704
3282
|
* Checks if the document includes a value with the key `key`.
|
|
3705
3283
|
*/
|
|
3706
3284
|
has(key) {
|
|
3707
|
-
return
|
|
3285
|
+
return isCollection$1(this.contents) ? this.contents.has(key) : false;
|
|
3708
3286
|
}
|
|
3709
3287
|
/**
|
|
3710
3288
|
* Checks if the document includes a value at `path`.
|
|
3711
3289
|
*/
|
|
3712
3290
|
hasIn(path) {
|
|
3713
|
-
if (
|
|
3291
|
+
if (isEmptyPath(path))
|
|
3714
3292
|
return this.contents !== undefined;
|
|
3715
|
-
return
|
|
3293
|
+
return isCollection$1(this.contents) ? this.contents.hasIn(path) : false;
|
|
3716
3294
|
}
|
|
3717
3295
|
/**
|
|
3718
3296
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -3720,7 +3298,7 @@ class Document$4 {
|
|
|
3720
3298
|
*/
|
|
3721
3299
|
set(key, value) {
|
|
3722
3300
|
if (this.contents == null) {
|
|
3723
|
-
this.contents =
|
|
3301
|
+
this.contents = collectionFromPath(this.schema, [key], value);
|
|
3724
3302
|
}
|
|
3725
3303
|
else if (assertCollection(this.contents)) {
|
|
3726
3304
|
this.contents.set(key, value);
|
|
@@ -3731,10 +3309,10 @@ class Document$4 {
|
|
|
3731
3309
|
* boolean to add/remove the item from the set.
|
|
3732
3310
|
*/
|
|
3733
3311
|
setIn(path, value) {
|
|
3734
|
-
if (
|
|
3312
|
+
if (isEmptyPath(path))
|
|
3735
3313
|
this.contents = value;
|
|
3736
3314
|
else if (this.contents == null) {
|
|
3737
|
-
this.contents =
|
|
3315
|
+
this.contents = collectionFromPath(this.schema, Array.from(path), value);
|
|
3738
3316
|
}
|
|
3739
3317
|
else if (assertCollection(this.contents)) {
|
|
3740
3318
|
this.contents.setIn(path, value);
|
|
@@ -3756,7 +3334,7 @@ class Document$4 {
|
|
|
3756
3334
|
if (this.directives)
|
|
3757
3335
|
this.directives.yaml.version = '1.1';
|
|
3758
3336
|
else
|
|
3759
|
-
this.directives = new
|
|
3337
|
+
this.directives = new Directives({ version: '1.1' });
|
|
3760
3338
|
opt = { merge: true, resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
3761
3339
|
break;
|
|
3762
3340
|
case '1.2':
|
|
@@ -3764,7 +3342,7 @@ class Document$4 {
|
|
|
3764
3342
|
if (this.directives)
|
|
3765
3343
|
this.directives.yaml.version = version;
|
|
3766
3344
|
else
|
|
3767
|
-
this.directives = new
|
|
3345
|
+
this.directives = new Directives({ version });
|
|
3768
3346
|
opt = { merge: false, resolveKnownTags: true, schema: 'core' };
|
|
3769
3347
|
break;
|
|
3770
3348
|
case null:
|
|
@@ -3781,7 +3359,7 @@ class Document$4 {
|
|
|
3781
3359
|
if (options.schema instanceof Object)
|
|
3782
3360
|
this.schema = options.schema;
|
|
3783
3361
|
else if (opt)
|
|
3784
|
-
this.schema = new Schema
|
|
3362
|
+
this.schema = new Schema(Object.assign(opt, options));
|
|
3785
3363
|
else
|
|
3786
3364
|
throw new Error(`With a null YAML version, the { schema: Schema } option is required`);
|
|
3787
3365
|
}
|
|
@@ -3794,14 +3372,14 @@ class Document$4 {
|
|
|
3794
3372
|
mapAsMap: mapAsMap === true,
|
|
3795
3373
|
mapKeyWarned: false,
|
|
3796
3374
|
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100,
|
|
3797
|
-
stringify: stringify$
|
|
3375
|
+
stringify: stringify$2
|
|
3798
3376
|
};
|
|
3799
|
-
const res = toJS
|
|
3377
|
+
const res = toJS(this.contents, jsonArg ?? '', ctx);
|
|
3800
3378
|
if (typeof onAnchor === 'function')
|
|
3801
3379
|
for (const { count, res } of ctx.anchors.values())
|
|
3802
3380
|
onAnchor(res, count);
|
|
3803
3381
|
return typeof reviver === 'function'
|
|
3804
|
-
? applyReviver
|
|
3382
|
+
? applyReviver(reviver, { '': res }, '', res)
|
|
3805
3383
|
: res;
|
|
3806
3384
|
}
|
|
3807
3385
|
/**
|
|
@@ -3822,20 +3400,16 @@ class Document$4 {
|
|
|
3822
3400
|
const s = JSON.stringify(options.indent);
|
|
3823
3401
|
throw new Error(`"indent" option must be a positive integer, not ${s}`);
|
|
3824
3402
|
}
|
|
3825
|
-
return stringifyDocument
|
|
3403
|
+
return stringifyDocument(this, options);
|
|
3826
3404
|
}
|
|
3827
3405
|
}
|
|
3828
3406
|
function assertCollection(contents) {
|
|
3829
|
-
if (
|
|
3407
|
+
if (isCollection$1(contents))
|
|
3830
3408
|
return true;
|
|
3831
3409
|
throw new Error('Expected a YAML collection as document contents');
|
|
3832
3410
|
}
|
|
3833
3411
|
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
var errors$4 = {};
|
|
3837
|
-
|
|
3838
|
-
class YAMLError$1 extends Error {
|
|
3412
|
+
class YAMLError extends Error {
|
|
3839
3413
|
constructor(name, pos, code, message) {
|
|
3840
3414
|
super();
|
|
3841
3415
|
this.name = name;
|
|
@@ -3844,12 +3418,12 @@ class YAMLError$1 extends Error {
|
|
|
3844
3418
|
this.pos = pos;
|
|
3845
3419
|
}
|
|
3846
3420
|
}
|
|
3847
|
-
class YAMLParseError
|
|
3421
|
+
class YAMLParseError extends YAMLError {
|
|
3848
3422
|
constructor(pos, code, message) {
|
|
3849
3423
|
super('YAMLParseError', pos, code, message);
|
|
3850
3424
|
}
|
|
3851
3425
|
}
|
|
3852
|
-
class YAMLWarning
|
|
3426
|
+
class YAMLWarning extends YAMLError {
|
|
3853
3427
|
constructor(pos, code, message) {
|
|
3854
3428
|
super('YAMLWarning', pos, code, message);
|
|
3855
3429
|
}
|
|
@@ -3891,22 +3465,7 @@ const prettifyError = (src, lc) => (error) => {
|
|
|
3891
3465
|
}
|
|
3892
3466
|
};
|
|
3893
3467
|
|
|
3894
|
-
|
|
3895
|
-
errors$4.YAMLParseError = YAMLParseError$1;
|
|
3896
|
-
errors$4.YAMLWarning = YAMLWarning$1;
|
|
3897
|
-
errors$4.prettifyError = prettifyError;
|
|
3898
|
-
|
|
3899
|
-
var composeDoc$2 = {};
|
|
3900
|
-
|
|
3901
|
-
var composeNode$2 = {};
|
|
3902
|
-
|
|
3903
|
-
var composeCollection$2 = {};
|
|
3904
|
-
|
|
3905
|
-
var resolveBlockMap$2 = {};
|
|
3906
|
-
|
|
3907
|
-
var resolveProps$5 = {};
|
|
3908
|
-
|
|
3909
|
-
function resolveProps$4(tokens, { flow, indicator, next, offset, onError, startOnNewline }) {
|
|
3468
|
+
function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnNewline }) {
|
|
3910
3469
|
let spaceBefore = false;
|
|
3911
3470
|
let atNewline = startOnNewline;
|
|
3912
3471
|
let hasSpace = startOnNewline;
|
|
@@ -4039,10 +3598,6 @@ function resolveProps$4(tokens, { flow, indicator, next, offset, onError, startO
|
|
|
4039
3598
|
};
|
|
4040
3599
|
}
|
|
4041
3600
|
|
|
4042
|
-
resolveProps$5.resolveProps = resolveProps$4;
|
|
4043
|
-
|
|
4044
|
-
var utilContainsNewline$3 = {};
|
|
4045
|
-
|
|
4046
3601
|
function containsNewline(key) {
|
|
4047
3602
|
if (!key)
|
|
4048
3603
|
return null;
|
|
@@ -4076,30 +3631,18 @@ function containsNewline(key) {
|
|
|
4076
3631
|
}
|
|
4077
3632
|
}
|
|
4078
3633
|
|
|
4079
|
-
utilContainsNewline$3.containsNewline = containsNewline;
|
|
4080
|
-
|
|
4081
|
-
var utilFlowIndentCheck$2 = {};
|
|
4082
|
-
|
|
4083
|
-
var utilContainsNewline$2 = utilContainsNewline$3;
|
|
4084
|
-
|
|
4085
3634
|
function flowIndentCheck(indent, fc, onError) {
|
|
4086
3635
|
if (fc?.type === 'flow-collection') {
|
|
4087
3636
|
const end = fc.end[0];
|
|
4088
3637
|
if (end.indent === indent &&
|
|
4089
3638
|
(end.source === ']' || end.source === '}') &&
|
|
4090
|
-
|
|
3639
|
+
containsNewline(fc)) {
|
|
4091
3640
|
const msg = 'Flow end indicator should be more indented than parent';
|
|
4092
3641
|
onError(end, 'BAD_INDENT', msg, true);
|
|
4093
3642
|
}
|
|
4094
3643
|
}
|
|
4095
3644
|
}
|
|
4096
3645
|
|
|
4097
|
-
utilFlowIndentCheck$2.flowIndentCheck = flowIndentCheck;
|
|
4098
|
-
|
|
4099
|
-
var utilMapIncludes$2 = {};
|
|
4100
|
-
|
|
4101
|
-
var Node$5 = Node$t;
|
|
4102
|
-
|
|
4103
3646
|
function mapIncludes(ctx, items, search) {
|
|
4104
3647
|
const { uniqueKeys } = ctx.options;
|
|
4105
3648
|
if (uniqueKeys === false)
|
|
@@ -4107,32 +3650,23 @@ function mapIncludes(ctx, items, search) {
|
|
|
4107
3650
|
const isEqual = typeof uniqueKeys === 'function'
|
|
4108
3651
|
? uniqueKeys
|
|
4109
3652
|
: (a, b) => a === b ||
|
|
4110
|
-
(
|
|
4111
|
-
|
|
3653
|
+
(isScalar$1(a) &&
|
|
3654
|
+
isScalar$1(b) &&
|
|
4112
3655
|
a.value === b.value &&
|
|
4113
3656
|
!(a.value === '<<' && ctx.schema.merge));
|
|
4114
3657
|
return items.some(pair => isEqual(pair.key, search));
|
|
4115
3658
|
}
|
|
4116
3659
|
|
|
4117
|
-
utilMapIncludes$2.mapIncludes = mapIncludes;
|
|
4118
|
-
|
|
4119
|
-
var Pair$2 = Pair$9;
|
|
4120
|
-
var YAMLMap$2 = YAMLMap$7;
|
|
4121
|
-
var resolveProps$3 = resolveProps$5;
|
|
4122
|
-
var utilContainsNewline$1 = utilContainsNewline$3;
|
|
4123
|
-
var utilFlowIndentCheck$1 = utilFlowIndentCheck$2;
|
|
4124
|
-
var utilMapIncludes$1 = utilMapIncludes$2;
|
|
4125
|
-
|
|
4126
3660
|
const startColMsg = 'All mapping items must start at the same column';
|
|
4127
|
-
function resolveBlockMap
|
|
4128
|
-
const map = new YAMLMap
|
|
3661
|
+
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
3662
|
+
const map = new YAMLMap(ctx.schema);
|
|
4129
3663
|
if (ctx.atRoot)
|
|
4130
3664
|
ctx.atRoot = false;
|
|
4131
3665
|
let offset = bm.offset;
|
|
4132
3666
|
for (const collItem of bm.items) {
|
|
4133
3667
|
const { start, key, sep, value } = collItem;
|
|
4134
3668
|
// key properties
|
|
4135
|
-
const keyProps = resolveProps
|
|
3669
|
+
const keyProps = resolveProps(start, {
|
|
4136
3670
|
indicator: 'explicit-key-ind',
|
|
4137
3671
|
next: key ?? sep?.[0],
|
|
4138
3672
|
offset,
|
|
@@ -4157,7 +3691,7 @@ function resolveBlockMap$1({ composeNode, composeEmptyNode }, ctx, bm, onError)
|
|
|
4157
3691
|
}
|
|
4158
3692
|
continue;
|
|
4159
3693
|
}
|
|
4160
|
-
if (keyProps.hasNewlineAfterProp ||
|
|
3694
|
+
if (keyProps.hasNewlineAfterProp || containsNewline(key)) {
|
|
4161
3695
|
onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
|
|
4162
3696
|
}
|
|
4163
3697
|
}
|
|
@@ -4170,11 +3704,11 @@ function resolveBlockMap$1({ composeNode, composeEmptyNode }, ctx, bm, onError)
|
|
|
4170
3704
|
? composeNode(ctx, key, keyProps, onError)
|
|
4171
3705
|
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
|
|
4172
3706
|
if (ctx.schema.compat)
|
|
4173
|
-
|
|
4174
|
-
if (
|
|
3707
|
+
flowIndentCheck(bm.indent, key, onError);
|
|
3708
|
+
if (mapIncludes(ctx, map.items, keyNode))
|
|
4175
3709
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
4176
3710
|
// value properties
|
|
4177
|
-
const valueProps = resolveProps
|
|
3711
|
+
const valueProps = resolveProps(sep ?? [], {
|
|
4178
3712
|
indicator: 'map-value-ind',
|
|
4179
3713
|
next: value,
|
|
4180
3714
|
offset: keyNode.range[2],
|
|
@@ -4195,9 +3729,9 @@ function resolveBlockMap$1({ composeNode, composeEmptyNode }, ctx, bm, onError)
|
|
|
4195
3729
|
? composeNode(ctx, value, valueProps, onError)
|
|
4196
3730
|
: composeEmptyNode(ctx, offset, sep, null, valueProps, onError);
|
|
4197
3731
|
if (ctx.schema.compat)
|
|
4198
|
-
|
|
3732
|
+
flowIndentCheck(bm.indent, value, onError);
|
|
4199
3733
|
offset = valueNode.range[2];
|
|
4200
|
-
const pair = new Pair
|
|
3734
|
+
const pair = new Pair(keyNode, valueNode);
|
|
4201
3735
|
if (ctx.options.keepSourceTokens)
|
|
4202
3736
|
pair.srcToken = collItem;
|
|
4203
3737
|
map.items.push(pair);
|
|
@@ -4212,7 +3746,7 @@ function resolveBlockMap$1({ composeNode, composeEmptyNode }, ctx, bm, onError)
|
|
|
4212
3746
|
else
|
|
4213
3747
|
keyNode.comment = valueProps.comment;
|
|
4214
3748
|
}
|
|
4215
|
-
const pair = new Pair
|
|
3749
|
+
const pair = new Pair(keyNode);
|
|
4216
3750
|
if (ctx.options.keepSourceTokens)
|
|
4217
3751
|
pair.srcToken = collItem;
|
|
4218
3752
|
map.items.push(pair);
|
|
@@ -4222,21 +3756,13 @@ function resolveBlockMap$1({ composeNode, composeEmptyNode }, ctx, bm, onError)
|
|
|
4222
3756
|
return map;
|
|
4223
3757
|
}
|
|
4224
3758
|
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
var resolveBlockSeq$2 = {};
|
|
4228
|
-
|
|
4229
|
-
var YAMLSeq$2 = YAMLSeq$7;
|
|
4230
|
-
var resolveProps$2 = resolveProps$5;
|
|
4231
|
-
var utilFlowIndentCheck = utilFlowIndentCheck$2;
|
|
4232
|
-
|
|
4233
|
-
function resolveBlockSeq$1({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
4234
|
-
const seq = new YAMLSeq$2.YAMLSeq(ctx.schema);
|
|
3759
|
+
function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
3760
|
+
const seq = new YAMLSeq(ctx.schema);
|
|
4235
3761
|
if (ctx.atRoot)
|
|
4236
3762
|
ctx.atRoot = false;
|
|
4237
3763
|
let offset = bs.offset;
|
|
4238
3764
|
for (const { start, value } of bs.items) {
|
|
4239
|
-
const props = resolveProps
|
|
3765
|
+
const props = resolveProps(start, {
|
|
4240
3766
|
indicator: 'seq-item-ind',
|
|
4241
3767
|
next: value,
|
|
4242
3768
|
offset,
|
|
@@ -4262,7 +3788,7 @@ function resolveBlockSeq$1({ composeNode, composeEmptyNode }, ctx, bs, onError)
|
|
|
4262
3788
|
? composeNode(ctx, value, props, onError)
|
|
4263
3789
|
: composeEmptyNode(ctx, offset, start, null, props, onError);
|
|
4264
3790
|
if (ctx.schema.compat)
|
|
4265
|
-
|
|
3791
|
+
flowIndentCheck(bs.indent, value, onError);
|
|
4266
3792
|
offset = node.range[2];
|
|
4267
3793
|
seq.items.push(node);
|
|
4268
3794
|
}
|
|
@@ -4270,13 +3796,7 @@ function resolveBlockSeq$1({ composeNode, composeEmptyNode }, ctx, bs, onError)
|
|
|
4270
3796
|
return seq;
|
|
4271
3797
|
}
|
|
4272
3798
|
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
var resolveFlowCollection$2 = {};
|
|
4276
|
-
|
|
4277
|
-
var resolveEnd$6 = {};
|
|
4278
|
-
|
|
4279
|
-
function resolveEnd$5(end, offset, reqSpace, onError) {
|
|
3799
|
+
function resolveEnd(end, offset, reqSpace, onError) {
|
|
4280
3800
|
let comment = '';
|
|
4281
3801
|
if (end) {
|
|
4282
3802
|
let hasSpace = false;
|
|
@@ -4312,25 +3832,14 @@ function resolveEnd$5(end, offset, reqSpace, onError) {
|
|
|
4312
3832
|
return { comment, offset };
|
|
4313
3833
|
}
|
|
4314
3834
|
|
|
4315
|
-
resolveEnd$6.resolveEnd = resolveEnd$5;
|
|
4316
|
-
|
|
4317
|
-
var Node$4 = Node$t;
|
|
4318
|
-
var Pair$1 = Pair$9;
|
|
4319
|
-
var YAMLMap$1 = YAMLMap$7;
|
|
4320
|
-
var YAMLSeq$1 = YAMLSeq$7;
|
|
4321
|
-
var resolveEnd$4 = resolveEnd$6;
|
|
4322
|
-
var resolveProps$1 = resolveProps$5;
|
|
4323
|
-
var utilContainsNewline = utilContainsNewline$3;
|
|
4324
|
-
var utilMapIncludes = utilMapIncludes$2;
|
|
4325
|
-
|
|
4326
3835
|
const blockMsg = 'Block collections are not allowed within flow collections';
|
|
4327
3836
|
const isBlock = (token) => token && (token.type === 'block-map' || token.type === 'block-seq');
|
|
4328
|
-
function resolveFlowCollection
|
|
3837
|
+
function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError) {
|
|
4329
3838
|
const isMap = fc.start.source === '{';
|
|
4330
3839
|
const fcName = isMap ? 'flow map' : 'flow sequence';
|
|
4331
3840
|
const coll = isMap
|
|
4332
|
-
? new YAMLMap
|
|
4333
|
-
: new YAMLSeq
|
|
3841
|
+
? new YAMLMap(ctx.schema)
|
|
3842
|
+
: new YAMLSeq(ctx.schema);
|
|
4334
3843
|
coll.flow = true;
|
|
4335
3844
|
const atRoot = ctx.atRoot;
|
|
4336
3845
|
if (atRoot)
|
|
@@ -4339,7 +3848,7 @@ function resolveFlowCollection$1({ composeNode, composeEmptyNode }, ctx, fc, onE
|
|
|
4339
3848
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
4340
3849
|
const collItem = fc.items[i];
|
|
4341
3850
|
const { start, key, sep, value } = collItem;
|
|
4342
|
-
const props = resolveProps
|
|
3851
|
+
const props = resolveProps(start, {
|
|
4343
3852
|
flow: fcName,
|
|
4344
3853
|
indicator: 'explicit-key-ind',
|
|
4345
3854
|
next: key ?? sep?.[0],
|
|
@@ -4362,7 +3871,7 @@ function resolveFlowCollection$1({ composeNode, composeEmptyNode }, ctx, fc, onE
|
|
|
4362
3871
|
offset = props.end;
|
|
4363
3872
|
continue;
|
|
4364
3873
|
}
|
|
4365
|
-
if (!isMap && ctx.options.strict &&
|
|
3874
|
+
if (!isMap && ctx.options.strict && containsNewline(key))
|
|
4366
3875
|
onError(key, // checked by containsNewline()
|
|
4367
3876
|
'MULTILINE_IMPLICIT_KEY', 'Implicit keys of flow sequence pairs need to be on a single line');
|
|
4368
3877
|
}
|
|
@@ -4389,7 +3898,7 @@ function resolveFlowCollection$1({ composeNode, composeEmptyNode }, ctx, fc, onE
|
|
|
4389
3898
|
}
|
|
4390
3899
|
if (prevItemComment) {
|
|
4391
3900
|
let prev = coll.items[coll.items.length - 1];
|
|
4392
|
-
if (
|
|
3901
|
+
if (isPair(prev))
|
|
4393
3902
|
prev = prev.value ?? prev.key;
|
|
4394
3903
|
if (prev.comment)
|
|
4395
3904
|
prev.comment += '\n' + prevItemComment;
|
|
@@ -4420,7 +3929,7 @@ function resolveFlowCollection$1({ composeNode, composeEmptyNode }, ctx, fc, onE
|
|
|
4420
3929
|
if (isBlock(key))
|
|
4421
3930
|
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
|
|
4422
3931
|
// value properties
|
|
4423
|
-
const valueProps = resolveProps
|
|
3932
|
+
const valueProps = resolveProps(sep ?? [], {
|
|
4424
3933
|
flow: fcName,
|
|
4425
3934
|
indicator: 'map-value-ind',
|
|
4426
3935
|
next: value,
|
|
@@ -4465,17 +3974,17 @@ function resolveFlowCollection$1({ composeNode, composeEmptyNode }, ctx, fc, onE
|
|
|
4465
3974
|
else
|
|
4466
3975
|
keyNode.comment = valueProps.comment;
|
|
4467
3976
|
}
|
|
4468
|
-
const pair = new Pair
|
|
3977
|
+
const pair = new Pair(keyNode, valueNode);
|
|
4469
3978
|
if (ctx.options.keepSourceTokens)
|
|
4470
3979
|
pair.srcToken = collItem;
|
|
4471
3980
|
if (isMap) {
|
|
4472
3981
|
const map = coll;
|
|
4473
|
-
if (
|
|
3982
|
+
if (mapIncludes(ctx, map.items, keyNode))
|
|
4474
3983
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
4475
3984
|
map.items.push(pair);
|
|
4476
3985
|
}
|
|
4477
3986
|
else {
|
|
4478
|
-
const map = new YAMLMap
|
|
3987
|
+
const map = new YAMLMap(ctx.schema);
|
|
4479
3988
|
map.flow = true;
|
|
4480
3989
|
map.items.push(pair);
|
|
4481
3990
|
coll.items.push(map);
|
|
@@ -4498,7 +4007,7 @@ function resolveFlowCollection$1({ composeNode, composeEmptyNode }, ctx, fc, onE
|
|
|
4498
4007
|
ee.unshift(ce);
|
|
4499
4008
|
}
|
|
4500
4009
|
if (ee.length > 0) {
|
|
4501
|
-
const end = resolveEnd
|
|
4010
|
+
const end = resolveEnd(ee, cePos, ctx.options.strict, onError);
|
|
4502
4011
|
if (end.comment) {
|
|
4503
4012
|
if (coll.comment)
|
|
4504
4013
|
coll.comment += '\n' + end.comment;
|
|
@@ -4513,27 +4022,19 @@ function resolveFlowCollection$1({ composeNode, composeEmptyNode }, ctx, fc, onE
|
|
|
4513
4022
|
return coll;
|
|
4514
4023
|
}
|
|
4515
4024
|
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
var Node$3 = Node$t;
|
|
4519
|
-
var Scalar$4 = Scalar$k;
|
|
4520
|
-
var resolveBlockMap = resolveBlockMap$2;
|
|
4521
|
-
var resolveBlockSeq = resolveBlockSeq$2;
|
|
4522
|
-
var resolveFlowCollection = resolveFlowCollection$2;
|
|
4523
|
-
|
|
4524
|
-
function composeCollection$1(CN, ctx, token, tagToken, onError) {
|
|
4025
|
+
function composeCollection(CN, ctx, token, tagToken, onError) {
|
|
4525
4026
|
let coll;
|
|
4526
4027
|
switch (token.type) {
|
|
4527
4028
|
case 'block-map': {
|
|
4528
|
-
coll = resolveBlockMap
|
|
4029
|
+
coll = resolveBlockMap(CN, ctx, token, onError);
|
|
4529
4030
|
break;
|
|
4530
4031
|
}
|
|
4531
4032
|
case 'block-seq': {
|
|
4532
|
-
coll = resolveBlockSeq
|
|
4033
|
+
coll = resolveBlockSeq(CN, ctx, token, onError);
|
|
4533
4034
|
break;
|
|
4534
4035
|
}
|
|
4535
4036
|
case 'flow-collection': {
|
|
4536
|
-
coll = resolveFlowCollection
|
|
4037
|
+
coll = resolveFlowCollection(CN, ctx, token, onError);
|
|
4537
4038
|
break;
|
|
4538
4039
|
}
|
|
4539
4040
|
}
|
|
@@ -4548,7 +4049,7 @@ function composeCollection$1(CN, ctx, token, tagToken, onError) {
|
|
|
4548
4049
|
coll.tag = Coll.tagName;
|
|
4549
4050
|
return coll;
|
|
4550
4051
|
}
|
|
4551
|
-
const expType =
|
|
4052
|
+
const expType = isMap(coll) ? 'map' : 'seq';
|
|
4552
4053
|
let tag = ctx.schema.tags.find(t => t.collection === expType && t.tag === tagName);
|
|
4553
4054
|
if (!tag) {
|
|
4554
4055
|
const kt = ctx.schema.knownTags[tagName];
|
|
@@ -4563,9 +4064,9 @@ function composeCollection$1(CN, ctx, token, tagToken, onError) {
|
|
|
4563
4064
|
}
|
|
4564
4065
|
}
|
|
4565
4066
|
const res = tag.resolve(coll, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
4566
|
-
const node =
|
|
4067
|
+
const node = isNode(res)
|
|
4567
4068
|
? res
|
|
4568
|
-
: new Scalar
|
|
4069
|
+
: new Scalar(res);
|
|
4569
4070
|
node.range = coll.range;
|
|
4570
4071
|
node.tag = tagName;
|
|
4571
4072
|
if (tag?.format)
|
|
@@ -4573,20 +4074,12 @@ function composeCollection$1(CN, ctx, token, tagToken, onError) {
|
|
|
4573
4074
|
return node;
|
|
4574
4075
|
}
|
|
4575
4076
|
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
var composeScalar$2 = {};
|
|
4579
|
-
|
|
4580
|
-
var resolveBlockScalar$3 = {};
|
|
4581
|
-
|
|
4582
|
-
var Scalar$3 = Scalar$k;
|
|
4583
|
-
|
|
4584
|
-
function resolveBlockScalar$2(scalar, strict, onError) {
|
|
4077
|
+
function resolveBlockScalar(scalar, strict, onError) {
|
|
4585
4078
|
const start = scalar.offset;
|
|
4586
4079
|
const header = parseBlockScalarHeader(scalar, strict, onError);
|
|
4587
4080
|
if (!header)
|
|
4588
4081
|
return { value: '', type: null, comment: '', range: [start, start, start] };
|
|
4589
|
-
const type = header.mode === '>' ? Scalar
|
|
4082
|
+
const type = header.mode === '>' ? Scalar.BLOCK_FOLDED : Scalar.BLOCK_LITERAL;
|
|
4590
4083
|
const lines = scalar.source ? splitLines(scalar.source) : [];
|
|
4591
4084
|
// determine the end of content & start of chomping
|
|
4592
4085
|
let chompStart = lines.length;
|
|
@@ -4655,7 +4148,7 @@ function resolveBlockScalar$2(scalar, strict, onError) {
|
|
|
4655
4148
|
onError(offset - content.length - (crlf ? 2 : 1), 'BAD_INDENT', message);
|
|
4656
4149
|
indent = '';
|
|
4657
4150
|
}
|
|
4658
|
-
if (type === Scalar
|
|
4151
|
+
if (type === Scalar.BLOCK_LITERAL) {
|
|
4659
4152
|
value += sep + indent.slice(trimIndent) + content;
|
|
4660
4153
|
sep = '\n';
|
|
4661
4154
|
}
|
|
@@ -4772,29 +4265,22 @@ function splitLines(source) {
|
|
|
4772
4265
|
return lines;
|
|
4773
4266
|
}
|
|
4774
4267
|
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
var resolveFlowScalar$3 = {};
|
|
4778
|
-
|
|
4779
|
-
var Scalar$2 = Scalar$k;
|
|
4780
|
-
var resolveEnd$3 = resolveEnd$6;
|
|
4781
|
-
|
|
4782
|
-
function resolveFlowScalar$2(scalar, strict, onError) {
|
|
4268
|
+
function resolveFlowScalar(scalar, strict, onError) {
|
|
4783
4269
|
const { offset, type, source, end } = scalar;
|
|
4784
4270
|
let _type;
|
|
4785
4271
|
let value;
|
|
4786
4272
|
const _onError = (rel, code, msg) => onError(offset + rel, code, msg);
|
|
4787
4273
|
switch (type) {
|
|
4788
4274
|
case 'scalar':
|
|
4789
|
-
_type = Scalar
|
|
4275
|
+
_type = Scalar.PLAIN;
|
|
4790
4276
|
value = plainValue(source, _onError);
|
|
4791
4277
|
break;
|
|
4792
4278
|
case 'single-quoted-scalar':
|
|
4793
|
-
_type = Scalar
|
|
4279
|
+
_type = Scalar.QUOTE_SINGLE;
|
|
4794
4280
|
value = singleQuotedValue(source, _onError);
|
|
4795
4281
|
break;
|
|
4796
4282
|
case 'double-quoted-scalar':
|
|
4797
|
-
_type = Scalar
|
|
4283
|
+
_type = Scalar.QUOTE_DOUBLE;
|
|
4798
4284
|
value = doubleQuotedValue(source, _onError);
|
|
4799
4285
|
break;
|
|
4800
4286
|
/* istanbul ignore next should not happen */
|
|
@@ -4808,7 +4294,7 @@ function resolveFlowScalar$2(scalar, strict, onError) {
|
|
|
4808
4294
|
};
|
|
4809
4295
|
}
|
|
4810
4296
|
const valueEnd = offset + source.length;
|
|
4811
|
-
const re = resolveEnd
|
|
4297
|
+
const re = resolveEnd(end, valueEnd, strict, onError);
|
|
4812
4298
|
return {
|
|
4813
4299
|
value,
|
|
4814
4300
|
type: _type,
|
|
@@ -4998,17 +4484,10 @@ function parseCharCode(source, offset, length, onError) {
|
|
|
4998
4484
|
return String.fromCodePoint(code);
|
|
4999
4485
|
}
|
|
5000
4486
|
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
var Node$2 = Node$t;
|
|
5004
|
-
var Scalar$1 = Scalar$k;
|
|
5005
|
-
var resolveBlockScalar$1 = resolveBlockScalar$3;
|
|
5006
|
-
var resolveFlowScalar$1 = resolveFlowScalar$3;
|
|
5007
|
-
|
|
5008
|
-
function composeScalar$1(ctx, token, tagToken, onError) {
|
|
4487
|
+
function composeScalar(ctx, token, tagToken, onError) {
|
|
5009
4488
|
const { value, type, comment, range } = token.type === 'block-scalar'
|
|
5010
|
-
? resolveBlockScalar
|
|
5011
|
-
: resolveFlowScalar
|
|
4489
|
+
? resolveBlockScalar(token, ctx.options.strict, onError)
|
|
4490
|
+
: resolveFlowScalar(token, ctx.options.strict, onError);
|
|
5012
4491
|
const tagName = tagToken
|
|
5013
4492
|
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
|
|
5014
4493
|
: null;
|
|
@@ -5016,16 +4495,16 @@ function composeScalar$1(ctx, token, tagToken, onError) {
|
|
|
5016
4495
|
? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError)
|
|
5017
4496
|
: token.type === 'scalar'
|
|
5018
4497
|
? findScalarTagByTest(ctx, value, token, onError)
|
|
5019
|
-
: ctx.schema[
|
|
4498
|
+
: ctx.schema[SCALAR$1];
|
|
5020
4499
|
let scalar;
|
|
5021
4500
|
try {
|
|
5022
4501
|
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
5023
|
-
scalar =
|
|
4502
|
+
scalar = isScalar$1(res) ? res : new Scalar(res);
|
|
5024
4503
|
}
|
|
5025
4504
|
catch (error) {
|
|
5026
4505
|
const msg = error instanceof Error ? error.message : String(error);
|
|
5027
4506
|
onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg);
|
|
5028
|
-
scalar = new Scalar
|
|
4507
|
+
scalar = new Scalar(value);
|
|
5029
4508
|
}
|
|
5030
4509
|
scalar.range = range;
|
|
5031
4510
|
scalar.source = value;
|
|
@@ -5041,7 +4520,7 @@ function composeScalar$1(ctx, token, tagToken, onError) {
|
|
|
5041
4520
|
}
|
|
5042
4521
|
function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
5043
4522
|
if (tagName === '!')
|
|
5044
|
-
return schema[
|
|
4523
|
+
return schema[SCALAR$1]; // non-specific tag
|
|
5045
4524
|
const matchWithTest = [];
|
|
5046
4525
|
for (const tag of schema.tags) {
|
|
5047
4526
|
if (!tag.collection && tag.tag === tagName) {
|
|
@@ -5062,13 +4541,13 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
|
5062
4541
|
return kt;
|
|
5063
4542
|
}
|
|
5064
4543
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
|
|
5065
|
-
return schema[
|
|
4544
|
+
return schema[SCALAR$1];
|
|
5066
4545
|
}
|
|
5067
4546
|
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
5068
|
-
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[
|
|
4547
|
+
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[SCALAR$1];
|
|
5069
4548
|
if (schema.compat) {
|
|
5070
4549
|
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
|
5071
|
-
schema[
|
|
4550
|
+
schema[SCALAR$1];
|
|
5072
4551
|
if (tag.tag !== compat.tag) {
|
|
5073
4552
|
const ts = directives.tagString(tag.tag);
|
|
5074
4553
|
const cs = directives.tagString(compat.tag);
|
|
@@ -5079,10 +4558,6 @@ function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
|
5079
4558
|
return tag;
|
|
5080
4559
|
}
|
|
5081
4560
|
|
|
5082
|
-
composeScalar$2.composeScalar = composeScalar$1;
|
|
5083
|
-
|
|
5084
|
-
var utilEmptyScalarPosition$1 = {};
|
|
5085
|
-
|
|
5086
4561
|
function emptyScalarPosition(offset, before, pos) {
|
|
5087
4562
|
if (before) {
|
|
5088
4563
|
if (pos === null)
|
|
@@ -5109,16 +4584,8 @@ function emptyScalarPosition(offset, before, pos) {
|
|
|
5109
4584
|
return offset;
|
|
5110
4585
|
}
|
|
5111
4586
|
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
var Alias$1 = Alias$5;
|
|
5115
|
-
var composeCollection = composeCollection$2;
|
|
5116
|
-
var composeScalar = composeScalar$2;
|
|
5117
|
-
var resolveEnd$2 = resolveEnd$6;
|
|
5118
|
-
var utilEmptyScalarPosition = utilEmptyScalarPosition$1;
|
|
5119
|
-
|
|
5120
|
-
const CN = { composeNode: composeNode$1, composeEmptyNode };
|
|
5121
|
-
function composeNode$1(ctx, token, props, onError) {
|
|
4587
|
+
const CN = { composeNode, composeEmptyNode };
|
|
4588
|
+
function composeNode(ctx, token, props, onError) {
|
|
5122
4589
|
const { spaceBefore, comment, anchor, tag } = props;
|
|
5123
4590
|
let node;
|
|
5124
4591
|
let isSrcToken = true;
|
|
@@ -5132,14 +4599,14 @@ function composeNode$1(ctx, token, props, onError) {
|
|
|
5132
4599
|
case 'single-quoted-scalar':
|
|
5133
4600
|
case 'double-quoted-scalar':
|
|
5134
4601
|
case 'block-scalar':
|
|
5135
|
-
node = composeScalar
|
|
4602
|
+
node = composeScalar(ctx, token, tag, onError);
|
|
5136
4603
|
if (anchor)
|
|
5137
4604
|
node.anchor = anchor.source.substring(1);
|
|
5138
4605
|
break;
|
|
5139
4606
|
case 'block-map':
|
|
5140
4607
|
case 'block-seq':
|
|
5141
4608
|
case 'flow-collection':
|
|
5142
|
-
node = composeCollection
|
|
4609
|
+
node = composeCollection(CN, ctx, token, tag, onError);
|
|
5143
4610
|
if (anchor)
|
|
5144
4611
|
node.anchor = anchor.source.substring(1);
|
|
5145
4612
|
break;
|
|
@@ -5170,11 +4637,11 @@ function composeNode$1(ctx, token, props, onError) {
|
|
|
5170
4637
|
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag }, onError) {
|
|
5171
4638
|
const token = {
|
|
5172
4639
|
type: 'scalar',
|
|
5173
|
-
offset:
|
|
4640
|
+
offset: emptyScalarPosition(offset, before, pos),
|
|
5174
4641
|
indent: -1,
|
|
5175
4642
|
source: ''
|
|
5176
4643
|
};
|
|
5177
|
-
const node = composeScalar
|
|
4644
|
+
const node = composeScalar(ctx, token, tag, onError);
|
|
5178
4645
|
if (anchor) {
|
|
5179
4646
|
node.anchor = anchor.source.substring(1);
|
|
5180
4647
|
if (node.anchor === '')
|
|
@@ -5187,37 +4654,29 @@ function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anch
|
|
|
5187
4654
|
return node;
|
|
5188
4655
|
}
|
|
5189
4656
|
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
5190
|
-
const alias = new Alias
|
|
4657
|
+
const alias = new Alias(source.substring(1));
|
|
5191
4658
|
if (alias.source === '')
|
|
5192
4659
|
onError(offset, 'BAD_ALIAS', 'Alias cannot be an empty string');
|
|
5193
4660
|
if (alias.source.endsWith(':'))
|
|
5194
4661
|
onError(offset + source.length - 1, 'BAD_ALIAS', 'Alias ending in : is ambiguous', true);
|
|
5195
4662
|
const valueEnd = offset + source.length;
|
|
5196
|
-
const re = resolveEnd
|
|
4663
|
+
const re = resolveEnd(end, valueEnd, options.strict, onError);
|
|
5197
4664
|
alias.range = [offset, valueEnd, re.offset];
|
|
5198
4665
|
if (re.comment)
|
|
5199
4666
|
alias.comment = re.comment;
|
|
5200
4667
|
return alias;
|
|
5201
4668
|
}
|
|
5202
4669
|
|
|
5203
|
-
|
|
5204
|
-
composeNode$2.composeNode = composeNode$1;
|
|
5205
|
-
|
|
5206
|
-
var Document$3 = Document$5;
|
|
5207
|
-
var composeNode = composeNode$2;
|
|
5208
|
-
var resolveEnd$1 = resolveEnd$6;
|
|
5209
|
-
var resolveProps = resolveProps$5;
|
|
5210
|
-
|
|
5211
|
-
function composeDoc$1(options, directives, { offset, start, value, end }, onError) {
|
|
4670
|
+
function composeDoc(options, directives, { offset, start, value, end }, onError) {
|
|
5212
4671
|
const opts = Object.assign({ _directives: directives }, options);
|
|
5213
|
-
const doc = new Document
|
|
4672
|
+
const doc = new Document(undefined, opts);
|
|
5214
4673
|
const ctx = {
|
|
5215
4674
|
atRoot: true,
|
|
5216
4675
|
directives: doc.directives,
|
|
5217
4676
|
options: doc.options,
|
|
5218
4677
|
schema: doc.schema
|
|
5219
4678
|
};
|
|
5220
|
-
const props = resolveProps
|
|
4679
|
+
const props = resolveProps(start, {
|
|
5221
4680
|
indicator: 'doc-start',
|
|
5222
4681
|
next: value ?? end?.[0],
|
|
5223
4682
|
offset,
|
|
@@ -5232,25 +4691,16 @@ function composeDoc$1(options, directives, { offset, start, value, end }, onErro
|
|
|
5232
4691
|
onError(props.end, 'MISSING_CHAR', 'Block collection cannot start on same line with directives-end marker');
|
|
5233
4692
|
}
|
|
5234
4693
|
doc.contents = value
|
|
5235
|
-
? composeNode
|
|
5236
|
-
:
|
|
4694
|
+
? composeNode(ctx, value, props, onError)
|
|
4695
|
+
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
|
5237
4696
|
const contentEnd = doc.contents.range[2];
|
|
5238
|
-
const re = resolveEnd
|
|
4697
|
+
const re = resolveEnd(end, contentEnd, false, onError);
|
|
5239
4698
|
if (re.comment)
|
|
5240
4699
|
doc.comment = re.comment;
|
|
5241
4700
|
doc.range = [offset, contentEnd, re.offset];
|
|
5242
4701
|
return doc;
|
|
5243
4702
|
}
|
|
5244
4703
|
|
|
5245
|
-
composeDoc$2.composeDoc = composeDoc$1;
|
|
5246
|
-
|
|
5247
|
-
var directives = directives$2;
|
|
5248
|
-
var Document$2 = Document$5;
|
|
5249
|
-
var errors$3 = errors$4;
|
|
5250
|
-
var Node$1 = Node$t;
|
|
5251
|
-
var composeDoc = composeDoc$2;
|
|
5252
|
-
var resolveEnd = resolveEnd$6;
|
|
5253
|
-
|
|
5254
4704
|
function getErrorPos(src) {
|
|
5255
4705
|
if (typeof src === 'number')
|
|
5256
4706
|
return [src, src + 1];
|
|
@@ -5298,7 +4748,7 @@ function parsePrelude(prelude) {
|
|
|
5298
4748
|
* const docs = new Composer().compose(tokens)
|
|
5299
4749
|
* ```
|
|
5300
4750
|
*/
|
|
5301
|
-
class Composer
|
|
4751
|
+
class Composer {
|
|
5302
4752
|
constructor(options = {}) {
|
|
5303
4753
|
this.doc = null;
|
|
5304
4754
|
this.atDirectives = false;
|
|
@@ -5308,12 +4758,12 @@ class Composer$1 {
|
|
|
5308
4758
|
this.onError = (source, code, message, warning) => {
|
|
5309
4759
|
const pos = getErrorPos(source);
|
|
5310
4760
|
if (warning)
|
|
5311
|
-
this.warnings.push(new
|
|
4761
|
+
this.warnings.push(new YAMLWarning(pos, code, message));
|
|
5312
4762
|
else
|
|
5313
|
-
this.errors.push(new
|
|
4763
|
+
this.errors.push(new YAMLParseError(pos, code, message));
|
|
5314
4764
|
};
|
|
5315
4765
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
5316
|
-
this.directives = new
|
|
4766
|
+
this.directives = new Directives({ version: options.version || '1.2' });
|
|
5317
4767
|
this.options = options;
|
|
5318
4768
|
}
|
|
5319
4769
|
decorate(doc, afterDoc) {
|
|
@@ -5327,9 +4777,9 @@ class Composer$1 {
|
|
|
5327
4777
|
else if (afterEmptyLine || doc.directives.docStart || !dc) {
|
|
5328
4778
|
doc.commentBefore = comment;
|
|
5329
4779
|
}
|
|
5330
|
-
else if (
|
|
4780
|
+
else if (isCollection$1(dc) && !dc.flow && dc.items.length > 0) {
|
|
5331
4781
|
let it = dc.items[0];
|
|
5332
|
-
if (
|
|
4782
|
+
if (isPair(it))
|
|
5333
4783
|
it = it.key;
|
|
5334
4784
|
const cb = it.commentBefore;
|
|
5335
4785
|
it.commentBefore = cb ? `${comment}\n${cb}` : comment;
|
|
@@ -5377,8 +4827,6 @@ class Composer$1 {
|
|
|
5377
4827
|
}
|
|
5378
4828
|
/** Advance the composer by one CST token. */
|
|
5379
4829
|
*next(token) {
|
|
5380
|
-
if (process.env.LOG_STREAM)
|
|
5381
|
-
console.dir(token, { depth: null });
|
|
5382
4830
|
switch (token.type) {
|
|
5383
4831
|
case 'directive':
|
|
5384
4832
|
this.directives.add(token.source, (offset, message, warning) => {
|
|
@@ -5390,7 +4838,7 @@ class Composer$1 {
|
|
|
5390
4838
|
this.atDirectives = true;
|
|
5391
4839
|
break;
|
|
5392
4840
|
case 'document': {
|
|
5393
|
-
const doc = composeDoc
|
|
4841
|
+
const doc = composeDoc(this.options, this.directives, token, this.onError);
|
|
5394
4842
|
if (this.atDirectives && !doc.directives.docStart)
|
|
5395
4843
|
this.onError(token, 'MISSING_CHAR', 'Missing directives-end/doc-start indicator line');
|
|
5396
4844
|
this.decorate(doc, false);
|
|
@@ -5411,7 +4859,7 @@ class Composer$1 {
|
|
|
5411
4859
|
const msg = token.source
|
|
5412
4860
|
? `${token.message}: ${JSON.stringify(token.source)}`
|
|
5413
4861
|
: token.message;
|
|
5414
|
-
const error = new
|
|
4862
|
+
const error = new YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', msg);
|
|
5415
4863
|
if (this.atDirectives || !this.doc)
|
|
5416
4864
|
this.errors.push(error);
|
|
5417
4865
|
else
|
|
@@ -5421,11 +4869,11 @@ class Composer$1 {
|
|
|
5421
4869
|
case 'doc-end': {
|
|
5422
4870
|
if (!this.doc) {
|
|
5423
4871
|
const msg = 'Unexpected doc-end without preceding document';
|
|
5424
|
-
this.errors.push(new
|
|
4872
|
+
this.errors.push(new YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', msg));
|
|
5425
4873
|
break;
|
|
5426
4874
|
}
|
|
5427
4875
|
this.doc.directives.docEnd = true;
|
|
5428
|
-
const end = resolveEnd
|
|
4876
|
+
const end = resolveEnd(token.end, token.offset + token.source.length, this.doc.options.strict, this.onError);
|
|
5429
4877
|
this.decorate(this.doc, true);
|
|
5430
4878
|
if (end.comment) {
|
|
5431
4879
|
const dc = this.doc.comment;
|
|
@@ -5435,7 +4883,7 @@ class Composer$1 {
|
|
|
5435
4883
|
break;
|
|
5436
4884
|
}
|
|
5437
4885
|
default:
|
|
5438
|
-
this.errors.push(new
|
|
4886
|
+
this.errors.push(new YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', `Unsupported token ${token.type}`));
|
|
5439
4887
|
}
|
|
5440
4888
|
}
|
|
5441
4889
|
/**
|
|
@@ -5452,7 +4900,7 @@ class Composer$1 {
|
|
|
5452
4900
|
}
|
|
5453
4901
|
else if (forceDoc) {
|
|
5454
4902
|
const opts = Object.assign({ _directives: this.directives }, this.options);
|
|
5455
|
-
const doc = new Document
|
|
4903
|
+
const doc = new Document(undefined, opts);
|
|
5456
4904
|
if (this.atDirectives)
|
|
5457
4905
|
this.onError(endOffset, 'MISSING_CHAR', 'Missing directives-end indicator line');
|
|
5458
4906
|
doc.range = [0, endOffset, endOffset];
|
|
@@ -5462,17 +4910,6 @@ class Composer$1 {
|
|
|
5462
4910
|
}
|
|
5463
4911
|
}
|
|
5464
4912
|
|
|
5465
|
-
composer$2.Composer = Composer$1;
|
|
5466
|
-
|
|
5467
|
-
var cst$3 = {};
|
|
5468
|
-
|
|
5469
|
-
var cstScalar$1 = {};
|
|
5470
|
-
|
|
5471
|
-
var resolveBlockScalar = resolveBlockScalar$3;
|
|
5472
|
-
var resolveFlowScalar = resolveFlowScalar$3;
|
|
5473
|
-
var errors$2 = errors$4;
|
|
5474
|
-
var stringifyString = stringifyString$5;
|
|
5475
|
-
|
|
5476
4913
|
function resolveAsScalar(token, strict = true, onError) {
|
|
5477
4914
|
if (token) {
|
|
5478
4915
|
const _onError = (pos, code, message) => {
|
|
@@ -5480,15 +4917,15 @@ function resolveAsScalar(token, strict = true, onError) {
|
|
|
5480
4917
|
if (onError)
|
|
5481
4918
|
onError(offset, code, message);
|
|
5482
4919
|
else
|
|
5483
|
-
throw new
|
|
4920
|
+
throw new YAMLParseError([offset, offset + 1], code, message);
|
|
5484
4921
|
};
|
|
5485
4922
|
switch (token.type) {
|
|
5486
4923
|
case 'scalar':
|
|
5487
4924
|
case 'single-quoted-scalar':
|
|
5488
4925
|
case 'double-quoted-scalar':
|
|
5489
|
-
return resolveFlowScalar
|
|
4926
|
+
return resolveFlowScalar(token, strict, _onError);
|
|
5490
4927
|
case 'block-scalar':
|
|
5491
|
-
return resolveBlockScalar
|
|
4928
|
+
return resolveBlockScalar(token, strict, _onError);
|
|
5492
4929
|
}
|
|
5493
4930
|
}
|
|
5494
4931
|
return null;
|
|
@@ -5509,7 +4946,7 @@ function resolveAsScalar(token, strict = true, onError) {
|
|
|
5509
4946
|
*/
|
|
5510
4947
|
function createScalarToken(value, context) {
|
|
5511
4948
|
const { implicitKey = false, indent, inFlow = false, offset = -1, type = 'PLAIN' } = context;
|
|
5512
|
-
const source = stringifyString
|
|
4949
|
+
const source = stringifyString({ type, value }, {
|
|
5513
4950
|
implicitKey,
|
|
5514
4951
|
indent: indent > 0 ? ' '.repeat(indent) : '',
|
|
5515
4952
|
inFlow,
|
|
@@ -5578,7 +5015,7 @@ function setScalarValue(token, value, context = {}) {
|
|
|
5578
5015
|
default:
|
|
5579
5016
|
type = 'PLAIN';
|
|
5580
5017
|
}
|
|
5581
|
-
const source = stringifyString
|
|
5018
|
+
const source = stringifyString({ type, value }, {
|
|
5582
5019
|
implicitKey: implicitKey || indent === null,
|
|
5583
5020
|
indent: indent !== null && indent > 0 ? ' '.repeat(indent) : '',
|
|
5584
5021
|
inFlow,
|
|
@@ -5681,19 +5118,13 @@ function setFlowScalarValue(token, source, type) {
|
|
|
5681
5118
|
}
|
|
5682
5119
|
}
|
|
5683
5120
|
|
|
5684
|
-
cstScalar$1.createScalarToken = createScalarToken;
|
|
5685
|
-
cstScalar$1.resolveAsScalar = resolveAsScalar;
|
|
5686
|
-
cstScalar$1.setScalarValue = setScalarValue;
|
|
5687
|
-
|
|
5688
|
-
var cstStringify$1 = {};
|
|
5689
|
-
|
|
5690
5121
|
/**
|
|
5691
5122
|
* Stringify a CST document, token, or collection item
|
|
5692
5123
|
*
|
|
5693
5124
|
* Fair warning: This applies no validation whatsoever, and
|
|
5694
5125
|
* simply concatenates the sources in their logical order.
|
|
5695
5126
|
*/
|
|
5696
|
-
const stringify$
|
|
5127
|
+
const stringify$1 = (cst) => 'type' in cst ? stringifyToken(cst) : stringifyItem(cst);
|
|
5697
5128
|
function stringifyToken(token) {
|
|
5698
5129
|
switch (token.type) {
|
|
5699
5130
|
case 'block-scalar': {
|
|
@@ -5747,10 +5178,6 @@ function stringifyItem({ start, key, sep, value }) {
|
|
|
5747
5178
|
return res;
|
|
5748
5179
|
}
|
|
5749
5180
|
|
|
5750
|
-
cstStringify$1.stringify = stringify$2;
|
|
5751
|
-
|
|
5752
|
-
var cstVisit$1 = {};
|
|
5753
|
-
|
|
5754
5181
|
const BREAK = Symbol('break visit');
|
|
5755
5182
|
const SKIP = Symbol('skip children');
|
|
5756
5183
|
const REMOVE = Symbol('remove item');
|
|
@@ -5782,7 +5209,7 @@ const REMOVE = Symbol('remove item');
|
|
|
5782
5209
|
* visitor is called on item entry, next visitors are called after handling
|
|
5783
5210
|
* a non-empty `key` and when exiting the item.
|
|
5784
5211
|
*/
|
|
5785
|
-
function visit
|
|
5212
|
+
function visit(cst, visitor) {
|
|
5786
5213
|
if ('type' in cst && cst.type === 'document')
|
|
5787
5214
|
cst = { start: cst.start, value: cst.value };
|
|
5788
5215
|
_visit(Object.freeze([]), cst, visitor);
|
|
@@ -5791,13 +5218,13 @@ function visit$1(cst, visitor) {
|
|
|
5791
5218
|
// namespace using `var`, but then complains about that because
|
|
5792
5219
|
// `unique symbol` must be `const`.
|
|
5793
5220
|
/** Terminate visit traversal completely */
|
|
5794
|
-
visit
|
|
5221
|
+
visit.BREAK = BREAK;
|
|
5795
5222
|
/** Do not visit the children of the current item */
|
|
5796
|
-
visit
|
|
5223
|
+
visit.SKIP = SKIP;
|
|
5797
5224
|
/** Remove the current item */
|
|
5798
|
-
visit
|
|
5225
|
+
visit.REMOVE = REMOVE;
|
|
5799
5226
|
/** Find the item at `path` from `cst` as the root */
|
|
5800
|
-
visit
|
|
5227
|
+
visit.itemAtPath = (cst, path) => {
|
|
5801
5228
|
let item = cst;
|
|
5802
5229
|
for (const [field, index] of path) {
|
|
5803
5230
|
const tok = item?.[field];
|
|
@@ -5814,8 +5241,8 @@ visit$1.itemAtPath = (cst, path) => {
|
|
|
5814
5241
|
*
|
|
5815
5242
|
* Throws an error if the collection is not found, which should never happen if the item itself exists.
|
|
5816
5243
|
*/
|
|
5817
|
-
visit
|
|
5818
|
-
const parent = visit
|
|
5244
|
+
visit.parentCollection = (cst, path) => {
|
|
5245
|
+
const parent = visit.itemAtPath(cst, path.slice(0, -1));
|
|
5819
5246
|
const field = path[path.length - 1][0];
|
|
5820
5247
|
const coll = parent?.[field];
|
|
5821
5248
|
if (coll && 'items' in coll)
|
|
@@ -5847,12 +5274,6 @@ function _visit(path, item, visitor) {
|
|
|
5847
5274
|
return typeof ctrl === 'function' ? ctrl(item, path) : ctrl;
|
|
5848
5275
|
}
|
|
5849
5276
|
|
|
5850
|
-
cstVisit$1.visit = visit$1;
|
|
5851
|
-
|
|
5852
|
-
var cstScalar = cstScalar$1;
|
|
5853
|
-
var cstStringify = cstStringify$1;
|
|
5854
|
-
var cstVisit = cstVisit$1;
|
|
5855
|
-
|
|
5856
5277
|
/** The byte order mark */
|
|
5857
5278
|
const BOM = '\u{FEFF}';
|
|
5858
5279
|
/** Start of doc-mode */
|
|
@@ -5862,9 +5283,9 @@ const FLOW_END = '\x18'; // C0: Cancel
|
|
|
5862
5283
|
/** Next token is a scalar value */
|
|
5863
5284
|
const SCALAR = '\x1f'; // C0: Unit Separator
|
|
5864
5285
|
/** @returns `true` if `token` is a flow or block collection */
|
|
5865
|
-
const isCollection
|
|
5286
|
+
const isCollection = (token) => !!token && 'items' in token;
|
|
5866
5287
|
/** @returns `true` if `token` is a flow or block scalar; not an alias */
|
|
5867
|
-
const isScalar
|
|
5288
|
+
const isScalar = (token) => !!token &&
|
|
5868
5289
|
(token.type === 'scalar' ||
|
|
5869
5290
|
token.type === 'single-quoted-scalar' ||
|
|
5870
5291
|
token.type === 'double-quoted-scalar' ||
|
|
@@ -5946,23 +5367,22 @@ function tokenType(source) {
|
|
|
5946
5367
|
return null;
|
|
5947
5368
|
}
|
|
5948
5369
|
|
|
5949
|
-
cst
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
var cst$2 = cst$3;
|
|
5370
|
+
var cst = /*#__PURE__*/Object.freeze({
|
|
5371
|
+
__proto__: null,
|
|
5372
|
+
BOM: BOM,
|
|
5373
|
+
DOCUMENT: DOCUMENT,
|
|
5374
|
+
FLOW_END: FLOW_END,
|
|
5375
|
+
SCALAR: SCALAR,
|
|
5376
|
+
isCollection: isCollection,
|
|
5377
|
+
isScalar: isScalar,
|
|
5378
|
+
prettyToken: prettyToken,
|
|
5379
|
+
tokenType: tokenType,
|
|
5380
|
+
createScalarToken: createScalarToken,
|
|
5381
|
+
resolveAsScalar: resolveAsScalar,
|
|
5382
|
+
setScalarValue: setScalarValue,
|
|
5383
|
+
stringify: stringify$1,
|
|
5384
|
+
visit: visit
|
|
5385
|
+
});
|
|
5966
5386
|
|
|
5967
5387
|
/*
|
|
5968
5388
|
START -> stream
|
|
@@ -6063,7 +5483,7 @@ const isNotAnchorChar = (ch) => !ch || invalidAnchorChars.includes(ch);
|
|
|
6063
5483
|
* - `\x1f` (Unit Separator): Next token is a scalar value
|
|
6064
5484
|
* - `\u{FEFF}` (Byte order mark): Emitted separately outside documents
|
|
6065
5485
|
*/
|
|
6066
|
-
class Lexer
|
|
5486
|
+
class Lexer {
|
|
6067
5487
|
constructor() {
|
|
6068
5488
|
/**
|
|
6069
5489
|
* Flag indicating whether the end of the current buffer marks the end of
|
|
@@ -6206,7 +5626,7 @@ class Lexer$1 {
|
|
|
6206
5626
|
let line = this.getLine();
|
|
6207
5627
|
if (line === null)
|
|
6208
5628
|
return this.setNext('stream');
|
|
6209
|
-
if (line[0] ===
|
|
5629
|
+
if (line[0] === BOM) {
|
|
6210
5630
|
yield* this.pushCount(1);
|
|
6211
5631
|
line = line.substring(1);
|
|
6212
5632
|
}
|
|
@@ -6236,7 +5656,7 @@ class Lexer$1 {
|
|
|
6236
5656
|
yield* this.pushNewline();
|
|
6237
5657
|
return 'stream';
|
|
6238
5658
|
}
|
|
6239
|
-
yield
|
|
5659
|
+
yield DOCUMENT;
|
|
6240
5660
|
return yield* this.parseLineStart();
|
|
6241
5661
|
}
|
|
6242
5662
|
*parseLineStart() {
|
|
@@ -6346,7 +5766,7 @@ class Lexer$1 {
|
|
|
6346
5766
|
if (!atFlowEndMarker) {
|
|
6347
5767
|
// this is an error
|
|
6348
5768
|
this.flowLevel = 0;
|
|
6349
|
-
yield
|
|
5769
|
+
yield FLOW_END;
|
|
6350
5770
|
return yield* this.parseLineStart();
|
|
6351
5771
|
}
|
|
6352
5772
|
}
|
|
@@ -6511,7 +5931,7 @@ class Lexer$1 {
|
|
|
6511
5931
|
break;
|
|
6512
5932
|
} while (true);
|
|
6513
5933
|
}
|
|
6514
|
-
yield
|
|
5934
|
+
yield SCALAR;
|
|
6515
5935
|
yield* this.pushToIndex(nl + 1, true);
|
|
6516
5936
|
return yield* this.parseLineStart();
|
|
6517
5937
|
}
|
|
@@ -6555,7 +5975,7 @@ class Lexer$1 {
|
|
|
6555
5975
|
}
|
|
6556
5976
|
if (!ch && !this.atEnd)
|
|
6557
5977
|
return this.setNext('plain-scalar');
|
|
6558
|
-
yield
|
|
5978
|
+
yield SCALAR;
|
|
6559
5979
|
yield* this.pushToIndex(end + 1, true);
|
|
6560
5980
|
return inFlow ? 'flow' : 'doc';
|
|
6561
5981
|
}
|
|
@@ -6662,16 +6082,12 @@ class Lexer$1 {
|
|
|
6662
6082
|
}
|
|
6663
6083
|
}
|
|
6664
6084
|
|
|
6665
|
-
lexer$2.Lexer = Lexer$1;
|
|
6666
|
-
|
|
6667
|
-
var lineCounter$2 = {};
|
|
6668
|
-
|
|
6669
6085
|
/**
|
|
6670
6086
|
* Tracks newlines during parsing in order to provide an efficient API for
|
|
6671
6087
|
* determining the one-indexed `{ line, col }` position for any offset
|
|
6672
6088
|
* within the input.
|
|
6673
6089
|
*/
|
|
6674
|
-
class LineCounter
|
|
6090
|
+
class LineCounter {
|
|
6675
6091
|
constructor() {
|
|
6676
6092
|
this.lineStarts = [];
|
|
6677
6093
|
/**
|
|
@@ -6704,13 +6120,6 @@ class LineCounter$1 {
|
|
|
6704
6120
|
}
|
|
6705
6121
|
}
|
|
6706
6122
|
|
|
6707
|
-
lineCounter$2.LineCounter = LineCounter$1;
|
|
6708
|
-
|
|
6709
|
-
var parser$2 = {};
|
|
6710
|
-
|
|
6711
|
-
var cst$1 = cst$3;
|
|
6712
|
-
var lexer$1 = lexer$2;
|
|
6713
|
-
|
|
6714
6123
|
function includesToken(list, type) {
|
|
6715
6124
|
for (let i = 0; i < list.length; ++i)
|
|
6716
6125
|
if (list[i].type === type)
|
|
@@ -6827,7 +6236,7 @@ function fixFlowSeqItems(fc) {
|
|
|
6827
6236
|
* }
|
|
6828
6237
|
* ```
|
|
6829
6238
|
*/
|
|
6830
|
-
class Parser
|
|
6239
|
+
class Parser {
|
|
6831
6240
|
/**
|
|
6832
6241
|
* @param onNewLine - If defined, called separately with the start position of
|
|
6833
6242
|
* each new line (in `parse()`, including the start of input).
|
|
@@ -6850,7 +6259,7 @@ class Parser$1 {
|
|
|
6850
6259
|
/** The type of the current token, set in parse() */
|
|
6851
6260
|
this.type = '';
|
|
6852
6261
|
// Must be defined after `next()`
|
|
6853
|
-
this.lexer = new
|
|
6262
|
+
this.lexer = new Lexer();
|
|
6854
6263
|
this.onNewLine = onNewLine;
|
|
6855
6264
|
}
|
|
6856
6265
|
/**
|
|
@@ -6874,15 +6283,13 @@ class Parser$1 {
|
|
|
6874
6283
|
*/
|
|
6875
6284
|
*next(source) {
|
|
6876
6285
|
this.source = source;
|
|
6877
|
-
if (process.env.LOG_TOKENS)
|
|
6878
|
-
console.log('|', cst$1.prettyToken(source));
|
|
6879
6286
|
if (this.atScalar) {
|
|
6880
6287
|
this.atScalar = false;
|
|
6881
6288
|
yield* this.step();
|
|
6882
6289
|
this.offset += source.length;
|
|
6883
6290
|
return;
|
|
6884
6291
|
}
|
|
6885
|
-
const type =
|
|
6292
|
+
const type = tokenType(source);
|
|
6886
6293
|
if (!type) {
|
|
6887
6294
|
const message = `Not a YAML token: ${source}`;
|
|
6888
6295
|
yield* this.pop({ type: 'error', offset: this.offset, message, source });
|
|
@@ -7659,21 +7066,10 @@ class Parser$1 {
|
|
|
7659
7066
|
}
|
|
7660
7067
|
}
|
|
7661
7068
|
|
|
7662
|
-
parser$2.Parser = Parser$1;
|
|
7663
|
-
|
|
7664
|
-
var publicApi$1 = {};
|
|
7665
|
-
|
|
7666
|
-
var composer$1 = composer$2;
|
|
7667
|
-
var Document$1 = Document$5;
|
|
7668
|
-
var errors$1 = errors$4;
|
|
7669
|
-
var log = log$2;
|
|
7670
|
-
var lineCounter$1 = lineCounter$2;
|
|
7671
|
-
var parser$1 = parser$2;
|
|
7672
|
-
|
|
7673
7069
|
function parseOptions(options) {
|
|
7674
7070
|
const prettyErrors = options.prettyErrors !== false;
|
|
7675
|
-
const lineCounter
|
|
7676
|
-
return { lineCounter
|
|
7071
|
+
const lineCounter = options.lineCounter || (prettyErrors && new LineCounter()) || null;
|
|
7072
|
+
return { lineCounter, prettyErrors };
|
|
7677
7073
|
}
|
|
7678
7074
|
/**
|
|
7679
7075
|
* Parse the input as a stream of YAML documents.
|
|
@@ -7684,42 +7080,42 @@ function parseOptions(options) {
|
|
|
7684
7080
|
* EmptyStream and contain additional stream information. In
|
|
7685
7081
|
* TypeScript, you should use `'empty' in docs` as a type guard for it.
|
|
7686
7082
|
*/
|
|
7687
|
-
function parseAllDocuments
|
|
7083
|
+
function parseAllDocuments(source, options = {}) {
|
|
7688
7084
|
const { lineCounter, prettyErrors } = parseOptions(options);
|
|
7689
|
-
const parser
|
|
7690
|
-
const composer
|
|
7691
|
-
const docs = Array.from(composer
|
|
7085
|
+
const parser = new Parser(lineCounter?.addNewLine);
|
|
7086
|
+
const composer = new Composer(options);
|
|
7087
|
+
const docs = Array.from(composer.compose(parser.parse(source)));
|
|
7692
7088
|
if (prettyErrors && lineCounter)
|
|
7693
7089
|
for (const doc of docs) {
|
|
7694
|
-
doc.errors.forEach(
|
|
7695
|
-
doc.warnings.forEach(
|
|
7090
|
+
doc.errors.forEach(prettifyError(source, lineCounter));
|
|
7091
|
+
doc.warnings.forEach(prettifyError(source, lineCounter));
|
|
7696
7092
|
}
|
|
7697
7093
|
if (docs.length > 0)
|
|
7698
7094
|
return docs;
|
|
7699
|
-
return Object.assign([], { empty: true }, composer
|
|
7095
|
+
return Object.assign([], { empty: true }, composer.streamInfo());
|
|
7700
7096
|
}
|
|
7701
7097
|
/** Parse an input string into a single YAML.Document */
|
|
7702
|
-
function parseDocument
|
|
7098
|
+
function parseDocument(source, options = {}) {
|
|
7703
7099
|
const { lineCounter, prettyErrors } = parseOptions(options);
|
|
7704
|
-
const parser
|
|
7705
|
-
const composer
|
|
7100
|
+
const parser = new Parser(lineCounter?.addNewLine);
|
|
7101
|
+
const composer = new Composer(options);
|
|
7706
7102
|
// `doc` is always set by compose.end(true) at the very latest
|
|
7707
7103
|
let doc = null;
|
|
7708
|
-
for (const _doc of composer
|
|
7104
|
+
for (const _doc of composer.compose(parser.parse(source), true, source.length)) {
|
|
7709
7105
|
if (!doc)
|
|
7710
7106
|
doc = _doc;
|
|
7711
7107
|
else if (doc.options.logLevel !== 'silent') {
|
|
7712
|
-
doc.errors.push(new
|
|
7108
|
+
doc.errors.push(new YAMLParseError(_doc.range.slice(0, 2), 'MULTIPLE_DOCS', 'Source contains multiple documents; please use YAML.parseAllDocuments()'));
|
|
7713
7109
|
break;
|
|
7714
7110
|
}
|
|
7715
7111
|
}
|
|
7716
7112
|
if (prettyErrors && lineCounter) {
|
|
7717
|
-
doc.errors.forEach(
|
|
7718
|
-
doc.warnings.forEach(
|
|
7113
|
+
doc.errors.forEach(prettifyError(source, lineCounter));
|
|
7114
|
+
doc.warnings.forEach(prettifyError(source, lineCounter));
|
|
7719
7115
|
}
|
|
7720
7116
|
return doc;
|
|
7721
7117
|
}
|
|
7722
|
-
function parse
|
|
7118
|
+
function parse(src, reviver, options) {
|
|
7723
7119
|
let _reviver = undefined;
|
|
7724
7120
|
if (typeof reviver === 'function') {
|
|
7725
7121
|
_reviver = reviver;
|
|
@@ -7727,10 +7123,10 @@ function parse$1(src, reviver, options) {
|
|
|
7727
7123
|
else if (options === undefined && reviver && typeof reviver === 'object') {
|
|
7728
7124
|
options = reviver;
|
|
7729
7125
|
}
|
|
7730
|
-
const doc = parseDocument
|
|
7126
|
+
const doc = parseDocument(src, options);
|
|
7731
7127
|
if (!doc)
|
|
7732
7128
|
return null;
|
|
7733
|
-
doc.warnings.forEach(warning =>
|
|
7129
|
+
doc.warnings.forEach(warning => warn(doc.options.logLevel, warning));
|
|
7734
7130
|
if (doc.errors.length > 0) {
|
|
7735
7131
|
if (doc.options.logLevel !== 'silent')
|
|
7736
7132
|
throw doc.errors[0];
|
|
@@ -7739,7 +7135,7 @@ function parse$1(src, reviver, options) {
|
|
|
7739
7135
|
}
|
|
7740
7136
|
return doc.toJS(Object.assign({ reviver: _reviver }, options));
|
|
7741
7137
|
}
|
|
7742
|
-
function stringify
|
|
7138
|
+
function stringify(value, replacer, options) {
|
|
7743
7139
|
let _replacer = null;
|
|
7744
7140
|
if (typeof replacer === 'function' || Array.isArray(replacer)) {
|
|
7745
7141
|
_replacer = replacer;
|
|
@@ -7758,86 +7154,31 @@ function stringify$1(value, replacer, options) {
|
|
|
7758
7154
|
if (!keepUndefined)
|
|
7759
7155
|
return undefined;
|
|
7760
7156
|
}
|
|
7761
|
-
return new Document
|
|
7157
|
+
return new Document(value, _replacer, options).toString(options);
|
|
7762
7158
|
}
|
|
7763
7159
|
|
|
7764
|
-
|
|
7765
|
-
publicApi$1.parseAllDocuments = parseAllDocuments$1;
|
|
7766
|
-
publicApi$1.parseDocument = parseDocument$1;
|
|
7767
|
-
publicApi$1.stringify = stringify$1;
|
|
7768
|
-
|
|
7769
|
-
var composer = composer$2;
|
|
7770
|
-
var Document = Document$5;
|
|
7771
|
-
var Schema = Schema$3;
|
|
7772
|
-
var errors = errors$4;
|
|
7773
|
-
var Alias = Alias$5;
|
|
7774
|
-
var Node = Node$t;
|
|
7775
|
-
var Pair = Pair$9;
|
|
7776
|
-
var Scalar = Scalar$k;
|
|
7777
|
-
var YAMLMap = YAMLMap$7;
|
|
7778
|
-
var YAMLSeq = YAMLSeq$7;
|
|
7779
|
-
var cst = cst$3;
|
|
7780
|
-
var lexer = lexer$2;
|
|
7781
|
-
var lineCounter = lineCounter$2;
|
|
7782
|
-
var parser = parser$2;
|
|
7783
|
-
var publicApi = publicApi$1;
|
|
7784
|
-
var visit = visit$6;
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
var Composer = dist.Composer = composer.Composer;
|
|
7789
|
-
var Document_1 = dist.Document = Document.Document;
|
|
7790
|
-
var Schema_1 = dist.Schema = Schema.Schema;
|
|
7791
|
-
var YAMLError = dist.YAMLError = errors.YAMLError;
|
|
7792
|
-
var YAMLParseError = dist.YAMLParseError = errors.YAMLParseError;
|
|
7793
|
-
var YAMLWarning = dist.YAMLWarning = errors.YAMLWarning;
|
|
7794
|
-
var Alias_1 = dist.Alias = Alias.Alias;
|
|
7795
|
-
var isAlias = dist.isAlias = Node.isAlias;
|
|
7796
|
-
var isCollection = dist.isCollection = Node.isCollection;
|
|
7797
|
-
var isDocument = dist.isDocument = Node.isDocument;
|
|
7798
|
-
var isMap = dist.isMap = Node.isMap;
|
|
7799
|
-
var isNode = dist.isNode = Node.isNode;
|
|
7800
|
-
var isPair = dist.isPair = Node.isPair;
|
|
7801
|
-
var isScalar = dist.isScalar = Node.isScalar;
|
|
7802
|
-
var isSeq = dist.isSeq = Node.isSeq;
|
|
7803
|
-
var Pair_1 = dist.Pair = Pair.Pair;
|
|
7804
|
-
var Scalar_1 = dist.Scalar = Scalar.Scalar;
|
|
7805
|
-
var YAMLMap_1 = dist.YAMLMap = YAMLMap.YAMLMap;
|
|
7806
|
-
var YAMLSeq_1 = dist.YAMLSeq = YAMLSeq.YAMLSeq;
|
|
7807
|
-
var CST = dist.CST = cst;
|
|
7808
|
-
var Lexer = dist.Lexer = lexer.Lexer;
|
|
7809
|
-
var LineCounter = dist.LineCounter = lineCounter.LineCounter;
|
|
7810
|
-
var Parser = dist.Parser = parser.Parser;
|
|
7811
|
-
var parse = dist.parse = publicApi.parse;
|
|
7812
|
-
var parseAllDocuments = dist.parseAllDocuments = publicApi.parseAllDocuments;
|
|
7813
|
-
var parseDocument = dist.parseDocument = publicApi.parseDocument;
|
|
7814
|
-
var stringify = dist.stringify = publicApi.stringify;
|
|
7815
|
-
var visit_1 = dist.visit = visit.visit;
|
|
7816
|
-
var visitAsync = dist.visitAsync = visit.visitAsync;
|
|
7817
|
-
|
|
7818
|
-
var index = /*#__PURE__*/_mergeNamespaces({
|
|
7160
|
+
var YAML = /*#__PURE__*/Object.freeze({
|
|
7819
7161
|
__proto__: null,
|
|
7820
|
-
|
|
7162
|
+
CST: cst,
|
|
7821
7163
|
Composer: Composer,
|
|
7822
|
-
Document:
|
|
7823
|
-
Schema:
|
|
7164
|
+
Document: Document,
|
|
7165
|
+
Schema: Schema,
|
|
7824
7166
|
YAMLError: YAMLError,
|
|
7825
7167
|
YAMLParseError: YAMLParseError,
|
|
7826
7168
|
YAMLWarning: YAMLWarning,
|
|
7827
|
-
Alias:
|
|
7169
|
+
Alias: Alias,
|
|
7828
7170
|
isAlias: isAlias,
|
|
7829
|
-
isCollection: isCollection,
|
|
7171
|
+
isCollection: isCollection$1,
|
|
7830
7172
|
isDocument: isDocument,
|
|
7831
7173
|
isMap: isMap,
|
|
7832
7174
|
isNode: isNode,
|
|
7833
7175
|
isPair: isPair,
|
|
7834
|
-
isScalar: isScalar,
|
|
7176
|
+
isScalar: isScalar$1,
|
|
7835
7177
|
isSeq: isSeq,
|
|
7836
|
-
Pair:
|
|
7837
|
-
Scalar:
|
|
7838
|
-
YAMLMap:
|
|
7839
|
-
YAMLSeq:
|
|
7840
|
-
CST: CST,
|
|
7178
|
+
Pair: Pair,
|
|
7179
|
+
Scalar: Scalar,
|
|
7180
|
+
YAMLMap: YAMLMap,
|
|
7181
|
+
YAMLSeq: YAMLSeq,
|
|
7841
7182
|
Lexer: Lexer,
|
|
7842
7183
|
LineCounter: LineCounter,
|
|
7843
7184
|
Parser: Parser,
|
|
@@ -7845,8 +7186,10 @@ var index = /*#__PURE__*/_mergeNamespaces({
|
|
|
7845
7186
|
parseAllDocuments: parseAllDocuments,
|
|
7846
7187
|
parseDocument: parseDocument,
|
|
7847
7188
|
stringify: stringify,
|
|
7848
|
-
visit:
|
|
7189
|
+
visit: visit$1,
|
|
7849
7190
|
visitAsync: visitAsync
|
|
7850
|
-
}
|
|
7191
|
+
});
|
|
7192
|
+
|
|
7193
|
+
// `export * as default from ...` fails on Webpack v4
|
|
7851
7194
|
|
|
7852
|
-
export {
|
|
7195
|
+
export { Alias, cst as CST, Composer, Document, Lexer, LineCounter, Pair, Parser, Scalar, Schema, YAMLError, YAMLMap, YAMLParseError, YAMLSeq, YAMLWarning, YAML as default, isAlias, isCollection$1 as isCollection, isDocument, isMap, isNode, isPair, isScalar$1 as isScalar, isSeq, parse, parseAllDocuments, parseDocument, stringify, visit$1 as visit, visitAsync };
|