Skip to content

Commit 1aeb767

Browse files
fromcelticparkfacebook-github-bot
authored andcommitted
Added iOS support for loading multiple RAM bundles
Differential Revision: D5850970 fbshipit-source-id: 88ab6fe3822f1bc4195007f8ec83177a84c27569
1 parent 7982191 commit 1aeb767

File tree

8 files changed

+68
-6
lines changed

8 files changed

+68
-6
lines changed

React/CxxBridge/RCTCxxBridge.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#import <cxxreact/JSBundleType.h>
3636
#import <cxxreact/JSCExecutor.h>
3737
#import <cxxreact/JSIndexedRAMBundle.h>
38+
#include <cxxreact/JSIndexedRAMBundleRegistry.h>
3839
#import <cxxreact/Platform.h>
39-
#import <cxxreact/RAMBundleRegistry.h>
4040
#import <jschelpers/Value.h>
4141

4242
#import "NSDataBigString.h"
@@ -1185,7 +1185,8 @@ - (void)executeApplicationScript:(NSData *)script
11851185
[self->_performanceLogger markStopForTag:RCTPLRAMBundleLoad];
11861186
[self->_performanceLogger setValue:scriptStr->size() forTag:RCTPLRAMStartupCodeSize];
11871187
if (self->_reactInstance) {
1188-
auto registry = std::make_unique<RAMBundleRegistry>(std::move(ramBundle));
1188+
std::string baseDirectoryPath = sourceUrlStr.stringByDeletingLastPathComponent.UTF8String;
1189+
auto registry = std::make_unique<JSIndexedRAMBundleRegistry>(std::move(ramBundle), baseDirectoryPath);
11891190
self->_reactInstance->loadRAMBundle(std::move(registry), std::move(scriptStr),
11901191
sourceUrlStr.UTF8String, !async);
11911192
}

React/React.xcodeproj/project.pbxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@
11021102
C654505E1F3BD9280090799B /* RCTManagedPointer.h in Headers */ = {isa = PBXBuildFile; fileRef = C654505D1F3BD9280090799B /* RCTManagedPointer.h */; };
11031103
C654505F1F3BD9280090799B /* RCTManagedPointer.h in Headers */ = {isa = PBXBuildFile; fileRef = C654505D1F3BD9280090799B /* RCTManagedPointer.h */; };
11041104
C669D8981F72E3DE006748EB /* RAMBundleRegistry.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = C6D380181F71D75B00621378 /* RAMBundleRegistry.h */; };
1105+
C669D8B91F72E4B7006748EB /* JSIndexedRAMBundleRegistry.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */; };
11051106
C6827DF61EF17CCC00D66BEF /* RCTJSEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = C6827DF51EF17CCC00D66BEF /* RCTJSEnvironment.h */; };
11061107
C6827DF71EF17CCC00D66BEF /* RCTJSEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = C6827DF51EF17CCC00D66BEF /* RCTJSEnvironment.h */; };
11071108
C6827DFB1EF1800E00D66BEF /* RCTJSEnvironment.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = C6827DF51EF17CCC00D66BEF /* RCTJSEnvironment.h */; };
@@ -1110,6 +1111,10 @@
11101111
C6D3801B1F71D76200621378 /* RAMBundleRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = C6D380181F71D75B00621378 /* RAMBundleRegistry.h */; };
11111112
C6D3801C1F71D76700621378 /* RAMBundleRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D380191F71D75B00621378 /* RAMBundleRegistry.cpp */; };
11121113
C6D3801D1F71D76800621378 /* RAMBundleRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D380191F71D75B00621378 /* RAMBundleRegistry.cpp */; };
1114+
C6D380201F71D91D00621378 /* JSIndexedRAMBundleRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */; };
1115+
C6D380211F71D91E00621378 /* JSIndexedRAMBundleRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */; };
1116+
C6D380221F71D92300621378 /* JSIndexedRAMBundleRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D3801F1F71D91600621378 /* JSIndexedRAMBundleRegistry.cpp */; };
1117+
C6D380231F71D92400621378 /* JSIndexedRAMBundleRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D3801F1F71D91600621378 /* JSIndexedRAMBundleRegistry.cpp */; };
11131118
CF2731C01E7B8DE40044CA4F /* RCTDeviceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CF2731BE1E7B8DE40044CA4F /* RCTDeviceInfo.h */; };
11141119
CF2731C11E7B8DE40044CA4F /* RCTDeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = CF2731BF1E7B8DE40044CA4F /* RCTDeviceInfo.m */; };
11151120
CF2731C21E7B8DEF0044CA4F /* RCTDeviceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CF2731BE1E7B8DE40044CA4F /* RCTDeviceInfo.h */; };
@@ -1609,6 +1614,7 @@
16091614
dstPath = include/cxxreact;
16101615
dstSubfolderSpec = 16;
16111616
files = (
1617+
C669D8B91F72E4B7006748EB /* JSIndexedRAMBundleRegistry.h in Copy Headers */,
16121618
C669D8981F72E3DE006748EB /* RAMBundleRegistry.h in Copy Headers */,
16131619
3DA981A01E5B0E34004F2374 /* CxxModule.h in Copy Headers */,
16141620
3DA981A11E5B0E34004F2374 /* CxxNativeModule.h in Copy Headers */,
@@ -2103,6 +2109,8 @@
21032109
C6827DF51EF17CCC00D66BEF /* RCTJSEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTJSEnvironment.h; sourceTree = "<group>"; };
21042110
C6D380181F71D75B00621378 /* RAMBundleRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAMBundleRegistry.h; sourceTree = "<group>"; };
21052111
C6D380191F71D75B00621378 /* RAMBundleRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RAMBundleRegistry.cpp; sourceTree = "<group>"; };
2112+
C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSIndexedRAMBundleRegistry.h; sourceTree = "<group>"; };
2113+
C6D3801F1F71D91600621378 /* JSIndexedRAMBundleRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSIndexedRAMBundleRegistry.cpp; sourceTree = "<group>"; };
21062114
CF2731BE1E7B8DE40044CA4F /* RCTDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDeviceInfo.h; sourceTree = "<group>"; };
21072115
CF2731BF1E7B8DE40044CA4F /* RCTDeviceInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDeviceInfo.m; sourceTree = "<group>"; };
21082116
E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTTextDecorationLineType.h; sourceTree = "<group>"; };
@@ -2771,6 +2779,8 @@
27712779
3D92B0AB1E03699D0018521A /* JSExecutor.h */,
27722780
3D92B0C61E03699D0018521A /* JSIndexedRAMBundle.cpp */,
27732781
3D92B0C71E03699D0018521A /* JSIndexedRAMBundle.h */,
2782+
C6D3801F1F71D91600621378 /* JSIndexedRAMBundleRegistry.cpp */,
2783+
C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */,
27742784
3D92B0C81E03699D0018521A /* JSModulesUnbundle.h */,
27752785
3D92B0C91E03699D0018521A /* MessageQueueThread.h */,
27762786
3D92B0CA1E03699D0018521A /* MethodCall.cpp */,
@@ -3002,6 +3012,7 @@
30023012
27595AC61E575C7800CCE2B1 /* JsArgumentHelpers.h in Headers */,
30033013
27595AD71E575C7800CCE2B1 /* SampleCxxModule.h in Headers */,
30043014
27595AD21E575C7800CCE2B1 /* MethodCall.h in Headers */,
3015+
C6D380211F71D91E00621378 /* JSIndexedRAMBundleRegistry.h in Headers */,
30053016
3D3030221DF8294C00D6DDAE /* JSBundleType.h in Headers */,
30063017
27595ACA1E575C7800CCE2B1 /* JSCMemory.h in Headers */,
30073018
3D74547D1E54758900E74ADD /* JSBigString.h in Headers */,
@@ -3091,6 +3102,7 @@
30913102
27595AAB1E575C7800CCE2B1 /* JsArgumentHelpers.h in Headers */,
30923103
27595ABC1E575C7800CCE2B1 /* SampleCxxModule.h in Headers */,
30933104
27595AB71E575C7800CCE2B1 /* MethodCall.h in Headers */,
3105+
C6D380201F71D91D00621378 /* JSIndexedRAMBundleRegistry.h in Headers */,
30943106
3D3CD9471DE5FC7800167DC4 /* oss-compat-util.h in Headers */,
30953107
27595AAF1E575C7800CCE2B1 /* JSCMemory.h in Headers */,
30963108
3D74547C1E54758900E74ADD /* JSBigString.h in Headers */,
@@ -3953,6 +3965,7 @@
39533965
isa = PBXSourcesBuildPhase;
39543966
buildActionMask = 2147483647;
39553967
files = (
3968+
C6D380221F71D92300621378 /* JSIndexedRAMBundleRegistry.cpp in Sources */,
39563969
3DC159E51E83E1E9007B1282 /* JSBigString.cpp in Sources */,
39573970
13F8877B1E29726200C3C7A1 /* JSIndexedRAMBundle.cpp in Sources */,
39583971
13F8877D1E29726200C3C7A1 /* ModuleRegistry.cpp in Sources */,
@@ -3978,6 +3991,7 @@
39783991
isa = PBXSourcesBuildPhase;
39793992
buildActionMask = 2147483647;
39803993
files = (
3994+
C6D380231F71D92400621378 /* JSIndexedRAMBundleRegistry.cpp in Sources */,
39813995
3DC159E61E83E1FA007B1282 /* JSBigString.cpp in Sources */,
39823996
13F8878E1E29726300C3C7A1 /* JSIndexedRAMBundle.cpp in Sources */,
39833997
13F887901E29726300C3C7A1 /* ModuleRegistry.cpp in Sources */,

ReactCommon/cxxreact/Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ LOCAL_SRC_FILES := \
1818
JSCTracing.cpp \
1919
JSCUtils.cpp \
2020
JSIndexedRAMBundle.cpp \
21+
JSIndexedRAMBundleRegistry.cpp \
2122
MethodCall.cpp \
2223
ModuleRegistry.cpp \
2324
NativeToJsBridge.cpp \

ReactCommon/cxxreact/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ CXXREACT_PUBLIC_HEADERS = [
8080
"JSCExecutor.h",
8181
"JSCNativeModules.h",
8282
"JSIndexedRAMBundle.h",
83+
"JSIndexedRAMBundleRegistry.h",
8384
"JSModulesUnbundle.h",
8485
"MessageQueueThread.h",
8586
"MethodCall.h",

ReactCommon/cxxreact/JSIndexedRAMBundle.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "JSIndexedRAMBundle.h"
44

55
#include "oss-compat-util.h"
6-
#include "JSBigString.h"
76

87
namespace facebook {
98
namespace react {

ReactCommon/cxxreact/JSIndexedRAMBundle.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <fstream>
66
#include <memory>
77

8+
#include <cxxreact/JSBigString.h>
89
#include <cxxreact/JSModulesUnbundle.h>
910

1011
#ifndef RN_EXPORT
@@ -14,9 +15,6 @@
1415
namespace facebook {
1516
namespace react {
1617

17-
class JSBigString;
18-
class JSBigBufferString;
19-
2018
class RN_EXPORT JSIndexedRAMBundle : public JSModulesUnbundle {
2119
public:
2220
// Throws std::runtime_error on failure.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2004-present Facebook. All Rights Reserved.
2+
3+
#include "JSIndexedRAMBundleRegistry.h"
4+
5+
#include <cxxreact/JSIndexedRAMBundle.h>
6+
#include <folly/Memory.h>
7+
8+
#include "oss-compat-util.h"
9+
10+
namespace facebook {
11+
namespace react {
12+
13+
std::unique_ptr<JSModulesUnbundle> JSIndexedRAMBundleRegistry::bundleById(uint32_t index) const {
14+
return folly::make_unique<JSIndexedRAMBundle>(bundlePathById(index).c_str());
15+
}
16+
17+
std::string JSIndexedRAMBundleRegistry::bundlePathById(uint32_t index) const {
18+
return m_baseDirectoryPath + "/js-bundles/" + toString(index) + ".jsbundle";
19+
}
20+
21+
} // namespace react
22+
} // namespace facebook
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2004-present Facebook. All Rights Reserved.
2+
3+
#pragma once
4+
5+
#include <cxxreact/RAMBundleRegistry.h>
6+
7+
namespace facebook {
8+
namespace react {
9+
10+
class JSIndexedRAMBundleRegistry: public RAMBundleRegistry {
11+
public:
12+
JSIndexedRAMBundleRegistry(
13+
std::unique_ptr<JSModulesUnbundle> mainBundle,
14+
std::string baseDirectoryPath):
15+
RAMBundleRegistry(std::move(mainBundle)), m_baseDirectoryPath(baseDirectoryPath) {}
16+
17+
protected:
18+
virtual std::unique_ptr<JSModulesUnbundle> bundleById(uint32_t index) const override;
19+
private:
20+
std::string bundlePathById(uint32_t index) const;
21+
22+
std::string m_baseDirectoryPath;
23+
};
24+
25+
} // namespace react
26+
} // namespace facebook

0 commit comments

Comments
 (0)