@hot-updater/react-native 0.4.1-3 → 0.4.1-5
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 +6 -6
- package/dist/index.mjs +6 -6
- package/package.json +3 -3
- package/src/wrap.tsx +10 -6
package/dist/index.js
CHANGED
|
@@ -1797,8 +1797,8 @@ async function installUpdate(updateInfo) {
|
|
|
1797
1797
|
function wrap(config) {
|
|
1798
1798
|
return (WrappedComponent)=>{
|
|
1799
1799
|
const HotUpdaterHOC = ()=>{
|
|
1800
|
-
const { progress
|
|
1801
|
-
const [
|
|
1800
|
+
const { progress } = useHotUpdaterStore();
|
|
1801
|
+
const [isCheckUpdateCompleted, setIsCheckUpdateCompleted] = (0, react.useState)(false);
|
|
1802
1802
|
(0, react.useEffect)(()=>{
|
|
1803
1803
|
config.onProgress?.(progress);
|
|
1804
1804
|
}, [
|
|
@@ -1812,17 +1812,17 @@ function wrap(config) {
|
|
|
1812
1812
|
config.onCheckUpdateCompleted?.({
|
|
1813
1813
|
isBundleUpdated: false
|
|
1814
1814
|
});
|
|
1815
|
+
setIsCheckUpdateCompleted(true);
|
|
1815
1816
|
return;
|
|
1816
1817
|
}
|
|
1817
|
-
setIsUpdating(true);
|
|
1818
1818
|
const isSuccess = await installUpdate(updateInfo);
|
|
1819
1819
|
config.onCheckUpdateCompleted?.({
|
|
1820
1820
|
isBundleUpdated: isSuccess
|
|
1821
1821
|
});
|
|
1822
|
-
|
|
1822
|
+
setIsCheckUpdateCompleted(true);
|
|
1823
1823
|
} catch (error) {
|
|
1824
1824
|
if (error instanceof HotUpdaterError) config.onError?.(error);
|
|
1825
|
-
|
|
1825
|
+
setIsCheckUpdateCompleted(true);
|
|
1826
1826
|
throw error;
|
|
1827
1827
|
}
|
|
1828
1828
|
};
|
|
@@ -1831,7 +1831,7 @@ function wrap(config) {
|
|
|
1831
1831
|
config.source,
|
|
1832
1832
|
config.requestHeaders
|
|
1833
1833
|
]);
|
|
1834
|
-
if (config.fallbackComponent &&
|
|
1834
|
+
if (config.fallbackComponent && (!isCheckUpdateCompleted || progress > 0 && progress < 1)) {
|
|
1835
1835
|
const Fallback = config.fallbackComponent;
|
|
1836
1836
|
return /*#__PURE__*/ React.createElement(Fallback, {
|
|
1837
1837
|
progress: progress
|
package/dist/index.mjs
CHANGED
|
@@ -1765,8 +1765,8 @@ async function installUpdate(updateInfo) {
|
|
|
1765
1765
|
function wrap(config) {
|
|
1766
1766
|
return (WrappedComponent)=>{
|
|
1767
1767
|
const HotUpdaterHOC = ()=>{
|
|
1768
|
-
const { progress
|
|
1769
|
-
const [
|
|
1768
|
+
const { progress } = useHotUpdaterStore();
|
|
1769
|
+
const [isCheckUpdateCompleted, setIsCheckUpdateCompleted] = (0, react.useState)(false);
|
|
1770
1770
|
(0, react.useEffect)(()=>{
|
|
1771
1771
|
config.onProgress?.(progress);
|
|
1772
1772
|
}, [
|
|
@@ -1780,17 +1780,17 @@ function wrap(config) {
|
|
|
1780
1780
|
config.onCheckUpdateCompleted?.({
|
|
1781
1781
|
isBundleUpdated: false
|
|
1782
1782
|
});
|
|
1783
|
+
setIsCheckUpdateCompleted(true);
|
|
1783
1784
|
return;
|
|
1784
1785
|
}
|
|
1785
|
-
setIsUpdating(true);
|
|
1786
1786
|
const isSuccess = await installUpdate(updateInfo);
|
|
1787
1787
|
config.onCheckUpdateCompleted?.({
|
|
1788
1788
|
isBundleUpdated: isSuccess
|
|
1789
1789
|
});
|
|
1790
|
-
|
|
1790
|
+
setIsCheckUpdateCompleted(true);
|
|
1791
1791
|
} catch (error) {
|
|
1792
1792
|
if (error instanceof HotUpdaterError) config.onError?.(error);
|
|
1793
|
-
|
|
1793
|
+
setIsCheckUpdateCompleted(true);
|
|
1794
1794
|
throw error;
|
|
1795
1795
|
}
|
|
1796
1796
|
};
|
|
@@ -1799,7 +1799,7 @@ function wrap(config) {
|
|
|
1799
1799
|
config.source,
|
|
1800
1800
|
config.requestHeaders
|
|
1801
1801
|
]);
|
|
1802
|
-
if (config.fallbackComponent &&
|
|
1802
|
+
if (config.fallbackComponent && (!isCheckUpdateCompleted || progress > 0 && progress < 1)) {
|
|
1803
1803
|
const Fallback = config.fallbackComponent;
|
|
1804
1804
|
return /*#__PURE__*/ React.createElement(Fallback, {
|
|
1805
1805
|
progress: progress
|
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-5",
|
|
4
4
|
"description": "React Native OTA solution for self-hosted",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"react-native-builder-bob": "^0.33.1"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@hot-updater/js": "0.4.1-
|
|
79
|
-
"@hot-updater/core": "0.4.1-
|
|
78
|
+
"@hot-updater/js": "0.4.1-5",
|
|
79
|
+
"@hot-updater/core": "0.4.1-5"
|
|
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 && progress < 1))
|
|
125
|
+
) {
|
|
122
126
|
const Fallback = config.fallbackComponent;
|
|
123
127
|
return <Fallback progress={progress} />;
|
|
124
128
|
}
|