@speclynx/apidom-parser-adapter-json 1.12.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/LICENSE +202 -0
  3. package/LICENSES/AFL-3.0.txt +182 -0
  4. package/LICENSES/Apache-2.0.txt +202 -0
  5. package/LICENSES/BSD-3-Clause.txt +26 -0
  6. package/LICENSES/MIT.txt +9 -0
  7. package/NOTICE +65 -0
  8. package/README.md +124 -0
  9. package/dist/167.apidom-parser-adapter-json.browser.js +10 -0
  10. package/dist/167.apidom-parser-adapter-json.browser.min.js +1 -0
  11. package/dist/451.apidom-parser-adapter-json.browser.js +10 -0
  12. package/dist/451.apidom-parser-adapter-json.browser.min.js +1 -0
  13. package/dist/9786785aaddf11f37840.wasm +0 -0
  14. package/dist/apidom-parser-adapter-json.browser.js +17850 -0
  15. package/dist/apidom-parser-adapter-json.browser.min.js +1 -0
  16. package/package.json +69 -0
  17. package/src/adapter.cjs +75 -0
  18. package/src/adapter.mjs +65 -0
  19. package/src/lexical-analysis/index.cjs +42 -0
  20. package/src/lexical-analysis/index.mjs +38 -0
  21. package/src/media-types.cjs +20 -0
  22. package/src/media-types.mjs +16 -0
  23. package/src/syntactic-analysis/TreeCursorIterator.cjs +62 -0
  24. package/src/syntactic-analysis/TreeCursorIterator.mjs +57 -0
  25. package/src/syntactic-analysis/TreeCursorSyntaxNode.cjs +51 -0
  26. package/src/syntactic-analysis/TreeCursorSyntaxNode.mjs +47 -0
  27. package/src/syntactic-analysis/direct/index.cjs +64 -0
  28. package/src/syntactic-analysis/direct/index.mjs +59 -0
  29. package/src/syntactic-analysis/direct/visitors/CstVisitor.cjs +163 -0
  30. package/src/syntactic-analysis/direct/visitors/CstVisitor.mjs +158 -0
  31. package/src/syntactic-analysis/indirect/index.cjs +56 -0
  32. package/src/syntactic-analysis/indirect/index.mjs +49 -0
  33. package/src/syntactic-analysis/indirect/visitors/CstVisitor.cjs +177 -0
  34. package/src/syntactic-analysis/indirect/visitors/CstVisitor.mjs +172 -0
  35. package/src/syntactic-analysis/indirect/visitors/JsonAstVisitor.cjs +189 -0
  36. package/src/syntactic-analysis/indirect/visitors/JsonAstVisitor.mjs +183 -0
  37. package/types/apidom-parser-adapter-json.d.ts +103 -0
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@speclynx/apidom-parser-adapter-json",
3
+ "version": "1.12.1",
4
+ "description": "Parser adapter for parsing JSON documents into base namespace.",
5
+ "publishConfig": {
6
+ "access": "public",
7
+ "registry": "https://registry.npmjs.org",
8
+ "provenance": true
9
+ },
10
+ "type": "module",
11
+ "sideEffects": false,
12
+ "unpkg": "./dist/apidom-parser-apdater-json.browser.min.js",
13
+ "main": "./src/adapter.cjs",
14
+ "exports": {
15
+ "types": "./types/apidom-parser-adapter-json.d.ts",
16
+ "import": "./src/adapter.mjs",
17
+ "require": "./src/adapter.cjs"
18
+ },
19
+ "types": "./types/apidom-parser-adapter-json.d.ts",
20
+ "scripts": {
21
+ "build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser",
22
+ "build:es": "cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'",
23
+ "build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir src --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
24
+ "build:umd:browser": "cross-env BABEL_ENV=browser webpack --config config/webpack/browser.config.js --progress",
25
+ "lint": "eslint ./",
26
+ "lint:fix": "eslint ./ --fix",
27
+ "clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
28
+ "typescript:check-types": "tsc --noEmit && tsc -p ./test/tsconfig.json --noEmit",
29
+ "typescript:declaration": "tsc -p tsconfig.declaration.json && api-extractor run -l -c ./config/api-extractor/api-extractor.json",
30
+ "test": "npm run build:es && cross-env BABEL_ENV=es babel test --out-dir test --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward' && cross-env NODE_ENV=test NODE_NO_WARNINGS=1 mocha",
31
+ "perf": "cross-env BABEL_ENV=es babel ./test/perf/index.ts --out-file ./test/perf/index.mjs --root-mode 'upward' && cross-env NODE_ENV=test node ./test/perf/index.mjs",
32
+ "perf:lexical-analysis": "cross-env BABEL_ENV=es babel ./test/perf/lexical-analysis.ts --out-file ./test/perf/lexical-analysis.mjs --root-mode 'upward' && cross-env NODE_ENV=test node ./test/perf/lexical-analysis.mjs",
33
+ "perf:parse-syntactic-analysis-direct": "cross-env BABEL_ENV=es babel ./test/perf/parse-syntactic-analysis-direct.ts --out-file ./test/perf/parse-syntactic-analysis-direct.mjs --root-mode 'upward' && cross-env NODE_ENV=test node ./test/perf/parse-syntactic-analysis-direct.mjs",
34
+ "perf:parse-syntactic-analysis-indirect": "cross-env BABEL_ENV=es babel ./test/perf/parse-syntactic-analysis-indirect.ts --out-file ./test/perf/parse-syntactic-analysis-indirect.mjs --root-mode 'upward' && cross-env NODE_ENV=test node ./test/perf/parse-syntactic-analysis-indirect.mjs",
35
+ "prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
36
+ "postpack": "rimraf NOTICE LICENSES"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/speclynx/apidom.git"
41
+ },
42
+ "author": "Vladimir Gorej",
43
+ "license": "Apache-2.0",
44
+ "dependencies": {
45
+ "@babel/runtime-corejs3": "^7.28.4",
46
+ "@speclynx/apidom-ast": "^1.12.1",
47
+ "@speclynx/apidom-core": "^1.12.1",
48
+ "@speclynx/apidom-error": "^1.12.1",
49
+ "@types/ramda": "~0.30.0",
50
+ "ramda": "~0.32.0",
51
+ "ramda-adjunct": "^6.0.0",
52
+ "web-tree-sitter": "=0.25.10"
53
+ },
54
+ "devDependencies": {
55
+ "@types/emscripten": "^1.41.2",
56
+ "tree-sitter-json": "=0.24.8"
57
+ },
58
+ "files": [
59
+ "src/**/*.mjs",
60
+ "src/**/*.cjs",
61
+ "dist/",
62
+ "types/apidom-parser-adapter-json.d.ts",
63
+ "LICENSES",
64
+ "NOTICE",
65
+ "README.md",
66
+ "CHANGELOG.md"
67
+ ],
68
+ "gitHead": "49be88493f922c4ace2e4ebc0f23387ccb62c4fc"
69
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.parse = exports.namespace = exports.mediaTypes = exports.detectionRegExp = exports.detect = void 0;
6
+ var _apidomCore = require("@speclynx/apidom-core");
7
+ var _index = _interopRequireDefault(require("./lexical-analysis/index.cjs"));
8
+ exports.lexicalAnalysis = _index.default;
9
+ var _index2 = _interopRequireDefault(require("./syntactic-analysis/direct/index.cjs"));
10
+ exports.syntacticAnalysis = _index2.default;
11
+ exports.syntacticAnalysisDirect = _index2.default;
12
+ var _index3 = _interopRequireDefault(require("./syntactic-analysis/indirect/index.cjs"));
13
+ exports.syntacticAnalysisIndirect = _index3.default;
14
+ var _mediaTypes = _interopRequireDefault(require("./media-types.cjs"));
15
+ exports.mediaTypes = _mediaTypes.default;
16
+ /**
17
+ * @public
18
+ */
19
+
20
+ /**
21
+ * @public
22
+ */
23
+ const namespace = exports.namespace = (0, _apidomCore.createNamespace)();
24
+
25
+ /**
26
+ * @public
27
+ */
28
+ const detectionRegExp = exports.detectionRegExp =
29
+ // eslint-disable-next-line no-control-regex
30
+ /(?<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*$)/;
31
+
32
+ /**
33
+ * @public
34
+ */
35
+ const detect = async source => {
36
+ if (!detectionRegExp.test(source)) {
37
+ return false;
38
+ }
39
+ try {
40
+ const cst = await (0, _index.default)(source);
41
+ return cst.rootNode.type !== 'ERROR';
42
+ } catch {
43
+ return false;
44
+ }
45
+ };
46
+
47
+ /**
48
+ * @public
49
+ */
50
+
51
+ /**
52
+ * @public
53
+ */
54
+ exports.detect = detect;
55
+ /**
56
+ * @public
57
+ */
58
+ const parse = async (source, {
59
+ sourceMap = false,
60
+ syntacticAnalysis = 'direct'
61
+ } = {}) => {
62
+ const cst = await (0, _index.default)(source);
63
+ let apiDOM;
64
+ if (syntacticAnalysis === 'indirect') {
65
+ apiDOM = (0, _index3.default)(cst, {
66
+ sourceMap
67
+ });
68
+ } else {
69
+ apiDOM = (0, _index2.default)(cst, {
70
+ sourceMap
71
+ });
72
+ }
73
+ return apiDOM;
74
+ };
75
+ exports.parse = parse;
@@ -0,0 +1,65 @@
1
+ import { createNamespace } from '@speclynx/apidom-core';
2
+ import lexicalAnalysis from "./lexical-analysis/index.mjs";
3
+ import syntacticAnalysisDirect from "./syntactic-analysis/direct/index.mjs";
4
+ import syntacticAnalysisIndirect from "./syntactic-analysis/indirect/index.mjs";
5
+ export { lexicalAnalysis, syntacticAnalysisDirect as syntacticAnalysis, syntacticAnalysisDirect, syntacticAnalysisIndirect };
6
+
7
+ /**
8
+ * @public
9
+ */
10
+ export { default as mediaTypes } from "./media-types.mjs";
11
+ /**
12
+ * @public
13
+ */
14
+ export const namespace = createNamespace();
15
+
16
+ /**
17
+ * @public
18
+ */
19
+ export const detectionRegExp =
20
+ // eslint-disable-next-line no-control-regex
21
+ /(?<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*$)/;
22
+
23
+ /**
24
+ * @public
25
+ */
26
+ export const detect = async source => {
27
+ if (!detectionRegExp.test(source)) {
28
+ return false;
29
+ }
30
+ try {
31
+ const cst = await lexicalAnalysis(source);
32
+ return cst.rootNode.type !== 'ERROR';
33
+ } catch {
34
+ return false;
35
+ }
36
+ };
37
+
38
+ /**
39
+ * @public
40
+ */
41
+
42
+ /**
43
+ * @public
44
+ */
45
+
46
+ /**
47
+ * @public
48
+ */
49
+ export const parse = async (source, {
50
+ sourceMap = false,
51
+ syntacticAnalysis = 'direct'
52
+ } = {}) => {
53
+ const cst = await lexicalAnalysis(source);
54
+ let apiDOM;
55
+ if (syntacticAnalysis === 'indirect') {
56
+ apiDOM = syntacticAnalysisIndirect(cst, {
57
+ sourceMap
58
+ });
59
+ } else {
60
+ apiDOM = syntacticAnalysisDirect(cst, {
61
+ sourceMap
62
+ });
63
+ }
64
+ return apiDOM;
65
+ };