Skip to content

Commit 4a0a8a6

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 32dbcd0 commit 4a0a8a6

File tree

182 files changed

+51446
-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.

182 files changed

+51446
-0
lines changed
Lines changed: 348 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,348 @@
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 PlatformType =
9+
| 'iOS'
10+
| 'android';
11+
12+
export interface SchemaType {
13+
readonly modules: {
14+
[hasteModuleName: string]: ComponentSchema | NativeModuleSchema;
15+
};
16+
}
17+
18+
export interface DoubleTypeAnnotation {
19+
readonly type: 'DoubleTypeAnnotation';
20+
}
21+
22+
export interface FloatTypeAnnotation {
23+
readonly type: 'FloatTypeAnnotation';
24+
}
25+
26+
export interface BooleanTypeAnnotation {
27+
readonly type: 'BooleanTypeAnnotation';
28+
}
29+
30+
export interface Int32TypeAnnotation {
31+
readonly type: 'Int32TypeAnnotation';
32+
}
33+
34+
export interface StringTypeAnnotation {
35+
readonly type: 'StringTypeAnnotation';
36+
}
37+
38+
export interface StringEnumTypeAnnotation {
39+
readonly type: 'StringEnumTypeAnnotation';
40+
readonly options: readonly string[];
41+
}
42+
43+
export interface VoidTypeAnnotation {
44+
readonly type: 'VoidTypeAnnotation';
45+
}
46+
47+
export interface ObjectTypeAnnotation<T> {
48+
readonly type: 'ObjectTypeAnnotation';
49+
readonly properties: readonly NamedShape<T>[];
50+
readonly baseTypes?: readonly string[] | undefined;
51+
}
52+
53+
export interface FunctionTypeAnnotation<P, R> {
54+
readonly type: 'FunctionTypeAnnotation';
55+
readonly params: readonly NamedShape<P>[];
56+
readonly returnTypeAnnotation: R;
57+
}
58+
59+
export interface NamedShape<T> {
60+
readonly name: string;
61+
readonly optional: boolean;
62+
readonly typeAnnotation: T;
63+
}
64+
65+
export interface ComponentSchema {
66+
readonly type: 'Component';
67+
readonly components: {
68+
[componentName: string]: ComponentShape;
69+
};
70+
}
71+
72+
export interface ComponentShape extends OptionsShape {
73+
readonly extendsProps: readonly ExtendsPropsShape[];
74+
readonly events: readonly EventTypeShape[];
75+
readonly props: readonly NamedShape<PropTypeAnnotation>[];
76+
readonly commands: readonly NamedShape<CommandTypeAnnotation>[];
77+
}
78+
79+
export interface OptionsShape {
80+
readonly interfaceOnly?: boolean | undefined;
81+
readonly paperComponentName?: string | undefined;
82+
readonly excludedPlatforms?: readonly PlatformType[] | undefined;
83+
readonly paperComponentNameDeprecated?: string | undefined;
84+
}
85+
86+
export interface ExtendsPropsShape {
87+
readonly type: 'ReactNativeBuiltInType';
88+
readonly knownTypeName: 'ReactNativeCoreViewProps';
89+
}
90+
91+
export interface EventTypeShape {
92+
readonly name: string;
93+
readonly bubblingType:
94+
| 'direct'
95+
| 'bubble';
96+
readonly optional: boolean;
97+
readonly paperTopLevelNameDeprecated?: string | undefined;
98+
readonly typeAnnotation: {
99+
readonly type: 'EventTypeAnnotation';
100+
readonly argument?: ObjectTypeAnnotation<EventTypeAnnotation> | undefined;
101+
};
102+
}
103+
104+
export type EventTypeAnnotation =
105+
| BooleanTypeAnnotation
106+
| StringTypeAnnotation
107+
| DoubleTypeAnnotation
108+
| FloatTypeAnnotation
109+
| Int32TypeAnnotation
110+
| StringEnumTypeAnnotation
111+
| ObjectTypeAnnotation<EventTypeAnnotation>;
112+
113+
export type PropTypeAnnotation =
114+
| {
115+
readonly type: 'BooleanTypeAnnotation';
116+
readonly default:
117+
| boolean
118+
| null;
119+
}
120+
| {
121+
readonly type: 'StringTypeAnnotation';
122+
readonly default:
123+
| string
124+
| null;
125+
}
126+
| {
127+
readonly type: 'DoubleTypeAnnotation';
128+
readonly default: number;
129+
}
130+
| {
131+
readonly type: 'FloatTypeAnnotation';
132+
readonly default:
133+
| number
134+
| null;
135+
}
136+
| {
137+
readonly type: 'Int32TypeAnnotation';
138+
readonly default: number;
139+
}
140+
| {
141+
readonly type: 'StringEnumTypeAnnotation';
142+
readonly default: string;
143+
readonly options: readonly string[];
144+
}
145+
| {
146+
readonly type: 'Int32EnumTypeAnnotation';
147+
readonly default: number;
148+
readonly options: readonly number[];
149+
}
150+
| ReservedPropTypeAnnotation
151+
| ObjectTypeAnnotation<PropTypeAnnotation>
152+
| {
153+
readonly type: 'ArrayTypeAnnotation';
154+
readonly elementType:
155+
| BooleanTypeAnnotation
156+
| StringTypeAnnotation
157+
| DoubleTypeAnnotation
158+
| FloatTypeAnnotation
159+
| Int32TypeAnnotation
160+
| {
161+
readonly type: 'StringEnumTypeAnnotation';
162+
readonly default: string;
163+
readonly options: readonly string[];
164+
}
165+
| ObjectTypeAnnotation<PropTypeAnnotation>
166+
| ReservedPropTypeAnnotation
167+
| {
168+
readonly type: 'ArrayTypeAnnotation';
169+
readonly elementType: ObjectTypeAnnotation<PropTypeAnnotation>;
170+
};
171+
};
172+
173+
export interface ReservedPropTypeAnnotation {
174+
readonly type: 'ReservedPropTypeAnnotation';
175+
readonly name:
176+
| 'ColorPrimitive'
177+
| 'ImageSourcePrimitive'
178+
| 'PointPrimitive'
179+
| 'EdgeInsetsPrimitive'
180+
| 'ImageRequestPrimitive'
181+
| 'DimensionPrimitive';
182+
}
183+
184+
export type CommandTypeAnnotation = FunctionTypeAnnotation<CommandParamTypeAnnotation, VoidTypeAnnotation>;
185+
186+
export type CommandParamTypeAnnotation =
187+
| ReservedTypeAnnotation
188+
| BooleanTypeAnnotation
189+
| Int32TypeAnnotation
190+
| DoubleTypeAnnotation
191+
| FloatTypeAnnotation
192+
| StringTypeAnnotation;
193+
194+
export interface ReservedTypeAnnotation {
195+
readonly type: 'ReservedTypeAnnotation';
196+
readonly name: 'RootTag';
197+
}
198+
199+
export type Nullable<T extends NativeModuleTypeAnnotation> =
200+
| NullableTypeAnnotation<T>
201+
| T;
202+
203+
export interface NullableTypeAnnotation<T extends NativeModuleTypeAnnotation> {
204+
readonly type: 'NullableTypeAnnotation';
205+
readonly typeAnnotation: T;
206+
}
207+
208+
export interface NativeModuleSchema {
209+
readonly type: 'NativeModule';
210+
readonly aliasMap: NativeModuleAliasMap;
211+
readonly enumMap: NativeModuleEnumMap;
212+
readonly spec: NativeModuleSpec;
213+
readonly moduleName: string;
214+
readonly excludedPlatforms?: readonly PlatformType[] | undefined;
215+
}
216+
217+
export interface NativeModuleSpec {
218+
readonly properties: readonly NativeModulePropertyShape[];
219+
}
220+
221+
export type NativeModulePropertyShape = NamedShape<Nullable<NativeModuleFunctionTypeAnnotation>>;
222+
223+
export interface NativeModuleEnumMap {
224+
readonly [enumName: string]: NativeModuleEnumDeclarationWithMembers;
225+
}
226+
227+
export interface NativeModuleAliasMap {
228+
readonly [aliasName: string]: NativeModuleObjectTypeAnnotation;
229+
}
230+
231+
export type NativeModuleFunctionTypeAnnotation = FunctionTypeAnnotation<Nullable<NativeModuleParamTypeAnnotation>, Nullable<NativeModuleReturnTypeAnnotation>>;
232+
233+
export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation<Nullable<NativeModuleBaseTypeAnnotation>>;
234+
235+
export interface NativeModuleArrayTypeAnnotation<T extends Nullable<NativeModuleBaseTypeAnnotation>> {
236+
readonly type: 'ArrayTypeAnnotation';
237+
readonly elementType?: T | undefined;
238+
}
239+
240+
export interface NativeModuleStringTypeAnnotation {
241+
readonly type: 'StringTypeAnnotation';
242+
}
243+
244+
export interface NativeModuleNumberTypeAnnotation {
245+
readonly type: 'NumberTypeAnnotation';
246+
}
247+
248+
export interface NativeModuleInt32TypeAnnotation {
249+
readonly type: 'Int32TypeAnnotation';
250+
}
251+
252+
export interface NativeModuleDoubleTypeAnnotation {
253+
readonly type: 'DoubleTypeAnnotation';
254+
}
255+
256+
export interface NativeModuleFloatTypeAnnotation {
257+
readonly type: 'FloatTypeAnnotation';
258+
}
259+
260+
export interface NativeModuleBooleanTypeAnnotation {
261+
readonly type: 'BooleanTypeAnnotation';
262+
}
263+
264+
export type NativeModuleEnumMembers = readonly {
265+
readonly name: string;
266+
readonly value: string;
267+
}[];
268+
269+
export type NativeModuleEnumMemberType =
270+
| 'NumberTypeAnnotation'
271+
| 'StringTypeAnnotation';
272+
273+
export interface NativeModuleEnumDeclaration {
274+
readonly name: string;
275+
readonly type: 'EnumDeclaration';
276+
readonly memberType: NativeModuleEnumMemberType;
277+
}
278+
279+
export interface NativeModuleEnumDeclarationWithMembers {
280+
name: string;
281+
type: 'EnumDeclarationWithMembers';
282+
memberType: NativeModuleEnumMemberType;
283+
members: NativeModuleEnumMembers;
284+
}
285+
286+
export interface NativeModuleGenericObjectTypeAnnotation {
287+
readonly type: 'GenericObjectTypeAnnotation';
288+
}
289+
290+
export interface NativeModuleTypeAliasTypeAnnotation {
291+
readonly type: 'TypeAliasTypeAnnotation';
292+
readonly name: string;
293+
}
294+
295+
export interface NativeModulePromiseTypeAnnotation {
296+
readonly type: 'PromiseTypeAnnotation';
297+
readonly elementType?: Nullable<NativeModuleBaseTypeAnnotation> | undefined;
298+
}
299+
300+
export type UnionTypeAnnotationMemberType =
301+
| 'NumberTypeAnnotation'
302+
| 'ObjectTypeAnnotation'
303+
| 'StringTypeAnnotation';
304+
305+
export interface NativeModuleUnionTypeAnnotation {
306+
readonly type: 'UnionTypeAnnotation';
307+
readonly memberType: UnionTypeAnnotationMemberType;
308+
}
309+
310+
export interface NativeModuleMixedTypeAnnotation {
311+
readonly type: 'MixedTypeAnnotation';
312+
}
313+
314+
export type NativeModuleBaseTypeAnnotation =
315+
| NativeModuleStringTypeAnnotation
316+
| NativeModuleNumberTypeAnnotation
317+
| NativeModuleInt32TypeAnnotation
318+
| NativeModuleDoubleTypeAnnotation
319+
| NativeModuleFloatTypeAnnotation
320+
| NativeModuleBooleanTypeAnnotation
321+
| NativeModuleEnumDeclaration
322+
| NativeModuleGenericObjectTypeAnnotation
323+
| ReservedTypeAnnotation
324+
| NativeModuleTypeAliasTypeAnnotation
325+
| NativeModuleArrayTypeAnnotation<Nullable<NativeModuleBaseTypeAnnotation>>
326+
| NativeModuleObjectTypeAnnotation
327+
| NativeModuleUnionTypeAnnotation
328+
| NativeModuleMixedTypeAnnotation;
329+
330+
export type NativeModuleParamTypeAnnotation =
331+
| NativeModuleBaseTypeAnnotation
332+
| NativeModuleParamOnlyTypeAnnotation;
333+
334+
export type NativeModuleReturnTypeAnnotation =
335+
| NativeModuleBaseTypeAnnotation
336+
| NativeModuleReturnOnlyTypeAnnotation;
337+
338+
export type NativeModuleTypeAnnotation =
339+
| NativeModuleBaseTypeAnnotation
340+
| NativeModuleParamOnlyTypeAnnotation
341+
| NativeModuleReturnOnlyTypeAnnotation;
342+
343+
export type NativeModuleParamOnlyTypeAnnotation = NativeModuleFunctionTypeAnnotation;
344+
345+
export type NativeModuleReturnOnlyTypeAnnotation =
346+
| NativeModulePromiseTypeAnnotation
347+
| VoidTypeAnnotation;
348+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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';

0 commit comments

Comments
 (0)