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