Permalink
Browse files

Added iOS support for loading multiple RAM bundles

Differential Revision: D5890466

fbshipit-source-id: e7805f90a7c446f5f75427c3fadcd133a3f7ad18
  • Loading branch information...
fromcelticpark authored and facebook-github-bot committed Sep 22, 2017
1 parent 7d11573 commit 7d2021ec49c7108f36b5c543cc8fd3211759644d
@@ -35,8 +35,8 @@
#import <cxxreact/JSBundleType.h>
#import <cxxreact/JSCExecutor.h>
#import <cxxreact/JSIndexedRAMBundle.h>
#include <cxxreact/JSIndexedRAMBundleRegistry.h>
#import <cxxreact/Platform.h>
#import <cxxreact/RAMBundleRegistry.h>
#import <jschelpers/Value.h>
#import "NSDataBigString.h"
@@ -1185,7 +1185,8 @@ - (void)executeApplicationScript:(NSData *)script
[self->_performanceLogger markStopForTag:RCTPLRAMBundleLoad];
[self->_performanceLogger setValue:scriptStr->size() forTag:RCTPLRAMStartupCodeSize];
if (self->_reactInstance) {
auto registry = std::make_unique<RAMBundleRegistry>(std::move(ramBundle));
std::string baseDirectoryPath = sourceUrlStr.stringByDeletingLastPathComponent.UTF8String;
auto registry = std::make_unique<JSIndexedRAMBundleRegistry>(std::move(ramBundle), baseDirectoryPath);
self->_reactInstance->loadRAMBundle(std::move(registry), std::move(scriptStr),
sourceUrlStr.UTF8String, !async);
}
@@ -1103,6 +1103,7 @@
C654505E1F3BD9280090799B /* RCTManagedPointer.h in Headers */ = {isa = PBXBuildFile; fileRef = C654505D1F3BD9280090799B /* RCTManagedPointer.h */; };
C654505F1F3BD9280090799B /* RCTManagedPointer.h in Headers */ = {isa = PBXBuildFile; fileRef = C654505D1F3BD9280090799B /* RCTManagedPointer.h */; };
C669D8981F72E3DE006748EB /* RAMBundleRegistry.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = C6D380181F71D75B00621378 /* RAMBundleRegistry.h */; };
C669D8B91F72E4B7006748EB /* JSIndexedRAMBundleRegistry.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */; };
C6827DF61EF17CCC00D66BEF /* RCTJSEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = C6827DF51EF17CCC00D66BEF /* RCTJSEnvironment.h */; };
C6827DF71EF17CCC00D66BEF /* RCTJSEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = C6827DF51EF17CCC00D66BEF /* RCTJSEnvironment.h */; };
C6827DFB1EF1800E00D66BEF /* RCTJSEnvironment.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = C6827DF51EF17CCC00D66BEF /* RCTJSEnvironment.h */; };
@@ -1111,6 +1112,10 @@
C6D3801B1F71D76200621378 /* RAMBundleRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = C6D380181F71D75B00621378 /* RAMBundleRegistry.h */; };
C6D3801C1F71D76700621378 /* RAMBundleRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D380191F71D75B00621378 /* RAMBundleRegistry.cpp */; };
C6D3801D1F71D76800621378 /* RAMBundleRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D380191F71D75B00621378 /* RAMBundleRegistry.cpp */; };
C6D380201F71D91D00621378 /* JSIndexedRAMBundleRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */; };
C6D380211F71D91E00621378 /* JSIndexedRAMBundleRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */; };
C6D380221F71D92300621378 /* JSIndexedRAMBundleRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D3801F1F71D91600621378 /* JSIndexedRAMBundleRegistry.cpp */; };
C6D380231F71D92400621378 /* JSIndexedRAMBundleRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D3801F1F71D91600621378 /* JSIndexedRAMBundleRegistry.cpp */; };
CF2731C01E7B8DE40044CA4F /* RCTDeviceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CF2731BE1E7B8DE40044CA4F /* RCTDeviceInfo.h */; };
CF2731C11E7B8DE40044CA4F /* RCTDeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = CF2731BF1E7B8DE40044CA4F /* RCTDeviceInfo.m */; };
CF2731C21E7B8DEF0044CA4F /* RCTDeviceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CF2731BE1E7B8DE40044CA4F /* RCTDeviceInfo.h */; };
@@ -1610,6 +1615,7 @@
dstPath = include/cxxreact;
dstSubfolderSpec = 16;
files = (
C669D8B91F72E4B7006748EB /* JSIndexedRAMBundleRegistry.h in Copy Headers */,
C669D8981F72E3DE006748EB /* RAMBundleRegistry.h in Copy Headers */,
3DA981A01E5B0E34004F2374 /* CxxModule.h in Copy Headers */,
3DA981A11E5B0E34004F2374 /* CxxNativeModule.h in Copy Headers */,
@@ -2106,6 +2112,8 @@
C6827DF51EF17CCC00D66BEF /* RCTJSEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTJSEnvironment.h; sourceTree = "<group>"; };
C6D380181F71D75B00621378 /* RAMBundleRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAMBundleRegistry.h; sourceTree = "<group>"; };
C6D380191F71D75B00621378 /* RAMBundleRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RAMBundleRegistry.cpp; sourceTree = "<group>"; };
C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSIndexedRAMBundleRegistry.h; sourceTree = "<group>"; };
C6D3801F1F71D91600621378 /* JSIndexedRAMBundleRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSIndexedRAMBundleRegistry.cpp; sourceTree = "<group>"; };
CF2731BE1E7B8DE40044CA4F /* RCTDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDeviceInfo.h; sourceTree = "<group>"; };
CF2731BF1E7B8DE40044CA4F /* RCTDeviceInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDeviceInfo.m; sourceTree = "<group>"; };
E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTTextDecorationLineType.h; sourceTree = "<group>"; };
@@ -2776,6 +2784,8 @@
3D92B0AB1E03699D0018521A /* JSExecutor.h */,
3D92B0C61E03699D0018521A /* JSIndexedRAMBundle.cpp */,
3D92B0C71E03699D0018521A /* JSIndexedRAMBundle.h */,
C6D3801F1F71D91600621378 /* JSIndexedRAMBundleRegistry.cpp */,
C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */,
3D92B0C81E03699D0018521A /* JSModulesUnbundle.h */,
3D92B0C91E03699D0018521A /* MessageQueueThread.h */,
3D92B0CA1E03699D0018521A /* MethodCall.cpp */,
@@ -3007,6 +3017,7 @@
27595AC61E575C7800CCE2B1 /* JsArgumentHelpers.h in Headers */,
27595AD71E575C7800CCE2B1 /* SampleCxxModule.h in Headers */,
27595AD21E575C7800CCE2B1 /* MethodCall.h in Headers */,
C6D380211F71D91E00621378 /* JSIndexedRAMBundleRegistry.h in Headers */,
3D3030221DF8294C00D6DDAE /* JSBundleType.h in Headers */,
27595ACA1E575C7800CCE2B1 /* JSCMemory.h in Headers */,
3D74547D1E54758900E74ADD /* JSBigString.h in Headers */,
@@ -3096,6 +3107,7 @@
27595AAB1E575C7800CCE2B1 /* JsArgumentHelpers.h in Headers */,
27595ABC1E575C7800CCE2B1 /* SampleCxxModule.h in Headers */,
27595AB71E575C7800CCE2B1 /* MethodCall.h in Headers */,
C6D380201F71D91D00621378 /* JSIndexedRAMBundleRegistry.h in Headers */,
3D3CD9471DE5FC7800167DC4 /* oss-compat-util.h in Headers */,
27595AAF1E575C7800CCE2B1 /* JSCMemory.h in Headers */,
3D74547C1E54758900E74ADD /* JSBigString.h in Headers */,
@@ -3958,6 +3970,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C6D380221F71D92300621378 /* JSIndexedRAMBundleRegistry.cpp in Sources */,
3DC159E51E83E1E9007B1282 /* JSBigString.cpp in Sources */,
13F8877B1E29726200C3C7A1 /* JSIndexedRAMBundle.cpp in Sources */,
13F8877D1E29726200C3C7A1 /* ModuleRegistry.cpp in Sources */,
@@ -3983,6 +3996,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C6D380231F71D92400621378 /* JSIndexedRAMBundleRegistry.cpp in Sources */,
3DC159E61E83E1FA007B1282 /* JSBigString.cpp in Sources */,
13F8878E1E29726300C3C7A1 /* JSIndexedRAMBundle.cpp in Sources */,
13F887901E29726300C3C7A1 /* ModuleRegistry.cpp in Sources */,
@@ -18,6 +18,7 @@ LOCAL_SRC_FILES := \
JSCTracing.cpp \
JSCUtils.cpp \
JSIndexedRAMBundle.cpp \
JSIndexedRAMBundleRegistry.cpp \
MethodCall.cpp \
ModuleRegistry.cpp \
NativeToJsBridge.cpp \
@@ -80,6 +80,7 @@ CXXREACT_PUBLIC_HEADERS = [
"JSCExecutor.h",
"JSCNativeModules.h",
"JSIndexedRAMBundle.h",
"JSIndexedRAMBundleRegistry.h",
"JSModulesUnbundle.h",
"MessageQueueThread.h",
"MethodCall.h",
@@ -3,7 +3,6 @@
#include "JSIndexedRAMBundle.h"
#include "oss-compat-util.h"
#include "JSBigString.h"
namespace facebook {
namespace react {
@@ -5,6 +5,7 @@
#include <fstream>
#include <memory>
#include <cxxreact/JSBigString.h>
#include <cxxreact/JSModulesUnbundle.h>
#ifndef RN_EXPORT
@@ -14,9 +15,6 @@
namespace facebook {
namespace react {
class JSBigString;
class JSBigBufferString;
class RN_EXPORT JSIndexedRAMBundle : public JSModulesUnbundle {
public:
// Throws std::runtime_error on failure.
@@ -0,0 +1,22 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include "JSIndexedRAMBundleRegistry.h"
#include <cxxreact/JSIndexedRAMBundle.h>
#include <folly/Memory.h>
#include "oss-compat-util.h"
namespace facebook {
namespace react {
std::unique_ptr<JSModulesUnbundle> JSIndexedRAMBundleRegistry::bundleById(uint32_t index) const {
return folly::make_unique<JSIndexedRAMBundle>(bundlePathById(index).c_str());
}
std::string JSIndexedRAMBundleRegistry::bundlePathById(uint32_t index) const {
return m_baseDirectoryPath + "/js-bundles/" + toString(index) + ".jsbundle";
}
} // namespace react
} // namespace facebook
@@ -0,0 +1,30 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include <cxxreact/RAMBundleRegistry.h>
#ifndef RN_EXPORT
#define RN_EXPORT __attribute__((visibility("default")))
#endif
namespace facebook {
namespace react {
class RN_EXPORT JSIndexedRAMBundleRegistry: public RAMBundleRegistry {
public:
JSIndexedRAMBundleRegistry(
std::unique_ptr<JSModulesUnbundle> mainBundle,
std::string baseDirectoryPath):
RAMBundleRegistry(std::move(mainBundle)), m_baseDirectoryPath(baseDirectoryPath) {}
protected:
virtual std::unique_ptr<JSModulesUnbundle> bundleById(uint32_t index) const override;
private:
std::string bundlePathById(uint32_t index) const;
std::string m_baseDirectoryPath;
};
} // namespace react
} // namespace facebook

0 comments on commit 7d2021e

Please sign in to comment.