@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
package/lib/module/types.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Parameters passed to resolver.checkUpdate method
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Parameters passed to resolver.notifyAppReady method
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Resolver interface for custom network operations
|
|
13
|
+
*/
|
|
14
|
+
|
|
3
15
|
/**
|
|
4
16
|
* Information about a signature verification failure.
|
|
5
17
|
* This is a security-critical event that indicates the bundle
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isSignatureVerificationError","error","Error","message","toLowerCase","includes","extractSignatureFailure","bundleId","normalizedError","String"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["isSignatureVerificationError","error","Error","message","toLowerCase","includes","extractSignatureFailure","bundleId","normalizedError","String"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAGA;AACA;AACA;;AAgDA;AACA;AACA;;AA0BA;AACA;AACA;;AAoDA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,4BAA4BA,CAACC,KAAc,EAAW;EACpE,IAAI,EAAEA,KAAK,YAAYC,KAAK,CAAC,EAAE;IAC7B,OAAO,KAAK;EACd;EAEA,MAAMC,OAAO,GAAGF,KAAK,CAACE,OAAO,CAACC,WAAW,CAAC,CAAC;;EAE3C;EACA;EACA,OACED,OAAO,CAACE,QAAQ,CAAC,wBAAwB,CAAC,IAC1CF,OAAO,CAACE,QAAQ,CAAC,2BAA2B,CAAC,IAC7CF,OAAO,CAACE,QAAQ,CAAC,8BAA8B,CAAC,IAChDF,OAAO,CAACE,QAAQ,CAAC,6BAA6B,CAAC,IAC/CF,OAAO,CAACE,QAAQ,CAAC,qCAAqC,CAAC;AAE3D;;AAEA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CACrCL,KAAc,EACdM,QAAgB,EACc;EAC9B,MAAMC,eAAe,GACnBP,KAAK,YAAYC,KAAK,GAAGD,KAAK,GAAG,IAAIC,KAAK,CAACO,MAAM,CAACR,KAAK,CAAC,CAAC;EAE3D,OAAO;IACLM,QAAQ;IACRJ,OAAO,EAAEK,eAAe,CAACL,OAAO;IAChCF,KAAK,EAAEO;EACT,CAAC;AACH","ignoreList":[]}
|
package/lib/module/wrap.js
CHANGED
|
@@ -3,10 +3,70 @@
|
|
|
3
3
|
import React, { useEffect, useLayoutEffect, useState } from "react";
|
|
4
4
|
import { checkForUpdate } from "./checkForUpdate.js";
|
|
5
5
|
import { useEventCallback } from "./hooks/useEventCallback.js";
|
|
6
|
-
import { getBundleId, reload } from "./native.js";
|
|
6
|
+
import { getBundleId, notifyAppReady as nativeNotifyAppReady, reload } from "./native.js";
|
|
7
7
|
import { useHotUpdaterStore } from "./store.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Common options shared between auto and manual update modes
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Configuration with baseURL for standard server-based updates
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Configuration with resolver for custom network operations
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Union type ensuring baseURL and resolver are mutually exclusive
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Internal options after normalization in index.ts
|
|
27
|
+
* Always has resolver (never baseURL)
|
|
28
|
+
*/
|
|
8
29
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to handle notifyAppReady flow
|
|
32
|
+
*/
|
|
33
|
+
const handleNotifyAppReady = async options => {
|
|
34
|
+
try {
|
|
35
|
+
// Always call native notifyAppReady for bundle promotion
|
|
36
|
+
const nativeResult = nativeNotifyAppReady();
|
|
37
|
+
|
|
38
|
+
// If resolver.notifyAppReady exists, call it with simplified params
|
|
39
|
+
if (options.resolver?.notifyAppReady) {
|
|
40
|
+
await options.resolver.notifyAppReady({
|
|
41
|
+
status: nativeResult.status,
|
|
42
|
+
crashedBundleId: nativeResult.crashedBundleId,
|
|
43
|
+
requestHeaders: options.requestHeaders,
|
|
44
|
+
requestTimeout: options.requestTimeout
|
|
45
|
+
}).catch(e => {
|
|
46
|
+
console.warn("[HotUpdater] Resolver notifyAppReady failed:", e);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
options.onNotifyAppReady?.(nativeResult);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.warn("[HotUpdater] Failed to notify app ready:", e);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
9
54
|
export function wrap(options) {
|
|
55
|
+
if (options.updateMode === "manual") {
|
|
56
|
+
return WrappedComponent => {
|
|
57
|
+
const ManualHOC = props => {
|
|
58
|
+
useLayoutEffect(() => {
|
|
59
|
+
void handleNotifyAppReady(options);
|
|
60
|
+
}, []);
|
|
61
|
+
return /*#__PURE__*/_jsx(WrappedComponent, {
|
|
62
|
+
...props
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
return ManualHOC;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// updateMode: "auto"
|
|
10
70
|
const {
|
|
11
71
|
reloadOnForceUpdate = true,
|
|
12
72
|
...restOptions
|
|
@@ -20,8 +80,10 @@ export function wrap(options) {
|
|
|
20
80
|
try {
|
|
21
81
|
setUpdateStatus("CHECK_FOR_UPDATE");
|
|
22
82
|
const updateInfo = await checkForUpdate({
|
|
23
|
-
|
|
83
|
+
resolver: restOptions.resolver,
|
|
84
|
+
updateStrategy: restOptions.updateStrategy,
|
|
24
85
|
requestHeaders: restOptions.requestHeaders,
|
|
86
|
+
requestTimeout: restOptions.requestTimeout,
|
|
25
87
|
onError: restOptions.onError
|
|
26
88
|
});
|
|
27
89
|
setMessage(updateInfo?.message ?? null);
|
|
@@ -72,6 +134,13 @@ export function wrap(options) {
|
|
|
72
134
|
useEffect(() => {
|
|
73
135
|
restOptions.onProgress?.(progress);
|
|
74
136
|
}, [progress]);
|
|
137
|
+
|
|
138
|
+
// Notify native side that app is ready (JS bundle fully loaded)
|
|
139
|
+
useLayoutEffect(() => {
|
|
140
|
+
void handleNotifyAppReady(restOptions);
|
|
141
|
+
}, []);
|
|
142
|
+
|
|
143
|
+
// Start update check
|
|
75
144
|
useLayoutEffect(() => {
|
|
76
145
|
initHotUpdater();
|
|
77
146
|
}, []);
|
package/lib/module/wrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useLayoutEffect","useState","checkForUpdate","useEventCallback","getBundleId","reload","useHotUpdaterStore","jsx","_jsx","
|
|
1
|
+
{"version":3,"names":["React","useEffect","useLayoutEffect","useState","checkForUpdate","useEventCallback","getBundleId","notifyAppReady","nativeNotifyAppReady","reload","useHotUpdaterStore","jsx","_jsx","handleNotifyAppReady","options","nativeResult","resolver","status","crashedBundleId","requestHeaders","requestTimeout","catch","e","console","warn","onNotifyAppReady","wrap","updateMode","WrappedComponent","ManualHOC","props","reloadOnForceUpdate","restOptions","HotUpdaterHOC","progress","state","message","setMessage","updateStatus","setUpdateStatus","initHotUpdater","updateInfo","updateStrategy","onError","onUpdateProcessCompleted","shouldForceUpdate","id","updateBundle","error","isSuccess","Error","onProgress","fallbackComponent","Fallback"],"sourceRoot":"../../src","sources":["wrap.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AACnE,SAASC,cAAc,QAAQ,qBAAkB;AAEjD,SAASC,gBAAgB,QAAQ,6BAA0B;AAC3D,SACEC,WAAW,EAEXC,cAAc,IAAIC,oBAAoB,EACtCC,MAAM,QACD,a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oB,iBAAiB,IAC7Bd,YAAY,KAAK,0BAA0B,EAC3C;QACA,MAAMe,QAAQ,GAAGrB,WAAW,CAACoB,iBAAiB;QAC9C,oBACExC,IAAA,CAACyC,QAAQ;UACPnB,QAAQ,EAAEA,QAAS;UACnBjB,MAAM,EAAEqB,YAAa;UACrBF,OAAO,EAAEA;QAAQ,CAClB,CAAC;MAEN;MAEA,oBAAOxB,IAAA,CAACgB,gBAAgB;QAAA,GAAKE;MAAK,CAAG,CAAC;IACxC,CAAC;IAED,OAAOG,aAAa;EACtB,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HotUpdaterResolver } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a default resolver that uses baseURL for network operations.
|
|
4
|
+
* This encapsulates the existing baseURL logic into a resolver.
|
|
5
|
+
*
|
|
6
|
+
* @param baseURL - The base URL for the update server
|
|
7
|
+
* @returns A HotUpdaterResolver that uses the baseURL
|
|
8
|
+
*/
|
|
9
|
+
export declare function createDefaultResolver(baseURL: string): HotUpdaterResolver;
|
|
10
|
+
//# sourceMappingURL=DefaultResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultResolver.d.ts","sourceRoot":"","sources":["../../../src/DefaultResolver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAA6B,MAAM,SAAS,CAAC;AAE7E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAwBzE"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import type { AppUpdateInfo
|
|
2
|
-
import {
|
|
1
|
+
import type { AppUpdateInfo } from "@hot-updater/core";
|
|
2
|
+
import type { HotUpdaterResolver } from "./types";
|
|
3
3
|
export interface CheckForUpdateOptions {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Update strategy
|
|
6
|
+
* - "fingerprint": Use fingerprint hash to check for updates
|
|
7
|
+
* - "appVersion": Use app version to check for updates
|
|
8
|
+
* - Can override the strategy set in HotUpdater.wrap()
|
|
9
|
+
*/
|
|
10
|
+
updateStrategy: "appVersion" | "fingerprint";
|
|
5
11
|
requestHeaders?: Record<string, string>;
|
|
6
12
|
onError?: (error: Error) => void;
|
|
7
13
|
/**
|
|
@@ -17,15 +23,8 @@ export type CheckForUpdateResult = AppUpdateInfo & {
|
|
|
17
23
|
*/
|
|
18
24
|
updateBundle: () => Promise<boolean>;
|
|
19
25
|
};
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The update strategy to use.
|
|
24
|
-
* @description
|
|
25
|
-
* - "fingerprint": Use the fingerprint hash to check for updates.
|
|
26
|
-
* - "appVersion": Use the target app version to check for updates.
|
|
27
|
-
*/
|
|
28
|
-
updateStrategy: "appVersion" | "fingerprint";
|
|
26
|
+
export interface InternalCheckForUpdateOptions extends CheckForUpdateOptions {
|
|
27
|
+
resolver: HotUpdaterResolver;
|
|
29
28
|
}
|
|
30
|
-
export declare
|
|
29
|
+
export declare function checkForUpdate(options: InternalCheckForUpdateOptions): Promise<CheckForUpdateResult | null>;
|
|
31
30
|
//# sourceMappingURL=checkForUpdate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkForUpdate.d.ts","sourceRoot":"","sources":["../../../src/checkForUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"checkForUpdate.d.ts","sourceRoot":"","sources":["../../../src/checkForUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAWvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,cAAc,EAAE,YAAY,GAAG,aAAa,CAAC;IAE7C,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;AAGF,MAAM,WAAW,6BAA8B,SAAQ,qBAAqB;IAC1E,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAkEtC"}
|
|
@@ -1,3 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hot Updater Error Codes
|
|
3
|
+
*
|
|
4
|
+
* This file defines all possible error codes that can be thrown by the native
|
|
5
|
+
* updateBundle function. These error codes are shared across iOS and Android
|
|
6
|
+
* implementations to ensure consistent error handling.
|
|
7
|
+
*
|
|
8
|
+
* Error Classification:
|
|
9
|
+
* - Parameter Validation: Invalid or missing function parameters
|
|
10
|
+
* - Bundle Storage: Errors during download, extraction, and storage
|
|
11
|
+
* - Signature Verification: Cryptographic verification failures (collapsed to a single public code)
|
|
12
|
+
* - Internal: Platform-specific or unexpected errors
|
|
13
|
+
*
|
|
14
|
+
* Retryability:
|
|
15
|
+
* - Retryable: DOWNLOAD_FAILED, INCOMPLETE_DOWNLOAD
|
|
16
|
+
* - Non-retryable: Most validation and verification errors
|
|
17
|
+
*/
|
|
18
|
+
export declare enum HotUpdaterErrorCode {
|
|
19
|
+
/**
|
|
20
|
+
* Bundle ID is missing or empty.
|
|
21
|
+
* Thrown when bundleId parameter is null, undefined, or empty string.
|
|
22
|
+
* @retryable false
|
|
23
|
+
*/
|
|
24
|
+
MISSING_BUNDLE_ID = "MISSING_BUNDLE_ID",
|
|
25
|
+
/**
|
|
26
|
+
* File URL is invalid or malformed.
|
|
27
|
+
* Thrown when fileUrl parameter cannot be parsed as a valid URL.
|
|
28
|
+
* @retryable false
|
|
29
|
+
*/
|
|
30
|
+
INVALID_FILE_URL = "INVALID_FILE_URL",
|
|
31
|
+
/**
|
|
32
|
+
* Failed to create required directory for bundle storage.
|
|
33
|
+
* Thrown when bundle directory creation fails due to permissions or disk errors.
|
|
34
|
+
* @retryable false - Usually indicates permissions or filesystem corruption
|
|
35
|
+
*/
|
|
36
|
+
DIRECTORY_CREATION_FAILED = "DIRECTORY_CREATION_FAILED",
|
|
37
|
+
/**
|
|
38
|
+
* Bundle download failed.
|
|
39
|
+
* Covers network errors, HTTP errors (4xx/5xx), timeouts, and connection issues.
|
|
40
|
+
* Check error message for specific cause (network, HTTP status code, etc.).
|
|
41
|
+
* @retryable true - Network issues are often transient
|
|
42
|
+
*/
|
|
43
|
+
DOWNLOAD_FAILED = "DOWNLOAD_FAILED",
|
|
44
|
+
/**
|
|
45
|
+
* Download incomplete - received size doesn't match expected size.
|
|
46
|
+
* Thrown when downloaded file size doesn't match Content-Length header.
|
|
47
|
+
* Error message includes both expected and actual byte counts.
|
|
48
|
+
* @retryable true - Download may succeed on retry
|
|
49
|
+
*/
|
|
50
|
+
INCOMPLETE_DOWNLOAD = "INCOMPLETE_DOWNLOAD",
|
|
51
|
+
/**
|
|
52
|
+
* Bundle archive format is invalid or corrupted.
|
|
53
|
+
* Thrown when ZIP file has wrong magic bytes, invalid structure, or unsupported format.
|
|
54
|
+
* Also thrown for path traversal attempts during extraction.
|
|
55
|
+
* @retryable false - Indicates corrupted or malicious bundle
|
|
56
|
+
*/
|
|
57
|
+
EXTRACTION_FORMAT_ERROR = "EXTRACTION_FORMAT_ERROR",
|
|
58
|
+
/**
|
|
59
|
+
* Bundle missing required platform files.
|
|
60
|
+
* Thrown when extracted bundle doesn't contain index.android.bundle (Android)
|
|
61
|
+
* or main.jsbundle (iOS).
|
|
62
|
+
* @retryable false - Indicates incorrectly built bundle
|
|
63
|
+
*/
|
|
64
|
+
INVALID_BUNDLE = "INVALID_BUNDLE",
|
|
65
|
+
/**
|
|
66
|
+
* Insufficient disk space for bundle download and extraction.
|
|
67
|
+
* Thrown when available disk space is less than required (file size * 2).
|
|
68
|
+
* Error message includes required and available bytes.
|
|
69
|
+
* @retryable false - User must free up disk space
|
|
70
|
+
*/
|
|
71
|
+
INSUFFICIENT_DISK_SPACE = "INSUFFICIENT_DISK_SPACE",
|
|
72
|
+
/**
|
|
73
|
+
* Bundle signature verification failed (general).
|
|
74
|
+
* Thrown when cryptographic signature verification fails.
|
|
75
|
+
* All signature/hash sub-errors are collapsed into this public code.
|
|
76
|
+
* @retryable false - Indicates tampered or incorrectly signed bundle
|
|
77
|
+
*/
|
|
78
|
+
SIGNATURE_VERIFICATION_FAILED = "SIGNATURE_VERIFICATION_FAILED",
|
|
79
|
+
/**
|
|
80
|
+
* Failed to move bundle to final location.
|
|
81
|
+
* Thrown when atomic move from temp directory to final directory fails.
|
|
82
|
+
* iOS: Thrown if move operation fails.
|
|
83
|
+
* Android: Thrown if rename, move, AND copy all fail.
|
|
84
|
+
* @retryable false - Usually indicates filesystem corruption or permissions
|
|
85
|
+
*/
|
|
86
|
+
MOVE_OPERATION_FAILED = "MOVE_OPERATION_FAILED",
|
|
87
|
+
/**
|
|
88
|
+
* Bundle is in crashed history and cannot be applied.
|
|
89
|
+
* Thrown when attempting to install a bundle that previously caused a crash.
|
|
90
|
+
* Use HotUpdater.clearCrashHistory() to allow retrying this bundle.
|
|
91
|
+
* @retryable false - Bundle was marked as crashed for safety
|
|
92
|
+
*/
|
|
93
|
+
BUNDLE_IN_CRASHED_HISTORY = "BUNDLE_IN_CRASHED_HISTORY",
|
|
94
|
+
/**
|
|
95
|
+
* Internal error: self deallocated during update (iOS only).
|
|
96
|
+
* Thrown when the native object is deallocated mid-operation.
|
|
97
|
+
* iOS-specific due to manual memory management (ARC).
|
|
98
|
+
* Not applicable to Android (uses garbage collection).
|
|
99
|
+
* @platform iOS
|
|
100
|
+
* @retryable false - Memory management issue
|
|
101
|
+
*/
|
|
102
|
+
SELF_DEALLOCATED = "SELF_DEALLOCATED",
|
|
103
|
+
/**
|
|
104
|
+
* An unknown or unexpected error occurred.
|
|
105
|
+
* Catch-all for errors that don't fit other categories.
|
|
106
|
+
* Check error message for details.
|
|
107
|
+
* @retryable unknown - Depends on underlying cause
|
|
108
|
+
*/
|
|
109
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Type guard to check if an error is a HotUpdaterError
|
|
113
|
+
*/
|
|
114
|
+
export declare function isHotUpdaterError(error: unknown): error is {
|
|
115
|
+
code: HotUpdaterErrorCode;
|
|
116
|
+
message: string;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Base error class for Hot Updater
|
|
120
|
+
*/
|
|
1
121
|
export declare class HotUpdaterError extends Error {
|
|
2
122
|
constructor(message: string);
|
|
3
123
|
}
|
|
@@ -1 +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"}
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,oBAAY,mBAAmB;IAG7B;;;;OAIG;IACH,iBAAiB,sBAAsB;IAEvC;;;;OAIG;IACH,gBAAgB,qBAAqB;IAIrC;;;;OAIG;IACH,yBAAyB,8BAA8B;IAEvD;;;;;OAKG;IACH,eAAe,oBAAoB;IAEnC;;;;;OAKG;IACH,mBAAmB,wBAAwB;IAE3C;;;;;OAKG;IACH,uBAAuB,4BAA4B;IAEnD;;;;;OAKG;IACH,cAAc,mBAAmB;IAEjC;;;;;OAKG;IACH,uBAAuB,4BAA4B;IAEnD;;;;;OAKG;IACH,6BAA6B,kCAAkC;IAE/D;;;;;;OAMG;IACH,qBAAqB,0BAA0B;IAE/C;;;;;OAKG;IACH,yBAAyB,8BAA8B;IAOvD;;;;;;;OAOG;IACH,gBAAgB,qBAAqB;IAErC;;;;;OAKG;IACH,aAAa,kBAAkB;CAChC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAUzD;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { AppUpdateInfo
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
source: UpdateSource;
|
|
5
|
-
params: UpdateBundleParams;
|
|
1
|
+
import type { AppUpdateInfo } from "@hot-updater/core";
|
|
2
|
+
export declare const fetchUpdateInfo: ({ url, requestHeaders, onError, requestTimeout, }: {
|
|
3
|
+
url: string;
|
|
6
4
|
requestHeaders?: Record<string, string>;
|
|
7
5
|
onError?: (error: Error) => void;
|
|
8
6
|
requestTimeout?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchUpdateInfo.d.ts","sourceRoot":"","sources":["../../../src/fetchUpdateInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"fetchUpdateInfo.d.ts","sourceRoot":"","sources":["../../../src/fetchUpdateInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,eAAO,MAAM,eAAe,GAAU,mDAKnC;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,KAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CA8B/B,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export type { HotUpdaterEvent } from "./native";
|
|
1
|
+
import { type CheckForUpdateOptions } from "./checkForUpdate";
|
|
2
|
+
import { type UpdateParams } from "./native";
|
|
3
|
+
import { type HotUpdaterOptions } from "./wrap";
|
|
4
|
+
export type { HotUpdaterEvent, NotifyAppReadyResult } from "./native";
|
|
5
5
|
export * from "./store";
|
|
6
|
-
export { extractSignatureFailure, isSignatureVerificationError, type SignatureVerificationFailure, } from "./types";
|
|
7
|
-
export type { HotUpdaterOptions } from "./wrap";
|
|
6
|
+
export { extractSignatureFailure, type HotUpdaterResolver, isSignatureVerificationError, type ResolverCheckUpdateParams, type ResolverNotifyAppReadyParams, type SignatureVerificationFailure, } from "./types";
|
|
7
|
+
export type { HotUpdaterOptions, RunUpdateProcessResponse } from "./wrap";
|
|
8
8
|
export declare const HotUpdater: {
|
|
9
9
|
/**
|
|
10
10
|
* `HotUpdater.wrap` checks for updates at the entry point, and if there is a bundle to update, it downloads the bundle and applies the update strategy.
|
|
@@ -21,14 +21,16 @@ export declare const HotUpdater: {
|
|
|
21
21
|
* @example
|
|
22
22
|
* ```tsx
|
|
23
23
|
* export default HotUpdater.wrap({
|
|
24
|
-
*
|
|
24
|
+
* baseURL: "<your-update-server-url>",
|
|
25
|
+
* updateStrategy: "appVersion",
|
|
26
|
+
* updateMode: "auto",
|
|
25
27
|
* requestHeaders: {
|
|
26
28
|
* "Authorization": "Bearer <your-access-token>",
|
|
27
29
|
* },
|
|
28
30
|
* })(App);
|
|
29
31
|
* ```
|
|
30
32
|
*/
|
|
31
|
-
wrap:
|
|
33
|
+
wrap: (options: HotUpdaterOptions) => (WrappedComponent: import("react").ComponentType<object>) => import("react").ComponentType<object>;
|
|
32
34
|
/**
|
|
33
35
|
* Reloads the app.
|
|
34
36
|
*/
|
|
@@ -124,40 +126,7 @@ export declare const HotUpdater: {
|
|
|
124
126
|
* }
|
|
125
127
|
* ```
|
|
126
128
|
*/
|
|
127
|
-
checkForUpdate:
|
|
128
|
-
/**
|
|
129
|
-
* Manually checks and applies updates for the application.
|
|
130
|
-
*
|
|
131
|
-
* @param {RunUpdateProcessConfig} config - Update process configuration
|
|
132
|
-
* @param {string} config.source - Update server URL
|
|
133
|
-
* @param {Record<string, string>} [config.requestHeaders] - Request headers
|
|
134
|
-
* @param {boolean} [config.reloadOnForceUpdate=false] - Whether to automatically reload on force update
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* ```ts
|
|
138
|
-
* // Auto reload on force update
|
|
139
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
140
|
-
* source: "<your-update-server-url>",
|
|
141
|
-
* requestHeaders: {
|
|
142
|
-
* // Add necessary headers
|
|
143
|
-
* },
|
|
144
|
-
* reloadOnForceUpdate: true
|
|
145
|
-
* });
|
|
146
|
-
*
|
|
147
|
-
* // Manually handle reload on force update
|
|
148
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
149
|
-
* source: "<your-update-server-url>",
|
|
150
|
-
* reloadOnForceUpdate: false
|
|
151
|
-
* });
|
|
152
|
-
*
|
|
153
|
-
* if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
|
|
154
|
-
* await HotUpdater.reload();
|
|
155
|
-
* }
|
|
156
|
-
* ```
|
|
157
|
-
*
|
|
158
|
-
* @returns {Promise<RunUpdateProcessResponse>} The result of the update process
|
|
159
|
-
*/
|
|
160
|
-
runUpdateProcess: ({ reloadOnForceUpdate, ...checkForUpdateOptions }: import("./runUpdateProcess").RunUpdateProcessOptions) => Promise<import("./runUpdateProcess").RunUpdateProcessResponse>;
|
|
129
|
+
checkForUpdate: (config: CheckForUpdateOptions) => Promise<import("./checkForUpdate").CheckForUpdateResult | null>;
|
|
161
130
|
/**
|
|
162
131
|
* Updates the bundle of the app.
|
|
163
132
|
*
|
|
@@ -191,7 +160,7 @@ export declare const HotUpdater: {
|
|
|
191
160
|
* }
|
|
192
161
|
* ```
|
|
193
162
|
*/
|
|
194
|
-
updateBundle:
|
|
163
|
+
updateBundle: (params: UpdateParams) => Promise<boolean>;
|
|
195
164
|
/**
|
|
196
165
|
* Fetches the fingerprint of the app.
|
|
197
166
|
*
|
|
@@ -204,6 +173,31 @@ export declare const HotUpdater: {
|
|
|
204
173
|
* ```
|
|
205
174
|
*/
|
|
206
175
|
getFingerprintHash: () => string | null;
|
|
176
|
+
/**
|
|
177
|
+
* Gets the list of bundle IDs that have been marked as crashed.
|
|
178
|
+
* These bundles will be rejected if attempted to install again.
|
|
179
|
+
*
|
|
180
|
+
* @returns {string[]} Array of crashed bundle IDs
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* const crashedBundles = HotUpdater.getCrashHistory();
|
|
185
|
+
* console.log("Crashed bundles:", crashedBundles);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
getCrashHistory: () => string[];
|
|
189
|
+
/**
|
|
190
|
+
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
191
|
+
* to be installed again.
|
|
192
|
+
*
|
|
193
|
+
* @returns {boolean} true if clearing was successful
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* // Clear crash history to allow retrying a previously failed bundle
|
|
198
|
+
* HotUpdater.clearCrashHistory();
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
clearCrashHistory: () => boolean;
|
|
207
202
|
};
|
|
208
|
-
export { getUpdateSource } from "./checkForUpdate";
|
|
209
203
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAG3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAUL,KAAK,YAAY,EAElB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,KAAK,iBAAiB,EAAkC,MAAM,QAAQ,CAAC;AAEhF,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACtE,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,4BAA4B,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,GAClC,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAmT1E,eAAO,MAAM,UAAU;IAtQnB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;oBACa,iBAAiB;IAuCjC;;OAEG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;;;;;;;;OAYG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;6BACsB,qBAAqB;IAgB9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;2BACoB,YAAY;IAKnC;;;;;;;;;;OAUG;;IAGH;;;;;;;;;;;OAWG;;IAGH;;;;;;;;;;;OAWG;;CAK2C,CAAC"}
|
|
@@ -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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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: () => {
|