react-native-update 10.41.0 → 10.42.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/package.json
CHANGED
|
Binary file
|
package/src/client.ts
CHANGED
|
@@ -452,6 +452,10 @@ export class Pushy {
|
|
|
452
452
|
if (!updateInfo.update || !hash) {
|
|
453
453
|
return;
|
|
454
454
|
}
|
|
455
|
+
if (hash === currentVersion) {
|
|
456
|
+
log(`current hash ${currentVersion}, ignored`);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
455
459
|
if (rolledBackVersion === hash) {
|
|
456
460
|
log(`rolledback hash ${rolledBackVersion}, ignored`);
|
|
457
461
|
return;
|
package/src/provider.tsx
CHANGED
|
@@ -23,11 +23,10 @@ import {
|
|
|
23
23
|
CheckResult,
|
|
24
24
|
ProgressData,
|
|
25
25
|
UpdateTestPayload,
|
|
26
|
-
VersionInfo,
|
|
27
26
|
} from './type';
|
|
28
27
|
import { UpdateContext } from './context';
|
|
29
28
|
import { URL } from 'react-native-url-polyfill';
|
|
30
|
-
import {
|
|
29
|
+
import { resolveCheckResult } from './resolveCheckResult';
|
|
31
30
|
import { assertWeb, log } from './utils';
|
|
32
31
|
|
|
33
32
|
export const UpdateProvider = ({
|
|
@@ -181,94 +180,77 @@ export const UpdateProvider = ({
|
|
|
181
180
|
if (!rootInfo) {
|
|
182
181
|
return;
|
|
183
182
|
}
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
log(`${info.name} in ${rollout}% rollout, continue`);
|
|
200
|
-
}
|
|
201
|
-
if (info.update) {
|
|
202
|
-
info.description = info.description ?? '';
|
|
183
|
+
const info = resolveCheckResult(rootInfo);
|
|
184
|
+
if (info.update) {
|
|
185
|
+
info.description = info.description ?? '';
|
|
186
|
+
}
|
|
187
|
+
updateInfoRef.current = info;
|
|
188
|
+
setUpdateInfo(info);
|
|
189
|
+
if (info.expired) {
|
|
190
|
+
if (
|
|
191
|
+
options.onPackageExpired &&
|
|
192
|
+
(await options.onPackageExpired(info)) === false
|
|
193
|
+
) {
|
|
194
|
+
log('onPackageExpired returned false, skipping');
|
|
195
|
+
return;
|
|
203
196
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
log('onPackageExpired returned false, skipping');
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
const { downloadUrl } = info;
|
|
215
|
-
if (downloadUrl && sharedState.apkStatus === null) {
|
|
216
|
-
if (options.updateStrategy === 'silentAndNow') {
|
|
217
|
-
if (Platform.OS === 'android' && downloadUrl.endsWith('.apk')) {
|
|
218
|
-
downloadAndInstallApk(downloadUrl);
|
|
219
|
-
} else {
|
|
220
|
-
Linking.openURL(downloadUrl);
|
|
221
|
-
}
|
|
222
|
-
return info;
|
|
197
|
+
const { downloadUrl } = info;
|
|
198
|
+
if (downloadUrl && sharedState.apkStatus === null) {
|
|
199
|
+
if (options.updateStrategy === 'silentAndNow') {
|
|
200
|
+
if (Platform.OS === 'android' && downloadUrl.endsWith('.apk')) {
|
|
201
|
+
downloadAndInstallApk(downloadUrl);
|
|
202
|
+
} else {
|
|
203
|
+
Linking.openURL(downloadUrl);
|
|
223
204
|
}
|
|
224
|
-
alertUpdate(
|
|
225
|
-
client.t('alert_title'),
|
|
226
|
-
client.t('alert_app_updated'),
|
|
227
|
-
[
|
|
228
|
-
{
|
|
229
|
-
text: client.t('alert_update_button'),
|
|
230
|
-
onPress: () => {
|
|
231
|
-
if (
|
|
232
|
-
Platform.OS === 'android' &&
|
|
233
|
-
downloadUrl.endsWith('.apk')
|
|
234
|
-
) {
|
|
235
|
-
downloadAndInstallApk(downloadUrl);
|
|
236
|
-
} else {
|
|
237
|
-
Linking.openURL(downloadUrl);
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
],
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
} else if (info.update) {
|
|
245
|
-
if (
|
|
246
|
-
options.updateStrategy === 'silentAndNow' ||
|
|
247
|
-
options.updateStrategy === 'silentAndLater'
|
|
248
|
-
) {
|
|
249
|
-
downloadUpdate(info);
|
|
250
205
|
return info;
|
|
251
206
|
}
|
|
252
207
|
alertUpdate(
|
|
253
208
|
client.t('alert_title'),
|
|
254
|
-
client.t('
|
|
255
|
-
name: info.name!,
|
|
256
|
-
description: info.description!,
|
|
257
|
-
}),
|
|
209
|
+
client.t('alert_app_updated'),
|
|
258
210
|
[
|
|
259
|
-
{ text: client.t('alert_cancel'), style: 'cancel' },
|
|
260
211
|
{
|
|
261
|
-
text: client.t('
|
|
262
|
-
style: 'default',
|
|
212
|
+
text: client.t('alert_update_button'),
|
|
263
213
|
onPress: () => {
|
|
264
|
-
|
|
214
|
+
if (
|
|
215
|
+
Platform.OS === 'android' &&
|
|
216
|
+
downloadUrl.endsWith('.apk')
|
|
217
|
+
) {
|
|
218
|
+
downloadAndInstallApk(downloadUrl);
|
|
219
|
+
} else {
|
|
220
|
+
Linking.openURL(downloadUrl);
|
|
221
|
+
}
|
|
265
222
|
},
|
|
266
223
|
},
|
|
267
224
|
],
|
|
268
225
|
);
|
|
269
226
|
}
|
|
270
|
-
|
|
227
|
+
} else if (info.update) {
|
|
228
|
+
if (
|
|
229
|
+
options.updateStrategy === 'silentAndNow' ||
|
|
230
|
+
options.updateStrategy === 'silentAndLater'
|
|
231
|
+
) {
|
|
232
|
+
downloadUpdate(info);
|
|
233
|
+
return info;
|
|
234
|
+
}
|
|
235
|
+
alertUpdate(
|
|
236
|
+
client.t('alert_title'),
|
|
237
|
+
client.t('alert_new_version_found', {
|
|
238
|
+
name: info.name!,
|
|
239
|
+
description: info.description!,
|
|
240
|
+
}),
|
|
241
|
+
[
|
|
242
|
+
{ text: client.t('alert_cancel'), style: 'cancel' },
|
|
243
|
+
{
|
|
244
|
+
text: client.t('alert_confirm'),
|
|
245
|
+
style: 'default',
|
|
246
|
+
onPress: () => {
|
|
247
|
+
downloadUpdate();
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
);
|
|
271
252
|
}
|
|
253
|
+
return info;
|
|
272
254
|
},
|
|
273
255
|
[
|
|
274
256
|
client,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { currentVersion, packageVersion } from './core';
|
|
2
|
+
import { isInRollout } from './isInRollout';
|
|
3
|
+
import { CheckResult } from './type';
|
|
4
|
+
import { log } from './utils';
|
|
5
|
+
|
|
6
|
+
export function resolveCheckResult(rootInfo: CheckResult): CheckResult {
|
|
7
|
+
const { expVersion, ...rootResult } = rootInfo;
|
|
8
|
+
const rollout = expVersion?.config?.rollout?.[packageVersion];
|
|
9
|
+
if (rootResult.update && expVersion && typeof rollout === 'number') {
|
|
10
|
+
if (isInRollout(rollout)) {
|
|
11
|
+
log(`${expVersion.name} in ${rollout}% rollout, continue`);
|
|
12
|
+
if (expVersion.hash === currentVersion) {
|
|
13
|
+
return { upToDate: true };
|
|
14
|
+
}
|
|
15
|
+
const info: CheckResult = {
|
|
16
|
+
update: true,
|
|
17
|
+
...expVersion,
|
|
18
|
+
};
|
|
19
|
+
if (rootResult.paths) {
|
|
20
|
+
info.paths = rootResult.paths;
|
|
21
|
+
}
|
|
22
|
+
return info;
|
|
23
|
+
}
|
|
24
|
+
log(`${expVersion.name} not in ${rollout}% rollout, ignored`);
|
|
25
|
+
}
|
|
26
|
+
if (rootResult.update && rootResult.hash === currentVersion) {
|
|
27
|
+
return { upToDate: true };
|
|
28
|
+
}
|
|
29
|
+
return rootResult;
|
|
30
|
+
}
|