utils
Selkies-specific utilities shared by the dashboard's panels and layouts.
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 the dashboard 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 a panel mounts when
its menu or section 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.
Interfaces
ServerSetting
Defined in: utils.ts:79
The server's description of one setting in the serverSettings payload.
Properties
value?
value?: unknown;Defined in: utils.ts:80
locked?
locked?: boolean;Defined in: utils.ts:81
overridden?
overridden?: boolean;Defined in: utils.ts:82
allowed?
allowed?: string[];Defined in: utils.ts:83
min?
min?: number;Defined in: utils.ts:84
max?
max?: number;Defined in: utils.ts:85
default?
default?: unknown;Defined in: utils.ts:86
PrintJob
Defined in: utils.ts:93
A document printed in the session, as the core hands it over: a blob URL.
Properties
name
name: string;Defined in: utils.ts:93
url
url: string;Defined in: utils.ts:93
ClipboardPreview
Defined in: utils.ts:96
The server clipboard preview; a secret arrives as the flag alone, never its text.
Properties
text
text: string;Defined in: utils.ts:96
truncated
truncated: boolean;Defined in: utils.ts:96
secret
secret: boolean;Defined in: utils.ts:96
Type Aliases
ServerSettings
type ServerSettings = Record<string, any>;Defined in: utils.ts:90
The serverSettings payload: untyped JSON keyed by setting name.
CoreMessage
type CoreMessage = Record<string, any>;Defined in: utils.ts:99
A message the core posts to the page's window (or the page to itself): an object with a type.
Renderable
type Renderable = Record<string, boolean>;Defined in: utils.ts:185
Every visibility flag the panels and layouts read, from computeRenderableSettings.
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: ../../selkies-web-core/lib/util.js:561
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:64
The localStorage key for a setting on this display.
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
string
storedBool()
function storedBool(key, fallback): boolean;Defined in: utils.ts:73
Reads a stored boolean, fallback where nothing is stored.
Parameters
| Parameter | Type |
|---|---|
key | string |
fallback | boolean |
Returns
boolean
onCoreMessage()
function onCoreMessage(handler): () => void;Defined in: utils.ts:106
Hands handler every message the core posts to this window: from this
origin, and an object, which is what every message of the core's is.
Parameters
| Parameter | Type |
|---|---|
handler | (message) => void |
Returns
The unsubscribe, for an effect's cleanup.
() => void
getPrintJobs()
function getPrintJobs(): PrintJob[];Defined in: utils.ts:141
The documents printed so far this page; printJobsChanged fires on each.
Returns
PrintJob[]
getLastServerSettings()
function getLastServerSettings(): ServerSettings;Defined in: utils.ts:146
The last serverSettings payload, or null before the first connection.
Returns
getLastClipboardContent()
function getLastClipboardContent(): ClipboardPreview;Defined in: utils.ts:151
The last server clipboard preview; the core emits it only on clipboard events.
Returns
getLastEffectiveCursorState()
function getLastEffectiveCursorState(): boolean;Defined in: utils.ts:159
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:168
The dashboard's own audio device picks, which the core keeps for the life of the page; a remounted 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:176
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 | ServerSetting |
Returns
boolean
computeRenderableSettings()
function computeRenderableSettings(serverSettings): Renderable;Defined in: utils.ts:194
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. Every flag defaults to shown
before the payload arrives, except those an absent server cannot offer.
Parameters
| Parameter | Type |
|---|---|
serverSettings | ServerSettings |
Returns
hint()
function hint(label, detail?): string;Defined in: utils.ts:279
The hover text of a labeled control: its label, then its detail after a colon where it has one, so a label the row cut short still reads whole.
Parameters
| Parameter | Type |
|---|---|
label | unknown |
detail? | string |
Returns
string
hardwareKeyboard()
function hardwareKeyboard(): object;Defined in: ../../selkies-web-core/lib/hardware-keyboard.js:119
The page's watch, listening from its first use: keydowns and touches on the window in the capture phase, before the stream's own handlers take them, and on a touch screen the primary pointer.
Returns
attached
attached: () => boolean;Returns
boolean
Whether a keyboard is taken to be attached.
onKeyDown()
onKeyDown(event): void;Parameters
| Parameter | Type | Description |
|---|---|---|
event | KeyboardEvent | - |
Returns
void
onTouch()
onTouch(): void;Returns
void
onPointer()
onPointer(fine): void;The primary pointer of a touch screen turned fine, a keyboard attached with its touchpad, or coarse, the keyboard gone with the keys it typed.
Parameters
| Parameter | Type | Description |
|---|---|---|
fine | boolean | - |
Returns
void
reset()
reset(): void;Forgets the verdict until the next keyboard-only key or pointer change, as when the user asks for the button back.
Returns
void
subscribe()
subscribe(fn): () => void;Parameters
| Parameter | Type | Description |
|---|---|---|
fn | (attached) => void | - |
Returns
Unsubscribes.
() => void
getRoutePrefix()
function getRoutePrefix(): string;Defined in: ../../selkies-web-core/lib/util.js:392
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:448
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.