@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
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeEventEmitter, Platform } from "react-native";
|
|
4
|
+
import HotUpdaterNative from "./specs/NativeHotUpdater.js";
|
|
5
|
+
const NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
6
|
+
export const HotUpdaterConstants = {
|
|
7
|
+
OVER_THE_AIR_CHANNEL: __HOT_UPDATER_CHANNEL,
|
|
8
|
+
HOT_UPDATER_BUNDLE_ID: __HOT_UPDATER_BUNDLE_ID || NIL_UUID,
|
|
9
|
+
FINGERPRINT_HASH: Platform.select({
|
|
10
|
+
ios: __HOT_UPDATER_FINGERPRINT_HASH_IOS,
|
|
11
|
+
android: __HOT_UPDATER_FINGERPRINT_HASH_ANDROID,
|
|
12
|
+
default: null
|
|
13
|
+
}),
|
|
14
|
+
UPDATE_STRATEGY: __HOT_UPDATER_UPDATE_STRATEGY
|
|
15
|
+
};
|
|
16
|
+
export const addListener = (eventName, listener) => {
|
|
17
|
+
const eventEmitter = new NativeEventEmitter(HotUpdaterNative);
|
|
18
|
+
const subscription = eventEmitter.addListener(eventName, listener);
|
|
19
|
+
return () => {
|
|
20
|
+
subscription.remove();
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Downloads files and applies them to the app.
|
|
26
|
+
*
|
|
27
|
+
* @param {UpdateParams} params - Parameters object required for bundle update
|
|
28
|
+
* @returns {Promise<boolean>} Resolves with true if download was successful, otherwise rejects with an error.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Use updateBundle(params: UpdateBundleParamsWithStatus) instead
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
export async function updateBundle(paramsOrBundleId, fileUrl) {
|
|
36
|
+
const updateBundleId = typeof paramsOrBundleId === "string" ? paramsOrBundleId : paramsOrBundleId.bundleId;
|
|
37
|
+
const status = typeof paramsOrBundleId === "string" ? "UPDATE" : paramsOrBundleId.status;
|
|
38
|
+
const currentBundleId = getBundleId();
|
|
39
|
+
|
|
40
|
+
// updateBundleId <= currentBundleId
|
|
41
|
+
if (status === "UPDATE" && updateBundleId.localeCompare(currentBundleId) <= 0) {
|
|
42
|
+
throw new Error("Update bundle id is the same as the current bundle id. Preventing infinite update loop.");
|
|
43
|
+
}
|
|
44
|
+
if (typeof paramsOrBundleId === "string") {
|
|
45
|
+
return HotUpdaterNative.updateBundle({
|
|
46
|
+
bundleId: updateBundleId,
|
|
47
|
+
fileUrl: fileUrl || null
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return HotUpdaterNative.updateBundle({
|
|
51
|
+
bundleId: updateBundleId,
|
|
52
|
+
fileUrl: paramsOrBundleId.fileUrl
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Fetches the current app version.
|
|
58
|
+
*/
|
|
59
|
+
export const getAppVersion = () => {
|
|
60
|
+
const constants = HotUpdaterNative.getConstants();
|
|
61
|
+
return constants?.APP_VERSION ?? null;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Reloads the app.
|
|
66
|
+
*/
|
|
67
|
+
export const reload = () => {
|
|
68
|
+
requestAnimationFrame(() => {
|
|
69
|
+
HotUpdaterNative.reload();
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Fetches the minimum bundle id, which represents the initial bundle of the app
|
|
75
|
+
* since it is created at build time.
|
|
76
|
+
*
|
|
77
|
+
* @returns {string} Resolves with the minimum bundle id or null if not available.
|
|
78
|
+
*/
|
|
79
|
+
export const getMinBundleId = () => {
|
|
80
|
+
const constants = HotUpdaterNative.getConstants();
|
|
81
|
+
return constants.MIN_BUNDLE_ID;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Fetches the current bundle version id.
|
|
86
|
+
*
|
|
87
|
+
* @async
|
|
88
|
+
* @returns {Promise<string>} Resolves with the current version id or null if not available.
|
|
89
|
+
*/
|
|
90
|
+
export const getBundleId = () => {
|
|
91
|
+
return HotUpdaterConstants.HOT_UPDATER_BUNDLE_ID === NIL_UUID ? getMinBundleId() : HotUpdaterConstants.HOT_UPDATER_BUNDLE_ID;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Fetches the channel for the app.
|
|
96
|
+
*
|
|
97
|
+
* @returns {string} Resolves with the channel or null if not available.
|
|
98
|
+
*/
|
|
99
|
+
export const getChannel = () => {
|
|
100
|
+
if (HotUpdaterConstants.OVER_THE_AIR_CHANNEL) {
|
|
101
|
+
return HotUpdaterConstants.OVER_THE_AIR_CHANNEL;
|
|
102
|
+
}
|
|
103
|
+
const constants = HotUpdaterNative.getConstants();
|
|
104
|
+
return constants.CHANNEL;
|
|
105
|
+
};
|
|
106
|
+
export const getReleaseChannel = () => {
|
|
107
|
+
const constants = HotUpdaterNative.getConstants();
|
|
108
|
+
return constants.CHANNEL;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Fetches the fingerprint for the app.
|
|
113
|
+
*
|
|
114
|
+
* @returns {string | null} Resolves with the fingerprint hash
|
|
115
|
+
*/
|
|
116
|
+
export const getFingerprintHash = () => {
|
|
117
|
+
return HotUpdaterConstants.FINGERPRINT_HASH;
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","Platform","HotUpdaterNative","NIL_UUID","HotUpdaterConstants","OVER_THE_AIR_CHANNEL","__HOT_UPDATER_CHANNEL","HOT_UPDATER_BUNDLE_ID","__HOT_UPDATER_BUNDLE_ID","FINGERPRINT_HASH","select","ios","__HOT_UPDATER_FINGERPRINT_HASH_IOS","android","__HOT_UPDATER_FINGERPRINT_HASH_ANDROID","default","UPDATE_STRATEGY","__HOT_UPDATER_UPDATE_STRATEGY","addListener","eventName","listener","eventEmitter","subscription","remove","updateBundle","paramsOrBundleId","fileUrl","updateBundleId","bundleId","status","currentBundleId","getBundleId","localeCompare","Error","getAppVersion","constants","getConstants","APP_VERSION","reload","requestAnimationFrame","getMinBundleId","MIN_BUNDLE_ID","getChannel","CHANNEL","getReleaseChannel","getFingerprintHash"],"sourceRoot":"../../src","sources":["native.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { checkForUpdate } from "./checkForUpdate.js";
|
|
4
|
+
import { getBundleId, reload } from "./native.js";
|
|
5
|
+
/**
|
|
6
|
+
* Manually checks and applies updates for the application.
|
|
7
|
+
*
|
|
8
|
+
* @param {RunUpdateProcessConfig} config - Update process configuration
|
|
9
|
+
* @param {string} config.source - Update server URL
|
|
10
|
+
* @param {Record<string, string>} [config.requestHeaders] - Request headers
|
|
11
|
+
* @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Auto reload on force update
|
|
16
|
+
* const result = await HotUpdater.runUpdateProcess({
|
|
17
|
+
* source: "<your-update-server-url>",
|
|
18
|
+
* requestHeaders: {
|
|
19
|
+
* // Add necessary headers
|
|
20
|
+
* },
|
|
21
|
+
* reloadOnForceUpdate: true
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Manually handle reload on force update
|
|
25
|
+
* const result = await HotUpdater.runUpdateProcess({
|
|
26
|
+
* source: "<your-update-server-url>",
|
|
27
|
+
* reloadOnForceUpdate: false
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
|
|
31
|
+
* HotUpdater.reload();
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @returns {Promise<RunUpdateProcessResponse>} The result of the update process
|
|
36
|
+
*/
|
|
37
|
+
export const runUpdateProcess = async ({
|
|
38
|
+
reloadOnForceUpdate = true,
|
|
39
|
+
...checkForUpdateOptions
|
|
40
|
+
}) => {
|
|
41
|
+
const updateInfo = await checkForUpdate(checkForUpdateOptions);
|
|
42
|
+
if (!updateInfo) {
|
|
43
|
+
return {
|
|
44
|
+
status: "UP_TO_DATE",
|
|
45
|
+
shouldForceUpdate: false,
|
|
46
|
+
message: null,
|
|
47
|
+
id: getBundleId()
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const isUpdated = await updateInfo.updateBundle();
|
|
51
|
+
if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) {
|
|
52
|
+
reload();
|
|
53
|
+
}
|
|
54
|
+
if (!isUpdated) {
|
|
55
|
+
throw new Error("New update was found but failed to download the bundle.");
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
status: updateInfo.status,
|
|
59
|
+
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
60
|
+
id: updateInfo.id,
|
|
61
|
+
message: updateInfo.message
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=runUpdateProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["checkForUpdate","getBundleId","reload","runUpdateProcess","reloadOnForceUpdate","checkForUpdateOptions","updateInfo","status","shouldForceUpdate","message","id","isUpdated","updateBundle","Error"],"sourceRoot":"../../src","sources":["runUpdateProcess.ts"],"mappings":";;AAAA,SAAqCA,cAAc,QAAQ,qBAAkB;AAC7E,SAASC,WAAW,EAAEC,MAAM,QAAQ,aAAU;AAkB9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAAO;EACrCC,mBAAmB,GAAG,IAAI;EAC1B,GAAGC;AACoB,CAAC,KAAwC;EAChE,MAAMC,UAAU,GAAG,MAAMN,cAAc,CAACK,qBAAqB,CAAC;EAC9D,IAAI,CAACC,UAAU,EAAE;IACf,OAAO;MACLC,MAAM,EAAE,YAAY;MACpBC,iBAAiB,EAAE,KAAK;MACxBC,OAAO,EAAE,IAAI;MACbC,EAAE,EAAET,WAAW,CAAC;IAClB,CAAC;EACH;EAEA,MAAMU,SAAS,GAAG,MAAML,UAAU,CAACM,YAAY,CAAC,CAAC;EACjD,IAAID,SAAS,IAAIL,UAAU,CAACE,iBAAiB,IAAIJ,mBAAmB,EAAE;IACpEF,MAAM,CAAC,CAAC;EACV;EAEA,IAAI,CAACS,SAAS,EAAE;IACd,MAAM,IAAIE,KAAK,CAAC,yDAAyD,CAAC;EAC5E;EACA,OAAO;IACLN,MAAM,EAAED,UAAU,CAACC,MAAM;IACzBC,iBAAiB,EAAEF,UAAU,CAACE,iBAAiB;IAC/CE,EAAE,EAAEJ,UAAU,CAACI,EAAE;IACjBD,OAAO,EAAEH,UAAU,CAACG;EACtB,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../src","sources":["specs/NativeHotUpdater.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAsBlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,YAAY,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import useSyncExternalStoreExports from "use-sync-external-store/shim/with-selector";
|
|
4
|
+
const {
|
|
5
|
+
useSyncExternalStoreWithSelector
|
|
6
|
+
} = useSyncExternalStoreExports;
|
|
7
|
+
const createHotUpdaterStore = () => {
|
|
8
|
+
let state = {
|
|
9
|
+
progress: 0,
|
|
10
|
+
isBundleUpdated: false
|
|
11
|
+
};
|
|
12
|
+
const getSnapshot = () => {
|
|
13
|
+
return state;
|
|
14
|
+
};
|
|
15
|
+
const listeners = new Set();
|
|
16
|
+
const emitChange = () => {
|
|
17
|
+
for (const listener of listeners) {
|
|
18
|
+
listener();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const setState = newState => {
|
|
22
|
+
state = {
|
|
23
|
+
...state,
|
|
24
|
+
...newState
|
|
25
|
+
};
|
|
26
|
+
emitChange();
|
|
27
|
+
};
|
|
28
|
+
const subscribe = listener => {
|
|
29
|
+
listeners.add(listener);
|
|
30
|
+
return () => listeners.delete(listener);
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
getSnapshot,
|
|
34
|
+
setState,
|
|
35
|
+
subscribe
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export const hotUpdaterStore = createHotUpdaterStore();
|
|
39
|
+
export const useHotUpdaterStore = (selector = snapshot => snapshot) => {
|
|
40
|
+
return useSyncExternalStoreWithSelector(hotUpdaterStore.subscribe, hotUpdaterStore.getSnapshot, hotUpdaterStore.getSnapshot, selector);
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSyncExternalStoreExports","useSyncExternalStoreWithSelector","createHotUpdaterStore","state","progress","isBundleUpdated","getSnapshot","listeners","Set","emitChange","listener","setState","newState","subscribe","add","delete","hotUpdaterStore","useHotUpdaterStore","selector","snapshot"],"sourceRoot":"../../src","sources":["store.ts"],"mappings":";;AAAA,OAAOA,2BAA2B,MAAM,4CAA4C;AAMpF,MAAM;EAAEC;AAAiC,CAAC,GAAGD,2BAA2B;AAExE,MAAME,qBAAqB,GAAGA,CAAA,KAAM;EAClC,IAAIC,KAAsB,GAAG;IAC3BC,QAAQ,EAAE,CAAC;IACXC,eAAe,EAAE;EACnB,CAAC;EAED,MAAMC,WAAW,GAAGA,CAAA,KAAM;IACxB,OAAOH,KAAK;EACd,CAAC;EAED,MAAMI,SAAS,GAAG,IAAIC,GAAG,CAAa,CAAC;EAEvC,MAAMC,UAAU,GAAGA,CAAA,KAAM;IACvB,KAAK,MAAMC,QAAQ,IAAIH,SAAS,EAAE;MAChCG,QAAQ,CAAC,CAAC;IACZ;EACF,CAAC;EAED,MAAMC,QAAQ,GAAIC,QAAkC,IAAK;IACvDT,KAAK,GAAG;MACN,GAAGA,KAAK;MACR,GAAGS;IACL,CAAC;IACDH,UAAU,CAAC,CAAC;EACd,CAAC;EAED,MAAMI,SAAS,GAAIH,QAAoB,IAAK;IAC1CH,SAAS,CAACO,GAAG,CAACJ,QAAQ,CAAC;IACvB,OAAO,MAAMH,SAAS,CAACQ,MAAM,CAACL,QAAQ,CAAC;EACzC,CAAC;EAED,OAAO;IAAEJ,WAAW;IAAEK,QAAQ;IAAEE;EAAU,CAAC;AAC7C,CAAC;AAED,OAAO,MAAMG,eAAe,GAAGd,qBAAqB,CAAC,CAAC;AAEtD,OAAO,MAAMe,kBAAkB,GAAGA,CAChCC,QAA0C,GAAIC,QAAQ,IAAKA,QAAa,KACrE;EACH,OAAOlB,gCAAgC,CACrCe,eAAe,CAACH,SAAS,EACzBG,eAAe,CAACV,WAAW,EAC3BU,eAAe,CAACV,WAAW,EAC3BY,QACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { useEffect, useLayoutEffect, useState } from "react";
|
|
5
|
+
import { checkForUpdate } from "./checkForUpdate.js";
|
|
6
|
+
import { useEventCallback } from "./hooks/useEventCallback.js";
|
|
7
|
+
import { getBundleId, reload } from "./native.js";
|
|
8
|
+
import { useHotUpdaterStore } from "./store.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
export function wrap(options) {
|
|
11
|
+
const {
|
|
12
|
+
reloadOnForceUpdate = true,
|
|
13
|
+
...restOptions
|
|
14
|
+
} = options;
|
|
15
|
+
return WrappedComponent => {
|
|
16
|
+
const HotUpdaterHOC = props => {
|
|
17
|
+
const progress = useHotUpdaterStore(state => state.progress);
|
|
18
|
+
const [message, setMessage] = useState(null);
|
|
19
|
+
const [updateStatus, setUpdateStatus] = useState("CHECK_FOR_UPDATE");
|
|
20
|
+
const initHotUpdater = useEventCallback(async () => {
|
|
21
|
+
try {
|
|
22
|
+
setUpdateStatus("CHECK_FOR_UPDATE");
|
|
23
|
+
const updateInfo = await checkForUpdate({
|
|
24
|
+
source: restOptions.source,
|
|
25
|
+
requestHeaders: restOptions.requestHeaders,
|
|
26
|
+
onError: restOptions.onError
|
|
27
|
+
});
|
|
28
|
+
setMessage(updateInfo?.message ?? null);
|
|
29
|
+
if (!updateInfo) {
|
|
30
|
+
restOptions.onUpdateProcessCompleted?.({
|
|
31
|
+
status: "UP_TO_DATE",
|
|
32
|
+
shouldForceUpdate: false,
|
|
33
|
+
message: null,
|
|
34
|
+
id: getBundleId()
|
|
35
|
+
});
|
|
36
|
+
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (updateInfo.shouldForceUpdate === false) {
|
|
40
|
+
void updateInfo.updateBundle().catch(error => {
|
|
41
|
+
restOptions.onError?.(error);
|
|
42
|
+
});
|
|
43
|
+
restOptions.onUpdateProcessCompleted?.({
|
|
44
|
+
id: updateInfo.id,
|
|
45
|
+
status: updateInfo.status,
|
|
46
|
+
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
47
|
+
message: updateInfo.message
|
|
48
|
+
});
|
|
49
|
+
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// Force Update Scenario
|
|
53
|
+
setUpdateStatus("UPDATING");
|
|
54
|
+
const isSuccess = await updateInfo.updateBundle();
|
|
55
|
+
if (!isSuccess) {
|
|
56
|
+
throw new Error("New update was found but failed to download the bundle.");
|
|
57
|
+
}
|
|
58
|
+
if (reloadOnForceUpdate) {
|
|
59
|
+
reload();
|
|
60
|
+
}
|
|
61
|
+
restOptions.onUpdateProcessCompleted?.({
|
|
62
|
+
id: updateInfo.id,
|
|
63
|
+
status: updateInfo.status,
|
|
64
|
+
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
65
|
+
message: updateInfo.message
|
|
66
|
+
});
|
|
67
|
+
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
68
|
+
} catch (error) {
|
|
69
|
+
restOptions.onError?.(error);
|
|
70
|
+
setUpdateStatus("UPDATE_PROCESS_COMPLETED");
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
restOptions.onProgress?.(progress);
|
|
75
|
+
}, [progress]);
|
|
76
|
+
useLayoutEffect(() => {
|
|
77
|
+
initHotUpdater();
|
|
78
|
+
}, []);
|
|
79
|
+
if (restOptions.fallbackComponent && updateStatus !== "UPDATE_PROCESS_COMPLETED") {
|
|
80
|
+
const Fallback = restOptions.fallbackComponent;
|
|
81
|
+
return /*#__PURE__*/_jsx(Fallback, {
|
|
82
|
+
progress: progress,
|
|
83
|
+
status: updateStatus,
|
|
84
|
+
message: message
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return /*#__PURE__*/_jsx(WrappedComponent, {
|
|
88
|
+
...props
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
return HotUpdaterHOC;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=wrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","useLayoutEffect","useState","checkForUpdate","useEventCallback","getBundleId","reload","useHotUpdaterStore","jsx","_jsx","wrap","options","reloadOnForceUpdate","restOptions","WrappedComponent","HotUpdaterHOC","props","progress","state","message","setMessage","updateStatus","setUpdateStatus","initHotUpdater","updateInfo","source","requestHeaders","onError","onUpdateProcessCompleted","status","shouldForceUpdate","id","updateBundle","catch","error","isSuccess","Error","onProgress","fallbackComponent","Fallback"],"sourceRoot":"../../src","sources":["wrap.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AppUpdateInfo, GetBundlesArgs } from "@hot-updater/core";
|
|
2
|
+
import { type UpdateSource } from "./fetchUpdateInfo";
|
|
3
|
+
export interface CheckForUpdateOptions {
|
|
4
|
+
source: UpdateSource;
|
|
5
|
+
requestHeaders?: Record<string, string>;
|
|
6
|
+
onError?: (error: Error) => void;
|
|
7
|
+
/**
|
|
8
|
+
* The timeout duration for the request.
|
|
9
|
+
* @default 5000
|
|
10
|
+
*/
|
|
11
|
+
requestTimeout?: number;
|
|
12
|
+
}
|
|
13
|
+
export type CheckForUpdateResult = AppUpdateInfo & {
|
|
14
|
+
/**
|
|
15
|
+
* Updates the bundle.
|
|
16
|
+
* This method is equivalent to `HotUpdater.updateBundle()` but with all required arguments pre-filled.
|
|
17
|
+
*/
|
|
18
|
+
updateBundle: () => Promise<boolean>;
|
|
19
|
+
};
|
|
20
|
+
export declare function checkForUpdate(options: CheckForUpdateOptions): Promise<CheckForUpdateResult | null>;
|
|
21
|
+
export declare const getUpdateSource: (baseUrl: string) => (args: GetBundlesArgs) => string;
|
|
22
|
+
//# sourceMappingURL=checkForUpdate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkForUpdate.d.ts","sourceRoot":"","sources":["../../../src/checkForUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGvE,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,mBAAmB,CAAC;AAUvE,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,YAAY,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD;;;OAGG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACtC,CAAC;AAEF,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CA8DtC;AAED,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,MAAM,MAAM,cAAc,WASxE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/error.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AppUpdateInfo, GetBundlesArgs } from "@hot-updater/core";
|
|
2
|
+
export type UpdateSource = string | ((args: GetBundlesArgs) => Promise<AppUpdateInfo | null>) | ((args: GetBundlesArgs) => string);
|
|
3
|
+
export declare const fetchUpdateInfo: (source: UpdateSource, args: GetBundlesArgs, requestHeaders?: Record<string, string>, onError?: (error: Error) => void, requestTimeout?: number) => Promise<AppUpdateInfo | null>;
|
|
4
|
+
//# sourceMappingURL=fetchUpdateInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchUpdateInfo.d.ts","sourceRoot":"","sources":["../../../src/fetchUpdateInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,CAAC,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,GACzD,CAAC,CAAC,IAAI,EAAE,cAAc,KAAK,MAAM,CAAC,CAAC;AAEvC,eAAO,MAAM,eAAe,GAC1B,QAAQ,YAAY,EACpB,MAAM,cAAc,EACpB,iBAAiB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACvC,UAAU,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAChC,uBAAqB,KACpB,OAAO,CAAC,aAAa,GAAG,IAAI,CA+D9B,CAAC"}
|
|
@@ -2,3 +2,4 @@ type EventCallback<Args extends unknown[], R> = ((...args: Args) => R) | undefin
|
|
|
2
2
|
export declare function useEventCallback<Args extends unknown[], R>(fn: (...args: Args) => R): (...args: Args) => R;
|
|
3
3
|
export declare function useEventCallback<Args extends unknown[], R>(fn: EventCallback<Args, R>): EventCallback<Args, R>;
|
|
4
4
|
export {};
|
|
5
|
+
//# sourceMappingURL=useEventCallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventCallback.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useEventCallback.ts"],"names":[],"mappings":"AAEA,KAAK,aAAa,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,IACxC,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC,GACtB,SAAS,CAAC;AAEd,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,EACxD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,GACvB,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC;AACxB,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,EACxD,EAAE,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,GACzB,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { checkForUpdate } from "./checkForUpdate";
|
|
2
|
+
import { updateBundle } from "./native";
|
|
2
3
|
import { wrap } from "./wrap";
|
|
3
4
|
export type { HotUpdaterOptions } from "./wrap";
|
|
4
5
|
export type { HotUpdaterEvent } from "./native";
|
|
@@ -44,24 +45,31 @@ export declare const HotUpdater: {
|
|
|
44
45
|
*/
|
|
45
46
|
getMinBundleId: () => string;
|
|
46
47
|
/**
|
|
47
|
-
* Fetches the current
|
|
48
|
+
* Fetches the current channel of the app.
|
|
48
49
|
*
|
|
49
|
-
*
|
|
50
|
-
* If the app is running in development mode, the channel will be `null`.
|
|
51
|
-
*
|
|
52
|
-
* @returns {string | null} The current release channel of the app
|
|
50
|
+
* If no channel is specified, the app is assigned to the 'production' channel.
|
|
53
51
|
*
|
|
52
|
+
* @returns {string} The current release channel of the app
|
|
53
|
+
* @default "production"
|
|
54
54
|
* @example
|
|
55
55
|
* ```ts
|
|
56
56
|
* const channel = HotUpdater.getChannel();
|
|
57
57
|
* console.log(`Current channel: ${channel}`);
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
-
getChannel: () => string
|
|
60
|
+
getChannel: () => string;
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* The initial channel of the native app.
|
|
63
|
+
*
|
|
64
|
+
* @returns {string} The current release channel of the app
|
|
65
|
+
* @default "production"
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const channel = HotUpdater.getReleaseChannel();
|
|
69
|
+
* console.log(`Current release channel: ${channel}`);
|
|
70
|
+
* ```
|
|
63
71
|
*/
|
|
64
|
-
|
|
72
|
+
getReleaseChannel: () => string;
|
|
65
73
|
/**
|
|
66
74
|
* Adds a listener to HotUpdater events.
|
|
67
75
|
*
|
|
@@ -146,8 +154,9 @@ export declare const HotUpdater: {
|
|
|
146
154
|
/**
|
|
147
155
|
* Updates the bundle of the app.
|
|
148
156
|
*
|
|
149
|
-
* @param {
|
|
150
|
-
* @param {string}
|
|
157
|
+
* @param {UpdateBundleParams} params - Parameters object required for bundle update
|
|
158
|
+
* @param {string} params.bundleId - The bundle ID of the app
|
|
159
|
+
* @param {string|null} params.fileUrl - The URL of the zip file
|
|
151
160
|
*
|
|
152
161
|
* @returns {Promise<boolean>} Whether the update was successful
|
|
153
162
|
*
|
|
@@ -166,11 +175,28 @@ export declare const HotUpdater: {
|
|
|
166
175
|
* };
|
|
167
176
|
* }
|
|
168
177
|
*
|
|
169
|
-
* await HotUpdater.updateBundle(
|
|
178
|
+
* await HotUpdater.updateBundle({
|
|
179
|
+
* bundleId: updateInfo.id,
|
|
180
|
+
* fileUrl: updateInfo.fileUrl
|
|
181
|
+
* });
|
|
170
182
|
* if (updateInfo.shouldForceUpdate) {
|
|
171
183
|
* HotUpdater.reload();
|
|
172
184
|
* }
|
|
173
185
|
* ```
|
|
174
186
|
*/
|
|
175
|
-
updateBundle:
|
|
187
|
+
updateBundle: typeof updateBundle;
|
|
188
|
+
/**
|
|
189
|
+
* Fetches the fingerprint of the app.
|
|
190
|
+
*
|
|
191
|
+
* @returns {string} The fingerprint of the app
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const fingerprint = HotUpdater.getFingerprintHash();
|
|
196
|
+
* console.log(`Fingerprint: ${fingerprint}`);
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
getFingerprintHash: () => string | null;
|
|
176
200
|
};
|
|
201
|
+
export { getUpdateSource } from "./checkForUpdate";
|
|
202
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EASL,YAAY,EACb,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,cAAc,SAAS,CAAC;AAQxB,eAAO,MAAM,UAAU;IACrB;;;;;;;;;;;;;;;;;;;;;OAqBG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;;;;;;;;;OAYG;;IAEH;;;;;;;;;;OAUG;;IAEH;;;;;;;;;;;;;;;;OAgBG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;;IAEH;;;;;;;;;;OAUG;;CAEJ,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { UpdateStatus, UpdateStrategy } from "@hot-updater/core";
|
|
2
|
+
import { type UpdateBundleParams } from "./specs/NativeHotUpdater";
|
|
3
|
+
export declare const HotUpdaterConstants: {
|
|
4
|
+
OVER_THE_AIR_CHANNEL: string | null;
|
|
5
|
+
HOT_UPDATER_BUNDLE_ID: string;
|
|
6
|
+
FINGERPRINT_HASH: string | null;
|
|
7
|
+
UPDATE_STRATEGY: UpdateStrategy;
|
|
8
|
+
};
|
|
9
|
+
export type HotUpdaterEvent = {
|
|
10
|
+
onProgress: {
|
|
11
|
+
progress: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const addListener: <T extends keyof HotUpdaterEvent>(eventName: T, listener: (event: HotUpdaterEvent[T]) => void) => () => void;
|
|
15
|
+
export type UpdateParams = UpdateBundleParams & {
|
|
16
|
+
status: UpdateStatus;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Downloads files and applies them to the app.
|
|
20
|
+
*
|
|
21
|
+
* @param {UpdateParams} params - Parameters object required for bundle update
|
|
22
|
+
* @returns {Promise<boolean>} Resolves with true if download was successful, otherwise rejects with an error.
|
|
23
|
+
*/
|
|
24
|
+
export declare function updateBundle(params: UpdateParams): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use updateBundle(params: UpdateBundleParamsWithStatus) instead
|
|
27
|
+
*/
|
|
28
|
+
export declare function updateBundle(bundleId: string, fileUrl: string | null): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Fetches the current app version.
|
|
31
|
+
*/
|
|
32
|
+
export declare const getAppVersion: () => string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Reloads the app.
|
|
35
|
+
*/
|
|
36
|
+
export declare const reload: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Fetches the minimum bundle id, which represents the initial bundle of the app
|
|
39
|
+
* since it is created at build time.
|
|
40
|
+
*
|
|
41
|
+
* @returns {string} Resolves with the minimum bundle id or null if not available.
|
|
42
|
+
*/
|
|
43
|
+
export declare const getMinBundleId: () => string;
|
|
44
|
+
/**
|
|
45
|
+
* Fetches the current bundle version id.
|
|
46
|
+
*
|
|
47
|
+
* @async
|
|
48
|
+
* @returns {Promise<string>} Resolves with the current version id or null if not available.
|
|
49
|
+
*/
|
|
50
|
+
export declare const getBundleId: () => string;
|
|
51
|
+
/**
|
|
52
|
+
* Fetches the channel for the app.
|
|
53
|
+
*
|
|
54
|
+
* @returns {string} Resolves with the channel or null if not available.
|
|
55
|
+
*/
|
|
56
|
+
export declare const getChannel: () => string;
|
|
57
|
+
export declare const getReleaseChannel: () => string;
|
|
58
|
+
/**
|
|
59
|
+
* Fetches the fingerprint for the app.
|
|
60
|
+
*
|
|
61
|
+
* @returns {string | null} Resolves with the fingerprint hash
|
|
62
|
+
*/
|
|
63
|
+
export declare const getFingerprintHash: () => string | null;
|
|
64
|
+
//# sourceMappingURL=native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAyB,EACvB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAUlC,eAAO,MAAM,mBAAmB;;;;;CAS/B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,eAAe,EACzD,WAAW,CAAC,EACZ,UAAU,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,eAQ9C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG;IAC9C,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC3E;;GAEG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,OAAO,CAAC,CAAC;AAqCpB;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,MAAM,GAAG,IAGzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,YAIlB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAO,MAGjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAO,MAI9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAAO,MAM7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAO,MAGpC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAO,MAAM,GAAG,IAE9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -46,3 +46,4 @@ export interface RunUpdateProcessOptions extends CheckForUpdateOptions {
|
|
|
46
46
|
* @returns {Promise<RunUpdateProcessResponse>} The result of the update process
|
|
47
47
|
*/
|
|
48
48
|
export declare const runUpdateProcess: ({ reloadOnForceUpdate, ...checkForUpdateOptions }: RunUpdateProcessOptions) => Promise<RunUpdateProcessResponse>;
|
|
49
|
+
//# sourceMappingURL=runUpdateProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runUpdateProcess.d.ts","sourceRoot":"","sources":["../../../src/runUpdateProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAkB,MAAM,kBAAkB,CAAC;AAG9E,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,YAAY,CAAC;IAC7C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,gBAAgB,GAAU,mDAGpC,uBAAuB,KAAG,OAAO,CAAC,wBAAwB,CAyB5D,CAAC"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import type { TurboModule } from "react-native";
|
|
2
|
+
export interface UpdateBundleParams {
|
|
3
|
+
bundleId: string;
|
|
4
|
+
fileUrl: string | null;
|
|
5
|
+
}
|
|
2
6
|
export interface Spec extends TurboModule {
|
|
3
7
|
reload(): void;
|
|
4
|
-
updateBundle(
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
* use getConstants().APP_VERSION instead
|
|
8
|
-
*/
|
|
9
|
-
getAppVersion(): Promise<string | null>;
|
|
10
|
-
setChannel(channel: string): Promise<void>;
|
|
8
|
+
updateBundle(params: UpdateBundleParams): Promise<boolean>;
|
|
11
9
|
addListener(eventName: string): void;
|
|
12
10
|
removeListeners(count: number): void;
|
|
13
11
|
readonly getConstants: () => {
|
|
14
12
|
MIN_BUNDLE_ID: string;
|
|
15
13
|
APP_VERSION: string | null;
|
|
16
|
-
CHANNEL: string
|
|
14
|
+
CHANNEL: string;
|
|
17
15
|
};
|
|
18
16
|
}
|
|
19
|
-
declare const _default: Spec
|
|
17
|
+
declare const _default: Spec;
|
|
20
18
|
export default _default;
|
|
19
|
+
//# sourceMappingURL=NativeHotUpdater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeHotUpdater.d.ts","sourceRoot":"","sources":["../../../../src/specs/NativeHotUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IAEvC,MAAM,IAAI,IAAI,CAAC;IACf,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAG3D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,MAAM;QAC3B,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;;AAED,wBAAoE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/store.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAsCF,eAAO,MAAM,eAAe;;yBAhBE,OAAO,CAAC,eAAe,CAAC;0BAQvB,MAAM,IAAI;CAQa,CAAC;AAEvD,eAAO,MAAM,kBAAkB,GAAI,CAAC,GAAG,eAAe,EACpD,WAAU,CAAC,QAAQ,EAAE,eAAe,KAAK,CAA+B,MAQzE,CAAC"}
|