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
|
@@ -7,30 +7,36 @@ var resolveEnd = require('./resolve-end.js');
|
|
|
7
7
|
var utilEmptyScalarPosition = require('./util-empty-scalar-position.js');
|
|
8
8
|
|
|
9
9
|
const CN = { composeNode, composeEmptyNode };
|
|
10
|
-
function composeNode(
|
|
11
|
-
const { spaceBefore, comment, anchor,
|
|
10
|
+
function composeNode(ctx, token, props, onError) {
|
|
11
|
+
const { spaceBefore, comment, anchor, tag } = props;
|
|
12
12
|
let node;
|
|
13
13
|
switch (token.type) {
|
|
14
14
|
case 'alias':
|
|
15
|
-
node = composeAlias(
|
|
16
|
-
if (anchor ||
|
|
17
|
-
onError(token
|
|
15
|
+
node = composeAlias(ctx, token, onError);
|
|
16
|
+
if (anchor || tag)
|
|
17
|
+
onError(token, 'ALIAS_PROPS', 'An alias node must not specify any properties');
|
|
18
18
|
break;
|
|
19
19
|
case 'scalar':
|
|
20
20
|
case 'single-quoted-scalar':
|
|
21
21
|
case 'double-quoted-scalar':
|
|
22
22
|
case 'block-scalar':
|
|
23
|
-
node = composeScalar.composeScalar(
|
|
23
|
+
node = composeScalar.composeScalar(ctx, token, tag, onError);
|
|
24
|
+
if (anchor)
|
|
25
|
+
node.anchor = anchor.source.substring(1);
|
|
24
26
|
break;
|
|
25
27
|
case 'block-map':
|
|
26
28
|
case 'block-seq':
|
|
27
29
|
case 'flow-collection':
|
|
28
|
-
node = composeCollection.composeCollection(CN,
|
|
30
|
+
node = composeCollection.composeCollection(CN, ctx, token, tag, onError);
|
|
31
|
+
if (anchor)
|
|
32
|
+
node.anchor = anchor.source.substring(1);
|
|
29
33
|
break;
|
|
30
34
|
default:
|
|
31
35
|
console.log(token);
|
|
32
36
|
throw new Error(`Unsupporten token type: ${token.type}`);
|
|
33
37
|
}
|
|
38
|
+
if (anchor && node.anchor === '')
|
|
39
|
+
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
34
40
|
if (spaceBefore)
|
|
35
41
|
node.spaceBefore = true;
|
|
36
42
|
if (comment) {
|
|
@@ -41,28 +47,32 @@ function composeNode(doc, token, props, onError) {
|
|
|
41
47
|
}
|
|
42
48
|
return node;
|
|
43
49
|
}
|
|
44
|
-
function composeEmptyNode(
|
|
50
|
+
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag }, onError) {
|
|
45
51
|
const token = {
|
|
46
52
|
type: 'scalar',
|
|
47
53
|
offset: utilEmptyScalarPosition.emptyScalarPosition(offset, before, pos),
|
|
48
54
|
indent: -1,
|
|
49
55
|
source: ''
|
|
50
56
|
};
|
|
51
|
-
const node = composeScalar.composeScalar(
|
|
57
|
+
const node = composeScalar.composeScalar(ctx, token, tag, onError);
|
|
58
|
+
if (anchor) {
|
|
59
|
+
node.anchor = anchor.source.substring(1);
|
|
60
|
+
if (node.anchor === '')
|
|
61
|
+
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
62
|
+
}
|
|
52
63
|
if (spaceBefore)
|
|
53
64
|
node.spaceBefore = true;
|
|
54
65
|
if (comment)
|
|
55
66
|
node.comment = comment;
|
|
56
67
|
return node;
|
|
57
68
|
}
|
|
58
|
-
function composeAlias(
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
alias.range = [offset, re.offset];
|
|
69
|
+
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
70
|
+
const alias = new Alias.Alias(source.substring(1));
|
|
71
|
+
if (alias.source === '')
|
|
72
|
+
onError(offset, 'BAD_ALIAS', 'Alias cannot be an empty string');
|
|
73
|
+
const valueEnd = offset + source.length;
|
|
74
|
+
const re = resolveEnd.resolveEnd(end, valueEnd, options.strict, onError);
|
|
75
|
+
alias.range = [offset, valueEnd, re.offset];
|
|
66
76
|
if (re.comment)
|
|
67
77
|
alias.comment = re.comment;
|
|
68
78
|
return alias;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Document } from '../doc/Document.js';
|
|
2
1
|
import { Scalar } from '../nodes/Scalar.js';
|
|
3
|
-
import type { BlockScalar, FlowScalar } from '../parse/
|
|
4
|
-
|
|
2
|
+
import type { BlockScalar, FlowScalar, SourceToken } from '../parse/cst.js';
|
|
3
|
+
import type { ComposeContext } from './compose-node.js';
|
|
4
|
+
import type { ComposeErrorHandler } from './composer.js';
|
|
5
|
+
export declare function composeScalar(ctx: ComposeContext, token: FlowScalar | BlockScalar, tagToken: SourceToken | null, onError: ComposeErrorHandler): Scalar.Parsed;
|
|
@@ -5,44 +5,42 @@ var Scalar = require('../nodes/Scalar.js');
|
|
|
5
5
|
var resolveBlockScalar = require('./resolve-block-scalar.js');
|
|
6
6
|
var resolveFlowScalar = require('./resolve-flow-scalar.js');
|
|
7
7
|
|
|
8
|
-
function composeScalar(
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
function composeScalar(ctx, token, tagToken, onError) {
|
|
9
|
+
const { value, type, comment, range } = token.type === 'block-scalar'
|
|
10
|
+
? resolveBlockScalar.resolveBlockScalar(token, ctx.options.strict, onError)
|
|
11
|
+
: resolveFlowScalar.resolveFlowScalar(token, ctx.options.strict, onError);
|
|
12
|
+
const tagName = tagToken
|
|
13
|
+
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
|
|
14
|
+
: null;
|
|
15
|
+
const tag = tagToken && tagName
|
|
16
|
+
? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError)
|
|
17
|
+
: findScalarTagByTest(ctx.schema, value, token.type === 'scalar');
|
|
16
18
|
let scalar;
|
|
17
19
|
try {
|
|
18
|
-
const res = tag
|
|
19
|
-
? tag.resolve(value, msg => onError(offset, msg), doc.options)
|
|
20
|
-
: value;
|
|
20
|
+
const res = tag.resolve(value, msg => onError(tagToken || token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
21
21
|
scalar = Node.isScalar(res) ? res : new Scalar.Scalar(res);
|
|
22
22
|
}
|
|
23
23
|
catch (error) {
|
|
24
|
-
|
|
24
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
25
|
+
onError(tagToken || token, 'TAG_RESOLVE_FAILED', msg);
|
|
25
26
|
scalar = new Scalar.Scalar(value);
|
|
26
27
|
}
|
|
27
|
-
scalar.range =
|
|
28
|
+
scalar.range = range;
|
|
28
29
|
scalar.source = value;
|
|
29
30
|
if (type)
|
|
30
31
|
scalar.type = type;
|
|
31
32
|
if (tagName)
|
|
32
33
|
scalar.tag = tagName;
|
|
33
|
-
if (tag
|
|
34
|
+
if (tag.format)
|
|
34
35
|
scalar.format = tag.format;
|
|
35
36
|
if (comment)
|
|
36
37
|
scalar.comment = comment;
|
|
37
|
-
if (anchor)
|
|
38
|
-
doc.anchors.setAnchor(scalar, anchor);
|
|
39
38
|
return scalar;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
function findScalarTagByName(schema, value, tagName, onError) {
|
|
40
|
+
function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
43
41
|
var _a;
|
|
44
42
|
if (tagName === '!')
|
|
45
|
-
return
|
|
43
|
+
return schema[Node.SCALAR]; // non-specific tag
|
|
46
44
|
const matchWithTest = [];
|
|
47
45
|
for (const tag of schema.tags) {
|
|
48
46
|
if (!tag.collection && tag.tag === tagName) {
|
|
@@ -62,8 +60,8 @@ function findScalarTagByName(schema, value, tagName, onError) {
|
|
|
62
60
|
schema.tags.push(Object.assign({}, kt, { default: false, test: undefined }));
|
|
63
61
|
return kt;
|
|
64
62
|
}
|
|
65
|
-
onError(
|
|
66
|
-
return
|
|
63
|
+
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
|
|
64
|
+
return schema[Node.SCALAR];
|
|
67
65
|
}
|
|
68
66
|
function findScalarTagByTest(schema, value, apply) {
|
|
69
67
|
var _a;
|
|
@@ -73,7 +71,7 @@ function findScalarTagByTest(schema, value, apply) {
|
|
|
73
71
|
return tag;
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
|
-
return
|
|
74
|
+
return schema[Node.SCALAR];
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
exports.composeScalar = composeScalar;
|
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
import { Directives } from '../doc/directives.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import { Document } from '../doc/Document.js';
|
|
3
|
+
import { ErrorCode, YAMLParseError, YAMLWarning } from '../errors.js';
|
|
4
|
+
import { Range } from '../nodes/Node.js';
|
|
5
|
+
import { DocumentOptions, ParseOptions, SchemaOptions } from '../options.js';
|
|
6
|
+
import type { Token } from '../parse/cst.js';
|
|
7
|
+
declare type ErrorSource = number | [number, number] | Range | {
|
|
8
|
+
offset: number;
|
|
9
|
+
source?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type ComposeErrorHandler = (source: ErrorSource, code: ErrorCode, message: string, warning?: boolean) => void;
|
|
5
12
|
/**
|
|
6
13
|
* Compose a stream of CST nodes into a stream of YAML Documents.
|
|
7
14
|
*
|
|
8
15
|
* ```ts
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* const
|
|
12
|
-
* const
|
|
13
|
-
*
|
|
14
|
-
* composer.end()
|
|
16
|
+
* import { Composer, Parser } from 'yaml'
|
|
17
|
+
*
|
|
18
|
+
* const src: string = ...
|
|
19
|
+
* const tokens = new Parser().parse(src)
|
|
20
|
+
* const docs = new Composer().compose(tokens)
|
|
15
21
|
* ```
|
|
16
22
|
*/
|
|
17
23
|
export declare class Composer {
|
|
18
24
|
private directives;
|
|
19
25
|
private doc;
|
|
20
|
-
private onDocument;
|
|
21
26
|
private options;
|
|
22
27
|
private atDirectives;
|
|
23
28
|
private prelude;
|
|
24
29
|
private errors;
|
|
25
30
|
private warnings;
|
|
26
|
-
constructor(
|
|
31
|
+
constructor(options?: ParseOptions & DocumentOptions & SchemaOptions);
|
|
27
32
|
private onError;
|
|
28
33
|
private decorate;
|
|
29
34
|
/**
|
|
@@ -38,20 +43,20 @@ export declare class Composer {
|
|
|
38
43
|
warnings: YAMLWarning[];
|
|
39
44
|
};
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
46
|
+
* Compose tokens into documents.
|
|
47
|
+
*
|
|
48
|
+
* @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.
|
|
49
|
+
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
43
50
|
*/
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
|
|
51
|
+
compose(tokens: Iterable<Token>, forceDoc?: boolean, endOffset?: number): Generator<Document.Parsed<import("../nodes/Node.js").ParsedNode>, void, unknown>;
|
|
52
|
+
/** Advance the composer by one CST token. */
|
|
53
|
+
next(token: Token): Generator<Document.Parsed<import("../nodes/Node.js").ParsedNode>, void, unknown>;
|
|
47
54
|
/**
|
|
48
|
-
* Call at end of input to
|
|
55
|
+
* Call at end of input to yield any remaining document.
|
|
49
56
|
*
|
|
50
|
-
* @param forceDoc - If the stream contains no document, still emit a final
|
|
51
|
-
*
|
|
52
|
-
* to a subsequent document.
|
|
53
|
-
* @param offset - Should be set if `forceDoc` is also set, to set the
|
|
54
|
-
* document range end and to indicate errors correctly.
|
|
57
|
+
* @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.
|
|
58
|
+
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
55
59
|
*/
|
|
56
|
-
end(forceDoc
|
|
60
|
+
end(forceDoc?: boolean, endOffset?: number): Generator<Document.Parsed<import("../nodes/Node.js").ParsedNode>, void, unknown>;
|
|
57
61
|
}
|
|
62
|
+
export {};
|
package/dist/compose/composer.js
CHANGED
|
@@ -8,7 +8,16 @@ var options = require('../options.js');
|
|
|
8
8
|
var composeDoc = require('./compose-doc.js');
|
|
9
9
|
var resolveEnd = require('./resolve-end.js');
|
|
10
10
|
|
|
11
|
+
function getErrorPos(src) {
|
|
12
|
+
if (typeof src === 'number')
|
|
13
|
+
return [src, src + 1];
|
|
14
|
+
if (Array.isArray(src))
|
|
15
|
+
return src.length === 2 ? src : [src[0], src[1]];
|
|
16
|
+
const { offset, source } = src;
|
|
17
|
+
return [offset, offset + (typeof source === 'string' ? source.length : 1)];
|
|
18
|
+
}
|
|
11
19
|
function parsePrelude(prelude) {
|
|
20
|
+
var _a;
|
|
12
21
|
let comment = '';
|
|
13
22
|
let atComment = false;
|
|
14
23
|
let afterEmptyLine = false;
|
|
@@ -18,12 +27,12 @@ function parsePrelude(prelude) {
|
|
|
18
27
|
case '#':
|
|
19
28
|
comment +=
|
|
20
29
|
(comment === '' ? '' : afterEmptyLine ? '\n\n' : '\n') +
|
|
21
|
-
source.substring(1);
|
|
30
|
+
(source.substring(1) || ' ');
|
|
22
31
|
atComment = true;
|
|
23
32
|
afterEmptyLine = false;
|
|
24
33
|
break;
|
|
25
34
|
case '%':
|
|
26
|
-
if (prelude[i + 1][0] !== '#')
|
|
35
|
+
if (((_a = prelude[i + 1]) === null || _a === void 0 ? void 0 : _a[0]) !== '#')
|
|
27
36
|
i += 1;
|
|
28
37
|
atComment = false;
|
|
29
38
|
break;
|
|
@@ -40,90 +49,30 @@ function parsePrelude(prelude) {
|
|
|
40
49
|
* Compose a stream of CST nodes into a stream of YAML Documents.
|
|
41
50
|
*
|
|
42
51
|
* ```ts
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* const
|
|
46
|
-
* const
|
|
47
|
-
*
|
|
48
|
-
* composer.end()
|
|
52
|
+
* import { Composer, Parser } from 'yaml'
|
|
53
|
+
*
|
|
54
|
+
* const src: string = ...
|
|
55
|
+
* const tokens = new Parser().parse(src)
|
|
56
|
+
* const docs = new Composer().compose(tokens)
|
|
49
57
|
* ```
|
|
50
58
|
*/
|
|
51
59
|
class Composer {
|
|
52
|
-
constructor(
|
|
60
|
+
constructor(options$1 = {}) {
|
|
53
61
|
this.doc = null;
|
|
54
62
|
this.atDirectives = false;
|
|
55
63
|
this.prelude = [];
|
|
56
64
|
this.errors = [];
|
|
57
65
|
this.warnings = [];
|
|
58
|
-
this.onError = (
|
|
66
|
+
this.onError = (source, code, message, warning) => {
|
|
67
|
+
const pos = getErrorPos(source);
|
|
59
68
|
if (warning)
|
|
60
|
-
this.warnings.push(new errors.YAMLWarning(
|
|
69
|
+
this.warnings.push(new errors.YAMLWarning(pos, code, message));
|
|
61
70
|
else
|
|
62
|
-
this.errors.push(new errors.YAMLParseError(
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Advance the composed by one CST token. Bound to the Composer
|
|
66
|
-
* instance, so may be used directly as a callback function.
|
|
67
|
-
*/
|
|
68
|
-
this.next = (token) => {
|
|
69
|
-
if (process.env.LOG_STREAM)
|
|
70
|
-
console.dir(token, { depth: null });
|
|
71
|
-
switch (token.type) {
|
|
72
|
-
case 'directive':
|
|
73
|
-
this.directives.add(token.source, this.onError);
|
|
74
|
-
this.prelude.push(token.source);
|
|
75
|
-
this.atDirectives = true;
|
|
76
|
-
break;
|
|
77
|
-
case 'document': {
|
|
78
|
-
const doc = composeDoc.composeDoc(this.options, this.directives, token, this.onError);
|
|
79
|
-
this.decorate(doc, false);
|
|
80
|
-
if (this.doc)
|
|
81
|
-
this.onDocument(this.doc);
|
|
82
|
-
this.doc = doc;
|
|
83
|
-
this.atDirectives = false;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
case 'byte-order-mark':
|
|
87
|
-
case 'space':
|
|
88
|
-
break;
|
|
89
|
-
case 'comment':
|
|
90
|
-
case 'newline':
|
|
91
|
-
this.prelude.push(token.source);
|
|
92
|
-
break;
|
|
93
|
-
case 'error': {
|
|
94
|
-
const msg = token.source
|
|
95
|
-
? `${token.message}: ${JSON.stringify(token.source)}`
|
|
96
|
-
: token.message;
|
|
97
|
-
const error = new errors.YAMLParseError(-1, msg);
|
|
98
|
-
if (this.atDirectives || !this.doc)
|
|
99
|
-
this.errors.push(error);
|
|
100
|
-
else
|
|
101
|
-
this.doc.errors.push(error);
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
case 'doc-end': {
|
|
105
|
-
if (!this.doc) {
|
|
106
|
-
const msg = 'Unexpected doc-end without preceding document';
|
|
107
|
-
this.errors.push(new errors.YAMLParseError(token.offset, msg));
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
const end = resolveEnd.resolveEnd(token.end, token.offset + token.source.length, this.doc.options.strict, this.onError);
|
|
111
|
-
this.decorate(this.doc, true);
|
|
112
|
-
if (end.comment) {
|
|
113
|
-
const dc = this.doc.comment;
|
|
114
|
-
this.doc.comment = dc ? `${dc}\n${end.comment}` : end.comment;
|
|
115
|
-
}
|
|
116
|
-
this.doc.range[1] = end.offset;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
default:
|
|
120
|
-
this.errors.push(new errors.YAMLParseError(-1, `Unsupported token ${token.type}`));
|
|
121
|
-
}
|
|
71
|
+
this.errors.push(new errors.YAMLParseError(pos, code, message));
|
|
122
72
|
};
|
|
123
73
|
this.directives = new directives.Directives({
|
|
124
|
-
version:
|
|
74
|
+
version: options$1.version || options.defaultOptions.version
|
|
125
75
|
});
|
|
126
|
-
this.onDocument = onDocument;
|
|
127
76
|
this.options = options$1;
|
|
128
77
|
}
|
|
129
78
|
decorate(doc, afterDoc) {
|
|
@@ -138,7 +87,9 @@ class Composer {
|
|
|
138
87
|
doc.commentBefore = comment;
|
|
139
88
|
}
|
|
140
89
|
else if (Node.isCollection(dc) && !dc.flow && dc.items.length > 0) {
|
|
141
|
-
|
|
90
|
+
let it = dc.items[0];
|
|
91
|
+
if (Node.isPair(it))
|
|
92
|
+
it = it.key;
|
|
142
93
|
const cb = it.commentBefore;
|
|
143
94
|
it.commentBefore = cb ? `${comment}\n${cb}` : comment;
|
|
144
95
|
}
|
|
@@ -172,20 +123,99 @@ class Composer {
|
|
|
172
123
|
warnings: this.warnings
|
|
173
124
|
};
|
|
174
125
|
}
|
|
175
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Compose tokens into documents.
|
|
128
|
+
*
|
|
129
|
+
* @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.
|
|
130
|
+
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
131
|
+
*/
|
|
132
|
+
*compose(tokens, forceDoc = false, endOffset = -1) {
|
|
133
|
+
for (const token of tokens)
|
|
134
|
+
yield* this.next(token);
|
|
135
|
+
yield* this.end(forceDoc, endOffset);
|
|
136
|
+
}
|
|
137
|
+
/** Advance the composer by one CST token. */
|
|
138
|
+
*next(token) {
|
|
139
|
+
if (process.env.LOG_STREAM)
|
|
140
|
+
console.dir(token, { depth: null });
|
|
141
|
+
switch (token.type) {
|
|
142
|
+
case 'directive':
|
|
143
|
+
this.directives.add(token.source, (offset, message, warning) => {
|
|
144
|
+
const pos = getErrorPos(token);
|
|
145
|
+
pos[0] += offset;
|
|
146
|
+
this.onError(pos, 'BAD_DIRECTIVE', message, warning);
|
|
147
|
+
});
|
|
148
|
+
this.prelude.push(token.source);
|
|
149
|
+
this.atDirectives = true;
|
|
150
|
+
break;
|
|
151
|
+
case 'document': {
|
|
152
|
+
const doc = composeDoc.composeDoc(this.options, this.directives, token, this.onError);
|
|
153
|
+
if (this.atDirectives && !doc.directives.marker)
|
|
154
|
+
this.onError(token, 'MISSING_CHAR', 'Missing directives-end indicator line');
|
|
155
|
+
this.decorate(doc, false);
|
|
156
|
+
if (this.doc)
|
|
157
|
+
yield this.doc;
|
|
158
|
+
this.doc = doc;
|
|
159
|
+
this.atDirectives = false;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case 'byte-order-mark':
|
|
163
|
+
case 'space':
|
|
164
|
+
break;
|
|
165
|
+
case 'comment':
|
|
166
|
+
case 'newline':
|
|
167
|
+
this.prelude.push(token.source);
|
|
168
|
+
break;
|
|
169
|
+
case 'error': {
|
|
170
|
+
const msg = token.source
|
|
171
|
+
? `${token.message}: ${JSON.stringify(token.source)}`
|
|
172
|
+
: token.message;
|
|
173
|
+
const error = new errors.YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', msg);
|
|
174
|
+
if (this.atDirectives || !this.doc)
|
|
175
|
+
this.errors.push(error);
|
|
176
|
+
else
|
|
177
|
+
this.doc.errors.push(error);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case 'doc-end': {
|
|
181
|
+
if (!this.doc) {
|
|
182
|
+
const msg = 'Unexpected doc-end without preceding document';
|
|
183
|
+
this.errors.push(new errors.YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', msg));
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
const end = resolveEnd.resolveEnd(token.end, token.offset + token.source.length, this.doc.options.strict, this.onError);
|
|
187
|
+
this.decorate(this.doc, true);
|
|
188
|
+
if (end.comment) {
|
|
189
|
+
const dc = this.doc.comment;
|
|
190
|
+
this.doc.comment = dc ? `${dc}\n${end.comment}` : end.comment;
|
|
191
|
+
}
|
|
192
|
+
this.doc.range[2] = end.offset;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
default:
|
|
196
|
+
this.errors.push(new errors.YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', `Unsupported token ${token.type}`));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Call at end of input to yield any remaining document.
|
|
201
|
+
*
|
|
202
|
+
* @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.
|
|
203
|
+
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
204
|
+
*/
|
|
205
|
+
*end(forceDoc = false, endOffset = -1) {
|
|
176
206
|
if (this.doc) {
|
|
177
207
|
this.decorate(this.doc, true);
|
|
178
|
-
this.
|
|
208
|
+
yield this.doc;
|
|
179
209
|
this.doc = null;
|
|
180
210
|
}
|
|
181
211
|
else if (forceDoc) {
|
|
182
212
|
const opts = Object.assign({ directives: this.directives }, this.options);
|
|
183
213
|
const doc = new Document.Document(undefined, opts);
|
|
184
214
|
if (this.atDirectives)
|
|
185
|
-
this.onError(
|
|
186
|
-
doc.range = [0,
|
|
215
|
+
this.onError(endOffset, 'MISSING_CHAR', 'Missing directives-end indicator line');
|
|
216
|
+
doc.range = [0, endOffset, endOffset];
|
|
187
217
|
this.decorate(doc, false);
|
|
188
|
-
|
|
218
|
+
yield doc;
|
|
189
219
|
}
|
|
190
220
|
}
|
|
191
221
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ParsedNode } from '../nodes/Node.js';
|
|
2
2
|
import { YAMLMap } from '../nodes/YAMLMap.js';
|
|
3
|
-
import type { BlockMap } from '../parse/
|
|
4
|
-
import type { ComposeNode } from './compose-node.js';
|
|
5
|
-
|
|
3
|
+
import type { BlockMap } from '../parse/cst.js';
|
|
4
|
+
import type { ComposeContext, ComposeNode } from './compose-node.js';
|
|
5
|
+
import type { ComposeErrorHandler } from './composer.js';
|
|
6
|
+
export declare function resolveBlockMap({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bm: BlockMap, onError: ComposeErrorHandler): YAMLMap.Parsed<ParsedNode, ParsedNode | null>;
|
|
@@ -4,26 +4,31 @@ var Pair = require('../nodes/Pair.js');
|
|
|
4
4
|
var YAMLMap = require('../nodes/YAMLMap.js');
|
|
5
5
|
var resolveProps = require('./resolve-props.js');
|
|
6
6
|
var utilContainsNewline = require('./util-contains-newline.js');
|
|
7
|
+
var utilMapIncludes = require('./util-map-includes.js');
|
|
7
8
|
|
|
8
9
|
const startColMsg = 'All mapping items must start at the same column';
|
|
9
|
-
function resolveBlockMap({ composeNode, composeEmptyNode },
|
|
10
|
+
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
10
11
|
var _a;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
doc.anchors.setAnchor(map, anchor);
|
|
15
|
-
for (const { start, key, sep, value } of items) {
|
|
12
|
+
const map = new YAMLMap.YAMLMap(ctx.schema);
|
|
13
|
+
let offset = bm.offset;
|
|
14
|
+
for (const { start, key, sep, value } of bm.items) {
|
|
16
15
|
// key properties
|
|
17
|
-
const keyProps = resolveProps.resolveProps(
|
|
16
|
+
const keyProps = resolveProps.resolveProps(start, {
|
|
17
|
+
indicator: 'explicit-key-ind',
|
|
18
|
+
next: key || (sep === null || sep === void 0 ? void 0 : sep[0]),
|
|
19
|
+
offset,
|
|
20
|
+
onError,
|
|
21
|
+
startOnNewline: true
|
|
22
|
+
});
|
|
18
23
|
const implicitKey = !keyProps.found;
|
|
19
24
|
if (implicitKey) {
|
|
20
25
|
if (key) {
|
|
21
26
|
if (key.type === 'block-seq')
|
|
22
|
-
onError(offset, 'A block sequence may not be used as an implicit map key');
|
|
23
|
-
else if ('indent' in key && key.indent !== indent)
|
|
24
|
-
onError(offset, startColMsg);
|
|
27
|
+
onError(offset, 'BLOCK_AS_IMPLICIT_KEY', 'A block sequence may not be used as an implicit map key');
|
|
28
|
+
else if ('indent' in key && key.indent !== bm.indent)
|
|
29
|
+
onError(offset, 'BAD_INDENT', startColMsg);
|
|
25
30
|
}
|
|
26
|
-
if (!keyProps.anchor && !keyProps.
|
|
31
|
+
if (!keyProps.anchor && !keyProps.tag && !sep) {
|
|
27
32
|
// TODO: assert being at last item?
|
|
28
33
|
if (keyProps.comment) {
|
|
29
34
|
if (map.comment)
|
|
@@ -34,39 +39,46 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, doc, { indent, items
|
|
|
34
39
|
continue;
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
|
-
else if (((_a = keyProps.found) === null || _a === void 0 ? void 0 : _a.indent) !== indent)
|
|
38
|
-
onError(offset, startColMsg);
|
|
39
|
-
offset += keyProps.length;
|
|
42
|
+
else if (((_a = keyProps.found) === null || _a === void 0 ? void 0 : _a.indent) !== bm.indent)
|
|
43
|
+
onError(offset, 'BAD_INDENT', startColMsg);
|
|
40
44
|
if (implicitKey && utilContainsNewline.containsNewline(key))
|
|
41
|
-
onError(
|
|
45
|
+
onError(key, // checked by containsNewline()
|
|
46
|
+
'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
|
|
42
47
|
// key value
|
|
43
|
-
const keyStart =
|
|
48
|
+
const keyStart = keyProps.end;
|
|
44
49
|
const keyNode = key
|
|
45
|
-
? composeNode(
|
|
46
|
-
: composeEmptyNode(
|
|
47
|
-
|
|
50
|
+
? composeNode(ctx, key, keyProps, onError)
|
|
51
|
+
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
|
|
52
|
+
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
53
|
+
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
48
54
|
// value properties
|
|
49
|
-
const valueProps = resolveProps.resolveProps(
|
|
50
|
-
|
|
55
|
+
const valueProps = resolveProps.resolveProps(sep || [], {
|
|
56
|
+
indicator: 'map-value-ind',
|
|
57
|
+
next: value,
|
|
58
|
+
offset: keyNode.range[2],
|
|
59
|
+
onError,
|
|
60
|
+
startOnNewline: !key || key.type === 'block-scalar'
|
|
61
|
+
});
|
|
62
|
+
offset = valueProps.end;
|
|
51
63
|
if (valueProps.found) {
|
|
52
64
|
if (implicitKey) {
|
|
53
65
|
if ((value === null || value === void 0 ? void 0 : value.type) === 'block-map' && !valueProps.hasNewline)
|
|
54
|
-
onError(offset, 'Nested mappings are not allowed in compact mappings');
|
|
55
|
-
if (
|
|
66
|
+
onError(offset, 'BLOCK_AS_IMPLICIT_KEY', 'Nested mappings are not allowed in compact mappings');
|
|
67
|
+
if (ctx.options.strict &&
|
|
56
68
|
keyProps.start < valueProps.found.offset - 1024)
|
|
57
|
-
onError(
|
|
69
|
+
onError(keyNode.range, 'KEY_OVER_1024_CHARS', 'The : indicator must be at most 1024 chars after the start of an implicit block mapping key');
|
|
58
70
|
}
|
|
59
71
|
// value value
|
|
60
72
|
const valueNode = value
|
|
61
|
-
? composeNode(
|
|
62
|
-
: composeEmptyNode(
|
|
63
|
-
offset = valueNode.range[
|
|
73
|
+
? composeNode(ctx, value, valueProps, onError)
|
|
74
|
+
: composeEmptyNode(ctx, offset, sep, null, valueProps, onError);
|
|
75
|
+
offset = valueNode.range[2];
|
|
64
76
|
map.items.push(new Pair.Pair(keyNode, valueNode));
|
|
65
77
|
}
|
|
66
78
|
else {
|
|
67
79
|
// key with no value
|
|
68
80
|
if (implicitKey)
|
|
69
|
-
onError(
|
|
81
|
+
onError(keyNode.range, 'MISSING_CHAR', 'Implicit map keys need to be followed by map values');
|
|
70
82
|
if (valueProps.comment) {
|
|
71
83
|
if (keyNode.comment)
|
|
72
84
|
keyNode.comment += '\n' + valueProps.comment;
|
|
@@ -76,7 +88,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, doc, { indent, items
|
|
|
76
88
|
map.items.push(new Pair.Pair(keyNode));
|
|
77
89
|
}
|
|
78
90
|
}
|
|
79
|
-
map.range = [
|
|
91
|
+
map.range = [bm.offset, offset, offset];
|
|
80
92
|
return map;
|
|
81
93
|
}
|
|
82
94
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { Range } from '../nodes/Node.js';
|
|
1
2
|
import { Scalar } from '../nodes/Scalar.js';
|
|
2
|
-
import type { BlockScalar } from '../parse/
|
|
3
|
-
|
|
3
|
+
import type { BlockScalar } from '../parse/cst.js';
|
|
4
|
+
import type { ComposeErrorHandler } from './composer.js';
|
|
5
|
+
export declare function resolveBlockScalar(scalar: BlockScalar, strict: boolean, onError: ComposeErrorHandler): {
|
|
4
6
|
value: string;
|
|
5
7
|
type: Scalar.BLOCK_FOLDED | Scalar.BLOCK_LITERAL | null;
|
|
6
8
|
comment: string;
|
|
7
|
-
|
|
9
|
+
range: Range;
|
|
8
10
|
};
|