2018-09-11 22:27:47 +00:00
|
|
|
// Copyright (c) Facebook, Inc. and its affiliates.
|
2018-05-31 22:31:03 +00:00
|
|
|
|
|
|
|
// This source code is licensed under the MIT license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree.
|
2016-05-04 02:29:58 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
#include <stdexcept>
|
|
|
|
|
2018-05-03 15:38:01 +00:00
|
|
|
#include <folly/Conv.h>
|
2016-05-04 02:29:58 +00:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
2018-05-10 05:01:34 +00:00
|
|
|
class JSModulesUnbundle {
|
2016-05-04 02:29:58 +00:00
|
|
|
/**
|
|
|
|
* Represents the set of JavaScript modules that the application consists of.
|
|
|
|
* The source code of each module can be retrieved by module ID.
|
|
|
|
*
|
|
|
|
* The class is non-copyable because copying instances might involve copying
|
|
|
|
* several megabytes of memory.
|
|
|
|
*/
|
|
|
|
public:
|
|
|
|
class ModuleNotFound : public std::out_of_range {
|
2018-05-03 15:38:01 +00:00
|
|
|
public:
|
2016-05-04 02:29:58 +00:00
|
|
|
using std::out_of_range::out_of_range;
|
2018-05-03 15:38:01 +00:00
|
|
|
ModuleNotFound(uint32_t moduleId) : std::out_of_range::out_of_range(
|
|
|
|
folly::to<std::string>("Module not found: ", moduleId)) {}
|
2016-05-04 02:29:58 +00:00
|
|
|
};
|
|
|
|
struct Module {
|
|
|
|
std::string name;
|
|
|
|
std::string code;
|
|
|
|
};
|
2018-05-10 05:01:34 +00:00
|
|
|
JSModulesUnbundle() {}
|
2016-05-04 02:29:58 +00:00
|
|
|
virtual ~JSModulesUnbundle() {}
|
|
|
|
virtual Module getModule(uint32_t moduleId) const = 0;
|
2018-05-10 05:01:34 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
JSModulesUnbundle(const JSModulesUnbundle&) = delete;
|
2016-05-04 02:29:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|