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
|
@@ -5,18 +5,18 @@ 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
14
|
var _Comment = _interopRequireDefault(require("./Comment"));
|
|
13
15
|
|
|
14
|
-
var _Node =
|
|
16
|
+
var _Node = _interopRequireDefault(require("./Node"));
|
|
15
17
|
|
|
16
18
|
var _Range = _interopRequireDefault(require("./Range"));
|
|
17
19
|
|
|
18
|
-
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; } }
|
|
19
|
-
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
22
22
|
class FlowCollection extends _Node.default {
|
|
@@ -27,7 +27,7 @@ class FlowCollection extends _Node.default {
|
|
|
27
27
|
|
|
28
28
|
prevNodeIsJsonLike(idx = this.items.length) {
|
|
29
29
|
const node = this.items[idx - 1];
|
|
30
|
-
return !!node && (node.jsonLike || node.type ===
|
|
30
|
+
return !!node && (node.jsonLike || node.type === _constants.Type.COMMENT && this.nodeIsJsonLike(idx - 1));
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* @param {ParseContext} context
|
|
@@ -74,7 +74,15 @@ class FlowCollection extends _Node.default {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
offset = _Node.default.endOfIndent(src, lineStart);
|
|
77
|
-
|
|
77
|
+
|
|
78
|
+
if (offset <= lineStart + indent) {
|
|
79
|
+
char = src[offset];
|
|
80
|
+
|
|
81
|
+
if (offset < lineStart + indent || char !== ']' && char !== '}') {
|
|
82
|
+
const msg = 'Insufficient indentation in flow collection';
|
|
83
|
+
this.error = new _errors.YAMLSemanticError(this, msg);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
78
86
|
}
|
|
79
87
|
break;
|
|
80
88
|
|
|
@@ -207,6 +215,4 @@ class FlowCollection extends _Node.default {
|
|
|
207
215
|
|
|
208
216
|
}
|
|
209
217
|
|
|
210
|
-
exports.default = FlowCollection;
|
|
211
|
-
module.exports = exports.default;
|
|
212
|
-
module.exports.default = exports.default;
|
|
218
|
+
exports.default = FlowCollection;
|
package/dist/cst/Node.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("../constants");
|
|
7
9
|
|
|
8
10
|
var _getLinePos = _interopRequireDefault(require("./getLinePos"));
|
|
9
11
|
|
|
@@ -11,37 +13,7 @@ var _Range = _interopRequireDefault(require("./Range"));
|
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
ALIAS: 'ALIAS',
|
|
16
|
-
BLANK_LINE: 'BLANK_LINE',
|
|
17
|
-
BLOCK_FOLDED: 'BLOCK_FOLDED',
|
|
18
|
-
BLOCK_LITERAL: 'BLOCK_LITERAL',
|
|
19
|
-
COMMENT: 'COMMENT',
|
|
20
|
-
DIRECTIVE: 'DIRECTIVE',
|
|
21
|
-
DOCUMENT: 'DOCUMENT',
|
|
22
|
-
FLOW_MAP: 'FLOW_MAP',
|
|
23
|
-
FLOW_SEQ: 'FLOW_SEQ',
|
|
24
|
-
MAP: 'MAP',
|
|
25
|
-
MAP_KEY: 'MAP_KEY',
|
|
26
|
-
MAP_VALUE: 'MAP_VALUE',
|
|
27
|
-
PLAIN: 'PLAIN',
|
|
28
|
-
QUOTE_DOUBLE: 'QUOTE_DOUBLE',
|
|
29
|
-
QUOTE_SINGLE: 'QUOTE_SINGLE',
|
|
30
|
-
SEQ: 'SEQ',
|
|
31
|
-
SEQ_ITEM: 'SEQ_ITEM'
|
|
32
|
-
};
|
|
33
|
-
exports.Type = Type;
|
|
34
|
-
const Char = {
|
|
35
|
-
ANCHOR: '&',
|
|
36
|
-
COMMENT: '#',
|
|
37
|
-
TAG: '!',
|
|
38
|
-
DIRECTIVES_END: '-',
|
|
39
|
-
DOCUMENT_END: '.'
|
|
40
|
-
/** Root class of all nodes */
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
exports.Char = Char;
|
|
44
|
-
|
|
16
|
+
/** Root class of all nodes */
|
|
45
17
|
class Node {
|
|
46
18
|
static addStringTerminator(src, offset, str) {
|
|
47
19
|
if (str[str.length - 1] === '\n') return str;
|
|
@@ -59,7 +31,7 @@ class Node {
|
|
|
59
31
|
if (sep) {
|
|
60
32
|
if (ch0 !== sep) return false;
|
|
61
33
|
} else {
|
|
62
|
-
if (ch0 !== Char.DIRECTIVES_END && ch0 !== Char.DOCUMENT_END) return false;
|
|
34
|
+
if (ch0 !== _constants.Char.DIRECTIVES_END && ch0 !== _constants.Char.DOCUMENT_END) return false;
|
|
63
35
|
}
|
|
64
36
|
|
|
65
37
|
const ch1 = src[offset + 1];
|
|
@@ -219,7 +191,7 @@ class Node {
|
|
|
219
191
|
|
|
220
192
|
get anchor() {
|
|
221
193
|
for (let i = 0; i < this.props.length; ++i) {
|
|
222
|
-
const anchor = this.getPropValue(i, Char.ANCHOR, true);
|
|
194
|
+
const anchor = this.getPropValue(i, _constants.Char.ANCHOR, true);
|
|
223
195
|
if (anchor != null) return anchor;
|
|
224
196
|
}
|
|
225
197
|
|
|
@@ -230,7 +202,7 @@ class Node {
|
|
|
230
202
|
const comments = [];
|
|
231
203
|
|
|
232
204
|
for (let i = 0; i < this.props.length; ++i) {
|
|
233
|
-
const comment = this.getPropValue(i, Char.COMMENT, true);
|
|
205
|
+
const comment = this.getPropValue(i, _constants.Char.COMMENT, true);
|
|
234
206
|
if (comment != null) comments.push(comment);
|
|
235
207
|
}
|
|
236
208
|
|
|
@@ -256,7 +228,7 @@ class Node {
|
|
|
256
228
|
} = this.context;
|
|
257
229
|
|
|
258
230
|
for (let i = 0; i < this.props.length; ++i) {
|
|
259
|
-
if (src[this.props[i].start] === Char.COMMENT) return true;
|
|
231
|
+
if (src[this.props[i].start] === _constants.Char.COMMENT) return true;
|
|
260
232
|
}
|
|
261
233
|
}
|
|
262
234
|
|
|
@@ -270,7 +242,7 @@ class Node {
|
|
|
270
242
|
} = this.context;
|
|
271
243
|
|
|
272
244
|
for (let i = 0; i < this.props.length; ++i) {
|
|
273
|
-
if (src[this.props[i].start] !== Char.COMMENT) return true;
|
|
245
|
+
if (src[this.props[i].start] !== _constants.Char.COMMENT) return true;
|
|
274
246
|
}
|
|
275
247
|
}
|
|
276
248
|
|
|
@@ -282,7 +254,7 @@ class Node {
|
|
|
282
254
|
}
|
|
283
255
|
|
|
284
256
|
get jsonLike() {
|
|
285
|
-
const jsonLikeTypes = [Type.FLOW_MAP, Type.FLOW_SEQ, Type.QUOTE_DOUBLE, Type.QUOTE_SINGLE];
|
|
257
|
+
const jsonLikeTypes = [_constants.Type.FLOW_MAP, _constants.Type.FLOW_SEQ, _constants.Type.QUOTE_DOUBLE, _constants.Type.QUOTE_SINGLE];
|
|
286
258
|
return jsonLikeTypes.indexOf(this.type) !== -1;
|
|
287
259
|
}
|
|
288
260
|
|
|
@@ -308,7 +280,7 @@ class Node {
|
|
|
308
280
|
|
|
309
281
|
get tag() {
|
|
310
282
|
for (let i = 0; i < this.props.length; ++i) {
|
|
311
|
-
const tag = this.getPropValue(i, Char.TAG, false);
|
|
283
|
+
const tag = this.getPropValue(i, _constants.Char.TAG, false);
|
|
312
284
|
|
|
313
285
|
if (tag != null) {
|
|
314
286
|
if (tag[1] === '<') {
|
|
@@ -351,7 +323,7 @@ class Node {
|
|
|
351
323
|
src
|
|
352
324
|
} = this.context;
|
|
353
325
|
|
|
354
|
-
if (src[start] === Char.COMMENT) {
|
|
326
|
+
if (src[start] === _constants.Char.COMMENT) {
|
|
355
327
|
const end = Node.endOfLine(src, start + 1);
|
|
356
328
|
const commentRange = new _Range.default(start, end);
|
|
357
329
|
this.props.push(commentRange);
|
package/dist/cst/ParseContext.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 _Alias = _interopRequireDefault(require("./Alias"));
|
|
@@ -17,7 +19,7 @@ var _CollectionItem = _interopRequireDefault(require("./CollectionItem"));
|
|
|
17
19
|
|
|
18
20
|
var _FlowCollection = _interopRequireDefault(require("./FlowCollection"));
|
|
19
21
|
|
|
20
|
-
var _Node =
|
|
22
|
+
var _Node = _interopRequireDefault(require("./Node"));
|
|
21
23
|
|
|
22
24
|
var _PlainValue = _interopRequireDefault(require("./PlainValue"));
|
|
23
25
|
|
|
@@ -27,8 +29,6 @@ var _QuoteSingle = _interopRequireDefault(require("./QuoteSingle"));
|
|
|
27
29
|
|
|
28
30
|
var _Range = _interopRequireDefault(require("./Range"));
|
|
29
31
|
|
|
30
|
-
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; } }
|
|
31
|
-
|
|
32
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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; }
|
|
@@ -46,37 +46,37 @@ class ParseContext {
|
|
|
46
46
|
static parseType(src, offset, inFlow) {
|
|
47
47
|
switch (src[offset]) {
|
|
48
48
|
case '*':
|
|
49
|
-
return
|
|
49
|
+
return _constants.Type.ALIAS;
|
|
50
50
|
|
|
51
51
|
case '>':
|
|
52
|
-
return
|
|
52
|
+
return _constants.Type.BLOCK_FOLDED;
|
|
53
53
|
|
|
54
54
|
case '|':
|
|
55
|
-
return
|
|
55
|
+
return _constants.Type.BLOCK_LITERAL;
|
|
56
56
|
|
|
57
57
|
case '{':
|
|
58
|
-
return
|
|
58
|
+
return _constants.Type.FLOW_MAP;
|
|
59
59
|
|
|
60
60
|
case '[':
|
|
61
|
-
return
|
|
61
|
+
return _constants.Type.FLOW_SEQ;
|
|
62
62
|
|
|
63
63
|
case '?':
|
|
64
|
-
return !inFlow && _Node.default.atBlank(src, offset + 1, true) ?
|
|
64
|
+
return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? _constants.Type.MAP_KEY : _constants.Type.PLAIN;
|
|
65
65
|
|
|
66
66
|
case ':':
|
|
67
|
-
return !inFlow && _Node.default.atBlank(src, offset + 1, true) ?
|
|
67
|
+
return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? _constants.Type.MAP_VALUE : _constants.Type.PLAIN;
|
|
68
68
|
|
|
69
69
|
case '-':
|
|
70
|
-
return !inFlow && _Node.default.atBlank(src, offset + 1, true) ?
|
|
70
|
+
return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? _constants.Type.SEQ_ITEM : _constants.Type.PLAIN;
|
|
71
71
|
|
|
72
72
|
case '"':
|
|
73
|
-
return
|
|
73
|
+
return _constants.Type.QUOTE_DOUBLE;
|
|
74
74
|
|
|
75
75
|
case "'":
|
|
76
|
-
return
|
|
76
|
+
return _constants.Type.QUOTE_SINGLE;
|
|
77
77
|
|
|
78
78
|
default:
|
|
79
|
-
return
|
|
79
|
+
return _constants.Type.PLAIN;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -99,36 +99,36 @@ class ParseContext {
|
|
|
99
99
|
let node;
|
|
100
100
|
|
|
101
101
|
switch (type) {
|
|
102
|
-
case
|
|
102
|
+
case _constants.Type.ALIAS:
|
|
103
103
|
node = new _Alias.default(type, props);
|
|
104
104
|
break;
|
|
105
105
|
|
|
106
|
-
case
|
|
107
|
-
case
|
|
106
|
+
case _constants.Type.BLOCK_FOLDED:
|
|
107
|
+
case _constants.Type.BLOCK_LITERAL:
|
|
108
108
|
node = new _BlockValue.default(type, props);
|
|
109
109
|
break;
|
|
110
110
|
|
|
111
|
-
case
|
|
112
|
-
case
|
|
111
|
+
case _constants.Type.FLOW_MAP:
|
|
112
|
+
case _constants.Type.FLOW_SEQ:
|
|
113
113
|
node = new _FlowCollection.default(type, props);
|
|
114
114
|
break;
|
|
115
115
|
|
|
116
|
-
case
|
|
117
|
-
case
|
|
118
|
-
case
|
|
116
|
+
case _constants.Type.MAP_KEY:
|
|
117
|
+
case _constants.Type.MAP_VALUE:
|
|
118
|
+
case _constants.Type.SEQ_ITEM:
|
|
119
119
|
node = new _CollectionItem.default(type, props);
|
|
120
120
|
break;
|
|
121
121
|
|
|
122
|
-
case
|
|
123
|
-
case
|
|
122
|
+
case _constants.Type.COMMENT:
|
|
123
|
+
case _constants.Type.PLAIN:
|
|
124
124
|
node = new _PlainValue.default(type, props);
|
|
125
125
|
break;
|
|
126
126
|
|
|
127
|
-
case
|
|
127
|
+
case _constants.Type.QUOTE_DOUBLE:
|
|
128
128
|
node = new _QuoteDouble.default(type, props);
|
|
129
129
|
break;
|
|
130
130
|
|
|
131
|
-
case
|
|
131
|
+
case _constants.Type.QUOTE_SINGLE:
|
|
132
132
|
node = new _QuoteSingle.default(type, props);
|
|
133
133
|
break;
|
|
134
134
|
|
|
@@ -149,7 +149,7 @@ class ParseContext {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
if (context.nodeStartsCollection(node)) {
|
|
152
|
-
if (!node.error && !context.atLineStart && context.parent.type ===
|
|
152
|
+
if (!node.error && !context.atLineStart && context.parent.type === _constants.Type.DOCUMENT) {
|
|
153
153
|
node.error = new _errors.YAMLSyntaxError(node, 'Block collection must not have preceding content here (e.g. directives-end indicator)');
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -213,20 +213,20 @@ class ParseContext {
|
|
|
213
213
|
offset = _Node.default.endOfWhiteSpace(src, offset);
|
|
214
214
|
let ch = src[offset];
|
|
215
215
|
|
|
216
|
-
while (ch ===
|
|
216
|
+
while (ch === _constants.Char.ANCHOR || ch === _constants.Char.COMMENT || ch === _constants.Char.TAG || ch === '\n') {
|
|
217
217
|
if (ch === '\n') {
|
|
218
218
|
const lineStart = offset + 1;
|
|
219
219
|
|
|
220
220
|
const inEnd = _Node.default.endOfIndent(src, lineStart);
|
|
221
221
|
|
|
222
222
|
const indentDiff = inEnd - (lineStart + this.indent);
|
|
223
|
-
const noIndicatorAsIndent = parent.type ===
|
|
223
|
+
const noIndicatorAsIndent = parent.type === _constants.Type.SEQ_ITEM && parent.context.atLineStart;
|
|
224
224
|
if (!_Node.default.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break;
|
|
225
225
|
this.atLineStart = true;
|
|
226
226
|
this.lineStart = lineStart;
|
|
227
227
|
lineHasProps = false;
|
|
228
228
|
offset = inEnd;
|
|
229
|
-
} else if (ch ===
|
|
229
|
+
} else if (ch === _constants.Char.COMMENT) {
|
|
230
230
|
const end = _Node.default.endOfLine(src, offset + 1);
|
|
231
231
|
|
|
232
232
|
props.push(new _Range.default(offset, end));
|
|
@@ -234,7 +234,7 @@ class ParseContext {
|
|
|
234
234
|
} else {
|
|
235
235
|
let end = _Node.default.endOfIdentifier(src, offset + 1);
|
|
236
236
|
|
|
237
|
-
if (ch ===
|
|
237
|
+
if (ch === _constants.Char.TAG && src[end] === ',' && /^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(src.slice(offset + 1, end + 13))) {
|
|
238
238
|
// Let's presume we're dealing with a YAML 1.0 domain tag here, rather
|
|
239
239
|
// than an empty but 'foo.bar' private-tagged node in a flow collection
|
|
240
240
|
// followed without whitespace by a plain string starting with a year
|
|
@@ -269,6 +269,4 @@ class ParseContext {
|
|
|
269
269
|
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
exports.default = ParseContext;
|
|
273
|
-
module.exports = exports.default;
|
|
274
|
-
module.exports.default = exports.default;
|
|
272
|
+
exports.default = ParseContext;
|
package/dist/cst/PlainValue.js
CHANGED
package/dist/cst/QuoteDouble.js
CHANGED
package/dist/cst/QuoteSingle.js
CHANGED
package/dist/cst/Range.js
CHANGED
package/dist/cst/getLinePos.js
CHANGED
package/dist/cst/parse.js
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.warnFileDeprecation = warnFileDeprecation;
|
|
7
|
+
exports.warnOptionDeprecation = warnOptionDeprecation;
|
|
8
|
+
|
|
9
|
+
/* global global, console */
|
|
10
|
+
function warn(msg) {
|
|
11
|
+
if (global && global.process && global.process.emitWarning) {
|
|
12
|
+
global.process.emitWarning(msg, 'DeprecationWarning');
|
|
13
|
+
} else {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.warn(`DeprecationWarning: ${msg}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function warnFileDeprecation(filename) {
|
|
20
|
+
if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return;
|
|
21
|
+
const path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/');
|
|
22
|
+
warn(`The endpoint 'yaml/${path}' will be removed in a future release.`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const warned = {};
|
|
26
|
+
|
|
27
|
+
function warnOptionDeprecation(name, alternative) {
|
|
28
|
+
if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return;
|
|
29
|
+
if (warned[name]) return;
|
|
30
|
+
warned[name] = true;
|
|
31
|
+
let msg = `The option '${name}' will be removed in a future release`;
|
|
32
|
+
msg += alternative ? `, use '${alternative}' instead.` : '.';
|
|
33
|
+
warn(msg);
|
|
34
|
+
}
|
package/dist/errors.js
CHANGED
|
@@ -3,70 +3,64 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.YAMLWarning = exports.YAMLSyntaxError = exports.YAMLSemanticError = exports.YAMLReferenceError = void 0;
|
|
6
|
+
exports.YAMLWarning = exports.YAMLSyntaxError = exports.YAMLSemanticError = exports.YAMLReferenceError = exports.YAMLError = void 0;
|
|
7
7
|
|
|
8
8
|
var _Node = _interopRequireDefault(require("./cst/Node"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
|
-
class
|
|
13
|
-
constructor(source, message) {
|
|
14
|
-
if (!message || !(source instanceof _Node.default)) {
|
|
15
|
-
throw new Error('Invalid arguments for new YAMLReferenceError');
|
|
16
|
-
}
|
|
17
|
-
|
|
12
|
+
class YAMLError extends Error {
|
|
13
|
+
constructor(name, source, message) {
|
|
14
|
+
if (!message || !(source instanceof _Node.default)) throw new Error(`Invalid arguments for new ${name}`);
|
|
18
15
|
super();
|
|
19
|
-
this.name =
|
|
16
|
+
this.name = name;
|
|
20
17
|
this.message = message;
|
|
21
18
|
this.source = source;
|
|
22
19
|
}
|
|
23
20
|
|
|
21
|
+
makePretty() {
|
|
22
|
+
if (this.source) {
|
|
23
|
+
this.nodeType = this.source.type;
|
|
24
|
+
this.range = this.source.range;
|
|
25
|
+
this.linePos = this.source.rangeAsLinePos;
|
|
26
|
+
delete this.source;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
exports.
|
|
32
|
+
exports.YAMLError = YAMLError;
|
|
27
33
|
|
|
28
|
-
class
|
|
34
|
+
class YAMLReferenceError extends YAMLError {
|
|
29
35
|
constructor(source, message) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
36
|
+
super('YAMLReferenceError', source, message);
|
|
37
|
+
}
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.YAMLReferenceError = YAMLReferenceError;
|
|
42
|
+
|
|
43
|
+
class YAMLSemanticError extends YAMLError {
|
|
44
|
+
constructor(source, message) {
|
|
45
|
+
super('YAMLSemanticError', source, message);
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
exports.YAMLSemanticError = YAMLSemanticError;
|
|
43
51
|
|
|
44
|
-
class YAMLSyntaxError extends
|
|
52
|
+
class YAMLSyntaxError extends YAMLError {
|
|
45
53
|
constructor(source, message) {
|
|
46
|
-
|
|
47
|
-
throw new Error('Invalid arguments for new YAMLSyntaxError');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
super();
|
|
51
|
-
this.name = 'YAMLSyntaxError';
|
|
52
|
-
this.message = message;
|
|
53
|
-
this.source = source;
|
|
54
|
+
super('YAMLSyntaxError', source, message);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
exports.YAMLSyntaxError = YAMLSyntaxError;
|
|
59
60
|
|
|
60
|
-
class YAMLWarning extends
|
|
61
|
+
class YAMLWarning extends YAMLError {
|
|
61
62
|
constructor(source, message) {
|
|
62
|
-
|
|
63
|
-
throw new Error('Invalid arguments for new YAMLWarning');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
super();
|
|
67
|
-
this.name = 'YAMLWarning';
|
|
68
|
-
this.message = message;
|
|
69
|
-
this.source = source;
|
|
63
|
+
super('YAMLWarning', source, message);
|
|
70
64
|
}
|
|
71
65
|
|
|
72
66
|
}
|
package/dist/index.js
CHANGED
|
@@ -17,10 +17,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
17
|
|
|
18
18
|
/* global console */
|
|
19
19
|
const defaultOptions = {
|
|
20
|
+
anchorPrefix: 'a',
|
|
21
|
+
customTags: null,
|
|
22
|
+
keepCstNodes: false,
|
|
20
23
|
keepNodeTypes: true,
|
|
21
24
|
keepBlobsInJSON: true,
|
|
22
25
|
mapAsMap: false,
|
|
23
|
-
|
|
26
|
+
maxAliasCount: 100,
|
|
27
|
+
prettyErrors: false,
|
|
28
|
+
// TODO Set true in v2
|
|
24
29
|
version: '1.2'
|
|
25
30
|
};
|
|
26
31
|
|
|
@@ -43,7 +48,17 @@ class Document extends _Document.default {
|
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
function parseAllDocuments(src, options) {
|
|
46
|
-
|
|
51
|
+
const stream = [];
|
|
52
|
+
let prev;
|
|
53
|
+
|
|
54
|
+
for (const cstDoc of (0, _parse.default)(src)) {
|
|
55
|
+
const doc = new Document(options);
|
|
56
|
+
doc.parse(cstDoc, prev);
|
|
57
|
+
stream.push(doc);
|
|
58
|
+
prev = doc;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return stream;
|
|
47
62
|
}
|
|
48
63
|
|
|
49
64
|
function parseDocument(src, options) {
|
|
@@ -82,6 +97,4 @@ var _default = {
|
|
|
82
97
|
parseDocument,
|
|
83
98
|
stringify
|
|
84
99
|
};
|
|
85
|
-
exports.default = _default;
|
|
86
|
-
module.exports = exports.default;
|
|
87
|
-
module.exports.default = exports.default;
|
|
100
|
+
exports.default = _default;
|
package/dist/listTagNames.js
CHANGED