@onekeyfe/react-native-background-thread 3.0.88 → 3.0.90

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.
@@ -66,6 +66,17 @@ typedef NS_ENUM(NSInteger, EBgMgrSegmentEvalError) {
66
66
  /// @param host The RCTHost for the main runtime
67
67
  + (void)installSharedBridgeInMainRuntime:(RCTHost *)host;
68
68
 
69
+ /// Install the main-runtime bridge and start the background runtime only after
70
+ /// that installation has executed on the main JS runtime. Expo initializes its
71
+ /// module registry on the JS thread, so this ordered entry point prevents a
72
+ /// second Expo-backed runtime from registering modules during foreground
73
+ /// runtime startup.
74
+ ///
75
+ /// @param host The RCTHost for the main runtime
76
+ /// @param entryURL The custom entry URL for the background runner
77
+ + (void)installSharedBridgeInMainRuntime:(RCTHost *)host
78
+ thenStartBackgroundRunnerWithEntryURL:(NSString *)entryURL;
79
+
69
80
  /// Start background runner with default entry URL
70
81
  - (void)startBackgroundRunner;
71
82
 
@@ -44,6 +44,19 @@ class BgMgrNSDataJSIBuffer : public facebook::jsi::Buffer {
44
44
 
45
45
  } // namespace
46
46
 
47
+ static RCTReactNativeFactory *CreateBackgroundReactNativeFactory(
48
+ id<RCTReactNativeFactoryDelegate> delegate) {
49
+ Class expoFactoryClass = NSClassFromString(@"EXReactNativeFactory");
50
+ if (expoFactoryClass &&
51
+ [expoFactoryClass isSubclassOfClass:[RCTReactNativeFactory class]]) {
52
+ [BTLogger info:@"Using Expo React Native factory for background runtime"];
53
+ return [(RCTReactNativeFactory *)[expoFactoryClass alloc]
54
+ initWithDelegate:delegate];
55
+ }
56
+
57
+ return [[RCTReactNativeFactory alloc] initWithDelegate:delegate];
58
+ }
59
+
47
60
  // Exactly-once settle guard for the bg watchdog — same design as
48
61
  // SplitBundleLoader's SBLSettleGuard. An ARC object captured by both the
49
62
  // executor block and the watchdog dispatch_after; ARC keeps its lock alive
@@ -172,7 +185,8 @@ static NSString *const MODULE_DEBUG_URL = @"http://localhost:8082/apps/mobile/ba
172
185
 
173
186
  #pragma mark - SharedBridge
174
187
 
175
- + (void)installSharedBridgeInMainRuntime:(RCTHost *)host {
188
+ + (void)installSharedBridgeInMainRuntime:(RCTHost *)host
189
+ completion:(dispatch_block_t)completion {
176
190
  if (!host) {
177
191
  [BTLogger error:@"Cannot install SharedBridge: RCTHost is nil"];
178
192
  return;
@@ -212,6 +226,21 @@ static NSString *const MODULE_DEBUG_URL = @"http://localhost:8082/apps/mobile/ba
212
226
  // reload observer reads this to detect host hostDidStart: omissions.
213
227
  [BackgroundThreadManager sharedInstance].mainSharedBridgeInstalled = YES;
214
228
  [BTLogger info:@"SharedStore and SharedRPC installed in main runtime"];
229
+ if (completion) {
230
+ completion();
231
+ }
232
+ }];
233
+ }
234
+
235
+ + (void)installSharedBridgeInMainRuntime:(RCTHost *)host {
236
+ [self installSharedBridgeInMainRuntime:host completion:nil];
237
+ }
238
+
239
+ + (void)installSharedBridgeInMainRuntime:(RCTHost *)host
240
+ thenStartBackgroundRunnerWithEntryURL:(NSString *)entryURL {
241
+ [self installSharedBridgeInMainRuntime:host completion:^{
242
+ [[BackgroundThreadManager sharedInstance]
243
+ startBackgroundRunnerWithEntryURL:entryURL];
215
244
  }];
216
245
  }
217
246
 
@@ -255,7 +284,7 @@ static NSString *const MODULE_DEBUG_URL = @"http://localhost:8082/apps/mobile/ba
255
284
  NSDictionary *initialProperties = @{};
256
285
  NSDictionary *launchOptions = @{};
257
286
  self.reactNativeFactoryDelegate = [[BackgroundReactNativeDelegate alloc] init];
258
- self.reactNativeFactory = [[RCTReactNativeFactory alloc] initWithDelegate:self.reactNativeFactoryDelegate];
287
+ self.reactNativeFactory = CreateBackgroundReactNativeFactory(self.reactNativeFactoryDelegate);
259
288
 
260
289
  // Only set jsBundleSource for debug HTTP URLs or explicit OTA overrides.
261
290
  // Leaving the default release name ("background.bundle") unset lets the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-background-thread",
3
- "version": "3.0.88",
3
+ "version": "3.0.90",
4
4
  "description": "react-native-background-thread",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -63,8 +63,8 @@
63
63
  "@eslint/compat": "^1.3.2",
64
64
  "@eslint/eslintrc": "^3.3.1",
65
65
  "@eslint/js": "^9.35.0",
66
- "@react-native/babel-preset": "0.83.0",
67
- "@react-native/eslint-config": "0.83.0",
66
+ "@react-native/babel-preset": "0.86.2",
67
+ "@react-native/eslint-config": "0.86.2",
68
68
  "@release-it/conventional-changelog": "^10.0.1",
69
69
  "@types/jest": "^29.5.14",
70
70
  "@types/react": "^19.2.0",
@@ -76,8 +76,8 @@
76
76
  "jest": "^29.7.0",
77
77
  "lefthook": "^2.0.3",
78
78
  "prettier": "^2.8.8",
79
- "react": "19.2.0",
80
- "react-native": "patch:react-native@npm%3A0.83.0#~/.yarn/patches/react-native-npm-0.83.0-577d0f2d83.patch",
79
+ "react": "19.2.3",
80
+ "react-native": "patch:react-native@npm%3A0.86.2#~/.yarn/patches/react-native-npm-0.86.2-c9d546616f.patch",
81
81
  "react-native-builder-bob": "^0.40.17",
82
82
  "release-it": "^19.0.4",
83
83
  "turbo": "^2.5.6",