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
package/browser/dist/Anchors.js
CHANGED
|
@@ -1,65 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
|
-
var _Alias = _interopRequireDefault(require("./schema/Alias"));
|
|
17
|
-
|
|
18
|
-
var _Map = _interopRequireDefault(require("./schema/Map"));
|
|
19
|
-
|
|
20
|
-
var _Merge = _interopRequireDefault(require("./schema/Merge"));
|
|
21
|
-
|
|
22
|
-
var _Scalar = _interopRequireDefault(require("./schema/Scalar"));
|
|
23
|
-
|
|
24
|
-
var _Seq = _interopRequireDefault(require("./schema/Seq"));
|
|
25
|
-
|
|
26
|
-
var Anchors =
|
|
27
|
-
/*#__PURE__*/
|
|
28
|
-
function () {
|
|
29
|
-
(0, _createClass2.default)(Anchors, null, [{
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import Alias from './schema/Alias';
|
|
5
|
+
import Map from './schema/Map';
|
|
6
|
+
import Merge from './schema/Merge';
|
|
7
|
+
import Scalar from './schema/Scalar';
|
|
8
|
+
import Seq from './schema/Seq';
|
|
9
|
+
|
|
10
|
+
var Anchors = /*#__PURE__*/function () {
|
|
11
|
+
_createClass(Anchors, null, [{
|
|
30
12
|
key: "validAnchorNode",
|
|
31
13
|
value: function validAnchorNode(node) {
|
|
32
|
-
return node instanceof
|
|
14
|
+
return node instanceof Scalar || node instanceof Seq || node instanceof Map;
|
|
33
15
|
}
|
|
34
16
|
}]);
|
|
35
17
|
|
|
36
18
|
function Anchors(prefix) {
|
|
37
|
-
(
|
|
38
|
-
|
|
19
|
+
_classCallCheck(this, Anchors);
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "map", {});
|
|
22
|
+
|
|
39
23
|
this.prefix = prefix;
|
|
40
24
|
}
|
|
41
25
|
|
|
42
|
-
(
|
|
26
|
+
_createClass(Anchors, [{
|
|
43
27
|
key: "createAlias",
|
|
44
28
|
value: function createAlias(node, name) {
|
|
45
29
|
this.setAnchor(node, name);
|
|
46
|
-
return new
|
|
30
|
+
return new Alias(node);
|
|
47
31
|
}
|
|
48
32
|
}, {
|
|
49
33
|
key: "createMergePair",
|
|
50
34
|
value: function createMergePair() {
|
|
51
35
|
var _this = this;
|
|
52
36
|
|
|
53
|
-
var merge = new
|
|
37
|
+
var merge = new Merge();
|
|
54
38
|
|
|
55
39
|
for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
56
40
|
sources[_key] = arguments[_key];
|
|
57
41
|
}
|
|
58
42
|
|
|
59
43
|
merge.value.items = sources.map(function (s) {
|
|
60
|
-
if (s instanceof
|
|
61
|
-
if (s.source instanceof
|
|
62
|
-
} else if (s instanceof
|
|
44
|
+
if (s instanceof Alias) {
|
|
45
|
+
if (s.source instanceof Map) return s;
|
|
46
|
+
} else if (s instanceof Map) {
|
|
63
47
|
return _this.createAlias(s);
|
|
64
48
|
}
|
|
65
49
|
|
|
@@ -142,7 +126,8 @@ function () {
|
|
|
142
126
|
return name;
|
|
143
127
|
}
|
|
144
128
|
}]);
|
|
129
|
+
|
|
145
130
|
return Anchors;
|
|
146
131
|
}();
|
|
147
132
|
|
|
148
|
-
|
|
133
|
+
export { Anchors as default };
|
package/browser/dist/Document.js
CHANGED
|
@@ -1,54 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
|
|
20
|
-
var _addComment = _interopRequireDefault(require("./addComment"));
|
|
21
|
-
|
|
22
|
-
var _Anchors = _interopRequireDefault(require("./Anchors"));
|
|
23
|
-
|
|
24
|
-
var _constants = require("./constants");
|
|
25
|
-
|
|
26
|
-
var _errors = require("./errors");
|
|
27
|
-
|
|
28
|
-
var _listTagNames = _interopRequireDefault(require("./listTagNames"));
|
|
29
|
-
|
|
30
|
-
var _schema = _interopRequireDefault(require("./schema"));
|
|
31
|
-
|
|
32
|
-
var _Alias = _interopRequireDefault(require("./schema/Alias"));
|
|
33
|
-
|
|
34
|
-
var _Collection = _interopRequireWildcard(require("./schema/Collection"));
|
|
35
|
-
|
|
36
|
-
var _Node = _interopRequireDefault(require("./schema/Node"));
|
|
37
|
-
|
|
38
|
-
var _Scalar = _interopRequireDefault(require("./schema/Scalar"));
|
|
39
|
-
|
|
40
|
-
var _toJSON2 = _interopRequireDefault(require("./toJSON"));
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
import addComment from './addComment';
|
|
6
|
+
import Anchors from './Anchors';
|
|
7
|
+
import { Char, Type } from './constants';
|
|
8
|
+
import { YAMLError, YAMLReferenceError, YAMLSemanticError, YAMLSyntaxError, YAMLWarning } from './errors';
|
|
9
|
+
import listTagNames from './listTagNames';
|
|
10
|
+
import Schema from './schema';
|
|
11
|
+
import Alias from './schema/Alias';
|
|
12
|
+
import Collection, { isEmptyPath } from './schema/Collection';
|
|
13
|
+
import Node from './schema/Node';
|
|
14
|
+
import Scalar from './schema/Scalar';
|
|
15
|
+
import _toJSON from './toJSON';
|
|
41
16
|
|
|
42
17
|
var isCollectionItem = function isCollectionItem(node) {
|
|
43
|
-
return node && [
|
|
18
|
+
return node && [Type.MAP_KEY, Type.MAP_VALUE, Type.SEQ_ITEM].includes(node.type);
|
|
44
19
|
};
|
|
45
20
|
|
|
46
|
-
var Document =
|
|
47
|
-
/*#__PURE__*/
|
|
48
|
-
function () {
|
|
21
|
+
var Document = /*#__PURE__*/function () {
|
|
49
22
|
function Document(options) {
|
|
50
|
-
(
|
|
51
|
-
|
|
23
|
+
_classCallCheck(this, Document);
|
|
24
|
+
|
|
25
|
+
this.anchors = new Anchors(options.anchorPrefix);
|
|
52
26
|
this.commentBefore = null;
|
|
53
27
|
this.comment = null;
|
|
54
28
|
this.contents = null;
|
|
@@ -61,10 +35,10 @@ function () {
|
|
|
61
35
|
this.warnings = [];
|
|
62
36
|
}
|
|
63
37
|
|
|
64
|
-
(
|
|
38
|
+
_createClass(Document, [{
|
|
65
39
|
key: "assertCollectionContents",
|
|
66
40
|
value: function assertCollectionContents() {
|
|
67
|
-
if (this.contents instanceof
|
|
41
|
+
if (this.contents instanceof Collection) return true;
|
|
68
42
|
throw new Error('Expected a YAML collection as document contents');
|
|
69
43
|
}
|
|
70
44
|
}, {
|
|
@@ -88,7 +62,7 @@ function () {
|
|
|
88
62
|
}, {
|
|
89
63
|
key: "deleteIn",
|
|
90
64
|
value: function deleteIn(path) {
|
|
91
|
-
if (
|
|
65
|
+
if (isEmptyPath(path)) {
|
|
92
66
|
if (this.contents == null) return false;
|
|
93
67
|
this.contents = null;
|
|
94
68
|
return true;
|
|
@@ -105,24 +79,24 @@ function () {
|
|
|
105
79
|
}, {
|
|
106
80
|
key: "get",
|
|
107
81
|
value: function get(key, keepScalar) {
|
|
108
|
-
return this.contents instanceof
|
|
82
|
+
return this.contents instanceof Collection ? this.contents.get(key, keepScalar) : undefined;
|
|
109
83
|
}
|
|
110
84
|
}, {
|
|
111
85
|
key: "getIn",
|
|
112
86
|
value: function getIn(path, keepScalar) {
|
|
113
|
-
if (
|
|
114
|
-
return this.contents instanceof
|
|
87
|
+
if (isEmptyPath(path)) return !keepScalar && this.contents instanceof Scalar ? this.contents.value : this.contents;
|
|
88
|
+
return this.contents instanceof Collection ? this.contents.getIn(path, keepScalar) : undefined;
|
|
115
89
|
}
|
|
116
90
|
}, {
|
|
117
91
|
key: "has",
|
|
118
92
|
value: function has(key) {
|
|
119
|
-
return this.contents instanceof
|
|
93
|
+
return this.contents instanceof Collection ? this.contents.has(key) : false;
|
|
120
94
|
}
|
|
121
95
|
}, {
|
|
122
96
|
key: "hasIn",
|
|
123
97
|
value: function hasIn(path) {
|
|
124
|
-
if (
|
|
125
|
-
return this.contents instanceof
|
|
98
|
+
if (isEmptyPath(path)) return this.contents !== undefined;
|
|
99
|
+
return this.contents instanceof Collection ? this.contents.hasIn(path) : false;
|
|
126
100
|
}
|
|
127
101
|
}, {
|
|
128
102
|
key: "set",
|
|
@@ -133,7 +107,7 @@ function () {
|
|
|
133
107
|
}, {
|
|
134
108
|
key: "setIn",
|
|
135
109
|
value: function setIn(path, value) {
|
|
136
|
-
if (
|
|
110
|
+
if (isEmptyPath(path)) this.contents = value;else {
|
|
137
111
|
this.assertCollectionContents();
|
|
138
112
|
this.contents.setIn(path, value);
|
|
139
113
|
}
|
|
@@ -153,7 +127,7 @@ function () {
|
|
|
153
127
|
|
|
154
128
|
if (Array.isArray(customTags)) this.options.customTags = customTags;
|
|
155
129
|
var opt = Object.assign({}, this.getDefaults(), this.options);
|
|
156
|
-
this.schema = new
|
|
130
|
+
this.schema = new Schema(opt);
|
|
157
131
|
}
|
|
158
132
|
}, {
|
|
159
133
|
key: "parse",
|
|
@@ -189,7 +163,7 @@ function () {
|
|
|
189
163
|
try {
|
|
190
164
|
for (var _iterator = this.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
191
165
|
var _error = _step.value;
|
|
192
|
-
if (_error instanceof
|
|
166
|
+
if (_error instanceof YAMLError) _error.makePretty();
|
|
193
167
|
}
|
|
194
168
|
} catch (err) {
|
|
195
169
|
_didIteratorError = true;
|
|
@@ -213,7 +187,7 @@ function () {
|
|
|
213
187
|
try {
|
|
214
188
|
for (var _iterator2 = this.warnings[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
215
189
|
var warn = _step2.value;
|
|
216
|
-
if (warn instanceof
|
|
190
|
+
if (warn instanceof YAMLError) warn.makePretty();
|
|
217
191
|
}
|
|
218
192
|
} catch (err) {
|
|
219
193
|
_didIteratorError2 = true;
|
|
@@ -262,7 +236,7 @@ function () {
|
|
|
262
236
|
if (name) {
|
|
263
237
|
var msg = "YAML only supports %TAG and %YAML directives, and not %".concat(name);
|
|
264
238
|
|
|
265
|
-
_this.warnings.push(new
|
|
239
|
+
_this.warnings.push(new YAMLWarning(directive, msg));
|
|
266
240
|
}
|
|
267
241
|
|
|
268
242
|
}
|
|
@@ -302,7 +276,7 @@ function () {
|
|
|
302
276
|
if (contentNodes.length === 1) {
|
|
303
277
|
var msg = 'Document is not valid YAML (bad indentation?)';
|
|
304
278
|
|
|
305
|
-
_this2.errors.push(new
|
|
279
|
+
_this2.errors.push(new YAMLSyntaxError(node, msg));
|
|
306
280
|
}
|
|
307
281
|
|
|
308
282
|
var res = _this2.resolveNode(node);
|
|
@@ -316,7 +290,7 @@ function () {
|
|
|
316
290
|
} else if (node.comment !== null) {
|
|
317
291
|
var cc = contentNodes.length === 0 ? comments.before : comments.after;
|
|
318
292
|
cc.push(node.comment);
|
|
319
|
-
} else if (node.type ===
|
|
293
|
+
} else if (node.type === Type.BLANK_LINE) {
|
|
320
294
|
spaceBefore = true;
|
|
321
295
|
|
|
322
296
|
if (contentNodes.length === 0 && comments.before.length > 0 && !_this2.commentBefore) {
|
|
@@ -340,7 +314,7 @@ function () {
|
|
|
340
314
|
var cb = comments.before.join('\n') || null;
|
|
341
315
|
|
|
342
316
|
if (cb) {
|
|
343
|
-
var cbNode = this.contents instanceof
|
|
317
|
+
var cbNode = this.contents instanceof Collection && this.contents.items[0] ? this.contents.items[0] : this.contents;
|
|
344
318
|
cbNode.commentBefore = cbNode.commentBefore ? "".concat(cb, "\n").concat(cbNode.commentBefore) : cb;
|
|
345
319
|
}
|
|
346
320
|
} else {
|
|
@@ -365,7 +339,7 @@ function () {
|
|
|
365
339
|
}, {
|
|
366
340
|
key: "resolveTagDirective",
|
|
367
341
|
value: function resolveTagDirective(directive) {
|
|
368
|
-
var _directive$parameters = (
|
|
342
|
+
var _directive$parameters = _slicedToArray(directive.parameters, 2),
|
|
369
343
|
handle = _directive$parameters[0],
|
|
370
344
|
prefix = _directive$parameters[1];
|
|
371
345
|
|
|
@@ -379,36 +353,36 @@ function () {
|
|
|
379
353
|
});
|
|
380
354
|
} else {
|
|
381
355
|
var msg = 'The %TAG directive must only be given at most once per handle in the same document.';
|
|
382
|
-
this.errors.push(new
|
|
356
|
+
this.errors.push(new YAMLSemanticError(directive, msg));
|
|
383
357
|
}
|
|
384
358
|
} else {
|
|
385
359
|
var _msg = 'Insufficient parameters given for %TAG directive';
|
|
386
|
-
this.errors.push(new
|
|
360
|
+
this.errors.push(new YAMLSemanticError(directive, _msg));
|
|
387
361
|
}
|
|
388
362
|
}
|
|
389
363
|
}, {
|
|
390
364
|
key: "resolveYamlDirective",
|
|
391
365
|
value: function resolveYamlDirective(directive) {
|
|
392
|
-
var _directive$parameters2 = (
|
|
366
|
+
var _directive$parameters2 = _slicedToArray(directive.parameters, 1),
|
|
393
367
|
version = _directive$parameters2[0];
|
|
394
368
|
|
|
395
369
|
if (directive.name === 'YAML:1.0') version = '1.0';
|
|
396
370
|
|
|
397
371
|
if (this.version) {
|
|
398
372
|
var msg = 'The %YAML directive must only be given at most once per document.';
|
|
399
|
-
this.errors.push(new
|
|
373
|
+
this.errors.push(new YAMLSemanticError(directive, msg));
|
|
400
374
|
}
|
|
401
375
|
|
|
402
376
|
if (!version) {
|
|
403
377
|
var _msg2 = 'Insufficient parameters given for %YAML directive';
|
|
404
|
-
this.errors.push(new
|
|
378
|
+
this.errors.push(new YAMLSemanticError(directive, _msg2));
|
|
405
379
|
} else {
|
|
406
380
|
if (!Document.defaults[version]) {
|
|
407
381
|
var v0 = this.version || this.options.version;
|
|
408
382
|
|
|
409
383
|
var _msg3 = "Document will be parsed as YAML ".concat(v0, " rather than YAML ").concat(version);
|
|
410
384
|
|
|
411
|
-
this.warnings.push(new
|
|
385
|
+
this.warnings.push(new YAMLWarning(directive, _msg3));
|
|
412
386
|
}
|
|
413
387
|
|
|
414
388
|
this.version = version;
|
|
@@ -429,7 +403,7 @@ function () {
|
|
|
429
403
|
if (verbatim) {
|
|
430
404
|
if (verbatim !== '!' && verbatim !== '!!') return verbatim;
|
|
431
405
|
var msg = "Verbatim tags aren't resolved, so ".concat(verbatim, " is invalid.");
|
|
432
|
-
this.errors.push(new
|
|
406
|
+
this.errors.push(new YAMLSemanticError(node, msg));
|
|
433
407
|
} else if (handle === '!' && !suffix) {
|
|
434
408
|
nonSpecific = true;
|
|
435
409
|
} else {
|
|
@@ -459,32 +433,32 @@ function () {
|
|
|
459
433
|
return prefix.prefix + decodeURIComponent(suffix);
|
|
460
434
|
}
|
|
461
435
|
|
|
462
|
-
this.errors.push(new
|
|
436
|
+
this.errors.push(new YAMLSemanticError(node, "The ".concat(handle, " tag has no suffix.")));
|
|
463
437
|
} else {
|
|
464
438
|
var _msg4 = "The ".concat(handle, " tag handle is non-default and was not declared.");
|
|
465
439
|
|
|
466
|
-
this.errors.push(new
|
|
440
|
+
this.errors.push(new YAMLSemanticError(node, _msg4));
|
|
467
441
|
}
|
|
468
442
|
}
|
|
469
443
|
}
|
|
470
444
|
|
|
471
445
|
switch (type) {
|
|
472
|
-
case
|
|
473
|
-
case
|
|
474
|
-
case
|
|
475
|
-
case
|
|
476
|
-
return
|
|
446
|
+
case Type.BLOCK_FOLDED:
|
|
447
|
+
case Type.BLOCK_LITERAL:
|
|
448
|
+
case Type.QUOTE_DOUBLE:
|
|
449
|
+
case Type.QUOTE_SINGLE:
|
|
450
|
+
return Schema.defaultTags.STR;
|
|
477
451
|
|
|
478
|
-
case
|
|
479
|
-
case
|
|
480
|
-
return
|
|
452
|
+
case Type.FLOW_MAP:
|
|
453
|
+
case Type.MAP:
|
|
454
|
+
return Schema.defaultTags.MAP;
|
|
481
455
|
|
|
482
|
-
case
|
|
483
|
-
case
|
|
484
|
-
return
|
|
456
|
+
case Type.FLOW_SEQ:
|
|
457
|
+
case Type.SEQ:
|
|
458
|
+
return Schema.defaultTags.SEQ;
|
|
485
459
|
|
|
486
|
-
case
|
|
487
|
-
return nonSpecific ?
|
|
460
|
+
case Type.PLAIN:
|
|
461
|
+
return nonSpecific ? Schema.defaultTags.STR : null;
|
|
488
462
|
|
|
489
463
|
default:
|
|
490
464
|
return null;
|
|
@@ -515,11 +489,11 @@ function () {
|
|
|
515
489
|
end = _step3$value.end;
|
|
516
490
|
|
|
517
491
|
switch (node.context.src[start]) {
|
|
518
|
-
case
|
|
492
|
+
case Char.COMMENT:
|
|
519
493
|
{
|
|
520
494
|
if (!node.commentHasRequiredWhitespace(start)) {
|
|
521
495
|
var _msg7 = 'Comments must be separated from other tokens by white space characters';
|
|
522
|
-
errors.push(new
|
|
496
|
+
errors.push(new YAMLSemanticError(node, _msg7));
|
|
523
497
|
}
|
|
524
498
|
|
|
525
499
|
var c = node.context.src.slice(start + 1, end);
|
|
@@ -534,19 +508,19 @@ function () {
|
|
|
534
508
|
}
|
|
535
509
|
break;
|
|
536
510
|
|
|
537
|
-
case
|
|
511
|
+
case Char.ANCHOR:
|
|
538
512
|
if (hasAnchor) {
|
|
539
513
|
var _msg8 = 'A node can have at most one anchor';
|
|
540
|
-
errors.push(new
|
|
514
|
+
errors.push(new YAMLSemanticError(node, _msg8));
|
|
541
515
|
}
|
|
542
516
|
|
|
543
517
|
hasAnchor = true;
|
|
544
518
|
break;
|
|
545
519
|
|
|
546
|
-
case
|
|
520
|
+
case Char.TAG:
|
|
547
521
|
if (hasTag) {
|
|
548
522
|
var _msg9 = 'A node can have at most one tag';
|
|
549
|
-
errors.push(new
|
|
523
|
+
errors.push(new YAMLSemanticError(node, _msg9));
|
|
550
524
|
}
|
|
551
525
|
|
|
552
526
|
hasTag = true;
|
|
@@ -582,10 +556,10 @@ function () {
|
|
|
582
556
|
|
|
583
557
|
var res;
|
|
584
558
|
|
|
585
|
-
if (node.type ===
|
|
559
|
+
if (node.type === Type.ALIAS) {
|
|
586
560
|
if (hasAnchor || hasTag) {
|
|
587
561
|
var msg = 'An alias node must not specify any properties';
|
|
588
|
-
errors.push(new
|
|
562
|
+
errors.push(new YAMLSemanticError(node, msg));
|
|
589
563
|
}
|
|
590
564
|
|
|
591
565
|
var _name = node.rawValue;
|
|
@@ -594,12 +568,12 @@ function () {
|
|
|
594
568
|
if (!src) {
|
|
595
569
|
var _msg5 = "Aliased anchor not found: ".concat(_name);
|
|
596
570
|
|
|
597
|
-
errors.push(new
|
|
571
|
+
errors.push(new YAMLReferenceError(node, _msg5));
|
|
598
572
|
return null;
|
|
599
573
|
} // Lazy resolution for circular references
|
|
600
574
|
|
|
601
575
|
|
|
602
|
-
res = new
|
|
576
|
+
res = new Alias(src);
|
|
603
577
|
|
|
604
578
|
anchors._cstAliases.push(res);
|
|
605
579
|
} else {
|
|
@@ -608,10 +582,10 @@ function () {
|
|
|
608
582
|
if (tagName) {
|
|
609
583
|
res = schema.resolveNodeWithFallback(this, node, tagName);
|
|
610
584
|
} else {
|
|
611
|
-
if (node.type !==
|
|
585
|
+
if (node.type !== Type.PLAIN) {
|
|
612
586
|
var _msg6 = "Failed to resolve ".concat(node.type, " node here");
|
|
613
587
|
|
|
614
|
-
errors.push(new
|
|
588
|
+
errors.push(new YAMLSyntaxError(node, _msg6));
|
|
615
589
|
return null;
|
|
616
590
|
}
|
|
617
591
|
|
|
@@ -644,8 +618,8 @@ function () {
|
|
|
644
618
|
}, {
|
|
645
619
|
key: "listNonDefaultTags",
|
|
646
620
|
value: function listNonDefaultTags() {
|
|
647
|
-
return (
|
|
648
|
-
return t.indexOf(
|
|
621
|
+
return listTagNames(this.contents).filter(function (t) {
|
|
622
|
+
return t.indexOf(Schema.defaultPrefix) !== 0;
|
|
649
623
|
});
|
|
650
624
|
}
|
|
651
625
|
}, {
|
|
@@ -710,7 +684,7 @@ function () {
|
|
|
710
684
|
keepBlobsInJSON = _this$options.keepBlobsInJSON,
|
|
711
685
|
mapAsMap = _this$options.mapAsMap,
|
|
712
686
|
maxAliasCount = _this$options.maxAliasCount;
|
|
713
|
-
var keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof
|
|
687
|
+
var keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof Scalar));
|
|
714
688
|
var ctx = {
|
|
715
689
|
doc: this,
|
|
716
690
|
keep: keep,
|
|
@@ -726,7 +700,7 @@ function () {
|
|
|
726
700
|
node: _this3.anchors.map[name]
|
|
727
701
|
};
|
|
728
702
|
});
|
|
729
|
-
return (
|
|
703
|
+
return _toJSON(this.contents, arg, ctx);
|
|
730
704
|
}
|
|
731
705
|
}, {
|
|
732
706
|
key: "toString",
|
|
@@ -775,7 +749,7 @@ function () {
|
|
|
775
749
|
var contentComment = null;
|
|
776
750
|
|
|
777
751
|
if (this.contents) {
|
|
778
|
-
if (this.contents instanceof
|
|
752
|
+
if (this.contents instanceof Node) {
|
|
779
753
|
if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push('');
|
|
780
754
|
if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment
|
|
781
755
|
|
|
@@ -789,7 +763,7 @@ function () {
|
|
|
789
763
|
var body = this.schema.stringify(this.contents, ctx, function () {
|
|
790
764
|
return contentComment = null;
|
|
791
765
|
}, onChompKeep);
|
|
792
|
-
lines.push((
|
|
766
|
+
lines.push(addComment(body, '', contentComment));
|
|
793
767
|
} else if (this.contents !== undefined) {
|
|
794
768
|
lines.push(this.schema.stringify(this.contents, ctx));
|
|
795
769
|
}
|
|
@@ -802,17 +776,17 @@ function () {
|
|
|
802
776
|
return lines.join('\n') + '\n';
|
|
803
777
|
}
|
|
804
778
|
}]);
|
|
779
|
+
|
|
805
780
|
return Document;
|
|
806
781
|
}();
|
|
807
782
|
|
|
808
|
-
|
|
809
|
-
(0, _defineProperty2.default)(Document, "defaults", {
|
|
783
|
+
_defineProperty(Document, "defaults", {
|
|
810
784
|
'1.0': {
|
|
811
785
|
schema: 'yaml-1.1',
|
|
812
786
|
merge: true,
|
|
813
787
|
tagPrefixes: [{
|
|
814
788
|
handle: '!',
|
|
815
|
-
prefix:
|
|
789
|
+
prefix: Schema.defaultPrefix
|
|
816
790
|
}, {
|
|
817
791
|
handle: '!!',
|
|
818
792
|
prefix: 'tag:private.yaml.org,2002:'
|
|
@@ -826,7 +800,7 @@ exports.default = Document;
|
|
|
826
800
|
prefix: '!'
|
|
827
801
|
}, {
|
|
828
802
|
handle: '!!',
|
|
829
|
-
prefix:
|
|
803
|
+
prefix: Schema.defaultPrefix
|
|
830
804
|
}]
|
|
831
805
|
},
|
|
832
806
|
'1.2': {
|
|
@@ -837,7 +811,9 @@ exports.default = Document;
|
|
|
837
811
|
prefix: '!'
|
|
838
812
|
}, {
|
|
839
813
|
handle: '!!',
|
|
840
|
-
prefix:
|
|
814
|
+
prefix: Schema.defaultPrefix
|
|
841
815
|
}]
|
|
842
816
|
}
|
|
843
|
-
});
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
export { Document as default };
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.addCommentBefore = addCommentBefore;
|
|
7
|
-
exports.default = addComment;
|
|
8
|
-
|
|
9
|
-
function addCommentBefore(str, indent, comment) {
|
|
1
|
+
export function addCommentBefore(str, indent, comment) {
|
|
10
2
|
if (!comment) return str;
|
|
11
3
|
var cc = comment.replace(/[\s\S]^/gm, "$&".concat(indent, "#"));
|
|
12
4
|
return "#".concat(cc, "\n").concat(indent).concat(str);
|
|
13
5
|
}
|
|
14
|
-
|
|
15
|
-
function addComment(str, indent, comment) {
|
|
6
|
+
export default function addComment(str, indent, comment) {
|
|
16
7
|
return !comment ? str : comment.indexOf('\n') === -1 ? "".concat(str, " #").concat(comment) : "".concat(str, "\n") + comment.replace(/^/gm, "".concat(indent || '', "#"));
|
|
17
8
|
}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Type = exports.Char = void 0;
|
|
7
|
-
var Char = {
|
|
1
|
+
export var Char = {
|
|
8
2
|
ANCHOR: '&',
|
|
9
3
|
COMMENT: '#',
|
|
10
4
|
TAG: '!',
|
|
11
5
|
DIRECTIVES_END: '-',
|
|
12
6
|
DOCUMENT_END: '.'
|
|
13
7
|
};
|
|
14
|
-
|
|
15
|
-
var Type = {
|
|
8
|
+
export var Type = {
|
|
16
9
|
ALIAS: 'ALIAS',
|
|
17
10
|
BLANK_LINE: 'BLANK_LINE',
|
|
18
11
|
BLOCK_FOLDED: 'BLOCK_FOLDED',
|
|
@@ -30,5 +23,4 @@ var Type = {
|
|
|
30
23
|
QUOTE_SINGLE: 'QUOTE_SINGLE',
|
|
31
24
|
SEQ: 'SEQ',
|
|
32
25
|
SEQ_ITEM: 'SEQ_ITEM'
|
|
33
|
-
};
|
|
34
|
-
exports.Type = Type;
|
|
26
|
+
};
|