yaml 1.7.2 → 1.8.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/browser/dist/Anchors.js +24 -39
- package/browser/dist/Document.js +86 -110
- package/browser/dist/addComment.js +2 -11
- package/browser/dist/constants.js +3 -11
- package/browser/dist/cst/Alias.js +19 -36
- package/browser/dist/cst/BlankLine.js +25 -38
- package/browser/dist/cst/BlockValue.js +29 -51
- package/browser/dist/cst/Collection.js +42 -65
- package/browser/dist/cst/CollectionItem.js +33 -55
- package/browser/dist/cst/Comment.js +19 -35
- package/browser/dist/cst/Directive.js +20 -56
- package/browser/dist/cst/Document.js +47 -71
- package/browser/dist/cst/FlowCollection.js +38 -61
- package/browser/dist/cst/Node.js +26 -46
- package/browser/dist/cst/ParseContext.js +100 -140
- package/browser/dist/cst/PlainValue.js +21 -38
- package/browser/dist/cst/QuoteDouble.js +26 -42
- package/browser/dist/cst/QuoteSingle.js +25 -41
- package/browser/dist/cst/Range.js +9 -19
- package/browser/dist/cst/parse.js +5 -16
- package/browser/dist/cst/source-utils.js +3 -14
- package/browser/dist/errors.js +42 -78
- package/browser/dist/foldFlowLines.js +4 -15
- package/browser/dist/index.js +24 -44
- package/browser/dist/listTagNames.js +10 -24
- package/browser/dist/schema/Alias.js +32 -49
- package/browser/dist/schema/Collection.js +54 -65
- package/browser/dist/schema/Map.js +39 -49
- package/browser/dist/schema/Merge.js +32 -52
- package/browser/dist/schema/Node.js +3 -12
- package/browser/dist/schema/Pair.js +40 -58
- package/browser/dist/schema/Scalar.js +18 -33
- package/browser/dist/schema/Seq.js +23 -40
- package/browser/dist/schema/index.js +66 -81
- package/browser/dist/schema/parseMap.js +52 -72
- package/browser/dist/schema/parseSeq.js +30 -45
- package/browser/dist/schema/parseUtils.js +12 -25
- package/browser/dist/stringify.js +39 -45
- package/browser/dist/tags/core.js +30 -37
- package/browser/dist/tags/failsafe/index.js +4 -17
- package/browser/dist/tags/failsafe/map.js +15 -24
- package/browser/dist/tags/failsafe/seq.js +7 -18
- package/browser/dist/tags/failsafe/string.js +7 -19
- package/browser/dist/tags/index.js +35 -49
- package/browser/dist/tags/json.js +11 -38
- package/browser/dist/tags/options.js +8 -20
- package/browser/dist/tags/yaml-1.1/binary.js +16 -29
- package/browser/dist/tags/yaml-1.1/index.js +34 -54
- package/browser/dist/tags/yaml-1.1/omap.js +39 -58
- package/browser/dist/tags/yaml-1.1/pairs.js +15 -34
- package/browser/dist/tags/yaml-1.1/set.js +35 -61
- package/browser/dist/tags/yaml-1.1/timestamp.js +6 -16
- package/browser/dist/test-events.js +7 -19
- package/browser/dist/toJSON.js +1 -8
- package/browser/dist/warnings.js +3 -15
- package/dist/Document.js +1 -1
- package/dist/cst/BlankLine.js +4 -0
- package/dist/cst/BlockValue.js +1 -1
- package/dist/cst/Directive.js +0 -16
- package/dist/cst/Node.js +0 -5
- package/dist/cst/ParseContext.js +41 -55
- package/dist/schema/Alias.js +1 -0
- package/dist/schema/Collection.js +22 -5
- package/dist/schema/Map.js +12 -5
- package/dist/schema/Pair.js +1 -0
- package/dist/schema/index.js +10 -5
- package/dist/schema/parseMap.js +1 -1
- package/dist/stringify.js +15 -8
- package/dist/tags/core.js +27 -10
- package/dist/tags/failsafe/map.js +5 -1
- package/dist/tags/failsafe/seq.js +1 -1
- package/dist/tags/index.js +13 -1
- package/dist/tags/json.js +2 -9
- package/dist/tags/yaml-1.1/index.js +6 -6
- package/dist/tags/yaml-1.1/pairs.js +1 -1
- package/dist/tags/yaml-1.1/set.js +1 -1
- package/package.json +33 -16
- package/types.mjs +20 -0
- package/util.mjs +24 -0
|
@@ -1,37 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
import Node from './Node';
|
|
7
|
+
import Range from './Range';
|
|
2
8
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
|
|
16
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _Node2 = _interopRequireDefault(require("./Node"));
|
|
21
|
-
|
|
22
|
-
var _Range = _interopRequireDefault(require("./Range"));
|
|
23
|
-
|
|
24
|
-
var Alias =
|
|
25
|
-
/*#__PURE__*/
|
|
26
|
-
function (_Node) {
|
|
27
|
-
(0, _inherits2.default)(Alias, _Node);
|
|
9
|
+
var Alias = /*#__PURE__*/function (_Node) {
|
|
10
|
+
_inherits(Alias, _Node);
|
|
28
11
|
|
|
29
12
|
function Alias() {
|
|
30
|
-
(
|
|
31
|
-
|
|
13
|
+
_classCallCheck(this, Alias);
|
|
14
|
+
|
|
15
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(Alias).apply(this, arguments));
|
|
32
16
|
}
|
|
33
17
|
|
|
34
|
-
(
|
|
18
|
+
_createClass(Alias, [{
|
|
35
19
|
key: "parse",
|
|
36
20
|
|
|
37
21
|
/**
|
|
@@ -44,16 +28,15 @@ function (_Node) {
|
|
|
44
28
|
value: function parse(context, start) {
|
|
45
29
|
this.context = context;
|
|
46
30
|
var src = context.src;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.valueRange = new _Range.default(start + 1, offset);
|
|
51
|
-
offset = _Node2.default.endOfWhiteSpace(src, offset);
|
|
31
|
+
var offset = Node.endOfIdentifier(src, start + 1);
|
|
32
|
+
this.valueRange = new Range(start + 1, offset);
|
|
33
|
+
offset = Node.endOfWhiteSpace(src, offset);
|
|
52
34
|
offset = this.parseComment(offset);
|
|
53
35
|
return offset;
|
|
54
36
|
}
|
|
55
37
|
}]);
|
|
38
|
+
|
|
56
39
|
return Alias;
|
|
57
|
-
}(
|
|
40
|
+
}(Node);
|
|
58
41
|
|
|
59
|
-
|
|
42
|
+
export { Alias as default };
|
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
|
|
16
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _constants = require("../constants");
|
|
21
|
-
|
|
22
|
-
var _Node2 = _interopRequireDefault(require("./Node"));
|
|
23
|
-
|
|
24
|
-
var _Range = _interopRequireDefault(require("./Range"));
|
|
25
|
-
|
|
26
|
-
var BlankLine =
|
|
27
|
-
/*#__PURE__*/
|
|
28
|
-
function (_Node) {
|
|
29
|
-
(0, _inherits2.default)(BlankLine, _Node);
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
import { Type } from '../constants';
|
|
7
|
+
import Node from './Node';
|
|
8
|
+
import Range from './Range';
|
|
9
|
+
|
|
10
|
+
var BlankLine = /*#__PURE__*/function (_Node) {
|
|
11
|
+
_inherits(BlankLine, _Node);
|
|
30
12
|
|
|
31
13
|
function BlankLine() {
|
|
32
|
-
(
|
|
33
|
-
|
|
14
|
+
_classCallCheck(this, BlankLine);
|
|
15
|
+
|
|
16
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(BlankLine).call(this, Type.BLANK_LINE));
|
|
34
17
|
}
|
|
18
|
+
/* istanbul ignore next */
|
|
35
19
|
|
|
36
|
-
|
|
20
|
+
|
|
21
|
+
_createClass(BlankLine, [{
|
|
37
22
|
key: "parse",
|
|
38
23
|
|
|
39
24
|
/**
|
|
@@ -48,22 +33,24 @@ function (_Node) {
|
|
|
48
33
|
var src = context.src;
|
|
49
34
|
var offset = start + 1;
|
|
50
35
|
|
|
51
|
-
while (
|
|
52
|
-
var lineEnd =
|
|
53
|
-
|
|
36
|
+
while (Node.atBlank(src, offset)) {
|
|
37
|
+
var lineEnd = Node.endOfWhiteSpace(src, offset);
|
|
54
38
|
if (lineEnd === '\n') offset = lineEnd + 1;else break;
|
|
55
39
|
}
|
|
56
40
|
|
|
57
|
-
this.range = new
|
|
41
|
+
this.range = new Range(start, offset);
|
|
58
42
|
return offset;
|
|
59
43
|
}
|
|
60
44
|
}, {
|
|
61
45
|
key: "includesTrailingLines",
|
|
62
46
|
get: function get() {
|
|
47
|
+
// This is never called from anywhere, but if it were,
|
|
48
|
+
// this is the value it should return.
|
|
63
49
|
return true;
|
|
64
50
|
}
|
|
65
51
|
}]);
|
|
52
|
+
|
|
66
53
|
return BlankLine;
|
|
67
|
-
}(
|
|
54
|
+
}(Node);
|
|
68
55
|
|
|
69
|
-
|
|
56
|
+
export { BlankLine as default };
|
|
@@ -1,54 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
|
|
16
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
-
|
|
18
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
19
|
-
|
|
20
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
-
|
|
22
|
-
var _constants = require("../constants");
|
|
23
|
-
|
|
24
|
-
var _Node2 = _interopRequireDefault(require("./Node"));
|
|
25
|
-
|
|
26
|
-
var _Range = _interopRequireDefault(require("./Range"));
|
|
27
|
-
|
|
28
|
-
var Chomp = {
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
+
import _get from "@babel/runtime/helpers/get";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import { Type } from '../constants';
|
|
8
|
+
import Node from './Node';
|
|
9
|
+
import Range from './Range';
|
|
10
|
+
export var Chomp = {
|
|
29
11
|
CLIP: 'CLIP',
|
|
30
12
|
KEEP: 'KEEP',
|
|
31
13
|
STRIP: 'STRIP'
|
|
32
14
|
};
|
|
33
|
-
exports.Chomp = Chomp;
|
|
34
15
|
|
|
35
|
-
var BlockValue =
|
|
36
|
-
|
|
37
|
-
function (_Node) {
|
|
38
|
-
(0, _inherits2.default)(BlockValue, _Node);
|
|
16
|
+
var BlockValue = /*#__PURE__*/function (_Node) {
|
|
17
|
+
_inherits(BlockValue, _Node);
|
|
39
18
|
|
|
40
19
|
function BlockValue(type, props) {
|
|
41
20
|
var _this;
|
|
42
21
|
|
|
43
|
-
(
|
|
44
|
-
|
|
22
|
+
_classCallCheck(this, BlockValue);
|
|
23
|
+
|
|
24
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(BlockValue).call(this, type, props));
|
|
45
25
|
_this.blockIndent = null;
|
|
46
26
|
_this.chomping = Chomp.CLIP;
|
|
47
27
|
_this.header = null;
|
|
48
28
|
return _this;
|
|
49
29
|
}
|
|
50
30
|
|
|
51
|
-
(
|
|
31
|
+
_createClass(BlockValue, [{
|
|
52
32
|
key: "parseBlockHeader",
|
|
53
33
|
value: function parseBlockHeader(start) {
|
|
54
34
|
var src = this.context.src;
|
|
@@ -82,7 +62,7 @@ function (_Node) {
|
|
|
82
62
|
|
|
83
63
|
default:
|
|
84
64
|
this.blockIndent = Number(bi) || null;
|
|
85
|
-
this.header = new
|
|
65
|
+
this.header = new Range(start, offset);
|
|
86
66
|
return offset;
|
|
87
67
|
}
|
|
88
68
|
|
|
@@ -102,10 +82,8 @@ function (_Node) {
|
|
|
102
82
|
|
|
103
83
|
for (var ch = src[offset]; ch === '\n'; ch = src[offset]) {
|
|
104
84
|
offset += 1;
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
var end = _Node2.default.endOfBlockIndent(src, bi, offset); // should not include tab?
|
|
108
|
-
|
|
85
|
+
if (Node.atDocumentBoundary(src, offset)) break;
|
|
86
|
+
var end = Node.endOfBlockIndent(src, bi, offset); // should not include tab?
|
|
109
87
|
|
|
110
88
|
if (end === null) break;
|
|
111
89
|
|
|
@@ -131,7 +109,7 @@ function (_Node) {
|
|
|
131
109
|
if (src[end] === '\n') {
|
|
132
110
|
offset = end;
|
|
133
111
|
} else {
|
|
134
|
-
offset = valueEnd =
|
|
112
|
+
offset = valueEnd = Node.endOfLine(src, end);
|
|
135
113
|
}
|
|
136
114
|
}
|
|
137
115
|
|
|
@@ -139,7 +117,7 @@ function (_Node) {
|
|
|
139
117
|
offset = src[valueEnd] ? valueEnd + 1 : valueEnd;
|
|
140
118
|
}
|
|
141
119
|
|
|
142
|
-
this.valueRange = new
|
|
120
|
+
this.valueRange = new Range(start + 1, offset);
|
|
143
121
|
return offset;
|
|
144
122
|
}
|
|
145
123
|
/**
|
|
@@ -169,7 +147,7 @@ function (_Node) {
|
|
|
169
147
|
this.context = context;
|
|
170
148
|
var src = context.src;
|
|
171
149
|
var offset = this.parseBlockHeader(start);
|
|
172
|
-
offset =
|
|
150
|
+
offset = Node.endOfWhiteSpace(src, offset);
|
|
173
151
|
offset = this.parseComment(offset);
|
|
174
152
|
offset = this.parseBlockValue(offset);
|
|
175
153
|
return offset;
|
|
@@ -177,7 +155,7 @@ function (_Node) {
|
|
|
177
155
|
}, {
|
|
178
156
|
key: "setOrigRanges",
|
|
179
157
|
value: function setOrigRanges(cr, offset) {
|
|
180
|
-
offset = (
|
|
158
|
+
offset = _get(_getPrototypeOf(BlockValue.prototype), "setOrigRanges", this).call(this, cr, offset);
|
|
181
159
|
return this.header ? this.header.setOrigRange(cr, offset) : offset;
|
|
182
160
|
}
|
|
183
161
|
}, {
|
|
@@ -203,7 +181,7 @@ function (_Node) {
|
|
|
203
181
|
end -= 1;
|
|
204
182
|
|
|
205
183
|
if (end <= start) {
|
|
206
|
-
if (this.chomping === Chomp.KEEP) break;else return '';
|
|
184
|
+
if (this.chomping === Chomp.KEEP) break;else return ''; // probably never happens
|
|
207
185
|
}
|
|
208
186
|
|
|
209
187
|
if (ch === '\n') lastNewLine = end;
|
|
@@ -222,7 +200,7 @@ function (_Node) {
|
|
|
222
200
|
}
|
|
223
201
|
|
|
224
202
|
var bi = indent + this.blockIndent;
|
|
225
|
-
var folded = this.type ===
|
|
203
|
+
var folded = this.type === Type.BLOCK_FOLDED;
|
|
226
204
|
var atStart = true;
|
|
227
205
|
var str = '';
|
|
228
206
|
var sep = '';
|
|
@@ -239,8 +217,7 @@ function (_Node) {
|
|
|
239
217
|
if (_ch === '\n') {
|
|
240
218
|
if (sep === '\n') str += '\n';else sep = '\n';
|
|
241
219
|
} else {
|
|
242
|
-
var lineEnd =
|
|
243
|
-
|
|
220
|
+
var lineEnd = Node.endOfLine(src, i);
|
|
244
221
|
var line = src.slice(i, lineEnd);
|
|
245
222
|
i = lineEnd;
|
|
246
223
|
|
|
@@ -263,7 +240,8 @@ function (_Node) {
|
|
|
263
240
|
return this.chomping === Chomp.STRIP ? str : str + '\n';
|
|
264
241
|
}
|
|
265
242
|
}]);
|
|
243
|
+
|
|
266
244
|
return BlockValue;
|
|
267
|
-
}(
|
|
245
|
+
}(Node);
|
|
268
246
|
|
|
269
|
-
|
|
247
|
+
export { BlockValue as default };
|
|
@@ -1,41 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
|
-
|
|
17
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
18
|
-
|
|
19
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
20
|
-
|
|
21
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
22
|
-
|
|
23
|
-
var _constants = require("../constants");
|
|
24
|
-
|
|
25
|
-
var _BlankLine = _interopRequireDefault(require("./BlankLine"));
|
|
26
|
-
|
|
27
|
-
var _CollectionItem = _interopRequireDefault(require("./CollectionItem"));
|
|
28
|
-
|
|
29
|
-
var _Comment = _interopRequireDefault(require("./Comment"));
|
|
30
|
-
|
|
31
|
-
var _Node2 = _interopRequireDefault(require("./Node"));
|
|
32
|
-
|
|
33
|
-
var _Range = _interopRequireDefault(require("./Range"));
|
|
34
|
-
|
|
35
|
-
function grabCollectionEndComments(node) {
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
3
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
4
|
+
import _get from "@babel/runtime/helpers/get";
|
|
5
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import { Type } from '../constants';
|
|
8
|
+
import BlankLine from './BlankLine';
|
|
9
|
+
import CollectionItem from './CollectionItem';
|
|
10
|
+
import Comment from './Comment';
|
|
11
|
+
import Node from './Node';
|
|
12
|
+
import Range from './Range';
|
|
13
|
+
export function grabCollectionEndComments(node) {
|
|
36
14
|
var cnode = node;
|
|
37
15
|
|
|
38
|
-
while (cnode instanceof
|
|
16
|
+
while (cnode instanceof CollectionItem) {
|
|
39
17
|
cnode = cnode.node;
|
|
40
18
|
}
|
|
41
19
|
|
|
@@ -46,14 +24,14 @@ function grabCollectionEndComments(node) {
|
|
|
46
24
|
for (var i = len - 1; i >= 0; --i) {
|
|
47
25
|
var n = cnode.items[i];
|
|
48
26
|
|
|
49
|
-
if (n.type ===
|
|
27
|
+
if (n.type === Type.COMMENT) {
|
|
50
28
|
// Keep sufficiently indented comments with preceding node
|
|
51
29
|
var _n$context = n.context,
|
|
52
30
|
indent = _n$context.indent,
|
|
53
31
|
lineStart = _n$context.lineStart;
|
|
54
32
|
if (indent > 0 && n.range.start >= lineStart + indent) break;
|
|
55
33
|
ci = i;
|
|
56
|
-
} else if (n.type ===
|
|
34
|
+
} else if (n.type === Type.BLANK_LINE) ci = i;else break;
|
|
57
35
|
}
|
|
58
36
|
|
|
59
37
|
if (ci === -1) return null;
|
|
@@ -70,15 +48,14 @@ function grabCollectionEndComments(node) {
|
|
|
70
48
|
return ca;
|
|
71
49
|
}
|
|
72
50
|
|
|
73
|
-
var Collection =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
(
|
|
77
|
-
(0, _createClass2.default)(Collection, null, [{
|
|
51
|
+
var Collection = /*#__PURE__*/function (_Node) {
|
|
52
|
+
_inherits(Collection, _Node);
|
|
53
|
+
|
|
54
|
+
_createClass(Collection, null, [{
|
|
78
55
|
key: "nextContentHasIndent",
|
|
79
56
|
value: function nextContentHasIndent(src, offset, indent) {
|
|
80
|
-
var lineStart =
|
|
81
|
-
offset =
|
|
57
|
+
var lineStart = Node.endOfLine(src, offset) + 1;
|
|
58
|
+
offset = Node.endOfWhiteSpace(src, lineStart);
|
|
82
59
|
var ch = src[offset];
|
|
83
60
|
if (!ch) return false;
|
|
84
61
|
if (offset >= lineStart + indent) return true;
|
|
@@ -90,8 +67,9 @@ function (_Node) {
|
|
|
90
67
|
function Collection(firstItem) {
|
|
91
68
|
var _this;
|
|
92
69
|
|
|
93
|
-
(
|
|
94
|
-
|
|
70
|
+
_classCallCheck(this, Collection);
|
|
71
|
+
|
|
72
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(Collection).call(this, firstItem.type === Type.SEQ_ITEM ? Type.SEQ : Type.MAP));
|
|
95
73
|
|
|
96
74
|
for (var i = firstItem.props.length - 1; i >= 0; --i) {
|
|
97
75
|
if (firstItem.props[i].start < firstItem.context.lineStart) {
|
|
@@ -110,7 +88,7 @@ function (_Node) {
|
|
|
110
88
|
return _this;
|
|
111
89
|
}
|
|
112
90
|
|
|
113
|
-
(
|
|
91
|
+
_createClass(Collection, [{
|
|
114
92
|
key: "parse",
|
|
115
93
|
|
|
116
94
|
/**
|
|
@@ -124,24 +102,23 @@ function (_Node) {
|
|
|
124
102
|
src = context.src; // It's easier to recalculate lineStart here rather than tracking down the
|
|
125
103
|
// last context from which to read it -- eemeli/yaml#2
|
|
126
104
|
|
|
127
|
-
var lineStart =
|
|
128
|
-
|
|
105
|
+
var lineStart = Node.startOfLine(src, start);
|
|
129
106
|
var firstItem = this.items[0]; // First-item context needs to be correct for later comment handling
|
|
130
107
|
// -- eemeli/yaml#17
|
|
131
108
|
|
|
132
109
|
firstItem.context.parent = this;
|
|
133
|
-
this.valueRange =
|
|
110
|
+
this.valueRange = Range.copy(firstItem.valueRange);
|
|
134
111
|
var indent = firstItem.range.start - firstItem.context.lineStart;
|
|
135
112
|
var offset = start;
|
|
136
|
-
offset =
|
|
113
|
+
offset = Node.normalizeOffset(src, offset);
|
|
137
114
|
var ch = src[offset];
|
|
138
|
-
var atLineStart =
|
|
115
|
+
var atLineStart = Node.endOfWhiteSpace(src, lineStart) === offset;
|
|
139
116
|
var prevIncludesTrailingLines = false;
|
|
140
117
|
|
|
141
118
|
while (ch) {
|
|
142
119
|
while (ch === '\n' || ch === '#') {
|
|
143
120
|
if (atLineStart && ch === '\n' && !prevIncludesTrailingLines) {
|
|
144
|
-
var blankLine = new
|
|
121
|
+
var blankLine = new BlankLine();
|
|
145
122
|
offset = blankLine.parse({
|
|
146
123
|
src: src
|
|
147
124
|
}, offset);
|
|
@@ -159,7 +136,7 @@ function (_Node) {
|
|
|
159
136
|
return offset;
|
|
160
137
|
}
|
|
161
138
|
|
|
162
|
-
var comment = new
|
|
139
|
+
var comment = new Comment();
|
|
163
140
|
offset = comment.parse({
|
|
164
141
|
indent: indent,
|
|
165
142
|
lineStart: lineStart,
|
|
@@ -175,11 +152,10 @@ function (_Node) {
|
|
|
175
152
|
}
|
|
176
153
|
|
|
177
154
|
lineStart = offset + 1;
|
|
178
|
-
offset =
|
|
179
|
-
|
|
180
|
-
if (_Node2.default.atBlank(src, offset)) {
|
|
181
|
-
var wsEnd = _Node2.default.endOfWhiteSpace(src, offset);
|
|
155
|
+
offset = Node.endOfIndent(src, lineStart);
|
|
182
156
|
|
|
157
|
+
if (Node.atBlank(src, offset)) {
|
|
158
|
+
var wsEnd = Node.endOfWhiteSpace(src, offset);
|
|
183
159
|
var next = src[wsEnd];
|
|
184
160
|
|
|
185
161
|
if (!next || next === '\n' || next === '#') {
|
|
@@ -200,7 +176,7 @@ function (_Node) {
|
|
|
200
176
|
break;
|
|
201
177
|
}
|
|
202
178
|
|
|
203
|
-
if (firstItem.type ===
|
|
179
|
+
if (firstItem.type === Type.SEQ_ITEM !== (ch === '-')) {
|
|
204
180
|
var typeswitch = true;
|
|
205
181
|
|
|
206
182
|
if (ch === '-') {
|
|
@@ -226,7 +202,7 @@ function (_Node) {
|
|
|
226
202
|
|
|
227
203
|
this.items.push(node);
|
|
228
204
|
this.valueRange.end = node.valueRange.end;
|
|
229
|
-
offset =
|
|
205
|
+
offset = Node.normalizeOffset(src, node.range.end);
|
|
230
206
|
ch = src[offset];
|
|
231
207
|
atLineStart = false;
|
|
232
208
|
prevIncludesTrailingLines = node.includesTrailingLines; // Need to reset lineStart and atLineStart here if preceding node's range
|
|
@@ -256,7 +232,7 @@ function (_Node) {
|
|
|
256
232
|
}, {
|
|
257
233
|
key: "setOrigRanges",
|
|
258
234
|
value: function setOrigRanges(cr, offset) {
|
|
259
|
-
offset = (
|
|
235
|
+
offset = _get(_getPrototypeOf(Collection.prototype), "setOrigRanges", this).call(this, cr, offset);
|
|
260
236
|
this.items.forEach(function (node) {
|
|
261
237
|
offset = node.setOrigRanges(cr, offset);
|
|
262
238
|
});
|
|
@@ -283,7 +259,7 @@ function (_Node) {
|
|
|
283
259
|
str += String(item);
|
|
284
260
|
}
|
|
285
261
|
|
|
286
|
-
return
|
|
262
|
+
return Node.addStringTerminator(src, range.end, str);
|
|
287
263
|
}
|
|
288
264
|
}, {
|
|
289
265
|
key: "includesTrailingLines",
|
|
@@ -291,7 +267,8 @@ function (_Node) {
|
|
|
291
267
|
return this.items.length > 0;
|
|
292
268
|
}
|
|
293
269
|
}]);
|
|
270
|
+
|
|
294
271
|
return Collection;
|
|
295
|
-
}(
|
|
272
|
+
}(Node);
|
|
296
273
|
|
|
297
|
-
|
|
274
|
+
export { Collection as default };
|