Skip to content

Frontend API

Your frontend module must export a setup(ctx) function. It receives a SpindleFrontendContext for host DOM rendering, events, backend communication, and opt-in sandbox frames.

import type { SpindleFrontendContext } from 'lumiverse-spindle-types'

export function setup(ctx: SpindleFrontendContext) {
  // Your initialization code here

  // Return a cleanup function (optional)
  return () => {
    ctx.dom.cleanup()
  }
}

Alternatively, export a teardown() function:

export function setup(ctx: SpindleFrontendContext) {
  // init
}

export function teardown() {
  // cleanup
}

API Surface

Frontend UI can follow two supported rendering paths:

  • direct host rendering through ctx.dom.* and ctx.ui.*
  • isolated iframe rendering through ctx.dom.createSandboxFrame(...) and ctx.messages.renderWidget(...)
Category Permission Description
Client Detection Free Identify browser tabs, PWAs, desktop apps, and iOS/Android apps, with native bridge discovery
UUIDs Free Generate UUID v4 or v7 strings synchronously, including over plain HTTP
Chat Composer Free (send needs generation) Read, replace or insert the chat draft and send it through the host's send path
DOM Helper Free Inject sanitized HTML/CSS in the host DOM, target specific chat messages with virtualizer-safe replay, and create host-managed sandbox frames
UI Event Helpers Free Keyboard/Drawer/Settings state and DOM Action delegation
HTML Islands Free Auto-isolation of styled HTML in messages, and how to opt out
Events Free Subscribe to WebSocket events, emit custom events
UI Placement Varies Drawer tabs, float widgets, dock panels, modals, context menus, input bar actions
Shared Components Free Mount Lumiverse's first-party React components — model picker, form atoms, searchable selects, pagination, and the native Loom block editor — into extension-owned DOM
Backend Communication Free Send/receive messages to/from backend worker
Frontend Process Lifecycle Free Register backend-spawned frontend process handlers
Message Tags Free Intercept custom XML tags in chat messages
Display Resolver Free Resolve message display (macros, format, regex) in the browser for chats your extension owns
Message Previews Free Render an active-chat swipe or source range through the native display pipeline in a preview-only host surface
File Uploads Free Open file picker and read selected files
Theme Authoring Varies Work with native theme assets, safe .lumitheme drafts, the component/variable catalog, and native Theme Editor navigation
Connection Profiles Free (switching the LLM profile needs generation) List the user's LLM, image, TTS, STT, embedding, and Decision profiles without credentials
Speech-to-text media (discovery is free) Record or transcribe audio through the host speech stack, including bundled on-device Whistle
Text-to-speech media (playback state is free) Speak text or chat messages through the user's TTS connections, and know when host TTS is playing
System audio system_audio (discovery is free) Combined and optional stereo spectrum and loudness of the sound the device is playing; analysis only, with explicit host consent (optionally remembered) and a host indicator while it runs. Needs a native desktop adapter