yaml 1.3.2 → 1.6.0
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/README.md +4 -6
- package/browser/dist/Anchors.js +12 -10
- package/browser/dist/Document.js +170 -75
- package/browser/dist/constants.js +34 -0
- package/browser/dist/cst/Alias.js +1 -3
- package/browser/dist/cst/BlankLine.js +5 -7
- package/browser/dist/cst/BlockValue.js +4 -4
- package/browser/dist/cst/Collection.js +8 -8
- package/browser/dist/cst/CollectionItem.js +6 -8
- package/browser/dist/cst/Comment.js +5 -7
- package/browser/dist/cst/Directive.js +5 -7
- package/browser/dist/cst/Document.js +17 -11
- package/browser/dist/cst/FlowCollection.js +14 -8
- package/browser/dist/cst/Node.js +12 -40
- package/browser/dist/cst/ParseContext.js +32 -34
- package/browser/dist/cst/PlainValue.js +1 -3
- package/browser/dist/cst/QuoteDouble.js +1 -3
- package/browser/dist/cst/QuoteSingle.js +1 -3
- package/browser/dist/cst/Range.js +1 -3
- package/browser/dist/cst/getLinePos.js +1 -4
- package/browser/dist/cst/parse.js +1 -4
- package/browser/dist/deprecation.js +34 -0
- package/browser/dist/errors.js +50 -59
- package/browser/dist/index.js +37 -7
- package/browser/dist/listTagNames.js +1 -3
- package/browser/dist/schema/Alias.js +90 -10
- package/browser/dist/schema/Collection.js +3 -3
- package/browser/dist/schema/Map.js +22 -105
- package/browser/dist/schema/Merge.js +74 -1
- package/browser/dist/schema/Node.js +1 -3
- package/browser/dist/schema/Pair.js +37 -23
- package/browser/dist/schema/Scalar.js +3 -5
- package/browser/dist/schema/Seq.js +30 -7
- package/browser/dist/schema/index.js +158 -82
- package/browser/dist/schema/parseMap.js +18 -21
- package/browser/dist/schema/parseSeq.js +9 -12
- package/browser/dist/{schema/_string.js → stringify.js} +65 -73
- package/browser/dist/tags/core.js +132 -0
- package/browser/dist/tags/failsafe/index.js +17 -0
- package/browser/dist/tags/failsafe/map.js +65 -0
- package/browser/dist/tags/failsafe/seq.js +54 -0
- package/browser/dist/tags/failsafe/string.js +40 -0
- package/browser/dist/tags/index.js +50 -0
- package/browser/dist/tags/json.js +103 -0
- package/browser/dist/tags/options.js +35 -0
- package/browser/dist/{schema/_binary.js → tags/yaml-1.1/binary.js} +20 -20
- package/browser/dist/tags/yaml-1.1/index.js +177 -0
- package/browser/dist/{schema/_omap.js → tags/yaml-1.1/omap.js} +25 -25
- package/browser/dist/{schema/_pairs.js → tags/yaml-1.1/pairs.js} +9 -13
- package/browser/dist/tags/yaml-1.1/set.js +140 -0
- package/browser/dist/{schema/_timestamp.js → tags/yaml-1.1/timestamp.js} +13 -10
- package/browser/dist/test-events.js +1 -4
- package/browser/dist/toJSON.js +20 -8
- package/browser/index.js +1 -0
- package/browser/map.js +2 -1
- package/browser/pair.js +2 -1
- package/browser/parse-cst.js +1 -1
- package/browser/scalar.js +2 -1
- package/browser/schema.js +7 -3
- package/browser/seq.js +2 -1
- package/browser/types/binary.js +7 -1
- package/browser/types/omap.js +2 -1
- package/browser/types/pairs.js +2 -1
- package/browser/types/set.js +2 -1
- package/browser/types/timestamp.js +10 -1
- package/browser/types.js +11 -0
- package/browser/util.js +15 -0
- package/dist/Anchors.js +9 -8
- package/dist/Document.js +89 -45
- package/dist/constants.js +34 -0
- package/dist/cst/Alias.js +1 -3
- package/dist/cst/BlankLine.js +5 -7
- package/dist/cst/BlockValue.js +4 -4
- package/dist/cst/Collection.js +8 -8
- package/dist/cst/CollectionItem.js +6 -8
- package/dist/cst/Comment.js +5 -7
- package/dist/cst/Directive.js +5 -7
- package/dist/cst/Document.js +17 -11
- package/dist/cst/FlowCollection.js +14 -8
- package/dist/cst/Node.js +12 -40
- package/dist/cst/ParseContext.js +32 -34
- package/dist/cst/PlainValue.js +1 -3
- package/dist/cst/QuoteDouble.js +1 -3
- package/dist/cst/QuoteSingle.js +1 -3
- package/dist/cst/Range.js +1 -3
- package/dist/cst/getLinePos.js +1 -4
- package/dist/cst/parse.js +1 -4
- package/dist/deprecation.js +34 -0
- package/dist/errors.js +29 -35
- package/dist/index.js +18 -5
- package/dist/listTagNames.js +1 -3
- package/dist/schema/Alias.js +67 -12
- package/dist/schema/Map.js +10 -74
- package/dist/schema/Merge.js +31 -0
- package/dist/schema/Node.js +1 -3
- package/dist/schema/Pair.js +30 -16
- package/dist/schema/Scalar.js +3 -5
- package/dist/schema/Seq.js +9 -5
- package/dist/schema/index.js +109 -74
- package/dist/schema/parseMap.js +18 -21
- package/dist/schema/parseSeq.js +9 -12
- package/dist/{schema/_string.js → stringify.js} +56 -65
- package/dist/tags/core.js +96 -0
- package/dist/tags/failsafe/index.js +17 -0
- package/dist/tags/failsafe/map.js +33 -0
- package/dist/tags/failsafe/seq.js +34 -0
- package/dist/tags/failsafe/string.js +40 -0
- package/dist/tags/index.js +50 -0
- package/dist/tags/json.js +67 -0
- package/dist/tags/options.js +35 -0
- package/dist/{schema/_binary.js → tags/yaml-1.1/binary.js} +18 -20
- package/dist/tags/yaml-1.1/index.js +131 -0
- package/dist/{schema/_omap.js → tags/yaml-1.1/omap.js} +16 -16
- package/dist/{schema/_pairs.js → tags/yaml-1.1/pairs.js} +9 -11
- package/dist/{schema/_set.js → tags/yaml-1.1/set.js} +12 -44
- package/dist/{schema/_timestamp.js → tags/yaml-1.1/timestamp.js} +7 -10
- package/dist/test-events.js +1 -4
- package/dist/toJSON.js +15 -5
- package/index.js +1 -0
- package/map.js +2 -1
- package/package.json +23 -17
- package/pair.js +2 -1
- package/parse-cst.js +1 -1
- package/scalar.js +2 -1
- package/schema.js +7 -3
- package/seq.js +2 -1
- package/types/binary.js +7 -1
- package/types/omap.js +2 -1
- package/types/pairs.js +2 -1
- package/types/set.js +2 -1
- package/types/timestamp.js +10 -1
- package/types.js +11 -0
- package/util.js +15 -0
- package/browser/dist/polyfill.js +0 -251
- package/browser/dist/schema/_set.js +0 -212
- package/browser/dist/schema/core.js +0 -98
- package/browser/dist/schema/failsafe.js +0 -125
- package/browser/dist/schema/json.js +0 -66
- package/browser/dist/schema/yaml-1.1.js +0 -140
- package/dist/polyfill.js +0 -27
- package/dist/schema/core.js +0 -79
- package/dist/schema/failsafe.js +0 -74
- package/dist/schema/json.js +0 -56
- package/dist/schema/yaml-1.1.js +0 -115
package/dist/Document.js
CHANGED
|
@@ -9,7 +9,7 @@ var _addComment = _interopRequireDefault(require("./addComment"));
|
|
|
9
9
|
|
|
10
10
|
var _Anchors = _interopRequireDefault(require("./Anchors"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _constants = require("./constants");
|
|
13
13
|
|
|
14
14
|
var _errors = require("./errors");
|
|
15
15
|
|
|
@@ -21,7 +21,7 @@ var _Alias = _interopRequireDefault(require("./schema/Alias"));
|
|
|
21
21
|
|
|
22
22
|
var _Collection = _interopRequireWildcard(require("./schema/Collection"));
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _Node = _interopRequireDefault(require("./schema/Node"));
|
|
25
25
|
|
|
26
26
|
var _Scalar = _interopRequireDefault(require("./schema/Scalar"));
|
|
27
27
|
|
|
@@ -33,14 +33,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
33
33
|
|
|
34
34
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
35
|
|
|
36
|
-
const isCollectionItem = node => node && [
|
|
36
|
+
const isCollectionItem = node => node && [_constants.Type.MAP_KEY, _constants.Type.MAP_VALUE, _constants.Type.SEQ_ITEM].includes(node.type);
|
|
37
37
|
|
|
38
38
|
class Document {
|
|
39
39
|
constructor(options) {
|
|
40
|
-
this.anchors = new _Anchors.default();
|
|
40
|
+
this.anchors = new _Anchors.default(options.anchorPrefix);
|
|
41
41
|
this.commentBefore = null;
|
|
42
42
|
this.comment = null;
|
|
43
43
|
this.contents = null;
|
|
44
|
+
this.directivesEndMarker = null;
|
|
44
45
|
this.errors = [];
|
|
45
46
|
this.options = options;
|
|
46
47
|
this.schema = null;
|
|
@@ -118,12 +119,13 @@ class Document {
|
|
|
118
119
|
if (!this.schema) this.schema = new _schema.default(Object.assign({}, this.getDefaults(), this.options));
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
parse(node) {
|
|
122
|
+
parse(node, prevDoc) {
|
|
122
123
|
if (this.options.keepCstNodes) this.cstNode = node;
|
|
123
124
|
if (this.options.keepNodeTypes) this.type = 'DOCUMENT';
|
|
124
125
|
const {
|
|
125
126
|
directives = [],
|
|
126
127
|
contents = [],
|
|
128
|
+
directivesEndMarker,
|
|
127
129
|
error,
|
|
128
130
|
valueRange
|
|
129
131
|
} = node;
|
|
@@ -133,7 +135,26 @@ class Document {
|
|
|
133
135
|
this.errors.push(error);
|
|
134
136
|
}
|
|
135
137
|
|
|
138
|
+
this.parseDirectives(directives, prevDoc);
|
|
139
|
+
if (directivesEndMarker) this.directivesEndMarker = true;
|
|
140
|
+
this.range = valueRange ? [valueRange.start, valueRange.end] : null;
|
|
141
|
+
this.setSchema();
|
|
142
|
+
this.anchors._cstAliases = [];
|
|
143
|
+
this.parseContents(contents);
|
|
144
|
+
this.anchors.resolveNodes();
|
|
145
|
+
|
|
146
|
+
if (this.options.prettyErrors) {
|
|
147
|
+
for (const error of this.errors) if (error instanceof _errors.YAMLError) error.makePretty();
|
|
148
|
+
|
|
149
|
+
for (const warn of this.warnings) if (warn instanceof _errors.YAMLError) warn.makePretty();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
parseDirectives(directives, prevDoc) {
|
|
136
156
|
const directiveComments = [];
|
|
157
|
+
let hasDirectives = false;
|
|
137
158
|
directives.forEach(directive => {
|
|
138
159
|
const {
|
|
139
160
|
comment,
|
|
@@ -143,11 +164,13 @@ class Document {
|
|
|
143
164
|
switch (name) {
|
|
144
165
|
case 'TAG':
|
|
145
166
|
this.resolveTagDirective(directive);
|
|
167
|
+
hasDirectives = true;
|
|
146
168
|
break;
|
|
147
169
|
|
|
148
170
|
case 'YAML':
|
|
149
171
|
case 'YAML:1.0':
|
|
150
172
|
this.resolveYamlDirective(directive);
|
|
173
|
+
hasDirectives = true;
|
|
151
174
|
break;
|
|
152
175
|
|
|
153
176
|
default:
|
|
@@ -160,10 +183,24 @@ class Document {
|
|
|
160
183
|
|
|
161
184
|
if (comment) directiveComments.push(comment);
|
|
162
185
|
});
|
|
163
|
-
|
|
164
|
-
this.
|
|
165
|
-
|
|
186
|
+
|
|
187
|
+
if (prevDoc && !hasDirectives && '1.1' === (this.version || prevDoc.version || this.options.version)) {
|
|
188
|
+
const copyTagPrefix = ({
|
|
189
|
+
handle,
|
|
190
|
+
prefix
|
|
191
|
+
}) => ({
|
|
192
|
+
handle,
|
|
193
|
+
prefix
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
this.tagPrefixes = prevDoc.tagPrefixes.map(copyTagPrefix);
|
|
197
|
+
this.version = prevDoc.version;
|
|
198
|
+
}
|
|
199
|
+
|
|
166
200
|
this.commentBefore = directiveComments.join('\n') || null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
parseContents(contents) {
|
|
167
204
|
const comments = {
|
|
168
205
|
before: [],
|
|
169
206
|
after: []
|
|
@@ -188,7 +225,7 @@ class Document {
|
|
|
188
225
|
} else if (node.comment !== null) {
|
|
189
226
|
const cc = contentNodes.length === 0 ? comments.before : comments.after;
|
|
190
227
|
cc.push(node.comment);
|
|
191
|
-
} else if (node.type ===
|
|
228
|
+
} else if (node.type === _constants.Type.BLANK_LINE) {
|
|
192
229
|
spaceBefore = true;
|
|
193
230
|
|
|
194
231
|
if (contentNodes.length === 0 && comments.before.length > 0 && !this.commentBefore) {
|
|
@@ -233,8 +270,6 @@ class Document {
|
|
|
233
270
|
}
|
|
234
271
|
|
|
235
272
|
this.comment = comments.after.join('\n') || null;
|
|
236
|
-
this.anchors.resolveNodes();
|
|
237
|
-
return this;
|
|
238
273
|
}
|
|
239
274
|
|
|
240
275
|
resolveTagDirective(directive) {
|
|
@@ -331,21 +366,21 @@ class Document {
|
|
|
331
366
|
}
|
|
332
367
|
|
|
333
368
|
switch (type) {
|
|
334
|
-
case
|
|
335
|
-
case
|
|
336
|
-
case
|
|
337
|
-
case
|
|
369
|
+
case _constants.Type.BLOCK_FOLDED:
|
|
370
|
+
case _constants.Type.BLOCK_LITERAL:
|
|
371
|
+
case _constants.Type.QUOTE_DOUBLE:
|
|
372
|
+
case _constants.Type.QUOTE_SINGLE:
|
|
338
373
|
return _schema.default.defaultTags.STR;
|
|
339
374
|
|
|
340
|
-
case
|
|
341
|
-
case
|
|
375
|
+
case _constants.Type.FLOW_MAP:
|
|
376
|
+
case _constants.Type.MAP:
|
|
342
377
|
return _schema.default.defaultTags.MAP;
|
|
343
378
|
|
|
344
|
-
case
|
|
345
|
-
case
|
|
379
|
+
case _constants.Type.FLOW_SEQ:
|
|
380
|
+
case _constants.Type.SEQ:
|
|
346
381
|
return _schema.default.defaultTags.SEQ;
|
|
347
382
|
|
|
348
|
-
case
|
|
383
|
+
case _constants.Type.PLAIN:
|
|
349
384
|
return nonSpecific ? _schema.default.defaultTags.STR : null;
|
|
350
385
|
|
|
351
386
|
default:
|
|
@@ -375,7 +410,7 @@ class Document {
|
|
|
375
410
|
} = _ref;
|
|
376
411
|
|
|
377
412
|
switch (node.context.src[start]) {
|
|
378
|
-
case
|
|
413
|
+
case _constants.Char.COMMENT:
|
|
379
414
|
{
|
|
380
415
|
if (!node.commentHasRequiredWhitespace(start)) {
|
|
381
416
|
const msg = 'Comments must be separated from other tokens by white space characters';
|
|
@@ -396,7 +431,7 @@ class Document {
|
|
|
396
431
|
}
|
|
397
432
|
break;
|
|
398
433
|
|
|
399
|
-
case
|
|
434
|
+
case _constants.Char.ANCHOR:
|
|
400
435
|
if (hasAnchor) {
|
|
401
436
|
const msg = 'A node can have at most one anchor';
|
|
402
437
|
errors.push(new _errors.YAMLSemanticError(node, msg));
|
|
@@ -405,7 +440,7 @@ class Document {
|
|
|
405
440
|
hasAnchor = true;
|
|
406
441
|
break;
|
|
407
442
|
|
|
408
|
-
case
|
|
443
|
+
case _constants.Char.TAG:
|
|
409
444
|
if (hasTag) {
|
|
410
445
|
const msg = 'A node can have at most one tag';
|
|
411
446
|
errors.push(new _errors.YAMLSemanticError(node, msg));
|
|
@@ -430,7 +465,7 @@ class Document {
|
|
|
430
465
|
|
|
431
466
|
let res;
|
|
432
467
|
|
|
433
|
-
if (node.type ===
|
|
468
|
+
if (node.type === _constants.Type.ALIAS) {
|
|
434
469
|
if (hasAnchor || hasTag) {
|
|
435
470
|
const msg = 'An alias node must not specify any properties';
|
|
436
471
|
errors.push(new _errors.YAMLSemanticError(node, msg));
|
|
@@ -449,18 +484,13 @@ class Document {
|
|
|
449
484
|
res = new _Alias.default(src);
|
|
450
485
|
|
|
451
486
|
anchors._cstAliases.push(res);
|
|
452
|
-
|
|
453
|
-
if (!src.resolved) {
|
|
454
|
-
const msg = 'Alias node contains a circular reference, which cannot be resolved as JSON';
|
|
455
|
-
this.warnings.push(new _errors.YAMLWarning(node, msg));
|
|
456
|
-
}
|
|
457
487
|
} else {
|
|
458
488
|
const tagName = this.resolveTagName(node);
|
|
459
489
|
|
|
460
490
|
if (tagName) {
|
|
461
491
|
res = schema.resolveNodeWithFallback(this, node, tagName);
|
|
462
492
|
} else {
|
|
463
|
-
if (node.type !==
|
|
493
|
+
if (node.type !== _constants.Type.PLAIN) {
|
|
464
494
|
const msg = `Failed to resolve ${node.type} node here`;
|
|
465
495
|
errors.push(new _errors.YAMLSyntaxError(node, msg));
|
|
466
496
|
return null;
|
|
@@ -539,21 +569,32 @@ class Document {
|
|
|
539
569
|
}
|
|
540
570
|
|
|
541
571
|
toJSON(arg) {
|
|
542
|
-
const
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
572
|
+
const {
|
|
573
|
+
keepBlobsInJSON,
|
|
574
|
+
mapAsMap,
|
|
575
|
+
maxAliasCount
|
|
576
|
+
} = this.options;
|
|
577
|
+
const keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof _Scalar.default));
|
|
578
|
+
const ctx = {
|
|
579
|
+
doc: this,
|
|
547
580
|
keep,
|
|
548
|
-
mapAsMap
|
|
549
|
-
|
|
581
|
+
mapAsMap: keep && !!mapAsMap,
|
|
582
|
+
maxAliasCount
|
|
583
|
+
};
|
|
584
|
+
const anchorNames = Object.keys(this.anchors.map);
|
|
585
|
+
if (anchorNames.length > 0) ctx.anchors = anchorNames.map(name => ({
|
|
586
|
+
alias: [],
|
|
587
|
+
aliasCount: 0,
|
|
588
|
+
count: 1,
|
|
589
|
+
node: this.anchors.map[name]
|
|
590
|
+
}));
|
|
591
|
+
return (0, _toJSON.default)(this.contents, arg, ctx);
|
|
550
592
|
}
|
|
551
593
|
|
|
552
594
|
toString() {
|
|
553
595
|
if (this.errors.length > 0) throw new Error('Document with errors cannot be stringified');
|
|
554
596
|
this.setSchema();
|
|
555
597
|
const lines = [];
|
|
556
|
-
if (this.commentBefore) lines.push(this.commentBefore.replace(/^/gm, '#'), '');
|
|
557
598
|
let hasDirectives = false;
|
|
558
599
|
|
|
559
600
|
if (this.version) {
|
|
@@ -577,7 +618,13 @@ class Document {
|
|
|
577
618
|
hasDirectives = true;
|
|
578
619
|
}
|
|
579
620
|
});
|
|
580
|
-
if (hasDirectives) lines.push('---');
|
|
621
|
+
if (hasDirectives || this.directivesEndMarker) lines.push('---');
|
|
622
|
+
|
|
623
|
+
if (this.commentBefore) {
|
|
624
|
+
if (hasDirectives || !this.directivesEndMarker) lines.unshift('');
|
|
625
|
+
lines.unshift(this.commentBefore.replace(/^/gm, '#'));
|
|
626
|
+
}
|
|
627
|
+
|
|
581
628
|
const ctx = {
|
|
582
629
|
anchors: {},
|
|
583
630
|
doc: this,
|
|
@@ -587,8 +634,8 @@ class Document {
|
|
|
587
634
|
let contentComment = null;
|
|
588
635
|
|
|
589
636
|
if (this.contents) {
|
|
590
|
-
if (this.contents instanceof
|
|
591
|
-
if (this.contents.spaceBefore && hasDirectives) lines.push('');
|
|
637
|
+
if (this.contents instanceof _Node.default) {
|
|
638
|
+
if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push('');
|
|
592
639
|
if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment
|
|
593
640
|
|
|
594
641
|
ctx.forceBlockIndent = !!this.comment;
|
|
@@ -648,7 +695,4 @@ _defineProperty(Document, "defaults", {
|
|
|
648
695
|
prefix: _schema.default.defaultPrefix
|
|
649
696
|
}]
|
|
650
697
|
}
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
module.exports = exports.default;
|
|
654
|
-
module.exports.default = exports.default;
|
|
698
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Type = exports.Char = void 0;
|
|
7
|
+
const Char = {
|
|
8
|
+
ANCHOR: '&',
|
|
9
|
+
COMMENT: '#',
|
|
10
|
+
TAG: '!',
|
|
11
|
+
DIRECTIVES_END: '-',
|
|
12
|
+
DOCUMENT_END: '.'
|
|
13
|
+
};
|
|
14
|
+
exports.Char = Char;
|
|
15
|
+
const Type = {
|
|
16
|
+
ALIAS: 'ALIAS',
|
|
17
|
+
BLANK_LINE: 'BLANK_LINE',
|
|
18
|
+
BLOCK_FOLDED: 'BLOCK_FOLDED',
|
|
19
|
+
BLOCK_LITERAL: 'BLOCK_LITERAL',
|
|
20
|
+
COMMENT: 'COMMENT',
|
|
21
|
+
DIRECTIVE: 'DIRECTIVE',
|
|
22
|
+
DOCUMENT: 'DOCUMENT',
|
|
23
|
+
FLOW_MAP: 'FLOW_MAP',
|
|
24
|
+
FLOW_SEQ: 'FLOW_SEQ',
|
|
25
|
+
MAP: 'MAP',
|
|
26
|
+
MAP_KEY: 'MAP_KEY',
|
|
27
|
+
MAP_VALUE: 'MAP_VALUE',
|
|
28
|
+
PLAIN: 'PLAIN',
|
|
29
|
+
QUOTE_DOUBLE: 'QUOTE_DOUBLE',
|
|
30
|
+
QUOTE_SINGLE: 'QUOTE_SINGLE',
|
|
31
|
+
SEQ: 'SEQ',
|
|
32
|
+
SEQ_ITEM: 'SEQ_ITEM'
|
|
33
|
+
};
|
|
34
|
+
exports.Type = Type;
|
package/dist/cst/Alias.js
CHANGED
package/dist/cst/BlankLine.js
CHANGED
|
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
var _Node = _interopRequireDefault(require("./Node"));
|
|
9
11
|
|
|
10
12
|
var _Range = _interopRequireDefault(require("./Range"));
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
15
|
-
|
|
16
16
|
class BlankLine extends _Node.default {
|
|
17
17
|
constructor() {
|
|
18
|
-
super(
|
|
18
|
+
super(_constants.Type.BLANK_LINE);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
get includesTrailingLines() {
|
|
@@ -49,6 +49,4 @@ class BlankLine extends _Node.default {
|
|
|
49
49
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
exports.default = BlankLine;
|
|
53
|
-
module.exports = exports.default;
|
|
54
|
-
module.exports.default = exports.default;
|
|
52
|
+
exports.default = BlankLine;
|
package/dist/cst/BlockValue.js
CHANGED
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.Chomp = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
var _Node = _interopRequireDefault(require("./Node"));
|
|
9
11
|
|
|
10
12
|
var _Range = _interopRequireDefault(require("./Range"));
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
15
|
-
|
|
16
16
|
const Chomp = {
|
|
17
17
|
CLIP: 'CLIP',
|
|
18
18
|
KEEP: 'KEEP',
|
|
@@ -69,7 +69,7 @@ class BlockValue extends _Node.default {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const bi = indent + this.blockIndent;
|
|
72
|
-
const folded = this.type ===
|
|
72
|
+
const folded = this.type === _constants.Type.BLOCK_FOLDED;
|
|
73
73
|
let atStart = true;
|
|
74
74
|
let str = '';
|
|
75
75
|
let sep = '';
|
package/dist/cst/Collection.js
CHANGED
|
@@ -6,18 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.grabCollectionEndComments = grabCollectionEndComments;
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
|
|
9
|
+
var _constants = require("../constants");
|
|
10
|
+
|
|
9
11
|
var _BlankLine = _interopRequireDefault(require("./BlankLine"));
|
|
10
12
|
|
|
11
13
|
var _CollectionItem = _interopRequireDefault(require("./CollectionItem"));
|
|
12
14
|
|
|
13
15
|
var _Comment = _interopRequireDefault(require("./Comment"));
|
|
14
16
|
|
|
15
|
-
var _Node =
|
|
17
|
+
var _Node = _interopRequireDefault(require("./Node"));
|
|
16
18
|
|
|
17
19
|
var _Range = _interopRequireDefault(require("./Range"));
|
|
18
20
|
|
|
19
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
20
|
-
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
|
|
23
23
|
function grabCollectionEndComments(node) {
|
|
@@ -32,7 +32,7 @@ function grabCollectionEndComments(node) {
|
|
|
32
32
|
for (let i = len - 1; i >= 0; --i) {
|
|
33
33
|
const n = cnode.items[i];
|
|
34
34
|
|
|
35
|
-
if (n.type ===
|
|
35
|
+
if (n.type === _constants.Type.COMMENT) {
|
|
36
36
|
// Keep sufficiently indented comments with preceding node
|
|
37
37
|
const {
|
|
38
38
|
indent,
|
|
@@ -40,7 +40,7 @@ function grabCollectionEndComments(node) {
|
|
|
40
40
|
} = n.context;
|
|
41
41
|
if (indent > 0 && n.range.start >= lineStart + indent) break;
|
|
42
42
|
ci = i;
|
|
43
|
-
} else if (n.type ===
|
|
43
|
+
} else if (n.type === _constants.Type.BLANK_LINE) ci = i;else break;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
if (ci === -1) return null;
|
|
@@ -64,12 +64,12 @@ class Collection extends _Node.default {
|
|
|
64
64
|
const ch = src[offset];
|
|
65
65
|
if (!ch) return false;
|
|
66
66
|
if (offset >= lineStart + indent) return true;
|
|
67
|
-
if (ch !== '#') return false;
|
|
67
|
+
if (ch !== '#' && ch !== '\n') return false;
|
|
68
68
|
return Collection.nextContentHasIndent(src, offset, indent);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
constructor(firstItem) {
|
|
72
|
-
super(firstItem.type ===
|
|
72
|
+
super(firstItem.type === _constants.Type.SEQ_ITEM ? _constants.Type.SEQ : _constants.Type.MAP);
|
|
73
73
|
|
|
74
74
|
for (let i = firstItem.props.length - 1; i >= 0; --i) {
|
|
75
75
|
if (firstItem.props[i].start < firstItem.context.lineStart) {
|
|
@@ -181,7 +181,7 @@ class Collection extends _Node.default {
|
|
|
181
181
|
break;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
if (firstItem.type ===
|
|
184
|
+
if (firstItem.type === _constants.Type.SEQ_ITEM !== (ch === '-')) {
|
|
185
185
|
let typeswitch = true;
|
|
186
186
|
|
|
187
187
|
if (ch === '-') {
|
|
@@ -5,16 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
8
10
|
var _errors = require("../errors");
|
|
9
11
|
|
|
10
12
|
var _BlankLine = _interopRequireDefault(require("./BlankLine"));
|
|
11
13
|
|
|
12
|
-
var _Node =
|
|
14
|
+
var _Node = _interopRequireDefault(require("./Node"));
|
|
13
15
|
|
|
14
16
|
var _Range = _interopRequireDefault(require("./Range"));
|
|
15
17
|
|
|
16
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
17
|
-
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
20
|
class CollectionItem extends _Node.default {
|
|
@@ -43,7 +43,7 @@ class CollectionItem extends _Node.default {
|
|
|
43
43
|
atLineStart,
|
|
44
44
|
lineStart
|
|
45
45
|
} = context;
|
|
46
|
-
if (!atLineStart && this.type ===
|
|
46
|
+
if (!atLineStart && this.type === _constants.Type.SEQ_ITEM) this.error = new _errors.YAMLSemanticError(this, 'Sequence items must not have preceding content on the same line');
|
|
47
47
|
const indent = atLineStart ? start - lineStart : context.indent;
|
|
48
48
|
|
|
49
49
|
let offset = _Node.default.endOfWhiteSpace(src, start + 1);
|
|
@@ -77,7 +77,7 @@ class CollectionItem extends _Node.default {
|
|
|
77
77
|
ch = src[offset];
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
if (_Node.default.nextNodeIsIndented(ch, offset - (lineStart + indent), this.type !==
|
|
80
|
+
if (_Node.default.nextNodeIsIndented(ch, offset - (lineStart + indent), this.type !== _constants.Type.SEQ_ITEM)) {
|
|
81
81
|
this.node = parseNode({
|
|
82
82
|
atLineStart,
|
|
83
83
|
inCollection: false,
|
|
@@ -116,6 +116,4 @@ class CollectionItem extends _Node.default {
|
|
|
116
116
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
exports.default = CollectionItem;
|
|
120
|
-
module.exports = exports.default;
|
|
121
|
-
module.exports.default = exports.default;
|
|
119
|
+
exports.default = CollectionItem;
|
package/dist/cst/Comment.js
CHANGED
|
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
var _Node = _interopRequireDefault(require("./Node"));
|
|
9
11
|
|
|
10
12
|
var _Range = _interopRequireDefault(require("./Range"));
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
15
|
-
|
|
16
16
|
class Comment extends _Node.default {
|
|
17
17
|
constructor() {
|
|
18
|
-
super(
|
|
18
|
+
super(_constants.Type.COMMENT);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Parses a comment line from the source
|
|
@@ -35,6 +35,4 @@ class Comment extends _Node.default {
|
|
|
35
35
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
exports.default = Comment;
|
|
39
|
-
module.exports = exports.default;
|
|
40
|
-
module.exports.default = exports.default;
|
|
38
|
+
exports.default = Comment;
|
package/dist/cst/Directive.js
CHANGED
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
var _Node = _interopRequireDefault(require("./Node"));
|
|
9
11
|
|
|
10
12
|
var _Range = _interopRequireDefault(require("./Range"));
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
15
|
-
|
|
16
16
|
class Directive extends _Node.default {
|
|
17
17
|
static endOfDirective(src, offset) {
|
|
18
18
|
let ch = src[offset];
|
|
@@ -31,7 +31,7 @@ class Directive extends _Node.default {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
constructor() {
|
|
34
|
-
super(
|
|
34
|
+
super(_constants.Type.DIRECTIVE);
|
|
35
35
|
this.name = null;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -77,6 +77,4 @@ class Directive extends _Node.default {
|
|
|
77
77
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
exports.default = Directive;
|
|
81
|
-
module.exports = exports.default;
|
|
82
|
-
module.exports.default = exports.default;
|
|
80
|
+
exports.default = Directive;
|
package/dist/cst/Document.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
8
10
|
var _errors = require("../errors");
|
|
9
11
|
|
|
10
12
|
var _BlankLine = _interopRequireDefault(require("./BlankLine"));
|
|
@@ -15,12 +17,10 @@ var _Comment = _interopRequireDefault(require("./Comment"));
|
|
|
15
17
|
|
|
16
18
|
var _Directive = _interopRequireDefault(require("./Directive"));
|
|
17
19
|
|
|
18
|
-
var _Node =
|
|
20
|
+
var _Node = _interopRequireDefault(require("./Node"));
|
|
19
21
|
|
|
20
22
|
var _Range = _interopRequireDefault(require("./Range"));
|
|
21
23
|
|
|
22
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
23
|
-
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
|
|
26
26
|
class Document extends _Node.default {
|
|
@@ -32,9 +32,11 @@ class Document extends _Node.default {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
constructor() {
|
|
35
|
-
super(
|
|
35
|
+
super(_constants.Type.DOCUMENT);
|
|
36
36
|
this.directives = null;
|
|
37
37
|
this.contents = null;
|
|
38
|
+
this.directivesEndMarker = null;
|
|
39
|
+
this.documentEndMarker = null;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
parseDirectives(start) {
|
|
@@ -46,7 +48,7 @@ class Document extends _Node.default {
|
|
|
46
48
|
let hasDirectives = false;
|
|
47
49
|
let offset = start;
|
|
48
50
|
|
|
49
|
-
while (!_Node.default.atDocumentBoundary(src, offset,
|
|
51
|
+
while (!_Node.default.atDocumentBoundary(src, offset, _constants.Char.DIRECTIVES_END)) {
|
|
50
52
|
offset = Document.startCommentOrEndBlankLine(src, offset);
|
|
51
53
|
|
|
52
54
|
switch (src[offset]) {
|
|
@@ -103,7 +105,10 @@ class Document extends _Node.default {
|
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
|
|
106
|
-
if (src[offset])
|
|
108
|
+
if (src[offset]) {
|
|
109
|
+
this.directivesEndMarker = new _Range.default(offset, offset + 3);
|
|
110
|
+
return offset + 3;
|
|
111
|
+
}
|
|
107
112
|
|
|
108
113
|
if (hasDirectives) {
|
|
109
114
|
this.error = new _errors.YAMLSemanticError(this, 'Missing directives-end indicator line');
|
|
@@ -130,7 +135,7 @@ class Document extends _Node.default {
|
|
|
130
135
|
let atLineStart = lineStart === start;
|
|
131
136
|
this.valueRange = new _Range.default(offset);
|
|
132
137
|
|
|
133
|
-
while (!_Node.default.atDocumentBoundary(src, offset,
|
|
138
|
+
while (!_Node.default.atDocumentBoundary(src, offset, _constants.Char.DOCUMENT_END)) {
|
|
134
139
|
switch (src[offset]) {
|
|
135
140
|
case '\n':
|
|
136
141
|
if (atLineStart) {
|
|
@@ -190,6 +195,7 @@ class Document extends _Node.default {
|
|
|
190
195
|
this.valueRange.end = offset;
|
|
191
196
|
|
|
192
197
|
if (src[offset]) {
|
|
198
|
+
this.documentEndMarker = new _Range.default(offset, offset + 3);
|
|
193
199
|
offset += 3;
|
|
194
200
|
|
|
195
201
|
if (src[offset]) {
|
|
@@ -244,9 +250,11 @@ class Document extends _Node.default {
|
|
|
244
250
|
this.directives.forEach(node => {
|
|
245
251
|
offset = node.setOrigRanges(cr, offset);
|
|
246
252
|
});
|
|
253
|
+
if (this.directivesEndMarker) offset = this.directivesEndMarker.setOrigRange(cr, offset);
|
|
247
254
|
this.contents.forEach(node => {
|
|
248
255
|
offset = node.setOrigRanges(cr, offset);
|
|
249
256
|
});
|
|
257
|
+
if (this.documentEndMarker) offset = this.documentEndMarker.setOrigRange(cr, offset);
|
|
250
258
|
return offset;
|
|
251
259
|
}
|
|
252
260
|
|
|
@@ -260,7 +268,7 @@ class Document extends _Node.default {
|
|
|
260
268
|
let str = directives.join('');
|
|
261
269
|
|
|
262
270
|
if (contents.length > 0) {
|
|
263
|
-
if (directives.length > 0 || contents[0].type ===
|
|
271
|
+
if (directives.length > 0 || contents[0].type === _constants.Type.COMMENT) str += '---\n';
|
|
264
272
|
str += contents.join('');
|
|
265
273
|
}
|
|
266
274
|
|
|
@@ -270,6 +278,4 @@ class Document extends _Node.default {
|
|
|
270
278
|
|
|
271
279
|
}
|
|
272
280
|
|
|
273
|
-
exports.default = Document;
|
|
274
|
-
module.exports = exports.default;
|
|
275
|
-
module.exports.default = exports.default;
|
|
281
|
+
exports.default = Document;
|