@marver-design/marver 0.30.0 → 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 +74 -0
- package/README.md +11 -7
- package/dist/{anchor-check-c52IDkiQ.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-C3mUtjEn.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-B0Wi1OQ3.mjs → daemon-MxoEQajX.mjs} +223 -26
- package/dist/deep-link-DYtuT740.mjs +163 -0
- package/dist/{dev-5dlxoW28.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-CXRoMA8g.mjs → plugin-CL8_wL7a.mjs} +519 -112
- package/dist/{poster-CYmCa00B.mjs → poster-B7uSjlEP.mjs} +1 -1
- package/dist/{profile-B1FKOM1e.mjs → profile-cdmSer1k.mjs} +1 -1
- package/dist/{publish-bakes-C_2ZtHou.mjs → publish-bakes-BjgDNeyS.mjs} +3 -3
- package/dist/{queue-DeSQm24g.mjs → queue-BLLfdlDw.mjs} +156 -11
- package/dist/{recover-XD8iXJOj.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-CRRGgxru.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/performance.md +2 -1
- 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/recorder.ts +3 -2
- package/src/client/shell/show.ts +250 -0
- package/src/client/shell/store.ts +79 -48
- 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
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Showing the human a place (spec 31 D1, D3): `marver show`'s `sh:show { seq, board, n?, f?, s?, c? }` from the dev
|
|
3
|
+
* server, and in the Mac app the same command over the bridge (`onShow`) for a `marver://` link into a tab already
|
|
4
|
+
* open. One rule for both:
|
|
5
|
+
*
|
|
6
|
+
* - the command is checked again (shared/deep-link.ts `checkShowTarget`) - the hash's own targets, never a raw hash;
|
|
7
|
+
* - a tab holding unsent words (a comment draft, a Jam edit: api.ts `typedUnsent`) or a capture recording does not move:
|
|
8
|
+
* it puts up "Your agent wants to show you <title> · Go", and Go moves it when the human chooses;
|
|
9
|
+
* - else it switches board, selects (node keys stay node keys - one copy of a frame, never every copy), opens the
|
|
10
|
+
* thread, and fits - even when it is already there: a repeat refits;
|
|
11
|
+
* - a newer command supersedes an older one still on its way (a board read, a fit), and a server seq it already took is
|
|
12
|
+
* never taken twice;
|
|
13
|
+
* - in the app, a server show then asks the main process (`front()`, a trusted bridge call bound to the admitted
|
|
14
|
+
* document) to activate its tab and bring the window forward; a bridge show was activated by main already;
|
|
15
|
+
* - a server show is answered (`POST show/ack { seq, page, outcome }`), so `marver show` can say "shown in 2 tabs".
|
|
16
|
+
*/
|
|
17
|
+
import { create } from 'zustand'
|
|
18
|
+
import { checkShowTarget, type ShowTarget } from '../../shared/deep-link.ts'
|
|
19
|
+
import { api, typedUnsent } from './api.ts'
|
|
20
|
+
import { bootLanded, cancelBoot, canvasCtl } from './canvas/ctl.ts'
|
|
21
|
+
import { openThreadAt } from './jam-keys.ts'
|
|
22
|
+
import { handNow, isLatest, navigated, navNow, revealFrame, switchFor } from './goto.ts'
|
|
23
|
+
import { linkTargets } from './hash.ts'
|
|
24
|
+
import { useJamCapture } from './jam-capture.ts'
|
|
25
|
+
import { APP } from './marver-app.ts'
|
|
26
|
+
import { PAGE_ID } from './recorder.ts'
|
|
27
|
+
import { boardLabel, landingBoard, sceneLabel, useStore } from './store.ts'
|
|
28
|
+
|
|
29
|
+
export type ShowFrom = 'server' | 'app'
|
|
30
|
+
export type ShowResult = 'shown' | 'notice' | 'stale' | 'missing' | 'bad' | 'deferred'
|
|
31
|
+
|
|
32
|
+
/** The notice a tab holding unsent words puts up instead of moving: its words, and the target Go opens. */
|
|
33
|
+
export interface ShowNotice { title: string; target: ShowTarget | 'landing'; at: number }
|
|
34
|
+
export const useShowNotice = create<{ notice: ShowNotice | null }>(() => ({ notice: null }))
|
|
35
|
+
|
|
36
|
+
/** Words a move would lose, or a capture it would cut: the same reasons a notice's click reads (open-item.ts). */
|
|
37
|
+
const holdsWords = (): boolean => typedUnsent() || !!useJamCapture.getState().current
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A show never races the boot (spec 31 D3). One that comes while the tab still boots - its board not loaded, or its
|
|
41
|
+
* first camera not applied (the app delivers a link's place right after the page's hello, before its first render) - is
|
|
42
|
+
* deferred: the newest alone is kept, and applied once the boot settles, whether it loaded or failed. A person's own
|
|
43
|
+
* navigation meanwhile wins: the deferred show is dropped. Applying it cancels every boot reveal still to come
|
|
44
|
+
* (canvas/ctl.ts `cancelBoot`).
|
|
45
|
+
*/
|
|
46
|
+
let booting = true
|
|
47
|
+
/** The board the boot failed to load, while the tab still names it: a show to it loads it again, never takes it as shown */
|
|
48
|
+
let failedBoard: string | null = null
|
|
49
|
+
let deferred: { t: ShowTarget | 'landing'; seq?: number; from: ShowFrom; n: number; nav: number; hand: number } | null = null
|
|
50
|
+
|
|
51
|
+
/** App.tsx, once `boot()` answered: a board that failed or has no nodes is settled now; one with nodes once its first
|
|
52
|
+
* camera is applied (Canvas.tsx), or two seconds at most. */
|
|
53
|
+
export function bootSettled(ok: boolean): void {
|
|
54
|
+
if (!ok) failedBoard = useStore.getState().board
|
|
55
|
+
const settle = () => {
|
|
56
|
+
if (!booting) return
|
|
57
|
+
booting = false
|
|
58
|
+
const d = deferred
|
|
59
|
+
deferred = null
|
|
60
|
+
// the newest show, and no navigation of a person's since it came: applied now
|
|
61
|
+
if (d && d.n === current && isLatest(d.nav) && d.hand === handNow()) void apply(d.t, d.seq, d.from, d.n)
|
|
62
|
+
}
|
|
63
|
+
if (!ok || !useStore.getState().nodes.length) settle()
|
|
64
|
+
else void Promise.race([bootLanded, new Promise((r) => setTimeout(r, 2000))]).then(settle)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The newest command's number: an older one still on its way stops at its next step. */
|
|
68
|
+
let current = 0
|
|
69
|
+
/** The last server seq this page took: the same one again (a reconnect's replay) is never taken twice. */
|
|
70
|
+
let lastSeq = 0
|
|
71
|
+
|
|
72
|
+
/** What the notice calls the place: one frame by its title, one scene by its label, else the board. */
|
|
73
|
+
export function titleOf(t: ShowTarget): string {
|
|
74
|
+
const s = useStore.getState()
|
|
75
|
+
const frames = t.f ?? []
|
|
76
|
+
if (frames.length === 1 && !t.s?.length && !t.n?.length) {
|
|
77
|
+
const f = s.manifest?.frames.find((x) => x.id === frames[0])
|
|
78
|
+
return f?.title || frames[0]!
|
|
79
|
+
}
|
|
80
|
+
if (t.s?.length === 1 && !frames.length && !t.n?.length) return sceneLabel(t.s[0]!)
|
|
81
|
+
return boardLabel(t.board)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The words the notice says for the canvas's own board (a link that named no place it understands). */
|
|
85
|
+
const LANDING = 'the board this canvas opens on'
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Move to the target now - board, selection, thread, camera - each step only while this command is the newest and,
|
|
89
|
+
* unless the person chose it (`force`: the notice's Go), while no words wait unsent: words typed while the board loads
|
|
90
|
+
* stop it before anything moves (`blocked`, which the caller turns into the notice). `shown` only once the camera has
|
|
91
|
+
* landed for this command: a newer show, or a board that went, is never counted shown.
|
|
92
|
+
*/
|
|
93
|
+
async function go(t: ShowTarget | 'landing', n: number, force: boolean): Promise<ShowResult | 'blocked'> {
|
|
94
|
+
const nav = navigated()
|
|
95
|
+
const hand = handNow()
|
|
96
|
+
// the newest show, no navigation since, and nothing the person did on the canvas since (goto.ts navigatedByHand)
|
|
97
|
+
const owned = () => n === current && isLatest(nav) && hand === handNow()
|
|
98
|
+
const words = () => !force && holdsWords()
|
|
99
|
+
const alive = () => owned() && !words()
|
|
100
|
+
const ended = (): 'blocked' | 'stale' => (owned() && words() ? 'blocked' : 'stale')
|
|
101
|
+
if (!alive()) return ended()
|
|
102
|
+
// the camera is this show's from here: every boot reveal still to come gives way (the boot camera, its frame fallback,
|
|
103
|
+
// its thread). After a failed boot the show owns the camera for good - if its own board then fails too, the canvas is a
|
|
104
|
+
// failed board load like any other and the boot link's place is not restored (spec 31 as built: accepted)
|
|
105
|
+
cancelBoot()
|
|
106
|
+
let target: ShowTarget
|
|
107
|
+
if (t === 'landing') {
|
|
108
|
+
const board = await landingBoard()
|
|
109
|
+
if (!alive()) return ended()
|
|
110
|
+
target = { board }
|
|
111
|
+
} else target = t
|
|
112
|
+
let s = useStore.getState()
|
|
113
|
+
if (s.play) s.setPlay(null) // a stale overlay never survives a show
|
|
114
|
+
if (target.board !== s.board) {
|
|
115
|
+
if (!await switchFor(target.board, nav, alive)) return alive() ? 'missing' : ended()
|
|
116
|
+
s = useStore.getState()
|
|
117
|
+
} else if (failedBoard === s.board && !s.nodes.length) {
|
|
118
|
+
// the board the boot failed to load: loaded now, or the show did not happen
|
|
119
|
+
if (!await s.boot(alive)) return alive() ? 'missing' : ended()
|
|
120
|
+
s = useStore.getState()
|
|
121
|
+
}
|
|
122
|
+
failedBoard = null
|
|
123
|
+
if (!alive()) return ended()
|
|
124
|
+
const keys = linkTargets(target, s.nodes)
|
|
125
|
+
// nodes or a scene named, none on this board: nothing to show - never answered shown (a frame is followed below)
|
|
126
|
+
if (!keys.length && (target.n?.length || target.s?.length) && !target.f?.length) return 'missing'
|
|
127
|
+
useStore.setState({ selection: keys })
|
|
128
|
+
s.look(keys)
|
|
129
|
+
if (target.c) {
|
|
130
|
+
// the thread where it can be seen - pins turned on, a resolved one in its panel - under the same request, and
|
|
131
|
+
// waited for: a thread that never shows is no "shown"
|
|
132
|
+
if (!await openThreadAt(target.board, target.c, { alive })) return alive() ? 'missing' : ended()
|
|
133
|
+
return (await fitOwn(alive)) ? 'shown' : ended()
|
|
134
|
+
}
|
|
135
|
+
if (!keys.length && target.f?.length) {
|
|
136
|
+
// not on this board's nodes: where it lives, under the same request - shown once it is selected there and the
|
|
137
|
+
// camera has landed, for this command
|
|
138
|
+
const f = target.f[0]!
|
|
139
|
+
await revealFrame(f, nav, alive)
|
|
140
|
+
for (let i = 0; i < 40 && alive(); i++) {
|
|
141
|
+
const now = useStore.getState()
|
|
142
|
+
if (now.selection.some((k) => now.nodes.find((x) => x.key === k)?.frame === f)) return (await fitOwn(alive)) ? 'shown' : ended()
|
|
143
|
+
await new Promise((r) => setTimeout(r, 50))
|
|
144
|
+
}
|
|
145
|
+
return alive() ? 'missing' : ended()
|
|
146
|
+
}
|
|
147
|
+
// the refit, even when the place is already on screen - unless a newer navigation has the camera by then (a frame's
|
|
148
|
+
// worth for the selection to draw; none in a background tab, whose timers run once a second)
|
|
149
|
+
if (document.visibilityState !== 'hidden') await new Promise((r) => setTimeout(r, 60))
|
|
150
|
+
if (!alive()) return ended()
|
|
151
|
+
if (keys.length) canvasCtl.fitNodes(keys); else canvasCtl.fitAll()
|
|
152
|
+
return (await cameraLanded(alive)) ? 'shown' : ended()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** The show's own fit to what the helper selected (revealFrame's and revealThread's fits run on their timers, which a
|
|
156
|
+
* newer show may cancel): this command's camera, then its landing - in a background tab at once. */
|
|
157
|
+
async function fitOwn(alive: () => boolean): Promise<boolean> {
|
|
158
|
+
if (!alive()) return false
|
|
159
|
+
const sel = useStore.getState().selection
|
|
160
|
+
// a thread with no node to fit (a resolved one, in its panel): the board it is on, fitted all the same
|
|
161
|
+
if (sel.length) canvasCtl.fitNodes([...sel]); else canvasCtl.fitAll()
|
|
162
|
+
return cameraLanded(alive)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** The camera came to rest (the commands' own rule, commands.ts `cameraDone`: it flew and stopped, or rested 250 ms),
|
|
166
|
+
* while `alive` held throughout - a newer navigation or words typed meanwhile is no landing. A tab in the background
|
|
167
|
+
* lands its camera at once (Canvas.tsx `fly`), and is timed here without frames. 2 s at most, so `marver show`'s 3 s
|
|
168
|
+
* hear every tab; a camera still flying then has not landed - no "shown". */
|
|
169
|
+
async function cameraLanded(alive: () => boolean): Promise<boolean> {
|
|
170
|
+
const since = performance.now()
|
|
171
|
+
let saw = false
|
|
172
|
+
// a background tab's fit landed synchronously (Canvas.tsx fly): verified now, no polling its throttled timers
|
|
173
|
+
if (document.visibilityState === 'hidden') return alive() && !canvasCtl.cameraBusy()
|
|
174
|
+
for (let n = 1; performance.now() - since < 2000; n++) {
|
|
175
|
+
// a frame, or 50 ms where none come (a tab in the background)
|
|
176
|
+
await new Promise((r) => { const late = setTimeout(r, 50); requestAnimationFrame(() => { clearTimeout(late); r(null) }) })
|
|
177
|
+
if (!alive()) return false
|
|
178
|
+
const busy = canvasCtl.cameraBusy()
|
|
179
|
+
if (busy) saw = true
|
|
180
|
+
if (!busy && (saw || performance.now() - since > 250) && n >= 2) return true
|
|
181
|
+
}
|
|
182
|
+
return false
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const ack = (seq: number, outcome: 'shown' | 'notice') => {
|
|
186
|
+
const c = /(?:^|;\s*)mv_c=([\w-]+)/.exec(document.cookie)?.[1] ?? ''
|
|
187
|
+
void api('show/ack', { method: 'POST', headers: { 'content-type': 'application/json', 'x-mv-c': c }, body: JSON.stringify({ seq, page: PAGE_ID, outcome }) }).catch(() => {})
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The tab to the front of the app's window (a server show): main checks the asking document and acts. */
|
|
191
|
+
const front = () => { try { APP?.front?.() } catch { /* the app went away under the page */ } }
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* A show command, from the dev server (`seq`) or the app's bridge. The app's `null` is a link that named no place this
|
|
195
|
+
* shell takes: the canvas's own board, by the same rule (moved to, or the notice over unsent words).
|
|
196
|
+
*/
|
|
197
|
+
export async function showTarget(raw: unknown, from: ShowFrom): Promise<ShowResult> {
|
|
198
|
+
const seq = from === 'server' ? (raw as { seq?: unknown } | null)?.seq : undefined
|
|
199
|
+
if (from === 'server' && (typeof seq !== 'number' || !Number.isSafeInteger(seq) || seq < 1)) return 'bad'
|
|
200
|
+
const t: ShowTarget | 'landing' | null = from === 'app' && raw === null ? 'landing' : checkShowTarget(raw)
|
|
201
|
+
if (!t) return 'bad'
|
|
202
|
+
if (typeof seq === 'number') {
|
|
203
|
+
if (seq <= lastSeq) return 'stale'
|
|
204
|
+
lastSeq = seq
|
|
205
|
+
}
|
|
206
|
+
const n = ++current
|
|
207
|
+
if (booting) {
|
|
208
|
+
// the newest alone waits for the boot (an older deferred one is superseded: never answered)
|
|
209
|
+
deferred = { t, ...(typeof seq === 'number' ? { seq } : {}), from, n, nav: navNow(), hand: handNow() }
|
|
210
|
+
return 'deferred'
|
|
211
|
+
}
|
|
212
|
+
return apply(t, typeof seq === "number" ? seq : undefined, from, n)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** A show applied: the notice over unsent words, or the move - answered, and the window forward, once it is on screen. */
|
|
216
|
+
async function apply(t: ShowTarget | 'landing', seq: number | undefined, from: ShowFrom, n: number): Promise<ShowResult> {
|
|
217
|
+
const notice = (): ShowResult => {
|
|
218
|
+
useShowNotice.setState({ notice: { title: t === 'landing' ? LANDING : titleOf(t), target: t, at: Date.now() } })
|
|
219
|
+
if (typeof seq === 'number') ack(seq, 'notice')
|
|
220
|
+
if (from === 'server') front()
|
|
221
|
+
return 'notice'
|
|
222
|
+
}
|
|
223
|
+
if (holdsWords()) return notice()
|
|
224
|
+
useShowNotice.setState({ notice: null })
|
|
225
|
+
const r = await go(t, n, false)
|
|
226
|
+
// words typed while it was on its way: the notice instead, nothing moved
|
|
227
|
+
if (r === 'blocked') return n === current ? notice() : 'stale'
|
|
228
|
+
// answered, and the window brought forward, once it is on screen: a newer show or a board that went is no "shown"
|
|
229
|
+
if (r === 'shown') {
|
|
230
|
+
if (typeof seq === 'number') ack(seq, 'shown')
|
|
231
|
+
if (from === 'server') front()
|
|
232
|
+
}
|
|
233
|
+
return r
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** The notice's Go: the human chose to move, words or not. */
|
|
237
|
+
export async function goNow(): Promise<ShowResult> {
|
|
238
|
+
const notice = useShowNotice.getState().notice
|
|
239
|
+
useShowNotice.setState({ notice: null })
|
|
240
|
+
if (!notice) return 'stale'
|
|
241
|
+
const r = await go(notice.target, ++current, true)
|
|
242
|
+
return r === 'blocked' ? 'stale' : r
|
|
243
|
+
}
|
|
244
|
+
export const dismissShow = (): void => { useShowNotice.setState({ notice: null }) }
|
|
245
|
+
|
|
246
|
+
/** A server seq the page knows (tests read where it stands). */
|
|
247
|
+
export const showState = () => ({ current, lastSeq })
|
|
248
|
+
|
|
249
|
+
// dev-only inspection hook for tests (never installed in published builds)
|
|
250
|
+
if (typeof window !== 'undefined' && import.meta.env.DEV) (window as unknown as { __mvShow: unknown }).__mvShow = { showTarget, goNow, dismissShow, state: showState, notice: () => useShowNotice.getState().notice }
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { create } from 'zustand'
|
|
2
2
|
import { ROUTE, slideSize } from '../const.ts'
|
|
3
3
|
import { tidy, parseLayout, type BoardLayout, type TidyNode } from './tidy.ts'
|
|
4
|
-
import { clearNoteHeights, noteHeight, noteReserve, notesCramped, scopeNotes, setNoteHeight } from './notes.ts'
|
|
4
|
+
import { clearNoteHeights, noteHeight, noteReserve, notesCramped, scopeNotes, setNoteHeight, tidyNodes } from './notes.ts'
|
|
5
5
|
import { stableNodeKey } from './keys.ts'
|
|
6
6
|
import { canvasCtl } from './canvas/ctl.ts'
|
|
7
7
|
import { api, beforeResume, canvasStopped, holdsReload, lostInResume, mvFetch, noteUnsaved, onLinkNotice, savedInResume, scoped, STOPPED_WAY, withWs } from './api.ts'
|
|
8
8
|
import { unsavedWhen, workChanged } from './unsaved.ts'
|
|
9
9
|
import { nextSeq, PAGE_ID } from './recorder-seams.ts'
|
|
10
10
|
import type { BoardWriter, HeldBy, LoadTrigger } from '../../shared/perf-records.ts'
|
|
11
|
+
import type { DeviceLook } from '../../shared/devices.ts'
|
|
11
12
|
// @ts-expect-error virtual module provided by the plugin
|
|
12
13
|
import shConfig from 'virtual:sh-config'
|
|
13
14
|
// @ts-expect-error virtual module: null in dev; a published build inlines manifest+boards
|
|
@@ -128,9 +129,12 @@ export interface JamNote {
|
|
|
128
129
|
/** earlier notices folded under this one - View walks through them */
|
|
129
130
|
stack?: JamNote[]
|
|
130
131
|
}
|
|
131
|
-
|
|
132
|
+
/** A plain notice's one action (spec 31 B.3: "Resolved 31 conversations · Undo"): what its click runs - which records
|
|
133
|
+
* its own command (`resolve-undo`). `id` names it on the notice (`data-toast`). */
|
|
134
|
+
export interface ToastAction { label: string; id: string; run: () => void }
|
|
135
|
+
export interface Toast { id: number; text: string; jam?: JamNote; action?: ToastAction }
|
|
132
136
|
|
|
133
|
-
export const CONFIG: { viewports: Record<string, { width: number; height: number }>; themes: string[]; zoomSpeed?: number; noTheme: boolean; setup?: boolean; projectName?: string; branding?: boolean; jam?: { chime: boolean; capture: 'confirm' | 'at-once'; names?: boolean } | null; workspace?: string; version?: string } = shConfig
|
|
137
|
+
export const CONFIG: { viewports: Record<string, { width: number; height: number }>; devices?: Record<string, DeviceLook>; themes: string[]; zoomSpeed?: number; noTheme: boolean; setup?: boolean; projectName?: string; branding?: boolean; jam?: { chime: boolean; capture: 'confirm' | 'at-once'; names?: boolean } | null; workspace?: string; version?: string } = shConfig
|
|
134
138
|
|
|
135
139
|
/** Invariant: `branding: false` strips every Marver mention - new chrome included. */
|
|
136
140
|
export const BRANDING = CONFIG.branding !== false
|
|
@@ -173,8 +177,9 @@ export { cap, humanize } from './labels.ts'
|
|
|
173
177
|
import { cap, humanize } from './labels.ts'
|
|
174
178
|
import { canAutoReload } from './canvas/ready-watch.ts'
|
|
175
179
|
import { pumpUpdates } from './canvas/updates.ts'
|
|
176
|
-
import { archiveLast, buildTree, flatten, framesOn, labelOf, toWire, TREE_PROTOCOL, type TreeItem } from '../../shared/board-tree.ts'
|
|
180
|
+
import { archiveLast, buildTree, canvasLabel, flatten, framesOn, labelOf, toWire, TREE_PROTOCOL, type TreeItem } from '../../shared/board-tree.ts'
|
|
177
181
|
import { UNPLACED } from './hash.ts'
|
|
182
|
+
import { placeNewcomers } from '../../shared/auto-place.ts'
|
|
178
183
|
import type { BoardType, StatusWord } from '../../shared/board-types.ts'
|
|
179
184
|
import type { Phase, Status } from '../../shared/status.ts'
|
|
180
185
|
import { isNew, type Marks } from '../../shared/marks.ts'
|
|
@@ -259,7 +264,7 @@ export async function fetchMembership(): Promise<{ boards: { name: string; frame
|
|
|
259
264
|
* re-render on change), else the Title-Cased slug. */
|
|
260
265
|
export const boardLabel = (n: string) => (n === UNPLACED ? 'Not on a board' : labelOf(n, useStore.getState().boardTitles[n]))
|
|
261
266
|
/** The canvas's name, as the sidebar heads it: the project's (share.name, else the repo folder). */
|
|
262
|
-
export const CANVAS_NAME = CONFIG.projectName ?
|
|
267
|
+
export const CANVAS_NAME = CONFIG.projectName ? canvasLabel(CONFIG.projectName) : 'Marver'
|
|
263
268
|
/** The browser tab: the board, then the canvas - "Start here - Acme Studio" - so a row of canvas tabs
|
|
264
269
|
* says which project each one is (it said "- Marver" on all of them). */
|
|
265
270
|
export const tabTitle = (board: string | null | undefined): string => (board ? `${boardLabel(board)} - ${CANVAS_NAME}` : CANVAS_NAME)
|
|
@@ -318,16 +323,7 @@ const HEADER = 28
|
|
|
318
323
|
* tidy keeps the scene reserve on the first node it places), and the measured height of the
|
|
319
324
|
* column standing there, so a note longer than its frame gets its room below as well. */
|
|
320
325
|
export function tidyInput(nodes: readonly Node[], manifest: Manifest | null): TidyNode[] {
|
|
321
|
-
|
|
322
|
-
const sceneNote = (scene: string) => !!manifest?.scenes.find((s) => s.name === scene)?.note
|
|
323
|
-
return nodes.map((n) => {
|
|
324
|
-
const f = entryOf(n.frame)
|
|
325
|
-
const scene = f?.scene ?? ''
|
|
326
|
-
return {
|
|
327
|
-
key: n.key, frame: n.frame, scene, group: f?.variantGroup, variant: f?.variant, w: n.w, h: n.h + HEADER,
|
|
328
|
-
noteW: noteReserve(!!f?.note, false), sceneNoteW: noteReserve(false, sceneNote(scene)), noteH: noteHeight(n.key),
|
|
329
|
-
}
|
|
330
|
-
})
|
|
326
|
+
return tidyNodes(nodes, manifest) // notes.ts: the deck PDF's plan lays boards out with the same input
|
|
331
327
|
}
|
|
332
328
|
let toastSeq = 0
|
|
333
329
|
const nodeKey = () => 'n_' + Math.random().toString(36).slice(2, 8)
|
|
@@ -338,6 +334,36 @@ const nodeKey = () => 'n_' + Math.random().toString(36).slice(2, 8)
|
|
|
338
334
|
let manifestRev = 0
|
|
339
335
|
export const bumpManifestRev = () => { manifestRev++ }
|
|
340
336
|
|
|
337
|
+
/** The board read again over itself: a frame still on it keeps its live document, so the node keeps what is known of
|
|
338
|
+
* that document. Read fresh it would wait for a ready that document sent long ago - the watchdog then reloads every
|
|
339
|
+
* frame - and its `nav`, back to none, would read as a request to navigate. Only a healthy document is kept: one that
|
|
340
|
+
* failed, one silent past its retry, and one whose sizing changed - its mode, or a content frame's human width (a
|
|
341
|
+
* measure it will never send again) - are asked anew.
|
|
342
|
+
* A kept content frame keeps the size it measured: the file holds none (auto) or the width alone is the human's
|
|
343
|
+
* (manual), and a document that stays never measures again unless its width changes. `kept`: the nodes whose
|
|
344
|
+
* document stands; `carried`: the nodes whose kept size differs from the file's. */
|
|
345
|
+
function keepDocuments(mounted: Node[], nodes: Node[]): { nodes: Node[]; kept: Set<string>; carried: Set<string> } {
|
|
346
|
+
const was = new Map(mounted.map((n) => [n.key, n]))
|
|
347
|
+
const kept = new Set<string>(), carried = new Set<string>()
|
|
348
|
+
const next = nodes.map((n) => {
|
|
349
|
+
const o = was.get(n.key)
|
|
350
|
+
if (!o || o.frame !== n.frame || o.missing || n.missing) return n
|
|
351
|
+
const { status, error, nav, rev, themeOn, readyRetried, stale, shown, want } = o
|
|
352
|
+
// only a frame that measures (renders a Doc) has a size of its own to keep; a bare Md or Img is the size its board says
|
|
353
|
+
const fits = measures(n.frame)
|
|
354
|
+
// a human width the file changed is sizing too: the document fits its height at a width only once it loads there
|
|
355
|
+
const resized = fits && n.sizeMode === 'manual' && Math.round(o.w) !== Math.round(n.w)
|
|
356
|
+
if (status === 'error' || (status === 'loading' && readyRetried) || o.sizeMode !== n.sizeMode || resized) return { ...n, nav: (nav ?? 0) + 1, stale, want }
|
|
357
|
+
kept.add(n.key)
|
|
358
|
+
// auto: the whole size is measured; manual: the height, at the width it has
|
|
359
|
+
const w = fits && o.sizeMode === 'auto' ? o.w : n.w
|
|
360
|
+
const h = fits && (o.sizeMode === 'auto' || o.sizeMode === 'manual') ? o.h : n.h
|
|
361
|
+
if (Math.round(w) !== Math.round(n.w) || Math.round(h) !== Math.round(n.h)) carried.add(n.key)
|
|
362
|
+
return { ...n, w, h, status, error, nav, rev, themeOn, readyRetried, stale, shown, want }
|
|
363
|
+
})
|
|
364
|
+
return { nodes: next, kept, carried }
|
|
365
|
+
}
|
|
366
|
+
|
|
341
367
|
/** ws= binds the document to this canvas (spec 28 A1.11): another project on this port later answers a
|
|
342
368
|
* frame's own reload with the "another canvas" page (server/guard.ts), never with its frame. */
|
|
343
369
|
export function frameUrl(frame: FrameEntry, theme: string): string {
|
|
@@ -542,7 +568,7 @@ export const recorderHooks = {
|
|
|
542
568
|
/** a request is about to commit: the load that was up ends - before the incoming sizes are installed, so it ends by
|
|
543
569
|
* the sizes it read (which frames measure), its board's nodes still in the store */
|
|
544
570
|
handover: (_request: string): void => {},
|
|
545
|
-
commit: (_request: string, _nodes: readonly Node[], _manifest: Manifest): void => {},
|
|
571
|
+
commit: (_request: string, _nodes: readonly Node[], _manifest: Manifest, _kept?: ReadonlySet<string>): void => {},
|
|
546
572
|
cut: (_request: string, _reason: RequestCut): void => {},
|
|
547
573
|
/** nothing of the reflow story is left: no reflow pending, no height held, none owed */
|
|
548
574
|
reflowIdle: (): void => {},
|
|
@@ -715,7 +741,10 @@ interface State {
|
|
|
715
741
|
togglePanel(): void
|
|
716
742
|
setTheme(theme: string): void
|
|
717
743
|
runTidy(): void
|
|
718
|
-
|
|
744
|
+
/** a plain notice, gone after 4 s - or `ms`; one with an `action` (Undo) stays its own while it shows */
|
|
745
|
+
toast(text: string, action?: ToastAction, ms?: number): void
|
|
746
|
+
/** take a plain notice down now (its action ran) */
|
|
747
|
+
dropToast(id: number): void
|
|
719
748
|
jamToast(note: JamNote): void
|
|
720
749
|
/** a jam card failed - one notice, with Retry (spec 27: only a question or a failure interrupts) */
|
|
721
750
|
jamFailed(cards: { id: string; rev: number; board: string; thread?: string; frames: string[]; note?: string; batch?: string }[]): void
|
|
@@ -865,7 +894,12 @@ export const useStore = create<State>((set, get) => {
|
|
|
865
894
|
if (!holds.size && reflowOwed) { reflowOwed = false; scheduleReflow(null) }
|
|
866
895
|
else reflowSettled()
|
|
867
896
|
}
|
|
868
|
-
|
|
897
|
+
/** `keep`: nodes whose document a board read kept - a reload of theirs still on its way keeps its hold and the
|
|
898
|
+
* measure it held back (an image still loading lands when the hold lets go) */
|
|
899
|
+
const dropHolds = (keep?: ReadonlySet<string>) => {
|
|
900
|
+
for (const [k, h] of holds) if (!keep?.has(k)) { clearTimeout(h.timer); holds.delete(k) }
|
|
901
|
+
reflowOwed = reflowOwed && holds.size > 0 // a reflow owed to a hold that stays is still owed when it lets go
|
|
902
|
+
}
|
|
869
903
|
/** A content measure moved the rows: once, after the last held node lets go. */
|
|
870
904
|
const reflowAfterHolds = () => { reflowReasons.add('measured'); if (holds.size) reflowOwed = true; else scheduleReflow('measured') }
|
|
871
905
|
/** The recorder hears when nothing of the reflow story is left (spec 28 A1.7): no timer, no held height, none owed. */
|
|
@@ -915,10 +949,11 @@ export const useStore = create<State>((set, get) => {
|
|
|
915
949
|
* it: it already equals the committed one. So once the board is up, the recipe re-runs if the
|
|
916
950
|
* known heights differ from the ones its positions were laid out around (`laidOut`). A frame the
|
|
917
951
|
* human dragged, at heights that did not change, stays where they put it. */
|
|
918
|
-
const layoutStale = () => {
|
|
952
|
+
const layoutStale = (kept?: ReadonlySet<string>) => {
|
|
919
953
|
const { nodes, laidOut } = get()
|
|
920
954
|
const record = laidOut ?? {}
|
|
921
|
-
|
|
955
|
+
// `kept`: nodes whose size a board read kept from their live document - known as surely as a measured one
|
|
956
|
+
const known = (n: Node) => (n.sizeMode === 'auto' && hasKnownHeight(n.frame, Math.round(n.w))) || !!kept?.has(n.key)
|
|
922
957
|
const has = (n: Node) => Object.prototype.hasOwnProperty.call(record, n.key)
|
|
923
958
|
// a node the layout recorded, at another size now
|
|
924
959
|
if (nodes.some((n) => known(n) && has(n) && sizeOf(n) !== record[n.key])) return true
|
|
@@ -981,7 +1016,9 @@ export const useStore = create<State>((set, get) => {
|
|
|
981
1016
|
* mounted board reads: those it read come back with it, for the commit to install (installSizes).
|
|
982
1017
|
* null = failure (transport, malformed manifest, non-404 board error) - the caller
|
|
983
1018
|
* keeps whatever board is currently mounted. */
|
|
984
|
-
|
|
1019
|
+
/** `tidied`: this load laid the rows out itself (no positions, a cramped note) - every position is the recipe's, made
|
|
1020
|
+
* around the sizes it read */
|
|
1021
|
+
const loadBoardState = async (boardName: string): Promise<{ state: Partial<State>; sizes: SizeRead | null; tidied: boolean } | null> => {
|
|
985
1022
|
clearNoteHeights() // heights are per column drawn; a key shared by two board files carries none across
|
|
986
1023
|
loadErrors.delete(boardName)
|
|
987
1024
|
try {
|
|
@@ -1121,7 +1158,6 @@ export const useStore = create<State>((set, get) => {
|
|
|
1121
1158
|
// (the old published everything-board bug: frames created after the board file was last
|
|
1122
1159
|
// saved piled up at the origin)
|
|
1123
1160
|
if (boardAuto) {
|
|
1124
|
-
const placed = new Set(nodes.map((n) => n.frame))
|
|
1125
1161
|
// newcomers get deterministic keys too - on a published auto board
|
|
1126
1162
|
// this path mints EVERY key, every visit, and comments anchor to them
|
|
1127
1163
|
const haveKeys = new Set(nodes.map((n) => n.key))
|
|
@@ -1131,24 +1167,10 @@ export const useStore = create<State>((set, get) => {
|
|
|
1131
1167
|
haveKeys.add(k)
|
|
1132
1168
|
return k
|
|
1133
1169
|
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
const d = defaultSize(f)
|
|
1139
|
-
const vp = deviceView ? CONFIG.viewports[deviceView] : null
|
|
1140
|
-
const w = vp?.width ?? d.w, h = vp?.height ?? d.h
|
|
1141
|
-
let x: number, y: number
|
|
1142
|
-
const sibling = f.variantGroup
|
|
1143
|
-
? nodes.filter((n) => manifest.frames.find((m) => m.id === n.frame)?.variantGroup === f.variantGroup)
|
|
1144
|
-
.reduce<Node | null>((a, n) => (!a || n.x + n.w > a.x + a.w ? n : a), null)
|
|
1145
|
-
: null
|
|
1146
|
-
if (sibling) { x = sibling.x + sibling.w + Math.max(140, sibling.w * 0.12); y = sibling.y }
|
|
1147
|
-
else { x = nodes.length ? maxX + 96 : 0; y = 0 }
|
|
1148
|
-
const node: Node = { key: mint(f.id), frame: f.id, x, y, w, h, theme: resolveTheme(f), status: 'loading', ...(f.contentWidth ? { sizeMode: (vp ? 'device' : 'auto') as Node['sizeMode'] } : {}) }
|
|
1149
|
-
nodes.push(node)
|
|
1150
|
-
maxX = Math.max(maxX, x + w)
|
|
1151
|
-
}
|
|
1170
|
+
// the placement rule the deck PDF's plan shares (src/shared/auto-place.ts)
|
|
1171
|
+
const vp = deviceView ? CONFIG.viewports[deviceView] : null
|
|
1172
|
+
placeNewcomers(nodes, manifest.frames, (f) => { const d = defaultSize(f); return { w: vp?.width ?? d.w, h: vp?.height ?? d.h } },
|
|
1173
|
+
(f, x, y, w, h): Node => ({ key: mint(f.id), frame: f.id, x, y, w, h, theme: resolveTheme(f), status: 'loading', ...(f.contentWidth ? { sizeMode: (vp ? 'device' : 'auto') as Node['sizeMode'] } : {}) }))
|
|
1152
1174
|
}
|
|
1153
1175
|
// published: re-apply this visit's pins and content sizes over the inlined data
|
|
1154
1176
|
if (DATA && nodes.length) {
|
|
@@ -1167,7 +1189,8 @@ export const useStore = create<State>((set, get) => {
|
|
|
1167
1189
|
// a note that landed while this board was closed has no room in the saved positions:
|
|
1168
1190
|
// a board with a recipe re-applies it (spec 18 - room is the layout's job)
|
|
1169
1191
|
const cramped = !!boardHash && !needTidy && !!(layout || sceneRows?.length || boardAuto) && notesCramped(nodes, manifest)
|
|
1170
|
-
|
|
1192
|
+
const tidied = (!boardHash || needTidy || cramped) && nodes.length > 0
|
|
1193
|
+
if (tidied) {
|
|
1171
1194
|
const placedAll = tidy(tidyInput(nodes, manifest), effectiveLayout(layout, sceneRows), layoutWarn, knownScenes(manifest))
|
|
1172
1195
|
for (const pl of placedAll) { const n = nodes.find((x) => x.key === pl.key)!; n.x = pl.x; n.y = pl.y }
|
|
1173
1196
|
laidOut = sizeRecord(nodes)
|
|
@@ -1180,7 +1203,7 @@ export const useStore = create<State>((set, get) => {
|
|
|
1180
1203
|
if (layout && boardHash && !needTidy && !cramped && nodes.length) {
|
|
1181
1204
|
tidy(tidyInput(nodes, manifest), layout, layoutWarn, knownScenes(manifest))
|
|
1182
1205
|
}
|
|
1183
|
-
return { state: { manifest, nodes, boardHash, boardAuto, deviceView, sceneRows, layout, layoutRaw, baseLayout, laidOut, baseLaidOut, selection: [], dirty: prunedAtLoad || cramped }, sizes }
|
|
1206
|
+
return { state: { manifest, nodes, boardHash, boardAuto, deviceView, sceneRows, layout, layoutRaw, baseLayout, laidOut, baseLaidOut, selection: [], dirty: prunedAtLoad || cramped }, sizes, tidied }
|
|
1184
1207
|
} catch { return null } finally { preparing = null }
|
|
1185
1208
|
}
|
|
1186
1209
|
|
|
@@ -1203,13 +1226,20 @@ export const useStore = create<State>((set, get) => {
|
|
|
1203
1226
|
if (!loaded) { recorderHooks.cut(request, 'error'); get().toast(`board "${boardName}" failed to load${whyNot(boardName)}`); return false }
|
|
1204
1227
|
// the user kept editing while we fetched - their newer state wins over the reload
|
|
1205
1228
|
if (get().board !== boardName || editRev !== revAtStart || (mayCommit && !mayCommit())) { recorderHooks.cut(request, 'edited'); return false }
|
|
1206
|
-
const next = loaded.state
|
|
1207
1229
|
const live = get().manifest // a WS manifest update may have landed mid-fetch
|
|
1208
1230
|
recorderHooks.handover(request) // the load that was up ends by its own sizes
|
|
1209
1231
|
installSizes(loaded.sizes) // the sizes this load read are the page's from its commit
|
|
1210
|
-
|
|
1232
|
+
// after the install: which frames measure is this load's word
|
|
1233
|
+
const { nodes, kept, carried } = keepDocuments(get().nodes, loaded.state.nodes as Node[])
|
|
1234
|
+
const next = { ...loaded.state, nodes }
|
|
1235
|
+
recorderHooks.commit(request, next.nodes, next.manifest as Manifest, kept) // before the set: mounting is not a move
|
|
1211
1236
|
set(next)
|
|
1212
|
-
cancelReflow(); dropHolds()
|
|
1237
|
+
cancelReflow(); dropHolds(kept)
|
|
1238
|
+
// a kept size the file did not hold: rows this load laid out around the file's sizes are laid out again around the
|
|
1239
|
+
// kept ones; positions read from the file move only if the layout was not made around it - judged as a known
|
|
1240
|
+
// height is (a human's placement at the sizes it recorded stays)
|
|
1241
|
+
if (carried.size && composed(get())) scheduleReflow('stale', loaded.tidied ? undefined : () => layoutStale(carried))
|
|
1242
|
+
for (const k of [...reloadCause.keys()]) if (!kept.has(k)) reloadCause.delete(k) // a document still loading keeps its cause
|
|
1213
1243
|
if (next.dirty) scheduleSave() // load-time prune must reach the disk
|
|
1214
1244
|
if (live && manifestKey(live) !== manifestKey(next.manifest as Manifest)) get().applyManifest(live)
|
|
1215
1245
|
else if (scenesRev !== scenesAtStart && liveScenes) set({ manifest: { ...get().manifest!, scenes: liveScenes } }) // an sh:scenes that landed mid-fetch outranks the file we read
|
|
@@ -1922,11 +1952,12 @@ export const useStore = create<State>((set, get) => {
|
|
|
1922
1952
|
})))
|
|
1923
1953
|
scheduleSave()
|
|
1924
1954
|
},
|
|
1925
|
-
toast(text) {
|
|
1955
|
+
toast(text, action, ms) {
|
|
1926
1956
|
const id = ++toastSeq
|
|
1927
|
-
set((s) => ({ toasts: [...s.toasts, { id, text }] }))
|
|
1928
|
-
setTimeout(() => set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })), 4000)
|
|
1957
|
+
set((s) => ({ toasts: [...s.toasts, { id, text, ...(action ? { action } : {}) }] }))
|
|
1958
|
+
setTimeout(() => set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })), ms ?? 4000)
|
|
1929
1959
|
},
|
|
1960
|
+
dropToast(id) { set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })) },
|
|
1930
1961
|
/** A Live Jam reply notification: persistent (no auto-dismiss), one per thread (a newer reply
|
|
1931
1962
|
* supersedes), capped so the stack stays small. */
|
|
1932
1963
|
jamToast(note) {
|
|
@@ -635,6 +635,8 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
635
635
|
cursor: pointer; text-align: left }
|
|
636
636
|
.sh-menu button:hover { background: var(--glass-hover) }
|
|
637
637
|
.sh-menu button span { flex: 1; text-transform: capitalize }
|
|
638
|
+
/* a device's label is written as it should read ("iPad landscape", spec 31 F.2) - never re-capitalised */
|
|
639
|
+
.sh-menu button span.dev-label { text-transform: none }
|
|
638
640
|
/* the sidebar right-click menu keeps its labels verbatim (they match the toolbar exactly);
|
|
639
641
|
it scrolls rather than overflowing the window when the folder list grows long */
|
|
640
642
|
.sh-ctxmenu { max-height: calc(100vh - 16px - var(--mv-top, 0px)); max-width: 240px; overflow-y: auto; scrollbar-width: thin }
|
|
@@ -712,6 +714,9 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
712
714
|
border: 0; background: none; border-radius: 999px; color: var(--glass-ink-3); cursor: pointer;
|
|
713
715
|
transition: color .15s, background .15s }
|
|
714
716
|
.sh-update .x:hover { background: var(--glass-hover); color: var(--glass-ink) }
|
|
717
|
+
/* `marver show` over unsent words (spec 31 D3): above the update pill, so both can be up */
|
|
718
|
+
.sh-show-notice { bottom: calc(var(--edge) + 50px); z-index: 33 } /* over Play (30, 31) and the toasts (32): a draft typed in Play keeps its notice in view */
|
|
719
|
+
.sh-show-notice .cmd code { color: var(--glass-ink) }
|
|
715
720
|
|
|
716
721
|
/* bottom-RIGHT now: jam reply pills live here; plain toasts ride along */
|
|
717
722
|
.sh-toasts { position: absolute; right: var(--edge); bottom: var(--edge); z-index: 32; display: flex;
|
|
@@ -719,10 +724,24 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
719
724
|
.sh-toast { display: flex; align-items: center; gap: 6px; font: 500 12px -apple-system, system-ui, sans-serif;
|
|
720
725
|
color: var(--glass-ink-2); border-radius: 999px; padding: 7px 13px }
|
|
721
726
|
.sh-toast svg { color: var(--glass-good); flex: none }
|
|
727
|
+
/* a notice's one action (spec 31 B.3: Undo) */
|
|
728
|
+
.sh-toast-act { margin-left: 6px; padding: 2px 9px; border: 0; border-radius: 999px; cursor: pointer;
|
|
729
|
+
background: var(--glass-hover); color: var(--glass-ink); font: 600 12px -apple-system, system-ui, sans-serif }
|
|
730
|
+
.sh-toast-act:hover { background: color-mix(in srgb, var(--glass-ink) 14%, transparent) }
|
|
722
731
|
/* the jam pill's svgs are NOT the toast checkmark: the mark stays white/90 on blue, the X keeps
|
|
723
732
|
its own muted ink - undo the blanket green above */
|
|
724
733
|
.sh-toast.jam svg { color: currentColor }
|
|
725
734
|
.sh-toast-more { color: var(--glass-ink-3); font-size: 11px; padding: 2px 10px }
|
|
735
|
+
/* a deck PDF being made (spec 31): its board and page, a thin progress bar, Cancel */
|
|
736
|
+
.sh-toast.sh-pdf-notice { gap: 8px; padding: 7px 8px 7px 13px; pointer-events: auto }
|
|
737
|
+
.sh-toast.sh-pdf-notice svg { color: currentColor }
|
|
738
|
+
.sh-toast.sh-pdf-notice b { font-weight: 600; color: var(--glass-ink) }
|
|
739
|
+
.sh-pdf-notice .bar { width: 56px; height: 3px; border-radius: 2px; background: var(--glass-line, rgba(127,127,127,.25)); overflow: hidden; flex: none }
|
|
740
|
+
.sh-pdf-notice .bar i { display: block; height: 100%; background: currentColor; opacity: .7; transition: width .3s }
|
|
741
|
+
.sh-pdf-notice button { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 999px; border: 0; background: transparent; color: var(--glass-ink-3); cursor: pointer }
|
|
742
|
+
.sh-pdf-notice button:hover { background: var(--glass-hover, rgba(127,127,127,.15)); color: var(--glass-ink) }
|
|
743
|
+
/* app 1.0.1: the held file's Download, a word not an icon */
|
|
744
|
+
.sh-pdf-notice button.go { width: auto; padding: 0 9px; font: inherit; font-weight: 600; color: var(--glass-ink) }
|
|
726
745
|
|
|
727
746
|
/* the Live Jam reply pill: our full glass treatment, full radius, one row (§9) */
|
|
728
747
|
.sh-toast.jam { gap: 12px; padding: 12px 12px 12px 14px; width: 380px; max-width: 100%; border-radius: 999px;
|
|
@@ -1184,6 +1203,23 @@ body.sh-hide-ui .sh-play-nav { display: none !important }
|
|
|
1184
1203
|
color: var(--glass-ink); white-space: pre-wrap; overflow-wrap: break-word }
|
|
1185
1204
|
.cm-scroll > .cm-body { margin-top: -10px } /* pulls against the scroller's 12px gap -> the same 2px replies get */
|
|
1186
1205
|
.cm-msg { display: flex; flex-direction: column; gap: 2px }
|
|
1206
|
+
/* spec 31 C.1: a card's words can be selected and copied - the pan/zoom wrapper sets user-select: none on everything
|
|
1207
|
+
inside it (Canvas.tsx), and Play's stage overlay too; the card's own controls stay unselectable */
|
|
1208
|
+
.cm-card, .sh-play-comments .cm-card { user-select: text; -webkit-user-select: text; cursor: auto }
|
|
1209
|
+
.cm-card button, .cm-card .cm-actions, .cm-card header .dim, .cm-card .cm-tools { user-select: none; -webkit-user-select: none }
|
|
1210
|
+
/* spec 31 C.3-C.4: your own message's Edit and Delete - quiet until the message is hovered */
|
|
1211
|
+
.cm-card .cm-tools { margin-left: auto; display: inline-flex; gap: 2px; opacity: 0; transition: opacity .12s }
|
|
1212
|
+
.cm-card header:hover .cm-tools, .cm-card .cm-tools:focus-within, .cm-msg:hover .cm-tools { opacity: 1 }
|
|
1213
|
+
@media (hover: none) { .cm-card .cm-tools { opacity: 1 } }
|
|
1214
|
+
.cm-tool { height: 20px; padding: 0 6px; border: 0; border-radius: 6px; background: none; cursor: pointer;
|
|
1215
|
+
color: var(--glass-ink-3); font: 500 11.5px -apple-system, system-ui, sans-serif }
|
|
1216
|
+
.cm-tool:hover { background: var(--glass-hover); color: var(--glass-ink) }
|
|
1217
|
+
.cm-tool.danger { color: var(--mk-ask) }
|
|
1218
|
+
.cm-card .cm-edited { font-style: italic }
|
|
1219
|
+
.cm-editing { padding-left: 33px }
|
|
1220
|
+
.cm-confirm { display: flex; align-items: center; gap: 4px; padding-left: 33px; font-size: 12px; color: var(--glass-ink-2) }
|
|
1221
|
+
.cm-confirm span { flex: 1 }
|
|
1222
|
+
.cm-card .cm-deleted { color: var(--glass-ink-3); font-style: italic; padding-left: 0 }
|
|
1187
1223
|
.cm-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
|
|
1188
1224
|
border: 0; border-radius: 8px; background: none; color: var(--glass-ink-3); cursor: pointer;
|
|
1189
1225
|
transition: background .12s, color .12s }
|
|
@@ -2059,3 +2095,10 @@ textarea.jm-field:focus { border-color: transparent; box-shadow: 0 0 0 1px var(-
|
|
|
2059
2095
|
.jm-count { cursor: pointer }
|
|
2060
2096
|
/* in play the Jam button's crossed microphone wears the dark pill's ink (the canvas grey would vanish) */
|
|
2061
2097
|
.sh-play-pill .sh-pill-btn.jm-jam .jm-nomic { color: inherit }
|
|
2098
|
+
|
|
2099
|
+
/* spec 31 F.1: a device's own icon - its sanitized SVG as a mask, filled with the ink it sits in */
|
|
2100
|
+
.sh-dev-mask { display: inline-block; flex: none; background-color: currentColor;
|
|
2101
|
+
-webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
|
|
2102
|
+
-webkit-mask-position: center; mask-position: center }
|
|
2103
|
+
/* a Jam view line's device, as it reads, with its icon */
|
|
2104
|
+
.jm-dev { display: inline-flex; align-items: center; gap: 3px; vertical-align: -2px }
|