Playwriter.Transport (Playwriter v0.1.0)

Copy Markdown View Source

Transport factory and utilities.

Provides a unified interface for creating and working with transports.

Summary

Functions

Check if a transport is healthy.

Start a transport based on configuration.

Stop a transport.

Determine if we're running in WSL.

Types

mode()

@type mode() :: :local | :remote | :auto

transport()

@type transport() :: pid()

Functions

healthy?(transport)

@spec healthy?(transport()) :: boolean()

Check if a transport is healthy.

start(opts \\ [])

@spec start(keyword()) :: {:ok, transport()} | {:error, term()}

Start a transport based on configuration.

Options

  • :mode - :local, :remote, or :auto (default: :auto)
  • :ws_endpoint - WebSocket URL for remote mode
  • :headless - boolean, only for local mode (default: true)
  • :auto_discover - attempt to find remote server in auto mode (default: true)
  • :browser_type - :chromium, :firefox, or :webkit (default: :chromium)

Auto Mode

In :auto mode, the transport will:

  1. Use :remote if ws_endpoint is provided
  2. Try to discover a Windows server if running in WSL and headless is false
  3. Fall back to :local mode

Examples

# Local headless browser
{:ok, transport} = Playwriter.Transport.start(mode: :local, headless: true)

# Connect to remote server
{:ok, transport} = Playwriter.Transport.start(
  mode: :remote,
  ws_endpoint: "ws://localhost:3337/"
)

# Auto-detect best transport
{:ok, transport} = Playwriter.Transport.start(mode: :auto)

stop(transport)

@spec stop(transport()) :: :ok

Stop a transport.

wsl?()

@spec wsl?() :: boolean()

Determine if we're running in WSL.