diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index 5232e06f72a..8c89419471d 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -1215,6 +1215,7 @@ CF2731C11E7B8DE40044CA4F /* RCTDeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = CF2731BF1E7B8DE40044CA4F /* RCTDeviceInfo.m */; }; CF2731C21E7B8DEF0044CA4F /* RCTDeviceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CF2731BE1E7B8DE40044CA4F /* RCTDeviceInfo.h */; }; CF2731C31E7B8DF30044CA4F /* RCTDeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = CF2731BF1E7B8DE40044CA4F /* RCTDeviceInfo.m */; }; + E223624420875A8000108244 /* JSExecutor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E223624320875A8000108244 /* JSExecutor.cpp */; }; E9B20B7B1B500126007A2DA7 /* RCTAccessibilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E9B20B7A1B500126007A2DA7 /* RCTAccessibilityManager.m */; }; EBF21BBC1FC498270052F4D5 /* InspectorInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = EBF21BBA1FC498270052F4D5 /* InspectorInterfaces.h */; }; EBF21BBD1FC498270052F4D5 /* InspectorInterfaces.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBF21BBB1FC498270052F4D5 /* InspectorInterfaces.cpp */; }; @@ -2305,6 +2306,7 @@ C6D380191F71D75B00621378 /* RAMBundleRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RAMBundleRegistry.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 = ""; }; + E223624320875A8000108244 /* JSExecutor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSExecutor.cpp; sourceTree = ""; }; E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTTextDecorationLineType.h; sourceTree = ""; }; E9B20B791B500126007A2DA7 /* RCTAccessibilityManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAccessibilityManager.h; sourceTree = ""; }; E9B20B7A1B500126007A2DA7 /* RCTAccessibilityManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAccessibilityManager.m; sourceTree = ""; }; @@ -3034,6 +3036,7 @@ AC70D2EA1DE489FC002E6351 /* cxxreact */ = { isa = PBXGroup; children = ( + E223624320875A8000108244 /* JSExecutor.cpp */, 3D92B0A71E03699D0018521A /* CxxModule.h */, 3D92B0A81E03699D0018521A /* CxxNativeModule.cpp */, 3D92B0A91E03699D0018521A /* CxxNativeModule.h */, @@ -4440,6 +4443,7 @@ buildActionMask = 2147483647; files = ( 13134C9A1E296B2A00B9F3CB /* RCTCxxMethod.mm in Sources */, + E223624420875A8000108244 /* JSExecutor.cpp in Sources */, 59500D451F71C63F00B122B7 /* RCTUIManagerUtils.m in Sources */, 597633361F4E021D005BE8A4 /* RCTShadowView+Internal.m in Sources */, 13723B501A82FD3C00F88898 /* RCTStatusBarManager.m in Sources */, diff --git a/ReactCommon/cxxreact/Android.mk b/ReactCommon/cxxreact/Android.mk index 56ffdb1b3c5..1c22c761e6e 100644 --- a/ReactCommon/cxxreact/Android.mk +++ b/ReactCommon/cxxreact/Android.mk @@ -17,6 +17,7 @@ LOCAL_SRC_FILES := \ JSCSamplingProfiler.cpp \ JSCTracing.cpp \ JSCUtils.cpp \ + JSExecutor.cpp \ JSIndexedRAMBundle.cpp \ MethodCall.cpp \ ModuleRegistry.cpp \ diff --git a/ReactCommon/cxxreact/BUCK b/ReactCommon/cxxreact/BUCK index 8bf767e8289..14aa2e3c999 100644 --- a/ReactCommon/cxxreact/BUCK +++ b/ReactCommon/cxxreact/BUCK @@ -89,6 +89,7 @@ CXXREACT_PUBLIC_HEADERS = [ "JSExecutor.h", "JSCExecutor.h", "JSCNativeModules.h", + "JSCUtils.h", "JSIndexedRAMBundle.h", "JSModulesUnbundle.h", "MessageQueueThread.h", diff --git a/ReactCommon/cxxreact/JSCExecutor.cpp b/ReactCommon/cxxreact/JSCExecutor.cpp index a7d8c72cbf7..01a68fb4d5a 100644 --- a/ReactCommon/cxxreact/JSCExecutor.cpp +++ b/ReactCommon/cxxreact/JSCExecutor.cpp @@ -458,13 +458,16 @@ namespace facebook { m_bundleRegistry = std::move(bundleRegistry); } - void JSCExecutor::registerBundle(uint32_t bundleId, const std::string& bundlePath) { + void JSCExecutor::registerBundle( + uint32_t bundleId, + const std::string& bundlePath) { if (m_bundleRegistry) { m_bundleRegistry->registerBundle(bundleId, bundlePath); } else { - auto sourceUrl = String(m_context, bundlePath.c_str()); + auto stPath = JSCExecutor::getSyntheticBundlePath(bundleId, bundlePath); + auto sourceUrlStr = String(m_context, stPath.c_str()); auto source = adoptString(JSBigFileString::fromPath(bundlePath)); - evaluateScript(m_context, source, sourceUrl); + evaluateScript(m_context, source, sourceUrlStr); } } diff --git a/ReactCommon/cxxreact/JSCUtils.cpp b/ReactCommon/cxxreact/JSCUtils.cpp index 8681faa443f..45cc591bf76 100644 --- a/ReactCommon/cxxreact/JSCUtils.cpp +++ b/ReactCommon/cxxreact/JSCUtils.cpp @@ -2,6 +2,8 @@ #include "JSCUtils.h" +#include "RAMBundleRegistry.h" + #include namespace facebook { diff --git a/ReactCommon/cxxreact/JSExecutor.cpp b/ReactCommon/cxxreact/JSExecutor.cpp new file mode 100644 index 00000000000..9548f9664ac --- /dev/null +++ b/ReactCommon/cxxreact/JSExecutor.cpp @@ -0,0 +1,22 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#include "JSExecutor.h" + +#include "RAMBundleRegistry.h" + +#include + +namespace facebook { +namespace react { + +std::string JSExecutor::getSyntheticBundlePath( + uint32_t bundleId, + const std::string& bundlePath) { + if (bundleId == RAMBundleRegistry::MAIN_BUNDLE_ID) { + return bundlePath; + } + return folly::to("seg-", bundleId, ".js"); +} + +} +} diff --git a/ReactCommon/cxxreact/JSExecutor.h b/ReactCommon/cxxreact/JSExecutor.h index 85b4bfcb036..35338cd0876 100644 --- a/ReactCommon/cxxreact/JSExecutor.h +++ b/ReactCommon/cxxreact/JSExecutor.h @@ -101,6 +101,10 @@ public: virtual void destroy() {} virtual ~JSExecutor() {} + + static std::string getSyntheticBundlePath( + uint32_t bundleId, + const std::string& bundlePath); }; } }