react-native-update 8.5.0 → 8.5.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/lib/endpoint.ts +16 -9
- package/package.json +1 -1
package/lib/endpoint.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { logger } from './utils';
|
|
2
2
|
|
|
3
3
|
let currentEndpoint = 'https://update.react-native.cn/api';
|
|
4
|
-
let backupEndpoints: string[] = [
|
|
5
|
-
|
|
4
|
+
let backupEndpoints: string[] = [
|
|
5
|
+
'https://pushy-koa-qgbgqmcpis.cn-beijing.fcapp.run',
|
|
6
|
+
'https://update.reactnative.cn/api',
|
|
7
|
+
];
|
|
8
|
+
let backupEndpointsQueryUrls = [
|
|
9
|
+
'https://gitee.com/sunnylqm/react-native-pushy/raw/master/endpoints.json',
|
|
10
|
+
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-pushy@master/endpoints.json',
|
|
11
|
+
];
|
|
6
12
|
|
|
7
13
|
export async function updateBackupEndpoints() {
|
|
8
|
-
if (
|
|
14
|
+
if (backupEndpointsQueryUrls) {
|
|
9
15
|
try {
|
|
10
|
-
const resp = await
|
|
16
|
+
const resp = await Promise.race(
|
|
17
|
+
backupEndpointsQueryUrls.map((queryUrl) => fetch(queryUrl)),
|
|
18
|
+
);
|
|
11
19
|
const remoteEndpoints = await resp.json();
|
|
12
20
|
if (Array.isArray(remoteEndpoints)) {
|
|
13
21
|
backupEndpoints = Array.from(
|
|
@@ -36,18 +44,17 @@ export function getCheckUrl(APPKEY, endpoint = currentEndpoint) {
|
|
|
36
44
|
export function setCustomEndpoints({
|
|
37
45
|
main,
|
|
38
46
|
backups,
|
|
39
|
-
|
|
47
|
+
backupQueryUrls,
|
|
40
48
|
}: {
|
|
41
49
|
main: string;
|
|
42
50
|
backups?: string[];
|
|
43
|
-
|
|
51
|
+
backupQueryUrls?: string[];
|
|
44
52
|
}) {
|
|
45
53
|
currentEndpoint = main;
|
|
46
|
-
backupEndpointsQueryUrl = null;
|
|
47
54
|
if (Array.isArray(backups) && backups.length > 0) {
|
|
48
55
|
backupEndpoints = backups;
|
|
49
56
|
}
|
|
50
|
-
if (
|
|
51
|
-
|
|
57
|
+
if (Array.isArray(backupQueryUrls) && backupQueryUrls.length > 0) {
|
|
58
|
+
backupEndpointsQueryUrls = backupQueryUrls;
|
|
52
59
|
}
|
|
53
60
|
}
|