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).
Interfaces
PrintJob
Defined in: utils.ts:75
A document printed in the session, as the core hands it over: a blob URL.
Properties
name
name: string;Defined in: utils.ts:75
url
url: string;Defined in: utils.ts:75
Variables
displayId
const displayId: "display2" | "primary";Defined in: utils.ts:52
Which display this page is, from the #display2 URL hash.
isSecondaryDisplay
const isSecondaryDisplay: boolean;Defined in: utils.ts:53
isViewerUrlMode
const isViewerUrlMode: boolean;Defined in: utils.ts:60
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: ../../selkies-web-core/lib/util.js:362
Whether the client is touch-first: its primary pointer is coarse. True on phones and tablets, false on desktops -- including touch-screen laptops, whose primary pointer is still the pointing device. The form factor is fixed for the life of the document, so it is resolved once and available to every first render; a touch-capable device this misses is still caught by the first touchstart.
Functions
getPrefixedKey()
function getPrefixedKey(key): string;Defined in: utils.ts:66
The localStorage key for a setting on this display.
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
string
getPrintJobs()
function getPrintJobs(): PrintJob[];Defined in: utils.ts:104
The documents printed so far this page; printJobsChanged fires on each.
Returns
PrintJob[]
getLastServerSettings()
function getLastServerSettings(): any;Defined in: utils.ts:109
The last serverSettings payload, or null before the first connection.
Returns
any
getLastClipboardContent()
function getLastClipboardContent(): object;Defined in: utils.ts:114
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:122
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:131
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:139
Whether a control is worth rendering: the user can actually change it, meaning not locked and with more than one permitted value.
Parameters
| Parameter | Type |
|---|---|
setting | any |
Returns
boolean
computeRenderableSettings()
function computeRenderableSettings(serverSettings): Record<string, any>;Defined in: utils.ts:153
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
| Parameter | Type |
|---|---|
serverSettings | any |
Returns
Record<string, any>
getRoutePrefix()
function getRoutePrefix(): string;Defined in: ../../selkies-web-core/lib/util.js:317
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:331
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.