@n-uf/placement 26.11.55 → 26.11.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/index.d.ts +6 -39
- package/dist/index.js +0 -6
- package/dist/index.js.map +1 -1
- package/dist/side-zvoEwBLn.d.ts +10 -0
- package/dist/stack.d.ts +63 -12
- package/dist/stack.js +32 -21
- package/dist/stack.js.map +1 -1
- package/dist/tiling.d.ts +57 -57
- package/dist/tiling.js +32 -27
- package/dist/tiling.js.map +1 -1
- package/package.json +2 -1
package/dist/tiling.d.ts
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as Rect, S as Size, P as Point } from './geometry-L5gCoiZV.js';
|
|
2
|
+
import { S as Side, A as Axis } from './side-zvoEwBLn.js';
|
|
2
3
|
import { Target } from './index.js';
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* The order layouts: panes in order and an area in, a rect per pane out. Pure rect functions; a drop on one reorders
|
|
7
|
+
* (the dragged pane inserted at an index, see `orderTargets`).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* How a layout spaces its panes: `gap` px between neighbors (default 0), `ratio` the master's share (default 0.5),
|
|
12
|
+
* `handle` px a split's divider takes beside the gap (default 0; only a split tree reads it).
|
|
13
|
+
*/
|
|
14
|
+
interface TileOptions {
|
|
15
|
+
readonly gap?: number;
|
|
16
|
+
readonly ratio?: number;
|
|
17
|
+
readonly handle?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The master area: `count` panes (rounded, kept within 1..n; default 1) on `side` (default `"left"`). Left and right
|
|
21
|
+
* make it a column of panes stacked vertically; top and bottom a row of panes side by side. The one home of the
|
|
22
|
+
* concept: `masterStack` takes it in its options (`OrderOptions`), a split that lays out as master and stack in its
|
|
23
|
+
* `master` field.
|
|
24
|
+
*/
|
|
25
|
+
interface MasterOptions {
|
|
26
|
+
readonly count?: number;
|
|
27
|
+
readonly side?: Side;
|
|
28
|
+
}
|
|
29
|
+
/** What the order layouts take: `TileOptions` and the master area's `count` and `side` (`columns` and `grid` ignore them). */
|
|
30
|
+
type OrderOptions = TileOptions & MasterOptions;
|
|
31
|
+
/** An order layout: `masterStack`, `columns`, `grid`, or the app's own of the same shape. */
|
|
32
|
+
type OrderLayout = <K>(panes: readonly K[], area: Rect, options?: OrderOptions) => Map<K, Rect>;
|
|
33
|
+
/** The master's share in effect: clamped to 0.05..0.95; one that is not finite is 0.5. */
|
|
34
|
+
declare const masterRatio: (v: number | undefined) => number;
|
|
35
|
+
/** How many of `n` panes are masters for a requested `count`: rounded, within 1..n; NaN is 1. */
|
|
36
|
+
declare function masterCount(count: number | undefined, n: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* Master and stack: the first `count` panes are the masters, in an area on `side` that takes `ratio` of the room the
|
|
39
|
+
* gap leaves (clamped to 0.05..0.95; default 0.5); the rest are the stack, in the other area. Left and right make
|
|
40
|
+
* each area a column of panes stacked vertically; top and bottom a row of panes side by side. Right and bottom put
|
|
41
|
+
* the stack first in space. With no stack (n at most `count`) all the panes fill the area, stacked along the side's
|
|
42
|
+
* cross axis. Each area divides its length equally between its panes, the gap between them.
|
|
43
|
+
*/
|
|
44
|
+
declare function masterStack<K>(panes: readonly K[], area: Rect, options?: OrderOptions): Map<K, Rect>;
|
|
45
|
+
/** Equal columns, full height. */
|
|
46
|
+
declare function columns<K>(panes: readonly K[], area: Rect, options?: TileOptions): Map<K, Rect>;
|
|
47
|
+
/** A grid as square as the count allows; the last row's cells widen to fill it. */
|
|
48
|
+
declare function grid<K>(panes: readonly K[], area: Rect, options?: TileOptions): Map<K, Rect>;
|
|
49
|
+
|
|
4
50
|
/**
|
|
5
51
|
* A pane's drop regions: a center rectangle (a drop there swaps with the pane) and four side trapezoids (a drop there
|
|
6
52
|
* splits the pane on that side), formed by the diagonals from each pane corner to the nearest corner of the center.
|
|
@@ -11,10 +57,9 @@ import { Target } from './index.js';
|
|
|
11
57
|
* a boundary doesn't flicker. A region that takes no drop is the consumer's to answer with a null place.
|
|
12
58
|
*/
|
|
13
59
|
|
|
14
|
-
type
|
|
15
|
-
type PaneRegion = "center" | PaneSide;
|
|
60
|
+
type PaneRegion = "center" | Side;
|
|
16
61
|
/** The sides in their tie-break order: at an exact diagonal the first wins (a corner resolves to `top`). */
|
|
17
|
-
declare const PANE_SIDES: readonly
|
|
62
|
+
declare const PANE_SIDES: readonly Side[];
|
|
18
63
|
interface PaneRegionOptions {
|
|
19
64
|
/** The center rectangle's share of each pane axis (0.05 to 0.95); `centerX` / `centerY` override one axis. */
|
|
20
65
|
readonly center?: number;
|
|
@@ -53,51 +98,6 @@ declare function paneCenter(size: Size, options?: PaneRegionOptions): PaneCenter
|
|
|
53
98
|
*/
|
|
54
99
|
declare function paneRegion(pane: Rect, point: Point, previous?: PaneRegion | null, options?: PaneRegionOptions): PaneRegion;
|
|
55
100
|
|
|
56
|
-
/**
|
|
57
|
-
* The order layouts: panes in order and an area in, a rect per pane out. Pure rect functions; a drop on one reorders
|
|
58
|
-
* (the dragged pane inserted at an index, see `orderTargets`).
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* How a layout spaces its panes: `gap` px between neighbors (default 0), `ratio` the master's share (default 0.5),
|
|
63
|
-
* `handle` px a split's divider takes beside the gap (default 0; only a split tree reads it).
|
|
64
|
-
*/
|
|
65
|
-
interface TileOptions {
|
|
66
|
-
readonly gap?: number;
|
|
67
|
-
readonly ratio?: number;
|
|
68
|
-
readonly handle?: number;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* The master area: `count` panes (rounded, kept within 1..n; default 1) on `side` (default `"left"`). Left and right
|
|
72
|
-
* make it a column of panes stacked vertically; top and bottom a row of panes side by side. The one home of the
|
|
73
|
-
* concept: `masterStack` takes it in its options (`OrderOptions`), a split that lays out as master and stack in its
|
|
74
|
-
* `master` field.
|
|
75
|
-
*/
|
|
76
|
-
interface MasterOptions {
|
|
77
|
-
readonly count?: number;
|
|
78
|
-
readonly side?: PaneSide;
|
|
79
|
-
}
|
|
80
|
-
/** What the order layouts take: `TileOptions` and the master area's `count` and `side` (`columns` and `grid` ignore them). */
|
|
81
|
-
type OrderOptions = TileOptions & MasterOptions;
|
|
82
|
-
/** An order layout: `masterStack`, `columns`, `grid`, or the app's own of the same shape. */
|
|
83
|
-
type OrderLayout = <K>(panes: readonly K[], area: Rect, options?: OrderOptions) => Map<K, Rect>;
|
|
84
|
-
/** The master's share in effect: clamped to 0.05..0.95; one that is not finite is 0.5. */
|
|
85
|
-
declare const masterRatio: (v: number | undefined) => number;
|
|
86
|
-
/** How many of `n` panes are masters for a requested `count`: rounded, within 1..n; NaN is 1. */
|
|
87
|
-
declare function masterCount(count: number | undefined, n: number): number;
|
|
88
|
-
/**
|
|
89
|
-
* Master and stack: the first `count` panes are the masters, in an area on `side` that takes `ratio` of the room the
|
|
90
|
-
* gap leaves (clamped to 0.05..0.95; default 0.5); the rest are the stack, in the other area. Left and right make
|
|
91
|
-
* each area a column of panes stacked vertically; top and bottom a row of panes side by side. Right and bottom put
|
|
92
|
-
* the stack first in space. With no stack (n at most `count`) all the panes fill the area, stacked along the side's
|
|
93
|
-
* cross axis. Each area divides its length equally between its panes, the gap between them.
|
|
94
|
-
*/
|
|
95
|
-
declare function masterStack<K>(panes: readonly K[], area: Rect, options?: OrderOptions): Map<K, Rect>;
|
|
96
|
-
/** Equal columns, full height. */
|
|
97
|
-
declare function columns<K>(panes: readonly K[], area: Rect, options?: TileOptions): Map<K, Rect>;
|
|
98
|
-
/** A grid as square as the count allows; the last row's cells widen to fill it. */
|
|
99
|
-
declare function grid<K>(panes: readonly K[], area: Rect, options?: TileOptions): Map<K, Rect>;
|
|
100
|
-
|
|
101
101
|
/**
|
|
102
102
|
* The split tree: how panes divide an area. A node is a pane, or a split of its rect in two (`a` then `b`). A split
|
|
103
103
|
* with an `axis` divides along it (`"x"`: `a` left of `b`; `"y"`: `a` above `b`) at `ratio`; one without divides
|
|
@@ -115,7 +115,7 @@ type Split<K> = {
|
|
|
115
115
|
} | {
|
|
116
116
|
readonly a: Split<K>;
|
|
117
117
|
readonly b: Split<K>;
|
|
118
|
-
readonly axis?:
|
|
118
|
+
readonly axis?: Axis;
|
|
119
119
|
readonly ratio?: number;
|
|
120
120
|
readonly gap?: number;
|
|
121
121
|
readonly id?: string;
|
|
@@ -128,7 +128,7 @@ declare const panesOf: <K>(tree: Split<K> | null) => K[];
|
|
|
128
128
|
* means the same whatever the pane's shape; no side splits along the longer side, `pane` second (dwindle). An empty
|
|
129
129
|
* tree becomes `pane` alone; an `at` that isn't in the tree (or null) splits the whole tree, so no pane is lost.
|
|
130
130
|
*/
|
|
131
|
-
declare function splitPane<K>(tree: Split<K> | null, at: K | null, pane: K, side?:
|
|
131
|
+
declare function splitPane<K>(tree: Split<K> | null, at: K | null, pane: K, side?: Side): Split<K>;
|
|
132
132
|
/** `tree` without `pane`: its sibling takes their parent's place. */
|
|
133
133
|
declare function removePane<K>(tree: Split<K> | null, pane: K): Split<K> | null;
|
|
134
134
|
/** `tree` with panes `x` and `y` in each other's place; unchanged unless both are in it. */
|
|
@@ -177,9 +177,9 @@ interface MinLength {
|
|
|
177
177
|
* chooses one for a pane.
|
|
178
178
|
*/
|
|
179
179
|
interface SplitOptions<K> extends TileOptions {
|
|
180
|
-
readonly fixed?: (child: Split<K>, axis:
|
|
181
|
-
readonly fixedAcross?: (child: Split<K>, axis:
|
|
182
|
-
readonly floor?: (child: Split<K>, axis:
|
|
180
|
+
readonly fixed?: (child: Split<K>, axis: Axis) => FixedLength | undefined;
|
|
181
|
+
readonly fixedAcross?: (child: Split<K>, axis: Axis) => number | undefined;
|
|
182
|
+
readonly floor?: (child: Split<K>, axis: Axis, split: Split<K>) => MinLength;
|
|
183
183
|
}
|
|
184
184
|
/** A laid-out split: the box it divides, its axis and ratio in effect, and the strip between its two sides. */
|
|
185
185
|
interface SplitGeometry {
|
|
@@ -256,11 +256,11 @@ interface SplitRoomOptions {
|
|
|
256
256
|
* gutter (`gap` plus `handle`), across it `min`. The rect is the pane's as the host measures it, where it will be
|
|
257
257
|
* when the dragged pane is lifted out. `canDropOnPane`'s first rule, for a side.
|
|
258
258
|
*/
|
|
259
|
-
declare function canSplitPane(target: Rect, side:
|
|
259
|
+
declare function canSplitPane(target: Rect, side: Side, options: SplitRoomOptions): DropVerdict;
|
|
260
260
|
/** What `dropFits` reads: the `min` (as in `DropOptions`) and the `side` of `at` the drop is on, for the reason. */
|
|
261
261
|
interface DropFitsOptions {
|
|
262
262
|
readonly min: number;
|
|
263
|
-
readonly side:
|
|
263
|
+
readonly side: Side;
|
|
264
264
|
}
|
|
265
265
|
/**
|
|
266
266
|
* The fit rule: in `projected`, the rect of every pane in the layout the drop makes (the host's own projection of
|
|
@@ -332,4 +332,4 @@ type Direction = "left" | "right" | "up" | "down";
|
|
|
332
332
|
*/
|
|
333
333
|
declare function neighbor<K>(rects: ReadonlyMap<K, Rect>, from: K, direction: Direction): K | null;
|
|
334
334
|
|
|
335
|
-
export { type Direction, type DropFitsOptions, type DropOptions, type DropVerdict, type FixedLength, type MasterOptions, type MinLength, type OrderLayout, type OrderOptions, type OrderTarget, PANE_REGION_DEFAULTS, PANE_SIDES, type PaneCenter, type PaneRegion, type PaneRegionOptions, type
|
|
335
|
+
export { type Direction, type DropFitsOptions, type DropOptions, type DropVerdict, type FixedLength, type MasterOptions, type MinLength, type OrderLayout, type OrderOptions, type OrderTarget, PANE_REGION_DEFAULTS, PANE_SIDES, type PaneCenter, type PaneRegion, type PaneRegionOptions, type PaneTarget, type PaneTargetsOptions, Rect, type Split, type SplitGeometry, type SplitLayout, type SplitOptions, type SplitRoomOptions, type TileOptions, canDropOnPane, canSplitPane, columns, dropFits, dropOnPane, giveWay, grid, layoutSplit, layoutSplitTree, masterCount, masterRatio, masterStack, neighbor, orderTargets, paneCenter, paneRegion, paneTargets, panesOf, removePane, splitFromOrder, splitPane, swapPanes };
|
package/dist/tiling.js
CHANGED
|
@@ -127,12 +127,15 @@ var unit = (v) => v === void 0 || !Number.isFinite(v) ? 0.5 : Math.min(1, Math.m
|
|
|
127
127
|
var usable = (v) => v !== void 0 && Number.isFinite(v) && v > 0;
|
|
128
128
|
var NET = [0.05, 0.95];
|
|
129
129
|
function layoutSplit(tree, area, options = {}) {
|
|
130
|
-
|
|
130
|
+
const ctx = { options, gap: px(options.gap), handle: px(options.handle), panes: /* @__PURE__ */ new Map(), splits: null };
|
|
131
|
+
lay(tree, area, ctx, false);
|
|
132
|
+
return ctx.panes;
|
|
131
133
|
}
|
|
132
134
|
function layoutSplitTree(tree, area, options = {}) {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
const splits = /* @__PURE__ */ new Map();
|
|
136
|
+
const ctx = { options, gap: px(options.gap), handle: px(options.handle), panes: /* @__PURE__ */ new Map(), splits };
|
|
137
|
+
lay(tree, area, ctx, false);
|
|
138
|
+
return { panes: ctx.panes, splits };
|
|
136
139
|
}
|
|
137
140
|
function strip(box, x, mid, gutter) {
|
|
138
141
|
const lo = Math.max(x ? box.x : box.y, mid - gutter / 2);
|
|
@@ -146,28 +149,28 @@ function clampByMin(ratio, extent, gutter, minA, minB, net) {
|
|
|
146
149
|
const boundedMax = Math.max(Math.min(1 - minB / room, net[1]), net[0]);
|
|
147
150
|
return boundedMin > boundedMax ? 0.5 : Math.min(Math.max(ratio, boundedMin), boundedMax);
|
|
148
151
|
}
|
|
149
|
-
function layMaster(tree, master, area, ctx) {
|
|
152
|
+
function layMaster(tree, master, area, ctx, owned) {
|
|
150
153
|
const gap = tree.gap === void 0 ? ctx.gap : px(tree.gap);
|
|
151
154
|
const panes = panesOf(tree);
|
|
152
155
|
const ratio = masterRatio(tree.ratio);
|
|
153
156
|
const side = master.side ?? "left";
|
|
154
157
|
for (const [pane, r] of masterStack(panes, area, { gap, ratio, count: master.count, side })) ctx.panes.set(pane, r);
|
|
155
|
-
if (tree.id === void 0) return;
|
|
158
|
+
if (tree.id === void 0 || ctx.splits === null) return;
|
|
156
159
|
const x = side === "left" || side === "right";
|
|
157
160
|
const stacked = panes.length > masterCount(master.count, panes.length);
|
|
158
161
|
const room = Math.max(0, (x ? area.width : area.height) - gap);
|
|
159
162
|
const first = side === "left" || side === "top" ? room * ratio : room * (1 - ratio);
|
|
160
163
|
const mid = (x ? area.x : area.y) + first + gap / 2;
|
|
161
|
-
ctx.splits.set(tree.id, { rect: { ...area }, axis: x ? "x" : "y", ratio, divider: stacked ? strip(area, x, mid, gap) : null });
|
|
164
|
+
ctx.splits.set(tree.id, { rect: owned ? area : { ...area }, axis: x ? "x" : "y", ratio, divider: stacked ? strip(area, x, mid, gap) : null });
|
|
162
165
|
}
|
|
163
|
-
function lay(tree, area, ctx) {
|
|
166
|
+
function lay(tree, area, ctx, owned) {
|
|
164
167
|
if (!tree) return;
|
|
165
168
|
if ("pane" in tree) {
|
|
166
|
-
ctx.panes.set(tree.pane, { ...area });
|
|
169
|
+
ctx.panes.set(tree.pane, owned ? area : { ...area });
|
|
167
170
|
return;
|
|
168
171
|
}
|
|
169
172
|
if (tree.master) {
|
|
170
|
-
layMaster(tree, tree.master, area, ctx);
|
|
173
|
+
layMaster(tree, tree.master, area, ctx, owned);
|
|
171
174
|
return;
|
|
172
175
|
}
|
|
173
176
|
const axis = tree.axis ?? (area.width >= area.height ? "x" : "y");
|
|
@@ -177,28 +180,27 @@ function lay(tree, area, ctx) {
|
|
|
177
180
|
const cross = x ? area.height : area.width;
|
|
178
181
|
const gutter = (tree.gap === void 0 ? ctx.gap : px(tree.gap)) + ctx.handle;
|
|
179
182
|
const { fixed, fixedAcross, floor } = ctx.options;
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const acrossA = across(tree.a);
|
|
185
|
-
const acrossB = across(tree.b);
|
|
183
|
+
const lenA = fixedAcross?.(tree.a, axis);
|
|
184
|
+
const lenB = fixedAcross?.(tree.b, axis);
|
|
185
|
+
const acrossA = usable(lenA) ? lenA : cross;
|
|
186
|
+
const acrossB = usable(lenB) ? lenB : cross;
|
|
186
187
|
const fixedA = fixed?.(tree.a, axis);
|
|
187
188
|
const fixedB = fixed?.(tree.b, axis);
|
|
188
189
|
let lengthA;
|
|
189
190
|
let lengthB;
|
|
190
191
|
let startB;
|
|
191
192
|
let ratio = unit(tree.ratio);
|
|
192
|
-
let
|
|
193
|
-
const holds = fixedA && fixedB && fixedA.keep && fixedB.keep && usable(fixedA.length) && usable(fixedB.length) ? [fixedA.length, fixedB.length] : null;
|
|
193
|
+
let ruled = false;
|
|
194
194
|
const lead = fixedA ?? fixedB;
|
|
195
|
-
if (
|
|
196
|
-
|
|
195
|
+
if (fixedA && fixedB && fixedA.keep && fixedB.keep && usable(fixedA.length) && usable(fixedB.length)) {
|
|
196
|
+
lengthA = fixedA.length;
|
|
197
|
+
lengthB = fixedB.length;
|
|
197
198
|
startB = origin + lengthA + gutter;
|
|
198
199
|
ratio = extent > 0 ? (lengthA + gutter / 2) / extent : ratio;
|
|
199
200
|
} else if (lead && usable(lead.length) && lead.length + gutter < extent) {
|
|
200
201
|
const rest = Math.max(0, extent - lead.length - gutter);
|
|
201
|
-
|
|
202
|
+
lengthA = lead === fixedA ? lead.length : rest;
|
|
203
|
+
lengthB = lead === fixedA ? rest : lead.length;
|
|
202
204
|
startB = origin + lengthA + gutter;
|
|
203
205
|
ratio = (lengthA + gutter / 2) / extent;
|
|
204
206
|
} else {
|
|
@@ -211,15 +213,18 @@ function lay(tree, area, ctx) {
|
|
|
211
213
|
lengthA = Math.max(0, extent * ratio - gutter / 2);
|
|
212
214
|
lengthB = Math.max(0, extent * (1 - ratio) - gutter / 2);
|
|
213
215
|
startB = origin + extent * ratio + gutter / 2;
|
|
214
|
-
|
|
216
|
+
ruled = true;
|
|
217
|
+
}
|
|
218
|
+
if (tree.id !== void 0 && ctx.splits !== null) {
|
|
219
|
+
const divider = ruled ? strip(area, x, origin + extent * ratio, gutter) : null;
|
|
220
|
+
ctx.splits.set(tree.id, { rect: owned ? area : { ...area }, axis, ratio, divider });
|
|
215
221
|
}
|
|
216
|
-
if (tree.id !== void 0) ctx.splits.set(tree.id, { rect: { ...area }, axis, ratio, divider });
|
|
217
222
|
if (x) {
|
|
218
|
-
lay(tree.a, { x: area.x, y: area.y, width: lengthA, height: acrossA }, ctx);
|
|
219
|
-
lay(tree.b, { x: startB, y: area.y, width: lengthB, height: acrossB }, ctx);
|
|
223
|
+
lay(tree.a, { x: area.x, y: area.y, width: lengthA, height: acrossA }, ctx, true);
|
|
224
|
+
lay(tree.b, { x: startB, y: area.y, width: lengthB, height: acrossB }, ctx, true);
|
|
220
225
|
} else {
|
|
221
|
-
lay(tree.a, { x: area.x, y: area.y, width: acrossA, height: lengthA }, ctx);
|
|
222
|
-
lay(tree.b, { x: area.x, y: startB, width: acrossB, height: lengthB }, ctx);
|
|
226
|
+
lay(tree.a, { x: area.x, y: area.y, width: acrossA, height: lengthA }, ctx, true);
|
|
227
|
+
lay(tree.b, { x: area.x, y: startB, width: acrossB, height: lengthB }, ctx, true);
|
|
223
228
|
}
|
|
224
229
|
}
|
|
225
230
|
|
package/dist/tiling.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tiling/order.ts","../src/tiling/split.ts","../src/tiling/layout.ts","../src/tiling/drop.ts","../src/tiling/regions.ts","../src/tiling/targets.ts","../src/tiling/give-way.ts","../src/tiling/neighbor.ts"],"sourcesContent":["/**\n * The order layouts: panes in order and an area in, a rect per pane out. Pure rect functions; a drop on one reorders\n * (the dragged pane inserted at an index, see `orderTargets`).\n */\nimport type { Rect } from \"../geometry\";\nimport type { PaneSide } from \"./regions\";\n\n/**\n * How a layout spaces its panes: `gap` px between neighbors (default 0), `ratio` the master's share (default 0.5),\n * `handle` px a split's divider takes beside the gap (default 0; only a split tree reads it).\n */\nexport interface TileOptions {\n readonly gap?: number;\n readonly ratio?: number;\n readonly handle?: number;\n}\n\n/**\n * The master area: `count` panes (rounded, kept within 1..n; default 1) on `side` (default `\"left\"`). Left and right\n * make it a column of panes stacked vertically; top and bottom a row of panes side by side. The one home of the\n * concept: `masterStack` takes it in its options (`OrderOptions`), a split that lays out as master and stack in its\n * `master` field.\n */\nexport interface MasterOptions {\n readonly count?: number;\n readonly side?: PaneSide;\n}\n\n/** What the order layouts take: `TileOptions` and the master area's `count` and `side` (`columns` and `grid` ignore them). */\nexport type OrderOptions = TileOptions & MasterOptions;\n\n/** An order layout: `masterStack`, `columns`, `grid`, or the app's own of the same shape. */\nexport type OrderLayout = <K>(panes: readonly K[], area: Rect, options?: OrderOptions) => Map<K, Rect>;\n\n/** The master's share in effect: clamped to 0.05..0.95; one that is not finite is 0.5. */\nexport const masterRatio = (v: number | undefined): number => (v === undefined || !Number.isFinite(v) ? 0.5 : Math.min(0.95, Math.max(0.05, v)));\n\n/** How many of `n` panes are masters for a requested `count`: rounded, within 1..n; NaN is 1. */\nexport function masterCount(count: number | undefined, n: number): number {\n const c = Math.round(count ?? 1);\n return Math.min(Math.max(Number.isNaN(c) ? 1 : c, 1), Math.max(n, 1));\n}\n\n/** `items` side by side or one above the other in equal shares of the box, `gap` between them. */\nfunction divide<K>(items: readonly K[], x: number, y: number, width: number, height: number, vertical: boolean, gap: number, out: Map<K, Rect>): void {\n const n = items.length;\n const total = gap * (n - 1);\n if (vertical) {\n const each = Math.max(0, (height - total) / n);\n items.forEach((pane, i) => out.set(pane, { x, y: y + i * (each + gap), width, height: each }));\n } else {\n const each = Math.max(0, (width - total) / n);\n items.forEach((pane, i) => out.set(pane, { x: x + i * (each + gap), y, width: each, height }));\n }\n}\n\n/**\n * Master and stack: the first `count` panes are the masters, in an area on `side` that takes `ratio` of the room the\n * gap leaves (clamped to 0.05..0.95; default 0.5); the rest are the stack, in the other area. Left and right make\n * each area a column of panes stacked vertically; top and bottom a row of panes side by side. Right and bottom put\n * the stack first in space. With no stack (n at most `count`) all the panes fill the area, stacked along the side's\n * cross axis. Each area divides its length equally between its panes, the gap between them.\n */\nexport function masterStack<K>(panes: readonly K[], area: Rect, options: OrderOptions = {}): Map<K, Rect> {\n const gap = options.gap !== undefined && Number.isFinite(options.gap) && options.gap > 0 ? options.gap : 0;\n const out = new Map<K, Rect>();\n if (panes.length === 0) return out;\n const side = options.side ?? \"left\";\n const ratio = masterRatio(options.ratio);\n const count = masterCount(options.count, panes.length);\n const masters = panes.slice(0, count);\n const stack = panes.slice(count);\n const column = side === \"left\" || side === \"right\";\n if (stack.length === 0) {\n divide(masters, area.x, area.y, area.width, area.height, column, gap, out);\n } else if (column) {\n const room = Math.max(0, area.width - gap);\n const masterWidth = room * ratio;\n const stackWidth = room * (1 - ratio);\n const masterX = side === \"left\" ? area.x : area.x + stackWidth + gap;\n const stackX = side === \"left\" ? area.x + masterWidth + gap : area.x;\n divide(masters, masterX, area.y, masterWidth, area.height, true, gap, out);\n divide(stack, stackX, area.y, stackWidth, area.height, true, gap, out);\n } else {\n const room = Math.max(0, area.height - gap);\n const masterHeight = room * ratio;\n const stackHeight = room * (1 - ratio);\n const masterY = side === \"top\" ? area.y : area.y + stackHeight + gap;\n const stackY = side === \"top\" ? area.y + masterHeight + gap : area.y;\n divide(masters, area.x, masterY, area.width, masterHeight, false, gap, out);\n divide(stack, area.x, stackY, area.width, stackHeight, false, gap, out);\n }\n return out;\n}\n\n/** Equal columns, full height. */\nexport function columns<K>(panes: readonly K[], area: Rect, options: TileOptions = {}): Map<K, Rect> {\n const gap = options.gap ?? 0;\n const out = new Map<K, Rect>();\n const n = panes.length;\n const w = (area.width - gap * (n - 1)) / Math.max(1, n);\n panes.forEach((id, i) => out.set(id, { x: area.x + i * (w + gap), y: area.y, width: w, height: area.height }));\n return out;\n}\n\n/** A grid as square as the count allows; the last row's cells widen to fill it. */\nexport function grid<K>(panes: readonly K[], area: Rect, options: TileOptions = {}): Map<K, Rect> {\n const gap = options.gap ?? 0;\n const out = new Map<K, Rect>();\n const n = panes.length;\n if (n === 0) return out;\n const cols = Math.ceil(Math.sqrt(n));\n const rows = Math.ceil(n / cols);\n const h = (area.height - gap * (rows - 1)) / rows;\n panes.forEach((id, i) => {\n const row = Math.floor(i / cols);\n const inRow = row === rows - 1 ? n - cols * (rows - 1) : cols;\n const col = i - row * cols;\n const w = (area.width - gap * (inRow - 1)) / inRow;\n out.set(id, { x: area.x + col * (w + gap), y: area.y + row * (h + gap), width: w, height: h });\n });\n return out;\n}\n","/**\n * The split tree: how panes divide an area. A node is a pane, or a split of its rect in two (`a` then `b`). A split\n * with an `axis` divides along it (`\"x\"`: `a` left of `b`; `\"y\"`: `a` above `b`) at `ratio`; one without divides\n * along the rect's longer side in halves, which is dwindle (split along the longer side). Pure: trees in, trees out.\n */\nimport type { MasterOptions } from \"./order\";\nimport type { PaneRegion, PaneSide } from \"./regions\";\n\n/**\n * A pane, or a split of its rect in two, `a` then `b`. A split takes its `axis` and its `ratio` (the first side's\n * share); `gap` replaces the layout's gap for this split (the handle stays global); `id` names the split so\n * `layoutSplitTree` reports its geometry. With `master`, the split lays its subtree out flat: its panes, in order,\n * as master and stack (`masterStack`) in its rect, by its `ratio` and gap; the splits under it are not laid out.\n */\nexport type Split<K> =\n | { readonly pane: K }\n | {\n readonly a: Split<K>;\n readonly b: Split<K>;\n readonly axis?: \"x\" | \"y\";\n readonly ratio?: number;\n readonly gap?: number;\n readonly id?: string;\n readonly master?: MasterOptions;\n };\n\n/** The panes of `tree` in order (`a` before `b`). */\nexport const panesOf = <K>(tree: Split<K> | null): K[] => (!tree ? [] : \"pane\" in tree ? [tree.pane] : [...panesOf(tree.a), ...panesOf(tree.b)]);\n\nconst has = <K>(tree: Split<K> | null, pane: K): boolean => panesOf(tree).includes(pane);\n\n/** `tree` with each pane node `fn` gives a replacement for replaced. */\nfunction mapPanes<K>(tree: Split<K>, fn: (pane: K) => Split<K>): Split<K> {\n if (\"pane\" in tree) return fn(tree.pane);\n return { ...tree, a: mapPanes(tree.a, fn), b: mapPanes(tree.b, fn) };\n}\n\n/**\n * `tree` with pane `at` split in two, `pane` on its `side`. A side writes an explicit axis and ratio 0.5, so the side\n * means the same whatever the pane's shape; no side splits along the longer side, `pane` second (dwindle). An empty\n * tree becomes `pane` alone; an `at` that isn't in the tree (or null) splits the whole tree, so no pane is lost.\n */\nexport function splitPane<K>(tree: Split<K> | null, at: K | null, pane: K, side?: PaneSide): Split<K> {\n const fresh: Split<K> = { pane };\n const split = (node: Split<K>): Split<K> => {\n if (!side) return { a: node, b: fresh };\n const axis = side === \"left\" || side === \"right\" ? \"x\" : \"y\";\n const first = side === \"left\" || side === \"top\";\n return first ? { a: fresh, b: node, axis, ratio: 0.5 } : { a: node, b: fresh, axis, ratio: 0.5 };\n };\n if (!tree) return fresh;\n if (at === null || !has(tree, at)) return split(tree);\n return mapPanes(tree, (p) => (p === at ? split({ pane: p }) : { pane: p }));\n}\n\n/** `tree` without `pane`: its sibling takes their parent's place. */\nexport function removePane<K>(tree: Split<K> | null, pane: K): Split<K> | null {\n if (!tree) return null;\n if (\"pane\" in tree) return tree.pane === pane ? null : tree;\n const a = removePane(tree.a, pane);\n const b = removePane(tree.b, pane);\n return a && b ? { ...tree, a, b } : (a ?? b);\n}\n\n/** `tree` with panes `x` and `y` in each other's place; unchanged unless both are in it. */\nexport function swapPanes<K>(tree: Split<K> | null, x: K, y: K): Split<K> | null {\n if (!tree || !has(tree, x) || !has(tree, y)) return tree;\n return mapPanes(tree, (p) => ({ pane: p === x ? y : p === y ? x : p }));\n}\n\n/** A dwindle tree for `panes`: each one splits the one before it along the longer side. */\nexport function splitFromOrder<K>(panes: readonly K[]): Split<K> | null {\n let t: Split<K> | null = null;\n panes.forEach((id, i) => {\n t = splitPane(t, i > 0 ? panes[i - 1]! : null, id);\n });\n return t;\n}\n\n/**\n * A drop of `dragged` on pane `at`'s `region`. A side splits `at` on that side (`dragged` taken out of its old place\n * first). The center swaps the two when `dragged` is in the tree; a pane from outside takes `at`'s place, with `at`\n * split off after it along the longer side. An `at` that isn't in the tree (or is `dragged` itself) changes nothing\n * but adding `dragged` when it is missing, as `splitPane` does. The set of panes is kept: the tree's, plus `dragged`.\n */\nexport function dropOnPane<K>(tree: Split<K> | null, dragged: K, at: K, region: PaneRegion): Split<K> {\n if (!tree) return { pane: dragged };\n if (dragged === at || !has(tree, at)) return has(tree, dragged) ? tree : splitPane(tree, null, dragged);\n if (region !== \"center\") return splitPane(removePane(tree, dragged), at, dragged, region);\n if (has(tree, dragged)) return swapPanes(tree, dragged, at)!;\n return mapPanes(tree, (p) => (p === at ? { a: { pane: dragged }, b: { pane: p } } : { pane: p }));\n}\n","/**\n * The split tree laid out: the rect of every pane of a `Split` tree in an area, and the geometry of the splits that\n * have an id. See docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\nimport { masterCount, masterRatio, masterStack, type MasterOptions, type TileOptions } from \"./order\";\nimport { panesOf, type Split } from \"./split\";\n\n/** A px option: a finite number, never below 0 (anything else is 0). */\nconst px = (v: number | undefined): number => (v !== undefined && Number.isFinite(v) && v > 0 ? v : 0);\n\n/** A ratio: clamped to 0..1; one that is not finite is 0.5. */\nconst unit = (v: number | undefined): number => (v === undefined || !Number.isFinite(v) ? 0.5 : Math.min(1, Math.max(0, v)));\n\n/** A usable length: finite and above 0. */\nconst usable = (v: number | undefined): v is number => v !== undefined && Number.isFinite(v) && v > 0;\n\n/** The least a ratio may be in a split with a floor: within 5 and 95 % unless a side takes the net off. */\nconst NET: readonly [number, number] = [0.05, 0.95];\n\n/** A split child's fixed length along its split. `keep` marks one that holds its length even beside another. */\nexport interface FixedLength {\n readonly length: number;\n readonly keep?: boolean;\n}\n\n/** A split child's least length along its split. `net` (default true) keeps the split's ratio within 5..95 %. */\nexport interface MinLength {\n readonly min: number;\n readonly net?: boolean;\n}\n\n/**\n * What a split tree's layout reads of its host, each per split, of the split's two direct children.\n *\n * - `fixed(child, axis)`: the child's fixed length along the split, if it has one. The first child that reports one\n * decides: it takes its length when the length is above 0 and, with the gutter, less than the extent, and the other\n * side fills the rest (the gutter between). Otherwise, or with a length that does not fit, the split falls back to\n * its ratio, and the other child's length is not read. When both report a length with `keep`, each keeps its own,\n * in order, and the room left over stays empty; if the two (and the gutter) do not fit the extent, the second runs\n * past the end. A split a fixed length decides has no divider and no floor.\n * - `fixedAcross(child, axis)`: the child's fixed length across the split; the child takes it, when positive and\n * finite, from the start of the cross axis instead of the whole cross extent. It is not checked against the cross\n * extent: a length larger than the cross extent makes a pane larger than the split's box.\n * - `floor(child, axis, split)`: the child's least length along the split. The ratio is clamped so each side keeps\n * its floor of the room less the gutter, within the net (5..95 %) unless either side says `net: false`; where the\n * two floors cannot both fit, the ratio is 0.5. With no `floor`, the ratio is only clamped to 0..1. `giveWay` is\n * the other policy of the same minimum: it floats the newest pane instead of squeezing the ratio, and a host\n * chooses one for a pane.\n */\nexport interface SplitOptions<K> extends TileOptions {\n readonly fixed?: (child: Split<K>, axis: \"x\" | \"y\") => FixedLength | undefined;\n readonly fixedAcross?: (child: Split<K>, axis: \"x\" | \"y\") => number | undefined;\n readonly floor?: (child: Split<K>, axis: \"x\" | \"y\", split: Split<K>) => MinLength;\n}\n\n/** A laid-out split: the box it divides, its axis and ratio in effect, and the strip between its two sides. */\nexport interface SplitGeometry {\n readonly rect: Rect;\n readonly axis: \"x\" | \"y\";\n /**\n * The first side's share in effect: the middle of the gutter lies at the box's start plus its extent times this\n * (for a fixed-length child, the middle of the gutter after the first side over the extent). For a master split\n * it is the master area's share (clamped to 0.05..0.95) of the room less the gap, measured from the master's own\n * side: with the master on the right, ratio 0.3 in 1000 with a gap of 10, the divider lies at 693..703.\n */\n readonly ratio: number;\n /** The gutter between the two sides, as a rect inside `rect`; null where the split has none. */\n readonly divider: Rect | null;\n}\n\n/** A tree laid out: every pane's rect, and the geometry of each split that has an `id`. */\nexport interface SplitLayout<K> {\n readonly panes: Map<K, Rect>;\n readonly splits: Map<string, SplitGeometry>;\n}\n\ninterface Ctx<K> {\n readonly options: SplitOptions<K>;\n readonly gap: number;\n readonly handle: number;\n readonly panes: Map<K, Rect>;\n readonly splits: Map<string, SplitGeometry>;\n}\n\n/**\n * The rect of every pane of `tree` in `area`. Each split's gutter is its gap (its own `gap`, else `options.gap`) plus\n * `options.handle`. A split's `ratio` is clamped to 0..1 (one that is not finite is 0.5), and the middle of the gutter\n * sits at `extent * ratio`: the first side is `extent * ratio` less half the gutter, the second starts half a gutter\n * past it and is the rest less half the gutter. No size is ever negative: a side too short for half the gutter is 0\n * along the axis, and the second side of a split with no room may then start up to half a gutter past the rect's end.\n * At ratio 0.5 both sides are equal. `options.floor`, `fixed` and `fixedAcross` (see `SplitOptions`) read the host's\n * minimums and fixed lengths per split. A negative or non-finite `gap` or `handle` is 0. The area is taken as given:\n * with a negative width or height every length along that axis is 0 and a pane's size across it is copied as it\n * is, so pass an area with no negative side.\n */\nexport function layoutSplit<K>(tree: Split<K> | null, area: Rect, options: SplitOptions<K> = {}): Map<K, Rect> {\n return layoutSplitTree(tree, area, options).panes;\n}\n\n/**\n * `layoutSplit` and the geometry of every split that has an `id` (a repeated id keeps the one laid out last: a split under another, or a later one beside it): the box it divides,\n * its axis and ratio in effect (after the floors), and its divider, the gutter strip between its two sides. A split\n * that lays out as master and stack is reported too, its nested splits are not.\n */\nexport function layoutSplitTree<K>(tree: Split<K> | null, area: Rect, options: SplitOptions<K> = {}): SplitLayout<K> {\n const ctx: Ctx<K> = { options, gap: px(options.gap), handle: px(options.handle), panes: new Map(), splits: new Map() };\n lay(tree, area, ctx);\n return { panes: ctx.panes, splits: ctx.splits };\n}\n\n/** The strip `gutter` wide centered on `mid` across `box`, clipped to it. */\nfunction strip(box: Rect, x: boolean, mid: number, gutter: number): Rect {\n const lo = Math.max(x ? box.x : box.y, mid - gutter / 2);\n const hi = Math.min(x ? box.x + box.width : box.y + box.height, mid + gutter / 2);\n const length = Math.max(0, hi - lo);\n return x ? { x: lo, y: box.y, width: length, height: box.height } : { x: box.x, y: lo, width: box.width, height: length };\n}\n\n/**\n * `ratio` kept so the first side has `minA` and the second `minB` of the room less the gutter (at least 1 px of room),\n * within `net`; 0.5 where the two cannot both fit.\n */\nfunction clampByMin(ratio: number, extent: number, gutter: number, minA: number, minB: number, net: readonly [number, number]): number {\n const room = Math.max(extent - gutter, 1);\n const boundedMin = Math.min(Math.max(minA / room, net[0]), net[1]);\n const boundedMax = Math.max(Math.min(1 - minB / room, net[1]), net[0]);\n return boundedMin > boundedMax ? 0.5 : Math.min(Math.max(ratio, boundedMin), boundedMax);\n}\n\n/** A split that lays its panes out flat as master and stack: the gap only, never the handle. */\nfunction layMaster<K>(tree: Extract<Split<K>, { a: unknown }>, master: MasterOptions, area: Rect, ctx: Ctx<K>): void {\n const gap = tree.gap === undefined ? ctx.gap : px(tree.gap);\n const panes = panesOf(tree);\n const ratio = masterRatio(tree.ratio);\n const side = master.side ?? \"left\";\n // Only the count and side come from `master`: the ratio and gap are the split's own.\n for (const [pane, r] of masterStack(panes, area, { gap, ratio, count: master.count, side })) ctx.panes.set(pane, r);\n if (tree.id === undefined) return;\n const x = side === \"left\" || side === \"right\";\n const stacked = panes.length > masterCount(master.count, panes.length);\n const room = Math.max(0, (x ? area.width : area.height) - gap);\n const first = side === \"left\" || side === \"top\" ? room * ratio : room * (1 - ratio);\n const mid = (x ? area.x : area.y) + first + gap / 2;\n ctx.splits.set(tree.id, { rect: { ...area }, axis: x ? \"x\" : \"y\", ratio, divider: stacked ? strip(area, x, mid, gap) : null });\n}\n\nfunction lay<K>(tree: Split<K> | null, area: Rect, ctx: Ctx<K>): void {\n if (!tree) return;\n if (\"pane\" in tree) {\n ctx.panes.set(tree.pane, { ...area });\n return;\n }\n if (tree.master) {\n layMaster(tree, tree.master, area, ctx);\n return;\n }\n const axis = tree.axis ?? (area.width >= area.height ? \"x\" : \"y\");\n const x = axis === \"x\";\n const extent = x ? area.width : area.height;\n const origin = x ? area.x : area.y;\n const cross = x ? area.height : area.width;\n const gutter = (tree.gap === undefined ? ctx.gap : px(tree.gap)) + ctx.handle;\n const { fixed, fixedAcross, floor } = ctx.options;\n // Across the split a child with a fixed length takes it from the start; the others take the whole cross extent.\n const across = (child: Split<K>): number => {\n const length = fixedAcross?.(child, axis);\n return usable(length) ? length : cross;\n };\n const acrossA = across(tree.a);\n const acrossB = across(tree.b);\n const fixedA = fixed?.(tree.a, axis);\n const fixedB = fixed?.(tree.b, axis);\n\n // The lengths of the two sides along the split, where the second starts, the ratio in effect and the divider.\n let lengthA: number;\n let lengthB: number;\n let startB: number;\n let ratio = unit(tree.ratio);\n let divider: Rect | null = null;\n const holds = fixedA && fixedB && fixedA.keep && fixedB.keep && usable(fixedA.length) && usable(fixedB.length) ? [fixedA.length, fixedB.length] : null;\n const lead = fixedA ?? fixedB;\n if (holds) {\n [lengthA, lengthB] = holds as [number, number];\n startB = origin + lengthA + gutter;\n ratio = extent > 0 ? (lengthA + gutter / 2) / extent : ratio;\n } else if (lead && usable(lead.length) && lead.length + gutter < extent) {\n const rest = Math.max(0, extent - lead.length - gutter);\n [lengthA, lengthB] = lead === fixedA ? [lead.length, rest] : [rest, lead.length];\n startB = origin + lengthA + gutter;\n ratio = (lengthA + gutter / 2) / extent;\n } else {\n if (floor) {\n const a = floor(tree.a, axis, tree);\n const b = floor(tree.b, axis, tree);\n const net = a.net === false || b.net === false ? ([0, 1] as const) : NET;\n ratio = clampByMin(Number.isFinite(tree.ratio ?? 0.5) ? (tree.ratio ?? 0.5) : 0.5, extent, gutter, px(a.min), px(b.min), net);\n }\n lengthA = Math.max(0, extent * ratio - gutter / 2);\n lengthB = Math.max(0, extent * (1 - ratio) - gutter / 2);\n startB = origin + extent * ratio + gutter / 2;\n divider = strip(area, x, origin + extent * ratio, gutter);\n }\n if (tree.id !== undefined) ctx.splits.set(tree.id, { rect: { ...area }, axis, ratio, divider });\n if (x) {\n lay(tree.a, { x: area.x, y: area.y, width: lengthA, height: acrossA }, ctx);\n lay(tree.b, { x: startB, y: area.y, width: lengthB, height: acrossB }, ctx);\n } else {\n lay(tree.a, { x: area.x, y: area.y, width: acrossA, height: lengthA }, ctx);\n lay(tree.b, { x: area.x, y: startB, width: acrossB, height: lengthB }, ctx);\n }\n}\n","/**\n * Whether a drop on a pane leaves room: the rule a host asks before it offers a side of a pane as a drop place. See\n * docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\nimport { layoutSplit, type SplitOptions } from \"./layout\";\nimport type { PaneRegion, PaneSide } from \"./regions\";\nimport { dropOnPane, panesOf, removePane, type Split } from \"./split\";\n\n/** The layout options a drop is judged under, and `min`: the least width and height, px, a pane must keep. */\nexport interface DropOptions<K> extends SplitOptions<K> {\n readonly min: number;\n}\n\n/** A drop's verdict: `ok`, or not, with its `reason`. */\nexport interface DropVerdict {\n readonly ok: boolean;\n readonly reason?: string;\n}\n\nconst px = (v: number | undefined): number => (v !== undefined && Number.isFinite(v) && v > 0 ? v : 0);\n\n/**\n * Whether dropping `dragged` on pane `at`'s `region` leaves both at least `options.min` wide and high.\n *\n * - The center is fine unless `dragged` is `at`, or `at` is not in the tree (nothing to swap with).\n * - A side needs, in the layout of the tree without `dragged` (so `at` is measured where it will be when `dragged` is\n * lifted out), a span of `at` along the split of at least `2 * min` plus the gutter (the options' gap plus handle)\n * and across it of at least `min`; and in the layout of `dropOnPane(tree, dragged, at, region)` both `dragged` and\n * `at` at least `min` wide and high. That check is skipped when `area` has no width or no height. A pane that is\n * not in the tree counts as one being added; an `at` that is not in it (or is `dragged`) has no place to split.\n */\nexport function canDropOnPane<K>(tree: Split<K> | null, dragged: K, at: K, region: PaneRegion, area: Rect, options: DropOptions<K>): DropVerdict {\n if (region === \"center\") {\n if (dragged === at) return { ok: false, reason: \"center swap blocked: a pane dropped on itself\" };\n return panesOf(tree).includes(at) ? { ok: true } : { ok: false, reason: \"center rejected: no pane to swap\" };\n }\n const target = layoutSplit(removePane(tree, dragged), area, options).get(at);\n if (!target) return { ok: false, reason: `${region} rejected: no pane to split` };\n const room = canSplitPane(target, region, options);\n if (!room.ok) return room;\n return dropFits(layoutSplit(dropOnPane(tree, dragged, at, region), area, options), dragged, at, area, { min: options.min, side: region });\n}\n\n/** What `canSplitPane` reads: `min` (as in `DropOptions`) and the gutter's parts, `gap` and `handle`, px. */\nexport interface SplitRoomOptions {\n readonly min: number;\n readonly gap?: number;\n readonly handle?: number;\n}\n\n/**\n * The room rule: whether a pane of rect `target` can take another on `side`, both at least `options.min` wide and\n * high. Along the split (width for left and right, height for top and bottom) the pane needs `2 * min` plus the\n * gutter (`gap` plus `handle`), across it `min`. The rect is the pane's as the host measures it, where it will be\n * when the dragged pane is lifted out. `canDropOnPane`'s first rule, for a side.\n */\nexport function canSplitPane(target: Rect, side: PaneSide, options: SplitRoomOptions): DropVerdict {\n const min = px(options.min);\n const gutter = px(options.gap) + px(options.handle);\n const horizontal = side === \"left\" || side === \"right\";\n const along = horizontal ? target.width : target.height;\n const across = horizontal ? target.height : target.width;\n const need = min * 2 + gutter;\n if (along < need) return { ok: false, reason: `${side} rejected: axis span ${along.toFixed(1)}px < min ${need.toFixed(1)}px (2 panes + gutter ${gutter}px)` };\n if (across < min) return { ok: false, reason: `${side} rejected: cross span ${across.toFixed(1)}px < min ${min.toFixed(1)}px` };\n return { ok: true };\n}\n\n/** What `dropFits` reads: the `min` (as in `DropOptions`) and the `side` of `at` the drop is on, for the reason. */\nexport interface DropFitsOptions {\n readonly min: number;\n readonly side: PaneSide;\n}\n\n/**\n * The fit rule: in `projected`, the rect of every pane in the layout the drop makes (the host's own projection of\n * `dropOnPane`'s tree), whether `dragged` and `at` are both there and at least `options.min` wide and high. Fine\n * when `area` has no width or no height (there is nothing to measure). `canDropOnPane`'s last rule.\n */\nexport function dropFits<K>(projected: ReadonlyMap<K, Rect>, dragged: K, at: K, area: Rect, options: DropFitsOptions): DropVerdict {\n if (!(area.width > 0 && area.height > 0)) return { ok: true };\n const min = px(options.min);\n const fits = (r: Rect | undefined): boolean => !!r && r.width >= min && r.height >= min;\n return fits(projected.get(dragged)) && fits(projected.get(at)) ? { ok: true } : { ok: false, reason: `${options.side} rejected: projected footprint of the two panes violates min ${min}px` };\n}\n","/**\n * A pane's drop regions: a center rectangle (a drop there swaps with the pane) and four side trapezoids (a drop there\n * splits the pane on that side), formed by the diagonals from each pane corner to the nearest corner of the center.\n * The five regions cover the pane with no gaps and no overlaps.\n *\n * Meant for `@n-uf/motion/drag`'s `placeOf(target, point, previous)`: one target per pane (`paneTargets`), its place\n * the region under the pointer, the previous region held for `hysteresis` px past its boundary so a pointer resting on\n * a boundary doesn't flicker. A region that takes no drop is the consumer's to answer with a null place.\n */\nimport { clamp, type Point, type Rect, type Size } from \"../geometry\";\n\nexport type PaneSide = \"top\" | \"right\" | \"bottom\" | \"left\";\nexport type PaneRegion = \"center\" | PaneSide;\n\n/** The sides in their tie-break order: at an exact diagonal the first wins (a corner resolves to `top`). */\nexport const PANE_SIDES: readonly PaneSide[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\nexport interface PaneRegionOptions {\n /** The center rectangle's share of each pane axis (0.05 to 0.95); `centerX` / `centerY` override one axis. */\n readonly center?: number;\n readonly centerX?: number;\n readonly centerY?: number;\n /** The least the center spans on either axis, px (a small pane keeps a usable center). */\n readonly centerMin?: number;\n /** How far past its boundary the previous region holds, px. */\n readonly hysteresis?: number;\n /** Device pixels per px: the center's edges snap to that grid, as the browser draws them. */\n readonly pixelRatio?: number;\n /**\n * The pane's center rectangle as the host already has it (pane-local px, as `paneCenter` gives), used as it is in\n * place of measuring: `center`, `centerX`, `centerY`, `centerMin` and `pixelRatio` are not read. Only `paneRegion`\n * reads it; its `width` and `height` are the pane's own size for the hold toward the middle.\n */\n readonly paneCenter?: PaneCenter;\n}\n\nexport const PANE_REGION_DEFAULTS: Required<Omit<PaneRegionOptions, \"centerX\" | \"centerY\" | \"paneCenter\">> = { center: 0.34, centerMin: 24, hysteresis: 6, pixelRatio: 1 };\n\n/** The center rectangle of a pane of `size`, in pane-local px (origin at the pane's top-left corner). */\nexport interface PaneCenter {\n readonly width: number;\n readonly height: number;\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\nconst snap = (v: number, ratio: number): number => Math.round(v * ratio) / ratio;\n\n/** Where the center rectangle of a pane of `size` lies, by these options. */\nexport function paneCenter(size: Size, options: PaneRegionOptions = {}): PaneCenter {\n const o = { ...PANE_REGION_DEFAULTS, ...options };\n const width = Math.max(0, size.width);\n const height = Math.max(0, size.height);\n const ratio = o.pixelRatio > 0 ? o.pixelRatio : 1;\n const rx = clamp(o.centerX ?? o.center, 0.05, 0.95);\n const ry = clamp(o.centerY ?? o.center, 0.05, 0.95);\n const cw = Math.min(width, Math.max(width * rx, Math.min(o.centerMin, width)));\n const ch = Math.min(height, Math.max(height * ry, Math.min(o.centerMin, height)));\n return { width, height, left: snap((width - cw) / 2, ratio), top: snap((height - ch) / 2, ratio), right: snap((width + cw) / 2, ratio), bottom: snap((height + ch) / 2, ratio) };\n}\n\n/** How deep past the center a point is toward each side, as a share of that side's band (positive: in that band). */\nfunction depths(p: Point, c: PaneCenter): { side: PaneSide; depth: number }[] {\n return [\n { side: \"top\", depth: (c.top - p.y) / Math.max(c.top, 1) },\n { side: \"right\", depth: (p.x - c.right) / Math.max(c.width - c.right, 1) },\n { side: \"bottom\", depth: (p.y - c.bottom) / Math.max(c.height - c.bottom, 1) },\n { side: \"left\", depth: (c.left - p.x) / Math.max(c.left, 1) },\n ];\n}\n\n/** The region a pane-local point is in, by position alone. */\nfunction rawRegion(p: Point, c: PaneCenter): PaneRegion {\n if (p.x >= c.left && p.x <= c.right && p.y >= c.top && p.y <= c.bottom) return \"center\";\n let best: PaneRegion = \"center\";\n let deepest = 0;\n for (const d of depths(p, c)) {\n if (d.depth > deepest) {\n deepest = d.depth;\n best = d.side;\n }\n }\n return best;\n}\n\n/** `p` moved `by` px into `region` (toward the pane's middle for the center). */\nfunction toward(p: Point, region: PaneRegion, by: number, c: PaneCenter): Point {\n if (region === \"left\") return { x: p.x - by, y: p.y };\n if (region === \"right\") return { x: p.x + by, y: p.y };\n if (region === \"top\") return { x: p.x, y: p.y - by };\n if (region === \"bottom\") return { x: p.x, y: p.y + by };\n const dx = c.width / 2 - p.x;\n const dy = c.height / 2 - p.y;\n const len = Math.hypot(dx, dy);\n if (len <= by || len === 0) return { x: c.width / 2, y: c.height / 2 };\n return { x: p.x + (dx / len) * by, y: p.y + (dy / len) * by };\n}\n\n/**\n * The drop region of `pane` (in the same coordinates as `point`) the point is in. With a `previous` region, the point\n * has to be `hysteresis` px past that region's boundary before the region changes: no time-based debounce, only\n * geometry. A host that has measured the center itself passes it as `options.paneCenter`; the same center gives the\n * same region as the one measured here.\n */\nexport function paneRegion(pane: Rect, point: Point, previous: PaneRegion | null = null, options: PaneRegionOptions = {}): PaneRegion {\n const c = options.paneCenter ?? paneCenter(pane, options);\n const p = { x: point.x - pane.x, y: point.y - pane.y };\n const raw = rawRegion(p, c);\n const by = Math.max(0, options.hysteresis ?? PANE_REGION_DEFAULTS.hysteresis);\n if (previous === null || by === 0 || previous === raw) return raw;\n return rawRegion(toward(p, previous, by, c), c) === previous ? previous : raw;\n}\n","/**\n * Drop targets for tiling, in the root `Target` shape (what `@n-uf/motion/drag` takes). Both kinds come from one\n * helper: a pane target (`pane:<id>`, its hit the pane, the place in it its drop region) for the split tree, and an\n * insertion target (`at:<index>`, its hit and slot the dragged pane's rect with it inserted there) for an order layout.\n */\nimport type { Rect } from \"../geometry\";\nimport type { Target } from \"../target\";\nimport type { OrderLayout, OrderOptions } from \"./order\";\n\n/** A split tree's target: drop on pane `pane` (the region under the pointer says how). */\nexport interface PaneTarget<K> extends Target {\n readonly pane: K;\n}\n\n/** An order layout's target: insert the dragged pane at `index`; `layout` is every pane's rect with it there. */\nexport interface OrderTarget<K> extends Target {\n readonly index: number;\n readonly layout: ReadonlyMap<K, Rect>;\n}\n\n/** The one shape both kinds share: a slot-sized drop with no precedence over any other. */\nconst tilingTarget = (id: string, hit: Rect, slot?: Rect): Target => ({ id, priority: 2, hit, ...(slot ? { slot } : {}) });\n\nexport interface PaneTargetsOptions<K> {\n /** A pane left out: the dragged one, when it is still laid out. */\n readonly except?: K;\n /**\n * A pane's key in its target's id (`pane:<key>`); default `String`. Keys must be unique across the panes: a drag\n * intent follows its targets by id, so two panes with one key would be one target.\n */\n readonly key?: (pane: K) => string;\n}\n\n/** One target per pane of `layout`, its id `pane:<key>`. */\nexport function paneTargets<K>(layout: ReadonlyMap<K, Rect>, options: PaneTargetsOptions<K> = {}): PaneTarget<K>[] {\n const key = options.key ?? String;\n return [...layout].filter(([k]) => k !== options.except).map(([pane, r]) => ({ ...tilingTarget(`pane:${key(pane)}`, r), pane }));\n}\n\n/**\n * One target per index `dragged` could be inserted at among `panes` (which don't hold it), laid out by `arrange` in\n * `area`. Each target's hit and slot is `dragged`'s rect with it there, so the targets cover the area as the layout\n * does. Ids are `at:<index>`, unique whatever the panes are.\n */\nexport function orderTargets<K>(arrange: OrderLayout, panes: readonly K[], dragged: K, area: Rect, options?: OrderOptions): OrderTarget<K>[] {\n return Array.from({ length: panes.length + 1 }, (_, index) => {\n const layout = arrange([...panes.slice(0, index), dragged, ...panes.slice(index)], area, options);\n const slot = layout.get(dragged)!;\n return { ...tilingTarget(`at:${index}`, slot, slot), index, layout };\n });\n}\n","import type { Rect, Size } from \"../geometry\";\n\n/**\n * The minimum-size give-way: while a pane is laid out below its minimum, the newest pane (highest `age`) floats and\n * the rest are laid out again. Stops when every pane keeps its minimum or one pane is left. `layout` lays out the\n * kept panes; the result says which are kept (in their order) and which float (newest first).\n */\nexport function giveWay<K>(panes: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (pane: K) => Size, age: (pane: K) => number): { kept: K[]; floats: K[] } {\n let kept = [...panes];\n const floats: K[] = [];\n for (;;) {\n const res = layout(kept);\n const broken = [...res].some(([k, r]) => r.width < min(k).width - 0.5 || r.height < min(k).height - 0.5);\n if (!broken || kept.length <= 1) return { kept, floats };\n const newest = kept.reduce((a, b) => (age(b) > age(a) ? b : a));\n kept = kept.filter((k) => k !== newest);\n floats.push(newest);\n }\n}\n","/**\n * The nearest pane in a direction: the rule a host moves focus by. See docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\n\n/** A direction on the plane: `\"up\"` is toward smaller y. */\nexport type Direction = \"left\" | \"right\" | \"up\" | \"down\";\n\n/**\n * The pane nearest `from` in `direction`, or null when none lies that way. A candidate's center has to be strictly on\n * that side of `from`'s center. Its score is the center distance along the direction, plus a quarter of the center\n * distance across it, plus 100 when it does not overlap `from` across the direction (the overlap strictly above 0);\n * the lowest score wins, ties to the first in the map's order. A pane that is not in `rects` has no neighbor.\n *\n * The host chooses which rects to pass. One option: lay the tree out in a unit square (`{ x: 0, y: 0, width: 1,\n * height: 1 }`) with the host's px floors. A floor of tens of px cannot fit in a unit square, so a split's two floors\n * cannot both fit and it lays out at 0.5 whatever its ratio; fixed lengths in px along a split do not fit either, and\n * the area's size and the gap drop out. Fixed lengths across a split are not checked against the cross extent, so\n * they still apply in a unit square, and a host leaves `fixedAcross` out there. The rects of the real layout work too.\n */\nexport function neighbor<K>(rects: ReadonlyMap<K, Rect>, from: K, direction: Direction): K | null {\n const origin = rects.get(from);\n if (!origin) return null;\n const horizontal = direction === \"left\" || direction === \"right\";\n // Centers and ends as sums of edges (right = x + width), so a host that keeps edge rects gets the same bits.\n const center = (r: Rect, x: boolean): number => (x ? (r.x + (r.x + r.width)) / 2 : (r.y + (r.y + r.height)) / 2);\n const reach = (r: Rect, x: boolean): [number, number] => (x ? [r.x, r.x + r.width] : [r.y, r.y + r.height]);\n const fromAlong = center(origin, horizontal);\n const fromAcross = center(origin, !horizontal);\n const [originStart, originEnd] = reach(origin, !horizontal);\n const sign = direction === \"left\" || direction === \"up\" ? -1 : 1;\n let best: K | null = null;\n let bestScore = Number.POSITIVE_INFINITY;\n for (const [key, r] of rects) {\n if (key === from) continue;\n const along = center(r, horizontal);\n if (sign < 0 ? along >= fromAlong : along <= fromAlong) continue;\n const [start, end] = reach(r, !horizontal);\n const overlap = Math.max(0, Math.min(originEnd, end) - Math.max(originStart, start));\n const score = Math.abs(along - fromAlong) + Math.abs(center(r, !horizontal) - fromAcross) * 0.25 + (overlap > 0 ? 0 : 100);\n if (score < bestScore) {\n bestScore = score;\n best = key;\n }\n }\n return best;\n}\n"],"mappings":";;;;;AAmCO,IAAM,cAAc,CAAC,MAAmC,MAAM,UAAa,CAAC,OAAO,SAAS,CAAC,IAAI,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM,CAAC,CAAC;AAGvI,SAAS,YAAY,OAA2B,GAAmB;AACxE,QAAM,IAAI,KAAK,MAAM,SAAS,CAAC;AAC/B,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AACtE;AAGA,SAAS,OAAU,OAAqB,GAAW,GAAW,OAAe,QAAgB,UAAmB,KAAa,KAAyB;AACpJ,QAAM,IAAI,MAAM;AAChB,QAAM,QAAQ,OAAO,IAAI;AACzB,MAAI,UAAU;AACZ,UAAM,OAAO,KAAK,IAAI,IAAI,SAAS,SAAS,CAAC;AAC7C,UAAM,QAAQ,CAAC,MAAM,MAAM,IAAI,IAAI,MAAM,EAAE,GAAG,GAAG,IAAI,KAAK,OAAO,MAAM,OAAO,QAAQ,KAAK,CAAC,CAAC;AAAA,EAC/F,OAAO;AACL,UAAM,OAAO,KAAK,IAAI,IAAI,QAAQ,SAAS,CAAC;AAC5C,UAAM,QAAQ,CAAC,MAAM,MAAM,IAAI,IAAI,MAAM,EAAE,GAAG,IAAI,KAAK,OAAO,MAAM,GAAG,OAAO,MAAM,OAAO,CAAC,CAAC;AAAA,EAC/F;AACF;AASO,SAAS,YAAe,OAAqB,MAAY,UAAwB,CAAC,GAAiB;AACxG,QAAM,MAAM,QAAQ,QAAQ,UAAa,OAAO,SAAS,QAAQ,GAAG,KAAK,QA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AAM,SAAS,CAAC,GAAS,MAAwB,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW;AAC9G,QAAM,QAAQ,CAAC,GAAS,MAAkC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM;AACzG,QAAM,YAAY,OAAO,QAAQ,UAAU;AAC3C,QAAM,aAAa,OAAO,QAAQ,CAAC,UAAU;AAC7C,QAAM,CAAC,aAAa,SAAS,IAAI,MAAM,QAAQ,CAAC,UAAU;AAC1D,QAAM,OAAO,cAAc,UAAU,cAAc,OAAO,KAAK;AAC/D,MAAI,OAAiB;AACrB,MAAI,YAAY,OAAO;AACvB,aAAW,CAAC,KAAK,CAAC,KAAK,OAAO;AAC5B,QAAI,QAAQ,KAAM;AAClB,UAAM,QAAQ,OAAO,GAAG,UAAU;AAClC,QAAI,OAAO,IAAI,SAAS,YAAY,SAAS,UAAW;AACxD,UAAM,CAAC,OAAO,GAAG,IAAI,MAAM,GAAG,CAAC,UAAU;AACzC,UAAM,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,GAAG,IAAI,KAAK,IAAI,aAAa,KAAK,CAAC;AACnF,UAAM,QAAQ,KAAK,IAAI,QAAQ,SAAS,IAAI,KAAK,IAAI,OAAO,GAAG,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,UAAU,IAAI,IAAI;AACtH,QAAI,QAAQ,WAAW;AACrB,kBAAY;AACZ,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":["px"]}
|
|
1
|
+
{"version":3,"sources":["../src/tiling/order.ts","../src/tiling/split.ts","../src/tiling/layout.ts","../src/tiling/drop.ts","../src/tiling/regions.ts","../src/tiling/targets.ts","../src/tiling/give-way.ts","../src/tiling/neighbor.ts"],"sourcesContent":["/**\n * The order layouts: panes in order and an area in, a rect per pane out. Pure rect functions; a drop on one reorders\n * (the dragged pane inserted at an index, see `orderTargets`).\n */\nimport type { Rect } from \"../geometry\";\nimport type { Side } from \"../side\";\n\n/**\n * How a layout spaces its panes: `gap` px between neighbors (default 0), `ratio` the master's share (default 0.5),\n * `handle` px a split's divider takes beside the gap (default 0; only a split tree reads it).\n */\nexport interface TileOptions {\n readonly gap?: number;\n readonly ratio?: number;\n readonly handle?: number;\n}\n\n/**\n * The master area: `count` panes (rounded, kept within 1..n; default 1) on `side` (default `\"left\"`). Left and right\n * make it a column of panes stacked vertically; top and bottom a row of panes side by side. The one home of the\n * concept: `masterStack` takes it in its options (`OrderOptions`), a split that lays out as master and stack in its\n * `master` field.\n */\nexport interface MasterOptions {\n readonly count?: number;\n readonly side?: Side;\n}\n\n/** What the order layouts take: `TileOptions` and the master area's `count` and `side` (`columns` and `grid` ignore them). */\nexport type OrderOptions = TileOptions & MasterOptions;\n\n/** An order layout: `masterStack`, `columns`, `grid`, or the app's own of the same shape. */\nexport type OrderLayout = <K>(panes: readonly K[], area: Rect, options?: OrderOptions) => Map<K, Rect>;\n\n/** The master's share in effect: clamped to 0.05..0.95; one that is not finite is 0.5. */\nexport const masterRatio = (v: number | undefined): number => (v === undefined || !Number.isFinite(v) ? 0.5 : Math.min(0.95, Math.max(0.05, v)));\n\n/** How many of `n` panes are masters for a requested `count`: rounded, within 1..n; NaN is 1. */\nexport function masterCount(count: number | undefined, n: number): number {\n const c = Math.round(count ?? 1);\n return Math.min(Math.max(Number.isNaN(c) ? 1 : c, 1), Math.max(n, 1));\n}\n\n/** `items` side by side or one above the other in equal shares of the box, `gap` between them. */\nfunction divide<K>(items: readonly K[], x: number, y: number, width: number, height: number, vertical: boolean, gap: number, out: Map<K, Rect>): void {\n const n = items.length;\n const total = gap * (n - 1);\n if (vertical) {\n const each = Math.max(0, (height - total) / n);\n items.forEach((pane, i) => out.set(pane, { x, y: y + i * (each + gap), width, height: each }));\n } else {\n const each = Math.max(0, (width - total) / n);\n items.forEach((pane, i) => out.set(pane, { x: x + i * (each + gap), y, width: each, height }));\n }\n}\n\n/**\n * Master and stack: the first `count` panes are the masters, in an area on `side` that takes `ratio` of the room the\n * gap leaves (clamped to 0.05..0.95; default 0.5); the rest are the stack, in the other area. Left and right make\n * each area a column of panes stacked vertically; top and bottom a row of panes side by side. Right and bottom put\n * the stack first in space. With no stack (n at most `count`) all the panes fill the area, stacked along the side's\n * cross axis. Each area divides its length equally between its panes, the gap between them.\n */\nexport function masterStack<K>(panes: readonly K[], area: Rect, options: OrderOptions = {}): Map<K, Rect> {\n const gap = options.gap !== undefined && Number.isFinite(options.gap) && options.gap > 0 ? options.gap : 0;\n const out = new Map<K, Rect>();\n if (panes.length === 0) return out;\n const side = options.side ?? \"left\";\n const ratio = masterRatio(options.ratio);\n const count = masterCount(options.count, panes.length);\n const masters = panes.slice(0, count);\n const stack = panes.slice(count);\n const column = side === \"left\" || side === \"right\";\n if (stack.length === 0) {\n divide(masters, area.x, area.y, area.width, area.height, column, gap, out);\n } else if (column) {\n const room = Math.max(0, area.width - gap);\n const masterWidth = room * ratio;\n const stackWidth = room * (1 - ratio);\n const masterX = side === \"left\" ? area.x : area.x + stackWidth + gap;\n const stackX = side === \"left\" ? area.x + masterWidth + gap : area.x;\n divide(masters, masterX, area.y, masterWidth, area.height, true, gap, out);\n divide(stack, stackX, area.y, stackWidth, area.height, true, gap, out);\n } else {\n const room = Math.max(0, area.height - gap);\n const masterHeight = room * ratio;\n const stackHeight = room * (1 - ratio);\n const masterY = side === \"top\" ? area.y : area.y + stackHeight + gap;\n const stackY = side === \"top\" ? area.y + masterHeight + gap : area.y;\n divide(masters, area.x, masterY, area.width, masterHeight, false, gap, out);\n divide(stack, area.x, stackY, area.width, stackHeight, false, gap, out);\n }\n return out;\n}\n\n/** Equal columns, full height. */\nexport function columns<K>(panes: readonly K[], area: Rect, options: TileOptions = {}): Map<K, Rect> {\n const gap = options.gap ?? 0;\n const out = new Map<K, Rect>();\n const n = panes.length;\n const w = (area.width - gap * (n - 1)) / Math.max(1, n);\n panes.forEach((id, i) => out.set(id, { x: area.x + i * (w + gap), y: area.y, width: w, height: area.height }));\n return out;\n}\n\n/** A grid as square as the count allows; the last row's cells widen to fill it. */\nexport function grid<K>(panes: readonly K[], area: Rect, options: TileOptions = {}): Map<K, Rect> {\n const gap = options.gap ?? 0;\n const out = new Map<K, Rect>();\n const n = panes.length;\n if (n === 0) return out;\n const cols = Math.ceil(Math.sqrt(n));\n const rows = Math.ceil(n / cols);\n const h = (area.height - gap * (rows - 1)) / rows;\n panes.forEach((id, i) => {\n const row = Math.floor(i / cols);\n const inRow = row === rows - 1 ? n - cols * (rows - 1) : cols;\n const col = i - row * cols;\n const w = (area.width - gap * (inRow - 1)) / inRow;\n out.set(id, { x: area.x + col * (w + gap), y: area.y + row * (h + gap), width: w, height: h });\n });\n return out;\n}\n","/**\n * The split tree: how panes divide an area. A node is a pane, or a split of its rect in two (`a` then `b`). A split\n * with an `axis` divides along it (`\"x\"`: `a` left of `b`; `\"y\"`: `a` above `b`) at `ratio`; one without divides\n * along the rect's longer side in halves, which is dwindle (split along the longer side). Pure: trees in, trees out.\n */\nimport type { Axis, Side } from \"../side\";\nimport type { MasterOptions } from \"./order\";\nimport type { PaneRegion } from \"./regions\";\n\n/**\n * A pane, or a split of its rect in two, `a` then `b`. A split takes its `axis` and its `ratio` (the first side's\n * share); `gap` replaces the layout's gap for this split (the handle stays global); `id` names the split so\n * `layoutSplitTree` reports its geometry. With `master`, the split lays its subtree out flat: its panes, in order,\n * as master and stack (`masterStack`) in its rect, by its `ratio` and gap; the splits under it are not laid out.\n */\nexport type Split<K> =\n | { readonly pane: K }\n | {\n readonly a: Split<K>;\n readonly b: Split<K>;\n readonly axis?: Axis;\n readonly ratio?: number;\n readonly gap?: number;\n readonly id?: string;\n readonly master?: MasterOptions;\n };\n\n/** The panes of `tree` in order (`a` before `b`). */\nexport const panesOf = <K>(tree: Split<K> | null): K[] => (!tree ? [] : \"pane\" in tree ? [tree.pane] : [...panesOf(tree.a), ...panesOf(tree.b)]);\n\nconst has = <K>(tree: Split<K> | null, pane: K): boolean => panesOf(tree).includes(pane);\n\n/** `tree` with each pane node `fn` gives a replacement for replaced. */\nfunction mapPanes<K>(tree: Split<K>, fn: (pane: K) => Split<K>): Split<K> {\n if (\"pane\" in tree) return fn(tree.pane);\n return { ...tree, a: mapPanes(tree.a, fn), b: mapPanes(tree.b, fn) };\n}\n\n/**\n * `tree` with pane `at` split in two, `pane` on its `side`. A side writes an explicit axis and ratio 0.5, so the side\n * means the same whatever the pane's shape; no side splits along the longer side, `pane` second (dwindle). An empty\n * tree becomes `pane` alone; an `at` that isn't in the tree (or null) splits the whole tree, so no pane is lost.\n */\nexport function splitPane<K>(tree: Split<K> | null, at: K | null, pane: K, side?: Side): Split<K> {\n const fresh: Split<K> = { pane };\n const split = (node: Split<K>): Split<K> => {\n if (!side) return { a: node, b: fresh };\n const axis = side === \"left\" || side === \"right\" ? \"x\" : \"y\";\n const first = side === \"left\" || side === \"top\";\n return first ? { a: fresh, b: node, axis, ratio: 0.5 } : { a: node, b: fresh, axis, ratio: 0.5 };\n };\n if (!tree) return fresh;\n if (at === null || !has(tree, at)) return split(tree);\n return mapPanes(tree, (p) => (p === at ? split({ pane: p }) : { pane: p }));\n}\n\n/** `tree` without `pane`: its sibling takes their parent's place. */\nexport function removePane<K>(tree: Split<K> | null, pane: K): Split<K> | null {\n if (!tree) return null;\n if (\"pane\" in tree) return tree.pane === pane ? null : tree;\n const a = removePane(tree.a, pane);\n const b = removePane(tree.b, pane);\n return a && b ? { ...tree, a, b } : (a ?? b);\n}\n\n/** `tree` with panes `x` and `y` in each other's place; unchanged unless both are in it. */\nexport function swapPanes<K>(tree: Split<K> | null, x: K, y: K): Split<K> | null {\n if (!tree || !has(tree, x) || !has(tree, y)) return tree;\n return mapPanes(tree, (p) => ({ pane: p === x ? y : p === y ? x : p }));\n}\n\n/** A dwindle tree for `panes`: each one splits the one before it along the longer side. */\nexport function splitFromOrder<K>(panes: readonly K[]): Split<K> | null {\n let t: Split<K> | null = null;\n panes.forEach((id, i) => {\n t = splitPane(t, i > 0 ? panes[i - 1]! : null, id);\n });\n return t;\n}\n\n/**\n * A drop of `dragged` on pane `at`'s `region`. A side splits `at` on that side (`dragged` taken out of its old place\n * first). The center swaps the two when `dragged` is in the tree; a pane from outside takes `at`'s place, with `at`\n * split off after it along the longer side. An `at` that isn't in the tree (or is `dragged` itself) changes nothing\n * but adding `dragged` when it is missing, as `splitPane` does. The set of panes is kept: the tree's, plus `dragged`.\n */\nexport function dropOnPane<K>(tree: Split<K> | null, dragged: K, at: K, region: PaneRegion): Split<K> {\n if (!tree) return { pane: dragged };\n if (dragged === at || !has(tree, at)) return has(tree, dragged) ? tree : splitPane(tree, null, dragged);\n if (region !== \"center\") return splitPane(removePane(tree, dragged), at, dragged, region);\n if (has(tree, dragged)) return swapPanes(tree, dragged, at)!;\n return mapPanes(tree, (p) => (p === at ? { a: { pane: dragged }, b: { pane: p } } : { pane: p }));\n}\n","/**\n * The split tree laid out: the rect of every pane of a `Split` tree in an area, and the geometry of the splits that\n * have an id. See docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\nimport type { Axis } from \"../side\";\nimport { masterCount, masterRatio, masterStack, type MasterOptions, type TileOptions } from \"./order\";\nimport { panesOf, type Split } from \"./split\";\n\n/** A px option: a finite number, never below 0 (anything else is 0). */\nconst px = (v: number | undefined): number => (v !== undefined && Number.isFinite(v) && v > 0 ? v : 0);\n\n/** A ratio: clamped to 0..1; one that is not finite is 0.5. */\nconst unit = (v: number | undefined): number => (v === undefined || !Number.isFinite(v) ? 0.5 : Math.min(1, Math.max(0, v)));\n\n/** A usable length: finite and above 0. */\nconst usable = (v: number | undefined): v is number => v !== undefined && Number.isFinite(v) && v > 0;\n\n/** The least a ratio may be in a split with a floor: within 5 and 95 % unless a side takes the net off. */\nconst NET: readonly [number, number] = [0.05, 0.95];\n\n/** A split child's fixed length along its split. `keep` marks one that holds its length even beside another. */\nexport interface FixedLength {\n readonly length: number;\n readonly keep?: boolean;\n}\n\n/** A split child's least length along its split. `net` (default true) keeps the split's ratio within 5..95 %. */\nexport interface MinLength {\n readonly min: number;\n readonly net?: boolean;\n}\n\n/**\n * What a split tree's layout reads of its host, each per split, of the split's two direct children.\n *\n * - `fixed(child, axis)`: the child's fixed length along the split, if it has one. The first child that reports one\n * decides: it takes its length when the length is above 0 and, with the gutter, less than the extent, and the other\n * side fills the rest (the gutter between). Otherwise, or with a length that does not fit, the split falls back to\n * its ratio, and the other child's length is not read. When both report a length with `keep`, each keeps its own,\n * in order, and the room left over stays empty; if the two (and the gutter) do not fit the extent, the second runs\n * past the end. A split a fixed length decides has no divider and no floor.\n * - `fixedAcross(child, axis)`: the child's fixed length across the split; the child takes it, when positive and\n * finite, from the start of the cross axis instead of the whole cross extent. It is not checked against the cross\n * extent: a length larger than the cross extent makes a pane larger than the split's box.\n * - `floor(child, axis, split)`: the child's least length along the split. The ratio is clamped so each side keeps\n * its floor of the room less the gutter, within the net (5..95 %) unless either side says `net: false`; where the\n * two floors cannot both fit, the ratio is 0.5. With no `floor`, the ratio is only clamped to 0..1. `giveWay` is\n * the other policy of the same minimum: it floats the newest pane instead of squeezing the ratio, and a host\n * chooses one for a pane.\n */\nexport interface SplitOptions<K> extends TileOptions {\n readonly fixed?: (child: Split<K>, axis: Axis) => FixedLength | undefined;\n readonly fixedAcross?: (child: Split<K>, axis: Axis) => number | undefined;\n readonly floor?: (child: Split<K>, axis: Axis, split: Split<K>) => MinLength;\n}\n\n/** A laid-out split: the box it divides, its axis and ratio in effect, and the strip between its two sides. */\nexport interface SplitGeometry {\n readonly rect: Rect;\n readonly axis: \"x\" | \"y\";\n /**\n * The first side's share in effect: the middle of the gutter lies at the box's start plus its extent times this\n * (for a fixed-length child, the middle of the gutter after the first side over the extent). For a master split\n * it is the master area's share (clamped to 0.05..0.95) of the room less the gap, measured from the master's own\n * side: with the master on the right, ratio 0.3 in 1000 with a gap of 10, the divider lies at 693..703.\n */\n readonly ratio: number;\n /** The gutter between the two sides, as a rect inside `rect`; null where the split has none. */\n readonly divider: Rect | null;\n}\n\n/** A tree laid out: every pane's rect, and the geometry of each split that has an `id`. */\nexport interface SplitLayout<K> {\n readonly panes: Map<K, Rect>;\n readonly splits: Map<string, SplitGeometry>;\n}\n\ninterface Ctx<K> {\n readonly options: SplitOptions<K>;\n readonly gap: number;\n readonly handle: number;\n readonly panes: Map<K, Rect>;\n /** Where the geometry of the named splits goes; null for `layoutSplit`, which reports panes only and builds none. */\n readonly splits: Map<string, SplitGeometry> | null;\n}\n\n/**\n * The rect of every pane of `tree` in `area`. Each split's gutter is its gap (its own `gap`, else `options.gap`) plus\n * `options.handle`. A split's `ratio` is clamped to 0..1 (one that is not finite is 0.5), and the middle of the gutter\n * sits at `extent * ratio`: the first side is `extent * ratio` less half the gutter, the second starts half a gutter\n * past it and is the rest less half the gutter. No size is ever negative: a side too short for half the gutter is 0\n * along the axis, and the second side of a split with no room may then start up to half a gutter past the rect's end.\n * At ratio 0.5 both sides are equal. `options.floor`, `fixed` and `fixedAcross` (see `SplitOptions`) read the host's\n * minimums and fixed lengths per split. A negative or non-finite `gap` or `handle` is 0. The area is taken as given:\n * with a negative width or height every length along that axis is 0 and a pane's size across it is copied as it\n * is, so pass an area with no negative side.\n */\nexport function layoutSplit<K>(tree: Split<K> | null, area: Rect, options: SplitOptions<K> = {}): Map<K, Rect> {\n const ctx: Ctx<K> = { options, gap: px(options.gap), handle: px(options.handle), panes: new Map(), splits: null };\n lay(tree, area, ctx, false);\n return ctx.panes;\n}\n\n/**\n * `layoutSplit` and the geometry of every split that has an `id` (a repeated id keeps the one laid out last: a split under another, or a later one beside it): the box it divides,\n * its axis and ratio in effect (after the floors), and its divider, the gutter strip between its two sides. A split\n * that lays out as master and stack is reported too, its nested splits are not.\n */\nexport function layoutSplitTree<K>(tree: Split<K> | null, area: Rect, options: SplitOptions<K> = {}): SplitLayout<K> {\n const splits = new Map<string, SplitGeometry>();\n const ctx: Ctx<K> = { options, gap: px(options.gap), handle: px(options.handle), panes: new Map(), splits };\n lay(tree, area, ctx, false);\n return { panes: ctx.panes, splits };\n}\n\n/** The strip `gutter` wide centered on `mid` across `box`, clipped to it. */\nfunction strip(box: Rect, x: boolean, mid: number, gutter: number): Rect {\n const lo = Math.max(x ? box.x : box.y, mid - gutter / 2);\n const hi = Math.min(x ? box.x + box.width : box.y + box.height, mid + gutter / 2);\n const length = Math.max(0, hi - lo);\n return x ? { x: lo, y: box.y, width: length, height: box.height } : { x: box.x, y: lo, width: box.width, height: length };\n}\n\n/**\n * `ratio` kept so the first side has `minA` and the second `minB` of the room less the gutter (at least 1 px of room),\n * within `net`; 0.5 where the two cannot both fit.\n */\nfunction clampByMin(ratio: number, extent: number, gutter: number, minA: number, minB: number, net: readonly [number, number]): number {\n const room = Math.max(extent - gutter, 1);\n const boundedMin = Math.min(Math.max(minA / room, net[0]), net[1]);\n const boundedMax = Math.max(Math.min(1 - minB / room, net[1]), net[0]);\n return boundedMin > boundedMax ? 0.5 : Math.min(Math.max(ratio, boundedMin), boundedMax);\n}\n\n/** A split that lays its panes out flat as master and stack: the gap only, never the handle. */\nfunction layMaster<K>(tree: Extract<Split<K>, { a: unknown }>, master: MasterOptions, area: Rect, ctx: Ctx<K>, owned: boolean): void {\n const gap = tree.gap === undefined ? ctx.gap : px(tree.gap);\n const panes = panesOf(tree);\n const ratio = masterRatio(tree.ratio);\n const side = master.side ?? \"left\";\n // Only the count and side come from `master`: the ratio and gap are the split's own.\n for (const [pane, r] of masterStack(panes, area, { gap, ratio, count: master.count, side })) ctx.panes.set(pane, r);\n if (tree.id === undefined || ctx.splits === null) return;\n const x = side === \"left\" || side === \"right\";\n const stacked = panes.length > masterCount(master.count, panes.length);\n const room = Math.max(0, (x ? area.width : area.height) - gap);\n const first = side === \"left\" || side === \"top\" ? room * ratio : room * (1 - ratio);\n const mid = (x ? area.x : area.y) + first + gap / 2;\n ctx.splits.set(tree.id, { rect: owned ? area : { ...area }, axis: x ? \"x\" : \"y\", ratio, divider: stacked ? strip(area, x, mid, gap) : null });\n}\n\n/**\n * Lays `tree` out in `area`. `owned` says `area` is a rect this layout made itself (a split's child), so a pane or a\n * split may keep it as its own; the caller's rect (the root) is copied, never kept.\n */\nfunction lay<K>(tree: Split<K> | null, area: Rect, ctx: Ctx<K>, owned: boolean): void {\n if (!tree) return;\n if (\"pane\" in tree) {\n ctx.panes.set(tree.pane, owned ? area : { ...area });\n return;\n }\n if (tree.master) {\n layMaster(tree, tree.master, area, ctx, owned);\n return;\n }\n const axis = tree.axis ?? (area.width >= area.height ? \"x\" : \"y\");\n const x = axis === \"x\";\n const extent = x ? area.width : area.height;\n const origin = x ? area.x : area.y;\n const cross = x ? area.height : area.width;\n const gutter = (tree.gap === undefined ? ctx.gap : px(tree.gap)) + ctx.handle;\n const { fixed, fixedAcross, floor } = ctx.options;\n // Across the split a child with a fixed length takes it from the start; the others take the whole cross extent.\n const lenA = fixedAcross?.(tree.a, axis);\n const lenB = fixedAcross?.(tree.b, axis);\n const acrossA = usable(lenA) ? lenA : cross;\n const acrossB = usable(lenB) ? lenB : cross;\n const fixedA = fixed?.(tree.a, axis);\n const fixedB = fixed?.(tree.b, axis);\n\n // The lengths of the two sides along the split, where the second starts, the ratio in effect and the divider.\n let lengthA: number;\n let lengthB: number;\n let startB: number;\n let ratio = unit(tree.ratio);\n let ruled = false; // the divider is the gutter strip at the ratio (a split no fixed length decides)\n const lead = fixedA ?? fixedB;\n if (fixedA && fixedB && fixedA.keep && fixedB.keep && usable(fixedA.length) && usable(fixedB.length)) {\n lengthA = fixedA.length;\n lengthB = fixedB.length;\n startB = origin + lengthA + gutter;\n ratio = extent > 0 ? (lengthA + gutter / 2) / extent : ratio;\n } else if (lead && usable(lead.length) && lead.length + gutter < extent) {\n const rest = Math.max(0, extent - lead.length - gutter);\n lengthA = lead === fixedA ? lead.length : rest;\n lengthB = lead === fixedA ? rest : lead.length;\n startB = origin + lengthA + gutter;\n ratio = (lengthA + gutter / 2) / extent;\n } else {\n if (floor) {\n const a = floor(tree.a, axis, tree);\n const b = floor(tree.b, axis, tree);\n const net = a.net === false || b.net === false ? ([0, 1] as const) : NET;\n ratio = clampByMin(Number.isFinite(tree.ratio ?? 0.5) ? (tree.ratio ?? 0.5) : 0.5, extent, gutter, px(a.min), px(b.min), net);\n }\n lengthA = Math.max(0, extent * ratio - gutter / 2);\n lengthB = Math.max(0, extent * (1 - ratio) - gutter / 2);\n startB = origin + extent * ratio + gutter / 2;\n ruled = true;\n }\n // The geometry is built only for a named split and only when the caller asked for it (`layoutSplitTree`).\n if (tree.id !== undefined && ctx.splits !== null) {\n const divider = ruled ? strip(area, x, origin + extent * ratio, gutter) : null;\n ctx.splits.set(tree.id, { rect: owned ? area : { ...area }, axis, ratio, divider });\n }\n if (x) {\n lay(tree.a, { x: area.x, y: area.y, width: lengthA, height: acrossA }, ctx, true);\n lay(tree.b, { x: startB, y: area.y, width: lengthB, height: acrossB }, ctx, true);\n } else {\n lay(tree.a, { x: area.x, y: area.y, width: acrossA, height: lengthA }, ctx, true);\n lay(tree.b, { x: area.x, y: startB, width: acrossB, height: lengthB }, ctx, true);\n }\n}\n","/**\n * Whether a drop on a pane leaves room: the rule a host asks before it offers a side of a pane as a drop place. See\n * docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\nimport type { Side } from \"../side\";\nimport { layoutSplit, type SplitOptions } from \"./layout\";\nimport type { PaneRegion } from \"./regions\";\nimport { dropOnPane, panesOf, removePane, type Split } from \"./split\";\n\n/** The layout options a drop is judged under, and `min`: the least width and height, px, a pane must keep. */\nexport interface DropOptions<K> extends SplitOptions<K> {\n readonly min: number;\n}\n\n/** A drop's verdict: `ok`, or not, with its `reason`. */\nexport interface DropVerdict {\n readonly ok: boolean;\n readonly reason?: string;\n}\n\nconst px = (v: number | undefined): number => (v !== undefined && Number.isFinite(v) && v > 0 ? v : 0);\n\n/**\n * Whether dropping `dragged` on pane `at`'s `region` leaves both at least `options.min` wide and high.\n *\n * - The center is fine unless `dragged` is `at`, or `at` is not in the tree (nothing to swap with).\n * - A side needs, in the layout of the tree without `dragged` (so `at` is measured where it will be when `dragged` is\n * lifted out), a span of `at` along the split of at least `2 * min` plus the gutter (the options' gap plus handle)\n * and across it of at least `min`; and in the layout of `dropOnPane(tree, dragged, at, region)` both `dragged` and\n * `at` at least `min` wide and high. That check is skipped when `area` has no width or no height. A pane that is\n * not in the tree counts as one being added; an `at` that is not in it (or is `dragged`) has no place to split.\n */\nexport function canDropOnPane<K>(tree: Split<K> | null, dragged: K, at: K, region: PaneRegion, area: Rect, options: DropOptions<K>): DropVerdict {\n if (region === \"center\") {\n if (dragged === at) return { ok: false, reason: \"center swap blocked: a pane dropped on itself\" };\n return panesOf(tree).includes(at) ? { ok: true } : { ok: false, reason: \"center rejected: no pane to swap\" };\n }\n const target = layoutSplit(removePane(tree, dragged), area, options).get(at);\n if (!target) return { ok: false, reason: `${region} rejected: no pane to split` };\n const room = canSplitPane(target, region, options);\n if (!room.ok) return room;\n return dropFits(layoutSplit(dropOnPane(tree, dragged, at, region), area, options), dragged, at, area, { min: options.min, side: region });\n}\n\n/** What `canSplitPane` reads: `min` (as in `DropOptions`) and the gutter's parts, `gap` and `handle`, px. */\nexport interface SplitRoomOptions {\n readonly min: number;\n readonly gap?: number;\n readonly handle?: number;\n}\n\n/**\n * The room rule: whether a pane of rect `target` can take another on `side`, both at least `options.min` wide and\n * high. Along the split (width for left and right, height for top and bottom) the pane needs `2 * min` plus the\n * gutter (`gap` plus `handle`), across it `min`. The rect is the pane's as the host measures it, where it will be\n * when the dragged pane is lifted out. `canDropOnPane`'s first rule, for a side.\n */\nexport function canSplitPane(target: Rect, side: Side, options: SplitRoomOptions): DropVerdict {\n const min = px(options.min);\n const gutter = px(options.gap) + px(options.handle);\n const horizontal = side === \"left\" || side === \"right\";\n const along = horizontal ? target.width : target.height;\n const across = horizontal ? target.height : target.width;\n const need = min * 2 + gutter;\n if (along < need) return { ok: false, reason: `${side} rejected: axis span ${along.toFixed(1)}px < min ${need.toFixed(1)}px (2 panes + gutter ${gutter}px)` };\n if (across < min) return { ok: false, reason: `${side} rejected: cross span ${across.toFixed(1)}px < min ${min.toFixed(1)}px` };\n return { ok: true };\n}\n\n/** What `dropFits` reads: the `min` (as in `DropOptions`) and the `side` of `at` the drop is on, for the reason. */\nexport interface DropFitsOptions {\n readonly min: number;\n readonly side: Side;\n}\n\n/**\n * The fit rule: in `projected`, the rect of every pane in the layout the drop makes (the host's own projection of\n * `dropOnPane`'s tree), whether `dragged` and `at` are both there and at least `options.min` wide and high. Fine\n * when `area` has no width or no height (there is nothing to measure). `canDropOnPane`'s last rule.\n */\nexport function dropFits<K>(projected: ReadonlyMap<K, Rect>, dragged: K, at: K, area: Rect, options: DropFitsOptions): DropVerdict {\n if (!(area.width > 0 && area.height > 0)) return { ok: true };\n const min = px(options.min);\n const fits = (r: Rect | undefined): boolean => !!r && r.width >= min && r.height >= min;\n return fits(projected.get(dragged)) && fits(projected.get(at)) ? { ok: true } : { ok: false, reason: `${options.side} rejected: projected footprint of the two panes violates min ${min}px` };\n}\n","/**\n * A pane's drop regions: a center rectangle (a drop there swaps with the pane) and four side trapezoids (a drop there\n * splits the pane on that side), formed by the diagonals from each pane corner to the nearest corner of the center.\n * The five regions cover the pane with no gaps and no overlaps.\n *\n * Meant for `@n-uf/motion/drag`'s `placeOf(target, point, previous)`: one target per pane (`paneTargets`), its place\n * the region under the pointer, the previous region held for `hysteresis` px past its boundary so a pointer resting on\n * a boundary doesn't flicker. A region that takes no drop is the consumer's to answer with a null place.\n */\nimport { clamp, type Point, type Rect, type Size } from \"../geometry\";\nimport type { Side } from \"../side\";\n\nexport type PaneRegion = \"center\" | Side;\n\n/** The sides in their tie-break order: at an exact diagonal the first wins (a corner resolves to `top`). */\nexport const PANE_SIDES: readonly Side[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\nexport interface PaneRegionOptions {\n /** The center rectangle's share of each pane axis (0.05 to 0.95); `centerX` / `centerY` override one axis. */\n readonly center?: number;\n readonly centerX?: number;\n readonly centerY?: number;\n /** The least the center spans on either axis, px (a small pane keeps a usable center). */\n readonly centerMin?: number;\n /** How far past its boundary the previous region holds, px. */\n readonly hysteresis?: number;\n /** Device pixels per px: the center's edges snap to that grid, as the browser draws them. */\n readonly pixelRatio?: number;\n /**\n * The pane's center rectangle as the host already has it (pane-local px, as `paneCenter` gives), used as it is in\n * place of measuring: `center`, `centerX`, `centerY`, `centerMin` and `pixelRatio` are not read. Only `paneRegion`\n * reads it; its `width` and `height` are the pane's own size for the hold toward the middle.\n */\n readonly paneCenter?: PaneCenter;\n}\n\nexport const PANE_REGION_DEFAULTS: Required<Omit<PaneRegionOptions, \"centerX\" | \"centerY\" | \"paneCenter\">> = { center: 0.34, centerMin: 24, hysteresis: 6, pixelRatio: 1 };\n\n/** The center rectangle of a pane of `size`, in pane-local px (origin at the pane's top-left corner). */\nexport interface PaneCenter {\n readonly width: number;\n readonly height: number;\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\nconst snap = (v: number, ratio: number): number => Math.round(v * ratio) / ratio;\n\n/** Where the center rectangle of a pane of `size` lies, by these options. */\nexport function paneCenter(size: Size, options: PaneRegionOptions = {}): PaneCenter {\n const o = { ...PANE_REGION_DEFAULTS, ...options };\n const width = Math.max(0, size.width);\n const height = Math.max(0, size.height);\n const ratio = o.pixelRatio > 0 ? o.pixelRatio : 1;\n const rx = clamp(o.centerX ?? o.center, 0.05, 0.95);\n const ry = clamp(o.centerY ?? o.center, 0.05, 0.95);\n const cw = Math.min(width, Math.max(width * rx, Math.min(o.centerMin, width)));\n const ch = Math.min(height, Math.max(height * ry, Math.min(o.centerMin, height)));\n return { width, height, left: snap((width - cw) / 2, ratio), top: snap((height - ch) / 2, ratio), right: snap((width + cw) / 2, ratio), bottom: snap((height + ch) / 2, ratio) };\n}\n\n/** How deep past the center a point is toward each side, as a share of that side's band (positive: in that band). */\nfunction depths(p: Point, c: PaneCenter): { side: Side; depth: number }[] {\n return [\n { side: \"top\", depth: (c.top - p.y) / Math.max(c.top, 1) },\n { side: \"right\", depth: (p.x - c.right) / Math.max(c.width - c.right, 1) },\n { side: \"bottom\", depth: (p.y - c.bottom) / Math.max(c.height - c.bottom, 1) },\n { side: \"left\", depth: (c.left - p.x) / Math.max(c.left, 1) },\n ];\n}\n\n/** The region a pane-local point is in, by position alone. */\nfunction rawRegion(p: Point, c: PaneCenter): PaneRegion {\n if (p.x >= c.left && p.x <= c.right && p.y >= c.top && p.y <= c.bottom) return \"center\";\n let best: PaneRegion = \"center\";\n let deepest = 0;\n for (const d of depths(p, c)) {\n if (d.depth > deepest) {\n deepest = d.depth;\n best = d.side;\n }\n }\n return best;\n}\n\n/** `p` moved `by` px into `region` (toward the pane's middle for the center). */\nfunction toward(p: Point, region: PaneRegion, by: number, c: PaneCenter): Point {\n if (region === \"left\") return { x: p.x - by, y: p.y };\n if (region === \"right\") return { x: p.x + by, y: p.y };\n if (region === \"top\") return { x: p.x, y: p.y - by };\n if (region === \"bottom\") return { x: p.x, y: p.y + by };\n const dx = c.width / 2 - p.x;\n const dy = c.height / 2 - p.y;\n const len = Math.hypot(dx, dy);\n if (len <= by || len === 0) return { x: c.width / 2, y: c.height / 2 };\n return { x: p.x + (dx / len) * by, y: p.y + (dy / len) * by };\n}\n\n/**\n * The drop region of `pane` (in the same coordinates as `point`) the point is in. With a `previous` region, the point\n * has to be `hysteresis` px past that region's boundary before the region changes: no time-based debounce, only\n * geometry. A host that has measured the center itself passes it as `options.paneCenter`; the same center gives the\n * same region as the one measured here.\n */\nexport function paneRegion(pane: Rect, point: Point, previous: PaneRegion | null = null, options: PaneRegionOptions = {}): PaneRegion {\n const c = options.paneCenter ?? paneCenter(pane, options);\n const p = { x: point.x - pane.x, y: point.y - pane.y };\n const raw = rawRegion(p, c);\n const by = Math.max(0, options.hysteresis ?? PANE_REGION_DEFAULTS.hysteresis);\n if (previous === null || by === 0 || previous === raw) return raw;\n return rawRegion(toward(p, previous, by, c), c) === previous ? previous : raw;\n}\n","/**\n * Drop targets for tiling, in the root `Target` shape (what `@n-uf/motion/drag` takes). Both kinds come from one\n * helper: a pane target (`pane:<id>`, its hit the pane, the place in it its drop region) for the split tree, and an\n * insertion target (`at:<index>`, its hit and slot the dragged pane's rect with it inserted there) for an order layout.\n */\nimport type { Rect } from \"../geometry\";\nimport type { Target } from \"../target\";\nimport type { OrderLayout, OrderOptions } from \"./order\";\n\n/** A split tree's target: drop on pane `pane` (the region under the pointer says how). */\nexport interface PaneTarget<K> extends Target {\n readonly pane: K;\n}\n\n/** An order layout's target: insert the dragged pane at `index`; `layout` is every pane's rect with it there. */\nexport interface OrderTarget<K> extends Target {\n readonly index: number;\n readonly layout: ReadonlyMap<K, Rect>;\n}\n\n/** The one shape both kinds share: a slot-sized drop with no precedence over any other. */\nconst tilingTarget = (id: string, hit: Rect, slot?: Rect): Target => ({ id, priority: 2, hit, ...(slot ? { slot } : {}) });\n\nexport interface PaneTargetsOptions<K> {\n /** A pane left out: the dragged one, when it is still laid out. */\n readonly except?: K;\n /**\n * A pane's key in its target's id (`pane:<key>`); default `String`. Keys must be unique across the panes: a drag\n * intent follows its targets by id, so two panes with one key would be one target.\n */\n readonly key?: (pane: K) => string;\n}\n\n/** One target per pane of `layout`, its id `pane:<key>`. */\nexport function paneTargets<K>(layout: ReadonlyMap<K, Rect>, options: PaneTargetsOptions<K> = {}): PaneTarget<K>[] {\n const key = options.key ?? String;\n return [...layout].filter(([k]) => k !== options.except).map(([pane, r]) => ({ ...tilingTarget(`pane:${key(pane)}`, r), pane }));\n}\n\n/**\n * One target per index `dragged` could be inserted at among `panes` (which don't hold it), laid out by `arrange` in\n * `area`. Each target's hit and slot is `dragged`'s rect with it there, so the targets cover the area as the layout\n * does. Ids are `at:<index>`, unique whatever the panes are.\n */\nexport function orderTargets<K>(arrange: OrderLayout, panes: readonly K[], dragged: K, area: Rect, options?: OrderOptions): OrderTarget<K>[] {\n return Array.from({ length: panes.length + 1 }, (_, index) => {\n const layout = arrange([...panes.slice(0, index), dragged, ...panes.slice(index)], area, options);\n const slot = layout.get(dragged)!;\n return { ...tilingTarget(`at:${index}`, slot, slot), index, layout };\n });\n}\n","import type { Rect, Size } from \"../geometry\";\n\n/**\n * The minimum-size give-way: while a pane is laid out below its minimum, the newest pane (highest `age`) floats and\n * the rest are laid out again. Stops when every pane keeps its minimum or one pane is left. `layout` lays out the\n * kept panes; the result says which are kept (in their order) and which float (newest first).\n */\nexport function giveWay<K>(panes: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (pane: K) => Size, age: (pane: K) => number): { kept: K[]; floats: K[] } {\n let kept = [...panes];\n const floats: K[] = [];\n for (;;) {\n const res = layout(kept);\n const broken = [...res].some(([k, r]) => r.width < min(k).width - 0.5 || r.height < min(k).height - 0.5);\n if (!broken || kept.length <= 1) return { kept, floats };\n const newest = kept.reduce((a, b) => (age(b) > age(a) ? b : a));\n kept = kept.filter((k) => k !== newest);\n floats.push(newest);\n }\n}\n","/**\n * The nearest pane in a direction: the rule a host moves focus by. See docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\n\n/** A direction on the plane: `\"up\"` is toward smaller y. */\nexport type Direction = \"left\" | \"right\" | \"up\" | \"down\";\n\n/**\n * The pane nearest `from` in `direction`, or null when none lies that way. A candidate's center has to be strictly on\n * that side of `from`'s center. Its score is the center distance along the direction, plus a quarter of the center\n * distance across it, plus 100 when it does not overlap `from` across the direction (the overlap strictly above 0);\n * the lowest score wins, ties to the first in the map's order. A pane that is not in `rects` has no neighbor.\n *\n * The host chooses which rects to pass. One option: lay the tree out in a unit square (`{ x: 0, y: 0, width: 1,\n * height: 1 }`) with the host's px floors. A floor of tens of px cannot fit in a unit square, so a split's two floors\n * cannot both fit and it lays out at 0.5 whatever its ratio; fixed lengths in px along a split do not fit either, and\n * the area's size and the gap drop out. Fixed lengths across a split are not checked against the cross extent, so\n * they still apply in a unit square, and a host leaves `fixedAcross` out there. The rects of the real layout work too.\n */\nexport function neighbor<K>(rects: ReadonlyMap<K, Rect>, from: K, direction: Direction): K | null {\n const origin = rects.get(from);\n if (!origin) return null;\n const horizontal = direction === \"left\" || direction === \"right\";\n // Centers and ends as sums of edges (right = x + width), so a host that keeps edge rects gets the same bits.\n const center = (r: Rect, x: boolean): number => (x ? (r.x + (r.x + r.width)) / 2 : (r.y + (r.y + r.height)) / 2);\n const reach = (r: Rect, x: boolean): [number, number] => (x ? [r.x, r.x + r.width] : [r.y, r.y + r.height]);\n const fromAlong = center(origin, horizontal);\n const fromAcross = center(origin, !horizontal);\n const [originStart, originEnd] = reach(origin, !horizontal);\n const sign = direction === \"left\" || direction === \"up\" ? -1 : 1;\n let best: K | null = null;\n let bestScore = Number.POSITIVE_INFINITY;\n for (const [key, r] of rects) {\n if (key === from) continue;\n const along = center(r, horizontal);\n if (sign < 0 ? along >= fromAlong : along <= fromAlong) continue;\n const [start, end] = reach(r, !horizontal);\n const overlap = Math.max(0, Math.min(originEnd, end) - Math.max(originStart, start));\n const score = Math.abs(along - fromAlong) + Math.abs(center(r, !horizontal) - fromAcross) * 0.25 + (overlap > 0 ? 0 : 100);\n if (score < bestScore) {\n bestScore = score;\n best = key;\n }\n }\n return best;\n}\n"],"mappings":";;;;;AAmCO,IAAM,cAAc,CAAC,MAAmC,MAAM,UAAa,CAAC,OAAO,SAAS,CAAC,IAAI,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM,CAAC,CAAC;AAGvI,SAAS,YAAY,OAA2B,GAAmB;AACxE,QAAM,IAAI,KAAK,MAAM,SAAS,CAAC;AAC/B,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AACtE;AAGA,SAAS,OAAU,OAAqB,GAAW,GAAW,OAAe,QAAgB,UAAmB,KAAa,KAAyB;AACpJ,QAAM,I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AK;AAC/D,MAAI,OAAiB;AACrB,MAAI,YAAY,OAAO;AACvB,aAAW,CAAC,KAAK,CAAC,KAAK,OAAO;AAC5B,QAAI,QAAQ,KAAM;AAClB,UAAM,QAAQ,OAAO,GAAG,UAAU;AAClC,QAAI,OAAO,IAAI,SAAS,YAAY,SAAS,UAAW;AACxD,UAAM,CAAC,OAAO,GAAG,IAAI,MAAM,GAAG,CAAC,UAAU;AACzC,UAAM,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,GAAG,IAAI,KAAK,IAAI,aAAa,KAAK,CAAC;AACnF,UAAM,QAAQ,KAAK,IAAI,QAAQ,SAAS,IAAI,KAAK,IAAI,OAAO,GAAG,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,UAAU,IAAI,IAAI;AACtH,QAAI,QAAQ,WAAW;AACrB,kBAAY;AACZ,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":["px"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n-uf/placement",
|
|
3
|
-
"version": "26.11.
|
|
3
|
+
"version": "26.11.57",
|
|
4
4
|
"description": "Where things fit: the stage cut into edge bands, the items along one edge fitted with their forms, one edge's drop places, floats kept clear, panes tiled and popups positioned. Pure geometry in, rects out. No DOM, no framework, no motion.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"layout",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"build": "tsup && node ./scripts/check-dist.mjs",
|
|
64
64
|
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.test.json",
|
|
65
65
|
"test": "vitest run",
|
|
66
|
+
"bench": "vitest bench --run",
|
|
66
67
|
"check": "pnpm typecheck && pnpm test && pnpm build"
|
|
67
68
|
},
|
|
68
69
|
"main": "./dist/index.js",
|