Skip to content

Commit

Permalink
feat: re-enabled inspector protocol handling (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
rigor789 authored May 4, 2023
1 parent 2e5f5f1 commit c100f72
Show file tree
Hide file tree
Showing 14 changed files with 483 additions and 78 deletions.
2 changes: 1 addition & 1 deletion NativeScript/NativeScript-Prefix.pch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NativeScript_Prefix_pch
#define NativeScript_Prefix_pch

#define NATIVESCRIPT_VERSION "8.5.1"
#define NATIVESCRIPT_VERSION "8.5.2-alpha.3"

#ifdef DEBUG
#define SIZEOF_OFF_T 8
Expand Down
3 changes: 1 addition & 2 deletions NativeScript/NativeScript.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ - (instancetype)initWithConfig:(Config*)config {
runtime_->Init(isolate);
std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count();
printf("Runtime initialization took %llims\n", duration);
printf("Runtime V8 Version %s\n", V8::GetVersion());
printf("Runtime initialization took %llims (version %s, V8 version %s)\n", duration, NATIVESCRIPT_VERSION, V8::GetVersion());

if (config.IsDebug) {
Isolate::Scope isolate_scope(isolate);
Expand Down
34 changes: 0 additions & 34 deletions NativeScript/inspector/JsV8InspectorClient.cpp

This file was deleted.

15 changes: 14 additions & 1 deletion NativeScript/inspector/JsV8InspectorClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "include/v8-inspector.h"
#include "src/inspector/v8-console-message.h"

#include "ns-v8-tracing-agent-impl.h"
#include "runtime/Runtime.h"

namespace v8_inspector {
Expand Down Expand Up @@ -46,14 +47,18 @@ class JsV8InspectorClient : V8InspectorClient, V8Inspector::Channel {
v8::Persistent<v8::Context> context_;
std::unique_ptr<V8InspectorSession> session_;
tns::Runtime* runtime_;
v8::Isolate* isolate_;
bool terminated_;
std::vector<std::string> messages_;
std::queue<std::string> messages_;
bool runningNestedLoops_;
dispatch_queue_t messagesQueue_;
dispatch_queue_t messageLoopQueue_;
dispatch_semaphore_t messageArrived_;
std::function<void (std::string)> sender_;
bool isWaitingForDebugger_;
bool hasScheduledDebugBreak_;

std::unique_ptr<tns::inspector::TracingAgentImpl> tracing_agent_;

// Override of V8InspectorClient
v8::Local<v8::Context> ensureDefaultContextInGroup(int contextGroupId) override;
Expand All @@ -67,6 +72,14 @@ class JsV8InspectorClient : V8InspectorClient, V8Inspector::Channel {
static void registerDomainDispatcherCallback(const v8::FunctionCallbackInfo<v8::Value>& args);
static void inspectorSendEventCallback(const v8::FunctionCallbackInfo<v8::Value>& args);
static void inspectorTimestampCallback(const v8::FunctionCallbackInfo<v8::Value>& args);

// {N} specific helpers
bool CallDomainHandlerFunction(v8::Local<v8::Context> context,
v8::Local<v8::Function> domainMethodFunc,
const v8::Local<v8::Object>& arg,
v8::Local<v8::Object>& domainDebugger,
v8::Local<v8::Value>& result);
std::string GetReturnMessageFromDomainHandlerResult(const v8::Local<v8::Value>& result, const v8::Local<v8::Value>& requestId);
};

}
Expand Down
Loading

0 comments on commit c100f72

Please sign in to comment.