mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
Allow method with sessionId and use it when appropriate (*.enable)
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
@@ -121,3 +121,33 @@ pub fn getParams(
|
||||
};
|
||||
return std.json.innerParse(T, alloc, scanner, options);
|
||||
}
|
||||
|
||||
pub fn getSessionID(
|
||||
alloc: std.mem.Allocator,
|
||||
scanner: *std.json.Scanner,
|
||||
) ![]const u8 {
|
||||
var n = (try scanner.next()).string;
|
||||
if (std.mem.eql(u8, n, "params")) {
|
||||
// ignore empty params
|
||||
_ = (try scanner.next()).object_begin;
|
||||
_ = (try scanner.next()).object_end;
|
||||
n = (try scanner.next()).string;
|
||||
}
|
||||
try checkKey("sessionId", n);
|
||||
const options = std.json.ParseOptions{
|
||||
.max_value_len = scanner.input.len,
|
||||
.allocate = .alloc_if_needed,
|
||||
};
|
||||
return std.json.innerParse([]const u8, alloc, scanner, options);
|
||||
}
|
||||
|
||||
// Common
|
||||
// ------
|
||||
|
||||
pub const SessionID = "9559320D92474062597D9875C664CAC0";
|
||||
|
||||
pub const SessionIDResp = struct {
|
||||
id: u64,
|
||||
result: struct {} = .{},
|
||||
sessionId: []const u8,
|
||||
};
|
||||
|
||||
@@ -2,9 +2,10 @@ const std = @import("std");
|
||||
|
||||
const server = @import("../server.zig");
|
||||
const Ctx = server.Cmd;
|
||||
const result = @import("cdp.zig").result;
|
||||
const getParams = @import("cdp.zig").getParams;
|
||||
const stringify = @import("cdp.zig").stringify;
|
||||
const cdp = @import("cdp.zig");
|
||||
const result = cdp.result;
|
||||
const getParams = cdp.getParams;
|
||||
const stringify = cdp.stringify;
|
||||
|
||||
const LogMethods = enum {
|
||||
enable,
|
||||
@@ -27,8 +28,11 @@ pub fn log(
|
||||
fn enable(
|
||||
alloc: std.mem.Allocator,
|
||||
id: u64,
|
||||
_: *std.json.Scanner,
|
||||
scanner: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
) ![]const u8 {
|
||||
return result(alloc, id, null, null);
|
||||
return stringify(alloc, cdp.SessionIDResp{
|
||||
.id = id,
|
||||
.sessionId = try cdp.getSessionID(alloc, scanner),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ const std = @import("std");
|
||||
|
||||
const server = @import("../server.zig");
|
||||
const Ctx = server.Cmd;
|
||||
const result = @import("cdp.zig").result;
|
||||
const getParams = @import("cdp.zig").getParams;
|
||||
const stringify = @import("cdp.zig").stringify;
|
||||
const cdp = @import("cdp.zig");
|
||||
const result = cdp.result;
|
||||
const getParams = cdp.getParams;
|
||||
const stringify = cdp.stringify;
|
||||
|
||||
const NetworkMethods = enum {
|
||||
enable,
|
||||
@@ -27,8 +28,11 @@ pub fn network(
|
||||
fn enable(
|
||||
alloc: std.mem.Allocator,
|
||||
id: u64,
|
||||
_: *std.json.Scanner,
|
||||
scanner: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
) ![]const u8 {
|
||||
return result(alloc, id, null, null);
|
||||
return stringify(alloc, cdp.SessionIDResp{
|
||||
.id = id,
|
||||
.sessionId = try cdp.getSessionID(alloc, scanner),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ const std = @import("std");
|
||||
|
||||
const server = @import("../server.zig");
|
||||
const Ctx = server.Cmd;
|
||||
const result = @import("cdp.zig").result;
|
||||
const getParams = @import("cdp.zig").getParams;
|
||||
const stringify = @import("cdp.zig").stringify;
|
||||
const cdp = @import("cdp.zig");
|
||||
const result = cdp.result;
|
||||
const getParams = cdp.getParams;
|
||||
const stringify = cdp.stringify;
|
||||
|
||||
const PageMethods = enum {
|
||||
enable,
|
||||
@@ -33,10 +34,13 @@ pub fn page(
|
||||
fn enable(
|
||||
alloc: std.mem.Allocator,
|
||||
id: u64,
|
||||
_: *std.json.Scanner,
|
||||
scanner: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
) ![]const u8 {
|
||||
return result(alloc, id, null, null);
|
||||
return stringify(alloc, cdp.SessionIDResp{
|
||||
.id = id,
|
||||
.sessionId = try cdp.getSessionID(alloc, scanner),
|
||||
});
|
||||
}
|
||||
|
||||
fn getFrameTree(
|
||||
|
||||
@@ -2,9 +2,10 @@ const std = @import("std");
|
||||
|
||||
const server = @import("../server.zig");
|
||||
const Ctx = server.Cmd;
|
||||
const result = @import("cdp.zig").result;
|
||||
const getParams = @import("cdp.zig").getParams;
|
||||
const stringify = @import("cdp.zig").stringify;
|
||||
const cdp = @import("cdp.zig");
|
||||
const result = cdp.result;
|
||||
const getParams = cdp.getParams;
|
||||
const stringify = cdp.stringify;
|
||||
|
||||
const RuntimeMethods = enum {
|
||||
enable,
|
||||
@@ -29,10 +30,13 @@ pub fn runtime(
|
||||
fn enable(
|
||||
alloc: std.mem.Allocator,
|
||||
id: u64,
|
||||
_: *std.json.Scanner,
|
||||
scanner: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
) ![]const u8 {
|
||||
return result(alloc, id, null, null);
|
||||
return stringify(alloc, cdp.SessionIDResp{
|
||||
.id = id,
|
||||
.sessionId = try cdp.getSessionID(alloc, scanner),
|
||||
});
|
||||
}
|
||||
|
||||
fn runIfWaitingForDebugger(
|
||||
|
||||
Reference in New Issue
Block a user