yaml 1.9.1 → 1.10.2
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 +25 -25
- package/browser/dist/PlainValue-b8036b75.js +1275 -0
- package/browser/dist/Schema-e94716c8.js +682 -0
- package/browser/dist/index.js +860 -27
- package/browser/dist/legacy-exports.js +3 -0
- package/browser/dist/package.json +1 -0
- package/browser/dist/parse-cst.js +1904 -0
- package/browser/dist/resolveSeq-492ab440.js +2419 -0
- package/browser/dist/types.js +4 -0
- package/browser/dist/util.js +2 -0
- package/browser/dist/warnings-df54cb69.js +499 -0
- package/browser/index.js +1 -1
- package/browser/map.js +2 -4
- package/browser/pair.js +2 -4
- package/browser/parse-cst.js +1 -1
- package/browser/scalar.js +2 -4
- package/browser/schema.js +7 -10
- package/browser/seq.js +2 -4
- package/browser/types/binary.js +7 -5
- package/browser/types/omap.js +3 -4
- package/browser/types/pairs.js +3 -4
- package/browser/types/set.js +3 -4
- package/browser/types/timestamp.js +9 -5
- package/browser/types.js +1 -13
- package/browser/util.js +1 -18
- package/dist/Document-9b4560a1.js +757 -0
- package/dist/PlainValue-ec8e588e.js +876 -0
- package/dist/Schema-88e323a7.js +525 -0
- package/dist/index.js +20 -84
- package/dist/legacy-exports.js +16 -0
- package/dist/parse-cst.js +1753 -0
- package/dist/resolveSeq-d03cb037.js +2161 -0
- package/dist/test-events.js +11 -9
- package/dist/types.js +23 -0
- package/dist/util.js +19 -0
- package/dist/warnings-1000a372.js +416 -0
- package/index.d.ts +23 -9
- package/map.js +2 -2
- package/package.json +27 -42
- package/pair.js +2 -2
- package/parse-cst.d.ts +4 -0
- package/parse-cst.js +1 -1
- package/scalar.js +2 -2
- package/schema.js +8 -6
- package/seq.js +2 -2
- package/types/binary.js +3 -2
- package/types/omap.js +3 -2
- package/types/pairs.js +3 -2
- package/types/set.js +3 -2
- package/types/timestamp.js +6 -6
- package/types.d.ts +113 -98
- package/types.js +16 -11
- package/types.mjs +15 -19
- package/util.js +14 -14
- package/util.mjs +13 -20
- package/browser/dist/Anchors.js +0 -130
- package/browser/dist/Document.js +0 -824
- package/browser/dist/addComment.js +0 -8
- package/browser/dist/constants.js +0 -26
- package/browser/dist/cst/Alias.js +0 -46
- package/browser/dist/cst/BlankLine.js +0 -52
- package/browser/dist/cst/BlockValue.js +0 -251
- package/browser/dist/cst/Collection.js +0 -278
- package/browser/dist/cst/CollectionItem.js +0 -140
- package/browser/dist/cst/Comment.js +0 -44
- package/browser/dist/cst/Directive.js +0 -76
- package/browser/dist/cst/Document.js +0 -286
- package/browser/dist/cst/FlowCollection.js +0 -220
- package/browser/dist/cst/Node.js +0 -386
- package/browser/dist/cst/ParseContext.js +0 -246
- package/browser/dist/cst/PlainValue.js +0 -170
- package/browser/dist/cst/QuoteDouble.js +0 -245
- package/browser/dist/cst/QuoteSingle.js +0 -120
- package/browser/dist/cst/Range.js +0 -64
- package/browser/dist/cst/parse.js +0 -48
- package/browser/dist/cst/source-utils.js +0 -168
- package/browser/dist/errors.js +0 -127
- package/browser/dist/foldFlowLines.js +0 -138
- package/browser/dist/listTagNames.js +0 -28
- package/browser/dist/schema/Alias.js +0 -135
- package/browser/dist/schema/Collection.js +0 -260
- package/browser/dist/schema/Map.js +0 -161
- package/browser/dist/schema/Merge.js +0 -118
- package/browser/dist/schema/Node.js +0 -4
- package/browser/dist/schema/Pair.js +0 -194
- package/browser/dist/schema/Scalar.js +0 -42
- package/browser/dist/schema/Seq.js +0 -116
- package/browser/dist/schema/index.js +0 -368
- package/browser/dist/schema/parseMap.js +0 -312
- package/browser/dist/schema/parseSeq.js +0 -168
- package/browser/dist/schema/parseUtils.js +0 -106
- package/browser/dist/stringify.js +0 -332
- package/browser/dist/tags/core.js +0 -141
- package/browser/dist/tags/failsafe/index.js +0 -4
- package/browser/dist/tags/failsafe/map.js +0 -53
- package/browser/dist/tags/failsafe/seq.js +0 -39
- package/browser/dist/tags/failsafe/string.js +0 -28
- package/browser/dist/tags/index.js +0 -36
- package/browser/dist/tags/json.js +0 -77
- package/browser/dist/tags/options.js +0 -26
- package/browser/dist/tags/yaml-1.1/binary.js +0 -87
- package/browser/dist/tags/yaml-1.1/index.js +0 -189
- package/browser/dist/tags/yaml-1.1/omap.js +0 -137
- package/browser/dist/tags/yaml-1.1/pairs.js +0 -78
- package/browser/dist/tags/yaml-1.1/set.js +0 -118
- package/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
- package/browser/dist/test-events.js +0 -163
- package/browser/dist/toJSON.js +0 -19
- package/browser/dist/warnings.js +0 -39
- package/dist/Anchors.js +0 -120
- package/dist/Document.js +0 -714
- package/dist/addComment.js +0 -14
- package/dist/constants.js +0 -31
- package/dist/cst/Alias.js +0 -33
- package/dist/cst/BlankLine.js +0 -40
- package/dist/cst/BlockValue.js +0 -243
- package/dist/cst/Collection.js +0 -266
- package/dist/cst/CollectionItem.js +0 -135
- package/dist/cst/Comment.js +0 -33
- package/dist/cst/Directive.js +0 -59
- package/dist/cst/Document.js +0 -276
- package/dist/cst/FlowCollection.js +0 -213
- package/dist/cst/Node.js +0 -360
- package/dist/cst/ParseContext.js +0 -253
- package/dist/cst/PlainValue.js +0 -156
- package/dist/cst/QuoteDouble.js +0 -232
- package/dist/cst/QuoteSingle.js +0 -108
- package/dist/cst/Range.js +0 -60
- package/dist/cst/parse.js +0 -50
- package/dist/cst/source-utils.js +0 -175
- package/dist/errors.js +0 -97
- package/dist/foldFlowLines.js +0 -143
- package/dist/listTagNames.js +0 -33
- package/dist/schema/Alias.js +0 -105
- package/dist/schema/Collection.js +0 -184
- package/dist/schema/Map.js +0 -98
- package/dist/schema/Merge.js +0 -75
- package/dist/schema/Node.js +0 -7
- package/dist/schema/Pair.js +0 -174
- package/dist/schema/Scalar.js +0 -26
- package/dist/schema/Seq.js +0 -73
- package/dist/schema/index.js +0 -310
- package/dist/schema/parseMap.js +0 -334
- package/dist/schema/parseSeq.js +0 -175
- package/dist/schema/parseUtils.js +0 -101
- package/dist/stringify.js +0 -352
- package/dist/tags/core.js +0 -121
- package/dist/tags/failsafe/index.js +0 -12
- package/dist/tags/failsafe/map.js +0 -32
- package/dist/tags/failsafe/seq.js +0 -29
- package/dist/tags/failsafe/string.js +0 -37
- package/dist/tags/index.js +0 -53
- package/dist/tags/json.js +0 -64
- package/dist/tags/options.js +0 -36
- package/dist/tags/yaml-1.1/binary.js +0 -94
- package/dist/tags/yaml-1.1/index.js +0 -162
- package/dist/tags/yaml-1.1/omap.js +0 -100
- package/dist/tags/yaml-1.1/pairs.js +0 -75
- package/dist/tags/yaml-1.1/set.js +0 -82
- package/dist/tags/yaml-1.1/timestamp.js +0 -90
- package/dist/toJSON.js +0 -21
- package/dist/warnings.js +0 -48
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.CollectionItem = void 0;
|
|
4
|
-
|
|
5
|
-
var _constants = require("../constants");
|
|
6
|
-
|
|
7
|
-
var _errors = require("../errors");
|
|
8
|
-
|
|
9
|
-
var _BlankLine = require("./BlankLine");
|
|
10
|
-
|
|
11
|
-
var _Node = require("./Node");
|
|
12
|
-
|
|
13
|
-
var _Range = require("./Range");
|
|
14
|
-
|
|
15
|
-
class CollectionItem extends _Node.Node {
|
|
16
|
-
constructor(type, props) {
|
|
17
|
-
super(type, props);
|
|
18
|
-
this.node = null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
get includesTrailingLines() {
|
|
22
|
-
return !!this.node && this.node.includesTrailingLines;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @param {ParseContext} context
|
|
26
|
-
* @param {number} start - Index of first character
|
|
27
|
-
* @returns {number} - Index of the character after this
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
parse(context, start) {
|
|
32
|
-
this.context = context;
|
|
33
|
-
const {
|
|
34
|
-
parseNode,
|
|
35
|
-
src
|
|
36
|
-
} = context;
|
|
37
|
-
let {
|
|
38
|
-
atLineStart,
|
|
39
|
-
lineStart
|
|
40
|
-
} = context;
|
|
41
|
-
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');
|
|
42
|
-
const indent = atLineStart ? start - lineStart : context.indent;
|
|
43
|
-
|
|
44
|
-
let offset = _Node.Node.endOfWhiteSpace(src, start + 1);
|
|
45
|
-
|
|
46
|
-
let ch = src[offset];
|
|
47
|
-
const inlineComment = ch === '#';
|
|
48
|
-
const comments = [];
|
|
49
|
-
let blankLine = null;
|
|
50
|
-
|
|
51
|
-
while (ch === '\n' || ch === '#') {
|
|
52
|
-
if (ch === '#') {
|
|
53
|
-
const end = _Node.Node.endOfLine(src, offset + 1);
|
|
54
|
-
|
|
55
|
-
comments.push(new _Range.Range(offset, end));
|
|
56
|
-
offset = end;
|
|
57
|
-
} else {
|
|
58
|
-
atLineStart = true;
|
|
59
|
-
lineStart = offset + 1;
|
|
60
|
-
|
|
61
|
-
const wsEnd = _Node.Node.endOfWhiteSpace(src, lineStart);
|
|
62
|
-
|
|
63
|
-
if (src[wsEnd] === '\n' && comments.length === 0) {
|
|
64
|
-
blankLine = new _BlankLine.BlankLine();
|
|
65
|
-
lineStart = blankLine.parse({
|
|
66
|
-
src
|
|
67
|
-
}, lineStart);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
offset = _Node.Node.endOfIndent(src, lineStart);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
ch = src[offset];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (_Node.Node.nextNodeIsIndented(ch, offset - (lineStart + indent), this.type !== _constants.Type.SEQ_ITEM)) {
|
|
77
|
-
this.node = parseNode({
|
|
78
|
-
atLineStart,
|
|
79
|
-
inCollection: false,
|
|
80
|
-
indent,
|
|
81
|
-
lineStart,
|
|
82
|
-
parent: this
|
|
83
|
-
}, offset);
|
|
84
|
-
} else if (ch && lineStart > start + 1) {
|
|
85
|
-
offset = lineStart - 1;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (this.node) {
|
|
89
|
-
if (blankLine) {
|
|
90
|
-
// Only blank lines preceding non-empty nodes are captured. Note that
|
|
91
|
-
// this means that collection item range start indices do not always
|
|
92
|
-
// increase monotonically. -- eemeli/yaml#126
|
|
93
|
-
const items = context.parent.items || context.parent.contents;
|
|
94
|
-
if (items) items.push(blankLine);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (comments.length) Array.prototype.push.apply(this.props, comments);
|
|
98
|
-
offset = this.node.range.end;
|
|
99
|
-
} else {
|
|
100
|
-
if (inlineComment) {
|
|
101
|
-
const c = comments[0];
|
|
102
|
-
this.props.push(c);
|
|
103
|
-
offset = c.end;
|
|
104
|
-
} else {
|
|
105
|
-
offset = _Node.Node.endOfLine(src, start + 1);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const end = this.node ? this.node.valueRange.end : offset;
|
|
110
|
-
this.valueRange = new _Range.Range(start, end);
|
|
111
|
-
return offset;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
setOrigRanges(cr, offset) {
|
|
115
|
-
offset = super.setOrigRanges(cr, offset);
|
|
116
|
-
return this.node ? this.node.setOrigRanges(cr, offset) : offset;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
toString() {
|
|
120
|
-
const {
|
|
121
|
-
context: {
|
|
122
|
-
src
|
|
123
|
-
},
|
|
124
|
-
node,
|
|
125
|
-
range,
|
|
126
|
-
value
|
|
127
|
-
} = this;
|
|
128
|
-
if (value != null) return value;
|
|
129
|
-
const str = node ? src.slice(range.start, node.range.start) + String(node) : src.slice(range.start, range.end);
|
|
130
|
-
return _Node.Node.addStringTerminator(src, range.end, str);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
exports.CollectionItem = CollectionItem;
|
package/dist/cst/Comment.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.Comment = void 0;
|
|
4
|
-
|
|
5
|
-
var _constants = require("../constants");
|
|
6
|
-
|
|
7
|
-
var _Node = require("./Node");
|
|
8
|
-
|
|
9
|
-
var _Range = require("./Range");
|
|
10
|
-
|
|
11
|
-
class Comment extends _Node.Node {
|
|
12
|
-
constructor() {
|
|
13
|
-
super(_constants.Type.COMMENT);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Parses a comment line from the source
|
|
17
|
-
*
|
|
18
|
-
* @param {ParseContext} context
|
|
19
|
-
* @param {number} start - Index of first character
|
|
20
|
-
* @returns {number} - Index of the character after this scalar
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
parse(context, start) {
|
|
25
|
-
this.context = context;
|
|
26
|
-
const offset = this.parseComment(start);
|
|
27
|
-
this.range = new _Range.Range(start, offset);
|
|
28
|
-
return offset;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
exports.Comment = Comment;
|
package/dist/cst/Directive.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.Directive = void 0;
|
|
4
|
-
|
|
5
|
-
var _constants = require("../constants");
|
|
6
|
-
|
|
7
|
-
var _Node = require("./Node");
|
|
8
|
-
|
|
9
|
-
var _Range = require("./Range");
|
|
10
|
-
|
|
11
|
-
class Directive extends _Node.Node {
|
|
12
|
-
constructor() {
|
|
13
|
-
super(_constants.Type.DIRECTIVE);
|
|
14
|
-
this.name = null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
get parameters() {
|
|
18
|
-
const raw = this.rawValue;
|
|
19
|
-
return raw ? raw.trim().split(/[ \t]+/) : [];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
parseName(start) {
|
|
23
|
-
const {
|
|
24
|
-
src
|
|
25
|
-
} = this.context;
|
|
26
|
-
let offset = start;
|
|
27
|
-
let ch = src[offset];
|
|
28
|
-
|
|
29
|
-
while (ch && ch !== '\n' && ch !== '\t' && ch !== ' ') ch = src[offset += 1];
|
|
30
|
-
|
|
31
|
-
this.name = src.slice(start, offset);
|
|
32
|
-
return offset;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
parseParameters(start) {
|
|
36
|
-
const {
|
|
37
|
-
src
|
|
38
|
-
} = this.context;
|
|
39
|
-
let offset = start;
|
|
40
|
-
let ch = src[offset];
|
|
41
|
-
|
|
42
|
-
while (ch && ch !== '\n' && ch !== '#') ch = src[offset += 1];
|
|
43
|
-
|
|
44
|
-
this.valueRange = new _Range.Range(start, offset);
|
|
45
|
-
return offset;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
parse(context, start) {
|
|
49
|
-
this.context = context;
|
|
50
|
-
let offset = this.parseName(start + 1);
|
|
51
|
-
offset = this.parseParameters(offset);
|
|
52
|
-
offset = this.parseComment(offset);
|
|
53
|
-
this.range = new _Range.Range(start, offset);
|
|
54
|
-
return offset;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
exports.Directive = Directive;
|
package/dist/cst/Document.js
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.Document = void 0;
|
|
4
|
-
|
|
5
|
-
var _constants = require("../constants");
|
|
6
|
-
|
|
7
|
-
var _errors = require("../errors");
|
|
8
|
-
|
|
9
|
-
var _BlankLine = require("./BlankLine");
|
|
10
|
-
|
|
11
|
-
var _Collection = require("./Collection");
|
|
12
|
-
|
|
13
|
-
var _Comment = require("./Comment");
|
|
14
|
-
|
|
15
|
-
var _Directive = require("./Directive");
|
|
16
|
-
|
|
17
|
-
var _Node = require("./Node");
|
|
18
|
-
|
|
19
|
-
var _Range = require("./Range");
|
|
20
|
-
|
|
21
|
-
class Document extends _Node.Node {
|
|
22
|
-
static startCommentOrEndBlankLine(src, start) {
|
|
23
|
-
const offset = _Node.Node.endOfWhiteSpace(src, start);
|
|
24
|
-
|
|
25
|
-
const ch = src[offset];
|
|
26
|
-
return ch === '#' || ch === '\n' ? offset : start;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
constructor() {
|
|
30
|
-
super(_constants.Type.DOCUMENT);
|
|
31
|
-
this.directives = null;
|
|
32
|
-
this.contents = null;
|
|
33
|
-
this.directivesEndMarker = null;
|
|
34
|
-
this.documentEndMarker = null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
parseDirectives(start) {
|
|
38
|
-
const {
|
|
39
|
-
src
|
|
40
|
-
} = this.context;
|
|
41
|
-
this.directives = [];
|
|
42
|
-
let atLineStart = true;
|
|
43
|
-
let hasDirectives = false;
|
|
44
|
-
let offset = start;
|
|
45
|
-
|
|
46
|
-
while (!_Node.Node.atDocumentBoundary(src, offset, _constants.Char.DIRECTIVES_END)) {
|
|
47
|
-
offset = Document.startCommentOrEndBlankLine(src, offset);
|
|
48
|
-
|
|
49
|
-
switch (src[offset]) {
|
|
50
|
-
case '\n':
|
|
51
|
-
if (atLineStart) {
|
|
52
|
-
const blankLine = new _BlankLine.BlankLine();
|
|
53
|
-
offset = blankLine.parse({
|
|
54
|
-
src
|
|
55
|
-
}, offset);
|
|
56
|
-
|
|
57
|
-
if (offset < src.length) {
|
|
58
|
-
this.directives.push(blankLine);
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
offset += 1;
|
|
62
|
-
atLineStart = true;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
break;
|
|
66
|
-
|
|
67
|
-
case '#':
|
|
68
|
-
{
|
|
69
|
-
const comment = new _Comment.Comment();
|
|
70
|
-
offset = comment.parse({
|
|
71
|
-
src
|
|
72
|
-
}, offset);
|
|
73
|
-
this.directives.push(comment);
|
|
74
|
-
atLineStart = false;
|
|
75
|
-
}
|
|
76
|
-
break;
|
|
77
|
-
|
|
78
|
-
case '%':
|
|
79
|
-
{
|
|
80
|
-
const directive = new _Directive.Directive();
|
|
81
|
-
offset = directive.parse({
|
|
82
|
-
parent: this,
|
|
83
|
-
src
|
|
84
|
-
}, offset);
|
|
85
|
-
this.directives.push(directive);
|
|
86
|
-
hasDirectives = true;
|
|
87
|
-
atLineStart = false;
|
|
88
|
-
}
|
|
89
|
-
break;
|
|
90
|
-
|
|
91
|
-
default:
|
|
92
|
-
if (hasDirectives) {
|
|
93
|
-
this.error = new _errors.YAMLSemanticError(this, 'Missing directives-end indicator line');
|
|
94
|
-
} else if (this.directives.length > 0) {
|
|
95
|
-
this.contents = this.directives;
|
|
96
|
-
this.directives = [];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return offset;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (src[offset]) {
|
|
104
|
-
this.directivesEndMarker = new _Range.Range(offset, offset + 3);
|
|
105
|
-
return offset + 3;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (hasDirectives) {
|
|
109
|
-
this.error = new _errors.YAMLSemanticError(this, 'Missing directives-end indicator line');
|
|
110
|
-
} else if (this.directives.length > 0) {
|
|
111
|
-
this.contents = this.directives;
|
|
112
|
-
this.directives = [];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return offset;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
parseContents(start) {
|
|
119
|
-
const {
|
|
120
|
-
parseNode,
|
|
121
|
-
src
|
|
122
|
-
} = this.context;
|
|
123
|
-
if (!this.contents) this.contents = [];
|
|
124
|
-
let lineStart = start;
|
|
125
|
-
|
|
126
|
-
while (src[lineStart - 1] === '-') lineStart -= 1;
|
|
127
|
-
|
|
128
|
-
let offset = _Node.Node.endOfWhiteSpace(src, start);
|
|
129
|
-
|
|
130
|
-
let atLineStart = lineStart === start;
|
|
131
|
-
this.valueRange = new _Range.Range(offset);
|
|
132
|
-
|
|
133
|
-
while (!_Node.Node.atDocumentBoundary(src, offset, _constants.Char.DOCUMENT_END)) {
|
|
134
|
-
switch (src[offset]) {
|
|
135
|
-
case '\n':
|
|
136
|
-
if (atLineStart) {
|
|
137
|
-
const blankLine = new _BlankLine.BlankLine();
|
|
138
|
-
offset = blankLine.parse({
|
|
139
|
-
src
|
|
140
|
-
}, offset);
|
|
141
|
-
|
|
142
|
-
if (offset < src.length) {
|
|
143
|
-
this.contents.push(blankLine);
|
|
144
|
-
}
|
|
145
|
-
} else {
|
|
146
|
-
offset += 1;
|
|
147
|
-
atLineStart = true;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
lineStart = offset;
|
|
151
|
-
break;
|
|
152
|
-
|
|
153
|
-
case '#':
|
|
154
|
-
{
|
|
155
|
-
const comment = new _Comment.Comment();
|
|
156
|
-
offset = comment.parse({
|
|
157
|
-
src
|
|
158
|
-
}, offset);
|
|
159
|
-
this.contents.push(comment);
|
|
160
|
-
atLineStart = false;
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
|
|
164
|
-
default:
|
|
165
|
-
{
|
|
166
|
-
const iEnd = _Node.Node.endOfIndent(src, offset);
|
|
167
|
-
|
|
168
|
-
const context = {
|
|
169
|
-
atLineStart,
|
|
170
|
-
indent: -1,
|
|
171
|
-
inFlow: false,
|
|
172
|
-
inCollection: false,
|
|
173
|
-
lineStart,
|
|
174
|
-
parent: this
|
|
175
|
-
};
|
|
176
|
-
const node = parseNode(context, iEnd);
|
|
177
|
-
if (!node) return this.valueRange.end = iEnd; // at next document start
|
|
178
|
-
|
|
179
|
-
this.contents.push(node);
|
|
180
|
-
offset = node.range.end;
|
|
181
|
-
atLineStart = false;
|
|
182
|
-
const ec = (0, _Collection.grabCollectionEndComments)(node);
|
|
183
|
-
if (ec) Array.prototype.push.apply(this.contents, ec);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
offset = Document.startCommentOrEndBlankLine(src, offset);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
this.valueRange.end = offset;
|
|
191
|
-
|
|
192
|
-
if (src[offset]) {
|
|
193
|
-
this.documentEndMarker = new _Range.Range(offset, offset + 3);
|
|
194
|
-
offset += 3;
|
|
195
|
-
|
|
196
|
-
if (src[offset]) {
|
|
197
|
-
offset = _Node.Node.endOfWhiteSpace(src, offset);
|
|
198
|
-
|
|
199
|
-
if (src[offset] === '#') {
|
|
200
|
-
const comment = new _Comment.Comment();
|
|
201
|
-
offset = comment.parse({
|
|
202
|
-
src
|
|
203
|
-
}, offset);
|
|
204
|
-
this.contents.push(comment);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
switch (src[offset]) {
|
|
208
|
-
case '\n':
|
|
209
|
-
offset += 1;
|
|
210
|
-
break;
|
|
211
|
-
|
|
212
|
-
case undefined:
|
|
213
|
-
break;
|
|
214
|
-
|
|
215
|
-
default:
|
|
216
|
-
this.error = new _errors.YAMLSyntaxError(this, 'Document end marker line cannot have a non-comment suffix');
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return offset;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* @param {ParseContext} context
|
|
225
|
-
* @param {number} start - Index of first character
|
|
226
|
-
* @returns {number} - Index of the character after this
|
|
227
|
-
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
parse(context, start) {
|
|
231
|
-
context.root = this;
|
|
232
|
-
this.context = context;
|
|
233
|
-
const {
|
|
234
|
-
src
|
|
235
|
-
} = context;
|
|
236
|
-
let offset = src.charCodeAt(start) === 0xfeff ? start + 1 : start; // skip BOM
|
|
237
|
-
|
|
238
|
-
offset = this.parseDirectives(offset);
|
|
239
|
-
offset = this.parseContents(offset);
|
|
240
|
-
return offset;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
setOrigRanges(cr, offset) {
|
|
244
|
-
offset = super.setOrigRanges(cr, offset);
|
|
245
|
-
this.directives.forEach(node => {
|
|
246
|
-
offset = node.setOrigRanges(cr, offset);
|
|
247
|
-
});
|
|
248
|
-
if (this.directivesEndMarker) offset = this.directivesEndMarker.setOrigRange(cr, offset);
|
|
249
|
-
this.contents.forEach(node => {
|
|
250
|
-
offset = node.setOrigRanges(cr, offset);
|
|
251
|
-
});
|
|
252
|
-
if (this.documentEndMarker) offset = this.documentEndMarker.setOrigRange(cr, offset);
|
|
253
|
-
return offset;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
toString() {
|
|
257
|
-
const {
|
|
258
|
-
contents,
|
|
259
|
-
directives,
|
|
260
|
-
value
|
|
261
|
-
} = this;
|
|
262
|
-
if (value != null) return value;
|
|
263
|
-
let str = directives.join('');
|
|
264
|
-
|
|
265
|
-
if (contents.length > 0) {
|
|
266
|
-
if (directives.length > 0 || contents[0].type === _constants.Type.COMMENT) str += '---\n';
|
|
267
|
-
str += contents.join('');
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if (str[str.length - 1] !== '\n') str += '\n';
|
|
271
|
-
return str;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
exports.Document = Document;
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.FlowCollection = void 0;
|
|
4
|
-
|
|
5
|
-
var _constants = require("../constants");
|
|
6
|
-
|
|
7
|
-
var _errors = require("../errors");
|
|
8
|
-
|
|
9
|
-
var _BlankLine = require("./BlankLine");
|
|
10
|
-
|
|
11
|
-
var _Comment = require("./Comment");
|
|
12
|
-
|
|
13
|
-
var _Node = require("./Node");
|
|
14
|
-
|
|
15
|
-
var _Range = require("./Range");
|
|
16
|
-
|
|
17
|
-
class FlowCollection extends _Node.Node {
|
|
18
|
-
constructor(type, props) {
|
|
19
|
-
super(type, props);
|
|
20
|
-
this.items = null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
prevNodeIsJsonLike(idx = this.items.length) {
|
|
24
|
-
const node = this.items[idx - 1];
|
|
25
|
-
return !!node && (node.jsonLike || node.type === _constants.Type.COMMENT && this.prevNodeIsJsonLike(idx - 1));
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @param {ParseContext} context
|
|
29
|
-
* @param {number} start - Index of first character
|
|
30
|
-
* @returns {number} - Index of the character after this
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
parse(context, start) {
|
|
35
|
-
this.context = context;
|
|
36
|
-
const {
|
|
37
|
-
parseNode,
|
|
38
|
-
src
|
|
39
|
-
} = context;
|
|
40
|
-
let {
|
|
41
|
-
indent,
|
|
42
|
-
lineStart
|
|
43
|
-
} = context;
|
|
44
|
-
let char = src[start]; // { or [
|
|
45
|
-
|
|
46
|
-
this.items = [{
|
|
47
|
-
char,
|
|
48
|
-
offset: start
|
|
49
|
-
}];
|
|
50
|
-
|
|
51
|
-
let offset = _Node.Node.endOfWhiteSpace(src, start + 1);
|
|
52
|
-
|
|
53
|
-
char = src[offset];
|
|
54
|
-
|
|
55
|
-
while (char && char !== ']' && char !== '}') {
|
|
56
|
-
switch (char) {
|
|
57
|
-
case '\n':
|
|
58
|
-
{
|
|
59
|
-
lineStart = offset + 1;
|
|
60
|
-
|
|
61
|
-
const wsEnd = _Node.Node.endOfWhiteSpace(src, lineStart);
|
|
62
|
-
|
|
63
|
-
if (src[wsEnd] === '\n') {
|
|
64
|
-
const blankLine = new _BlankLine.BlankLine();
|
|
65
|
-
lineStart = blankLine.parse({
|
|
66
|
-
src
|
|
67
|
-
}, lineStart);
|
|
68
|
-
this.items.push(blankLine);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
offset = _Node.Node.endOfIndent(src, lineStart);
|
|
72
|
-
|
|
73
|
-
if (offset <= lineStart + indent) {
|
|
74
|
-
char = src[offset];
|
|
75
|
-
|
|
76
|
-
if (offset < lineStart + indent || char !== ']' && char !== '}') {
|
|
77
|
-
const msg = 'Insufficient indentation in flow collection';
|
|
78
|
-
this.error = new _errors.YAMLSemanticError(this, msg);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
|
|
84
|
-
case ',':
|
|
85
|
-
{
|
|
86
|
-
this.items.push({
|
|
87
|
-
char,
|
|
88
|
-
offset
|
|
89
|
-
});
|
|
90
|
-
offset += 1;
|
|
91
|
-
}
|
|
92
|
-
break;
|
|
93
|
-
|
|
94
|
-
case '#':
|
|
95
|
-
{
|
|
96
|
-
const comment = new _Comment.Comment();
|
|
97
|
-
offset = comment.parse({
|
|
98
|
-
src
|
|
99
|
-
}, offset);
|
|
100
|
-
this.items.push(comment);
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
|
|
104
|
-
case '?':
|
|
105
|
-
case ':':
|
|
106
|
-
{
|
|
107
|
-
const next = src[offset + 1];
|
|
108
|
-
|
|
109
|
-
if (next === '\n' || next === '\t' || next === ' ' || next === ',' || // in-flow : after JSON-like key does not need to be followed by whitespace
|
|
110
|
-
char === ':' && this.prevNodeIsJsonLike()) {
|
|
111
|
-
this.items.push({
|
|
112
|
-
char,
|
|
113
|
-
offset
|
|
114
|
-
});
|
|
115
|
-
offset += 1;
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
// fallthrough
|
|
120
|
-
|
|
121
|
-
default:
|
|
122
|
-
{
|
|
123
|
-
const node = parseNode({
|
|
124
|
-
atLineStart: false,
|
|
125
|
-
inCollection: false,
|
|
126
|
-
inFlow: true,
|
|
127
|
-
indent: -1,
|
|
128
|
-
lineStart,
|
|
129
|
-
parent: this
|
|
130
|
-
}, offset);
|
|
131
|
-
|
|
132
|
-
if (!node) {
|
|
133
|
-
// at next document start
|
|
134
|
-
this.valueRange = new _Range.Range(start, offset);
|
|
135
|
-
return offset;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
this.items.push(node);
|
|
139
|
-
offset = _Node.Node.normalizeOffset(src, node.range.end);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
offset = _Node.Node.endOfWhiteSpace(src, offset);
|
|
144
|
-
char = src[offset];
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
this.valueRange = new _Range.Range(start, offset + 1);
|
|
148
|
-
|
|
149
|
-
if (char) {
|
|
150
|
-
this.items.push({
|
|
151
|
-
char,
|
|
152
|
-
offset
|
|
153
|
-
});
|
|
154
|
-
offset = _Node.Node.endOfWhiteSpace(src, offset + 1);
|
|
155
|
-
offset = this.parseComment(offset);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return offset;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
setOrigRanges(cr, offset) {
|
|
162
|
-
offset = super.setOrigRanges(cr, offset);
|
|
163
|
-
this.items.forEach(node => {
|
|
164
|
-
if (node instanceof _Node.Node) {
|
|
165
|
-
offset = node.setOrigRanges(cr, offset);
|
|
166
|
-
} else if (cr.length === 0) {
|
|
167
|
-
node.origOffset = node.offset;
|
|
168
|
-
} else {
|
|
169
|
-
let i = offset;
|
|
170
|
-
|
|
171
|
-
while (i < cr.length) {
|
|
172
|
-
if (cr[i] > node.offset) break;else ++i;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
node.origOffset = node.offset + i;
|
|
176
|
-
offset = i;
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
return offset;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
toString() {
|
|
183
|
-
const {
|
|
184
|
-
context: {
|
|
185
|
-
src
|
|
186
|
-
},
|
|
187
|
-
items,
|
|
188
|
-
range,
|
|
189
|
-
value
|
|
190
|
-
} = this;
|
|
191
|
-
if (value != null) return value;
|
|
192
|
-
const nodes = items.filter(item => item instanceof _Node.Node);
|
|
193
|
-
let str = '';
|
|
194
|
-
let prevEnd = range.start;
|
|
195
|
-
nodes.forEach(node => {
|
|
196
|
-
const prefix = src.slice(prevEnd, node.range.start);
|
|
197
|
-
prevEnd = node.range.end;
|
|
198
|
-
str += prefix + String(node);
|
|
199
|
-
|
|
200
|
-
if (str[str.length - 1] === '\n' && src[prevEnd - 1] !== '\n' && src[prevEnd] === '\n') {
|
|
201
|
-
// Comment range does not include the terminal newline, but its
|
|
202
|
-
// stringified value does. Without this fix, newlines at comment ends
|
|
203
|
-
// get duplicated.
|
|
204
|
-
prevEnd += 1;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
str += src.slice(prevEnd, range.end);
|
|
208
|
-
return _Node.Node.addStringTerminator(src, range.end, str);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
exports.FlowCollection = FlowCollection;
|