Skip to content

Commit

Permalink
Migrate fabric.mounting.mountitems subset to Kotlin (facebook#44440)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#44440

# Changelog:
[Internal] -

As in the title, note that there are more files there to migrate, will come separately, to make reviewing easier.

Reviewed By: javache

Differential Revision: D57046953
  • Loading branch information
rshest authored and facebook-github-bot committed May 7, 2024
1 parent 06eea61 commit 6f8b60c
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 171 deletions.
14 changes: 7 additions & 7 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -2802,13 +2802,13 @@ public abstract interface class com/facebook/react/fabric/mounting/mountitems/Mo
public abstract fun getSurfaceId ()I
}

public class com/facebook/react/fabric/mounting/mountitems/MountItemFactory {
public fun <init> ()V
public static fun createDispatchCommandMountItem (IIILcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem;
public static fun createDispatchCommandMountItem (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem;
public static fun createIntBufferBatchMountItem (I[I[Ljava/lang/Object;I)Lcom/facebook/react/fabric/mounting/mountitems/MountItem;
public static fun createPreAllocateViewMountItem (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)Lcom/facebook/react/fabric/mounting/mountitems/MountItem;
public static fun createSendAccessibilityEventMountItem (III)Lcom/facebook/react/fabric/mounting/mountitems/MountItem;
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 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;Lcom/facebook/react/fabric/events/EventEmitterWrapper;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 {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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.fabric.mounting.mountitems

public interface BatchMountItem : MountItem {
/** @return if the BatchMountItem contains any MountItem */
public fun isBatchEmpty(): Boolean
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.fabric.mounting.mountitems

/**
* Utility class for Fabric components, this will be removed
*
* TODO T97384889: remove this class when the component names are unified between JS - Android -
* iOS - C++
*/
internal object FabricNameComponentMapping {
private val componentNames: Map<String, String> =
mapOf(
// TODO T97384889: unify component names between JS - Android - iOS - C++
"View" to "RCTView",
"Image" to "RCTImageView",
"ScrollView" to "RCTScrollView",
"Slider" to "RCTSlider",
"ModalHostView" to "RCTModalHostView",
"Paragraph" to "RCTText",
"Text" to "RCText",
"RawText" to "RCTRawText",
"ActivityIndicatorView" to "AndroidProgressBar",
"ShimmeringView" to "RKShimmeringView",
"TemplateView" to "RCTTemplateView",
"AxialGradientView" to "RCTAxialGradientView",
"Video" to "RCTVideo",
"Map" to "RCTMap",
"WebView" to "RCTWebView",
"Keyframes" to "RCTKeyframes",
"ImpressionTrackingView" to "RCTImpressionTrackingView",
)

/** @return the name of component in the Fabric environment */
@JvmStatic
fun getFabricComponentName(componentName: String): String {
val component = componentNames[componentName]
return component ?: componentName
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.fabric.mounting.mountitems

import androidx.annotation.AnyThread
import androidx.annotation.UiThread
import com.facebook.proguard.annotations.DoNotStripAny
import com.facebook.react.fabric.mounting.MountingManager

@DoNotStripAny
public interface MountItem {
/** Execute this [MountItem] into the operation queue received by parameter. */
@UiThread public fun execute(mountingManager: MountingManager)

@AnyThread public fun getSurfaceId(): Int
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.fabric.mounting.mountitems

import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.fabric.events.EventEmitterWrapper
import com.facebook.react.uimanager.StateWrapper

/** Factory class that expose creation of [MountItem] */
public object MountItemFactory {
/** @return a [DispatchCommandMountItem] for commands identified by an int */
@JvmStatic
public fun createDispatchCommandMountItem(
surfaceId: Int,
reactTag: Int,
commandId: Int,
commandArgs: ReadableArray?
): DispatchCommandMountItem =
DispatchIntCommandMountItem(surfaceId, reactTag, commandId, commandArgs)

/** @return a [DispatchCommandMountItem] for commands identified by a String */
@JvmStatic
public fun createDispatchCommandMountItem(
surfaceId: Int,
reactTag: Int,
commandId: String,
commandArgs: ReadableArray?
): DispatchCommandMountItem =
DispatchStringCommandMountItem(surfaceId, reactTag, commandId, commandArgs)

/** @return a [MountItem] that will control the execution of an AccessibilityEvent */
@JvmStatic
public fun createSendAccessibilityEventMountItem(
surfaceId: Int,
reactTag: Int,
eventType: Int
): MountItem = SendAccessibilityEventMountItem(surfaceId, reactTag, eventType)

/** @return a [MountItem] that will be used to preallocate views */
@JvmStatic
public fun createPreAllocateViewMountItem(
surfaceId: Int,
reactTag: Int,
component: String,
props: ReadableMap?,
stateWrapper: StateWrapper?,
eventEmitterWrapper: EventEmitterWrapper?,
isLayoutable: Boolean
): MountItem =
PreAllocateViewMountItem(
surfaceId, reactTag, component, props, stateWrapper, eventEmitterWrapper, isLayoutable)

/**
* @return a [MountItem] that will be read and execute a collection of MountItems serialized in
* the int[] and Object[] received by parameter
*/
@JvmStatic
public fun createIntBufferBatchMountItem(
surfaceId: Int,
intBuf: IntArray?,
objBuf: Array<Any?>?,
commitNumber: Int
): MountItem = IntBufferBatchMountItem(surfaceId, intBuf, objBuf, commitNumber)
}

0 comments on commit 6f8b60c

Please sign in to comment.