yaml 2.8.1 → 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 +22 -46
- 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/index.d.ts
CHANGED
|
@@ -1,25 +1,335 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { A as YAMLSeq, C as ToStringOptions, D as Schema, E as Pair, F as StringifyContext, G as YAMLError, I as Scalar, J as LineCounter, K as YAMLParseError, L as ToJSContext, N as NodeOf, O as CollectionTag, P as Primitive, S as ToJSOptions, T as Tags, U as Reviver, W as ErrorCode, _ as Range, b as ParseOptions, c as Directives, d as Replacer, f as Alias, g as NodeBase, h as Node, j as YAMLMap, k as ScalarTag, l as DocValue, m as cst_d_exports, p as Token, q as YAMLWarning, u as Document, v as CreateNodeOptions, w as TagId, x as SchemaOptions, y as DocumentOptions, z as NodeCreator } from "./stringifyString-S_ITVLTO.js";
|
|
2
|
+
|
|
3
|
+
//#region src/compose/composer.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Compose a stream of CST nodes into a stream of YAML Documents.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Composer, Parser } from 'yaml'
|
|
9
|
+
*
|
|
10
|
+
* const src: string = ...
|
|
11
|
+
* const tokens = new Parser().parse(src)
|
|
12
|
+
* const docs = new Composer().compose(tokens)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare class Composer<Value extends DocValue = DocValue, Strict extends boolean = true> {
|
|
16
|
+
private directives;
|
|
17
|
+
private doc;
|
|
18
|
+
private docs;
|
|
19
|
+
private options;
|
|
20
|
+
private atDirectives;
|
|
21
|
+
private prelude;
|
|
22
|
+
private errors;
|
|
23
|
+
private warnings;
|
|
24
|
+
constructor(options?: ParseOptions & DocumentOptions & SchemaOptions);
|
|
25
|
+
private onError;
|
|
26
|
+
private decorate;
|
|
27
|
+
/**
|
|
28
|
+
* Current stream status information.
|
|
29
|
+
*
|
|
30
|
+
* Mostly useful at the end of input for an empty stream.
|
|
31
|
+
*/
|
|
32
|
+
streamInfo(): {
|
|
33
|
+
comment: string;
|
|
34
|
+
directives: Directives;
|
|
35
|
+
errors: YAMLParseError[];
|
|
36
|
+
warnings: YAMLWarning[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Compose tokens into documents.
|
|
40
|
+
*
|
|
41
|
+
* @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
|
|
42
|
+
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
43
|
+
*/
|
|
44
|
+
compose(tokens: Iterable<Token>, forceDoc?: boolean, endOffset?: number): Document.Parsed<Value, Strict>[];
|
|
45
|
+
/** Advance the composer by one CST token. */
|
|
46
|
+
next(token: Token): void;
|
|
47
|
+
/**
|
|
48
|
+
* Call at end of input to handle any remaining document.
|
|
49
|
+
*
|
|
50
|
+
* @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
|
|
51
|
+
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
52
|
+
*/
|
|
53
|
+
end(forceDoc?: boolean, endOffset?: number): Document.Parsed<Value, Strict>[];
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/parse/lexer.d.ts
|
|
57
|
+
/**
|
|
58
|
+
* Splits an input `source` string into lexical YAML tokens,
|
|
59
|
+
* i.e. smaller strings that are easily identifiable by `tokens.tokenType()`.
|
|
60
|
+
*
|
|
61
|
+
* Lexing starts always in a "stream" context.
|
|
62
|
+
*
|
|
63
|
+
* In addition to slices of the original input, the following control characters
|
|
64
|
+
* may also be emitted:
|
|
65
|
+
*
|
|
66
|
+
* - `\x02` (Start of Text): A document starts with the next token
|
|
67
|
+
* - `\x18` (Cancel): Unexpected end of flow-mode (indicates an error)
|
|
68
|
+
* - `\x1f` (Unit Separator): Next token is a scalar value
|
|
69
|
+
* - `\u{FEFF}` (Byte order mark): Emitted separately outside documents
|
|
70
|
+
*/
|
|
71
|
+
declare function lex(source: string): string[];
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/parse/parser.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* A YAML concrete syntax tree (CST) parser
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* const src: string = ...
|
|
79
|
+
* for (const token of new Parser().parse(src)) {
|
|
80
|
+
* // token: Token
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* To use the parser with a user-provided lexer:
|
|
85
|
+
*
|
|
86
|
+
* ```ts
|
|
87
|
+
* function parse(source: string, lexTokens: string[]) {
|
|
88
|
+
* const parser = new Parser()
|
|
89
|
+
* for (const lexeme of lexTokens) parser.next(lexeme)
|
|
90
|
+
* return parser.end()
|
|
91
|
+
* }
|
|
92
|
+
*
|
|
93
|
+
* const src: string = ...
|
|
94
|
+
* for (const token of parse(src, lex(src))) {
|
|
95
|
+
* // token: Token
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare class Parser {
|
|
100
|
+
private onNewLine?;
|
|
101
|
+
/** If true, space and sequence indicators count as indentation */
|
|
102
|
+
private atNewLine;
|
|
103
|
+
/** If true, next token is a scalar value */
|
|
104
|
+
private atScalar;
|
|
105
|
+
/** Current indentation level */
|
|
106
|
+
private indent;
|
|
107
|
+
/** Current offset since the start of parsing */
|
|
108
|
+
offset: number;
|
|
109
|
+
/** On the same line with a block map key */
|
|
110
|
+
private onKeyLine;
|
|
111
|
+
/** Top indicates the node that's currently being built */
|
|
112
|
+
stack: Token[];
|
|
113
|
+
/** The source of the current token, set in parse() */
|
|
114
|
+
private source;
|
|
115
|
+
/** The type of the current token, set in parse() */
|
|
116
|
+
private type;
|
|
117
|
+
tokens: Token[];
|
|
118
|
+
/**
|
|
119
|
+
* @param onNewLine - If defined, called separately with the start position of
|
|
120
|
+
* each new line (in `parse()`, including the start of input).
|
|
121
|
+
*/
|
|
122
|
+
constructor(onNewLine?: (offset: number) => void);
|
|
123
|
+
/**
|
|
124
|
+
* Parse `source` as a YAML stream.
|
|
125
|
+
*
|
|
126
|
+
* Errors are not thrown, but included in the result as `{ type: 'error', message }` tokens.
|
|
127
|
+
*
|
|
128
|
+
* @returns Tokens representing each directive, document, and other structure.
|
|
129
|
+
*/
|
|
130
|
+
parse(source: string): Token[];
|
|
131
|
+
/**
|
|
132
|
+
* Advance the parser by the `source` of one lexical token.
|
|
133
|
+
*/
|
|
134
|
+
next(source: string): void;
|
|
135
|
+
/** Call at end of input to account for any remaining constructions */
|
|
136
|
+
end(): Token[];
|
|
137
|
+
private get sourceToken();
|
|
138
|
+
private step;
|
|
139
|
+
private peek;
|
|
140
|
+
private pop;
|
|
141
|
+
private stream;
|
|
142
|
+
private document;
|
|
143
|
+
private scalar;
|
|
144
|
+
private blockScalar;
|
|
145
|
+
private blockMap;
|
|
146
|
+
private blockSequence;
|
|
147
|
+
private flowCollection;
|
|
148
|
+
private flowScalar;
|
|
149
|
+
private startBlockValue;
|
|
150
|
+
private atIndentedComment;
|
|
151
|
+
private documentEnd;
|
|
152
|
+
private lineEnd;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/public-api.d.ts
|
|
156
|
+
interface EmptyStream extends Array<Document.Parsed>, ReturnType<Composer["streamInfo"]> {
|
|
157
|
+
empty: true;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Parse the input as a stream of YAML documents.
|
|
161
|
+
*
|
|
162
|
+
* Documents should be separated from each other by `...` or `---` marker lines.
|
|
163
|
+
*
|
|
164
|
+
* @returns If an empty `docs` array is returned, it will be of type
|
|
165
|
+
* EmptyStream and contain additional stream information. In
|
|
166
|
+
* TypeScript, you should use `'empty' in docs` as a type guard for it.
|
|
167
|
+
*/
|
|
168
|
+
declare function parseAllDocuments<Value extends DocValue = DocValue, Strict extends boolean = true>(source: string, options?: ParseOptions & DocumentOptions & SchemaOptions): Document.Parsed<Value, Strict>[] | EmptyStream;
|
|
169
|
+
/** Parse an input string into a single YAML.Document */
|
|
170
|
+
declare function parseDocument<Value extends DocValue = DocValue, Strict extends boolean = true>(source: string, options?: ParseOptions & DocumentOptions & SchemaOptions): Document.Parsed<Value, Strict>;
|
|
171
|
+
/**
|
|
172
|
+
* Parse an input string into JavaScript.
|
|
173
|
+
*
|
|
174
|
+
* Only supports input consisting of a single YAML document; for multi-document
|
|
175
|
+
* support you should use `YAML.parseAllDocuments`. May throw on error, and may
|
|
176
|
+
* log warnings using `console.warn`.
|
|
177
|
+
*
|
|
178
|
+
* @param str - A string with YAML formatting.
|
|
179
|
+
* @param reviver - A reviver function, as in `JSON.parse()`
|
|
180
|
+
* @returns The value will match the type of the root value of the parsed YAML
|
|
181
|
+
* document, so Maps become objects, Sequences arrays, and scalars result in
|
|
182
|
+
* nulls, booleans, numbers and strings.
|
|
183
|
+
*/
|
|
184
|
+
declare function parse(src: string, options?: ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions): any;
|
|
185
|
+
declare function parse(src: string, reviver: Reviver, options?: ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions): any;
|
|
186
|
+
/**
|
|
187
|
+
* Stringify a value as a YAML document.
|
|
188
|
+
*
|
|
189
|
+
* @param replacer - A replacer array or function, as in `JSON.stringify()`
|
|
190
|
+
* @returns Will always include `\n` as the last character, as is expected of YAML documents.
|
|
191
|
+
*/
|
|
192
|
+
declare function stringify(value: any, options?: DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions): string;
|
|
193
|
+
declare function stringify(value: any, replacer?: Replacer | null, options?: string | number | (DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions)): string;
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/schema/yaml-1.1/omap.d.ts
|
|
196
|
+
declare class YAMLOMap<K extends Primitive | NodeBase = Primitive | NodeBase, V extends Primitive | NodeBase = Primitive | NodeBase> extends YAMLSeq<Pair<K, V>> {
|
|
197
|
+
static tag: string;
|
|
198
|
+
constructor(schema?: Schema);
|
|
199
|
+
add: typeof YAMLMap.prototype.add;
|
|
200
|
+
delete: typeof YAMLMap.prototype.delete;
|
|
201
|
+
get: typeof YAMLMap.prototype.get;
|
|
202
|
+
has: typeof YAMLMap.prototype.has;
|
|
203
|
+
set: typeof YAMLMap.prototype.set;
|
|
204
|
+
/**
|
|
205
|
+
* If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
|
|
206
|
+
* but TypeScript won't allow widening the signature of a child method.
|
|
207
|
+
*/
|
|
208
|
+
toJSON(_?: unknown, ctx?: ToJSContext): unknown[];
|
|
209
|
+
static from(nc: NodeCreator, iterable: unknown): YAMLOMap;
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/schema/yaml-1.1/set.d.ts
|
|
213
|
+
declare class YAMLSet<T extends Primitive | NodeBase = Primitive | NodeBase> extends YAMLMap<T, T> {
|
|
214
|
+
static tag: string;
|
|
215
|
+
constructor(schema?: Schema);
|
|
216
|
+
/**
|
|
217
|
+
* Add a value to the set.
|
|
218
|
+
*
|
|
219
|
+
* If `value` is a Pair, its `.value` must be null and `options` is ignored.
|
|
220
|
+
*
|
|
221
|
+
* If the set already includes a matching value, no value is added.
|
|
222
|
+
*/
|
|
223
|
+
add(value: unknown, options?: Omit<CreateNodeOptions, "aliasDuplicateObjects">): void;
|
|
224
|
+
/**
|
|
225
|
+
* Returns the value matching `key`.
|
|
226
|
+
*/
|
|
227
|
+
get(key: unknown): NodeOf<T> | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* `value` needs to be true/false to add/remove the item from the set.
|
|
230
|
+
*/
|
|
231
|
+
set(key: unknown, value: boolean, options?: Omit<CreateNodeOptions, "aliasDuplicateObjects">): void;
|
|
232
|
+
toJSON(_?: unknown, ctx?: ToJSContext): any;
|
|
233
|
+
toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
|
234
|
+
static from(nc: NodeCreator, iterable: unknown): YAMLSet;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/visit.d.ts
|
|
238
|
+
type visitorFn<T> = (key: number | "key" | "value" | null, node: T, path: readonly (Document | Node | Pair)[]) => void | symbol | number | Node | Pair;
|
|
239
|
+
type visitor = visitorFn<unknown> | {
|
|
240
|
+
Alias?: visitorFn<Alias>;
|
|
241
|
+
Collection?: visitorFn<YAMLMap | YAMLSeq>;
|
|
242
|
+
Map?: visitorFn<YAMLMap>;
|
|
243
|
+
Node?: visitorFn<Alias | Scalar | YAMLMap | YAMLSeq>;
|
|
244
|
+
Pair?: visitorFn<Pair>;
|
|
245
|
+
Scalar?: visitorFn<Scalar>;
|
|
246
|
+
Seq?: visitorFn<YAMLSeq>;
|
|
247
|
+
Value?: visitorFn<Scalar | YAMLMap | YAMLSeq>;
|
|
248
|
+
};
|
|
249
|
+
type asyncVisitorFn<T> = (key: number | "key" | "value" | null, node: T, path: readonly (Document | Node | Pair)[]) => void | symbol | number | Node | Pair | Promise<void | symbol | number | Node | Pair>;
|
|
250
|
+
type asyncVisitor = asyncVisitorFn<unknown> | {
|
|
251
|
+
Alias?: asyncVisitorFn<Alias>;
|
|
252
|
+
Collection?: asyncVisitorFn<YAMLMap | YAMLSeq>;
|
|
253
|
+
Map?: asyncVisitorFn<YAMLMap>;
|
|
254
|
+
Node?: asyncVisitorFn<Alias | Scalar | YAMLMap | YAMLSeq>;
|
|
255
|
+
Pair?: asyncVisitorFn<Pair>;
|
|
256
|
+
Scalar?: asyncVisitorFn<Scalar>;
|
|
257
|
+
Seq?: asyncVisitorFn<YAMLSeq>;
|
|
258
|
+
Value?: asyncVisitorFn<Scalar | YAMLMap | YAMLSeq>;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Apply a visitor to an AST node or document.
|
|
262
|
+
*
|
|
263
|
+
* Walks through the tree (depth-first) starting from `node`, calling a
|
|
264
|
+
* `visitor` function with three arguments:
|
|
265
|
+
* - `key`: For sequence values and map `Pair`, the node's index in the
|
|
266
|
+
* collection. Within a `Pair`, `'key'` or `'value'`, correspondingly.
|
|
267
|
+
* `null` for the root node.
|
|
268
|
+
* - `node`: The current node.
|
|
269
|
+
* - `path`: The ancestry of the current node.
|
|
270
|
+
*
|
|
271
|
+
* The return value of the visitor may be used to control the traversal:
|
|
272
|
+
* - `undefined` (default): Do nothing and continue
|
|
273
|
+
* - `visit.SKIP`: Do not visit the children of this node, continue with next
|
|
274
|
+
* sibling
|
|
275
|
+
* - `visit.BREAK`: Terminate traversal completely
|
|
276
|
+
* - `visit.REMOVE`: Remove the current node, then continue with the next one
|
|
277
|
+
* - `Node`: Replace the current node, then continue by visiting it
|
|
278
|
+
* - `number`: While iterating the items of a sequence or map, set the index
|
|
279
|
+
* of the next step. This is useful especially if the index of the current
|
|
280
|
+
* node has changed.
|
|
281
|
+
*
|
|
282
|
+
* If `visitor` is a single function, it will be called with all values
|
|
283
|
+
* encountered in the tree, including e.g. `null` values. Alternatively,
|
|
284
|
+
* separate visitor functions may be defined for each `Map`, `Pair`, `Seq`,
|
|
285
|
+
* `Alias` and `Scalar` node. To define the same visitor function for more than
|
|
286
|
+
* one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar)
|
|
287
|
+
* and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
|
|
288
|
+
* specific defined one will be used for each node.
|
|
289
|
+
*/
|
|
290
|
+
declare const visit: {
|
|
291
|
+
(node: Node | Document | null, visitor: visitor): void; /** Terminate visit traversal completely */
|
|
292
|
+
BREAK: symbol; /** Do not visit the children of the current node */
|
|
293
|
+
SKIP: symbol; /** Remove the current node */
|
|
294
|
+
REMOVE: symbol;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Apply an async visitor to an AST node or document.
|
|
298
|
+
*
|
|
299
|
+
* Walks through the tree (depth-first) starting from `node`, calling a
|
|
300
|
+
* `visitor` function with three arguments:
|
|
301
|
+
* - `key`: For sequence values and map `Pair`, the node's index in the
|
|
302
|
+
* collection. Within a `Pair`, `'key'` or `'value'`, correspondingly.
|
|
303
|
+
* `null` for the root node.
|
|
304
|
+
* - `node`: The current node.
|
|
305
|
+
* - `path`: The ancestry of the current node.
|
|
306
|
+
*
|
|
307
|
+
* The return value of the visitor may be used to control the traversal:
|
|
308
|
+
* - `Promise`: Must resolve to one of the following values
|
|
309
|
+
* - `undefined` (default): Do nothing and continue
|
|
310
|
+
* - `visitAsync.SKIP`: Do not visit the children of this node,
|
|
311
|
+
* continue with next sibling
|
|
312
|
+
* - `visitAsync.BREAK`: Terminate traversal completely
|
|
313
|
+
* - `visitAsync.REMOVE`: Remove the current node,
|
|
314
|
+
* then continue with the next one
|
|
315
|
+
* - `Node`: Replace the current node, then continue by visiting it
|
|
316
|
+
* - `number`: While iterating the items of a sequence or map, set the index
|
|
317
|
+
* of the next step. This is useful especially if the index of the current
|
|
318
|
+
* node has changed.
|
|
319
|
+
*
|
|
320
|
+
* If `visitor` is a single function, it will be called with all values
|
|
321
|
+
* encountered in the tree, including e.g. `null` values. Alternatively,
|
|
322
|
+
* separate visitor functions may be defined for each `Map`, `Pair`, `Seq`,
|
|
323
|
+
* `Alias` and `Scalar` node. To define the same visitor function for more than
|
|
324
|
+
* one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar)
|
|
325
|
+
* and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
|
|
326
|
+
* specific defined one will be used for each node.
|
|
327
|
+
*/
|
|
328
|
+
declare const visitAsync: {
|
|
329
|
+
(node: Node | Document | null, visitor: asyncVisitor): Promise<void>; /** Terminate visit traversal completely */
|
|
330
|
+
BREAK: symbol; /** Do not visit the children of the current node */
|
|
331
|
+
SKIP: symbol; /** Remove the current node */
|
|
332
|
+
REMOVE: symbol;
|
|
333
|
+
};
|
|
334
|
+
//#endregion
|
|
335
|
+
export { Alias, cst_d_exports as CST, type CollectionTag, Composer, type CreateNodeOptions, type DocValue, Document, type DocumentOptions, type EmptyStream, type ErrorCode, LineCounter, type Node, Pair, type ParseOptions, Parser, type Range, Scalar, type ScalarTag, Schema, type SchemaOptions, type TagId, type Tags, type ToJSOptions, type ToStringOptions, YAMLError, YAMLMap, type YAMLOMap, YAMLParseError, YAMLSeq, type YAMLSet, YAMLWarning, type asyncVisitor, type asyncVisitorFn, lex, parse, parseAllDocuments, parseDocument, stringify, visit, visitAsync, type visitor, type visitorFn };
|
package/dist/index.js
CHANGED
|
@@ -1,50 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { a as Schema, b as Scalar, f as Alias, g as YAMLSeq, i as Document, n as visit, p as Pair, r as visitAsync, u as YAMLMap } from "./directives-CG6n4xSM.js";
|
|
2
|
+
import { a as cst_exports, c as YAMLParseError, i as lex, l as YAMLWarning, n as Composer, r as Parser, s as YAMLError, t as LineCounter } from "./line-counter-TFl552k_.js";
|
|
3
|
+
import { i as stringify, n as parseAllDocuments, r as parseDocument, t as parse } from "./public-api-BE74JyVm.js";
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
var Document = require('./doc/Document.js');
|
|
5
|
-
var Schema = require('./schema/Schema.js');
|
|
6
|
-
var errors = require('./errors.js');
|
|
7
|
-
var Alias = require('./nodes/Alias.js');
|
|
8
|
-
var identity = require('./nodes/identity.js');
|
|
9
|
-
var Pair = require('./nodes/Pair.js');
|
|
10
|
-
var Scalar = require('./nodes/Scalar.js');
|
|
11
|
-
var YAMLMap = require('./nodes/YAMLMap.js');
|
|
12
|
-
var YAMLSeq = require('./nodes/YAMLSeq.js');
|
|
13
|
-
var cst = require('./parse/cst.js');
|
|
14
|
-
var lexer = require('./parse/lexer.js');
|
|
15
|
-
var lineCounter = require('./parse/line-counter.js');
|
|
16
|
-
var parser = require('./parse/parser.js');
|
|
17
|
-
var publicApi = require('./public-api.js');
|
|
18
|
-
var visit = require('./visit.js');
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
exports.Composer = composer.Composer;
|
|
23
|
-
exports.Document = Document.Document;
|
|
24
|
-
exports.Schema = Schema.Schema;
|
|
25
|
-
exports.YAMLError = errors.YAMLError;
|
|
26
|
-
exports.YAMLParseError = errors.YAMLParseError;
|
|
27
|
-
exports.YAMLWarning = errors.YAMLWarning;
|
|
28
|
-
exports.Alias = Alias.Alias;
|
|
29
|
-
exports.isAlias = identity.isAlias;
|
|
30
|
-
exports.isCollection = identity.isCollection;
|
|
31
|
-
exports.isDocument = identity.isDocument;
|
|
32
|
-
exports.isMap = identity.isMap;
|
|
33
|
-
exports.isNode = identity.isNode;
|
|
34
|
-
exports.isPair = identity.isPair;
|
|
35
|
-
exports.isScalar = identity.isScalar;
|
|
36
|
-
exports.isSeq = identity.isSeq;
|
|
37
|
-
exports.Pair = Pair.Pair;
|
|
38
|
-
exports.Scalar = Scalar.Scalar;
|
|
39
|
-
exports.YAMLMap = YAMLMap.YAMLMap;
|
|
40
|
-
exports.YAMLSeq = YAMLSeq.YAMLSeq;
|
|
41
|
-
exports.CST = cst;
|
|
42
|
-
exports.Lexer = lexer.Lexer;
|
|
43
|
-
exports.LineCounter = lineCounter.LineCounter;
|
|
44
|
-
exports.Parser = parser.Parser;
|
|
45
|
-
exports.parse = publicApi.parse;
|
|
46
|
-
exports.parseAllDocuments = publicApi.parseAllDocuments;
|
|
47
|
-
exports.parseDocument = publicApi.parseDocument;
|
|
48
|
-
exports.stringify = publicApi.stringify;
|
|
49
|
-
exports.visit = visit.visit;
|
|
50
|
-
exports.visitAsync = visit.visitAsync;
|
|
5
|
+
export { Alias, cst_exports as CST, Composer, Document, LineCounter, Pair, Parser, Scalar, Schema, YAMLError, YAMLMap, YAMLParseError, YAMLSeq, YAMLWarning, lex, parse, parseAllDocuments, parseDocument, stringify, visit, visitAsync };
|