@hot-updater/react-native 0.23.0 → 0.24.0

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 (91) 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/checkForUpdate.js +31 -28
  19. package/lib/commonjs/checkForUpdate.js.map +1 -1
  20. package/lib/commonjs/error.js +45 -1
  21. package/lib/commonjs/error.js.map +1 -1
  22. package/lib/commonjs/fetchUpdateInfo.js +7 -45
  23. package/lib/commonjs/fetchUpdateInfo.js.map +1 -1
  24. package/lib/commonjs/index.js +237 -208
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/native.js +103 -3
  27. package/lib/commonjs/native.js.map +1 -1
  28. package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
  29. package/lib/commonjs/wrap.js +39 -1
  30. package/lib/commonjs/wrap.js.map +1 -1
  31. package/lib/module/checkForUpdate.js +32 -26
  32. package/lib/module/checkForUpdate.js.map +1 -1
  33. package/lib/module/error.js +45 -0
  34. package/lib/module/error.js.map +1 -1
  35. package/lib/module/fetchUpdateInfo.js +7 -45
  36. package/lib/module/fetchUpdateInfo.js.map +1 -1
  37. package/lib/module/index.js +238 -203
  38. package/lib/module/index.js.map +1 -1
  39. package/lib/module/native.js +87 -2
  40. package/lib/module/native.js.map +1 -1
  41. package/lib/module/specs/NativeHotUpdater.js.map +1 -1
  42. package/lib/module/wrap.js +40 -2
  43. package/lib/module/wrap.js.map +1 -1
  44. package/lib/typescript/commonjs/checkForUpdate.d.ts +11 -13
  45. package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/error.d.ts +120 -0
  47. package/lib/typescript/commonjs/error.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/fetchUpdateInfo.d.ts +3 -5
  49. package/lib/typescript/commonjs/fetchUpdateInfo.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/index.d.ts +35 -41
  51. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/native.d.ts +58 -2
  53. package/lib/typescript/commonjs/native.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +62 -0
  55. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/wrap.d.ts +76 -5
  57. package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
  58. package/lib/typescript/module/checkForUpdate.d.ts +11 -13
  59. package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
  60. package/lib/typescript/module/error.d.ts +120 -0
  61. package/lib/typescript/module/error.d.ts.map +1 -1
  62. package/lib/typescript/module/fetchUpdateInfo.d.ts +3 -5
  63. package/lib/typescript/module/fetchUpdateInfo.d.ts.map +1 -1
  64. package/lib/typescript/module/index.d.ts +35 -41
  65. package/lib/typescript/module/index.d.ts.map +1 -1
  66. package/lib/typescript/module/native.d.ts +58 -2
  67. package/lib/typescript/module/native.d.ts.map +1 -1
  68. package/lib/typescript/module/specs/NativeHotUpdater.d.ts +62 -0
  69. package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
  70. package/lib/typescript/module/wrap.d.ts +76 -5
  71. package/lib/typescript/module/wrap.d.ts.map +1 -1
  72. package/package.json +8 -7
  73. package/plugin/build/withHotUpdater.js +55 -4
  74. package/src/checkForUpdate.ts +51 -40
  75. package/src/error.ts +153 -0
  76. package/src/fetchUpdateInfo.ts +10 -58
  77. package/src/index.ts +283 -206
  78. package/src/native.ts +88 -2
  79. package/src/specs/NativeHotUpdater.ts +63 -0
  80. package/src/wrap.tsx +131 -9
  81. package/android/src/main/java/com/hotupdater/HotUpdaterFactory.kt +0 -52
  82. package/ios/HotUpdater/Internal/HotUpdaterFactory.swift +0 -24
  83. package/lib/commonjs/runUpdateProcess.js +0 -69
  84. package/lib/commonjs/runUpdateProcess.js.map +0 -1
  85. package/lib/module/runUpdateProcess.js +0 -64
  86. package/lib/module/runUpdateProcess.js.map +0 -1
  87. package/lib/typescript/commonjs/runUpdateProcess.d.ts +0 -49
  88. package/lib/typescript/commonjs/runUpdateProcess.d.ts.map +0 -1
  89. package/lib/typescript/module/runUpdateProcess.d.ts +0 -49
  90. package/lib/typescript/module/runUpdateProcess.d.ts.map +0 -1
  91. package/src/runUpdateProcess.ts +0 -80
@@ -3,10 +3,34 @@
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
+ */
8
12
  import { jsx as _jsx } from "react/jsx-runtime";
9
13
  export function wrap(options) {
14
+ if (options.updateMode === "manual") {
15
+ return WrappedComponent => {
16
+ const ManualHOC = props => {
17
+ useLayoutEffect(() => {
18
+ try {
19
+ const result = nativeNotifyAppReady();
20
+ options.onNotifyAppReady?.(result);
21
+ } catch (e) {
22
+ console.warn("[HotUpdater] Failed to notify app ready:", e);
23
+ }
24
+ }, []);
25
+ return /*#__PURE__*/_jsx(WrappedComponent, {
26
+ ...props
27
+ });
28
+ };
29
+ return ManualHOC;
30
+ };
31
+ }
32
+
33
+ // updateMode: "auto"
10
34
  const {
11
35
  reloadOnForceUpdate = true,
12
36
  ...restOptions
@@ -20,8 +44,10 @@ export function wrap(options) {
20
44
  try {
21
45
  setUpdateStatus("CHECK_FOR_UPDATE");
22
46
  const updateInfo = await checkForUpdate({
23
- source: restOptions.source,
47
+ baseURL: restOptions.baseURL,
48
+ updateStrategy: restOptions.updateStrategy,
24
49
  requestHeaders: restOptions.requestHeaders,
50
+ requestTimeout: restOptions.requestTimeout,
25
51
  onError: restOptions.onError
26
52
  });
27
53
  setMessage(updateInfo?.message ?? null);
@@ -72,6 +98,18 @@ export function wrap(options) {
72
98
  useEffect(() => {
73
99
  restOptions.onProgress?.(progress);
74
100
  }, [progress]);
101
+
102
+ // Notify native side that app is ready (JS bundle fully loaded)
103
+ useLayoutEffect(() => {
104
+ try {
105
+ const result = nativeNotifyAppReady();
106
+ restOptions.onNotifyAppReady?.(result);
107
+ } catch (e) {
108
+ console.warn("[HotUpdater] Failed to notify app ready:", e);
109
+ }
110
+ }, []);
111
+
112
+ // Start update check
75
113
  useLayoutEffect(() => {
76
114
  initHotUpdater();
77
115
  }, []);
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useLayoutEffect","useState","checkForUpdate","useEventCallback","getBundleId","reload","useHotUpdaterStore","jsx","_jsx","wrap","options","reloadOnForceUpdate","restOptions","WrappedComponent","HotUpdaterHOC","props","progress","state","message","setMessage","updateStatus","setUpdateStatus","initHotUpdater","updateInfo","source","requestHeaders","onError","onUpdateProcessCompleted","status","shouldForceUpdate","id","updateBundle","catch","error","isSuccess","Error","onProgress","fallbackComponent","Fallback"],"sourceRoot":"../../src","sources":["wrap.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AACnE,SAAqCC,cAAc,QAAQ,qBAAkB;AAE7E,SAASC,gBAAgB,QAAQ,6BAA0B;AAC3D,SAASC,WAAW,EAAEC,MAAM,QAAQ,aAAU;AAE9C,SAASC,kBAAkB,QAAQ,YAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAmD7C,OAAO,SAASC,IAAIA,CAClBC,OAA0B,EAC4C;EACtE,MAAM;IAAEC,mBAAmB,GAAG,IAAI;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAE9D,OAAQG,gBAAwC,IAAK;IACnD,MAAMC,aAA0B,GAAIC,KAAQ,IAAK;MAC/C,MAAMC,QAAQ,GAAGV,kBAAkB,CAAEW,KAAK,IAAKA,KAAK,CAACD,QAAQ,CAAC;MAE9D,MAAM,CAACE,OAAO,EAAEC,UAAU,CAAC,GAAGlB,QAAQ,CAAgB,IAAI,CAAC;MAC3D,MAAM,CAACmB,YAAY,EAAEC,eAAe,CAAC,GACnCpB,QAAQ,CAAe,kBAAkB,CAAC;MAE5C,MAAMqB,cAAc,GAAGnB,gBAAgB,CAAC,YAAY;QAClD,IAAI;UACFkB,eAAe,CAAC,kBAAkB,CAAC;UAEnC,MAAME,UAAU,GAAG,MAAMrB,cAAc,CAAC;YACtCsB,MAAM,EAAEZ,WAAW,CAACY,MAAM;YAC1BC,cAAc,EAAEb,WAAW,CAACa,cAAc;YAC1CC,OAAO,EAAEd,WAAW,CAACc;UACvB,CAAC,CAAC;UAEFP,UAAU,CAACI,UAAU,EAAEL,OAAO,IAAI,IAAI,CAAC;UAEvC,IAAI,CAACK,UAAU,EAAE;YACfX,WAAW,CAAC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,CAAC;QAC7C;MACF,CAAC,CAAC;MAEFtB,SAAS,CAAC,MAAM;QACda,WAAW,CAACwB,UAAU,GAAGpB,QAAQ,CAAC;MACpC,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;MAEdhB,eAAe,CAAC,MAAM;QACpBsB,cAAc,CAAC,CAAC;MAClB,CAAC,EAAE,EAAE,CAAC;MAEN,IACEV,WAAW,CAACyB,iBAAiB,IAC7BjB,YAAY,KAAK,0BAA0B,EAC3C;QACA,MAAMkB,QAAQ,GAAG1B,WAAW,CAACyB,iBAAiB;QAC9C,oBACE7B,IAAA,CAAC8B,QAAQ;UACPtB,QAAQ,EAAEA,QAAS;UACnBY,MAAM,EAAER,YAAa;UACrBF,OAAO,EAAEA;QAAQ,CAClB,CAAC;MAEN;MAEA,oBAAOV,IAAA,CAACK,gBAAgB;QAAA,GAAKE;MAAK,CAAG,CAAC;IACxC,CAAC;IAED,OAAOD,aAAa;EACtB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["React","useEffect","useLayoutEffect","useState","checkForUpdate","useEventCallback","getBundleId","notifyAppReady","nativeNotifyAppReady","reload","useHotUpdaterStore","jsx","_jsx","wrap","options","updateMode","WrappedComponent","ManualHOC","props","result","onNotifyAppReady","e","console","warn","reloadOnForceUpdate","restOptions","HotUpdaterHOC","progress","state","message","setMessage","updateStatus","setUpdateStatus","initHotUpdater","updateInfo","baseURL","updateStrategy","requestHeaders","requestTimeout","onError","onUpdateProcessCompleted","status","shouldForceUpdate","id","updateBundle","catch","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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ateSource } from "./fetchUpdateInfo";
1
+ import type { AppUpdateInfo } from "@hot-updater/core";
3
2
  export interface CheckForUpdateOptions {
4
- source: UpdateSource;
3
+ /**
4
+ * Update strategy
5
+ * - "fingerprint": Use fingerprint hash to check for updates
6
+ * - "appVersion": Use app version to check for updates
7
+ * - Can override the strategy set in HotUpdater.wrap()
8
+ */
9
+ updateStrategy: "appVersion" | "fingerprint";
5
10
  requestHeaders?: Record<string, string>;
6
11
  onError?: (error: Error) => void;
7
12
  /**
@@ -17,15 +22,8 @@ export type CheckForUpdateResult = AppUpdateInfo & {
17
22
  */
18
23
  updateBundle: () => Promise<boolean>;
19
24
  };
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";
25
+ export interface InternalCheckForUpdateOptions extends CheckForUpdateOptions {
26
+ baseURL: string;
29
27
  }
30
- export declare const getUpdateSource: (baseUrl: string, options: GetUpdateSourceOptions) => (params: UpdateBundleParams) => string;
28
+ export declare function checkForUpdate(options: InternalCheckForUpdateOptions): Promise<CheckForUpdateResult | null>;
31
29
  //# 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,K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+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";
1
+ import { type CheckForUpdateOptions } from "./checkForUpdate";
2
+ import { type UpdateParams } from "./native";
3
3
  import { wrap } from "./wrap";
4
- export type { HotUpdaterEvent } from "./native";
4
+ export type { HotUpdaterEvent, NotifyAppReadyResult } from "./native";
5
5
  export * from "./store";
6
6
  export { extractSignatureFailure, isSignatureVerificationError, type SignatureVerificationFailure, } from "./types";
7
- export type { HotUpdaterOptions } from "./wrap";
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,7 +21,9 @@ 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
  * },
@@ -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;AAC1B,OAAO,EAUL,KAAK,YAAY,EAElB,MAAM,UAAU,CAAC;AAElB,OAAO,EAA0B,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtD,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACtE,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,KAAK,4BAA4B,GAClC,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAwR1E,eAAO,MAAM,UAAU;IA1OnB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;UAMG,OAAO,IAAI;IAEjB;;OAEG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;;;;;;;;OAYG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;6BACsB,qBAAqB;IAmB9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;2BACoB,YAAY;IAMnC;;;;;;;;;;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, otherwise rejects with an error.
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 {Promise<string>} Resolves with the current version id or null if not available.
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;AAMlC,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;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OA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G;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;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,O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