// Copyright 2004-present Facebook. All Rights Reserved. #pragma once #include #include #include #include #include #include #include #ifndef RN_EXPORT #define RN_EXPORT __attribute__((visibility("default"))) #endif namespace facebook { namespace react { class RN_EXPORT RAMBundleRegistry : noncopyable { public: using unique_ram_bundle = std::unique_ptr; using bundle_path = std::string; constexpr static uint32_t MAIN_BUNDLE_ID = 0; static std::unique_ptr singleBundleRegistry(unique_ram_bundle mainBundle); static std::unique_ptr multipleBundlesRegistry(unique_ram_bundle mainBundle, std::function factory); RAMBundleRegistry(RAMBundleRegistry&&) = default; RAMBundleRegistry& operator=(RAMBundleRegistry&&) = default; void registerBundle(uint32_t bundleId, bundle_path bundlePath); JSModulesUnbundle::Module getModule(uint32_t bundleId, uint32_t moduleId); virtual ~RAMBundleRegistry() {}; private: explicit RAMBundleRegistry(unique_ram_bundle mainBundle, std::function factory = {}); JSModulesUnbundle *getBundle(uint32_t bundleId) const; std::function m_factory; std::unordered_map m_bundlePaths; std::unordered_map m_bundles; }; } // namespace react } // namespace facebook