buttplug.js

Types

All exported types from @zendrex/buttplug.js.


Client Types

ButtplugClientOptions

Configuration options for ButtplugClient.

Prop

Type

ClientEventMap

Event map for the ButtplugClient emitter. Each key is an event name and its value is the payload type passed to listeners.

Prop

Type

DeviceOutputOptions

Options for Device.output. Sends a raw OutputCommand to a specific feature on the device.

Prop

Type

DeviceStopOptions

Options for Device.stop. Without any options, stops all features on the device.

Prop

Type

Device Types

DeviceFeatures

Collection of normalized output and input features for a device.

Prop

Type

OutputFeature

Normalized output feature with type, index, range, and optional duration range.

Prop

Type

InputFeature

Normalized input feature with type, index, range, and command capabilities.

Prop

Type

FeatureValue

Feature index paired with a scalar value, used for batch output commands.

Prop

Type

RotationValue

Feature index paired with speed and direction for rotation commands.

Prop

Type

PositionValue

Feature index paired with position and duration for timed movement commands.

Prop

Type

Protocol Types

OutputType

Output actuator type string literal union. All supported output types:

type OutputType =
  | "Vibrate"
  | "Rotate"
  | "RotateWithDirection"
  | "Oscillate"
  | "Constrict"
  | "Spray"
  | "Temperature"
  | "Led"
  | "Position"
  | "HwPositionWithDuration";

InputType

Input sensor type string literal union. All supported input types:

type InputType =
  | "Battery"
  | "RSSI"
  | "Pressure"
  | "Button"
  | "Position";

OutputCommand

Discriminated union of output command payloads, keyed by actuator type. Each variant is a single-key object:

type OutputCommand =
  | { Vibrate: { Value: number } }
  | { Rotate: { Value: number } }
  | { RotateWithDirection: { Value: number; Clockwise: boolean } }
  | { Oscillate: { Value: number } }
  | { Constrict: { Value: number } }
  | { Spray: { Value: number } }
  | { Temperature: { Value: number } }
  | { Led: { Value: number } }
  | { Position: { Value: number } }
  | { HwPositionWithDuration: { Position: number; Duration: number } };

ServerInfo

Handshake response from the server with capabilities and timing requirements.

Prop

Type

InputReading

Server message delivering a sensor reading from a device.

Prop

Type

Pattern Types

PatternPlayOptions

Options for controlling pattern playback behavior.

Prop

Type

PatternDescriptor

Discriminated union of pattern descriptors. Uses the type field to distinguish between preset and custom patterns.

type PatternDescriptor = PresetPattern | CustomPattern;

PresetPattern

Pattern descriptor that references a built-in preset by name.

Prop

Type

CustomPattern

Pattern descriptor with user-defined keyframe tracks.

Prop

Type

Track

A sequence of keyframes bound to a specific device feature.

Prop

Type

Keyframe

A single animation keyframe with a target value, transition duration, and optional easing. A duration of 0 creates an instant jump to the value.

Prop

Type

Easing

Easing curve identifier used for keyframe interpolation:

type Easing = "linear" | "easeIn" | "easeOut" | "easeInOut" | "step";

PatternInfo

Read-only snapshot of a running pattern, returned by PatternEngine.list().

Prop

Type

PresetInfo

Metadata describing a built-in preset pattern.

Prop

Type

StopReason

Reason a pattern was stopped, used in PatternPlayOptions.onStop callbacks:

type StopReason =
  | "manual"
  | "complete"
  | "timeout"
  | "error"
  | "disconnect"
  | "deviceRemoved";
ValueTriggered when
"manual"stop(), stopAll(), or stopByDevice() was called
"complete"All loop iterations finished naturally
"timeout"Safety timeout elapsed
"error"Device or protocol error during playback
"disconnect"Client disconnected from server
"deviceRemoved"Target device was removed

Logger

Logger

Structured logging interface for Buttplug components. Supports hierarchical prefixes via child().

Prop

Type

Two built-in implementations are exported:

  • consoleLogger -- Writes to console with a [buttplug] prefix
  • noopLogger -- Silently discards all messages (default)
import { ButtplugClient, consoleLogger } from "@zendrex/buttplug.js";

const client = new ButtplugClient("ws://localhost:12345", {
  logger: consoleLogger,
});

On this page