@marver-design/marver 0.24.0 → 0.25.1
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 +56 -0
- package/README.md +1 -1
- package/dist/anchor-DVV732zR.mjs +33 -0
- package/dist/anchor-check-DGZnYviN.mjs +135 -0
- package/dist/{bake-ZhXq-X9f.mjs → bake-BpxMZfij.mjs} +45 -6
- 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-ckcinlWH.mjs → build-DKaGhoVN.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-Dx1hCVOT.mjs → comments-pTLlhjh4.mjs} +150 -20
- package/dist/{config-BUKprFAp.mjs → config-cKgZBRj0.mjs} +1 -1
- package/dist/{context-BncTXjLB.mjs → context-D2ugHqwO.mjs} +17 -123
- package/dist/{daemon-CQv73-jM.mjs → daemon-Cl8KXGW4.mjs} +146 -64
- package/dist/{dev-gv4NS6Fk.mjs → dev-Diqx1Rt8.mjs} +23 -11
- package/dist/{events-B3LBn74P.mjs → events-DnK_AnrW.mjs} +13 -15
- package/dist/imports-WBSnnHLb.mjs +143 -0
- package/dist/{init--3Moc4J7.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-Sa08E7wO.mjs → plugin-dTF5reck.mjs} +425 -207
- package/dist/{poster-B2QPvKOq.mjs → poster-D-zjYpgk.mjs} +1 -1
- package/dist/{profile-CrZohD6g.mjs → profile-Do0nGkXO.mjs} +1 -1
- package/dist/{publish-bakes-BJR3huhu.mjs → publish-bakes-C_9VZ-Mq.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-Cw96h5Kk.mjs → shot-CUlmkqFX.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-CBUfsOOT.mjs → work-CpJn1gwY.mjs} +8 -4
- package/dist/{work-ayuL_9Kk.mjs → work-GE88wb_3.mjs} +4 -4
- package/docs/boards-and-folders.md +62 -21
- package/docs/live-jam.md +10 -5
- 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 +66 -22
- package/src/client/shell/BoardList.tsx +54 -11
- 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 -34
- package/src/client/shell/Toolbar.tsx +3 -1
- package/src/client/shell/canvas/Canvas.tsx +1 -1
- package/src/client/shell/canvas/FrameNode.tsx +10 -5
- package/src/client/shell/canvas/sleep.ts +23 -4
- package/src/client/shell/canvas/updates.ts +55 -0
- package/src/client/shell/comments-store.ts +48 -19
- 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 +17 -19
- package/src/client/shell/pin-layout.ts +37 -0
- package/src/client/shell/store.ts +312 -92
- package/src/client/shell/styles.css +10 -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 +17 -12
- 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-vXjxMHTG.mjs +0 -132
- package/dist/manifest-cyG3kbhk.mjs +0 -528
|
@@ -13,16 +13,16 @@
|
|
|
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
|
-
import { stageShown } from './marks-ui.tsx'
|
|
19
19
|
import { ROUTE, slideSize } from '../const.ts'
|
|
20
20
|
import { poweredByUrl } from '../../shared/utm.ts'
|
|
21
21
|
import { canvasCtl } from './canvas/ctl.ts'
|
|
22
22
|
import { revealFrame } from './goto.ts'
|
|
23
23
|
import { Tip } from './Tip.tsx'
|
|
24
24
|
import { CommentButton, DevicePicker, HideUIButton, isHideUI, LaserButton, Popover, ThemePicker, toggleHideUI, usePopover } from './Toolbar.tsx'
|
|
25
|
-
import { DraftComposer,
|
|
25
|
+
import { DraftComposer, Pins, placePins, ThreadCard } from './Comments.tsx'
|
|
26
26
|
import { ArrowLeftIcon, ArrowRightIcon, BrowsersIcon, CaretIcon, CheckIcon, GridIcon, PanelFilledIcon, PanelHollowIcon, ParallelogramDuoIcon, ReloadIcon, SpecDocIcon } from './icons.tsx'
|
|
27
27
|
|
|
28
28
|
const commentsStore = () => useComments.getState()
|
|
@@ -209,12 +209,12 @@ function PlayComments({ iframe, frameId, vp, dw, dh, ready }: {
|
|
|
209
209
|
const active = useComments((s) => s.active)
|
|
210
210
|
const draft = useComments((s) => s.draft)
|
|
211
211
|
const allThreads = useComments((s) => s.threads)
|
|
212
|
-
const { setActive } = useComments.getState()
|
|
213
212
|
// a thread on a sticky note (spec 18) belongs to the canvas: the stage has no notes, and its
|
|
214
213
|
// anchor must never be handed to inspect.js (a same-named frame element would match)
|
|
215
214
|
const threads = allThreads.filter((t) => t.frame === frameId && !t.resolved && !isNoteAnchor(t.anchor))
|
|
216
215
|
const anchored = threads.filter((t) => (t.anchor as any)?.el)
|
|
217
|
-
|
|
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>>({})
|
|
218
218
|
const sx = vp.width ? dw / vp.width : 1
|
|
219
219
|
const sy = vp.height ? dh / vp.height : 1
|
|
220
220
|
|
|
@@ -222,14 +222,14 @@ function PlayComments({ iframe, frameId, vp, dw, dh, ready }: {
|
|
|
222
222
|
// stage swaps in place, so the DOM under an anchor can change without a remount)
|
|
223
223
|
useEffect(() => {
|
|
224
224
|
const win = iframe.current?.contentWindow
|
|
225
|
-
if (!win || !anchored.length) {
|
|
225
|
+
if (!win || !anchored.length) { setPoints({}); return }
|
|
226
226
|
const ask = () => win.postMessage({ type: 'sh:resolve-anchors', anchors: anchored.map((t) => ({ key: t.id, anchor: t.anchor })) }, location.origin)
|
|
227
227
|
const onMsg = (e: MessageEvent) => {
|
|
228
228
|
// reject a reply from a frame we already walked off (data.id is the frame that resolved)
|
|
229
229
|
if (e.source !== win || e.origin !== location.origin || e.data?.type !== 'sh:anchor-rects' || e.data.id !== frameId) return
|
|
230
|
-
const next: typeof
|
|
231
|
-
for (const r of e.data.rects ?? []) next[r.key] = r.orphan ? null : r.
|
|
232
|
-
|
|
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))
|
|
233
233
|
}
|
|
234
234
|
window.addEventListener('message', onMsg)
|
|
235
235
|
ask()
|
|
@@ -240,7 +240,7 @@ function PlayComments({ iframe, frameId, vp, dw, dh, ready }: {
|
|
|
240
240
|
const t2 = setTimeout(ask, 700)
|
|
241
241
|
const iv = setInterval(ask, 3000)
|
|
242
242
|
return () => { clearTimeout(t1); clearTimeout(t2); clearInterval(iv); window.removeEventListener('message', onMsg) }
|
|
243
|
-
}, [frameId, anchored.map((t) => t.id).join(','), iframe, ready])
|
|
243
|
+
}, [frameId, anchored.map((t) => `${t.id}:${JSON.stringify(t.anchor)}`).join(','), iframe, ready])
|
|
244
244
|
|
|
245
245
|
// #4/#5: drive the persistent element highlight into the frame - the composing draft, or
|
|
246
246
|
// the open thread's anchor. null clears it. The frame guards against a stage-swap race;
|
|
@@ -253,18 +253,19 @@ function PlayComments({ iframe, frameId, vp, dw, dh, ready }: {
|
|
|
253
253
|
const at = !show || !showAnchor ? null : (draft?.frame === frameId && !isNoteAnchor(draft.anchor) ? draft.anchor
|
|
254
254
|
: (active ? (threads.find((t) => t.id === active && (t.anchor as any)?.el)?.anchor ?? null) : null))
|
|
255
255
|
win.postMessage({ type: 'sh:highlight-anchor', frame: frameId, anchor: at ?? null }, location.origin)
|
|
256
|
-
}, [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)])
|
|
257
257
|
|
|
258
258
|
if (!show) return null
|
|
259
259
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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)
|
|
267
267
|
}
|
|
268
|
+
const placed = placePins(threads, stagePoints, dw, 1)
|
|
268
269
|
const activeThread = threads.find((t) => t.id === active)
|
|
269
270
|
const draftAt = draft?.frame === frameId && !isNoteAnchor(draft.anchor) ? (() => {
|
|
270
271
|
const a = draft.anchor as any
|
|
@@ -273,19 +274,8 @@ function PlayComments({ iframe, frameId, vp, dw, dh, ready }: {
|
|
|
273
274
|
|
|
274
275
|
return (
|
|
275
276
|
<div className="sh-play-comments">
|
|
276
|
-
{threads
|
|
277
|
-
|
|
278
|
-
return (
|
|
279
|
-
<div key={t.id} className={`cm-pin sh-no-pan${t.id === active ? ' on' : ''}${orphan ? ' orphan' : ''}`}
|
|
280
|
-
style={{ left: x, top: y, ...hueVars((t.anchor as any)?.el?.hue) }}
|
|
281
|
-
onPointerDown={(e) => e.stopPropagation()}
|
|
282
|
-
onClick={(e) => { e.stopPropagation(); setActive(t.id === active ? null : t.id) }}
|
|
283
|
-
title={orphan ? 'the anchored element is gone - comment parked' : undefined}>
|
|
284
|
-
<MarkerFace threads={[t]} />
|
|
285
|
-
</div>
|
|
286
|
-
)
|
|
287
|
-
})}
|
|
288
|
-
{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 />}
|
|
289
279
|
{draftAt && <DraftComposer at={draftAt} bounds={{ w: dw, h: dh }} hue={(draft?.anchor as any)?.el?.hue} />}
|
|
290
280
|
</div>
|
|
291
281
|
)
|
|
@@ -465,14 +455,25 @@ function PlayInner() {
|
|
|
465
455
|
postStage({ type: 'sh:laser', on: s.laser })
|
|
466
456
|
postStage({ type: 'sh:pick', on: commentsStore().commentMode, quiet: !commentsStore().showAnchor })
|
|
467
457
|
setStageReady((n) => n + 1) // a reload wiped the frame's lock; let PlayComments re-drive it
|
|
468
|
-
|
|
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}` } })
|
|
469
463
|
} else if (data.type === 'sh:stage-at') {
|
|
470
464
|
const p = s.play
|
|
471
465
|
if (p && typeof data.at === 'string') s.setPlay({ ...p, at: data.at })
|
|
472
466
|
} else if (data.type === 'sh:stage-exit') {
|
|
473
467
|
exit()
|
|
474
468
|
} else if (data.type === 'sh:stage-error') {
|
|
475
|
-
|
|
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
|
+
}
|
|
476
477
|
} else if (data.type === 'sh:stage-key') {
|
|
477
478
|
if (data.meta && data.key === '/') toggleCollapse()
|
|
478
479
|
else handleKey(String(data.key), String(data.code))
|
|
@@ -528,7 +529,7 @@ function PlayInner() {
|
|
|
528
529
|
if (key === 'r') { restart(); return }
|
|
529
530
|
if (key === 'h') { toggleHideUI(); return }
|
|
530
531
|
if (key === 'l' && SOURCE_REVEALED) { const s = useStore.getState(); if (!s.laser) commentsStore().setMode(false); s.setLaser(!s.laser); return }
|
|
531
|
-
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 }
|
|
532
533
|
if (key === 'C') { const c = commentsStore(); c.setShow(!c.show); return } // ⇧C hides/shows pins
|
|
533
534
|
if (key === 'L') { const c = commentsStore(); c.setShowAnchor(!c.showAnchor); return } // ⇧L element focus
|
|
534
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')
|
|
@@ -232,7 +232,7 @@ export function Canvas() {
|
|
|
232
232
|
if (keys.length) {
|
|
233
233
|
useStore.setState({ selection: keys })
|
|
234
234
|
const st = useStore.getState() // a link opened is a look (marks not in yet: their first load acknowledges it)
|
|
235
|
-
st.
|
|
235
|
+
st.look(keys)
|
|
236
236
|
canvasCtl.fitNodes(keys)
|
|
237
237
|
} else {
|
|
238
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'
|
|
@@ -66,6 +66,8 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
66
66
|
const interact = useStore((s) => s.interact === node.key)
|
|
67
67
|
const working = useStore((s) => s.working.includes(node.frame)) // Live Jam: Marver is editing this frame
|
|
68
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))
|
|
69
71
|
// sticky notes (spec 18): the scene's note when this node is the scene's first on the board
|
|
70
72
|
// (reading order), then the frame's own. Text is compared by value - a note edit re-renders
|
|
71
73
|
// only its column; a pan never re-renders any node (no position subscription here).
|
|
@@ -198,11 +200,14 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
198
200
|
if (doc && doc !== lastDoc.current) { lastDoc.current = doc; dirty.current = false }
|
|
199
201
|
if (interact) dirty.current = true
|
|
200
202
|
wake(node.key, iframe)
|
|
201
|
-
|
|
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
|
|
202
207
|
if (node.themeOn !== undefined && node.themeOn !== node.theme) return // the frame has not painted the new theme yet
|
|
203
|
-
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)
|
|
204
209
|
return () => clearTimeout(t)
|
|
205
|
-
}, [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])
|
|
206
211
|
useEffect(() => () => wake(node.key, iframeRef.current), [node.key])
|
|
207
212
|
|
|
208
213
|
// image-LOD: once the frame is ready its content listener is live, so send the settled zoom - a static
|
|
@@ -274,7 +279,7 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
|
|
|
274
279
|
// shift-click toggles multi-selection instead of dragging (Figma convention)
|
|
275
280
|
if (e.shiftKey && mode === 'move') { select(node.key, true); return }
|
|
276
281
|
if (!(selected && useStore.getState().selection.length > 1)) select(node.key)
|
|
277
|
-
else useStore.getState().
|
|
282
|
+
else useStore.getState().look([node.key]) // a click inside a group selection still looks at this one
|
|
278
283
|
const el = e.currentTarget as HTMLElement
|
|
279
284
|
const world = document.getElementById('sh-world')!
|
|
280
285
|
// Law G-5: measured scale, never stored zoom state. #sh-world is 1px wide by design,
|
|
@@ -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 }>()
|
|
@@ -53,6 +54,13 @@ let seq = 0
|
|
|
53
54
|
/** Nodes with one retry of a failed compile in flight. */
|
|
54
55
|
const retried = new Set<string>()
|
|
55
56
|
const RETRY_MS = 4000
|
|
57
|
+
/** The server's answer for a compile still running (src/server/bake.ts COMPILING), and how many times a
|
|
58
|
+
* node looks again for it before settling for the pause alone. */
|
|
59
|
+
const COMPILING = 'compiling - ask again'
|
|
60
|
+
const COMPILING_TRIES = 15
|
|
61
|
+
/** Looks so far, per node, for the sleep key they were for: a new key (an edit, a theme, a size)
|
|
62
|
+
* or a wake starts the count again. */
|
|
63
|
+
const compiling = new Map<string, { key: string; n: number }>()
|
|
56
64
|
|
|
57
65
|
/** Does this document have anything to compile? Cheap: one computed style per element. */
|
|
58
66
|
export function hasEffects(doc: Document): boolean {
|
|
@@ -82,7 +90,7 @@ function ask(key: SleepKey): Promise<Answer> {
|
|
|
82
90
|
// one ask per key; every waiter for that key gets the same answer
|
|
83
91
|
const byKey = new Map<string, { key: SleepKey; waiters: ((a: Answer) => void)[] }>()
|
|
84
92
|
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) }))
|
|
93
|
+
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
94
|
let data: { answers?: (Answer & SleepKey)[] } | null = null
|
|
87
95
|
const index = PUBLISHED ? await staticAnswers() : null
|
|
88
96
|
if (!index) {
|
|
@@ -124,6 +132,15 @@ export async function sleep(nodeKey: string, iframe: HTMLIFrameElement, key: Sle
|
|
|
124
132
|
}
|
|
125
133
|
const answer = await ask(key)
|
|
126
134
|
if (!current()) return 'live'
|
|
135
|
+
// still compiling (issue #23): the server answered in seconds and carries on by itself. The frame
|
|
136
|
+
// stays LIVE meanwhile - pausing now would freeze a finite animation midway, under a texture of its
|
|
137
|
+
// end - and looks again, a bounded number of times; past that, the pause alone below
|
|
138
|
+
if (!PUBLISHED && !answer.ok && answer.error === COMPILING) {
|
|
139
|
+
const was = compiling.get(nodeKey)
|
|
140
|
+
const n = (was && was.key === k ? was.n : 0) + 1
|
|
141
|
+
compiling.set(nodeKey, { key: k, n })
|
|
142
|
+
if (n <= COMPILING_TRIES) { setTimeout(() => { if (current()) void sleep(nodeKey, iframe, key) }, RETRY_MS); return 'live' }
|
|
143
|
+
}
|
|
127
144
|
// no compiler (a published canvas, a compile that failed): the pause alone, the glass live -
|
|
128
145
|
// never an effect layer without its texture
|
|
129
146
|
let targets = answer.ok ? answer.targets.filter((t) => t.verified && t.texture) : []
|
|
@@ -137,7 +154,8 @@ export async function sleep(nodeKey: string, iframe: HTMLIFrameElement, key: Sle
|
|
|
137
154
|
if (!install(doc, targets)) return 'live'
|
|
138
155
|
// a certified sleep is remembered; the pause-only fallback is not, so the next lifecycle event
|
|
139
156
|
// asks again (a compile the source outran, a server hiccup), and one retry is scheduled now
|
|
140
|
-
if (targets.length) asleep.set(nodeKey, { key: k, doc })
|
|
157
|
+
if (targets.length) { asleep.set(nodeKey, { key: k, doc }); compiling.delete(nodeKey) }
|
|
158
|
+
else if (answer.ok === false && answer.error === COMPILING) { /* out of looks: the pause alone, final */ }
|
|
141
159
|
else if (!PUBLISHED && !retried.has(nodeKey)) { retried.add(nodeKey); setTimeout(() => { retried.delete(nodeKey); if (current()) void sleep(nodeKey, iframe, key) }, RETRY_MS) } // a static miss is final
|
|
142
160
|
return 'asleep'
|
|
143
161
|
}
|
|
@@ -146,6 +164,7 @@ export async function sleep(nodeKey: string, iframe: HTMLIFrameElement, key: Sle
|
|
|
146
164
|
export function wake(nodeKey: string, iframe: HTMLIFrameElement | null): void {
|
|
147
165
|
pending.delete(nodeKey)
|
|
148
166
|
asleep.delete(nodeKey)
|
|
167
|
+
compiling.delete(nodeKey)
|
|
149
168
|
const doc = iframe?.contentDocument
|
|
150
169
|
const st = doc?.getElementById(STYLE_ID)
|
|
151
170
|
if (!doc || !st) return
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calm updates, the shell's half (spec 26 Part 2): a node an edit made stale reloads through the
|
|
3
|
+
* same boot queue a board uses (admission.ts) - at most four at a time, the one nearest the centre
|
|
4
|
+
* of the view first - and only while it is on screen (or within half a screen of it) and not in use.
|
|
5
|
+
* Further off it waits until it comes near; in use (interact, a drag, laser or comment on it) it waits for a safe point; while
|
|
6
|
+
* the play stage covers the canvas, the canvas counts as off screen. A job checks all of that again
|
|
7
|
+
* when its turn comes.
|
|
8
|
+
*/
|
|
9
|
+
import { admit, release } from './admission.ts'
|
|
10
|
+
import { frameIsLeased, useStore, type Node } from '../store.ts'
|
|
11
|
+
|
|
12
|
+
const rect = (key: string) => document.querySelector(`[data-node="${CSS.escape(key)}"]`)?.getBoundingClientRect()
|
|
13
|
+
const view = () => document.querySelector('.sh-canvas')?.getBoundingClientRect()
|
|
14
|
+
|
|
15
|
+
/** On screen at any zoom - or within half a screen of it, so a small pan shows fresh frames and a
|
|
16
|
+
* camera still moving between two places does not starve the frames on its way. */
|
|
17
|
+
function onScreen(key: string): boolean {
|
|
18
|
+
const r = rect(key), c = view()
|
|
19
|
+
if (!r || !c) return false
|
|
20
|
+
const mx = c.width / 2, my = c.height / 2
|
|
21
|
+
return r.right > c.left - mx && r.left < c.right + mx && r.bottom > c.top - my && r.top < c.bottom + my
|
|
22
|
+
}
|
|
23
|
+
const rank = (key: string) => () => {
|
|
24
|
+
const r = rect(key), c = view()
|
|
25
|
+
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
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const ready = (n: Node) => {
|
|
29
|
+
const s = useStore.getState()
|
|
30
|
+
// a document to replace (ready, or errored), never one still booting for the first time
|
|
31
|
+
return !!n.stale && !n.missing && (n.status === 'ready' || n.status === 'error') && !s.play && !frameIsLeased(n.frame, s) && onScreen(n.key)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let ticker: ReturnType<typeof setInterval> | undefined
|
|
35
|
+
|
|
36
|
+
/** Give every stale node that may reload now a place in the queue. Stale nodes off screen are looked
|
|
37
|
+
* at again on a slow tick (a pan or a zoom brings them in), stopped once none is left. */
|
|
38
|
+
export function pumpUpdates(): void {
|
|
39
|
+
const s = useStore.getState()
|
|
40
|
+
const stale = s.nodes.filter((n) => n.stale && !n.missing)
|
|
41
|
+
if (!stale.length) { clearInterval(ticker); ticker = undefined; return }
|
|
42
|
+
ticker ??= setInterval(pumpUpdates, 400)
|
|
43
|
+
for (const n of stale) {
|
|
44
|
+
if (!ready(n)) continue
|
|
45
|
+
admit({
|
|
46
|
+
key: n.key,
|
|
47
|
+
rank: rank(n.key),
|
|
48
|
+
start: () => {
|
|
49
|
+
const now = useStore.getState().nodes.find((x) => x.key === n.key)
|
|
50
|
+
if (!now || !ready(now)) { release(n.key); return } // scrolled away or taken in use while it queued
|
|
51
|
+
useStore.getState().startReload(n.key) // released when its document is ready (FrameNode)
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -5,10 +5,15 @@
|
|
|
5
5
|
* on which one it is beyond capability flags the endpoints themselves report.
|
|
6
6
|
*/
|
|
7
7
|
import { create } from 'zustand'
|
|
8
|
-
import { replay, type CommentEvent, type Thread } from '../../shared/events.ts'
|
|
8
|
+
import { asks, replay, type CommentEvent, type Thread } from '../../shared/events.ts'
|
|
9
9
|
import { mentionPeople, mentionsIn } from './mentions.ts'
|
|
10
10
|
import { playPing } from './sound.ts'
|
|
11
11
|
import { ROUTE } from '../const.ts'
|
|
12
|
+
import { ALL_SCENES } from '../../shared/board-tree.ts'
|
|
13
|
+
import { UNPLACED } from './hash.ts'
|
|
14
|
+
|
|
15
|
+
/** What the Not on a board view says when asked for a comment: a note needs a board to live on. */
|
|
16
|
+
export const NO_COMMENTS_HERE = 'pin it on a board to comment'
|
|
12
17
|
|
|
13
18
|
export interface Me {
|
|
14
19
|
email: string
|
|
@@ -53,6 +58,8 @@ interface CommentsState {
|
|
|
53
58
|
* path as the poll, so dedup + the reply notification behave identically. ANY board:
|
|
54
59
|
* notifications must reach the user wherever they are on the canvas. */
|
|
55
60
|
poke(board?: string): void
|
|
61
|
+
/** A thread by id, from any board's log - one sweep first when it is not loaded yet. */
|
|
62
|
+
findThread(id: string): Promise<Thread | null>
|
|
56
63
|
/** `board` routes the write to a thread's ORIGIN log; default = the active board. */
|
|
57
64
|
send(events: CommentEvent[], board?: string): Promise<boolean>
|
|
58
65
|
create(body: string): Promise<void>
|
|
@@ -109,24 +116,31 @@ export const useComments = create<CommentsState>((set, get) => {
|
|
|
109
116
|
// log), keyed on the event id via `union`'s fresh filter so it fires exactly once. The pill's
|
|
110
117
|
// board is the THREAD's origin board, so View can navigate there. One ping per batch, like a
|
|
111
118
|
// person's - except for a jam job's opening "On it" line (ids `jam-e<attempt>-…`, daemon.ts): the pill
|
|
112
|
-
// shows it, the ping waits for the answer.
|
|
119
|
+
// shows it, the ping waits for the answer. A jam job whose final block asks what its opening
|
|
120
|
+
// line already said re-flags that line (an edit carrying `asks`): the question gets its notice.
|
|
113
121
|
const notifyAgent = (fresh: CommentEvent[]) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
const news = fresh.flatMap((e) => {
|
|
123
|
+
if (!e.agent) return []
|
|
124
|
+
if (e.type === 'reply' || e.type === 'create') return [{ e, threadId: e.parentId ?? e.commentId ?? '', body: e.body, ask: asks(e, e.type === 'create') }]
|
|
125
|
+
if (e.type !== 'edit' || e.asks !== true) return []
|
|
126
|
+
const t = get().threads.find((t) => t.id === e.commentId || t.replies.some((r) => r.id === e.commentId))
|
|
127
|
+
return t ? [{ e, threadId: t.id, body: (t.id === e.commentId ? t : t.replies.find((r) => r.id === e.commentId))?.body, ask: true }] : []
|
|
128
|
+
})
|
|
129
|
+
if (!news.length) return
|
|
130
|
+
if (news.some(({ e }) => !/^jam-e\d+-/.test(e.id))) playPing()
|
|
117
131
|
void import('./store.ts').then(({ useStore }) => {
|
|
118
132
|
const s = useStore.getState()
|
|
119
|
-
for (const e of
|
|
120
|
-
const threadId = e.parentId ?? e.commentId ?? ''
|
|
133
|
+
for (const { e, threadId, body, ask } of news) {
|
|
121
134
|
// the FRAME is the news: resolve the reply's thread -> frame -> manifest title + intent
|
|
122
135
|
const t = get().threads.find((t) => t.id === threadId)
|
|
123
136
|
const entry = t?.frame ? s.manifest?.frames.find((f) => f.id === t.frame) : undefined
|
|
124
137
|
s.jamToast({
|
|
125
138
|
threadId, board: t?.board ?? e.board ?? get().board ?? '', ts: e.ts,
|
|
126
|
-
preview: (
|
|
139
|
+
preview: (body ?? '').replace(/\s+/g, ' ').slice(0, 90),
|
|
127
140
|
frame: t?.frame, frameTitle: entry?.title ?? t?.frame, intent: entry?.intent,
|
|
128
|
-
// a
|
|
129
|
-
|
|
141
|
+
// a message that asks stands alone; the rest fold into the board's round (the writer's
|
|
142
|
+
// `asks`, else the old rule: a note asks, a reply asks when it ends in "?")
|
|
143
|
+
round: !ask,
|
|
130
144
|
})
|
|
131
145
|
}
|
|
132
146
|
})
|
|
@@ -188,16 +202,18 @@ export const useComments = create<CommentsState>((set, get) => {
|
|
|
188
202
|
const stamped = (events: CommentEvent[] | undefined, board: string): CommentEvent[] =>
|
|
189
203
|
(events ?? []).map((e) => (e.board ? e : { ...e, board }))
|
|
190
204
|
/** Every board that could hold a log: the switcher list plus the active board -
|
|
191
|
-
* the sum of what this client can navigate to
|
|
192
|
-
*
|
|
205
|
+
* the sum of what this client can navigate to - and the old all-scenes log, whose threads
|
|
206
|
+
* outlive their board (spec 26) until a published canvas says it has none. Transport
|
|
207
|
+
* failure = just the active board; the next sweep widens again. */
|
|
208
|
+
let allScenesOff = false
|
|
193
209
|
const watchNames = async (): Promise<string[]> => {
|
|
194
|
-
const names = new Set<string>()
|
|
210
|
+
const names = new Set<string>(allScenesOff ? [] : [ALL_SCENES])
|
|
195
211
|
try {
|
|
196
212
|
const { fetchBoardNames } = await import('./store.ts')
|
|
197
213
|
for (const n of await fetchBoardNames()) names.add(n)
|
|
198
214
|
} catch { /* keep what we have */ }
|
|
199
215
|
const b = get().board
|
|
200
|
-
if (b) names.add(b)
|
|
216
|
+
if (b && b !== UNPLACED) names.add(b)
|
|
201
217
|
return [...names]
|
|
202
218
|
}
|
|
203
219
|
/** One sweep across every board's log - the notification feed and the frame-scoped
|
|
@@ -206,7 +222,10 @@ export const useComments = create<CommentsState>((set, get) => {
|
|
|
206
222
|
if (apiOff) return
|
|
207
223
|
const names = await watchNames()
|
|
208
224
|
const results = await Promise.all(names.map((n) =>
|
|
209
|
-
api(`comments/${n}`).then((r) =>
|
|
225
|
+
api(`comments/${n}`).then((r) => {
|
|
226
|
+
if (n === ALL_SCENES && r.status === 404) allScenesOff = true // a canvas published before 0.25 serves none
|
|
227
|
+
return r.ok ? stamped(r.data.events as CommentEvent[] | undefined, n) : null
|
|
228
|
+
})))
|
|
210
229
|
union(results.flatMap((evs) => evs ?? []))
|
|
211
230
|
names.forEach((n, i) => { if (results[i] !== null) baselinedBoards.add(n) })
|
|
212
231
|
}
|
|
@@ -218,7 +237,7 @@ export const useComments = create<CommentsState>((set, get) => {
|
|
|
218
237
|
|
|
219
238
|
poke(board) {
|
|
220
239
|
const b = board ?? get().board
|
|
221
|
-
if (!b || apiOff) return
|
|
240
|
+
if (!b || apiOff || b === UNPLACED) return
|
|
222
241
|
void api(`comments/${b}`).then((r) => {
|
|
223
242
|
if (!r.ok) return
|
|
224
243
|
union(stamped(r.data.events, b)) // brand-new events still notify via the bootTs rule
|
|
@@ -229,7 +248,7 @@ export const useComments = create<CommentsState>((set, get) => {
|
|
|
229
248
|
async load(board) {
|
|
230
249
|
// threads are frame-scoped and global - a board switch keeps them all (the same
|
|
231
250
|
// frame on another board keeps its pins); only the open card and a draft reset
|
|
232
|
-
if (get().board !== board) set({ board, active: null, draft: null })
|
|
251
|
+
if (get().board !== board) set({ board, active: null, draft: null, ...(board === UNPLACED ? { commentMode: false } : {}) })
|
|
233
252
|
else set({ board })
|
|
234
253
|
const me = await api('me')
|
|
235
254
|
if (me.status === 404) { apiOff = true; return } // static serve: no comments API at all
|
|
@@ -328,7 +347,13 @@ export const useComments = create<CommentsState>((set, get) => {
|
|
|
328
347
|
await get().send([{ id: uuid(), ts: Date.now(), type: reopen ? 'reopen' : 'resolve', commentId: threadId }], origin)
|
|
329
348
|
},
|
|
330
349
|
|
|
331
|
-
|
|
350
|
+
async findThread(id) {
|
|
351
|
+
if (!get().threads.some((t) => t.id === id)) await fetchAll()
|
|
352
|
+
return get().threads.find((t) => t.id === id) ?? null
|
|
353
|
+
},
|
|
354
|
+
|
|
355
|
+
// the Not on a board view shows threads but takes no new ones (spec 26): a note needs a board
|
|
356
|
+
setMode(on) { if (on && get().board === UNPLACED) return; set({ commentMode: on, ...(on ? { show: true } : { draft: null }) }) },
|
|
332
357
|
setShow(show) { set({ show }) },
|
|
333
358
|
setShowAnchor(showAnchor) { set({ showAnchor }) },
|
|
334
359
|
setActive(active) {
|
|
@@ -339,7 +364,11 @@ export const useComments = create<CommentsState>((set, get) => {
|
|
|
339
364
|
set({ active, mentionSeen })
|
|
340
365
|
} else set({ active })
|
|
341
366
|
},
|
|
342
|
-
setDraft(draft) {
|
|
367
|
+
setDraft(draft) {
|
|
368
|
+
const board = draft ? draft.board ?? get().board ?? undefined : undefined
|
|
369
|
+
if (board === UNPLACED) return
|
|
370
|
+
set({ draft: draft ? { ...draft, board } : null })
|
|
371
|
+
},
|
|
343
372
|
dismissIdentity() { set({ needsIdentity: false }) }, // inviteToken survives dismissal - commenting later reopens the claim
|
|
344
373
|
|
|
345
374
|
async signIn(email, password) {
|
package/src/client/shell/goto.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* and a sticky note's link (shell DOM, spec 18). On this board: select and fit. Elsewhere: follow
|
|
4
4
|
* the frame home (below). Never edits a board unless no board pins the target.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { fetchMembership, useStore } from './store.ts'
|
|
7
|
+
import { UNPLACED } from './hash.ts'
|
|
7
8
|
import { canvasCtl } from './canvas/ctl.ts'
|
|
8
9
|
|
|
9
10
|
/** Navigate to a frame id. `carry` keeps interact mode across the hop (a link inside an
|
|
@@ -35,10 +36,7 @@ async function gotoAcrossBoards(target: string, carry: boolean) {
|
|
|
35
36
|
const seq = navigated()
|
|
36
37
|
let home: string | null = null
|
|
37
38
|
try {
|
|
38
|
-
|
|
39
|
-
for (const name of names) {
|
|
40
|
-
if ((await boardFrames(name)).includes(target)) { home = name; break }
|
|
41
|
-
}
|
|
39
|
+
home = (await fetchMembership()).boards.find((b) => b.name !== s.board && b.frames.includes(target))?.name ?? null
|
|
42
40
|
} catch {
|
|
43
41
|
// a transport failure is NOT proof the frame is unpinned - spawning here would
|
|
44
42
|
// recreate the board mutation this function exists to prevent
|
|
@@ -61,12 +59,14 @@ async function gotoAcrossBoards(target: string, carry: boolean) {
|
|
|
61
59
|
/** Navigation supersedes any goto or reveal still on its way - its board lookup (gotoSeq) AND a board
|
|
62
60
|
* switch it already started (a switch to the board on screen cancels any pending one: store.ts) - so
|
|
63
61
|
* a slow lookup can never yank the view away from where the human has gone since. Every entry point
|
|
64
|
-
* calls it: a pasted link, back/forward, a goto, a reveal. */
|
|
62
|
+
* calls it: a pasted link, back/forward, a goto, a reveal, a board picked in the sidebar. */
|
|
65
63
|
export function navigated(): number {
|
|
66
64
|
const s = useStore.getState()
|
|
67
65
|
if (s.board) void s.switchBoard(s.board)
|
|
68
66
|
return ++gotoSeq
|
|
69
67
|
}
|
|
68
|
+
/** Is this still the latest navigation - nothing newer since `navigated()` handed it out? */
|
|
69
|
+
export const isLatest = (seq: number): boolean => seq === gotoSeq
|
|
70
70
|
|
|
71
71
|
/** Switch to `home` and select + fit `target` there once the board commits - unless the human has
|
|
72
72
|
* moved on: newer navigation, or a board they switched to themselves while the lookup ran. */
|
|
@@ -90,9 +90,9 @@ async function landOn(home: string, target: string, carry: boolean, seq: number,
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/** Show a frame where it lives, for a LINK (a pasted canvas link naming a frame the board does
|
|
93
|
-
* not show, the way back from a focus link): this board, else the first
|
|
94
|
-
*
|
|
95
|
-
* must not edit a board. */
|
|
93
|
+
* not show, the way back from a focus link): this board, else the first board that shows it
|
|
94
|
+
* (archive boards last), else - a frame on no board - the Not on a board view. Unlike a goto it
|
|
95
|
+
* never spawns - opening a link must not edit a board. */
|
|
96
96
|
export async function revealFrame(target: string): Promise<void> {
|
|
97
97
|
const s = useStore.getState()
|
|
98
98
|
const here = s.nodes.find((n) => n.frame === target && !n.missing)
|
|
@@ -107,11 +107,8 @@ export async function revealFrame(target: string): Promise<void> {
|
|
|
107
107
|
const from = s.board
|
|
108
108
|
let home: string | null = null
|
|
109
109
|
try {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
if ((await boardFrames(name)).includes(target)) { home = name; break }
|
|
113
|
-
}
|
|
114
|
-
if (!home && all.includes('all-scenes')) home = 'all-scenes'
|
|
110
|
+
const m = await fetchMembership()
|
|
111
|
+
home = m.boards.find((b) => b.name !== s.board && b.frames.includes(target))?.name ?? (m.unplaced.includes(target) && s.board !== UNPLACED ? UNPLACED : null)
|
|
115
112
|
} catch {
|
|
116
113
|
return useStore.getState().toast(`could not read the boards - try again`)
|
|
117
114
|
}
|
package/src/client/shell/hash.ts
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* shell writes it as board/selection/play change and parses it once on boot; camera
|
|
5
5
|
* intent is always fit semantics (fit-all / fit-selection), never raw coordinates.
|
|
6
6
|
*
|
|
7
|
-
* #/
|
|
7
|
+
* #/ the landing board, fit all
|
|
8
8
|
* #/b/<board> board, fit all
|
|
9
|
+
* #/b/~unplaced the Not on a board view (UNPLACED)
|
|
10
|
+
* #/b/all-scenes... a link from before 0.25: lands on a real board (legacy-links.ts)
|
|
9
11
|
* #/b/<board>?n=k1,k2 board with nodes selected, camera fit to selection
|
|
10
12
|
* #/b/<board>?f=<scene/frame>,... the same, by FRAME id - the link an agent can write
|
|
11
13
|
* (node keys are the shell's; `marver link` prints these)
|
|
@@ -33,6 +35,9 @@ export interface HashState {
|
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
const BOARD_RE = /^[a-z0-9][a-z0-9-]*$/
|
|
38
|
+
/** The Not on a board view (spec 26, Part 7): a temporary board of the frames no board shows,
|
|
39
|
+
* never saved. Off the board-name grammar, so no board file can ever be called this. */
|
|
40
|
+
export const UNPLACED = '~unplaced'
|
|
36
41
|
const isFrameId = (at: string) => /^[\w./-]{1,200}$/.test(at) && !at.includes('..')
|
|
37
42
|
|
|
38
43
|
/** The node keys a link names on the loaded board: its keys (`n`), the nodes showing its frames
|
|
@@ -64,7 +69,7 @@ export function parseHash(hash: string = location.hash): HashState {
|
|
|
64
69
|
const m = path.match(/^\/(b|p)\/([^/?]+)$/)
|
|
65
70
|
if (!m) return {}
|
|
66
71
|
const board = decodeURIComponent(m[2])
|
|
67
|
-
if (!BOARD_RE.test(board)) return {}
|
|
72
|
+
if (!BOARD_RE.test(board) && board !== UNPLACED) return {}
|
|
68
73
|
if (m[1] === 'b') {
|
|
69
74
|
const list = (k: string) => (params.get(k) ?? '').split(',').map((s) => s.trim()).filter(Boolean)
|
|
70
75
|
const n = list('n')
|
|
@@ -100,7 +105,7 @@ export function buildHash(s: HashState): string {
|
|
|
100
105
|
if (s.play.slides) p.set('slides', '1')
|
|
101
106
|
return `#/p/${s.board}?${p}`
|
|
102
107
|
}
|
|
103
|
-
if (!s.board
|
|
108
|
+
if (!s.board) return '#/'
|
|
104
109
|
const p = new URLSearchParams()
|
|
105
110
|
if (s.n?.length) p.set('n', s.n.join(','))
|
|
106
111
|
if (s.c) p.set('c', s.c)
|
|
@@ -116,5 +121,7 @@ export function writeHash(s: HashState, push = false) {
|
|
|
116
121
|
else history.replaceState(null, '', h)
|
|
117
122
|
}
|
|
118
123
|
|
|
119
|
-
/** The hash as it stood when the app loaded - boot intent, captured once
|
|
120
|
-
|
|
124
|
+
/** The hash as it stood when the app loaded - boot intent, captured once; re-aimed only when an old
|
|
125
|
+
* link resolves to where it lands now (legacy-links.ts), before the board boots. */
|
|
126
|
+
export let bootHash = parseHash()
|
|
127
|
+
export function retargetBoot(h: HashState) { bootHash = h }
|