mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +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);
|
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 server = @import("../server.zig");
|
||||||
const Ctx = server.Cmd;
|
const Ctx = server.Cmd;
|
||||||
const result = @import("cdp.zig").result;
|
const cdp = @import("cdp.zig");
|
||||||
const getParams = @import("cdp.zig").getParams;
|
const result = cdp.result;
|
||||||
const stringify = @import("cdp.zig").stringify;
|
const getParams = cdp.getParams;
|
||||||
|
const stringify = cdp.stringify;
|
||||||
|
|
||||||
const LogMethods = enum {
|
const LogMethods = enum {
|
||||||
enable,
|
enable,
|
||||||
@@ -27,8 +28,11 @@ pub fn log(
|
|||||||
fn enable(
|
fn enable(
|
||||||
alloc: std.mem.Allocator,
|
alloc: std.mem.Allocator,
|
||||||
id: u64,
|
id: u64,
|
||||||
_: *std.json.Scanner,
|
scanner: *std.json.Scanner,
|
||||||
_: *Ctx,
|
_: *Ctx,
|
||||||
) ![]const u8 {
|
) ![]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 server = @import("../server.zig");
|
||||||
const Ctx = server.Cmd;
|
const Ctx = server.Cmd;
|
||||||
const result = @import("cdp.zig").result;
|
const cdp = @import("cdp.zig");
|
||||||
const getParams = @import("cdp.zig").getParams;
|
const result = cdp.result;
|
||||||
const stringify = @import("cdp.zig").stringify;
|
const getParams = cdp.getParams;
|
||||||
|
const stringify = cdp.stringify;
|
||||||
|
|
||||||
const NetworkMethods = enum {
|
const NetworkMethods = enum {
|
||||||
enable,
|
enable,
|
||||||
@@ -27,8 +28,11 @@ pub fn network(
|
|||||||
fn enable(
|
fn enable(
|
||||||
alloc: std.mem.Allocator,
|
alloc: std.mem.Allocator,
|
||||||
id: u64,
|
id: u64,
|
||||||
_: *std.json.Scanner,
|
scanner: *std.json.Scanner,
|
||||||
_: *Ctx,
|
_: *Ctx,
|
||||||
) ![]const u8 {
|
) ![]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 server = @import("../server.zig");
|
||||||
const Ctx = server.Cmd;
|
const Ctx = server.Cmd;
|
||||||
const result = @import("cdp.zig").result;
|
const cdp = @import("cdp.zig");
|
||||||
const getParams = @import("cdp.zig").getParams;
|
const result = cdp.result;
|
||||||
const stringify = @import("cdp.zig").stringify;
|
const getParams = cdp.getParams;
|
||||||
|
const stringify = cdp.stringify;
|
||||||
|
|
||||||
const PageMethods = enum {
|
const PageMethods = enum {
|
||||||
enable,
|
enable,
|
||||||
@@ -33,10 +34,13 @@ pub fn page(
|
|||||||
fn enable(
|
fn enable(
|
||||||
alloc: std.mem.Allocator,
|
alloc: std.mem.Allocator,
|
||||||
id: u64,
|
id: u64,
|
||||||
_: *std.json.Scanner,
|
scanner: *std.json.Scanner,
|
||||||
_: *Ctx,
|
_: *Ctx,
|
||||||
) ![]const u8 {
|
) ![]const u8 {
|
||||||
return result(alloc, id, null, null);
|
return stringify(alloc, cdp.SessionIDResp{
|
||||||
|
.id = id,
|
||||||
|
.sessionId = try cdp.getSessionID(alloc, scanner),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn getFrameTree(
|
fn getFrameTree(
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ const std = @import("std");
|
|||||||
|
|
||||||
const server = @import("../server.zig");
|
const server = @import("../server.zig");
|
||||||
const Ctx = server.Cmd;
|
const Ctx = server.Cmd;
|
||||||
const result = @import("cdp.zig").result;
|
const cdp = @import("cdp.zig");
|
||||||
const getParams = @import("cdp.zig").getParams;
|
const result = cdp.result;
|
||||||
const stringify = @import("cdp.zig").stringify;
|
const getParams = cdp.getParams;
|
||||||
|
const stringify = cdp.stringify;
|
||||||
|
|
||||||
const RuntimeMethods = enum {
|
const RuntimeMethods = enum {
|
||||||
enable,
|
enable,
|
||||||
@@ -29,10 +30,13 @@ pub fn runtime(
|
|||||||
fn enable(
|
fn enable(
|
||||||
alloc: std.mem.Allocator,
|
alloc: std.mem.Allocator,
|
||||||
id: u64,
|
id: u64,
|
||||||
_: *std.json.Scanner,
|
scanner: *std.json.Scanner,
|
||||||
_: *Ctx,
|
_: *Ctx,
|
||||||
) ![]const u8 {
|
) ![]const u8 {
|
||||||
return result(alloc, id, null, null);
|
return stringify(alloc, cdp.SessionIDResp{
|
||||||
|
.id = id,
|
||||||
|
.sessionId = try cdp.getSessionID(alloc, scanner),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn runIfWaitingForDebugger(
|
fn runIfWaitingForDebugger(
|
||||||
|
|||||||
Reference in New Issue
Block a user