@hot-updater/react-native 0.30.9 → 0.30.11

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.
@@ -23,18 +23,101 @@ exports.isHotUpdaterError = isHotUpdaterError;
23
23
  * - Non-retryable: Most validation and verification errors
24
24
  */
25
25
  let HotUpdaterErrorCode = exports.HotUpdaterErrorCode = /*#__PURE__*/function (HotUpdaterErrorCode) {
26
+ // ==================== Parameter Validation Errors ====================
27
+ /**
28
+ * Bundle ID is missing or empty.
29
+ * Thrown when bundleId parameter is null, undefined, or empty string.
30
+ * @retryable false
31
+ */
26
32
  HotUpdaterErrorCode["MISSING_BUNDLE_ID"] = "MISSING_BUNDLE_ID";
33
+ /**
34
+ * File URL is invalid or malformed.
35
+ * Thrown when fileUrl parameter cannot be parsed as a valid URL.
36
+ * @retryable false
37
+ */
27
38
  HotUpdaterErrorCode["INVALID_FILE_URL"] = "INVALID_FILE_URL";
39
+ // ==================== Bundle Storage Errors ====================
40
+ /**
41
+ * Failed to create required directory for bundle storage.
42
+ * Thrown when bundle directory creation fails due to permissions or disk errors.
43
+ * @retryable false - Usually indicates permissions or filesystem corruption
44
+ */
28
45
  HotUpdaterErrorCode["DIRECTORY_CREATION_FAILED"] = "DIRECTORY_CREATION_FAILED";
46
+ /**
47
+ * Bundle download failed.
48
+ * Covers network errors, HTTP errors (4xx/5xx), timeouts, and connection issues.
49
+ * Check error message for specific cause (network, HTTP status code, etc.).
50
+ * @retryable true - Network issues are often transient
51
+ */
29
52
  HotUpdaterErrorCode["DOWNLOAD_FAILED"] = "DOWNLOAD_FAILED";
53
+ /**
54
+ * Download incomplete - received size doesn't match expected size.
55
+ * Thrown when downloaded file size doesn't match Content-Length header.
56
+ * Error message includes both expected and actual byte counts.
57
+ * @retryable true - Download may succeed on retry
58
+ */
30
59
  HotUpdaterErrorCode["INCOMPLETE_DOWNLOAD"] = "INCOMPLETE_DOWNLOAD";
60
+ /**
61
+ * Bundle archive format is invalid or corrupted.
62
+ * Thrown when ZIP file has wrong magic bytes, invalid structure, or unsupported format.
63
+ * Also thrown for path traversal attempts during extraction.
64
+ * @retryable false - Indicates corrupted or malicious bundle
65
+ */
31
66
  HotUpdaterErrorCode["EXTRACTION_FORMAT_ERROR"] = "EXTRACTION_FORMAT_ERROR";
67
+ /**
68
+ * Bundle missing required platform files.
69
+ * Thrown when extracted bundle doesn't contain index.android.bundle (Android)
70
+ * or main.jsbundle (iOS).
71
+ * @retryable false - Indicates incorrectly built bundle
72
+ */
32
73
  HotUpdaterErrorCode["INVALID_BUNDLE"] = "INVALID_BUNDLE";
74
+ /**
75
+ * Insufficient disk space for bundle download and extraction.
76
+ * Thrown when available disk space is less than required (file size * 2).
77
+ * Error message includes required and available bytes.
78
+ * @retryable false - User must free up disk space
79
+ */
33
80
  HotUpdaterErrorCode["INSUFFICIENT_DISK_SPACE"] = "INSUFFICIENT_DISK_SPACE";
81
+ /**
82
+ * Bundle signature verification failed (general).
83
+ * Thrown when cryptographic signature verification fails.
84
+ * All signature/hash sub-errors are collapsed into this public code.
85
+ * @retryable false - Indicates tampered or incorrectly signed bundle
86
+ */
34
87
  HotUpdaterErrorCode["SIGNATURE_VERIFICATION_FAILED"] = "SIGNATURE_VERIFICATION_FAILED";
88
+ /**
89
+ * Failed to move bundle to final location.
90
+ * Thrown when atomic move from temp directory to final directory fails.
91
+ * iOS: Thrown if move operation fails.
92
+ * Android: Thrown if rename, move, AND copy all fail.
93
+ * @retryable false - Usually indicates filesystem corruption or permissions
94
+ */
35
95
  HotUpdaterErrorCode["MOVE_OPERATION_FAILED"] = "MOVE_OPERATION_FAILED";
96
+ /**
97
+ * Bundle is in crashed history and cannot be applied.
98
+ * Thrown when attempting to install a bundle that previously caused a crash.
99
+ * Use HotUpdater.clearCrashHistory() to allow retrying this bundle.
100
+ * @retryable false - Bundle was marked as crashed for safety
101
+ */
36
102
  HotUpdaterErrorCode["BUNDLE_IN_CRASHED_HISTORY"] = "BUNDLE_IN_CRASHED_HISTORY";
103
+ // ==================== Signature Verification Errors ====================
104
+ // (Collapsed into SIGNATURE_VERIFICATION_FAILED)
105
+ // ==================== Internal Errors ====================
106
+ /**
107
+ * Internal error: self deallocated during update (iOS only).
108
+ * Thrown when the native object is deallocated mid-operation.
109
+ * iOS-specific due to manual memory management (ARC).
110
+ * Not applicable to Android (uses garbage collection).
111
+ * @platform iOS
112
+ * @retryable false - Memory management issue
113
+ */
37
114
  HotUpdaterErrorCode["SELF_DEALLOCATED"] = "SELF_DEALLOCATED";
115
+ /**
116
+ * An unknown or unexpected error occurred.
117
+ * Catch-all for errors that don't fit other categories.
118
+ * Check error message for details.
119
+ * @retryable unknown - Depends on underlying cause
120
+ */
38
121
  HotUpdaterErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
39
122
  return HotUpdaterErrorCode;
40
123
  }({});
@@ -1 +1 @@
1
- {"version":3,"names":["HotUpdaterErrorCode","exports","isHotUpdaterError","error","code","Object","values","includes","HotUpdaterError","Error","constructor","message","name"],"sourceRoot":"../../src","sources":["error.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAhBA,IAkBYA,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;AAmH/B;AACA;AACA;AACO,SAASE,iBAAiBA,CAC/BC,KAAc,EAC2C;EACzD,OACE,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,MAAM,IAAIA,KAAK,IACf,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ,IAC9BC,MAAM,CAACC,MAAM,CAACN,mBAAmB,CAAC,CAACO,QAAQ,CACzCJ,KAAK,CAACC,IACR,CAAC;AAEL;;AAEA;AACA;AACA;AACO,MAAMI,eAAe,SAASC,KAAK,CAAC;EACzCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,iBAAiB;EAC/B;AACF;AAACX,OAAA,CAAAO,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["HotUpdaterErrorCode","exports","isHotUpdaterError","error","code","Object","values","includes","HotUpdaterError","Error","constructor","message","name"],"sourceRoot":"../../src","sources":["error.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAhBA,IAkBYA,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,0BAAnBA,mBAAmB;EAC7B;EAEA;AACF;AACA;AACA;AACA;EAPYA,mBAAmB;EAU7B;AACF;AACA;AACA;AACA;EAdYA,mBAAmB;EAiB7B;EAEA;AACF;AACA;AACA;AACA;EAvBYA,mBAAmB;EA0B7B;AACF;AACA;AACA;AACA;AACA;EA/BYA,mBAAmB;EAkC7B;AACF;AACA;AACA;AACA;AACA;EAvCYA,mBAAmB;EA0C7B;AACF;AACA;AACA;AACA;AACA;EA/CYA,mBAAmB;EAkD7B;AACF;AACA;AACA;AACA;AACA;EAvDYA,mBAAmB;EA0D7B;AACF;AACA;AACA;AACA;AACA;EA/DYA,mBAAmB;EAkE7B;AACF;AACA;AACA;AACA;AACA;EAvEYA,mBAAmB;EA0E7B;AACF;AACA;AACA;AACA;AACA;AACA;EAhFYA,mBAAmB;EAmF7B;AACF;AACA;AACA;AACA;AACA;EAxFYA,mBAAmB;EA2F7B;EACA;EAEA;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EAvGYA,mBAAmB;EA0G7B;AACF;AACA;AACA;AACA;AACA;EA/GYA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;AAmH/B;AACA;AACA;AACO,SAASE,iBAAiBA,CAC/BC,KAAc,EAC2C;EACzD,OACE,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,MAAM,IAAIA,KAAK,IACf,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ,IAC9BC,MAAM,CAACC,MAAM,CAACN,mBAAmB,CAAC,CAACO,QAAQ,CACzCJ,KAAK,CAACC,IACR,CAAC;AAEL;;AAEA;AACA;AACA;AACO,MAAMI,eAAe,SAASC,KAAK,CAAC;EACzCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,iBAAiB;EAC/B;AACF;AAACX,OAAA,CAAAO,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -7,14 +7,13 @@ exports.fetchUpdateInfo = void 0;
7
7
  const fetchUpdateInfo = async ({
8
8
  url,
9
9
  requestHeaders,
10
- onError,
11
10
  requestTimeout = 5000
12
11
  }) => {
12
+ const controller = new AbortController();
13
+ const timeoutId = setTimeout(() => {
14
+ controller.abort();
15
+ }, requestTimeout);
13
16
  try {
14
- const controller = new AbortController();
15
- const timeoutId = setTimeout(() => {
16
- controller.abort();
17
- }, requestTimeout);
18
17
  const headers = {
19
18
  "Content-Type": "application/json",
20
19
  ...requestHeaders
@@ -23,18 +22,17 @@ const fetchUpdateInfo = async ({
23
22
  signal: controller.signal,
24
23
  headers
25
24
  });
26
- clearTimeout(timeoutId);
27
25
  if (response.status !== 200) {
28
26
  throw new Error(response.statusText);
29
27
  }
30
28
  return response.json();
31
29
  } catch (error) {
32
30
  if (error instanceof Error && error.name === "AbortError") {
33
- onError?.(new Error("Request timed out"));
34
- } else {
35
- onError?.(error);
31
+ throw new Error("Request timed out");
36
32
  }
37
- return null;
33
+ throw error;
34
+ } finally {
35
+ clearTimeout(timeoutId);
38
36
  }
39
37
  };
40
38
  exports.fetchUpdateInfo = fetchUpdateInfo;
@@ -1 +1 @@
1
- {"version":3,"names":["fetchUpdateInfo","url","requestHeaders","onError","requestTimeout","controller","AbortController","timeoutId","setTimeout","abort","headers","response","fetch","signal","clearTimeout","status","Error","statusText","json","error","name","exports"],"sourceRoot":"../../src","sources":["fetchUpdateInfo.ts"],"mappings":";;;;;;AAEO,MAAMA,eAAe,GAAG,MAAAA,CAAO;EACpCC,GAAG;EACHC,cAAc;EACdC,OAAO;EACPC,cAAc,GAAG;AAMnB,CAAC,KAAoC;EACnC,IAAI;IACF,MAAMC,UAAU,GAAG,IAAIC,eAAe,CAAC,CAAC;IACxC,MAAMC,SAAS,GAAGC,UAAU,CAAC,MAAM;MACjCH,UAAU,CAACI,KAAK,CAAC,CAAC;IACpB,CAAC,EAAEL,cAAc,CAAC;IAElB,MAAMM,OAAO,GAAG;MACd,cAAc,EAAE,kBAAkB;MAClC,GAAGR;IACL,CAAC;IAED,MAAMS,QAAQ,GAAG,MAAMC,KAAK,CAACX,GAAG,EAAE;MAChCY,MAAM,EAAER,UAAU,CAACQ,MAAM;MACzBH;IACF,CAAC,CAAC;IACFI,YAAY,CAACP,SAAS,CAAC;IAEvB,IAAII,QAAQ,CAACI,MAAM,KAAK,GAAG,EAAE;MAC3B,MAAM,IAAIC,KAAK,CAACL,QAAQ,CAACM,UAAU,CAAC;IACtC;IACA,OAAON,QAAQ,CAACO,IAAI,CAAC,CAAC;EACxB,CAAC,CAAC,OAAOC,KAAc,EAAE;IACvB,IAAIA,KAAK,YAAYH,KAAK,IAAIG,KAAK,CAACC,IAAI,KAAK,YAAY,EAAE;MACzDjB,OAAO,GAAG,IAAIa,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC3C,CAAC,MAAM;MACLb,OAAO,GAAGgB,KAAc,CAAC;IAC3B;IACA,OAAO,IAAI;EACb;AACF,CAAC;AAACE,OAAA,CAAArB,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["fetchUpdateInfo","url","requestHeaders","requestTimeout","controller","AbortController","timeoutId","setTimeout","abort","headers","response","fetch","signal","status","Error","statusText","json","error","name","clearTimeout","exports"],"sourceRoot":"../../src","sources":["fetchUpdateInfo.ts"],"mappings":";;;;;;AAEO,MAAMA,eAAe,GAAG,MAAAA,CAAO;EACpCC,GAAG;EACHC,cAAc;EACdC,cAAc,GAAG;AAKnB,CAAC,KAAoC;EACnC,MAAMC,UAAU,GAAG,IAAIC,eAAe,CAAC,CAAC;EACxC,MAAMC,SAAS,GAAGC,UAAU,CAAC,MAAM;IACjCH,UAAU,CAACI,KAAK,CAAC,CAAC;EACpB,CAAC,EAAEL,cAAc,CAAC;EAElB,IAAI;IACF,MAAMM,OAAO,GAAG;MACd,cAAc,EAAE,kBAAkB;MAClC,GAAGP;IACL,CAAC;IAED,MAAMQ,QAAQ,GAAG,MAAMC,KAAK,CAACV,GAAG,EAAE;MAChCW,MAAM,EAAER,UAAU,CAACQ,MAAM;MACzBH;IACF,CAAC,CAAC;IAEF,IAAIC,QAAQ,CAACG,MAAM,KAAK,GAAG,EAAE;MAC3B,MAAM,IAAIC,KAAK,CAACJ,QAAQ,CAACK,UAAU,CAAC;IACtC;IACA,OAAOL,QAAQ,CAACM,IAAI,CAAC,CAAC;EACxB,CAAC,CAAC,OAAOC,KAAc,EAAE;IACvB,IAAIA,KAAK,YAAYH,KAAK,IAAIG,KAAK,CAACC,IAAI,KAAK,YAAY,EAAE;MACzD,MAAM,IAAIJ,KAAK,CAAC,mBAAmB,CAAC;IACtC;IACA,MAAMG,KAAK;EACb,CAAC,SAAS;IACRE,YAAY,CAACb,SAAS,CAAC;EACzB;AACF,CAAC;AAACc,OAAA,CAAApB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -19,18 +19,101 @@
19
19
  */
20
20
 
21
21
  export let HotUpdaterErrorCode = /*#__PURE__*/function (HotUpdaterErrorCode) {
22
+ // ==================== Parameter Validation Errors ====================
23
+ /**
24
+ * Bundle ID is missing or empty.
25
+ * Thrown when bundleId parameter is null, undefined, or empty string.
26
+ * @retryable false
27
+ */
22
28
  HotUpdaterErrorCode["MISSING_BUNDLE_ID"] = "MISSING_BUNDLE_ID";
29
+ /**
30
+ * File URL is invalid or malformed.
31
+ * Thrown when fileUrl parameter cannot be parsed as a valid URL.
32
+ * @retryable false
33
+ */
23
34
  HotUpdaterErrorCode["INVALID_FILE_URL"] = "INVALID_FILE_URL";
35
+ // ==================== Bundle Storage Errors ====================
36
+ /**
37
+ * Failed to create required directory for bundle storage.
38
+ * Thrown when bundle directory creation fails due to permissions or disk errors.
39
+ * @retryable false - Usually indicates permissions or filesystem corruption
40
+ */
24
41
  HotUpdaterErrorCode["DIRECTORY_CREATION_FAILED"] = "DIRECTORY_CREATION_FAILED";
42
+ /**
43
+ * Bundle download failed.
44
+ * Covers network errors, HTTP errors (4xx/5xx), timeouts, and connection issues.
45
+ * Check error message for specific cause (network, HTTP status code, etc.).
46
+ * @retryable true - Network issues are often transient
47
+ */
25
48
  HotUpdaterErrorCode["DOWNLOAD_FAILED"] = "DOWNLOAD_FAILED";
49
+ /**
50
+ * Download incomplete - received size doesn't match expected size.
51
+ * Thrown when downloaded file size doesn't match Content-Length header.
52
+ * Error message includes both expected and actual byte counts.
53
+ * @retryable true - Download may succeed on retry
54
+ */
26
55
  HotUpdaterErrorCode["INCOMPLETE_DOWNLOAD"] = "INCOMPLETE_DOWNLOAD";
56
+ /**
57
+ * Bundle archive format is invalid or corrupted.
58
+ * Thrown when ZIP file has wrong magic bytes, invalid structure, or unsupported format.
59
+ * Also thrown for path traversal attempts during extraction.
60
+ * @retryable false - Indicates corrupted or malicious bundle
61
+ */
27
62
  HotUpdaterErrorCode["EXTRACTION_FORMAT_ERROR"] = "EXTRACTION_FORMAT_ERROR";
63
+ /**
64
+ * Bundle missing required platform files.
65
+ * Thrown when extracted bundle doesn't contain index.android.bundle (Android)
66
+ * or main.jsbundle (iOS).
67
+ * @retryable false - Indicates incorrectly built bundle
68
+ */
28
69
  HotUpdaterErrorCode["INVALID_BUNDLE"] = "INVALID_BUNDLE";
70
+ /**
71
+ * Insufficient disk space for bundle download and extraction.
72
+ * Thrown when available disk space is less than required (file size * 2).
73
+ * Error message includes required and available bytes.
74
+ * @retryable false - User must free up disk space
75
+ */
29
76
  HotUpdaterErrorCode["INSUFFICIENT_DISK_SPACE"] = "INSUFFICIENT_DISK_SPACE";
77
+ /**
78
+ * Bundle signature verification failed (general).
79
+ * Thrown when cryptographic signature verification fails.
80
+ * All signature/hash sub-errors are collapsed into this public code.
81
+ * @retryable false - Indicates tampered or incorrectly signed bundle
82
+ */
30
83
  HotUpdaterErrorCode["SIGNATURE_VERIFICATION_FAILED"] = "SIGNATURE_VERIFICATION_FAILED";
84
+ /**
85
+ * Failed to move bundle to final location.
86
+ * Thrown when atomic move from temp directory to final directory fails.
87
+ * iOS: Thrown if move operation fails.
88
+ * Android: Thrown if rename, move, AND copy all fail.
89
+ * @retryable false - Usually indicates filesystem corruption or permissions
90
+ */
31
91
  HotUpdaterErrorCode["MOVE_OPERATION_FAILED"] = "MOVE_OPERATION_FAILED";
92
+ /**
93
+ * Bundle is in crashed history and cannot be applied.
94
+ * Thrown when attempting to install a bundle that previously caused a crash.
95
+ * Use HotUpdater.clearCrashHistory() to allow retrying this bundle.
96
+ * @retryable false - Bundle was marked as crashed for safety
97
+ */
32
98
  HotUpdaterErrorCode["BUNDLE_IN_CRASHED_HISTORY"] = "BUNDLE_IN_CRASHED_HISTORY";
99
+ // ==================== Signature Verification Errors ====================
100
+ // (Collapsed into SIGNATURE_VERIFICATION_FAILED)
101
+ // ==================== Internal Errors ====================
102
+ /**
103
+ * Internal error: self deallocated during update (iOS only).
104
+ * Thrown when the native object is deallocated mid-operation.
105
+ * iOS-specific due to manual memory management (ARC).
106
+ * Not applicable to Android (uses garbage collection).
107
+ * @platform iOS
108
+ * @retryable false - Memory management issue
109
+ */
33
110
  HotUpdaterErrorCode["SELF_DEALLOCATED"] = "SELF_DEALLOCATED";
111
+ /**
112
+ * An unknown or unexpected error occurred.
113
+ * Catch-all for errors that don't fit other categories.
114
+ * Check error message for details.
115
+ * @retryable unknown - Depends on underlying cause
116
+ */
34
117
  HotUpdaterErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
35
118
  return HotUpdaterErrorCode;
36
119
  }({});
@@ -1 +1 @@
1
- {"version":3,"names":["HotUpdaterErrorCode","isHotUpdaterError","error","code","Object","values","includes","HotUpdaterError","Error","constructor","message","name"],"sourceRoot":"../../src","sources":["error.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,WAAYA,mBAAmB,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;;AAmH/B;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAC/BC,KAAc,EAC2C;EACzD,OACE,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,MAAM,IAAIA,KAAK,IACf,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ,IAC9BC,MAAM,CAACC,MAAM,CAACL,mBAAmB,CAAC,CAACM,QAAQ,CACzCJ,KAAK,CAACC,IACR,CAAC;AAEL;;AAEA;AACA;AACA;AACA,OAAO,MAAMI,eAAe,SAASC,KAAK,CAAC;EACzCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,iBAAiB;EAC/B;AACF","ignoreList":[]}
1
+ {"version":3,"names":["HotUpdaterErrorCode","isHotUpdaterError","error","code","Object","values","includes","HotUpdaterError","Error","constructor","message","name"],"sourceRoot":"../../src","sources":["error.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,WAAYA,mBAAmB,0BAAnBA,mBAAmB;EAC7B;EAEA;AACF;AACA;AACA;AACA;EAPYA,mBAAmB;EAU7B;AACF;AACA;AACA;AACA;EAdYA,mBAAmB;EAiB7B;EAEA;AACF;AACA;AACA;AACA;EAvBYA,mBAAmB;EA0B7B;AACF;AACA;AACA;AACA;AACA;EA/BYA,mBAAmB;EAkC7B;AACF;AACA;AACA;AACA;AACA;EAvCYA,mBAAmB;EA0C7B;AACF;AACA;AACA;AACA;AACA;EA/CYA,mBAAmB;EAkD7B;AACF;AACA;AACA;AACA;AACA;EAvDYA,mBAAmB;EA0D7B;AACF;AACA;AACA;AACA;AACA;EA/DYA,mBAAmB;EAkE7B;AACF;AACA;AACA;AACA;AACA;EAvEYA,mBAAmB;EA0E7B;AACF;AACA;AACA;AACA;AACA;AACA;EAhFYA,mBAAmB;EAmF7B;AACF;AACA;AACA;AACA;AACA;EAxFYA,mBAAmB;EA2F7B;EACA;EAEA;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EAvGYA,mBAAmB;EA0G7B;AACF;AACA;AACA;AACA;AACA;EA/GYA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;;AAmH/B;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAC/BC,KAAc,EAC2C;EACzD,OACE,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,MAAM,IAAIA,KAAK,IACf,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ,IAC9BC,MAAM,CAACC,MAAM,CAACL,mBAAmB,CAAC,CAACM,QAAQ,CACzCJ,KAAK,CAACC,IACR,CAAC;AAEL;;AAEA;AACA;AACA;AACA,OAAO,MAAMI,eAAe,SAASC,KAAK,CAAC;EACzCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,iBAAiB;EAC/B;AACF","ignoreList":[]}
@@ -3,14 +3,13 @@
3
3
  export const fetchUpdateInfo = async ({
4
4
  url,
5
5
  requestHeaders,
6
- onError,
7
6
  requestTimeout = 5000
8
7
  }) => {
8
+ const controller = new AbortController();
9
+ const timeoutId = setTimeout(() => {
10
+ controller.abort();
11
+ }, requestTimeout);
9
12
  try {
10
- const controller = new AbortController();
11
- const timeoutId = setTimeout(() => {
12
- controller.abort();
13
- }, requestTimeout);
14
13
  const headers = {
15
14
  "Content-Type": "application/json",
16
15
  ...requestHeaders
@@ -19,18 +18,17 @@ export const fetchUpdateInfo = async ({
19
18
  signal: controller.signal,
20
19
  headers
21
20
  });
22
- clearTimeout(timeoutId);
23
21
  if (response.status !== 200) {
24
22
  throw new Error(response.statusText);
25
23
  }
26
24
  return response.json();
27
25
  } catch (error) {
28
26
  if (error instanceof Error && error.name === "AbortError") {
29
- onError?.(new Error("Request timed out"));
30
- } else {
31
- onError?.(error);
27
+ throw new Error("Request timed out");
32
28
  }
33
- return null;
29
+ throw error;
30
+ } finally {
31
+ clearTimeout(timeoutId);
34
32
  }
35
33
  };
36
34
  //# sourceMappingURL=fetchUpdateInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["fetchUpdateInfo","url","requestHeaders","onError","requestTimeout","controller","AbortController","timeoutId","setTimeout","abort","headers","response","fetch","signal","clearTimeout","status","Error","statusText","json","error","name"],"sourceRoot":"../../src","sources":["fetchUpdateInfo.ts"],"mappings":";;AAEA,OAAO,MAAMA,eAAe,GAAG,MAAAA,CAAO;EACpCC,GAAG;EACHC,cAAc;EACdC,OAAO;EACPC,cAAc,GAAG;AAMnB,CAAC,KAAoC;EACnC,IAAI;IACF,MAAMC,UAAU,GAAG,IAAIC,eAAe,CAAC,CAAC;IACxC,MAAMC,SAAS,GAAGC,UAAU,CAAC,MAAM;MACjCH,UAAU,CAACI,KAAK,CAAC,CAAC;IACpB,CAAC,EAAEL,cAAc,CAAC;IAElB,MAAMM,OAAO,GAAG;MACd,cAAc,EAAE,kBAAkB;MAClC,GAAGR;IACL,CAAC;IAED,MAAMS,QAAQ,GAAG,MAAMC,KAAK,CAACX,GAAG,EAAE;MAChCY,MAAM,EAAER,UAAU,CAACQ,MAAM;MACzBH;IACF,CAAC,CAAC;IACFI,YAAY,CAACP,SAAS,CAAC;IAEvB,IAAII,QAAQ,CAACI,MAAM,KAAK,GAAG,EAAE;MAC3B,MAAM,IAAIC,KAAK,CAACL,QAAQ,CAACM,UAAU,CAAC;IACtC;IACA,OAAON,QAAQ,CAACO,IAAI,CAAC,CAAC;EACxB,CAAC,CAAC,OAAOC,KAAc,EAAE;IACvB,IAAIA,KAAK,YAAYH,KAAK,IAAIG,KAAK,CAACC,IAAI,KAAK,YAAY,EAAE;MACzDjB,OAAO,GAAG,IAAIa,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC3C,CAAC,MAAM;MACLb,OAAO,GAAGgB,KAAc,CAAC;IAC3B;IACA,OAAO,IAAI;EACb;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["fetchUpdateInfo","url","requestHeaders","requestTimeout","controller","AbortController","timeoutId","setTimeout","abort","headers","response","fetch","signal","status","Error","statusText","json","error","name","clearTimeout"],"sourceRoot":"../../src","sources":["fetchUpdateInfo.ts"],"mappings":";;AAEA,OAAO,MAAMA,eAAe,GAAG,MAAAA,CAAO;EACpCC,GAAG;EACHC,cAAc;EACdC,cAAc,GAAG;AAKnB,CAAC,KAAoC;EACnC,MAAMC,UAAU,GAAG,IAAIC,eAAe,CAAC,CAAC;EACxC,MAAMC,SAAS,GAAGC,UAAU,CAAC,MAAM;IACjCH,UAAU,CAACI,KAAK,CAAC,CAAC;EACpB,CAAC,EAAEL,cAAc,CAAC;EAElB,IAAI;IACF,MAAMM,OAAO,GAAG;MACd,cAAc,EAAE,kBAAkB;MAClC,GAAGP;IACL,CAAC;IAED,MAAMQ,QAAQ,GAAG,MAAMC,KAAK,CAACV,GAAG,EAAE;MAChCW,MAAM,EAAER,UAAU,CAACQ,MAAM;MACzBH;IACF,CAAC,CAAC;IAEF,IAAIC,QAAQ,CAACG,MAAM,KAAK,GAAG,EAAE;MAC3B,MAAM,IAAIC,KAAK,CAACJ,QAAQ,CAACK,UAAU,CAAC;IACtC;IACA,OAAOL,QAAQ,CAACM,IAAI,CAAC,CAAC;EACxB,CAAC,CAAC,OAAOC,KAAc,EAAE;IACvB,IAAIA,KAAK,YAAYH,KAAK,IAAIG,KAAK,CAACC,IAAI,KAAK,YAAY,EAAE;MACzD,MAAM,IAAIJ,KAAK,CAAC,mBAAmB,CAAC;IACtC;IACA,MAAMG,KAAK;EACb,CAAC,SAAS;IACRE,YAAY,CAACb,SAAS,CAAC;EACzB;AACF,CAAC","ignoreList":[]}
@@ -1,8 +1,7 @@
1
1
  import type { AppUpdateInfo } from "@hot-updater/core";
2
- export declare const fetchUpdateInfo: ({ url, requestHeaders, onError, requestTimeout, }: {
2
+ export declare const fetchUpdateInfo: ({ url, requestHeaders, requestTimeout, }: {
3
3
  url: string;
4
4
  requestHeaders?: Record<string, string>;
5
- onError?: (error: Error) => void;
6
5
  requestTimeout?: number;
7
6
  }) => Promise<AppUpdateInfo | null>;
8
7
  //# sourceMappingURL=fetchUpdateInfo.d.ts.map
@@ -1 +1 @@
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
+ {"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,0CAInC;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,KAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CA6B/B,CAAC"}
@@ -1,8 +1,7 @@
1
1
  import type { AppUpdateInfo } from "@hot-updater/core";
2
- export declare const fetchUpdateInfo: ({ url, requestHeaders, onError, requestTimeout, }: {
2
+ export declare const fetchUpdateInfo: ({ url, requestHeaders, requestTimeout, }: {
3
3
  url: string;
4
4
  requestHeaders?: Record<string, string>;
5
- onError?: (error: Error) => void;
6
5
  requestTimeout?: number;
7
6
  }) => Promise<AppUpdateInfo | null>;
8
7
  //# sourceMappingURL=fetchUpdateInfo.d.ts.map
@@ -1 +1 @@
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
+ {"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,0CAInC;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,KAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CA6B/B,CAAC"}
package/package.json CHANGED
@@ -1,21 +1,14 @@
1
1
  {
2
2
  "name": "@hot-updater/react-native",
3
- "version": "0.30.9",
3
+ "version": "0.30.11",
4
4
  "description": "React Native OTA solution for self-hosted",
5
- "main": "lib/commonjs/index",
6
- "module": "lib/module/index",
5
+ "main": "./lib/module/index.js",
7
6
  "types": "./lib/typescript/commonjs/index.d.ts",
8
- "react-native": "src/index",
9
7
  "exports": {
10
8
  ".": {
11
- "import": {
12
- "types": "./lib/typescript/module/index.d.ts",
13
- "default": "./lib/module/index.js"
14
- },
15
- "require": {
16
- "types": "./lib/typescript/commonjs/index.d.ts",
17
- "default": "./lib/commonjs/index.js"
18
- }
9
+ "source": "./src/index.ts",
10
+ "types": "./lib/typescript/commonjs/index.d.ts",
11
+ "default": "./lib/module/index.js"
19
12
  },
20
13
  "./package.json": "./package.json",
21
14
  "./app.plugin.js": "./app.plugin.js"
@@ -118,16 +111,16 @@
118
111
  "expo": "^50.0.0",
119
112
  "react": "19.1.3",
120
113
  "react-native": "0.79.1",
121
- "react-native-builder-bob": "^0.40.10",
114
+ "react-native-builder-bob": "0.41.0",
122
115
  "typescript": "^6.0.2",
123
- "hot-updater": "0.30.9"
116
+ "hot-updater": "0.30.11"
124
117
  },
125
118
  "dependencies": {
126
119
  "use-sync-external-store": "1.5.0",
127
- "@hot-updater/cli-tools": "0.30.9",
128
- "@hot-updater/core": "0.30.9",
129
- "@hot-updater/js": "0.30.9",
130
- "@hot-updater/plugin-core": "0.30.9"
120
+ "@hot-updater/cli-tools": "0.30.11",
121
+ "@hot-updater/js": "0.30.11",
122
+ "@hot-updater/core": "0.30.11",
123
+ "@hot-updater/plugin-core": "0.30.11"
131
124
  },
132
125
  "scripts": {
133
126
  "build": "bob build && tsc -p plugin/tsconfig.build.json",
@@ -3,20 +3,18 @@ import type { AppUpdateInfo } from "@hot-updater/core";
3
3
  export const fetchUpdateInfo = async ({
4
4
  url,
5
5
  requestHeaders,
6
- onError,
7
6
  requestTimeout = 5000,
8
7
  }: {
9
8
  url: string;
10
9
  requestHeaders?: Record<string, string>;
11
- onError?: (error: Error) => void;
12
10
  requestTimeout?: number;
13
11
  }): Promise<AppUpdateInfo | null> => {
14
- try {
15
- const controller = new AbortController();
16
- const timeoutId = setTimeout(() => {
17
- controller.abort();
18
- }, requestTimeout);
12
+ const controller = new AbortController();
13
+ const timeoutId = setTimeout(() => {
14
+ controller.abort();
15
+ }, requestTimeout);
19
16
 
17
+ try {
20
18
  const headers = {
21
19
  "Content-Type": "application/json",
22
20
  ...requestHeaders,
@@ -26,7 +24,6 @@ export const fetchUpdateInfo = async ({
26
24
  signal: controller.signal,
27
25
  headers,
28
26
  });
29
- clearTimeout(timeoutId);
30
27
 
31
28
  if (response.status !== 200) {
32
29
  throw new Error(response.statusText);
@@ -34,10 +31,10 @@ export const fetchUpdateInfo = async ({
34
31
  return response.json();
35
32
  } catch (error: unknown) {
36
33
  if (error instanceof Error && error.name === "AbortError") {
37
- onError?.(new Error("Request timed out"));
38
- } else {
39
- onError?.(error as Error);
34
+ throw new Error("Request timed out");
40
35
  }
41
- return null;
36
+ throw error;
37
+ } finally {
38
+ clearTimeout(timeoutId);
42
39
  }
43
40
  };