From 0928406530e64ddeb4e39e5fbbb52896fb0a1114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateo=20Guzm=C3=A1n?= Date: Mon, 10 Mar 2025 06:54:42 -0700 Subject: [PATCH] Make `DispatchCommandMountItem`, `MountItemFactory`, `MountItem` & `BatchMountItem` internal (#49893) Summary: As part of the initiative to reduce the public API surface, these classes under com.facebook.react.fabric.mounting.mountitems can be internalized. I've checked there are no relevant OSS usages: - [DispatchCommandMountItem](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem) (all GH results are forks) - [MountItemFactory](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.fabric.mounting.mountitems.MountItemFactory) - [MountItem](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.fabric.mounting.mountitems.MountItem) (a lot of GH results, but all are forks) - [BatchMountItem](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.fabric.mounting.mountitems.BatchMountItem) (all GH results are forks) ## Changelog: [INTERNAL] - Make DispatchCommandMountItem, MountItemFactory, MountItem & BatchMountItem internal Pull Request resolved: https://github.com/facebook/react-native/pull/49893 Test Plan: ```bash yarn test-android yarn android ``` Reviewed By: cortinico Differential Revision: D70788076 Pulled By: javache fbshipit-source-id: 34b8c5e0a716365d5905dfb846c6467b0ae9fc09 --- .../ReactAndroid/api/ReactAndroid.api | 25 ------------------- .../mounting/mountitems/BatchMountItem.kt | 4 +-- .../mountitems/DispatchCommandMountItem.kt | 6 ++--- .../fabric/mounting/mountitems/MountItem.kt | 6 ++--- .../mounting/mountitems/MountItemFactory.kt | 14 +++++------ 5 files changed, 15 insertions(+), 40 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 60893586c9d..1c0e6f5ccb4 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -2562,31 +2562,6 @@ public class com/facebook/react/fabric/mounting/SurfaceMountingManager { public fun updateState (ILcom/facebook/react/uimanager/StateWrapper;)V } -public abstract interface class com/facebook/react/fabric/mounting/mountitems/BatchMountItem : com/facebook/react/fabric/mounting/mountitems/MountItem { - public abstract fun isBatchEmpty ()Z -} - -public abstract class com/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem : com/facebook/react/fabric/mounting/mountitems/MountItem { - public fun ()V - public final fun getRetries ()I - public final fun incrementRetries ()V -} - -public abstract interface class com/facebook/react/fabric/mounting/mountitems/MountItem { - public abstract fun execute (Lcom/facebook/react/fabric/mounting/MountingManager;)V - public abstract fun getSurfaceId ()I -} - -public final class com/facebook/react/fabric/mounting/mountitems/MountItemFactory { - public static final field INSTANCE Lcom/facebook/react/fabric/mounting/mountitems/MountItemFactory; - public static final fun createDestroyViewMountItem (II)Lcom/facebook/react/fabric/mounting/mountitems/MountItem; - public static final fun createDispatchCommandMountItem (IIILcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem; - public static final fun createDispatchCommandMountItem (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem; - public static final fun createIntBufferBatchMountItem (I[I[Ljava/lang/Object;I)Lcom/facebook/react/fabric/mounting/mountitems/MountItem; - public static final fun createPreAllocateViewMountItem (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/uimanager/StateWrapper;Z)Lcom/facebook/react/fabric/mounting/mountitems/MountItem; - public static final fun createSendAccessibilityEventMountItem (III)Lcom/facebook/react/fabric/mounting/mountitems/MountItem; -} - public abstract interface class com/facebook/react/interfaces/TaskInterface { public abstract fun getError ()Ljava/lang/Exception; public abstract fun getResult ()Ljava/lang/Object; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.kt index 1450d791b87..b1841223635 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.kt @@ -7,7 +7,7 @@ package com.facebook.react.fabric.mounting.mountitems -public interface BatchMountItem : MountItem { +internal interface BatchMountItem : MountItem { /** @return if the BatchMountItem contains any MountItem */ - public fun isBatchEmpty(): Boolean + fun isBatchEmpty(): Boolean } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem.kt index e44050f72fe..10dd3a02a03 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem.kt @@ -14,13 +14,13 @@ import androidx.annotation.UiThread * DispatchIntCommandMountItem}, we can delete this interface too. It provides a set of common * operations to simplify generic operations on all types of ViewCommands. */ -public abstract class DispatchCommandMountItem : MountItem { +internal abstract class DispatchCommandMountItem : MountItem { private var numRetries: Int = 0 @UiThread - public fun incrementRetries() { + fun incrementRetries() { numRetries++ } - @UiThread public fun getRetries(): Int = numRetries + @UiThread fun getRetries(): Int = numRetries } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItem.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItem.kt index 37181775b21..bb0e23efa72 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItem.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItem.kt @@ -13,9 +13,9 @@ import com.facebook.proguard.annotations.DoNotStripAny import com.facebook.react.fabric.mounting.MountingManager @DoNotStripAny -public interface MountItem { +internal interface MountItem { /** Execute this [MountItem] into the operation queue received by parameter. */ - @UiThread public fun execute(mountingManager: MountingManager) + @UiThread fun execute(mountingManager: MountingManager) - @AnyThread public fun getSurfaceId(): Int + @AnyThread fun getSurfaceId(): Int } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItemFactory.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItemFactory.kt index d3e71cc0536..c6886a86049 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItemFactory.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/MountItemFactory.kt @@ -12,10 +12,10 @@ import com.facebook.react.bridge.ReadableMap import com.facebook.react.uimanager.StateWrapper /** Factory class that expose creation of [MountItem] */ -public object MountItemFactory { +internal object MountItemFactory { /** @return a [DispatchCommandMountItem] for commands identified by an int */ @JvmStatic - public fun createDispatchCommandMountItem( + fun createDispatchCommandMountItem( surfaceId: Int, reactTag: Int, commandId: Int, @@ -25,7 +25,7 @@ public object MountItemFactory { /** @return a [DispatchCommandMountItem] for commands identified by a String */ @JvmStatic - public fun createDispatchCommandMountItem( + fun createDispatchCommandMountItem( surfaceId: Int, reactTag: Int, commandId: String, @@ -35,7 +35,7 @@ public object MountItemFactory { /** @return a [MountItem] that will control the execution of an AccessibilityEvent */ @JvmStatic - public fun createSendAccessibilityEventMountItem( + fun createSendAccessibilityEventMountItem( surfaceId: Int, reactTag: Int, eventType: Int @@ -43,7 +43,7 @@ public object MountItemFactory { /** @return a [MountItem] that will be used to preallocate views */ @JvmStatic - public fun createPreAllocateViewMountItem( + fun createPreAllocateViewMountItem( surfaceId: Int, reactTag: Int, component: String, @@ -55,7 +55,7 @@ public object MountItemFactory { /** @return a [MountItem] that will be used to destroy views */ @JvmStatic - public fun createDestroyViewMountItem(surfaceId: Int, reactTag: Int): MountItem = + fun createDestroyViewMountItem(surfaceId: Int, reactTag: Int): MountItem = DestroyUnmountedViewMountItem(surfaceId, reactTag) /** @@ -63,7 +63,7 @@ public object MountItemFactory { * the int[] and Object[] received by parameter */ @JvmStatic - public fun createIntBufferBatchMountItem( + fun createIntBufferBatchMountItem( surfaceId: Int, intBuf: IntArray, objBuf: Array,