Skip to content

Latest commit

 

History

History
144 lines (120 loc) · 7.66 KB

WEBUI_THEMES_V1.md

File metadata and controls

144 lines (120 loc) · 7.66 KB

WebUI themes v1

Settings supports Chinese (zh-CN), English (en) and Japanese (ja). Language is stored locally by the browser and in software preferences. Module-provided labels remain the responsibility of the module author.

Theme ZIPs have files directly at their root:

obliviousmic.theme.json
style.css
LICENSE
NOTICE       (optional)
README.md    (optional)
settings.json (optional, declared with "settings": "settings.json")
assets/      (optional PNG/JPEG/WebP/static SVG/WOFF/WOFF2 files)

Example manifest:

{
  "theme_api": 1,
  "id": "my-theme",
  "version": "1.0.0",
  "name": "My theme",
  "author": "Your name",
  "license": "Apache-2.0",
  "style": "style.css",
  "mode": "dark"
}

CSS can change layout or override the --om-* variables used by the base UI. Useful tokens: --om-background, --om-foreground, --om-accent, --om-on-accent, --om-accent-hover, --om-sidebar, --om-surface, --om-border, --om-muted, --om-danger, --om-color-scheme. The packaged Night theme lists every token; copy it to start a complete theme. url("assets/image.png") is rewritten to the authenticated installed asset URL. Imports, external URLs, executable content, symlinks, traversal and archives exceeding the limits are rejected. Themes carry their own license; theme installation grants no rights to unrelated assets.

SVG decorations are limited to namespaced svg, g, path, rect, circle, ellipse, line, polyline and polygon, with validated numeric geometry, solid hex colors, basic transforms and paint attributes. Text, scripts, styles, links, embedded raster images, animation, foreign content, entities and XML processing instructions are rejected. The file limit is 256 KiB / 2048 elements; SVG responses also carry a restrictive CSP and nosniff. Theme cards can use validated SVG previews. Configurable background images use PNG/JPEG/WebP.

The Night theme (Ink Violet), the Daylight theme and the optional Masquerade theme are installed through the same ZIP validation mechanism, from packaged source files. They cannot be deleted. Custom versions coexist; switching is global to this installation and persists across restart, independently of audio profiles. Switch away from a theme to uninstall it. Installation and removal roll back if the index cannot be saved. A damaged selected stylesheet falls back to Night on restart. Audio data and graphs are never touched by theme operations.

Masquerade is an Easter egg: a fresh installation lists only Night and Daylight. Click the sidebar ObliviousMic emblem five consecutive times (no gap longer than 1.2 seconds) to unlock and immediately apply Masquerade. Clicking elsewhere or leaving the window resets the sequence. The emblem also accepts Enter/Space. Discovery is stored in themes-data/unlocked.json, independently of the selected theme and appearance settings, and survives browser/framework restarts. Existing Masquerade selections remain visible; switching away preserves their discovery. The authenticated POST /api/v1/themes/unlock-masquerade selects the newest verified packaged version. This is a UI discovery feature, not an access boundary for the bundled CSS/assets.

Daylight 1.2.0 (日间主题) uses an oatmeal beige background, cream cards, coffee-colored text and caramel controls. Warm sage audio connections, plum text connections and ochre controls retain their distinct meanings. Graph edge colors can use --om-edge-audio, --om-edge-metadata and --om-edge-control; themes without these tokens retain the original audio/text/control colors.

Night 1.1.0 uses GitHub-inspired charcoal surfaces, neutral gray dividers, blue actions and high-contrast text. Green/red status lights keep their state meanings; audio, text and control connections use cyan, purple and amber respectively.

When a newer packaged theme version is installed at startup, an existing selection of that theme moves to the newer version. Other selections and the default remain unchanged; older packaged files remain available to open pages.

Limits: 8 MiB archive/expanded files, 2048 members, 256 KiB CSS. Only the compiled stylesheet and listed passive assets are served, with content hashes checked. ZIP themes contain presentation code, so install styles from sources you trust.

API: GET/POST /api/v1/themes, PUT /api/v1/themes/selected, DELETE /api/v1/themes/{id}/{version}, authenticated GET /api/v1/themes/{id}/{version}/served.css and /assets/{file}.

First paint and appearance settings

The server inserts a render-blocking /appearance.css link after the base UI styles in both / and /index.html, along with theme identity, mode and settings revision. The selected style therefore loads before React paints, without waiting for login, audio metrics or the workspace API. /appearance.css exposes only the selected presentation CSS, uses no-store, and includes saved appearance values. Theme management and all mutations remain authenticated. The Vite development server does not render this Python-served HTML; use the built WebUI to test first paint.

Every installed theme (including existing CSS-only packages) has framework controls for colors, font family/size, desktop sidebar/content width, desktop card columns, corners, minimum control height, transition duration and packaged background images. Null means inherit the package value. Mobile breakpoints retain their narrow layout.

Theme settings persist under themes-data/settings/{theme-id}.json, separately from immutable installed files, and are shared across versions of the same theme. Values no longer valid for a new version fall back to its declared defaults. Preview is temporary and never writes settings; leaving Settings cancels it. Saving appearance does not stop devices or apply an audio graph.

Optional manifest fields: description (text), display_names (language-to-name map, English fallback), preview (packaged PNG/JPEG/WebP path under assets/), and settings: "settings.json". These are additive Theme API 1 fields.

settings.json declares groups, each with id, localized label and fields. Each field declares id, localized label, type, variable (--om-*), and default (nullable). Supported types: color (#RRGGBB/#RRGGBBAA), number (minimum/maximum/step/unit), select (options with value/label), toggle, image (packaged images), and text (quoted CSS string, at most 120 characters). Numbers support px, rem, %, ms or no unit. Select values are bounded CSS tokens, not external URLs. Group/field IDs and CSS variables must be unique, including framework controls. At most 12 groups and 24 fields per group; the declaration file must be at most 64 KiB. Settings are validated before installation and again before preview/save. Assets retain integrity verification.

Stable layout hooks: [data-ui="sidebar"], main, header, page-heading, installed-modules, graph-editor, graph-canvas, module-palette, theme-settings (each uses the same data-ui attribute). Authors may restyle these and existing CSS classes, using declared CSS variables for configurable effects. Theme files do not replace React components or execute scripts. This borrows Halo's declarative settings concept; Halo templates/YAML/Java plugins are not directly loadable.

Additional authenticated APIs:

  • GET /api/v1/themes/{id}/{version}/settings: groups, values, images and revision.
  • PUT .../settings: { "values": { ... }, "expected_revision": N }; {} values restore declared defaults. Conflicting revisions are rejected.
  • POST .../preview: { "values": { ... } } returns variable CSS without saving.

See Chinese authoring guide and examples/themes/studio/ for a complete installable example.