@skillre/dsh-plugin-sticky-wall 0.6.0 → 0.7.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/README.en.md +4 -4
- package/README.md +4 -4
- package/compatibility.json +5 -3
- package/lib/client.js +115 -35
- package/lib/layout.d.ts +27 -5
- package/lib/layout.js +82 -25
- package/lib/transport.js +11 -1
- package/lib/types.d.ts +30 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -17,9 +17,9 @@ Non-goals: task management (no scheduling, assignment or reminders), collaborati
|
|
|
17
17
|
- **Sidebar entry** — a "Notes" glyph in `sidebar.panellist`; clicking it swaps the centre column to the wall.
|
|
18
18
|
- **Free canvas** — notes are cards on a canvas, not list rows. Position, rotation and a three-step width (small/medium/large) are note data owned by the Host, so the same wall opens with the same arrangement in another window.
|
|
19
19
|
- **Drag to place** — press anywhere on a card and drag; the drop lands on the new position immediately and then writes it to the Host, so the card never snaps back first. A drag does **not** bump `updatedAt`, so tidying your desk never reshuffles a "by updated" sort.
|
|
20
|
-
- **A wall with a middle** — "Tidy" packs every note into a **compact composition hugging a clear rectangle** at the world origin, which is kept free for the greeting and the quick-capture field; the camera opens with the whole wall framed and centred. The packer follows the rectangle's own **contour** rather than a circle, so every card is only half its own size away from the middle: the same fourteen notes occupy 1261x705 instead of 1645x1794, and frame at **84% instead of 36%**. Each candidate slot is scored by the zoom the whole wall would need, so the result is a wide, low cluster rather than a disc that leaves the window's sides empty. The reserve is measured against each card's **edge
|
|
21
|
-
- **The centre is the entry point** — the middle of the wall is an always-available capture field: type a line, press Enter, and it becomes a note without opening the form. The new note lands in the **nearest free gap** rather than being thrown off screen.
|
|
22
|
-
- **The arrival is visible** — a new card pops in and holds a ring for about 0.9s; if the gap is
|
|
20
|
+
- **A wall with a middle** — "Tidy" packs every note into a **compact composition hugging a clear rectangle** at the world origin, which is kept free for the greeting and the quick-capture field; the camera opens with the whole wall framed and centred. The packer follows the rectangle's own **contour** rather than a circle, so every card is only half its own size away from the middle: the same fourteen notes occupy 1261x705 instead of 1645x1794, and frame at **84% instead of 36%**. Each candidate slot is scored by the zoom the whole wall would need, so the result is a wide, low cluster rather than a disc that leaves the window's sides empty. The reserve is measured against each card's **edge**. Tidy keeps it constant in world space; a **single new note** instead follows where the field really is in world space, so capturing after panning or zooming still lands beside the field rather than behind it.
|
|
21
|
+
- **The centre is the entry point** — the middle of the wall is an always-available capture field: type a line, press Enter, and it becomes a note without opening the form. The new note lands in the **nearest free gap to the field** rather than being thrown off screen — or hidden behind it.
|
|
22
|
+
- **The arrival is visible** — a new card pops in and holds a ring for about 0.9s; if the gap is not on screen the camera brings it to the free space **beside the capture field** (whichever of above/below/left/right needs the least movement), zooming out only when nothing fits, so a capture never leaves you guessing whether it worked. It deliberately does **not** centre the card, because the centre of the viewport is where the field is drawn.
|
|
23
23
|
- **The reserve is a magnetic edge** — dragging a card onto the capture field pushes it to the nearest clear spot instead of letting it cover the input.
|
|
24
24
|
- **One-click tidy** — "Tidy" repacks deterministically and collision-checks every card against the ones already placed, so the same wall always yields the same arrangement and cards never overlap.
|
|
25
25
|
- **Three views** — canvas (default, free placement), grid (responsive masonry for reading long notes) and list (one line per note for finding one by title).
|
|
@@ -135,7 +135,7 @@ The install path was verified end to end: derive the spec from the live index, i
|
|
|
135
135
|
- Card width has only **three presets** (small/medium/large); there is no arbitrary resize. A drag keeps the card's existing tilt.
|
|
136
136
|
- Tidy is O(n) spiral placement plus a spatial-grid collision check; the wall holds at most 400 notes, and a wall larger than the viewport needs panning or zooming out.
|
|
137
137
|
- The canvas is a flat plane: no grouping, layers, connectors or snap alignment, and no rotation gesture beyond the stored tilt.
|
|
138
|
-
- Auto-framing has a legibility floor (
|
|
138
|
+
- Auto-framing has a legibility floor (42%): a large wall is centred rather than crammed entirely into view, so panning is expected. The middle is reserved space — tidy never places a card under the greeting or the capture field, and a capture on a panned or zoomed wall avoids wherever the field currently sits.
|
|
139
139
|
- Placement is owned by the Host, but two windows open on the same wall each render their own snapshot and do not live-push the other's drags.
|
|
140
140
|
- Archived notes do not occupy a `maxNotes` slot, but restoring them does; a restore at the cap is rejected instead of silently overshooting.
|
|
141
141
|
- "Clear archive" is a permanent, irreversible delete.
|
package/README.md
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
- **左侧栏入口**:`sidebar.panellist` 中的「便签墙」图标,点击把中央区域切换到便签墙页面。
|
|
18
18
|
- **自由画布**:便签不是列表项,而是画布上的卡片。位置、旋转角、宽度三档(小/中/大)都属于便签数据,由 Host 保存;同一面墙在另一个窗口打开时摆位一致。
|
|
19
19
|
- **拖动摆放**:按住卡片任意位置即可拖动,松手立刻落到新位置再把结果写回 Host(不会先弹回原处)。拖动本身**不会**改 `updatedAt`,所以「按更新」排序不会因为你整理桌面而乱掉。
|
|
20
|
-
- **圆心构图**:整理把整面墙排成**贴着中心留白的一圈紧凑构图**,中心空出一块**矩形留白**给问候语和快速记录框;相机打开时把整面墙框进视野并居中。排布不是按「圆环」而是按**留白矩形的轮廓**铺开,所以每张卡片离中心都只有它自己的一半尺寸那么远 —— 同样 14 张便签,0.5.0 的圆环要占 1645×1794、只能框到 36%,现在占 1261×705、能框到 84
|
|
21
|
-
- **中心即入口**:便签墙正中是随时可用的快速记录框 ——
|
|
22
|
-
- **落点可见**:新便签生成时会在落点**弹入并亮一圈**(约 0.9
|
|
20
|
+
- **圆心构图**:整理把整面墙排成**贴着中心留白的一圈紧凑构图**,中心空出一块**矩形留白**给问候语和快速记录框;相机打开时把整面墙框进视野并居中。排布不是按「圆环」而是按**留白矩形的轮廓**铺开,所以每张卡片离中心都只有它自己的一半尺寸那么远 —— 同样 14 张便签,0.5.0 的圆环要占 1645×1794、只能框到 36%,现在占 1261×705、能框到 84%。留白按**卡片边缘**判定;整理时它在世界坐标里恒定,而**单张新便签的落点跟随记录框当前在世界里的真实位置**,所以平移到别处或放大之后再记一条,卡片仍然落在记录框旁边而不是它背后。
|
|
21
|
+
- **中心即入口**:便签墙正中是随时可用的快速记录框 —— 写一句按回车就落成一张便签,不用打开表单。新便签落在**离记录框最近的空缺位置**,不会甩到视野之外,也不会被记录框本身挡住。
|
|
22
|
+
- **落点可见**:新便签生成时会在落点**弹入并亮一圈**(约 0.9 秒);如果落点不在视野里,相机会把它带到**记录框旁边的空位**(上/下/左/右取最省力的那侧),必要时才适度缩小 —— 记下一条之后不用猜它到底有没有生成。相机不会把新便签对到画面正中,因为那里正是记录框。
|
|
23
23
|
- **留白是磁吸边界**:把卡片拖到中间记录框上会被自动推到最近的空位,不会盖住输入框。
|
|
24
24
|
- **一键整理**:「整理」把全部便签按确定性算法重新排布并做真实碰撞检测 —— 同一面墙按两次得到同一个结果,卡片永不重叠。
|
|
25
25
|
- **三种视图**:画布(默认,自由摆位)、网格(响应式瀑布流,适合读长文)、列表(一行一条,适合按标题找)。
|
|
@@ -146,7 +146,7 @@ node scripts/preview.mjs check # 离线校验预览图与 locale 元数据(n
|
|
|
146
146
|
- 卡片宽度只有小/中/大**三档预设**,不支持任意拖拽调整宽度;拖动会保留卡片原有的轻微倾角。
|
|
147
147
|
- 整理是 O(n) 的螺旋放置 + 网格碰撞检测;便签上限 400 张,超出视野的墙需要自己平移或缩小。
|
|
148
148
|
- 画布是二维平面:没有分组、图层、连线或吸附对齐;也不支持双指旋转或触屏捏合之外的手势。
|
|
149
|
-
- 自动取景有可读性下限(
|
|
149
|
+
- 自动取景有可读性下限(42%):便签很多时整面墙不会全部挤进视野,而是居中显示、需要平移查看。整理不会把卡片放在问候语和记录框下面;平移到别处再新建时,落点也会避开记录框当前所在的位置。
|
|
150
150
|
- 便签的位置由 Host 保存;同一面墙在两个窗口同时打开时,各自渲染自己的快照,不会实时推送另一个窗口的拖动结果。
|
|
151
151
|
- 归档便签不占 `maxNotes` 名额,但恢复它们会占名额;名额已满时恢复会被拒绝而不是悄悄超限。
|
|
152
152
|
- 「清空归档」是永久删除,不可撤销。
|
package/compatibility.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"verified": [
|
|
5
5
|
{
|
|
6
6
|
"dsh": "0.2.2-rc.1",
|
|
7
|
-
"verifiedAt": "2026-11-
|
|
7
|
+
"verifiedAt": "2026-11-10",
|
|
8
8
|
"result": "passed",
|
|
9
9
|
"checks": [
|
|
10
10
|
"dump-config",
|
|
@@ -54,7 +54,9 @@
|
|
|
54
54
|
"browser-centre-capture-lands-visible",
|
|
55
55
|
"browser-dock-no-overflow",
|
|
56
56
|
"browser-dock-menu-show-archived",
|
|
57
|
-
"browser-wall-is-a-ring"
|
|
57
|
+
"browser-wall-is-a-ring",
|
|
58
|
+
"browser-capture-clear-of-field-on-panned-wall",
|
|
59
|
+
"browser-capture-clear-of-field-on-zoomed-wall"
|
|
58
60
|
],
|
|
59
61
|
"notes": "Packed tarball 0.2.0 installed into an owned, disposable, non-Desktop web profile created from the shipped template (DSH 0.2.2-rc.1). dsh --profile <test> --dump-config composed the bundle row; a bounded real startup served the Web app; the authenticated browser transport exercised the exact /api/skillre-sticky-wall/execute route: list, create, update, move (placement echoed back without bumping updatedAt), an out-of-bounds move CLAMPED into the world while a non-finite one is refused as sticky-wall/bad-request, arrange, archive, delete, plus storage persistence of both the note and its canvas placement across a full restart, and an unauthenticated request returning 401. Cleanup stopped every owned process, removed the owned profile root and verified it was gone. The real DSH Web UI was then driven in headless Chromium against a FRESH owned profile: the 便签墙 sidebar entry appeared and selected the panel (the shell's own preview-notice mask was dismissed first, otherwise it swallows pointer input), the wall mounted with the seeded welcome note, the composer created a note whose Markdown body rendered as strong/code/list elements with no literal markers left, pin moved it first, search filtered to it, archive hid it from the default wall, the archived toggle showed it again, the note survived a full page reload, canvas cards were absolutely positioned from stored layouts, a real pointer drag wrote a new placement through the Host, 整理 repacked the wall and left NO overlapping cards, grid and list views rendered the same note set, and the note palette switched between light and dark. 24/24 UI assertions passed with no uncaught errors. Cleanup stopped the harness, killed Chrome, removed both the owned profile and the Chrome scratch directory, and verified they were gone. The display contract was verified offline: meta.detail resolves to docs/DETAIL*.md, each carries exactly one banner image at the 640x300 ratio, and both SVGs render (evidence PNGs committed). Two real defects were found and fixed during this verification: card heights were under-estimated for CJK text (so the tidy pass overlapped cards), and arrange packed only the live set (so an archived visible card stayed on top of tidied ones). A post-review pass fixed four defects the independent review found and proved each with a test that fails when the fix is reverted: (1) the height estimate charged a long title a flat 1.4 lines, so a 120-char CJK title estimated 104px against a rendered ~244px and tidy overlapped; the title and tag pills are now measured by columns. (2) The packer silently clamped cards past the world coordinate limit, pinning hundreds to one edge; the shelf width now scales with the wall and a 300-card worst case is asserted overlap-free. (3) Every drag wrote rotate: 0, destroying the tilt tidy applied; the drag now carries rotation through and the UI harness asserts it. (4) Derived preview positions were indexed off the filtered list, so legacy notes jumped while typing in the search box; the index now comes from the unfiltered snapshot. Rotation is also budgeted into the shelf gap, and the transport clamps instead of rejecting an out-of-bounds drag. 0.2.1 makes the drag direct: the canvas card no longer transitions its transform (which turned every per-frame write into an animation target and made the card trail the pointer), the drag flag moved from React state to a node attribute so pressing no longer re-renders the wall, pointer moves are coalesced into one write per animation frame, the pointer loop is registered once instead of per press, and the hover lift no longer overwrites the drag transform on the canvas. The UI harness caught a regression in that rewrite (the drop cleared the inline transform and stripped the card's tilt) and the fix is covered by a test. 0.3.0 gives the wall a centre and makes the canvas direct. Tidy now packs a phyllotaxis spiral centred on the world origin with a real spatial-grid collision check (no shelf estimate), and the finished disc is re-centred on its centre of mass; the camera opens on that middle and frames the whole wall, capped at 100%. The canvas became a clipping viewport with one transform-driven world instead of a padded scroll container, so panning and zooming cost zero React renders and dragging a card can no longer move the wall under it. Pan is drag-on-paper or wheel, zoom is ctrl/cmd+wheel anchored on the pointer, and reset re-frames the wall. The drop is optimistic: the card lands on its final world position before the Host round-trip. Cards are memoized and note objects are reconciled by identity, the per-note full-size wrapper element is gone, and body clamping follows the width preset. Verified in the real DSH Web UI with 31/31 assertions on a fresh owned profile, including a 14-note wall that tidies into a centred disc with zero overlaps (aspect ratio 0.94) and is framed at 54% by the camera, a real pointer drag that persists its placement and keeps its rotation, a real drag on empty paper that pans the camera by exactly the pointer delta, a wheel zoom that keeps the world point under the cursor fixed to under 2px, and a reset that re-frames the whole wall. The harness itself caught two real defects during this verification: the wheel listener was bound to a canvas node that did not exist yet while the wall was loading (so zoom silently did nothing), and a pan that ended inside a single animation frame was dropped entirely. Both are fixed and asserted. 0.4.0 turns the wall into a centre-anchored board. The tidy pass now packs a phyllotaxis RING that leaves a clear disc (CENTRE_RADIUS, measured to each card's nearest EDGE, not its centre) at the middle, and the re-centring shift is applied only when it preserves that reserve. The wall's middle is now its centrepiece: a time-aware greeting, a running tally and an always-available quick-capture field, rendered as a screen-space overlay that stays put under pan and zoom. The header and toolbar rows are gone — the canvas fills the whole window and every control lives in one floating dock along the bottom. Auto-framing measures the RENDERED card boxes from the DOM instead of deriving them, is capped at 100% and floored at 50% for legibility, and runs one animation frame after the reconcile so tidy frames the wall it actually produced. Canvas cards are rendered at exactly the height the Host estimated, which is what makes the packer's collision geometry true by construction. Verified in the real DSH Web UI with 36/36 assertions: the centrepiece sits at the exact viewport middle and does not move while panning, tidy leaves the centre clear with zero card overlaps, a 14-note wall tidies to a centred ring (offset 1,1; aspect 1.01), quick capture creates a note and clears the field, the canvas covers 100% of the page with a single-row dock, and a real drag, a paper pan and a pointer-anchored wheel zoom all behave. The harness caught four real defects during this pass: the wheel listener bound to a canvas that did not exist yet, a same-frame pan being dropped, tidy consuming a fit request against the pre-tidy bounds, and a fit floor that shrank a large wall to unreadable size. 0.6.0 re-verified on the same DSH line: contour packing replaces ring packing (see CHANGELOG 0.6.0); the packed 0.6.0 tarball mounts, composes, boots and passes the full API suite in an owned isolated profile, and the 38-check real-UI run passes.",
|
|
60
62
|
"evidence": [
|
|
@@ -73,7 +75,7 @@
|
|
|
73
75
|
"tests/layout.spec.ts",
|
|
74
76
|
"tests/markdown.spec.tsx",
|
|
75
77
|
"docs/evidence/sticky-wall-canvas-many.png",
|
|
76
|
-
"docs/evidence/isolated-mount-0.
|
|
78
|
+
"docs/evidence/isolated-mount-0.7.0.json"
|
|
77
79
|
]
|
|
78
80
|
}
|
|
79
81
|
],
|
package/lib/client.js
CHANGED
|
@@ -386,22 +386,38 @@ window.__ModuleLoader__.load({
|
|
|
386
386
|
const sin = Math.sin(radians);
|
|
387
387
|
return { width: width * cos + height * sin, height: height * cos + width * sin };
|
|
388
388
|
}
|
|
389
|
-
function intersectsReserve(box, reserve = CENTRE_RESERVE) {
|
|
390
|
-
const clear = clearsReserve(box, reserve);
|
|
391
|
-
return !clear;
|
|
392
|
-
}
|
|
393
389
|
var RESERVE_EPSILON = 0.05;
|
|
394
390
|
function clearsReserve(box, reserve) {
|
|
395
|
-
return !(box.x < reserve.halfWidth - RESERVE_EPSILON && box.x + box.width > -reserve.halfWidth + RESERVE_EPSILON && box.y < reserve.halfHeight - RESERVE_EPSILON && box.y + box.height > -reserve.halfHeight + RESERVE_EPSILON);
|
|
391
|
+
return !(box.x < reserve.x + reserve.halfWidth - RESERVE_EPSILON && box.x + box.width > reserve.x - reserve.halfWidth + RESERVE_EPSILON && box.y < reserve.y + reserve.halfHeight - RESERVE_EPSILON && box.y + box.height > reserve.y - reserve.halfHeight + RESERVE_EPSILON);
|
|
392
|
+
}
|
|
393
|
+
function normalizeReserve(raw) {
|
|
394
|
+
const cap = LAYOUT_LIMITS.coord / 4;
|
|
395
|
+
const clampHalf = (value) => {
|
|
396
|
+
const number = Number(value);
|
|
397
|
+
if (!Number.isFinite(number) || number <= 0) return 0;
|
|
398
|
+
return Math.min(cap, number);
|
|
399
|
+
};
|
|
400
|
+
const clampCoord = (value) => {
|
|
401
|
+
const number = Number(value);
|
|
402
|
+
if (!Number.isFinite(number)) return 0;
|
|
403
|
+
return Math.min(LAYOUT_LIMITS.coord, Math.max(-LAYOUT_LIMITS.coord, number));
|
|
404
|
+
};
|
|
405
|
+
return {
|
|
406
|
+
x: clampCoord(raw?.x ?? 0),
|
|
407
|
+
y: clampCoord(raw?.y ?? 0),
|
|
408
|
+
halfWidth: clampHalf(raw?.halfWidth),
|
|
409
|
+
halfHeight: clampHalf(raw?.halfHeight)
|
|
410
|
+
};
|
|
396
411
|
}
|
|
397
412
|
function pushOutOfReserve(note, layout, reserve = CENTRE_RESERVE) {
|
|
413
|
+
const rect = normalizeReserve(reserve);
|
|
398
414
|
const box = footprintOf(note, layout);
|
|
399
|
-
if (
|
|
415
|
+
if (clearsReserve(box, rect)) return layout;
|
|
400
416
|
const moves = [
|
|
401
|
-
{ dx: -
|
|
402
|
-
{ dx:
|
|
403
|
-
{ dx: 0, dy: -
|
|
404
|
-
{ dx: 0, dy:
|
|
417
|
+
{ dx: rect.x - rect.halfWidth - (box.x + box.width), dy: 0 },
|
|
418
|
+
{ dx: rect.x + rect.halfWidth - box.x, dy: 0 },
|
|
419
|
+
{ dx: 0, dy: rect.y - rect.halfHeight - (box.y + box.height) },
|
|
420
|
+
{ dx: 0, dy: rect.y + rect.halfHeight - box.y }
|
|
405
421
|
];
|
|
406
422
|
let best = moves[0];
|
|
407
423
|
for (const move of moves) {
|
|
@@ -1794,16 +1810,11 @@ window.__ModuleLoader__.load({
|
|
|
1794
1810
|
tween.current = 0;
|
|
1795
1811
|
}
|
|
1796
1812
|
}, []);
|
|
1797
|
-
const
|
|
1798
|
-
const
|
|
1799
|
-
|
|
1813
|
+
const glideCameraTo = (0, import_react.useCallback)((zoomTarget, panX, panY) => {
|
|
1814
|
+
const target = clampZoom(zoomTarget);
|
|
1815
|
+
const to = { zoom: target, panX, panY };
|
|
1800
1816
|
stopTween();
|
|
1801
1817
|
const from = { ...camera.current };
|
|
1802
|
-
const to = {
|
|
1803
|
-
zoom: clampZoom(zoomTarget),
|
|
1804
|
-
panX: viewport.clientWidth / 2 - worldX * clampZoom(zoomTarget),
|
|
1805
|
-
panY: viewport.clientHeight / 2 - worldY * clampZoom(zoomTarget)
|
|
1806
|
-
};
|
|
1807
1818
|
if (typeof requestAnimationFrame !== "function") {
|
|
1808
1819
|
camera.current = { ...to };
|
|
1809
1820
|
setZoom(to.zoom);
|
|
@@ -1832,6 +1843,12 @@ window.__ModuleLoader__.load({
|
|
|
1832
1843
|
tween.current = requestAnimationFrame(frame);
|
|
1833
1844
|
setZoom(to.zoom);
|
|
1834
1845
|
}, [applyCamera, stopTween]);
|
|
1846
|
+
const glideTo = (0, import_react.useCallback)((zoomTarget, worldX, worldY) => {
|
|
1847
|
+
const viewport = viewportRefCurrent.current;
|
|
1848
|
+
if (viewport === null) return;
|
|
1849
|
+
const target = clampZoom(zoomTarget);
|
|
1850
|
+
glideCameraTo(target, viewport.clientWidth / 2 - worldX * target, viewport.clientHeight / 2 - worldY * target);
|
|
1851
|
+
}, [glideCameraTo]);
|
|
1835
1852
|
const centreOn = (0, import_react.useCallback)((worldX, worldY) => {
|
|
1836
1853
|
stopTween();
|
|
1837
1854
|
const viewport = viewportRefCurrent.current;
|
|
@@ -1913,27 +1930,90 @@ window.__ModuleLoader__.load({
|
|
|
1913
1930
|
const resetView = (0, import_react.useCallback)(() => {
|
|
1914
1931
|
fitWall();
|
|
1915
1932
|
}, [fitWall]);
|
|
1916
|
-
const centreReserve = (0, import_react.useCallback)(() =>
|
|
1933
|
+
const centreReserve = (0, import_react.useCallback)(() => {
|
|
1934
|
+
const base = CENTRE_RESERVE;
|
|
1935
|
+
const viewport = viewportRefCurrent.current;
|
|
1936
|
+
const centre = centreRef.current;
|
|
1937
|
+
if (viewport === null || centre === null) return base;
|
|
1938
|
+
const view2 = viewport.getBoundingClientRect();
|
|
1939
|
+
const block = centre.getBoundingClientRect();
|
|
1940
|
+
if (view2.width === 0 || view2.height === 0 || block.width === 0 || block.height === 0) return base;
|
|
1941
|
+
const zoomNow = camera.current.zoom;
|
|
1942
|
+
const screenX = block.left + block.width / 2 - view2.left;
|
|
1943
|
+
const screenY = block.top + block.height / 2 - view2.top;
|
|
1944
|
+
return {
|
|
1945
|
+
x: (screenX - camera.current.panX) / zoomNow,
|
|
1946
|
+
y: (screenY - camera.current.panY) / zoomNow,
|
|
1947
|
+
halfWidth: base.halfWidth,
|
|
1948
|
+
halfHeight: base.halfHeight
|
|
1949
|
+
};
|
|
1950
|
+
}, []);
|
|
1917
1951
|
const revealBox = (0, import_react.useCallback)((box) => {
|
|
1918
1952
|
const viewport = viewportRefCurrent.current;
|
|
1919
1953
|
if (viewport === null) return;
|
|
1920
|
-
const
|
|
1921
|
-
const
|
|
1922
|
-
const centreY = box.y + box.height / 2;
|
|
1923
|
-
const screenX = centreX * zoomNow + camera.current.panX;
|
|
1924
|
-
const screenY = centreY * zoomNow + camera.current.panY;
|
|
1954
|
+
const width = viewport.clientWidth || 960;
|
|
1955
|
+
const height = viewport.clientHeight || 640;
|
|
1925
1956
|
const margin = 72;
|
|
1926
|
-
const
|
|
1927
|
-
|
|
1928
|
-
const
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1957
|
+
const dock = dockRef.current;
|
|
1958
|
+
const bottomInset = dock === null ? 0 : dock.offsetHeight + 24;
|
|
1959
|
+
const usableBottom = height - margin - bottomInset;
|
|
1960
|
+
const view2 = viewport.getBoundingClientRect();
|
|
1961
|
+
const centre = centreRef.current;
|
|
1962
|
+
const blockRect = centre === null ? null : centre.getBoundingClientRect();
|
|
1963
|
+
const fieldX = blockRect === null ? width / 2 : blockRect.left + blockRect.width / 2 - view2.left;
|
|
1964
|
+
const fieldY = blockRect === null ? height / 2 : blockRect.top + blockRect.height / 2 - view2.top;
|
|
1965
|
+
const reserve = CENTRE_RESERVE;
|
|
1966
|
+
const blockHalf = (zoom2) => ({
|
|
1967
|
+
// The painted overlay is counter-scaled by `min(1, zoom)`, while its world
|
|
1968
|
+
// footprint stays fixed; taking the larger of the two keeps the card clear
|
|
1969
|
+
// of whichever is actually on screen.
|
|
1970
|
+
halfW: reserve.halfWidth * Math.max(1, zoom2),
|
|
1971
|
+
halfH: reserve.halfHeight * Math.max(1, zoom2)
|
|
1972
|
+
});
|
|
1973
|
+
const cardX = box.x + box.width / 2;
|
|
1974
|
+
const cardY = box.y + box.height / 2;
|
|
1975
|
+
const screenX = cardX * camera.current.zoom + camera.current.panX;
|
|
1976
|
+
const screenY = cardY * camera.current.zoom + camera.current.panY;
|
|
1977
|
+
const fitsAt = (x, y2, zoom2) => x - box.width * zoom2 / 2 >= margin && x + box.width * zoom2 / 2 <= width - margin && y2 - box.height * zoom2 / 2 >= margin && y2 + box.height * zoom2 / 2 <= usableBottom;
|
|
1978
|
+
const hiddenAt = (x, y2, zoom2) => {
|
|
1979
|
+
const { halfW, halfH: halfH2 } = blockHalf(zoom2);
|
|
1980
|
+
return x - box.width * zoom2 / 2 < fieldX + halfW && x + box.width * zoom2 / 2 > fieldX - halfW && y2 - box.height * zoom2 / 2 < fieldY + halfH2 && y2 + box.height * zoom2 / 2 > fieldY - halfH2;
|
|
1981
|
+
};
|
|
1982
|
+
if (fitsAt(screenX, screenY, camera.current.zoom) && !hiddenAt(screenX, screenY, camera.current.zoom)) return;
|
|
1983
|
+
const gap = 26;
|
|
1984
|
+
for (let step = 0; step <= 8; step += 1) {
|
|
1985
|
+
const zoom2 = step === 0 ? camera.current.zoom : Math.max(ZOOM_MIN, camera.current.zoom * 0.88 ** step);
|
|
1986
|
+
const { halfW, halfH: halfH2 } = blockHalf(zoom2);
|
|
1987
|
+
const halfCardW = box.width * zoom2 / 2;
|
|
1988
|
+
const halfCardH = box.height * zoom2 / 2;
|
|
1989
|
+
const candidates = [
|
|
1990
|
+
{ x: fieldX, y: fieldY - halfH2 - gap - halfCardH },
|
|
1991
|
+
{ x: fieldX, y: fieldY + halfH2 + gap + halfCardH },
|
|
1992
|
+
{ x: fieldX - halfW - gap - halfCardW, y: fieldY },
|
|
1993
|
+
{ x: fieldX + halfW + gap + halfCardW, y: fieldY }
|
|
1994
|
+
];
|
|
1995
|
+
let best = null;
|
|
1996
|
+
for (const candidate of candidates) {
|
|
1997
|
+
if (!fitsAt(candidate.x, candidate.y, zoom2)) continue;
|
|
1998
|
+
if (hiddenAt(candidate.x, candidate.y, zoom2)) continue;
|
|
1999
|
+
const cost = Math.hypot(candidate.x - screenX, candidate.y - screenY);
|
|
2000
|
+
if (best === null || cost < best.cost) best = { x: candidate.x, y: candidate.y, zoom: zoom2, cost };
|
|
2001
|
+
}
|
|
2002
|
+
if (best !== null) {
|
|
2003
|
+
glideCameraTo(best.zoom, best.x - cardX * best.zoom, best.y - cardY * best.zoom);
|
|
2004
|
+
return;
|
|
2005
|
+
}
|
|
2006
|
+
if (zoom2 <= ZOOM_MIN) break;
|
|
2007
|
+
}
|
|
2008
|
+
const targetZoom = Math.max(ZOOM_MIN, Math.min(
|
|
2009
|
+
camera.current.zoom,
|
|
2010
|
+
(width - margin * 2) / Math.max(1, box.width),
|
|
2011
|
+
(usableBottom - margin) / Math.max(1, box.height)
|
|
2012
|
+
));
|
|
2013
|
+
const { halfH } = blockHalf(targetZoom);
|
|
2014
|
+
const y = fieldY + halfH + gap + box.height * targetZoom / 2;
|
|
2015
|
+
glideCameraTo(targetZoom, width / 2 - cardX * targetZoom, y - cardY * targetZoom);
|
|
2016
|
+
}, [glideCameraTo]);
|
|
1937
2017
|
const arrival = (0, import_react.useRef)(null);
|
|
1938
2018
|
(0, import_react.useEffect)(() => {
|
|
1939
2019
|
const pending = arrival.current;
|
package/lib/layout.d.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* Both halves import this module, so the geometry never drifts between the
|
|
21
21
|
* value the Host persists and the value the Client previews.
|
|
22
22
|
*/
|
|
23
|
-
import { type CentreReserve, type Note, type NoteLayout, type NoteWidth } from './types.js';
|
|
23
|
+
import { type CentreReserve, type Note, type NoteLayout, type NoteWidth, type ReserveRect } from './types.js';
|
|
24
24
|
/** Clamp one layout into the declared world bounds. */
|
|
25
25
|
export declare function clampLayout(layout: NoteLayout): NoteLayout;
|
|
26
26
|
/** True when two layouts describe the same position (rounded comparison). */
|
|
@@ -145,7 +145,21 @@ export declare function normalizeWidth(raw: unknown): NoteWidth;
|
|
|
145
145
|
* capped well inside the world bounds so the packer can never be asked to keep
|
|
146
146
|
* a middle clear that leaves no paper for the cards.
|
|
147
147
|
*/
|
|
148
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Clamp a reserve into something the packer can actually honour.
|
|
150
|
+
*
|
|
151
|
+
* The Client sends a reserve positioned where the centrepiece currently sits in
|
|
152
|
+
* world space, so it can arrive with huge coordinates (a deeply zoomed-out wall)
|
|
153
|
+
* or as garbage. Both extremes are refused here: a non-finite coordinate becomes
|
|
154
|
+
* the origin, and the half-extents are capped well inside the world bounds so the
|
|
155
|
+
* packer can never be asked to keep a middle clear that leaves no paper for the
|
|
156
|
+
* cards.
|
|
157
|
+
*
|
|
158
|
+
* The position is clamped to the world bounds rather than to zero: a panned wall
|
|
159
|
+
* legitimately puts the field far from the origin, and snapping it back to the
|
|
160
|
+
* origin would reintroduce the very bug this position exists to fix.
|
|
161
|
+
*/
|
|
162
|
+
export declare function normalizeReserve(raw: CentreReserve): ReserveRect;
|
|
149
163
|
/**
|
|
150
164
|
* The nearest free spot for one new card, in world coordinates.
|
|
151
165
|
*
|
|
@@ -156,11 +170,19 @@ export declare function normalizeReserve(raw: CentreReserve): CentreReserve;
|
|
|
156
170
|
* the user could not see it, which reads exactly like the capture silently
|
|
157
171
|
* failing.
|
|
158
172
|
*
|
|
159
|
-
* This searches outward from the
|
|
173
|
+
* This searches outward from the field instead: the spiral is walked from just
|
|
160
174
|
* outside the centrepiece's reserve, and the first candidate that clears every
|
|
161
175
|
* existing card (plus a gap) and stays out of the reserve is the answer. The
|
|
162
|
-
* result is therefore the gap nearest the
|
|
163
|
-
*
|
|
176
|
+
* result is therefore the gap nearest the place the user is actually looking at,
|
|
177
|
+
* which is where the wall has room.
|
|
178
|
+
*
|
|
179
|
+
* The spiral orbits the RESERVE, not the world origin. That distinction is the
|
|
180
|
+
* fix for a note appearing behind the capture field: the field is a screen-space
|
|
181
|
+
* overlay, so on a panned wall it covers a patch of world that is nowhere near
|
|
182
|
+
* the origin. Orbiting the origin placed the card beside a point the user could
|
|
183
|
+
* not see, and the reveal then centred that point — with the field drawn on top
|
|
184
|
+
* of it. Orbiting the reserve puts the card next to the field, which is both
|
|
185
|
+
* visible and the only placement that can never be hidden by it.
|
|
164
186
|
*
|
|
165
187
|
* Deterministic for the same inputs, so two windows creating at once cannot
|
|
166
188
|
* disagree about the free spot for the same wall.
|
package/lib/layout.js
CHANGED
|
@@ -245,8 +245,7 @@ export function rotatedExtent(width, height, rotate) {
|
|
|
245
245
|
* cards in from the sides.
|
|
246
246
|
*/
|
|
247
247
|
export function intersectsReserve(box, reserve = CENTRE_RESERVE) {
|
|
248
|
-
|
|
249
|
-
return !clear;
|
|
248
|
+
return !clearsReserve(box, normalizeReserve(reserve));
|
|
250
249
|
}
|
|
251
250
|
/**
|
|
252
251
|
* Tolerance for the reserve test, in world pixels.
|
|
@@ -258,11 +257,20 @@ export function intersectsReserve(box, reserve = CENTRE_RESERVE) {
|
|
|
258
257
|
* far below anything visible and well above the rounding error.
|
|
259
258
|
*/
|
|
260
259
|
const RESERVE_EPSILON = 0.05;
|
|
260
|
+
/**
|
|
261
|
+
* Whether a footprint stays out of the clear rectangle.
|
|
262
|
+
*
|
|
263
|
+
* The rectangle has a POSITION as well as a size. The centrepiece is a
|
|
264
|
+
* screen-space overlay, so the world patch it covers moves as the camera pans
|
|
265
|
+
* and zooms; a reserve that only knew its half-extents therefore described the
|
|
266
|
+
* world origin, and a card captured from a panned wall was placed clear of the
|
|
267
|
+
* wrong place — which is exactly how a fresh card ended up behind the field.
|
|
268
|
+
*/
|
|
261
269
|
function clearsReserve(box, reserve) {
|
|
262
|
-
return !(box.x < reserve.halfWidth - RESERVE_EPSILON &&
|
|
263
|
-
box.x + box.width > -reserve.halfWidth + RESERVE_EPSILON &&
|
|
264
|
-
box.y < reserve.halfHeight - RESERVE_EPSILON &&
|
|
265
|
-
box.y + box.height > -reserve.halfHeight + RESERVE_EPSILON);
|
|
270
|
+
return !(box.x < reserve.x + reserve.halfWidth - RESERVE_EPSILON &&
|
|
271
|
+
box.x + box.width > reserve.x - reserve.halfWidth + RESERVE_EPSILON &&
|
|
272
|
+
box.y < reserve.y + reserve.halfHeight - RESERVE_EPSILON &&
|
|
273
|
+
box.y + box.height > reserve.y - reserve.halfHeight + RESERVE_EPSILON);
|
|
266
274
|
}
|
|
267
275
|
/** Cell coordinate of one world value. */
|
|
268
276
|
function cellOf(value) {
|
|
@@ -432,7 +440,20 @@ export function arrangeLayouts(notes, options = {}) {
|
|
|
432
440
|
const extent = rotatedExtent(cardWidth, cardHeight, rotate);
|
|
433
441
|
return { note, width, cardWidth, cardHeight, rotate, extent };
|
|
434
442
|
});
|
|
435
|
-
|
|
443
|
+
// The contour is anchored on the ORIGIN, deliberately, even when the caller
|
|
444
|
+
// sends a positioned reserve.
|
|
445
|
+
//
|
|
446
|
+
// Tidy ends by centring the finished wall's bounding box on the origin, and the
|
|
447
|
+
// Client then refits the camera so that box fills the viewport — which puts the
|
|
448
|
+
// centrepiece back over the origin. So the origin is where the field is going to
|
|
449
|
+
// be, not where it happens to be at the instant tidy was pressed. Honouring a
|
|
450
|
+
// transient camera position here would pack the wall around a point the refit is
|
|
451
|
+
// about to move away from. The SIZE is still honoured, because that is the part
|
|
452
|
+
// that does not change.
|
|
453
|
+
//
|
|
454
|
+
// `findFreeLayout` is the opposite case: it places one card on the CURRENT view,
|
|
455
|
+
// with no refit to follow, so it orbits the reserve's real position.
|
|
456
|
+
const reserve = { ...normalizeReserve(options.centreReserve ?? CENTRE_RESERVE), x: 0, y: 0 };
|
|
436
457
|
// Largest first: the classic first-fit-decreasing heuristic. Big cards claim
|
|
437
458
|
// the inner frames where there is less room to waste, and small cards fill the
|
|
438
459
|
// gaps they leave. Ties break on id so the result stays deterministic across
|
|
@@ -647,6 +668,20 @@ export function normalizeWidth(raw) {
|
|
|
647
668
|
* capped well inside the world bounds so the packer can never be asked to keep
|
|
648
669
|
* a middle clear that leaves no paper for the cards.
|
|
649
670
|
*/
|
|
671
|
+
/**
|
|
672
|
+
* Clamp a reserve into something the packer can actually honour.
|
|
673
|
+
*
|
|
674
|
+
* The Client sends a reserve positioned where the centrepiece currently sits in
|
|
675
|
+
* world space, so it can arrive with huge coordinates (a deeply zoomed-out wall)
|
|
676
|
+
* or as garbage. Both extremes are refused here: a non-finite coordinate becomes
|
|
677
|
+
* the origin, and the half-extents are capped well inside the world bounds so the
|
|
678
|
+
* packer can never be asked to keep a middle clear that leaves no paper for the
|
|
679
|
+
* cards.
|
|
680
|
+
*
|
|
681
|
+
* The position is clamped to the world bounds rather than to zero: a panned wall
|
|
682
|
+
* legitimately puts the field far from the origin, and snapping it back to the
|
|
683
|
+
* origin would reintroduce the very bug this position exists to fix.
|
|
684
|
+
*/
|
|
650
685
|
export function normalizeReserve(raw) {
|
|
651
686
|
const cap = LAYOUT_LIMITS.coord / 4;
|
|
652
687
|
const clampHalf = (value) => {
|
|
@@ -655,7 +690,18 @@ export function normalizeReserve(raw) {
|
|
|
655
690
|
return 0;
|
|
656
691
|
return Math.min(cap, number);
|
|
657
692
|
};
|
|
658
|
-
|
|
693
|
+
const clampCoord = (value) => {
|
|
694
|
+
const number = Number(value);
|
|
695
|
+
if (!Number.isFinite(number))
|
|
696
|
+
return 0;
|
|
697
|
+
return Math.min(LAYOUT_LIMITS.coord, Math.max(-LAYOUT_LIMITS.coord, number));
|
|
698
|
+
};
|
|
699
|
+
return {
|
|
700
|
+
x: clampCoord(raw?.x ?? 0),
|
|
701
|
+
y: clampCoord(raw?.y ?? 0),
|
|
702
|
+
halfWidth: clampHalf(raw?.halfWidth),
|
|
703
|
+
halfHeight: clampHalf(raw?.halfHeight),
|
|
704
|
+
};
|
|
659
705
|
}
|
|
660
706
|
/**
|
|
661
707
|
* The nearest free spot for one new card, in world coordinates.
|
|
@@ -667,11 +713,19 @@ export function normalizeReserve(raw) {
|
|
|
667
713
|
* the user could not see it, which reads exactly like the capture silently
|
|
668
714
|
* failing.
|
|
669
715
|
*
|
|
670
|
-
* This searches outward from the
|
|
716
|
+
* This searches outward from the field instead: the spiral is walked from just
|
|
671
717
|
* outside the centrepiece's reserve, and the first candidate that clears every
|
|
672
718
|
* existing card (plus a gap) and stays out of the reserve is the answer. The
|
|
673
|
-
* result is therefore the gap nearest the
|
|
674
|
-
*
|
|
719
|
+
* result is therefore the gap nearest the place the user is actually looking at,
|
|
720
|
+
* which is where the wall has room.
|
|
721
|
+
*
|
|
722
|
+
* The spiral orbits the RESERVE, not the world origin. That distinction is the
|
|
723
|
+
* fix for a note appearing behind the capture field: the field is a screen-space
|
|
724
|
+
* overlay, so on a panned wall it covers a patch of world that is nowhere near
|
|
725
|
+
* the origin. Orbiting the origin placed the card beside a point the user could
|
|
726
|
+
* not see, and the reveal then centred that point — with the field drawn on top
|
|
727
|
+
* of it. Orbiting the reserve puts the card next to the field, which is both
|
|
728
|
+
* visible and the only placement that can never be hidden by it.
|
|
675
729
|
*
|
|
676
730
|
* Deterministic for the same inputs, so two windows creating at once cannot
|
|
677
731
|
* disagree about the free spot for the same wall.
|
|
@@ -702,7 +756,8 @@ export function findFreeLayout(note, existing, options = {}) {
|
|
|
702
756
|
// Start just outside the reserve so the first candidate is the closest legal
|
|
703
757
|
// ring, then walk the same golden-angle spiral the tidy pass uses. A step near
|
|
704
758
|
// the card's own size keeps the search local: the answer is the first gap, not
|
|
705
|
-
// a far-away hole.
|
|
759
|
+
// a far-away hole. The whole spiral is offset by the reserve's centre, because
|
|
760
|
+
// the field it protects is wherever the camera has put it.
|
|
706
761
|
const step = Math.max(64, Math.sqrt(extent.width * extent.height) * 0.92);
|
|
707
762
|
const startRadius = Math.hypot(reserve.halfWidth, reserve.halfHeight);
|
|
708
763
|
const startIndex = (startRadius / step) ** 2;
|
|
@@ -711,8 +766,8 @@ export function findFreeLayout(note, existing, options = {}) {
|
|
|
711
766
|
const radius = step * Math.sqrt(index);
|
|
712
767
|
const theta = index * GOLDEN_ANGLE;
|
|
713
768
|
const candidate = {
|
|
714
|
-
x: Math.cos(theta) * radius - extent.width / 2,
|
|
715
|
-
y: Math.sin(theta) * radius - extent.height / 2,
|
|
769
|
+
x: reserve.x + Math.cos(theta) * radius - extent.width / 2,
|
|
770
|
+
y: reserve.y + Math.sin(theta) * radius - extent.height / 2,
|
|
716
771
|
width: extent.width,
|
|
717
772
|
height: extent.height,
|
|
718
773
|
};
|
|
@@ -731,8 +786,8 @@ export function findFreeLayout(note, existing, options = {}) {
|
|
|
731
786
|
// than a real path: place just outside the reserve on the first ring.
|
|
732
787
|
const fallbackRadius = startRadius + Math.max(extent.width, extent.height);
|
|
733
788
|
return clampLayout({
|
|
734
|
-
x: -cardWidth / 2,
|
|
735
|
-
y:
|
|
789
|
+
x: reserve.x - cardWidth / 2,
|
|
790
|
+
y: reserve.y + fallbackRadius - cardHeight / 2,
|
|
736
791
|
rotate,
|
|
737
792
|
width,
|
|
738
793
|
});
|
|
@@ -772,28 +827,30 @@ export function noteBox(note, index) {
|
|
|
772
827
|
* collisions needs the whole ordered list, not just the first answer.
|
|
773
828
|
*/
|
|
774
829
|
export function escapesFromReserve(note, layout, reserve = CENTRE_RESERVE) {
|
|
830
|
+
const rect = normalizeReserve(reserve);
|
|
775
831
|
const box = footprintOf(note, layout);
|
|
776
832
|
const moves = [
|
|
777
|
-
{ dx: -
|
|
778
|
-
{ dx:
|
|
779
|
-
{ dx: 0, dy: -
|
|
780
|
-
{ dx: 0, dy:
|
|
833
|
+
{ dx: rect.x - rect.halfWidth - (box.x + box.width), dy: 0 },
|
|
834
|
+
{ dx: rect.x + rect.halfWidth - box.x, dy: 0 },
|
|
835
|
+
{ dx: 0, dy: rect.y - rect.halfHeight - (box.y + box.height) },
|
|
836
|
+
{ dx: 0, dy: rect.y + rect.halfHeight - box.y },
|
|
781
837
|
];
|
|
782
838
|
return moves
|
|
783
839
|
.sort((left, right) => (Math.abs(left.dx) + Math.abs(left.dy)) - (Math.abs(right.dx) + Math.abs(right.dy)))
|
|
784
840
|
.map((move) => clampLayout({ ...layout, x: layout.x + move.dx, y: layout.y + move.dy }));
|
|
785
841
|
}
|
|
786
842
|
export function pushOutOfReserve(note, layout, reserve = CENTRE_RESERVE) {
|
|
843
|
+
const rect = normalizeReserve(reserve);
|
|
787
844
|
const box = footprintOf(note, layout);
|
|
788
|
-
if (
|
|
845
|
+
if (clearsReserve(box, rect))
|
|
789
846
|
return layout;
|
|
790
847
|
// Four ways out, one per edge; the shortest wins so the card slides to the
|
|
791
848
|
// nearest side instead of jumping around the rectangle.
|
|
792
849
|
const moves = [
|
|
793
|
-
{ dx: -
|
|
794
|
-
{ dx:
|
|
795
|
-
{ dx: 0, dy: -
|
|
796
|
-
{ dx: 0, dy:
|
|
850
|
+
{ dx: rect.x - rect.halfWidth - (box.x + box.width), dy: 0 },
|
|
851
|
+
{ dx: rect.x + rect.halfWidth - box.x, dy: 0 },
|
|
852
|
+
{ dx: 0, dy: rect.y - rect.halfHeight - (box.y + box.height) },
|
|
853
|
+
{ dx: 0, dy: rect.y + rect.halfHeight - box.y },
|
|
797
854
|
];
|
|
798
855
|
let best = moves[0];
|
|
799
856
|
for (const move of moves) {
|
package/lib/transport.js
CHANGED
|
@@ -45,13 +45,23 @@ const layoutSchema = z
|
|
|
45
45
|
/**
|
|
46
46
|
* The clear rectangle the Client reserves around the wall's centrepiece.
|
|
47
47
|
*
|
|
48
|
+
* The half-extents describe its SIZE and `x`/`y` its POSITION in world space: the
|
|
49
|
+
* centrepiece is a screen-space overlay, so on a panned or zoomed wall the patch
|
|
50
|
+
* of world it covers is not the origin. Omitting the position means the origin,
|
|
51
|
+
* which is where a freshly framed wall puts the field.
|
|
52
|
+
*
|
|
48
53
|
* Bounds are NOT enforced here for the same reason the layout's are not: the
|
|
49
54
|
* store normalizes with `normalizeReserve`, which caps an absurd value instead of
|
|
50
55
|
* erroring, so a deeply zoomed-out wall still gets a wall. Non-finite values are
|
|
51
56
|
* refused, because there is no sensible clamp for NaN.
|
|
52
57
|
*/
|
|
53
58
|
const reserveSchema = z
|
|
54
|
-
.object({
|
|
59
|
+
.object({
|
|
60
|
+
x: z.number().finite().optional(),
|
|
61
|
+
y: z.number().finite().optional(),
|
|
62
|
+
halfWidth: z.number().finite(),
|
|
63
|
+
halfHeight: z.number().finite(),
|
|
64
|
+
})
|
|
55
65
|
.strict();
|
|
56
66
|
const requestSchema = z.discriminatedUnion('action', [
|
|
57
67
|
z.object({ action: z.literal('list'), includeArchived: z.boolean().optional(), sort: sortSchema.optional() }).strict(),
|
package/lib/types.d.ts
CHANGED
|
@@ -66,8 +66,37 @@ export declare const CENTRE_RESERVE: Readonly<{
|
|
|
66
66
|
halfWidth: 330;
|
|
67
67
|
halfHeight: 136;
|
|
68
68
|
}>;
|
|
69
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* A clear rectangle around the wall's centrepiece, in WORLD pixels.
|
|
71
|
+
*
|
|
72
|
+
* The size is fixed, but the POSITION is not, and that distinction is the whole
|
|
73
|
+
* point. The centrepiece is a screen-space overlay: it stays at the middle of
|
|
74
|
+
* the viewport while the paper pans and zooms underneath it, so the patch of
|
|
75
|
+
* world it covers moves with the camera even though the patch keeps its size.
|
|
76
|
+
*
|
|
77
|
+
* A reserve that only carried half-extents therefore described the wrong place
|
|
78
|
+
* as soon as the camera moved: the Host kept the world ORIGIN clear while the
|
|
79
|
+
* field sat somewhere else, and a note captured from the field was placed —
|
|
80
|
+
* and then revealed — directly behind it. `x`/`y` are that missing position;
|
|
81
|
+
* they default to the origin, which is exactly where a freshly framed wall puts
|
|
82
|
+
* the field.
|
|
83
|
+
*/
|
|
70
84
|
export interface CentreReserve {
|
|
85
|
+
/** World x of the reserve's centre; defaults to the origin. */
|
|
86
|
+
x?: number | undefined;
|
|
87
|
+
/** World y of the reserve's centre; defaults to the origin. */
|
|
88
|
+
y?: number | undefined;
|
|
89
|
+
/** Half-width in world pixels. */
|
|
90
|
+
halfWidth: number;
|
|
91
|
+
/** Half-height in world pixels. */
|
|
92
|
+
halfHeight: number;
|
|
93
|
+
}
|
|
94
|
+
/** A reserve with its position resolved: what the geometry actually works on. */
|
|
95
|
+
export interface ReserveRect {
|
|
96
|
+
/** World x of the reserve's centre. */
|
|
97
|
+
x: number;
|
|
98
|
+
/** World y of the reserve's centre. */
|
|
99
|
+
y: number;
|
|
71
100
|
/** Half-width in world pixels. */
|
|
72
101
|
halfWidth: number;
|
|
73
102
|
/** Half-height in world pixels. */
|