@speclynx/apidom-parser-adapter-json 2.2.2 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speclynx/apidom-parser-adapter-json",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "Parser adapter for parsing JSON documents into base namespace.",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -42,10 +42,10 @@
42
42
  "license": "Apache-2.0",
43
43
  "dependencies": {
44
44
  "@babel/runtime-corejs3": "^7.28.4",
45
- "@speclynx/apidom-core": "^2.2.2",
46
- "@speclynx/apidom-datamodel": "^2.2.2",
47
- "@speclynx/apidom-error": "^2.2.2",
48
- "web-tree-sitter": "=0.25.10"
45
+ "@speclynx/apidom-core": "^2.3.0",
46
+ "@speclynx/apidom-datamodel": "^2.3.0",
47
+ "@speclynx/apidom-error": "^2.3.0",
48
+ "web-tree-sitter": "=0.26.3"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/emscripten": "^1.41.2",
@@ -61,5 +61,5 @@
61
61
  "README.md",
62
62
  "CHANGELOG.md"
63
63
  ],
64
- "gitHead": "220dbc19c94e58d28ea05d05c4eaf2f5dc0c5fbc"
64
+ "gitHead": "b561fa09e688f1d9b1968b8353f32ddad9a4a803"
65
65
  }
package/src/adapter.cjs CHANGED
@@ -42,10 +42,6 @@ const detect = async (source, {
42
42
  return treeSitter.detect(source);
43
43
  };
44
44
 
45
- /**
46
- * @public
47
- */
48
-
49
45
  /**
50
46
  * @public
51
47
  */
@@ -58,7 +54,7 @@ const parse = async (source, {
58
54
  strict = false
59
55
  } = {}) => {
60
56
  if (strict && sourceMap) {
61
- throw new _apidomError.ApiDOMError('Cannot use sourceMap with strict parsing. Strict parsing does not support source maps.');
57
+ throw new _apidomError.UnsupportedOperationError('Cannot use sourceMap with strict parsing. Strict parsing does not support source maps.');
62
58
  }
63
59
  if (strict) {
64
60
  return native.parse(source);
package/src/adapter.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Namespace } from '@speclynx/apidom-datamodel';
2
- import { ApiDOMError } from '@speclynx/apidom-error';
2
+ import { UnsupportedOperationError } from '@speclynx/apidom-error';
3
3
  import * as native from "./native/index.mjs";
4
4
  import * as treeSitter from "./tree-sitter/index.mjs";
5
5
  export { lexicalAnalysis, syntacticAnalysis } from "./tree-sitter/index.mjs";
@@ -37,10 +37,6 @@ export const detect = async (source, {
37
37
  * @public
38
38
  */
39
39
 
40
- /**
41
- * @public
42
- */
43
-
44
40
  /**
45
41
  * @public
46
42
  */
@@ -49,7 +45,7 @@ export const parse = async (source, {
49
45
  strict = false
50
46
  } = {}) => {
51
47
  if (strict && sourceMap) {
52
- throw new ApiDOMError('Cannot use sourceMap with strict parsing. Strict parsing does not support source maps.');
48
+ throw new UnsupportedOperationError('Cannot use sourceMap with strict parsing. Strict parsing does not support source maps.');
53
49
  }
54
50
  if (strict) {
55
51
  return native.parse(source);
@@ -7,6 +7,9 @@ var _apidomDatamodel = require("@speclynx/apidom-datamodel");
7
7
  * @public
8
8
  */
9
9
  const detect = async source => {
10
+ if (source.trim().length === 0) {
11
+ return false;
12
+ }
10
13
  try {
11
14
  JSON.parse(source);
12
15
  return true;
@@ -20,9 +23,12 @@ const detect = async source => {
20
23
  */
21
24
  exports.detect = detect;
22
25
  const parse = async source => {
26
+ const parseResult = new _apidomDatamodel.ParseResultElement();
27
+ if (source.trim().length === 0) {
28
+ return parseResult;
29
+ }
23
30
  const pojo = JSON.parse(source);
24
31
  const element = (0, _apidomDatamodel.refract)(pojo);
25
- const parseResult = new _apidomDatamodel.ParseResultElement();
26
32
  element.classes.push('result');
27
33
  parseResult.push(element);
28
34
  return parseResult;
@@ -4,6 +4,9 @@ import { ParseResultElement, refract } from '@speclynx/apidom-datamodel';
4
4
  * @public
5
5
  */
6
6
  export const detect = async source => {
7
+ if (source.trim().length === 0) {
8
+ return false;
9
+ }
7
10
  try {
8
11
  JSON.parse(source);
9
12
  return true;
@@ -16,9 +19,12 @@ export const detect = async source => {
16
19
  * @public
17
20
  */
18
21
  export const parse = async source => {
22
+ const parseResult = new ParseResultElement();
23
+ if (source.trim().length === 0) {
24
+ return parseResult;
25
+ }
19
26
  const pojo = JSON.parse(source);
20
27
  const element = refract(pojo);
21
- const parseResult = new ParseResultElement();
22
28
  element.classes.push('result');
23
29
  parseResult.push(element);
24
30
  return parseResult;