English
core/platform/platform.ts
Generated from the exports of core/platform/platform.ts · npm run docs:gen
Compatibility by operating system (PLAN-V2 §2.6): one type and one decision function for steps, quests, store items and server executors. A value is either the same for every system or given per system (PerOS); a thing says which systems it supports (Support); the server describes the machine it runs on (Host).
Standards that cite this file: Platform support (per OS, local or hosted)
Exports
OS type
ts
type OS = "macos" | "linux" | "windows";OSES const
ts
const OSES: readonly OS[]Arch type
ts
type Arch = "arm64" | "x64";ARCHES const
ts
const ARCHES: readonly Arch[]Platform interface
ts
interface Platform { os: OS; arch?: Arch[]; min?: string /* minimal OS version, dotted */ }PerOS type
One value for every system, or one value per system.
ts
type PerOS<T> = T | Partial<Record<OS, T>>;Need type
ts
type Need = "gui" | "audio" | "gpu" | "keychain" | "sudo" | "terminal" | "local-device";NEEDS const
ts
const NEEDS: readonly Need[]LOCAL_ONLY_NEEDS const
Needs a hosted world can never offer: a thing that has one of them cannot be "ok" when hosted.
ts
const LOCAL_ONLY_NEEDS: readonly Need[]Support interface
ts
interface Support {
/** Not empty; a single element means "only on this system", and is shown as such. */
platforms: Platform[];
/** Default: "ok" when linux is listed and needs is empty, else "no". */
hosted?: "ok" | "limited" | "no";
needs?: Need[];
notes?: Partial<Record<OS, Text>>;
}Host interface
The machine the game server runs on, as /api/game describes it.
ts
interface Host {
os: OS; arch: Arch; version?: string; mode: "local" | "hosted"; has: Need[];
/** Hosted only: the trial ("free") or a kept world ("paid"). Absent: unknown. */
tier?: "free" | "paid";
/** The marketing axis this world was opened from (a closed list, checked by core/axes once it exists). */
axis?: string;
/** Hosted: the experiment arm drawn by the control plane (WORLD_ARM), "control" by default. */
arm?: string;
/** Hosted: the store item of a store landing (WORLD_ITEM): the world opens on that item. */
item?: string;
/** What the server measured of the machine (core/platform/resources.ts): cores, memory, free disk, GPU. Absent: unknown. */
machine?: Measured;
}HostCond type
Where a beat, a tour stop, a step or a choice applies (ONBOARDING-V2 §4.3). Absent = everywhere. hosted-free holds only when the tier is known to be "free", hosted-paid only when it is "paid": an unknown tier shows neither the trial's text nor the kept world's.
ts
type HostCond = "local" | "hosted" | "hosted-free" | "hosted-paid";HOST_CONDS const
ts
const HOST_CONDS: readonly HostCond[]isHostCond const
ts
const isHostCond = (x: unknown): x is HostCond => …onHost function
Does this condition hold on this host? No host described = local (the 0.1 default host).
ts
function onHost(c: HostCond | undefined | null, h: Host | undefined | null): booleanRefHostId type
The reference hosts, shared by the client (?host=), the validators and the tests.
ts
type RefHostId = "local" | "hosted-free" | "hosted-paid";REF_HOST_IDS const
ts
const REF_HOST_IDS: readonly RefHostId[]REF_HOSTS const
ts
const REF_HOSTS: Readonly<Record<RefHostId, Host>>refHost function
?host= values of the demo and the tests: "hosted" is the free tier.
ts
function refHost(id: string | null | undefined): Host | undefinedUnsupported type
ts
type Unsupported = { ok: false; reason: "os" | "arch" | "version" | "hosted" | "needs"; detail: string };Supported type
ts
type Supported = { ok: true } | Unsupported;compareVersions function
Compares dotted versions: negative when a < b. Missing parts count as 0; non-numeric parts as 0.
ts
function compareVersions(a: string, b: string): numberhostedLevel function
The hosted level of a support, with its default.
ts
function hostedLevel(s: Support): "ok" | "limited" | "no"supports function
Can this thing run on this host? No support declared means "everywhere" (0.1 behaviour).
ts
function supports(s: Support | undefined | null, h: Host): SupportedisPerOSTable function
True when a PerOS value is written as a table by system (and not as one value for all).
ts
function isPerOSTable(v: unknown): v is Partial<Record<OS, unknown>>pick function
The value for this system: the single value, or the one of its row. Generalises command() of 0.1.
ts
function pick<T>(v: PerOS<T> | null | undefined, os: OS): T | nullcheckSupport function
Problems of a support declaration (empty = valid). perOS lists the PerOS values of the same thing (install, verify, scripts…): written as a table, each must cover exactly the declared systems.
ts
function checkSupport(s: unknown, perOS: Record<string, unknown> = {}): string[]hostOf function
The host of a Node process (used by the server and by tests).
ts
function hostOf(platform: string, arch: string, mode: "local" | "hosted", has: Need[], version?: string): Host