@marver-design/marver 0.25.1 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +116 -0
- package/README.md +5 -3
- package/dist/{anchor-DVV732zR.mjs → anchor-5H1vnoLu.mjs} +6 -1
- package/dist/{anchor-check-DGZnYviN.mjs → anchor-check-l-ny3UzH.mjs} +1 -1
- package/dist/audio-Dw1lfMdb.mjs +443 -0
- package/dist/{auth-DdUKeVKt.mjs → auth-Dix8wrXV.mjs} +1 -1
- package/dist/{bake-BpxMZfij.mjs → bake-C-awKgLA.mjs} +1 -1
- package/dist/{boards-Csxj2WJn.mjs → boards-DYG22tOe.mjs} +2 -2
- package/dist/{build-DKaGhoVN.mjs → build-BDRiO_mP.mjs} +16 -9
- package/dist/capture-vadKjuCo.mjs +730 -0
- package/dist/cli.mjs +24 -18
- package/dist/{collab-gqNdScUE.mjs → collab-Dxg2trOK.mjs} +4 -3
- package/dist/{comments-Zoch254k.mjs → comments-0BSbb04K.mjs} +14 -3
- package/dist/{comments-pTLlhjh4.mjs → comments-BqXua-XL.mjs} +7 -7
- package/dist/{config-cKgZBRj0.mjs → config-Cf7EjAMf.mjs} +12 -1
- package/dist/{context-D2ugHqwO.mjs → context-HQ4Giw58.mjs} +1 -1
- package/dist/daemon-DL6Fwq6D.mjs +2569 -0
- package/dist/{dev-Diqx1Rt8.mjs → dev-Bw_qYWWq.mjs} +202 -18
- package/dist/dev-lock-DWSpa6nj.mjs +179 -0
- package/dist/{events-DnK_AnrW.mjs → events-CLH4ijKP.mjs} +14 -4
- package/dist/{init-DO4DhUt_.mjs → init-D8DtrK_F.mjs} +2 -2
- package/dist/{ledger-BNXW14Xw.mjs → ledger-D54iROST.mjs} +17 -1
- package/dist/{link-C-qUIuKU.mjs → link-BNzLvdhI.mjs} +2 -2
- package/dist/live-Cgzsicwi.mjs +4 -0
- package/dist/{manifest-DnAte_fB.mjs → manifest-Nl3KSVOk.mjs} +1 -1
- package/dist/{marks-koRsbHfe.mjs → marks-CKgzucHZ.mjs} +2 -2
- package/dist/{marks-DFuintmJ.mjs → marks-DyWMv_Z1.mjs} +23 -5
- package/dist/{marver-id-gate-DGANtVyC.mjs → marver-id-gate-BjF6v4bT.mjs} +4 -4
- package/dist/perf-C75MZ73h.mjs +167 -0
- package/dist/{perf-CCisg-ny.mjs → perf-DPbLGhhO.mjs} +1 -1
- package/dist/perf-jam-BU3TVrZu.mjs +239 -0
- package/dist/{plugin-dTF5reck.mjs → plugin-DkGmZs_r.mjs} +298 -38
- package/dist/{poster-D-zjYpgk.mjs → poster-BdtSKMDm.mjs} +2 -1
- package/dist/{profile-Do0nGkXO.mjs → profile-WU9qcbIo.mjs} +1 -1
- package/dist/{publish-bakes-C_9VZ-Mq.mjs → publish-bakes-9RzRToXV.mjs} +3 -3
- package/dist/queue-29ok5_eZ.mjs +1319 -0
- package/dist/reserve-BURNQ2Y3.mjs +53 -0
- package/dist/{rolldown-runtime-D7D4PA-g.mjs → rolldown-runtime-8H4AJuhK.mjs} +1 -0
- package/dist/{serve-wv2QWdxB.mjs → serve-C8rVheYk.mjs} +12 -12
- package/dist/session-BAaJsK5c.mjs +191 -0
- package/dist/{share-ScamJcks.mjs → share--oFJ1bCI.mjs} +2 -2
- package/dist/{shot-CUlmkqFX.mjs → shot-DQeR_Pfn.mjs} +339 -20
- package/dist/shot-XQV7HC9A.mjs +139 -0
- package/dist/speech-models-DomiLQcY.mjs +299 -0
- package/dist/speech-worker.mjs +354 -0
- package/dist/{summary-CrW88e3q.mjs → summary-Y8MY1Wuc.mjs} +2 -2
- package/dist/{sync-C3035OnJ.mjs → sync-DKk-yT1V.mjs} +9 -8
- package/dist/{work-GE88wb_3.mjs → work-F5u-twpJ.mjs} +28 -5
- package/dist/{work-CpJn1gwY.mjs → work-VvX_JIgl.mjs} +2 -2
- package/docs/jam-session.md +194 -0
- package/docs/live-jam.md +29 -3
- package/package.json +7 -1
- package/src/client/frame-host/bridge.js +20 -2
- package/src/client/frame-host/inspect.d.ts +4 -0
- package/src/client/frame-host/inspect.js +96 -6
- package/src/client/frame-host/keys.d.ts +6 -0
- package/src/client/frame-host/keys.js +59 -0
- package/src/client/frame-host/trail.d.ts +7 -0
- package/src/client/frame-host/trail.js +204 -0
- package/src/client/shell/App.tsx +52 -8
- package/src/client/shell/Comments.tsx +20 -6
- package/src/client/shell/JamSurface.tsx +346 -0
- package/src/client/shell/Play.tsx +32 -9
- package/src/client/shell/Tip.tsx +8 -3
- package/src/client/shell/Toolbar.tsx +5 -4
- package/src/client/shell/canvas/Canvas.tsx +12 -2
- package/src/client/shell/canvas/FrameNode.tsx +14 -4
- package/src/client/shell/comments-store.ts +23 -16
- package/src/client/shell/icons.tsx +17 -0
- package/src/client/shell/jam-capture.ts +1005 -0
- package/src/client/shell/jam-keys.ts +358 -0
- package/src/client/shell/jam-lane.tsx +249 -0
- package/src/client/shell/jam-lines.ts +115 -0
- package/src/client/shell/jam-panel.tsx +556 -0
- package/src/client/shell/jam-queue.ts +126 -0
- package/src/client/shell/jam-session.tsx +389 -0
- package/src/client/shell/jam-state.ts +103 -0
- package/src/client/shell/jam-surface-parts.tsx +106 -0
- package/src/client/shell/jam-ui.tsx +104 -0
- package/src/client/shell/jam-voice.ts +479 -0
- package/src/client/shell/sound.ts +22 -0
- package/src/client/shell/stage-size.ts +11 -0
- package/src/client/shell/store.ts +47 -17
- package/src/client/shell/styles.css +564 -2
- package/src/client/stage/main.tsx +18 -2
- package/src/shared/capture-frames.ts +41 -0
- package/src/shared/events.ts +19 -4
- package/src/shared/speech.ts +16 -0
- package/templates/AGENTS-embedded.md +10 -2
- package/templates/AGENTS-studio.md +10 -2
- package/templates/instructions/iterate.md +8 -6
- package/templates/instructions/jam.md +131 -59
- package/dist/daemon-Cl8KXGW4.mjs +0 -1523
- package/dist/perf-QJIWtTw1.mjs +0 -68
- package/dist/shot-jdO_B6Qw.mjs +0 -86
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jam's surfaces in the shell (spec 27): the lane along the bottom (captures only, in the order made,
|
|
3
|
+
* the one recording last), the one focus panel (a capture's detail - a draft's read-back - or a
|
|
4
|
+
* review), the notes card over the capture tile, the teal edge ring and the numbered points while a
|
|
5
|
+
* capture records. The pieces are presentational (jam-lane.tsx, jam-panel.tsx); this file feeds
|
|
6
|
+
* them from the three stores and turns their clicks into queue actions.
|
|
7
|
+
*/
|
|
8
|
+
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
9
|
+
import { ROUTE } from '../const.ts'
|
|
10
|
+
import { captureCounts, useJamCapture } from './jam-capture.ts'
|
|
11
|
+
import { useJamVoice, voiceSession, voiceSessionEnd, voiceSessionId, type Heard } from './jam-voice.ts'
|
|
12
|
+
import { holdsSessionMic, PlayCounter, RecordDetail, StartSheet, WrapSheet } from './jam-session.tsx'
|
|
13
|
+
import { FocusPanel, VoiceAsk } from './jam-panel.tsx'
|
|
14
|
+
import { addNote, decideDraft, laneCards, openThread, openTile, pendingEdit, resumeDraft, reveal, saveEdit, shownLane, startCapture } from './jam-keys.ts'
|
|
15
|
+
import { ContextMenu, useContextMenu, type MenuItem } from './ContextMenu.tsx'
|
|
16
|
+
import { ArrowBendUpLeftIcon, ArrowLineUpIcon, ArrowUpIcon, CheckSquareOffsetIcon, CommentIcon, EyeIcon, NotebookIcon, PencilSimpleIcon, PlayIcon, ReloadIcon, XIcon } from './icons.tsx'
|
|
17
|
+
import { laneLine, timelineLines } from './jam-lines.ts'
|
|
18
|
+
import { changedShots, useJamQueue, type JamCard } from './jam-queue.ts'
|
|
19
|
+
import { DONE_GROUP, doneFold, letGoOfTile, useJamUi } from './jam-state.ts'
|
|
20
|
+
import { CaptureLaneRow, FocusPanelView } from './jam-surface-parts.tsx'
|
|
21
|
+
import { clearMoreDraft, EdgeRing } from './jam-panel.tsx'
|
|
22
|
+
import { useComments } from './comments-store.ts'
|
|
23
|
+
import { HARNESS } from './Comments.tsx'
|
|
24
|
+
import { PUBLISHED, useStore } from './store.ts'
|
|
25
|
+
import type { CaptureRecord } from '../../server/jam/types.ts'
|
|
26
|
+
|
|
27
|
+
const csrf = () => /(?:^|;\s*)mv_c=([\w-]+)/.exec(document.cookie)?.[1] ?? ''
|
|
28
|
+
const picture = (id?: string) => (id ? `${ROUTE}/api/jam/picture?id=${encodeURIComponent(id)}` : undefined)
|
|
29
|
+
|
|
30
|
+
/** Is the lane showing? While a run lasts with a capture in it, or a capture records. */
|
|
31
|
+
export function useLaneShown(): boolean {
|
|
32
|
+
const cards = useJamQueue((s) => s.cards)
|
|
33
|
+
const run = useJamQueue((s) => s.run)
|
|
34
|
+
// a capture recording, sealing or waiting to send keeps the lane up until its server card arrives
|
|
35
|
+
const busy = useJamCapture((s) => !!s.current || Object.keys(s.caps).length > 0 || s.unsent.length > 0)
|
|
36
|
+
// a session keeps it up from start to end: between captures its own tile says it is still on
|
|
37
|
+
const session = useJamQueue((s) => !!s.session)
|
|
38
|
+
return !PUBLISHED && (busy || session || laneCards(cards, run).length > 0)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A capture's record, loaded once per id for its detail. */
|
|
42
|
+
function useRecord(id: string | undefined) {
|
|
43
|
+
const [rec, setRec] = useState<{ id: string; record: CaptureRecord; edited?: string } | null>(null)
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!id || rec?.id === id) return
|
|
46
|
+
let live = true
|
|
47
|
+
fetch(`${ROUTE}/api/jam/capture?id=${encodeURIComponent(id)}`, { headers: { 'x-mv-c': csrf() } })
|
|
48
|
+
.then((r) => (r.ok ? r.json() : null)).then((r) => { if (live && r?.record) setRec({ id, record: r.record, edited: r.edited }) }, () => {})
|
|
49
|
+
return () => { live = false }
|
|
50
|
+
}, [id])
|
|
51
|
+
return rec?.id === id ? rec : null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
|
|
55
|
+
const cards = useJamQueue((s) => s.cards)
|
|
56
|
+
const run = useJamQueue((s) => s.run)
|
|
57
|
+
const agent = useJamQueue((s) => s.agent)
|
|
58
|
+
const ui = useJamUi()
|
|
59
|
+
const cap = useJamCapture()
|
|
60
|
+
const voice = useJamVoice()
|
|
61
|
+
const shown = useLaneShown()
|
|
62
|
+
const session = useJamQueue((s) => s.session)
|
|
63
|
+
const playing = useStore((s) => !!s.play)
|
|
64
|
+
const [, setTick] = useState(0)
|
|
65
|
+
// the capture tile's timer and a working card's clock move
|
|
66
|
+
useEffect(() => { const t = setInterval(() => setTick((n) => n + 1), 1000); return () => clearInterval(t) }, [])
|
|
67
|
+
// a new capture or a new draft brings the lane back to its right end
|
|
68
|
+
useEffect(() => { ui.follow() }, [cap.current, cards?.filter((c) => c.kind === 'capture').length])
|
|
69
|
+
// the read-back of the capture just ended opens when capturing stops - over a review too (a capture
|
|
70
|
+
// made during a review is confirmed in its read-back; the review it follows stays bound in its record).
|
|
71
|
+
// It waits for that capture's own card: a resumed one replaces its draft, which must not open instead
|
|
72
|
+
// the capture ENDED last, not the one that sealed last (pictures can keep an earlier one sealing longer)
|
|
73
|
+
const [shownFor, setShownFor] = useState<string | null>(null)
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (cap.current || !cap.lastEnded || cap.lastEnded === shownFor) return
|
|
76
|
+
const sealed = cap.sealed.find((x) => x.id === cap.lastEnded)
|
|
77
|
+
if (!sealed?.card) return
|
|
78
|
+
const draft = cards?.find((c) => c.id === sealed.card!.id && c.state === 'draft')
|
|
79
|
+
if (!draft) return
|
|
80
|
+
setShownFor(cap.lastEnded)
|
|
81
|
+
if (ui.panel?.kind === 'capture' && ui.panel.id === draft.id) return
|
|
82
|
+
ui.open({ kind: 'capture', id: draft.id })
|
|
83
|
+
reveal(draft)
|
|
84
|
+
}, [cap.current, cap.sealed, cap.lastEnded, cards])
|
|
85
|
+
|
|
86
|
+
// the session as the server holds it: a page opened (or reloaded) during one hears its talk again; one
|
|
87
|
+
// ended elsewhere (another tab) stops the talk here
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
// only the tab that holds the session's microphone hears its talk - another tab never takes it over
|
|
90
|
+
const heard = voiceSessionId()
|
|
91
|
+
if (session && heard !== session.id && holdsSessionMic(session.id)) void voiceSession(session.id, performance.timeOrigin + performance.now())
|
|
92
|
+
// the talk of a session that is not the server's (ended, or another one) stops here
|
|
93
|
+
else if (heard && heard !== session?.id) void voiceSessionEnd()
|
|
94
|
+
}, [session?.id])
|
|
95
|
+
|
|
96
|
+
// J pressed while a capture recorded: the wrap-up waits for that capture's read-back to have opened and
|
|
97
|
+
// closed (or for it to have no draft at all - dropped, or kept at once)
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (ui.sheet !== 'wrap-pending' || cap.current || Object.keys(cap.caps).length || cap.unsent.length) return
|
|
100
|
+
const id = cap.lastEnded
|
|
101
|
+
const card = id ? cards?.find((c) => c.id === id) : undefined
|
|
102
|
+
// sealed but its card not here yet: wait for it (a dropped capture never sealed - nothing to wait for)
|
|
103
|
+
if (id && !card && cap.sealed.some((x) => x.id === id)) return
|
|
104
|
+
// a draft: its read-back first - opened, then closed (confirmed, kept, dropped, or set aside)
|
|
105
|
+
if (card && card.state === 'draft' && (shownFor !== id || ui.panel?.id === id)) return
|
|
106
|
+
ui.setSheet('wrap')
|
|
107
|
+
}, [ui.sheet, ui.panel, cap.current, cap.caps, cap.unsent, cap.lastEnded, cards, shownFor])
|
|
108
|
+
|
|
109
|
+
// a draft being resumed is the capture recording (or sealing) now: its own tile steps aside
|
|
110
|
+
const list = shownLane(cards, run, cap.resuming)
|
|
111
|
+
const cm = useContextMenu()
|
|
112
|
+
// a comment opening (a pin, a thread, Open thread) takes the place of the read-back or review: the panel
|
|
113
|
+
// closes; the tile lets go too, unless the thread is that tile's own (a capture that asks opens its thread)
|
|
114
|
+
useEffect(() => useComments.subscribe((s, p) => {
|
|
115
|
+
if (!s.active || s.active === p.active) return
|
|
116
|
+
const st = useJamUi.getState()
|
|
117
|
+
const sel = useJamQueue.getState().cards?.find((c) => c.id === st.selected)
|
|
118
|
+
if (sel?.thread === s.active) { if (st.panel) st.close() } else letGoOfTile()
|
|
119
|
+
}), [])
|
|
120
|
+
const made = (id: string) => Number(/^cap-(\d+)-/.exec(id)?.[1] ?? 0)
|
|
121
|
+
const withMade = list.map((c) => ({ made: c.made, tile: { id: c.id, state: c.state, title: c.title ?? 'Capture', line: laneLine(c), ...(c.exclusive ? { exclusive: true } : {}), ...(c.state === 'done' && c.shots?.some((x) => !x.same) ? { frames: c.shots.filter((x) => !x.same).map((x) => x.frame) } : {}), ...(c.kind === 'wrapup' ? { record: true } : {}) } as { id: string; state: JamCard['state']; title: string; line: string; exclusive?: boolean; frames?: string[]; record?: boolean } }))
|
|
122
|
+
// captures the server does not hold yet: sealing (pictures and flushes still out) or waiting to send -
|
|
123
|
+
// each in its place by when it started, so one sealing late never swaps with a newer one
|
|
124
|
+
const known = new Set(list.map((c) => c.id))
|
|
125
|
+
for (const c of Object.values(cap.caps)) if (c.state === 'draining' && !known.has(c.id)) withMade.push({ made: made(c.id), tile: { id: c.id, state: 'confirming', title: 'Capture', line: 'Finishing' } })
|
|
126
|
+
for (const id of cap.unsent) if (!known.has(id) && !cap.caps[id]) withMade.push({ made: made(id), tile: { id, state: 'confirming', title: 'Capture', line: 'Waiting to send' } })
|
|
127
|
+
const tiles = withMade.sort((a, b) => a.made - b.made).map((x) => x.tile)
|
|
128
|
+
// a selected tile that became done while the Done group is folded: the group holds the selection now
|
|
129
|
+
const doneNow = doneFold(tiles, ui.doneOpen)
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (doneNow.fold && !ui.doneOpen && ui.selected && doneNow.done.some((t) => t.id === ui.selected)) ui.select(DONE_GROUP)
|
|
132
|
+
}, [doneNow.fold, ui.doneOpen, ui.selected, doneNow.done.length])
|
|
133
|
+
const recording = cap.current ? (() => {
|
|
134
|
+
const c = cap.caps[cap.current!]
|
|
135
|
+
const counts = captureCounts(c)
|
|
136
|
+
const steps = (c?.steps ?? []).filter((x) => ['select', 'device', 'theme', 'copied', 'interact'].includes(x.event)).length
|
|
137
|
+
return { time: counts.time, points: c?.points.length ?? 0, pictures: c?.pictures.length ?? 0, picturesMax: (c?.pictures.length ?? 0) >= 12, steps,
|
|
138
|
+
notes: counts.notes, noteOn: cap.noteOpen, onNote: () => cap.setNoteOpen(!cap.noteOpen), onStop: () => cap.end(),
|
|
139
|
+
// the microphone: on while it hears this capture; off once you were asked (a click asks again)
|
|
140
|
+
...(voice.hearing === cap.current ? { mic: 'on' as const } : voice.choice !== null || voice.denied ? { mic: 'off' as const, onMic: () => useJamVoice.setState({ asking: true, choice: null }) } : {}) }
|
|
141
|
+
})() : undefined
|
|
142
|
+
|
|
143
|
+
// a session between captures (none recording, none still sealing here): its own tile
|
|
144
|
+
const between = session && !cap.current ? {
|
|
145
|
+
since: session.since, mic: voice.live,
|
|
146
|
+
onCapture: () => startCapture(), // as S: one started over an open review follows it
|
|
147
|
+
} : undefined
|
|
148
|
+
|
|
149
|
+
const panelCard = ui.panel ? cards?.find((c) => c.id === ui.panel!.id) : undefined
|
|
150
|
+
const rec = useRecord(ui.panel?.kind === 'capture' || ui.panel?.kind === 'review' ? ui.panel.id : undefined)
|
|
151
|
+
const agentName = agent ? HARNESS[agent] ?? agent : 'your agent'
|
|
152
|
+
const act = (c: JamCard | undefined, action: Parameters<ReturnType<typeof useJamQueue.getState>['act']>[1], body?: string) => (c ? useJamQueue.getState().act(c, action, body) : Promise.resolve(false))
|
|
153
|
+
const openThread = (c?: JamCard) => { if (c?.thread) useComments.getState().setActive(c.thread) }
|
|
154
|
+
/** The panel's arrows: the previous or next card of the same kind on the lane (reviews among reviews). */
|
|
155
|
+
const step = (d: number) => {
|
|
156
|
+
if (!ui.panel || !panelCard) return undefined
|
|
157
|
+
const of = list.filter((c) => (ui.panel!.kind === 'review' ? c.state === 'review' : true))
|
|
158
|
+
const n = of[of.findIndex((c) => c.id === panelCard.id) + d]
|
|
159
|
+
return n ? () => openTile(n.id) : undefined
|
|
160
|
+
}
|
|
161
|
+
const detail = useMemo(() => {
|
|
162
|
+
if (!ui.panel || !panelCard) return null
|
|
163
|
+
const of = list.filter((c) => (ui.panel!.kind === 'review' ? c.state === 'review' : true))
|
|
164
|
+
const idx = of.findIndex((c) => c.id === panelCard.id)
|
|
165
|
+
return { of: [idx + 1, of.length] as [number, number] }
|
|
166
|
+
}, [ui.panel, panelCard, list])
|
|
167
|
+
|
|
168
|
+
const sheetOpen = ui.sheet === 'start' || ui.sheet === 'wrap'
|
|
169
|
+
// the microphone question in a session with no capture recording: under the Jam button
|
|
170
|
+
const askAlone = voice.asking && !cap.current && !!session
|
|
171
|
+
if (!shown && !ui.panel && !sheetOpen && !askAlone) return null
|
|
172
|
+
// in play the lane folds to a counter beside the navigator (Q opens it); the capture recording stays
|
|
173
|
+
const folded = playing && !ui.laneKeys
|
|
174
|
+
return (
|
|
175
|
+
<>
|
|
176
|
+
{/* the edges glow while a capture records - and for the whole session, between captures too */}
|
|
177
|
+
{(cap.current || session) && <EdgeRing />}
|
|
178
|
+
{ui.sheet === 'start' && <div className="jm-sheet-at"><StartSheet /></div>}
|
|
179
|
+
{ui.sheet === 'wrap' && <div className="jm-sheet-at"><WrapSheet /></div>}
|
|
180
|
+
{askAlone && !sheetOpen && <div className="jm-sheet-at"><VoiceAsk {...voiceAsk(voice)} /></div>}
|
|
181
|
+
{folded && shown && <PlayCounter cards={list} style={{ left: playNavRight(), bottom: 'var(--edge)' }} />}
|
|
182
|
+
{shown && (
|
|
183
|
+
<CaptureLaneRow
|
|
184
|
+
tiles={folded ? [] : tiles} recording={recording} between={between} selected={ui.selected ?? undefined} keyboard={ui.laneKeys} followEnd={ui.followEnd}
|
|
185
|
+
doneOpen={ui.doneOpen} onDoneOpen={(open, ids) => ui.setDoneOpen(open, ids)}
|
|
186
|
+
onOpen={(id) => openTile(id)}
|
|
187
|
+
onMenu={(e, id) => { const c = cards?.find((x) => x.id === id); if (c) { ui.select(id); cm.open(e, tileMenu(c)) } else e.preventDefault() }}
|
|
188
|
+
ask={voice.asking && cap.current ? voiceAsk(voice) : undefined}
|
|
189
|
+
caption={cap.current ? captionOf(voice.heard[cap.current]) : undefined}
|
|
190
|
+
notes={cap.noteOpen ? {
|
|
191
|
+
notes: (cap.current ? cap.caps[cap.current]?.steps ?? [] : []).filter((x) => x.event === 'note').map((x) => ({ t: captureCounts({ ...cap.caps[cap.current!]!, t0: cap.caps[cap.current!]!.t0 }, x.at).time, text: (x as { text: string }).text })),
|
|
192
|
+
draft: cap.noteDraft, onDraft: cap.setNoteDraft, onAdd: () => cap.note(cap.noteDraft), onClose: () => cap.setNoteOpen(false),
|
|
193
|
+
} : undefined}
|
|
194
|
+
/>
|
|
195
|
+
)}
|
|
196
|
+
{ui.panel && panelCard && panelCard.kind === 'wrapup' && (
|
|
197
|
+
<FocusPanel left={sidebarRight} onClose={() => ui.close()}>
|
|
198
|
+
<RecordDetail key={panelCard.id} card={panelCard} agent={agentName} more={ui.moreOpen} of={detail?.of} onPrev={step(-1)} onNext={step(1)}
|
|
199
|
+
onMoreOpen={(on) => ui.setMoreOpen(on)}
|
|
200
|
+
onGood={() => { void act(panelCard, 'good'); ui.close() }}
|
|
201
|
+
onLater={() => { void act(panelCard, 'later'); ui.close() }}
|
|
202
|
+
onRetry={() => { void act(panelCard, 'retry'); ui.close() }}
|
|
203
|
+
onDrop={() => { void act(panelCard, 'drop'); ui.close() }}
|
|
204
|
+
onMore={(text) => void (async () => {
|
|
205
|
+
if (await act(panelCard, 'more', text)) { clearMoreDraft(panelCard.id); ui.setMoreOpen(false); ui.close() }
|
|
206
|
+
else useStore.getState().toast('your note was not sent - try again')
|
|
207
|
+
})()} />
|
|
208
|
+
</FocusPanel>
|
|
209
|
+
)}
|
|
210
|
+
{ui.panel && panelCard && panelCard.kind !== 'wrapup' && (
|
|
211
|
+
<FocusPanelView
|
|
212
|
+
left={sidebarRight}
|
|
213
|
+
kind={ui.panel.kind}
|
|
214
|
+
card={panelCard}
|
|
215
|
+
of={detail?.of}
|
|
216
|
+
agent={agentName}
|
|
217
|
+
reviewedTitle={panelCard.reviewing ? cards?.find((c) => c.id === panelCard.reviewing!.card)?.title : undefined}
|
|
218
|
+
lines={rec ? timelineLines(rec.record, panelCard.edited ?? rec.edited) : []}
|
|
219
|
+
pictures={(rec?.record.pictures ?? []).map((id, i) => ({ id, url: picture(id)!, caption: `picture ${i + 1}` }))}
|
|
220
|
+
shots={changedShots(panelCard.shots).map((x) => ({ frame: x.frame, before: picture(x.before), after: picture(x.after), ...(x.new ? { new: true } : {}) }))}
|
|
221
|
+
reply={panelCard.reply ? replyText(panelCard) : ''}
|
|
222
|
+
view={ui.view} tab={ui.tab} moreOpen={ui.moreOpen}
|
|
223
|
+
onTab={(i) => ui.setTab(i)} onFlip={(v) => ui.setView(v)} onMoreOpen={(on) => ui.setMoreOpen(on)}
|
|
224
|
+
onClose={() => ui.close()}
|
|
225
|
+
onEdit={(text) => saveEdit(panelCard, text)}
|
|
226
|
+
onConfirm={() => void decideDraft(panelCard.id, 'confirm')}
|
|
227
|
+
onKeep={() => void decideDraft(panelCard.id, 'keep')}
|
|
228
|
+
onDrop={() => void decideDraft(panelCard.id, 'drop')}
|
|
229
|
+
onResume={() => void resumeDraft(panelCard.id)}
|
|
230
|
+
onAddNote={async (text, id) => { const ok = await addNote(panelCard, text, id); if (!ok) useStore.getState().toast('the note was not added - try again'); return ok }}
|
|
231
|
+
onGood={() => { void act(panelCard, 'good'); ui.close() }}
|
|
232
|
+
onMore={(text) => void (async () => {
|
|
233
|
+
// the composer and its words stay until the follow-up is really queued
|
|
234
|
+
if (await act(panelCard, 'more', text)) { clearMoreDraft(panelCard.id); ui.setMoreOpen(false); ui.close() }
|
|
235
|
+
else useStore.getState().toast('your follow-up was not sent - try again')
|
|
236
|
+
})()}
|
|
237
|
+
onLater={() => { void act(panelCard, 'later'); ui.close() }}
|
|
238
|
+
onOpenThread={() => openThread(panelCard)}
|
|
239
|
+
onPrev={step(-1)} onNext={step(1)} pending={pendingEdit(panelCard.id)} locked={cap.settling === panelCard.id}
|
|
240
|
+
onRetry={() => void (async () => { if (await act(useJamQueue.getState().cards?.find((x) => x.id === panelCard.id), 'retry')) ui.close(); else useStore.getState().toast('the capture could not be retried - look again') })()}
|
|
241
|
+
/>
|
|
242
|
+
)}
|
|
243
|
+
<ContextMenu menu={cm.menu} close={cm.close} />
|
|
244
|
+
</>
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** In play: just right of the stage's navigator (its restart and frame arrows), where the counter sits. */
|
|
249
|
+
function playNavRight(): number {
|
|
250
|
+
const r = document.querySelector('.sh-play-nav')?.getBoundingClientRect()
|
|
251
|
+
return r ? Math.round(r.right + 8) : 176
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** What the microphone question shows now: the question, the download, its progress. */
|
|
255
|
+
function voiceAsk(v: ReturnType<typeof useJamVoice.getState>) {
|
|
256
|
+
const d = v.download
|
|
257
|
+
const step = v.choice === null ? 'ask' as const
|
|
258
|
+
// the engine could not start: why, and a way to try again - never a download that would not help
|
|
259
|
+
: v.server === 'unavailable' ? 'unavailable' as const
|
|
260
|
+
: d?.state === 'downloading' ? 'downloading' as const : d?.state === 'checking' ? 'checking' as const
|
|
261
|
+
: d?.state === 'failed' ? 'failed' as const : 'download' as const
|
|
262
|
+
return {
|
|
263
|
+
step, mb: v.mb, progress: d && d.total ? d.received / d.total : 0, error: v.server === 'unavailable' ? v.reason : d?.error,
|
|
264
|
+
onYes: () => v.setChoice('yes'), onNo: () => v.setChoice('no'), onDownload: () => void v.startDownload(),
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** The caption's words: the newest phrase in ink, a little of what came before it dim. */
|
|
269
|
+
function captionOf(heard: Heard[] | undefined): { old: string; live: string } | undefined {
|
|
270
|
+
if (!heard?.length) return undefined
|
|
271
|
+
const text = heard.map((w) => w.w)
|
|
272
|
+
const live = text.slice(-12)
|
|
273
|
+
const old = text.slice(Math.max(0, text.length - 24), Math.max(0, text.length - 12))
|
|
274
|
+
return { old: old.join(' '), live: live.join(' ') }
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Open a card's thread with the caret in its reply field - to add to the conversation. */
|
|
278
|
+
function replyIn(c: JamCard) {
|
|
279
|
+
if (!c.thread) return
|
|
280
|
+
openThread(c)
|
|
281
|
+
// once the thread's card has drawn (on another board, once that board has loaded)
|
|
282
|
+
const until = performance.now() + 3_000
|
|
283
|
+
const focus = () => {
|
|
284
|
+
const el = useComments.getState().active === c.thread ? document.querySelector<HTMLTextAreaElement>('.cm-card textarea') : null
|
|
285
|
+
if (el) { el.focus(); el.setSelectionRange(el.value.length, el.value.length) } else if (performance.now() < until) requestAnimationFrame(focus)
|
|
286
|
+
}
|
|
287
|
+
requestAnimationFrame(focus)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** A tile's right-click menu: what can be done with this capture now. */
|
|
291
|
+
function tileMenu(c: JamCard): MenuItem[] {
|
|
292
|
+
const q = useJamQueue.getState()
|
|
293
|
+
const act = (a: Parameters<typeof q.act>[1], body?: string) => { const fresh = useJamQueue.getState().cards?.find((x) => x.id === c.id); if (fresh) void useJamQueue.getState().act(fresh, a, body) }
|
|
294
|
+
const item = (label: string, icon: ReactNode, onClick: () => void): MenuItem => ({ label, icon, onClick })
|
|
295
|
+
// one icon per action, never two alike in a menu: open (eye), review (checklist), resume (play), rename
|
|
296
|
+
// (pencil), add to queue (send arrow), keep (notebook), do next (to the top), retry, reply, thread, drop
|
|
297
|
+
const open = item(c.state === 'review' ? 'Review' : c.state === 'draft' ? 'Open read-back' : 'Open', c.state === 'review' ? <CheckSquareOffsetIcon size={14} /> : <EyeIcon size={14} />, () => openTile(c.id))
|
|
298
|
+
const rename: MenuItem = { label: 'Rename', icon: <PencilSimpleIcon size={14} />, panel: (close) => <RenameField card={c} close={close} /> }
|
|
299
|
+
const reply = c.thread ? [item('Reply in thread', <ArrowBendUpLeftIcon size={14} />, () => replyIn(c))] : []
|
|
300
|
+
const thread = c.thread ? [item('Open thread', <CommentIcon size={14} />, () => openThread(c))] : []
|
|
301
|
+
switch (c.state) {
|
|
302
|
+
case 'draft': return [open, item('Resume capture', <PlayIcon size={14} />, () => void resumeDraft(c.id)), rename,
|
|
303
|
+
item('Add to queue', <ArrowUpIcon size={14} />, () => void decideDraft(c.id, 'confirm')), item('Keep, do not send', <NotebookIcon size={14} />, () => void decideDraft(c.id, 'keep')),
|
|
304
|
+
item('Drop', <XIcon size={14} />, () => void decideDraft(c.id, 'drop'))]
|
|
305
|
+
case 'queued': return c.kind === 'capture'
|
|
306
|
+
? [open, rename, item('Do next', <ArrowLineUpIcon size={14} />, () => act('first')), item('Keep, do not send', <NotebookIcon size={14} />, () => act('keep')), item('Drop', <XIcon size={14} />, () => act('drop'))]
|
|
307
|
+
: [open, item('Drop', <XIcon size={14} />, () => act('drop'))] // a queued record: open or drop it
|
|
308
|
+
case 'review': return [open, ...reply, ...thread, rename]
|
|
309
|
+
case 'asks': return [...reply, open, rename]
|
|
310
|
+
case 'failed': return [item('Retry', <ReloadIcon size={14} />, () => act('retry')), open, ...thread, item('Drop', <XIcon size={14} />, () => act('drop'))]
|
|
311
|
+
default: return [open, ...reply, ...thread, rename]
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Rename, in place of the menu: the title as it is, ⏎ saves, Esc leaves; empty gives back its first words. */
|
|
316
|
+
function RenameField({ card, close }: { card: JamCard; close: () => void }) {
|
|
317
|
+
const [text, setText] = useState(card.named ? card.title ?? '' : card.title === 'Capture' ? '' : card.title ?? '')
|
|
318
|
+
const ref = useRef<HTMLInputElement>(null)
|
|
319
|
+
useEffect(() => { requestAnimationFrame(() => ref.current?.select()) }, [])
|
|
320
|
+
const save = async () => {
|
|
321
|
+
const fresh = useJamQueue.getState().cards?.find((x) => x.id === card.id)
|
|
322
|
+
if (fresh && !(await useJamQueue.getState().act(fresh, 'rename', text))) useStore.getState().toast('the capture could not be renamed - look again')
|
|
323
|
+
close()
|
|
324
|
+
}
|
|
325
|
+
return (
|
|
326
|
+
<div className="jm-rename">
|
|
327
|
+
<input ref={ref} value={text} maxLength={80} placeholder="Name this capture" aria-label="Capture name"
|
|
328
|
+
onChange={(e) => setText(e.target.value)}
|
|
329
|
+
onKeyDown={(e) => { e.stopPropagation(); if (e.key === 'Enter') void save(); if (e.key === 'Escape') close() }} />
|
|
330
|
+
</div>
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** The agent's reply to a card, as the thread shows it. */
|
|
335
|
+
function replyText(c: JamCard): string {
|
|
336
|
+
const threads = useComments.getState().threads
|
|
337
|
+
const t = threads.find((x) => x.id === c.thread)
|
|
338
|
+
return t?.replies.find((r) => r.id === c.reply)?.body ?? ''
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** Lift the bottom edge while the lane shows: the sidebar stops above it, the Update pill, toasts and
|
|
342
|
+
* notices rise one lane. Returns the class for `.sh-app` - in its className, so a re-render of the app
|
|
343
|
+
* (interact on or off, the theme) never drops it. */
|
|
344
|
+
export function useLaneLift(): string {
|
|
345
|
+
return useLaneShown() ? ' jm-lane-on' : ''
|
|
346
|
+
}
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
* on - no auto-fade, no hover magic. The bottom-left navigator (restart · prev · i/N ·
|
|
11
11
|
* next) stays prototype-only.
|
|
12
12
|
*/
|
|
13
|
+
import { setStageSize } from './stage-size.ts'
|
|
14
|
+
import { frameLoaded, frameReady, onFrameMessage, stageNavigated } from './jam-capture.ts'
|
|
15
|
+
import { jamKey } from './jam-keys.ts'
|
|
16
|
+
import { letGoOfTile } from './jam-state.ts'
|
|
17
|
+
import { JamButton } from './jam-session.tsx'
|
|
13
18
|
import { useEffect, useRef, useState } from 'react'
|
|
14
19
|
import { useStore, BOARD_POLICY, BRANDING, CONFIG, PUBLISHED, SOURCE_REVEALED, boardLabel, boardLocked, cap, fetchBoardNames, modeAllowed, playsAsSlides, SLIDE_INTRINSIC, type Node } from './store.ts'
|
|
15
20
|
import { deckOrder } from './play-order.ts'
|
|
@@ -21,6 +26,7 @@ import { poweredByUrl } from '../../shared/utm.ts'
|
|
|
21
26
|
import { canvasCtl } from './canvas/ctl.ts'
|
|
22
27
|
import { revealFrame } from './goto.ts'
|
|
23
28
|
import { Tip } from './Tip.tsx'
|
|
29
|
+
import { keyAllowed } from '../frame-host/keys.js'
|
|
24
30
|
import { CommentButton, DevicePicker, HideUIButton, isHideUI, LaserButton, Popover, ThemePicker, toggleHideUI, usePopover } from './Toolbar.tsx'
|
|
25
31
|
import { DraftComposer, Pins, placePins, ThreadCard } from './Comments.tsx'
|
|
26
32
|
import { ArrowLeftIcon, ArrowRightIcon, BrowsersIcon, CaretIcon, CheckIcon, GridIcon, PanelFilledIcon, PanelHollowIcon, ParallelogramDuoIcon, ReloadIcon, SpecDocIcon } from './icons.tsx'
|
|
@@ -334,7 +340,8 @@ function PlayInner() {
|
|
|
334
340
|
|
|
335
341
|
// laser / comment ride the same rail as canvas frames, broadcast to the stage iframe.
|
|
336
342
|
// Re-sent on stage-ready (below) so a stage reload restores the mode.
|
|
337
|
-
|
|
343
|
+
const laserInspect = useStore((s) => s.laserInspect)
|
|
344
|
+
useEffect(() => { postStage({ type: 'sh:laser', on: laser, inspect: laserInspect }) }, [laser, laserInspect])
|
|
338
345
|
useEffect(() => { postStage({ type: 'sh:pick', on: commentMode, quiet: !useComments.getState().showAnchor }) }, [commentMode, playShowAnchor])
|
|
339
346
|
|
|
340
347
|
const exit = () => {
|
|
@@ -444,7 +451,11 @@ function PlayInner() {
|
|
|
444
451
|
const data = e.data
|
|
445
452
|
if (!data || typeof data.type !== 'string') return
|
|
446
453
|
const s = useStore.getState()
|
|
454
|
+
// Jam (spec 27): the stage records like a frame; a key the shell owns comes back as sh:key
|
|
455
|
+
if (onFrameMessage('stage', data)) return
|
|
456
|
+
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 }); return }
|
|
447
457
|
if (data.type === 'sh:stage-ready') {
|
|
458
|
+
frameReady('stage')
|
|
448
459
|
// an iframe reload (registry HMR invalidation) boots at the frozen initial src -
|
|
449
460
|
// resync it to the shell's current truth: navigation, theme, AND review modes
|
|
450
461
|
const p = s.play
|
|
@@ -452,7 +463,7 @@ function PlayInner() {
|
|
|
452
463
|
if (typeof data.at === 'string' && data.at !== p.at) postStage({ type: 'sh:stage-set', at: p.at })
|
|
453
464
|
postStage({ type: 'sh:set-theme', theme: p.theme })
|
|
454
465
|
}
|
|
455
|
-
postStage({ type: 'sh:laser', on: s.laser })
|
|
466
|
+
postStage({ type: 'sh:laser', on: s.laser, inspect: s.laserInspect })
|
|
456
467
|
postStage({ type: 'sh:pick', on: commentsStore().commentMode, quiet: !commentsStore().showAnchor })
|
|
457
468
|
setStageReady((n) => n + 1) // a reload wiped the frame's lock; let PlayComments re-drive it
|
|
458
469
|
} else if (data.type === 'sh:stage-shown') {
|
|
@@ -462,7 +473,7 @@ function PlayInner() {
|
|
|
462
473
|
useStore.setState({ stageShown: { at: data.at, shown: `${String(data.epoch ?? '')}:${Number(data.doc) || 0}` } })
|
|
463
474
|
} else if (data.type === 'sh:stage-at') {
|
|
464
475
|
const p = s.play
|
|
465
|
-
if (p && typeof data.at === 'string') s.setPlay({ ...p, at: data.at })
|
|
476
|
+
if (p && typeof data.at === 'string') stageNavigated(data.at, () => s.setPlay({ ...p, at: data.at }))
|
|
466
477
|
} else if (data.type === 'sh:stage-exit') {
|
|
467
478
|
exit()
|
|
468
479
|
} else if (data.type === 'sh:stage-error') {
|
|
@@ -476,7 +487,7 @@ function PlayInner() {
|
|
|
476
487
|
}
|
|
477
488
|
} else if (data.type === 'sh:stage-key') {
|
|
478
489
|
if (data.meta && data.key === '/') toggleCollapse()
|
|
479
|
-
else handleKey(String(data.key), String(data.code))
|
|
490
|
+
else handleKey(String(data.key), String(data.code), !!data.alt)
|
|
480
491
|
} else if (data.type === 'sh:picked') {
|
|
481
492
|
// comment pick from the stage: stage the draft on the walked frame (its canvas
|
|
482
493
|
// node when one is on this board, so the thread also lands on the canvas). Stamp
|
|
@@ -492,6 +503,7 @@ function PlayInner() {
|
|
|
492
503
|
} else if (data.type === 'sh:frame-down') {
|
|
493
504
|
const c = commentsStore()
|
|
494
505
|
if (c.active) c.setActive(null)
|
|
506
|
+
letGoOfTile() // a click in the prototype closes the review open over it, as on the canvas
|
|
495
507
|
} else if (data.type === 'sh:laser-copy') {
|
|
496
508
|
// laser click in the prototype: copy the element's address ([board ▸ scene] +
|
|
497
509
|
// frame file + css path) and confirm in the frame's own hover label, like the canvas
|
|
@@ -511,7 +523,7 @@ function PlayInner() {
|
|
|
511
523
|
}, [])
|
|
512
524
|
|
|
513
525
|
// shared handler: keys arrive directly (focus in shell) or forwarded by the stage
|
|
514
|
-
const handleKey = (key: string, code: string) => {
|
|
526
|
+
const handleKey = (key: string, code: string, alt = false) => {
|
|
515
527
|
if (key === 'Escape') {
|
|
516
528
|
// a live review mode swallows Escape first (cancel), so it never ejects you from
|
|
517
529
|
// the prototype mid-comment; a second Escape (nothing live) exits
|
|
@@ -528,7 +540,8 @@ function PlayInner() {
|
|
|
528
540
|
if (key === ']') { switchVariant(1); return }
|
|
529
541
|
if (key === 'r') { restart(); return }
|
|
530
542
|
if (key === 'h') { toggleHideUI(); return }
|
|
531
|
-
|
|
543
|
+
// L: the pointer laser; ⌥L: inspect
|
|
544
|
+
if (key === 'l' && SOURCE_REVEALED) { commentsStore().setMode(false); useStore.getState().toggleLaser(alt); return }
|
|
532
545
|
if (key === 'c') { const c = commentsStore(); if (!c.commentMode && useStore.getState().board === UNPLACED) return useStore.getState().toast(NO_COMMENTS_HERE); if (!c.commentMode) useStore.getState().setLaser(false); c.setMode(!c.commentMode); return }
|
|
533
546
|
if (key === 'C') { const c = commentsStore(); c.setShow(!c.show); return } // ⇧C hides/shows pins
|
|
534
547
|
if (key === 'L') { const c = commentsStore(); c.setShowAnchor(!c.showAnchor); return } // ⇧L element focus
|
|
@@ -548,10 +561,14 @@ function PlayInner() {
|
|
|
548
561
|
const toggleCollapse = () => setPillOpen((o) => !o)
|
|
549
562
|
useEffect(() => {
|
|
550
563
|
const onKey = (e: KeyboardEvent) => {
|
|
551
|
-
if (e
|
|
564
|
+
if (!keyAllowed(e)) return // the one key guard (frame-host/keys.js): never from a field, an editable, an IME composition
|
|
565
|
+
// Jam's keys first - a review open takes the arrows before they step screens
|
|
566
|
+
// with Option a Mac types a symbol (⌥L is "¬"): an Alt shortcut is named by the key pressed
|
|
567
|
+
const key = e.altKey && /^Key[A-Z]$/.test(e.code) ? e.code.slice(3).toLowerCase() : e.key
|
|
568
|
+
if (!e.repeat && jamKey({ key, shift: e.shiftKey, alt: e.altKey, meta: e.metaKey, ctrl: e.ctrlKey })) { e.preventDefault(); return }
|
|
552
569
|
if ((e.metaKey || e.ctrlKey) && e.key === '/') { e.preventDefault(); toggleCollapse(); return }
|
|
553
570
|
if (e.metaKey || e.ctrlKey) return
|
|
554
|
-
handleKey(e.
|
|
571
|
+
handleKey(key, e.code, e.altKey)
|
|
555
572
|
}
|
|
556
573
|
window.addEventListener('keydown', onKey)
|
|
557
574
|
return () => window.removeEventListener('keydown', onKey)
|
|
@@ -578,6 +595,10 @@ function PlayInner() {
|
|
|
578
595
|
: docPreset ? { width: Math.min(win.w, 860), height: win.h }
|
|
579
596
|
: fill ? { width: win.w, height: win.h }
|
|
580
597
|
: CONFIG.viewports[play.device] ?? Object.values(CONFIG.viewports)[0]
|
|
598
|
+
// (a capture reads what the stage is: the size a frame seen here is pictured at - published after this layout)
|
|
599
|
+
// (no hook here - this is past the early return: a microtask, right after this layout)
|
|
600
|
+
const stageAt = play.at, stageW = Math.round(vp.width), stageH = Math.round(vp.height)
|
|
601
|
+
queueMicrotask(() => setStageSize(stageAt, stageW, stageH))
|
|
581
602
|
const scale = stage ? Math.max(0.05, fill ? Math.min(win.w / vp.width, win.h / vp.height)
|
|
582
603
|
: slides ? Math.min((win.w - 48) / vp.width, (win.h - (deckChrome === 'none' ? 48 : 88)) / vp.height)
|
|
583
604
|
: Math.min((win.w - 96) / vp.width, (win.h - 128) / vp.height))
|
|
@@ -611,6 +632,7 @@ function PlayInner() {
|
|
|
611
632
|
<iframe
|
|
612
633
|
ref={iframeRef}
|
|
613
634
|
src={src.current}
|
|
635
|
+
onLoad={() => frameLoaded('stage', iframeRef.current)}
|
|
614
636
|
title="play"
|
|
615
637
|
style={{ width: vp.width, height: vp.height, transform: `scale(${dw / vp.width}, ${dh / vp.height})` }}
|
|
616
638
|
/>
|
|
@@ -668,6 +690,7 @@ function PlayInner() {
|
|
|
668
690
|
<CommentButton />
|
|
669
691
|
{!trimmed && <>
|
|
670
692
|
<LaserButton />
|
|
693
|
+
{!PUBLISHED && CONFIG.jam && <JamButton inPlay />}
|
|
671
694
|
<i className="sep" />
|
|
672
695
|
{!docPreset && <DevicePicker value={fill ? 'fill' : play.device} onSelect={(n) => n && setDevice(n)} includeFill includeSlide={slides} stageOnly={slides} hint={deviceHint} dark />}
|
|
673
696
|
<ThemePicker value={play.theme} onSelect={setTheme} hint="D" dark />
|
|
@@ -691,7 +714,7 @@ function PlayInner() {
|
|
|
691
714
|
deep link (the link's chrome) - not hidden, not rendered */}
|
|
692
715
|
{!noDoor && (
|
|
693
716
|
<Tip side="bottom" label={<><b>Open in canvas</b><span>Esc</span></>}>
|
|
694
|
-
<button className="sh-pill-btn" onClick={exit}><GridIcon size={16} /></button>
|
|
717
|
+
<button className="sh-pill-btn" data-play-exit="" onClick={exit}><GridIcon size={16} /></button>
|
|
695
718
|
</Tip>
|
|
696
719
|
)}
|
|
697
720
|
{BRANDING && PUBLISHED && !trimmed && (
|
package/src/client/shell/Tip.tsx
CHANGED
|
@@ -4,11 +4,13 @@ import { createPortal } from 'react-dom'
|
|
|
4
4
|
/** shadcn-style tooltip: snappy (150ms in, instant out), contrast-flipped, zoom-fade.
|
|
5
5
|
* Portaled to the app root - glass never nests, and neither do overlays. `inv` pins the
|
|
6
6
|
* flipped (light) bubble for surfaces with fixed dark chrome (play mode), where the
|
|
7
|
-
* theme-following default would sit dark-on-dark. */
|
|
8
|
-
export function Tip({ label, side = 'top', inv = false, children }: { label: ReactNode; side?: 'top' | 'bottom' | 'right'; inv?: boolean; children: ReactElement }) {
|
|
7
|
+
* theme-following default would sit dark-on-dark. `only(trigger)` decides at hover whether it shows. */
|
|
8
|
+
export function Tip({ label, side = 'top', inv = false, only, children }: { label: ReactNode; side?: 'top' | 'bottom' | 'right'; inv?: boolean; only?: (el: HTMLElement) => boolean; children: ReactElement }) {
|
|
9
9
|
const [pos, setPos] = useState<{ x: number; y: number } | null>(null)
|
|
10
10
|
const timer = useRef<number | undefined>(undefined)
|
|
11
|
-
const show = (e: React.
|
|
11
|
+
const show = (e: React.SyntheticEvent) => {
|
|
12
|
+
// `only`: shown when the trigger needs it (a title cut short shows whole; one that fits shows nothing)
|
|
13
|
+
if (only && !only(e.currentTarget as HTMLElement)) return
|
|
12
14
|
const r = (e.currentTarget as HTMLElement).getBoundingClientRect()
|
|
13
15
|
// right: beside the trigger, centred on it - a sidebar row's glyph, read toward the canvas
|
|
14
16
|
const at = side === 'right' ? { x: r.right + 9, y: r.top + r.height / 2 } : { x: r.left + r.width / 2, y: side === 'top' ? r.top - 7 : r.bottom + 7 }
|
|
@@ -52,6 +54,9 @@ export function Tip({ label, side = 'top', inv = false, children }: { label: Rea
|
|
|
52
54
|
{cloneElement(child, {
|
|
53
55
|
onMouseEnter: (e: React.MouseEvent) => { child.props.onMouseEnter?.(e); show(e) },
|
|
54
56
|
onMouseLeave: (e: React.MouseEvent) => { child.props.onMouseLeave?.(e); hide() },
|
|
57
|
+
// the keyboard's way in: a trigger reached by Tab shows its tip too (a mouse click never does)
|
|
58
|
+
onFocus: (e: React.FocusEvent) => { child.props.onFocus?.(e); if ((e.currentTarget as HTMLElement).matches(':focus-visible')) show(e) },
|
|
59
|
+
onBlur: (e: React.FocusEvent) => { child.props.onBlur?.(e); hide() },
|
|
55
60
|
onClick: (e: React.MouseEvent) => { child.props.onClick?.(e); hide() },
|
|
56
61
|
})}
|
|
57
62
|
{pos && app && createPortal(
|
|
@@ -89,15 +89,16 @@ function TipRows({ rows }: { rows: [string, string][] }) {
|
|
|
89
89
|
* since the two are one-at-a-time). */
|
|
90
90
|
export function LaserButton() {
|
|
91
91
|
const laser = useStore((s) => s.laser)
|
|
92
|
+
const laserInspect = useStore((s) => s.laserInspect)
|
|
92
93
|
const showAnchor = useComments((s) => s.showAnchor)
|
|
93
94
|
// stripped build: the paths are not in the bundle, so the button that would
|
|
94
95
|
// copy them has nothing honest to offer
|
|
95
96
|
if (!SOURCE_REVEALED) return null
|
|
96
97
|
return (
|
|
97
|
-
<Tip side="bottom" label={<TipRows rows={[['Laser
|
|
98
|
-
<button className={`sh-pill-btn${laser ? ' on' : ''}`} onClick={() => {
|
|
99
|
-
|
|
100
|
-
useStore.getState().
|
|
98
|
+
<Tip side="bottom" label={<TipRows rows={[['Laser', 'L'], ['Inspect', '⌥L'], [showAnchor ? 'Hide laser comment' : 'Show laser comment', '⇧L']]} />}>
|
|
99
|
+
<button className={`sh-pill-btn${laser ? ' on' : ''}`} data-laser={laser ? (laserInspect ? 'inspect' : 'pointer') : 'off'} onClick={(e) => {
|
|
100
|
+
commentsStore().setMode(false)
|
|
101
|
+
useStore.getState().toggleLaser(e.altKey)
|
|
101
102
|
}}><LaserIcon size={16} /></button>
|
|
102
103
|
</Tip>
|
|
103
104
|
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useRef } from 'react'
|
|
2
2
|
import { TransformWrapper, TransformComponent, type ReactZoomPanPinchContentRef } from 'react-zoom-pan-pinch'
|
|
3
3
|
import { CONFIG, useStore } from '../store.ts'
|
|
4
|
+
import { letGoOfTile } from '../jam-state.ts'
|
|
4
5
|
import { bootHash, linkTargets } from '../hash.ts'
|
|
5
6
|
import { revealFrame } from '../goto.ts'
|
|
6
7
|
import { startPerf } from '../perf.ts'
|
|
@@ -35,11 +36,16 @@ function insets(el: HTMLElement) {
|
|
|
35
36
|
const rect = (q: string) => document.querySelector(q)?.getBoundingClientRect()
|
|
36
37
|
const side = rect('.sh-panel:not(.closed)') ?? rect('.sh-fab')
|
|
37
38
|
const pill = rect('.sh-pill')
|
|
39
|
+
// Jam (spec 27): the focus panel sits right of the sidebar and the lane along the bottom - a card's
|
|
40
|
+
// frames fit in the space left of neither
|
|
41
|
+
const focus = rect('.jm-focus')
|
|
42
|
+
const lane = rect('.jm-lane')
|
|
43
|
+
const leftEdge = Math.max(side ? side.right : 0, focus ? focus.right : 0)
|
|
38
44
|
return {
|
|
39
|
-
left: (
|
|
45
|
+
left: (leftEdge ? Math.max(0, leftEdge - c.left) : 0) + GAP,
|
|
40
46
|
right: GAP + 16,
|
|
41
47
|
top: (pill ? Math.max(0, pill.bottom - c.top) : 0) + 12 + BAR,
|
|
42
|
-
bottom: GAP + 16,
|
|
48
|
+
bottom: (lane ? Math.max(0, c.bottom - lane.top) : 0) + GAP + 16,
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
51
|
|
|
@@ -259,6 +265,10 @@ export function Canvas() {
|
|
|
259
265
|
if (!el) return
|
|
260
266
|
const down = (e: PointerEvent) => {
|
|
261
267
|
const t = e.target as HTMLElement | null
|
|
268
|
+
// anywhere on the canvas, a frame too: the panel closes and its tile lets go - except on a comment's
|
|
269
|
+
// own controls (its pin, its card, its reply): opening one closes the panel there and keeps the
|
|
270
|
+
// tile when the thread is its own (JamSurface)
|
|
271
|
+
if (!t?.closest('.cm-layer, .cm-card, .cm-pin, .cm-stack')) letGoOfTile()
|
|
262
272
|
if (t?.closest('.sh-node') || t?.closest('.sh-gcaption')) return
|
|
263
273
|
const s = useStore.getState()
|
|
264
274
|
if (s.selection.length || s.interact) s.select(null)
|