@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
@@ -75,13 +75,12 @@ export function IntentGlyph({ intent, size = 14, ...rest }: IconProps & { intent
75
75
  /** The slide badge (v1.5): a 16:9 stage with the play wedge - a deck frame. */
76
76
  export const SlideFrameIcon = icon(<path d="M192,48H64A16,16,0,0,0,48,64V192a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64A16,16,0,0,0,192,48Zm0,144H64V64H192V192ZM240,56V200a8,8,0,0,1-16,0V56a8,8,0,0,1,16,0ZM32,56V200a8,8,0,0,1-16,0V56a8,8,0,0,1,16,0Z" />)
77
77
  export const PanelHollowIcon = icon(<><rect x="32" y="48" width="192" height="160" rx="32" fill="none" stroke="currentColor" strokeWidth="16" /><rect x="72" y="88" width="48" height="80" rx="24" fill="none" stroke="currentColor" strokeWidth="14" /></>)
78
- /** Board glyphs: CardsThree = the built-in `all-scenes` board; Cards = curated boards. */
79
- export const CardsThreeIcon = icon(<path d="M208,88H48a16,16,0,0,0-16,16v96a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V104A16,16,0,0,0,208,88Zm0,112H48V104H208v96ZM48,64a8,8,0,0,1,8-8H200a8,8,0,0,1,0,16H56A8,8,0,0,1,48,64ZM64,32a8,8,0,0,1,8-8H184a8,8,0,0,1,0,16H72A8,8,0,0,1,64,32Z" />)
80
78
  export const FrameCornersIcon = icon(<path d="M160 48h40a8 8 0 0 1 8 8v40M208 160v40a8 8 0 0 1-8 8h-40M96 208H56a8 8 0 0 1-8-8v-40M48 96V56a8 8 0 0 1 8-8h40" fill="none" stroke="currentColor" strokeWidth="16" strokeLinecap="round" strokeLinejoin="round" />)
81
79
  export const ArrowLeftIcon = icon(<path d="M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z" />)
82
80
  export const ArrowRightIcon = icon(<path d="M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" />)
83
81
  /** Variants/experimentation mark: the flask (Phosphor). */
84
82
  export const VariantsIcon = icon(<path d="M223.45,208.19,168,101.11V40h8a8,8,0,0,0,0-16H80a8,8,0,0,0,0,16h8v61.11L32.55,208.19A16,16,0,0,0,46.86,232H209.14a16,16,0,0,0,14.31-23.81ZM102.13,108.5A8,8,0,0,0,104,103.35V40h48v63.35a8,8,0,0,0,1.87,5.15L179.36,157c-11.71,2.87-26.5.66-44.16-6.64-14.08-5.82-27.34-8.53-39.66-8.16ZM46.86,216,84.36,143.6c11.68-2.9,26.47-.68,44.13,6.61,13.09,5.42,25.36,8.11,36.65,8.11a67.86,67.86,0,0,0,22.53-3.72L209.14,216Z" />)
83
+ /** The board glyph, for a board with no type. */
85
84
  export const CardsIcon = icon(<path d="M184,72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V88A16,16,0,0,0,184,72Zm0,128H40V88H184V200ZM232,56V176a8,8,0,0,1-16,0V56H64a8,8,0,0,1,0-16H216A16,16,0,0,1,232,56Z" />)
86
85
  /** Viewport-name -> device glyph; unknown custom names fall back to the generic Devices. */
87
86
  export function deviceIcon(name: string | null, size = 14) {
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Links from before 0.25 (spec 26, Part 7). The built-in All Scenes board is gone, but links naming
3
+ * it live on in messages, docs and threads - each one lands on a real board:
4
+ *
5
+ * ?c=<thread> the first board (sidebar order, archive boards last) that shows its frame
6
+ * ?f= / ?s= the board that shows most of them (the first on a tie), those selected, and a
7
+ * notice naming where the others are; the Not on a board view only when none
8
+ * of them is on a board
9
+ * ?n=<keys> the keys turned back into frames - from a leftover all-scenes.json (in dev,
10
+ * or as the build shipped it), or the keys the old board minted (keys.ts) -
11
+ * then as above; none recovered: the landing board, with a notice
12
+ * #/p/all-scenes plays on the first board that shows its frame; device, theme and mode kept
13
+ * #/b/all-scenes the landing board
14
+ */
15
+ import { ALL_SCENES } from '../../shared/board-tree.ts'
16
+ import { stableNodeKey } from './keys.ts'
17
+ import { UNPLACED, type HashState } from './hash.ts'
18
+ import { ALL_SCENES_KEYS, boardLabel, fetchMembership, PUBLISHED } from './store.ts'
19
+ import { useComments } from './comments-store.ts'
20
+ import { ROUTE } from '../const.ts'
21
+
22
+ export const isLegacyLink = (h: HashState): boolean => h.board === ALL_SCENES
23
+
24
+ /** Where an old link lands now: the hash to apply instead (no board = the landing board), and what
25
+ * to say about it. */
26
+ export async function landLegacy(h: HashState): Promise<{ hash: HashState; notice: string | null }> {
27
+ const { board: _old, n, f, s, c, ...rest } = h
28
+ let m: Awaited<ReturnType<typeof fetchMembership>>
29
+ try { m = await fetchMembership() } catch { return { hash: rest, notice: 'could not read the boards - opened the first one' } }
30
+ const live = [...new Set([...m.boards.flatMap((b) => b.frames), ...m.unplaced])]
31
+ // a frame on no board has the Not on a board view in dev; a published canvas ships no such frame
32
+ const home = (frame: string): string | undefined =>
33
+ m.boards.find((b) => b.frames.includes(frame))?.name ?? (!PUBLISHED && m.unplaced.includes(frame) ? UNPLACED : undefined)
34
+
35
+ if (h.play) return { hash: { ...rest, board: h.play.at ? home(h.play.at) : undefined }, notice: null }
36
+ if (c) {
37
+ const t = await useComments.getState().findThread(c)
38
+ return { hash: { ...rest, board: t?.frame ? home(t.frame) : undefined, c, ...(t?.frame ? { f: [t.frame] } : {}) }, notice: t ? null : 'that thread is not on this canvas any more' }
39
+ }
40
+
41
+ const frames = new Set([...(f ?? []), ...live.filter((id) => s?.some((sc) => id.startsWith(`${sc}/`)))].filter((id) => live.includes(id)))
42
+ if (n?.length) {
43
+ // node keys: the leftover file's, else the ones the old board gave each frame (it minted them all)
44
+ const byKey = new Map([...live.map((id) => [stableNodeKey(ALL_SCENES, id, 0), id] as const), ...Object.entries(ALL_SCENES_KEYS)])
45
+ if (!PUBLISHED) {
46
+ try {
47
+ const leftover = (await (await fetch(`${ROUTE}/api/boards/${ALL_SCENES}`)).json())?.board as { nodes?: { key?: unknown; frame?: unknown }[] } | null
48
+ for (const node of Array.isArray(leftover?.nodes) ? leftover.nodes : []) if (typeof node?.key === 'string' && typeof node.frame === 'string') byKey.set(node.key, node.frame)
49
+ } catch { /* no leftover, or not JSON: the minted keys stand */ }
50
+ }
51
+ for (const k of n) { const id = byKey.get(k); if (id && live.includes(id)) frames.add(id) }
52
+ if (!frames.size) return { hash: rest, notice: 'the frames that link named could not be found - opened the first board' }
53
+ }
54
+ if (!frames.size) return { hash: rest, notice: null }
55
+
56
+ // the board that shows most of them, the first in sidebar order on a tie
57
+ const asked = [...frames]
58
+ let best: { name: string; frames: string[] } | null = null, most = 0
59
+ for (const b of m.boards) { const k = asked.filter((id) => b.frames.includes(id)).length; if (k > most) { best = b; most = k } }
60
+ if (!best) {
61
+ const anyUnplaced = !PUBLISHED && asked.some((id) => m.unplaced.includes(id))
62
+ return { hash: { ...rest, ...(anyUnplaced ? { board: UNPLACED, f: asked } : {}) }, notice: anyUnplaced ? null : 'those frames are on no board - opened the first one' }
63
+ }
64
+ const here = asked.filter((id) => best!.frames.includes(id))
65
+ const elsewhere = asked.filter((id) => !here.includes(id)).map((id) => { const b = home(id); return `${id} is ${b === UNPLACED ? 'on no board' : b ? `on ${boardLabel(b)}` : 'not shipped'}` })
66
+ return { hash: { ...rest, board: best.name, f: here }, notice: elsewhere.length ? `${here.length} of ${asked.length} here - ${elsewhere.join('; ')}` : null }
67
+ }
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { useEffect, type HTMLAttributes, type ReactNode } from 'react'
7
7
  import { create } from 'zustand'
8
- import { useStore, PUBLISHED } from './store.ts'
8
+ import { useStore, PUBLISHED, shownRev } from './store.ts'
9
9
  import { useComments } from './comments-store.ts'
10
10
  import { frameMark, isNew, questions, type Ask, type FrameMark } from '../../shared/marks.ts'
11
11
 
@@ -28,12 +28,6 @@ const derive = () => {
28
28
  useStore.subscribe((s, p) => { if (s.marks !== p.marks || s.manifest !== p.manifest) derive() })
29
29
  useComments.subscribe((s, p) => { if (s.threads !== p.threads) derive() })
30
30
 
31
- /** The playNav at which the focus/play stage last finished loading (Play reports it); -1 while none
32
- * has. An applied Update reloads the stage: the change is on screen once that reload lands. */
33
- let stageNav = -1
34
- export const stageShown = () => { stageNav = useStore.getState().playNav }
35
- useStore.subscribe((s, p) => { if (!s.play && p.play) stageNav = -1 })
36
-
37
31
  export const asksNow = (): Map<string, Ask> => useMarkView.getState().q
38
32
  /** Open Marver questions per frame - for the board list, a light component that rolls up per board. */
39
33
  export const useAsks = (): Map<string, Ask> => useMarkView((s) => s.q)
@@ -63,7 +57,7 @@ export const toneOf = (m: FrameMark): string => (!m ? '' : m.kind === 'new' ? '
63
57
 
64
58
  export const Bubble = ({ n, hollow }: { n: number; hollow?: boolean }) => (
65
59
  <i className={`mk-bubble${hollow ? ' hollow' : ''}`} data-mark={hollow ? 'answered' : 'ask'}
66
- aria-label={hollow ? `${n} answered, waiting on the agent` : `${n} question${n > 1 ? 's' : ''} for you`}>{n}</i>
60
+ aria-label={hollow ? `${n} answered, waiting on the agent` : `${n} waiting on you`}>{n}</i>
67
61
  )
68
62
 
69
63
  /** A frame row's slot: the bubble, or the blue dot. */
@@ -80,38 +74,42 @@ export function MarkedRow({ frame, className, children, ...rest }: { frame: stri
80
74
  }
81
75
 
82
76
  /** Looking at a frame counts as seeing it (spec 25): any part of it in the window for two seconds,
83
- * at a readable zoom (scale 0.5 or more), showing the change - a frame still loading, or holding a
84
- * deferred update, is not showing it yet. In focus or play the frame on stage fills the window, once
85
- * an update it holds is applied and the stage has reloaded with it. Polls once a second, and only frames that are new. */
77
+ * at a readable zoom (scale 0.5 or more) - for the revision its document shows (spec 26): a frame
78
+ * still loading, stale, or showing an older revision than its last edit is not showing that edit, and
79
+ * the clock starts again when a new revision is up. In focus or play the stage counts the same way,
80
+ * once an Update it holds is applied. Polls once a second, and only frames that are new. */
86
81
  export function useSeenOnScreen() {
87
82
  useEffect(() => {
88
83
  if (PUBLISHED) return
89
- const since = new Map<string, number>() // "key@changed" -> when it came into view
84
+ const since = new Map<string, number>() // "where@changed:shown" -> when it came into view
90
85
  const tick = () => {
91
86
  const s = useStore.getState(), m = s.marks
92
87
  const now = Date.now()
93
- const shown = new Map<string, string>() // clock key -> frame; a newer change restarts the clock
88
+ const shown = new Map<string, string>() // clock key -> node key (or 'stage'); a newer change or document restarts the clock
94
89
  if (m && !document.hidden && s.play) {
95
- const f = s.nodes.find((n) => n.key === s.play!.at)?.frame ?? s.play.at
96
- if (!s.playUpdateRevision && stageNav === s.playNav && isNew(m, f)) shown.set(`play:${f}@${m.changed[f] ?? 0}`, f)
90
+ const st = s.stageShown, f = st?.at
91
+ if (st && f && !s.playUpdateRevision && isNew(m, f)) {
92
+ const [e, r] = st.shown.split(':')
93
+ if (e === m.epoch && Number(r) >= (m.doc[f] ?? 0)) shown.set(`play:${f}@${m.changed[f] ?? 0}:${st.shown}`, 'stage')
94
+ }
97
95
  } else if (m && !document.hidden && s.scale >= 0.5) {
98
96
  // in view: some of it inside the window and not all of that under the open sidebar
99
97
  const P = document.querySelector('.sh-panel:not(.closed)')?.getBoundingClientRect()
100
98
  const W = window.innerWidth, H = window.innerHeight
101
99
  for (const n of s.nodes) {
102
- if (n.status !== 'ready' || s.pendingFrameRevisions[n.frame] || !isNew(m, n.frame)) continue
100
+ if (n.status !== 'ready' || n.stale || !isNew(m, n.frame) || shownRev(n, m) < (m.doc[n.frame] ?? 0)) continue
103
101
  const r = document.querySelector<HTMLElement>(`.sh-node[data-node="${CSS.escape(n.key)}"]`)?.getBoundingClientRect()
104
102
  if (!r) continue
105
103
  const x0 = Math.max(r.left, 0), x1 = Math.min(r.right, W), y0 = Math.max(r.top, 0), y1 = Math.min(r.bottom, H)
106
104
  if (x0 >= x1 || y0 >= y1) continue
107
105
  if (P && x0 >= P.left && x1 <= P.right && y0 >= P.top && y1 <= P.bottom) continue
108
- shown.set(`${n.key}@${m.changed[n.frame] ?? 0}`, n.frame)
106
+ shown.set(`${n.key}@${m.changed[n.frame] ?? 0}:${n.shown}`, n.key)
109
107
  }
110
108
  }
111
109
  for (const k of [...since.keys()]) if (!shown.has(k)) since.delete(k)
112
110
  const due: string[] = []
113
- for (const [k, f] of shown) { const t = since.get(k) ?? now; since.set(k, t); if (now - t >= 2000) due.push(f) }
114
- if (due.length) s.markSeen(due, true)
111
+ for (const [k, where] of shown) { const t = since.get(k) ?? now; since.set(k, t); if (now - t >= 2000) due.push(where) }
112
+ if (due.length) s.look(due)
115
113
  }
116
114
  const id = setInterval(tick, 1000)
117
115
  return () => clearInterval(id)
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Where comment markers sit (spec 26, Part 6): no two overlap, and they stay put.
3
+ *
4
+ * Each thread has a fixed attach point (its element's first line end, or where a person clicked);
5
+ * the marker is placed near it. Placement uses ONE marker size in screen space - the face (avatars,
6
+ * a count) draws inside it - so a reply or a new participant never moves anything. One pass in
7
+ * thread creation order moves a marker that would touch an earlier one down by its height plus
8
+ * 6 px; a moved marker keeps a thin line to its point. Threads with no point - legacy frame-level
9
+ * pins, orphans whose element is gone - line up in a column down from the frame's top-right corner.
10
+ *
11
+ * Pure: the canvas (node px, `inv` = world px per screen px) and the stage (screen px, inv 1) call
12
+ * the same function, and the tests read it directly.
13
+ */
14
+
15
+ /** The marker's box in screen px (CSS `.cm-pin` keeps its face inside it) and the gap between two. */
16
+ export const MARKER = { w: 80, h: 34, gap: 6 }
17
+
18
+ /** A placed marker: its tail (bottom-left, where `.cm-pin` hangs from) and, when it was moved off
19
+ * its point, the point the leader line runs up to. */
20
+ export interface Placed { x: number; y: number; lead?: { x: number; y: number }; column: boolean }
21
+
22
+ export function placeMarkers(items: readonly { id: string; point: { x: number; y: number } | null }[], frameW: number, inv: number): Map<string, Placed> {
23
+ const w = MARKER.w * inv, h = MARKER.h * inv, gap = MARKER.gap * inv, tail = 2 * inv
24
+ const boxes: { l: number; r: number; t: number; b: number }[] = []
25
+ const out = new Map<string, Placed>()
26
+ let slot = 0
27
+ for (const it of items) {
28
+ // a column slot hangs its box from the frame's top-right corner, 8 px in
29
+ const x = it.point ? it.point.x : frameW - 8 * inv - w + tail
30
+ let y = it.point ? it.point.y : 8 * inv + h + slot++ * (h + gap)
31
+ const touches = () => boxes.some((o) => x - tail < o.r + gap && o.l < x - tail + w + gap && y - h < o.b + gap && o.t < y + gap)
32
+ for (let i = 0; i < 500 && touches(); i++) y += h + gap
33
+ boxes.push({ l: x - tail, r: x - tail + w, t: y - h, b: y })
34
+ out.set(it.id, { x, y, column: !it.point, ...(it.point && y !== it.point.y ? { lead: it.point } : {}) })
35
+ }
36
+ return out
37
+ }