@marver-design/marver 0.23.1 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/README.md +3 -1
- package/dist/anchor-DVV732zR.mjs +33 -0
- package/dist/anchor-check-BE5VVN6Q.mjs +135 -0
- package/dist/{bake-DQtnDB8-.mjs → bake-D8byeRzB.mjs} +1 -1
- package/dist/{boards-BRLnoTC3.mjs → board-tree-DRioF94d.mjs} +21 -277
- package/dist/boards-CGg6piKF.mjs +342 -0
- package/dist/{boards-Dv-Ipd8G.mjs → boards-Csxj2WJn.mjs} +23 -9
- package/dist/{build-_ndp_dXn.mjs → build-BHoWLvSj.mjs} +63 -37
- package/dist/cli.mjs +31 -17
- package/dist/{collab-mAiNZlDj.mjs → collab-gqNdScUE.mjs} +39 -9
- package/dist/{comments-DZyobpxG.mjs → comments-Zoch254k.mjs} +19 -1
- package/dist/{comments-BlqyZh3D.mjs → comments-pTLlhjh4.mjs} +150 -20
- package/dist/{config-BUKprFAp.mjs → config-cKgZBRj0.mjs} +1 -1
- package/dist/{context-CdkNiKdJ.mjs → context-D2ugHqwO.mjs} +17 -123
- package/dist/{daemon-BvMPdQ3k.mjs → daemon-Cl8KXGW4.mjs} +146 -64
- package/dist/{dev-Cf-4eqaC.mjs → dev-DJdgow47.mjs} +23 -11
- package/dist/{events-B3LBn74P.mjs → events-DnK_AnrW.mjs} +13 -15
- package/dist/imports-WBSnnHLb.mjs +143 -0
- package/dist/{init-hfZV7TwY.mjs → init-DO4DhUt_.mjs} +28 -6
- package/dist/link-C-qUIuKU.mjs +160 -0
- package/dist/{board-status-BZSzc9Hp.mjs → manifest-DnAte_fB.mjs} +537 -13
- package/dist/marks-DFuintmJ.mjs +50 -0
- package/dist/marks-koRsbHfe.mjs +397 -0
- package/dist/{marver-id-gate-B_idGdHm.mjs → marver-id-gate-DGANtVyC.mjs} +2 -2
- package/dist/perf-CCisg-ny.mjs +49 -0
- package/dist/perf-QJIWtTw1.mjs +68 -0
- package/dist/{plugin-DoXql0ZZ.mjs → plugin-CTyhjwoJ.mjs} +469 -82
- package/dist/{poster-XBmUvQiL.mjs → poster-D0cbV7hi.mjs} +1 -1
- package/dist/{profile-CrZohD6g.mjs → profile-Do0nGkXO.mjs} +1 -1
- package/dist/{publish-bakes-KKTHWqq3.mjs → publish-bakes--l8ot2eQ.mjs} +9 -9
- package/dist/{serve-z5qtj_wJ.mjs → serve-wv2QWdxB.mjs} +6 -6
- package/dist/{share-BD-wcDQq.mjs → share-ScamJcks.mjs} +1 -1
- package/dist/{shot-DOD8v6fJ.mjs → shot-CckrGW-J.mjs} +19 -11
- package/dist/{shot-Dh6fV1Lm.mjs → shot-jdO_B6Qw.mjs} +1 -1
- package/dist/{summary-C7CAypbB.mjs → summary-CrW88e3q.mjs} +1 -1
- package/dist/{sync-DoA1vf4u.mjs → sync-C3035OnJ.mjs} +18 -8
- package/dist/{work-ClFFq0Qh.mjs → work-CpJn1gwY.mjs} +8 -4
- package/dist/{work-ayuL_9Kk.mjs → work-GE88wb_3.mjs} +4 -4
- package/docs/boards-and-folders.md +70 -4
- package/docs/live-jam.md +12 -4
- package/package.json +1 -1
- package/src/client/frame-host/bridge.js +2 -1
- package/src/client/frame-host/inspect.js +195 -84
- package/src/client/frame-host/main.tsx +7 -2
- package/src/client/frame-host/registry.ts +5 -5
- package/src/client/shell/App.tsx +98 -30
- package/src/client/shell/BoardList.tsx +74 -16
- package/src/client/shell/Comments.tsx +79 -34
- package/src/client/shell/ContextMenu.tsx +5 -2
- package/src/client/shell/LockedApp.tsx +45 -12
- package/src/client/shell/Play.tsx +35 -32
- package/src/client/shell/Toolbar.tsx +3 -1
- package/src/client/shell/canvas/Canvas.tsx +2 -0
- package/src/client/shell/canvas/FrameNode.tsx +15 -5
- package/src/client/shell/canvas/sleep.ts +4 -3
- package/src/client/shell/canvas/updates.ts +55 -0
- package/src/client/shell/comments-store.ts +48 -17
- package/src/client/shell/goto.ts +11 -14
- package/src/client/shell/hash.ts +12 -5
- package/src/client/shell/icons.tsx +1 -2
- package/src/client/shell/legacy-links.ts +67 -0
- package/src/client/shell/marks-ui.tsx +117 -0
- package/src/client/shell/pin-layout.ts +37 -0
- package/src/client/shell/store.ts +377 -67
- package/src/client/shell/styles.css +32 -8
- package/src/client/stage/main.tsx +19 -2
- package/src/shared/anchor.ts +57 -0
- package/src/shared/board-tree.ts +27 -10
- package/src/shared/events.ts +19 -10
- package/src/shared/marks.ts +70 -0
- package/templates/AGENTS-embedded.md +34 -15
- package/templates/AGENTS-studio.md +34 -15
- package/templates/instructions/boards.md +9 -5
- package/templates/instructions/iterate.md +20 -10
- package/templates/instructions/jam.md +13 -4
- package/templates/instructions/publish.md +2 -1
- package/templates/instructions/reference/deck-story.md +2 -2
- package/dist/link-BodAbIQz.mjs +0 -132
- package/dist/manifest-TpfDWldB.mjs +0 -528
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,72 @@
|
|
|
2
2
|
|
|
3
3
|
Notable changes to `@marver-design/marver`. Format follows [Keep a Changelog](https://keepachangelog.com); versions follow semver.
|
|
4
4
|
|
|
5
|
+
## 0.25.0 - 2026-10-15
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Edits land calmly.** When a file changes, the canvas reloads only the frames that read it - a
|
|
10
|
+
few at a time, the ones on screen first. A frame off screen waits until you scroll near it; one
|
|
11
|
+
you are using (typing in it, a laser, a comment) waits until you are done. A content frame keeps
|
|
12
|
+
its height while it reloads, so the rows below stay still, and the board moves once if heights
|
|
13
|
+
did change. The canvas page itself never reloads for a design edit. `npx marver perf` shows what
|
|
14
|
+
each edit reached and reloaded ([Edits land calmly](docs/boards-and-folders.md#edits-land-calmly)).
|
|
15
|
+
- **Comments sit on what they are about.** Every note your agent pins names an element - words it
|
|
16
|
+
shows (`--on`) or a selector (`--at`) - and is checked against the rendered frame while
|
|
17
|
+
`marver dev` runs. Markers never cover each other and stay put while you work; a follow-up goes
|
|
18
|
+
into its thread (`comments reply`, `comments new --thread`), and `npx marver comments move` re-pins
|
|
19
|
+
one ([Notes from your chat agent](docs/live-jam.md#notes-from-your-chat-agent)).
|
|
20
|
+
- **`npx marver marks`** prints what you have not reviewed yet - the frames waiting on you, the
|
|
21
|
+
ones that ask first, then the frames new since you looked - for you, or for your agent at the
|
|
22
|
+
start of a session.
|
|
23
|
+
- **`npx marver boards pin <board> <scene/frame ...>`** puts frames on a board. A frame on no
|
|
24
|
+
board is listed under **Not on a board** in the sidebar, and `work done` says where it belongs.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **No more All Scenes.** The built-in board that held every frame is gone - it was heavy, slow
|
|
29
|
+
to open, and always marked. Every frame lives on the board it belongs to; a fresh canvas lands on
|
|
30
|
+
a `welcome` board; old All Scenes links open a real board, and a canvas that published it keeps
|
|
31
|
+
its threads ([Every frame on a board](docs/boards-and-folders.md#every-frame-on-a-board)).
|
|
32
|
+
- **Marks are exact.** They start when `marver dev` starts, so what your agent makes before you open
|
|
33
|
+
the canvas is new when you do. A file every frame reads - a kit, a spec's markdown, a layout -
|
|
34
|
+
lights every frame that reads it, even when it changed while dev was off. A look clears only the
|
|
35
|
+
version on screen, and a frame you opened while its new version loaded clears once it is up.
|
|
36
|
+
Orange now reads "waiting on you": a question comes first for `u` and keeps its own notice,
|
|
37
|
+
because the agent says when a reply asks
|
|
38
|
+
([What is new, what needs you](docs/boards-and-folders.md#what-is-new-what-needs-you)).
|
|
39
|
+
- **What agents are told.** Pin each point on its element, one thread per topic, `--ask` on a reply
|
|
40
|
+
that asks, `npx marver marks` at the start of a session, and every frame on its board.
|
|
41
|
+
Upgrading: `npx marver init` updates the instructions.
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- 0.24 counted everything an agent did before you first opened the canvas as already seen.
|
|
46
|
+
- Notes pinned without an element all landed on one spot of the frame, one on top of the other.
|
|
47
|
+
|
|
48
|
+
## 0.24.0 - 2026-10-14
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- **The sidebar shows where to look.** A frame that changed since you looked turns blue - icon,
|
|
53
|
+
title and a dot - in the sidebar and on its title above the card; one where Marver asked you
|
|
54
|
+
something turns orange, with a bubble holding how many questions are open, hollow once you have
|
|
55
|
+
answered, gone when the thread is resolved. Every row keeps the one item at its right edge it has
|
|
56
|
+
today, and what matters most takes it, so nothing shifts or truncates further: a board you are not
|
|
57
|
+
on turns blue or wears the bubble in place of its status, a closed folder or folded scene turns its
|
|
58
|
+
count blue or shows the bubble. Selecting a frame, opening it from the sidebar, a link, focus or
|
|
59
|
+
play, two seconds on screen at a readable zoom, or **Mark all as seen** on a scene, board or folder clears
|
|
60
|
+
it. `u` goes to the next frame that needs you, then the next new one. A change is the frame's
|
|
61
|
+
file or sticky note changing, a `git pull`, or an agent's `npx marver work done`; the day you
|
|
62
|
+
upgrade, everything already there counts as seen. Marks are kept in `design/.local/seen.json` on
|
|
63
|
+
your machine ([What is new, what needs you](docs/boards-and-folders.md#what-is-new-what-needs-you)).
|
|
64
|
+
|
|
65
|
+
### Changed
|
|
66
|
+
|
|
67
|
+
- **One notice per round.** Marver's replies on a board fold into one notice that counts them
|
|
68
|
+
("directions · 4 replies") instead of a stack of eight, and View walks through them one by one; a
|
|
69
|
+
new note, or a reply that asks a question, still raises its own.
|
|
70
|
+
|
|
5
71
|
## 0.23.1 - 2026-10-14
|
|
6
72
|
|
|
7
73
|
### Fixed
|
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Frames appear on the canvas the moment the files land. That's the loop.
|
|
|
40
40
|
|
|
41
41
|
## The canvas
|
|
42
42
|
|
|
43
|
-
- **Frames, scenes, boards.** Frames are screens, scenes group them (`design/scenes/<scene>/<frame>.tsx`), boards arrange them. Agents write `design/boards/<name>.json` (a frame list is enough); switch boards at the top of the sidebar. `
|
|
43
|
+
- **Frames, scenes, boards.** Frames are screens, scenes group them (`design/scenes/<scene>/<frame>.tsx`), boards arrange them. Agents write `design/boards/<name>.json` (a frame list is enough); switch boards at the top of the sidebar. Every frame goes on the board it belongs to, and a frame that belongs to two goes on both (`npx marver boards pin <board> <scene/frame ...>`); a frame on no board is listed apart, under Not on a board. Right-click any board, scene, or frame in the sidebar to copy its path - the exact string to paste to your agent - and rename or drag-reorder boards from there too. Boards can live in folders, two levels deep - a folder holds boards and folders, a sub-folder holds boards: right-click the Boards header (or its `+`) for a new folder, a folder for a new one inside it, name it inline, drag boards in and out at either level (the seam shows exactly where a release lands, indented with the level) and folders among boards or into a folder; agents do the same by writing `"folder": "<name>"` on a board and `design/boards/_folders.json` for empty, ranked or nested folders (a sub-folder names its `"parent"`; `npx marver boards` prints the tree). The [boards and folders guide](docs/boards-and-folders.md) has every move. Boards, folders and scenes take a `title` - any name you like, "MVP", "UI", "Checkout (v2) 🛒" - while their file, key and directory stay the slug agents address; Rename in the sidebar edits the title. Every board wears an icon for its type - start, feature, surface, project, feedback, context, deck, archive - its own or its folder's, and feature boards wear a status read from the project's `context/`. Every object takes a one-sentence `description` (project in `design/config.ts`, boards and folders in their JSON, a scene's first `_brief.md` line, `meta.description` on a frame) and `design/manifest.json` carries them all - a new agent session orients in one read.
|
|
44
44
|
- **Devices view.** Hotkeys `1`-`5` (or the Devices menu) size every frame to mobile / tablet / laptop / monitor / tv to sweep your breakpoints; `0` restores your own layout exactly. Widths live in `design/config.ts`.
|
|
45
45
|
- **Prototype links.** `data-goto="scene/frame"` on any element links frames into a walkable prototype - across boards, too.
|
|
46
46
|
- **Five ways to view a board.** The canvas (frames on a plane), the board (the same, tidy), **present** (`p`: a full-screen clickable walkthrough - `data-goto` navigates, arrows step, `[` / `]` cycle variants, laser, comments, theme and device pickers in the toolbar), **focus** (one frame as a document - the reading preset for specs), and **slides** (a deck). A published board names its landing view; a frame deep link opens straight into it.
|
|
@@ -130,6 +130,8 @@ The same glow, driven from the terminal. When your agent takes a request, it cre
|
|
|
130
130
|
|
|
131
131
|
**Selection** - click selects · shift+click (canvas or sidebar) builds a multi-selection · `⌘A` selects every frame on the board · `⇧P` copies the selected frames' paths (board, frame, and file) · `i` copies the selected frame to the clipboard as a 2x PNG (`⇧i` for 4x; also the images-square button in the floating toolbar - dev canvases only, the renderer is the dev server's headless Chrome) · double-click enters interact mode (`esc` or click outside leaves) · drag the title bar to move, edges to resize (widths snap to devices).
|
|
132
132
|
|
|
133
|
+
**Where to look** - `u` goes to the next frame that needs you (an orange question bubble), then the next new one (blue) - see [what is new, what needs you](docs/boards-and-folders.md#what-is-new-what-needs-you).
|
|
134
|
+
|
|
133
135
|
**Modes** - `c` comment mode · `l` laser mode · `⇧C` hide/show comment pins · `⇧L` laser comment (spotlight a thread's element) · `p` play (present, or slides on a slides board) · `h` hide all chrome.
|
|
134
136
|
|
|
135
137
|
**In play** - `←` `→` step (Space and click advance a deck) · `[` `]` cycle variants · `d` cycles the theme · digits pick a device, the digit after your last one fills the window · `esc` exits, unless the board is locked to that view.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/shared/anchor.ts
|
|
2
|
+
/** Read a target from untrusted input - CLI flags, a Live Jam block: exactly one of `on` / `at`, an
|
|
3
|
+
* optional whole `nth` from 1. A string is the reason it is not one. */
|
|
4
|
+
function readTarget(raw) {
|
|
5
|
+
const clean = (v) => typeof v === "string" || typeof v === "number" ? String(v).replace(/\s+/g, " ").trim() : "";
|
|
6
|
+
const on = clean(raw.on), at = clean(raw.at);
|
|
7
|
+
if (!on === !at) return "name the element with --on \"<words it shows>\" or --at \"<css selector or data-testid>\" (one of them)";
|
|
8
|
+
if ((on || at).length > MAX_TARGET) return `--on / --at take at most ${MAX_TARGET} characters - name fewer words`;
|
|
9
|
+
const nth = raw.nth === void 0 ? void 0 : Number(raw.nth);
|
|
10
|
+
if (nth !== void 0 && !(Number.isInteger(nth) && nth >= 1)) return "--nth takes a whole number from 1";
|
|
11
|
+
return {
|
|
12
|
+
...on ? { on } : { at },
|
|
13
|
+
...nth ? { nth } : {}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const MAX_TARGET = 200;
|
|
17
|
+
/** The anchor written when the frame cannot be checked (dev off, no Chrome, a frame that throws):
|
|
18
|
+
* the target alone, which the canvas resolves exactly as the check would - by its words, or by
|
|
19
|
+
* `at` (its test id, else its selector). One that does not resolve shows as an orphan;
|
|
20
|
+
* `comments move` fixes it. */
|
|
21
|
+
function uncheckedAnchor(t) {
|
|
22
|
+
const nth = t.nth ? { nth: t.nth } : {};
|
|
23
|
+
return t.on ? { el: {
|
|
24
|
+
semantics: { quote: t.on },
|
|
25
|
+
...nth
|
|
26
|
+
} } : { el: {
|
|
27
|
+
semantics: {},
|
|
28
|
+
at: t.at,
|
|
29
|
+
...nth
|
|
30
|
+
} };
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { readTarget, uncheckedAnchor };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { MOUNTED, frameUrl, manifestFrame, planShot, withBrowser } from "./shot-CckrGW-J.mjs";
|
|
2
|
+
//#region src/server/anchor-check.ts
|
|
3
|
+
/**
|
|
4
|
+
* The anchor check (spec 26, Part 6): `comments new --on|--at`, `comments move` and a Live Jam re-pin
|
|
5
|
+
* name an element by its words or a selector; the dev server loads the frame in the headless
|
|
6
|
+
* browser `marver shot` uses - no screenshot - and asks the frame which VISIBLE element that is
|
|
7
|
+
* (inspect.js `__mvAnchorCheck`). What it finds is stored as the full element bundle, so the pin
|
|
8
|
+
* resolves exactly on the canvas.
|
|
9
|
+
*
|
|
10
|
+
* Refused only on evidence: a frame that rendered with no match, or several. Anything that stops
|
|
11
|
+
* the check - no Chrome, a browser that will not start, a frame that throws, the deadline - comes
|
|
12
|
+
* back `unchecked`, and the caller writes the note unchecked with a warning.
|
|
13
|
+
*/
|
|
14
|
+
/** End to end, a cold browser start included (most of it). */
|
|
15
|
+
const CHECK_MS = 2e4;
|
|
16
|
+
/** A request the check cannot even start on: an unknown frame, viewport or theme. */
|
|
17
|
+
var CheckInputError = class extends Error {};
|
|
18
|
+
async function checkAnchor(req, deadlineMs = 19e3) {
|
|
19
|
+
const theme = req.theme ?? "light";
|
|
20
|
+
if (!theme.trim() || theme.length > 64) throw new CheckInputError(`invalid theme "${theme}"`);
|
|
21
|
+
const frame = manifestFrame(req.root, req.frameId);
|
|
22
|
+
if (!frame) throw new CheckInputError(`unknown frame "${req.frameId}" - ids are in design/manifest.json`);
|
|
23
|
+
if (req.viewport && !req.viewports[req.viewport]) throw new CheckInputError(`unknown viewport "${req.viewport}" - this canvas has ${Object.keys(req.viewports).join(", ")}`);
|
|
24
|
+
const plan = planShot(frame, req.viewports);
|
|
25
|
+
const size = req.viewport ? req.viewports[req.viewport] : {
|
|
26
|
+
width: plan.width,
|
|
27
|
+
height: plan.initialHeight
|
|
28
|
+
};
|
|
29
|
+
const viewport = req.viewport ?? frame.viewport ?? (frame.slide ? "its slide stage" : frame.contentWidth ? `${size.width}px wide` : "mobile");
|
|
30
|
+
let timer;
|
|
31
|
+
const late = new Promise((done) => {
|
|
32
|
+
timer = setTimeout(() => done({
|
|
33
|
+
ok: false,
|
|
34
|
+
unchecked: `the check passed its ${CHECK_MS / 1e3} s deadline`
|
|
35
|
+
}), deadlineMs);
|
|
36
|
+
});
|
|
37
|
+
const by = Date.now() + deadlineMs;
|
|
38
|
+
const run = withBrowser("check", async (b) => {
|
|
39
|
+
const me = {};
|
|
40
|
+
const stop = setTimeout(() => b.abort(me, "the check timed out"), Math.max(0, by - Date.now()));
|
|
41
|
+
let thrown = "";
|
|
42
|
+
let off = () => {};
|
|
43
|
+
try {
|
|
44
|
+
const send = (method, params = {}, sid) => b.send(method, params, sid, me);
|
|
45
|
+
const targetId = (await send("Target.createTarget", { url: "about:blank" })).targetId;
|
|
46
|
+
const sid = (await send("Target.attachToTarget", {
|
|
47
|
+
targetId,
|
|
48
|
+
flatten: true
|
|
49
|
+
})).sessionId;
|
|
50
|
+
off = b.on((m) => {
|
|
51
|
+
if (m.sessionId === sid && m.method === "Runtime.exceptionThrown") thrown = String(m.params?.exceptionDetails?.exception?.description ?? m.params?.exceptionDetails?.text ?? "").split("\n")[0];
|
|
52
|
+
});
|
|
53
|
+
await send("Emulation.setDeviceMetricsOverride", {
|
|
54
|
+
width: size.width,
|
|
55
|
+
height: size.height,
|
|
56
|
+
deviceScaleFactor: 1,
|
|
57
|
+
mobile: false
|
|
58
|
+
}, sid);
|
|
59
|
+
await send("Page.enable", {}, sid);
|
|
60
|
+
await send("Runtime.enable", {}, sid);
|
|
61
|
+
const nav = await send("Page.navigate", { url: frameUrl(req.origin, frame, theme) }, sid);
|
|
62
|
+
if (nav?.errorText && nav.errorText !== "net::ERR_ABORTED") return {
|
|
63
|
+
ok: false,
|
|
64
|
+
unchecked: `the frame did not load (${nav.errorText})`
|
|
65
|
+
};
|
|
66
|
+
const evaluate = async (expression) => (await send("Runtime.evaluate", {
|
|
67
|
+
expression,
|
|
68
|
+
returnByValue: true,
|
|
69
|
+
awaitPromise: true
|
|
70
|
+
}, sid))?.result?.value;
|
|
71
|
+
while (!await evaluate(MOUNTED).catch(() => false)) {
|
|
72
|
+
if (Date.now() > by - 500) return {
|
|
73
|
+
ok: false,
|
|
74
|
+
unchecked: `the frame never rendered${thrown ? ` - it threw: ${thrown}` : ""}`
|
|
75
|
+
};
|
|
76
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
77
|
+
}
|
|
78
|
+
await evaluate("document.fonts.ready.then(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r(true)))))");
|
|
79
|
+
const error = await evaluate("window.__mvFrameError || \"\"") || thrown;
|
|
80
|
+
if (error) return {
|
|
81
|
+
ok: false,
|
|
82
|
+
unchecked: `the frame threw - ${error}`
|
|
83
|
+
};
|
|
84
|
+
const found = await evaluate(`window.__mvAnchorCheck ? window.__mvAnchorCheck(${JSON.stringify(req.target)}, ${JSON.stringify(req.others ?? [])}) : null`);
|
|
85
|
+
if (!found) return {
|
|
86
|
+
ok: false,
|
|
87
|
+
unchecked: "the frame has no Marver bridge to ask"
|
|
88
|
+
};
|
|
89
|
+
if (found.bad) throw new CheckInputError(found.bad);
|
|
90
|
+
if (found.transparent) return {
|
|
91
|
+
ok: false,
|
|
92
|
+
unchecked: "only a transparent element shows that now (a fade-in, a control shown on hover)"
|
|
93
|
+
};
|
|
94
|
+
if (found.none) return {
|
|
95
|
+
ok: false,
|
|
96
|
+
refused: "none",
|
|
97
|
+
visible: found.none,
|
|
98
|
+
viewport,
|
|
99
|
+
theme
|
|
100
|
+
};
|
|
101
|
+
if (found.several) return {
|
|
102
|
+
ok: false,
|
|
103
|
+
refused: "several",
|
|
104
|
+
matches: found.several,
|
|
105
|
+
viewport,
|
|
106
|
+
theme
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
ok: true,
|
|
110
|
+
anchor: found.anchor,
|
|
111
|
+
holders: found.holders ?? [],
|
|
112
|
+
viewport,
|
|
113
|
+
theme
|
|
114
|
+
};
|
|
115
|
+
} finally {
|
|
116
|
+
clearTimeout(stop);
|
|
117
|
+
off();
|
|
118
|
+
b.abort(me, "the check finished");
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
try {
|
|
122
|
+
return await Promise.race([run, late]);
|
|
123
|
+
} catch (err) {
|
|
124
|
+
if (err instanceof CheckInputError) throw err;
|
|
125
|
+
return {
|
|
126
|
+
ok: false,
|
|
127
|
+
unchecked: err.message
|
|
128
|
+
};
|
|
129
|
+
} finally {
|
|
130
|
+
clearTimeout(timer);
|
|
131
|
+
run.catch(() => {});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { CheckInputError, checkAnchor };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AREA, SURFACE, pool, shotConcurrency, withBrowser } from "./shot-
|
|
1
|
+
import { AREA, SURFACE, pool, shotConcurrency, withBrowser } from "./shot-CckrGW-J.mjs";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { join, sep } from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join, sep } from "node:path";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
//#region src/server/hash.ts
|
|
5
|
-
/** sha256 hex of a string - the CAS token for board files, the registry, the manifest. */
|
|
6
|
-
const hash = (s) => createHash("sha256").update(s).digest("hex");
|
|
7
|
-
//#endregion
|
|
8
1
|
//#region src/shared/board-types.ts
|
|
9
2
|
/**
|
|
10
3
|
* Board types (spec 20) - what a board is FOR in the workspace, one vocabulary every canvas
|
|
@@ -160,17 +153,32 @@ const KIND_FOLDERS = {
|
|
|
160
153
|
* board file - one slug, the folder it sits in directly), ranked among its siblings by
|
|
161
154
|
* `order`, and `design/boards/_folders.json` says which folders exist, where they rank, and
|
|
162
155
|
* which folder holds which (`parent`). Two levels: a folder holds boards and folders, a
|
|
163
|
-
* folder inside a folder (a sub-folder) holds boards only.
|
|
164
|
-
* tree - callers pin it last.
|
|
156
|
+
* folder inside a folder (a sub-folder) holds boards only.
|
|
165
157
|
*/
|
|
166
158
|
/** The on-disk name grammar shared by boards and folders (a board name is a filename). */
|
|
167
159
|
const BOARD_NAME = /^[a-z0-9][a-z0-9-]*$/;
|
|
168
160
|
const isBoardName = (n) => typeof n === "string" && n.length >= 1 && n.length <= 64 && BOARD_NAME.test(n);
|
|
169
161
|
/** The folder registry beside the boards - underscore = infrastructure, never a board. */
|
|
170
162
|
const FOLDERS_FILE = "_folders.json";
|
|
171
|
-
/**
|
|
172
|
-
*
|
|
173
|
-
|
|
163
|
+
/** The built-in board every frame sat on until 0.25 (spec 26, Part 7). A reserved name: never
|
|
164
|
+
* created, renamed to or saved, and a leftover file is set aside - but its comment log keeps
|
|
165
|
+
* its name, and old links naming it still land. */
|
|
166
|
+
const ALL_SCENES = "all-scenes";
|
|
167
|
+
/** Is this basename in design/boards/ a board file? `_folders.json`, temp files, any
|
|
168
|
+
* off-grammar name and a leftover `all-scenes.json` are not - every lister (dev API, build,
|
|
169
|
+
* watcher) shares this rule. */
|
|
170
|
+
const isBoardFile = (f) => f.endsWith(".json") && f !== `all-scenes.json` && isBoardName(f.slice(0, -5));
|
|
171
|
+
/** One meaning of "on a board": the live frames a board shows - those its nodes hold, or every
|
|
172
|
+
* live frame when it says `"auto": true`. Every check, hint, link, mark and the Not on a board
|
|
173
|
+
* list asks here. */
|
|
174
|
+
function framesOn(board, live) {
|
|
175
|
+
const b = board;
|
|
176
|
+
if (b?.auto === true) return [...live];
|
|
177
|
+
const held = new Set(Array.isArray(b?.nodes) ? b.nodes.map((n) => n?.frame) : []);
|
|
178
|
+
return live.filter((f) => held.has(f));
|
|
179
|
+
}
|
|
180
|
+
/** Sidebar order with archive boards last - history is not where a change is reviewed. */
|
|
181
|
+
const archiveLast = (order, isArchive) => [...order.filter((n) => !isArchive(n)), ...order.filter(isArchive)];
|
|
174
182
|
const readDescription = (v) => {
|
|
175
183
|
if (typeof v !== "string") return void 0;
|
|
176
184
|
return v.trim().replace(/\s+/g, " ").slice(0, 300) || void 0;
|
|
@@ -353,268 +361,4 @@ function folderMap(t) {
|
|
|
353
361
|
return out;
|
|
354
362
|
}
|
|
355
363
|
//#endregion
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Reading design/boards/ safely - the one enumerator the dev API, the build and the tests
|
|
359
|
-
* share. Only REGULAR files on the board-name grammar count as boards (a symlink, dangling or
|
|
360
|
-
* live, could read or publish JSON from outside the project - it is skipped, and reported so
|
|
361
|
-
* the build can fail closed). The folder registry is read the same way: absent = no folders,
|
|
362
|
-
* malformed = an error the human must fix, never a silently empty registry.
|
|
363
|
-
*/
|
|
364
|
-
/** Does realpath(dir) stay inside realpath(root)? A symlinked design/boards can't escape. */
|
|
365
|
-
function underRoot(root, dir) {
|
|
366
|
-
try {
|
|
367
|
-
const rr = realpathSync(root);
|
|
368
|
-
const rd = realpathSync(dir);
|
|
369
|
-
return rd === rr || rd.startsWith(rr + sep);
|
|
370
|
-
} catch {
|
|
371
|
-
return false;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
/** Is design/boards a directory we may read and write? It must not be a symlink at all (a
|
|
375
|
-
* link to the repo root would list package.json as a board and let a tree write rewrite
|
|
376
|
-
* it; a link outside would publish foreign JSON) and must resolve inside the root. Absent
|
|
377
|
-
* is fine (no boards yet). Returns the error, or null. */
|
|
378
|
-
function checkBoardsDir(root, boardsDir) {
|
|
379
|
-
return checkRealDirs(root, [[join(boardsDir, ".."), "design"], [boardsDir, "design/boards"]]);
|
|
380
|
-
}
|
|
381
|
-
/** Every EXISTING path in `dirs` (root-down order) must be a real directory inside the root -
|
|
382
|
-
* a symlinked `design` with no boards dir yet would otherwise be followed by the mkdir that
|
|
383
|
-
* creates it; a symlinked `design/scenes` would let a brief write land outside the project.
|
|
384
|
-
* An absent one ends the walk (nothing beneath it exists either). Returns the error, or null. */
|
|
385
|
-
function checkRealDirs(root, dirs) {
|
|
386
|
-
for (const [p, label] of dirs) {
|
|
387
|
-
try {
|
|
388
|
-
if (lstatSync(p).isSymbolicLink()) return `${label} must be a real directory, not a symlink`;
|
|
389
|
-
} catch {
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
392
|
-
if (!underRoot(root, p)) return `${label} escapes the project`;
|
|
393
|
-
}
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
/** A regular file (lstat: a symlink is never followed, a dangling one is not "absent"). */
|
|
397
|
-
const isRegularFile = (p) => {
|
|
398
|
-
try {
|
|
399
|
-
return lstatSync(p).isFile();
|
|
400
|
-
} catch {
|
|
401
|
-
return false;
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
/** Is there ANY node at p (a dangling symlink counts)? */
|
|
405
|
-
const nodeExists = (p) => {
|
|
406
|
-
try {
|
|
407
|
-
lstatSync(p);
|
|
408
|
-
return true;
|
|
409
|
-
} catch {
|
|
410
|
-
return false;
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
/** A board file's JSON, or why it is not JSON - the parser's own words, naming the line and column (#6). */
|
|
414
|
-
function parseBoard(content) {
|
|
415
|
-
try {
|
|
416
|
-
return { json: JSON.parse(content) };
|
|
417
|
-
} catch (e) {
|
|
418
|
-
const msg = e.message, lines = content.split("\n");
|
|
419
|
-
return {
|
|
420
|
-
json: null,
|
|
421
|
-
error: /end of JSON input$/.test(msg) ? `${msg} (line ${lines.length} column ${lines[lines.length - 1].length + 1})` : msg
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
/** Every board file: name, raw content, hash, and its JSON (null when malformed). `skipped`
|
|
426
|
-
* names the entries that looked like boards but were not regular files. */
|
|
427
|
-
function listBoardFiles(boardsDir) {
|
|
428
|
-
const boards = [], skipped = [];
|
|
429
|
-
if (!existsSync(boardsDir)) return {
|
|
430
|
-
boards,
|
|
431
|
-
skipped
|
|
432
|
-
};
|
|
433
|
-
for (const f of readdirSync(boardsDir)) {
|
|
434
|
-
if (!isBoardFile(f)) continue;
|
|
435
|
-
const file = join(boardsDir, f);
|
|
436
|
-
if (!isRegularFile(file)) {
|
|
437
|
-
skipped.push(f);
|
|
438
|
-
continue;
|
|
439
|
-
}
|
|
440
|
-
const content = readFileSync(file, "utf8");
|
|
441
|
-
boards.push({
|
|
442
|
-
name: f.slice(0, -5),
|
|
443
|
-
file,
|
|
444
|
-
content,
|
|
445
|
-
sha256: hash(content),
|
|
446
|
-
...parseBoard(content)
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
return {
|
|
450
|
-
boards,
|
|
451
|
-
skipped
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
function boardFields(json, validName) {
|
|
455
|
-
const o = json;
|
|
456
|
-
const title = readTitle(o?.title);
|
|
457
|
-
const description = readDescription(o?.description);
|
|
458
|
-
const type = readType(o?.type), capability = readCapability(o?.capability), status = readStatusWord(o?.status), reason = readReason(o?.reason);
|
|
459
|
-
return {
|
|
460
|
-
...typeof o?.order === "number" && Number.isFinite(o.order) ? { order: o.order } : {},
|
|
461
|
-
...validName(o?.folder) ? { folder: o.folder } : {},
|
|
462
|
-
...title ? { title } : {},
|
|
463
|
-
...description ? { description } : {},
|
|
464
|
-
...type ? { type } : {},
|
|
465
|
-
...capability ? { capability } : {},
|
|
466
|
-
...status ? { status } : {},
|
|
467
|
-
...reason ? { reason } : {}
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
/** The fields a board's file owns that the shell's save shape never carries: an autosave keeps
|
|
471
|
-
* each one from disk when the incoming board omits it (spec 20 - the fields survive every write). */
|
|
472
|
-
const AUTHOR_FIELDS = [
|
|
473
|
-
"order",
|
|
474
|
-
"folder",
|
|
475
|
-
"title",
|
|
476
|
-
"description",
|
|
477
|
-
"type",
|
|
478
|
-
"capability",
|
|
479
|
-
"status",
|
|
480
|
-
"reason"
|
|
481
|
-
];
|
|
482
|
-
/** The folder registry. `sha256` is the CAS token a tree write must echo (null = "there was
|
|
483
|
-
* no file"), so a write can never silently replace a registry it never saw. */
|
|
484
|
-
function readRegistry(boardsDir) {
|
|
485
|
-
const p = join(boardsDir, FOLDERS_FILE);
|
|
486
|
-
if (!nodeExists(p)) return {
|
|
487
|
-
state: "absent",
|
|
488
|
-
folders: [],
|
|
489
|
-
sha256: null
|
|
490
|
-
};
|
|
491
|
-
if (!isRegularFile(p)) return {
|
|
492
|
-
state: "malformed",
|
|
493
|
-
error: `design/boards/${FOLDERS_FILE} must be a regular file, not a symlink`,
|
|
494
|
-
sha256: null
|
|
495
|
-
};
|
|
496
|
-
const content = readFileSync(p, "utf8");
|
|
497
|
-
let raw;
|
|
498
|
-
try {
|
|
499
|
-
raw = JSON.parse(content);
|
|
500
|
-
} catch {
|
|
501
|
-
return {
|
|
502
|
-
state: "malformed",
|
|
503
|
-
error: `design/boards/${FOLDERS_FILE} is not valid JSON - fix the file`,
|
|
504
|
-
sha256: hash(content)
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
const parsed = parseFolders(raw);
|
|
508
|
-
if (typeof parsed === "string") return {
|
|
509
|
-
state: "malformed",
|
|
510
|
-
error: `design/boards/${FOLDERS_FILE}: ${parsed}`,
|
|
511
|
-
sha256: hash(content)
|
|
512
|
-
};
|
|
513
|
-
return {
|
|
514
|
-
state: "ok",
|
|
515
|
-
folders: parsed,
|
|
516
|
-
sha256: hash(content)
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
/** The registry's write lock - one writer at a time across processes (the dev server's tree write,
|
|
520
|
-
* `folders add`, `init --kind`), so a read-modify-write of `_folders.json` is atomic among Marver's
|
|
521
|
-
* writers. A lock older than 10 s is a crashed writer's and is taken over. `wait` = how long to
|
|
522
|
-
* try (the CLI waits; the dev server never blocks its event loop - it answers 409 instead). */
|
|
523
|
-
const REGISTRY_LOCK = ".folders.lock";
|
|
524
|
-
function withRegistryLock(dir, wait, fn) {
|
|
525
|
-
const lock = join(dir, REGISTRY_LOCK);
|
|
526
|
-
const t0 = Date.now();
|
|
527
|
-
for (;;) try {
|
|
528
|
-
writeFileSync(lock, `${process.pid} ${Date.now()}\n`, { flag: "wx" });
|
|
529
|
-
break;
|
|
530
|
-
} catch (e) {
|
|
531
|
-
if (e.code !== "EEXIST") throw e;
|
|
532
|
-
try {
|
|
533
|
-
if (Date.now() - lstatSync(lock).mtimeMs > 1e4) {
|
|
534
|
-
rmSync(lock, { force: true });
|
|
535
|
-
continue;
|
|
536
|
-
}
|
|
537
|
-
} catch {
|
|
538
|
-
continue;
|
|
539
|
-
}
|
|
540
|
-
if (Date.now() - t0 >= wait) return null;
|
|
541
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 25);
|
|
542
|
-
}
|
|
543
|
-
try {
|
|
544
|
-
return fn();
|
|
545
|
-
} finally {
|
|
546
|
-
rmSync(lock, { force: true });
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
/** Append typed folders to the registry (spec 20: `init --kind`, `folders add`). Never renames,
|
|
550
|
-
* moves or retypes a folder that exists - a name already registered is skipped and reported - and
|
|
551
|
-
* never drops a field of an existing entry it does not manage. New folders rank after everything
|
|
552
|
-
* already at the root. The write is compare-and-swap: the registry is re-read just before the
|
|
553
|
-
* atomic rename, and a change since the first read (the shell's drag, another agent) starts the
|
|
554
|
-
* append over from the new file. A malformed registry is an error, never overwritten. */
|
|
555
|
-
function addFolders(root, folders) {
|
|
556
|
-
const dir = join(root, "design", "boards");
|
|
557
|
-
const de = checkBoardsDir(root, dir);
|
|
558
|
-
if (de) throw new Error(de);
|
|
559
|
-
mkdirSync(dir, { recursive: true });
|
|
560
|
-
const file = join(dir, FOLDERS_FILE);
|
|
561
|
-
const done = withRegistryLock(dir, 5e3, () => appendFolders(dir, file, folders));
|
|
562
|
-
if (!done) throw new Error(`design/boards/${FOLDERS_FILE} is being written by another process - try again`);
|
|
563
|
-
return done;
|
|
564
|
-
}
|
|
565
|
-
function appendFolders(dir, file, folders) {
|
|
566
|
-
for (let attempt = 0; attempt < 5; attempt++) {
|
|
567
|
-
const before = nodeExists(file) ? readFileSync(file, "utf8") : null;
|
|
568
|
-
const reg = readRegistry(dir);
|
|
569
|
-
if (reg.state === "malformed") throw new Error(reg.error);
|
|
570
|
-
let raw = [];
|
|
571
|
-
if (before !== null) {
|
|
572
|
-
const j = JSON.parse(before);
|
|
573
|
-
raw = Array.isArray(j.folders) ? j.folders : [];
|
|
574
|
-
}
|
|
575
|
-
const have = new Set(raw.map((f) => f.name));
|
|
576
|
-
const rootRanks = [...raw.filter((f) => f.parent === void 0).map((f) => f.order), ...listBoardFiles(dir).boards.map((b) => {
|
|
577
|
-
const o = b.json;
|
|
578
|
-
return o?.folder ? void 0 : o?.order;
|
|
579
|
-
})].filter((o) => typeof o === "number" && Number.isFinite(o));
|
|
580
|
-
let next = rootRanks.length ? Math.max(...rootRanks) + 1 : 0;
|
|
581
|
-
const added = [], existing = [];
|
|
582
|
-
const rows = [...raw];
|
|
583
|
-
for (const f of folders) {
|
|
584
|
-
if (have.has(f.name)) {
|
|
585
|
-
existing.push(f.name);
|
|
586
|
-
continue;
|
|
587
|
-
}
|
|
588
|
-
rows.push({
|
|
589
|
-
name: f.name,
|
|
590
|
-
order: next++,
|
|
591
|
-
...f.title ? { title: f.title } : {},
|
|
592
|
-
...f.type ? { type: f.type } : {}
|
|
593
|
-
});
|
|
594
|
-
have.add(f.name);
|
|
595
|
-
added.push(f.name);
|
|
596
|
-
}
|
|
597
|
-
if (!added.length) return {
|
|
598
|
-
added,
|
|
599
|
-
existing
|
|
600
|
-
};
|
|
601
|
-
const version = rows.some((f) => f.parent !== void 0) ? 2 : 1;
|
|
602
|
-
const tmp = `${file}.${process.pid}.${Date.now()}.${attempt}.tmp`;
|
|
603
|
-
writeFileSync(tmp, JSON.stringify({
|
|
604
|
-
version,
|
|
605
|
-
folders: rows
|
|
606
|
-
}, null, 2) + "\n", { flag: "wx" });
|
|
607
|
-
if ((nodeExists(file) ? readFileSync(file, "utf8") : null) !== before) {
|
|
608
|
-
rmSync(tmp, { force: true });
|
|
609
|
-
continue;
|
|
610
|
-
}
|
|
611
|
-
renameSync(tmp, file);
|
|
612
|
-
return {
|
|
613
|
-
added,
|
|
614
|
-
existing
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
throw new Error(`design/boards/${FOLDERS_FILE} kept changing while folders were added - try again`);
|
|
618
|
-
}
|
|
619
|
-
//#endregion
|
|
620
|
-
export { knownType as A, wireKids as C, HAS_STATUS as D, FOLDER_MODULES as E, resolveType as F, settableStatuses as I, hash as L, readReason as M, readStatusWord as N, KIND_FOLDERS as O, readType as P, validateWire as S, DECISIONS as T, folderMap as _, checkRealDirs as a, readDescription as b, nodeExists as c, withRegistryLock as d, BOARD_NAME as f, folderEntries as g, flatten as h, checkBoardsDir as i, readCapability as j, PROPOSED_PUBLISH as k, parseBoard as l, buildTree as m, addFolders as n, isRegularFile as o, FOLDERS_FILE as p, boardFields as r, listBoardFiles as s, AUTHOR_FIELDS as t, readRegistry as u, humanize as v, BOARD_TYPES as w, readTitle as x, isBoardName as y };
|
|
364
|
+
export { settableStatuses as A, PROPOSED_PUBLISH as C, readStatusWord as D, readReason as E, readType as O, KIND_FOLDERS as S, readCapability as T, wireKids as _, buildTree as a, FOLDER_MODULES as b, folderMap as c, isBoardFile as d, isBoardName as f, validateWire as g, readTitle as h, archiveLast as i, resolveType as k, framesOn as l, readDescription as m, BOARD_NAME as n, flatten as o, parseFolders as p, FOLDERS_FILE as r, folderEntries as s, ALL_SCENES as t, humanize as u, BOARD_TYPES as v, knownType as w, HAS_STATUS as x, DECISIONS as y };
|