diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 12c04380160a..4783b941158a 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -314,6 +314,7 @@ public final class com/facebook/react/ReactInstanceManagerBuilder { } public abstract class com/facebook/react/ReactNativeHost { + public static final field Companion Lcom/facebook/react/ReactNativeHost$Companion; protected fun (Landroid/app/Application;)V public fun clear ()V protected fun createReactInstanceManager ()Lcom/facebook/react/ReactInstanceManager; @@ -340,6 +341,9 @@ public abstract class com/facebook/react/ReactNativeHost { public fun hasInstance ()Z } +public final class com/facebook/react/ReactNativeHost$Companion { +} + public abstract interface class com/facebook/react/ReactPackage { public fun createNativeModules (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List; public abstract fun createViewManagers (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List; @@ -3461,6 +3465,7 @@ public final class com/facebook/react/uimanager/MeasureSpecAssertions { } public class com/facebook/react/uimanager/NativeViewHierarchyManager { + public static final field Companion Lcom/facebook/react/uimanager/NativeViewHierarchyManager$Companion; public fun (Lcom/facebook/react/uimanager/ViewManagerRegistry;)V public fun (Lcom/facebook/react/uimanager/ViewManagerRegistry;Lcom/facebook/react/uimanager/RootViewManager;)V public fun addRootView (ILandroid/view/View;)V @@ -3490,6 +3495,9 @@ public class com/facebook/react/uimanager/NativeViewHierarchyManager { public fun updateViewExtraData (ILjava/lang/Object;)V } +public final class com/facebook/react/uimanager/NativeViewHierarchyManager$Companion { +} + public final class com/facebook/react/uimanager/NativeViewHierarchyOptimizer { public fun ()V } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.kt index eef741c689d3..d82dbdc41fc7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.kt @@ -252,7 +252,7 @@ public open class ReactDelegate { ((ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost?.devSupportManager != null) || (reactNativeHost?.hasInstance() == true && - reactNativeHost?.useDeveloperSupport == true)) + reactNativeHost?.getUseDeveloperSupport() == true)) ) { event.startTracking() return true @@ -273,7 +273,8 @@ public open class ReactDelegate { } } else { if ( - reactNativeHost?.hasInstance() == true && reactNativeHost?.useDeveloperSupport == true + reactNativeHost?.hasInstance() == true && + reactNativeHost?.getUseDeveloperSupport() == true ) { reactNativeHost?.reactInstanceManager?.showDevOptionsDialog() return true diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java deleted file mode 100644 index 56a609dbb2cf..000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * 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. - */ - -package com.facebook.react; - -import android.app.Application; -import androidx.annotation.Nullable; -import com.facebook.infer.annotation.Assertions; -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.react.bridge.JSExceptionHandler; -import com.facebook.react.bridge.JavaScriptExecutorFactory; -import com.facebook.react.bridge.ReactMarker; -import com.facebook.react.bridge.ReactMarkerConstants; -import com.facebook.react.bridge.UIManagerProvider; -import com.facebook.react.common.LifecycleState; -import com.facebook.react.common.SurfaceDelegate; -import com.facebook.react.common.SurfaceDelegateFactory; -import com.facebook.react.common.annotations.internal.LegacyArchitecture; -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel; -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; -import com.facebook.react.devsupport.DevSupportManagerFactory; -import com.facebook.react.devsupport.interfaces.DevLoadingViewManager; -import com.facebook.react.devsupport.interfaces.PausedInDebuggerOverlayManager; -import com.facebook.react.devsupport.interfaces.RedBoxHandler; -import com.facebook.react.internal.ChoreographerProvider; -import java.util.List; - -/** - * Simple class that holds an instance of {@link ReactInstanceManager}. This can be used in your - * {@link Application class} (see {@link ReactApplication}), or as a static field. - * - * @deprecated This class will be replaced by com.facebook.react.ReactHost in the New Architecture. - */ -@Deprecated( - since = "This class is part of Legacy Architecture and will be removed in a future release") -@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) -@Nullsafe(Nullsafe.Mode.LOCAL) -public abstract class ReactNativeHost { - - static { - LegacyArchitectureLogger.assertLegacyArchitecture( - "ReactNativeHost", LegacyArchitectureLogLevel.ERROR); - } - - private final Application mApplication; - private @Nullable ReactInstanceManager mReactInstanceManager; - - protected ReactNativeHost(Application application) { - mApplication = application; - } - - /** - * Get the current {@link ReactInstanceManager} instance, or create one. - * - *

NOTE: Care must be taken when storing this reference outside of the ReactNativeHost - * lifecycle. The ReactInstanceManager will be invalidated during {@link #clear()}, and may not be - * used again afterwards. - */ - public synchronized ReactInstanceManager getReactInstanceManager() { - if (mReactInstanceManager == null) { - ReactMarker.logMarker(ReactMarkerConstants.INIT_REACT_RUNTIME_START); - ReactMarker.logMarker(ReactMarkerConstants.GET_REACT_INSTANCE_MANAGER_START); - mReactInstanceManager = createReactInstanceManager(); - ReactMarker.logMarker(ReactMarkerConstants.GET_REACT_INSTANCE_MANAGER_END); - } - return mReactInstanceManager; - } - - /** - * Get whether this holder contains a {@link ReactInstanceManager} instance, or not. I.e. if - * {@link #getReactInstanceManager()} has been called at least once since this object was created - * or {@link #clear()} was called. - */ - public synchronized boolean hasInstance() { - return mReactInstanceManager != null; - } - - /** - * Destroy the current instance and invalidate the internal ReactInstanceManager, reclaiming its - * resources and preventing it from being reused. - */ - public synchronized void clear() { - if (mReactInstanceManager != null) { - mReactInstanceManager.invalidate(); - mReactInstanceManager = null; - } - } - - protected ReactInstanceManager createReactInstanceManager() { - ReactMarker.logMarker(ReactMarkerConstants.BUILD_REACT_INSTANCE_MANAGER_START); - ReactInstanceManagerBuilder builder = getBaseReactInstanceManagerBuilder(); - ReactMarker.logMarker(ReactMarkerConstants.BUILD_REACT_INSTANCE_MANAGER_END); - return builder.build(); - } - - protected ReactInstanceManagerBuilder getBaseReactInstanceManagerBuilder() { - ReactInstanceManagerBuilder builder = - ReactInstanceManager.builder() - .setApplication(mApplication) - .setJSMainModulePath(getJSMainModuleName()) - .setUseDeveloperSupport(getUseDeveloperSupport()) - .setDevSupportManagerFactory(getDevSupportManagerFactory()) - .setDevLoadingViewManager(getDevLoadingViewManager()) - .setRequireActivity(getShouldRequireActivity()) - .setSurfaceDelegateFactory(getSurfaceDelegateFactory()) - .setJSExceptionHandler(getJSExceptionHandler()) - .setLazyViewManagersEnabled(getLazyViewManagersEnabled()) - .setRedBoxHandler(getRedBoxHandler()) - .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory()) - .setUIManagerProvider(getUIManagerProvider()) - .setInitialLifecycleState(LifecycleState.BEFORE_CREATE) - .setReactPackageTurboModuleManagerDelegateBuilder( - getReactPackageTurboModuleManagerDelegateBuilder()) - .setChoreographerProvider(getChoreographerProvider()) - .setPausedInDebuggerOverlayManager(getPausedInDebuggerOverlayManager()); - - for (ReactPackage reactPackage : getPackages()) { - builder.addPackage(reactPackage); - } - - String jsBundleFile = getJSBundleFile(); - if (jsBundleFile != null) { - builder.setJSBundleFile(jsBundleFile); - } else { - builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName())); - } - return builder; - } - - /** Get the {@link RedBoxHandler} to send RedBox-related callbacks to. */ - protected @Nullable RedBoxHandler getRedBoxHandler() { - return null; - } - - protected @Nullable JSExceptionHandler getJSExceptionHandler() { - return null; - } - - /** Get the {@link JavaScriptExecutorFactory}. Override this to use a custom Executor. */ - protected @Nullable JavaScriptExecutorFactory getJavaScriptExecutorFactory() { - return null; - } - - protected @Nullable ReactPackageTurboModuleManagerDelegate.Builder - getReactPackageTurboModuleManagerDelegateBuilder() { - return null; - } - - protected final Application getApplication() { - return mApplication; - } - - protected @Nullable UIManagerProvider getUIManagerProvider() { - return reactApplicationContext -> null; - } - - /** Returns whether or not to treat it as normal if Activity is null. */ - public boolean getShouldRequireActivity() { - return true; - } - - /** - * Returns whether view managers should be created lazily. See {@link - * ViewManagerOnDemandReactPackage} for details. - * - * @experimental - */ - public boolean getLazyViewManagersEnabled() { - return false; - } - - /** - * Return the {@link SurfaceDelegateFactory} used by NativeModules to get access to a {@link - * SurfaceDelegate} to interact with a surface. By default in the mobile platform the {@link - * SurfaceDelegate} it returns is null, and the NativeModule needs to implement its own {@link - * SurfaceDelegate} to decide how it would interact with its own container surface. - */ - public SurfaceDelegateFactory getSurfaceDelegateFactory() { - return new SurfaceDelegateFactory() { - @Override - public @Nullable SurfaceDelegate createSurfaceDelegate(String moduleName) { - return null; - } - }; - } - - /** - * Get the {@link DevLoadingViewManager}. Override this to use a custom dev loading view manager - */ - protected @Nullable DevLoadingViewManager getDevLoadingViewManager() { - return null; - } - - protected @Nullable PausedInDebuggerOverlayManager getPausedInDebuggerOverlayManager() { - return null; - } - - /** - * Returns the name of the main module. Determines the URL used to fetch the JS bundle from Metro. - * It is only used when dev support is enabled. This is the first file to be executed once the - * {@link ReactInstanceManager} is created. e.g. "index.android" - */ - protected String getJSMainModuleName() { - return "index.android"; - } - - /** - * Returns a custom path of the bundle file. This is used in cases the bundle should be loaded - * from a custom path. By default it is loaded from Android assets, from a path specified by - * {@link getBundleAssetName}. e.g. "file://sdcard/myapp_cache/index.android.bundle" - */ - protected @Nullable String getJSBundleFile() { - return null; - } - - /** - * Returns the name of the bundle in assets. If this is null, and no file path is specified for - * the bundle, the app will only work with {@code getUseDeveloperSupport} enabled and will always - * try to load the JS bundle from Metro. e.g. "index.android.bundle" - */ - protected @Nullable String getBundleAssetName() { - return "index.android.bundle"; - } - - /** Returns whether dev mode should be enabled. This enables e.g. the dev menu. */ - public abstract boolean getUseDeveloperSupport(); - - /** Get the {@link DevSupportManagerFactory}. Override this to use a custom dev support manager */ - protected @Nullable DevSupportManagerFactory getDevSupportManagerFactory() { - return null; - } - - /** - * Returns a list of {@link ReactPackage} used by the app. You'll most likely want to return at - * least the {@code MainReactPackage}. If your app uses additional views or modules besides the - * default ones, you'll want to include more packages here. - */ - protected abstract List getPackages(); - - /** - * Returns a custom implementation of ChoreographerProvider to be used this host. If null - React - * will use default direct android.view.Choreographer-based provider. - */ - protected @Nullable ChoreographerProvider getChoreographerProvider() { - return null; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.kt new file mode 100644 index 000000000000..c2ceb2d178e2 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.kt @@ -0,0 +1,210 @@ +/* + * 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. + */ + +@file:Suppress("DEPRECATION") + +package com.facebook.react + +import android.app.Application +import com.facebook.react.bridge.JSExceptionHandler +import com.facebook.react.bridge.JavaScriptExecutorFactory +import com.facebook.react.bridge.ReactMarker +import com.facebook.react.bridge.ReactMarkerConstants +import com.facebook.react.bridge.UIManagerProvider +import com.facebook.react.common.LifecycleState +import com.facebook.react.common.SurfaceDelegateFactory +import com.facebook.react.common.annotations.internal.LegacyArchitecture +import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel +import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger +import com.facebook.react.devsupport.DevSupportManagerFactory +import com.facebook.react.devsupport.interfaces.DevLoadingViewManager +import com.facebook.react.devsupport.interfaces.PausedInDebuggerOverlayManager +import com.facebook.react.devsupport.interfaces.RedBoxHandler +import com.facebook.react.internal.ChoreographerProvider + +/** + * Simple class that holds an instance of [ReactInstanceManager]. This can be used in your + * [Application] class (see [ReactApplication]), or as a static field. + * + * @deprecated This class will be replaced by com.facebook.react.ReactHost in the New Architecture. + */ +@Deprecated("This class is part of Legacy Architecture and will be removed in a future release") +@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) +public abstract class ReactNativeHost protected constructor(private val mApplication: Application) { + + private var mReactInstanceManager: ReactInstanceManager? = null + + /** + * Get the current [ReactInstanceManager] instance, or create one. + * + * NOTE: Care must be taken when storing this reference outside of the ReactNativeHost lifecycle. + * The ReactInstanceManager will be invalidated during [clear], and may not be used again + * afterwards. + */ + public open val reactInstanceManager: ReactInstanceManager + @Synchronized + get() { + if (mReactInstanceManager == null) { + ReactMarker.logMarker(ReactMarkerConstants.INIT_REACT_RUNTIME_START) + ReactMarker.logMarker(ReactMarkerConstants.GET_REACT_INSTANCE_MANAGER_START) + mReactInstanceManager = createReactInstanceManager() + ReactMarker.logMarker(ReactMarkerConstants.GET_REACT_INSTANCE_MANAGER_END) + } + return mReactInstanceManager!! + } + + /** + * Get whether this holder contains a [ReactInstanceManager] instance, or not. I.e. if + * [getReactInstanceManager] has been called at least once since this object was created or + * [clear] was called. + */ + @Synchronized public open fun hasInstance(): Boolean = mReactInstanceManager != null + + /** + * Destroy the current instance and invalidate the internal ReactInstanceManager, reclaiming its + * resources and preventing it from being reused. + */ + @Synchronized + public open fun clear() { + mReactInstanceManager?.invalidate() + mReactInstanceManager = null + } + + protected open fun createReactInstanceManager(): ReactInstanceManager { + ReactMarker.logMarker(ReactMarkerConstants.BUILD_REACT_INSTANCE_MANAGER_START) + val builder = getBaseReactInstanceManagerBuilder() + ReactMarker.logMarker(ReactMarkerConstants.BUILD_REACT_INSTANCE_MANAGER_END) + return builder.build() + } + + protected open fun getBaseReactInstanceManagerBuilder(): ReactInstanceManagerBuilder { + val builder = + ReactInstanceManager.builder() + .setApplication(mApplication) + .setJSMainModulePath(getJSMainModuleName()) + .setUseDeveloperSupport(getUseDeveloperSupport()) + .setDevSupportManagerFactory(getDevSupportManagerFactory()) + .setDevLoadingViewManager(getDevLoadingViewManager()) + .setRequireActivity(getShouldRequireActivity()) + .setSurfaceDelegateFactory(getSurfaceDelegateFactory()) + .setJSExceptionHandler(getJSExceptionHandler()) + .setLazyViewManagersEnabled(getLazyViewManagersEnabled()) + .setRedBoxHandler(getRedBoxHandler()) + .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory()) + .setUIManagerProvider(getUIManagerProvider()) + .setInitialLifecycleState(LifecycleState.BEFORE_CREATE) + .setReactPackageTurboModuleManagerDelegateBuilder( + getReactPackageTurboModuleManagerDelegateBuilder() + ) + .setChoreographerProvider(getChoreographerProvider()) + .setPausedInDebuggerOverlayManager(getPausedInDebuggerOverlayManager()) + + for (reactPackage in getPackages()) { + builder.addPackage(reactPackage) + } + + val jsBundleFile = getJSBundleFile() + if (jsBundleFile != null) { + builder.setJSBundleFile(jsBundleFile) + } else { + builder.setBundleAssetName( + com.facebook.infer.annotation.Assertions.assertNotNull(getBundleAssetName()) + ) + } + return builder + } + + /** Get the [RedBoxHandler] to send RedBox-related callbacks to. */ + protected open fun getRedBoxHandler(): RedBoxHandler? = null + + protected open fun getJSExceptionHandler(): JSExceptionHandler? = null + + /** Get the [JavaScriptExecutorFactory]. Override this to use a custom Executor. */ + protected open fun getJavaScriptExecutorFactory(): JavaScriptExecutorFactory? = null + + protected open fun getReactPackageTurboModuleManagerDelegateBuilder(): + ReactPackageTurboModuleManagerDelegate.Builder? = null + + protected fun getApplication(): Application = mApplication + + protected open fun getUIManagerProvider(): UIManagerProvider? = UIManagerProvider { null } + + /** Returns whether or not to treat it as normal if Activity is null. */ + public open fun getShouldRequireActivity(): Boolean = true + + /** + * Returns whether view managers should be created lazily. See [ViewManagerOnDemandReactPackage] + * for details. + * + * @experimental + */ + public open fun getLazyViewManagersEnabled(): Boolean = false + + /** + * Return the [SurfaceDelegateFactory] used by NativeModules to get access to a SurfaceDelegate to + * interact with a surface. By default in the mobile platform the SurfaceDelegate it returns is + * null, and the NativeModule needs to implement its own SurfaceDelegate to decide how it would + * interact with its own container surface. + */ + public open fun getSurfaceDelegateFactory(): SurfaceDelegateFactory = SurfaceDelegateFactory { + null + } + + /** Get the [DevLoadingViewManager]. Override this to use a custom dev loading view manager. */ + protected open fun getDevLoadingViewManager(): DevLoadingViewManager? = null + + protected open fun getPausedInDebuggerOverlayManager(): PausedInDebuggerOverlayManager? = null + + /** + * Returns the name of the main module. Determines the URL used to fetch the JS bundle from Metro. + * It is only used when dev support is enabled. This is the first file to be executed once the + * [ReactInstanceManager] is created. e.g. "index.android" + */ + protected open fun getJSMainModuleName(): String = "index.android" + + /** + * Returns a custom path of the bundle file. This is used in cases the bundle should be loaded + * from a custom path. By default it is loaded from Android assets, from a path specified by + * [getBundleAssetName]. e.g. "file://sdcard/myapp_cache/index.android.bundle" + */ + protected open fun getJSBundleFile(): String? = null + + /** + * Returns the name of the bundle in assets. If this is null, and no file path is specified for + * the bundle, the app will only work with [getUseDeveloperSupport] enabled and will always try to + * load the JS bundle from Metro. e.g. "index.android.bundle" + */ + protected open fun getBundleAssetName(): String? = "index.android.bundle" + + /** Returns whether dev mode should be enabled. This enables e.g. the dev menu. */ + public abstract fun getUseDeveloperSupport(): Boolean + + /** Get the [DevSupportManagerFactory]. Override this to use a custom dev support manager. */ + protected open fun getDevSupportManagerFactory(): DevSupportManagerFactory? = null + + /** + * Returns a list of [ReactPackage] used by the app. You'll most likely want to return at least + * the `MainReactPackage`. If your app uses additional views or modules besides the default ones, + * you'll want to include more packages here. + */ + protected abstract fun getPackages(): List + + /** + * Returns a custom implementation of ChoreographerProvider to be used this host. If null - React + * will use default direct android.view.Choreographer-based provider. + */ + protected open fun getChoreographerProvider(): ChoreographerProvider? = null + + public companion object { + init { + LegacyArchitectureLogger.assertLegacyArchitecture( + "ReactNativeHost", + LegacyArchitectureLogLevel.ERROR, + ) + } + } +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactNativeHost.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactNativeHost.kt index 0298812cd82b..8f4c5a823d83 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactNativeHost.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactNativeHost.kt @@ -54,7 +54,7 @@ protected constructor( DefaultComponentsRegistry.register(componentFactory) val viewManagerRegistry = - if (lazyViewManagersEnabled) { + if (getLazyViewManagersEnabled()) { ViewManagerRegistry( object : ViewManagerResolver { override fun getViewManager(viewManagerName: String) = @@ -120,12 +120,12 @@ protected constructor( val concreteJSRuntimeFactory = jsRuntimeFactory ?: HermesInstance() return DefaultReactHost.getDefaultReactHost( context, - packages, - jsMainModuleName, - bundleAssetName ?: "index.android.bundle", - jsBundleFile, + getPackages(), + getJSMainModuleName(), + getBundleAssetName() ?: "index.android.bundle", + getJSBundleFile(), concreteJSRuntimeFactory, - useDeveloperSupport, + getUseDeveloperSupport(), ) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java deleted file mode 100644 index 25b8e4d954e3..000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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. - */ - -package com.facebook.react.uimanager; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.common.annotations.internal.LegacyArchitecture; -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel; -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; - -/** - * @deprecated This class is part of Legacy Architecture and has been stubbed out. It will be - * removed in a future release. - */ -@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) -@Deprecated( - since = "This class is part of Legacy Architecture and will be removed in a future release") -public class NativeViewHierarchyManager { - - static { - LegacyArchitectureLogger.assertLegacyArchitecture( - "NativeViewHierarchyManager", LegacyArchitectureLogLevel.ERROR); - } - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public NativeViewHierarchyManager(ViewManagerRegistry viewManagers) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public NativeViewHierarchyManager(ViewManagerRegistry viewManagers, RootViewManager manager) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public final synchronized @Nullable View resolveView(int tag) { - return null; - } - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public final synchronized @Nullable ViewManager resolveViewManager(int tag) { - return null; - } - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public void setLayoutAnimationEnabled(boolean enabled) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void updateInstanceHandle(int tag, long instanceHandle) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void updateProperties(int tag, ReactStylesDiffMap props) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void updateViewExtraData(int tag, Object extraData) {} - - /** - * @deprecated Please use {@link #updateLayout(int tag, int x, int y, int width, int height, - * YogaDirection layoutDirection)} instead. - */ - @Deprecated - public void updateLayout(int tag, int x, int y, int width, int height) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void updateLayout( - int parentTag, - int tag, - int x, - int y, - int width, - int height, - com.facebook.yoga.YogaDirection layoutDirection) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized long getInstanceHandle(int reactTag) { - return 0; - } - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void createView( - ThemedReactContext themedContext, - int tag, - String className, - @Nullable ReactStylesDiffMap initialProps) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void manageChildren( - int tag, - @Nullable int[] indicesToRemove, - @Nullable ViewAtIndex[] viewsToAdd, - @Nullable int[] tagsToDelete) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void setChildren(int tag, ReadableArray childrenTags) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void addRootView(int tag, View view) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - protected final synchronized void addRootViewGroup(int tag, View view) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - protected synchronized void dropView(View view) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void removeRootView(int rootViewTag) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized int getRootViewNum() { - return 0; - } - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void measure(int tag, int[] outputBuffer) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void measureInWindow(int tag, int[] outputBuffer) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized int findTargetTagForTouch(int reactTag, float touchX, float touchY) { - return 0; - } - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void setJSResponder( - int reactTag, int initialReactTag, boolean blockNativeResponder) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void clearJSResponder() {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void dispatchCommand( - int reactTag, int commandId, @Nullable ReadableArray args) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void dispatchCommand( - int reactTag, String commandId, @Nullable ReadableArray args) {} - - /** - * @deprecated Use new architecture instead. - */ - @Deprecated - public synchronized void sendAccessibilityEvent(int tag, int eventType) {} -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.kt new file mode 100644 index 000000000000..5036352996ca --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.kt @@ -0,0 +1,184 @@ +/* + * 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. + */ + +package com.facebook.react.uimanager + +import android.view.View +import com.facebook.react.bridge.ReadableArray +import com.facebook.react.common.annotations.internal.LegacyArchitecture +import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel +import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger + +/** + * This class is part of Legacy Architecture and has been stubbed out. It will be removed in a + * future release. + */ +@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) +@Deprecated("This class is part of Legacy Architecture and will be removed in a future release") +@Suppress("EXPOSED_PARAMETER_TYPE") +public open class NativeViewHierarchyManager { + + @Deprecated("Use new architecture instead.") public constructor(viewManagers: ViewManagerRegistry) + + @Deprecated("Use new architecture instead.") + public constructor(viewManagers: ViewManagerRegistry, manager: RootViewManager) + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public fun resolveView(tag: Int): View? = null + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public fun resolveViewManager(tag: Int): ViewManager<*, *>? = null + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + public open fun setLayoutAnimationEnabled(enabled: Boolean): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun updateInstanceHandle(tag: Int, instanceHandle: Long): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun updateProperties(tag: Int, props: ReactStylesDiffMap?): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun updateViewExtraData(tag: Int, extraData: Any?): Unit = Unit + + /** @deprecated Please use [updateLayout] with YogaDirection parameter instead. */ + @Deprecated("Please use updateLayout with YogaDirection parameter instead.") + public open fun updateLayout(tag: Int, x: Int, y: Int, width: Int, height: Int): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun updateLayout( + parentTag: Int, + tag: Int, + x: Int, + y: Int, + width: Int, + height: Int, + layoutDirection: com.facebook.yoga.YogaDirection, + ): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun getInstanceHandle(reactTag: Int): Long = 0 + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun createView( + themedContext: ThemedReactContext, + tag: Int, + className: String, + initialProps: ReactStylesDiffMap?, + ): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun manageChildren( + tag: Int, + indicesToRemove: IntArray?, + viewsToAdd: Array?, + tagsToDelete: IntArray?, + ): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun setChildren(tag: Int, childrenTags: ReadableArray?): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun addRootView(tag: Int, view: View): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + protected fun addRootViewGroup(tag: Int, view: View): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + protected open fun dropView(view: View): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun removeRootView(rootViewTag: Int): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun getRootViewNum(): Int = 0 + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun measure(tag: Int, outputBuffer: IntArray): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun measureInWindow(tag: Int, outputBuffer: IntArray): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun findTargetTagForTouch(reactTag: Int, touchX: Float, touchY: Float): Int = 0 + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun setJSResponder( + reactTag: Int, + initialReactTag: Int, + blockNativeResponder: Boolean, + ): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun clearJSResponder(): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun dispatchCommand(reactTag: Int, commandId: Int, args: ReadableArray?): Unit = Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun dispatchCommand(reactTag: Int, commandId: String, args: ReadableArray?): Unit = + Unit + + /** @deprecated Use new architecture instead. */ + @Deprecated("Use new architecture instead.") + @Synchronized + public open fun sendAccessibilityEvent(tag: Int, eventType: Int): Unit = Unit + + public companion object { + init { + LegacyArchitectureLogger.assertLegacyArchitecture( + "NativeViewHierarchyManager", + LegacyArchitectureLogLevel.ERROR, + ) + } + } +}