@n-uf/placement 26.12.8 → 26.12.10

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 CHANGED
@@ -5,6 +5,37 @@ 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.10
9
+
10
+ - **Changed (breaking in behavior, not in types):** under a fold, on the base basis, a pane you see folded takes no
11
+ drop: the hold does not change to a place of a pane drawn as a strip at the lift and in the frame drawn for the hold,
12
+ unless it already holds a place of that pane; there the hold and its frame stay. Before, a pointer on its way to a
13
+ strip took a place of that pane a few px early, and its preview moved the strip away. The place below such a pane is
14
+ no longer reached from home; it still is with nothing held, or once the pane is drawn open.
15
+ - **Changed:** the hit conformance's `hold-measures` no longer counts a kept place as past both measures where the
16
+ map's place names a pane drawn as a strip at the lift and in the kept place's frame.
17
+
18
+ ## 26.12.9
19
+
20
+ - **Changed (breaking in behavior, not in types):** under a fold, the hit on the base basis reads a strip from the
21
+ frame on screen, and the strip moves nothing. That frame follows the hold: the base with nothing held, the lift at
22
+ home, `after(held)` for a held place. Over a rail of it, `hold(state, point)` gives `state` back and `read.folded`
23
+ names the pane painted there, so home stays home (a release puts the pane back), a held place stays held (a release
24
+ commits it as previewed) and nothing stays nothing. Before, only the base's rails took no drop: a strip painted at
25
+ home or in a preview, over a pane the base opens (releasing the held pane can open a pane folded beside it, or move
26
+ a rail), offered a drop there. The lift basis is unchanged: over its rails nothing is held. Off the strips of the
27
+ frame on screen, the hold is the basis's zone map as before: on the base basis the open panes are tested against the
28
+ base while another frame may be painted. Without `fold`, nothing changes.
29
+ - **Changed:** `TilingDragOptions.railOffset` is asked at every read with the folds of the frame drawn for the hold
30
+ (before: the lift's alone, and on the base basis never), with the fold heading the rail and its index in that
31
+ 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
32
+ 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
33
+ host's offsets), and is pure; during a drag the strip under the pointer is `read(...).folded`.
34
+ - **Changed:** the hit conformance's `spine-no-place` is checked per hold and the frame drawn for it: over that frame's
35
+ rails the read names the painted pane, the frame stays, a second step changes nothing, a release gives what the
36
+ frame shows, and with nothing held there is no place. A host adapter that passed it before may now report a strip
37
+ painted at home or in a preview that offered a place.
38
+
8
39
  ## 26.12.8
9
40
 
10
41
  - **Changed:** `tilingDrag`, `tilingConformance` and `tilingHitConformance` take a `fold` key; in 26.12.7 they threw
package/dist/tiling.d.ts CHANGED
@@ -719,6 +719,19 @@ 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.
729
+ * - **A pane you see folded takes no drop** (under a fold, on the base basis). The hold does not change to a place
730
+ * whose pane is a strip both at the lift and in the frame drawn for the hold, unless the hold is already a place of
731
+ * that pane; where such a place is refused the hold stays as it is, and so does its frame. Off the strip the read
732
+ * names no strip (`folded` is null). It is one check on the place's pane, no geometry: a pane open at the lift, a
733
+ * pane the frame draws open (with nothing held the base is drawn), the lift basis and a layout without a fold are
734
+ * held as before. So the place beside such a pane is reached only from a frame that draws it open.
722
735
  *
723
736
  * See docs/placement.md, Entry: tiling, "A tiling drag's hit half".
724
737
  */
@@ -814,7 +827,11 @@ interface TilingHitRead<K> {
814
827
  readonly refused: TilingHeld<K> | null;
815
828
  /** The lift basis's mark for the held place; null on the base basis, at home, and with nothing held. */
816
829
  readonly mark: TilingMark<K> | null;
817
- /** Under a fold, the rail under the pointer and the pane painted there (`hit.foldedAt`); null off every rail. Nothing is held over a rail. */
830
+ /**
831
+ * Under a fold, the rail under the pointer in the frame drawn for the hold the read started from, and the pane
832
+ * painted there; null off every rail of that frame. There the frame stays: nothing is held on the lift basis, and on
833
+ * the base basis the hold is the one the read started from.
834
+ */
818
835
  readonly folded: TilingFolded<K> | null;
819
836
  }
820
837
  /**
@@ -850,7 +867,11 @@ interface TilingHit<T, K> {
850
867
  readonly intent: TilingHitIntent<K>;
851
868
  /** The zone map: the place id at `point` with nothing held (`"home"` for home), or null. Pure. */
852
869
  placeAt(point: Point): string | null;
853
- /** The hold rule: what is held at `point` after `state` (null: nothing held yet). Pure: a host with no intent steps it itself. */
870
+ /**
871
+ * The hold rule: what is held at `point` after `state` (null: nothing held yet). Pure: a host with no intent steps it
872
+ * itself. On the base basis it never changes to a place of a pane drawn as a strip at the lift and in the frame drawn
873
+ * for `state`, unless `state` is already a place of that pane; there it stays `state`.
874
+ */
854
875
  hold(state: TilingHold | null, point: Point): TilingHold | null;
855
876
  /** The place an id names (hosts never parse ids). */
856
877
  heldOf(id: string): TilingHeld<K> | null;
@@ -863,9 +884,9 @@ interface TilingHit<T, K> {
863
884
  /** 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
885
  read(frame: TilingHitFrame<TilingHitTarget<K>>, point: Point): TilingHitRead<K>;
865
886
  /**
866
- * Under a fold, the rail of the basis's layout whose box holds `point`, and the pane painted there; null off every
867
- * rail. On the lift basis the rails are painted at the drag's `railOffset`, read anew at every call; on the base
868
- * basis at none. Pure.
887
+ * Under a fold, with nothing held: the rail of the frame drawn then (the basis's layout) whose box holds `point`, and
888
+ * the pane painted there at the drag's `railOffset`, read anew at every call; null off every rail. Pure. During a drag
889
+ * the strip under the pointer is `read(...).folded`, read from the frame drawn for the hold.
869
890
  */
870
891
  foldedAt(point: Point): TilingFolded<K> | null;
871
892
  /** 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 +967,14 @@ interface TilingDragOptions<T, K> extends DropOptions<K>, FoldingSplitOptions<K>
946
967
  readonly still?: (pane: K) => boolean;
947
968
  /**
948
969
  * Under a fold whose rails' content runs past their boxes (`SplitFold.segmentFloor`), how far the host has moved each
949
- * rail of the lift layout (`RailOffset`): asked only with the lift's folds, the fold heading the rail and its index
950
- * (the lift is `layoutSplitTree`'s answer for the same input, so the index is the host's key, not the fold's `id`,
951
- * which may be undefined). Read at every hit read (`hit.read`, `hit.foldedAt`), never kept: an offset change is a
952
- * reason to read again. Not clamped; a value that is not a finite number reads 0. Default: 0 everywhere.
970
+ * rail of the frame it draws (`RailOffset`): asked with the folds of the frame drawn for the hold being read (the
971
+ * lift on the lift basis; on the base basis the base with nothing held, the lift at home, `after(held)` for a place),
972
+ * the fold heading the rail and its index in that frame's `folds`. The index is that frame's own, so a host whose
973
+ * 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
974
+ * stays the same across frames. Read at every hit read
975
+ * (`hit.read`, `hit.foldedAt`), never kept: an offset change, and every change of the frame drawn, is a reason to read
976
+ * again. Pass the hold whose frame is painted: a read between a hold change and its paint asks for rails not drawn
977
+ * yet. Not clamped; a value that is not a finite number reads 0. Default: 0 everywhere.
953
978
  */
954
979
  readonly railOffset?: RailOffset<K>;
955
980
  }
@@ -975,7 +1000,9 @@ interface TilingDrag<T, K> {
975
1000
  * The drag's hit half on `basis`, built from that one layout and fixed for the drag: `"lift"` for a host that draws
976
1001
  * marks over the lift, `"base"` for one that draws the held place's landed layout. Remembered per basis, as `after` is
977
1002
  * per place: every call on one basis gives the same hit, with its one hold, and the first call's options stand. A
978
- * fresh hold is the pure `hit.hold(state, point)`.
1003
+ * fresh hold is the pure `hit.hold(state, point)`. Under a fold, on the base basis, a pane you see folded takes no
1004
+ * drop: the hold does not change to a place of a pane drawn as a strip at the lift and in the frame drawn for the
1005
+ * hold, unless it already holds a place of that pane.
979
1006
  */
980
1007
  hit(basis: TilingBasis, options?: TilingHitOptions<K>): TilingHit<T, K>;
981
1008
  }
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 railBoxes = laid.folds.filter((f, i) => f.railOf === i).map((f) => f.rail);
1193
- const onRail = (p) => railBoxes.some((r) => inside(r, p));
1194
- const offsets = basis === "lift" ? ctx.railOffset : void 0;
1195
- const foldedAt = (p) => onRail(p) ? railAt(laid, p, offsets) : null;
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,24 @@ 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
+ };
1407
+ const paneOf = (place) => place.held.kind === "home" ? null : place.held.at;
1408
+ const seenFolded = (state2, place) => {
1409
+ if (basis !== "base") return false;
1410
+ const pane = paneOf(place);
1411
+ if (pane === null || !lift.spines.has(pane)) return false;
1412
+ const held = state2 === null ? null : byId.get(state2.place);
1413
+ if (held && paneOf(held) === pane) return false;
1414
+ return frameOf(state2).spines.has(pane);
1415
+ };
1399
1416
  const hold = (state2, p) => {
1417
+ if (onRailOf(frameOf(state2), p)) return basis === "lift" ? null : state2;
1400
1418
  if (onRail(p)) return null;
1401
1419
  const now = effective(rawAt(p).place);
1402
1420
  if (state2) {
@@ -1404,12 +1422,15 @@ function createTilingHit(ctx, basis, options = {}) {
1404
1422
  const held = byId.get(state2.place);
1405
1423
  if (held && (near2(held, p) || keepsByTravel(held, state2.from, p))) return state2;
1406
1424
  }
1425
+ if (now && seenFolded(state2, now)) return state2;
1407
1426
  return now ? { place: now.id, from: { x: p.x, y: p.y } } : null;
1408
1427
  };
1409
1428
  let state = null;
1429
+ let stepFrom = null;
1410
1430
  let last = null;
1411
1431
  const current = (p) => {
1412
1432
  if (!last || last.x !== p.x || last.y !== p.y) {
1433
+ stepFrom = state;
1413
1434
  state = hold(state, p);
1414
1435
  last = { x: p.x, y: p.y };
1415
1436
  }
@@ -1430,10 +1451,12 @@ function createTilingHit(ctx, basis, options = {}) {
1430
1451
  const read = (frame, p) => {
1431
1452
  const s = current(p);
1432
1453
  const place = s ? byId.get(s.place) ?? null : null;
1433
- const shown = place && place !== homePlace && frame.shown && place.owners.has(frame.shown.id) ? place : null;
1454
+ const folded = foldedIn(frameOf(stepFrom), p);
1455
+ const kept = folded !== null && basis === "base";
1456
+ const shown = place && place !== homePlace && (kept || frame.shown && place.owners.has(frame.shown.id)) ? place : null;
1434
1457
  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: foldedAt(p) };
1458
+ const refused = held || folded ? null : rawAt(p).refused?.held ?? null;
1459
+ return { held, refused, mark: basis === "lift" && shown ? markOf(shown) : null, folded };
1437
1460
  };
1438
1461
  return {
1439
1462
  basis,
@@ -1938,7 +1961,8 @@ var TILING_HIT_PROPERTIES = [
1938
1961
  /**
1939
1962
  * A path within the edge measure of the held zone's visible part, or inside its pane (not over home) within the travel
1940
1963
  * measure of where it was taken, never changes the place; and a point past both (over home's rim on the base included,
1941
- * where a zone runs on beneath home) reads the zone map.
1964
+ * where a zone runs on beneath home) reads the zone map, unless the map's place there names a pane drawn as a strip at
1965
+ * the lift and in the frame drawn for the place (a pane you see folded takes no drop).
1942
1966
  */
1943
1967
  "hold-measures",
1944
1968
  /** A straight sweep meets each place but home (which shows nothing) at most once. */
@@ -1967,9 +1991,12 @@ var TILING_HIT_PROPERTIES = [
1967
1991
  */
1968
1992
  "room-free-map",
1969
1993
  /**
1970
- * Under a fold, a rail takes no drop: every point of a rail's box (its edges included) has no place, holds nothing
1971
- * (whatever was held), and reads `folded` with that rail and the pane painted there (`paintedSpines` at the drag's
1972
- * rail offsets on the lift basis, none on the base), null in a gap.
1994
+ * Under a fold, a painted strip is read as painted and moves nothing, in every frame: for each hold and the frame drawn
1995
+ * for it (the lift on the lift basis; on the base basis the base with nothing held, the lift at home, `after(held)`),
1996
+ * every point of that frame's rail boxes (edges included) reads `folded` with that rail and the pane painted there
1997
+ * (`paintedSpines` at the drag's rail offsets), null in a gap; the frame stays (the lift basis holds nothing, the base
1998
+ * basis keeps the hold), a second step changes nothing, a release gives what the frame shows, nothing is refused, and
1999
+ * with nothing held there is no place.
1973
2000
  */
1974
2001
  "spine-no-place",
1975
2002
  /**
@@ -2402,14 +2429,41 @@ function tilingHitConformance(trees, options, hitOptions = {}, limit = 20) {
2402
2429
  if (!taken || taken.place === "home") continue;
2403
2430
  const kept = hit.hold(taken, p);
2404
2431
  if (kept?.place !== taken.place || hit.placeAt(p) === taken.place) continue;
2432
+ const shownFrame = basis === "lift" ? drag.lift : drag.after(hit.heldOf(taken.place));
2433
+ if (shownFrame.folds.some((f, i) => f.railOf === i && inside2(f.rail, p))) continue;
2434
+ const mapHeld = hit.placeAt(p) === null ? null : hit.heldOf(hit.placeAt(p));
2435
+ const takenHeld = hit.heldOf(taken.place);
2436
+ if (basis === "base" && mapHeld && mapHeld.kind !== "home" && drag.lift.spines.has(mapHeld.at) && shownFrame.spines.has(mapHeld.at) && !(takenHeld && takenHeld.kind !== "home" && takenHeld.at === mapHeld.at)) continue;
2405
2437
  if (!(home && inside2(home, p)) && Math.abs(p.x - taken.from.x) < travel && Math.abs(p.y - taken.from.y) < travel) continue;
2406
2438
  if (probed++ >= 24) break;
2407
2439
  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
2440
  }
2409
- if (rails.length > 0) {
2410
- const painted = paintedSpines(laid, basis === "lift" ? options.railOffset : void 0);
2411
- const taken = samples.map((p) => hit.hold(null, p)).find((s) => s !== null) ?? null;
2412
- for (const { f, i } of rails) {
2441
+ const frameFor = (s) => basis === "lift" ? drag.lift : s === null ? drag.base : s.place === "home" ? drag.lift : drag.after(hit.heldOf(s.place));
2442
+ const holdStates = [null];
2443
+ if (home) holdStates.push({ place: "home", from: { x: home.x + home.width / 2, y: home.y + home.height / 2 } });
2444
+ const heldPlaces = /* @__PURE__ */ new Set();
2445
+ for (const q of samples) {
2446
+ if (heldPlaces.size >= 6) break;
2447
+ const s = hit.hold(null, q);
2448
+ if (s && s.place !== "home" && !heldPlaces.has(s.place)) {
2449
+ heldPlaces.add(s.place);
2450
+ holdStates.push(s);
2451
+ }
2452
+ }
2453
+ for (const s of holdStates) {
2454
+ const F = frameFor(s);
2455
+ const railsOfF = F.folds.map((f, i) => ({ f, i })).filter(({ f, i }) => f.railOf === i);
2456
+ if (railsOfF.length === 0) continue;
2457
+ const painted = paintedSpines(F, options.railOffset);
2458
+ const enter = () => {
2459
+ frame(FAR);
2460
+ if (s === null) return true;
2461
+ const r = frame(s.from);
2462
+ return s.place === "home" ? r.held?.kind === "home" : r.held !== null && show2(r.held) === show2(hit.heldOf(s.place));
2463
+ };
2464
+ const keeps = basis === "lift" ? null : s;
2465
+ const wantHeld = keeps === null ? null : keeps.place === "home" ? HOME2 : hit.heldOf(keeps.place);
2466
+ for (const { f, i } of railsOfF) {
2413
2467
  const r = f.rail;
2414
2468
  const points = [
2415
2469
  { x: r.x, y: r.y },
@@ -2419,18 +2473,34 @@ function tilingHitConformance(trees, options, hitOptions = {}, limit = 20) {
2419
2473
  ];
2420
2474
  for (let k = 0; k < 16; k++) points.push(randomPoint(r));
2421
2475
  for (const p of points) {
2422
- const want = [...painted].find(([pane, s]) => laid.folds.some((g) => g.railOf === i && g.panes.includes(pane)) && inside2(s, p))?.[0] ?? null;
2423
- const read = fresh(p);
2424
- const at = hit.foldedAt(p);
2476
+ const want = [...painted].find(([pane, q]) => F.folds.some((g) => g.railOf === i && g.panes.includes(pane)) && inside2(q, p))?.[0] ?? null;
2477
+ const step = hit.hold(s, p);
2478
+ const again = hit.hold(step, p);
2479
+ const where = `rail ${i} of the frame for ${s ? s.place : "nothing"} at ${p.x.toFixed(1)},${p.y.toFixed(1)}`;
2480
+ check(
2481
+ "spine-no-place",
2482
+ sameHold(step, keeps) && sameHold(again, keeps) && (s !== null || hit.placeAt(p) === null),
2483
+ () => `${where}: the hold went to ${holdName(step)}, then ${holdName(again)}; it stays ${holdName(keeps)} (place with nothing held: ${hit.placeAt(p)})`
2484
+ );
2485
+ if (!enter()) continue;
2486
+ const read = frame(p);
2487
+ const second = frame(p);
2488
+ check(
2489
+ "spine-no-place",
2490
+ show2(read.held) === show2(wantHeld) && read.refused === null && hit.drawn(read) === F && JSON.stringify(second) === JSON.stringify(read),
2491
+ () => `${where}: held ${show2(read.held)} (stays ${show2(wantHeld)}), refused ${show2(read.refused)}, the frame ${hit.drawn(read) === F ? "stays" : "moved"}`
2492
+ );
2493
+ const rel = hit.release(read);
2425
2494
  check(
2426
2495
  "spine-no-place",
2427
- hit.placeAt(p) === null && hit.hold(null, p) === null && hit.hold(taken, p) === null && read.held === null && read.refused === null,
2428
- () => `rail ${i} at ${p.x.toFixed(1)},${p.y.toFixed(1)}: place ${hit.placeAt(p)}, held ${show2(read.held)}, refused ${show2(read.refused)}`
2496
+ wantHeld === null || wantHeld.kind === "home" ? rel.tree === drag.lift.tree : rel === drag.after(wantHeld),
2497
+ () => `${where}: a release commits ${show2(rel.held)}, the frame shows ${show2(wantHeld)}`
2429
2498
  );
2499
+ const at = s === null ? hit.foldedAt(p) : read.folded;
2430
2500
  check(
2431
2501
  "spine-no-place",
2432
2502
  read.folded?.rail === i && read.folded.pane === want && at?.rail === i && at.pane === want,
2433
- () => `rail ${i} at ${p.x.toFixed(1)},${p.y.toFixed(1)}: reads ${JSON.stringify(read.folded)}, foldedAt ${JSON.stringify(at)}, painted ${String(want)}`
2503
+ () => `${where}: reads ${JSON.stringify(read.folded)}, foldedAt ${JSON.stringify(at)}, painted ${String(want)}`
2434
2504
  );
2435
2505
  }
2436
2506
  }