@react-native/codegen 0.72.4 → 0.73.0-nightly-20230603-fd9e295be
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.
- package/README.md +2 -2
- package/lib/CodegenSchema.d.ts +15 -4
- package/lib/CodegenSchema.js.flow +33 -21
- package/lib/generators/components/CppHelpers.js +39 -2
- package/lib/generators/components/CppHelpers.js.flow +54 -5
- package/lib/generators/components/GenerateEventEmitterCpp.js +238 -55
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +233 -55
- package/lib/generators/components/GenerateEventEmitterH.js +77 -28
- package/lib/generators/components/GenerateEventEmitterH.js.flow +87 -32
- package/lib/generators/components/GeneratePropsH.js +1 -2
- package/lib/generators/components/GeneratePropsH.js.flow +1 -2
- package/lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js +0 -1
- package/lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js.flow +3 -5
- package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js +4 -0
- package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js.flow +4 -0
- package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js +2 -0
- package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js.flow +2 -0
- package/lib/generators/components/__test_fixtures__/fixtures.js +114 -1
- package/lib/generators/components/__test_fixtures__/fixtures.js.flow +114 -1
- package/lib/generators/modules/GenerateModuleCpp.js +3 -3
- package/lib/generators/modules/GenerateModuleCpp.js.flow +3 -3
- package/lib/generators/modules/GenerateModuleH.js +1 -1
- package/lib/generators/modules/GenerateModuleH.js.flow +1 -1
- package/lib/generators/modules/GenerateModuleJavaSpec.js +1 -2
- package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +1 -2
- package/lib/parsers/error-utils.js +44 -0
- package/lib/parsers/error-utils.js.flow +59 -0
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js +51 -0
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow +51 -0
- package/lib/parsers/flow/components/componentsUtils.js +6 -6
- package/lib/parsers/flow/components/componentsUtils.js.flow +10 -10
- package/lib/parsers/flow/components/events.js +157 -78
- package/lib/parsers/flow/components/events.js.flow +158 -77
- package/lib/parsers/flow/components/index.js +28 -105
- package/lib/parsers/flow/components/index.js.flow +21 -110
- package/lib/parsers/flow/modules/index.js +39 -49
- package/lib/parsers/flow/modules/index.js.flow +22 -31
- package/lib/parsers/flow/parser.d.ts +9 -2
- package/lib/parsers/flow/parser.js +167 -16
- package/lib/parsers/flow/parser.js.flow +209 -6
- package/lib/parsers/flow/utils.js +0 -63
- package/lib/parsers/flow/utils.js.flow +1 -77
- package/lib/parsers/parser.js.flow +141 -1
- package/lib/parsers/parserMock.js +165 -2
- package/lib/parsers/parserMock.js.flow +216 -2
- package/lib/parsers/parsers-commons.js +128 -9
- package/lib/parsers/parsers-commons.js.flow +182 -12
- package/lib/parsers/parsers-primitives.js +84 -35
- package/lib/parsers/parsers-primitives.js.flow +110 -35
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js +51 -0
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow +51 -0
- package/lib/parsers/typescript/components/componentsUtils.js +31 -7
- package/lib/parsers/typescript/components/componentsUtils.js.flow +31 -14
- package/lib/parsers/typescript/components/events.js +142 -67
- package/lib/parsers/typescript/components/events.js.flow +149 -68
- package/lib/parsers/typescript/components/extends.js +2 -49
- package/lib/parsers/typescript/components/extends.js.flow +1 -55
- package/lib/parsers/typescript/components/index.js +29 -109
- package/lib/parsers/typescript/components/index.js.flow +21 -116
- package/lib/parsers/typescript/modules/index.js +41 -50
- package/lib/parsers/typescript/modules/index.js.flow +23 -31
- package/lib/parsers/typescript/parser.d.ts +9 -2
- package/lib/parsers/typescript/parser.js +193 -7
- package/lib/parsers/typescript/parser.js.flow +235 -6
- package/lib/parsers/utils.js.flow +6 -0
- package/package.json +26 -15
- package/lib/parsers/flow/components/extends.js +0 -52
- package/lib/parsers/flow/components/extends.js.flow +0 -66
- package/lib/parsers/flow/components/props.js +0 -47
- package/lib/parsers/flow/components/props.js.flow +0 -60
- package/lib/parsers/typescript/components/props.js +0 -39
- package/lib/parsers/typescript/components/props.js.flow +0 -48
- package/lib/parsers/typescript/utils.js +0 -90
- package/lib/parsers/typescript/utils.js.flow +0 -104
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
const nullthrows = require('nullthrows');
|
|
14
14
|
|
|
15
15
|
const {
|
|
16
|
+
getImports,
|
|
17
|
+
getCppArrayTypeForAnnotation,
|
|
16
18
|
getCppTypeForAnnotation,
|
|
17
19
|
generateEventStructName,
|
|
18
20
|
} = require('./CppHelpers');
|
|
@@ -35,7 +37,13 @@ type ComponentCollection = $ReadOnly<{
|
|
|
35
37
|
...
|
|
36
38
|
}>;
|
|
37
39
|
|
|
38
|
-
const FileTemplate = ({
|
|
40
|
+
const FileTemplate = ({
|
|
41
|
+
componentEmitters,
|
|
42
|
+
extraIncludes,
|
|
43
|
+
}: {
|
|
44
|
+
componentEmitters: string,
|
|
45
|
+
extraIncludes: Set<string>,
|
|
46
|
+
}) => `
|
|
39
47
|
/**
|
|
40
48
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
41
49
|
*
|
|
@@ -47,13 +55,11 @@ const FileTemplate = ({componentEmitters}: {componentEmitters: string}) => `
|
|
|
47
55
|
#pragma once
|
|
48
56
|
|
|
49
57
|
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
50
|
-
|
|
58
|
+
${[...extraIncludes].join('\n')}
|
|
51
59
|
|
|
52
60
|
namespace facebook {
|
|
53
61
|
namespace react {
|
|
54
|
-
|
|
55
62
|
${componentEmitters}
|
|
56
|
-
|
|
57
63
|
} // namespace react
|
|
58
64
|
} // namespace facebook
|
|
59
65
|
`;
|
|
@@ -68,12 +74,11 @@ const ComponentTemplate = ({
|
|
|
68
74
|
events: string,
|
|
69
75
|
}) =>
|
|
70
76
|
`
|
|
71
|
-
class
|
|
77
|
+
class ${className}EventEmitter : public ViewEventEmitter {
|
|
72
78
|
public:
|
|
73
79
|
using ViewEventEmitter::ViewEventEmitter;
|
|
74
80
|
|
|
75
81
|
${structs}
|
|
76
|
-
|
|
77
82
|
${events}
|
|
78
83
|
};
|
|
79
84
|
`.trim();
|
|
@@ -124,11 +129,22 @@ function getNativeTypeFromAnnotation(
|
|
|
124
129
|
case 'Int32TypeAnnotation':
|
|
125
130
|
case 'DoubleTypeAnnotation':
|
|
126
131
|
case 'FloatTypeAnnotation':
|
|
132
|
+
case 'MixedTypeAnnotation':
|
|
127
133
|
return getCppTypeForAnnotation(type);
|
|
128
134
|
case 'StringEnumTypeAnnotation':
|
|
129
|
-
return generateEventStructName(nameParts.concat([eventProperty.name]));
|
|
130
135
|
case 'ObjectTypeAnnotation':
|
|
131
|
-
return generateEventStructName(nameParts
|
|
136
|
+
return generateEventStructName([...nameParts, eventProperty.name]);
|
|
137
|
+
case 'ArrayTypeAnnotation':
|
|
138
|
+
const eventTypeAnnotation = eventProperty.typeAnnotation;
|
|
139
|
+
if (eventTypeAnnotation.type !== 'ArrayTypeAnnotation') {
|
|
140
|
+
throw new Error(
|
|
141
|
+
"Inconsistent Codegen state: type was ArrayTypeAnnotation at the beginning of the body and now it isn't",
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
return getCppArrayTypeForAnnotation(eventTypeAnnotation.elementType, [
|
|
145
|
+
...nameParts,
|
|
146
|
+
eventProperty.name,
|
|
147
|
+
]);
|
|
132
148
|
default:
|
|
133
149
|
(type: empty);
|
|
134
150
|
throw new Error(`Received invalid event property type ${type}`);
|
|
@@ -161,6 +177,33 @@ function generateEnum(
|
|
|
161
177
|
);
|
|
162
178
|
}
|
|
163
179
|
|
|
180
|
+
function handleGenerateStructForArray(
|
|
181
|
+
structs: StructsMap,
|
|
182
|
+
name: string,
|
|
183
|
+
componentName: string,
|
|
184
|
+
elementType: EventTypeAnnotation,
|
|
185
|
+
nameParts: $ReadOnlyArray<string>,
|
|
186
|
+
): void {
|
|
187
|
+
if (elementType.type === 'ObjectTypeAnnotation') {
|
|
188
|
+
generateStruct(
|
|
189
|
+
structs,
|
|
190
|
+
componentName,
|
|
191
|
+
nameParts.concat([name]),
|
|
192
|
+
nullthrows(elementType.properties),
|
|
193
|
+
);
|
|
194
|
+
} else if (elementType.type === 'StringEnumTypeAnnotation') {
|
|
195
|
+
generateEnum(structs, elementType.options, nameParts.concat([name]));
|
|
196
|
+
} else if (elementType.type === 'ArrayTypeAnnotation') {
|
|
197
|
+
handleGenerateStructForArray(
|
|
198
|
+
structs,
|
|
199
|
+
name,
|
|
200
|
+
componentName,
|
|
201
|
+
elementType.elementType,
|
|
202
|
+
nameParts,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
164
207
|
function generateStruct(
|
|
165
208
|
structs: StructsMap,
|
|
166
209
|
componentName: string,
|
|
@@ -184,14 +227,20 @@ function generateStruct(
|
|
|
184
227
|
const {name, typeAnnotation} = property;
|
|
185
228
|
switch (typeAnnotation.type) {
|
|
186
229
|
case 'BooleanTypeAnnotation':
|
|
187
|
-
return;
|
|
188
230
|
case 'StringTypeAnnotation':
|
|
189
|
-
return;
|
|
190
231
|
case 'Int32TypeAnnotation':
|
|
191
|
-
return;
|
|
192
232
|
case 'DoubleTypeAnnotation':
|
|
193
|
-
return;
|
|
194
233
|
case 'FloatTypeAnnotation':
|
|
234
|
+
case 'MixedTypeAnnotation':
|
|
235
|
+
return;
|
|
236
|
+
case 'ArrayTypeAnnotation':
|
|
237
|
+
handleGenerateStructForArray(
|
|
238
|
+
structs,
|
|
239
|
+
name,
|
|
240
|
+
componentName,
|
|
241
|
+
typeAnnotation.elementType,
|
|
242
|
+
nameParts,
|
|
243
|
+
);
|
|
195
244
|
return;
|
|
196
245
|
case 'ObjectTypeAnnotation':
|
|
197
246
|
generateStruct(
|
|
@@ -270,7 +319,7 @@ module.exports = {
|
|
|
270
319
|
.map(moduleName => {
|
|
271
320
|
const module = schema.modules[moduleName];
|
|
272
321
|
if (module.type !== 'Component') {
|
|
273
|
-
return;
|
|
322
|
+
return null;
|
|
274
323
|
}
|
|
275
324
|
|
|
276
325
|
const {components} = module;
|
|
@@ -284,29 +333,35 @@ module.exports = {
|
|
|
284
333
|
.filter(Boolean)
|
|
285
334
|
.reduce((acc, components) => Object.assign(acc, components), {});
|
|
286
335
|
|
|
287
|
-
const
|
|
336
|
+
const extraIncludes = new Set<string>();
|
|
337
|
+
const componentEmitters = Object.keys(moduleComponents)
|
|
338
|
+
.map(componentName => {
|
|
339
|
+
const component = moduleComponents[componentName];
|
|
340
|
+
|
|
341
|
+
component.events.forEach(event => {
|
|
342
|
+
if (event.typeAnnotation.argument) {
|
|
343
|
+
const argIncludes = getImports(
|
|
344
|
+
event.typeAnnotation.argument.properties,
|
|
345
|
+
);
|
|
346
|
+
// $FlowFixMe[method-unbinding]
|
|
347
|
+
argIncludes.forEach(extraIncludes.add, extraIncludes);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
const replacedTemplate = ComponentTemplate({
|
|
352
|
+
className: componentName,
|
|
353
|
+
structs: indent(generateStructs(componentName, component), 2),
|
|
354
|
+
events: generateEvents(componentName, component),
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
return replacedTemplate;
|
|
358
|
+
})
|
|
359
|
+
.join('\n');
|
|
288
360
|
|
|
289
361
|
const fileName = 'EventEmitters.h';
|
|
290
|
-
|
|
291
|
-
const componentEmitters =
|
|
292
|
-
moduleComponentsWithEvents.length > 0
|
|
293
|
-
? Object.keys(moduleComponents)
|
|
294
|
-
.map(componentName => {
|
|
295
|
-
const component = moduleComponents[componentName];
|
|
296
|
-
|
|
297
|
-
const replacedTemplate = ComponentTemplate({
|
|
298
|
-
className: componentName,
|
|
299
|
-
structs: indent(generateStructs(componentName, component), 2),
|
|
300
|
-
events: generateEvents(componentName, component),
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
return replacedTemplate;
|
|
304
|
-
})
|
|
305
|
-
.join('\n')
|
|
306
|
-
: '';
|
|
307
|
-
|
|
308
362
|
const replacedTemplate = FileTemplate({
|
|
309
363
|
componentEmitters,
|
|
364
|
+
extraIncludes,
|
|
310
365
|
});
|
|
311
366
|
|
|
312
367
|
return new Map([[fileName, replacedTemplate]]);
|
|
@@ -46,7 +46,7 @@ const ClassTemplate = ({enums, structs, className, props, extendClasses}) =>
|
|
|
46
46
|
`
|
|
47
47
|
${enums}
|
|
48
48
|
${structs}
|
|
49
|
-
class
|
|
49
|
+
class ${className} final${extendClasses} {
|
|
50
50
|
public:
|
|
51
51
|
${className}() = default;
|
|
52
52
|
${className}(const PropsParserContext& context, const ${className} &sourceProps, const RawProps &rawProps);
|
|
@@ -346,7 +346,6 @@ function generatePropsString(componentName, props) {
|
|
|
346
346
|
function getExtendsImports(extendsProps) {
|
|
347
347
|
const imports = new Set();
|
|
348
348
|
imports.add('#include <react/renderer/core/PropsParserContext.h>');
|
|
349
|
-
imports.add('#include <jsi/jsi.h>');
|
|
350
349
|
extendsProps.forEach(extendProps => {
|
|
351
350
|
switch (extendProps.type) {
|
|
352
351
|
case 'ReactNativeBuiltInType':
|
|
@@ -80,7 +80,7 @@ const ClassTemplate = ({
|
|
|
80
80
|
`
|
|
81
81
|
${enums}
|
|
82
82
|
${structs}
|
|
83
|
-
class
|
|
83
|
+
class ${className} final${extendClasses} {
|
|
84
84
|
public:
|
|
85
85
|
${className}() = default;
|
|
86
86
|
${className}(const PropsParserContext& context, const ${className} &sourceProps, const RawProps &rawProps);
|
|
@@ -478,7 +478,6 @@ function getExtendsImports(
|
|
|
478
478
|
const imports: Set<string> = new Set();
|
|
479
479
|
|
|
480
480
|
imports.add('#include <react/renderer/core/PropsParserContext.h>');
|
|
481
|
-
imports.add('#include <jsi/jsi.h>');
|
|
482
481
|
|
|
483
482
|
extendsProps.forEach(extendProps => {
|
|
484
483
|
switch (extendProps.type) {
|
|
@@ -89,7 +89,6 @@ class PojoCollector {
|
|
|
89
89
|
}
|
|
90
90
|
case 'ArrayTypeAnnotation': {
|
|
91
91
|
const arrayTypeAnnotation = typeAnnotation;
|
|
92
|
-
// TODO: Flow assumes elementType can be any. Fix this.
|
|
93
92
|
const elementType = arrayTypeAnnotation.elementType;
|
|
94
93
|
const pojoElementType = (() => {
|
|
95
94
|
switch (elementType.type) {
|
|
@@ -21,6 +21,7 @@ import type {
|
|
|
21
21
|
Int32TypeAnnotation,
|
|
22
22
|
PropTypeAnnotation,
|
|
23
23
|
MixedTypeAnnotation,
|
|
24
|
+
ArrayTypeAnnotation,
|
|
24
25
|
} from '../../../CodegenSchema';
|
|
25
26
|
|
|
26
27
|
const {capitalize} = require('../../Utils');
|
|
@@ -110,11 +111,8 @@ class PojoCollector {
|
|
|
110
111
|
}
|
|
111
112
|
case 'ArrayTypeAnnotation': {
|
|
112
113
|
const arrayTypeAnnotation = typeAnnotation;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
typeof arrayTypeAnnotation,
|
|
116
|
-
'elementType',
|
|
117
|
-
> = arrayTypeAnnotation.elementType;
|
|
114
|
+
const elementType: $PropertyType<ArrayTypeAnnotation, 'elementType'> =
|
|
115
|
+
arrayTypeAnnotation.elementType;
|
|
118
116
|
|
|
119
117
|
const pojoElementType = (() => {
|
|
120
118
|
switch (elementType.type) {
|
|
@@ -31,7 +31,9 @@ const FileTemplate = ({lookupMap}) => `
|
|
|
31
31
|
|
|
32
32
|
Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) {
|
|
33
33
|
static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = {
|
|
34
|
+
#ifndef RCT_DYNAMIC_FRAMEWORKS
|
|
34
35
|
${lookupMap}
|
|
36
|
+
#endif
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
auto p = sFabricComponentsClassMap.find(name);
|
|
@@ -34,7 +34,9 @@ const FileTemplate = ({lookupMap}: {lookupMap: string}) => `
|
|
|
34
34
|
|
|
35
35
|
Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) {
|
|
36
36
|
static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = {
|
|
37
|
+
#ifndef RCT_DYNAMIC_FRAMEWORKS
|
|
37
38
|
${lookupMap}
|
|
39
|
+
#endif
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
auto p = sFabricComponentsClassMap.find(name);
|
|
@@ -119,7 +119,7 @@ const EVENTS_WITH_PAPER_NAME = {
|
|
|
119
119
|
},
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
|
-
name: '
|
|
122
|
+
name: 'onDirectChange',
|
|
123
123
|
paperTopLevelNameDeprecated: 'paperDirectChange',
|
|
124
124
|
optional: true,
|
|
125
125
|
bubblingType: 'direct',
|
|
@@ -1184,6 +1184,99 @@ const EVENT_PROPS = {
|
|
|
1184
1184
|
},
|
|
1185
1185
|
},
|
|
1186
1186
|
},
|
|
1187
|
+
{
|
|
1188
|
+
name: 'onArrayEventType',
|
|
1189
|
+
optional: true,
|
|
1190
|
+
bubblingType: 'bubble',
|
|
1191
|
+
typeAnnotation: {
|
|
1192
|
+
type: 'EventTypeAnnotation',
|
|
1193
|
+
argument: {
|
|
1194
|
+
type: 'ObjectTypeAnnotation',
|
|
1195
|
+
properties: [
|
|
1196
|
+
{
|
|
1197
|
+
name: 'bool_array_event_prop',
|
|
1198
|
+
optional: false,
|
|
1199
|
+
typeAnnotation: {
|
|
1200
|
+
type: 'ArrayTypeAnnotation',
|
|
1201
|
+
elementType: {
|
|
1202
|
+
type: 'BooleanTypeAnnotation',
|
|
1203
|
+
},
|
|
1204
|
+
},
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
name: 'string_enum_event_prop',
|
|
1208
|
+
optional: false,
|
|
1209
|
+
typeAnnotation: {
|
|
1210
|
+
type: 'ArrayTypeAnnotation',
|
|
1211
|
+
elementType: {
|
|
1212
|
+
type: 'StringEnumTypeAnnotation',
|
|
1213
|
+
options: ['YES', 'NO'],
|
|
1214
|
+
},
|
|
1215
|
+
},
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
name: 'array_array_event_prop',
|
|
1219
|
+
optional: false,
|
|
1220
|
+
typeAnnotation: {
|
|
1221
|
+
type: 'ArrayTypeAnnotation',
|
|
1222
|
+
elementType: {
|
|
1223
|
+
type: 'ArrayTypeAnnotation',
|
|
1224
|
+
elementType: {
|
|
1225
|
+
type: 'StringTypeAnnotation',
|
|
1226
|
+
},
|
|
1227
|
+
},
|
|
1228
|
+
},
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
name: 'array_object_event_prop',
|
|
1232
|
+
optional: false,
|
|
1233
|
+
typeAnnotation: {
|
|
1234
|
+
type: 'ArrayTypeAnnotation',
|
|
1235
|
+
elementType: {
|
|
1236
|
+
type: 'ObjectTypeAnnotation',
|
|
1237
|
+
properties: [
|
|
1238
|
+
{
|
|
1239
|
+
name: 'lat',
|
|
1240
|
+
optional: false,
|
|
1241
|
+
typeAnnotation: {
|
|
1242
|
+
type: 'DoubleTypeAnnotation',
|
|
1243
|
+
},
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
name: 'lon',
|
|
1247
|
+
optional: false,
|
|
1248
|
+
typeAnnotation: {
|
|
1249
|
+
type: 'DoubleTypeAnnotation',
|
|
1250
|
+
},
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
name: 'names',
|
|
1254
|
+
optional: false,
|
|
1255
|
+
typeAnnotation: {
|
|
1256
|
+
type: 'ArrayTypeAnnotation',
|
|
1257
|
+
elementType: {
|
|
1258
|
+
type: 'StringTypeAnnotation',
|
|
1259
|
+
},
|
|
1260
|
+
},
|
|
1261
|
+
},
|
|
1262
|
+
],
|
|
1263
|
+
},
|
|
1264
|
+
},
|
|
1265
|
+
},
|
|
1266
|
+
{
|
|
1267
|
+
name: 'array_mixed_event_prop',
|
|
1268
|
+
optional: false,
|
|
1269
|
+
typeAnnotation: {
|
|
1270
|
+
type: 'ArrayTypeAnnotation',
|
|
1271
|
+
elementType: {
|
|
1272
|
+
type: 'MixedTypeAnnotation',
|
|
1273
|
+
},
|
|
1274
|
+
},
|
|
1275
|
+
},
|
|
1276
|
+
],
|
|
1277
|
+
},
|
|
1278
|
+
},
|
|
1279
|
+
},
|
|
1187
1280
|
{
|
|
1188
1281
|
name: 'onEventDirect',
|
|
1189
1282
|
optional: true,
|
|
@@ -1233,6 +1326,26 @@ const EVENT_PROPS = {
|
|
|
1233
1326
|
type: 'EventTypeAnnotation',
|
|
1234
1327
|
},
|
|
1235
1328
|
},
|
|
1329
|
+
{
|
|
1330
|
+
name: 'onEventWithMixedPropAttribute',
|
|
1331
|
+
optional: true,
|
|
1332
|
+
bubblingType: 'direct',
|
|
1333
|
+
typeAnnotation: {
|
|
1334
|
+
type: 'EventTypeAnnotation',
|
|
1335
|
+
argument: {
|
|
1336
|
+
type: 'ObjectTypeAnnotation',
|
|
1337
|
+
properties: [
|
|
1338
|
+
{
|
|
1339
|
+
name: 'value',
|
|
1340
|
+
optional: false,
|
|
1341
|
+
typeAnnotation: {
|
|
1342
|
+
type: 'MixedTypeAnnotation',
|
|
1343
|
+
},
|
|
1344
|
+
},
|
|
1345
|
+
],
|
|
1346
|
+
},
|
|
1347
|
+
},
|
|
1348
|
+
},
|
|
1236
1349
|
],
|
|
1237
1350
|
props: [
|
|
1238
1351
|
{
|
|
@@ -123,7 +123,7 @@ const EVENTS_WITH_PAPER_NAME: SchemaType = {
|
|
|
123
123
|
},
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
|
-
name: '
|
|
126
|
+
name: 'onDirectChange',
|
|
127
127
|
paperTopLevelNameDeprecated: 'paperDirectChange',
|
|
128
128
|
optional: true,
|
|
129
129
|
bubblingType: 'direct',
|
|
@@ -1206,6 +1206,99 @@ const EVENT_PROPS: SchemaType = {
|
|
|
1206
1206
|
},
|
|
1207
1207
|
},
|
|
1208
1208
|
},
|
|
1209
|
+
{
|
|
1210
|
+
name: 'onArrayEventType',
|
|
1211
|
+
optional: true,
|
|
1212
|
+
bubblingType: 'bubble',
|
|
1213
|
+
typeAnnotation: {
|
|
1214
|
+
type: 'EventTypeAnnotation',
|
|
1215
|
+
argument: {
|
|
1216
|
+
type: 'ObjectTypeAnnotation',
|
|
1217
|
+
properties: [
|
|
1218
|
+
{
|
|
1219
|
+
name: 'bool_array_event_prop',
|
|
1220
|
+
optional: false,
|
|
1221
|
+
typeAnnotation: {
|
|
1222
|
+
type: 'ArrayTypeAnnotation',
|
|
1223
|
+
elementType: {
|
|
1224
|
+
type: 'BooleanTypeAnnotation',
|
|
1225
|
+
},
|
|
1226
|
+
},
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
name: 'string_enum_event_prop',
|
|
1230
|
+
optional: false,
|
|
1231
|
+
typeAnnotation: {
|
|
1232
|
+
type: 'ArrayTypeAnnotation',
|
|
1233
|
+
elementType: {
|
|
1234
|
+
type: 'StringEnumTypeAnnotation',
|
|
1235
|
+
options: ['YES', 'NO'],
|
|
1236
|
+
},
|
|
1237
|
+
},
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
name: 'array_array_event_prop',
|
|
1241
|
+
optional: false,
|
|
1242
|
+
typeAnnotation: {
|
|
1243
|
+
type: 'ArrayTypeAnnotation',
|
|
1244
|
+
elementType: {
|
|
1245
|
+
type: 'ArrayTypeAnnotation',
|
|
1246
|
+
elementType: {
|
|
1247
|
+
type: 'StringTypeAnnotation',
|
|
1248
|
+
},
|
|
1249
|
+
},
|
|
1250
|
+
},
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
name: 'array_object_event_prop',
|
|
1254
|
+
optional: false,
|
|
1255
|
+
typeAnnotation: {
|
|
1256
|
+
type: 'ArrayTypeAnnotation',
|
|
1257
|
+
elementType: {
|
|
1258
|
+
type: 'ObjectTypeAnnotation',
|
|
1259
|
+
properties: [
|
|
1260
|
+
{
|
|
1261
|
+
name: 'lat',
|
|
1262
|
+
optional: false,
|
|
1263
|
+
typeAnnotation: {
|
|
1264
|
+
type: 'DoubleTypeAnnotation',
|
|
1265
|
+
},
|
|
1266
|
+
},
|
|
1267
|
+
{
|
|
1268
|
+
name: 'lon',
|
|
1269
|
+
optional: false,
|
|
1270
|
+
typeAnnotation: {
|
|
1271
|
+
type: 'DoubleTypeAnnotation',
|
|
1272
|
+
},
|
|
1273
|
+
},
|
|
1274
|
+
{
|
|
1275
|
+
name: 'names',
|
|
1276
|
+
optional: false,
|
|
1277
|
+
typeAnnotation: {
|
|
1278
|
+
type: 'ArrayTypeAnnotation',
|
|
1279
|
+
elementType: {
|
|
1280
|
+
type: 'StringTypeAnnotation',
|
|
1281
|
+
},
|
|
1282
|
+
},
|
|
1283
|
+
},
|
|
1284
|
+
],
|
|
1285
|
+
},
|
|
1286
|
+
},
|
|
1287
|
+
},
|
|
1288
|
+
{
|
|
1289
|
+
name: 'array_mixed_event_prop',
|
|
1290
|
+
optional: false,
|
|
1291
|
+
typeAnnotation: {
|
|
1292
|
+
type: 'ArrayTypeAnnotation',
|
|
1293
|
+
elementType: {
|
|
1294
|
+
type: 'MixedTypeAnnotation',
|
|
1295
|
+
},
|
|
1296
|
+
},
|
|
1297
|
+
},
|
|
1298
|
+
],
|
|
1299
|
+
},
|
|
1300
|
+
},
|
|
1301
|
+
},
|
|
1209
1302
|
{
|
|
1210
1303
|
name: 'onEventDirect',
|
|
1211
1304
|
optional: true,
|
|
@@ -1255,6 +1348,26 @@ const EVENT_PROPS: SchemaType = {
|
|
|
1255
1348
|
type: 'EventTypeAnnotation',
|
|
1256
1349
|
},
|
|
1257
1350
|
},
|
|
1351
|
+
{
|
|
1352
|
+
name: 'onEventWithMixedPropAttribute',
|
|
1353
|
+
optional: true,
|
|
1354
|
+
bubblingType: 'direct',
|
|
1355
|
+
typeAnnotation: {
|
|
1356
|
+
type: 'EventTypeAnnotation',
|
|
1357
|
+
argument: {
|
|
1358
|
+
type: 'ObjectTypeAnnotation',
|
|
1359
|
+
properties: [
|
|
1360
|
+
{
|
|
1361
|
+
name: 'value',
|
|
1362
|
+
optional: false,
|
|
1363
|
+
typeAnnotation: {
|
|
1364
|
+
type: 'MixedTypeAnnotation',
|
|
1365
|
+
},
|
|
1366
|
+
},
|
|
1367
|
+
],
|
|
1368
|
+
},
|
|
1369
|
+
},
|
|
1370
|
+
},
|
|
1258
1371
|
],
|
|
1259
1372
|
props: [
|
|
1260
1373
|
{
|
|
@@ -91,8 +91,8 @@ const HostFunctionTemplate = ({
|
|
|
91
91
|
}) => {
|
|
92
92
|
const isNullable = returnTypeAnnotation.type === 'NullableTypeAnnotation';
|
|
93
93
|
const isVoid = returnTypeAnnotation.type === 'VoidTypeAnnotation';
|
|
94
|
-
const methodCallArgs = ['rt', ...args].join('
|
|
95
|
-
const methodCall = `static_cast<${hasteModuleName}CxxSpecJSI *>(&turboModule)->${methodName}(${methodCallArgs})`;
|
|
94
|
+
const methodCallArgs = [' rt', ...args].join(',\n ');
|
|
95
|
+
const methodCall = `static_cast<${hasteModuleName}CxxSpecJSI *>(&turboModule)->${methodName}(\n${methodCallArgs}\n )`;
|
|
96
96
|
return `static jsi::Value __hostFunction_${hasteModuleName}CxxSpecJSI_${methodName}(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {${
|
|
97
97
|
isVoid
|
|
98
98
|
? `\n ${methodCall};`
|
|
@@ -168,7 +168,7 @@ function serializeArg(moduleName, arg, index, resolveAlias, enumMap) {
|
|
|
168
168
|
} else {
|
|
169
169
|
let condition = `${val}.isNull() || ${val}.isUndefined()`;
|
|
170
170
|
if (optional) {
|
|
171
|
-
condition = `count
|
|
171
|
+
condition = `count <= ${index} || ${condition}`;
|
|
172
172
|
}
|
|
173
173
|
return `${condition} ? std::nullopt : std::make_optional(${expression})`;
|
|
174
174
|
}
|
|
@@ -40,8 +40,8 @@ const HostFunctionTemplate = ({
|
|
|
40
40
|
}>) => {
|
|
41
41
|
const isNullable = returnTypeAnnotation.type === 'NullableTypeAnnotation';
|
|
42
42
|
const isVoid = returnTypeAnnotation.type === 'VoidTypeAnnotation';
|
|
43
|
-
const methodCallArgs = ['rt', ...args].join('
|
|
44
|
-
const methodCall = `static_cast<${hasteModuleName}CxxSpecJSI *>(&turboModule)->${methodName}(${methodCallArgs})`;
|
|
43
|
+
const methodCallArgs = [' rt', ...args].join(',\n ');
|
|
44
|
+
const methodCall = `static_cast<${hasteModuleName}CxxSpecJSI *>(&turboModule)->${methodName}(\n${methodCallArgs}\n )`;
|
|
45
45
|
|
|
46
46
|
return `static jsi::Value __hostFunction_${hasteModuleName}CxxSpecJSI_${methodName}(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {${
|
|
47
47
|
isVoid
|
|
@@ -139,7 +139,7 @@ function serializeArg(
|
|
|
139
139
|
} else {
|
|
140
140
|
let condition = `${val}.isNull() || ${val}.isUndefined()`;
|
|
141
141
|
if (optional) {
|
|
142
|
-
condition = `count
|
|
142
|
+
condition = `count <= ${index} || ${condition}`;
|
|
143
143
|
}
|
|
144
144
|
return `${condition} ? std::nullopt : std::make_optional(${expression})`;
|
|
145
145
|
}
|
|
@@ -361,7 +361,7 @@ enum ${enumName} { ${values} };
|
|
|
361
361
|
|
|
362
362
|
template <>
|
|
363
363
|
struct Bridging<${enumName}> {
|
|
364
|
-
static ${enumName} fromJs(jsi::Runtime &rt, ${fromValue}
|
|
364
|
+
static ${enumName} fromJs(jsi::Runtime &rt, ${fromValue}) {
|
|
365
365
|
${fromValueConversion}
|
|
366
366
|
${fromCases}
|
|
367
367
|
}
|
|
@@ -338,7 +338,7 @@ enum ${enumName} { ${values} };
|
|
|
338
338
|
|
|
339
339
|
template <>
|
|
340
340
|
struct Bridging<${enumName}> {
|
|
341
|
-
static ${enumName} fromJs(jsi::Runtime &rt, ${fromValue}
|
|
341
|
+
static ${enumName} fromJs(jsi::Runtime &rt, ${fromValue}) {
|
|
342
342
|
${fromValueConversion}
|
|
343
343
|
${fromCases}
|
|
344
344
|
}
|
|
@@ -105,7 +105,7 @@ package ${packageName};
|
|
|
105
105
|
|
|
106
106
|
${imports}
|
|
107
107
|
|
|
108
|
-
public abstract class ${className} extends ReactContextBaseJavaModule implements
|
|
108
|
+
public abstract class ${className} extends ReactContextBaseJavaModule implements TurboModule {
|
|
109
109
|
public static final String NAME = "${jsName}";
|
|
110
110
|
|
|
111
111
|
public ${className}(ReactApplicationContext reactContext) {
|
|
@@ -488,7 +488,6 @@ module.exports = {
|
|
|
488
488
|
'com.facebook.react.bridge.ReactApplicationContext',
|
|
489
489
|
'com.facebook.react.bridge.ReactContextBaseJavaModule',
|
|
490
490
|
'com.facebook.react.bridge.ReactMethod',
|
|
491
|
-
'com.facebook.react.bridge.ReactModuleWithSpec',
|
|
492
491
|
'com.facebook.react.turbomodule.core.interfaces.TurboModule',
|
|
493
492
|
'com.facebook.proguard.annotations.DoNotStrip',
|
|
494
493
|
'javax.annotation.Nonnull',
|
|
@@ -52,7 +52,7 @@ package ${packageName};
|
|
|
52
52
|
|
|
53
53
|
${imports}
|
|
54
54
|
|
|
55
|
-
public abstract class ${className} extends ReactContextBaseJavaModule implements
|
|
55
|
+
public abstract class ${className} extends ReactContextBaseJavaModule implements TurboModule {
|
|
56
56
|
public static final String NAME = "${jsName}";
|
|
57
57
|
|
|
58
58
|
public ${className}(ReactApplicationContext reactContext) {
|
|
@@ -463,7 +463,6 @@ module.exports = {
|
|
|
463
463
|
'com.facebook.react.bridge.ReactApplicationContext',
|
|
464
464
|
'com.facebook.react.bridge.ReactContextBaseJavaModule',
|
|
465
465
|
'com.facebook.react.bridge.ReactMethod',
|
|
466
|
-
'com.facebook.react.bridge.ReactModuleWithSpec',
|
|
467
466
|
'com.facebook.react.turbomodule.core.interfaces.TurboModule',
|
|
468
467
|
'com.facebook.proguard.annotations.DoNotStrip',
|
|
469
468
|
'javax.annotation.Nonnull',
|