@specship/specship-win32-arm64 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dist/server/cli.js +1 -1
- package/lib/dist/server/routes/sse.js +1 -1
- package/lib/dist/server/server.js +1 -1
- package/lib/node_modules/.package-lock.json +11 -20
- package/lib/node_modules/ajv/node_modules/fast-uri/index.js +1 -1
- package/lib/node_modules/ajv/node_modules/fast-uri/package.json +1 -1
- package/lib/node_modules/ajv/node_modules/fast-uri/test/security.test.js +28 -0
- package/lib/node_modules/toad-cache/README.md +10 -9
- package/lib/node_modules/toad-cache/dist/toad-cache.cjs +139 -139
- package/lib/node_modules/toad-cache/dist/toad-cache.mjs +136 -140
- package/lib/node_modules/toad-cache/package.json +8 -8
- package/lib/node_modules/toad-cache/toad-cache.d.cts +20 -14
- package/lib/node_modules/toad-cache/toad-cache.d.ts +18 -14
- package/lib/node_modules/yaml/README.md +14 -31
- package/lib/node_modules/yaml/browser/dist/compose/compose-collection.js +3 -3
- package/lib/node_modules/yaml/browser/dist/compose/compose-doc.js +0 -1
- package/lib/node_modules/yaml/browser/dist/compose/compose-node.js +4 -21
- package/lib/node_modules/yaml/browser/dist/compose/compose-scalar.js +8 -14
- package/lib/node_modules/yaml/browser/dist/compose/composer.js +2 -4
- package/lib/node_modules/yaml/browser/dist/compose/resolve-block-map.js +0 -2
- package/lib/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +1 -3
- package/lib/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +2 -8
- package/lib/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +4 -6
- package/lib/node_modules/yaml/browser/dist/compose/resolve-props.js +5 -3
- package/lib/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +2 -1
- package/lib/node_modules/yaml/browser/dist/compose/util-map-includes.js +5 -1
- package/lib/node_modules/yaml/browser/dist/doc/Document.js +2 -3
- package/lib/node_modules/yaml/browser/dist/doc/anchors.js +2 -1
- package/lib/node_modules/yaml/browser/dist/doc/applyReviver.js +0 -1
- package/lib/node_modules/yaml/browser/dist/doc/createNode.js +2 -1
- package/lib/node_modules/yaml/browser/dist/errors.js +1 -1
- package/lib/node_modules/yaml/browser/dist/log.js +6 -1
- package/lib/node_modules/yaml/browser/dist/node_modules/tslib/tslib.es6.js +21 -0
- package/lib/node_modules/yaml/browser/dist/nodes/Alias.js +12 -27
- package/lib/node_modules/yaml/browser/dist/nodes/YAMLMap.js +1 -1
- package/lib/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +49 -8
- package/lib/node_modules/yaml/browser/dist/parse/lexer.js +24 -28
- package/lib/node_modules/yaml/browser/dist/parse/parser.js +8 -31
- package/lib/node_modules/yaml/browser/dist/public-api.js +0 -3
- package/lib/node_modules/yaml/browser/dist/schema/Schema.js +2 -1
- package/lib/node_modules/yaml/browser/dist/schema/json/schema.js +1 -1
- package/lib/node_modules/yaml/browser/dist/schema/tags.js +16 -29
- package/lib/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +13 -5
- package/lib/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +1 -1
- package/lib/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +0 -2
- package/lib/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +1 -1
- package/lib/node_modules/yaml/browser/dist/stringify/stringify.js +5 -10
- package/lib/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +3 -13
- package/lib/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +2 -3
- package/lib/node_modules/yaml/browser/dist/stringify/stringifyPair.js +1 -1
- package/lib/node_modules/yaml/browser/dist/stringify/stringifyString.js +16 -24
- package/lib/node_modules/yaml/browser/dist/util.js +1 -1
- package/lib/node_modules/yaml/dist/cli.d.ts +1 -1
- package/lib/node_modules/yaml/dist/cli.mjs +3 -5
- package/lib/node_modules/yaml/dist/compose/compose-collection.d.ts +4 -4
- package/lib/node_modules/yaml/dist/compose/compose-collection.js +3 -3
- package/lib/node_modules/yaml/dist/compose/compose-doc.d.ts +6 -6
- package/lib/node_modules/yaml/dist/compose/compose-doc.js +0 -1
- package/lib/node_modules/yaml/dist/compose/compose-node.d.ts +7 -8
- package/lib/node_modules/yaml/dist/compose/compose-node.js +4 -21
- package/lib/node_modules/yaml/dist/compose/compose-scalar.d.ts +4 -4
- package/lib/node_modules/yaml/dist/compose/compose-scalar.js +7 -13
- package/lib/node_modules/yaml/dist/compose/composer.d.ts +6 -7
- package/lib/node_modules/yaml/dist/compose/composer.js +3 -6
- package/lib/node_modules/yaml/dist/compose/resolve-block-map.d.ts +5 -5
- package/lib/node_modules/yaml/dist/compose/resolve-block-map.js +0 -2
- package/lib/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +5 -5
- package/lib/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +5 -5
- package/lib/node_modules/yaml/dist/compose/resolve-block-seq.js +1 -3
- package/lib/node_modules/yaml/dist/compose/resolve-end.d.ts +2 -2
- package/lib/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -7
- package/lib/node_modules/yaml/dist/compose/resolve-flow-collection.js +2 -8
- package/lib/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +4 -4
- package/lib/node_modules/yaml/dist/compose/resolve-flow-scalar.js +4 -6
- package/lib/node_modules/yaml/dist/compose/resolve-props.d.ts +2 -2
- package/lib/node_modules/yaml/dist/compose/resolve-props.js +5 -3
- package/lib/node_modules/yaml/dist/compose/util-contains-newline.d.ts +1 -1
- package/lib/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +1 -1
- package/lib/node_modules/yaml/dist/compose/util-empty-scalar-position.js +2 -1
- package/lib/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +2 -2
- package/lib/node_modules/yaml/dist/compose/util-map-includes.d.ts +3 -3
- package/lib/node_modules/yaml/dist/compose/util-map-includes.js +5 -1
- package/lib/node_modules/yaml/dist/doc/Document.d.ts +11 -11
- package/lib/node_modules/yaml/dist/doc/Document.js +2 -3
- package/lib/node_modules/yaml/dist/doc/anchors.d.ts +2 -2
- package/lib/node_modules/yaml/dist/doc/anchors.js +2 -1
- package/lib/node_modules/yaml/dist/doc/applyReviver.js +0 -1
- package/lib/node_modules/yaml/dist/doc/createNode.d.ts +4 -4
- package/lib/node_modules/yaml/dist/doc/createNode.js +2 -1
- package/lib/node_modules/yaml/dist/doc/directives.d.ts +1 -1
- package/lib/node_modules/yaml/dist/errors.d.ts +1 -1
- package/lib/node_modules/yaml/dist/errors.js +1 -1
- package/lib/node_modules/yaml/dist/index.d.ts +18 -21
- package/lib/node_modules/yaml/dist/log.js +4 -4
- package/lib/node_modules/yaml/dist/nodes/Alias.d.ts +9 -10
- package/lib/node_modules/yaml/dist/nodes/Alias.js +11 -26
- package/lib/node_modules/yaml/dist/nodes/Collection.d.ts +4 -4
- package/lib/node_modules/yaml/dist/nodes/Node.d.ts +9 -16
- package/lib/node_modules/yaml/dist/nodes/Pair.d.ts +8 -9
- package/lib/node_modules/yaml/dist/nodes/Scalar.d.ts +4 -9
- package/lib/node_modules/yaml/dist/nodes/YAMLMap.d.ts +10 -10
- package/lib/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +10 -10
- package/lib/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +3 -3
- package/lib/node_modules/yaml/dist/nodes/addPairToJSMap.js +48 -7
- package/lib/node_modules/yaml/dist/nodes/identity.d.ts +7 -7
- package/lib/node_modules/yaml/dist/nodes/toJS.d.ts +2 -4
- package/lib/node_modules/yaml/dist/options.d.ts +10 -22
- package/lib/node_modules/yaml/dist/parse/cst-scalar.d.ts +4 -4
- package/lib/node_modules/yaml/dist/parse/cst-stringify.d.ts +1 -1
- package/lib/node_modules/yaml/dist/parse/cst-visit.d.ts +2 -2
- package/lib/node_modules/yaml/dist/parse/cst.d.ts +3 -4
- package/lib/node_modules/yaml/dist/parse/lexer.d.ts +1 -1
- package/lib/node_modules/yaml/dist/parse/lexer.js +24 -28
- package/lib/node_modules/yaml/dist/parse/parser.d.ts +4 -4
- package/lib/node_modules/yaml/dist/parse/parser.js +9 -33
- package/lib/node_modules/yaml/dist/public-api.d.ts +5 -6
- package/lib/node_modules/yaml/dist/public-api.js +0 -3
- package/lib/node_modules/yaml/dist/schema/Schema.d.ts +5 -4
- package/lib/node_modules/yaml/dist/schema/Schema.js +2 -1
- package/lib/node_modules/yaml/dist/schema/common/map.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/common/null.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/common/seq.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/common/string.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/core/bool.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/core/float.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/core/int.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/core/schema.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/json/schema.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/json/schema.js +1 -1
- package/lib/node_modules/yaml/dist/schema/tags.d.ts +3 -11
- package/lib/node_modules/yaml/dist/schema/tags.js +13 -26
- package/lib/node_modules/yaml/dist/schema/types.d.ts +12 -14
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/binary.js +7 -9
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +17 -11
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +7 -7
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/schema.js +0 -2
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +9 -9
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +1 -1
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +1 -1
- package/lib/node_modules/yaml/dist/stringify/stringify.d.ts +3 -3
- package/lib/node_modules/yaml/dist/stringify/stringify.js +5 -10
- package/lib/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +2 -2
- package/lib/node_modules/yaml/dist/stringify/stringifyCollection.js +3 -13
- package/lib/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +3 -3
- package/lib/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +1 -1
- package/lib/node_modules/yaml/dist/stringify/stringifyNumber.js +2 -3
- package/lib/node_modules/yaml/dist/stringify/stringifyPair.d.ts +2 -2
- package/lib/node_modules/yaml/dist/stringify/stringifyPair.js +1 -1
- package/lib/node_modules/yaml/dist/stringify/stringifyString.d.ts +2 -2
- package/lib/node_modules/yaml/dist/stringify/stringifyString.js +15 -23
- package/lib/node_modules/yaml/dist/util.d.ts +12 -16
- package/lib/node_modules/yaml/dist/util.js +2 -2
- package/lib/node_modules/yaml/dist/visit.d.ts +7 -7
- package/lib/node_modules/yaml/package.json +14 -13
- package/lib/package.json +5 -6
- package/package.json +1 -1
- package/lib/node_modules/jsonc-parser/CHANGELOG.md +0 -76
- package/lib/node_modules/jsonc-parser/LICENSE.md +0 -21
- package/lib/node_modules/jsonc-parser/README.md +0 -364
- package/lib/node_modules/jsonc-parser/SECURITY.md +0 -41
- package/lib/node_modules/jsonc-parser/lib/esm/impl/edit.js +0 -185
- package/lib/node_modules/jsonc-parser/lib/esm/impl/format.js +0 -261
- package/lib/node_modules/jsonc-parser/lib/esm/impl/parser.js +0 -659
- package/lib/node_modules/jsonc-parser/lib/esm/impl/scanner.js +0 -443
- package/lib/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +0 -29
- package/lib/node_modules/jsonc-parser/lib/esm/main.d.ts +0 -351
- package/lib/node_modules/jsonc-parser/lib/esm/main.js +0 -178
- package/lib/node_modules/jsonc-parser/lib/umd/impl/edit.js +0 -201
- package/lib/node_modules/jsonc-parser/lib/umd/impl/format.js +0 -275
- package/lib/node_modules/jsonc-parser/lib/umd/impl/parser.js +0 -682
- package/lib/node_modules/jsonc-parser/lib/umd/impl/scanner.js +0 -456
- package/lib/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +0 -42
- package/lib/node_modules/jsonc-parser/lib/umd/main.d.ts +0 -351
- package/lib/node_modules/jsonc-parser/lib/umd/main.js +0 -194
- package/lib/node_modules/jsonc-parser/package.json +0 -37
- package/lib/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +0 -67
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +0 -9
- package/lib/node_modules/yaml/dist/schema/yaml-1.1/merge.js +0 -71
|
@@ -8,6 +8,19 @@ export type CacheEntry<T> = {
|
|
|
8
8
|
value: T
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export type CacheStatistics = {
|
|
12
|
+
expirations: number,
|
|
13
|
+
evictions: number,
|
|
14
|
+
hits: number,
|
|
15
|
+
emptyHits: number,
|
|
16
|
+
falsyHits: number,
|
|
17
|
+
misses: number,
|
|
18
|
+
invalidateAll: number,
|
|
19
|
+
invalidateOne: number,
|
|
20
|
+
cacheSize: number,
|
|
21
|
+
sets: number,
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
export interface ToadCache<T> {
|
|
12
25
|
first: any;
|
|
13
26
|
last: any;
|
|
@@ -28,7 +41,7 @@ export interface ToadCache<T> {
|
|
|
28
41
|
export class FifoMap<T> implements ToadCache<T>{
|
|
29
42
|
constructor(max?: number, ttlInMsecs?: number);
|
|
30
43
|
first: any;
|
|
31
|
-
items: Map<any, T
|
|
44
|
+
items: Map<any, CacheEntry<T>>;
|
|
32
45
|
last: any;
|
|
33
46
|
max: number;
|
|
34
47
|
ttl: number;
|
|
@@ -66,7 +79,7 @@ export class FifoObject<T> implements ToadCache<T> {
|
|
|
66
79
|
export class LruMap<T> implements ToadCache<T> {
|
|
67
80
|
constructor(max?: number, ttlInMsecs?: number);
|
|
68
81
|
first: any;
|
|
69
|
-
items: Map<any, T
|
|
82
|
+
items: Map<any, CacheEntry<T>>;
|
|
70
83
|
last: any;
|
|
71
84
|
max: number;
|
|
72
85
|
ttl: number;
|
|
@@ -103,25 +116,16 @@ export class LruObject<T> implements ToadCache<T> {
|
|
|
103
116
|
}
|
|
104
117
|
|
|
105
118
|
export class HitStatisticsRecord {
|
|
106
|
-
records: Record<string, Record<string,
|
|
107
|
-
expirations: number,
|
|
108
|
-
evictions: number,
|
|
109
|
-
hits: number,
|
|
110
|
-
emptyHits: number,
|
|
111
|
-
falsyHits: number,
|
|
112
|
-
misses: number,
|
|
113
|
-
invalidateAll: number,
|
|
114
|
-
invalidateOne: number,
|
|
115
|
-
cacheSize: number,
|
|
116
|
-
sets: number,
|
|
117
|
-
}>>
|
|
119
|
+
records: Record<string, Record<string, CacheStatistics>>
|
|
118
120
|
|
|
119
121
|
initForCache(cacheId: string, currentTimeStamp: string): void
|
|
120
122
|
resetForCache(cacheId: string): void
|
|
123
|
+
getStatistics(): Record<string, Record<string, CacheStatistics>>
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
export class LruObjectHitStatistics<T> extends LruObject<T>{
|
|
124
127
|
constructor(max?: number, ttlInMsecs?: number, cacheId?: string, globalStatisticsRecord?: HitStatisticsRecord, statisticTtlInHours?: number);
|
|
128
|
+
getStatistics(): Record<string, Record<string, CacheStatistics>>
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
export { FifoObject as Fifo }
|
|
@@ -20,18 +20,20 @@ This requirement may be updated between minor versions of the library.
|
|
|
20
20
|
|
|
21
21
|
For more information, see the project's documentation site: [**eemeli.org/yaml**](https://eemeli.org/yaml/)
|
|
22
22
|
|
|
23
|
-
For build instructions and contribution guidelines, see [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md).
|
|
24
|
-
|
|
25
23
|
To install:
|
|
26
24
|
|
|
27
25
|
```sh
|
|
28
26
|
npm install yaml
|
|
29
|
-
# or
|
|
30
|
-
deno add jsr:@eemeli/yaml
|
|
31
27
|
```
|
|
32
28
|
|
|
33
29
|
**Note:** These docs are for `yaml@2`. For v1, see the [v1.10.0 tag](https://github.com/eemeli/yaml/tree/v1.10.0) for the source and [eemeli.org/yaml/v1](https://eemeli.org/yaml/v1/) for the documentation.
|
|
34
30
|
|
|
31
|
+
The development and maintenance of this library is [sponsored](https://github.com/sponsors/eemeli) by:
|
|
32
|
+
|
|
33
|
+
<a href="https://www.scipress.io/">
|
|
34
|
+
<img width=150 src="https://eemeli.org/yaml/images/scipress.svg" alt="Scipress" />
|
|
35
|
+
</a>
|
|
36
|
+
|
|
35
37
|
## API Overview
|
|
36
38
|
|
|
37
39
|
The API provided by `yaml` has three layers, depending on how deep you need to go: [Parse & Stringify](https://eemeli.org/yaml/#parse-amp-stringify), [Documents](https://eemeli.org/yaml/#documents), and the underlying [Lexer/Parser/Composer](https://eemeli.org/yaml/#parsing-yaml).
|
|
@@ -39,29 +41,24 @@ The first has the simplest API and "just works", the second gets you all the bel
|
|
|
39
41
|
|
|
40
42
|
A [command-line tool](https://eemeli.org/yaml/#command-line-tool) is also included.
|
|
41
43
|
|
|
42
|
-
### Parse & Stringify
|
|
43
|
-
|
|
44
44
|
```js
|
|
45
45
|
import { parse, stringify } from 'yaml'
|
|
46
|
+
// or
|
|
47
|
+
import YAML from 'yaml'
|
|
48
|
+
// or
|
|
49
|
+
const YAML = require('yaml')
|
|
46
50
|
```
|
|
47
51
|
|
|
52
|
+
### Parse & Stringify
|
|
53
|
+
|
|
48
54
|
- [`parse(str, reviver?, options?): value`](https://eemeli.org/yaml/#yaml-parse)
|
|
49
55
|
- [`stringify(value, replacer?, options?): string`](https://eemeli.org/yaml/#yaml-stringify)
|
|
50
56
|
|
|
51
57
|
### Documents
|
|
52
58
|
|
|
53
|
-
<!-- prettier-ignore -->
|
|
54
|
-
```js
|
|
55
|
-
import {
|
|
56
|
-
Document,
|
|
57
|
-
isDocument,
|
|
58
|
-
parseAllDocuments,
|
|
59
|
-
parseDocument
|
|
60
|
-
} from 'yaml'
|
|
61
|
-
```
|
|
62
|
-
|
|
63
59
|
- [`Document`](https://eemeli.org/yaml/#documents)
|
|
64
60
|
- [`constructor(value, replacer?, options?)`](https://eemeli.org/yaml/#creating-documents)
|
|
61
|
+
- [`#anchors`](https://eemeli.org/yaml/#working-with-anchors)
|
|
65
62
|
- [`#contents`](https://eemeli.org/yaml/#content-nodes)
|
|
66
63
|
- [`#directives`](https://eemeli.org/yaml/#stream-directives)
|
|
67
64
|
- [`#errors`](https://eemeli.org/yaml/#errors)
|
|
@@ -72,15 +69,6 @@ import {
|
|
|
72
69
|
|
|
73
70
|
### Content Nodes
|
|
74
71
|
|
|
75
|
-
<!-- prettier-ignore -->
|
|
76
|
-
```js
|
|
77
|
-
import {
|
|
78
|
-
isAlias, isCollection, isMap, isNode,
|
|
79
|
-
isPair, isScalar, isSeq, Scalar,
|
|
80
|
-
visit, visitAsync, YAMLMap, YAMLSeq
|
|
81
|
-
} from 'yaml'
|
|
82
|
-
```
|
|
83
|
-
|
|
84
72
|
- [`isAlias(foo): boolean`](https://eemeli.org/yaml/#identifying-node-types)
|
|
85
73
|
- [`isCollection(foo): boolean`](https://eemeli.org/yaml/#identifying-node-types)
|
|
86
74
|
- [`isMap(foo): boolean`](https://eemeli.org/yaml/#identifying-node-types)
|
|
@@ -91,18 +79,13 @@ import {
|
|
|
91
79
|
- [`new Scalar(value)`](https://eemeli.org/yaml/#scalar-values)
|
|
92
80
|
- [`new YAMLMap()`](https://eemeli.org/yaml/#collections)
|
|
93
81
|
- [`new YAMLSeq()`](https://eemeli.org/yaml/#collections)
|
|
94
|
-
- [`doc.createAlias(node, name?): Alias`](https://eemeli.org/yaml/#
|
|
82
|
+
- [`doc.createAlias(node, name?): Alias`](https://eemeli.org/yaml/#working-with-anchors)
|
|
95
83
|
- [`doc.createNode(value, options?): Node`](https://eemeli.org/yaml/#creating-nodes)
|
|
96
84
|
- [`doc.createPair(key, value): Pair`](https://eemeli.org/yaml/#creating-nodes)
|
|
97
85
|
- [`visit(node, visitor)`](https://eemeli.org/yaml/#finding-and-modifying-nodes)
|
|
98
|
-
- [`visitAsync(node, visitor)`](https://eemeli.org/yaml/#finding-and-modifying-nodes)
|
|
99
86
|
|
|
100
87
|
### Parsing YAML
|
|
101
88
|
|
|
102
|
-
```js
|
|
103
|
-
import { Composer, Lexer, Parser } from 'yaml'
|
|
104
|
-
```
|
|
105
|
-
|
|
106
89
|
- [`new Lexer().lex(src)`](https://eemeli.org/yaml/#lexer)
|
|
107
90
|
- [`new Parser(onNewLine?).parse(src)`](https://eemeli.org/yaml/#parser)
|
|
108
91
|
- [`new Composer(options?).compose(tokens)`](https://eemeli.org/yaml/#composer)
|
|
@@ -59,13 +59,13 @@ function composeCollection(CN, ctx, token, props, onError) {
|
|
|
59
59
|
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
|
|
60
60
|
if (!tag) {
|
|
61
61
|
const kt = ctx.schema.knownTags[tagName];
|
|
62
|
-
if (kt
|
|
62
|
+
if (kt && kt.collection === expType) {
|
|
63
63
|
ctx.schema.tags.push(Object.assign({}, kt, { default: false }));
|
|
64
64
|
tag = kt;
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
67
|
-
if (kt) {
|
|
68
|
-
onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection
|
|
67
|
+
if (kt?.collection) {
|
|
68
|
+
onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection}`, true);
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
71
71
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, true);
|
|
@@ -7,7 +7,6 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
|
|
|
7
7
|
const opts = Object.assign({ _directives: directives }, options);
|
|
8
8
|
const doc = new Document(undefined, opts);
|
|
9
9
|
const ctx = {
|
|
10
|
-
atKey: false,
|
|
11
10
|
atRoot: true,
|
|
12
11
|
directives: doc.directives,
|
|
13
12
|
options: doc.options,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Alias } from '../nodes/Alias.js';
|
|
2
|
-
import { isScalar } from '../nodes/identity.js';
|
|
3
2
|
import { composeCollection } from './compose-collection.js';
|
|
4
3
|
import { composeScalar } from './compose-scalar.js';
|
|
5
4
|
import { resolveEnd } from './resolve-end.js';
|
|
@@ -7,7 +6,6 @@ import { emptyScalarPosition } from './util-empty-scalar-position.js';
|
|
|
7
6
|
|
|
8
7
|
const CN = { composeNode, composeEmptyNode };
|
|
9
8
|
function composeNode(ctx, token, props, onError) {
|
|
10
|
-
const atKey = ctx.atKey;
|
|
11
9
|
const { spaceBefore, comment, anchor, tag } = props;
|
|
12
10
|
let node;
|
|
13
11
|
let isSrcToken = true;
|
|
@@ -28,36 +26,21 @@ function composeNode(ctx, token, props, onError) {
|
|
|
28
26
|
case 'block-map':
|
|
29
27
|
case 'block-seq':
|
|
30
28
|
case 'flow-collection':
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
node.anchor = anchor.source.substring(1);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
// Almost certainly here due to a stack overflow
|
|
38
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
39
|
-
onError(token, 'RESOURCE_EXHAUSTION', message);
|
|
40
|
-
}
|
|
29
|
+
node = composeCollection(CN, ctx, token, props, onError);
|
|
30
|
+
if (anchor)
|
|
31
|
+
node.anchor = anchor.source.substring(1);
|
|
41
32
|
break;
|
|
42
33
|
default: {
|
|
43
34
|
const message = token.type === 'error'
|
|
44
35
|
? token.message
|
|
45
36
|
: `Unsupported token (type: ${token.type})`;
|
|
46
37
|
onError(token, 'UNEXPECTED_TOKEN', message);
|
|
38
|
+
node = composeEmptyNode(ctx, token.offset, undefined, null, props, onError);
|
|
47
39
|
isSrcToken = false;
|
|
48
40
|
}
|
|
49
41
|
}
|
|
50
|
-
node ?? (node = composeEmptyNode(ctx, token.offset, undefined, null, props, onError));
|
|
51
42
|
if (anchor && node.anchor === '')
|
|
52
43
|
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
53
|
-
if (atKey &&
|
|
54
|
-
ctx.options.stringKeys &&
|
|
55
|
-
(!isScalar(node) ||
|
|
56
|
-
typeof node.value !== 'string' ||
|
|
57
|
-
(node.tag && node.tag !== 'tag:yaml.org,2002:str'))) {
|
|
58
|
-
const msg = 'With stringKeys, all keys must be strings';
|
|
59
|
-
onError(tag ?? token, 'NON_STRING_KEY', msg);
|
|
60
|
-
}
|
|
61
44
|
if (spaceBefore)
|
|
62
45
|
node.spaceBefore = true;
|
|
63
46
|
if (comment) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SCALAR, isScalar } from '../nodes/identity.js';
|
|
2
2
|
import { Scalar } from '../nodes/Scalar.js';
|
|
3
3
|
import { resolveBlockScalar } from './resolve-block-scalar.js';
|
|
4
4
|
import { resolveFlowScalar } from './resolve-flow-scalar.js';
|
|
@@ -10,16 +10,11 @@ function composeScalar(ctx, token, tagToken, onError) {
|
|
|
10
10
|
const tagName = tagToken
|
|
11
11
|
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
|
|
12
12
|
: null;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
|
|
19
|
-
else if (token.type === 'scalar')
|
|
20
|
-
tag = findScalarTagByTest(ctx, value, token, onError);
|
|
21
|
-
else
|
|
22
|
-
tag = ctx.schema[SCALAR];
|
|
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];
|
|
23
18
|
let scalar;
|
|
24
19
|
try {
|
|
25
20
|
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
@@ -67,9 +62,8 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
|
67
62
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
|
|
68
63
|
return schema[SCALAR];
|
|
69
64
|
}
|
|
70
|
-
function findScalarTagByTest({
|
|
71
|
-
const tag = schema.tags.find(tag =>
|
|
72
|
-
tag.test?.test(value)) || schema[SCALAR];
|
|
65
|
+
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
66
|
+
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[SCALAR];
|
|
73
67
|
if (schema.compat) {
|
|
74
68
|
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
|
75
69
|
schema[SCALAR];
|
|
@@ -94,10 +94,8 @@ class Composer {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
if (afterDoc) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
for (let i = 0; i < this.warnings.length; ++i)
|
|
100
|
-
doc.warnings.push(this.warnings[i]);
|
|
97
|
+
Array.prototype.push.apply(doc.errors, this.errors);
|
|
98
|
+
Array.prototype.push.apply(doc.warnings, this.warnings);
|
|
101
99
|
}
|
|
102
100
|
else {
|
|
103
101
|
doc.errors = this.errors;
|
|
@@ -50,14 +50,12 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
|
|
|
50
50
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
51
51
|
}
|
|
52
52
|
// key value
|
|
53
|
-
ctx.atKey = true;
|
|
54
53
|
const keyStart = keyProps.end;
|
|
55
54
|
const keyNode = key
|
|
56
55
|
? composeNode(ctx, key, keyProps, onError)
|
|
57
56
|
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
|
|
58
57
|
if (ctx.schema.compat)
|
|
59
58
|
flowIndentCheck(bm.indent, key, onError);
|
|
60
|
-
ctx.atKey = false;
|
|
61
59
|
if (mapIncludes(ctx, map.items, keyNode))
|
|
62
60
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
63
61
|
// value properties
|
|
@@ -7,8 +7,6 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
|
|
|
7
7
|
const seq = new NodeClass(ctx.schema);
|
|
8
8
|
if (ctx.atRoot)
|
|
9
9
|
ctx.atRoot = false;
|
|
10
|
-
if (ctx.atKey)
|
|
11
|
-
ctx.atKey = false;
|
|
12
10
|
let offset = bs.offset;
|
|
13
11
|
let commentEnd = null;
|
|
14
12
|
for (const { start, value } of bs.items) {
|
|
@@ -22,7 +20,7 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
|
|
|
22
20
|
});
|
|
23
21
|
if (!props.found) {
|
|
24
22
|
if (props.anchor || props.tag || value) {
|
|
25
|
-
if (value
|
|
23
|
+
if (value && value.type === 'block-seq')
|
|
26
24
|
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
|
27
25
|
else
|
|
28
26
|
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
|
@@ -18,8 +18,6 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
18
18
|
const atRoot = ctx.atRoot;
|
|
19
19
|
if (atRoot)
|
|
20
20
|
ctx.atRoot = false;
|
|
21
|
-
if (ctx.atKey)
|
|
22
|
-
ctx.atKey = false;
|
|
23
21
|
let offset = fc.offset + fc.start.source.length;
|
|
24
22
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
25
23
|
const collItem = fc.items[i];
|
|
@@ -99,14 +97,12 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
99
97
|
else {
|
|
100
98
|
// item is a key+value pair
|
|
101
99
|
// key value
|
|
102
|
-
ctx.atKey = true;
|
|
103
100
|
const keyStart = props.end;
|
|
104
101
|
const keyNode = key
|
|
105
102
|
? composeNode(ctx, key, props, onError)
|
|
106
103
|
: composeEmptyNode(ctx, keyStart, start, null, props, onError);
|
|
107
104
|
if (isBlock(key))
|
|
108
105
|
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
|
|
109
|
-
ctx.atKey = false;
|
|
110
106
|
// value properties
|
|
111
107
|
const valueProps = resolveProps(sep ?? [], {
|
|
112
108
|
flow: fcName,
|
|
@@ -133,7 +129,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
133
129
|
}
|
|
134
130
|
}
|
|
135
131
|
else if (value) {
|
|
136
|
-
if ('source' in value && value.source
|
|
132
|
+
if ('source' in value && value.source && value.source[0] === ':')
|
|
137
133
|
onError(value, 'MISSING_CHAR', `Missing space after : in ${fcName}`);
|
|
138
134
|
else
|
|
139
135
|
onError(valueProps.start, 'MISSING_CHAR', `Missing , or : between ${fcName} items`);
|
|
@@ -167,8 +163,6 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
167
163
|
const map = new YAMLMap(ctx.schema);
|
|
168
164
|
map.flow = true;
|
|
169
165
|
map.items.push(pair);
|
|
170
|
-
const endRange = (valueNode ?? keyNode).range;
|
|
171
|
-
map.range = [keyNode.range[0], endRange[1], endRange[2]];
|
|
172
166
|
coll.items.push(map);
|
|
173
167
|
}
|
|
174
168
|
offset = valueNode ? valueNode.range[2] : valueProps.end;
|
|
@@ -177,7 +171,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
177
171
|
const expectedEnd = isMap ? '}' : ']';
|
|
178
172
|
const [ce, ...ee] = fc.end;
|
|
179
173
|
let cePos = offset;
|
|
180
|
-
if (ce
|
|
174
|
+
if (ce && ce.source === expectedEnd)
|
|
181
175
|
cePos = ce.offset + ce.source.length;
|
|
182
176
|
else {
|
|
183
177
|
const name = fcName[0].toUpperCase() + fcName.substring(1);
|
|
@@ -84,7 +84,7 @@ function foldLines(source) {
|
|
|
84
84
|
first = new RegExp('(.*?)(?<![ \t])[ \t]*\r?\n', 'sy');
|
|
85
85
|
line = new RegExp('[ \t]*(.*?)(?:(?<![ \t])[ \t]*)?\r?\n', 'sy');
|
|
86
86
|
}
|
|
87
|
-
catch {
|
|
87
|
+
catch (_) {
|
|
88
88
|
first = /(.*?)[ \t]*\r?\n/sy;
|
|
89
89
|
line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
|
|
90
90
|
}
|
|
@@ -142,7 +142,7 @@ function doubleQuotedValue(source, onError) {
|
|
|
142
142
|
next = source[++i + 1];
|
|
143
143
|
}
|
|
144
144
|
else if (next === 'x' || next === 'u' || next === 'U') {
|
|
145
|
-
const length =
|
|
145
|
+
const length = { x: 2, u: 4, U: 8 }[next];
|
|
146
146
|
res += parseCharCode(source, i + 1, length, onError);
|
|
147
147
|
i += length;
|
|
148
148
|
}
|
|
@@ -212,14 +212,12 @@ function parseCharCode(source, offset, length, onError) {
|
|
|
212
212
|
const cc = source.substr(offset, length);
|
|
213
213
|
const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
|
|
214
214
|
const code = ok ? parseInt(cc, 16) : NaN;
|
|
215
|
-
|
|
216
|
-
return String.fromCodePoint(code);
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
215
|
+
if (isNaN(code)) {
|
|
219
216
|
const raw = source.substr(offset - 2, length + 2);
|
|
220
217
|
onError(offset - 2, 'BAD_DQ_ESCAPE', `Invalid escape sequence ${raw}`);
|
|
221
218
|
return raw;
|
|
222
219
|
}
|
|
220
|
+
return String.fromCodePoint(code);
|
|
223
221
|
}
|
|
224
222
|
|
|
225
223
|
export { resolveFlowScalar };
|
|
@@ -55,7 +55,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
|
|
|
55
55
|
if (atNewline) {
|
|
56
56
|
if (comment)
|
|
57
57
|
comment += token.source;
|
|
58
|
-
else
|
|
58
|
+
else
|
|
59
59
|
spaceBefore = true;
|
|
60
60
|
}
|
|
61
61
|
else
|
|
@@ -72,7 +72,8 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
|
|
|
72
72
|
if (token.source.endsWith(':'))
|
|
73
73
|
onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true);
|
|
74
74
|
anchor = token;
|
|
75
|
-
|
|
75
|
+
if (start === null)
|
|
76
|
+
start = token.offset;
|
|
76
77
|
atNewline = false;
|
|
77
78
|
hasSpace = false;
|
|
78
79
|
reqSpace = true;
|
|
@@ -81,7 +82,8 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
|
|
|
81
82
|
if (tag)
|
|
82
83
|
onError(token, 'MULTIPLE_TAGS', 'A node can have at most one tag');
|
|
83
84
|
tag = token;
|
|
84
|
-
|
|
85
|
+
if (start === null)
|
|
86
|
+
start = token.offset;
|
|
85
87
|
atNewline = false;
|
|
86
88
|
hasSpace = false;
|
|
87
89
|
reqSpace = true;
|
|
@@ -6,7 +6,11 @@ function mapIncludes(ctx, items, search) {
|
|
|
6
6
|
return false;
|
|
7
7
|
const isEqual = typeof uniqueKeys === 'function'
|
|
8
8
|
? uniqueKeys
|
|
9
|
-
: (a, b) => a === b ||
|
|
9
|
+
: (a, b) => a === b ||
|
|
10
|
+
(isScalar(a) &&
|
|
11
|
+
isScalar(b) &&
|
|
12
|
+
a.value === b.value &&
|
|
13
|
+
!(a.value === '<<' && ctx.schema.merge));
|
|
10
14
|
return items.some(pair => isEqual(pair.key, search));
|
|
11
15
|
}
|
|
12
16
|
|
|
@@ -35,7 +35,6 @@ class Document {
|
|
|
35
35
|
logLevel: 'warn',
|
|
36
36
|
prettyErrors: true,
|
|
37
37
|
strict: true,
|
|
38
|
-
stringKeys: false,
|
|
39
38
|
uniqueKeys: true,
|
|
40
39
|
version: '1.2'
|
|
41
40
|
}, options);
|
|
@@ -259,7 +258,7 @@ class Document {
|
|
|
259
258
|
this.directives.yaml.version = '1.1';
|
|
260
259
|
else
|
|
261
260
|
this.directives = new Directives({ version: '1.1' });
|
|
262
|
-
opt = { resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
261
|
+
opt = { merge: true, resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
263
262
|
break;
|
|
264
263
|
case '1.2':
|
|
265
264
|
case 'next':
|
|
@@ -267,7 +266,7 @@ class Document {
|
|
|
267
266
|
this.directives.yaml.version = version;
|
|
268
267
|
else
|
|
269
268
|
this.directives = new Directives({ version });
|
|
270
|
-
opt = { resolveKnownTags: true, schema: 'core' };
|
|
269
|
+
opt = { merge: false, resolveKnownTags: true, schema: 'core' };
|
|
271
270
|
break;
|
|
272
271
|
case null:
|
|
273
272
|
if (this.directives)
|
|
@@ -39,7 +39,8 @@ function createNodeAnchors(doc, prefix) {
|
|
|
39
39
|
return {
|
|
40
40
|
onAnchor: (source) => {
|
|
41
41
|
aliasObjects.push(source);
|
|
42
|
-
|
|
42
|
+
if (!prevAnchors)
|
|
43
|
+
prevAnchors = anchorNames(doc);
|
|
43
44
|
const anchor = findNewAnchor(prefix, prevAnchors);
|
|
44
45
|
prevAnchors.add(anchor);
|
|
45
46
|
return anchor;
|
|
@@ -11,7 +11,6 @@ function applyReviver(reviver, obj, key, val) {
|
|
|
11
11
|
for (let i = 0, len = val.length; i < len; ++i) {
|
|
12
12
|
const v0 = val[i];
|
|
13
13
|
const v1 = applyReviver(reviver, val, String(i), v0);
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-array-delete
|
|
15
14
|
if (v1 === undefined)
|
|
16
15
|
delete val[i];
|
|
17
16
|
else if (v1 !== v0)
|
|
@@ -38,7 +38,8 @@ function createNode(value, tagName, ctx) {
|
|
|
38
38
|
if (aliasDuplicateObjects && value && typeof value === 'object') {
|
|
39
39
|
ref = sourceObjects.get(value);
|
|
40
40
|
if (ref) {
|
|
41
|
-
|
|
41
|
+
if (!ref.anchor)
|
|
42
|
+
ref.anchor = onAnchor(value);
|
|
42
43
|
return new Alias(ref.anchor);
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
@@ -46,7 +46,7 @@ const prettifyError = (src, lc) => (error) => {
|
|
|
46
46
|
if (/[^ ]/.test(lineStr)) {
|
|
47
47
|
let count = 1;
|
|
48
48
|
const end = error.linePos[1];
|
|
49
|
-
if (end
|
|
49
|
+
if (end && end.line === line && end.col > col) {
|
|
50
50
|
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
51
51
|
}
|
|
52
52
|
const pointer = ' '.repeat(ci) + '^'.repeat(count);
|
|
@@ -4,7 +4,12 @@ function debug(logLevel, ...messages) {
|
|
|
4
4
|
}
|
|
5
5
|
function warn(logLevel, warning) {
|
|
6
6
|
if (logLevel === 'debug' || logLevel === 'warn') {
|
|
7
|
-
|
|
7
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/7478
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
|
9
|
+
if (typeof process !== 'undefined' && process.emitWarning)
|
|
10
|
+
process.emitWarning(warning);
|
|
11
|
+
else
|
|
12
|
+
console.warn(warning);
|
|
8
13
|
}
|
|
9
14
|
}
|
|
10
15
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
16
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
17
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
18
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { __classPrivateFieldGet };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { anchorIsValid } from '../doc/anchors.js';
|
|
2
2
|
import { visit } from '../visit.js';
|
|
3
|
-
import { ALIAS, isAlias, isCollection, isPair
|
|
3
|
+
import { ALIAS, isAlias, isCollection, isPair } from './identity.js';
|
|
4
4
|
import { NodeBase } from './Node.js';
|
|
5
5
|
import { toJS } from './toJS.js';
|
|
6
6
|
|
|
@@ -18,38 +18,23 @@ class Alias extends NodeBase {
|
|
|
18
18
|
* Resolve the value of this alias within `doc`, finding the last
|
|
19
19
|
* instance of the `source` anchor before this node.
|
|
20
20
|
*/
|
|
21
|
-
resolve(doc
|
|
22
|
-
if (ctx?.maxAliasCount === 0)
|
|
23
|
-
throw new ReferenceError('Alias resolution is disabled');
|
|
24
|
-
let nodes;
|
|
25
|
-
if (ctx?.aliasResolveCache) {
|
|
26
|
-
nodes = ctx.aliasResolveCache;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
nodes = [];
|
|
30
|
-
visit(doc, {
|
|
31
|
-
Node: (_key, node) => {
|
|
32
|
-
if (isAlias(node) || hasAnchor(node))
|
|
33
|
-
nodes.push(node);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
if (ctx)
|
|
37
|
-
ctx.aliasResolveCache = nodes;
|
|
38
|
-
}
|
|
21
|
+
resolve(doc) {
|
|
39
22
|
let found = undefined;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
visit(doc, {
|
|
24
|
+
Node: (_key, node) => {
|
|
25
|
+
if (node === this)
|
|
26
|
+
return visit.BREAK;
|
|
27
|
+
if (node.anchor === this.source)
|
|
28
|
+
found = node;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
46
31
|
return found;
|
|
47
32
|
}
|
|
48
33
|
toJSON(_arg, ctx) {
|
|
49
34
|
if (!ctx)
|
|
50
35
|
return { source: this.source };
|
|
51
36
|
const { anchors, doc, maxAliasCount } = ctx;
|
|
52
|
-
const source = this.resolve(doc
|
|
37
|
+
const source = this.resolve(doc);
|
|
53
38
|
if (!source) {
|
|
54
39
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
55
40
|
throw new ReferenceError(msg);
|
|
@@ -61,7 +46,7 @@ class Alias extends NodeBase {
|
|
|
61
46
|
data = anchors.get(source);
|
|
62
47
|
}
|
|
63
48
|
/* istanbul ignore if */
|
|
64
|
-
if (data
|
|
49
|
+
if (!data || data.res === undefined) {
|
|
65
50
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
66
51
|
throw new ReferenceError(msg);
|
|
67
52
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { stringifyCollection } from '../stringify/stringifyCollection.js';
|
|
2
2
|
import { addPairToJSMap } from './addPairToJSMap.js';
|
|
3
3
|
import { Collection } from './Collection.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isPair, isScalar, MAP } from './identity.js';
|
|
5
5
|
import { Pair, createPair } from './Pair.js';
|
|
6
6
|
import { isScalarValue } from './Scalar.js';
|
|
7
7
|
|