yaml 1.3.0 → 1.5.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 +29 -23
- package/browser/dist/Anchors.js +12 -10
- package/browser/dist/Document.js +122 -60
- 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 +8 -10
- package/browser/dist/cst/FlowCollection.js +5 -7
- 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 +8 -13
- 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 +7 -4
- 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 +52 -26
- 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 +55 -39
- 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 +8 -10
- package/dist/cst/FlowCollection.js +5 -7
- 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 +8 -12
- package/dist/cst/parse.js +1 -4
- package/dist/deprecation.js +34 -0
- package/dist/errors.js +29 -35
- package/dist/index.js +7 -4
- 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 +46 -20
- 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 +22 -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/linePos.js +0 -58
- 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
|
@@ -9,15 +9,15 @@ exports.parsePairs = parsePairs;
|
|
|
9
9
|
exports.createPairs = createPairs;
|
|
10
10
|
exports.default = void 0;
|
|
11
11
|
|
|
12
|
-
var _errors = require("
|
|
12
|
+
var _errors = require("../../errors");
|
|
13
13
|
|
|
14
|
-
var _Map = _interopRequireDefault(require("
|
|
14
|
+
var _Map = _interopRequireDefault(require("../../schema/Map"));
|
|
15
15
|
|
|
16
|
-
var _Pair = _interopRequireDefault(require("
|
|
16
|
+
var _Pair = _interopRequireDefault(require("../../schema/Pair"));
|
|
17
17
|
|
|
18
|
-
var _parseSeq = _interopRequireDefault(require("
|
|
18
|
+
var _parseSeq = _interopRequireDefault(require("../../schema/parseSeq"));
|
|
19
19
|
|
|
20
|
-
var _Seq = _interopRequireDefault(require("
|
|
20
|
+
var _Seq = _interopRequireDefault(require("../../schema/Seq"));
|
|
21
21
|
|
|
22
22
|
function parsePairs(doc, cst) {
|
|
23
23
|
var seq = (0, _parseSeq.default)(doc, cst);
|
|
@@ -41,7 +41,7 @@ function parsePairs(doc, cst) {
|
|
|
41
41
|
return seq;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function createPairs(schema, iterable,
|
|
44
|
+
function createPairs(schema, iterable, ctx) {
|
|
45
45
|
var pairs = new _Seq.default();
|
|
46
46
|
pairs.tag = 'tag:yaml.org,2002:pairs';
|
|
47
47
|
var _iteratorNormalCompletion = true;
|
|
@@ -70,9 +70,8 @@ function createPairs(schema, iterable, wrapScalars) {
|
|
|
70
70
|
key = it;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
pairs.items.push(new _Pair.default(k, v));
|
|
73
|
+
var pair = schema.createPair(key, value, ctx);
|
|
74
|
+
pairs.items.push(pair);
|
|
76
75
|
}
|
|
77
76
|
} catch (err) {
|
|
78
77
|
_didIteratorError = true;
|
|
@@ -96,9 +95,6 @@ var _default = {
|
|
|
96
95
|
default: false,
|
|
97
96
|
tag: 'tag:yaml.org,2002:pairs',
|
|
98
97
|
resolve: parsePairs,
|
|
99
|
-
createNode: createPairs
|
|
100
|
-
stringify: function stringify(value, ctx, onComment, onChompKeep) {
|
|
101
|
-
return value.toString(ctx, onComment, onChompKeep);
|
|
102
|
-
}
|
|
98
|
+
createNode: createPairs
|
|
103
99
|
};
|
|
104
100
|
exports.default = _default;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = exports.YAMLSet = void 0;
|
|
11
|
+
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
23
|
+
|
|
24
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
25
|
+
|
|
26
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
+
|
|
28
|
+
var _errors = require("../../errors");
|
|
29
|
+
|
|
30
|
+
var _Map = _interopRequireWildcard(require("../../schema/Map"));
|
|
31
|
+
|
|
32
|
+
var _Pair = _interopRequireDefault(require("../../schema/Pair"));
|
|
33
|
+
|
|
34
|
+
var _parseMap = _interopRequireDefault(require("../../schema/parseMap"));
|
|
35
|
+
|
|
36
|
+
var _Scalar = _interopRequireDefault(require("../../schema/Scalar"));
|
|
37
|
+
|
|
38
|
+
var YAMLSet =
|
|
39
|
+
/*#__PURE__*/
|
|
40
|
+
function (_YAMLMap) {
|
|
41
|
+
(0, _inherits2.default)(YAMLSet, _YAMLMap);
|
|
42
|
+
|
|
43
|
+
function YAMLSet() {
|
|
44
|
+
var _this;
|
|
45
|
+
|
|
46
|
+
(0, _classCallCheck2.default)(this, YAMLSet);
|
|
47
|
+
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(YAMLSet).call(this));
|
|
48
|
+
_this.tag = YAMLSet.tag;
|
|
49
|
+
return _this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
(0, _createClass2.default)(YAMLSet, [{
|
|
53
|
+
key: "add",
|
|
54
|
+
value: function add(key) {
|
|
55
|
+
var pair = key instanceof _Pair.default ? key : new _Pair.default(key);
|
|
56
|
+
var prev = (0, _Map.findPair)(this.items, pair.key);
|
|
57
|
+
if (!prev) this.items.push(pair);
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
key: "get",
|
|
61
|
+
value: function get(key, keepPair) {
|
|
62
|
+
var pair = (0, _Map.findPair)(this.items, key);
|
|
63
|
+
return !keepPair && pair instanceof _Pair.default ? pair.key instanceof _Scalar.default ? pair.key.value : pair.key : pair;
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "set",
|
|
67
|
+
value: function set(key, value) {
|
|
68
|
+
if (typeof value !== 'boolean') throw new Error("Expected boolean value for set(key, value) in a YAML set, not ".concat((0, _typeof2.default)(value)));
|
|
69
|
+
var prev = (0, _Map.findPair)(this.items, key);
|
|
70
|
+
|
|
71
|
+
if (prev && !value) {
|
|
72
|
+
this.items.splice(this.items.indexOf(prev), 1);
|
|
73
|
+
} else if (!prev && value) {
|
|
74
|
+
this.items.push(new _Pair.default(key));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "toJSON",
|
|
79
|
+
value: function toJSON(_, ctx) {
|
|
80
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(YAMLSet.prototype), "toJSON", this).call(this, _, ctx, Set);
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "toString",
|
|
84
|
+
value: function toString(ctx, onComment, onChompKeep) {
|
|
85
|
+
if (!ctx) return JSON.stringify(this);
|
|
86
|
+
if (this.hasAllNullValues()) return (0, _get2.default)((0, _getPrototypeOf2.default)(YAMLSet.prototype), "toString", this).call(this, ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values');
|
|
87
|
+
}
|
|
88
|
+
}]);
|
|
89
|
+
return YAMLSet;
|
|
90
|
+
}(_Map.default);
|
|
91
|
+
|
|
92
|
+
exports.YAMLSet = YAMLSet;
|
|
93
|
+
(0, _defineProperty2.default)(YAMLSet, "tag", 'tag:yaml.org,2002:set');
|
|
94
|
+
|
|
95
|
+
function parseSet(doc, cst) {
|
|
96
|
+
var map = (0, _parseMap.default)(doc, cst);
|
|
97
|
+
if (!map.hasAllNullValues()) throw new _errors.YAMLSemanticError(cst, 'Set items must all have null values');
|
|
98
|
+
return Object.assign(new YAMLSet(), map);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function createSet(schema, iterable, ctx) {
|
|
102
|
+
var set = new YAMLSet();
|
|
103
|
+
var _iteratorNormalCompletion = true;
|
|
104
|
+
var _didIteratorError = false;
|
|
105
|
+
var _iteratorError = undefined;
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
for (var _iterator = iterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
109
|
+
var value = _step.value;
|
|
110
|
+
set.items.push(schema.createPair(value, null, ctx));
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
_didIteratorError = true;
|
|
114
|
+
_iteratorError = err;
|
|
115
|
+
} finally {
|
|
116
|
+
try {
|
|
117
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
118
|
+
_iterator.return();
|
|
119
|
+
}
|
|
120
|
+
} finally {
|
|
121
|
+
if (_didIteratorError) {
|
|
122
|
+
throw _iteratorError;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return set;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var _default = {
|
|
131
|
+
identify: function identify(value) {
|
|
132
|
+
return value instanceof Set;
|
|
133
|
+
},
|
|
134
|
+
nodeClass: YAMLSet,
|
|
135
|
+
default: false,
|
|
136
|
+
tag: 'tag:yaml.org,2002:set',
|
|
137
|
+
resolve: parseSet,
|
|
138
|
+
createNode: createSet
|
|
139
|
+
};
|
|
140
|
+
exports.default = _default;
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.timestamp = exports.floatTime = exports.intTime = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _stringify = require("../../stringify");
|
|
9
9
|
|
|
10
|
-
// Published as 'yaml/types/timestamp'
|
|
11
10
|
var parseSexagesimal = function parseSexagesimal(sign, parts) {
|
|
12
11
|
var n = parts.split(':').reduce(function (n, p) {
|
|
13
12
|
return n * 60 + Number(p);
|
|
@@ -18,7 +17,7 @@ var parseSexagesimal = function parseSexagesimal(sign, parts) {
|
|
|
18
17
|
|
|
19
18
|
var stringifySexagesimal = function stringifySexagesimal(_ref) {
|
|
20
19
|
var value = _ref.value;
|
|
21
|
-
if (isNaN(value) || !isFinite(value)) return (0,
|
|
20
|
+
if (isNaN(value) || !isFinite(value)) return (0, _stringify.stringifyNumber)(value);
|
|
22
21
|
var sign = '';
|
|
23
22
|
|
|
24
23
|
if (value < 0) {
|
|
@@ -47,7 +46,9 @@ var stringifySexagesimal = function stringifySexagesimal(_ref) {
|
|
|
47
46
|
};
|
|
48
47
|
|
|
49
48
|
var intTime = {
|
|
50
|
-
|
|
49
|
+
identify: function identify(value) {
|
|
50
|
+
return typeof value === 'number';
|
|
51
|
+
},
|
|
51
52
|
default: true,
|
|
52
53
|
tag: 'tag:yaml.org,2002:int',
|
|
53
54
|
format: 'TIME',
|
|
@@ -59,7 +60,9 @@ var intTime = {
|
|
|
59
60
|
};
|
|
60
61
|
exports.intTime = intTime;
|
|
61
62
|
var floatTime = {
|
|
62
|
-
|
|
63
|
+
identify: function identify(value) {
|
|
64
|
+
return typeof value === 'number';
|
|
65
|
+
},
|
|
63
66
|
default: true,
|
|
64
67
|
tag: 'tag:yaml.org,2002:float',
|
|
65
68
|
format: 'TIME',
|
|
@@ -71,7 +74,9 @@ var floatTime = {
|
|
|
71
74
|
};
|
|
72
75
|
exports.floatTime = floatTime;
|
|
73
76
|
var timestamp = {
|
|
74
|
-
|
|
77
|
+
identify: function identify(value) {
|
|
78
|
+
return value instanceof Date;
|
|
79
|
+
},
|
|
75
80
|
default: true,
|
|
76
81
|
tag: 'tag:yaml.org,2002:timestamp',
|
|
77
82
|
// If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
|
|
@@ -99,6 +104,4 @@ var timestamp = {
|
|
|
99
104
|
return value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '');
|
|
100
105
|
}
|
|
101
106
|
};
|
|
102
|
-
exports.timestamp = timestamp;
|
|
103
|
-
var _default = [intTime, floatTime, timestamp];
|
|
104
|
-
exports.default = _default;
|
|
107
|
+
exports.timestamp = timestamp;
|
|
@@ -172,7 +172,4 @@ function addEvents(events, doc, e, node) {
|
|
|
172
172
|
var value = node.cstNode.strValue.replace(/\\/g, '\\\\').replace(/\0/g, '\\0').replace(/\x07/g, '\\a').replace(/\x08/g, '\\b').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\v/g, '\\v').replace(/\f/g, '\\f').replace(/\r/g, '\\r').replace(/\x1b/g, '\\e');
|
|
173
173
|
events.push("=VAL".concat(props, " ").concat(scalar).concat(value));
|
|
174
174
|
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
module.exports = exports.default;
|
|
178
|
-
module.exports.default = exports.default;
|
|
175
|
+
}
|
package/browser/dist/toJSON.js
CHANGED
|
@@ -5,11 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = toJSON;
|
|
7
7
|
|
|
8
|
-
function toJSON(value, arg,
|
|
9
|
-
|
|
10
|
-
return toJSON(v, String(i),
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
function toJSON(value, arg, ctx) {
|
|
9
|
+
if (Array.isArray(value)) return value.map(function (v, i) {
|
|
10
|
+
return toJSON(v, String(i), ctx);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (value && typeof value.toJSON === 'function') {
|
|
14
|
+
var anchor = ctx && ctx.anchors && ctx.anchors.find(function (a) {
|
|
15
|
+
return a.node === value;
|
|
16
|
+
});
|
|
17
|
+
if (anchor) ctx.onCreate = function (res) {
|
|
18
|
+
anchor.res = res;
|
|
19
|
+
delete ctx.onCreate;
|
|
20
|
+
};
|
|
21
|
+
var res = value.toJSON(arg, ctx);
|
|
22
|
+
if (anchor && ctx.onCreate) ctx.onCreate(res);
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return value;
|
|
27
|
+
}
|
package/browser/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist').default
|
package/browser/map.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/schema/Map')
|
|
1
|
+
module.exports = require('./dist/schema/Map').default
|
|
2
|
+
require('./dist/deprecation').warnFileDeprecation(__filename)
|
package/browser/pair.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/schema/Pair')
|
|
1
|
+
module.exports = require('./dist/schema/Pair').default
|
|
2
|
+
require('./dist/deprecation').warnFileDeprecation(__filename)
|
package/browser/parse-cst.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./dist/cst/parse')
|
|
1
|
+
module.exports = require('./dist/cst/parse').default
|
package/browser/scalar.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/schema/Scalar')
|
|
1
|
+
module.exports = require('./dist/schema/Scalar').default
|
|
2
|
+
require('./dist/deprecation').warnFileDeprecation(__filename)
|
package/browser/schema.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
module.exports = require('./dist/schema')
|
|
2
|
-
|
|
3
|
-
module.exports.
|
|
1
|
+
module.exports = require('./dist/schema').default
|
|
2
|
+
var opt = require('./dist/tags/options')
|
|
3
|
+
module.exports.nullOptions = opt.nullOptions
|
|
4
|
+
module.exports.strOptions = opt.strOptions
|
|
5
|
+
module.exports.stringify = require('./dist/stringify').stringifyString
|
|
6
|
+
|
|
7
|
+
require('./dist/deprecation').warnFileDeprecation(__filename)
|
package/browser/seq.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/schema/Seq')
|
|
1
|
+
module.exports = require('./dist/schema/Seq').default
|
|
2
|
+
require('./dist/deprecation').warnFileDeprecation(__filename)
|
package/browser/types/binary.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
|
|
4
|
+
exports.binary = require('../dist/tags/yaml-1.1/binary').default
|
|
5
|
+
exports.default = [exports.binary]
|
|
6
|
+
|
|
7
|
+
require('../dist/deprecation').warnFileDeprecation(__filename)
|
package/browser/types/omap.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('../dist/
|
|
1
|
+
module.exports = require('../dist/tags/yaml-1.1/omap').default
|
|
2
|
+
require('../dist/deprecation').warnFileDeprecation(__filename)
|
package/browser/types/pairs.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('../dist/
|
|
1
|
+
module.exports = require('../dist/tags/yaml-1.1/pairs').default
|
|
2
|
+
require('../dist/deprecation').warnFileDeprecation(__filename)
|
package/browser/types/set.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('../dist/
|
|
1
|
+
module.exports = require('../dist/tags/yaml-1.1/set').default
|
|
2
|
+
require('../dist/deprecation').warnFileDeprecation(__filename)
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
|
|
4
|
+
var ts = require('../dist/tags/yaml-1.1/timestamp')
|
|
5
|
+
exports.default = [ts.intTime, ts.floatTime, ts.timestamp]
|
|
6
|
+
exports.floatTime = ts.floatTime
|
|
7
|
+
exports.intTime = ts.intTime
|
|
8
|
+
exports.timestamp = ts.timestamp
|
|
9
|
+
|
|
10
|
+
require('../dist/deprecation').warnFileDeprecation(__filename)
|
package/browser/types.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var opt = require('./dist/tags/options')
|
|
2
|
+
exports.binaryOptions = opt.binaryOptions
|
|
3
|
+
exports.boolOptions = opt.boolOptions
|
|
4
|
+
exports.nullOptions = opt.nullOptions
|
|
5
|
+
exports.strOptions = opt.strOptions
|
|
6
|
+
|
|
7
|
+
exports.Schema = require('./dist/schema').default
|
|
8
|
+
exports.YAMLMap = require('./dist/schema/Map').default
|
|
9
|
+
exports.YAMLSeq = require('./dist/schema/Seq').default
|
|
10
|
+
exports.Pair = require('./dist/schema/Pair').default
|
|
11
|
+
exports.Scalar = require('./dist/schema/Scalar').default
|
package/browser/util.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
exports.findPair = require('./dist/schema/Map').findPair
|
|
2
|
+
exports.parseMap = require('./dist/schema/parseMap').default
|
|
3
|
+
exports.parseSeq = require('./dist/schema/parseSeq').default
|
|
4
|
+
|
|
5
|
+
var str = require('./dist/stringify')
|
|
6
|
+
exports.stringifyNumber = str.stringifyNumber
|
|
7
|
+
exports.stringifyString = str.stringifyString
|
|
8
|
+
exports.toJSON = require('./dist/toJSON').default
|
|
9
|
+
exports.Type = require('./dist/cst/Node').Type
|
|
10
|
+
|
|
11
|
+
var err = require('./dist/errors')
|
|
12
|
+
exports.YAMLReferenceError = err.YAMLReferenceError
|
|
13
|
+
exports.YAMLSemanticError = err.YAMLSemanticError
|
|
14
|
+
exports.YAMLSyntaxError = err.YAMLSyntaxError
|
|
15
|
+
exports.YAMLWarning = err.YAMLWarning
|
package/dist/Anchors.js
CHANGED
|
@@ -20,14 +20,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
20
|
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; }
|
|
21
21
|
|
|
22
22
|
class Anchors {
|
|
23
|
-
constructor() {
|
|
24
|
-
_defineProperty(this, "map", {});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
23
|
static validAnchorNode(node) {
|
|
28
24
|
return node instanceof _Scalar.default || node instanceof _Seq.default || node instanceof _Map.default;
|
|
29
25
|
}
|
|
30
26
|
|
|
27
|
+
constructor(prefix) {
|
|
28
|
+
_defineProperty(this, "map", {});
|
|
29
|
+
|
|
30
|
+
this.prefix = prefix;
|
|
31
|
+
}
|
|
32
|
+
|
|
31
33
|
createAlias(node, name) {
|
|
32
34
|
this.setAnchor(node, name);
|
|
33
35
|
return new _Alias.default(node);
|
|
@@ -59,6 +61,7 @@ class Anchors {
|
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
newName(prefix) {
|
|
64
|
+
if (!prefix) prefix = this.prefix;
|
|
62
65
|
const names = Object.keys(this.map);
|
|
63
66
|
|
|
64
67
|
for (let i = 1; true; ++i) {
|
|
@@ -108,7 +111,7 @@ class Anchors {
|
|
|
108
111
|
} else {
|
|
109
112
|
if (!name) {
|
|
110
113
|
if (!node) return null;
|
|
111
|
-
name = this.newName(
|
|
114
|
+
name = this.newName();
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
map[name] = node;
|
|
@@ -119,6 +122,4 @@ class Anchors {
|
|
|
119
122
|
|
|
120
123
|
}
|
|
121
124
|
|
|
122
|
-
exports.default = Anchors;
|
|
123
|
-
module.exports = exports.default;
|
|
124
|
-
module.exports.default = exports.default;
|
|
125
|
+
exports.default = Anchors;
|
package/dist/Document.js
CHANGED
|
@@ -9,7 +9,7 @@ var _addComment = _interopRequireDefault(require("./addComment"));
|
|
|
9
9
|
|
|
10
10
|
var _Anchors = _interopRequireDefault(require("./Anchors"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _constants = require("./constants");
|
|
13
13
|
|
|
14
14
|
var _errors = require("./errors");
|
|
15
15
|
|
|
@@ -21,21 +21,23 @@ var _Alias = _interopRequireDefault(require("./schema/Alias"));
|
|
|
21
21
|
|
|
22
22
|
var _Collection = _interopRequireWildcard(require("./schema/Collection"));
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _Node = _interopRequireDefault(require("./schema/Node"));
|
|
25
25
|
|
|
26
26
|
var _Scalar = _interopRequireDefault(require("./schema/Scalar"));
|
|
27
27
|
|
|
28
|
+
var _toJSON = _interopRequireDefault(require("./toJSON"));
|
|
29
|
+
|
|
28
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; } }
|
|
29
31
|
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
33
|
|
|
32
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; }
|
|
33
35
|
|
|
34
|
-
const isCollectionItem = node => node && [
|
|
36
|
+
const isCollectionItem = node => node && [_constants.Type.MAP_KEY, _constants.Type.MAP_VALUE, _constants.Type.SEQ_ITEM].includes(node.type);
|
|
35
37
|
|
|
36
38
|
class Document {
|
|
37
39
|
constructor(options) {
|
|
38
|
-
this.anchors = new _Anchors.default();
|
|
40
|
+
this.anchors = new _Anchors.default(options.anchorPrefix);
|
|
39
41
|
this.commentBefore = null;
|
|
40
42
|
this.comment = null;
|
|
41
43
|
this.contents = null;
|
|
@@ -186,7 +188,7 @@ class Document {
|
|
|
186
188
|
} else if (node.comment !== null) {
|
|
187
189
|
const cc = contentNodes.length === 0 ? comments.before : comments.after;
|
|
188
190
|
cc.push(node.comment);
|
|
189
|
-
} else if (node.type ===
|
|
191
|
+
} else if (node.type === _constants.Type.BLANK_LINE) {
|
|
190
192
|
spaceBefore = true;
|
|
191
193
|
|
|
192
194
|
if (contentNodes.length === 0 && comments.before.length > 0 && !this.commentBefore) {
|
|
@@ -232,6 +234,13 @@ class Document {
|
|
|
232
234
|
|
|
233
235
|
this.comment = comments.after.join('\n') || null;
|
|
234
236
|
this.anchors.resolveNodes();
|
|
237
|
+
|
|
238
|
+
if (this.options.prettyErrors) {
|
|
239
|
+
for (const error of this.errors) if (error instanceof _errors.YAMLError) error.makePretty();
|
|
240
|
+
|
|
241
|
+
for (const warn of this.warnings) if (warn instanceof _errors.YAMLError) warn.makePretty();
|
|
242
|
+
}
|
|
243
|
+
|
|
235
244
|
return this;
|
|
236
245
|
}
|
|
237
246
|
|
|
@@ -329,21 +338,21 @@ class Document {
|
|
|
329
338
|
}
|
|
330
339
|
|
|
331
340
|
switch (type) {
|
|
332
|
-
case
|
|
333
|
-
case
|
|
334
|
-
case
|
|
335
|
-
case
|
|
341
|
+
case _constants.Type.BLOCK_FOLDED:
|
|
342
|
+
case _constants.Type.BLOCK_LITERAL:
|
|
343
|
+
case _constants.Type.QUOTE_DOUBLE:
|
|
344
|
+
case _constants.Type.QUOTE_SINGLE:
|
|
336
345
|
return _schema.default.defaultTags.STR;
|
|
337
346
|
|
|
338
|
-
case
|
|
339
|
-
case
|
|
347
|
+
case _constants.Type.FLOW_MAP:
|
|
348
|
+
case _constants.Type.MAP:
|
|
340
349
|
return _schema.default.defaultTags.MAP;
|
|
341
350
|
|
|
342
|
-
case
|
|
343
|
-
case
|
|
351
|
+
case _constants.Type.FLOW_SEQ:
|
|
352
|
+
case _constants.Type.SEQ:
|
|
344
353
|
return _schema.default.defaultTags.SEQ;
|
|
345
354
|
|
|
346
|
-
case
|
|
355
|
+
case _constants.Type.PLAIN:
|
|
347
356
|
return nonSpecific ? _schema.default.defaultTags.STR : null;
|
|
348
357
|
|
|
349
358
|
default:
|
|
@@ -373,7 +382,7 @@ class Document {
|
|
|
373
382
|
} = _ref;
|
|
374
383
|
|
|
375
384
|
switch (node.context.src[start]) {
|
|
376
|
-
case
|
|
385
|
+
case _constants.Char.COMMENT:
|
|
377
386
|
{
|
|
378
387
|
if (!node.commentHasRequiredWhitespace(start)) {
|
|
379
388
|
const msg = 'Comments must be separated from other tokens by white space characters';
|
|
@@ -394,7 +403,7 @@ class Document {
|
|
|
394
403
|
}
|
|
395
404
|
break;
|
|
396
405
|
|
|
397
|
-
case
|
|
406
|
+
case _constants.Char.ANCHOR:
|
|
398
407
|
if (hasAnchor) {
|
|
399
408
|
const msg = 'A node can have at most one anchor';
|
|
400
409
|
errors.push(new _errors.YAMLSemanticError(node, msg));
|
|
@@ -403,7 +412,7 @@ class Document {
|
|
|
403
412
|
hasAnchor = true;
|
|
404
413
|
break;
|
|
405
414
|
|
|
406
|
-
case
|
|
415
|
+
case _constants.Char.TAG:
|
|
407
416
|
if (hasTag) {
|
|
408
417
|
const msg = 'A node can have at most one tag';
|
|
409
418
|
errors.push(new _errors.YAMLSemanticError(node, msg));
|
|
@@ -428,7 +437,7 @@ class Document {
|
|
|
428
437
|
|
|
429
438
|
let res;
|
|
430
439
|
|
|
431
|
-
if (node.type ===
|
|
440
|
+
if (node.type === _constants.Type.ALIAS) {
|
|
432
441
|
if (hasAnchor || hasTag) {
|
|
433
442
|
const msg = 'An alias node must not specify any properties';
|
|
434
443
|
errors.push(new _errors.YAMLSemanticError(node, msg));
|
|
@@ -447,18 +456,13 @@ class Document {
|
|
|
447
456
|
res = new _Alias.default(src);
|
|
448
457
|
|
|
449
458
|
anchors._cstAliases.push(res);
|
|
450
|
-
|
|
451
|
-
if (!src.resolved) {
|
|
452
|
-
const msg = 'Alias node contains a circular reference, which cannot be resolved as JSON';
|
|
453
|
-
this.warnings.push(new _errors.YAMLWarning(node, msg));
|
|
454
|
-
}
|
|
455
459
|
} else {
|
|
456
460
|
const tagName = this.resolveTagName(node);
|
|
457
461
|
|
|
458
462
|
if (tagName) {
|
|
459
463
|
res = schema.resolveNodeWithFallback(this, node, tagName);
|
|
460
464
|
} else {
|
|
461
|
-
if (node.type !==
|
|
465
|
+
if (node.type !== _constants.Type.PLAIN) {
|
|
462
466
|
const msg = `Failed to resolve ${node.type} node here`;
|
|
463
467
|
errors.push(new _errors.YAMLSyntaxError(node, msg));
|
|
464
468
|
return null;
|
|
@@ -537,14 +541,26 @@ class Document {
|
|
|
537
541
|
}
|
|
538
542
|
|
|
539
543
|
toJSON(arg) {
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
544
|
+
const {
|
|
545
|
+
keepBlobsInJSON,
|
|
546
|
+
mapAsMap,
|
|
547
|
+
maxAliasCount
|
|
548
|
+
} = this.options;
|
|
549
|
+
const keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof _Scalar.default));
|
|
550
|
+
const ctx = {
|
|
551
|
+
doc: this,
|
|
545
552
|
keep,
|
|
546
|
-
mapAsMap
|
|
547
|
-
|
|
553
|
+
mapAsMap: keep && !!mapAsMap,
|
|
554
|
+
maxAliasCount
|
|
555
|
+
};
|
|
556
|
+
const anchorNames = Object.keys(this.anchors.map);
|
|
557
|
+
if (anchorNames.length > 0) ctx.anchors = anchorNames.map(name => ({
|
|
558
|
+
alias: [],
|
|
559
|
+
aliasCount: 0,
|
|
560
|
+
count: 1,
|
|
561
|
+
node: this.anchors.map[name]
|
|
562
|
+
}));
|
|
563
|
+
return (0, _toJSON.default)(this.contents, arg, ctx);
|
|
548
564
|
}
|
|
549
565
|
|
|
550
566
|
toString() {
|
|
@@ -585,11 +601,14 @@ class Document {
|
|
|
585
601
|
let contentComment = null;
|
|
586
602
|
|
|
587
603
|
if (this.contents) {
|
|
588
|
-
if (this.contents
|
|
589
|
-
|
|
604
|
+
if (this.contents instanceof _Node.default) {
|
|
605
|
+
if (this.contents.spaceBefore && hasDirectives) lines.push('');
|
|
606
|
+
if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment
|
|
607
|
+
|
|
608
|
+
ctx.forceBlockIndent = !!this.comment;
|
|
609
|
+
contentComment = this.contents.comment;
|
|
610
|
+
}
|
|
590
611
|
|
|
591
|
-
ctx.forceBlockIndent = !!this.comment;
|
|
592
|
-
contentComment = this.contents.comment;
|
|
593
612
|
const onChompKeep = contentComment ? null : () => chompKeep = true;
|
|
594
613
|
const body = this.schema.stringify(this.contents, ctx, () => contentComment = null, onChompKeep);
|
|
595
614
|
lines.push((0, _addComment.default)(body, '', contentComment));
|
|
@@ -643,7 +662,4 @@ _defineProperty(Document, "defaults", {
|
|
|
643
662
|
prefix: _schema.default.defaultPrefix
|
|
644
663
|
}]
|
|
645
664
|
}
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
module.exports = exports.default;
|
|
649
|
-
module.exports.default = exports.default;
|
|
665
|
+
});
|