Skip to content

Commit 192285b

Browse files
committed
[react-native-codegen] prebuild codegen lib
to let other people building expo go easier. the `lib` outputs are from `yarn` in packages/react-native-codegen.
1 parent a4585d8 commit 192285b

File tree

164 files changed

+48005
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+48005
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
* @format
9+
*/
10+
'use strict';
Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,332 @@
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+
export type PlatformType = 'iOS' | 'android';
14+
15+
export type SchemaType = $ReadOnly<{
16+
modules: $ReadOnly<{
17+
[hasteModuleName: string]: ComponentSchema | NativeModuleSchema,
18+
}>,
19+
}>;
20+
21+
/**
22+
* Component Type Annotations
23+
*/
24+
export type DoubleTypeAnnotation = $ReadOnly<{
25+
type: 'DoubleTypeAnnotation',
26+
}>;
27+
28+
export type FloatTypeAnnotation = $ReadOnly<{
29+
type: 'FloatTypeAnnotation',
30+
}>;
31+
32+
export type BooleanTypeAnnotation = $ReadOnly<{
33+
type: 'BooleanTypeAnnotation',
34+
}>;
35+
36+
export type Int32TypeAnnotation = $ReadOnly<{
37+
type: 'Int32TypeAnnotation',
38+
}>;
39+
40+
export type StringTypeAnnotation = $ReadOnly<{
41+
type: 'StringTypeAnnotation',
42+
}>;
43+
44+
export type StringEnumTypeAnnotation = $ReadOnly<{
45+
type: 'StringEnumTypeAnnotation',
46+
options: $ReadOnlyArray<string>,
47+
}>;
48+
49+
export type VoidTypeAnnotation = $ReadOnly<{
50+
type: 'VoidTypeAnnotation',
51+
}>;
52+
53+
export type ObjectTypeAnnotation<+T> = $ReadOnly<{
54+
type: 'ObjectTypeAnnotation',
55+
properties: $ReadOnlyArray<NamedShape<T>>,
56+
}>;
57+
58+
type FunctionTypeAnnotation<+P, +R> = $ReadOnly<{
59+
type: 'FunctionTypeAnnotation',
60+
params: $ReadOnlyArray<NamedShape<P>>,
61+
returnTypeAnnotation: R,
62+
}>;
63+
64+
export type NamedShape<+T> = $ReadOnly<{
65+
name: string,
66+
optional: boolean,
67+
typeAnnotation: T,
68+
}>;
69+
70+
export type ComponentSchema = $ReadOnly<{
71+
type: 'Component',
72+
components: $ReadOnly<{
73+
[componentName: string]: ComponentShape,
74+
}>,
75+
}>;
76+
77+
export type ComponentShape = $ReadOnly<{
78+
...OptionsShape,
79+
extendsProps: $ReadOnlyArray<ExtendsPropsShape>,
80+
events: $ReadOnlyArray<EventTypeShape>,
81+
props: $ReadOnlyArray<NamedShape<PropTypeAnnotation>>,
82+
commands: $ReadOnlyArray<NamedShape<CommandTypeAnnotation>>,
83+
}>;
84+
85+
export type OptionsShape = $ReadOnly<{
86+
interfaceOnly?: boolean,
87+
88+
// Use for components with no current paper rename in progress
89+
// Does not check for new name
90+
paperComponentName?: string,
91+
92+
// Use for components that are not used on other platforms.
93+
excludedPlatforms?: $ReadOnlyArray<PlatformType>,
94+
95+
// Use for components currently being renamed in paper
96+
// Will use new name if it is available and fallback to this name
97+
paperComponentNameDeprecated?: string,
98+
}>;
99+
100+
export type ExtendsPropsShape = $ReadOnly<{
101+
type: 'ReactNativeBuiltInType',
102+
knownTypeName: 'ReactNativeCoreViewProps',
103+
}>;
104+
105+
export type EventTypeShape = $ReadOnly<{
106+
name: string,
107+
bubblingType: 'direct' | 'bubble',
108+
optional: boolean,
109+
paperTopLevelNameDeprecated?: string,
110+
typeAnnotation: $ReadOnly<{
111+
type: 'EventTypeAnnotation',
112+
argument?: ObjectTypeAnnotation<EventTypeAnnotation>,
113+
}>,
114+
}>;
115+
116+
export type EventTypeAnnotation =
117+
| BooleanTypeAnnotation
118+
| StringTypeAnnotation
119+
| DoubleTypeAnnotation
120+
| FloatTypeAnnotation
121+
| Int32TypeAnnotation
122+
| StringEnumTypeAnnotation
123+
| ObjectTypeAnnotation<EventTypeAnnotation>;
124+
125+
export type PropTypeAnnotation =
126+
| $ReadOnly<{
127+
type: 'BooleanTypeAnnotation',
128+
default: boolean | null,
129+
}>
130+
| $ReadOnly<{
131+
type: 'StringTypeAnnotation',
132+
default: string | null,
133+
}>
134+
| $ReadOnly<{
135+
type: 'DoubleTypeAnnotation',
136+
default: number,
137+
}>
138+
| $ReadOnly<{
139+
type: 'FloatTypeAnnotation',
140+
default: number | null,
141+
}>
142+
| $ReadOnly<{
143+
type: 'Int32TypeAnnotation',
144+
default: number,
145+
}>
146+
| $ReadOnly<{
147+
type: 'StringEnumTypeAnnotation',
148+
default: string,
149+
options: $ReadOnlyArray<string>,
150+
}>
151+
| $ReadOnly<{
152+
type: 'Int32EnumTypeAnnotation',
153+
default: number,
154+
options: $ReadOnlyArray<number>,
155+
}>
156+
| ReservedPropTypeAnnotation
157+
| ObjectTypeAnnotation<PropTypeAnnotation>
158+
| $ReadOnly<{
159+
type: 'ArrayTypeAnnotation',
160+
elementType:
161+
| BooleanTypeAnnotation
162+
| StringTypeAnnotation
163+
| DoubleTypeAnnotation
164+
| FloatTypeAnnotation
165+
| Int32TypeAnnotation
166+
| $ReadOnly<{
167+
type: 'StringEnumTypeAnnotation',
168+
default: string,
169+
options: $ReadOnlyArray<string>,
170+
}>
171+
| ObjectTypeAnnotation<PropTypeAnnotation>
172+
| ReservedPropTypeAnnotation
173+
| $ReadOnly<{
174+
type: 'ArrayTypeAnnotation',
175+
elementType: ObjectTypeAnnotation<PropTypeAnnotation>,
176+
}>,
177+
}>;
178+
179+
export type ReservedPropTypeAnnotation = $ReadOnly<{
180+
type: 'ReservedPropTypeAnnotation',
181+
name:
182+
| 'ColorPrimitive'
183+
| 'ImageSourcePrimitive'
184+
| 'PointPrimitive'
185+
| 'EdgeInsetsPrimitive',
186+
}>;
187+
188+
export type CommandTypeAnnotation = FunctionTypeAnnotation<
189+
CommandParamTypeAnnotation,
190+
VoidTypeAnnotation,
191+
>;
192+
193+
export type CommandParamTypeAnnotation =
194+
| ReservedTypeAnnotation
195+
| BooleanTypeAnnotation
196+
| Int32TypeAnnotation
197+
| DoubleTypeAnnotation
198+
| FloatTypeAnnotation
199+
| StringTypeAnnotation;
200+
201+
export type ReservedTypeAnnotation = $ReadOnly<{
202+
type: 'ReservedTypeAnnotation',
203+
name: 'RootTag', // Union with more custom types.
204+
}>;
205+
206+
/**
207+
* NativeModule Types
208+
*/
209+
export type Nullable<+T: NativeModuleTypeAnnotation> =
210+
| NullableTypeAnnotation<T>
211+
| T;
212+
213+
export type NullableTypeAnnotation<+T: NativeModuleTypeAnnotation> = $ReadOnly<{
214+
type: 'NullableTypeAnnotation',
215+
typeAnnotation: T,
216+
}>;
217+
218+
export type NativeModuleSchema = $ReadOnly<{
219+
type: 'NativeModule',
220+
aliases: NativeModuleAliasMap,
221+
spec: NativeModuleSpec,
222+
moduleNames: $ReadOnlyArray<string>,
223+
// Use for modules that are not used on other platforms.
224+
// TODO: It's clearer to define `restrictedToPlatforms` instead, but
225+
// `excludedPlatforms` is used here to be consistent with ComponentSchema.
226+
excludedPlatforms?: $ReadOnlyArray<PlatformType>,
227+
}>;
228+
229+
type NativeModuleSpec = $ReadOnly<{
230+
properties: $ReadOnlyArray<NativeModulePropertyShape>,
231+
}>;
232+
233+
export type NativeModulePropertyShape = NamedShape<
234+
Nullable<NativeModuleFunctionTypeAnnotation>,
235+
>;
236+
237+
export type NativeModuleAliasMap = $ReadOnly<{
238+
[aliasName: string]: NativeModuleObjectTypeAnnotation,
239+
}>;
240+
241+
export type NativeModuleFunctionTypeAnnotation = FunctionTypeAnnotation<
242+
Nullable<NativeModuleParamTypeAnnotation>,
243+
Nullable<NativeModuleReturnTypeAnnotation>,
244+
>;
245+
246+
export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation<
247+
Nullable<NativeModuleBaseTypeAnnotation>,
248+
>;
249+
250+
export type NativeModuleArrayTypeAnnotation<
251+
+T: Nullable<NativeModuleBaseTypeAnnotation>,
252+
> = $ReadOnly<{
253+
type: 'ArrayTypeAnnotation',
254+
/**
255+
* TODO(T72031674): Migrate all our NativeModule specs to not use
256+
* invalid Array ElementTypes. Then, make the elementType required.
257+
*/
258+
elementType?: T,
259+
}>;
260+
261+
export type NativeModuleStringTypeAnnotation = $ReadOnly<{
262+
type: 'StringTypeAnnotation',
263+
}>;
264+
265+
export type NativeModuleNumberTypeAnnotation = $ReadOnly<{
266+
type: 'NumberTypeAnnotation',
267+
}>;
268+
269+
export type NativeModuleInt32TypeAnnotation = $ReadOnly<{
270+
type: 'Int32TypeAnnotation',
271+
}>;
272+
273+
export type NativeModuleDoubleTypeAnnotation = $ReadOnly<{
274+
type: 'DoubleTypeAnnotation',
275+
}>;
276+
277+
export type NativeModuleFloatTypeAnnotation = $ReadOnly<{
278+
type: 'FloatTypeAnnotation',
279+
}>;
280+
281+
export type NativeModuleBooleanTypeAnnotation = $ReadOnly<{
282+
type: 'BooleanTypeAnnotation',
283+
}>;
284+
285+
export type NativeModuleGenericObjectTypeAnnotation = $ReadOnly<{
286+
type: 'GenericObjectTypeAnnotation',
287+
}>;
288+
289+
export type NativeModuleTypeAliasTypeAnnotation = $ReadOnly<{
290+
type: 'TypeAliasTypeAnnotation',
291+
name: string,
292+
}>;
293+
294+
export type NativeModulePromiseTypeAnnotation = $ReadOnly<{
295+
type: 'PromiseTypeAnnotation',
296+
}>;
297+
298+
export type NativeModuleMixedTypeAnnotation = $ReadOnly<{
299+
type: 'MixedTypeAnnotation',
300+
}>;
301+
302+
export type NativeModuleBaseTypeAnnotation =
303+
| NativeModuleStringTypeAnnotation
304+
| NativeModuleNumberTypeAnnotation
305+
| NativeModuleInt32TypeAnnotation
306+
| NativeModuleDoubleTypeAnnotation
307+
| NativeModuleFloatTypeAnnotation
308+
| NativeModuleBooleanTypeAnnotation
309+
| NativeModuleGenericObjectTypeAnnotation
310+
| ReservedTypeAnnotation
311+
| NativeModuleTypeAliasTypeAnnotation
312+
| NativeModuleArrayTypeAnnotation<Nullable<NativeModuleBaseTypeAnnotation>>
313+
| NativeModuleObjectTypeAnnotation
314+
| NativeModuleMixedTypeAnnotation;
315+
316+
export type NativeModuleParamTypeAnnotation =
317+
| NativeModuleBaseTypeAnnotation
318+
| NativeModuleParamOnlyTypeAnnotation;
319+
320+
export type NativeModuleReturnTypeAnnotation =
321+
| NativeModuleBaseTypeAnnotation
322+
| NativeModuleReturnOnlyTypeAnnotation;
323+
324+
export type NativeModuleTypeAnnotation =
325+
| NativeModuleBaseTypeAnnotation
326+
| NativeModuleParamOnlyTypeAnnotation
327+
| NativeModuleReturnOnlyTypeAnnotation;
328+
329+
type NativeModuleParamOnlyTypeAnnotation = NativeModuleFunctionTypeAnnotation;
330+
type NativeModuleReturnOnlyTypeAnnotation =
331+
| NativeModulePromiseTypeAnnotation
332+
| VoidTypeAnnotation;

0 commit comments

Comments
 (0)