yaml 2.8.2 → 3.0.0-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 +65 -85
- package/{bin.mjs → bin.js} +1 -1
- package/dist/chunk-BYypO7fO.js +18 -0
- package/dist/cli.d.ts +10 -7
- package/dist/cli.js +181 -0
- package/dist/directives-CG6n4xSM.js +2856 -0
- package/dist/index.d.ts +335 -25
- package/dist/index.js +4 -49
- package/dist/line-counter-TFl552k_.js +3098 -0
- package/dist/public-api-BE74JyVm.js +79 -0
- package/dist/stringifyString-S_ITVLTO.d.ts +1306 -0
- package/dist/test-events.d.ts +6 -3
- package/dist/test-events.js +98 -124
- package/dist/util.d.ts +2 -16
- package/dist/util.js +2 -27
- package/package.json +20 -44
- package/browser/dist/compose/compose-collection.js +0 -88
- package/browser/dist/compose/compose-doc.js +0 -43
- package/browser/dist/compose/compose-node.js +0 -102
- package/browser/dist/compose/compose-scalar.js +0 -86
- package/browser/dist/compose/composer.js +0 -217
- package/browser/dist/compose/resolve-block-map.js +0 -115
- package/browser/dist/compose/resolve-block-scalar.js +0 -198
- package/browser/dist/compose/resolve-block-seq.js +0 -49
- package/browser/dist/compose/resolve-end.js +0 -37
- package/browser/dist/compose/resolve-flow-collection.js +0 -207
- package/browser/dist/compose/resolve-flow-scalar.js +0 -223
- package/browser/dist/compose/resolve-props.js +0 -146
- package/browser/dist/compose/util-contains-newline.js +0 -34
- package/browser/dist/compose/util-empty-scalar-position.js +0 -26
- package/browser/dist/compose/util-flow-indent-check.js +0 -15
- package/browser/dist/compose/util-map-includes.js +0 -13
- package/browser/dist/doc/Document.js +0 -335
- package/browser/dist/doc/anchors.js +0 -71
- package/browser/dist/doc/applyReviver.js +0 -55
- package/browser/dist/doc/createNode.js +0 -88
- package/browser/dist/doc/directives.js +0 -176
- package/browser/dist/errors.js +0 -57
- package/browser/dist/index.js +0 -17
- package/browser/dist/log.js +0 -11
- package/browser/dist/nodes/Alias.js +0 -114
- package/browser/dist/nodes/Collection.js +0 -147
- package/browser/dist/nodes/Node.js +0 -38
- package/browser/dist/nodes/Pair.js +0 -36
- package/browser/dist/nodes/Scalar.js +0 -24
- package/browser/dist/nodes/YAMLMap.js +0 -144
- package/browser/dist/nodes/YAMLSeq.js +0 -113
- package/browser/dist/nodes/addPairToJSMap.js +0 -63
- package/browser/dist/nodes/identity.js +0 -36
- package/browser/dist/nodes/toJS.js +0 -37
- package/browser/dist/parse/cst-scalar.js +0 -214
- package/browser/dist/parse/cst-stringify.js +0 -61
- package/browser/dist/parse/cst-visit.js +0 -97
- package/browser/dist/parse/cst.js +0 -98
- package/browser/dist/parse/lexer.js +0 -717
- package/browser/dist/parse/line-counter.js +0 -39
- package/browser/dist/parse/parser.js +0 -967
- package/browser/dist/public-api.js +0 -102
- package/browser/dist/schema/Schema.js +0 -37
- package/browser/dist/schema/common/map.js +0 -17
- package/browser/dist/schema/common/null.js +0 -15
- package/browser/dist/schema/common/seq.js +0 -17
- package/browser/dist/schema/common/string.js +0 -14
- package/browser/dist/schema/core/bool.js +0 -19
- package/browser/dist/schema/core/float.js +0 -43
- package/browser/dist/schema/core/int.js +0 -38
- package/browser/dist/schema/core/schema.js +0 -23
- package/browser/dist/schema/json/schema.js +0 -62
- package/browser/dist/schema/tags.js +0 -96
- package/browser/dist/schema/yaml-1.1/binary.js +0 -58
- package/browser/dist/schema/yaml-1.1/bool.js +0 -26
- package/browser/dist/schema/yaml-1.1/float.js +0 -46
- package/browser/dist/schema/yaml-1.1/int.js +0 -71
- package/browser/dist/schema/yaml-1.1/merge.js +0 -64
- package/browser/dist/schema/yaml-1.1/omap.js +0 -74
- package/browser/dist/schema/yaml-1.1/pairs.js +0 -78
- package/browser/dist/schema/yaml-1.1/schema.js +0 -39
- package/browser/dist/schema/yaml-1.1/set.js +0 -93
- package/browser/dist/schema/yaml-1.1/timestamp.js +0 -101
- package/browser/dist/stringify/foldFlowLines.js +0 -146
- package/browser/dist/stringify/stringify.js +0 -128
- package/browser/dist/stringify/stringifyCollection.js +0 -143
- package/browser/dist/stringify/stringifyComment.js +0 -20
- package/browser/dist/stringify/stringifyDocument.js +0 -85
- package/browser/dist/stringify/stringifyNumber.js +0 -24
- package/browser/dist/stringify/stringifyPair.js +0 -150
- package/browser/dist/stringify/stringifyString.js +0 -336
- package/browser/dist/util.js +0 -11
- package/browser/dist/visit.js +0 -233
- package/browser/index.js +0 -5
- package/browser/package.json +0 -3
- package/dist/cli.mjs +0 -201
- package/dist/compose/compose-collection.d.ts +0 -11
- package/dist/compose/compose-collection.js +0 -90
- package/dist/compose/compose-doc.d.ts +0 -7
- package/dist/compose/compose-doc.js +0 -45
- package/dist/compose/compose-node.d.ts +0 -29
- package/dist/compose/compose-node.js +0 -105
- package/dist/compose/compose-scalar.d.ts +0 -5
- package/dist/compose/compose-scalar.js +0 -88
- package/dist/compose/composer.d.ts +0 -63
- package/dist/compose/composer.js +0 -222
- package/dist/compose/resolve-block-map.d.ts +0 -6
- package/dist/compose/resolve-block-map.js +0 -117
- package/dist/compose/resolve-block-scalar.d.ts +0 -11
- package/dist/compose/resolve-block-scalar.js +0 -200
- package/dist/compose/resolve-block-seq.d.ts +0 -6
- package/dist/compose/resolve-block-seq.js +0 -51
- package/dist/compose/resolve-end.d.ts +0 -6
- package/dist/compose/resolve-end.js +0 -39
- package/dist/compose/resolve-flow-collection.d.ts +0 -7
- package/dist/compose/resolve-flow-collection.js +0 -209
- package/dist/compose/resolve-flow-scalar.d.ts +0 -10
- package/dist/compose/resolve-flow-scalar.js +0 -225
- package/dist/compose/resolve-props.d.ts +0 -23
- package/dist/compose/resolve-props.js +0 -148
- package/dist/compose/util-contains-newline.d.ts +0 -2
- package/dist/compose/util-contains-newline.js +0 -36
- package/dist/compose/util-empty-scalar-position.d.ts +0 -2
- package/dist/compose/util-empty-scalar-position.js +0 -28
- package/dist/compose/util-flow-indent-check.d.ts +0 -3
- package/dist/compose/util-flow-indent-check.js +0 -17
- package/dist/compose/util-map-includes.d.ts +0 -4
- package/dist/compose/util-map-includes.js +0 -15
- package/dist/doc/Document.d.ts +0 -141
- package/dist/doc/Document.js +0 -337
- package/dist/doc/anchors.d.ts +0 -24
- package/dist/doc/anchors.js +0 -76
- package/dist/doc/applyReviver.d.ts +0 -9
- package/dist/doc/applyReviver.js +0 -57
- package/dist/doc/createNode.d.ts +0 -17
- package/dist/doc/createNode.js +0 -90
- package/dist/doc/directives.d.ts +0 -49
- package/dist/doc/directives.js +0 -178
- package/dist/errors.d.ts +0 -21
- package/dist/errors.js +0 -62
- package/dist/log.d.ts +0 -3
- package/dist/log.js +0 -19
- package/dist/nodes/Alias.d.ts +0 -29
- package/dist/nodes/Alias.js +0 -116
- package/dist/nodes/Collection.d.ts +0 -73
- package/dist/nodes/Collection.js +0 -151
- package/dist/nodes/Node.d.ts +0 -53
- package/dist/nodes/Node.js +0 -40
- package/dist/nodes/Pair.d.ts +0 -22
- package/dist/nodes/Pair.js +0 -39
- package/dist/nodes/Scalar.d.ts +0 -43
- package/dist/nodes/Scalar.js +0 -27
- package/dist/nodes/YAMLMap.d.ts +0 -53
- package/dist/nodes/YAMLMap.js +0 -147
- package/dist/nodes/YAMLSeq.d.ts +0 -60
- package/dist/nodes/YAMLSeq.js +0 -115
- package/dist/nodes/addPairToJSMap.d.ts +0 -4
- package/dist/nodes/addPairToJSMap.js +0 -65
- package/dist/nodes/identity.d.ts +0 -23
- package/dist/nodes/identity.js +0 -53
- package/dist/nodes/toJS.d.ts +0 -29
- package/dist/nodes/toJS.js +0 -39
- package/dist/options.d.ts +0 -344
- package/dist/parse/cst-scalar.d.ts +0 -64
- package/dist/parse/cst-scalar.js +0 -218
- package/dist/parse/cst-stringify.d.ts +0 -8
- package/dist/parse/cst-stringify.js +0 -63
- package/dist/parse/cst-visit.d.ts +0 -39
- package/dist/parse/cst-visit.js +0 -99
- package/dist/parse/cst.d.ts +0 -109
- package/dist/parse/cst.js +0 -112
- package/dist/parse/lexer.d.ts +0 -87
- package/dist/parse/lexer.js +0 -719
- package/dist/parse/line-counter.d.ts +0 -22
- package/dist/parse/line-counter.js +0 -41
- package/dist/parse/parser.d.ts +0 -84
- package/dist/parse/parser.js +0 -972
- package/dist/public-api.d.ts +0 -44
- package/dist/public-api.js +0 -107
- package/dist/schema/Schema.d.ts +0 -17
- package/dist/schema/Schema.js +0 -39
- package/dist/schema/common/map.d.ts +0 -2
- package/dist/schema/common/map.js +0 -19
- package/dist/schema/common/null.d.ts +0 -4
- package/dist/schema/common/null.js +0 -17
- package/dist/schema/common/seq.d.ts +0 -2
- package/dist/schema/common/seq.js +0 -19
- package/dist/schema/common/string.d.ts +0 -2
- package/dist/schema/common/string.js +0 -16
- package/dist/schema/core/bool.d.ts +0 -4
- package/dist/schema/core/bool.js +0 -21
- package/dist/schema/core/float.d.ts +0 -4
- package/dist/schema/core/float.js +0 -47
- package/dist/schema/core/int.d.ts +0 -4
- package/dist/schema/core/int.js +0 -42
- package/dist/schema/core/schema.d.ts +0 -1
- package/dist/schema/core/schema.js +0 -25
- package/dist/schema/json/schema.d.ts +0 -2
- package/dist/schema/json/schema.js +0 -64
- package/dist/schema/json-schema.d.ts +0 -69
- package/dist/schema/tags.d.ts +0 -48
- package/dist/schema/tags.js +0 -99
- package/dist/schema/types.d.ts +0 -92
- package/dist/schema/yaml-1.1/binary.d.ts +0 -2
- package/dist/schema/yaml-1.1/binary.js +0 -70
- package/dist/schema/yaml-1.1/bool.d.ts +0 -7
- package/dist/schema/yaml-1.1/bool.js +0 -29
- package/dist/schema/yaml-1.1/float.d.ts +0 -4
- package/dist/schema/yaml-1.1/float.js +0 -50
- package/dist/schema/yaml-1.1/int.d.ts +0 -5
- package/dist/schema/yaml-1.1/int.js +0 -76
- package/dist/schema/yaml-1.1/merge.d.ts +0 -9
- package/dist/schema/yaml-1.1/merge.js +0 -68
- package/dist/schema/yaml-1.1/omap.d.ts +0 -22
- package/dist/schema/yaml-1.1/omap.js +0 -77
- package/dist/schema/yaml-1.1/pairs.d.ts +0 -10
- package/dist/schema/yaml-1.1/pairs.js +0 -82
- package/dist/schema/yaml-1.1/schema.d.ts +0 -1
- package/dist/schema/yaml-1.1/schema.js +0 -41
- package/dist/schema/yaml-1.1/set.d.ts +0 -28
- package/dist/schema/yaml-1.1/set.js +0 -96
- package/dist/schema/yaml-1.1/timestamp.d.ts +0 -6
- package/dist/schema/yaml-1.1/timestamp.js +0 -105
- package/dist/stringify/foldFlowLines.d.ts +0 -34
- package/dist/stringify/foldFlowLines.js +0 -151
- package/dist/stringify/stringify.d.ts +0 -21
- package/dist/stringify/stringify.js +0 -131
- package/dist/stringify/stringifyCollection.d.ts +0 -17
- package/dist/stringify/stringifyCollection.js +0 -145
- package/dist/stringify/stringifyComment.d.ts +0 -10
- package/dist/stringify/stringifyComment.js +0 -24
- package/dist/stringify/stringifyDocument.d.ts +0 -4
- package/dist/stringify/stringifyDocument.js +0 -87
- package/dist/stringify/stringifyNumber.d.ts +0 -2
- package/dist/stringify/stringifyNumber.js +0 -26
- package/dist/stringify/stringifyPair.d.ts +0 -3
- package/dist/stringify/stringifyPair.js +0 -152
- package/dist/stringify/stringifyString.d.ts +0 -9
- package/dist/stringify/stringifyString.js +0 -338
- package/dist/visit.d.ts +0 -102
- package/dist/visit.js +0 -236
- package/util.js +0 -2
package/dist/test-events.d.ts
CHANGED
package/dist/test-events.js
CHANGED
|
@@ -1,134 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var publicApi = require('./public-api.js');
|
|
5
|
-
var visit = require('./visit.js');
|
|
1
|
+
import { _ as Collection, b as Scalar, f as Alias, g as YAMLSeq, n as visit, p as Pair, u as YAMLMap, x as NodeBase } from "./directives-CG6n4xSM.js";
|
|
2
|
+
import "./line-counter-TFl552k_.js";
|
|
3
|
+
import { n as parseAllDocuments } from "./public-api-BE74JyVm.js";
|
|
6
4
|
|
|
5
|
+
//#region src/test-events.ts
|
|
7
6
|
const scalarChar = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
BLOCK_FOLDED: ">",
|
|
8
|
+
BLOCK_LITERAL: "|",
|
|
9
|
+
PLAIN: ":",
|
|
10
|
+
QUOTE_DOUBLE: "\"",
|
|
11
|
+
QUOTE_SINGLE: "'"
|
|
13
12
|
};
|
|
14
13
|
function anchorExists(doc, anchor) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
return found;
|
|
14
|
+
let found = false;
|
|
15
|
+
visit(doc, { Value(_key, node) {
|
|
16
|
+
if (node.anchor === anchor) {
|
|
17
|
+
found = true;
|
|
18
|
+
return visit.BREAK;
|
|
19
|
+
}
|
|
20
|
+
} });
|
|
21
|
+
return found;
|
|
25
22
|
}
|
|
26
|
-
// test harness for yaml-test-suite event tests
|
|
27
23
|
function testEvents(src) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return { events, error: error ?? e };
|
|
60
|
-
}
|
|
61
|
-
events.push('-STR');
|
|
62
|
-
return { events, error };
|
|
24
|
+
const docs = parseAllDocuments(src);
|
|
25
|
+
const errDoc = docs.find((doc) => doc.errors.length > 0);
|
|
26
|
+
const error = errDoc ? errDoc.errors[0].message : null;
|
|
27
|
+
const events = ["+STR"];
|
|
28
|
+
try {
|
|
29
|
+
for (let i = 0; i < docs.length; ++i) {
|
|
30
|
+
const doc = docs[i];
|
|
31
|
+
const root = doc.value;
|
|
32
|
+
const [rootStart] = doc.range || [0];
|
|
33
|
+
const error = doc.errors[0];
|
|
34
|
+
if (error && (!error.pos || error.pos[0] < rootStart)) throw new Error();
|
|
35
|
+
let docStart = "+DOC";
|
|
36
|
+
if (doc.directives.docStart) docStart += " ---";
|
|
37
|
+
else if (root.range[2] === root.range[0] && !root.anchor && !root.tag) continue;
|
|
38
|
+
events.push(docStart);
|
|
39
|
+
addEvents(events, doc, error?.pos[0] ?? -1, root);
|
|
40
|
+
let docEnd = "-DOC";
|
|
41
|
+
if (doc.directives.docEnd) docEnd += " ...";
|
|
42
|
+
events.push(docEnd);
|
|
43
|
+
}
|
|
44
|
+
} catch (e) {
|
|
45
|
+
return {
|
|
46
|
+
events,
|
|
47
|
+
error: error ?? e
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
events.push("-STR");
|
|
51
|
+
return {
|
|
52
|
+
events,
|
|
53
|
+
error
|
|
54
|
+
};
|
|
63
55
|
}
|
|
64
56
|
function addEvents(events, doc, errPos, node) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
events.push(`=ALI${props} *${alias}`);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const scalar = scalarChar[String(node.type)];
|
|
117
|
-
if (!scalar)
|
|
118
|
-
throw new Error(`Unexpected node type ${node.type}`);
|
|
119
|
-
const value = node.source
|
|
120
|
-
.replace(/\\/g, '\\\\')
|
|
121
|
-
.replace(/\0/g, '\\0')
|
|
122
|
-
.replace(/\x07/g, '\\a')
|
|
123
|
-
.replace(/\x08/g, '\\b')
|
|
124
|
-
.replace(/\t/g, '\\t')
|
|
125
|
-
.replace(/\n/g, '\\n')
|
|
126
|
-
.replace(/\v/g, '\\v')
|
|
127
|
-
.replace(/\f/g, '\\f')
|
|
128
|
-
.replace(/\r/g, '\\r')
|
|
129
|
-
.replace(/\x1b/g, '\\e');
|
|
130
|
-
events.push(`=VAL${props} ${scalar}${value}`);
|
|
131
|
-
}
|
|
57
|
+
if (!node) {
|
|
58
|
+
events.push("=VAL :");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (errPos !== -1 && node instanceof NodeBase && node.range[0] >= errPos) throw new Error();
|
|
62
|
+
let props = "";
|
|
63
|
+
let anchor = node instanceof Scalar || node instanceof Collection ? node.anchor : void 0;
|
|
64
|
+
if (anchor) {
|
|
65
|
+
if (/\d$/.test(anchor)) {
|
|
66
|
+
const alt = anchor.replace(/\d$/, "");
|
|
67
|
+
if (anchorExists(doc, alt)) anchor = alt;
|
|
68
|
+
}
|
|
69
|
+
props = ` &${anchor}`;
|
|
70
|
+
}
|
|
71
|
+
if (node instanceof NodeBase && node.tag) props += ` <${node.tag}>`;
|
|
72
|
+
if (node instanceof YAMLMap) {
|
|
73
|
+
const ev = node.flow ? "+MAP {}" : "+MAP";
|
|
74
|
+
events.push(`${ev}${props}`);
|
|
75
|
+
node.items.forEach(({ key, value }) => {
|
|
76
|
+
addEvents(events, doc, errPos, key);
|
|
77
|
+
addEvents(events, doc, errPos, value);
|
|
78
|
+
});
|
|
79
|
+
events.push("-MAP");
|
|
80
|
+
} else if (node instanceof YAMLSeq) {
|
|
81
|
+
const ev = node.flow ? "+SEQ []" : "+SEQ";
|
|
82
|
+
events.push(`${ev}${props}`);
|
|
83
|
+
node.items.forEach((item) => {
|
|
84
|
+
addEvents(events, doc, errPos, item);
|
|
85
|
+
});
|
|
86
|
+
events.push("-SEQ");
|
|
87
|
+
} else if (node instanceof Pair) {
|
|
88
|
+
events.push(`+MAP${props}`);
|
|
89
|
+
addEvents(events, doc, errPos, node.key);
|
|
90
|
+
addEvents(events, doc, errPos, node.value);
|
|
91
|
+
events.push("-MAP");
|
|
92
|
+
} else if (node instanceof Alias) {
|
|
93
|
+
let alias = node.source;
|
|
94
|
+
if (alias && /\d$/.test(alias)) {
|
|
95
|
+
const alt = alias.replace(/\d$/, "");
|
|
96
|
+
if (anchorExists(doc, alt)) alias = alt;
|
|
97
|
+
}
|
|
98
|
+
events.push(`=ALI${props} *${alias}`);
|
|
99
|
+
} else if (node instanceof Scalar) {
|
|
100
|
+
const scalar = scalarChar[String(node.type)];
|
|
101
|
+
if (!scalar) throw new Error(`Unexpected node type ${node.type}`);
|
|
102
|
+
const value = node.source.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");
|
|
103
|
+
events.push(`=VAL${props} ${scalar}${value}`);
|
|
104
|
+
} else throw new Error(`Unexpected node ${node}`);
|
|
132
105
|
}
|
|
133
106
|
|
|
134
|
-
|
|
107
|
+
//#endregion
|
|
108
|
+
export { testEvents };
|
package/dist/util.d.ts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
3
|
-
export { debug, warn } from './log';
|
|
4
|
-
export type { LogLevelId } from './log';
|
|
5
|
-
export { createPair } from './nodes/Pair';
|
|
6
|
-
export { toJS } from './nodes/toJS';
|
|
7
|
-
export type { ToJSContext } from './nodes/toJS';
|
|
8
|
-
export { findPair } from './nodes/YAMLMap';
|
|
9
|
-
export { map as mapTag } from './schema/common/map';
|
|
10
|
-
export { seq as seqTag } from './schema/common/seq';
|
|
11
|
-
export { string as stringTag } from './schema/common/string';
|
|
12
|
-
export { foldFlowLines } from './stringify/foldFlowLines';
|
|
13
|
-
export type { FoldOptions } from './stringify/foldFlowLines';
|
|
14
|
-
export type { StringifyContext } from './stringify/stringify';
|
|
15
|
-
export { stringifyNumber } from './stringify/stringifyNumber';
|
|
16
|
-
export { stringifyString } from './stringify/stringifyString';
|
|
1
|
+
import { B as LogLevelId, F as StringifyContext, H as warn, L as ToJSContext, M as findPair, R as toJS, V as debug, a as string, i as foldFlowLines, n as stringifyNumber, o as seq, r as FoldOptions, s as map, t as stringifyString, z as NodeCreator } from "./stringifyString-S_ITVLTO.js";
|
|
2
|
+
export { type FoldOptions, type LogLevelId, type NodeCreator, type StringifyContext, type ToJSContext, debug, findPair, foldFlowLines, map as mapTag, seq as seqTag, string as stringTag, stringifyNumber, stringifyString, toJS, warn };
|
package/dist/util.js
CHANGED
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { S as toJS, c as seq, d as findPair, h as warn, l as map, m as debug, o as stringifyNumber, s as string, v as stringifyString, y as foldFlowLines } from "./directives-CG6n4xSM.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var log = require('./log.js');
|
|
5
|
-
var Pair = require('./nodes/Pair.js');
|
|
6
|
-
var toJS = require('./nodes/toJS.js');
|
|
7
|
-
var YAMLMap = require('./nodes/YAMLMap.js');
|
|
8
|
-
var map = require('./schema/common/map.js');
|
|
9
|
-
var seq = require('./schema/common/seq.js');
|
|
10
|
-
var string = require('./schema/common/string.js');
|
|
11
|
-
var foldFlowLines = require('./stringify/foldFlowLines.js');
|
|
12
|
-
var stringifyNumber = require('./stringify/stringifyNumber.js');
|
|
13
|
-
var stringifyString = require('./stringify/stringifyString.js');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exports.createNode = createNode.createNode;
|
|
18
|
-
exports.debug = log.debug;
|
|
19
|
-
exports.warn = log.warn;
|
|
20
|
-
exports.createPair = Pair.createPair;
|
|
21
|
-
exports.toJS = toJS.toJS;
|
|
22
|
-
exports.findPair = YAMLMap.findPair;
|
|
23
|
-
exports.mapTag = map.map;
|
|
24
|
-
exports.seqTag = seq.seq;
|
|
25
|
-
exports.stringTag = string.string;
|
|
26
|
-
exports.foldFlowLines = foldFlowLines.foldFlowLines;
|
|
27
|
-
exports.stringifyNumber = stringifyNumber.stringifyNumber;
|
|
28
|
-
exports.stringifyString = stringifyString.stringifyString;
|
|
3
|
+
export { debug, findPair, foldFlowLines, map as mapTag, seq as seqTag, string as stringTag, stringifyNumber, stringifyString, toJS, warn };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "Eemeli Aro <eemeli@gmail.com>",
|
|
6
6
|
"funding": "https://github.com/sponsors/eemeli",
|
|
@@ -13,55 +13,41 @@
|
|
|
13
13
|
],
|
|
14
14
|
"homepage": "https://eemeli.org/yaml/",
|
|
15
15
|
"files": [
|
|
16
|
-
"
|
|
17
|
-
"dist/",
|
|
18
|
-
"util.js"
|
|
16
|
+
"dist/"
|
|
19
17
|
],
|
|
20
|
-
"type": "
|
|
18
|
+
"type": "module",
|
|
21
19
|
"main": "./dist/index.js",
|
|
22
|
-
"bin": "./bin.
|
|
23
|
-
"browser": {
|
|
24
|
-
"./dist/index.js": "./browser/index.js",
|
|
25
|
-
"./dist/util.js": "./browser/dist/util.js",
|
|
26
|
-
"./util.js": "./browser/dist/util.js"
|
|
27
|
-
},
|
|
20
|
+
"bin": "./bin.js",
|
|
28
21
|
"exports": {
|
|
29
22
|
".": {
|
|
30
23
|
"types": "./dist/index.d.ts",
|
|
31
|
-
"
|
|
32
|
-
"default": "./browser/index.js"
|
|
24
|
+
"default": "./dist/index.js"
|
|
33
25
|
},
|
|
34
26
|
"./package.json": "./package.json",
|
|
35
27
|
"./util": {
|
|
36
28
|
"types": "./dist/util.d.ts",
|
|
37
|
-
"
|
|
38
|
-
"default": "./browser/dist/util.js"
|
|
29
|
+
"default": "./dist/util.js"
|
|
39
30
|
}
|
|
40
31
|
},
|
|
41
32
|
"scripts": {
|
|
42
|
-
"build": "
|
|
43
|
-
"build:browser": "rollup -c config/rollup.browser-config.mjs",
|
|
44
|
-
"build:node": "rollup -c config/rollup.node-config.mjs",
|
|
33
|
+
"build": "rolldown -c",
|
|
45
34
|
"clean": "git clean -fdxe node_modules",
|
|
46
|
-
"lint": "eslint
|
|
35
|
+
"lint": "eslint src/",
|
|
47
36
|
"prettier": "prettier --write .",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"test": "jest --config config/jest.config.js",
|
|
37
|
+
"start": "node -i -e 'YAML=require(\"./src/index.ts\");const{parse,parseDocument,parseAllDocuments,stringify}=YAML'",
|
|
38
|
+
"test": "vitest run",
|
|
51
39
|
"test:all": "npm test && npm run test:types && npm run test:dist && npm run test:dist:types",
|
|
52
|
-
"test:
|
|
53
|
-
"test:dist": "
|
|
54
|
-
"test:dist:types": "tsc --allowJs --moduleResolution node --noEmit --target es5 dist/index.js",
|
|
40
|
+
"test:dist": "npm run build && vitest run",
|
|
41
|
+
"test:dist:types": "tsc --allowJs --moduleResolution node --noEmit --target es5 dist/cli.js dist/index.js dist/test-events.js dist/util.js",
|
|
55
42
|
"test:types": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json",
|
|
56
43
|
"docs:install": "cd docs-slate && bundle install",
|
|
57
|
-
"predocs:deploy": "node docs/prepare-docs.
|
|
44
|
+
"predocs:deploy": "node docs/prepare-docs.js",
|
|
58
45
|
"docs:deploy": "cd docs-slate && ./deploy.sh",
|
|
59
|
-
"predocs": "node docs/prepare-docs.
|
|
46
|
+
"predocs": "node docs/prepare-docs.js",
|
|
60
47
|
"docs": "cd docs-slate && bundle exec middleman server",
|
|
61
48
|
"preversion": "npm test && npm run build",
|
|
62
49
|
"prepublishOnly": "npm run clean && npm test && npm run build"
|
|
63
50
|
},
|
|
64
|
-
"browserslist": "defaults, not ie 11",
|
|
65
51
|
"prettier": {
|
|
66
52
|
"arrowParens": "avoid",
|
|
67
53
|
"semi": false,
|
|
@@ -69,29 +55,19 @@
|
|
|
69
55
|
"trailingComma": "none"
|
|
70
56
|
},
|
|
71
57
|
"devDependencies": {
|
|
72
|
-
"@babel/core": "^7.12.10",
|
|
73
|
-
"@babel/plugin-transform-typescript": "^7.12.17",
|
|
74
|
-
"@babel/preset-env": "^7.12.11",
|
|
75
58
|
"@eslint/js": "^9.9.1",
|
|
76
|
-
"@rollup/plugin-babel": "^6.0.3",
|
|
77
|
-
"@rollup/plugin-replace": "^6.0.3",
|
|
78
|
-
"@rollup/plugin-typescript": "^12.1.1",
|
|
79
|
-
"@types/jest": "^29.2.4",
|
|
80
59
|
"@types/node": "^20.11.20",
|
|
81
|
-
"babel-jest": "^29.0.1",
|
|
82
60
|
"eslint": "^9.9.1",
|
|
83
61
|
"eslint-config-prettier": "^10.1.8",
|
|
84
62
|
"fast-check": "^2.12.0",
|
|
85
|
-
"jest": "^29.0.1",
|
|
86
|
-
"jest-resolve": "^29.7.0",
|
|
87
|
-
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
88
63
|
"prettier": "^3.0.2",
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"typescript": "^5.
|
|
92
|
-
"typescript-eslint": "^8.4.0"
|
|
64
|
+
"rolldown": "^1.0.0-beta.54",
|
|
65
|
+
"rolldown-plugin-dts": "^0.22.1",
|
|
66
|
+
"typescript": "^5.9.3",
|
|
67
|
+
"typescript-eslint": "^8.4.0",
|
|
68
|
+
"vitest": "^4.0.15"
|
|
93
69
|
},
|
|
94
70
|
"engines": {
|
|
95
|
-
"node": "
|
|
71
|
+
"node": "^20.19 || ^22.12 || >=24"
|
|
96
72
|
}
|
|
97
73
|
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { isNode } from '../nodes/identity.js';
|
|
2
|
-
import { Scalar } from '../nodes/Scalar.js';
|
|
3
|
-
import { YAMLMap } from '../nodes/YAMLMap.js';
|
|
4
|
-
import { YAMLSeq } from '../nodes/YAMLSeq.js';
|
|
5
|
-
import { resolveBlockMap } from './resolve-block-map.js';
|
|
6
|
-
import { resolveBlockSeq } from './resolve-block-seq.js';
|
|
7
|
-
import { resolveFlowCollection } from './resolve-flow-collection.js';
|
|
8
|
-
|
|
9
|
-
function resolveCollection(CN, ctx, token, onError, tagName, tag) {
|
|
10
|
-
const coll = token.type === 'block-map'
|
|
11
|
-
? resolveBlockMap(CN, ctx, token, onError, tag)
|
|
12
|
-
: token.type === 'block-seq'
|
|
13
|
-
? resolveBlockSeq(CN, ctx, token, onError, tag)
|
|
14
|
-
: resolveFlowCollection(CN, ctx, token, onError, tag);
|
|
15
|
-
const Coll = coll.constructor;
|
|
16
|
-
// If we got a tagName matching the class, or the tag name is '!',
|
|
17
|
-
// then use the tagName from the node class used to create it.
|
|
18
|
-
if (tagName === '!' || tagName === Coll.tagName) {
|
|
19
|
-
coll.tag = Coll.tagName;
|
|
20
|
-
return coll;
|
|
21
|
-
}
|
|
22
|
-
if (tagName)
|
|
23
|
-
coll.tag = tagName;
|
|
24
|
-
return coll;
|
|
25
|
-
}
|
|
26
|
-
function composeCollection(CN, ctx, token, props, onError) {
|
|
27
|
-
const tagToken = props.tag;
|
|
28
|
-
const tagName = !tagToken
|
|
29
|
-
? null
|
|
30
|
-
: ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg));
|
|
31
|
-
if (token.type === 'block-seq') {
|
|
32
|
-
const { anchor, newlineAfterProp: nl } = props;
|
|
33
|
-
const lastProp = anchor && tagToken
|
|
34
|
-
? anchor.offset > tagToken.offset
|
|
35
|
-
? anchor
|
|
36
|
-
: tagToken
|
|
37
|
-
: (anchor ?? tagToken);
|
|
38
|
-
if (lastProp && (!nl || nl.offset < lastProp.offset)) {
|
|
39
|
-
const message = 'Missing newline after block sequence props';
|
|
40
|
-
onError(lastProp, 'MISSING_CHAR', message);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const expType = token.type === 'block-map'
|
|
44
|
-
? 'map'
|
|
45
|
-
: token.type === 'block-seq'
|
|
46
|
-
? 'seq'
|
|
47
|
-
: token.start.source === '{'
|
|
48
|
-
? 'map'
|
|
49
|
-
: 'seq';
|
|
50
|
-
// shortcut: check if it's a generic YAMLMap or YAMLSeq
|
|
51
|
-
// before jumping into the custom tag logic.
|
|
52
|
-
if (!tagToken ||
|
|
53
|
-
!tagName ||
|
|
54
|
-
tagName === '!' ||
|
|
55
|
-
(tagName === YAMLMap.tagName && expType === 'map') ||
|
|
56
|
-
(tagName === YAMLSeq.tagName && expType === 'seq')) {
|
|
57
|
-
return resolveCollection(CN, ctx, token, onError, tagName);
|
|
58
|
-
}
|
|
59
|
-
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
|
|
60
|
-
if (!tag) {
|
|
61
|
-
const kt = ctx.schema.knownTags[tagName];
|
|
62
|
-
if (kt?.collection === expType) {
|
|
63
|
-
ctx.schema.tags.push(Object.assign({}, kt, { default: false }));
|
|
64
|
-
tag = kt;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
if (kt) {
|
|
68
|
-
onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection ?? 'scalar'}`, true);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, true);
|
|
72
|
-
}
|
|
73
|
-
return resolveCollection(CN, ctx, token, onError, tagName);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
const coll = resolveCollection(CN, ctx, token, onError, tagName, tag);
|
|
77
|
-
const res = tag.resolve?.(coll, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg), ctx.options) ?? coll;
|
|
78
|
-
const node = isNode(res)
|
|
79
|
-
? res
|
|
80
|
-
: new Scalar(res);
|
|
81
|
-
node.range = coll.range;
|
|
82
|
-
node.tag = tagName;
|
|
83
|
-
if (tag?.format)
|
|
84
|
-
node.format = tag.format;
|
|
85
|
-
return node;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export { composeCollection };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Document } from '../doc/Document.js';
|
|
2
|
-
import { composeNode, composeEmptyNode } from './compose-node.js';
|
|
3
|
-
import { resolveEnd } from './resolve-end.js';
|
|
4
|
-
import { resolveProps } from './resolve-props.js';
|
|
5
|
-
|
|
6
|
-
function composeDoc(options, directives, { offset, start, value, end }, onError) {
|
|
7
|
-
const opts = Object.assign({ _directives: directives }, options);
|
|
8
|
-
const doc = new Document(undefined, opts);
|
|
9
|
-
const ctx = {
|
|
10
|
-
atKey: false,
|
|
11
|
-
atRoot: true,
|
|
12
|
-
directives: doc.directives,
|
|
13
|
-
options: doc.options,
|
|
14
|
-
schema: doc.schema
|
|
15
|
-
};
|
|
16
|
-
const props = resolveProps(start, {
|
|
17
|
-
indicator: 'doc-start',
|
|
18
|
-
next: value ?? end?.[0],
|
|
19
|
-
offset,
|
|
20
|
-
onError,
|
|
21
|
-
parentIndent: 0,
|
|
22
|
-
startOnNewline: true
|
|
23
|
-
});
|
|
24
|
-
if (props.found) {
|
|
25
|
-
doc.directives.docStart = true;
|
|
26
|
-
if (value &&
|
|
27
|
-
(value.type === 'block-map' || value.type === 'block-seq') &&
|
|
28
|
-
!props.hasNewline)
|
|
29
|
-
onError(props.end, 'MISSING_CHAR', 'Block collection cannot start on same line with directives-end marker');
|
|
30
|
-
}
|
|
31
|
-
// @ts-expect-error If Contents is set, let's trust the user
|
|
32
|
-
doc.contents = value
|
|
33
|
-
? composeNode(ctx, value, props, onError)
|
|
34
|
-
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
|
35
|
-
const contentEnd = doc.contents.range[2];
|
|
36
|
-
const re = resolveEnd(end, contentEnd, false, onError);
|
|
37
|
-
if (re.comment)
|
|
38
|
-
doc.comment = re.comment;
|
|
39
|
-
doc.range = [offset, contentEnd, re.offset];
|
|
40
|
-
return doc;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { composeDoc };
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Alias } from '../nodes/Alias.js';
|
|
2
|
-
import { isScalar } from '../nodes/identity.js';
|
|
3
|
-
import { composeCollection } from './compose-collection.js';
|
|
4
|
-
import { composeScalar } from './compose-scalar.js';
|
|
5
|
-
import { resolveEnd } from './resolve-end.js';
|
|
6
|
-
import { emptyScalarPosition } from './util-empty-scalar-position.js';
|
|
7
|
-
|
|
8
|
-
const CN = { composeNode, composeEmptyNode };
|
|
9
|
-
function composeNode(ctx, token, props, onError) {
|
|
10
|
-
const atKey = ctx.atKey;
|
|
11
|
-
const { spaceBefore, comment, anchor, tag } = props;
|
|
12
|
-
let node;
|
|
13
|
-
let isSrcToken = true;
|
|
14
|
-
switch (token.type) {
|
|
15
|
-
case 'alias':
|
|
16
|
-
node = composeAlias(ctx, token, onError);
|
|
17
|
-
if (anchor || tag)
|
|
18
|
-
onError(token, 'ALIAS_PROPS', 'An alias node must not specify any properties');
|
|
19
|
-
break;
|
|
20
|
-
case 'scalar':
|
|
21
|
-
case 'single-quoted-scalar':
|
|
22
|
-
case 'double-quoted-scalar':
|
|
23
|
-
case 'block-scalar':
|
|
24
|
-
node = composeScalar(ctx, token, tag, onError);
|
|
25
|
-
if (anchor)
|
|
26
|
-
node.anchor = anchor.source.substring(1);
|
|
27
|
-
break;
|
|
28
|
-
case 'block-map':
|
|
29
|
-
case 'block-seq':
|
|
30
|
-
case 'flow-collection':
|
|
31
|
-
node = composeCollection(CN, ctx, token, props, onError);
|
|
32
|
-
if (anchor)
|
|
33
|
-
node.anchor = anchor.source.substring(1);
|
|
34
|
-
break;
|
|
35
|
-
default: {
|
|
36
|
-
const message = token.type === 'error'
|
|
37
|
-
? token.message
|
|
38
|
-
: `Unsupported token (type: ${token.type})`;
|
|
39
|
-
onError(token, 'UNEXPECTED_TOKEN', message);
|
|
40
|
-
node = composeEmptyNode(ctx, token.offset, undefined, null, props, onError);
|
|
41
|
-
isSrcToken = false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (anchor && node.anchor === '')
|
|
45
|
-
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
46
|
-
if (atKey &&
|
|
47
|
-
ctx.options.stringKeys &&
|
|
48
|
-
(!isScalar(node) ||
|
|
49
|
-
typeof node.value !== 'string' ||
|
|
50
|
-
(node.tag && node.tag !== 'tag:yaml.org,2002:str'))) {
|
|
51
|
-
const msg = 'With stringKeys, all keys must be strings';
|
|
52
|
-
onError(tag ?? token, 'NON_STRING_KEY', msg);
|
|
53
|
-
}
|
|
54
|
-
if (spaceBefore)
|
|
55
|
-
node.spaceBefore = true;
|
|
56
|
-
if (comment) {
|
|
57
|
-
if (token.type === 'scalar' && token.source === '')
|
|
58
|
-
node.comment = comment;
|
|
59
|
-
else
|
|
60
|
-
node.commentBefore = comment;
|
|
61
|
-
}
|
|
62
|
-
// @ts-expect-error Type checking misses meaning of isSrcToken
|
|
63
|
-
if (ctx.options.keepSourceTokens && isSrcToken)
|
|
64
|
-
node.srcToken = token;
|
|
65
|
-
return node;
|
|
66
|
-
}
|
|
67
|
-
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) {
|
|
68
|
-
const token = {
|
|
69
|
-
type: 'scalar',
|
|
70
|
-
offset: emptyScalarPosition(offset, before, pos),
|
|
71
|
-
indent: -1,
|
|
72
|
-
source: ''
|
|
73
|
-
};
|
|
74
|
-
const node = composeScalar(ctx, token, tag, onError);
|
|
75
|
-
if (anchor) {
|
|
76
|
-
node.anchor = anchor.source.substring(1);
|
|
77
|
-
if (node.anchor === '')
|
|
78
|
-
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
79
|
-
}
|
|
80
|
-
if (spaceBefore)
|
|
81
|
-
node.spaceBefore = true;
|
|
82
|
-
if (comment) {
|
|
83
|
-
node.comment = comment;
|
|
84
|
-
node.range[2] = end;
|
|
85
|
-
}
|
|
86
|
-
return node;
|
|
87
|
-
}
|
|
88
|
-
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
89
|
-
const alias = new Alias(source.substring(1));
|
|
90
|
-
if (alias.source === '')
|
|
91
|
-
onError(offset, 'BAD_ALIAS', 'Alias cannot be an empty string');
|
|
92
|
-
if (alias.source.endsWith(':'))
|
|
93
|
-
onError(offset + source.length - 1, 'BAD_ALIAS', 'Alias ending in : is ambiguous', true);
|
|
94
|
-
const valueEnd = offset + source.length;
|
|
95
|
-
const re = resolveEnd(end, valueEnd, options.strict, onError);
|
|
96
|
-
alias.range = [offset, valueEnd, re.offset];
|
|
97
|
-
if (re.comment)
|
|
98
|
-
alias.comment = re.comment;
|
|
99
|
-
return alias;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export { composeEmptyNode, composeNode };
|