@speclynx/apidom-parser-adapter-yaml-1-2 4.0.3 → 4.0.5
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/CHANGELOG.md +10 -0
- package/package.json +7 -6
- package/src/adapter.ts +0 -75
- package/src/media-types.ts +0 -17
- package/src/tree-sitter/index.ts +0 -46
- package/src/tree-sitter/lexical-analysis/index.ts +0 -49
- package/src/tree-sitter/lexical-analysis/tree-sitter-yaml.wasm +0 -0
- package/src/tree-sitter/syntactic-analysis/CstTransformer.ts +0 -840
- package/src/tree-sitter/syntactic-analysis/YamlAstTransformer.ts +0 -602
- package/src/tree-sitter/syntactic-analysis/ast/Error.ts +0 -29
- package/src/tree-sitter/syntactic-analysis/ast/Literal.ts +0 -25
- package/src/tree-sitter/syntactic-analysis/ast/Node.ts +0 -78
- package/src/tree-sitter/syntactic-analysis/ast/ParseResult.ts +0 -16
- package/src/tree-sitter/syntactic-analysis/ast/anchors-aliases/ReferenceManager.ts +0 -23
- package/src/tree-sitter/syntactic-analysis/ast/errors/YamlError.ts +0 -8
- package/src/tree-sitter/syntactic-analysis/ast/errors/YamlSchemaError.ts +0 -8
- package/src/tree-sitter/syntactic-analysis/ast/errors/YamlTagError.ts +0 -68
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlAlias.ts +0 -25
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlAnchor.ts +0 -25
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlCollection.ts +0 -8
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlComment.ts +0 -25
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlDirective.ts +0 -47
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlDocument.ts +0 -10
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlKeyValuePair.ts +0 -52
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlMapping.ts +0 -19
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlNode.ts +0 -42
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlScalar.ts +0 -27
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlSequence.ts +0 -27
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlStream.ts +0 -22
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlStyle.ts +0 -22
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlTag.ts +0 -38
- package/src/tree-sitter/syntactic-analysis/ast/nodes/predicates.ts +0 -16
- package/src/tree-sitter/syntactic-analysis/ast/schemas/ScalarTag.ts +0 -42
- package/src/tree-sitter/syntactic-analysis/ast/schemas/Tag.ts +0 -20
- package/src/tree-sitter/syntactic-analysis/ast/schemas/canonical-format.ts +0 -185
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/GenericMapping.ts +0 -12
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/GenericSequence.ts +0 -12
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/GenericString.ts +0 -7
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/index.ts +0 -126
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/Boolean.ts +0 -20
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/FloatingPoint.ts +0 -20
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/Integer.ts +0 -20
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/Null.ts +0 -19
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/index.ts +0 -43
- package/src/tree-sitter/syntactic-analysis/index.ts +0 -36
- package/src/wasm.d.ts +0 -18
- package/src/yaml/index.ts +0 -53
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.0.5](https://github.com/speclynx/apidom/compare/v4.0.4...v4.0.5) (2026-03-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @speclynx/apidom-parser-adapter-yaml-1-2
|
|
9
|
+
|
|
10
|
+
## [4.0.4](https://github.com/speclynx/apidom/compare/v4.0.3...v4.0.4) (2026-03-12)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **release:** override minimatch 10.2.3 to fix glob pattern regression in lerna publish ([#157](https://github.com/speclynx/apidom/issues/157)) ([c2d65a0](https://github.com/speclynx/apidom/commit/c2d65a06a2187e8563a9dc9db74ba27255450e0b)), closes [lerna/lerna#4305](https://github.com/lerna/lerna/issues/4305) [isaacs/minimatch#284](https://github.com/isaacs/minimatch/issues/284)
|
|
15
|
+
|
|
6
16
|
## [4.0.3](https://github.com/speclynx/apidom/compare/v4.0.2...v4.0.3) (2026-03-11)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-parser-adapter-yaml-1-2",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"description": "Parser adapter for parsing YAML documents into base namespace.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apidom",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"license": "Apache-2.0",
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@babel/runtime-corejs3": "^7.28.4",
|
|
61
|
-
"@speclynx/apidom-core": "4.0.
|
|
62
|
-
"@speclynx/apidom-datamodel": "4.0.
|
|
63
|
-
"@speclynx/apidom-error": "4.0.
|
|
61
|
+
"@speclynx/apidom-core": "4.0.5",
|
|
62
|
+
"@speclynx/apidom-datamodel": "4.0.5",
|
|
63
|
+
"@speclynx/apidom-error": "4.0.5",
|
|
64
64
|
"ramda": "~0.32.0",
|
|
65
65
|
"ramda-adjunct": "^6.0.0",
|
|
66
66
|
"unraw": "^3.0.0",
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
"@types/emscripten": "^1.41.2"
|
|
72
72
|
},
|
|
73
73
|
"files": [
|
|
74
|
-
"src
|
|
74
|
+
"src/**/*.mjs",
|
|
75
|
+
"src/**/*.cjs",
|
|
75
76
|
"dist/",
|
|
76
77
|
"types/apidom-parser-adapter-yaml-1-2.d.ts",
|
|
77
78
|
"LICENSES",
|
|
@@ -79,5 +80,5 @@
|
|
|
79
80
|
"README.md",
|
|
80
81
|
"CHANGELOG.md"
|
|
81
82
|
],
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "5a85d2a832eeefb07d03760faa391b457447e966"
|
|
83
84
|
}
|
package/src/adapter.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { ParseResultElement, Namespace } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { UnsupportedOperationError } from '@speclynx/apidom-error';
|
|
3
|
-
|
|
4
|
-
import * as yaml from './yaml/index.ts';
|
|
5
|
-
import * as treeSitter from './tree-sitter/index.ts';
|
|
6
|
-
|
|
7
|
-
export type { YamlMediaTypes } from './media-types.ts';
|
|
8
|
-
export type { Tree } from './tree-sitter/index.ts';
|
|
9
|
-
|
|
10
|
-
export { lexicalAnalysis, syntacticAnalysis } from './tree-sitter/index.ts';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export { default as mediaTypes } from './media-types.ts';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
export const namespace = new Namespace();
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
export interface ParseDetectOptions {
|
|
26
|
-
strict?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export const detect = async (
|
|
33
|
-
source: string,
|
|
34
|
-
{ strict = false }: ParseDetectOptions = {},
|
|
35
|
-
): Promise<boolean> => {
|
|
36
|
-
if (strict) {
|
|
37
|
-
return yaml.detect(source);
|
|
38
|
-
}
|
|
39
|
-
return treeSitter.detect(source);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @public
|
|
44
|
-
*/
|
|
45
|
-
export interface ParseOptions {
|
|
46
|
-
sourceMap?: boolean;
|
|
47
|
-
style?: boolean;
|
|
48
|
-
strict?: boolean;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @public
|
|
53
|
-
*/
|
|
54
|
-
export const parse = async (
|
|
55
|
-
source: string,
|
|
56
|
-
{ sourceMap = false, style = false, strict = false }: ParseOptions = {},
|
|
57
|
-
): Promise<ParseResultElement> => {
|
|
58
|
-
if (strict && sourceMap) {
|
|
59
|
-
throw new UnsupportedOperationError(
|
|
60
|
-
'Cannot use sourceMap with strict parsing. Strict parsing does not support source maps.',
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (strict && style) {
|
|
65
|
-
throw new UnsupportedOperationError(
|
|
66
|
-
'Cannot use style with strict parsing. Strict parsing does not support style preservation.',
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (strict) {
|
|
71
|
-
return yaml.parse(source);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return treeSitter.parse(source, { sourceMap, style });
|
|
75
|
-
};
|
package/src/media-types.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MediaTypes } from '@speclynx/apidom-core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export class YamlMediaTypes extends MediaTypes<string> {
|
|
7
|
-
latest() {
|
|
8
|
-
return this[1];
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
const mediaTypes = new YamlMediaTypes('text/yaml', 'application/yaml');
|
|
16
|
-
|
|
17
|
-
export default mediaTypes;
|
package/src/tree-sitter/index.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ParseResultElement } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import type { Tree } from 'web-tree-sitter';
|
|
3
|
-
|
|
4
|
-
import lexicalAnalysis from './lexical-analysis/index.ts';
|
|
5
|
-
import syntacticAnalysis from './syntactic-analysis/index.ts';
|
|
6
|
-
|
|
7
|
-
export type { Tree };
|
|
8
|
-
export { lexicalAnalysis, syntacticAnalysis };
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export const detect = async (source: string): Promise<boolean> => {
|
|
14
|
-
let cst: Tree | null = null;
|
|
15
|
-
try {
|
|
16
|
-
cst = await lexicalAnalysis(source);
|
|
17
|
-
return !cst.rootNode.isError;
|
|
18
|
-
} catch {
|
|
19
|
-
return false;
|
|
20
|
-
} finally {
|
|
21
|
-
cst?.delete();
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
export interface ParseOptions {
|
|
29
|
-
sourceMap?: boolean;
|
|
30
|
-
style?: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @public
|
|
35
|
-
*/
|
|
36
|
-
export const parse = async (
|
|
37
|
-
source: string,
|
|
38
|
-
{ sourceMap = false, style = false }: ParseOptions = {},
|
|
39
|
-
): Promise<ParseResultElement> => {
|
|
40
|
-
const cst = await lexicalAnalysis(source);
|
|
41
|
-
try {
|
|
42
|
-
return syntacticAnalysis(cst, { sourceMap, style });
|
|
43
|
-
} finally {
|
|
44
|
-
cst.delete();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Parser, Tree, Language } from 'web-tree-sitter';
|
|
2
|
-
import treeSitter from 'web-tree-sitter/web-tree-sitter.wasm';
|
|
3
|
-
import { ApiDOMError } from '@speclynx/apidom-error';
|
|
4
|
-
|
|
5
|
-
import treeSitterYaml from './tree-sitter-yaml.wasm';
|
|
6
|
-
|
|
7
|
-
let parser: Parser | null = null;
|
|
8
|
-
let parserInitLock: Promise<Parser> | null = null;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Lexical Analysis of source string using WebTreeSitter.
|
|
12
|
-
* This is WebAssembly version of TreeSitters Lexical Analysis.
|
|
13
|
-
*
|
|
14
|
-
* Given JavaScript doesn't support true parallelism, this
|
|
15
|
-
* code should be as lazy as possible and temporal safety should be fine.
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
const analyze = async (source: string): Promise<Tree> => {
|
|
20
|
-
if (parser === null && parserInitLock === null) {
|
|
21
|
-
// acquire lock
|
|
22
|
-
parserInitLock = Parser.init({
|
|
23
|
-
wasmBinary: treeSitter,
|
|
24
|
-
locateFile: (scriptName: string) => scriptName,
|
|
25
|
-
} as unknown as EmscriptenModule)
|
|
26
|
-
.then(() => Language.load(treeSitterYaml))
|
|
27
|
-
.then((yamlLanguage) => {
|
|
28
|
-
const parserInstance = new Parser();
|
|
29
|
-
parserInstance.setLanguage(yamlLanguage);
|
|
30
|
-
return parserInstance;
|
|
31
|
-
})
|
|
32
|
-
.finally(() => {
|
|
33
|
-
// release lock
|
|
34
|
-
parserInitLock = null;
|
|
35
|
-
});
|
|
36
|
-
parser = await parserInitLock;
|
|
37
|
-
} else if (parser === null && parserInitLock !== null) {
|
|
38
|
-
// await for lock to be released if there is one
|
|
39
|
-
parser = await parserInitLock;
|
|
40
|
-
} else if (parser === null) {
|
|
41
|
-
throw new ApiDOMError(
|
|
42
|
-
'Error while initializing web-tree-sitter and loading tree-sitter-yaml grammar.',
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return parser.parse(source) as Tree;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default analyze;
|
|
Binary file
|