Skip to main content

Module library

Module library 

Source
Expand description

Zenith library subsystem: pack format, registry, and resolver.

A library “pack” is a .zen file whose IDENTITY is declared by a single library SELF-entry in its own libraries block, for example:

libraries { library id="@zenith/flowchart" version="1.0.0" }

That entry’s id is the package id and version is the pack version. A pack’s ITEMS are its components, filter/mask tokens, and actions: item decision in pack @zenith/flowchart is addressed @zenith/flowchart#decision.

PRESET packs are embedded in the binary via include_str! (see EMBEDDED_PACKS); PROJECT packs live in <project_dir>/libraries/*.zen and are scanned at runtime. Resolution order is project packs first, then embedded presets (a project pack shadows an embedded pack of the same id).

This module contains pure pack-loading/registry logic only; the CLI command that consumes it lives in crate::commands::library. The submodules group by concern: registry (pack model + parse + resolve), add (shared materialization machinery), and one module per materialize* flavor (component, token, action).

Structs§

ActionAddOutcome
The outcome of a successful materialize_action call.
AddError
An error produced while materializing a library item into a target document.
AddOutcome
The outcome of a successful super::materialize call.
LibraryPack
A loaded library pack: its identity plus the items it provides.
PackError
An error produced while parsing a pack.
PackItem
A single exported item of a LibraryPack: its id plus its kind.
TokenAddOutcome
The outcome of a successful materialize_token call.

Enums§

ItemKind
What kind of thing a pack item is.
PackSource
Where a LibraryPack was loaded from.

Constants§

EMBEDDED_PACKS
Embedded preset packs, as (pack_id, pack_source) pairs.

Functions§

collect_all_ids
Collect EVERY id declared anywhere in doc into one set, used to generate unique instance/provenance ids that cannot collide with anything in the target: every node id (recursively, across pages, masters, and components), plus all block-level ids (tokens, styles, assets, libraries, components, masters, sections, provenance, pages, the document id, and the project id).
load_embedded_packs
Parse every entry in EMBEDDED_PACKS into a LibraryPack.
load_pack_document
Load the FULL Document of a resolved pack.
load_project_packs
Scan project_dir/libraries/*.zen and parse each file into a LibraryPack.
materialize
Materialize the pack item pkg_id#item into target at (at_x, at_y) on the page page_id, returning the AddOutcome describing what was added.
materialize_action
Materialize the action item pkg_id#action_id against target_src, returning the ActionAddOutcome describing what happened.
materialize_token
Materialize the filter-token item pkg_id#item into target, returning the TokenAddOutcome describing what was added.
parse_pack
Parse a .zen pack source into a LibraryPack tagged with source_kind.
parse_spec
Parse a pkg#item spec into (pkg_id, item).
resolve_packs
Resolve all available packs: project packs first, then embedded presets.