Skip to content

Commit f7be8a4

Browse files
committed
Update dependencies in package.json and bun.lock, enhance .gitignore to exclude mcp.json, and refactor provider and utils for improved web support.
1 parent 4383a66 commit f7be8a4

5 files changed

Lines changed: 75 additions & 38 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ android/bin
5151
Example/testHotUpdate/harmony
5252
Example/testHotUpdate/android/app/.cxx
5353
Example/harmony_use_pushy/libs
54-
.cursor/mcp.json
54+
**/mcp.json

Example/expoUsePushy/bun.lock

Lines changed: 30 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/expoUsePushy/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
"web": "expo start --web"
1010
},
1111
"dependencies": {
12+
"@expo/metro-runtime": "~4.0.1",
1213
"expo": "~52.0.46",
1314
"expo-status-bar": "~2.0.1",
1415
"react": "18.3.1",
16+
"react-dom": "18.3.1",
1517
"react-native": "0.76.9",
16-
"react-native-update": "^10.28.7"
18+
"react-native-update": "^10.30.3",
19+
"react-native-web": "~0.19.13"
1720
},
1821
"devDependencies": {
1922
"@babel/core": "^7.25.2",

src/provider.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
import { UpdateContext } from './context';
2424
import { URL } from 'react-native-url-polyfill';
2525
import { isInRollout } from './isInRollout';
26-
import { log } from './utils';
26+
import { assertWeb, log } from './utils';
2727

2828
export const UpdateProvider = ({
2929
client,
@@ -277,6 +277,9 @@ export const UpdateProvider = ({
277277
if (!client.assertDebug('checkUpdate()')) {
278278
return;
279279
}
280+
if (!assertWeb()) {
281+
return;
282+
}
280283
const { checkStrategy, dismissErrorAfter, autoMarkSuccess } = options;
281284
if (autoMarkSuccess) {
282285
setTimeout(() => {
@@ -351,6 +354,9 @@ export const UpdateProvider = ({
351354
}, [client]);
352355

353356
useEffect(() => {
357+
if (!assertWeb()) {
358+
return;
359+
}
354360
const parseLinking = (url: string | null) => {
355361
if (!url) {
356362
return;

src/utils.ts

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export function log(...args: any[]) {
55
console.log(i18n.t('dev_log_prefix'), ...args);
66
}
77

8+
export const isWeb = Platform.OS === 'web';
9+
810
export function promiseAny<T>(promises: Promise<T>[]) {
911
return new Promise<T>((resolve, reject) => {
1012
let count = 0;
@@ -35,38 +37,37 @@ class EmptyModule {
3537
}
3638
export const emptyModule = new EmptyModule();
3739

38-
const ping =
39-
Platform.OS === 'web'
40-
? Promise.resolve
41-
: async (url: string) => {
42-
let pingFinished = false;
43-
return Promise.race([
44-
enhancedFetch(url, {
45-
method: 'HEAD',
40+
const ping = isWeb
41+
? Promise.resolve
42+
: async (url: string) => {
43+
let pingFinished = false;
44+
return Promise.race([
45+
enhancedFetch(url, {
46+
method: 'HEAD',
47+
})
48+
.then(({ status, statusText, url: finalUrl }) => {
49+
pingFinished = true;
50+
if (status === 200) {
51+
return finalUrl;
52+
}
53+
log('ping failed', url, status, statusText);
54+
throw new Error(i18n.t('error_ping_failed'));
4655
})
47-
.then(({ status, statusText, url: finalUrl }) => {
48-
pingFinished = true;
49-
if (status === 200) {
50-
return finalUrl;
51-
}
52-
log('ping failed', url, status, statusText);
53-
throw new Error(i18n.t('error_ping_failed'));
54-
})
55-
.catch(e => {
56-
pingFinished = true;
57-
log('ping error', url, e);
58-
throw e;
59-
}),
60-
new Promise((_, reject) =>
61-
setTimeout(() => {
62-
reject(new Error(i18n.t('error_ping_timeout')));
63-
if (!pingFinished) {
64-
log('ping timeout', url);
65-
}
66-
}, 5000),
67-
),
68-
]);
69-
};
56+
.catch(e => {
57+
pingFinished = true;
58+
log('ping error', url, e);
59+
throw e;
60+
}),
61+
new Promise((_, reject) =>
62+
setTimeout(() => {
63+
reject(new Error(i18n.t('error_ping_timeout')));
64+
if (!pingFinished) {
65+
log('ping timeout', url);
66+
}
67+
}, 5000),
68+
),
69+
]);
70+
};
7071

7172
export function joinUrls(paths: string[], fileName?: string) {
7273
if (fileName) {
@@ -91,7 +92,7 @@ export const testUrls = async (urls?: string[]) => {
9192
};
9293

9394
export const assertWeb = () => {
94-
if (Platform.OS === 'web') {
95+
if (isWeb) {
9596
console.warn(i18n.t('dev_web_not_supported'));
9697
return false;
9798
}

0 commit comments

Comments
 (0)