step-node-agent 3.25.4 → 3.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AgentConf.yaml +13 -0
- package/api/controllers/controller.js +4 -0
- package/api/routes/routes.js +1 -0
- package/node_modules/aws4/aws4.js +1 -1
- package/node_modules/aws4/package.json +2 -2
- package/node_modules/body-parser/HISTORY.md +7 -0
- package/node_modules/body-parser/README.md +11 -0
- package/node_modules/body-parser/lib/types/urlencoded.js +30 -7
- package/node_modules/body-parser/package.json +2 -2
- package/node_modules/encodeurl/README.md +19 -38
- package/node_modules/encodeurl/index.js +1 -1
- package/node_modules/encodeurl/package.json +7 -7
- package/node_modules/express/History.md +27 -0
- package/node_modules/express/Readme.md +100 -6
- package/node_modules/express/lib/response.js +11 -10
- package/node_modules/express/package.json +11 -11
- package/node_modules/finalhandler/HISTORY.md +15 -0
- package/node_modules/finalhandler/README.md +2 -2
- package/node_modules/finalhandler/index.js +7 -2
- package/node_modules/finalhandler/package.json +8 -7
- package/node_modules/get-fqdn/LICENSE +21 -0
- package/node_modules/get-fqdn/README.md +83 -0
- package/node_modules/get-fqdn/index.js +17 -0
- package/node_modules/get-fqdn/package.json +73 -0
- package/node_modules/is-core-module/CHANGELOG.md +10 -0
- package/node_modules/is-core-module/core.json +2 -2
- package/node_modules/is-core-module/package.json +4 -4
- package/node_modules/is-core-module/test/index.js +17 -1
- package/node_modules/merge-descriptors/README.md +4 -3
- package/node_modules/merge-descriptors/index.js +3 -3
- package/node_modules/merge-descriptors/package.json +14 -7
- package/node_modules/path-to-regexp/index.js +57 -40
- package/node_modules/path-to-regexp/package.json +2 -2
- package/node_modules/qs/.editorconfig +3 -0
- package/node_modules/qs/.eslintrc +2 -2
- package/node_modules/qs/CHANGELOG.md +59 -5
- package/node_modules/qs/README.md +133 -49
- package/node_modules/qs/dist/qs.js +56 -2020
- package/node_modules/qs/lib/parse.js +46 -13
- package/node_modules/qs/lib/stringify.js +53 -28
- package/node_modules/qs/lib/utils.js +47 -34
- package/node_modules/qs/package.json +26 -12
- package/node_modules/qs/test/empty-keys-cases.js +267 -0
- package/node_modules/qs/test/parse.js +347 -32
- package/node_modules/qs/test/stringify.js +436 -47
- package/node_modules/send/HISTORY.md +5 -0
- package/node_modules/send/index.js +1 -2
- package/node_modules/send/node_modules/encodeurl/LICENSE +22 -0
- package/node_modules/send/node_modules/encodeurl/README.md +128 -0
- package/node_modules/send/node_modules/encodeurl/index.js +60 -0
- package/node_modules/send/node_modules/encodeurl/package.json +40 -0
- package/node_modules/send/package.json +1 -1
- package/node_modules/serve-static/HISTORY.md +16 -0
- package/node_modules/serve-static/index.js +1 -2
- package/node_modules/serve-static/package.json +3 -3
- package/node_modules/yaml/LICENSE +13 -0
- package/node_modules/yaml/README.md +155 -0
- package/node_modules/yaml/bin.mjs +11 -0
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +42 -0
- package/node_modules/yaml/browser/dist/compose/compose-node.js +92 -0
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +80 -0
- package/node_modules/yaml/browser/dist/compose/composer.js +217 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +113 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +47 -0
- package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +203 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +223 -0
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +148 -0
- package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +27 -0
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +17 -0
- package/node_modules/yaml/browser/dist/doc/Document.js +334 -0
- package/node_modules/yaml/browser/dist/doc/anchors.js +72 -0
- package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
- package/node_modules/yaml/browser/dist/doc/createNode.js +89 -0
- package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
- package/node_modules/yaml/browser/dist/errors.js +57 -0
- package/node_modules/yaml/browser/dist/index.js +17 -0
- package/node_modules/yaml/browser/dist/log.js +14 -0
- package/node_modules/yaml/browser/dist/nodes/Alias.js +101 -0
- package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
- package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
- package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +104 -0
- package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
- package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
- package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
- package/node_modules/yaml/browser/dist/parse/lexer.js +717 -0
- package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
- package/node_modules/yaml/browser/dist/parse/parser.js +954 -0
- package/node_modules/yaml/browser/dist/public-api.js +99 -0
- package/node_modules/yaml/browser/dist/schema/Schema.js +38 -0
- package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
- package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
- package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
- package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
- package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
- package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
- package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
- package/node_modules/yaml/browser/dist/schema/tags.js +83 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +66 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +37 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
- package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
- package/node_modules/yaml/browser/dist/stringify/stringify.js +124 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +143 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +24 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +328 -0
- package/node_modules/yaml/browser/dist/util.js +11 -0
- package/node_modules/yaml/browser/dist/visit.js +233 -0
- package/node_modules/yaml/browser/index.js +5 -0
- package/node_modules/yaml/browser/package.json +3 -0
- package/node_modules/yaml/dist/cli.d.ts +8 -0
- package/node_modules/yaml/dist/cli.mjs +199 -0
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
- package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
- package/node_modules/yaml/dist/compose/compose-doc.js +44 -0
- package/node_modules/yaml/dist/compose/compose-node.d.ts +28 -0
- package/node_modules/yaml/dist/compose/compose-node.js +95 -0
- package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
- package/node_modules/yaml/dist/compose/compose-scalar.js +82 -0
- package/node_modules/yaml/dist/compose/composer.d.ts +62 -0
- package/node_modules/yaml/dist/compose/composer.js +221 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.js +115 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +49 -0
- package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +205 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +225 -0
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
- package/node_modules/yaml/dist/compose/resolve-props.js +150 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +29 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
- package/node_modules/yaml/dist/compose/util-map-includes.js +19 -0
- package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
- package/node_modules/yaml/dist/doc/Document.js +336 -0
- package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
- package/node_modules/yaml/dist/doc/anchors.js +77 -0
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
- package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
- package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
- package/node_modules/yaml/dist/doc/createNode.js +91 -0
- package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
- package/node_modules/yaml/dist/doc/directives.js +178 -0
- package/node_modules/yaml/dist/errors.d.ts +21 -0
- package/node_modules/yaml/dist/errors.js +62 -0
- package/node_modules/yaml/dist/index.d.ts +22 -0
- package/node_modules/yaml/dist/index.js +50 -0
- package/node_modules/yaml/dist/log.d.ts +3 -0
- package/node_modules/yaml/dist/log.js +17 -0
- package/node_modules/yaml/dist/nodes/Alias.d.ts +28 -0
- package/node_modules/yaml/dist/nodes/Alias.js +103 -0
- package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
- package/node_modules/yaml/dist/nodes/Collection.js +151 -0
- package/node_modules/yaml/dist/nodes/Node.d.ts +47 -0
- package/node_modules/yaml/dist/nodes/Node.js +40 -0
- package/node_modules/yaml/dist/nodes/Pair.d.ts +21 -0
- package/node_modules/yaml/dist/nodes/Pair.js +39 -0
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +42 -0
- package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +106 -0
- package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
- package/node_modules/yaml/dist/nodes/identity.js +53 -0
- package/node_modules/yaml/dist/nodes/toJS.d.ts +27 -0
- package/node_modules/yaml/dist/nodes/toJS.js +39 -0
- package/node_modules/yaml/dist/options.d.ts +338 -0
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
- package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
- package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
- package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
- package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
- package/node_modules/yaml/dist/parse/cst.d.ts +108 -0
- package/node_modules/yaml/dist/parse/cst.js +112 -0
- package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
- package/node_modules/yaml/dist/parse/lexer.js +719 -0
- package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
- package/node_modules/yaml/dist/parse/line-counter.js +41 -0
- package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
- package/node_modules/yaml/dist/parse/parser.js +958 -0
- package/node_modules/yaml/dist/public-api.d.ts +43 -0
- package/node_modules/yaml/dist/public-api.js +104 -0
- package/node_modules/yaml/dist/schema/Schema.d.ts +18 -0
- package/node_modules/yaml/dist/schema/Schema.js +40 -0
- package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/map.js +19 -0
- package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
- package/node_modules/yaml/dist/schema/common/null.js +17 -0
- package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/seq.js +19 -0
- package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/string.js +16 -0
- package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/bool.js +21 -0
- package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/float.js +47 -0
- package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/int.js +42 -0
- package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/core/schema.js +25 -0
- package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
- package/node_modules/yaml/dist/schema/json/schema.js +64 -0
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +40 -0
- package/node_modules/yaml/dist/schema/tags.js +86 -0
- package/node_modules/yaml/dist/schema/types.d.ts +90 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +68 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +28 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +39 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
- package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
- package/node_modules/yaml/dist/stringify/stringify.js +127 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +145 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.js +26 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
- package/node_modules/yaml/dist/stringify/stringifyString.js +330 -0
- package/node_modules/yaml/dist/test-events.d.ts +4 -0
- package/node_modules/yaml/dist/test-events.js +134 -0
- package/node_modules/yaml/dist/util.d.ts +12 -0
- package/node_modules/yaml/dist/util.js +28 -0
- package/node_modules/yaml/dist/visit.d.ts +102 -0
- package/node_modules/yaml/dist/visit.js +236 -0
- package/node_modules/yaml/package.json +96 -0
- package/node_modules/yaml/util.js +2 -0
- package/package.json +7 -3
- package/server.js +50 -23
- package/node_modules/path-to-regexp/History.md +0 -36
- /package/node_modules/{encodeurl → send/node_modules/encodeurl}/HISTORY.md +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Alias } from '../nodes/Alias.js';
|
|
2
|
+
import { composeCollection } from './compose-collection.js';
|
|
3
|
+
import { composeScalar } from './compose-scalar.js';
|
|
4
|
+
import { resolveEnd } from './resolve-end.js';
|
|
5
|
+
import { emptyScalarPosition } from './util-empty-scalar-position.js';
|
|
6
|
+
|
|
7
|
+
const CN = { composeNode, composeEmptyNode };
|
|
8
|
+
function composeNode(ctx, token, props, onError) {
|
|
9
|
+
const { spaceBefore, comment, anchor, tag } = props;
|
|
10
|
+
let node;
|
|
11
|
+
let isSrcToken = true;
|
|
12
|
+
switch (token.type) {
|
|
13
|
+
case 'alias':
|
|
14
|
+
node = composeAlias(ctx, token, onError);
|
|
15
|
+
if (anchor || tag)
|
|
16
|
+
onError(token, 'ALIAS_PROPS', 'An alias node must not specify any properties');
|
|
17
|
+
break;
|
|
18
|
+
case 'scalar':
|
|
19
|
+
case 'single-quoted-scalar':
|
|
20
|
+
case 'double-quoted-scalar':
|
|
21
|
+
case 'block-scalar':
|
|
22
|
+
node = composeScalar(ctx, token, tag, onError);
|
|
23
|
+
if (anchor)
|
|
24
|
+
node.anchor = anchor.source.substring(1);
|
|
25
|
+
break;
|
|
26
|
+
case 'block-map':
|
|
27
|
+
case 'block-seq':
|
|
28
|
+
case 'flow-collection':
|
|
29
|
+
node = composeCollection(CN, ctx, token, props, onError);
|
|
30
|
+
if (anchor)
|
|
31
|
+
node.anchor = anchor.source.substring(1);
|
|
32
|
+
break;
|
|
33
|
+
default: {
|
|
34
|
+
const message = token.type === 'error'
|
|
35
|
+
? token.message
|
|
36
|
+
: `Unsupported token (type: ${token.type})`;
|
|
37
|
+
onError(token, 'UNEXPECTED_TOKEN', message);
|
|
38
|
+
node = composeEmptyNode(ctx, token.offset, undefined, null, props, onError);
|
|
39
|
+
isSrcToken = false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (anchor && node.anchor === '')
|
|
43
|
+
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
44
|
+
if (spaceBefore)
|
|
45
|
+
node.spaceBefore = true;
|
|
46
|
+
if (comment) {
|
|
47
|
+
if (token.type === 'scalar' && token.source === '')
|
|
48
|
+
node.comment = comment;
|
|
49
|
+
else
|
|
50
|
+
node.commentBefore = comment;
|
|
51
|
+
}
|
|
52
|
+
// @ts-expect-error Type checking misses meaning of isSrcToken
|
|
53
|
+
if (ctx.options.keepSourceTokens && isSrcToken)
|
|
54
|
+
node.srcToken = token;
|
|
55
|
+
return node;
|
|
56
|
+
}
|
|
57
|
+
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) {
|
|
58
|
+
const token = {
|
|
59
|
+
type: 'scalar',
|
|
60
|
+
offset: emptyScalarPosition(offset, before, pos),
|
|
61
|
+
indent: -1,
|
|
62
|
+
source: ''
|
|
63
|
+
};
|
|
64
|
+
const node = composeScalar(ctx, token, tag, onError);
|
|
65
|
+
if (anchor) {
|
|
66
|
+
node.anchor = anchor.source.substring(1);
|
|
67
|
+
if (node.anchor === '')
|
|
68
|
+
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
69
|
+
}
|
|
70
|
+
if (spaceBefore)
|
|
71
|
+
node.spaceBefore = true;
|
|
72
|
+
if (comment) {
|
|
73
|
+
node.comment = comment;
|
|
74
|
+
node.range[2] = end;
|
|
75
|
+
}
|
|
76
|
+
return node;
|
|
77
|
+
}
|
|
78
|
+
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
79
|
+
const alias = new Alias(source.substring(1));
|
|
80
|
+
if (alias.source === '')
|
|
81
|
+
onError(offset, 'BAD_ALIAS', 'Alias cannot be an empty string');
|
|
82
|
+
if (alias.source.endsWith(':'))
|
|
83
|
+
onError(offset + source.length - 1, 'BAD_ALIAS', 'Alias ending in : is ambiguous', true);
|
|
84
|
+
const valueEnd = offset + source.length;
|
|
85
|
+
const re = resolveEnd(end, valueEnd, options.strict, onError);
|
|
86
|
+
alias.range = [offset, valueEnd, re.offset];
|
|
87
|
+
if (re.comment)
|
|
88
|
+
alias.comment = re.comment;
|
|
89
|
+
return alias;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { composeEmptyNode, composeNode };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { SCALAR, isScalar } from '../nodes/identity.js';
|
|
2
|
+
import { Scalar } from '../nodes/Scalar.js';
|
|
3
|
+
import { resolveBlockScalar } from './resolve-block-scalar.js';
|
|
4
|
+
import { resolveFlowScalar } from './resolve-flow-scalar.js';
|
|
5
|
+
|
|
6
|
+
function composeScalar(ctx, token, tagToken, onError) {
|
|
7
|
+
const { value, type, comment, range } = token.type === 'block-scalar'
|
|
8
|
+
? resolveBlockScalar(ctx, token, onError)
|
|
9
|
+
: resolveFlowScalar(token, ctx.options.strict, onError);
|
|
10
|
+
const tagName = tagToken
|
|
11
|
+
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
|
|
12
|
+
: null;
|
|
13
|
+
const tag = tagToken && tagName
|
|
14
|
+
? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError)
|
|
15
|
+
: token.type === 'scalar'
|
|
16
|
+
? findScalarTagByTest(ctx, value, token, onError)
|
|
17
|
+
: ctx.schema[SCALAR];
|
|
18
|
+
let scalar;
|
|
19
|
+
try {
|
|
20
|
+
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
21
|
+
scalar = isScalar(res) ? res : new Scalar(res);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
25
|
+
onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg);
|
|
26
|
+
scalar = new Scalar(value);
|
|
27
|
+
}
|
|
28
|
+
scalar.range = range;
|
|
29
|
+
scalar.source = value;
|
|
30
|
+
if (type)
|
|
31
|
+
scalar.type = type;
|
|
32
|
+
if (tagName)
|
|
33
|
+
scalar.tag = tagName;
|
|
34
|
+
if (tag.format)
|
|
35
|
+
scalar.format = tag.format;
|
|
36
|
+
if (comment)
|
|
37
|
+
scalar.comment = comment;
|
|
38
|
+
return scalar;
|
|
39
|
+
}
|
|
40
|
+
function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
41
|
+
if (tagName === '!')
|
|
42
|
+
return schema[SCALAR]; // non-specific tag
|
|
43
|
+
const matchWithTest = [];
|
|
44
|
+
for (const tag of schema.tags) {
|
|
45
|
+
if (!tag.collection && tag.tag === tagName) {
|
|
46
|
+
if (tag.default && tag.test)
|
|
47
|
+
matchWithTest.push(tag);
|
|
48
|
+
else
|
|
49
|
+
return tag;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for (const tag of matchWithTest)
|
|
53
|
+
if (tag.test?.test(value))
|
|
54
|
+
return tag;
|
|
55
|
+
const kt = schema.knownTags[tagName];
|
|
56
|
+
if (kt && !kt.collection) {
|
|
57
|
+
// Ensure that the known tag is available for stringifying,
|
|
58
|
+
// but does not get used by default.
|
|
59
|
+
schema.tags.push(Object.assign({}, kt, { default: false, test: undefined }));
|
|
60
|
+
return kt;
|
|
61
|
+
}
|
|
62
|
+
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
|
|
63
|
+
return schema[SCALAR];
|
|
64
|
+
}
|
|
65
|
+
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
66
|
+
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[SCALAR];
|
|
67
|
+
if (schema.compat) {
|
|
68
|
+
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
|
69
|
+
schema[SCALAR];
|
|
70
|
+
if (tag.tag !== compat.tag) {
|
|
71
|
+
const ts = directives.tagString(tag.tag);
|
|
72
|
+
const cs = directives.tagString(compat.tag);
|
|
73
|
+
const msg = `Value may be parsed as either ${ts} or ${cs}`;
|
|
74
|
+
onError(token, 'TAG_RESOLVE_FAILED', msg, true);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return tag;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { composeScalar };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { Directives } from '../doc/directives.js';
|
|
2
|
+
import { Document } from '../doc/Document.js';
|
|
3
|
+
import { YAMLWarning, YAMLParseError } from '../errors.js';
|
|
4
|
+
import { isCollection, isPair } from '../nodes/identity.js';
|
|
5
|
+
import { composeDoc } from './compose-doc.js';
|
|
6
|
+
import { resolveEnd } from './resolve-end.js';
|
|
7
|
+
|
|
8
|
+
function getErrorPos(src) {
|
|
9
|
+
if (typeof src === 'number')
|
|
10
|
+
return [src, src + 1];
|
|
11
|
+
if (Array.isArray(src))
|
|
12
|
+
return src.length === 2 ? src : [src[0], src[1]];
|
|
13
|
+
const { offset, source } = src;
|
|
14
|
+
return [offset, offset + (typeof source === 'string' ? source.length : 1)];
|
|
15
|
+
}
|
|
16
|
+
function parsePrelude(prelude) {
|
|
17
|
+
let comment = '';
|
|
18
|
+
let atComment = false;
|
|
19
|
+
let afterEmptyLine = false;
|
|
20
|
+
for (let i = 0; i < prelude.length; ++i) {
|
|
21
|
+
const source = prelude[i];
|
|
22
|
+
switch (source[0]) {
|
|
23
|
+
case '#':
|
|
24
|
+
comment +=
|
|
25
|
+
(comment === '' ? '' : afterEmptyLine ? '\n\n' : '\n') +
|
|
26
|
+
(source.substring(1) || ' ');
|
|
27
|
+
atComment = true;
|
|
28
|
+
afterEmptyLine = false;
|
|
29
|
+
break;
|
|
30
|
+
case '%':
|
|
31
|
+
if (prelude[i + 1]?.[0] !== '#')
|
|
32
|
+
i += 1;
|
|
33
|
+
atComment = false;
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
// This may be wrong after doc-end, but in that case it doesn't matter
|
|
37
|
+
if (!atComment)
|
|
38
|
+
afterEmptyLine = true;
|
|
39
|
+
atComment = false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { comment, afterEmptyLine };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Compose a stream of CST nodes into a stream of YAML Documents.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { Composer, Parser } from 'yaml'
|
|
49
|
+
*
|
|
50
|
+
* const src: string = ...
|
|
51
|
+
* const tokens = new Parser().parse(src)
|
|
52
|
+
* const docs = new Composer().compose(tokens)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
class Composer {
|
|
56
|
+
constructor(options = {}) {
|
|
57
|
+
this.doc = null;
|
|
58
|
+
this.atDirectives = false;
|
|
59
|
+
this.prelude = [];
|
|
60
|
+
this.errors = [];
|
|
61
|
+
this.warnings = [];
|
|
62
|
+
this.onError = (source, code, message, warning) => {
|
|
63
|
+
const pos = getErrorPos(source);
|
|
64
|
+
if (warning)
|
|
65
|
+
this.warnings.push(new YAMLWarning(pos, code, message));
|
|
66
|
+
else
|
|
67
|
+
this.errors.push(new YAMLParseError(pos, code, message));
|
|
68
|
+
};
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
70
|
+
this.directives = new Directives({ version: options.version || '1.2' });
|
|
71
|
+
this.options = options;
|
|
72
|
+
}
|
|
73
|
+
decorate(doc, afterDoc) {
|
|
74
|
+
const { comment, afterEmptyLine } = parsePrelude(this.prelude);
|
|
75
|
+
//console.log({ dc: doc.comment, prelude, comment })
|
|
76
|
+
if (comment) {
|
|
77
|
+
const dc = doc.contents;
|
|
78
|
+
if (afterDoc) {
|
|
79
|
+
doc.comment = doc.comment ? `${doc.comment}\n${comment}` : comment;
|
|
80
|
+
}
|
|
81
|
+
else if (afterEmptyLine || doc.directives.docStart || !dc) {
|
|
82
|
+
doc.commentBefore = comment;
|
|
83
|
+
}
|
|
84
|
+
else if (isCollection(dc) && !dc.flow && dc.items.length > 0) {
|
|
85
|
+
let it = dc.items[0];
|
|
86
|
+
if (isPair(it))
|
|
87
|
+
it = it.key;
|
|
88
|
+
const cb = it.commentBefore;
|
|
89
|
+
it.commentBefore = cb ? `${comment}\n${cb}` : comment;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const cb = dc.commentBefore;
|
|
93
|
+
dc.commentBefore = cb ? `${comment}\n${cb}` : comment;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (afterDoc) {
|
|
97
|
+
Array.prototype.push.apply(doc.errors, this.errors);
|
|
98
|
+
Array.prototype.push.apply(doc.warnings, this.warnings);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
doc.errors = this.errors;
|
|
102
|
+
doc.warnings = this.warnings;
|
|
103
|
+
}
|
|
104
|
+
this.prelude = [];
|
|
105
|
+
this.errors = [];
|
|
106
|
+
this.warnings = [];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Current stream status information.
|
|
110
|
+
*
|
|
111
|
+
* Mostly useful at the end of input for an empty stream.
|
|
112
|
+
*/
|
|
113
|
+
streamInfo() {
|
|
114
|
+
return {
|
|
115
|
+
comment: parsePrelude(this.prelude).comment,
|
|
116
|
+
directives: this.directives,
|
|
117
|
+
errors: this.errors,
|
|
118
|
+
warnings: this.warnings
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Compose tokens into documents.
|
|
123
|
+
*
|
|
124
|
+
* @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.
|
|
125
|
+
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
126
|
+
*/
|
|
127
|
+
*compose(tokens, forceDoc = false, endOffset = -1) {
|
|
128
|
+
for (const token of tokens)
|
|
129
|
+
yield* this.next(token);
|
|
130
|
+
yield* this.end(forceDoc, endOffset);
|
|
131
|
+
}
|
|
132
|
+
/** Advance the composer by one CST token. */
|
|
133
|
+
*next(token) {
|
|
134
|
+
switch (token.type) {
|
|
135
|
+
case 'directive':
|
|
136
|
+
this.directives.add(token.source, (offset, message, warning) => {
|
|
137
|
+
const pos = getErrorPos(token);
|
|
138
|
+
pos[0] += offset;
|
|
139
|
+
this.onError(pos, 'BAD_DIRECTIVE', message, warning);
|
|
140
|
+
});
|
|
141
|
+
this.prelude.push(token.source);
|
|
142
|
+
this.atDirectives = true;
|
|
143
|
+
break;
|
|
144
|
+
case 'document': {
|
|
145
|
+
const doc = composeDoc(this.options, this.directives, token, this.onError);
|
|
146
|
+
if (this.atDirectives && !doc.directives.docStart)
|
|
147
|
+
this.onError(token, 'MISSING_CHAR', 'Missing directives-end/doc-start indicator line');
|
|
148
|
+
this.decorate(doc, false);
|
|
149
|
+
if (this.doc)
|
|
150
|
+
yield this.doc;
|
|
151
|
+
this.doc = doc;
|
|
152
|
+
this.atDirectives = false;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case 'byte-order-mark':
|
|
156
|
+
case 'space':
|
|
157
|
+
break;
|
|
158
|
+
case 'comment':
|
|
159
|
+
case 'newline':
|
|
160
|
+
this.prelude.push(token.source);
|
|
161
|
+
break;
|
|
162
|
+
case 'error': {
|
|
163
|
+
const msg = token.source
|
|
164
|
+
? `${token.message}: ${JSON.stringify(token.source)}`
|
|
165
|
+
: token.message;
|
|
166
|
+
const error = new YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', msg);
|
|
167
|
+
if (this.atDirectives || !this.doc)
|
|
168
|
+
this.errors.push(error);
|
|
169
|
+
else
|
|
170
|
+
this.doc.errors.push(error);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case 'doc-end': {
|
|
174
|
+
if (!this.doc) {
|
|
175
|
+
const msg = 'Unexpected doc-end without preceding document';
|
|
176
|
+
this.errors.push(new YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', msg));
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
this.doc.directives.docEnd = true;
|
|
180
|
+
const end = resolveEnd(token.end, token.offset + token.source.length, this.doc.options.strict, this.onError);
|
|
181
|
+
this.decorate(this.doc, true);
|
|
182
|
+
if (end.comment) {
|
|
183
|
+
const dc = this.doc.comment;
|
|
184
|
+
this.doc.comment = dc ? `${dc}\n${end.comment}` : end.comment;
|
|
185
|
+
}
|
|
186
|
+
this.doc.range[2] = end.offset;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
default:
|
|
190
|
+
this.errors.push(new YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', `Unsupported token ${token.type}`));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Call at end of input to yield any remaining document.
|
|
195
|
+
*
|
|
196
|
+
* @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.
|
|
197
|
+
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
198
|
+
*/
|
|
199
|
+
*end(forceDoc = false, endOffset = -1) {
|
|
200
|
+
if (this.doc) {
|
|
201
|
+
this.decorate(this.doc, true);
|
|
202
|
+
yield this.doc;
|
|
203
|
+
this.doc = null;
|
|
204
|
+
}
|
|
205
|
+
else if (forceDoc) {
|
|
206
|
+
const opts = Object.assign({ _directives: this.directives }, this.options);
|
|
207
|
+
const doc = new Document(undefined, opts);
|
|
208
|
+
if (this.atDirectives)
|
|
209
|
+
this.onError(endOffset, 'MISSING_CHAR', 'Missing directives-end indicator line');
|
|
210
|
+
doc.range = [0, endOffset, endOffset];
|
|
211
|
+
this.decorate(doc, false);
|
|
212
|
+
yield doc;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export { Composer };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Pair } from '../nodes/Pair.js';
|
|
2
|
+
import { YAMLMap } from '../nodes/YAMLMap.js';
|
|
3
|
+
import { resolveProps } from './resolve-props.js';
|
|
4
|
+
import { containsNewline } from './util-contains-newline.js';
|
|
5
|
+
import { flowIndentCheck } from './util-flow-indent-check.js';
|
|
6
|
+
import { mapIncludes } from './util-map-includes.js';
|
|
7
|
+
|
|
8
|
+
const startColMsg = 'All mapping items must start at the same column';
|
|
9
|
+
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, tag) {
|
|
10
|
+
const NodeClass = tag?.nodeClass ?? YAMLMap;
|
|
11
|
+
const map = new NodeClass(ctx.schema);
|
|
12
|
+
if (ctx.atRoot)
|
|
13
|
+
ctx.atRoot = false;
|
|
14
|
+
let offset = bm.offset;
|
|
15
|
+
let commentEnd = null;
|
|
16
|
+
for (const collItem of bm.items) {
|
|
17
|
+
const { start, key, sep, value } = collItem;
|
|
18
|
+
// key properties
|
|
19
|
+
const keyProps = resolveProps(start, {
|
|
20
|
+
indicator: 'explicit-key-ind',
|
|
21
|
+
next: key ?? sep?.[0],
|
|
22
|
+
offset,
|
|
23
|
+
onError,
|
|
24
|
+
parentIndent: bm.indent,
|
|
25
|
+
startOnNewline: true
|
|
26
|
+
});
|
|
27
|
+
const implicitKey = !keyProps.found;
|
|
28
|
+
if (implicitKey) {
|
|
29
|
+
if (key) {
|
|
30
|
+
if (key.type === 'block-seq')
|
|
31
|
+
onError(offset, 'BLOCK_AS_IMPLICIT_KEY', 'A block sequence may not be used as an implicit map key');
|
|
32
|
+
else if ('indent' in key && key.indent !== bm.indent)
|
|
33
|
+
onError(offset, 'BAD_INDENT', startColMsg);
|
|
34
|
+
}
|
|
35
|
+
if (!keyProps.anchor && !keyProps.tag && !sep) {
|
|
36
|
+
commentEnd = keyProps.end;
|
|
37
|
+
if (keyProps.comment) {
|
|
38
|
+
if (map.comment)
|
|
39
|
+
map.comment += '\n' + keyProps.comment;
|
|
40
|
+
else
|
|
41
|
+
map.comment = keyProps.comment;
|
|
42
|
+
}
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (keyProps.newlineAfterProp || containsNewline(key)) {
|
|
46
|
+
onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (keyProps.found?.indent !== bm.indent) {
|
|
50
|
+
onError(offset, 'BAD_INDENT', startColMsg);
|
|
51
|
+
}
|
|
52
|
+
// key value
|
|
53
|
+
const keyStart = keyProps.end;
|
|
54
|
+
const keyNode = key
|
|
55
|
+
? composeNode(ctx, key, keyProps, onError)
|
|
56
|
+
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
|
|
57
|
+
if (ctx.schema.compat)
|
|
58
|
+
flowIndentCheck(bm.indent, key, onError);
|
|
59
|
+
if (mapIncludes(ctx, map.items, keyNode))
|
|
60
|
+
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
61
|
+
// value properties
|
|
62
|
+
const valueProps = resolveProps(sep ?? [], {
|
|
63
|
+
indicator: 'map-value-ind',
|
|
64
|
+
next: value,
|
|
65
|
+
offset: keyNode.range[2],
|
|
66
|
+
onError,
|
|
67
|
+
parentIndent: bm.indent,
|
|
68
|
+
startOnNewline: !key || key.type === 'block-scalar'
|
|
69
|
+
});
|
|
70
|
+
offset = valueProps.end;
|
|
71
|
+
if (valueProps.found) {
|
|
72
|
+
if (implicitKey) {
|
|
73
|
+
if (value?.type === 'block-map' && !valueProps.hasNewline)
|
|
74
|
+
onError(offset, 'BLOCK_AS_IMPLICIT_KEY', 'Nested mappings are not allowed in compact mappings');
|
|
75
|
+
if (ctx.options.strict &&
|
|
76
|
+
keyProps.start < valueProps.found.offset - 1024)
|
|
77
|
+
onError(keyNode.range, 'KEY_OVER_1024_CHARS', 'The : indicator must be at most 1024 chars after the start of an implicit block mapping key');
|
|
78
|
+
}
|
|
79
|
+
// value value
|
|
80
|
+
const valueNode = value
|
|
81
|
+
? composeNode(ctx, value, valueProps, onError)
|
|
82
|
+
: composeEmptyNode(ctx, offset, sep, null, valueProps, onError);
|
|
83
|
+
if (ctx.schema.compat)
|
|
84
|
+
flowIndentCheck(bm.indent, value, onError);
|
|
85
|
+
offset = valueNode.range[2];
|
|
86
|
+
const pair = new Pair(keyNode, valueNode);
|
|
87
|
+
if (ctx.options.keepSourceTokens)
|
|
88
|
+
pair.srcToken = collItem;
|
|
89
|
+
map.items.push(pair);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// key with no value
|
|
93
|
+
if (implicitKey)
|
|
94
|
+
onError(keyNode.range, 'MISSING_CHAR', 'Implicit map keys need to be followed by map values');
|
|
95
|
+
if (valueProps.comment) {
|
|
96
|
+
if (keyNode.comment)
|
|
97
|
+
keyNode.comment += '\n' + valueProps.comment;
|
|
98
|
+
else
|
|
99
|
+
keyNode.comment = valueProps.comment;
|
|
100
|
+
}
|
|
101
|
+
const pair = new Pair(keyNode);
|
|
102
|
+
if (ctx.options.keepSourceTokens)
|
|
103
|
+
pair.srcToken = collItem;
|
|
104
|
+
map.items.push(pair);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (commentEnd && commentEnd < offset)
|
|
108
|
+
onError(commentEnd, 'IMPOSSIBLE', 'Map comment with trailing content');
|
|
109
|
+
map.range = [bm.offset, offset, commentEnd ?? offset];
|
|
110
|
+
return map;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { resolveBlockMap };
|