hermes-estree 0.32.1 → 0.33.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/generated/HermesESTreeSelectorTypes.js.flow +262 -27
- package/dist/generated/predicates.js +120 -0
- package/dist/generated/predicates.js.flow +72 -0
- package/dist/predicates.js +2 -4
- package/dist/predicates.js.flow +5 -4
- package/dist/src/generated/predicates.js +120 -0
- package/dist/src/predicates.js +2 -4
- package/dist/types.js.flow +103 -11
- package/package.json +1 -1
- package/dist/HermesAST.js.flow +0 -57
- package/dist/HermesASTAdapter.js +0 -192
- package/dist/HermesASTAdapter.js.flow +0 -189
- package/dist/HermesParser.js +0 -108
- package/dist/HermesParser.js.flow +0 -161
- package/dist/HermesParserDecodeUTF8String.js +0 -68
- package/dist/HermesParserDecodeUTF8String.js.flow +0 -65
- package/dist/HermesParserDeserializer.js +0 -242
- package/dist/HermesParserDeserializer.js.flow +0 -260
- package/dist/HermesParserNodeDeserializers.js +0 -2477
- package/dist/HermesParserNodeDeserializers.js.flow +0 -16
- package/dist/HermesParserWASM.js +0 -6
- package/dist/HermesParserWASM.js.flow +0 -87
- package/dist/HermesToESTreeAdapter.js +0 -439
- package/dist/HermesToESTreeAdapter.js.flow +0 -421
- package/dist/ParserOptions.js +0 -18
- package/dist/ParserOptions.js.flow +0 -41
- package/dist/babel/TransformESTreeToBabel.js +0 -1123
- package/dist/babel/TransformESTreeToBabel.js.flow +0 -1277
- package/dist/estree/StripFlowTypes.js +0 -175
- package/dist/estree/StripFlowTypes.js.flow +0 -158
- package/dist/estree/StripFlowTypesForBabel.js +0 -215
- package/dist/estree/StripFlowTypesForBabel.js.flow +0 -216
- package/dist/estree/TransformComponentSyntax.js +0 -788
- package/dist/estree/TransformComponentSyntax.js.flow +0 -864
- package/dist/estree/TransformEnumSyntax.js +0 -106
- package/dist/estree/TransformEnumSyntax.js.flow +0 -125
- package/dist/estree/TransformMatchSyntax.js +0 -1006
- package/dist/estree/TransformMatchSyntax.js.flow +0 -912
- package/dist/generated/ESTreeVisitorKeys.js +0 -220
- package/dist/generated/ESTreeVisitorKeys.js.flow +0 -15
- package/dist/generated/ParserVisitorKeys.js +0 -794
- package/dist/generated/ParserVisitorKeys.js.flow +0 -17
- package/dist/getModuleDocblock.js +0 -112
- package/dist/getModuleDocblock.js.flow +0 -118
- package/dist/src/HermesASTAdapter.js +0 -192
- package/dist/src/HermesParser.js +0 -108
- package/dist/src/HermesParserDecodeUTF8String.js +0 -68
- package/dist/src/HermesParserDeserializer.js +0 -242
- package/dist/src/HermesParserNodeDeserializers.js +0 -2477
- package/dist/src/HermesToESTreeAdapter.js +0 -439
- package/dist/src/ParserOptions.js +0 -18
- package/dist/src/babel/TransformESTreeToBabel.js +0 -1123
- package/dist/src/estree/StripFlowTypes.js +0 -175
- package/dist/src/estree/StripFlowTypesForBabel.js +0 -215
- package/dist/src/estree/TransformComponentSyntax.js +0 -788
- package/dist/src/estree/TransformEnumSyntax.js +0 -106
- package/dist/src/estree/TransformMatchSyntax.js +0 -1006
- package/dist/src/generated/ESTreeVisitorKeys.js +0 -220
- package/dist/src/generated/ParserVisitorKeys.js +0 -794
- package/dist/src/getModuleDocblock.js +0 -112
- package/dist/src/transform/SimpleTransform.js +0 -136
- package/dist/src/transform/astArrayMutationHelpers.js +0 -62
- package/dist/src/transform/astNodeMutationHelpers.js +0 -200
- package/dist/src/traverse/SimpleTraverser.js +0 -137
- package/dist/src/traverse/getVisitorKeys.js +0 -37
- package/dist/src/utils/Builders.js +0 -191
- package/dist/src/utils/GenID.js +0 -41
- package/dist/src/utils/createSyntaxError.js +0 -25
- package/dist/src/utils/mutateESTreeASTForPrettier.js +0 -127
- package/dist/transform/SimpleTransform.js +0 -136
- package/dist/transform/SimpleTransform.js.flow +0 -169
- package/dist/transform/astArrayMutationHelpers.js +0 -62
- package/dist/transform/astArrayMutationHelpers.js.flow +0 -71
- package/dist/transform/astNodeMutationHelpers.js +0 -200
- package/dist/transform/astNodeMutationHelpers.js.flow +0 -246
- package/dist/traverse/SimpleTraverser.js +0 -137
- package/dist/traverse/SimpleTraverser.js.flow +0 -133
- package/dist/traverse/getVisitorKeys.js +0 -37
- package/dist/traverse/getVisitorKeys.js.flow +0 -36
- package/dist/utils/Builders.js +0 -191
- package/dist/utils/Builders.js.flow +0 -218
- package/dist/utils/GenID.js +0 -41
- package/dist/utils/GenID.js.flow +0 -38
- package/dist/utils/createSyntaxError.js +0 -25
- package/dist/utils/createSyntaxError.js.flow +0 -24
- package/dist/utils/mutateESTreeASTForPrettier.js +0 -127
- package/dist/utils/mutateESTreeASTForPrettier.js.flow +0 -130
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _HermesASTAdapter = _interopRequireDefault(require("./HermesASTAdapter"));
|
|
9
|
-
|
|
10
|
-
var _getModuleDocblock = require("./getModuleDocblock");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
16
|
-
*
|
|
17
|
-
* This source code is licensed under the MIT license found in the
|
|
18
|
-
* LICENSE file in the root directory of this source tree.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @format
|
|
22
|
-
*/
|
|
23
|
-
class HermesToESTreeAdapter extends _HermesASTAdapter.default {
|
|
24
|
-
constructor(options, code) {
|
|
25
|
-
super(options);
|
|
26
|
-
this.code = void 0;
|
|
27
|
-
this.code = code;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
fixSourceLocation(node) {
|
|
31
|
-
var _this$sourceFilename;
|
|
32
|
-
|
|
33
|
-
const loc = node.loc;
|
|
34
|
-
|
|
35
|
-
if (loc == null) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
node.loc = {
|
|
40
|
-
source: (_this$sourceFilename = this.sourceFilename) != null ? _this$sourceFilename : null,
|
|
41
|
-
start: loc.start,
|
|
42
|
-
end: loc.end
|
|
43
|
-
};
|
|
44
|
-
node.range = [loc.rangeStart, loc.rangeEnd];
|
|
45
|
-
delete node.start;
|
|
46
|
-
delete node.end;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
mapNode(node) {
|
|
50
|
-
this.fixSourceLocation(node);
|
|
51
|
-
|
|
52
|
-
switch (node.type) {
|
|
53
|
-
case 'Program':
|
|
54
|
-
return this.mapProgram(node);
|
|
55
|
-
|
|
56
|
-
case 'NullLiteral':
|
|
57
|
-
return this.mapNullLiteral(node);
|
|
58
|
-
|
|
59
|
-
case 'BooleanLiteral':
|
|
60
|
-
case 'StringLiteral':
|
|
61
|
-
case 'NumericLiteral':
|
|
62
|
-
case 'JSXStringLiteral':
|
|
63
|
-
return this.mapSimpleLiteral(node);
|
|
64
|
-
|
|
65
|
-
case 'BigIntLiteral':
|
|
66
|
-
return this.mapBigIntLiteral(node);
|
|
67
|
-
|
|
68
|
-
case 'RegExpLiteral':
|
|
69
|
-
return this.mapRegExpLiteral(node);
|
|
70
|
-
|
|
71
|
-
case 'Empty':
|
|
72
|
-
return this.mapEmpty(node);
|
|
73
|
-
|
|
74
|
-
case 'TemplateElement':
|
|
75
|
-
return this.mapTemplateElement(node);
|
|
76
|
-
|
|
77
|
-
case 'BigIntLiteralTypeAnnotation':
|
|
78
|
-
return this.mapBigIntLiteralTypeAnnotation(node);
|
|
79
|
-
|
|
80
|
-
case 'GenericTypeAnnotation':
|
|
81
|
-
return this.mapGenericTypeAnnotation(node);
|
|
82
|
-
|
|
83
|
-
case 'ImportDeclaration':
|
|
84
|
-
return this.mapImportDeclaration(node);
|
|
85
|
-
|
|
86
|
-
case 'ImportSpecifier':
|
|
87
|
-
return this.mapImportSpecifier(node);
|
|
88
|
-
|
|
89
|
-
case 'ExportDefaultDeclaration':
|
|
90
|
-
return this.mapExportDefaultDeclaration(node);
|
|
91
|
-
|
|
92
|
-
case 'ExportNamedDeclaration':
|
|
93
|
-
return this.mapExportNamedDeclaration(node);
|
|
94
|
-
|
|
95
|
-
case 'ExportAllDeclaration':
|
|
96
|
-
return this.mapExportAllDeclaration(node);
|
|
97
|
-
|
|
98
|
-
case 'FunctionDeclaration':
|
|
99
|
-
case 'FunctionExpression':
|
|
100
|
-
case 'ArrowFunctionExpression':
|
|
101
|
-
return this.mapFunction(node);
|
|
102
|
-
|
|
103
|
-
case 'PrivateName':
|
|
104
|
-
return this.mapPrivateName(node);
|
|
105
|
-
|
|
106
|
-
case 'ClassProperty':
|
|
107
|
-
case 'ClassPrivateProperty':
|
|
108
|
-
return this.mapClassProperty(node);
|
|
109
|
-
|
|
110
|
-
case 'MemberExpression':
|
|
111
|
-
case 'OptionalMemberExpression':
|
|
112
|
-
case 'CallExpression':
|
|
113
|
-
case 'OptionalCallExpression':
|
|
114
|
-
return this.mapChainExpression(node);
|
|
115
|
-
|
|
116
|
-
case 'BlockStatement':
|
|
117
|
-
return this.mapBlockStatement(node);
|
|
118
|
-
|
|
119
|
-
default:
|
|
120
|
-
return this.mapNodeDefault(node);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
mapProgram(node) {
|
|
125
|
-
const nodeDefault = this.mapNodeDefault(node);
|
|
126
|
-
node.sourceType = this.getSourceType();
|
|
127
|
-
node.docblock = (0, _getModuleDocblock.getModuleDocblock)(nodeDefault);
|
|
128
|
-
return nodeDefault;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
mapSimpleLiteral(node) {
|
|
132
|
-
return {
|
|
133
|
-
type: 'Literal',
|
|
134
|
-
loc: node.loc,
|
|
135
|
-
range: node.range,
|
|
136
|
-
value: node.value,
|
|
137
|
-
raw: this.code.slice(node.range[0], node.range[1]),
|
|
138
|
-
literalType: (() => {
|
|
139
|
-
switch (node.type) {
|
|
140
|
-
case 'NullLiteral':
|
|
141
|
-
return 'null';
|
|
142
|
-
|
|
143
|
-
case 'BooleanLiteral':
|
|
144
|
-
return 'boolean';
|
|
145
|
-
|
|
146
|
-
case 'StringLiteral':
|
|
147
|
-
case 'JSXStringLiteral':
|
|
148
|
-
return 'string';
|
|
149
|
-
|
|
150
|
-
case 'NumericLiteral':
|
|
151
|
-
return 'numeric';
|
|
152
|
-
|
|
153
|
-
case 'BigIntLiteral':
|
|
154
|
-
return 'bigint';
|
|
155
|
-
|
|
156
|
-
case 'RegExpLiteral':
|
|
157
|
-
return 'regexp';
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return null;
|
|
161
|
-
})()
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
mapBigIntLiteral(node) {
|
|
166
|
-
const newNode = this.mapSimpleLiteral(node);
|
|
167
|
-
return { ...newNode,
|
|
168
|
-
...this.getBigIntLiteralValue(node.bigint)
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
mapNullLiteral(node) {
|
|
173
|
-
return { ...this.mapSimpleLiteral(node),
|
|
174
|
-
value: null
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
mapRegExpLiteral(node) {
|
|
179
|
-
const {
|
|
180
|
-
pattern,
|
|
181
|
-
flags
|
|
182
|
-
} = node; // Create RegExp value if possible. This can fail when the flags are invalid.
|
|
183
|
-
|
|
184
|
-
let value;
|
|
185
|
-
|
|
186
|
-
try {
|
|
187
|
-
value = new RegExp(pattern, flags);
|
|
188
|
-
} catch (e) {
|
|
189
|
-
value = null;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return { ...this.mapSimpleLiteral(node),
|
|
193
|
-
value,
|
|
194
|
-
regex: {
|
|
195
|
-
pattern,
|
|
196
|
-
flags
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
mapBigIntLiteralTypeAnnotation(node) {
|
|
202
|
-
return { ...node,
|
|
203
|
-
...this.getBigIntLiteralValue(node.raw)
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
mapTemplateElement(node) {
|
|
208
|
-
return {
|
|
209
|
-
type: 'TemplateElement',
|
|
210
|
-
loc: node.loc,
|
|
211
|
-
range: node.range,
|
|
212
|
-
tail: node.tail,
|
|
213
|
-
value: {
|
|
214
|
-
cooked: node.cooked,
|
|
215
|
-
raw: node.raw
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
mapGenericTypeAnnotation(node) {
|
|
221
|
-
// Convert simple `this` generic type to ThisTypeAnnotation
|
|
222
|
-
if (node.typeParameters == null && node.id.type === 'Identifier' && node.id.name === 'this') {
|
|
223
|
-
return {
|
|
224
|
-
type: 'ThisTypeAnnotation',
|
|
225
|
-
loc: node.loc,
|
|
226
|
-
range: node.range
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return this.mapNodeDefault(node);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
mapComment(node) {
|
|
234
|
-
if (node.type === 'CommentBlock') {
|
|
235
|
-
node.type = 'Block';
|
|
236
|
-
} else if (node.type === 'CommentLine') {
|
|
237
|
-
node.type = 'Line';
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return node;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
mapFunction(nodeUnprocessed) {
|
|
244
|
-
const node = this.mapNodeDefault(nodeUnprocessed);
|
|
245
|
-
|
|
246
|
-
switch (node.type) {
|
|
247
|
-
// This prop should ideally only live on `ArrowFunctionExpression` but to
|
|
248
|
-
// match espree output we place it on all functions types.
|
|
249
|
-
case 'FunctionDeclaration':
|
|
250
|
-
case 'FunctionExpression':
|
|
251
|
-
node.expression = false;
|
|
252
|
-
return node;
|
|
253
|
-
|
|
254
|
-
case 'ArrowFunctionExpression':
|
|
255
|
-
node.expression = node.body.type !== 'BlockStatement';
|
|
256
|
-
return node;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return node;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
mapChainExpression(nodeUnprocessed) {
|
|
263
|
-
/*
|
|
264
|
-
NOTE - In the below comments `MemberExpression` and `CallExpression`
|
|
265
|
-
are completely interchangable. For terseness we just reference
|
|
266
|
-
one each time.
|
|
267
|
-
*/
|
|
268
|
-
|
|
269
|
-
/*
|
|
270
|
-
Hermes uses the old babel-style AST:
|
|
271
|
-
```
|
|
272
|
-
(one?.two).three?.four;
|
|
273
|
-
^^^^^^^^^^^^^^^^^^^^^^ OptionalMemberExpression
|
|
274
|
-
^^^^^^^^^^^^^^^^ MemberExpression
|
|
275
|
-
^^^^^^^^ OptionalMemberExpression
|
|
276
|
-
```
|
|
277
|
-
We need to convert it to the ESTree representation:
|
|
278
|
-
```
|
|
279
|
-
(one?.two).three?.four;
|
|
280
|
-
^^^^^^^^^^^^^^^^^^^^^^ ChainExpression
|
|
281
|
-
^^^^^^^^^^^^^^^^^^^^^^ MemberExpression[optional = true]
|
|
282
|
-
^^^^^^^^^^^^^^^^ MemberExpression[optional = false]
|
|
283
|
-
^^^^^^^^ ChainExpression
|
|
284
|
-
^^^^^^^^ MemberExpression[optional = true]
|
|
285
|
-
```
|
|
286
|
-
We do this by converting the AST and its children (depth first), and then unwrapping
|
|
287
|
-
the resulting AST as appropriate.
|
|
288
|
-
Put another way:
|
|
289
|
-
1) traverse to the leaf
|
|
290
|
-
2) if the current node is an `OptionalMemberExpression`:
|
|
291
|
-
a) if the `.object` is a `ChainExpression`:
|
|
292
|
-
i) unwrap the child (`node.object = child.expression`)
|
|
293
|
-
b) convert this node to a `MemberExpression[optional = true]`
|
|
294
|
-
c) wrap this node (`node = ChainExpression[expression = node]`)
|
|
295
|
-
3) if the current node is a `MemberExpression`:
|
|
296
|
-
a) convert this node to a `MemberExpression[optional = true]`
|
|
297
|
-
*/
|
|
298
|
-
const node = this.mapNodeDefault(nodeUnprocessed);
|
|
299
|
-
|
|
300
|
-
const {
|
|
301
|
-
child,
|
|
302
|
-
childKey,
|
|
303
|
-
isOptional
|
|
304
|
-
} = (() => {
|
|
305
|
-
const isOptional = node.optional === true;
|
|
306
|
-
|
|
307
|
-
if (node.type.endsWith('MemberExpression')) {
|
|
308
|
-
return {
|
|
309
|
-
child: node.object,
|
|
310
|
-
childKey: 'object',
|
|
311
|
-
isOptional
|
|
312
|
-
};
|
|
313
|
-
} else if (node.type.endsWith('CallExpression')) {
|
|
314
|
-
return {
|
|
315
|
-
child: node.callee,
|
|
316
|
-
childKey: 'callee',
|
|
317
|
-
isOptional
|
|
318
|
-
};
|
|
319
|
-
} else {
|
|
320
|
-
return {
|
|
321
|
-
child: node.expression,
|
|
322
|
-
childKey: 'expression',
|
|
323
|
-
isOptional: false
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
})();
|
|
327
|
-
|
|
328
|
-
const isChildUnwrappable = child.type === 'ChainExpression' && // (x?.y).z is semantically different to `x?.y.z`.
|
|
329
|
-
// In the un-parenthesised case `.z` is only executed if and only if `x?.y` returns a non-nullish value.
|
|
330
|
-
// In the parenthesised case, `.z` is **always** executed, regardless of the return of `x?.y`.
|
|
331
|
-
// As such the AST is different between the two cases.
|
|
332
|
-
//
|
|
333
|
-
// In the hermes AST - any member part of a non-short-circuited optional chain is represented with `OptionalMemberExpression`
|
|
334
|
-
// so if we see a `MemberExpression`, then we know we've hit a parenthesis boundary.
|
|
335
|
-
node.type !== 'MemberExpression' && node.type !== 'CallExpression';
|
|
336
|
-
|
|
337
|
-
if (node.type.startsWith('Optional')) {
|
|
338
|
-
node.type = node.type.replace('Optional', '');
|
|
339
|
-
node.optional = isOptional;
|
|
340
|
-
} else {
|
|
341
|
-
node.optional = false;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (!isChildUnwrappable && !isOptional) {
|
|
345
|
-
return node;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
if (isChildUnwrappable) {
|
|
349
|
-
const newChild = child.expression;
|
|
350
|
-
node[childKey] = newChild;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
return {
|
|
354
|
-
type: 'ChainExpression',
|
|
355
|
-
expression: node,
|
|
356
|
-
loc: node.loc,
|
|
357
|
-
range: node.range
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
mapClassProperty(nodeUnprocessed) {
|
|
362
|
-
const node = this.mapNodeDefault(nodeUnprocessed);
|
|
363
|
-
|
|
364
|
-
const key = (() => {
|
|
365
|
-
if (node.type === 'ClassPrivateProperty') {
|
|
366
|
-
const key = this.mapNodeDefault(node.key);
|
|
367
|
-
return {
|
|
368
|
-
type: 'PrivateIdentifier',
|
|
369
|
-
name: key.name,
|
|
370
|
-
range: key.range,
|
|
371
|
-
loc: key.loc
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return node.key;
|
|
376
|
-
})();
|
|
377
|
-
|
|
378
|
-
return { ...node,
|
|
379
|
-
computed: node.type === 'ClassPrivateProperty' ? false : node.computed,
|
|
380
|
-
key,
|
|
381
|
-
type: 'PropertyDefinition'
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
mapPrivateName(node) {
|
|
386
|
-
return {
|
|
387
|
-
type: 'PrivateIdentifier',
|
|
388
|
-
name: node.id.name,
|
|
389
|
-
// estree the location refers to the entire string including the hash token
|
|
390
|
-
range: node.range,
|
|
391
|
-
loc: node.loc
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
mapExportNamedDeclaration(nodeUnprocessed) {
|
|
396
|
-
const node = super.mapExportNamedDeclaration(nodeUnprocessed);
|
|
397
|
-
const namespaceSpecifier = node.specifiers.find(spec => spec.type === 'ExportNamespaceSpecifier');
|
|
398
|
-
|
|
399
|
-
if (namespaceSpecifier != null) {
|
|
400
|
-
var _node$exportKind;
|
|
401
|
-
|
|
402
|
-
if (node.specifiers.length !== 1) {
|
|
403
|
-
// this should already a hermes parser error - but let's be absolutely sure we're aligned with the spec
|
|
404
|
-
throw new Error('Cannot use an export all with any other specifiers');
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
return {
|
|
408
|
-
type: 'ExportAllDeclaration',
|
|
409
|
-
source: node.source,
|
|
410
|
-
exportKind: (_node$exportKind = node.exportKind) != null ? _node$exportKind : 'value',
|
|
411
|
-
exported: namespaceSpecifier.exported,
|
|
412
|
-
range: node.range,
|
|
413
|
-
loc: node.loc
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
return node;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
mapExportAllDeclaration(nodeUnprocessed) {
|
|
421
|
-
var _node$exported;
|
|
422
|
-
|
|
423
|
-
const node = super.mapExportAllDeclaration(nodeUnprocessed);
|
|
424
|
-
node.exported = (_node$exported = node.exported) != null ? _node$exported : null;
|
|
425
|
-
return node;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
mapBlockStatement(node) {
|
|
429
|
-
if (node.implicit && node.body.length) {
|
|
430
|
-
return this.mapNode(node.body[0]);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
delete node.implicit;
|
|
434
|
-
return this.mapNodeDefault(node);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
exports.default = HermesToESTreeAdapter;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ParserOptionsKeys = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
10
|
-
*
|
|
11
|
-
* This source code is licensed under the MIT license found in the
|
|
12
|
-
* LICENSE file in the root directory of this source tree.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @format
|
|
16
|
-
*/
|
|
17
|
-
const ParserOptionsKeys = new Set(['allowReturnOutsideFunction', 'babel', 'flow', 'enableExperimentalComponentSyntax', 'enableExperimentalFlowMatchSyntax', 'reactRuntimeTarget', 'sourceFilename', 'sourceType', 'tokens', 'transformOptions']);
|
|
18
|
-
exports.ParserOptionsKeys = ParserOptionsKeys;
|