@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
@@ -6,14 +6,15 @@
6
6
  * overlap (pin-layout.ts places them).
7
7
  */
8
8
  import { TOP } from './inset.ts'
9
- import { useEffect, useMemo, useRef, useState } from 'react'
9
+ import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
10
10
  import { createPortal } from 'react-dom'
11
11
  import { avatarFallback, useComments } from './comments-store.ts'
12
12
  import { api } from './api.ts'
13
13
  import { CONFIG, useStore, type Node } from './store.ts'
14
14
  import { threadHostKey } from './keys.ts'
15
15
  import { isNoteAnchor, resolveNoteAnchor, useNotes } from './notes.ts'
16
- import { canvasCtl } from './canvas/ctl.ts'
16
+ import { bootCancelled, canvasCtl } from './canvas/ctl.ts'
17
+ import { navigatedByHand } from './goto.ts'
17
18
  import { MARKER, placeMarkers, type Placed } from './pin-layout.ts'
18
19
  import { bootHash, buildHash, parseHash, writeHash } from './hash.ts'
19
20
  import { isLegacyLink } from './legacy-links.ts'
@@ -304,7 +305,7 @@ export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: s
304
305
  if (!engaged && open.length) {
305
306
  return (
306
307
  <button className={`cm-stack sh-no-pan${open.some((t) => alertIds.has(t.id)) ? ' mention' : ''}`}
307
- onClick={(e) => { e.stopPropagation(); cmd('thread-open', { via: 'click', in: 'shell', frame: frameId }); useStore.getState().select(node.key); const hit = open.find((t) => alertIds.has(t.id)) ?? open[0]; if (hit) setActive(hit.id) }}>
308
+ onClick={(e) => { e.stopPropagation(); cmd('thread-open', { via: 'click', in: 'shell', frame: frameId }); navigatedByHand(); useStore.getState().select(node.key); const hit = open.find((t) => alertIds.has(t.id)) ?? open[0]; if (hit) setActive(hit.id) }}>
308
309
  <MarkerFace threads={open} />
309
310
  </button>
310
311
  )
@@ -461,7 +462,7 @@ function AgentMetaTip({ meta }: { meta?: AgentMeta }) {
461
462
  * human messages keep their avatar + name. While the dev profile is still UNSET, every own
462
463
  * message avatar invites editing on hover (discoverability); once set, only the composer's
463
464
  * avatar is the door. */
464
- function MessageHead({ author, agent, agentMeta, ts, board, eventId }: { author?: Thread['author']; agent?: boolean; agentMeta?: AgentMeta; ts: number; board?: string; eventId?: string }) {
465
+ function MessageHead({ author, agent, agentMeta, ts, board, eventId, edited, tools }: { author?: Thread['author']; agent?: boolean; agentMeta?: AgentMeta; ts: number; board?: string; eventId?: string; edited?: number; tools?: ReactNode }) {
465
466
  const me = useComments((s) => s.me)
466
467
  const local = useComments((s) => s.local)
467
468
  const connected = useComments((s) => s.connected)
@@ -484,7 +485,9 @@ function MessageHead({ author, agent, agentMeta, ts, board, eventId }: { author?
484
485
  {unset && own ? <EditableAvatar author={author} size={24} /> : <Avatar author={author} size={24} />}
485
486
  <b>{shown?.name ?? 'Someone'}</b>
486
487
  <span className="dim">{rel(ts)}</span>
488
+ {edited ? <span className="dim cm-edited" title={new Date(edited).toLocaleString()}>edited</span> : null}
487
489
  <TagStatus board={board} eventId={eventId} harness={HARNESS} />
490
+ {tools}
488
491
  </header>
489
492
  )
490
493
  }
@@ -496,7 +499,7 @@ function CommentInput({ value, onChange, onSubmit, onCancel, placeholder, autoFo
496
499
  /** ends `h` (spec 30): a person typing has got a draft, so the command starts here, at ⏎ or send */
497
500
  onSubmit: (h: CmdHandle) => void | Promise<unknown>
498
501
  onCancel: () => void; placeholder: string; autoFocus?: boolean; sendLabel: string; owner: boolean
499
- sendCmd: 'comment-send' | 'comment-reply'; frame?: string
502
+ sendCmd: 'comment-send' | 'comment-reply' | 'comment-edit-save'; frame?: string
500
503
  }) {
501
504
  const ref = useRef<HTMLTextAreaElement>(null)
502
505
  const hlRef = useRef<HTMLDivElement>(null)
@@ -685,6 +688,40 @@ export function ThreadCard({ thread, at, bounds, nodeKey, side = 'r', flank, sta
685
688
  const [text, setText] = useState('')
686
689
  const [copied, setCopied] = useState(false)
687
690
  const copyTimer = useRef<ReturnType<typeof setTimeout>>(undefined)
691
+ // your own messages (spec 31 C.3-C.4): the one being edited, with its words; the one asking "delete?"
692
+ const [editing, setEditing] = useState<{ id: string; text: string } | null>(null)
693
+ const [asking, setAsking] = useState<string | null>(null)
694
+ useComments((s) => s.ownership) // a read of who owns what redraws the tools
695
+ const canDelete = useComments((s) => s.local || s.caps.delete) // an older published server takes no delete
696
+ const mine = (m: { id: string; author?: { id?: string }; agent?: boolean }) => canComment && useComments.getState().isMine(thread.board, m)
697
+ const how = (): CmdOpts => ({ via: 'click', in: 'shell', frame: thread.frame })
698
+ const tools = (m: { id: string; author?: { id?: string }; agent?: boolean; body?: string }) => !mine(m) || editing?.id === m.id ? null : (
699
+ <span className="cm-tools">
700
+ {!(m.id === thread.id && thread.capture) && <button className="cm-tool" data-edit={m.id} onClick={() => { cmd('comment-edit', how()); setAsking(null); setEditing({ id: m.id, text: m.body ?? '' }) }}>Edit</button>}
701
+ {canDelete && <button className="cm-tool" data-delete={m.id} onClick={() => { cmd('comment-delete-ask', how()); setEditing(null); setAsking(m.id) }}>Delete</button>}
702
+ </span>
703
+ )
704
+ /** A message's words: as they are, in their editor, or under the "delete?" question. */
705
+ const words = (m: { id: string; body?: string; author?: Thread['author'] }, root: boolean, shown: ReactNode) => {
706
+ if (editing?.id === m.id) return (
707
+ <div className="cm-editing">
708
+ <CommentInput value={editing.text} onChange={(v) => setEditing({ id: m.id, text: v })} placeholder="Edit your comment…" autoFocus sendLabel="Save" owner={local} sendCmd="comment-edit-save" frame={thread.frame}
709
+ onSubmit={async (h) => { const sent = editing.text; if (sent.trim() === (m.body ?? '').trim()) { h.done(); setEditing(null); return } if (await useComments.getState().edit(thread.id, m.id, sent, h)) setEditing((cur) => (cur?.id === m.id ? null : cur)) }}
710
+ onCancel={() => setEditing(null)} />
711
+ </div>
712
+ )
713
+ if (asking !== m.id) return shown
714
+ return (
715
+ <>
716
+ {shown}
717
+ <div className="cm-confirm" data-confirm-delete={m.id}>
718
+ <span>Delete this {root ? 'comment' : 'reply'}?{root && thread.replies.length ? ' Its replies stay.' : ''}</span>
719
+ <button className="cm-tool danger" onClick={() => { const h = cmd('comment-delete', how()); setAsking(null); void useComments.getState().remove(thread.id, m.id, h) }}>Delete</button>
720
+ <button className="cm-tool" onClick={() => { cmd('comment-delete-cancel', how()); setAsking(null) }}>Cancel</button>
721
+ </div>
722
+ </>
723
+ )
724
+ }
688
725
  useEffect(() => () => clearTimeout(copyTimer.current), [])
689
726
  // Canvas: the card is a WORLD OBJECT parked beside its frame - it stays put (panning moves
690
727
  // frame + card together, never following the viewport). Zoom scales it with a CLAMP
@@ -820,16 +857,23 @@ export function ThreadCard({ thread, at, bounds, nodeKey, side = 'r', flank, sta
820
857
  {/* "there is more": the scroller MASKS its own content at the overflowing edge - a soft fade
821
858
  of the text itself, not a paint layer over the glass */}
822
859
  <div className={`cm-scroll${shadows.top ? ' fade-top' : ''}${shadows.bot ? ' fade-bot' : ''}`} ref={scrollRef} onScroll={syncShadows}>
823
- <MessageHead author={thread.author} agent={thread.agent} agentMeta={thread.agentMeta} ts={thread.ts} board={thread.board} eventId={eventOf(thread.id)} />
824
- {/* a capture's comment reads as a capture: a labelled block, never a typed comment (spec 27) */}
825
- {thread.capture
826
- ? <CaptureBlock id={thread.capture} facts={thread.facts} words={thread.body ?? ''} />
827
- : <CommentBody body={thread.body} owner={isOwner(thread.author)} />}
860
+ {/* a deleted first comment keeps its replies under a placeholder: nothing of what was said, nor who said it */}
861
+ {thread.deleted
862
+ ? <p className="cm-body cm-deleted" data-deleted>Comment deleted</p>
863
+ : <>
864
+ <MessageHead author={thread.author} agent={thread.agent} agentMeta={thread.agentMeta} ts={thread.ts} board={thread.board} eventId={eventOf(thread.id)}
865
+ edited={thread.edited} tools={tools(thread)} />
866
+ {/* a capture's comment reads as a capture: a labelled block, never a typed comment (spec 27) - yours to edit or
867
+ delete like any message (deleting it withdraws a capture not sent yet) */}
868
+ {words(thread, true, thread.capture
869
+ ? <CaptureBlock id={thread.capture} facts={thread.facts} words={thread.body ?? ''} />
870
+ : <CommentBody body={thread.body} owner={isOwner(thread.author)} />)}
871
+ </>}
828
872
  {/* replies repeat the root's exact message shape (Figma's pattern) - only the icons differ */}
829
873
  {thread.replies.map((r) => (
830
- <div key={r.id} className="cm-msg">
831
- <MessageHead author={r.author} agent={r.agent} agentMeta={r.agentMeta} ts={r.ts} board={thread.board} eventId={eventOf(r.id)} />
832
- <CommentBody body={r.body} owner={isOwner(r.author)} />
874
+ <div key={r.id} className="cm-msg" data-msg={r.id}>
875
+ <MessageHead author={r.author} agent={r.agent} agentMeta={r.agentMeta} ts={r.ts} board={thread.board} eventId={eventOf(r.id)} edited={r.edited} tools={tools(r)} />
876
+ {words(r, false, <CommentBody body={r.body} owner={isOwner(r.author)} />)}
833
877
  {/* a jam job changed a shared file it was not given: one line, so the reply says it (spec 27) */}
834
878
  {r.agent && r.alsoChanged?.length ? <div className="cm-also">Also changed {r.alsoChanged.map((f) => f.split('/').pop()).join(', ')}</div> : null}
835
879
  </div>
@@ -1041,7 +1085,8 @@ export function CommentsController() {
1041
1085
  if (!active) return
1042
1086
  const onDown = (e: PointerEvent) => {
1043
1087
  const t = e.target instanceof Element ? e.target : null
1044
- if (t?.closest('.cm-card, .cm-pin, .cm-stack, .cm-modal')) return
1088
+ // the show notice (spec 31 D3) too: it is up because words wait unsent here - its Go and × never close them
1089
+ if (t?.closest('.cm-card, .cm-pin, .cm-stack, .cm-modal, .sh-show-notice')) return
1045
1090
  if (useComments.getState().active) cmd('thread-close', { via: 'click', in: 'shell' }) // silent when none is open
1046
1091
  useComments.getState().setActive(null)
1047
1092
  }
@@ -1064,8 +1109,9 @@ export function CommentsController() {
1064
1109
  // Consumed only on a successful find: the controller's first effect fires with
1065
1110
  // the pre-boot board (child effects run before the parent's boot effect), and
1066
1111
  // burning the flag on that empty pass would eat the link.
1067
- if (bootThreadConsumed || !bootHash.c) return
1068
- if (revealThread(bootHash.c)) bootThreadConsumed = true
1112
+ // ...unless a show applied meanwhile (spec 31 D3): the camera is the show's, the boot link's thread gives way
1113
+ if (bootThreadConsumed || !bootHash.c || bootCancelled()) return
1114
+ if (revealThread(bootHash.c, () => !bootCancelled())) bootThreadConsumed = true
1069
1115
  })
1070
1116
  return live(board)
1071
1117
  }, [board])
@@ -1102,3 +1148,18 @@ export function CommentsController() {
1102
1148
 
1103
1149
  return <IdentityDialog />
1104
1150
  }
1151
+
1152
+ /** ⌘A inside a comment card (spec 31 C.1): its messages' text, never every frame - when the selection or the focus is
1153
+ * in a card (not in its composer, which keeps the field's own ⌘A). True when it took the key. */
1154
+ export function cardSelectAll(): boolean {
1155
+ const sel = window.getSelection()
1156
+ const at = (n: globalThis.Node | null | undefined) => (n instanceof Element ? n : n?.parentElement)?.closest('.cm-card') ?? null
1157
+ const card = at(document.activeElement !== document.body ? document.activeElement : null) ?? at(sel?.anchorNode)
1158
+ const text = card?.querySelector('.cm-scroll')
1159
+ if (!card || !text || !sel) return false
1160
+ const range = document.createRange()
1161
+ range.selectNodeContents(text)
1162
+ sel.removeAllRanges()
1163
+ sel.addRange(range)
1164
+ return true
1165
+ }
@@ -11,14 +11,18 @@
11
11
  * next) stays prototype-only.
12
12
  */
13
13
  import { setStageSize } from './stage-size.ts'
14
- import { usable } from './inset.ts'
14
+ import { onTopChange, usable } from './inset.ts'
15
+ import { onImmersiveChange, tight as tightNow } from './immersive.ts'
16
+ import { MOTION } from '../../shared/immersive.ts'
15
17
  import { frameLoaded, frameReady, onFrameMessage, stageNavigated } from './jam-capture.ts'
16
18
  import { jamKey } from './jam-keys.ts'
17
19
  import { letGoOfTile } from './jam-state.ts'
18
20
  import { JamButton } from './jam-session.tsx'
19
- import { useEffect, useRef, useState } from 'react'
21
+ import { useEffect, useLayoutEffect, useRef, useState } from 'react'
20
22
  import { useStore, BOARD_POLICY, BRANDING, CONFIG, PUBLISHED, SOURCE_REVEALED, boardLabel, boardLocked, cap, fetchBoardNames, modeAllowed, playsAsSlides, SLIDE_INTRINSIC, stoppedFor, type Node } from './store.ts'
21
23
  import { deckOrder } from './play-order.ts'
24
+ import { boardOrder, presentDevice } from '../../shared/export-plan.ts'
25
+ import { exportPdf } from './pdf-export.tsx'
22
26
  import { NO_COMMENTS_HERE, useComments } from './comments-store.ts'
23
27
  import { UNPLACED } from './hash.ts'
24
28
  import { isNoteAnchor } from './notes.ts'
@@ -29,12 +33,13 @@ import { canvasCtl } from './canvas/ctl.ts'
29
33
  import { recorder } from './recorder.ts'
30
34
  import { perfSeams } from './recorder-seams.ts'
31
35
  import { cmd, endAfterFrames, endOnStage, keysOf, type CmdHandle, type CmdOpts, type CmdName } from './commands.ts'
32
- import { revealFrame, switchFor } from './goto.ts'
36
+ import { navigatedByHand, revealFrame, switchFor } from './goto.ts'
33
37
  import { Tip } from './Tip.tsx'
34
38
  import { keyAllowed } from '../frame-host/keys.js'
35
39
  import { CommentButton, DevicePicker, HideUIButton, isHideUI, LaserButton, Popover, ThemePicker, toggleHideUI, usePopover } from './Toolbar.tsx'
36
- import { DraftComposer, Pins, placePins, ThreadCard } from './Comments.tsx'
37
- import { ArrowLeftIcon, ArrowRightIcon, BrowsersIcon, CaretIcon, CheckIcon, GridIcon, PanelFilledIcon, PanelHollowIcon, ParallelogramDuoIcon, ReloadIcon, SpecDocIcon } from './icons.tsx'
40
+ import { cardSelectAll, DraftComposer, Pins, placePins, ThreadCard } from './Comments.tsx'
41
+ import { ArrowLeftIcon, ArrowRightIcon, BrowsersIcon, CaretIcon, CheckIcon, ExportIcon, GridIcon, PanelFilledIcon, PanelHollowIcon, ParallelogramDuoIcon, ReloadIcon, SpecDocIcon } from './icons.tsx'
42
+ import { deviceLabel } from './devices.tsx'
38
43
 
39
44
  const commentsStore = () => useComments.getState()
40
45
 
@@ -42,16 +47,8 @@ const commentsStore = () => useComments.getState()
42
47
  * documents and cannot mount into the persistent chain), deduped. */
43
48
  function playList(): string[] {
44
49
  const s = useStore.getState()
45
- const seen = new Set<string>()
46
- const out: string[] = []
47
- for (const n of s.nodes) {
48
- if (n.missing || seen.has(n.frame)) continue
49
- const f = s.frameFor(n)
50
- if (!f || f.kind !== 'tsx') continue
51
- seen.add(n.frame)
52
- out.push(n.frame)
53
- }
54
- return out
50
+ // the export plan's board order (spec 31 #2): the PDF prints the same list, html frames included
51
+ return boardOrder(s.nodes, (n) => s.frameFor(n), { html: false }).map((n) => n.frame)
55
52
  }
56
53
 
57
54
  /** Slides mode (v1.5): the deck's play order is the BOARD's reading order -
@@ -108,11 +105,10 @@ export function enterPlay(over?: { at?: string; device?: string; theme?: string
108
105
  ?? (overAt ? undefined : selNode ?? s.nodes.find((n) => list.includes(n.frame)))
109
106
  const at = overAt ?? node!.frame
110
107
  const frame = s.manifest?.frames.find((f) => f.id === at)
111
- // device: the link's; else the node's width names it; else the frame's declared viewport
112
- const names = Object.keys(CONFIG.viewports)
108
+ // device: the link's; else the export plan's rule (spec 31 #2) - the node's width names it, else the frame's
109
+ // declared viewport, else the first
113
110
  const device = (over?.device && (CONFIG.viewports[over.device] || over.device === 'fill') ? over.device : undefined)
114
- ?? (node ? names.find((v) => CONFIG.viewports[v].width === node.w) : undefined)
115
- ?? (frame?.viewport && CONFIG.viewports[frame.viewport] ? frame.viewport : names[0])
111
+ ?? presentDevice(node, frame, CONFIG.viewports)!
116
112
  const theme = (over?.theme && CONFIG.themes.includes(over.theme) ? over.theme : undefined)
117
113
  ?? node?.theme ?? frame?.theme ?? s.viewTheme
118
114
  s.setPlay({ at, device, theme })
@@ -137,10 +133,8 @@ export function enterFocus(at?: string, over?: { device?: string; theme?: string
137
133
  if (!target) { s.toast('nothing to focus here'); return }
138
134
  const frame = s.manifest?.frames.find((f) => f.id === target)
139
135
  const node = s.nodes.find((n) => n.frame === target && !n.missing)
140
- const names = Object.keys(CONFIG.viewports)
141
136
  const device = (over?.device && (CONFIG.viewports[over.device] || over.device === 'fill') ? over.device : undefined)
142
- ?? (node ? names.find((v) => CONFIG.viewports[v].width === node.w) : undefined)
143
- ?? (frame?.viewport && CONFIG.viewports[frame.viewport] ? frame.viewport : names[0])
137
+ ?? presentDevice(node, frame, CONFIG.viewports)!
144
138
  const theme = (over?.theme && CONFIG.themes.includes(over.theme) ? over.theme : undefined)
145
139
  ?? node?.theme ?? frame?.theme ?? s.viewTheme
146
140
  s.setPlay({ at: target, device, theme, focus: true, ...(over?.deep ? { deep: true } : {}) })
@@ -320,6 +314,15 @@ function PlayInner() {
320
314
  const src = useRef(play ? withWs(`${ROUTE}/stage/?at=${encodeURIComponent(play.at)}&theme=${encodeURIComponent(play.theme)}${slParams(play)}`) : '')
321
315
  // the view below the Mac app's strip when the shell took the inset (inset.ts): fill, the doc preset and every fit
322
316
  const [win, setWin] = useState(() => { const u = usable(); return { w: u.width, h: u.height } })
317
+ // spec 32 C4: play's 24 px margins - Hide UI on in play (immersive.ts `tight`: in the app, at main's answer)
318
+ const [tight, setTight] = useState(tightNow)
319
+ // spec 32 C5.2: the stage's FLIP on a re-fit C4 causes - its rect before the re-fit, read as it changes
320
+ const rootRef = useRef<HTMLDivElement>(null)
321
+ const stageRef = useRef<HTMLDivElement>(null)
322
+ const flipFrom = useRef<{ width: number; height: number } | null>(null)
323
+ const flipping = useRef<{ end: () => void } | null>(null)
324
+ const fixedRef = useRef(false)
325
+ const sizeRef = useRef({ w: 0, h: 0 })
323
326
  const [pillOpen, setPillOpen] = useState(true) // collapse (pill -> re-open fab), like the canvas
324
327
  const [stageReady, setStageReady] = useState(0) // bumps on each sh:stage-ready (reload) - re-drives the highlight
325
328
  const [away, setAway] = useState(false) // the stage shows another project's "another canvas" page (A1.11)
@@ -337,6 +340,9 @@ function PlayInner() {
337
340
  // a frame deep link is presentation, not access (01-sharing §3.5) - on a PUBLISHED canvas. In dev
338
341
  // the visitor is the owner, who followed an agent's link: the way back to the canvas stays.
339
342
  const noDoor = locked || (!!play?.deep && PUBLISHED)
343
+ // read by the key handler, which is bound once (spec 32 C7)
344
+ const noDoorRef = useRef(noDoor)
345
+ noDoorRef.current = noDoor
340
346
 
341
347
  // the stage is same-origin (/__mv/stage/); a fixed target origin keeps anchor bundles
342
348
  // from leaking if a link ever navigates the iframe cross-origin
@@ -490,7 +496,8 @@ function PlayInner() {
490
496
  perfSeams.stageMessage.emit(data)
491
497
  // Jam (spec 27): the stage records like a frame; a key the shell owns comes back as sh:key
492
498
  if (onFrameMessage('stage', data)) return
493
- if (data.type === 'sh:key') { if (typeof data.key === 'string') jamKey({ key: data.key, shift: !!data.shift, alt: !!data.alt, meta: !!data.meta, ctrl: !!data.ctrl }, 'stage'); return }
499
+ // a key the stage forwards: the person's, so a show or link still loading gives way (spec 31 D3)
500
+ if (data.type === 'sh:key') { if (typeof data.key === 'string') { navigatedByHand(); jamKey({ key: data.key, shift: !!data.shift, alt: !!data.alt, meta: !!data.meta, ctrl: !!data.ctrl }, 'stage') } return }
494
501
  if (data.type === 'sh:stage-ready') {
495
502
  frameReady('stage')
496
503
  // an iframe reload (registry HMR invalidation) boots at the frozen initial src -
@@ -525,6 +532,7 @@ function PlayInner() {
525
532
  if (s.playNav && !s.stageShown) useStore.setState({ playUpdateRevision: 'retry' }) // an Update that failed: offer it again
526
533
  }
527
534
  } else if (data.type === 'sh:stage-key') {
535
+ navigatedByHand() // the person's key or click on the stage (spec 31 D3)
528
536
  if (data.meta && data.key === '/') { cmd('toolbar', { via: 'key', in: 'stage', keys: 'Meta+/' }); toggleCollapse() }
529
537
  // the stage's background click, posted as Space, says so (#50)
530
538
  else handleKey(String(data.key), String(data.code), !!data.alt, data.origin === 'click' ? { via: 'click', in: 'stage' } : { via: 'key', in: 'stage', keys: keysOf({ key: String(data.key), alt: !!data.alt }) })
@@ -578,6 +586,8 @@ function PlayInner() {
578
586
  c.setMode(false); c.setActive(null); c.setDraft(null); s.setLaser(false)
579
587
  endAfterFrames(h)
580
588
  }
589
+ // spec 32 C7: a board with no way out (locked, a published deep link) - Escape with nothing live shows the UI again
590
+ else if (noDoorRef.current && isHideUI()) { cmd('hide-ui', how); toggleHideUI() }
581
591
  else exitFrom(how)
582
592
  return
583
593
  }
@@ -623,6 +633,8 @@ function PlayInner() {
623
633
  const key = e.altKey && /^Key[A-Z]$/.test(e.code) ? e.code.slice(3).toLowerCase() : e.key
624
634
  if (!e.repeat && jamKey({ key, shift: e.shiftKey, alt: e.altKey, meta: e.metaKey, ctrl: e.ctrlKey })) { e.preventDefault(); return }
625
635
  if ((e.metaKey || e.ctrlKey) && e.key === '/') { e.preventDefault(); cmd('toolbar', { via: 'key', in: 'shell', keys: keysOf(e) }); toggleCollapse(); return }
636
+ // ⌘A in the open thread's card selects its words, never the whole page (spec 31 C.1)
637
+ if ((e.metaKey || e.ctrlKey) && e.key === 'a' && cardSelectAll()) { e.preventDefault(); cmd('thread-select-all', { via: 'key', in: 'shell', keys: keysOf(e) }); return }
626
638
  if (e.metaKey || e.ctrlKey) return
627
639
  handleKey(key, e.code, e.altKey, { via: 'key', in: 'shell', keys: keysOf(e, key) })
628
640
  }
@@ -633,9 +645,60 @@ function PlayInner() {
633
645
  useEffect(() => {
634
646
  const onResize = () => { const u = usable(); setWin({ w: u.width, h: u.height }) }
635
647
  window.addEventListener('resize', onResize)
636
- return () => window.removeEventListener('resize', onResize)
648
+ // spec 32 C4: `win` follows the play inset (onTopChange) and the margins `tight` - one refit for main's one answer
649
+ // (the two land in one turn and render once). A fixed stage's rect is read first, for its FLIP (C5.2): mid-FLIP it
650
+ // is the size it shows now, so a reversal starts from there
651
+ const refit = () => {
652
+ if (fixedRef.current && stageRef.current) { const r = stageRef.current.getBoundingClientRect(); flipFrom.current = { width: r.width, height: r.height } }
653
+ onResize()
654
+ setTight(tightNow())
655
+ }
656
+ const offTop = onTopChange(refit)
657
+ const offTight = onImmersiveChange(refit)
658
+ return () => { window.removeEventListener('resize', onResize); offTop(); offTight(); flipping.current?.end() }
637
659
  }, [])
638
660
 
661
+ // spec 32 C5.2: a fixed stage re-fit by C4 (the play inset, the margins) animates as a FLIP - it starts at
662
+ // scale(prev/next) at its new whole-pixel size and runs to none over the stage's time; `.flip` holds the inner .dev's
663
+ // own size transition off, so one animation resizes it. Ended by the transform's transitionend, or the time + 50 ms;
664
+ // a newer re-fit mid-FLIP starts again from the rect it shows (read before the re-fit); leaving play drops it at once;
665
+ // a stage that is no longer fixed (responsive fill, the doc preset - picked mid-FLIP) drops it at once too: it never FLIPs
666
+ useLayoutEffect(() => {
667
+ if (!fixedRef.current) flipping.current?.end()
668
+ const from = flipFrom.current
669
+ flipFrom.current = null
670
+ const el = stageRef.current, root = rootRef.current
671
+ const { w, h } = sizeRef.current
672
+ if (!from || !el || !root || !w || !h || (Math.abs(from.width - w) < 0.5 && Math.abs(from.height - h) < 0.5)) return
673
+ flipping.current?.end()
674
+ if (matchMedia('(prefers-reduced-motion: reduce)').matches) return // C5.4: instant
675
+ const m = tightNow() ? MOTION.out : MOTION.back
676
+ root.classList.add('flip')
677
+ el.style.transition = 'none'
678
+ el.style.transform = `scale(${from.width / w}, ${from.height / h})`
679
+ void el.getBoundingClientRect()
680
+ el.style.transition = `transform ${m.stage}ms ${m.stageEase}`
681
+ el.style.transform = 'none'
682
+ let timer: ReturnType<typeof setTimeout> | undefined
683
+ const onEnd = (e: TransitionEvent) => { if (e.target === el && e.propertyName === 'transform') f.end() }
684
+ const f = {
685
+ end: () => {
686
+ clearTimeout(timer)
687
+ el.removeEventListener('transitionend', onEnd)
688
+ root.classList.remove('flip')
689
+ // cancelled, not only cleared: under the default `all 0s` a running transform transition whose end is unchanged
690
+ // runs on, so `none` is flushed first - an end mid-FLIP (fill picked, play left) leaves no scale behind
691
+ el.style.transition = 'none'; el.style.transform = 'none'
692
+ void el.getBoundingClientRect()
693
+ el.style.transition = ''; el.style.transform = ''
694
+ if (flipping.current === f) { flipping.current = null; setStageReady((n) => n + 1) } // the comments overlay re-measures
695
+ },
696
+ }
697
+ el.addEventListener('transitionend', onEnd)
698
+ timer = setTimeout(f.end, m.stage + 50)
699
+ flipping.current = f
700
+ })
701
+
639
702
  if (!play) return null // parent gates on play; belt to its braces
640
703
 
641
704
  // doc preset: reading width, natural document scrolling - the iframe takes the
@@ -655,11 +718,18 @@ function PlayInner() {
655
718
  // (no hook here - this is past the early return: a microtask, right after this layout)
656
719
  const stageAt = play.at, stageW = Math.round(vp.width), stageH = Math.round(vp.height)
657
720
  queueMicrotask(() => setStageSize(stageAt, stageW, stageH))
721
+ // spec 32 C4: shown, today's margins; Hide UI on (`tight`), 24 px in both axes in every host - fill and the doc preset
722
+ // have none either way, and grow with `win`
658
723
  const scale = stage ? Math.max(0.05, fill ? Math.min(win.w / vp.width, win.h / vp.height)
724
+ : tight ? Math.min((win.w - 24) / vp.width, (win.h - 24) / vp.height)
659
725
  : slides ? Math.min((win.w - 48) / vp.width, (win.h - (deckChrome === 'none' ? 48 : 88)) / vp.height)
660
726
  : Math.min((win.w - 96) / vp.width, (win.h - 128) / vp.height))
661
727
  : docPreset || fill ? 1
728
+ : tight ? Math.min(1, (win.w - 24) / vp.width, (win.h - 24) / vp.height)
662
729
  : Math.min(1, (win.w - 96) / vp.width, (win.h - 128) / vp.height)
730
+ // the stages whose width and height scale together get the FLIP (C5.2): a slide stage (under fill too) and a device;
731
+ // responsive fill and the doc preset only grow in height while the iframe reflows - a FLIP would squash the live frame
732
+ fixedRef.current = !!stage || !(docPreset || fill)
663
733
  const names = Object.keys(CONFIG.viewports)
664
734
  const list = focus ? [play.at] : slides ? currentDeck() : playList()
665
735
  const pos = list.indexOf(play.at)
@@ -670,14 +740,15 @@ function PlayInner() {
670
740
  // fractional sizes left subpixel seams glowing at the corners on dark frames
671
741
  const dw = Math.round(vp.width * scale)
672
742
  const dh = Math.round(vp.height * scale)
743
+ sizeRef.current = { w: dw, h: dh }
673
744
  const deviceHint = stage ? `${vp.width} × ${vp.height} stage · ${fill ? 'edge to edge' : 'fit to the window'}`
674
- : fill ? 'Fill window' : `${vp.width} × ${vp.height} · keys 1-${names.length + 1}`
745
+ : fill ? 'Fill window' : `${CONFIG.viewports[play.device] ? `${deviceLabel(play.device)} · ` : ''}${vp.width} × ${vp.height} · keys 1-${names.length + 1}`
675
746
 
676
747
  return (
677
- <div className={`sh-play${fill || docPreset ? ' fill' : ''}${docPreset ? ` doc t-${play.theme}` : ''}`}>
748
+ <div ref={rootRef} className={`sh-play${fill || docPreset ? ' fill' : ''}${docPreset ? ` doc t-${play.theme}` : ''}`}>
678
749
  {/* device + comment overlay share ONE flex-centered box; the overlay is inset:0 over
679
750
  it (a sibling of the clipping .dev, so a thread card is never eaten by overflow) */}
680
- <div className="sh-play-stage" style={{ width: dw, height: dh }}
751
+ <div ref={stageRef} className="sh-play-stage" style={{ width: dw, height: dh }}
681
752
  onClick={slides ? (e) => {
682
753
  // background advance: never on controls, links, media, comments, or goto targets
683
754
  const t = e.target as Element
@@ -768,6 +839,12 @@ function PlayInner() {
768
839
  </button>
769
840
  </Tip>
770
841
  </>}
842
+ {/* spec 31: the deck (or the present board) as a PDF, in the theme the stage shows - a dev canvas only */}
843
+ {!focus && !PUBLISHED && (
844
+ <Tip side="bottom" label={<><b>Export PDF</b><span>this board, one page per {slides ? 'slide' : 'frame'}</span></>}>
845
+ <button className="sh-pill-btn" aria-label="Export PDF" onClick={() => void exportPdf(board, { theme: play.theme }, { via: 'click', in: 'pill' })}><ExportIcon size={15} /></button>
846
+ </Tip>
847
+ )}
771
848
  {/* the canvas door: absent on a locked board (policy) and on a frame
772
849
  deep link (the link's chrome) - not hidden, not rendered */}
773
850
  {!noDoor && (
@@ -8,13 +8,14 @@
8
8
  */
9
9
  import { createPortal } from 'react-dom'
10
10
  import { useEffect, useRef, useState, type ReactNode } from 'react'
11
- import { useStore, CONFIG, SOURCE_REVEALED, cap, stoppedFor } from './store.ts'
11
+ import { useStore, CONFIG, SOURCE_REVEALED, stoppedFor } from './store.ts'
12
12
  import { STOPPED_TIP, useStopped } from './api.ts'
13
13
  import { NO_COMMENTS_HERE, useComments } from './comments-store.ts'
14
14
  import { UNPLACED } from './hash.ts'
15
15
  import { Tip } from './Tip.tsx'
16
16
  import { cmd } from './commands.ts'
17
- import { CaretIcon, CheckIcon, CommentIcon, DevicesIcon, EyeSlashIcon, FrameCornersIcon, LaserIcon, MoonIcon, SlideFrameIcon, SunIcon, deviceIcon } from './icons.tsx'
17
+ import { CaretIcon, CheckIcon, CommentIcon, DevicesIcon, EyeSlashIcon, FrameCornersIcon, LaserIcon, MoonIcon, SlideFrameIcon, SunIcon } from './icons.tsx'
18
+ import { deviceIcon, deviceLabel } from './devices.tsx'
18
19
 
19
20
  const commentsStore = () => useComments.getState()
20
21
 
@@ -216,7 +217,7 @@ export function DevicePicker({ value, onSelect, includeDefault, includeFill, inc
216
217
  </>}
217
218
  {entries.map(([name, vp], i) => (
218
219
  <button key={name} onClick={() => pick(name)} title={`${vp.width} × ${vp.height}`}>
219
- {deviceIcon(name)}<span>{cap(name)}</span><kbd>{i < 9 ? i + 1 : ''}</kbd>
220
+ {deviceIcon(name)}<span className="dev-label">{deviceLabel(name)}</span><kbd>{i < 9 ? i + 1 : ''}</kbd>
220
221
  {value === name && <CheckIcon size={13} className="chk" />}
221
222
  </button>
222
223
  ))}
@@ -21,6 +21,11 @@
21
21
  * hand (A4.6 #30);
22
22
  * - `mv:open` (app 0.3, A4.6 #29, #30): a notice's click, opened by open-item.ts and answered as `mv:opened`. An app
23
23
  * without `onOpen` never sends one, and nothing here waits for it.
24
+ * - `mv:show` (app 1.1, spec 31 D1): a `marver://` link into this tab, shown by show.ts as `marver show` is; and
25
+ * show.ts asks `front()` once it showed a `marver show`.
26
+ *
27
+ * - `mv:immersive` (app 1.2, spec 32 C1, C2): immersive play's wish, and main's answer - immersive.ts; a `hidden` or
28
+ * `untrusted` app state ends it with Hide UI off (C6.4, C6.5).
24
29
  *
25
30
  * The one ground (0.27.2, A3.8 #27, #31): `mv:hello` says the inset the shell applied (inset.ts's `TOP`: 44 only when
26
31
  * the app said so and gave the whole presentation contract), and each `mv:present { epoch, w, h, frames }` is answered
@@ -32,7 +37,8 @@
32
37
  import { BOUNDS, MENU_IN, type AppState, type Busy, type Hello, type MarverAppV1, type MenuIn, type MenuItem, type Present } from '../../shared/app-api.ts'
33
38
  import type { CmdIn } from '../../shared/perf-records.ts'
34
39
  import { relayed } from './commands.ts'
35
- import { markSeenFrom } from './marks-ui.tsx'
40
+ import { markSeenFrom, resolveAllFrom } from './marks-ui.tsx'
41
+ import { canExportPdf, exportPdf } from './pdf-export.tsx'
36
42
  import { APP } from './marver-app.ts'
37
43
  import { TOP } from './inset.ts'
38
44
  import { api, canvasStopped } from './api.ts'
@@ -47,6 +53,9 @@ import { useJamQueue } from './jam-queue.ts'
47
53
  import { useJamUi } from './jam-state.ts'
48
54
  import { useJamVoice, voiceUntrusted } from './jam-voice.ts'
49
55
  import { endOpen, openLiveItem } from './open-item.ts'
56
+ import { showTarget } from './show.ts'
57
+ import { navigatedByHand } from './goto.ts'
58
+ import { appStateEnds, startImmersive } from './immersive.ts'
50
59
 
51
60
  /** The ground under the strip (A2.14 #26): the shell's own - never a frame's pinned theme. */
52
61
  export const shellDark = (): boolean => { const s = useStore.getState(); return !!s.play || s.viewTheme === 'dark' }
@@ -130,28 +139,47 @@ const ITEMS: readonly Item[] = [
130
139
  ]
131
140
  const offered = (it: Item) => { try { return it.when?.() ?? true } catch { return false } }
132
141
 
142
+ /** File > Export PDF… (spec 31): the open board, offered only to an app that saves PDFs (`exportPdf`, app 1.1) - an
143
+ * older app refuses a menu naming the `file` group - and on a dev canvas with a board open. */
144
+ const pdfOffered = () => !!APP?.exportPdf && canExportPdf() && useStore.getState().board !== UNPLACED
145
+
133
146
  /** `mv:menu` now: at most 40 items, ids, labels and hints within the contract's bounds. */
134
147
  export function menuNow(): MenuItem[] {
135
- return ITEMS.filter(offered).slice(0, BOUNDS.menuItems).map((it) => ({
148
+ const items: MenuItem[] = ITEMS.filter(offered).map((it) => ({
136
149
  id: it.id, group: it.group, label: it.label, hint: it.hint,
137
150
  ...(it.checked ? { checked: (() => { try { return !!it.checked!() } catch { return false } })() } : {}),
138
151
  }))
152
+ if (pdfOffered()) items.unshift({ id: 'export-pdf', group: 'file', label: 'Export PDF…' })
153
+ return items.slice(0, BOUNDS.menuItems)
139
154
  }
140
155
 
141
156
  /** A menu item chosen in the app: its key, replayed on the shell's window - the same handlers, the same rules (a
142
157
  * text field holding the focus does not stop it: the person chose the item). An id the page does not offer now
143
158
  * does nothing. One id is the app's own, never in the menu: the tab's right-click Mark All as Seen clears every
144
- * frame's "new" in this canvas, here and on disk, as the sidebar's Mark all as seen does for a board. */
159
+ * frame's "new" in this canvas, here and on disk, as the sidebar's Mark all as seen does for a board; another, Resolve All
160
+ * Comments, resolves every open thread on the canvas (spec 31). */
145
161
  export function runMenuItem(id: string, from?: unknown): void {
146
162
  // spec 30 #51: the menu it came from, as app 1.0.1 says; app 1.0.0 says nothing, so `app`
147
163
  const where: CmdIn = (MENU_IN as readonly unknown[]).includes(from) ? from as MenuIn : 'app'
148
164
  if (id === 'mark-all-seen') {
149
165
  const s = useStore.getState()
150
- if (!PUBLISHED && s.marks) markSeenFrom({ via: 'relay', in: where }, Object.keys(s.marks.changed))
166
+ // each of the app's own items, once it acts, is the person's input: a show or link still loading gives way (spec 31 D3)
167
+ if (!PUBLISHED && s.marks) { navigatedByHand(); markSeenFrom({ via: 'relay', in: where }, Object.keys(s.marks.changed)) }
168
+ return
169
+ }
170
+ // the tab's Resolve All Comments (spec 31 B.1): every open thread on the canvas, as the sidebar's does for a board
171
+ if (id === 'resolve-all-comments') {
172
+ if (!PUBLISHED) { navigatedByHand(); void resolveAllFrom({ via: 'relay', in: where }, { canvas: true }) }
173
+ return
174
+ }
175
+ if (id === 'export-pdf') {
176
+ if (pdfOffered()) { navigatedByHand(); const s = useStore.getState(); void exportPdf(s.board, s.play ? { theme: s.play.theme } : {}, { via: 'relay', in: where }) }
151
177
  return
152
178
  }
153
179
  const it = ITEMS.find((x) => x.id === id)
154
180
  if (!it || !offered(it)) return
181
+ // the person chose it in the app's menu: a show or link still loading gives way (spec 31 D3; its key is untrusted)
182
+ navigatedByHand()
155
183
  // recorded by the key handler that runs it, once, as the relay it is (`cmd()` reads `relayed`)
156
184
  relayed(where, () => window.dispatchEvent(new KeyboardEvent('keydown', { ...it.key, bubbles: true, cancelable: true })))
157
185
  }
@@ -186,6 +214,8 @@ function onAppState(s: AppState): void {
186
214
  if (s === 'shown') { void resumeReconcile(); return }
187
215
  // a notice's click still reading or waiting moves nothing more once the tab is hidden or its trust is gone
188
216
  endOpen()
217
+ // spec 32 C6.4, C6.5: immersive play ends with Hide UI off, so coming back shows the chrome
218
+ appStateEnds()
189
219
  if (s === 'untrusted') voiceUntrusted()
190
220
  }
191
221
 
@@ -207,9 +237,14 @@ export function startAppBridge(): void {
207
237
  call(() => app.onMenuClick((p) => runMenuItem(typeof p?.id === 'string' ? p.id : '', p?.in)))
208
238
  // a notice's click (A4.6 #29, #30): the exact item, resolved against fresh reads and answered
209
239
  if (typeof app.onOpen === 'function') call(() => { app.onOpen!((p) => openLiveItem(p)) })
240
+ // a `marver://` link into this open tab (spec 31 D1): the same navigation command `marver show` sends - moved to, or
241
+ // a notice over unsent words; never a reload or a hash replaced under the page
242
+ if (typeof app.onShow === 'function') call(() => { app.onShow!((t) => { void showTarget(t, 'app') }) })
210
243
  // the one ground's presentation requests (0.27.2): answered only when the shell took the inset - a shell that did
211
244
  // not is placed below the strip and never asked (A3.8 #31)
212
245
  if (TOP) call(() => { answerPresents(app, call) })
246
+ // spec 32 C1: immersive play's wish, sent on every change, and main's answers (an app without `immersive` gets none)
247
+ call(() => startImmersive())
213
248
 
214
249
  // 1. hello, first (A2.14 #9)
215
250
  call(() => app.hello(helloNow()))
@@ -252,7 +287,7 @@ export function startAppBridge(): void {
252
287
  }
253
288
  const menuChanged = () => { if (menuQueued) return; menuQueued = true; queueMicrotask(sendMenu) }
254
289
  sendMenu()
255
- useStore.subscribe((s, p) => { if (s.laser !== p.laser || s.laserInspect !== p.laserInspect) menuChanged() })
290
+ useStore.subscribe((s, p) => { if (s.laser !== p.laser || s.laserInspect !== p.laserInspect || (s.board === UNPLACED) !== (p.board === UNPLACED)) menuChanged() })
256
291
  useComments.subscribe((s, p) => { if (s.commentMode !== p.commentMode || s.show !== p.show) menuChanged() })
257
292
  useNotes.subscribe((s, p) => { if (s.all !== p.all) menuChanged() })
258
293
  useJamQueue.subscribe((s, p) => { if (!!s.session !== !!p.session) menuChanged() })