Selkies
Developer ReferenceDashboard (Wish)

utils

Selkies-specific utilities shared by the dashboard components, kept apart from lib/utils.ts, which shadcn manages.

Storage keys: every localStorage key is prefixed with the storage namespace the streaming cores derive from the page URL (lib/util.js), and the per-display settings gain a _display2 suffix on the secondary display, selected by the #display2 URL hash. The route prefix is the cores' derivation too, so both dashboards and both cores agree on all of them.

Core state cache: the core broadcasts serverSettings once per connection and clipboardContentUpdate, effectiveCursorState and audioDeviceSelected only when something changes, but the panel components (Settings, Sharing, Files, Clipboard) mount lazily when their menu opens, after those messages. The latest of each is cached at module scope so a late mount can seed its state synchronously; the panels' own listeners still pick up later messages (reconnects, new clipboard events).

Variables

displayId

const displayId: "display2" | "primary";

Defined in: utils.ts:50

Which display this page is, from the #display2 URL hash.


isSecondaryDisplay

const isSecondaryDisplay: boolean;

Defined in: utils.ts:51


isViewerUrlMode

const isViewerUrlMode: boolean;

Defined in: utils.ts:58

Viewer-designated URL modes, known before the server answers with a role. The control UI keys off this for its first render so a shared viewer never sees controls it cannot use in the gap before clientRoleUpdate arrives.


isMobileClient

const isMobileClient: boolean;

Defined in: utils.ts:65

Whether this is a mobile browser; the form factor is fixed for the life of the document, so it is resolved once and available to the first render.

Functions

getPrefixedKey()

function getPrefixedKey(key): string;

Defined in: utils.ts:73

The localStorage key for a setting on this display.

Parameters

ParameterType
keystring

Returns

string


getLastServerSettings()

function getLastServerSettings(): any;

Defined in: utils.ts:104

The last serverSettings payload, or null before the first connection.

Returns

any


getLastClipboardContent()

function getLastClipboardContent(): object;

Defined in: utils.ts:109

The last server clipboard preview; the core emits it only on clipboard events.

Returns

object

text
text: string;
truncated
truncated: boolean;

getLastEffectiveCursorState()

function getLastEffectiveCursorState(): boolean;

Defined in: utils.ts:117

The cursor mode actually in effect (multi-monitor forces browser cursors on), emitted at connect and display-config time.

Returns

boolean


getLastAudioDevices()

function getLastAudioDevices(): object;

Defined in: utils.ts:126

The dashboard's own audio device picks, which the core keeps for the life of the page; a remounted Settings panel shows them again instead of pretending the defaults are in use.

Returns

object

input
input: string;
output
output: string;

isSettingRenderable()

function isSettingRenderable(setting): boolean;

Defined in: utils.ts:134

Whether a control is worth rendering: the user can actually change it, meaning not locked and with more than one permitted value.

Parameters

ParameterType
settingany

Returns

boolean


computeRenderableSettings()

function computeRenderableSettings(serverSettings): Record<string, any>;

Defined in: utils.ts:148

Derives every visibility flag the panels read from a serverSettings payload: the admin's ui_* toggles, per-control renderability from each setting's own constraints, the sharing roles, the stream-control menu entries and the file-transfer directions.

Parameters

ParameterType
serverSettingsany

Returns

Record<string, any>


getRoutePrefix()

function getRoutePrefix(): string;

Defined in: ../../selkies-web-core/lib/util.js:122

Directory this document is served from, without a trailing slash ('' at the server root). Every request the client builds hangs off it, so a deployment reverse-proxied under a subfolder reaches its own routes, and an iframed client reads its own path instead of the frame's.

Returns

string

The path prefix, e.g. /desk.


getStorageAppName()

function getStorageAppName(): string;

Defined in: ../../selkies-web-core/lib/util.js:136

The localStorage namespace every stored key is prefixed with.

Origin and pathname only, not the full URL: a per-session ?token= must not mint a new namespace on each connect. Cores and dashboards share one prefix, so this derivation is the single one they all call.

Returns

string

Sanitized namespace, empty outside a browser.

On this page

Edit on GitHub