@n-uf/placement 26.12.8 → 26.12.9
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 +21 -0
- package/dist/tiling.d.ts +23 -8
- package/dist/tiling.js +76 -20
- package/dist/tiling.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ Versions are calendar versions, `YY.M.R` (year, month of the release, counter wi
|
|
|
5
5
|
|
|
6
6
|
Unreleased entries live in `changes/` until a release joins them.
|
|
7
7
|
|
|
8
|
+
## 26.12.9
|
|
9
|
+
|
|
10
|
+
- **Changed (breaking in behavior, not in types):** under a fold, the hit on the base basis reads a strip from the
|
|
11
|
+
frame on screen, and the strip moves nothing. That frame follows the hold: the base with nothing held, the lift at
|
|
12
|
+
home, `after(held)` for a held place. Over a rail of it, `hold(state, point)` gives `state` back and `read.folded`
|
|
13
|
+
names the pane painted there, so home stays home (a release puts the pane back), a held place stays held (a release
|
|
14
|
+
commits it as previewed) and nothing stays nothing. Before, only the base's rails took no drop: a strip painted at
|
|
15
|
+
home or in a preview, over a pane the base opens (releasing the held pane can open a pane folded beside it, or move
|
|
16
|
+
a rail), offered a drop there. The lift basis is unchanged: over its rails nothing is held. Off the strips of the
|
|
17
|
+
frame on screen, the hold is the basis's zone map as before: on the base basis the open panes are tested against the
|
|
18
|
+
base while another frame may be painted. Without `fold`, nothing changes.
|
|
19
|
+
- **Changed:** `TilingDragOptions.railOffset` is asked at every read with the folds of the frame drawn for the hold
|
|
20
|
+
(before: the lift's alone, and on the base basis never), with the fold heading the rail and its index in that
|
|
21
|
+
frame's `folds`. A host whose frames differ keys each rail by its fold's `id` (a fold with no `id` has no key that
|
|
22
|
+
stays the same across frames), and passes the hold whose frame is painted. `hit.foldedAt(point)` keeps its shape: it answers with nothing held (the base on the base basis, now at the
|
|
23
|
+
host's offsets), and is pure; during a drag the strip under the pointer is `read(...).folded`.
|
|
24
|
+
- **Changed:** the hit conformance's `spine-no-place` is checked per hold and the frame drawn for it: over that frame's
|
|
25
|
+
rails the read names the painted pane, the frame stays, a second step changes nothing, a release gives what the
|
|
26
|
+
frame shows, and with nothing held there is no place. A host adapter that passed it before may now report a strip
|
|
27
|
+
painted at home or in a preview that offered a place.
|
|
28
|
+
|
|
8
29
|
## 26.12.8
|
|
9
30
|
|
|
10
31
|
- **Changed:** `tilingDrag`, `tilingConformance` and `tilingHitConformance` take a `fold` key; in 26.12.7 they threw
|
package/dist/tiling.d.ts
CHANGED
|
@@ -719,6 +719,13 @@ interface TilingAfter<T, K> extends TilingLaidOut<T, K> {
|
|
|
719
719
|
* included, null when nothing is held outside home), the refused place under the pointer when nothing is held, and, on
|
|
720
720
|
* the lift basis, the mark: a region of the lift layout (the target's half for a side, its outline for a swap or a
|
|
721
721
|
* join, and for a swap the wash in the open slot), never an `after` rect.
|
|
722
|
+
* - **A painted strip is read as painted and moves nothing** (under a fold). The frame on screen is the lift on the lift
|
|
723
|
+
* basis; on the base basis it follows the hold: the base with nothing held, the lift at home, `after(held)` for a
|
|
724
|
+
* place. Over a rail of that frame, at the host's offset, the read names the pane painted there and the frame stays:
|
|
725
|
+
* on the lift basis nothing is held (the lift is drawn whatever is held), on the base basis the hold stays as it was
|
|
726
|
+
* (home stays home, a held place stays held and a release commits it as previewed, nothing stays nothing). Off the
|
|
727
|
+
* frame's rails the hold follows the basis's zone map. So on the base basis the open panes are tested against the
|
|
728
|
+
* base while another frame may be painted; only a painted strip is read from the frame on screen.
|
|
722
729
|
*
|
|
723
730
|
* See docs/placement.md, Entry: tiling, "A tiling drag's hit half".
|
|
724
731
|
*/
|
|
@@ -814,7 +821,11 @@ interface TilingHitRead<K> {
|
|
|
814
821
|
readonly refused: TilingHeld<K> | null;
|
|
815
822
|
/** The lift basis's mark for the held place; null on the base basis, at home, and with nothing held. */
|
|
816
823
|
readonly mark: TilingMark<K> | null;
|
|
817
|
-
/**
|
|
824
|
+
/**
|
|
825
|
+
* Under a fold, the rail under the pointer in the frame drawn for the hold the read started from, and the pane
|
|
826
|
+
* painted there; null off every rail of that frame. There the frame stays: nothing is held on the lift basis, and on
|
|
827
|
+
* the base basis the hold is the one the read started from.
|
|
828
|
+
*/
|
|
818
829
|
readonly folded: TilingFolded<K> | null;
|
|
819
830
|
}
|
|
820
831
|
/**
|
|
@@ -863,9 +874,9 @@ interface TilingHit<T, K> {
|
|
|
863
874
|
/** The intent's frame at `point`, read: the held place, the refused one, the lift basis's mark, and the rail under the pointer. */
|
|
864
875
|
read(frame: TilingHitFrame<TilingHitTarget<K>>, point: Point): TilingHitRead<K>;
|
|
865
876
|
/**
|
|
866
|
-
* Under a fold, the rail of the basis's layout whose box holds `point`, and
|
|
867
|
-
*
|
|
868
|
-
*
|
|
877
|
+
* Under a fold, with nothing held: the rail of the frame drawn then (the basis's layout) whose box holds `point`, and
|
|
878
|
+
* the pane painted there at the drag's `railOffset`, read anew at every call; null off every rail. Pure. During a drag
|
|
879
|
+
* the strip under the pointer is `read(...).folded`, read from the frame drawn for the hold.
|
|
869
880
|
*/
|
|
870
881
|
foldedAt(point: Point): TilingFolded<K> | null;
|
|
871
882
|
/** What a frame draws: the lift on the lift basis; on the base basis `after(held)`, the lift at home, the base with nothing held. */
|
|
@@ -946,10 +957,14 @@ interface TilingDragOptions<T, K> extends DropOptions<K>, FoldingSplitOptions<K>
|
|
|
946
957
|
readonly still?: (pane: K) => boolean;
|
|
947
958
|
/**
|
|
948
959
|
* Under a fold whose rails' content runs past their boxes (`SplitFold.segmentFloor`), how far the host has moved each
|
|
949
|
-
* rail of the
|
|
950
|
-
*
|
|
951
|
-
*
|
|
952
|
-
*
|
|
960
|
+
* rail of the frame it draws (`RailOffset`): asked with the folds of the frame drawn for the hold being read (the
|
|
961
|
+
* lift on the lift basis; on the base basis the base with nothing held, the lift at home, `after(held)` for a place),
|
|
962
|
+
* the fold heading the rail and its index in that frame's `folds`. The index is that frame's own, so a host whose
|
|
963
|
+
* frames differ keys each rail by the fold's `id` (the folded split's own `id`); a fold with no `id` has no key that
|
|
964
|
+
* stays the same across frames. Read at every hit read
|
|
965
|
+
* (`hit.read`, `hit.foldedAt`), never kept: an offset change, and every change of the frame drawn, is a reason to read
|
|
966
|
+
* again. Pass the hold whose frame is painted: a read between a hold change and its paint asks for rails not drawn
|
|
967
|
+
* yet. Not clamped; a value that is not a finite number reads 0. Default: 0 everywhere.
|
|
953
968
|
*/
|
|
954
969
|
readonly railOffset?: RailOffset<K>;
|
|
955
970
|
}
|
package/dist/tiling.js
CHANGED
|
@@ -1189,10 +1189,11 @@ function createTilingHit(ctx, basis, options = {}) {
|
|
|
1189
1189
|
const drawnAs = (t, k) => stackOf(t, k)?.active ?? k;
|
|
1190
1190
|
const subjectDrawn = drawnAs(lift.tree, ctx.subjectKey);
|
|
1191
1191
|
const baseFolded = new Set(base.folds.flatMap((f) => f.panes));
|
|
1192
|
-
const
|
|
1193
|
-
const
|
|
1194
|
-
const
|
|
1195
|
-
const
|
|
1192
|
+
const offsets = ctx.railOffset;
|
|
1193
|
+
const onRailOf = (frame, p) => frame.folds.some((f, i) => f.railOf === i && inside(f.rail, p));
|
|
1194
|
+
const onRail = (p) => onRailOf(laid, p);
|
|
1195
|
+
const foldedIn = (frame, p) => onRailOf(frame, p) ? railAt(frame, p, offsets) : null;
|
|
1196
|
+
const foldedAt = (p) => foldedIn(laid, p);
|
|
1196
1197
|
const atOf = (pane) => {
|
|
1197
1198
|
if (base.layout.has(pane) || baseFolded.has(pane)) return pane;
|
|
1198
1199
|
const members = stackOf(laid.tree, pane)?.members ?? [];
|
|
@@ -1396,7 +1397,15 @@ function createTilingHit(ctx, basis, options = {}) {
|
|
|
1396
1397
|
if (rx <= 0 || ry <= 0) return false;
|
|
1397
1398
|
return ((p.x - from.x) / rx) ** 2 + ((p.y - from.y) / ry) ** 2 < 1;
|
|
1398
1399
|
};
|
|
1400
|
+
const frameOf = (state2) => {
|
|
1401
|
+
if (basis === "lift") return lift;
|
|
1402
|
+
if (state2 === null) return base;
|
|
1403
|
+
if (state2.place === "home") return lift;
|
|
1404
|
+
const place = byId.get(state2.place);
|
|
1405
|
+
return place ? after(place.held) : base;
|
|
1406
|
+
};
|
|
1399
1407
|
const hold = (state2, p) => {
|
|
1408
|
+
if (onRailOf(frameOf(state2), p)) return basis === "lift" ? null : state2;
|
|
1400
1409
|
if (onRail(p)) return null;
|
|
1401
1410
|
const now = effective(rawAt(p).place);
|
|
1402
1411
|
if (state2) {
|
|
@@ -1407,9 +1416,11 @@ function createTilingHit(ctx, basis, options = {}) {
|
|
|
1407
1416
|
return now ? { place: now.id, from: { x: p.x, y: p.y } } : null;
|
|
1408
1417
|
};
|
|
1409
1418
|
let state = null;
|
|
1419
|
+
let stepFrom = null;
|
|
1410
1420
|
let last = null;
|
|
1411
1421
|
const current = (p) => {
|
|
1412
1422
|
if (!last || last.x !== p.x || last.y !== p.y) {
|
|
1423
|
+
stepFrom = state;
|
|
1413
1424
|
state = hold(state, p);
|
|
1414
1425
|
last = { x: p.x, y: p.y };
|
|
1415
1426
|
}
|
|
@@ -1430,10 +1441,12 @@ function createTilingHit(ctx, basis, options = {}) {
|
|
|
1430
1441
|
const read = (frame, p) => {
|
|
1431
1442
|
const s = current(p);
|
|
1432
1443
|
const place = s ? byId.get(s.place) ?? null : null;
|
|
1433
|
-
const
|
|
1444
|
+
const folded = foldedIn(frameOf(stepFrom), p);
|
|
1445
|
+
const kept = folded !== null && basis === "base";
|
|
1446
|
+
const shown = place && place !== homePlace && (kept || frame.shown && place.owners.has(frame.shown.id)) ? place : null;
|
|
1434
1447
|
const held = place === homePlace ? HOME : shown?.held ?? null;
|
|
1435
|
-
const refused = held ? null : rawAt(p).refused?.held ?? null;
|
|
1436
|
-
return { held, refused, mark: basis === "lift" && shown ? markOf(shown) : null, folded
|
|
1448
|
+
const refused = held || folded ? null : rawAt(p).refused?.held ?? null;
|
|
1449
|
+
return { held, refused, mark: basis === "lift" && shown ? markOf(shown) : null, folded };
|
|
1437
1450
|
};
|
|
1438
1451
|
return {
|
|
1439
1452
|
basis,
|
|
@@ -1967,9 +1980,12 @@ var TILING_HIT_PROPERTIES = [
|
|
|
1967
1980
|
*/
|
|
1968
1981
|
"room-free-map",
|
|
1969
1982
|
/**
|
|
1970
|
-
* Under a fold, a
|
|
1971
|
-
* (
|
|
1972
|
-
* rail
|
|
1983
|
+
* Under a fold, a painted strip is read as painted and moves nothing, in every frame: for each hold and the frame drawn
|
|
1984
|
+
* for it (the lift on the lift basis; on the base basis the base with nothing held, the lift at home, `after(held)`),
|
|
1985
|
+
* every point of that frame's rail boxes (edges included) reads `folded` with that rail and the pane painted there
|
|
1986
|
+
* (`paintedSpines` at the drag's rail offsets), null in a gap; the frame stays (the lift basis holds nothing, the base
|
|
1987
|
+
* basis keeps the hold), a second step changes nothing, a release gives what the frame shows, nothing is refused, and
|
|
1988
|
+
* with nothing held there is no place.
|
|
1973
1989
|
*/
|
|
1974
1990
|
"spine-no-place",
|
|
1975
1991
|
/**
|
|
@@ -2402,14 +2418,38 @@ function tilingHitConformance(trees, options, hitOptions = {}, limit = 20) {
|
|
|
2402
2418
|
if (!taken || taken.place === "home") continue;
|
|
2403
2419
|
const kept = hit.hold(taken, p);
|
|
2404
2420
|
if (kept?.place !== taken.place || hit.placeAt(p) === taken.place) continue;
|
|
2421
|
+
const shownFrame = basis === "lift" ? drag.lift : drag.after(hit.heldOf(taken.place));
|
|
2422
|
+
if (shownFrame.folds.some((f, i) => f.railOf === i && inside2(f.rail, p))) continue;
|
|
2405
2423
|
if (!(home && inside2(home, p)) && Math.abs(p.x - taken.from.x) < travel && Math.abs(p.y - taken.from.y) < travel) continue;
|
|
2406
2424
|
if (probed++ >= 24) break;
|
|
2407
2425
|
check("hold-measures", shows(p, taken.place), () => `${taken.place} taken at ${q.x.toFixed(1)},${q.y.toFixed(1)} is kept at ${p.x.toFixed(1)},${p.y.toFixed(1)}, past both measures (the map reads ${hit.placeAt(p)})`);
|
|
2408
2426
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2427
|
+
const frameFor = (s) => basis === "lift" ? drag.lift : s === null ? drag.base : s.place === "home" ? drag.lift : drag.after(hit.heldOf(s.place));
|
|
2428
|
+
const holdStates = [null];
|
|
2429
|
+
if (home) holdStates.push({ place: "home", from: { x: home.x + home.width / 2, y: home.y + home.height / 2 } });
|
|
2430
|
+
const heldPlaces = /* @__PURE__ */ new Set();
|
|
2431
|
+
for (const q of samples) {
|
|
2432
|
+
if (heldPlaces.size >= 6) break;
|
|
2433
|
+
const s = hit.hold(null, q);
|
|
2434
|
+
if (s && s.place !== "home" && !heldPlaces.has(s.place)) {
|
|
2435
|
+
heldPlaces.add(s.place);
|
|
2436
|
+
holdStates.push(s);
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
for (const s of holdStates) {
|
|
2440
|
+
const F = frameFor(s);
|
|
2441
|
+
const railsOfF = F.folds.map((f, i) => ({ f, i })).filter(({ f, i }) => f.railOf === i);
|
|
2442
|
+
if (railsOfF.length === 0) continue;
|
|
2443
|
+
const painted = paintedSpines(F, options.railOffset);
|
|
2444
|
+
const enter = () => {
|
|
2445
|
+
frame(FAR);
|
|
2446
|
+
if (s === null) return true;
|
|
2447
|
+
const r = frame(s.from);
|
|
2448
|
+
return s.place === "home" ? r.held?.kind === "home" : r.held !== null && show2(r.held) === show2(hit.heldOf(s.place));
|
|
2449
|
+
};
|
|
2450
|
+
const keeps = basis === "lift" ? null : s;
|
|
2451
|
+
const wantHeld = keeps === null ? null : keeps.place === "home" ? HOME2 : hit.heldOf(keeps.place);
|
|
2452
|
+
for (const { f, i } of railsOfF) {
|
|
2413
2453
|
const r = f.rail;
|
|
2414
2454
|
const points = [
|
|
2415
2455
|
{ x: r.x, y: r.y },
|
|
@@ -2419,18 +2459,34 @@ function tilingHitConformance(trees, options, hitOptions = {}, limit = 20) {
|
|
|
2419
2459
|
];
|
|
2420
2460
|
for (let k = 0; k < 16; k++) points.push(randomPoint(r));
|
|
2421
2461
|
for (const p of points) {
|
|
2422
|
-
const want = [...painted].find(([pane,
|
|
2423
|
-
const
|
|
2424
|
-
const
|
|
2462
|
+
const want = [...painted].find(([pane, q]) => F.folds.some((g) => g.railOf === i && g.panes.includes(pane)) && inside2(q, p))?.[0] ?? null;
|
|
2463
|
+
const step = hit.hold(s, p);
|
|
2464
|
+
const again = hit.hold(step, p);
|
|
2465
|
+
const where = `rail ${i} of the frame for ${s ? s.place : "nothing"} at ${p.x.toFixed(1)},${p.y.toFixed(1)}`;
|
|
2466
|
+
check(
|
|
2467
|
+
"spine-no-place",
|
|
2468
|
+
sameHold(step, keeps) && sameHold(again, keeps) && (s !== null || hit.placeAt(p) === null),
|
|
2469
|
+
() => `${where}: the hold went to ${holdName(step)}, then ${holdName(again)}; it stays ${holdName(keeps)} (place with nothing held: ${hit.placeAt(p)})`
|
|
2470
|
+
);
|
|
2471
|
+
if (!enter()) continue;
|
|
2472
|
+
const read = frame(p);
|
|
2473
|
+
const second = frame(p);
|
|
2474
|
+
check(
|
|
2475
|
+
"spine-no-place",
|
|
2476
|
+
show2(read.held) === show2(wantHeld) && read.refused === null && hit.drawn(read) === F && JSON.stringify(second) === JSON.stringify(read),
|
|
2477
|
+
() => `${where}: held ${show2(read.held)} (stays ${show2(wantHeld)}), refused ${show2(read.refused)}, the frame ${hit.drawn(read) === F ? "stays" : "moved"}`
|
|
2478
|
+
);
|
|
2479
|
+
const rel = hit.release(read);
|
|
2425
2480
|
check(
|
|
2426
2481
|
"spine-no-place",
|
|
2427
|
-
|
|
2428
|
-
() =>
|
|
2482
|
+
wantHeld === null || wantHeld.kind === "home" ? rel.tree === drag.lift.tree : rel === drag.after(wantHeld),
|
|
2483
|
+
() => `${where}: a release commits ${show2(rel.held)}, the frame shows ${show2(wantHeld)}`
|
|
2429
2484
|
);
|
|
2485
|
+
const at = s === null ? hit.foldedAt(p) : read.folded;
|
|
2430
2486
|
check(
|
|
2431
2487
|
"spine-no-place",
|
|
2432
2488
|
read.folded?.rail === i && read.folded.pane === want && at?.rail === i && at.pane === want,
|
|
2433
|
-
() =>
|
|
2489
|
+
() => `${where}: reads ${JSON.stringify(read.folded)}, foldedAt ${JSON.stringify(at)}, painted ${String(want)}`
|
|
2434
2490
|
);
|
|
2435
2491
|
}
|
|
2436
2492
|
}
|