@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
@@ -0,0 +1,250 @@
1
+ /**
2
+ * Showing the human a place (spec 31 D1, D3): `marver show`'s `sh:show { seq, board, n?, f?, s?, c? }` from the dev
3
+ * server, and in the Mac app the same command over the bridge (`onShow`) for a `marver://` link into a tab already
4
+ * open. One rule for both:
5
+ *
6
+ * - the command is checked again (shared/deep-link.ts `checkShowTarget`) - the hash's own targets, never a raw hash;
7
+ * - a tab holding unsent words (a comment draft, a Jam edit: api.ts `typedUnsent`) or a capture recording does not move:
8
+ * it puts up "Your agent wants to show you <title> · Go", and Go moves it when the human chooses;
9
+ * - else it switches board, selects (node keys stay node keys - one copy of a frame, never every copy), opens the
10
+ * thread, and fits - even when it is already there: a repeat refits;
11
+ * - a newer command supersedes an older one still on its way (a board read, a fit), and a server seq it already took is
12
+ * never taken twice;
13
+ * - in the app, a server show then asks the main process (`front()`, a trusted bridge call bound to the admitted
14
+ * document) to activate its tab and bring the window forward; a bridge show was activated by main already;
15
+ * - a server show is answered (`POST show/ack { seq, page, outcome }`), so `marver show` can say "shown in 2 tabs".
16
+ */
17
+ import { create } from 'zustand'
18
+ import { checkShowTarget, type ShowTarget } from '../../shared/deep-link.ts'
19
+ import { api, typedUnsent } from './api.ts'
20
+ import { bootLanded, cancelBoot, canvasCtl } from './canvas/ctl.ts'
21
+ import { openThreadAt } from './jam-keys.ts'
22
+ import { handNow, isLatest, navigated, navNow, revealFrame, switchFor } from './goto.ts'
23
+ import { linkTargets } from './hash.ts'
24
+ import { useJamCapture } from './jam-capture.ts'
25
+ import { APP } from './marver-app.ts'
26
+ import { PAGE_ID } from './recorder.ts'
27
+ import { boardLabel, landingBoard, sceneLabel, useStore } from './store.ts'
28
+
29
+ export type ShowFrom = 'server' | 'app'
30
+ export type ShowResult = 'shown' | 'notice' | 'stale' | 'missing' | 'bad' | 'deferred'
31
+
32
+ /** The notice a tab holding unsent words puts up instead of moving: its words, and the target Go opens. */
33
+ export interface ShowNotice { title: string; target: ShowTarget | 'landing'; at: number }
34
+ export const useShowNotice = create<{ notice: ShowNotice | null }>(() => ({ notice: null }))
35
+
36
+ /** Words a move would lose, or a capture it would cut: the same reasons a notice's click reads (open-item.ts). */
37
+ const holdsWords = (): boolean => typedUnsent() || !!useJamCapture.getState().current
38
+
39
+ /**
40
+ * A show never races the boot (spec 31 D3). One that comes while the tab still boots - its board not loaded, or its
41
+ * first camera not applied (the app delivers a link's place right after the page's hello, before its first render) - is
42
+ * deferred: the newest alone is kept, and applied once the boot settles, whether it loaded or failed. A person's own
43
+ * navigation meanwhile wins: the deferred show is dropped. Applying it cancels every boot reveal still to come
44
+ * (canvas/ctl.ts `cancelBoot`).
45
+ */
46
+ let booting = true
47
+ /** The board the boot failed to load, while the tab still names it: a show to it loads it again, never takes it as shown */
48
+ let failedBoard: string | null = null
49
+ let deferred: { t: ShowTarget | 'landing'; seq?: number; from: ShowFrom; n: number; nav: number; hand: number } | null = null
50
+
51
+ /** App.tsx, once `boot()` answered: a board that failed or has no nodes is settled now; one with nodes once its first
52
+ * camera is applied (Canvas.tsx), or two seconds at most. */
53
+ export function bootSettled(ok: boolean): void {
54
+ if (!ok) failedBoard = useStore.getState().board
55
+ const settle = () => {
56
+ if (!booting) return
57
+ booting = false
58
+ const d = deferred
59
+ deferred = null
60
+ // the newest show, and no navigation of a person's since it came: applied now
61
+ if (d && d.n === current && isLatest(d.nav) && d.hand === handNow()) void apply(d.t, d.seq, d.from, d.n)
62
+ }
63
+ if (!ok || !useStore.getState().nodes.length) settle()
64
+ else void Promise.race([bootLanded, new Promise((r) => setTimeout(r, 2000))]).then(settle)
65
+ }
66
+
67
+ /** The newest command's number: an older one still on its way stops at its next step. */
68
+ let current = 0
69
+ /** The last server seq this page took: the same one again (a reconnect's replay) is never taken twice. */
70
+ let lastSeq = 0
71
+
72
+ /** What the notice calls the place: one frame by its title, one scene by its label, else the board. */
73
+ export function titleOf(t: ShowTarget): string {
74
+ const s = useStore.getState()
75
+ const frames = t.f ?? []
76
+ if (frames.length === 1 && !t.s?.length && !t.n?.length) {
77
+ const f = s.manifest?.frames.find((x) => x.id === frames[0])
78
+ return f?.title || frames[0]!
79
+ }
80
+ if (t.s?.length === 1 && !frames.length && !t.n?.length) return sceneLabel(t.s[0]!)
81
+ return boardLabel(t.board)
82
+ }
83
+
84
+ /** The words the notice says for the canvas's own board (a link that named no place it understands). */
85
+ const LANDING = 'the board this canvas opens on'
86
+
87
+ /**
88
+ * Move to the target now - board, selection, thread, camera - each step only while this command is the newest and,
89
+ * unless the person chose it (`force`: the notice's Go), while no words wait unsent: words typed while the board loads
90
+ * stop it before anything moves (`blocked`, which the caller turns into the notice). `shown` only once the camera has
91
+ * landed for this command: a newer show, or a board that went, is never counted shown.
92
+ */
93
+ async function go(t: ShowTarget | 'landing', n: number, force: boolean): Promise<ShowResult | 'blocked'> {
94
+ const nav = navigated()
95
+ const hand = handNow()
96
+ // the newest show, no navigation since, and nothing the person did on the canvas since (goto.ts navigatedByHand)
97
+ const owned = () => n === current && isLatest(nav) && hand === handNow()
98
+ const words = () => !force && holdsWords()
99
+ const alive = () => owned() && !words()
100
+ const ended = (): 'blocked' | 'stale' => (owned() && words() ? 'blocked' : 'stale')
101
+ if (!alive()) return ended()
102
+ // the camera is this show's from here: every boot reveal still to come gives way (the boot camera, its frame fallback,
103
+ // its thread). After a failed boot the show owns the camera for good - if its own board then fails too, the canvas is a
104
+ // failed board load like any other and the boot link's place is not restored (spec 31 as built: accepted)
105
+ cancelBoot()
106
+ let target: ShowTarget
107
+ if (t === 'landing') {
108
+ const board = await landingBoard()
109
+ if (!alive()) return ended()
110
+ target = { board }
111
+ } else target = t
112
+ let s = useStore.getState()
113
+ if (s.play) s.setPlay(null) // a stale overlay never survives a show
114
+ if (target.board !== s.board) {
115
+ if (!await switchFor(target.board, nav, alive)) return alive() ? 'missing' : ended()
116
+ s = useStore.getState()
117
+ } else if (failedBoard === s.board && !s.nodes.length) {
118
+ // the board the boot failed to load: loaded now, or the show did not happen
119
+ if (!await s.boot(alive)) return alive() ? 'missing' : ended()
120
+ s = useStore.getState()
121
+ }
122
+ failedBoard = null
123
+ if (!alive()) return ended()
124
+ const keys = linkTargets(target, s.nodes)
125
+ // nodes or a scene named, none on this board: nothing to show - never answered shown (a frame is followed below)
126
+ if (!keys.length && (target.n?.length || target.s?.length) && !target.f?.length) return 'missing'
127
+ useStore.setState({ selection: keys })
128
+ s.look(keys)
129
+ if (target.c) {
130
+ // the thread where it can be seen - pins turned on, a resolved one in its panel - under the same request, and
131
+ // waited for: a thread that never shows is no "shown"
132
+ if (!await openThreadAt(target.board, target.c, { alive })) return alive() ? 'missing' : ended()
133
+ return (await fitOwn(alive)) ? 'shown' : ended()
134
+ }
135
+ if (!keys.length && target.f?.length) {
136
+ // not on this board's nodes: where it lives, under the same request - shown once it is selected there and the
137
+ // camera has landed, for this command
138
+ const f = target.f[0]!
139
+ await revealFrame(f, nav, alive)
140
+ for (let i = 0; i < 40 && alive(); i++) {
141
+ const now = useStore.getState()
142
+ if (now.selection.some((k) => now.nodes.find((x) => x.key === k)?.frame === f)) return (await fitOwn(alive)) ? 'shown' : ended()
143
+ await new Promise((r) => setTimeout(r, 50))
144
+ }
145
+ return alive() ? 'missing' : ended()
146
+ }
147
+ // the refit, even when the place is already on screen - unless a newer navigation has the camera by then (a frame's
148
+ // worth for the selection to draw; none in a background tab, whose timers run once a second)
149
+ if (document.visibilityState !== 'hidden') await new Promise((r) => setTimeout(r, 60))
150
+ if (!alive()) return ended()
151
+ if (keys.length) canvasCtl.fitNodes(keys); else canvasCtl.fitAll()
152
+ return (await cameraLanded(alive)) ? 'shown' : ended()
153
+ }
154
+
155
+ /** The show's own fit to what the helper selected (revealFrame's and revealThread's fits run on their timers, which a
156
+ * newer show may cancel): this command's camera, then its landing - in a background tab at once. */
157
+ async function fitOwn(alive: () => boolean): Promise<boolean> {
158
+ if (!alive()) return false
159
+ const sel = useStore.getState().selection
160
+ // a thread with no node to fit (a resolved one, in its panel): the board it is on, fitted all the same
161
+ if (sel.length) canvasCtl.fitNodes([...sel]); else canvasCtl.fitAll()
162
+ return cameraLanded(alive)
163
+ }
164
+
165
+ /** The camera came to rest (the commands' own rule, commands.ts `cameraDone`: it flew and stopped, or rested 250 ms),
166
+ * while `alive` held throughout - a newer navigation or words typed meanwhile is no landing. A tab in the background
167
+ * lands its camera at once (Canvas.tsx `fly`), and is timed here without frames. 2 s at most, so `marver show`'s 3 s
168
+ * hear every tab; a camera still flying then has not landed - no "shown". */
169
+ async function cameraLanded(alive: () => boolean): Promise<boolean> {
170
+ const since = performance.now()
171
+ let saw = false
172
+ // a background tab's fit landed synchronously (Canvas.tsx fly): verified now, no polling its throttled timers
173
+ if (document.visibilityState === 'hidden') return alive() && !canvasCtl.cameraBusy()
174
+ for (let n = 1; performance.now() - since < 2000; n++) {
175
+ // a frame, or 50 ms where none come (a tab in the background)
176
+ await new Promise((r) => { const late = setTimeout(r, 50); requestAnimationFrame(() => { clearTimeout(late); r(null) }) })
177
+ if (!alive()) return false
178
+ const busy = canvasCtl.cameraBusy()
179
+ if (busy) saw = true
180
+ if (!busy && (saw || performance.now() - since > 250) && n >= 2) return true
181
+ }
182
+ return false
183
+ }
184
+
185
+ const ack = (seq: number, outcome: 'shown' | 'notice') => {
186
+ const c = /(?:^|;\s*)mv_c=([\w-]+)/.exec(document.cookie)?.[1] ?? ''
187
+ void api('show/ack', { method: 'POST', headers: { 'content-type': 'application/json', 'x-mv-c': c }, body: JSON.stringify({ seq, page: PAGE_ID, outcome }) }).catch(() => {})
188
+ }
189
+
190
+ /** The tab to the front of the app's window (a server show): main checks the asking document and acts. */
191
+ const front = () => { try { APP?.front?.() } catch { /* the app went away under the page */ } }
192
+
193
+ /**
194
+ * A show command, from the dev server (`seq`) or the app's bridge. The app's `null` is a link that named no place this
195
+ * shell takes: the canvas's own board, by the same rule (moved to, or the notice over unsent words).
196
+ */
197
+ export async function showTarget(raw: unknown, from: ShowFrom): Promise<ShowResult> {
198
+ const seq = from === 'server' ? (raw as { seq?: unknown } | null)?.seq : undefined
199
+ if (from === 'server' && (typeof seq !== 'number' || !Number.isSafeInteger(seq) || seq < 1)) return 'bad'
200
+ const t: ShowTarget | 'landing' | null = from === 'app' && raw === null ? 'landing' : checkShowTarget(raw)
201
+ if (!t) return 'bad'
202
+ if (typeof seq === 'number') {
203
+ if (seq <= lastSeq) return 'stale'
204
+ lastSeq = seq
205
+ }
206
+ const n = ++current
207
+ if (booting) {
208
+ // the newest alone waits for the boot (an older deferred one is superseded: never answered)
209
+ deferred = { t, ...(typeof seq === 'number' ? { seq } : {}), from, n, nav: navNow(), hand: handNow() }
210
+ return 'deferred'
211
+ }
212
+ return apply(t, typeof seq === "number" ? seq : undefined, from, n)
213
+ }
214
+
215
+ /** A show applied: the notice over unsent words, or the move - answered, and the window forward, once it is on screen. */
216
+ async function apply(t: ShowTarget | 'landing', seq: number | undefined, from: ShowFrom, n: number): Promise<ShowResult> {
217
+ const notice = (): ShowResult => {
218
+ useShowNotice.setState({ notice: { title: t === 'landing' ? LANDING : titleOf(t), target: t, at: Date.now() } })
219
+ if (typeof seq === 'number') ack(seq, 'notice')
220
+ if (from === 'server') front()
221
+ return 'notice'
222
+ }
223
+ if (holdsWords()) return notice()
224
+ useShowNotice.setState({ notice: null })
225
+ const r = await go(t, n, false)
226
+ // words typed while it was on its way: the notice instead, nothing moved
227
+ if (r === 'blocked') return n === current ? notice() : 'stale'
228
+ // answered, and the window brought forward, once it is on screen: a newer show or a board that went is no "shown"
229
+ if (r === 'shown') {
230
+ if (typeof seq === 'number') ack(seq, 'shown')
231
+ if (from === 'server') front()
232
+ }
233
+ return r
234
+ }
235
+
236
+ /** The notice's Go: the human chose to move, words or not. */
237
+ export async function goNow(): Promise<ShowResult> {
238
+ const notice = useShowNotice.getState().notice
239
+ useShowNotice.setState({ notice: null })
240
+ if (!notice) return 'stale'
241
+ const r = await go(notice.target, ++current, true)
242
+ return r === 'blocked' ? 'stale' : r
243
+ }
244
+ export const dismissShow = (): void => { useShowNotice.setState({ notice: null }) }
245
+
246
+ /** A server seq the page knows (tests read where it stands). */
247
+ export const showState = () => ({ current, lastSeq })
248
+
249
+ // dev-only inspection hook for tests (never installed in published builds)
250
+ if (typeof window !== 'undefined' && import.meta.env.DEV) (window as unknown as { __mvShow: unknown }).__mvShow = { showTarget, goNow, dismissShow, state: showState, notice: () => useShowNotice.getState().notice }
@@ -1,13 +1,14 @@
1
1
  import { create } from 'zustand'
2
2
  import { ROUTE, slideSize } from '../const.ts'
3
3
  import { tidy, parseLayout, type BoardLayout, type TidyNode } from './tidy.ts'
4
- import { clearNoteHeights, noteHeight, noteReserve, notesCramped, scopeNotes, setNoteHeight } from './notes.ts'
4
+ import { clearNoteHeights, noteHeight, noteReserve, notesCramped, scopeNotes, setNoteHeight, tidyNodes } from './notes.ts'
5
5
  import { stableNodeKey } from './keys.ts'
6
6
  import { canvasCtl } from './canvas/ctl.ts'
7
7
  import { api, beforeResume, canvasStopped, holdsReload, lostInResume, mvFetch, noteUnsaved, onLinkNotice, savedInResume, scoped, STOPPED_WAY, withWs } from './api.ts'
8
8
  import { unsavedWhen, workChanged } from './unsaved.ts'
9
9
  import { nextSeq, PAGE_ID } from './recorder-seams.ts'
10
10
  import type { BoardWriter, HeldBy, LoadTrigger } from '../../shared/perf-records.ts'
11
+ import type { DeviceLook } from '../../shared/devices.ts'
11
12
  // @ts-expect-error virtual module provided by the plugin
12
13
  import shConfig from 'virtual:sh-config'
13
14
  // @ts-expect-error virtual module: null in dev; a published build inlines manifest+boards
@@ -128,9 +129,12 @@ export interface JamNote {
128
129
  /** earlier notices folded under this one - View walks through them */
129
130
  stack?: JamNote[]
130
131
  }
131
- export interface Toast { id: number; text: string; jam?: JamNote }
132
+ /** A plain notice's one action (spec 31 B.3: "Resolved 31 conversations · Undo"): what its click runs - which records
133
+ * its own command (`resolve-undo`). `id` names it on the notice (`data-toast`). */
134
+ export interface ToastAction { label: string; id: string; run: () => void }
135
+ export interface Toast { id: number; text: string; jam?: JamNote; action?: ToastAction }
132
136
 
133
- export const CONFIG: { viewports: Record<string, { width: number; height: number }>; themes: string[]; zoomSpeed?: number; noTheme: boolean; setup?: boolean; projectName?: string; branding?: boolean; jam?: { chime: boolean; capture: 'confirm' | 'at-once'; names?: boolean } | null; workspace?: string; version?: string } = shConfig
137
+ export const CONFIG: { viewports: Record<string, { width: number; height: number }>; devices?: Record<string, DeviceLook>; themes: string[]; zoomSpeed?: number; noTheme: boolean; setup?: boolean; projectName?: string; branding?: boolean; jam?: { chime: boolean; capture: 'confirm' | 'at-once'; names?: boolean } | null; workspace?: string; version?: string } = shConfig
134
138
 
135
139
  /** Invariant: `branding: false` strips every Marver mention - new chrome included. */
136
140
  export const BRANDING = CONFIG.branding !== false
@@ -173,8 +177,9 @@ export { cap, humanize } from './labels.ts'
173
177
  import { cap, humanize } from './labels.ts'
174
178
  import { canAutoReload } from './canvas/ready-watch.ts'
175
179
  import { pumpUpdates } from './canvas/updates.ts'
176
- import { archiveLast, buildTree, flatten, framesOn, labelOf, toWire, TREE_PROTOCOL, type TreeItem } from '../../shared/board-tree.ts'
180
+ import { archiveLast, buildTree, canvasLabel, flatten, framesOn, labelOf, toWire, TREE_PROTOCOL, type TreeItem } from '../../shared/board-tree.ts'
177
181
  import { UNPLACED } from './hash.ts'
182
+ import { placeNewcomers } from '../../shared/auto-place.ts'
178
183
  import type { BoardType, StatusWord } from '../../shared/board-types.ts'
179
184
  import type { Phase, Status } from '../../shared/status.ts'
180
185
  import { isNew, type Marks } from '../../shared/marks.ts'
@@ -259,7 +264,7 @@ export async function fetchMembership(): Promise<{ boards: { name: string; frame
259
264
  * re-render on change), else the Title-Cased slug. */
260
265
  export const boardLabel = (n: string) => (n === UNPLACED ? 'Not on a board' : labelOf(n, useStore.getState().boardTitles[n]))
261
266
  /** The canvas's name, as the sidebar heads it: the project's (share.name, else the repo folder). */
262
- export const CANVAS_NAME = CONFIG.projectName ? humanize(CONFIG.projectName) : 'Marver'
267
+ export const CANVAS_NAME = CONFIG.projectName ? canvasLabel(CONFIG.projectName) : 'Marver'
263
268
  /** The browser tab: the board, then the canvas - "Start here - Acme Studio" - so a row of canvas tabs
264
269
  * says which project each one is (it said "- Marver" on all of them). */
265
270
  export const tabTitle = (board: string | null | undefined): string => (board ? `${boardLabel(board)} - ${CANVAS_NAME}` : CANVAS_NAME)
@@ -318,16 +323,7 @@ const HEADER = 28
318
323
  * tidy keeps the scene reserve on the first node it places), and the measured height of the
319
324
  * column standing there, so a note longer than its frame gets its room below as well. */
320
325
  export function tidyInput(nodes: readonly Node[], manifest: Manifest | null): TidyNode[] {
321
- const entryOf = (id: string) => manifest?.frames.find((f) => f.id === id)
322
- const sceneNote = (scene: string) => !!manifest?.scenes.find((s) => s.name === scene)?.note
323
- return nodes.map((n) => {
324
- const f = entryOf(n.frame)
325
- const scene = f?.scene ?? ''
326
- return {
327
- key: n.key, frame: n.frame, scene, group: f?.variantGroup, variant: f?.variant, w: n.w, h: n.h + HEADER,
328
- noteW: noteReserve(!!f?.note, false), sceneNoteW: noteReserve(false, sceneNote(scene)), noteH: noteHeight(n.key),
329
- }
330
- })
326
+ return tidyNodes(nodes, manifest) // notes.ts: the deck PDF's plan lays boards out with the same input
331
327
  }
332
328
  let toastSeq = 0
333
329
  const nodeKey = () => 'n_' + Math.random().toString(36).slice(2, 8)
@@ -745,7 +741,10 @@ interface State {
745
741
  togglePanel(): void
746
742
  setTheme(theme: string): void
747
743
  runTidy(): void
748
- toast(text: string): void
744
+ /** a plain notice, gone after 4 s - or `ms`; one with an `action` (Undo) stays its own while it shows */
745
+ toast(text: string, action?: ToastAction, ms?: number): void
746
+ /** take a plain notice down now (its action ran) */
747
+ dropToast(id: number): void
749
748
  jamToast(note: JamNote): void
750
749
  /** a jam card failed - one notice, with Retry (spec 27: only a question or a failure interrupts) */
751
750
  jamFailed(cards: { id: string; rev: number; board: string; thread?: string; frames: string[]; note?: string; batch?: string }[]): void
@@ -1159,7 +1158,6 @@ export const useStore = create<State>((set, get) => {
1159
1158
  // (the old published everything-board bug: frames created after the board file was last
1160
1159
  // saved piled up at the origin)
1161
1160
  if (boardAuto) {
1162
- const placed = new Set(nodes.map((n) => n.frame))
1163
1161
  // newcomers get deterministic keys too - on a published auto board
1164
1162
  // this path mints EVERY key, every visit, and comments anchor to them
1165
1163
  const haveKeys = new Set(nodes.map((n) => n.key))
@@ -1169,24 +1167,10 @@ export const useStore = create<State>((set, get) => {
1169
1167
  haveKeys.add(k)
1170
1168
  return k
1171
1169
  }
1172
- let maxX = nodes.reduce((a, n) => Math.max(a, n.x + n.w), 0)
1173
- for (const f of manifest.frames) {
1174
- if (placed.has(f.id)) continue
1175
- placed.add(f.id)
1176
- const d = defaultSize(f)
1177
- const vp = deviceView ? CONFIG.viewports[deviceView] : null
1178
- const w = vp?.width ?? d.w, h = vp?.height ?? d.h
1179
- let x: number, y: number
1180
- const sibling = f.variantGroup
1181
- ? nodes.filter((n) => manifest.frames.find((m) => m.id === n.frame)?.variantGroup === f.variantGroup)
1182
- .reduce<Node | null>((a, n) => (!a || n.x + n.w > a.x + a.w ? n : a), null)
1183
- : null
1184
- if (sibling) { x = sibling.x + sibling.w + Math.max(140, sibling.w * 0.12); y = sibling.y }
1185
- else { x = nodes.length ? maxX + 96 : 0; y = 0 }
1186
- const node: Node = { key: mint(f.id), frame: f.id, x, y, w, h, theme: resolveTheme(f), status: 'loading', ...(f.contentWidth ? { sizeMode: (vp ? 'device' : 'auto') as Node['sizeMode'] } : {}) }
1187
- nodes.push(node)
1188
- maxX = Math.max(maxX, x + w)
1189
- }
1170
+ // the placement rule the deck PDF's plan shares (src/shared/auto-place.ts)
1171
+ const vp = deviceView ? CONFIG.viewports[deviceView] : null
1172
+ placeNewcomers(nodes, manifest.frames, (f) => { const d = defaultSize(f); return { w: vp?.width ?? d.w, h: vp?.height ?? d.h } },
1173
+ (f, x, y, w, h): Node => ({ key: mint(f.id), frame: f.id, x, y, w, h, theme: resolveTheme(f), status: 'loading', ...(f.contentWidth ? { sizeMode: (vp ? 'device' : 'auto') as Node['sizeMode'] } : {}) }))
1190
1174
  }
1191
1175
  // published: re-apply this visit's pins and content sizes over the inlined data
1192
1176
  if (DATA && nodes.length) {
@@ -1968,11 +1952,12 @@ export const useStore = create<State>((set, get) => {
1968
1952
  })))
1969
1953
  scheduleSave()
1970
1954
  },
1971
- toast(text) {
1955
+ toast(text, action, ms) {
1972
1956
  const id = ++toastSeq
1973
- set((s) => ({ toasts: [...s.toasts, { id, text }] }))
1974
- setTimeout(() => set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })), 4000)
1957
+ set((s) => ({ toasts: [...s.toasts, { id, text, ...(action ? { action } : {}) }] }))
1958
+ setTimeout(() => set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })), ms ?? 4000)
1975
1959
  },
1960
+ dropToast(id) { set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })) },
1976
1961
  /** A Live Jam reply notification: persistent (no auto-dismiss), one per thread (a newer reply
1977
1962
  * supersedes), capped so the stack stays small. */
1978
1963
  jamToast(note) {
@@ -635,6 +635,8 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
635
635
  cursor: pointer; text-align: left }
636
636
  .sh-menu button:hover { background: var(--glass-hover) }
637
637
  .sh-menu button span { flex: 1; text-transform: capitalize }
638
+ /* a device's label is written as it should read ("iPad landscape", spec 31 F.2) - never re-capitalised */
639
+ .sh-menu button span.dev-label { text-transform: none }
638
640
  /* the sidebar right-click menu keeps its labels verbatim (they match the toolbar exactly);
639
641
  it scrolls rather than overflowing the window when the folder list grows long */
640
642
  .sh-ctxmenu { max-height: calc(100vh - 16px - var(--mv-top, 0px)); max-width: 240px; overflow-y: auto; scrollbar-width: thin }
@@ -712,6 +714,9 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
712
714
  border: 0; background: none; border-radius: 999px; color: var(--glass-ink-3); cursor: pointer;
713
715
  transition: color .15s, background .15s }
714
716
  .sh-update .x:hover { background: var(--glass-hover); color: var(--glass-ink) }
717
+ /* `marver show` over unsent words (spec 31 D3): above the update pill, so both can be up */
718
+ .sh-show-notice { bottom: calc(var(--edge) + 50px); z-index: 33 } /* over Play (30, 31) and the toasts (32): a draft typed in Play keeps its notice in view */
719
+ .sh-show-notice .cmd code { color: var(--glass-ink) }
715
720
 
716
721
  /* bottom-RIGHT now: jam reply pills live here; plain toasts ride along */
717
722
  .sh-toasts { position: absolute; right: var(--edge); bottom: var(--edge); z-index: 32; display: flex;
@@ -719,10 +724,24 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
719
724
  .sh-toast { display: flex; align-items: center; gap: 6px; font: 500 12px -apple-system, system-ui, sans-serif;
720
725
  color: var(--glass-ink-2); border-radius: 999px; padding: 7px 13px }
721
726
  .sh-toast svg { color: var(--glass-good); flex: none }
727
+ /* a notice's one action (spec 31 B.3: Undo) */
728
+ .sh-toast-act { margin-left: 6px; padding: 2px 9px; border: 0; border-radius: 999px; cursor: pointer;
729
+ background: var(--glass-hover); color: var(--glass-ink); font: 600 12px -apple-system, system-ui, sans-serif }
730
+ .sh-toast-act:hover { background: color-mix(in srgb, var(--glass-ink) 14%, transparent) }
722
731
  /* the jam pill's svgs are NOT the toast checkmark: the mark stays white/90 on blue, the X keeps
723
732
  its own muted ink - undo the blanket green above */
724
733
  .sh-toast.jam svg { color: currentColor }
725
734
  .sh-toast-more { color: var(--glass-ink-3); font-size: 11px; padding: 2px 10px }
735
+ /* a deck PDF being made (spec 31): its board and page, a thin progress bar, Cancel */
736
+ .sh-toast.sh-pdf-notice { gap: 8px; padding: 7px 8px 7px 13px; pointer-events: auto }
737
+ .sh-toast.sh-pdf-notice svg { color: currentColor }
738
+ .sh-toast.sh-pdf-notice b { font-weight: 600; color: var(--glass-ink) }
739
+ .sh-pdf-notice .bar { width: 56px; height: 3px; border-radius: 2px; background: var(--glass-line, rgba(127,127,127,.25)); overflow: hidden; flex: none }
740
+ .sh-pdf-notice .bar i { display: block; height: 100%; background: currentColor; opacity: .7; transition: width .3s }
741
+ .sh-pdf-notice button { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 999px; border: 0; background: transparent; color: var(--glass-ink-3); cursor: pointer }
742
+ .sh-pdf-notice button:hover { background: var(--glass-hover, rgba(127,127,127,.15)); color: var(--glass-ink) }
743
+ /* app 1.0.1: the held file's Download, a word not an icon */
744
+ .sh-pdf-notice button.go { width: auto; padding: 0 9px; font: inherit; font-weight: 600; color: var(--glass-ink) }
726
745
 
727
746
  /* the Live Jam reply pill: our full glass treatment, full radius, one row (§9) */
728
747
  .sh-toast.jam { gap: 12px; padding: 12px 12px 12px 14px; width: 380px; max-width: 100%; border-radius: 999px;
@@ -773,8 +792,13 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
773
792
 
774
793
  /* ---- Play mode: near-black stage, one centered device, auto-hiding bar.
775
794
  Fixed dark palette - the backdrop never follows the board theme, so no tokens here. */
776
- .sh-play { position: absolute; inset: 0; z-index: 30; background: #0a0a0b; display: flex; padding-top: var(--mv-top, 0px);
777
- align-items: center; justify-content: center; animation: sh-play-in .28s ease-out; cursor: auto }
795
+ .sh-play { position: absolute; inset: 0; z-index: 30; background: #0a0a0b; display: flex; padding-top: var(--mv-play-top, var(--mv-top, 0px));
796
+ align-items: center; justify-content: center; animation: sh-play-in .28s ease-out; cursor: auto;
797
+ /* spec 32 C5.1 (MOTION, src/shared/immersive.ts): the play inset goes in 320 ms and comes back in 300 ms */
798
+ transition: padding-top 300ms cubic-bezier(.2, .8, .2, 1) }
799
+ :root.mv-immersive .sh-play { transition: padding-top 320ms cubic-bezier(.2, .8, .2, 1) }
800
+ /* spec 32 C5.2: while the stage FLIPs, the device's own size transition holds off - one animation resizes it */
801
+ .sh-play.flip .dev { transition: none }
778
802
  @keyframes sh-play-in { from { opacity: 0 } }
779
803
  /* the device wears the frame-node card language: same theme border tokens, the same
780
804
  masked 1px edge-light gradient ring (glass catching light), and a real drop shadow
@@ -932,15 +956,29 @@ body.sh-kbd .sh-app :focus-visible { outline: 2px solid var(--accent); outline-o
932
956
  /* Hide-UI: one binary body class (canvas + prototype) drops all operating chrome. Not
933
957
  persisted - a page refresh always restores it. Comment pins/threads (the review
934
958
  annotations) stay; only the marver chrome hides, for a clean point-and-shoot frame. */
935
- body.sh-hide-ui .sh-pill,
936
- body.sh-hide-ui .sh-pill-fab,
959
+ body.sh-hide-ui .sh-pill:not(.sh-play-pill),
960
+ body.sh-hide-ui .sh-pill-fab:not(.sh-play *),
937
961
  body.sh-hide-ui .sh-panel,
938
962
  body.sh-hide-ui .sh-fab,
939
963
  body.sh-hide-ui .sh-ctx,
940
964
  body.sh-hide-ui .sh-update,
941
965
  body.sh-hide-ui .sh-toasts,
942
- body.sh-hide-ui .sh-banner:not(.sh-stopped), /* a stopped canvas stays said: the page holds what only it has */
943
- body.sh-hide-ui .sh-play-nav { display: none !important }
966
+ body.sh-hide-ui .sh-banner:not(.sh-stopped) { display: none !important } /* a stopped canvas stays said: the page holds what only it has */
967
+
968
+ /* spec 32 C5.3 (MOTION.out.pills 160 ms, MOTION.back.pills 200 ms): in play the pills, their fab, the navigator and the
969
+ minimal deck's progress strip fade instead of vanishing - out up (the pills) or down (the nav, the strip), then
970
+ hidden from the pointer and from view; back at once into view, then up to full.
971
+ The pills' 6 px goes on `translate`, so `transform` keeps the pill/fab morph (`.closed`, `.hidden`) and its --morph time
972
+ while the fade's own move takes MOTION's 160 ms out and 200 ms back, ease. */
973
+ .sh-play .sh-play-pill, .sh-play .sh-pill-fab { transition: opacity 200ms ease, translate 200ms ease, transform var(--morph), visibility 0s }
974
+ .sh-play-nav, .sh-slides-strip { transition: opacity 200ms ease, transform 200ms ease, visibility 0s }
975
+ body.sh-hide-ui .sh-play .sh-play-pill, body.sh-hide-ui .sh-play .sh-pill-fab, body.sh-hide-ui .sh-play-nav, body.sh-hide-ui .sh-slides-strip {
976
+ opacity: 0; pointer-events: none; visibility: hidden;
977
+ transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms }
978
+ body.sh-hide-ui .sh-play .sh-play-pill, body.sh-hide-ui .sh-play .sh-pill-fab {
979
+ translate: 0 -6px; transition: opacity 160ms ease, translate 160ms ease, transform var(--morph), visibility 0s linear 160ms }
980
+ body.sh-hide-ui .sh-play-nav { transform: translateY(6px) }
981
+ body.sh-hide-ui .sh-slides-strip { transform: translateX(-50%) translateY(6px) }
944
982
 
945
983
  /* the prototype pill reuses the shared pill LAYOUT but wears the discreet DARK skin of the
946
984
  bottom-left navigator (not the bright canvas glass), so it recedes into the near-black
@@ -1184,6 +1222,23 @@ body.sh-hide-ui .sh-play-nav { display: none !important }
1184
1222
  color: var(--glass-ink); white-space: pre-wrap; overflow-wrap: break-word }
1185
1223
  .cm-scroll > .cm-body { margin-top: -10px } /* pulls against the scroller's 12px gap -> the same 2px replies get */
1186
1224
  .cm-msg { display: flex; flex-direction: column; gap: 2px }
1225
+ /* spec 31 C.1: a card's words can be selected and copied - the pan/zoom wrapper sets user-select: none on everything
1226
+ inside it (Canvas.tsx), and Play's stage overlay too; the card's own controls stay unselectable */
1227
+ .cm-card, .sh-play-comments .cm-card { user-select: text; -webkit-user-select: text; cursor: auto }
1228
+ .cm-card button, .cm-card .cm-actions, .cm-card header .dim, .cm-card .cm-tools { user-select: none; -webkit-user-select: none }
1229
+ /* spec 31 C.3-C.4: your own message's Edit and Delete - quiet until the message is hovered */
1230
+ .cm-card .cm-tools { margin-left: auto; display: inline-flex; gap: 2px; opacity: 0; transition: opacity .12s }
1231
+ .cm-card header:hover .cm-tools, .cm-card .cm-tools:focus-within, .cm-msg:hover .cm-tools { opacity: 1 }
1232
+ @media (hover: none) { .cm-card .cm-tools { opacity: 1 } }
1233
+ .cm-tool { height: 20px; padding: 0 6px; border: 0; border-radius: 6px; background: none; cursor: pointer;
1234
+ color: var(--glass-ink-3); font: 500 11.5px -apple-system, system-ui, sans-serif }
1235
+ .cm-tool:hover { background: var(--glass-hover); color: var(--glass-ink) }
1236
+ .cm-tool.danger { color: var(--mk-ask) }
1237
+ .cm-card .cm-edited { font-style: italic }
1238
+ .cm-editing { padding-left: 33px }
1239
+ .cm-confirm { display: flex; align-items: center; gap: 4px; padding-left: 33px; font-size: 12px; color: var(--glass-ink-2) }
1240
+ .cm-confirm span { flex: 1 }
1241
+ .cm-card .cm-deleted { color: var(--glass-ink-3); font-style: italic; padding-left: 0 }
1187
1242
  .cm-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
1188
1243
  border: 0; border-radius: 8px; background: none; color: var(--glass-ink-3); cursor: pointer;
1189
1244
  transition: background .12s, color .12s }
@@ -2059,3 +2114,10 @@ textarea.jm-field:focus { border-color: transparent; box-shadow: 0 0 0 1px var(-
2059
2114
  .jm-count { cursor: pointer }
2060
2115
  /* in play the Jam button's crossed microphone wears the dark pill's ink (the canvas grey would vanish) */
2061
2116
  .sh-play-pill .sh-pill-btn.jm-jam .jm-nomic { color: inherit }
2117
+
2118
+ /* spec 31 F.1: a device's own icon - its sanitized SVG as a mask, filled with the ink it sits in */
2119
+ .sh-dev-mask { display: inline-block; flex: none; background-color: currentColor;
2120
+ -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
2121
+ -webkit-mask-position: center; mask-position: center }
2122
+ /* a Jam view line's device, as it reads, with its icon */
2123
+ .jm-dev { display: inline-flex; align-items: center; gap: 3px; vertical-align: -2px }