Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/react-native/React/Base/RCTBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ BOOL RCTTurboModuleInteropEnabled(void);
void RCTEnableTurboModuleInterop(BOOL enabled);
#endif // RCT_REMOVE_LEGACY_MODULE_INTEROP

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP
// Turn on the fabric interop layer
BOOL RCTFabricInteropLayerEnabled(void);
void RCTEnableFabricInteropLayer(BOOL enabled);
#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP

BOOL RCTUIManagerDispatchAccessibilityManagerInitOntoMain(void);
void RCTUIManagerSetDispatchAccessibilityManagerInitOntoMain(BOOL enabled);
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/React/Base/RCTBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ void RCTEnableTurboModuleInterop(BOOL enabled)
}
#endif // RCT_REMOVE_LEGACY_MODULE_INTEROP

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP
static BOOL fabricInteropLayerEnabled = YES;
BOOL RCTFabricInteropLayerEnabled()
{
Expand All @@ -221,6 +222,7 @@ void RCTEnableFabricInteropLayer(BOOL enabled)
{
fabricInteropLayerEnabled = enabled;
}
#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP

static RCTBridgeProxyLoggingLevel bridgeProxyLoggingLevel = kRCTBridgeProxyLoggingLevelNone;
RCTBridgeProxyLoggingLevel RCTTurboModuleInteropBridgeProxyLogLevel(void)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#import <UIKit/UIKit.h>

#import <React/RCTViewComponentView.h>
Expand All @@ -30,3 +32,5 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#import "RCTLegacyViewManagerInteropComponentView.h"

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#import <React/RCTAssert.h>
#import <React/RCTBridge+Private.h>
#import <React/RCTConstants.h>
Expand Down Expand Up @@ -299,3 +301,5 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
}

@end

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#import <Foundation/Foundation.h>
#import <react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h>

Expand All @@ -25,3 +27,5 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/

#import "RCTLegacyViewManagerInteropCoordinatorAdapter.h"

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#import <React/UIView+React.h>
#import <react/utils/FollyConvert.h>

Expand Down Expand Up @@ -146,3 +149,5 @@ - (BOOL)_propIsSameObject:(id)first second:(id)second
}

@end

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#import <React/RCTComponentViewClassDescriptor.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <React/RCTImageComponentView.h>
#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP
#import <React/RCTLegacyViewManagerInteropComponentView.h>
#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
#import <React/RCTMountingTransactionObserving.h>
#import <React/RCTParagraphComponentView.h>
#import <React/RCTRootComponentView.h>
Expand Down Expand Up @@ -125,11 +127,6 @@ - (void)_registerComponentIfPossible:(const std::string &)name
return;
}

// Paper name: we prepare this variables to warn the user
// when the component is registered in both Fabric and in the
// interop layer, so they can remove that
NSString *componentNameString = RCTNSStringFromString(name);

// Fallback 1: Call provider function for component view class.
Class<RCTComponentViewProtocol> klass = RCTComponentViewClassWithName(name.c_str());
if (klass != nullptr) {
Expand All @@ -149,6 +146,12 @@ - (void)_registerComponentIfPossible:(const std::string &)name
}
}

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP
// Paper name: we prepare this variables to warn the user
// when the component is registered in both Fabric and in the
// interop layer, so they can remove that
NSString *componentNameString = RCTNSStringFromString(name);

// Fallback 3: Try to use Paper Interop.
// TODO(T174674274): Implement lazy loading of legacy view managers in the new architecture.
if (RCTFabricInteropLayerEnabled() && [RCTLegacyViewManagerInteropComponentView isSupported:componentNameString]) {
Expand All @@ -166,6 +169,7 @@ - (void)_registerComponentIfPossible:(const std::string &)name
_registrationStatusMap.insert({provider.name, true});
return;
}
#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP

// Fallback 4: use <UnimplementedView> if component doesn't exist.
auto flavor = std::make_shared<const std::string>(name);
Expand Down
1 change: 1 addition & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,7 @@ public final class com/facebook/react/common/build/ReactBuildConfig {
public static final field IS_INTERNAL_BUILD Z
public static final field UNSTABLE_ENABLE_FUSEBOX_RELEASE Z
public static final field UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE Z
public static final field UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP Z
}

public abstract interface class com/facebook/react/common/mapbuffer/MapBuffer : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker {
Expand Down
1 change: 1 addition & 0 deletions packages/react-native/ReactAndroid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ android {
buildConfigField("boolean", "UNSTABLE_ENABLE_FUSEBOX_RELEASE", "false")
buildConfigField("boolean", "ENABLE_PERFETTO", "false")
buildConfigField("boolean", "UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE", "false")
buildConfigField("boolean", "UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP", "false")

resValue("integer", "react_native_dev_server_port", reactNativeDevServerPort())
resValue("string", "react_native_dev_server_ip", "localhost")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.facebook.react.bridge.queue.MessageQueueThread;
import com.facebook.react.bridge.queue.ReactQueueConfiguration;
import com.facebook.react.common.LifecycleState;
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.interfaces.ExtraWindowEventListener;
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
import java.lang.ref.WeakReference;
Expand Down Expand Up @@ -579,6 +580,9 @@ public boolean startActivityForResult(Intent intent, int code, Bundle bundle) {
*/
public <T extends JavaScriptModule> void internal_registerInteropModule(
Class<T> interopModuleInterface, Object interopModule) {
if (ReactBuildConfig.UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP) {
return;
}
if (mInteropModuleRegistry != null) {
mInteropModuleRegistry.registerInteropModule(interopModuleInterface, interopModule);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ public object ReactBuildConfig {
@JvmField
public val UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE: Boolean =
BuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE

@JvmField
public val UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP: Boolean =
BuildConfig.UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP
}
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ public void initialize() {

ReactMarker.addFabricListener(mDevToolsReactPerfLogger);
}
if (ReactNativeNewArchitectureFeatureFlags.useFabricInterop()) {
if (!ReactBuildConfig.UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP
&& ReactNativeNewArchitectureFeatureFlags.useFabricInterop()) {
InteropEventEmitter interopEventEmitter = new InteropEventEmitter(mReactApplicationContext);
mReactApplicationContext.internal_registerInteropModule(
RCTEventEmitter.class, interopEventEmitter);
Expand Down Expand Up @@ -514,7 +515,8 @@ public void sweepActiveTouchForTag(int surfaceId, int reactTag) {
* [addUiBlock] and [prependUiBlock] on UIManagerModule.
*/
public void addUIBlock(UIBlock block) {
if (ReactNativeNewArchitectureFeatureFlags.useFabricInterop()) {
if (!ReactBuildConfig.UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP
&& ReactNativeNewArchitectureFeatureFlags.useFabricInterop()) {
InteropUIBlockListener listener = getInteropUIBlockListener();
listener.addUIBlock(block);
}
Expand All @@ -525,7 +527,8 @@ public void addUIBlock(UIBlock block) {
* [addUiBlock] and [prependUiBlock] on UIManagerModule.
*/
public void prependUIBlock(UIBlock block) {
if (ReactNativeNewArchitectureFeatureFlags.useFabricInterop()) {
if (!ReactBuildConfig.UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP
&& ReactNativeNewArchitectureFeatureFlags.useFabricInterop()) {
InteropUIBlockListener listener = getInteropUIBlockListener();
listener.prependUIBlock(block);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ internal class BridgelessReactContext(context: Context, private val reactHost: R
get() = reactHost.defaultBackButtonHandler

init {
if (ReactNativeNewArchitectureFeatureFlags.useFabricInterop()) {
if (
!ReactBuildConfig.UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP &&
ReactNativeNewArchitectureFeatureFlags.useFabricInterop()
) {
initializeInteropModules()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ internal object UIManagerModuleConstantsHelper {
var viewManagerBubblingEvents: MutableMap<String, Any>? =
viewManager.exportedCustomBubblingEventTypeConstants
if (viewManagerBubblingEvents != null) {
if (useFabricInterop()) {
if (!ReactBuildConfig.UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP && useFabricInterop()) {
// For Fabric, events needs to be fired with a "top" prefix.
// For the sake of Fabric Interop, here we normalize events adding "top" in their
// name if the user hasn't provided it.
Expand All @@ -160,7 +160,7 @@ internal object UIManagerModuleConstantsHelper {
viewManager.exportedCustomDirectEventTypeConstants
validateDirectEventNames(viewManager.getName(), viewManagerDirectEvents)
if (viewManagerDirectEvents != null) {
if (useFabricInterop()) {
if (!ReactBuildConfig.UNSTABLE_REMOVE_LEGACY_COMPONENT_INTEROP && useFabricInterop()) {
// For Fabric, events needs to be fired with a "top" prefix.
// For the sake of Fabric Interop, here we normalize events adding "top" in their
// name if the user hasn't provided it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#include <react/debug/react_native_assert.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP
#include <react/renderer/components/legacyviewmanagerinterop/UnstableLegacyViewManagerAutomaticComponentDescriptor.h>
#include <react/renderer/components/legacyviewmanagerinterop/UnstableLegacyViewManagerAutomaticShadowNode.h>
#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/ShadowNodeFragment.h>
#include <utility>
Expand Down Expand Up @@ -84,6 +86,7 @@ const ComponentDescriptor& ComponentDescriptorRegistry::at(
}

if (it == _registryByName.end()) {
#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP
if (ReactNativeFeatureFlags::useFabricInterop()) {
// When interop is enabled, if the component is not found we rely on
// UnstableLegacyViewManagerAutomaticComponentDescriptor to support legacy
Expand All @@ -94,6 +97,7 @@ const ComponentDescriptor& ComponentDescriptorRegistry::at(
registerComponentDescriptor(componentDescriptor);
return *_registryByName.find(unifiedComponentName)->second;
} else {
#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
// When interop is disabled, if the component is not found we rely on
// fallbackComponentDescriptor (default:
// UnimplementedNativeViewComponentDescriptor).
Expand All @@ -107,7 +111,9 @@ const ComponentDescriptor& ComponentDescriptorRegistry::at(
} else {
return *_fallbackComponentDescriptor.get();
}
#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP
}
#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
}

return *it->second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
* LICENSE file in the root directory of this source tree.
*/

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

namespace facebook::react {

extern const char LegacyViewManagerInteropComponentName[] =
"LegacyViewManagerInterop";

} // namespace facebook::react

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#pragma once

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#include <react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropState.h>
#include <react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
Expand All @@ -22,3 +24,5 @@ using LegacyViewManagerInteropShadowNode = ConcreteViewShadowNode<
LegacyViewManagerInteropState>;

} // namespace facebook::react

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#pragma once

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#import <memory>

namespace facebook::react {
Expand All @@ -20,3 +22,5 @@ class LegacyViewManagerInteropState final {
};

} // namespace facebook::react

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/

#include "LegacyViewManagerInteropViewProps.h"

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#include <react/renderer/core/DynamicPropsUtilities.h>

namespace facebook::react {
Expand All @@ -21,3 +24,5 @@ LegacyViewManagerInteropViewProps::LegacyViewManagerInteropViewProps(
NullValueStrategy::Override)) {}

} // namespace facebook::react

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#include <folly/dynamic.h>
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
Expand All @@ -26,3 +28,5 @@ class LegacyViewManagerInteropViewProps final : public ViewProps {
};

} // namespace facebook::react

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/

#include "UnstableLegacyViewManagerAutomaticComponentDescriptor.h"

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#include <react/renderer/components/legacyviewmanagerinterop/UnstableLegacyViewManagerAutomaticShadowNode.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/core/ReactPrimitives.h>
Expand All @@ -24,3 +27,5 @@ UnstableLegacyViewManagerAutomaticComponentDescriptor::getComponentHandle()
return reinterpret_cast<ComponentHandle>(getComponentName());
}
} // namespace facebook::react

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#pragma once

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

#include <react/renderer/components/legacyviewmanagerinterop/UnstableLegacyViewManagerAutomaticShadowNode.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/core/ReactPrimitives.h>
Expand All @@ -33,3 +35,5 @@ class UnstableLegacyViewManagerAutomaticComponentDescriptor final
std::string legacyComponentName_;
};
} // namespace facebook::react

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
* LICENSE file in the root directory of this source tree.
*/

#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP

namespace facebook::react {

extern const char LegacyViewManagerAndroidInteropComponentName[] =
"LegacyViewManagerInterop";

} // namespace facebook::react

#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP
Loading
Loading