@react-native/codegen 0.72.1

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.
Files changed (186) hide show
  1. package/README.md +21 -0
  2. package/lib/CodegenSchema.js +11 -0
  3. package/lib/CodegenSchema.js.flow +351 -0
  4. package/lib/SchemaValidator.js +54 -0
  5. package/lib/SchemaValidator.js.flow +67 -0
  6. package/lib/cli/combine/combine-js-to-schema-cli.js +50 -0
  7. package/lib/cli/combine/combine-js-to-schema-cli.js.flow +49 -0
  8. package/lib/cli/combine/combine-js-to-schema.js +110 -0
  9. package/lib/cli/combine/combine-js-to-schema.js.flow +48 -0
  10. package/lib/cli/combine/combine-utils.js +118 -0
  11. package/lib/cli/combine/combine-utils.js.flow +85 -0
  12. package/lib/cli/generators/generate-all.js +65 -0
  13. package/lib/cli/generators/generate-all.js.flow +66 -0
  14. package/lib/cli/parser/parser-cli.js +55 -0
  15. package/lib/cli/parser/parser-cli.js.flow +18 -0
  16. package/lib/cli/parser/parser.js +35 -0
  17. package/lib/cli/parser/parser.js.flow +37 -0
  18. package/lib/cli/parser/parser.sh +15 -0
  19. package/lib/generators/RNCodegen.js +207 -0
  20. package/lib/generators/RNCodegen.js.flow +284 -0
  21. package/lib/generators/Utils.js +31 -0
  22. package/lib/generators/Utils.js.flow +33 -0
  23. package/lib/generators/__test_fixtures__/fixtures.js +79 -0
  24. package/lib/generators/__test_fixtures__/fixtures.js.flow +82 -0
  25. package/lib/generators/components/ComponentsGeneratorUtils.js +217 -0
  26. package/lib/generators/components/ComponentsGeneratorUtils.js.flow +304 -0
  27. package/lib/generators/components/CppHelpers.js +188 -0
  28. package/lib/generators/components/CppHelpers.js.flow +228 -0
  29. package/lib/generators/components/GenerateComponentDescriptorH.js +75 -0
  30. package/lib/generators/components/GenerateComponentDescriptorH.js.flow +95 -0
  31. package/lib/generators/components/GenerateComponentHObjCpp.js +327 -0
  32. package/lib/generators/components/GenerateComponentHObjCpp.js.flow +418 -0
  33. package/lib/generators/components/GenerateEventEmitterCpp.js +199 -0
  34. package/lib/generators/components/GenerateEventEmitterCpp.js.flow +273 -0
  35. package/lib/generators/components/GenerateEventEmitterH.js +224 -0
  36. package/lib/generators/components/GenerateEventEmitterH.js.flow +315 -0
  37. package/lib/generators/components/GeneratePropsCpp.js +126 -0
  38. package/lib/generators/components/GeneratePropsCpp.js.flow +161 -0
  39. package/lib/generators/components/GeneratePropsH.js +606 -0
  40. package/lib/generators/components/GeneratePropsH.js.flow +778 -0
  41. package/lib/generators/components/GeneratePropsJavaDelegate.js +287 -0
  42. package/lib/generators/components/GeneratePropsJavaDelegate.js.flow +348 -0
  43. package/lib/generators/components/GeneratePropsJavaInterface.js +237 -0
  44. package/lib/generators/components/GeneratePropsJavaInterface.js.flow +288 -0
  45. package/lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js +157 -0
  46. package/lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js.flow +187 -0
  47. package/lib/generators/components/GeneratePropsJavaPojo/index.js +66 -0
  48. package/lib/generators/components/GeneratePropsJavaPojo/index.js.flow +80 -0
  49. package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js +273 -0
  50. package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js.flow +296 -0
  51. package/lib/generators/components/GenerateShadowNodeCpp.js +73 -0
  52. package/lib/generators/components/GenerateShadowNodeCpp.js.flow +95 -0
  53. package/lib/generators/components/GenerateShadowNodeH.js +91 -0
  54. package/lib/generators/components/GenerateShadowNodeH.js.flow +124 -0
  55. package/lib/generators/components/GenerateStateCpp.js +70 -0
  56. package/lib/generators/components/GenerateStateCpp.js.flow +92 -0
  57. package/lib/generators/components/GenerateStateH.js +93 -0
  58. package/lib/generators/components/GenerateStateH.js.flow +111 -0
  59. package/lib/generators/components/GenerateTests.js +165 -0
  60. package/lib/generators/components/GenerateTests.js.flow +219 -0
  61. package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js +91 -0
  62. package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js.flow +107 -0
  63. package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js +89 -0
  64. package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js.flow +105 -0
  65. package/lib/generators/components/GenerateViewConfigJs.js +410 -0
  66. package/lib/generators/components/GenerateViewConfigJs.js.flow +484 -0
  67. package/lib/generators/components/JavaHelpers.js +87 -0
  68. package/lib/generators/components/JavaHelpers.js.flow +119 -0
  69. package/lib/generators/components/__test_fixtures__/fixtures.js +1641 -0
  70. package/lib/generators/components/__test_fixtures__/fixtures.js.flow +1672 -0
  71. package/lib/generators/modules/GenerateModuleCpp.js +299 -0
  72. package/lib/generators/modules/GenerateModuleCpp.js.flow +278 -0
  73. package/lib/generators/modules/GenerateModuleH.js +373 -0
  74. package/lib/generators/modules/GenerateModuleH.js.flow +355 -0
  75. package/lib/generators/modules/GenerateModuleJavaSpec.js +571 -0
  76. package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +553 -0
  77. package/lib/generators/modules/GenerateModuleJniCpp.js +505 -0
  78. package/lib/generators/modules/GenerateModuleJniCpp.js.flow +523 -0
  79. package/lib/generators/modules/GenerateModuleJniH.js +138 -0
  80. package/lib/generators/modules/GenerateModuleJniH.js.flow +148 -0
  81. package/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js +262 -0
  82. package/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js.flow +208 -0
  83. package/lib/generators/modules/GenerateModuleObjCpp/Utils.js +25 -0
  84. package/lib/generators/modules/GenerateModuleObjCpp/Utils.js.flow +32 -0
  85. package/lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js +337 -0
  86. package/lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js.flow +288 -0
  87. package/lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js +330 -0
  88. package/lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js.flow +279 -0
  89. package/lib/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js +25 -0
  90. package/lib/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js.flow +35 -0
  91. package/lib/generators/modules/GenerateModuleObjCpp/index.js +185 -0
  92. package/lib/generators/modules/GenerateModuleObjCpp/index.js.flow +219 -0
  93. package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js +529 -0
  94. package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow +510 -0
  95. package/lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js +96 -0
  96. package/lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js.flow +121 -0
  97. package/lib/generators/modules/Utils.js +34 -0
  98. package/lib/generators/modules/Utils.js.flow +53 -0
  99. package/lib/generators/modules/__test_fixtures__/fixtures.js +1658 -0
  100. package/lib/generators/modules/__test_fixtures__/fixtures.js.flow +1669 -0
  101. package/lib/parsers/consistency/compareSnaps.js +84 -0
  102. package/lib/parsers/error-utils.js +284 -0
  103. package/lib/parsers/error-utils.js.flow +295 -0
  104. package/lib/parsers/errors.js +350 -0
  105. package/lib/parsers/errors.js.flow +439 -0
  106. package/lib/parsers/flow/components/__test_fixtures__/failures.js +583 -0
  107. package/lib/parsers/flow/components/__test_fixtures__/failures.js.flow +600 -0
  108. package/lib/parsers/flow/components/__test_fixtures__/fixtures.js +1001 -0
  109. package/lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow +1016 -0
  110. package/lib/parsers/flow/components/commands.js +104 -0
  111. package/lib/parsers/flow/components/commands.js.flow +123 -0
  112. package/lib/parsers/flow/components/componentsUtils.js +446 -0
  113. package/lib/parsers/flow/components/componentsUtils.js.flow +496 -0
  114. package/lib/parsers/flow/components/events.js +233 -0
  115. package/lib/parsers/flow/components/events.js.flow +262 -0
  116. package/lib/parsers/flow/components/extends.js +52 -0
  117. package/lib/parsers/flow/components/extends.js.flow +66 -0
  118. package/lib/parsers/flow/components/index.js +267 -0
  119. package/lib/parsers/flow/components/index.js.flow +226 -0
  120. package/lib/parsers/flow/components/options.js +72 -0
  121. package/lib/parsers/flow/components/options.js.flow +87 -0
  122. package/lib/parsers/flow/components/props.js +47 -0
  123. package/lib/parsers/flow/components/props.js.flow +60 -0
  124. package/lib/parsers/flow/components/schema.js +106 -0
  125. package/lib/parsers/flow/components/schema.js.flow +62 -0
  126. package/lib/parsers/flow/index.js +80 -0
  127. package/lib/parsers/flow/index.js.flow +85 -0
  128. package/lib/parsers/flow/modules/__test_fixtures__/failures.js +215 -0
  129. package/lib/parsers/flow/modules/__test_fixtures__/failures.js.flow +223 -0
  130. package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js +724 -0
  131. package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js.flow +747 -0
  132. package/lib/parsers/flow/modules/index.js +528 -0
  133. package/lib/parsers/flow/modules/index.js.flow +420 -0
  134. package/lib/parsers/flow/parser.js +109 -0
  135. package/lib/parsers/flow/parser.js.flow +83 -0
  136. package/lib/parsers/flow/utils.js +108 -0
  137. package/lib/parsers/flow/utils.js.flow +123 -0
  138. package/lib/parsers/parser.js +11 -0
  139. package/lib/parsers/parser.js.flow +70 -0
  140. package/lib/parsers/parserMock.js +96 -0
  141. package/lib/parsers/parserMock.js.flow +68 -0
  142. package/lib/parsers/parsers-commons.js +448 -0
  143. package/lib/parsers/parsers-commons.js.flow +447 -0
  144. package/lib/parsers/parsers-primitives.js +387 -0
  145. package/lib/parsers/parsers-primitives.js.flow +383 -0
  146. package/lib/parsers/parsers-utils.js +18 -0
  147. package/lib/parsers/parsers-utils.js.flow +19 -0
  148. package/lib/parsers/schema/index.js +23 -0
  149. package/lib/parsers/schema/index.js.flow +26 -0
  150. package/lib/parsers/typescript/components/__test_fixtures__/failures.js +489 -0
  151. package/lib/parsers/typescript/components/__test_fixtures__/failures.js.flow +505 -0
  152. package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js +1151 -0
  153. package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow +1168 -0
  154. package/lib/parsers/typescript/components/commands.js +132 -0
  155. package/lib/parsers/typescript/components/commands.js.flow +151 -0
  156. package/lib/parsers/typescript/components/componentsUtils.js +471 -0
  157. package/lib/parsers/typescript/components/componentsUtils.js.flow +521 -0
  158. package/lib/parsers/typescript/components/events.js +240 -0
  159. package/lib/parsers/typescript/components/events.js.flow +262 -0
  160. package/lib/parsers/typescript/components/extends.js +88 -0
  161. package/lib/parsers/typescript/components/extends.js.flow +103 -0
  162. package/lib/parsers/typescript/components/index.js +277 -0
  163. package/lib/parsers/typescript/components/index.js.flow +239 -0
  164. package/lib/parsers/typescript/components/options.js +72 -0
  165. package/lib/parsers/typescript/components/options.js.flow +87 -0
  166. package/lib/parsers/typescript/components/props.js +39 -0
  167. package/lib/parsers/typescript/components/props.js.flow +48 -0
  168. package/lib/parsers/typescript/components/schema.js +106 -0
  169. package/lib/parsers/typescript/components/schema.js.flow +62 -0
  170. package/lib/parsers/typescript/index.js +85 -0
  171. package/lib/parsers/typescript/index.js.flow +94 -0
  172. package/lib/parsers/typescript/modules/__test_fixtures__/failures.js +160 -0
  173. package/lib/parsers/typescript/modules/__test_fixtures__/failures.js.flow +167 -0
  174. package/lib/parsers/typescript/modules/__test_fixtures__/fixtures.js +701 -0
  175. package/lib/parsers/typescript/modules/__test_fixtures__/fixtures.js.flow +727 -0
  176. package/lib/parsers/typescript/modules/index.js +543 -0
  177. package/lib/parsers/typescript/modules/index.js.flow +435 -0
  178. package/lib/parsers/typescript/parseTopLevelType.js +203 -0
  179. package/lib/parsers/typescript/parseTopLevelType.js.flow +243 -0
  180. package/lib/parsers/typescript/parser.js +105 -0
  181. package/lib/parsers/typescript/parser.js.flow +87 -0
  182. package/lib/parsers/typescript/utils.js +101 -0
  183. package/lib/parsers/typescript/utils.js.flow +115 -0
  184. package/lib/parsers/utils.js +273 -0
  185. package/lib/parsers/utils.js.flow +266 -0
  186. package/package.json +45 -0
@@ -0,0 +1,1168 @@
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-local
8
+ * @format
9
+ */
10
+
11
+ // @licenselint-loose-mode
12
+
13
+ 'use strict';
14
+
15
+ const EVENT_DEFINITION = `
16
+ boolean_required: boolean;
17
+ boolean_optional_key?: boolean;
18
+ boolean_optional_value: boolean | null | undefined;
19
+ boolean_optional_both?: boolean | null | undefined;
20
+
21
+ string_required: string;
22
+ string_optional_key?: (string);
23
+ string_optional_value: (string) | null | undefined;
24
+ string_optional_both?: (string | null | undefined);
25
+
26
+ double_required: Double;
27
+ double_optional_key?: Double;
28
+ double_optional_value: Double | null | undefined;
29
+ double_optional_both?: Double | null | undefined;
30
+
31
+ float_required: Float;
32
+ float_optional_key?: Float;
33
+ float_optional_value: Float | null | undefined;
34
+ float_optional_both?: Float | null | undefined;
35
+
36
+ int32_required: Int32;
37
+ int32_optional_key?: Int32;
38
+ int32_optional_value: Int32 | null | undefined;
39
+ int32_optional_both?: Int32 | null | undefined;
40
+
41
+ enum_required: 'small' | 'large';
42
+ enum_optional_key?: 'small' | 'large';
43
+ enum_optional_value: ('small' | 'large') | null | undefined;
44
+ enum_optional_both?: ('small' | 'large') | null | undefined;
45
+
46
+ object_required: {
47
+ boolean_required: boolean;
48
+ };
49
+
50
+ object_optional_key?: {
51
+ string_optional_key?: string;
52
+ };
53
+
54
+ object_optional_value: {
55
+ float_optional_value: Float | null | undefined;
56
+ } | null | undefined;
57
+
58
+ object_optional_both?: {
59
+ int32_optional_both?: Int32 | null | undefined;
60
+ } | null | undefined;
61
+
62
+ object_required_nested_2_layers: {
63
+ object_optional_nested_1_layer?: {
64
+ boolean_required: Int32;
65
+ string_optional_key?: string;
66
+ double_optional_value: Double | null | undefined;
67
+ float_optional_value: Float | null | undefined;
68
+ int32_optional_both?: Int32 | null | undefined;
69
+ } | null | undefined;
70
+ };
71
+
72
+ object_readonly_required: Readonly<{
73
+ boolean_required: boolean;
74
+ }>;
75
+
76
+ object_readonly_optional_key?: Readonly<{
77
+ string_optional_key?: string;
78
+ }>;
79
+
80
+ object_readonly_optional_value: Readonly<{
81
+ float_optional_value: Float | null | undefined;
82
+ }> | null | undefined;
83
+
84
+ object_readonly_optional_both?: Readonly<{
85
+ int32_optional_both?: Int32 | null | undefined;
86
+ }> | null | undefined;
87
+ `;
88
+
89
+ const ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS = `
90
+ /**
91
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
92
+ *
93
+ * This source code is licensed under the MIT license found in the
94
+ * LICENSE file in the root directory of this source tree.
95
+ *
96
+ * @format
97
+ */
98
+
99
+ 'use strict';
100
+
101
+ import type {
102
+ BubblingEventHandler,
103
+ DirectEventHandler,
104
+ WithDefault,
105
+ } from 'CodegenTypes';
106
+ import type {ViewProps} from 'ViewPropTypes';
107
+ import type {HostComponent} from 'react-native';
108
+
109
+ const codegenNativeComponent = require('codegenNativeComponent');
110
+
111
+ export interface ModuleProps extends ViewProps {
112
+ // Props
113
+ boolean_default_true_optional_both?: WithDefault<boolean, true>;
114
+
115
+ // Events
116
+ onDirectEventDefinedInlineNull: DirectEventHandler<null>;
117
+ onBubblingEventDefinedInlineNull: BubblingEventHandler<null>;
118
+ }
119
+
120
+ export default codegenNativeComponent<ModuleProps>('Module', {
121
+ interfaceOnly: true,
122
+ paperComponentName: 'RCTModule',
123
+ }) as HostComponent<ModuleProps>;
124
+ `;
125
+
126
+ const ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS_NO_CAST = `
127
+ /**
128
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
129
+ *
130
+ * This source code is licensed under the MIT license found in the
131
+ * LICENSE file in the root directory of this source tree.
132
+ *
133
+ * @format
134
+ */
135
+
136
+ const codegenNativeComponent = require('codegenNativeComponent');
137
+
138
+ import type {
139
+ BubblingEventHandler,
140
+ DirectEventHandler,
141
+ WithDefault,
142
+ } from 'CodegenTypes';
143
+ import type {ViewProps} from 'ViewPropTypes';
144
+ import type {HostComponent} from 'react-native';
145
+
146
+ export interface ModuleProps extends ViewProps {
147
+ // Props
148
+ boolean_default_true_optional_both?: WithDefault<boolean, true>;
149
+
150
+ // Events
151
+ onDirectEventDefinedInlineNull: DirectEventHandler<null>;
152
+ onBubblingEventDefinedInlineNull: BubblingEventHandler<null>;
153
+ }
154
+
155
+ export default codegenNativeComponent<ModuleProps>('Module', {
156
+ interfaceOnly: true,
157
+ excludedPlatforms: ['android'],
158
+ paperComponentName: 'RCTModule',
159
+ }) as HostComponent<ModuleProps>;
160
+ `;
161
+
162
+ const NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION = `
163
+ /**
164
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
165
+ *
166
+ * This source code is licensed under the MIT license found in the
167
+ * LICENSE file in the root directory of this source tree.
168
+ *
169
+ * @format
170
+ */
171
+
172
+ const codegenNativeComponent = require('codegenNativeComponent');
173
+
174
+ import type {ViewProps} from 'ViewPropTypes';
175
+ import type {HostComponent} from 'react-native';
176
+
177
+ export interface ModuleProps extends ViewProps {
178
+
179
+ }
180
+
181
+ export default codegenNativeComponent<ModuleProps>('Module', {
182
+ deprecatedViewConfigName: 'DeprecateModuleName',
183
+ }) as HostComponent<ModuleProps>;
184
+ `;
185
+
186
+ const ALL_PROP_TYPES_NO_EVENTS = `
187
+ /**
188
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
189
+ *
190
+ * This source code is licensed under the MIT license found in the
191
+ * LICENSE file in the root directory of this source tree.
192
+ *
193
+ * @format
194
+ */
195
+
196
+ 'use strict';
197
+
198
+ const codegenNativeComponent = require('codegenNativeComponent');
199
+
200
+ import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
201
+ import type {ImageSource} from 'ImageSource';
202
+ import type {
203
+ ColorValue,
204
+ ColorArrayValue,
205
+ PointValue,
206
+ EdgeInsetsValue,
207
+ } from 'StyleSheetTypes';
208
+ import type {ViewProps} from 'ViewPropTypes';
209
+ import type {HostComponent} from 'react-native';
210
+
211
+ export interface ModuleProps extends ViewProps {
212
+ // Props
213
+ // Boolean props
214
+ boolean_required: boolean;
215
+ boolean_optional_key?: WithDefault<boolean, true>;
216
+ boolean_optional_both?: WithDefault<boolean, true>;
217
+
218
+ // Boolean props, null default
219
+ boolean_null_optional_key?: WithDefault<boolean, null>;
220
+ boolean_null_optional_both?: WithDefault<boolean, null>;
221
+
222
+ // String props
223
+ string_required: string;
224
+ string_optional_key?: WithDefault<string, ''>;
225
+ string_optional_both?: WithDefault<string, ''>;
226
+
227
+ // String props, null default
228
+ string_null_optional_key?: WithDefault<string, null>;
229
+ string_null_optional_both?: WithDefault<string, null>;
230
+
231
+ // Stringish props
232
+ stringish_required: Stringish;
233
+ stringish_optional_key?: WithDefault<Stringish, ''>;
234
+ stringish_optional_both?: WithDefault<Stringish, ''>;
235
+
236
+ // Stringish props, null default
237
+ stringish_null_optional_key?: WithDefault<Stringish, null>;
238
+ stringish_null_optional_both?: WithDefault<Stringish, null>;
239
+
240
+ // Double props
241
+ double_required: Double;
242
+ double_optional_key?: WithDefault<Double, 1.1>;
243
+ double_optional_both?: WithDefault<Double, 1.1>;
244
+
245
+ // Float props
246
+ float_required: Float;
247
+ float_optional_key?: WithDefault<Float, 1.1>;
248
+ float_optional_both?: WithDefault<Float, 1.1>;
249
+
250
+ // Float props, null default
251
+ float_null_optional_key?: WithDefault<Float, null>;
252
+ float_null_optional_both?: WithDefault<Float, null>;
253
+
254
+ // Int32 props
255
+ int32_required: Int32;
256
+ int32_optional_key?: WithDefault<Int32, 1>;
257
+ int32_optional_both?: WithDefault<Int32, 1>;
258
+
259
+ // String enum props
260
+ enum_optional_key?: WithDefault<'small' | 'large', 'small'>;
261
+ enum_optional_both?: WithDefault<'small' | 'large', 'small'>;
262
+
263
+ // Int enum props
264
+ int_enum_optional_key?: WithDefault<0 | 1, 0>;
265
+
266
+ // Object props
267
+ object_optional_key?: Readonly<{prop: string}>;
268
+ object_optional_both?: Readonly<{prop: string} | null | undefined>;
269
+ object_optional_value: Readonly<{prop: string} | null | undefined>;
270
+
271
+ // ImageSource props
272
+ image_required: ImageSource;
273
+ image_optional_value: ImageSource | null | undefined;
274
+ image_optional_both?: ImageSource | null | undefined;
275
+
276
+ // ColorValue props
277
+ color_required: ColorValue;
278
+ color_optional_key?: ColorValue;
279
+ color_optional_value: ColorValue | null | undefined;
280
+ color_optional_both?: ColorValue | null | undefined;
281
+
282
+ // ColorArrayValue props
283
+ color_array_required: ColorArrayValue;
284
+ color_array_optional_key?: ColorArrayValue;
285
+ color_array_optional_value: ColorArrayValue | null | undefined;
286
+ color_array_optional_both?: ColorArrayValue | null | undefined;
287
+
288
+ // ProcessedColorValue props
289
+ processed_color_required: ProcessedColorValue;
290
+ processed_color_optional_key?: ProcessedColorValue;
291
+ processed_color_optional_value: ProcessedColorValue | null | undefined;
292
+ processed_color_optional_both?: ProcessedColorValue | null | undefined;
293
+
294
+ // PointValue props
295
+ point_required: PointValue;
296
+ point_optional_key?: PointValue;
297
+ point_optional_value: PointValue | null | undefined;
298
+ point_optional_both?: PointValue | null | undefined;
299
+
300
+ // EdgeInsets props
301
+ insets_required: EdgeInsetsValue;
302
+ insets_optional_key?: EdgeInsetsValue;
303
+ insets_optional_value: EdgeInsetsValue | null | undefined;
304
+ insets_optional_both?: EdgeInsetsValue | null | undefined;
305
+ }
306
+
307
+ export default codegenNativeComponent<ModuleProps>(
308
+ 'Module',
309
+ ) as HostComponent<ModuleProps>;
310
+ `;
311
+
312
+ const ARRAY_PROP_TYPES_NO_EVENTS = `
313
+ /**
314
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
315
+ *
316
+ * This source code is licensed under the MIT license found in the
317
+ * LICENSE file in the root directory of this source tree.
318
+ *
319
+ * @format
320
+ */
321
+
322
+ 'use strict';
323
+
324
+ const codegenNativeComponent = require('codegenNativeComponent');
325
+
326
+ import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
327
+ import type {ImageSource} from 'ImageSource';
328
+ import type {
329
+ ColorValue,
330
+ ColorArrayValue,
331
+ PointValue,
332
+ EdgeInsetsValue,
333
+ } from 'StyleSheetTypes';
334
+ import type {ViewProps} from 'ViewPropTypes';
335
+ import type {HostComponent} from 'react-native';
336
+
337
+ type ObjectType = Readonly<{prop: string}>;
338
+ type ArrayObjectType = ReadonlyArray<Readonly<{prop: string}>>;
339
+
340
+ export interface ModuleProps extends ViewProps {
341
+ // Props
342
+ // Boolean props
343
+ array_boolean_required: ReadonlyArray<boolean>;
344
+ array_boolean_optional_key?: ReadonlyArray<boolean>;
345
+ array_boolean_optional_value: ReadonlyArray<boolean> | null | undefined;
346
+ array_boolean_optional_both?: ReadonlyArray<boolean> | null | undefined;
347
+
348
+ // String props
349
+ array_string_required: ReadonlyArray<string>;
350
+ array_string_optional_key?: ReadonlyArray<string>;
351
+ array_string_optional_value: ReadonlyArray<string> | null | undefined;
352
+ array_string_optional_both?: ReadonlyArray<string> | null | undefined;
353
+
354
+ // Double props
355
+ array_double_required: ReadonlyArray<Double>;
356
+ array_double_optional_key?: ReadonlyArray<Double>;
357
+ array_double_optional_value: ReadonlyArray<Double> | null | undefined;
358
+ array_double_optional_both?: ReadonlyArray<Double> | null | undefined;
359
+
360
+ // Float props
361
+ array_float_required: ReadonlyArray<Float>;
362
+ array_float_optional_key?: ReadonlyArray<Float>;
363
+ array_float_optional_value: ReadonlyArray<Float> | null | undefined;
364
+ array_float_optional_both?: ReadonlyArray<Float> | null | undefined;
365
+
366
+ // Int32 props
367
+ array_int32_required: ReadonlyArray<Int32>;
368
+ array_int32_optional_key?: ReadonlyArray<Int32>;
369
+ array_int32_optional_value: ReadonlyArray<Int32> | null | undefined;
370
+ array_int32_optional_both?: ReadonlyArray<Int32> | null | undefined;
371
+
372
+ // String enum props
373
+ array_enum_optional_key?: WithDefault<
374
+ ReadonlyArray<'small' | 'large'>,
375
+ 'small'
376
+ >;
377
+ array_enum_optional_both?: WithDefault<
378
+ ReadonlyArray<'small' | 'large'>,
379
+ 'small'
380
+ >;
381
+
382
+ // ImageSource props
383
+ array_image_required: ReadonlyArray<ImageSource>;
384
+ array_image_optional_key?: ReadonlyArray<ImageSource>;
385
+ array_image_optional_value: ReadonlyArray<ImageSource> | null | undefined;
386
+ array_image_optional_both?: ReadonlyArray<ImageSource> | null | undefined;
387
+
388
+ // ColorValue props
389
+ array_color_required: ReadonlyArray<ColorValue>;
390
+ array_color_optional_key?: ReadonlyArray<ColorValue>;
391
+ array_color_optional_value: ReadonlyArray<ColorValue> | null | undefined;
392
+ array_color_optional_both?: ReadonlyArray<ColorValue> | null | undefined;
393
+
394
+ // PointValue props
395
+ array_point_required: ReadonlyArray<PointValue>;
396
+ array_point_optional_key?: ReadonlyArray<PointValue>;
397
+ array_point_optional_value: ReadonlyArray<PointValue> | null | undefined;
398
+ array_point_optional_both?: ReadonlyArray<PointValue> | null | undefined;
399
+
400
+ // EdgeInsetsValue props
401
+ array_insets_required: ReadonlyArray<EdgeInsetsValue>;
402
+ array_insets_optional_key?: ReadonlyArray<EdgeInsetsValue>;
403
+ array_insets_optional_value: ReadonlyArray<EdgeInsetsValue> | null | undefined;
404
+ array_insets_optional_both?: ReadonlyArray<EdgeInsetsValue> | null | undefined;
405
+
406
+ // Object props
407
+ array_object_required: ReadonlyArray<Readonly<{prop: string}>>;
408
+ array_object_optional_key?: ReadonlyArray<Readonly<{prop: string}>>;
409
+ array_object_optional_value: ArrayObjectType | null | undefined;
410
+ array_object_optional_both?: ReadonlyArray<ObjectType> | null | undefined;
411
+
412
+ // Nested array object types
413
+ array_of_array_object_required: ReadonlyArray<
414
+ Readonly<{
415
+ // This needs to be the same name as the top level array above
416
+ array_object_required: ReadonlyArray<Readonly<{prop: string}>>;
417
+ }>
418
+ >;
419
+ array_of_array_object_optional_key?: ReadonlyArray<
420
+ Readonly<{
421
+ // This needs to be the same name as the top level array above
422
+ array_object_optional_key: ReadonlyArray<Readonly<{prop?: string}>>;
423
+ }>
424
+ >;
425
+ array_of_array_object_optional_value: ReadonlyArray<
426
+ Readonly<{
427
+ // This needs to be the same name as the top level array above
428
+ array_object_optional_value: ReadonlyArray<
429
+ Readonly<{prop: string | null | undefined}>
430
+ >;
431
+ }>
432
+ > | null | undefined;
433
+ array_of_array_object_optional_both?: ReadonlyArray<
434
+ Readonly<{
435
+ // This needs to be the same name as the top level array above
436
+ array_object_optional_both: ReadonlyArray<
437
+ Readonly<{prop?: string | null | undefined}>
438
+ >;
439
+ }>
440
+ > | null | undefined;
441
+
442
+ // Nested array of array of object types
443
+ array_of_array_of_object_required: ReadonlyArray<
444
+ ReadonlyArray<
445
+ Readonly<{
446
+ prop: string;
447
+ }>
448
+ >
449
+ >;
450
+
451
+ // Nested array of array of object types (in file)
452
+ array_of_array_of_object_required_in_file: ReadonlyArray<
453
+ ReadonlyArray<ObjectType>
454
+ >;
455
+
456
+ // Nested array of array of object types (with spread)
457
+ array_of_array_of_object_required_with_spread: ReadonlyArray<
458
+ ReadonlyArray<
459
+ Readonly<ObjectType & {}>,
460
+ >,
461
+ >,
462
+ }
463
+
464
+ export default codegenNativeComponent<ModuleProps>(
465
+ 'Module',
466
+ ) as HostComponent<ModuleProps>;
467
+ `;
468
+
469
+ const ARRAY2_PROP_TYPES_NO_EVENTS = `
470
+ /**
471
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
472
+ *
473
+ * This source code is licensed under the MIT license found in the
474
+ * LICENSE file in the root directory of this source tree.
475
+ *
476
+ * @format
477
+ */
478
+
479
+ 'use strict';
480
+
481
+ const codegenNativeComponent = require('codegenNativeComponent');
482
+
483
+ import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
484
+ import type {ImageSource} from 'ImageSource';
485
+ import type {
486
+ ColorValue,
487
+ ColorArrayValue,
488
+ PointValue,
489
+ EdgeInsetsValue,
490
+ } from 'StyleSheetTypes';
491
+ import type {ViewProps} from 'ViewPropTypes';
492
+ import type {HostComponent} from 'react-native';
493
+
494
+ type ObjectType = Readonly<{prop: string}>;
495
+ type ArrayObjectType = readonly Readonly<{prop: string}>[];
496
+
497
+ export interface ModuleProps extends ViewProps {
498
+ // Props
499
+ // Boolean props
500
+ array_boolean_required: readonly boolean[];
501
+ array_boolean_optional_key?: readonly boolean[];
502
+ array_boolean_optional_value: readonly boolean[] | null | undefined;
503
+ array_boolean_optional_both?: readonly boolean[] | null | undefined;
504
+
505
+ // String props
506
+ array_string_required: readonly string[];
507
+ array_string_optional_key?: readonly string[];
508
+ array_string_optional_value: readonly string[] | null | undefined;
509
+ array_string_optional_both?: readonly string[] | null | undefined;
510
+
511
+ // Double props
512
+ array_double_required: readonly Double[];
513
+ array_double_optional_key?: readonly Double[];
514
+ array_double_optional_value: readonly Double[] | null | undefined;
515
+ array_double_optional_both?: readonly Double[] | null | undefined;
516
+
517
+ // Float props
518
+ array_float_required: readonly Float[];
519
+ array_float_optional_key?: readonly Float[];
520
+ array_float_optional_value: readonly Float[] | null | undefined;
521
+ array_float_optional_both?: readonly Float[] | null | undefined;
522
+
523
+ // Int32 props
524
+ array_int32_required: readonly Int32[];
525
+ array_int32_optional_key?: readonly Int32[];
526
+ array_int32_optional_value: readonly Int32[] | null | undefined;
527
+ array_int32_optional_both?: readonly Int32[] | null | undefined;
528
+
529
+ // String enum props
530
+ array_enum_optional_key?: WithDefault<
531
+ readonly ('small' | 'large')[],
532
+ 'small'
533
+ >;
534
+ array_enum_optional_both?: WithDefault<
535
+ readonly ('small' | 'large')[],
536
+ 'small'
537
+ >;
538
+
539
+ // ImageSource props
540
+ array_image_required: readonly ImageSource[];
541
+ array_image_optional_key?: readonly ImageSource[];
542
+ array_image_optional_value: readonly ImageSource[] | null | undefined;
543
+ array_image_optional_both?: readonly ImageSource[] | null | undefined;
544
+
545
+ // ColorValue props
546
+ array_color_required: readonly ColorValue[];
547
+ array_color_optional_key?: readonly ColorValue[];
548
+ array_color_optional_value: readonly ColorValue[] | null | undefined;
549
+ array_color_optional_both?: readonly ColorValue[] | null | undefined;
550
+
551
+ // PointValue props
552
+ array_point_required: readonly PointValue[];
553
+ array_point_optional_key?: readonly PointValue[];
554
+ array_point_optional_value: readonly PointValue[] | null | undefined;
555
+ array_point_optional_both?: readonly PointValue[] | null | undefined;
556
+
557
+ // EdgeInsetsValue props
558
+ array_insets_required: readonly EdgeInsetsValue[];
559
+ array_insets_optional_key?: readonly EdgeInsetsValue[];
560
+ array_insets_optional_value: readonly EdgeInsetsValue[] | null | undefined;
561
+ array_insets_optional_both?: readonly EdgeInsetsValue[] | null | undefined;
562
+
563
+ // Object props
564
+ array_object_required: readonly Readonly<{prop: string}>[];
565
+ array_object_optional_key?: readonly Readonly<{prop: string}>[];
566
+ array_object_optional_value: ArrayObjectType | null | undefined;
567
+ array_object_optional_both?: readonly ObjectType[] | null | undefined;
568
+
569
+ // Nested array object types
570
+ array_of_array_object_required: readonly Readonly<{
571
+ // This needs to be the same name as the top level array above
572
+ array_object_required: readonly Readonly<{prop: string}>[];
573
+ }>[];
574
+ array_of_array_object_optional_key?: readonly Readonly<{
575
+ // This needs to be the same name as the top level array above
576
+ array_object_optional_key: readonly Readonly<{prop?: string}>[];
577
+ }>[];
578
+ array_of_array_object_optional_value: readonly Readonly<{
579
+ // This needs to be the same name as the top level array above
580
+ array_object_optional_value: readonly Readonly<{prop: string | null | undefined}>[];
581
+ }>[] | null | undefined;
582
+ array_of_array_object_optional_both?: readonly Readonly<{
583
+ // This needs to be the same name as the top level array above
584
+ array_object_optional_both: readonly Readonly<{prop?: string | null | undefined}>[];
585
+ }>[] | null | undefined;
586
+
587
+ // Nested array of array of object types
588
+ array_of_array_of_object_required: readonly Readonly<{
589
+ prop: string;
590
+ }>[][];
591
+
592
+ // Nested array of array of object types (in file)
593
+ array_of_array_of_object_required_in_file: readonly ObjectType[][];
594
+
595
+ // Nested array of array of object types (with spread)
596
+ array_of_array_of_object_required_with_spread: readonly Readonly<ObjectType & {}>[][];
597
+ }
598
+
599
+ export default codegenNativeComponent<ModuleProps>(
600
+ 'Module',
601
+ ) as HostComponent<ModuleProps>;
602
+ `;
603
+
604
+ const OBJECT_PROP_TYPES_NO_EVENTS = `
605
+ /**
606
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
607
+ *
608
+ * This source code is licensed under the MIT license found in the
609
+ * LICENSE file in the root directory of this source tree.
610
+ *
611
+ * @format
612
+ */
613
+
614
+ 'use strict';
615
+
616
+ const codegenNativeComponent = require('codegenNativeComponent');
617
+
618
+ import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
619
+ import type {ImageSource} from 'ImageSource';
620
+ import type {
621
+ ColorValue,
622
+ ColorArrayValue,
623
+ PointValue,
624
+ EdgeInsetsValue,
625
+ } from 'StyleSheetTypes';
626
+ import type {ViewProps} from 'ViewPropTypes';
627
+ import type {HostComponent} from 'react-native';
628
+
629
+ export interface ModuleProps extends ViewProps {
630
+ // Props
631
+ // Boolean props
632
+ boolean_required: Readonly<{prop: boolean}>;
633
+ boolean_optional: Readonly<{prop?: WithDefault<boolean, false>}>;
634
+
635
+ // String props
636
+ string_required: Readonly<{prop: string}>;
637
+ string_optional: Readonly<{prop?: WithDefault<string, ''>}>;
638
+
639
+ // Double props
640
+ double_required: Readonly<{prop: Double}>;
641
+ double_optional: Readonly<{prop?: WithDefault<Double, 0.0>}>;
642
+
643
+ // Float props
644
+ float_required: Readonly<{prop: Float}>;
645
+ float_optional: Readonly<{prop?: WithDefault<Float, 0.0>}>;
646
+
647
+ // Int32 props
648
+ int_required: Readonly<{prop: Int32}>;
649
+ int_optional: Readonly<{prop?: WithDefault<Int32, 0>}>;
650
+
651
+ // String enum props
652
+ enum_optional: Readonly<{
653
+ prop?: WithDefault<ReadonlyArray<'small' | 'large'>, 'small'>;
654
+ }>;
655
+
656
+ // ImageSource props
657
+ image_required: Readonly<{prop: ImageSource}>;
658
+ image_optional_key: Readonly<{prop?: ImageSource}>;
659
+ image_optional_value: Readonly<{prop: ImageSource | null | undefined}>;
660
+ image_optional_both: Readonly<{prop?: ImageSource | null | undefined}>;
661
+
662
+ // ColorValue props
663
+ color_required: Readonly<{prop: ColorValue}>;
664
+ color_optional_key: Readonly<{prop?: ColorValue}>;
665
+ color_optional_value: Readonly<{prop: ColorValue | null | undefined}>;
666
+ color_optional_both: Readonly<{prop?: ColorValue | null | undefined}>;
667
+
668
+ // ProcessedColorValue props
669
+ processed_color_required: Readonly<{prop: ProcessedColorValue}>;
670
+ processed_color_optional_key: Readonly<{prop?: ProcessedColorValue}>;
671
+ processed_color_optional_value: Readonly<{
672
+ prop: ProcessedColorValue | null | undefined;
673
+ }>;
674
+ processed_color_optional_both: Readonly<{
675
+ prop?: ProcessedColorValue | null | undefined;
676
+ }>;
677
+
678
+ // PointValue props
679
+ point_required: Readonly<{prop: PointValue}>;
680
+ point_optional_key: Readonly<{prop?: PointValue}>;
681
+ point_optional_value: Readonly<{prop: PointValue | null | undefined}>;
682
+ point_optional_both: Readonly<{prop?: PointValue | null | undefined}>;
683
+
684
+ // EdgeInsetsValue props
685
+ insets_required: Readonly<{prop: EdgeInsetsValue}>;
686
+ insets_optional_key: Readonly<{prop?: EdgeInsetsValue}>;
687
+ insets_optional_value: Readonly<{prop: EdgeInsetsValue | null | undefined}>;
688
+ insets_optional_both: Readonly<{prop?: EdgeInsetsValue | null | undefined}>;
689
+
690
+ // Nested object props
691
+ object_required: Readonly<{prop: Readonly<{nestedProp: string}>}>;
692
+ object_optional_key?: Readonly<{prop: Readonly<{nestedProp: string}>}>;
693
+ object_optional_value: Readonly<{
694
+ prop: Readonly<{nestedProp: string}>;
695
+ }> | null | undefined;
696
+ object_optional_both?: Readonly<{
697
+ prop: Readonly<{nestedProp: string}>;
698
+ }> | null | undefined;
699
+ }
700
+
701
+ export default codegenNativeComponent<ModuleProps>(
702
+ 'Module',
703
+ ) as HostComponent<ModuleProps>;
704
+ `;
705
+
706
+ const PROPS_ALIASED_LOCALLY = `
707
+ /**
708
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
709
+ *
710
+ * This source code is licensed under the MIT license found in the
711
+ * LICENSE file in the root directory of this source tree.
712
+ *
713
+ * @format
714
+ */
715
+
716
+ 'use strict';
717
+
718
+ import type {ViewProps} from 'ViewPropTypes';
719
+ import type {HostComponent} from 'react-native';
720
+
721
+ const codegenNativeComponent = require('codegenNativeComponent');
722
+
723
+ type DeepSpread = Readonly<{
724
+ otherStringProp: string;
725
+ }>;
726
+
727
+ export interface PropsInFile extends DeepSpread {
728
+ isEnabled: boolean;
729
+ label: string;
730
+ }
731
+
732
+ type ReadOnlyPropsInFile = Readonly<PropsInFile>;
733
+
734
+ export interface ModuleProps extends ViewProps, ReadOnlyPropsInFile {
735
+ localType: ReadOnlyPropsInFile;
736
+ localArr: ReadonlyArray<ReadOnlyPropsInFile>;
737
+ }
738
+
739
+ export default codegenNativeComponent<ModuleProps>(
740
+ 'Module',
741
+ ) as HostComponent<ModuleProps>;
742
+ `;
743
+
744
+ const EVENTS_DEFINED_INLINE_WITH_ALL_TYPES = `
745
+ /**
746
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
747
+ *
748
+ * This source code is licensed under the MIT license found in the
749
+ * LICENSE file in the root directory of this source tree.
750
+ *
751
+ * @format
752
+ */
753
+
754
+ import type {HostComponent} from 'react-native';
755
+ const codegenNativeComponent = require('codegenNativeComponent');
756
+
757
+ import type {
758
+ Int32,
759
+ Double,
760
+ Float,
761
+ BubblingEventHandler,
762
+ DirectEventHandler,
763
+ } from 'CodegenTypes';
764
+
765
+ import type {ViewProps} from 'ViewPropTypes';
766
+
767
+ export interface ModuleProps extends ViewProps {
768
+ // No Props
769
+
770
+ // Events
771
+ onDirectEventDefinedInline: DirectEventHandler<
772
+ Readonly<{
773
+ ${EVENT_DEFINITION}
774
+ }>
775
+ >;
776
+
777
+ onDirectEventDefinedInlineOptionalKey?: (DirectEventHandler<
778
+ Readonly<{
779
+ ${EVENT_DEFINITION}
780
+ }>
781
+ >);
782
+
783
+ onDirectEventDefinedInlineOptionalValue: (DirectEventHandler<
784
+ Readonly<{
785
+ ${EVENT_DEFINITION}
786
+ }>
787
+ >) | null | undefined;
788
+
789
+ onDirectEventDefinedInlineOptionalBoth?: (DirectEventHandler<
790
+ Readonly<{
791
+ ${EVENT_DEFINITION}
792
+ }>
793
+ > | null | undefined);
794
+
795
+ onDirectEventDefinedInlineWithPaperName?: DirectEventHandler<
796
+ Readonly<{
797
+ ${EVENT_DEFINITION}
798
+ }>,
799
+ 'paperDirectEventDefinedInlineWithPaperName'
800
+ > | null | undefined;
801
+
802
+ onBubblingEventDefinedInline: BubblingEventHandler<
803
+ Readonly<{
804
+ ${EVENT_DEFINITION}
805
+ }>
806
+ >;
807
+
808
+ onBubblingEventDefinedInlineOptionalKey?: BubblingEventHandler<
809
+ Readonly<{
810
+ ${EVENT_DEFINITION}
811
+ }>
812
+ >;
813
+
814
+ onBubblingEventDefinedInlineOptionalValue: BubblingEventHandler<
815
+ Readonly<{
816
+ ${EVENT_DEFINITION}
817
+ }>
818
+ > | null | undefined;
819
+
820
+ onBubblingEventDefinedInlineOptionalBoth?: BubblingEventHandler<
821
+ Readonly<{
822
+ ${EVENT_DEFINITION}
823
+ }>
824
+ > | null | undefined;
825
+
826
+ onBubblingEventDefinedInlineWithPaperName?: BubblingEventHandler<
827
+ Readonly<{
828
+ ${EVENT_DEFINITION}
829
+ }>,
830
+ 'paperBubblingEventDefinedInlineWithPaperName'
831
+ > | null | undefined;
832
+ }
833
+
834
+ export default codegenNativeComponent<ModuleProps>(
835
+ 'Module',
836
+ ) as HostComponent<ModuleProps>;
837
+ `;
838
+
839
+ const EVENTS_DEFINED_AS_NULL_INLINE = `
840
+ /**
841
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
842
+ *
843
+ * This source code is licensed under the MIT license found in the
844
+ * LICENSE file in the root directory of this source tree.
845
+ *
846
+ * @format
847
+ */
848
+
849
+ 'use strict';
850
+
851
+ const codegenNativeComponent = require('codegenNativeComponent');
852
+
853
+ import type {BubblingEventHandler, DirectEventHandler} from 'CodegenTypese';
854
+ import type {ViewProps} from 'ViewPropTypes';
855
+ import type {HostComponent} from 'react-native';
856
+
857
+ export interface ModuleProps extends ViewProps {
858
+ // No props
859
+
860
+ // Events defined inline
861
+ onDirectEventDefinedInlineNull: DirectEventHandler<null>;
862
+ onDirectEventDefinedInlineNullOptionalKey?: DirectEventHandler<null>;
863
+ onDirectEventDefinedInlineNullOptionalValue: DirectEventHandler<null> | null | undefined;
864
+ onDirectEventDefinedInlineNullOptionalBoth?: DirectEventHandler<null>;
865
+ onDirectEventDefinedInlineNullWithPaperName?: DirectEventHandler<
866
+ null,
867
+ 'paperDirectEventDefinedInlineNullWithPaperName'
868
+ > | null | undefined;
869
+
870
+ onBubblingEventDefinedInlineNull: BubblingEventHandler<undefined>;
871
+ onBubblingEventDefinedInlineNullOptionalKey?: BubblingEventHandler<undefined>;
872
+ onBubblingEventDefinedInlineNullOptionalValue: BubblingEventHandler<undefined> | null | undefined;
873
+ onBubblingEventDefinedInlineNullOptionalBoth?: BubblingEventHandler<undefined> | null | undefined;
874
+ onBubblingEventDefinedInlineNullWithPaperName?: BubblingEventHandler<
875
+ undefined,
876
+ 'paperBubblingEventDefinedInlineNullWithPaperName'
877
+ > | null | undefined;
878
+ }
879
+
880
+ export default codegenNativeComponent<ModuleProps>(
881
+ 'Module',
882
+ ) as HostComponent<ModuleProps>;
883
+ `;
884
+
885
+ const PROPS_AND_EVENTS_TYPES_EXPORTED = `
886
+ /**
887
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
888
+ *
889
+ * This source code is licensed under the MIT license found in the
890
+ * LICENSE file in the root directory of this source tree.
891
+ *
892
+ * @format
893
+ */
894
+
895
+ const codegenNativeComponent = require('codegenNativeComponent');
896
+
897
+ import type {ViewProps} from 'ViewPropTypes';
898
+ import type {HostComponent} from 'react-native';
899
+ import type {
900
+ BubblingEventHandler,
901
+ DirectEventHandler,
902
+ } from 'CodegenTypes';
903
+
904
+ export type EventInFile = Readonly<{
905
+ ${EVENT_DEFINITION}
906
+ }>;
907
+
908
+ export interface ModuleProps extends ViewProps {
909
+ // No props
910
+
911
+ // Events defined inline
912
+ onBubblingEventDefinedInline: BubblingEventHandler<EventInFile>;
913
+ onBubblingEventDefinedInlineWithPaperName: BubblingEventHandler<
914
+ EventInFile,
915
+ 'paperBubblingEventDefinedInlineWithPaperName'
916
+ >;
917
+ onDirectEventDefinedInline: DirectEventHandler<EventInFile>;
918
+ onDirectEventDefinedInlineWithPaperName: DirectEventHandler<
919
+ EventInFile,
920
+ 'paperDirectEventDefinedInlineWithPaperName'
921
+ >;
922
+ }
923
+
924
+ export default codegenNativeComponent<ModuleProps>(
925
+ 'Module',
926
+ ) as HostComponent<ModuleProps>;
927
+ `;
928
+
929
+ const PROPS_AS_EXTERNAL_TYPES = `
930
+ /**
931
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
932
+ *
933
+ * This source code is licensed under the MIT license found in the
934
+ * LICENSE file in the root directory of this source tree.
935
+ *
936
+ * @format
937
+ */
938
+
939
+ const codegenNativeComponent = require('codegenNativeComponent');
940
+
941
+ import type {HostComponent} from 'react-native';
942
+
943
+ export type String = string;
944
+ export type AnotherArray = ReadonlyArray<String>;
945
+
946
+ export interface ModuleProps {
947
+ disable: String;
948
+ array: AnotherArray;
949
+ }
950
+
951
+ export default codegenNativeComponent<ModuleProps>(
952
+ 'Module',
953
+ ) as HostComponent<ModuleProps>;
954
+ `;
955
+
956
+ const COMMANDS_DEFINED_WITH_ALL_TYPES = `
957
+ /**
958
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
959
+ *
960
+ * This source code is licensed under the MIT license found in the
961
+ * LICENSE file in the root directory of this source tree.
962
+ *
963
+ * @format
964
+ */
965
+
966
+ const codegenNativeCommands = require('codegenNativeCommands');
967
+ const codegenNativeComponent = require('codegenNativeComponent');
968
+
969
+ import type {Int32, Double, Float} from 'CodegenTypes';
970
+ import type {RootTag} from 'RCTExport';
971
+ import type {ViewProps} from 'ViewPropTypes';
972
+ import type {HostComponent} from 'react-native';
973
+
974
+
975
+ export interface ModuleProps extends ViewProps {
976
+ // No props or events
977
+ }
978
+
979
+ type NativeType = HostComponent<ModuleProps>;
980
+
981
+ interface NativeCommands {
982
+ readonly handleRootTag: (viewRef: React.ElementRef<NativeType>, rootTag: RootTag) => void;
983
+ readonly hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void;
984
+ scrollTo(
985
+ viewRef: React.ElementRef<NativeType>,
986
+ x: Float,
987
+ y: Int32,
988
+ z: Double,
989
+ animated: boolean,
990
+ ): void;
991
+ }
992
+
993
+ export const Commands = codegenNativeCommands<NativeCommands>({
994
+ supportedCommands: ['handleRootTag', 'hotspotUpdate', 'scrollTo'],
995
+ });
996
+
997
+ export default codegenNativeComponent<ModuleProps>(
998
+ 'Module',
999
+ ) as NativeType;
1000
+ `;
1001
+
1002
+ const COMMANDS_WITH_EXTERNAL_TYPES = `
1003
+ /**
1004
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1005
+ *
1006
+ * This source code is licensed under the MIT license found in the
1007
+ * LICENSE file in the root directory of this source tree.
1008
+ *
1009
+ * @format
1010
+ */
1011
+
1012
+ const codegenNativeCommands = require('codegenNativeCommands');
1013
+ const codegenNativeComponent = require('codegenNativeComponent');
1014
+
1015
+ import type {Int32} from 'CodegenTypes';
1016
+ import type {ViewProps} from 'ViewPropTypes';
1017
+ import type {HostComponent} from 'react-native';
1018
+
1019
+ export type Boolean = boolean;
1020
+ export type Int = Int32;
1021
+ export type Void = void;
1022
+
1023
+ export interface ModuleProps extends ViewProps {
1024
+ // No props or events
1025
+ }
1026
+
1027
+ type NativeType = HostComponent<ModuleProps>;
1028
+
1029
+ export type ScrollTo = (
1030
+ viewRef: React.ElementRef<NativeType>,
1031
+ y: Int,
1032
+ animated: Boolean,
1033
+ ) => Void;
1034
+
1035
+ interface NativeCommands {
1036
+ readonly scrollTo: ScrollTo;
1037
+ }
1038
+
1039
+ export const Commands = codegenNativeCommands<NativeCommands>({
1040
+ supportedCommands: ['scrollTo'],
1041
+ });
1042
+
1043
+ export default codegenNativeComponent<ModuleProps>('Module') as NativeType;
1044
+
1045
+ `;
1046
+
1047
+ const COMMANDS_EVENTS_TYPES_EXPORTED = `
1048
+ /**
1049
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1050
+ *
1051
+ * This source code is licensed under the MIT license found in the
1052
+ * LICENSE file in the root directory of this source tree.
1053
+ *
1054
+ * @format
1055
+ */
1056
+
1057
+ import type {
1058
+ BubblingEventHandler,
1059
+ DirectEventHandler,
1060
+ } from 'CodegenTypes';
1061
+ import type {ViewProps} from 'ViewPropTypes';
1062
+ import type {HostComponent} from 'react-native';
1063
+
1064
+ const codegenNativeComponent = require('codegenNativeComponent');
1065
+
1066
+ export type EventInFile = Readonly<{
1067
+ ${EVENT_DEFINITION}
1068
+ }>;
1069
+
1070
+ export type Boolean = boolean;
1071
+ export type Int = Int32;
1072
+ export type Void = void;
1073
+
1074
+ export interface ModuleProps extends ViewProps {
1075
+ // No props
1076
+
1077
+ // Events defined inline
1078
+ onBubblingEventDefinedInline: BubblingEventHandler<EventInFile>,
1079
+ onBubblingEventDefinedInlineWithPaperName: BubblingEventHandler<EventInFile, 'paperBubblingEventDefinedInlineWithPaperName'>,
1080
+ onDirectEventDefinedInline: DirectEventHandler<EventInFile>,
1081
+ onDirectEventDefinedInlineWithPaperName: DirectEventHandler<EventInFile, 'paperDirectEventDefinedInlineWithPaperName'>,
1082
+ }
1083
+
1084
+ // Add state here
1085
+ export interface ModuleNativeState {
1086
+ boolean_required: boolean,
1087
+ boolean_optional_key?: WithDefault<boolean, true>,
1088
+ boolean_optional_both?: WithDefault<boolean, true>,
1089
+ }
1090
+
1091
+ type NativeType = HostComponent<ModuleProps>;
1092
+
1093
+ export type ScrollTo = (viewRef: React.ElementRef<NativeType>, y: Int, animated: Boolean) => Void;
1094
+
1095
+ interface NativeCommands {
1096
+ readonly scrollTo: ScrollTo;
1097
+ }
1098
+
1099
+ export const Commands = codegenNativeCommands<NativeCommands>({
1100
+ supportedCommands: ['scrollTo']
1101
+ });
1102
+
1103
+ export default codegenNativeComponent<ModuleProps>(
1104
+ 'Module',
1105
+ ) as NativeType;
1106
+ `;
1107
+
1108
+ const PROPS_AND_EVENTS_WITH_INTERFACES = `
1109
+ import type {
1110
+ BubblingEventHandler,
1111
+ DirectEventHandler,
1112
+ Int32,
1113
+ } from 'CodegenTypes';
1114
+ import type {ViewProps} from 'ViewPropTypes';
1115
+ import type {HostComponent} from 'react-native';
1116
+
1117
+ const codegenNativeComponent = require('codegenNativeComponent');
1118
+
1119
+ export interface Base1 {
1120
+ readonly x: string;
1121
+ }
1122
+
1123
+ export interface Base2 {
1124
+ readonly y: Int32;
1125
+ }
1126
+
1127
+ export interface Derived extends Base1, Base2 {
1128
+ readonly z: boolean;
1129
+ }
1130
+
1131
+ export interface ModuleProps extends ViewProps {
1132
+ // Props
1133
+ ordinary_prop: Derived;
1134
+ readonly_prop: Readonly<Derived>;
1135
+ ordinary_array_prop?: readonly Derived[];
1136
+ readonly_array_prop?: readonly Readonly<Derived>[];
1137
+ ordinary_nested_array_prop?: readonly Derived[][];
1138
+ readonly_nested_array_prop?: readonly Readonly<Derived>[][];
1139
+
1140
+ // Events
1141
+ onDirect: DirectEventHandler<Derived>;
1142
+ onBubbling: BubblingEventHandler<Readonly<Derived>>;
1143
+ }
1144
+
1145
+ export default codegenNativeComponent<ModuleProps>('Module', {
1146
+ interfaceOnly: true,
1147
+ paperComponentName: 'RCTModule',
1148
+ }) as HostComponent<ModuleProps>;
1149
+ `;
1150
+
1151
+ module.exports = {
1152
+ ALL_PROP_TYPES_NO_EVENTS,
1153
+ ARRAY_PROP_TYPES_NO_EVENTS,
1154
+ ARRAY2_PROP_TYPES_NO_EVENTS,
1155
+ OBJECT_PROP_TYPES_NO_EVENTS,
1156
+ PROPS_ALIASED_LOCALLY,
1157
+ ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS,
1158
+ ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS_NO_CAST,
1159
+ NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION,
1160
+ EVENTS_DEFINED_INLINE_WITH_ALL_TYPES,
1161
+ EVENTS_DEFINED_AS_NULL_INLINE,
1162
+ PROPS_AND_EVENTS_TYPES_EXPORTED,
1163
+ COMMANDS_EVENTS_TYPES_EXPORTED,
1164
+ COMMANDS_DEFINED_WITH_ALL_TYPES,
1165
+ PROPS_AS_EXTERNAL_TYPES,
1166
+ COMMANDS_WITH_EXTERNAL_TYPES,
1167
+ PROPS_AND_EVENTS_WITH_INTERFACES,
1168
+ };