mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
Merge pull request #543 from lightpanda-io/describeNode2
descibeNode for new js runtime
This commit is contained in:
2
.github/actions/install/action.yml
vendored
2
.github/actions/install/action.yml
vendored
@@ -17,7 +17,7 @@ inputs:
|
||||
zig-v8:
|
||||
description: 'zig v8 version to install'
|
||||
required: false
|
||||
default: 'v0.1.17'
|
||||
default: 'v0.1.18'
|
||||
v8:
|
||||
description: 'v8 version to install'
|
||||
required: false
|
||||
|
||||
@@ -5,7 +5,7 @@ ARG ZIG=0.14.0
|
||||
ARG ZIG_MINISIG=RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U
|
||||
ARG ARCH=x86_64
|
||||
ARG V8=11.1.134
|
||||
ARG ZIG_V8=v0.1.16
|
||||
ARG ZIG_V8=v0.1.18
|
||||
|
||||
RUN apt-get update -yq && \
|
||||
apt-get install -yq xz-utils \
|
||||
@@ -51,10 +51,6 @@ WORKDIR /browser
|
||||
RUN git submodule init && \
|
||||
git submodule update --recursive
|
||||
|
||||
RUN cd vendor/zig-js-runtime && \
|
||||
git submodule init && \
|
||||
git submodule update --recursive
|
||||
|
||||
RUN make install-libiconv && \
|
||||
make install-netsurf && \
|
||||
make install-mimalloc
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
.hash = "tigerbeetle_io-0.0.0-ViLgxpyRBAB5BMfIcj3KMXfbJzwARs9uSl8aRy2OXULd",
|
||||
},
|
||||
.v8 = .{
|
||||
.url = "https://github.com/karlseguin/zig-v8-fork/archive/e5f1c0c9f1ed147617427f22cdaf11df4ab60b79.tar.gz",
|
||||
.hash = "v8-0.0.0-xddH61vYIACI2pT1t-dUbXm18cHAKy-KWT_Qft4sBwam",
|
||||
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/5790c80fcd12dec64e596f6f66f09de567020e8a.tar.gz",
|
||||
.hash = "v8-0.0.0-xddH66roIAAdXNJpBKN_NO8zBz2H8b9moUzshBCfns2p",
|
||||
},
|
||||
//.v8 = .{ .path = "../zig-v8-fork" },
|
||||
//.tigerbeetle_io = .{ .path = "../tigerbeetle-io" },
|
||||
|
||||
@@ -30,6 +30,7 @@ pub fn processMessage(cmd: anytype) !void {
|
||||
getSearchResults,
|
||||
discardSearchResults,
|
||||
resolveNode,
|
||||
describeNode,
|
||||
}, cmd.input.action) orelse return error.UnknownMethod;
|
||||
|
||||
switch (action) {
|
||||
@@ -39,6 +40,7 @@ pub fn processMessage(cmd: anytype) !void {
|
||||
.getSearchResults => return getSearchResults(cmd),
|
||||
.discardSearchResults => return discardSearchResults(cmd),
|
||||
.resolveNode => return resolveNode(cmd),
|
||||
.describeNode => return describeNode(cmd),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +153,33 @@ fn resolveNode(cmd: anytype) !void {
|
||||
} }, .{});
|
||||
}
|
||||
|
||||
fn describeNode(cmd: anytype) !void {
|
||||
const params = (try cmd.params(struct {
|
||||
nodeId: ?Node.Id = null,
|
||||
backendNodeId: ?Node.Id = null,
|
||||
objectId: ?[]const u8 = null,
|
||||
depth: u32 = 1,
|
||||
pierce: bool = false,
|
||||
})) orelse return error.InvalidParams;
|
||||
if (params.backendNodeId != null or params.depth != 1 or params.pierce) {
|
||||
return error.NotYetImplementedParams;
|
||||
}
|
||||
|
||||
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
|
||||
|
||||
if (params.nodeId != null) {
|
||||
const node = bc.node_registry.lookup_by_id.get(params.nodeId.?) orelse return error.NodeNotFound;
|
||||
return cmd.sendResult(.{ .node = bc.nodeWriter(node, .{}) }, .{});
|
||||
}
|
||||
if (params.objectId != null) {
|
||||
// Retrieve the object from which ever context it is in.
|
||||
const parser_node = try bc.session.inspector.getNodePtr(cmd.arena, params.objectId.?);
|
||||
const node = try bc.node_registry.register(@ptrCast(parser_node));
|
||||
return cmd.sendResult(.{ .node = bc.nodeWriter(node, .{}) }, .{});
|
||||
}
|
||||
return error.MissingParams;
|
||||
}
|
||||
|
||||
const testing = @import("../testing.zig");
|
||||
|
||||
test "cdp.dom: getSearchResults unknown search id" {
|
||||
|
||||
@@ -55,13 +55,13 @@ const Browser = struct {
|
||||
if (self.session != null) {
|
||||
return error.MockBrowserSessionAlreadyExists;
|
||||
}
|
||||
|
||||
const arena = self.arena.allocator();
|
||||
const executor = arena.create(Executor) catch unreachable;
|
||||
self.session = try arena.create(Session);
|
||||
self.session.?.* = .{
|
||||
.page = null,
|
||||
.arena = arena,
|
||||
.executor = .{},
|
||||
.executor = executor,
|
||||
.inspector = .{},
|
||||
};
|
||||
return self.session.?;
|
||||
@@ -78,7 +78,7 @@ const Browser = struct {
|
||||
const Session = struct {
|
||||
page: ?Page = null,
|
||||
arena: Allocator,
|
||||
executor: Executor,
|
||||
executor: *Executor,
|
||||
inspector: Inspector,
|
||||
|
||||
pub fn currentPage(self: *Session) ?*Page {
|
||||
@@ -112,7 +112,7 @@ const Executor = struct {};
|
||||
const Inspector = struct {
|
||||
pub fn getRemoteObject(
|
||||
self: *const Inspector,
|
||||
executor: Executor,
|
||||
executor: *Executor,
|
||||
group: []const u8,
|
||||
value: anytype,
|
||||
) !RemoteObject {
|
||||
@@ -122,6 +122,11 @@ const Inspector = struct {
|
||||
_ = value;
|
||||
return RemoteObject{};
|
||||
}
|
||||
pub fn getNodePtr(self: Inspector, alloc: std.mem.Allocator, object_id: []const u8) !?*anyopaque {
|
||||
_ = self;
|
||||
_ = object_id;
|
||||
return try alloc.create(i32);
|
||||
}
|
||||
};
|
||||
|
||||
const RemoteObject = struct {
|
||||
|
||||
@@ -1369,6 +1369,15 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
|
||||
generate_preview,
|
||||
);
|
||||
}
|
||||
|
||||
// Gets a value by object ID regardless of which context it is in.
|
||||
pub fn getNodePtr(self: *const Inspector, allocator: Allocator, object_id: []const u8) !?*anyopaque {
|
||||
const unwrapped = try self.session.unwrapObject(allocator, object_id);
|
||||
// The values context and groupId are not used here
|
||||
const toa = getTaggedAnyOpaque(unwrapped.value) orelse return null;
|
||||
if (toa.subtype == null or toa.subtype != .node) return error.ObjectIdIsNotANode;
|
||||
return toa.ptr;
|
||||
}
|
||||
};
|
||||
|
||||
pub const RemoteObject = v8.RemoteObject;
|
||||
|
||||
Reference in New Issue
Block a user