react-native/ReactCommon/cxxreact/JSDeltaBundleClient.h

43 lines
1010 B
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include <cstdint>
#include <memory>
#include <string>
#include <unordered_map>
#include <cxxreact/JSBigString.h>
#include <cxxreact/JSModulesUnbundle.h>
#include <folly/dynamic.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_;
};
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_;
};
} // namespace react
} // namespace facebook