@react-native/codegen 0.74.0 → 0.75.0-nightly-20240221-a1171f79f
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/CodegenSchema.d.ts +10 -1
- package/lib/CodegenSchema.js.flow +2 -1
- package/lib/SchemaValidator.js.flow +2 -2
- package/lib/cli/combine/combine-js-to-schema-cli.js +59 -40
- package/lib/cli/combine/combine-js-to-schema-cli.js.flow +23 -39
- package/lib/cli/combine/combine-js-to-schema.js +49 -1
- package/lib/cli/combine/combine-js-to-schema.js.flow +59 -1
- package/lib/cli/combine/combine-schemas-cli.js +77 -0
- package/lib/cli/combine/combine-schemas-cli.js.flow +87 -0
- package/lib/cli/combine/combine-utils.js +3 -65
- package/lib/cli/combine/combine-utils.js.flow +7 -28
- package/lib/cli/parser/parser.js +1 -1
- package/lib/cli/parser/parser.js.flow +1 -1
- package/lib/generators/RNCodegen.d.ts +1 -0
- package/lib/generators/RNCodegen.js +58 -31
- package/lib/generators/RNCodegen.js.flow +52 -32
- package/lib/generators/TypeUtils/Cxx/index.js +17 -0
- package/lib/generators/TypeUtils/Cxx/index.js.flow +18 -0
- package/lib/generators/TypeUtils/Java/index.js +31 -0
- package/lib/generators/TypeUtils/Java/index.js.flow +27 -0
- package/lib/generators/TypeUtils/Objective-C/index.js +17 -0
- package/lib/generators/TypeUtils/Objective-C/index.js.flow +18 -0
- package/lib/generators/components/ComponentsGeneratorUtils.js +7 -7
- package/lib/generators/components/ComponentsGeneratorUtils.js.flow +8 -10
- package/lib/generators/components/ComponentsProviderUtils.js +55 -0
- package/lib/generators/components/ComponentsProviderUtils.js.flow +60 -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 +28 -12
- package/lib/generators/components/GenerateComponentDescriptorH.js.flow +20 -12
- package/lib/generators/components/GenerateComponentHObjCpp.js +15 -1
- package/lib/generators/components/GenerateComponentHObjCpp.js.flow +11 -2
- package/lib/generators/components/GenerateEventEmitterCpp.js +28 -15
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +16 -17
- package/lib/generators/components/GenerateEventEmitterH.js +20 -13
- package/lib/generators/components/GenerateEventEmitterH.js.flow +13 -15
- package/lib/generators/components/GeneratePropsCpp.js +17 -8
- package/lib/generators/components/GeneratePropsCpp.js.flow +13 -9
- package/lib/generators/components/GeneratePropsH.js +23 -16
- package/lib/generators/components/GeneratePropsH.js.flow +12 -16
- package/lib/generators/components/GeneratePropsJavaDelegate.js +11 -3
- package/lib/generators/components/GeneratePropsJavaDelegate.js.flow +7 -4
- package/lib/generators/components/GeneratePropsJavaInterface.js +11 -3
- package/lib/generators/components/GeneratePropsJavaInterface.js.flow +6 -3
- package/lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js.flow +6 -6
- package/lib/generators/components/GeneratePropsJavaPojo/index.js +1 -1
- package/lib/generators/components/GeneratePropsJavaPojo/index.js.flow +1 -1
- package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js.flow +1 -0
- package/lib/generators/components/GenerateShadowNodeCpp.js +19 -8
- package/lib/generators/components/GenerateShadowNodeCpp.js.flow +9 -8
- package/lib/generators/components/GenerateShadowNodeH.js +27 -11
- package/lib/generators/components/GenerateShadowNodeH.js.flow +11 -14
- package/lib/generators/components/GenerateStateCpp.js +19 -8
- package/lib/generators/components/GenerateStateCpp.js.flow +9 -8
- package/lib/generators/components/GenerateStateH.js +9 -5
- package/lib/generators/components/GenerateStateH.js.flow +3 -4
- package/lib/generators/components/GenerateTests.js +11 -5
- package/lib/generators/components/GenerateTests.js.flow +2 -2
- package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js +16 -3
- package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js.flow +18 -3
- package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js +18 -3
- package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js.flow +21 -3
- package/lib/generators/components/GenerateViewConfigJs.js +2 -2
- package/lib/generators/components/GenerateViewConfigJs.js.flow +2 -2
- package/lib/generators/components/JavaHelpers.js +8 -0
- package/lib/generators/components/JavaHelpers.js.flow +9 -0
- package/lib/generators/components/__test_fixtures__/fixtures.js +22 -0
- package/lib/generators/components/__test_fixtures__/fixtures.js.flow +22 -0
- package/lib/generators/modules/GenerateModuleCpp.js +14 -10
- package/lib/generators/modules/GenerateModuleCpp.js.flow +9 -10
- package/lib/generators/modules/GenerateModuleH.js +198 -72
- package/lib/generators/modules/GenerateModuleH.js.flow +186 -71
- package/lib/generators/modules/GenerateModuleJavaSpec.js +50 -57
- package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +45 -50
- package/lib/generators/modules/GenerateModuleJniCpp.js +16 -12
- package/lib/generators/modules/GenerateModuleJniCpp.js.flow +11 -12
- package/lib/generators/modules/GenerateModuleJniH.js +12 -5
- package/lib/generators/modules/GenerateModuleJniH.js.flow +8 -6
- package/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js +5 -5
- package/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js.flow +11 -12
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js +23 -21
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js.flow +19 -18
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js +23 -21
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js.flow +19 -18
- package/lib/generators/modules/GenerateModuleObjCpp/index.js +18 -20
- package/lib/generators/modules/GenerateModuleObjCpp/index.js.flow +11 -14
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js +40 -42
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow +38 -44
- package/lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js +25 -27
- package/lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js.flow +26 -28
- package/lib/generators/modules/Utils.js +98 -0
- package/lib/generators/modules/Utils.js.flow +34 -2
- package/lib/generators/modules/__test_fixtures__/fixtures.js +685 -64
- package/lib/generators/modules/__test_fixtures__/fixtures.js.flow +686 -64
- package/lib/parsers/error-utils.js +17 -17
- package/lib/parsers/error-utils.js.flow +10 -10
- package/lib/parsers/errors.js +10 -0
- package/lib/parsers/errors.js.flow +15 -1
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js +7 -1
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow +7 -1
- package/lib/parsers/flow/components/commands.js +24 -0
- package/lib/parsers/flow/components/commands.js.flow +45 -3
- package/lib/parsers/flow/components/componentsUtils.js +5 -4
- package/lib/parsers/flow/components/componentsUtils.js.flow +4 -3
- package/lib/parsers/flow/components/events.js +7 -7
- package/lib/parsers/flow/components/events.js.flow +7 -7
- package/lib/parsers/flow/components/index.js +8 -8
- package/lib/parsers/flow/components/index.js.flow +3 -3
- package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js +13 -0
- package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js.flow +13 -0
- package/lib/parsers/flow/modules/index.js +20 -19
- package/lib/parsers/flow/modules/index.js.flow +10 -11
- package/lib/parsers/flow/parseFlowAndThrowErrors.js +105 -0
- package/lib/parsers/flow/parseFlowAndThrowErrors.js.flow +41 -0
- package/lib/parsers/flow/parser.js +24 -25
- package/lib/parsers/flow/parser.js.flow +27 -36
- package/lib/parsers/flow/utils.js.flow +1 -1
- package/lib/parsers/parser.js.flow +12 -10
- package/lib/parsers/parserMock.js +11 -12
- package/lib/parsers/parserMock.js.flow +25 -28
- package/lib/parsers/parsers-commons.js +85 -36
- package/lib/parsers/parsers-commons.js.flow +71 -37
- package/lib/parsers/parsers-primitives.js +17 -17
- package/lib/parsers/parsers-primitives.js.flow +14 -16
- package/lib/parsers/schema.js.flow +3 -3
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js +8 -1
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow +8 -1
- package/lib/parsers/typescript/components/commands.js +23 -15
- package/lib/parsers/typescript/components/commands.js.flow +24 -16
- package/lib/parsers/typescript/components/componentsUtils.js +34 -20
- package/lib/parsers/typescript/components/componentsUtils.js.flow +36 -19
- package/lib/parsers/typescript/components/events.js +22 -22
- package/lib/parsers/typescript/components/events.js.flow +11 -10
- package/lib/parsers/typescript/components/extends.js.flow +1 -0
- package/lib/parsers/typescript/components/index.js +10 -10
- package/lib/parsers/typescript/components/index.js.flow +4 -4
- package/lib/parsers/typescript/modules/__test_fixtures__/fixtures.js +13 -0
- package/lib/parsers/typescript/modules/__test_fixtures__/fixtures.js.flow +13 -0
- package/lib/parsers/typescript/modules/index.js +25 -20
- package/lib/parsers/typescript/modules/index.js.flow +16 -14
- package/lib/parsers/typescript/parser.js +25 -26
- package/lib/parsers/typescript/parser.js.flow +23 -27
- package/lib/parsers/utils.js +5 -0
- package/lib/parsers/utils.js.flow +6 -1
- package/package.json +8 -6
|
@@ -12,15 +12,17 @@
|
|
|
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
|
-
libraryName,
|
|
20
21
|
componentNames,
|
|
22
|
+
headerPrefix,
|
|
21
23
|
}: {
|
|
22
|
-
libraryName: string,
|
|
23
24
|
componentNames: string,
|
|
25
|
+
headerPrefix: string,
|
|
24
26
|
}) => `
|
|
25
27
|
/**
|
|
26
28
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
@@ -31,15 +33,13 @@ const FileTemplate = ({
|
|
|
31
33
|
* ${'@'}generated by codegen project: GenerateShadowNodeCpp.js
|
|
32
34
|
*/
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
${IncludeTemplate({headerPrefix, file: 'ShadowNodes.h'})}
|
|
35
37
|
|
|
36
|
-
namespace facebook {
|
|
37
|
-
namespace react {
|
|
38
|
+
namespace facebook::react {
|
|
38
39
|
|
|
39
40
|
${componentNames}
|
|
40
41
|
|
|
41
|
-
} // namespace react
|
|
42
|
-
} // namespace facebook
|
|
42
|
+
} // namespace facebook::react
|
|
43
43
|
`;
|
|
44
44
|
|
|
45
45
|
const ComponentTemplate = ({className}: {className: string}) =>
|
|
@@ -53,6 +53,7 @@ module.exports = {
|
|
|
53
53
|
schema: SchemaType,
|
|
54
54
|
packageName?: string,
|
|
55
55
|
assumeNonnull: boolean = false,
|
|
56
|
+
headerPrefix?: string,
|
|
56
57
|
): FilesOutput {
|
|
57
58
|
const fileName = 'ShadowNodes.cpp';
|
|
58
59
|
|
|
@@ -87,7 +88,7 @@ module.exports = {
|
|
|
87
88
|
|
|
88
89
|
const replacedTemplate = FileTemplate({
|
|
89
90
|
componentNames,
|
|
90
|
-
|
|
91
|
+
headerPrefix: headerPrefix ?? '',
|
|
91
92
|
});
|
|
92
93
|
|
|
93
94
|
return new Map([[fileName, replacedTemplate]]);
|
|
@@ -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 = ({componentClasses, headerPrefix}) => `
|
|
16
19
|
/**
|
|
17
20
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
18
21
|
*
|
|
@@ -24,18 +27,26 @@ const FileTemplate = ({imports, libraryName, componentClasses}) => `
|
|
|
24
27
|
|
|
25
28
|
#pragma once
|
|
26
29
|
|
|
27
|
-
${
|
|
28
|
-
|
|
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
|
+
})}
|
|
29
42
|
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
30
43
|
#include <jsi/jsi.h>
|
|
31
44
|
|
|
32
|
-
namespace facebook {
|
|
33
|
-
namespace react {
|
|
45
|
+
namespace facebook::react {
|
|
34
46
|
|
|
35
47
|
${componentClasses}
|
|
36
48
|
|
|
37
|
-
} // namespace react
|
|
38
|
-
} // namespace facebook
|
|
49
|
+
} // namespace facebook::react
|
|
39
50
|
`;
|
|
40
51
|
const ComponentTemplate = ({className, eventEmitter}) =>
|
|
41
52
|
`
|
|
@@ -50,7 +61,13 @@ using ${className}ShadowNode = ConcreteViewShadowNode<
|
|
|
50
61
|
${className}State>;
|
|
51
62
|
`.trim();
|
|
52
63
|
module.exports = {
|
|
53
|
-
generate(
|
|
64
|
+
generate(
|
|
65
|
+
libraryName,
|
|
66
|
+
schema,
|
|
67
|
+
packageName,
|
|
68
|
+
assumeNonnull = false,
|
|
69
|
+
headerPrefix,
|
|
70
|
+
) {
|
|
54
71
|
const fileName = 'ShadowNodes.h';
|
|
55
72
|
const moduleResults = Object.keys(schema.modules)
|
|
56
73
|
.map(moduleName => {
|
|
@@ -80,11 +97,10 @@ module.exports = {
|
|
|
80
97
|
})
|
|
81
98
|
.filter(Boolean)
|
|
82
99
|
.join('\n\n');
|
|
83
|
-
const eventEmitterImport = `#include <react/renderer/components/${libraryName}/EventEmitters.h>\n`;
|
|
84
100
|
const replacedTemplate = FileTemplate({
|
|
85
101
|
componentClasses: moduleResults,
|
|
86
|
-
|
|
87
|
-
|
|
102
|
+
headerPrefix:
|
|
103
|
+
headerPrefix !== null && headerPrefix !== void 0 ? headerPrefix : '',
|
|
88
104
|
});
|
|
89
105
|
return new Map([[fileName, replacedTemplate]]);
|
|
90
106
|
},
|
|
@@ -12,17 +12,17 @@
|
|
|
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
|
-
imports,
|
|
20
|
-
libraryName,
|
|
21
21
|
componentClasses,
|
|
22
|
+
headerPrefix,
|
|
22
23
|
}: {
|
|
23
|
-
imports: string,
|
|
24
|
-
libraryName: string,
|
|
25
24
|
componentClasses: string,
|
|
25
|
+
headerPrefix: string,
|
|
26
26
|
}) => `
|
|
27
27
|
/**
|
|
28
28
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
@@ -35,18 +35,17 @@ const FileTemplate = ({
|
|
|
35
35
|
|
|
36
36
|
#pragma once
|
|
37
37
|
|
|
38
|
-
${
|
|
39
|
-
|
|
38
|
+
${IncludeTemplate({headerPrefix, file: 'EventEmitters.h'})}
|
|
39
|
+
${IncludeTemplate({headerPrefix, file: 'Props.h'})}
|
|
40
|
+
${IncludeTemplate({headerPrefix, file: 'States.h'})}
|
|
40
41
|
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
41
42
|
#include <jsi/jsi.h>
|
|
42
43
|
|
|
43
|
-
namespace facebook {
|
|
44
|
-
namespace react {
|
|
44
|
+
namespace facebook::react {
|
|
45
45
|
|
|
46
46
|
${componentClasses}
|
|
47
47
|
|
|
48
|
-
} // namespace react
|
|
49
|
-
} // namespace facebook
|
|
48
|
+
} // namespace facebook::react
|
|
50
49
|
`;
|
|
51
50
|
|
|
52
51
|
const ComponentTemplate = ({
|
|
@@ -74,6 +73,7 @@ module.exports = {
|
|
|
74
73
|
schema: SchemaType,
|
|
75
74
|
packageName?: string,
|
|
76
75
|
assumeNonnull: boolean = false,
|
|
76
|
+
headerPrefix?: string,
|
|
77
77
|
): FilesOutput {
|
|
78
78
|
const fileName = 'ShadowNodes.h';
|
|
79
79
|
|
|
@@ -111,12 +111,9 @@ module.exports = {
|
|
|
111
111
|
.filter(Boolean)
|
|
112
112
|
.join('\n\n');
|
|
113
113
|
|
|
114
|
-
const eventEmitterImport = `#include <react/renderer/components/${libraryName}/EventEmitters.h>\n`;
|
|
115
|
-
|
|
116
114
|
const replacedTemplate = FileTemplate({
|
|
117
115
|
componentClasses: moduleResults,
|
|
118
|
-
|
|
119
|
-
imports: eventEmitterImport,
|
|
116
|
+
headerPrefix: headerPrefix ?? '',
|
|
120
117
|
});
|
|
121
118
|
|
|
122
119
|
return new Map([[fileName, replacedTemplate]]);
|
|
@@ -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 = ({stateClasses, headerPrefix}) => `
|
|
16
19
|
/**
|
|
17
20
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
18
21
|
*
|
|
@@ -21,19 +24,26 @@ const FileTemplate = ({libraryName, stateClasses}) => `
|
|
|
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
|
-
namespace facebook {
|
|
27
|
-
namespace react {
|
|
32
|
+
namespace facebook::react {
|
|
28
33
|
|
|
29
34
|
${stateClasses}
|
|
30
35
|
|
|
31
|
-
} // namespace react
|
|
32
|
-
} // namespace facebook
|
|
36
|
+
} // namespace facebook::react
|
|
33
37
|
`;
|
|
34
38
|
const StateTemplate = ({stateName}) => '';
|
|
35
39
|
module.exports = {
|
|
36
|
-
generate(
|
|
40
|
+
generate(
|
|
41
|
+
libraryName,
|
|
42
|
+
schema,
|
|
43
|
+
packageName,
|
|
44
|
+
assumeNonnull = false,
|
|
45
|
+
headerPrefix,
|
|
46
|
+
) {
|
|
37
47
|
const fileName = 'States.cpp';
|
|
38
48
|
const stateClasses = Object.keys(schema.modules)
|
|
39
49
|
.map(moduleName => {
|
|
@@ -62,8 +72,9 @@ module.exports = {
|
|
|
62
72
|
.filter(Boolean)
|
|
63
73
|
.join('\n');
|
|
64
74
|
const replacedTemplate = FileTemplate({
|
|
65
|
-
libraryName,
|
|
66
75
|
stateClasses,
|
|
76
|
+
headerPrefix:
|
|
77
|
+
headerPrefix !== null && headerPrefix !== void 0 ? headerPrefix : '',
|
|
67
78
|
});
|
|
68
79
|
return new Map([[fileName, replacedTemplate]]);
|
|
69
80
|
},
|
|
@@ -12,15 +12,17 @@
|
|
|
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
|
-
libraryName,
|
|
20
21
|
stateClasses,
|
|
22
|
+
headerPrefix,
|
|
21
23
|
}: {
|
|
22
|
-
libraryName: string,
|
|
23
24
|
stateClasses: string,
|
|
25
|
+
headerPrefix: string,
|
|
24
26
|
}) => `
|
|
25
27
|
/**
|
|
26
28
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
@@ -30,15 +32,13 @@ const FileTemplate = ({
|
|
|
30
32
|
*
|
|
31
33
|
* ${'@'}generated by codegen project: GenerateStateCpp.js
|
|
32
34
|
*/
|
|
33
|
-
|
|
35
|
+
${IncludeTemplate({headerPrefix, file: 'States.h'})}
|
|
34
36
|
|
|
35
|
-
namespace facebook {
|
|
36
|
-
namespace react {
|
|
37
|
+
namespace facebook::react {
|
|
37
38
|
|
|
38
39
|
${stateClasses}
|
|
39
40
|
|
|
40
|
-
} // namespace react
|
|
41
|
-
} // namespace facebook
|
|
41
|
+
} // namespace facebook::react
|
|
42
42
|
`;
|
|
43
43
|
|
|
44
44
|
const StateTemplate = ({stateName}: {stateName: string}) => '';
|
|
@@ -49,6 +49,7 @@ module.exports = {
|
|
|
49
49
|
schema: SchemaType,
|
|
50
50
|
packageName?: string,
|
|
51
51
|
assumeNonnull: boolean = false,
|
|
52
|
+
headerPrefix?: string,
|
|
52
53
|
): FilesOutput {
|
|
53
54
|
const fileName = 'States.cpp';
|
|
54
55
|
|
|
@@ -83,8 +84,8 @@ module.exports = {
|
|
|
83
84
|
.join('\n');
|
|
84
85
|
|
|
85
86
|
const replacedTemplate = FileTemplate({
|
|
86
|
-
libraryName,
|
|
87
87
|
stateClasses,
|
|
88
|
+
headerPrefix: headerPrefix ?? '',
|
|
88
89
|
});
|
|
89
90
|
|
|
90
91
|
return new Map([[fileName, replacedTemplate]]);
|
|
@@ -30,13 +30,11 @@ const FileTemplate = ({libraryName, stateClasses}) =>
|
|
|
30
30
|
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
|
31
31
|
#endif
|
|
32
32
|
|
|
33
|
-
namespace facebook {
|
|
34
|
-
namespace react {
|
|
33
|
+
namespace facebook::react {
|
|
35
34
|
|
|
36
35
|
${stateClasses}
|
|
37
36
|
|
|
38
|
-
} // namespace react
|
|
39
|
-
} // namespace facebook
|
|
37
|
+
} // namespace facebook::react
|
|
40
38
|
`.trim();
|
|
41
39
|
const StateTemplate = ({stateName}) =>
|
|
42
40
|
`
|
|
@@ -56,7 +54,13 @@ public:
|
|
|
56
54
|
};
|
|
57
55
|
`.trim();
|
|
58
56
|
module.exports = {
|
|
59
|
-
generate(
|
|
57
|
+
generate(
|
|
58
|
+
libraryName,
|
|
59
|
+
schema,
|
|
60
|
+
packageName,
|
|
61
|
+
assumeNonnull = false,
|
|
62
|
+
headerPrefix,
|
|
63
|
+
) {
|
|
60
64
|
const fileName = 'States.h';
|
|
61
65
|
const stateClasses = Object.keys(schema.modules)
|
|
62
66
|
.map(moduleName => {
|
|
@@ -39,13 +39,11 @@ const FileTemplate = ({
|
|
|
39
39
|
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
|
40
40
|
#endif
|
|
41
41
|
|
|
42
|
-
namespace facebook {
|
|
43
|
-
namespace react {
|
|
42
|
+
namespace facebook::react {
|
|
44
43
|
|
|
45
44
|
${stateClasses}
|
|
46
45
|
|
|
47
|
-
} // namespace react
|
|
48
|
-
} // namespace facebook
|
|
46
|
+
} // namespace facebook::react
|
|
49
47
|
`.trim();
|
|
50
48
|
|
|
51
49
|
const StateTemplate = ({stateName}: {stateName: string}) =>
|
|
@@ -72,6 +70,7 @@ module.exports = {
|
|
|
72
70
|
schema: SchemaType,
|
|
73
71
|
packageName?: string,
|
|
74
72
|
assumeNonnull: boolean = false,
|
|
73
|
+
headerPrefix?: string,
|
|
75
74
|
): FilesOutput {
|
|
76
75
|
const fileName = 'States.h';
|
|
77
76
|
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const _require = require('
|
|
14
|
-
|
|
15
|
-
const _require2 = require('
|
|
16
|
-
|
|
13
|
+
const _require = require('../Utils'),
|
|
14
|
+
toSafeCppString = _require.toSafeCppString;
|
|
15
|
+
const _require2 = require('./CppHelpers'),
|
|
16
|
+
getImports = _require2.getImports;
|
|
17
17
|
const FileTemplate = ({libraryName, imports, componentTests}) =>
|
|
18
18
|
`
|
|
19
19
|
/**
|
|
@@ -125,7 +125,13 @@ function generateTestsString(name, component) {
|
|
|
125
125
|
return [baseTest, ...testCases].map(createTest).join('');
|
|
126
126
|
}
|
|
127
127
|
module.exports = {
|
|
128
|
-
generate(
|
|
128
|
+
generate(
|
|
129
|
+
libraryName,
|
|
130
|
+
schema,
|
|
131
|
+
packageName,
|
|
132
|
+
assumeNonnull = false,
|
|
133
|
+
headerPrefix,
|
|
134
|
+
) {
|
|
129
135
|
const fileName = 'Tests.cpp';
|
|
130
136
|
const allImports = new Set([
|
|
131
137
|
'#include <react/renderer/core/propsConversions.h>',
|
|
@@ -12,9 +12,8 @@
|
|
|
12
12
|
import type {ComponentShape, PropTypeAnnotation} from '../../CodegenSchema';
|
|
13
13
|
import type {SchemaType} from '../../CodegenSchema';
|
|
14
14
|
|
|
15
|
-
const {getImports} = require('./CppHelpers');
|
|
16
|
-
|
|
17
15
|
const {toSafeCppString} = require('../Utils');
|
|
16
|
+
const {getImports} = require('./CppHelpers');
|
|
18
17
|
|
|
19
18
|
type FilesOutput = Map<string, string>;
|
|
20
19
|
type PropValueType = string | number | boolean;
|
|
@@ -172,6 +171,7 @@ module.exports = {
|
|
|
172
171
|
schema: SchemaType,
|
|
173
172
|
packageName?: string,
|
|
174
173
|
assumeNonnull: boolean = false,
|
|
174
|
+
headerPrefix?: string,
|
|
175
175
|
): FilesOutput {
|
|
176
176
|
const fileName = 'Tests.cpp';
|
|
177
177
|
const allImports = new Set([
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
const _require = require('./ComponentsProviderUtils'),
|
|
14
|
+
generateSupportedApplePlatformsMacro =
|
|
15
|
+
_require.generateSupportedApplePlatformsMacro;
|
|
16
|
+
|
|
13
17
|
// File path -> contents
|
|
14
18
|
|
|
15
19
|
const FileTemplate = ({lookupFuncs}) => `
|
|
@@ -32,11 +36,12 @@ extern "C" {
|
|
|
32
36
|
#endif
|
|
33
37
|
|
|
34
38
|
Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name);
|
|
35
|
-
|
|
39
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
36
40
|
#ifndef RCT_DYNAMIC_FRAMEWORKS
|
|
37
41
|
|
|
38
42
|
${lookupFuncs}
|
|
39
43
|
|
|
44
|
+
#endif
|
|
40
45
|
#endif
|
|
41
46
|
|
|
42
47
|
#ifdef __cplusplus
|
|
@@ -51,12 +56,16 @@ const LookupFuncTemplate = ({className, libraryName}) =>
|
|
|
51
56
|
Class<RCTComponentViewProtocol> ${className}Cls(void) __attribute__((used)); // ${libraryName}
|
|
52
57
|
`.trim();
|
|
53
58
|
module.exports = {
|
|
54
|
-
generate(schemas) {
|
|
59
|
+
generate(schemas, supportedApplePlatforms) {
|
|
55
60
|
const fileName = 'RCTThirdPartyFabricComponentsProvider.h';
|
|
56
61
|
const lookupFuncs = Object.keys(schemas)
|
|
57
62
|
.map(libraryName => {
|
|
58
63
|
const schema = schemas[libraryName];
|
|
59
|
-
|
|
64
|
+
const librarySupportedApplePlatforms =
|
|
65
|
+
supportedApplePlatforms === null || supportedApplePlatforms === void 0
|
|
66
|
+
? void 0
|
|
67
|
+
: supportedApplePlatforms[libraryName];
|
|
68
|
+
const generatedLookup = Object.keys(schema.modules)
|
|
60
69
|
.map(moduleName => {
|
|
61
70
|
const module = schema.modules[moduleName];
|
|
62
71
|
if (module.type !== 'Component') {
|
|
@@ -85,6 +94,10 @@ module.exports = {
|
|
|
85
94
|
})
|
|
86
95
|
.filter(Boolean)
|
|
87
96
|
.join('\n');
|
|
97
|
+
return generateSupportedApplePlatformsMacro(
|
|
98
|
+
generatedLookup,
|
|
99
|
+
librarySupportedApplePlatforms,
|
|
100
|
+
);
|
|
88
101
|
})
|
|
89
102
|
.join('\n');
|
|
90
103
|
const replacedTemplate = FileTemplate({
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
import type {SchemaType} from '../../CodegenSchema';
|
|
14
14
|
|
|
15
|
+
const {
|
|
16
|
+
generateSupportedApplePlatformsMacro,
|
|
17
|
+
} = require('./ComponentsProviderUtils');
|
|
18
|
+
|
|
15
19
|
// File path -> contents
|
|
16
20
|
type FilesOutput = Map<string, string>;
|
|
17
21
|
|
|
@@ -35,11 +39,12 @@ extern "C" {
|
|
|
35
39
|
#endif
|
|
36
40
|
|
|
37
41
|
Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name);
|
|
38
|
-
|
|
42
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
39
43
|
#ifndef RCT_DYNAMIC_FRAMEWORKS
|
|
40
44
|
|
|
41
45
|
${lookupFuncs}
|
|
42
46
|
|
|
47
|
+
#endif
|
|
43
48
|
#endif
|
|
44
49
|
|
|
45
50
|
#ifdef __cplusplus
|
|
@@ -62,13 +67,18 @@ Class<RCTComponentViewProtocol> ${className}Cls(void) __attribute__((used)); //
|
|
|
62
67
|
`.trim();
|
|
63
68
|
|
|
64
69
|
module.exports = {
|
|
65
|
-
generate(
|
|
70
|
+
generate(
|
|
71
|
+
schemas: {[string]: SchemaType},
|
|
72
|
+
supportedApplePlatforms?: {[string]: {[string]: boolean}},
|
|
73
|
+
): FilesOutput {
|
|
66
74
|
const fileName = 'RCTThirdPartyFabricComponentsProvider.h';
|
|
67
75
|
|
|
68
76
|
const lookupFuncs = Object.keys(schemas)
|
|
69
77
|
.map(libraryName => {
|
|
70
78
|
const schema = schemas[libraryName];
|
|
71
|
-
|
|
79
|
+
const librarySupportedApplePlatforms =
|
|
80
|
+
supportedApplePlatforms?.[libraryName];
|
|
81
|
+
const generatedLookup = Object.keys(schema.modules)
|
|
72
82
|
.map(moduleName => {
|
|
73
83
|
const module = schema.modules[moduleName];
|
|
74
84
|
if (module.type !== 'Component') {
|
|
@@ -99,6 +109,11 @@ module.exports = {
|
|
|
99
109
|
})
|
|
100
110
|
.filter(Boolean)
|
|
101
111
|
.join('\n');
|
|
112
|
+
|
|
113
|
+
return generateSupportedApplePlatformsMacro(
|
|
114
|
+
generatedLookup,
|
|
115
|
+
librarySupportedApplePlatforms,
|
|
116
|
+
);
|
|
102
117
|
})
|
|
103
118
|
.join('\n');
|
|
104
119
|
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
const _require = require('./ComponentsProviderUtils'),
|
|
14
|
+
generateSupportedApplePlatformsMacro =
|
|
15
|
+
_require.generateSupportedApplePlatformsMacro;
|
|
16
|
+
|
|
13
17
|
// File path -> contents
|
|
14
18
|
|
|
15
19
|
const FileTemplate = ({lookupMap}) => `
|
|
@@ -31,9 +35,11 @@ const FileTemplate = ({lookupMap}) => `
|
|
|
31
35
|
|
|
32
36
|
Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) {
|
|
33
37
|
static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = {
|
|
38
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
34
39
|
#ifndef RCT_DYNAMIC_FRAMEWORKS
|
|
35
40
|
${lookupMap}
|
|
36
41
|
#endif
|
|
42
|
+
#endif
|
|
37
43
|
};
|
|
38
44
|
|
|
39
45
|
auto p = sFabricComponentsClassMap.find(name);
|
|
@@ -47,12 +53,16 @@ ${lookupMap}
|
|
|
47
53
|
const LookupMapTemplate = ({className, libraryName}) => `
|
|
48
54
|
{"${className}", ${className}Cls}, // ${libraryName}`;
|
|
49
55
|
module.exports = {
|
|
50
|
-
generate(schemas) {
|
|
56
|
+
generate(schemas, supportedApplePlatforms) {
|
|
51
57
|
const fileName = 'RCTThirdPartyFabricComponentsProvider.mm';
|
|
52
58
|
const lookupMap = Object.keys(schemas)
|
|
53
59
|
.map(libraryName => {
|
|
54
60
|
const schema = schemas[libraryName];
|
|
55
|
-
|
|
61
|
+
const librarySupportedApplePlatforms =
|
|
62
|
+
supportedApplePlatforms === null || supportedApplePlatforms === void 0
|
|
63
|
+
? void 0
|
|
64
|
+
: supportedApplePlatforms[libraryName];
|
|
65
|
+
const generatedLookup = Object.keys(schema.modules)
|
|
56
66
|
.map(moduleName => {
|
|
57
67
|
const module = schema.modules[moduleName];
|
|
58
68
|
if (module.type !== 'Component') {
|
|
@@ -80,7 +90,12 @@ module.exports = {
|
|
|
80
90
|
});
|
|
81
91
|
return componentTemplates.length > 0 ? componentTemplates : null;
|
|
82
92
|
})
|
|
83
|
-
.filter(Boolean)
|
|
93
|
+
.filter(Boolean)
|
|
94
|
+
.join('\n');
|
|
95
|
+
return generateSupportedApplePlatformsMacro(
|
|
96
|
+
generatedLookup,
|
|
97
|
+
librarySupportedApplePlatforms,
|
|
98
|
+
);
|
|
84
99
|
})
|
|
85
100
|
.join('\n');
|
|
86
101
|
const replacedTemplate = FileTemplate({
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
import type {SchemaType} from '../../CodegenSchema';
|
|
14
14
|
|
|
15
|
+
const {
|
|
16
|
+
generateSupportedApplePlatformsMacro,
|
|
17
|
+
} = require('./ComponentsProviderUtils');
|
|
18
|
+
|
|
15
19
|
// File path -> contents
|
|
16
20
|
type FilesOutput = Map<string, string>;
|
|
17
21
|
|
|
@@ -34,9 +38,11 @@ const FileTemplate = ({lookupMap}: {lookupMap: string}) => `
|
|
|
34
38
|
|
|
35
39
|
Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) {
|
|
36
40
|
static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = {
|
|
41
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
37
42
|
#ifndef RCT_DYNAMIC_FRAMEWORKS
|
|
38
43
|
${lookupMap}
|
|
39
44
|
#endif
|
|
45
|
+
#endif
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
auto p = sFabricComponentsClassMap.find(name);
|
|
@@ -58,13 +64,19 @@ const LookupMapTemplate = ({
|
|
|
58
64
|
{"${className}", ${className}Cls}, // ${libraryName}`;
|
|
59
65
|
|
|
60
66
|
module.exports = {
|
|
61
|
-
generate(
|
|
67
|
+
generate(
|
|
68
|
+
schemas: {[string]: SchemaType},
|
|
69
|
+
supportedApplePlatforms?: {[string]: {[string]: boolean}},
|
|
70
|
+
): FilesOutput {
|
|
62
71
|
const fileName = 'RCTThirdPartyFabricComponentsProvider.mm';
|
|
63
72
|
|
|
64
73
|
const lookupMap = Object.keys(schemas)
|
|
65
74
|
.map(libraryName => {
|
|
66
75
|
const schema = schemas[libraryName];
|
|
67
|
-
|
|
76
|
+
const librarySupportedApplePlatforms =
|
|
77
|
+
supportedApplePlatforms?.[libraryName];
|
|
78
|
+
|
|
79
|
+
const generatedLookup = Object.keys(schema.modules)
|
|
68
80
|
.map(moduleName => {
|
|
69
81
|
const module = schema.modules[moduleName];
|
|
70
82
|
if (module.type !== 'Component') {
|
|
@@ -96,7 +108,13 @@ module.exports = {
|
|
|
96
108
|
|
|
97
109
|
return componentTemplates.length > 0 ? componentTemplates : null;
|
|
98
110
|
})
|
|
99
|
-
.filter(Boolean)
|
|
111
|
+
.filter(Boolean)
|
|
112
|
+
.join('\n');
|
|
113
|
+
|
|
114
|
+
return generateSupportedApplePlatformsMacro(
|
|
115
|
+
generatedLookup,
|
|
116
|
+
librarySupportedApplePlatforms,
|
|
117
|
+
);
|
|
100
118
|
})
|
|
101
119
|
.join('\n');
|
|
102
120
|
|
|
@@ -167,7 +167,7 @@ function getValidAttributesForEvents(events, imports) {
|
|
|
167
167
|
function generateBubblingEventInfo(event, nameOveride) {
|
|
168
168
|
return j.property(
|
|
169
169
|
'init',
|
|
170
|
-
j.identifier(nameOveride ||
|
|
170
|
+
j.identifier(normalizeInputEventName(nameOveride || event.name)),
|
|
171
171
|
j.objectExpression([
|
|
172
172
|
j.property(
|
|
173
173
|
'init',
|
|
@@ -187,7 +187,7 @@ function generateBubblingEventInfo(event, nameOveride) {
|
|
|
187
187
|
function generateDirectEventInfo(event, nameOveride) {
|
|
188
188
|
return j.property(
|
|
189
189
|
'init',
|
|
190
|
-
j.identifier(nameOveride ||
|
|
190
|
+
j.identifier(normalizeInputEventName(nameOveride || event.name)),
|
|
191
191
|
j.objectExpression([
|
|
192
192
|
j.property(
|
|
193
193
|
'init',
|
|
@@ -197,7 +197,7 @@ function generateBubblingEventInfo(
|
|
|
197
197
|
) {
|
|
198
198
|
return j.property(
|
|
199
199
|
'init',
|
|
200
|
-
j.identifier(nameOveride ||
|
|
200
|
+
j.identifier(normalizeInputEventName(nameOveride || event.name)),
|
|
201
201
|
j.objectExpression([
|
|
202
202
|
j.property(
|
|
203
203
|
'init',
|
|
@@ -221,7 +221,7 @@ function generateDirectEventInfo(
|
|
|
221
221
|
) {
|
|
222
222
|
return j.property(
|
|
223
223
|
'init',
|
|
224
|
-
j.identifier(nameOveride ||
|
|
224
|
+
j.identifier(normalizeInputEventName(nameOveride || event.name)),
|
|
225
225
|
j.objectExpression([
|
|
226
226
|
j.property(
|
|
227
227
|
'init',
|