@marver-design/marver 0.27.0 → 0.28.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 +195 -0
- package/README.md +9 -4
- package/dist/{anchor-check-ChdDqL5z.mjs → anchor-check-PHUOFj1N.mjs} +1 -1
- package/dist/{audio-Dw1lfMdb.mjs → audio-DX4POHAj.mjs} +39 -4
- package/dist/{board-tree-DRioF94d.mjs → board-tree-BXR8dw4b.mjs} +3 -1
- package/dist/{boards-DlTcpF47.mjs → boards-BeWtjGUM.mjs} +50 -5
- package/dist/boards-EH2onUXM.mjs +995 -0
- package/dist/{build-DZnFysGU.mjs → build-BsAyLMT1.mjs} +9 -22
- package/dist/{capture-vadKjuCo.mjs → capture-DdZ6xgoz.mjs} +92 -30
- package/dist/cli.mjs +56 -21
- package/dist/{collab-Dxg2trOK.mjs → collab-BEAcXrBb.mjs} +1 -1
- package/dist/{comments-DxOkCSNE.mjs → comments-CrBHPEQl.mjs} +4 -4
- package/dist/config-BezZTiov.mjs +182 -0
- package/dist/conn-BMiHS42T.mjs +222 -0
- package/dist/connectors-MR9d-EBP.mjs +290 -0
- package/dist/{context-HQ4Giw58.mjs → context-BUnFiyA3.mjs} +3 -3
- package/dist/{daemon-BSA0lV8d.mjs → daemon-C5dg2R-V.mjs} +2188 -183
- package/dist/{dev-eQJhWsqg.mjs → dev-D7YS7iT2.mjs} +25 -14
- package/dist/{init-COD0x48i.mjs → init-WE5lQkQL.mjs} +8 -3
- package/dist/jam-Cj5gBvwD.mjs +373 -0
- package/dist/{link-DDXZVGtv.mjs → link-BFFRgrMt.mjs} +4 -4
- package/dist/listener-DdLEM79A.mjs +80 -0
- package/dist/{ls-D7O1G505.mjs → ls-BZ5TAtd5.mjs} +1 -1
- package/dist/{manifest-Nl3KSVOk.mjs → manifest-DPZ3WNg_.mjs} +2 -2
- package/dist/{marks-CWM3WJjc.mjs → marks-Dyn6tmjp.mjs} +3 -3
- package/dist/{marks-CKgzucHZ.mjs → marks-Kmdab_5w.mjs} +3 -3
- package/dist/{marver-id-gate-BjF6v4bT.mjs → marver-id-gate-D-R0hSt_.mjs} +1 -1
- package/dist/perf-Cn5LiRaY.mjs +1319 -0
- package/dist/perf-jam-QxD_UnzN.mjs +635 -0
- package/dist/permit-DDa6wqOs.mjs +187 -0
- package/dist/plugin-C_0yb-Fq.mjs +5089 -0
- package/dist/{poster-Bx83ZYVK.mjs → poster-DHi6I1fO.mjs} +1 -1
- package/dist/{profile-Bh5Y5zpW.mjs → profile-jIS6BcAs.mjs} +1 -1
- package/dist/{publish-bakes-aljgm45S.mjs → publish-bakes-r4PEZuPl.mjs} +3 -3
- package/dist/{queue-CAM_vNmX.mjs → queue-c-6aTHEz.mjs} +164 -25
- package/dist/{recover-t9Pno3u9.mjs → recover-nrLEVLyJ.mjs} +2 -2
- package/dist/{serve-C8rVheYk.mjs → serve-Dp3nHstu.mjs} +3 -3
- package/dist/{session-BAaJsK5c.mjs → session-DyVE7cCk.mjs} +1 -1
- package/dist/{share-W5H3BNvP.mjs → share-Ce4tP7ji.mjs} +1 -1
- package/dist/{shot-LFhC-WYD.mjs → shot-BrRtqaiS.mjs} +34 -8
- package/dist/{shot-DoHLl6ig.mjs → shot-DBWN8hPP.mjs} +1 -1
- package/dist/sizes-wjXDev3b.mjs +139 -0
- package/dist/{slots-DCDo3N0x.mjs → slots-CFNnegCc.mjs} +8 -1
- package/dist/speech-worker.mjs +23 -3
- package/dist/{sync-BQVlHZpx.mjs → sync-CQdGARJ9.mjs} +1 -1
- package/dist/transport-C5FnY9ni.mjs +203 -0
- package/dist/{work-BroFwnup.mjs → work-BYWD_1Zf.mjs} +3 -3
- package/dist/{work-Bp1p39kq.mjs → work-DJxH7cCX.mjs} +1 -1
- package/docs/jam-session.md +42 -16
- package/docs/live-jam.md +92 -10
- package/docs/performance.md +197 -35
- package/package.json +1 -1
- package/src/client/content/video.tsx +10 -2
- package/src/client/shell/App.tsx +10 -3
- package/src/client/shell/Comments.tsx +5 -3
- package/src/client/shell/ContextMenu.tsx +5 -3
- package/src/client/shell/JamSurface.tsx +56 -21
- package/src/client/shell/LockedApp.tsx +3 -0
- package/src/client/shell/Play.tsx +4 -2
- package/src/client/shell/Tip.tsx +3 -1
- package/src/client/shell/api.ts +47 -20
- package/src/client/shell/app-bridge.ts +254 -0
- package/src/client/shell/app-perf.ts +92 -0
- package/src/client/shell/canvas/Canvas.tsx +115 -22
- package/src/client/shell/canvas/FrameNode.tsx +10 -6
- package/src/client/shell/canvas/admission.ts +23 -8
- package/src/client/shell/canvas/ctl.ts +6 -0
- package/src/client/shell/canvas/sleep.ts +57 -17
- package/src/client/shell/canvas/updates.ts +2 -1
- package/src/client/shell/icons.tsx +1 -0
- package/src/client/shell/inset.ts +44 -0
- package/src/client/shell/jam-capture.ts +113 -33
- package/src/client/shell/jam-keys.ts +40 -9
- package/src/client/shell/jam-lane.tsx +14 -5
- package/src/client/shell/jam-lines.ts +66 -9
- package/src/client/shell/jam-panel.tsx +61 -6
- package/src/client/shell/jam-queue.ts +50 -8
- package/src/client/shell/jam-session.tsx +53 -4
- package/src/client/shell/jam-surface-parts.tsx +6 -3
- package/src/client/shell/jam-ui.tsx +6 -1
- package/src/client/shell/jam-voice-wait.ts +21 -0
- package/src/client/shell/jam-voice.ts +62 -15
- package/src/client/shell/main.tsx +14 -1
- package/src/client/shell/marks-ui.tsx +5 -3
- package/src/client/shell/marver-app.ts +21 -0
- package/src/client/shell/perf-run-probe.ts +34 -0
- package/src/client/shell/perf-run.ts +70 -0
- package/src/client/shell/perf.ts +11 -0
- package/src/client/shell/recorder.ts +45 -3
- package/src/client/shell/store.ts +52 -24
- package/src/client/shell/styles.css +65 -17
- package/src/client/shell/tidy.ts +3 -2
- package/src/client/shell/unsaved.ts +81 -0
- package/src/client/shell/whiteout-probes.ts +141 -0
- package/src/shared/app-api.ts +205 -0
- package/src/shared/app-perf.ts +308 -0
- package/src/shared/approval.ts +20 -0
- package/src/shared/events.ts +1 -1
- package/src/shared/logo-sniff.ts +86 -0
- package/src/shared/machine.ts +132 -0
- package/src/shared/perf-run.ts +177 -0
- package/templates/AGENTS-embedded.md +31 -1
- package/templates/AGENTS-studio.md +31 -1
- package/templates/instructions/boards.md +10 -2
- package/templates/instructions/jam.md +90 -0
- package/dist/bake-DM_uWgAA.mjs +0 -786
- package/dist/boards-CGg6piKF.mjs +0 -342
- package/dist/perf-BWzQwZqj.mjs +0 -369
- package/dist/perf-BoDSkbEb.mjs +0 -429
- package/dist/perf-jam-D55U3FZK.mjs +0 -242
- package/dist/plugin-C-E7omsh.mjs +0 -2762
|
@@ -5,6 +5,7 @@ import { clearNoteHeights, noteHeight, noteReserve, notesCramped, scopeNotes, se
|
|
|
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
|
+
import { unsavedWhen, workChanged } from './unsaved.ts'
|
|
8
9
|
// @ts-expect-error virtual module provided by the plugin
|
|
9
10
|
import shConfig from 'virtual:sh-config'
|
|
10
11
|
// @ts-expect-error virtual module: null in dev; a published build inlines manifest+boards
|
|
@@ -127,7 +128,7 @@ export interface JamNote {
|
|
|
127
128
|
}
|
|
128
129
|
export interface Toast { id: number; text: string; jam?: JamNote }
|
|
129
130
|
|
|
130
|
-
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 } = shConfig
|
|
131
|
+
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
|
|
131
132
|
|
|
132
133
|
/** Invariant: `branding: false` strips every Marver mention - new chrome included. */
|
|
133
134
|
export const BRANDING = CONFIG.branding !== false
|
|
@@ -391,22 +392,31 @@ const measures = (frameId: string) => { const m = preparing ? preparing.measurin
|
|
|
391
392
|
|
|
392
393
|
// settled heights that differ from the committed ones, written back in batches (dev only). One
|
|
393
394
|
// write in flight at a time; a height that changes while its write is in flight queues behind it,
|
|
394
|
-
// so the LAST settled height is the one the file ends with
|
|
395
|
+
// so the LAST settled height is the one the file ends with. A write the server did not take (no
|
|
396
|
+
// answer, or an error status) goes back in the queue - behind any newer height for the same key,
|
|
397
|
+
// which wins - so the heights stay unsaved until they reach the file, and is sent again after a
|
|
398
|
+
// wait that doubles with each failure in a row (1.5 s to 24 s)
|
|
395
399
|
const pendingHeights = new Map<string, number>()
|
|
396
400
|
const inflightHeights = new Map<string, number>()
|
|
397
401
|
let heightsTimer: ReturnType<typeof setTimeout> | undefined
|
|
398
|
-
|
|
402
|
+
/** The write in flight, until it has answered and its heights are saved or queued again (the resume awaits it). */
|
|
403
|
+
let flushing: Promise<void> | null = null
|
|
404
|
+
let heightsFailed = 0
|
|
405
|
+
const HEIGHTS_MS = 1500
|
|
399
406
|
const persistHeight = (key: string, h: number) => {
|
|
400
407
|
if (DATA) return
|
|
401
|
-
if (!inflightHeights.has(key) && savedHeights.get(key) === h) { pendingHeights.delete(key); return }
|
|
408
|
+
if (!inflightHeights.has(key) && savedHeights.get(key) === h) { if (pendingHeights.delete(key)) workChanged(); return }
|
|
409
|
+
if (!pendingHeights.size) workChanged() // heights not written yet: unsaved (unsaved.ts)
|
|
402
410
|
pendingHeights.set(key, h)
|
|
403
|
-
if (!flushing) heightsTimer ??= setTimeout(flushHeights,
|
|
411
|
+
if (!flushing) heightsTimer ??= setTimeout(flushHeights, HEIGHTS_MS) // a throttle, not a debounce: a board settling in waves still writes
|
|
404
412
|
}
|
|
405
|
-
async function flushHeights() {
|
|
413
|
+
async function flushHeights(): Promise<void> {
|
|
406
414
|
heightsTimer = undefined
|
|
407
|
-
if (flushing
|
|
415
|
+
if (flushing) return flushing
|
|
416
|
+
if (!pendingHeights.size) return
|
|
408
417
|
if (canvasStopped()) return // held until the canvas answers again (A1.11): the resume flushes them
|
|
409
|
-
|
|
418
|
+
let done = () => {}
|
|
419
|
+
flushing = new Promise<void>((r) => { done = r })
|
|
410
420
|
const batch = Object.fromEntries([...pendingHeights].slice(0, 500))
|
|
411
421
|
for (const [k, v] of Object.entries(batch)) { pendingHeights.delete(k); inflightHeights.set(k, v) }
|
|
412
422
|
let answered = false
|
|
@@ -419,13 +429,26 @@ async function flushHeights() {
|
|
|
419
429
|
}
|
|
420
430
|
} catch { /* lost: below */ }
|
|
421
431
|
// no answer = the write may or may not have landed: what the file holds is unknown, so nothing is
|
|
422
|
-
// deduplicated against it - a correction queued meanwhile still goes, the next report still writes
|
|
423
|
-
|
|
432
|
+
// deduplicated against it - a correction queued meanwhile still goes, the next report still writes.
|
|
433
|
+
// Each of its heights is owed again, unless a newer one for that key is already queued
|
|
434
|
+
if (!answered) for (const [k, v] of Object.entries(batch)) { savedHeights.delete(k); if (!pendingHeights.has(k)) pendingHeights.set(k, v) }
|
|
424
435
|
for (const k of Object.keys(batch)) inflightHeights.delete(k)
|
|
425
436
|
// a height that settled while the write was in flight: still owed only if it differs from what landed
|
|
426
437
|
for (const [k, v] of pendingHeights) if (savedHeights.get(k) === v) pendingHeights.delete(k)
|
|
427
|
-
|
|
428
|
-
|
|
438
|
+
heightsFailed = answered ? 0 : Math.min(heightsFailed + 1, 5)
|
|
439
|
+
flushing = null
|
|
440
|
+
workChanged()
|
|
441
|
+
if (pendingHeights.size) heightsTimer ??= setTimeout(flushHeights, HEIGHTS_MS * 2 ** Math.max(0, heightsFailed - 1))
|
|
442
|
+
done()
|
|
443
|
+
}
|
|
444
|
+
/** Every height this page measured is in the file: none queued, none in flight. */
|
|
445
|
+
const heightsSaved = () => !pendingHeights.size && !inflightHeights.size
|
|
446
|
+
/** The resume's turn (A1.11): the write in flight answers first, then what is queued goes now - unless it is waiting
|
|
447
|
+
* out a failure's backoff, which its own timer sends. True once every height is in the file. */
|
|
448
|
+
async function settleHeights(): Promise<boolean> {
|
|
449
|
+
await flushing
|
|
450
|
+
if (pendingHeights.size && !(heightsFailed && heightsTimer)) { clearTimeout(heightsTimer); await flushHeights() }
|
|
451
|
+
return heightsSaved()
|
|
429
452
|
}
|
|
430
453
|
|
|
431
454
|
const hasKnownHeight = (frameId: string, w: number) => measures(frameId) && (measuredHeights.has(`${frameId}@${w}`) || savedNow().has(`${frameId}@${w}`))
|
|
@@ -2120,7 +2143,7 @@ export const useStore = create<State>((set, get) => {
|
|
|
2120
2143
|
// renamed/deleted externally - drop the write, don't recreate it or loop
|
|
2121
2144
|
set({ dirty: false })
|
|
2122
2145
|
get().toast(BOARD_GONE)
|
|
2123
|
-
lostInResume('gone') // a resume
|
|
2146
|
+
lostInResume('gone') // a save while a resume is owed: the page after its reload says this, not "saved"
|
|
2124
2147
|
return true
|
|
2125
2148
|
}
|
|
2126
2149
|
const reloaded = await get().boot() // hash advances only when the authoritative reload commits
|
|
@@ -2131,7 +2154,7 @@ export const useStore = create<State>((set, get) => {
|
|
|
2131
2154
|
const { sha256 } = await res.json()
|
|
2132
2155
|
// an edit that landed after this save started keeps dirty set for the next save
|
|
2133
2156
|
set({ boardHash: sha256, ...(editRev === rev ? { dirty: false } : {}) })
|
|
2134
|
-
savedInResume() // a resume's
|
|
2157
|
+
savedInResume() // a save while a resume is owed (the resume's, or this autosave): the page after its reload says the edits were saved
|
|
2135
2158
|
return true
|
|
2136
2159
|
}
|
|
2137
2160
|
return false
|
|
@@ -2157,11 +2180,14 @@ beforeResume(async () => {
|
|
|
2157
2180
|
const s = () => useStore.getState()
|
|
2158
2181
|
if (s().gesture) return false
|
|
2159
2182
|
for (let i = 0; i < 5 && s().dirty; i++) if (!(await s().save())) break
|
|
2160
|
-
|
|
2161
|
-
|
|
2183
|
+
// heights a write did not land (a 500, no answer) hold the reload too: queued again, they go on their timer while
|
|
2184
|
+
// the page works as live, and it reloads the second after they reach the file
|
|
2185
|
+
const heights = await settleHeights()
|
|
2186
|
+
return heights && !s().dirty && !s().gesture
|
|
2162
2187
|
})
|
|
2163
|
-
// and an edit made,
|
|
2164
|
-
|
|
2188
|
+
// and an edit made, a drag begun, or a height measured or sent back to the queue while that save was on its way holds
|
|
2189
|
+
// the reload as well
|
|
2190
|
+
holdsReload(() => { const s = useStore.getState(); return s.dirty || !!s.gesture || !heightsSaved() })
|
|
2165
2191
|
// while stopped, the banner says "your unsaved edits are kept" from the edit that makes some
|
|
2166
2192
|
useStore.subscribe((s, p) => { if ((s.dirty !== p.dirty || s.gesture !== p.gesture) && canvasStopped()) noteUnsaved() })
|
|
2167
2193
|
onLinkNotice((text) => useStore.getState().toast(text))
|
|
@@ -2172,12 +2198,14 @@ export function stoppedFor(what: string): boolean {
|
|
|
2172
2198
|
useStore.getState().toast(`${what} - ${STOPPED_WAY}`)
|
|
2173
2199
|
return true
|
|
2174
2200
|
}
|
|
2175
|
-
// a
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2201
|
+
// spec 28 A2.9: leaving a page that holds a board edit not on disk yet - dirty, a save in flight or one that failed -
|
|
2202
|
+
// or heights not written yet asks first (unsaved.ts's one beforeunload), live or stopped; the Mac app hears it too.
|
|
2203
|
+
// A drag is not work until it drops. A published canvas keeps its pins and sizes in the session: nothing to lose
|
|
2204
|
+
if (!PUBLISHED) {
|
|
2205
|
+
unsavedWhen('board-unsaved', () => useStore.getState().dirty)
|
|
2206
|
+
unsavedWhen('heights', () => !heightsSaved())
|
|
2207
|
+
useStore.subscribe((s, p) => { if (s.dirty !== p.dirty) workChanged() })
|
|
2208
|
+
}
|
|
2181
2209
|
|
|
2182
2210
|
// dev-only inspection hook for tests/debugging (never installed in published builds)
|
|
2183
2211
|
if (import.meta.env.DEV) (window as unknown as { __mvStore: unknown }).__mvStore = useStore
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Light board -> light glass chrome over a paper canvas; dark board -> dark glass
|
|
3
3
|
chrome over a dark canvas. Frames are cards; chrome is glass. */
|
|
4
4
|
|
|
5
|
+
/* @tokens */
|
|
6
|
+
/* The token block (spec 28 A2.2, A2.9): the Mac app copies everything between these two markers into its own pages
|
|
7
|
+
at build time (app/scripts/tokens.mjs, rewritten onto :root), so its strip and pages wear exactly this glass. */
|
|
5
8
|
.sh-app {
|
|
6
9
|
--ground: #e7e9ef; --dot: #c9cbd5;
|
|
7
10
|
--accent: #0088ff; --accent-ring: rgba(0, 136, 255, .2); --beam: rgba(0, 136, 255, .42); --beam-blur: 6px; --beam-bottom: -13px; --beam-h: 12px; --beam-inset: 12%; --edge-accent: rgba(0, 136, 255, .8); --inner-tint: rgba(0, 136, 255, .13); --tip-bg: #18181b; --tip-ink: #fafafa; --accent-wash: rgba(0, 136, 255, .07);
|
|
@@ -102,6 +105,17 @@
|
|
|
102
105
|
@property --glass-accent { syntax: '<color>'; inherits: true; initial-value: #0077e6; }
|
|
103
106
|
@property --glass-accent-bg { syntax: '<color>'; inherits: true; initial-value: rgba(0, 136, 255, .13); }
|
|
104
107
|
|
|
108
|
+
/* Reduce Transparency and Increase Contrast (spec 28 A2.9, A2.13): every glass surface opaque - its fill the solid
|
|
109
|
+
one, its border the node's, no blur - in both themes (the dark rule's own specificity, later in the file); and
|
|
110
|
+
with more contrast the dimmer inks take the full one. macOS's settings reach Chrome too. */
|
|
111
|
+
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
|
|
112
|
+
.sh-app, .sh-app.dark { --glass: var(--solid); --glass-brd: var(--node-brd); --blur: none; }
|
|
113
|
+
}
|
|
114
|
+
@media (prefers-contrast: more) {
|
|
115
|
+
.sh-app, .sh-app.dark { --glass-ink-2: var(--glass-ink); --glass-ink-3: var(--glass-ink); }
|
|
116
|
+
}
|
|
117
|
+
/* @end-tokens */
|
|
118
|
+
|
|
105
119
|
/* interact mode: the whole shell shifts to the interactive purple - one token override,
|
|
106
120
|
and every accent-derived surface (mark, sidebar actives, selection bar, beams, rings,
|
|
107
121
|
handles, device chips) follows without knowing the mode exists */
|
|
@@ -150,6 +164,21 @@ button svg { pointer-events: none } /* event targets stay on the button - pan
|
|
|
150
164
|
background-size: var(--grid-size, 20px 20px);
|
|
151
165
|
background-position: var(--grid-pos, 0 0);
|
|
152
166
|
opacity: var(--grid-alpha, 1) }
|
|
167
|
+
/* the scroll edge (0.27.2, spec 28 A2.9 v1.8 #8, A3.8 #31): under the Mac app's transparent strip only (App.tsx renders
|
|
168
|
+
it when inset.ts's TOP is 44). One band over the world and under the chrome (z 9; the panels are 10): opaque ground
|
|
169
|
+
through --mv-top, fading out over 16 px more, the dots drawn from the same three grid variables paintGrid writes on
|
|
170
|
+
.sh-app - so nothing of a frame shows under the tabs, and a frame panned up fades out below them while the dots run
|
|
171
|
+
on. The grid's alpha reaches the dots only. The world itself carries no mask (one would add a render surface to every
|
|
172
|
+
frame). */
|
|
173
|
+
.sh-edge { position: absolute; left: 0; right: 0; top: 0; height: calc(var(--mv-top, 0px) + 16px); z-index: 9; pointer-events: none;
|
|
174
|
+
background: var(--ground);
|
|
175
|
+
-webkit-mask-image: linear-gradient(#000 0 var(--mv-top, 0px), transparent calc(var(--mv-top, 0px) + 16px));
|
|
176
|
+
mask-image: linear-gradient(#000 0 var(--mv-top, 0px), transparent calc(var(--mv-top, 0px) + 16px)) }
|
|
177
|
+
.sh-edge::before { content: ''; position: absolute; inset: 0;
|
|
178
|
+
background-image: radial-gradient(var(--dot) 1px, transparent 1px);
|
|
179
|
+
background-size: var(--grid-size, 20px 20px);
|
|
180
|
+
background-position: var(--grid-pos, 0 0);
|
|
181
|
+
opacity: var(--grid-alpha, 1) }
|
|
153
182
|
.sh-content { will-change: auto }
|
|
154
183
|
#sh-world { position: relative; width: 1px; height: 1px }
|
|
155
184
|
#sh-world.sh-gesturing .sh-live { pointer-events: none } /* law G-4 */
|
|
@@ -434,8 +463,10 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
434
463
|
.sh-ibtn:hover { background: var(--glass-hover); color: var(--glass-ink) }
|
|
435
464
|
|
|
436
465
|
/* floating glass panel; collapses into the fab with a scale-fade morph */
|
|
437
|
-
|
|
438
|
-
|
|
466
|
+
/* The floating chrome sits at the larger of the edge and the app's top inset (Nic, 26 Oct): in the Mac app the strip's own
|
|
467
|
+
padding is the gap, so nothing stacks the edge under it; in a browser --mv-top is 0 and the edge holds, as before. */
|
|
468
|
+
.sh-panel { position: absolute; left: var(--edge); top: max(var(--edge), var(--mv-top, 0px)); width: 236px;
|
|
469
|
+
max-height: calc(100% - var(--edge) - max(var(--edge), var(--mv-top, 0px))); z-index: 10;
|
|
439
470
|
border-radius: var(--r-panel); padding: 10px; display: flex; flex-direction: column;
|
|
440
471
|
font-size: 13px; color: var(--glass-ink);
|
|
441
472
|
transform-origin: 22px 22px; transition: transform var(--morph), opacity .2s ease }
|
|
@@ -559,7 +590,7 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
559
590
|
.sh-panel .sub.dim:hover { background: none; color: var(--glass-ink-3) }
|
|
560
591
|
|
|
561
592
|
/* collapsed panel: a round glass button; morphs against the panel */
|
|
562
|
-
.sh-fab { position: absolute; left: var(--edge); top: var(--edge); z-index: 11; width: 44px; height: 44px;
|
|
593
|
+
.sh-fab { position: absolute; left: var(--edge); top: max(var(--edge), var(--mv-top, 0px)); z-index: 11; width: 44px; height: 44px;
|
|
563
594
|
display: grid; place-items: center; border-radius: 999px;
|
|
564
595
|
color: var(--glass-ink-2); cursor: pointer;
|
|
565
596
|
transition: transform var(--morph), opacity .2s ease }
|
|
@@ -568,13 +599,13 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
568
599
|
|
|
569
600
|
/* pill nav */
|
|
570
601
|
/* uniform 5px inset on every side: 34px buttons + 2*5px = 44px, same as the fab */
|
|
571
|
-
.sh-pill { position: absolute; right: var(--edge); top: var(--edge); z-index: 10; display: flex; align-items: center; gap: 1px;
|
|
602
|
+
.sh-pill { position: absolute; right: var(--edge); top: max(var(--edge), var(--mv-top, 0px)); z-index: 10; display: flex; align-items: center; gap: 1px;
|
|
572
603
|
border-radius: 999px; padding: 5px;
|
|
573
604
|
transform-origin: calc(100% - 22px) 22px; transition: transform var(--morph), opacity .2s ease }
|
|
574
605
|
.sh-pill.closed { transform: scale(.16); opacity: 0; pointer-events: none }
|
|
575
606
|
/* the pill's expand chip - the sidebar fab, mirrored top-right: same glass (shared
|
|
576
607
|
surface rule above), same morph, the bar shrinking into the chip's spot */
|
|
577
|
-
.sh-pill-fab { position: absolute; right: var(--edge); top: var(--edge); z-index: 11; width: 44px; height: 44px;
|
|
608
|
+
.sh-pill-fab { position: absolute; right: var(--edge); top: max(var(--edge), var(--mv-top, 0px)); z-index: 11; width: 44px; height: 44px;
|
|
578
609
|
display: grid; place-items: center; border-radius: 999px;
|
|
579
610
|
color: var(--glass-ink-2); cursor: pointer;
|
|
580
611
|
transition: transform var(--morph), opacity .2s ease }
|
|
@@ -606,7 +637,7 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
606
637
|
.sh-menu button span { flex: 1; text-transform: capitalize }
|
|
607
638
|
/* the sidebar right-click menu keeps its labels verbatim (they match the toolbar exactly);
|
|
608
639
|
it scrolls rather than overflowing the window when the folder list grows long */
|
|
609
|
-
.sh-ctxmenu { max-height: calc(100vh - 16px); max-width: 240px; overflow-y: auto; scrollbar-width: thin }
|
|
640
|
+
.sh-ctxmenu { max-height: calc(100vh - 16px - var(--mv-top, 0px)); max-width: 240px; overflow-y: auto; scrollbar-width: thin }
|
|
610
641
|
.sh-ctxmenu button { flex: none; max-width: 100% }
|
|
611
642
|
.sh-ctxmenu button span { text-transform: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0 }
|
|
612
643
|
.sh-menu .chk { color: var(--glass-accent) }
|
|
@@ -649,7 +680,7 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
649
680
|
/* a lane tile's whole title: wraps past one line, never wider than a short paragraph */
|
|
650
681
|
.sh-tip .jm-tip-title { display: block; max-width: 320px; white-space: normal; line-height: 16px }
|
|
651
682
|
/* a status's tooltip: the status, then where it came from - each piece of evidence on its own line */
|
|
652
|
-
.sh-tip .sh-tip-lines { display: flex; flex-direction: column; gap: 2px; max-width: 420px; max-height: calc(100vh - 32px); overflow: hidden; white-space: normal }
|
|
683
|
+
.sh-tip .sh-tip-lines { display: flex; flex-direction: column; gap: 2px; max-width: 420px; max-height: calc(100vh - 32px - var(--mv-top, 0px)); overflow: hidden; white-space: normal }
|
|
653
684
|
/* read by a screen reader, never seen: what a glyph says to the eye */
|
|
654
685
|
.sh-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0 }
|
|
655
686
|
.sh-tip .sh-tip-lines small { opacity: .62; font-size: 11px; line-height: 1.35; overflow-wrap: anywhere }
|
|
@@ -742,7 +773,7 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
742
773
|
|
|
743
774
|
/* ---- Play mode: near-black stage, one centered device, auto-hiding bar.
|
|
744
775
|
Fixed dark palette - the backdrop never follows the board theme, so no tokens here. */
|
|
745
|
-
.sh-play { position: absolute; inset: 0; z-index: 30; background: #0a0a0b; display: flex;
|
|
776
|
+
.sh-play { position: absolute; inset: 0; z-index: 30; background: #0a0a0b; display: flex; padding-top: var(--mv-top, 0px);
|
|
746
777
|
align-items: center; justify-content: center; animation: sh-play-in .28s ease-out; cursor: auto }
|
|
747
778
|
@keyframes sh-play-in { from { opacity: 0 } }
|
|
748
779
|
/* the device wears the frame-node card language: same theme border tokens, the same
|
|
@@ -773,7 +804,10 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
773
804
|
.sh-play.fill .dev { border-radius: 0; box-shadow: none; transition: none }
|
|
774
805
|
.sh-play.fill .dev::after { display: none }
|
|
775
806
|
|
|
776
|
-
/* the two floating chrome pieces share one glass language and one idle behavior
|
|
807
|
+
/* the two floating chrome pieces share one glass language and one idle behavior. Of them only .sh-play-nav is still
|
|
808
|
+
rendered: play's top chrome is the shared pill (Play.tsx: nav.sh-pill.sh-play-pill, .sh-pill-fab), which takes the
|
|
809
|
+
Mac app's inset through .sh-pill's own rule - .sh-play-bar, its menu and .sh-play-chip below are unused, left as
|
|
810
|
+
they were */
|
|
777
811
|
.sh-play-bar, .sh-play-nav { position: absolute; display: flex; align-items: center; gap: 1px;
|
|
778
812
|
padding: 4px; border-radius: 999px;
|
|
779
813
|
background: rgba(18, 18, 24, .82); border: 1px solid rgba(255, 255, 255, .12);
|
|
@@ -1121,6 +1155,8 @@ body.sh-hide-ui .sh-play-nav { display: none !important }
|
|
|
1121
1155
|
@keyframes sh-tstat-pop { from { opacity: 0; transform: translateY(-3px) } }
|
|
1122
1156
|
.cm-tstat-pop { animation-name: sh-tstat-pop }
|
|
1123
1157
|
.cm-tstat-pop .sh-tip-lines { display: flex; flex-direction: column; gap: 2px; white-space: normal; min-width: 0 }
|
|
1158
|
+
.cm-tstat-pop.many { flex-wrap: wrap; row-gap: 6px } /* a stalled run's three choices wrap under its lines */
|
|
1159
|
+
.cm-tstat-pop.many .sh-tip-lines { flex-basis: 100% }
|
|
1124
1160
|
.cm-tstat-pop .sh-tip-lines b { font-weight: 600; font-size: 12px; letter-spacing: 0; white-space: normal; overflow: visible; text-overflow: clip; max-width: none; color: inherit }
|
|
1125
1161
|
.cm-tstat-pop .sh-tip-lines small { opacity: .62; font-size: 11px; line-height: 1.35 }
|
|
1126
1162
|
.cm-tstat-act { flex: none; height: 24px; padding: 0 10px; border: 0; border-radius: 6px; cursor: pointer;
|
|
@@ -1254,7 +1290,7 @@ body.sh-hide-ui .sh-play-nav { display: none !important }
|
|
|
1254
1290
|
.sh-tip .cm-meta-row b { font-weight: 600; opacity: 1; margin: 0; color: var(--tip-ink) } /* value: bold, full-bright */
|
|
1255
1291
|
.sh-tip .cm-meta-row .k { margin: 0; opacity: .5; font-weight: 500; color: var(--tip-ink) } /* label: muted qualifier */
|
|
1256
1292
|
/* identity modal - same glass family */
|
|
1257
|
-
.cm-modal-wrap { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center;
|
|
1293
|
+
.cm-modal-wrap { position: fixed; inset: var(--mv-top, 0px) 0 0 0; z-index: 300; display: flex; align-items: center; justify-content: center;
|
|
1258
1294
|
background: rgba(24,24,27,.45); backdrop-filter: blur(5px) }
|
|
1259
1295
|
/* the auth modal is a focused surface, not a floating glass panel - near-solid so
|
|
1260
1296
|
the canvas behind never bleeds through the fields */
|
|
@@ -1553,7 +1589,7 @@ body.sh-commenting .sh-sticky-body { cursor: crosshair }
|
|
|
1553
1589
|
.sh-pill-btn.jm-jam .jm-nomic { color: var(--glass-ink-2) }
|
|
1554
1590
|
|
|
1555
1591
|
/* ---- a capture's tile (round 3): two lines, a little squarer - glyph | title over a status line
|
|
1556
|
-
("Ready to review", "
|
|
1592
|
+
("Ready to review", "Claude Code is working · 0:41", "Done · 1 frame changed"). Colour only in the glyph. ---- */
|
|
1557
1593
|
.jm-card { display: inline-flex; align-items: center; gap: 10px; height: 44px; width: 216px; flex: none; /* one width: a tile never resizes */
|
|
1558
1594
|
padding: 0 14px 0 12px; border-radius: 10px; color: var(--glass-ink); text-align: left; cursor: pointer }
|
|
1559
1595
|
.jm-card .jm-st { flex: none }
|
|
@@ -1586,7 +1622,7 @@ body.sh-commenting .sh-sticky-body { cursor: crosshair }
|
|
|
1586
1622
|
.jm-rename input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring) }
|
|
1587
1623
|
|
|
1588
1624
|
/* ---- the capture: an edge ring round the window, the chip, the caption, points ---- */
|
|
1589
|
-
.jm-edge { position: absolute; inset: 0; pointer-events: none; z-index: 40;
|
|
1625
|
+
.jm-edge { position: absolute; inset: var(--mv-top, 0px) 0 0 0; pointer-events: none; z-index: 40;
|
|
1590
1626
|
box-shadow: inset 0 0 0 2px var(--jm-rec), inset 0 0 0 6px var(--jm-rec-ring) }
|
|
1591
1627
|
/* the capture recording NOW (round 3): the last tile of the lane, two lines like the others - a pulsing
|
|
1592
1628
|
teal dot, "Capturing" and the timer over what it holds so far - then Stop. A little wider, never cut. */
|
|
@@ -1765,6 +1801,9 @@ body.sh-commenting .sh-sticky-body { cursor: crosshair }
|
|
|
1765
1801
|
.jm-chip .stop svg { display: none }
|
|
1766
1802
|
.jm-chip .stop::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--jm-rec); flex: none }
|
|
1767
1803
|
.jm-chip .stop:disabled::before { background: var(--glass-ink-3) }
|
|
1804
|
+
.jm-chip .stop.review::before { display: none }
|
|
1805
|
+
.jm-chip .stop.review svg { display: block; color: var(--jm-rec) }
|
|
1806
|
+
.jm-chip .stop.review:disabled svg { color: var(--glass-ink-3) }
|
|
1768
1807
|
.jm-stage .jm-chip { height: 40px; padding: 0 5px 0 14px; border-radius: 999px; background: rgba(18, 18, 24, .82);
|
|
1769
1808
|
border: 1px solid rgba(255, 255, 255, .12); box-shadow: none; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px) }
|
|
1770
1809
|
.jm-stage .jm-chip .note, .jm-stage .jm-chip .stop { height: 30px; border-radius: 999px }
|
|
@@ -1810,7 +1849,7 @@ body.sh-commenting .sh-sticky-body { cursor: crosshair }
|
|
|
1810
1849
|
.jm-notefield .caret { display: inline-block; width: 1px; height: 15px; background: var(--accent); vertical-align: -3px; margin-left: 1px }
|
|
1811
1850
|
.jm-notes .foot { display: flex; gap: 12px; justify-content: flex-end; font: 500 11px -apple-system, system-ui, sans-serif; color: var(--glass-ink-3) }
|
|
1812
1851
|
/* the focus panel: top edge to just above the lane; the panel inside fills it and its middle scrolls */
|
|
1813
|
-
.jm-focus { position: absolute; top: var(--edge); bottom: calc(var(--edge) + var(--jm-lane) + 2px); z-index: 31; display: flex }
|
|
1852
|
+
.jm-focus { position: absolute; top: max(var(--edge), var(--mv-top, 0px)); bottom: calc(var(--edge) + var(--jm-lane) + 2px); z-index: 31; display: flex }
|
|
1814
1853
|
.jm-focus > .jm-panel { width: 100%; height: 100%; min-height: 0 }
|
|
1815
1854
|
/* one big picture at a time: the frame tabs and a Before | After switch above it (B flips) */
|
|
1816
1855
|
.jm-fbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap } /* a narrow window wraps the switch under the tabs */
|
|
@@ -1831,7 +1870,13 @@ body.sh-commenting .sh-sticky-body { cursor: crosshair }
|
|
|
1831
1870
|
.jm-ftabs button.on { background: var(--solid); color: var(--glass-ink); font-weight: 600; box-shadow: 0 1px 2px rgba(24, 24, 27, .12), 0 0 0 .5px var(--glass-brd) }
|
|
1832
1871
|
.jm-focus > .jm-readback .jm-thumbs { gap: 12px }
|
|
1833
1872
|
/* the review's big picture sits centred in a quiet well that takes the panel's spare height */
|
|
1834
|
-
.jm-focus .jm-big { align-items: center; padding:
|
|
1873
|
+
.jm-focus .jm-big { align-items: center; padding: 14px 16px 16px; border-radius: 14px; background: #0a0a0b }
|
|
1874
|
+
/* the pictures sit on the play-mode stage (Nic, 27 Oct): dark in both themes, so the frames read apart from the panel */
|
|
1875
|
+
.jm-focus .jm-big.pair { gap: 16px }
|
|
1876
|
+
.jm-focus .jm-big.pair .jm-shot { gap: 8px }
|
|
1877
|
+
.jm-focus .jm-big.pair .jm-shot .cap { color: rgba(255, 255, 255, .86) }
|
|
1878
|
+
.jm-focus .jm-big .jm-shot .pic img { box-shadow: 0 0 0 1px rgba(255, 255, 255, .1), 0 6px 20px -8px rgba(0, 0, 0, .6) }
|
|
1879
|
+
.jm-focus .jm-big .jm-shot .pic.none { border-color: rgba(255, 255, 255, .28); color: rgba(255, 255, 255, .6) }
|
|
1835
1880
|
/* in play the Note button is a pill like Stop beside it (the navigator material) */
|
|
1836
1881
|
.jm-stage .jm-chip .notebtn { height: 30px; border-radius: 999px; padding: 0 11px }
|
|
1837
1882
|
|
|
@@ -1884,14 +1929,14 @@ button.jm-link { padding: 0; border: 0; background: none; text-align: left; widt
|
|
|
1884
1929
|
|
|
1885
1930
|
/* Jam V2: while the lane shows, the sidebar stops above it and the bottom edge rises one lane - the
|
|
1886
1931
|
Update pill, toasts and notices (LANE_H, jam-lane.tsx) */
|
|
1887
|
-
.sh-app.jm-lane-on .sh-panel { max-height: calc(100% -
|
|
1932
|
+
.sh-app.jm-lane-on .sh-panel { max-height: calc(100% - var(--edge) - 56px - max(var(--edge), var(--mv-top, 0px))); bottom: auto }
|
|
1888
1933
|
.sh-app.jm-lane-on .sh-update { bottom: calc(var(--edge) + 56px) }
|
|
1889
1934
|
.sh-app.jm-lane-on .sh-toasts { bottom: calc(var(--edge) + 56px) }
|
|
1890
1935
|
.sh-app.jm-lane-on .sh-banner { bottom: calc(var(--edge) + 56px) }
|
|
1891
1936
|
/* the canvas stopped (spec 28 A1.11): on the toolbar's centre line in the gap between the sidebar and the
|
|
1892
1937
|
toolbar, or just below the toolbar row - placed by the shell (App.tsx placeBanner), which measures both; above
|
|
1893
1938
|
play and focus. The fallback before it measures: top centre, on the line (34px tall, the row 46px) */
|
|
1894
|
-
.sh-app .sh-banner.sh-stopped { top: calc(var(--edge) + 6px); bottom: auto; left: 50%; right: auto; transform: translateX(-50%);
|
|
1939
|
+
.sh-app .sh-banner.sh-stopped { top: calc(max(var(--edge), var(--mv-top, 0px)) + 6px); bottom: auto; left: 50%; right: auto; transform: translateX(-50%);
|
|
1895
1940
|
z-index: 40; width: max-content; max-width: none; white-space: nowrap; text-align: center; text-wrap: balance; pointer-events: auto }
|
|
1896
1941
|
.sh-banner.sh-stopped code { font: 500 11.5px/14px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 5px; border-radius: 5px;
|
|
1897
1942
|
background: color-mix(in srgb, currentColor 11%, transparent); white-space: nowrap }
|
|
@@ -2001,8 +2046,11 @@ button.jm-link { padding: 0; border: 0; background: none; text-align: left; widt
|
|
|
2001
2046
|
.jm-panel button.row:hover { background: var(--glass-hover) }
|
|
2002
2047
|
textarea.jm-field { width: 100%; resize: none; outline: none; overflow: hidden; display: block }
|
|
2003
2048
|
textarea.jm-field:focus { border-color: transparent; box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-ring) }
|
|
2004
|
-
.jm-sheet-at { position: absolute; right: var(--edge); top:
|
|
2049
|
+
.jm-sheet-at { position: absolute; right: var(--edge); top: calc(max(var(--edge), var(--mv-top, 0px)) + 54px); z-index: 42 }
|
|
2005
2050
|
.jm-sheet .rows, .jm-wrapup .rows { margin: 0 -8px }
|
|
2051
|
+
/* a row with a second line (who works, the switches): air between rows, the line under the name kept to one line */
|
|
2052
|
+
.jm-sheet .rows .row:has(small) { padding-top: 5px; padding-bottom: 5px; line-height: 1.25 }
|
|
2053
|
+
.jm-sheet .rows .row.jm-two small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; max-width: 200px; vertical-align: top }
|
|
2006
2054
|
.jm-sc-row { position: relative; cursor: default; outline: none }
|
|
2007
2055
|
.jm-record-panel .jm-body { overflow: auto }
|
|
2008
2056
|
.jm-record-panel .jm-record { white-space: pre-wrap; overflow-wrap: anywhere }
|
package/src/client/shell/tidy.ts
CHANGED
|
@@ -22,8 +22,9 @@ export type Warn = (msg: string) => void
|
|
|
22
22
|
|
|
23
23
|
const isSpace = (x: unknown): x is Space => !!x && typeof x === 'object' && !Array.isArray(x)
|
|
24
24
|
/** Drop the items `isGone` names, each with the spacer that led into it (or, at the start, the
|
|
25
|
-
* one that followed it) - what is left reads as if the item was never there.
|
|
26
|
-
|
|
25
|
+
* one that followed it) - what is left reads as if the item was never there. (`boards place` takes a frame out of a
|
|
26
|
+
* scene recipe the same way.) */
|
|
27
|
+
export function dropGone<T>(items: T[], isGone: (x: T) => boolean): T[] {
|
|
27
28
|
const out: T[] = []
|
|
28
29
|
let skip = false
|
|
29
30
|
for (const it of items) {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What this page holds that is not on the server yet, and what it is busy with (spec 28 A2.9, A2.14 #18): one
|
|
3
|
+
* registry of reasons, read by one `beforeunload` - so Chrome asks before a reload or a close loses any of them, not
|
|
4
|
+
* only a capture being recorded - and, in the Mac app, by the shell's `mv:busy` (app-bridge.ts), which the app's guard
|
|
5
|
+
* trusts before it closes, reloads or replaces the page.
|
|
6
|
+
*
|
|
7
|
+
* Beside A1's `holdsReload` (api.ts), which keeps meaning "this page may not reload itself now" and drives the
|
|
8
|
+
* stopped banner: the two ask much the same questions, and each keeps its own job.
|
|
9
|
+
*
|
|
10
|
+
* The reasons are the contract's (`src/shared/app-api.ts`): unsaved - `capture-recording`, `capture-unsent` (sealed,
|
|
11
|
+
* not taken by the server yet, memory-only ones included), `board-unsaved` (a dirty board: a save in flight or
|
|
12
|
+
* failed keeps it dirty), `heights`, `typing` (words typed and not sent); busy but not unsaved - `jam-session`,
|
|
13
|
+
* `microphone`, `agent`. A drag is not work: it becomes `board-unsaved` on drop.
|
|
14
|
+
*
|
|
15
|
+
* No imports but the contract's types: a unit test drives it without a page.
|
|
16
|
+
*/
|
|
17
|
+
import { UNSAVED_WHY, WHY, type Why } from '../../shared/app-api.ts'
|
|
18
|
+
|
|
19
|
+
export type UnsavedWhy = (typeof UNSAVED_WHY)[number]
|
|
20
|
+
export type BusyWhy = Exclude<Why, UnsavedWhy>
|
|
21
|
+
|
|
22
|
+
const reasons = new Map<Why, Set<() => boolean>>()
|
|
23
|
+
/** A check that throws holds: what it guards is not known to be safe. */
|
|
24
|
+
const holds = (fn: () => boolean): boolean => { try { return !!fn() } catch { return true } }
|
|
25
|
+
const on = (why: Why): boolean => [...(reasons.get(why) ?? [])].some(holds)
|
|
26
|
+
export const isUnsaved = (why: Why): why is UnsavedWhy => (UNSAVED_WHY as readonly Why[]).includes(why)
|
|
27
|
+
|
|
28
|
+
function register(why: Why, fn: () => boolean): () => void {
|
|
29
|
+
let set = reasons.get(why)
|
|
30
|
+
if (!set) reasons.set(why, set = new Set())
|
|
31
|
+
set.add(fn)
|
|
32
|
+
workChanged()
|
|
33
|
+
return () => { set!.delete(fn); workChanged() }
|
|
34
|
+
}
|
|
35
|
+
/** Unsaved work of this kind while `fn` answers true. Returns the unregister. */
|
|
36
|
+
export const unsavedWhen = (why: UnsavedWhy, fn: () => boolean) => register(why, fn)
|
|
37
|
+
/** Busy (not unsaved) while `fn` answers true: a Jam session, the microphone, an agent at work. */
|
|
38
|
+
export const busyWhen = (why: BusyWhy, fn: () => boolean) => register(why, fn)
|
|
39
|
+
|
|
40
|
+
/** Every reason that holds now, in the contract's order. */
|
|
41
|
+
export const busyWhy = (): Why[] => WHY.filter(on)
|
|
42
|
+
/** The unsaved reasons that hold now. */
|
|
43
|
+
export const unsavedWhy = (): UnsavedWhy[] => UNSAVED_WHY.filter(on)
|
|
44
|
+
/** Does this page hold anything not on the server yet? */
|
|
45
|
+
export const hasUnsavedWork = (): boolean => UNSAVED_WHY.some(on)
|
|
46
|
+
|
|
47
|
+
const listeners = new Set<() => void>()
|
|
48
|
+
let queued = false
|
|
49
|
+
/** A reason may have changed: every listener hears it once, a microtask later (a burst of changes is one). */
|
|
50
|
+
export function workChanged(): void {
|
|
51
|
+
if (queued || !listeners.size) return
|
|
52
|
+
queued = true
|
|
53
|
+
queueMicrotask(() => { queued = false; for (const fn of [...listeners]) { try { fn() } catch { /* the rest still hear */ } } })
|
|
54
|
+
}
|
|
55
|
+
export const onWorkChange = (fn: () => void): (() => void) => { listeners.add(fn); return () => { listeners.delete(fn) } }
|
|
56
|
+
|
|
57
|
+
// ---- leaving --------------------------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
let leaving = false
|
|
60
|
+
let rearm: ReturnType<typeof setTimeout> | undefined
|
|
61
|
+
/** The page's own reload - A1's resume, once its canvas is back and what it held is saved - goes without asking
|
|
62
|
+
* itself. Should the reload not happen after all (a frame refused it), the guard is back a second later. */
|
|
63
|
+
export function leaveNow(go: () => void): void {
|
|
64
|
+
leaving = true
|
|
65
|
+
clearTimeout(rearm)
|
|
66
|
+
rearm = setTimeout(() => { leaving = false }, 1000)
|
|
67
|
+
go()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Would the guard ask before this page goes? */
|
|
71
|
+
export const asksBeforeLeaving = (): boolean => !leaving && hasUnsavedWork()
|
|
72
|
+
|
|
73
|
+
/** The one `beforeunload` (it replaces the store's stopped-and-dirty one and the capture's recording one). Chrome shows
|
|
74
|
+
* its question only on a page that had a gesture since it loaded; the Mac app does not rely on it (A2.14 #16). */
|
|
75
|
+
export function guardLeaving(target: EventTarget): void {
|
|
76
|
+
target.addEventListener('beforeunload', (e) => {
|
|
77
|
+
if (!asksBeforeLeaving()) return
|
|
78
|
+
e.preventDefault()
|
|
79
|
+
try { (e as BeforeUnloadEvent).returnValue = '' } catch { /* not every engine has it */ }
|
|
80
|
+
})
|
|
81
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The white-out detector's probes, the shell's half (spec 28 A3.3, A3.8 #16): up to 16 points of empty canvas
|
|
3
|
+
* background, picked geometrically before main captures and checked again after. Owner: the flash stream.
|
|
4
|
+
*
|
|
5
|
+
* During a gesture frames take no pointer events (styles.css ~169), so hit-testing alone would take a white frame
|
|
6
|
+
* for ground: `pick(tick)` takes grid points inside `usable()` below `VISIBLE_TOP` (inset.ts), each at least 48 px
|
|
7
|
+
* from every `.sh-node`'s screen rect, with the canvas surface under it; `verify(tick)` says which are still valid -
|
|
8
|
+
* moved on screen by less than their clearance between the two answers. A frame white on purpose is excluded by its
|
|
9
|
+
* rect. Main treats fewer than 4 valid probes, a changed document, bounds or active tab, or an answer later than
|
|
10
|
+
* 150 ms as inconclusive, never white.
|
|
11
|
+
*
|
|
12
|
+
* FROZEN signatures (A3.8 #53). The geometry: a 12 x 8 grid of cell centres over the usable rectangle, below the
|
|
13
|
+
* scroll edge; a point's clearance is its distance to the nearest node's rect (`getBoundingClientRect`: transforms and
|
|
14
|
+
* animation included); the 16 with the most clearance that have the canvas surface under them are kept, with the
|
|
15
|
+
* camera (`canvasCtl.transform()`) for the bracket. **The camera at every animation frame of the bracket**: from
|
|
16
|
+
* `pick` to `verify` the shell records the camera once a frame (the frames a capture can have read), since a pan
|
|
17
|
+
* that turns back - the recorder's own pan is 60 wheel events one way and 60 the other, and main's bracket can last
|
|
18
|
+
* some 800 ms (150 + 500 + 150) - can sweep a node over a probe and back with the two ends the same (review of
|
|
19
|
+
* a3-native, minor #16). `verify` maps each point through the pick's camera and each recorded one, both ways: the
|
|
20
|
+
* world point under it at pick, drawn at that frame, and the world point under it at that frame, drawn as the camera
|
|
21
|
+
* was at pick. The second is the one that matters under a zoom - if the world point under the probe at a frame was,
|
|
22
|
+
* at the pick's camera, closer than the clearance, no node (each at least the clearance away then) covered it at that
|
|
23
|
+
* frame; under a zoom out a node's edge moves further than the probe's own world point, so the first alone does not
|
|
24
|
+
* say that. A point is valid when every frame's moves are under its clearance, it is still `VERIFY_MARGIN` (8 px)
|
|
25
|
+
* clear of every node now, and the surface is still under it. With no camera (no canvas) every point is invalid: the
|
|
26
|
+
* sample is inconclusive. A main thread stalled for the whole bracket records no frame between, and draws none
|
|
27
|
+
* either: the camera is the shell's. Nodes that move on the board themselves (a drag, a layout animation) are not the
|
|
28
|
+
* camera's and not covered by this.
|
|
29
|
+
*/
|
|
30
|
+
import { PERF_BOUNDS, type PerfCam, type PerfMsg } from '../../shared/app-api.ts'
|
|
31
|
+
import { canvasCtl } from './canvas/ctl.ts'
|
|
32
|
+
import { VISIBLE_TOP } from './inset.ts'
|
|
33
|
+
|
|
34
|
+
/** At most this many probes a tick (the bridge refuses more than PERF_BOUNDS.points). */
|
|
35
|
+
export const MAX_PROBES = Math.min(16, PERF_BOUNDS.points)
|
|
36
|
+
/** Each probe's clearance from every node's screen rect, px. */
|
|
37
|
+
export const PROBE_CLEARANCE = 48
|
|
38
|
+
/** The candidate grid over the usable rectangle. */
|
|
39
|
+
export const PROBE_GRID: readonly [number, number] = [12, 8]
|
|
40
|
+
/** At `verify`, each kept point still this far from every node's rect, px (the design's margin). */
|
|
41
|
+
export const VERIFY_MARGIN = 8
|
|
42
|
+
|
|
43
|
+
const view = () => ({ w: innerWidth, h: innerHeight })
|
|
44
|
+
type Rect = { left: number; top: number; right: number; bottom: number }
|
|
45
|
+
|
|
46
|
+
/** The canvas surface itself: the zoom wrapper, its content or the world - never a frame, a caption, the chrome. */
|
|
47
|
+
export function isSurface(el: Element | null): boolean {
|
|
48
|
+
if (!el) return false
|
|
49
|
+
return el.id === 'sh-world' || el.classList.contains('sh-canvas') || el.classList.contains('sh-content')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A point's distance to the nearest rect (0 inside one); Infinity with none. */
|
|
53
|
+
export function clearance(x: number, y: number, rects: readonly Rect[]): number {
|
|
54
|
+
let d = Infinity
|
|
55
|
+
for (const r of rects) {
|
|
56
|
+
const dx = Math.max(r.left - x, 0, x - r.right)
|
|
57
|
+
const dy = Math.max(r.top - y, 0, y - r.bottom)
|
|
58
|
+
d = Math.min(d, Math.hypot(dx, dy))
|
|
59
|
+
if (d === 0) return 0
|
|
60
|
+
}
|
|
61
|
+
return d
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Where the world point under (x, y) at camera a is drawn at camera b, `o` the canvas wrapper's client origin. */
|
|
65
|
+
export function moved(x: number, y: number, a: PerfCam, b: PerfCam, o: { x: number; y: number }): number {
|
|
66
|
+
const wx = (x - o.x - a.x) / a.s
|
|
67
|
+
const wy = (y - o.y - a.y) / a.s
|
|
68
|
+
return Math.hypot(o.x + b.x + wx * b.s - x, o.y + b.y + wy * b.s - y)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const nodeRects = (): Rect[] => [...document.querySelectorAll('.sh-node')].map((e) => e.getBoundingClientRect())
|
|
72
|
+
const origin = () => { const r = document.querySelector('.sh-canvas')?.getBoundingClientRect(); return { x: r?.left ?? 0, y: r?.top ?? 0 } }
|
|
73
|
+
|
|
74
|
+
/** The points a tick picked, its clearances, its camera and the camera at each frame since, for its `verify` (the last four ticks kept). */
|
|
75
|
+
const kept = new Map<number, { pts: [number, number][]; clear: number[]; cam: PerfCam | null; path: PerfCam[]; stop(): void }>()
|
|
76
|
+
/** The longest bracket recorded, in frames (5 s at 120 Hz): past it a verify finds the path cut, and says invalid. */
|
|
77
|
+
export const PATH_FRAMES = 600
|
|
78
|
+
|
|
79
|
+
/** The camera at each animation frame from now until `stop()`, or until it holds PATH_FRAMES (then the path is cut). */
|
|
80
|
+
function cameraPath(): { path: PerfCam[]; stop(): void } {
|
|
81
|
+
const path: PerfCam[] = []
|
|
82
|
+
let on = true
|
|
83
|
+
const step = () => {
|
|
84
|
+
if (!on) return
|
|
85
|
+
const c = canvasCtl.transform()
|
|
86
|
+
if (c) path.push({ ...c })
|
|
87
|
+
if (path.length >= PATH_FRAMES) { on = false; return }
|
|
88
|
+
requestAnimationFrame(step)
|
|
89
|
+
}
|
|
90
|
+
requestAnimationFrame(step)
|
|
91
|
+
return { path, stop: () => { on = false } }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The `before` answer for `tick`: the points chosen now, the camera and the viewport. */
|
|
95
|
+
export function pick(tick: number): Extract<PerfMsg, { kind: 'probes'; at: 'before' }> {
|
|
96
|
+
const top = VISIBLE_TOP
|
|
97
|
+
const w = innerWidth, h = Math.max(0, innerHeight - top)
|
|
98
|
+
const rects = nodeRects()
|
|
99
|
+
const [cols, rows] = PROBE_GRID
|
|
100
|
+
const cands: { p: [number, number]; c: number }[] = []
|
|
101
|
+
for (let j = 0; j < rows; j++) {
|
|
102
|
+
for (let i = 0; i < cols; i++) {
|
|
103
|
+
const x = Math.round((i + 0.5) * w / cols)
|
|
104
|
+
const y = Math.round(top + (j + 0.5) * h / rows)
|
|
105
|
+
const c = clearance(x, y, rects)
|
|
106
|
+
if (c < PROBE_CLEARANCE) continue
|
|
107
|
+
if (!isSurface(document.elementFromPoint(x, y))) continue
|
|
108
|
+
cands.push({ p: [x, y], c })
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
cands.sort((a, b) => b.c - a.c)
|
|
112
|
+
const chosen = cands.slice(0, MAX_PROBES)
|
|
113
|
+
const cam = canvasCtl.transform()
|
|
114
|
+
const run = cameraPath()
|
|
115
|
+
kept.get(tick)?.stop()
|
|
116
|
+
kept.set(tick, { pts: chosen.map((x) => x.p), clear: chosen.map((x) => Math.min(x.c, 1e6)), cam, path: run.path, stop: run.stop })
|
|
117
|
+
for (const k of [...kept.keys()]) if (kept.size > 4 && k !== tick) { kept.get(k)!.stop(); kept.delete(k) }
|
|
118
|
+
return { kind: 'probes', tick, at: 'before', points: chosen.map((x) => x.p), cam, view: view() }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** The `after` answer for `tick`: one flag per point `pick(tick)` gave. */
|
|
122
|
+
export function verify(tick: number): Extract<PerfMsg, { kind: 'probes'; at: 'after' }> {
|
|
123
|
+
const k = kept.get(tick)
|
|
124
|
+
const cam = canvasCtl.transform()
|
|
125
|
+
if (!k) return { kind: 'probes', tick, at: 'after', valid: [], cam, view: view() }
|
|
126
|
+
kept.delete(tick)
|
|
127
|
+
const cut = k.path.length >= PATH_FRAMES
|
|
128
|
+
k.stop()
|
|
129
|
+
const rects = nodeRects()
|
|
130
|
+
const o = origin()
|
|
131
|
+
// every camera the bracket's frames showed, and the one now
|
|
132
|
+
const cams = cam ? [...k.path, cam] : []
|
|
133
|
+
const valid = k.pts.map(([x, y], i) => {
|
|
134
|
+
if (!k.cam || !cam || cut) return false
|
|
135
|
+
const c = k.clear[i]!
|
|
136
|
+
for (const at of cams) if (moved(x, y, k.cam, at, o) >= c || moved(x, y, at, k.cam, o) >= c) return false
|
|
137
|
+
if (clearance(x, y, rects) < VERIFY_MARGIN) return false
|
|
138
|
+
return isSurface(document.elementFromPoint(x, y))
|
|
139
|
+
})
|
|
140
|
+
return { kind: 'probes', tick, at: 'after', valid, cam, view: view() }
|
|
141
|
+
}
|