yaml 1.6.0 → 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 +99 -111
- 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 +57 -58
- 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 +30 -47
- package/browser/dist/cst/ParseContext.js +100 -140
- package/browser/dist/cst/PlainValue.js +22 -39
- 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 +168 -0
- package/browser/dist/errors.js +71 -74
- package/browser/dist/foldFlowLines.js +4 -15
- package/browser/dist/index.js +26 -45
- package/browser/dist/listTagNames.js +10 -24
- package/browser/dist/schema/Alias.js +33 -50
- package/browser/dist/schema/Collection.js +54 -65
- package/browser/dist/schema/Map.js +39 -49
- package/browser/dist/schema/Merge.js +33 -53
- package/browser/dist/schema/Node.js +3 -12
- package/browser/dist/schema/Pair.js +53 -56
- package/browser/dist/schema/Scalar.js +18 -33
- package/browser/dist/schema/Seq.js +23 -40
- package/browser/dist/schema/index.js +67 -81
- package/browser/dist/schema/parseMap.js +63 -70
- package/browser/dist/schema/parseSeq.js +45 -44
- package/browser/dist/schema/parseUtils.js +47 -11
- package/browser/dist/stringify.js +43 -48
- package/browser/dist/tags/core.js +30 -37
- package/browser/dist/tags/failsafe/index.js +4 -17
- package/browser/dist/tags/failsafe/map.js +17 -26
- 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 +28 -0
- package/browser/map.js +1 -1
- package/browser/pair.js +1 -1
- package/browser/scalar.js +1 -1
- package/browser/schema.js +1 -1
- package/browser/seq.js +1 -1
- package/browser/types/binary.js +1 -1
- package/browser/types/omap.js +1 -1
- package/browser/types/pairs.js +1 -1
- package/browser/types/set.js +1 -1
- package/browser/types/timestamp.js +1 -1
- package/dist/Document.js +21 -9
- package/dist/cst/BlankLine.js +4 -0
- package/dist/cst/BlockValue.js +1 -1
- package/dist/cst/CollectionItem.js +27 -6
- package/dist/cst/Directive.js +0 -16
- package/dist/cst/Node.js +7 -9
- package/dist/cst/ParseContext.js +41 -55
- package/dist/cst/PlainValue.js +1 -1
- package/dist/cst/source-utils.js +178 -0
- package/dist/errors.js +37 -3
- package/dist/index.js +5 -4
- package/dist/schema/Alias.js +2 -1
- package/dist/schema/Collection.js +22 -5
- package/dist/schema/Map.js +12 -5
- package/dist/schema/Merge.js +4 -5
- package/dist/schema/Pair.js +20 -2
- package/dist/schema/index.js +14 -8
- package/dist/schema/parseMap.js +20 -5
- package/dist/schema/parseSeq.js +19 -6
- package/dist/schema/parseUtils.js +54 -6
- package/dist/stringify.js +21 -11
- 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/omap.js +3 -5
- package/dist/tags/yaml-1.1/pairs.js +1 -1
- package/dist/tags/yaml-1.1/set.js +3 -1
- package/dist/{deprecation.js → warnings.js} +12 -7
- package/map.js +1 -1
- package/package.json +35 -17
- package/pair.js +1 -1
- package/scalar.js +1 -1
- package/schema.js +1 -1
- package/seq.js +1 -1
- package/types/binary.js +1 -1
- package/types/omap.js +1 -1
- package/types/pairs.js +1 -1
- package/types/set.js +1 -1
- package/types/timestamp.js +1 -1
- package/types.mjs +20 -0
- package/util.mjs +24 -0
- package/browser/dist/cst/getLinePos.js +0 -79
- package/browser/dist/deprecation.js +0 -34
- package/dist/cst/getLinePos.js +0 -79
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,15 +107,27 @@ 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
|
}
|
|
140
114
|
}
|
|
141
115
|
}, {
|
|
142
116
|
key: "setSchema",
|
|
143
|
-
value: function setSchema() {
|
|
144
|
-
if (!
|
|
117
|
+
value: function setSchema(id, customTags) {
|
|
118
|
+
if (!id && !customTags && this.schema) return;
|
|
119
|
+
if (typeof id === 'number') id = id.toFixed(1);
|
|
120
|
+
|
|
121
|
+
if (id === '1.0' || id === '1.1' || id === '1.2') {
|
|
122
|
+
if (this.version) this.version = id;else this.options.version = id;
|
|
123
|
+
delete this.options.schema;
|
|
124
|
+
} else if (id && typeof id === 'string') {
|
|
125
|
+
this.options.schema = id;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (Array.isArray(customTags)) this.options.customTags = customTags;
|
|
129
|
+
var opt = Object.assign({}, this.getDefaults(), this.options);
|
|
130
|
+
this.schema = new Schema(opt);
|
|
145
131
|
}
|
|
146
132
|
}, {
|
|
147
133
|
key: "parse",
|
|
@@ -177,7 +163,7 @@ function () {
|
|
|
177
163
|
try {
|
|
178
164
|
for (var _iterator = this.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
179
165
|
var _error = _step.value;
|
|
180
|
-
if (_error instanceof
|
|
166
|
+
if (_error instanceof YAMLError) _error.makePretty();
|
|
181
167
|
}
|
|
182
168
|
} catch (err) {
|
|
183
169
|
_didIteratorError = true;
|
|
@@ -201,7 +187,7 @@ function () {
|
|
|
201
187
|
try {
|
|
202
188
|
for (var _iterator2 = this.warnings[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
203
189
|
var warn = _step2.value;
|
|
204
|
-
if (warn instanceof
|
|
190
|
+
if (warn instanceof YAMLError) warn.makePretty();
|
|
205
191
|
}
|
|
206
192
|
} catch (err) {
|
|
207
193
|
_didIteratorError2 = true;
|
|
@@ -250,7 +236,7 @@ function () {
|
|
|
250
236
|
if (name) {
|
|
251
237
|
var msg = "YAML only supports %TAG and %YAML directives, and not %".concat(name);
|
|
252
238
|
|
|
253
|
-
_this.warnings.push(new
|
|
239
|
+
_this.warnings.push(new YAMLWarning(directive, msg));
|
|
254
240
|
}
|
|
255
241
|
|
|
256
242
|
}
|
|
@@ -290,7 +276,7 @@ function () {
|
|
|
290
276
|
if (contentNodes.length === 1) {
|
|
291
277
|
var msg = 'Document is not valid YAML (bad indentation?)';
|
|
292
278
|
|
|
293
|
-
_this2.errors.push(new
|
|
279
|
+
_this2.errors.push(new YAMLSyntaxError(node, msg));
|
|
294
280
|
}
|
|
295
281
|
|
|
296
282
|
var res = _this2.resolveNode(node);
|
|
@@ -304,7 +290,7 @@ function () {
|
|
|
304
290
|
} else if (node.comment !== null) {
|
|
305
291
|
var cc = contentNodes.length === 0 ? comments.before : comments.after;
|
|
306
292
|
cc.push(node.comment);
|
|
307
|
-
} else if (node.type ===
|
|
293
|
+
} else if (node.type === Type.BLANK_LINE) {
|
|
308
294
|
spaceBefore = true;
|
|
309
295
|
|
|
310
296
|
if (contentNodes.length === 0 && comments.before.length > 0 && !_this2.commentBefore) {
|
|
@@ -328,7 +314,7 @@ function () {
|
|
|
328
314
|
var cb = comments.before.join('\n') || null;
|
|
329
315
|
|
|
330
316
|
if (cb) {
|
|
331
|
-
var cbNode = this.contents instanceof
|
|
317
|
+
var cbNode = this.contents instanceof Collection && this.contents.items[0] ? this.contents.items[0] : this.contents;
|
|
332
318
|
cbNode.commentBefore = cbNode.commentBefore ? "".concat(cb, "\n").concat(cbNode.commentBefore) : cb;
|
|
333
319
|
}
|
|
334
320
|
} else {
|
|
@@ -353,7 +339,7 @@ function () {
|
|
|
353
339
|
}, {
|
|
354
340
|
key: "resolveTagDirective",
|
|
355
341
|
value: function resolveTagDirective(directive) {
|
|
356
|
-
var _directive$parameters = (
|
|
342
|
+
var _directive$parameters = _slicedToArray(directive.parameters, 2),
|
|
357
343
|
handle = _directive$parameters[0],
|
|
358
344
|
prefix = _directive$parameters[1];
|
|
359
345
|
|
|
@@ -367,36 +353,36 @@ function () {
|
|
|
367
353
|
});
|
|
368
354
|
} else {
|
|
369
355
|
var msg = 'The %TAG directive must only be given at most once per handle in the same document.';
|
|
370
|
-
this.errors.push(new
|
|
356
|
+
this.errors.push(new YAMLSemanticError(directive, msg));
|
|
371
357
|
}
|
|
372
358
|
} else {
|
|
373
359
|
var _msg = 'Insufficient parameters given for %TAG directive';
|
|
374
|
-
this.errors.push(new
|
|
360
|
+
this.errors.push(new YAMLSemanticError(directive, _msg));
|
|
375
361
|
}
|
|
376
362
|
}
|
|
377
363
|
}, {
|
|
378
364
|
key: "resolveYamlDirective",
|
|
379
365
|
value: function resolveYamlDirective(directive) {
|
|
380
|
-
var _directive$parameters2 = (
|
|
366
|
+
var _directive$parameters2 = _slicedToArray(directive.parameters, 1),
|
|
381
367
|
version = _directive$parameters2[0];
|
|
382
368
|
|
|
383
369
|
if (directive.name === 'YAML:1.0') version = '1.0';
|
|
384
370
|
|
|
385
371
|
if (this.version) {
|
|
386
372
|
var msg = 'The %YAML directive must only be given at most once per document.';
|
|
387
|
-
this.errors.push(new
|
|
373
|
+
this.errors.push(new YAMLSemanticError(directive, msg));
|
|
388
374
|
}
|
|
389
375
|
|
|
390
376
|
if (!version) {
|
|
391
377
|
var _msg2 = 'Insufficient parameters given for %YAML directive';
|
|
392
|
-
this.errors.push(new
|
|
378
|
+
this.errors.push(new YAMLSemanticError(directive, _msg2));
|
|
393
379
|
} else {
|
|
394
380
|
if (!Document.defaults[version]) {
|
|
395
381
|
var v0 = this.version || this.options.version;
|
|
396
382
|
|
|
397
383
|
var _msg3 = "Document will be parsed as YAML ".concat(v0, " rather than YAML ").concat(version);
|
|
398
384
|
|
|
399
|
-
this.warnings.push(new
|
|
385
|
+
this.warnings.push(new YAMLWarning(directive, _msg3));
|
|
400
386
|
}
|
|
401
387
|
|
|
402
388
|
this.version = version;
|
|
@@ -417,7 +403,7 @@ function () {
|
|
|
417
403
|
if (verbatim) {
|
|
418
404
|
if (verbatim !== '!' && verbatim !== '!!') return verbatim;
|
|
419
405
|
var msg = "Verbatim tags aren't resolved, so ".concat(verbatim, " is invalid.");
|
|
420
|
-
this.errors.push(new
|
|
406
|
+
this.errors.push(new YAMLSemanticError(node, msg));
|
|
421
407
|
} else if (handle === '!' && !suffix) {
|
|
422
408
|
nonSpecific = true;
|
|
423
409
|
} else {
|
|
@@ -447,32 +433,32 @@ function () {
|
|
|
447
433
|
return prefix.prefix + decodeURIComponent(suffix);
|
|
448
434
|
}
|
|
449
435
|
|
|
450
|
-
this.errors.push(new
|
|
436
|
+
this.errors.push(new YAMLSemanticError(node, "The ".concat(handle, " tag has no suffix.")));
|
|
451
437
|
} else {
|
|
452
438
|
var _msg4 = "The ".concat(handle, " tag handle is non-default and was not declared.");
|
|
453
439
|
|
|
454
|
-
this.errors.push(new
|
|
440
|
+
this.errors.push(new YAMLSemanticError(node, _msg4));
|
|
455
441
|
}
|
|
456
442
|
}
|
|
457
443
|
}
|
|
458
444
|
|
|
459
445
|
switch (type) {
|
|
460
|
-
case
|
|
461
|
-
case
|
|
462
|
-
case
|
|
463
|
-
case
|
|
464
|
-
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;
|
|
465
451
|
|
|
466
|
-
case
|
|
467
|
-
case
|
|
468
|
-
return
|
|
452
|
+
case Type.FLOW_MAP:
|
|
453
|
+
case Type.MAP:
|
|
454
|
+
return Schema.defaultTags.MAP;
|
|
469
455
|
|
|
470
|
-
case
|
|
471
|
-
case
|
|
472
|
-
return
|
|
456
|
+
case Type.FLOW_SEQ:
|
|
457
|
+
case Type.SEQ:
|
|
458
|
+
return Schema.defaultTags.SEQ;
|
|
473
459
|
|
|
474
|
-
case
|
|
475
|
-
return nonSpecific ?
|
|
460
|
+
case Type.PLAIN:
|
|
461
|
+
return nonSpecific ? Schema.defaultTags.STR : null;
|
|
476
462
|
|
|
477
463
|
default:
|
|
478
464
|
return null;
|
|
@@ -503,11 +489,11 @@ function () {
|
|
|
503
489
|
end = _step3$value.end;
|
|
504
490
|
|
|
505
491
|
switch (node.context.src[start]) {
|
|
506
|
-
case
|
|
492
|
+
case Char.COMMENT:
|
|
507
493
|
{
|
|
508
494
|
if (!node.commentHasRequiredWhitespace(start)) {
|
|
509
495
|
var _msg7 = 'Comments must be separated from other tokens by white space characters';
|
|
510
|
-
errors.push(new
|
|
496
|
+
errors.push(new YAMLSemanticError(node, _msg7));
|
|
511
497
|
}
|
|
512
498
|
|
|
513
499
|
var c = node.context.src.slice(start + 1, end);
|
|
@@ -522,19 +508,19 @@ function () {
|
|
|
522
508
|
}
|
|
523
509
|
break;
|
|
524
510
|
|
|
525
|
-
case
|
|
511
|
+
case Char.ANCHOR:
|
|
526
512
|
if (hasAnchor) {
|
|
527
513
|
var _msg8 = 'A node can have at most one anchor';
|
|
528
|
-
errors.push(new
|
|
514
|
+
errors.push(new YAMLSemanticError(node, _msg8));
|
|
529
515
|
}
|
|
530
516
|
|
|
531
517
|
hasAnchor = true;
|
|
532
518
|
break;
|
|
533
519
|
|
|
534
|
-
case
|
|
520
|
+
case Char.TAG:
|
|
535
521
|
if (hasTag) {
|
|
536
522
|
var _msg9 = 'A node can have at most one tag';
|
|
537
|
-
errors.push(new
|
|
523
|
+
errors.push(new YAMLSemanticError(node, _msg9));
|
|
538
524
|
}
|
|
539
525
|
|
|
540
526
|
hasTag = true;
|
|
@@ -570,10 +556,10 @@ function () {
|
|
|
570
556
|
|
|
571
557
|
var res;
|
|
572
558
|
|
|
573
|
-
if (node.type ===
|
|
559
|
+
if (node.type === Type.ALIAS) {
|
|
574
560
|
if (hasAnchor || hasTag) {
|
|
575
561
|
var msg = 'An alias node must not specify any properties';
|
|
576
|
-
errors.push(new
|
|
562
|
+
errors.push(new YAMLSemanticError(node, msg));
|
|
577
563
|
}
|
|
578
564
|
|
|
579
565
|
var _name = node.rawValue;
|
|
@@ -582,12 +568,12 @@ function () {
|
|
|
582
568
|
if (!src) {
|
|
583
569
|
var _msg5 = "Aliased anchor not found: ".concat(_name);
|
|
584
570
|
|
|
585
|
-
errors.push(new
|
|
571
|
+
errors.push(new YAMLReferenceError(node, _msg5));
|
|
586
572
|
return null;
|
|
587
573
|
} // Lazy resolution for circular references
|
|
588
574
|
|
|
589
575
|
|
|
590
|
-
res = new
|
|
576
|
+
res = new Alias(src);
|
|
591
577
|
|
|
592
578
|
anchors._cstAliases.push(res);
|
|
593
579
|
} else {
|
|
@@ -596,10 +582,10 @@ function () {
|
|
|
596
582
|
if (tagName) {
|
|
597
583
|
res = schema.resolveNodeWithFallback(this, node, tagName);
|
|
598
584
|
} else {
|
|
599
|
-
if (node.type !==
|
|
585
|
+
if (node.type !== Type.PLAIN) {
|
|
600
586
|
var _msg6 = "Failed to resolve ".concat(node.type, " node here");
|
|
601
587
|
|
|
602
|
-
errors.push(new
|
|
588
|
+
errors.push(new YAMLSyntaxError(node, _msg6));
|
|
603
589
|
return null;
|
|
604
590
|
}
|
|
605
591
|
|
|
@@ -632,8 +618,8 @@ function () {
|
|
|
632
618
|
}, {
|
|
633
619
|
key: "listNonDefaultTags",
|
|
634
620
|
value: function listNonDefaultTags() {
|
|
635
|
-
return (
|
|
636
|
-
return t.indexOf(
|
|
621
|
+
return listTagNames(this.contents).filter(function (t) {
|
|
622
|
+
return t.indexOf(Schema.defaultPrefix) !== 0;
|
|
637
623
|
});
|
|
638
624
|
}
|
|
639
625
|
}, {
|
|
@@ -698,7 +684,7 @@ function () {
|
|
|
698
684
|
keepBlobsInJSON = _this$options.keepBlobsInJSON,
|
|
699
685
|
mapAsMap = _this$options.mapAsMap,
|
|
700
686
|
maxAliasCount = _this$options.maxAliasCount;
|
|
701
|
-
var keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof
|
|
687
|
+
var keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof Scalar));
|
|
702
688
|
var ctx = {
|
|
703
689
|
doc: this,
|
|
704
690
|
keep: keep,
|
|
@@ -714,7 +700,7 @@ function () {
|
|
|
714
700
|
node: _this3.anchors.map[name]
|
|
715
701
|
};
|
|
716
702
|
});
|
|
717
|
-
return (
|
|
703
|
+
return _toJSON(this.contents, arg, ctx);
|
|
718
704
|
}
|
|
719
705
|
}, {
|
|
720
706
|
key: "toString",
|
|
@@ -763,7 +749,7 @@ function () {
|
|
|
763
749
|
var contentComment = null;
|
|
764
750
|
|
|
765
751
|
if (this.contents) {
|
|
766
|
-
if (this.contents instanceof
|
|
752
|
+
if (this.contents instanceof Node) {
|
|
767
753
|
if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push('');
|
|
768
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
|
|
769
755
|
|
|
@@ -777,7 +763,7 @@ function () {
|
|
|
777
763
|
var body = this.schema.stringify(this.contents, ctx, function () {
|
|
778
764
|
return contentComment = null;
|
|
779
765
|
}, onChompKeep);
|
|
780
|
-
lines.push((
|
|
766
|
+
lines.push(addComment(body, '', contentComment));
|
|
781
767
|
} else if (this.contents !== undefined) {
|
|
782
768
|
lines.push(this.schema.stringify(this.contents, ctx));
|
|
783
769
|
}
|
|
@@ -790,17 +776,17 @@ function () {
|
|
|
790
776
|
return lines.join('\n') + '\n';
|
|
791
777
|
}
|
|
792
778
|
}]);
|
|
779
|
+
|
|
793
780
|
return Document;
|
|
794
781
|
}();
|
|
795
782
|
|
|
796
|
-
|
|
797
|
-
(0, _defineProperty2.default)(Document, "defaults", {
|
|
783
|
+
_defineProperty(Document, "defaults", {
|
|
798
784
|
'1.0': {
|
|
799
785
|
schema: 'yaml-1.1',
|
|
800
786
|
merge: true,
|
|
801
787
|
tagPrefixes: [{
|
|
802
788
|
handle: '!',
|
|
803
|
-
prefix:
|
|
789
|
+
prefix: Schema.defaultPrefix
|
|
804
790
|
}, {
|
|
805
791
|
handle: '!!',
|
|
806
792
|
prefix: 'tag:private.yaml.org,2002:'
|
|
@@ -814,7 +800,7 @@ exports.default = Document;
|
|
|
814
800
|
prefix: '!'
|
|
815
801
|
}, {
|
|
816
802
|
handle: '!!',
|
|
817
|
-
prefix:
|
|
803
|
+
prefix: Schema.defaultPrefix
|
|
818
804
|
}]
|
|
819
805
|
},
|
|
820
806
|
'1.2': {
|
|
@@ -825,7 +811,9 @@ exports.default = Document;
|
|
|
825
811
|
prefix: '!'
|
|
826
812
|
}, {
|
|
827
813
|
handle: '!!',
|
|
828
|
-
prefix:
|
|
814
|
+
prefix: Schema.defaultPrefix
|
|
829
815
|
}]
|
|
830
816
|
}
|
|
831
|
-
});
|
|
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
|
+
};
|