@onekeyfe/react-native-split-bundle-loader 1.1.51 → 1.1.52

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.
@@ -15,4 +15,14 @@
15
15
  resolve:(RCTPromiseResolveBlock)resolve
16
16
  reject:(RCTPromiseRejectBlock)reject;
17
17
 
18
+ /// Evaluate a JS bundle file inside the given RCTHost's runtime.
19
+ /// Used for the common + entry split-bundle loading strategy:
20
+ /// 1. RCTHost boots with common.jsbundle (polyfills + shared modules)
21
+ /// 2. After the runtime is ready, this evaluates the entry-specific bundle
22
+ /// (main.jsbundle or background.bundle) via jsi::Runtime::evaluateJavaScript.
23
+ ///
24
+ /// @param bundlePath Absolute filesystem path to the bundle file.
25
+ /// @param host The RCTHost whose runtime should evaluate the bundle.
26
+ + (void)loadEntryBundle:(NSString *)bundlePath inHost:(id)host;
27
+
18
28
  @end
@@ -1,6 +1,8 @@
1
1
  #import "SplitBundleLoader.h"
2
2
  #import "SBLLogger.h"
3
3
  #import <React/RCTBridge.h>
4
+ #import <objc/runtime.h>
5
+ #include <jsi/jsi.h>
4
6
 
5
7
  // Bridgeless (New Architecture) support: RCTHost segment registration
6
8
  @interface RCTHost (SplitBundle)
@@ -188,6 +190,45 @@
188
190
  }
189
191
  }
190
192
 
193
+ // MARK: - loadEntryBundle (common + entry split loading)
194
+
195
+ + (void)loadEntryBundle:(NSString *)bundlePath inHost:(id)host
196
+ {
197
+ if (!host || bundlePath.length == 0) {
198
+ [SBLLogger warn:[NSString stringWithFormat:@"loadEntryBundle: invalid arguments (host=%@, path=%@)", host, bundlePath]];
199
+ return;
200
+ }
201
+
202
+ Ivar ivar = class_getInstanceVariable([host class], "_instance");
203
+ if (!ivar) {
204
+ [SBLLogger warn:[NSString stringWithFormat:@"loadEntryBundle: _instance ivar not found on %@", [host class]]];
205
+ return;
206
+ }
207
+
208
+ id instance = object_getIvar(host, ivar);
209
+ if (!instance) {
210
+ [SBLLogger warn:@"loadEntryBundle: _instance is nil"];
211
+ return;
212
+ }
213
+
214
+ NSData *data = [NSData dataWithContentsOfFile:bundlePath];
215
+ if (!data || data.length == 0) {
216
+ [SBLLogger warn:[NSString stringWithFormat:@"loadEntryBundle: failed to read bundle at %@", bundlePath]];
217
+ return;
218
+ }
219
+
220
+ NSString *sourceURL = bundlePath.lastPathComponent ?: bundlePath;
221
+ [SBLLogger info:[NSString stringWithFormat:@"loadEntryBundle: evaluating %@ (%lu bytes)", sourceURL, (unsigned long)data.length]];
222
+
223
+ [instance callFunctionOnBufferedRuntimeExecutor:^(facebook::jsi::Runtime &runtime) {
224
+ @autoreleasepool {
225
+ auto buffer = std::make_shared<facebook::jsi::StringBuffer>(
226
+ std::string(static_cast<const char *>(data.bytes), data.length));
227
+ runtime.evaluateJavaScript(std::move(buffer), [sourceURL UTF8String]);
228
+ }
229
+ }];
230
+ }
231
+
191
232
  // MARK: - loadSegment
192
233
 
193
234
  - (void)loadSegment:(double)segmentId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-split-bundle-loader",
3
- "version": "1.1.51",
3
+ "version": "1.1.52",
4
4
  "description": "react-native-split-bundle-loader",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",