Skip to content

Commit

Permalink
Move fabric.Binding* to Kotlin (facebook#44438)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#44438

# Changelog:
[Internal] -

As in the title.

Differential Revision: D57046289
  • Loading branch information
rshest authored and facebook-github-bot committed May 7, 2024
1 parent 47848ad commit 0d819c9
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 191 deletions.
2 changes: 1 addition & 1 deletion packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,7 @@ public abstract interface class com/facebook/react/fabric/Binding {
public abstract fun unregisterSurface (Lcom/facebook/react/fabric/SurfaceHandlerBinding;)V
}

public class com/facebook/react/fabric/BindingImpl : com/facebook/react/fabric/Binding {
public final class com/facebook/react/fabric/BindingImpl : com/facebook/react/fabric/Binding {
public fun <init> ()V
public fun driveCxxAnimations ()V
public fun getInspectorDataForInstance (Lcom/facebook/react/fabric/events/EventEmitterWrapper;)Lcom/facebook/react/bridge/ReadableNativeMap;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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

import com.facebook.react.bridge.NativeMap
import com.facebook.react.bridge.ReadableNativeMap
import com.facebook.react.bridge.RuntimeExecutor
import com.facebook.react.bridge.RuntimeScheduler
import com.facebook.react.fabric.events.EventBeatManager
import com.facebook.react.fabric.events.EventEmitterWrapper

public interface Binding {
public fun startSurface(surfaceId: Int, moduleName: String, initialProps: NativeMap)

public fun startSurfaceWithConstraints(
surfaceId: Int,
moduleName: String?,
initialProps: NativeMap?,
minWidth: Float,
maxWidth: Float,
minHeight: Float,
maxHeight: Float,
offsetX: Float,
offsetY: Float,
isRTL: Boolean,
doLeftAndRightSwapInRTL: Boolean
)

public fun stopSurface(surfaceId: Int)

public fun setPixelDensity(pointScaleFactor: Float)

public fun setConstraints(
surfaceId: Int,
minWidth: Float,
maxWidth: Float,
minHeight: Float,
maxHeight: Float,
offsetX: Float,
offsetY: Float,
isRTL: Boolean,
doLeftAndRightSwapInRTL: Boolean
)

public fun driveCxxAnimations()

public fun reportMount(surfaceId: Int)

public fun getInspectorDataForInstance(
eventEmitterWrapper: EventEmitterWrapper?
): ReadableNativeMap?

public fun register(
runtimeExecutor: RuntimeExecutor,
runtimeScheduler: RuntimeScheduler,
fabricUIManager: FabricUIManager,
eventBeatManager: EventBeatManager,
componentFactory: ComponentFactory,
reactNativeConfig: ReactNativeConfig
)

public fun unregister()

public fun registerSurface(surfaceHandler: SurfaceHandlerBinding?)

public fun unregisterSurface(surfaceHandler: SurfaceHandlerBinding?)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* 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

import android.annotation.SuppressLint
import com.facebook.jni.HybridData
import com.facebook.proguard.annotations.DoNotStrip
import com.facebook.react.bridge.NativeMap
import com.facebook.react.bridge.ReadableNativeMap
import com.facebook.react.bridge.RuntimeExecutor
import com.facebook.react.bridge.RuntimeScheduler
import com.facebook.react.common.mapbuffer.MapBufferSoLoader
import com.facebook.react.fabric.events.EventBeatManager
import com.facebook.react.fabric.events.EventEmitterWrapper
import com.facebook.react.uimanager.PixelUtil.getDisplayMetricDensity

@DoNotStrip
@SuppressLint("MissingNativeLoadLibrary")
public class BindingImpl : Binding {
@DoNotStrip private val hybridData: HybridData = initHybrid()

private external fun installFabricUIManager(
runtimeExecutor: RuntimeExecutor,
runtimeScheduler: RuntimeScheduler,
uiManager: FabricUIManager,
eventBeatManager: EventBeatManager,
componentsRegistry: ComponentFactory,
reactNativeConfig: Any
)

external override fun startSurface(surfaceId: Int, moduleName: String, initialProps: NativeMap)

external override fun startSurfaceWithConstraints(
surfaceId: Int,
moduleName: String?,
initialProps: NativeMap?,
minWidth: Float,
maxWidth: Float,
minHeight: Float,
maxHeight: Float,
offsetX: Float,
offsetY: Float,
isRTL: Boolean,
doLeftAndRightSwapInRTL: Boolean
)

external override fun stopSurface(surfaceId: Int)

external override fun setPixelDensity(pointScaleFactor: Float)

external override fun setConstraints(
surfaceId: Int,
minWidth: Float,
maxWidth: Float,
minHeight: Float,
maxHeight: Float,
offsetX: Float,
offsetY: Float,
isRTL: Boolean,
doLeftAndRightSwapInRTL: Boolean
)

external override fun driveCxxAnimations()

external override fun reportMount(surfaceId: Int)

external override fun getInspectorDataForInstance(
eventEmitterWrapper: EventEmitterWrapper?
): ReadableNativeMap?

override fun register(
runtimeExecutor: RuntimeExecutor,
runtimeScheduler: RuntimeScheduler,
fabricUIManager: FabricUIManager,
eventBeatManager: EventBeatManager,
componentFactory: ComponentFactory,
reactNativeConfig: ReactNativeConfig
) {
fabricUIManager.setBinding(this)
installFabricUIManager(
runtimeExecutor,
runtimeScheduler,
fabricUIManager,
eventBeatManager,
componentFactory,
reactNativeConfig)
setPixelDensity(getDisplayMetricDensity())
}

private external fun uninstallFabricUIManager()

override fun unregister() {
uninstallFabricUIManager()
}

external override fun registerSurface(surfaceHandler: SurfaceHandlerBinding?)

external override fun unregisterSurface(surfaceHandler: SurfaceHandlerBinding?)

private companion object {
init {
FabricSoLoader.staticInit()
MapBufferSoLoader.staticInit()
}

private external fun initHybrid(): HybridData
}
}

0 comments on commit 0d819c9

Please sign in to comment.