@skillre/dsh-plugin-sticky-wall 0.3.0 → 0.5.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 +8 -2
- package/README.md +8 -2
- package/compatibility.json +15 -4
- package/docs/preview.svg +91 -62
- package/docs/preview.zh.svg +91 -62
- package/lib/client.js +718 -121
- package/lib/layout.d.ts +107 -11
- package/lib/layout.js +485 -51
- package/lib/store.d.ts +16 -4
- package/lib/store.js +32 -11
- package/lib/transport.d.ts +7 -2
- package/lib/transport.js +17 -3
- package/lib/types.d.ts +28 -0
- package/lib/types.js +16 -0
- package/package.json +1 -1
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 Note, type NoteLayout, type NoteWidth } from './types.js';
|
|
23
|
+
import { type CentreReserve, type Note, type NoteLayout, type NoteWidth } 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). */
|
|
@@ -62,24 +62,120 @@ export declare function rotatedExtent(width: number, height: number, rotate: num
|
|
|
62
62
|
width: number;
|
|
63
63
|
height: number;
|
|
64
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Whether a footprint stays out of a clear rectangle.
|
|
67
|
+
*
|
|
68
|
+
* The tidy pass keeps the wall's middle clear for the centrepiece, and "clear"
|
|
69
|
+
* has to mean the card's EDGE: measuring from the card's centre let a wide card
|
|
70
|
+
* reach over the capture field by half its own width. A rectangle rather than a
|
|
71
|
+
* radius is the honest shape, because the centrepiece is a wide, short stack —
|
|
72
|
+
* a circle either wasted a tall column of paper above and below it or let wide
|
|
73
|
+
* cards in from the sides.
|
|
74
|
+
*/
|
|
75
|
+
export declare function intersectsReserve(box: Box, reserve?: CentreReserve): boolean;
|
|
76
|
+
/** One axis-aligned footprint on the wall, in world pixels. */
|
|
77
|
+
export interface Box {
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
}
|
|
65
83
|
/**
|
|
66
84
|
* Deterministic tidy arrangement for the whole wall.
|
|
67
85
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
86
|
+
* The wall is packed into CONCENTRIC RINGS around the world origin, outside the
|
|
87
|
+
* rectangle the centrepiece reserves. This replaced a phyllotaxis first-fit
|
|
88
|
+
* spiral, and the reason is measurable rather than aesthetic: a sunflower spiral
|
|
89
|
+
* has to keep every candidate clear of a card's full bounding circle, so it
|
|
90
|
+
* saturates at roughly a quarter of the available area and the only way to place
|
|
91
|
+
* the next card is to walk further out. A fourteen-card wall therefore spread
|
|
92
|
+
* over ~2700px of paper while its cards covered ~430,000px² — a sparse scatter,
|
|
93
|
+
* not a wall. Ring packing instead computes how many cards fit on each circle
|
|
94
|
+
* (`2πR / pitch`) and fills that circle evenly, so the same fourteen cards fit
|
|
95
|
+
* within ~1200px and the result reads as a ring around the middle.
|
|
96
|
+
*
|
|
97
|
+
* Cards are sorted largest-first within the ring they land on, which is the
|
|
98
|
+
* classic first-fit-decreasing heuristic: big cards claim the inner ring where
|
|
99
|
+
* there is less room to waste, and small cards take up the slack outside.
|
|
74
100
|
*
|
|
75
|
-
* A collision check
|
|
76
|
-
*
|
|
77
|
-
*
|
|
101
|
+
* A collision check still runs on every candidate rather than trusting the
|
|
102
|
+
* height estimate, because the estimate is a line count and a code block's
|
|
103
|
+
* padding is not something a line count can see. If a candidate does not fit the
|
|
104
|
+
* check pushes to the next ring — the packer never produces an overlap.
|
|
78
105
|
*
|
|
79
106
|
* Returns a map from note id to its new layout, for every note that needs to
|
|
80
107
|
* move. Notes already at exactly that layout are omitted by the caller, so
|
|
81
108
|
* pressing tidy on an already-tidy wall writes nothing.
|
|
82
109
|
*/
|
|
83
|
-
export declare function arrangeLayouts(notes: readonly Note[]
|
|
110
|
+
export declare function arrangeLayouts(notes: readonly Note[], options?: {
|
|
111
|
+
centreReserve?: CentreReserve | undefined;
|
|
112
|
+
}): Map<string, NoteLayout>;
|
|
84
113
|
/** Normalize a submitted width preset, defaulting to the middle size. */
|
|
85
114
|
export declare function normalizeWidth(raw: unknown): NoteWidth;
|
|
115
|
+
/**
|
|
116
|
+
* Clamp a reserve into something the packer can actually honour.
|
|
117
|
+
*
|
|
118
|
+
* The Client sends a zoom-corrected reserve, so it can arrive as a huge number
|
|
119
|
+
* (a deeply zoomed-out wall) or as garbage. Both extremes are refused here: a
|
|
120
|
+
* non-finite or negative half-extent becomes zero, and the whole reserve is
|
|
121
|
+
* capped well inside the world bounds so the packer can never be asked to keep
|
|
122
|
+
* a middle clear that leaves no paper for the cards.
|
|
123
|
+
*/
|
|
124
|
+
export declare function normalizeReserve(raw: CentreReserve): CentreReserve;
|
|
125
|
+
/**
|
|
126
|
+
* The nearest free spot for one new card, in world coordinates.
|
|
127
|
+
*
|
|
128
|
+
* Creating a note used to leave its placement to the Host, which stored `null`
|
|
129
|
+
* and let the Client derive a position from the note's index — and that derived
|
|
130
|
+
* position is a spiral that grows outward, so the tenth note could land a
|
|
131
|
+
* screen and a half away from where the user was looking. The card existed, but
|
|
132
|
+
* the user could not see it, which reads exactly like the capture silently
|
|
133
|
+
* failing.
|
|
134
|
+
*
|
|
135
|
+
* This searches outward from the middle instead: the spiral is walked from just
|
|
136
|
+
* outside the centrepiece's reserve, and the first candidate that clears every
|
|
137
|
+
* existing card (plus a gap) and stays out of the reserve is the answer. The
|
|
138
|
+
* result is therefore the gap nearest the centre of the wall, which is both
|
|
139
|
+
* where the user is looking and where the wall has room.
|
|
140
|
+
*
|
|
141
|
+
* Deterministic for the same inputs, so two windows creating at once cannot
|
|
142
|
+
* disagree about the free spot for the same wall.
|
|
143
|
+
*/
|
|
144
|
+
export declare function findFreeLayout(note: Note, existing: readonly Note[], options?: {
|
|
145
|
+
centreReserve?: CentreReserve | undefined;
|
|
146
|
+
}): NoteLayout;
|
|
147
|
+
/**
|
|
148
|
+
* The footprint one note occupies on the wall, as an axis-aligned box.
|
|
149
|
+
*
|
|
150
|
+
* Exposed because the Client needs it for two things the packer already knows:
|
|
151
|
+
* testing whether a card is inside the current viewport, and drawing the reserve
|
|
152
|
+
* it must not cover.
|
|
153
|
+
*/
|
|
154
|
+
export declare function noteBox(note: Note, index: number): Box;
|
|
155
|
+
/**
|
|
156
|
+
* The footprint a note occupies at a GIVEN layout.
|
|
157
|
+
*
|
|
158
|
+
* Split out from {@link noteBox} because the useful question is often about a
|
|
159
|
+
* layout that is not stored yet — a planned tidy position, or a candidate spot
|
|
160
|
+
* for a card that does not exist. `noteBox` answers "where is this note now";
|
|
161
|
+
* this answers "where would it be".
|
|
162
|
+
*/
|
|
163
|
+
/**
|
|
164
|
+
* Nudge a layout out of the centrepiece's reserved rectangle.
|
|
165
|
+
*
|
|
166
|
+
* The reserve is not only a packing rule: a user can drag a card straight over
|
|
167
|
+
* the quick-capture field, and a card parked there hides the wall's own controls
|
|
168
|
+
* behind itself. This returns the smallest translation that puts the card's
|
|
169
|
+
* footprint clear of the rectangle, which makes the reserve behave like a
|
|
170
|
+
* magnetic edge during a drag rather than a rule that is only enforced on tidy.
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
173
|
+
* Every way out of the reserve, shortest first.
|
|
174
|
+
*
|
|
175
|
+
* Exposed separately from {@link pushOutOfReserve} because the shortest escape is
|
|
176
|
+
* not always usable — it can land on a neighbour — so a caller that cares about
|
|
177
|
+
* collisions needs the whole ordered list, not just the first answer.
|
|
178
|
+
*/
|
|
179
|
+
export declare function escapesFromReserve(note: Note, layout: NoteLayout, reserve?: CentreReserve): NoteLayout[];
|
|
180
|
+
export declare function pushOutOfReserve(note: Note, layout: NoteLayout, reserve?: CentreReserve): NoteLayout;
|
|
181
|
+
export declare function footprintOf(note: Note, layout: NoteLayout): Box;
|