Permalink
Browse files

add "jsBundlesDirectory" method to RCTBridgeDelegate

Differential Revision: D6030185

fbshipit-source-id: 58d6f9d0d412c7ad0f83af9ae4df01c4dc1178bc
  • Loading branch information...
fromcelticpark authored and facebook-github-bot committed Oct 12, 2017
1 parent 4192790 commit dd400f842b416b421d73ce3d308b73e26a5d3577
@@ -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
@@ -1190,7 +1190,12 @@ - (void)executeApplicationScript:(NSData *)script
[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);
}
@@ -10,8 +10,8 @@
namespace facebook {
namespace react {
JSIndexedRAMBundleRegistry::JSIndexedRAMBundleRegistry(std::unique_ptr<JSModulesUnbundle> mainBundle, const std::string& entryFile):
RAMBundleRegistry(std::move(mainBundle)), m_baseDirectoryPath(jsBundlesDir(entryFile)) {}
JSIndexedRAMBundleRegistry::JSIndexedRAMBundleRegistry(std::unique_ptr<JSModulesUnbundle> mainBundle, const std::string& baseDirectoryPath):
RAMBundleRegistry(std::move(mainBundle)), m_baseDirectoryPath(baseDirectoryPath) {}
std::unique_ptr<JSModulesUnbundle> JSIndexedRAMBundleRegistry::bundleById(uint32_t index) const {
std::string bundlePathById = m_baseDirectoryPath + toString(index) + ".jsbundle";
@@ -13,7 +13,7 @@ namespace react {
class RN_EXPORT JSIndexedRAMBundleRegistry: public RAMBundleRegistry {
public:
JSIndexedRAMBundleRegistry(std::unique_ptr<JSModulesUnbundle> mainBundle, const std::string& entryFile);
JSIndexedRAMBundleRegistry(std::unique_ptr<JSModulesUnbundle> mainBundle, const std::string& baseDirectoryPath);
protected:
virtual std::unique_ptr<JSModulesUnbundle> bundleById(uint32_t index) const override;

0 comments on commit dd400f8

Please sign in to comment.