Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <cxxreact/MethodCall.h>
#include <cxxreact/ModuleRegistry.h>
#include <cxxreact/RecoverableError.h>
// #include <cxxreact/RAMBundleRegistry.h>
#include <fb/log.h>
#include <fb/fbjni/ByteBuffer.h>
#include <folly/dynamic.h>
Expand Down
1 change: 0 additions & 1 deletion ReactCommon/cxxreact/Instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class JSBigString;
class JSExecutorFactory;
class MessageQueueThread;
class ModuleRegistry;
// class RAMBundleRegistry;

struct InstanceCallback {
virtual ~InstanceCallback() {}
Expand Down
165 changes: 83 additions & 82 deletions ReactCommon/cxxreact/JSDeltaBundleClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,88 +12,89 @@
namespace facebook {
namespace react {

namespace {
std::string startupCode(const folly::dynamic *pre, const folly::dynamic *post) {
std::ostringstream startupCode;

for (auto section : {pre, post}) {
if (section != nullptr) {
startupCode << section->getString() << '\n';
}
}

return startupCode.str();
}
} // namespace

void JSDeltaBundleClient::patchModules(const folly::dynamic *modules) {
for (const folly::dynamic pair : *modules) {
auto id = pair[0].getInt();
auto module = pair[1];
modules_[id] = std::move(module.getString());
}
}

void JSDeltaBundleClient::patch(const folly::dynamic& delta) {
auto const base = delta.get_ptr("base");

if (base != nullptr && base->asBool()) {
clear();

auto const pre = delta.get_ptr("pre");
auto const post = delta.get_ptr("post");

startupCode_ = startupCode(pre, post);

const folly::dynamic *modules = delta.get_ptr("modules");
if (modules != nullptr) {
patchModules(modules);
}
} else {
const folly::dynamic *deleted = delta.get_ptr("deleted");
if (deleted != nullptr) {
for (const folly::dynamic id : *deleted) {
modules_.erase(id.getInt());
}
}

// TODO T37123645 This is deprecated but necessary in order to support older
// versions of the Metro server.
const folly::dynamic *modules = delta.get_ptr("modules");
if (modules != nullptr) {
patchModules(modules);
}

const folly::dynamic *added = delta.get_ptr("added");
if (added != nullptr) {
patchModules(added);
}

const folly::dynamic *modified = delta.get_ptr("modified");
if (modified != nullptr) {
patchModules(modified);
}
}

}

JSModulesUnbundle::Module JSDeltaBundleClient::getModule(uint32_t moduleId) const {
auto search = modules_.find(moduleId);
if (search != modules_.end()) {
return {folly::to<std::string>(search->first, ".js"), search->second};
}

throw JSModulesUnbundle::ModuleNotFound(moduleId);
}

std::unique_ptr<const JSBigString> JSDeltaBundleClient::getStartupCode() const {
return folly::make_unique<JSBigStdString>(startupCode_);
}

void JSDeltaBundleClient::clear() {
modules_.clear();
startupCode_.clear();
}
// TODO: refactor
// namespace {
// std::string startupCode(const folly::dynamic *pre, const folly::dynamic *post) {
// std::ostringstream startupCode;

// for (auto section : {pre, post}) {
// if (section != nullptr) {
// startupCode << section->getString() << '\n';
// }
// }

// return startupCode.str();
// }
// } // namespace

// void JSDeltaBundleClient::patchModules(const folly::dynamic *modules) {
// for (const folly::dynamic pair : *modules) {
// auto id = pair[0].getInt();
// auto module = pair[1];
// modules_[id] = std::move(module.getString());
// }
// }

// void JSDeltaBundleClient::patch(const folly::dynamic& delta) {
// auto const base = delta.get_ptr("base");

// if (base != nullptr && base->asBool()) {
// clear();

// auto const pre = delta.get_ptr("pre");
// auto const post = delta.get_ptr("post");

// startupCode_ = startupCode(pre, post);

// const folly::dynamic *modules = delta.get_ptr("modules");
// if (modules != nullptr) {
// patchModules(modules);
// }
// } else {
// const folly::dynamic *deleted = delta.get_ptr("deleted");
// if (deleted != nullptr) {
// for (const folly::dynamic id : *deleted) {
// modules_.erase(id.getInt());
// }
// }

// // TODO T37123645 This is deprecated but necessary in order to support older
// // versions of the Metro server.
// const folly::dynamic *modules = delta.get_ptr("modules");
// if (modules != nullptr) {
// patchModules(modules);
// }

// const folly::dynamic *added = delta.get_ptr("added");
// if (added != nullptr) {
// patchModules(added);
// }

// const folly::dynamic *modified = delta.get_ptr("modified");
// if (modified != nullptr) {
// patchModules(modified);
// }
// }

// }

// RAMBundle::Module JSDeltaBundleClient::getModule(uint32_t moduleId) const {
// auto search = modules_.find(moduleId);
// if (search != modules_.end()) {
// return {folly::to<std::string>(search->first, ".js"), search->second};
// }

// throw RAMBundle::ModuleNotFound(moduleId);
// }

// std::unique_ptr<const JSBigString> JSDeltaBundleClient::getStartupCode() const {
// return folly::make_unique<JSBigStdString>(startupCode_);
// }

// void JSDeltaBundleClient::clear() {
// modules_.clear();
// startupCode_.clear();
// }

} // namespace react
} // namespace facebook
56 changes: 28 additions & 28 deletions ReactCommon/cxxreact/JSDeltaBundleClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,39 @@
#include <memory>
#include <string>
#include <unordered_map>

#include <cxxreact/JSBigString.h>
#include <cxxreact/JSModulesUnbundle.h>
#include <folly/dynamic.h>
#include "JSBigString.h"
#include "RAMBundle.h"

namespace facebook {
namespace react {

class JSDeltaBundleClient {
public:
void patch(const folly::dynamic& delta);
JSModulesUnbundle::Module getModule(uint32_t moduleId) const;
std::unique_ptr<const JSBigString> getStartupCode() const;
void clear();

private:
std::unordered_map<uint32_t, std::string> modules_;
std::string startupCode_;

void patchModules(const folly::dynamic *delta);
};

class JSDeltaBundleClientRAMBundle : public JSModulesUnbundle {
public:
JSDeltaBundleClientRAMBundle(
std::shared_ptr<const JSDeltaBundleClient> client) : client_(client) {}

Module getModule(uint32_t moduleId) const override {
return client_->getModule(moduleId);
}
private:
const std::shared_ptr<const JSDeltaBundleClient> client_;
};
// TODO: refactor
// class JSDeltaBundleClient {
// public:
// void patch(const folly::dynamic& delta);
// RAMBundle::Module getModule(uint32_t moduleId) const;
// std::unique_ptr<const JSBigString> getStartupCode() const;
// void clear();

// private:
// std::unordered_map<uint32_t, std::string> modules_;
// std::string startupCode_;

// void patchModules(const folly::dynamic *delta);
// };

// class JSDeltaBundleClientRAMBundle : public JSModulesUnbundle {
// public:
// JSDeltaBundleClientRAMBundle(
// std::shared_ptr<const JSDeltaBundleClient> client) : client_(client) {}

// RAMBundle::Module getModule(uint32_t moduleId) const override {
// return client_->getModule(moduleId);
// }
// private:
// const std::shared_ptr<const JSDeltaBundleClient> client_;
// };

} // namespace react
} // namespace facebook
25 changes: 0 additions & 25 deletions ReactCommon/cxxreact/JSExecutor.cpp

This file was deleted.

5 changes: 0 additions & 5 deletions ReactCommon/cxxreact/JSExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class JSBigString;
class JSExecutor;
class MessageQueueThread;
class ModuleRegistry;
class RAMBundleRegistry;

// This interface describes the delegate interface required by
// Executor implementations to call from JS into native code.
Expand Down Expand Up @@ -105,10 +104,6 @@ class RN_EXPORT JSExecutor {

virtual void destroy() {}
virtual ~JSExecutor() {}

static std::string getSyntheticBundlePath(
uint32_t bundleId,
const std::string& bundlePath);
};

} }
45 changes: 0 additions & 45 deletions ReactCommon/cxxreact/JSModulesUnbundle.h

This file was deleted.

1 change: 0 additions & 1 deletion ReactCommon/cxxreact/NativeToJsBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "MethodCall.h"
#include "MessageQueueThread.h"
#include "ModuleRegistry.h"
#include "RAMBundleRegistry.h"

#ifdef WITH_FBSYSTRACE
#include <fbsystrace.h>
Expand Down
1 change: 0 additions & 1 deletion ReactCommon/cxxreact/NativeToJsBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ struct InstanceCallback;
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
Expand Down
Loading