@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.
Files changed (109) hide show
  1. package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +393 -49
  2. package/android/src/main/java/com/hotupdater/BundleMetadata.kt +204 -0
  3. package/android/src/main/java/com/hotupdater/HotUpdater.kt +48 -36
  4. package/android/src/main/java/com/hotupdater/HotUpdaterException.kt +134 -0
  5. package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +168 -95
  6. package/android/src/main/java/com/hotupdater/OkHttpDownloadService.kt +15 -3
  7. package/android/src/main/java/com/hotupdater/SignatureVerifier.kt +17 -12
  8. package/android/src/newarch/HotUpdaterModule.kt +88 -23
  9. package/android/src/oldarch/HotUpdaterModule.kt +89 -22
  10. package/android/src/oldarch/HotUpdaterSpec.kt +6 -0
  11. package/ios/HotUpdater/Internal/BundleFileStorageService.swift +401 -77
  12. package/ios/HotUpdater/Internal/BundleMetadata.swift +177 -0
  13. package/ios/HotUpdater/Internal/HotUpdater.mm +213 -47
  14. package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +96 -25
  15. package/ios/HotUpdater/Internal/SignatureVerifier.swift +35 -29
  16. package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +2 -2
  17. package/ios/HotUpdater/Public/HotUpdater.h +8 -2
  18. package/lib/commonjs/DefaultResolver.js +38 -0
  19. package/lib/commonjs/DefaultResolver.js.map +1 -0
  20. package/lib/commonjs/checkForUpdate.js +33 -45
  21. package/lib/commonjs/checkForUpdate.js.map +1 -1
  22. package/lib/commonjs/error.js +45 -1
  23. package/lib/commonjs/error.js.map +1 -1
  24. package/lib/commonjs/fetchUpdateInfo.js +7 -45
  25. package/lib/commonjs/fetchUpdateInfo.js.map +1 -1
  26. package/lib/commonjs/index.js +249 -208
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/commonjs/native.js +103 -3
  29. package/lib/commonjs/native.js.map +1 -1
  30. package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
  31. package/lib/commonjs/types.js +12 -0
  32. package/lib/commonjs/types.js.map +1 -1
  33. package/lib/commonjs/wrap.js +70 -1
  34. package/lib/commonjs/wrap.js.map +1 -1
  35. package/lib/module/DefaultResolver.js +34 -0
  36. package/lib/module/DefaultResolver.js.map +1 -0
  37. package/lib/module/checkForUpdate.js +34 -43
  38. package/lib/module/checkForUpdate.js.map +1 -1
  39. package/lib/module/error.js +45 -0
  40. package/lib/module/error.js.map +1 -1
  41. package/lib/module/fetchUpdateInfo.js +7 -45
  42. package/lib/module/fetchUpdateInfo.js.map +1 -1
  43. package/lib/module/index.js +250 -203
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/native.js +87 -2
  46. package/lib/module/native.js.map +1 -1
  47. package/lib/module/specs/NativeHotUpdater.js.map +1 -1
  48. package/lib/module/types.js +12 -0
  49. package/lib/module/types.js.map +1 -1
  50. package/lib/module/wrap.js +71 -2
  51. package/lib/module/wrap.js.map +1 -1
  52. package/lib/typescript/commonjs/DefaultResolver.d.ts +10 -0
  53. package/lib/typescript/commonjs/DefaultResolver.d.ts.map +1 -0
  54. package/lib/typescript/commonjs/checkForUpdate.d.ts +12 -13
  55. package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/error.d.ts +120 -0
  57. package/lib/typescript/commonjs/error.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/fetchUpdateInfo.d.ts +3 -5
  59. package/lib/typescript/commonjs/fetchUpdateInfo.d.ts.map +1 -1
  60. package/lib/typescript/commonjs/index.d.ts +38 -44
  61. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/native.d.ts +58 -2
  63. package/lib/typescript/commonjs/native.d.ts.map +1 -1
  64. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +62 -0
  65. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/types.d.ts +115 -0
  67. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  68. package/lib/typescript/commonjs/wrap.d.ts +132 -7
  69. package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
  70. package/lib/typescript/module/DefaultResolver.d.ts +10 -0
  71. package/lib/typescript/module/DefaultResolver.d.ts.map +1 -0
  72. package/lib/typescript/module/checkForUpdate.d.ts +12 -13
  73. package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
  74. package/lib/typescript/module/error.d.ts +120 -0
  75. package/lib/typescript/module/error.d.ts.map +1 -1
  76. package/lib/typescript/module/fetchUpdateInfo.d.ts +3 -5
  77. package/lib/typescript/module/fetchUpdateInfo.d.ts.map +1 -1
  78. package/lib/typescript/module/index.d.ts +38 -44
  79. package/lib/typescript/module/index.d.ts.map +1 -1
  80. package/lib/typescript/module/native.d.ts +58 -2
  81. package/lib/typescript/module/native.d.ts.map +1 -1
  82. package/lib/typescript/module/specs/NativeHotUpdater.d.ts +62 -0
  83. package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
  84. package/lib/typescript/module/types.d.ts +115 -0
  85. package/lib/typescript/module/types.d.ts.map +1 -1
  86. package/lib/typescript/module/wrap.d.ts +132 -7
  87. package/lib/typescript/module/wrap.d.ts.map +1 -1
  88. package/package.json +6 -6
  89. package/plugin/build/withHotUpdater.js +3 -3
  90. package/src/DefaultResolver.ts +36 -0
  91. package/src/checkForUpdate.ts +51 -56
  92. package/src/error.ts +153 -0
  93. package/src/fetchUpdateInfo.ts +10 -58
  94. package/src/index.ts +315 -206
  95. package/src/native.ts +88 -2
  96. package/src/specs/NativeHotUpdater.ts +63 -0
  97. package/src/types.ts +135 -0
  98. package/src/wrap.tsx +245 -34
  99. package/android/src/main/java/com/hotupdater/HotUpdaterFactory.kt +0 -52
  100. package/ios/HotUpdater/Internal/HotUpdaterFactory.swift +0 -24
  101. package/lib/commonjs/runUpdateProcess.js +0 -69
  102. package/lib/commonjs/runUpdateProcess.js.map +0 -1
  103. package/lib/module/runUpdateProcess.js +0 -64
  104. package/lib/module/runUpdateProcess.js.map +0 -1
  105. package/lib/typescript/commonjs/runUpdateProcess.d.ts +0 -49
  106. package/lib/typescript/commonjs/runUpdateProcess.d.ts.map +0 -1
  107. package/lib/typescript/module/runUpdateProcess.d.ts +0 -49
  108. package/lib/typescript/module/runUpdateProcess.d.ts.map +0 -1
  109. package/src/runUpdateProcess.ts +0 -80
@@ -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;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;QAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC,CAAC;CACH;;AAED,wBAAoE"}
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;;GAE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;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 { RunUpdateProcessResponse } from "./runUpdateProcess";
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
- export interface HotUpdaterOptions extends CheckForUpdateOptions {
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
- * source: "<update-server-url>",
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 declare function wrap<P extends React.JSX.IntrinsicAttributes = object>(options: HotUpdaterOptions): (WrappedComponent: React.ComponentType<P>) => React.ComponentType<P>;
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;AACpE,OAAO,EAAE,KAAK,qBAAqB,EAAkB,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAGnE,KAAK,YAAY,GACb,kBAAkB,GAClB,UAAU,GACV,0BAA0B,CAAC;AAE/B,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D;;;;;;;;;;;;;;;;;;;;OAoBG;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;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,GAAG,OAAO,KAAK,IAAI,CAAC;IAC7D,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,CAAC,QAAQ,EAAE,wBAAwB,KAAK,IAAI,CAAC;CACzE;AAED,wBAAgB,IAAI,CAAC,CAAC,SAAS,KAA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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"}
@@ -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, UpdateBundleParams } from "@hot-updater/core";
2
- import { type UpdateSource } from "./fetchUpdateInfo";
1
+ import type { AppUpdateInfo } from "@hot-updater/core";
2
+ import type { HotUpdaterResolver } from "./types";
3
3
  export interface CheckForUpdateOptions {
4
- source: UpdateSource;
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 declare function checkForUpdate(options: CheckForUpdateOptions): Promise<CheckForUpdateResult | null>;
21
- export interface GetUpdateSourceOptions {
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 const getUpdateSource: (baseUrl: string, options: GetUpdateSourceOptions) => (params: UpdateBundleParams) => string;
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,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG3E,OAAO,EAAmB,KAAK,YAAY,EAAE,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,CAuDtC;AAED,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,cAAc,EAAE,YAAY,GAAG,aAAa,CAAC;CAC9C;AAED,eAAO,MAAM,eAAe,GACzB,SAAS,MAAM,EAAE,SAAS,sBAAsB,MAChD,QAAQ,kBAAkB,WAc1B,CAAC"}
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, UpdateBundleParams } from "@hot-updater/core";
2
- export type UpdateSource = string | ((params: UpdateBundleParams) => Promise<AppUpdateInfo | null>) | ((params: UpdateBundleParams) => string);
3
- export declare const fetchUpdateInfo: ({ source, params, requestHeaders, onError, requestTimeout, }: {
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,EACV,aAAa,EACb,kBAAkB,EAEnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,CAAC,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,GAC/D,CAAC,CAAC,MAAM,EAAE,kBAAkB,KAAK,MAAM,CAAC,CAAC;AAqC7C,eAAO,MAAM,eAAe,GAAU,8DAMnC;IACD,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,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,CAgC/B,CAAC"}
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 { checkForUpdate } from "./checkForUpdate";
2
- import { updateBundle } from "./native";
3
- import { wrap } from "./wrap";
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
- * source: "<your-update-server-url>",
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: typeof 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: typeof 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: typeof 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,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAQL,YAAY,EACb,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,KAAK,4BAA4B,GAClC,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAQhD,eAAO,MAAM,UAAU;IACrB;;;;;;;;;;;;;;;;;;;;;OAqBG;;IAEH;;OAEG;;IAEH;;;;;;;;;;;;;;;;OAgBG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;;;;;;;;;OAYG;;IAEH;;;;;;;;;;;;;;;;OAgBG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;;IAEH;;;;;;;;;;OAUG;;CAEJ,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
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,EAC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