@react-native/codegen 0.75.0-nightly-20240527-c207708c4 → 0.75.0-nightly-20240529-5fbebb485

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.
@@ -15,6 +15,9 @@ export interface SchemaType {
15
15
  };
16
16
  }
17
17
 
18
+ /**
19
+ * Component Type Annotations
20
+ */
18
21
  export interface DoubleTypeAnnotation {
19
22
  readonly type: 'DoubleTypeAnnotation';
20
23
  }
@@ -47,6 +50,7 @@ export interface VoidTypeAnnotation {
47
50
  export interface ObjectTypeAnnotation<T> {
48
51
  readonly type: 'ObjectTypeAnnotation';
49
52
  readonly properties: readonly NamedShape<T>[];
53
+ // metadata for objects that generated from interfaces
50
54
  readonly baseTypes?: readonly string[] | undefined;
51
55
  }
52
56
 
@@ -83,8 +87,13 @@ export interface ComponentShape extends OptionsShape {
83
87
 
84
88
  export interface OptionsShape {
85
89
  readonly interfaceOnly?: boolean | undefined;
90
+ // Use for components with no current paper rename in progress
91
+ // Does not check for new name
86
92
  readonly paperComponentName?: string | undefined;
93
+ // Use for components that are not used on other platforms.
87
94
  readonly excludedPlatforms?: readonly PlatformType[] | undefined;
95
+ // Use for components currently being renamed in paper
96
+ // Will use new name if it is available and fallback to this name
88
97
  readonly paperComponentNameDeprecated?: string | undefined;
89
98
  }
90
99
 
@@ -112,6 +121,7 @@ export type EventTypeAnnotation =
112
121
  | DoubleTypeAnnotation
113
122
  | FloatTypeAnnotation
114
123
  | Int32TypeAnnotation
124
+ | MixedTypeAnnotation
115
125
  | StringEnumTypeAnnotation
116
126
  | ObjectTypeAnnotation<EventTypeAnnotation>
117
127
  | {
@@ -119,18 +129,35 @@ export type EventTypeAnnotation =
119
129
  readonly elementType: EventTypeAnnotation
120
130
  };
121
131
 
132
+ export type ArrayTypeAnnotation = {
133
+ readonly type: 'ArrayTypeAnnotation';
134
+ readonly elementType:
135
+ | BooleanTypeAnnotation
136
+ | StringTypeAnnotation
137
+ | DoubleTypeAnnotation
138
+ | FloatTypeAnnotation
139
+ | Int32TypeAnnotation
140
+ | {
141
+ readonly type: 'StringEnumTypeAnnotation';
142
+ readonly default: string;
143
+ readonly options: readonly string[];
144
+ }
145
+ | ObjectTypeAnnotation<PropTypeAnnotation>
146
+ | ReservedPropTypeAnnotation
147
+ | {
148
+ readonly type: 'ArrayTypeAnnotation';
149
+ readonly elementType: ObjectTypeAnnotation<PropTypeAnnotation>;
150
+ };
151
+ }
152
+
122
153
  export type PropTypeAnnotation =
123
154
  | {
124
155
  readonly type: 'BooleanTypeAnnotation';
125
- readonly default:
126
- | boolean
127
- | null;
156
+ readonly default: boolean | null;
128
157
  }
129
158
  | {
130
159
  readonly type: 'StringTypeAnnotation';
131
- readonly default:
132
- | string
133
- | null;
160
+ readonly default: string | null;
134
161
  }
135
162
  | {
136
163
  readonly type: 'DoubleTypeAnnotation';
@@ -138,9 +165,7 @@ export type PropTypeAnnotation =
138
165
  }
139
166
  | {
140
167
  readonly type: 'FloatTypeAnnotation';
141
- readonly default:
142
- | number
143
- | null;
168
+ readonly default: number | null;
144
169
  }
145
170
  | {
146
171
  readonly type: 'Int32TypeAnnotation';
@@ -158,26 +183,7 @@ export type PropTypeAnnotation =
158
183
  }
159
184
  | ReservedPropTypeAnnotation
160
185
  | ObjectTypeAnnotation<PropTypeAnnotation>
161
- | {
162
- readonly type: 'ArrayTypeAnnotation';
163
- readonly elementType:
164
- | BooleanTypeAnnotation
165
- | StringTypeAnnotation
166
- | DoubleTypeAnnotation
167
- | FloatTypeAnnotation
168
- | Int32TypeAnnotation
169
- | {
170
- readonly type: 'StringEnumTypeAnnotation';
171
- readonly default: string;
172
- readonly options: readonly string[];
173
- }
174
- | ObjectTypeAnnotation<PropTypeAnnotation>
175
- | ReservedPropTypeAnnotation
176
- | {
177
- readonly type: 'ArrayTypeAnnotation';
178
- readonly elementType: ObjectTypeAnnotation<PropTypeAnnotation>;
179
- };
180
- }
186
+ | ArrayTypeAnnotation
181
187
  | MixedTypeAnnotation;
182
188
 
183
189
  export interface ReservedPropTypeAnnotation {
@@ -191,7 +197,10 @@ export interface ReservedPropTypeAnnotation {
191
197
  | 'DimensionPrimitive';
192
198
  }
193
199
 
194
- export type CommandTypeAnnotation = FunctionTypeAnnotation<CommandParamTypeAnnotation, VoidTypeAnnotation>;
200
+ export type CommandTypeAnnotation = FunctionTypeAnnotation<
201
+ CommandParamTypeAnnotation,
202
+ VoidTypeAnnotation
203
+ >;
195
204
 
196
205
  export type CommandParamTypeAnnotation =
197
206
  | ReservedTypeAnnotation
@@ -200,21 +209,16 @@ export type CommandParamTypeAnnotation =
200
209
  | DoubleTypeAnnotation
201
210
  | FloatTypeAnnotation
202
211
  | StringTypeAnnotation
203
- | {
204
- readonly type: 'ArrayTypeAnnotation';
205
- readonly elementType:
206
- | Int32TypeAnnotation
207
- | DoubleTypeAnnotation
208
- | FloatTypeAnnotation
209
- | BooleanTypeAnnotation
210
- | StringTypeAnnotation
211
- };
212
+ | ArrayTypeAnnotation;
212
213
 
213
214
  export interface ReservedTypeAnnotation {
214
215
  readonly type: 'ReservedTypeAnnotation';
215
- readonly name: 'RootTag';
216
+ readonly name: 'RootTag'; // Union with more custom types.
216
217
  }
217
218
 
219
+ /**
220
+ * NativeModule Types
221
+ */
218
222
  export type Nullable<T extends NativeModuleTypeAnnotation> =
219
223
  | NullableTypeAnnotation<T>
220
224
  | T;
@@ -230,6 +234,9 @@ export interface NativeModuleSchema {
230
234
  readonly enumMap: NativeModuleEnumMap;
231
235
  readonly spec: NativeModuleSpec;
232
236
  readonly moduleName: string;
237
+ // Use for modules that are not used on other platforms.
238
+ // TODO: It's clearer to define `restrictedToPlatforms` instead, but
239
+ // `excludedPlatforms` is used here to be consistent with ComponentSchema.
233
240
  readonly excludedPlatforms?: readonly PlatformType[] | undefined;
234
241
  }
235
242
 
@@ -237,7 +244,9 @@ export interface NativeModuleSpec {
237
244
  readonly properties: readonly NativeModulePropertyShape[];
238
245
  }
239
246
 
240
- export type NativeModulePropertyShape = NamedShape<Nullable<NativeModuleFunctionTypeAnnotation>>;
247
+ export type NativeModulePropertyShape = NamedShape<
248
+ Nullable<NativeModuleFunctionTypeAnnotation>
249
+ >;
241
250
 
242
251
  export interface NativeModuleEnumMap {
243
252
  readonly [enumName: string]: NativeModuleEnumDeclarationWithMembers;
@@ -247,12 +256,21 @@ export interface NativeModuleAliasMap {
247
256
  readonly [aliasName: string]: NativeModuleObjectTypeAnnotation;
248
257
  }
249
258
 
250
- export type NativeModuleFunctionTypeAnnotation = FunctionTypeAnnotation<Nullable<NativeModuleParamTypeAnnotation>, Nullable<NativeModuleReturnTypeAnnotation>>;
259
+ export type NativeModuleFunctionTypeAnnotation = FunctionTypeAnnotation<
260
+ Nullable<NativeModuleParamTypeAnnotation>,
261
+ Nullable<NativeModuleReturnTypeAnnotation>
262
+ >;
251
263
 
252
- export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation<Nullable<NativeModuleBaseTypeAnnotation>>;
264
+ export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation<
265
+ Nullable<NativeModuleBaseTypeAnnotation>
266
+ >;
253
267
 
254
268
  export interface NativeModuleArrayTypeAnnotation<T extends Nullable<NativeModuleBaseTypeAnnotation>> {
255
269
  readonly type: 'ArrayTypeAnnotation';
270
+ /**
271
+ * TODO(T72031674): Migrate all our NativeModule specs to not use
272
+ * invalid Array ElementTypes. Then, make the elementType required.
273
+ */
256
274
  readonly elementType?: T | undefined;
257
275
  }
258
276
 
@@ -304,6 +322,9 @@ export interface NativeModuleEnumDeclarationWithMembers {
304
322
 
305
323
  export interface NativeModuleGenericObjectTypeAnnotation {
306
324
  readonly type: 'GenericObjectTypeAnnotation';
325
+ // a dictionary type is codegen as "Object"
326
+ // but we know all its members are in the same type
327
+ // when it happens, the following field is non-null
307
328
  readonly dictionaryValueType?: Nullable<NativeModuleTypeAnnotation> | undefined;
308
329
  }
309
330
 
@@ -360,9 +381,9 @@ export type NativeModuleTypeAnnotation =
360
381
  | NativeModuleParamOnlyTypeAnnotation
361
382
  | NativeModuleReturnOnlyTypeAnnotation;
362
383
 
363
- export type NativeModuleParamOnlyTypeAnnotation = NativeModuleFunctionTypeAnnotation;
384
+ type NativeModuleParamOnlyTypeAnnotation = NativeModuleFunctionTypeAnnotation;
364
385
 
365
- export type NativeModuleReturnOnlyTypeAnnotation =
386
+ type NativeModuleReturnOnlyTypeAnnotation =
366
387
  | NativeModuleFunctionTypeAnnotation
367
388
  | NativeModulePromiseTypeAnnotation
368
389
  | VoidTypeAnnotation;
@@ -53,7 +53,6 @@ export type VoidTypeAnnotation = $ReadOnly<{
53
53
  export type ObjectTypeAnnotation<+T> = $ReadOnly<{
54
54
  type: 'ObjectTypeAnnotation',
55
55
  properties: $ReadOnlyArray<NamedShape<T>>,
56
-
57
56
  // metadata for objects that generated from interfaces
58
57
  baseTypes?: $ReadOnlyArray<string>,
59
58
  }>;
@@ -91,14 +90,11 @@ export type ComponentShape = $ReadOnly<{
91
90
 
92
91
  export type OptionsShape = $ReadOnly<{
93
92
  interfaceOnly?: boolean,
94
-
95
93
  // Use for components with no current paper rename in progress
96
94
  // Does not check for new name
97
95
  paperComponentName?: string,
98
-
99
96
  // Use for components that are not used on other platforms.
100
97
  excludedPlatforms?: $ReadOnlyArray<PlatformType>,
101
-
102
98
  // Use for components currently being renamed in paper
103
99
  // Will use new name if it is available and fallback to this name
104
100
  paperComponentNameDeprecated?: string,
@@ -331,7 +327,6 @@ export type NativeModuleEnumDeclarationWithMembers = {
331
327
 
332
328
  export type NativeModuleGenericObjectTypeAnnotation = $ReadOnly<{
333
329
  type: 'GenericObjectTypeAnnotation',
334
-
335
330
  // a dictionary type is codegen as "Object"
336
331
  // but we know all its members are in the same type
337
332
  // when it happens, the following field is non-null
@@ -392,6 +387,7 @@ export type NativeModuleTypeAnnotation =
392
387
  | NativeModuleReturnOnlyTypeAnnotation;
393
388
 
394
389
  type NativeModuleParamOnlyTypeAnnotation = NativeModuleFunctionTypeAnnotation;
390
+
395
391
  type NativeModuleReturnOnlyTypeAnnotation =
396
392
  | NativeModulePromiseTypeAnnotation
397
393
  | VoidTypeAnnotation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/codegen",
3
- "version": "0.75.0-nightly-20240527-c207708c4",
3
+ "version": "0.75.0-nightly-20240529-5fbebb485",
4
4
  "description": "Code generation tools for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {