@marver-design/marver 0.30.1 → 0.32.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +12 -8
  3. package/dist/{anchor-check-Bv4o-R2T.mjs → anchor-check-DZtX13ly.mjs} +1 -1
  4. package/dist/{board-tree-BXR8dw4b.mjs → board-tree-DGj0HhEE.mjs} +6 -2
  5. package/dist/{boards-EH2onUXM.mjs → boards-Cim1GTKc.mjs} +32 -2
  6. package/dist/{boards-BeWtjGUM.mjs → boards-jHmEPLV7.mjs} +7 -7
  7. package/dist/{build-zWGXSzly.mjs → build-D2dHEWX-.mjs} +14 -17
  8. package/dist/{capture-DEtM4qm5.mjs → capture-HaS-1or8.mjs} +1 -1
  9. package/dist/cli.mjs +38 -20
  10. package/dist/{collab-BEAcXrBb.mjs → collab-D2NcrOB8.mjs} +53 -14
  11. package/dist/comment-actions-Bxf9Ld4g.mjs +351 -0
  12. package/dist/{comments-XNhMmSSu.mjs → comments-ocvsnt2j.mjs} +85 -10
  13. package/dist/config-B0YcFtqS.mjs +510 -0
  14. package/dist/{context-BUnFiyA3.mjs → context-Cj2TcC0H.mjs} +3 -3
  15. package/dist/{daemon-CChgWJNq.mjs → daemon-D6TrdgMi.mjs} +268 -28
  16. package/dist/deep-link-DYtuT740.mjs +163 -0
  17. package/dist/{dev-DOgIITpT.mjs → dev-DMQYbw-2.mjs} +23 -16
  18. package/dist/devices-uJZ2inMq.mjs +155 -0
  19. package/dist/{events-CLH4ijKP.mjs → events-Dieo1482.mjs} +49 -4
  20. package/dist/{init-CYlFaRzG.mjs → init-BgusplYn.mjs} +40 -10
  21. package/dist/{jam-Cj5gBvwD.mjs → jam-CkuLL8A8.mjs} +1 -1
  22. package/dist/{link-BFFRgrMt.mjs → link-aZq5cExV.mjs} +54 -7
  23. package/dist/{logo-CXY-1yrn.mjs → logo-C9s7-Cy9.mjs} +89 -66
  24. package/dist/{ls-NqmePKOf.mjs → ls-DGVIW-Io.mjs} +1 -1
  25. package/dist/{manifest-DPZ3WNg_.mjs → manifest-CK8Qh4Nq.mjs} +255 -13
  26. package/dist/{marks-BnNANic9.mjs → marks-C8oX8kbE.mjs} +3 -3
  27. package/dist/{marks-DBp3h1Mc.mjs → marks-Dt-5JXCp.mjs} +18 -5
  28. package/dist/{marver-id-gate-vBLb_Icb.mjs → marver-id-gate-BAeuMeaU.mjs} +11 -7
  29. package/dist/md-B9_13Q0R.mjs +105 -0
  30. package/dist/notes-CRAX4wgk.mjs +148 -0
  31. package/dist/own-C8Mq0Hnf.mjs +128 -0
  32. package/dist/pdf-Cf9GIoIM.mjs +2299 -0
  33. package/dist/pdf-HB0prF75.mjs +117 -0
  34. package/dist/{perf-6MOTHxay.mjs → perf-9ZEF5KLO.mjs} +5 -5
  35. package/dist/{perf-BCxAo0IS.mjs → perf-BA_NDarr.mjs} +2 -1
  36. package/dist/{plugin-CFWBcAba.mjs → plugin-DesQP9L5.mjs} +565 -107
  37. package/dist/{poster-DPPpQiva.mjs → poster-Bb6WraCA.mjs} +1 -1
  38. package/dist/{profile-B1FKOM1e.mjs → profile-cdmSer1k.mjs} +1 -1
  39. package/dist/{publish-bakes-_Zx8crP3.mjs → publish-bakes-EjMmukJB.mjs} +3 -3
  40. package/dist/{queue-DeSQm24g.mjs → queue-BLLfdlDw.mjs} +156 -11
  41. package/dist/{recover-mDUVsnPd.mjs → recover-B3dmatx4.mjs} +2 -2
  42. package/dist/{serve-DQv3Ti6X.mjs → serve-kcF6-H8V.mjs} +4 -4
  43. package/dist/{session-VDJfXEEm.mjs → session-DBF-nQvq.mjs} +29 -3
  44. package/dist/{share-Bu_kuOKL.mjs → share-CS2mg27O.mjs} +1 -1
  45. package/dist/{shot-d4h_hJi9.mjs → shot-Bjt2MQe3.mjs} +4 -4
  46. package/dist/{shot-DBWN8hPP.mjs → shot-BuUCG46-.mjs} +1 -1
  47. package/dist/show-DhmiUu01.mjs +101 -0
  48. package/dist/{sizes-wjXDev3b.mjs → sizes-BckcL4Zz.mjs} +1 -1
  49. package/dist/{slots-Dn4Onb0V.mjs → slots-BOcfIqxy.mjs} +15 -3
  50. package/dist/{summary-Y8MY1Wuc.mjs → summary-cPmRDGpX.mjs} +1 -1
  51. package/dist/{sync-CMozOwZ0.mjs → sync-BNWwh8OF.mjs} +205 -7
  52. package/dist/{work-DJxH7cCX.mjs → work-B4tydWnf.mjs} +38 -2
  53. package/dist/{work-BYWD_1Zf.mjs → work-CzIXp7n1.mjs} +3 -3
  54. package/docs/app.md +143 -6
  55. package/docs/boards-and-folders.md +41 -7
  56. package/docs/jam-session.md +5 -0
  57. package/docs/live-jam.md +9 -0
  58. package/docs/pdf.md +108 -0
  59. package/docs/publish.md +9 -9
  60. package/docs/sharing.md +11 -0
  61. package/docs/slides.md +11 -1
  62. package/package.json +3 -1
  63. package/src/client/content/index.tsx +4 -2
  64. package/src/client/frame-host/main.tsx +3 -0
  65. package/src/client/shell/App.tsx +71 -24
  66. package/src/client/shell/BoardList.tsx +16 -7
  67. package/src/client/shell/Comments.tsx +77 -16
  68. package/src/client/shell/Play.tsx +104 -27
  69. package/src/client/shell/Toolbar.tsx +4 -3
  70. package/src/client/shell/app-bridge.ts +40 -5
  71. package/src/client/shell/canvas/Canvas.tsx +30 -8
  72. package/src/client/shell/canvas/FrameNode.tsx +3 -1
  73. package/src/client/shell/canvas/ctl.ts +16 -0
  74. package/src/client/shell/commands.ts +20 -0
  75. package/src/client/shell/comments-store.ts +81 -2
  76. package/src/client/shell/devices.tsx +42 -0
  77. package/src/client/shell/goto.ts +56 -9
  78. package/src/client/shell/icons.tsx +11 -4
  79. package/src/client/shell/immersive.ts +123 -0
  80. package/src/client/shell/inset.ts +29 -3
  81. package/src/client/shell/jam-lines.ts +5 -3
  82. package/src/client/shell/jam-panel.tsx +17 -5
  83. package/src/client/shell/marks-ui.tsx +54 -0
  84. package/src/client/shell/notes.ts +21 -0
  85. package/src/client/shell/pdf-export.tsx +154 -0
  86. package/src/client/shell/pdf-notes.ts +20 -0
  87. package/src/client/shell/recorder-signals.ts +5 -2
  88. package/src/client/shell/show.ts +250 -0
  89. package/src/client/shell/store.ts +23 -38
  90. package/src/client/shell/styles.css +68 -6
  91. package/src/shared/app-api.ts +90 -4
  92. package/src/shared/auto-place.ts +32 -0
  93. package/src/shared/board-tree.ts +3 -0
  94. package/src/shared/board-types.ts +6 -2
  95. package/src/shared/deep-link.ts +212 -0
  96. package/src/shared/devices.ts +89 -0
  97. package/src/shared/events.ts +48 -5
  98. package/src/shared/export-plan.ts +98 -0
  99. package/src/shared/immersive.ts +13 -0
  100. package/src/shared/perf-records.ts +1 -1
  101. package/templates/AGENTS-embedded.md +76 -12
  102. package/templates/AGENTS-studio.md +76 -12
  103. package/templates/instructions/boards.md +6 -5
  104. package/templates/instructions/configure.md +32 -2
  105. package/templates/instructions/iterate.md +8 -0
  106. package/templates/instructions/jam.md +9 -0
  107. package/templates/instructions/publish.md +14 -4
  108. package/templates/instructions/review.md +4 -0
  109. package/templates/instructions/slides.md +67 -1
  110. package/templates/instructions/welcome.md +9 -5
  111. package/templates/playbooks/publish-canvas/PLAYBOOK.md +1 -1
  112. package/dist/config-BezZTiov.mjs +0 -182
@@ -1,19 +1,20 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
2
  import { a as ROUTE, i as PKG, r as NAME } from "./cli.mjs";
3
- import { a as checkBoardsDir, c as listBoardFiles, d as pinFrames, g as tryFileLock, h as takeFileLock, i as boardLock, l as nodeExists, m as readRegistry, p as readMembership, r as boardFields, s as isRegularFile, t as AUTHOR_FIELDS, u as parseBoard, v as withRegistryLock, y as hash } from "./boards-EH2onUXM.mjs";
4
- import { A as resolveType, D as readReason, E as readCapability, O as readStatusWord, S as HAS_STATUS, _ as validateWire, a as buildTree, c as folderMap, g as readTitle, h as readDescription, j as settableStatuses, k as readType, n as BOARD_NAME, r as FOLDERS_FILE, t as ALL_SCENES, v as wireKids } from "./board-tree-BXR8dw4b.mjs";
5
- import { c as setSceneTitle, d as annotateBoards, f as planNames, m as readContextFacts, n as isNoteFile, p as planWithStage, s as scanFrames, t as affectedFrameIds, u as writeManifest } from "./manifest-DPZ3WNg_.mjs";
6
- import { a as workActivity, r as boardsChanged } from "./work-DJxH7cCX.mjs";
7
- import { r as replay, t as asks } from "./events-CLH4ijKP.mjs";
3
+ import { _ as tryFileLock, c as isRegularFile, d as parseBoard, f as pinFrames, g as takeFileLock, h as readRegistry, i as boardLock, l as listBoardFiles, m as readMembership, o as checkBoardsDir, r as boardFields, s as checkRealDirs, t as AUTHOR_FIELDS, u as nodeExists, x as hash, y as withRegistryLock } from "./boards-Cim1GTKc.mjs";
4
+ import { A as resolveType, D as readReason, E as readCapability, O as readStatusWord, S as HAS_STATUS, _ as validateWire, a as buildTree, c as folderMap, g as readTitle, h as readDescription, j as settableStatuses, k as readType, n as BOARD_NAME, r as FOLDERS_FILE, t as ALL_SCENES, v as wireKids } from "./board-tree-DGj0HhEE.mjs";
5
+ import { c as setSceneTitle, d as annotateBoards, f as planNames, m as readContextFacts, n as isNoteFile, p as planWithStage, s as scanFrames, t as affectedFrameIds, u as writeManifest } from "./manifest-CK8Qh4Nq.mjs";
6
+ import { c as newerVersion, o as checkShowTarget } from "./deep-link-DYtuT740.mjs";
7
+ import { g as LIVE_WIRE, h as LIVE_BOUNDS, i as marverHome, o as originOf, v as workspaceId } from "./slots-BOcfIqxy.mjs";
8
+ import { i as pinningBoards, o as workActivity, r as boardsChanged, s as workClock } from "./work-B4tydWnf.mjs";
9
+ import { a as replay, t as asks } from "./events-Dieo1482.mjs";
8
10
  import { a as readLog, i as listBoards } from "./comments-0BSbb04K.mjs";
9
- import { g as LIVE_WIRE, h as LIVE_BOUNDS, i as marverHome, o as originOf, v as workspaceId } from "./slots-Dn4Onb0V.mjs";
10
- import { n as localProfile, t as isConnected } from "./profile-B1FKOM1e.mjs";
11
- import { c as recordChanged, i as initMarks, n as docRevs, o as observe, r as freshFrames, t as docRev } from "./marks-BnNANic9.mjs";
12
- import { C as WRITE_MATCH_MS, S as WRITER_HEADERS, _ as ID12, b as RELOAD_BOUNDS, c as takePageBatch, l as takeReloadBatch, n as appendRun, r as logReloadLines, t as PAGE_BODY_MAX, u as tidyPerfDir, v as RECORDER_LEVELS, w as decodeCmds, y as RECORDER_PARAM } from "./perf-BCxAo0IS.mjs";
13
- import { n as loadConfig } from "./config-BezZTiov.mjs";
14
- import { a as mergeSizes, c as serializeSizes, i as measuringFrames, l as sizesPath, n as autoWidthOf, o as readSizes, r as keptSizes, s as readSizesFile } from "./sizes-wjXDev3b.mjs";
15
- import { c as pool, d as withBrowser, f as Browser, l as shotConcurrency, m as launchFlags, r as SURFACE, t as AREA } from "./shot-d4h_hJi9.mjs";
16
- import { a as appProofOk, o as proofHeaders, r as logoRoute } from "./logo-CXY-1yrn.mjs";
11
+ import { n as localProfile, t as isConnected } from "./profile-cdmSer1k.mjs";
12
+ import { c as recordChanged, i as initMarks, n as docRevs, o as observe, r as freshFrames, t as docRev } from "./marks-C8oX8kbE.mjs";
13
+ import { C as WRITE_MATCH_MS, S as WRITER_HEADERS, _ as ID12, b as RELOAD_BOUNDS, c as takePageBatch, l as takeReloadBatch, n as appendRun, r as logReloadLines, t as PAGE_BODY_MAX, u as tidyPerfDir, v as RECORDER_LEVELS, w as decodeCmds, y as RECORDER_PARAM } from "./perf-BA_NDarr.mjs";
14
+ import { c as proofHeaders, i as logoRoute, s as appProofOk, t as findLogo } from "./logo-C9s7-Cy9.mjs";
15
+ import { n as loadConfig } from "./config-B0YcFtqS.mjs";
16
+ import { a as mergeSizes, c as serializeSizes, i as measuringFrames, l as sizesPath, n as autoWidthOf, o as readSizes, r as keptSizes, s as readSizesFile } from "./sizes-BckcL4Zz.mjs";
17
+ import { c as pool, d as withBrowser, h as launchFlags, l as shotConcurrency, p as Browser, r as SURFACE, t as AREA } from "./shot-Bjt2MQe3.mjs";
17
18
  import { closeSync, copyFileSync, existsSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, watch, writeFileSync } from "node:fs";
18
19
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
19
20
  import { fileURLToPath } from "node:url";
@@ -22,6 +23,55 @@ import { arch, cpus, totalmem } from "node:os";
22
23
  import { execFile } from "node:child_process";
23
24
  import { stat } from "node:fs/promises";
24
25
  import { isCSSRequest } from "vite";
26
+ //#region src/server/identity.ts
27
+ /**
28
+ * One identity resolver (spec 31 G.1): what a canvas is called, and which logo it wears - here, and nowhere else.
29
+ *
30
+ * - local name (`marver dev`: the app's tab and Home card through the slot file, the sidebar, the manifest's project):
31
+ * config `name` > `share.name` > the folder's name - today's runtime rule, with `name` on top.
32
+ * - published name (`marver build`'s meta.json: the gate's title, the sign-in screens): config `name` > `share.name` >
33
+ * package.json `name` > the folder's - today's build rule, with `name` on top.
34
+ * - logo: config `logo` > `share.logo` > logo.ts's ladder (`findLogo`).
35
+ *
36
+ * `share.*` keeps working and nothing is rewritten: a canvas that sets neither `name` nor `logo` resolves exactly as it
37
+ * did before.
38
+ */
39
+ /** The host package.json's `name`, when it has one. */
40
+ function packageName(root) {
41
+ try {
42
+ const n = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).name;
43
+ return typeof n === "string" && n ? n : void 0;
44
+ } catch {
45
+ return;
46
+ }
47
+ }
48
+ function canvasIdentity(root, config) {
49
+ const own = config.name || config.share.name;
50
+ const folder = basename(root);
51
+ const pkg = own ? void 0 : packageName(root);
52
+ return {
53
+ local: own || folder,
54
+ published: own || pkg || folder,
55
+ nameFrom: config.name ? "name" : config.share.name ? "share.name" : "folder",
56
+ logos: [{
57
+ key: "logo",
58
+ path: config.logo
59
+ }, {
60
+ key: "share.logo",
61
+ path: config.share.logo
62
+ }]
63
+ };
64
+ }
65
+ /** `marver dev`'s boot-line note (spec 31 G.2): what still makes this canvas look like any other in the app - its
66
+ * folder's name, the Marver mark - and the one place each is set. Null when it has both a name and a logo. */
67
+ function identityNudge(root, config) {
68
+ const id = canvasIdentity(root, config);
69
+ const folder = id.nameFrom === "folder";
70
+ const mark = !findLogo(root, id.logos);
71
+ if (!folder && !mark) return null;
72
+ return `this canvas still shows ${folder && mark ? `its folder's name ("${id.local}") and the Marver mark` : folder ? `its folder's name ("${id.local}")` : "the Marver mark"} - give it ${[folder ? "name: \"Your Product\" in design/config.ts" : "", mark ? "your product's logo at design/logo.svg" : ""].filter(Boolean).join(" and ")}`;
73
+ }
74
+ //#endregion
25
75
  //#region src/shared/frames.ts
26
76
  /** A canvas made of content frames alone (Doc, Md, Diagram ship their own styling) needs no theme -
27
77
  * only an app frame does (#4). Empty counts as not content-only: the warning still helps there. */
@@ -806,7 +856,7 @@ async function bakeIn(b, opts) {
806
856
  const deadline = setTimeout(() => {
807
857
  timedOut = true;
808
858
  b.abort(me, TIMED_OUT);
809
- }, DEADLINE_MS);
859
+ }, bakeSeams.deadlineMs ?? DEADLINE_MS);
810
860
  const closeTarget = async (id) => {
811
861
  let t;
812
862
  await Promise.race([b.send("Target.closeTarget", { targetId: id }).catch(() => {}), new Promise((r) => {
@@ -1291,11 +1341,13 @@ function endRunBakes(owner) {
1291
1341
  * looks at a COMPILING outlast any held compile (A3.8 r1 #4's case, added by the review of a3-runs). */
1292
1342
  const bakeSeams = {};
1293
1343
  const holdMs = () => {
1294
- return 0;
1344
+ if (bakeSeams.holdMs !== void 0) return bakeSeams.holdMs;
1345
+ const v = process.env.MARVER_SLOT_BASE ? Number(process.env.MV_BAKE_HOLD_MS) : NaN;
1346
+ return Number.isFinite(v) && v > 0 ? Math.min(v, 6e4) : 0;
1295
1347
  };
1296
1348
  /** The suite's answer for a compile still running, under MV_BAKE_STOP_ASKING (above). */
1297
1349
  const STOP_ASKING = "still compiling - the suite asks the page to stop asking";
1298
- const stillCompiling = () => COMPILING;
1350
+ const stillCompiling = () => bakeSeams.stopAsking ?? (!!process.env.MARVER_SLOT_BASE && process.env.MV_BAKE_STOP_ASKING === "1") ? STOP_ASKING : COMPILING;
1299
1351
  /** Compiles in flight, by generation and key: identical asks - inside one request or across
1300
1352
  * concurrent ones - share one compile. */
1301
1353
  const inflight = /* @__PURE__ */ new Map();
@@ -1812,6 +1864,11 @@ async function writeHeadlessProfile(home) {
1812
1864
  * firewalled registries degrade to silence. MARVER_NO_UPDATE_CHECK=1 disables it.
1813
1865
  * Published bundles never check anything - viewers are not the owner.
1814
1866
  */
1867
+ var update_exports = /* @__PURE__ */ __exportAll({
1868
+ checkUpdate: () => checkUpdate,
1869
+ installedVersion: () => installedVersion,
1870
+ updateStatus: () => updateStatus
1871
+ });
1815
1872
  const TTL = 864e5;
1816
1873
  /** Installed version: walk up from this module to the package's own package.json
1817
1874
  * (one level from dist/, two from src/server/ - the walk covers both). */
@@ -1827,48 +1884,77 @@ function installedVersion() {
1827
1884
  return null;
1828
1885
  }
1829
1886
  /** Strictly-newer numeric compare; anything non-numeric (prerelease tags) compares false. */
1830
- const newer = (a, b) => {
1831
- const pa = a.split(".").map((n) => parseInt(n, 10));
1832
- const pb = b.split(".").map((n) => parseInt(n, 10));
1833
- for (let i = 0; i < 3; i++) {
1834
- const x = pa[i] ?? 0, y = pb[i] ?? 0;
1835
- if (!Number.isFinite(x) || !Number.isFinite(y)) return false;
1836
- if (x !== y) return x > y;
1837
- }
1838
- return false;
1839
- };
1887
+ const newer = (a, b) => newerVersion(a, b);
1840
1888
  /** The latest published version when strictly newer than installed, else null. Never throws. */
1841
1889
  async function checkUpdate(root) {
1842
1890
  if (process.env.MARVER_NO_UPDATE_CHECK) return null;
1843
1891
  const current = installedVersion();
1844
1892
  if (!current) return null;
1845
- const latest = await latestVersion(root);
1893
+ const { latest } = await latestVersion(root);
1846
1894
  return latest && newer(latest, current) ? latest : null;
1847
1895
  }
1848
- async function latestVersion(root) {
1896
+ async function updateStatus(root) {
1897
+ const current = installedVersion();
1898
+ if (process.env.MARVER_NO_UPDATE_CHECK) return {
1899
+ current,
1900
+ latest: null,
1901
+ checkedAt: null,
1902
+ state: "disabled"
1903
+ };
1904
+ const r = await latestVersion(root);
1905
+ return {
1906
+ current,
1907
+ latest: r.latest,
1908
+ checkedAt: r.checkedAt,
1909
+ state: r.ok ? "ok" : "offline"
1910
+ };
1911
+ }
1912
+ /** One registry read at a time per root: requests that come together share it. */
1913
+ const asking = /* @__PURE__ */ new Map();
1914
+ function latestVersion(root) {
1849
1915
  const cacheFile = join(root, "design", ".local", "update-check.json");
1850
1916
  const wellFormed = (v) => typeof v === "string" && /^\d+\.\d+\.\d+$/.test(v);
1851
1917
  try {
1852
1918
  const c = JSON.parse(readFileSync(cacheFile, "utf8"));
1853
1919
  const age = Date.now() - c.checkedAt;
1854
- if (typeof c.checkedAt === "number" && age >= 0 && age < TTL) return wellFormed(c.latest) ? c.latest : null;
1855
- } catch {}
1856
- let latest = null;
1857
- try {
1858
- const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(PKG)}/latest`, { signal: AbortSignal.timeout(3e3) });
1859
- if (res.ok) {
1860
- const v = (await res.json())?.version;
1861
- if (wellFormed(v)) latest = v;
1862
- }
1863
- } catch {}
1864
- try {
1865
- mkdirSync(join(root, "design", ".local"), { recursive: true });
1866
- writeFileSync(cacheFile, JSON.stringify({
1867
- checkedAt: Date.now(),
1868
- latest
1869
- }) + "\n");
1920
+ if (typeof c.checkedAt === "number" && age >= 0 && age < TTL) return Promise.resolve({
1921
+ latest: wellFormed(c.latest) ? c.latest : null,
1922
+ checkedAt: c.checkedAt,
1923
+ ok: typeof c.ok === "boolean" ? c.ok : wellFormed(c.latest)
1924
+ });
1870
1925
  } catch {}
1871
- return latest;
1926
+ const had = asking.get(root);
1927
+ if (had) return had;
1928
+ const p = (async () => {
1929
+ let latest = null;
1930
+ let ok = false;
1931
+ try {
1932
+ const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(PKG)}/latest`, { signal: AbortSignal.timeout(3e3) });
1933
+ if (res.ok) {
1934
+ const v = (await res.json())?.version;
1935
+ if (wellFormed(v)) {
1936
+ latest = v;
1937
+ ok = true;
1938
+ }
1939
+ }
1940
+ } catch {}
1941
+ const checkedAt = Date.now();
1942
+ try {
1943
+ mkdirSync(join(root, "design", ".local"), { recursive: true });
1944
+ writeFileSync(cacheFile, JSON.stringify({
1945
+ checkedAt,
1946
+ latest,
1947
+ ok
1948
+ }) + "\n");
1949
+ } catch {}
1950
+ return {
1951
+ latest,
1952
+ checkedAt,
1953
+ ok
1954
+ };
1955
+ })().finally(() => asking.delete(root));
1956
+ asking.set(root, p);
1957
+ return p;
1872
1958
  }
1873
1959
  //#endregion
1874
1960
  //#region src/server/perf-run.ts
@@ -2071,7 +2157,17 @@ const runSeams = {};
2071
2157
  /** RUN_T, with the suite's overrides: `runSeams.t` in-process, `MV_PERF_RUN_T` (JSON) for a dev server a test starts -
2072
2158
  * both read only with MARVER_SLOT_BASE set (the suite's marker). */
2073
2159
  function runT() {
2074
- return { ...RUN_T };
2160
+ const t = { ...RUN_T };
2161
+ if (!process.env.MARVER_SLOT_BASE) return t;
2162
+ let env = {};
2163
+ try {
2164
+ env = JSON.parse(process.env.MV_PERF_RUN_T ?? "{}");
2165
+ } catch {}
2166
+ for (const src of [env, runSeams.t ?? {}]) for (const k of Object.keys(t)) {
2167
+ const v = src[k];
2168
+ if (typeof v === "number" && v >= 0) t[k] = v;
2169
+ }
2170
+ return t;
2075
2171
  }
2076
2172
  /** The shell's address for a run's load: its run id, the warm-up's mark, the recorder's level when not `full` (spec 30
2077
2173
  * #58: the shell reads it, `withWs()` carries it to the frames), the board. */
@@ -2139,6 +2235,7 @@ async function openPage(b, o) {
2139
2235
  }
2140
2236
  };
2141
2237
  function call(m, p = {}, sid, ms = T.callMs) {
2238
+ runSeams.cdp?.(m, p);
2142
2239
  const sent = b.send(m, p, sid, own);
2143
2240
  let t;
2144
2241
  const late = new Promise((_, reject) => {
@@ -2202,6 +2299,7 @@ async function openPage(b, o) {
2202
2299
  async function closePage(b, page) {
2203
2300
  page.stop();
2204
2301
  const bounded = async (m, p, sid) => {
2302
+ runSeams.cdp?.(m, p);
2205
2303
  let t;
2206
2304
  await Promise.race([b.send(m, p, sid).catch(() => {}), new Promise((r) => {
2207
2305
  t = setTimeout(r, 2e3);
@@ -2726,7 +2824,7 @@ async function serveRun(req, res, o) {
2726
2824
  };
2727
2825
  const beat = setInterval(() => write({ heartbeat: Date.now() }), T.heartbeatMs);
2728
2826
  try {
2729
- const drive = runOnce;
2827
+ const drive = runSeams.driver ?? runOnce;
2730
2828
  for (let i = 0; i < asked.req.repeat && !ac.signal.aborted; i++) write({ line: await drive({
2731
2829
  root: o.root,
2732
2830
  origin: o.origin,
@@ -2746,6 +2844,46 @@ async function serveRun(req, res, o) {
2746
2844
  }
2747
2845
  }
2748
2846
  //#endregion
2847
+ //#region src/server/show.ts
2848
+ const SHOW_OUTCOMES = ["shown", "notice"];
2849
+ const KEEP = 32;
2850
+ const PAGE = /^[A-Za-z0-9_-]{8,64}$/;
2851
+ function createShows() {
2852
+ let seq = 0;
2853
+ const kept = /* @__PURE__ */ new Map();
2854
+ return {
2855
+ start(t) {
2856
+ seq += 1;
2857
+ kept.set(seq, /* @__PURE__ */ new Map());
2858
+ for (const k of kept.keys()) if (k <= seq - KEEP) kept.delete(k);
2859
+ return {
2860
+ seq,
2861
+ cmd: {
2862
+ ...t,
2863
+ seq
2864
+ }
2865
+ };
2866
+ },
2867
+ ack(s, page, outcome) {
2868
+ if (typeof s !== "number" || !kept.has(s) || typeof page !== "string" || !PAGE.test(page)) return false;
2869
+ if (!SHOW_OUTCOMES.includes(outcome)) return false;
2870
+ kept.get(s).set(page, outcome);
2871
+ return true;
2872
+ },
2873
+ acks(s) {
2874
+ const m = kept.get(s);
2875
+ if (!m) return null;
2876
+ let shown = 0, notice = 0;
2877
+ for (const o of m.values()) if (o === "shown") shown++;
2878
+ else notice++;
2879
+ return {
2880
+ shown,
2881
+ notice
2882
+ };
2883
+ }
2884
+ };
2885
+ }
2886
+ //#endregion
2749
2887
  //#region src/server/api.ts
2750
2888
  const BODY_LIMIT = 1e6;
2751
2889
  const CSRF_MAX_AGE = 2592e3;
@@ -2902,6 +3040,7 @@ function apiMiddleware(root, opts = {}) {
2902
3040
  const notSymlink = (p) => !nodeExists(p) || isRegularFile(p);
2903
3041
  const nodeExists$1 = nodeExists;
2904
3042
  let sizesWarned = false;
3043
+ const shows = createShows();
2905
3044
  /** A board file this request wrote (spec 30 #18), with the page and commands it names - the watcher's `sh:board`
2906
3045
  * matches these bytes against it, as a candidate, never as proof. */
2907
3046
  const wroteBoard = (req, board, content) => {
@@ -2915,7 +3054,7 @@ function apiMiddleware(root, opts = {}) {
2915
3054
  * capture not sealed; then the bytes, 8 MB at most as they arrive, their signature and the whole PNG; and the capture
2916
3055
  * still not sealed, just before it is stored. Nothing is stored once `stop` (the deadline) has fired. */
2917
3056
  const livePicture = async (req, url, stop) => {
2918
- const { CAPTURE_ID, addPictureBytes, checkPng, isPng, readCapture, sweepPictures } = await import("./capture-DEtM4qm5.mjs").then((n) => n.i);
3057
+ const { CAPTURE_ID, addPictureBytes, checkPng, isPng, readCapture, sweepPictures } = await import("./capture-HaS-1or8.mjs").then((n) => n.i);
2919
3058
  if (String(req.headers["content-type"] ?? "").split(";")[0].trim().toLowerCase() !== "image/png") return [415, { error: "expected image/png" }];
2920
3059
  const capture = url.searchParams.get("capture") ?? "", frame = url.searchParams.get("frame") ?? "";
2921
3060
  if (!CAPTURE_ID.test(capture)) return [400, { error: "bad capture id" }];
@@ -3177,7 +3316,7 @@ function apiMiddleware(root, opts = {}) {
3177
3316
  return json(res, 400, { error: "malformed JSON" });
3178
3317
  }
3179
3318
  if (!b || b.kind !== "capture" && b.kind !== "upload") return json(res, 400, { error: "kind must be capture or upload" });
3180
- (await import("./perf-BCxAo0IS.mjs").then((n) => n.f)).logJam(root, b);
3319
+ (await import("./perf-BA_NDarr.mjs").then((n) => n.f)).logJam(root, b);
3181
3320
  return json(res, 200, { ok: true });
3182
3321
  }
3183
3322
  if (path === "perf/page" && req.method === "POST") {
@@ -3200,7 +3339,7 @@ function apiMiddleware(root, opts = {}) {
3200
3339
  return json(res, "error" in answer ? 503 : 200, answer);
3201
3340
  }
3202
3341
  if (path === "perf/run" && req.method === "POST" || path === "perf/inputs" && req.method === "GET") {
3203
- const { readDevInfo } = await import("./work-DJxH7cCX.mjs").then((n) => n.o);
3342
+ const { readDevInfo } = await import("./work-B4tydWnf.mjs").then((n) => n.c);
3204
3343
  const token = readDevInfo(root)?.token;
3205
3344
  if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
3206
3345
  if (path === "perf/inputs") {
@@ -3655,7 +3794,7 @@ function apiMiddleware(root, opts = {}) {
3655
3794
  }
3656
3795
  }
3657
3796
  if (path === "shot" && req.method === "GET") {
3658
- const { readDevInfo } = await import("./work-DJxH7cCX.mjs").then((n) => n.o);
3797
+ const { readDevInfo } = await import("./work-B4tydWnf.mjs").then((n) => n.c);
3659
3798
  const token = readDevInfo(root)?.token;
3660
3799
  if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
3661
3800
  const frameId = url.searchParams.get("frame") ?? "";
@@ -3671,7 +3810,7 @@ function apiMiddleware(root, opts = {}) {
3671
3810
  };
3672
3811
  const asPng = url.searchParams.get("format") === "png";
3673
3812
  const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
3674
- const { shootFrame } = await import("./shot-d4h_hJi9.mjs").then((n) => n.u);
3813
+ const { shootFrame } = await import("./shot-Bjt2MQe3.mjs").then((n) => n.u);
3675
3814
  const r = await shootFrame({
3676
3815
  root,
3677
3816
  viewports: opts.viewports ?? {},
@@ -3704,8 +3843,101 @@ function apiMiddleware(root, opts = {}) {
3704
3843
  });
3705
3844
  return res.end(png);
3706
3845
  }
3846
+ const pdfRoute = /^pdf(?:\/([^/]*)(\/file)?)?$/.exec(path);
3847
+ if (pdfRoute) {
3848
+ const { readDevInfo } = await import("./work-B4tydWnf.mjs").then((n) => n.c);
3849
+ const token = readDevInfo(root)?.token;
3850
+ if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
3851
+ const pdf = await import("./pdf-Cf9GIoIM.mjs");
3852
+ if (pdfRoute[1] === void 0) {
3853
+ if (req.method !== "POST") return json(res, 405, { error: "POST to start a PDF" });
3854
+ const raw = await readBody(req);
3855
+ if (raw == null) return json(res, 400, { error: "body too large or unreadable" });
3856
+ let b;
3857
+ try {
3858
+ b = JSON.parse(raw);
3859
+ } catch {
3860
+ return json(res, 400, { error: "malformed JSON" });
3861
+ }
3862
+ if (!b || typeof b !== "object" || Array.isArray(b)) return json(res, 400, { error: "expected an object" });
3863
+ if (!validName(b.board)) return json(res, 400, { error: "board must be a board name" });
3864
+ const opt = (k, ok) => b[k] === void 0 ? void 0 : ok(b[k]) ? b[k] : null;
3865
+ const theme = opt("theme", (v) => typeof v === "string" && /^[a-z0-9-]{1,32}$/i.test(v));
3866
+ const notes = opt("notes", (v) => typeof v === "boolean");
3867
+ const paper = opt("paper", (v) => v === "letter" || v === "a4");
3868
+ const mode = opt("mode", (v) => v === "auto" || v === "raster" || v === "vector");
3869
+ const keepGoing = opt("keepGoing", (v) => typeof v === "boolean");
3870
+ for (const [k, v] of Object.entries({
3871
+ theme,
3872
+ notes,
3873
+ paper,
3874
+ mode,
3875
+ keepGoing
3876
+ })) if (v === null) return json(res, 400, { error: `invalid ${k}` });
3877
+ const { docRev } = await import("./marks-C8oX8kbE.mjs").then((n) => n.a);
3878
+ const { installedVersion } = await Promise.resolve().then(() => update_exports);
3879
+ const ctx = {
3880
+ root,
3881
+ origin: opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`,
3882
+ viewports: opts.viewports ?? {},
3883
+ themes: opts.themes ?? ["light", "dark"],
3884
+ canvasName: opts.canvasName?.() ?? root.split(sep).pop() ?? "canvas",
3885
+ version: installedVersion() ?? "0.0.0",
3886
+ frames: () => devManifest().frames,
3887
+ scenes: () => devManifest().scenes,
3888
+ settled: opts.settled ?? (() => true),
3889
+ docRev: (id) => docRev(root, devManifest().frames, id)
3890
+ };
3891
+ const r = await pdf.startPdfJob(ctx, {
3892
+ board: b.board,
3893
+ ...theme ? { theme } : {},
3894
+ ...notes ? { notes } : {},
3895
+ ...paper ? { paper } : {},
3896
+ ...mode ? { mode } : {},
3897
+ ...keepGoing ? { keepGoing } : {}
3898
+ });
3899
+ if (!r.ok) return json(res, r.status, {
3900
+ error: r.error,
3901
+ ...r.job ? { job: r.job } : {}
3902
+ });
3903
+ return json(res, 202, pdf.jobStatus(r.job));
3904
+ }
3905
+ const j = pdf.getJob(pdfRoute[1]);
3906
+ if (!j || j.root !== root) return json(res, 404, { error: "no such PDF job - a finished one is kept for an hour" });
3907
+ if (pdfRoute[2]) {
3908
+ if (req.method !== "GET") return json(res, 405, { error: "GET the file" });
3909
+ if (j.state !== "done" || !j.file) return json(res, 409, { error: j.state === "running" ? "the PDF is not finished yet" : `the export ${j.state}${j.error ? ` - ${j.error}` : ""}` });
3910
+ const { createReadStream, statSync } = await import("node:fs");
3911
+ let size;
3912
+ try {
3913
+ size = statSync(j.file).size;
3914
+ } catch {
3915
+ return json(res, 410, { error: "the PDF is gone - export it again" });
3916
+ }
3917
+ res.writeHead(200, {
3918
+ "content-type": "application/pdf",
3919
+ "content-length": size,
3920
+ "cache-control": "no-store",
3921
+ "x-content-type-options": "nosniff",
3922
+ "content-disposition": `attachment; filename="${j.filename.replace(/[^A-Za-z0-9._-]/g, "_")}"`
3923
+ });
3924
+ const st = createReadStream(j.file);
3925
+ st.on("error", () => res.destroy());
3926
+ res.on("close", () => st.destroy());
3927
+ return st.pipe(res);
3928
+ }
3929
+ if (req.method === "GET") return json(res, 200, pdf.jobStatus(j));
3930
+ if (req.method === "DELETE") {
3931
+ pdf.cancelPdfJob(j.id);
3932
+ return json(res, 200, {
3933
+ job: j.id,
3934
+ cancelled: j.state === "running" || j.state === "cancelled"
3935
+ });
3936
+ }
3937
+ return json(res, 405, { error: "GET or DELETE a job" });
3938
+ }
3707
3939
  if (path === "shots" && req.method === "POST") {
3708
- const { readDevInfo } = await import("./work-DJxH7cCX.mjs").then((n) => n.o);
3940
+ const { readDevInfo } = await import("./work-B4tydWnf.mjs").then((n) => n.c);
3709
3941
  const token = readDevInfo(root)?.token;
3710
3942
  if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
3711
3943
  const raw = await readBody(req);
@@ -3722,7 +3954,7 @@ function apiMiddleware(root, opts = {}) {
3722
3954
  if (typeof theme !== "string" || !/^[a-z0-9-]+$/i.test(theme)) return json(res, 400, { error: "invalid theme" });
3723
3955
  const scale = body.scale === void 0 ? void 0 : body.scale;
3724
3956
  if (scale !== void 0 && !(Number.isInteger(scale) && scale >= 1 && scale <= 4)) return json(res, 400, { error: "invalid scale" });
3725
- const { resolveFrames, shootBatch } = await import("./shot-d4h_hJi9.mjs").then((n) => n.u);
3957
+ const { resolveFrames, shootBatch } = await import("./shot-Bjt2MQe3.mjs").then((n) => n.u);
3726
3958
  const sel = resolveFrames(root, body);
3727
3959
  if (!sel.ok) return json(res, sel.status, { error: sel.error });
3728
3960
  const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
@@ -3740,7 +3972,7 @@ function apiMiddleware(root, opts = {}) {
3740
3972
  }
3741
3973
  }
3742
3974
  if (path === "anchor" && req.method === "POST") {
3743
- const { readDevInfo } = await import("./work-DJxH7cCX.mjs").then((n) => n.o);
3975
+ const { readDevInfo } = await import("./work-B4tydWnf.mjs").then((n) => n.c);
3744
3976
  const token = readDevInfo(root)?.token;
3745
3977
  if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
3746
3978
  const raw = await readBody(req);
@@ -3756,7 +3988,7 @@ function apiMiddleware(root, opts = {}) {
3756
3988
  if (typeof target === "string") return json(res, 400, { error: target });
3757
3989
  const others = Array.isArray(b.others) ? b.others.filter((o) => typeof o?.key === "string").slice(0, 200) : [];
3758
3990
  const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
3759
- const { checkAnchor, CheckInputError } = await import("./anchor-check-Bv4o-R2T.mjs");
3991
+ const { checkAnchor, CheckInputError } = await import("./anchor-check-DZtX13ly.mjs");
3760
3992
  try {
3761
3993
  return json(res, 200, await checkAnchor({
3762
3994
  root,
@@ -3806,7 +4038,7 @@ function apiMiddleware(root, opts = {}) {
3806
4038
  });
3807
4039
  docs.push(typeof a?.doc === "string" ? a.doc : void 0);
3808
4040
  }
3809
- const { docRev } = await import("./marks-BnNANic9.mjs").then((n) => n.a);
4041
+ const { docRev } = await import("./marks-C8oX8kbE.mjs").then((n) => n.a);
3810
4042
  const all = devManifest().frames;
3811
4043
  const pending = opts.settled ? !opts.settled() : false;
3812
4044
  const behind = docs.map((d, i) => d !== void 0 && (pending || d !== docRev(root, all, asks[i].frame)));
@@ -3864,8 +4096,8 @@ function apiMiddleware(root, opts = {}) {
3864
4096
  return json(res, 400, { error: "malformed JSON" });
3865
4097
  }
3866
4098
  const src = typeof b?.src === "string" ? b.src : "";
3867
- const { ensurePoster, isLocalClip } = await import("./poster-DPPpQiva.mjs");
3868
- const { isLocalAssetRef } = await import("./build-zWGXSzly.mjs");
4099
+ const { ensurePoster, isLocalClip } = await import("./poster-Bb6WraCA.mjs");
4100
+ const { isLocalAssetRef } = await import("./build-D2dHEWX-.mjs");
3869
4101
  if (!isLocalAssetRef(src) || !isLocalClip(src)) return json(res, 400, { error: "src must be a clip under design/assets/" });
3870
4102
  const r = await ensurePoster(join(root, "design", "assets"), src);
3871
4103
  if (!r.ok) return json(res, r.error.includes("does not exist") ? 404 : 503, { error: r.error });
@@ -3892,7 +4124,7 @@ function apiMiddleware(root, opts = {}) {
3892
4124
  }
3893
4125
  const dir = join(root, "design", ".local");
3894
4126
  mkdirSync(dir, { recursive: true });
3895
- const { validAvatar } = await import("./collab-BEAcXrBb.mjs");
4127
+ const { validAvatar } = await import("./collab-D2NcrOB8.mjs");
3896
4128
  let cur = {};
3897
4129
  try {
3898
4130
  cur = JSON.parse(readFileSync(join(dir, "profile.json"), "utf8"));
@@ -3908,7 +4140,7 @@ function apiMiddleware(root, opts = {}) {
3908
4140
  }
3909
4141
  if (path === "marks" || path === "marks/seen") {
3910
4142
  if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
3911
- const { readMarks, markSeen } = await import("./marks-BnNANic9.mjs").then((n) => n.a);
4143
+ const { readMarks, markSeen } = await import("./marks-C8oX8kbE.mjs").then((n) => n.a);
3912
4144
  const manifest = devManifest();
3913
4145
  if (path === "marks" && req.method === "GET") return json(res, 200, readMarks(root, manifest));
3914
4146
  if (path === "marks/seen" && req.method === "POST") {
@@ -3927,15 +4159,52 @@ function apiMiddleware(root, opts = {}) {
3927
4159
  }
3928
4160
  return json(res, 405, { error: "method not allowed" });
3929
4161
  }
4162
+ if (path === "show" || path === "show/ack" || path === "show/acks") {
4163
+ const { readDevInfo } = await import("./work-B4tydWnf.mjs").then((n) => n.c);
4164
+ const token = readDevInfo(root)?.token;
4165
+ const tokenOk = !!token && req.headers["x-mv-work"] === token;
4166
+ if (path === "show" && req.method === "POST") {
4167
+ if (!ownerGated(req) && !tokenOk) return json(res, 403, { error: "forbidden" });
4168
+ const raw = await readBody(req, 16384);
4169
+ if (raw == null) return json(res, 400, { error: "body too large or unreadable" });
4170
+ let b;
4171
+ try {
4172
+ b = JSON.parse(raw);
4173
+ } catch {
4174
+ return json(res, 400, { error: "malformed JSON" });
4175
+ }
4176
+ const t = checkShowTarget(b);
4177
+ if (!t) return json(res, 400, { error: "not a show target: { board, n?, f?, s?, c? } in the link grammar" });
4178
+ if (t.board !== "~unplaced" && (dirError() || !listBoardFiles(boardsDir).boards.some((x) => x.name === t.board))) return json(res, 404, { error: `no board "${t.board}"` });
4179
+ const { seq, cmd } = shows.start(t);
4180
+ opts.broadcast?.("sh:show", cmd);
4181
+ return json(res, 200, { seq });
4182
+ }
4183
+ if (path === "show/ack" && req.method === "POST") {
4184
+ if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
4185
+ const raw = await readBody(req, 4096);
4186
+ let b = null;
4187
+ try {
4188
+ b = raw == null ? null : JSON.parse(raw);
4189
+ } catch {}
4190
+ return shows.ack(b?.seq, b?.page, b?.outcome) ? json(res, 200, { ok: true }) : json(res, 400, { error: "not an answer to a show kept here" });
4191
+ }
4192
+ if (path === "show/acks" && req.method === "GET") {
4193
+ if (!ownerGated(req) && !tokenOk) return json(res, 403, { error: "forbidden" });
4194
+ const a = shows.acks(Number(url.searchParams.get("seq")));
4195
+ return a ? json(res, 200, a) : json(res, 404, { error: "no such show" });
4196
+ }
4197
+ return json(res, 405, { error: "method not allowed" });
4198
+ }
3930
4199
  if (path === "work") {
3931
- const { workActivity, readDevInfo, WORK_TTL_DEFAULT, WORK_TTL_MAX } = await import("./work-DJxH7cCX.mjs").then((n) => n.o);
4200
+ const { workActivity, readDevInfo, WORK_TTL_DEFAULT, WORK_TTL_MAX } = await import("./work-B4tydWnf.mjs").then((n) => n.c);
3932
4201
  const tokenOk = () => {
3933
4202
  const t = readDevInfo(root)?.token;
3934
4203
  return !!t && req.headers["x-mv-work"] === t;
3935
4204
  };
3936
4205
  if (req.method === "GET") {
3937
4206
  if (!ownerGated(req) && !tokenOk()) return json(res, 403, { error: "forbidden" });
3938
- const { boardsShowing, activityClock } = await import("./work-DJxH7cCX.mjs").then((n) => n.o);
4207
+ const { boardsShowing, activityClock } = await import("./work-B4tydWnf.mjs").then((n) => n.c);
3939
4208
  const frames = workActivity.active();
3940
4209
  return json(res, 200, {
3941
4210
  frames,
@@ -3958,7 +4227,7 @@ function apiMiddleware(root, opts = {}) {
3958
4227
  if (!on && b.all === true) {
3959
4228
  const done = workActivity.active().filter((f) => workActivity.has(f, "cli"));
3960
4229
  if (done.length) {
3961
- (await import("./marks-BnNANic9.mjs").then((n) => n.a)).recordChanged(root, devFrames(), done, { doc: false });
4230
+ (await import("./marks-C8oX8kbE.mjs").then((n) => n.a)).recordChanged(root, devFrames(), done, { doc: false });
3962
4231
  opts.notify?.("sh:marks");
3963
4232
  }
3964
4233
  workActivity.clearAll("cli");
@@ -3978,7 +4247,7 @@ function apiMiddleware(root, opts = {}) {
3978
4247
  for (const f of frames) on ? workActivity.mark(f, ttl, "cli") : workActivity.clear(f, "cli");
3979
4248
  saveHolds(root, workActivity);
3980
4249
  if (!on) {
3981
- (await import("./marks-BnNANic9.mjs").then((n) => n.a)).recordChanged(root, devFrames(), frames, { doc: false });
4250
+ (await import("./marks-C8oX8kbE.mjs").then((n) => n.a)).recordChanged(root, devFrames(), frames, { doc: false });
3982
4251
  opts.notify?.("sh:marks");
3983
4252
  return json(res, 200, { frames: workActivity.active() });
3984
4253
  }
@@ -4031,7 +4300,7 @@ function apiMiddleware(root, opts = {}) {
4031
4300
  } catch {
4032
4301
  return json(res, 400, { error: "malformed JSON" });
4033
4302
  }
4034
- const { ACTIONS } = await import("./queue-DeSQm24g.mjs");
4303
+ const { ACTIONS } = await import("./queue-BLLfdlDw.mjs");
4035
4304
  if (!b || typeof b.id !== "string" || !Number.isInteger(b.rev) || !ACTIONS.includes(b.action) || b.body !== void 0 && typeof b.body !== "string") return json(res, 400, { error: "expected { id, rev, action, body? }" });
4036
4305
  if ("kind" in b) return json(res, 400, { error: "a capture has no category" });
4037
4306
  const { jamLive } = await Promise.resolve().then(() => live_exports);
@@ -4076,7 +4345,7 @@ function apiMiddleware(root, opts = {}) {
4076
4345
  if (!jamLive.session || !jamLive.view) return json(res, 409, { error: "jam is not running here" });
4077
4346
  if (req.method === "GET") {
4078
4347
  const ses = jamLive.view().session ?? null;
4079
- const { readTalk, talkMinutes, recordFile } = await import("./session-VDJfXEEm.mjs").then((n) => n.s);
4348
+ const { readTalk, talkMinutes, recordFile } = await import("./session-DBF-nQvq.mjs").then((n) => n.s);
4080
4349
  const folder = ses ? recordFile(root, ses.since, ses.id).replace(/[^/]+$/, "") : null;
4081
4350
  return json(res, 200, {
4082
4351
  session: ses,
@@ -4255,11 +4524,13 @@ function apiMiddleware(root, opts = {}) {
4255
4524
  }
4256
4525
  if (path === "jam/capture" && req.method === "GET") {
4257
4526
  if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
4258
- const { readCapture } = await import("./capture-DEtM4qm5.mjs").then((n) => n.i);
4527
+ const { readCapture } = await import("./capture-HaS-1or8.mjs").then((n) => n.i);
4259
4528
  const id = url.searchParams.get("id") ?? "";
4260
4529
  const cap = readCapture(root, id);
4261
4530
  if (!cap) return json(res, 404, { error: "no such capture" });
4262
4531
  const { jamLive } = await Promise.resolve().then(() => live_exports);
4532
+ const { captureWithdrawn } = await import("./queue-BLLfdlDw.mjs");
4533
+ if (jamLive.withdrawn?.(id) || captureWithdrawn(root, id, cap.record.context.board)) return json(res, 410, { error: "this capture was withdrawn - its comment was deleted" });
4263
4534
  const card = jamLive.view?.().cards.find((c) => c.id === id);
4264
4535
  return json(res, 200, {
4265
4536
  record: cap.record,
@@ -4278,11 +4549,11 @@ function apiMiddleware(root, opts = {}) {
4278
4549
  } catch {
4279
4550
  return json(res, 400, { error: "malformed JSON" });
4280
4551
  }
4281
- const { CAPTURE_ID, readCapture, addPicture, sweepPictures } = await import("./capture-DEtM4qm5.mjs").then((n) => n.i);
4552
+ const { CAPTURE_ID, readCapture, addPicture, sweepPictures } = await import("./capture-HaS-1or8.mjs").then((n) => n.i);
4282
4553
  if (!b || typeof b.capture !== "string" || !CAPTURE_ID.test(b.capture) || typeof b.frame !== "string") return json(res, 400, { error: "expected { capture, frame, theme?, viewport? }" });
4283
4554
  if (readCapture(root, b.capture)) return json(res, 409, { error: "that capture is sealed" });
4284
4555
  const theme = typeof b.theme === "string" && /^[a-z0-9-]+$/i.test(b.theme) ? b.theme : "light";
4285
- const { shootFrame } = await import("./shot-d4h_hJi9.mjs").then((n) => n.u);
4556
+ const { shootFrame } = await import("./shot-Bjt2MQe3.mjs").then((n) => n.u);
4286
4557
  const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
4287
4558
  const vp = typeof b.viewport === "string" ? opts.viewports?.[b.viewport] : void 0;
4288
4559
  const dim = (v) => typeof v === "number" && Number.isFinite(v) ? Math.round(v) : void 0;
@@ -4331,7 +4602,7 @@ function apiMiddleware(root, opts = {}) {
4331
4602
  if (path === "jam/picture" && req.method === "GET") {
4332
4603
  const site = String(req.headers["sec-fetch-site"] ?? "");
4333
4604
  if (!ownerGated(req) && !(cookie(req, "mv_c") && (site === "same-origin" || site === "none"))) return json(res, 403, { error: "forbidden" });
4334
- const { picturePath } = await import("./capture-DEtM4qm5.mjs").then((n) => n.i);
4605
+ const { picturePath } = await import("./capture-HaS-1or8.mjs").then((n) => n.i);
4335
4606
  const p = picturePath(root, url.searchParams.get("id") ?? "");
4336
4607
  if (!p) return json(res, 404, { error: "no such picture" });
4337
4608
  const png = readFileSync(p.path);
@@ -4349,11 +4620,66 @@ function apiMiddleware(root, opts = {}) {
4349
4620
  stored: listBoards(join(root, "design", "comments"))
4350
4621
  });
4351
4622
  }
4623
+ if (path === "capabilities" && req.method === "GET") return json(res, 200, {
4624
+ delete: true,
4625
+ resolveAll: true
4626
+ });
4627
+ if (path === "comment-ownership" && req.method === "GET") {
4628
+ if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
4629
+ const { ownership } = await import("./own-C8Mq0Hnf.mjs");
4630
+ return json(res, 200, { boards: ownership(root) });
4631
+ }
4632
+ if ((path === "comment-actions/resolve-all" || path === "comment-actions/undo") && req.method === "POST") {
4633
+ const { readDevInfo } = await import("./work-B4tydWnf.mjs").then((n) => n.c);
4634
+ const token = readDevInfo(root)?.token;
4635
+ if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
4636
+ const raw = await readBody(req);
4637
+ if (raw == null) return json(res, 400, { error: "body too large" });
4638
+ let b;
4639
+ try {
4640
+ b = JSON.parse(raw);
4641
+ } catch {
4642
+ return json(res, 400, { error: "malformed JSON" });
4643
+ }
4644
+ const ca = await import("./comment-actions-Bxf9Ld4g.mjs");
4645
+ const { jamLive } = await Promise.resolve().then(() => live_exports);
4646
+ if (typeof b?.op !== "string" || !ca.OP_RE.test(b.op)) return json(res, 400, { error: "expected { op: <8-64 char token>, ... }" });
4647
+ if (path === "comment-actions/undo") {
4648
+ const u = ca.undoResolveAll(root, b.op);
4649
+ if ("error" in u) return json(res, u.status, { error: u.error });
4650
+ jamLive.poke?.();
4651
+ backgroundPush(root);
4652
+ return json(res, u.failed.length ? 207 : 200, {
4653
+ ...u,
4654
+ summary: ca.undoSummary(u)
4655
+ });
4656
+ }
4657
+ const scope = ca.parseScope(b.scope);
4658
+ if (typeof scope === "string") return json(res, 400, { error: scope });
4659
+ const r = ca.resolveAll(root, b.op, scope, {
4660
+ busy: jamLive.busy,
4661
+ dryRun: b.dryRun === true
4662
+ });
4663
+ if ("error" in r) return json(res, r.status, { error: r.error });
4664
+ if (b.dryRun !== true) {
4665
+ jamLive.poke?.();
4666
+ backgroundPush(root);
4667
+ }
4668
+ return json(res, r.failed.length ? 207 : 200, {
4669
+ ...r,
4670
+ summary: ca.resolveSummary(r)
4671
+ });
4672
+ }
4352
4673
  const cm = /^comments\/([a-z0-9][a-z0-9-]*)$/.exec(path);
4353
4674
  if (cm) {
4354
4675
  const { appendEvents, readLog } = await import("./comments-0BSbb04K.mjs").then((n) => n.n);
4355
4676
  const dir = join(root, "design", "comments");
4356
- if (req.method === "GET") return json(res, 200, { events: readLog(dir, cm[1]) });
4677
+ if (req.method === "GET") {
4678
+ const { deletedMessages, withoutDeletedWords } = await import("./events-Dieo1482.mjs").then((n) => n.i);
4679
+ const evs = readLog(dir, cm[1]);
4680
+ const gone = deletedMessages(evs);
4681
+ return json(res, 200, { events: evs.map((e) => withoutDeletedWords(e, gone)) });
4682
+ }
4357
4683
  if (req.method === "POST") {
4358
4684
  if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
4359
4685
  const raw = await readBody(req);
@@ -4366,6 +4692,31 @@ function apiMiddleware(root, opts = {}) {
4366
4692
  }
4367
4693
  const incoming = Array.isArray(b.events) ? b.events : [];
4368
4694
  const me = localProfile(root);
4695
+ if (incoming.some((ev) => ev?.board !== void 0 && ev.board !== cm[1])) return json(res, 400, { error: "event board does not match the endpoint" });
4696
+ {
4697
+ const have = readLog(dir, cm[1]);
4698
+ const evIds = new Set(have.map((e) => e.id));
4699
+ const msgIds = new Set(have.filter((e) => (e.type === "create" || e.type === "reply") && e.commentId).map((e) => e.commentId));
4700
+ for (const ev of incoming) {
4701
+ if (ev?.type !== "create" && ev?.type !== "reply" || evIds.has(ev.id)) continue;
4702
+ if (typeof ev.commentId !== "string" || msgIds.has(ev.commentId)) return json(res, 409, { error: "a comment with that id already exists" });
4703
+ msgIds.add(ev.commentId);
4704
+ }
4705
+ }
4706
+ if (incoming.some((ev) => ev?.type === "edit" || ev?.type === "delete")) {
4707
+ const { ownsMessage } = await import("./own-C8Mq0Hnf.mjs");
4708
+ const { deletedMessages } = await import("./events-Dieo1482.mjs").then((n) => n.i);
4709
+ const log = readLog(dir, cm[1]);
4710
+ const gone = deletedMessages(log);
4711
+ const captures = new Set(log.filter((e) => e?.type === "create" && e.capture && e.commentId).map((e) => e.commentId));
4712
+ for (const ev of incoming) {
4713
+ if (ev?.type !== "edit" && ev?.type !== "delete") continue;
4714
+ if (typeof ev.commentId !== "string" || !ownsMessage(root, cm[1], ev.commentId)) return json(res, 403, { error: `only its author can ${ev.type} a comment` });
4715
+ if (ev.type === "edit" && gone.has(ev.commentId)) return json(res, 409, { error: "that comment was deleted" });
4716
+ if (ev.type === "edit" && captures.has(ev.commentId)) return json(res, 409, { error: "a capture is edited in Jam - here it can only be deleted" });
4717
+ if (ev.type === "edit" && (typeof ev.body !== "string" || !ev.body.trim())) return json(res, 400, { error: "an edit needs words - delete the comment instead" });
4718
+ }
4719
+ }
4369
4720
  const stamped = incoming.map((ev) => {
4370
4721
  const { agent: _a, agentMeta: _am, origin: _o, ...clean } = ev;
4371
4722
  return {
@@ -4375,20 +4726,24 @@ function apiMiddleware(root, opts = {}) {
4375
4726
  "create",
4376
4727
  "reply",
4377
4728
  "react",
4378
- "edit"
4729
+ "edit",
4730
+ "delete"
4379
4731
  ].includes(clean.type) ? me : void 0)
4380
4732
  };
4381
4733
  });
4382
- const fresh = appendEvents(dir, cm[1], stamped);
4383
4734
  const { record } = await import("./ledger-D54iROST.mjs").then((n) => n.n);
4735
+ const { recordOwn } = await import("./own-C8Mq0Hnf.mjs");
4736
+ const fresh = appendEvents(dir, cm[1], stamped);
4384
4737
  for (const ev of fresh) if (ev.type === "create" || ev.type === "reply" || ev.type === "edit") record(root, cm[1], ev.id);
4738
+ const mine = fresh.filter((ev) => (ev.type === "create" || ev.type === "reply") && typeof ev.commentId === "string").map((ev) => ev.commentId);
4739
+ if (mine.length) recordOwn(root, cm[1], mine);
4385
4740
  (await Promise.resolve().then(() => live_exports)).jamLive.poke?.();
4386
4741
  backgroundPush(root);
4387
4742
  return json(res, 200, { accepted: fresh.length });
4388
4743
  }
4389
4744
  }
4390
4745
  if (path === "sync" && req.method === "POST") {
4391
- const { loadCollab, syncOnce } = await import("./sync-CMozOwZ0.mjs").then((n) => n.o);
4746
+ const { loadCollab, syncOnce } = await import("./sync-BNWwh8OF.mjs").then((n) => n.o);
4392
4747
  const collab = loadCollab(root);
4393
4748
  if (!collab) return json(res, 200, { connected: false });
4394
4749
  try {
@@ -4417,13 +4772,29 @@ function backgroundPush(root) {
4417
4772
  pushTimer = setTimeout(async () => {
4418
4773
  pushTimer = null;
4419
4774
  try {
4420
- const { loadCollab, syncOnce } = await import("./sync-CMozOwZ0.mjs").then((n) => n.o);
4775
+ const { loadCollab, syncOnce } = await import("./sync-BNWwh8OF.mjs").then((n) => n.o);
4421
4776
  const collab = loadCollab(root);
4422
4777
  if (collab) await syncOnce(root, collab);
4423
4778
  } catch {}
4424
4779
  }, 1500);
4425
4780
  }
4426
4781
  //#endregion
4782
+ //#region src/server/pdf-reset.ts
4783
+ /**
4784
+ * The dev server's restart and close reach deck PDF jobs through this hook (spec 31): plugin.ts calls `resetPdf(root)`
4785
+ * without loading pdf.ts (and pdf-lib) on a canvas that never exported; pdf.ts registers itself when it first loads.
4786
+ */
4787
+ let reset = null;
4788
+ function onPdfReset(fn) {
4789
+ reset = fn;
4790
+ }
4791
+ /** Cancel this canvas's running PDF job (its browser closes) and forget its jobs. A no-op until pdf.ts has loaded. */
4792
+ function resetPdf(root) {
4793
+ try {
4794
+ reset?.(root);
4795
+ } catch {}
4796
+ }
4797
+ //#endregion
4427
4798
  //#region src/server/routes.ts
4428
4799
  function routesMiddleware(server, clientDir, stamps, proof) {
4429
4800
  const page = (dir) => {
@@ -4590,6 +4961,11 @@ function elsewhere(res) {
4590
4961
  * contracts: the Mac app's fake canvas runs it under Node's type stripping over a scripted `read()`, so the app's cases
4591
4962
  * meet this code, not a copy (#4).
4592
4963
  */
4964
+ /**
4965
+ * Spec 32 F2: the time app-live first saw a working Jam card with no `startedAt` (an older batch never claimed), by its
4966
+ * card - what its run counts from then. Kept for the process, a card leaving work forgets it.
4967
+ */
4968
+ const firstSeenWorking = /* @__PURE__ */ new Map();
4593
4969
  /** An item's id (#9): its kind and the first 20 hex of a sha256 over the occurrence's persisted parts, NUL-joined. */
4594
4970
  const liveId = (kind, ...parts) => `${kind}:${createHash("sha256").update(parts.map(String).join("\0")).digest("hex").slice(0, 20)}`;
4595
4971
  /** One line of at most `max` UTF-16 units: whitespace collapsed, control characters gone, never cut inside a pair. A
@@ -4711,38 +5087,93 @@ function liveSnapshot(input) {
4711
5087
  };
4712
5088
  for (const i of items) counts[i.kind]++;
4713
5089
  const shown = items.filter(refsFit).sort((a, b) => b.at - a.at || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
4714
- const working = input.cli.length > 0 || cards.some((c) => c.state === "working" && (!c.runner || !c.runner.state || c.runner.state === "claimed"));
5090
+ const runsNow = cards.filter((c) => c.state === "working" && !c.unstarted && (!c.runner || !c.runner.state || c.runner.state === "claimed"));
5091
+ const working = input.cli.length > 0 || runsNow.length > 0;
5092
+ const kept = shown.slice(0, LIVE_BOUNDS.items);
5093
+ const work = workOf(input, runsNow);
5094
+ const titles = titlesOf(input.titles, [...work?.board ? [work.board] : [], ...kept.map((i) => i.board)]);
4715
5095
  return {
4716
5096
  jam: view ? "on" : "off",
4717
- items: shown.slice(0, LIVE_BOUNDS.items),
5097
+ items: kept,
4718
5098
  cut: Math.max(0, shown.length - LIVE_BOUNDS.items),
4719
5099
  counts,
4720
5100
  unseen: input.fresh.length,
4721
5101
  working,
4722
- session: !!view?.session
5102
+ session: !!view?.session,
5103
+ ...work ? { work } : {},
5104
+ ...titles ? { titles } : {}
5105
+ };
5106
+ }
5107
+ /**
5108
+ * Spec 32 F2, `work`: since when something has been at work, and on which board. `since` is the earlier of `marver
5109
+ * work`'s clock and the oldest working run's start (its `startedAt`, else when it was first seen working); `board` the
5110
+ * newest working Jam card's board (the last made, then by id - never the latest run start), else the first board by name pinning a frame
5111
+ * the CLI holds; absent when nothing works.
5112
+ */
5113
+ function workOf(input, runsNow) {
5114
+ const now = input.now ?? Date.now();
5115
+ const ids = new Set(runsNow.map((c) => c.id));
5116
+ for (const id of [...firstSeenWorking.keys()]) if (!ids.has(id)) firstSeenWorking.delete(id);
5117
+ const startOf = (c) => {
5118
+ if (typeof c.startedAt === "number") return c.startedAt;
5119
+ let t = firstSeenWorking.get(c.id);
5120
+ if (t === void 0) firstSeenWorking.set(c.id, t = now);
5121
+ return t;
5122
+ };
5123
+ const cli = input.cli.length > 0 && typeof input.cliSince === "number" ? input.cliSince : void 0;
5124
+ const all = [...cli !== void 0 ? [cli] : [], ...runsNow.map(startOf)];
5125
+ if (!all.length) return void 0;
5126
+ const board = [...runsNow].sort((a, b) => b.made - a.made || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))[0]?.board ?? (input.cli.length ? input.pinning?.[0] : void 0);
5127
+ return {
5128
+ ...board && board.length <= LIVE_BOUNDS.ref ? { board } : {},
5129
+ since: Math.min(...all)
4723
5130
  };
4724
5131
  }
5132
+ /** Spec 32 F2, `titles`: the titles of the boards named, in that order, each once - at most `LIVE_TITLES_MAX`, a key a
5133
+ * ref (at most `LIVE_BOUNDS.ref`) and a value one line of at most `LIVE_BOUNDS.title`; absent when none has one. */
5134
+ function titlesOf(all, boards) {
5135
+ if (!all) return void 0;
5136
+ const out = {};
5137
+ let n = 0;
5138
+ for (const b of boards) {
5139
+ if (n >= 32) break;
5140
+ if (Object.hasOwn(out, b) || b.length > LIVE_BOUNDS.ref || !Object.hasOwn(all, b)) continue;
5141
+ const t = oneLine(all[b]);
5142
+ if (!t) continue;
5143
+ out[b] = t;
5144
+ n++;
5145
+ }
5146
+ return n ? out : void 0;
5147
+ }
4725
5148
  const block = (e) => `event: ${LIVE_WIRE.event}\ndata: ${JSON.stringify(e)}\n\n`;
5149
+ /** The event with only these items, and only the titles they or `work` still name (spec 32 F2: titles count in the bytes). */
5150
+ function withItems(e, items, cut) {
5151
+ const { titles, ...rest } = e;
5152
+ const named = /* @__PURE__ */ new Set([...e.work?.board ? [e.work.board] : [], ...items.map((i) => i.board)]);
5153
+ const kept = titles ? Object.fromEntries(Object.entries(titles).filter(([b]) => named.has(b))) : {};
5154
+ return {
5155
+ ...rest,
5156
+ items,
5157
+ cut,
5158
+ ...Object.keys(kept).length ? { titles: kept } : {}
5159
+ };
5160
+ }
4726
5161
  /**
4727
5162
  * The event as written (#11, r1 #4): `event: live`, one `data:` line, a blank line - within `LIVE_BOUNDS.eventBytes`
4728
5163
  * in UTF-8. While it is over, the oldest whole items go (the end of `items`), counted in `cut`; `counts` stay exact.
4729
5164
  */
4730
5165
  function encodeLive(e) {
4731
- let text = block(e);
5166
+ const text = block(e);
4732
5167
  if (Buffer.byteLength(text) <= LIVE_BOUNDS.eventBytes) return text;
4733
- const sizes = e.items.map((i) => Buffer.byteLength(JSON.stringify(i)) + 1);
4734
- let over = Buffer.byteLength(text) - LIVE_BOUNDS.eventBytes;
4735
- let keep = e.items.length;
4736
- while (keep > 0 && over > 0) over -= sizes[--keep];
4737
- for (;;) {
4738
- text = block({
4739
- ...e,
4740
- items: e.items.slice(0, keep),
4741
- cut: e.cut + e.items.length - keep
4742
- });
4743
- if (keep === 0 || Buffer.byteLength(text) <= LIVE_BOUNDS.eventBytes) return text;
4744
- keep--;
5168
+ const at = (keep) => block(withItems(e, e.items.slice(0, keep), e.cut + e.items.length - keep));
5169
+ const fits = (keep) => Buffer.byteLength(at(keep)) <= LIVE_BOUNDS.eventBytes;
5170
+ let lo = 0, hi = e.items.length - 1;
5171
+ while (lo < hi) {
5172
+ const mid = lo + hi + 1 >> 1;
5173
+ if (fits(mid)) lo = mid;
5174
+ else hi = mid - 1;
4745
5175
  }
5176
+ return at(lo);
4746
5177
  }
4747
5178
  /** `seq`: per server process, rising across Vite restarts - one counter for every hub this module makes (#11, #14). */
4748
5179
  const SEQ = { n: 0 };
@@ -4917,7 +5348,7 @@ function marverPlugin(ctx) {
4917
5348
  /** a watcher this plugin makes, handed to the start (its error is said, not Node's crash) - as it is, outside one */
4918
5349
  const guarded = (w) => ctx.startup?.watch?.(w) ?? w;
4919
5350
  let project = {
4920
- name: config.share.name || basename(root),
5351
+ name: canvasIdentity(root, config).local,
4921
5352
  description: config.description
4922
5353
  };
4923
5354
  const projectInfo = () => project;
@@ -5117,7 +5548,8 @@ function marverPlugin(ctx) {
5117
5548
  zoomSpeed: config.zoomSpeed,
5118
5549
  noTheme: themeFile() == null,
5119
5550
  setup: setupPending,
5120
- projectName: config.share.name || basename(root),
5551
+ devices: config.devices,
5552
+ projectName: canvasIdentity(root, config).local,
5121
5553
  branding: config.share.branding,
5122
5554
  jam: config.jam ? {
5123
5555
  chime: config.jam.chime,
@@ -5194,7 +5626,7 @@ function marverPlugin(ctx) {
5194
5626
  server.middlewares.use(perfRunBarrier());
5195
5627
  const hub = ctx.proof ? createLiveHub({
5196
5628
  instance: ctx.proof.instance,
5197
- read: () => liveSnapshot(live.read(manifest.frames)),
5629
+ read: () => liveSnapshot(live.read(manifest.frames, manifest.boards)),
5198
5630
  on: (fn) => workActivity.onChange(fn)
5199
5631
  }) : null;
5200
5632
  if (hub) onClose(() => hub.close());
@@ -5224,18 +5656,34 @@ function marverPlugin(ctx) {
5224
5656
  });
5225
5657
  server.middlewares.use((req, res, next) => {
5226
5658
  if (new URL(req.url ?? "/", "http://x").pathname !== `/__mv/api/update`) return next();
5227
- update.then((latest) => {
5659
+ update.then(() => updateStatus(root)).then((u) => {
5228
5660
  res.setHeader("content-type", "application/json");
5229
5661
  res.setHeader("cache-control", "no-store");
5230
- res.end(JSON.stringify({
5231
- latest,
5232
- current: installedVersion()
5233
- }));
5662
+ res.end(JSON.stringify(u));
5663
+ }, () => {
5664
+ res.statusCode = 500;
5665
+ res.end("{}");
5234
5666
  });
5235
5667
  });
5236
5668
  const listeningOrigin = () => originOf(server.httpServer?.address());
5237
5669
  initMarks(root, manifest.frames);
5238
5670
  tidyPerfDir(root);
5671
+ resetPdf(root);
5672
+ try {
5673
+ if (!checkRealDirs(root, [
5674
+ [join(root, "design"), "design"],
5675
+ [join(root, "design", ".local"), "design/.local"],
5676
+ [join(root, "design", ".local", "pdf"), "design/.local/pdf"]
5677
+ ])) rmSync(join(root, "design", ".local", "pdf"), {
5678
+ recursive: true,
5679
+ force: true
5680
+ });
5681
+ } catch {}
5682
+ server.httpServer?.once("close", () => resetPdf(root));
5683
+ server.middlewares.use((req, res, next) => {
5684
+ if (!(req.url ?? "").startsWith(`/__mv/handout/`)) return next();
5685
+ import("./pdf-Cf9GIoIM.mjs").then((m) => m.handoutMiddleware()(req, res, next), next);
5686
+ });
5239
5687
  server.middlewares.use(apiMiddleware(root, {
5240
5688
  viewports: config.viewports,
5241
5689
  origin: listeningOrigin,
@@ -5244,12 +5692,15 @@ function marverPlugin(ctx) {
5244
5692
  server.ws.send(event, {});
5245
5693
  liveChanged();
5246
5694
  },
5695
+ broadcast: (event, payload) => server.ws.send(event, payload),
5247
5696
  manifest: () => manifest,
5248
5697
  settled,
5249
5698
  workspace: ws,
5250
- inputs
5699
+ inputs,
5700
+ themes: config.themes,
5701
+ canvasName: () => canvasIdentity(root, config).local
5251
5702
  }));
5252
- server.middlewares.use(logoRoute(root, () => config.share.logo, ctx.proof));
5703
+ server.middlewares.use(logoRoute(root, () => canvasIdentity(root, config).logos, ctx.proof));
5253
5704
  server.middlewares.use(routesMiddleware(server, clientDir, {
5254
5705
  doc: (id) => docRev(root, manifest.frames, id),
5255
5706
  docs: () => docRevs(root, manifest.frames)
@@ -5376,7 +5827,7 @@ function marverPlugin(ctx) {
5376
5827
  if (f !== configFile) return;
5377
5828
  loadConfig(root).then((c) => {
5378
5829
  project = {
5379
- name: c.share.name || basename(root),
5830
+ name: canvasIdentity(root, c).local,
5380
5831
  description: c.description
5381
5832
  };
5382
5833
  regen();
@@ -5517,7 +5968,7 @@ function marverPlugin(ctx) {
5517
5968
  });
5518
5969
  return;
5519
5970
  }
5520
- const { shootFrame, shootBatch, resolveFrames } = await import("./shot-d4h_hJi9.mjs").then((n) => n.u);
5971
+ const { shootFrame, shootBatch, resolveFrames } = await import("./shot-Bjt2MQe3.mjs").then((n) => n.u);
5521
5972
  if (ways[0] === "frame") {
5522
5973
  if (typeof spec.frame !== "string") {
5523
5974
  write({
@@ -5601,7 +6052,7 @@ function liveSources(root) {
5601
6052
  const cache = /* @__PURE__ */ new Map();
5602
6053
  let reads = 0;
5603
6054
  return {
5604
- read(frames) {
6055
+ read(frames, manifestBoards) {
5605
6056
  const names = listBoards(dir);
5606
6057
  for (const b of cache.keys()) if (!names.includes(b)) cache.delete(b);
5607
6058
  const boards = [];
@@ -5627,11 +6078,18 @@ function liveSources(root) {
5627
6078
  threads: c.threads
5628
6079
  });
5629
6080
  }
6081
+ const cli = workActivity.leases("cli").map(([f]) => f);
6082
+ const titles = {};
6083
+ for (const b of manifestBoards ?? []) if (b.title) titles[b.name] = b.title;
6084
+ const since = workClock.since();
5630
6085
  return {
5631
6086
  boards,
5632
6087
  fresh: freshFrames(root, frames),
5633
6088
  jam: jamLive.view?.(),
5634
- cli: workActivity.leases("cli").map(([f]) => f)
6089
+ cli,
6090
+ ...since !== void 0 ? { cliSince: since } : {},
6091
+ ...cli.length ? { pinning: pinningBoards(root, cli) } : {},
6092
+ titles
5635
6093
  };
5636
6094
  },
5637
6095
  reads: () => reads
@@ -5688,4 +6146,4 @@ async function tailwind3Css(root) {
5688
6146
  return null;
5689
6147
  }
5690
6148
  //#endregion
5691
- export { live_exports as a, ASK_MAX as c, jamLive as i, bakeBatch as l, tailwind3Css as n, liveChanged as o, tailwind4Plugin as r, installedVersion as s, marverPlugin as t };
6149
+ export { live_exports as a, installedVersion as c, canvasIdentity as d, identityNudge as f, jamLive as i, ASK_MAX as l, tailwind3Css as n, liveChanged as o, tailwind4Plugin as r, onPdfReset as s, marverPlugin as t, bakeBatch as u };