@stripchatdev/ext-helper
v0.1.49
Published
SDK for building extensions on the Stripchat Extension Platform. Provides typed methods for context, events, settings, whisper messaging, and backend actions — all from inside sandboxed iframes.
Readme
@stripchatdev/ext-helper
SDK for building extensions on the Stripchat Extension Platform. Provides typed methods for context, events, settings, whisper messaging, and backend actions — all from inside sandboxed iframes.
Installation
npm install @stripchatdev/ext-helperQuick Start
Call createExtHelper() once at the entry point of each page:
import {createExtHelper} from '@stripchatdev/ext-helper';
const ext = createExtHelper();Make requests
const ctx = await ext.makeRequest('v1.ext.context.get', null);Subscribe to events
ext.subscribe('v1.ext.context.updated', ({context}) => {
// handle context update
});Send a whisper to other slots
await ext.makeRequest('v1.ext.whisper.local', {
data: {type: 'READY'},
});Share state between slots
Create the state host in the background slot. The background slot owns the canonical state and synchronizes it with visual slots through a shared channel:
import {createSlotStateHost} from '@stripchatdev/ext-helper/helpers';
const state = createSlotStateHost({
channel: 'game',
extHelper: ext,
initialState: {score: 0},
});
await state.setState({score: 1});Create a state client in a visual slot to read and update the background state.
Use the same channel value as the background host. The visual slot does not
own the state; its setState calls are sent to the background host, and its state
updates when the host publishes a snapshot:
import {useSlotState} from '@stripchatdev/ext-helper/helpers/react';
const {isLoading, setState, state} = useSlotState({
channel: 'game',
extHelper: ext,
});Call a backend action
const result = await ext.makeRequest('v1.ext.actions.call', {
actionName: 'stopDevice',
params: {deviceId: 'dev_456', token: 'tok_abc'},
});TypeScript
Full type definitions are included. You get autocompletion and type safety for all methods and events out of the box.
Documentation
For the full guide — manifest setup, slots, resolver scripts, settings, communication, and more — see the Extension Platform Documentation.
Browser Support
- Chrome 91+
- Firefox 90+
- Safari 15+
- Edge 91+
