@marver-design/marver 0.22.1 → 0.23.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 +84 -0
- package/README.md +13 -9
- package/dist/agent-BsieQGTD.mjs +99 -0
- package/dist/{bake-CvY8QR3L.mjs → bake-l6N12qgx.mjs} +1 -1
- package/dist/{board-status-CWGHIdo_.mjs → board-status-D_lHZZ09.mjs} +69 -610
- package/dist/{boards-BwKI0qWd.mjs → boards-CahYhF5B.mjs} +2 -1
- package/dist/boards-DbVJlbd5.mjs +612 -0
- package/dist/{build-B1kavcpc.mjs → build-CuRhHXcY.mjs} +10 -6
- package/dist/cli.mjs +20 -11
- package/dist/{comments-ClVgfQib.mjs → comments-0d3e274b.mjs} +71 -9
- package/dist/{config-DJxMRVD8.mjs → config-g-J8NrPn.mjs} +5 -97
- package/dist/{context-D4t59wDi.mjs → context-fAtQLHt2.mjs} +3 -2
- package/dist/{daemon-PmNqoOAk.mjs → daemon-DZ367fiM.mjs} +75 -17
- package/dist/{dev-Cf4wLGe2.mjs → dev-R6zvwbqX.mjs} +50 -10
- package/dist/{init-C_K-cjBQ.mjs → init-DAnBlt-V.mjs} +4 -3
- package/dist/{ledger-Bu0BjqIe.mjs → ledger-BNXW14Xw.mjs} +1 -6
- package/dist/link-CcfAfKY-.mjs +132 -0
- package/dist/{manifest-CcdWx7ud.mjs → manifest-BkjJ5OQk.mjs} +50 -5
- package/dist/{plugin-C5u07Yhv.mjs → plugin-C1avHL7g.mjs} +357 -31
- package/dist/{poster-BduzQBYz.mjs → poster-Bc4-3DlQ.mjs} +1 -1
- package/dist/{profile-BjAPAJSb.mjs → profile-CrZohD6g.mjs} +1 -1
- package/dist/{publish-bakes-b0jUwvM_.mjs → publish-bakes-DQWn14IY.mjs} +2 -2
- package/dist/{share--bdSc4G5.mjs → share-BD-wcDQq.mjs} +1 -1
- package/dist/{shot-BFEuYbaz.mjs → shot-C1YR_Sqx.mjs} +1 -1
- package/dist/{shot-BAR8hmU9.mjs → shot-CVOlQHUr.mjs} +2 -2
- package/dist/{sync-BZaCWqK-.mjs → sync-DoA1vf4u.mjs} +15 -1
- package/dist/{work-0YopuMt9.mjs → work-CJ8OIpBD.mjs} +9 -3
- package/dist/{work-CLrmY-vQ.mjs → work-CiUvBVa6.mjs} +72 -1
- package/docs/boards-and-folders.md +54 -6
- package/docs/context.md +10 -2
- package/docs/live-jam.md +11 -0
- package/package.json +1 -1
- package/src/client/content/diagram.tsx +7 -1
- package/src/client/content/img-lod.ts +12 -2
- package/src/client/content/index.tsx +69 -6
- package/src/client/frame-host/inspect.js +23 -0
- package/src/client/shell/App.tsx +19 -9
- package/src/client/shell/BoardList.tsx +21 -6
- package/src/client/shell/LockedApp.tsx +2 -2
- package/src/client/shell/Play.tsx +5 -1
- package/src/client/shell/StatusPicker.tsx +12 -5
- package/src/client/shell/Tip.tsx +25 -5
- package/src/client/shell/board-icons.tsx +15 -1
- package/src/client/shell/canvas/Canvas.tsx +42 -6
- package/src/client/shell/canvas/anchor.ts +41 -0
- package/src/client/shell/canvas/ctl.ts +6 -0
- package/src/client/shell/comments-store.ts +8 -5
- package/src/client/shell/goto.ts +52 -3
- package/src/client/shell/hash.ts +24 -3
- package/src/client/shell/store.ts +242 -28
- package/src/client/shell/styles.css +19 -2
- package/src/shared/board-types.ts +10 -6
- package/src/shared/status.ts +17 -8
- package/templates/AGENTS-embedded.md +43 -8
- package/templates/AGENTS-studio.md +43 -8
- package/templates/instructions/boards.md +13 -3
- package/templates/instructions/context.md +6 -2
- package/templates/instructions/iterate.md +29 -16
- package/templates/instructions/jam.md +9 -2
- package/templates/instructions/reference/deck-layouts.md +2 -1
- package/templates/instructions/reference/deck-story.md +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as PKG, r as NAME } from "./cli.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { n as tailwind3Css, r as tailwind4Plugin, t as marverPlugin } from "./plugin-
|
|
4
|
-
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { n as loadConfig, r as detectHost } from "./config-g-J8NrPn.mjs";
|
|
3
|
+
import { n as tailwind3Css, r as tailwind4Plugin, t as marverPlugin } from "./plugin-C1avHL7g.mjs";
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, watch } from "node:fs";
|
|
5
5
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { createLogger, createServer, parseAst, searchForWorkspaceRoot } from "vite";
|
|
@@ -454,12 +454,12 @@ async function dev(root, portFlag) {
|
|
|
454
454
|
console.log(`\n ${NAME} · ${projectName} → http://localhost:${port}/\n`);
|
|
455
455
|
setTimeout(async () => {
|
|
456
456
|
try {
|
|
457
|
-
await (await import("./shot-
|
|
457
|
+
await (await import("./shot-CVOlQHUr.mjs")).sweepGhosts((m) => console.log(` ${m}`));
|
|
458
458
|
} catch {}
|
|
459
459
|
}, 0);
|
|
460
460
|
try {
|
|
461
461
|
const { staleManagedInstructions } = await import("./managed-HwHVNI3h.mjs");
|
|
462
|
-
const { installedVersion } = await import("./plugin-
|
|
462
|
+
const { installedVersion } = await import("./plugin-C1avHL7g.mjs").then((n) => n.i);
|
|
463
463
|
const stale = staleManagedInstructions(root);
|
|
464
464
|
if (stale.length) {
|
|
465
465
|
const shown = stale.slice(0, 4).join(", ") + (stale.length > 4 ? `, +${stale.length - 4} more` : "");
|
|
@@ -469,11 +469,11 @@ async function dev(root, portFlag) {
|
|
|
469
469
|
} catch {}
|
|
470
470
|
try {
|
|
471
471
|
if (!existsSync(join(root, "context"))) {
|
|
472
|
-
const n = (await import("./manifest-
|
|
472
|
+
const n = (await import("./manifest-BkjJ5OQk.mjs").then((n) => n.i)).statusBoards(root).length;
|
|
473
473
|
if (n) console.log(` ${n} feature/project board${n === 1 ? "" : "s"}, no context/ - every status reads Backlog. To start it, tell your agent: "Set up our context."\n`);
|
|
474
474
|
}
|
|
475
475
|
} catch {}
|
|
476
|
-
const { loadCollab, syncOnce } = await import("./sync-
|
|
476
|
+
const { loadCollab, syncOnce } = await import("./sync-DoA1vf4u.mjs").then((n) => n.o);
|
|
477
477
|
if (loadCollab(root)) console.log(` comments: syncing with the published canvas\n`);
|
|
478
478
|
let syncing = false;
|
|
479
479
|
const tick = async () => {
|
|
@@ -488,8 +488,25 @@ async function dev(root, portFlag) {
|
|
|
488
488
|
};
|
|
489
489
|
tick();
|
|
490
490
|
setInterval(tick, 3e4).unref();
|
|
491
|
-
const { workActivity, writeDevInfo, removeDevInfo } = await import("./work-
|
|
492
|
-
|
|
491
|
+
const { workActivity, writeDevInfo, removeDevInfo, boardsShowing, onBoardsChanged, nextActivitySeq } = await import("./work-CiUvBVa6.mjs").then((n) => n.o);
|
|
492
|
+
let sent = "";
|
|
493
|
+
const broadcast = (frames) => {
|
|
494
|
+
const state = {
|
|
495
|
+
frames: [...frames].sort(),
|
|
496
|
+
boards: boardsShowing(root, frames)
|
|
497
|
+
};
|
|
498
|
+
const key = JSON.stringify(state);
|
|
499
|
+
if (key === sent) return;
|
|
500
|
+
sent = key;
|
|
501
|
+
server.ws.send("sh:jam-activity", {
|
|
502
|
+
...state,
|
|
503
|
+
seq: nextActivitySeq()
|
|
504
|
+
});
|
|
505
|
+
};
|
|
506
|
+
const unsubscribe = workActivity.onChange(broadcast);
|
|
507
|
+
const offBoards = onBoardsChanged((r) => {
|
|
508
|
+
if (r === root) broadcast(workActivity.active());
|
|
509
|
+
});
|
|
493
510
|
const sweep = setInterval(() => workActivity.sweep(), 15e3);
|
|
494
511
|
sweep.unref?.();
|
|
495
512
|
writeDevInfo(root, port);
|
|
@@ -497,13 +514,36 @@ async function dev(root, portFlag) {
|
|
|
497
514
|
const close = server.close.bind(server);
|
|
498
515
|
server.close = (async () => {
|
|
499
516
|
unsubscribe();
|
|
517
|
+
offBoards();
|
|
500
518
|
clearInterval(sweep);
|
|
501
519
|
removeDevInfo(root);
|
|
502
520
|
return close();
|
|
503
521
|
});
|
|
504
522
|
}
|
|
523
|
+
{
|
|
524
|
+
const dir = join(root, "design", "comments");
|
|
525
|
+
const due = /* @__PURE__ */ new Map();
|
|
526
|
+
try {
|
|
527
|
+
mkdirSync(dir, { recursive: true });
|
|
528
|
+
const w = watch(dir, { persistent: false }, (_e, file) => {
|
|
529
|
+
const m = typeof file === "string" ? file.match(/^([a-z0-9][a-z0-9-]*)\.jsonl$/) : null;
|
|
530
|
+
if (!m) return;
|
|
531
|
+
clearTimeout(due.get(m[1]));
|
|
532
|
+
due.set(m[1], setTimeout(() => {
|
|
533
|
+
due.delete(m[1]);
|
|
534
|
+
server.ws.send("sh:jam-comment", { board: m[1] });
|
|
535
|
+
}, 120));
|
|
536
|
+
});
|
|
537
|
+
const close = server.close.bind(server);
|
|
538
|
+
server.close = (async () => {
|
|
539
|
+
w.close();
|
|
540
|
+
for (const t of due.values()) clearTimeout(t);
|
|
541
|
+
return close();
|
|
542
|
+
});
|
|
543
|
+
} catch {}
|
|
544
|
+
}
|
|
505
545
|
if (config.jam) {
|
|
506
|
-
const { startJam } = await import("./daemon-
|
|
546
|
+
const { startJam } = await import("./daemon-DZ367fiM.mjs");
|
|
507
547
|
const jam = startJam(root, config.jam, (m) => console.log(m), (board) => server.ws.send("sh:jam-comment", { board }));
|
|
508
548
|
if (jam) {
|
|
509
549
|
const close = server.close.bind(server);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { D as KIND_FOLDERS, T as FOLDER_MODULES, n as addFolders } from "./boards-DbVJlbd5.mjs";
|
|
3
|
+
import { r as detectAgent } from "./agent-BsieQGTD.mjs";
|
|
3
4
|
import { MANAGED_PREFIX, enumerateInstructionTemplates, hashBody, pkgDir } from "./managed-HwHVNI3h.mjs";
|
|
4
5
|
import { t as writeManaged } from "./managed-write-Bo-oPc-i.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { l as writeManifest, o as scanFrames } from "./manifest-BkjJ5OQk.mjs";
|
|
7
|
+
import { i as readJson, r as detectHost, t as DEFAULTS } from "./config-g-J8NrPn.mjs";
|
|
7
8
|
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
8
9
|
import { basename, dirname, join, relative } from "node:path";
|
|
9
10
|
//#region src/cli/init.ts
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
1
|
import { closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, writeSync } from "node:fs";
|
|
3
2
|
import { dirname, join } from "node:path";
|
|
4
3
|
import { createHash } from "node:crypto";
|
|
@@ -59,10 +58,6 @@ function deviceId() {
|
|
|
59
58
|
* design/.local/ and hand a clone a ledger full of pre-authorized ids. Lines stamped with
|
|
60
59
|
* another machine match nothing here (device.ts).
|
|
61
60
|
*/
|
|
62
|
-
var ledger_exports = /* @__PURE__ */ __exportAll({
|
|
63
|
-
has: () => has,
|
|
64
|
-
record: () => record
|
|
65
|
-
});
|
|
66
61
|
const ledgerFile = (root) => join(root, "design", ".local", "jam-ledger");
|
|
67
62
|
const line = (board, id) => `${deviceId()}\t${board}\t${id}`;
|
|
68
63
|
/** Was this (board, id) authorized on this device by the gated dev POST? */
|
|
@@ -89,4 +84,4 @@ function record(root, board, id) {
|
|
|
89
84
|
}
|
|
90
85
|
}
|
|
91
86
|
//#endregion
|
|
92
|
-
export {
|
|
87
|
+
export { has, record, deviceId as t };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { r as NAME } from "./cli.mjs";
|
|
2
|
+
import { P as resolveType, g as folderMap, i as checkBoardsDir, l as readRegistry, m as flatten, p as buildTree, r as boardFields, s as listBoardFiles, v as isBoardName } from "./boards-DbVJlbd5.mjs";
|
|
3
|
+
import { o as scanFrames } from "./manifest-BkjJ5OQk.mjs";
|
|
4
|
+
import { i as readDevInfo } from "./work-CiUvBVa6.mjs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
//#region src/cli/link.ts
|
|
7
|
+
/**
|
|
8
|
+
* `marver link <scene/frame | scene ...>` - the canvas link that lands ON the work: the board the
|
|
9
|
+
* frames sit on, opened in canvas mode with them selected and the camera fitted (never past 100%) -
|
|
10
|
+
* not the full-screen focus view. An agent knows frame ids and scene names; it does not know the
|
|
11
|
+
* shell's node keys or which port `marver dev` took, so it asks here and pastes what comes back.
|
|
12
|
+
* `work done` prints the same link for the frames it clears; `comments new` prints its thread's.
|
|
13
|
+
*
|
|
14
|
+
* The board: `--board` when given; else the first board in sidebar order that shows EVERY frame
|
|
15
|
+
* asked for (archive boards last - history is not where a change is reviewed); else `all-scenes`,
|
|
16
|
+
* which holds every frame.
|
|
17
|
+
*/
|
|
18
|
+
function resolveLink(root, targets, board) {
|
|
19
|
+
if (!targets.length) throw new Error("name what to link: link <scene/frame | scene ...>");
|
|
20
|
+
const known = scanFrames(root).frames.map((f) => f.id);
|
|
21
|
+
const ids = new Set(known);
|
|
22
|
+
const frames = [], scenes = [], all = [], exact = [];
|
|
23
|
+
for (const raw of targets) {
|
|
24
|
+
const t = raw.replace(/^design\/scenes\//, "").replace(/\.(tsx|jsx|html)$/, "").replace(/\/+$/, "");
|
|
25
|
+
if (ids.has(t)) {
|
|
26
|
+
if (!frames.includes(t)) frames.push(t);
|
|
27
|
+
if (!all.includes(t)) all.push(t);
|
|
28
|
+
if (!exact.includes(t)) exact.push(t);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const members = known.filter((id) => id.startsWith(`${t}/`));
|
|
32
|
+
if (members.length) {
|
|
33
|
+
if (t.includes("/")) for (const m of members) {
|
|
34
|
+
if (!frames.includes(m)) frames.push(m);
|
|
35
|
+
if (!all.includes(m)) all.push(m);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (!scenes.includes(t)) scenes.push(t);
|
|
39
|
+
for (const m of members) if (!all.includes(m)) all.push(m);
|
|
40
|
+
}
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
throw new Error(`no frame or scene "${raw}" in design/scenes/ - a frame is <scene>/<name>, a scene is its folder`);
|
|
44
|
+
}
|
|
45
|
+
const dir = join(root, "design", "boards");
|
|
46
|
+
const files = checkBoardsDir(root, dir) ? [] : listBoardFiles(dir).boards;
|
|
47
|
+
const nodesOf = (name) => {
|
|
48
|
+
const json = files.find((b) => b.name === name)?.json;
|
|
49
|
+
return Array.isArray(json?.nodes) ? json.nodes.filter((n) => !!n && typeof n.frame === "string") : [];
|
|
50
|
+
};
|
|
51
|
+
const shows = (name) => {
|
|
52
|
+
const pins = new Set(nodesOf(name).map((n) => n.frame));
|
|
53
|
+
return all.every((f) => pins.has(f));
|
|
54
|
+
};
|
|
55
|
+
let pick = board;
|
|
56
|
+
let fellBack = false;
|
|
57
|
+
if (pick) {
|
|
58
|
+
if (!isBoardName(pick)) throw new Error(`"${pick}" is not a board name`);
|
|
59
|
+
if (pick !== "all-scenes" && !files.some((b) => b.name === pick)) throw new Error(`no board "${pick}" in design/boards/`);
|
|
60
|
+
if (pick !== "all-scenes" && !shows(pick)) {
|
|
61
|
+
const missing = all.filter((f) => !nodesOf(pick).some((n) => n.frame === f));
|
|
62
|
+
throw new Error(`board "${pick}" does not show ${missing.join(", ")} - pin ${missing.length === 1 ? "it" : "them"} there first, or leave --board out`);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
const reg = readRegistry(dir);
|
|
66
|
+
const folders = reg.state === "ok" ? reg.folders : [];
|
|
67
|
+
const rows = files.filter((b) => b.name !== "all-scenes").map((b) => ({
|
|
68
|
+
name: b.name,
|
|
69
|
+
...boardFields(b.json, isBoardName)
|
|
70
|
+
}));
|
|
71
|
+
const tree = buildTree(rows, folders);
|
|
72
|
+
const order = flatten(tree);
|
|
73
|
+
const fm = folderMap(tree);
|
|
74
|
+
const byName = new Map(folders.map((f) => [f.name, f]));
|
|
75
|
+
const typeOf = (n) => {
|
|
76
|
+
const folder = byName.get(fm.get(n) ?? "");
|
|
77
|
+
return resolveType(rows.find((r) => r.name === n)?.type, folder?.type, folder?.parent ? byName.get(folder.parent)?.type : void 0);
|
|
78
|
+
};
|
|
79
|
+
const isArchive = (n) => n === "archive" || typeOf(n) === "archive";
|
|
80
|
+
pick = [...order.filter((n) => !isArchive(n)), ...order.filter(isArchive)].find(shows);
|
|
81
|
+
if (!pick) {
|
|
82
|
+
pick = "all-scenes";
|
|
83
|
+
fellBack = true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const q = [frames.length ? `f=${frames.join(",")}` : "", scenes.length ? `s=${scenes.join(",")}` : ""].filter(Boolean).join("&");
|
|
87
|
+
return {
|
|
88
|
+
board: pick,
|
|
89
|
+
frames,
|
|
90
|
+
exact,
|
|
91
|
+
scenes,
|
|
92
|
+
all,
|
|
93
|
+
hash: `#/b/${pick}?${q}`,
|
|
94
|
+
...fellBack ? { fellBack } : {},
|
|
95
|
+
nodesOf
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** The dev server's origin when it is running in this repo and answers like `marver dev` - else null. */
|
|
99
|
+
async function devOrigin(root) {
|
|
100
|
+
const info = readDevInfo(root);
|
|
101
|
+
if (!info) return null;
|
|
102
|
+
try {
|
|
103
|
+
const res = await fetch(`http://localhost:${info.port}/__mv/api/work`, {
|
|
104
|
+
headers: { "x-mv-work": info.token },
|
|
105
|
+
signal: AbortSignal.timeout(1500)
|
|
106
|
+
});
|
|
107
|
+
const data = await res.json().catch(() => null);
|
|
108
|
+
return res.ok && Array.isArray(data?.frames) ? `http://localhost:${info.port}/` : null;
|
|
109
|
+
} catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const NOT_RUNNING = `\`${NAME} dev\` is not running in this repo - start it (\`npx ${NAME} dev\`), then run this again: the link carries its port`;
|
|
114
|
+
async function linkCommand(root, targets, opts) {
|
|
115
|
+
const r = resolveLink(root, targets, opts.board);
|
|
116
|
+
const origin = await devOrigin(root);
|
|
117
|
+
if (!origin) throw new Error(NOT_RUNNING);
|
|
118
|
+
if (r.fellBack) console.error(` (no curated board shows ${r.all.length === 1 ? "it" : "all of them"} - the link opens on all-scenes; pin ${r.all.length === 1 ? "it" : "them"} on a board for a tighter view)`);
|
|
119
|
+
console.log(`${origin}${r.hash}`);
|
|
120
|
+
}
|
|
121
|
+
/** The link line other commands print after their own output - never fails them. */
|
|
122
|
+
async function linkLine(root, targets) {
|
|
123
|
+
try {
|
|
124
|
+
const r = resolveLink(root, targets);
|
|
125
|
+
const origin = await devOrigin(root);
|
|
126
|
+
return origin ? `${origin}${r.hash}` : null;
|
|
127
|
+
} catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { devOrigin, linkCommand, linkLine, resolveLink };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { i as PKG, n as CONTENT_WIDTH } from "./cli.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { I as hash, a as checkRealDirs, b as readTitle, h as folderEntries, i as checkBoardsDir, l as readRegistry, m as flatten, p as buildTree, r as boardFields, s as listBoardFiles, v as isBoardName, y as readDescription } from "./boards-DbVJlbd5.mjs";
|
|
4
|
+
import { t as annotateBoards } from "./board-status-D_lHZZ09.mjs";
|
|
4
5
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
5
6
|
import { join, relative, sep } from "node:path";
|
|
6
7
|
import { randomBytes } from "node:crypto";
|
|
@@ -11,16 +12,20 @@ var manifest_exports = /* @__PURE__ */ __exportAll({
|
|
|
11
12
|
codeOnly: () => codeOnly,
|
|
12
13
|
contentScan: () => contentScan,
|
|
13
14
|
contentWidthOf: () => contentWidthOf,
|
|
15
|
+
docTags: () => docTags,
|
|
14
16
|
extractMeta: () => extractMeta,
|
|
15
17
|
frontMatter: () => frontMatter,
|
|
16
18
|
isNoteFile: () => isNoteFile,
|
|
19
|
+
layoutDocSource: () => layoutDocSource,
|
|
17
20
|
noteFileFor: () => noteFileFor,
|
|
18
21
|
readNote: () => readNote,
|
|
22
|
+
rendersDoc: () => rendersDoc,
|
|
19
23
|
scanFrames: () => scanFrames,
|
|
20
24
|
sceneBrief: () => sceneBrief,
|
|
21
25
|
sceneNote: () => sceneNote,
|
|
22
26
|
setSceneTitle: () => setSceneTitle,
|
|
23
27
|
statusBoards: () => statusBoards,
|
|
28
|
+
tagPattern: () => tagPattern,
|
|
24
29
|
toFrameId: () => toFrameId,
|
|
25
30
|
writeManifest: () => writeManifest
|
|
26
31
|
});
|
|
@@ -84,8 +89,46 @@ function extractMeta(src) {
|
|
|
84
89
|
* <Chart> is still a screen (device height, no document measuring), never a spec. Returns
|
|
85
90
|
* the inferred intent + natural width, or null for UI frames. */
|
|
86
91
|
const CONTENT_IMPORT = new RegExp(`from\\s+['"]${PKG}/content['"]`);
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
/** The JSX names a Doc renders under in this source: `Doc`, an alias (`import { Doc as Page }`),
|
|
93
|
+
* a namespace's member (`import * as C` -> `C.Doc`). Read from the code only (codeOnly). */
|
|
94
|
+
function docTags(code) {
|
|
95
|
+
const tags = ["Doc"];
|
|
96
|
+
for (const m of code.matchAll(/\bDoc\s+as\s+([A-Za-z_$][\w$]*)/g)) tags.push(m[1]);
|
|
97
|
+
for (const m of code.matchAll(/import\s+\*\s+as\s+([A-Za-z_$][\w$]*)\s+from/g)) tags.push(`${m[1]}.Doc`);
|
|
98
|
+
return tags;
|
|
99
|
+
}
|
|
100
|
+
const tagPattern = (tag) => tag.replace(/[.$]/g, "\\$&");
|
|
101
|
+
/** Does this source render a `<Doc>` - the one primitive that measures (content/index.tsx)? Lexical
|
|
102
|
+
* on the code (comments and strings blanked), through an aliased or namespace import too. */
|
|
103
|
+
function rendersDoc(src) {
|
|
104
|
+
const code = codeOnly(src);
|
|
105
|
+
return docTags(code).some((t) => new RegExp(`<${tagPattern(t)}[\\s>/]`).test(code));
|
|
106
|
+
}
|
|
107
|
+
/** The source of the nearest `_layout.tsx|jsx` around a frame that renders a Doc - the frame host
|
|
108
|
+
* wraps a frame in every `_layout` from its directory up to `scenes/` or `components/` - or null.
|
|
109
|
+
* `file` is the frame's path from the root; `memo` caches per directory across one scan. */
|
|
110
|
+
function layoutDocSource(root, file, memo) {
|
|
111
|
+
const parts = file.split("/").slice(0, -1);
|
|
112
|
+
if (parts.includes("..")) return null;
|
|
113
|
+
for (let i = parts.length; i >= 2; i--) {
|
|
114
|
+
const dir = parts.slice(0, i).join("/");
|
|
115
|
+
let found = memo.get(dir);
|
|
116
|
+
if (found === void 0) {
|
|
117
|
+
found = null;
|
|
118
|
+
for (const ext of ["tsx", "jsx"]) try {
|
|
119
|
+
const src = readFileSync(join(root, dir, `_layout.${ext}`), "utf8");
|
|
120
|
+
if (rendersDoc(src)) {
|
|
121
|
+
found = src;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
} catch {}
|
|
125
|
+
memo.set(dir, found);
|
|
126
|
+
}
|
|
127
|
+
if (found !== null) return found;
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const contentWidthOf = (src) => docTags(codeOnly(src)).some((t) => new RegExp(`<${tagPattern(t)}\\b[^>]*\\blayout\\s*=\\s*["']wide["']`).test(src)) ? CONTENT_WIDTH.wide : CONTENT_WIDTH.document;
|
|
89
132
|
/** The source with comments, template literals and CODE-shaped strings blanked (a JSX
|
|
90
133
|
* expression string `{'<Diagram>'}`, an attribute value), so a tag name quoted in an example
|
|
91
134
|
* or a comment never counts as a rendered element. Prose is left alone: JSX text has
|
|
@@ -322,6 +365,7 @@ const statusBoards = (root) => (scanBoards(root).boards ?? []).filter((b) => b.t
|
|
|
322
365
|
function scanFrames(root, project) {
|
|
323
366
|
const design = join(root, "design");
|
|
324
367
|
const frames = [];
|
|
368
|
+
const layoutDocs = /* @__PURE__ */ new Map();
|
|
325
369
|
for (const base of ["scenes", "components"]) for (const abs of walk(join(design, base))) {
|
|
326
370
|
const name = abs.split(sep).pop();
|
|
327
371
|
if (name.startsWith("_") || !FRAME_EXT.test(name)) continue;
|
|
@@ -354,7 +398,8 @@ function scanFrames(root, project) {
|
|
|
354
398
|
const content = contentScan(src);
|
|
355
399
|
if (content || meta.intent) {
|
|
356
400
|
entry.intent = meta.intent ?? content.intent;
|
|
357
|
-
|
|
401
|
+
const layout = rendersDoc(src) ? null : layoutDocSource(root, entry.file, layoutDocs);
|
|
402
|
+
entry.contentWidth = layout !== null ? contentWidthOf(layout) : content?.width ?? contentWidthOf(src);
|
|
358
403
|
}
|
|
359
404
|
}
|
|
360
405
|
frames.push(entry);
|
|
@@ -475,4 +520,4 @@ function writeManifest(root, manifest) {
|
|
|
475
520
|
return true;
|
|
476
521
|
}
|
|
477
522
|
//#endregion
|
|
478
|
-
export {
|
|
523
|
+
export { rendersDoc as a, toFrameId as c, manifest_exports as i, writeManifest as l, isNoteFile as n, scanFrames as o, layoutDocSource as r, setSceneTitle as s, affectedFrameIds as t };
|