react-native-ota-hot-update 2.3.6 → 2.4.0-rc.2

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 (36) hide show
  1. package/android/generated/java/com/otahotupdate/NativeOtaHotUpdateSpec.java +14 -1
  2. package/android/generated/jni/RNOtaHotUpdateSpec-generated.cpp +20 -2
  3. package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI-generated.cpp +26 -2
  4. package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI.h +32 -5
  5. package/android/src/main/java/com/otahotupdate/OtaHotUpdateModule.kt +365 -36
  6. package/android/src/main/java/com/otahotupdate/SharedPrefs.kt +12 -0
  7. package/android/src/main/java/com/otahotupdate/Utils.kt +9 -3
  8. package/android/src/oldarch/OtaHotUpdateSpec.kt +4 -1
  9. package/ios/OtaHotUpdate.mm +383 -42
  10. package/ios/generated/RNOtaHotUpdateSpec/RNOtaHotUpdateSpec-generated.mm +23 -2
  11. package/ios/generated/RNOtaHotUpdateSpec/RNOtaHotUpdateSpec.h +12 -0
  12. package/ios/generated/RNOtaHotUpdateSpecJSI-generated.cpp +26 -2
  13. package/ios/generated/RNOtaHotUpdateSpecJSI.h +32 -5
  14. package/lib/commonjs/NativeOtaHotUpdate.js.map +1 -1
  15. package/lib/commonjs/index.js +26 -3
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/module/NativeOtaHotUpdate.js.map +1 -1
  18. package/lib/module/index.js +26 -3
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/typescript/commonjs/src/NativeOtaHotUpdate.d.ts +4 -1
  21. package/lib/typescript/commonjs/src/NativeOtaHotUpdate.d.ts.map +1 -1
  22. package/lib/typescript/commonjs/src/index.d.ts +8 -2
  23. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/src/type.d.ts +36 -0
  25. package/lib/typescript/commonjs/src/type.d.ts.map +1 -1
  26. package/lib/typescript/module/src/NativeOtaHotUpdate.d.ts +4 -1
  27. package/lib/typescript/module/src/NativeOtaHotUpdate.d.ts.map +1 -1
  28. package/lib/typescript/module/src/index.d.ts +8 -2
  29. package/lib/typescript/module/src/index.d.ts.map +1 -1
  30. package/lib/typescript/module/src/type.d.ts +36 -0
  31. package/lib/typescript/module/src/type.d.ts.map +1 -1
  32. package/package.json +1 -1
  33. package/src/NativeOtaHotUpdate.ts +4 -1
  34. package/src/index.d.ts +25 -2
  35. package/src/index.tsx +36 -5
  36. package/src/type.ts +44 -1
package/src/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import type { DownloadManager } from './download';
2
- import type { UpdateGitOption, UpdateOption } from './type';
2
+ import type { UpdateGitOption, UpdateOption, BundleInfo } from './type';
3
+
4
+ // Re-export types for external use
5
+ export type { BundleInfo, UpdateOption, UpdateGitOption } from './type';
3
6
 
4
7
  export interface GitModule {
5
8
  checkForGitUpdate(options: UpdateGitOption): Promise<void>;
@@ -24,8 +27,9 @@ export interface OtaHotUpdate {
24
27
  * Set up the path to the downloaded bundle file.
25
28
  * @param path - The path to the bundle file.
26
29
  * @param extension - Optional extension for the bundle file.
30
+ * @param version - Optional version number to include in folder name.
27
31
  */
28
- setupBundlePath(path: string, extension?: string): Promise<boolean>;
32
+ setupBundlePath(path: string, extension?: string, version?: number): Promise<boolean>;
29
33
 
30
34
  /**
31
35
  * Set up an exact path to the bundle file for the update.
@@ -69,6 +73,25 @@ export interface OtaHotUpdate {
69
73
  */
70
74
  setCurrentVersion(version: number): Promise<boolean>;
71
75
 
76
+ /**
77
+ * Get the list of all bundle versions.
78
+ * @returns Array of bundle information including id, version, date, path, isActive, and metadata.
79
+ */
80
+ getBundleList(): Promise<BundleInfo[]>;
81
+
82
+ /**
83
+ * Delete a bundle by its identifier (folder name).
84
+ * @param id - The bundle identifier (folder name).
85
+ * @returns True if the bundle was successfully deleted, false otherwise.
86
+ */
87
+ deleteBundleById(id: string): Promise<boolean>;
88
+
89
+ /**
90
+ * Clear all bundles from history.
91
+ * @returns True if all bundles were successfully cleared, false otherwise.
92
+ */
93
+ clearAllBundles(): Promise<boolean>;
94
+
72
95
  /**
73
96
  * Git-related operations.
74
97
  */
package/src/index.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { NativeModules, Platform } from 'react-native';
2
2
  import type { DownloadManager } from './download';
3
- import type { UpdateGitOption, UpdateOption } from './type';
3
+ import type { UpdateGitOption, UpdateOption, BundleInfo } from './type';
4
4
  import git from './gits';
5
5
 
6
6
  const LINKING_ERROR =
@@ -48,8 +48,15 @@ const downloadBundleFile = async (
48
48
  });
49
49
  return res.path();
50
50
  };
51
- function setupBundlePath(path: string, extension?: string): Promise<boolean> {
52
- return RNhotupdate.setupBundlePath(path, extension);
51
+ function setupBundlePath(
52
+ path: string,
53
+ extension?: string,
54
+ version?: number,
55
+ maxVersions?: number,
56
+ metadata?: any
57
+ ): Promise<boolean> {
58
+ const metadataString = metadata ? JSON.stringify(metadata) : undefined;
59
+ return RNhotupdate.setupBundlePath(path, extension, version, maxVersions || 2, metadataString);
53
60
  }
54
61
  function setupExactBundlePath(path: string): Promise<boolean> {
55
62
  return RNhotupdate.setExactBundlePath(path);
@@ -140,8 +147,7 @@ async function downloadBundleUri(
140
147
  if (!path) {
141
148
  return installFail(option, `Cannot download bundle file: ${path}`);
142
149
  }
143
-
144
- const success = await setupBundlePath(path, option?.extensionBundle);
150
+ const success = await setupBundlePath(path, option?.extensionBundle, version, option?.maxBundleVersions, option?.metadata);
145
151
  if (!success) {
146
152
  return installFail(option);
147
153
  }
@@ -213,6 +219,28 @@ const checkForGitUpdate = async (options: UpdateGitOption) => {
213
219
  options?.onFinishProgress?.();
214
220
  }
215
221
  };
222
+ function getBundleList(): Promise<BundleInfo[]> {
223
+ return RNhotupdate.getBundleList(0).then((jsonString: string) => {
224
+ try {
225
+ const data = JSON.parse(jsonString);
226
+ return data.map((item: any) => ({
227
+ ...item,
228
+ date: new Date(item.date),
229
+ }));
230
+ } catch (error) {
231
+ return Promise.reject(new Error('Error parsing bundle list'));
232
+ }
233
+ });
234
+ }
235
+
236
+ function deleteBundleById(id: string): Promise<boolean> {
237
+ return RNhotupdate.deleteBundleById(id);
238
+ }
239
+
240
+ function clearAllBundles(): Promise<boolean> {
241
+ return RNhotupdate.clearAllBundles(0);
242
+ }
243
+
216
244
  export default {
217
245
  setupBundlePath,
218
246
  setupExactBundlePath,
@@ -224,6 +252,9 @@ export default {
224
252
  getUpdateMetadata,
225
253
  setUpdateMetadata,
226
254
  rollbackToPreviousBundle,
255
+ getBundleList,
256
+ deleteBundleById,
257
+ clearAllBundles,
227
258
  git: {
228
259
  checkForGitUpdate,
229
260
  ...git,
package/src/type.ts CHANGED
@@ -45,7 +45,50 @@ export interface UpdateOption {
45
45
  * Metadata for the update.
46
46
  * Can contain information such as version details, description, etc.
47
47
  */
48
- metadata?: any
48
+ metadata?: any;
49
+
50
+ /**
51
+ * Maximum number of bundle versions to keep in history.
52
+ * Default: 2 (backward compatible).
53
+ * If the number of bundles exceeds this value, older bundles will be automatically deleted.
54
+ */
55
+ maxBundleVersions?: number;
56
+ }
57
+
58
+ /**
59
+ * Information about a bundle version.
60
+ */
61
+ export interface BundleInfo {
62
+ /**
63
+ * Bundle identifier (folder name).
64
+ * Example: "output_v5_2025_01_25_14_30"
65
+ */
66
+ id: string;
67
+
68
+ /**
69
+ * Version number of the bundle.
70
+ */
71
+ version: number;
72
+
73
+ /**
74
+ * Date when the bundle was created.
75
+ */
76
+ date: Date;
77
+
78
+ /**
79
+ * Full path to the bundle file.
80
+ */
81
+ path: string;
82
+
83
+ /**
84
+ * Whether this bundle is currently active.
85
+ */
86
+ isActive: boolean;
87
+
88
+ /**
89
+ * Optional metadata associated with the bundle.
90
+ */
91
+ metadata?: any;
49
92
  }
50
93
 
51
94
  /**