Find and extend
Folio registry
New in Levni 0.6.0 levni add @owner/repo needs 0.6.0 or newer.
Drawing packs, installed like npm packages. A pack is a GitHub repository (or a folder in one) with Levni drawings in it; levni add installs it into your project, pins it to a commit and records a hash of every file. Scenes then use its drawings by a scoped name, so a pack never replaces a Folio drawing.
npx @levni/levni add @owner/repo # the newest release tag, or the default branch
npx @levni/levni add @owner/[email protected] # a tag, a branch or a commit
npx @levni/levni add @owner/repo/folder # a pack in a folder of a bigger repo
npx @levni/levni add ./my-pack # a pack folder on this machine
npx @levni/levni packs --verify # what is installed, and is it unchanged
npx @levni/levni remove @owner/repo
{ "type": "prop", "name": "@levni-dev/levni/examples/pack:lifebuoy", "x": 600, "y": 330, "size": 300 }
Try it with the example pack in this repository: npx @levni/levni add @Levni-Dev/levni/examples/pack.
What lands in your project#
levni_packs/
levni-dev/levni__examples__pack/
levni-pack.json the pack's own file, plus where it came from and the commit
props/*.json the drawings that passed the checks
levni.lock.json every pack: source, ref, commit, licence, a sha256 per file
Commit levni.lock.json with your project. levni_packs/ can be committed too, or rebuilt with levni add from the lock's sources. Set LEVNI_PACKS to keep packs somewhere else.
Make a pack#
-
A folder with
levni-pack.json:{ "name": "Istanbul pier", "version": "1.0.0", "description": "…", "license": "CC BY 4.0", "author": "Your name" } -
Drawings in
props/, one file each, named after the drawing (props/lifebuoy.json), in the Folio format: paths in a 0–100 box with Levni colour names, tags, a category. The Folio guide andlevni add <file>show the format and check it. -
Test it:
npx @levni/levni add ./my-pack, then draw a scene with@local/<name>:<drawing>. -
Push it to GitHub, add the topic
levni-packto the repository so it shows on levni.dev/registry, and tag a release (v1.0.0):levni addtakes the newest release by default.
What makes it safe to install#
- JSON only. Only
levni-pack.jsonandprops/*.jsonare read. Nothing in a pack runs: no scripts, no install hooks. - Checked before written. Every drawing goes through the same schema check as the Folio, and every variant is test-drawn; a drawing that fails is skipped with the reason. A pack where nothing passes is refused.
- Pinned. The ref you ask for is resolved to a commit, and the files are read at that commit, so a later push to the branch cannot change what you installed.
- Hashed.
levni.lock.jsonkeeps a sha256 of every installed file;levni packs --verifyreports any file that changed, went missing or was added. - Only GitHub. The registry talks to
api.github.com,raw.githubusercontent.comand, for very large repositories,codeload.github.com. Nothing else. - Scoped. A pack's drawings are always
@owner/repo:name, so a pack cannot replace a Folio drawing or another pack's.
The owner name in @owner/repo is a GitHub account, so a scope is someone's real account. There is no central server, no account and no upload: the registry is GitHub plus a topic.
From code#
import { addPack, listPacks, verifyPacks, removePack } from '@levni/levni';
const { id, props, skipped } = await addPack('@owner/[email protected]');
Limits#
- Unauthenticated GitHub API calls are limited to 60 an hour per address; one install uses three of them.
- Packs hold drawings for now. Style packs and fonts are planned.
- Up to 2,000 drawings per pack, 2 MB per file.