Skip to content

v0.2.0 — Client-driven target lifecycle

Choose a tag to compare

@olimsaidov olimsaidov released this 13 Jun 15:25
· 13 commits to master since this release
f3d6c77

Host-side Target lifecycle hooks

A Host can now let a CDP Client open and close Targets by passing onCreateTarget / onCloseTarget to IcdpHost:

new IcdpHost({
  onCreateTarget: ({ url }) => { /* create + pair() an iframe */ return targetId },
  onCloseTarget:  (targetId) => host.unpair(targetId),
})
  • Capability advertising — the Host announces which methods it handles; the Relay forwards only those and keeps its built-in defaults for unset hooks. Existing Hosts (and new IcdpHost(window)) are unaffected.
  • Await-connectcreateTarget resolves only after the new Target finishes its handshake, so the Client's first command can't race the not-connected gate. A Target that never connects (timeout/early destroy) is torn down instead of leaking as a zombie.
  • Relay hardening — session-scoped createTarget/closeTarget are honored (browser-domain, sessionId echoed back); forwarded requests are bounded by a timeout + disconnect cleanup; closeTarget returns CDP's { success: true }; only createTarget/closeTarget are host-forwardable so registry methods stay Relay-owned.

Full diff: 7bdc609...v0.2.0