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§
- Action
AddOutcome - The outcome of a successful
materialize_actioncall. - AddError
- An error produced while materializing a library item into a target document.
- AddOutcome
- The outcome of a successful
super::materializecall. - Library
Pack - A loaded library pack: its identity plus the items it provides.
- Pack
Error - An error produced while parsing a pack.
- Pack
Item - A single exported item of a
LibraryPack: its id plus its kind. - Token
AddOutcome - The outcome of a successful
materialize_tokencall.
Enums§
- Item
Kind - What kind of thing a pack item is.
- Pack
Source - Where a
LibraryPackwas loaded from.
Constants§
- EMBEDDED_
PACKS - Embedded preset packs, as
(pack_id, pack_source)pairs.
Functions§
- collect_
all_ ids - Collect EVERY id declared anywhere in
docinto 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_PACKSinto aLibraryPack. - load_
pack_ document - Load the FULL
Documentof a resolved pack. - load_
project_ packs - Scan
project_dir/libraries/*.zenand parse each file into aLibraryPack. - materialize
- Materialize the pack item
pkg_id#itemintotargetat(at_x, at_y)on the pagepage_id, returning theAddOutcomedescribing what was added. - materialize_
action - Materialize the action item
pkg_id#action_idagainsttarget_src, returning theActionAddOutcomedescribing what happened. - materialize_
token - Materialize the filter-token item
pkg_id#itemintotarget, returning theTokenAddOutcomedescribing what was added. - parse_
pack - Parse a
.zenpacksourceinto aLibraryPacktagged withsource_kind. - parse_
spec - Parse a
pkg#itemspec into(pkg_id, item). - resolve_
packs - Resolve all available packs: project packs first, then embedded presets.