react-native-update 10.43.3 → 10.44.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.
- package/android/src/main/java/cn/reactnative/modules/update/BundledResourceCopier.java +24 -12
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +23 -8
- package/android/src/main/java/cn/reactnative/modules/update/ReactReloadManager.java +9 -1
- package/android/src/main/java/cn/reactnative/modules/update/StateSerialRunner.java +64 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +2 -2
- package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +8 -8
- package/cpp/patch_core/archive_patch_core.cpp +16 -0
- package/cpp/patch_core/archive_patch_core.h +5 -0
- package/cpp/patch_core/jni_util.h +56 -0
- package/cpp/patch_core/patch_core_android.cpp +4 -37
- package/cpp/patch_core/state_ops.h +24 -0
- package/cpp/patch_core/tests/patch_core_test.cpp +32 -2
- package/cpp/patch_core/update_core_android.cpp +43 -69
- package/harmony/pushy/src/main/cpp/pushy.cpp +162 -35
- package/harmony/pushy/src/main/ets/DownloadTask.ts +59 -9
- package/harmony/pushy/src/main/ets/NativePatchCore.ts +2 -2
- package/harmony/pushy/src/main/ets/PushyTurboModule.ts +10 -10
- package/harmony/pushy/src/main/ets/UpdateContext.ts +26 -9
- package/harmony/pushy.har +0 -0
- package/ios/RCTPushy/RCTPushyDownloader.mm +41 -2
- package/package.json +2 -1
- package/src/client.ts +130 -75
- package/src/provider.tsx +40 -26
- package/src/utils.ts +2 -2
- package/harmony/pushy/src/main/cpp/pushy.c +0 -117
- package/harmony/pushy/src/main/cpp/pushy.h +0 -8
- package/src/__tests__/setup.ts +0 -44
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
#include "pushy.h"
|
|
2
|
-
#include "hpatch.h"
|
|
3
|
-
#include <napi/native_api.h>
|
|
4
|
-
#include <js_native_api.h>
|
|
5
|
-
#include <js_native_api_types.h>
|
|
6
|
-
|
|
7
|
-
#define _check(v,errInfo) do { \
|
|
8
|
-
if (!(v)) { \
|
|
9
|
-
_isError = hpatch_TRUE; \
|
|
10
|
-
_errInfo = errInfo; \
|
|
11
|
-
goto _clear; \
|
|
12
|
-
} \
|
|
13
|
-
} while(0)
|
|
14
|
-
|
|
15
|
-
napi_value HdiffPatch(napi_env env, napi_callback_info info) {
|
|
16
|
-
napi_status status;
|
|
17
|
-
size_t argc = 2;
|
|
18
|
-
napi_value args[2];
|
|
19
|
-
hpatch_BOOL _isError = hpatch_FALSE;
|
|
20
|
-
const char* _errInfo = "";
|
|
21
|
-
|
|
22
|
-
// 获取参数
|
|
23
|
-
status = napi_get_cb_info(env, info, &argc, args, NULL, NULL);
|
|
24
|
-
if (status != napi_ok || argc < 2) {
|
|
25
|
-
napi_throw_error(env, NULL, "Wrong number of arguments");
|
|
26
|
-
return NULL;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 获取origin buffer
|
|
30
|
-
bool isTypedArray;
|
|
31
|
-
status = napi_is_typedarray(env, args[0], &isTypedArray);
|
|
32
|
-
if (status != napi_ok || !isTypedArray) {
|
|
33
|
-
napi_throw_error(env, NULL, "First argument must be a TypedArray");
|
|
34
|
-
return NULL;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
uint8_t* originPtr;
|
|
38
|
-
size_t originLength;
|
|
39
|
-
status = napi_get_typedarray_info(env, args[0], NULL, &originLength,
|
|
40
|
-
(void**)&originPtr, NULL, NULL);
|
|
41
|
-
if (status != napi_ok) {
|
|
42
|
-
napi_throw_error(env, NULL, "Failed to get origin buffer");
|
|
43
|
-
return NULL;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 获取patch buffer
|
|
47
|
-
status = napi_is_typedarray(env, args[1], &isTypedArray);
|
|
48
|
-
if (status != napi_ok || !isTypedArray) {
|
|
49
|
-
napi_throw_error(env, NULL, "Second argument must be a TypedArray");
|
|
50
|
-
return NULL;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
uint8_t* patchPtr;
|
|
54
|
-
size_t patchLength;
|
|
55
|
-
status = napi_get_typedarray_info(env, args[1], NULL, &patchLength,
|
|
56
|
-
(void**)&patchPtr, NULL, NULL);
|
|
57
|
-
if (status != napi_ok) {
|
|
58
|
-
napi_throw_error(env, NULL, "Failed to get patch buffer");
|
|
59
|
-
return NULL;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// 执行patch操作
|
|
63
|
-
hpatch_singleCompressedDiffInfo patInfo;
|
|
64
|
-
|
|
65
|
-
_check(((originLength==0)||originPtr) && patchPtr && (patchLength>0), "Corrupt patch");
|
|
66
|
-
_check(kHPatch_ok==hpatch_getInfo_by_mem(&patInfo, patchPtr, patchLength), "Error info in hpatch");
|
|
67
|
-
_check(originLength==patInfo.oldDataSize, "Error oldDataSize in hpatch");
|
|
68
|
-
size_t newsize = (size_t)patInfo.newDataSize;
|
|
69
|
-
if (sizeof(size_t)!=sizeof(hpatch_StreamPos_t))
|
|
70
|
-
_check(newsize==patInfo.newDataSize, "Error newDataSize in hpatch");
|
|
71
|
-
|
|
72
|
-
// 创建结果buffer
|
|
73
|
-
napi_value resultBuffer;
|
|
74
|
-
uint8_t* outPtr;
|
|
75
|
-
void* data;
|
|
76
|
-
|
|
77
|
-
status = napi_create_arraybuffer(env, newsize, &data, &resultBuffer);
|
|
78
|
-
if (status != napi_ok) {
|
|
79
|
-
napi_throw_error(env, NULL, "Failed to create result buffer");
|
|
80
|
-
return NULL;
|
|
81
|
-
}
|
|
82
|
-
outPtr = (uint8_t*)data;
|
|
83
|
-
|
|
84
|
-
// 执行patch
|
|
85
|
-
_check(kHPatch_ok==hpatch_by_mem(originPtr, originLength, outPtr, newsize,
|
|
86
|
-
patchPtr, patchLength, &patInfo), "hpatch");
|
|
87
|
-
return resultBuffer;
|
|
88
|
-
|
|
89
|
-
_clear:
|
|
90
|
-
if (_isError) {
|
|
91
|
-
napi_throw_error(env, NULL, _errInfo);
|
|
92
|
-
return NULL;
|
|
93
|
-
}
|
|
94
|
-
return NULL;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// 模块初始化
|
|
98
|
-
napi_value Init(napi_env env, napi_value exports) {
|
|
99
|
-
napi_status status;
|
|
100
|
-
napi_value fn;
|
|
101
|
-
|
|
102
|
-
status = napi_create_function(env, NULL, 0, HdiffPatch, NULL, &fn);
|
|
103
|
-
if (status != napi_ok) {
|
|
104
|
-
napi_throw_error(env, NULL, "Unable to wrap native function");
|
|
105
|
-
return NULL;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
status = napi_set_named_property(env, exports, "hdiffPatch", fn);
|
|
109
|
-
if (status != napi_ok) {
|
|
110
|
-
napi_throw_error(env, NULL, "Unable to populate exports");
|
|
111
|
-
return NULL;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return exports;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
|
package/src/__tests__/setup.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { mock } from 'bun:test';
|
|
2
|
-
|
|
3
|
-
mock.module('react-native', () => {
|
|
4
|
-
return {
|
|
5
|
-
Platform: {
|
|
6
|
-
OS: 'ios',
|
|
7
|
-
Version: 13,
|
|
8
|
-
},
|
|
9
|
-
DeviceEventEmitter: {
|
|
10
|
-
addListener: () => ({ remove: () => {} }),
|
|
11
|
-
},
|
|
12
|
-
NativeModules: {
|
|
13
|
-
Pushy: {
|
|
14
|
-
currentVersionInfo: '{}',
|
|
15
|
-
downloadRootDir: '/tmp',
|
|
16
|
-
packageVersion: '1.0.0',
|
|
17
|
-
currentVersion: 'hash',
|
|
18
|
-
isFirstTime: false,
|
|
19
|
-
rolledBackVersion: '',
|
|
20
|
-
buildTime: '2023-01-01',
|
|
21
|
-
uuid: 'uuid',
|
|
22
|
-
setLocalHashInfo: () => {},
|
|
23
|
-
getLocalHashInfo: () => Promise.resolve('{}'),
|
|
24
|
-
setUuid: () => {},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
NativeEventEmitter: class {
|
|
28
|
-
addListener = () => ({ remove: () => {} });
|
|
29
|
-
removeAllListeners = () => {};
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
mock.module('../i18n', () => {
|
|
35
|
-
return {
|
|
36
|
-
default: {
|
|
37
|
-
t: (key: string, params?: any) => `${key}${params ? JSON.stringify(params) : ''}`,
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
mock.module('react-native/Libraries/Core/ReactNativeVersion', () => ({
|
|
43
|
-
version: { major: 0, minor: 73, patch: 0 },
|
|
44
|
-
}));
|