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