Revert D5850968: Configure JSExector with BundleRegistry instead of JSModulesUnbundle.
Differential Revision: D5850968 fbshipit-source-id: f4c9dc8d5f14cdd32195463e8786242e708770e9
This commit is contained in:
parent
526fd6b931
commit
0aa12939fd
|
@ -36,7 +36,6 @@
|
|||
#import <cxxreact/JSCExecutor.h>
|
||||
#import <cxxreact/JSIndexedRAMBundle.h>
|
||||
#import <cxxreact/Platform.h>
|
||||
#import <cxxreact/RAMBundleRegistry.h>
|
||||
#import <jschelpers/Value.h>
|
||||
|
||||
#import "NSDataBigString.h"
|
||||
|
@ -1185,9 +1184,8 @@ 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<RAMBundleRegistry>(std::move(ramBundle));
|
||||
self->_reactInstance->loadRAMBundle(std::move(registry), std::move(scriptStr),
|
||||
sourceUrlStr.UTF8String, !async);
|
||||
self->_reactInstance->loadUnbundle(std::move(ramBundle), std::move(scriptStr),
|
||||
sourceUrlStr.UTF8String, !async);
|
||||
}
|
||||
} else if (self->_reactInstance) {
|
||||
self->_reactInstance->loadScriptFromString(std::make_unique<NSDataBigString>(script),
|
||||
|
|
|
@ -91,8 +91,8 @@ public:
|
|||
}];
|
||||
}
|
||||
|
||||
void setBundleRegistry(std::unique_ptr<RAMBundleRegistry>) override {
|
||||
RCTAssert(NO, @"RAM bundles are not supported in RCTObjcExecutor");
|
||||
void setJSModulesUnbundle(std::unique_ptr<JSModulesUnbundle>) override {
|
||||
RCTAssert(NO, @"Unbundle is not supported in RCTObjcExecutor");
|
||||
}
|
||||
|
||||
void callFunction(const std::string &module, const std::string &method,
|
||||
|
|
|
@ -1102,7 +1102,6 @@
|
|||
C6194AB11EF156280034D062 /* RCTPackagerConnectionConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = C6194AAB1EF156280034D062 /* RCTPackagerConnectionConfig.h */; };
|
||||
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 */; };
|
||||
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 */; };
|
||||
|
@ -1610,7 +1609,6 @@
|
|||
dstPath = include/cxxreact;
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
C669D8981F72E3DE006748EB /* RAMBundleRegistry.h in Copy Headers */,
|
||||
3DA981A01E5B0E34004F2374 /* CxxModule.h in Copy Headers */,
|
||||
3DA981A11E5B0E34004F2374 /* CxxNativeModule.h in Copy Headers */,
|
||||
3DA981A21E5B0E34004F2374 /* JSExecutor.h in Copy Headers */,
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <cxxreact/MethodCall.h>
|
||||
#include <cxxreact/RecoverableError.h>
|
||||
#include <cxxreact/ModuleRegistry.h>
|
||||
#include <cxxreact/RAMBundleRegistry.h>
|
||||
#include <fb/log.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <folly/Memory.h>
|
||||
|
@ -186,10 +185,8 @@ void CatalystInstanceImpl::jniLoadScriptFromAssets(
|
|||
auto manager = extractAssetManager(assetManager);
|
||||
auto script = loadScriptFromAssets(manager, sourceURL);
|
||||
if (JniJSModulesUnbundle::isUnbundle(manager, sourceURL)) {
|
||||
auto bundle = folly::make_unique<JniJSModulesUnbundle>(manager, sourceURL);
|
||||
auto registry = folly::make_unique<RAMBundleRegistry>(std::move(bundle));
|
||||
instance_->loadRAMBundle(
|
||||
std::move(registry),
|
||||
instance_->loadUnbundle(
|
||||
folly::make_unique<JniJSModulesUnbundle>(manager, sourceURL),
|
||||
std::move(script),
|
||||
sourceURL,
|
||||
loadSynchronously);
|
||||
|
@ -217,9 +214,8 @@ void CatalystInstanceImpl::jniLoadScriptFromFile(const std::string& fileName,
|
|||
if (isIndexedRAMBundle(zFileName)) {
|
||||
auto bundle = folly::make_unique<JSIndexedRAMBundle>(zFileName);
|
||||
auto startupScript = bundle->getStartupCode();
|
||||
auto registry = folly::make_unique<RAMBundleRegistry>(std::move(bundle));
|
||||
instance_->loadRAMBundle(
|
||||
std::move(registry),
|
||||
instance_->loadUnbundle(
|
||||
std::move(bundle),
|
||||
std::move(startupScript),
|
||||
sourceURL,
|
||||
loadSynchronously);
|
||||
|
|
|
@ -84,10 +84,10 @@ void ProxyExecutor::loadApplicationScript(
|
|||
// we launch the application.
|
||||
}
|
||||
|
||||
void ProxyExecutor::setBundleRegistry(std::unique_ptr<RAMBundleRegistry>) {
|
||||
void ProxyExecutor::setJSModulesUnbundle(std::unique_ptr<JSModulesUnbundle>) {
|
||||
jni::throwNewJavaException(
|
||||
"java/lang/UnsupportedOperationException",
|
||||
"Loading application RAM bundles is not supported for proxy executors");
|
||||
"Loading application unbundles is not supported for proxy executors");
|
||||
}
|
||||
|
||||
void ProxyExecutor::callFunction(const std::string& moduleId, const std::string& methodId, const folly::dynamic& arguments) {
|
||||
|
|
|
@ -35,8 +35,8 @@ public:
|
|||
virtual void loadApplicationScript(
|
||||
std::unique_ptr<const JSBigString> script,
|
||||
std::string sourceURL) override;
|
||||
virtual void setBundleRegistry(
|
||||
std::unique_ptr<RAMBundleRegistry> bundle) override;
|
||||
virtual void setJSModulesUnbundle(
|
||||
std::unique_ptr<JSModulesUnbundle> bundle) override;
|
||||
virtual void callFunction(
|
||||
const std::string& moduleId,
|
||||
const std::string& methodId,
|
||||
|
|
|
@ -87,7 +87,6 @@ CXXREACT_PUBLIC_HEADERS = [
|
|||
"NativeModule.h",
|
||||
"NativeToJsBridge.h",
|
||||
"Platform.h",
|
||||
"RAMBundleRegistry.h",
|
||||
"RecoverableError.h",
|
||||
"SharedProxyCxxModule.h",
|
||||
"SystraceSection.h",
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
#include "JSBigString.h"
|
||||
#include "JSExecutor.h"
|
||||
#include "JSModulesUnbundle.h"
|
||||
#include "MessageQueueThread.h"
|
||||
#include "MethodCall.h"
|
||||
#include "NativeToJsBridge.h"
|
||||
#include "RAMBundleRegistry.h"
|
||||
#include "RecoverableError.h"
|
||||
#include "SystraceSection.h"
|
||||
|
||||
|
@ -50,17 +50,17 @@ void Instance::initializeBridge(
|
|||
CHECK(nativeToJsBridge_);
|
||||
}
|
||||
|
||||
void Instance::loadApplication(std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
void Instance::loadApplication(std::unique_ptr<JSModulesUnbundle> unbundle,
|
||||
std::unique_ptr<const JSBigString> string,
|
||||
std::string sourceURL) {
|
||||
callback_->incrementPendingJSCalls();
|
||||
SystraceSection s("Instance::loadApplication", "sourceURL",
|
||||
sourceURL);
|
||||
nativeToJsBridge_->loadApplication(std::move(bundleRegistry), std::move(string),
|
||||
nativeToJsBridge_->loadApplication(std::move(unbundle), std::move(string),
|
||||
std::move(sourceURL));
|
||||
}
|
||||
|
||||
void Instance::loadApplicationSync(std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
void Instance::loadApplicationSync(std::unique_ptr<JSModulesUnbundle> unbundle,
|
||||
std::unique_ptr<const JSBigString> string,
|
||||
std::string sourceURL) {
|
||||
std::unique_lock<std::mutex> lock(m_syncMutex);
|
||||
|
@ -68,7 +68,7 @@ void Instance::loadApplicationSync(std::unique_ptr<RAMBundleRegistry> bundleRegi
|
|||
|
||||
SystraceSection s("Instance::loadApplicationSync", "sourceURL",
|
||||
sourceURL);
|
||||
nativeToJsBridge_->loadApplicationSync(std::move(bundleRegistry), std::move(string),
|
||||
nativeToJsBridge_->loadApplicationSync(std::move(unbundle), std::move(string),
|
||||
std::move(sourceURL));
|
||||
}
|
||||
|
||||
|
@ -91,15 +91,15 @@ void Instance::loadScriptFromString(std::unique_ptr<const JSBigString> string,
|
|||
}
|
||||
}
|
||||
|
||||
void Instance::loadRAMBundle(std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
std::unique_ptr<const JSBigString> startupScript,
|
||||
std::string startupScriptSourceURL,
|
||||
bool loadSynchronously) {
|
||||
void Instance::loadUnbundle(std::unique_ptr<JSModulesUnbundle> unbundle,
|
||||
std::unique_ptr<const JSBigString> startupScript,
|
||||
std::string startupScriptSourceURL,
|
||||
bool loadSynchronously) {
|
||||
if (loadSynchronously) {
|
||||
loadApplicationSync(std::move(bundleRegistry), std::move(startupScript),
|
||||
loadApplicationSync(std::move(unbundle), std::move(startupScript),
|
||||
std::move(startupScriptSourceURL));
|
||||
} else {
|
||||
loadApplication(std::move(bundleRegistry), std::move(startupScript),
|
||||
loadApplication(std::move(unbundle), std::move(startupScript),
|
||||
std::move(startupScriptSourceURL));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ namespace react {
|
|||
|
||||
class JSBigString;
|
||||
class JSExecutorFactory;
|
||||
class JSModulesUnbundle;
|
||||
class MessageQueueThread;
|
||||
class ModuleRegistry;
|
||||
class RAMBundleRegistry;
|
||||
|
||||
struct InstanceCallback {
|
||||
virtual ~InstanceCallback() {}
|
||||
|
@ -44,9 +44,9 @@ public:
|
|||
|
||||
void loadScriptFromString(std::unique_ptr<const JSBigString> string,
|
||||
std::string sourceURL, bool loadSynchronously);
|
||||
void loadRAMBundle(std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
std::unique_ptr<const JSBigString> startupScript,
|
||||
std::string startupScriptSourceURL, bool loadSynchronously);
|
||||
void loadUnbundle(std::unique_ptr<JSModulesUnbundle> unbundle,
|
||||
std::unique_ptr<const JSBigString> startupScript,
|
||||
std::string startupScriptSourceURL, bool loadSynchronously);
|
||||
bool supportsProfiling();
|
||||
void setGlobalVariable(std::string propName,
|
||||
std::unique_ptr<const JSBigString> jsonValue);
|
||||
|
@ -73,10 +73,10 @@ public:
|
|||
|
||||
private:
|
||||
void callNativeModules(folly::dynamic &&calls, bool isEndOfBatch);
|
||||
void loadApplication(std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
void loadApplication(std::unique_ptr<JSModulesUnbundle> unbundle,
|
||||
std::unique_ptr<const JSBigString> startupScript,
|
||||
std::string startupScriptSourceURL);
|
||||
void loadApplicationSync(std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
void loadApplicationSync(std::unique_ptr<JSModulesUnbundle> unbundle,
|
||||
std::unique_ptr<const JSBigString> startupScript,
|
||||
std::string startupScriptSourceURL);
|
||||
|
||||
|
|
|
@ -354,11 +354,11 @@ void JSCExecutor::loadApplicationScript(std::unique_ptr<const JSBigString> scrip
|
|||
ReactMarker::logTaggedMarker(ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str());
|
||||
}
|
||||
|
||||
void JSCExecutor::setBundleRegistry(std::unique_ptr<RAMBundleRegistry> bundleRegistry) {
|
||||
void JSCExecutor::setJSModulesUnbundle(std::unique_ptr<JSModulesUnbundle> unbundle) {
|
||||
if (!m_bundleRegistry) {
|
||||
installNativeHook<&JSCExecutor::nativeRequire>("nativeRequire");
|
||||
}
|
||||
m_bundleRegistry = std::move(bundleRegistry);
|
||||
m_bundleRegistry = folly::make_unique<RAMBundleRegistry>(std::move(unbundle));
|
||||
}
|
||||
|
||||
void JSCExecutor::bindBridge() throw(JSException) {
|
||||
|
|
|
@ -65,7 +65,8 @@ public:
|
|||
std::unique_ptr<const JSBigString> script,
|
||||
std::string sourceURL) override;
|
||||
|
||||
virtual void setBundleRegistry(std::unique_ptr<RAMBundleRegistry> bundleRegistry) override;
|
||||
virtual void setJSModulesUnbundle(
|
||||
std::unique_ptr<JSModulesUnbundle> unbundle) override;
|
||||
|
||||
virtual void callFunction(
|
||||
const std::string& moduleId,
|
||||
|
|
|
@ -16,7 +16,6 @@ class JSExecutor;
|
|||
class JSModulesUnbundle;
|
||||
class MessageQueueThread;
|
||||
class ModuleRegistry;
|
||||
class RAMBundleRegistry;
|
||||
|
||||
// This interface describes the delegate interface required by
|
||||
// Executor implementations to call from JS into native code.
|
||||
|
@ -49,9 +48,9 @@ public:
|
|||
std::string sourceURL) = 0;
|
||||
|
||||
/**
|
||||
* Add an application "RAM" bundle registry
|
||||
* Add an application "unbundle" file
|
||||
*/
|
||||
virtual void setBundleRegistry(std::unique_ptr<RAMBundleRegistry> bundleRegistry) = 0;
|
||||
virtual void setJSModulesUnbundle(std::unique_ptr<JSModulesUnbundle> bundle) = 0;
|
||||
|
||||
/**
|
||||
* Executes BatchedBridge.callFunctionReturnFlushedQueue with the module ID,
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "JSBigString.h"
|
||||
#include "SystraceSection.h"
|
||||
#include "MethodCall.h"
|
||||
#include "JSModulesUnbundle.h"
|
||||
#include "MessageQueueThread.h"
|
||||
#include "RAMBundleRegistry.h"
|
||||
|
||||
#ifdef WITH_FBSYSTRACE
|
||||
#include <fbsystrace.h>
|
||||
|
@ -91,17 +91,17 @@ NativeToJsBridge::~NativeToJsBridge() {
|
|||
}
|
||||
|
||||
void NativeToJsBridge::loadApplication(
|
||||
std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
std::unique_ptr<JSModulesUnbundle> unbundle,
|
||||
std::unique_ptr<const JSBigString> startupScript,
|
||||
std::string startupScriptSourceURL) {
|
||||
runOnExecutorQueue(
|
||||
[bundleRegistryWrap=folly::makeMoveWrapper(std::move(bundleRegistry)),
|
||||
[unbundleWrap=folly::makeMoveWrapper(std::move(unbundle)),
|
||||
startupScript=folly::makeMoveWrapper(std::move(startupScript)),
|
||||
startupScriptSourceURL=std::move(startupScriptSourceURL)]
|
||||
(JSExecutor* executor) mutable {
|
||||
auto bundleRegistry = bundleRegistryWrap.move();
|
||||
if (bundleRegistry) {
|
||||
executor->setBundleRegistry(std::move(bundleRegistry));
|
||||
auto unbundle = unbundleWrap.move();
|
||||
if (unbundle) {
|
||||
executor->setJSModulesUnbundle(std::move(unbundle));
|
||||
}
|
||||
executor->loadApplicationScript(std::move(*startupScript),
|
||||
std::move(startupScriptSourceURL));
|
||||
|
@ -109,11 +109,11 @@ void NativeToJsBridge::loadApplication(
|
|||
}
|
||||
|
||||
void NativeToJsBridge::loadApplicationSync(
|
||||
std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
std::unique_ptr<JSModulesUnbundle> unbundle,
|
||||
std::unique_ptr<const JSBigString> startupScript,
|
||||
std::string startupScriptSourceURL) {
|
||||
if (bundleRegistry) {
|
||||
m_executor->setBundleRegistry(std::move(bundleRegistry));
|
||||
if (unbundle) {
|
||||
m_executor->setJSModulesUnbundle(std::move(unbundle));
|
||||
}
|
||||
m_executor->loadApplicationScript(std::move(startupScript),
|
||||
std::move(startupScriptSourceURL));
|
||||
|
|
|
@ -18,10 +18,10 @@ namespace facebook {
|
|||
namespace react {
|
||||
|
||||
struct InstanceCallback;
|
||||
class JSModulesUnbundle;
|
||||
class JsToNativeBridge;
|
||||
class MessageQueueThread;
|
||||
class ModuleRegistry;
|
||||
class RAMBundleRegistry;
|
||||
|
||||
// This class manages calls from native code to JS. It also manages
|
||||
// executors and their threads. All functions here can be called from
|
||||
|
@ -85,16 +85,16 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Starts the JS application. If bundleRegistry is non-null, then it is
|
||||
* Starts the JS application. If unbundle is non-null, then it is
|
||||
* used to fetch JavaScript modules as individual scripts.
|
||||
* Otherwise, the script is assumed to include all the modules.
|
||||
*/
|
||||
void loadApplication(
|
||||
std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
std::unique_ptr<JSModulesUnbundle> unbundle,
|
||||
std::unique_ptr<const JSBigString> startupCode,
|
||||
std::string sourceURL);
|
||||
void loadApplicationSync(
|
||||
std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
||||
std::unique_ptr<JSModulesUnbundle> unbundle,
|
||||
std::unique_ptr<const JSBigString> startupCode,
|
||||
std::string sourceURL);
|
||||
|
||||
|
|
|
@ -12,10 +12,6 @@ RAMBundleRegistry::RAMBundleRegistry(std::unique_ptr<JSModulesUnbundle> mainBund
|
|||
}
|
||||
|
||||
JSModulesUnbundle::Module RAMBundleRegistry::getModule(uint32_t bundleId, uint32_t moduleId) {
|
||||
if (m_bundles.find(bundleId) == m_bundles.end()) {
|
||||
m_bundles.emplace(bundleId, this->bundleById(bundleId));
|
||||
}
|
||||
|
||||
return getBundle(bundleId)->getModule(moduleId);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,25 +8,16 @@
|
|||
#include <utility>
|
||||
|
||||
#include <cxxreact/JSModulesUnbundle.h>
|
||||
#include <jschelpers/noncopyable.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class RAMBundleRegistry : noncopyable {
|
||||
class RAMBundleRegistry {
|
||||
public:
|
||||
constexpr static uint32_t MAIN_BUNDLE_ID = 0;
|
||||
|
||||
explicit RAMBundleRegistry(std::unique_ptr<JSModulesUnbundle> mainBundle);
|
||||
RAMBundleRegistry(RAMBundleRegistry&&) = default;
|
||||
RAMBundleRegistry& operator=(RAMBundleRegistry&&) = default;
|
||||
|
||||
JSModulesUnbundle::Module getModule(uint32_t bundleId, uint32_t moduleId);
|
||||
virtual ~RAMBundleRegistry() {};
|
||||
protected:
|
||||
virtual std::unique_ptr<JSModulesUnbundle> bundleById(uint32_t index) const {
|
||||
throw std::runtime_error("Please, override this method in a subclass to support multiple RAM bundles.");
|
||||
}
|
||||
private:
|
||||
JSModulesUnbundle *getBundle(uint32_t bundleId) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue