@marver-design/marver 0.30.1 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/README.md +12 -8
- package/dist/{anchor-check-Bv4o-R2T.mjs → anchor-check-DZtX13ly.mjs} +1 -1
- package/dist/{board-tree-BXR8dw4b.mjs → board-tree-DGj0HhEE.mjs} +6 -2
- package/dist/{boards-EH2onUXM.mjs → boards-Cim1GTKc.mjs} +32 -2
- package/dist/{boards-BeWtjGUM.mjs → boards-jHmEPLV7.mjs} +7 -7
- package/dist/{build-zWGXSzly.mjs → build-D2dHEWX-.mjs} +14 -17
- package/dist/{capture-DEtM4qm5.mjs → capture-HaS-1or8.mjs} +1 -1
- package/dist/cli.mjs +38 -20
- package/dist/{collab-BEAcXrBb.mjs → collab-D2NcrOB8.mjs} +53 -14
- package/dist/comment-actions-Bxf9Ld4g.mjs +351 -0
- package/dist/{comments-XNhMmSSu.mjs → comments-ocvsnt2j.mjs} +85 -10
- package/dist/config-B0YcFtqS.mjs +510 -0
- package/dist/{context-BUnFiyA3.mjs → context-Cj2TcC0H.mjs} +3 -3
- package/dist/{daemon-CChgWJNq.mjs → daemon-D6TrdgMi.mjs} +268 -28
- package/dist/deep-link-DYtuT740.mjs +163 -0
- package/dist/{dev-DOgIITpT.mjs → dev-DMQYbw-2.mjs} +23 -16
- package/dist/devices-uJZ2inMq.mjs +155 -0
- package/dist/{events-CLH4ijKP.mjs → events-Dieo1482.mjs} +49 -4
- package/dist/{init-CYlFaRzG.mjs → init-BgusplYn.mjs} +40 -10
- package/dist/{jam-Cj5gBvwD.mjs → jam-CkuLL8A8.mjs} +1 -1
- package/dist/{link-BFFRgrMt.mjs → link-aZq5cExV.mjs} +54 -7
- package/dist/{logo-CXY-1yrn.mjs → logo-C9s7-Cy9.mjs} +89 -66
- package/dist/{ls-NqmePKOf.mjs → ls-DGVIW-Io.mjs} +1 -1
- package/dist/{manifest-DPZ3WNg_.mjs → manifest-CK8Qh4Nq.mjs} +255 -13
- package/dist/{marks-BnNANic9.mjs → marks-C8oX8kbE.mjs} +3 -3
- package/dist/{marks-DBp3h1Mc.mjs → marks-Dt-5JXCp.mjs} +18 -5
- package/dist/{marver-id-gate-vBLb_Icb.mjs → marver-id-gate-BAeuMeaU.mjs} +11 -7
- package/dist/md-B9_13Q0R.mjs +105 -0
- package/dist/notes-CRAX4wgk.mjs +148 -0
- package/dist/own-C8Mq0Hnf.mjs +128 -0
- package/dist/pdf-Cf9GIoIM.mjs +2299 -0
- package/dist/pdf-HB0prF75.mjs +117 -0
- package/dist/{perf-6MOTHxay.mjs → perf-9ZEF5KLO.mjs} +5 -5
- package/dist/{perf-BCxAo0IS.mjs → perf-BA_NDarr.mjs} +2 -1
- package/dist/{plugin-CFWBcAba.mjs → plugin-DesQP9L5.mjs} +565 -107
- package/dist/{poster-DPPpQiva.mjs → poster-Bb6WraCA.mjs} +1 -1
- package/dist/{profile-B1FKOM1e.mjs → profile-cdmSer1k.mjs} +1 -1
- package/dist/{publish-bakes-_Zx8crP3.mjs → publish-bakes-EjMmukJB.mjs} +3 -3
- package/dist/{queue-DeSQm24g.mjs → queue-BLLfdlDw.mjs} +156 -11
- package/dist/{recover-mDUVsnPd.mjs → recover-B3dmatx4.mjs} +2 -2
- package/dist/{serve-DQv3Ti6X.mjs → serve-kcF6-H8V.mjs} +4 -4
- package/dist/{session-VDJfXEEm.mjs → session-DBF-nQvq.mjs} +29 -3
- package/dist/{share-Bu_kuOKL.mjs → share-CS2mg27O.mjs} +1 -1
- package/dist/{shot-d4h_hJi9.mjs → shot-Bjt2MQe3.mjs} +4 -4
- package/dist/{shot-DBWN8hPP.mjs → shot-BuUCG46-.mjs} +1 -1
- package/dist/show-DhmiUu01.mjs +101 -0
- package/dist/{sizes-wjXDev3b.mjs → sizes-BckcL4Zz.mjs} +1 -1
- package/dist/{slots-Dn4Onb0V.mjs → slots-BOcfIqxy.mjs} +15 -3
- package/dist/{summary-Y8MY1Wuc.mjs → summary-cPmRDGpX.mjs} +1 -1
- package/dist/{sync-CMozOwZ0.mjs → sync-BNWwh8OF.mjs} +205 -7
- package/dist/{work-DJxH7cCX.mjs → work-B4tydWnf.mjs} +38 -2
- package/dist/{work-BYWD_1Zf.mjs → work-CzIXp7n1.mjs} +3 -3
- package/docs/app.md +143 -6
- package/docs/boards-and-folders.md +41 -7
- package/docs/jam-session.md +5 -0
- package/docs/live-jam.md +9 -0
- package/docs/pdf.md +108 -0
- package/docs/publish.md +9 -9
- package/docs/sharing.md +11 -0
- package/docs/slides.md +11 -1
- package/package.json +3 -1
- package/src/client/content/index.tsx +4 -2
- package/src/client/frame-host/main.tsx +3 -0
- package/src/client/shell/App.tsx +71 -24
- package/src/client/shell/BoardList.tsx +16 -7
- package/src/client/shell/Comments.tsx +77 -16
- package/src/client/shell/Play.tsx +104 -27
- package/src/client/shell/Toolbar.tsx +4 -3
- package/src/client/shell/app-bridge.ts +40 -5
- package/src/client/shell/canvas/Canvas.tsx +30 -8
- package/src/client/shell/canvas/FrameNode.tsx +3 -1
- package/src/client/shell/canvas/ctl.ts +16 -0
- package/src/client/shell/commands.ts +20 -0
- package/src/client/shell/comments-store.ts +81 -2
- package/src/client/shell/devices.tsx +42 -0
- package/src/client/shell/goto.ts +56 -9
- package/src/client/shell/icons.tsx +11 -4
- package/src/client/shell/immersive.ts +123 -0
- package/src/client/shell/inset.ts +29 -3
- package/src/client/shell/jam-lines.ts +5 -3
- package/src/client/shell/jam-panel.tsx +17 -5
- package/src/client/shell/marks-ui.tsx +54 -0
- package/src/client/shell/notes.ts +21 -0
- package/src/client/shell/pdf-export.tsx +154 -0
- package/src/client/shell/pdf-notes.ts +20 -0
- package/src/client/shell/recorder-signals.ts +5 -2
- package/src/client/shell/show.ts +250 -0
- package/src/client/shell/store.ts +23 -38
- package/src/client/shell/styles.css +68 -6
- package/src/shared/app-api.ts +90 -4
- package/src/shared/auto-place.ts +32 -0
- package/src/shared/board-tree.ts +3 -0
- package/src/shared/board-types.ts +6 -2
- package/src/shared/deep-link.ts +212 -0
- package/src/shared/devices.ts +89 -0
- package/src/shared/events.ts +48 -5
- package/src/shared/export-plan.ts +98 -0
- package/src/shared/immersive.ts +13 -0
- package/src/shared/perf-records.ts +1 -1
- package/templates/AGENTS-embedded.md +76 -12
- package/templates/AGENTS-studio.md +76 -12
- package/templates/instructions/boards.md +6 -5
- package/templates/instructions/configure.md +32 -2
- package/templates/instructions/iterate.md +8 -0
- package/templates/instructions/jam.md +9 -0
- package/templates/instructions/publish.md +14 -4
- package/templates/instructions/review.md +4 -0
- package/templates/instructions/slides.md +67 -1
- package/templates/instructions/welcome.md +9 -5
- package/templates/playbooks/publish-canvas/PLAYBOOK.md +1 -1
- package/dist/config-BezZTiov.mjs +0 -182
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Immersive play (spec 32 C1, C2, C6): in play - prototype, slides or focus - Hide UI takes the whole window in the Mac
|
|
3
|
+
* app: the strip leaves with the shell's pills and the stage grows into the room they gave back. Canvas mode never is.
|
|
4
|
+
*
|
|
5
|
+
* The rule is derived, never latched. The wish:
|
|
6
|
+
*
|
|
7
|
+
* wants = TOP === 44 && typeof APP?.immersive === 'function' && isHideUI() && !!play && !useLink.shown
|
|
8
|
+
*
|
|
9
|
+
* read from its three sources - `onHideUI`, the store's `play`, and `useLink`'s `shown` (the stopped state, which changes
|
|
10
|
+
* on its own while the connection is probed) - and sent as `APP.immersive({ on })` on every change of it. Main is the
|
|
11
|
+
* authority (app/src/main/immersive-gate.ts): what the shell shows follows main's answer, never the wish. `granted` is
|
|
12
|
+
* true only after main's `{on: true}` for this document; the inset (C3, `setImmersiveTop`) and the recorder (C11) read
|
|
13
|
+
* it from here. `tight` - play's 24 px margins (C4) - is `granted || (isHideUI() && refused)` where the app speaks
|
|
14
|
+
* immersive, `refused` being main's latest answer a `{on: false}` with no `end` to a wish `on`; elsewhere (Chrome, app
|
|
15
|
+
* 1.1) it is `isHideUI()`, as before. So in the app nothing moves between the H press and main's answer, and the answer
|
|
16
|
+
* moves the margins and the inset in one refit. A wish `off` main has not answered within 1 s is taken as answered
|
|
17
|
+
* `{on: false}`.
|
|
18
|
+
*
|
|
19
|
+
* The ways back the shell owns (C6): an answer `{on: false, end: true}` - main took immersive away while the wish stood -
|
|
20
|
+
* restores the inset and turns Hide UI off while play is still on (never a blind toggle); a `hidden` or `untrusted` app
|
|
21
|
+
* state does the same while immersive (`appStateEnds`). Every exit the shell's own wish drops (H, play left, stopped) is
|
|
22
|
+
* answered with no `end`, so Hide UI stays exactly as that exit left it (C1.2).
|
|
23
|
+
*/
|
|
24
|
+
import { APP } from './marver-app.ts'
|
|
25
|
+
import { TOP, setImmersiveTop } from './inset.ts'
|
|
26
|
+
import { isHideUI, onHideUI, toggleHideUI } from './Toolbar.tsx'
|
|
27
|
+
import { useStore } from './store.ts'
|
|
28
|
+
import { useLink } from './api.ts'
|
|
29
|
+
|
|
30
|
+
/** How long a wish `off` waits for main's answer before it is taken as answered `{on: false}` (C1). */
|
|
31
|
+
export const OFF_WAIT_MS = 1000
|
|
32
|
+
|
|
33
|
+
/** The app speaks immersive play: the inset is the strip's, and the preload has the method (C1.4: no FEATURE name). */
|
|
34
|
+
const speaks = (): boolean => TOP === 44 && typeof APP?.immersive === 'function'
|
|
35
|
+
|
|
36
|
+
let wish = false // the wish last sent (none is sent before the first `on`)
|
|
37
|
+
let granted = false // main's `{on: true}` for the wish now standing
|
|
38
|
+
let refused = false // main's latest answer a `{on: false}` with no `end` to a wish `on`
|
|
39
|
+
let offTimer: ReturnType<typeof setTimeout> | undefined
|
|
40
|
+
let started = false
|
|
41
|
+
let shown = { granted: false, tight: false }
|
|
42
|
+
const listeners = new Set<() => void>()
|
|
43
|
+
|
|
44
|
+
/** The wish now, from its three sources (C1). */
|
|
45
|
+
export function wants(): boolean {
|
|
46
|
+
return speaks() && isHideUI() && !!useStore.getState().play && !useLink.getState().shown
|
|
47
|
+
}
|
|
48
|
+
/** Main granted immersive play for this document: the strip is hidden, the play inset is 0 (C3). */
|
|
49
|
+
export const isGranted = (): boolean => granted
|
|
50
|
+
/** Play's 24 px margins (C4): where the app speaks immersive, at main's answer; elsewhere, Hide UI alone. */
|
|
51
|
+
export function tight(): boolean {
|
|
52
|
+
return speaks() ? granted || (isHideUI() && refused) : isHideUI()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The inset follows `granted`, then whoever listens is told once - one refit for one answer. */
|
|
56
|
+
function emit(): void {
|
|
57
|
+
setImmersiveTop(granted)
|
|
58
|
+
const now = { granted, tight: tight() }
|
|
59
|
+
if (now.granted === shown.granted && now.tight === shown.tight) return
|
|
60
|
+
shown = now
|
|
61
|
+
for (const f of [...listeners]) { try { f() } catch (err) { console.error(err) } }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** One of the three sources changed: send the wish when it changed, and re-read `tight` (Hide UI alone moves it in Chrome). */
|
|
65
|
+
function sync(): void {
|
|
66
|
+
const w = wants()
|
|
67
|
+
if (w !== wish) {
|
|
68
|
+
wish = w
|
|
69
|
+
clearTimeout(offTimer); offTimer = undefined
|
|
70
|
+
try { APP?.immersive?.({ on: w }) } catch { /* the app went away under the page */ }
|
|
71
|
+
// a wish off main never answers is taken as answered: the inset comes back
|
|
72
|
+
if (!w) offTimer = setTimeout(() => answered({ on: false }), OFF_WAIT_MS)
|
|
73
|
+
}
|
|
74
|
+
emit()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Main's answer to the latest wish (the preload drops one to an older wish and one for another document, C2). */
|
|
78
|
+
function answered(s: { on: boolean; end?: boolean }): void {
|
|
79
|
+
if (!s || typeof s.on !== 'boolean') return
|
|
80
|
+
clearTimeout(offTimer); offTimer = undefined
|
|
81
|
+
if (s.on) {
|
|
82
|
+
// an `on` can only answer an `on`; one that outran a newer `off` grants nothing
|
|
83
|
+
if (wish) { granted = true; refused = false }
|
|
84
|
+
} else {
|
|
85
|
+
granted = false
|
|
86
|
+
refused = !s.end && wish
|
|
87
|
+
}
|
|
88
|
+
emit()
|
|
89
|
+
// C6.6: main took it away while the wish stood - and play is still on: Hide UI goes, so the chrome comes back
|
|
90
|
+
if (s.on === false && s.end === true && useStore.getState().play && isHideUI()) toggleHideUI()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** C6.4, C6.5: the tab was hidden or lost its trust - immersive play ends with Hide UI off, so coming back shows the chrome. */
|
|
94
|
+
export function appStateEnds(): void {
|
|
95
|
+
if (granted && isHideUI()) toggleHideUI()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Subscribes to the three sources and to main's answers; idempotent. app-bridge.ts starts it in the app; the first
|
|
99
|
+
* `onImmersiveChange` listener starts it anywhere else (Chrome needs `tight` to follow Hide UI). */
|
|
100
|
+
export function startImmersive(): void {
|
|
101
|
+
if (started) return
|
|
102
|
+
started = true
|
|
103
|
+
onHideUI(sync)
|
|
104
|
+
useStore.subscribe((s, p) => { if (!!s.play !== !!p.play) sync() })
|
|
105
|
+
useLink.subscribe((s, p) => { if (s.shown !== p.shown) sync() })
|
|
106
|
+
if (speaks() && typeof APP?.onImmersive === 'function') {
|
|
107
|
+
try { APP.onImmersive((s) => answered(s)) } catch { /* no answers: nothing is ever granted */ }
|
|
108
|
+
}
|
|
109
|
+
shown = { granted, tight: tight() }
|
|
110
|
+
sync()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Told when `granted` or `tight` changes (after the inset moved). Returns the unsubscribe. */
|
|
114
|
+
export function onImmersiveChange(f: () => void): () => void {
|
|
115
|
+
startImmersive()
|
|
116
|
+
listeners.add(f)
|
|
117
|
+
return () => { listeners.delete(f) }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// dev-only inspection hook for tests (never installed in published builds)
|
|
121
|
+
if (typeof window !== 'undefined' && (import.meta as { env?: { DEV?: boolean } }).env?.DEV) {
|
|
122
|
+
(window as unknown as { __mvImmersive: unknown }).__mvImmersive = { wants, tight, granted: isGranted }
|
|
123
|
+
}
|
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
* FROZEN before the A3 streams split (A3.8 #53): `TOP`, `VISIBLE_TOP`, `usable()`, `onScreen()` and `applyInset()`.
|
|
11
11
|
* Consumers: the top-anchored layers, the selection bar, tips and menus (`TOP + 8`), insets(), focus, play sizes
|
|
12
12
|
* and Jam's fill use `usable()`; seen marks, visibleNodes(), A3.3's probes and A4.3's full-view test use `onScreen()`.
|
|
13
|
+
*
|
|
14
|
+
* Amended in writing for spec 32 (C3, F3; Nic, gaps.md 3, 29): `TOP`, `VISIBLE_TOP`, `onScreen()` and `applyInset()`
|
|
15
|
+
* keep their contract, and so does `--mv-top`. Only `usable()` is dynamic, and only in immersive play: once main grants
|
|
16
|
+
* it, `setImmersiveTop(true)` drops the play inset to 0, which `usable()`, `onTopChange` listeners and `--mv-play-top`
|
|
17
|
+
* (read by `.sh-play` alone) follow; every other `var(--mv-top)` consumer keeps 44. Until immersive play is wired
|
|
18
|
+
* (spec 32 W4) nothing calls it, so `usable()` answers `TOP` as before.
|
|
13
19
|
*/
|
|
14
20
|
import { EDGE_FADE, TOP_INSET, type Inset } from '../../shared/app-api.ts'
|
|
15
21
|
import { APP } from './marver-app.ts'
|
|
@@ -23,12 +29,32 @@ export const VISIBLE_TOP = TOP ? TOP + EDGE_FADE : 0
|
|
|
23
29
|
export function applyInset(): void {
|
|
24
30
|
if (!TOP) return
|
|
25
31
|
document.documentElement.style.setProperty('--mv-top', `${TOP}px`)
|
|
32
|
+
// spec 32 C3: the play inset, `TOP` until immersive play drops it (`setImmersiveTop`)
|
|
33
|
+
document.documentElement.style.setProperty('--mv-play-top', `${TOP}px`)
|
|
26
34
|
document.documentElement.classList.add('mv-inset')
|
|
27
35
|
}
|
|
28
36
|
|
|
29
|
-
/**
|
|
37
|
+
/** spec 32 C3: the play inset now - `TOP`, or 0 while main has granted immersive play. */
|
|
38
|
+
let topNow: Inset = TOP
|
|
39
|
+
const topListeners = new Set<() => void>()
|
|
40
|
+
/**
|
|
41
|
+
* spec 32 C3: immersive play (granted by main) drops the play inset to 0; only `usable()` and `--mv-play-top` follow it.
|
|
42
|
+
* A no-op without the inset (`TOP` 0: Chrome, a published canvas, app 0.1): both values are then 0.
|
|
43
|
+
*/
|
|
44
|
+
export function setImmersiveTop(on: boolean): void {
|
|
45
|
+
const next: Inset = on ? 0 : TOP
|
|
46
|
+
if (next === topNow) return
|
|
47
|
+
topNow = next
|
|
48
|
+
document.documentElement.style.setProperty('--mv-play-top', `${next}px`)
|
|
49
|
+
document.documentElement.classList.toggle('mv-immersive', on)
|
|
50
|
+
for (const f of [...topListeners]) { try { f() } catch (err) { console.error(err) } }
|
|
51
|
+
}
|
|
52
|
+
/** spec 32 C3: told when `setImmersiveTop` changes the play inset; answers what unsubscribes. */
|
|
53
|
+
export const onTopChange = (f: () => void): (() => void) => { topListeners.add(f); return () => { topListeners.delete(f) } }
|
|
54
|
+
|
|
55
|
+
/** The view below the strip, in client px: below `TOP`, or the whole view while immersive (spec 32 C3). */
|
|
30
56
|
export function usable(): { top: number; left: number; width: number; height: number } {
|
|
31
|
-
return { top:
|
|
57
|
+
return { top: topNow, left: 0, width: innerWidth, height: Math.max(0, innerHeight - topNow) }
|
|
32
58
|
}
|
|
33
59
|
|
|
34
60
|
/** The part of a client rect on screen below the scroll edge, or null when none is. */
|
|
@@ -41,4 +67,4 @@ export function onScreen(r: DOMRectReadOnly): DOMRect | null {
|
|
|
41
67
|
}
|
|
42
68
|
|
|
43
69
|
// dev-only inspection hook for tests (never installed in published builds)
|
|
44
|
-
if (typeof window !== 'undefined' && (import.meta as { env?: { DEV?: boolean } }).env?.DEV) (window as unknown as { __mvInset: unknown }).__mvInset = { TOP, VISIBLE_TOP, usable, onScreen }
|
|
70
|
+
if (typeof window !== 'undefined' && (import.meta as { env?: { DEV?: boolean } }).env?.DEV) (window as unknown as { __mvInset: unknown }).__mvInset = { TOP, VISIBLE_TOP, usable, onScreen, setImmersiveTop, onTopChange }
|
|
@@ -106,7 +106,9 @@ export const laneTip = (c: LaneCard, name: (agent: string) => string | undefined
|
|
|
106
106
|
|
|
107
107
|
/** One line of a capture's detail: its time in the capture, the kind of step, the words, the element's
|
|
108
108
|
* source (file:line) and point number when it has them. */
|
|
109
|
-
export interface TimelineLine { t: string; kind: string; text: string; source?: string; point?: number
|
|
109
|
+
export interface TimelineLine { t: string; kind: string; text: string; source?: string; point?: number
|
|
110
|
+
/** a device or view step's viewport name, as configured - the panel shows its label and icon (spec 31 F.3) */
|
|
111
|
+
device?: string }
|
|
110
112
|
|
|
111
113
|
/** `<span> "Save 20%"` - an element as a line names it; a secret stays "•••". */
|
|
112
114
|
const el = (b: Bundle): string =>
|
|
@@ -145,10 +147,10 @@ export function timelineLines(r: CaptureRecord, edited?: string): TimelineLine[]
|
|
|
145
147
|
const v = s.view
|
|
146
148
|
const where = v.board ? (v.frames?.length ? `${v.board} / ${v.frames.map(frameName).join(', ')}` : v.board) : v.frames?.map(frameName).join(', ')
|
|
147
149
|
const size = v.viewport ? `${v.viewport}${v.width ? ` ${v.width}×${v.height}` : ''}` : ''
|
|
148
|
-
out.push({ t, kind: 'view', text: [where, size, v.theme].filter(Boolean).join(' · ') || 'the canvas' }); break
|
|
150
|
+
out.push({ t, kind: 'view', text: [where, size, v.theme].filter(Boolean).join(' · ') || 'the canvas', ...(v.viewport ? { device: v.viewport } : {}) }); break
|
|
149
151
|
}
|
|
150
152
|
case 'select': out.push({ t, kind: 'select', text: s.frames.map(frameName).join(', ') || 'nothing' }); break
|
|
151
|
-
case 'device': out.push({ t, kind: 'device', text: `${frameName(s.frame)} · ${s.viewport}${s.width ? ` ${s.width}` : ''}
|
|
153
|
+
case 'device': out.push({ t, kind: 'device', text: `${frameName(s.frame)} · ${s.viewport}${s.width ? ` ${s.width}` : ''}`, device: s.viewport }); break
|
|
152
154
|
case 'theme': out.push({ t, kind: 'theme', text: s.theme }); break
|
|
153
155
|
case 'copied': out.push({ t, kind: 'copied', text: `${s.what} of ${frameName(s.frame)}` }); break
|
|
154
156
|
case 'interact': out.push({ t, kind: 'interact', text: s.on ? 'on' : 'off' }); break
|
|
@@ -14,9 +14,10 @@ import { speechLines } from '../../shared/speech.ts'
|
|
|
14
14
|
import {
|
|
15
15
|
ArrowBendUpLeftIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon, CopyIcon, CursorClickIcon, CursorIcon, EyeIcon, FileCodeIcon,
|
|
16
16
|
FrameRectIcon, ImagesSquareIcon, LaserIcon, MicrophoneIcon, MoonIcon, PencilSimpleIcon, SignpostIcon, SunIcon, TextboxIcon,
|
|
17
|
-
ParallelogramFillIcon, WarningIcon, WaveformIcon, XIcon,
|
|
17
|
+
ParallelogramFillIcon, WarningIcon, WaveformIcon, XIcon,
|
|
18
18
|
} from './icons.tsx'
|
|
19
19
|
import { LANE_H } from './jam-lane.tsx'
|
|
20
|
+
import { deviceIcon, deviceLabel } from './devices.tsx'
|
|
20
21
|
import { Tip } from './Tip.tsx'
|
|
21
22
|
import { useJamQueue } from './jam-queue.ts'
|
|
22
23
|
import { holdsReload } from './api.ts'
|
|
@@ -70,7 +71,6 @@ holdsReload(() => moreDrafts.size > 0)
|
|
|
70
71
|
unsavedWhen('typing', () => moreDrafts.size > 0)
|
|
71
72
|
|
|
72
73
|
const unquote = (s: string) => s.replace(/^"(.*)"$/s, '$1')
|
|
73
|
-
const DEVICE: Record<string, string> = { phone: 'mobile', mobile: 'mobile', tablet: 'tablet', laptop: 'laptop', desktop: 'monitor', monitor: 'monitor', tv: 'tv' }
|
|
74
74
|
|
|
75
75
|
/** One line: time | glyph | what happened (the read-back's merged timeline, jam-lines.ts). */
|
|
76
76
|
function LineRow({ l }: { l: TimelineLine }) {
|
|
@@ -80,7 +80,16 @@ function LineRow({ l }: { l: TimelineLine }) {
|
|
|
80
80
|
switch (l.kind) {
|
|
81
81
|
case 'words': glyph = <MicrophoneIcon size={13} />; body = <span className="words">“{unquote(l.text)}”</span>; break
|
|
82
82
|
case 'note': glyph = <PencilSimpleIcon size={13} />; body = <span className="words">{unquote(l.text)}</span>; break
|
|
83
|
-
case 'view':
|
|
83
|
+
case 'view': {
|
|
84
|
+
glyph = <EyeIcon size={13} />
|
|
85
|
+
// the viewport part says the device as it reads, with its icon: "iPad landscape 1180×820" (spec 31 F.3)
|
|
86
|
+
const dev = l.device
|
|
87
|
+
if (dev) body = <>{l.text.split(' · ').map((seg, i) => {
|
|
88
|
+
const own = seg === dev || seg.startsWith(`${dev} `)
|
|
89
|
+
return <span key={i}>{i ? ' · ' : ''}{own ? <span className="jm-dev">{deviceIcon(dev, 12)}{deviceLabel(dev)}{seg.slice(dev.length)}</span> : seg}</span>
|
|
90
|
+
})}</>
|
|
91
|
+
break
|
|
92
|
+
}
|
|
84
93
|
case 'pick': glyph = <LaserIcon size={13} />; body = <>{l.point != null && <span className="pt pick">{l.point}</span>}{l.text}{code}</>; break
|
|
85
94
|
case 'click': glyph = <CursorClickIcon size={13} />; body = <>{l.point != null && <span className="pt click">{l.point}</span>}{l.text}{code}</>; break
|
|
86
95
|
case 'hover': glyph = <CursorIcon size={13} />; body = <>{l.text}{code}</>; break
|
|
@@ -89,8 +98,11 @@ function LineRow({ l }: { l: TimelineLine }) {
|
|
|
89
98
|
case 'scroll': glyph = <ArrowUpIcon size={13} style={{ transform: 'rotate(180deg)' }} />; break
|
|
90
99
|
case 'select': glyph = <FrameRectIcon size={13} />; body = <>selected {ui(l.text)}</>; break
|
|
91
100
|
case 'device': {
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
// the viewport as configured: its own label and icon (spec 31 F.3) - "viewed at iPad landscape 1180"
|
|
102
|
+
const name = l.device ?? (l.text.split(' · ')[1] ?? '').split(' ')[0]
|
|
103
|
+
const width = /\s(\d+)$/.exec(l.text)?.[1]
|
|
104
|
+
glyph = name ? deviceIcon(name, 13) : deviceIcon(null, 13)
|
|
105
|
+
body = <>viewed at {ui(name ? `${deviceLabel(name)}${width ? ` ${width}` : ''}` : l.text)}</>; break
|
|
94
106
|
}
|
|
95
107
|
case 'theme': glyph = l.text === 'dark' ? <MoonIcon size={13} /> : <SunIcon size={13} />; body = <>switched to {ui(l.text)}</>; break
|
|
96
108
|
case 'copied': {
|
|
@@ -10,6 +10,7 @@ import { useStore, PUBLISHED, shownRev } from './store.ts'
|
|
|
10
10
|
import { useComments } from './comments-store.ts'
|
|
11
11
|
import { frameMark, isNew, questions, type Ask, type FrameMark } from '../../shared/marks.ts'
|
|
12
12
|
import { cmd, endOnAnswer, type CmdOpts } from './commands.ts'
|
|
13
|
+
import { api } from './api.ts'
|
|
13
14
|
|
|
14
15
|
/** Mark all as seen (spec 30): `mark-seen` ends on the marks write's answer - the sidebar's, or the relay from the
|
|
15
16
|
* tab's menu (#51). Nothing new to clear is a noop: no write goes. */
|
|
@@ -21,6 +22,59 @@ export function markSeenFrom(how: CmdOpts, frames: string[]): void {
|
|
|
21
22
|
s.markSeen(frames)
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
/** A resolve-all scope (spec 31 B.1): what you see - a board, a folder, a scene, or the whole canvas (the app's tab). */
|
|
26
|
+
export type ResolveScope = { board: string } | { folder: string } | { scene: string } | { canvas: true }
|
|
27
|
+
|
|
28
|
+
/** One POST to the dev server's comment actions, tried once more with the same op on no answer (a retry returns the
|
|
29
|
+
* same receipt). */
|
|
30
|
+
async function commentAction(path: 'resolve-all' | 'undo', body: Record<string, unknown>): Promise<{ ok: boolean; status: number; data: any }> {
|
|
31
|
+
const csrf = /(?:^|;\s*)mv_c=([\w-]+)/.exec(document.cookie)?.[1] ?? ''
|
|
32
|
+
const once = async () => {
|
|
33
|
+
const r = await api(`comment-actions/${path}`, { method: 'POST', headers: { 'content-type': 'application/json', 'x-mv-c': csrf }, body: JSON.stringify(body) })
|
|
34
|
+
return { ok: r.ok || r.status === 207, status: r.status, data: await r.json().catch(() => ({})) }
|
|
35
|
+
}
|
|
36
|
+
try { return await once() } catch { return await once() }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Resolve all comments (spec 31 B.1-B.3): every open thread in `scope` but what Jam is at work on, then a notice
|
|
40
|
+
* that says how many, with Undo - which reopens what is unchanged since, and says Jam's finished items stay finished. */
|
|
41
|
+
export async function resolveAllFrom(how: CmdOpts, scope: ResolveScope): Promise<void> {
|
|
42
|
+
const h = cmd('resolve-all', how)
|
|
43
|
+
const s = useStore.getState()
|
|
44
|
+
if (PUBLISHED) { h.noop('published'); return }
|
|
45
|
+
// the server reads which frames a board shows from its saved file (release review): the open board's edits waiting for
|
|
46
|
+
// their autosave go first, and while they are not saved nothing is resolved - a frame just taken off it would still
|
|
47
|
+
// count (as the PDF export's check). The canvas scope reads no board, so it never waits
|
|
48
|
+
const st = () => useStore.getState()
|
|
49
|
+
const reads = 'board' in scope ? st().board === scope.board : !('canvas' in scope)
|
|
50
|
+
if (reads) for (let i = 0; i < 5 && st().dirty; i++) if (!(await st().save())) break
|
|
51
|
+
if (reads && st().dirty) { h.fail('api'); s.toast('this board\'s latest changes are not saved yet - nothing was resolved; try again in a moment'); return }
|
|
52
|
+
const op = crypto.randomUUID()
|
|
53
|
+
let r: Awaited<ReturnType<typeof commentAction>>
|
|
54
|
+
try { r = await commentAction('resolve-all', { op, scope }) } catch { h.fail('api'); s.toast('could not reach the dev server'); return }
|
|
55
|
+
if (!r.ok) { h.fail('api'); s.toast(String(r.data?.error ?? `resolve-all failed (${r.status})`)); return }
|
|
56
|
+
// the notice says it at once; the threads follow with one sweep of the logs (seconds on a canvas with many boards)
|
|
57
|
+
void useComments.getState().sweep()
|
|
58
|
+
const n = Array.isArray(r.data?.resolved) ? r.data.resolved.length : 0
|
|
59
|
+
if (!n && !r.data?.failed?.length) { h.noop('nothing-open'); s.toast(String(r.data?.summary ?? 'Nothing to resolve')); return }
|
|
60
|
+
if (r.data?.failed?.length) h.fail('api'); else h.done()
|
|
61
|
+
const summary = String(r.data?.summary ?? `Resolved ${n}`)
|
|
62
|
+
if (!n) { s.toast(summary, undefined, 8000); return }
|
|
63
|
+
s.toast(summary, { label: 'Undo', id: 'resolve-undo', run: () => { void undoResolveAll(op) } }, 10_000)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The notice's Undo (spec 31 B.3): records `resolve-undo` itself - the notice's button only runs it. */
|
|
67
|
+
async function undoResolveAll(op: string): Promise<void> {
|
|
68
|
+
const h = cmd('resolve-undo', { via: 'click', in: 'shell' })
|
|
69
|
+
const s = useStore.getState()
|
|
70
|
+
let r: Awaited<ReturnType<typeof commentAction>>
|
|
71
|
+
try { r = await commentAction('undo', { op }) } catch { h.fail('api'); s.toast('could not reach the dev server'); return }
|
|
72
|
+
if (!r.ok) { h.fail('api'); s.toast(String(r.data?.error ?? `undo failed (${r.status})`)); return }
|
|
73
|
+
void useComments.getState().sweep()
|
|
74
|
+
if (r.data?.failed?.length) h.fail('api'); else h.done()
|
|
75
|
+
s.toast(String(r.data?.summary ?? 'Reopened'), undefined, 6000)
|
|
76
|
+
}
|
|
77
|
+
|
|
24
78
|
/** Every frame's mark, derived ONCE per change of marks, threads or manifest. Rows and headers read
|
|
25
79
|
* one string each, so a change re-renders only what it changes - never the whole shell. */
|
|
26
80
|
interface View { q: Map<string, Ask>; frame: Record<string, string>; fresh: Record<string, true> }
|
|
@@ -104,6 +104,27 @@ export function notesCramped(
|
|
|
104
104
|
})
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
/** What tidy sees of a board's nodes (spec 18): each with its scene, variant run, header-inclusive height, the note
|
|
108
|
+
* width to reserve in front (the frame's note, and the scene's on every member - tidy keeps the scene reserve on the
|
|
109
|
+
* first node it places) and its column's measured height. One rule for the canvas (store.ts tidyInput) and the deck
|
|
110
|
+
* PDF's plan (pdf.ts), which lays a board out as the canvas does when it opens it. */
|
|
111
|
+
export function tidyNodes(
|
|
112
|
+
nodes: readonly { key: string; frame: string; w: number; h: number }[],
|
|
113
|
+
manifest: { frames: { id: string; scene: string; note?: string; variantGroup?: string; variant?: string }[]; scenes: { name: string; note?: string }[] } | null,
|
|
114
|
+
noteH: (key: string) => number = noteHeight,
|
|
115
|
+
): { key: string; frame: string; scene: string; group?: string; variant?: string; w: number; h: number; noteW: number; sceneNoteW: number; noteH: number }[] {
|
|
116
|
+
const entryOf = (id: string) => manifest?.frames.find((f) => f.id === id)
|
|
117
|
+
const sceneNote = (scene: string) => !!manifest?.scenes.find((s) => s.name === scene)?.note
|
|
118
|
+
return nodes.map((n) => {
|
|
119
|
+
const f = entryOf(n.frame)
|
|
120
|
+
const scene = f?.scene ?? ''
|
|
121
|
+
return {
|
|
122
|
+
key: n.key, frame: n.frame, scene, group: f?.variantGroup, variant: f?.variant, w: n.w, h: n.h + NODE_HEADER,
|
|
123
|
+
noteW: noteReserve(!!f?.note, false), sceneNoteW: noteReserve(false, sceneNote(scene)), noteH: noteH(n.key),
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
107
128
|
// ---- per-viewer visibility -------------------------------------------------------------
|
|
108
129
|
|
|
109
130
|
/** The viewer's choice is kept per canvas (spec 28 A1.6): the shell names the key at boot (store.ts),
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export PDF in the shell (spec 31 Part A): the board menu, slides and present mode's bar, and the app's File menu all
|
|
3
|
+
* come here. The dev server makes the PDF (`/__mv/api/pdf`, one job per canvas); a notice shows its progress; when it
|
|
4
|
+
* is done a browser downloads the file, and the Mac app - sent only the job id - fetches it itself and saves it where
|
|
5
|
+
* its save panel says. An app with no exportPdf (1.0.1) cancels a download its window did not start while focused, so
|
|
6
|
+
* there the notice holds the finished file and offers Download.
|
|
7
|
+
*/
|
|
8
|
+
import { create } from 'zustand'
|
|
9
|
+
import { api } from './api.ts'
|
|
10
|
+
import { APP } from './marver-app.ts'
|
|
11
|
+
import { boardLabel, PUBLISHED, useStore } from './store.ts'
|
|
12
|
+
import { cmd, type CmdOpts } from './commands.ts'
|
|
13
|
+
import { ExportIcon, XIcon } from './icons.tsx'
|
|
14
|
+
import { pdfFinish, reportNotes, type PdfReportLite } from './pdf-notes.ts'
|
|
15
|
+
|
|
16
|
+
const csrf = () => /(?:^|;\s*)mv_c=([\w-]+)/.exec(document.cookie)?.[1] ?? ''
|
|
17
|
+
|
|
18
|
+
interface PdfState {
|
|
19
|
+
job: string | null
|
|
20
|
+
board: string
|
|
21
|
+
page: number
|
|
22
|
+
pages: number
|
|
23
|
+
phase: string
|
|
24
|
+
/** `saving`: the app's save panel is open; `ready`: the file is fetched and waits for the notice's Download */
|
|
25
|
+
state: 'idle' | 'running' | 'saving' | 'ready'
|
|
26
|
+
/** `ready`: the file's name and what its report says needs a look */
|
|
27
|
+
filename: string
|
|
28
|
+
notes: string
|
|
29
|
+
}
|
|
30
|
+
const IDLE = { job: null, page: 0, pages: 0, phase: '', state: 'idle', filename: '', notes: '' } as const
|
|
31
|
+
export const usePdfExport = create<PdfState>(() => ({ ...IDLE, board: '' }))
|
|
32
|
+
/** `ready`: the fetched file's object URL, freed when it is downloaded or dismissed */
|
|
33
|
+
let readyUrl = ''
|
|
34
|
+
const clear = () => { if (readyUrl) { const u = readyUrl; readyUrl = ''; setTimeout(() => URL.revokeObjectURL(u), 60_000) } usePdfExport.setState(IDLE) }
|
|
35
|
+
|
|
36
|
+
/** Can the shell export here? A dev canvas only (a published one has no browser to print with). */
|
|
37
|
+
export const canExportPdf = (): boolean => !PUBLISHED
|
|
38
|
+
|
|
39
|
+
const toast = (t: string) => useStore.getState().toast(t)
|
|
40
|
+
const wait = (ms: number) => new Promise((r) => setTimeout(r, ms))
|
|
41
|
+
|
|
42
|
+
/** Start a PDF of `board` and see it through: progress in the notice, then the file downloaded (or, in the app, saved
|
|
43
|
+
* through its panel). `theme`: what the stage shows, when asked from slides or present mode. */
|
|
44
|
+
export async function exportPdf(board: string, o: { theme?: string }, how: CmdOpts): Promise<void> {
|
|
45
|
+
const h = cmd('export-pdf', { ...how, board })
|
|
46
|
+
if (!canExportPdf()) { h.noop('busy'); return }
|
|
47
|
+
const now = usePdfExport.getState().state
|
|
48
|
+
if (now !== 'idle') { h.noop('busy'); toast(now === 'ready' ? 'a PDF is waiting - download or dismiss it first' : 'a PDF is already being made'); return }
|
|
49
|
+
// the server prints the board file: this board's edits waiting for their autosave go first
|
|
50
|
+
const s = () => useStore.getState()
|
|
51
|
+
if (s().board === board) for (let i = 0; i < 5 && s().dirty; i++) if (!(await s().save())) break
|
|
52
|
+
if (s().board === board && s().dirty) { h.fail('api'); toast('this board\'s latest changes are not saved yet - try again in a moment'); return }
|
|
53
|
+
let job: string
|
|
54
|
+
try {
|
|
55
|
+
const r = await api('pdf', { method: 'POST', headers: { 'content-type': 'application/json', 'x-mv-c': csrf() }, body: JSON.stringify({ board, ...(o.theme ? { theme: o.theme } : {}) }) })
|
|
56
|
+
const b = await r.json().catch(() => ({})) as { job?: string; error?: string; pages?: number }
|
|
57
|
+
if (!r.ok || !b.job) { h.fail('api'); toast(b.error ?? `the PDF could not start (${r.status})`); return }
|
|
58
|
+
job = b.job
|
|
59
|
+
usePdfExport.setState({ job, board, page: 0, pages: b.pages ?? 0, phase: 'starting', state: 'running' })
|
|
60
|
+
h.done()
|
|
61
|
+
} catch { h.fail('api'); toast('could not reach the dev server'); return }
|
|
62
|
+
// this export is still the one the notice shows: a Cancel (here or a newer export) ends it after any await
|
|
63
|
+
const alive = () => usePdfExport.getState().job === job
|
|
64
|
+
let keep = false
|
|
65
|
+
try {
|
|
66
|
+
let st: { state?: string; page?: number; pages?: number; phase?: string; error?: string; filename?: string; report?: PdfReportLite } = {}
|
|
67
|
+
for (;;) {
|
|
68
|
+
await wait(500)
|
|
69
|
+
if (!alive()) return
|
|
70
|
+
const r = await api(`pdf/${job}`, { headers: { 'x-mv-c': csrf() } })
|
|
71
|
+
st = await r.json().catch(() => ({}))
|
|
72
|
+
if (!alive()) return
|
|
73
|
+
if (!r.ok) { toast(st.error ?? 'the PDF job was lost'); return }
|
|
74
|
+
usePdfExport.setState({ page: st.page ?? 0, pages: st.pages ?? 0, phase: st.phase ?? '' })
|
|
75
|
+
if (st.state !== 'running') break
|
|
76
|
+
}
|
|
77
|
+
if (st.state === 'cancelled') return
|
|
78
|
+
if (st.state !== 'done') { toast(`the PDF failed${st.error ? ` - ${st.error}` : ''}`); return }
|
|
79
|
+
const name = st.filename ?? `${board}.pdf`
|
|
80
|
+
// what the report says needs a look rides on the notice that says it is done
|
|
81
|
+
const notes = reportNotes(st.report)
|
|
82
|
+
const finish = pdfFinish(APP)
|
|
83
|
+
if (finish === 'app' && APP?.exportPdf) {
|
|
84
|
+
// the app fetches the file itself from this canvas and saves it where its panel says: only the id crosses
|
|
85
|
+
if (!alive()) return
|
|
86
|
+
usePdfExport.setState({ state: 'saving' })
|
|
87
|
+
const a = await APP.exportPdf({ job })
|
|
88
|
+
if (a.ok) toast(`${name} saved${notes}`)
|
|
89
|
+
else if (a.why !== 'cancelled') toast(`the PDF was not saved (${a.why})`)
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
const f = await api(`pdf/${job}/file`, { headers: { 'x-mv-c': csrf() } })
|
|
93
|
+
if (!alive()) return
|
|
94
|
+
if (!f.ok) { toast(`could not fetch the PDF (${f.status})`); return }
|
|
95
|
+
const blob = await f.blob()
|
|
96
|
+
if (!alive()) return
|
|
97
|
+
const url = URL.createObjectURL(blob)
|
|
98
|
+
if (finish === 'offer') {
|
|
99
|
+
// the person may be in another app by now: the download waits for their click, in a focused window
|
|
100
|
+
readyUrl = url; keep = true
|
|
101
|
+
usePdfExport.setState({ state: 'ready', filename: name, notes })
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
save(url, name)
|
|
105
|
+
setTimeout(() => URL.revokeObjectURL(url), 60_000)
|
|
106
|
+
toast(`${name} downloaded${notes}`)
|
|
107
|
+
} catch { toast('the PDF was interrupted - is the dev server still running?') }
|
|
108
|
+
finally { if (alive() && !keep) clear() }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function save(url: string, name: string) {
|
|
112
|
+
const a = document.createElement('a')
|
|
113
|
+
a.href = url; a.download = name; a.rel = 'noopener'
|
|
114
|
+
document.body.appendChild(a); a.click(); a.remove()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The notice's Download (an app with no exportPdf): the held file, downloaded from the click that asks for it. */
|
|
118
|
+
export function downloadPdf(how: CmdOpts): void {
|
|
119
|
+
const { state, board, filename, notes } = usePdfExport.getState()
|
|
120
|
+
const h = cmd('export-pdf-download', { ...how, ...(board ? { board } : {}) })
|
|
121
|
+
if (state !== 'ready' || !readyUrl) { h.noop('nothing-ready'); return }
|
|
122
|
+
save(readyUrl, filename)
|
|
123
|
+
h.done()
|
|
124
|
+
toast(`${filename} downloaded${notes}`)
|
|
125
|
+
clear()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Cancel the PDF being made (the server closes its browser; nothing of it stays). */
|
|
129
|
+
export async function cancelPdf(how: CmdOpts): Promise<void> {
|
|
130
|
+
const { job, board, state } = usePdfExport.getState()
|
|
131
|
+
const h = cmd('export-pdf-cancel', { ...how, ...(board ? { board } : {}) })
|
|
132
|
+
if (!job) { h.done(); return }
|
|
133
|
+
clear()
|
|
134
|
+
try {
|
|
135
|
+
const r = await api(`pdf/${job}`, { method: 'DELETE', headers: { 'x-mv-c': csrf() } })
|
|
136
|
+
if (r.ok) { h.done(); toast(state === 'ready' ? 'PDF dismissed' : 'PDF cancelled') } else h.fail('api')
|
|
137
|
+
} catch { h.fail('api') }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The notice while a PDF is made: its board, its page, and Cancel - or, once one waits (`ready`), Download and dismiss. */
|
|
141
|
+
export function PdfNotice() {
|
|
142
|
+
const s = usePdfExport()
|
|
143
|
+
if (s.state === 'idle') return null
|
|
144
|
+
const what = s.state === 'ready' ? 'Ready' : s.state === 'saving' ? 'Saving' : s.phase === 'merging' ? 'Finishing' : s.phase === 'handout' ? 'Printing the handout' : s.pages ? `Page ${Math.min(s.page + 1, s.pages)} of ${s.pages}` : 'Starting'
|
|
145
|
+
return (
|
|
146
|
+
<div className="sh-toast sh-pdf-notice" role="status" aria-live="polite">
|
|
147
|
+
<ExportIcon size={13} />
|
|
148
|
+
<span><b>{boardLabel(s.board)}</b> PDF · {what}</span>
|
|
149
|
+
{s.pages > 0 && s.state === 'running' && <span className="bar"><i style={{ width: `${Math.round((s.page / s.pages) * 100)}%` }} /></span>}
|
|
150
|
+
{s.state === 'ready' && <button className="go" onClick={() => downloadPdf({ via: 'click', in: 'shell' })}>Download</button>}
|
|
151
|
+
{(s.state === 'running' || s.state === 'ready') && <button aria-label={s.state === 'ready' ? 'Dismiss the PDF' : 'Cancel the PDF'} onClick={() => void cancelPdf({ via: 'click', in: 'shell' })}><XIcon size={11} /></button>}
|
|
152
|
+
</div>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A deck PDF's report as the shell's notice says it (spec 31): pure, so the suite reads it without the shell. */
|
|
2
|
+
export interface PdfReportLite { skipped?: unknown[]; slides?: { status?: string; clipped?: boolean; unsettled?: boolean; spilled?: boolean; changed?: boolean; printDiffers?: boolean }[] }
|
|
3
|
+
/** The report's warnings in a few words ("· 2 pictures, 1 clipped"), or nothing - `marver pdf` prints them in full. */
|
|
4
|
+
export function reportNotes(r: PdfReportLite | undefined): string {
|
|
5
|
+
if (!r?.slides) return ''
|
|
6
|
+
const n = (pred: (s: NonNullable<PdfReportLite['slides']>[number]) => boolean) => r.slides!.filter(pred).length
|
|
7
|
+
const parts = [
|
|
8
|
+
[r.skipped?.length ?? 0, 'skipped'], [n((s) => s.status === 'failed'), 'failed'], [n((s) => s.status === 'raster'), 'as pictures'],
|
|
9
|
+
[n((s) => !!s.unsettled), 'unsettled'], [n((s) => !!s.clipped), 'clipped'], [n((s) => !!s.spilled), 'spilled'],
|
|
10
|
+
[n((s) => !!s.changed), 'changed while printing'], [n((s) => !!s.printDiffers), 'printed differently'],
|
|
11
|
+
].filter(([c]) => (c as number) > 0).map(([c, w]) => `${c} ${w}`)
|
|
12
|
+
return parts.length ? ` · ${parts.join(', ')} (npx marver pdf says which)` : ''
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** How a finished PDF reaches the person: `app` - the Mac app (1.1+) saves it through its panel; `download` - a browser
|
|
16
|
+
* downloads it at once; `offer` - an app without exportPdf (1.0.1) cancels a download its window did not start while
|
|
17
|
+
* focused, so the notice keeps the job and offers Download, a click that starts it in a focused window. */
|
|
18
|
+
export function pdfFinish(app: { exportPdf?: unknown } | null): 'app' | 'download' | 'offer' {
|
|
19
|
+
return !app ? 'download' : typeof app.exportPdf === 'function' ? 'app' : 'offer'
|
|
20
|
+
}
|
|
@@ -27,6 +27,7 @@ import { hooked, perfSeams, type Answered } from './recorder-seams.ts'
|
|
|
27
27
|
import { addRow, createRate, foldRows, nodesIn, normRoute, p50, topWarnings } from './recorder-signals-core.ts'
|
|
28
28
|
import { useStore } from './store.ts'
|
|
29
29
|
import { isHideUI, onHideUI } from './Toolbar.tsx'
|
|
30
|
+
import { isGranted, onImmersiveChange } from './immersive.ts'
|
|
30
31
|
|
|
31
32
|
type State = ReturnType<typeof useStore.getState>
|
|
32
33
|
|
|
@@ -158,7 +159,7 @@ type Shown = 'cohort' | 'first-frame' | 'two-frames'
|
|
|
158
159
|
const SHOWN: Record<ModeName, Shown> = {
|
|
159
160
|
laser: 'cohort', inspect: 'cohort', comments: 'cohort',
|
|
160
161
|
play: 'first-frame', slides: 'first-frame',
|
|
161
|
-
interact: 'two-frames', 'hide-ui': 'two-frames', 'jam-session': 'two-frames', 'jam-capture': 'two-frames', 'jam-review': 'two-frames', 'jam-lane': 'two-frames',
|
|
162
|
+
interact: 'two-frames', 'hide-ui': 'two-frames', immersive: 'two-frames', 'jam-session': 'two-frames', 'jam-capture': 'two-frames', 'jam-review': 'two-frames', 'jam-lane': 'two-frames',
|
|
162
163
|
}
|
|
163
164
|
/** The first frame of a stage is a cold boot: the command's own deadline (`play`, `slides`: 30 s), not a toggle's 5 s - a
|
|
164
165
|
* slow first frame is the answer that record exists for. */
|
|
@@ -455,7 +456,7 @@ export function startSignals(): void {
|
|
|
455
456
|
|
|
456
457
|
// what is on already counts from here, with no enter record of its own
|
|
457
458
|
const s0 = useStore.getState()
|
|
458
|
-
const held = { ...canvasModes(s0), comments: useComments.getState().commentMode, 'hide-ui': isHideUI(), 'jam-session': !!useJamQueue.getState().session, 'jam-capture': !!useJamCapture.getState().current, ...reviewModes() }
|
|
459
|
+
const held = { ...canvasModes(s0), comments: useComments.getState().commentMode, 'hide-ui': isHideUI(), immersive: isGranted(), 'jam-session': !!useJamQueue.getState().session, 'jam-capture': !!useJamCapture.getState().current, ...reviewModes() }
|
|
459
460
|
for (const k of Object.keys(held) as ModeName[]) if (held[k]) modes.set(k, { since: now(), errors: 0 })
|
|
460
461
|
|
|
461
462
|
// #21, #26: the `t` a message to a document carries
|
|
@@ -471,6 +472,8 @@ export function startSignals(): void {
|
|
|
471
472
|
useJamCapture.subscribe(hooked('mode', (s: { current: string | null }, p: { current: string | null }) => { if (s.current !== p.current) setModes({ 'jam-capture': !!s.current }) }))
|
|
472
473
|
useJamUi.subscribe(hooked('mode', () => setModes(reviewModes())))
|
|
473
474
|
onHideUI(hooked('mode', () => setModes({ 'hide-ui': isHideUI() })))
|
|
475
|
+
// spec 32 C11: immersive play, held while main's grant stands (immersive.ts `granted`)
|
|
476
|
+
onImmersiveChange(hooked('mode', () => setModes({ immersive: isGranted() })))
|
|
474
477
|
|
|
475
478
|
perfSeams.frameMessage.on(hooked(null, onFrameMessage))
|
|
476
479
|
perfSeams.stageMessage.on(hooked(null, onStageMessage))
|