@marver-design/marver 0.24.0 → 0.25.1

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 (80) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +1 -1
  3. package/dist/anchor-DVV732zR.mjs +33 -0
  4. package/dist/anchor-check-DGZnYviN.mjs +135 -0
  5. package/dist/{bake-ZhXq-X9f.mjs → bake-BpxMZfij.mjs} +45 -6
  6. package/dist/{boards-BRLnoTC3.mjs → board-tree-DRioF94d.mjs} +21 -277
  7. package/dist/boards-CGg6piKF.mjs +342 -0
  8. package/dist/{boards-Dv-Ipd8G.mjs → boards-Csxj2WJn.mjs} +23 -9
  9. package/dist/{build-ckcinlWH.mjs → build-DKaGhoVN.mjs} +63 -37
  10. package/dist/cli.mjs +31 -17
  11. package/dist/{collab-mAiNZlDj.mjs → collab-gqNdScUE.mjs} +39 -9
  12. package/dist/{comments-DZyobpxG.mjs → comments-Zoch254k.mjs} +19 -1
  13. package/dist/{comments-Dx1hCVOT.mjs → comments-pTLlhjh4.mjs} +150 -20
  14. package/dist/{config-BUKprFAp.mjs → config-cKgZBRj0.mjs} +1 -1
  15. package/dist/{context-BncTXjLB.mjs → context-D2ugHqwO.mjs} +17 -123
  16. package/dist/{daemon-CQv73-jM.mjs → daemon-Cl8KXGW4.mjs} +146 -64
  17. package/dist/{dev-gv4NS6Fk.mjs → dev-Diqx1Rt8.mjs} +23 -11
  18. package/dist/{events-B3LBn74P.mjs → events-DnK_AnrW.mjs} +13 -15
  19. package/dist/imports-WBSnnHLb.mjs +143 -0
  20. package/dist/{init--3Moc4J7.mjs → init-DO4DhUt_.mjs} +28 -6
  21. package/dist/link-C-qUIuKU.mjs +160 -0
  22. package/dist/{board-status-BZSzc9Hp.mjs → manifest-DnAte_fB.mjs} +537 -13
  23. package/dist/marks-DFuintmJ.mjs +50 -0
  24. package/dist/marks-koRsbHfe.mjs +397 -0
  25. package/dist/{marver-id-gate-B_idGdHm.mjs → marver-id-gate-DGANtVyC.mjs} +2 -2
  26. package/dist/perf-CCisg-ny.mjs +49 -0
  27. package/dist/perf-QJIWtTw1.mjs +68 -0
  28. package/dist/{plugin-Sa08E7wO.mjs → plugin-dTF5reck.mjs} +425 -207
  29. package/dist/{poster-B2QPvKOq.mjs → poster-D-zjYpgk.mjs} +1 -1
  30. package/dist/{profile-CrZohD6g.mjs → profile-Do0nGkXO.mjs} +1 -1
  31. package/dist/{publish-bakes-BJR3huhu.mjs → publish-bakes-C_9VZ-Mq.mjs} +9 -9
  32. package/dist/{serve-z5qtj_wJ.mjs → serve-wv2QWdxB.mjs} +6 -6
  33. package/dist/{share-BD-wcDQq.mjs → share-ScamJcks.mjs} +1 -1
  34. package/dist/{shot-Cw96h5Kk.mjs → shot-CUlmkqFX.mjs} +19 -11
  35. package/dist/{shot-Dh6fV1Lm.mjs → shot-jdO_B6Qw.mjs} +1 -1
  36. package/dist/{summary-C7CAypbB.mjs → summary-CrW88e3q.mjs} +1 -1
  37. package/dist/{sync-DoA1vf4u.mjs → sync-C3035OnJ.mjs} +18 -8
  38. package/dist/{work-CBUfsOOT.mjs → work-CpJn1gwY.mjs} +8 -4
  39. package/dist/{work-ayuL_9Kk.mjs → work-GE88wb_3.mjs} +4 -4
  40. package/docs/boards-and-folders.md +62 -21
  41. package/docs/live-jam.md +10 -5
  42. package/package.json +1 -1
  43. package/src/client/frame-host/bridge.js +2 -1
  44. package/src/client/frame-host/inspect.js +195 -84
  45. package/src/client/frame-host/main.tsx +7 -2
  46. package/src/client/frame-host/registry.ts +5 -5
  47. package/src/client/shell/App.tsx +66 -22
  48. package/src/client/shell/BoardList.tsx +54 -11
  49. package/src/client/shell/Comments.tsx +79 -34
  50. package/src/client/shell/ContextMenu.tsx +5 -2
  51. package/src/client/shell/LockedApp.tsx +45 -12
  52. package/src/client/shell/Play.tsx +35 -34
  53. package/src/client/shell/Toolbar.tsx +3 -1
  54. package/src/client/shell/canvas/Canvas.tsx +1 -1
  55. package/src/client/shell/canvas/FrameNode.tsx +10 -5
  56. package/src/client/shell/canvas/sleep.ts +23 -4
  57. package/src/client/shell/canvas/updates.ts +55 -0
  58. package/src/client/shell/comments-store.ts +48 -19
  59. package/src/client/shell/goto.ts +11 -14
  60. package/src/client/shell/hash.ts +12 -5
  61. package/src/client/shell/icons.tsx +1 -2
  62. package/src/client/shell/legacy-links.ts +67 -0
  63. package/src/client/shell/marks-ui.tsx +17 -19
  64. package/src/client/shell/pin-layout.ts +37 -0
  65. package/src/client/shell/store.ts +312 -92
  66. package/src/client/shell/styles.css +10 -8
  67. package/src/client/stage/main.tsx +19 -2
  68. package/src/shared/anchor.ts +57 -0
  69. package/src/shared/board-tree.ts +27 -10
  70. package/src/shared/events.ts +19 -10
  71. package/src/shared/marks.ts +17 -12
  72. package/templates/AGENTS-embedded.md +34 -15
  73. package/templates/AGENTS-studio.md +34 -15
  74. package/templates/instructions/boards.md +9 -5
  75. package/templates/instructions/iterate.md +20 -10
  76. package/templates/instructions/jam.md +13 -4
  77. package/templates/instructions/publish.md +2 -1
  78. package/templates/instructions/reference/deck-story.md +2 -2
  79. package/dist/link-vXjxMHTG.mjs +0 -132
  80. package/dist/manifest-cyG3kbhk.mjs +0 -528
@@ -19,6 +19,10 @@
19
19
  //
20
20
  // shell -> frame : sh:laser · sh:pick · sh:copy-ok · sh:resolve-anchors · sh:highlight-anchor
21
21
  // frame -> shell : sh:frame-down · sh:picked · sh:laser-copy · sh:anchor-rects
22
+ //
23
+ // Anchors (spec 26): only VISIBLE elements ever match, a pin attaches at the end of its element's
24
+ // first rendered line (a person's pin: where they clicked), and `window.__mvAnchorCheck` is the
25
+ // dev server's door - it loads the frame headless and asks which element a CLI target names.
22
26
 
23
27
  // comment-mode cursor: the pin's teardrop in the comment green, duotone (dark rim,
24
28
  // lighter inner) with a white halo ring so it pops on any content; hotspot at the tail
@@ -50,6 +54,195 @@ const DEPTH_HUE = (() => {
50
54
  return r
51
55
  })()
52
56
 
57
+ const norm = (t) => (t ?? '').replace(/\s+/g, ' ').trim()
58
+
59
+ /** Rendered and not hidden: a display:none subtree has no boxes, a visibility:hidden or
60
+ * transparent one fails checkVisibility. A hidden duplicate is never an anchor's element. */
61
+ const shown = (el) => el.getClientRects().length > 0 &&
62
+ (el.checkVisibility?.({ visibilityProperty: true, opacityProperty: true }) ?? true)
63
+ /** Rendered but perhaps transparent - a control that shows on hover, a frame mid-fade-in. Second choice:
64
+ * matched only when nothing visible does, so such a pin is never orphaned nor such a target refused. */
65
+ const rendered = (el) => el.getClientRects().length > 0 && (el.checkVisibility?.({ visibilityProperty: true }) ?? true)
66
+ let visible = shown
67
+ let transparentOnly = false // the last `matching` found only rendered-but-transparent elements
68
+ const matching = (find) => {
69
+ transparentOnly = false
70
+ const first = find()
71
+ if (first.length) return first
72
+ visible = rendered
73
+ try { const second = find(); transparentOnly = second.length > 0; return second } finally { visible = shown }
74
+ }
75
+ /** A box too small to read - a screen-reader-only label - is not text a person sees. */
76
+ const tiny = (el) => { const r = el.getBoundingClientRect(); return r.width < 2 || r.height < 2 }
77
+
78
+ const cssPath = (el) => {
79
+ const seg = []
80
+ for (let cur = el; cur && cur !== document.body; cur = cur.parentElement) {
81
+ if (cur.id) { seg.unshift(`#${CSS.escape(cur.id)}`); break }
82
+ const tag = cur.tagName.toLowerCase()
83
+ let n = 1
84
+ for (let sib = cur.previousElementSibling; sib; sib = sib.previousElementSibling)
85
+ if (sib.tagName === cur.tagName) n++
86
+ seg.unshift(n > 1 ? `${tag}:nth-of-type(${n})` : tag)
87
+ }
88
+ return seg.join(' > ')
89
+ }
90
+ // the element's live depth hue (0..300) - so the shell can tint the pin / composer /
91
+ // thread card in the same colour the element wears in laser, and keep it after a reload
92
+ const hueOf = (el) => {
93
+ const raw = getComputedStyle(el).getPropertyValue('--mv-hue').trim() // set by the mode sheet
94
+ const n = raw === '' ? NaN : Number(raw)
95
+ return Number.isFinite(n) ? ((n % 360) + 360) % 360 : 210 // fallback: a calm blue
96
+ }
97
+ /** The element half of every anchor - a click's and a checked CLI target's alike (one format). */
98
+ const elBundle = (el) => {
99
+ const text = norm(el.textContent)
100
+ return {
101
+ el: {
102
+ semantics: {
103
+ tag: el.tagName.toLowerCase(),
104
+ role: el.getAttribute('role') ?? undefined,
105
+ ariaLabel: el.getAttribute('aria-label') ?? undefined,
106
+ testId: el.getAttribute('data-testid') ?? undefined,
107
+ quote: text.slice(0, 200) || undefined,
108
+ },
109
+ cssPath: cssPath(el),
110
+ source: el.dataset.mvLoc ?? undefined,
111
+ hue: hueOf(el),
112
+ },
113
+ }
114
+ }
115
+
116
+ const SKIP = 'script,style,noscript,template'
117
+ /** The visible elements showing these words (case and spacing aside): the innermost element
118
+ * whose SEEN text holds them - only text whose own element is shown, with a line break or a block
119
+ * between words read as a space - so "Pay <b>now</b>" is its paragraph, "Welcome<br>back" reads
120
+ * "Welcome back", words split by a hidden run still read as one, and a hidden or transparent copy
121
+ * never stands in for words nobody sees - once per place they appear. */
122
+ const byWords = (words) => {
123
+ const q = norm(words).toLowerCase()
124
+ if (!q) return []
125
+ const seen = new Map() // element -> its seen text, each element measured once
126
+ const seenText = (el) => {
127
+ if (seen.has(el)) return seen.get(el)
128
+ let t = ''
129
+ if (!el.matches(SKIP)) {
130
+ const on = visible(el) && !tiny(el)
131
+ for (const n of el.childNodes) {
132
+ if (n.nodeType === 3) t += on ? n.data : ''
133
+ else if (n.nodeType === 1) t += n.tagName === 'BR' ? ' ' : getComputedStyle(n).display.startsWith('inline') ? seenText(n) : ` ${seenText(n)} `
134
+ }
135
+ }
136
+ seen.set(el, t)
137
+ return t
138
+ }
139
+ const has = (el) => norm(seenText(el)).toLowerCase().includes(q)
140
+ const walk = (el) => {
141
+ const inner = [...el.children].filter(has).flatMap(walk)
142
+ return inner.length || el === document.body ? inner : [el]
143
+ }
144
+ return document.body && has(document.body) ? walk(document.body) : []
145
+ }
146
+ /** `--at`: its exact data-testid first, else a CSS selector (throws on one that is neither). */
147
+ const byAt = (at) => {
148
+ const all = (sel) => [...document.querySelectorAll(sel)].filter((el) => visible(el))
149
+ const ids = all(`[data-testid="${CSS.escape(at)}"]`)
150
+ return ids.length ? ids : all(at)
151
+ }
152
+
153
+ /** Does this element still fit what an anchor says about it? */
154
+ const fits = (el, want) => {
155
+ if (want.tag && el.tagName.toLowerCase() !== want.tag) return false
156
+ if (want.role && el.getAttribute('role') !== want.role) return false
157
+ if (want.ariaLabel && el.getAttribute('aria-label') !== want.ariaLabel) return false
158
+ if (want.testId && el.getAttribute('data-testid') !== want.testId) return false
159
+ const text = norm(el.textContent)
160
+ if (want.quote && !(text.startsWith(want.quote.slice(0, 60)) || text.includes(want.quote.slice(0, 40)))) return false
161
+ return true
162
+ }
163
+ /** Every visible element an anchor can mean, in document order: by its test id, tag or selector,
164
+ * filtered by its semantics - or, for an agent's words-only anchor, the elements showing them. */
165
+ const anchorMatches = (anchor) => {
166
+ const a = anchor?.el ?? {}
167
+ const want = a.semantics ?? {}
168
+ if (want.quote && !want.tag && !a.cssPath) return byWords(want.quote)
169
+ if (a.at) { try { return byAt(a.at) } catch { return [] } }
170
+ const tag = typeof want.tag === 'string' && /^[a-z][a-z0-9-]*$/.test(want.tag) ? want.tag : null
171
+ const pool = want.testId ? `[data-testid="${CSS.escape(want.testId)}"]` : tag && (want.quote || !a.cssPath) ? tag : a.cssPath
172
+ if (!pool) return []
173
+ try { return [...document.querySelectorAll(pool)].filter((el) => fits(el, want) && visible(el)) } catch { return [] }
174
+ }
175
+ /** A captured bundle's exact path wins while it still fits; otherwise the `nth` of its matches. */
176
+ const resolveAnchor = (anchor) => {
177
+ const a = anchor?.el ?? {}
178
+ if (a.semantics?.tag && a.cssPath) {
179
+ try {
180
+ const exact = document.querySelector(a.cssPath)
181
+ if (exact && fits(exact, a.semantics) && rendered(exact)) return exact // a person's click: there, even transparent now
182
+ } catch { /* stale selector */ }
183
+ }
184
+ return matching(() => anchorMatches(anchor))[(a.nth ?? 1) - 1] ?? null
185
+ }
186
+
187
+ /** Where a pin attaches, in this document's viewport px. A person's pin: the point they clicked.
188
+ * Otherwise the end of the element's first rendered line - a text range over its text, so a
189
+ * heading, a paragraph and a bold run wrapped over two lines all take their first line's end -
190
+ * and for an element with no text, its top-right corner. */
191
+ const attachPoint = (el, anchor) => {
192
+ const r = el.getBoundingClientRect()
193
+ const pos = anchor?.pos
194
+ if (pos && anchor?.el?.cssPath && Number.isFinite(pos.fx) && Number.isFinite(pos.fy))
195
+ return { x: r.left + pos.fx * r.width, y: r.top + pos.fy * r.height }
196
+ const range = document.createRange()
197
+ const walk = document.createTreeWalker(el, NodeFilter.SHOW_TEXT)
198
+ let line = null
199
+ for (let n = walk.nextNode(), i = 0; n && i < 400; n = walk.nextNode(), i++) {
200
+ if (!n.data.trim() || !n.parentElement || n.parentElement.closest(SKIP) || !visible(n.parentElement) || tiny(n.parentElement)) continue
201
+ range.selectNodeContents(n)
202
+ for (const q of range.getClientRects()) {
203
+ if (!q.width || !q.height) continue
204
+ if (!line) { line = { top: q.top, bottom: q.bottom, right: q.right }; continue }
205
+ if ((q.top + q.bottom) / 2 > line.bottom) return { x: line.right, y: (line.top + line.bottom) / 2 } // the second line
206
+ line.right = Math.max(line.right, q.right)
207
+ }
208
+ }
209
+ return line ? { x: line.right, y: (line.top + line.bottom) / 2 } : { x: r.right, y: r.top }
210
+ }
211
+
212
+ /** The headings, labels and buttons a frame shows - what to suggest when words match nothing. */
213
+ const landmarks = () => {
214
+ const seen = new Set()
215
+ for (const el of document.querySelectorAll('h1,h2,h3,h4,h5,h6,label,button,[role=button],a,legend,th')) {
216
+ const t = norm(el.textContent).slice(0, 60)
217
+ if (t && shown(el)) seen.add(t)
218
+ if (seen.size >= 30) break
219
+ }
220
+ return [...seen]
221
+ }
222
+ const describeEl = (el) => `${el.tagName.toLowerCase()} "${norm(el.textContent).slice(0, 50)}"`
223
+
224
+ /** The dev server's anchor check (server/anchor-check.ts): which visible element does an agent's
225
+ * target name? Refuses only on evidence - none, or several without `nth` - and for the one it
226
+ * finds returns the full bundle (exact on the canvas), plus the open threads already on it. */
227
+ const checkTarget = ({ on, at, nth } = {}, others = []) => {
228
+ let found = []
229
+ if (on) found = matching(() => byWords(on))
230
+ else if (at) { try { found = matching(() => byAt(at)) } catch { return { bad: `"${at}" is neither a data-testid nor a CSS selector` } } }
231
+ if (!found.length) return { none: landmarks() }
232
+ // only a transparent element shows it right now (a fade-in still running, a control that shows on
233
+ // hover): no evidence either way - the note is written unchecked, never refused
234
+ if (transparentOnly) return { transparent: true }
235
+ const el = found.length === 1 && !nth ? found[0] : nth ? found[nth - 1] : null
236
+ if (!el) return { several: found.slice(0, 20).map(describeEl) }
237
+ const anchor = elBundle(el)
238
+ // the fallback scan (a stale path) must land on this one of several look-alikes too
239
+ const i = matching(() => anchorMatches({ el: { ...anchor.el, cssPath: undefined } })).indexOf(el)
240
+ if (i > 0) anchor.el.nth = i + 1
241
+ const holders = others.filter((o) => { try { return resolveAnchor(o.anchor) === el } catch { return false } }).map((o) => o.key)
242
+ return { anchor, holders }
243
+ }
244
+ if (typeof window !== 'undefined') window.__mvAnchorCheck = checkTarget
245
+
53
246
  export function createInspect({ post, getId, onModeChange }) {
54
247
  let laserOn = false, pickOn = false
55
248
  // quiet pick (⇧L laser comment off): clicks still anchor comments, but NO hover outline,
@@ -200,41 +393,10 @@ body [data-mv-hover] { outline: 2px solid hsl(var(--mv-hue) 95% 45%); outline-of
200
393
  place(labelEl, e)
201
394
  }, true)
202
395
 
203
- const cssPath = (el) => {
204
- const seg = []
205
- for (let cur = el; cur && cur !== document.body; cur = cur.parentElement) {
206
- if (cur.id) { seg.unshift(`#${CSS.escape(cur.id)}`); break }
207
- const tag = cur.tagName.toLowerCase()
208
- let n = 1
209
- for (let sib = cur.previousElementSibling; sib; sib = sib.previousElementSibling)
210
- if (sib.tagName === cur.tagName) n++
211
- seg.unshift(n > 1 ? `${tag}:nth-of-type(${n})` : tag)
212
- }
213
- return seg.join(' > ')
214
- }
215
- // the element's live depth hue (0..300) - so the shell can tint the pin / composer /
216
- // thread card in the same colour the element wears in laser, and keep it after a reload
217
- const hueOf = (el) => {
218
- const raw = getComputedStyle(el).getPropertyValue('--mv-hue').trim() // set by the mode sheet
219
- const n = raw === '' ? NaN : Number(raw)
220
- return Number.isFinite(n) ? ((n % 360) + 360) % 360 : 210 // fallback: a calm blue
221
- }
222
396
  const anchorBundle = (el, e) => {
223
397
  const r = el.getBoundingClientRect()
224
- const text = (el.textContent ?? '').trim().replace(/\s+/g, ' ')
225
398
  return {
226
- el: {
227
- semantics: {
228
- tag: el.tagName.toLowerCase(),
229
- role: el.getAttribute('role') ?? undefined,
230
- ariaLabel: el.getAttribute('aria-label') ?? undefined,
231
- testId: el.getAttribute('data-testid') ?? undefined,
232
- quote: text.slice(0, 200) || undefined,
233
- },
234
- cssPath: cssPath(el),
235
- source: el.dataset.mvLoc ?? undefined,
236
- hue: hueOf(el),
237
- },
399
+ ...elBundle(el),
238
400
  pos: {
239
401
  fx: r.width ? Math.min(1, Math.max(0, (e.clientX - r.left) / r.width)) : .5,
240
402
  fy: r.height ? Math.min(1, Math.max(0, (e.clientY - r.top) / r.height)) : .5,
@@ -266,57 +428,6 @@ body [data-mv-hover] { outline: 2px solid hsl(var(--mv-hue) 95% 45%); outline-of
266
428
  }
267
429
  }, true)
268
430
 
269
- const resolveAnchor = (anchor) => {
270
- const want = anchor?.el?.semantics ?? {}
271
- const match = (el) => {
272
- if (want.tag && el.tagName.toLowerCase() !== want.tag) return false
273
- if (want.role && el.getAttribute('role') !== want.role) return false
274
- if (want.ariaLabel && el.getAttribute('aria-label') !== want.ariaLabel) return false
275
- if (want.testId && el.getAttribute('data-testid') !== want.testId) return false
276
- const text = (el.textContent ?? '').trim().replace(/\s+/g, ' ')
277
- if (want.quote && !(text.startsWith(want.quote.slice(0, 60)) || text.includes(want.quote.slice(0, 40)))) return false
278
- return true
279
- }
280
- try {
281
- const byPath = anchor?.el?.cssPath && document.querySelector(anchor.el.cssPath)
282
- if (byPath && match(byPath)) return byPath
283
- } catch { /* stale selector */ }
284
- try {
285
- if (want.testId) {
286
- const el = document.querySelector(`[data-testid="${CSS.escape(want.testId)}"]`)
287
- if (el && match(el)) return el
288
- }
289
- if (want.quote && typeof want.tag === 'string' && /^[a-z][a-z0-9-]*$/.test(want.tag)) {
290
- for (const el of document.querySelectorAll(want.tag))
291
- if (match(el)) return el
292
- }
293
- // an anchor an agent wrote (`comments new --on "<text>"`) names the words alone: the
294
- // innermost element showing them
295
- if (want.quote && !want.tag && !anchor?.el?.cssPath) return byWords(want.quote)
296
- } catch { /* malformed semantics must not sink the whole batch */ }
297
- return null
298
- }
299
-
300
- const norm = (t) => (t ?? '').replace(/\s+/g, ' ').trim()
301
- const byWords = (quote) => {
302
- const q = norm(quote).slice(0, 80).toLowerCase()
303
- if (!q) return null
304
- // one text node holding the words: its element (the common case, and cheap)
305
- const walk = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT)
306
- for (let n = walk.nextNode(); n; n = walk.nextNode()) {
307
- const host = n.parentElement
308
- if (!host || host.closest('script,style,noscript,template')) continue
309
- if (norm(n.data).toLowerCase().includes(q)) return host
310
- }
311
- // words split across inline elements ("Pay <b>now</b>"): walk down from the body to the
312
- // innermost element whose text still holds them (the first occurrence)
313
- const holds = (el) => !el.matches('script,style,noscript,template') && norm(el.textContent).toLowerCase().includes(q)
314
- let el = document.body
315
- if (!holds(el)) return null
316
- for (let next = [...el.children].find(holds); next; next = [...el.children].find(holds)) el = next
317
- return el
318
- }
319
-
320
431
  // re-resolve + re-apply the shell-driven highlight. Called on set and on every
321
432
  // resolve-anchors pass, so a stage frame swapped in AFTER the highlight arrived
322
433
  // (the DOM had not committed yet) still lights up on the next cycle - and, just as
@@ -359,7 +470,7 @@ body [data-mv-hover] { outline: 2px solid hsl(var(--mv-hue) 95% 45%); outline-of
359
470
  try { el = resolveAnchor(a.anchor) } catch { /* one bad anchor, not the batch */ }
360
471
  if (!el) return { key: a.key, orphan: true }
361
472
  const r = el.getBoundingClientRect()
362
- return { key: a.key, rect: { x: r.left, y: r.top, w: r.width, h: r.height } }
473
+ return { key: a.key, rect: { x: r.left, y: r.top, w: r.width, h: r.height }, point: attachPoint(el, a.anchor) }
363
474
  })
364
475
  reapplyHighlight()
365
476
  post({ type: 'sh:anchor-rects', id: getId(), rects })
@@ -100,7 +100,7 @@ async function boot() {
100
100
  // sh:ready on the first COMMIT, stamped with the URL revision so the shell can drop a ready queued
101
101
  // by a superseded document (one it auto-renavigated past) - a WindowProxy survives navigation, so
102
102
  // a stale ready could otherwise mark a reloading frame ready. Mirrors the sh:measure generation guard.
103
- const ready = () => { phases.commit = Math.round(performance.now()); post({ type: 'sh:ready', id, gen: params.get('r') ?? '', meta: frameMod.meta && typeof frameMod.meta === 'object' ? frameMod.meta : undefined, phases }) }
103
+ const ready = () => { phases.commit = Math.round(performance.now()); post({ type: 'sh:ready', id, gen: params.get('r') ?? '', doc: document.querySelector('meta[name="mv-doc"]')?.getAttribute('content') ?? '', meta: frameMod.meta && typeof frameMod.meta === 'object' ? frameMod.meta : undefined, phases }) }
104
104
  createRoot(document.getElementById('root')!).render(createElement(Boundary, null, createElement(Committed, { onCommit: ready }, tree)))
105
105
  } catch (err) {
106
106
  fail((err as Error).message)
@@ -110,4 +110,9 @@ async function boot() {
110
110
  boot()
111
111
  // Fast Refresh keeps this document alive across edits: tell the shell its source changed, so a
112
112
  // sleeping frame wakes and compiles again (a texture describes a source revision).
113
- if (import.meta.hot) import.meta.hot.on('vite:afterUpdate', () => post({ type: 'sh:hmr', id }))
113
+ // an update applied in place in this document (an app component under Fast Refresh): its sleeping
114
+ // textures describe old code. The shared registry's update reaches every frame and changes nothing in
115
+ // it (spec 26) - the frames it concerns are reloaded by the shell - so it is not one.
116
+ if (import.meta.hot) import.meta.hot.on('vite:afterUpdate', (p: { updates?: { acceptedPath?: string; path?: string }[] }) => {
117
+ if (p.updates?.some((u) => !(u.acceptedPath ?? u.path ?? '').includes('/frame-host/registry'))) post({ type: 'sh:hmr', id })
118
+ })
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * The glob registry - a JSX-free module so plugin-react never touches it.
3
- * It is the HMR boundary for glob-map invalidation (frame files added/removed):
4
- * accepting here reloads THIS iframe only, instead of Vite broadcasting a full
5
- * page reload to every client including the shell.
6
- * Component edits never reach this module - they stop at Fast Refresh in the frame itself.
3
+ * Every design update reaches it (Fast Refresh is off under design/), and it is the one HMR
4
+ * boundary of a frame document: it accepts the update and does nothing with it. The dev server
5
+ * names the frames an edit touched and the shell reloads exactly those, queued and lease-aware
6
+ * (spec 26) - a document never reloads itself, and its map refreshes so a new frame can open.
7
7
  */
8
8
  export const frames = import.meta.glob(['/design/scenes/**/*.{tsx,jsx}', '/design/components/**/*.{tsx,jsx}'])
9
9
  export const layouts = import.meta.glob(['/design/scenes/**/_layout.{tsx,jsx}', '/design/components/**/_layout.{tsx,jsx}'])
@@ -37,4 +37,4 @@ export function layoutChain(fileKey: string): string[] {
37
37
  return chain
38
38
  }
39
39
 
40
- if (import.meta.hot) import.meta.hot.accept(() => location.reload())
40
+ if (import.meta.hot) import.meta.hot.accept(() => { /* the shell reloads what changed */ })
@@ -1,19 +1,20 @@
1
1
  import { Component, useEffect, useRef, useState, type MouseEvent as ReactMouseEvent, type ReactNode } from 'react'
2
- import { useStore, CONFIG, CANVAS_NAME, LOCKED_SHELL, PUBLISHED, SOURCE_REVEALED, boardLabel, boardFrames, cap, humanize, fetchBoardNames, tabTitle, hydrateBoardPolicy, landingMode, playsAsSlides, sceneLabel, type FrameEntry } from './store.ts'
3
- import { BoardList } from './BoardList.tsx'
2
+ import { useStore, CONFIG, CANVAS_NAME, LOCKED_SHELL, PUBLISHED, SOURCE_REVEALED, logReload, takeReloadCause, addToBoard, boardLabel, cap, humanize, fetchBoardNames, landingBoard, tabTitle, hydrateBoardPolicy, landingMode, playsAsSlides, sceneLabel, type FrameEntry } from './store.ts'
3
+ import { AddToBoard, BoardList } from './BoardList.tsx'
4
4
  import { ContextMenu, copyToClipboard, framePath, useContextMenu, type MenuItem } from './ContextMenu.tsx'
5
5
  import { Tip } from './Tip.tsx'
6
6
  import { PKG, ROUTE } from '../const.ts'
7
7
  import { animateLayout, Canvas, canvasCtl } from './canvas/Canvas.tsx'
8
8
  import { frameByWindow } from './canvas/frame-registry.ts'
9
9
  import { enterFocus, enterPlay, enterSlides, playCtl, PlayOverlay } from './Play.tsx'
10
- import { bootHash, linkTargets, parseHash, writeHash } from './hash.ts'
11
- import { CaretIcon, CheckIcon, ColumnsIcon, FrameRectIcon, ImagesSquareIcon, IntentGlyph, MoonIcon, PanelFilledIcon, PanelHollowIcon, ParallelogramDuoIcon, ParallelogramFillIcon, PencilSimpleIcon, PlayIcon, SignpostIcon, SlideFrameIcon, SunIcon, VariantsIcon, XIcon, deviceIcon } from './icons.tsx'
12
- import { humanize as slugLabel, readTitle } from '../../shared/board-tree.ts'
13
- import { CommentsController, revealThread } from './Comments.tsx'
10
+ import { bootHash, linkTargets, parseHash, retargetBoot, UNPLACED, writeHash } from './hash.ts'
11
+ import { isLegacyLink, landLegacy } from './legacy-links.ts'
12
+ import { CaretIcon, CheckIcon, ColumnsIcon, FrameRectIcon, ImagesSquareIcon, IntentGlyph, MoonIcon, PanelFilledIcon, PanelHollowIcon, ParallelogramDuoIcon, ParallelogramFillIcon, PencilSimpleIcon, PlayIcon, PlusIcon, SignpostIcon, SlideFrameIcon, SunIcon, VariantsIcon, XIcon, deviceIcon } from './icons.tsx'
13
+ import { ALL_SCENES, humanize as slugLabel, readTitle } from '../../shared/board-tree.ts'
14
+ import { CommentsController, parkThread, revealThread } from './Comments.tsx'
14
15
  import { poweredByUrl } from '../../shared/utm.ts'
15
- import { avatarFallback, useComments } from './comments-store.ts'
16
- import { goTo, navigated, revealFrame } from './goto.ts'
16
+ import { avatarFallback, NO_COMMENTS_HERE, useComments } from './comments-store.ts'
17
+ import { goTo, isLatest, navigated, revealFrame } from './goto.ts'
17
18
  import { useNotes } from './notes.ts'
18
19
  import { contentOnly } from '../../shared/frames.ts'
19
20
  import { nextToLook } from '../../shared/marks.ts'
@@ -366,16 +367,24 @@ export function App() {
366
367
  if (r.ok) hydrateBoardPolicy(((await r.json()) as { boards?: Record<string, never> }).boards ?? {})
367
368
  } catch { /* dev server without the route - fine */ }
368
369
  }
369
- if (bootHash.board) {
370
+ // a link from before 0.25 names the All Scenes board: it lands on a real one (legacy-links.ts)
371
+ let notice: string | null = null
372
+ if (isLegacyLink(bootHash)) {
373
+ const r = await landLegacy(bootHash)
374
+ retargetBoot(r.hash)
375
+ writeHash(r.hash)
376
+ notice = r.notice
377
+ }
378
+ if (bootHash.board && !(PUBLISHED && bootHash.board === UNPLACED)) { // the Not on a board view is dev's
370
379
  if (bootHash.board !== useStore.getState().board) // a deep link wins
371
- useStore.setState({ board: bootHash.board, boardAuto: bootHash.board === 'all-scenes' })
380
+ useStore.setState({ board: bootHash.board, boardAuto: false })
372
381
  } else if (!PUBLISHED) {
373
- // fresh open, no deep link: LAND on the first curated board (a tight, fast board = a good first
374
- // impression) instead of the auto all-scenes everything-board, which renders every frame at once.
375
- const first = (await fetchBoardNames().catch(() => [] as string[])).find((n) => n !== 'all-scenes')
376
- if (first && first !== useStore.getState().board) useStore.setState({ board: first, boardAuto: false })
382
+ // fresh open, no deep link: LAND on the first board - with none yet, the Not on a board view
383
+ const first = await landingBoard()
384
+ if (first !== useStore.getState().board) useStore.setState({ board: first, boardAuto: false })
377
385
  }
378
386
  const ok = await boot()
387
+ if (notice) toast(notice)
379
388
  urlReady.current = true
380
389
  // a link naming frames on a board with NO nodes: the canvas's boot fit never runs (it waits
381
390
  // for the first frame) - follow the frame to where it lives from here
@@ -426,8 +435,28 @@ export function App() {
426
435
  // restores never echo back into history.
427
436
  useEffect(() => {
428
437
  const onPop = async () => {
429
- navigated() // a reveal still looking up its board must not land after this
430
- const h = parseHash()
438
+ const nav = navigated() // a reveal still looking up its board must not land after this
439
+ // a lookup below still running when newer navigation lands - a link, a board picked, a step in play - is dropped
440
+ const at = useStore.getState().board, step = useStore.getState().play?.at
441
+ const overtaken = () => !isLatest(nav) || useStore.getState().board !== at || useStore.getState().play?.at !== step
442
+ let h = parseHash()
443
+ if (PUBLISHED && h.board === UNPLACED) h = {} // the Not on a board view is dev's: published, the default board
444
+ const legacy = isLegacyLink(h)
445
+ if (legacy) {
446
+ // an old All Scenes link pasted, or walked back to: where it lands now, written over it -
447
+ // once, though back/forward fires two events
448
+ const r = await landLegacy(h)
449
+ const board = r.hash.board ?? await landingBoard()
450
+ if (overtaken()) return
451
+ h = { ...r.hash, board }
452
+ writeHash(h)
453
+ if (r.notice) toast(r.notice)
454
+ } else if (!h.board && !h.focus && !h.invite) {
455
+ // the bare #/ opens the landing board
456
+ const board = await landingBoard()
457
+ if (overtaken()) return
458
+ h = { ...h, board }
459
+ }
431
460
  let s = useStore.getState()
432
461
  if (h.board && h.board !== s.board) {
433
462
  if (s.play) s.setPlay(null) // a stale overlay must never survive into another board
@@ -435,6 +464,8 @@ export function App() {
435
464
  s = useStore.getState()
436
465
  if (s.board !== h.board) return // switch failed; the projection effect will re-sync the URL
437
466
  }
467
+ // the thread an old link names (Comments.tsx opens every other link's): now, or once the new board's comments load
468
+ if (legacy && h.c) { if (s.board !== at) parkThread(h.c); else revealThread(h.c) }
438
469
  if (h.focus) {
439
470
  enterFocus(h.focus.at, { ...h.focus, deep: true })
440
471
  } else if (h.play) {
@@ -447,7 +478,7 @@ export function App() {
447
478
  if (s.play) s.setPlay(null)
448
479
  const keys = linkTargets(h, s.nodes)
449
480
  useStore.setState({ selection: keys })
450
- s.markSeen(keys.map((k) => s.nodes.find((n) => n.key === k)?.frame).filter((f): f is string => !!f)) // a link opened is a look
481
+ s.look(keys) // a link opened is a look
451
482
  if (!keys.length && h.f?.length) void revealFrame(h.f[0]) // not on this board - where it lives
452
483
  else setTimeout(() => (keys.length ? canvasCtl.fitNodes(keys) : canvasCtl.fitAll()), 60)
453
484
  }
@@ -464,7 +495,9 @@ export function App() {
464
495
  // page title follows the open board (and its title, when one is set)
465
496
  const board = useStore((s) => s.board)
466
497
  const titles = useStore((s) => s.boardTitles)
467
- useEffect(() => { document.title = tabTitle(board) }, [board, titles])
498
+ // an empty Not on a board view (a canvas with no board and no frame yet) is no place to name in the tab
499
+ const emptyView = useStore((s) => s.board === UNPLACED && !s.nodes.length)
500
+ useEffect(() => { document.title = tabTitle(emptyView ? null : board) }, [board, titles, emptyView])
468
501
 
469
502
  // favicon follows the mode: blue pack in design mode, purple pack in interact.
470
503
  // The links are rebuilt (not toggled) so the set stays deterministic; the .ico is
@@ -526,6 +559,7 @@ export function App() {
526
559
  import.meta.hot.on('vite:ws:connect', () => void useStore.getState().syncWorking())
527
560
  // sidebar marks (spec 25): a frame changed on disk, or an agent's work started or ended
528
561
  void useStore.getState().syncMarks()
562
+ logReload({ kind: 'shell-boot' }) // the reload log: every time the canvas page itself loads
529
563
  import.meta.hot.on('vite:ws:connect', () => void useStore.getState().syncMarks())
530
564
  import.meta.hot.on('sh:marks', () => void useStore.getState().syncMarks())
531
565
  import.meta.hot.on('sh:boards', () => void useStore.getState().syncMarks()) // a board's frames changed: its roll-up too
@@ -537,7 +571,7 @@ export function App() {
537
571
  // reload, never a React Fast Refresh yanking a frame the user is in.
538
572
  import.meta.hot.on('sh:frame-invalidated', (m: any) => {
539
573
  const frameIds = Array.isArray(m?.frameIds) ? m.frameIds.filter((x: unknown) => typeof x === 'string') : []
540
- if (frameIds.length && typeof m?.revision === 'string') useStore.getState().invalidateFrames(frameIds, m.revision)
574
+ if (frameIds.length && typeof m?.revision === 'string') useStore.getState().invalidateFrames(frameIds, m.revision, { epoch: m?.epoch, docs: m?.docs })
541
575
  })
542
576
  // multi-viewer sync: another viewer (or an agent) saved this board. A clean canvas
543
577
  // re-boots silently, keeping whatever selection survives; a dirty one keeps its
@@ -577,6 +611,11 @@ export function App() {
577
611
  // sleeping override of the previous document must not be trusted for this one
578
612
  if (s.nodes.find((n) => n.key === nodeKey)?.status === 'ready') s.bumpRev(nodeKey)
579
613
  s.setStatus(nodeKey, 'ready')
614
+ // the revision this document was served with (spec 26): a look counts up to it, and one older
615
+ // than the frame's last edit reloads
616
+ const before = s.nodes.find((n) => n.key === nodeKey)?.shown
617
+ if (typeof data.doc === 'string') s.setShown(nodeKey, data.doc)
618
+ logReload({ kind: 'ready', cause: takeReloadCause(nodeKey) ?? (before === undefined ? 'first' : 'self'), node: nodeKey, frame: String(data.id ?? ''), shown: typeof data.doc === 'string' ? data.doc : undefined, ms: Number(data.phases?.commit) })
580
619
  } else if (data.type === 'sh:error') {
581
620
  s.setStatus(nodeKey, 'error', String(data.message ?? 'unknown error'))
582
621
  } else if (data.type === 'sh:exit-interact') {
@@ -692,6 +731,7 @@ export function App() {
692
731
  // pins · Shift+P = copy file path(s) (P alone is play; D6, changelog 0.4.0)
693
732
  if (e.key === 'c' && !e.shiftKey) {
694
733
  const c = commentsStore()
734
+ if (!c.commentMode && s.board === UNPLACED) return void toast(NO_COMMENTS_HERE)
695
735
  if (!c.commentMode) s.setLaser(false)
696
736
  c.setMode(!c.commentMode)
697
737
  toast(c.commentMode ? 'comment mode off' : 'comment mode - click an element in a frame')
@@ -851,7 +891,7 @@ export function App() {
851
891
  ? `board: ${useStore.getState().board} · scene: ${sc.name} (design/scenes/${sc.name}/)`
852
892
  : `board: ${useStore.getState().board} · scene: (root)`, 'path copied'),
853
893
  }, ...(!PUBLISHED && sc.name ? [{ label: 'Rename', icon: <PencilSimpleIcon size={15} />, onClick: () => setSceneNaming(sc.name) }] : []),
854
- ...(!PUBLISHED ? [{ label: 'Mark all as seen', icon: <CheckIcon size={15} />, onClick: () => useStore.getState().markSeen(frames.filter((f) => f.scene === sc.name).map((f) => f.id), true) }] : [])])}
894
+ ...(!PUBLISHED ? [{ label: 'Mark all as seen', icon: <CheckIcon size={15} />, onClick: () => useStore.getState().markSeen(frames.filter((f) => f.scene === sc.name).map((f) => f.id)) }] : [])])}
855
895
  onPick={() => {
856
896
  const keys = nodes.filter((n) => frames.some((f) => f.scene === sc.name && f.id === n.frame) && !n.missing).map((n) => n.key)
857
897
  if (!keys.length) return
@@ -886,6 +926,8 @@ export function App() {
886
926
  }
887
927
  const frameMenu = (fr: FrameEntry): MenuItem[] => [
888
928
  { label: 'Copy path', icon: <SignpostIcon size={15} />, onClick: () => copyToClipboard(framePath(useStore.getState().board, fr), 'path copied') },
929
+ // the Not on a board view (spec 26): put the frame where it belongs
930
+ ...(useStore.getState().board === UNPLACED ? [{ label: 'Add to board…', icon: <PlusIcon size={15} />, panel: (close: () => void) => <AddToBoard frame={fr.id} close={close} /> }] : []),
889
931
  ]
890
932
  const seen = new Set<string>()
891
933
  const rows: ReactNode[] = []
@@ -1053,7 +1095,9 @@ function JamAvatar({ author }: { author: { name?: string; avatar?: string; id?:
1053
1095
  async function viewNote(note: import('./store.ts').JamNote, dismiss: () => void) {
1054
1096
  if (revealThread(note.threadId)) { dismiss(); return }
1055
1097
  const s = useStore.getState()
1056
- if (note.board && s.board !== note.board) await s.switchBoard(note.board)
1098
+ // a thread in the old all-scenes log has no board of its own: its frame's board shows it (spec 26)
1099
+ if (note.board === ALL_SCENES) { if (note.frame) await revealFrame(note.frame) }
1100
+ else if (note.board && s.board !== note.board) await s.switchBoard(note.board)
1057
1101
  for (let i = 0; i < 12; i++) {
1058
1102
  if (revealThread(note.threadId)) { dismiss(); return }
1059
1103
  await new Promise((r) => setTimeout(r, 250))
@@ -1076,7 +1120,7 @@ function JamToast({ id, note, badge, inert }: { id: number; note: import('./stor
1076
1120
  {human
1077
1121
  ? <b className="sh-jam-frame"><span className="t">{note.author!.name ?? 'Someone'}</span> <span className="v">{note.kind === 'mention' ? 'mentioned you' : 'replied'}</span></b>
1078
1122
  : note.stack?.length
1079
- ? <b className="sh-jam-frame"><span className="t">{boardLabel(note.board)}</span> <span className="v">· {note.stack.length + 1} replies</span></b>
1123
+ ? <b className="sh-jam-frame"><span className="t">{note.board === ALL_SCENES ? note.frameTitle ?? note.frame ?? '' : boardLabel(note.board)}</span> <span className="v">· {note.stack.length + 1} replies</span></b>
1080
1124
  : <b className="sh-jam-frame"><span className="t">{note.frameTitle ?? note.board}</span></b>}
1081
1125
  <span className="sh-jam-prev">{note.preview}</span>
1082
1126
  </div>