@swagger-api/apidom-parser-adapter-json 0.68.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 (40) hide show
  1. package/CHANGELOG.md +373 -0
  2. package/LICENSES/Apache-2.0.txt +202 -0
  3. package/LICENSES/MIT.txt +9 -0
  4. package/NOTICE +57 -0
  5. package/README.md +125 -0
  6. package/cjs/adapter-browser.cjs +46 -0
  7. package/cjs/adapter-node.cjs +46 -0
  8. package/cjs/adapter.cjs +14 -0
  9. package/cjs/lexical-analysis/browser-patch.cjs +20 -0
  10. package/cjs/lexical-analysis/browser.cjs +42 -0
  11. package/cjs/lexical-analysis/node.cjs +21 -0
  12. package/cjs/media-types.cjs +14 -0
  13. package/cjs/syntactic-analysis/PreOrderCursorChildrenIterator.cjs +33 -0
  14. package/cjs/syntactic-analysis/PreOrderCusrorIterator.cjs +31 -0
  15. package/cjs/syntactic-analysis/direct/CursorIterator.cjs +110 -0
  16. package/cjs/syntactic-analysis/direct/index.cjs +228 -0
  17. package/cjs/syntactic-analysis/indirect/index.cjs +41 -0
  18. package/cjs/syntactic-analysis/indirect/visitors/CstVisitor.cjs +190 -0
  19. package/cjs/syntactic-analysis/indirect/visitors/JsonAstVisitor.cjs +186 -0
  20. package/dist/7c7ca323880d9fa6e48d1d1b2e78e140.wasm +0 -0
  21. package/dist/apidom-parser-adapter-json.browser.js +31014 -0
  22. package/dist/apidom-parser-adapter-json.browser.min.js +1 -0
  23. package/dist/fba0b3cc0d7ee926ea482deee298a5fe.wasm +0 -0
  24. package/es/adapter-browser.js +35 -0
  25. package/es/adapter-node.js +35 -0
  26. package/es/adapter.js +6 -0
  27. package/es/lexical-analysis/browser-patch.js +17 -0
  28. package/es/lexical-analysis/browser.js +36 -0
  29. package/es/lexical-analysis/node.js +14 -0
  30. package/es/media-types.js +8 -0
  31. package/es/syntactic-analysis/PreOrderCursorChildrenIterator.js +32 -0
  32. package/es/syntactic-analysis/PreOrderCusrorIterator.js +30 -0
  33. package/es/syntactic-analysis/direct/CursorIterator.js +104 -0
  34. package/es/syntactic-analysis/direct/index.js +227 -0
  35. package/es/syntactic-analysis/indirect/index.js +34 -0
  36. package/es/syntactic-analysis/indirect/visitors/CstVisitor.js +183 -0
  37. package/es/syntactic-analysis/indirect/visitors/JsonAstVisitor.js +180 -0
  38. package/package.json +81 -0
  39. package/types/dist.d.ts +53 -0
  40. package/wasm/tree-sitter-json.wasm +0 -0
package/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # @swagger-api/apidom-parser-adapter-json
2
+
3
+ `@swagger-api/apidom-parser-adapter-json` is a parser adapter for the [JSON format](https://www.json.org/json-en.html).
4
+
5
+ [CST](https://tree-sitter.github.io/tree-sitter/using-parsers#syntax-nodes) produced by lexical analysis is [syntactically analyzed](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-json/src/syntactic-analysis) and
6
+ ApiDOM structure using [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace) is produced.
7
+
8
+ ## Installation
9
+
10
+ After [prerequisites](https://github.com/swagger-api/apidom/blob/main/README.md#prerequisites) for installing this package are satisfied, you can install it
11
+ via [npm CLI](https://docs.npmjs.com/cli) by running the following command:
12
+
13
+ ```sh
14
+ $ npm install @swagger-api/apidom-parser-adapter-json
15
+ ```
16
+
17
+ ## Parse phases
18
+
19
+ The parse stage takes JSON string and produces ApiDOM structure using [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace).
20
+ There are two phases of parsing: **Lexical Analysis** and **Syntactic Analysis**.
21
+
22
+ ### Lexical Analysis
23
+
24
+ Lexical Analysis will take a JSON string and turn it into a stream of tokens.
25
+ [tree-sitter](https://www.npmjs.com/package/tree-sitter) / [web-tree-sitter](https://www.npmjs.com/package/web-tree-sitter) is used as an underlying lexical analyzer.
26
+
27
+ ### Syntactic Analysis
28
+
29
+ Syntactic Analysis will take a stream of tokens and turn it into an ApiDOM representation.
30
+ [CST](https://tree-sitter.github.io/tree-sitter/using-parsers#syntax-nodes) produced by lexical analysis is [syntactically analyzed](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-json/src/syntactic-analysis)
31
+ and ApiDOM structure using [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace) is produced.
32
+
33
+ #### [Direct Syntactical analysis](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-json/src/syntactic-analysis/direct)
34
+
35
+ This analysis directly turns tree-sitter CST into ApiDOM. Single traversal is required which makes
36
+ it super performant, and it's the default analysis used.
37
+
38
+ ```js
39
+ import { parse } from '@swagger-api/apidom-parser-adapter-json';
40
+
41
+ const parseResult = await parse('{"prop": "value"}', {
42
+ syntacticAnalysis: 'direct',
43
+ });
44
+ ```
45
+
46
+ #### [Indirect Syntactic analysis]((https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-json/src/syntactic-analysis/indirect))
47
+
48
+ This analysis turns trees-sitter CST into [JSON AST](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ast#json-ast-nodes) representation.
49
+ Then JSON AST is turned into ApiDOM. Two traversals are required, which makes indirect analysis less performant than direct one.
50
+ Thought less performant, having JSON AST representation allows us to do further complex analysis.
51
+
52
+ ```js
53
+ import { parse } from '@swagger-api/apidom-parser-adapter-json';
54
+
55
+ const parseResult = await parse('{"prop": "value"}', {
56
+ syntacticAnalysis: 'indirect',
57
+ });
58
+ ```
59
+
60
+ ## Parser adapter API
61
+
62
+ This parser adapter is fully compatible with parser adapter interface required by [@swagger-api/apidom-parser](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser#mounting-parser-adapters)
63
+ and implements all required properties.
64
+
65
+ ### mediaTypes
66
+
67
+ Defines list of media types that this parser adapter recognizes.
68
+
69
+ ```js
70
+ ['application/json']
71
+ ```
72
+
73
+ ### detect
74
+
75
+ [Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-json/src/adapter.ts#L3) is based on using [JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) to indicate whether the provided source string is or isn't JSON string.
76
+
77
+ ### namespace
78
+
79
+ This adapter exposes an instance of [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace).
80
+
81
+ ### parse
82
+
83
+ `parse` function consumes various options as a second argument. Here is a list of these options:
84
+
85
+ Option | Type | Default | Description
86
+ --- | --- | --- | ---
87
+ <a name="sourceMap"></a>`sourceMap` | `Boolean` | `false` | Indicate whether to generate source maps.
88
+ <a name="syntacticAnalysis"></a>`syntacticAnalysis` | `String` | `direct` | Indicate type of syntactic analysis
89
+
90
+ All unrecognized arbitrary options will be ignored.
91
+
92
+ ## Usage
93
+
94
+ This parser adapter can be used directly or indirectly via [@swagger-api/apidom-parser](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser).
95
+
96
+ ### Direct usage
97
+
98
+ During direct usage you don't need to provide `mediaType` as the `parse` function is already pre-bound
99
+ with [supported media types](#mediatypes).
100
+
101
+ ```js
102
+ import { parse, detect } from '@swagger-api/apidom-parser-adapter-json';
103
+
104
+ // detecting
105
+ await detect('{"prop": "value"}'); // => true
106
+ await detect('test'); // => false
107
+
108
+ // parsing
109
+ const parseResult = await parse('{"prop": "value"}', { sourceMap: true });
110
+ ```
111
+
112
+ ### Indirect usage
113
+
114
+ You can omit the `mediaType` option here, but please read [Word on detect vs mediaTypes](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser#word-on-detect-vs-mediatypes) before you do so.
115
+
116
+ ```js
117
+ import ApiDOMParser from '@swagger-api/apidom-parser';
118
+ import * as jsonParserAdapter from '@swagger-api/apidom-parser-adapter-json';
119
+
120
+ const parser = ApiDOMParser();
121
+
122
+ parser.use(jsonParserAdapter);
123
+
124
+ const parseResult = await parser.parse('{"prop", "value"}', { mediaType: jsonParserAdapter.mediaTypes.latest('json') });
125
+ ```
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.parse = exports.namespace = exports.mediaTypes = exports.detect = void 0;
6
+ var _browser = _interopRequireDefault(require("./lexical-analysis/browser.cjs"));
7
+ exports.lexicalAnalysis = _browser.default;
8
+ var _index = _interopRequireDefault(require("./syntactic-analysis/direct/index.cjs"));
9
+ exports.syntacticAnalysis = _index.default;
10
+ exports.syntacticAnalysisDirect = _index.default;
11
+ var _index2 = _interopRequireDefault(require("./syntactic-analysis/indirect/index.cjs"));
12
+ exports.syntacticAnalysisIndirect = _index2.default;
13
+ var _adapter = require("./adapter.cjs");
14
+ exports.detectionRegExp = _adapter.detectionRegExp;
15
+ exports.mediaTypes = _adapter.mediaTypes;
16
+ exports.namespace = _adapter.namespace;
17
+ const detect = async source => {
18
+ if (!_adapter.detectionRegExp.test(source)) {
19
+ return false;
20
+ }
21
+ try {
22
+ const cst = await (0, _browser.default)(source);
23
+ return cst.rootNode.type !== 'ERROR';
24
+ } catch {
25
+ return false;
26
+ }
27
+ };
28
+ exports.detect = detect;
29
+ const parse = async (source, {
30
+ sourceMap = false,
31
+ syntacticAnalysis = 'direct'
32
+ } = {}) => {
33
+ const cst = await (0, _browser.default)(source);
34
+ let apiDOM;
35
+ if (syntacticAnalysis === 'indirect') {
36
+ apiDOM = (0, _index2.default)(cst, {
37
+ sourceMap
38
+ });
39
+ } else {
40
+ apiDOM = (0, _index.default)(cst, {
41
+ sourceMap
42
+ });
43
+ }
44
+ return apiDOM;
45
+ };
46
+ exports.parse = parse;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.parse = exports.namespace = exports.mediaTypes = exports.detect = void 0;
6
+ var _node = _interopRequireDefault(require("./lexical-analysis/node.cjs"));
7
+ exports.lexicalAnalysis = _node.default;
8
+ var _index = _interopRequireDefault(require("./syntactic-analysis/direct/index.cjs"));
9
+ exports.syntacticAnalysis = _index.default;
10
+ exports.syntacticAnalysisDirect = _index.default;
11
+ var _index2 = _interopRequireDefault(require("./syntactic-analysis/indirect/index.cjs"));
12
+ exports.syntacticAnalysisIndirect = _index2.default;
13
+ var _adapter = require("./adapter.cjs");
14
+ exports.detectionRegExp = _adapter.detectionRegExp;
15
+ exports.mediaTypes = _adapter.mediaTypes;
16
+ exports.namespace = _adapter.namespace;
17
+ const detect = async source => {
18
+ if (!_adapter.detectionRegExp.test(source)) {
19
+ return false;
20
+ }
21
+ try {
22
+ const cst = await (0, _node.default)(source);
23
+ return cst.rootNode.type !== 'ERROR';
24
+ } catch {
25
+ return false;
26
+ }
27
+ };
28
+ exports.detect = detect;
29
+ const parse = async (source, {
30
+ sourceMap = false,
31
+ syntacticAnalysis = 'direct'
32
+ } = {}) => {
33
+ const cst = await (0, _node.default)(source);
34
+ let apiDOM;
35
+ if (syntacticAnalysis === 'indirect') {
36
+ apiDOM = (0, _index2.default)(cst, {
37
+ sourceMap
38
+ });
39
+ } else {
40
+ apiDOM = (0, _index.default)(cst, {
41
+ sourceMap
42
+ });
43
+ }
44
+ return apiDOM;
45
+ };
46
+ exports.parse = parse;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.namespace = exports.mediaTypes = exports.detectionRegExp = void 0;
6
+ var _apidomCore = require("@swagger-api/apidom-core");
7
+ var _mediaTypes = _interopRequireDefault(require("./media-types.cjs"));
8
+ exports.mediaTypes = _mediaTypes.default;
9
+ const namespace = (0, _apidomCore.createNamespace)();
10
+ exports.namespace = namespace;
11
+ const detectionRegExp =
12
+ // eslint-disable-next-line no-control-regex
13
+ /(?<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*$)/;
14
+ exports.detectionRegExp = detectionRegExp;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ var _ramda = require("ramda");
5
+ var _ramdaAdjunct = require("ramda-adjunct");
6
+ var _treeSitter = _interopRequireDefault(require("web-tree-sitter/tree-sitter.wasm"));
7
+ // @ts-ignore
8
+
9
+ // patch fetch() to let emscripten load the WASM file
10
+ const realFetch = globalThis.fetch;
11
+ if ((0, _ramdaAdjunct.isFunction)(realFetch)) {
12
+ globalThis.fetch = (...args) => {
13
+ // @ts-ignore
14
+ if ((0, _ramdaAdjunct.isString)(args[0]) && args[0].endsWith('tree-sitter.wasm')) {
15
+ // @ts-ignore
16
+ return realFetch.apply(globalThis, [_treeSitter.default, (0, _ramda.tail)(args)]);
17
+ }
18
+ return realFetch.apply(globalThis, args);
19
+ };
20
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ require("./browser-patch.cjs");
7
+ var _webTreeSitter = _interopRequireDefault(require("web-tree-sitter"));
8
+ var _treeSitterJson = _interopRequireDefault(require("../../wasm/tree-sitter-json.wasm"));
9
+ // @ts-ignore
10
+
11
+ let parser = null;
12
+ let parserInitLock = null;
13
+
14
+ /**
15
+ * Lexical Analysis of source string using WebTreeSitter.
16
+ * This is WebAssembly version of TreeSitters Lexical Analysis.
17
+ *
18
+ * Given JavaScript doesn't support true parallelism, this
19
+ * code should be as lazy as possible and temporal safety should be fine.
20
+ */
21
+ const analyze = async source => {
22
+ if (parser === null && parserInitLock === null) {
23
+ // acquire lock
24
+ parserInitLock = _webTreeSitter.default.init().then(() => _webTreeSitter.default.Language.load(_treeSitterJson.default)).then(jsonLanguage => {
25
+ const parserInstance = new _webTreeSitter.default();
26
+ parserInstance.setLanguage(jsonLanguage);
27
+ return parserInstance;
28
+ }).finally(() => {
29
+ // release lock
30
+ parserInitLock = null;
31
+ });
32
+ parser = await parserInitLock;
33
+ } else if (parser === null && parserInitLock !== null) {
34
+ // await for lock to be released if there is one
35
+ parser = await parserInitLock;
36
+ } else if (parser === null) {
37
+ throw new Error('Error while initializing web-tree-sitter');
38
+ }
39
+ return parser.parse(source);
40
+ };
41
+ var _default = analyze;
42
+ exports.default = _default;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _treeSitter = _interopRequireDefault(require("tree-sitter"));
7
+ var _treeSitterJson = _interopRequireDefault(require("tree-sitter-json"));
8
+ // @ts-ignore
9
+
10
+ const parser = new _treeSitter.default();
11
+ parser.setLanguage(_treeSitterJson.default);
12
+
13
+ /**
14
+ * Lexical Analysis of source string using TreeSitter.
15
+ * This is Node.js version of TreeSitters Lexical Analysis.
16
+ */
17
+ const analyze = async source => {
18
+ return parser.parse(source);
19
+ };
20
+ var _default = analyze;
21
+ exports.default = _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = exports.JSONMediaTypes = void 0;
5
+ var _apidomCore = require("@swagger-api/apidom-core");
6
+ class JSONMediaTypes extends _apidomCore.MediaTypes {
7
+ latest() {
8
+ return this[0];
9
+ }
10
+ }
11
+ exports.JSONMediaTypes = JSONMediaTypes;
12
+ const mediaTypes = new JSONMediaTypes('application/json');
13
+ var _default = mediaTypes;
14
+ exports.default = _default;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ class PreOrderCursorChildrenIterator {
6
+ constructor(cursor) {
7
+ this.cursor = cursor;
8
+ }
9
+ createNode() {
10
+ return {
11
+ type: this.cursor.nodeType,
12
+ startPosition: this.cursor.startPosition,
13
+ endPosition: this.cursor.endPosition,
14
+ children: []
15
+ };
16
+ }
17
+ *[Symbol.iterator]() {
18
+ // @ts-ignore
19
+ const method = this[this.cursor.nodeType];
20
+ const currentNode = (method || this.createNode).call(this);
21
+ const constructor = this.constructor;
22
+ if (this.cursor.gotoFirstChild()) {
23
+ currentNode.children.push(...[...new constructor(this.cursor)]);
24
+ while (this.cursor.gotoNextSibling()) {
25
+ currentNode.children.push(...[...new constructor(this.cursor)]);
26
+ }
27
+ this.cursor.gotoParent();
28
+ }
29
+ yield currentNode;
30
+ }
31
+ }
32
+ var _default = PreOrderCursorChildrenIterator;
33
+ exports.default = _default;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ class PreOrderCursorIterator {
6
+ constructor(cursor) {
7
+ this.cursor = cursor;
8
+ }
9
+ createNode() {
10
+ return {
11
+ type: this.cursor.nodeType,
12
+ startPosition: this.cursor.startPosition,
13
+ endPosition: this.cursor.endPosition
14
+ };
15
+ }
16
+ *[Symbol.iterator]() {
17
+ // @ts-ignore
18
+ const method = this[this.cursor.nodeType];
19
+ const constructor = this.constructor;
20
+ yield (method || this.createNode).call(this);
21
+ if (this.cursor.gotoFirstChild()) {
22
+ yield* new constructor(this.cursor);
23
+ while (this.cursor.gotoNextSibling()) {
24
+ yield* new constructor(this.cursor);
25
+ }
26
+ this.cursor.gotoParent();
27
+ }
28
+ }
29
+ }
30
+ var _default = PreOrderCursorIterator;
31
+ exports.default = _default;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _PreOrderCursorChildrenIterator = _interopRequireDefault(require("../PreOrderCursorChildrenIterator.cjs"));
7
+ class CursorIterator extends _PreOrderCursorChildrenIterator.default {
8
+ document() {
9
+ return {
10
+ type: this.cursor.nodeType,
11
+ startPosition: this.cursor.startPosition,
12
+ endPosition: this.cursor.endPosition,
13
+ children: []
14
+ };
15
+ }
16
+ object() {
17
+ return {
18
+ type: this.cursor.nodeType,
19
+ startPosition: this.cursor.startPosition,
20
+ endPosition: this.cursor.endPosition,
21
+ fieldName: this.cursor.currentFieldName,
22
+ children: []
23
+ };
24
+ }
25
+ array() {
26
+ return {
27
+ type: this.cursor.nodeType,
28
+ startPosition: this.cursor.startPosition,
29
+ endPosition: this.cursor.endPosition,
30
+ fieldName: this.cursor.currentFieldName,
31
+ children: []
32
+ };
33
+ }
34
+ pair() {
35
+ return {
36
+ type: this.cursor.nodeType,
37
+ startPosition: this.cursor.startPosition,
38
+ endPosition: this.cursor.endPosition,
39
+ get keyNode() {
40
+ return this.children.find(node => node.fieldName === 'key');
41
+ },
42
+ get valueNode() {
43
+ return this.children.find(node => node.fieldName === 'value');
44
+ },
45
+ children: []
46
+ };
47
+ }
48
+ string() {
49
+ return {
50
+ type: this.cursor.nodeType,
51
+ startPosition: this.cursor.startPosition,
52
+ endPosition: this.cursor.endPosition,
53
+ text: this.cursor.nodeText,
54
+ fieldName: this.cursor.currentFieldName,
55
+ children: []
56
+ };
57
+ }
58
+ number() {
59
+ return {
60
+ type: this.cursor.nodeType,
61
+ startPosition: this.cursor.startPosition,
62
+ endPosition: this.cursor.endPosition,
63
+ text: this.cursor.nodeText,
64
+ fieldName: this.cursor.currentFieldName,
65
+ children: []
66
+ };
67
+ }
68
+ null() {
69
+ return {
70
+ type: this.cursor.nodeType,
71
+ startPosition: this.cursor.startPosition,
72
+ endPosition: this.cursor.endPosition,
73
+ fieldName: this.cursor.currentFieldName,
74
+ children: []
75
+ };
76
+ }
77
+ true() {
78
+ return {
79
+ type: this.cursor.nodeType,
80
+ startPosition: this.cursor.startPosition,
81
+ endPosition: this.cursor.endPosition,
82
+ fieldName: this.cursor.currentFieldName,
83
+ children: []
84
+ };
85
+ }
86
+ false() {
87
+ return {
88
+ type: this.cursor.nodeType,
89
+ startPosition: this.cursor.startPosition,
90
+ endPosition: this.cursor.endPosition,
91
+ fieldName: this.cursor.currentFieldName,
92
+ children: []
93
+ };
94
+ }
95
+ ERROR() {
96
+ const {
97
+ currentNode
98
+ } = this.cursor;
99
+ return {
100
+ type: this.cursor.nodeType,
101
+ startPosition: this.cursor.startPosition,
102
+ endPosition: this.cursor.endPosition,
103
+ // @ts-ignore
104
+ hasError: () => currentNode.hasError(),
105
+ children: []
106
+ };
107
+ }
108
+ }
109
+ var _default = CursorIterator;
110
+ exports.default = _default;