runtime6 plugins11 API members
zRuntime
Client-side utility compiler, shorthand expander, and plugin engine for 0build.
API & Events
window.zRuntime API
| Property / Method | Kind | Signature | Description |
|---|---|---|---|
zRuntime.debug | config | boolean (default: false) | Boolean flag enabling per-plugin diagnostics in the browser console during development. |
zRuntime.customRules | config | Rule[] | Array of custom Rule definitions merged ahead of style generation (matching selectors replace built-ins). |
zRuntime.safelist | config | (string | SafelistDescriptor)[] | Array of class strings or descriptor objects to pre-generate even when absent from the initial DOM. |
zRuntime.refresh | method | () => void | Clears the internal rule cache and runs style generation from scratch. |
zRuntime.regenerate | method | () => void | Re-runs style generation while preserving the existing rule cache. |
zRuntime.getCache | method | () => Map<string, CssRule> | Returns the internal Map of compiled CSS rules keyed by class, state, theme, and breakpoint. |
zRuntime.getRules | method | () => Rule[] | Returns the merged array of active built-in and custom Rule definitions. |
zRuntime.decoder | helper | function | Parses a raw utility class token into a structured ParsedClass descriptor. |
zRuntime.encoder | helper | function | Serializes a ParsedClass descriptor back into a utility class token string. |
zRuntime.escaper | helper | function | Escapes special CSS selector characters (such as :, [, ], /) for generated rules. |
zRuntime.variable | helper | function | Computes the expected CSS custom property name for a class, breakpoint, theme, and state. |
DOM Events
| Event | Description |
|---|---|
z-runtime:init | Dispatched on document when the CLS-prevention plugin initializes. |
z-runtime:ready | Dispatched on document after runtime styles have been injected and z-not-ready has swapped to z-ready. |
Tokens
Breakpoints
| Prefix | Min width |
|---|---|
sm: | 40rem |
md: | 48rem |
lg: | 64rem |
xl: | 80rem |
2xl: | 96rem |
Pseudo-classes & Pseudo-elements
Pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, :group-hover
Pseudo-elements: ::before, ::after
Colors & Intensities
Colors (26): red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, slate, gray, zinc, neutral, stone, taupe, mauve, mist, olive
Intensities: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950
Plugins & Hooks
Built-in Plugins
| Plugin | Source | Hooks | Description |
|---|---|---|---|
cls-prevention | src/js/runtime/plugins/cls-prevention.ts | onInit, onAfterInject | Dispatches z-runtime:init / z-runtime:ready and swaps z-not-ready to z-ready on <html> after CSS injection. |
custom-rules | src/js/runtime/plugins/custom-rules.ts | onRulesLoad | Validates and merges window.zRuntime.customRules into the active rule list. |
inline-vars | src/js/runtime/plugins/inline-vars.ts | onElementScan | Expands class=value shorthands (colors, /o opacity, auto-bracketed scale redirects) into inline CSS variables and reports missing variables in debug mode. |
dom-extractor | src/js/runtime/plugins/dom-extractor.ts | onElementScan | Scans [class] elements for interactive pseudo-class/pseudo-element tokens and warns when paired content-before/content-after classes are missing. |
safelist | src/js/runtime/plugins/safelist.ts | onAdditionalClasses | Expands window.zRuntime.safelist strings and { class, states, prefixes, dark } combinations into compiled classes. |
arbitrary-properties | src/js/runtime/plugins/arbitrary-properties.ts | onElementScan | Parses [property]={value} tokens (including dark, breakpoint, and state variants) and registers one-off rules into @layer utilities. |
Plugin Lifecycle Hooks
| Hook | Signature | Description |
|---|---|---|
onInit | (core: ZRuntimeCore) => void | Runs immediately when a plugin is registered via .use(plugin). |
onRulesLoad | (rules: Rule[], core: ZRuntimeCore) => Rule[] | Transforms or extends the active Rule[] array at the start of generate(). |
onElementScan | (element: Element, rules: Rule[], core: ZRuntimeCore) => ParsedClass[] | Inspects each [class] DOM element and returns ParsedClass[] entries to compile. |
onAdditionalClasses | (core: ZRuntimeCore) => ParsedClass[] | Provides extra ParsedClass[] entries not present in the DOM (such as safelists). |
onBeforeInject | (generatedCss: GeneratedCSS, core: ZRuntimeCore) => GeneratedCSS | Transforms the grouped GeneratedCSS layers right before <style> injection. |
onAfterInject | (core: ZRuntimeCore) => void | Runs after <style id="z-interactive-styles"> has been updated. |
Custom Rules
Cascade layers: components, styles, utilities
Rule Fields
| Field | Type | Required | Description |
|---|---|---|---|
selector | string | yes | Base utility class name this rule matches (for example opacity or [m]). |
properties | string | string[] | yes | CSS property name or ordered array of property names emitted by the rule. |
dark | boolean | no | Whether the rule generates .dark scoped variants. |
placeholders | Record<string, string> | no | Map of template placeholder tokens (for example {var}) in values to variable base names. |
layer | string | no | Target CSS cascade layer: components, styles (default), or utilities. |
impliedPseudo | string | no | Optional pseudo-selector suffix automatically appended to generated rules. |
fallback | string | no | Optional CSS fallback value placed inside var(--name, fallback) when arbitrary: true. |
arbitrary | boolean | no | When true, emits var(--...) directly from the computed CSS variable instead of static values. |
values | string[] | yes | CSS value template(s) corresponding to properties (required unless arbitrary: true). |