hermes-parser 0.28.1 → 0.29.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.
Files changed (41) hide show
  1. package/dist/HermesASTAdapter.js +1 -2
  2. package/dist/HermesASTAdapter.js.flow +2 -5
  3. package/dist/HermesParserNodeDeserializers.js +3 -2
  4. package/dist/HermesParserWASM.js +1 -1
  5. package/dist/HermesToESTreeAdapter.js +12 -0
  6. package/dist/HermesToESTreeAdapter.js.flow +10 -0
  7. package/dist/babel/TransformESTreeToBabel.js.flow +21 -19
  8. package/dist/estree/StripComponentSyntax.js.flow +6 -5
  9. package/dist/estree/TransformMatchSyntax.js +4 -15
  10. package/dist/estree/TransformMatchSyntax.js.flow +18 -19
  11. package/dist/generated/ESTreeVisitorKeys.js +1 -1
  12. package/dist/generated/ParserVisitorKeys.js +1 -1
  13. package/dist/index.js.flow +1 -1
  14. package/dist/src/HermesASTAdapter.js +192 -0
  15. package/dist/src/HermesParser.js +108 -0
  16. package/dist/src/HermesParserDecodeUTF8String.js +68 -0
  17. package/dist/src/HermesParserDeserializer.js +243 -0
  18. package/dist/src/HermesParserNodeDeserializers.js +2473 -0
  19. package/dist/src/HermesToESTreeAdapter.js +453 -0
  20. package/dist/src/ParserOptions.js +18 -0
  21. package/dist/src/babel/TransformESTreeToBabel.js +1104 -0
  22. package/dist/src/estree/StripComponentSyntax.js +788 -0
  23. package/dist/src/estree/StripFlowTypes.js +175 -0
  24. package/dist/src/estree/StripFlowTypesForBabel.js +215 -0
  25. package/dist/src/estree/TransformMatchSyntax.js +1005 -0
  26. package/dist/src/generated/ESTreeVisitorKeys.js +220 -0
  27. package/dist/src/generated/ParserVisitorKeys.js +790 -0
  28. package/dist/src/getModuleDocblock.js +112 -0
  29. package/dist/src/index.js +153 -0
  30. package/dist/src/transform/SimpleTransform.js +120 -0
  31. package/dist/src/transform/astArrayMutationHelpers.js +62 -0
  32. package/dist/src/transform/astNodeMutationHelpers.js +195 -0
  33. package/dist/src/traverse/SimpleTraverser.js +137 -0
  34. package/dist/src/traverse/getVisitorKeys.js +37 -0
  35. package/dist/src/utils/Builders.js +191 -0
  36. package/dist/src/utils/GenID.js +41 -0
  37. package/dist/src/utils/createSyntaxError.js +25 -0
  38. package/dist/src/utils/mutateESTreeASTForPrettier.js +127 -0
  39. package/dist/utils/Builders.js +17 -0
  40. package/dist/utils/Builders.js.flow +20 -0
  41. package/package.json +2 -2
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @format
9
+ * @generated
10
+ */
11
+
12
+ /*
13
+ * !!! GENERATED FILE !!!
14
+ *
15
+ * Any manual changes to this file will be overwritten. To regenerate run `yarn build`.
16
+ */
17
+ // lint directives to let us do some basic validation of generated files
18
+
19
+ /* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
20
+
21
+ /* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray, $FlowFixMe */
22
+ 'use strict';
23
+
24
+ module.exports = {
25
+ AnyTypeAnnotation: [],
26
+ ArrayExpression: ['elements'],
27
+ ArrayPattern: ['elements', 'typeAnnotation'],
28
+ ArrayTypeAnnotation: ['elementType'],
29
+ ArrowFunctionExpression: ['id', 'params', 'body', 'typeParameters', 'returnType', 'predicate'],
30
+ AsConstExpression: ['expression'],
31
+ AsExpression: ['expression', 'typeAnnotation'],
32
+ AssignmentExpression: ['left', 'right'],
33
+ AssignmentPattern: ['left', 'right'],
34
+ AwaitExpression: ['argument'],
35
+ BigIntLiteralTypeAnnotation: [],
36
+ BigIntTypeAnnotation: [],
37
+ BinaryExpression: ['left', 'right'],
38
+ BlockStatement: ['body'],
39
+ BooleanLiteralTypeAnnotation: [],
40
+ BooleanTypeAnnotation: [],
41
+ BreakStatement: ['label'],
42
+ CallExpression: ['callee', 'typeArguments', 'arguments'],
43
+ CatchClause: ['param', 'body'],
44
+ ChainExpression: ['expression'],
45
+ ClassBody: ['body'],
46
+ ClassDeclaration: ['id', 'typeParameters', 'superClass', 'superTypeParameters', 'implements', 'decorators', 'body'],
47
+ ClassExpression: ['id', 'typeParameters', 'superClass', 'superTypeParameters', 'implements', 'decorators', 'body'],
48
+ ClassImplements: ['id', 'typeParameters'],
49
+ ComponentDeclaration: ['id', 'params', 'body', 'typeParameters', 'rendersType'],
50
+ ComponentParameter: ['name', 'local'],
51
+ ComponentTypeAnnotation: ['params', 'rest', 'typeParameters', 'rendersType'],
52
+ ComponentTypeParameter: ['name', 'typeAnnotation'],
53
+ ConditionalExpression: ['test', 'consequent', 'alternate'],
54
+ ConditionalTypeAnnotation: ['checkType', 'extendsType', 'trueType', 'falseType'],
55
+ ContinueStatement: ['label'],
56
+ DebuggerStatement: [],
57
+ DeclareClass: ['id', 'typeParameters', 'extends', 'implements', 'mixins', 'body'],
58
+ DeclareComponent: ['id', 'params', 'rest', 'typeParameters', 'rendersType'],
59
+ DeclaredPredicate: ['value'],
60
+ DeclareEnum: ['id', 'body'],
61
+ DeclareExportAllDeclaration: ['source'],
62
+ DeclareExportDeclaration: ['declaration', 'specifiers', 'source'],
63
+ DeclareFunction: ['id', 'predicate'],
64
+ DeclareHook: ['id'],
65
+ DeclareInterface: ['id', 'typeParameters', 'extends', 'body'],
66
+ DeclareModule: ['id', 'body'],
67
+ DeclareModuleExports: ['typeAnnotation'],
68
+ DeclareNamespace: ['id', 'body'],
69
+ DeclareOpaqueType: ['id', 'typeParameters', 'impltype', 'supertype'],
70
+ DeclareTypeAlias: ['id', 'typeParameters', 'right'],
71
+ DeclareVariable: ['id'],
72
+ DoWhileStatement: ['body', 'test'],
73
+ EmptyStatement: [],
74
+ EmptyTypeAnnotation: [],
75
+ EnumBigIntBody: ['members'],
76
+ EnumBigIntMember: ['id', 'init'],
77
+ EnumBooleanBody: ['members'],
78
+ EnumBooleanMember: ['id', 'init'],
79
+ EnumDeclaration: ['id', 'body'],
80
+ EnumDefaultedMember: ['id'],
81
+ EnumNumberBody: ['members'],
82
+ EnumNumberMember: ['id', 'init'],
83
+ EnumStringBody: ['members'],
84
+ EnumStringMember: ['id', 'init'],
85
+ EnumSymbolBody: ['members'],
86
+ ExistsTypeAnnotation: [],
87
+ ExportAllDeclaration: ['exported', 'source'],
88
+ ExportDefaultDeclaration: ['declaration'],
89
+ ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
90
+ ExportSpecifier: ['exported', 'local'],
91
+ ExpressionStatement: ['expression'],
92
+ ForInStatement: ['left', 'right', 'body'],
93
+ ForOfStatement: ['left', 'right', 'body'],
94
+ ForStatement: ['init', 'test', 'update', 'body'],
95
+ FunctionDeclaration: ['id', 'params', 'body', 'typeParameters', 'returnType', 'predicate'],
96
+ FunctionExpression: ['id', 'params', 'body', 'typeParameters', 'returnType', 'predicate'],
97
+ FunctionTypeAnnotation: ['params', 'this', 'returnType', 'rest', 'typeParameters'],
98
+ FunctionTypeParam: ['name', 'typeAnnotation'],
99
+ GenericTypeAnnotation: ['id', 'typeParameters'],
100
+ HookDeclaration: ['id', 'params', 'body', 'typeParameters', 'returnType'],
101
+ HookTypeAnnotation: ['params', 'returnType', 'rest', 'typeParameters'],
102
+ Identifier: ['typeAnnotation'],
103
+ IfStatement: ['test', 'consequent', 'alternate'],
104
+ ImportAttribute: ['key', 'value'],
105
+ ImportDeclaration: ['specifiers', 'source', 'assertions'],
106
+ ImportDefaultSpecifier: ['local'],
107
+ ImportExpression: ['source', 'options'],
108
+ ImportNamespaceSpecifier: ['local'],
109
+ ImportSpecifier: ['imported', 'local'],
110
+ IndexedAccessType: ['objectType', 'indexType'],
111
+ InferredPredicate: [],
112
+ InferTypeAnnotation: ['typeParameter'],
113
+ InterfaceDeclaration: ['id', 'typeParameters', 'extends', 'body'],
114
+ InterfaceExtends: ['id', 'typeParameters'],
115
+ InterfaceTypeAnnotation: ['extends', 'body'],
116
+ IntersectionTypeAnnotation: ['types'],
117
+ JSXAttribute: ['name', 'value'],
118
+ JSXClosingElement: ['name'],
119
+ JSXClosingFragment: [],
120
+ JSXElement: ['openingElement', 'children', 'closingElement'],
121
+ JSXEmptyExpression: [],
122
+ JSXExpressionContainer: ['expression'],
123
+ JSXFragment: ['openingFragment', 'children', 'closingFragment'],
124
+ JSXIdentifier: [],
125
+ JSXMemberExpression: ['object', 'property'],
126
+ JSXNamespacedName: ['namespace', 'name'],
127
+ JSXOpeningElement: ['name', 'attributes', 'typeArguments'],
128
+ JSXOpeningFragment: [],
129
+ JSXSpreadAttribute: ['argument'],
130
+ JSXSpreadChild: ['expression'],
131
+ JSXText: [],
132
+ KeyofTypeAnnotation: ['argument'],
133
+ LabeledStatement: ['label', 'body'],
134
+ LogicalExpression: ['left', 'right'],
135
+ MatchArrayPattern: ['elements', 'rest'],
136
+ MatchAsPattern: ['pattern', 'target'],
137
+ MatchBindingPattern: ['id'],
138
+ MatchExpression: ['argument', 'cases'],
139
+ MatchExpressionCase: ['pattern', 'body', 'guard'],
140
+ MatchIdentifierPattern: ['id'],
141
+ MatchLiteralPattern: ['literal'],
142
+ MatchMemberPattern: ['base', 'property'],
143
+ MatchObjectPattern: ['properties', 'rest'],
144
+ MatchObjectPatternProperty: ['key', 'pattern'],
145
+ MatchOrPattern: ['patterns'],
146
+ MatchRestPattern: ['argument'],
147
+ MatchStatement: ['argument', 'cases'],
148
+ MatchStatementCase: ['pattern', 'body', 'guard'],
149
+ MatchUnaryPattern: ['argument'],
150
+ MatchWildcardPattern: [],
151
+ MemberExpression: ['object', 'property'],
152
+ MetaProperty: ['meta', 'property'],
153
+ MethodDefinition: ['key', 'value'],
154
+ MixedTypeAnnotation: [],
155
+ NewExpression: ['callee', 'typeArguments', 'arguments'],
156
+ NullableTypeAnnotation: ['typeAnnotation'],
157
+ NullLiteralTypeAnnotation: [],
158
+ NumberLiteralTypeAnnotation: [],
159
+ NumberTypeAnnotation: [],
160
+ ObjectExpression: ['properties'],
161
+ ObjectPattern: ['properties', 'typeAnnotation'],
162
+ ObjectTypeAnnotation: ['properties', 'indexers', 'callProperties', 'internalSlots'],
163
+ ObjectTypeCallProperty: ['value'],
164
+ ObjectTypeIndexer: ['id', 'key', 'value', 'variance'],
165
+ ObjectTypeInternalSlot: ['id', 'value'],
166
+ ObjectTypeMappedTypeProperty: ['keyTparam', 'propType', 'sourceType', 'variance'],
167
+ ObjectTypeProperty: ['key', 'value', 'variance'],
168
+ ObjectTypeSpreadProperty: ['argument'],
169
+ OpaqueType: ['id', 'typeParameters', 'impltype', 'supertype'],
170
+ OptionalIndexedAccessType: ['objectType', 'indexType'],
171
+ PrivateIdentifier: [],
172
+ Program: ['body'],
173
+ Property: ['key', 'value'],
174
+ PropertyDefinition: ['key', 'value', 'variance', 'typeAnnotation'],
175
+ QualifiedTypeIdentifier: ['qualification', 'id'],
176
+ QualifiedTypeofIdentifier: ['qualification', 'id'],
177
+ RestElement: ['argument'],
178
+ ReturnStatement: ['argument'],
179
+ SequenceExpression: ['expressions'],
180
+ SpreadElement: ['argument'],
181
+ StaticBlock: ['body'],
182
+ StringLiteralTypeAnnotation: [],
183
+ StringTypeAnnotation: [],
184
+ Super: [],
185
+ SwitchCase: ['test', 'consequent'],
186
+ SwitchStatement: ['discriminant', 'cases'],
187
+ SymbolTypeAnnotation: [],
188
+ TaggedTemplateExpression: ['tag', 'quasi'],
189
+ TemplateElement: [],
190
+ TemplateLiteral: ['quasis', 'expressions'],
191
+ ThisExpression: [],
192
+ ThisTypeAnnotation: [],
193
+ ThrowStatement: ['argument'],
194
+ TryStatement: ['block', 'handler', 'finalizer'],
195
+ TupleTypeAnnotation: ['types'],
196
+ TupleTypeLabeledElement: ['label', 'elementType', 'variance'],
197
+ TupleTypeSpreadElement: ['label', 'typeAnnotation'],
198
+ TypeAlias: ['id', 'typeParameters', 'right'],
199
+ TypeAnnotation: ['typeAnnotation'],
200
+ TypeCastExpression: ['expression', 'typeAnnotation'],
201
+ TypeofTypeAnnotation: ['argument', 'typeArguments'],
202
+ TypeOperator: ['typeAnnotation'],
203
+ TypeParameter: ['bound', 'variance', 'default'],
204
+ TypeParameterDeclaration: ['params'],
205
+ TypeParameterInstantiation: ['params'],
206
+ TypePredicate: ['parameterName', 'typeAnnotation'],
207
+ UnaryExpression: ['argument'],
208
+ UnionTypeAnnotation: ['types'],
209
+ UpdateExpression: ['argument'],
210
+ VariableDeclaration: ['declarations'],
211
+ VariableDeclarator: ['id', 'init'],
212
+ Variance: [],
213
+ VoidTypeAnnotation: [],
214
+ WhileStatement: ['test', 'body'],
215
+ WithStatement: ['object', 'body'],
216
+ YieldExpression: ['argument'],
217
+ OptionalMemberExpression: ['object', 'property'],
218
+ OptionalCallExpression: ['callee', 'typeArguments', 'arguments'],
219
+ Literal: []
220
+ };