@marver-design/marver 0.28.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 +103 -0
- package/README.md +4 -3
- package/dist/{anchor-check-PHUOFj1N.mjs → anchor-check-c52IDkiQ.mjs} +1 -1
- package/dist/{build-BsAyLMT1.mjs → build-C3mUtjEn.mjs} +7 -4
- package/dist/{capture-DdZ6xgoz.mjs → capture-DEtM4qm5.mjs} +168 -5
- package/dist/cli.mjs +11 -11
- package/dist/{comments-CrBHPEQl.mjs → comments-XNhMmSSu.mjs} +2 -2
- package/dist/{connectors-MR9d-EBP.mjs → connectors-DekQvKt9.mjs} +3 -1
- package/dist/{daemon-C5dg2R-V.mjs → daemon-B0Wi1OQ3.mjs} +30 -29
- package/dist/{dev-D7YS7iT2.mjs → dev-5dlxoW28.mjs} +19 -14
- package/dist/{init-WE5lQkQL.mjs → init-CYlFaRzG.mjs} +1 -1
- package/dist/logo-CXY-1yrn.mjs +305 -0
- package/dist/{ls-BZ5TAtd5.mjs → ls-NqmePKOf.mjs} +1 -1
- package/dist/{marks-Kmdab_5w.mjs → marks-BnNANic9.mjs} +20 -1
- package/dist/{marks-Dyn6tmjp.mjs → marks-DBp3h1Mc.mjs} +2 -5
- package/dist/{marver-id-gate-D-R0hSt_.mjs → marver-id-gate-vBLb_Icb.mjs} +1 -1
- package/dist/{perf-Cn5LiRaY.mjs → perf-6MOTHxay.mjs} +751 -122
- package/dist/perf-BCxAo0IS.mjs +1743 -0
- package/dist/{plugin-C_0yb-Fq.mjs → plugin-CXRoMA8g.mjs} +1382 -810
- package/dist/{poster-DHi6I1fO.mjs → poster-CYmCa00B.mjs} +1 -1
- package/dist/{profile-jIS6BcAs.mjs → profile-B1FKOM1e.mjs} +1 -1
- package/dist/{publish-bakes-r4PEZuPl.mjs → publish-bakes-C_2ZtHou.mjs} +3 -3
- package/dist/{queue-c-6aTHEz.mjs → queue-DeSQm24g.mjs} +29 -14
- package/dist/{recover-nrLEVLyJ.mjs → recover-XD8iXJOj.mjs} +2 -2
- package/dist/{serve-Dp3nHstu.mjs → serve-DQv3Ti6X.mjs} +8 -4
- package/dist/{session-DyVE7cCk.mjs → session-VDJfXEEm.mjs} +1 -1
- package/dist/{share-Ce4tP7ji.mjs → share-Bu_kuOKL.mjs} +1 -1
- package/dist/{shot-BrRtqaiS.mjs → shot-CRRGgxru.mjs} +3 -3
- package/dist/{slots-CFNnegCc.mjs → slots-Dn4Onb0V.mjs} +101 -3
- package/dist/{sync-CQdGARJ9.mjs → sync-CMozOwZ0.mjs} +1 -1
- package/docs/app.md +194 -0
- package/docs/boards-and-folders.md +11 -0
- package/docs/jam-session.md +12 -3
- package/docs/live-jam.md +3 -0
- package/docs/performance.md +99 -19
- package/docs/publish.md +7 -0
- 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 +71 -46
- package/src/client/shell/ContextMenu.tsx +8 -6
- package/src/client/shell/JamSurface.tsx +187 -71
- package/src/client/shell/LockedApp.tsx +19 -3
- package/src/client/shell/Play.tsx +110 -62
- package/src/client/shell/StatusPicker.tsx +19 -9
- package/src/client/shell/Toolbar.tsx +15 -7
- package/src/client/shell/api.ts +25 -7
- package/src/client/shell/app-bridge.ts +23 -9
- 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 +56 -27
- package/src/client/shell/goto.ts +15 -9
- package/src/client/shell/jam-capture.ts +39 -15
- package/src/client/shell/jam-keys.ts +303 -111
- package/src/client/shell/jam-lane.tsx +19 -12
- package/src/client/shell/jam-lines.ts +10 -1
- package/src/client/shell/jam-panel.tsx +68 -53
- package/src/client/shell/jam-queue.ts +6 -1
- package/src/client/shell/jam-session.tsx +41 -37
- package/src/client/shell/jam-state.ts +28 -5
- package/src/client/shell/jam-surface-parts.tsx +8 -6
- package/src/client/shell/jam-ui.tsx +12 -5
- package/src/client/shell/jam-voice.ts +4 -2
- package/src/client/shell/live-picture.ts +134 -0
- package/src/client/shell/main.tsx +7 -1
- package/src/client/shell/marks-ui.tsx +11 -0
- package/src/client/shell/open-item.ts +83 -0
- package/src/client/shell/open-resolve.ts +50 -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 +62 -24
- package/src/client/shell/styles.css +2 -0
- package/src/client/shell/whiteout-probes.ts +3 -1
- package/src/client/stage/main.tsx +39 -12
- package/src/shared/app-api.ts +201 -9
- package/src/shared/app-perf.ts +103 -8
- 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/templates/instructions/jam.md +4 -0
- package/dist/live-Cgzsicwi.mjs +0 -4
- package/dist/perf-jam-QxD_UnzN.mjs +0 -635
|
@@ -27,6 +27,8 @@ import { stranded, withWs } from './api.ts'
|
|
|
27
27
|
import { poweredByUrl } from '../../shared/utm.ts'
|
|
28
28
|
import { canvasCtl } from './canvas/ctl.ts'
|
|
29
29
|
import { recorder } from './recorder.ts'
|
|
30
|
+
import { perfSeams } from './recorder-seams.ts'
|
|
31
|
+
import { cmd, endAfterFrames, endOnStage, keysOf, type CmdHandle, type CmdOpts, type CmdName } from './commands.ts'
|
|
30
32
|
import { revealFrame, switchFor } from './goto.ts'
|
|
31
33
|
import { Tip } from './Tip.tsx'
|
|
32
34
|
import { keyAllowed } from '../frame-host/keys.js'
|
|
@@ -146,13 +148,13 @@ export function enterFocus(at?: string, over?: { device?: string; theme?: string
|
|
|
146
148
|
|
|
147
149
|
/** Switch boards WITHOUT leaving play: the overlay stays up over the canvas churn, then
|
|
148
150
|
* a fresh stage mounts at the new board's start (PlayInner is keyed by board). */
|
|
149
|
-
async function switchPlayBoard(name: string) {
|
|
151
|
+
async function switchPlayBoard(name: string, h: CmdHandle) {
|
|
150
152
|
const s = useStore.getState()
|
|
151
|
-
if (name === s.board) return
|
|
153
|
+
if (name === s.board) { h.cancel('same-board'); return }
|
|
152
154
|
const device = s.play?.device // the device is the viewer's choice - it survives the switch
|
|
153
155
|
// a navigation like any other: a link still reading its board gives way to it, and it to a newer one - which then
|
|
154
156
|
// has the board, the stage and the camera
|
|
155
|
-
if (!await switchFor(name)) return
|
|
157
|
+
if (!await switchFor(name)) { h.cancel('superseded'); return }
|
|
156
158
|
const dev = device && device !== 'slide' ? { device } : undefined // the deck's own size does not follow to a prototype
|
|
157
159
|
if (playsAsSlides(name)) enterSlides(device ? { device } : undefined)
|
|
158
160
|
else enterPlay(dev)
|
|
@@ -164,6 +166,11 @@ export const playCtl = {
|
|
|
164
166
|
setAt: (_at: string) => {},
|
|
165
167
|
/** Apply a parsed play hash to the OPEN session - at, device, and theme alike. */
|
|
166
168
|
sync: (_p: { at?: string; device?: string; theme?: string }) => {},
|
|
169
|
+
/** Leave play as its own Esc does: then back on the canvas at the frame you ended on */
|
|
170
|
+
exit: () => {},
|
|
171
|
+
/** Leave play and nothing more - no way back to its frame (no fit, no board switch): a notice's click opening something
|
|
172
|
+
* on the canvas owns what moves next (spec 28 A4.6 r4 #1; code review r2 P1). False on a board with no way out. */
|
|
173
|
+
leave: (): boolean => false,
|
|
167
174
|
}
|
|
168
175
|
|
|
169
176
|
export function PlayOverlay() {
|
|
@@ -194,7 +201,7 @@ function BoardMenu({ current }: { current: string }) {
|
|
|
194
201
|
</Tip>
|
|
195
202
|
<Popover pop={pop} dark>
|
|
196
203
|
{names.map((n) => (
|
|
197
|
-
<button key={n} onClick={() => { pop.setOpen(false); switchPlayBoard(n) }}>
|
|
204
|
+
<button key={n} onClick={() => { pop.setOpen(false); switchPlayBoard(n, cmd('play-board', { via: 'click', in: 'pill', board: n })) }}>
|
|
198
205
|
<span>{boardLabel(n)}</span>
|
|
199
206
|
{n === current && <CheckIcon size={13} className="chk" />}
|
|
200
207
|
</button>
|
|
@@ -343,22 +350,29 @@ function PlayInner() {
|
|
|
343
350
|
if (!p) return
|
|
344
351
|
iframeRef.current.src = withWs(`${ROUTE}/stage/?at=${encodeURIComponent(p.at)}&theme=${encodeURIComponent(p.theme)}${slParams(p)}&r=${playNav}`)
|
|
345
352
|
}, [playNav])
|
|
346
|
-
const applyUpdate = () => useStore.getState().applyPlayUpdate()
|
|
353
|
+
const applyUpdate = () => { cmd('play-update', { via: 'click', in: 'pill' }); useStore.getState().applyPlayUpdate() }
|
|
347
354
|
|
|
348
355
|
// laser / comment ride the same rail as canvas frames, broadcast to the stage iframe.
|
|
349
356
|
// Re-sent on stage-ready (below) so a stage reload restores the mode.
|
|
350
357
|
const laserInspect = useStore((s) => s.laserInspect)
|
|
351
|
-
useEffect(() => { postStage({ type: 'sh:laser', on: laser, inspect: laserInspect }) }, [laser, laserInspect])
|
|
352
|
-
useEffect(() => { postStage({ type: 'sh:pick', on: commentMode, quiet: !useComments.getState().showAnchor }) }, [commentMode, playShowAnchor])
|
|
358
|
+
useEffect(() => { postStage({ type: 'sh:laser', on: laser, inspect: laserInspect, t: perfSeams.transition('mode') }) }, [laser, laserInspect])
|
|
359
|
+
useEffect(() => { postStage({ type: 'sh:pick', on: commentMode, quiet: !useComments.getState().showAnchor, t: perfSeams.transition('mode') }) }, [commentMode, playShowAnchor])
|
|
353
360
|
|
|
354
|
-
|
|
361
|
+
/** Play torn down, nothing more: false where there is no way out */
|
|
362
|
+
const leave = (): boolean => {
|
|
355
363
|
// the lock caps disclosure: a locked board has no way out into other modes,
|
|
356
364
|
// and a deep-link visit carries no door on the surface (URL still works)
|
|
357
|
-
if (noDoor) return
|
|
365
|
+
if (noDoor) return false
|
|
358
366
|
frozenDeck = null
|
|
359
|
-
const { at } = useStore.getState().play ?? {}
|
|
360
367
|
if (isHideUI()) toggleHideUI() // never strand the canvas with its chrome hidden
|
|
361
368
|
useStore.getState().setPlay(null)
|
|
369
|
+
return true
|
|
370
|
+
}
|
|
371
|
+
/** Open in canvas, or an Esc with nothing live (spec 30 `play-exit`): a board with no way out stays. */
|
|
372
|
+
const exitFrom = (how: CmdOpts) => { const h = cmd('play-exit', how); if (noDoor) h.noop('no-door'); exit() }
|
|
373
|
+
const exit = () => {
|
|
374
|
+
const { at } = useStore.getState().play ?? {}
|
|
375
|
+
if (!leave()) return
|
|
362
376
|
// land back on the canvas at the frame you ended on
|
|
363
377
|
const n = useStore.getState().nodes.find((x) => x.frame === at && !x.missing)
|
|
364
378
|
if (n) { useStore.getState().select(n.key); setTimeout(() => canvasCtl.fitNode(n.key), 30) }
|
|
@@ -373,17 +387,19 @@ function PlayInner() {
|
|
|
373
387
|
if (p.slides) { useStore.getState().setPlay({ ...p, device: name === 'fill' ? 'fill' : 'slide' }); return }
|
|
374
388
|
if (CONFIG.viewports[name] || name === 'fill') useStore.getState().setPlay({ ...p, device: name })
|
|
375
389
|
}
|
|
376
|
-
const setTheme = (t: string) => {
|
|
390
|
+
const setTheme = (t: string, how?: CmdOpts) => {
|
|
377
391
|
const p = useStore.getState().play
|
|
378
392
|
if (!p) return
|
|
393
|
+
if (how) cmd('theme', how)
|
|
379
394
|
useStore.getState().setPlay({ ...p, theme: t })
|
|
380
|
-
postStage({ type: 'sh:set-theme', theme: t })
|
|
395
|
+
postStage({ type: 'sh:set-theme', theme: t, t: perfSeams.transition('theme') })
|
|
381
396
|
}
|
|
382
397
|
/** Walk to a frame: the stage swaps silently; state + URL follow via the projection. */
|
|
383
398
|
const goTo = (at: string) => playCtl.setAt(at)
|
|
384
|
-
const step = (dir: 1 | -1) => {
|
|
399
|
+
const step = (dir: 1 | -1, how: CmdOpts) => {
|
|
400
|
+
const h = cmd(dir === 1 ? 'play-next' : 'play-prev', how)
|
|
385
401
|
const p = useStore.getState().play
|
|
386
|
-
if (!p || p.focus) return
|
|
402
|
+
if (!p || p.focus) { h.noop('end'); return } // focus is one frame - no walking
|
|
387
403
|
if (p.slides) {
|
|
388
404
|
// a deck never wraps: past the last slide is the end, before the first is
|
|
389
405
|
// the start. A variant swap can put `at` off the frozen deck - step from
|
|
@@ -396,20 +412,27 @@ function PlayInner() {
|
|
|
396
412
|
if (g) i = deck.findIndex((id) => frames.find((f) => f.id === id)?.variantGroup === g)
|
|
397
413
|
}
|
|
398
414
|
const next = i === -1 ? deck[0] : deck[Math.min(deck.length - 1, Math.max(0, i + dir))]
|
|
399
|
-
if (next && next !== p.at) goTo(next)
|
|
415
|
+
if (next && next !== p.at) { endOnStage(h, next); goTo(next) } else h.noop('end')
|
|
400
416
|
return
|
|
401
417
|
}
|
|
402
418
|
const list = playList()
|
|
403
|
-
if (!list.length) return
|
|
419
|
+
if (!list.length) { h.noop('end'); return }
|
|
404
420
|
const i = list.indexOf(p.at)
|
|
405
421
|
// an off-board frame has no position: → restarts, ← goes to the last board frame
|
|
406
|
-
|
|
422
|
+
const to = i === -1 ? (dir === 1 ? list[0] : list[list.length - 1]) : list[(i + dir + list.length) % list.length]
|
|
423
|
+
if (to === p.at) { h.noop('end'); return } // a board of one frame
|
|
424
|
+
endOnStage(h, to)
|
|
425
|
+
goTo(to)
|
|
407
426
|
}
|
|
408
|
-
const restart = () => {
|
|
427
|
+
const restart = (how: CmdOpts) => {
|
|
428
|
+
const h = cmd('play-restart', how)
|
|
409
429
|
const p = useStore.getState().play
|
|
410
|
-
if (p?.focus) return
|
|
430
|
+
if (p?.focus) { h.noop('no-frames'); return }
|
|
411
431
|
const list = p?.slides ? currentDeck() : playList()
|
|
412
|
-
if (list.length)
|
|
432
|
+
if (!list.length) { h.noop('no-frames'); return }
|
|
433
|
+
// already on the first: nothing to swap, nothing for the stage to say
|
|
434
|
+
if (list[0] === p?.at) endAfterFrames(h); else endOnStage(h, list[0])
|
|
435
|
+
goTo(list[0])
|
|
413
436
|
}
|
|
414
437
|
|
|
415
438
|
/** Variant siblings of the CURRENT frame present on this board: the
|
|
@@ -425,13 +448,16 @@ function PlayInner() {
|
|
|
425
448
|
.filter((f) => f.variantGroup === cur.variantGroup && f.kind === 'tsx' && onBoard.has(f.id))
|
|
426
449
|
.sort((a, b) => (a.variant ?? '').localeCompare(b.variant ?? ''))
|
|
427
450
|
}
|
|
428
|
-
const switchVariant = (dir: 1 | -1) => {
|
|
451
|
+
const switchVariant = (dir: 1 | -1, how: CmdOpts) => {
|
|
452
|
+
const h = cmd('play-variant', how)
|
|
429
453
|
const p = useStore.getState().play
|
|
430
|
-
if (!p) return
|
|
454
|
+
if (!p) { h.noop('no-variants'); return }
|
|
431
455
|
const vs = variantList()
|
|
432
|
-
if (vs.length < 2) return
|
|
456
|
+
if (vs.length < 2) { h.noop('no-variants'); return }
|
|
433
457
|
const i = vs.findIndex((f) => f.id === p.at)
|
|
434
|
-
|
|
458
|
+
const to = vs[(i + dir + vs.length) % vs.length].id
|
|
459
|
+
endOnStage(h, to)
|
|
460
|
+
goTo(to)
|
|
435
461
|
}
|
|
436
462
|
|
|
437
463
|
// history restores + walk: swap the stage silently (no sh:stage-at back) and track here
|
|
@@ -448,7 +474,9 @@ function PlayInner() {
|
|
|
448
474
|
if (p.theme && p.theme !== cur.theme) setTheme(p.theme)
|
|
449
475
|
if (p.at && p.at !== cur.at) playCtl.setAt(p.at)
|
|
450
476
|
}
|
|
451
|
-
|
|
477
|
+
playCtl.exit = exit
|
|
478
|
+
playCtl.leave = leave
|
|
479
|
+
return () => { playCtl.setAt = () => {}; playCtl.sync = () => {}; playCtl.exit = () => {}; playCtl.leave = () => false }
|
|
452
480
|
}, [])
|
|
453
481
|
|
|
454
482
|
// messages from the stage; source-validated against our one iframe
|
|
@@ -458,9 +486,11 @@ function PlayInner() {
|
|
|
458
486
|
const data = e.data
|
|
459
487
|
if (!data || typeof data.type !== 'string') return
|
|
460
488
|
const s = useStore.getState()
|
|
489
|
+
// the recorder's (spec 30): every stage message, before the shell acts on it - never consumed here
|
|
490
|
+
perfSeams.stageMessage.emit(data)
|
|
461
491
|
// Jam (spec 27): the stage records like a frame; a key the shell owns comes back as sh:key
|
|
462
492
|
if (onFrameMessage('stage', data)) return
|
|
463
|
-
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 }
|
|
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 }
|
|
464
494
|
if (data.type === 'sh:stage-ready') {
|
|
465
495
|
frameReady('stage')
|
|
466
496
|
// an iframe reload (registry HMR invalidation) boots at the frozen initial src -
|
|
@@ -480,7 +510,8 @@ function PlayInner() {
|
|
|
480
510
|
useStore.setState({ stageShown: { at: data.at, shown: `${String(data.epoch ?? '')}:${Number(data.doc) || 0}` } })
|
|
481
511
|
} else if (data.type === 'sh:stage-at') {
|
|
482
512
|
const p = s.play
|
|
483
|
-
|
|
513
|
+
// a data-goto in the stage, handled there in place (stage/main.tsx:277)
|
|
514
|
+
if (p && typeof data.at === 'string') { endOnStage(cmd('goto', { via: 'click', in: 'stage', frame: data.at }), data.at); stageNavigated(data.at, () => s.setPlay({ ...p, at: data.at })) }
|
|
484
515
|
} else if (data.type === 'sh:stage-exit') {
|
|
485
516
|
exit()
|
|
486
517
|
} else if (data.type === 'sh:stage-error') {
|
|
@@ -494,8 +525,9 @@ function PlayInner() {
|
|
|
494
525
|
if (s.playNav && !s.stageShown) useStore.setState({ playUpdateRevision: 'retry' }) // an Update that failed: offer it again
|
|
495
526
|
}
|
|
496
527
|
} else if (data.type === 'sh:stage-key') {
|
|
497
|
-
if (data.meta && data.key === '/') toggleCollapse()
|
|
498
|
-
|
|
528
|
+
if (data.meta && data.key === '/') { cmd('toolbar', { via: 'key', in: 'stage', keys: 'Meta+/' }); toggleCollapse() }
|
|
529
|
+
// the stage's background click, posted as Space, says so (#50)
|
|
530
|
+
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 }) })
|
|
499
531
|
} else if (data.type === 'sh:picked') {
|
|
500
532
|
// comment pick from the stage: stage the draft on the walked frame (its canvas
|
|
501
533
|
// node when one is on this board, so the thread also lands on the canvas). Stamp
|
|
@@ -507,11 +539,12 @@ function PlayInner() {
|
|
|
507
539
|
const at = String(data.id ?? '')
|
|
508
540
|
if (!at || at !== s.play?.at) return
|
|
509
541
|
const n = s.nodes.find((x) => x.frame === at && !x.missing)
|
|
542
|
+
cmd('comment-pick', { via: 'click', in: 'stage', frame: at })
|
|
510
543
|
c.setDraft({ nodeKey: n?.key ?? '', frame: at, anchor: data.anchor })
|
|
511
544
|
} else if (data.type === 'sh:frame-down') {
|
|
512
545
|
const c = commentsStore()
|
|
513
|
-
if (c.active) c.setActive(null)
|
|
514
|
-
letGoOfTile() // a click in the prototype closes the review open over it, as on the canvas
|
|
546
|
+
if (c.active) { cmd('thread-close', { via: 'click', in: 'stage' }); c.setActive(null) }
|
|
547
|
+
letGoOfTile({ via: 'click', in: 'stage' }) // a click in the prototype closes the review open over it, as on the canvas
|
|
515
548
|
} else if (data.type === 'sh:laser-copy') {
|
|
516
549
|
// laser click in the prototype: copy the element's address ([board ▸ scene] +
|
|
517
550
|
// frame file + css path) and confirm in the frame's own hover label, like the canvas
|
|
@@ -520,9 +553,10 @@ function PlayInner() {
|
|
|
520
553
|
// drop a stale post that outran a stage swap (the sender echoes its frame id)
|
|
521
554
|
if (f && String(data.id ?? '') === at) {
|
|
522
555
|
const addr = `[${s.board} ▸ ${f.scene || '(root)'}] ${f.file} · ${String(data.path ?? '')}${data.source ? ` (${String(data.source)})` : ''}`
|
|
556
|
+
const h = cmd('laser-copy', { via: 'click', in: 'stage', frame: at })
|
|
523
557
|
navigator.clipboard.writeText(addr).then(
|
|
524
|
-
() => postStage({ type: 'sh:copy-ok', seq: data.seq }),
|
|
525
|
-
() => s.toast('copy blocked - click the canvas first'))
|
|
558
|
+
() => { h.done(); postStage({ type: 'sh:copy-ok', seq: data.seq }) },
|
|
559
|
+
() => { h.fail('clipboard-blocked'); s.toast('copy blocked - click the canvas first') })
|
|
526
560
|
}
|
|
527
561
|
}
|
|
528
562
|
}
|
|
@@ -531,38 +565,52 @@ function PlayInner() {
|
|
|
531
565
|
}, [])
|
|
532
566
|
|
|
533
567
|
// shared handler: keys arrive directly (focus in shell) or forwarded by the stage
|
|
534
|
-
const handleKey = (key: string, code: string, alt
|
|
568
|
+
const handleKey = (key: string, code: string, alt: boolean, how: CmdOpts) => {
|
|
535
569
|
if (key === 'Escape') {
|
|
536
570
|
// a live review mode swallows Escape first (cancel), so it never ejects you from
|
|
537
571
|
// the prototype mid-comment; a second Escape (nothing live) exits
|
|
538
572
|
const c = commentsStore()
|
|
539
573
|
const s = useStore.getState()
|
|
540
|
-
if (c.commentMode || s.laser || c.active || c.draft) {
|
|
541
|
-
|
|
574
|
+
if (c.commentMode || s.laser || c.active || c.draft) {
|
|
575
|
+
const h = cmd('escape', how)
|
|
576
|
+
if (c.commentMode || c.active || c.draft) h.step('comments-off')
|
|
577
|
+
if (s.laser) h.step('laser-off')
|
|
578
|
+
c.setMode(false); c.setActive(null); c.setDraft(null); s.setLaser(false)
|
|
579
|
+
endAfterFrames(h)
|
|
580
|
+
}
|
|
581
|
+
else exitFrom(how)
|
|
542
582
|
return
|
|
543
583
|
}
|
|
544
|
-
if (key === 'ArrowRight') { step(1); return }
|
|
545
|
-
if (key === 'ArrowLeft') { step(-1); return }
|
|
546
|
-
if (key === ' ' && useStore.getState().play?.slides) { step(1); return }
|
|
547
|
-
if (key === '[') { switchVariant(-1); return }
|
|
548
|
-
if (key === ']') { switchVariant(1); return }
|
|
549
|
-
if (key === 'r') { restart(); return }
|
|
550
|
-
if (key === 'h') { toggleHideUI(); return }
|
|
584
|
+
if (key === 'ArrowRight') { step(1, how); return }
|
|
585
|
+
if (key === 'ArrowLeft') { step(-1, how); return }
|
|
586
|
+
if (key === ' ' && useStore.getState().play?.slides) { step(1, how); return }
|
|
587
|
+
if (key === '[') { switchVariant(-1, how); return }
|
|
588
|
+
if (key === ']') { switchVariant(1, how); return }
|
|
589
|
+
if (key === 'r') { restart(how); return }
|
|
590
|
+
if (key === 'h') { cmd('hide-ui', how); toggleHideUI(); return }
|
|
551
591
|
// L: the pointer laser; ⌥L: inspect
|
|
552
|
-
if (key === 'l'
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
592
|
+
if (key === 'l') {
|
|
593
|
+
const h = cmd(alt ? 'inspect' : 'laser', how)
|
|
594
|
+
if (!SOURCE_REVEALED) h.noop('stripped')
|
|
595
|
+
else { commentsStore().setMode(false); useStore.getState().toggleLaser(alt); return }
|
|
596
|
+
}
|
|
597
|
+
if (key === 'c') { const c = commentsStore(); const h = cmd('comments', how); if (!c.commentMode && useStore.getState().board === UNPLACED) { h.noop('unplaced'); return useStore.getState().toast(NO_COMMENTS_HERE) } if (!c.commentMode && stoppedFor('Comments need the canvas running')) { h.noop('stopped'); return } if (!c.commentMode) useStore.getState().setLaser(false); c.setMode(!c.commentMode); return }
|
|
598
|
+
if (key === 'C') { const c = commentsStore(); cmd('pins', how); c.setShow(!c.show); return } // ⇧C hides/shows pins
|
|
599
|
+
if (key === 'L') { const c = commentsStore(); cmd('laser-comment', how); c.setShowAnchor(!c.showAnchor); return } // ⇧L element focus
|
|
556
600
|
|
|
557
601
|
if (/^Digit[1-9]$/.test(code)) {
|
|
558
602
|
const names = Object.keys(CONFIG.viewports)
|
|
559
603
|
const idx = Number(code.slice(5))
|
|
604
|
+
const h = cmd('device', how)
|
|
560
605
|
if (idx <= names.length) setDevice(names[idx - 1])
|
|
561
606
|
else if (idx === names.length + 1) setDevice('fill')
|
|
607
|
+
else h.noop('unknown-device')
|
|
562
608
|
}
|
|
563
|
-
if (key === 'd'
|
|
564
|
-
|
|
565
|
-
|
|
609
|
+
if (key === 'd') {
|
|
610
|
+
if (CONFIG.themes.length > 1) {
|
|
611
|
+
const p = useStore.getState().play!
|
|
612
|
+
setTheme(CONFIG.themes[(CONFIG.themes.indexOf(p.theme) + 1) % CONFIG.themes.length], how)
|
|
613
|
+
} else cmd('theme', how).noop('one-theme')
|
|
566
614
|
}
|
|
567
615
|
}
|
|
568
616
|
/** ⌘/ collapses the toolbar to a re-open fab - same shortcut + ladder as design mode. */
|
|
@@ -574,9 +622,9 @@ function PlayInner() {
|
|
|
574
622
|
// with Option a Mac types a symbol (⌥L is "¬"): an Alt shortcut is named by the key pressed
|
|
575
623
|
const key = e.altKey && /^Key[A-Z]$/.test(e.code) ? e.code.slice(3).toLowerCase() : e.key
|
|
576
624
|
if (!e.repeat && jamKey({ key, shift: e.shiftKey, alt: e.altKey, meta: e.metaKey, ctrl: e.ctrlKey })) { e.preventDefault(); return }
|
|
577
|
-
if ((e.metaKey || e.ctrlKey) && e.key === '/') { e.preventDefault(); toggleCollapse(); return }
|
|
625
|
+
if ((e.metaKey || e.ctrlKey) && e.key === '/') { e.preventDefault(); cmd('toolbar', { via: 'key', in: 'shell', keys: keysOf(e) }); toggleCollapse(); return }
|
|
578
626
|
if (e.metaKey || e.ctrlKey) return
|
|
579
|
-
handleKey(key, e.code, e.altKey)
|
|
627
|
+
handleKey(key, e.code, e.altKey, { via: 'key', in: 'shell', keys: keysOf(e, key) })
|
|
580
628
|
}
|
|
581
629
|
window.addEventListener('keydown', onKey)
|
|
582
630
|
return () => window.removeEventListener('keydown', onKey)
|
|
@@ -634,7 +682,7 @@ function PlayInner() {
|
|
|
634
682
|
// background advance: never on controls, links, media, comments, or goto targets
|
|
635
683
|
const t = e.target as Element
|
|
636
684
|
if (t.closest('a, button, input, textarea, select, video, [contenteditable], [data-goto], .cm-card, .cm-pin, .cm-stack, .sh-pill')) return
|
|
637
|
-
step(1)
|
|
685
|
+
step(1, { via: 'click', in: 'stage' })
|
|
638
686
|
} : undefined}>
|
|
639
687
|
<div className="dev" data-theme={play.theme} style={{ width: dw, height: dh }}>
|
|
640
688
|
<iframe
|
|
@@ -702,8 +750,8 @@ function PlayInner() {
|
|
|
702
750
|
<LaserButton />
|
|
703
751
|
{!PUBLISHED && CONFIG.jam && <JamButton inPlay />}
|
|
704
752
|
<i className="sep" />
|
|
705
|
-
{!docPreset && <DevicePicker value={fill ? 'fill' : play.device} onSelect={(n) => n
|
|
706
|
-
<ThemePicker value={play.theme} onSelect={setTheme} hint="D" dark />
|
|
753
|
+
{!docPreset && <DevicePicker value={fill ? 'fill' : play.device} onSelect={(n) => { if (!n) return; cmd('device', { via: 'click', in: 'pill', arg: n }); setDevice(n) }} includeFill includeSlide={slides} stageOnly={slides} hint={deviceHint} dark />}
|
|
754
|
+
<ThemePicker value={play.theme} onSelect={(t) => setTheme(t, { via: 'click', in: 'pill' })} hint="D" dark />
|
|
707
755
|
</>}
|
|
708
756
|
{playUpdateRevision && <>
|
|
709
757
|
<i className="sep" />
|
|
@@ -715,7 +763,7 @@ function PlayInner() {
|
|
|
715
763
|
<i className="sep" />
|
|
716
764
|
<HideUIButton />
|
|
717
765
|
<Tip side="bottom" label={<><b>Collapse toolbar</b><span>H hides everything · ⌘/</span></>}>
|
|
718
|
-
<button className="sh-pill-btn" onClick={() => setPillOpen(false)} tabIndex={pillOpen ? 0 : -1}>
|
|
766
|
+
<button className="sh-pill-btn" onClick={() => { cmd('toolbar', { via: 'click', in: 'pill' }); setPillOpen(false) }} tabIndex={pillOpen ? 0 : -1}>
|
|
719
767
|
<PanelFilledIcon size={17} style={{ transform: 'rotate(90deg)' }} />
|
|
720
768
|
</button>
|
|
721
769
|
</Tip>
|
|
@@ -724,7 +772,7 @@ function PlayInner() {
|
|
|
724
772
|
deep link (the link's chrome) - not hidden, not rendered */}
|
|
725
773
|
{!noDoor && (
|
|
726
774
|
<Tip side="bottom" label={<><b>Open in canvas</b><span>Esc</span></>}>
|
|
727
|
-
<button className="sh-pill-btn" data-play-exit="" onClick={
|
|
775
|
+
<button className="sh-pill-btn" data-play-exit="" onClick={() => exitFrom({ via: 'click', in: 'pill' })}><GridIcon size={16} /></button>
|
|
728
776
|
</Tip>
|
|
729
777
|
)}
|
|
730
778
|
{BRANDING && PUBLISHED && !trimmed && (
|
|
@@ -738,28 +786,28 @@ function PlayInner() {
|
|
|
738
786
|
)}
|
|
739
787
|
{!(slides && deckChrome === 'none') && (
|
|
740
788
|
<Tip side="bottom" label={<><b>Open toolbar</b><span>⌘/</span></>}>
|
|
741
|
-
<button className={`sh-pill-fab${pillOpen ? ' hidden' : ''}`} onClick={() => setPillOpen(true)}
|
|
789
|
+
<button className={`sh-pill-fab${pillOpen ? ' hidden' : ''}`} onClick={() => { cmd('toolbar', { via: 'click', in: 'pill' }); setPillOpen(true) }}
|
|
742
790
|
aria-hidden={pillOpen} tabIndex={pillOpen ? -1 : 0}><PanelHollowIcon size={18} style={{ transform: 'rotate(90deg)' }} /></button>
|
|
743
791
|
</Tip>
|
|
744
792
|
)}
|
|
745
793
|
|
|
746
794
|
{!focus && !trimmed && <div className="sh-play-nav">
|
|
747
795
|
<Tip inv label={<><b>Restart</b><span className="k">R</span></>}>
|
|
748
|
-
<button onClick={restart}><ReloadIcon size={14} /></button>
|
|
796
|
+
<button onClick={() => restart({ via: 'click', in: 'pill' })}><ReloadIcon size={14} /></button>
|
|
749
797
|
</Tip>
|
|
750
798
|
<i className="sep" />
|
|
751
799
|
<Tip inv label={<><b>Previous frame</b><span className="k">←</span></>}>
|
|
752
|
-
<button onClick={() => step(-1)}><ArrowLeftIcon size={14} /></button>
|
|
800
|
+
<button onClick={() => step(-1, { via: 'click', in: 'pill' })}><ArrowLeftIcon size={14} /></button>
|
|
753
801
|
</Tip>
|
|
754
802
|
<span className="pos">{pos === -1 ? '·' : pos + 1}<em>/</em>{list.length}</span>
|
|
755
803
|
<Tip inv label={<><b>Next frame</b><span className="k">→</span></>}>
|
|
756
|
-
<button onClick={() => step(1)}><ArrowRightIcon size={14} /></button>
|
|
804
|
+
<button onClick={() => step(1, { via: 'click', in: 'pill' })}><ArrowRightIcon size={14} /></button>
|
|
757
805
|
</Tip>
|
|
758
806
|
{variants.length > 1 && <>
|
|
759
807
|
<i className="sep" />
|
|
760
808
|
{variants.map((v) => (
|
|
761
809
|
<Tip inv key={v.id} label={<><b>{v.title ?? v.id}</b><span className="k">[ ]</span></>}>
|
|
762
|
-
<button className={`vchip${v.id === play.at ? ' on' : ''}`} onClick={() => goTo(v.id)}>
|
|
810
|
+
<button className={`vchip${v.id === play.at ? ' on' : ''}`} onClick={() => { if (v.id === play.at) cmd('play-variant', { via: 'click', in: 'pill' }).noop('no-variants'); else { endOnStage(cmd('play-variant', { via: 'click', in: 'pill' }), v.id); goTo(v.id) } }}>
|
|
763
811
|
{(v.variant ?? '?').toUpperCase()}
|
|
764
812
|
</button>
|
|
765
813
|
</Tip>
|
|
@@ -3,6 +3,7 @@ import { StatusIcon } from './board-icons.tsx'
|
|
|
3
3
|
import { STATUS_LABEL, type Status } from '../../shared/status.ts'
|
|
4
4
|
import type { StatusWord } from '../../shared/board-types.ts'
|
|
5
5
|
import type { BoardMeta } from './store.ts'
|
|
6
|
+
import { cmd, keysOf, type CmdHandle, type CmdOpts } from './commands.ts'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A board's status, from its right-click menu - Linear's picker, on Marver's rule (spec 20): a
|
|
@@ -13,10 +14,14 @@ import type { BoardMeta } from './store.ts'
|
|
|
13
14
|
* the shipped record. The status the evidence gives shows read-only at the top, with where it came from.
|
|
14
15
|
*
|
|
15
16
|
* Type to filter, arrows and Enter, or a number. Blocked asks why before it writes.
|
|
17
|
+
*
|
|
18
|
+
* `board-status` (spec 30) starts at the decision and `onPick` ends it on the write's answer; the status and the reason
|
|
19
|
+
* stay out of it. Closing with nothing chosen is BoardList's to record: ContextMenu's listeners close this panel, and
|
|
20
|
+
* BoardList's run first (`data-board` says which board was being decided).
|
|
16
21
|
*/
|
|
17
22
|
type Opt = { key: string; status: StatusWord | null; label: string; icon: Status | 'clear' }
|
|
18
23
|
|
|
19
|
-
export function StatusPicker({ meta, onPick }: { meta: BoardMeta; onPick: (status: StatusWord | null, reason
|
|
24
|
+
export function StatusPicker({ board, meta, close, onPick }: { board: string; meta: BoardMeta; close: () => void; onPick: (board: string, status: StatusWord | null, reason: string | undefined, h: CmdHandle) => void }) {
|
|
20
25
|
const settable = meta.settable ?? []
|
|
21
26
|
const current = meta.status
|
|
22
27
|
const hasContext = !settable.includes('todo')
|
|
@@ -31,26 +36,31 @@ export function StatusPicker({ meta, onPick }: { meta: BoardMeta; onPick: (statu
|
|
|
31
36
|
const [asking, setAsking] = useState(false)
|
|
32
37
|
const [reason, setReason] = useState(current?.status === 'blocked' ? current.reason ?? '' : '')
|
|
33
38
|
|
|
34
|
-
const
|
|
39
|
+
const decide = (status: StatusWord | null, reason: string | undefined, how: CmdOpts) => {
|
|
40
|
+
const h = cmd('board-status', { ...how, board })
|
|
41
|
+
close()
|
|
42
|
+
onPick(board, status, reason, h)
|
|
43
|
+
}
|
|
44
|
+
const choose = (o: Opt | undefined, how: CmdOpts) => {
|
|
35
45
|
if (!o) return
|
|
36
46
|
if (o.status === 'blocked') { setAsking(true); return }
|
|
37
|
-
|
|
47
|
+
decide(o.status, undefined, how)
|
|
38
48
|
}
|
|
39
49
|
const keys = (e: KeyboardEvent<HTMLInputElement>) => {
|
|
40
50
|
if (e.key === 'ArrowDown') { e.preventDefault(); setHi((h) => Math.min(h + 1, shown.length - 1)) }
|
|
41
51
|
else if (e.key === 'ArrowUp') { e.preventDefault(); setHi((h) => Math.max(h - 1, 0)) }
|
|
42
|
-
else if (e.key === 'Enter') { e.preventDefault(); choose(shown[hi]) }
|
|
43
|
-
else if (/^[1-9]$/.test(e.key) && !q) { e.preventDefault(); choose(opts[Number(e.key) - 1]) }
|
|
52
|
+
else if (e.key === 'Enter') { e.preventDefault(); choose(shown[hi], { via: 'key', in: 'shell', keys: keysOf(e) }) }
|
|
53
|
+
else if (/^[1-9]$/.test(e.key) && !q) { e.preventDefault(); choose(opts[Number(e.key) - 1], { via: 'key', in: 'shell', keys: keysOf(e) }) }
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
if (asking) {
|
|
47
57
|
const ok = !!reason.trim()
|
|
48
58
|
return (
|
|
49
|
-
<div className="sh-status-picker" data-status-picker="reason">
|
|
59
|
+
<div className="sh-status-picker" data-status-picker="reason" data-board={board}>
|
|
50
60
|
<div className="sp-head"><StatusIcon status="blocked" /><b>Blocked - why?</b></div>
|
|
51
61
|
<input autoFocus className="sp-input" value={reason} maxLength={300} placeholder="Waiting on…"
|
|
52
62
|
onChange={(e) => setReason(e.target.value)}
|
|
53
|
-
onKeyDown={(e) => { if (e.key === 'Enter' && ok) { e.preventDefault();
|
|
63
|
+
onKeyDown={(e) => { if (e.key === 'Enter' && ok) { e.preventDefault(); decide('blocked', reason.trim(), { via: 'key', in: 'shell', keys: keysOf(e) }) } }} />
|
|
54
64
|
<div className="sp-foot">{ok ? 'Enter to save' : 'A blocked board says why'} · Esc to close</div>
|
|
55
65
|
</div>
|
|
56
66
|
)
|
|
@@ -59,7 +69,7 @@ export function StatusPicker({ meta, onPick }: { meta: BoardMeta; onPick: (statu
|
|
|
59
69
|
// what the evidence says, when no decision hides it: the status and the line that decided it
|
|
60
70
|
const evidence = !decided && current && hasContext ? current.evidence?.[0] : undefined
|
|
61
71
|
return (
|
|
62
|
-
<div className="sh-status-picker" data-status-picker="list">
|
|
72
|
+
<div className="sh-status-picker" data-status-picker="list" data-board={board}>
|
|
63
73
|
<input autoFocus className="sp-input" value={q} placeholder="Change status…"
|
|
64
74
|
onChange={(e) => { setQ(e.target.value); setHi(0) }} onKeyDown={keys} />
|
|
65
75
|
{current && evidence && (
|
|
@@ -76,7 +86,7 @@ export function StatusPicker({ meta, onPick }: { meta: BoardMeta; onPick: (statu
|
|
|
76
86
|
const isCurrent = o.status !== null && o.status === current?.status && (decided || !hasContext || fromPlan)
|
|
77
87
|
return (
|
|
78
88
|
<button key={o.key} data-status-option={o.key} className={i === hi ? 'hi' : undefined}
|
|
79
|
-
onMouseEnter={() => setHi(i)} onClick={() => choose(o)}>
|
|
89
|
+
onMouseEnter={() => setHi(i)} onClick={() => choose(o, { via: 'click', in: 'shell' })}>
|
|
80
90
|
{o.icon === 'clear'
|
|
81
91
|
? <svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden><path d="M3.2 6.2 A4.2 4.2 0 1 1 4.4 10.4 M3.2 3.4 V6.2 H6" /></svg>
|
|
82
92
|
: <StatusIcon status={o.icon} />}
|
|
@@ -13,6 +13,7 @@ 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
|
+
import { cmd } from './commands.ts'
|
|
16
17
|
import { CaretIcon, CheckIcon, CommentIcon, DevicesIcon, EyeSlashIcon, FrameCornersIcon, LaserIcon, MoonIcon, SlideFrameIcon, SunIcon, deviceIcon } from './icons.tsx'
|
|
17
18
|
|
|
18
19
|
const commentsStore = () => useComments.getState()
|
|
@@ -63,6 +64,8 @@ export function toggleHideUI() {
|
|
|
63
64
|
document.body.classList.toggle('sh-hide-ui', !isHideUI())
|
|
64
65
|
hideListeners.forEach((f) => f())
|
|
65
66
|
}
|
|
67
|
+
/** Told at every toggle, in its own turn (the recorder's `hide-ui` mode, spec 30 #25). Returns the unsubscribe. */
|
|
68
|
+
export const onHideUI = (f: () => void) => { hideListeners.add(f); return () => { hideListeners.delete(f) } }
|
|
66
69
|
export function useHideUI() {
|
|
67
70
|
const [on, setOn] = useState(isHideUI)
|
|
68
71
|
useEffect(() => {
|
|
@@ -98,6 +101,7 @@ export function LaserButton() {
|
|
|
98
101
|
return (
|
|
99
102
|
<Tip side="bottom" label={<TipRows rows={[['Laser', 'L'], ['Inspect', '⌥L'], [showAnchor ? 'Hide laser comment' : 'Show laser comment', '⇧L']]} />}>
|
|
100
103
|
<button className={`sh-pill-btn${laser ? ' on' : ''}`} data-laser={laser ? (laserInspect ? 'inspect' : 'pointer') : 'off'} onClick={(e) => {
|
|
104
|
+
cmd(e.altKey ? 'inspect' : 'laser', { via: 'click', in: 'pill' })
|
|
101
105
|
commentsStore().setMode(false)
|
|
102
106
|
useStore.getState().toggleLaser(e.altKey)
|
|
103
107
|
}}><LaserIcon size={16} /></button>
|
|
@@ -122,7 +126,7 @@ export function CommentButton() {
|
|
|
122
126
|
if (stopped && !commentMode) {
|
|
123
127
|
return (
|
|
124
128
|
<Tip side="bottom" label={<div className="sh-tip-lines"><b>Comments need the canvas running</b><small>{STOPPED_TIP}</small></div>}>
|
|
125
|
-
<button className="sh-pill-btn off" aria-disabled="true" data-stopped="" onClick={() => stoppedFor('Comments need the canvas running')}><CommentIcon size={16} /></button>
|
|
129
|
+
<button className="sh-pill-btn off" aria-disabled="true" data-stopped="" onClick={() => { const h = cmd('comments', { via: 'click', in: 'pill' }); stoppedFor('Comments need the canvas running'); h.noop('stopped') }}><CommentIcon size={16} /></button>
|
|
126
130
|
</Tip>
|
|
127
131
|
)
|
|
128
132
|
}
|
|
@@ -131,10 +135,13 @@ export function CommentButton() {
|
|
|
131
135
|
<Tip side="bottom" label={<><b>Commenting is not available for you yet</b><span>click to ask the owner</span></>}>
|
|
132
136
|
<button className="sh-pill-btn" style={{ opacity: .55 }} onClick={() => {
|
|
133
137
|
const s = useStore.getState()
|
|
134
|
-
|
|
138
|
+
const h = cmd('ask-to-comment', { via: 'click', in: 'pill' })
|
|
139
|
+
if (Date.now() - asked.current < 8000) { h.noop('too-soon'); return }
|
|
135
140
|
asked.current = Date.now()
|
|
136
|
-
void commentsStore().askToComment().then((ok) =>
|
|
137
|
-
|
|
141
|
+
void commentsStore().askToComment().then((ok) => {
|
|
142
|
+
if (ok) h.done(); else h.fail('api')
|
|
143
|
+
s.toast(ok ? 'asked the owner for comment access - they decide' : 'could not send the request - try again')
|
|
144
|
+
}, (e: unknown) => { h.fail('api'); throw e })
|
|
138
145
|
}}><CommentIcon size={16} /></button>
|
|
139
146
|
</Tip>
|
|
140
147
|
)
|
|
@@ -143,8 +150,9 @@ export function CommentButton() {
|
|
|
143
150
|
<Tip side="bottom" label={<TipRows rows={[['Comment', 'C'], [show ? 'Hide pins' : 'Show pins', '⇧C']]} />}>
|
|
144
151
|
<button className={`sh-pill-btn${commentMode ? ' on' : ''}`} onClick={() => {
|
|
145
152
|
const c = commentsStore()
|
|
146
|
-
|
|
147
|
-
if (!c.commentMode &&
|
|
153
|
+
const h = cmd('comments', { via: 'click', in: 'pill' })
|
|
154
|
+
if (!c.commentMode && useStore.getState().board === UNPLACED) { h.noop('unplaced'); return useStore.getState().toast(NO_COMMENTS_HERE) }
|
|
155
|
+
if (!c.commentMode && stoppedFor('Comments need the canvas running')) { h.noop('stopped'); return }
|
|
148
156
|
if (!c.commentMode) useStore.getState().setLaser(false)
|
|
149
157
|
c.setMode(!c.commentMode)
|
|
150
158
|
useStore.getState().toast(c.commentMode ? 'comment mode off' : 'comment mode - click an element in a frame')
|
|
@@ -159,7 +167,7 @@ export function HideUIButton() {
|
|
|
159
167
|
const on = useHideUI()
|
|
160
168
|
return (
|
|
161
169
|
<Tip side="bottom" label={<><b>Hide all UI</b><span>press H to reveal</span></>}>
|
|
162
|
-
<button className={`sh-pill-btn${on ? ' on' : ''}`} onClick={toggleHideUI}><EyeSlashIcon size={16} /></button>
|
|
170
|
+
<button className={`sh-pill-btn${on ? ' on' : ''}`} onClick={() => { cmd('hide-ui', { via: 'click', in: 'pill' }); toggleHideUI() }}><EyeSlashIcon size={16} /></button>
|
|
163
171
|
</Tip>
|
|
164
172
|
)
|
|
165
173
|
}
|
package/src/client/shell/api.ts
CHANGED
|
@@ -10,6 +10,10 @@ import { create } from 'zustand'
|
|
|
10
10
|
import { ROUTE } from '../const.ts'
|
|
11
11
|
import { guardLeaving, leaveNow, unsavedWhen, workChanged } from './unsaved.ts'
|
|
12
12
|
import { PERF_RUN, perfRunGate, RUN_HEADER, RUN_PARAM } from './perf-run.ts'
|
|
13
|
+
import { RECORDER_LEVEL } from '../recorder-level.ts'
|
|
14
|
+
import { RECORDER_PARAM } from '../../shared/perf-records.ts'
|
|
15
|
+
import { perfSeams } from './recorder-seams.ts'
|
|
16
|
+
import { hmrBack, hmrLost as recordHmrLost } from './recorder-hmr.ts'
|
|
13
17
|
// @ts-expect-error virtual module provided by the plugin
|
|
14
18
|
import shConfig from 'virtual:sh-config'
|
|
15
19
|
// @ts-expect-error virtual module: null in dev; a published build inlines manifest+boards
|
|
@@ -22,10 +26,12 @@ export const WS: string = shData === null && typeof shConfig?.workspace === 'str
|
|
|
22
26
|
export const scoped = (key: string) => (WS ? `${key}:${WS}` : key)
|
|
23
27
|
const param = (url: string, k: string, v: string) => `${url}${url.includes('?') ? '&' : '?'}${k}=${v}`
|
|
24
28
|
/** A URL a document or an <img> loads, naming the workspace (frames, the stage, Jam pictures) - and, in a headless
|
|
25
|
-
* perf run, the run (spec 28 A3.8 #17): a frame's own writes are refused by its Referer, its Video asks no poster.
|
|
29
|
+
* perf run, the run (spec 28 A3.8 #17): a frame's own writes are refused by its Referer, its Video asks no poster.
|
|
30
|
+
* A page recording at the `core` level (spec 30 #58) says so too, so its frames' hooks keep its level. */
|
|
26
31
|
export const withWs = (url: string) => {
|
|
27
32
|
const u = WS ? param(url, 'ws', WS) : url
|
|
28
|
-
|
|
33
|
+
const v = RECORDER_LEVEL === 'core' ? param(u, RECORDER_PARAM, 'core') : u
|
|
34
|
+
return PERF_RUN ? param(v, RUN_PARAM, PERF_RUN.id) : v
|
|
29
35
|
}
|
|
30
36
|
/** The headers every request of this page carries: its workspace, and its perf run's id. */
|
|
31
37
|
const named = (h: Record<string, string> | undefined): Record<string, string> => ({ ...h, ...(WS ? { 'x-mv-ws': WS } : {}), ...(PERF_RUN ? { [RUN_HEADER]: PERF_RUN.id } : {}) })
|
|
@@ -56,14 +62,20 @@ export function mvFetch(url: string, init: RequestInit = {}): Promise<Response>
|
|
|
56
62
|
const refused = perfRunGate(url, init)
|
|
57
63
|
if (refused) return Promise.resolve(refused)
|
|
58
64
|
if (WS && canvasStopped()) return Promise.resolve(stoppedAnswer())
|
|
59
|
-
|
|
65
|
+
// the recorder's (spec 30 #18): a board write names its page and the commands folded into it - none until then
|
|
66
|
+
const extra = WS ? perfSeams.requestHeaders(url, init) : undefined
|
|
67
|
+
const headers = extra ? { ...(init.headers as Record<string, string> | undefined), ...extra } : init.headers as Record<string, string> | undefined
|
|
68
|
+
const t0 = performance.now()
|
|
69
|
+
const sent = fetch(url, WS || PERF_RUN ? { ...init, headers: named(headers) } : init)
|
|
60
70
|
if (!WS) return sent
|
|
61
71
|
// the server's refusal is told apart here, before any caller's own 409 (a board conflict, a stale tree)
|
|
62
72
|
return sent.then((r) => {
|
|
73
|
+
perfSeams.answered.emit({ url, init, headers, status: r.status, ms: performance.now() - t0 })
|
|
63
74
|
if (r.status !== 409 || r.headers.get('x-mv-elsewhere') !== '1') return r
|
|
64
75
|
lost('elsewhere')
|
|
65
76
|
return stoppedAnswer()
|
|
66
77
|
}, (e: unknown) => {
|
|
78
|
+
perfSeams.answered.emit({ url, init, headers, status: (e as Error)?.name === 'TimeoutError' ? 'timeout' : 0, ms: performance.now() - t0 })
|
|
67
79
|
// the live socket is gone, so nothing else would say so: a request that reaches nothing stops the page
|
|
68
80
|
if (hmrLost && (e as Error)?.name !== 'AbortError') lost('down')
|
|
69
81
|
throw e
|
|
@@ -127,6 +139,8 @@ async function resume() {
|
|
|
127
139
|
if (back) useLink.setState({ link: 'resuming' }) // requests flow again: the flushers use them
|
|
128
140
|
let ok = true
|
|
129
141
|
for (const fn of flushers) ok = (await fn().catch(() => false)) && ok
|
|
142
|
+
// the socket's way back (spec 30 #30): said before anything below decides, a second at most - the holds are asked after it
|
|
143
|
+
await hmrBack()
|
|
130
144
|
const now = useLink.getState().link
|
|
131
145
|
if (now !== 'resuming' && now !== 'live') return // lost again while saving: the probe goes on
|
|
132
146
|
// asked here, with nothing awaited between the answer and the reload: words typed or an edit made while a
|
|
@@ -207,12 +221,16 @@ export const resumed: { outcome: ResumeOutcome; board?: string; camera?: { x: nu
|
|
|
207
221
|
// words a person typed into the page and has not sent (a comment, a Jam edit, a name): a reload would drop them
|
|
208
222
|
const typed = new WeakSet<EventTarget>()
|
|
209
223
|
const TEXT_FIELDS = 'textarea, input:not([type]), input[type=text], input[type=search], input[type=email], input[type=url], input[type=password]'
|
|
224
|
+
/** Does a text field on the page hold words typed and not sent? The `typing` reason's own check, and what a notice's
|
|
225
|
+
* click reads before every move (spec 28 A4.6 #30, r2 #1): a board change, another thread or a panel replaced would
|
|
226
|
+
* unmount the field and lose them. Words the shell keeps with no field on screen (a More work draft, a read-back's
|
|
227
|
+
* edit still saving) are not here: they survive a move. */
|
|
228
|
+
export const typedUnsent = (): boolean => [...document.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>(TEXT_FIELDS)].some((el) => typed.has(el) && el.value.trim() !== '')
|
|
210
229
|
if (WS) {
|
|
211
230
|
document.addEventListener('input', (e) => { if (e.target) typed.add(e.target); if (canvasStopped()) noteUnsaved(); workChanged() }, true)
|
|
212
|
-
|
|
213
|
-
holdsReload(typedWords)
|
|
231
|
+
holdsReload(typedUnsent)
|
|
214
232
|
// and leaving the page asks first (spec 28 A2.9): the words are only here
|
|
215
|
-
unsavedWhen('typing',
|
|
233
|
+
unsavedWhen('typing', typedUnsent)
|
|
216
234
|
}
|
|
217
235
|
|
|
218
236
|
// one question before this page goes, whatever it holds that the server does not have (unsaved.ts): a capture, a
|
|
@@ -225,7 +243,7 @@ if (typeof window !== 'undefined' && !PERF_RUN) guardLeaving(window)
|
|
|
225
243
|
// Vite - not into another project that took the port, and not into this one's next run before it has
|
|
226
244
|
// saved what it holds - and its socket stays closed, so no other project's broadcast reaches it. It
|
|
227
245
|
// reloads itself in resume(). Frames keep Vite's own reload: their URLs name the workspace.
|
|
228
|
-
if (WS && import.meta.hot) import.meta.hot.on('vite:ws:disconnect', () => { hmrLost = true; lost('down'); return new Promise<never>(() => {}) })
|
|
246
|
+
if (WS && import.meta.hot) import.meta.hot.on('vite:ws:disconnect', () => { hmrLost = true; recordHmrLost(); lost('down'); return new Promise<never>(() => {}) })
|
|
229
247
|
|
|
230
248
|
// dev-only inspection hook for tests (never installed in published builds)
|
|
231
249
|
if (WS && import.meta.env.DEV) (window as unknown as { __mvLink: unknown }).__mvLink = useLink
|