@react-native/codegen 0.72.1 → 0.72.2
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/lib/CodegenSchema.d.ts +348 -0
- package/lib/CodegenSchema.js.flow +31 -3
- package/lib/SchemaValidator.d.ts +11 -0
- package/lib/cli/combine/combine-js-to-schema.js +8 -8
- package/lib/cli/combine/combine-js-to-schema.js.flow +8 -7
- package/lib/cli/parser/parser.js +8 -15
- package/lib/cli/parser/parser.js.flow +8 -14
- package/lib/generators/Utils.js +16 -0
- package/lib/generators/Utils.js.flow +20 -0
- package/lib/generators/__test_fixtures__/fixtures.js +2 -1
- package/lib/generators/__test_fixtures__/fixtures.js.flow +2 -1
- package/lib/generators/components/ComponentsGeneratorUtils.js +10 -1
- package/lib/generators/components/ComponentsGeneratorUtils.js.flow +12 -2
- package/lib/generators/components/CppHelpers.js +8 -15
- package/lib/generators/components/CppHelpers.js.flow +8 -19
- package/lib/generators/components/GenerateEventEmitterCpp.js +7 -3
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +7 -3
- package/lib/generators/components/GenerateEventEmitterH.js +2 -2
- package/lib/generators/components/GenerateEventEmitterH.js.flow +1 -2
- package/lib/generators/components/GeneratePropsH.js +3 -4
- package/lib/generators/components/GeneratePropsH.js.flow +2 -4
- package/lib/generators/components/GeneratePropsJavaDelegate.js +2 -0
- package/lib/generators/components/GeneratePropsJavaDelegate.js.flow +2 -0
- package/lib/generators/components/GeneratePropsJavaInterface.js +3 -0
- package/lib/generators/components/GeneratePropsJavaInterface.js.flow +3 -0
- package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js +8 -0
- package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js.flow +12 -0
- package/lib/generators/components/GenerateTests.js +3 -2
- package/lib/generators/components/GenerateTests.js.flow +3 -1
- package/lib/generators/components/GenerateViewConfigJs.js +5 -2
- package/lib/generators/components/GenerateViewConfigJs.js.flow +5 -2
- package/lib/generators/components/JavaHelpers.js +9 -0
- package/lib/generators/components/JavaHelpers.js.flow +12 -1
- package/lib/generators/components/__test_fixtures__/fixtures.js +41 -0
- package/lib/generators/components/__test_fixtures__/fixtures.js.flow +42 -0
- package/lib/generators/modules/GenerateModuleCpp.js +9 -4
- package/lib/generators/modules/GenerateModuleCpp.js.flow +11 -3
- package/lib/generators/modules/GenerateModuleH.js +185 -33
- package/lib/generators/modules/GenerateModuleH.js.flow +203 -25
- package/lib/generators/modules/GenerateModuleJavaSpec.js +2 -2
- package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +5 -5
- package/lib/generators/modules/GenerateModuleJniCpp.js +2 -2
- package/lib/generators/modules/GenerateModuleJniCpp.js.flow +5 -5
- package/lib/generators/modules/GenerateModuleObjCpp/index.js +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/index.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow +2 -2
- package/lib/generators/modules/Utils.js +4 -0
- package/lib/generators/modules/Utils.js.flow +6 -0
- package/lib/generators/modules/__test_fixtures__/fixtures.js +152 -10
- package/lib/generators/modules/__test_fixtures__/fixtures.js.flow +152 -10
- package/lib/parsers/error-utils.js +1 -19
- package/lib/parsers/error-utils.js.flow +1 -19
- package/lib/parsers/errors.d.ts +10 -0
- package/lib/parsers/errors.js +9 -29
- package/lib/parsers/errors.js.flow +2 -20
- package/lib/parsers/flow/Visitor.js +37 -0
- package/lib/parsers/flow/Visitor.js.flow +41 -0
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js +20 -2
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow +20 -2
- package/lib/parsers/flow/components/commands.js +3 -0
- package/lib/parsers/flow/components/commands.js.flow +2 -1
- package/lib/parsers/flow/components/componentsUtils.js +10 -0
- package/lib/parsers/flow/components/componentsUtils.js.flow +11 -1
- package/lib/parsers/flow/components/events.js.flow +1 -1
- package/lib/parsers/flow/components/extends.js.flow +1 -1
- package/lib/parsers/flow/components/index.js.flow +1 -1
- package/lib/parsers/flow/components/options.js.flow +1 -1
- package/lib/parsers/flow/components/props.js.flow +1 -1
- package/lib/parsers/flow/modules/__test_fixtures__/failures.js +54 -0
- package/lib/parsers/flow/modules/__test_fixtures__/failures.js.flow +56 -0
- package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js +64 -1
- package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js.flow +66 -1
- package/lib/parsers/flow/modules/index.js +99 -25
- package/lib/parsers/flow/modules/index.js.flow +106 -22
- package/lib/parsers/flow/parser.d.ts +10 -0
- package/lib/parsers/flow/parser.js +122 -32
- package/lib/parsers/flow/parser.js.flow +144 -24
- package/lib/parsers/flow/utils.js +33 -19
- package/lib/parsers/flow/utils.js.flow +37 -22
- package/lib/parsers/parser.d.ts +17 -0
- package/lib/parsers/parser.js.flow +102 -17
- package/lib/parsers/parserMock.js +87 -30
- package/lib/parsers/parserMock.js.flow +118 -24
- package/lib/parsers/parsers-commons.js +121 -119
- package/lib/parsers/parsers-commons.js.flow +130 -131
- package/lib/parsers/parsers-primitives.js +75 -12
- package/lib/parsers/parsers-primitives.js.flow +92 -13
- package/lib/parsers/schema/index.d.ts +10 -0
- package/lib/parsers/typescript/Visitor.js +42 -0
- package/lib/parsers/typescript/Visitor.js.flow +47 -0
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js +22 -0
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow +22 -0
- package/lib/parsers/typescript/components/commands.js +3 -0
- package/lib/parsers/typescript/components/commands.js.flow +2 -1
- package/lib/parsers/typescript/components/componentsUtils.js +5 -0
- package/lib/parsers/typescript/components/componentsUtils.js.flow +6 -1
- package/lib/parsers/typescript/components/events.js.flow +1 -1
- package/lib/parsers/typescript/components/extends.js.flow +1 -1
- package/lib/parsers/typescript/components/index.js.flow +1 -1
- package/lib/parsers/typescript/components/options.js.flow +1 -1
- package/lib/parsers/typescript/components/props.js.flow +1 -1
- package/lib/parsers/typescript/modules/__test_fixtures__/failures.js +52 -0
- package/lib/parsers/typescript/modules/__test_fixtures__/failures.js.flow +54 -0
- package/lib/parsers/typescript/modules/__test_fixtures__/fixtures.js +142 -0
- package/lib/parsers/typescript/modules/__test_fixtures__/fixtures.js.flow +146 -0
- package/lib/parsers/typescript/modules/index.js +266 -87
- package/lib/parsers/typescript/modules/index.js.flow +230 -48
- package/lib/parsers/typescript/parser.d.ts +10 -0
- package/lib/parsers/typescript/parser.js +131 -25
- package/lib/parsers/typescript/parser.js.flow +137 -26
- package/lib/parsers/typescript/utils.js +40 -20
- package/lib/parsers/typescript/utils.js.flow +44 -24
- package/lib/parsers/utils.js +0 -125
- package/lib/parsers/utils.js.flow +3 -70
- package/package.json +4 -1
- package/lib/parsers/flow/index.js +0 -80
- package/lib/parsers/flow/index.js.flow +0 -85
- package/lib/parsers/typescript/index.js +0 -85
- package/lib/parsers/typescript/index.js.flow +0 -94
|
@@ -67,14 +67,12 @@ function throwIfMoreThanOneModuleRegistryCalls(
|
|
|
67
67
|
hasteModuleName,
|
|
68
68
|
callExpressions,
|
|
69
69
|
callExpressionsLength,
|
|
70
|
-
language,
|
|
71
70
|
) {
|
|
72
71
|
if (callExpressions.length > 1) {
|
|
73
72
|
throw new MoreThanOneModuleRegistryCallsParserError(
|
|
74
73
|
hasteModuleName,
|
|
75
74
|
callExpressions,
|
|
76
75
|
callExpressionsLength,
|
|
77
|
-
language,
|
|
78
76
|
);
|
|
79
77
|
}
|
|
80
78
|
}
|
|
@@ -82,14 +80,9 @@ function throwIfUnusedModuleInterfaceParserError(
|
|
|
82
80
|
nativeModuleName,
|
|
83
81
|
moduleSpec,
|
|
84
82
|
callExpressions,
|
|
85
|
-
language,
|
|
86
83
|
) {
|
|
87
84
|
if (callExpressions.length === 0) {
|
|
88
|
-
throw new UnusedModuleInterfaceParserError(
|
|
89
|
-
nativeModuleName,
|
|
90
|
-
moduleSpec,
|
|
91
|
-
language,
|
|
92
|
-
);
|
|
85
|
+
throw new UnusedModuleInterfaceParserError(nativeModuleName, moduleSpec);
|
|
93
86
|
}
|
|
94
87
|
}
|
|
95
88
|
function throwIfWrongNumberOfCallExpressionArgs(
|
|
@@ -97,7 +90,6 @@ function throwIfWrongNumberOfCallExpressionArgs(
|
|
|
97
90
|
flowCallExpression,
|
|
98
91
|
methodName,
|
|
99
92
|
numberOfCallExpressionArgs,
|
|
100
|
-
language,
|
|
101
93
|
) {
|
|
102
94
|
if (numberOfCallExpressionArgs !== 1) {
|
|
103
95
|
throw new IncorrectModuleRegistryCallArityParserError(
|
|
@@ -105,7 +97,6 @@ function throwIfWrongNumberOfCallExpressionArgs(
|
|
|
105
97
|
flowCallExpression,
|
|
106
98
|
methodName,
|
|
107
99
|
numberOfCallExpressionArgs,
|
|
108
|
-
language,
|
|
109
100
|
);
|
|
110
101
|
}
|
|
111
102
|
}
|
|
@@ -122,7 +113,6 @@ function throwIfIncorrectModuleRegistryCallTypeParameterParserError(
|
|
|
122
113
|
typeArguments,
|
|
123
114
|
methodName,
|
|
124
115
|
moduleName,
|
|
125
|
-
parser.language(),
|
|
126
116
|
);
|
|
127
117
|
}
|
|
128
118
|
if (parser.checkIfInvalidModule(typeArguments)) {
|
|
@@ -133,7 +123,6 @@ function throwIfUnsupportedFunctionReturnTypeAnnotationParserError(
|
|
|
133
123
|
nativeModuleName,
|
|
134
124
|
returnTypeAnnotation,
|
|
135
125
|
invalidReturnType,
|
|
136
|
-
language,
|
|
137
126
|
cxxOnly,
|
|
138
127
|
returnType,
|
|
139
128
|
) {
|
|
@@ -142,7 +131,6 @@ function throwIfUnsupportedFunctionReturnTypeAnnotationParserError(
|
|
|
142
131
|
nativeModuleName,
|
|
143
132
|
returnTypeAnnotation.returnType,
|
|
144
133
|
'FunctionTypeAnnotation',
|
|
145
|
-
language,
|
|
146
134
|
);
|
|
147
135
|
}
|
|
148
136
|
}
|
|
@@ -152,7 +140,6 @@ function throwIfUntypedModule(
|
|
|
152
140
|
callExpression,
|
|
153
141
|
methodName,
|
|
154
142
|
moduleName,
|
|
155
|
-
language,
|
|
156
143
|
) {
|
|
157
144
|
if (typeArguments == null) {
|
|
158
145
|
throw new UntypedModuleRegistryCallParserError(
|
|
@@ -160,7 +147,6 @@ function throwIfUntypedModule(
|
|
|
160
147
|
callExpression,
|
|
161
148
|
methodName,
|
|
162
149
|
moduleName,
|
|
163
|
-
language,
|
|
164
150
|
);
|
|
165
151
|
}
|
|
166
152
|
}
|
|
@@ -203,7 +189,6 @@ function throwIfPropertyValueTypeIsUnsupported(
|
|
|
203
189
|
propertyValue,
|
|
204
190
|
propertyKey,
|
|
205
191
|
type,
|
|
206
|
-
language,
|
|
207
192
|
) {
|
|
208
193
|
const invalidPropertyValueType =
|
|
209
194
|
UnsupportedObjectPropertyTypeToInvalidPropertyValueTypeMap[type];
|
|
@@ -212,7 +197,6 @@ function throwIfPropertyValueTypeIsUnsupported(
|
|
|
212
197
|
propertyValue,
|
|
213
198
|
propertyKey,
|
|
214
199
|
invalidPropertyValueType,
|
|
215
|
-
language,
|
|
216
200
|
);
|
|
217
201
|
}
|
|
218
202
|
function throwIfMoreThanOneModuleInterfaceParserError(
|
|
@@ -247,7 +231,6 @@ function throwIfArrayElementTypeAnnotationIsUnsupported(
|
|
|
247
231
|
flowElementType,
|
|
248
232
|
flowArrayType,
|
|
249
233
|
type,
|
|
250
|
-
language,
|
|
251
234
|
) {
|
|
252
235
|
const TypeMap = {
|
|
253
236
|
FunctionTypeAnnotation: 'FunctionTypeAnnotation',
|
|
@@ -263,7 +246,6 @@ function throwIfArrayElementTypeAnnotationIsUnsupported(
|
|
|
263
246
|
flowElementType,
|
|
264
247
|
flowArrayType,
|
|
265
248
|
TypeMap[type],
|
|
266
|
-
language,
|
|
267
249
|
);
|
|
268
250
|
}
|
|
269
251
|
}
|
|
@@ -63,14 +63,12 @@ function throwIfMoreThanOneModuleRegistryCalls(
|
|
|
63
63
|
hasteModuleName: string,
|
|
64
64
|
callExpressions: $FlowFixMe,
|
|
65
65
|
callExpressionsLength: number,
|
|
66
|
-
language: ParserType,
|
|
67
66
|
) {
|
|
68
67
|
if (callExpressions.length > 1) {
|
|
69
68
|
throw new MoreThanOneModuleRegistryCallsParserError(
|
|
70
69
|
hasteModuleName,
|
|
71
70
|
callExpressions,
|
|
72
71
|
callExpressionsLength,
|
|
73
|
-
language,
|
|
74
72
|
);
|
|
75
73
|
}
|
|
76
74
|
}
|
|
@@ -79,14 +77,9 @@ function throwIfUnusedModuleInterfaceParserError(
|
|
|
79
77
|
nativeModuleName: string,
|
|
80
78
|
moduleSpec: $FlowFixMe,
|
|
81
79
|
callExpressions: $FlowFixMe,
|
|
82
|
-
language: ParserType,
|
|
83
80
|
) {
|
|
84
81
|
if (callExpressions.length === 0) {
|
|
85
|
-
throw new UnusedModuleInterfaceParserError(
|
|
86
|
-
nativeModuleName,
|
|
87
|
-
moduleSpec,
|
|
88
|
-
language,
|
|
89
|
-
);
|
|
82
|
+
throw new UnusedModuleInterfaceParserError(nativeModuleName, moduleSpec);
|
|
90
83
|
}
|
|
91
84
|
}
|
|
92
85
|
|
|
@@ -95,7 +88,6 @@ function throwIfWrongNumberOfCallExpressionArgs(
|
|
|
95
88
|
flowCallExpression: $FlowFixMe,
|
|
96
89
|
methodName: string,
|
|
97
90
|
numberOfCallExpressionArgs: number,
|
|
98
|
-
language: ParserType,
|
|
99
91
|
) {
|
|
100
92
|
if (numberOfCallExpressionArgs !== 1) {
|
|
101
93
|
throw new IncorrectModuleRegistryCallArityParserError(
|
|
@@ -103,7 +95,6 @@ function throwIfWrongNumberOfCallExpressionArgs(
|
|
|
103
95
|
flowCallExpression,
|
|
104
96
|
methodName,
|
|
105
97
|
numberOfCallExpressionArgs,
|
|
106
|
-
language,
|
|
107
98
|
);
|
|
108
99
|
}
|
|
109
100
|
}
|
|
@@ -121,7 +112,6 @@ function throwIfIncorrectModuleRegistryCallTypeParameterParserError(
|
|
|
121
112
|
typeArguments,
|
|
122
113
|
methodName,
|
|
123
114
|
moduleName,
|
|
124
|
-
parser.language(),
|
|
125
115
|
);
|
|
126
116
|
}
|
|
127
117
|
|
|
@@ -134,7 +124,6 @@ function throwIfUnsupportedFunctionReturnTypeAnnotationParserError(
|
|
|
134
124
|
nativeModuleName: string,
|
|
135
125
|
returnTypeAnnotation: $FlowFixMe,
|
|
136
126
|
invalidReturnType: string,
|
|
137
|
-
language: ParserType,
|
|
138
127
|
cxxOnly: boolean,
|
|
139
128
|
returnType: string,
|
|
140
129
|
) {
|
|
@@ -143,7 +132,6 @@ function throwIfUnsupportedFunctionReturnTypeAnnotationParserError(
|
|
|
143
132
|
nativeModuleName,
|
|
144
133
|
returnTypeAnnotation.returnType,
|
|
145
134
|
'FunctionTypeAnnotation',
|
|
146
|
-
language,
|
|
147
135
|
);
|
|
148
136
|
}
|
|
149
137
|
}
|
|
@@ -154,7 +142,6 @@ function throwIfUntypedModule(
|
|
|
154
142
|
callExpression: $FlowFixMe,
|
|
155
143
|
methodName: string,
|
|
156
144
|
moduleName: string,
|
|
157
|
-
language: ParserType,
|
|
158
145
|
) {
|
|
159
146
|
if (typeArguments == null) {
|
|
160
147
|
throw new UntypedModuleRegistryCallParserError(
|
|
@@ -162,7 +149,6 @@ function throwIfUntypedModule(
|
|
|
162
149
|
callExpression,
|
|
163
150
|
methodName,
|
|
164
151
|
moduleName,
|
|
165
|
-
language,
|
|
166
152
|
);
|
|
167
153
|
}
|
|
168
154
|
}
|
|
@@ -208,7 +194,6 @@ function throwIfPropertyValueTypeIsUnsupported(
|
|
|
208
194
|
propertyValue: $FlowFixMe,
|
|
209
195
|
propertyKey: string,
|
|
210
196
|
type: string,
|
|
211
|
-
language: ParserType,
|
|
212
197
|
) {
|
|
213
198
|
const invalidPropertyValueType =
|
|
214
199
|
UnsupportedObjectPropertyTypeToInvalidPropertyValueTypeMap[type];
|
|
@@ -218,7 +203,6 @@ function throwIfPropertyValueTypeIsUnsupported(
|
|
|
218
203
|
propertyValue,
|
|
219
204
|
propertyKey,
|
|
220
205
|
invalidPropertyValueType,
|
|
221
|
-
language,
|
|
222
206
|
);
|
|
223
207
|
}
|
|
224
208
|
|
|
@@ -256,7 +240,6 @@ function throwIfArrayElementTypeAnnotationIsUnsupported(
|
|
|
256
240
|
flowElementType: $FlowFixMe,
|
|
257
241
|
flowArrayType: 'Array' | '$ReadOnlyArray' | 'ReadonlyArray',
|
|
258
242
|
type: string,
|
|
259
|
-
language: ParserType,
|
|
260
243
|
) {
|
|
261
244
|
const TypeMap = {
|
|
262
245
|
FunctionTypeAnnotation: 'FunctionTypeAnnotation',
|
|
@@ -273,7 +256,6 @@ function throwIfArrayElementTypeAnnotationIsUnsupported(
|
|
|
273
256
|
flowElementType,
|
|
274
257
|
flowArrayType,
|
|
275
258
|
TypeMap[type],
|
|
276
|
-
language,
|
|
277
259
|
);
|
|
278
260
|
}
|
|
279
261
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export type ParserType = 'Flow' | 'TypeScript';
|
|
9
|
+
|
|
10
|
+
export declare class ParserError extends Error {}
|
package/lib/parsers/errors.js
CHANGED
|
@@ -132,7 +132,6 @@ class UnsupportedArrayElementTypeAnnotationParserError extends ParserError {
|
|
|
132
132
|
arrayElementTypeAST,
|
|
133
133
|
arrayType,
|
|
134
134
|
invalidArrayElementType,
|
|
135
|
-
language,
|
|
136
135
|
) {
|
|
137
136
|
super(
|
|
138
137
|
nativeModuleName,
|
|
@@ -164,7 +163,6 @@ class UnsupportedObjectPropertyValueTypeAnnotationParserError extends ParserErro
|
|
|
164
163
|
propertyValueAST,
|
|
165
164
|
propertyName,
|
|
166
165
|
invalidPropertyValueType,
|
|
167
|
-
language,
|
|
168
166
|
) {
|
|
169
167
|
super(
|
|
170
168
|
nativeModuleName,
|
|
@@ -179,7 +177,7 @@ class UnsupportedObjectPropertyValueTypeAnnotationParserError extends ParserErro
|
|
|
179
177
|
*/
|
|
180
178
|
|
|
181
179
|
class UnnamedFunctionParamParserError extends ParserError {
|
|
182
|
-
constructor(functionParam, nativeModuleName
|
|
180
|
+
constructor(functionParam, nativeModuleName) {
|
|
183
181
|
super(
|
|
184
182
|
nativeModuleName,
|
|
185
183
|
functionParam,
|
|
@@ -202,12 +200,7 @@ class UnsupportedFunctionParamTypeAnnotationParserError extends ParserError {
|
|
|
202
200
|
}
|
|
203
201
|
}
|
|
204
202
|
class UnsupportedFunctionReturnTypeAnnotationParserError extends ParserError {
|
|
205
|
-
constructor(
|
|
206
|
-
nativeModuleName,
|
|
207
|
-
flowReturnTypeAnnotation,
|
|
208
|
-
invalidReturnType,
|
|
209
|
-
language,
|
|
210
|
-
) {
|
|
203
|
+
constructor(nativeModuleName, flowReturnTypeAnnotation, invalidReturnType) {
|
|
211
204
|
super(
|
|
212
205
|
nativeModuleName,
|
|
213
206
|
flowReturnTypeAnnotation,
|
|
@@ -221,7 +214,7 @@ class UnsupportedFunctionReturnTypeAnnotationParserError extends ParserError {
|
|
|
221
214
|
*/
|
|
222
215
|
|
|
223
216
|
class UnsupportedEnumDeclarationParserError extends ParserError {
|
|
224
|
-
constructor(nativeModuleName, arrayElementTypeAST, memberType
|
|
217
|
+
constructor(nativeModuleName, arrayElementTypeAST, memberType) {
|
|
225
218
|
super(
|
|
226
219
|
nativeModuleName,
|
|
227
220
|
arrayElementTypeAST,
|
|
@@ -235,7 +228,7 @@ class UnsupportedEnumDeclarationParserError extends ParserError {
|
|
|
235
228
|
*/
|
|
236
229
|
|
|
237
230
|
class UnsupportedUnionTypeAnnotationParserError extends ParserError {
|
|
238
|
-
constructor(nativeModuleName, arrayElementTypeAST, types
|
|
231
|
+
constructor(nativeModuleName, arrayElementTypeAST, types) {
|
|
239
232
|
super(
|
|
240
233
|
nativeModuleName,
|
|
241
234
|
arrayElementTypeAST,
|
|
@@ -251,7 +244,7 @@ class UnsupportedUnionTypeAnnotationParserError extends ParserError {
|
|
|
251
244
|
*/
|
|
252
245
|
|
|
253
246
|
class UnusedModuleInterfaceParserError extends ParserError {
|
|
254
|
-
constructor(nativeModuleName, flowInterface
|
|
247
|
+
constructor(nativeModuleName, flowInterface) {
|
|
255
248
|
super(
|
|
256
249
|
nativeModuleName,
|
|
257
250
|
flowInterface,
|
|
@@ -260,7 +253,7 @@ class UnusedModuleInterfaceParserError extends ParserError {
|
|
|
260
253
|
}
|
|
261
254
|
}
|
|
262
255
|
class MoreThanOneModuleRegistryCallsParserError extends ParserError {
|
|
263
|
-
constructor(nativeModuleName, flowCallExpressions, numCalls
|
|
256
|
+
constructor(nativeModuleName, flowCallExpressions, numCalls) {
|
|
264
257
|
super(
|
|
265
258
|
nativeModuleName,
|
|
266
259
|
flowCallExpressions,
|
|
@@ -269,13 +262,7 @@ class MoreThanOneModuleRegistryCallsParserError extends ParserError {
|
|
|
269
262
|
}
|
|
270
263
|
}
|
|
271
264
|
class UntypedModuleRegistryCallParserError extends ParserError {
|
|
272
|
-
constructor(
|
|
273
|
-
nativeModuleName,
|
|
274
|
-
flowCallExpression,
|
|
275
|
-
methodName,
|
|
276
|
-
moduleName,
|
|
277
|
-
language,
|
|
278
|
-
) {
|
|
265
|
+
constructor(nativeModuleName, flowCallExpression, methodName, moduleName) {
|
|
279
266
|
super(
|
|
280
267
|
nativeModuleName,
|
|
281
268
|
flowCallExpression,
|
|
@@ -284,13 +271,7 @@ class UntypedModuleRegistryCallParserError extends ParserError {
|
|
|
284
271
|
}
|
|
285
272
|
}
|
|
286
273
|
class IncorrectModuleRegistryCallTypeParameterParserError extends ParserError {
|
|
287
|
-
constructor(
|
|
288
|
-
nativeModuleName,
|
|
289
|
-
flowTypeArguments,
|
|
290
|
-
methodName,
|
|
291
|
-
moduleName,
|
|
292
|
-
language,
|
|
293
|
-
) {
|
|
274
|
+
constructor(nativeModuleName, flowTypeArguments, methodName, moduleName) {
|
|
294
275
|
super(
|
|
295
276
|
nativeModuleName,
|
|
296
277
|
flowTypeArguments,
|
|
@@ -304,7 +285,6 @@ class IncorrectModuleRegistryCallArityParserError extends ParserError {
|
|
|
304
285
|
flowCallExpression,
|
|
305
286
|
methodName,
|
|
306
287
|
incorrectArity,
|
|
307
|
-
language,
|
|
308
288
|
) {
|
|
309
289
|
super(
|
|
310
290
|
nativeModuleName,
|
|
@@ -314,7 +294,7 @@ class IncorrectModuleRegistryCallArityParserError extends ParserError {
|
|
|
314
294
|
}
|
|
315
295
|
}
|
|
316
296
|
class IncorrectModuleRegistryCallArgumentTypeParserError extends ParserError {
|
|
317
|
-
constructor(nativeModuleName, flowArgument, methodName, type
|
|
297
|
+
constructor(nativeModuleName, flowArgument, methodName, type) {
|
|
318
298
|
const a = /[aeiouy]/.test(type.toLowerCase()) ? 'an' : 'a';
|
|
319
299
|
super(
|
|
320
300
|
nativeModuleName,
|
|
@@ -176,7 +176,6 @@ class UnsupportedArrayElementTypeAnnotationParserError extends ParserError {
|
|
|
176
176
|
arrayElementTypeAST: $FlowFixMe,
|
|
177
177
|
arrayType: 'Array' | '$ReadOnlyArray' | 'ReadonlyArray',
|
|
178
178
|
invalidArrayElementType: string,
|
|
179
|
-
language: ParserType,
|
|
180
179
|
) {
|
|
181
180
|
super(
|
|
182
181
|
nativeModuleName,
|
|
@@ -216,7 +215,6 @@ class UnsupportedObjectPropertyValueTypeAnnotationParserError extends ParserErro
|
|
|
216
215
|
propertyValueAST: $FlowFixMe,
|
|
217
216
|
propertyName: string,
|
|
218
217
|
invalidPropertyValueType: string,
|
|
219
|
-
language: ParserType,
|
|
220
218
|
) {
|
|
221
219
|
super(
|
|
222
220
|
nativeModuleName,
|
|
@@ -231,11 +229,7 @@ class UnsupportedObjectPropertyValueTypeAnnotationParserError extends ParserErro
|
|
|
231
229
|
*/
|
|
232
230
|
|
|
233
231
|
class UnnamedFunctionParamParserError extends ParserError {
|
|
234
|
-
constructor(
|
|
235
|
-
functionParam: $FlowFixMe,
|
|
236
|
-
nativeModuleName: string,
|
|
237
|
-
language: ParserType,
|
|
238
|
-
) {
|
|
232
|
+
constructor(functionParam: $FlowFixMe, nativeModuleName: string) {
|
|
239
233
|
super(
|
|
240
234
|
nativeModuleName,
|
|
241
235
|
functionParam,
|
|
@@ -264,7 +258,6 @@ class UnsupportedFunctionReturnTypeAnnotationParserError extends ParserError {
|
|
|
264
258
|
nativeModuleName: string,
|
|
265
259
|
flowReturnTypeAnnotation: $FlowFixMe,
|
|
266
260
|
invalidReturnType: string,
|
|
267
|
-
language: ParserType,
|
|
268
261
|
) {
|
|
269
262
|
super(
|
|
270
263
|
nativeModuleName,
|
|
@@ -283,7 +276,6 @@ class UnsupportedEnumDeclarationParserError extends ParserError {
|
|
|
283
276
|
nativeModuleName: string,
|
|
284
277
|
arrayElementTypeAST: $FlowFixMe,
|
|
285
278
|
memberType: string,
|
|
286
|
-
language: ParserType,
|
|
287
279
|
) {
|
|
288
280
|
super(
|
|
289
281
|
nativeModuleName,
|
|
@@ -302,7 +294,6 @@ class UnsupportedUnionTypeAnnotationParserError extends ParserError {
|
|
|
302
294
|
nativeModuleName: string,
|
|
303
295
|
arrayElementTypeAST: $FlowFixMe,
|
|
304
296
|
types: UnionTypeAnnotationMemberType[],
|
|
305
|
-
language: ParserType,
|
|
306
297
|
) {
|
|
307
298
|
super(
|
|
308
299
|
nativeModuleName,
|
|
@@ -319,11 +310,7 @@ class UnsupportedUnionTypeAnnotationParserError extends ParserError {
|
|
|
319
310
|
*/
|
|
320
311
|
|
|
321
312
|
class UnusedModuleInterfaceParserError extends ParserError {
|
|
322
|
-
constructor(
|
|
323
|
-
nativeModuleName: string,
|
|
324
|
-
flowInterface: $FlowFixMe,
|
|
325
|
-
language: ParserType,
|
|
326
|
-
) {
|
|
313
|
+
constructor(nativeModuleName: string, flowInterface: $FlowFixMe) {
|
|
327
314
|
super(
|
|
328
315
|
nativeModuleName,
|
|
329
316
|
flowInterface,
|
|
@@ -337,7 +324,6 @@ class MoreThanOneModuleRegistryCallsParserError extends ParserError {
|
|
|
337
324
|
nativeModuleName: string,
|
|
338
325
|
flowCallExpressions: $FlowFixMe,
|
|
339
326
|
numCalls: number,
|
|
340
|
-
language: ParserType,
|
|
341
327
|
) {
|
|
342
328
|
super(
|
|
343
329
|
nativeModuleName,
|
|
@@ -353,7 +339,6 @@ class UntypedModuleRegistryCallParserError extends ParserError {
|
|
|
353
339
|
flowCallExpression: $FlowFixMe,
|
|
354
340
|
methodName: string,
|
|
355
341
|
moduleName: string,
|
|
356
|
-
language: ParserType,
|
|
357
342
|
) {
|
|
358
343
|
super(
|
|
359
344
|
nativeModuleName,
|
|
@@ -369,7 +354,6 @@ class IncorrectModuleRegistryCallTypeParameterParserError extends ParserError {
|
|
|
369
354
|
flowTypeArguments: $FlowFixMe,
|
|
370
355
|
methodName: string,
|
|
371
356
|
moduleName: string,
|
|
372
|
-
language: ParserType,
|
|
373
357
|
) {
|
|
374
358
|
super(
|
|
375
359
|
nativeModuleName,
|
|
@@ -385,7 +369,6 @@ class IncorrectModuleRegistryCallArityParserError extends ParserError {
|
|
|
385
369
|
flowCallExpression: $FlowFixMe,
|
|
386
370
|
methodName: string,
|
|
387
371
|
incorrectArity: number,
|
|
388
|
-
language: ParserType,
|
|
389
372
|
) {
|
|
390
373
|
super(
|
|
391
374
|
nativeModuleName,
|
|
@@ -401,7 +384,6 @@ class IncorrectModuleRegistryCallArgumentTypeParserError extends ParserError {
|
|
|
401
384
|
flowArgument: $FlowFixMe,
|
|
402
385
|
methodName: string,
|
|
403
386
|
type: string,
|
|
404
|
-
language: ParserType,
|
|
405
387
|
) {
|
|
406
388
|
const a = /[aeiouy]/.test(type.toLowerCase()) ? 'an' : 'a';
|
|
407
389
|
super(
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const _require = require('../utils'),
|
|
14
|
+
isModuleRegistryCall = _require.isModuleRegistryCall;
|
|
15
|
+
function Visitor(infoMap) {
|
|
16
|
+
return {
|
|
17
|
+
CallExpression(node) {
|
|
18
|
+
if (
|
|
19
|
+
node.callee.type === 'Identifier' &&
|
|
20
|
+
node.callee.name === 'codegenNativeComponent'
|
|
21
|
+
) {
|
|
22
|
+
infoMap.isComponent = true;
|
|
23
|
+
}
|
|
24
|
+
if (isModuleRegistryCall(node)) {
|
|
25
|
+
infoMap.isModule = true;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
InterfaceExtends(node) {
|
|
29
|
+
if (node.id.name === 'TurboModule') {
|
|
30
|
+
infoMap.isModule = true;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
module.exports = {
|
|
36
|
+
Visitor,
|
|
37
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const {isModuleRegistryCall} = require('../utils');
|
|
14
|
+
|
|
15
|
+
function Visitor(infoMap: {isComponent: boolean, isModule: boolean}): {
|
|
16
|
+
[type: string]: (node: $FlowFixMe) => void,
|
|
17
|
+
} {
|
|
18
|
+
return {
|
|
19
|
+
CallExpression(node: $FlowFixMe) {
|
|
20
|
+
if (
|
|
21
|
+
node.callee.type === 'Identifier' &&
|
|
22
|
+
node.callee.name === 'codegenNativeComponent'
|
|
23
|
+
) {
|
|
24
|
+
infoMap.isComponent = true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (isModuleRegistryCall(node)) {
|
|
28
|
+
infoMap.isModule = true;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
InterfaceExtends(node: $FlowFixMe) {
|
|
32
|
+
if (node.id.name === 'TurboModule') {
|
|
33
|
+
infoMap.isModule = true;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
Visitor,
|
|
41
|
+
};
|
|
@@ -207,7 +207,7 @@ const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
207
207
|
|
|
208
208
|
import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
|
|
209
209
|
import type {ImageSource} from 'ImageSource';
|
|
210
|
-
import type {ColorValue, ColorArrayValue, PointValue, EdgeInsetsValue} from 'StyleSheetTypes';
|
|
210
|
+
import type {ColorValue, ColorArrayValue, PointValue, EdgeInsetsValue, DimensionValue} from 'StyleSheetTypes';
|
|
211
211
|
import type {ViewProps} from 'ViewPropTypes';
|
|
212
212
|
import type {HostComponent} from 'react-native';
|
|
213
213
|
|
|
@@ -307,6 +307,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
307
307
|
insets_optional_key?: EdgeInsetsValue,
|
|
308
308
|
insets_optional_value: ?EdgeInsetsValue,
|
|
309
309
|
insets_optional_both?: ?EdgeInsetsValue,
|
|
310
|
+
|
|
311
|
+
// DimensionValue props
|
|
312
|
+
dimension_required: DimensionValue,
|
|
313
|
+
dimension_optional_key?: DimensionValue,
|
|
314
|
+
dimension_optional_value: ?DimensionValue,
|
|
315
|
+
dimension_optional_both?: ?DimensionValue,
|
|
310
316
|
|}>;
|
|
311
317
|
|
|
312
318
|
export default (codegenNativeComponent<ModuleProps, Options>(
|
|
@@ -330,7 +336,7 @@ const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
330
336
|
|
|
331
337
|
import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
|
|
332
338
|
import type {ImageSource} from 'ImageSource';
|
|
333
|
-
import type {ColorValue, PointValue, ProcessColorValue, EdgeInsetsValue} from 'StyleSheetTypes';
|
|
339
|
+
import type {ColorValue, PointValue, ProcessColorValue, EdgeInsetsValue, DimensionValue} from 'StyleSheetTypes';
|
|
334
340
|
import type {ViewProps} from 'ViewPropTypes';
|
|
335
341
|
import type {HostComponent} from 'react-native';
|
|
336
342
|
|
|
@@ -405,6 +411,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
405
411
|
array_insets_optional_value: ?$ReadOnlyArray<EdgeInsetsValue>,
|
|
406
412
|
array_insets_optional_both?: ?$ReadOnlyArray<EdgeInsetsValue>,
|
|
407
413
|
|
|
414
|
+
// DimensionValue props
|
|
415
|
+
array_dimension_required: $ReadOnlyArray<DimensionValue>,
|
|
416
|
+
array_dimension_optional_key?: $ReadOnlyArray<DimensionValue>,
|
|
417
|
+
array_dimension_optional_value: ?$ReadOnlyArray<DimensionValue>,
|
|
418
|
+
array_dimension_optional_both?: ?$ReadOnlyArray<DimensionValue>,
|
|
419
|
+
|
|
408
420
|
// Object props
|
|
409
421
|
array_object_required: $ReadOnlyArray<$ReadOnly<{| prop: string |}>>,
|
|
410
422
|
array_object_optional_key?: $ReadOnlyArray<$ReadOnly<{| prop: string |}>>,
|
|
@@ -545,6 +557,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
545
557
|
insets_optional_value: $ReadOnly<{|prop: ?EdgeInsetsValue|}>,
|
|
546
558
|
insets_optional_both: $ReadOnly<{|prop?: ?EdgeInsetsValue|}>,
|
|
547
559
|
|
|
560
|
+
// DimensionValue props
|
|
561
|
+
dimension_required: $ReadOnly<{|prop: DimensionValue|}>,
|
|
562
|
+
dimension_optional_key: $ReadOnly<{|prop?: DimensionValue|}>,
|
|
563
|
+
dimension_optional_value: $ReadOnly<{|prop: ?DimensionValue|}>,
|
|
564
|
+
dimension_optional_both: $ReadOnly<{|prop?: ?DimensionValue|}>,
|
|
565
|
+
|
|
548
566
|
// Nested object props
|
|
549
567
|
object_required: $ReadOnly<{|prop: $ReadOnly<{nestedProp: string}>|}>,
|
|
550
568
|
object_optional_key?: $ReadOnly<{|prop: $ReadOnly<{nestedProp: string}>|}>,
|
|
@@ -211,7 +211,7 @@ const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
211
211
|
|
|
212
212
|
import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
|
|
213
213
|
import type {ImageSource} from 'ImageSource';
|
|
214
|
-
import type {ColorValue, ColorArrayValue, PointValue, EdgeInsetsValue} from 'StyleSheetTypes';
|
|
214
|
+
import type {ColorValue, ColorArrayValue, PointValue, EdgeInsetsValue, DimensionValue} from 'StyleSheetTypes';
|
|
215
215
|
import type {ViewProps} from 'ViewPropTypes';
|
|
216
216
|
import type {HostComponent} from 'react-native';
|
|
217
217
|
|
|
@@ -311,6 +311,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
311
311
|
insets_optional_key?: EdgeInsetsValue,
|
|
312
312
|
insets_optional_value: ?EdgeInsetsValue,
|
|
313
313
|
insets_optional_both?: ?EdgeInsetsValue,
|
|
314
|
+
|
|
315
|
+
// DimensionValue props
|
|
316
|
+
dimension_required: DimensionValue,
|
|
317
|
+
dimension_optional_key?: DimensionValue,
|
|
318
|
+
dimension_optional_value: ?DimensionValue,
|
|
319
|
+
dimension_optional_both?: ?DimensionValue,
|
|
314
320
|
|}>;
|
|
315
321
|
|
|
316
322
|
export default (codegenNativeComponent<ModuleProps, Options>(
|
|
@@ -335,7 +341,7 @@ const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
335
341
|
|
|
336
342
|
import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
|
|
337
343
|
import type {ImageSource} from 'ImageSource';
|
|
338
|
-
import type {ColorValue, PointValue, ProcessColorValue, EdgeInsetsValue} from 'StyleSheetTypes';
|
|
344
|
+
import type {ColorValue, PointValue, ProcessColorValue, EdgeInsetsValue, DimensionValue} from 'StyleSheetTypes';
|
|
339
345
|
import type {ViewProps} from 'ViewPropTypes';
|
|
340
346
|
import type {HostComponent} from 'react-native';
|
|
341
347
|
|
|
@@ -410,6 +416,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
410
416
|
array_insets_optional_value: ?$ReadOnlyArray<EdgeInsetsValue>,
|
|
411
417
|
array_insets_optional_both?: ?$ReadOnlyArray<EdgeInsetsValue>,
|
|
412
418
|
|
|
419
|
+
// DimensionValue props
|
|
420
|
+
array_dimension_required: $ReadOnlyArray<DimensionValue>,
|
|
421
|
+
array_dimension_optional_key?: $ReadOnlyArray<DimensionValue>,
|
|
422
|
+
array_dimension_optional_value: ?$ReadOnlyArray<DimensionValue>,
|
|
423
|
+
array_dimension_optional_both?: ?$ReadOnlyArray<DimensionValue>,
|
|
424
|
+
|
|
413
425
|
// Object props
|
|
414
426
|
array_object_required: $ReadOnlyArray<$ReadOnly<{| prop: string |}>>,
|
|
415
427
|
array_object_optional_key?: $ReadOnlyArray<$ReadOnly<{| prop: string |}>>,
|
|
@@ -551,6 +563,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
551
563
|
insets_optional_value: $ReadOnly<{|prop: ?EdgeInsetsValue|}>,
|
|
552
564
|
insets_optional_both: $ReadOnly<{|prop?: ?EdgeInsetsValue|}>,
|
|
553
565
|
|
|
566
|
+
// DimensionValue props
|
|
567
|
+
dimension_required: $ReadOnly<{|prop: DimensionValue|}>,
|
|
568
|
+
dimension_optional_key: $ReadOnly<{|prop?: DimensionValue|}>,
|
|
569
|
+
dimension_optional_value: $ReadOnly<{|prop: ?DimensionValue|}>,
|
|
570
|
+
dimension_optional_both: $ReadOnly<{|prop?: ?DimensionValue|}>,
|
|
571
|
+
|
|
554
572
|
// Nested object props
|
|
555
573
|
object_required: $ReadOnly<{|prop: $ReadOnly<{nestedProp: string}>|}>,
|
|
556
574
|
object_optional_key?: $ReadOnly<{|prop: $ReadOnly<{nestedProp: string}>|}>,
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
const _require = require('../utils.js'),
|
|
14
14
|
getValueFromTypes = _require.getValueFromTypes;
|
|
15
|
+
|
|
16
|
+
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
|
17
|
+
|
|
15
18
|
function buildCommandSchema(property, types) {
|
|
16
19
|
const name = property.key.name;
|
|
17
20
|
const optional = property.optional;
|
|
@@ -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
|
|
7
|
+
* @flow strict
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -18,6 +18,7 @@ import type {TypeDeclarationMap} from '../../utils';
|
|
|
18
18
|
|
|
19
19
|
const {getValueFromTypes} = require('../utils.js');
|
|
20
20
|
|
|
21
|
+
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
|
21
22
|
type EventTypeAST = Object;
|
|
22
23
|
|
|
23
24
|
function buildCommandSchema(property: EventTypeAST, types: TypeDeclarationMap) {
|