@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,8 +1,12 @@
1
1
  import { r as NAME } from "./cli.mjs";
2
- import { _ as unplacedHint, a as checkBoardsDir, c as listBoardFiles, p as readMembership } from "./boards-EH2onUXM.mjs";
3
- import { f as isBoardName } from "./board-tree-BXR8dw4b.mjs";
4
- import { s as scanFrames } from "./manifest-DPZ3WNg_.mjs";
5
- import { i as readDevInfo } from "./work-DJxH7cCX.mjs";
2
+ import { l as listBoardFiles, m as readMembership, o as checkBoardsDir, v as unplacedHint } from "./boards-Cim1GTKc.mjs";
3
+ import { f as isBoardName } from "./board-tree-DGj0HhEE.mjs";
4
+ import { s as scanFrames } from "./manifest-CK8Qh4Nq.mjs";
5
+ import { a as checkAppLive, i as buildDeepLink, l as targetFromHash, r as appTakesLink, t as APP_LIVE_FILE } from "./deep-link-DYtuT740.mjs";
6
+ import { r as pidRuns } from "./exclusive-B1RtpeeP.mjs";
7
+ import { i as marverHome } from "./slots-BOcfIqxy.mjs";
8
+ import { a as readDevInfo } from "./work-B4tydWnf.mjs";
9
+ import { readFileSync, realpathSync } from "node:fs";
6
10
  import { join } from "node:path";
7
11
  //#region src/cli/link.ts
8
12
  /**
@@ -135,13 +139,55 @@ async function devOrigin(root) {
135
139
  * the first one's lock. */
136
140
  const unreachable = (pid) => `\`${NAME} dev\` runs (pid ${pid}) but cannot be reached from here - a sandbox?`;
137
141
  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`;
142
+ /**
143
+ * Whether the Mac app takes this canvas's links now (spec 31 D2): `~/.marver/state/app-live.json` (MARVER_HOME
144
+ * honoured) names a pid that runs, is under 90 s old, says `scheme: 1`, and lists this canvas's real folder among its
145
+ * open tabs. Anything else - an older app, a stale file, the canvas not open there - is the localhost link.
146
+ */
147
+ function appLive(root, now = Date.now()) {
148
+ let file;
149
+ try {
150
+ file = checkAppLive(JSON.parse(readFileSync(join(marverHome(), "state", APP_LIVE_FILE), "utf8")));
151
+ } catch {
152
+ return false;
153
+ }
154
+ let real = root;
155
+ try {
156
+ real = realpathSync(root);
157
+ } catch {}
158
+ return appTakesLink(file, real, now, pidRuns);
159
+ }
160
+ /**
161
+ * The link for one hash (spec 31 D1, D2): the app's `marver://open?ws=<folder>&to=<hash>&port=<p>` when the app is in
162
+ * use with this canvas open (and `web` is not asked), else `<origin><hash>`.
163
+ */
164
+ function linkFor(root, origin, hash, o = {}) {
165
+ if (!o.web && targetFromHash(hash) && (o.app ?? appLive(root))) {
166
+ let real = root;
167
+ try {
168
+ real = realpathSync(root);
169
+ } catch {}
170
+ const port = Number(new URL(origin).port) || void 0;
171
+ const deep = buildDeepLink({
172
+ ws: real,
173
+ to: hash,
174
+ port
175
+ });
176
+ if (deep) return deep;
177
+ }
178
+ return `${origin}${hash}`;
179
+ }
138
180
  async function linkCommand(root, targets, opts) {
139
181
  const r = resolveLink(root, targets, opts.board);
140
182
  if (!r.links.length) throw new Error(r.hints.join("\n"));
141
183
  const found = await findDev(root);
142
184
  if (!found) throw new Error(NOT_RUNNING);
143
185
  const origin = "origin" in found ? found.origin : `http://localhost:${found.unreachable.port}/`;
144
- for (const l of r.links) console.log(`${origin}${l.hash}`);
186
+ const app = !opts.web && appLive(root);
187
+ for (const l of r.links) console.log(linkFor(root, origin, l.hash, {
188
+ web: opts.web,
189
+ app
190
+ }));
145
191
  if ("unreachable" in found) console.error(` ${unreachable(found.unreachable.pid)} The link is its port, from design/.local/dev.json - the person's browser reaches it`);
146
192
  for (const h of r.hints) console.error(` ${h}`);
147
193
  }
@@ -157,8 +203,9 @@ async function handBack(root, targets) {
157
203
  try {
158
204
  const r = resolveLink(root, targets);
159
205
  const origin = await devOrigin(root);
206
+ const app = !!origin && appLive(root);
160
207
  return {
161
- links: origin ? r.links.map((l) => `${origin}${l.hash}`) : [],
208
+ links: origin ? r.links.map((l) => linkFor(root, origin, l.hash, { app })) : [],
162
209
  hints: r.hints
163
210
  };
164
211
  } catch {
@@ -169,4 +216,4 @@ async function handBack(root, targets) {
169
216
  }
170
217
  }
171
218
  //#endregion
172
- export { devOrigin, handBack, linkCommand, resolveLink, resolveTargets, unreachable };
219
+ export { NOT_RUNNING, devOrigin, findDev, handBack, linkCommand, linkFor, resolveLink, resolveTargets, unreachable };
@@ -2,51 +2,9 @@ import { a as ROUTE } from "./cli.mjs";
2
2
  import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readSync, realpathSync, writeFileSync } from "node:fs";
3
3
  import { join, resolve, sep } from "node:path";
4
4
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
5
- //#region src/server/proof.ts
6
- /**
7
- * The document proof (spec 28 A1.4). The Mac app puts a fresh nonce on every main-frame request to a
8
- * local canvas (`x-mv-nonce`) and checks the answer before the document commits; only the canvas
9
- * holding the slot file's key can sign it, so the privileges the app grants belong to that exact
10
- * document. The proof rides the very response the app commits - the check and the load can never
11
- * reach different listeners.
12
- *
13
- * Pinned exactly, so the app (A2.3 `proof.ts`) computes the same: the key is the slot file's 32 bytes
14
- * (base64url there), HMAC-SHA256 over UTF-8 `doc|<nonce>|<port>` (port in decimal), base64url without
15
- * padding. Requests from the app itself carry `app|<port>` the same way, and the logo the app fetches
16
- * (`GET /__mv/logo`, spec 28 A2.4) `logo|<nonce>|<port>`: a listener that took the port after the tab was
17
- * verified can never hand it a logo. The live stream (`GET /__mv/app/live`, A4.6 #6) is proved both ways: the
18
- * request carries `x-mv-app` (`appProof`, checked by `appProofOk`), the answer `live|<nonce>|<port>` - a
19
- * listener that took the port after a canvas stopped can never put words into a notice.
20
- */
21
- /** 16-64 base64url characters - anything else is not a nonce, and is ignored. */
22
- const NONCE = /^[A-Za-z0-9_-]{16,64}$/;
23
- const sign$1 = (key, msg) => createHmac("sha256", key).update(msg, "utf8").digest("base64url");
24
- const docProof = (key, nonce, port) => sign$1(key, `doc|${nonce}|${port}`);
25
- const appProof = (key, port) => sign$1(key, `app|${port}`);
26
- const logoProof = (key, nonce, port) => sign$1(key, `logo|${nonce}|${port}`);
27
- const liveProof = (key, nonce, port) => sign$1(key, `live|${nonce}|${port}`);
28
- const PROOFS = {
29
- doc: docProof,
30
- logo: logoProof,
31
- live: liveProof
32
- };
33
- /** The two headers for a request carrying a well-formed `x-mv-nonce`, else null: over the shell's document
34
- * (`doc`), the logo (`logo`) or the live stream (`live`). */
35
- function proofHeaders(p, nonce, kind = "doc") {
36
- if (!p || typeof nonce !== "string" || !NONCE.test(nonce)) return null;
37
- return {
38
- "x-mv-instance": p.instance,
39
- "x-mv-proof": PROOFS[kind](p.key, nonce, p.port)
40
- };
41
- }
42
- /** Is this `x-mv-app` header the app's own, `appProof(key, port)`? Compared in constant time over equal lengths;
43
- * anything but one string is no. The HMAC is never relaxed: no cookie, no token stands in for it (A4.6 #6). */
44
- function appProofOk(p, header) {
45
- if (typeof header !== "string") return false;
46
- const got = Buffer.from(header);
47
- const want = Buffer.from(appProof(p.key, p.port));
48
- return got.length === want.length && timingSafeEqual(got, want);
49
- }
5
+ //#region src/shared/logo-sniff.ts
6
+ /** The most a logo may weigh, on either side: a file past it is never read whole, a fetch past it is aborted. */
7
+ const LOGO_MAX = 262144;
50
8
  /** The type each sniffed logo is served with. */
51
9
  const LOGO_MIME = {
52
10
  png: "image/png",
@@ -130,6 +88,52 @@ function doctypeEnd(s, i) {
130
88
  return -1;
131
89
  }
132
90
  //#endregion
91
+ //#region src/server/proof.ts
92
+ /**
93
+ * The document proof (spec 28 A1.4). The Mac app puts a fresh nonce on every main-frame request to a
94
+ * local canvas (`x-mv-nonce`) and checks the answer before the document commits; only the canvas
95
+ * holding the slot file's key can sign it, so the privileges the app grants belong to that exact
96
+ * document. The proof rides the very response the app commits - the check and the load can never
97
+ * reach different listeners.
98
+ *
99
+ * Pinned exactly, so the app (A2.3 `proof.ts`) computes the same: the key is the slot file's 32 bytes
100
+ * (base64url there), HMAC-SHA256 over UTF-8 `doc|<nonce>|<port>` (port in decimal), base64url without
101
+ * padding. Requests from the app itself carry `app|<port>` the same way, and the logo the app fetches
102
+ * (`GET /__mv/logo`, spec 28 A2.4) `logo|<nonce>|<port>`: a listener that took the port after the tab was
103
+ * verified can never hand it a logo. The live stream (`GET /__mv/app/live`, A4.6 #6) is proved both ways: the
104
+ * request carries `x-mv-app` (`appProof`, checked by `appProofOk`), the answer `live|<nonce>|<port>` - a
105
+ * listener that took the port after a canvas stopped can never put words into a notice.
106
+ */
107
+ /** 16-64 base64url characters - anything else is not a nonce, and is ignored. */
108
+ const NONCE = /^[A-Za-z0-9_-]{16,64}$/;
109
+ const sign$1 = (key, msg) => createHmac("sha256", key).update(msg, "utf8").digest("base64url");
110
+ const docProof = (key, nonce, port) => sign$1(key, `doc|${nonce}|${port}`);
111
+ const appProof = (key, port) => sign$1(key, `app|${port}`);
112
+ const logoProof = (key, nonce, port) => sign$1(key, `logo|${nonce}|${port}`);
113
+ const liveProof = (key, nonce, port) => sign$1(key, `live|${nonce}|${port}`);
114
+ const PROOFS = {
115
+ doc: docProof,
116
+ logo: logoProof,
117
+ live: liveProof
118
+ };
119
+ /** The two headers for a request carrying a well-formed `x-mv-nonce`, else null: over the shell's document
120
+ * (`doc`), the logo (`logo`) or the live stream (`live`). */
121
+ function proofHeaders(p, nonce, kind = "doc") {
122
+ if (!p || typeof nonce !== "string" || !NONCE.test(nonce)) return null;
123
+ return {
124
+ "x-mv-instance": p.instance,
125
+ "x-mv-proof": PROOFS[kind](p.key, nonce, p.port)
126
+ };
127
+ }
128
+ /** Is this `x-mv-app` header the app's own, `appProof(key, port)`? Compared in constant time over equal lengths;
129
+ * anything but one string is no. The HMAC is never relaxed: no cookie, no token stands in for it (A4.6 #6). */
130
+ function appProofOk(p, header) {
131
+ if (typeof header !== "string") return false;
132
+ const got = Buffer.from(header);
133
+ const want = Buffer.from(appProof(p.key, p.port));
134
+ return got.length === want.length && timingSafeEqual(got, want);
135
+ }
136
+ //#endregion
133
137
  //#region src/server/logo.ts
134
138
  const LOGO_LADDER = [
135
139
  "design/logo.svg",
@@ -140,28 +144,52 @@ const LOGO_LADDER = [
140
144
  "public/favicon.png",
141
145
  "public/favicon.ico"
142
146
  ];
143
- /** The first candidate that passes every check, read whole; null when none does. `warn` hears why a `share.logo`
144
- * was ignored (the ladder's own entries are tried quietly: most repos have none of them). */
145
- function findLogo(root, shareLogo, warn) {
147
+ /** The first candidate that passes every check, read whole; null when none does. The config's own come first, in
148
+ * the order given (`canvasIdentity`: config `logo`, then `share.logo` - a bare string is a `share.logo`), then the
149
+ * ladder. `warn` hears why one the config names was ignored (the ladder's own entries are tried quietly: most repos
150
+ * have none of them). */
151
+ function findLogo(root, own, warn) {
146
152
  let realRoot;
147
153
  try {
148
154
  realRoot = realpathSync(root);
149
155
  } catch {
150
156
  return null;
151
157
  }
152
- const own = typeof shareLogo === "string" && shareLogo !== "" ? shareLogo : null;
153
- for (const cand of new Set(own ? [own, ...LOGO_LADDER] : LOGO_LADDER)) {
158
+ const named = (typeof own === "string" || own === void 0 ? [{
159
+ key: "share.logo",
160
+ path: own
161
+ }] : own).filter((o) => typeof o.path === "string" && o.path !== "");
162
+ const keyOf = /* @__PURE__ */ new Map();
163
+ for (const o of named) if (!keyOf.has(o.path)) keyOf.set(o.path, o.key);
164
+ for (const cand of /* @__PURE__ */ new Set([...named.map((o) => o.path), ...LOGO_LADDER])) {
154
165
  const r = readLogo(realRoot, resolve(realRoot, cand));
155
166
  if (typeof r !== "string") return {
156
167
  ...r,
157
168
  from: cand
158
169
  };
159
- if (cand === own) warn?.(`share.logo ${own} is ignored: ${r}`);
170
+ const key = keyOf.get(cand);
171
+ if (key) warn?.(`${key} ${cand} is ignored: ${r}`);
160
172
  }
161
173
  return null;
162
174
  }
163
175
  /** One candidate: its bytes and type, or why it does not count. */
164
176
  function readLogo(realRoot, file) {
177
+ const r = readInside(realRoot, file, LOGO_MAX, /\.(svg|png|ico)$/i, "not .svg, .png or .ico", "over 256 KB");
178
+ if (typeof r === "string") return r;
179
+ const type = sniffLogo(r);
180
+ return type ? {
181
+ type,
182
+ bytes: r
183
+ } : "not an image (PNG, ICO or SVG)";
184
+ }
185
+ /**
186
+ * A file inside the repo, read whole - or why not: a regular file by `lstat` (never a symlink, even one inside the
187
+ * repo), its extension `ext`, at most `max` bytes, its real path inside the repo's real path (a symlinked folder on the
188
+ * way out is caught here), and read as checked: no symlink swapped in since (O_NOFOLLOW), the same file (device and
189
+ * inode), never more than one byte past the limit whatever it grew to meanwhile. The logo's checks (spec 28 A2.9), and
190
+ * a device's own icon's (spec 31 F.1).
191
+ */
192
+ function readInside(realRoot, file, max, ext, badExt, tooBig) {
165
193
  let st;
166
194
  try {
167
195
  st = lstatSync(file);
@@ -170,8 +198,8 @@ function readLogo(realRoot, file) {
170
198
  }
171
199
  if (st.isSymbolicLink()) return "a symlink";
172
200
  if (!st.isFile()) return "not a file";
173
- if (!/\.(svg|png|ico)$/i.test(file)) return "not .svg, .png or .ico";
174
- if (st.size > 262144) return "over 256 KB";
201
+ if (!ext.test(file)) return badExt;
202
+ if (st.size > max) return tooBig;
175
203
  let real;
176
204
  try {
177
205
  real = realpathSync(file);
@@ -188,16 +216,11 @@ function readLogo(realRoot, file) {
188
216
  try {
189
217
  const f = fstatSync(fd);
190
218
  if (!f.isFile() || f.ino !== st.ino || f.dev !== st.dev) return "changed while it was read";
191
- const buf = Buffer.alloc(262145);
219
+ const buf = Buffer.alloc(max + 1);
192
220
  let n = 0;
193
221
  for (let k = 1; k > 0 && n < buf.length; n += k) k = readSync(fd, buf, n, buf.length - n, null);
194
- if (n > 262144) return "over 256 KB";
195
- const bytes = Buffer.from(buf.subarray(0, n));
196
- const type = sniffLogo(bytes);
197
- return type ? {
198
- type,
199
- bytes
200
- } : "not an image (PNG, ICO or SVG)";
222
+ if (n > max) return tooBig;
223
+ return Buffer.from(buf.subarray(0, n));
201
224
  } catch {
202
225
  return "unreadable";
203
226
  } finally {
@@ -206,8 +229,8 @@ function readLogo(realRoot, file) {
206
229
  }
207
230
  /** `marver build`: the logo into `<outDir>/__mv/logo.<type>` (an `.ico` as `logo.ico`), by its bytes - never a copy
208
231
  * that follows a link. Its published path, or undefined when the repo has none. */
209
- function publishLogo(root, shareLogo, outDir, warn) {
210
- const logo = findLogo(root, shareLogo, warn);
232
+ function publishLogo(root, own, outDir, warn) {
233
+ const logo = findLogo(root, own, warn);
211
234
  if (!logo) return void 0;
212
235
  const dir = join(outDir, ROUTE.slice(1));
213
236
  mkdirSync(dir, { recursive: true });
@@ -258,7 +281,7 @@ function matches(header, tag) {
258
281
  * SVG opened as a page is a picture. A request carrying a well-formed `x-mv-nonce` gets the logo proof
259
282
  * (`x-mv-instance`, `x-mv-proof` over `logo|<nonce>|<port>`), on a 200 and a 304 alike. 404 when the repo has none.
260
283
  */
261
- function logoRoute(root, shareLogo, proof) {
284
+ function logoRoute(root, own, proof) {
262
285
  const warned = /* @__PURE__ */ new Set();
263
286
  const warn = (m) => {
264
287
  if (warned.has(m)) return;
@@ -278,7 +301,7 @@ function logoRoute(root, shareLogo, proof) {
278
301
  res.setHeader("allow", "GET, HEAD");
279
302
  return res.end();
280
303
  }
281
- const logo = findLogo(root, shareLogo(), warn);
304
+ const logo = findLogo(root, own(), warn);
282
305
  if (!logo) {
283
306
  res.statusCode = 404;
284
307
  res.setHeader("cache-control", "no-store");
@@ -302,4 +325,4 @@ function logoRoute(root, shareLogo, proof) {
302
325
  };
303
326
  }
304
327
  //#endregion
305
- export { appProofOk as a, publishLogo as i, logoIcons as n, proofHeaders as o, logoRoute as r, logoIconLink as t };
328
+ export { publishLogo as a, proofHeaders as c, logoRoute as i, logoIconLink as n, readInside as o, logoIcons as r, appProofOk as s, findLogo as t };
@@ -1,5 +1,5 @@
1
1
  import { r as NAME } from "./cli.mjs";
2
- import { l as readRunning, n as formatRunning } from "./slots-Dn4Onb0V.mjs";
2
+ import { l as readRunning, n as formatRunning } from "./slots-BOcfIqxy.mjs";
3
3
  //#region src/cli/ls.ts
4
4
  /**
5
5
  * `marver ls` (spec 28 A1.5): the canvases running on this Mac, read from the registry
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
2
  import { i as PKG, n as CONTENT_WIDTH } from "./cli.mjs";
3
- import { a as checkBoardsDir, c as listBoardFiles, m as readRegistry, o as checkRealDirs, r as boardFields, 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, a as buildTree, b as DECISIONS, f as isBoardName, g as readTitle, h as readDescription, o as flatten, s as folderEntries } from "./board-tree-BXR8dw4b.mjs";
3
+ import { h as readRegistry, l as listBoardFiles, o as checkBoardsDir, r as boardFields, s as checkRealDirs, x as hash } from "./boards-Cim1GTKc.mjs";
4
+ import { A as resolveType, D as readReason, E as readCapability, O as readStatusWord, S as HAS_STATUS, a as buildTree, b as DECISIONS, f as isBoardName, g as readTitle, h as readDescription, o as flatten, s as folderEntries } from "./board-tree-DGj0HhEE.mjs";
5
5
  import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
6
6
  import { join, relative, sep } from "node:path";
7
7
  import { randomBytes } from "node:crypto";
@@ -789,6 +789,7 @@ var manifest_exports = /* @__PURE__ */ __exportAll({
789
789
  statusBoards: () => statusBoards,
790
790
  tagPattern: () => tagPattern,
791
791
  toFrameId: () => toFrameId,
792
+ unescapeJs: () => unescapeJs,
792
793
  writeManifest: () => writeManifest
793
794
  });
794
795
  const FRAME_EXT = /\.(tsx|jsx|html)$/;
@@ -810,19 +811,230 @@ function readNote(abs) {
810
811
  return;
811
812
  }
812
813
  }
813
- /** Extract `export const meta = {...}` with literal string values only. Anything else is silently omitted. */
814
- function extractMeta(src) {
814
+ /** A JS string literal's escapes, read: a backslash before a quote, a backtick or a backslash; \n \t \r; \xHH,
815
+ * \uHHHH, \u{H...}; any other escaped character is itself (\$ is $). */
816
+ function unescapeJs(s) {
817
+ return s.replace(/\\(u\{([0-9a-fA-F]{1,6})\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|[\s\S])/g, (_m, e, cp, u, x) => {
818
+ const hex = cp ?? u ?? x;
819
+ if (hex) {
820
+ const n = parseInt(hex, 16);
821
+ return n <= 1114111 ? String.fromCodePoint(n) : "";
822
+ }
823
+ return e === "n" ? "\n" : e === "t" ? " " : e === "r" ? "\r" : e === "b" ? "\b" : e === "f" ? "\f" : e === "v" ? "\v" : e === "0" ? "\0" : e === "\n" ? "" : e;
824
+ });
825
+ }
826
+ /** Can a `/` here start a regex literal? After a value it divides: a literal, a name (a keyword after `.` is a
827
+ * property's name: `values.in / 2`), `]`, `}`, a postfix `++`/`--` (`count++ / 2`), a `)` - unless that `)` closes
828
+ * an `if`/`while`/`for`/`with` condition (`if (ready) /'/.test(t)`). After an operator or a keyword it starts one. */
829
+ const REGEX_AFTER_WORD = /* @__PURE__ */ new Set([
830
+ "return",
831
+ "typeof",
832
+ "instanceof",
833
+ "in",
834
+ "of",
835
+ "new",
836
+ "delete",
837
+ "void",
838
+ "throw",
839
+ "case",
840
+ "do",
841
+ "else",
842
+ "yield",
843
+ "await"
844
+ ]);
845
+ const CONTROL = /* @__PURE__ */ new Set([
846
+ "if",
847
+ "while",
848
+ "for",
849
+ "with"
850
+ ]);
851
+ const regexCan = (prev) => !prev || prev.k === "punct" && (prev.v === ")" ? !!prev.ctrl : ![
852
+ "]",
853
+ "}",
854
+ "++",
855
+ "--"
856
+ ].includes(prev.v)) || prev.k === "word" && !prev.prop && REGEX_AFTER_WORD.has(prev.v);
857
+ /**
858
+ * The JS tokens from `i` to the `}` that closes an already-open `{` (spec 31 H.1, review rounds 1-3): strings, template
859
+ * literals (their `${...}` holes tokenized as code of their own), regex literals and comments are read whole, so a
860
+ * brace, a quote or a slash inside one is text. `emit` hears each token at this object's own level (depth 0) and the
861
+ * `}` that ends it; the index of that `}`, or -1 when the code never closes or a literal is unterminated.
862
+ */
863
+ function tokens(src, i, emit) {
864
+ let depth = 0;
865
+ let prev;
866
+ /** each open `(`: whether it opens a control statement's condition */
867
+ const parens = [];
868
+ const out = (t) => {
869
+ prev = t;
870
+ if (emit) emit(t, depth);
871
+ };
872
+ while (i < src.length) {
873
+ const ch = src[i];
874
+ if (/\s/.test(ch)) {
875
+ i++;
876
+ continue;
877
+ }
878
+ if (ch === "/" && src[i + 1] === "/") {
879
+ const nl = src.indexOf("\n", i);
880
+ i = nl < 0 ? src.length : nl;
881
+ continue;
882
+ }
883
+ if (ch === "/" && src[i + 1] === "*") {
884
+ const e = src.indexOf("*/", i + 2);
885
+ if (e < 0) return -1;
886
+ i = e + 2;
887
+ continue;
888
+ }
889
+ if (ch === "'" || ch === "\"") {
890
+ let j = i + 1;
891
+ for (; j < src.length && src[j] !== ch; j++) {
892
+ if (src[j] === "\n") return -1;
893
+ if (src[j] === "\\") j++;
894
+ }
895
+ if (j >= src.length) return -1;
896
+ out({
897
+ k: "str",
898
+ raw: src.slice(i + 1, j)
899
+ });
900
+ i = j + 1;
901
+ continue;
902
+ }
903
+ if (ch === "`") {
904
+ let j = i + 1, holes = false;
905
+ for (; j < src.length && src[j] !== "`"; j++) if (src[j] === "\\") j++;
906
+ else if (src[j] === "$" && src[j + 1] === "{") {
907
+ holes = true;
908
+ j = tokens(src, j + 2);
909
+ if (j < 0) return -1;
910
+ }
911
+ if (j >= src.length) return -1;
912
+ out({
913
+ k: "tpl",
914
+ raw: src.slice(i + 1, j),
915
+ holes
916
+ });
917
+ i = j + 1;
918
+ continue;
919
+ }
920
+ if (ch === "/" && regexCan(prev)) {
921
+ let j = i + 1, cls = false;
922
+ for (; j < src.length; j++) {
923
+ const c = src[j];
924
+ if (c === "\n") return -1;
925
+ if (c === "\\") {
926
+ j++;
927
+ continue;
928
+ }
929
+ if (cls) {
930
+ if (c === "]") cls = false;
931
+ } else if (c === "[") cls = true;
932
+ else if (c === "/") break;
933
+ }
934
+ if (j >= src.length) return -1;
935
+ j++;
936
+ while (j < src.length && /[A-Za-z]/.test(src[j])) j++;
937
+ out({ k: "re" });
938
+ i = j;
939
+ continue;
940
+ }
941
+ const w = /^(?:[\p{ID_Start}_$][\p{ID_Continue}$\u200c\u200d]*|\d[\w.]*)/u.exec(src.slice(i, i + 256));
942
+ if (w) {
943
+ out({
944
+ k: "word",
945
+ v: w[0],
946
+ prop: prev?.k === "punct" && (prev.v === "." || prev.v === "?.")
947
+ });
948
+ i += w[0].length;
949
+ continue;
950
+ }
951
+ if (ch === "}" && depth === 0) {
952
+ if (emit) emit({
953
+ k: "punct",
954
+ v: "}"
955
+ }, 0);
956
+ return i;
957
+ }
958
+ if (ch === "(") {
959
+ parens.push(prev?.k === "word" && !prev.prop && CONTROL.has(prev.v));
960
+ out({
961
+ k: "punct",
962
+ v: ch
963
+ });
964
+ depth++;
965
+ i++;
966
+ continue;
967
+ }
968
+ if (ch === "{" || ch === "[") {
969
+ out({
970
+ k: "punct",
971
+ v: ch
972
+ });
973
+ depth++;
974
+ i++;
975
+ continue;
976
+ }
977
+ if (ch === ")") {
978
+ depth--;
979
+ out({
980
+ k: "punct",
981
+ v: ch,
982
+ ctrl: parens.pop() === true
983
+ });
984
+ i++;
985
+ continue;
986
+ }
987
+ if (ch === "}" || ch === "]") {
988
+ depth--;
989
+ out({
990
+ k: "punct",
991
+ v: ch
992
+ });
993
+ i++;
994
+ continue;
995
+ }
996
+ const op = /^(?:\+\+|--|\?\.(?!\d)|=>|\.\.\.)/.exec(src.slice(i, i + 3));
997
+ if (op) {
998
+ out({
999
+ k: "punct",
1000
+ v: op[0]
1001
+ });
1002
+ i += op[0].length;
1003
+ continue;
1004
+ }
1005
+ out({
1006
+ k: "punct",
1007
+ v: ch
1008
+ });
1009
+ i++;
1010
+ }
1011
+ return -1;
1012
+ }
1013
+ /** The lenient reading, for a meta the tokenizer cannot follow: r31's - the body to its first `}`, each key's literal
1014
+ * found where a property starts - with its quotes read escape-aware (spec 31 H.1). Never worse than r31 was. */
1015
+ function lenientMeta(src) {
815
1016
  const m = /export\s+const\s+meta\s*=\s*\{([\s\S]*?)\}/.exec(src);
816
1017
  if (!m) return {};
817
1018
  const body = m[1];
818
- const pick = (key) => {
819
- const r = new RegExp(`(?:^|[{,])\\s*${key}\\s*:\\s*(?:'([^'\\n]*)'|"([^"\\n]*)"|\`([^\`\\n]*)\`)\\s*(?=[,}\\n]|$)`).exec(body);
820
- return r ? r[1] ?? r[2] ?? r[3] : void 0;
821
- };
822
- const pickBool = (key) => {
823
- const r = new RegExp(`(?:^|[{,])\\s*${key}\\s*:\\s*(true|false)\\b`).exec(body);
824
- return r ? r[1] === "true" : void 0;
825
- };
1019
+ const strings = /* @__PURE__ */ new Map();
1020
+ for (const key of [
1021
+ "title",
1022
+ "viewport",
1023
+ "theme",
1024
+ "of",
1025
+ "variant",
1026
+ "intent",
1027
+ "description"
1028
+ ]) {
1029
+ const r = new RegExp(`(?:^|[{,])\\s*${key}\\s*:\\s*(?:'((?:[^'\\\\\\n]|\\\\.)*)'|"((?:[^"\\\\\\n]|\\\\.)*)"|\`((?:[^\`\\\\\\n]|\\\\.)*)\`)\\s*(?=[,}\\n]|$)`).exec(body);
1030
+ if (r && !(r[3] !== void 0 && /(^|[^\\])(\\\\)*\$\{/.test(r[3]))) strings.set(key, unescapeJs(r[1] ?? r[2] ?? r[3]));
1031
+ }
1032
+ const b = /(?:^|[{,])\s*slide\s*:\s*(true|false)\b/.exec(body);
1033
+ return metaOf(strings, new Map(b ? [["slide", b[1] === "true"]] : []));
1034
+ }
1035
+ /** The meta from its literal properties. */
1036
+ function metaOf(strings, bools) {
1037
+ const pick = (key) => strings.get(key);
826
1038
  const out = {};
827
1039
  const title = pick("title");
828
1040
  if (title) out.title = title;
@@ -836,12 +1048,42 @@ function extractMeta(src) {
836
1048
  if (variant) out.variant = variant;
837
1049
  const intent = pick("intent");
838
1050
  if (intent) out.intent = intent;
839
- const slide = pickBool("slide");
1051
+ const slide = bools.get("slide");
840
1052
  if (slide !== void 0) out.slide = slide;
841
1053
  const description = readDescription(pick("description"));
842
1054
  if (description) out.description = description;
843
1055
  return out;
844
1056
  }
1057
+ /** Extract `export const meta = {...}` with literal string values only. Anything else is silently omitted.
1058
+ * Only the object's own top-level properties count, each value a lone literal: `title: "Draft" + phase` is computed,
1059
+ * a template with a `${...}` too, and words inside a string (`"... slide: true ..."`) are only words. */
1060
+ function extractMeta(src) {
1061
+ const m = /export\s+const\s+meta\s*=\s*\{/.exec(src);
1062
+ if (!m) return {};
1063
+ const props = [[]];
1064
+ if (tokens(src, m.index + m[0].length, (t, depth) => {
1065
+ if (depth > 0) {
1066
+ props[props.length - 1].push({
1067
+ k: "punct",
1068
+ v: "nested"
1069
+ });
1070
+ return;
1071
+ }
1072
+ if (t.k === "punct" && t.v === ",") props.push([]);
1073
+ else if (!(t.k === "punct" && t.v === "}")) props[props.length - 1].push(t);
1074
+ }) < 0) return lenientMeta(src);
1075
+ const strings = /* @__PURE__ */ new Map();
1076
+ const bools = /* @__PURE__ */ new Map();
1077
+ for (const p of props) {
1078
+ if (p.length !== 3 || p[1].k !== "punct" || p[1].v !== ":") continue;
1079
+ const [k, , v] = p;
1080
+ const key = k.k === "word" ? k.v : k.k === "str" ? unescapeJs(k.raw) : null;
1081
+ if (key === null) continue;
1082
+ if (v.k === "str" || v.k === "tpl" && !v.holes) strings.set(key, unescapeJs(v.raw));
1083
+ else if (v.k === "word" && (v.v === "true" || v.v === "false")) bools.set(key, v.v === "true");
1084
+ }
1085
+ return metaOf(strings, bools);
1086
+ }
845
1087
  /** Content-frame detection: LEXICAL by convention - the frame file itself imports
846
1088
  * PKG/content (an import specifier scan, so "<Diagram" inside a string in a UI frame can
847
1089
  * never misbadge it; barrels/re-exports are not detected - meta.intent is the taught path
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
- import { a as checkBoardsDir, c as listBoardFiles, o as checkRealDirs, y as hash } from "./boards-EH2onUXM.mjs";
3
- import { l as framesOn } from "./board-tree-BXR8dw4b.mjs";
4
- import { a as noteFileFor } from "./manifest-DPZ3WNg_.mjs";
2
+ import { l as listBoardFiles, o as checkBoardsDir, s as checkRealDirs, x as hash } from "./boards-Cim1GTKc.mjs";
3
+ import { l as framesOn } from "./board-tree-DGj0HhEE.mjs";
4
+ import { a as noteFileFor } from "./manifest-CK8Qh4Nq.mjs";
5
5
  import { t as imports } from "./imports-WBSnnHLb.mjs";
6
6
  import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
7
7
  import { dirname, join, relative, sep } from "node:path";