v0.2.0 — Client-driven target lifecycle
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-connect —
createTargetresolves 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/closeTargetare honored (browser-domain, sessionId echoed back); forwarded requests are bounded by a timeout + disconnect cleanup;closeTargetreturns CDP's{ success: true }; onlycreateTarget/closeTargetare host-forwardable so registry methods stay Relay-owned.
Full diff: 7bdc609...v0.2.0