react-native-update 9.2.5 → 9.2.8
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/.cursor/mcp.json +4 -0
- package/lib/main.ts +3 -3
- package/lib/utils.ts +26 -1
- package/package.json +1 -1
package/.cursor/mcp.json
ADDED
package/lib/main.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
UpdateAvailableResult,
|
|
17
17
|
UpdateEventsListener,
|
|
18
18
|
} from './type';
|
|
19
|
-
import { assertRelease, logger, promiseAny, testUrls } from './utils';
|
|
19
|
+
import { assertRelease, enhancedFetch, logger, promiseAny, testUrls } from './utils';
|
|
20
20
|
export { setCustomEndpoints };
|
|
21
21
|
const {
|
|
22
22
|
version: v,
|
|
@@ -158,7 +158,7 @@ export async function checkUpdate(APPKEY: string) {
|
|
|
158
158
|
};
|
|
159
159
|
let resp;
|
|
160
160
|
try {
|
|
161
|
-
resp = await
|
|
161
|
+
resp = await enhancedFetch(getCheckUrl(APPKEY), fetchPayload);
|
|
162
162
|
} catch (e) {
|
|
163
163
|
report({
|
|
164
164
|
type: 'errorChecking',
|
|
@@ -169,7 +169,7 @@ export async function checkUpdate(APPKEY: string) {
|
|
|
169
169
|
try {
|
|
170
170
|
resp = await promiseAny(
|
|
171
171
|
backupEndpoints.map(endpoint =>
|
|
172
|
-
|
|
172
|
+
enhancedFetch(getCheckUrl(APPKEY, endpoint), fetchPayload),
|
|
173
173
|
),
|
|
174
174
|
);
|
|
175
175
|
} catch {}
|
package/lib/utils.ts
CHANGED
|
@@ -33,7 +33,7 @@ const ping =
|
|
|
33
33
|
: async (url: string) => {
|
|
34
34
|
let pingFinished = false;
|
|
35
35
|
return Promise.race([
|
|
36
|
-
|
|
36
|
+
enhancedFetch(url, {
|
|
37
37
|
method: 'HEAD',
|
|
38
38
|
})
|
|
39
39
|
.then(({ status, statusText }) => {
|
|
@@ -73,3 +73,28 @@ export const testUrls = async (urls?: string[]) => {
|
|
|
73
73
|
logger('all ping failed, use first url:', urls[0]);
|
|
74
74
|
return urls[0];
|
|
75
75
|
};
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// export const isAndroid70AndBelow = () => {
|
|
80
|
+
// // android 7.0 and below devices do not support letsencrypt cert
|
|
81
|
+
// // https://letsencrypt.org/2023/07/10/cross-sign-expiration/
|
|
82
|
+
// return Platform.OS === 'android' && Platform.Version <= 24;
|
|
83
|
+
// };
|
|
84
|
+
|
|
85
|
+
export const enhancedFetch = async (
|
|
86
|
+
url: string,
|
|
87
|
+
params: Parameters<typeof fetch>[1],
|
|
88
|
+
isRetry = false,
|
|
89
|
+
) => {
|
|
90
|
+
return fetch(url, params)
|
|
91
|
+
.catch((e) => {
|
|
92
|
+
logger('fetch error', url, e);
|
|
93
|
+
if (isRetry) {
|
|
94
|
+
throw e;
|
|
95
|
+
}
|
|
96
|
+
logger('trying fallback to http');
|
|
97
|
+
return enhancedFetch(url.replace('https', 'http'), params, true);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|