@hot-updater/react-native 0.17.0 → 0.18.1
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/HotUpdater.podspec +7 -11
- package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +200 -0
- package/android/src/main/java/com/hotupdater/FileManagerService.kt +104 -0
- package/android/src/main/java/com/hotupdater/HotUpdater.kt +62 -305
- package/android/src/main/java/com/hotupdater/HotUpdaterFactory.kt +49 -0
- package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +176 -0
- package/android/src/main/java/com/hotupdater/HttpDownloadService.kt +98 -0
- package/android/src/main/java/com/hotupdater/VersionedPreferencesService.kt +69 -0
- package/android/src/main/java/com/hotupdater/ZipFileUnzipService.kt +52 -0
- package/android/src/newarch/HotUpdaterModule.kt +31 -34
- package/android/src/oldarch/HotUpdaterModule.kt +32 -34
- package/android/src/oldarch/HotUpdaterSpec.kt +2 -9
- package/ios/HotUpdater/Internal/BundleFileStorageService.swift +593 -0
- package/ios/HotUpdater/Internal/FileManagerService.swift +97 -0
- package/ios/HotUpdater/Internal/HotUpdater-Bridging-Header.h +8 -0
- package/ios/HotUpdater/Internal/HotUpdater.mm +241 -0
- package/ios/HotUpdater/Internal/HotUpdaterFactory.swift +24 -0
- package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +143 -0
- package/ios/HotUpdater/Internal/NotificationExtension.swift +6 -0
- package/ios/HotUpdater/Internal/SSZipArchiveUnzipService.swift +25 -0
- package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +101 -0
- package/ios/HotUpdater/Internal/VersionedPreferencesService.swift +82 -0
- package/ios/HotUpdater/Public/HotUpdater.h +29 -0
- package/lib/commonjs/checkForUpdate.js +70 -0
- package/lib/commonjs/checkForUpdate.js.map +1 -0
- package/lib/commonjs/error.js +14 -0
- package/lib/commonjs/error.js.map +1 -0
- package/lib/commonjs/fetchUpdateInfo.js +74 -0
- package/lib/commonjs/fetchUpdateInfo.js.map +1 -0
- package/lib/commonjs/hooks/useEventCallback.js +17 -0
- package/lib/commonjs/hooks/useEventCallback.js.map +1 -0
- package/lib/commonjs/index.js +234 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/native.js +132 -0
- package/lib/commonjs/native.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/runUpdateProcess.js +69 -0
- package/lib/commonjs/runUpdateProcess.js.map +1 -0
- package/lib/commonjs/specs/NativeHotUpdater.js +9 -0
- package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -0
- package/lib/commonjs/store.js +48 -0
- package/lib/commonjs/store.js.map +1 -0
- package/lib/commonjs/wrap.js +98 -0
- package/lib/commonjs/wrap.js.map +1 -0
- package/lib/module/checkForUpdate.js +64 -0
- package/lib/module/checkForUpdate.js.map +1 -0
- package/lib/module/error.js +9 -0
- package/lib/module/error.js.map +1 -0
- package/lib/module/fetchUpdateInfo.js +69 -0
- package/lib/module/fetchUpdateInfo.js.map +1 -0
- package/lib/module/hooks/useEventCallback.js +13 -0
- package/lib/module/hooks/useEventCallback.js.map +1 -0
- package/lib/module/index.js +211 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native.js +119 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/runUpdateProcess.js +64 -0
- package/lib/module/runUpdateProcess.js.map +1 -0
- package/lib/module/specs/NativeHotUpdater.js +5 -0
- package/lib/module/specs/NativeHotUpdater.js.map +1 -0
- package/lib/module/store.js +42 -0
- package/lib/module/store.js.map +1 -0
- package/lib/module/wrap.js +94 -0
- package/lib/module/wrap.js.map +1 -0
- package/lib/typescript/commonjs/checkForUpdate.d.ts +22 -0
- package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -0
- package/{dist → lib/typescript/commonjs}/error.d.ts +1 -0
- package/lib/typescript/commonjs/error.d.ts.map +1 -0
- package/lib/typescript/commonjs/fetchUpdateInfo.d.ts +4 -0
- package/lib/typescript/commonjs/fetchUpdateInfo.d.ts.map +1 -0
- package/{dist → lib/typescript/commonjs}/hooks/useEventCallback.d.ts +1 -0
- package/lib/typescript/commonjs/hooks/useEventCallback.d.ts.map +1 -0
- package/{dist → lib/typescript/commonjs}/index.d.ts +38 -12
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/native.d.ts +64 -0
- package/lib/typescript/commonjs/native.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/{dist → lib/typescript/commonjs}/runUpdateProcess.d.ts +1 -0
- package/lib/typescript/commonjs/runUpdateProcess.d.ts.map +1 -0
- package/{dist → lib/typescript/commonjs}/specs/NativeHotUpdater.d.ts +8 -9
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -0
- package/{dist → lib/typescript/commonjs}/store.d.ts +1 -0
- package/lib/typescript/commonjs/store.d.ts.map +1 -0
- package/{dist → lib/typescript/commonjs}/wrap.d.ts +3 -2
- package/lib/typescript/commonjs/wrap.d.ts.map +1 -0
- package/lib/typescript/module/checkForUpdate.d.ts +22 -0
- package/lib/typescript/module/checkForUpdate.d.ts.map +1 -0
- package/lib/typescript/module/error.d.ts +4 -0
- package/lib/typescript/module/error.d.ts.map +1 -0
- package/lib/typescript/module/fetchUpdateInfo.d.ts +4 -0
- package/lib/typescript/module/fetchUpdateInfo.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useEventCallback.d.ts +5 -0
- package/lib/typescript/module/hooks/useEventCallback.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +202 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/native.d.ts +64 -0
- package/lib/typescript/module/native.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/runUpdateProcess.d.ts +49 -0
- package/lib/typescript/module/runUpdateProcess.d.ts.map +1 -0
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts +19 -0
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -0
- package/lib/typescript/module/store.d.ts +11 -0
- package/lib/typescript/module/store.d.ts.map +1 -0
- package/lib/typescript/module/wrap.d.ts +51 -0
- package/lib/typescript/module/wrap.d.ts.map +1 -0
- package/package.json +59 -30
- package/src/checkForUpdate.ts +59 -9
- package/src/fetchUpdateInfo.ts +40 -12
- package/src/index.ts +37 -11
- package/src/native.ts +87 -41
- package/src/runUpdateProcess.ts +2 -2
- package/src/specs/NativeHotUpdater.ts +8 -10
- package/src/wrap.tsx +9 -13
- package/android/generated/java/com/hotupdater/NativeHotUpdaterSpec.java +0 -93
- package/android/generated/jni/CMakeLists.txt +0 -36
- package/android/generated/jni/HotUpdaterSpec-generated.cpp +0 -68
- package/android/generated/jni/HotUpdaterSpec.h +0 -31
- package/android/generated/jni/react/renderer/components/HotUpdaterSpec/HotUpdaterSpecJSI-generated.cpp +0 -70
- package/android/generated/jni/react/renderer/components/HotUpdaterSpec/HotUpdaterSpecJSI.h +0 -121
- package/android/src/main/java/com/hotupdater/HotUpdaterPrefs.kt +0 -42
- package/dist/checkForUpdate.d.ts +0 -12
- package/dist/fetchUpdateInfo.d.ts +0 -3
- package/dist/index.js +0 -341
- package/dist/index.mjs +0 -301
- package/dist/native.d.ts +0 -41
- package/ios/HotUpdater/HotUpdater.h +0 -15
- package/ios/HotUpdater/HotUpdater.mm +0 -468
- package/ios/HotUpdater/HotUpdater.modulemap +0 -6
- package/ios/HotUpdater/HotUpdaterPrefs.h +0 -9
- package/ios/HotUpdater/HotUpdaterPrefs.mm +0 -45
- package/ios/generated/HotUpdaterSpec/HotUpdaterSpec-generated.mm +0 -81
- package/ios/generated/HotUpdaterSpec/HotUpdaterSpec.h +0 -112
- package/ios/generated/HotUpdaterSpecJSI-generated.cpp +0 -70
- package/ios/generated/HotUpdaterSpecJSI.h +0 -121
- package/react-native.config.js +0 -12
- package/src/global.d.ts +0 -3
package/dist/index.js
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_modules__ = {
|
|
3
|
-
"./src/specs/NativeHotUpdater.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
4
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
5
|
-
Z: ()=>__WEBPACK_DEFAULT_EXPORT__
|
|
6
|
-
});
|
|
7
|
-
var react_native__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("react-native");
|
|
8
|
-
const __WEBPACK_DEFAULT_EXPORT__ = react_native__WEBPACK_IMPORTED_MODULE_0__.TurboModuleRegistry.get("HotUpdater");
|
|
9
|
-
},
|
|
10
|
-
"react-native": function(module) {
|
|
11
|
-
module.exports = require("react-native");
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
var __webpack_module_cache__ = {};
|
|
15
|
-
function __webpack_require__(moduleId) {
|
|
16
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
17
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
18
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
19
|
-
exports: {}
|
|
20
|
-
};
|
|
21
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
22
|
-
return module.exports;
|
|
23
|
-
}
|
|
24
|
-
(()=>{
|
|
25
|
-
__webpack_require__.n = (module)=>{
|
|
26
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
27
|
-
__webpack_require__.d(getter, {
|
|
28
|
-
a: getter
|
|
29
|
-
});
|
|
30
|
-
return getter;
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
(()=>{
|
|
34
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
35
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: definition[key]
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
(()=>{
|
|
42
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
43
|
-
})();
|
|
44
|
-
(()=>{
|
|
45
|
-
__webpack_require__.r = (exports1)=>{
|
|
46
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
47
|
-
value: 'Module'
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
50
|
-
value: true
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
})();
|
|
54
|
-
var __webpack_exports__ = {};
|
|
55
|
-
(()=>{
|
|
56
|
-
__webpack_require__.r(__webpack_exports__);
|
|
57
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
58
|
-
HotUpdater: ()=>src_HotUpdater,
|
|
59
|
-
useHotUpdaterStore: ()=>useHotUpdaterStore,
|
|
60
|
-
hotUpdaterStore: ()=>hotUpdaterStore
|
|
61
|
-
});
|
|
62
|
-
var external_react_native_ = __webpack_require__("react-native");
|
|
63
|
-
class HotUpdaterError extends Error {
|
|
64
|
-
constructor(message){
|
|
65
|
-
super(message);
|
|
66
|
-
this.name = "HotUpdaterError";
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const fetchUpdateInfo = async (source, { appVersion, bundleId, platform, minBundleId, channel }, requestHeaders, onError, requestTimeout = 5000)=>{
|
|
70
|
-
if ("function" == typeof source) return source();
|
|
71
|
-
const controller = new AbortController();
|
|
72
|
-
const timeoutId = setTimeout(()=>{
|
|
73
|
-
controller.abort();
|
|
74
|
-
}, requestTimeout);
|
|
75
|
-
try {
|
|
76
|
-
const response = await fetch(source, {
|
|
77
|
-
signal: controller.signal,
|
|
78
|
-
headers: {
|
|
79
|
-
"Content-Type": "application/json",
|
|
80
|
-
"x-app-platform": platform,
|
|
81
|
-
"x-app-version": appVersion,
|
|
82
|
-
"x-bundle-id": bundleId,
|
|
83
|
-
...minBundleId ? {
|
|
84
|
-
"x-min-bundle-id": minBundleId
|
|
85
|
-
} : {},
|
|
86
|
-
...channel ? {
|
|
87
|
-
"x-channel": channel
|
|
88
|
-
} : {},
|
|
89
|
-
...requestHeaders
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
clearTimeout(timeoutId);
|
|
93
|
-
if (200 !== response.status) throw new Error(response.statusText);
|
|
94
|
-
return response.json();
|
|
95
|
-
} catch (error) {
|
|
96
|
-
if ("AbortError" === error.name) {
|
|
97
|
-
onError?.(new Error("Request timed out"));
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
onError?.(error);
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
const NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
105
|
-
const HotUpdater = {
|
|
106
|
-
HOT_UPDATER_BUNDLE_ID: __HOT_UPDATER_BUNDLE_ID || NIL_UUID,
|
|
107
|
-
CHANNEL: __HOT_UPDATER_CHANNEL || (__DEV__ ? null : "production")
|
|
108
|
-
};
|
|
109
|
-
const RCTNativeHotUpdater = __webpack_require__("./src/specs/NativeHotUpdater.ts").Z;
|
|
110
|
-
const LINKING_ERROR = `The package '@hot-updater/react-native' doesn't seem to be linked. Make sure: \n\n` + external_react_native_.Platform.select({
|
|
111
|
-
ios: "- You have run 'pod install'\n",
|
|
112
|
-
default: ""
|
|
113
|
-
}) + "- You rebuilt the app after installing the package\n- You are not using Expo Go\n";
|
|
114
|
-
const HotUpdaterNative = RCTNativeHotUpdater ? RCTNativeHotUpdater : new Proxy({}, {
|
|
115
|
-
get () {
|
|
116
|
-
throw new Error(LINKING_ERROR);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
const addListener = (eventName, listener)=>{
|
|
120
|
-
const eventEmitter = new external_react_native_.NativeEventEmitter(HotUpdaterNative);
|
|
121
|
-
const subscription = eventEmitter.addListener(eventName, listener);
|
|
122
|
-
return ()=>{
|
|
123
|
-
subscription.remove();
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
const updateBundle = (bundleId, zipUrl)=>HotUpdaterNative.updateBundle(bundleId, zipUrl);
|
|
127
|
-
const getAppVersion = ()=>{
|
|
128
|
-
const constants = HotUpdaterNative.getConstants();
|
|
129
|
-
return constants?.APP_VERSION ?? null;
|
|
130
|
-
};
|
|
131
|
-
const reload = ()=>{
|
|
132
|
-
requestAnimationFrame(()=>{
|
|
133
|
-
HotUpdaterNative.reload();
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
const getMinBundleId = ()=>{
|
|
137
|
-
const constants = HotUpdaterNative.getConstants();
|
|
138
|
-
return constants.MIN_BUNDLE_ID;
|
|
139
|
-
};
|
|
140
|
-
const getBundleId = ()=>HotUpdater.HOT_UPDATER_BUNDLE_ID === NIL_UUID ? getMinBundleId() : HotUpdater.HOT_UPDATER_BUNDLE_ID;
|
|
141
|
-
const setChannel = async (channel)=>HotUpdaterNative.setChannel(channel);
|
|
142
|
-
const getChannel = ()=>{
|
|
143
|
-
const constants = HotUpdaterNative.getConstants();
|
|
144
|
-
return constants?.CHANNEL ?? HotUpdater.CHANNEL ?? null;
|
|
145
|
-
};
|
|
146
|
-
async function checkForUpdate(options) {
|
|
147
|
-
if (__DEV__) return null;
|
|
148
|
-
if (![
|
|
149
|
-
"ios",
|
|
150
|
-
"android"
|
|
151
|
-
].includes(external_react_native_.Platform.OS)) {
|
|
152
|
-
options.onError?.(new HotUpdaterError("HotUpdater is only supported on iOS and Android"));
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
const currentAppVersion = getAppVersion();
|
|
156
|
-
const platform = external_react_native_.Platform.OS;
|
|
157
|
-
const currentBundleId = getBundleId();
|
|
158
|
-
const minBundleId = getMinBundleId();
|
|
159
|
-
const channel = getChannel();
|
|
160
|
-
if (!currentAppVersion) {
|
|
161
|
-
options.onError?.(new HotUpdaterError("Failed to get app version"));
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
return fetchUpdateInfo(options.source, {
|
|
165
|
-
appVersion: currentAppVersion,
|
|
166
|
-
bundleId: currentBundleId,
|
|
167
|
-
platform,
|
|
168
|
-
minBundleId,
|
|
169
|
-
channel: channel ?? void 0
|
|
170
|
-
}, options.requestHeaders, options.onError, options.requestTimeout);
|
|
171
|
-
}
|
|
172
|
-
const runUpdateProcess = async ({ reloadOnForceUpdate = true, ...checkForUpdateOptions })=>{
|
|
173
|
-
const updateInfo = await checkForUpdate(checkForUpdateOptions);
|
|
174
|
-
if (!updateInfo) return {
|
|
175
|
-
status: "UP_TO_DATE",
|
|
176
|
-
shouldForceUpdate: false,
|
|
177
|
-
message: null,
|
|
178
|
-
id: getBundleId()
|
|
179
|
-
};
|
|
180
|
-
const isUpdated = await updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
181
|
-
if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) reload();
|
|
182
|
-
if (!isUpdated) throw new Error("New update was found but failed to download the bundle.");
|
|
183
|
-
return {
|
|
184
|
-
status: updateInfo.status,
|
|
185
|
-
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
186
|
-
id: updateInfo.id,
|
|
187
|
-
message: updateInfo.message
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
const with_selector_namespaceObject = require("use-sync-external-store/shim/with-selector");
|
|
191
|
-
var with_selector_default = /*#__PURE__*/ __webpack_require__.n(with_selector_namespaceObject);
|
|
192
|
-
const { useSyncExternalStoreWithSelector } = with_selector_default();
|
|
193
|
-
const createHotUpdaterStore = ()=>{
|
|
194
|
-
let state = {
|
|
195
|
-
progress: 0,
|
|
196
|
-
isBundleUpdated: false
|
|
197
|
-
};
|
|
198
|
-
const getSnapshot = ()=>state;
|
|
199
|
-
const listeners = new Set();
|
|
200
|
-
const emitChange = ()=>{
|
|
201
|
-
for (const listener of listeners)listener();
|
|
202
|
-
};
|
|
203
|
-
const setState = (newState)=>{
|
|
204
|
-
state = {
|
|
205
|
-
...state,
|
|
206
|
-
...newState
|
|
207
|
-
};
|
|
208
|
-
emitChange();
|
|
209
|
-
};
|
|
210
|
-
const subscribe = (listener)=>{
|
|
211
|
-
listeners.add(listener);
|
|
212
|
-
return ()=>listeners.delete(listener);
|
|
213
|
-
};
|
|
214
|
-
return {
|
|
215
|
-
getSnapshot,
|
|
216
|
-
setState,
|
|
217
|
-
subscribe
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
const hotUpdaterStore = createHotUpdaterStore();
|
|
221
|
-
const useHotUpdaterStore = (selector = (snapshot)=>snapshot)=>useSyncExternalStoreWithSelector(hotUpdaterStore.subscribe, hotUpdaterStore.getSnapshot, hotUpdaterStore.getSnapshot, selector);
|
|
222
|
-
const external_react_namespaceObject = require("react");
|
|
223
|
-
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
224
|
-
function useEventCallback(fn) {
|
|
225
|
-
const callbackRef = (0, external_react_namespaceObject.useRef)(()=>{
|
|
226
|
-
throw new Error("Cannot call an event handler while rendering.");
|
|
227
|
-
});
|
|
228
|
-
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
229
|
-
callbackRef.current = fn;
|
|
230
|
-
}, [
|
|
231
|
-
fn
|
|
232
|
-
]);
|
|
233
|
-
return (0, external_react_namespaceObject.useCallback)((...args)=>callbackRef.current?.(...args), [
|
|
234
|
-
callbackRef
|
|
235
|
-
]);
|
|
236
|
-
}
|
|
237
|
-
function wrap(options) {
|
|
238
|
-
const { reloadOnForceUpdate = true, ...restOptions } = options;
|
|
239
|
-
return (WrappedComponent)=>{
|
|
240
|
-
const HotUpdaterHOC = (props)=>{
|
|
241
|
-
const progress = useHotUpdaterStore((state)=>state.progress);
|
|
242
|
-
const [message, setMessage] = (0, external_react_namespaceObject.useState)(null);
|
|
243
|
-
const [updateStatus, setUpdateStatus] = (0, external_react_namespaceObject.useState)("CHECK_FOR_UPDATE");
|
|
244
|
-
const initHotUpdater = useEventCallback(async ()=>{
|
|
245
|
-
try {
|
|
246
|
-
setUpdateStatus("CHECK_FOR_UPDATE");
|
|
247
|
-
const updateInfo = await checkForUpdate({
|
|
248
|
-
source: restOptions.source,
|
|
249
|
-
requestHeaders: restOptions.requestHeaders,
|
|
250
|
-
onError: restOptions.onError
|
|
251
|
-
});
|
|
252
|
-
setMessage(updateInfo?.message ?? null);
|
|
253
|
-
if (!updateInfo) {
|
|
254
|
-
restOptions.onUpdateProcessCompleted?.({
|
|
255
|
-
status: "UP_TO_DATE",
|
|
256
|
-
shouldForceUpdate: false,
|
|
257
|
-
message: null,
|
|
258
|
-
id: getBundleId()
|
|
259
|
-
});
|
|
260
|
-
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
if (false === updateInfo.shouldForceUpdate) {
|
|
264
|
-
updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
265
|
-
restOptions.onUpdateProcessCompleted?.({
|
|
266
|
-
id: updateInfo.id,
|
|
267
|
-
status: updateInfo.status,
|
|
268
|
-
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
269
|
-
message: updateInfo.message
|
|
270
|
-
});
|
|
271
|
-
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
setUpdateStatus("UPDATING");
|
|
275
|
-
const isSuccess = await updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
276
|
-
if (!isSuccess) throw new Error("New update was found but failed to download the bundle.");
|
|
277
|
-
if (reloadOnForceUpdate) reload();
|
|
278
|
-
restOptions.onUpdateProcessCompleted?.({
|
|
279
|
-
id: updateInfo.id,
|
|
280
|
-
status: updateInfo.status,
|
|
281
|
-
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
282
|
-
message: updateInfo.message
|
|
283
|
-
});
|
|
284
|
-
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
285
|
-
} catch (error) {
|
|
286
|
-
if (error instanceof HotUpdaterError) restOptions.onError?.(error);
|
|
287
|
-
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
288
|
-
throw error;
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
292
|
-
restOptions.onProgress?.(progress);
|
|
293
|
-
}, [
|
|
294
|
-
progress
|
|
295
|
-
]);
|
|
296
|
-
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
297
|
-
initHotUpdater();
|
|
298
|
-
}, []);
|
|
299
|
-
if (restOptions.fallbackComponent && "UPDATE_PROCESS_COMPLETED" !== updateStatus) {
|
|
300
|
-
const Fallback = restOptions.fallbackComponent;
|
|
301
|
-
return /*#__PURE__*/ external_react_default().createElement(Fallback, {
|
|
302
|
-
progress: progress,
|
|
303
|
-
status: updateStatus,
|
|
304
|
-
message: message
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
return /*#__PURE__*/ external_react_default().createElement(WrappedComponent, props);
|
|
308
|
-
};
|
|
309
|
-
return HotUpdaterHOC;
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
addListener("onProgress", ({ progress })=>{
|
|
313
|
-
hotUpdaterStore.setState({
|
|
314
|
-
progress
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
const src_HotUpdater = {
|
|
318
|
-
wrap: wrap,
|
|
319
|
-
reload: reload,
|
|
320
|
-
getAppVersion: getAppVersion,
|
|
321
|
-
getBundleId: getBundleId,
|
|
322
|
-
getMinBundleId: getMinBundleId,
|
|
323
|
-
getChannel: getChannel,
|
|
324
|
-
setChannel: setChannel,
|
|
325
|
-
addListener: addListener,
|
|
326
|
-
checkForUpdate: checkForUpdate,
|
|
327
|
-
runUpdateProcess: runUpdateProcess,
|
|
328
|
-
updateBundle: updateBundle
|
|
329
|
-
};
|
|
330
|
-
})();
|
|
331
|
-
exports.HotUpdater = __webpack_exports__.HotUpdater;
|
|
332
|
-
exports.hotUpdaterStore = __webpack_exports__.hotUpdaterStore;
|
|
333
|
-
exports.useHotUpdaterStore = __webpack_exports__.useHotUpdaterStore;
|
|
334
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
335
|
-
"HotUpdater",
|
|
336
|
-
"hotUpdaterStore",
|
|
337
|
-
"useHotUpdaterStore"
|
|
338
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
339
|
-
Object.defineProperty(exports, '__esModule', {
|
|
340
|
-
value: true
|
|
341
|
-
});
|
package/dist/index.mjs
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__ from "react-native";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_use_sync_external_store_shim_with_selector_83d70c15__ from "use-sync-external-store/shim/with-selector";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
4
|
-
var __webpack_modules__ = {
|
|
5
|
-
"./src/specs/NativeHotUpdater.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
7
|
-
Z: ()=>NativeHotUpdater
|
|
8
|
-
});
|
|
9
|
-
var external_react_native_ = __webpack_require__("react-native");
|
|
10
|
-
const NativeHotUpdater = external_react_native_.TurboModuleRegistry.get("HotUpdater");
|
|
11
|
-
},
|
|
12
|
-
"react-native": function(module) {
|
|
13
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
var __webpack_module_cache__ = {};
|
|
17
|
-
function __webpack_require__(moduleId) {
|
|
18
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
20
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
21
|
-
exports: {}
|
|
22
|
-
};
|
|
23
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
|
-
return module.exports;
|
|
25
|
-
}
|
|
26
|
-
(()=>{
|
|
27
|
-
__webpack_require__.d = (exports, definition)=>{
|
|
28
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: definition[key]
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
})();
|
|
34
|
-
(()=>{
|
|
35
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
36
|
-
})();
|
|
37
|
-
var external_react_native_ = __webpack_require__("react-native");
|
|
38
|
-
class HotUpdaterError extends Error {
|
|
39
|
-
constructor(message){
|
|
40
|
-
super(message);
|
|
41
|
-
this.name = "HotUpdaterError";
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const fetchUpdateInfo = async (source, { appVersion, bundleId, platform, minBundleId, channel }, requestHeaders, onError, requestTimeout = 5000)=>{
|
|
45
|
-
if ("function" == typeof source) return source();
|
|
46
|
-
const controller = new AbortController();
|
|
47
|
-
const timeoutId = setTimeout(()=>{
|
|
48
|
-
controller.abort();
|
|
49
|
-
}, requestTimeout);
|
|
50
|
-
try {
|
|
51
|
-
const response = await fetch(source, {
|
|
52
|
-
signal: controller.signal,
|
|
53
|
-
headers: {
|
|
54
|
-
"Content-Type": "application/json",
|
|
55
|
-
"x-app-platform": platform,
|
|
56
|
-
"x-app-version": appVersion,
|
|
57
|
-
"x-bundle-id": bundleId,
|
|
58
|
-
...minBundleId ? {
|
|
59
|
-
"x-min-bundle-id": minBundleId
|
|
60
|
-
} : {},
|
|
61
|
-
...channel ? {
|
|
62
|
-
"x-channel": channel
|
|
63
|
-
} : {},
|
|
64
|
-
...requestHeaders
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
clearTimeout(timeoutId);
|
|
68
|
-
if (200 !== response.status) throw new Error(response.statusText);
|
|
69
|
-
return response.json();
|
|
70
|
-
} catch (error) {
|
|
71
|
-
if ("AbortError" === error.name) {
|
|
72
|
-
onError?.(new Error("Request timed out"));
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
onError?.(error);
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
80
|
-
const HotUpdater = {
|
|
81
|
-
HOT_UPDATER_BUNDLE_ID: __HOT_UPDATER_BUNDLE_ID || NIL_UUID,
|
|
82
|
-
CHANNEL: __HOT_UPDATER_CHANNEL || (__DEV__ ? null : "production")
|
|
83
|
-
};
|
|
84
|
-
const RCTNativeHotUpdater = __webpack_require__("./src/specs/NativeHotUpdater.ts").Z;
|
|
85
|
-
const LINKING_ERROR = `The package '@hot-updater/react-native' doesn't seem to be linked. Make sure: \n\n` + external_react_native_.Platform.select({
|
|
86
|
-
ios: "- You have run 'pod install'\n",
|
|
87
|
-
default: ""
|
|
88
|
-
}) + "- You rebuilt the app after installing the package\n- You are not using Expo Go\n";
|
|
89
|
-
const HotUpdaterNative = RCTNativeHotUpdater ? RCTNativeHotUpdater : new Proxy({}, {
|
|
90
|
-
get () {
|
|
91
|
-
throw new Error(LINKING_ERROR);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
const addListener = (eventName, listener)=>{
|
|
95
|
-
const eventEmitter = new external_react_native_.NativeEventEmitter(HotUpdaterNative);
|
|
96
|
-
const subscription = eventEmitter.addListener(eventName, listener);
|
|
97
|
-
return ()=>{
|
|
98
|
-
subscription.remove();
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
const updateBundle = (bundleId, zipUrl)=>HotUpdaterNative.updateBundle(bundleId, zipUrl);
|
|
102
|
-
const getAppVersion = ()=>{
|
|
103
|
-
const constants = HotUpdaterNative.getConstants();
|
|
104
|
-
return constants?.APP_VERSION ?? null;
|
|
105
|
-
};
|
|
106
|
-
const reload = ()=>{
|
|
107
|
-
requestAnimationFrame(()=>{
|
|
108
|
-
HotUpdaterNative.reload();
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
const getMinBundleId = ()=>{
|
|
112
|
-
const constants = HotUpdaterNative.getConstants();
|
|
113
|
-
return constants.MIN_BUNDLE_ID;
|
|
114
|
-
};
|
|
115
|
-
const getBundleId = ()=>HotUpdater.HOT_UPDATER_BUNDLE_ID === NIL_UUID ? getMinBundleId() : HotUpdater.HOT_UPDATER_BUNDLE_ID;
|
|
116
|
-
const setChannel = async (channel)=>HotUpdaterNative.setChannel(channel);
|
|
117
|
-
const getChannel = ()=>{
|
|
118
|
-
const constants = HotUpdaterNative.getConstants();
|
|
119
|
-
return constants?.CHANNEL ?? HotUpdater.CHANNEL ?? null;
|
|
120
|
-
};
|
|
121
|
-
async function checkForUpdate(options) {
|
|
122
|
-
if (__DEV__) return null;
|
|
123
|
-
if (![
|
|
124
|
-
"ios",
|
|
125
|
-
"android"
|
|
126
|
-
].includes(external_react_native_.Platform.OS)) {
|
|
127
|
-
options.onError?.(new HotUpdaterError("HotUpdater is only supported on iOS and Android"));
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
const currentAppVersion = getAppVersion();
|
|
131
|
-
const platform = external_react_native_.Platform.OS;
|
|
132
|
-
const currentBundleId = getBundleId();
|
|
133
|
-
const minBundleId = getMinBundleId();
|
|
134
|
-
const channel = getChannel();
|
|
135
|
-
if (!currentAppVersion) {
|
|
136
|
-
options.onError?.(new HotUpdaterError("Failed to get app version"));
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
return fetchUpdateInfo(options.source, {
|
|
140
|
-
appVersion: currentAppVersion,
|
|
141
|
-
bundleId: currentBundleId,
|
|
142
|
-
platform,
|
|
143
|
-
minBundleId,
|
|
144
|
-
channel: channel ?? void 0
|
|
145
|
-
}, options.requestHeaders, options.onError, options.requestTimeout);
|
|
146
|
-
}
|
|
147
|
-
const runUpdateProcess = async ({ reloadOnForceUpdate = true, ...checkForUpdateOptions })=>{
|
|
148
|
-
const updateInfo = await checkForUpdate(checkForUpdateOptions);
|
|
149
|
-
if (!updateInfo) return {
|
|
150
|
-
status: "UP_TO_DATE",
|
|
151
|
-
shouldForceUpdate: false,
|
|
152
|
-
message: null,
|
|
153
|
-
id: getBundleId()
|
|
154
|
-
};
|
|
155
|
-
const isUpdated = await updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
156
|
-
if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) reload();
|
|
157
|
-
if (!isUpdated) throw new Error("New update was found but failed to download the bundle.");
|
|
158
|
-
return {
|
|
159
|
-
status: updateInfo.status,
|
|
160
|
-
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
161
|
-
id: updateInfo.id,
|
|
162
|
-
message: updateInfo.message
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
const { useSyncExternalStoreWithSelector } = __WEBPACK_EXTERNAL_MODULE_use_sync_external_store_shim_with_selector_83d70c15__["default"];
|
|
166
|
-
const createHotUpdaterStore = ()=>{
|
|
167
|
-
let state = {
|
|
168
|
-
progress: 0,
|
|
169
|
-
isBundleUpdated: false
|
|
170
|
-
};
|
|
171
|
-
const getSnapshot = ()=>state;
|
|
172
|
-
const listeners = new Set();
|
|
173
|
-
const emitChange = ()=>{
|
|
174
|
-
for (const listener of listeners)listener();
|
|
175
|
-
};
|
|
176
|
-
const setState = (newState)=>{
|
|
177
|
-
state = {
|
|
178
|
-
...state,
|
|
179
|
-
...newState
|
|
180
|
-
};
|
|
181
|
-
emitChange();
|
|
182
|
-
};
|
|
183
|
-
const subscribe = (listener)=>{
|
|
184
|
-
listeners.add(listener);
|
|
185
|
-
return ()=>listeners.delete(listener);
|
|
186
|
-
};
|
|
187
|
-
return {
|
|
188
|
-
getSnapshot,
|
|
189
|
-
setState,
|
|
190
|
-
subscribe
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
const hotUpdaterStore = createHotUpdaterStore();
|
|
194
|
-
const useHotUpdaterStore = (selector = (snapshot)=>snapshot)=>useSyncExternalStoreWithSelector(hotUpdaterStore.subscribe, hotUpdaterStore.getSnapshot, hotUpdaterStore.getSnapshot, selector);
|
|
195
|
-
function useEventCallback(fn) {
|
|
196
|
-
const callbackRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(()=>{
|
|
197
|
-
throw new Error("Cannot call an event handler while rendering.");
|
|
198
|
-
});
|
|
199
|
-
(0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
|
|
200
|
-
callbackRef.current = fn;
|
|
201
|
-
}, [
|
|
202
|
-
fn
|
|
203
|
-
]);
|
|
204
|
-
return (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((...args)=>callbackRef.current?.(...args), [
|
|
205
|
-
callbackRef
|
|
206
|
-
]);
|
|
207
|
-
}
|
|
208
|
-
function wrap(options) {
|
|
209
|
-
const { reloadOnForceUpdate = true, ...restOptions } = options;
|
|
210
|
-
return (WrappedComponent)=>{
|
|
211
|
-
const HotUpdaterHOC = (props)=>{
|
|
212
|
-
const progress = useHotUpdaterStore((state)=>state.progress);
|
|
213
|
-
const [message, setMessage] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(null);
|
|
214
|
-
const [updateStatus, setUpdateStatus] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)("CHECK_FOR_UPDATE");
|
|
215
|
-
const initHotUpdater = useEventCallback(async ()=>{
|
|
216
|
-
try {
|
|
217
|
-
setUpdateStatus("CHECK_FOR_UPDATE");
|
|
218
|
-
const updateInfo = await checkForUpdate({
|
|
219
|
-
source: restOptions.source,
|
|
220
|
-
requestHeaders: restOptions.requestHeaders,
|
|
221
|
-
onError: restOptions.onError
|
|
222
|
-
});
|
|
223
|
-
setMessage(updateInfo?.message ?? null);
|
|
224
|
-
if (!updateInfo) {
|
|
225
|
-
restOptions.onUpdateProcessCompleted?.({
|
|
226
|
-
status: "UP_TO_DATE",
|
|
227
|
-
shouldForceUpdate: false,
|
|
228
|
-
message: null,
|
|
229
|
-
id: getBundleId()
|
|
230
|
-
});
|
|
231
|
-
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
if (false === updateInfo.shouldForceUpdate) {
|
|
235
|
-
updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
236
|
-
restOptions.onUpdateProcessCompleted?.({
|
|
237
|
-
id: updateInfo.id,
|
|
238
|
-
status: updateInfo.status,
|
|
239
|
-
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
240
|
-
message: updateInfo.message
|
|
241
|
-
});
|
|
242
|
-
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
setUpdateStatus("UPDATING");
|
|
246
|
-
const isSuccess = await updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
247
|
-
if (!isSuccess) throw new Error("New update was found but failed to download the bundle.");
|
|
248
|
-
if (reloadOnForceUpdate) reload();
|
|
249
|
-
restOptions.onUpdateProcessCompleted?.({
|
|
250
|
-
id: updateInfo.id,
|
|
251
|
-
status: updateInfo.status,
|
|
252
|
-
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
253
|
-
message: updateInfo.message
|
|
254
|
-
});
|
|
255
|
-
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
256
|
-
} catch (error) {
|
|
257
|
-
if (error instanceof HotUpdaterError) restOptions.onError?.(error);
|
|
258
|
-
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
259
|
-
throw error;
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
263
|
-
restOptions.onProgress?.(progress);
|
|
264
|
-
}, [
|
|
265
|
-
progress
|
|
266
|
-
]);
|
|
267
|
-
(0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
|
|
268
|
-
initHotUpdater();
|
|
269
|
-
}, []);
|
|
270
|
-
if (restOptions.fallbackComponent && "UPDATE_PROCESS_COMPLETED" !== updateStatus) {
|
|
271
|
-
const Fallback = restOptions.fallbackComponent;
|
|
272
|
-
return /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(Fallback, {
|
|
273
|
-
progress: progress,
|
|
274
|
-
status: updateStatus,
|
|
275
|
-
message: message
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
return /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(WrappedComponent, props);
|
|
279
|
-
};
|
|
280
|
-
return HotUpdaterHOC;
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
addListener("onProgress", ({ progress })=>{
|
|
284
|
-
hotUpdaterStore.setState({
|
|
285
|
-
progress
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
const src_HotUpdater = {
|
|
289
|
-
wrap: wrap,
|
|
290
|
-
reload: reload,
|
|
291
|
-
getAppVersion: getAppVersion,
|
|
292
|
-
getBundleId: getBundleId,
|
|
293
|
-
getMinBundleId: getMinBundleId,
|
|
294
|
-
getChannel: getChannel,
|
|
295
|
-
setChannel: setChannel,
|
|
296
|
-
addListener: addListener,
|
|
297
|
-
checkForUpdate: checkForUpdate,
|
|
298
|
-
runUpdateProcess: runUpdateProcess,
|
|
299
|
-
updateBundle: updateBundle
|
|
300
|
-
};
|
|
301
|
-
export { src_HotUpdater as HotUpdater, hotUpdaterStore, useHotUpdaterStore };
|
package/dist/native.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export type HotUpdaterEvent = {
|
|
2
|
-
onProgress: {
|
|
3
|
-
progress: number;
|
|
4
|
-
};
|
|
5
|
-
};
|
|
6
|
-
export declare const addListener: <T extends keyof HotUpdaterEvent>(eventName: T, listener: (event: HotUpdaterEvent[T]) => void) => () => void;
|
|
7
|
-
/**
|
|
8
|
-
* Downloads files from given URLs.
|
|
9
|
-
*
|
|
10
|
-
* @param {string} bundleId - identifier for the bundle id.
|
|
11
|
-
* @param {string | null} zipUrl - zip file URL. If null, it means rolling back to the built-in bundle
|
|
12
|
-
* @returns {Promise<boolean>} Resolves with true if download was successful, otherwise rejects with an error.
|
|
13
|
-
*/
|
|
14
|
-
export declare const updateBundle: (bundleId: string, zipUrl: string | null) => Promise<boolean>;
|
|
15
|
-
/**
|
|
16
|
-
* Fetches the current app version.
|
|
17
|
-
*/
|
|
18
|
-
export declare const getAppVersion: () => string | null;
|
|
19
|
-
/**
|
|
20
|
-
* Reloads the app.
|
|
21
|
-
*/
|
|
22
|
-
export declare const reload: () => void;
|
|
23
|
-
/**
|
|
24
|
-
* Fetches the minimum bundle id, which represents the initial bundle of the app
|
|
25
|
-
* since it is created at build time.
|
|
26
|
-
*
|
|
27
|
-
* @returns {string} Resolves with the minimum bundle id or null if not available.
|
|
28
|
-
*/
|
|
29
|
-
export declare const getMinBundleId: () => string;
|
|
30
|
-
/**
|
|
31
|
-
* Fetches the current bundle version id.
|
|
32
|
-
*
|
|
33
|
-
* @async
|
|
34
|
-
* @returns {Promise<string>} Resolves with the current version id or null if not available.
|
|
35
|
-
*/
|
|
36
|
-
export declare const getBundleId: () => string;
|
|
37
|
-
/**
|
|
38
|
-
* Sets the channel for the app.
|
|
39
|
-
*/
|
|
40
|
-
export declare const setChannel: (channel: string) => Promise<void>;
|
|
41
|
-
export declare const getChannel: () => string | null;
|