add "jsBundlesDirectory" method to RCTBridgeDelegate

Differential Revision: D6030185

fbshipit-source-id: 58d6f9d0d412c7ad0f83af9ae4df01c4dc1178bc
This commit is contained in:
Alex Dvornikov
2017-10-12 12:30:24 -07:00
committed by Facebook Github Bot
parent 4192790f05
commit dd400f842b
4 changed files with 16 additions and 4 deletions

View File

@@ -121,4 +121,11 @@
- (void)loadSourceForBridge:(RCTBridge *)bridge
withBlock:(RCTSourceLoadBlock)loadCallback;
/**
* Specifies the path to folder where additional bundles are located
*
* @experimental
*/
- (NSURL *)jsBundlesDirectory;
@end

View File

@@ -1190,7 +1190,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
[self->_performanceLogger markStopForTag:RCTPLRAMBundleLoad];
[self->_performanceLogger setValue:scriptStr->size() forTag:RCTPLRAMStartupCodeSize];
if (self->_reactInstance) {
auto registry = std::make_unique<JSIndexedRAMBundleRegistry>(std::move(ramBundle), sourceUrlStr.UTF8String);
NSString *jsBundlesDirectory = [self.delegate respondsToSelector:@selector(jsBundlesDirectory)]
? [[self.delegate jsBundlesDirectory].path stringByAppendingString:@"/"]
: nil;
auto registry = jsBundlesDirectory != nil
? std::make_unique<JSIndexedRAMBundleRegistry>(std::move(ramBundle), jsBundlesDirectory.UTF8String)
: std::make_unique<RAMBundleRegistry>(std::move(ramBundle));
self->_reactInstance->loadRAMBundle(std::move(registry), std::move(scriptStr),
sourceUrlStr.UTF8String, !async);
}