@hot-updater/react-native 0.6.0 → 0.6.1-rc.0
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 +202 -245
- package/dist/index.mjs +7 -50
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1431,7 +1431,7 @@ var __webpack_modules__ = {
|
|
|
1431
1431
|
*
|
|
1432
1432
|
* This source code is licensed under the MIT license found in the
|
|
1433
1433
|
* LICENSE file in the root directory of this source tree.
|
|
1434
|
-
*/ var l = Symbol.for("react.element"), n = Symbol.for("react.portal"),
|
|
1434
|
+
*/ var l = Symbol.for("react.element"), n = Symbol.for("react.portal"), z = (Symbol.for("react.fragment"), Symbol.for("react.strict_mode"), Symbol.for("react.profiler"), Symbol.for("react.provider"), Symbol.for("react.context"), Symbol.for("react.forward_ref"), Symbol.for("react.suspense"), Symbol.for("react.memo"), Symbol.for("react.lazy"), Symbol.iterator);
|
|
1435
1435
|
function A(a) {
|
|
1436
1436
|
if (null === a || "object" != typeof a) return null;
|
|
1437
1437
|
a = z && a[z] || a["@@iterator"];
|
|
@@ -1479,25 +1479,6 @@ var __webpack_modules__ = {
|
|
|
1479
1479
|
__self: !0,
|
|
1480
1480
|
__source: !0
|
|
1481
1481
|
};
|
|
1482
|
-
function M(a, b, e) {
|
|
1483
|
-
var d, c = {}, k = null, h = null;
|
|
1484
|
-
if (null != b) for(d in void 0 !== b.ref && (h = b.ref), void 0 !== b.key && (k = "" + b.key), b)J.call(b, d) && !L.hasOwnProperty(d) && (c[d] = b[d]);
|
|
1485
|
-
var g = arguments.length - 2;
|
|
1486
|
-
if (1 === g) c.children = e;
|
|
1487
|
-
else if (1 < g) {
|
|
1488
|
-
for(var f = Array(g), m = 0; m < g; m++)f[m] = arguments[m + 2];
|
|
1489
|
-
c.children = f;
|
|
1490
|
-
}
|
|
1491
|
-
if (a && a.defaultProps) for(d in g = a.defaultProps)void 0 === c[d] && (c[d] = g[d]);
|
|
1492
|
-
return {
|
|
1493
|
-
$$typeof: l,
|
|
1494
|
-
type: a,
|
|
1495
|
-
key: k,
|
|
1496
|
-
ref: h,
|
|
1497
|
-
props: c,
|
|
1498
|
-
_owner: K.current
|
|
1499
|
-
};
|
|
1500
|
-
}
|
|
1501
1482
|
function N(a, b) {
|
|
1502
1483
|
return {
|
|
1503
1484
|
$$typeof: l,
|
|
@@ -1555,32 +1536,8 @@ var __webpack_modules__ = {
|
|
|
1555
1536
|
else if ("object" === k) throw b = String(a), Error("Objects are not valid as a React child (found: " + ("[object Object]" === b ? "object with keys {" + Object.keys(a).join(", ") + "}" : b) + "). If you meant to render a collection of children, use an array instead.");
|
|
1556
1537
|
return h;
|
|
1557
1538
|
}
|
|
1558
|
-
function S(a, b, e) {
|
|
1559
|
-
if (null == a) return a;
|
|
1560
|
-
var d = [], c = 0;
|
|
1561
|
-
R(a, d, "", "", function(a) {
|
|
1562
|
-
return b.call(e, a, c++);
|
|
1563
|
-
});
|
|
1564
|
-
return d;
|
|
1565
|
-
}
|
|
1566
|
-
function T(a) {
|
|
1567
|
-
if (-1 === a._status) {
|
|
1568
|
-
var b = a._result;
|
|
1569
|
-
b = b();
|
|
1570
|
-
b.then(function(b) {
|
|
1571
|
-
if (0 === a._status || -1 === a._status) a._status = 1, a._result = b;
|
|
1572
|
-
}, function(b) {
|
|
1573
|
-
if (0 === a._status || -1 === a._status) a._status = 2, a._result = b;
|
|
1574
|
-
});
|
|
1575
|
-
-1 === a._status && (a._status = 0, a._result = b);
|
|
1576
|
-
}
|
|
1577
|
-
if (1 === a._status) return a._result.default;
|
|
1578
|
-
throw a._result;
|
|
1579
|
-
}
|
|
1580
1539
|
var U = {
|
|
1581
1540
|
current: null
|
|
1582
|
-
}, V = {
|
|
1583
|
-
transition: null
|
|
1584
1541
|
};
|
|
1585
1542
|
exports1.useCallback = function(a, b) {
|
|
1586
1543
|
return U.current.useCallback(a, b);
|
|
@@ -1608,9 +1565,7 @@ var __webpack_modules__ = {
|
|
|
1608
1565
|
},
|
|
1609
1566
|
"./src/specs/NativeHotUpdater.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1610
1567
|
__webpack_require__.d(__webpack_exports__, {
|
|
1611
|
-
Z:
|
|
1612
|
-
return __WEBPACK_DEFAULT_EXPORT__;
|
|
1613
|
-
}
|
|
1568
|
+
Z: ()=>__WEBPACK_DEFAULT_EXPORT__
|
|
1614
1569
|
});
|
|
1615
1570
|
var react_native__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("react-native");
|
|
1616
1571
|
const __WEBPACK_DEFAULT_EXPORT__ = react_native__WEBPACK_IMPORTED_MODULE_0__.TurboModuleRegistry.get("HotUpdater");
|
|
@@ -1676,220 +1631,222 @@ function __webpack_require__(moduleId) {
|
|
|
1676
1631
|
};
|
|
1677
1632
|
})();
|
|
1678
1633
|
var __webpack_exports__ = {};
|
|
1679
|
-
|
|
1680
|
-
__webpack_require__.
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
if (
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
}
|
|
1705
|
-
class HotUpdaterError extends Error {
|
|
1706
|
-
constructor(message){
|
|
1707
|
-
super(message);
|
|
1708
|
-
this.name = "HotUpdaterError";
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
const core_namespaceObject = require("@hot-updater/core");
|
|
1712
|
-
const HotUpdater = {
|
|
1713
|
-
HOT_UPDATER_BUNDLE_ID: core_namespaceObject.NIL_UUID
|
|
1714
|
-
};
|
|
1715
|
-
const LINKING_ERROR = `The package '@hot-updater/react-native' doesn't seem to be linked. Make sure: \n\n` + external_react_native_.Platform.select({
|
|
1716
|
-
ios: "- You have run 'pod install'\n",
|
|
1717
|
-
default: ""
|
|
1718
|
-
}) + "- You rebuilt the app after installing the package\n- You are not using Expo Go\n";
|
|
1719
|
-
const isTurboModuleEnabled = null != global.__turboModuleProxy;
|
|
1720
|
-
const HotUpdaterModule = isTurboModuleEnabled ? __webpack_require__("./src/specs/NativeHotUpdater.ts").Z : external_react_native_.NativeModules.HotUpdater;
|
|
1721
|
-
const HotUpdaterNative = HotUpdaterModule ? HotUpdaterModule : new Proxy({}, {
|
|
1722
|
-
get () {
|
|
1723
|
-
throw new Error(LINKING_ERROR);
|
|
1724
|
-
}
|
|
1725
|
-
});
|
|
1726
|
-
const addListener = (eventName, listener)=>{
|
|
1727
|
-
const eventEmitter = new external_react_native_.NativeEventEmitter(HotUpdaterNative);
|
|
1728
|
-
const subscription = eventEmitter.addListener(eventName, listener);
|
|
1729
|
-
return ()=>{
|
|
1730
|
-
subscription.remove();
|
|
1634
|
+
(()=>{
|
|
1635
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1636
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1637
|
+
hotUpdaterStore: ()=>hotUpdaterStore,
|
|
1638
|
+
useHotUpdaterStore: ()=>useHotUpdaterStore,
|
|
1639
|
+
HotUpdater: ()=>src_HotUpdater
|
|
1640
|
+
});
|
|
1641
|
+
const js_namespaceObject = require("@hot-updater/js");
|
|
1642
|
+
var external_react_native_ = __webpack_require__("react-native");
|
|
1643
|
+
const ensureUpdateInfo = async (source, { appVersion, bundleId, platform }, requestHeaders)=>{
|
|
1644
|
+
try {
|
|
1645
|
+
let bundles = null;
|
|
1646
|
+
if ("string" == typeof source) {
|
|
1647
|
+
if (source.startsWith("http")) return await fetch(source, {
|
|
1648
|
+
headers: {
|
|
1649
|
+
"x-app-platform": platform,
|
|
1650
|
+
"x-app-version": appVersion,
|
|
1651
|
+
"x-bundle-id": bundleId,
|
|
1652
|
+
...requestHeaders
|
|
1653
|
+
}
|
|
1654
|
+
}).then((res)=>res.json());
|
|
1655
|
+
} else bundles = "function" == typeof source ? await source() : source;
|
|
1656
|
+
return bundles ?? [];
|
|
1657
|
+
} catch {
|
|
1658
|
+
return [];
|
|
1659
|
+
}
|
|
1731
1660
|
};
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
};
|
|
1738
|
-
const getBundleId = ()=>HotUpdater.HOT_UPDATER_BUNDLE_ID;
|
|
1739
|
-
async function checkForUpdate(config) {
|
|
1740
|
-
if (__DEV__) {
|
|
1741
|
-
console.warn("[HotUpdater] __DEV__ is true, HotUpdater is only supported in production");
|
|
1742
|
-
return null;
|
|
1661
|
+
class HotUpdaterError extends Error {
|
|
1662
|
+
constructor(message){
|
|
1663
|
+
super(message);
|
|
1664
|
+
this.name = "HotUpdaterError";
|
|
1665
|
+
}
|
|
1743
1666
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
].includes(external_react_native_.Platform.OS)) throw new HotUpdaterError("HotUpdater is only supported on iOS and Android");
|
|
1748
|
-
const currentAppVersion = await getAppVersion();
|
|
1749
|
-
const platform = external_react_native_.Platform.OS;
|
|
1750
|
-
const currentBundleId = await getBundleId();
|
|
1751
|
-
if (!currentAppVersion) throw new HotUpdaterError("Failed to get app version");
|
|
1752
|
-
const ensuredUpdateInfo = await ensureUpdateInfo(config.source, {
|
|
1753
|
-
appVersion: currentAppVersion,
|
|
1754
|
-
bundleId: currentBundleId,
|
|
1755
|
-
platform
|
|
1756
|
-
}, config.requestHeaders);
|
|
1757
|
-
let updateInfo = null;
|
|
1758
|
-
if (Array.isArray(ensuredUpdateInfo)) {
|
|
1759
|
-
const bundles = ensuredUpdateInfo;
|
|
1760
|
-
updateInfo = await (0, js_namespaceObject.getUpdateInfo)(bundles, {
|
|
1761
|
-
appVersion: currentAppVersion,
|
|
1762
|
-
bundleId: currentBundleId,
|
|
1763
|
-
platform
|
|
1764
|
-
});
|
|
1765
|
-
} else updateInfo = ensuredUpdateInfo;
|
|
1766
|
-
return updateInfo;
|
|
1767
|
-
}
|
|
1768
|
-
const runUpdateProcess = async ({ reloadOnForceUpdate = false, ...checkForUpdateConfig })=>{
|
|
1769
|
-
const updateInfo = await checkForUpdate(checkForUpdateConfig);
|
|
1770
|
-
if (!updateInfo) return {
|
|
1771
|
-
status: "UP_TO_DATE"
|
|
1772
|
-
};
|
|
1773
|
-
const isUpdated = await updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
1774
|
-
if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) reload();
|
|
1775
|
-
if (!isUpdated) throw new Error("New update was found but failed to download the bundle.");
|
|
1776
|
-
return {
|
|
1777
|
-
status: updateInfo.status,
|
|
1778
|
-
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
1779
|
-
id: updateInfo.id
|
|
1667
|
+
const core_namespaceObject = require("@hot-updater/core");
|
|
1668
|
+
const HotUpdater = {
|
|
1669
|
+
HOT_UPDATER_BUNDLE_ID: core_namespaceObject.NIL_UUID
|
|
1780
1670
|
};
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1671
|
+
const LINKING_ERROR = `The package '@hot-updater/react-native' doesn't seem to be linked. Make sure: \n\n` + external_react_native_.Platform.select({
|
|
1672
|
+
ios: "- You have run 'pod install'\n",
|
|
1673
|
+
default: ""
|
|
1674
|
+
}) + "- You rebuilt the app after installing the package\n- You are not using Expo Go\n";
|
|
1675
|
+
const isTurboModuleEnabled = null != global.__turboModuleProxy;
|
|
1676
|
+
const HotUpdaterModule = isTurboModuleEnabled ? __webpack_require__("./src/specs/NativeHotUpdater.ts").Z : external_react_native_.NativeModules.HotUpdater;
|
|
1677
|
+
const HotUpdaterNative = HotUpdaterModule ? HotUpdaterModule : new Proxy({}, {
|
|
1678
|
+
get () {
|
|
1679
|
+
throw new Error(LINKING_ERROR);
|
|
1680
|
+
}
|
|
1681
|
+
});
|
|
1682
|
+
const addListener = (eventName, listener)=>{
|
|
1683
|
+
const eventEmitter = new external_react_native_.NativeEventEmitter(HotUpdaterNative);
|
|
1684
|
+
const subscription = eventEmitter.addListener(eventName, listener);
|
|
1685
|
+
return ()=>{
|
|
1686
|
+
subscription.remove();
|
|
1687
|
+
};
|
|
1787
1688
|
};
|
|
1788
|
-
const
|
|
1789
|
-
const
|
|
1790
|
-
const
|
|
1791
|
-
|
|
1689
|
+
const updateBundle = (bundleId, zipUrl)=>HotUpdaterNative.updateBundle(bundleId, zipUrl);
|
|
1690
|
+
const getAppVersion = ()=>HotUpdaterNative.getAppVersion();
|
|
1691
|
+
const reload = ()=>{
|
|
1692
|
+
HotUpdaterNative.reload();
|
|
1792
1693
|
};
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1694
|
+
const getBundleId = ()=>HotUpdater.HOT_UPDATER_BUNDLE_ID;
|
|
1695
|
+
async function checkForUpdate(config) {
|
|
1696
|
+
if (__DEV__) {
|
|
1697
|
+
console.warn("[HotUpdater] __DEV__ is true, HotUpdater is only supported in production");
|
|
1698
|
+
return null;
|
|
1699
|
+
}
|
|
1700
|
+
if (![
|
|
1701
|
+
"ios",
|
|
1702
|
+
"android"
|
|
1703
|
+
].includes(external_react_native_.Platform.OS)) throw new HotUpdaterError("HotUpdater is only supported on iOS and Android");
|
|
1704
|
+
const currentAppVersion = await getAppVersion();
|
|
1705
|
+
const platform = external_react_native_.Platform.OS;
|
|
1706
|
+
const currentBundleId = await getBundleId();
|
|
1707
|
+
if (!currentAppVersion) throw new HotUpdaterError("Failed to get app version");
|
|
1708
|
+
const ensuredUpdateInfo = await ensureUpdateInfo(config.source, {
|
|
1709
|
+
appVersion: currentAppVersion,
|
|
1710
|
+
bundleId: currentBundleId,
|
|
1711
|
+
platform
|
|
1712
|
+
}, config.requestHeaders);
|
|
1713
|
+
let updateInfo = null;
|
|
1714
|
+
if (Array.isArray(ensuredUpdateInfo)) {
|
|
1715
|
+
const bundles = ensuredUpdateInfo;
|
|
1716
|
+
updateInfo = await (0, js_namespaceObject.getUpdateInfo)(bundles, {
|
|
1717
|
+
appVersion: currentAppVersion,
|
|
1718
|
+
bundleId: currentBundleId,
|
|
1719
|
+
platform
|
|
1720
|
+
});
|
|
1721
|
+
} else updateInfo = ensuredUpdateInfo;
|
|
1722
|
+
return updateInfo;
|
|
1723
|
+
}
|
|
1724
|
+
const runUpdateProcess = async ({ reloadOnForceUpdate = false, ...checkForUpdateConfig })=>{
|
|
1725
|
+
const updateInfo = await checkForUpdate(checkForUpdateConfig);
|
|
1726
|
+
if (!updateInfo) return {
|
|
1727
|
+
status: "UP_TO_DATE"
|
|
1728
|
+
};
|
|
1729
|
+
const isUpdated = await updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
1730
|
+
if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) reload();
|
|
1731
|
+
if (!isUpdated) throw new Error("New update was found but failed to download the bundle.");
|
|
1732
|
+
return {
|
|
1733
|
+
status: updateInfo.status,
|
|
1734
|
+
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
1735
|
+
id: updateInfo.id
|
|
1797
1736
|
};
|
|
1798
|
-
emitChange();
|
|
1799
|
-
};
|
|
1800
|
-
const subscribe = (listener)=>{
|
|
1801
|
-
listeners.add(listener);
|
|
1802
|
-
return ()=>listeners.delete(listener);
|
|
1803
1737
|
};
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1738
|
+
var react = __webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js");
|
|
1739
|
+
const createHotUpdaterStore = ()=>{
|
|
1740
|
+
let state = {
|
|
1741
|
+
progress: 0,
|
|
1742
|
+
isBundleUpdated: false
|
|
1743
|
+
};
|
|
1744
|
+
const getSnapshot = ()=>state;
|
|
1745
|
+
const listeners = new Set();
|
|
1746
|
+
const emitChange = ()=>{
|
|
1747
|
+
for (const listener of listeners)listener();
|
|
1748
|
+
};
|
|
1749
|
+
const setProgress = (progress)=>{
|
|
1750
|
+
state = {
|
|
1751
|
+
isBundleUpdated: 1 === progress,
|
|
1752
|
+
progress
|
|
1753
|
+
};
|
|
1754
|
+
emitChange();
|
|
1755
|
+
};
|
|
1756
|
+
const subscribe = (listener)=>{
|
|
1757
|
+
listeners.add(listener);
|
|
1758
|
+
return ()=>listeners.delete(listener);
|
|
1759
|
+
};
|
|
1760
|
+
return {
|
|
1761
|
+
getSnapshot,
|
|
1762
|
+
setProgress,
|
|
1763
|
+
subscribe
|
|
1764
|
+
};
|
|
1808
1765
|
};
|
|
1809
|
-
|
|
1810
|
-
const
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1766
|
+
const hotUpdaterStore = createHotUpdaterStore();
|
|
1767
|
+
const useHotUpdaterStore = ()=>(0, react.useSyncExternalStore)(hotUpdaterStore.subscribe, hotUpdaterStore.getSnapshot, hotUpdaterStore.getSnapshot);
|
|
1768
|
+
function useEventCallback(fn) {
|
|
1769
|
+
const callbackRef = (0, react.useRef)(()=>{
|
|
1770
|
+
throw new Error("Cannot call an event handler while rendering.");
|
|
1771
|
+
});
|
|
1772
|
+
(0, react.useLayoutEffect)(()=>{
|
|
1773
|
+
callbackRef.current = fn;
|
|
1774
|
+
}, [
|
|
1775
|
+
fn
|
|
1776
|
+
]);
|
|
1777
|
+
return (0, react.useCallback)((...args)=>callbackRef.current?.(...args), [
|
|
1778
|
+
callbackRef
|
|
1779
|
+
]);
|
|
1780
|
+
}
|
|
1781
|
+
function wrap(config) {
|
|
1782
|
+
const { reloadOnForceUpdate = true, ...restConfig } = config;
|
|
1783
|
+
return (WrappedComponent)=>{
|
|
1784
|
+
const HotUpdaterHOC = ()=>{
|
|
1785
|
+
const { progress } = useHotUpdaterStore();
|
|
1786
|
+
const [status, setStatus] = (0, react.useState)("IDLE");
|
|
1787
|
+
const initHotUpdater = useEventCallback(async ()=>{
|
|
1788
|
+
try {
|
|
1789
|
+
setStatus("CHECK_FOR_UPDATE");
|
|
1790
|
+
const updateInfo = await checkForUpdate({
|
|
1791
|
+
source: restConfig.source,
|
|
1792
|
+
requestHeaders: restConfig.requestHeaders
|
|
1793
|
+
});
|
|
1794
|
+
if (!updateInfo) {
|
|
1795
|
+
restConfig.onUpdateProcessCompleted?.({
|
|
1796
|
+
status: "UP_TO_DATE"
|
|
1797
|
+
});
|
|
1798
|
+
setStatus("UPDATE_PROCESS_COMPLETED");
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
setStatus("UPDATING");
|
|
1802
|
+
const isSuccess = await updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
1803
|
+
if (!isSuccess) throw new Error("New update was found but failed to download the bundle.");
|
|
1804
|
+
if (updateInfo.shouldForceUpdate && reloadOnForceUpdate) reload();
|
|
1839
1805
|
restConfig.onUpdateProcessCompleted?.({
|
|
1840
|
-
|
|
1806
|
+
id: updateInfo.id,
|
|
1807
|
+
status: updateInfo.status,
|
|
1808
|
+
shouldForceUpdate: updateInfo.shouldForceUpdate
|
|
1841
1809
|
});
|
|
1842
1810
|
setStatus("UPDATE_PROCESS_COMPLETED");
|
|
1843
|
-
|
|
1811
|
+
} catch (error) {
|
|
1812
|
+
if (error instanceof HotUpdaterError) restConfig.onError?.(error);
|
|
1813
|
+
setStatus("UPDATE_PROCESS_COMPLETED");
|
|
1814
|
+
throw error;
|
|
1844
1815
|
}
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1816
|
+
});
|
|
1817
|
+
(0, react.useEffect)(()=>{
|
|
1818
|
+
restConfig.onProgress?.(progress);
|
|
1819
|
+
}, [
|
|
1820
|
+
progress
|
|
1821
|
+
]);
|
|
1822
|
+
(0, react.useLayoutEffect)(()=>{
|
|
1823
|
+
initHotUpdater();
|
|
1824
|
+
}, []);
|
|
1825
|
+
if (restConfig.fallbackComponent && "UPDATE_PROCESS_COMPLETED" !== status) {
|
|
1826
|
+
const Fallback = restConfig.fallbackComponent;
|
|
1827
|
+
return /*#__PURE__*/ React.createElement(Fallback, {
|
|
1828
|
+
progress: progress
|
|
1853
1829
|
});
|
|
1854
|
-
setStatus("UPDATE_PROCESS_COMPLETED");
|
|
1855
|
-
} catch (error) {
|
|
1856
|
-
if (error instanceof HotUpdaterError) restConfig.onError?.(error);
|
|
1857
|
-
setStatus("UPDATE_PROCESS_COMPLETED");
|
|
1858
|
-
throw error;
|
|
1859
1830
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
}, [
|
|
1864
|
-
progress
|
|
1865
|
-
]);
|
|
1866
|
-
(0, react.useLayoutEffect)(()=>{
|
|
1867
|
-
initHotUpdater();
|
|
1868
|
-
}, []);
|
|
1869
|
-
if (restConfig.fallbackComponent && "UPDATE_PROCESS_COMPLETED" !== status) {
|
|
1870
|
-
const Fallback = restConfig.fallbackComponent;
|
|
1871
|
-
return /*#__PURE__*/ React.createElement(Fallback, {
|
|
1872
|
-
progress: progress
|
|
1873
|
-
});
|
|
1874
|
-
}
|
|
1875
|
-
return /*#__PURE__*/ React.createElement(WrappedComponent, null);
|
|
1831
|
+
return /*#__PURE__*/ React.createElement(WrappedComponent, null);
|
|
1832
|
+
};
|
|
1833
|
+
return HotUpdaterHOC;
|
|
1876
1834
|
};
|
|
1877
|
-
|
|
1835
|
+
}
|
|
1836
|
+
addListener("onProgress", ({ progress })=>{
|
|
1837
|
+
hotUpdaterStore.setProgress(progress);
|
|
1838
|
+
});
|
|
1839
|
+
const src_HotUpdater = {
|
|
1840
|
+
wrap: wrap,
|
|
1841
|
+
reload: reload,
|
|
1842
|
+
getAppVersion: getAppVersion,
|
|
1843
|
+
getBundleId: getBundleId,
|
|
1844
|
+
addListener: addListener,
|
|
1845
|
+
checkForUpdate: checkForUpdate,
|
|
1846
|
+
runUpdateProcess: runUpdateProcess,
|
|
1847
|
+
updateBundle: updateBundle
|
|
1878
1848
|
};
|
|
1879
|
-
}
|
|
1880
|
-
addListener("onProgress", ({ progress })=>{
|
|
1881
|
-
hotUpdaterStore.setProgress(progress);
|
|
1882
|
-
});
|
|
1883
|
-
const src_HotUpdater = {
|
|
1884
|
-
wrap: wrap,
|
|
1885
|
-
reload: reload,
|
|
1886
|
-
getAppVersion: getAppVersion,
|
|
1887
|
-
getBundleId: getBundleId,
|
|
1888
|
-
addListener: addListener,
|
|
1889
|
-
checkForUpdate: checkForUpdate,
|
|
1890
|
-
runUpdateProcess: runUpdateProcess,
|
|
1891
|
-
updateBundle: updateBundle
|
|
1892
|
-
};
|
|
1849
|
+
})();
|
|
1893
1850
|
var __webpack_export_target__ = exports;
|
|
1894
1851
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
1895
1852
|
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! For license information please see index.mjs.LICENSE.txt */
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__ from "react-native";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_js_db235456__ from "@hot-updater/js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_core_132f924c__ from "@hot-updater/core";
|
|
5
5
|
var __webpack_modules__ = {
|
|
6
6
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js": function(module, exports, __webpack_require__) {
|
|
7
7
|
module = __webpack_require__.nmd(module);
|
|
@@ -1433,7 +1433,7 @@ var __webpack_modules__ = {
|
|
|
1433
1433
|
*
|
|
1434
1434
|
* This source code is licensed under the MIT license found in the
|
|
1435
1435
|
* LICENSE file in the root directory of this source tree.
|
|
1436
|
-
*/ var l = Symbol.for("react.element"), n = Symbol.for("react.portal"),
|
|
1436
|
+
*/ var l = Symbol.for("react.element"), n = Symbol.for("react.portal"), z = (Symbol.for("react.fragment"), Symbol.for("react.strict_mode"), Symbol.for("react.profiler"), Symbol.for("react.provider"), Symbol.for("react.context"), Symbol.for("react.forward_ref"), Symbol.for("react.suspense"), Symbol.for("react.memo"), Symbol.for("react.lazy"), Symbol.iterator);
|
|
1437
1437
|
function A(a) {
|
|
1438
1438
|
if (null === a || "object" != typeof a) return null;
|
|
1439
1439
|
a = z && a[z] || a["@@iterator"];
|
|
@@ -1481,25 +1481,6 @@ var __webpack_modules__ = {
|
|
|
1481
1481
|
__self: !0,
|
|
1482
1482
|
__source: !0
|
|
1483
1483
|
};
|
|
1484
|
-
function M(a, b, e) {
|
|
1485
|
-
var d, c = {}, k = null, h = null;
|
|
1486
|
-
if (null != b) for(d in void 0 !== b.ref && (h = b.ref), void 0 !== b.key && (k = "" + b.key), b)J.call(b, d) && !L.hasOwnProperty(d) && (c[d] = b[d]);
|
|
1487
|
-
var g = arguments.length - 2;
|
|
1488
|
-
if (1 === g) c.children = e;
|
|
1489
|
-
else if (1 < g) {
|
|
1490
|
-
for(var f = Array(g), m = 0; m < g; m++)f[m] = arguments[m + 2];
|
|
1491
|
-
c.children = f;
|
|
1492
|
-
}
|
|
1493
|
-
if (a && a.defaultProps) for(d in g = a.defaultProps)void 0 === c[d] && (c[d] = g[d]);
|
|
1494
|
-
return {
|
|
1495
|
-
$$typeof: l,
|
|
1496
|
-
type: a,
|
|
1497
|
-
key: k,
|
|
1498
|
-
ref: h,
|
|
1499
|
-
props: c,
|
|
1500
|
-
_owner: K.current
|
|
1501
|
-
};
|
|
1502
|
-
}
|
|
1503
1484
|
function N(a, b) {
|
|
1504
1485
|
return {
|
|
1505
1486
|
$$typeof: l,
|
|
@@ -1557,32 +1538,8 @@ var __webpack_modules__ = {
|
|
|
1557
1538
|
else if ("object" === k) throw b = String(a), Error("Objects are not valid as a React child (found: " + ("[object Object]" === b ? "object with keys {" + Object.keys(a).join(", ") + "}" : b) + "). If you meant to render a collection of children, use an array instead.");
|
|
1558
1539
|
return h;
|
|
1559
1540
|
}
|
|
1560
|
-
function S(a, b, e) {
|
|
1561
|
-
if (null == a) return a;
|
|
1562
|
-
var d = [], c = 0;
|
|
1563
|
-
R(a, d, "", "", function(a) {
|
|
1564
|
-
return b.call(e, a, c++);
|
|
1565
|
-
});
|
|
1566
|
-
return d;
|
|
1567
|
-
}
|
|
1568
|
-
function T(a) {
|
|
1569
|
-
if (-1 === a._status) {
|
|
1570
|
-
var b = a._result;
|
|
1571
|
-
b = b();
|
|
1572
|
-
b.then(function(b) {
|
|
1573
|
-
if (0 === a._status || -1 === a._status) a._status = 1, a._result = b;
|
|
1574
|
-
}, function(b) {
|
|
1575
|
-
if (0 === a._status || -1 === a._status) a._status = 2, a._result = b;
|
|
1576
|
-
});
|
|
1577
|
-
-1 === a._status && (a._status = 0, a._result = b);
|
|
1578
|
-
}
|
|
1579
|
-
if (1 === a._status) return a._result.default;
|
|
1580
|
-
throw a._result;
|
|
1581
|
-
}
|
|
1582
1541
|
var U = {
|
|
1583
1542
|
current: null
|
|
1584
|
-
}, V = {
|
|
1585
|
-
transition: null
|
|
1586
1543
|
};
|
|
1587
1544
|
exports.useCallback = function(a, b) {
|
|
1588
1545
|
return U.current.useCallback(a, b);
|
|
@@ -1616,7 +1573,7 @@ var __webpack_modules__ = {
|
|
|
1616
1573
|
const NativeHotUpdater = external_react_native_.TurboModuleRegistry.get("HotUpdater");
|
|
1617
1574
|
},
|
|
1618
1575
|
"react-native": function(module) {
|
|
1619
|
-
module.exports =
|
|
1576
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__;
|
|
1620
1577
|
}
|
|
1621
1578
|
};
|
|
1622
1579
|
var __webpack_module_cache__ = {};
|
|
@@ -1678,7 +1635,7 @@ class HotUpdaterError extends Error {
|
|
|
1678
1635
|
}
|
|
1679
1636
|
}
|
|
1680
1637
|
const HotUpdater = {
|
|
1681
|
-
HOT_UPDATER_BUNDLE_ID:
|
|
1638
|
+
HOT_UPDATER_BUNDLE_ID: __WEBPACK_EXTERNAL_MODULE__hot_updater_core_132f924c__.NIL_UUID
|
|
1682
1639
|
};
|
|
1683
1640
|
const LINKING_ERROR = `The package '@hot-updater/react-native' doesn't seem to be linked. Make sure: \n\n` + external_react_native_.Platform.select({
|
|
1684
1641
|
ios: "- You have run 'pod install'\n",
|
|
@@ -1725,7 +1682,7 @@ async function checkForUpdate(config) {
|
|
|
1725
1682
|
let updateInfo = null;
|
|
1726
1683
|
if (Array.isArray(ensuredUpdateInfo)) {
|
|
1727
1684
|
const bundles = ensuredUpdateInfo;
|
|
1728
|
-
updateInfo = await (0,
|
|
1685
|
+
updateInfo = await (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_js_db235456__.getUpdateInfo)(bundles, {
|
|
1729
1686
|
appVersion: currentAppVersion,
|
|
1730
1687
|
bundleId: currentBundleId,
|
|
1731
1688
|
platform
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/react-native",
|
|
3
|
-
"version": "0.6.0",
|
|
3
|
+
"version": "0.6.1-rc.0",
|
|
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.6.0",
|
|
79
|
-
"@hot-updater/core": "0.6.0"
|
|
78
|
+
"@hot-updater/js": "0.6.1-rc.0",
|
|
79
|
+
"@hot-updater/core": "0.6.1-rc.0"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "rslib build",
|