react-native-update 9.2.5 → 9.2.7

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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "mcpServers": {
3
+ "RadonAi": {
4
+ "url": "http://127.0.0.1:53976/mcp",
5
+ "type": "http",
6
+ "headers": {
7
+ "nonce": "199ac31c-50fd-441b-802e-5e8067371986"
8
+ }
9
+ }
10
+ }
11
+ }
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 fetch(getCheckUrl(APPKEY), fetchPayload);
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
- fetch(getCheckUrl(APPKEY, endpoint), fetchPayload),
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
- fetch(url, {
36
+ enhancedFetch(url, {
37
37
  method: 'HEAD',
38
38
  })
39
39
  .then(({ status, statusText }) => {
@@ -73,3 +73,34 @@ 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
+ .then((r) => {
92
+ if (r.ok) {
93
+ return r;
94
+ }
95
+ throw new Error(`${r.status} ${r.statusText}`);
96
+ })
97
+ .catch((e) => {
98
+ logger('fetch error', url, e);
99
+ if (isRetry) {
100
+ throw e;
101
+ }
102
+ logger('trying fallback to http');
103
+ return enhancedFetch(url.replace('https', 'http'), params, true);
104
+ });
105
+ };
106
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "9.2.5",
3
+ "version": "9.2.7",
4
4
  "description": "react-native hot update",
5
5
  "main": "lib/index.ts",
6
6
  "scripts": {