react-native-update 10.34.8 → 10.34.9

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.
@@ -7,7 +7,7 @@ set(HDIFFPATCH_DIR ${ANDROID_JNI_DIR}/HDiffPatch)
7
7
  set(LZMA_DIR ${ANDROID_JNI_DIR}/lzma)
8
8
  set(HDP_SOURCES
9
9
  ${CMAKE_CURRENT_SOURCE_DIR}/pushy.c
10
- ${CMAKE_CURRENT_SOURCE_DIR}/hpatch.c
10
+ ${ANDROID_JNI_DIR}/hpatch.c
11
11
  ${HDIFFPATCH_DIR}/libHDiffPatch/HPatch/patch.c
12
12
  ${HDIFFPATCH_DIR}/file_for_patch.c
13
13
  ${LZMA_DIR}/C/LzmaDec.c
@@ -22,6 +22,7 @@ add_library(rnupdate SHARED
22
22
 
23
23
  target_include_directories(rnupdate PRIVATE
24
24
  ${CMAKE_CURRENT_SOURCE_DIR}
25
+ ${ANDROID_JNI_DIR}
25
26
  ${HDIFFPATCH_DIR}
26
27
  ${HDIFFPATCH_DIR}/libHDiffPatch/HPatch
27
28
  ${LZMA_DIR}/C
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.34.8",
3
+ "version": "10.34.9",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {
@@ -1,137 +0,0 @@
1
- // hpatch.c
2
- // Copyright 2021 housisong, All rights reserved
3
- #include "hpatch.h"
4
- #include "HDiffPatch/libHDiffPatch/HPatch/patch.h"
5
- #include "HDiffPatch/file_for_patch.h"
6
-
7
- //#define _CompressPlugin_zlib
8
- //#define _CompressPlugin_bz2
9
- #define _CompressPlugin_lzma
10
- #define _CompressPlugin_lzma2
11
- #define _IsNeedIncludeDefaultCompressHead 0
12
- #include "lzma/C/LzmaDec.h"
13
- #include "lzma/C/Lzma2Dec.h"
14
- #include "HDiffPatch/decompress_plugin_demo.h"
15
-
16
- #define kMaxLoadMemOldSize ((1<<20)*8)
17
-
18
- #define _check(v,errorType) do{ \
19
- if (!(v)){ if (result==kHPatch_ok) result=errorType; if (!_isInClear){ goto _clear; }; } }while(0)
20
-
21
- int hpatch_getInfo_by_mem(hpatch_singleCompressedDiffInfo* out_patinfo,
22
- const uint8_t* pat,size_t patsize){
23
- hpatch_TStreamInput patStream;
24
- mem_as_hStreamInput(&patStream,pat,pat+patsize);
25
- if (!getSingleCompressedDiffInfo(out_patinfo,&patStream,0))
26
- return kHPatch_error_info;//data error;
27
- return kHPatch_ok; //ok
28
- }
29
-
30
- static hpatch_TDecompress* getDecompressPlugin(const char* compressType){
31
- #ifdef _CompressPlugin_zlib
32
- if (zlibDecompressPlugin.is_can_open(compressType))
33
- return &zlibDecompressPlugin;
34
- #endif
35
- #ifdef _CompressPlugin_bz2
36
- if (bz2DecompressPlugin.is_can_open(compressType))
37
- return &bz2DecompressPlugin;
38
- #endif
39
- #ifdef _CompressPlugin_lzma
40
- if (lzmaDecompressPlugin.is_can_open(compressType))
41
- return &lzmaDecompressPlugin;
42
- #endif
43
- #ifdef _CompressPlugin_lzma2
44
- if (lzma2DecompressPlugin.is_can_open(compressType))
45
- return &lzma2DecompressPlugin;
46
- #endif
47
- return 0;
48
- }
49
- static int hpatch_by_stream(const hpatch_TStreamInput* old,hpatch_BOOL isLoadOldAllToMem,const hpatch_TStreamInput* pat,
50
- hpatch_TStreamOutput* out_new,const hpatch_singleCompressedDiffInfo* patInfo){
51
- int result=kHPatch_ok;
52
- int _isInClear=hpatch_FALSE;
53
- hpatch_TDecompress* decompressPlugin=0;
54
- uint8_t* temp_cache=0;
55
- size_t temp_cache_size;
56
- hpatch_singleCompressedDiffInfo _patinfo;
57
- hpatch_TStreamInput _old;
58
- {// info
59
- if (!patInfo){
60
- _check(getSingleCompressedDiffInfo(&_patinfo,pat,0),kHPatch_error_info);
61
- patInfo=&_patinfo;
62
- }
63
- _check(old->streamSize==patInfo->oldDataSize,kHPatch_error_old_size);
64
- _check(out_new->streamSize>=patInfo->newDataSize,kHPatch_error_new_size);
65
- out_new->streamSize=patInfo->newDataSize;
66
- if (strlen(patInfo->compressType)>0){
67
- decompressPlugin=getDecompressPlugin(patInfo->compressType);
68
- _check(decompressPlugin,kHPatch_error_compressType);
69
- }
70
- }
71
- {// mem
72
- size_t mem_size;
73
- size_t oldSize=(size_t)old->streamSize;
74
- isLoadOldAllToMem=isLoadOldAllToMem&&(old->streamSize<=kMaxLoadMemOldSize);
75
- temp_cache_size=patInfo->stepMemSize+hpatch_kFileIOBufBetterSize*3;
76
- mem_size=temp_cache_size+(isLoadOldAllToMem?oldSize:0);
77
- temp_cache=malloc(mem_size);
78
- _check(temp_cache,kHPatch_error_malloc);
79
- if (isLoadOldAllToMem){//load old to mem
80
- uint8_t* oldMem=temp_cache+temp_cache_size;
81
- _check(old->read(old,0,oldMem,oldMem+oldSize),kHPatch_error_old_fread);
82
- mem_as_hStreamInput(&_old,oldMem,oldMem+oldSize);
83
- old=&_old;
84
- }
85
- }
86
-
87
- _check(patch_single_compressed_diff(out_new,old,pat,patInfo->diffDataPos,
88
- patInfo->uncompressedSize,decompressPlugin,patInfo->coverCount,
89
- patInfo->stepMemSize,temp_cache,temp_cache+temp_cache_size),kHPatch_error_patch);
90
-
91
- _clear:
92
- _isInClear=hpatch_TRUE;
93
- if (temp_cache){ free(temp_cache); temp_cache=0; }
94
- return result;
95
- }
96
-
97
- int hpatch_by_mem(const uint8_t* old,size_t oldsize,uint8_t* newBuf,size_t newsize,
98
- const uint8_t* pat,size_t patsize,const hpatch_singleCompressedDiffInfo* patInfo){
99
- hpatch_TStreamInput oldStream;
100
- hpatch_TStreamInput patStream;
101
- hpatch_TStreamOutput newStream;
102
- mem_as_hStreamInput(&oldStream,old,old+oldsize);
103
- mem_as_hStreamInput(&patStream,pat,pat+patsize);
104
- mem_as_hStreamOutput(&newStream,newBuf,newBuf+newsize);
105
- return hpatch_by_stream(&oldStream,hpatch_FALSE,&patStream,&newStream,patInfo);
106
- }
107
-
108
- int hpatch_by_file(const char* oldfile, const char* newfile, const char* patchfile){
109
- int result=kHPatch_ok;
110
- int _isInClear=hpatch_FALSE;
111
- int patch_result;
112
- hpatch_TFileStreamInput oldStream;
113
- hpatch_TFileStreamInput patStream;
114
- hpatch_TFileStreamOutput newStream;
115
- hpatch_TFileStreamInput_init(&oldStream);
116
- hpatch_TFileStreamInput_init(&patStream);
117
- hpatch_TFileStreamOutput_init(&newStream);
118
-
119
- _check(hpatch_TFileStreamInput_open(&oldStream,oldfile),kHPatch_error_old_fopen);
120
- _check(hpatch_TFileStreamInput_open(&patStream,patchfile),kHPatch_error_pat_fopen);
121
- _check(hpatch_TFileStreamOutput_open(&newStream,newfile,~(hpatch_StreamPos_t)0),kHPatch_error_new_fopen);
122
-
123
- patch_result=hpatch_by_stream(&oldStream.base,hpatch_TRUE,&patStream.base,&newStream.base,0);
124
- if (patch_result!=kHPatch_ok){
125
- _check(!oldStream.fileError,kHPatch_error_old_fread);
126
- _check(!patStream.fileError,kHPatch_error_pat_fread);
127
- _check(!newStream.fileError,kHPatch_error_new_fwrite);
128
- _check(hpatch_FALSE,patch_result);
129
- }
130
-
131
- _clear:
132
- _isInClear=hpatch_TRUE;
133
- _check(hpatch_TFileStreamInput_close(&oldStream),kHPatch_error_old_fclose);
134
- _check(hpatch_TFileStreamInput_close(&patStream),kHPatch_error_pat_fclose);
135
- _check(hpatch_TFileStreamOutput_close(&newStream),kHPatch_error_new_fclose);
136
- return result;
137
- }
@@ -1,44 +0,0 @@
1
- // hpatch.h
2
- // import HDiffPatch, support patchData created by "hdiffz -SD -c-lzma2 oldfile newfile patchfile"
3
- // Copyright 2021 housisong, All rights reserved
4
-
5
- #ifndef HDIFFPATCH_PATCH_H
6
- #define HDIFFPATCH_PATCH_H
7
- # include <stdint.h> //for uint8_t
8
- #include "HDiffPatch/libHDiffPatch/HPatch/patch_types.h" //for hpatch_singleCompressedDiffInfo
9
- #ifdef __cplusplus
10
- extern "C" {
11
- #endif
12
-
13
- //result
14
- enum {
15
- kHPatch_ok = 0,
16
- kHPatch_error_malloc =-1,
17
- kHPatch_error_info =-2,
18
- kHPatch_error_compressType =-3,
19
- kHPatch_error_patch =-4,
20
- kHPatch_error_old_fopen =-5,
21
- kHPatch_error_old_fread =-6,
22
- kHPatch_error_old_fclose =-7,
23
- kHPatch_error_pat_fopen =-8,
24
- kHPatch_error_pat_fread =-9,
25
- kHPatch_error_pat_fclose =-10,
26
- kHPatch_error_new_fopen =-11,
27
- kHPatch_error_new_fwrite =-12,
28
- kHPatch_error_new_fclose =-13,
29
- kHPatch_error_old_size =-14,
30
- kHPatch_error_new_size =-15,
31
- };
32
-
33
- int hpatch_getInfo_by_mem(hpatch_singleCompressedDiffInfo* out_patinfo,
34
- const uint8_t* pat,size_t patsize);
35
-
36
- //patInfo can NULL
37
- int hpatch_by_mem(const uint8_t* old,size_t oldsize, uint8_t* newBuf,size_t newsize,
38
- const uint8_t* pat,size_t patsize,const hpatch_singleCompressedDiffInfo* patInfo);
39
- int hpatch_by_file(const char* oldfile, const char* newfile, const char* patchfile);
40
-
41
- #ifdef __cplusplus
42
- }
43
- #endif
44
- #endif //HDIFFPATCH_PATCH_H