@hot-updater/react-native 0.23.1 → 0.24.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/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +393 -49
- package/android/src/main/java/com/hotupdater/BundleMetadata.kt +204 -0
- package/android/src/main/java/com/hotupdater/HotUpdater.kt +48 -36
- package/android/src/main/java/com/hotupdater/HotUpdaterException.kt +134 -0
- package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +168 -95
- package/android/src/main/java/com/hotupdater/OkHttpDownloadService.kt +15 -3
- package/android/src/main/java/com/hotupdater/SignatureVerifier.kt +17 -12
- package/android/src/newarch/HotUpdaterModule.kt +88 -23
- package/android/src/oldarch/HotUpdaterModule.kt +89 -22
- package/android/src/oldarch/HotUpdaterSpec.kt +6 -0
- package/ios/HotUpdater/Internal/BundleFileStorageService.swift +401 -77
- package/ios/HotUpdater/Internal/BundleMetadata.swift +177 -0
- package/ios/HotUpdater/Internal/HotUpdater.mm +213 -47
- package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +96 -25
- package/ios/HotUpdater/Internal/SignatureVerifier.swift +35 -29
- package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +2 -2
- package/ios/HotUpdater/Public/HotUpdater.h +8 -2
- package/lib/commonjs/DefaultResolver.js +38 -0
- package/lib/commonjs/DefaultResolver.js.map +1 -0
- package/lib/commonjs/checkForUpdate.js +33 -45
- package/lib/commonjs/checkForUpdate.js.map +1 -1
- package/lib/commonjs/error.js +45 -1
- package/lib/commonjs/error.js.map +1 -1
- package/lib/commonjs/fetchUpdateInfo.js +7 -45
- package/lib/commonjs/fetchUpdateInfo.js.map +1 -1
- package/lib/commonjs/index.js +249 -208
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native.js +103 -3
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
- package/lib/commonjs/types.js +12 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/wrap.js +70 -1
- package/lib/commonjs/wrap.js.map +1 -1
- package/lib/module/DefaultResolver.js +34 -0
- package/lib/module/DefaultResolver.js.map +1 -0
- package/lib/module/checkForUpdate.js +34 -43
- package/lib/module/checkForUpdate.js.map +1 -1
- package/lib/module/error.js +45 -0
- package/lib/module/error.js.map +1 -1
- package/lib/module/fetchUpdateInfo.js +7 -45
- package/lib/module/fetchUpdateInfo.js.map +1 -1
- package/lib/module/index.js +250 -203
- package/lib/module/index.js.map +1 -1
- package/lib/module/native.js +87 -2
- package/lib/module/native.js.map +1 -1
- package/lib/module/specs/NativeHotUpdater.js.map +1 -1
- package/lib/module/types.js +12 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/wrap.js +71 -2
- package/lib/module/wrap.js.map +1 -1
- package/lib/typescript/commonjs/DefaultResolver.d.ts +10 -0
- package/lib/typescript/commonjs/DefaultResolver.d.ts.map +1 -0
- package/lib/typescript/commonjs/checkForUpdate.d.ts +12 -13
- package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
- package/lib/typescript/commonjs/error.d.ts +120 -0
- package/lib/typescript/commonjs/error.d.ts.map +1 -1
- package/lib/typescript/commonjs/fetchUpdateInfo.d.ts +3 -5
- package/lib/typescript/commonjs/fetchUpdateInfo.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +38 -44
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/native.d.ts +58 -2
- package/lib/typescript/commonjs/native.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +62 -0
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +115 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/wrap.d.ts +132 -7
- package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
- package/lib/typescript/module/DefaultResolver.d.ts +10 -0
- package/lib/typescript/module/DefaultResolver.d.ts.map +1 -0
- package/lib/typescript/module/checkForUpdate.d.ts +12 -13
- package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
- package/lib/typescript/module/error.d.ts +120 -0
- package/lib/typescript/module/error.d.ts.map +1 -1
- package/lib/typescript/module/fetchUpdateInfo.d.ts +3 -5
- package/lib/typescript/module/fetchUpdateInfo.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +38 -44
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/native.d.ts +58 -2
- package/lib/typescript/module/native.d.ts.map +1 -1
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts +62 -0
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +115 -0
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/wrap.d.ts +132 -7
- package/lib/typescript/module/wrap.d.ts.map +1 -1
- package/package.json +6 -6
- package/plugin/build/withHotUpdater.js +3 -3
- package/src/DefaultResolver.ts +36 -0
- package/src/checkForUpdate.ts +51 -56
- package/src/error.ts +153 -0
- package/src/fetchUpdateInfo.ts +10 -58
- package/src/index.ts +315 -206
- package/src/native.ts +88 -2
- package/src/specs/NativeHotUpdater.ts +63 -0
- package/src/types.ts +135 -0
- package/src/wrap.tsx +245 -34
- package/android/src/main/java/com/hotupdater/HotUpdaterFactory.kt +0 -52
- package/ios/HotUpdater/Internal/HotUpdaterFactory.swift +0 -24
- package/lib/commonjs/runUpdateProcess.js +0 -69
- package/lib/commonjs/runUpdateProcess.js.map +0 -1
- package/lib/module/runUpdateProcess.js +0 -64
- package/lib/module/runUpdateProcess.js.map +0 -1
- package/lib/typescript/commonjs/runUpdateProcess.d.ts +0 -49
- package/lib/typescript/commonjs/runUpdateProcess.d.ts.map +0 -1
- package/lib/typescript/module/runUpdateProcess.d.ts +0 -49
- package/lib/typescript/module/runUpdateProcess.d.ts.map +0 -1
- package/src/runUpdateProcess.ts +0 -80
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { UpdateStatus } from "@hot-updater/core";
|
|
2
|
+
import { HotUpdaterErrorCode, isHotUpdaterError } from "./error";
|
|
2
3
|
import { type UpdateBundleParams } from "./specs/NativeHotUpdater";
|
|
4
|
+
export { HotUpdaterErrorCode, isHotUpdaterError };
|
|
3
5
|
export declare const HotUpdaterConstants: {
|
|
4
6
|
HOT_UPDATER_BUNDLE_ID: string;
|
|
5
7
|
};
|
|
@@ -16,7 +18,8 @@ export type UpdateParams = UpdateBundleParams & {
|
|
|
16
18
|
* Downloads files and applies them to the app.
|
|
17
19
|
*
|
|
18
20
|
* @param {UpdateParams} params - Parameters object required for bundle update
|
|
19
|
-
* @returns {Promise<boolean>} Resolves with true if download was successful
|
|
21
|
+
* @returns {Promise<boolean>} Resolves with true if download was successful
|
|
22
|
+
* @throws {Error} Rejects with error.code from HotUpdaterErrorCode enum and error.message
|
|
20
23
|
*/
|
|
21
24
|
export declare function updateBundle(params: UpdateParams): Promise<boolean>;
|
|
22
25
|
/**
|
|
@@ -42,7 +45,7 @@ export declare const getMinBundleId: () => string;
|
|
|
42
45
|
* Fetches the current bundle version id.
|
|
43
46
|
*
|
|
44
47
|
* @async
|
|
45
|
-
* @returns {
|
|
48
|
+
* @returns {string} Resolves with the current version id or null if not available.
|
|
46
49
|
*/
|
|
47
50
|
export declare const getBundleId: () => string;
|
|
48
51
|
/**
|
|
@@ -57,4 +60,57 @@ export declare const getChannel: () => string;
|
|
|
57
60
|
* @returns {string | null} Resolves with the fingerprint hash
|
|
58
61
|
*/
|
|
59
62
|
export declare const getFingerprintHash: () => string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Result returned by notifyAppReady()
|
|
65
|
+
*/
|
|
66
|
+
export type NotifyAppReadyResult = {
|
|
67
|
+
status: "PROMOTED" | "RECOVERED" | "STABLE";
|
|
68
|
+
crashedBundleId?: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Notifies the native side that the app has successfully started with the current bundle.
|
|
72
|
+
* If the bundle matches the staging bundle, it promotes to stable.
|
|
73
|
+
*
|
|
74
|
+
* This function is called automatically when the module loads.
|
|
75
|
+
*
|
|
76
|
+
* @returns {NotifyAppReadyResult} Bundle state information
|
|
77
|
+
* - `status: "PROMOTED"` - Staging bundle was promoted to stable (ACTIVE event)
|
|
78
|
+
* - `status: "RECOVERED"` - App recovered from crash, rollback occurred (ROLLBACK event)
|
|
79
|
+
* - `status: "STABLE"` - No changes, already stable
|
|
80
|
+
* - `crashedBundleId` - Present only when status is "RECOVERED"
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const result = HotUpdater.notifyAppReady();
|
|
85
|
+
*
|
|
86
|
+
* switch (result.status) {
|
|
87
|
+
* case "PROMOTED":
|
|
88
|
+
* // Send ACTIVE analytics event
|
|
89
|
+
* analytics.track('bundle_active', { bundleId: HotUpdater.getBundleId() });
|
|
90
|
+
* break;
|
|
91
|
+
* case "RECOVERED":
|
|
92
|
+
* // Send ROLLBACK analytics event
|
|
93
|
+
* analytics.track('bundle_rollback', { crashedBundleId: result.crashedBundleId });
|
|
94
|
+
* break;
|
|
95
|
+
* case "STABLE":
|
|
96
|
+
* // No special action needed
|
|
97
|
+
* break;
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare const notifyAppReady: () => NotifyAppReadyResult;
|
|
102
|
+
/**
|
|
103
|
+
* Gets the list of bundle IDs that have been marked as crashed.
|
|
104
|
+
* These bundles will be rejected if attempted to install again.
|
|
105
|
+
*
|
|
106
|
+
* @returns {string[]} Array of crashed bundle IDs
|
|
107
|
+
*/
|
|
108
|
+
export declare const getCrashHistory: () => string[];
|
|
109
|
+
/**
|
|
110
|
+
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
111
|
+
* to be installed again.
|
|
112
|
+
*
|
|
113
|
+
* @returns {boolean} true if clearing was successful
|
|
114
|
+
*/
|
|
115
|
+
export declare const clearCrashHistory: () => boolean;
|
|
60
116
|
//# sourceMappingURL=native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAyB,EACvB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAyB,EACvB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,CAAC;AAMlD,eAAO,MAAM,mBAAmB;;CAE/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;AAOF;;;;;;GAMG;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;AAgEpB;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,MAAM,GAAG,IAGzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,qBAElB,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,MAG7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAO,MAAM,GAAG,IAG9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,cAAc,QAAO,oBAYjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAO,MAAM,EAWxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,QAAO,OAEpC,CAAC"}
|
|
@@ -15,7 +15,69 @@ export interface UpdateBundleParams {
|
|
|
15
15
|
}
|
|
16
16
|
export interface Spec extends TurboModule {
|
|
17
17
|
reload(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Downloads and applies a bundle update.
|
|
20
|
+
*
|
|
21
|
+
* @param params - Update bundle parameters
|
|
22
|
+
* @returns Promise that resolves to true if successful
|
|
23
|
+
* @throws {HotUpdaterErrorCode} Rejects with one of the following error codes:
|
|
24
|
+
*
|
|
25
|
+
* Parameter validation:
|
|
26
|
+
* - MISSING_BUNDLE_ID: Missing or empty bundleId
|
|
27
|
+
* - INVALID_FILE_URL: Invalid fileUrl provided
|
|
28
|
+
*
|
|
29
|
+
* Bundle storage:
|
|
30
|
+
* - DIRECTORY_CREATION_FAILED: Failed to create bundle directory
|
|
31
|
+
* - DOWNLOAD_FAILED: Failed to download bundle
|
|
32
|
+
* - INCOMPLETE_DOWNLOAD: Download incomplete (size mismatch)
|
|
33
|
+
* - EXTRACTION_FORMAT_ERROR: Invalid or corrupted archive format
|
|
34
|
+
* - INVALID_BUNDLE: Bundle missing required platform files
|
|
35
|
+
* - INSUFFICIENT_DISK_SPACE: Insufficient disk space
|
|
36
|
+
* - MOVE_OPERATION_FAILED: Failed to move bundle files
|
|
37
|
+
* - BUNDLE_IN_CRASHED_HISTORY: Bundle was previously marked as crashed
|
|
38
|
+
*
|
|
39
|
+
* Signature:
|
|
40
|
+
* - SIGNATURE_VERIFICATION_FAILED: Any signature/hash verification failure
|
|
41
|
+
*
|
|
42
|
+
* Internal:
|
|
43
|
+
* - SELF_DEALLOCATED: Native object was deallocated (iOS)
|
|
44
|
+
* - UNKNOWN_ERROR: Fallback for rare or platform-specific errors
|
|
45
|
+
*
|
|
46
|
+
* Note: iOS normalizes rare signature/storage errors to SIGNATURE_VERIFICATION_FAILED
|
|
47
|
+
* or UNKNOWN_ERROR to keep the JS error surface small.
|
|
48
|
+
*/
|
|
18
49
|
updateBundle(params: UpdateBundleParams): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Notifies the native side that the app has successfully started with the given bundle.
|
|
52
|
+
* If the bundle matches the staging bundle, it promotes to stable.
|
|
53
|
+
*
|
|
54
|
+
* @param params - Parameters containing the bundle ID
|
|
55
|
+
* @returns Object with status and optional crashedBundleId
|
|
56
|
+
* - `status: "PROMOTED"` - Staging bundle was promoted to stable (ACTIVE event)
|
|
57
|
+
* - `status: "RECOVERED"` - App recovered from crash, rollback occurred (ROLLBACK event)
|
|
58
|
+
* - `status: "STABLE"` - No changes, already stable
|
|
59
|
+
* - `crashedBundleId` - Present only when status is "RECOVERED"
|
|
60
|
+
*/
|
|
61
|
+
notifyAppReady(params: {
|
|
62
|
+
bundleId: string;
|
|
63
|
+
}): {
|
|
64
|
+
status: "PROMOTED" | "RECOVERED" | "STABLE";
|
|
65
|
+
crashedBundleId?: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Gets the list of bundle IDs that have been marked as crashed.
|
|
69
|
+
* These bundles will be rejected if attempted to install again.
|
|
70
|
+
*
|
|
71
|
+
* @returns Array of crashed bundle IDs
|
|
72
|
+
*/
|
|
73
|
+
getCrashHistory(): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
76
|
+
* to be installed again.
|
|
77
|
+
*
|
|
78
|
+
* @returns true if clearing was successful
|
|
79
|
+
*/
|
|
80
|
+
clearCrashHistory(): boolean;
|
|
19
81
|
addListener(eventName: string): void;
|
|
20
82
|
removeListeners(count: number): void;
|
|
21
83
|
readonly getConstants: () => {
|
|
@@ -1 +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;IACvB;;;;;;;;OAQG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IAEvC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;
|
|
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;IACvB;;;;;;;;OAQG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IAEvC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3D;;;;;;;;;;OAUG;IACH,cAAc,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG;QAC5C,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;QAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IAEF;;;;;OAKG;IACH,eAAe,IAAI,MAAM,EAAE,CAAC;IAE5B;;;;;OAKG;IACH,iBAAiB,IAAI,OAAO,CAAC;IAG7B,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;QAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC,CAAC;CACH;;AAED,wBAAoE"}
|
|
@@ -1,3 +1,118 @@
|
|
|
1
|
+
import type { AppUpdateInfo } from "@hot-updater/core";
|
|
2
|
+
import type { NotifyAppReadyResult } from "./native";
|
|
3
|
+
/**
|
|
4
|
+
* Parameters passed to resolver.checkUpdate method
|
|
5
|
+
*/
|
|
6
|
+
export interface ResolverCheckUpdateParams {
|
|
7
|
+
/**
|
|
8
|
+
* The platform the app is running on
|
|
9
|
+
*/
|
|
10
|
+
platform: "ios" | "android";
|
|
11
|
+
/**
|
|
12
|
+
* The current app version
|
|
13
|
+
*/
|
|
14
|
+
appVersion: string;
|
|
15
|
+
/**
|
|
16
|
+
* The current bundle ID
|
|
17
|
+
*/
|
|
18
|
+
bundleId: string;
|
|
19
|
+
/**
|
|
20
|
+
* Minimum bundle ID from build time
|
|
21
|
+
*/
|
|
22
|
+
minBundleId: string;
|
|
23
|
+
/**
|
|
24
|
+
* The channel name (e.g., "production", "staging")
|
|
25
|
+
*/
|
|
26
|
+
channel: string;
|
|
27
|
+
/**
|
|
28
|
+
* Update strategy being used
|
|
29
|
+
*/
|
|
30
|
+
updateStrategy: "fingerprint" | "appVersion";
|
|
31
|
+
/**
|
|
32
|
+
* The fingerprint hash (only present when using fingerprint strategy)
|
|
33
|
+
*/
|
|
34
|
+
fingerprintHash: string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Request headers from global config (for optional use)
|
|
37
|
+
*/
|
|
38
|
+
requestHeaders?: Record<string, string>;
|
|
39
|
+
/**
|
|
40
|
+
* Request timeout from global config (for optional use)
|
|
41
|
+
*/
|
|
42
|
+
requestTimeout?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parameters passed to resolver.notifyAppReady method
|
|
46
|
+
*/
|
|
47
|
+
export interface ResolverNotifyAppReadyParams {
|
|
48
|
+
/**
|
|
49
|
+
* The bundle state from native notifyAppReady
|
|
50
|
+
* - "PROMOTED": Staging bundle was promoted to stable
|
|
51
|
+
* - "RECOVERED": App recovered from crash, rollback occurred
|
|
52
|
+
* - "STABLE": No changes, bundle is stable
|
|
53
|
+
*/
|
|
54
|
+
status: "PROMOTED" | "RECOVERED" | "STABLE";
|
|
55
|
+
/**
|
|
56
|
+
* Present only when status is "RECOVERED"
|
|
57
|
+
*/
|
|
58
|
+
crashedBundleId?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Request headers from global config (for optional use)
|
|
61
|
+
*/
|
|
62
|
+
requestHeaders?: Record<string, string>;
|
|
63
|
+
/**
|
|
64
|
+
* Request timeout from global config (for optional use)
|
|
65
|
+
*/
|
|
66
|
+
requestTimeout?: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolver interface for custom network operations
|
|
70
|
+
*/
|
|
71
|
+
export interface HotUpdaterResolver {
|
|
72
|
+
/**
|
|
73
|
+
* Custom implementation for checking updates.
|
|
74
|
+
* When provided, this completely replaces the default fetchUpdateInfo flow.
|
|
75
|
+
*
|
|
76
|
+
* @param params - All parameters needed to check for updates
|
|
77
|
+
* @returns Update information or null if up to date
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* checkUpdate: async (params) => {
|
|
82
|
+
* const response = await fetch(`https://api.custom.com/check`, {
|
|
83
|
+
* method: 'POST',
|
|
84
|
+
* body: JSON.stringify(params),
|
|
85
|
+
* headers: params.requestHeaders,
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* if (!response.ok) return null;
|
|
89
|
+
* return response.json();
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
checkUpdate?: (params: ResolverCheckUpdateParams) => Promise<AppUpdateInfo | null>;
|
|
94
|
+
/**
|
|
95
|
+
* Custom implementation for notifying app ready.
|
|
96
|
+
* When provided, this completely replaces the default notifyAppReady network flow.
|
|
97
|
+
* Note: The native notifyAppReady for bundle promotion still happens automatically.
|
|
98
|
+
*
|
|
99
|
+
* @param params - All parameters about the current app state
|
|
100
|
+
* @returns Notification result
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* notifyAppReady: async (params) => {
|
|
105
|
+
* await fetch(`https://api.custom.com/notify`, {
|
|
106
|
+
* method: 'POST',
|
|
107
|
+
* body: JSON.stringify(params),
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* return { status: "STABLE" };
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
notifyAppReady?: (params: ResolverNotifyAppReadyParams) => Promise<NotifyAppReadyResult | undefined>;
|
|
115
|
+
}
|
|
1
116
|
/**
|
|
2
117
|
* Information about a signature verification failure.
|
|
3
118
|
* This is a security-critical event that indicates the bundle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAgBpE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,GACf,4BAA4B,CAS9B"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,QAAQ,EAAE,KAAK,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,cAAc,EAAE,aAAa,GAAG,YAAY,CAAC;IAE7C;;OAEG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;;OAKG;IACH,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;IAE5C;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAAW,CAAC,EAAE,CACZ,MAAM,EAAE,yBAAyB,KAC9B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IAEnC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAAc,CAAC,EAAE,CACf,MAAM,EAAE,4BAA4B,KACjC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAC;CAChD;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAgBpE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,GACf,4BAA4B,CAS9B"}
|
|
@@ -1,9 +1,99 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { type CheckForUpdateOptions } from "./checkForUpdate";
|
|
3
2
|
import type { HotUpdaterError } from "./error";
|
|
4
|
-
import type
|
|
3
|
+
import { type NotifyAppReadyResult } from "./native";
|
|
4
|
+
import type { HotUpdaterResolver } from "./types";
|
|
5
|
+
export interface RunUpdateProcessResponse {
|
|
6
|
+
status: "ROLLBACK" | "UPDATE" | "UP_TO_DATE";
|
|
7
|
+
shouldForceUpdate: boolean;
|
|
8
|
+
message: string | null;
|
|
9
|
+
id: string;
|
|
10
|
+
}
|
|
5
11
|
type UpdateStatus = "CHECK_FOR_UPDATE" | "UPDATING" | "UPDATE_PROCESS_COMPLETED";
|
|
6
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Common options shared between auto and manual update modes
|
|
14
|
+
*/
|
|
15
|
+
interface CommonHotUpdaterOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Custom request headers for update checks
|
|
18
|
+
*/
|
|
19
|
+
requestHeaders?: Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Request timeout in milliseconds
|
|
22
|
+
* @default 5000
|
|
23
|
+
*/
|
|
24
|
+
requestTimeout?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Callback invoked when the app is ready and bundle verification completes.
|
|
27
|
+
* Provides information about bundle promotion, recovery from crashes, or stable state.
|
|
28
|
+
*
|
|
29
|
+
* @param result - Bundle state information
|
|
30
|
+
* @param result.status - Current bundle state:
|
|
31
|
+
* - "PROMOTED": Staging bundle was promoted to stable (new update applied)
|
|
32
|
+
* - "RECOVERED": App recovered from a crash, rollback occurred
|
|
33
|
+
* - "STABLE": No changes, bundle is stable
|
|
34
|
+
* @param result.crashedBundleId - Present only when status is "RECOVERED"
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* HotUpdater.wrap({
|
|
39
|
+
* baseURL: "https://api.example.com",
|
|
40
|
+
* updateMode: "manual",
|
|
41
|
+
* onNotifyAppReady: ({ status, crashedBundleId }) => {
|
|
42
|
+
* if (status === "RECOVERED") {
|
|
43
|
+
* analytics.track('bundle_rollback', { crashedBundleId });
|
|
44
|
+
* } else if (status === "PROMOTED") {
|
|
45
|
+
* analytics.track('bundle_promoted');
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* })(App);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
onNotifyAppReady?: (result: NotifyAppReadyResult) => void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Configuration with baseURL for standard server-based updates
|
|
55
|
+
*/
|
|
56
|
+
interface BaseURLConfig {
|
|
57
|
+
/**
|
|
58
|
+
* Base URL for update server
|
|
59
|
+
* @example "https://update.example.com"
|
|
60
|
+
*/
|
|
61
|
+
baseURL: string;
|
|
62
|
+
/**
|
|
63
|
+
* Resolver is not allowed when using baseURL
|
|
64
|
+
*/
|
|
65
|
+
resolver?: never;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Configuration with resolver for custom network operations
|
|
69
|
+
*/
|
|
70
|
+
interface ResolverConfig {
|
|
71
|
+
/**
|
|
72
|
+
* Custom resolver for network operations
|
|
73
|
+
*/
|
|
74
|
+
resolver: HotUpdaterResolver;
|
|
75
|
+
/**
|
|
76
|
+
* baseURL is not allowed when using resolver
|
|
77
|
+
*/
|
|
78
|
+
baseURL?: never;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Union type ensuring baseURL and resolver are mutually exclusive
|
|
82
|
+
*/
|
|
83
|
+
type NetworkConfig = BaseURLConfig | ResolverConfig;
|
|
84
|
+
export type AutoUpdateOptions = CommonHotUpdaterOptions & NetworkConfig & {
|
|
85
|
+
/**
|
|
86
|
+
* Update strategy
|
|
87
|
+
* - "fingerprint": Use fingerprint hash to check for updates
|
|
88
|
+
* - "appVersion": Use app version to check for updates
|
|
89
|
+
*/
|
|
90
|
+
updateStrategy: "fingerprint" | "appVersion";
|
|
91
|
+
/**
|
|
92
|
+
* Update mode
|
|
93
|
+
* - "auto": Automatically check and download updates
|
|
94
|
+
*/
|
|
95
|
+
updateMode: "auto";
|
|
96
|
+
onError?: (error: HotUpdaterError | Error | unknown) => void;
|
|
7
97
|
/**
|
|
8
98
|
* Component to show while downloading a new bundle update.
|
|
9
99
|
*
|
|
@@ -14,7 +104,8 @@ export interface HotUpdaterOptions extends CheckForUpdateOptions {
|
|
|
14
104
|
*
|
|
15
105
|
* ```tsx
|
|
16
106
|
* HotUpdater.wrap({
|
|
17
|
-
*
|
|
107
|
+
* baseURL: "<update-server-url>",
|
|
108
|
+
* updateStrategy: "appVersion",
|
|
18
109
|
* fallbackComponent: ({ progress = 0 }) => (
|
|
19
110
|
* <View style={styles.container}>
|
|
20
111
|
* <Text style={styles.text}>Updating... {progress}%</Text>
|
|
@@ -30,7 +121,6 @@ export interface HotUpdaterOptions extends CheckForUpdateOptions {
|
|
|
30
121
|
progress: number;
|
|
31
122
|
message: string | null;
|
|
32
123
|
}>;
|
|
33
|
-
onError?: (error: HotUpdaterError | Error | unknown) => void;
|
|
34
124
|
onProgress?: (progress: number) => void;
|
|
35
125
|
/**
|
|
36
126
|
* When a force update exists, the app will automatically reload.
|
|
@@ -45,7 +135,42 @@ export interface HotUpdaterOptions extends CheckForUpdateOptions {
|
|
|
45
135
|
* @see {@link https://hot-updater.dev/docs/react-native-api/wrap#onupdateprocesscompleted}
|
|
46
136
|
*/
|
|
47
137
|
onUpdateProcessCompleted?: (response: RunUpdateProcessResponse) => void;
|
|
48
|
-
}
|
|
49
|
-
export
|
|
138
|
+
};
|
|
139
|
+
export type ManualUpdateOptions = CommonHotUpdaterOptions & NetworkConfig & {
|
|
140
|
+
/**
|
|
141
|
+
* Update mode
|
|
142
|
+
* - "manual": Only notify app ready, user manually calls checkForUpdate()
|
|
143
|
+
*/
|
|
144
|
+
updateMode: "manual";
|
|
145
|
+
};
|
|
146
|
+
export type HotUpdaterOptions = AutoUpdateOptions | ManualUpdateOptions;
|
|
147
|
+
/**
|
|
148
|
+
* Internal options after normalization in index.ts
|
|
149
|
+
* Always has resolver (never baseURL)
|
|
150
|
+
*/
|
|
151
|
+
type InternalCommonOptions = {
|
|
152
|
+
resolver: HotUpdaterResolver;
|
|
153
|
+
requestHeaders?: Record<string, string>;
|
|
154
|
+
requestTimeout?: number;
|
|
155
|
+
onNotifyAppReady?: (result: NotifyAppReadyResult) => void;
|
|
156
|
+
};
|
|
157
|
+
type InternalAutoUpdateOptions = InternalCommonOptions & {
|
|
158
|
+
updateStrategy: "fingerprint" | "appVersion";
|
|
159
|
+
updateMode: "auto";
|
|
160
|
+
onError?: (error: HotUpdaterError | Error | unknown) => void;
|
|
161
|
+
fallbackComponent?: React.FC<{
|
|
162
|
+
status: Exclude<UpdateStatus, "UPDATE_PROCESS_COMPLETED">;
|
|
163
|
+
progress: number;
|
|
164
|
+
message: string | null;
|
|
165
|
+
}>;
|
|
166
|
+
onProgress?: (progress: number) => void;
|
|
167
|
+
reloadOnForceUpdate?: boolean;
|
|
168
|
+
onUpdateProcessCompleted?: (response: RunUpdateProcessResponse) => void;
|
|
169
|
+
};
|
|
170
|
+
type InternalManualUpdateOptions = InternalCommonOptions & {
|
|
171
|
+
updateMode: "manual";
|
|
172
|
+
};
|
|
173
|
+
export type InternalWrapOptions = InternalAutoUpdateOptions | InternalManualUpdateOptions;
|
|
174
|
+
export declare function wrap<P extends React.JSX.IntrinsicAttributes = object>(options: InternalWrapOptions): (WrappedComponent: React.ComponentType<P>) => React.ComponentType<P>;
|
|
50
175
|
export {};
|
|
51
176
|
//# sourceMappingURL=wrap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../../src/wrap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../../src/wrap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,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,KAAK,YAAY,GACb,kBAAkB,GAClB,UAAU,GACV,0BAA0B,CAAC;AAE/B;;GAEG;AACH,UAAU,uBAAuB;IAC/B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D;AAED;;GAEG;AACH,UAAU,aAAa;IACrB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB;AAED;;GAEG;AACH,UAAU,cAAc;IACtB;;OAEG;IACH,QAAQ,EAAE,kBAAkB,CAAC;IAE7B;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB;AAED;;GAEG;AACH,KAAK,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GACrD,aAAa,GAAG;IACd;;;;OAIG;IACH,cAAc,EAAE,aAAa,GAAG,YAAY,CAAC;IAE7C;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,GAAG,OAAO,KAAK,IAAI,CAAC;IAE7D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC;QAC1D,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC,CAAC;IAEH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAExC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,CAAC,QAAQ,EAAE,wBAAwB,KAAK,IAAI,CAAC;CACzE,CAAC;AAEJ,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GACvD,aAAa,GAAG;IACd;;;OAGG;IACH,UAAU,EAAE,QAAQ,CAAC;CACtB,CAAC;AAEJ,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAExE;;;GAGG;AACH,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D,CAAC;AAEF,KAAK,yBAAyB,GAAG,qBAAqB,GAAG;IACvD,cAAc,EAAE,aAAa,GAAG,YAAY,CAAC;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,GAAG,OAAO,KAAK,IAAI,CAAC;IAC7D,iBAAiB,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC;QAC1D,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC,CAAC;IACH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,wBAAwB,CAAC,EAAE,CAAC,QAAQ,EAAE,wBAAwB,KAAK,IAAI,CAAC;CACzE,CAAC;AAEF,KAAK,2BAA2B,GAAG,qBAAqB,GAAG;IACzD,UAAU,EAAE,QAAQ,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B,yBAAyB,GACzB,2BAA2B,CAAC;AAmChC,wBAAgB,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,mBAAmB,GAAG,MAAM,EACnE,OAAO,EAAE,mBAAmB,GAC3B,CAAC,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CA8HtE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "React Native OTA solution for self-hosted",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -120,14 +120,14 @@
|
|
|
120
120
|
"react-native": "0.79.1",
|
|
121
121
|
"react-native-builder-bob": "^0.40.10",
|
|
122
122
|
"typescript": "^5.8.3",
|
|
123
|
-
"hot-updater": "0.
|
|
123
|
+
"hot-updater": "0.24.1"
|
|
124
124
|
},
|
|
125
125
|
"dependencies": {
|
|
126
126
|
"use-sync-external-store": "1.5.0",
|
|
127
|
-
"@hot-updater/cli-tools": "0.
|
|
128
|
-
"@hot-updater/core": "0.
|
|
129
|
-
"@hot-updater/
|
|
130
|
-
"@hot-updater/
|
|
127
|
+
"@hot-updater/cli-tools": "0.24.1",
|
|
128
|
+
"@hot-updater/core": "0.24.1",
|
|
129
|
+
"@hot-updater/plugin-core": "0.24.1",
|
|
130
|
+
"@hot-updater/js": "0.24.1"
|
|
131
131
|
},
|
|
132
132
|
"scripts": {
|
|
133
133
|
"build": "bob build && tsc -p plugin/tsconfig.build.json",
|
|
@@ -39,10 +39,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var node_path_1 = __importDefault(require("node:path"));
|
|
43
42
|
var cli_tools_1 = require("@hot-updater/cli-tools");
|
|
44
43
|
var config_plugins_1 = require("expo/config-plugins");
|
|
45
44
|
var hot_updater_1 = require("hot-updater");
|
|
45
|
+
var path_1 = __importDefault(require("path"));
|
|
46
46
|
var package_json_1 = __importDefault(require("../../package.json"));
|
|
47
47
|
var transformers_1 = require("./transformers");
|
|
48
48
|
var fingerprintCache = null;
|
|
@@ -77,9 +77,9 @@ var getPublicKeyFromConfig = function (signingConfig) { return __awaiter(void 0,
|
|
|
77
77
|
_a.label = 1;
|
|
78
78
|
case 1:
|
|
79
79
|
_a.trys.push([1, 3, , 4]);
|
|
80
|
-
privateKeyPath =
|
|
80
|
+
privateKeyPath = path_1.default.isAbsolute(signingConfig.privateKeyPath)
|
|
81
81
|
? signingConfig.privateKeyPath
|
|
82
|
-
:
|
|
82
|
+
: path_1.default.resolve(process.cwd(), signingConfig.privateKeyPath);
|
|
83
83
|
return [4 /*yield*/, (0, hot_updater_1.loadPrivateKey)(privateKeyPath)];
|
|
84
84
|
case 2:
|
|
85
85
|
privateKeyPEM = _a.sent();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AppUpdateInfo } from "@hot-updater/core";
|
|
2
|
+
import { fetchUpdateInfo } from "./fetchUpdateInfo";
|
|
3
|
+
import type { HotUpdaterResolver, ResolverCheckUpdateParams } from "./types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a default resolver that uses baseURL for network operations.
|
|
7
|
+
* This encapsulates the existing baseURL logic into a resolver.
|
|
8
|
+
*
|
|
9
|
+
* @param baseURL - The base URL for the update server
|
|
10
|
+
* @returns A HotUpdaterResolver that uses the baseURL
|
|
11
|
+
*/
|
|
12
|
+
export function createDefaultResolver(baseURL: string): HotUpdaterResolver {
|
|
13
|
+
return {
|
|
14
|
+
checkUpdate: async (
|
|
15
|
+
params: ResolverCheckUpdateParams,
|
|
16
|
+
): Promise<AppUpdateInfo | null> => {
|
|
17
|
+
// Build URL based on strategy (existing buildUpdateUrl logic)
|
|
18
|
+
let url: string;
|
|
19
|
+
if (params.updateStrategy === "fingerprint") {
|
|
20
|
+
if (!params.fingerprintHash) {
|
|
21
|
+
throw new Error("Fingerprint hash is required");
|
|
22
|
+
}
|
|
23
|
+
url = `${baseURL}/fingerprint/${params.platform}/${params.fingerprintHash}/${params.channel}/${params.minBundleId}/${params.bundleId}`;
|
|
24
|
+
} else {
|
|
25
|
+
url = `${baseURL}/app-version/${params.platform}/${params.appVersion}/${params.channel}/${params.minBundleId}/${params.bundleId}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Use existing fetchUpdateInfo
|
|
29
|
+
return fetchUpdateInfo({
|
|
30
|
+
url,
|
|
31
|
+
requestHeaders: params.requestHeaders,
|
|
32
|
+
requestTimeout: params.requestTimeout,
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|