This document summarises the key runtime and typing APIs exposed by ignite-element. It complements the inline TypeScript declarations and the example applications.
Creates a registration function for wiring adapters to custom elements.
| Option | Type | Description |
|---|---|---|
source |
State library source (machine, actor, slice, store, observable, factory) | Determines the adapter and whether state is shared or isolated. Inference covers XState, Redux Toolkit, and MobX. |
| Option | Type | Description |
|---|---|---|
states |
(snapshot) => Record<string, unknown> |
Derive façade data from the adapter snapshot. Runs once per adapter instance. |
commands |
(actor) => Record<string, (...args: any[]) => unknown> |
Expose imperative helpers bound to the adapter’s command actor (dispatch/send/store). |
cleanup |
boolean |
Defaults to true. When false, disables the reference-counted shutdown for shared adapters so the host can stop them manually. |
(tag: string, renderer: ComponentRenderer) => void
ComponentRenderercan be a function, an object withrender(args), or a class whose instances implementrender(args).- Render args merge the original adapter state/metadata with the derived façade values.
- TypeScript infers the render argument shape from the callbacks you provide—no extra helper types required.
Lower-level factory used by igniteCore. Accepts a callback that returns an adapter and optional configuration:
scope: forceStateScope.SharedorStateScope.Isolatedwhen auto-detection is not desired.createAdditionalArgs(adapter): supply extra props that should always appear in render arguments.cleanup: defaults totrue. When enabled, shared adapters are reference-counted and stopped once the last element disconnects. Set tofalseif you want to manage shutdown manually.
It returns a (tag, renderer) function identical to the one from igniteCore.
Registers application-wide defaults at module evaluation time. Typical usage lives in ignite.config.ts:
import { defineIgniteConfig } from "ignite-element";
export default defineIgniteConfig({
styles: new URL("./styles.css", import.meta.url).href, // formerly globalStyles
renderer: "ignite-jsx", // or "lit"
strategy: "diff", // optional, selects the diffing renderer once available
logging: "warn", // optional: "off" | "warn" | "debug"
});stylesmirrorssetGlobalStylesbut runs once when the module is imported.globalStylesremains as a deprecated alias.rendererselects the default renderer ("ignite-jsx"by default). Supplying"lit"switches back to the template literal strategy. Per-component overrides are still possible via the factorycreateRenderStrategyoption.strategyis reserved for renderer strategy selection (diff vs replace) when multiple Ignite JSX strategies are available.loggingcontrols renderer/config debug output ("off"|"warn"|"debug").
Bundler plugins (igniteConfigVitePlugin, IgniteConfigWebpackPlugin) are available to auto-import the config file when present.
setGlobalStyles(href: string): injects a stylesheet once and reuses it across components.injectStyles(element: HTMLElement, css: string): for advanced use-cases requiring manual style injection.
- Adapter inference for XState, Redux, and MobX sources.
- Facade callbacks for derived state and command helpers.
- Ignite JSX renderer strategy and tooling.
-
ignite.config.(ts|js)for centralised styling defaults.
For the full acceptance criteria and future enhancements, see plans/ACCEPTANCE_CRITERIA.md.