@hot-updater/react-native 0.4.1-2 → 0.4.1-4
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/dist/index.js +10 -1419
- package/dist/index.mjs +9 -1418
- package/package.json +4 -4
- package/src/wrap.tsx +10 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/react-native",
|
|
3
|
-
"version": "0.4.1-
|
|
3
|
+
"version": "0.4.1-4",
|
|
4
4
|
"description": "React Native OTA solution for self-hosted",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
"del-cli": "^6.0.0",
|
|
73
73
|
"react": "18.3.1",
|
|
74
74
|
"react-native": "0.76.2",
|
|
75
|
-
"react-native-builder-bob": "^0.33.1"
|
|
76
|
-
"@hot-updater/js": "0.4.1-2"
|
|
75
|
+
"react-native-builder-bob": "^0.33.1"
|
|
77
76
|
},
|
|
78
77
|
"dependencies": {
|
|
79
|
-
"@hot-updater/
|
|
78
|
+
"@hot-updater/js": "0.4.1-4",
|
|
79
|
+
"@hot-updater/core": "0.4.1-4"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "rslib build",
|
package/src/wrap.tsx
CHANGED
|
@@ -86,8 +86,9 @@ export function wrap<P>(
|
|
|
86
86
|
): (WrappedComponent: React.ComponentType) => React.ComponentType<P> {
|
|
87
87
|
return (WrappedComponent) => {
|
|
88
88
|
const HotUpdaterHOC: React.FC<P> = () => {
|
|
89
|
-
const { progress
|
|
90
|
-
const [
|
|
89
|
+
const { progress } = useHotUpdaterStore();
|
|
90
|
+
const [isCheckUpdateCompleted, setIsCheckUpdateCompleted] =
|
|
91
|
+
useState(false);
|
|
91
92
|
|
|
92
93
|
useEffect(() => {
|
|
93
94
|
config.onProgress?.(progress);
|
|
@@ -99,18 +100,18 @@ export function wrap<P>(
|
|
|
99
100
|
const updateInfo = await checkUpdate(config);
|
|
100
101
|
if (!updateInfo) {
|
|
101
102
|
config.onCheckUpdateCompleted?.({ isBundleUpdated: false });
|
|
103
|
+
setIsCheckUpdateCompleted(true);
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
104
|
-
setIsUpdating(true);
|
|
105
106
|
|
|
106
107
|
const isSuccess = await installUpdate(updateInfo);
|
|
107
108
|
config.onCheckUpdateCompleted?.({ isBundleUpdated: isSuccess });
|
|
108
|
-
|
|
109
|
+
setIsCheckUpdateCompleted(true);
|
|
109
110
|
} catch (error) {
|
|
110
111
|
if (error instanceof HotUpdaterError) {
|
|
111
112
|
config.onError?.(error);
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
+
setIsCheckUpdateCompleted(true);
|
|
114
115
|
throw error;
|
|
115
116
|
}
|
|
116
117
|
};
|
|
@@ -118,7 +119,10 @@ export function wrap<P>(
|
|
|
118
119
|
initHotUpdater();
|
|
119
120
|
}, [config.source, config.requestHeaders]);
|
|
120
121
|
|
|
121
|
-
if (
|
|
122
|
+
if (
|
|
123
|
+
config.fallbackComponent &&
|
|
124
|
+
(!isCheckUpdateCompleted || progress > 0)
|
|
125
|
+
) {
|
|
122
126
|
const Fallback = config.fallbackComponent;
|
|
123
127
|
return <Fallback progress={progress} />;
|
|
124
128
|
}
|