@marver-design/marver 0.30.1 → 0.31.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 +58 -0
- package/README.md +11 -7
- package/dist/{anchor-check-Bv4o-R2T.mjs → anchor-check-B92s9tVv.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-OlAhZ87x.mjs} +7 -7
- package/dist/{build-zWGXSzly.mjs → build-BNssmbqd.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-BakJQwaf.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-MxoEQajX.mjs} +222 -23
- package/dist/deep-link-DYtuT740.mjs +163 -0
- package/dist/{dev-DOgIITpT.mjs → dev-BBZe_brH.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-Cmt9Xy4X.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-0m721FFn.mjs +117 -0
- package/dist/pdf-CZENT6t3.mjs +2299 -0
- package/dist/{perf-BCxAo0IS.mjs → perf-BB0XNt1M.mjs} +1 -1
- package/dist/{perf-6MOTHxay.mjs → perf-CIMijND6.mjs} +5 -5
- package/dist/{plugin-CFWBcAba.mjs → plugin-CL8_wL7a.mjs} +460 -83
- package/dist/{poster-DPPpQiva.mjs → poster-B7uSjlEP.mjs} +1 -1
- package/dist/{profile-B1FKOM1e.mjs → profile-cdmSer1k.mjs} +1 -1
- package/dist/{publish-bakes-_Zx8crP3.mjs → publish-bakes-BjgDNeyS.mjs} +3 -3
- package/dist/{queue-DeSQm24g.mjs → queue-BLLfdlDw.mjs} +156 -11
- package/dist/{recover-mDUVsnPd.mjs → recover-ByuFQOF9.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-BqwkdtKn.mjs} +4 -4
- package/dist/{shot-DBWN8hPP.mjs → shot-D2TQGo2V.mjs} +1 -1
- package/dist/show-B1u3DiJw.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-BYWD_1Zf.mjs → work-DRdzXPvg.mjs} +3 -3
- package/dist/{work-DJxH7cCX.mjs → work-Nv-n2_Un.mjs} +1 -1
- package/docs/app.md +49 -0
- package/docs/boards-and-folders.md +37 -6
- 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 +9 -0
- 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 +24 -22
- package/src/client/shell/Toolbar.tsx +4 -3
- package/src/client/shell/app-bridge.ts +32 -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/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/show.ts +250 -0
- package/src/client/shell/store.ts +23 -38
- package/src/client/shell/styles.css +43 -0
- package/src/shared/app-api.ts +49 -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/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
package/src/client/shell/goto.ts
CHANGED
|
@@ -71,6 +71,52 @@ export function navigated(): number {
|
|
|
71
71
|
if (s.board) void s.switchBoard(s.board)
|
|
72
72
|
return ++gotoSeq
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* A person acted on the canvas or its camera themselves - a frame, a badge or a comment stack clicked, ⌘A, Escape, a pan,
|
|
76
|
+
* a zoom, a fit or zoom key, the zoom menu, a notification's View (spec 31 D3): a `marver show` or an app link still on
|
|
77
|
+
* its way gives way, its board never committed over what they did (show.ts reads `handNow`). Its own counter, apart
|
|
78
|
+
* from the navigation number: nothing the person started themselves - a board switch, its fit - is cancelled by it.
|
|
79
|
+
* Programmatic selection and fits (the show's own) never call it, so a show never cancels itself.
|
|
80
|
+
*
|
|
81
|
+
* Accepted limits for this release: a click or Escape inside a frame the person is interacting with arrives as a message
|
|
82
|
+
* (`sh:frame-down`, `sh:exit-interact`) and is not counted - a show still loading then lands over it; and a frame's own
|
|
83
|
+
* script that synthesizes keys is forwarded and counted like the person's - a show still loading then does not land,
|
|
84
|
+
* and nothing else changes.
|
|
85
|
+
*/
|
|
86
|
+
let handSeq = 0
|
|
87
|
+
export function navigatedByHand(): void { ++handSeq }
|
|
88
|
+
export const handNow = (): number => handSeq
|
|
89
|
+
|
|
90
|
+
const TEXT = 'textarea, input, select, [contenteditable=""], [contenteditable="true"]'
|
|
91
|
+
const MODIFIERS = new Set(['Shift', 'Control', 'Alt', 'Meta', 'CapsLock', 'Fn'])
|
|
92
|
+
/**
|
|
93
|
+
* Every input the person makes in the shell counts (spec 31 D3) - a pointer pressed, a key, a wheel - so no handler can
|
|
94
|
+
* be missed: a device preset, a Jam tile, Play and back, a toolbar button. Not words typed into a field (they make a
|
|
95
|
+
* show the notice instead, show.ts) nor a modifier key alone; never a synthetic event (`isTrusted`). Input inside a
|
|
96
|
+
* frame's own document never reaches here: its wheel is forwarded and counted by the canvas (Canvas.tsx beginGesture),
|
|
97
|
+
* a click on its node by FrameNode, a key it forwards (`sh:key`, the stage's `sh:stage-key`) where the shell takes it;
|
|
98
|
+
* the app menu's items replay their key untrusted and count at their relay (app-bridge.ts runMenuItem). Installed once
|
|
99
|
+
* by App.tsx; answers what removes it.
|
|
100
|
+
*/
|
|
101
|
+
export function watchHands(target: Window = window): () => void {
|
|
102
|
+
const inText = (e: Event) => { const t = e.target as Element | null; return !!t?.closest?.(TEXT) }
|
|
103
|
+
const press = (e: PointerEvent) => { if (e.isTrusted && !inText(e)) navigatedByHand() }
|
|
104
|
+
// a key held down repeats: one choice, counted once (a held Enter on the show notice's Go never cancels the Go)
|
|
105
|
+
// Escape in a field is no word: it leaves the field (a composer dismissed) - the person's choice, counted (release r3)
|
|
106
|
+
const key = (e: KeyboardEvent) => { if (e.isTrusted && !e.repeat && !MODIFIERS.has(e.key) && (!inText(e) || e.key === 'Escape')) navigatedByHand() }
|
|
107
|
+
const wheel = (e: WheelEvent) => { if (e.isTrusted) navigatedByHand() }
|
|
108
|
+
target.addEventListener('pointerdown', press, true)
|
|
109
|
+
target.addEventListener('keydown', key, true)
|
|
110
|
+
target.addEventListener('wheel', wheel, { capture: true, passive: true })
|
|
111
|
+
return () => {
|
|
112
|
+
target.removeEventListener('pointerdown', press, true)
|
|
113
|
+
target.removeEventListener('keydown', key, true)
|
|
114
|
+
target.removeEventListener('wheel', wheel, { capture: true })
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** The navigation now, without starting one: a caller that waits (`marver show` for the boot) reads it first, and
|
|
118
|
+
* gives way if a person navigated meanwhile (`isLatest`). */
|
|
119
|
+
export const navNow = (): number => gotoSeq
|
|
74
120
|
/** Is this still the latest navigation - nothing newer since `navigated()` handed it out? */
|
|
75
121
|
export const isLatest = (seq: number): boolean => seq === gotoSeq
|
|
76
122
|
/** The one way a navigation changes boards - a link, a goto, a reveal, a board picked in the sidebar or the play pill, a
|
|
@@ -84,22 +130,22 @@ export async function switchFor(board: string, nav: number = navigated(), mayCom
|
|
|
84
130
|
return isLatest(nav) && useStore.getState().board === board
|
|
85
131
|
}
|
|
86
132
|
/** The camera to a node once it is drawn - unless a newer navigation has it by then. */
|
|
87
|
-
const fitLater = (key: string, seq: number) => setTimeout(() => { if (isLatest(seq)) canvasCtl.fitNode(key) }, 50)
|
|
133
|
+
const fitLater = (key: string, seq: number, mayCommit?: () => boolean) => setTimeout(() => { if (isLatest(seq) && (!mayCommit || mayCommit())) canvasCtl.fitNode(key) }, 50)
|
|
88
134
|
|
|
89
135
|
/** Switch to `home` and select + fit `target` there once the board commits - unless the human has
|
|
90
136
|
* moved on: newer navigation, or a board they switched to themselves while the lookup ran. */
|
|
91
|
-
async function landOn(home: string, target: string, carry: boolean, seq: number, from: string) {
|
|
137
|
+
async function landOn(home: string, target: string, carry: boolean, seq: number, from: string, mayCommit?: () => boolean) {
|
|
92
138
|
if (seq !== gotoSeq || useStore.getState().board !== from) return
|
|
93
|
-
if (!await switchFor(home, seq)) return
|
|
139
|
+
if (!await switchFor(home, seq, mayCommit)) return
|
|
94
140
|
for (let i = 0; i < 12; i++) { // the board commits async - retry like viewNote
|
|
95
|
-
if (seq !== gotoSeq) return
|
|
141
|
+
if (seq !== gotoSeq || (mayCommit && !mayCommit())) return
|
|
96
142
|
const st = useStore.getState()
|
|
97
143
|
if (st.board === home) { // a cancelled/failed switch must not select here
|
|
98
144
|
const node = st.nodes.find((n) => n.frame === target && !n.missing)
|
|
99
145
|
if (node) {
|
|
100
146
|
st.select(node.key)
|
|
101
147
|
if (carry) st.setInteract(node.key)
|
|
102
|
-
fitLater(node.key, seq)
|
|
148
|
+
fitLater(node.key, seq, mayCommit)
|
|
103
149
|
return
|
|
104
150
|
}
|
|
105
151
|
}
|
|
@@ -111,13 +157,14 @@ async function landOn(home: string, target: string, carry: boolean, seq: number,
|
|
|
111
157
|
* not show, the way back from a focus link): this board, else the first board that shows it
|
|
112
158
|
* (archive boards last), else - a frame on no board - the Not on a board view. Unlike a goto it
|
|
113
159
|
* never spawns - opening a link must not edit a board. */
|
|
114
|
-
export async function revealFrame(target: string, nav?: number): Promise<void> { // `nav`: a caller's navigation, else its own
|
|
160
|
+
export async function revealFrame(target: string, nav?: number, mayCommit?: () => boolean): Promise<void> { // `nav`: a caller's navigation, else its own; `mayCommit`: its own condition, read before the board commits and before it selects (`marver show`'s: no words typed meanwhile)
|
|
115
161
|
const s = useStore.getState()
|
|
162
|
+
if (mayCommit && !mayCommit()) return
|
|
116
163
|
const here = s.nodes.find((n) => n.frame === target && !n.missing)
|
|
117
164
|
if (here) {
|
|
118
165
|
const seq = nav ?? navigated()
|
|
119
166
|
s.select(here.key)
|
|
120
|
-
fitLater(here.key, seq)
|
|
167
|
+
fitLater(here.key, seq, mayCommit)
|
|
121
168
|
return
|
|
122
169
|
}
|
|
123
170
|
if (!s.manifest?.frames.some((f) => f.id === target)) return s.toast(`no frame "${target}" on this canvas`)
|
|
@@ -130,7 +177,7 @@ export async function revealFrame(target: string, nav?: number): Promise<void> {
|
|
|
130
177
|
} catch {
|
|
131
178
|
return useStore.getState().toast(`could not read the boards - try again`)
|
|
132
179
|
}
|
|
133
|
-
if (seq !== gotoSeq) return
|
|
180
|
+
if (seq !== gotoSeq || (mayCommit && !mayCommit())) return
|
|
134
181
|
if (!home) return useStore.getState().toast(`"${target}" is not on any board`)
|
|
135
|
-
await landOn(home, target, false, seq, from)
|
|
182
|
+
await landOn(home, target, false, seq, from, mayCommit)
|
|
136
183
|
}
|
|
@@ -85,10 +85,15 @@ export const ArrowRightIcon = icon(<path d="M221.66,133.66l-72,72a8,8,0,0,1-11.3
|
|
|
85
85
|
export const VariantsIcon = icon(<path d="M223.45,208.19,168,101.11V40h8a8,8,0,0,0,0-16H80a8,8,0,0,0,0,16h8v61.11L32.55,208.19A16,16,0,0,0,46.86,232H209.14a16,16,0,0,0,14.31-23.81ZM102.13,108.5A8,8,0,0,0,104,103.35V40h48v63.35a8,8,0,0,0,1.87,5.15L179.36,157c-11.71,2.87-26.5.66-44.16-6.64-14.08-5.82-27.34-8.53-39.66-8.16ZM46.86,216,84.36,143.6c11.68-2.9,26.47-.68,44.13,6.61,13.09,5.42,25.36,8.11,36.65,8.11a67.86,67.86,0,0,0,22.53-3.72L209.14,216Z" />)
|
|
86
86
|
/** The board glyph, for a board with no type. */
|
|
87
87
|
export const CardsIcon = icon(<path d="M184,72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V88A16,16,0,0,0,184,72Zm0,128H40V88H184V200ZM232,56V176a8,8,0,0,1-16,0V56H64a8,8,0,0,1,0-16H216A16,16,0,0,1,232,56Z" />)
|
|
88
|
-
|
|
89
|
-
export
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
/* spec 31 F.1: the built-in glyphs beyond Phosphor's devices, drawn in the same 256-space and stroke. */
|
|
89
|
+
export const WatchIcon = icon(<><rect x="64" y="64" width="128" height="128" rx="32" fill="none" stroke="currentColor" strokeWidth="16" /><path d="M92 64 L100 24 H156 L164 64 M92 192 L100 232 H156 L164 192" fill="none" stroke="currentColor" strokeWidth="16" strokeLinejoin="round" /><path d="M128 104 V128 H148" fill="none" stroke="currentColor" strokeWidth="14" strokeLinecap="round" strokeLinejoin="round" /></>)
|
|
90
|
+
export const DesktopIcon = icon(<><rect x="24" y="40" width="208" height="144" rx="16" fill="none" stroke="currentColor" strokeWidth="16" /><path d="M24 152 H232 M128 184 V216 M88 216 H168" fill="none" stroke="currentColor" strokeWidth="16" strokeLinecap="round" /></>)
|
|
91
|
+
export const EreaderIcon = icon(<><rect x="52" y="24" width="152" height="208" rx="20" fill="none" stroke="currentColor" strokeWidth="16" /><path d="M88 72 H168 M88 104 H168 M88 136 H144" fill="none" stroke="currentColor" strokeWidth="14" strokeLinecap="round" /><path d="M112 196 H144" fill="none" stroke="currentColor" strokeWidth="14" strokeLinecap="round" /></>)
|
|
92
|
+
|
|
93
|
+
/** A built-in device glyph's icon; an unknown or absent one is the generic Devices. */
|
|
94
|
+
export const DEVICE_GLYPH_ICONS: Record<string, typeof DevicesIcon> = {
|
|
95
|
+
mobile: DeviceMobileIcon, tablet: DeviceTabletIcon, laptop: LaptopIcon, monitor: MonitorIcon, tv: TvIcon,
|
|
96
|
+
watch: WatchIcon, desktop: DesktopIcon, ereader: EreaderIcon,
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
export const BrowsersIcon = icon(<path d="M216,40H72A16,16,0,0,0,56,56V72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V184h16a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM184,88v16H40V88Zm0,112H40V120H184v80Zm32-32H200V88a16,16,0,0,0-16-16H72V56H216Z" />)
|
|
@@ -112,4 +117,6 @@ export const FileCodeIcon = icon(<path d="M181.66,146.34a8,8,0,0,1,0,11.32l-24,2
|
|
|
112
117
|
export const KeyboardIcon = icon(<path d="M224,48H32A16,16,0,0,0,16,64V192a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V64A16,16,0,0,0,224,48Zm0,144H32V64H224V192Zm-16-64a8,8,0,0,1-8,8H56a8,8,0,0,1,0-16H200A8,8,0,0,1,208,128Zm0-32a8,8,0,0,1-8,8H56a8,8,0,0,1,0-16H200A8,8,0,0,1,208,96ZM72,160a8,8,0,0,1-8,8H56a8,8,0,0,1,0-16h8A8,8,0,0,1,72,160Zm96,0a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,160Zm40,0a8,8,0,0,1-8,8h-8a8,8,0,0,1,0-16h8A8,8,0,0,1,208,160Z" />)
|
|
113
118
|
export const ArrowBendUpLeftIcon = icon(<path d="M232,200a8,8,0,0,1-16,0,88.1,88.1,0,0,0-88-88H51.31l34.35,34.34a8,8,0,0,1-11.32,11.32l-48-48a8,8,0,0,1,0-11.32l48-48A8,8,0,0,1,85.66,61.66L51.31,96H128A104.11,104.11,0,0,1,232,200Z" />)
|
|
114
119
|
export const WarningIcon = icon(<path d="M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z" />)
|
|
120
|
+
/** Phosphor's Export: a page with an arrow up out of it (Export PDF, spec 31) */
|
|
121
|
+
export const ExportIcon = icon(<path d="M216,112v96a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V112A16,16,0,0,1,56,96H80a8,8,0,0,1,0,16H56v96H200V112H176a8,8,0,0,1,0-16h24A16,16,0,0,1,216,112ZM93.66,69.66,120,43.31V136a8,8,0,0,0,16,0V43.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,69.66Z" />)
|
|
115
122
|
export const NotebookIcon = icon(<path d="M184,112a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16h64A8,8,0,0,1,184,112Zm-8,24H112a8,8,0,0,0,0,16h64a8,8,0,0,0,0-16Zm48-88V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM48,208H72V48H48Zm160,0V48H88V208H208Z" />)
|
|
@@ -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
|
+
}
|