From f9a5b30e5a805061416123d037351e5c03860756 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 13 Feb 2024 05:29:24 -0800 Subject: [PATCH] Fix autolinking for local app Fabric components (#42962) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42962 Autolinking local app fabric component requires user to manipulate the C++ code. This removes this requirement by generating the code necessary to register all the discovered Fabric Components. I've updated the RN-Tester Android setup to use this mechanism also. Changelog: [Android] [Fixed] - Fix autolinking for local app Fabric components Reviewed By: RSNara Differential Revision: D53661231 fbshipit-source-id: 28c376fbd08c326f117f8d420485d63e2b4b1241 --- .../GenerateComponentDescriptorH-test.js.snap | 72 ++ .../src/generators/RNCodegen.d.ts | 1 + .../src/generators/RNCodegen.js | 4 + .../GenerateComponentDescriptorCpp.js | 103 +++ .../GenerateComponentDescriptorH.js | 21 +- .../GenerateComponentDescriptorCpp-test.js | 35 + ...enerateComponentDescriptorCpp-test.js.snap | 874 ++++++++++++++++++ .../GenerateComponentDescriptorH-test.js.snap | 116 +++ .../cmake-utils/ReactNative-application.cmake | 2 + .../cmake-utils/default-app-setup/OnLoad.cpp | 10 +- .../android/app/src/main/jni/OnLoad.cpp | 11 +- 11 files changed, 1236 insertions(+), 13 deletions(-) create mode 100644 packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorCpp.js create mode 100644 packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorCpp-test.js create mode 100644 packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorCpp-test.js.snap diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap index e989a3b2ecabf1..46757e6c95c090 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap @@ -16,11 +16,15 @@ Object { #include #include +#include namespace facebook::react { using ArrayPropsNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -42,11 +46,15 @@ Object { #include #include +#include namespace facebook::react { using BooleanPropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -68,11 +76,15 @@ Object { #include #include +#include namespace facebook::react { using ColorPropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -94,11 +106,15 @@ Object { #include #include +#include namespace facebook::react { using DimensionPropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -120,11 +136,15 @@ Object { #include #include +#include namespace facebook::react { using EdgeInsetsPropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -146,11 +166,15 @@ Object { #include #include +#include namespace facebook::react { using EnumPropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -172,11 +196,15 @@ Object { #include #include +#include namespace facebook::react { using EventNestedObjectPropsNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -198,11 +226,15 @@ Object { #include #include +#include namespace facebook::react { using EventPropsNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -224,11 +256,15 @@ Object { #include #include +#include namespace facebook::react { using FloatPropsNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -250,11 +286,15 @@ Object { #include #include +#include namespace facebook::react { using ImagePropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -276,11 +316,15 @@ Object { #include #include +#include namespace facebook::react { using IntegerPropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -302,11 +346,15 @@ Object { #include #include +#include namespace facebook::react { +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -328,11 +376,15 @@ Object { #include #include +#include namespace facebook::react { using MixedPropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -354,11 +406,15 @@ Object { #include #include +#include namespace facebook::react { using MultiNativePropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -380,11 +436,15 @@ Object { #include #include +#include namespace facebook::react { using NoPropsNoEventsNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -406,11 +466,15 @@ Object { #include #include +#include namespace facebook::react { using ObjectPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -432,11 +496,15 @@ Object { #include #include +#include namespace facebook::react { using PointPropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -458,11 +526,15 @@ Object { #include #include +#include namespace facebook::react { using StringPropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; +void RNCodegenModuleFixtures_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } diff --git a/packages/react-native-codegen/src/generators/RNCodegen.d.ts b/packages/react-native-codegen/src/generators/RNCodegen.d.ts index 9cf647abfcceea..f73eb2e0fa51b3 100644 --- a/packages/react-native-codegen/src/generators/RNCodegen.d.ts +++ b/packages/react-native-codegen/src/generators/RNCodegen.d.ts @@ -14,6 +14,7 @@ export type ViewGeneratorFunction = (libraryName: string, schema: SchemaType) => type LibraryGeneratorNames = | 'generateComponentDescriptorH' + | 'generateComponentDescriptorCpp' | 'generateComponentHObjCpp' | 'generateEventEmitterCpp' | 'generateEventEmitterH' diff --git a/packages/react-native-codegen/src/generators/RNCodegen.js b/packages/react-native-codegen/src/generators/RNCodegen.js index 5b7297f2ac0382..d363ceb0957c1c 100644 --- a/packages/react-native-codegen/src/generators/RNCodegen.js +++ b/packages/react-native-codegen/src/generators/RNCodegen.js @@ -19,6 +19,7 @@ TODO: import type {SchemaType} from '../CodegenSchema'; const schemaValidator = require('../SchemaValidator.js'); +const generateComponentDescriptorCpp = require('./components/GenerateComponentDescriptorCpp.js'); const generateComponentDescriptorH = require('./components/GenerateComponentDescriptorH.js'); const generateComponentHObjCpp = require('./components/GenerateComponentHObjCpp.js'); const generateEventEmitterCpp = require('./components/GenerateEventEmitterCpp.js'); @@ -46,6 +47,7 @@ const path = require('path'); const ALL_GENERATORS = { generateComponentDescriptorH: generateComponentDescriptorH.generate, + generateComponentDescriptorCpp: generateComponentDescriptorCpp.generate, generateComponentHObjCpp: generateComponentHObjCpp.generate, generateEventEmitterCpp: generateEventEmitterCpp.generate, generateEventEmitterH: generateEventEmitterH.generate, @@ -126,6 +128,7 @@ const LIBRARY_GENERATORS = { componentsAndroid: [ // JNI/C++ files generateComponentDescriptorH.generate, + generateComponentDescriptorCpp.generate, generateEventEmitterCpp.generate, generateEventEmitterH.generate, generatePropsCpp.generate, @@ -140,6 +143,7 @@ const LIBRARY_GENERATORS = { ], componentsIOS: [ generateComponentDescriptorH.generate, + generateComponentDescriptorCpp.generate, generateEventEmitterCpp.generate, generateEventEmitterH.generate, generateComponentHObjCpp.generate, diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorCpp.js b/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorCpp.js new file mode 100644 index 00000000000000..bdb1665348bcef --- /dev/null +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorCpp.js @@ -0,0 +1,103 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict + * @format + */ + +'use strict'; + +import type {SchemaType} from '../../CodegenSchema'; + +const {IncludeTemplate} = require('./CppHelpers'); + +// File path -> contents +type FilesOutput = Map; + +const FileTemplate = ({ + libraryName, + componentRegistrations, + headerPrefix, +}: { + libraryName: string, + componentRegistrations: string, + headerPrefix: string, +}) => ` +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * ${'@'}generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +${IncludeTemplate({headerPrefix, file: 'ShadowNodes.h'})} +#include +#include + +namespace facebook::react { + +void ${libraryName}_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +${componentRegistrations} +} + +} // namespace facebook::react +`; + +const ComponentRegistrationTemplate = ({className}: {className: string}) => + ` +registry->add(concreteComponentDescriptorProvider<${className}ComponentDescriptor>()); +`.trim(); + +module.exports = { + generate( + libraryName: string, + schema: SchemaType, + packageName?: string, + assumeNonnull: boolean = false, + headerPrefix?: string, + ): FilesOutput { + const fileName = 'ComponentDescriptors.h'; + + const componentRegistrations = Object.keys(schema.modules) + .map(moduleName => { + const module = schema.modules[moduleName]; + if (module.type !== 'Component') { + return; + } + + const {components} = module; + // No components in this module + if (components == null) { + return null; + } + + return Object.keys(components) + .map(componentName => { + if (components[componentName].interfaceOnly === true) { + return; + } + + return ComponentRegistrationTemplate({className: componentName}); + }) + .join('\n'); + }) + .filter(Boolean) + .join('\n'); + + const replacedTemplate = FileTemplate({ + libraryName, + componentRegistrations, + headerPrefix: headerPrefix ?? '', + }); + + return new Map([[fileName, replacedTemplate]]); + }, +}; diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js b/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js index 9bd6e0581cf747..0a68446cd1af71 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js @@ -18,10 +18,12 @@ const {IncludeTemplate} = require('./CppHelpers'); type FilesOutput = Map; const FileTemplate = ({ - componentDescriptors, + libraryName, + componentDefinitions, headerPrefix, }: { - componentDescriptors: string, + libraryName: string, + componentDefinitions: string, headerPrefix: string, }) => ` /** @@ -37,15 +39,19 @@ const FileTemplate = ({ ${IncludeTemplate({headerPrefix, file: 'ShadowNodes.h'})} #include +#include namespace facebook::react { -${componentDescriptors} +${componentDefinitions} + +void ${libraryName}_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); } // namespace facebook::react `; -const ComponentTemplate = ({className}: {className: string}) => +const ComponentDefinitionTemplate = ({className}: {className: string}) => ` using ${className}ComponentDescriptor = ConcreteComponentDescriptor<${className}ShadowNode>; `.trim(); @@ -60,7 +66,7 @@ module.exports = { ): FilesOutput { const fileName = 'ComponentDescriptors.h'; - const componentDescriptors = Object.keys(schema.modules) + const componentDefinitions = Object.keys(schema.modules) .map(moduleName => { const module = schema.modules[moduleName]; if (module.type !== 'Component') { @@ -79,7 +85,7 @@ module.exports = { return; } - return ComponentTemplate({className: componentName}); + return ComponentDefinitionTemplate({className: componentName}); }) .join('\n'); }) @@ -87,7 +93,8 @@ module.exports = { .join('\n'); const replacedTemplate = FileTemplate({ - componentDescriptors, + libraryName, + componentDefinitions, headerPrefix: headerPrefix ?? '', }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorCpp-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorCpp-test.js new file mode 100644 index 00000000000000..ebef5169033a4c --- /dev/null +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorCpp-test.js @@ -0,0 +1,35 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + * @oncall react_native + */ + +'use strict'; + +const fixtures = require('../__test_fixtures__/fixtures.js'); +const generator = require('../GenerateComponentDescriptorCpp.js'); + +describe('GenerateComponentDescriptorCpp', () => { + Object.keys(fixtures) + .sort() + .forEach(fixtureName => { + const fixture = fixtures[fixtureName]; + + it(`can generate fixture ${fixtureName}`, () => { + expect( + generator.generate( + fixtureName, + fixture, + '', + false, + `react/renderer/components/${fixtureName}/`, + ), + ).toMatchSnapshot(); + }); + }); +}); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorCpp-test.js.snap new file mode 100644 index 00000000000000..f6cc87ca9e2882 --- /dev/null +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorCpp-test.js.snap @@ -0,0 +1,874 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`GenerateComponentDescriptorCpp can generate fixture ARRAY_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void ARRAY_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void ARRAY_PROPS_WITH_NESTED_OBJECT_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture BOOLEAN_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void BOOLEAN_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture COLOR_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void COLOR_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture COMMANDS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void COMMANDS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture COMMANDS_AND_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void COMMANDS_AND_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture DIMENSION_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void DIMENSION_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture DOUBLE_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void DOUBLE_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void EVENT_NESTED_OBJECT_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture EVENT_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void EVENT_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void EVENTS_WITH_PAPER_NAME_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { + +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture EXCLUDE_ANDROID 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void EXCLUDE_ANDROID_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void EXCLUDE_ANDROID_IOS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture FLOAT_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void FLOAT_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture IMAGE_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void IMAGE_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture INSETS_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void INSETS_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void INT32_ENUM_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture INTEGER_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void INTEGER_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture INTERFACE_ONLY 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void INTERFACE_ONLY_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { + +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture MIXED_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void MIXED_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture MULTI_NATIVE_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void MULTI_NATIVE_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture NO_PROPS_NO_EVENTS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void NO_PROPS_NO_EVENTS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture OBJECT_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void OBJECT_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture POINT_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void POINT_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void STRING_ENUM_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture STRING_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void STRING_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void TWO_COMPONENTS_DIFFERENT_FILES_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; + +exports[`GenerateComponentDescriptorCpp can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +void TWO_COMPONENTS_SAME_FILE_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react +", +} +`; diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap index 7f55bcf5d714e1..605f4a21938960 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap @@ -16,11 +16,15 @@ Map { #include #include +#include namespace facebook::react { using ArrayPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void ARRAY_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -42,11 +46,15 @@ Map { #include #include +#include namespace facebook::react { using ArrayPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void ARRAY_PROPS_WITH_NESTED_OBJECT_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -68,11 +76,15 @@ Map { #include #include +#include namespace facebook::react { using BooleanPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void BOOLEAN_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -94,11 +106,15 @@ Map { #include #include +#include namespace facebook::react { using ColorPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void COLOR_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -120,11 +136,15 @@ Map { #include #include +#include namespace facebook::react { using CommandNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void COMMANDS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -146,11 +166,15 @@ Map { #include #include +#include namespace facebook::react { using CommandNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void COMMANDS_AND_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -172,11 +196,15 @@ Map { #include #include +#include namespace facebook::react { using DimensionPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void DIMENSION_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -198,11 +226,15 @@ Map { #include #include +#include namespace facebook::react { using DoublePropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void DOUBLE_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -224,11 +256,15 @@ Map { #include #include +#include namespace facebook::react { using EventsNestedObjectNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void EVENT_NESTED_OBJECT_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -250,11 +286,15 @@ Map { #include #include +#include namespace facebook::react { using EventsNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void EVENT_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -276,11 +316,15 @@ Map { #include #include +#include namespace facebook::react { +void EVENTS_WITH_PAPER_NAME_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -302,11 +346,15 @@ Map { #include #include +#include namespace facebook::react { using ExcludedAndroidComponentComponentDescriptor = ConcreteComponentDescriptor; +void EXCLUDE_ANDROID_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -328,11 +376,15 @@ Map { #include #include +#include namespace facebook::react { using ExcludedAndroidIosComponentComponentDescriptor = ConcreteComponentDescriptor; +void EXCLUDE_ANDROID_IOS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -354,12 +406,16 @@ Map { #include #include +#include namespace facebook::react { using ExcludedIosComponentComponentDescriptor = ConcreteComponentDescriptor; using MultiFileIncludedNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -381,11 +437,15 @@ Map { #include #include +#include namespace facebook::react { using FloatPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void FLOAT_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -407,11 +467,15 @@ Map { #include #include +#include namespace facebook::react { using ImagePropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void IMAGE_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -433,11 +497,15 @@ Map { #include #include +#include namespace facebook::react { using InsetsPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void INSETS_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -459,11 +527,15 @@ Map { #include #include +#include namespace facebook::react { using Int32EnumPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void INT32_ENUM_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -485,11 +557,15 @@ Map { #include #include +#include namespace facebook::react { using IntegerPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void INTEGER_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -511,11 +587,15 @@ Map { #include #include +#include namespace facebook::react { +void INTERFACE_ONLY_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -537,11 +617,15 @@ Map { #include #include +#include namespace facebook::react { using MixedPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void MIXED_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -563,11 +647,15 @@ Map { #include #include +#include namespace facebook::react { using ImageColorPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void MULTI_NATIVE_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -589,11 +677,15 @@ Map { #include #include +#include namespace facebook::react { using NoPropsNoEventsComponentComponentDescriptor = ConcreteComponentDescriptor; +void NO_PROPS_NO_EVENTS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -615,11 +707,15 @@ Map { #include #include +#include namespace facebook::react { using ObjectPropsComponentDescriptor = ConcreteComponentDescriptor; +void OBJECT_PROPS_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -641,11 +737,15 @@ Map { #include #include +#include namespace facebook::react { using PointPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void POINT_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -667,11 +767,15 @@ Map { #include #include +#include namespace facebook::react { using StringEnumPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void STRING_ENUM_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -693,11 +797,15 @@ Map { #include #include +#include namespace facebook::react { using StringPropComponentComponentDescriptor = ConcreteComponentDescriptor; +void STRING_PROP_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -719,12 +827,16 @@ Map { #include #include +#include namespace facebook::react { using MultiFile1NativeComponentComponentDescriptor = ConcreteComponentDescriptor; using MultiFile2NativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void TWO_COMPONENTS_DIFFERENT_FILES_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } @@ -746,12 +858,16 @@ Map { #include #include +#include namespace facebook::react { using MultiComponent1NativeComponentComponentDescriptor = ConcreteComponentDescriptor; using MultiComponent2NativeComponentComponentDescriptor = ConcreteComponentDescriptor; +void TWO_COMPONENTS_SAME_FILE_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + } // namespace facebook::react ", } diff --git a/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake b/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake index 3f2bd1237c5340..1ad0af8843dbc1 100644 --- a/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake +++ b/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake @@ -141,6 +141,8 @@ if(EXISTS ${PROJECT_BUILD_DIR}/generated/source/codegen/jni/CMakeLists.txt) target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -DREACT_NATIVE_APP_CODEGEN_HEADER="${APP_CODEGEN_HEADER}.h" + -DREACT_NATIVE_APP_COMPONENT_DESCRIPTORS_HEADER="react/renderer/components/${APP_CODEGEN_HEADER}/ComponentDescriptors.h" + -DREACT_NATIVE_APP_COMPONENT_REGISTRATION=${APP_CODEGEN_HEADER}_registerComponentDescriptorsFromCodegen -DREACT_NATIVE_APP_MODULE_PROVIDER=${APP_CODEGEN_HEADER}_ModuleProvider ) endif() diff --git a/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp b/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp index 4452ca8aea6cb1..d206b123ad44bb 100644 --- a/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp @@ -36,6 +36,9 @@ #ifdef REACT_NATIVE_APP_CODEGEN_HEADER #include REACT_NATIVE_APP_CODEGEN_HEADER #endif +#ifdef REACT_NATIVE_APP_COMPONENT_DESCRIPTORS_HEADER +#include REACT_NATIVE_APP_COMPONENT_DESCRIPTORS_HEADER +#endif namespace facebook::react { @@ -47,7 +50,12 @@ void registerComponents( // providerRegistry->add(concreteComponentDescriptorProvider< // MyComponentDescriptor>()); - // By default we just use the components autolinked by RN CLI + // We link app local components if available +#ifdef REACT_NATIVE_APP_COMPONENT_REGISTRATION + REACT_NATIVE_APP_COMPONENT_REGISTRATION(registry); +#endif + + // And we fallback to the components autolinked by RN CLI rncli_registerProviders(registry); } diff --git a/packages/rn-tester/android/app/src/main/jni/OnLoad.cpp b/packages/rn-tester/android/app/src/main/jni/OnLoad.cpp index 99f8b74255fe15..7ba52751e28dd3 100644 --- a/packages/rn-tester/android/app/src/main/jni/OnLoad.cpp +++ b/packages/rn-tester/android/app/src/main/jni/OnLoad.cpp @@ -11,21 +11,22 @@ #include #include #include -#include #ifdef REACT_NATIVE_APP_CODEGEN_HEADER #include REACT_NATIVE_APP_CODEGEN_HEADER #endif +#ifdef REACT_NATIVE_APP_COMPONENT_DESCRIPTORS_HEADER +#include REACT_NATIVE_APP_COMPONENT_DESCRIPTORS_HEADER +#endif namespace facebook { namespace react { -extern const char RNTMyNativeViewName[] = "RNTMyLegacyNativeView"; - void registerComponents( std::shared_ptr registry) { - registry->add(concreteComponentDescriptorProvider< - RNTMyNativeViewComponentDescriptor>()); +#ifdef REACT_NATIVE_APP_COMPONENT_REGISTRATION + REACT_NATIVE_APP_COMPONENT_REGISTRATION(registry); +#endif } std::shared_ptr cxxModuleProvider(