react-native-update 10.12.0 → 10.13.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/package.json +1 -1
- package/src/client.ts +13 -16
- package/src/core.ts +1 -3
- package/src/type.ts +4 -6
- package/src/utils.ts +10 -1
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CheckResult, PushyOptions, ProgressData, EventType } from './type';
|
|
2
|
-
import { log, testUrls } from './utils';
|
|
2
|
+
import { joinUrls, log, testUrls } from './utils';
|
|
3
3
|
import { EmitterSubscription, Platform } from 'react-native';
|
|
4
4
|
import { PermissionsAndroid } from './permissions';
|
|
5
5
|
import {
|
|
@@ -64,8 +64,7 @@ export class Pushy {
|
|
|
64
64
|
setOptions = (options: Partial<PushyOptions>) => {
|
|
65
65
|
for (const [key, value] of Object.entries(options)) {
|
|
66
66
|
if (value !== undefined) {
|
|
67
|
-
|
|
68
|
-
this.options[key] = value;
|
|
67
|
+
(this.options as any)[key] = value;
|
|
69
68
|
if (key === 'logger') {
|
|
70
69
|
if (isRolledBack) {
|
|
71
70
|
this.report({
|
|
@@ -272,15 +271,13 @@ export class Pushy {
|
|
|
272
271
|
) => {
|
|
273
272
|
const {
|
|
274
273
|
hash,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
updateUrl: _updateUrl,
|
|
280
|
-
updateUrls,
|
|
274
|
+
diff,
|
|
275
|
+
pdiff,
|
|
276
|
+
full,
|
|
277
|
+
paths = [],
|
|
281
278
|
name,
|
|
282
|
-
description,
|
|
283
|
-
metaInfo,
|
|
279
|
+
description = '',
|
|
280
|
+
metaInfo = '',
|
|
284
281
|
} = info;
|
|
285
282
|
if (
|
|
286
283
|
this.options.beforeDownloadUpdate &&
|
|
@@ -316,7 +313,7 @@ export class Pushy {
|
|
|
316
313
|
let succeeded = '';
|
|
317
314
|
this.report({ type: 'downloading' });
|
|
318
315
|
let lastError: any;
|
|
319
|
-
const diffUrl =
|
|
316
|
+
const diffUrl = await testUrls(joinUrls(paths, diff));
|
|
320
317
|
if (diffUrl) {
|
|
321
318
|
log('downloading diff');
|
|
322
319
|
try {
|
|
@@ -335,7 +332,7 @@ export class Pushy {
|
|
|
335
332
|
}
|
|
336
333
|
}
|
|
337
334
|
}
|
|
338
|
-
const pdiffUrl =
|
|
335
|
+
const pdiffUrl = await testUrls(joinUrls(paths, pdiff));
|
|
339
336
|
if (!succeeded && pdiffUrl) {
|
|
340
337
|
log('downloading pdiff');
|
|
341
338
|
try {
|
|
@@ -353,12 +350,12 @@ export class Pushy {
|
|
|
353
350
|
}
|
|
354
351
|
}
|
|
355
352
|
}
|
|
356
|
-
const
|
|
357
|
-
if (!succeeded &&
|
|
353
|
+
const fullUrl = await testUrls(joinUrls(paths, full));
|
|
354
|
+
if (!succeeded && fullUrl) {
|
|
358
355
|
log('downloading full patch');
|
|
359
356
|
try {
|
|
360
357
|
await PushyModule.downloadFullUpdate({
|
|
361
|
-
updateUrl:
|
|
358
|
+
updateUrl: fullUrl,
|
|
362
359
|
hash,
|
|
363
360
|
});
|
|
364
361
|
succeeded = 'full';
|
package/src/core.ts
CHANGED
|
@@ -4,9 +4,7 @@ const {
|
|
|
4
4
|
version: v,
|
|
5
5
|
} = require('react-native/Libraries/Core/ReactNativeVersion');
|
|
6
6
|
const RNVersion = `${v.major}.${v.minor}.${v.patch}`;
|
|
7
|
-
const isTurboModuleEnabled =
|
|
8
|
-
// @ts-expect-error
|
|
9
|
-
global.__turboModuleProxy != null;
|
|
7
|
+
const isTurboModuleEnabled = (global as any).__turboModuleProxy != null;
|
|
10
8
|
|
|
11
9
|
export const PushyModule =
|
|
12
10
|
Platform.OS === 'web'
|
package/src/type.ts
CHANGED
|
@@ -7,12 +7,10 @@ export interface CheckResult {
|
|
|
7
7
|
hash?: string;
|
|
8
8
|
description?: string;
|
|
9
9
|
metaInfo?: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
updateUrl?: string;
|
|
15
|
-
updateUrls?: string[];
|
|
10
|
+
pdiff?: string;
|
|
11
|
+
diff?: string;
|
|
12
|
+
full?: string;
|
|
13
|
+
paths?: string[];
|
|
16
14
|
paused?: 'app' | 'package';
|
|
17
15
|
message?: string;
|
|
18
16
|
}
|
package/src/utils.ts
CHANGED
|
@@ -31,9 +31,18 @@ const ping =
|
|
|
31
31
|
|
|
32
32
|
const canUseGoogle = ping('https://www.google.com');
|
|
33
33
|
|
|
34
|
+
export function joinUrls(paths: string[], fileName?: string) {
|
|
35
|
+
if (fileName) {
|
|
36
|
+
return paths.map(path => 'https://' + path + '/' + fileName);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
export const testUrls = async (urls?: string[]) => {
|
|
35
|
-
if (!urls?.length
|
|
41
|
+
if (!urls?.length) {
|
|
36
42
|
return null;
|
|
37
43
|
}
|
|
44
|
+
if (await canUseGoogle) {
|
|
45
|
+
return urls[0];
|
|
46
|
+
}
|
|
38
47
|
return Promise.race(urls.map(ping)).catch(() => null);
|
|
39
48
|
};
|