@marver-design/marver 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +2 -1
- package/dist/{anchor-check-DhlpKl2K.mjs → anchor-check-c52IDkiQ.mjs} +1 -1
- package/dist/{build-CWbrb2bl.mjs → build-C3mUtjEn.mjs} +5 -4
- package/dist/cli.mjs +5 -5
- package/dist/{daemon-Sc_z8gT6.mjs → daemon-B0Wi1OQ3.mjs} +5 -3
- package/dist/{dev-DWBKQhxf.mjs → dev-5dlxoW28.mjs} +8 -8
- package/dist/{perf-Denssrko.mjs → perf-6MOTHxay.mjs} +710 -99
- package/dist/perf-BCxAo0IS.mjs +1743 -0
- package/dist/{plugin-DqoZB-D6.mjs → plugin-CXRoMA8g.mjs} +898 -539
- package/dist/{poster-CrsjqhY4.mjs → poster-CYmCa00B.mjs} +1 -1
- package/dist/{publish-bakes-DW-NDgU2.mjs → publish-bakes-C_2ZtHou.mjs} +2 -2
- package/dist/{recover-GtJ9UDAB.mjs → recover-XD8iXJOj.mjs} +1 -1
- package/dist/{shot-T04Ixrvq.mjs → shot-CRRGgxru.mjs} +3 -3
- package/docs/app.md +194 -0
- package/docs/performance.md +98 -18
- package/package.json +1 -1
- package/src/client/frame-host/bridge.js +17 -8
- package/src/client/frame-host/inplace.ts +124 -0
- package/src/client/frame-host/inspect.d.ts +1 -0
- package/src/client/frame-host/inspect.js +13 -4
- package/src/client/frame-host/main.tsx +12 -3
- package/src/client/frame-host/messages.ts +85 -0
- package/src/client/frame-host/signals.d.ts +15 -0
- package/src/client/frame-host/signals.js +219 -0
- package/src/client/recorder-level.ts +41 -0
- package/src/client/shell/App.tsx +158 -88
- package/src/client/shell/BoardList.tsx +103 -48
- package/src/client/shell/Comments.tsx +66 -42
- package/src/client/shell/ContextMenu.tsx +3 -2
- package/src/client/shell/JamSurface.tsx +116 -71
- package/src/client/shell/LockedApp.tsx +19 -3
- package/src/client/shell/Play.tsx +94 -58
- package/src/client/shell/StatusPicker.tsx +19 -9
- package/src/client/shell/Toolbar.tsx +15 -7
- package/src/client/shell/api.ts +18 -4
- package/src/client/shell/app-bridge.ts +12 -6
- package/src/client/shell/app-perf.ts +31 -1
- package/src/client/shell/canvas/Canvas.tsx +17 -6
- package/src/client/shell/canvas/FrameNode.tsx +25 -12
- package/src/client/shell/canvas/Sticky.tsx +4 -2
- package/src/client/shell/canvas/ctl.ts +2 -0
- package/src/client/shell/canvas/ready-watch.ts +4 -0
- package/src/client/shell/canvas/sleep.ts +2 -0
- package/src/client/shell/canvas/updates.ts +13 -6
- package/src/client/shell/commands.ts +765 -0
- package/src/client/shell/comments-store.ts +42 -27
- package/src/client/shell/goto.ts +11 -6
- package/src/client/shell/jam-keys.ts +141 -75
- package/src/client/shell/jam-lane.tsx +19 -12
- package/src/client/shell/jam-panel.tsx +61 -48
- package/src/client/shell/jam-session.tsx +41 -37
- package/src/client/shell/jam-state.ts +9 -1
- package/src/client/shell/jam-surface-parts.tsx +8 -6
- package/src/client/shell/jam-ui.tsx +9 -6
- package/src/client/shell/jam-voice.ts +4 -2
- package/src/client/shell/main.tsx +7 -1
- package/src/client/shell/marks-ui.tsx +11 -0
- package/src/client/shell/perf.ts +51 -5
- package/src/client/shell/recorder-core.ts +4 -1
- package/src/client/shell/recorder-hmr.ts +36 -0
- package/src/client/shell/recorder-reloads.ts +264 -0
- package/src/client/shell/recorder-seams.ts +116 -0
- package/src/client/shell/recorder-self.ts +73 -0
- package/src/client/shell/recorder-signals-core.ts +139 -0
- package/src/client/shell/recorder-signals.ts +485 -0
- package/src/client/shell/recorder.ts +115 -41
- package/src/client/shell/store.ts +56 -22
- package/src/client/shell/whiteout-probes.ts +3 -1
- package/src/client/stage/main.tsx +10 -5
- package/src/shared/app-api.ts +28 -6
- package/src/shared/app-perf.ts +99 -6
- package/src/shared/app-report.ts +586 -0
- package/src/shared/perf-records.ts +445 -0
- package/src/shared/perf-run.ts +6 -2
- package/dist/perf-jam-CLkERSHo.mjs +0 -642
|
@@ -29,7 +29,10 @@
|
|
|
29
29
|
* at the size found; main refuses it and the tab stays covered. rAF does not run in a hidden page, so a request to a
|
|
30
30
|
* page nobody sees waits by itself. App 0.1 says no inset and asks nothing: none of it runs there.
|
|
31
31
|
*/
|
|
32
|
-
import { BOUNDS, type AppState, type Busy, type Hello, type MarverAppV1, type MenuItem, type Present } from '../../shared/app-api.ts'
|
|
32
|
+
import { BOUNDS, MENU_IN, type AppState, type Busy, type Hello, type MarverAppV1, type MenuIn, type MenuItem, type Present } from '../../shared/app-api.ts'
|
|
33
|
+
import type { CmdIn } from '../../shared/perf-records.ts'
|
|
34
|
+
import { relayed } from './commands.ts'
|
|
35
|
+
import { markSeenFrom } from './marks-ui.tsx'
|
|
33
36
|
import { APP } from './marver-app.ts'
|
|
34
37
|
import { TOP } from './inset.ts'
|
|
35
38
|
import { api, canvasStopped } from './api.ts'
|
|
@@ -139,15 +142,18 @@ export function menuNow(): MenuItem[] {
|
|
|
139
142
|
* text field holding the focus does not stop it: the person chose the item). An id the page does not offer now
|
|
140
143
|
* does nothing. One id is the app's own, never in the menu: the tab's right-click Mark All as Seen clears every
|
|
141
144
|
* frame's "new" in this canvas, here and on disk, as the sidebar's Mark all as seen does for a board. */
|
|
142
|
-
export function runMenuItem(id: string): void {
|
|
145
|
+
export function runMenuItem(id: string, from?: unknown): void {
|
|
146
|
+
// spec 30 #51: the menu it came from, as app 1.0.1 says; app 1.0.0 says nothing, so `app`
|
|
147
|
+
const where: CmdIn = (MENU_IN as readonly unknown[]).includes(from) ? from as MenuIn : 'app'
|
|
143
148
|
if (id === 'mark-all-seen') {
|
|
144
149
|
const s = useStore.getState()
|
|
145
|
-
if (!PUBLISHED && s.marks)
|
|
150
|
+
if (!PUBLISHED && s.marks) markSeenFrom({ via: 'relay', in: where }, Object.keys(s.marks.changed))
|
|
146
151
|
return
|
|
147
152
|
}
|
|
148
153
|
const it = ITEMS.find((x) => x.id === id)
|
|
149
154
|
if (!it || !offered(it)) return
|
|
150
|
-
|
|
155
|
+
// recorded by the key handler that runs it, once, as the relay it is (`cmd()` reads `relayed`)
|
|
156
|
+
relayed(where, () => window.dispatchEvent(new KeyboardEvent('keydown', { ...it.key, bubbles: true, cancelable: true })))
|
|
151
157
|
}
|
|
152
158
|
|
|
153
159
|
// ---- coming back into view ----------------------------------------------------------------------------------
|
|
@@ -172,7 +178,7 @@ export async function resumeReconcile(): Promise<void> {
|
|
|
172
178
|
const now = useStore.getState()
|
|
173
179
|
if (now.board !== board || now.dirty || now.gesture) return
|
|
174
180
|
const disk = typeof body?.sha256 === 'string' ? body.sha256 : null
|
|
175
|
-
if (disk !== now.boardHash) await now.boot()
|
|
181
|
+
if (disk !== now.boardHash) await now.boot(undefined, 'app-shown')
|
|
176
182
|
} catch { /* the next shown, or the live socket, heals it */ } finally { reconciling = false }
|
|
177
183
|
}
|
|
178
184
|
|
|
@@ -198,7 +204,7 @@ export function startAppBridge(): void {
|
|
|
198
204
|
|
|
199
205
|
// what the app says, listened for before the page says anything
|
|
200
206
|
call(() => app.onAppState((s) => onAppState(s)))
|
|
201
|
-
call(() => app.onMenuClick((p) => runMenuItem(typeof p?.id === 'string' ? p.id : '')))
|
|
207
|
+
call(() => app.onMenuClick((p) => runMenuItem(typeof p?.id === 'string' ? p.id : '', p?.in)))
|
|
202
208
|
// a notice's click (A4.6 #29, #30): the exact item, resolved against fresh reads and answered
|
|
203
209
|
if (typeof app.onOpen === 'function') call(() => { app.onOpen!((p) => openLiveItem(p)) })
|
|
204
210
|
// the one ground's presentation requests (0.27.2): answered only when the shell took the inset - a shell that did
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* holds two); `board` is sent when the frame count or the sleeping count changed, read at each change of the board's
|
|
14
14
|
* nodes and again at each gesture's end (frames fall asleep without the store moving), never more.
|
|
15
15
|
*/
|
|
16
|
-
import type
|
|
16
|
+
import { PERF_BOUNDS, type PerfMsg, type WatchWhy } from '../../shared/app-api.ts'
|
|
17
17
|
import { APP } from './marver-app.ts'
|
|
18
18
|
import { useStore } from './store.ts'
|
|
19
19
|
import { sleepingCount } from './canvas/sleep.ts'
|
|
@@ -85,6 +85,36 @@ export function displayHz(): number | null {
|
|
|
85
85
|
try { return APP?.perfInfo?.().hz ?? null } catch { return null }
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
/** Spec 30 R8 #38: does the app take `mv:perf` `watch`? App 1.0.1's preload says so in `perfInfo()`; app 1.0.0 would
|
|
89
|
+
* refuse it and spend the tab's bucket, so nothing is sent without it. */
|
|
90
|
+
export function watchSupported(): boolean {
|
|
91
|
+
try { return PERF_ON && APP?.perfInfo?.().watch === true } catch { return false }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The windows this page has open, oldest first, by reason: each its `seq` (#38). */
|
|
95
|
+
const watching: Record<WatchWhy, number[]> = { load: [], theme: [], reload: [] }
|
|
96
|
+
let watchSeq = 0
|
|
97
|
+
/**
|
|
98
|
+
* Spec 30 R8 #38: a white-out window this page opens (`on`) or closes - `load` from the request to settled or cut,
|
|
99
|
+
* `theme` from a switch to its outcome, `reload` from an on-screen job's `startReload` to its ready. Callers: recorder-
|
|
100
|
+
* self.ts (`load`), signals (`theme`), edits (`reload`). One `seq` per window, its oldest of that reason closed first;
|
|
101
|
+
* sent only when `watchSupported()`. Main ends a window at 10 s whatever is said here.
|
|
102
|
+
*/
|
|
103
|
+
export function watchWindow(why: WatchWhy, on: boolean): void {
|
|
104
|
+
if (!watchSupported()) return
|
|
105
|
+
const open = watching[why]
|
|
106
|
+
if (on) {
|
|
107
|
+
watchSeq = watchSeq >= PERF_BOUNDS.counter - 1 ? 1 : watchSeq + 1
|
|
108
|
+
open.push(watchSeq)
|
|
109
|
+
// a window never closed (its caller's page state lost) goes on main's 10 s: never a list without end
|
|
110
|
+
if (open.length > 64) open.shift()
|
|
111
|
+
sendPerf({ kind: 'watch', on: true, seq: watchSeq, why })
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
const seq = open.shift()
|
|
115
|
+
if (seq !== undefined) sendPerf({ kind: 'watch', on: false, seq, why })
|
|
116
|
+
}
|
|
117
|
+
|
|
88
118
|
/** One message to the app, never throwing. */
|
|
89
119
|
export function sendPerf(p: PerfMsg): void {
|
|
90
120
|
if (!PERF_ON) return
|
|
@@ -4,7 +4,7 @@ import { CONFIG, useStore } from '../store.ts'
|
|
|
4
4
|
import { letGoOfTile } from '../jam-state.ts'
|
|
5
5
|
import { bootHash, linkTargets } from '../hash.ts'
|
|
6
6
|
import { revealFrame } from '../goto.ts'
|
|
7
|
-
import { startPerf } from '../perf.ts'
|
|
7
|
+
import { noteGestureCmd, startPerf } from '../perf.ts'
|
|
8
8
|
import { FrameNode, HEADER } from './FrameNode.tsx'
|
|
9
9
|
import { NOTE_GAP } from '../notes.ts'
|
|
10
10
|
import { onMotion, startCameraBroadcast, setCameraScale } from './camera-broadcast.ts'
|
|
@@ -154,6 +154,7 @@ let presetTimer = 0
|
|
|
154
154
|
export function animateLayout(ms = 360) {
|
|
155
155
|
const w = document.getElementById('sh-world')
|
|
156
156
|
if (!w) return
|
|
157
|
+
noteGestureCmd()
|
|
157
158
|
w.classList.add('sh-preset')
|
|
158
159
|
clearTimeout(presetTimer)
|
|
159
160
|
presetTimer = window.setTimeout(() => w.classList.remove('sh-preset'), ms)
|
|
@@ -163,6 +164,7 @@ export function animateLayout(ms = 360) {
|
|
|
163
164
|
// dragging the canvas into a locked-shell bundle; Canvas assigns the real
|
|
164
165
|
// implementations below when it mounts
|
|
165
166
|
import { canvasCtl, type CanvasWheelInput } from './ctl.ts'
|
|
167
|
+
import { cmd, type CmdHandle } from '../commands.ts'
|
|
166
168
|
export { canvasCtl, type CanvasWheelInput }
|
|
167
169
|
import { anchorNode, anchoredCamera, type Held } from './anchor.ts'
|
|
168
170
|
/** The node a content-driven reflow must not move on screen (holdView -> the layout effect). */
|
|
@@ -195,7 +197,7 @@ function GroupCaptions() {
|
|
|
195
197
|
style={{ transform: `translate(${g.x}px, ${g.y}px) translateY(calc(-100% - clamp(4px, 8px * var(--sh-inv, 1), 40px)))` }}
|
|
196
198
|
title="Select all variants"
|
|
197
199
|
onPointerDown={(e) => e.stopPropagation()}
|
|
198
|
-
onClick={() => { useStore.getState().selectMany(g.keys); canvasCtl.fitNodes(g.keys) }}>
|
|
200
|
+
onClick={() => { cmd('group-fit', { via: 'click', in: 'shell', frames: g.keys.length }); useStore.getState().selectMany(g.keys); canvasCtl.fitNodes(g.keys) }}>
|
|
199
201
|
{id.split('/').map((s) => s[0].toUpperCase() + s.slice(1)).join(' / ')} · {g.ids.size} variants
|
|
200
202
|
</div>
|
|
201
203
|
)
|
|
@@ -205,6 +207,7 @@ function GroupCaptions() {
|
|
|
205
207
|
}
|
|
206
208
|
|
|
207
209
|
export function Canvas() {
|
|
210
|
+
const spacePan = useRef<{ h: CmdHandle; panned: boolean } | null>(null) // the recorder's (spec 30): `space-pan` in flight
|
|
208
211
|
const nodes = useStore((s) => s.nodes)
|
|
209
212
|
const gesture = useStore((s) => s.gesture)
|
|
210
213
|
const setScale = useStore((s) => s.setScale)
|
|
@@ -291,6 +294,7 @@ export function Canvas() {
|
|
|
291
294
|
fly(cx - (cx - positionX) * k, cy - (cy - positionY) * k, target, 250)
|
|
292
295
|
}
|
|
293
296
|
canvasCtl.cameraBusy = () => !!ref.current?.instance.animation
|
|
297
|
+
canvasCtl.layoutBusy = () => !!document.getElementById('sh-world')?.classList.contains('sh-preset')
|
|
294
298
|
// the camera as the world is drawn now, mid-flight included: the white-out probes' bracket (spec 28 A3.8 #16)
|
|
295
299
|
canvasCtl.transform = () => {
|
|
296
300
|
const t = ref.current?.instance.transformState
|
|
@@ -387,10 +391,11 @@ export function Canvas() {
|
|
|
387
391
|
// anywhere on the canvas, a frame too: the panel closes and its tile lets go - except on a comment's
|
|
388
392
|
// own controls (its pin, its card, its reply): opening one closes the panel there and keeps the
|
|
389
393
|
// tile when the thread is its own (JamSurface)
|
|
390
|
-
if (!t?.closest('.cm-layer, .cm-card, .cm-pin, .cm-stack')) letGoOfTile()
|
|
394
|
+
if (!t?.closest('.cm-layer, .cm-card, .cm-pin, .cm-stack')) letGoOfTile({ via: 'click', in: 'shell' })
|
|
391
395
|
if (t?.closest('.sh-node') || t?.closest('.sh-gcaption')) return
|
|
392
396
|
const s = useStore.getState()
|
|
393
|
-
|
|
397
|
+
// silent when it changes nothing (R12's silence note)
|
|
398
|
+
if (s.selection.length || s.interact) { cmd('deselect', { via: 'click', in: 'shell', frames: s.selection.length }); s.select(null) }
|
|
394
399
|
}
|
|
395
400
|
el.addEventListener('pointerdown', down)
|
|
396
401
|
return () => el.removeEventListener('pointerdown', down)
|
|
@@ -469,9 +474,12 @@ export function Canvas() {
|
|
|
469
474
|
if (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement) return
|
|
470
475
|
e.preventDefault()
|
|
471
476
|
document.body.classList.add('sh-space')
|
|
477
|
+
// spec 30: ends with the pan it was held for, or - let go with no drag - `no-drag`
|
|
478
|
+
spacePan.current = { h: cmd('space-pan', { via: 'key', in: 'shell', keys: 'Space' }), panned: false }
|
|
472
479
|
}
|
|
473
|
-
const
|
|
474
|
-
const
|
|
480
|
+
const letGo = () => { const sp = spacePan.current; if (sp && !sp.panned) { sp.h.noop('no-drag'); spacePan.current = null } }
|
|
481
|
+
const up = (e: KeyboardEvent) => { if (e.code === 'Space') { document.body.classList.remove('sh-space'); letGo() } }
|
|
482
|
+
const drop = () => { document.body.classList.remove('sh-space'); letGo() }
|
|
475
483
|
window.addEventListener('keydown', down)
|
|
476
484
|
window.addEventListener('keyup', up)
|
|
477
485
|
window.addEventListener('blur', drop)
|
|
@@ -488,6 +496,9 @@ export function Canvas() {
|
|
|
488
496
|
const pan = (on: boolean) => () => {
|
|
489
497
|
camera(on)
|
|
490
498
|
document.body.classList[on ? 'add' : 'remove']('sh-panning')
|
|
499
|
+
const sp = spacePan.current
|
|
500
|
+
if (sp && on) sp.panned = true
|
|
501
|
+
else if (sp?.panned) { sp.h.done(); spacePan.current = null }
|
|
491
502
|
}
|
|
492
503
|
const zoom = (on: boolean) => () => camera(on)
|
|
493
504
|
|
|
@@ -10,13 +10,17 @@ import { registerFrame, unregisterFrame } from './frame-registry.ts'
|
|
|
10
10
|
import { canvasClick, canvasPointer, frameGone, frameLoaded, pressNow, useJamCapture } from '../jam-capture.ts'
|
|
11
11
|
import { primeCameraFor } from './camera-broadcast.ts'
|
|
12
12
|
import { scheduleSleep, sleep, wake } from './sleep.ts'
|
|
13
|
-
import { canAutoReload,
|
|
13
|
+
import { canAutoReload, silenceAction } from './ready-watch.ts'
|
|
14
|
+
import { watchdogLine } from '../recorder-reloads.ts'
|
|
14
15
|
import { Stickies, type NoteSpec } from './Sticky.tsx'
|
|
15
16
|
import { recorder } from '../recorder.ts'
|
|
17
|
+
import { perfSeams } from '../recorder-seams.ts'
|
|
16
18
|
import { noteId, sceneNoteHost } from '../notes.ts'
|
|
17
19
|
import { slideSize, stageFit } from '../../const.ts'
|
|
18
20
|
import { FrameSlot, toneOf, useFrameMark } from '../marks-ui.tsx'
|
|
19
21
|
import { stranded } from '../api.ts'
|
|
22
|
+
import { WATCHDOG_MS } from '../../../shared/perf-records.ts'
|
|
23
|
+
import { cmd, endOnReady, endOnSave, type CmdHandle } from '../commands.ts'
|
|
20
24
|
|
|
21
25
|
export const HEADER = 28
|
|
22
26
|
const SNAP = 12
|
|
@@ -136,7 +140,7 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
136
140
|
useEffect(() => {
|
|
137
141
|
if (themeRef.current !== node.theme) {
|
|
138
142
|
themeRef.current = node.theme
|
|
139
|
-
iframeRef.current?.contentWindow?.postMessage({ type: 'sh:set-theme', theme: node.theme }, '*')
|
|
143
|
+
iframeRef.current?.contentWindow?.postMessage({ type: 'sh:set-theme', theme: node.theme, t: perfSeams.transition('theme') }, '*')
|
|
140
144
|
}
|
|
141
145
|
}, [node.theme, node.key])
|
|
142
146
|
|
|
@@ -177,14 +181,14 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
177
181
|
t.id === s.active && !t.resolved && threadHostKey(t, useStore.getState().nodes) === node.key)) || s.draft?.nodeKey === node.key)
|
|
178
182
|
useEffect(() => {
|
|
179
183
|
if (node.status === 'ready' || !laser)
|
|
180
|
-
iframeRef.current?.contentWindow?.postMessage({ type: 'sh:laser', on: laser, inspect: laserInspect }, location.origin)
|
|
184
|
+
iframeRef.current?.contentWindow?.postMessage({ type: 'sh:laser', on: laser, inspect: laserInspect, t: perfSeams.transition('mode') }, location.origin)
|
|
181
185
|
}, [laser, laserInspect, node.status])
|
|
182
186
|
// comment mode = pick mode in the frame (late loaders join like laser does); quiet when
|
|
183
187
|
// laser comment (⇧L) is off - clicks still anchor, no lighting in the artwork
|
|
184
188
|
const showAnchor = useComments((s) => s.showAnchor)
|
|
185
189
|
useEffect(() => {
|
|
186
190
|
if (node.status === 'ready' || !commentMode)
|
|
187
|
-
iframeRef.current?.contentWindow?.postMessage({ type: 'sh:pick', on: commentMode, quiet: !showAnchor }, location.origin)
|
|
191
|
+
iframeRef.current?.contentWindow?.postMessage({ type: 'sh:pick', on: commentMode, quiet: !showAnchor, t: perfSeams.transition('mode') }, location.origin)
|
|
188
192
|
}, [commentMode, showAnchor, node.status])
|
|
189
193
|
// B0.2: the interact target owns its own wheel (app scrolls); passive frames forward
|
|
190
194
|
// wheel to the canvas. Replayed on ready like laser/pick so a reload restores truth.
|
|
@@ -282,7 +286,11 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
282
286
|
if (!admitted || node.status !== 'loading' || !frame || node.missing) return
|
|
283
287
|
// the second silence gives the slot back, and is the recorder's never-ready (spec 28 A1.7) - the frame stays
|
|
284
288
|
// loading, never a red card
|
|
285
|
-
const t = setTimeout(() => {
|
|
289
|
+
const t = setTimeout(() => {
|
|
290
|
+
const action = silenceAction(node, true)
|
|
291
|
+
watchdogLine(node.key, action) // the silence is a line, before the retry (spec 30 #20)
|
|
292
|
+
if (action === 'retry') reloadRef.current(true); else { release(node.key); recorder.neverReady(node.key) }
|
|
293
|
+
}, WATCHDOG_MS)
|
|
286
294
|
return () => clearTimeout(t)
|
|
287
295
|
// depend on the frame's stable SIGNATURE, not the manifest object - that object is replaced on
|
|
288
296
|
// every manifest reconcile, so depending on it would reset the budget on unrelated frames during
|
|
@@ -293,7 +301,8 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
293
301
|
e.stopPropagation()
|
|
294
302
|
if (e.button !== 0) return
|
|
295
303
|
// shift-click toggles multi-selection instead of dragging (Figma convention)
|
|
296
|
-
if (e.shiftKey && mode === 'move') { select(node.key, true); return }
|
|
304
|
+
if (e.shiftKey && mode === 'move') { cmd('select', { via: 'click', in: 'shell', frame: node.frame }); select(node.key, true); return }
|
|
305
|
+
if (mode === 'move') cmd('select', { via: 'click', in: 'shell', frame: node.frame })
|
|
297
306
|
if (!(selected && useStore.getState().selection.length > 1)) select(node.key)
|
|
298
307
|
else useStore.getState().look([node.key]) // a click inside a group selection still looks at this one
|
|
299
308
|
const el = e.currentTarget as HTMLElement
|
|
@@ -315,9 +324,12 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
315
324
|
// begins - a bare click otherwise promotes then demotes the compositor layer, re-rasterising
|
|
316
325
|
// the frame's text at a fractional zoom = the "jiggle". A pure click now never toggles it.
|
|
317
326
|
let gesturing = false
|
|
327
|
+
// spec 30: a press that became a drag - its start here, its end once the save carrying its id landed
|
|
328
|
+
let moved: CmdHandle | null = null
|
|
318
329
|
const begin = () => {
|
|
319
330
|
if (gesturing) return
|
|
320
331
|
gesturing = true
|
|
332
|
+
moved = cmd(mode === 'move' ? 'frame-move' : 'frame-resize', { via: 'drag', in: 'shell', frame: node.frame, frames: Math.max(1, Object.keys(groupStarts).length) })
|
|
321
333
|
world.classList.add('sh-gesturing') // drops iframe pointer-events
|
|
322
334
|
setGesture(true)
|
|
323
335
|
if (mode !== 'move') { resizing.current = true; wake(node.key, iframeRef.current); setResizeTick((t) => t + 1) } // awake before the first resized paint, for the whole resize
|
|
@@ -345,6 +357,7 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
345
357
|
const done = () => {
|
|
346
358
|
if (finished) return
|
|
347
359
|
finished = true
|
|
360
|
+
if (moved) endOnSave(moved, useStore.getState().board)
|
|
348
361
|
try { el.releasePointerCapture(e.pointerId) } catch { /* already released */ }
|
|
349
362
|
world.classList.remove('sh-gesturing')
|
|
350
363
|
setGesture(false)
|
|
@@ -378,7 +391,7 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
378
391
|
<b>file deleted</b>
|
|
379
392
|
<span className="dim">{node.frame}</span>
|
|
380
393
|
<span className="row">
|
|
381
|
-
<button className="sh-no-pan" onClick={() => useStore.getState().removeNode(node.key)}>
|
|
394
|
+
<button className="sh-no-pan" onClick={() => { endOnSave(cmd('remove-node', { via: 'click', in: 'shell', frame: node.frame }), useStore.getState().board); useStore.getState().removeNode(node.key) }}>
|
|
382
395
|
<XIcon size={12} /> remove from board
|
|
383
396
|
</button>
|
|
384
397
|
</span>
|
|
@@ -410,7 +423,7 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
410
423
|
{frame.variantGroup && (
|
|
411
424
|
<div className="sh-vbadge sh-no-pan" title={`${frame.variantGroup} · variant ${frame.variant?.toUpperCase()} - click to select`}
|
|
412
425
|
onPointerDown={(e) => e.stopPropagation()}
|
|
413
|
-
onClick={(e) => { select(node.key, e.shiftKey) }}>
|
|
426
|
+
onClick={(e) => { cmd('select', { via: 'click', in: 'shell', frame: node.frame }); select(node.key, e.shiftKey) }}>
|
|
414
427
|
<b>{frame.variant?.toUpperCase()}</b>
|
|
415
428
|
<span>{variantName}</span>
|
|
416
429
|
</div>
|
|
@@ -433,10 +446,10 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
433
446
|
<span className="msg">{node.error}</span>
|
|
434
447
|
<span className="dim">{frame.file}</span>
|
|
435
448
|
<span className="row">
|
|
436
|
-
<button className="sh-no-pan" onClick={() => reload(false)}>
|
|
449
|
+
<button className="sh-no-pan" onClick={() => { endOnReady(cmd('frame-reload', { via: 'click', in: 'shell', frame: node.frame }), node.key); reload(false) }}>
|
|
437
450
|
<ReloadIcon size={12} /> reload
|
|
438
451
|
</button>
|
|
439
|
-
<button className="sh-no-pan" onClick={() => { navigator.clipboard.writeText(`${frame.file}: ${node.error}`); toast('error copied for agent') }}>
|
|
452
|
+
<button className="sh-no-pan" onClick={() => { const h = cmd('copy-error', { via: 'click', in: 'shell', frame: node.frame }); navigator.clipboard.writeText(`${frame.file}: ${node.error}`).then(() => h.done(), () => h.fail('clipboard-blocked')); toast('error copied for agent') }}>
|
|
440
453
|
<CopyIcon size={12} /> copy for agent
|
|
441
454
|
</button>
|
|
442
455
|
</span>
|
|
@@ -447,7 +460,7 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
447
460
|
{node.status === 'loading' && node.readyRetried && !away ? (
|
|
448
461
|
<div className="sh-loading sh-no-pan">
|
|
449
462
|
<span>still loading</span>
|
|
450
|
-
<button className="sh-no-pan" onClick={() => reload(false)}>
|
|
463
|
+
<button className="sh-no-pan" onClick={() => { endOnReady(cmd('frame-reload', { via: 'click', in: 'shell', frame: node.frame }), node.key); reload(false) }}>
|
|
451
464
|
<ReloadIcon size={11} /> reload
|
|
452
465
|
</button>
|
|
453
466
|
</div>
|
|
@@ -469,7 +482,7 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
469
482
|
<div
|
|
470
483
|
className="sh-overlay sh-no-pan"
|
|
471
484
|
onPointerDown={(e) => { downAt.current = { x: e.clientX, y: e.clientY, t: pressNow() }; if (capturing) canvasPointer(null); drag(e, 'move') }}
|
|
472
|
-
onDoubleClick={(e) => { e.stopPropagation(); setInteract(node.key) }}
|
|
485
|
+
onDoubleClick={(e) => { e.stopPropagation(); cmd('interact', { via: 'dblclick', in: 'shell', frame: node.frame }); setInteract(node.key) }}
|
|
473
486
|
// a capture records canvas-mode clicks and hovers: the overlay keeps the click (drag and
|
|
474
487
|
// select are unchanged) and asks the frame what is under it
|
|
475
488
|
onClick={(e) => { const d = downAt.current; if (capturing && d && Math.hypot(e.clientX - d.x, e.clientY - d.y) < 4) canvasClick(node.key, e.clientX, e.clientY, d.t) }}
|
|
@@ -20,6 +20,7 @@ import { useComments } from '../comments-store.ts'
|
|
|
20
20
|
import { goTo } from '../goto.ts'
|
|
21
21
|
import { NOTE_W, SCENE_NOTE_W, noteAnchor, noteVisible, useNotes, type NoteKind } from '../notes.ts'
|
|
22
22
|
import { useStore } from '../store.ts'
|
|
23
|
+
import { cmd } from '../commands.ts'
|
|
23
24
|
|
|
24
25
|
export interface NoteSpec { kind: NoteKind; id: string; text: string }
|
|
25
26
|
|
|
@@ -253,12 +254,13 @@ function StickyBody({ text, kind, nodeKey, frameId }: { text: string; kind: Note
|
|
|
253
254
|
const origin = bodyEl.getBoundingClientRect()
|
|
254
255
|
const s = origin.width ? origin.width / nodeEl.offsetWidth : 1 // on-screen px per world px
|
|
255
256
|
const toBody = (r: DOMRect) => ({ x: (r.left - origin.left) / s, y: (r.top - origin.top) / s, w: r.width / s, h: r.height / s })
|
|
257
|
+
cmd('comment-pick', { via: 'click', in: 'shell', frame: frameId })
|
|
256
258
|
if (c.active) c.setActive(null)
|
|
257
259
|
c.setDraft({ nodeKey, frame: frameId, anchor: noteAnchor(pick, root, kind, e, toBody) })
|
|
258
260
|
return
|
|
259
261
|
}
|
|
260
262
|
const link = target.closest('a[data-goto]')
|
|
261
|
-
if (link) { e.preventDefault(); e.stopPropagation(); goTo(link.getAttribute('data-goto') ?? '') }
|
|
263
|
+
if (link) { e.preventDefault(); e.stopPropagation(); goTo(link.getAttribute('data-goto') ?? '', false, cmd('goto', { via: 'click', in: 'shell' })) }
|
|
262
264
|
}
|
|
263
265
|
return <div ref={ref} className="sh-sticky-body" onClick={onClick} />
|
|
264
266
|
}
|
|
@@ -287,7 +289,7 @@ export const Stickies = memo(function Stickies({ nodeKey, frameId, notes, underB
|
|
|
287
289
|
<div ref={col} className={`sh-notes${on ? '' : ' off'}${underBadge ? ' below-vbadge' : ''}`} data-node-notes={nodeKey} style={{ width }}>
|
|
288
290
|
<button className="sh-notes-fold sh-no-pan" type="button" aria-label={on ? 'hide notes' : 'show notes'} title={on ? 'hide notes (N: all)' : 'show notes (N: all)'}
|
|
289
291
|
onPointerDown={(e) => e.stopPropagation()}
|
|
290
|
-
onClick={(e) => { e.stopPropagation(); useNotes.getState().toggle(ids) }} />
|
|
292
|
+
onClick={(e) => { e.stopPropagation(); cmd('notes', { via: 'click', in: 'shell', frame: frameId }); useNotes.getState().toggle(ids) }} />
|
|
291
293
|
{notes.map((n) => (
|
|
292
294
|
<div key={n.id} className="sh-sticky sh-no-pan" data-sticky={n.kind} data-note={n.id} style={{ width: n.kind === 'scene' ? SCENE_NOTE_W : NOTE_W }}
|
|
293
295
|
onPointerDown={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>
|
|
@@ -29,6 +29,8 @@ export const canvasCtl = {
|
|
|
29
29
|
/** Is the camera mid-flight (a fit, a zoom)? A content-driven reflow waits for it to land: a fit
|
|
30
30
|
* aimed at the frames a link names must not land on where they were before the rows moved. */
|
|
31
31
|
cameraBusy(): boolean { return false },
|
|
32
|
+
/** Is a layout animation running (`animateLayout`)? The recorder's `tidy` and `device` end after it (spec 30). */
|
|
33
|
+
layoutBusy(): boolean { return false },
|
|
32
34
|
/** What the camera shows now, in world px (null with no canvas) - a load's visible cohort when no fit landed. */
|
|
33
35
|
view(): { x: number; y: number; w: number; h: number } | null { return null },
|
|
34
36
|
/** Where a rect on screen now will be once the camera lands from the flight it is on (a fit, a zoom) - itself while
|
|
@@ -26,3 +26,7 @@ export function shouldArmReadyWatch(node: ReadyNode, hasFrame: boolean): boolean
|
|
|
26
26
|
export function canAutoReload(node: ReadyNode): boolean {
|
|
27
27
|
return node.status === 'loading' && !node.readyRetried
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
/** What a silence comes to (spec 30 #20): the first a retry, the second giving up - the watchdog's own line says which,
|
|
31
|
+
* before it acts. */
|
|
32
|
+
export const silenceAction = (node: ReadyNode, hasFrame: boolean): 'retry' | 'gave-up' => (shouldArmReadyWatch(node, hasFrame) ? 'retry' : 'gave-up')
|
|
@@ -53,6 +53,8 @@ const keyOf = (k: SleepKey) => `${k.frame}|${k.theme}|${Math.round(k.w)}|${Math.
|
|
|
53
53
|
const asleep = new Map<string, { key: string; doc: Document }>()
|
|
54
54
|
/** How many frames are asleep now (the recorder's weight of a settled load, spec 28 A1.7). */
|
|
55
55
|
export const sleepingCount = (): number => asleep.size
|
|
56
|
+
/** Is this node's document asleep now (the recorder's `invalidated`, `ready`: spec 30 #13, #14)? */
|
|
57
|
+
export const isAsleep = (key: string): boolean => asleep.has(key)
|
|
56
58
|
/**
|
|
57
59
|
* The page's own bake work (spec 28 A3.8 #18): four counts of their own - `pending` below is the current request
|
|
58
60
|
* per node and survives a successful sleep, so it says nothing about idleness. `scheduled`: FrameNode's 250 ms
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { admit, release } from './admission.ts'
|
|
10
10
|
import { canvasCtl } from './ctl.ts'
|
|
11
|
-
import { frameIsLeased, useStore, type Node } from '../store.ts'
|
|
11
|
+
import { frameIsLeased, reloadHooks, useStore, type Node } from '../store.ts'
|
|
12
|
+
import type { HeldBy } from '../../../shared/perf-records.ts'
|
|
12
13
|
|
|
13
14
|
const rect = (key: string) => document.querySelector(`[data-node="${CSS.escape(key)}"]`)?.getBoundingClientRect()
|
|
14
15
|
const view = () => document.querySelector('.sh-canvas')?.getBoundingClientRect()
|
|
@@ -26,11 +27,16 @@ const rank = (key: string) => () => {
|
|
|
26
27
|
return r && c ? Math.hypot(r.x + r.width / 2 - c.x - c.width / 2, r.y + r.height / 2 - c.y - c.height / 2) : Infinity
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
/** Why a node's job may not start now, or null - the one list of what holds a reload (the recorder reads it too, spec 30
|
|
31
|
+
* #13). A document to replace (ready, or errored), never one still booting for the first time. */
|
|
32
|
+
export function heldBy(n: Node, s = useStore.getState()): HeldBy | null {
|
|
33
|
+
if (n.missing) return 'missing'
|
|
34
|
+
if (n.status !== 'ready' && n.status !== 'error') return 'loading'
|
|
35
|
+
if (s.play) return 'play'
|
|
36
|
+
if (frameIsLeased(n.frame, s)) return 'leased'
|
|
37
|
+
return onScreen(n.key) ? null : 'offscreen'
|
|
33
38
|
}
|
|
39
|
+
const ready = (n: Node) => !!n.stale && !heldBy(n)
|
|
34
40
|
|
|
35
41
|
let ticker: ReturnType<typeof setInterval> | undefined
|
|
36
42
|
|
|
@@ -42,7 +48,8 @@ export function pumpUpdates(): void {
|
|
|
42
48
|
if (!stale.length) { clearInterval(ticker); ticker = undefined; return }
|
|
43
49
|
ticker ??= setInterval(pumpUpdates, 400)
|
|
44
50
|
for (const n of stale) {
|
|
45
|
-
|
|
51
|
+
const why = heldBy(n, s)
|
|
52
|
+
if (why) { reloadHooks.held(n.key, why); continue }
|
|
46
53
|
admit({
|
|
47
54
|
key: n.key,
|
|
48
55
|
rank: rank(n.key),
|