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:
- locked server value: the operator forces it, the client cannot override;
- explicit client choice, from localStorage, which must satisfy
isValid; - explicit server choice, a CLI or environment override, which must
satisfy
isValid; - conditional default, derived from other state, which must satisfy
isValid; - 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
| Parameter | Type |
|---|---|
stored | string |
Returns
any
conditional?
conditional?: (ctx) => any;Defined in: lib/conditional-settings.js:34
State-derived default, or
undefined when the state implies nothing.
Parameters
| Parameter | Type |
|---|---|
ctx | any |
Returns
any
isValid?
isValid?: (value, ctx) => boolean;Defined in: lib/conditional-settings.js:36
Rejects invalid candidates at every rung.
Parameters
| Parameter | Type |
|---|---|
value | any |
ctx | any |
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
| Parameter | Type |
|---|---|
serverValue | any |
Returns
any
toServer?
toServer?: (uiValue) => any;Defined in: lib/conditional-settings.js:41
Inverse of toUi; identity by
default.
Parameters
| Parameter | Type |
|---|---|
uiValue | any |
Returns
any
serialize?
serialize?: (uiValue) => string;Defined in: lib/conditional-settings.js:43
localStorage form; String
by default.
Parameters
| Parameter | Type |
|---|---|
uiValue | any |
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
| Parameter | Type |
|---|---|
serverValue | any |
ctx | any |
io | { postSetting: Function; postToCore: Function; } |
io.postSetting | Function |
io.postToCore | Function |
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
| Parameter | Type |
|---|---|
v | any |
Returns
boolean
conditional
conditional: (ctx) => boolean;Parameters
| Parameter | Type |
|---|---|
ctx | any |
Returns
boolean
fallback
fallback: boolean = false;toUi
toUi: (cssScaling) => boolean;Parameters
| Parameter | Type |
|---|---|
cssScaling | any |
Returns
boolean
toServer
toServer: (hidpi) => boolean;Parameters
| Parameter | Type |
|---|---|
hidpi | any |
Returns
boolean
serialize
serialize: (hidpi) => string;Parameters
| Parameter | Type |
|---|---|
hidpi | any |
Returns
string
propagate
propagate: (cssScaling, _ctx, io) => any;Parameters
| Parameter | Type |
|---|---|
cssScaling | any |
_ctx | any |
io | any |
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
| Parameter | Type |
|---|---|
v | any |
ctx | any |
Returns
any
fallback
fallback: string = "cbr";propagate
propagate: (mode, _ctx, io) => any;Parameters
| Parameter | Type |
|---|---|
mode | any |
_ctx | any |
io | any |
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
| Parameter | Type |
|---|---|
stored | string |
Returns
any
isValid?
isValid?: (value, ctx) => boolean;Rejects invalid candidates at every rung.
Parameters
| Parameter | Type |
|---|---|
value | any |
ctx | any |
Returns
boolean
fallback?
fallback?: any;Value used when nothing else resolves.
toUi?
toUi?: (serverValue) => any;Maps the server domain to the UI domain.
Parameters
| Parameter | Type |
|---|---|
serverValue | any |
Returns
any
toServer?
toServer?: (uiValue) => any;Inverse of toUi; identity by
default.
Parameters
| Parameter | Type |
|---|---|
uiValue | any |
Returns
any
serialize?
serialize?: (uiValue) => string;localStorage form; String
by default.
Parameters
| Parameter | Type |
|---|---|
uiValue | any |
Returns
string
propagate?
propagate?: (serverValue, ctx, io) => void;Pushes a change to the server or the core.
Parameters
| Parameter | Type |
|---|---|
serverValue | any |
ctx | any |
io | { postSetting: Function; postToCore: Function; } |
io.postSetting | Function |
io.postToCore | Function |
Returns
void
conditional
conditional: (ctx) => boolean;Parameters
| Parameter | Type |
|---|---|
ctx | any |
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
| Parameter | Type |
|---|---|
stored | string |
Returns
any
isValid?
isValid?: (value, ctx) => boolean;Rejects invalid candidates at every rung.
Parameters
| Parameter | Type |
|---|---|
value | any |
ctx | any |
Returns
boolean
fallback?
fallback?: any;Value used when nothing else resolves.
toUi?
toUi?: (serverValue) => any;Maps the server domain to the UI domain.
Parameters
| Parameter | Type |
|---|---|
serverValue | any |
Returns
any
toServer?
toServer?: (uiValue) => any;Inverse of toUi; identity by
default.
Parameters
| Parameter | Type |
|---|---|
uiValue | any |
Returns
any
serialize?
serialize?: (uiValue) => string;localStorage form; String
by default.
Parameters
| Parameter | Type |
|---|---|
uiValue | any |
Returns
string
propagate?
propagate?: (serverValue, ctx, io) => void;Pushes a change to the server or the core.
Parameters
| Parameter | Type |
|---|---|
serverValue | any |
ctx | any |
io | { postSetting: Function; postToCore: Function; } |
io.postSetting | Function |
io.postToCore | Function |
Returns
void
conditional
conditional: (ctx) => boolean;Parameters
| Parameter | Type |
|---|---|
ctx | any |
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
| Parameter | Type | Description |
|---|---|---|
encoder | string | Encoder wire value. |
encoderBackends | { } | The server's encoder_backends payload entry, keyed by codec name. |
useCpu | boolean | Whether software encoding is forced. |
fullColor | boolean | Whether full color is asked for. |
tenBit | boolean | Whether 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
| Parameter | Type | Description |
|---|---|---|
encoder | string | Encoder 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
| Parameter | Type | Description |
|---|---|---|
encoder | string | Encoder wire value. |
encoderBackends | { } | The server's encoder_backends payload entry, keyed by codec name. |
useCpu | boolean | Whether software encoding is forced. |
fullColor | boolean | Whether 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
| Parameter | Type | Description |
|---|---|---|
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.value | any | - |
input.server.locked? | boolean | - |
input.server.overridden? | boolean | - |
input.stored | string | The client's stored choice. |
input.parse? | (stored) => any | Interprets the stored string. |
input.conditional? | () => any | State-derived default. |
input.isValid? | (value) => boolean | Rejects 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
| Parameter | Type | Description |
|---|---|---|
spec | SettingSpec | The setting. |
serverSettings | any | The server_settings payload. |
ctx | any | State the spec's conditional and validator read. |
readStored | (key) => string | localStorage 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
| Parameter | Type | Description |
|---|---|---|
spec | SettingSpec | The setting. |
serverSettings | any | The server_settings payload. |
readStored | (key) => string | localStorage 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
| Parameter | Type | Description |
|---|---|---|
key | string | The server and storage key. |
fallback | boolean | Value when nothing else resolves. |
propagate | (serverValue, ctx, io) => void | Pushes a change. |
Returns
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
| Parameter | Type | Description |
|---|---|---|
serverKey | string | Key into server_settings. |
Returns
string