zerolith/internal
Import from zerolith/internal. Generated from the source; every signature below is what the published types declare.
Functions
prepared
function prepared(strings: readonly string[], markup: string, parts: readonly PreparedPart[]): TemplateStringsArrayRegisters the scan a build tool made of a template's strings, so the
runtime binds the template without scanning it, and returns the strings
for use as the tag's first argument:
html(prepared(strings, markup, parts), ...values). The prepare pass in
@zerolith/vite emits these calls from what scan produced.
Source: packages/zerolith/src/template.ts:72
scan
function scan(strings: readonly string[]): ScannedScans the static strings of a template literal. Pure; usable without a DOM.
Source: packages/zerolith/src/scan.ts:80
styleFile
function styleFile(path: string, rules: string): StylesThe styles of a stylesheet file imported with ?scoped, as in
import card from "./card.css?scoped". The dev server, the build, and
the Vite plugin turn that import into a call to this function with the
file's path in the project and its rules, which are scoped as a css
literal's are. The scope class holds the file's name and a hash of its
path rather than of its text, so the server and the browser agree on it
however each processed the file, and a second call for the same path,
made when the file changed in development, replaces the rules of the
stylesheet the document adopted while every element keeps its class.
A constructable stylesheet resolves references against the page, so the
tools hand over rules whose references are already URLs the page can use.
Source: packages/zerolith/src/css.ts:143
devtoolsInternal
function devtoolsInternal<T>(fn: () => T): TRuns fn with everything it creates marked as belonging to the inspector, including what the effects and owners it creates make when they run later.
Source: packages/zerolith/src/devtools.ts:292
devtoolsSaveRestore
function devtoolsSaveRestore(state: Record<string, unknown>): voidQueues values for named state signals created from now on, each taken once. The dev server's client writes them to sessionStorage before a reload; the Vite plugin's runtime calls this between a module's disposal and the re-render that follows. An empty record drops what is left.
Source: packages/zerolith/src/devtools.ts:217
Interfaces
PartSpec
interface PartSpecWhere and how one or more expressions bind into the template.
kind: number: How the part binds:CHILDfor content; for an attribute,BOOLEAN,PROPERTY, orEVENTafter a?,., or@prefix,REFforref, andATTRIBUTEotherwise.index: number: Position of the bound node in a tree walk of the template content.name: string: Attribute, property, or event name as written in the source.strings: readonly string[]: Static text around the expressions of an attribute value; always one longer thancount.count: number: Number of expressions the part consumes.
Source: packages/zerolith/src/parts.ts:18
Scanned
interface ScannedThe scanner's output: markup with markers, and the parts in source order.
markup: string: The static strings as one markup string, with each bound attribute replaced by an attribute namedzl$N, N being its index inparts, and each child expression by a<!--zl$-->comment.parts: PartSpec[]: One part per child expression and per bound attribute, in source order;indexis -1 here, andpreparesets it on its own copies.
Source: packages/zerolith/src/parts.ts:33
DevtoolsHook
interface DevtoolsHookThe object published as globalThis.__ZEROLITH_DEVTOOLS__ in development builds.
readonly version: number: The version of the hook's shape, which a tool reading the hook can check before it relies on the other members.nodes(): NodeSnapshot[]: Live reactive nodes, oldest first.roots(): RootSnapshot[]: Mounted roots.diagnostics(): Diagnostic[]: The most recent diagnostics, oldest first.subscribe(listener: (event: DevtoolsEvent) => void): () => void: Subscribes to changes; returns an unsubscribe function.
Source: packages/zerolith/src/devtools.ts:42
NodeSnapshot
interface NodeSnapshotWhat a reactive node looks like to an inspector.
id: number: Unique across nodes and roots, assigned when the node is created; anodeevent names the node by this number.kind: "state" | "computed" | "effect":statefor asignal,computedfor acomputedvalue, andeffectfor an effect, including those the renderer starts for its bindings.name: string | undefined: The signal's or computed value'snameoption, or else the name of the computed's or effect's function;undefinedwhen there is neither. A named state node keeps its value across an edit in development.value?: unknown: The current value for state and computed nodes; absent for effects and when reading threw.observers: number: How many nodes currently depend on this one.internal: boolean: Created while the inspector itself was rendering.
Source: packages/zerolith/src/devtools.ts:5
RootSnapshot
interface RootSnapshotA mounted root as the inspector sees it.
id: number: Unique across roots and nodes, assigned at mount; arootevent names the root by this number.kind: "render" | "hydrate": The call that mounted the root:renderorhydrate, the latter also when hydration found no server markup and rendered instead.container: Node: The element or fragment the root was mounted into, with a selector target already resolved to its element.internal: boolean: Mounted while the inspector itself was rendering, as its own dock is; no subscriber hears of such a root, and the Roots tab leaves it out.
Source: packages/zerolith/src/devtools.ts:22
Types
PreparedPart
type PreparedPart = readonly [number, string, readonly string[]]A part as a build tool emits it: the kind, the name, and the static strings; count and index follow from them.
Source: packages/zerolith/src/parts.ts:42
DevtoolsEvent
type DevtoolsEvent = { type: "node"; id: number } | { type: "root"; id: number; removed: boolean } | { type: "diagnostic"; diagnostic: Diagnostic } | { type: "flush"; effects: number }Something the hook announces to subscribers.
Source: packages/zerolith/src/devtools.ts:35
Constants
SCOPE_MARKER
const SCOPE_MARKER: stringThe class every scoped root carries, used as the lower bound of enclosing scopes.
Source: packages/zerolith/src/css.ts:12
version
const version: stringThe version of this zerolith, which the packages released with it compare with their own.
Source: packages/zerolith/src/version.ts:1