From fd0ca4dd6209d79ac8c93dbffac2e3dca1caeadc Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Fri, 19 Jan 2024 06:18:28 -0800 Subject: [PATCH] Undo move of CallInvokerHolder to `.internal` (#42362) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42362 This undos a change of CallInvokerHolder bringing it back in the public package: https://github.com/facebook/react-native/commit/b7191cde4e36 The problem is that if a developer wants to use the C++ CallInvokerHolder to schedule work on the JS thread from C++, they're forced to import the `.internal` Java/Kotlin class. Plus this is going to be a massive breaking change for the ecosystem: https://github.com/search?type=code&q=%2Fimport.*CallInvokerHolderImpl%2F So unless we come with a clear deprecation/replacement path, I'm undoing this change for now. Changelog: [Internal] [Changed] - Undo move of CallInvokerHolder to `.internal` Reviewed By: cipolleschi Differential Revision: D52873256 fbshipit-source-id: 900c3170ed2100ec706b03112bc23a0ba0171bcc --- .../ReactAndroid/api/ReactAndroid.api | 24 ++++++++++++++----- .../ReactAndroid/proguard-rules.pro | 1 + .../react/bridge/CatalystInstance.java | 4 ++-- .../react/bridge/CatalystInstanceImpl.java | 4 ++-- .../turbomodule/core/TurboModuleManager.java | 6 +++-- .../facebook/react/runtime/ReactInstance.java | 4 ++-- .../core/CallInvokerHolderImpl.java | 5 ++-- .../NativeMethodCallInvokerHolderImpl.java | 5 ++-- .../core/interfaces/CallInvokerHolder.kt | 2 +- .../NativeMethodCallInvokerHolder.kt | 2 +- .../ReactCommon/CallInvokerHolder.h | 2 +- .../NativeMethodCallInvokerHolder.h | 2 +- 12 files changed, 39 insertions(+), 22 deletions(-) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/{internal => }/turbomodule/core/CallInvokerHolderImpl.java (81%) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/{internal => }/turbomodule/core/NativeMethodCallInvokerHolderImpl.java (81%) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/{internal => }/turbomodule/core/interfaces/CallInvokerHolder.kt (90%) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/{internal => }/turbomodule/core/interfaces/NativeMethodCallInvokerHolder.kt (84%) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 809e00fc5956de..f709de483e5370 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -536,11 +536,11 @@ public abstract interface class com/facebook/react/bridge/CatalystInstance : com public abstract fun destroy ()V public abstract fun extendNativeModules (Lcom/facebook/react/bridge/NativeModuleRegistry;)V public abstract fun getFabricUIManager ()Lcom/facebook/react/bridge/UIManager; - public abstract fun getJSCallInvokerHolder ()Lcom/facebook/react/internal/turbomodule/core/interfaces/CallInvokerHolder; + public abstract fun getJSCallInvokerHolder ()Lcom/facebook/react/turbomodule/core/interfaces/CallInvokerHolder; public abstract fun getJSIModule (Lcom/facebook/react/bridge/JSIModuleType;)Lcom/facebook/react/bridge/JSIModule; public abstract fun getJSModule (Ljava/lang/Class;)Lcom/facebook/react/bridge/JavaScriptModule; public abstract fun getJavaScriptContextHolder ()Lcom/facebook/react/bridge/JavaScriptContextHolder; - public abstract fun getNativeMethodCallInvokerHolder ()Lcom/facebook/react/internal/turbomodule/core/interfaces/NativeMethodCallInvokerHolder; + public abstract fun getNativeMethodCallInvokerHolder ()Lcom/facebook/react/turbomodule/core/interfaces/NativeMethodCallInvokerHolder; public abstract fun getNativeModule (Ljava/lang/Class;)Lcom/facebook/react/bridge/NativeModule; public abstract fun getNativeModule (Ljava/lang/String;)Lcom/facebook/react/bridge/NativeModule; public abstract fun getNativeModules ()Ljava/util/Collection; @@ -568,13 +568,13 @@ public class com/facebook/react/bridge/CatalystInstanceImpl : com/facebook/react public fun destroy ()V public fun extendNativeModules (Lcom/facebook/react/bridge/NativeModuleRegistry;)V public fun getFabricUIManager ()Lcom/facebook/react/bridge/UIManager; - public fun getJSCallInvokerHolder ()Lcom/facebook/react/internal/turbomodule/core/CallInvokerHolderImpl; - public synthetic fun getJSCallInvokerHolder ()Lcom/facebook/react/internal/turbomodule/core/interfaces/CallInvokerHolder; + public fun getJSCallInvokerHolder ()Lcom/facebook/react/turbomodule/core/CallInvokerHolderImpl; + public synthetic fun getJSCallInvokerHolder ()Lcom/facebook/react/turbomodule/core/interfaces/CallInvokerHolder; public fun getJSIModule (Lcom/facebook/react/bridge/JSIModuleType;)Lcom/facebook/react/bridge/JSIModule; public fun getJSModule (Ljava/lang/Class;)Lcom/facebook/react/bridge/JavaScriptModule; public fun getJavaScriptContextHolder ()Lcom/facebook/react/bridge/JavaScriptContextHolder; - public fun getNativeMethodCallInvokerHolder ()Lcom/facebook/react/internal/turbomodule/core/NativeMethodCallInvokerHolderImpl; - public synthetic fun getNativeMethodCallInvokerHolder ()Lcom/facebook/react/internal/turbomodule/core/interfaces/NativeMethodCallInvokerHolder; + public fun getNativeMethodCallInvokerHolder ()Lcom/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl; + public synthetic fun getNativeMethodCallInvokerHolder ()Lcom/facebook/react/turbomodule/core/interfaces/NativeMethodCallInvokerHolder; public fun getNativeModule (Ljava/lang/Class;)Lcom/facebook/react/bridge/NativeModule; public fun getNativeModule (Ljava/lang/String;)Lcom/facebook/react/bridge/NativeModule; public fun getNativeModules ()Ljava/util/Collection; @@ -3820,6 +3820,18 @@ public abstract interface class com/facebook/react/touch/ReactInterceptingViewGr public abstract fun setOnInterceptTouchEventListener (Lcom/facebook/react/touch/OnInterceptTouchEventListener;)V } +public class com/facebook/react/turbomodule/core/CallInvokerHolderImpl : com/facebook/react/turbomodule/core/interfaces/CallInvokerHolder { +} + +public class com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl : com/facebook/react/turbomodule/core/interfaces/NativeMethodCallInvokerHolder { +} + +public abstract interface class com/facebook/react/turbomodule/core/interfaces/CallInvokerHolder { +} + +public abstract interface class com/facebook/react/turbomodule/core/interfaces/NativeMethodCallInvokerHolder { +} + public abstract interface class com/facebook/react/turbomodule/core/interfaces/TurboModule : com/facebook/react/internal/turbomodule/core/interfaces/TurboModule { } diff --git a/packages/react-native/ReactAndroid/proguard-rules.pro b/packages/react-native/ReactAndroid/proguard-rules.pro index 64ab4631c65cb8..70c7e22bd8f10b 100644 --- a/packages/react-native/ReactAndroid/proguard-rules.pro +++ b/packages/react-native/ReactAndroid/proguard-rules.pro @@ -54,6 +54,7 @@ -dontwarn com.facebook.react.** -keep,includedescriptorclasses class com.facebook.react.bridge.** { *; } +-keep,includedescriptorclasses class com.facebook.react.turbomodule.core.** { *; } -keep,includedescriptorclasses class com.facebook.react.internal.turbomodule.core.** { *; } # hermes diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java index 3849fd50db200e..0ee0dd6df275ee 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java @@ -12,9 +12,9 @@ import com.facebook.react.bridge.queue.ReactQueueConfiguration; import com.facebook.react.common.annotations.DeprecatedInNewArchitecture; import com.facebook.react.common.annotations.VisibleForTesting; -import com.facebook.react.internal.turbomodule.core.interfaces.CallInvokerHolder; -import com.facebook.react.internal.turbomodule.core.interfaces.NativeMethodCallInvokerHolder; import com.facebook.react.internal.turbomodule.core.interfaces.TurboModuleRegistry; +import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder; +import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHolder; import java.util.Collection; import java.util.List; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java index 621372533b22e6..3658f68cac44f7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java @@ -26,10 +26,10 @@ import com.facebook.react.common.ReactConstants; import com.facebook.react.common.annotations.VisibleForTesting; import com.facebook.react.config.ReactFeatureFlags; -import com.facebook.react.internal.turbomodule.core.CallInvokerHolderImpl; -import com.facebook.react.internal.turbomodule.core.NativeMethodCallInvokerHolderImpl; import com.facebook.react.internal.turbomodule.core.interfaces.TurboModuleRegistry; import com.facebook.react.module.annotations.ReactModule; +import com.facebook.react.turbomodule.core.CallInvokerHolderImpl; +import com.facebook.react.turbomodule.core.NativeMethodCallInvokerHolderImpl; import com.facebook.systrace.Systrace; import com.facebook.systrace.TraceListener; import java.lang.ref.WeakReference; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.java index 1d7a4397bcedf2..e66dbc3492830b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.java @@ -19,10 +19,12 @@ import com.facebook.react.bridge.ReactNoCrashSoftException; import com.facebook.react.bridge.ReactSoftExceptionLogger; import com.facebook.react.bridge.RuntimeExecutor; -import com.facebook.react.internal.turbomodule.core.interfaces.CallInvokerHolder; -import com.facebook.react.internal.turbomodule.core.interfaces.NativeMethodCallInvokerHolder; import com.facebook.react.internal.turbomodule.core.interfaces.TurboModule; import com.facebook.react.internal.turbomodule.core.interfaces.TurboModuleRegistry; +import com.facebook.react.turbomodule.core.CallInvokerHolderImpl; +import com.facebook.react.turbomodule.core.NativeMethodCallInvokerHolderImpl; +import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder; +import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHolder; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java index be0a7f39eb65de..da24155a6758f3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java @@ -44,13 +44,13 @@ import com.facebook.react.fabric.events.EventBeatManager; import com.facebook.react.interfaces.exceptionmanager.ReactJsExceptionHandler; import com.facebook.react.internal.AndroidChoreographerProvider; -import com.facebook.react.internal.turbomodule.core.CallInvokerHolderImpl; -import com.facebook.react.internal.turbomodule.core.NativeMethodCallInvokerHolderImpl; import com.facebook.react.internal.turbomodule.core.TurboModuleManager; import com.facebook.react.internal.turbomodule.core.TurboModuleManagerDelegate; import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.modules.core.JavaTimerManager; import com.facebook.react.modules.core.ReactChoreographer; +import com.facebook.react.turbomodule.core.CallInvokerHolderImpl; +import com.facebook.react.turbomodule.core.NativeMethodCallInvokerHolderImpl; import com.facebook.react.uimanager.ComponentNameResolver; import com.facebook.react.uimanager.ComponentNameResolverManager; import com.facebook.react.uimanager.DisplayMetricsHolder; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/CallInvokerHolderImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/CallInvokerHolderImpl.java similarity index 81% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/CallInvokerHolderImpl.java rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/CallInvokerHolderImpl.java index b64055a04b13e9..e652516e37b06c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/CallInvokerHolderImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/CallInvokerHolderImpl.java @@ -5,11 +5,12 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.internal.turbomodule.core; +package com.facebook.react.turbomodule.core; import com.facebook.jni.HybridData; import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.internal.turbomodule.core.interfaces.CallInvokerHolder; +import com.facebook.react.internal.turbomodule.core.NativeModuleSoLoader; +import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder; /** * JSCallInvoker is created at a different time/place (i.e: in CatalystInstance) than diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/NativeMethodCallInvokerHolderImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl.java similarity index 81% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/NativeMethodCallInvokerHolderImpl.java rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl.java index 4fd3ee97eb7416..8892fa4ba2235f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/NativeMethodCallInvokerHolderImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl.java @@ -5,11 +5,12 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.internal.turbomodule.core; +package com.facebook.react.turbomodule.core; import com.facebook.jni.HybridData; import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.internal.turbomodule.core.interfaces.NativeMethodCallInvokerHolder; +import com.facebook.react.internal.turbomodule.core.NativeModuleSoLoader; +import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHolder; /** * NativeMethodCallInvokerHolder is created at a different time/place (i.e: in CatalystInstance) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/interfaces/CallInvokerHolder.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/CallInvokerHolder.kt similarity index 90% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/interfaces/CallInvokerHolder.kt rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/CallInvokerHolder.kt index 3befd1b47a76e9..12ac4792a01252 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/interfaces/CallInvokerHolder.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/CallInvokerHolder.kt @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.internal.turbomodule.core.interfaces +package com.facebook.react.turbomodule.core.interfaces /** * JS CallInvoker is created by CatalystInstance.cpp, but used by TurboModuleManager.cpp. Both C++ * classes are instantiated at different times/places. Therefore, to pass the JS CallInvoker diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/interfaces/NativeMethodCallInvokerHolder.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/NativeMethodCallInvokerHolder.kt similarity index 84% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/interfaces/NativeMethodCallInvokerHolder.kt rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/NativeMethodCallInvokerHolder.kt index 3f89a39d9c2d83..7d1a3cc42838df 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/interfaces/NativeMethodCallInvokerHolder.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/NativeMethodCallInvokerHolder.kt @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.internal.turbomodule.core.interfaces +package com.facebook.react.turbomodule.core.interfaces /** * This interface represents the opaque Java object that contains a pointer to and instance of * NativeMethodCallInvoker. diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CallInvokerHolder.h b/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CallInvokerHolder.h index 6ea72c9cf90aad..3e4b4f8f2a2767 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CallInvokerHolder.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CallInvokerHolder.h @@ -16,7 +16,7 @@ namespace facebook::react { class CallInvokerHolder : public jni::HybridClass { public: static auto constexpr kJavaDescriptor = - "Lcom/facebook/react/internal/turbomodule/core/CallInvokerHolderImpl;"; + "Lcom/facebook/react/turbomodule/core/CallInvokerHolderImpl;"; static void registerNatives(); std::shared_ptr getCallInvoker(); diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/NativeMethodCallInvokerHolder.h b/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/NativeMethodCallInvokerHolder.h index 9e464f0755fe56..ef8fa3b5a42395 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/NativeMethodCallInvokerHolder.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/NativeMethodCallInvokerHolder.h @@ -17,7 +17,7 @@ class NativeMethodCallInvokerHolder : public jni::HybridClass { public: static auto constexpr kJavaDescriptor = - "Lcom/facebook/react/internal/turbomodule/core/NativeMethodCallInvokerHolderImpl;"; + "Lcom/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl;"; static void registerNatives(); std::shared_ptr getNativeMethodCallInvoker();