runtime6 plugins11 API members

zRuntime

Client-side utility compiler, shorthand expander, and plugin engine for 0build.

API & Events

window.zRuntime API

Property / MethodKindSignatureDescription
zRuntime.debugconfigboolean (default: false)Boolean flag enabling per-plugin diagnostics in the browser console during development.
zRuntime.customRulesconfigRule[]Array of custom Rule definitions merged ahead of style generation (matching selectors replace built-ins).
zRuntime.safelistconfig(string | SafelistDescriptor)[]Array of class strings or descriptor objects to pre-generate even when absent from the initial DOM.
zRuntime.refreshmethod() => voidClears the internal rule cache and runs style generation from scratch.
zRuntime.regeneratemethod() => voidRe-runs style generation while preserving the existing rule cache.
zRuntime.getCachemethod() => Map<string, CssRule>Returns the internal Map of compiled CSS rules keyed by class, state, theme, and breakpoint.
zRuntime.getRulesmethod() => Rule[]Returns the merged array of active built-in and custom Rule definitions.
zRuntime.decoderhelperfunctionParses a raw utility class token into a structured ParsedClass descriptor.
zRuntime.encoderhelperfunctionSerializes a ParsedClass descriptor back into a utility class token string.
zRuntime.escaperhelperfunctionEscapes special CSS selector characters (such as :, [, ], /) for generated rules.
zRuntime.variablehelperfunctionComputes the expected CSS custom property name for a class, breakpoint, theme, and state.

DOM Events

EventDescription
z-runtime:initDispatched on document when the CLS-prevention plugin initializes.
z-runtime:readyDispatched on document after runtime styles have been injected and z-not-ready has swapped to z-ready.

Tokens

Breakpoints

PrefixMin 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

PluginSourceHooksDescription
cls-preventionsrc/js/runtime/plugins/cls-prevention.tsonInit, onAfterInjectDispatches z-runtime:init / z-runtime:ready and swaps z-not-ready to z-ready on <html> after CSS injection.
custom-rulessrc/js/runtime/plugins/custom-rules.tsonRulesLoadValidates and merges window.zRuntime.customRules into the active rule list.
inline-varssrc/js/runtime/plugins/inline-vars.tsonElementScanExpands class=value shorthands (colors, /o opacity, auto-bracketed scale redirects) into inline CSS variables and reports missing variables in debug mode.
dom-extractorsrc/js/runtime/plugins/dom-extractor.tsonElementScanScans [class] elements for interactive pseudo-class/pseudo-element tokens and warns when paired content-before/content-after classes are missing.
safelistsrc/js/runtime/plugins/safelist.tsonAdditionalClassesExpands window.zRuntime.safelist strings and { class, states, prefixes, dark } combinations into compiled classes.
arbitrary-propertiessrc/js/runtime/plugins/arbitrary-properties.tsonElementScanParses [property]={value} tokens (including dark, breakpoint, and state variants) and registers one-off rules into @layer utilities.

Plugin Lifecycle Hooks

HookSignatureDescription
onInit(core: ZRuntimeCore) => voidRuns 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) => GeneratedCSSTransforms the grouped GeneratedCSS layers right before <style> injection.
onAfterInject(core: ZRuntimeCore) => voidRuns after <style id="z-interactive-styles"> has been updated.

Custom Rules

Cascade layers: components, styles, utilities

Rule Fields

FieldTypeRequiredDescription
selectorstringyesBase utility class name this rule matches (for example opacity or [m]).
propertiesstring | string[]yesCSS property name or ordered array of property names emitted by the rule.
darkbooleannoWhether the rule generates .dark scoped variants.
placeholdersRecord<string, string>noMap of template placeholder tokens (for example {var}) in values to variable base names.
layerstringnoTarget CSS cascade layer: components, styles (default), or utilities.
impliedPseudostringnoOptional pseudo-selector suffix automatically appended to generated rules.
fallbackstringnoOptional CSS fallback value placed inside var(--name, fallback) when arbitrary: true.
arbitrarybooleannoWhen true, emits var(--...) directly from the computed CSS variable instead of static values.
valuesstring[]yesCSS value template(s) corresponding to properties (required unless arbitrary: true).