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.
Files changed (2) hide show
  1. package/lib/endpoint.ts +16 -9
  2. 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[] = ['https://update.reactnative.cn/api'];
5
- let backupEndpointsQueryUrl: string | null = null;
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 (backupEndpointsQueryUrl) {
14
+ if (backupEndpointsQueryUrls) {
9
15
  try {
10
- const resp = await fetch(backupEndpointsQueryUrl);
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
- backupQueryUrl,
47
+ backupQueryUrls,
40
48
  }: {
41
49
  main: string;
42
50
  backups?: string[];
43
- backupQueryUrl?: string;
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 (typeof backupQueryUrl === 'string') {
51
- backupEndpointsQueryUrl = backupQueryUrl;
57
+ if (Array.isArray(backupQueryUrls) && backupQueryUrls.length > 0) {
58
+ backupEndpointsQueryUrls = backupQueryUrls;
52
59
  }
53
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "8.5.0",
3
+ "version": "8.5.1",
4
4
  "description": "react-native hot update",
5
5
  "main": "lib/index.ts",
6
6
  "scripts": {