react-native-ota-hot-update 2.3.5 → 2.4.0-rc.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.
- package/android/generated/java/com/otahotupdate/NativeOtaHotUpdateSpec.java +14 -1
- package/android/generated/jni/RNOtaHotUpdateSpec-generated.cpp +20 -2
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI-generated.cpp +26 -2
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI.h +32 -5
- package/android/gradle.properties +4 -0
- package/android/src/main/java/com/otahotupdate/OtaHotUpdate.kt +6 -1
- package/android/src/main/java/com/otahotupdate/OtaHotUpdateModule.kt +365 -36
- package/android/src/main/java/com/otahotupdate/SharedPrefs.kt +12 -0
- package/android/src/main/java/com/otahotupdate/Utils.kt +9 -3
- package/android/src/oldarch/OtaHotUpdateSpec.kt +4 -1
- package/ios/OtaHotUpdate.mm +383 -42
- package/ios/generated/RNOtaHotUpdateSpec/RNOtaHotUpdateSpec-generated.mm +23 -2
- package/ios/generated/RNOtaHotUpdateSpec/RNOtaHotUpdateSpec.h +12 -0
- package/ios/generated/RNOtaHotUpdateSpecJSI-generated.cpp +26 -2
- package/ios/generated/RNOtaHotUpdateSpecJSI.h +32 -5
- package/lib/commonjs/NativeOtaHotUpdate.js.map +1 -1
- package/lib/commonjs/index.js +26 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeOtaHotUpdate.js.map +1 -1
- package/lib/module/index.js +26 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeOtaHotUpdate.d.ts +4 -1
- package/lib/typescript/commonjs/src/NativeOtaHotUpdate.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +8 -2
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/type.d.ts +36 -0
- package/lib/typescript/commonjs/src/type.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeOtaHotUpdate.d.ts +4 -1
- package/lib/typescript/module/src/NativeOtaHotUpdate.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +8 -2
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/type.d.ts +36 -0
- package/lib/typescript/module/src/type.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeOtaHotUpdate.ts +4 -1
- package/src/index.d.ts +25 -2
- package/src/index.tsx +36 -5
- package/src/type.ts +44 -1
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(
|
|
52
|
-
|
|
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, 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
|
/**
|