@n-uf/placement 26.12.9 → 26.12.11
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 +34 -0
- package/dist/tiling.d.ts +39 -5
- package/dist/tiling.js +23 -5
- package/dist/tiling.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,40 @@ 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.11
|
|
9
|
+
|
|
10
|
+
- **Added:** `TilingHitOptions.start`. A hit made at a pickup starts at home: make it with `start: "home"`. A hit made
|
|
11
|
+
in mid-drag starts from nothing held. With `"home"` the drag's one hold holds home before its first step, so the
|
|
12
|
+
first read is the read from home at that point (on the base basis a strip is read from the lift, the frame drawn at
|
|
13
|
+
home). With no home (`hit.home` is null) it starts from nothing held, as when the option is left out. The option
|
|
14
|
+
counts on the drag's first `hit(basis)` call, as every hit option does. The start applies once, to the first step;
|
|
15
|
+
the pure `hold(state, point)` does not read it.
|
|
16
|
+
- **Added:** `TilingHit.cap`, the cap the hit resolved (`TilingHitOptions.cap`, default 0.25, never below 0), read-only,
|
|
17
|
+
beside the edge measure it resolved (`intent.tuning.band`).
|
|
18
|
+
- **Changed (breaking in behavior, not in types):** strips are read from the frame on screen; places from the basis's
|
|
19
|
+
map. Before: "Off that frame's rails the hold is the basis's map (its own rails take no place)", so on the base basis a
|
|
20
|
+
rail of the base let any hold go, also where the frame on screen (the lift at home, `after(held)` for a place) paints
|
|
21
|
+
no strip there: a press on home over a strip of the base that the lift does not paint let home go. Now: "Off that
|
|
22
|
+
frame's rails the hold is the basis's map (the rails that take no place are those of the frame drawn for the hold)".
|
|
23
|
+
A rail of the base the frame does not paint plays no part: a hold inside its own keep stays, and the place is the
|
|
24
|
+
map's, so such a press stays home. A painted strip keeps the hold and is named, as before; with nothing held the frame
|
|
25
|
+
is the base, so its strips still take no drop, and `placeAt(point)` still gives null on them. The lift basis is
|
|
26
|
+
unchanged. Only a host with folds (`TilingDragOptions.fold`) can see this.
|
|
27
|
+
- **Changed:** the zone map under `placeAt`, `hold` and `read` reads no rail; only the frame drawn for the hold does.
|
|
28
|
+
So `read(frame, point).refused` follows the same rule: at a point on a rail of the base that the frame drawn for the
|
|
29
|
+
hold does not paint, a read that holds nothing names the refused place under the pointer in `refused`, as anywhere
|
|
30
|
+
off a painted strip (before, it was null on every rail of the base).
|
|
31
|
+
|
|
32
|
+
## 26.12.10
|
|
33
|
+
|
|
34
|
+
- **Changed (breaking in behavior, not in types):** under a fold, on the base basis, a pane you see folded takes no
|
|
35
|
+
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,
|
|
36
|
+
unless it already holds a place of that pane; there the hold and its frame stay. Before, a pointer on its way to a
|
|
37
|
+
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
|
|
38
|
+
no longer reached from home; it still is with nothing held, or once the pane is drawn open.
|
|
39
|
+
- **Changed:** the hit conformance's `hold-measures` no longer counts a kept place as past both measures where the
|
|
40
|
+
map's place names a pane drawn as a strip at the lift and in the kept place's frame.
|
|
41
|
+
|
|
8
42
|
## 26.12.9
|
|
9
43
|
|
|
10
44
|
- **Changed (breaking in behavior, not in types):** under a fold, the hit on the base basis reads a strip from the
|
package/dist/tiling.d.ts
CHANGED
|
@@ -724,8 +724,19 @@ interface TilingAfter<T, K> extends TilingLaidOut<T, K> {
|
|
|
724
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
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
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
|
|
728
|
-
*
|
|
727
|
+
* frame's rails the hold follows the basis's zone map, and a rail of the basis that frame does not paint plays no
|
|
728
|
+
* part: a hold inside its own keep stays, and the place is the map's. With nothing held the frame is the basis's
|
|
729
|
+
* layout, so its strips take no drop. Strips are read from the frame on screen; places from the basis's map.
|
|
730
|
+
* - **A pane you see folded takes no drop** (under a fold, on the base basis). The hold does not change to a place
|
|
731
|
+
* 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
|
|
732
|
+
* that pane; where such a place is refused the hold stays as it is, and so does its frame. Off the strip the read
|
|
733
|
+
* names no strip (`folded` is null). It is one check on the place's pane, no geometry: a pane open at the lift, a
|
|
734
|
+
* pane the frame draws open (with nothing held the base is drawn), the lift basis and a layout without a fold are
|
|
735
|
+
* held as before. So the place beside such a pane is reached only from a frame that draws it open.
|
|
736
|
+
* - **Where the hold starts**: a hit made at a pickup starts at home: make it with `start: "home"`. A hit made in
|
|
737
|
+
* mid-drag starts from nothing held. The start applies once, to the first step of the drag's one hold; with no home it
|
|
738
|
+
* is nothing held, so a host never branches on `home`. The resolved cap is `hit.cap`, beside the edge measure
|
|
739
|
+
* (`hit.intent.tuning.band`).
|
|
729
740
|
*
|
|
730
741
|
* See docs/placement.md, Entry: tiling, "A tiling drag's hit half".
|
|
731
742
|
*/
|
|
@@ -762,6 +773,14 @@ interface TilingHitOptions<K> {
|
|
|
762
773
|
readonly cap?: number;
|
|
763
774
|
/** A run neighbor's swap across the run, a share of its extent there (default 0.56): each side strip is half the rest. */
|
|
764
775
|
readonly neighborSwap?: number;
|
|
776
|
+
/**
|
|
777
|
+
* Where the drag's one hold starts. A hit made at a pickup starts at home: make it with `start: "home"`. A hit made
|
|
778
|
+
* in mid-drag starts from nothing held. Left out, the hold starts from nothing held; with `"home"` its first step is
|
|
779
|
+
* the hold rule from home taken at that point (`hold({ place: "home", from: point }, point)`), and with no home
|
|
780
|
+
* (`TilingHit.home` is null) it starts from nothing held as well. The start applies once, to the first step; a later
|
|
781
|
+
* read never applies it again. The pure `hold(state, point)` does not read it.
|
|
782
|
+
*/
|
|
783
|
+
readonly start?: "home";
|
|
765
784
|
}
|
|
766
785
|
/**
|
|
767
786
|
* The hit's defaults: 6 px past the edge, 24 px of travel inside one pane, each at most a quarter of the zone (`cap`);
|
|
@@ -857,11 +876,23 @@ interface TilingHit<T, K> {
|
|
|
857
876
|
readonly home: Rect | null;
|
|
858
877
|
/** Every target, fixed for the drag. */
|
|
859
878
|
readonly targets: readonly TilingHitTarget<K>[];
|
|
860
|
-
/**
|
|
879
|
+
/**
|
|
880
|
+
* The options for a drag intent (`createDragIntent({ ...hit.intent })`). Its `tuning.band` is the edge measure the
|
|
881
|
+
* hit resolved, px.
|
|
882
|
+
*/
|
|
861
883
|
readonly intent: TilingHitIntent<K>;
|
|
884
|
+
/**
|
|
885
|
+
* The cap the hit resolved: the most either measure is of the held zone's extent, per axis (`TilingHitOptions.cap`,
|
|
886
|
+
* default 0.25, never below 0). Read-only; the edge measure beside it is `intent.tuning.band`.
|
|
887
|
+
*/
|
|
888
|
+
readonly cap: number;
|
|
862
889
|
/** The zone map: the place id at `point` with nothing held (`"home"` for home), or null. Pure. */
|
|
863
890
|
placeAt(point: Point): string | null;
|
|
864
|
-
/**
|
|
891
|
+
/**
|
|
892
|
+
* The hold rule: what is held at `point` after `state` (null: nothing held yet). Pure: a host with no intent steps it
|
|
893
|
+
* 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
|
|
894
|
+
* for `state`, unless `state` is already a place of that pane; there it stays `state`.
|
|
895
|
+
*/
|
|
865
896
|
hold(state: TilingHold | null, point: Point): TilingHold | null;
|
|
866
897
|
/** The place an id names (hosts never parse ids). */
|
|
867
898
|
heldOf(id: string): TilingHeld<K> | null;
|
|
@@ -990,7 +1021,10 @@ interface TilingDrag<T, K> {
|
|
|
990
1021
|
* The drag's hit half on `basis`, built from that one layout and fixed for the drag: `"lift"` for a host that draws
|
|
991
1022
|
* marks over the lift, `"base"` for one that draws the held place's landed layout. Remembered per basis, as `after` is
|
|
992
1023
|
* per place: every call on one basis gives the same hit, with its one hold, and the first call's options stand. A
|
|
993
|
-
* fresh hold is the pure `hit.hold(state, point)`.
|
|
1024
|
+
* fresh hold is the pure `hit.hold(state, point)`. Under a fold, on the base basis, a pane you see folded takes no
|
|
1025
|
+
* 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
|
|
1026
|
+
* hold, unless it already holds a place of that pane. A hit made at a pickup starts at home: make it with
|
|
1027
|
+
* `start: "home"`. A hit made in mid-drag starts from nothing held.
|
|
994
1028
|
*/
|
|
995
1029
|
hit(basis: TilingBasis, options?: TilingHitOptions<K>): TilingHit<T, K>;
|
|
996
1030
|
}
|
package/dist/tiling.js
CHANGED
|
@@ -1352,7 +1352,6 @@ function createTilingHit(ctx, basis, options = {}) {
|
|
|
1352
1352
|
}
|
|
1353
1353
|
Object.freeze(targets);
|
|
1354
1354
|
const rawAt = (p) => {
|
|
1355
|
-
if (onRail(p)) return { place: null, refused: null };
|
|
1356
1355
|
if (home && inside(home, p)) return { place: homePlace, refused: null };
|
|
1357
1356
|
const pane = panes.find((ph) => inside(ph.body.hit, p));
|
|
1358
1357
|
if (!pane) return { place: null, refused: null };
|
|
@@ -1371,7 +1370,7 @@ function createTilingHit(ctx, basis, options = {}) {
|
|
|
1371
1370
|
return live(place) ? { place, refused: null } : { place: null, refused: refused ?? place };
|
|
1372
1371
|
};
|
|
1373
1372
|
const effective = (p) => p && homeLike(p) ? homePlace : p;
|
|
1374
|
-
const placeAt = (p) => effective(rawAt(p).place)?.id ?? null;
|
|
1373
|
+
const placeAt = (p) => onRail(p) ? null : effective(rawAt(p).place)?.id ?? null;
|
|
1375
1374
|
let homeLikeAll = null;
|
|
1376
1375
|
const homePieces = () => {
|
|
1377
1376
|
homeLikeAll ??= [...byId.values()].filter((p) => p !== homePlace && homeLike(p));
|
|
@@ -1404,22 +1403,36 @@ function createTilingHit(ctx, basis, options = {}) {
|
|
|
1404
1403
|
const place = byId.get(state2.place);
|
|
1405
1404
|
return place ? after(place.held) : base;
|
|
1406
1405
|
};
|
|
1406
|
+
const paneOf = (place) => place.held.kind === "home" ? null : place.held.at;
|
|
1407
|
+
const seenFolded = (state2, place) => {
|
|
1408
|
+
if (basis !== "base") return false;
|
|
1409
|
+
const pane = paneOf(place);
|
|
1410
|
+
if (pane === null || !lift.spines.has(pane)) return false;
|
|
1411
|
+
const held = state2 === null ? null : byId.get(state2.place);
|
|
1412
|
+
if (held && paneOf(held) === pane) return false;
|
|
1413
|
+
return frameOf(state2).spines.has(pane);
|
|
1414
|
+
};
|
|
1407
1415
|
const hold = (state2, p) => {
|
|
1408
1416
|
if (onRailOf(frameOf(state2), p)) return basis === "lift" ? null : state2;
|
|
1409
|
-
if (onRail(p)) return null;
|
|
1410
1417
|
const now = effective(rawAt(p).place);
|
|
1411
1418
|
if (state2) {
|
|
1412
1419
|
if (now && now.id === state2.place) return state2;
|
|
1413
1420
|
const held = byId.get(state2.place);
|
|
1414
1421
|
if (held && (near2(held, p) || keepsByTravel(held, state2.from, p))) return state2;
|
|
1415
1422
|
}
|
|
1423
|
+
if (now && seenFolded(state2, now)) return state2;
|
|
1416
1424
|
return now ? { place: now.id, from: { x: p.x, y: p.y } } : null;
|
|
1417
1425
|
};
|
|
1418
1426
|
let state = null;
|
|
1427
|
+
let startAtHome = options.start === "home" && home !== null;
|
|
1419
1428
|
let stepFrom = null;
|
|
1420
1429
|
let last = null;
|
|
1421
1430
|
const current = (p) => {
|
|
1422
1431
|
if (!last || last.x !== p.x || last.y !== p.y) {
|
|
1432
|
+
if (startAtHome) {
|
|
1433
|
+
startAtHome = false;
|
|
1434
|
+
state = { place: "home", from: { x: p.x, y: p.y } };
|
|
1435
|
+
}
|
|
1423
1436
|
stepFrom = state;
|
|
1424
1437
|
state = hold(state, p);
|
|
1425
1438
|
last = { x: p.x, y: p.y };
|
|
@@ -1451,6 +1464,7 @@ function createTilingHit(ctx, basis, options = {}) {
|
|
|
1451
1464
|
return {
|
|
1452
1465
|
basis,
|
|
1453
1466
|
home: home ? { ...home } : null,
|
|
1467
|
+
cap,
|
|
1454
1468
|
targets,
|
|
1455
1469
|
intent: {
|
|
1456
1470
|
tuning: { aimSpeed: Infinity, dwell: 0, switchHold: 0, roomAfter: 0, band: edge, bandShare: 1, breakthrough: 0, gapGrace: 0 },
|
|
@@ -1951,7 +1965,8 @@ var TILING_HIT_PROPERTIES = [
|
|
|
1951
1965
|
/**
|
|
1952
1966
|
* A path within the edge measure of the held zone's visible part, or inside its pane (not over home) within the travel
|
|
1953
1967
|
* measure of where it was taken, never changes the place; and a point past both (over home's rim on the base included,
|
|
1954
|
-
* where a zone runs on beneath home) reads the zone map
|
|
1968
|
+
* 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
|
|
1969
|
+
* the lift and in the frame drawn for the place (a pane you see folded takes no drop).
|
|
1955
1970
|
*/
|
|
1956
1971
|
"hold-measures",
|
|
1957
1972
|
/** A straight sweep meets each place but home (which shows nothing) at most once. */
|
|
@@ -1985,7 +2000,7 @@ var TILING_HIT_PROPERTIES = [
|
|
|
1985
2000
|
* every point of that frame's rail boxes (edges included) reads `folded` with that rail and the pane painted there
|
|
1986
2001
|
* (`paintedSpines` at the drag's rail offsets), null in a gap; the frame stays (the lift basis holds nothing, the base
|
|
1987
2002
|
* 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.
|
|
2003
|
+
* with nothing held there is no place (the rails that take no place are those of the frame drawn for the hold).
|
|
1989
2004
|
*/
|
|
1990
2005
|
"spine-no-place",
|
|
1991
2006
|
/**
|
|
@@ -2420,6 +2435,9 @@ function tilingHitConformance(trees, options, hitOptions = {}, limit = 20) {
|
|
|
2420
2435
|
if (kept?.place !== taken.place || hit.placeAt(p) === taken.place) continue;
|
|
2421
2436
|
const shownFrame = basis === "lift" ? drag.lift : drag.after(hit.heldOf(taken.place));
|
|
2422
2437
|
if (shownFrame.folds.some((f, i) => f.railOf === i && inside2(f.rail, p))) continue;
|
|
2438
|
+
const mapHeld = hit.placeAt(p) === null ? null : hit.heldOf(hit.placeAt(p));
|
|
2439
|
+
const takenHeld = hit.heldOf(taken.place);
|
|
2440
|
+
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;
|
|
2423
2441
|
if (!(home && inside2(home, p)) && Math.abs(p.x - taken.from.x) < travel && Math.abs(p.y - taken.from.y) < travel) continue;
|
|
2424
2442
|
if (probed++ >= 24) break;
|
|
2425
2443
|
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)})`);
|