Capability first · transport second

ThemeBootstrap.js

Reuses the shared presentation owner, loads authoritative preferences, and observes native appearance and existing canonical User readiness without blocking rendering or starting User storage.

SDK 0.97.1Runtime 0.8.12Protocol arcane/1
On this page

Overview

Reuses the shared presentation owner, loads authoritative preferences, and observes native appearance and existing canonical User readiness without blocking rendering or starting User storage.

  • Artifact
    ThemeBootstrap.js · esm
  • Classification
    public first party
  • Availability
    Browser/native hybrid
  • Normalization
    Theme state normalized; storage/native errors mixed.

Import and lifecycle

JavaScript
import * as module from '/node_modules/arcane-os/runtime/arcane/modules/ThemeBootstrap.js';

Import reuses ThemePresentation and starts one shared authoritative preference load/apply promise, publishing globalThis.arcaneThemeReady. Module-graph evaluation may follow first paint; the classic ThemePresentation script after app-id and before CSS provides the early entry. Shared subscriptions observe appearance.changed and user-entity-loaded with already-ready User replay; bootstrap does not start a separate profile lifecycle or block rendering. Initial failures are warned and converted to an error-bearing result.

Application-facing behavior: bootstrapArcaneTheme(), disposeArcaneThemeBootstrap(), arcaneThemeReady, and default ready promise. Shared bootstrap replays an already-ready User. In native hosts it independently forwards computed --background/--text-color through Arcane.window.setTheme, observing shared theme events, root/body presentation attributes, stylesheets, device scheme and page restoration; browser CSS resolution retains alpha and converts modern colors to sRGB. Disposal releases appearance/user/theme subscriptions, native sampling observers and listeners, and pending window requests. Ordinary browsers remain silent. Presentation cache is nonauthoritative; use classic ThemePresentation after app-id and before CSS for early restoration.

Protocol and host implementation

ThemeManager + host Arcane.events projected once through the per-realm globalThis.arcaneEvents authority This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

BindingFormDeclaration or signatureParameter syntax
bootstrapArcaneThemefunctionfunction bootstrapArcaneTheme(options={})options={}
disposeArcaneThemeBootstrapfunctionfunction disposeArcaneThemeBootstrap()—
arcaneThemeReadyvariable · valuevariable arcaneThemeReady—
defaultdefault · valuevariable default—
CallableKindExact public signatureParameter syntax
bootstrapArcaneThemeexported-functionfunction bootstrapArcaneTheme(options={})options={}

Parameter meanings and results

bootstrapArcaneTheme(options={}) returns Promise<{manager,state}|{manager:null,state:null,error}>. Empty options reuse the shared promise/listeners. arcaneThemeReady and the default export are that promise. disposeArcaneThemeBootstrap removes both appearance and user-ready subscriptions.

Events, side effects, and errors

Source-literal CustomEvent dispatches

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

Lifecycle and event flow

  • Consumes Core appearance.changed and canonical user-entity-loaded; resulting ThemeManager work may emit global arcane-theme-change.

Direct coded failures

This artifact directly assigns no stable coded failure.

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • Initial load errors are contained in the resolved error object.
  • Appearance reload, user skin, and presentation-cache errors are logged without blocking page rendering.

Availability and capabilities

Browser/native hybrid. Theme state normalized; storage/native errors mixed.

Theme load may use preferences.read and appearance.read; persistence/application may require preferences.write and appearance.write. Arcane.events subscription grants no capability.

Contract example

JavaScript
import arcaneThemeReady,{bootstrapArcaneTheme} from '/node_modules/arcane-os/runtime/arcane/modules/ThemeBootstrap.js';

console.log((await arcaneThemeReady).state);
console.log((await bootstrapArcaneTheme()).state);