@react-native/codegen 0.85.0-nightly-20260113-b60f533ac → 0.85.0-nightly-20260115-caa1fb6a0
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.js.flow +16 -16
- package/lib/SchemaValidator.js.flow +1 -1
- package/lib/generators/Utils.js.flow +1 -1
- package/lib/generators/components/ComponentsGeneratorUtils.js.flow +3 -3
- package/lib/generators/components/CppHelpers.js.flow +4 -4
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +8 -8
- package/lib/generators/components/GenerateEventEmitterH.js.flow +5 -5
- package/lib/generators/components/GeneratePropsH.js.flow +9 -9
- package/lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js.flow +5 -5
- package/lib/generators/components/GenerateViewConfigJs.js.flow +1 -1
- package/lib/generators/modules/GenerateModuleH.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleJniCpp.js.flow +4 -4
- package/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js.flow +3 -3
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow +3 -3
- package/lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js.flow +7 -7
- package/lib/parsers/error-utils.js.flow +4 -4
- package/lib/parsers/errors.js.flow +3 -3
- package/lib/parsers/flow/components/commands.js.flow +3 -3
- package/lib/parsers/flow/components/componentsUtils.js.flow +2 -2
- package/lib/parsers/flow/components/events.js.flow +2 -2
- package/lib/parsers/flow/parser.js.flow +10 -10
- package/lib/parsers/parser.js.flow +6 -6
- package/lib/parsers/parserMock.js.flow +10 -10
- package/lib/parsers/parsers-commons.js.flow +7 -7
- package/lib/parsers/parsers-primitives.js.flow +2 -2
- package/lib/parsers/schema.js.flow +4 -4
- package/lib/parsers/typescript/components/commands.js.flow +2 -2
- package/lib/parsers/typescript/components/componentsUtils.js.flow +2 -2
- package/lib/parsers/typescript/components/events.js.flow +3 -3
- package/lib/parsers/typescript/components/extends.js.flow +1 -1
- package/lib/parsers/typescript/modules/index.js.flow +2 -2
- package/lib/parsers/typescript/parser.js.flow +6 -6
- package/package.json +4 -4
|
@@ -70,14 +70,14 @@ export type VoidTypeAnnotation = Readonly<{
|
|
|
70
70
|
|
|
71
71
|
export type ObjectTypeAnnotation<+T> = Readonly<{
|
|
72
72
|
type: 'ObjectTypeAnnotation',
|
|
73
|
-
properties:
|
|
73
|
+
properties: ReadonlyArray<NamedShape<T>>,
|
|
74
74
|
// metadata for objects that generated from interfaces
|
|
75
|
-
baseTypes?:
|
|
75
|
+
baseTypes?: ReadonlyArray<string>,
|
|
76
76
|
}>;
|
|
77
77
|
|
|
78
78
|
export type UnionTypeAnnotation<+T> = Readonly<{
|
|
79
79
|
type: 'UnionTypeAnnotation',
|
|
80
|
-
types:
|
|
80
|
+
types: ReadonlyArray<T>,
|
|
81
81
|
}>;
|
|
82
82
|
|
|
83
83
|
export type MixedTypeAnnotation = Readonly<{
|
|
@@ -91,7 +91,7 @@ export type EventEmitterTypeAnnotation = Readonly<{
|
|
|
91
91
|
|
|
92
92
|
type FunctionTypeAnnotation<+P, +R> = Readonly<{
|
|
93
93
|
type: 'FunctionTypeAnnotation',
|
|
94
|
-
params:
|
|
94
|
+
params: ReadonlyArray<NamedShape<P>>,
|
|
95
95
|
returnTypeAnnotation: R,
|
|
96
96
|
}>;
|
|
97
97
|
|
|
@@ -110,10 +110,10 @@ export type ComponentSchema = Readonly<{
|
|
|
110
110
|
|
|
111
111
|
export type ComponentShape = Readonly<{
|
|
112
112
|
...OptionsShape,
|
|
113
|
-
extendsProps:
|
|
114
|
-
events:
|
|
115
|
-
props:
|
|
116
|
-
commands:
|
|
113
|
+
extendsProps: ReadonlyArray<ExtendsPropsShape>,
|
|
114
|
+
events: ReadonlyArray<EventTypeShape>,
|
|
115
|
+
props: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
|
116
|
+
commands: ReadonlyArray<NamedShape<CommandTypeAnnotation>>,
|
|
117
117
|
}>;
|
|
118
118
|
|
|
119
119
|
export type OptionsShape = Readonly<{
|
|
@@ -124,7 +124,7 @@ export type OptionsShape = Readonly<{
|
|
|
124
124
|
// Does not check for new name
|
|
125
125
|
paperComponentName?: string,
|
|
126
126
|
// Use for components that are not used on other platforms.
|
|
127
|
-
excludedPlatforms?:
|
|
127
|
+
excludedPlatforms?: ReadonlyArray<PlatformType>,
|
|
128
128
|
// Use for components currently being renamed in paper
|
|
129
129
|
// Will use new name if it is available and fallback to this name
|
|
130
130
|
paperComponentNameDeprecated?: string,
|
|
@@ -171,7 +171,7 @@ export type ComponentArrayTypeAnnotation = ArrayTypeAnnotation<
|
|
|
171
171
|
| Readonly<{
|
|
172
172
|
type: 'StringEnumTypeAnnotation',
|
|
173
173
|
default: string,
|
|
174
|
-
options:
|
|
174
|
+
options: ReadonlyArray<string>,
|
|
175
175
|
}>
|
|
176
176
|
| ObjectTypeAnnotation<PropTypeAnnotation>
|
|
177
177
|
| ReservedPropTypeAnnotation
|
|
@@ -220,12 +220,12 @@ export type PropTypeAnnotation =
|
|
|
220
220
|
| Readonly<{
|
|
221
221
|
type: 'StringEnumTypeAnnotation',
|
|
222
222
|
default: string,
|
|
223
|
-
options:
|
|
223
|
+
options: ReadonlyArray<string>,
|
|
224
224
|
}>
|
|
225
225
|
| Readonly<{
|
|
226
226
|
type: 'Int32EnumTypeAnnotation',
|
|
227
227
|
default: number,
|
|
228
|
-
options:
|
|
228
|
+
options: ReadonlyArray<number>,
|
|
229
229
|
}>
|
|
230
230
|
| ReservedPropTypeAnnotation
|
|
231
231
|
| ObjectTypeAnnotation<PropTypeAnnotation>
|
|
@@ -283,12 +283,12 @@ export type NativeModuleSchema = Readonly<{
|
|
|
283
283
|
// Use for modules that are not used on other platforms.
|
|
284
284
|
// TODO: It's clearer to define `restrictedToPlatforms` instead, but
|
|
285
285
|
// `excludedPlatforms` is used here to be consistent with ComponentSchema.
|
|
286
|
-
excludedPlatforms?:
|
|
286
|
+
excludedPlatforms?: ReadonlyArray<PlatformType>,
|
|
287
287
|
}>;
|
|
288
288
|
|
|
289
289
|
type NativeModuleSpec = Readonly<{
|
|
290
|
-
eventEmitters:
|
|
291
|
-
methods:
|
|
290
|
+
eventEmitters: ReadonlyArray<NativeModuleEventEmitterShape>,
|
|
291
|
+
methods: ReadonlyArray<NativeModulePropertyShape>,
|
|
292
292
|
}>;
|
|
293
293
|
|
|
294
294
|
export type NativeModuleEventEmitterShape =
|
|
@@ -353,7 +353,7 @@ export type NativeModuleEnumDeclarationWithMembers = {
|
|
|
353
353
|
name: string,
|
|
354
354
|
type: 'EnumDeclarationWithMembers',
|
|
355
355
|
memberType: NativeModuleEnumMemberType,
|
|
356
|
-
members:
|
|
356
|
+
members: ReadonlyArray<NativeModuleEnumMember>,
|
|
357
357
|
};
|
|
358
358
|
|
|
359
359
|
export type NativeModuleGenericObjectTypeAnnotation = Readonly<{
|
|
@@ -14,7 +14,7 @@ import type {SchemaType} from './CodegenSchema';
|
|
|
14
14
|
|
|
15
15
|
const nullthrows = require('nullthrows');
|
|
16
16
|
|
|
17
|
-
function getErrors(schema: SchemaType):
|
|
17
|
+
function getErrors(schema: SchemaType): ReadonlyArray<string> {
|
|
18
18
|
const errors = new Set<string>();
|
|
19
19
|
|
|
20
20
|
// Map of component name -> Array of module names
|
|
@@ -67,7 +67,7 @@ class HeterogeneousUnionError extends Error {
|
|
|
67
67
|
function parseValidUnionType(
|
|
68
68
|
annotation: NativeModuleUnionTypeAnnotation,
|
|
69
69
|
): ValidUnionType {
|
|
70
|
-
const isUnionOfType = (types:
|
|
70
|
+
const isUnionOfType = (types: ReadonlyArray<string>): boolean => {
|
|
71
71
|
return annotation.types.every(memberTypeAnnotation =>
|
|
72
72
|
types.includes(memberTypeAnnotation.type),
|
|
73
73
|
);
|
|
@@ -46,7 +46,7 @@ function getNativeTypeFromAnnotation(
|
|
|
46
46
|
| ReservedPropTypeAnnotation
|
|
47
47
|
| {
|
|
48
48
|
+default: string,
|
|
49
|
-
+options:
|
|
49
|
+
+options: ReadonlyArray<string>,
|
|
50
50
|
+type: 'StringEnumTypeAnnotation',
|
|
51
51
|
}
|
|
52
52
|
| {
|
|
@@ -54,7 +54,7 @@ function getNativeTypeFromAnnotation(
|
|
|
54
54
|
+type: 'ArrayTypeAnnotation',
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
|
-
nameParts:
|
|
57
|
+
nameParts: ReadonlyArray<string>,
|
|
58
58
|
): string {
|
|
59
59
|
const typeAnnotation = prop.typeAnnotation;
|
|
60
60
|
|
|
@@ -214,7 +214,7 @@ const convertVarValueToPointer = (type: string, value: string): string => {
|
|
|
214
214
|
};
|
|
215
215
|
|
|
216
216
|
function getLocalImports(
|
|
217
|
-
properties:
|
|
217
|
+
properties: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
|
218
218
|
): Set<string> {
|
|
219
219
|
const imports: Set<string> = new Set();
|
|
220
220
|
|
|
@@ -120,8 +120,8 @@ function getCppArrayTypeForAnnotation(
|
|
|
120
120
|
|
|
121
121
|
function getImports(
|
|
122
122
|
properties:
|
|
123
|
-
|
|
|
124
|
-
|
|
|
123
|
+
| ReadonlyArray<NamedShape<PropTypeAnnotation>>
|
|
124
|
+
| ReadonlyArray<NamedShape<EventTypeAnnotation>>,
|
|
125
125
|
): Set<string> {
|
|
126
126
|
const imports: Set<string> = new Set();
|
|
127
127
|
|
|
@@ -183,13 +183,13 @@ function getImports(
|
|
|
183
183
|
return imports;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
function generateEventStructName(parts:
|
|
186
|
+
function generateEventStructName(parts: ReadonlyArray<string> = []): string {
|
|
187
187
|
return parts.map(toSafeCppString).join('');
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
function generateStructName(
|
|
191
191
|
componentName: string,
|
|
192
|
-
parts:
|
|
192
|
+
parts: ReadonlyArray<string> = [],
|
|
193
193
|
): string {
|
|
194
194
|
const additional = parts.map(toSafeCppString).join('');
|
|
195
195
|
return `${componentName}${additional}Struct`;
|
|
@@ -99,7 +99,7 @@ void ${className}EventEmitter::${eventName}() const {
|
|
|
99
99
|
function generateSetter(
|
|
100
100
|
variableName: string,
|
|
101
101
|
propertyName: string,
|
|
102
|
-
propertyParts:
|
|
102
|
+
propertyParts: ReadonlyArray<string>,
|
|
103
103
|
usingEvent: boolean,
|
|
104
104
|
valueMapper: string => string = value => value,
|
|
105
105
|
) {
|
|
@@ -114,7 +114,7 @@ function generateSetter(
|
|
|
114
114
|
function generateObjectSetter(
|
|
115
115
|
variableName: string,
|
|
116
116
|
propertyName: string,
|
|
117
|
-
propertyParts:
|
|
117
|
+
propertyParts: ReadonlyArray<string>,
|
|
118
118
|
typeAnnotation: ObjectTypeAnnotation<EventTypeAnnotation>,
|
|
119
119
|
extraIncludes: Set<string>,
|
|
120
120
|
usingEvent: boolean,
|
|
@@ -151,7 +151,7 @@ function setValueAtIndex(
|
|
|
151
151
|
function generateArraySetter(
|
|
152
152
|
variableName: string,
|
|
153
153
|
propertyName: string,
|
|
154
|
-
propertyParts:
|
|
154
|
+
propertyParts: ReadonlyArray<string>,
|
|
155
155
|
elementType: EventTypeAnnotation,
|
|
156
156
|
extraIncludes: Set<string>,
|
|
157
157
|
usingEvent: boolean,
|
|
@@ -184,7 +184,7 @@ function handleArrayElementType(
|
|
|
184
184
|
propertyName: string,
|
|
185
185
|
indexVariable: string,
|
|
186
186
|
loopLocalVariable: string,
|
|
187
|
-
propertyParts:
|
|
187
|
+
propertyParts: ReadonlyArray<string>,
|
|
188
188
|
extraIncludes: Set<string>,
|
|
189
189
|
usingEvent: boolean,
|
|
190
190
|
): string {
|
|
@@ -249,7 +249,7 @@ function convertObjectTypeArray(
|
|
|
249
249
|
propertyName: string,
|
|
250
250
|
indexVariable: string,
|
|
251
251
|
loopLocalVariable: string,
|
|
252
|
-
propertyParts:
|
|
252
|
+
propertyParts: ReadonlyArray<string>,
|
|
253
253
|
objectTypeAnnotation: ObjectTypeAnnotation<EventTypeAnnotation>,
|
|
254
254
|
extraIncludes: Set<string>,
|
|
255
255
|
): string {
|
|
@@ -268,7 +268,7 @@ function convertArrayTypeArray(
|
|
|
268
268
|
propertyName: string,
|
|
269
269
|
indexVariable: string,
|
|
270
270
|
loopLocalVariable: string,
|
|
271
|
-
propertyParts:
|
|
271
|
+
propertyParts: ReadonlyArray<string>,
|
|
272
272
|
eventTypeAnnotation: EventTypeAnnotation,
|
|
273
273
|
extraIncludes: Set<string>,
|
|
274
274
|
usingEvent: boolean,
|
|
@@ -296,8 +296,8 @@ function convertArrayTypeArray(
|
|
|
296
296
|
|
|
297
297
|
function generateSetters(
|
|
298
298
|
parentPropertyName: string,
|
|
299
|
-
properties:
|
|
300
|
-
propertyParts:
|
|
299
|
+
properties: ReadonlyArray<NamedShape<EventTypeAnnotation>>,
|
|
300
|
+
propertyParts: ReadonlyArray<string>,
|
|
301
301
|
extraIncludes: Set<string>,
|
|
302
302
|
usingEvent: boolean = true,
|
|
303
303
|
): string {
|
|
@@ -117,7 +117,7 @@ static char const *toString(const ${enumName} value) {
|
|
|
117
117
|
function getNativeTypeFromAnnotation(
|
|
118
118
|
componentName: string,
|
|
119
119
|
eventProperty: NamedShape<EventTypeAnnotation>,
|
|
120
|
-
nameParts:
|
|
120
|
+
nameParts: ReadonlyArray<string>,
|
|
121
121
|
): string {
|
|
122
122
|
const {typeAnnotation} = eventProperty;
|
|
123
123
|
switch (typeAnnotation.type) {
|
|
@@ -156,7 +156,7 @@ function getNativeTypeFromAnnotation(
|
|
|
156
156
|
}
|
|
157
157
|
function generateEnum(
|
|
158
158
|
structs: StructsMap,
|
|
159
|
-
options:
|
|
159
|
+
options: ReadonlyArray<string>,
|
|
160
160
|
nameParts: Array<string>,
|
|
161
161
|
) {
|
|
162
162
|
const structName = generateEventStructName(nameParts);
|
|
@@ -186,7 +186,7 @@ function handleGenerateStructForArray(
|
|
|
186
186
|
name: string,
|
|
187
187
|
componentName: string,
|
|
188
188
|
elementType: EventTypeAnnotation,
|
|
189
|
-
nameParts:
|
|
189
|
+
nameParts: ReadonlyArray<string>,
|
|
190
190
|
): void {
|
|
191
191
|
if (elementType.type === 'ObjectTypeAnnotation') {
|
|
192
192
|
generateStruct(
|
|
@@ -219,8 +219,8 @@ function handleGenerateStructForArray(
|
|
|
219
219
|
function generateStruct(
|
|
220
220
|
structs: StructsMap,
|
|
221
221
|
componentName: string,
|
|
222
|
-
nameParts:
|
|
223
|
-
properties:
|
|
222
|
+
nameParts: ReadonlyArray<string>,
|
|
223
|
+
properties: ReadonlyArray<NamedShape<EventTypeAnnotation>>,
|
|
224
224
|
): void {
|
|
225
225
|
const structNameParts = nameParts;
|
|
226
226
|
const structName = generateEventStructName(structNameParts);
|
|
@@ -351,7 +351,7 @@ function convertValueToEnumOption(value: string): string {
|
|
|
351
351
|
function generateArrayEnumString(
|
|
352
352
|
componentName: string,
|
|
353
353
|
name: string,
|
|
354
|
-
options:
|
|
354
|
+
options: ReadonlyArray<string>,
|
|
355
355
|
): string {
|
|
356
356
|
const enumName = getEnumName(componentName, name);
|
|
357
357
|
|
|
@@ -393,7 +393,7 @@ function generateStringEnum(
|
|
|
393
393
|
) {
|
|
394
394
|
const typeAnnotation = prop.typeAnnotation;
|
|
395
395
|
if (typeAnnotation.type === 'StringEnumTypeAnnotation') {
|
|
396
|
-
const values:
|
|
396
|
+
const values: ReadonlyArray<string> = typeAnnotation.options;
|
|
397
397
|
const enumName = getEnumName(componentName, prop.name);
|
|
398
398
|
|
|
399
399
|
const fromCases = values
|
|
@@ -431,7 +431,7 @@ function generateIntEnum(
|
|
|
431
431
|
) {
|
|
432
432
|
const typeAnnotation = prop.typeAnnotation;
|
|
433
433
|
if (typeAnnotation.type === 'Int32EnumTypeAnnotation') {
|
|
434
|
-
const values:
|
|
434
|
+
const values: ReadonlyArray<number> = typeAnnotation.options;
|
|
435
435
|
const enumName = getEnumName(componentName, prop.name);
|
|
436
436
|
|
|
437
437
|
const fromCases = values
|
|
@@ -527,8 +527,8 @@ function generateEnumString(
|
|
|
527
527
|
|
|
528
528
|
function generatePropsString(
|
|
529
529
|
componentName: string,
|
|
530
|
-
props:
|
|
531
|
-
nameParts:
|
|
530
|
+
props: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
|
531
|
+
nameParts: ReadonlyArray<string>,
|
|
532
532
|
generateOptionalProperties?: boolean = false,
|
|
533
533
|
) {
|
|
534
534
|
return props
|
|
@@ -557,7 +557,7 @@ function generatePropsString(
|
|
|
557
557
|
}
|
|
558
558
|
|
|
559
559
|
function getExtendsImports(
|
|
560
|
-
extendsProps:
|
|
560
|
+
extendsProps: ReadonlyArray<ExtendsPropsShape>,
|
|
561
561
|
): Set<string> {
|
|
562
562
|
const imports: Set<string> = new Set();
|
|
563
563
|
|
|
@@ -605,7 +605,7 @@ function generateStructsForComponent(
|
|
|
605
605
|
|
|
606
606
|
function generateStructs(
|
|
607
607
|
componentName: string,
|
|
608
|
-
properties:
|
|
608
|
+
properties: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
|
609
609
|
nameParts: Array<string>,
|
|
610
610
|
generateOptionalObjectProperties?: boolean = false,
|
|
611
611
|
): StructsMap {
|
|
@@ -726,8 +726,8 @@ function generateStructs(
|
|
|
726
726
|
function generateStruct(
|
|
727
727
|
structs: StructsMap,
|
|
728
728
|
componentName: string,
|
|
729
|
-
nameParts:
|
|
730
|
-
properties:
|
|
729
|
+
nameParts: ReadonlyArray<string>,
|
|
730
|
+
properties: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
|
731
731
|
generateOptionalObjectProperties?: boolean = false,
|
|
732
732
|
): void {
|
|
733
733
|
const structNameParts = nameParts;
|
|
@@ -29,7 +29,7 @@ const {capitalize} = require('../../Utils');
|
|
|
29
29
|
export type Pojo = {
|
|
30
30
|
name: string,
|
|
31
31
|
namespace: string,
|
|
32
|
-
properties:
|
|
32
|
+
properties: ReadonlyArray<PojoProperty>,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export type PojoProperty = NamedShape<PojoTypeAnnotation>;
|
|
@@ -63,12 +63,12 @@ export type PojoTypeAnnotation =
|
|
|
63
63
|
| Readonly<{
|
|
64
64
|
type: 'StringEnumTypeAnnotation',
|
|
65
65
|
default: string,
|
|
66
|
-
options:
|
|
66
|
+
options: ReadonlyArray<string>,
|
|
67
67
|
}>
|
|
68
68
|
| Readonly<{
|
|
69
69
|
type: 'Int32EnumTypeAnnotation',
|
|
70
70
|
default: number,
|
|
71
|
-
options:
|
|
71
|
+
options: ReadonlyArray<number>,
|
|
72
72
|
}>
|
|
73
73
|
| ReservedPropTypeAnnotation
|
|
74
74
|
| PojoTypeAliasAnnotation
|
|
@@ -84,7 +84,7 @@ export type PojoTypeAnnotation =
|
|
|
84
84
|
| Readonly<{
|
|
85
85
|
type: 'StringEnumTypeAnnotation',
|
|
86
86
|
default: string,
|
|
87
|
-
options:
|
|
87
|
+
options: ReadonlyArray<string>,
|
|
88
88
|
}>
|
|
89
89
|
| PojoTypeAliasAnnotation
|
|
90
90
|
| ReservedPropTypeAnnotation
|
|
@@ -182,7 +182,7 @@ class PojoCollector {
|
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
getAllPojos():
|
|
185
|
+
getAllPojos(): ReadonlyArray<Pojo> {
|
|
186
186
|
return [...this._pojos.values()];
|
|
187
187
|
}
|
|
188
188
|
}
|
|
@@ -184,7 +184,7 @@ function normalizeInputEventName(name: string) {
|
|
|
184
184
|
|
|
185
185
|
// Replicates the behavior of viewConfig in RCTComponentData.m
|
|
186
186
|
function getValidAttributesForEvents(
|
|
187
|
-
events:
|
|
187
|
+
events: ReadonlyArray<EventTypeShape>,
|
|
188
188
|
imports: Set<string>,
|
|
189
189
|
) {
|
|
190
190
|
imports.add(
|
|
@@ -170,7 +170,7 @@ const ModuleSpecClassDeclarationTemplate = ({
|
|
|
170
170
|
enums: string,
|
|
171
171
|
moduleEventEmitters: EventEmitterCpp[],
|
|
172
172
|
moduleFunctions: string[],
|
|
173
|
-
methods:
|
|
173
|
+
methods: ReadonlyArray<Readonly<{methodName: string, paramCount: number}>>,
|
|
174
174
|
}>) => {
|
|
175
175
|
return `${enums}${structs}
|
|
176
176
|
template <typename T>
|
|
@@ -504,7 +504,7 @@ function getMemberValueAppearance(member: NativeModuleEnumMember['value']) {
|
|
|
504
504
|
function generateEnum(
|
|
505
505
|
hasteModuleName: string,
|
|
506
506
|
origEnumName: string,
|
|
507
|
-
members:
|
|
507
|
+
members: ReadonlyArray<NativeModuleEnumMember>,
|
|
508
508
|
memberType: NativeModuleEnumMemberType,
|
|
509
509
|
): string {
|
|
510
510
|
const enumName = getEnumName(hasteModuleName, origEnumName);
|
|
@@ -60,8 +60,8 @@ const ModuleClassConstructorTemplate = ({
|
|
|
60
60
|
methods,
|
|
61
61
|
}: Readonly<{
|
|
62
62
|
hasteModuleName: string,
|
|
63
|
-
eventEmitters:
|
|
64
|
-
methods:
|
|
63
|
+
eventEmitters: ReadonlyArray<NativeModuleEventEmitterShape>,
|
|
64
|
+
methods: ReadonlyArray<{
|
|
65
65
|
propertyName: string,
|
|
66
66
|
argCount: number,
|
|
67
67
|
}>,
|
|
@@ -109,7 +109,7 @@ const FileTemplate = ({
|
|
|
109
109
|
libraryName: string,
|
|
110
110
|
include: string,
|
|
111
111
|
modules: string,
|
|
112
|
-
moduleLookups:
|
|
112
|
+
moduleLookups: ReadonlyArray<{
|
|
113
113
|
hasteModuleName: string,
|
|
114
114
|
moduleName: string,
|
|
115
115
|
}>,
|
|
@@ -527,7 +527,7 @@ module.exports = {
|
|
|
527
527
|
})
|
|
528
528
|
.join('\n');
|
|
529
529
|
|
|
530
|
-
const moduleLookups:
|
|
530
|
+
const moduleLookups: ReadonlyArray<{
|
|
531
531
|
hasteModuleName: string,
|
|
532
532
|
moduleName: string,
|
|
533
533
|
}> = Object.keys(nativeModules)
|
|
@@ -47,13 +47,13 @@ type StructContext = 'CONSTANTS' | 'REGULAR';
|
|
|
47
47
|
export type RegularStruct = Readonly<{
|
|
48
48
|
context: 'REGULAR',
|
|
49
49
|
name: string,
|
|
50
|
-
properties:
|
|
50
|
+
properties: ReadonlyArray<StructProperty>,
|
|
51
51
|
}>;
|
|
52
52
|
|
|
53
53
|
export type ConstantsStruct = Readonly<{
|
|
54
54
|
context: 'CONSTANTS',
|
|
55
55
|
name: string,
|
|
56
|
-
properties:
|
|
56
|
+
properties: ReadonlyArray<StructProperty>,
|
|
57
57
|
}>;
|
|
58
58
|
|
|
59
59
|
export type Struct = RegularStruct | ConstantsStruct;
|
|
@@ -240,7 +240,7 @@ class StructCollector {
|
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
getAllStructs():
|
|
243
|
+
getAllStructs(): ReadonlyArray<Struct> {
|
|
244
244
|
return [...this._structs.values()];
|
|
245
245
|
}
|
|
246
246
|
|
|
@@ -57,7 +57,7 @@ export type MethodSerializationOutput = Readonly<{
|
|
|
57
57
|
methodName: string,
|
|
58
58
|
protocolMethod: string,
|
|
59
59
|
selector: string,
|
|
60
|
-
structParamRecords:
|
|
60
|
+
structParamRecords: ReadonlyArray<StructParameterRecord>,
|
|
61
61
|
returnJSType: ReturnJSType,
|
|
62
62
|
argCount: number,
|
|
63
63
|
}>;
|
|
@@ -67,7 +67,7 @@ function serializeMethod(
|
|
|
67
67
|
property: NativeModulePropertyShape,
|
|
68
68
|
structCollector: StructCollector,
|
|
69
69
|
resolveAlias: AliasResolver,
|
|
70
|
-
):
|
|
70
|
+
): ReadonlyArray<MethodSerializationOutput> {
|
|
71
71
|
const {name: methodName, typeAnnotation: nullableTypeAnnotation} = property;
|
|
72
72
|
const [propertyTypeAnnotation] = unwrapNullable(nullableTypeAnnotation);
|
|
73
73
|
const {params} = propertyTypeAnnotation;
|
|
@@ -472,7 +472,7 @@ function serializeConstantsProtocolMethods(
|
|
|
472
472
|
property: NativeModulePropertyShape,
|
|
473
473
|
structCollector: StructCollector,
|
|
474
474
|
resolveAlias: AliasResolver,
|
|
475
|
-
):
|
|
475
|
+
): ReadonlyArray<MethodSerializationOutput> {
|
|
476
476
|
const [propertyTypeAnnotation] = unwrapNullable(property.typeAnnotation);
|
|
477
477
|
if (propertyTypeAnnotation.params.length !== 0) {
|
|
478
478
|
throw new Error(
|
|
@@ -29,10 +29,10 @@ const ModuleTemplate = ({
|
|
|
29
29
|
methodSerializationOutputs,
|
|
30
30
|
}: Readonly<{
|
|
31
31
|
hasteModuleName: string,
|
|
32
|
-
structs:
|
|
32
|
+
structs: ReadonlyArray<Struct>,
|
|
33
33
|
moduleName: string,
|
|
34
|
-
eventEmitters:
|
|
35
|
-
methodSerializationOutputs:
|
|
34
|
+
eventEmitters: ReadonlyArray<NativeModuleEventEmitterShape>,
|
|
35
|
+
methodSerializationOutputs: ReadonlyArray<MethodSerializationOutput>,
|
|
36
36
|
}>) => `
|
|
37
37
|
@implementation ${hasteModuleName}SpecBase
|
|
38
38
|
${eventEmitters
|
|
@@ -129,7 +129,7 @@ const MethodMapEntryTemplate = ({
|
|
|
129
129
|
}: Readonly<{
|
|
130
130
|
hasteModuleName: string,
|
|
131
131
|
methodName: string,
|
|
132
|
-
structParamRecords:
|
|
132
|
+
structParamRecords: ReadonlyArray<StructParameterRecord>,
|
|
133
133
|
argCount: number,
|
|
134
134
|
}>) => `
|
|
135
135
|
methodMap_["${methodName}"] = MethodMetadata {${argCount}, __hostFunction_${hasteModuleName}SpecJSI_${methodName}};
|
|
@@ -141,10 +141,10 @@ const MethodMapEntryTemplate = ({
|
|
|
141
141
|
|
|
142
142
|
function serializeModuleSource(
|
|
143
143
|
hasteModuleName: string,
|
|
144
|
-
structs:
|
|
144
|
+
structs: ReadonlyArray<Struct>,
|
|
145
145
|
moduleName: string,
|
|
146
|
-
eventEmitters:
|
|
147
|
-
methodSerializationOutputs:
|
|
146
|
+
eventEmitters: ReadonlyArray<NativeModuleEventEmitterShape>,
|
|
147
|
+
methodSerializationOutputs: ReadonlyArray<MethodSerializationOutput>,
|
|
148
148
|
): string {
|
|
149
149
|
return ModuleTemplate({
|
|
150
150
|
hasteModuleName,
|
|
@@ -239,7 +239,7 @@ function throwIfPropertyValueTypeIsUnsupported(
|
|
|
239
239
|
|
|
240
240
|
function throwIfMoreThanOneModuleInterfaceParserError(
|
|
241
241
|
nativeModuleName: string,
|
|
242
|
-
moduleSpecs:
|
|
242
|
+
moduleSpecs: ReadonlyArray<$FlowFixMe>,
|
|
243
243
|
parserType: ParserType,
|
|
244
244
|
) {
|
|
245
245
|
if (moduleSpecs.length > 1) {
|
|
@@ -333,7 +333,7 @@ function throwIfPartialWithMoreParameter(typeAnnotation: $FlowFixMe) {
|
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
function throwIfMoreThanOneCodegenNativecommands(
|
|
336
|
-
commandsTypeNames:
|
|
336
|
+
commandsTypeNames: ReadonlyArray<$FlowFixMe>,
|
|
337
337
|
) {
|
|
338
338
|
if (commandsTypeNames.length > 1) {
|
|
339
339
|
throw new Error('codegenNativeCommands may only be called once in a file');
|
|
@@ -375,9 +375,9 @@ function throwIfBubblingTypeIsNull(
|
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
function throwIfArgumentPropsAreNull(
|
|
378
|
-
argumentProps:
|
|
378
|
+
argumentProps: ?ReadonlyArray<$FlowFixMe>,
|
|
379
379
|
eventName: string,
|
|
380
|
-
):
|
|
380
|
+
): ReadonlyArray<$FlowFixMe> {
|
|
381
381
|
if (!argumentProps) {
|
|
382
382
|
throw new Error(`Unable to determine event arguments for "${eventName}"`);
|
|
383
383
|
}
|
|
@@ -15,7 +15,7 @@ import type {Parser} from './parser';
|
|
|
15
15
|
export type ParserType = 'Flow' | 'TypeScript';
|
|
16
16
|
|
|
17
17
|
class ParserError extends Error {
|
|
18
|
-
nodes:
|
|
18
|
+
nodes: ReadonlyArray<$FlowFixMe>;
|
|
19
19
|
constructor(
|
|
20
20
|
nativeModuleName: string,
|
|
21
21
|
astNodeOrNodes: $FlowFixMe,
|
|
@@ -57,8 +57,8 @@ class ModuleInterfaceNotFoundParserError extends ParserError {
|
|
|
57
57
|
class MoreThanOneModuleInterfaceParserError extends ParserError {
|
|
58
58
|
constructor(
|
|
59
59
|
nativeModuleName: string,
|
|
60
|
-
flowModuleInterfaces:
|
|
61
|
-
names:
|
|
60
|
+
flowModuleInterfaces: ReadonlyArray<$FlowFixMe>,
|
|
61
|
+
names: ReadonlyArray<string>,
|
|
62
62
|
language: ParserType,
|
|
63
63
|
) {
|
|
64
64
|
const finalName = names[names.length - 1];
|
|
@@ -33,7 +33,7 @@ function buildCommandSchema(
|
|
|
33
33
|
optional: boolean,
|
|
34
34
|
typeAnnotation: {
|
|
35
35
|
type: 'FunctionTypeAnnotation',
|
|
36
|
-
params:
|
|
36
|
+
params: ReadonlyArray<{
|
|
37
37
|
name: string,
|
|
38
38
|
optional: boolean,
|
|
39
39
|
typeAnnotation: CommandParamTypeAnnotation,
|
|
@@ -224,10 +224,10 @@ function getCommandArrayElementTypeType(
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
function getCommands(
|
|
227
|
-
commandTypeAST:
|
|
227
|
+
commandTypeAST: ReadonlyArray<EventTypeAST>,
|
|
228
228
|
types: TypeDeclarationMap,
|
|
229
229
|
parser: Parser,
|
|
230
|
-
):
|
|
230
|
+
): ReadonlyArray<NamedShape<CommandTypeAnnotation>> {
|
|
231
231
|
return commandTypeAST
|
|
232
232
|
.filter(property => property.type === 'ObjectTypeProperty')
|
|
233
233
|
.map(property => buildCommandSchema(property, types, parser))
|
|
@@ -187,10 +187,10 @@ function getTypeAnnotationForArray<+T>(
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
function flattenProperties(
|
|
190
|
-
typeDefinition:
|
|
190
|
+
typeDefinition: ReadonlyArray<PropAST>,
|
|
191
191
|
types: TypeDeclarationMap,
|
|
192
192
|
parser: Parser,
|
|
193
|
-
):
|
|
193
|
+
): ReadonlyArray<PropAST> {
|
|
194
194
|
return typeDefinition
|
|
195
195
|
.map(property => {
|
|
196
196
|
if (property.type === 'ObjectTypeProperty') {
|
|
@@ -275,10 +275,10 @@ type TypeMap = {
|
|
|
275
275
|
};
|
|
276
276
|
|
|
277
277
|
function getEvents(
|
|
278
|
-
eventTypeAST:
|
|
278
|
+
eventTypeAST: ReadonlyArray<EventTypeAST>,
|
|
279
279
|
types: TypeMap,
|
|
280
280
|
parser: Parser,
|
|
281
|
-
):
|
|
281
|
+
): ReadonlyArray<EventTypeShape> {
|
|
282
282
|
return eventTypeAST
|
|
283
283
|
.filter(property => property.type === 'ObjectTypeProperty')
|
|
284
284
|
.map(property => buildEventSchema(types, property, parser))
|
|
@@ -152,7 +152,7 @@ class FlowParser implements Parser {
|
|
|
152
152
|
|
|
153
153
|
getFunctionTypeAnnotationParameters(
|
|
154
154
|
functionTypeAnnotation: $FlowFixMe,
|
|
155
|
-
):
|
|
155
|
+
): ReadonlyArray<$FlowFixMe> {
|
|
156
156
|
return functionTypeAnnotation.params;
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -227,7 +227,7 @@ class FlowParser implements Parser {
|
|
|
227
227
|
|
|
228
228
|
parseEnumMembers(
|
|
229
229
|
typeAnnotation: $FlowFixMe,
|
|
230
|
-
):
|
|
230
|
+
): ReadonlyArray<NativeModuleEnumMember> {
|
|
231
231
|
return typeAnnotation.members.map(member => {
|
|
232
232
|
const value =
|
|
233
233
|
typeof member.init?.value === 'number'
|
|
@@ -371,7 +371,7 @@ class FlowParser implements Parser {
|
|
|
371
371
|
return annotatedElement.right.properties;
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
bodyProperties(typeAlias: $FlowFixMe):
|
|
374
|
+
bodyProperties(typeAlias: $FlowFixMe): ReadonlyArray<$FlowFixMe> {
|
|
375
375
|
return typeAlias.body.properties;
|
|
376
376
|
}
|
|
377
377
|
|
|
@@ -489,9 +489,9 @@ class FlowParser implements Parser {
|
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
removeKnownExtends(
|
|
492
|
-
typeDefinition:
|
|
492
|
+
typeDefinition: ReadonlyArray<PropAST>,
|
|
493
493
|
types: TypeDeclarationMap,
|
|
494
|
-
):
|
|
494
|
+
): ReadonlyArray<PropAST> {
|
|
495
495
|
return typeDefinition.filter(
|
|
496
496
|
prop =>
|
|
497
497
|
prop.type !== 'ObjectTypeSpreadProperty' ||
|
|
@@ -500,9 +500,9 @@ class FlowParser implements Parser {
|
|
|
500
500
|
}
|
|
501
501
|
|
|
502
502
|
getExtendsProps(
|
|
503
|
-
typeDefinition:
|
|
503
|
+
typeDefinition: ReadonlyArray<PropAST>,
|
|
504
504
|
types: TypeDeclarationMap,
|
|
505
|
-
):
|
|
505
|
+
): ReadonlyArray<ExtendsPropsShape> {
|
|
506
506
|
return typeDefinition
|
|
507
507
|
.filter(prop => prop.type === 'ObjectTypeSpreadProperty')
|
|
508
508
|
.map(prop => this.extendsForProp(prop, types, this))
|
|
@@ -510,11 +510,11 @@ class FlowParser implements Parser {
|
|
|
510
510
|
}
|
|
511
511
|
|
|
512
512
|
getProps(
|
|
513
|
-
typeDefinition:
|
|
513
|
+
typeDefinition: ReadonlyArray<PropAST>,
|
|
514
514
|
types: TypeDeclarationMap,
|
|
515
515
|
): {
|
|
516
|
-
props:
|
|
517
|
-
extendsProps:
|
|
516
|
+
props: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
|
517
|
+
extendsProps: ReadonlyArray<ExtendsPropsShape>,
|
|
518
518
|
} {
|
|
519
519
|
const nonExtendsProps = this.removeKnownExtends(typeDefinition, types);
|
|
520
520
|
const props = flattenProperties(nonExtendsProps, types, this)
|
|
@@ -183,7 +183,7 @@ export interface Parser {
|
|
|
183
183
|
*/
|
|
184
184
|
getFunctionTypeAnnotationParameters(
|
|
185
185
|
functionTypeAnnotation: $FlowFixMe,
|
|
186
|
-
):
|
|
186
|
+
): ReadonlyArray<$FlowFixMe>;
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
189
|
* Given a parameter, it returns the function name of the parameter.
|
|
@@ -235,7 +235,7 @@ export interface Parser {
|
|
|
235
235
|
*/
|
|
236
236
|
parseEnumMembers(
|
|
237
237
|
typeAnnotation: $FlowFixMe,
|
|
238
|
-
):
|
|
238
|
+
): ReadonlyArray<NativeModuleEnumMember>;
|
|
239
239
|
|
|
240
240
|
/**
|
|
241
241
|
* Given a node, it returns true if it is a module interface
|
|
@@ -328,7 +328,7 @@ export interface Parser {
|
|
|
328
328
|
* @parameter typeAlias: the type alias.
|
|
329
329
|
* @returns: an array of properties.
|
|
330
330
|
*/
|
|
331
|
-
bodyProperties(typeAlias: $FlowFixMe):
|
|
331
|
+
bodyProperties(typeAlias: $FlowFixMe): ReadonlyArray<$FlowFixMe>;
|
|
332
332
|
|
|
333
333
|
/**
|
|
334
334
|
* Given a keyword convert it to TypeAnnotation.
|
|
@@ -382,11 +382,11 @@ export interface Parser {
|
|
|
382
382
|
getResolveTypeAnnotationFN(): ResolveTypeAnnotationFN;
|
|
383
383
|
|
|
384
384
|
getProps(
|
|
385
|
-
typeDefinition:
|
|
385
|
+
typeDefinition: ReadonlyArray<PropAST>,
|
|
386
386
|
types: TypeDeclarationMap,
|
|
387
387
|
): {
|
|
388
|
-
props:
|
|
389
|
-
extendsProps:
|
|
388
|
+
props: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
|
389
|
+
extendsProps: ReadonlyArray<ExtendsPropsShape>,
|
|
390
390
|
};
|
|
391
391
|
|
|
392
392
|
getProperties(typeName: string, types: TypeDeclarationMap): $FlowFixMe;
|
|
@@ -133,7 +133,7 @@ export class MockedParser implements Parser {
|
|
|
133
133
|
|
|
134
134
|
getFunctionTypeAnnotationParameters(
|
|
135
135
|
functionTypeAnnotation: $FlowFixMe,
|
|
136
|
-
):
|
|
136
|
+
): ReadonlyArray<$FlowFixMe> {
|
|
137
137
|
return functionTypeAnnotation.params;
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -170,7 +170,7 @@ export class MockedParser implements Parser {
|
|
|
170
170
|
|
|
171
171
|
parseEnumMembers(
|
|
172
172
|
typeAnnotation: $FlowFixMe,
|
|
173
|
-
):
|
|
173
|
+
): ReadonlyArray<NativeModuleEnumMember> {
|
|
174
174
|
return typeAnnotation.type === 'StringTypeAnnotation'
|
|
175
175
|
? [
|
|
176
176
|
{
|
|
@@ -279,7 +279,7 @@ export class MockedParser implements Parser {
|
|
|
279
279
|
return annotatedElement.right.properties;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
bodyProperties(typeAlias: $FlowFixMe):
|
|
282
|
+
bodyProperties(typeAlias: $FlowFixMe): ReadonlyArray<$FlowFixMe> {
|
|
283
283
|
return typeAlias.body.properties;
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -401,9 +401,9 @@ export class MockedParser implements Parser {
|
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
getExtendsProps(
|
|
404
|
-
typeDefinition:
|
|
404
|
+
typeDefinition: ReadonlyArray<PropAST>,
|
|
405
405
|
types: TypeDeclarationMap,
|
|
406
|
-
):
|
|
406
|
+
): ReadonlyArray<ExtendsPropsShape> {
|
|
407
407
|
return typeDefinition
|
|
408
408
|
.filter(prop => prop.type === 'ObjectTypeSpreadProperty')
|
|
409
409
|
.map(prop => this.extendsForProp(prop, types, this))
|
|
@@ -439,9 +439,9 @@ export class MockedParser implements Parser {
|
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
removeKnownExtends(
|
|
442
|
-
typeDefinition:
|
|
442
|
+
typeDefinition: ReadonlyArray<PropAST>,
|
|
443
443
|
types: TypeDeclarationMap,
|
|
444
|
-
):
|
|
444
|
+
): ReadonlyArray<PropAST> {
|
|
445
445
|
return typeDefinition.filter(
|
|
446
446
|
prop =>
|
|
447
447
|
prop.type !== 'ObjectTypeSpreadProperty' ||
|
|
@@ -450,11 +450,11 @@ export class MockedParser implements Parser {
|
|
|
450
450
|
}
|
|
451
451
|
|
|
452
452
|
getProps(
|
|
453
|
-
typeDefinition:
|
|
453
|
+
typeDefinition: ReadonlyArray<PropAST>,
|
|
454
454
|
types: TypeDeclarationMap,
|
|
455
455
|
): {
|
|
456
|
-
props:
|
|
457
|
-
extendsProps:
|
|
456
|
+
props: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
|
457
|
+
extendsProps: ReadonlyArray<ExtendsPropsShape>,
|
|
458
458
|
} {
|
|
459
459
|
const nonExtendsProps = this.removeKnownExtends(typeDefinition, types);
|
|
460
460
|
const props = flattenProperties(nonExtendsProps, types, this)
|
|
@@ -78,7 +78,7 @@ const {
|
|
|
78
78
|
const invariant = require('invariant');
|
|
79
79
|
|
|
80
80
|
export type CommandOptions = Readonly<{
|
|
81
|
-
supportedCommands:
|
|
81
|
+
supportedCommands: ReadonlyArray<string>,
|
|
82
82
|
}>;
|
|
83
83
|
|
|
84
84
|
// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser
|
|
@@ -90,7 +90,7 @@ type ExtendedPropResult = {
|
|
|
90
90
|
} | null;
|
|
91
91
|
|
|
92
92
|
export type EventArgumentReturnType = {
|
|
93
|
-
argumentProps:
|
|
93
|
+
argumentProps: ?ReadonlyArray<$FlowFixMe>,
|
|
94
94
|
paperTopLevelNameDeprecated: ?$FlowFixMe,
|
|
95
95
|
bubblingType: ?'direct' | 'bubble',
|
|
96
96
|
};
|
|
@@ -751,7 +751,7 @@ const buildModuleSchema = (
|
|
|
751
751
|
): NativeModuleSchema => {
|
|
752
752
|
const language = parser.language();
|
|
753
753
|
const types = parser.getTypes(ast);
|
|
754
|
-
const moduleSpecs = (Object.values(types):
|
|
754
|
+
const moduleSpecs = (Object.values(types): ReadonlyArray<$FlowFixMe>).filter(
|
|
755
755
|
t => parser.isModuleInterface(t),
|
|
756
756
|
);
|
|
757
757
|
|
|
@@ -793,7 +793,7 @@ const buildModuleSchema = (
|
|
|
793
793
|
parser,
|
|
794
794
|
)
|
|
795
795
|
: {};
|
|
796
|
-
const properties:
|
|
796
|
+
const properties: ReadonlyArray<$FlowFixMe> =
|
|
797
797
|
language === 'Flow' ? moduleSpec.body.properties : moduleSpec.body.body;
|
|
798
798
|
|
|
799
799
|
type PropertyShape =
|
|
@@ -1043,8 +1043,8 @@ function getCommandTypeNameAndOptionsExpression(
|
|
|
1043
1043
|
}
|
|
1044
1044
|
|
|
1045
1045
|
function propertyNames(
|
|
1046
|
-
properties:
|
|
1047
|
-
):
|
|
1046
|
+
properties: ReadonlyArray<$FlowFixMe>,
|
|
1047
|
+
): ReadonlyArray<$FlowFixMe> {
|
|
1048
1048
|
return properties
|
|
1049
1049
|
.map(property => property && property.key && property.key.name)
|
|
1050
1050
|
.filter(Boolean);
|
|
@@ -1293,7 +1293,7 @@ function buildPropertiesForEvent(
|
|
|
1293
1293
|
}
|
|
1294
1294
|
|
|
1295
1295
|
function verifyPropNotAlreadyDefined(
|
|
1296
|
-
props:
|
|
1296
|
+
props: ReadonlyArray<PropAST>,
|
|
1297
1297
|
needleProp: PropAST,
|
|
1298
1298
|
) {
|
|
1299
1299
|
const propName = needleProp.key.name;
|
|
@@ -435,8 +435,8 @@ function emitUnion(
|
|
|
435
435
|
translateTypeAnnotation: $FlowFixMe,
|
|
436
436
|
parser: Parser,
|
|
437
437
|
): Nullable<NativeModuleUnionTypeAnnotation> {
|
|
438
|
-
const unparsedMemberTypes:
|
|
439
|
-
(typeAnnotation.types:
|
|
438
|
+
const unparsedMemberTypes: ReadonlyArray<$FlowFixMe> =
|
|
439
|
+
(typeAnnotation.types: ReadonlyArray<$FlowFixMe>);
|
|
440
440
|
|
|
441
441
|
const memberTypes = unparsedMemberTypes.map(
|
|
442
442
|
(memberType: $FlowFixMe): NativeModuleUnionTypeAnnotationMemberType => {
|
|
@@ -23,10 +23,10 @@ import type {
|
|
|
23
23
|
export type ComponentSchemaBuilderConfig = Readonly<{
|
|
24
24
|
filename: string,
|
|
25
25
|
componentName: string,
|
|
26
|
-
extendsProps:
|
|
27
|
-
events:
|
|
28
|
-
props:
|
|
29
|
-
commands:
|
|
26
|
+
extendsProps: ReadonlyArray<ExtendsPropsShape>,
|
|
27
|
+
events: ReadonlyArray<EventTypeShape>,
|
|
28
|
+
props: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
|
29
|
+
commands: ReadonlyArray<NamedShape<CommandTypeAnnotation>>,
|
|
30
30
|
options?: ?OptionsShape,
|
|
31
31
|
}>;
|
|
32
32
|
|
|
@@ -205,10 +205,10 @@ function buildCommandSchema(
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
function getCommands(
|
|
208
|
-
commandTypeAST:
|
|
208
|
+
commandTypeAST: ReadonlyArray<EventTypeAST>,
|
|
209
209
|
types: TypeDeclarationMap,
|
|
210
210
|
parser: Parser,
|
|
211
|
-
):
|
|
211
|
+
): ReadonlyArray<NamedShape<CommandTypeAnnotation>> {
|
|
212
212
|
return commandTypeAST
|
|
213
213
|
.filter(
|
|
214
214
|
property =>
|
|
@@ -476,10 +476,10 @@ function getSchemaInfo(
|
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
function flattenProperties(
|
|
479
|
-
typeDefinition:
|
|
479
|
+
typeDefinition: ReadonlyArray<PropAST>,
|
|
480
480
|
types: TypeDeclarationMap,
|
|
481
481
|
parser: Parser,
|
|
482
|
-
):
|
|
482
|
+
): ReadonlyArray<PropAST> {
|
|
483
483
|
return typeDefinition
|
|
484
484
|
.map(property => {
|
|
485
485
|
if (property.type === 'TSPropertySignature') {
|
|
@@ -178,7 +178,7 @@ function findEventArgumentsAndType(
|
|
|
178
178
|
bubblingType: void | 'direct' | 'bubble',
|
|
179
179
|
paperName: ?$FlowFixMe,
|
|
180
180
|
): {
|
|
181
|
-
argumentProps:
|
|
181
|
+
argumentProps: ?ReadonlyArray<$FlowFixMe>,
|
|
182
182
|
paperTopLevelNameDeprecated: ?$FlowFixMe,
|
|
183
183
|
bubblingType: ?'direct' | 'bubble',
|
|
184
184
|
} {
|
|
@@ -280,10 +280,10 @@ function buildEventSchema(
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
function getEvents(
|
|
283
|
-
eventTypeAST:
|
|
283
|
+
eventTypeAST: ReadonlyArray<EventTypeAST>,
|
|
284
284
|
types: TypeDeclarationMap,
|
|
285
285
|
parser: Parser,
|
|
286
|
-
):
|
|
286
|
+
): ReadonlyArray<EventTypeShape> {
|
|
287
287
|
return eventTypeAST
|
|
288
288
|
.map(property => buildEventSchema(types, property, parser))
|
|
289
289
|
.filter(Boolean);
|
|
@@ -27,7 +27,7 @@ function isEvent(typeAnnotation: $FlowFixMe, parser: Parser): boolean {
|
|
|
27
27
|
type PropsAST = Object;
|
|
28
28
|
|
|
29
29
|
function categorizeProps(
|
|
30
|
-
typeDefinition:
|
|
30
|
+
typeDefinition: ReadonlyArray<PropsAST>,
|
|
31
31
|
types: TypeDeclarationMap,
|
|
32
32
|
events: Array<PropsAST>,
|
|
33
33
|
parser: Parser,
|
|
@@ -57,9 +57,9 @@ function translateObjectTypeAnnotation(
|
|
|
57
57
|
*/
|
|
58
58
|
typeScriptTypeAnnotation: $FlowFixMe,
|
|
59
59
|
nullable: boolean,
|
|
60
|
-
objectMembers:
|
|
60
|
+
objectMembers: ReadonlyArray<$FlowFixMe>,
|
|
61
61
|
typeResolutionStatus: TypeResolutionStatus,
|
|
62
|
-
baseTypes:
|
|
62
|
+
baseTypes: ReadonlyArray<string>,
|
|
63
63
|
types: TypeDeclarationMap,
|
|
64
64
|
aliasMap: {...NativeModuleAliasMap},
|
|
65
65
|
enumMap: {...NativeModuleEnumMap},
|
|
@@ -157,7 +157,7 @@ class TypeScriptParser implements Parser {
|
|
|
157
157
|
|
|
158
158
|
getFunctionTypeAnnotationParameters(
|
|
159
159
|
functionTypeAnnotation: $FlowFixMe,
|
|
160
|
-
):
|
|
160
|
+
): ReadonlyArray<$FlowFixMe> {
|
|
161
161
|
return functionTypeAnnotation.parameters;
|
|
162
162
|
}
|
|
163
163
|
|
|
@@ -248,7 +248,7 @@ class TypeScriptParser implements Parser {
|
|
|
248
248
|
|
|
249
249
|
parseEnumMembers(
|
|
250
250
|
typeAnnotation: $FlowFixMe,
|
|
251
|
-
):
|
|
251
|
+
): ReadonlyArray<NativeModuleEnumMember> {
|
|
252
252
|
return typeAnnotation.members.map(member => {
|
|
253
253
|
const value =
|
|
254
254
|
member.initializer?.operator === '-'
|
|
@@ -385,7 +385,7 @@ class TypeScriptParser implements Parser {
|
|
|
385
385
|
return annotatedElement.typeAnnotation.members;
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
-
bodyProperties(typeAlias: TypeDeclarationMap):
|
|
388
|
+
bodyProperties(typeAlias: TypeDeclarationMap): ReadonlyArray<$FlowFixMe> {
|
|
389
389
|
return typeAlias.body.body;
|
|
390
390
|
}
|
|
391
391
|
|
|
@@ -516,11 +516,11 @@ class TypeScriptParser implements Parser {
|
|
|
516
516
|
}
|
|
517
517
|
|
|
518
518
|
getProps(
|
|
519
|
-
typeDefinition:
|
|
519
|
+
typeDefinition: ReadonlyArray<PropAST>,
|
|
520
520
|
types: TypeDeclarationMap,
|
|
521
521
|
): {
|
|
522
|
-
props:
|
|
523
|
-
extendsProps:
|
|
522
|
+
props: ReadonlyArray<NamedShape<PropTypeAnnotation>>,
|
|
523
|
+
extendsProps: ReadonlyArray<ExtendsPropsShape>,
|
|
524
524
|
} {
|
|
525
525
|
const extendsProps: Array<ExtendsPropsShape> = [];
|
|
526
526
|
const componentPropAsts: Array<PropAST> = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/codegen",
|
|
3
|
-
"version": "0.85.0-nightly-
|
|
3
|
+
"version": "0.85.0-nightly-20260115-caa1fb6a0",
|
|
4
4
|
"description": "Code generation tools for React Native",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"bugs": "https://github.com/facebook/react-native/issues",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": "
|
|
21
|
+
"node": "^20.19.4 || ^22.13.0 || ^24.3.0 || >= 25.0.0"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "yarn clean && node scripts/build.js --verbose",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/core": "^7.25.2",
|
|
33
33
|
"@babel/parser": "^7.25.3",
|
|
34
|
-
"hermes-parser": "0.
|
|
34
|
+
"hermes-parser": "0.33.3",
|
|
35
35
|
"invariant": "^2.2.4",
|
|
36
36
|
"nullthrows": "^1.1.1",
|
|
37
37
|
"tinyglobby": "^0.2.15",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/plugin-transform-nullish-coalescing-operator": "^7.24.7",
|
|
46
46
|
"@babel/plugin-transform-optional-chaining": "^7.24.8",
|
|
47
47
|
"@babel/preset-env": "^7.25.3",
|
|
48
|
-
"hermes-estree": "0.
|
|
48
|
+
"hermes-estree": "0.33.3",
|
|
49
49
|
"micromatch": "^4.0.4",
|
|
50
50
|
"prettier": "3.6.2",
|
|
51
51
|
"rimraf": "^3.0.2"
|