diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 535f22c1b39d1f..cf667c325e3567 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -35,8 +35,8 @@ #import #import #import +#include #import -#import #import #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(std::move(ramBundle)); + std::string baseDirectoryPath = sourceUrlStr.stringByDeletingLastPathComponent.UTF8String; + auto registry = std::make_unique(std::move(ramBundle), baseDirectoryPath); self->_reactInstance->loadRAMBundle(std::move(registry), std::move(scriptStr), sourceUrlStr.UTF8String, !async); } diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index f8aa22880287a0..b6677d57fe0d94 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -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 = ""; }; C6D380181F71D75B00621378 /* RAMBundleRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAMBundleRegistry.h; sourceTree = ""; }; C6D380191F71D75B00621378 /* RAMBundleRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RAMBundleRegistry.cpp; sourceTree = ""; }; + C6D3801E1F71D91600621378 /* JSIndexedRAMBundleRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSIndexedRAMBundleRegistry.h; sourceTree = ""; }; + C6D3801F1F71D91600621378 /* JSIndexedRAMBundleRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSIndexedRAMBundleRegistry.cpp; sourceTree = ""; }; CF2731BE1E7B8DE40044CA4F /* RCTDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDeviceInfo.h; sourceTree = ""; }; CF2731BF1E7B8DE40044CA4F /* RCTDeviceInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDeviceInfo.m; sourceTree = ""; }; E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTTextDecorationLineType.h; sourceTree = ""; }; @@ -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 */, diff --git a/ReactCommon/cxxreact/Android.mk b/ReactCommon/cxxreact/Android.mk index fae8dbaabba4e0..7e64ce3f91f1d3 100644 --- a/ReactCommon/cxxreact/Android.mk +++ b/ReactCommon/cxxreact/Android.mk @@ -18,6 +18,7 @@ LOCAL_SRC_FILES := \ JSCTracing.cpp \ JSCUtils.cpp \ JSIndexedRAMBundle.cpp \ + JSIndexedRAMBundleRegistry.cpp \ MethodCall.cpp \ ModuleRegistry.cpp \ NativeToJsBridge.cpp \ diff --git a/ReactCommon/cxxreact/BUCK b/ReactCommon/cxxreact/BUCK index 6b567cca03b7ec..4012972acd58cc 100644 --- a/ReactCommon/cxxreact/BUCK +++ b/ReactCommon/cxxreact/BUCK @@ -80,6 +80,7 @@ CXXREACT_PUBLIC_HEADERS = [ "JSCExecutor.h", "JSCNativeModules.h", "JSIndexedRAMBundle.h", + "JSIndexedRAMBundleRegistry.h", "JSModulesUnbundle.h", "MessageQueueThread.h", "MethodCall.h", diff --git a/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp b/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp index b5fc10dfbab015..1fb50627e1636c 100644 --- a/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp +++ b/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp @@ -3,7 +3,6 @@ #include "JSIndexedRAMBundle.h" #include "oss-compat-util.h" -#include "JSBigString.h" namespace facebook { namespace react { diff --git a/ReactCommon/cxxreact/JSIndexedRAMBundle.h b/ReactCommon/cxxreact/JSIndexedRAMBundle.h index 8898fe4edb252e..79e2587f30eeb8 100644 --- a/ReactCommon/cxxreact/JSIndexedRAMBundle.h +++ b/ReactCommon/cxxreact/JSIndexedRAMBundle.h @@ -5,6 +5,7 @@ #include #include +#include #include #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. diff --git a/ReactCommon/cxxreact/JSIndexedRAMBundleRegistry.cpp b/ReactCommon/cxxreact/JSIndexedRAMBundleRegistry.cpp new file mode 100644 index 00000000000000..92d1fdbfbb70c0 --- /dev/null +++ b/ReactCommon/cxxreact/JSIndexedRAMBundleRegistry.cpp @@ -0,0 +1,22 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#include "JSIndexedRAMBundleRegistry.h" + +#include +#include + +#include "oss-compat-util.h" + +namespace facebook { +namespace react { + +std::unique_ptr JSIndexedRAMBundleRegistry::bundleById(uint32_t index) const { + return folly::make_unique(bundlePathById(index).c_str()); +} + +std::string JSIndexedRAMBundleRegistry::bundlePathById(uint32_t index) const { + return m_baseDirectoryPath + "/js-bundles/" + toString(index) + ".jsbundle"; +} + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/cxxreact/JSIndexedRAMBundleRegistry.h b/ReactCommon/cxxreact/JSIndexedRAMBundleRegistry.h new file mode 100644 index 00000000000000..db3a189e87c428 --- /dev/null +++ b/ReactCommon/cxxreact/JSIndexedRAMBundleRegistry.h @@ -0,0 +1,30 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#pragma once + +#include + +#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 mainBundle, + std::string baseDirectoryPath): + RAMBundleRegistry(std::move(mainBundle)), m_baseDirectoryPath(baseDirectoryPath) {} + +protected: + virtual std::unique_ptr bundleById(uint32_t index) const override; +private: + std::string bundlePathById(uint32_t index) const; + + std::string m_baseDirectoryPath; +}; + +} // namespace react +} // namespace facebook