expo-dev-menu-interface 1.8.0 → 1.8.2
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/android/build.gradle +2 -2
- package/android/src/main/java/expo/interfaces/devmenu/DevMenuDelegateInterface.kt +2 -3
- package/android/src/main/java/expo/interfaces/devmenu/DevMenuManagerInterface.kt +3 -4
- package/android/src/main/java/expo/interfaces/devmenu/ReactHostWrapper.kt +120 -0
- package/package.json +2 -2
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'host.exp.exponent'
|
|
4
|
-
version = '1.8.
|
|
4
|
+
version = '1.8.2'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -13,7 +13,7 @@ android {
|
|
|
13
13
|
namespace "expo.interfaces.devmenu"
|
|
14
14
|
defaultConfig {
|
|
15
15
|
versionCode 6
|
|
16
|
-
versionName '1.8.
|
|
16
|
+
versionName '1.8.2'
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package expo.interfaces.devmenu
|
|
2
2
|
|
|
3
3
|
import android.os.Bundle
|
|
4
|
-
import com.facebook.react.ReactInstanceManager
|
|
5
4
|
|
|
6
5
|
interface DevMenuDelegateInterface {
|
|
7
6
|
/**
|
|
@@ -10,9 +9,9 @@ interface DevMenuDelegateInterface {
|
|
|
10
9
|
fun appInfo(): Bundle?
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
|
-
* Returns a
|
|
12
|
+
* Returns a [ReactHostWrapper] ot the currently shown app. It is a context of what the dev menu displays.
|
|
14
13
|
*/
|
|
15
|
-
fun
|
|
14
|
+
fun reactHost(): ReactHostWrapper
|
|
16
15
|
|
|
17
16
|
fun supportsDevelopment(): Boolean {
|
|
18
17
|
return true
|
|
@@ -4,7 +4,6 @@ import android.app.Activity
|
|
|
4
4
|
import android.os.Bundle
|
|
5
5
|
import android.view.KeyEvent
|
|
6
6
|
import android.view.MotionEvent
|
|
7
|
-
import com.facebook.react.ReactNativeHost
|
|
8
7
|
import com.facebook.react.bridge.ReadableMap
|
|
9
8
|
import expo.interfaces.devmenu.items.DevMenuDataSourceItem
|
|
10
9
|
import kotlinx.coroutines.CoroutineScope
|
|
@@ -48,9 +47,9 @@ interface DevMenuManagerInterface {
|
|
|
48
47
|
fun setDelegate(newDelegate: DevMenuDelegateInterface)
|
|
49
48
|
|
|
50
49
|
/**
|
|
51
|
-
* Initializes the dev menu manager to work with react
|
|
50
|
+
* Initializes the dev menu manager to work with react host.
|
|
52
51
|
*/
|
|
53
|
-
fun
|
|
52
|
+
fun initializeWithReactHost(reactHost: ReactHostWrapper)
|
|
54
53
|
|
|
55
54
|
/**
|
|
56
55
|
* Finds and dispatches action with provided [actionId].
|
|
@@ -77,7 +76,7 @@ interface DevMenuManagerInterface {
|
|
|
77
76
|
/**
|
|
78
77
|
* @return the dev menu application host.
|
|
79
78
|
*/
|
|
80
|
-
fun getMenuHost():
|
|
79
|
+
fun getMenuHost(): ReactHostWrapper
|
|
81
80
|
|
|
82
81
|
/**
|
|
83
82
|
* Synchronizes [ReactInstanceManager] from delegate with one saved in [DevMenuManger].
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
@file:Suppress("DEPRECATION")
|
|
2
|
+
|
|
3
|
+
package expo.interfaces.devmenu
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.JSEngineResolutionAlgorithm
|
|
6
|
+
import com.facebook.react.ReactHost
|
|
7
|
+
import com.facebook.react.ReactInstanceEventListener
|
|
8
|
+
import com.facebook.react.ReactNativeHost
|
|
9
|
+
import com.facebook.react.bridge.ReactContext
|
|
10
|
+
import com.facebook.react.common.LifecycleState
|
|
11
|
+
import com.facebook.react.config.ReactFeatureFlags
|
|
12
|
+
import com.facebook.react.devsupport.interfaces.DevSupportManager
|
|
13
|
+
import com.facebook.react.runtime.ReactHostImpl
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An abstract wrapper to host [ReactNativeHost] and [ReactHost],
|
|
17
|
+
* so that call-sites do not have to handle the difference between legacy bridge and bridgeless mode.
|
|
18
|
+
*/
|
|
19
|
+
class ReactHostWrapper(reactNativeHost: ReactNativeHost, reactHost: ReactHost?) {
|
|
20
|
+
lateinit var reactNativeHost: ReactNativeHost
|
|
21
|
+
lateinit var reactHost: ReactHost
|
|
22
|
+
|
|
23
|
+
init {
|
|
24
|
+
if (ReactFeatureFlags.enableBridgelessArchitecture) {
|
|
25
|
+
this.reactHost = requireNotNull(reactHost)
|
|
26
|
+
} else {
|
|
27
|
+
this.reactNativeHost = reactNativeHost
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override fun hashCode(): Int {
|
|
32
|
+
return if (isBridgelessMode) {
|
|
33
|
+
reactHost.hashCode()
|
|
34
|
+
} else {
|
|
35
|
+
reactNativeHost.hashCode()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
val currentReactContext: ReactContext?
|
|
40
|
+
get() {
|
|
41
|
+
return if (isBridgelessMode) {
|
|
42
|
+
reactHost.currentReactContext
|
|
43
|
+
} else {
|
|
44
|
+
reactNativeHost.reactInstanceManager.currentReactContext
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
val lifecycleState: LifecycleState
|
|
49
|
+
get() {
|
|
50
|
+
return if (isBridgelessMode) {
|
|
51
|
+
reactHost.lifecycleState
|
|
52
|
+
} else {
|
|
53
|
+
reactNativeHost.reactInstanceManager.lifecycleState
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
val hasInstance: Boolean
|
|
58
|
+
get() {
|
|
59
|
+
if (isBridgelessMode) {
|
|
60
|
+
return currentReactContext?.hasActiveReactInstance() ?: false
|
|
61
|
+
}
|
|
62
|
+
return reactNativeHost.hasInstance() && currentReactContext?.hasActiveReactInstance() ?: false
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
val devSupportManager: DevSupportManager?
|
|
66
|
+
get() {
|
|
67
|
+
return if (isBridgelessMode) {
|
|
68
|
+
reactHost.devSupportManager
|
|
69
|
+
} else {
|
|
70
|
+
reactNativeHost.reactInstanceManager.devSupportManager
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
val isBridgelessMode = ReactFeatureFlags.enableBridgelessArchitecture
|
|
75
|
+
|
|
76
|
+
val jsExecutorName: String
|
|
77
|
+
get() {
|
|
78
|
+
if (isBridgelessMode) {
|
|
79
|
+
return if (reactHost.jsEngineResolutionAlgorithm == JSEngineResolutionAlgorithm.JSC) {
|
|
80
|
+
"JSC"
|
|
81
|
+
} else {
|
|
82
|
+
"Hermes"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return reactNativeHost.reactInstanceManager.jsExecutorName
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fun addReactInstanceEventListener(listener: ReactInstanceEventListener) {
|
|
90
|
+
if (isBridgelessMode) {
|
|
91
|
+
(reactHost as ReactHostImpl).addReactInstanceEventListener(listener)
|
|
92
|
+
} else {
|
|
93
|
+
reactNativeHost.reactInstanceManager.addReactInstanceEventListener(listener)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fun removeReactInstanceEventListener(listener: ReactInstanceEventListener) {
|
|
98
|
+
if (isBridgelessMode) {
|
|
99
|
+
(reactHost as ReactHostImpl).removeReactInstanceEventListener(listener)
|
|
100
|
+
} else {
|
|
101
|
+
reactNativeHost.reactInstanceManager.removeReactInstanceEventListener(listener)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
fun start() {
|
|
106
|
+
if (isBridgelessMode) {
|
|
107
|
+
(reactHost as ReactHostImpl).start()
|
|
108
|
+
} else {
|
|
109
|
+
reactNativeHost.reactInstanceManager.createReactContextInBackground()
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
fun destroy(reason: String = "DevLauncher reloading app") {
|
|
114
|
+
if (isBridgelessMode) {
|
|
115
|
+
reactHost.destroy(reason, null)
|
|
116
|
+
} else {
|
|
117
|
+
reactNativeHost.clear()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-dev-menu-interface",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "Interface for expo-dev-menu",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"expo": "*"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "0897aeadb926491a457bcd67d83360956994ee82"
|
|
29
29
|
}
|