Skip to content

Commit

Permalink
Inline DefaultJSIModulePackage (#41094)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #41094

Inlining the `DefaultJSIModulePackage` in `DefaultReactNativeHost` for simplification

Changelog:
[Internal] internal

Reviewed By: mdvacca

Differential Revision: D50468945

fbshipit-source-id: 9c458044518db1db38cdac590da542be497cecaf
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Oct 23, 2023
1 parent 9b6e2d2 commit 85356fd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 60 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ import android.app.Application
import android.content.Context
import com.facebook.react.JSEngineResolutionAlgorithm
import com.facebook.react.ReactHost
import com.facebook.react.ReactInstanceManager
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackageTurboModuleManagerDelegate
import com.facebook.react.bridge.JSIModulePackage
import com.facebook.react.bridge.JSIModuleProvider
import com.facebook.react.bridge.JSIModuleSpec
import com.facebook.react.bridge.JSIModuleType
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.UIManager
import com.facebook.react.fabric.ComponentFactory
import com.facebook.react.fabric.FabricJSIModuleProvider
import com.facebook.react.fabric.ReactNativeConfig
import com.facebook.react.uimanager.ViewManagerRegistry

/**
* A utility class that allows you to simplify the setup of a [ReactNativeHost] for new apps in Open
Expand All @@ -38,7 +48,29 @@ protected constructor(

override fun getJSIModulePackage(): JSIModulePackage? =
if (isNewArchEnabled) {
DefaultJSIModulePackage(this)
JSIModulePackage { reactApplicationContext: ReactApplicationContext, _ ->
listOf(
object : JSIModuleSpec<UIManager> {
override fun getJSIModuleType(): JSIModuleType = JSIModuleType.UIManager

override fun getJSIModuleProvider(): JSIModuleProvider<UIManager> {
val componentFactory = ComponentFactory()

DefaultComponentsRegistry.register(componentFactory)

val reactInstanceManager: ReactInstanceManager = getReactInstanceManager()

val viewManagers =
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext)
val viewManagerRegistry = ViewManagerRegistry(viewManagers)
return FabricJSIModuleProvider(
reactApplicationContext,
componentFactory,
ReactNativeConfig.DEFAULT_CONFIG,
viewManagerRegistry)
}
})
}
} else {
null
}
Expand Down

0 comments on commit 85356fd

Please sign in to comment.