slightly more progress

This commit is contained in:
Jarred Sumner
2023-04-13 04:54:05 -07:00
parent cf599e77d9
commit c4b3b321c2
3 changed files with 20 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
#include <JavaScriptCore/Heap.h>
#include <JavaScriptCore/JSGlobalObject.h>
#include "JSGlobalObjectInspectorController.h"
#include <JavaScriptCore/JSGlobalObjectDebugger.h>
namespace Zig {
@@ -111,6 +112,8 @@ void BunInspector::drainOutgoingMessages()
}
}
extern "C" void Bun__tickWhileWaitingForDebugger(JSC::JSGlobalObject* globalObject);
RefPtr<BunInspector> BunInspector::startWebSocketServer(
WebCore::ScriptExecutionContext& context,
WTF::String hostname,
@@ -184,7 +187,13 @@ RefPtr<BunInspector> BunInspector::startWebSocketServer(
*connectionPtr = new BunInspectorConnection(inspector);
ws->subscribe("BunInspectorConnection");
BunInspectorConnection* connection = *connectionPtr;
inspector->connect(Inspector::FrontendChannel::ConnectionType::Local); },
inspector->connect(Inspector::FrontendChannel::ConnectionType::Local);
auto* debugger = reinterpret_cast<Inspector::JSGlobalObjectDebugger*>(inspector->globalObject()->inspectorController().debugger());
debugger->runWhilePausedCallback = [](JSC::JSGlobalObject& globalObject, bool& isPaused) {
while (isPaused) {
Bun__tickWhileWaitingForDebugger(&globalObject);
}
}; },
.message = [inspector](auto* ws, std::string_view message, uWS::OpCode opCode) {
if (opCode == uWS::OpCode::TEXT) {

View File

@@ -11,6 +11,7 @@
namespace Zig {
using namespace JSC;
using namespace WebCore;
class BunInspector final : public RefCounted<BunInspector>, ::Inspector::InspectorTarget, ::Inspector::FrontendChannel, public WebCore::ContextDestructionObserver {
public:

View File

@@ -879,3 +879,12 @@ pub const AnyEventLoop = union(enum) {
}
}
};
pub export fn Bun__tickWhileWaitingForDebugger(globalObject: *JSC.JSGlobalObject) callconv(.C) void {
globalObject.bunVM().eventLoop().tickPossiblyForever();
}
comptime {
if (!JSC.is_bindgen)
_ = Bun__tickWhileWaitingForDebugger;
}