hostscreen

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 8 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 hostscreen serves the host_screen.* methods of one bridge connection (ホストの画面, ADR 0008): it lists what can be shown, runs at most one stream and paces its frames to the app's acks. Each kind of target (browser, Android emulator, iOS simulator) is a Kind in its own package.

Index

Constants

View Source
const (
	// MaxInFlight is how many frames may wait for the app's ack.
	MaxInFlight = 2
	// StallAfter is how long the app may hold MaxInFlight frames before
	// the stream is paused; its next ack resumes it with a full frame.
	StallAfter = 2 * time.Second
)
View Source
const (
	MaxDragPoints   = 1000
	MaxDragDuration = 10_000 // ms
	// MaxScroll bounds dx and dy: the fingers may cross a fitted frame
	// several times over.
	MaxScroll = 10
)

Bounds of an input, so one request cannot hold the input queue long.

Variables

This section is empty.

Functions

func CheckInput

func CheckInput(in wire.HostScreenInput) error

CheckInput refuses with bad_request an input whose shape is wrong for its type: a point outside the frame (0–1), a drag of fewer than two points, a text without text or enter, an unknown key or action, a navigate to an empty url. Whether the target takes it is the stream's to say.

Types

type Events

type Events interface {
	Frame(Frame)
	// State reports wire.HostScreenLive (with the target's title and URL
	// when it has them) or wire.HostScreenGone, after which no call
	// follows.
	State(wire.HostScreenState)
}

Events receives what a Stream produces. A Stream calls it from its own goroutines; the calls need not be serialized.

type Frame

type Frame struct {
	Data          string // base64 of one JPEG
	Width, Height int    // the target's size in its own coordinates
}

Frame is one picture of a target.

type Inputter

type Inputter interface {
	// Input performs in on the target (already checked by CheckInput:
	// points within the frame, the fields its type needs) and returns once
	// the target took it. Inputs come one at a time, in the order the app
	// sent them; Input may block on the target, never on the app's acks.
	// Errors are *wire.Error: unsupported for an input the kind does not
	// take.
	Input(ctx context.Context, in wire.HostScreenInput) error
}

Inputter is a Stream that takes host_screen.input; a Stream without it answers every input unsupported.

type Kind

type Kind interface {
	// Name is the target kind and the key of its section.
	Name() string
	// List returns the section (a wire.HostScreenSection).
	List(ctx context.Context) (any, error)
	// Open connects to t (t.Kind is Name()). Errors are *wire.Error:
	// bad_request, not_found or unavailable.
	Open(ctx context.Context, t wire.HostScreenTarget) (Stream, error)
}

Kind is one kind of target: its section of host_screen.list and its streams.

type PortsKind

type PortsKind interface {
	Kind
	// ListPorts is List plus ports (each 1–65535, without repeats).
	ListPorts(ctx context.Context, ports []int) (any, error)
}

PortsKind is a Kind whose section also lists the CDP ports the app named by hand (host_screen.list's cdp_ports): the browser kind.

type Server

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

Server is the host_screen.* state of one bridge connection.

func NewServer

func NewServer(notify func(method string, params any), kinds ...Kind) *Server

NewServer serves kinds, writing notifications with notify (safe for concurrent use).

func (*Server) Ack

func (s *Server) Ack(seq int64) error

Ack answers host_screen.ack. It never waits for the stream's target.

func (*Server) Input

func (s *Server) Input(ctx context.Context, in wire.HostScreenInput) error

Input answers host_screen.input: it checks in, then has the current stream perform it. The caller runs inputs one at a time in the app's order (with Start and Stop); acks never wait for them.

func (*Server) List

func (s *Server) List(ctx context.Context, p wire.HostScreenListParams) (map[string]any, error)

List answers host_screen.list: one section per kind. A port of p.CDPPorts outside 1–65535 is bad_request.

func (*Server) Serves

func (s *Server) Serves(kind string) bool

Serves tells whether kind is one of the server's kinds.

func (*Server) Start

func (s *Server) Start(ctx context.Context, t wire.HostScreenTarget, started func()) error

Start answers host_screen.start: it stops the current stream, opens t and, once opened, calls started (which answers the app) before the stream's first notification.

func (*Server) Stop

func (s *Server) Stop()

Stop answers host_screen.stop; without a stream it does nothing.

type Stream

type Stream interface {
	// Start begins delivery: State live first, then a full frame, then a
	// frame whenever the target changes.
	Start(Events)
	// Pause stops capturing while the app is stalled.
	Pause()
	// Resume captures again, beginning with a full frame (the target may
	// not change by itself).
	Resume()
	// Close stops the stream and waits for its goroutines: no Events call
	// follows its return.
	Close()
}

Stream is one target being shown. Its methods do not block on the target, except Close.

Directories

Path Synopsis
Package android is the Android emulator kind of the host screen (ADR 0008): the emulators `adb devices` lists, matched with the files in which they advertise their gRPC port, and one shown through the emulator's gRPC streamScreenshot.
Package android is the Android emulator kind of the host screen (ADR 0008): the emulators `adb devices` lists, matched with the files in which they advertise their gRPC port, and one shown through the emulator's gRPC streamScreenshot.
emupb
Package emupb is the Go code of the Android emulator's gRPC service, generated from emulator_controller.proto.
Package emupb is the Go code of the Android emulator's gRPC service, generated from emulator_controller.proto.
Package browser is the browser kind of the host screen (ADR 0008): the Chromium-family browsers of the user that opened a CDP port, and a page target of one shown through Page.startScreencast.
Package browser is the browser kind of the host screen (ADR 0008): the Chromium-family browsers of the user that opened a CDP port, and a page target of one shown through Page.startScreencast.
ios
Package ios is the iOS simulator kind of the host screen (ADR 0008, macOS only): the booted simulators simctl lists, one shown through an idb_companion stagent starts for the stream (#630).
Package ios is the iOS simulator kind of the host screen (ADR 0008, macOS only): the booted simulators simctl lists, one shown through an idb_companion stagent starts for the stream (#630).
idbpb
Package idbpb is the generated client of idb_companion's gRPC API (idb.proto, a subset of facebook/idb v1.6.8).
Package idbpb is the generated client of idb_companion's gRPC API (idb.proto, a subset of facebook/idb v1.6.8).

Jump to

Keyboard shortcuts

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