Files
alkane-os/third-party/flare-ui/dash-editor
x ad31cfbafa Vendor flare-ui v0.2.9 and prove the schema-driven UI in an image
Spike, not the final UI: it answers whether flare-ui can drive Alkane OS's
on-box pages, and what it costs.

What works:

- schema/alkane-bb.json authors the sidebar as data (3 sections, 14 tabs);
- src/bin/ui-spike.rs renders it through flare_ui::nav + flare_ui::shell, so
  the unified sidebar, ordering and surface filtering come from the schema
  rather than from hand-written HTML;
- the render uses the shared bf- design tokens, the same ones the rest of the
  suite uses.

Size, measured rather than assumed (armv7, release, stripped):

  ui-baseline   323 KiB   (maud + serde_json, no flare-ui)
  ui-spike      771 KiB   (flare-ui + wschema + sha2)
  marginal      448 KiB

Vendoring: third-party/flare-ui is the full v0.2.9 tree pinned in
flare-ui/flare-ui.lock (a partial archive does not compile, since the crate
include_str!s assets from dash-editor/). vendor/ is re-generated as a cargo
directory source with the new registry dependencies (maud, sha2, typenum,
digest, generic-array, block-buffer, crypto-common, cfg-if, etc.) so the build
still works offline. third-party/README.md records how to re-pin.
2026-11-04 14:06:25 -06:00
..

flare-dash-editor

The dashboard block editor and the .wdash file format, shared by FLARE (the supervisory portal) and WardenOS (the panel firmware's web console). Both embed the same editor and read the same files, so a dashboard built in one renders in the other.

Plain static files: no build step, no bundler, no network fetch at runtime. A consumer copies them in as they are.

Contents

Path What it is
editor/dashboard-*.js The editor scripts, loaded in the order below
editor/studio.css The editor's stylesheet
editor/dashboard_studio.html The editor markup: palette, canvas, toolbar, properties
docs/wdash.md The .wdash format specification
vectors/ .wdash test vectors and cases.json, the outcome each reader owes
tools/wdash.mjs Reference header reader, checksum and file writer (Node)
rust/wdash_format.rs The Rust header reader, checksum and file writer both consumers compile in
tools/dash-vendor.sh Pins a consumer's vendored copy to one commit
tools/dash-vendor-selftest.sh Proves a consumer's check catches an unlisted file, against its real lock
tools/make-vectors.mjs Regenerates vectors/

The editor edits the version 3 dashboard document described in FLARE's docs/dashboards.md; docs/wdash.md specifies the file that carries one.

Consuming the editor

A page that embeds the editor provides:

  1. An element with data-dashboard-editor, optionally carrying data-sources-href: the URL the source picker fetches its readings from.
  2. Inside it, editor/dashboard_studio.html, and a raw JSON pane: a <details> holding a <textarea data-dashboard-raw> with the document text, and an element with data-dashboard-raw-error beside it.
  3. editor/studio.css, plus definitions for the base classes and design tokens it uses (bf-btn, bf-input, --bf-space-2, --app-text and the rest; FLARE's portal.css and tokens.css are one set).
  4. The scripts, deferred or appended in this order: dashboard-doc.js, dashboard-raw.js, dashboard-editor.js, dashboard-inspector.js, dashboard-list.js, dashboard-sources.js, dashboard-drag.js, dashboard-json.js, dashboard-file.js. Each runs once at load against the markup already on the page.
  5. Optionally, the two forms behind Import and Export, outside the editor's own form (a form cannot nest). The studio hides a control whose form is missing.
Form id Method What it does
dashboard_import_form POST, multipart/form-data Reads a .wdash file and answers with its document. Never stores.
dashboard_export_form GET Downloads the saved dashboard as a .wdash attachment.

With scripting off the forms submit as forms: the import posts a file field and any hidden fields the form holds. With scripting on, dashboard-file.js posts the file's text as the body to the import form's action, with Accept: application/json and the form's csrf field, if any, as an X-CSRF-Token header. The host answers {"name": ..., "document": {...}}, or {"error": ...} with a refusal status. The document goes into the raw pane as an ordinary, undoable change, and the editor root receives a dashboard-import event carrying {name, document}. An import with no answer ends after 15 seconds, or after data-file-timeout-ms on the editor root.

The textarea is the document. The editor keeps it in step with the canvas, and the host saves whatever it holds.

The markup's comments are Jinja-style comment blocks. A template engine that includes the file drops them; a page that inserts it as HTML removes them first:

markup.replace(/\{#[\s\S]*?#\}/g, "")

Vendoring

Consumers vendor exact copies pinned to a commit rather than using a git submodule. Both consumers build without network access to this repository: FLARE's image builds from flare-server/ alone, and the WardenOS overlay is copied into a root filesystem file by file. A pinned copy keeps both builds unchanged and needs no cross-repository credential in CI.

Each consumer keeps dash-editor.lock at its root, mapping files here to paths there with the git blob id of each, and runs the vendored dash-vendor.sh check in CI. A blob id is the hash of the file's bytes, so a vendored file edited in place, or a sync without its lock, fails the check.

check also holds each directory a vendored file lands in to the lock: a file there that the lock does not name fails it. A directory that also holds the consumer's own files (FLARE's static/js, templates, scripts and docs) is declared in the lock with a shared <dir> line, written by hand; only its locked files are checked. sync keeps those lines. Each consumer vendors dash-vendor-selftest.sh beside the tool and runs it in CI: in a throwaway copy of its vendored files, it plants a file in every directory the lock owns and expects check to fail.

To move a consumer to a new commit:

scripts/dash-vendor.sh sync /path/to/flare-dash-editor <commit>   # tools/ in WardenOS

sync copies the locked files from that commit, rewrites the lock and runs check --upstream against the checkout, which proves each locked id is the file at that commit. Change the editor here first, then sync each consumer; never edit a vendored copy.

Rust

rust/wdash_format.rs is the .wdash header for a Rust reader: the header rules, the RFC 8785 canonical form, the checksum, and the writer. It needs std, serde_json and sha2, and knows nothing of storage or of the document's own rules, which each reader applies after header passes. FLARE and WardenOS vendor it like the editor and compile it in as a module, so the drift check covers it; its unit tests run in both consumers' suites.

Tests

node --test tests/*.test.mjs

The tests run the vectors through the reference reader, check the canonical form against RFC 8785 cases, check that the markup carries no template syntax and every hook the scripts read, and run dash-vendor.sh against throwaway repositories. The consumers drive the editor in real browsers: FLARE's scripts/test-editor-browser.mjs and WardenOS's tests/e2e.

License

MIT, see LICENSE.