@marver-design/marver 0.23.1 → 0.25.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 +66 -0
- package/README.md +3 -1
- package/dist/anchor-DVV732zR.mjs +33 -0
- package/dist/anchor-check-BE5VVN6Q.mjs +135 -0
- package/dist/{bake-DQtnDB8-.mjs → bake-D8byeRzB.mjs} +1 -1
- package/dist/{boards-BRLnoTC3.mjs → board-tree-DRioF94d.mjs} +21 -277
- package/dist/boards-CGg6piKF.mjs +342 -0
- package/dist/{boards-Dv-Ipd8G.mjs → boards-Csxj2WJn.mjs} +23 -9
- package/dist/{build-_ndp_dXn.mjs → build-BHoWLvSj.mjs} +63 -37
- package/dist/cli.mjs +31 -17
- package/dist/{collab-mAiNZlDj.mjs → collab-gqNdScUE.mjs} +39 -9
- package/dist/{comments-DZyobpxG.mjs → comments-Zoch254k.mjs} +19 -1
- package/dist/{comments-BlqyZh3D.mjs → comments-pTLlhjh4.mjs} +150 -20
- package/dist/{config-BUKprFAp.mjs → config-cKgZBRj0.mjs} +1 -1
- package/dist/{context-CdkNiKdJ.mjs → context-D2ugHqwO.mjs} +17 -123
- package/dist/{daemon-BvMPdQ3k.mjs → daemon-Cl8KXGW4.mjs} +146 -64
- package/dist/{dev-Cf-4eqaC.mjs → dev-DJdgow47.mjs} +23 -11
- package/dist/{events-B3LBn74P.mjs → events-DnK_AnrW.mjs} +13 -15
- package/dist/imports-WBSnnHLb.mjs +143 -0
- package/dist/{init-hfZV7TwY.mjs → init-DO4DhUt_.mjs} +28 -6
- package/dist/link-C-qUIuKU.mjs +160 -0
- package/dist/{board-status-BZSzc9Hp.mjs → manifest-DnAte_fB.mjs} +537 -13
- package/dist/marks-DFuintmJ.mjs +50 -0
- package/dist/marks-koRsbHfe.mjs +397 -0
- package/dist/{marver-id-gate-B_idGdHm.mjs → marver-id-gate-DGANtVyC.mjs} +2 -2
- package/dist/perf-CCisg-ny.mjs +49 -0
- package/dist/perf-QJIWtTw1.mjs +68 -0
- package/dist/{plugin-DoXql0ZZ.mjs → plugin-CTyhjwoJ.mjs} +469 -82
- package/dist/{poster-XBmUvQiL.mjs → poster-D0cbV7hi.mjs} +1 -1
- package/dist/{profile-CrZohD6g.mjs → profile-Do0nGkXO.mjs} +1 -1
- package/dist/{publish-bakes-KKTHWqq3.mjs → publish-bakes--l8ot2eQ.mjs} +9 -9
- package/dist/{serve-z5qtj_wJ.mjs → serve-wv2QWdxB.mjs} +6 -6
- package/dist/{share-BD-wcDQq.mjs → share-ScamJcks.mjs} +1 -1
- package/dist/{shot-DOD8v6fJ.mjs → shot-CckrGW-J.mjs} +19 -11
- package/dist/{shot-Dh6fV1Lm.mjs → shot-jdO_B6Qw.mjs} +1 -1
- package/dist/{summary-C7CAypbB.mjs → summary-CrW88e3q.mjs} +1 -1
- package/dist/{sync-DoA1vf4u.mjs → sync-C3035OnJ.mjs} +18 -8
- package/dist/{work-ClFFq0Qh.mjs → work-CpJn1gwY.mjs} +8 -4
- package/dist/{work-ayuL_9Kk.mjs → work-GE88wb_3.mjs} +4 -4
- package/docs/boards-and-folders.md +70 -4
- package/docs/live-jam.md +12 -4
- package/package.json +1 -1
- package/src/client/frame-host/bridge.js +2 -1
- package/src/client/frame-host/inspect.js +195 -84
- package/src/client/frame-host/main.tsx +7 -2
- package/src/client/frame-host/registry.ts +5 -5
- package/src/client/shell/App.tsx +98 -30
- package/src/client/shell/BoardList.tsx +74 -16
- package/src/client/shell/Comments.tsx +79 -34
- package/src/client/shell/ContextMenu.tsx +5 -2
- package/src/client/shell/LockedApp.tsx +45 -12
- package/src/client/shell/Play.tsx +35 -32
- package/src/client/shell/Toolbar.tsx +3 -1
- package/src/client/shell/canvas/Canvas.tsx +2 -0
- package/src/client/shell/canvas/FrameNode.tsx +15 -5
- package/src/client/shell/canvas/sleep.ts +4 -3
- package/src/client/shell/canvas/updates.ts +55 -0
- package/src/client/shell/comments-store.ts +48 -17
- package/src/client/shell/goto.ts +11 -14
- package/src/client/shell/hash.ts +12 -5
- package/src/client/shell/icons.tsx +1 -2
- package/src/client/shell/legacy-links.ts +67 -0
- package/src/client/shell/marks-ui.tsx +117 -0
- package/src/client/shell/pin-layout.ts +37 -0
- package/src/client/shell/store.ts +377 -67
- package/src/client/shell/styles.css +32 -8
- package/src/client/stage/main.tsx +19 -2
- package/src/shared/anchor.ts +57 -0
- package/src/shared/board-tree.ts +27 -10
- package/src/shared/events.ts +19 -10
- package/src/shared/marks.ts +70 -0
- package/templates/AGENTS-embedded.md +34 -15
- package/templates/AGENTS-studio.md +34 -15
- package/templates/instructions/boards.md +9 -5
- package/templates/instructions/iterate.md +20 -10
- package/templates/instructions/jam.md +13 -4
- package/templates/instructions/publish.md +2 -1
- package/templates/instructions/reference/deck-story.md +2 -2
- package/dist/link-BodAbIQz.mjs +0 -132
- package/dist/manifest-TpfDWldB.mjs +0 -528
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Comment surfaces on the canvas. Canvas-first: pins live ON the frame
|
|
3
3
|
* at their anchored elements; an inactive frame collapses its open threads into a
|
|
4
4
|
* top-right stack; the thread card opens beside its pin. Pins keep a screen-space
|
|
5
|
-
* size via --sh-inv (the vbadge pattern) so zoom never shrinks them away
|
|
5
|
+
* size via --sh-inv (the vbadge pattern) so zoom never shrinks them away, and never
|
|
6
|
+
* overlap (pin-layout.ts places them).
|
|
6
7
|
*/
|
|
7
8
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
8
9
|
import { createPortal } from 'react-dom'
|
|
@@ -11,7 +12,9 @@ import { CONFIG, useStore, type Node } from './store.ts'
|
|
|
11
12
|
import { threadHostKey } from './keys.ts'
|
|
12
13
|
import { isNoteAnchor, resolveNoteAnchor, useNotes } from './notes.ts'
|
|
13
14
|
import { canvasCtl } from './canvas/ctl.ts'
|
|
15
|
+
import { MARKER, placeMarkers, type Placed } from './pin-layout.ts'
|
|
14
16
|
import { bootHash, buildHash, parseHash, writeHash } from './hash.ts'
|
|
17
|
+
import { isLegacyLink } from './legacy-links.ts'
|
|
15
18
|
import { ArrowUpIcon, CheckIcon, CheckSquareOffsetIcon, LinkIcon, ParallelogramFillIcon, PencilSimpleIcon, PlusIcon, XIcon } from './icons.tsx'
|
|
16
19
|
import { Tip } from './Tip.tsx'
|
|
17
20
|
import { mentionAlerts, mentionPeople, mentionQueryAt, parseBody, type MentionPerson } from './mentions.ts'
|
|
@@ -115,6 +118,44 @@ export function MarkerFace({ threads, max = 3 }: { threads: Thread[]; max?: numb
|
|
|
115
118
|
)
|
|
116
119
|
}
|
|
117
120
|
|
|
121
|
+
type Point = { x: number; y: number }
|
|
122
|
+
|
|
123
|
+
/** Open threads in creation order - the order markers are placed in, so a newer one moves, never
|
|
124
|
+
* an older one. */
|
|
125
|
+
export const byCreation = (threads: Thread[]): Thread[] => [...threads].sort((a, b) => a.ts - b.ts || (a.id < b.id ? -1 : 1))
|
|
126
|
+
|
|
127
|
+
/** Place one surface's markers - a canvas frame (node px) or the stage (screen px, inv 1): fixed
|
|
128
|
+
* points, a fixed marker size, the column for threads with no point. It reads nothing a selection
|
|
129
|
+
* or an open card changes, so neither ever moves a marker. */
|
|
130
|
+
export const placePins = (threads: Thread[], points: Map<string, Point | null>, frameW: number, inv: number) =>
|
|
131
|
+
placeMarkers(byCreation(threads).map((t) => ({ id: t.id, point: points.get(t.id) ?? null })), frameW, inv)
|
|
132
|
+
|
|
133
|
+
/** The placed markers, with a thin line from each one that had to move to its point. */
|
|
134
|
+
export function Pins({ threads, placed, orphans, inv, active, alertIds }: {
|
|
135
|
+
threads: Thread[]; placed: Map<string, Placed>; orphans: Set<string>
|
|
136
|
+
inv: number; active: string | null; alertIds?: Set<string>
|
|
137
|
+
}) {
|
|
138
|
+
const { setActive } = useComments.getState()
|
|
139
|
+
return (
|
|
140
|
+
<>
|
|
141
|
+
{threads.map((t) => {
|
|
142
|
+
const p = placed.get(t.id)!
|
|
143
|
+
const orphan = orphans.has(t.id)
|
|
144
|
+
return [
|
|
145
|
+
p.lead && <i key={`${t.id}-lead`} data-lead={t.id} className="cm-lead" aria-hidden style={{ left: p.lead.x, top: p.lead.y, height: p.y - MARKER.h * inv - p.lead.y }} />,
|
|
146
|
+
<div key={t.id} data-thread={t.id} className={`cm-pin sh-no-pan${t.id === active ? ' on' : ''}${orphan ? ' orphan' : ''}${alertIds?.has(t.id) ? ' mention' : ''}`}
|
|
147
|
+
style={{ left: p.x, top: p.y, ...hueVars(anchorHue(t.anchor)) }}
|
|
148
|
+
onPointerDown={(e) => e.stopPropagation()}
|
|
149
|
+
onClick={(e) => { e.stopPropagation(); setActive(t.id === active ? null : t.id) }}
|
|
150
|
+
title={orphan ? 'the anchored element is gone - comment parked' : undefined}>
|
|
151
|
+
<MarkerFace threads={[t]} max={2} />
|
|
152
|
+
</div>,
|
|
153
|
+
]
|
|
154
|
+
})}
|
|
155
|
+
</>
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
118
159
|
/** Lives inside FrameNode's body, over the iframe. Owns anchor resolution for its frame. */
|
|
119
160
|
export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: string; iframe: React.RefObject<HTMLIFrameElement | null> }) {
|
|
120
161
|
const show = useComments((s) => s.show)
|
|
@@ -131,7 +172,11 @@ export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: s
|
|
|
131
172
|
const threads = allThreads.filter((t) => t.frame === frameId && threadHostKey(t, allNodes) === node.key)
|
|
132
173
|
const selected = useStore((s) => s.selection.includes(node.key))
|
|
133
174
|
const { setActive } = useComments.getState()
|
|
134
|
-
|
|
175
|
+
// each in-frame thread's attach point, in the frame's px - null when its element is gone
|
|
176
|
+
const [framePoints, setFramePoints] = useState<Record<string, Point | null>>({})
|
|
177
|
+
// the zoom markers are placed at: the store commits it once a zoom settles, never mid-gesture,
|
|
178
|
+
// so markers hold still while you zoom and land once
|
|
179
|
+
const scale = useStore((s) => s.scale)
|
|
135
180
|
// a slide renders at its stage and the node scales it (FrameNode): rects the frame reports are
|
|
136
181
|
// in stage px, so they map through the same fit into the node's coordinates
|
|
137
182
|
const frameEntry = useStore((s) => s.frameFor(node))
|
|
@@ -139,6 +184,7 @@ export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: s
|
|
|
139
184
|
const fit = stage ? stageFit(stage, { w: node.w, h: node.h }) : null
|
|
140
185
|
const inNode = <R extends { x: number; y: number; w: number; h: number }>(r: R): R =>
|
|
141
186
|
fit ? { ...r, x: fit.ox + r.x * fit.k, y: fit.oy + r.y * fit.k, w: r.w * fit.k, h: r.h * fit.k } : r
|
|
187
|
+
const pointInNode = (p: Point): Point => (fit ? { x: fit.ox + p.x * fit.k, y: fit.oy + p.y * fit.k } : p)
|
|
142
188
|
|
|
143
189
|
const open = threads.filter((t) => !t.resolved)
|
|
144
190
|
const anchored = open.filter((t) => (t.anchor as any)?.el)
|
|
@@ -150,28 +196,29 @@ export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: s
|
|
|
150
196
|
// postMessage) or on a sticky note (spec 18: shell DOM, resolved right here)
|
|
151
197
|
const inFrame = anchored.filter((t) => !isNoteAnchor(t.anchor))
|
|
152
198
|
const onNote = anchored.filter((t) => isNoteAnchor(t.anchor))
|
|
153
|
-
// resolve anchors against the live frame whenever threads or the
|
|
199
|
+
// resolve anchors against the live frame whenever threads, their anchors (a re-pin) or the
|
|
200
|
+
// document change
|
|
154
201
|
useEffect(() => {
|
|
155
202
|
const win = iframe.current?.contentWindow
|
|
156
203
|
if (!win || node.status !== 'ready' || !inFrame.length) return
|
|
157
204
|
const ask = () => win.postMessage({ type: 'sh:resolve-anchors', anchors: inFrame.map((t) => ({ key: t.id, anchor: t.anchor })) }, location.origin)
|
|
158
205
|
const onMsg = (e: MessageEvent) => {
|
|
159
206
|
if (e.source !== win || e.origin !== location.origin || e.data?.type !== 'sh:anchor-rects') return
|
|
160
|
-
const next: typeof
|
|
161
|
-
for (const r of e.data.rects ?? []) next[r.key] = r.orphan ? null : r.
|
|
162
|
-
|
|
207
|
+
const next: typeof framePoints = {}
|
|
208
|
+
for (const r of e.data.rects ?? []) next[r.key] = r.orphan ? null : r.point
|
|
209
|
+
setFramePoints((cur) => (JSON.stringify(cur) === JSON.stringify(next) ? cur : next))
|
|
163
210
|
}
|
|
164
211
|
window.addEventListener('message', onMsg)
|
|
165
212
|
ask()
|
|
166
213
|
const iv = setInterval(ask, 4000) // re-renders, scroll, hot reloads - cheap to re-ask
|
|
167
214
|
return () => { clearInterval(iv); window.removeEventListener('message', onMsg) }
|
|
168
|
-
}, [node.status, inFrame.map((t) => t.id).join(','), iframe])
|
|
215
|
+
}, [node.status, inFrame.map((t) => `${t.id}:${JSON.stringify(t.anchor)}`).join(','), iframe])
|
|
169
216
|
// note anchors: their own map, measured in the shell, in node-body coordinates (negative x -
|
|
170
217
|
// the note is left of the frame). The composing draft is measured too (key 'draft'), so it
|
|
171
218
|
// follows a fold like a saved pin. A folded column parks pins on the fold; a note whose file
|
|
172
219
|
// is gone, or whose element the markdown no longer has, parks like an orphan. Re-measured on
|
|
173
220
|
// every fold/unfold (twice: at once and past the transition) and on the same 4 s beat.
|
|
174
|
-
const [noteRects, setNoteRects] = useState<
|
|
221
|
+
const [noteRects, setNoteRects] = useState<Record<string, { x: number; y: number; w: number; h: number } | null>>({})
|
|
175
222
|
const notesState = useNotes()
|
|
176
223
|
const draftOnNote = draft?.nodeKey === node.key && isNoteAnchor(draft.anchor) ? draft.anchor : null
|
|
177
224
|
useEffect(() => {
|
|
@@ -191,7 +238,7 @@ export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: s
|
|
|
191
238
|
const el = resolveNoteAnchor(a, body)
|
|
192
239
|
return el ? toBody(el.getBoundingClientRect()) : null
|
|
193
240
|
}
|
|
194
|
-
const next: typeof
|
|
241
|
+
const next: typeof noteRects = {}
|
|
195
242
|
for (const t of onNote) next[t.id] = place(t.anchor)
|
|
196
243
|
if (draftOnNote) next.draft = place(draftOnNote)
|
|
197
244
|
setNoteRects(next)
|
|
@@ -226,8 +273,9 @@ export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: s
|
|
|
226
273
|
const el = body && resolveNoteAnchor(anchor, body)
|
|
227
274
|
if (el) el.setAttribute('data-sh-lock', '')
|
|
228
275
|
}
|
|
229
|
-
// active/draft/show/showAnchor/activeShown
|
|
230
|
-
|
|
276
|
+
// active/draft/show/showAnchor/activeShown and the active anchor (a re-pin) are the triggers;
|
|
277
|
+
// `open` is read fresh from the closure
|
|
278
|
+
}, [active, draft, show, showAnchor, activeShown, JSON.stringify(open.find((t) => t.id === active)?.anchor ?? null), node.status, node.key, frameId, iframe])
|
|
231
279
|
|
|
232
280
|
// the open card's frozen side (D3) - a HOOK, so it must live above the early returns; and the
|
|
233
281
|
// reset must too: a card can close via the inactive-frame early return (clicking another frame),
|
|
@@ -254,15 +302,22 @@ export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: s
|
|
|
254
302
|
)
|
|
255
303
|
}
|
|
256
304
|
|
|
257
|
-
|
|
305
|
+
// each open thread's attach point in node px: a note's where it was clicked on the note, a
|
|
306
|
+
// frame's where the frame says; none (the column) for a legacy frame-level pin, an orphan, or
|
|
307
|
+
// an anchor not resolved yet
|
|
308
|
+
const points = new Map<string, Point | null>()
|
|
309
|
+
const orphans = new Set<string>()
|
|
310
|
+
for (const t of open) {
|
|
258
311
|
const a = t.anchor as any
|
|
259
|
-
|
|
260
|
-
const r = isNoteAnchor(a) ? noteRects[t.id] :
|
|
261
|
-
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
return { x: (p?.fx ?? 0.94) * node.w, y: (p?.fy ?? 0.06) * node.h, orphan: false }
|
|
312
|
+
if (!a?.el) continue
|
|
313
|
+
const r = isNoteAnchor(a) ? noteRects[t.id] : undefined
|
|
314
|
+
const p = isNoteAnchor(a) ? (r ? { x: r.x + (a.pos?.fx ?? 0.5) * r.w, y: r.y + (a.pos?.fy ?? 0.5) * r.h } : r) : framePoints[t.id] && pointInNode(framePoints[t.id]!)
|
|
315
|
+
if (p === null) orphans.add(t.id)
|
|
316
|
+
points.set(t.id, p ?? null)
|
|
265
317
|
}
|
|
318
|
+
const inv = 1 / Math.max(0.01, scale)
|
|
319
|
+
const placed = placePins(open, points, node.w, inv)
|
|
320
|
+
const pinAt = (t: Thread): Placed => placed.get(t.id)!
|
|
266
321
|
|
|
267
322
|
// The card's SIDE, chosen ONCE per open and frozen (D3 - never switches mid-read): the pin's
|
|
268
323
|
// side of the frame first, skipping a side another frame's screen rect occupies, then wherever
|
|
@@ -290,7 +345,7 @@ export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: s
|
|
|
290
345
|
// panel is a card nobody can read (a note's gutter makes that reach likelier)
|
|
291
346
|
const panelRight = document.querySelector('.sh-panel:not(.closed)')?.getBoundingClientRect().right ?? 0
|
|
292
347
|
const room = (s: 'l' | 'r') => (s === 'r' ? window.innerWidth - rect.right : rect.left - gutter - panelRight) >= W + GAP
|
|
293
|
-
const prefer: ('l' | 'r')[] =
|
|
348
|
+
const prefer: ('l' | 'r')[] = pinAt(activeThread2).x < node.w / 2 ? ['l', 'r'] : ['r', 'l']
|
|
294
349
|
return prefer.find((s) => room(s) && !occupied(s)) ?? prefer.find(room) ?? prefer[0]
|
|
295
350
|
}
|
|
296
351
|
sideRef.current = { id: activeThread2.id, side: compute() }
|
|
@@ -299,21 +354,9 @@ export function CommentLayer({ node, frameId, iframe }: { node: Node; frameId: s
|
|
|
299
354
|
|
|
300
355
|
return (
|
|
301
356
|
<>
|
|
302
|
-
{open
|
|
303
|
-
const { x, y, orphan } = pinPos(t)
|
|
304
|
-
const isActive = t.id === active
|
|
305
|
-
return (
|
|
306
|
-
<div key={t.id} className={`cm-pin sh-no-pan${isActive ? ' on' : ''}${isActive && cardSide === 'r' ? ' tail-r' : ''}${orphan ? ' orphan' : ''}${alertIds.has(t.id) ? ' mention' : ''}`}
|
|
307
|
-
style={{ left: x, top: y, ...hueVars(anchorHue(t.anchor)) }}
|
|
308
|
-
onPointerDown={(e) => e.stopPropagation()}
|
|
309
|
-
onClick={(e) => { e.stopPropagation(); setActive(t.id === active ? null : t.id) }}
|
|
310
|
-
title={orphan ? 'the anchored element is gone - comment parked' : undefined}>
|
|
311
|
-
<MarkerFace threads={[t]} />
|
|
312
|
-
</div>
|
|
313
|
-
)
|
|
314
|
-
})}
|
|
357
|
+
<Pins threads={open} placed={placed} orphans={orphans} inv={inv} active={active} alertIds={alertIds} />
|
|
315
358
|
{activeThread2 && (
|
|
316
|
-
<ThreadCard key={active} thread={activeThread2} at={
|
|
359
|
+
<ThreadCard key={active} thread={activeThread2} at={pinAt(activeThread2)} bounds={{ w: node.w, h: node.h }} nodeKey={node.key} side={cardSide}
|
|
317
360
|
flank={cardSide === 'l' ? (noteColumn() ? 'note' : flankBadge ? 'badge' : flankShim ? 'shim' : null) : null} />
|
|
318
361
|
)}
|
|
319
362
|
{draft?.nodeKey === node.key && (() => {
|
|
@@ -943,6 +986,8 @@ export function revealThread(c: string): boolean {
|
|
|
943
986
|
/** Board-level comment wiring: load + liveness + mode broadcast, one instance in App. */
|
|
944
987
|
let bootThreadConsumed = false
|
|
945
988
|
let pendingThread: string | null = null // cross-board deep link awaiting its board's comments
|
|
989
|
+
/** Open this thread once the board just switched to has loaded its comments (an old link, App.tsx). */
|
|
990
|
+
export const parkThread = (id: string) => { pendingThread = id }
|
|
946
991
|
export function CommentsController() {
|
|
947
992
|
const ctlShowAnchor = useComments((s) => s.showAnchor)
|
|
948
993
|
const board = useStore((s) => s.board)
|
|
@@ -999,7 +1044,7 @@ export function CommentsController() {
|
|
|
999
1044
|
if (!s.local && !s.me) useComments.setState({ inviteToken: h.invite, needsIdentity: true })
|
|
1000
1045
|
return
|
|
1001
1046
|
}
|
|
1002
|
-
if (!h.c) return
|
|
1047
|
+
if (!h.c || isLegacyLink(h)) return // an old All Scenes link: App.tsx finds its board first
|
|
1003
1048
|
if (!revealThread(h.c)) pendingThread = h.c
|
|
1004
1049
|
}
|
|
1005
1050
|
window.addEventListener('hashchange', onHash)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react'
|
|
2
2
|
import { createPortal } from 'react-dom'
|
|
3
3
|
import { useStore, SOURCE_REVEALED } from './store.ts'
|
|
4
|
+
import { UNPLACED } from './hash.ts'
|
|
4
5
|
|
|
5
6
|
/** Copy text to the clipboard, toasting the outcome. Success is confirmed out loud; a
|
|
6
7
|
* blocked clipboard (no user gesture / permission) says so instead of failing silently. */
|
|
@@ -13,8 +14,10 @@ export function copyToClipboard(text: string, okMsg: string) {
|
|
|
13
14
|
* toolbar, and ⇧P: the board it sits on, the frame id, and its file. */
|
|
14
15
|
// stripped build: the file column would only show the opaque token, so the
|
|
15
16
|
// copy keeps what is still honest - the board and the frame id
|
|
16
|
-
export const framePath = (board: string, f: { id: string; file: string }) =>
|
|
17
|
-
|
|
17
|
+
export const framePath = (board: string, f: { id: string; file: string }) => {
|
|
18
|
+
const where = board === UNPLACED ? 'not on a board' : `board: ${board}`
|
|
19
|
+
return SOURCE_REVEALED ? `${where} · frame: ${f.id} (${f.file})` : `${where} · frame: ${f.id}`
|
|
20
|
+
}
|
|
18
21
|
|
|
19
22
|
/** A menu row. `panel` makes it open a panel IN PLACE of the menu (a picker - the board's status),
|
|
20
23
|
* drawn by the caller and handed `close`; `onClick` then is not called. */
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
* within what the lock allows.
|
|
11
11
|
*/
|
|
12
12
|
import { Component, useEffect, useRef, type ReactNode } from 'react'
|
|
13
|
-
import { useStore, landingMode, tabTitle } from './store.ts'
|
|
13
|
+
import { useStore, landingBoard, landingMode, tabTitle } from './store.ts'
|
|
14
14
|
import { enterFocus, enterPlay, enterSlides, PlayOverlay, playCtl } from './Play.tsx'
|
|
15
|
-
import { bootHash, parseHash, writeHash } from './hash.ts'
|
|
15
|
+
import { UNPLACED, bootHash, parseHash, retargetBoot, writeHash } from './hash.ts'
|
|
16
|
+
import { isLegacyLink, landLegacy } from './legacy-links.ts'
|
|
16
17
|
import { useComments } from './comments-store.ts'
|
|
17
18
|
|
|
18
19
|
export class ShellBoundary extends Component<{ children: ReactNode }, { err: Error | null }> {
|
|
@@ -31,6 +32,15 @@ export class ShellBoundary extends Component<{ children: ReactNode }, { err: Err
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
let booted = false
|
|
35
|
+
/** A thread a link names: opened on the stage once the comments are on its board (a board's load
|
|
36
|
+
* closes the open thread, so never before - the effect below opens it after). */
|
|
37
|
+
let pendingThread: string | null = null
|
|
38
|
+
const openPending = () => {
|
|
39
|
+
const c = useComments.getState()
|
|
40
|
+
if (!pendingThread || c.board !== useStore.getState().board || !c.threads.some((t) => t.id === pendingThread)) return
|
|
41
|
+
c.setActive(pendingThread)
|
|
42
|
+
pendingThread = null
|
|
43
|
+
}
|
|
34
44
|
|
|
35
45
|
export function App() {
|
|
36
46
|
const toasts = useStore((s) => s.toasts)
|
|
@@ -38,19 +48,24 @@ export function App() {
|
|
|
38
48
|
|
|
39
49
|
/** The landing rule, enforced: the mode the lock pinned, entered on boot and
|
|
40
50
|
* re-entered if anything ever drops the overlay - there is no other surface. */
|
|
41
|
-
const land = () => {
|
|
51
|
+
const land = (at?: string) => {
|
|
42
52
|
const s = useStore.getState()
|
|
43
53
|
if (s.play) return
|
|
44
54
|
const mode = landingMode(s.board)
|
|
45
|
-
if (mode === 'focus') enterFocus()
|
|
46
|
-
else if (mode === 'slides') enterSlides()
|
|
47
|
-
else enterPlay()
|
|
55
|
+
if (mode === 'focus') enterFocus(at)
|
|
56
|
+
else if (mode === 'slides') enterSlides(at ? { at } : undefined)
|
|
57
|
+
else enterPlay(at ? { at } : undefined)
|
|
48
58
|
}
|
|
49
59
|
|
|
50
60
|
useEffect(() => {
|
|
51
61
|
if (booted) return
|
|
52
62
|
booted = true
|
|
53
63
|
const start = async () => {
|
|
64
|
+
// an old All Scenes link: a real board, at the frame it names, with what to say about it
|
|
65
|
+
let notice: string | null = null
|
|
66
|
+
if (isLegacyLink(bootHash)) { const r = await landLegacy(bootHash); retargetBoot(r.hash); notice = r.notice }
|
|
67
|
+
// the Not on a board view is dev's: a published canvas opens its default board instead
|
|
68
|
+
if (bootHash.board === UNPLACED) retargetBoot({})
|
|
54
69
|
if (bootHash.board && bootHash.board !== useStore.getState().board)
|
|
55
70
|
useStore.setState({ board: bootHash.board, boardAuto: false })
|
|
56
71
|
const ok = await boot()
|
|
@@ -59,7 +74,9 @@ export function App() {
|
|
|
59
74
|
if (bootHash.focus) enterFocus(bootHash.focus.at, { ...bootHash.focus, deep: true })
|
|
60
75
|
else if (bootHash.play?.slides) enterSlides(bootHash.play)
|
|
61
76
|
else if (bootHash.play) enterPlay(bootHash.play)
|
|
62
|
-
else land()
|
|
77
|
+
else land(bootHash.f?.[0])
|
|
78
|
+
if (notice) useStore.getState().toast(notice)
|
|
79
|
+
if (bootHash.c) { pendingThread = bootHash.c; openPending() }
|
|
63
80
|
}
|
|
64
81
|
const boot = useStore.getState().boot
|
|
65
82
|
void start()
|
|
@@ -79,14 +96,30 @@ export function App() {
|
|
|
79
96
|
|
|
80
97
|
// back/forward + pasted links, within what the lock allows
|
|
81
98
|
useEffect(() => {
|
|
99
|
+
let popSeq = 0
|
|
82
100
|
const onPop = async () => {
|
|
83
|
-
|
|
101
|
+
// a lookup newer navigation overtook - a link, a step on the stage - is dropped
|
|
102
|
+
const mine = ++popSeq, was = useStore.getState()
|
|
103
|
+
const parsed = parseHash()
|
|
104
|
+
const raw = parsed.board === UNPLACED ? {} : parsed // dev's view, and what it names: not here
|
|
105
|
+
// an old All Scenes link lands on a real board; it, and the bare #/, with no board: the landing one
|
|
106
|
+
const r = isLegacyLink(raw) ? await landLegacy(raw) : { hash: raw, notice: null }
|
|
107
|
+
const h = r.hash
|
|
108
|
+
const board = h.board ?? (h.focus ? undefined : await landingBoard())
|
|
84
109
|
const s = useStore.getState()
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
110
|
+
if (mine !== popSeq || s.board !== was.board || s.play?.at !== was.play?.at) return
|
|
111
|
+
if (r.notice) s.toast(r.notice)
|
|
112
|
+
if (h.c) pendingThread = h.c
|
|
113
|
+
if (board && board !== s.board) {
|
|
114
|
+
await s.switchBoard(board)
|
|
115
|
+
useStore.getState().setPlay(null) // the stage restarts on the board the link names, at its frame
|
|
116
|
+
if (h.play?.slides) enterSlides(h.play)
|
|
117
|
+
else if (h.play) enterPlay(h.play)
|
|
118
|
+
else land(h.f?.[0])
|
|
88
119
|
return
|
|
89
120
|
}
|
|
121
|
+
openPending() // same board: its comments are here already
|
|
122
|
+
if (h.f?.length && s.play) return playCtl.setAt(h.f[0]) // the stage on screen steps to the frame named
|
|
90
123
|
if (h.focus) enterFocus(h.focus.at, { ...h.focus, deep: true })
|
|
91
124
|
// sync only holds WITHIN a mode: same-mode restores drive the MOUNTED
|
|
92
125
|
// stage (sh:stage-set); crossing present↔slides re-enters and remounts
|
|
@@ -103,7 +136,7 @@ export function App() {
|
|
|
103
136
|
useEffect(() => {
|
|
104
137
|
if (!board) return
|
|
105
138
|
const c = useComments.getState()
|
|
106
|
-
void c.load(board)
|
|
139
|
+
void c.load(board).then(openPending)
|
|
107
140
|
return c.live(board)
|
|
108
141
|
}, [board])
|
|
109
142
|
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
import { useEffect, useRef, useState } from 'react'
|
|
14
14
|
import { useStore, BOARD_POLICY, BRANDING, CONFIG, PUBLISHED, SOURCE_REVEALED, boardLabel, boardLocked, cap, fetchBoardNames, modeAllowed, playsAsSlides, SLIDE_INTRINSIC, type Node } from './store.ts'
|
|
15
15
|
import { deckOrder } from './play-order.ts'
|
|
16
|
-
import { useComments } from './comments-store.ts'
|
|
16
|
+
import { NO_COMMENTS_HERE, useComments } from './comments-store.ts'
|
|
17
|
+
import { UNPLACED } from './hash.ts'
|
|
17
18
|
import { isNoteAnchor } from './notes.ts'
|
|
18
19
|
import { ROUTE, slideSize } from '../const.ts'
|
|
19
20
|
import { poweredByUrl } from '../../shared/utm.ts'
|
|
@@ -21,7 +22,7 @@ import { canvasCtl } from './canvas/ctl.ts'
|
|
|
21
22
|
import { revealFrame } from './goto.ts'
|
|
22
23
|
import { Tip } from './Tip.tsx'
|
|
23
24
|
import { CommentButton, DevicePicker, HideUIButton, isHideUI, LaserButton, Popover, ThemePicker, toggleHideUI, usePopover } from './Toolbar.tsx'
|
|
24
|
-
import { DraftComposer,
|
|
25
|
+
import { DraftComposer, Pins, placePins, ThreadCard } from './Comments.tsx'
|
|
25
26
|
import { ArrowLeftIcon, ArrowRightIcon, BrowsersIcon, CaretIcon, CheckIcon, GridIcon, PanelFilledIcon, PanelHollowIcon, ParallelogramDuoIcon, ReloadIcon, SpecDocIcon } from './icons.tsx'
|
|
26
27
|
|
|
27
28
|
const commentsStore = () => useComments.getState()
|
|
@@ -208,12 +209,12 @@ function PlayComments({ iframe, frameId, vp, dw, dh, ready }: {
|
|
|
208
209
|
const active = useComments((s) => s.active)
|
|
209
210
|
const draft = useComments((s) => s.draft)
|
|
210
211
|
const allThreads = useComments((s) => s.threads)
|
|
211
|
-
const { setActive } = useComments.getState()
|
|
212
212
|
// a thread on a sticky note (spec 18) belongs to the canvas: the stage has no notes, and its
|
|
213
213
|
// anchor must never be handed to inspect.js (a same-named frame element would match)
|
|
214
214
|
const threads = allThreads.filter((t) => t.frame === frameId && !t.resolved && !isNoteAnchor(t.anchor))
|
|
215
215
|
const anchored = threads.filter((t) => (t.anchor as any)?.el)
|
|
216
|
-
|
|
216
|
+
// each thread's attach point in the frame's px - null when its element is gone
|
|
217
|
+
const [points, setPoints] = useState<Record<string, { x: number; y: number } | null>>({})
|
|
217
218
|
const sx = vp.width ? dw / vp.width : 1
|
|
218
219
|
const sy = vp.height ? dh / vp.height : 1
|
|
219
220
|
|
|
@@ -221,14 +222,14 @@ function PlayComments({ iframe, frameId, vp, dw, dh, ready }: {
|
|
|
221
222
|
// stage swaps in place, so the DOM under an anchor can change without a remount)
|
|
222
223
|
useEffect(() => {
|
|
223
224
|
const win = iframe.current?.contentWindow
|
|
224
|
-
if (!win || !anchored.length) {
|
|
225
|
+
if (!win || !anchored.length) { setPoints({}); return }
|
|
225
226
|
const ask = () => win.postMessage({ type: 'sh:resolve-anchors', anchors: anchored.map((t) => ({ key: t.id, anchor: t.anchor })) }, location.origin)
|
|
226
227
|
const onMsg = (e: MessageEvent) => {
|
|
227
228
|
// reject a reply from a frame we already walked off (data.id is the frame that resolved)
|
|
228
229
|
if (e.source !== win || e.origin !== location.origin || e.data?.type !== 'sh:anchor-rects' || e.data.id !== frameId) return
|
|
229
|
-
const next: typeof
|
|
230
|
-
for (const r of e.data.rects ?? []) next[r.key] = r.orphan ? null : r.
|
|
231
|
-
|
|
230
|
+
const next: typeof points = {}
|
|
231
|
+
for (const r of e.data.rects ?? []) next[r.key] = r.orphan ? null : r.point
|
|
232
|
+
setPoints((cur) => (JSON.stringify(cur) === JSON.stringify(next) ? cur : next))
|
|
232
233
|
}
|
|
233
234
|
window.addEventListener('message', onMsg)
|
|
234
235
|
ask()
|
|
@@ -239,7 +240,7 @@ function PlayComments({ iframe, frameId, vp, dw, dh, ready }: {
|
|
|
239
240
|
const t2 = setTimeout(ask, 700)
|
|
240
241
|
const iv = setInterval(ask, 3000)
|
|
241
242
|
return () => { clearTimeout(t1); clearTimeout(t2); clearInterval(iv); window.removeEventListener('message', onMsg) }
|
|
242
|
-
}, [frameId, anchored.map((t) => t.id).join(','), iframe, ready])
|
|
243
|
+
}, [frameId, anchored.map((t) => `${t.id}:${JSON.stringify(t.anchor)}`).join(','), iframe, ready])
|
|
243
244
|
|
|
244
245
|
// #4/#5: drive the persistent element highlight into the frame - the composing draft, or
|
|
245
246
|
// the open thread's anchor. null clears it. The frame guards against a stage-swap race;
|
|
@@ -252,18 +253,19 @@ function PlayComments({ iframe, frameId, vp, dw, dh, ready }: {
|
|
|
252
253
|
const at = !show || !showAnchor ? null : (draft?.frame === frameId && !isNoteAnchor(draft.anchor) ? draft.anchor
|
|
253
254
|
: (active ? (threads.find((t) => t.id === active && (t.anchor as any)?.el)?.anchor ?? null) : null))
|
|
254
255
|
win.postMessage({ type: 'sh:highlight-anchor', frame: frameId, anchor: at ?? null }, location.origin)
|
|
255
|
-
}, [active, draft, show, showAnchor, frameId, iframe,
|
|
256
|
+
}, [active, draft, show, showAnchor, frameId, iframe, points, ready, JSON.stringify(threads.find((t) => t.id === active)?.anchor ?? null)])
|
|
256
257
|
|
|
257
258
|
if (!show) return null
|
|
258
259
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
260
|
+
// the canvas's placement, in the stage's screen px: the same points, the same column
|
|
261
|
+
const stagePoints = new Map<string, { x: number; y: number } | null>()
|
|
262
|
+
const orphans = new Set<string>()
|
|
263
|
+
for (const t of anchored) {
|
|
264
|
+
const p = points[t.id]
|
|
265
|
+
if (p === null) orphans.add(t.id)
|
|
266
|
+
stagePoints.set(t.id, p ? { x: p.x * sx, y: p.y * sy } : null)
|
|
266
267
|
}
|
|
268
|
+
const placed = placePins(threads, stagePoints, dw, 1)
|
|
267
269
|
const activeThread = threads.find((t) => t.id === active)
|
|
268
270
|
const draftAt = draft?.frame === frameId && !isNoteAnchor(draft.anchor) ? (() => {
|
|
269
271
|
const a = draft.anchor as any
|
|
@@ -272,19 +274,8 @@ function PlayComments({ iframe, frameId, vp, dw, dh, ready }: {
|
|
|
272
274
|
|
|
273
275
|
return (
|
|
274
276
|
<div className="sh-play-comments">
|
|
275
|
-
{threads
|
|
276
|
-
|
|
277
|
-
return (
|
|
278
|
-
<div key={t.id} className={`cm-pin sh-no-pan${t.id === active ? ' on' : ''}${orphan ? ' orphan' : ''}`}
|
|
279
|
-
style={{ left: x, top: y, ...hueVars((t.anchor as any)?.el?.hue) }}
|
|
280
|
-
onPointerDown={(e) => e.stopPropagation()}
|
|
281
|
-
onClick={(e) => { e.stopPropagation(); setActive(t.id === active ? null : t.id) }}
|
|
282
|
-
title={orphan ? 'the anchored element is gone - comment parked' : undefined}>
|
|
283
|
-
<MarkerFace threads={[t]} />
|
|
284
|
-
</div>
|
|
285
|
-
)
|
|
286
|
-
})}
|
|
287
|
-
{activeThread && <ThreadCard key={active!} thread={activeThread} at={pinAt(activeThread)} bounds={{ w: dw, h: dh }} stage />}
|
|
277
|
+
<Pins threads={threads} placed={placed} orphans={orphans} inv={1} active={active} />
|
|
278
|
+
{activeThread && <ThreadCard key={active!} thread={activeThread} at={placed.get(activeThread.id)!} bounds={{ w: dw, h: dh }} stage />}
|
|
288
279
|
{draftAt && <DraftComposer at={draftAt} bounds={{ w: dw, h: dh }} hue={(draft?.anchor as any)?.el?.hue} />}
|
|
289
280
|
</div>
|
|
290
281
|
)
|
|
@@ -464,13 +455,25 @@ function PlayInner() {
|
|
|
464
455
|
postStage({ type: 'sh:laser', on: s.laser })
|
|
465
456
|
postStage({ type: 'sh:pick', on: commentsStore().commentMode, quiet: !commentsStore().showAnchor })
|
|
466
457
|
setStageReady((n) => n + 1) // a reload wiped the frame's lock; let PlayComments re-drive it
|
|
458
|
+
} else if (data.type === 'sh:stage-shown') {
|
|
459
|
+
// spec 26: the stage committed this frame at this revision - a look on it counts up to there.
|
|
460
|
+
// Only from the stage document now up: one an Update replaced may still be talking
|
|
461
|
+
if (typeof data.at === 'string' && String(data.nav ?? '') === (s.playNav ? String(s.playNav) : ''))
|
|
462
|
+
useStore.setState({ stageShown: { at: data.at, shown: `${String(data.epoch ?? '')}:${Number(data.doc) || 0}` } })
|
|
467
463
|
} else if (data.type === 'sh:stage-at') {
|
|
468
464
|
const p = s.play
|
|
469
465
|
if (p && typeof data.at === 'string') s.setPlay({ ...p, at: data.at })
|
|
470
466
|
} else if (data.type === 'sh:stage-exit') {
|
|
471
467
|
exit()
|
|
472
468
|
} else if (data.type === 'sh:stage-error') {
|
|
473
|
-
|
|
469
|
+
// a frame added after this stage was served is not in its registry: that is an update to take
|
|
470
|
+
// (Update serves a fresh stage), not an error
|
|
471
|
+
if (/^unknown frame id/.test(String(data.message ?? ''))) useStore.setState({ playUpdateRevision: 'new frame' })
|
|
472
|
+
else {
|
|
473
|
+
useStore.setState({ stageShown: null }) // an error card holds the stage now: nothing on it counts as seen
|
|
474
|
+
s.toast(`play: ${String(data.message ?? 'frame error')}`)
|
|
475
|
+
if (s.playNav && !s.stageShown) useStore.setState({ playUpdateRevision: 'retry' }) // an Update that failed: offer it again
|
|
476
|
+
}
|
|
474
477
|
} else if (data.type === 'sh:stage-key') {
|
|
475
478
|
if (data.meta && data.key === '/') toggleCollapse()
|
|
476
479
|
else handleKey(String(data.key), String(data.code))
|
|
@@ -526,7 +529,7 @@ function PlayInner() {
|
|
|
526
529
|
if (key === 'r') { restart(); return }
|
|
527
530
|
if (key === 'h') { toggleHideUI(); return }
|
|
528
531
|
if (key === 'l' && SOURCE_REVEALED) { const s = useStore.getState(); if (!s.laser) commentsStore().setMode(false); s.setLaser(!s.laser); return }
|
|
529
|
-
if (key === 'c') { const c = commentsStore(); if (!c.commentMode) useStore.getState().setLaser(false); c.setMode(!c.commentMode); return }
|
|
532
|
+
if (key === 'c') { const c = commentsStore(); if (!c.commentMode && useStore.getState().board === UNPLACED) return useStore.getState().toast(NO_COMMENTS_HERE); if (!c.commentMode) useStore.getState().setLaser(false); c.setMode(!c.commentMode); return }
|
|
530
533
|
if (key === 'C') { const c = commentsStore(); c.setShow(!c.show); return } // ⇧C hides/shows pins
|
|
531
534
|
if (key === 'L') { const c = commentsStore(); c.setShowAnchor(!c.showAnchor); return } // ⇧L element focus
|
|
532
535
|
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
import { createPortal } from 'react-dom'
|
|
10
10
|
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
|
11
11
|
import { useStore, CONFIG, SOURCE_REVEALED, cap } from './store.ts'
|
|
12
|
-
import { useComments } from './comments-store.ts'
|
|
12
|
+
import { NO_COMMENTS_HERE, useComments } from './comments-store.ts'
|
|
13
|
+
import { UNPLACED } from './hash.ts'
|
|
13
14
|
import { Tip } from './Tip.tsx'
|
|
14
15
|
import { CaretIcon, CheckIcon, CommentIcon, DevicesIcon, EyeSlashIcon, FrameCornersIcon, LaserIcon, MoonIcon, SlideFrameIcon, SunIcon, deviceIcon } from './icons.tsx'
|
|
15
16
|
|
|
@@ -131,6 +132,7 @@ export function CommentButton() {
|
|
|
131
132
|
<Tip side="bottom" label={<TipRows rows={[['Comment', 'C'], [show ? 'Hide pins' : 'Show pins', '⇧C']]} />}>
|
|
132
133
|
<button className={`sh-pill-btn${commentMode ? ' on' : ''}`} onClick={() => {
|
|
133
134
|
const c = commentsStore()
|
|
135
|
+
if (!c.commentMode && useStore.getState().board === UNPLACED) return useStore.getState().toast(NO_COMMENTS_HERE)
|
|
134
136
|
if (!c.commentMode) useStore.getState().setLaser(false)
|
|
135
137
|
c.setMode(!c.commentMode)
|
|
136
138
|
useStore.getState().toast(c.commentMode ? 'comment mode off' : 'comment mode - click an element in a frame')
|
|
@@ -231,6 +231,8 @@ export function Canvas() {
|
|
|
231
231
|
const keys = linkTargets(bootHash, useStore.getState().nodes)
|
|
232
232
|
if (keys.length) {
|
|
233
233
|
useStore.setState({ selection: keys })
|
|
234
|
+
const st = useStore.getState() // a link opened is a look (marks not in yet: their first load acknowledges it)
|
|
235
|
+
st.look(keys)
|
|
234
236
|
canvasCtl.fitNodes(keys)
|
|
235
237
|
} else {
|
|
236
238
|
canvasCtl.fitAll()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { memo, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
|
2
|
-
import { cap, frameUrl, useStore, CONFIG, type Node } from '../store.ts'
|
|
2
|
+
import { cap, frameUrl, shownRev, useStore, CONFIG, type Node } from '../store.ts'
|
|
3
3
|
import { admit, release } from './admission.ts'
|
|
4
4
|
import { CopyIcon, IntentGlyph, ParallelogramFillIcon, ReloadIcon, SlideFrameIcon, XIcon } from '../icons.tsx'
|
|
5
5
|
import { CommentLayer } from '../Comments.tsx'
|
|
@@ -12,6 +12,7 @@ import { canAutoReload, shouldArmReadyWatch } from './ready-watch.ts'
|
|
|
12
12
|
import { Stickies, type NoteSpec } from './Sticky.tsx'
|
|
13
13
|
import { noteId, sceneNoteHost } from '../notes.ts'
|
|
14
14
|
import { slideSize, stageFit } from '../../const.ts'
|
|
15
|
+
import { FrameSlot, toneOf, useFrameMark } from '../marks-ui.tsx'
|
|
15
16
|
|
|
16
17
|
export const HEADER = 28
|
|
17
18
|
const SNAP = 12
|
|
@@ -64,6 +65,9 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
64
65
|
const selected = useStore((s) => s.selection.includes(node.key))
|
|
65
66
|
const interact = useStore((s) => s.interact === node.key)
|
|
66
67
|
const working = useStore((s) => s.working.includes(node.frame)) // Live Jam: Marver is editing this frame
|
|
68
|
+
const mark = useFrameMark(node.frame) // spec 25: new, or a question for you
|
|
69
|
+
// spec 26: its document shows an older revision than the frame's last edit (an event not here yet)
|
|
70
|
+
const behind = useStore((s) => !!s.marks && !!node.shown && shownRev(node, s.marks) < (s.marks.doc[node.frame] ?? 0))
|
|
67
71
|
// sticky notes (spec 18): the scene's note when this node is the scene's first on the board
|
|
68
72
|
// (reading order), then the frame's own. Text is compared by value - a note edit re-renders
|
|
69
73
|
// only its column; a pan never re-renders any node (no position subscription here).
|
|
@@ -196,11 +200,14 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
196
200
|
if (doc && doc !== lastDoc.current) { lastDoc.current = doc; dirty.current = false }
|
|
197
201
|
if (interact) dirty.current = true
|
|
198
202
|
wake(node.key, iframe)
|
|
199
|
-
|
|
203
|
+
// a stale document - or one behind the frame's last edit - waits awake for its reload (spec 26):
|
|
204
|
+
// textures are baked from the server's newest source, which it does not show; waking also cancels
|
|
205
|
+
// one being installed
|
|
206
|
+
if (interact || dirty.current || resizing.current || node.status !== 'ready' || node.stale || behind) return
|
|
200
207
|
if (node.themeOn !== undefined && node.themeOn !== node.theme) return // the frame has not painted the new theme yet
|
|
201
|
-
const t = setTimeout(() => { void sleep(node.key, iframe, { frame: frame.id, theme: node.theme, w, h }) }, 250)
|
|
208
|
+
const t = setTimeout(() => { void sleep(node.key, iframe, { frame: frame.id, theme: node.theme, w, h, doc: node.shown }) }, 250)
|
|
202
209
|
return () => clearTimeout(t)
|
|
203
|
-
}, [interact, node.status, node.theme, node.themeOn, node.rev, node.nav, w, h, node.missing, frame?.id, node.key, resizeTick])
|
|
210
|
+
}, [interact, node.status, node.theme, node.themeOn, node.rev, node.nav, node.stale, behind, w, h, node.missing, frame?.id, node.key, resizeTick])
|
|
204
211
|
useEffect(() => () => wake(node.key, iframeRef.current), [node.key])
|
|
205
212
|
|
|
206
213
|
// image-LOD: once the frame is ready its content listener is live, so send the settled zoom - a static
|
|
@@ -272,6 +279,7 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
272
279
|
// shift-click toggles multi-selection instead of dragging (Figma convention)
|
|
273
280
|
if (e.shiftKey && mode === 'move') { select(node.key, true); return }
|
|
274
281
|
if (!(selected && useStore.getState().selection.length > 1)) select(node.key)
|
|
282
|
+
else useStore.getState().look([node.key]) // a click inside a group selection still looks at this one
|
|
275
283
|
const el = e.currentTarget as HTMLElement
|
|
276
284
|
const world = document.getElementById('sh-world')!
|
|
277
285
|
// Law G-5: measured scale, never stored zoom state. #sh-world is 1px wide by design,
|
|
@@ -391,13 +399,15 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
391
399
|
<span>{variantName}</span>
|
|
392
400
|
</div>
|
|
393
401
|
)}
|
|
394
|
-
<div className=
|
|
402
|
+
<div className={`sh-node-head sh-no-pan${toneOf(mark)}`} onPointerDown={(e) => drag(e, 'move')} title={frame.file}>
|
|
395
403
|
{/* the chrome badge: slide first, else the content intent glyph */}
|
|
396
404
|
{frame.slide
|
|
397
405
|
? <SlideFrameIcon size={12} className="iicon sh-no-pan" role="img" aria-hidden={false} aria-label="slide" />
|
|
398
406
|
: frame.intent && <IntentGlyph intent={frame.intent} size={12} className="iicon sh-no-pan" aria-label={frame.intent} />}
|
|
399
407
|
<span className="id sh-no-pan">{frame.title ?? frame.id}</span>
|
|
400
408
|
<span className="dim sh-no-pan">{Math.round(node.w)} · {node.theme}</span>
|
|
409
|
+
{/* the sidebar's marks on the frame itself (spec 25): no outline, no glow - the glow is an agent working */}
|
|
410
|
+
<FrameSlot m={mark} />
|
|
401
411
|
</div>
|
|
402
412
|
|
|
403
413
|
<div className="sh-node-body" style={{ height: node.h }}>
|
|
@@ -29,7 +29,8 @@ import { ROUTE } from '../../const.ts'
|
|
|
29
29
|
import { BAKES, PUBLISHED } from '../store.ts'
|
|
30
30
|
import { readOwn, sleepRule } from '../../../shared/sleep-rule.ts'
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
/** `doc`: the revision the document shows (spec 26) - the compiler refuses a document behind its frame */
|
|
33
|
+
export interface SleepKey { frame: string; theme: string; w: number; h: number; doc?: string }
|
|
33
34
|
interface Target { sel: string; rect: { x: number; y: number; w: number; h: number }; filter: string; level: number; texture: string; verified: boolean }
|
|
34
35
|
type Answer = { ok: true; targets: Target[] } | { ok: false; error: string }
|
|
35
36
|
|
|
@@ -43,7 +44,7 @@ const TOL = 0.5
|
|
|
43
44
|
const AWAKE = new URLSearchParams(location.search).get('awake') === '1'
|
|
44
45
|
const PAUSE = `*,*::before,*::after{animation-play-state:paused!important}`
|
|
45
46
|
const csrf = () => document.cookie.match(/(?:^|; )mv_c=([^;]+)/)?.[1] ?? ''
|
|
46
|
-
const keyOf = (k: SleepKey) => `${k.frame}|${k.theme}|${Math.round(k.w)}|${Math.round(k.h)}`
|
|
47
|
+
const keyOf = (k: SleepKey) => `${k.frame}|${k.theme}|${Math.round(k.w)}|${Math.round(k.h)}${k.doc ? `|${k.doc}` : ''}`
|
|
47
48
|
|
|
48
49
|
/** What a node's DOCUMENT is asleep under, published only once its override is INSTALLED. */
|
|
49
50
|
const asleep = new Map<string, { key: string; doc: Document }>()
|
|
@@ -82,7 +83,7 @@ function ask(key: SleepKey): Promise<Answer> {
|
|
|
82
83
|
// one ask per key; every waiter for that key gets the same answer
|
|
83
84
|
const byKey = new Map<string, { key: SleepKey; waiters: ((a: Answer) => void)[] }>()
|
|
84
85
|
for (const q of batch) { const kk = keyOf(q.key); const e = byKey.get(kk); if (e) e.waiters.push(q.resolve); else byKey.set(kk, { key: q.key, waiters: [q.resolve] }) }
|
|
85
|
-
const asks = [...byKey.values()].map((e) => ({ frame: e.key.frame, theme: e.key.theme, w: Math.round(e.key.w), h: Math.round(e.key.h) }))
|
|
86
|
+
const asks = [...byKey.values()].map((e) => ({ frame: e.key.frame, theme: e.key.theme, w: Math.round(e.key.w), h: Math.round(e.key.h), ...(e.key.doc ? { doc: e.key.doc } : {}) }))
|
|
86
87
|
let data: { answers?: (Answer & SleepKey)[] } | null = null
|
|
87
88
|
const index = PUBLISHED ? await staticAnswers() : null
|
|
88
89
|
if (!index) {
|