Selkies

lib/conditional-settings

Conditional settings: settings whose default depends on other state (HiDPI defers to whether a manual resolution is set, paint-over to Turbo, ...), and the plain ones that share the ladder so a locked or overridden server value reaches the UI.

Each is a declarative spec, and the precedence ladder, resolution, and (through the dashboards' thin useConditionalSetting hook) initialization, server sync, and dependency re-derivation are generic; adding a setting is one more spec. A spec fully describes both the read side and the write side so the dashboards touch neither postMessage nor localStorage keys directly.

Resolution precedence, highest first:

  1. locked server value: the operator forces it, the client cannot override;
  2. explicit client choice, from localStorage, which must satisfy isValid;
  3. explicit server choice, a CLI or environment override, which must satisfy isValid;
  4. conditional default, derived from other state, which must satisfy isValid;
  5. built-in server default, the ground-truth fallback.

Interfaces

SettingSpec

Defined in: lib/conditional-settings.js:28

Properties

id
id: string;

Defined in: lib/conditional-settings.js:29

Name of the setting in the dashboards.

serverKey
serverKey: string;

Defined in: lib/conditional-settings.js:30

Key into server_settings.

storageKey
storageKey: string;

Defined in: lib/conditional-settings.js:31

localStorage key for the client's choice.

parse?
parse?: (stored) => any;

Defined in: lib/conditional-settings.js:32

Interprets the stored string; identity by default.

Parameters
ParameterType
storedstring
Returns

any

conditional?
conditional?: (ctx) => any;

Defined in: lib/conditional-settings.js:34

State-derived default, or undefined when the state implies nothing.

Parameters
ParameterType
ctxany
Returns

any

isValid?
isValid?: (value, ctx) => boolean;

Defined in: lib/conditional-settings.js:36

Rejects invalid candidates at every rung.

Parameters
ParameterType
valueany
ctxany
Returns

boolean

fallback?
fallback?: any;

Defined in: lib/conditional-settings.js:38

Value used when nothing else resolves.

toUi?
toUi?: (serverValue) => any;

Defined in: lib/conditional-settings.js:39

Maps the server domain to the UI domain.

Parameters
ParameterType
serverValueany
Returns

any

toServer?
toServer?: (uiValue) => any;

Defined in: lib/conditional-settings.js:41

Inverse of toUi; identity by default.

Parameters
ParameterType
uiValueany
Returns

any

serialize?
serialize?: (uiValue) => string;

Defined in: lib/conditional-settings.js:43

localStorage form; String by default.

Parameters
ParameterType
uiValueany
Returns

string

propagate?
propagate?: (serverValue, ctx, io) => void;

Defined in: lib/conditional-settings.js:45

Pushes a change to the server or the core.

Parameters
ParameterType
serverValueany
ctxany
io{ postSetting: Function; postToCore: Function; }
io.postSettingFunction
io.postToCoreFunction
Returns

void

Variables

HIDPI_SPEC

const HIDPI_SPEC: object;

Defined in: lib/conditional-settings.js:193

HiDPI, shown as the inverse of use_css_scaling. A manual or preset resolution wants CSS scaling on (HiDPI off). The core owns useCssScaling, applying and persisting it on the propagated message.

Type Declaration

id
id: string = "hidpi";
serverKey
serverKey: string = "use_css_scaling";
storageKey
storageKey: string = "useCssScaling";
parse
parse: (v) => boolean;
Parameters
ParameterType
vany
Returns

boolean

conditional
conditional: (ctx) => boolean;
Parameters
ParameterType
ctxany
Returns

boolean

fallback
fallback: boolean = false;
toUi
toUi: (cssScaling) => boolean;
Parameters
ParameterType
cssScalingany
Returns

boolean

toServer
toServer: (hidpi) => boolean;
Parameters
ParameterType
hidpiany
Returns

boolean

serialize
serialize: (hidpi) => string;
Parameters
ParameterType
hidpiany
Returns

string

propagate
propagate: (cssScaling, _ctx, io) => any;
Parameters
ParameterType
cssScalingany
_ctxany
ioany
Returns

any


RATE_CONTROL_SPEC

const RATE_CONTROL_SPEC: object;

Defined in: lib/conditional-settings.js:207

Rate control: the server's, CBR unless an operator set it, on both transports.

Type Declaration

id
id: string = "rate_control_mode";
serverKey
serverKey: string = "rate_control_mode";
storageKey
storageKey: string = "rate_control_mode";
isValid
isValid: (v, ctx) => any;
Parameters
ParameterType
vany
ctxany
Returns

any

fallback
fallback: string = "cbr";
propagate
propagate: (mode, _ctx, io) => any;
Parameters
ParameterType
modeany
_ctxany
ioany
Returns

any


USE_BROWSER_CURSORS_SPEC

const USE_BROWSER_CURSORS_SPEC: SettingSpec;

Defined in: lib/conditional-settings.js:235

The core owns use_browser_cursors, applying and persisting it on the propagated message, so this spec posts to the core rather than a settings message.


VIDEO_FULLCOLOR_SPEC

const VIDEO_FULLCOLOR_SPEC: SettingSpec;

Defined in: lib/conditional-settings.js:237


VIDEO_10BIT_SPEC

const VIDEO_10BIT_SPEC: SettingSpec;

Defined in: lib/conditional-settings.js:239


VIDEO_STREAMING_MODE_SPEC

const VIDEO_STREAMING_MODE_SPEC: SettingSpec;

Defined in: lib/conditional-settings.js:241


USE_PAINT_OVER_QUALITY_SPEC

const USE_PAINT_OVER_QUALITY_SPEC: object;

Defined in: lib/conditional-settings.js:250

Paint-over cleans up a still screen at its own quality; it defaults off under Turbo and on without it, JPEG included (a constant rate cleans a still screen up without it too, to the session's quality); a stored choice or an operator's value overrides it. ctx.encoder and ctx.videoStreamingMode carry the encoder and Turbo.

Type Declaration

id
id: string;

Name of the setting in the dashboards.

serverKey
serverKey: string;

Key into server_settings.

storageKey
storageKey: string;

localStorage key for the client's choice.

parse?
parse?: (stored) => any;

Interprets the stored string; identity by default.

Parameters
ParameterType
storedstring
Returns

any

isValid?
isValid?: (value, ctx) => boolean;

Rejects invalid candidates at every rung.

Parameters
ParameterType
valueany
ctxany
Returns

boolean

fallback?
fallback?: any;

Value used when nothing else resolves.

toUi?
toUi?: (serverValue) => any;

Maps the server domain to the UI domain.

Parameters
ParameterType
serverValueany
Returns

any

toServer?
toServer?: (uiValue) => any;

Inverse of toUi; identity by default.

Parameters
ParameterType
uiValueany
Returns

any

serialize?
serialize?: (uiValue) => string;

localStorage form; String by default.

Parameters
ParameterType
uiValueany
Returns

string

propagate?
propagate?: (serverValue, ctx, io) => void;

Pushes a change to the server or the core.

Parameters
ParameterType
serverValueany
ctxany
io{ postSetting: Function; postToCore: Function; }
io.postSettingFunction
io.postToCoreFunction
Returns

void

conditional
conditional: (ctx) => boolean;
Parameters
ParameterType
ctxany
Returns

boolean


USE_CPU_SPEC

const USE_CPU_SPEC: SettingSpec;

Defined in: lib/conditional-settings.js:256


CPU_ENCODE_THREADING_SPEC

const CPU_ENCODE_THREADING_SPEC: SettingSpec;

Defined in: lib/conditional-settings.js:258


FORCE_ALIGNED_RESOLUTION_SPEC

const FORCE_ALIGNED_RESOLUTION_SPEC: SettingSpec;

Defined in: lib/conditional-settings.js:260


RAW_POINTER_MOTION_SPEC

const RAW_POINTER_MOTION_SPEC: object;

Defined in: lib/conditional-settings.js:270

Raw pointer motion under pointer lock: whether the client asks the engine for the deltas ahead of the OS acceleration curve. Off until chosen on macOS (ctx.macDesktop), where the engine grants the option and the curve it removes is what carried a slow hand across the remote screen; a stored choice or an operator value overrides the platform. The core owns it, applying and persisting it on the propagated message.

Type Declaration

id
id: string;

Name of the setting in the dashboards.

serverKey
serverKey: string;

Key into server_settings.

storageKey
storageKey: string;

localStorage key for the client's choice.

parse?
parse?: (stored) => any;

Interprets the stored string; identity by default.

Parameters
ParameterType
storedstring
Returns

any

isValid?
isValid?: (value, ctx) => boolean;

Rejects invalid candidates at every rung.

Parameters
ParameterType
valueany
ctxany
Returns

boolean

fallback?
fallback?: any;

Value used when nothing else resolves.

toUi?
toUi?: (serverValue) => any;

Maps the server domain to the UI domain.

Parameters
ParameterType
serverValueany
Returns

any

toServer?
toServer?: (uiValue) => any;

Inverse of toUi; identity by default.

Parameters
ParameterType
uiValueany
Returns

any

serialize?
serialize?: (uiValue) => string;

localStorage form; String by default.

Parameters
ParameterType
uiValueany
Returns

string

propagate?
propagate?: (serverValue, ctx, io) => void;

Pushes a change to the server or the core.

Parameters
ParameterType
serverValueany
ctxany
io{ postSetting: Function; postToCore: Function; }
io.postSettingFunction
io.postToCoreFunction
Returns

void

conditional
conditional: (ctx) => boolean;
Parameters
ParameterType
ctxany
Returns

boolean


MAC_CMD_AS_CTRL_SPEC

const MAC_CMD_AS_CTRL_SPEC: SettingSpec;

Defined in: lib/conditional-settings.js:282

Whether a macOS Command chord is sent as its Control chord. On unless chosen or set otherwise; only macOS clients read it (ctx.macDesktop decides whether a panel offers it at all). The core owns it, applying and persisting it on the propagated message.

Functions

cpuEncodeThreadingApplies()

function cpuEncodeThreadingApplies(
   encoder, 
   encoderBackends, 
   useCpu, 
   fullColor, 
   tenBit
): boolean;

Defined in: lib/conditional-settings.js:65

Whether the CPU encode threading switch does anything for a session on an encoder: the session codes in software, on a CPU-only encoder (whose stripes it codes one after another), where software is forced on a codec that has a software encoder, where the host encodes the codec in software alone, or where the hardware engine hands a full color or 10-bit stream to its software encoder. A hardware engine has no such threads. Without a backend table it cannot be told, and reads as applying.

Parameters

ParameterTypeDescription
encoderstringEncoder wire value.
encoderBackends{ }The server's encoder_backends payload entry, keyed by codec name.
useCpubooleanWhether software encoding is forced.
fullColorbooleanWhether full color is asked for.
tenBitbooleanWhether 10-bit is asked for.

Returns

boolean


softwareChoiceAvailable()

function softwareChoiceAvailable(encoder, encoderBackends): boolean;

Defined in: lib/conditional-settings.js:88

Whether the software-encoding switch changes anything for an encoder: its codec has both a hardware backend on the server's encode node and a software encoder in its pixelflux build, so the switch moves the session between them. Never for the CPU-only encoders. Without a backend table (a server whose hardware side could not be probed) only H.264 is read as served both ways.

Parameters

ParameterTypeDescription
encoderstringEncoder wire value.
encoderBackends{ }The server's encoder_backends payload entry, keyed by codec name.

Returns

boolean


tenBitStream()

function tenBitStream(
   encoder, 
   encoderBackends, 
   useCpu, 
   fullColor
): object;

Defined in: lib/conditional-settings.js:113

The 10-bit stream an encoder would run on this server, or null where it would stream 8 bits. A session runs on the encode node's engine where the codec has one and software is not forced, and the server hands it to its software encoder where the engine lacks the 4:4:4 a full-color session asks for, or the 10 bits this one does while the software encoder codes them. Each side answers at the chroma it would run: its 4:4:4 where full color is on and it carries that, else 4:2:0. null without a backend table, so the switch is not offered on a guess.

Parameters

ParameterTypeDescription
encoderstringEncoder wire value.
encoderBackends{ }The server's encoder_backends payload entry, keyed by codec name.
useCpubooleanWhether software encoding is forced.
fullColorbooleanWhether full color is on.

Returns

object

The stream's chroma, and whether the software encoder codes it.

fullcolor
fullcolor: boolean;
software
software: boolean;

resolveConditionalSetting()

function resolveConditionalSetting(input): any;

Defined in: lib/conditional-settings.js:141

Resolves one setting to its value in server terms through the module's precedence ladder.

Parameters

ParameterTypeDescription
input{ server: { value: any; locked?: boolean; overridden?: boolean; }; stored: string; parse?: (stored) => any; conditional?: () => any; isValid?: (value) => boolean; }-
input.server{ value: any; locked?: boolean; overridden?: boolean; }The setting's entry in server_settings.
input.server.valueany-
input.server.locked?boolean-
input.server.overridden?boolean-
input.storedstringThe client's stored choice.
input.parse?(stored) => anyInterprets the stored string.
input.conditional?() => anyState-derived default.
input.isValid?(value) => booleanRejects invalid candidates.

Returns

any

The resolved value; undefined without a server entry.


resolveSpec()

function resolveSpec(
   spec, 
   serverSettings, 
   ctx, 
   readStored
): any;

Defined in: lib/conditional-settings.js:162

Resolves a spec to its UI value.

Parameters

ParameterTypeDescription
specSettingSpecThe setting.
serverSettingsanyThe server_settings payload.
ctxanyState the spec's conditional and validator read.
readStored(key) => stringlocalStorage reader.

Returns

any

The value in the UI domain.


isSettingPinned()

function isSettingPinned(
   spec, 
   serverSettings, 
   readStored
): boolean;

Defined in: lib/conditional-settings.js:183

Whether a setting is explicitly pinned, so a dependency change must not re-derive it: the client stored a choice, or the operator overrode or locked it.

Parameters

ParameterTypeDescription
specSettingSpecThe setting.
serverSettingsanyThe server_settings payload.
readStored(key) => stringlocalStorage reader.

Returns

boolean


boolSpec()

function boolSpec(
   key, 
   fallback, 
   propagate
): SettingSpec;

Defined in: lib/conditional-settings.js:226

A spec for a plain boolean setting that carries a server truth. Routing it through the ladder makes the displayed state track the real applied value, so a locked or overridden operator value reaches the toggle. serverKey and storageKey are the same key.

Parameters

ParameterTypeDescription
keystringThe server and storage key.
fallbackbooleanValue when nothing else resolves.
propagate(serverValue, ctx, io) => voidPushes a change.

Returns

SettingSpec


storageKeyForServerKey()

function storageKeyForServerKey(serverKey): string;

Defined in: lib/conditional-settings.js:308

The localStorage key a server setting's client choice lives under, which is what the cores ask "has the user overridden this?" about.

Parameters

ParameterTypeDescription
serverKeystringKey into server_settings.

Returns

string

On this page

InterfacesSettingSpecPropertiesidserverKeystorageKeyparse?ParametersReturnsconditional?ParametersReturnsisValid?ParametersReturnsfallback?toUi?ParametersReturnstoServer?ParametersReturnsserialize?ParametersReturnspropagate?ParametersReturnsVariablesHIDPI_SPECType DeclarationidserverKeystorageKeyparseParametersReturnsconditionalParametersReturnsfallbacktoUiParametersReturnstoServerParametersReturnsserializeParametersReturnspropagateParametersReturnsRATE_CONTROL_SPECType DeclarationidserverKeystorageKeyisValidParametersReturnsfallbackpropagateParametersReturnsUSE_BROWSER_CURSORS_SPECVIDEO_FULLCOLOR_SPECVIDEO_10BIT_SPECVIDEO_STREAMING_MODE_SPECUSE_PAINT_OVER_QUALITY_SPECType DeclarationidserverKeystorageKeyparse?ParametersReturnsisValid?ParametersReturnsfallback?toUi?ParametersReturnstoServer?ParametersReturnsserialize?ParametersReturnspropagate?ParametersReturnsconditionalParametersReturnsUSE_CPU_SPECCPU_ENCODE_THREADING_SPECFORCE_ALIGNED_RESOLUTION_SPECRAW_POINTER_MOTION_SPECType DeclarationidserverKeystorageKeyparse?ParametersReturnsisValid?ParametersReturnsfallback?toUi?ParametersReturnstoServer?ParametersReturnsserialize?ParametersReturnspropagate?ParametersReturnsconditionalParametersReturnsMAC_CMD_AS_CTRL_SPECFunctionscpuEncodeThreadingApplies()ParametersReturnssoftwareChoiceAvailable()ParametersReturnstenBitStream()ParametersReturnsfullcolorsoftwareresolveConditionalSetting()ParametersReturnsresolveSpec()ParametersReturnsisSettingPinned()ParametersReturnsboolSpec()ParametersReturnsstorageKeyForServerKey()ParametersReturns
Edit on GitHub