Skip to content

Commit ad8c9fa

Browse files
Add target.setDiscoverTargets
Signed-off-by: Francis Bouvier <[email protected]>
1 parent fa82160 commit ad8c9fa

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/cdp/target.zig

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const getMsg = cdp.getMsg;
88
const stringify = cdp.stringify;
99

1010
const TargetMethods = enum {
11+
setDiscoverTargets,
1112
setAutoAttach,
1213
getTargetInfo,
1314
getBrowserContexts,
@@ -25,6 +26,7 @@ pub fn target(
2526
const method = std.meta.stringToEnum(TargetMethods, action) orelse
2627
return error.UnknownMethod;
2728
return switch (method) {
29+
.setDiscoverTargets => targetSetDiscoverTargets(alloc, id, scanner, ctx),
2830
.setAutoAttach => tagetSetAutoAttach(alloc, id, scanner, ctx),
2931
.getTargetInfo => tagetGetTargetInfo(alloc, id, scanner, ctx),
3032
.getBrowserContexts => getBrowserContexts(alloc, id, scanner, ctx),
@@ -37,6 +39,17 @@ const PageTargetID = "CFCD6EC01573CF29BB638E9DC0F52DDC";
3739
const BrowserTargetID = "2d2bdef9-1c95-416f-8c0e-83f3ab73a30c";
3840
const BrowserContextID = "65618675CB7D3585A95049E9DFE95EA9";
3941

42+
fn targetSetDiscoverTargets(
43+
alloc: std.mem.Allocator,
44+
id: ?u16,
45+
scanner: *std.json.Scanner,
46+
_: *Ctx,
47+
) ![]const u8 {
48+
const msg = try getMsg(alloc, void, scanner);
49+
50+
return result(alloc, id orelse msg.id.?, null, null, msg.sessionID);
51+
}
52+
4053
const AttachToTarget = struct {
4154
sessionId: []const u8,
4255
targetInfo: struct {
@@ -52,8 +65,8 @@ const AttachToTarget = struct {
5265
};
5366

5467
const TargetFilter = struct {
55-
type: []const u8,
56-
exclude: bool,
68+
type: ?[]const u8 = null,
69+
exclude: ?bool = null,
5770
};
5871

5972
fn tagetSetAutoAttach(

0 commit comments

Comments
 (0)