@speclynx/apidom-parser-adapter-json 3.2.1 → 4.0.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/CHANGELOG.md +4 -0
- package/package.json +5 -5
- package/src/adapter.cjs +0 -71
- package/src/adapter.mjs +0 -61
- package/src/media-types.cjs +0 -20
- package/src/media-types.mjs +0 -16
- package/src/native/index.cjs +0 -37
- package/src/native/index.mjs +0 -32
- package/src/tree-sitter/index.cjs +0 -56
- package/src/tree-sitter/index.mjs +0 -50
- package/src/tree-sitter/lexical-analysis/index.cjs +0 -43
- package/src/tree-sitter/lexical-analysis/index.mjs +0 -39
- package/src/tree-sitter/syntactic-analysis/index.cjs +0 -280
- package/src/tree-sitter/syntactic-analysis/index.mjs +0 -276
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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.0](https://github.com/speclynx/apidom/compare/v3.2.1...v4.0.0) (2026-03-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @speclynx/apidom-parser-adapter-json
|
|
9
|
+
|
|
6
10
|
## [3.2.1](https://github.com/speclynx/apidom/compare/v3.2.0...v3.2.1) (2026-03-09)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @speclynx/apidom-parser-adapter-json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-parser-adapter-json",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Parser adapter for parsing JSON 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": "
|
|
62
|
-
"@speclynx/apidom-datamodel": "
|
|
63
|
-
"@speclynx/apidom-error": "
|
|
61
|
+
"@speclynx/apidom-core": "4.0.0",
|
|
62
|
+
"@speclynx/apidom-datamodel": "4.0.0",
|
|
63
|
+
"@speclynx/apidom-error": "4.0.0",
|
|
64
64
|
"web-tree-sitter": "=0.26.6"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"README.md",
|
|
78
78
|
"CHANGELOG.md"
|
|
79
79
|
],
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "384ff82a1bb68d015fd6801de641898b4b582876"
|
|
81
81
|
}
|
package/src/adapter.cjs
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
5
|
-
exports.__esModule = true;
|
|
6
|
-
exports.syntacticAnalysis = exports.parse = exports.namespace = exports.mediaTypes = exports.lexicalAnalysis = exports.detectionRegExp = exports.detect = void 0;
|
|
7
|
-
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
8
|
-
var _apidomError = require("@speclynx/apidom-error");
|
|
9
|
-
var native = _interopRequireWildcard(require("./native/index.cjs"));
|
|
10
|
-
var treeSitter = _interopRequireWildcard(require("./tree-sitter/index.cjs"));
|
|
11
|
-
exports.lexicalAnalysis = treeSitter.lexicalAnalysis;
|
|
12
|
-
exports.syntacticAnalysis = treeSitter.syntacticAnalysis;
|
|
13
|
-
var _mediaTypes = _interopRequireDefault(require("./media-types.cjs"));
|
|
14
|
-
exports.mediaTypes = _mediaTypes.default;
|
|
15
|
-
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
const namespace = exports.namespace = new _apidomDatamodel.Namespace();
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
const detectionRegExp = exports.detectionRegExp = treeSitter.detectionRegExp;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @public
|
|
35
|
-
*/
|
|
36
|
-
const detect = async (source, {
|
|
37
|
-
strict = false
|
|
38
|
-
} = {}) => {
|
|
39
|
-
if (strict) {
|
|
40
|
-
return native.detect(source);
|
|
41
|
-
}
|
|
42
|
-
return treeSitter.detect(source);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
exports.detect = detect;
|
|
49
|
-
/**
|
|
50
|
-
* @public
|
|
51
|
-
*/
|
|
52
|
-
const parse = async (source, {
|
|
53
|
-
sourceMap = false,
|
|
54
|
-
style = false,
|
|
55
|
-
strict = false
|
|
56
|
-
} = {}) => {
|
|
57
|
-
if (strict && sourceMap) {
|
|
58
|
-
throw new _apidomError.UnsupportedOperationError('Cannot use sourceMap with strict parsing. Strict parsing does not support source maps.');
|
|
59
|
-
}
|
|
60
|
-
if (strict && style) {
|
|
61
|
-
throw new _apidomError.UnsupportedOperationError('Cannot use style with strict parsing. Strict parsing does not support style preservation.');
|
|
62
|
-
}
|
|
63
|
-
if (strict) {
|
|
64
|
-
return native.parse(source);
|
|
65
|
-
}
|
|
66
|
-
return treeSitter.parse(source, {
|
|
67
|
-
sourceMap,
|
|
68
|
-
style
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
exports.parse = parse;
|
package/src/adapter.mjs
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Namespace } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { UnsupportedOperationError } from '@speclynx/apidom-error';
|
|
3
|
-
import * as native from "./native/index.mjs";
|
|
4
|
-
import * as treeSitter from "./tree-sitter/index.mjs";
|
|
5
|
-
export { lexicalAnalysis, syntacticAnalysis } from "./tree-sitter/index.mjs";
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export { default as mediaTypes } from "./media-types.mjs";
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export const namespace = new Namespace();
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
export const detectionRegExp = treeSitter.detectionRegExp;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
export const detect = async (source, {
|
|
28
|
-
strict = false
|
|
29
|
-
} = {}) => {
|
|
30
|
-
if (strict) {
|
|
31
|
-
return native.detect(source);
|
|
32
|
-
}
|
|
33
|
-
return treeSitter.detect(source);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @public
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export const parse = async (source, {
|
|
44
|
-
sourceMap = false,
|
|
45
|
-
style = false,
|
|
46
|
-
strict = false
|
|
47
|
-
} = {}) => {
|
|
48
|
-
if (strict && sourceMap) {
|
|
49
|
-
throw new UnsupportedOperationError('Cannot use sourceMap with strict parsing. Strict parsing does not support source maps.');
|
|
50
|
-
}
|
|
51
|
-
if (strict && style) {
|
|
52
|
-
throw new UnsupportedOperationError('Cannot use style with strict parsing. Strict parsing does not support style preservation.');
|
|
53
|
-
}
|
|
54
|
-
if (strict) {
|
|
55
|
-
return native.parse(source);
|
|
56
|
-
}
|
|
57
|
-
return treeSitter.parse(source, {
|
|
58
|
-
sourceMap,
|
|
59
|
-
style
|
|
60
|
-
});
|
|
61
|
-
};
|
package/src/media-types.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = exports.JSONMediaTypes = void 0;
|
|
5
|
-
var _apidomCore = require("@speclynx/apidom-core");
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
class JSONMediaTypes extends _apidomCore.MediaTypes {
|
|
10
|
-
latest() {
|
|
11
|
-
return this[0];
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
exports.JSONMediaTypes = JSONMediaTypes;
|
|
19
|
-
const mediaTypes = new JSONMediaTypes('application/json');
|
|
20
|
-
var _default = exports.default = mediaTypes;
|
package/src/media-types.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { MediaTypes } from '@speclynx/apidom-core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export class JSONMediaTypes extends MediaTypes {
|
|
7
|
-
latest() {
|
|
8
|
-
return this[0];
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
const mediaTypes = new JSONMediaTypes('application/json');
|
|
16
|
-
export default mediaTypes;
|
package/src/native/index.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.parse = exports.detect = void 0;
|
|
5
|
-
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
const detect = async source => {
|
|
10
|
-
if (source.trim().length === 0) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
JSON.parse(source);
|
|
15
|
-
return true;
|
|
16
|
-
} catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
exports.detect = detect;
|
|
25
|
-
const parse = async source => {
|
|
26
|
-
const parseResult = new _apidomDatamodel.ParseResultElement();
|
|
27
|
-
if (source.trim().length === 0) {
|
|
28
|
-
return parseResult;
|
|
29
|
-
}
|
|
30
|
-
let pojo = JSON.parse(source);
|
|
31
|
-
const element = (0, _apidomDatamodel.refract)(pojo);
|
|
32
|
-
pojo = null; // allow GC to reclaim POJO
|
|
33
|
-
element.classes.push('result');
|
|
34
|
-
parseResult.push(element);
|
|
35
|
-
return parseResult;
|
|
36
|
-
};
|
|
37
|
-
exports.parse = parse;
|
package/src/native/index.mjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ParseResultElement, refract } from '@speclynx/apidom-datamodel';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export const detect = async source => {
|
|
7
|
-
if (source.trim().length === 0) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
try {
|
|
11
|
-
JSON.parse(source);
|
|
12
|
-
return true;
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
export const parse = async source => {
|
|
22
|
-
const parseResult = new ParseResultElement();
|
|
23
|
-
if (source.trim().length === 0) {
|
|
24
|
-
return parseResult;
|
|
25
|
-
}
|
|
26
|
-
let pojo = JSON.parse(source);
|
|
27
|
-
const element = refract(pojo);
|
|
28
|
-
pojo = null; // allow GC to reclaim POJO
|
|
29
|
-
element.classes.push('result');
|
|
30
|
-
parseResult.push(element);
|
|
31
|
-
return parseResult;
|
|
32
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.parse = exports.detectionRegExp = exports.detect = void 0;
|
|
6
|
-
var _index = _interopRequireDefault(require("./lexical-analysis/index.cjs"));
|
|
7
|
-
exports.lexicalAnalysis = _index.default;
|
|
8
|
-
var _index2 = _interopRequireDefault(require("./syntactic-analysis/index.cjs"));
|
|
9
|
-
exports.syntacticAnalysis = _index2.default;
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
const detectionRegExp = exports.detectionRegExp =
|
|
14
|
-
// eslint-disable-next-line no-control-regex
|
|
15
|
-
/(?<true>^\s*true\s*$)|(?<false>^\s*false\s*$)|(?<null>^\s*null\s*$)|(?<number>^\s*\d+\s*$)|(?<object>^\s*{\s*)|(?<array>^\s*\[\s*)|(?<string>^\s*"(((?=\\)\\(["\\/bfnrt]|u[0-9a-fA-F]{4}))|[^"\\\x00-\x1F\x7F])*"\s*$)/;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
const detect = async source => {
|
|
21
|
-
if (!detectionRegExp.test(source)) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
let cst = null;
|
|
25
|
-
try {
|
|
26
|
-
cst = await (0, _index.default)(source);
|
|
27
|
-
return cst.rootNode.type !== 'ERROR';
|
|
28
|
-
} catch {
|
|
29
|
-
return false;
|
|
30
|
-
} finally {
|
|
31
|
-
cst?.delete();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
exports.detect = detect;
|
|
39
|
-
/**
|
|
40
|
-
* @public
|
|
41
|
-
*/
|
|
42
|
-
const parse = async (source, {
|
|
43
|
-
sourceMap = false,
|
|
44
|
-
style = false
|
|
45
|
-
} = {}) => {
|
|
46
|
-
const cst = await (0, _index.default)(source);
|
|
47
|
-
try {
|
|
48
|
-
return (0, _index2.default)(cst, {
|
|
49
|
-
sourceMap,
|
|
50
|
-
style
|
|
51
|
-
});
|
|
52
|
-
} finally {
|
|
53
|
-
cst.delete();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
exports.parse = parse;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import lexicalAnalysis from "./lexical-analysis/index.mjs";
|
|
2
|
-
import syntacticAnalysis from "./syntactic-analysis/index.mjs";
|
|
3
|
-
export { lexicalAnalysis, syntacticAnalysis };
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export const detectionRegExp =
|
|
9
|
-
// eslint-disable-next-line no-control-regex
|
|
10
|
-
/(?<true>^\s*true\s*$)|(?<false>^\s*false\s*$)|(?<null>^\s*null\s*$)|(?<number>^\s*\d+\s*$)|(?<object>^\s*{\s*)|(?<array>^\s*\[\s*)|(?<string>^\s*"(((?=\\)\\(["\\/bfnrt]|u[0-9a-fA-F]{4}))|[^"\\\x00-\x1F\x7F])*"\s*$)/;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export const detect = async source => {
|
|
16
|
-
if (!detectionRegExp.test(source)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
let cst = null;
|
|
20
|
-
try {
|
|
21
|
-
cst = await lexicalAnalysis(source);
|
|
22
|
-
return cst.rootNode.type !== 'ERROR';
|
|
23
|
-
} catch {
|
|
24
|
-
return false;
|
|
25
|
-
} finally {
|
|
26
|
-
cst?.delete();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export const parse = async (source, {
|
|
38
|
-
sourceMap = false,
|
|
39
|
-
style = false
|
|
40
|
-
} = {}) => {
|
|
41
|
-
const cst = await lexicalAnalysis(source);
|
|
42
|
-
try {
|
|
43
|
-
return syntacticAnalysis(cst, {
|
|
44
|
-
sourceMap,
|
|
45
|
-
style
|
|
46
|
-
});
|
|
47
|
-
} finally {
|
|
48
|
-
cst.delete();
|
|
49
|
-
}
|
|
50
|
-
};
|