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
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
| Binding | Form | Declaration or signature | Parameter syntax |
|---|---|---|---|
default | default · class | class ThemeManager | — |
loadAndApplyTheme | function | async function loadAndApplyTheme(options={}) | options={} |
| Callable | Kind | Exact public signature | Parameter syntax |
|---|---|---|---|
loadAndApplyTheme | exported-function | async function loadAndApplyTheme(options={}) | options={} |
| Member | Kind | Exact public declaration | Parameter syntax |
|---|---|---|---|
ThemeManager.constructor | constructor | constructor({appearanceStore=null,skinStore=null,systemAppearance=null,root=null}={}) | {appearanceStore=null,skinStore=null,systemAppearance=null,root=null}={} |
ThemeManager.load | async method | async load() | — |
ThemeManager.apply | method | apply() | — |
ThemeManager.current | method | current() | — |
ThemeManager.setScheme | async method | async setScheme(scheme='system') | scheme='system' |
ThemeManager.saveCustom | async method | async saveCustom(input={}) | input={} |
ThemeManager.activateCustom | async method | async activateCustom() | — |
ThemeManager.preview | method | preview(input={}) | input={} |
ThemeManager.resetCustom | async method | async resetCustom() | — |
ThemeManager.syncSystemAppearance | async method | async syncSystemAppearance() | — |
ThemeManager.emit | method | emit(reason='theme-state-applied') | reason='theme-state-applied' |
ThemeManager.dispose | method | dispose() | — |
ThemeManager.destroy | method | destroy() | — |
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
import {loadAndApplyTheme} from '/arcane/modules/ThemeManager.js';
const {manager,state} = await loadAndApplyTheme();
console.log(state.mode, manager.current());