cdp

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cdp discovers Antigravity 2.0 renderer targets over Chrome DevTools Protocol and injects the RTL payload into active pages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPDiscoverer

type HTTPDiscoverer struct {
	// contains filtered or unexported fields
}

HTTPDiscoverer queries Electron's local CDP HTTP endpoint (/json).

func NewHTTPDiscoverer

func NewHTTPDiscoverer(port int) *HTTPDiscoverer

NewHTTPDiscoverer creates an HTTPDiscoverer targeting http://127.0.0.1:<port>.

func NewHTTPDiscovererWithURL

func NewHTTPDiscovererWithURL(baseURL string) *HTTPDiscoverer

NewHTTPDiscovererWithURL creates an HTTPDiscoverer for a custom base URL (useful in tests).

func (*HTTPDiscoverer) Discover

func (d *HTTPDiscoverer) Discover(ctx context.Context) ([]Target, error)

Discover fetches /json and returns eligible page/webview targets.

type Injector

type Injector interface {
	Inject(ctx context.Context, target Target, script string) error
}

Injector delivers a JavaScript payload to a CDP target.

type Sidecar

type Sidecar struct {
	// contains filtered or unexported fields
}

Sidecar watches CDP targets and injects the RTL payload into any new or restarted windows.

func NewSidecar

func NewSidecar(discoverer TargetDiscoverer, injector Injector, payload string, pollInterval time.Duration, logger *slog.Logger) *Sidecar

NewSidecar constructs a Sidecar with the given dependencies and polling interval.

func (*Sidecar) Run

func (s *Sidecar) Run(ctx context.Context) error

Run polls for CDP targets until ctx is canceled.

func (*Sidecar) SyncOnce

func (s *Sidecar) SyncOnce(ctx context.Context)

SyncOnce discovers current targets, injects into any unseen or changed targets, and prunes targets that are no longer present.

type Target

type Target struct {
	ID                   string `json:"id"`
	Type                 string `json:"type"`
	Title                string `json:"title"`
	URL                  string `json:"url"`
	WebSocketDebuggerURL string `json:"webSocketDebuggerUrl"`
}

Target represents a single debuggable Chromium target returned by /json.

type TargetDiscoverer

type TargetDiscoverer interface {
	Discover(ctx context.Context) ([]Target, error)
}

TargetDiscoverer lists active CDP targets eligible for script injection.

type WSInjector

type WSInjector struct {
	// contains filtered or unexported fields
}

WSInjector connects to a target's WebSocket debugger URL and evaluates the payload immediately as well as on future document loads.

func NewWSInjector

func NewWSInjector() *WSInjector

NewWSInjector returns a WSInjector with a default operation timeout.

func (*WSInjector) Inject

func (w *WSInjector) Inject(ctx context.Context, target Target, script string) error

Inject opens a short-lived CDP WebSocket session, registers the script for future navigations, and evaluates it immediately in the current document.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL