M3: library variables (#60)

Publishing a library now includes the file's variable collections (modes,
aliases, scopes), versioned per variable and collection; variables hidden
from publishing stay out unless a published variable aliases them or a
published component binds them. Files using the library see its
collections read-only in the Variables editor and the variable pickers;
binding, aliasing or setting a collection's mode copies the variables in
as read-only linked copies, library components keep their bindings, and
"Library updates available" covers changed variables (bound layers follow).

New commands: library.importVariable, library.bindVariable,
library.aliasVariable, library.setVariableMode; variable.update takes
hiddenFromPublishing.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
BFlat
2026-10-10 09:06:18 +07:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 20ca885084
commit d7fd41cd13
22 changed files with 1611 additions and 493 deletions
+2 -1
View File
@@ -99,7 +99,8 @@ Invoke a menu item exactly like clicking it (this may open a dialog). Returns `{
Switch panels and modes: `rightTab` `design|prototype|inspect`, `leftTab` `file|assets`, `theme`,
`home` (bool), `palette` (bool: the Actions palette), `mainMenu` (bool), `colorPicker`
(`{fills?, index?}`: open the colour picker on the selection's paint; `null` closes it), `variables` (bool,
or a collection id or name to show: the Variables editor), `layerFilter` (string:
or a collection id or name to show, or `{library, collection?}` for an enabled library's collection: the
Variables editor), `layerFilter` (string:
open the layers search with that filter; `null` closes it), `collapseLayers` (true: collapse the
layers tree), `exportPreview` (bool: the Design panel Export section's preview), `preview` (true or a
frame id: open the prototype preview pane like `proto.preview`; false or `null` closes it),
+23 -11
View File
@@ -166,14 +166,17 @@ accounts, nothing on the network; the browser build has no file system, so there
read library files return an error).
- **Publish** (in the library file): `library.publish {description?, include?, exclude?}` publishes
the file's components, component sets and styles as a new version (by default everything except
names starting with `.` or `_`, or what the last publish offered; `include`/`exclude` take
component ids and style ids or names). Components and styles they use come along, unoffered. Each
asset keeps the version it last changed in; publishing with no changes is refused. Save the file
(`file.save`) so other files see the new version.
the file's components, component sets, styles and variable collections as a new version (by
default everything except names starting with `.` or `_`, or what the last publish offered;
`include`/`exclude` take component ids and style or collection ids or names). A collection comes
with its variables (values per mode, aliases, scopes), except those hidden from publishing
(`variable.update {variable, hiddenFromPublishing: true}`). Components, styles and variables that
published assets use (a component's bound variables, a variable's alias targets) come along,
unoffered. Each asset keeps the version it last changed in; publishing with no changes is refused.
Save the file (`file.save`) so other files see the new version.
- **Enable**: `library.add {path}` / `library.remove {id}` (id, name or path) / `library.list
{assets?}` (versions, pending updates, errors; with `assets: true` each library's components and
styles, and what this file can publish). Libraries are read read-only with size limits, and read
{assets?}` (versions, pending updates, errors; with `assets: true` each library's components,
styles, variable collections (with their modes) and variables, and what this file can publish). Libraries are read read-only with size limits, and read
again when the file changes.
- **Use**: `library.place {library, component, x?, y?}` (a component, set or variant by id or name;
page point, default the view's centre) copies the component, with the components and styles it
@@ -181,10 +184,19 @@ read library files return an error).
{library, component}` only copies it (then `instance.create`, `instance.swap`…).
`library.applyStyle {library, style, ids?, target?}` copies a style in (linked, read-only) and
applies it. Instances of library components behave like any instance: overrides, properties,
variants, swap, reset, detach. Editing the copies (or library styles) is refused; edit the library
file and publish.
- **Update**: `library.updates` lists the components and styles with a newer published version;
`library.acceptUpdates {ids? (library ids)}` pulls them in, keeping instance overrides.
variants, swap, reset, detach. Library components keep their variable bindings and explicit modes
(bound to copies of the library's variables).
- **Library variables**: `library.bindVariable {library, variable, field, ids?}` copies a published
variable in (linked, read-only, with the variables it aliases and its collection) and binds it
like `variable.bind`; `library.aliasVariable {library, alias, variable, mode?}` makes a local
variable's value an alias of a library variable; `library.setVariableMode {library, collection,
mode, ids?}` sets a library collection's mode on frames (the page when no ids are given);
`library.importVariable {library, variable}` only copies it (then `variable.bind`, `variable.set
{value: {alias}}`). The copies render without the library file. Editing the copies (library
components, styles, variables or collections) is refused; edit the library file and publish.
- **Update**: `library.updates` lists the components, styles, variable collections and variables
with a newer published version; `library.acceptUpdates {ids? (library ids)}` pulls them in,
keeping instance overrides; bound layers, aliases and explicit modes follow the updated values.
### Slots
+1 -1
View File
@@ -1,6 +1,6 @@
# Parity report
Generated by `cargo xtask parity`: FigCraft commands registered for the incumbent's main menu and toolbar (381 commands in the engine).
Generated by `cargo xtask parity`: FigCraft commands registered for the incumbent's main menu and toolbar (389 commands in the engine).
**197 / 202 menu items (97.5%)**