@marver-design/marver 0.29.0 → 0.30.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.
- package/CHANGELOG.md +44 -0
- package/README.md +2 -1
- package/dist/{anchor-check-DhlpKl2K.mjs → anchor-check-c52IDkiQ.mjs} +1 -1
- package/dist/{build-CWbrb2bl.mjs → build-C3mUtjEn.mjs} +5 -4
- package/dist/cli.mjs +5 -5
- package/dist/{daemon-Sc_z8gT6.mjs → daemon-B0Wi1OQ3.mjs} +5 -3
- package/dist/{dev-DWBKQhxf.mjs → dev-5dlxoW28.mjs} +8 -8
- package/dist/{perf-Denssrko.mjs → perf-6MOTHxay.mjs} +710 -99
- package/dist/perf-BCxAo0IS.mjs +1743 -0
- package/dist/{plugin-DqoZB-D6.mjs → plugin-CXRoMA8g.mjs} +898 -539
- package/dist/{poster-CrsjqhY4.mjs → poster-CYmCa00B.mjs} +1 -1
- package/dist/{publish-bakes-DW-NDgU2.mjs → publish-bakes-C_2ZtHou.mjs} +2 -2
- package/dist/{recover-GtJ9UDAB.mjs → recover-XD8iXJOj.mjs} +1 -1
- package/dist/{shot-T04Ixrvq.mjs → shot-CRRGgxru.mjs} +3 -3
- package/docs/app.md +194 -0
- package/docs/performance.md +98 -18
- package/package.json +1 -1
- package/src/client/frame-host/bridge.js +17 -8
- package/src/client/frame-host/inplace.ts +124 -0
- package/src/client/frame-host/inspect.d.ts +1 -0
- package/src/client/frame-host/inspect.js +13 -4
- package/src/client/frame-host/main.tsx +12 -3
- package/src/client/frame-host/messages.ts +85 -0
- package/src/client/frame-host/signals.d.ts +15 -0
- package/src/client/frame-host/signals.js +219 -0
- package/src/client/recorder-level.ts +41 -0
- package/src/client/shell/App.tsx +158 -88
- package/src/client/shell/BoardList.tsx +103 -48
- package/src/client/shell/Comments.tsx +66 -42
- package/src/client/shell/ContextMenu.tsx +3 -2
- package/src/client/shell/JamSurface.tsx +116 -71
- package/src/client/shell/LockedApp.tsx +19 -3
- package/src/client/shell/Play.tsx +94 -58
- package/src/client/shell/StatusPicker.tsx +19 -9
- package/src/client/shell/Toolbar.tsx +15 -7
- package/src/client/shell/api.ts +18 -4
- package/src/client/shell/app-bridge.ts +12 -6
- package/src/client/shell/app-perf.ts +31 -1
- package/src/client/shell/canvas/Canvas.tsx +17 -6
- package/src/client/shell/canvas/FrameNode.tsx +25 -12
- package/src/client/shell/canvas/Sticky.tsx +4 -2
- package/src/client/shell/canvas/ctl.ts +2 -0
- package/src/client/shell/canvas/ready-watch.ts +4 -0
- package/src/client/shell/canvas/sleep.ts +2 -0
- package/src/client/shell/canvas/updates.ts +13 -6
- package/src/client/shell/commands.ts +765 -0
- package/src/client/shell/comments-store.ts +42 -27
- package/src/client/shell/goto.ts +11 -6
- package/src/client/shell/jam-keys.ts +141 -75
- package/src/client/shell/jam-lane.tsx +19 -12
- package/src/client/shell/jam-panel.tsx +61 -48
- package/src/client/shell/jam-session.tsx +41 -37
- package/src/client/shell/jam-state.ts +9 -1
- package/src/client/shell/jam-surface-parts.tsx +8 -6
- package/src/client/shell/jam-ui.tsx +9 -6
- package/src/client/shell/jam-voice.ts +4 -2
- package/src/client/shell/main.tsx +7 -1
- package/src/client/shell/marks-ui.tsx +11 -0
- package/src/client/shell/perf.ts +51 -5
- package/src/client/shell/recorder-core.ts +4 -1
- package/src/client/shell/recorder-hmr.ts +36 -0
- package/src/client/shell/recorder-reloads.ts +264 -0
- package/src/client/shell/recorder-seams.ts +116 -0
- package/src/client/shell/recorder-self.ts +73 -0
- package/src/client/shell/recorder-signals-core.ts +139 -0
- package/src/client/shell/recorder-signals.ts +485 -0
- package/src/client/shell/recorder.ts +115 -41
- package/src/client/shell/store.ts +56 -22
- package/src/client/shell/whiteout-probes.ts +3 -1
- package/src/client/stage/main.tsx +10 -5
- package/src/shared/app-api.ts +28 -6
- package/src/shared/app-perf.ts +99 -6
- package/src/shared/app-report.ts +586 -0
- package/src/shared/perf-records.ts +445 -0
- package/src/shared/perf-run.ts +6 -2
- package/dist/perf-jam-CLkERSHo.mjs +0 -642
|
@@ -24,6 +24,7 @@ import { CaptureBlock } from './jam-panel.tsx'
|
|
|
24
24
|
import { useJamQueue } from './jam-queue.ts'
|
|
25
25
|
import { mentionAlerts, mentionPeople, mentionQueryAt, parseBody, type MentionPerson } from './mentions.ts'
|
|
26
26
|
import { slideSize, stageFit } from '../const.ts'
|
|
27
|
+
import { cmd, keysOf, type CmdHandle, type CmdOpts } from './commands.ts'
|
|
27
28
|
import type { AgentMeta, Thread } from '../../shared/events.ts'
|
|
28
29
|
|
|
29
30
|
/** Tint the pin / composer / thread card EDGES (border, outline, focus ring) in the anchored
|
|
@@ -153,7 +154,7 @@ export function Pins({ threads, placed, orphans, inv, active, alertIds }: {
|
|
|
153
154
|
<div key={t.id} data-thread={t.id} className={`cm-pin sh-no-pan${t.id === active ? ' on' : ''}${orphan ? ' orphan' : ''}${alertIds?.has(t.id) ? ' mention' : ''}${working.includes(t.id) ? ' working' : ''}`}
|
|
154
155
|
style={{ left: p.x, top: p.y, ...hueVars(anchorHue(t.anchor)) }}
|
|
155
156
|
onPointerDown={(e) => e.stopPropagation()}
|
|
156
|
-
onClick={(e) => { e.stopPropagation(); setActive(t.id === active ? null : t.id) }}
|
|
157
|
+
onClick={(e) => { e.stopPropagation(); cmd(t.id === active ? 'thread-close' : 'thread-open', { via: 'click', in: 'shell', frame: t.frame }); setActive(t.id === active ? null : t.id) }}
|
|
157
158
|
title={orphan ? 'the anchored element is gone - comment parked' : undefined}>
|
|
158
159
|
<MarkerFace threads={[t]} max={2} />
|
|
159
160
|
</div>,
|
|
@@ -303,7 +304,7 @@ export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: s
|
|
|
303
304
|
if (!engaged && open.length) {
|
|
304
305
|
return (
|
|
305
306
|
<button className={`cm-stack sh-no-pan${open.some((t) => alertIds.has(t.id)) ? ' mention' : ''}`}
|
|
306
|
-
onClick={(e) => { e.stopPropagation(); useStore.getState().select(node.key); const hit = open.find((t) => alertIds.has(t.id)) ?? open[0]; if (hit) setActive(hit.id) }}>
|
|
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) }}>
|
|
307
308
|
<MarkerFace threads={open} />
|
|
308
309
|
</button>
|
|
309
310
|
)
|
|
@@ -490,9 +491,12 @@ function MessageHead({ author, agent, agentMeta, ts, board, eventId }: { author?
|
|
|
490
491
|
|
|
491
492
|
/** An auto-growing composer with the full keybindings: Enter send, Shift+Enter newline,
|
|
492
493
|
* Cmd/Ctrl+Enter send, Escape cancel; IME-guarded, disabled while a send is in flight. */
|
|
493
|
-
function CommentInput({ value, onChange, onSubmit, onCancel, placeholder, autoFocus, sendLabel, owner }: {
|
|
494
|
-
value: string; onChange: (v: string) => void
|
|
495
|
-
|
|
494
|
+
function CommentInput({ value, onChange, onSubmit, onCancel, placeholder, autoFocus, sendLabel, owner, sendCmd, frame }: {
|
|
495
|
+
value: string; onChange: (v: string) => void
|
|
496
|
+
/** ends `h` (spec 30): a person typing has got a draft, so the command starts here, at ⏎ or send */
|
|
497
|
+
onSubmit: (h: CmdHandle) => void | Promise<unknown>
|
|
498
|
+
onCancel: () => void; placeholder: string; autoFocus?: boolean; sendLabel: string; owner: boolean
|
|
499
|
+
sendCmd: 'comment-send' | 'comment-reply'; frame?: string
|
|
496
500
|
}) {
|
|
497
501
|
const ref = useRef<HTMLTextAreaElement>(null)
|
|
498
502
|
const hlRef = useRef<HTMLDivElement>(null)
|
|
@@ -511,8 +515,9 @@ function CommentInput({ value, onChange, onSubmit, onCancel, placeholder, autoFo
|
|
|
511
515
|
const listOpen = matches.length > 0
|
|
512
516
|
useEffect(() => { setPick(0) }, [q?.start, q?.query])
|
|
513
517
|
const track = () => setCaret(ref.current?.selectionStart ?? 0)
|
|
514
|
-
const choose = (p: MentionPerson) => {
|
|
518
|
+
const choose = (p: MentionPerson, how: CmdOpts) => {
|
|
515
519
|
if (!q) return
|
|
520
|
+
cmd('mention-pick', how).done()
|
|
516
521
|
const pos = q.start + p.label.length + 2 // '@' + label + ' '
|
|
517
522
|
onChange(value.slice(0, q.start) + '@' + p.label + ' ' + value.slice(caret))
|
|
518
523
|
setCaret(pos)
|
|
@@ -524,10 +529,11 @@ function CommentInput({ value, onChange, onSubmit, onCancel, placeholder, autoFo
|
|
|
524
529
|
const syncScroll = () => { if (hlRef.current && ref.current) hlRef.current.scrollTop = ref.current.scrollTop }
|
|
525
530
|
useEffect(() => { if (autoFocus) ref.current?.focus() }, [autoFocus])
|
|
526
531
|
useEffect(grow, [value])
|
|
527
|
-
const submit = async () => {
|
|
532
|
+
const submit = async (how: CmdOpts) => {
|
|
528
533
|
if (busy || !value.trim()) return
|
|
534
|
+
const h = cmd(sendCmd, { ...how, frame })
|
|
529
535
|
setBusy(true)
|
|
530
|
-
try { await onSubmit() } finally { setBusy(false) }
|
|
536
|
+
try { await onSubmit(h) } finally { setBusy(false) }
|
|
531
537
|
}
|
|
532
538
|
return (
|
|
533
539
|
<div className="cm-inputwrap">
|
|
@@ -546,7 +552,7 @@ function CommentInput({ value, onChange, onSubmit, onCancel, placeholder, autoFo
|
|
|
546
552
|
<div className="cm-mentionlist" role="listbox">
|
|
547
553
|
{matches.map((p, i) => (
|
|
548
554
|
<button key={p.id ?? p.email} type="button" className={i === pick ? 'on' : ''} role="option" aria-selected={i === pick}
|
|
549
|
-
onMouseDown={(e) => { e.preventDefault(); choose(p) }} onMouseEnter={() => setPick(i)}>
|
|
555
|
+
onMouseDown={(e) => { e.preventDefault(); choose(p, { via: 'click', in: 'shell' }) }} onMouseEnter={() => setPick(i)}>
|
|
550
556
|
<Avatar author={{ ...p, name: p.label }} size={18} /><span>{p.label}</span>
|
|
551
557
|
</button>
|
|
552
558
|
))}
|
|
@@ -560,18 +566,18 @@ function CommentInput({ value, onChange, onSubmit, onCancel, placeholder, autoFo
|
|
|
560
566
|
if (listOpen) {
|
|
561
567
|
if (e.key === 'ArrowDown') { e.preventDefault(); setPick((v) => (v + 1) % matches.length); return }
|
|
562
568
|
if (e.key === 'ArrowUp') { e.preventDefault(); setPick((v) => (v + matches.length - 1) % matches.length); return }
|
|
563
|
-
if (e.key === 'Enter' || e.key === 'Tab') { e.preventDefault(); choose(matches[pick] ?? matches[0]); return }
|
|
564
|
-
if (e.key === 'Escape') { setDismissed(q!.start); return }
|
|
569
|
+
if (e.key === 'Enter' || e.key === 'Tab') { e.preventDefault(); choose(matches[pick] ?? matches[0], { via: 'key', in: 'shell', keys: keysOf(e) }); return }
|
|
570
|
+
if (e.key === 'Escape') { cmd('mention-dismiss', { via: 'key', in: 'shell', keys: keysOf(e) }).done(); setDismissed(q!.start); return }
|
|
565
571
|
}
|
|
566
|
-
if (e.key === 'Escape') { onCancel
|
|
572
|
+
if (e.key === 'Escape') { cmd('draft-discard', { via: 'key', in: 'shell', keys: keysOf(e), frame }); onCancel(); return }
|
|
567
573
|
if (e.key === 'Enter') {
|
|
568
574
|
if ((e.nativeEvent as unknown as { isComposing?: boolean }).isComposing) return // IME: mid-composition Enter must not send
|
|
569
575
|
if (e.shiftKey) return // newline
|
|
570
|
-
e.preventDefault(); void submit()
|
|
576
|
+
e.preventDefault(); void submit({ via: 'key', in: 'shell', keys: keysOf(e) }) // Enter / Cmd·Ctrl+Enter send
|
|
571
577
|
}
|
|
572
578
|
}} />
|
|
573
579
|
<Tip side="top" label={<b>⏎ send · ⇧⏎ new line</b>}>
|
|
574
|
-
<button className="cm-send" disabled={busy || !value.trim()} aria-label={sendLabel} onClick={() => void submit()}>
|
|
580
|
+
<button className="cm-send" disabled={busy || !value.trim()} aria-label={sendLabel} onClick={() => void submit({ via: 'click', in: 'shell' })}>
|
|
575
581
|
<ArrowUpIcon size={15} />
|
|
576
582
|
</button>
|
|
577
583
|
</Tip>
|
|
@@ -593,19 +599,22 @@ function ProfileDialog({ onClose }: { onClose: () => void }) {
|
|
|
593
599
|
const [busy, setBusy] = useState(false)
|
|
594
600
|
const [err, setErr] = useState<string | null>(null)
|
|
595
601
|
const ready = connected || !!name.trim()
|
|
596
|
-
const save = async () => {
|
|
602
|
+
const save = async (how: CmdOpts) => {
|
|
597
603
|
if (busy || !ready) return
|
|
604
|
+
const h = cmd('profile-save', how)
|
|
598
605
|
setBusy(true)
|
|
599
606
|
try {
|
|
600
|
-
const e = await useComments.getState().saveProfile({ ...(connected ? {} : { name: name.trim() }), avatar })
|
|
607
|
+
const e = await useComments.getState().saveProfile({ ...(connected ? {} : { name: name.trim() }), avatar }, h)
|
|
601
608
|
if (e) return setErr(e) // a failed save must not close as if it worked
|
|
602
609
|
onClose()
|
|
603
610
|
} finally { setBusy(false) }
|
|
604
611
|
}
|
|
612
|
+
// its own command, whatever a save still in flight later answers (spec 30): that save keeps its own end
|
|
613
|
+
const dismiss = (how: CmdOpts) => { cmd('profile-dismiss', how); onClose() }
|
|
605
614
|
return createPortal(
|
|
606
|
-
<div className="cm-modal-wrap" onClick={
|
|
615
|
+
<div className="cm-modal-wrap" onClick={() => dismiss({ via: 'click', in: 'shell' })} onPointerDown={(e) => e.stopPropagation()}>
|
|
607
616
|
<div className="cm-modal" onClick={(e) => e.stopPropagation()}
|
|
608
|
-
onKeyDown={(e) => { e.stopPropagation(); if (e.key === 'Escape')
|
|
617
|
+
onKeyDown={(e) => { e.stopPropagation(); if (e.key === 'Escape') dismiss({ via: 'key', in: 'shell', keys: keysOf(e) }) }}>
|
|
609
618
|
<h2>{unset ? 'Set up your profile' : 'Edit your profile'}</h2>
|
|
610
619
|
<p className="dim">
|
|
611
620
|
{connected
|
|
@@ -619,13 +628,13 @@ function ProfileDialog({ onClose }: { onClose: () => void }) {
|
|
|
619
628
|
? <div className="cm-chip" style={{ flex: 1 }}><b>{me?.name}</b><span>CONNECT</span></div>
|
|
620
629
|
: <input placeholder="Set a display name" style={{ flex: 1 }} value={name}
|
|
621
630
|
onChange={(e) => setName(e.target.value)}
|
|
622
|
-
onKeyDown={(e) => e.key === 'Enter' && void save()} />}
|
|
631
|
+
onKeyDown={(e) => e.key === 'Enter' && void save({ via: 'key', in: 'shell', keys: keysOf(e) })} />}
|
|
623
632
|
</div>
|
|
624
633
|
</div>
|
|
625
634
|
{err && <span className="cm-err">{err}</span>}
|
|
626
635
|
<div className="cm-row">
|
|
627
|
-
<button className="cm-primary" disabled={busy || !ready} onClick={() => void save()}>Save</button>
|
|
628
|
-
<button onClick={
|
|
636
|
+
<button className="cm-primary" disabled={busy || !ready} onClick={() => void save({ via: 'click', in: 'shell' })}>Save</button>
|
|
637
|
+
<button onClick={() => dismiss({ via: 'click', in: 'shell' })}>Not now</button>
|
|
629
638
|
</div>
|
|
630
639
|
</div>
|
|
631
640
|
</div>,
|
|
@@ -642,7 +651,7 @@ function EditableAvatar({ author, size = 24 }: { author?: Thread['author']; size
|
|
|
642
651
|
return (
|
|
643
652
|
<span className="cm-me">
|
|
644
653
|
<Tip side="top" label={<b>Edit your profile</b>}>
|
|
645
|
-
<button className="cm-mebtn" aria-label="Edit your profile" onClick={() => setOpen(true)}>
|
|
654
|
+
<button className="cm-mebtn" aria-label="Edit your profile" onClick={() => { cmd('profile-open', { via: 'click', in: 'shell' }); setOpen(true) }}>
|
|
646
655
|
<Avatar author={author} size={size} />
|
|
647
656
|
<span className="cm-pen-face"><PencilSimpleIcon size={Math.round(size * 0.55)} /></span>
|
|
648
657
|
</button>
|
|
@@ -774,10 +783,11 @@ export function ThreadCard({ thread, at, bounds, nodeKey, side = 'r', flank, sta
|
|
|
774
783
|
: { left: at.x, top: Math.min(at.y + 14, bounds.h - 40) }
|
|
775
784
|
// clear only after the server took it - a failed send must not eat the words,
|
|
776
785
|
// and text typed WHILE the request was in flight must survive the clear
|
|
777
|
-
const submit = async () => {
|
|
786
|
+
const submit = async (h: CmdHandle) => {
|
|
778
787
|
const sent = text
|
|
779
|
-
if (
|
|
788
|
+
if (await useComments.getState().replyOk(thread.id, sent, h)) setText((cur) => (cur === sent ? '' : cur))
|
|
780
789
|
}
|
|
790
|
+
const closeCard = () => setActive(null)
|
|
781
791
|
const card = (
|
|
782
792
|
<div ref={cardRef} data-sh-wheel-local data-thread={thread.id} className={`cm-card sh-no-pan${flip ? ' flip' : ''}${float ? ` parked dock-${side}` : ''}${float && flank ? ` flank-${flank}` : ''}${stage ? ' stage-dock' : ''}`} style={{ ...pos, ...hueVars(anchorHue(thread.anchor)) }}
|
|
783
793
|
onPointerDown={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()} onWheel={(e) => e.stopPropagation()}>
|
|
@@ -787,22 +797,24 @@ export function ThreadCard({ thread, at, bounds, nodeKey, side = 'r', flank, sta
|
|
|
787
797
|
<Tip side="bottom" label={<b>{copied ? 'Copied' : 'Copy link'}</b>}>
|
|
788
798
|
<button className={`cm-icon cm-copy${copied ? ' ok' : ''}`} onClick={() => {
|
|
789
799
|
const url = `${location.origin}${location.pathname}${buildHash({ board: useStore.getState().board, c: thread.id })}`
|
|
800
|
+
const h = cmd('thread-copy-link', { via: 'click', in: 'shell', frame: thread.frame })
|
|
790
801
|
// the check means "it's on your clipboard" - only show it when that's true
|
|
791
802
|
navigator.clipboard.writeText(url).then(() => {
|
|
803
|
+
h.done()
|
|
792
804
|
setCopied(true)
|
|
793
805
|
clearTimeout(copyTimer.current)
|
|
794
806
|
copyTimer.current = setTimeout(() => setCopied(false), 1600)
|
|
795
|
-
}, () => useStore.getState().toast('copy blocked - try again'))
|
|
807
|
+
}, () => { h.fail('clipboard-blocked'); useStore.getState().toast('copy blocked - try again') })
|
|
796
808
|
}}>
|
|
797
809
|
<span className="a"><LinkIcon size={15} /></span>
|
|
798
810
|
<span className="b"><CheckIcon size={16} /></span>
|
|
799
811
|
</button>
|
|
800
812
|
</Tip>
|
|
801
813
|
<Tip side="bottom" label={<b>Resolve</b>}>
|
|
802
|
-
<button className="cm-icon" onClick={() => { void resolve(thread.id); setActive(null) }}><CheckSquareOffsetIcon size={16} /></button>
|
|
814
|
+
<button className="cm-icon" onClick={() => { const h = cmd('comment-resolve', { via: 'click', in: 'shell', frame: thread.frame }); void resolve(thread.id, false, h); setActive(null) }}><CheckSquareOffsetIcon size={16} /></button>
|
|
803
815
|
</Tip>
|
|
804
816
|
<Tip side="bottom" label={<b>Close</b>}>
|
|
805
|
-
<button className="cm-icon" onClick={() => setActive(null)}><XIcon size={15} /></button>
|
|
817
|
+
<button className="cm-icon" onClick={() => { cmd('thread-close', { via: 'click', in: 'shell', frame: thread.frame }); setActive(null) }}><XIcon size={15} /></button>
|
|
806
818
|
</Tip>
|
|
807
819
|
</div>
|
|
808
820
|
{/* "there is more": the scroller MASKS its own content at the overflowing edge - a soft fade
|
|
@@ -826,10 +838,10 @@ export function ThreadCard({ thread, at, bounds, nodeKey, side = 'r', flank, sta
|
|
|
826
838
|
{canComment ? (
|
|
827
839
|
<div className="cm-compose">
|
|
828
840
|
<ComposeAvatar />
|
|
829
|
-
<CommentInput value={text} onChange={setText} onSubmit={submit} onCancel={
|
|
841
|
+
<CommentInput value={text} onChange={setText} onSubmit={submit} onCancel={closeCard} placeholder="Reply…" sendLabel="Send" owner={local} sendCmd="comment-reply" frame={thread.frame} />
|
|
830
842
|
</div>
|
|
831
843
|
) : (
|
|
832
|
-
<button className="cm-signin-cta" onClick={() => useComments.setState({ needsIdentity: true })}>
|
|
844
|
+
<button className="cm-signin-cta" onClick={() => { cmd('identity-open', { via: 'click', in: 'shell' }); useComments.setState({ needsIdentity: true }) }}>
|
|
833
845
|
Sign in to comment
|
|
834
846
|
</button>
|
|
835
847
|
)}
|
|
@@ -843,14 +855,17 @@ export function ThreadCard({ thread, at, bounds, nodeKey, side = 'r', flank, sta
|
|
|
843
855
|
export function DraftComposer({ at, bounds, hue }: { at: { x: number; y: number }; bounds: { w: number; h: number }; hue?: number }) {
|
|
844
856
|
const { create, setDraft } = useComments.getState()
|
|
845
857
|
const local = useComments((s) => s.local)
|
|
858
|
+
const frame = useComments((s) => s.draft?.frame)
|
|
846
859
|
const [text, setText] = useState('')
|
|
847
860
|
const flip = at.x > bounds.w * 0.55
|
|
861
|
+
const send = (h: CmdHandle) => create(text, h)
|
|
862
|
+
const discard = () => setDraft(null)
|
|
848
863
|
return (
|
|
849
864
|
<div data-sh-wheel-local className={`cm-card cm-draft sh-no-pan${flip ? ' flip' : ''}`} style={{ left: at.x, top: Math.min(at.y + 14, bounds.h - 40), ...hueVars(hue) }}
|
|
850
865
|
onPointerDown={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}>
|
|
851
866
|
{/* the draft is JUST the tight pill - no avatar chrome on a first comment */}
|
|
852
867
|
<div className="cm-compose">
|
|
853
|
-
<CommentInput value={text} onChange={setText} onSubmit={
|
|
868
|
+
<CommentInput value={text} onChange={setText} onSubmit={send} onCancel={discard} placeholder="Comment on this element…" autoFocus sendLabel="Comment" owner={local} sendCmd="comment-send" frame={frame} />
|
|
854
869
|
</div>
|
|
855
870
|
</div>
|
|
856
871
|
)
|
|
@@ -862,15 +877,20 @@ function AvatarPick({ value, onPick }: { value: string; onPick: (dataUri: string
|
|
|
862
877
|
const fileRef = useRef<HTMLInputElement>(null)
|
|
863
878
|
const pick = (file: File | undefined) => {
|
|
864
879
|
if (!file) return
|
|
880
|
+
const h = cmd('avatar-pick', { via: 'click', in: 'shell' }) // never the file's name
|
|
865
881
|
const img = new Image()
|
|
866
882
|
img.onload = () => {
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
883
|
+
try {
|
|
884
|
+
const s = Math.min(img.width, img.height)
|
|
885
|
+
const c = document.createElement('canvas')
|
|
886
|
+
c.width = c.height = 128
|
|
887
|
+
c.getContext('2d')!.drawImage(img, (img.width - s) / 2, (img.height - s) / 2, s, s, 0, 0, 128, 128)
|
|
888
|
+
onPick(c.toDataURL('image/jpeg', 0.85))
|
|
889
|
+
h.done()
|
|
890
|
+
} catch { h.fail('unreadable') }
|
|
872
891
|
URL.revokeObjectURL(img.src)
|
|
873
892
|
}
|
|
893
|
+
img.onerror = () => { h.fail('unreadable'); URL.revokeObjectURL(img.src) }
|
|
874
894
|
img.src = URL.createObjectURL(file)
|
|
875
895
|
}
|
|
876
896
|
return (
|
|
@@ -917,17 +937,20 @@ export function IdentityDialog() {
|
|
|
917
937
|
const missing = claiming
|
|
918
938
|
? (invite ? 'Password and display name still needed' : 'Token, password, and display name still needed')
|
|
919
939
|
: 'Fill in email and password'
|
|
920
|
-
const go = async () => {
|
|
940
|
+
const go = async (how: CmdOpts) => {
|
|
921
941
|
if (!ready) return
|
|
942
|
+
const h = cmd(claiming ? 'claim' : 'sign-in', how)
|
|
922
943
|
setErr(null)
|
|
923
|
-
const e = claiming ? await claim(invite ?? token, password, name, avatar || undefined) : await signIn(email, password)
|
|
944
|
+
const e = claiming ? await claim(invite ?? token, password, name, avatar || undefined, h) : await signIn(email, password, h)
|
|
924
945
|
if (e) return setErr(e)
|
|
925
946
|
// a consumed invite link leaves the URL - the hash becomes the plain board view
|
|
926
947
|
if (invite) writeHash({ board: useStore.getState().board })
|
|
927
948
|
}
|
|
928
|
-
const onEnter = (e: React.KeyboardEvent) => e.key === 'Enter' && void go()
|
|
949
|
+
const onEnter = (e: React.KeyboardEvent) => e.key === 'Enter' && void go({ via: 'key', in: 'shell', keys: keysOf(e) })
|
|
950
|
+
// its own command, whatever a sign-in still in flight later answers (spec 30): that one keeps its own end
|
|
951
|
+
const dismiss = () => { cmd('identity-dismiss', { via: 'click', in: 'shell' }); dismissIdentity() }
|
|
929
952
|
return (
|
|
930
|
-
<div className="cm-modal-wrap" onClick={
|
|
953
|
+
<div className="cm-modal-wrap" onClick={dismiss}>
|
|
931
954
|
<div className="cm-modal" onClick={(e) => e.stopPropagation()}>
|
|
932
955
|
<h2>{invite ? 'You’re invited to comment' : claiming ? 'Sign up to comment' : 'Sign in to comment'}</h2>
|
|
933
956
|
<p className="dim">
|
|
@@ -964,7 +987,7 @@ export function IdentityDialog() {
|
|
|
964
987
|
{err && <span className="cm-err">{err}</span>}
|
|
965
988
|
<div className="cm-row">
|
|
966
989
|
{ready ? (
|
|
967
|
-
<button className="cm-primary" onClick={() => void go()}>
|
|
990
|
+
<button className="cm-primary" onClick={() => void go({ via: 'click', in: 'shell' })}>
|
|
968
991
|
{claiming ? (invite ? 'Join the canvas' : 'Create account') : 'Sign in'}
|
|
969
992
|
</button>
|
|
970
993
|
) : (
|
|
@@ -974,10 +997,10 @@ export function IdentityDialog() {
|
|
|
974
997
|
</button>
|
|
975
998
|
</Tip>
|
|
976
999
|
)}
|
|
977
|
-
<button onClick={
|
|
1000
|
+
<button onClick={dismiss}>Not now</button>
|
|
978
1001
|
</div>
|
|
979
1002
|
{!invite && (
|
|
980
|
-
<button className="cm-switch" onClick={() => { setErr(null); setMode(mode === 'signin' ? 'claim' : 'signin') }}>
|
|
1003
|
+
<button className="cm-switch" onClick={() => { cmd('identity-switch', { via: 'click', in: 'shell' }); setErr(null); setMode(mode === 'signin' ? 'claim' : 'signin') }}>
|
|
981
1004
|
{mode === 'signin' ? 'Have an invite token instead?' : 'Already have an account? Sign in'}
|
|
982
1005
|
</button>
|
|
983
1006
|
)}
|
|
@@ -1019,6 +1042,7 @@ export function CommentsController() {
|
|
|
1019
1042
|
const onDown = (e: PointerEvent) => {
|
|
1020
1043
|
const t = e.target instanceof Element ? e.target : null
|
|
1021
1044
|
if (t?.closest('.cm-card, .cm-pin, .cm-stack, .cm-modal')) return
|
|
1045
|
+
if (useComments.getState().active) cmd('thread-close', { via: 'click', in: 'shell' }) // silent when none is open
|
|
1022
1046
|
useComments.getState().setActive(null)
|
|
1023
1047
|
}
|
|
1024
1048
|
document.addEventListener('pointerdown', onDown, true)
|
|
@@ -3,12 +3,13 @@ import { createPortal } from 'react-dom'
|
|
|
3
3
|
import { useStore, SOURCE_REVEALED } from './store.ts'
|
|
4
4
|
import { UNPLACED } from './hash.ts'
|
|
5
5
|
import { TOP } from './inset.ts'
|
|
6
|
+
import type { CmdHandle } from './commands.ts'
|
|
6
7
|
|
|
7
8
|
/** Copy text to the clipboard, toasting the outcome. Success is confirmed out loud; a
|
|
8
9
|
* blocked clipboard (no user gesture / permission) says so instead of failing silently. */
|
|
9
|
-
export function copyToClipboard(text: string, okMsg: string) {
|
|
10
|
+
export function copyToClipboard(text: string, okMsg: string, h: CmdHandle) {
|
|
10
11
|
const { toast } = useStore.getState()
|
|
11
|
-
navigator.clipboard.writeText(text).then(() => toast(okMsg), () => toast('copy blocked - click the canvas first'))
|
|
12
|
+
navigator.clipboard.writeText(text).then(() => { h.done(); toast(okMsg) }, () => { h.fail('clipboard-blocked'); toast('copy blocked - click the canvas first') })
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
/** The address a frame copies - the same string from the sidebar right-click, the floating
|