hermes-parser 0.10.0 → 0.11.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/dist/HermesASTAdapter.js +4 -13
- package/dist/HermesASTAdapter.js.flow +2 -11
- package/dist/HermesParser.js +2 -2
- package/dist/HermesParser.js.flow +2 -0
- package/dist/HermesParserNodeDeserializers.js +150 -6
- package/dist/HermesParserWASM.js +1 -1
- package/dist/HermesParserWASM.js.flow +2 -2
- package/dist/HermesToBabelAdapter.js +53 -9
- package/dist/HermesToBabelAdapter.js.flow +57 -10
- package/dist/HermesToESTreeAdapter.js +3 -12
- package/dist/HermesToESTreeAdapter.js.flow +4 -13
- package/dist/ParserOptions.js.flow +1 -0
- package/dist/generated/ESTreeVisitorKeys.js +194 -0
- package/dist/generated/ESTreeVisitorKeys.js.flow +15 -0
- package/dist/generated/{visitor-keys.js → ParserVisitorKeys.js} +70 -2
- package/dist/index.js +5 -0
- package/dist/index.js.flow +3 -1
- package/dist/transform/SimpleTransform.js.flow +3 -3
- package/dist/transform/astArrayMutationHelpers.js.flow +1 -1
- package/dist/transform/astNodeMutationHelpers.js.flow +2 -2
- package/dist/traverse/SimpleTraverser.js.flow +2 -2
- package/dist/traverse/getVisitorKeys.js +4 -2
- package/dist/traverse/getVisitorKeys.js.flow +4 -3
- package/package.json +3 -2
- package/dist/getVisitorKeys.js +0 -1
- package/dist/getVisitorKeys.js.flow +0 -0
- /package/dist/generated/{visitor-keys.js.flow → ParserVisitorKeys.js.flow} +0 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
7
|
+
* @flow strict
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -35,7 +35,7 @@ export type TransformOptions = $ReadOnly<{
|
|
|
35
35
|
/** The callback function which is called on entering each node. */
|
|
36
36
|
transform: TransformCallback,
|
|
37
37
|
|
|
38
|
-
/** The set of visitor keys to use for traversal. Defaults to the
|
|
38
|
+
/** The set of visitor keys to use for traversal. Defaults to the Flow ESTree visitor keys */
|
|
39
39
|
visitorKeys?: ?VisitorKeysType,
|
|
40
40
|
}>;
|
|
41
41
|
|
|
@@ -98,7 +98,7 @@ export class SimpleTransform {
|
|
|
98
98
|
* @return Either the orginal node if the properties matched the existing node or a new node with
|
|
99
99
|
* the new properties.
|
|
100
100
|
*/
|
|
101
|
-
static nodeWith<T: ESNode>(node: T, overrideProps:
|
|
101
|
+
static nodeWith<T: ESNode>(node: T, overrideProps: Partial<T>): T {
|
|
102
102
|
return nodeWith<T>(node, overrideProps);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
7
|
+
* @flow strict
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -149,7 +149,7 @@ export function updateAllParentPointers(node: ESNode) {
|
|
|
149
149
|
*
|
|
150
150
|
* This will only create a new object if the overrides actually result in a change.
|
|
151
151
|
*/
|
|
152
|
-
export function nodeWith<T: ESNode>(node: T, overrideProps:
|
|
152
|
+
export function nodeWith<T: ESNode>(node: T, overrideProps: Partial<T>): T {
|
|
153
153
|
// Check if this will actually result in a change, maintaining referential equality is important.
|
|
154
154
|
const willBeUnchanged = Object.entries(overrideProps).every(([key, value]) =>
|
|
155
155
|
// $FlowExpectedError[prop-missing]
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
7
|
+
* @flow strict
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -21,7 +21,7 @@ export type TraverserOptions = $ReadOnly<{
|
|
|
21
21
|
enter: TraverserCallback,
|
|
22
22
|
/** The callback function which is called on leaving each node. */
|
|
23
23
|
leave: TraverserCallback,
|
|
24
|
-
/** The set of visitor keys to use for traversal. Defaults to the
|
|
24
|
+
/** The set of visitor keys to use for traversal. Defaults to the Flow ESTree visitor keys */
|
|
25
25
|
visitorKeys?: ?VisitorKeysType,
|
|
26
26
|
}>;
|
|
27
27
|
|
|
@@ -15,14 +15,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
exports.getVisitorKeys = getVisitorKeys;
|
|
16
16
|
exports.isNode = isNode;
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _ESTreeVisitorKeys = _interopRequireDefault(require("../generated/ESTreeVisitorKeys"));
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
21
|
|
|
20
22
|
function isNode(thing) {
|
|
21
23
|
return typeof thing === 'object' && thing != null && typeof thing.type === 'string';
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
function getVisitorKeys(node, visitorKeys) {
|
|
25
|
-
const keys = (visitorKeys != null ? visitorKeys :
|
|
27
|
+
const keys = (visitorKeys != null ? visitorKeys : _ESTreeVisitorKeys.default)[node.type];
|
|
26
28
|
|
|
27
29
|
if (keys == null) {
|
|
28
30
|
throw new Error(`No visitor keys found for node type "${node.type}".`);
|
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
7
|
+
* @flow strict
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
import type {ESNode} from 'hermes-estree';
|
|
14
|
+
import type {VisitorKeys as VisitorKeysType} from '../generated/ESTreeVisitorKeys';
|
|
14
15
|
|
|
15
|
-
import
|
|
16
|
+
import FlowVisitorKeys from '../generated/ESTreeVisitorKeys';
|
|
16
17
|
|
|
17
18
|
export function isNode(thing: mixed): boolean %checks {
|
|
18
19
|
return (
|
|
@@ -20,7 +21,7 @@ export function isNode(thing: mixed): boolean %checks {
|
|
|
20
21
|
);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export type VisitorKeysType
|
|
24
|
+
export type {VisitorKeysType};
|
|
24
25
|
export function getVisitorKeys<T: ESNode>(
|
|
25
26
|
node: T,
|
|
26
27
|
visitorKeys?: ?VisitorKeysType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermes-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "A JavaScript parser built from the Hermes engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
"url": "git@github.com:facebook/hermes.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"hermes-estree": "0.
|
|
12
|
+
"hermes-estree": "0.11.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@babel/parser": "7.7.4",
|
|
16
|
+
"@babel/types": "7.7.4",
|
|
16
17
|
"espree": "9.3.2"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
package/dist/getVisitorKeys.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
File without changes
|
|
File without changes
|