react-native-update 10.15.4 → 10.17.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/.project +28 -0
- package/android/bin/.project +34 -0
- package/android/bin/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/bin/jni/HDiffPatch/builds/android_ndk_jni_mk/java/com/github/sisong/HPatch.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/CRC.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZ/BinTree.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZ/InWindow.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZ/OutWindow.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Base.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Decoder$LenDecoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Decoder$LiteralDecoder$Decoder2.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Decoder$LiteralDecoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Decoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Encoder$LenEncoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Encoder$LenPriceTableEncoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Encoder$LiteralEncoder$Encoder2.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Encoder$LiteralEncoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Encoder$Optimal.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Encoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/RangeCoder/BitTreeDecoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/RangeCoder/BitTreeEncoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/RangeCoder/Decoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/Compression/RangeCoder/Encoder.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/ICodeProgress.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/LzmaAlone$CommandLine.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/LzmaAlone.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/LzmaBench$CBenchRandomGenerator.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/LzmaBench$CBitRandomGenerator.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/LzmaBench$CProgressInfo.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/LzmaBench$CRandomGenerator.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/LzmaBench$CrcOutStream.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/LzmaBench$MyInputStream.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/LzmaBench$MyOutputStream.class +0 -0
- package/android/bin/jni/lzma/Java/SevenZip/LzmaBench.class +0 -0
- package/android/bin/src/main/java/cn/reactnative/modules/update/DownloadTask.class +0 -0
- package/android/bin/src/main/java/cn/reactnative/modules/update/DownloadTaskParams.class +0 -0
- package/android/bin/src/main/java/cn/reactnative/modules/update/PushyFileProvider.class +0 -0
- package/android/bin/src/main/java/cn/reactnative/modules/update/SafeZipFile$SafeZipEntryIterator.class +0 -0
- package/android/bin/src/main/java/cn/reactnative/modules/update/SafeZipFile.class +0 -0
- package/android/bin/src/main/java/cn/reactnative/modules/update/UpdateContext$DownloadFileListener.class +0 -0
- package/android/bin/src/main/java/cn/reactnative/modules/update/UpdateContext.class +0 -0
- package/android/bin/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.class +0 -0
- package/android/bin/src/main/java/cn/reactnative/modules/update/UpdatePackage.class +0 -0
- package/android/bin/src/newarch/cn/reactnative/modules/update/UpdateModule.class +0 -0
- package/android/bin/src/oldarch/cn/reactnative/modules/update/UpdateModule.class +0 -0
- package/package.json +3 -2
- package/src/client.ts +42 -29
- package/src/context.ts +1 -1
- package/src/provider.tsx +10 -5
- package/src/type.ts +2 -1
- package/.yarnrc.yml +0 -1
package/android/.project
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<projectDescription>
|
|
3
|
+
<name>react-native-update</name>
|
|
4
|
+
<comment>Project react-native-update created by Buildship.</comment>
|
|
5
|
+
<projects>
|
|
6
|
+
</projects>
|
|
7
|
+
<buildSpec>
|
|
8
|
+
<buildCommand>
|
|
9
|
+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
10
|
+
<arguments>
|
|
11
|
+
</arguments>
|
|
12
|
+
</buildCommand>
|
|
13
|
+
</buildSpec>
|
|
14
|
+
<natures>
|
|
15
|
+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
16
|
+
</natures>
|
|
17
|
+
<filteredResources>
|
|
18
|
+
<filter>
|
|
19
|
+
<id>1727963310481</id>
|
|
20
|
+
<name></name>
|
|
21
|
+
<type>30</type>
|
|
22
|
+
<matcher>
|
|
23
|
+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
|
24
|
+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
|
25
|
+
</matcher>
|
|
26
|
+
</filter>
|
|
27
|
+
</filteredResources>
|
|
28
|
+
</projectDescription>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<projectDescription>
|
|
3
|
+
<name>react-native-update</name>
|
|
4
|
+
<comment>Project react-native-update created by Buildship.</comment>
|
|
5
|
+
<projects>
|
|
6
|
+
</projects>
|
|
7
|
+
<buildSpec>
|
|
8
|
+
<buildCommand>
|
|
9
|
+
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
10
|
+
<arguments>
|
|
11
|
+
</arguments>
|
|
12
|
+
</buildCommand>
|
|
13
|
+
<buildCommand>
|
|
14
|
+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
15
|
+
<arguments>
|
|
16
|
+
</arguments>
|
|
17
|
+
</buildCommand>
|
|
18
|
+
</buildSpec>
|
|
19
|
+
<natures>
|
|
20
|
+
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
21
|
+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
22
|
+
</natures>
|
|
23
|
+
<filteredResources>
|
|
24
|
+
<filter>
|
|
25
|
+
<id>1727963310481</id>
|
|
26
|
+
<name></name>
|
|
27
|
+
<type>30</type>
|
|
28
|
+
<matcher>
|
|
29
|
+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
|
30
|
+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
|
31
|
+
</matcher>
|
|
32
|
+
</filter>
|
|
33
|
+
</filteredResources>
|
|
34
|
+
</projectDescription>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
arguments=--init-script /var/folders/l6/0fn3x28s5s585ld3p04gsy1h0000gn/T/db3b08fc4a9ef609cb16b96b200fa13e563f396e9bb1ed0905fdab7bc3bc513b.gradle --init-script /var/folders/l6/0fn3x28s5s585ld3p04gsy1h0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
|
|
2
|
+
auto.sync=false
|
|
3
|
+
build.scans.enabled=false
|
|
4
|
+
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(8.9))
|
|
5
|
+
connection.project.dir=
|
|
6
|
+
eclipse.preferences.version=1
|
|
7
|
+
gradle.user.home=
|
|
8
|
+
java.home=/Users/sunny/.sdkman/candidates/java/17.0.9-zulu/zulu-17.jdk/Contents/Home
|
|
9
|
+
jvm.arguments=
|
|
10
|
+
offline.mode=false
|
|
11
|
+
override.workspace.settings=true
|
|
12
|
+
show.console.view=true
|
|
13
|
+
show.executions.view=true
|
package/android/bin/jni/HDiffPatch/builds/android_ndk_jni_mk/java/com/github/sisong/HPatch.class
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Decoder$LiteralDecoder$Decoder2.class
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Encoder$LenPriceTableEncoder.class
ADDED
|
Binary file
|
package/android/bin/jni/lzma/Java/SevenZip/Compression/LZMA/Encoder$LiteralEncoder$Encoder2.class
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.17.0",
|
|
4
4
|
"description": "react-native hot update",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"scripts": {
|
|
@@ -74,5 +74,6 @@
|
|
|
74
74
|
"react-native": "0.73",
|
|
75
75
|
"ts-jest": "^29.2.5",
|
|
76
76
|
"typescript": "^5.6.3"
|
|
77
|
-
}
|
|
77
|
+
},
|
|
78
|
+
"packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
|
|
78
79
|
}
|
package/src/client.ts
CHANGED
|
@@ -43,11 +43,13 @@ export class Pushy {
|
|
|
43
43
|
lastChecking?: number;
|
|
44
44
|
lastRespJson?: Promise<any>;
|
|
45
45
|
|
|
46
|
-
progressHandlers: Record<string, EmitterSubscription> = {};
|
|
47
|
-
downloadedHash?: string;
|
|
46
|
+
static progressHandlers: Record<string, EmitterSubscription> = {};
|
|
47
|
+
static downloadedHash?: string;
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
static apkStatus: 'downloading' | 'downloaded' | null = null;
|
|
50
|
+
|
|
51
|
+
static marked = false;
|
|
52
|
+
static applyingUpdate = false;
|
|
51
53
|
version = cInfo.pushy;
|
|
52
54
|
loggerPromise = (() => {
|
|
53
55
|
let resolve: (value?: unknown) => void = () => {};
|
|
@@ -121,21 +123,21 @@ export class Pushy {
|
|
|
121
123
|
getCheckUrl = (endpoint: string = this.options.server!.main) => {
|
|
122
124
|
return `${endpoint}/checkUpdate/${this.options.appKey}`;
|
|
123
125
|
};
|
|
124
|
-
assertHash = (hash: string) => {
|
|
125
|
-
if (!
|
|
126
|
+
static assertHash = (hash: string) => {
|
|
127
|
+
if (!Pushy.downloadedHash) {
|
|
126
128
|
return;
|
|
127
129
|
}
|
|
128
|
-
if (hash !==
|
|
129
|
-
log(`use downloaded hash ${
|
|
130
|
+
if (hash !== Pushy.downloadedHash) {
|
|
131
|
+
log(`use downloaded hash ${Pushy.downloadedHash} first`);
|
|
130
132
|
return;
|
|
131
133
|
}
|
|
132
134
|
return true;
|
|
133
135
|
};
|
|
134
136
|
markSuccess = () => {
|
|
135
|
-
if (
|
|
137
|
+
if (Pushy.marked || __DEV__ || !isFirstTime) {
|
|
136
138
|
return;
|
|
137
139
|
}
|
|
138
|
-
|
|
140
|
+
Pushy.marked = true;
|
|
139
141
|
PushyModule.markSuccess();
|
|
140
142
|
this.report({ type: 'markSuccess' });
|
|
141
143
|
};
|
|
@@ -146,9 +148,9 @@ export class Pushy {
|
|
|
146
148
|
);
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
149
|
-
if (
|
|
151
|
+
if (Pushy.assertHash(hash) && !Pushy.applyingUpdate) {
|
|
150
152
|
log('switchVersion: ' + hash);
|
|
151
|
-
|
|
153
|
+
Pushy.applyingUpdate = true;
|
|
152
154
|
return PushyModule.reloadUpdate({ hash });
|
|
153
155
|
}
|
|
154
156
|
};
|
|
@@ -160,7 +162,7 @@ export class Pushy {
|
|
|
160
162
|
);
|
|
161
163
|
return;
|
|
162
164
|
}
|
|
163
|
-
if (
|
|
165
|
+
if (Pushy.assertHash(hash)) {
|
|
164
166
|
log('switchVersionLater: ' + hash);
|
|
165
167
|
return PushyModule.setNeedUpdate({ hash });
|
|
166
168
|
}
|
|
@@ -314,15 +316,15 @@ export class Pushy {
|
|
|
314
316
|
log(`rolledback hash ${rolledBackVersion}, ignored`);
|
|
315
317
|
return;
|
|
316
318
|
}
|
|
317
|
-
if (
|
|
318
|
-
log(`duplicated downloaded hash ${
|
|
319
|
-
return
|
|
319
|
+
if (Pushy.downloadedHash === hash) {
|
|
320
|
+
log(`duplicated downloaded hash ${Pushy.downloadedHash}, ignored`);
|
|
321
|
+
return Pushy.downloadedHash;
|
|
320
322
|
}
|
|
321
|
-
if (
|
|
323
|
+
if (Pushy.progressHandlers[hash]) {
|
|
322
324
|
return;
|
|
323
325
|
}
|
|
324
326
|
if (onDownloadProgress) {
|
|
325
|
-
|
|
327
|
+
Pushy.progressHandlers[hash] = pushyNativeEventEmitter.addListener(
|
|
326
328
|
'RCTPushyDownloadProgress',
|
|
327
329
|
progressData => {
|
|
328
330
|
if (progressData.hash === hash) {
|
|
@@ -389,9 +391,9 @@ export class Pushy {
|
|
|
389
391
|
}
|
|
390
392
|
}
|
|
391
393
|
}
|
|
392
|
-
if (
|
|
393
|
-
|
|
394
|
-
delete
|
|
394
|
+
if (Pushy.progressHandlers[hash]) {
|
|
395
|
+
Pushy.progressHandlers[hash].remove();
|
|
396
|
+
delete Pushy.progressHandlers[hash];
|
|
395
397
|
}
|
|
396
398
|
if (__DEV__) {
|
|
397
399
|
return hash;
|
|
@@ -417,7 +419,7 @@ export class Pushy {
|
|
|
417
419
|
description,
|
|
418
420
|
metaInfo,
|
|
419
421
|
});
|
|
420
|
-
|
|
422
|
+
Pushy.downloadedHash = hash;
|
|
421
423
|
return hash;
|
|
422
424
|
};
|
|
423
425
|
downloadAndInstallApk = async (
|
|
@@ -427,7 +429,14 @@ export class Pushy {
|
|
|
427
429
|
if (Platform.OS !== 'android') {
|
|
428
430
|
return;
|
|
429
431
|
}
|
|
430
|
-
|
|
432
|
+
if (Pushy.apkStatus === 'downloading') {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
if (Pushy.apkStatus === 'downloaded') {
|
|
436
|
+
this.report({ type: 'errorInstallApk' });
|
|
437
|
+
this.throwIfEnabled(new Error('errorInstallApk'));
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
431
440
|
if (Platform.Version <= 23) {
|
|
432
441
|
try {
|
|
433
442
|
const granted = await PermissionsAndroid.request(
|
|
@@ -444,12 +453,14 @@ export class Pushy {
|
|
|
444
453
|
return;
|
|
445
454
|
}
|
|
446
455
|
}
|
|
456
|
+
Pushy.apkStatus = 'downloading';
|
|
457
|
+
this.report({ type: 'downloadingApk' });
|
|
447
458
|
const progressKey = 'downloadingApk';
|
|
448
459
|
if (onDownloadProgress) {
|
|
449
|
-
if (
|
|
450
|
-
|
|
460
|
+
if (Pushy.progressHandlers[progressKey]) {
|
|
461
|
+
Pushy.progressHandlers[progressKey].remove();
|
|
451
462
|
}
|
|
452
|
-
|
|
463
|
+
Pushy.progressHandlers[progressKey] = pushyNativeEventEmitter.addListener(
|
|
453
464
|
'RCTPushyDownloadProgress',
|
|
454
465
|
(progressData: ProgressData) => {
|
|
455
466
|
if (progressData.hash === progressKey) {
|
|
@@ -463,12 +474,14 @@ export class Pushy {
|
|
|
463
474
|
target: 'update.apk',
|
|
464
475
|
hash: progressKey,
|
|
465
476
|
}).catch(() => {
|
|
477
|
+
Pushy.apkStatus = null;
|
|
466
478
|
this.report({ type: 'errorDownloadAndInstallApk' });
|
|
467
479
|
this.throwIfEnabled(new Error('errorDownloadAndInstallApk'));
|
|
468
480
|
});
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
481
|
+
Pushy.apkStatus = 'downloaded';
|
|
482
|
+
if (Pushy.progressHandlers[progressKey]) {
|
|
483
|
+
Pushy.progressHandlers[progressKey].remove();
|
|
484
|
+
delete Pushy.progressHandlers[progressKey];
|
|
472
485
|
}
|
|
473
486
|
};
|
|
474
487
|
}
|
package/src/context.ts
CHANGED
|
@@ -25,7 +25,7 @@ export const PushyContext = createContext<{
|
|
|
25
25
|
switchVersionLater: () => Promise<void>;
|
|
26
26
|
markSuccess: () => void;
|
|
27
27
|
dismissError: () => void;
|
|
28
|
-
downloadUpdate: () => Promise<void>;
|
|
28
|
+
downloadUpdate: () => Promise<boolean | void>;
|
|
29
29
|
downloadAndInstallApk: (url: string) => Promise<void>;
|
|
30
30
|
getCurrentVersionInfo: () => Promise<{
|
|
31
31
|
name?: string;
|
package/src/provider.tsx
CHANGED
|
@@ -90,18 +90,20 @@ export const PushyProvider = ({
|
|
|
90
90
|
const downloadUpdate = useCallback(
|
|
91
91
|
async (info: CheckResult | undefined = updateInfoRef.current) => {
|
|
92
92
|
if (!info || !info.update) {
|
|
93
|
-
return;
|
|
93
|
+
return false;
|
|
94
94
|
}
|
|
95
95
|
try {
|
|
96
96
|
const hash = await client.downloadUpdate(info, setProgress);
|
|
97
97
|
if (!hash) {
|
|
98
|
-
return;
|
|
98
|
+
return false;
|
|
99
99
|
}
|
|
100
100
|
stateListener.current && stateListener.current.remove();
|
|
101
101
|
if (options.updateStrategy === 'silentAndNow') {
|
|
102
|
-
|
|
102
|
+
client.switchVersion(hash);
|
|
103
|
+
return true;
|
|
103
104
|
} else if (options.updateStrategy === 'silentAndLater') {
|
|
104
|
-
|
|
105
|
+
client.switchVersionLater(hash);
|
|
106
|
+
return true;
|
|
105
107
|
}
|
|
106
108
|
alertUpdate('提示', '下载完毕,是否立即更新?', [
|
|
107
109
|
{
|
|
@@ -119,10 +121,12 @@ export const PushyProvider = ({
|
|
|
119
121
|
},
|
|
120
122
|
},
|
|
121
123
|
]);
|
|
124
|
+
return true;
|
|
122
125
|
} catch (e: any) {
|
|
123
126
|
setLastError(e);
|
|
124
127
|
alertError('更新失败', e.message);
|
|
125
128
|
throwErrorIfEnabled(e);
|
|
129
|
+
return false;
|
|
126
130
|
}
|
|
127
131
|
},
|
|
128
132
|
[
|
|
@@ -202,7 +206,8 @@ export const PushyProvider = ({
|
|
|
202
206
|
options.updateStrategy === 'silentAndNow' ||
|
|
203
207
|
options.updateStrategy === 'silentAndLater'
|
|
204
208
|
) {
|
|
205
|
-
|
|
209
|
+
downloadUpdate(info);
|
|
210
|
+
return;
|
|
206
211
|
}
|
|
207
212
|
alertUpdate(
|
|
208
213
|
'提示',
|
package/src/type.ts
CHANGED
|
@@ -38,7 +38,8 @@ export type EventType =
|
|
|
38
38
|
| 'downloadingApk'
|
|
39
39
|
| 'rejectStoragePermission'
|
|
40
40
|
| 'errorStoragePermission'
|
|
41
|
-
| 'errorDownloadAndInstallApk'
|
|
41
|
+
| 'errorDownloadAndInstallApk'
|
|
42
|
+
| 'errorInstallApk';
|
|
42
43
|
|
|
43
44
|
export interface EventData {
|
|
44
45
|
currentVersion: string;
|
package/.yarnrc.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
nodeLinker: node-modules
|