@n-uf/placement 26.11.38 → 26.11.39
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/README.md +9 -3
- package/dist/{chunk-GWZ5BPIN.js → chunk-US2TGS3W.js} +77 -54
- package/dist/chunk-US2TGS3W.js.map +1 -0
- package/dist/{model-bUSbHw8v.d.ts → model-gUF8juqt.d.ts} +7 -2
- package/dist/scene-cases.d.ts +1 -1
- package/dist/scene-cases.js +2 -1
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +10 -3
- package/dist/scene.js +3 -1
- package/package.json +2 -2
- package/dist/chunk-GWZ5BPIN.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
Versions are calendar versions, `YY.M.R` (year, month of the release, counter within the month), shared with
|
|
4
4
|
`@n-uf/motion`: both packages carry the same version, and a release bumps both.
|
|
5
5
|
|
|
6
|
+
## 26.11.39
|
|
7
|
+
|
|
8
|
+
- `./scene/cases`, **conformance row C17 requires the scene's own rail drop.** C17 now carries
|
|
9
|
+
`requires: { railDrop: "scene" }`, so a host that lays its own rail strips skips it, as it does the other rows whose
|
|
10
|
+
pixels depend on the scene's rail drop strips.
|
|
11
|
+
|
|
12
|
+
- `./scene`, **an item's zone is its own** (behavior change). A move sets `align` only when the drop names a zone (a
|
|
13
|
+
gap in a zone, a zone's slot, `moveTo` with `zone`); a rail, a new column, home, `dockHome` (the start scene's
|
|
14
|
+
`align`) and `moveTo` with no `zone` keep it. Before, a move to a rail stored the rail's start zone, so a group from a
|
|
15
|
+
bar's end zone, docked on a rail and later lent back to that bar through `showIn`, landed in its start cluster. An
|
|
16
|
+
item lies in its own zone where its edge takes it there, else in the first zone that does (`zoneIn`), one rule for
|
|
17
|
+
every edge and for lent items; its stored `align` is unchanged. Scenes whose items all lie in zones their edges take
|
|
18
|
+
lay out, target and store exactly as before. An item stored in a zone its edge doesn't take (a group with no `align`
|
|
19
|
+
in a column whose start zone takes only panels) now lies in the first zone that takes it, the column's tray, where it
|
|
20
|
+
lay among the panels before; `zoneExtents` and the gaps count it there. For a host this shows when it adds
|
|
21
|
+
`zoneAccepts` (a tray or deck) to a column whose stored scenes already hold groups with no `align`: on upgrade those
|
|
22
|
+
groups move from the start cluster to the tray at the column's foot, and that column's gap ids change
|
|
23
|
+
(`gap:<col>:end:0` appears). The stored scene is unchanged by reading and storing it. To know where an item lies, read
|
|
24
|
+
`SceneItemLayout.zone`, not `scene.items[id].align`, since the two can now differ; a host that wants to rewrite its
|
|
25
|
+
stored scenes can set each item's `align` to `zoneIn(edge, item)` (exported).
|
|
26
|
+
|
|
6
27
|
## 26.11.38
|
|
7
28
|
|
|
8
29
|
- `./scene`, **`Edge.showIn`** (additive): a hidden edge that names another, static edge lends it its items, which lay
|
package/README.md
CHANGED
|
@@ -872,9 +872,15 @@ Hits, clicks, drags and `after()` work as for the tile, at the title's length.
|
|
|
872
872
|
`Edge.size` is the user's size across, clamped to the widest open setter's `cross.min` (and the edge's `cross.min`) at
|
|
873
873
|
least and `cross.max` at most; `resize` sets it.
|
|
874
874
|
|
|
875
|
-
**Zones.** An item's `align` (`start`, the default, `center` or `end`) is its zone
|
|
876
|
-
|
|
877
|
-
|
|
875
|
+
**Zones.** An item's `align` (`start`, the default, `center` or `end`) is its zone, a fact of the item, not of the
|
|
876
|
+
edge it lies in. It lies in that zone where its edge takes its kind there (`Edge.zoneAccepts`), else in the first zone
|
|
877
|
+
that does (`zoneIn`, one rule for every edge and for the items a hidden edge lends through `showIn`); its stored
|
|
878
|
+
`align` stays as it was, so it is back in its own zone on an edge that takes it there. A move sets `align` only when the
|
|
879
|
+
drop names a zone: a gap in a zone, a zone's slot, `moveTo` with `zone`. A move whose zone is implied keeps it: a rail,
|
|
880
|
+
a new column, home and `dockHome` (which takes the start scene's `align` back), `moveTo` with no `zone`. Give-way is as
|
|
881
|
+
without zones (it sums the minimum sizes); when room is spare, start items pack from the start, end items from the end
|
|
882
|
+
(before the » entry) and center items sit on the edge's middle, moved only as far as they must to stay between the
|
|
883
|
+
other two.
|
|
878
884
|
|
|
879
885
|
**Bar alignment zones.** A horizontal bar picks the zone of a drop by thirds of its length: a pointer in the left third
|
|
880
886
|
is over the leading zone (`start`), in the middle third over the center zone, in the right third over the trailing zone
|
|
@@ -59,42 +59,58 @@ function railColumnOf(scene, side, kind) {
|
|
|
59
59
|
if (scene.rails?.[side]) return void 0;
|
|
60
60
|
return scene.edges.filter((e) => e.side === side && !e.compact && e.hidden !== true && zoneTakes(e, "start", kind)).reduce((m, e) => !m || e.ring < m.ring ? e : m, void 0);
|
|
61
61
|
}
|
|
62
|
+
function zoneIn(edge, item) {
|
|
63
|
+
const own = zoneOf(item);
|
|
64
|
+
if (item.fixed || zoneTakes(edge, own, item.kind)) return own;
|
|
65
|
+
return zonesTaking(edge, item.kind)[0] ?? own;
|
|
66
|
+
}
|
|
62
67
|
var showInOf = (scene, e) => {
|
|
63
68
|
if (e.hidden !== true || e.showIn === void 0) return void 0;
|
|
64
69
|
const to = scene.edges.find((x) => x.id === e.showIn);
|
|
65
70
|
return to && to !== e && to.hidden !== true && to.column !== true ? to : void 0;
|
|
66
71
|
};
|
|
67
72
|
function viewOf(scene) {
|
|
68
|
-
if (!scene.edges.some((e) => e.hidden === true)) return { view: scene, lent: /* @__PURE__ */ new Map(), ignored: [] };
|
|
69
73
|
const lent = /* @__PURE__ */ new Map();
|
|
70
74
|
const ignored = [];
|
|
71
75
|
const added = /* @__PURE__ */ new Map();
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
const hidden = scene.edges.some((e) => e.hidden === true);
|
|
77
|
+
if (hidden) {
|
|
78
|
+
for (const e of scene.edges) {
|
|
79
|
+
if (e.hidden !== true || e.showIn === void 0) continue;
|
|
80
|
+
const to = showInOf(scene, e);
|
|
81
|
+
if (!to) {
|
|
82
|
+
ignored.push(e.id);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
for (const id of e.items) {
|
|
86
|
+
const item = Object.hasOwn(scene.items, id) ? scene.items[id] : void 0;
|
|
87
|
+
if (!item || item.fixed || lent.has(id) || to.items.includes(id) || !edgeTakes(to, item.kind)) continue;
|
|
88
|
+
lent.set(id, e.id);
|
|
89
|
+
added.set(to.id, [...added.get(to.id) ?? [], id]);
|
|
90
|
+
}
|
|
79
91
|
}
|
|
92
|
+
}
|
|
93
|
+
const edges = hidden ? scene.edges.filter((e) => e.hidden !== true).map((e) => added.has(e.id) ? { ...e, items: [...e.items, ...added.get(e.id)] } : e) : scene.edges;
|
|
94
|
+
const rezoned = /* @__PURE__ */ new Set();
|
|
95
|
+
let items;
|
|
96
|
+
for (const e of edges) {
|
|
80
97
|
for (const id of e.items) {
|
|
81
98
|
const item = Object.hasOwn(scene.items, id) ? scene.items[id] : void 0;
|
|
82
|
-
if (!item
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
99
|
+
if (!item) continue;
|
|
100
|
+
const zone = zoneIn(e, item);
|
|
101
|
+
if (zone === zoneOf(item)) continue;
|
|
102
|
+
const { align: _a, ...plain } = item;
|
|
103
|
+
items ??= { ...scene.items };
|
|
104
|
+
items[id] = zone === "start" ? plain : { ...plain, align: zone };
|
|
105
|
+
rezoned.add(id);
|
|
90
106
|
}
|
|
91
107
|
}
|
|
92
|
-
|
|
93
|
-
return { view: { ...scene, edges, ...
|
|
108
|
+
if (!hidden && !items) return { view: scene, lent, ignored, rezoned };
|
|
109
|
+
return { view: { ...scene, edges, ...items ? { items } : {} }, lent, ignored, rezoned };
|
|
94
110
|
}
|
|
95
111
|
var inHiddenEdge = (scene, id) => scene.edges.some((e) => e.hidden === true && e.items.includes(id));
|
|
96
|
-
function withHiddenOf(scene, shown, lent = /* @__PURE__ */ new Map(), moved, zoned = false) {
|
|
97
|
-
if (shown === scene
|
|
112
|
+
function withHiddenOf(scene, shown, lent = /* @__PURE__ */ new Map(), moved, zoned = false, rezoned = /* @__PURE__ */ new Set()) {
|
|
113
|
+
if (shown === scene) return shown;
|
|
98
114
|
const back = [...lent.keys()].filter((id) => id !== moved);
|
|
99
115
|
const edges = shown.edges.filter((e) => e.hidden !== true).map((e) => back.some((id) => e.items.includes(id)) ? { ...e, items: e.items.filter((id) => !back.includes(id)) } : e);
|
|
100
116
|
scene.edges.forEach((e, i) => {
|
|
@@ -103,15 +119,14 @@ function withHiddenOf(scene, shown, lent = /* @__PURE__ */ new Map(), moved, zon
|
|
|
103
119
|
edges.splice(Math.min(i, edges.length), 0, own);
|
|
104
120
|
});
|
|
105
121
|
const items = back.length > 0 ? { ...shown.items, ...Object.fromEntries(back.map((id) => [id, scene.items[id]])) } : { ...shown.items };
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
122
|
+
const keep2 = new Set([...rezoned].filter((id) => !back.includes(id) && !(id === moved && zoned)));
|
|
123
|
+
if (moved !== void 0 && !zoned) keep2.add(moved);
|
|
124
|
+
for (const id of keep2) {
|
|
125
|
+
const was = Object.hasOwn(scene.items, id) ? scene.items[id] : void 0;
|
|
126
|
+
const now = Object.hasOwn(items, id) ? items[id] : void 0;
|
|
127
|
+
if (!was || !now || now.align === was.align) continue;
|
|
128
|
+
const { align: _a, ...plain } = now;
|
|
129
|
+
items[id] = was.align === void 0 ? plain : { ...plain, align: was.align };
|
|
115
130
|
}
|
|
116
131
|
const ringBefore = new Map(scene.edges.filter((e) => e.hidden !== true).map((e) => [e.id, e.ring]));
|
|
117
132
|
for (const side of new Set(scene.edges.filter((e) => e.hidden === true).map((e) => e.side))) {
|
|
@@ -1351,22 +1366,22 @@ function insertColumn(scene0, id, side, ring, others) {
|
|
|
1351
1366
|
const col = newColumn(scene, side, kind, r, [id], others);
|
|
1352
1367
|
if (!col) return null;
|
|
1353
1368
|
if (!zoneTakes(col, "start", kind)) return null;
|
|
1354
|
-
const
|
|
1355
|
-
|
|
1356
|
-
const { align: _a, ...plain } = item;
|
|
1357
|
-
const placed = withItem(scene, zone === "start" ? plain : { ...plain, align: zone });
|
|
1358
|
-
const shifted = placed.edges.map((e) => e.side === side && e.ring >= r ? { ...e, ring: e.ring + 1 } : e);
|
|
1359
|
-
return { ...placed, edges: closeRings([...shifted, col], /* @__PURE__ */ new Set([side])) };
|
|
1369
|
+
const shifted = scene.edges.map((e) => e.side === side && e.ring >= r ? { ...e, ring: e.ring + 1 } : e);
|
|
1370
|
+
return { ...scene, edges: closeRings([...shifted, col], /* @__PURE__ */ new Set([side])) };
|
|
1360
1371
|
}
|
|
1372
|
+
var zoneAt = (scene, edge, id) => {
|
|
1373
|
+
const it = itemOf(scene, id);
|
|
1374
|
+
return it ? zoneIn(edge, it) : "start";
|
|
1375
|
+
};
|
|
1361
1376
|
function insertIndex(scene, edge, zone, at) {
|
|
1362
1377
|
const rank = { start: 0, center: 1, end: 2 };
|
|
1363
|
-
const inZone = edge.items.map((id, i) => ({ id, i })).filter((x) =>
|
|
1378
|
+
const inZone = edge.items.map((id, i) => ({ id, i })).filter((x) => zoneAt(scene, edge, x.id) === zone);
|
|
1364
1379
|
const k = Math.min(Math.max(0, Math.floor(Number.isFinite(at) ? at : inZone.length)), inZone.length);
|
|
1365
1380
|
if (k < inZone.length) return inZone[k].i;
|
|
1366
1381
|
if (inZone.length > 0) return inZone[inZone.length - 1].i + 1;
|
|
1367
1382
|
let idx = 0;
|
|
1368
1383
|
edge.items.forEach((id, i) => {
|
|
1369
|
-
if (rank[
|
|
1384
|
+
if (rank[zoneAt(scene, edge, id)] < rank[zone]) idx = i + 1;
|
|
1370
1385
|
});
|
|
1371
1386
|
return idx;
|
|
1372
1387
|
}
|
|
@@ -1384,7 +1399,7 @@ function moveAmong(scene, id, place, others) {
|
|
|
1384
1399
|
}
|
|
1385
1400
|
const railColumn = place.kind === "rail" ? railColumnOf(scene, place.side, item.kind) : void 0;
|
|
1386
1401
|
if (railColumn) {
|
|
1387
|
-
const docked = moveAmong(scene, id, { edge: railColumn.id,
|
|
1402
|
+
const docked = moveAmong(scene, id, { edge: railColumn.id, at: Infinity }, others);
|
|
1388
1403
|
return docked === scene ? scene : withItem(docked, { ...docked.items[id], from: Math.max(1, item.from ?? 0) });
|
|
1389
1404
|
}
|
|
1390
1405
|
if (place.kind === "column" || place.kind === "rail") {
|
|
@@ -1395,10 +1410,10 @@ function moveAmong(scene, id, place, others) {
|
|
|
1395
1410
|
}
|
|
1396
1411
|
const edge = scene.edges.find((e) => e.id === place.edge);
|
|
1397
1412
|
if (!edge || edge.hidden === true || !edge.accepts.includes(item.kind)) return scene;
|
|
1398
|
-
const zone = place.zone ?? (
|
|
1399
|
-
if (!
|
|
1413
|
+
const zone = place.zone ?? zoneIn(edge, item);
|
|
1414
|
+
if (!zoneTakes(edge, zone, item.kind)) return scene;
|
|
1400
1415
|
const { align: _drop, ...rest } = item;
|
|
1401
|
-
const moved = zone === "start" ? rest : { ...rest, align: zone };
|
|
1416
|
+
const moved = place.zone === void 0 ? item : zone === "start" ? rest : { ...rest, align: zone };
|
|
1402
1417
|
const lifted = withItem(lift(scene, id), moved);
|
|
1403
1418
|
const target = lifted.edges.find((e) => e.id === place.edge);
|
|
1404
1419
|
if (!target) return scene;
|
|
@@ -1506,11 +1521,12 @@ function homeFor(scene, id, start) {
|
|
|
1506
1521
|
for (const e of start.edges) {
|
|
1507
1522
|
const k = e.items.indexOf(id);
|
|
1508
1523
|
if (k < 0) continue;
|
|
1509
|
-
const
|
|
1524
|
+
const own = itemOf(start, id) ?? itemOf(scene, id);
|
|
1510
1525
|
const found = scene.edges.find((x) => x.id === e.id);
|
|
1511
1526
|
const here = found && (e.column !== true || found.items.some((x) => e.items.includes(x))) ? found : void 0;
|
|
1512
1527
|
if (here) {
|
|
1513
|
-
const
|
|
1528
|
+
const zone = own ? zoneIn(here, own) : "start";
|
|
1529
|
+
const now = here.items.filter((x) => x !== id && zoneAt(scene, here, x) === zone);
|
|
1514
1530
|
const next = e.items.slice(k + 1).find((x) => now.includes(x));
|
|
1515
1531
|
return { kind: "gap", edge: e.id, zone, at: next ? now.indexOf(next) : now.length };
|
|
1516
1532
|
}
|
|
@@ -1527,10 +1543,18 @@ function dockHome(scene, id, start) {
|
|
|
1527
1543
|
const moved = moveTo(scene, id, place);
|
|
1528
1544
|
const item = itemOf(moved, id);
|
|
1529
1545
|
if (!item) return scene;
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1546
|
+
const was = itemOf(start, id);
|
|
1547
|
+
const from = was?.from;
|
|
1548
|
+
let out = item;
|
|
1549
|
+
if (was && out.align !== was.align) {
|
|
1550
|
+
const { align: _a, ...plain } = out;
|
|
1551
|
+
out = was.align === void 0 ? plain : { ...plain, align: was.align };
|
|
1552
|
+
}
|
|
1553
|
+
if (out.from !== from) {
|
|
1554
|
+
const { from: _f, ...plain } = out;
|
|
1555
|
+
out = from === void 0 ? plain : { ...plain, from };
|
|
1556
|
+
}
|
|
1557
|
+
return out === item ? moved : withItem(moved, out);
|
|
1534
1558
|
}
|
|
1535
1559
|
function clampFloat(r, stage, drawn = r) {
|
|
1536
1560
|
const at = clampInto({ x: r.x, y: r.y, width: drawn.width, height: drawn.height }, stage);
|
|
@@ -1849,7 +1873,7 @@ function zoneSpans(scene, seen, edge, reach, probe) {
|
|
|
1849
1873
|
const placed = /* @__PURE__ */ new Map();
|
|
1850
1874
|
for (const [id, it] of Object.entries(seen.items)) {
|
|
1851
1875
|
if (it.edge !== edge.id || it.inMenu) continue;
|
|
1852
|
-
const z = zoneOf(scene.items[id]);
|
|
1876
|
+
const z = it.zone ?? zoneOf(scene.items[id]);
|
|
1853
1877
|
const [a, b] = at(thirds && it.fixed ? reservedRect(scene, seen, id) : it.rect);
|
|
1854
1878
|
const was = placed.get(z);
|
|
1855
1879
|
placed.set(z, was ? [Math.min(was[0], a), Math.max(was[1], b)] : [a, b]);
|
|
@@ -2962,7 +2986,7 @@ function alongOfSlots(s, tiles) {
|
|
|
2962
2986
|
}
|
|
2963
2987
|
function generate(scene, dragged, options) {
|
|
2964
2988
|
checkEdgeIds(scene);
|
|
2965
|
-
const { view: shown, lent } = viewOf(scene);
|
|
2989
|
+
const { view: shown, lent, rezoned } = viewOf(scene);
|
|
2966
2990
|
if (shown === scene) return generateShown(scene, dragged, options, []);
|
|
2967
2991
|
if (inHiddenEdge(scene, dragged) && !lent.has(dragged)) return { targets: [], refusals: [], lost: [] };
|
|
2968
2992
|
const hidden = scene.edges.filter((e) => e.hidden === true);
|
|
@@ -2976,13 +3000,11 @@ function generate(scene, dragged, options) {
|
|
|
2976
3000
|
after: (point, grab) => {
|
|
2977
3001
|
const a = t.after(point, grab);
|
|
2978
3002
|
if (a.scene === shown) return { scene, layout: showsIn ? solve(scene, prev) : a.layout };
|
|
2979
|
-
const
|
|
2980
|
-
const zoned = t.place.kind === "gap" || t.place.kind === "rail" && !!railColumnOf(shown, t.place.side, scene.items[dragged].kind);
|
|
2981
|
-
const back = withHiddenOf(scene, a.scene, lent, moved, zoned);
|
|
3003
|
+
const back = withHiddenOf(scene, a.scene, lent, dragged, t.place.kind === "gap", rezoned);
|
|
2982
3004
|
const restored = showsIn ? prune(back) : back;
|
|
2983
3005
|
const ringOf = new Map(a.scene.edges.map((e) => [e.id, e.ring]));
|
|
2984
3006
|
const renumbered = restored.edges.some((e) => e.hidden !== true && ringOf.get(e.id) !== e.ring);
|
|
2985
|
-
const layout = renumbered || showsIn ? solve(restored, prev) : a.layout;
|
|
3007
|
+
const layout = renumbered || showsIn || rezoned.size > 0 ? solve(restored, prev) : a.layout;
|
|
2986
3008
|
return { scene: restored, layout };
|
|
2987
3009
|
}
|
|
2988
3010
|
}))
|
|
@@ -3123,6 +3145,7 @@ export {
|
|
|
3123
3145
|
zonesTaking,
|
|
3124
3146
|
edgeTakes,
|
|
3125
3147
|
railModeOf,
|
|
3148
|
+
zoneIn,
|
|
3126
3149
|
isOutsideSideBar,
|
|
3127
3150
|
isSideBar,
|
|
3128
3151
|
floatOrientOf,
|
|
@@ -3157,4 +3180,4 @@ export {
|
|
|
3157
3180
|
refusalTargets,
|
|
3158
3181
|
stops
|
|
3159
3182
|
};
|
|
3160
|
-
//# sourceMappingURL=chunk-
|
|
3183
|
+
//# sourceMappingURL=chunk-US2TGS3W.js.map
|