mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Add Bun.canReload event to inspector
This commit is contained in:
@@ -452,6 +452,21 @@ extern "C" void Bun__ensureDebugger(ScriptExecutionContextIdentifier scriptId, b
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void BunDebugger__willHotReload() {
|
||||
if (debuggerScriptExecutionContext == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
debuggerScriptExecutionContext->postTaskConcurrently([](ScriptExecutionContext &context){
|
||||
WTF::LockHolder locker(inspectorConnectionsLock);
|
||||
for (auto& connections : *inspectorConnections) {
|
||||
for (auto* connection : connections.value) {
|
||||
connection->sendMessageToFrontend("{\"method\":\"Bun.canReload\"}"_s);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(jsFunctionCreateConnection, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
auto* debuggerGlobalObject = jsDynamicCast<Zig::GlobalObject*>(globalObject);
|
||||
|
||||
@@ -2720,6 +2720,7 @@ pub const VirtualMachine = struct {
|
||||
|
||||
pub const HotReloader = NewHotReloader(VirtualMachine, JSC.EventLoop, false);
|
||||
pub const Watcher = HotReloader.Watcher;
|
||||
extern fn BunDebugger__willHotReload() void;
|
||||
|
||||
pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime reload_immediately: bool) type {
|
||||
return struct {
|
||||
@@ -2777,6 +2778,7 @@ pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime
|
||||
unreachable;
|
||||
}
|
||||
|
||||
BunDebugger__willHotReload();
|
||||
var that = bun.default_allocator.create(HotReloadTask) catch unreachable;
|
||||
|
||||
that.* = this.*;
|
||||
|
||||
Reference in New Issue
Block a user