@juspay-tech/react-native-hyperswitch 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HyperswitchSdkReactNative.podspec +31 -0
- package/android/build.gradle +119 -0
- package/android/gradle.properties +5 -0
- package/android/hyperswitch_autolinking.gradle +378 -0
- package/android/proguard-rules.pro +72 -0
- package/android/src/main/AndroidManifest.xml +25 -0
- package/android/src/main/assets/hyperswitch.bundle +1677 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/HyperswitchSdkReactNativePackage.kt +36 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/activity/RedirectActivity.kt +39 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/DefaultReactHost.kt +314 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/DefaultReactNativeHost.kt +131 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/ReactDelegate.kt +423 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/ReactFragment.kt +335 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/HyperswitchSdkNativeModule.kt +143 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/HyperswitchSdkReactNativeModule.kt +92 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/provider/HyperProvider.kt +269 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/views/GooglePayButtonView.kt +60 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/views/GooglePayButtonViewManager.kt +76 -0
- package/android/src/main/java/io/hyperswitch/hyperota/HyperOtaLogger.kt +122 -0
- package/android/src/main/java/io/hyperswitch/logs/CrashHandler.kt +29 -0
- package/android/src/main/java/io/hyperswitch/logs/Debouncer.kt +20 -0
- package/android/src/main/java/io/hyperswitch/logs/HyperLogManager.kt +113 -0
- package/android/src/main/java/io/hyperswitch/logs/LogData.kt +159 -0
- package/android/src/main/java/io/hyperswitch/logs/LogFileManager.kt +60 -0
- package/android/src/main/java/io/hyperswitch/networking/HyperNetworking.kt +73 -0
- package/android/src/main/java/io/hyperswitch/react/Utils.kt +23 -0
- package/android/src/main/res/values/attrs.xml +6 -0
- package/android/src/main/res/values/strings.xml +5 -0
- package/android/src/main/res/values/theme.xml +16 -0
- package/ios/Modules/HyperswitchModule.swift +61 -0
- package/ios/Modules/HyperswitchNativeModule.swift +113 -0
- package/ios/Modules/HyperswitchSdkNative.h +5 -0
- package/ios/Modules/HyperswitchSdkNative.mm +98 -0
- package/ios/Modules/HyperswitchSdkReactNative.h +5 -0
- package/ios/Modules/HyperswitchSdkReactNative.mm +53 -0
- package/ios/Views/ApplePayView.h +14 -0
- package/ios/Views/ApplePayView.mm +89 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayHandler.swift +249 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.m +18 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.swift +123 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+SwiftUI.swift +49 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+UIKit.swift +49 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView.swift +80 -0
- package/ios/hyperswitchSDK/Core/HyperSession/PaymentSession+UIKit.swift +176 -0
- package/ios/hyperswitchSDK/Core/HyperSession/PaymentSessionTypes.swift +121 -0
- package/ios/hyperswitchSDK/Core/Models/LogPayload.swift +53 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/Debouncer.swift +37 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/LogBuilder.swift +91 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/LogFileManager.swift +75 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/LogManager.swift +113 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.m +16 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.swift +74 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.m +28 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.swift +168 -0
- package/ios/hyperswitchSDK/Core/NativeModule/OTAServices.swift +113 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNHeadlessManager.swift +45 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNResponseHandler.swift +12 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNViewManager.swift +90 -0
- package/ios/hyperswitchSDK/Core/NativeModule/hyper-Bridging-Header.h +9 -0
- package/ios/hyperswitchSDK/Core/Resources/HyperOTA.plist +20 -0
- package/ios/hyperswitchSDK/Core/Resources/hyperswitch.bundle +1673 -0
- package/ios/hyperswitchSDK/Shared/APIClient.swift +21 -0
- package/ios/hyperswitchSDK/Shared/DictionaryConverter.swift +104 -0
- package/ios/hyperswitchSDK/Shared/Environment.swift +24 -0
- package/ios/hyperswitchSDK/Shared/Extensions.swift +31 -0
- package/ios/hyperswitchSDK/Shared/Helper.swift +16 -0
- package/ios/hyperswitchSDK/Shared/HyperNetworking.swift +137 -0
- package/ios/hyperswitchSDK/Shared/HyperParams.swift +44 -0
- package/ios/hyperswitchSDK/Shared/HyperUIViewController.swift +25 -0
- package/ios/hyperswitchSDK/Shared/PaymentSession.swift +43 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheet.swift +30 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheetAppearance.swift +264 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheetConfiguration.swift +494 -0
- package/ios/hyperswitchSDK/Shared/SwiftUIManager.swift +28 -0
- package/ios/hyperswitchSDK/Shared/Version.swift +12 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.mlmap +5 -0
- package/lib/bs/build.ninja +29 -0
- package/lib/bs/install.ninja +25 -0
- package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/context/HyperProvider.ast +0 -0
- package/lib/bs/src/context/HyperProvider.d +1 -0
- package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/hooks/useHyper.ast +0 -0
- package/lib/bs/src/hooks/useHyper.d +1 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk.ast +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk.d +1 -0
- package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration.ast +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration.d +1 -0
- package/lib/commonjs/context/HyperProvider.gen.js +16 -0
- package/lib/commonjs/context/HyperProvider.gen.js.map +1 -0
- package/lib/commonjs/context/HyperProvider.res +78 -0
- package/lib/commonjs/context/HyperProvider.res.js +98 -0
- package/lib/commonjs/context/HyperProvider.res.js.map +1 -0
- package/lib/commonjs/hooks/useHyper.gen.js +15 -0
- package/lib/commonjs/hooks/useHyper.gen.js.map +1 -0
- package/lib/commonjs/hooks/useHyper.res +142 -0
- package/lib/commonjs/hooks/useHyper.res.js +152 -0
- package/lib/commonjs/hooks/useHyper.res.js.map +1 -0
- package/lib/commonjs/index.js +26 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.gen.js +6 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.gen.js.map +1 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.res +55 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.res.js +14 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.res.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/shims/Js.shim.js +2 -0
- package/lib/commonjs/shims/Js.shim.js.map +1 -0
- package/lib/commonjs/specs/ApplePayButtonNativeComponent.ts +11 -0
- package/lib/commonjs/specs/GooglePayButtonNativeComponent.android.js +10 -0
- package/lib/commonjs/specs/GooglePayButtonNativeComponent.android.js.map +1 -0
- package/lib/commonjs/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkNative.js +9 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkNative.js.map +1 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkReactNative.js +9 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkReactNative.js.map +1 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.gen.js +2 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.gen.js.map +1 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.res +215 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.res.js +4 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.res.js.map +1 -0
- package/lib/module/context/HyperProvider.gen.js +11 -0
- package/lib/module/context/HyperProvider.gen.js.map +1 -0
- package/lib/module/context/HyperProvider.res +78 -0
- package/lib/module/context/HyperProvider.res.js +91 -0
- package/lib/module/context/HyperProvider.res.js.map +1 -0
- package/lib/module/hooks/useHyper.gen.js +10 -0
- package/lib/module/hooks/useHyper.gen.js.map +1 -0
- package/lib/module/hooks/useHyper.res +142 -0
- package/lib/module/hooks/useHyper.res.js +142 -0
- package/lib/module/hooks/useHyper.res.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/modules/NativeHyperswitchSdk.gen.js +4 -0
- package/lib/module/modules/NativeHyperswitchSdk.gen.js.map +1 -0
- package/lib/module/modules/NativeHyperswitchSdk.res +55 -0
- package/lib/module/modules/NativeHyperswitchSdk.res.js +9 -0
- package/lib/module/modules/NativeHyperswitchSdk.res.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/shims/Js.shim.js +2 -0
- package/lib/module/shims/Js.shim.js.map +1 -0
- package/lib/module/specs/ApplePayButtonNativeComponent.ts +11 -0
- package/lib/module/specs/GooglePayButtonNativeComponent.android.js +5 -0
- package/lib/module/specs/GooglePayButtonNativeComponent.android.js.map +1 -0
- package/lib/module/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
- package/lib/module/specs/NativeHyperswitchSdkNative.js +5 -0
- package/lib/module/specs/NativeHyperswitchSdkNative.js.map +1 -0
- package/lib/module/specs/NativeHyperswitchSdkReactNative.js +5 -0
- package/lib/module/specs/NativeHyperswitchSdkReactNative.js.map +1 -0
- package/lib/module/types/PaymentSheetConfiguration.gen.js +2 -0
- package/lib/module/types/PaymentSheetConfiguration.gen.js.map +1 -0
- package/lib/module/types/PaymentSheetConfiguration.res +215 -0
- package/lib/module/types/PaymentSheetConfiguration.res.js +4 -0
- package/lib/module/types/PaymentSheetConfiguration.res.js.map +1 -0
- package/lib/typescript/commonjs/babel.config.d.ts +10 -0
- package/lib/typescript/commonjs/babel.config.d.ts.map +1 -0
- package/lib/typescript/commonjs/eslint.config.d.mts +3 -0
- package/lib/typescript/commonjs/eslint.config.d.mts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/scripts/bootstrap.d.ts +2 -0
- package/lib/typescript/commonjs/scripts/bootstrap.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.gen.d.ts +17 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.res.d.ts +20 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.res.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.gen.d.ts +10 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.res.d.ts +95 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.res.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.gen.d.ts +24 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.res.d.ts +2 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.res.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/shims/Js.shim.d.ts +4 -0
- package/lib/typescript/commonjs/src/shims/Js.shim.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/ApplePayButtonNativeComponent.d.ts +10 -0
- package/lib/typescript/commonjs/src/specs/ApplePayButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/GooglePayButtonNativeComponent.android.d.ts +11 -0
- package/lib/typescript/commonjs/src/specs/GooglePayButtonNativeComponent.android.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts +1 -0
- package/lib/typescript/commonjs/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkNative.d.ts +17 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkNative.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkReactNative.d.ts +9 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkReactNative.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.gen.d.ts +149 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.res.d.ts +1 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.res.d.ts.map +1 -0
- package/lib/typescript/module/babel.config.d.ts +10 -0
- package/lib/typescript/module/babel.config.d.ts.map +1 -0
- package/lib/typescript/module/eslint.config.d.mts +3 -0
- package/lib/typescript/module/eslint.config.d.mts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/scripts/bootstrap.d.ts +2 -0
- package/lib/typescript/module/scripts/bootstrap.d.ts.map +1 -0
- package/lib/typescript/module/src/context/HyperProvider.gen.d.ts +17 -0
- package/lib/typescript/module/src/context/HyperProvider.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/context/HyperProvider.res.d.ts +20 -0
- package/lib/typescript/module/src/context/HyperProvider.res.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useHyper.gen.d.ts +10 -0
- package/lib/typescript/module/src/hooks/useHyper.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useHyper.res.d.ts +95 -0
- package/lib/typescript/module/src/hooks/useHyper.res.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.gen.d.ts +24 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.res.d.ts +2 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.res.d.ts.map +1 -0
- package/lib/typescript/module/src/shims/Js.shim.d.ts +4 -0
- package/lib/typescript/module/src/shims/Js.shim.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/ApplePayButtonNativeComponent.d.ts +10 -0
- package/lib/typescript/module/src/specs/ApplePayButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/GooglePayButtonNativeComponent.android.d.ts +11 -0
- package/lib/typescript/module/src/specs/GooglePayButtonNativeComponent.android.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts +1 -0
- package/lib/typescript/module/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkNative.d.ts +17 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkNative.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkReactNative.d.ts +9 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkReactNative.d.ts.map +1 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.gen.d.ts +149 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.res.d.ts +1 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.res.d.ts.map +1 -0
- package/package.json +196 -0
- package/src/context/HyperProvider.gen.tsx +26 -0
- package/src/context/HyperProvider.res +78 -0
- package/src/context/HyperProvider.res.js +112 -0
- package/src/hooks/useHyper.gen.tsx +18 -0
- package/src/hooks/useHyper.res +142 -0
- package/src/hooks/useHyper.res.js +157 -0
- package/src/index.tsx +13 -0
- package/src/modules/NativeHyperswitchSdk.gen.tsx +25 -0
- package/src/modules/NativeHyperswitchSdk.res +55 -0
- package/src/modules/NativeHyperswitchSdk.res.js +10 -0
- package/src/shims/Js.shim.ts +5 -0
- package/src/specs/ApplePayButtonNativeComponent.ts +11 -0
- package/src/specs/GooglePayButtonNativeComponent.android.ts +12 -0
- package/src/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
- package/src/specs/NativeHyperswitchSdkNative.ts +33 -0
- package/src/specs/NativeHyperswitchSdkReactNative.ts +17 -0
- package/src/types/PaymentSheetConfiguration.gen.tsx +202 -0
- package/src/types/PaymentSheetConfiguration.res +215 -0
- package/src/types/PaymentSheetConfiguration.res.js +2 -0
package/android/src/main/java/com/hyperswitchsdkreactnative/HyperswitchSdkReactNativePackage.kt
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package com.hyperswitchsdkreactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import com.facebook.react.uimanager.ViewManager
|
|
9
|
+
import com.hyperswitchsdkreactnative.modules.HyperswitchSdkNativeModule
|
|
10
|
+
import com.hyperswitchsdkreactnative.modules.HyperswitchSdkReactNativeModule
|
|
11
|
+
import com.hyperswitchsdkreactnative.views.GooglePayButtonViewManager
|
|
12
|
+
import java.util.ArrayList
|
|
13
|
+
|
|
14
|
+
class HyperswitchSdkReactNativePackage : BaseReactPackage() {
|
|
15
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
16
|
+
return when (name) {
|
|
17
|
+
HyperswitchSdkReactNativeModule.NAME -> HyperswitchSdkReactNativeModule(reactContext)
|
|
18
|
+
HyperswitchSdkNativeModule.NAME -> HyperswitchSdkNativeModule(reactContext)
|
|
19
|
+
else -> null
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
24
|
+
val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
|
|
25
|
+
viewManagers.add(GooglePayButtonViewManager())
|
|
26
|
+
return viewManagers
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
30
|
+
return ReactModuleInfoProvider {
|
|
31
|
+
arrayOf(HyperswitchSdkReactNativeModule.NAME, HyperswitchSdkNativeModule.NAME).associateWith {
|
|
32
|
+
ReactModuleInfo(it, it, false, false, false, true)
|
|
33
|
+
}.toMutableMap()
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package com.hyperswitchsdkreactnative.activity
|
|
2
|
+
|
|
3
|
+
import android.content.Intent
|
|
4
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
5
|
+
import com.proyecto26.inappbrowser.ChromeTabsDismissedEvent
|
|
6
|
+
import com.proyecto26.inappbrowser.ChromeTabsManagerActivity
|
|
7
|
+
import org.greenrobot.eventbus.EventBus
|
|
8
|
+
|
|
9
|
+
class RedirectActivity : AppCompatActivity() {
|
|
10
|
+
|
|
11
|
+
// Override onResume method to handle redirection logic
|
|
12
|
+
override fun onResume() {
|
|
13
|
+
super.onResume()
|
|
14
|
+
|
|
15
|
+
// Get app link data from intent
|
|
16
|
+
val appLinkData = intent.data
|
|
17
|
+
|
|
18
|
+
// Post ChromeTabsDismissedEvent to EventBus
|
|
19
|
+
EventBus.getDefault().post(
|
|
20
|
+
ChromeTabsDismissedEvent(
|
|
21
|
+
appLinkData?.toString() ?: "chrome tabs activity closed", // Set URL or default message
|
|
22
|
+
"cancel", // Set action as cancel
|
|
23
|
+
false // Set as not from a user gesture
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
// Start ChromeTabsManagerActivity to dismiss the Chrome tab
|
|
28
|
+
startActivity(ChromeTabsManagerActivity.createDismissIntent(applicationContext))
|
|
29
|
+
|
|
30
|
+
// Finish the current activity
|
|
31
|
+
finish()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Override onNewIntent to update the intent when a new intent is received
|
|
35
|
+
override fun onNewIntent(intent: Intent) {
|
|
36
|
+
super.onNewIntent(intent)
|
|
37
|
+
setIntent(intent) // Set the new intent
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
@file:Suppress("DEPRECATION")
|
|
9
|
+
|
|
10
|
+
package com.hyperswitchsdkreactnative.internal
|
|
11
|
+
|
|
12
|
+
import android.content.Context
|
|
13
|
+
import com.facebook.react.ReactHost
|
|
14
|
+
import com.facebook.react.ReactNativeHost
|
|
15
|
+
import com.facebook.react.ReactPackage
|
|
16
|
+
import com.facebook.react.bridge.JSBundleLoader
|
|
17
|
+
import com.facebook.react.bridge.ReactContext
|
|
18
|
+
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
|
19
|
+
import com.facebook.react.common.build.ReactBuildConfig
|
|
20
|
+
import com.facebook.react.defaults.DefaultComponentsRegistry
|
|
21
|
+
import com.facebook.react.defaults.DefaultReactHostDelegate
|
|
22
|
+
import com.facebook.react.defaults.DefaultTurboModuleManagerDelegate
|
|
23
|
+
import com.facebook.react.fabric.ComponentFactory
|
|
24
|
+
import com.facebook.react.runtime.BindingsInstaller
|
|
25
|
+
import com.facebook.react.runtime.JSRuntimeFactory
|
|
26
|
+
import com.facebook.react.runtime.ReactHostImpl
|
|
27
|
+
import com.facebook.react.runtime.cxxreactpackage.CxxReactPackage
|
|
28
|
+
import com.facebook.react.runtime.hermes.HermesInstance
|
|
29
|
+
import java.lang.Exception
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A utility class that allows you to simplify the setup of a [ReactHost] for new apps in Open
|
|
33
|
+
* Source.
|
|
34
|
+
*
|
|
35
|
+
* [ReactHost] is an interface responsible of handling the lifecycle of a React Native app when
|
|
36
|
+
* running in bridgeless mode.
|
|
37
|
+
*/
|
|
38
|
+
internal object DefaultReactHost {
|
|
39
|
+
private var reactHost: ReactHost? = null
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Util function to create a default [ReactHost] to be used in your application. This method is
|
|
43
|
+
* used by the New App template.
|
|
44
|
+
*
|
|
45
|
+
* @param context the Android [Context] to use for creating the [ReactHost]
|
|
46
|
+
* @param packageList the list of [ReactPackage]s to use for creating the [ReactHost]
|
|
47
|
+
* @param jsMainModulePath the path to your app's main module on Metro. Usually `index` or
|
|
48
|
+
* `index.<platform>`
|
|
49
|
+
* @param jsBundleAssetPath the path to the JS bundle relative to the assets directory. Will be
|
|
50
|
+
* composed in a `asset://...` URL
|
|
51
|
+
* @param jsBundleFilePath the path to the JS bundle on the filesystem. Will be composed in a
|
|
52
|
+
* `file://...` URL
|
|
53
|
+
* @param jsRuntimeFactory the JS engine to use for executing [ReactHost], default to Hermes.
|
|
54
|
+
* @param useDevSupport whether to enable dev support, default to ReactBuildConfig.DEBUG.
|
|
55
|
+
* @param cxxReactPackageProviders a list of cxxreactpackage providers (to register c++ turbo
|
|
56
|
+
* modules)
|
|
57
|
+
*
|
|
58
|
+
* TODO(T186951312): Should this be @UnstableReactNativeAPI?
|
|
59
|
+
*/
|
|
60
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
61
|
+
@JvmStatic
|
|
62
|
+
fun getDefaultReactHost(
|
|
63
|
+
context: Context,
|
|
64
|
+
packageList: List<ReactPackage>,
|
|
65
|
+
jsMainModulePath: String = "index",
|
|
66
|
+
jsBundleAssetPath: String = "index",
|
|
67
|
+
jsBundleFilePath: String? = null,
|
|
68
|
+
jsRuntimeFactory: JSRuntimeFactory? = null,
|
|
69
|
+
useDevSupport: Boolean = ReactBuildConfig.DEBUG,
|
|
70
|
+
cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList(),
|
|
71
|
+
): ReactHost =
|
|
72
|
+
getDefaultReactHost(
|
|
73
|
+
context,
|
|
74
|
+
packageList,
|
|
75
|
+
jsMainModulePath,
|
|
76
|
+
jsBundleAssetPath,
|
|
77
|
+
jsBundleFilePath,
|
|
78
|
+
jsRuntimeFactory,
|
|
79
|
+
useDevSupport,
|
|
80
|
+
cxxReactPackageProviders,
|
|
81
|
+
{ throw it },
|
|
82
|
+
null,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Util function to create a default [ReactHost] to be used in your application. This method is
|
|
87
|
+
* used by the New App template.
|
|
88
|
+
*
|
|
89
|
+
* @param context the Android [Context] to use for creating the [ReactHost]
|
|
90
|
+
* @param packageList the list of [ReactPackage]s to use for creating the [ReactHost]
|
|
91
|
+
* @param jsMainModulePath the path to your app's main module on Metro. Usually `index` or
|
|
92
|
+
* `index.<platform>`
|
|
93
|
+
* @param jsBundleAssetPath the path to the JS bundle relative to the assets directory. Will be
|
|
94
|
+
* composed in a `asset://...` URL
|
|
95
|
+
* @param jsBundleFilePath the path to the JS bundle on the filesystem. Will be composed in a
|
|
96
|
+
* `file://...` URL
|
|
97
|
+
* @param jsRuntimeFactory the JS engine to use for executing [ReactHost], default to Hermes.
|
|
98
|
+
* @param useDevSupport whether to enable dev support, default to ReactBuildConfig.DEBUG.
|
|
99
|
+
* @param cxxReactPackageProviders a list of cxxreactpackage providers (to register c++ turbo
|
|
100
|
+
* modules)
|
|
101
|
+
* @param exceptionHandler Callback that can be used by React Native host applications to react to
|
|
102
|
+
* exceptions thrown by the internals of React Native.
|
|
103
|
+
* @param bindingsInstaller that can be used for installing bindings.
|
|
104
|
+
*
|
|
105
|
+
* TODO(T186951312): Should this be @UnstableReactNativeAPI?
|
|
106
|
+
*/
|
|
107
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
108
|
+
@JvmStatic
|
|
109
|
+
fun getDefaultReactHost(
|
|
110
|
+
context: Context,
|
|
111
|
+
packageList: List<ReactPackage>,
|
|
112
|
+
jsMainModulePath: String = "index",
|
|
113
|
+
jsBundleAssetPath: String = "index",
|
|
114
|
+
jsBundleFilePath: String? = null,
|
|
115
|
+
jsRuntimeFactory: JSRuntimeFactory? = null,
|
|
116
|
+
useDevSupport: Boolean = ReactBuildConfig.DEBUG,
|
|
117
|
+
cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList(),
|
|
118
|
+
exceptionHandler: (Exception) -> Unit = { throw it },
|
|
119
|
+
bindingsInstaller: BindingsInstaller? = null,
|
|
120
|
+
): ReactHost {
|
|
121
|
+
if (reactHost == null) {
|
|
122
|
+
|
|
123
|
+
val bundleLoader =
|
|
124
|
+
if (jsBundleFilePath != null) {
|
|
125
|
+
if (jsBundleFilePath.startsWith("assets://")) {
|
|
126
|
+
JSBundleLoader.createAssetLoader(context, jsBundleFilePath, true)
|
|
127
|
+
} else {
|
|
128
|
+
JSBundleLoader.createFileLoader(jsBundleFilePath)
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
JSBundleLoader.createAssetLoader(context, "assets://$jsBundleAssetPath", true)
|
|
132
|
+
}
|
|
133
|
+
val defaultTmmDelegateBuilder = DefaultTurboModuleManagerDelegate.Builder()
|
|
134
|
+
cxxReactPackageProviders.forEach { defaultTmmDelegateBuilder.addCxxReactPackage(it) }
|
|
135
|
+
val defaultReactHostDelegate =
|
|
136
|
+
DefaultReactHostDelegate(
|
|
137
|
+
jsMainModulePath = jsMainModulePath,
|
|
138
|
+
jsBundleLoader = bundleLoader,
|
|
139
|
+
reactPackages = packageList,
|
|
140
|
+
jsRuntimeFactory = jsRuntimeFactory ?: HermesInstance(),
|
|
141
|
+
bindingsInstaller = bindingsInstaller,
|
|
142
|
+
turboModuleManagerDelegateBuilder = defaultTmmDelegateBuilder,
|
|
143
|
+
exceptionHandler = exceptionHandler,
|
|
144
|
+
)
|
|
145
|
+
val componentFactory = ComponentFactory()
|
|
146
|
+
DefaultComponentsRegistry.register(componentFactory)
|
|
147
|
+
// TODO: T164788699 find alternative of accessing ReactHostImpl for initialising reactHost
|
|
148
|
+
reactHost =
|
|
149
|
+
ReactHostImpl(
|
|
150
|
+
context,
|
|
151
|
+
defaultReactHostDelegate,
|
|
152
|
+
componentFactory,
|
|
153
|
+
true /* allowPackagerServerAccess */,
|
|
154
|
+
useDevSupport,
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
return reactHost as ReactHost
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Util function to create a default [ReactHost] to be used in your application. This method is
|
|
162
|
+
* used by the New App template.
|
|
163
|
+
*
|
|
164
|
+
* @param context the Android [Context] to use for creating the [ReactHost]
|
|
165
|
+
* @param packageList the list of [ReactPackage]s to use for creating the [ReactHost]
|
|
166
|
+
* @param jsMainModulePath the path to your app's main module on Metro. Usually `index` or
|
|
167
|
+
* `index.<platform>`
|
|
168
|
+
* @param jsBundleAssetPath the path to the JS bundle relative to the assets directory. Will be
|
|
169
|
+
* composed in a `asset://...` URL
|
|
170
|
+
* @param jsBundleFilePath the path to the JS bundle on the filesystem. Will be composed in a
|
|
171
|
+
* `file://...` URL
|
|
172
|
+
* @param isHermesEnabled whether to use Hermes as the JS engine, default to true.
|
|
173
|
+
* @param useDevSupport whether to enable dev support, default to ReactBuildConfig.DEBUG.
|
|
174
|
+
* @param cxxReactPackageProviders a list of cxxreactpackage providers (to register c++ turbo
|
|
175
|
+
* modules)
|
|
176
|
+
* @param exceptionHandler Callback that can be used by React Native host applications to react to
|
|
177
|
+
* exceptions thrown by the internals of React Native.
|
|
178
|
+
* @param bindingsInstaller that can be used for installing bindings.
|
|
179
|
+
*/
|
|
180
|
+
@Deprecated(
|
|
181
|
+
message = "Use `getDefaultReactHost` with `jsRuntimeFactory` instead",
|
|
182
|
+
replaceWith =
|
|
183
|
+
ReplaceWith(
|
|
184
|
+
"""
|
|
185
|
+
fun getDefaultReactHost(
|
|
186
|
+
context: Context,
|
|
187
|
+
packageList: List<ReactPackage>,
|
|
188
|
+
jsMainModulePath: String,
|
|
189
|
+
jsBundleAssetPath: String,
|
|
190
|
+
jsBundleFilePath: String?,
|
|
191
|
+
jsRuntimeFactory: JSRuntimeFactory?,
|
|
192
|
+
useDevSupport: Boolean,
|
|
193
|
+
cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage>,
|
|
194
|
+
exceptionHandler: (Exception) -> Unit,
|
|
195
|
+
bindingsInstaller: BindingsInstaller?,
|
|
196
|
+
): ReactHost
|
|
197
|
+
"""),
|
|
198
|
+
)
|
|
199
|
+
@JvmStatic
|
|
200
|
+
fun getDefaultReactHost(
|
|
201
|
+
context: Context,
|
|
202
|
+
packageList: List<ReactPackage>,
|
|
203
|
+
jsMainModulePath: String = "index",
|
|
204
|
+
jsBundleAssetPath: String = "index",
|
|
205
|
+
jsBundleFilePath: String? = null,
|
|
206
|
+
isHermesEnabled: Boolean = true,
|
|
207
|
+
useDevSupport: Boolean = ReactBuildConfig.DEBUG,
|
|
208
|
+
cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList(),
|
|
209
|
+
exceptionHandler: (Exception) -> Unit = { throw it },
|
|
210
|
+
bindingsInstaller: BindingsInstaller? = null,
|
|
211
|
+
): ReactHost =
|
|
212
|
+
getDefaultReactHost(
|
|
213
|
+
context,
|
|
214
|
+
packageList,
|
|
215
|
+
jsMainModulePath,
|
|
216
|
+
jsBundleAssetPath,
|
|
217
|
+
jsBundleFilePath,
|
|
218
|
+
HermesInstance(),
|
|
219
|
+
useDevSupport,
|
|
220
|
+
cxxReactPackageProviders,
|
|
221
|
+
exceptionHandler,
|
|
222
|
+
bindingsInstaller,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Util function to create a default [ReactHost] to be used in your application. This method is
|
|
227
|
+
* used by the New App template.
|
|
228
|
+
*
|
|
229
|
+
* @param context the Android [Context] to use for creating the [ReactHost]
|
|
230
|
+
* @param packageList the list of [ReactPackage]s to use for creating the [ReactHost]
|
|
231
|
+
* @param jsMainModulePath the path to your app's main module on Metro. Usually `index` or
|
|
232
|
+
* `index.<platform>`
|
|
233
|
+
* @param jsBundleAssetPath the path to the JS bundle relative to the assets directory. Will be
|
|
234
|
+
* composed in a `asset://...` URL
|
|
235
|
+
* @param jsBundleFilePath the path to the JS bundle on the filesystem. Will be composed in a
|
|
236
|
+
* `file://...` URL
|
|
237
|
+
* @param isHermesEnabled whether to use Hermes as the JS engine, default to true.
|
|
238
|
+
* @param useDevSupport whether to enable dev support, default to ReactBuildConfig.DEBUG.
|
|
239
|
+
* @param cxxReactPackageProviders a list of cxxreactpackage providers (to register c++ turbo
|
|
240
|
+
* modules)
|
|
241
|
+
*/
|
|
242
|
+
@Deprecated(
|
|
243
|
+
message = "Use `getDefaultReactHost` with `jsRuntimeFactory` instead",
|
|
244
|
+
replaceWith =
|
|
245
|
+
ReplaceWith(
|
|
246
|
+
"""
|
|
247
|
+
fun getDefaultReactHost(
|
|
248
|
+
context: Context,
|
|
249
|
+
packageList: List<ReactPackage>,
|
|
250
|
+
jsMainModulePath: String,
|
|
251
|
+
jsBundleAssetPath: String,
|
|
252
|
+
jsBundleFilePath: String?,
|
|
253
|
+
jsRuntimeFactory: JSRuntimeFactory?,
|
|
254
|
+
useDevSupport: Boolean,
|
|
255
|
+
cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage>,
|
|
256
|
+
): ReactHost
|
|
257
|
+
"""),
|
|
258
|
+
)
|
|
259
|
+
@JvmStatic
|
|
260
|
+
fun getDefaultReactHost(
|
|
261
|
+
context: Context,
|
|
262
|
+
packageList: List<ReactPackage>,
|
|
263
|
+
jsMainModulePath: String = "index",
|
|
264
|
+
jsBundleAssetPath: String = "index",
|
|
265
|
+
jsBundleFilePath: String? = null,
|
|
266
|
+
isHermesEnabled: Boolean = true,
|
|
267
|
+
useDevSupport: Boolean = ReactBuildConfig.DEBUG,
|
|
268
|
+
cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList(),
|
|
269
|
+
): ReactHost =
|
|
270
|
+
getDefaultReactHost(
|
|
271
|
+
context,
|
|
272
|
+
packageList,
|
|
273
|
+
jsMainModulePath,
|
|
274
|
+
jsBundleAssetPath,
|
|
275
|
+
jsBundleFilePath,
|
|
276
|
+
HermesInstance(),
|
|
277
|
+
useDevSupport,
|
|
278
|
+
cxxReactPackageProviders,
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Util function to create a default [ReactHost] to be used in your application. This method is
|
|
283
|
+
* used by the New App template.
|
|
284
|
+
*
|
|
285
|
+
* This method takes in input a [ReactNativeHost] (bridge-mode) and uses its configuration to
|
|
286
|
+
* create an equivalent [ReactHost] (bridgeless-mode).
|
|
287
|
+
*
|
|
288
|
+
* @param context the Android [Context] to use for creating the [ReactHost]
|
|
289
|
+
* @param reactNativeHost the [ReactNativeHost] to use for creating the [ReactHost]
|
|
290
|
+
*
|
|
291
|
+
* TODO(T186951312): Should this be @UnstableReactNativeAPI? It's not, to maintain consistency
|
|
292
|
+
* with above getDefaultReactHost.
|
|
293
|
+
*/
|
|
294
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
295
|
+
@JvmStatic
|
|
296
|
+
fun getDefaultReactHost(
|
|
297
|
+
context: Context,
|
|
298
|
+
reactNativeHost: ReactNativeHost,
|
|
299
|
+
jsRuntimeFactory: JSRuntimeFactory? = null,
|
|
300
|
+
): ReactHost {
|
|
301
|
+
require(reactNativeHost is DefaultReactNativeHost) {
|
|
302
|
+
"You can call getDefaultReactHost only with instances of DefaultReactNativeHost"
|
|
303
|
+
}
|
|
304
|
+
return reactNativeHost.toReactHost(context, jsRuntimeFactory)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Cleanup function for brownfield scenarios where you want to remove the references kept by
|
|
309
|
+
* reactHost after destroying the RN instance.
|
|
310
|
+
*/
|
|
311
|
+
internal fun invalidate() {
|
|
312
|
+
reactHost = null
|
|
313
|
+
}
|
|
314
|
+
}
|
package/android/src/main/java/com/hyperswitchsdkreactnative/internal/DefaultReactNativeHost.kt
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
@file:Suppress("DEPRECATION")
|
|
9
|
+
|
|
10
|
+
package com.hyperswitchsdkreactnative.internal
|
|
11
|
+
|
|
12
|
+
import android.app.Application
|
|
13
|
+
import android.content.Context
|
|
14
|
+
import com.facebook.react.ReactHost
|
|
15
|
+
import com.facebook.react.ReactNativeHost
|
|
16
|
+
import com.facebook.react.ReactPackageTurboModuleManagerDelegate
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
18
|
+
import com.facebook.react.bridge.UIManagerProvider
|
|
19
|
+
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
|
20
|
+
import com.facebook.react.defaults.DefaultComponentsRegistry
|
|
21
|
+
import com.facebook.react.defaults.DefaultTurboModuleManagerDelegate
|
|
22
|
+
import com.facebook.react.fabric.ComponentFactory
|
|
23
|
+
import com.facebook.react.fabric.FabricUIManagerProviderImpl
|
|
24
|
+
// import com.facebook.react.fabric.ReactNativeConfig
|
|
25
|
+
import com.facebook.react.runtime.JSRuntimeFactory
|
|
26
|
+
import com.facebook.react.runtime.hermes.HermesInstance
|
|
27
|
+
import com.facebook.react.uimanager.ViewManagerRegistry
|
|
28
|
+
import com.facebook.react.uimanager.ViewManagerResolver
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A utility class that allows you to simplify the setup of a [ReactNativeHost] for new apps in Open
|
|
32
|
+
* Source.
|
|
33
|
+
*
|
|
34
|
+
* Specifically, for apps that are using the New Architecture, this Default class takes care of
|
|
35
|
+
* providing the default TurboModuleManagerDelegateBuilder and the default JSIModulePackage,
|
|
36
|
+
* provided the name of the dynamic library to load.
|
|
37
|
+
*/
|
|
38
|
+
internal abstract class DefaultReactNativeHost
|
|
39
|
+
protected constructor(
|
|
40
|
+
application: Application,
|
|
41
|
+
) : ReactNativeHost(application) {
|
|
42
|
+
|
|
43
|
+
override fun getReactPackageTurboModuleManagerDelegateBuilder():
|
|
44
|
+
ReactPackageTurboModuleManagerDelegate.Builder? =
|
|
45
|
+
if (isNewArchEnabled) {
|
|
46
|
+
DefaultTurboModuleManagerDelegate.Builder()
|
|
47
|
+
} else {
|
|
48
|
+
error(
|
|
49
|
+
"Overriding isNewArchEnabled to false is not supported anymore since React Native 0.82. Please check your MainApplication.kt file, and remove the override for `isNewArchEnabled`.")
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override fun getUIManagerProvider(): UIManagerProvider? =
|
|
53
|
+
if (isNewArchEnabled) {
|
|
54
|
+
UIManagerProvider { reactApplicationContext: ReactApplicationContext ->
|
|
55
|
+
val componentFactory = ComponentFactory()
|
|
56
|
+
DefaultComponentsRegistry.register(componentFactory)
|
|
57
|
+
|
|
58
|
+
val viewManagerRegistry =
|
|
59
|
+
if (lazyViewManagersEnabled) {
|
|
60
|
+
ViewManagerRegistry(
|
|
61
|
+
object : ViewManagerResolver {
|
|
62
|
+
override fun getViewManager(viewManagerName: String) =
|
|
63
|
+
reactInstanceManager.createViewManager(viewManagerName)
|
|
64
|
+
|
|
65
|
+
override fun getViewManagerNames() = reactInstanceManager.viewManagerNames
|
|
66
|
+
})
|
|
67
|
+
} else {
|
|
68
|
+
ViewManagerRegistry(
|
|
69
|
+
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
FabricUIManagerProviderImpl(
|
|
73
|
+
componentFactory, viewManagerRegistry)
|
|
74
|
+
.createUIManager(reactApplicationContext)
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
error(
|
|
78
|
+
"Overriding isNewArchEnabled to false is not supported anymore since React Native 0.82. Please check your MainApplication.kt file, and remove the override for `isNewArchEnabled`.")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
override fun clear() {
|
|
82
|
+
super.clear()
|
|
83
|
+
DefaultReactHost.invalidate()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Returns whether the user wants to use the New Architecture or not.
|
|
88
|
+
*
|
|
89
|
+
* If true, we will load the default JSI Module Package and TurboModuleManagerDelegate needed to
|
|
90
|
+
* enable the New Architecture
|
|
91
|
+
*
|
|
92
|
+
* If false, the app will not attempt to load the New Architecture modules.
|
|
93
|
+
*/
|
|
94
|
+
protected open val isNewArchEnabled: Boolean
|
|
95
|
+
get() = true
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Returns whether the user wants to use Hermes.
|
|
99
|
+
*
|
|
100
|
+
* If true, the app will load the Hermes engine, and fail if not found. If false, the app will
|
|
101
|
+
* load the JSC engine, and fail if not found.
|
|
102
|
+
*/
|
|
103
|
+
@Deprecated(
|
|
104
|
+
"Setting isHermesEnabled inside `ReactNativeHost` is deprecated and this field will be ignored. If this field is set to true, you can safely remove it. If this field is set to false, please follow the setup on https://github.com/react-native-community/javascriptcore to continue using JSC",
|
|
105
|
+
ReplaceWith(""),
|
|
106
|
+
)
|
|
107
|
+
protected open val isHermesEnabled: Boolean
|
|
108
|
+
get() = true
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Converts this [ReactNativeHost] (bridge-mode) to a [ReactHost] (bridgeless-mode).
|
|
112
|
+
*
|
|
113
|
+
* @param context the Android [Context] to use for creating the [ReactHost]
|
|
114
|
+
*/
|
|
115
|
+
@UnstableReactNativeAPI
|
|
116
|
+
internal fun toReactHost(
|
|
117
|
+
context: Context,
|
|
118
|
+
jsRuntimeFactory: JSRuntimeFactory? = null,
|
|
119
|
+
): ReactHost {
|
|
120
|
+
val concreteJSRuntimeFactory = jsRuntimeFactory ?: HermesInstance()
|
|
121
|
+
return DefaultReactHost.getDefaultReactHost(
|
|
122
|
+
context,
|
|
123
|
+
packages,
|
|
124
|
+
jsMainModuleName,
|
|
125
|
+
bundleAssetName ?: "index",
|
|
126
|
+
jsBundleFile,
|
|
127
|
+
concreteJSRuntimeFactory,
|
|
128
|
+
useDeveloperSupport,
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
}
|