hermes-parser 0.29.1 → 0.31.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/HermesParserNodeDeserializers.js +4 -0
- package/dist/HermesParserWASM.js +1 -1
- package/dist/HermesToESTreeAdapter.js +0 -14
- package/dist/HermesToESTreeAdapter.js.flow +0 -16
- package/dist/babel/TransformESTreeToBabel.js +16 -0
- package/dist/babel/TransformESTreeToBabel.js.flow +12 -0
- package/dist/estree/StripComponentSyntax.js.flow +2 -2
- package/dist/generated/ESTreeVisitorKeys.js +2 -2
- package/dist/generated/ParserVisitorKeys.js +4 -0
- package/dist/index.js.flow +3 -3
- package/dist/src/HermesParserNodeDeserializers.js +4 -0
- package/dist/src/HermesToESTreeAdapter.js +0 -14
- package/dist/src/babel/TransformESTreeToBabel.js +16 -0
- package/dist/src/generated/ESTreeVisitorKeys.js +2 -2
- package/dist/src/generated/ParserVisitorKeys.js +4 -0
- package/package.json +2 -2
|
@@ -95,9 +95,6 @@ class HermesToESTreeAdapter extends _HermesASTAdapter.default {
|
|
|
95
95
|
case 'ExportAllDeclaration':
|
|
96
96
|
return this.mapExportAllDeclaration(node);
|
|
97
97
|
|
|
98
|
-
case 'Property':
|
|
99
|
-
return this.mapProperty(node);
|
|
100
|
-
|
|
101
98
|
case 'FunctionDeclaration':
|
|
102
99
|
case 'FunctionExpression':
|
|
103
100
|
case 'ArrowFunctionExpression':
|
|
@@ -233,17 +230,6 @@ class HermesToESTreeAdapter extends _HermesASTAdapter.default {
|
|
|
233
230
|
return this.mapNodeDefault(node);
|
|
234
231
|
}
|
|
235
232
|
|
|
236
|
-
mapProperty(nodeUnprocessed) {
|
|
237
|
-
const node = this.mapNodeDefault(nodeUnprocessed);
|
|
238
|
-
|
|
239
|
-
if (node.value.type === 'FunctionExpression' && (node.method || node.kind !== 'init')) {
|
|
240
|
-
node.value.loc.start = node.key.loc.end;
|
|
241
|
-
node.value.range[0] = node.key.range[1];
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return node;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
233
|
mapComment(node) {
|
|
248
234
|
if (node.type === 'CommentBlock') {
|
|
249
235
|
node.type = 'Block';
|
|
@@ -76,8 +76,6 @@ export default class HermesToESTreeAdapter extends HermesASTAdapter {
|
|
|
76
76
|
return this.mapExportNamedDeclaration(node);
|
|
77
77
|
case 'ExportAllDeclaration':
|
|
78
78
|
return this.mapExportAllDeclaration(node);
|
|
79
|
-
case 'Property':
|
|
80
|
-
return this.mapProperty(node);
|
|
81
79
|
case 'FunctionDeclaration':
|
|
82
80
|
case 'FunctionExpression':
|
|
83
81
|
case 'ArrowFunctionExpression':
|
|
@@ -214,20 +212,6 @@ export default class HermesToESTreeAdapter extends HermesASTAdapter {
|
|
|
214
212
|
return this.mapNodeDefault(node);
|
|
215
213
|
}
|
|
216
214
|
|
|
217
|
-
mapProperty(nodeUnprocessed: HermesNode): HermesNode {
|
|
218
|
-
const node = this.mapNodeDefault(nodeUnprocessed);
|
|
219
|
-
|
|
220
|
-
if (
|
|
221
|
-
node.value.type === 'FunctionExpression' &&
|
|
222
|
-
(node.method || node.kind !== 'init')
|
|
223
|
-
) {
|
|
224
|
-
node.value.loc.start = node.key.loc.end;
|
|
225
|
-
node.value.range[0] = node.key.range[1];
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return node;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
215
|
mapComment(node: HermesNode): HermesNode {
|
|
232
216
|
if (node.type === 'CommentBlock') {
|
|
233
217
|
node.type = 'Block';
|
|
@@ -1065,6 +1065,22 @@ function transformNode(node) {
|
|
|
1065
1065
|
return node;
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
|
+
case 'DeclareOpaqueType':
|
|
1069
|
+
case 'OpaqueType':
|
|
1070
|
+
{
|
|
1071
|
+
if (node.lowerBound != null) {
|
|
1072
|
+
// $FlowExpectedError[cannot-write]
|
|
1073
|
+
delete node.lowerBound;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
if (node.upperBound != null) {
|
|
1077
|
+
// $FlowExpectedError[cannot-write]
|
|
1078
|
+
delete node.upperBound;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
return node;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1068
1084
|
default:
|
|
1069
1085
|
{
|
|
1070
1086
|
return node;
|
|
@@ -1223,6 +1223,18 @@ function transformNode(node: ESNodeOrBabelNode): ESNodeOrBabelNode | null {
|
|
|
1223
1223
|
}
|
|
1224
1224
|
return node;
|
|
1225
1225
|
}
|
|
1226
|
+
case 'DeclareOpaqueType':
|
|
1227
|
+
case 'OpaqueType': {
|
|
1228
|
+
if (node.lowerBound != null) {
|
|
1229
|
+
// $FlowExpectedError[cannot-write]
|
|
1230
|
+
delete node.lowerBound;
|
|
1231
|
+
}
|
|
1232
|
+
if (node.upperBound != null) {
|
|
1233
|
+
// $FlowExpectedError[cannot-write]
|
|
1234
|
+
delete node.upperBound;
|
|
1235
|
+
}
|
|
1236
|
+
return node;
|
|
1237
|
+
}
|
|
1226
1238
|
default: {
|
|
1227
1239
|
return node;
|
|
1228
1240
|
}
|
|
@@ -311,8 +311,8 @@ function mapComponentParameterType(
|
|
|
311
311
|
param.local.type === 'AssignmentPattern'
|
|
312
312
|
? true
|
|
313
313
|
: param.local.type === 'Identifier'
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
? param.local.optional
|
|
315
|
+
: false;
|
|
316
316
|
|
|
317
317
|
return {
|
|
318
318
|
type: 'ObjectTypeProperty',
|
|
@@ -66,7 +66,7 @@ module.exports = {
|
|
|
66
66
|
DeclareModule: ['id', 'body'],
|
|
67
67
|
DeclareModuleExports: ['typeAnnotation'],
|
|
68
68
|
DeclareNamespace: ['id', 'body'],
|
|
69
|
-
DeclareOpaqueType: ['id', 'typeParameters', 'impltype', 'supertype'],
|
|
69
|
+
DeclareOpaqueType: ['id', 'typeParameters', 'impltype', 'lowerBound', 'upperBound', 'supertype'],
|
|
70
70
|
DeclareTypeAlias: ['id', 'typeParameters', 'right'],
|
|
71
71
|
DeclareVariable: ['id'],
|
|
72
72
|
DoWhileStatement: ['body', 'test'],
|
|
@@ -166,7 +166,7 @@ module.exports = {
|
|
|
166
166
|
ObjectTypeMappedTypeProperty: ['keyTparam', 'propType', 'sourceType', 'variance'],
|
|
167
167
|
ObjectTypeProperty: ['key', 'value', 'variance'],
|
|
168
168
|
ObjectTypeSpreadProperty: ['argument'],
|
|
169
|
-
OpaqueType: ['id', 'typeParameters', 'impltype', 'supertype'],
|
|
169
|
+
OpaqueType: ['id', 'typeParameters', 'impltype', 'lowerBound', 'upperBound', 'supertype'],
|
|
170
170
|
OptionalIndexedAccessType: ['objectType', 'indexType'],
|
|
171
171
|
PrivateIdentifier: [],
|
|
172
172
|
Program: ['body'],
|
|
@@ -214,6 +214,8 @@ const HERMES_AST_VISITOR_KEYS = {
|
|
|
214
214
|
id: 'Node',
|
|
215
215
|
typeParameters: 'Node',
|
|
216
216
|
impltype: 'Node',
|
|
217
|
+
lowerBound: 'Node',
|
|
218
|
+
upperBound: 'Node',
|
|
217
219
|
supertype: 'Node'
|
|
218
220
|
},
|
|
219
221
|
DeclareTypeAlias: {
|
|
@@ -586,6 +588,8 @@ const HERMES_AST_VISITOR_KEYS = {
|
|
|
586
588
|
id: 'Node',
|
|
587
589
|
typeParameters: 'Node',
|
|
588
590
|
impltype: 'Node',
|
|
591
|
+
lowerBound: 'Node',
|
|
592
|
+
upperBound: 'Node',
|
|
589
593
|
supertype: 'Node'
|
|
590
594
|
},
|
|
591
595
|
OptionalIndexedAccessType: {
|
package/dist/index.js.flow
CHANGED
|
@@ -66,14 +66,14 @@ function getOptions(options?: ParserOptions = {...DEFAULTS}) {
|
|
|
66
66
|
|
|
67
67
|
declare function parse(
|
|
68
68
|
code: string,
|
|
69
|
-
opts: {...ParserOptions, babel: true}
|
|
69
|
+
opts: $ReadOnly<{...ParserOptions, babel: true}>,
|
|
70
70
|
): BabelFile;
|
|
71
71
|
// eslint-disable-next-line no-redeclare
|
|
72
72
|
declare function parse(
|
|
73
73
|
code: string,
|
|
74
74
|
opts?:
|
|
75
|
-
| {...ParserOptions, babel?: false | void}
|
|
76
|
-
| {...ParserOptions, babel: false}
|
|
75
|
+
| $ReadOnly<{...ParserOptions, babel?: false | void}>
|
|
76
|
+
| $ReadOnly<{...ParserOptions, babel: false}>,
|
|
77
77
|
): ESTreeProgram;
|
|
78
78
|
|
|
79
79
|
// eslint-disable-next-line no-redeclare
|
|
@@ -1547,6 +1547,8 @@ function deserializeOpaqueType() {
|
|
|
1547
1547
|
id: this.deserializeNode(),
|
|
1548
1548
|
typeParameters: this.deserializeNode(),
|
|
1549
1549
|
impltype: this.deserializeNode(),
|
|
1550
|
+
lowerBound: this.deserializeNode(),
|
|
1551
|
+
upperBound: this.deserializeNode(),
|
|
1550
1552
|
supertype: this.deserializeNode()
|
|
1551
1553
|
};
|
|
1552
1554
|
}
|
|
@@ -1579,6 +1581,8 @@ function deserializeDeclareOpaqueType() {
|
|
|
1579
1581
|
id: this.deserializeNode(),
|
|
1580
1582
|
typeParameters: this.deserializeNode(),
|
|
1581
1583
|
impltype: this.deserializeNode(),
|
|
1584
|
+
lowerBound: this.deserializeNode(),
|
|
1585
|
+
upperBound: this.deserializeNode(),
|
|
1582
1586
|
supertype: this.deserializeNode()
|
|
1583
1587
|
};
|
|
1584
1588
|
}
|
|
@@ -95,9 +95,6 @@ class HermesToESTreeAdapter extends _HermesASTAdapter.default {
|
|
|
95
95
|
case 'ExportAllDeclaration':
|
|
96
96
|
return this.mapExportAllDeclaration(node);
|
|
97
97
|
|
|
98
|
-
case 'Property':
|
|
99
|
-
return this.mapProperty(node);
|
|
100
|
-
|
|
101
98
|
case 'FunctionDeclaration':
|
|
102
99
|
case 'FunctionExpression':
|
|
103
100
|
case 'ArrowFunctionExpression':
|
|
@@ -233,17 +230,6 @@ class HermesToESTreeAdapter extends _HermesASTAdapter.default {
|
|
|
233
230
|
return this.mapNodeDefault(node);
|
|
234
231
|
}
|
|
235
232
|
|
|
236
|
-
mapProperty(nodeUnprocessed) {
|
|
237
|
-
const node = this.mapNodeDefault(nodeUnprocessed);
|
|
238
|
-
|
|
239
|
-
if (node.value.type === 'FunctionExpression' && (node.method || node.kind !== 'init')) {
|
|
240
|
-
node.value.loc.start = node.key.loc.end;
|
|
241
|
-
node.value.range[0] = node.key.range[1];
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return node;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
233
|
mapComment(node) {
|
|
248
234
|
if (node.type === 'CommentBlock') {
|
|
249
235
|
node.type = 'Block';
|
|
@@ -1065,6 +1065,22 @@ function transformNode(node) {
|
|
|
1065
1065
|
return node;
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
|
+
case 'DeclareOpaqueType':
|
|
1069
|
+
case 'OpaqueType':
|
|
1070
|
+
{
|
|
1071
|
+
if (node.lowerBound != null) {
|
|
1072
|
+
// $FlowExpectedError[cannot-write]
|
|
1073
|
+
delete node.lowerBound;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
if (node.upperBound != null) {
|
|
1077
|
+
// $FlowExpectedError[cannot-write]
|
|
1078
|
+
delete node.upperBound;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
return node;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1068
1084
|
default:
|
|
1069
1085
|
{
|
|
1070
1086
|
return node;
|
|
@@ -66,7 +66,7 @@ module.exports = {
|
|
|
66
66
|
DeclareModule: ['id', 'body'],
|
|
67
67
|
DeclareModuleExports: ['typeAnnotation'],
|
|
68
68
|
DeclareNamespace: ['id', 'body'],
|
|
69
|
-
DeclareOpaqueType: ['id', 'typeParameters', 'impltype', 'supertype'],
|
|
69
|
+
DeclareOpaqueType: ['id', 'typeParameters', 'impltype', 'lowerBound', 'upperBound', 'supertype'],
|
|
70
70
|
DeclareTypeAlias: ['id', 'typeParameters', 'right'],
|
|
71
71
|
DeclareVariable: ['id'],
|
|
72
72
|
DoWhileStatement: ['body', 'test'],
|
|
@@ -166,7 +166,7 @@ module.exports = {
|
|
|
166
166
|
ObjectTypeMappedTypeProperty: ['keyTparam', 'propType', 'sourceType', 'variance'],
|
|
167
167
|
ObjectTypeProperty: ['key', 'value', 'variance'],
|
|
168
168
|
ObjectTypeSpreadProperty: ['argument'],
|
|
169
|
-
OpaqueType: ['id', 'typeParameters', 'impltype', 'supertype'],
|
|
169
|
+
OpaqueType: ['id', 'typeParameters', 'impltype', 'lowerBound', 'upperBound', 'supertype'],
|
|
170
170
|
OptionalIndexedAccessType: ['objectType', 'indexType'],
|
|
171
171
|
PrivateIdentifier: [],
|
|
172
172
|
Program: ['body'],
|
|
@@ -214,6 +214,8 @@ const HERMES_AST_VISITOR_KEYS = {
|
|
|
214
214
|
id: 'Node',
|
|
215
215
|
typeParameters: 'Node',
|
|
216
216
|
impltype: 'Node',
|
|
217
|
+
lowerBound: 'Node',
|
|
218
|
+
upperBound: 'Node',
|
|
217
219
|
supertype: 'Node'
|
|
218
220
|
},
|
|
219
221
|
DeclareTypeAlias: {
|
|
@@ -586,6 +588,8 @@ const HERMES_AST_VISITOR_KEYS = {
|
|
|
586
588
|
id: 'Node',
|
|
587
589
|
typeParameters: 'Node',
|
|
588
590
|
impltype: 'Node',
|
|
591
|
+
lowerBound: 'Node',
|
|
592
|
+
upperBound: 'Node',
|
|
589
593
|
supertype: 'Node'
|
|
590
594
|
},
|
|
591
595
|
OptionalIndexedAccessType: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermes-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "A JavaScript parser built from the Hermes engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git@github.com:facebook/hermes.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"hermes-estree": "0.
|
|
12
|
+
"hermes-estree": "0.31.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@babel/parser": "7.7.4",
|