@react-native/codegen 0.74.0-nightly-20240208-b796cda38 → 0.74.0-nightly-20240214-b8ad91732
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/lib/generators/RNCodegen.d.ts +1 -0
- package/lib/generators/RNCodegen.js +4 -0
- package/lib/generators/RNCodegen.js.flow +4 -0
- package/lib/generators/components/CppHelpers.js +7 -0
- package/lib/generators/components/CppHelpers.js.flow +14 -0
- package/lib/generators/components/GenerateComponentDescriptorCpp.js +89 -0
- package/lib/generators/components/GenerateComponentDescriptorCpp.js.flow +101 -0
- package/lib/generators/components/GenerateComponentDescriptorH.js +18 -7
- package/lib/generators/components/GenerateComponentDescriptorH.js.flow +17 -8
- package/lib/generators/components/GenerateEventEmitterCpp.js +9 -4
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +6 -5
- package/lib/generators/components/GeneratePropsCpp.js +5 -1
- package/lib/generators/components/GeneratePropsCpp.js.flow +6 -2
- package/lib/generators/components/GenerateShadowNodeCpp.js +7 -1
- package/lib/generators/components/GenerateShadowNodeCpp.js.flow +3 -1
- package/lib/generators/components/GenerateShadowNodeH.js +15 -3
- package/lib/generators/components/GenerateShadowNodeH.js.flow +5 -3
- package/lib/generators/components/GenerateStateCpp.js +7 -1
- package/lib/generators/components/GenerateStateCpp.js.flow +3 -1
- package/lib/generators/modules/GenerateModuleJniH.js +3 -0
- package/lib/generators/modules/GenerateModuleJniH.js.flow +3 -0
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ export type ViewGeneratorFunction = (libraryName: string, schema: SchemaType) =>
|
|
|
14
14
|
|
|
15
15
|
type LibraryGeneratorNames =
|
|
16
16
|
| 'generateComponentDescriptorH'
|
|
17
|
+
| 'generateComponentDescriptorCpp'
|
|
17
18
|
| 'generateComponentHObjCpp'
|
|
18
19
|
| 'generateEventEmitterCpp'
|
|
19
20
|
| 'generateEventEmitterH'
|
|
@@ -16,6 +16,7 @@ TODO:
|
|
|
16
16
|
- ViewConfigs should spread in View's valid attributes
|
|
17
17
|
*/
|
|
18
18
|
const schemaValidator = require('../SchemaValidator.js');
|
|
19
|
+
const generateComponentDescriptorCpp = require('./components/GenerateComponentDescriptorCpp.js');
|
|
19
20
|
const generateComponentDescriptorH = require('./components/GenerateComponentDescriptorH.js');
|
|
20
21
|
const generateComponentHObjCpp = require('./components/GenerateComponentHObjCpp.js');
|
|
21
22
|
const generateEventEmitterCpp = require('./components/GenerateEventEmitterCpp.js');
|
|
@@ -42,6 +43,7 @@ const fs = require('fs');
|
|
|
42
43
|
const path = require('path');
|
|
43
44
|
const ALL_GENERATORS = {
|
|
44
45
|
generateComponentDescriptorH: generateComponentDescriptorH.generate,
|
|
46
|
+
generateComponentDescriptorCpp: generateComponentDescriptorCpp.generate,
|
|
45
47
|
generateComponentHObjCpp: generateComponentHObjCpp.generate,
|
|
46
48
|
generateEventEmitterCpp: generateEventEmitterCpp.generate,
|
|
47
49
|
generateEventEmitterH: generateEventEmitterH.generate,
|
|
@@ -81,6 +83,7 @@ const LIBRARY_GENERATORS = {
|
|
|
81
83
|
componentsAndroid: [
|
|
82
84
|
// JNI/C++ files
|
|
83
85
|
generateComponentDescriptorH.generate,
|
|
86
|
+
generateComponentDescriptorCpp.generate,
|
|
84
87
|
generateEventEmitterCpp.generate,
|
|
85
88
|
generateEventEmitterH.generate,
|
|
86
89
|
generatePropsCpp.generate,
|
|
@@ -95,6 +98,7 @@ const LIBRARY_GENERATORS = {
|
|
|
95
98
|
],
|
|
96
99
|
componentsIOS: [
|
|
97
100
|
generateComponentDescriptorH.generate,
|
|
101
|
+
generateComponentDescriptorCpp.generate,
|
|
98
102
|
generateEventEmitterCpp.generate,
|
|
99
103
|
generateEventEmitterH.generate,
|
|
100
104
|
generateComponentHObjCpp.generate,
|
|
@@ -19,6 +19,7 @@ TODO:
|
|
|
19
19
|
import type {SchemaType} from '../CodegenSchema';
|
|
20
20
|
|
|
21
21
|
const schemaValidator = require('../SchemaValidator.js');
|
|
22
|
+
const generateComponentDescriptorCpp = require('./components/GenerateComponentDescriptorCpp.js');
|
|
22
23
|
const generateComponentDescriptorH = require('./components/GenerateComponentDescriptorH.js');
|
|
23
24
|
const generateComponentHObjCpp = require('./components/GenerateComponentHObjCpp.js');
|
|
24
25
|
const generateEventEmitterCpp = require('./components/GenerateEventEmitterCpp.js');
|
|
@@ -46,6 +47,7 @@ const path = require('path');
|
|
|
46
47
|
|
|
47
48
|
const ALL_GENERATORS = {
|
|
48
49
|
generateComponentDescriptorH: generateComponentDescriptorH.generate,
|
|
50
|
+
generateComponentDescriptorCpp: generateComponentDescriptorCpp.generate,
|
|
49
51
|
generateComponentHObjCpp: generateComponentHObjCpp.generate,
|
|
50
52
|
generateEventEmitterCpp: generateEventEmitterCpp.generate,
|
|
51
53
|
generateEventEmitterH: generateEventEmitterH.generate,
|
|
@@ -126,6 +128,7 @@ const LIBRARY_GENERATORS = {
|
|
|
126
128
|
componentsAndroid: [
|
|
127
129
|
// JNI/C++ files
|
|
128
130
|
generateComponentDescriptorH.generate,
|
|
131
|
+
generateComponentDescriptorCpp.generate,
|
|
129
132
|
generateEventEmitterCpp.generate,
|
|
130
133
|
generateEventEmitterH.generate,
|
|
131
134
|
generatePropsCpp.generate,
|
|
@@ -140,6 +143,7 @@ const LIBRARY_GENERATORS = {
|
|
|
140
143
|
],
|
|
141
144
|
componentsIOS: [
|
|
142
145
|
generateComponentDescriptorH.generate,
|
|
146
|
+
generateComponentDescriptorCpp.generate,
|
|
143
147
|
generateEventEmitterCpp.generate,
|
|
144
148
|
generateEventEmitterH.generate,
|
|
145
149
|
generateComponentHObjCpp.generate,
|
|
@@ -208,6 +208,12 @@ function convertDefaultTypeToString(componentName, prop) {
|
|
|
208
208
|
throw new Error(`Unsupported type annotation: ${typeAnnotation.type}`);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
+
const IncludeTemplate = ({headerPrefix, file}) => {
|
|
212
|
+
if (headerPrefix === '') {
|
|
213
|
+
return `#include "${file}"`;
|
|
214
|
+
}
|
|
215
|
+
return `#include <${headerPrefix}${file}>`;
|
|
216
|
+
};
|
|
211
217
|
module.exports = {
|
|
212
218
|
convertDefaultTypeToString,
|
|
213
219
|
getCppArrayTypeForAnnotation,
|
|
@@ -217,4 +223,5 @@ module.exports = {
|
|
|
217
223
|
toIntEnumValueName,
|
|
218
224
|
generateStructName,
|
|
219
225
|
generateEventStructName,
|
|
226
|
+
IncludeTemplate,
|
|
220
227
|
};
|
|
@@ -256,6 +256,19 @@ function convertDefaultTypeToString(
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
const IncludeTemplate = ({
|
|
260
|
+
headerPrefix,
|
|
261
|
+
file,
|
|
262
|
+
}: {
|
|
263
|
+
headerPrefix: string,
|
|
264
|
+
file: string,
|
|
265
|
+
}): string => {
|
|
266
|
+
if (headerPrefix === '') {
|
|
267
|
+
return `#include "${file}"`;
|
|
268
|
+
}
|
|
269
|
+
return `#include <${headerPrefix}${file}>`;
|
|
270
|
+
};
|
|
271
|
+
|
|
259
272
|
module.exports = {
|
|
260
273
|
convertDefaultTypeToString,
|
|
261
274
|
getCppArrayTypeForAnnotation,
|
|
@@ -265,4 +278,5 @@ module.exports = {
|
|
|
265
278
|
toIntEnumValueName,
|
|
266
279
|
generateStructName,
|
|
267
280
|
generateEventStructName,
|
|
281
|
+
IncludeTemplate,
|
|
268
282
|
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const _require = require('./CppHelpers'),
|
|
14
|
+
IncludeTemplate = _require.IncludeTemplate;
|
|
15
|
+
|
|
16
|
+
// File path -> contents
|
|
17
|
+
|
|
18
|
+
const FileTemplate = ({libraryName, componentRegistrations, headerPrefix}) => `
|
|
19
|
+
/**
|
|
20
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
21
|
+
*
|
|
22
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
23
|
+
* once the code is regenerated.
|
|
24
|
+
*
|
|
25
|
+
* ${'@'}generated by codegen project: GenerateComponentDescriptorCpp.js
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
${IncludeTemplate({
|
|
29
|
+
headerPrefix,
|
|
30
|
+
file: 'ComponentDescriptors.h',
|
|
31
|
+
})}
|
|
32
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
33
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
34
|
+
|
|
35
|
+
namespace facebook::react {
|
|
36
|
+
|
|
37
|
+
void ${libraryName}_registerComponentDescriptorsFromCodegen(
|
|
38
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
|
|
39
|
+
${componentRegistrations}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
} // namespace facebook::react
|
|
43
|
+
`;
|
|
44
|
+
const ComponentRegistrationTemplate = ({className}) =>
|
|
45
|
+
`
|
|
46
|
+
registry->add(concreteComponentDescriptorProvider<${className}ComponentDescriptor>());
|
|
47
|
+
`.trim();
|
|
48
|
+
module.exports = {
|
|
49
|
+
generate(
|
|
50
|
+
libraryName,
|
|
51
|
+
schema,
|
|
52
|
+
packageName,
|
|
53
|
+
assumeNonnull = false,
|
|
54
|
+
headerPrefix,
|
|
55
|
+
) {
|
|
56
|
+
const fileName = 'ComponentDescriptors.cpp';
|
|
57
|
+
const componentRegistrations = Object.keys(schema.modules)
|
|
58
|
+
.map(moduleName => {
|
|
59
|
+
const module = schema.modules[moduleName];
|
|
60
|
+
if (module.type !== 'Component') {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const components = module.components;
|
|
64
|
+
// No components in this module
|
|
65
|
+
if (components == null) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return Object.keys(components)
|
|
69
|
+
.map(componentName => {
|
|
70
|
+
if (components[componentName].interfaceOnly === true) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
return ComponentRegistrationTemplate({
|
|
74
|
+
className: componentName,
|
|
75
|
+
});
|
|
76
|
+
})
|
|
77
|
+
.join('\n');
|
|
78
|
+
})
|
|
79
|
+
.filter(Boolean)
|
|
80
|
+
.join('\n');
|
|
81
|
+
const replacedTemplate = FileTemplate({
|
|
82
|
+
libraryName,
|
|
83
|
+
componentRegistrations,
|
|
84
|
+
headerPrefix:
|
|
85
|
+
headerPrefix !== null && headerPrefix !== void 0 ? headerPrefix : '',
|
|
86
|
+
});
|
|
87
|
+
return new Map([[fileName, replacedTemplate]]);
|
|
88
|
+
},
|
|
89
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
import type {SchemaType} from '../../CodegenSchema';
|
|
14
|
+
|
|
15
|
+
const {IncludeTemplate} = require('./CppHelpers');
|
|
16
|
+
|
|
17
|
+
// File path -> contents
|
|
18
|
+
type FilesOutput = Map<string, string>;
|
|
19
|
+
|
|
20
|
+
const FileTemplate = ({
|
|
21
|
+
libraryName,
|
|
22
|
+
componentRegistrations,
|
|
23
|
+
headerPrefix,
|
|
24
|
+
}: {
|
|
25
|
+
libraryName: string,
|
|
26
|
+
componentRegistrations: string,
|
|
27
|
+
headerPrefix: string,
|
|
28
|
+
}) => `
|
|
29
|
+
/**
|
|
30
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
31
|
+
*
|
|
32
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
33
|
+
* once the code is regenerated.
|
|
34
|
+
*
|
|
35
|
+
* ${'@'}generated by codegen project: GenerateComponentDescriptorCpp.js
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
${IncludeTemplate({headerPrefix, file: 'ComponentDescriptors.h'})}
|
|
39
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
40
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
41
|
+
|
|
42
|
+
namespace facebook::react {
|
|
43
|
+
|
|
44
|
+
void ${libraryName}_registerComponentDescriptorsFromCodegen(
|
|
45
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
|
|
46
|
+
${componentRegistrations}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
} // namespace facebook::react
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
const ComponentRegistrationTemplate = ({className}: {className: string}) =>
|
|
53
|
+
`
|
|
54
|
+
registry->add(concreteComponentDescriptorProvider<${className}ComponentDescriptor>());
|
|
55
|
+
`.trim();
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
generate(
|
|
59
|
+
libraryName: string,
|
|
60
|
+
schema: SchemaType,
|
|
61
|
+
packageName?: string,
|
|
62
|
+
assumeNonnull: boolean = false,
|
|
63
|
+
headerPrefix?: string,
|
|
64
|
+
): FilesOutput {
|
|
65
|
+
const fileName = 'ComponentDescriptors.cpp';
|
|
66
|
+
|
|
67
|
+
const componentRegistrations = Object.keys(schema.modules)
|
|
68
|
+
.map(moduleName => {
|
|
69
|
+
const module = schema.modules[moduleName];
|
|
70
|
+
if (module.type !== 'Component') {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const {components} = module;
|
|
75
|
+
// No components in this module
|
|
76
|
+
if (components == null) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return Object.keys(components)
|
|
81
|
+
.map(componentName => {
|
|
82
|
+
if (components[componentName].interfaceOnly === true) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return ComponentRegistrationTemplate({className: componentName});
|
|
87
|
+
})
|
|
88
|
+
.join('\n');
|
|
89
|
+
})
|
|
90
|
+
.filter(Boolean)
|
|
91
|
+
.join('\n');
|
|
92
|
+
|
|
93
|
+
const replacedTemplate = FileTemplate({
|
|
94
|
+
libraryName,
|
|
95
|
+
componentRegistrations,
|
|
96
|
+
headerPrefix: headerPrefix ?? '',
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return new Map([[fileName, replacedTemplate]]);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
@@ -10,9 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
const _require = require('./CppHelpers'),
|
|
14
|
+
IncludeTemplate = _require.IncludeTemplate;
|
|
15
|
+
|
|
13
16
|
// File path -> contents
|
|
14
17
|
|
|
15
|
-
const FileTemplate = ({
|
|
18
|
+
const FileTemplate = ({libraryName, componentDefinitions, headerPrefix}) => `
|
|
16
19
|
/**
|
|
17
20
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
18
21
|
*
|
|
@@ -24,16 +27,23 @@ const FileTemplate = ({componentDescriptors, headerPrefix}) => `
|
|
|
24
27
|
|
|
25
28
|
#pragma once
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
${IncludeTemplate({
|
|
31
|
+
headerPrefix,
|
|
32
|
+
file: 'ShadowNodes.h',
|
|
33
|
+
})}
|
|
28
34
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
35
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
29
36
|
|
|
30
37
|
namespace facebook::react {
|
|
31
38
|
|
|
32
|
-
${
|
|
39
|
+
${componentDefinitions}
|
|
40
|
+
|
|
41
|
+
void ${libraryName}_registerComponentDescriptorsFromCodegen(
|
|
42
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
33
43
|
|
|
34
44
|
} // namespace facebook::react
|
|
35
45
|
`;
|
|
36
|
-
const
|
|
46
|
+
const ComponentDefinitionTemplate = ({className}) =>
|
|
37
47
|
`
|
|
38
48
|
using ${className}ComponentDescriptor = ConcreteComponentDescriptor<${className}ShadowNode>;
|
|
39
49
|
`.trim();
|
|
@@ -46,7 +56,7 @@ module.exports = {
|
|
|
46
56
|
headerPrefix,
|
|
47
57
|
) {
|
|
48
58
|
const fileName = 'ComponentDescriptors.h';
|
|
49
|
-
const
|
|
59
|
+
const componentDefinitions = Object.keys(schema.modules)
|
|
50
60
|
.map(moduleName => {
|
|
51
61
|
const module = schema.modules[moduleName];
|
|
52
62
|
if (module.type !== 'Component') {
|
|
@@ -62,7 +72,7 @@ module.exports = {
|
|
|
62
72
|
if (components[componentName].interfaceOnly === true) {
|
|
63
73
|
return;
|
|
64
74
|
}
|
|
65
|
-
return
|
|
75
|
+
return ComponentDefinitionTemplate({
|
|
66
76
|
className: componentName,
|
|
67
77
|
});
|
|
68
78
|
})
|
|
@@ -71,7 +81,8 @@ module.exports = {
|
|
|
71
81
|
.filter(Boolean)
|
|
72
82
|
.join('\n');
|
|
73
83
|
const replacedTemplate = FileTemplate({
|
|
74
|
-
|
|
84
|
+
libraryName,
|
|
85
|
+
componentDefinitions,
|
|
75
86
|
headerPrefix:
|
|
76
87
|
headerPrefix !== null && headerPrefix !== void 0 ? headerPrefix : '',
|
|
77
88
|
});
|
|
@@ -12,14 +12,18 @@
|
|
|
12
12
|
|
|
13
13
|
import type {SchemaType} from '../../CodegenSchema';
|
|
14
14
|
|
|
15
|
+
const {IncludeTemplate} = require('./CppHelpers');
|
|
16
|
+
|
|
15
17
|
// File path -> contents
|
|
16
18
|
type FilesOutput = Map<string, string>;
|
|
17
19
|
|
|
18
20
|
const FileTemplate = ({
|
|
19
|
-
|
|
21
|
+
libraryName,
|
|
22
|
+
componentDefinitions,
|
|
20
23
|
headerPrefix,
|
|
21
24
|
}: {
|
|
22
|
-
|
|
25
|
+
libraryName: string,
|
|
26
|
+
componentDefinitions: string,
|
|
23
27
|
headerPrefix: string,
|
|
24
28
|
}) => `
|
|
25
29
|
/**
|
|
@@ -33,17 +37,21 @@ const FileTemplate = ({
|
|
|
33
37
|
|
|
34
38
|
#pragma once
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
${IncludeTemplate({headerPrefix, file: 'ShadowNodes.h'})}
|
|
37
41
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
42
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
38
43
|
|
|
39
44
|
namespace facebook::react {
|
|
40
45
|
|
|
41
|
-
${
|
|
46
|
+
${componentDefinitions}
|
|
47
|
+
|
|
48
|
+
void ${libraryName}_registerComponentDescriptorsFromCodegen(
|
|
49
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
42
50
|
|
|
43
51
|
} // namespace facebook::react
|
|
44
52
|
`;
|
|
45
53
|
|
|
46
|
-
const
|
|
54
|
+
const ComponentDefinitionTemplate = ({className}: {className: string}) =>
|
|
47
55
|
`
|
|
48
56
|
using ${className}ComponentDescriptor = ConcreteComponentDescriptor<${className}ShadowNode>;
|
|
49
57
|
`.trim();
|
|
@@ -58,7 +66,7 @@ module.exports = {
|
|
|
58
66
|
): FilesOutput {
|
|
59
67
|
const fileName = 'ComponentDescriptors.h';
|
|
60
68
|
|
|
61
|
-
const
|
|
69
|
+
const componentDefinitions = Object.keys(schema.modules)
|
|
62
70
|
.map(moduleName => {
|
|
63
71
|
const module = schema.modules[moduleName];
|
|
64
72
|
if (module.type !== 'Component') {
|
|
@@ -77,7 +85,7 @@ module.exports = {
|
|
|
77
85
|
return;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
return
|
|
88
|
+
return ComponentDefinitionTemplate({className: componentName});
|
|
81
89
|
})
|
|
82
90
|
.join('\n');
|
|
83
91
|
})
|
|
@@ -85,7 +93,8 @@ module.exports = {
|
|
|
85
93
|
.join('\n');
|
|
86
94
|
|
|
87
95
|
const replacedTemplate = FileTemplate({
|
|
88
|
-
|
|
96
|
+
libraryName,
|
|
97
|
+
componentDefinitions,
|
|
89
98
|
headerPrefix: headerPrefix ?? '',
|
|
90
99
|
});
|
|
91
100
|
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
const _require = require('../Utils'),
|
|
14
14
|
indent = _require.indent;
|
|
15
15
|
const _require2 = require('./CppHelpers'),
|
|
16
|
+
IncludeTemplate = _require2.IncludeTemplate,
|
|
16
17
|
generateEventStructName = _require2.generateEventStructName;
|
|
17
18
|
|
|
18
19
|
// File path -> contents
|
|
@@ -27,7 +28,10 @@ const FileTemplate = ({events, extraIncludes, headerPrefix}) => `
|
|
|
27
28
|
* ${'@'}generated by codegen project: GenerateEventEmitterCpp.js
|
|
28
29
|
*/
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
${IncludeTemplate({
|
|
32
|
+
headerPrefix,
|
|
33
|
+
file: 'EventEmitters.h',
|
|
34
|
+
})}
|
|
31
35
|
${[...extraIncludes].join('\n')}
|
|
32
36
|
|
|
33
37
|
namespace facebook::react {
|
|
@@ -319,9 +323,10 @@ function generateEvent(componentName, event, extraIncludes) {
|
|
|
319
323
|
// In order to migrate to this new system we have to support the current
|
|
320
324
|
// naming scheme. We should delete this once we are able to control this name
|
|
321
325
|
// throughout the system.
|
|
322
|
-
const dispatchEventName =
|
|
323
|
-
|
|
324
|
-
|
|
326
|
+
const dispatchEventName =
|
|
327
|
+
event.paperTopLevelNameDeprecated != null
|
|
328
|
+
? event.paperTopLevelNameDeprecated
|
|
329
|
+
: `${event.name[2].toLowerCase()}${event.name.slice(3)}`;
|
|
325
330
|
if (event.typeAnnotation.argument) {
|
|
326
331
|
const implementation = `
|
|
327
332
|
auto $payload = jsi::Object(runtime);
|
|
@@ -19,7 +19,7 @@ import type {
|
|
|
19
19
|
} from '../../CodegenSchema';
|
|
20
20
|
|
|
21
21
|
const {indent} = require('../Utils');
|
|
22
|
-
const {generateEventStructName} = require('./CppHelpers');
|
|
22
|
+
const {IncludeTemplate, generateEventStructName} = require('./CppHelpers');
|
|
23
23
|
|
|
24
24
|
// File path -> contents
|
|
25
25
|
type FilesOutput = Map<string, string>;
|
|
@@ -47,7 +47,7 @@ const FileTemplate = ({
|
|
|
47
47
|
* ${'@'}generated by codegen project: GenerateEventEmitterCpp.js
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
${IncludeTemplate({headerPrefix, file: 'EventEmitters.h'})}
|
|
51
51
|
${[...extraIncludes].join('\n')}
|
|
52
52
|
|
|
53
53
|
namespace facebook::react {
|
|
@@ -369,9 +369,10 @@ function generateEvent(
|
|
|
369
369
|
// In order to migrate to this new system we have to support the current
|
|
370
370
|
// naming scheme. We should delete this once we are able to control this name
|
|
371
371
|
// throughout the system.
|
|
372
|
-
const dispatchEventName =
|
|
373
|
-
|
|
374
|
-
|
|
372
|
+
const dispatchEventName =
|
|
373
|
+
event.paperTopLevelNameDeprecated != null
|
|
374
|
+
? event.paperTopLevelNameDeprecated
|
|
375
|
+
: `${event.name[2].toLowerCase()}${event.name.slice(3)}`;
|
|
375
376
|
|
|
376
377
|
if (event.typeAnnotation.argument) {
|
|
377
378
|
const implementation = `
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
const _require = require('./CppHelpers'),
|
|
14
|
+
IncludeTemplate = _require.IncludeTemplate,
|
|
14
15
|
convertDefaultTypeToString = _require.convertDefaultTypeToString,
|
|
15
16
|
getImports = _require.getImports;
|
|
16
17
|
|
|
@@ -26,7 +27,10 @@ const FileTemplate = ({imports, componentClasses, headerPrefix}) => `
|
|
|
26
27
|
* ${'@'}generated by codegen project: GeneratePropsCpp.js
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
${IncludeTemplate({
|
|
31
|
+
headerPrefix,
|
|
32
|
+
file: 'Props.h',
|
|
33
|
+
})}
|
|
30
34
|
${imports}
|
|
31
35
|
|
|
32
36
|
namespace facebook::react {
|
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
import type {ComponentShape, SchemaType} from '../../CodegenSchema';
|
|
14
14
|
|
|
15
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
IncludeTemplate,
|
|
17
|
+
convertDefaultTypeToString,
|
|
18
|
+
getImports,
|
|
19
|
+
} = require('./CppHelpers');
|
|
16
20
|
|
|
17
21
|
// File path -> contents
|
|
18
22
|
type FilesOutput = Map<string, string>;
|
|
@@ -35,7 +39,7 @@ const FileTemplate = ({
|
|
|
35
39
|
* ${'@'}generated by codegen project: GeneratePropsCpp.js
|
|
36
40
|
*/
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
${IncludeTemplate({headerPrefix, file: 'Props.h'})}
|
|
39
43
|
${imports}
|
|
40
44
|
|
|
41
45
|
namespace facebook::react {
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
const _require = require('./CppHelpers'),
|
|
14
|
+
IncludeTemplate = _require.IncludeTemplate;
|
|
15
|
+
|
|
13
16
|
// File path -> contents
|
|
14
17
|
|
|
15
18
|
const FileTemplate = ({componentNames, headerPrefix}) => `
|
|
@@ -22,7 +25,10 @@ const FileTemplate = ({componentNames, headerPrefix}) => `
|
|
|
22
25
|
* ${'@'}generated by codegen project: GenerateShadowNodeCpp.js
|
|
23
26
|
*/
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
${IncludeTemplate({
|
|
29
|
+
headerPrefix,
|
|
30
|
+
file: 'ShadowNodes.h',
|
|
31
|
+
})}
|
|
26
32
|
|
|
27
33
|
namespace facebook::react {
|
|
28
34
|
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import type {SchemaType} from '../../CodegenSchema';
|
|
14
14
|
|
|
15
|
+
const {IncludeTemplate} = require('./CppHelpers');
|
|
16
|
+
|
|
15
17
|
// File path -> contents
|
|
16
18
|
type FilesOutput = Map<string, string>;
|
|
17
19
|
|
|
@@ -31,7 +33,7 @@ const FileTemplate = ({
|
|
|
31
33
|
* ${'@'}generated by codegen project: GenerateShadowNodeCpp.js
|
|
32
34
|
*/
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
${IncludeTemplate({headerPrefix, file: 'ShadowNodes.h'})}
|
|
35
37
|
|
|
36
38
|
namespace facebook::react {
|
|
37
39
|
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
const _require = require('./CppHelpers'),
|
|
14
|
+
IncludeTemplate = _require.IncludeTemplate;
|
|
15
|
+
|
|
13
16
|
// File path -> contents
|
|
14
17
|
|
|
15
18
|
const FileTemplate = ({componentClasses, headerPrefix}) => `
|
|
@@ -24,9 +27,18 @@ const FileTemplate = ({componentClasses, headerPrefix}) => `
|
|
|
24
27
|
|
|
25
28
|
#pragma once
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
${IncludeTemplate({
|
|
31
|
+
headerPrefix,
|
|
32
|
+
file: 'EventEmitters.h',
|
|
33
|
+
})}
|
|
34
|
+
${IncludeTemplate({
|
|
35
|
+
headerPrefix,
|
|
36
|
+
file: 'Props.h',
|
|
37
|
+
})}
|
|
38
|
+
${IncludeTemplate({
|
|
39
|
+
headerPrefix,
|
|
40
|
+
file: 'States.h',
|
|
41
|
+
})}
|
|
30
42
|
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
31
43
|
#include <jsi/jsi.h>
|
|
32
44
|
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import type {SchemaType} from '../../CodegenSchema';
|
|
14
14
|
|
|
15
|
+
const {IncludeTemplate} = require('./CppHelpers');
|
|
16
|
+
|
|
15
17
|
// File path -> contents
|
|
16
18
|
type FilesOutput = Map<string, string>;
|
|
17
19
|
|
|
@@ -33,9 +35,9 @@ const FileTemplate = ({
|
|
|
33
35
|
|
|
34
36
|
#pragma once
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
${IncludeTemplate({headerPrefix, file: 'EventEmitters.h'})}
|
|
39
|
+
${IncludeTemplate({headerPrefix, file: 'Props.h'})}
|
|
40
|
+
${IncludeTemplate({headerPrefix, file: 'States.h'})}
|
|
39
41
|
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
40
42
|
#include <jsi/jsi.h>
|
|
41
43
|
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
const _require = require('./CppHelpers'),
|
|
14
|
+
IncludeTemplate = _require.IncludeTemplate;
|
|
15
|
+
|
|
13
16
|
// File path -> contents
|
|
14
17
|
|
|
15
18
|
const FileTemplate = ({stateClasses, headerPrefix}) => `
|
|
@@ -21,7 +24,10 @@ const FileTemplate = ({stateClasses, headerPrefix}) => `
|
|
|
21
24
|
*
|
|
22
25
|
* ${'@'}generated by codegen project: GenerateStateCpp.js
|
|
23
26
|
*/
|
|
24
|
-
|
|
27
|
+
${IncludeTemplate({
|
|
28
|
+
headerPrefix,
|
|
29
|
+
file: 'States.h',
|
|
30
|
+
})}
|
|
25
31
|
|
|
26
32
|
namespace facebook::react {
|
|
27
33
|
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import type {SchemaType} from '../../CodegenSchema';
|
|
14
14
|
|
|
15
|
+
const {IncludeTemplate} = require('./CppHelpers');
|
|
16
|
+
|
|
15
17
|
// File path -> contents
|
|
16
18
|
type FilesOutput = Map<string, string>;
|
|
17
19
|
|
|
@@ -30,7 +32,7 @@ const FileTemplate = ({
|
|
|
30
32
|
*
|
|
31
33
|
* ${'@'}generated by codegen project: GenerateStateCpp.js
|
|
32
34
|
*/
|
|
33
|
-
|
|
35
|
+
${IncludeTemplate({headerPrefix, file: 'States.h'})}
|
|
34
36
|
|
|
35
37
|
namespace facebook::react {
|
|
36
38
|
|
|
@@ -79,10 +79,13 @@ target_link_libraries(
|
|
|
79
79
|
${libraryName !== 'rncore' ? 'react_codegen_rncore' : ''}
|
|
80
80
|
react_debug
|
|
81
81
|
react_nativemodule_core
|
|
82
|
+
react_render_componentregistry
|
|
82
83
|
react_render_core
|
|
83
84
|
react_render_debug
|
|
84
85
|
react_render_graphics
|
|
85
86
|
react_render_imagemanager
|
|
87
|
+
react_render_mapbuffer
|
|
88
|
+
react_utils
|
|
86
89
|
rrc_image
|
|
87
90
|
rrc_view
|
|
88
91
|
turbomodulejsijni
|
|
@@ -91,10 +91,13 @@ target_link_libraries(
|
|
|
91
91
|
${libraryName !== 'rncore' ? 'react_codegen_rncore' : ''}
|
|
92
92
|
react_debug
|
|
93
93
|
react_nativemodule_core
|
|
94
|
+
react_render_componentregistry
|
|
94
95
|
react_render_core
|
|
95
96
|
react_render_debug
|
|
96
97
|
react_render_graphics
|
|
97
98
|
react_render_imagemanager
|
|
99
|
+
react_render_mapbuffer
|
|
100
|
+
react_utils
|
|
98
101
|
rrc_image
|
|
99
102
|
rrc_view
|
|
100
103
|
turbomodulejsijni
|