20#include <TargetConditionals.h>
22#if !defined(TARGET_OS_IPHONE)
23#define TARGET_OS_IPHONE 0
27#include <choc/platform/choc_FileWatcher.h>
39#include <unordered_map>
61 const std::string& entry_file,
74 const std::filesystem::path&
watched_path()
const {
return watched_path_; }
98 std::filesystem::path watched_path_;
99 std::string entry_file_;
107 std::unique_ptr<choc::file::Watcher> watcher_;
112 mutable std::mutex hashes_mutex_;
113 std::unordered_map<std::string, std::uint64_t> observed_content_hashes_;
115 mutable std::mutex pending_mutex_;
116 std::string pending_code_;
117 bool has_pending_ =
false;
118 std::atomic<uint32_t> reload_count_{0};
121 void on_file_changed(
const choc::file::Watcher::Event& event);
123 std::optional<std::string> try_read_file(
const std::filesystem::path&
path);
124 std::string read_file(
const std::filesystem::path&
path);
125 void seed_observed_content_hashes();
126 static std::uint64_t content_hash(std::string_view content);
static constexpr bool kWatchesFiles
Definition hot_reload.hpp:54
HotReloader(const std::filesystem::path &js_file, ReloadCallback on_reload)
HotReloader & operator=(const HotReloader &)=delete
const std::filesystem::path & watched_path() const
Definition hot_reload.hpp:74
bool has_pending_reload() const
uint32_t reload_count() const
Definition hot_reload.hpp:77
HotReloader(const HotReloader &)=delete
bool should_reload_for_modified_file(const std::filesystem::path &path)
HotReloader(const std::filesystem::path &directory, const std::string &entry_file, ReloadCallback on_reload)
#define TARGET_OS_IPHONE
Definition hot_reload.hpp:23
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ path
Definition anchor_strategy.hpp:42
std::function< void(const std::string &code)> ReloadCallback
Definition hot_reload.hpp:44