Capability first · transport second

ThemeManager.js

Loads, applies, previews, saves, resets, and synchronizes semantic Arcane themes.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
On this page

Overview

Loads, applies, previews, saves, resets, and synchronizes semantic Arcane themes.

  • Artifact
    ThemeManager.js · esm
  • Classification
    public first party
  • Availability
    Browser/native hybrid
  • Normalization
    Theme values/events normalized; storage/native failures mixed.

Import and lifecycle

JavaScript
import * as module from '/arcane/modules/ThemeManager.js';

Construction binds stores and appearance bridge without I/O. load() reads preferences and applies DOM state. Set/save/activate/reset methods persist settings, mutate root presentation, call native appearance, and emit. preview() mutates root without persistence.

Application-facing behavior: default ThemeManager, loadAndApplyTheme(); scheme/custom/system APIs and arcane-theme-change.

Protocol and host implementation

PreferenceStore, DOM, Arcane.appearance This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

BindingFormDeclaration or signatureParameter syntax
defaultdefault · classclass ThemeManager
loadAndApplyThemefunctionasync function loadAndApplyTheme(options={})options={}
CallableKindExact public signatureParameter syntax
loadAndApplyThemeexported-functionasync function loadAndApplyTheme(options={})options={}
MemberKindExact public declarationParameter syntax
ThemeManager.constructorconstructorconstructor({appearanceStore=null,skinStore=null,systemAppearance=null,root=null}={}){appearanceStore=null,skinStore=null,systemAppearance=null,root=null}={}
ThemeManager.loadasync methodasync load()
ThemeManager.applymethodapply()
ThemeManager.currentmethodcurrent()
ThemeManager.setSchemeasync methodasync setScheme(scheme='system')scheme='system'
ThemeManager.saveCustomasync methodasync saveCustom(input={})input={}
ThemeManager.activateCustomasync methodasync activateCustom()
ThemeManager.previewmethodpreview(input={})input={}
ThemeManager.resetCustomasync methodasync resetCustom()
ThemeManager.syncSystemAppearanceasync methodasync syncSystemAppearance()
ThemeManager.emitmethodemit(reason='theme-state-applied')reason='theme-state-applied'
ThemeManager.disposemethoddispose()
ThemeManager.destroymethoddestroy()

Parameter meanings and results

new ThemeManager({appearanceStore?,skinStore?,systemAppearance?,root?}); load(), current(), apply(), setScheme(), saveCustom(), activateCustom(), preview(), resetCustom(), syncSystemAppearance(); loadAndApplyTheme(options) resolves {manager,state}.

Events, side effects, and errors

Source-literal CustomEvent dispatches

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

Lifecycle and event flow

  • Global arcane-theme-change with current state after persisted changes.

Direct coded failures

This artifact directly assigns no stable coded failure.

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • Theme validation and preference/storage/native failures propagate.
  • Invalid stored custom theme is contained as null during load.

Availability and capabilities

Browser/native hybrid. Theme values/events normalized; storage/native failures mixed.

Native preference reads/writes require preferences.read/preferences.write; system synchronization requires appearance.write, with related reads under appearance.read. Browser/local adapters need no Core.

Contract example

JavaScript
import {loadAndApplyTheme} from '/arcane/modules/ThemeManager.js';

const {manager,state} = await loadAndApplyTheme();
console.log(state.mode, manager.current());