@marver-design/marver 0.23.1 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +3 -1
  3. package/dist/anchor-DVV732zR.mjs +33 -0
  4. package/dist/anchor-check-BE5VVN6Q.mjs +135 -0
  5. package/dist/{bake-DQtnDB8-.mjs → bake-D8byeRzB.mjs} +1 -1
  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-_ndp_dXn.mjs → build-BHoWLvSj.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-BlqyZh3D.mjs → comments-pTLlhjh4.mjs} +150 -20
  14. package/dist/{config-BUKprFAp.mjs → config-cKgZBRj0.mjs} +1 -1
  15. package/dist/{context-CdkNiKdJ.mjs → context-D2ugHqwO.mjs} +17 -123
  16. package/dist/{daemon-BvMPdQ3k.mjs → daemon-Cl8KXGW4.mjs} +146 -64
  17. package/dist/{dev-Cf-4eqaC.mjs → dev-DJdgow47.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-hfZV7TwY.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-DoXql0ZZ.mjs → plugin-CTyhjwoJ.mjs} +469 -82
  29. package/dist/{poster-XBmUvQiL.mjs → poster-D0cbV7hi.mjs} +1 -1
  30. package/dist/{profile-CrZohD6g.mjs → profile-Do0nGkXO.mjs} +1 -1
  31. package/dist/{publish-bakes-KKTHWqq3.mjs → publish-bakes--l8ot2eQ.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-DOD8v6fJ.mjs → shot-CckrGW-J.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-ClFFq0Qh.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 +70 -4
  41. package/docs/live-jam.md +12 -4
  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 +98 -30
  48. package/src/client/shell/BoardList.tsx +74 -16
  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 -32
  53. package/src/client/shell/Toolbar.tsx +3 -1
  54. package/src/client/shell/canvas/Canvas.tsx +2 -0
  55. package/src/client/shell/canvas/FrameNode.tsx +15 -5
  56. package/src/client/shell/canvas/sleep.ts +4 -3
  57. package/src/client/shell/canvas/updates.ts +55 -0
  58. package/src/client/shell/comments-store.ts +48 -17
  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 +117 -0
  64. package/src/client/shell/pin-layout.ts +37 -0
  65. package/src/client/shell/store.ts +377 -67
  66. package/src/client/shell/styles.css +32 -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 +70 -0
  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-BodAbIQz.mjs +0 -132
  80. package/dist/manifest-TpfDWldB.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 */ })