API Reference
The Loom Standard Library
Welcome to the technical reference for the Loom engine. This section details the modules, functions, and types available in the package.
info
Modules Overview​
Loom is organized into several modules to keep the namespace clean.
| Module | Description |
|---|---|
| Engine | The weave loop, construct-loom, and lifecycle hooks. |
| Motifs | The component constructors: motif, content-motif, data-motif. |
| Query | Utilities for searching, filtering, and aggregating signals. |
| Mutator | Utilities for performing immutable updates on the Context. |
| Guards | Assertion functions to enforce document architecture. |
| Matcher | Schema validation and pattern matching utilities. |
| Utilities | Helpers for data manipulation (collection) and path inspection (path). |
The loom Namespace​
While you typically use construct-loom to create your own library instance, the static utilities are always available directly from the package.
#import "@preview/loom:0.1.0"
// 1. Core Constructors
#let (weave, motif, ..) = loom.construct-loom(<my-lib>)
// 2. Static Utilities (Used inside measure/scope)
#loom.query.select(..)
#loom.mutator.batch(..)
#loom.guards.assert-inside(..)
#loom.matcher.match(..)
#loom.collection.get(..)
Pro Tip: Destructuring
You can destructure the engine components directly during construction to keep your code clean:
#let (weave, motif) = loom.construct-loom(<id>)
Common Types​
Throughout this reference, we use the following type definitions:
Context:dictionaryThe immutable state object passed down from parent to child.Signal:dictionaryA data packet emitted by a component during themeasurephase. It bubbles up to the parent.Motif:functionA Loom component. Technically, it is a standard Typst function that returns a(key, payload)tuple.Body:content|arrayThe content passed to a component.