@react-native/codegen 0.73.0 → 0.74.0-nightly-20231003-5dedf277c
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/cli/combine/combine-js-to-schema-cli.js +7 -1
- package/lib/cli/combine/combine-js-to-schema-cli.js.flow +7 -1
- package/lib/generators/components/CppHelpers.js +39 -2
- package/lib/generators/components/CppHelpers.js.flow +54 -5
- package/lib/generators/components/GenerateEventEmitterCpp.js +222 -28
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +221 -34
- package/lib/generators/components/GenerateEventEmitterH.js +77 -26
- package/lib/generators/components/GenerateEventEmitterH.js.flow +87 -30
- package/lib/generators/components/GeneratePropsH.js +2 -3
- package/lib/generators/components/GeneratePropsH.js.flow +2 -3
- 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 +1 -1
- package/lib/generators/modules/GenerateModuleCpp.js.flow +1 -1
- package/lib/generators/modules/GenerateModuleH.js +44 -39
- package/lib/generators/modules/GenerateModuleH.js.flow +51 -39
- package/lib/generators/modules/GenerateModuleJavaSpec.js +9 -7
- package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +10 -6
- package/lib/generators/modules/GenerateModuleJniH.js +1 -1
- package/lib/generators/modules/GenerateModuleJniH.js.flow +1 -1
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js +11 -3
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow +13 -3
- package/lib/parsers/error-utils.js +44 -0
- package/lib/parsers/error-utils.js.flow +59 -0
- package/lib/parsers/errors.js +3 -9
- package/lib/parsers/errors.js.flow +3 -9
- 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 +22 -33
- package/lib/parsers/flow/components/componentsUtils.js.flow +24 -45
- package/lib/parsers/flow/components/events.js +151 -128
- package/lib/parsers/flow/components/events.js.flow +161 -136
- package/lib/parsers/flow/components/index.js +13 -94
- package/lib/parsers/flow/components/index.js.flow +5 -102
- package/lib/parsers/flow/modules/index.js +24 -24
- package/lib/parsers/flow/modules/index.js.flow +6 -6
- package/lib/parsers/flow/parser.d.ts +9 -2
- package/lib/parsers/flow/parser.js +179 -18
- package/lib/parsers/flow/parser.js.flow +231 -7
- package/lib/parsers/flow/utils.js +0 -63
- package/lib/parsers/flow/utils.js.flow +1 -77
- package/lib/parsers/parser.js.flow +176 -3
- package/lib/parsers/parserMock.js +202 -4
- package/lib/parsers/parserMock.js.flow +253 -4
- package/lib/parsers/parsers-commons.js +268 -10
- package/lib/parsers/parsers-commons.js.flow +365 -12
- package/lib/parsers/parsers-primitives.js +95 -1
- package/lib/parsers/parsers-primitives.js.flow +136 -1
- 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 +49 -57
- package/lib/parsers/typescript/components/componentsUtils.js.flow +48 -66
- package/lib/parsers/typescript/components/events.js +136 -115
- package/lib/parsers/typescript/components/events.js.flow +148 -119
- 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 +14 -99
- package/lib/parsers/typescript/components/index.js.flow +6 -106
- package/lib/parsers/typescript/modules/index.js +28 -26
- package/lib/parsers/typescript/modules/index.js.flow +9 -8
- package/lib/parsers/typescript/parser.d.ts +9 -2
- package/lib/parsers/typescript/parser.js +208 -14
- package/lib/parsers/typescript/parser.js.flow +247 -8
- package/lib/parsers/utils.js.flow +6 -0
- package/package.json +27 -16
- 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
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
const nullthrows = require('nullthrows');
|
|
14
14
|
const _require = require('./CppHelpers'),
|
|
15
|
+
getImports = _require.getImports,
|
|
16
|
+
getCppArrayTypeForAnnotation = _require.getCppArrayTypeForAnnotation,
|
|
15
17
|
getCppTypeForAnnotation = _require.getCppTypeForAnnotation,
|
|
16
18
|
generateEventStructName = _require.generateEventStructName;
|
|
17
19
|
const _require2 = require('../Utils'),
|
|
18
20
|
indent = _require2.indent,
|
|
19
21
|
toSafeCppString = _require2.toSafeCppString;
|
|
20
|
-
const FileTemplate = ({componentEmitters}) => `
|
|
22
|
+
const FileTemplate = ({componentEmitters, extraIncludes}) => `
|
|
21
23
|
/**
|
|
22
24
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
23
25
|
*
|
|
@@ -29,7 +31,7 @@ const FileTemplate = ({componentEmitters}) => `
|
|
|
29
31
|
#pragma once
|
|
30
32
|
|
|
31
33
|
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
32
|
-
|
|
34
|
+
${[...extraIncludes].join('\n')}
|
|
33
35
|
|
|
34
36
|
namespace facebook {
|
|
35
37
|
namespace react {
|
|
@@ -39,12 +41,11 @@ ${componentEmitters}
|
|
|
39
41
|
`;
|
|
40
42
|
const ComponentTemplate = ({className, structs, events}) =>
|
|
41
43
|
`
|
|
42
|
-
class
|
|
44
|
+
class ${className}EventEmitter : public ViewEventEmitter {
|
|
43
45
|
public:
|
|
44
46
|
using ViewEventEmitter::ViewEventEmitter;
|
|
45
47
|
|
|
46
48
|
${structs}
|
|
47
|
-
|
|
48
49
|
${events}
|
|
49
50
|
};
|
|
50
51
|
`.trim();
|
|
@@ -73,11 +74,22 @@ function getNativeTypeFromAnnotation(componentName, eventProperty, nameParts) {
|
|
|
73
74
|
case 'Int32TypeAnnotation':
|
|
74
75
|
case 'DoubleTypeAnnotation':
|
|
75
76
|
case 'FloatTypeAnnotation':
|
|
77
|
+
case 'MixedTypeAnnotation':
|
|
76
78
|
return getCppTypeForAnnotation(type);
|
|
77
79
|
case 'StringEnumTypeAnnotation':
|
|
78
|
-
return generateEventStructName(nameParts.concat([eventProperty.name]));
|
|
79
80
|
case 'ObjectTypeAnnotation':
|
|
80
|
-
return generateEventStructName(nameParts
|
|
81
|
+
return generateEventStructName([...nameParts, eventProperty.name]);
|
|
82
|
+
case 'ArrayTypeAnnotation':
|
|
83
|
+
const eventTypeAnnotation = eventProperty.typeAnnotation;
|
|
84
|
+
if (eventTypeAnnotation.type !== 'ArrayTypeAnnotation') {
|
|
85
|
+
throw new Error(
|
|
86
|
+
"Inconsistent Codegen state: type was ArrayTypeAnnotation at the beginning of the body and now it isn't",
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return getCppArrayTypeForAnnotation(eventTypeAnnotation.elementType, [
|
|
90
|
+
...nameParts,
|
|
91
|
+
eventProperty.name,
|
|
92
|
+
]);
|
|
81
93
|
default:
|
|
82
94
|
type;
|
|
83
95
|
throw new Error(`Received invalid event property type ${type}`);
|
|
@@ -103,6 +115,32 @@ function generateEnum(structs, options, nameParts) {
|
|
|
103
115
|
}),
|
|
104
116
|
);
|
|
105
117
|
}
|
|
118
|
+
function handleGenerateStructForArray(
|
|
119
|
+
structs,
|
|
120
|
+
name,
|
|
121
|
+
componentName,
|
|
122
|
+
elementType,
|
|
123
|
+
nameParts,
|
|
124
|
+
) {
|
|
125
|
+
if (elementType.type === 'ObjectTypeAnnotation') {
|
|
126
|
+
generateStruct(
|
|
127
|
+
structs,
|
|
128
|
+
componentName,
|
|
129
|
+
nameParts.concat([name]),
|
|
130
|
+
nullthrows(elementType.properties),
|
|
131
|
+
);
|
|
132
|
+
} else if (elementType.type === 'StringEnumTypeAnnotation') {
|
|
133
|
+
generateEnum(structs, elementType.options, nameParts.concat([name]));
|
|
134
|
+
} else if (elementType.type === 'ArrayTypeAnnotation') {
|
|
135
|
+
handleGenerateStructForArray(
|
|
136
|
+
structs,
|
|
137
|
+
name,
|
|
138
|
+
componentName,
|
|
139
|
+
elementType.elementType,
|
|
140
|
+
nameParts,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
106
144
|
function generateStruct(structs, componentName, nameParts, properties) {
|
|
107
145
|
const structNameParts = nameParts;
|
|
108
146
|
const structName = generateEventStructName(structNameParts);
|
|
@@ -120,14 +158,20 @@ function generateStruct(structs, componentName, nameParts, properties) {
|
|
|
120
158
|
typeAnnotation = property.typeAnnotation;
|
|
121
159
|
switch (typeAnnotation.type) {
|
|
122
160
|
case 'BooleanTypeAnnotation':
|
|
123
|
-
return;
|
|
124
161
|
case 'StringTypeAnnotation':
|
|
125
|
-
return;
|
|
126
162
|
case 'Int32TypeAnnotation':
|
|
127
|
-
return;
|
|
128
163
|
case 'DoubleTypeAnnotation':
|
|
129
|
-
return;
|
|
130
164
|
case 'FloatTypeAnnotation':
|
|
165
|
+
case 'MixedTypeAnnotation':
|
|
166
|
+
return;
|
|
167
|
+
case 'ArrayTypeAnnotation':
|
|
168
|
+
handleGenerateStructForArray(
|
|
169
|
+
structs,
|
|
170
|
+
name,
|
|
171
|
+
componentName,
|
|
172
|
+
typeAnnotation.elementType,
|
|
173
|
+
nameParts,
|
|
174
|
+
);
|
|
131
175
|
return;
|
|
132
176
|
case 'ObjectTypeAnnotation':
|
|
133
177
|
generateStruct(
|
|
@@ -187,7 +231,7 @@ module.exports = {
|
|
|
187
231
|
.map(moduleName => {
|
|
188
232
|
const module = schema.modules[moduleName];
|
|
189
233
|
if (module.type !== 'Component') {
|
|
190
|
-
return;
|
|
234
|
+
return null;
|
|
191
235
|
}
|
|
192
236
|
const components = module.components;
|
|
193
237
|
// No components in this module
|
|
@@ -198,24 +242,31 @@ module.exports = {
|
|
|
198
242
|
})
|
|
199
243
|
.filter(Boolean)
|
|
200
244
|
.reduce((acc, components) => Object.assign(acc, components), {});
|
|
201
|
-
const
|
|
245
|
+
const extraIncludes = new Set();
|
|
246
|
+
const componentEmitters = Object.keys(moduleComponents)
|
|
247
|
+
.map(componentName => {
|
|
248
|
+
const component = moduleComponents[componentName];
|
|
249
|
+
component.events.forEach(event => {
|
|
250
|
+
if (event.typeAnnotation.argument) {
|
|
251
|
+
const argIncludes = getImports(
|
|
252
|
+
event.typeAnnotation.argument.properties,
|
|
253
|
+
);
|
|
254
|
+
// $FlowFixMe[method-unbinding]
|
|
255
|
+
argIncludes.forEach(extraIncludes.add, extraIncludes);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
const replacedTemplate = ComponentTemplate({
|
|
259
|
+
className: componentName,
|
|
260
|
+
structs: indent(generateStructs(componentName, component), 2),
|
|
261
|
+
events: generateEvents(componentName, component),
|
|
262
|
+
});
|
|
263
|
+
return replacedTemplate;
|
|
264
|
+
})
|
|
265
|
+
.join('\n');
|
|
202
266
|
const fileName = 'EventEmitters.h';
|
|
203
|
-
const componentEmitters =
|
|
204
|
-
moduleComponentsWithEvents.length > 0
|
|
205
|
-
? Object.keys(moduleComponents)
|
|
206
|
-
.map(componentName => {
|
|
207
|
-
const component = moduleComponents[componentName];
|
|
208
|
-
const replacedTemplate = ComponentTemplate({
|
|
209
|
-
className: componentName,
|
|
210
|
-
structs: indent(generateStructs(componentName, component), 2),
|
|
211
|
-
events: generateEvents(componentName, component),
|
|
212
|
-
});
|
|
213
|
-
return replacedTemplate;
|
|
214
|
-
})
|
|
215
|
-
.join('\n')
|
|
216
|
-
: '';
|
|
217
267
|
const replacedTemplate = FileTemplate({
|
|
218
268
|
componentEmitters,
|
|
269
|
+
extraIncludes,
|
|
219
270
|
});
|
|
220
271
|
return new Map([[fileName, replacedTemplate]]);
|
|
221
272
|
},
|
|
@@ -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,7 +55,7 @@ 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 {
|
|
@@ -66,12 +74,11 @@ const ComponentTemplate = ({
|
|
|
66
74
|
events: string,
|
|
67
75
|
}) =>
|
|
68
76
|
`
|
|
69
|
-
class
|
|
77
|
+
class ${className}EventEmitter : public ViewEventEmitter {
|
|
70
78
|
public:
|
|
71
79
|
using ViewEventEmitter::ViewEventEmitter;
|
|
72
80
|
|
|
73
81
|
${structs}
|
|
74
|
-
|
|
75
82
|
${events}
|
|
76
83
|
};
|
|
77
84
|
`.trim();
|
|
@@ -122,11 +129,22 @@ function getNativeTypeFromAnnotation(
|
|
|
122
129
|
case 'Int32TypeAnnotation':
|
|
123
130
|
case 'DoubleTypeAnnotation':
|
|
124
131
|
case 'FloatTypeAnnotation':
|
|
132
|
+
case 'MixedTypeAnnotation':
|
|
125
133
|
return getCppTypeForAnnotation(type);
|
|
126
134
|
case 'StringEnumTypeAnnotation':
|
|
127
|
-
return generateEventStructName(nameParts.concat([eventProperty.name]));
|
|
128
135
|
case 'ObjectTypeAnnotation':
|
|
129
|
-
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
|
+
]);
|
|
130
148
|
default:
|
|
131
149
|
(type: empty);
|
|
132
150
|
throw new Error(`Received invalid event property type ${type}`);
|
|
@@ -159,6 +177,33 @@ function generateEnum(
|
|
|
159
177
|
);
|
|
160
178
|
}
|
|
161
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
|
+
|
|
162
207
|
function generateStruct(
|
|
163
208
|
structs: StructsMap,
|
|
164
209
|
componentName: string,
|
|
@@ -182,14 +227,20 @@ function generateStruct(
|
|
|
182
227
|
const {name, typeAnnotation} = property;
|
|
183
228
|
switch (typeAnnotation.type) {
|
|
184
229
|
case 'BooleanTypeAnnotation':
|
|
185
|
-
return;
|
|
186
230
|
case 'StringTypeAnnotation':
|
|
187
|
-
return;
|
|
188
231
|
case 'Int32TypeAnnotation':
|
|
189
|
-
return;
|
|
190
232
|
case 'DoubleTypeAnnotation':
|
|
191
|
-
return;
|
|
192
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
|
+
);
|
|
193
244
|
return;
|
|
194
245
|
case 'ObjectTypeAnnotation':
|
|
195
246
|
generateStruct(
|
|
@@ -268,7 +319,7 @@ module.exports = {
|
|
|
268
319
|
.map(moduleName => {
|
|
269
320
|
const module = schema.modules[moduleName];
|
|
270
321
|
if (module.type !== 'Component') {
|
|
271
|
-
return;
|
|
322
|
+
return null;
|
|
272
323
|
}
|
|
273
324
|
|
|
274
325
|
const {components} = module;
|
|
@@ -282,29 +333,35 @@ module.exports = {
|
|
|
282
333
|
.filter(Boolean)
|
|
283
334
|
.reduce((acc, components) => Object.assign(acc, components), {});
|
|
284
335
|
|
|
285
|
-
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');
|
|
286
360
|
|
|
287
361
|
const fileName = 'EventEmitters.h';
|
|
288
|
-
|
|
289
|
-
const componentEmitters =
|
|
290
|
-
moduleComponentsWithEvents.length > 0
|
|
291
|
-
? Object.keys(moduleComponents)
|
|
292
|
-
.map(componentName => {
|
|
293
|
-
const component = moduleComponents[componentName];
|
|
294
|
-
|
|
295
|
-
const replacedTemplate = ComponentTemplate({
|
|
296
|
-
className: componentName,
|
|
297
|
-
structs: indent(generateStructs(componentName, component), 2),
|
|
298
|
-
events: generateEvents(componentName, component),
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
return replacedTemplate;
|
|
302
|
-
})
|
|
303
|
-
.join('\n')
|
|
304
|
-
: '';
|
|
305
|
-
|
|
306
362
|
const replacedTemplate = FileTemplate({
|
|
307
363
|
componentEmitters,
|
|
364
|
+
extraIncludes,
|
|
308
365
|
});
|
|
309
366
|
|
|
310
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);
|
|
@@ -96,7 +96,7 @@ const StructTemplate = ({structName, fields, fromCases}) =>
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ${structName} &result) {
|
|
99
|
-
auto map = (
|
|
99
|
+
auto map = (std::unordered_map<std::string, RawValue>)value;
|
|
100
100
|
|
|
101
101
|
${fromCases}
|
|
102
102
|
}
|
|
@@ -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);
|
|
@@ -161,7 +161,7 @@ const StructTemplate = ({
|
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ${structName} &result) {
|
|
164
|
-
auto map = (
|
|
164
|
+
auto map = (std::unordered_map<std::string, RawValue>)value;
|
|
165
165
|
|
|
166
166
|
${fromCases}
|
|
167
167
|
}
|
|
@@ -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
|
{
|