@react-native/codegen 0.76.0-nightly-20240829-20e3f4518 → 0.76.0-nightly-20240830-435124765
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 +53 -49
- package/lib/CodegenSchema.js.flow +7 -3
- package/lib/generators/modules/GenerateModuleH.js.flow +1 -1
- package/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js +4 -1
- package/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js.flow +4 -1
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js +1 -1
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow +1 -1
- package/lib/generators/modules/__test_fixtures__/fixtures.js +6 -0
- package/lib/generators/modules/__test_fixtures__/fixtures.js.flow +6 -0
- package/lib/parsers/parsers-primitives.js +3 -0
- package/lib/parsers/parsers-primitives.js.flow +3 -0
- package/package.json +1 -1
package/lib/CodegenSchema.d.ts
CHANGED
|
@@ -110,8 +110,8 @@ export interface ExtendsPropsShape {
|
|
|
110
110
|
export interface EventTypeShape {
|
|
111
111
|
readonly name: string;
|
|
112
112
|
readonly bubblingType:
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
| 'direct'
|
|
114
|
+
| 'bubble';
|
|
115
115
|
readonly optional: boolean;
|
|
116
116
|
readonly paperTopLevelNameDeprecated?: string | undefined;
|
|
117
117
|
readonly typeAnnotation: {
|
|
@@ -137,55 +137,55 @@ export type EventTypeAnnotation =
|
|
|
137
137
|
export type ArrayTypeAnnotation = {
|
|
138
138
|
readonly type: 'ArrayTypeAnnotation';
|
|
139
139
|
readonly elementType:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
140
|
+
| BooleanTypeAnnotation
|
|
141
|
+
| StringTypeAnnotation
|
|
142
|
+
| DoubleTypeAnnotation
|
|
143
|
+
| FloatTypeAnnotation
|
|
144
|
+
| Int32TypeAnnotation
|
|
145
|
+
| {
|
|
146
|
+
readonly type: 'StringEnumTypeAnnotation';
|
|
147
|
+
readonly default: string;
|
|
148
|
+
readonly options: readonly string[];
|
|
149
|
+
}
|
|
150
|
+
| ObjectTypeAnnotation<PropTypeAnnotation>
|
|
151
|
+
| ReservedPropTypeAnnotation
|
|
152
|
+
| {
|
|
153
|
+
readonly type: 'ArrayTypeAnnotation';
|
|
154
|
+
readonly elementType: ObjectTypeAnnotation<PropTypeAnnotation>;
|
|
155
|
+
};
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
export type PropTypeAnnotation =
|
|
159
159
|
| {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
readonly type: 'BooleanTypeAnnotation';
|
|
161
|
+
readonly default: boolean | null;
|
|
162
|
+
}
|
|
163
163
|
| {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
readonly type: 'StringTypeAnnotation';
|
|
165
|
+
readonly default: string | null;
|
|
166
|
+
}
|
|
167
167
|
| {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
readonly type: 'DoubleTypeAnnotation';
|
|
169
|
+
readonly default: number;
|
|
170
|
+
}
|
|
171
171
|
| {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
readonly type: 'FloatTypeAnnotation';
|
|
173
|
+
readonly default: number | null;
|
|
174
|
+
}
|
|
175
175
|
| {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
readonly type: 'Int32TypeAnnotation';
|
|
177
|
+
readonly default: number;
|
|
178
|
+
}
|
|
179
179
|
| {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
readonly type: 'StringEnumTypeAnnotation';
|
|
181
|
+
readonly default: string;
|
|
182
|
+
readonly options: readonly string[];
|
|
183
|
+
}
|
|
184
184
|
| {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
readonly type: 'Int32EnumTypeAnnotation';
|
|
186
|
+
readonly default: number;
|
|
187
|
+
readonly options: readonly number[];
|
|
188
|
+
}
|
|
189
189
|
| ReservedPropTypeAnnotation
|
|
190
190
|
| ObjectTypeAnnotation<PropTypeAnnotation>
|
|
191
191
|
| ArrayTypeAnnotation
|
|
@@ -194,12 +194,12 @@ export type PropTypeAnnotation =
|
|
|
194
194
|
export interface ReservedPropTypeAnnotation {
|
|
195
195
|
readonly type: 'ReservedPropTypeAnnotation';
|
|
196
196
|
readonly name:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
| 'ColorPrimitive'
|
|
198
|
+
| 'ImageSourcePrimitive'
|
|
199
|
+
| 'PointPrimitive'
|
|
200
|
+
| 'EdgeInsetsPrimitive'
|
|
201
|
+
| 'ImageRequestPrimitive'
|
|
202
|
+
| 'DimensionPrimitive';
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
export type CommandTypeAnnotation = FunctionTypeAnnotation<
|
|
@@ -279,7 +279,11 @@ export interface NativeModuleArrayTypeAnnotation<T extends Nullable<NativeModule
|
|
|
279
279
|
* TODO(T72031674): Migrate all our NativeModule specs to not use
|
|
280
280
|
* invalid Array ElementTypes. Then, make the elementType required.
|
|
281
281
|
*/
|
|
282
|
-
readonly elementType
|
|
282
|
+
readonly elementType: T | UnsafeAnyTypeAnnotation;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface UnsafeAnyTypeAnnotation {
|
|
286
|
+
readonly type: 'AnyTypeAnnotation',
|
|
283
287
|
}
|
|
284
288
|
|
|
285
289
|
export interface NativeModuleStringTypeAnnotation {
|
|
@@ -375,7 +379,7 @@ export type NativeModuleEventEmitterTypeAnnotation =
|
|
|
375
379
|
| NativeModuleEventEmitterBaseTypeAnnotation
|
|
376
380
|
| {
|
|
377
381
|
readonly type: 'ArrayTypeAnnotation';
|
|
378
|
-
readonly elementType: NativeModuleEventEmitterBaseTypeAnnotation
|
|
382
|
+
readonly elementType: NativeModuleEventEmitterBaseTypeAnnotation;
|
|
379
383
|
};
|
|
380
384
|
|
|
381
385
|
export type NativeModuleBaseTypeAnnotation =
|
|
@@ -283,9 +283,13 @@ export type NativeModuleArrayTypeAnnotation<
|
|
|
283
283
|
* TODO(T72031674): Migrate all our NativeModule specs to not use
|
|
284
284
|
* invalid Array ElementTypes. Then, make the elementType required.
|
|
285
285
|
*/
|
|
286
|
-
elementType
|
|
286
|
+
elementType: T | UnsafeAnyTypeAnnotation,
|
|
287
287
|
}>;
|
|
288
288
|
|
|
289
|
+
export type UnsafeAnyTypeAnnotation = {
|
|
290
|
+
type: 'AnyTypeAnnotation',
|
|
291
|
+
};
|
|
292
|
+
|
|
289
293
|
export type NativeModuleNumberTypeAnnotation = $ReadOnly<{
|
|
290
294
|
type: 'NumberTypeAnnotation',
|
|
291
295
|
}>;
|
|
@@ -293,7 +297,7 @@ export type NativeModuleNumberTypeAnnotation = $ReadOnly<{
|
|
|
293
297
|
export type NativeModuleEnumMembers = $ReadOnlyArray<
|
|
294
298
|
$ReadOnly<{
|
|
295
299
|
name: string,
|
|
296
|
-
value: string,
|
|
300
|
+
value: string | number,
|
|
297
301
|
}>,
|
|
298
302
|
>;
|
|
299
303
|
|
|
@@ -361,7 +365,7 @@ export type NativeModuleEventEmitterTypeAnnotation =
|
|
|
361
365
|
| NativeModuleEventEmitterBaseTypeAnnotation
|
|
362
366
|
| {
|
|
363
367
|
type: 'ArrayTypeAnnotation',
|
|
364
|
-
elementType: NativeModuleEventEmitterBaseTypeAnnotation
|
|
368
|
+
elementType: NativeModuleEventEmitterBaseTypeAnnotation,
|
|
365
369
|
};
|
|
366
370
|
|
|
367
371
|
export type NativeModuleBaseTypeAnnotation =
|
|
@@ -407,7 +407,7 @@ function generateEnum(
|
|
|
407
407
|
const nativeEnumMemberType: NativeEnumMemberValueType =
|
|
408
408
|
memberType === 'StringTypeAnnotation' ? 'std::string' : 'int32_t';
|
|
409
409
|
|
|
410
|
-
const getMemberValueAppearance = (value: string) =>
|
|
410
|
+
const getMemberValueAppearance = (value: string | number) =>
|
|
411
411
|
memberType === 'StringTypeAnnotation' ? `"${value}"` : `${value}`;
|
|
412
412
|
|
|
413
413
|
const fromCases =
|
|
@@ -168,9 +168,12 @@ class StructCollector {
|
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
170
|
case 'ArrayTypeAnnotation': {
|
|
171
|
-
if (typeAnnotation.elementType
|
|
171
|
+
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
|
|
172
172
|
return wrapNullable(nullable, {
|
|
173
173
|
type: 'ArrayTypeAnnotation',
|
|
174
|
+
elementType: {
|
|
175
|
+
type: 'AnyTypeAnnotation',
|
|
176
|
+
},
|
|
174
177
|
});
|
|
175
178
|
}
|
|
176
179
|
return wrapNullable(nullable, {
|
|
@@ -93,9 +93,12 @@ class StructCollector {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
case 'ArrayTypeAnnotation': {
|
|
96
|
-
if (typeAnnotation.elementType
|
|
96
|
+
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
|
|
97
97
|
return wrapNullable(nullable, {
|
|
98
98
|
type: 'ArrayTypeAnnotation',
|
|
99
|
+
elementType: {
|
|
100
|
+
type: 'AnyTypeAnnotation',
|
|
101
|
+
},
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
104
|
|
|
@@ -177,7 +177,7 @@ function toObjCType(
|
|
|
177
177
|
case 'GenericObjectTypeAnnotation':
|
|
178
178
|
return wrapObjCOptional('id<NSObject>', isRequired);
|
|
179
179
|
case 'ArrayTypeAnnotation':
|
|
180
|
-
if (typeAnnotation.elementType
|
|
180
|
+
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
|
|
181
181
|
return wrapObjCOptional('id<NSObject>', isRequired);
|
|
182
182
|
}
|
|
183
183
|
return wrapCxxOptional(
|
|
@@ -256,7 +256,7 @@ function toObjCValue(
|
|
|
256
256
|
return value;
|
|
257
257
|
case 'ArrayTypeAnnotation':
|
|
258
258
|
const elementType = typeAnnotation.elementType;
|
|
259
|
-
if (elementType
|
|
259
|
+
if (elementType.type === 'AnyTypeAnnotation') {
|
|
260
260
|
return value;
|
|
261
261
|
}
|
|
262
262
|
const localVarName = `el${'_'.repeat(depth + 1)}`;
|
|
@@ -118,7 +118,7 @@ function toObjCType(
|
|
|
118
118
|
case 'GenericObjectTypeAnnotation':
|
|
119
119
|
return wrapObjCOptional('id<NSObject>', isRequired);
|
|
120
120
|
case 'ArrayTypeAnnotation':
|
|
121
|
-
if (typeAnnotation.elementType
|
|
121
|
+
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
|
|
122
122
|
return wrapObjCOptional('id<NSObject>', isRequired);
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -198,7 +198,7 @@ function toObjCValue(
|
|
|
198
198
|
return value;
|
|
199
199
|
case 'ArrayTypeAnnotation':
|
|
200
200
|
const {elementType} = typeAnnotation;
|
|
201
|
-
if (elementType
|
|
201
|
+
if (elementType.type === 'AnyTypeAnnotation') {
|
|
202
202
|
return value;
|
|
203
203
|
}
|
|
204
204
|
|
|
@@ -165,7 +165,7 @@ function toObjCType(
|
|
|
165
165
|
case 'GenericObjectTypeAnnotation':
|
|
166
166
|
return wrapObjCOptional('id<NSObject>', isRequired);
|
|
167
167
|
case 'ArrayTypeAnnotation':
|
|
168
|
-
if (typeAnnotation.elementType
|
|
168
|
+
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
|
|
169
169
|
return wrapObjCOptional('id<NSObject>', isRequired);
|
|
170
170
|
}
|
|
171
171
|
return wrapCxxOptional(
|
|
@@ -245,7 +245,7 @@ function toObjCValue(
|
|
|
245
245
|
return value;
|
|
246
246
|
case 'ArrayTypeAnnotation':
|
|
247
247
|
const elementType = typeAnnotation.elementType;
|
|
248
|
-
if (elementType
|
|
248
|
+
if (elementType.type === 'AnyTypeAnnotation') {
|
|
249
249
|
return value;
|
|
250
250
|
}
|
|
251
251
|
const localVarName = `itemValue_${depth}`;
|
|
@@ -109,7 +109,7 @@ function toObjCType(
|
|
|
109
109
|
case 'GenericObjectTypeAnnotation':
|
|
110
110
|
return wrapObjCOptional('id<NSObject>', isRequired);
|
|
111
111
|
case 'ArrayTypeAnnotation':
|
|
112
|
-
if (typeAnnotation.elementType
|
|
112
|
+
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
|
|
113
113
|
return wrapObjCOptional('id<NSObject>', isRequired);
|
|
114
114
|
}
|
|
115
115
|
return wrapCxxOptional(
|
|
@@ -188,7 +188,7 @@ function toObjCValue(
|
|
|
188
188
|
return value;
|
|
189
189
|
case 'ArrayTypeAnnotation':
|
|
190
190
|
const {elementType} = typeAnnotation;
|
|
191
|
-
if (elementType
|
|
191
|
+
if (elementType.type === 'AnyTypeAnnotation') {
|
|
192
192
|
return value;
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -339,7 +339,7 @@ function getReturnObjCType(methodName, nullableTypeAnnotation) {
|
|
|
339
339
|
case 'TypeAliasTypeAnnotation':
|
|
340
340
|
return wrapOptional('NSDictionary *', isRequired);
|
|
341
341
|
case 'ArrayTypeAnnotation':
|
|
342
|
-
if (typeAnnotation.elementType
|
|
342
|
+
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
|
|
343
343
|
return wrapOptional('NSArray<id<NSObject>> *', isRequired);
|
|
344
344
|
}
|
|
345
345
|
return wrapOptional(
|
|
@@ -305,7 +305,7 @@ function getReturnObjCType(
|
|
|
305
305
|
case 'TypeAliasTypeAnnotation':
|
|
306
306
|
return wrapOptional('NSDictionary *', isRequired);
|
|
307
307
|
case 'ArrayTypeAnnotation':
|
|
308
|
-
if (typeAnnotation.elementType
|
|
308
|
+
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
|
|
309
309
|
return wrapOptional('NSArray<id<NSObject>> *', isRequired);
|
|
310
310
|
}
|
|
311
311
|
|
|
@@ -940,6 +940,9 @@ const COMPLEX_OBJECTS = {
|
|
|
940
940
|
type: 'NullableTypeAnnotation',
|
|
941
941
|
typeAnnotation: {
|
|
942
942
|
type: 'ArrayTypeAnnotation',
|
|
943
|
+
elementType: {
|
|
944
|
+
type: 'AnyTypeAnnotation',
|
|
945
|
+
},
|
|
943
946
|
},
|
|
944
947
|
},
|
|
945
948
|
params: [],
|
|
@@ -1959,6 +1962,9 @@ const CXX_ONLY_NATIVE_MODULES = {
|
|
|
1959
1962
|
type: 'FunctionTypeAnnotation',
|
|
1960
1963
|
returnTypeAnnotation: {
|
|
1961
1964
|
type: 'ArrayTypeAnnotation',
|
|
1965
|
+
elementType: {
|
|
1966
|
+
type: 'AnyTypeAnnotation',
|
|
1967
|
+
},
|
|
1962
1968
|
},
|
|
1963
1969
|
params: [
|
|
1964
1970
|
{
|
|
@@ -947,6 +947,9 @@ const COMPLEX_OBJECTS: SchemaType = {
|
|
|
947
947
|
type: 'NullableTypeAnnotation',
|
|
948
948
|
typeAnnotation: {
|
|
949
949
|
type: 'ArrayTypeAnnotation',
|
|
950
|
+
elementType: {
|
|
951
|
+
type: 'AnyTypeAnnotation',
|
|
952
|
+
},
|
|
950
953
|
},
|
|
951
954
|
},
|
|
952
955
|
params: [],
|
|
@@ -1969,6 +1972,9 @@ const CXX_ONLY_NATIVE_MODULES: SchemaType = {
|
|
|
1969
1972
|
type: 'FunctionTypeAnnotation',
|
|
1970
1973
|
returnTypeAnnotation: {
|
|
1971
1974
|
type: 'ArrayTypeAnnotation',
|
|
1975
|
+
elementType: {
|
|
1976
|
+
type: 'AnyTypeAnnotation',
|
|
1977
|
+
},
|
|
1972
1978
|
},
|
|
1973
1979
|
params: [
|
|
1974
1980
|
{
|