Make CDP less generic.

It's still generic over the client - we need to assert messages written to and
be able to send specific commands, but it's no longer generic over Browser/
Session/Page/etc..
This commit is contained in:
Karl Seguin
2025-04-24 18:06:55 +08:00
parent 332508f563
commit 1fca035cfe
4 changed files with 18 additions and 208 deletions

View File

@@ -22,6 +22,8 @@ const json = std.json;
const App = @import("../app.zig").App;
const asUint = @import("../str/parser.zig").asUint;
const Browser = @import("../browser/browser.zig").Browser;
const Session = @import("../browser/browser.zig").Session;
const Incrementing = @import("../id.zig").Incrementing;
const Notification = @import("../notification.zig").Notification;
@@ -32,8 +34,6 @@ pub const LOADER_ID = "LOADERID24DD2FD56CF1EF33C965C79C";
pub const CDP = CDPT(struct {
const Client = *@import("../server.zig").Client;
const Browser = @import("../browser/browser.zig").Browser;
const Session = @import("../browser/browser.zig").Session;
});
const SessionIdGen = Incrementing(u32, "SID");
@@ -69,8 +69,6 @@ pub fn CDPT(comptime TypeProvider: type) type {
message_arena: std.heap.ArenaAllocator,
const Self = @This();
pub const Browser = TypeProvider.Browser;
pub const Session = TypeProvider.Session;
pub fn init(app: *App, client: TypeProvider.Client) !Self {
const allocator = app.allocator;
@@ -247,6 +245,7 @@ pub fn CDPT(comptime TypeProvider: type) type {
return false;
}
bc.deinit();
self.browser.closeSession();
self.browser_context_pool.destroy(bc);
self.browser_context = null;
return true;
@@ -282,7 +281,7 @@ pub fn BrowserContext(comptime CDP_T: type) type {
// all intents and purpose, from CDP's point of view our Browser and
// our Session more or less maps to a BrowserContext. THIS HAS ZERO
// RELATION TO SESSION_ID
session: *CDP_T.Session,
session: *Session,
// Points to the session arena
arena: Allocator,
@@ -309,7 +308,7 @@ pub fn BrowserContext(comptime CDP_T: type) type {
node_registry: Node.Registry,
node_search_list: Node.Search.List,
isolated_world: ?IsolatedWorld(CDP_T.Browser.EnvType),
isolated_world: ?IsolatedWorld(Browser.EnvType),
const Self = @This();