Capability first · transport second

ThemePresentation.js

Restores app-scoped presentation before CSS and owns complete skin-class application without starting profile storage.

SDK 0.97.1Runtime 0.8.12Protocol arcane/1
On this page

Overview

Restores app-scoped presentation before CSS and owns complete skin-class application without starting profile storage.

  • Artifact
    ThemePresentation.js · classic-script
  • Classification
    public first party
  • Availability
    Browser / native WebView classic script
  • Normalization
    Synchronous presentation only; complete strings and numeric class text remain usable, cache failures preserve rendering, and authoritative profile and appearance loads reconcile the cache.

Import and lifecycle

HTML
<script src="/node_modules/arcane-os/runtime/arcane/modules/ThemePresentation.js"></script>

First classic evaluation installs or reuses globalThis.arcaneThemePresentation and synchronously restores the app-scoped presentation before following CSS. Place after the existing app-id declaration with no type=module, async, or defer. No imports, User/OPFS/model startup, page hiding, polling, profile snapshot, or migration. Root colors apply before body exists; one DOMContentLoaded callback supplies the latest complete skin classes. Cache misses leave ordinary first-visit presentation; module-only use can evaluate after first paint.

Application-facing behavior: No ESM exports; globalThis.arcaneThemePresentation with applyUserSkin(skin,{root?,body?,cache?}) returning palette|null, remember(fields,root?) returning boolean, restore(root?) returning cached record ({} on miss) or null when unavailable/failed, and reportError(message,error). Classic script runs after the existing app-id declaration and before CSS without type=module, async, or defer; first evaluation restores automatically. Cache fields: skin, palette, appearance:{colorScheme,density,reduceMotion,fontSize}, customProperties (Theme-owned applied CSS map or null). Complete Error goes to console.warn initially and shared logging after ThemeManager import. No User import, OPFS, model wait, profile snapshot, unrelated inline style capture, or migration; missing cache cannot supply an unloaded profile skin.

Protocol and host implementation

DOM and optional application-scoped localStorage This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

This artifact has no ESM bindings. Its public load, global, asset, or worker contract is listed below.

CallableKindExact public signatureParameter syntax
arcaneThemePresentation.applyUserSkinglobal-memberfunction applyUserSkin(skin,{ root=globalThis.document?.documentElement, body=(root?.ownerDocument||globalThis.document)?.body, cache=true }={})skin,{ root=globalThis.document?.documentElement, body=(root?.ownerDocument||globalThis.document)?.body, cache=true }={}
arcaneThemePresentation.rememberglobal-memberfunction remember(fields,root=globalThis.document?.documentElement)fields,root=globalThis.document?.documentElement
arcaneThemePresentation.restoreglobal-memberfunction restore(root=globalThis.document?.documentElement)root=globalThis.document?.documentElement
arcaneThemePresentation.reportErrorglobal-memberfunction reportError(message,error)message,error
MemberKindExact public declarationParameter syntax
arcaneThemePresentation.applyUserSkinstatic global-methodfunction applyUserSkin(skin,{ root=globalThis.document?.documentElement, body=(root?.ownerDocument||globalThis.document)?.body, cache=true }={})skin,{ root=globalThis.document?.documentElement, body=(root?.ownerDocument||globalThis.document)?.body, cache=true }={}
arcaneThemePresentation.rememberstatic global-methodfunction remember(fields,root=globalThis.document?.documentElement)fields,root=globalThis.document?.documentElement
arcaneThemePresentation.restorestatic global-methodfunction restore(root=globalThis.document?.documentElement)root=globalThis.document?.documentElement
arcaneThemePresentation.reportErrorstatic global-methodfunction reportError(message,error)message,error

Parameter meanings and results

No ESM exports. Global applyUserSkin(skin,{root?,body?,cache=true}={}) returns selected palette or null for falsy skin/missing root, preserving independent body classes and complete supplied strings; numbers cache their complete class text. remember(fields,root=document.documentElement) returns whether its write succeeded. restore(root=document.documentElement) returns cached record, {} on cache miss, or null when unavailable/failed. reportError(message,error) initially calls console.warn and is connected to arcaneLogging.warn by ThemeManager. Cache fields are skin, palette, appearance:{colorScheme,density,reduceMotion,fontSize}, and customProperties (applied Theme-owned CSS property map or null), under arcane.apps.<application-id>:arcane.theme.presentation. Existing profile readiness and authoritative appearance preferences reconcile this presentation-only record.

Events, side effects, and errors

Source-literal CustomEvent dispatches

No source-literal CustomEvent dispatch is part of this artifact.

Lifecycle and event flow

  • Consumes one native DOMContentLoaded only when complete skin classes were applied before body exists; no semantic event or User lifecycle is started.

Direct coded failures

This artifact directly assigns no stable coded failure.

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • Missing application identity or storage skips the cache.
  • Conflicting document identities, storage failures, and malformed JSON log the complete Error without blocking rendering. A later authoritative write can replace malformed cached JSON.

Availability and capabilities

Browser / native WebView classic script. Synchronous presentation only; complete strings and numeric class text remain usable, cache failures preserve rendering, and authoritative profile and appearance loads reconcile the cache.

None; DOM and optional application-scoped localStorage only.

Load example

HTML
<meta name="arcane-app-id" content="dragon-observatory">
<script src="/node_modules/arcane-os/runtime/arcane/modules/ThemePresentation.js"></script>
<link rel="stylesheet" href="/arcane/css/theme.css">
<script type="module" src="/node_modules/arcane-os/runtime/arcane/modules/ThemeBootstrap.js"></script>

No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.