@node-core/utils 7.2.0 → 7.2.1
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/lib/ci/build-types/test_build.js +3 -3
- package/lib/ci/failure_aggregator.js +2 -2
- package/lib/ci/run_ci.js +3 -2
- package/lib/cli.js +6 -6
- package/lib/figures.js +6 -6
- package/lib/update-v8/backport.js +3 -4
- package/lib/verbosity.js +2 -4
- package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/README.md +4 -4
- package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.d.mts +21 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.mjs +46 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/LICENSE +22 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.d.ts +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.js +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.d.ts +35 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.js +1 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.d.ts +34 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.js +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/package.json +88 -0
- package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/package.json +25 -20
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.d.ts +48 -3
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.js +58 -19
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/package.json +1 -1
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/readme.md +36 -1
- package/node_modules/ansi-regex/index.js +9 -4
- package/node_modules/ansi-regex/package.json +1 -1
- package/node_modules/ansi-regex/readme.md +6 -0
- package/node_modules/ansi-styles/index.d.ts +12 -12
- package/node_modules/ansi-styles/index.js +3 -3
- package/node_modules/ansi-styles/package.json +4 -4
- package/node_modules/cli-truncate/index.d.ts +3 -3
- package/node_modules/cli-truncate/index.js +40 -14
- package/node_modules/cli-truncate/node_modules/string-width/index.js +133 -15
- package/node_modules/cli-truncate/node_modules/string-width/package.json +4 -4
- package/node_modules/cli-truncate/node_modules/string-width/readme.md +1 -1
- package/node_modules/cli-truncate/package.json +7 -7
- package/node_modules/cli-truncate/readme.md +2 -3
- package/node_modules/ghauth/.github/dependabot.yml +11 -3
- package/node_modules/ghauth/.github/workflows/depsound.yml +33 -0
- package/node_modules/ghauth/.github/workflows/test-and-release.yml +4 -4
- package/node_modules/ghauth/CHANGELOG.md +60 -0
- package/node_modules/ghauth/package.json +30 -6
- package/node_modules/js-yaml/README.md +20 -187
- package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs +1008 -946
- package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs.map +1 -1
- package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js +29 -23
- package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.cjs.js +1043 -583
- package/node_modules/js-yaml/dist/js-yaml.cjs.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.d.ts +877 -133
- package/node_modules/js-yaml/dist/js-yaml.mjs +995 -556
- package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
- package/node_modules/js-yaml/package.json +8 -7
- package/node_modules/listr2/dist/{index.d.cts → index.d.mts} +90 -60
- package/node_modules/listr2/dist/{index.js → index.mjs} +496 -373
- package/node_modules/listr2/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/listr2/node_modules/string-width/index.js +207 -0
- package/node_modules/listr2/node_modules/string-width/package.json +65 -0
- package/node_modules/listr2/node_modules/string-width/readme.md +66 -0
- package/node_modules/listr2/node_modules/wrap-ansi/index.d.ts +1 -1
- package/node_modules/listr2/node_modules/wrap-ansi/index.js +544 -116
- package/node_modules/listr2/node_modules/wrap-ansi/package.json +10 -13
- package/node_modules/listr2/node_modules/wrap-ansi/readme.md +2 -0
- package/node_modules/listr2/package.json +16 -19
- package/node_modules/log-update/index.d.ts +64 -1
- package/node_modules/log-update/index.js +268 -18
- package/node_modules/log-update/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/log-update/node_modules/string-width/index.js +207 -0
- package/node_modules/log-update/node_modules/string-width/package.json +65 -0
- package/node_modules/log-update/node_modules/string-width/readme.md +66 -0
- package/node_modules/log-update/node_modules/wrap-ansi/index.d.ts +1 -1
- package/node_modules/log-update/node_modules/wrap-ansi/index.js +544 -116
- package/node_modules/log-update/node_modules/wrap-ansi/package.json +10 -13
- package/node_modules/log-update/node_modules/wrap-ansi/readme.md +2 -0
- package/node_modules/log-update/package.json +14 -12
- package/node_modules/log-update/readme.md +61 -0
- package/node_modules/slice-ansi/index.d.ts +2 -2
- package/node_modules/slice-ansi/index.js +260 -112
- package/node_modules/slice-ansi/package.json +10 -9
- package/node_modules/slice-ansi/readme.md +3 -2
- package/node_modules/slice-ansi/tokenize-ansi.js +752 -0
- package/node_modules/smol-toml/README.md +205 -191
- package/node_modules/smol-toml/dist/date.d.ts +0 -1
- package/node_modules/smol-toml/dist/date.js +0 -1
- package/node_modules/smol-toml/dist/error.d.ts +0 -1
- package/node_modules/smol-toml/dist/error.js +0 -1
- package/node_modules/smol-toml/dist/extract.js +32 -65
- package/node_modules/smol-toml/dist/index.cjs +302 -288
- package/node_modules/smol-toml/dist/index.d.ts +0 -1
- package/node_modules/smol-toml/dist/index.js +0 -1
- package/node_modules/smol-toml/dist/parse.d.ts +1 -3
- package/node_modules/smol-toml/dist/parse.js +22 -21
- package/node_modules/smol-toml/dist/primitive.js +75 -76
- package/node_modules/smol-toml/dist/stringify.d.ts +0 -1
- package/node_modules/smol-toml/dist/stringify.js +43 -30
- package/node_modules/smol-toml/dist/struct.js +90 -93
- package/node_modules/smol-toml/dist/util.d.ts +1 -1
- package/node_modules/smol-toml/dist/util.js +36 -39
- package/node_modules/smol-toml/package.json +6 -6
- package/node_modules/strip-ansi/index.js +5 -0
- package/node_modules/strip-ansi/package.json +5 -5
- package/package.json +3 -5
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.cjs +0 -127
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.cts +0 -152
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.ts +0 -152
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.js +0 -92
- package/node_modules/chalk/package.json +0 -92
- package/node_modules/chalk/readme.md +0 -331
- package/node_modules/chalk/source/index.d.ts +0 -437
- package/node_modules/chalk/source/index.js +0 -261
- package/node_modules/chalk/source/utilities.js +0 -33
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +0 -299
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -261
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +0 -1
- package/node_modules/chalk/source/vendor/supports-color/browser.js +0 -32
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +0 -55
- package/node_modules/chalk/source/vendor/supports-color/index.js +0 -206
- package/node_modules/colorette/LICENSE.md +0 -7
- package/node_modules/colorette/README.md +0 -134
- package/node_modules/colorette/index.cjs +0 -218
- package/node_modules/colorette/index.d.ts +0 -93
- package/node_modules/colorette/index.js +0 -150
- package/node_modules/colorette/package.json +0 -40
- package/node_modules/eventemitter3/LICENSE +0 -21
- package/node_modules/eventemitter3/README.md +0 -94
- package/node_modules/eventemitter3/dist/eventemitter3.esm.js +0 -347
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.umd.js +0 -355
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +0 -1
- package/node_modules/eventemitter3/index.d.ts +0 -135
- package/node_modules/eventemitter3/index.js +0 -336
- package/node_modules/eventemitter3/index.mjs +0 -4
- package/node_modules/eventemitter3/package.json +0 -67
- package/node_modules/figures/index.d.ts +0 -279
- package/node_modules/figures/index.js +0 -292
- package/node_modules/figures/package.json +0 -49
- package/node_modules/figures/readme.md +0 -337
- package/node_modules/listr2/dist/index.cjs +0 -2189
- package/node_modules/listr2/dist/index.d.ts +0 -1528
- package/node_modules/rfdc/.github/workflows/ci.yml +0 -21
- package/node_modules/rfdc/LICENSE +0 -15
- package/node_modules/rfdc/default.js +0 -3
- package/node_modules/rfdc/index.d.ts +0 -13
- package/node_modules/rfdc/index.js +0 -198
- package/node_modules/rfdc/index.test-d.ts +0 -13
- package/node_modules/rfdc/package.json +0 -73
- package/node_modules/rfdc/readme.md +0 -181
- package/node_modules/rfdc/test/index.js +0 -306
- package/node_modules/smol-toml/dist/date.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/date.js.map +0 -1
- package/node_modules/smol-toml/dist/error.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/error.js.map +0 -1
- package/node_modules/smol-toml/dist/extract.js.map +0 -1
- package/node_modules/smol-toml/dist/index.cjs.map +0 -1
- package/node_modules/smol-toml/dist/index.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/index.js.map +0 -1
- package/node_modules/smol-toml/dist/parse.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/parse.js.map +0 -1
- package/node_modules/smol-toml/dist/primitive.d.ts +0 -29
- package/node_modules/smol-toml/dist/primitive.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/primitive.js.map +0 -1
- package/node_modules/smol-toml/dist/stringify.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/stringify.js.map +0 -1
- package/node_modules/smol-toml/dist/struct.js.map +0 -1
- package/node_modules/smol-toml/dist/util.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/util.js.map +0 -1
- package/node_modules/smol-toml/src/date.ts +0 -152
- package/node_modules/smol-toml/src/error.ts +0 -77
- package/node_modules/smol-toml/src/extract.ts +0 -113
- package/node_modules/smol-toml/src/index.ts +0 -42
- package/node_modules/smol-toml/src/parse.ts +0 -184
- package/node_modules/smol-toml/src/primitive.ts +0 -249
- package/node_modules/smol-toml/src/stringify.ts +0 -191
- package/node_modules/smol-toml/src/struct.ts +0 -202
- package/node_modules/smol-toml/src/util.ts +0 -106
- /package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/LICENSE +0 -0
- /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.d.ts +0 -0
- /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.js +0 -0
- /package/node_modules/{chalk → ansi-escapes}/license +0 -0
- /package/node_modules/{figures → listr2/node_modules/string-width}/license +0 -0
- /package/node_modules/log-update/node_modules/{ansi-escapes → string-width}/license +0 -0
|
@@ -1,193 +1,519 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returned by a scalar resolver when the source does not match its tag.
|
|
3
|
+
*
|
|
4
|
+
* @category Tags
|
|
5
|
+
*/
|
|
1
6
|
declare const NOT_RESOLVED: unique symbol;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Options for {@link defineScalarTag}.
|
|
9
|
+
*
|
|
10
|
+
* @category Tags
|
|
11
|
+
*/
|
|
12
|
+
interface ScalarTagOptions<Result> {
|
|
13
|
+
/**
|
|
14
|
+
* Whether this tag participates in resolving plain scalars without an
|
|
15
|
+
* explicit tag. Default: `false`.
|
|
16
|
+
*/
|
|
17
|
+
implicit?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether explicit tag names are matched by prefix instead of exact equality.
|
|
20
|
+
* Default: `false`.
|
|
21
|
+
*/
|
|
22
|
+
matchByTagPrefix?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Set of `source.charAt(0)` keys for which `resolve` may succeed (a superset
|
|
25
|
+
* of what it really matches). A key is either a single character or '' (empty
|
|
26
|
+
* source). `null` means "no constraint, always try". Used by the composer to
|
|
27
|
+
* dispatch implicit scalars by first character without running every resolver.
|
|
28
|
+
*/
|
|
29
|
+
implicitFirstChars?: readonly string[] | null;
|
|
30
|
+
/**
|
|
31
|
+
* Construct a value from scalar text, or return {@link NOT_RESOLVED} when it
|
|
32
|
+
* is invalid for this tag. `isExplicit` is true for an explicit tag and
|
|
33
|
+
* `tagName` is the actual matched name.
|
|
34
|
+
*/
|
|
14
35
|
resolve: (source: string, isExplicit: boolean, tagName: string) => Result | typeof NOT_RESOLVED;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Selects this tag for a JavaScript value when dumping. Use `() => false`
|
|
38
|
+
* for load-only tags.
|
|
39
|
+
*/
|
|
40
|
+
identify: (data: any) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* A scalar's printed form is text, so `represent` always yields a string.
|
|
43
|
+
* The factory supplies a `String(data)` default when a tag omits it.
|
|
44
|
+
*/
|
|
45
|
+
represent?: (data: any) => string;
|
|
46
|
+
/** Return the tag name to emit for a prefix-matching tag. Defaults to `tagName`. */
|
|
47
|
+
representTagName?: (data: any) => string;
|
|
18
48
|
}
|
|
19
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Normalized scalar tag returned by {@link defineScalarTag}.
|
|
51
|
+
*
|
|
52
|
+
* @category Tags
|
|
53
|
+
*/
|
|
54
|
+
interface ScalarTagDefinition<Result = unknown> extends Required<ScalarTagOptions<Result>> {
|
|
55
|
+
/** Tag name used for schema lookup. */
|
|
20
56
|
tagName: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
57
|
+
/** YAML node kind handled by this tag. */
|
|
58
|
+
nodeKind: 'scalar';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Options for {@link defineSequenceTag}.
|
|
62
|
+
*
|
|
63
|
+
* @category Tags
|
|
64
|
+
*/
|
|
65
|
+
interface SequenceTagOptions<Carrier, Result = Carrier> {
|
|
66
|
+
/**
|
|
67
|
+
* Whether explicit tag names are matched by prefix instead of exact equality.
|
|
68
|
+
* Default: `false`.
|
|
69
|
+
*/
|
|
70
|
+
matchByTagPrefix?: boolean;
|
|
71
|
+
/** Create the carrier used while constructing a sequence. */
|
|
24
72
|
create: (tagName: string) => Carrier;
|
|
73
|
+
/** Add an item to the carrier. Return a non-empty error message to reject it. */
|
|
25
74
|
addItem: (carrier: Carrier, item: unknown, index: number) => void | string;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
75
|
+
/** Convert the completed carrier to the result. Defaults to the identity function. */
|
|
76
|
+
finalize?: (carrier: Carrier) => Result;
|
|
77
|
+
/**
|
|
78
|
+
* Selects this tag for a JavaScript value when dumping. Use `() => false`
|
|
79
|
+
* for load-only tags.
|
|
80
|
+
*/
|
|
81
|
+
identify: (data: any) => boolean;
|
|
82
|
+
/** Return the array-like contents to dump. Defaults to the identity function. */
|
|
83
|
+
represent?: (data: any) => ArrayLike<unknown>;
|
|
84
|
+
/** Return the tag name to emit for a prefix-matching tag. Defaults to `tagName`. */
|
|
85
|
+
representTagName?: (data: any) => string;
|
|
31
86
|
}
|
|
32
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Normalized sequence tag returned by {@link defineSequenceTag}.
|
|
89
|
+
*
|
|
90
|
+
* @category Tags
|
|
91
|
+
*/
|
|
92
|
+
interface SequenceTagDefinition<Carrier = unknown, Result = Carrier> extends Required<SequenceTagOptions<Carrier, Result>> {
|
|
93
|
+
/** Tag name used for schema lookup. */
|
|
33
94
|
tagName: string;
|
|
34
|
-
|
|
95
|
+
/** YAML node kind handled by this tag. */
|
|
96
|
+
nodeKind: 'sequence';
|
|
97
|
+
/** Sequence tags do not participate in implicit scalar resolution. */
|
|
35
98
|
implicit: false;
|
|
36
|
-
|
|
99
|
+
/** Whether the carrier is also the final result (`finalize` was omitted). */
|
|
100
|
+
carrierIsResult: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Options for {@link defineMappingTag}.
|
|
104
|
+
*
|
|
105
|
+
* @category Tags
|
|
106
|
+
*/
|
|
107
|
+
interface MappingTagOptions<Carrier, Result = Carrier> {
|
|
108
|
+
/**
|
|
109
|
+
* Whether explicit tag names are matched by prefix instead of exact equality.
|
|
110
|
+
* Default: `false`.
|
|
111
|
+
*/
|
|
112
|
+
matchByTagPrefix?: boolean;
|
|
113
|
+
/** Create the carrier used while constructing a mapping. */
|
|
37
114
|
create: (tagName: string) => Carrier;
|
|
115
|
+
/**
|
|
116
|
+
* Writes a pair. Returns '' on success, a non-empty error message otherwise
|
|
117
|
+
* (key does not fit the representation, value rejected, ...). Always a string
|
|
118
|
+
* so the hot path never allocates an exception wrapper.
|
|
119
|
+
*/
|
|
38
120
|
addPair: (carrier: Carrier, key: unknown, value: unknown) => string;
|
|
121
|
+
/** Return whether the carrier contains a key, for duplicate and merge checks. */
|
|
39
122
|
has: (carrier: Carrier, key: unknown) => boolean;
|
|
123
|
+
/** Return the keys of a completed result for YAML merge processing. */
|
|
40
124
|
keys: (result: Result) => Iterable<unknown>;
|
|
125
|
+
/** Return a value from a completed result for YAML merge processing. */
|
|
41
126
|
get: (result: Result, key: unknown) => unknown;
|
|
42
|
-
|
|
127
|
+
/** Convert the completed carrier to the result. Defaults to the identity function. */
|
|
128
|
+
finalize?: (carrier: Carrier) => Result;
|
|
129
|
+
/**
|
|
130
|
+
* Selects this tag for a JavaScript value when dumping. Use `() => false`
|
|
131
|
+
* for load-only tags.
|
|
132
|
+
*/
|
|
133
|
+
identify: (data: any) => boolean;
|
|
134
|
+
/** Return the mapping entries to dump. Defaults to the identity function. */
|
|
135
|
+
represent?: (data: any) => Map<unknown, unknown>;
|
|
136
|
+
/** Return the tag name to emit for a prefix-matching tag. Defaults to `tagName`. */
|
|
137
|
+
representTagName?: (data: any) => string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Normalized mapping tag returned by {@link defineMappingTag}.
|
|
141
|
+
*
|
|
142
|
+
* @category Tags
|
|
143
|
+
*/
|
|
144
|
+
interface MappingTagDefinition<Carrier = unknown, Result = Carrier> extends Required<MappingTagOptions<Carrier, Result>> {
|
|
145
|
+
/** Tag name used for schema lookup. */
|
|
146
|
+
tagName: string;
|
|
147
|
+
/** YAML node kind handled by this tag. */
|
|
148
|
+
nodeKind: 'mapping';
|
|
149
|
+
/** Mapping tags do not participate in implicit scalar resolution. */
|
|
150
|
+
implicit: false;
|
|
151
|
+
/** Whether the carrier is also the final result (`finalize` was omitted). */
|
|
43
152
|
carrierIsResult: boolean;
|
|
44
|
-
identify: IdentifyFn | null;
|
|
45
|
-
represent: MappingRepresent;
|
|
46
|
-
representTagName: RepresentTagNameFn | null;
|
|
47
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Any normalized tag definition accepted by {@link Schema}.
|
|
156
|
+
*
|
|
157
|
+
* @category Tags
|
|
158
|
+
*/
|
|
48
159
|
type TagDefinition = ScalarTagDefinition<any> | SequenceTagDefinition<any, any> | MappingTagDefinition<any, any>;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
identify?: ScalarTagDefinition<Result>['identify'];
|
|
55
|
-
represent?: ScalarTagDefinition<Result>['represent'];
|
|
56
|
-
representTagName?: ScalarTagDefinition<Result>['representTagName'];
|
|
57
|
-
}
|
|
58
|
-
type RepresentOptions<Container, Canonical, Represent> = {
|
|
59
|
-
identify?: null;
|
|
60
|
-
represent?: Represent;
|
|
61
|
-
representTagName?: RepresentTagNameFn | null;
|
|
62
|
-
} | (Container extends Canonical ? {
|
|
63
|
-
identify?: IdentifyFn | null;
|
|
64
|
-
represent?: Represent;
|
|
65
|
-
representTagName?: RepresentTagNameFn | null;
|
|
66
|
-
} : {
|
|
67
|
-
identify: IdentifyFn;
|
|
68
|
-
represent: Represent;
|
|
69
|
-
representTagName?: RepresentTagNameFn | null;
|
|
70
|
-
});
|
|
71
|
-
type SequenceTagOptions<Carrier, Result = Carrier> = {
|
|
72
|
-
matchByTagPrefix?: boolean;
|
|
73
|
-
create: SequenceTagDefinition<Carrier, Result>['create'];
|
|
74
|
-
addItem: SequenceTagDefinition<Carrier, Result>['addItem'];
|
|
75
|
-
finalize?: SequenceTagDefinition<Carrier, Result>['finalize'];
|
|
76
|
-
} & RepresentOptions<Result, ArrayLike<unknown>, SequenceRepresent>;
|
|
77
|
-
type MappingTagOptions<Carrier, Result = Carrier> = {
|
|
78
|
-
matchByTagPrefix?: boolean;
|
|
79
|
-
create: MappingTagDefinition<Carrier, Result>['create'];
|
|
80
|
-
addPair: MappingTagDefinition<Carrier, Result>['addPair'];
|
|
81
|
-
has: MappingTagDefinition<Carrier, Result>['has'];
|
|
82
|
-
keys: MappingTagDefinition<Carrier, Result>['keys'];
|
|
83
|
-
get: MappingTagDefinition<Carrier, Result>['get'];
|
|
84
|
-
finalize?: MappingTagDefinition<Carrier, Result>['finalize'];
|
|
85
|
-
} & RepresentOptions<Result, Map<unknown, unknown>, MappingRepresent>;
|
|
160
|
+
/**
|
|
161
|
+
* Create a normalized scalar tag definition.
|
|
162
|
+
*
|
|
163
|
+
* @category Tags
|
|
164
|
+
*/
|
|
86
165
|
declare function defineScalarTag<Result>(tagName: string, options: ScalarTagOptions<Result>): ScalarTagDefinition<Result>;
|
|
166
|
+
/**
|
|
167
|
+
* Create a normalized sequence tag definition.
|
|
168
|
+
*
|
|
169
|
+
* @category Tags
|
|
170
|
+
*/
|
|
87
171
|
declare function defineSequenceTag<Carrier, Result = Carrier>(tagName: string, options: SequenceTagOptions<Carrier, Result>): SequenceTagDefinition<Carrier, Result>;
|
|
172
|
+
/**
|
|
173
|
+
* Create a normalized mapping tag definition.
|
|
174
|
+
*
|
|
175
|
+
* @category Tags
|
|
176
|
+
*/
|
|
88
177
|
declare function defineMappingTag<Carrier, Result = Carrier>(tagName: string, options: MappingTagOptions<Carrier, Result>): MappingTagDefinition<Carrier, Result>;
|
|
89
178
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
interface TagDefinitionListMap {
|
|
96
|
-
scalar: ScalarTagDefinition[];
|
|
97
|
-
sequence: SequenceTagDefinition[];
|
|
98
|
-
mapping: MappingTagDefinition[];
|
|
99
|
-
}
|
|
179
|
+
/**
|
|
180
|
+
* Controls tag resolution when loading and type selection when dumping.
|
|
181
|
+
*
|
|
182
|
+
* @category Schemas
|
|
183
|
+
*/
|
|
100
184
|
declare class Schema {
|
|
101
185
|
readonly tags: readonly TagDefinition[];
|
|
186
|
+
/** @internal */
|
|
102
187
|
readonly implicitScalarTags: readonly ScalarTagDefinition[];
|
|
103
|
-
|
|
104
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Dispatch implicit scalar resolvers by `source.charAt(0)`. Each bucket holds
|
|
190
|
+
* the resolvers that may match that key, in schema order; a key absent from
|
|
191
|
+
* the map uses
|
|
192
|
+
* {@link Schema.implicitScalarAnyFirstChar}
|
|
193
|
+
* (resolvers that declared no first-char constraint, so they apply to any
|
|
194
|
+
* first character).
|
|
195
|
+
*/
|
|
196
|
+
private readonly implicitScalarByFirstChar;
|
|
197
|
+
private readonly implicitScalarAnyFirstChar;
|
|
198
|
+
/**
|
|
199
|
+
* The default scalar tag (`!!str`), resolved once so the composer's fallback
|
|
200
|
+
* for unresolved plain scalars avoids a keyed lookup per scalar.
|
|
201
|
+
*
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
105
204
|
readonly defaultScalarTag: ScalarTagDefinition;
|
|
205
|
+
/**
|
|
206
|
+
* The default container tags (`!!seq` / `!!map`), used by the dumper: when a
|
|
207
|
+
* value is identified by its default tag, the tag is implicit and not
|
|
208
|
+
* printed. Undefined if the schema does not define them (then such values
|
|
209
|
+
* can't be dumped).
|
|
210
|
+
*
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
106
213
|
readonly defaultSequenceTag: SequenceTagDefinition | undefined;
|
|
214
|
+
/** @internal */
|
|
107
215
|
readonly defaultMappingTag: MappingTagDefinition | undefined;
|
|
108
|
-
readonly exact
|
|
109
|
-
readonly prefix
|
|
216
|
+
private readonly exact;
|
|
217
|
+
private readonly prefix;
|
|
110
218
|
constructor(tags: readonly TagDefinition[]);
|
|
219
|
+
/** @internal */
|
|
220
|
+
lookupScalarTag(tagName: string): ScalarTagDefinition | undefined;
|
|
221
|
+
/** @internal */
|
|
222
|
+
lookupSequenceTag(tagName: string): SequenceTagDefinition | undefined;
|
|
223
|
+
/** @internal */
|
|
224
|
+
lookupMappingTag(tagName: string): MappingTagDefinition | undefined;
|
|
225
|
+
/** @internal */
|
|
226
|
+
resolveImplicitScalarTag(source: string): {
|
|
227
|
+
value: unknown;
|
|
228
|
+
tag: ScalarTagDefinition;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Creates a new schema with the specified tags added. If a tag already
|
|
232
|
+
* exists, it is replaced by the specified tag.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
*
|
|
236
|
+
* ```javascript
|
|
237
|
+
* import { CORE_SCHEMA, mergeTag, realMapTag } from 'js-yaml'
|
|
238
|
+
*
|
|
239
|
+
* const schema = CORE_SCHEMA.withTags(mergeTag, realMapTag)
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
111
242
|
withTags(...tags: Array<TagDefinition | readonly TagDefinition[]>): Schema;
|
|
112
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* The YAML 1.2 Failsafe Schema: strings, sequences, and mappings.
|
|
246
|
+
*
|
|
247
|
+
* @category Schemas
|
|
248
|
+
*/
|
|
113
249
|
declare const FAILSAFE_SCHEMA: Schema;
|
|
250
|
+
/**
|
|
251
|
+
* The YAML 1.2 JSON Schema. It uses JSON scalar forms while retaining YAML
|
|
252
|
+
* collection syntax.
|
|
253
|
+
*
|
|
254
|
+
* @category Schemas
|
|
255
|
+
*/
|
|
114
256
|
declare const JSON_SCHEMA: Schema;
|
|
257
|
+
/**
|
|
258
|
+
* The default schema for the loaders. Note, {@link CORE_SCHEMA} comes
|
|
259
|
+
* without the `!!merge` tag. You can easily enable it if needed.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* Enable {@link mergeTag}:
|
|
263
|
+
*
|
|
264
|
+
* ```javascript
|
|
265
|
+
* import { load, CORE_SCHEMA, mergeTag } from 'js-yaml'
|
|
266
|
+
*
|
|
267
|
+
* try {
|
|
268
|
+
* load(data, { schema: CORE_SCHEMA.withTags(mergeTag) })
|
|
269
|
+
* } catch (e) {
|
|
270
|
+
* console.error(e)
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @category Schemas
|
|
275
|
+
*/
|
|
115
276
|
declare const CORE_SCHEMA: Schema;
|
|
277
|
+
/**
|
|
278
|
+
* YAML 1.1-compatible schema.
|
|
279
|
+
*
|
|
280
|
+
* @category Schemas
|
|
281
|
+
*/
|
|
116
282
|
declare const YAML11_SCHEMA: Schema;
|
|
283
|
+
/**
|
|
284
|
+
* The dumper schema for maximum compatibility. It combines all supported type
|
|
285
|
+
* variants from YAML 1.1 and YAML 1.2 so strings matching any of them are
|
|
286
|
+
* quoted. This makes the generated YAML more compatible with other parsers.
|
|
287
|
+
*
|
|
288
|
+
* The schema is based on YAML 1.1, but extends `!!int` and `!!float` to accept
|
|
289
|
+
* both YAML 1.1 and Core Schema forms, since Core Schema supports some forms
|
|
290
|
+
* that YAML 1.1 does not.
|
|
291
|
+
*
|
|
292
|
+
* @category Schemas
|
|
293
|
+
*/
|
|
294
|
+
declare const DUMP_SCHEMA: Schema;
|
|
117
295
|
|
|
296
|
+
/** @category Tags */
|
|
118
297
|
declare const strTag: ScalarTagDefinition<string>;
|
|
119
298
|
|
|
299
|
+
/** @category Tags */
|
|
120
300
|
declare const nullCoreTag: ScalarTagDefinition<null>;
|
|
121
301
|
|
|
302
|
+
/** @category Tags */
|
|
122
303
|
declare const nullJsonTag: ScalarTagDefinition<null>;
|
|
123
304
|
|
|
305
|
+
/** @category Tags */
|
|
124
306
|
declare const nullYaml11Tag: ScalarTagDefinition<null>;
|
|
125
307
|
|
|
308
|
+
/** @category Tags */
|
|
126
309
|
declare const boolCoreTag: ScalarTagDefinition<boolean>;
|
|
127
310
|
|
|
311
|
+
/** @category Tags */
|
|
128
312
|
declare const boolJsonTag: ScalarTagDefinition<boolean>;
|
|
129
313
|
|
|
314
|
+
/** @category Tags */
|
|
130
315
|
declare const boolYaml11Tag: ScalarTagDefinition<boolean>;
|
|
131
316
|
|
|
317
|
+
/** @category Tags */
|
|
132
318
|
declare const intCoreTag: ScalarTagDefinition<number>;
|
|
133
319
|
|
|
320
|
+
/** @category Tags */
|
|
134
321
|
declare const intJsonTag: ScalarTagDefinition<number>;
|
|
135
322
|
|
|
323
|
+
/** @category Tags */
|
|
136
324
|
declare const intYaml11Tag: ScalarTagDefinition<number>;
|
|
137
325
|
|
|
326
|
+
/** @category Tags */
|
|
138
327
|
declare const floatCoreTag: ScalarTagDefinition<number>;
|
|
139
328
|
|
|
329
|
+
/** @category Tags */
|
|
140
330
|
declare const floatJsonTag: ScalarTagDefinition<number>;
|
|
141
331
|
|
|
332
|
+
/** @category Tags */
|
|
142
333
|
declare const floatYaml11Tag: ScalarTagDefinition<number>;
|
|
143
334
|
|
|
144
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Enables merge keys in {@link CORE_SCHEMA} when added with
|
|
337
|
+
* {@link Schema.withTags}.
|
|
338
|
+
*
|
|
339
|
+
* @category Tags
|
|
340
|
+
*/
|
|
341
|
+
declare const mergeTag: ScalarTagDefinition<"<<">;
|
|
145
342
|
|
|
343
|
+
/**
|
|
344
|
+
* The `!!binary` tag, represented as a `Uint8Array`.
|
|
345
|
+
*
|
|
346
|
+
* @category Tags
|
|
347
|
+
*/
|
|
146
348
|
declare const binaryTag: ScalarTagDefinition<Uint8Array<ArrayBuffer>>;
|
|
147
349
|
|
|
350
|
+
/**
|
|
351
|
+
* The YAML 1.1 `!!timestamp` tag, represented as a JavaScript `Date`.
|
|
352
|
+
*
|
|
353
|
+
* @category Tags
|
|
354
|
+
*/
|
|
148
355
|
declare const timestampTag: ScalarTagDefinition<Date>;
|
|
149
356
|
|
|
357
|
+
/** @category Tags */
|
|
150
358
|
declare const seqTag: SequenceTagDefinition<unknown[], unknown[]>;
|
|
151
359
|
|
|
152
|
-
|
|
360
|
+
/**
|
|
361
|
+
* Provided only for YAML 1.1 compatibility and supported by the loader only.
|
|
362
|
+
* JavaScript has no dedicated class to represent this type, so it cannot be
|
|
363
|
+
* identified and dumped.
|
|
364
|
+
*
|
|
365
|
+
* ```yaml
|
|
366
|
+
* !!omap
|
|
367
|
+
* - one: 1
|
|
368
|
+
* - two: 2
|
|
369
|
+
* ```
|
|
370
|
+
*
|
|
371
|
+
* is loaded as
|
|
372
|
+
*
|
|
373
|
+
* ```javascript
|
|
374
|
+
* [
|
|
375
|
+
* { one: 1 },
|
|
376
|
+
* { two: 2 }
|
|
377
|
+
* ]
|
|
378
|
+
* ```
|
|
379
|
+
*
|
|
380
|
+
* @category Tags
|
|
381
|
+
*/
|
|
382
|
+
declare const omapTag: SequenceTagDefinition<{
|
|
153
383
|
list: unknown[];
|
|
154
384
|
seen: Set<unknown>;
|
|
155
|
-
}
|
|
156
|
-
declare const omapTag: SequenceTagDefinition<OmapCarrier, unknown[]>;
|
|
385
|
+
}, unknown[]>;
|
|
157
386
|
|
|
158
|
-
|
|
159
|
-
|
|
387
|
+
/**
|
|
388
|
+
* Provided only for YAML 1.1 compatibility and supported by the loader only.
|
|
389
|
+
* JavaScript has no dedicated class to represent this type, so it cannot be
|
|
390
|
+
* identified and dumped.
|
|
391
|
+
*
|
|
392
|
+
* ```yaml
|
|
393
|
+
* !!pairs
|
|
394
|
+
* - one: 1
|
|
395
|
+
* - two: 2
|
|
396
|
+
* ```
|
|
397
|
+
*
|
|
398
|
+
* is loaded as
|
|
399
|
+
*
|
|
400
|
+
* ```javascript
|
|
401
|
+
* [
|
|
402
|
+
* ['one', 1],
|
|
403
|
+
* ['two', 2]
|
|
404
|
+
* ]
|
|
405
|
+
* ```
|
|
406
|
+
*
|
|
407
|
+
* @category Tags
|
|
408
|
+
*/
|
|
409
|
+
declare const pairsTag: SequenceTagDefinition<[unknown, unknown][], [unknown, unknown][]>;
|
|
160
410
|
|
|
161
|
-
|
|
162
|
-
|
|
411
|
+
/**
|
|
412
|
+
* This is the default mapping implementation. It uses `{}` objects and has only
|
|
413
|
+
* partial functionality due to language limitations. This choice was made
|
|
414
|
+
* because users expect to get JavaScript objects, and it was left unchanged to
|
|
415
|
+
* avoid too many breaking changes in the v5 release.
|
|
416
|
+
*
|
|
417
|
+
* Side effects:
|
|
418
|
+
*
|
|
419
|
+
* - `Object.hasOwn()` checks or `for...of` loops are required for safe use (to
|
|
420
|
+
* avoid falling through to prototypes).
|
|
421
|
+
* - Only scalar string keys are supported properly.
|
|
422
|
+
* - Other scalar keys, such as `null` and numbers, are converted to strings.
|
|
423
|
+
* This is historical behaviour, and it can cause side effects such as
|
|
424
|
+
* problems with `!!merge`.
|
|
425
|
+
*
|
|
426
|
+
* Note that non-string scalar keys may be deprecated in future versions.
|
|
427
|
+
*
|
|
428
|
+
* Ideally, use {@link realMapTag} instead.
|
|
429
|
+
*
|
|
430
|
+
* @category Tags
|
|
431
|
+
*/
|
|
432
|
+
declare const mapTag: MappingTagDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
163
433
|
|
|
164
|
-
|
|
165
|
-
|
|
434
|
+
/**
|
|
435
|
+
* Recommended when non-string keys are actually needed. It uses native
|
|
436
|
+
* JavaScript `Map` objects, so keys keep their constructed types instead of
|
|
437
|
+
* being converted to strings.
|
|
438
|
+
*
|
|
439
|
+
* It is not the default to avoid widespread breaking changes in existing
|
|
440
|
+
* projects. `Map` has a different access API and does not pass deep equality
|
|
441
|
+
* checks against `{}`-based fixtures. Alongside the other changes in v5,
|
|
442
|
+
* making it the default was considered too disruptive.
|
|
443
|
+
*
|
|
444
|
+
* If these differences are acceptable for your project, we recommend using
|
|
445
|
+
* {@link realMapTag} to guarantee the absence of problems and side effects.
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* Enable {@link realMapTag}:
|
|
449
|
+
*
|
|
450
|
+
* ```javascript
|
|
451
|
+
* import { load, CORE_SCHEMA, realMapTag } from 'js-yaml'
|
|
452
|
+
*
|
|
453
|
+
* try {
|
|
454
|
+
* load(data, { schema: CORE_SCHEMA.withTags(realMapTag) })
|
|
455
|
+
* } catch (e) {
|
|
456
|
+
* console.error(e)
|
|
457
|
+
* }
|
|
458
|
+
* ```
|
|
459
|
+
*
|
|
460
|
+
* @category Tags
|
|
461
|
+
*/
|
|
462
|
+
declare const realMapTag: MappingTagDefinition<Map<unknown, unknown>, Map<unknown, unknown>>;
|
|
166
463
|
|
|
167
|
-
|
|
168
|
-
|
|
464
|
+
/**
|
|
465
|
+
* This implementation exists solely to reproduce v4 behavior exactly. Its use
|
|
466
|
+
* is strongly discouraged. If complex or non-string keys are needed, use
|
|
467
|
+
* {@link realMapTag} instead.
|
|
468
|
+
*
|
|
469
|
+
* @category Tags
|
|
470
|
+
*/
|
|
471
|
+
declare const legacyMapTag: MappingTagDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
169
472
|
|
|
473
|
+
/**
|
|
474
|
+
* The YAML 1.1 `!!set` tag, represented as a JavaScript `Set`.
|
|
475
|
+
*
|
|
476
|
+
* @category Tags
|
|
477
|
+
*/
|
|
170
478
|
declare const setTag: MappingTagDefinition<Set<unknown>, Set<unknown>>;
|
|
171
479
|
|
|
172
|
-
|
|
173
|
-
declare const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
declare const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
480
|
+
/** @category Events */
|
|
481
|
+
declare const EVENT_ID: {
|
|
482
|
+
readonly DOCUMENT: 1;
|
|
483
|
+
readonly SEQUENCE: 2;
|
|
484
|
+
readonly MAPPING: 3;
|
|
485
|
+
readonly SCALAR: 4;
|
|
486
|
+
readonly ALIAS: 5;
|
|
487
|
+
readonly POP: 6;
|
|
488
|
+
};
|
|
489
|
+
/** @category Events */
|
|
490
|
+
type EventId = typeof EVENT_ID[keyof typeof EVENT_ID];
|
|
491
|
+
/** @category Nodes */
|
|
492
|
+
declare const SCALAR_STYLE: {
|
|
493
|
+
readonly PLAIN: 1;
|
|
494
|
+
readonly SINGLE_QUOTED: 2;
|
|
495
|
+
readonly DOUBLE_QUOTED: 3;
|
|
496
|
+
readonly LITERAL_BLOCK: 4;
|
|
497
|
+
readonly FOLDED_BLOCK: 5;
|
|
498
|
+
};
|
|
499
|
+
/** @category Nodes */
|
|
500
|
+
type ScalarStyle = typeof SCALAR_STYLE[keyof typeof SCALAR_STYLE];
|
|
501
|
+
/** @category Nodes */
|
|
502
|
+
declare const COLLECTION_STYLE: {
|
|
503
|
+
readonly BLOCK: 1;
|
|
504
|
+
readonly FLOW: 2;
|
|
505
|
+
};
|
|
506
|
+
/** @category Nodes */
|
|
507
|
+
type CollectionStyle = typeof COLLECTION_STYLE[keyof typeof COLLECTION_STYLE];
|
|
508
|
+
/** @category Nodes */
|
|
509
|
+
declare const CHOMPING_MODE: {
|
|
510
|
+
readonly CLIP: 1;
|
|
511
|
+
readonly STRIP: 2;
|
|
512
|
+
readonly KEEP: 3;
|
|
513
|
+
};
|
|
514
|
+
/** @category Nodes */
|
|
515
|
+
type ChompingMode = typeof CHOMPING_MODE[keyof typeof CHOMPING_MODE];
|
|
516
|
+
/** @category Events */
|
|
191
517
|
type DocumentDirective = {
|
|
192
518
|
kind: 'yaml';
|
|
193
519
|
version: string;
|
|
@@ -196,14 +522,16 @@ type DocumentDirective = {
|
|
|
196
522
|
handle: string;
|
|
197
523
|
prefix: string;
|
|
198
524
|
};
|
|
525
|
+
/** @category Events */
|
|
199
526
|
interface DocumentEvent {
|
|
200
|
-
type: typeof
|
|
527
|
+
type: typeof EVENT_ID.DOCUMENT;
|
|
201
528
|
explicitStart: boolean;
|
|
202
529
|
explicitEnd: boolean;
|
|
203
530
|
directives: DocumentDirective[];
|
|
204
531
|
}
|
|
532
|
+
/** @category Events */
|
|
205
533
|
interface SequenceEvent {
|
|
206
|
-
type: typeof
|
|
534
|
+
type: typeof EVENT_ID.SEQUENCE;
|
|
207
535
|
start: number;
|
|
208
536
|
anchorStart: number;
|
|
209
537
|
anchorEnd: number;
|
|
@@ -211,8 +539,9 @@ interface SequenceEvent {
|
|
|
211
539
|
tagEnd: number;
|
|
212
540
|
style: CollectionStyle;
|
|
213
541
|
}
|
|
542
|
+
/** @category Events */
|
|
214
543
|
interface MappingEvent {
|
|
215
|
-
type: typeof
|
|
544
|
+
type: typeof EVENT_ID.MAPPING;
|
|
216
545
|
start: number;
|
|
217
546
|
anchorStart: number;
|
|
218
547
|
anchorEnd: number;
|
|
@@ -220,8 +549,13 @@ interface MappingEvent {
|
|
|
220
549
|
tagEnd: number;
|
|
221
550
|
style: CollectionStyle;
|
|
222
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* A scalar whose decoded value can be read with {@link getScalarValue}.
|
|
554
|
+
*
|
|
555
|
+
* @category Events
|
|
556
|
+
*/
|
|
223
557
|
interface ScalarEvent {
|
|
224
|
-
type: typeof
|
|
558
|
+
type: typeof EVENT_ID.SCALAR;
|
|
225
559
|
valueStart: number;
|
|
226
560
|
valueEnd: number;
|
|
227
561
|
anchorStart: number;
|
|
@@ -229,112 +563,393 @@ interface ScalarEvent {
|
|
|
229
563
|
tagStart: number;
|
|
230
564
|
tagEnd: number;
|
|
231
565
|
style: ScalarStyle;
|
|
232
|
-
chomping:
|
|
566
|
+
chomping: ChompingMode;
|
|
233
567
|
indent: number;
|
|
234
568
|
fast: boolean;
|
|
235
569
|
}
|
|
570
|
+
/** @category Events */
|
|
236
571
|
interface AliasEvent {
|
|
237
|
-
type: typeof
|
|
572
|
+
type: typeof EVENT_ID.ALIAS;
|
|
238
573
|
anchorStart: number;
|
|
239
574
|
anchorEnd: number;
|
|
240
575
|
}
|
|
576
|
+
/**
|
|
577
|
+
* Closes the most recently opened document, sequence, or mapping.
|
|
578
|
+
*
|
|
579
|
+
* @category Events
|
|
580
|
+
*/
|
|
241
581
|
interface PopEvent {
|
|
242
|
-
type: typeof
|
|
582
|
+
type: typeof EVENT_ID.POP;
|
|
243
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* Source ranges are zero-based and end-exclusive; `-1` means absent.
|
|
586
|
+
*
|
|
587
|
+
* @category Events
|
|
588
|
+
*/
|
|
244
589
|
type Event = DocumentEvent | SequenceEvent | MappingEvent | ScalarEvent | AliasEvent | PopEvent;
|
|
245
590
|
|
|
591
|
+
/** @category Events */
|
|
246
592
|
interface ConstructorOptions {
|
|
593
|
+
/** Source text referenced by offsets in `events`. */
|
|
247
594
|
source: string;
|
|
248
595
|
filename?: string;
|
|
596
|
+
/**
|
|
597
|
+
* Schema to use.
|
|
598
|
+
*
|
|
599
|
+
* @defaultValue {@link CORE_SCHEMA}
|
|
600
|
+
*/
|
|
249
601
|
schema?: Schema;
|
|
602
|
+
/**
|
|
603
|
+
* Enables compatibility with `JSON.parse` behavior. Duplicate keys in a
|
|
604
|
+
* mapping override values instead of throwing an error.
|
|
605
|
+
*
|
|
606
|
+
* @defaultValue `false`
|
|
607
|
+
*/
|
|
250
608
|
json?: boolean;
|
|
609
|
+
/**
|
|
610
|
+
* Maximum total number of keys processed by merge (`<<`) across one load
|
|
611
|
+
* call. Each member of a merge sequence also counts as one key. Set to `-1`
|
|
612
|
+
* to disable the limit.
|
|
613
|
+
*
|
|
614
|
+
* @defaultValue `10000`
|
|
615
|
+
*/
|
|
251
616
|
maxTotalMergeKeys?: number;
|
|
617
|
+
/**
|
|
618
|
+
* Maximum number of alias nodes (`*ref`) per document. Set to `0` to reject
|
|
619
|
+
* all aliases, or to `-1` for no limit.
|
|
620
|
+
*
|
|
621
|
+
* @defaultValue `-1`
|
|
622
|
+
*/
|
|
252
623
|
maxAliases?: number;
|
|
253
624
|
}
|
|
625
|
+
/**
|
|
626
|
+
* Constructs JavaScript documents directly from parser events, without an
|
|
627
|
+
* intermediate AST.
|
|
628
|
+
*
|
|
629
|
+
* @category Events
|
|
630
|
+
*/
|
|
254
631
|
declare function constructFromEvents(events: Event[], options: ConstructorOptions): unknown[];
|
|
255
632
|
|
|
633
|
+
/** @category Events */
|
|
256
634
|
interface ParserOptions {
|
|
635
|
+
/**
|
|
636
|
+
* File path used in error messages.
|
|
637
|
+
*
|
|
638
|
+
* @defaultValue `null`
|
|
639
|
+
*/
|
|
257
640
|
filename?: string;
|
|
641
|
+
/**
|
|
642
|
+
* Maximum nesting depth for collections. Aliases are not taken into account.
|
|
643
|
+
*
|
|
644
|
+
* @defaultValue `100`
|
|
645
|
+
*/
|
|
258
646
|
maxDepth?: number;
|
|
259
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* Parses YAML into a flat event stream referencing source text by offsets.
|
|
650
|
+
*
|
|
651
|
+
* @category Events
|
|
652
|
+
*/
|
|
260
653
|
declare function parseEvents(input: string, options: ParserOptions): Event[];
|
|
261
654
|
|
|
655
|
+
/** @category Main */
|
|
262
656
|
interface LoadOptions extends ParserOptions, Omit<ConstructorOptions, 'source'> {
|
|
263
657
|
}
|
|
658
|
+
/** @inline */
|
|
264
659
|
type LoadAllIterator = (document: unknown) => void;
|
|
660
|
+
/**
|
|
661
|
+
* Same as {@link load}, but understands multi-document sources.
|
|
662
|
+
* Returns an array of documents.
|
|
663
|
+
*
|
|
664
|
+
* @category Main
|
|
665
|
+
*/
|
|
265
666
|
declare function loadAll(input: string, options?: LoadOptions): unknown[];
|
|
667
|
+
/**
|
|
668
|
+
* @deprecated Iterator is not supported.
|
|
669
|
+
*/
|
|
266
670
|
declare function loadAll(input: string, iterator: null, options?: LoadOptions): unknown[];
|
|
671
|
+
/**
|
|
672
|
+
* @deprecated Iterator is not supported.
|
|
673
|
+
*/
|
|
267
674
|
declare function loadAll(input: string, iterator: LoadAllIterator, options?: LoadOptions): void;
|
|
675
|
+
/**
|
|
676
|
+
* Parses `string` as a single YAML document. Throws {@link YAMLException} on
|
|
677
|
+
* error. This function does not understand multi-document or empty sources; it
|
|
678
|
+
* throws an exception on those.
|
|
679
|
+
*
|
|
680
|
+
* > [!NOTE]
|
|
681
|
+
* > 1. When processing untrusted input, see the
|
|
682
|
+
* > [security considerations](../docs/safety.md).
|
|
683
|
+
* > 2. All exceptions MUST be caught, not just {@link YAMLException}.
|
|
684
|
+
* > 3. The default {@link CORE_SCHEMA} comes without the `!!merge` tag. You can
|
|
685
|
+
* > easily enable it if needed.
|
|
686
|
+
* > 4. The default {@link mapTag} is `{}`-object based, with known limitations
|
|
687
|
+
* > (see description). For full compatibility use {@link realMapTag}
|
|
688
|
+
* > instead (it uses native JS `Map`).
|
|
689
|
+
*
|
|
690
|
+
* @example
|
|
691
|
+
* Enable {@link mergeTag} and {@link realMapTag}:
|
|
692
|
+
*
|
|
693
|
+
* ```javascript
|
|
694
|
+
* import { load, CORE_SCHEMA, mergeTag, realMapTag } from 'js-yaml'
|
|
695
|
+
*
|
|
696
|
+
* try {
|
|
697
|
+
* load(data, { schema: CORE_SCHEMA.withTags(mergeTag, realMapTag) })
|
|
698
|
+
* } catch (e) {
|
|
699
|
+
* console.error(e)
|
|
700
|
+
* }
|
|
701
|
+
* ```
|
|
702
|
+
*
|
|
703
|
+
* @category Main
|
|
704
|
+
*/
|
|
268
705
|
declare function load(input: string, options?: LoadOptions): unknown;
|
|
269
706
|
|
|
270
|
-
|
|
271
|
-
tagged: boolean;
|
|
272
|
-
flow: boolean;
|
|
273
|
-
singleQuoted: boolean;
|
|
274
|
-
doubleQuoted: boolean;
|
|
275
|
-
literal: boolean;
|
|
276
|
-
folded: boolean;
|
|
277
|
-
}
|
|
707
|
+
/** @category Nodes */
|
|
278
708
|
interface NodeBase {
|
|
709
|
+
/**
|
|
710
|
+
* YAML tag. Untagged nodes carry the semantic resolved tag; tagged nodes carry
|
|
711
|
+
* the printable/verbatim tag spelling.
|
|
712
|
+
*/
|
|
279
713
|
tag: string;
|
|
280
|
-
|
|
714
|
+
/** Whether to print the node's tag explicitly. */
|
|
715
|
+
tagged: boolean;
|
|
281
716
|
anchor?: string;
|
|
717
|
+
/** Reserved for the formatting layer; not populated by the dumper yet. */
|
|
282
718
|
commentBefore?: string;
|
|
283
719
|
comment?: string;
|
|
284
720
|
commentAfter?: string;
|
|
285
721
|
blankBefore?: number;
|
|
286
722
|
}
|
|
723
|
+
/** @category Nodes */
|
|
287
724
|
interface ScalarNode extends NodeBase {
|
|
288
725
|
kind: 'scalar';
|
|
726
|
+
/** Preferred scalar style; the presenter may fall back when necessary. */
|
|
727
|
+
style: ScalarStyle;
|
|
289
728
|
value: string;
|
|
290
729
|
}
|
|
730
|
+
/** @category Nodes */
|
|
291
731
|
interface SequenceNode extends NodeBase {
|
|
292
732
|
kind: 'sequence';
|
|
733
|
+
style: CollectionStyle;
|
|
293
734
|
items: Node[];
|
|
294
735
|
}
|
|
736
|
+
/** @category Nodes */
|
|
295
737
|
interface MappingNode extends NodeBase {
|
|
296
738
|
kind: 'mapping';
|
|
739
|
+
style: CollectionStyle;
|
|
297
740
|
items: Array<{
|
|
298
741
|
key: Node;
|
|
299
742
|
value: Node;
|
|
300
743
|
}>;
|
|
301
744
|
}
|
|
302
|
-
|
|
745
|
+
/** @category Nodes */
|
|
746
|
+
interface AliasNode {
|
|
303
747
|
kind: 'alias';
|
|
748
|
+
/** The anchor name this alias points at (`*name`). */
|
|
304
749
|
anchor: string;
|
|
305
750
|
}
|
|
751
|
+
/** @category Nodes */
|
|
306
752
|
type Node = ScalarNode | SequenceNode | MappingNode | AliasNode;
|
|
753
|
+
/**
|
|
754
|
+
* The layer above {@link Node}: each document wraps one content node plus its
|
|
755
|
+
* own markers/directives. Not a member of {@link Node} — the fields differ.
|
|
756
|
+
* Document directives are ordered presentation data.
|
|
757
|
+
*
|
|
758
|
+
* @category Nodes
|
|
759
|
+
*/
|
|
307
760
|
interface Document {
|
|
761
|
+
/** null = empty document */
|
|
308
762
|
contents: Node | null;
|
|
763
|
+
/** print '---' */
|
|
309
764
|
explicitStart?: boolean;
|
|
765
|
+
/** print '...' */
|
|
310
766
|
explicitEnd?: boolean;
|
|
311
767
|
directives: DocumentDirective[];
|
|
312
768
|
}
|
|
313
769
|
|
|
770
|
+
/** Scalar presentation state passed to styling rules. @category AST */
|
|
771
|
+
interface ScalarLayout {
|
|
772
|
+
readonly node: Readonly<ScalarNode>;
|
|
773
|
+
readonly parent: Readonly<Node> | null;
|
|
774
|
+
readonly level: number;
|
|
775
|
+
readonly isKey: boolean;
|
|
776
|
+
readonly flowOnly: boolean;
|
|
777
|
+
readonly shiftOfParent: number;
|
|
778
|
+
readonly shiftOfContent: number;
|
|
779
|
+
readonly shiftOfFirstLine: number;
|
|
780
|
+
readonly presenterOptions: Readonly<Required<PresenterOptions>>;
|
|
781
|
+
/**
|
|
782
|
+
* Bit mask of allowed styles; each bit corresponds to a {@link SCALAR_STYLE}
|
|
783
|
+
* value.
|
|
784
|
+
*/
|
|
785
|
+
allowedStylesMask: number;
|
|
786
|
+
/**
|
|
787
|
+
* Selected output style, which styling rules may modify. To avoid overriding
|
|
788
|
+
* earlier decisions, a rule should normally modify it only while it is
|
|
789
|
+
* {@link SCALAR_STYLE.PLAIN}.
|
|
790
|
+
*/
|
|
791
|
+
style: ScalarStyle;
|
|
792
|
+
}
|
|
793
|
+
/** Function signature for scalar styling rules. @category AST */
|
|
794
|
+
type ScalarStyleRule = (layout: ScalarLayout) => void;
|
|
795
|
+
|
|
796
|
+
/** @category AST */
|
|
314
797
|
interface PresenterOptions {
|
|
798
|
+
/** Schema used when selecting a safe scalar style. */
|
|
315
799
|
schema: Schema;
|
|
800
|
+
/**
|
|
801
|
+
* Indentation width in spaces.
|
|
802
|
+
*
|
|
803
|
+
* @defaultValue `2`
|
|
804
|
+
*/
|
|
316
805
|
indent?: number;
|
|
806
|
+
/**
|
|
807
|
+
* Does not add an indentation level to array elements when enabled.
|
|
808
|
+
*
|
|
809
|
+
* @defaultValue `false`
|
|
810
|
+
*/
|
|
317
811
|
seqNoIndent?: boolean;
|
|
812
|
+
/**
|
|
813
|
+
* Allows a nested collection to start on the same line after `-`.
|
|
814
|
+
*
|
|
815
|
+
* @defaultValue `true`
|
|
816
|
+
*/
|
|
318
817
|
seqInlineFirst?: boolean;
|
|
319
|
-
|
|
818
|
+
/**
|
|
819
|
+
* Preferred line width for folding. Unbreakable and more-indented lines may
|
|
820
|
+
* exceed it. Set to `-1` for unlimited width.
|
|
821
|
+
*
|
|
822
|
+
* @defaultValue `80`
|
|
823
|
+
*/
|
|
320
824
|
lineWidth?: number;
|
|
825
|
+
/**
|
|
826
|
+
* Adds spaces inside flow collection brackets: `{a: 1}` becomes `{ a: 1 }`.
|
|
827
|
+
*
|
|
828
|
+
* @defaultValue `false`
|
|
829
|
+
*/
|
|
321
830
|
flowBracketPadding?: boolean;
|
|
831
|
+
/**
|
|
832
|
+
* Omits the space after commas in flow collections: `[1, 2]` becomes
|
|
833
|
+
* `[1,2]`.
|
|
834
|
+
*
|
|
835
|
+
* @defaultValue `false`
|
|
836
|
+
*/
|
|
322
837
|
flowSkipCommaSpace?: boolean;
|
|
838
|
+
/**
|
|
839
|
+
* Omits the space after `:` in flow mappings: `{"a": 1}` becomes `{"a":1}`.
|
|
840
|
+
*
|
|
841
|
+
* This forces `quoteFlowKeys`; otherwise `a:1` would be parsed as a single
|
|
842
|
+
* plain scalar instead of a mapping entry.
|
|
843
|
+
*
|
|
844
|
+
* @defaultValue `false`
|
|
845
|
+
*/
|
|
323
846
|
flowSkipColonSpace?: boolean;
|
|
847
|
+
/**
|
|
848
|
+
* Quotes flow mapping keys: `{a: 1}` becomes `{"a": 1}`.
|
|
849
|
+
*
|
|
850
|
+
* @defaultValue `false`
|
|
851
|
+
*/
|
|
324
852
|
quoteFlowKeys?: boolean;
|
|
853
|
+
/**
|
|
854
|
+
* Quoting style to use when a string needs quotes.
|
|
855
|
+
*
|
|
856
|
+
* @defaultValue `'single'`
|
|
857
|
+
*/
|
|
325
858
|
quoteStyle?: 'single' | 'double';
|
|
859
|
+
/**
|
|
860
|
+
* Quotes all non-key strings using {@link quoteStyle}.
|
|
861
|
+
*
|
|
862
|
+
* @defaultValue `false`
|
|
863
|
+
*/
|
|
326
864
|
forceQuotes?: boolean;
|
|
865
|
+
/**
|
|
866
|
+
* Customizes how strings are rendered as plain, quoted, literal, or folded
|
|
867
|
+
* scalars. Rules are applied in array order; providing this option replaces
|
|
868
|
+
* the {@link DEFAULT_SCALAR_STYLE_RULES default rules}.
|
|
869
|
+
*
|
|
870
|
+
* @defaultValue `Object.values(DEFAULT_SCALAR_STYLE_RULES)`
|
|
871
|
+
*/
|
|
872
|
+
scalarStyleRules?: readonly ScalarStyleRule[];
|
|
873
|
+
/**
|
|
874
|
+
* Prints an explicit tag before an anchor: `&ref_0 !!set` becomes
|
|
875
|
+
* `!!set &ref_0`.
|
|
876
|
+
*
|
|
877
|
+
* @defaultValue `false`
|
|
878
|
+
*/
|
|
327
879
|
tagBeforeAnchor?: boolean;
|
|
328
880
|
}
|
|
881
|
+
/**
|
|
882
|
+
* Build YAML from AST.
|
|
883
|
+
*
|
|
884
|
+
* @category AST
|
|
885
|
+
*/
|
|
329
886
|
declare function present(documents: Document[], options: PresenterOptions): string;
|
|
330
887
|
|
|
888
|
+
/** @category Main */
|
|
331
889
|
interface DumpOptions extends Omit<PresenterOptions, 'schema'> {
|
|
890
|
+
/**
|
|
891
|
+
* Schema to use.
|
|
892
|
+
*
|
|
893
|
+
* @defaultValue {@link DUMP_SCHEMA}
|
|
894
|
+
*/
|
|
332
895
|
schema?: Schema;
|
|
896
|
+
/**
|
|
897
|
+
* Skips invalid types instead of throwing. Invalid mapping pairs and sequence
|
|
898
|
+
* items are skipped; `undefined` sequence items are serialized as `null`.
|
|
899
|
+
*
|
|
900
|
+
* @defaultValue `false`
|
|
901
|
+
*/
|
|
333
902
|
skipInvalid?: boolean;
|
|
903
|
+
/**
|
|
904
|
+
* Inlines duplicate objects instead of converting them into references.
|
|
905
|
+
*
|
|
906
|
+
* @defaultValue `false`
|
|
907
|
+
*/
|
|
334
908
|
noRefs?: boolean;
|
|
909
|
+
/**
|
|
910
|
+
* Nesting level at which collections switch from block to flow style. Set to
|
|
911
|
+
* `-1` to never switch automatically.
|
|
912
|
+
*
|
|
913
|
+
* @defaultValue `-1`
|
|
914
|
+
*/
|
|
335
915
|
flowLevel?: number;
|
|
916
|
+
/**
|
|
917
|
+
* Sorts mapping keys when `true`. A function can be provided to define the
|
|
918
|
+
* sort order.
|
|
919
|
+
*
|
|
920
|
+
* @defaultValue `false`
|
|
921
|
+
* @deprecated Use {@link transform} to reorder mapping items.
|
|
922
|
+
*/
|
|
923
|
+
sortKeys?: boolean | ((a: any, b: any) => number);
|
|
924
|
+
/**
|
|
925
|
+
* Mutates the generated AST before it is rendered.
|
|
926
|
+
*
|
|
927
|
+
* @example Sort mapping keys:
|
|
928
|
+
*
|
|
929
|
+
* ```typescript
|
|
930
|
+
* import { dump, visit } from 'js-yaml'
|
|
931
|
+
*
|
|
932
|
+
* dump(value, {
|
|
933
|
+
* transform: documents => visit(documents, node => {
|
|
934
|
+
* if (node.kind === 'mapping') node.items.sort((a, b) => {
|
|
935
|
+
* const x = a.key.kind === 'scalar' ? a.key.value : ''
|
|
936
|
+
* const y = b.key.kind === 'scalar' ? b.key.value : ''
|
|
937
|
+
* return x.localeCompare(y)
|
|
938
|
+
* })
|
|
939
|
+
* })
|
|
940
|
+
* })
|
|
941
|
+
* ```
|
|
942
|
+
*/
|
|
336
943
|
transform?: (documents: Document[]) => void;
|
|
337
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Serializes JS object as a YAML document. By default it can dump every
|
|
947
|
+
* supported YAML type, so it throws an exception if you try to dump regexps or
|
|
948
|
+
* functions. However, you can disable exceptions by setting the
|
|
949
|
+
* {@link DumpOptions.skipInvalid} option to `true`.
|
|
950
|
+
*
|
|
951
|
+
* @category Main
|
|
952
|
+
*/
|
|
338
953
|
declare function dump(input: any, options?: DumpOptions): string;
|
|
339
954
|
|
|
340
955
|
interface SnippetMark {
|
|
@@ -346,37 +961,166 @@ interface SnippetMark {
|
|
|
346
961
|
snippet?: string | null;
|
|
347
962
|
}
|
|
348
963
|
|
|
964
|
+
/**
|
|
965
|
+
* A YAML error. Unlike an ordinary `Error`, it adds a source snippet showing
|
|
966
|
+
* the location of the problem to the error message, when available.
|
|
967
|
+
*
|
|
968
|
+
* @category Main
|
|
969
|
+
*/
|
|
349
970
|
declare class YAMLException extends Error {
|
|
350
971
|
reason: string;
|
|
351
972
|
mark?: SnippetMark;
|
|
973
|
+
/**
|
|
974
|
+
* Optional `mark` contains source snippet data. Usually, use
|
|
975
|
+
* {@link YAMLException.throwAt} instead of passing it directly.
|
|
976
|
+
*/
|
|
352
977
|
constructor(reason: string, mark?: SnippetMark);
|
|
978
|
+
/**
|
|
979
|
+
* Returns the formatted error, omitting the source snippet in compact mode.
|
|
980
|
+
*/
|
|
353
981
|
toString(compact?: boolean): string;
|
|
982
|
+
/**
|
|
983
|
+
* Builds a YAMLException with a source snippet and throws it. `source` is
|
|
984
|
+
* the raw input text; `position` is an offset into it.
|
|
985
|
+
*/
|
|
986
|
+
static throwAt(source: string, position: number, message: string, filename?: string): never;
|
|
354
987
|
}
|
|
355
988
|
|
|
989
|
+
/**
|
|
990
|
+
* Decodes the scalar referenced by event offsets in `input`.
|
|
991
|
+
*
|
|
992
|
+
* @category Events
|
|
993
|
+
*/
|
|
356
994
|
declare function getScalarValue(input: string, scalar: ScalarEvent): string;
|
|
357
995
|
|
|
996
|
+
/** @category AST */
|
|
358
997
|
interface FromEventsOptions {
|
|
998
|
+
/** Source text referenced by offsets in `events`. */
|
|
359
999
|
source: string;
|
|
1000
|
+
/** Schema used to resolve implicit scalar tags. */
|
|
360
1001
|
schema: Schema;
|
|
361
1002
|
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Builds an AST from parser events
|
|
1005
|
+
*
|
|
1006
|
+
* @category AST
|
|
1007
|
+
*/
|
|
362
1008
|
declare function eventsToAst(events: Event[], options: FromEventsOptions): Document[];
|
|
363
1009
|
|
|
1010
|
+
/** @category AST */
|
|
364
1011
|
interface FromJsOptions {
|
|
1012
|
+
/** Inlines duplicate objects instead of converting them into references. */
|
|
365
1013
|
noRefs?: boolean;
|
|
1014
|
+
/**
|
|
1015
|
+
* Skips unrepresentable values instead of throwing. Invalid mapping pairs
|
|
1016
|
+
* and sequence items are skipped; `undefined` sequence items become `null`.
|
|
1017
|
+
*/
|
|
366
1018
|
skipInvalid?: boolean;
|
|
367
1019
|
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Convert JS object to AST. A JS value is one YAML document. An unrepresentable
|
|
1022
|
+
* root becomes an empty document, which the presenter renders as an empty
|
|
1023
|
+
* string.
|
|
1024
|
+
*
|
|
1025
|
+
* @category AST
|
|
1026
|
+
*/
|
|
368
1027
|
declare function jsToAst(input: unknown, schema: Schema, options?: FromJsOptions): Document[];
|
|
369
1028
|
|
|
1029
|
+
/**
|
|
1030
|
+
* Default scalar styling rules in application order.
|
|
1031
|
+
* See [Scalar styling](../../docs/scalar_styling.md) for usage details.
|
|
1032
|
+
*
|
|
1033
|
+
* @category AST
|
|
1034
|
+
*/
|
|
1035
|
+
declare const DEFAULT_SCALAR_STYLE_RULES: {
|
|
1036
|
+
readonly applyQuoteFlowKeysOption: typeof applyQuoteFlowKeysOption;
|
|
1037
|
+
readonly doubleQuoteForInvisibles: typeof doubleQuoteForInvisibles;
|
|
1038
|
+
readonly doubleQuoteWhitespaceOnly: typeof doubleQuoteWhitespaceOnly;
|
|
1039
|
+
readonly applyForceQuotesOption: typeof applyForceQuotesOption;
|
|
1040
|
+
readonly tryLongOrMultilineAsBlock: typeof tryLongOrMultilineAsBlock;
|
|
1041
|
+
readonly quoteInvalidPlain: typeof quoteInvalidPlain;
|
|
1042
|
+
readonly fallbackToDoubleQuoted: typeof fallbackToDoubleQuoted;
|
|
1043
|
+
};
|
|
1044
|
+
declare function applyQuoteFlowKeysOption(layout: ScalarLayout): void;
|
|
1045
|
+
declare function doubleQuoteForInvisibles(layout: ScalarLayout): void;
|
|
1046
|
+
declare function doubleQuoteWhitespaceOnly(layout: ScalarLayout): void;
|
|
1047
|
+
declare function applyForceQuotesOption(layout: ScalarLayout): void;
|
|
1048
|
+
declare function tryLongOrMultilineAsBlock(layout: ScalarLayout): void;
|
|
1049
|
+
declare function quoteInvalidPlain(layout: ScalarLayout): void;
|
|
1050
|
+
declare function fallbackToDoubleQuoted(layout: ScalarLayout): void;
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Return from a visitor to stop the whole traversal.
|
|
1054
|
+
*
|
|
1055
|
+
* @category AST
|
|
1056
|
+
*/
|
|
370
1057
|
declare const VISIT_BREAK: unique symbol;
|
|
1058
|
+
/**
|
|
1059
|
+
* Return from a visitor to skip the current node's children.
|
|
1060
|
+
*
|
|
1061
|
+
* @category AST
|
|
1062
|
+
*/
|
|
371
1063
|
declare const VISIT_SKIP: unique symbol;
|
|
1064
|
+
/** @inline */
|
|
372
1065
|
type VisitControl = typeof VISIT_BREAK | typeof VISIT_SKIP | undefined | void;
|
|
1066
|
+
/**
|
|
1067
|
+
* Traversal-derived position of the current node. Kept off the node itself: a
|
|
1068
|
+
* node may sit in several places (alias/dedup reuse), so depth/role belong to
|
|
1069
|
+
* the walk, not the node. {@link VisitContext.parent} `kind` +
|
|
1070
|
+
* {@link VisitContext.isKey} pin the exact slot.
|
|
1071
|
+
*
|
|
1072
|
+
* @category AST
|
|
1073
|
+
*/
|
|
373
1074
|
interface VisitContext {
|
|
1075
|
+
/** 0 = document content root */
|
|
374
1076
|
depth: number;
|
|
1077
|
+
/** Enclosing sequence/mapping, null at the root */
|
|
375
1078
|
parent: Node | null;
|
|
1079
|
+
/** Node sits in a mapping key position */
|
|
376
1080
|
isKey: boolean;
|
|
377
1081
|
}
|
|
1082
|
+
/** @category AST */
|
|
378
1083
|
type Visitor = (node: Node, ctx: VisitContext) => VisitControl;
|
|
1084
|
+
/**
|
|
1085
|
+
* Walk every node in the documents, calling {@link Visitor} once per
|
|
1086
|
+
* node (pre-order).
|
|
1087
|
+
*
|
|
1088
|
+
* @category AST
|
|
1089
|
+
*/
|
|
379
1090
|
declare function visit(documents: Document[], visitor: Visitor): void;
|
|
380
1091
|
|
|
381
|
-
|
|
382
|
-
|
|
1092
|
+
/** @deprecated Use `EVENT_ID.DOCUMENT` instead. @internal */
|
|
1093
|
+
declare const EVENT_DOCUMENT: 1;
|
|
1094
|
+
/** @deprecated Use `EVENT_ID.SEQUENCE` instead. @internal */
|
|
1095
|
+
declare const EVENT_SEQUENCE: 2;
|
|
1096
|
+
/** @deprecated Use `EVENT_ID.MAPPING` instead. @internal */
|
|
1097
|
+
declare const EVENT_MAPPING: 3;
|
|
1098
|
+
/** @deprecated Use `EVENT_ID.SCALAR` instead. @internal */
|
|
1099
|
+
declare const EVENT_SCALAR: 4;
|
|
1100
|
+
/** @deprecated Use `EVENT_ID.ALIAS` instead. @internal */
|
|
1101
|
+
declare const EVENT_ALIAS: 5;
|
|
1102
|
+
/** @deprecated Use `EVENT_ID.POP` instead. @internal */
|
|
1103
|
+
declare const EVENT_POP: 6;
|
|
1104
|
+
/** @deprecated Use `SCALAR_STYLE.PLAIN` instead. @internal */
|
|
1105
|
+
declare const SCALAR_STYLE_PLAIN: 1;
|
|
1106
|
+
/** @deprecated Use `SCALAR_STYLE.SINGLE_QUOTED` instead. @internal */
|
|
1107
|
+
declare const SCALAR_STYLE_SINGLE_QUOTED: 2;
|
|
1108
|
+
/** @deprecated Use `SCALAR_STYLE.DOUBLE_QUOTED` instead. @internal */
|
|
1109
|
+
declare const SCALAR_STYLE_DOUBLE_QUOTED: 3;
|
|
1110
|
+
/** @deprecated Use `SCALAR_STYLE.LITERAL_BLOCK` instead. @internal */
|
|
1111
|
+
declare const SCALAR_STYLE_LITERAL_BLOCK: 4;
|
|
1112
|
+
/** @deprecated Use `SCALAR_STYLE.FOLDED_BLOCK` instead. @internal */
|
|
1113
|
+
declare const SCALAR_STYLE_FOLDED_BLOCK: 5;
|
|
1114
|
+
/** @deprecated Use `COLLECTION_STYLE.BLOCK` instead. @internal */
|
|
1115
|
+
declare const COLLECTION_STYLE_BLOCK: 1;
|
|
1116
|
+
/** @deprecated Use `COLLECTION_STYLE.FLOW` instead. @internal */
|
|
1117
|
+
declare const COLLECTION_STYLE_FLOW: 2;
|
|
1118
|
+
/** @deprecated Use `CHOMPING_MODE.CLIP` instead. @internal */
|
|
1119
|
+
declare const CHOMPING_CLIP: 1;
|
|
1120
|
+
/** @deprecated Use `CHOMPING_MODE.STRIP` instead. @internal */
|
|
1121
|
+
declare const CHOMPING_STRIP: 2;
|
|
1122
|
+
/** @deprecated Use `CHOMPING_MODE.KEEP` instead. @internal */
|
|
1123
|
+
declare const CHOMPING_KEEP: 3;
|
|
1124
|
+
|
|
1125
|
+
export { CHOMPING_CLIP, CHOMPING_KEEP, CHOMPING_MODE, CHOMPING_STRIP, COLLECTION_STYLE, COLLECTION_STYLE_BLOCK, COLLECTION_STYLE_FLOW, CORE_SCHEMA, DEFAULT_SCALAR_STYLE_RULES, DUMP_SCHEMA, EVENT_ALIAS, EVENT_DOCUMENT, EVENT_ID, EVENT_MAPPING, EVENT_POP, EVENT_SCALAR, EVENT_SEQUENCE, FAILSAFE_SCHEMA, JSON_SCHEMA, NOT_RESOLVED, SCALAR_STYLE, SCALAR_STYLE_DOUBLE_QUOTED, SCALAR_STYLE_FOLDED_BLOCK, SCALAR_STYLE_LITERAL_BLOCK, SCALAR_STYLE_PLAIN, SCALAR_STYLE_SINGLE_QUOTED, Schema, VISIT_BREAK, VISIT_SKIP, YAML11_SCHEMA, YAMLException, binaryTag, boolCoreTag, boolJsonTag, boolYaml11Tag, constructFromEvents, defineMappingTag, defineScalarTag, defineSequenceTag, dump, eventsToAst, floatCoreTag, floatJsonTag, floatYaml11Tag, getScalarValue, intCoreTag, intJsonTag, intYaml11Tag, jsToAst, legacyMapTag, load, loadAll, mapTag, mergeTag, nullCoreTag, nullJsonTag, nullYaml11Tag, omapTag, pairsTag, parseEvents, present, realMapTag, seqTag, setTag, strTag, timestampTag, visit };
|
|
1126
|
+
export type { AliasEvent, AliasNode, ChompingMode, CollectionStyle, ConstructorOptions, Document, DocumentDirective, DocumentEvent, DumpOptions, Event, EventId, FromEventsOptions, FromJsOptions, LoadOptions, MappingEvent, MappingNode, MappingTagDefinition, MappingTagOptions, Node, NodeBase, ParserOptions, PopEvent, PresenterOptions, ScalarEvent, ScalarLayout, ScalarNode, ScalarStyle, ScalarStyleRule, ScalarTagDefinition, ScalarTagOptions, SequenceEvent, SequenceNode, SequenceTagDefinition, SequenceTagOptions, TagDefinition, VisitContext, Visitor };
|