Skip to main content
Version: 0.1.0

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

If you are looking for conceptual guides or tutorials, please check the Concepts or Showcase sections.

Modules Overview​

Loom is organized into several modules to keep the namespace clean.

ModuleDescription
EngineThe weave loop, construct-loom, and lifecycle hooks.
MotifsThe component constructors: motif, content-motif, data-motif.
QueryUtilities for searching, filtering, and aggregating signals.
MutatorUtilities for performing immutable updates on the Context.
GuardsAssertion functions to enforce document architecture.
MatcherSchema validation and pattern matching utilities.
UtilitiesHelpers 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: dictionary The immutable state object passed down from parent to child.
  • Signal: dictionary A data packet emitted by a component during the measure phase. It bubbles up to the parent.
  • Motif: function A Loom component. Technically, it is a standard Typst function that returns a (key, payload) tuple.
  • Body: content | array The content passed to a component.