yaml 2.0.0-4 → 2.0.0-8
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 +5 -5
- package/browser/dist/compose/compose-collection.js +12 -9
- package/browser/dist/compose/compose-doc.js +23 -6
- package/browser/dist/compose/compose-node.js +27 -17
- package/browser/dist/compose/compose-scalar.js +21 -23
- package/browser/dist/compose/composer.js +108 -78
- package/browser/dist/compose/resolve-block-map.js +41 -29
- package/browser/dist/compose/resolve-block-scalar.js +14 -17
- package/browser/dist/compose/resolve-block-seq.js +21 -17
- package/browser/dist/compose/resolve-end.js +7 -8
- package/browser/dist/compose/resolve-flow-collection.js +158 -199
- package/browser/dist/compose/resolve-flow-scalar.js +62 -26
- package/browser/dist/compose/resolve-props.js +72 -37
- package/browser/dist/compose/util-contains-newline.js +15 -12
- package/browser/dist/compose/util-map-includes.js +17 -0
- package/browser/dist/doc/Document.js +74 -99
- package/browser/dist/doc/anchors.js +72 -0
- package/browser/dist/doc/createNode.js +35 -19
- package/browser/dist/doc/directives.js +5 -0
- package/browser/dist/errors.js +16 -12
- package/browser/dist/index.js +3 -3
- package/browser/dist/nodes/Alias.js +51 -28
- package/browser/dist/nodes/Collection.js +23 -92
- package/browser/dist/nodes/Node.js +9 -1
- package/browser/dist/nodes/Pair.js +16 -231
- package/browser/dist/nodes/YAMLMap.js +8 -4
- package/browser/dist/nodes/YAMLSeq.js +7 -4
- package/browser/dist/nodes/addPairToJSMap.js +103 -0
- package/browser/dist/nodes/toJS.js +12 -10
- package/browser/dist/options.js +1 -2
- package/browser/dist/parse/cst-scalar.js +219 -0
- package/browser/dist/parse/cst-stringify.js +61 -0
- package/browser/dist/parse/cst-visit.js +97 -0
- package/{dist/parse/tokens.js → browser/dist/parse/cst.js} +12 -7
- package/browser/dist/parse/lexer.js +149 -125
- package/browser/dist/parse/parser.js +272 -196
- package/browser/dist/public-api.js +11 -14
- package/browser/dist/schema/Schema.js +28 -0
- package/browser/dist/{tags/failsafe → schema/common}/map.js +0 -0
- package/browser/dist/schema/common/null.js +13 -0
- package/browser/dist/{tags/failsafe → schema/common}/seq.js +1 -1
- package/browser/dist/{tags/failsafe → schema/common}/string.js +0 -0
- package/browser/dist/schema/core/bool.js +19 -0
- package/browser/dist/schema/core/float.js +40 -0
- package/browser/dist/schema/core/int.js +38 -0
- package/browser/dist/schema/core/schema.js +23 -0
- package/browser/dist/{tags/json.js → schema/json/schema.js} +5 -6
- package/browser/dist/schema/tags.js +79 -0
- package/browser/dist/{tags → schema}/yaml-1.1/binary.js +0 -0
- package/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/browser/dist/schema/yaml-1.1/float.js +43 -0
- package/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/browser/dist/{tags → schema}/yaml-1.1/omap.js +0 -0
- package/browser/dist/{tags → schema}/yaml-1.1/pairs.js +9 -6
- package/browser/dist/schema/yaml-1.1/schema.js +37 -0
- package/browser/dist/{tags → schema}/yaml-1.1/set.js +0 -0
- package/browser/dist/{tags → schema}/yaml-1.1/timestamp.js +0 -0
- package/browser/dist/stringify/stringify.js +8 -6
- package/browser/dist/stringify/stringifyCollection.js +122 -0
- package/browser/dist/stringify/stringifyComment.js +14 -0
- package/browser/dist/stringify/stringifyDocument.js +64 -0
- package/browser/dist/stringify/stringifyPair.js +111 -0
- package/browser/dist/stringify/stringifyString.js +53 -52
- package/browser/dist/visit.js +20 -1
- package/dist/compose/compose-collection.d.ts +4 -4
- package/dist/compose/compose-collection.js +12 -9
- package/dist/compose/compose-doc.d.ts +4 -3
- package/dist/compose/compose-doc.js +23 -6
- package/dist/compose/compose-node.d.ts +15 -7
- package/dist/compose/compose-node.js +27 -17
- package/dist/compose/compose-scalar.d.ts +4 -3
- package/dist/compose/compose-scalar.js +20 -22
- package/dist/compose/composer.d.ts +28 -23
- package/dist/compose/composer.js +109 -79
- package/dist/compose/resolve-block-map.d.ts +5 -4
- package/dist/compose/resolve-block-map.js +41 -29
- package/dist/compose/resolve-block-scalar.d.ts +5 -3
- package/dist/compose/resolve-block-scalar.js +14 -17
- package/dist/compose/resolve-block-seq.d.ts +4 -4
- package/dist/compose/resolve-block-seq.js +21 -17
- package/dist/compose/resolve-end.d.ts +3 -2
- package/dist/compose/resolve-end.js +7 -8
- package/dist/compose/resolve-flow-collection.d.ts +4 -5
- package/dist/compose/resolve-flow-collection.js +157 -198
- package/dist/compose/resolve-flow-scalar.d.ts +5 -3
- package/dist/compose/resolve-flow-scalar.js +62 -26
- package/dist/compose/resolve-props.d.ts +16 -10
- package/dist/compose/resolve-props.js +72 -37
- package/dist/compose/util-contains-newline.d.ts +1 -1
- package/dist/compose/util-contains-newline.js +15 -12
- package/dist/compose/util-empty-scalar-position.d.ts +1 -1
- package/dist/compose/util-map-includes.d.ts +4 -0
- package/dist/compose/util-map-includes.js +19 -0
- package/dist/doc/Document.d.ts +35 -15
- package/dist/doc/Document.js +72 -97
- package/dist/doc/anchors.d.ts +24 -0
- package/dist/doc/anchors.js +77 -0
- package/dist/doc/createNode.d.ts +10 -11
- package/dist/doc/createNode.js +34 -18
- package/dist/doc/directives.d.ts +1 -0
- package/dist/doc/directives.js +5 -0
- package/dist/errors.d.ts +11 -8
- package/dist/errors.js +16 -12
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -3
- package/dist/nodes/Alias.d.ts +19 -9
- package/dist/nodes/Alias.js +51 -28
- package/dist/nodes/Collection.d.ts +9 -17
- package/dist/nodes/Collection.js +22 -91
- package/dist/nodes/Node.d.ts +10 -4
- package/dist/nodes/Node.js +9 -0
- package/dist/nodes/Pair.d.ts +10 -13
- package/dist/nodes/Pair.js +15 -230
- package/dist/nodes/Scalar.d.ts +6 -3
- package/dist/nodes/YAMLMap.d.ts +3 -3
- package/dist/nodes/YAMLMap.js +8 -4
- package/dist/nodes/YAMLSeq.d.ts +3 -3
- package/dist/nodes/YAMLSeq.js +7 -4
- package/dist/nodes/addPairToJSMap.d.ts +3 -0
- package/dist/nodes/addPairToJSMap.js +105 -0
- package/dist/nodes/toJS.d.ts +4 -5
- package/dist/nodes/toJS.js +12 -10
- package/dist/options.d.ts +41 -25
- package/dist/options.js +1 -2
- package/dist/parse/cst-scalar.d.ts +58 -0
- package/dist/parse/cst-scalar.js +223 -0
- package/dist/parse/cst-stringify.d.ts +8 -0
- package/dist/parse/cst-stringify.js +63 -0
- package/dist/parse/cst-visit.d.ts +39 -0
- package/dist/parse/cst-visit.js +99 -0
- package/dist/parse/{tokens.d.ts → cst.d.ts} +23 -7
- package/{browser/dist/parse/tokens.js → dist/parse/cst.js} +27 -1
- package/dist/parse/lexer.d.ts +7 -14
- package/dist/parse/lexer.js +150 -126
- package/dist/parse/parser.d.ts +31 -24
- package/dist/parse/parser.js +274 -198
- package/dist/public-api.d.ts +7 -7
- package/dist/public-api.js +11 -14
- package/dist/{doc → schema}/Schema.d.ts +6 -3
- package/dist/schema/Schema.js +30 -0
- package/dist/{tags/failsafe → schema/common}/map.d.ts +0 -0
- package/dist/{tags/failsafe → schema/common}/map.js +0 -0
- package/dist/schema/common/null.d.ts +4 -0
- package/dist/schema/common/null.js +15 -0
- package/dist/{tags/failsafe → schema/common}/seq.d.ts +0 -0
- package/dist/{tags/failsafe → schema/common}/seq.js +1 -1
- package/dist/{tags/failsafe → schema/common}/string.d.ts +0 -0
- package/dist/{tags/failsafe → schema/common}/string.js +0 -0
- package/dist/schema/core/bool.d.ts +4 -0
- package/dist/schema/core/bool.js +21 -0
- package/dist/schema/core/float.d.ts +4 -0
- package/dist/schema/core/float.js +44 -0
- package/dist/schema/core/int.d.ts +4 -0
- package/dist/schema/core/int.js +42 -0
- package/dist/schema/core/schema.d.ts +1 -0
- package/dist/schema/core/schema.js +25 -0
- package/dist/schema/json/schema.d.ts +2 -0
- package/dist/{tags/json.js → schema/json/schema.js} +5 -6
- package/dist/schema/tags.d.ts +41 -0
- package/dist/schema/tags.js +82 -0
- package/dist/{tags → schema}/types.d.ts +3 -7
- package/dist/{tags → schema}/yaml-1.1/binary.d.ts +0 -0
- package/dist/{tags → schema}/yaml-1.1/binary.js +0 -0
- package/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/dist/schema/yaml-1.1/bool.js +29 -0
- package/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/dist/schema/yaml-1.1/float.js +47 -0
- package/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/dist/schema/yaml-1.1/int.js +76 -0
- package/dist/{tags → schema}/yaml-1.1/omap.d.ts +0 -0
- package/dist/{tags → schema}/yaml-1.1/omap.js +0 -0
- package/dist/{tags → schema}/yaml-1.1/pairs.d.ts +3 -2
- package/dist/{tags → schema}/yaml-1.1/pairs.js +9 -6
- package/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/dist/schema/yaml-1.1/schema.js +39 -0
- package/dist/{tags → schema}/yaml-1.1/set.d.ts +1 -1
- package/dist/{tags → schema}/yaml-1.1/set.js +0 -0
- package/dist/{tags → schema}/yaml-1.1/timestamp.d.ts +0 -0
- package/dist/{tags → schema}/yaml-1.1/timestamp.js +0 -0
- package/dist/stringify/stringify.d.ts +1 -2
- package/dist/stringify/stringify.js +8 -6
- package/dist/stringify/stringifyCollection.d.ts +21 -0
- package/dist/stringify/stringifyCollection.js +124 -0
- package/dist/stringify/stringifyComment.d.ts +2 -0
- package/dist/stringify/stringifyComment.js +17 -0
- package/dist/stringify/stringifyDocument.d.ts +3 -0
- package/dist/stringify/stringifyDocument.js +66 -0
- package/dist/stringify/stringifyPair.d.ts +3 -0
- package/dist/stringify/stringifyPair.js +113 -0
- package/dist/stringify/stringifyString.js +53 -52
- package/dist/test-events.d.ts +1 -2
- package/dist/test-events.js +25 -12
- package/dist/util.d.ts +1 -1
- package/dist/visit.d.ts +10 -1
- package/dist/visit.js +20 -1
- package/package.json +9 -8
- package/browser/dist/doc/Anchors.js +0 -102
- package/browser/dist/doc/Schema.js +0 -27
- package/browser/dist/doc/getSchemaTags.js +0 -30
- package/browser/dist/stringify/addComment.js +0 -17
- package/browser/dist/tags/core.js +0 -109
- package/browser/dist/tags/failsafe/index.js +0 -7
- package/browser/dist/tags/index.js +0 -34
- package/browser/dist/tags/yaml-1.1/index.js +0 -152
- package/dist/doc/Anchors.d.ts +0 -36
- package/dist/doc/Anchors.js +0 -104
- package/dist/doc/Schema.js +0 -29
- package/dist/doc/getSchemaTags.d.ts +0 -3
- package/dist/doc/getSchemaTags.js +0 -32
- package/dist/stringify/addComment.d.ts +0 -2
- package/dist/stringify/addComment.js +0 -20
- package/dist/tags/core.d.ts +0 -14
- package/dist/tags/core.js +0 -119
- package/dist/tags/failsafe/index.d.ts +0 -1
- package/dist/tags/failsafe/index.js +0 -9
- package/dist/tags/index.d.ts +0 -31
- package/dist/tags/index.js +0 -37
- package/dist/tags/json.d.ts +0 -2
- package/dist/tags/yaml-1.1/index.d.ts +0 -2
- package/dist/tags/yaml-1.1/index.js +0 -154
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { createScalarToken, resolveAsScalar, setScalarValue } from './cst-scalar.js';
|
|
2
|
+
export { stringify } from './cst-stringify.js';
|
|
3
|
+
export { visit, Visitor, VisitPath } from './cst-visit.js';
|
|
2
4
|
export interface SourceToken {
|
|
3
|
-
type:
|
|
5
|
+
type: 'byte-order-mark' | 'doc-mode' | 'doc-start' | 'space' | 'comment' | 'newline' | 'directive-line' | 'anchor' | 'tag' | 'seq-item-ind' | 'explicit-key-ind' | 'map-value-ind' | 'flow-map-start' | 'flow-map-end' | 'flow-seq-start' | 'flow-seq-end' | 'flow-error-end' | 'comma' | 'block-scalar-header';
|
|
6
|
+
offset: number;
|
|
4
7
|
indent: number;
|
|
5
8
|
source: string;
|
|
6
9
|
}
|
|
7
10
|
export interface ErrorToken {
|
|
8
11
|
type: 'error';
|
|
9
|
-
offset
|
|
12
|
+
offset: number;
|
|
10
13
|
source: string;
|
|
11
14
|
message: string;
|
|
12
15
|
}
|
|
13
16
|
export interface Directive {
|
|
14
17
|
type: 'directive';
|
|
18
|
+
offset: number;
|
|
15
19
|
source: string;
|
|
16
20
|
}
|
|
17
21
|
export interface Document {
|
|
@@ -39,7 +43,7 @@ export interface BlockScalar {
|
|
|
39
43
|
offset: number;
|
|
40
44
|
indent: number;
|
|
41
45
|
props: Token[];
|
|
42
|
-
source
|
|
46
|
+
source: string;
|
|
43
47
|
}
|
|
44
48
|
export interface BlockMap {
|
|
45
49
|
type: 'block-map';
|
|
@@ -63,19 +67,27 @@ export interface BlockSequence {
|
|
|
63
67
|
indent: number;
|
|
64
68
|
items: Array<{
|
|
65
69
|
start: SourceToken[];
|
|
66
|
-
|
|
70
|
+
key?: never;
|
|
67
71
|
sep?: never;
|
|
72
|
+
value?: Token;
|
|
68
73
|
}>;
|
|
69
74
|
}
|
|
75
|
+
export declare type CollectionItem = {
|
|
76
|
+
start: SourceToken[];
|
|
77
|
+
key?: Token | null;
|
|
78
|
+
sep?: SourceToken[];
|
|
79
|
+
value?: Token;
|
|
80
|
+
};
|
|
70
81
|
export interface FlowCollection {
|
|
71
82
|
type: 'flow-collection';
|
|
72
83
|
offset: number;
|
|
73
84
|
indent: number;
|
|
74
85
|
start: SourceToken;
|
|
75
|
-
items:
|
|
86
|
+
items: CollectionItem[];
|
|
76
87
|
end: SourceToken[];
|
|
77
88
|
}
|
|
78
89
|
export declare type Token = SourceToken | ErrorToken | Directive | Document | DocumentEnd | FlowScalar | BlockScalar | BlockMap | BlockSequence | FlowCollection;
|
|
90
|
+
export declare type TokenType = SourceToken['type'] | DocumentEnd['type'] | FlowScalar['type'];
|
|
79
91
|
/** The byte order mark */
|
|
80
92
|
export declare const BOM = "\uFEFF";
|
|
81
93
|
/** Start of doc-mode */
|
|
@@ -84,7 +96,11 @@ export declare const DOCUMENT = "\u0002";
|
|
|
84
96
|
export declare const FLOW_END = "\u0018";
|
|
85
97
|
/** Next token is a scalar value */
|
|
86
98
|
export declare const SCALAR = "\u001F";
|
|
99
|
+
/** @returns `true` if `token` is a flow or block collection */
|
|
100
|
+
export declare const isCollection: (token: Token | null | undefined) => token is BlockMap | BlockSequence | FlowCollection;
|
|
101
|
+
/** @returns `true` if `token` is a flow or block scalar; not an alias */
|
|
102
|
+
export declare const isScalar: (token: Token | null | undefined) => token is BlockScalar | FlowScalar;
|
|
87
103
|
/** Get a printable representation of a lexer token */
|
|
88
104
|
export declare function prettyToken(token: string): string;
|
|
89
105
|
/** Identify the type of a lexer token. May return `null` for unknown tokens. */
|
|
90
|
-
export declare function tokenType(source: string):
|
|
106
|
+
export declare function tokenType(source: string): TokenType | null;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cstScalar = require('./cst-scalar.js');
|
|
4
|
+
var cstStringify = require('./cst-stringify.js');
|
|
5
|
+
var cstVisit = require('./cst-visit.js');
|
|
6
|
+
|
|
1
7
|
/** The byte order mark */
|
|
2
8
|
const BOM = '\u{FEFF}';
|
|
3
9
|
/** Start of doc-mode */
|
|
@@ -6,6 +12,14 @@ const DOCUMENT = '\x02'; // C0: Start of Text
|
|
|
6
12
|
const FLOW_END = '\x18'; // C0: Cancel
|
|
7
13
|
/** Next token is a scalar value */
|
|
8
14
|
const SCALAR = '\x1f'; // C0: Unit Separator
|
|
15
|
+
/** @returns `true` if `token` is a flow or block collection */
|
|
16
|
+
const isCollection = (token) => !!token && 'items' in token;
|
|
17
|
+
/** @returns `true` if `token` is a flow or block scalar; not an alias */
|
|
18
|
+
const isScalar = (token) => !!token &&
|
|
19
|
+
(token.type === 'scalar' ||
|
|
20
|
+
token.type === 'single-quoted-scalar' ||
|
|
21
|
+
token.type === 'double-quoted-scalar' ||
|
|
22
|
+
token.type === 'block-scalar');
|
|
9
23
|
/* istanbul ignore next */
|
|
10
24
|
/** Get a printable representation of a lexer token */
|
|
11
25
|
function prettyToken(token) {
|
|
@@ -83,4 +97,16 @@ function tokenType(source) {
|
|
|
83
97
|
return null;
|
|
84
98
|
}
|
|
85
99
|
|
|
86
|
-
|
|
100
|
+
exports.createScalarToken = cstScalar.createScalarToken;
|
|
101
|
+
exports.resolveAsScalar = cstScalar.resolveAsScalar;
|
|
102
|
+
exports.setScalarValue = cstScalar.setScalarValue;
|
|
103
|
+
exports.stringify = cstStringify.stringify;
|
|
104
|
+
exports.visit = cstVisit.visit;
|
|
105
|
+
exports.BOM = BOM;
|
|
106
|
+
exports.DOCUMENT = DOCUMENT;
|
|
107
|
+
exports.FLOW_END = FLOW_END;
|
|
108
|
+
exports.SCALAR = SCALAR;
|
|
109
|
+
exports.isCollection = isCollection;
|
|
110
|
+
exports.isScalar = isScalar;
|
|
111
|
+
exports.prettyToken = prettyToken;
|
|
112
|
+
exports.tokenType = tokenType;
|
package/dist/parse/lexer.d.ts
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* - `\u{FEFF}` (Byte order mark): Emitted separately outside documents
|
|
15
15
|
*/
|
|
16
16
|
export declare class Lexer {
|
|
17
|
-
private push;
|
|
18
17
|
/**
|
|
19
18
|
* Flag indicating whether the end of the current buffer marks the end of
|
|
20
19
|
* all input
|
|
@@ -48,25 +47,19 @@ export declare class Lexer {
|
|
|
48
47
|
private indentNext;
|
|
49
48
|
/** Indentation level of the current line. */
|
|
50
49
|
private indentValue;
|
|
50
|
+
/** Position of the next \n character. */
|
|
51
|
+
private lineEndPos;
|
|
51
52
|
/** Stores the state of the lexer if reaching the end of incpomplete input */
|
|
52
53
|
private next;
|
|
53
54
|
/** A pointer to `buffer`; the current position of the lexer. */
|
|
54
55
|
private pos;
|
|
55
56
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
57
|
+
* Generate YAML tokens from the `source` string. If `incomplete`,
|
|
58
|
+
* a part of the last line may be left as a buffer for the next call.
|
|
58
59
|
*
|
|
59
|
-
* @
|
|
60
|
+
* @returns A generator of lexical tokens
|
|
60
61
|
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Read YAML tokens from the `source` string, calling the callback
|
|
64
|
-
* defined in the constructor for each one. If `incomplete`, a part
|
|
65
|
-
* of the last line may be left as a buffer for the next call.
|
|
66
|
-
*
|
|
67
|
-
* @public
|
|
68
|
-
*/
|
|
69
|
-
lex(source: string, incomplete: boolean): void;
|
|
62
|
+
lex(source: string, incomplete?: boolean): Generator<string, void, unknown>;
|
|
70
63
|
private atLineEnd;
|
|
71
64
|
private charAt;
|
|
72
65
|
private continueScalar;
|
|
@@ -87,7 +80,7 @@ export declare class Lexer {
|
|
|
87
80
|
private pushCount;
|
|
88
81
|
private pushToIndex;
|
|
89
82
|
private pushIndicators;
|
|
90
|
-
private
|
|
83
|
+
private pushTag;
|
|
91
84
|
private pushNewline;
|
|
92
85
|
private pushSpaces;
|
|
93
86
|
private pushUntil;
|