@hot-updater/react-native 1.0.7 → 1.0.8
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/src/main/java/com/hotupdater/ContentAppearedLog.kt +31 -0
- package/android/src/newarch/ReactIntegrationManager.kt +27 -0
- package/lib/commonjs/sdkVersion.js +1 -1
- package/lib/module/sdkVersion.js +1 -1
- package/lib/typescript/commonjs/sdkVersion.d.ts +1 -1
- package/lib/typescript/module/sdkVersion.d.ts +1 -1
- package/package.json +4 -4
- package/src/sdkVersion.ts +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.hotupdater
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.view.View
|
|
5
|
+
import android.view.ViewGroup
|
|
6
|
+
import com.facebook.react.ReactRootView
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A New Architecture reload restarts each surface in its existing view, and a
|
|
10
|
+
* view logs CONTENT_APPEARED only for its first content (the old architecture
|
|
11
|
+
* asks for it again when it runs the app). Asks every React root view
|
|
12
|
+
* of the activity to log it again, so the reloaded bundle's first content
|
|
13
|
+
* completes its launch, as a cold start does. Otherwise the next process rolls
|
|
14
|
+
* the working bundle back as an unfinished launch.
|
|
15
|
+
*/
|
|
16
|
+
internal object ContentAppearedLog {
|
|
17
|
+
fun rearm(activity: Activity?) {
|
|
18
|
+
activity?.window?.decorView?.let(::rearm)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private fun rearm(view: View) {
|
|
22
|
+
if (view is ReactRootView) {
|
|
23
|
+
view.setShouldLogContentAppeared(true)
|
|
24
|
+
}
|
|
25
|
+
if (view is ViewGroup) {
|
|
26
|
+
for (index in 0 until view.childCount) {
|
|
27
|
+
rearm(view.getChildAt(index))
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.hotupdater
|
|
2
2
|
|
|
3
|
+
import android.app.Activity
|
|
3
4
|
import android.content.Context
|
|
4
5
|
import android.util.Log
|
|
5
6
|
import com.facebook.react.ReactApplication
|
|
@@ -7,6 +8,7 @@ import com.facebook.react.ReactHost
|
|
|
7
8
|
import com.facebook.react.ReactInstanceEventListener
|
|
8
9
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
10
|
import com.facebook.react.bridge.ReactContext
|
|
11
|
+
import com.facebook.react.bridge.UiThreadUtil
|
|
10
12
|
import com.facebook.react.common.LifecycleState
|
|
11
13
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
12
14
|
import kotlin.coroutines.resume
|
|
@@ -67,12 +69,37 @@ class ReactIntegrationManager(
|
|
|
67
69
|
if (reactHost.lifecycleState != LifecycleState.RESUMED && activity != null) {
|
|
68
70
|
reactHost.onHostResume(activity)
|
|
69
71
|
}
|
|
72
|
+
rearmContentAppearedAfterReload(reactHost, activity)
|
|
70
73
|
reactHost.reload("Requested by HotUpdater")
|
|
71
74
|
} catch (e: Exception) {
|
|
72
75
|
Log.d("HotUpdater", "Failed to reload with ReactHost: ${e.message}")
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Lets the reloaded bundle log its first content (see [ContentAppearedLog]).
|
|
81
|
+
*
|
|
82
|
+
* The views are re-armed once the new instance exists: by then reload has
|
|
83
|
+
* stopped and cleared the old surfaces, so the old bundle cannot complete the
|
|
84
|
+
* new bundle's launch, and the new bundle has not mounted anything yet.
|
|
85
|
+
*/
|
|
86
|
+
private fun rearmContentAppearedAfterReload(
|
|
87
|
+
reactHost: ReactHost,
|
|
88
|
+
activity: Activity?,
|
|
89
|
+
) {
|
|
90
|
+
val listener =
|
|
91
|
+
object : ReactInstanceEventListener {
|
|
92
|
+
override fun onReactContextInitialized(context: ReactContext) {
|
|
93
|
+
reactHost.removeReactInstanceEventListener(this)
|
|
94
|
+
val rearm = { ContentAppearedLog.rearm(context.currentActivity ?: activity) }
|
|
95
|
+
// ReactHostImpl calls this on the UI thread, before it restarts
|
|
96
|
+
// the surfaces. Another host may not.
|
|
97
|
+
if (UiThreadUtil.isOnUiThread()) rearm() else UiThreadUtil.runOnUiThread(rearm)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
reactHost.addReactInstanceEventListener(listener)
|
|
101
|
+
}
|
|
102
|
+
|
|
76
103
|
private fun getReactApplication(): ReactApplication? {
|
|
77
104
|
if (context is ReactApplicationContext) {
|
|
78
105
|
val activity = context.currentActivity
|
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.HOT_UPDATER_SDK_VERSION = void 0;
|
|
7
|
-
const HOT_UPDATER_SDK_VERSION = exports.HOT_UPDATER_SDK_VERSION = "1.0.
|
|
7
|
+
const HOT_UPDATER_SDK_VERSION = exports.HOT_UPDATER_SDK_VERSION = "1.0.8";
|
|
8
8
|
//# sourceMappingURL=sdkVersion.js.map
|
package/lib/module/sdkVersion.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const HOT_UPDATER_SDK_VERSION = "1.0.
|
|
1
|
+
export declare const HOT_UPDATER_SDK_VERSION = "1.0.8";
|
|
2
2
|
//# sourceMappingURL=sdkVersion.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const HOT_UPDATER_SDK_VERSION = "1.0.
|
|
1
|
+
export declare const HOT_UPDATER_SDK_VERSION = "1.0.8";
|
|
2
2
|
//# sourceMappingURL=sdkVersion.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/react-native",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "React Native OTA solution for self-hosted",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -124,9 +124,9 @@
|
|
|
124
124
|
},
|
|
125
125
|
"dependencies": {
|
|
126
126
|
"use-sync-external-store": "1.5.0",
|
|
127
|
-
"@hot-updater/
|
|
128
|
-
"@hot-updater/
|
|
129
|
-
"@hot-updater/plugin-
|
|
127
|
+
"@hot-updater/plugin-insights": "1.0.8",
|
|
128
|
+
"@hot-updater/protocol": "1.0.8",
|
|
129
|
+
"@hot-updater/plugin-remote-config": "1.0.8"
|
|
130
130
|
},
|
|
131
131
|
"scripts": {
|
|
132
132
|
"build": "node ./scripts/sync-sdk-version.mjs run -- bob build",
|
package/src/sdkVersion.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const HOT_UPDATER_SDK_VERSION = "1.0.
|
|
1
|
+
export const HOT_UPDATER_SDK_VERSION = "1.0.8";
|