add "jsBundlesDirectory" method to RCTBridgeDelegate
Differential Revision: D6030185 fbshipit-source-id: 58d6f9d0d412c7ad0f83af9ae4df01c4dc1178bc
This commit is contained in:
parent
4192790f05
commit
dd400f842b
|
@ -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 @@ 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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue