react-native-update 10.19.1 → 10.19.2
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/.github/workflows/publish.yml +21 -0
- package/ios/RCTPushy/RCTPushy.mm +7 -6
- package/package.json +1 -1
- package/src/utils.ts +31 -6
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Publish Package to npmjs
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [published]
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
# Setup .npmrc file to publish to npm
|
|
14
|
+
- uses: actions/setup-node@v4
|
|
15
|
+
with:
|
|
16
|
+
node-version: '20.x'
|
|
17
|
+
registry-url: 'https://registry.npmjs.org'
|
|
18
|
+
- run: npm ci
|
|
19
|
+
- run: npm publish --provenance --access public
|
|
20
|
+
env:
|
|
21
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/ios/RCTPushy/RCTPushy.mm
CHANGED
|
@@ -315,17 +315,18 @@ RCT_EXPORT_METHOD(reloadUpdate:(NSDictionary *)options
|
|
|
315
315
|
if (hash.length) {
|
|
316
316
|
[self setNeedUpdate:options resolver:resolve rejecter:reject];
|
|
317
317
|
|
|
318
|
+
// reload in earlier version
|
|
319
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
320
|
+
[self.bridge setValue:[[self class] bundleURL] forKey:@"bundleURL"];
|
|
321
|
+
[self.bridge reload];
|
|
322
|
+
});
|
|
323
|
+
|
|
318
324
|
#if __has_include("RCTReloadCommand.h")
|
|
319
325
|
// reload 0.62+
|
|
320
326
|
RCTReloadCommandSetBundleURL([[self class] bundleURL]);
|
|
321
327
|
RCTTriggerReloadCommandListeners(@"pushy reload");
|
|
322
|
-
#else
|
|
323
|
-
// reload in earlier version
|
|
324
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
325
|
-
[self.bridge setValue:[[self class] bundleURL] forKey:@"bundleURL"];
|
|
326
|
-
[self.bridge reload];
|
|
327
|
-
});
|
|
328
328
|
#endif
|
|
329
|
+
|
|
329
330
|
resolve(@true);
|
|
330
331
|
}else{
|
|
331
332
|
reject(@"执行报错", nil, nil);
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -37,15 +37,35 @@ export const emptyModule = new EmptyModule();
|
|
|
37
37
|
const ping =
|
|
38
38
|
Platform.OS === 'web'
|
|
39
39
|
? Promise.resolve
|
|
40
|
-
: async (url: string) =>
|
|
41
|
-
|
|
40
|
+
: async (url: string) => {
|
|
41
|
+
let pingFinished = false;
|
|
42
|
+
return Promise.race([
|
|
42
43
|
fetch(url, {
|
|
43
44
|
method: 'HEAD',
|
|
44
45
|
})
|
|
45
|
-
.then(({ status }) =>
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
.then(({ status, statusText }) => {
|
|
47
|
+
pingFinished = true;
|
|
48
|
+
if (status === 200) {
|
|
49
|
+
return url;
|
|
50
|
+
}
|
|
51
|
+
log('ping failed', url, status, statusText);
|
|
52
|
+
return null;
|
|
53
|
+
})
|
|
54
|
+
.catch(e => {
|
|
55
|
+
pingFinished = true;
|
|
56
|
+
log('ping error', url, e);
|
|
57
|
+
return null;
|
|
58
|
+
}),
|
|
59
|
+
new Promise(r =>
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
r(null);
|
|
62
|
+
if (!pingFinished) {
|
|
63
|
+
log('ping timeout', url);
|
|
64
|
+
}
|
|
65
|
+
}, 2000),
|
|
66
|
+
),
|
|
48
67
|
]);
|
|
68
|
+
};
|
|
49
69
|
|
|
50
70
|
export function joinUrls(paths: string[], fileName?: string) {
|
|
51
71
|
if (fileName) {
|
|
@@ -57,5 +77,10 @@ export const testUrls = async (urls?: string[]) => {
|
|
|
57
77
|
if (!urls?.length) {
|
|
58
78
|
return null;
|
|
59
79
|
}
|
|
60
|
-
|
|
80
|
+
const ret = await promiseAny(urls.map(ping));
|
|
81
|
+
if (ret) {
|
|
82
|
+
return ret;
|
|
83
|
+
}
|
|
84
|
+
log('all ping failed, use first url:', urls[0]);
|
|
85
|
+
return urls[0];
|
|
61
86
|
};
|