Skip to content

Commit

Permalink
Delete deprecated JSIModule methods (#42115)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #42115

React Native Android had a concept called JSIModules, which iOS doesn't have. The JSIModule concept was introduced in the early stages of the Fabric project to represent modules that interact with JS through JSI and they are not NativeModules.

In the new architecture this concept is not really necessary and these interfaces were only used to initialize and destroy the Fabric renderer and TurboModule Manager in react native core. Bridgeless mode doesn’t use JSIModule anymore. Also, it has an explicit list of supported JSI module types, so is not open for extension.
In order to simplify RN concepts and reduce confusion with TurboModules, which also "use JSI", deleting everything related to JSIModule. This was already deprecated in 0.74.0.

Please use ReactInstanceEventListener to subscribe for react instance events instead of getJSIModule() and we recommend using TurboModules instead of JSIModules.

Changelog:
[General][Breaking] Delete JSIModule

Reviewed By: javache, cortinico

Differential Revision: D49597702

fbshipit-source-id: bc2bc190aafaf559336b341b50ffabf413474105
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Apr 19, 2024
1 parent ac3261f commit 73b4d67
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 270 deletions.
34 changes: 0 additions & 34 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,11 @@ public final class com/facebook/react/bridge/CallbackImpl : com/facebook/react/b

public abstract interface class com/facebook/react/bridge/CatalystInstance : com/facebook/react/bridge/JSBundleLoaderDelegate, com/facebook/react/bridge/JSInstance, com/facebook/react/bridge/MemoryPressureListener {
public abstract fun addBridgeIdleDebugListener (Lcom/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener;)V
public abstract fun addJSIModules (Ljava/util/List;)V
public abstract fun callFunction (Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/NativeArray;)V
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/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/turbomodule/core/interfaces/NativeMethodCallInvokerHolder;
Expand All @@ -586,21 +584,18 @@ public abstract interface class com/facebook/react/bridge/CatalystInstance : com
public abstract fun removeBridgeIdleDebugListener (Lcom/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener;)V
public abstract fun runJSBundle ()V
public abstract fun setFabricUIManager (Lcom/facebook/react/bridge/UIManager;)V
public abstract fun setTurboModuleManager (Lcom/facebook/react/bridge/JSIModule;)V
public abstract fun setTurboModuleRegistry (Lcom/facebook/react/internal/turbomodule/core/interfaces/TurboModuleRegistry;)V
}

public class com/facebook/react/bridge/CatalystInstanceImpl : com/facebook/react/bridge/CatalystInstance {
public fun addBridgeIdleDebugListener (Lcom/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener;)V
public fun addJSIModules (Ljava/util/List;)V
public fun callFunction (Lcom/facebook/react/bridge/CatalystInstanceImpl$PendingJSCall;)V
public fun callFunction (Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/NativeArray;)V
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/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/turbomodule/core/NativeMethodCallInvokerHolderImpl;
Expand All @@ -626,7 +621,6 @@ public class com/facebook/react/bridge/CatalystInstanceImpl : com/facebook/react
public fun setFabricUIManager (Lcom/facebook/react/bridge/UIManager;)V
public fun setGlobalVariable (Ljava/lang/String;Ljava/lang/String;)V
public fun setSourceURLs (Ljava/lang/String;Ljava/lang/String;)V
public fun setTurboModuleManager (Lcom/facebook/react/bridge/JSIModule;)V
public fun setTurboModuleRegistry (Lcom/facebook/react/internal/turbomodule/core/interfaces/TurboModuleRegistry;)V
}

Expand Down Expand Up @@ -796,31 +790,6 @@ public abstract interface class com/facebook/react/bridge/JSExceptionHandler {
public abstract fun handleException (Ljava/lang/Exception;)V
}

public abstract interface class com/facebook/react/bridge/JSIModule {
public abstract fun initialize ()V
public abstract fun invalidate ()V
}

public abstract interface class com/facebook/react/bridge/JSIModulePackage {
public abstract fun getJSIModules (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/react/bridge/JavaScriptContextHolder;)Ljava/util/List;
}

public abstract interface class com/facebook/react/bridge/JSIModuleProvider {
public abstract fun get ()Lcom/facebook/react/bridge/JSIModule;
}

public abstract interface class com/facebook/react/bridge/JSIModuleSpec {
public abstract fun getJSIModuleProvider ()Lcom/facebook/react/bridge/JSIModuleProvider;
public abstract fun getJSIModuleType ()Lcom/facebook/react/bridge/JSIModuleType;
}

public final class com/facebook/react/bridge/JSIModuleType : java/lang/Enum {
public static final field TurboModuleManager Lcom/facebook/react/bridge/JSIModuleType;
public static final field UIManager Lcom/facebook/react/bridge/JSIModuleType;
public static fun valueOf (Ljava/lang/String;)Lcom/facebook/react/bridge/JSIModuleType;
public static fun values ()[Lcom/facebook/react/bridge/JSIModuleType;
}

public class com/facebook/react/bridge/JSONArguments {
public fun <init> ()V
public static fun fromJSONArray (Lorg/json/JSONArray;)Lcom/facebook/react/bridge/ReadableArray;
Expand Down Expand Up @@ -3706,13 +3675,11 @@ public abstract class com/facebook/react/runtime/BindingsInstaller {
public final class com/facebook/react/runtime/BridgelessCatalystInstance : com/facebook/react/bridge/CatalystInstance {
public fun <init> (Lcom/facebook/react/runtime/ReactHostImpl;)V
public fun addBridgeIdleDebugListener (Lcom/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener;)V
public fun addJSIModules (Ljava/util/List;)V
public fun callFunction (Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/NativeArray;)V
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/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/turbomodule/core/interfaces/NativeMethodCallInvokerHolder;
Expand All @@ -3736,7 +3703,6 @@ public final class com/facebook/react/runtime/BridgelessCatalystInstance : com/f
public fun runJSBundle ()V
public fun setFabricUIManager (Lcom/facebook/react/bridge/UIManager;)V
public fun setSourceURLs (Ljava/lang/String;Ljava/lang/String;)V
public fun setTurboModuleManager (Lcom/facebook/react/bridge/JSIModule;)V
public fun setTurboModuleRegistry (Lcom/facebook/react/internal/turbomodule/core/interfaces/TurboModuleRegistry;)V
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHolder;
import java.util.Collection;
import java.util.List;

/**
* A higher level API on top of the asynchronous JSC bridge. This provides an environment allowing
Expand Down Expand Up @@ -72,13 +71,6 @@ public interface CatalystInstance
@Nullable
NativeModule getNativeModule(String moduleName);

@Deprecated(
since =
"getJSIModule(JSIModuleType moduleType) is deprecated and will be deleted in the future."
+ " Please use ReactInstanceEventListener to subscribe for react instance events"
+ " instead.")
JSIModule getJSIModule(JSIModuleType moduleType);

Collection<NativeModule> getNativeModules();

/**
Expand Down Expand Up @@ -122,9 +114,6 @@ public interface CatalystInstance

RuntimeScheduler getRuntimeScheduler();

@Deprecated
<T extends JSIModule> void addJSIModules(List<JSIModuleSpec<T>> jsiModules);

/**
* Returns a hybrid object that contains a pointer to a JS CallInvoker, which is used to schedule
* work on the JS Thread. Required for TurboModuleManager initialization.
Expand All @@ -137,13 +126,6 @@ public interface CatalystInstance
*/
NativeMethodCallInvokerHolder getNativeMethodCallInvokerHolder();

@Deprecated(
since =
"setTurboModuleManager(JSIModule getter) is deprecated and will be deleted in the future."
+ " Please use setTurboModuleRegistry(TurboModuleRegistry"
+ " turboModuleRegistry)instead.")
void setTurboModuleManager(JSIModule getter);

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;

Expand Down Expand Up @@ -92,7 +91,6 @@ public String toString() {
private final Object mJSCallsPendingInitLock = new Object();

private final NativeModuleRegistry mNativeModuleRegistry;
private final JSIModuleRegistry mJSIModuleRegistry = new JSIModuleRegistry();
private final JSExceptionHandler mJSExceptionHandler;
private final MessageQueueThread mNativeModulesQueueThread;
private boolean mInitialized = false;
Expand Down Expand Up @@ -357,7 +355,6 @@ public void destroy() {
mNativeModulesQueueThread.runOnQueue(
() -> {
mNativeModuleRegistry.notifyJSInstanceDestroy();
mJSIModuleRegistry.notifyJSInstanceDestroy();
if (mFabricUIManager != null) {
mFabricUIManager.invalidate();
}
Expand Down Expand Up @@ -543,17 +540,6 @@ public JavaScriptContextHolder getJavaScriptContextHolder() {

public native RuntimeScheduler getRuntimeScheduler();

@Override
@Deprecated
public <T extends JSIModule> void addJSIModules(List<JSIModuleSpec<T>> jsiModules) {
mJSIModuleRegistry.registerModules(jsiModules);
}

@Override
public JSIModule getJSIModule(JSIModuleType moduleType) {
return mJSIModuleRegistry.getModule(moduleType);
}

private native long getJavaScriptContext();

private void incrementPendingJSCalls() {
Expand All @@ -571,10 +557,6 @@ private void incrementPendingJSCalls() {
}
}

public void setTurboModuleManager(JSIModule module) {
mTurboModuleRegistry = (TurboModuleRegistry) module;
}

@Override
public void setTurboModuleRegistry(TurboModuleRegistry turboModuleRegistry) {
mTurboModuleRegistry = turboModuleRegistry;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,7 @@ public boolean isBridgeless() {
* @return The UIManager when CatalystInstance is active.
*/
public @Nullable UIManager getFabricUIManager() {
UIManager uiManager = mCatalystInstance.getFabricUIManager();
return uiManager != null
? uiManager
: (UIManager) mCatalystInstance.getJSIModule(JSIModuleType.UIManager);
return mCatalystInstance.getFabricUIManager();
}

/**
Expand Down
Loading

0 comments on commit 73b4d67

Please sign in to comment.