Lenses
What a lens is — HTML built from the markdown of a base — and which templates exist. The lens kit lies in the package; the style and the skins ("Kit", "Draft") are in the package kit-style. Actions to build, check and show lenses; the service lenses "Project packages" and "Project checks".
关于该包
这段内容尚未翻译,下面是英文原文。
A lens is an HTML page that a program builds from the markdown of a base and that shows records in its own perspective: a board, a map, an ontology, nesting. You edit markdown, you rebuild the HTML. The package puts the page /base/lenses.md (what a lens is, the header, the templates, the lists "convert to lenses" and "not lenses"), two service lenses, and gives three actions: build, check, serve.
Service lenses
/base/packages.html— "Project packages", the package map: a canvas (drag to pan, Ctrl or Cmd and the wheel to zoom, F to fit) of every installed package as a card with its icon, title, version and counts, in groups by set and family, each a quiet heading above its cards, or in dependency layers with arrows. Click or press Enter on a package card to open it with the selected layout. Peek shows its version, source, linked dependencies, actions, norms and page link. The right panel remembers the opening mode. The arrangement, the canvas and the card presets (main, editorial, quiet, juicy) are settings in the right panel./base/checks.html— "Project checks": all checks with their norm, and the norms that no check holds.
build writes the data of both to lib/base/packages.data.js from .shtukbase/packages.lock and the packages' package.md (actions/packages.mjs); check says if they are out of date.
Lenses on a live server
A lens opened from a live server (the live package, shtuk run live serve) notices this itself (/api/hello) and turns on editing: the record's fields by the collection schema, changing a select or a phase by clicking a card's chip, dragging a card between board columns (changing the select or phase), editing text, "Create record", "To trash". A schema or contour error is shown at the field. If files change, the lens rereads itself. From disk and from a static server (serve) it is read-only, as before. A board by phase shows the columns of all the contour's phases in order.
Icons
A record shows its icon next to its title in cards, links, lists and the record header: the field icon is an emoji (shown as text) or a path to an .svg (shown through <img>, so no script in it runs; from the root of the base, /assets/icons/x.svg, or from the page's folder). Without its own icon a record shows what its collection gives: icons.item of the collection page, else the collection page's icon, else 📄; a collection with icons: {tier: none} shows none, with tier: kind only its own. Lens and region icons may be an .svg path too. The fields and the rules are the package "Page icons" (icons); the kit only shows them. The kit server sends .svg as image/svg+xml with no scripts allowed.
Lens style: "Kit" and "Draft"
In the Appearance section of the right panel there is a style choice: "Kit" (as it was) or "Draft" (graphite, champagne). The choice is remembered and applies to all the project's lenses, like the theme; it works both from disk and from a server.
- The project's default style is the field
skinin the header of/base/lenses.md:skin: keeris "Draft",skin: kitor empty is "Kit". After an edit —build. - A lens address can set the style and the theme for one showing without remembering them:
packages.html?skin=keer&theme=dark. The lens's own settings are set the same way, for example the arrangement:?arrange=layers;#<record id>opens a record. - Skins are the files
skins/<id>.cssof the package kit-style; a new skin appears in the choice afterbuild.
Lens layout
Set layout: on Design to an installed layout id and rebuild the lenses. The kit loads the package's
CSS and JavaScript under the Lens layout convention. An empty or unavailable choice uses
the built-in frame. The selected style and component library still provide tokens and component CSS.
Where the boundary is
- Here: the definition of a lens, the templates, the kit and the actions on it.
- The kit (
kit.js, its own part ofkit.css, templates, the build, the server) lies inkit/of the package; install puts it in.shtukbase/packages/lenses/kit/. There are no npm dependencies: js-yaml lies as one file inkit/vendor/. Bun is needed (or Node 20+ for the build itself). - The style is in the package
kit-style(whichrequireslists): the base, the header, chips, the card, markdown, the board, the gallery and the skins. Its own partkit/kit/kit.cssholds only what lenses need: the canvas, arrows, panels, the record, views. The build puts intolib/kit.cssthe "Kit" skin, the kit-style style, its own part and the other skins. It looks for the style in the project (design/kit-style/, the kit-style pages), then next to the package in the standard repository; if absent — a clear error "install kit-style". - The explore kit (package
explore-kit, not required): when the project hasdesign/explore-kit/explore.jsandexplore.css, the build copies them intolib/next tokit.js, so a lens links../lib/explore.jsfor a settings panel with presets. SHTUK_KITis an optional replacement: the path to another copy of the kit, for example when working on the kit itself.- The package has no norms: checking that lenses are fresh (
check) is an action, not a norm's enforcer. - Ontology lenses are built by the package
ontology; it takes the kit from this package.
动作 3
| 名称 | 作用 | 文件 | 时机 |
|---|---|---|---|
| build | Build the project's lenses (lib/) and the data of the service lenses | actions/build.mjs | shtuk run |
| check | Check that the built lenses (lib/) are up to date | actions/check.mjs | shtuk run |
| serve | Open the project in a browser on 127.0.0.1 (the kit server) | actions/serve.mjs | shtuk run |
shtuk check 运行检查;shtuk run lenses <名称> 运行任意动作。“安装后”动作只有在包来自可信来源时才会自动运行。
页面 3
这些页面会放到项目中的以下路径。
- /base/
- checks.html 视图
- 透镜视图 页面
- packages.html 视图
包文件 81
它们会放到 .shtukbase/packages/lenses/,动作从那里运行。