@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,64 +0,0 @@
1
- "use strict";
2
-
3
- import { checkForUpdate } from "./checkForUpdate.js";
4
- import { getBundleId, reload } from "./native.js";
5
- /**
6
- * Manually checks and applies updates for the application.
7
- *
8
- * @param {RunUpdateProcessConfig} config - Update process configuration
9
- * @param {string} config.source - Update server URL
10
- * @param {Record<string, string>} [config.requestHeaders] - Request headers
11
- * @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
12
- *
13
- * @example
14
- * ```ts
15
- * // Auto reload on force update
16
- * const result = await HotUpdater.runUpdateProcess({
17
- * source: "<your-update-server-url>",
18
- * requestHeaders: {
19
- * // Add necessary headers
20
- * },
21
- * reloadOnForceUpdate: true
22
- * });
23
- *
24
- * // Manually handle reload on force update
25
- * const result = await HotUpdater.runUpdateProcess({
26
- * source: "<your-update-server-url>",
27
- * reloadOnForceUpdate: false
28
- * });
29
- *
30
- * if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
31
- * await HotUpdater.reload();
32
- * }
33
- * ```
34
- *
35
- * @returns {Promise<RunUpdateProcessResponse>} The result of the update process
36
- */
37
- export const runUpdateProcess = async ({
38
- reloadOnForceUpdate = true,
39
- ...checkForUpdateOptions
40
- }) => {
41
- const updateInfo = await checkForUpdate(checkForUpdateOptions);
42
- if (!updateInfo) {
43
- return {
44
- status: "UP_TO_DATE",
45
- shouldForceUpdate: false,
46
- message: null,
47
- id: getBundleId()
48
- };
49
- }
50
- const isUpdated = await updateInfo.updateBundle();
51
- if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) {
52
- await reload();
53
- }
54
- if (!isUpdated) {
55
- throw new Error("New update was found but failed to download the bundle.");
56
- }
57
- return {
58
- status: updateInfo.status,
59
- shouldForceUpdate: updateInfo.shouldForceUpdate,
60
- id: updateInfo.id,
61
- message: updateInfo.message
62
- };
63
- };
64
- //# sourceMappingURL=runUpdateProcess.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["checkForUpdate","getBundleId","reload","runUpdateProcess","reloadOnForceUpdate","checkForUpdateOptions","updateInfo","status","shouldForceUpdate","message","id","isUpdated","updateBundle","Error"],"sourceRoot":"../../src","sources":["runUpdateProcess.ts"],"mappings":";;AAAA,SAAqCA,cAAc,QAAQ,qBAAkB;AAC7E,SAASC,WAAW,EAAEC,MAAM,QAAQ,aAAU;AAkB9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAAO;EACrCC,mBAAmB,GAAG,IAAI;EAC1B,GAAGC;AACoB,CAAC,KAAwC;EAChE,MAAMC,UAAU,GAAG,MAAMN,cAAc,CAACK,qBAAqB,CAAC;EAC9D,IAAI,CAACC,UAAU,EAAE;IACf,OAAO;MACLC,MAAM,EAAE,YAAY;MACpBC,iBAAiB,EAAE,KAAK;MACxBC,OAAO,EAAE,IAAI;MACbC,EAAE,EAAET,WAAW,CAAC;IAClB,CAAC;EACH;EAEA,MAAMU,SAAS,GAAG,MAAML,UAAU,CAACM,YAAY,CAAC,CAAC;EACjD,IAAID,SAAS,IAAIL,UAAU,CAACE,iBAAiB,IAAIJ,mBAAmB,EAAE;IACpE,MAAMF,MAAM,CAAC,CAAC;EAChB;EAEA,IAAI,CAACS,SAAS,EAAE;IACd,MAAM,IAAIE,KAAK,CAAC,yDAAyD,CAAC;EAC5E;EACA,OAAO;IACLN,MAAM,EAAED,UAAU,CAACC,MAAM;IACzBC,iBAAiB,EAAEF,UAAU,CAACE,iBAAiB;IAC/CE,EAAE,EAAEJ,UAAU,CAACI,EAAE;IACjBD,OAAO,EAAEH,UAAU,CAACG;EACtB,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1,49 +0,0 @@
1
- import { type CheckForUpdateOptions } from "./checkForUpdate";
2
- export interface RunUpdateProcessResponse {
3
- status: "ROLLBACK" | "UPDATE" | "UP_TO_DATE";
4
- shouldForceUpdate: boolean;
5
- message: string | null;
6
- id: string;
7
- }
8
- export interface RunUpdateProcessOptions extends CheckForUpdateOptions {
9
- /**
10
- * If `true`, the app will be reloaded when the downloaded bundle is a force update.
11
- * If `false`, shouldForceUpdate will be returned as true but the app won't reload.
12
- * @default true
13
- */
14
- reloadOnForceUpdate?: boolean;
15
- }
16
- /**
17
- * Manually checks and applies updates for the application.
18
- *
19
- * @param {RunUpdateProcessConfig} config - Update process configuration
20
- * @param {string} config.source - Update server URL
21
- * @param {Record<string, string>} [config.requestHeaders] - Request headers
22
- * @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
23
- *
24
- * @example
25
- * ```ts
26
- * // Auto reload on force update
27
- * const result = await HotUpdater.runUpdateProcess({
28
- * source: "<your-update-server-url>",
29
- * requestHeaders: {
30
- * // Add necessary headers
31
- * },
32
- * reloadOnForceUpdate: true
33
- * });
34
- *
35
- * // Manually handle reload on force update
36
- * const result = await HotUpdater.runUpdateProcess({
37
- * source: "<your-update-server-url>",
38
- * reloadOnForceUpdate: false
39
- * });
40
- *
41
- * if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
42
- * await HotUpdater.reload();
43
- * }
44
- * ```
45
- *
46
- * @returns {Promise<RunUpdateProcessResponse>} The result of the update process
47
- */
48
- export declare const runUpdateProcess: ({ reloadOnForceUpdate, ...checkForUpdateOptions }: RunUpdateProcessOptions) => Promise<RunUpdateProcessResponse>;
49
- //# sourceMappingURL=runUpdateProcess.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runUpdateProcess.d.ts","sourceRoot":"","sources":["../../../src/runUpdateProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAkB,MAAM,kBAAkB,CAAC;AAG9E,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,YAAY,CAAC;IAC7C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,gBAAgB,GAAU,mDAGpC,uBAAuB,KAAG,OAAO,CAAC,wBAAwB,CAyB5D,CAAC"}
@@ -1,49 +0,0 @@
1
- import { type CheckForUpdateOptions } from "./checkForUpdate";
2
- export interface RunUpdateProcessResponse {
3
- status: "ROLLBACK" | "UPDATE" | "UP_TO_DATE";
4
- shouldForceUpdate: boolean;
5
- message: string | null;
6
- id: string;
7
- }
8
- export interface RunUpdateProcessOptions extends CheckForUpdateOptions {
9
- /**
10
- * If `true`, the app will be reloaded when the downloaded bundle is a force update.
11
- * If `false`, shouldForceUpdate will be returned as true but the app won't reload.
12
- * @default true
13
- */
14
- reloadOnForceUpdate?: boolean;
15
- }
16
- /**
17
- * Manually checks and applies updates for the application.
18
- *
19
- * @param {RunUpdateProcessConfig} config - Update process configuration
20
- * @param {string} config.source - Update server URL
21
- * @param {Record<string, string>} [config.requestHeaders] - Request headers
22
- * @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
23
- *
24
- * @example
25
- * ```ts
26
- * // Auto reload on force update
27
- * const result = await HotUpdater.runUpdateProcess({
28
- * source: "<your-update-server-url>",
29
- * requestHeaders: {
30
- * // Add necessary headers
31
- * },
32
- * reloadOnForceUpdate: true
33
- * });
34
- *
35
- * // Manually handle reload on force update
36
- * const result = await HotUpdater.runUpdateProcess({
37
- * source: "<your-update-server-url>",
38
- * reloadOnForceUpdate: false
39
- * });
40
- *
41
- * if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
42
- * await HotUpdater.reload();
43
- * }
44
- * ```
45
- *
46
- * @returns {Promise<RunUpdateProcessResponse>} The result of the update process
47
- */
48
- export declare const runUpdateProcess: ({ reloadOnForceUpdate, ...checkForUpdateOptions }: RunUpdateProcessOptions) => Promise<RunUpdateProcessResponse>;
49
- //# sourceMappingURL=runUpdateProcess.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runUpdateProcess.d.ts","sourceRoot":"","sources":["../../../src/runUpdateProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAkB,MAAM,kBAAkB,CAAC;AAG9E,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,YAAY,CAAC;IAC7C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,gBAAgB,GAAU,mDAGpC,uBAAuB,KAAG,OAAO,CAAC,wBAAwB,CAyB5D,CAAC"}
@@ -1,80 +0,0 @@
1
- import { type CheckForUpdateOptions, checkForUpdate } from "./checkForUpdate";
2
- import { getBundleId, reload } from "./native";
3
-
4
- export interface RunUpdateProcessResponse {
5
- status: "ROLLBACK" | "UPDATE" | "UP_TO_DATE";
6
- shouldForceUpdate: boolean;
7
- message: string | null;
8
- id: string;
9
- }
10
-
11
- export interface RunUpdateProcessOptions extends CheckForUpdateOptions {
12
- /**
13
- * If `true`, the app will be reloaded when the downloaded bundle is a force update.
14
- * If `false`, shouldForceUpdate will be returned as true but the app won't reload.
15
- * @default true
16
- */
17
- reloadOnForceUpdate?: boolean;
18
- }
19
-
20
- /**
21
- * Manually checks and applies updates for the application.
22
- *
23
- * @param {RunUpdateProcessConfig} config - Update process configuration
24
- * @param {string} config.source - Update server URL
25
- * @param {Record<string, string>} [config.requestHeaders] - Request headers
26
- * @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
27
- *
28
- * @example
29
- * ```ts
30
- * // Auto reload on force update
31
- * const result = await HotUpdater.runUpdateProcess({
32
- * source: "<your-update-server-url>",
33
- * requestHeaders: {
34
- * // Add necessary headers
35
- * },
36
- * reloadOnForceUpdate: true
37
- * });
38
- *
39
- * // Manually handle reload on force update
40
- * const result = await HotUpdater.runUpdateProcess({
41
- * source: "<your-update-server-url>",
42
- * reloadOnForceUpdate: false
43
- * });
44
- *
45
- * if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
46
- * await HotUpdater.reload();
47
- * }
48
- * ```
49
- *
50
- * @returns {Promise<RunUpdateProcessResponse>} The result of the update process
51
- */
52
- export const runUpdateProcess = async ({
53
- reloadOnForceUpdate = true,
54
- ...checkForUpdateOptions
55
- }: RunUpdateProcessOptions): Promise<RunUpdateProcessResponse> => {
56
- const updateInfo = await checkForUpdate(checkForUpdateOptions);
57
- if (!updateInfo) {
58
- return {
59
- status: "UP_TO_DATE",
60
- shouldForceUpdate: false,
61
- message: null,
62
- id: getBundleId(),
63
- };
64
- }
65
-
66
- const isUpdated = await updateInfo.updateBundle();
67
- if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) {
68
- await reload();
69
- }
70
-
71
- if (!isUpdated) {
72
- throw new Error("New update was found but failed to download the bundle.");
73
- }
74
- return {
75
- status: updateInfo.status,
76
- shouldForceUpdate: updateInfo.shouldForceUpdate,
77
- id: updateInfo.id,
78
- message: updateInfo.message,
79
- };
80
- };