yaml 2.1.1 → 2.1.3
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 +1 -1
- package/browser/dist/compose/compose-node.js +4 -2
- package/browser/dist/compose/resolve-block-map.js +5 -2
- package/browser/dist/compose/resolve-block-seq.js +5 -5
- package/browser/dist/doc/createNode.js +1 -1
- package/browser/dist/schema/yaml-1.1/set.js +2 -1
- package/dist/compose/compose-node.d.ts +2 -1
- package/dist/compose/compose-node.js +4 -2
- package/dist/compose/resolve-block-map.js +5 -2
- package/dist/compose/resolve-block-seq.js +5 -5
- package/dist/doc/createNode.js +1 -1
- package/dist/nodes/Alias.d.ts +1 -1
- package/dist/nodes/YAMLMap.d.ts +2 -1
- package/dist/nodes/addPairToJSMap.d.ts +2 -1
- package/dist/schema/yaml-1.1/set.js +2 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# YAML <a href="https://www.npmjs.com/package/yaml"><img align="right" src="https://badge.fury.io/js/yaml.svg" title="npm package" /></a>
|
|
2
2
|
|
|
3
|
-
`yaml` is a definitive library for [YAML](
|
|
3
|
+
`yaml` is a definitive library for [YAML](https://yaml.org/), the human friendly data serialization standard.
|
|
4
4
|
This library:
|
|
5
5
|
|
|
6
6
|
- Supports both YAML 1.1 and YAML 1.2 and all common data schemas,
|
|
@@ -54,7 +54,7 @@ function composeNode(ctx, token, props, onError) {
|
|
|
54
54
|
node.srcToken = token;
|
|
55
55
|
return node;
|
|
56
56
|
}
|
|
57
|
-
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag }, onError) {
|
|
57
|
+
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) {
|
|
58
58
|
const token = {
|
|
59
59
|
type: 'scalar',
|
|
60
60
|
offset: emptyScalarPosition(offset, before, pos),
|
|
@@ -69,8 +69,10 @@ function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anch
|
|
|
69
69
|
}
|
|
70
70
|
if (spaceBefore)
|
|
71
71
|
node.spaceBefore = true;
|
|
72
|
-
if (comment)
|
|
72
|
+
if (comment) {
|
|
73
73
|
node.comment = comment;
|
|
74
|
+
node.range[2] = end;
|
|
75
|
+
}
|
|
74
76
|
return node;
|
|
75
77
|
}
|
|
76
78
|
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
@@ -11,6 +11,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
11
11
|
if (ctx.atRoot)
|
|
12
12
|
ctx.atRoot = false;
|
|
13
13
|
let offset = bm.offset;
|
|
14
|
+
let commentEnd = null;
|
|
14
15
|
for (const collItem of bm.items) {
|
|
15
16
|
const { start, key, sep, value } = collItem;
|
|
16
17
|
// key properties
|
|
@@ -30,7 +31,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
30
31
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
31
32
|
}
|
|
32
33
|
if (!keyProps.anchor && !keyProps.tag && !sep) {
|
|
33
|
-
|
|
34
|
+
commentEnd = keyProps.end;
|
|
34
35
|
if (keyProps.comment) {
|
|
35
36
|
if (map.comment)
|
|
36
37
|
map.comment += '\n' + keyProps.comment;
|
|
@@ -100,7 +101,9 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
100
101
|
map.items.push(pair);
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
+
if (commentEnd && commentEnd < offset)
|
|
105
|
+
onError(commentEnd, 'IMPOSSIBLE', 'Map comment with trailing content');
|
|
106
|
+
map.range = [bm.offset, offset, commentEnd ?? offset];
|
|
104
107
|
return map;
|
|
105
108
|
}
|
|
106
109
|
|
|
@@ -7,6 +7,7 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
7
7
|
if (ctx.atRoot)
|
|
8
8
|
ctx.atRoot = false;
|
|
9
9
|
let offset = bs.offset;
|
|
10
|
+
let commentEnd = null;
|
|
10
11
|
for (const { start, value } of bs.items) {
|
|
11
12
|
const props = resolveProps(start, {
|
|
12
13
|
indicator: 'seq-item-ind',
|
|
@@ -15,16 +16,15 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
15
16
|
onError,
|
|
16
17
|
startOnNewline: true
|
|
17
18
|
});
|
|
18
|
-
offset = props.end;
|
|
19
19
|
if (!props.found) {
|
|
20
20
|
if (props.anchor || props.tag || value) {
|
|
21
21
|
if (value && value.type === 'block-seq')
|
|
22
|
-
onError(
|
|
22
|
+
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
|
23
23
|
else
|
|
24
24
|
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
|
|
27
|
+
commentEnd = props.end;
|
|
28
28
|
if (props.comment)
|
|
29
29
|
seq.comment = props.comment;
|
|
30
30
|
continue;
|
|
@@ -32,13 +32,13 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
32
32
|
}
|
|
33
33
|
const node = value
|
|
34
34
|
? composeNode(ctx, value, props, onError)
|
|
35
|
-
: composeEmptyNode(ctx,
|
|
35
|
+
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
|
36
36
|
if (ctx.schema.compat)
|
|
37
37
|
flowIndentCheck(bs.indent, value, onError);
|
|
38
38
|
offset = node.range[2];
|
|
39
39
|
seq.items.push(node);
|
|
40
40
|
}
|
|
41
|
-
seq.range = [bs.offset, offset, offset];
|
|
41
|
+
seq.range = [bs.offset, offset, commentEnd ?? offset];
|
|
42
42
|
return seq;
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -26,7 +26,7 @@ function createNode(value, tagName, ctx) {
|
|
|
26
26
|
if (value instanceof String ||
|
|
27
27
|
value instanceof Number ||
|
|
28
28
|
value instanceof Boolean ||
|
|
29
|
-
(typeof BigInt
|
|
29
|
+
(typeof BigInt !== 'undefined' && value instanceof BigInt) // not supported everywhere
|
|
30
30
|
) {
|
|
31
31
|
// https://tc39.es/ecma262/#sec-serializejsonproperty
|
|
32
32
|
value = value.valueOf();
|
|
@@ -15,6 +15,7 @@ interface Props {
|
|
|
15
15
|
comment: string;
|
|
16
16
|
anchor: SourceToken | null;
|
|
17
17
|
tag: SourceToken | null;
|
|
18
|
+
end: number;
|
|
18
19
|
}
|
|
19
20
|
declare const CN: {
|
|
20
21
|
composeNode: typeof composeNode;
|
|
@@ -22,5 +23,5 @@ declare const CN: {
|
|
|
22
23
|
};
|
|
23
24
|
export declare type ComposeNode = typeof CN;
|
|
24
25
|
export declare function composeNode(ctx: ComposeContext, token: Token, props: Props, onError: ComposeErrorHandler): ParsedNode;
|
|
25
|
-
export declare function composeEmptyNode(ctx: ComposeContext, offset: number, before: Token[] | undefined, pos: number | null, { spaceBefore, comment, anchor, tag }: Props, onError: ComposeErrorHandler): import("../index.js").Scalar.Parsed;
|
|
26
|
+
export declare function composeEmptyNode(ctx: ComposeContext, offset: number, before: Token[] | undefined, pos: number | null, { spaceBefore, comment, anchor, tag, end }: Props, onError: ComposeErrorHandler): import("../index.js").Scalar.Parsed;
|
|
26
27
|
export {};
|
|
@@ -56,7 +56,7 @@ function composeNode(ctx, token, props, onError) {
|
|
|
56
56
|
node.srcToken = token;
|
|
57
57
|
return node;
|
|
58
58
|
}
|
|
59
|
-
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag }, onError) {
|
|
59
|
+
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) {
|
|
60
60
|
const token = {
|
|
61
61
|
type: 'scalar',
|
|
62
62
|
offset: utilEmptyScalarPosition.emptyScalarPosition(offset, before, pos),
|
|
@@ -71,8 +71,10 @@ function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anch
|
|
|
71
71
|
}
|
|
72
72
|
if (spaceBefore)
|
|
73
73
|
node.spaceBefore = true;
|
|
74
|
-
if (comment)
|
|
74
|
+
if (comment) {
|
|
75
75
|
node.comment = comment;
|
|
76
|
+
node.range[2] = end;
|
|
77
|
+
}
|
|
76
78
|
return node;
|
|
77
79
|
}
|
|
78
80
|
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
@@ -13,6 +13,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
13
13
|
if (ctx.atRoot)
|
|
14
14
|
ctx.atRoot = false;
|
|
15
15
|
let offset = bm.offset;
|
|
16
|
+
let commentEnd = null;
|
|
16
17
|
for (const collItem of bm.items) {
|
|
17
18
|
const { start, key, sep, value } = collItem;
|
|
18
19
|
// key properties
|
|
@@ -32,7 +33,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
32
33
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
33
34
|
}
|
|
34
35
|
if (!keyProps.anchor && !keyProps.tag && !sep) {
|
|
35
|
-
|
|
36
|
+
commentEnd = keyProps.end;
|
|
36
37
|
if (keyProps.comment) {
|
|
37
38
|
if (map.comment)
|
|
38
39
|
map.comment += '\n' + keyProps.comment;
|
|
@@ -102,7 +103,9 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
102
103
|
map.items.push(pair);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
if (commentEnd && commentEnd < offset)
|
|
107
|
+
onError(commentEnd, 'IMPOSSIBLE', 'Map comment with trailing content');
|
|
108
|
+
map.range = [bm.offset, offset, commentEnd ?? offset];
|
|
106
109
|
return map;
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -9,6 +9,7 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
9
9
|
if (ctx.atRoot)
|
|
10
10
|
ctx.atRoot = false;
|
|
11
11
|
let offset = bs.offset;
|
|
12
|
+
let commentEnd = null;
|
|
12
13
|
for (const { start, value } of bs.items) {
|
|
13
14
|
const props = resolveProps.resolveProps(start, {
|
|
14
15
|
indicator: 'seq-item-ind',
|
|
@@ -17,16 +18,15 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
17
18
|
onError,
|
|
18
19
|
startOnNewline: true
|
|
19
20
|
});
|
|
20
|
-
offset = props.end;
|
|
21
21
|
if (!props.found) {
|
|
22
22
|
if (props.anchor || props.tag || value) {
|
|
23
23
|
if (value && value.type === 'block-seq')
|
|
24
|
-
onError(
|
|
24
|
+
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
|
25
25
|
else
|
|
26
26
|
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
|
|
29
|
+
commentEnd = props.end;
|
|
30
30
|
if (props.comment)
|
|
31
31
|
seq.comment = props.comment;
|
|
32
32
|
continue;
|
|
@@ -34,13 +34,13 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
34
34
|
}
|
|
35
35
|
const node = value
|
|
36
36
|
? composeNode(ctx, value, props, onError)
|
|
37
|
-
: composeEmptyNode(ctx,
|
|
37
|
+
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
|
38
38
|
if (ctx.schema.compat)
|
|
39
39
|
utilFlowIndentCheck.flowIndentCheck(bs.indent, value, onError);
|
|
40
40
|
offset = node.range[2];
|
|
41
41
|
seq.items.push(node);
|
|
42
42
|
}
|
|
43
|
-
seq.range = [bs.offset, offset, offset];
|
|
43
|
+
seq.range = [bs.offset, offset, commentEnd ?? offset];
|
|
44
44
|
return seq;
|
|
45
45
|
}
|
|
46
46
|
|
package/dist/doc/createNode.js
CHANGED
|
@@ -28,7 +28,7 @@ function createNode(value, tagName, ctx) {
|
|
|
28
28
|
if (value instanceof String ||
|
|
29
29
|
value instanceof Number ||
|
|
30
30
|
value instanceof Boolean ||
|
|
31
|
-
(typeof BigInt
|
|
31
|
+
(typeof BigInt !== 'undefined' && value instanceof BigInt) // not supported everywhere
|
|
32
32
|
) {
|
|
33
33
|
// https://tc39.es/ecma262/#sec-serializejsonproperty
|
|
34
34
|
value = value.valueOf();
|
package/dist/nodes/Alias.d.ts
CHANGED
|
@@ -23,6 +23,6 @@ export declare class Alias extends NodeBase {
|
|
|
23
23
|
* instance of the `source` anchor before this node.
|
|
24
24
|
*/
|
|
25
25
|
resolve(doc: Document): Scalar | YAMLMap | YAMLSeq | undefined;
|
|
26
|
-
toJSON(_arg?: unknown, ctx?: ToJSContext):
|
|
26
|
+
toJSON(_arg?: unknown, ctx?: ToJSContext): {} | null;
|
|
27
27
|
toString(ctx?: StringifyContext, _onComment?: () => void, _onChompKeep?: () => void): string;
|
|
28
28
|
}
|
package/dist/nodes/YAMLMap.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ParsedNode, Range } from './Node.js';
|
|
|
6
6
|
import { Pair } from './Pair.js';
|
|
7
7
|
import { Scalar } from './Scalar.js';
|
|
8
8
|
import type { ToJSContext } from './toJS.js';
|
|
9
|
+
export declare type MapLike = Map<unknown, unknown> | Set<unknown> | Record<string | number | symbol, unknown>;
|
|
9
10
|
export declare function findPair<K = unknown, V = unknown>(items: Iterable<Pair<K, V>>, key: unknown): Pair<K, V> | undefined;
|
|
10
11
|
export declare namespace YAMLMap {
|
|
11
12
|
interface Parsed<K extends ParsedNode = ParsedNode, V extends ParsedNode | null = ParsedNode | null> extends YAMLMap<K, V> {
|
|
@@ -39,7 +40,7 @@ export declare class YAMLMap<K = unknown, V = unknown> extends Collection {
|
|
|
39
40
|
* @param {Class} Type - If set, forces the returned collection type
|
|
40
41
|
* @returns Instance of Type, Map, or Object
|
|
41
42
|
*/
|
|
42
|
-
toJSON<T = unknown
|
|
43
|
+
toJSON<T extends MapLike = Map<unknown, unknown>>(_?: unknown, ctx?: ToJSContext, Type?: {
|
|
43
44
|
new (): T;
|
|
44
45
|
}): any;
|
|
45
46
|
toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Pair } from './Pair.js';
|
|
2
2
|
import { ToJSContext } from './toJS.js';
|
|
3
|
-
|
|
3
|
+
import type { MapLike } from './YAMLMap.js';
|
|
4
|
+
export declare function addPairToJSMap(ctx: ToJSContext | undefined, map: MapLike, { key, value }: Pair): MapLike;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "Eemeli Aro <eemeli@gmail.com>",
|
|
6
6
|
"repository": "github:eemeli/yaml",
|
|
@@ -72,16 +72,16 @@
|
|
|
72
72
|
"@rollup/plugin-babel": "^5.2.3",
|
|
73
73
|
"@rollup/plugin-replace": "^4.0.0",
|
|
74
74
|
"@rollup/plugin-typescript": "^8.1.1",
|
|
75
|
-
"@types/jest": "^
|
|
75
|
+
"@types/jest": "^28.1.8",
|
|
76
76
|
"@types/node": "^12.20.47",
|
|
77
77
|
"@typescript-eslint/eslint-plugin": "^5.3.1",
|
|
78
78
|
"@typescript-eslint/parser": "^5.3.1",
|
|
79
|
-
"babel-jest": "^
|
|
79
|
+
"babel-jest": "^29.0.1",
|
|
80
80
|
"cross-env": "^7.0.3",
|
|
81
81
|
"eslint": "^8.2.0",
|
|
82
82
|
"eslint-config-prettier": "^8.1.0",
|
|
83
83
|
"fast-check": "^2.12.0",
|
|
84
|
-
"jest": "^
|
|
84
|
+
"jest": "^29.0.1",
|
|
85
85
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
86
86
|
"prettier": "^2.2.1",
|
|
87
87
|
"rollup": "^2.38.2",
|