react-native-update 10.10.1 → 10.10.3
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 +8 -4
- package/src/provider.tsx +17 -10
- package/src/type.ts +1 -1
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -17,8 +17,10 @@ import {
|
|
|
17
17
|
const defaultServer = {
|
|
18
18
|
main: 'https://update.react-native.cn/api',
|
|
19
19
|
backups: ['https://update.reactnative.cn/api'],
|
|
20
|
-
|
|
20
|
+
queryUrls: [
|
|
21
|
+
'https://gitee.com/sunnylqm/react-native-pushy/raw/master/endpoints.json',
|
|
21
22
|
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-pushy@master/endpoints.json',
|
|
23
|
+
],
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
const empty = {};
|
|
@@ -233,9 +235,11 @@ export class Pushy {
|
|
|
233
235
|
if (!server) {
|
|
234
236
|
return [];
|
|
235
237
|
}
|
|
236
|
-
if (server.
|
|
238
|
+
if (server.queryUrls) {
|
|
237
239
|
try {
|
|
238
|
-
const resp = await
|
|
240
|
+
const resp = await Promise.race(
|
|
241
|
+
server.queryUrls.map(queryUrl => fetch(queryUrl)),
|
|
242
|
+
);
|
|
239
243
|
const remoteEndpoints = await resp.json();
|
|
240
244
|
log('fetch endpoints:', remoteEndpoints);
|
|
241
245
|
if (Array.isArray(remoteEndpoints)) {
|
|
@@ -244,7 +248,7 @@ export class Pushy {
|
|
|
244
248
|
);
|
|
245
249
|
}
|
|
246
250
|
} catch (e: any) {
|
|
247
|
-
log('failed to fetch endpoints from: ', server.
|
|
251
|
+
log('failed to fetch endpoints from: ', server.queryUrls);
|
|
248
252
|
}
|
|
249
253
|
}
|
|
250
254
|
return server.backups;
|
package/src/provider.tsx
CHANGED
|
@@ -270,21 +270,28 @@ export const PushyProvider = ({
|
|
|
270
270
|
} catch {
|
|
271
271
|
return false;
|
|
272
272
|
}
|
|
273
|
-
if (payload && payload.type) {
|
|
273
|
+
if (payload && payload.type && payload.type.startsWith('__rnPushy')) {
|
|
274
|
+
const logger = options.logger || (() => {});
|
|
275
|
+
options.logger = ({ type, data }) => {
|
|
276
|
+
logger({ type, data });
|
|
277
|
+
Alert.alert(type, JSON.stringify(data));
|
|
278
|
+
};
|
|
274
279
|
if (payload.type === '__rnPushyVersionHash') {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
checkUpdate({ toHash: payload.data }).then(() => {
|
|
281
|
+
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
|
282
|
+
Alert.alert(
|
|
283
|
+
'提示',
|
|
284
|
+
'当前尚未检测到更新版本,如果是首次扫码,请等待服务器端生成补丁包后再试(约10秒)',
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
options.logger = logger;
|
|
288
|
+
});
|
|
283
289
|
}
|
|
290
|
+
return true;
|
|
284
291
|
}
|
|
285
292
|
return false;
|
|
286
293
|
},
|
|
287
|
-
[checkUpdate],
|
|
294
|
+
[checkUpdate, options],
|
|
288
295
|
);
|
|
289
296
|
|
|
290
297
|
return (
|