aboutsummaryrefslogtreecommitdiff
path: root/src/cdp/ownership.ts
diff options
context:
space:
mode:
authorAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-07-22 00:59:58 +0530
committerGitHub <noreply@github.com>2026-07-22 00:59:58 +0530
commitfe00d3361dece3d35f788d3eeb1c750eedbf6294 (patch)
treea51b8ffe3cddb1aa8d457784f71cc1b2b0b61d56 /src/cdp/ownership.ts
parent7de0beaf2cf713afc50c573e941fa279ec6df9d9 (diff)
feat: add forms domain and durable window binding (v0.9.0) (#14)
- Add forms domain with a universal field setter that auto-detects element type and fires framework-compatible input events (React native-setter trick) - Add window-binding helper to capture and bind the real Chrome windowId as the session's durable window identity on every new-window code path - Wire supporting changes across CDP session/ownership, client, navigate, isolated-tab, prompt, and state - Add manual tests for forms and window binding - Bump version 0.8.3 -> 0.9.0 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src/cdp/ownership.ts')
-rw-r--r--src/cdp/ownership.ts20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/cdp/ownership.ts b/src/cdp/ownership.ts
index f221d6a..727b3d8 100644
--- a/src/cdp/ownership.ts
+++ b/src/cdp/ownership.ts
@@ -20,14 +20,24 @@ export type OwnershipRegistry = {
replaceAll(ids: ReadonlyArray<string>): void;
setHarnessWindow(targetId: string | undefined): void;
harnessWindow(): string | undefined;
+ /** The real Chrome windowId of the dedicated harness window — the durable
+ * identity of "the window this session initialized", surviving seed-tab
+ * closure. Undefined until the window is created (or after teardown). */
+ setHarnessWindowId(windowId: number | undefined): void;
+ harnessWindowId(): number | undefined;
onChange(cb: () => void): void;
};
export const createOwnershipRegistry = (
- initial?: { readonly ownedTargetIds?: ReadonlyArray<string>; readonly harnessWindowTargetId?: string },
+ initial?: {
+ readonly ownedTargetIds?: ReadonlyArray<string>;
+ readonly harnessWindowTargetId?: string;
+ readonly harnessWindowId?: number;
+ },
): OwnershipRegistry => {
const owned = new Set<string>(initial?.ownedTargetIds ?? []);
let harnessWindow: string | undefined = initial?.harnessWindowTargetId;
+ let harnessWindowId: number | undefined = initial?.harnessWindowId;
let listener: (() => void) | null = null;
const notify = (): void => {
@@ -65,6 +75,14 @@ export const createOwnershipRegistry = (
harnessWindow() {
return harnessWindow;
},
+ setHarnessWindowId(windowId) {
+ if (harnessWindowId === windowId) return;
+ harnessWindowId = windowId;
+ notify();
+ },
+ harnessWindowId() {
+ return harnessWindowId;
+ },
onChange(cb) {
listener = cb;
},