react-native-update 10.17.0 → 10.18.0

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.
@@ -1,6 +1,10 @@
1
1
  #import "RCTPushy.h"
2
2
  #import "RCTPushyDownloader.h"
3
3
  #import "RCTPushyManager.h"
4
+
5
+ #if __has_include("RCTReloadCommand.h")
6
+ #import "RCTReloadCommand.h"
7
+ #endif
4
8
  // Thanks to this guard, we won't import this header when we build for the old architecture.
5
9
  #ifdef RCT_NEW_ARCH_ENABLED
6
10
  #import "RCTPushySpec.h"
@@ -311,14 +315,17 @@ RCT_EXPORT_METHOD(reloadUpdate:(NSDictionary *)options
311
315
  if (hash.length) {
312
316
  [self setNeedUpdate:options resolver:resolve rejecter:reject];
313
317
 
314
- // reload 0.62+
315
- // RCTReloadCommandSetBundleURL([[self class] bundleURL]);
316
- // RCTTriggerReloadCommandListeners(@"pushy reload");
317
-
318
- dispatch_async(dispatch_get_main_queue(), ^{
319
- [self.bridge setValue:[[self class] bundleURL] forKey:@"bundleURL"];
320
- [self.bridge reload];
321
- });
318
+ #if __has_include("RCTReloadCommand.h")
319
+ // reload 0.62+
320
+ RCTReloadCommandSetBundleURL([[self class] bundleURL]);
321
+ 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
+ #endif
322
329
  resolve(@true);
323
330
  }else{
324
331
  reject(@"执行报错", nil, nil);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.17.0",
3
+ "version": "10.18.0",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {
package/src/utils.ts CHANGED
@@ -41,12 +41,12 @@ const ping =
41
41
  Promise.race([
42
42
  fetch(url, {
43
43
  method: 'HEAD',
44
- }).then(({ status }) => (status === 200 ? url : null)),
44
+ })
45
+ .then(({ status }) => (status === 200 ? url : null))
46
+ .catch(() => null),
45
47
  new Promise(r => setTimeout(() => r(null), 2000)),
46
48
  ]);
47
49
 
48
- const canUseGoogle = ping('https://www.google.com');
49
-
50
50
  export function joinUrls(paths: string[], fileName?: string) {
51
51
  if (fileName) {
52
52
  return paths.map(path => 'https://' + path + '/' + fileName);
@@ -57,8 +57,5 @@ export const testUrls = async (urls?: string[]) => {
57
57
  if (!urls?.length) {
58
58
  return null;
59
59
  }
60
- if (await canUseGoogle) {
61
- return urls[0];
62
- }
63
60
  return promiseAny(urls.map(ping)).catch(() => null);
64
61
  };