Skip to main content
Version: 5.0

Class: ObsUtilsApi

Defined in: api.ts:114

Constructors

Constructor

new ObsUtilsApi(): ObsUtilsApi

Defined in: api.ts:123

Returns

ObsUtilsApi

Properties

directorTabs

directorTabs: Map<string, DirectorTabRegistration | DirectorTabSvelte5Registration>

Defined in: api.ts:121


obsRemoteEventTypes

obsRemoteEventTypes: Map<string, OBSRemoteEventTypeRegistration>

Defined in: api.ts:119


overlayTriggers

overlayTriggers: Map<string, OverlayTriggerRegistration>

Defined in: api.ts:120


overlayTypeNames

overlayTypeNames: Map<string, string>

Defined in: api.ts:116


overlayTypes

overlayTypes: Map<string, OverlayType>

Defined in: api.ts:115


singleInstanceOverlays

singleInstanceOverlays: Set<Component>

Defined in: api.ts:117


singleInstanceOverlaysSvelte5

singleInstanceOverlaysSvelte5: Set<(target) => () => void>

Defined in: api.ts:118

Methods

buildLegacyRollOverlayCanvas()

buildLegacyRollOverlayCanvas(config): OverlayData

Defined in: api.ts:228

Build a wysiwyg (canvas) overlay that emulates the 4.x roll overlay. Shared by the v4 migration (5.0 type: 'roll' entries) and the docs snippet that pulls the user's legacy flat settings out of the world.

The returned overlay is a 250×250 layer with tileBy: 'players', a core.onPlayerRoll transition out of the idle track, and the pre / roll / post phases chained through transition-on-end.

Push the result into streamOverlays (or import it through the composer) — this helper is data-only and does not touch settings.

Parameters

config

LegacyRollOverlayConfig

Returns

OverlayData


fireOverlayTrigger()

fireOverlayTrigger(key, payload): void

Defined in: api.ts:178

Public — modules call this when their in-system event fires (e.g. a chat message is created, a roll is made). Dispatches via Foundry's Hooks bus so any number of overlay renderers can react without tight coupling.

Parameters

key

string

payload

Record<string, any>

Returns

void


getDirectorState()

getDirectorState(): DirectorState

Defined in: api.ts:163

Public — snapshot of Director state (tracking modes, combat, focused user). Subscribe to obs-utils.director.stateChanged to react to changes; the hook payload is (next: DirectorState, prev: DirectorState | undefined).

Returns

DirectorState


getOBSWebsocketClient()

getOBSWebsocketClient(): Promise<any> | undefined

Defined in: api.ts:278

Returns

Promise<any> | undefined


getSelectedActors()

getSelectedActors(): any

Defined in: api.ts:246

Returns

any


isOBS()

isOBS(): any

Defined in: api.ts:286

Returns

any


playPreset()

playPreset(preset): void

Defined in: api.ts:299

Public — play a camera preset on the OBS client. The DM that calls this claims active-GM control, swaps the current tracking mode to cloneDM, pauses their outgoing viewport stream, and broadcasts the preset so it runs locally on every OBS client. The DM's own view does not move.

For previewing a preset in the editor (no broadcast, no state changes), call playSequence directly from cameraSequencePlayer.

Parameters

preset

CameraPreset

Returns

void


previewPreset()

previewPreset(preset): SequenceController

Defined in: api.ts:307

Local-only preview play. Use this from the preset editor when scrubbing or auditioning — doesn't touch tracking state and doesn't broadcast.

Parameters

preset

CameraPreset

Returns

SequenceController


registerDirectorTab()

registerDirectorTab(reg): void

Defined in: api.ts:149

Public — register a tab in the Director window.

Parameters

reg

DirectorTabRegistration

Returns

void

Deprecated

A Svelte 5 component from another module fails to mount here (effect_orphan). Use registerDirectorTabSvelte5, which lets your module mount its own UI. Still fine for OBS Utils' own (same-bundle) tabs.


registerDirectorTabSvelte5()

registerDirectorTabSvelte5(reg): void

Defined in: api.ts:154

Public — register a Director tab whose UI your module mounts itself (cross-bundle-safe).

Parameters

reg

DirectorTabSvelte5Registration

Returns

void


registerOBSRemoteEventType()

registerOBSRemoteEventType(reg): void

Defined in: api.ts:134

Public — modules call this in their init hook to expose a new event type.

Parameters

reg

OBSRemoteEventTypeRegistration

Returns

void


registerOverlayTrigger()

registerOverlayTrigger(reg): void

Defined in: api.ts:139

Public — modules call this to expose a new overlay trigger type.

Parameters

reg

OverlayTriggerRegistration

Returns

void


registerOverlayType()

registerOverlayType(key, readableName, type): void

Defined in: api.ts:211

Register a new overlay type. Surfaces in the Stream Composer's "+ new" menu and elsewhere the type list is consumed.

Parameters

key

string

Stable key written into OverlayData.type (e.g. 'wysiwyg').

readableName

string

i18n key for the display label. Resolved via game.i18n.localize() at render time. Pass a literal string only if you intentionally ship a single-locale module.

type

OverlayType

The OverlayType instance with the renderer and editor wired up.

Returns

void


registerStarterOverlays()

registerStarterOverlays(overlays): void

Defined in: api.ts:274

Public — system modules call this in their init hook to register their own starter overlay set. The burger menu in the overlay editor imports whichever set is registered (or the generic default if none). Last writer wins.

Parameters

overlays

OverlayData[]

Returns

void


registerUniqueOverlay()

registerUniqueOverlay(overlay): void

Defined in: api.ts:233

Parameters

overlay

Component

Returns

void


registerUniqueOverlaySvelte5()

registerUniqueOverlaySvelte5(mount): void

Defined in: api.ts:242

Register a unique overlay rendered once on the stream, for Svelte 5 modules. Pass a mount callback that mounts your overlay into the given element with your own module's Svelte mount() and returns a cleanup function — OBS Utils can't mount a Svelte 5 component from another bundle itself (effect_orphan).

Parameters

mount

(target) => () => void

Returns

void


setAVData()

setAVData(actorValueArray): void

Defined in: api.ts:254

Parameters

actorValueArray

ActorValues

Returns

void


setAVDataGrouped()

setAVDataGrouped(groups): void

Defined in: api.ts:264

Public — system modules call this with a hierarchical layout. The picker UI renders groups in the dropdown. Group labels are i18n keys, localized at flatten time. Calling this replaces any previously-set AV data (grouped or flat) — last writer wins, same as setAVData.

Parameters

groups

ActorValueGroup[]

Returns

void


setSelectedActors()

setSelectedActors(actorArray): Promise<void>

Defined in: api.ts:250

Parameters

actorArray

string[]

Returns

Promise<void>


setTrackingMode()

setTrackingMode(slot, mode): Promise<void>

Defined in: api.ts:168

Public — set one of the tracking-mode slots. Mirrors the Controls tab UI.

Parameters

slot

"inCombat" | "outOfCombat"

mode

string

Returns

Promise<void>


triggerOBSRemoteEvent()

triggerOBSRemoteEvent(key, context?): Promise<void>

Defined in: api.ts:192

Public — modules call this when their in-system condition fires (e.g. on updateActor with system.attributes.hp.value changed). Looks up every configured instance for the type, runs the matcher, and executes the configured OBS actions for instances that pass.

Safe to call from any client; the actual OBS action execution is already gated to the OBS-mode client by triggerOBSAction.

Parameters

key

string

context?

Record<string, any> = {}

Returns

Promise<void>