selkies-core
Entry point of the web client: picks the streaming transport and starts it.
The transport is window.__SELKIES_STREAMING_MODE__ when the page injects
one, else the stream_mode the last session persisted, else WebSockets. A
dashboard switches it by posting a {type: "mode", mode} window message; the
choice is persisted and the page reloads two seconds later, since the two
cores are not built for an in-place hand-off. A host page that sets
window.__SELKIES_DEFER_INITIALIZATION starts the client itself through
window.selkiesCoreInitialize(); otherwise the client starts on load.
Persisted settings live in localStorage under the getStorageAppName()
namespace (origin plus pathname, never the query: a per-session ?token=
must not mint a namespace per connect and exhaust the origin's quota). This
module also owns the one-time migration from the two legacy key schemes: a
sanitizer that kept ?, = and : literal, and a full-href derivation
whose token-scoped keys are pruned on every load to recover stores the leak
already filled.
Functions
safeSetItem()
function safeSetItem(key, value): void;Defined in: selkies-core.js:40
Writes a key, degrading a full or unavailable store to a warning.
Parameters
| Parameter | Type |
|---|---|
key | any |
value | any |
Returns
void
determineStreamingMode()
function determineStreamingMode(): string;Defined in: selkies-core.js:115
Resolves the transport to start: the injected runtime mode, else the last session's persisted mode, else WebSockets.
Returns
string
"webrtc" or "websockets".
handleMessage()
function handleMessage(event): void;Defined in: selkies-core.js:131
Persists a dashboard's {type: "mode", mode} request and reloads the page.
Only the two real transports are persisted: anything else would make every following load throw until localStorage was repaired by hand. The reload waits two seconds so the server has switched modes before it lands.
Parameters
| Parameter | Type | Description |
|---|---|---|
event | MessageEvent<any> | Same-origin window message. |
Returns
void
switchStreamingMode()
function switchStreamingMode(newMode): void;Defined in: selkies-core.js:150
Persists the mode and starts the matching core.
Parameters
| Parameter | Type | Description |
|---|---|---|
newMode | string | "webrtc" or "websockets". |
Returns
void
Throws
On any other mode.