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
@type mode() :: :local | :remote | :auto
@type transport() :: pid()
Functions
Check if a transport is healthy.
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:
- Use
:remoteifws_endpointis provided - Try to discover a Windows server if running in WSL and headless is false
- Fall back to
:localmode
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)
@spec stop(transport()) :: :ok
Stop a transport.
@spec wsl?() :: boolean()
Determine if we're running in WSL.