@n-uf/placement 26.11.36 → 26.11.37
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 +12 -0
- package/README.md +12 -0
- package/dist/{chunk-SW3PZACP.js → chunk-2PWDUBPG.js} +69 -15
- package/dist/chunk-2PWDUBPG.js.map +1 -0
- package/dist/{model-fnbEHD6c.d.ts → model-CuE-ML-f.d.ts} +16 -2
- package/dist/scene-cases.d.ts +1 -1
- package/dist/scene-cases.js +1 -1
- package/dist/scene.d.ts +2 -2
- package/dist/scene.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-SW3PZACP.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.37
|
|
7
|
+
|
|
8
|
+
- `./scene`, **`Edge.hidden`** (additive): an edge kept in the scene with its items but not in the window, such as a
|
|
9
|
+
bar the host doesn't draw or a rail it has turned off. It is view state, the host's each time it builds the scene. It
|
|
10
|
+
takes no room, and the rest lays out as if it and its items weren't there: `solve` leaves both out of the layout, with
|
|
11
|
+
no give-way or folds for them. It has no targets, refusals or stops, and neither do its items. A drop elsewhere keeps
|
|
12
|
+
it as it was, a target that commits nothing gives back the scene itself, and `moveTo` into it is refused.
|
|
13
|
+
`storeScene` keeps its items but never writes `hidden`; `readScene` takes `hidden` from `base` (a stored one is
|
|
14
|
+
ignored, `edge:<id>:hidden`). A column a drop makes never takes a hidden edge's id, and a side where a drop makes or
|
|
15
|
+
removes a column is numbered again with the hidden edge at its own place. Scenes without it lay out and target exactly
|
|
16
|
+
as before.
|
|
17
|
+
|
|
6
18
|
## 26.11.36
|
|
7
19
|
|
|
8
20
|
- `./tiling`, fixed: **a split with no room for its gap keeps its panes inside its rect.** When a split's rect was
|
package/README.md
CHANGED
|
@@ -811,6 +811,18 @@ bar that sets `span: "full"` by name runs across the full bars' width instead (t
|
|
|
811
811
|
content's top or bottom; one with `span: "between"`, or with no `span`, lies over the content only. An edge
|
|
812
812
|
with nothing drawn in it takes no room.
|
|
813
813
|
|
|
814
|
+
**Hidden edges.** `Edge.hidden: true` keeps an edge and its items in the scene but out of the window: a bar the host
|
|
815
|
+
doesn't draw, a rail it has turned off. It is view state: the host decides it each time it builds the scene (from the
|
|
816
|
+
window's width, say). It takes no room, and everything else lays out exactly as if it and its items were not in the
|
|
817
|
+
scene: `solve` leaves it and its items out of the layout (no `edges[id]`, no `items[id]`, as for an item placed
|
|
818
|
+
nowhere), and they take no part in give-way or folds. It has no targets and no refusals for any kind and no keyboard
|
|
819
|
+
stops; its items have none either. A drop elsewhere keeps the hidden edge as it was, and one that commits nothing (home,
|
|
820
|
+
a blocked rect) gives back the scene itself. `moveTo` into it is refused, as into an edge that doesn't take the kind.
|
|
821
|
+
`storeScene` keeps its items like any edge's but never writes `hidden`; `readScene` takes `hidden` from `base` only
|
|
822
|
+
(a stored one is ignored and listed as `edge:<id>:hidden`). A column a drop makes never takes a hidden edge's id, and
|
|
823
|
+
where a drop makes or removes a column on its side, the side is numbered again from 0 with the hidden edge back where its
|
|
824
|
+
ring put it in the order. Side columns, rails and bars alike.
|
|
825
|
+
|
|
814
826
|
**Each edge is a stack.** Left and right edges are columns (`forms.column`), top and bottom ones bars (`forms.row`),
|
|
815
827
|
each solved by `fitStack` along the length it gets, with `gap`, `pad` and `menu` passed through, its cross limits never
|
|
816
828
|
wider than the room the cut leaves. Group forms in a column take their own width (`ownCross`); open panels and headers
|
|
@@ -57,7 +57,33 @@ var axisOf = (side) => side === "left" || side === "right" ? "column" : "row";
|
|
|
57
57
|
var chromeFor = (scene, who) => (scene.chrome ?? []).filter((c) => who === "floats" || c.for !== "floats").map((c) => ({ x: c.x, y: c.y, width: c.width, height: c.height }));
|
|
58
58
|
function railColumnOf(scene, side, kind) {
|
|
59
59
|
if (scene.rails?.[side]) return void 0;
|
|
60
|
-
return scene.edges.filter((e) => e.side === side && !e.compact && zoneTakes(e, "start", kind)).reduce((m, e) => !m || e.ring < m.ring ? e : m, void 0);
|
|
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
|
+
}
|
|
62
|
+
function shownScene(scene) {
|
|
63
|
+
return scene.edges.some((e) => e.hidden === true) ? { ...scene, edges: scene.edges.filter((e) => e.hidden !== true) } : scene;
|
|
64
|
+
}
|
|
65
|
+
var inHiddenEdge = (scene, id) => scene.edges.some((e) => e.hidden === true && e.items.includes(id));
|
|
66
|
+
function withHiddenOf(scene, shown) {
|
|
67
|
+
if (shown === scene || !scene.edges.some((e) => e.hidden === true)) return shown;
|
|
68
|
+
const edges = shown.edges.filter((e) => e.hidden !== true);
|
|
69
|
+
scene.edges.forEach((e, i) => {
|
|
70
|
+
if (e.hidden === true) edges.splice(Math.min(i, edges.length), 0, e);
|
|
71
|
+
});
|
|
72
|
+
const ringBefore = new Map(scene.edges.filter((e) => e.hidden !== true).map((e) => [e.id, e.ring]));
|
|
73
|
+
for (const side of new Set(scene.edges.filter((e) => e.hidden === true).map((e) => e.side))) {
|
|
74
|
+
const was = scene.edges.filter((e) => e.side === side && e.hidden !== true).map((e) => e.id).sort();
|
|
75
|
+
const now = edges.filter((e) => e.side === side && e.hidden !== true);
|
|
76
|
+
if (now.length === was.length && now.every((e) => was.includes(e.id))) continue;
|
|
77
|
+
const order = [...now].sort((a, b) => a.ring - b.ring || edges.indexOf(a) - edges.indexOf(b));
|
|
78
|
+
for (const h of scene.edges.filter((e) => e.side === side && e.hidden === true).sort((a, b) => a.ring - b.ring)) {
|
|
79
|
+
const k = order.findIndex((e) => e.hidden !== true && (ringBefore.get(e.id) ?? -Infinity) > h.ring);
|
|
80
|
+
order.splice(k < 0 ? order.length : k, 0, h);
|
|
81
|
+
}
|
|
82
|
+
order.forEach((e, ring) => {
|
|
83
|
+
if (e.ring !== ring) edges[edges.indexOf(e)] = { ...e, ring };
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return { ...shown, edges };
|
|
61
87
|
}
|
|
62
88
|
function railPolicyOf(scene, kind) {
|
|
63
89
|
const p = Object.hasOwn(scene.railDrop ?? {}, kind) ? scene.railDrop[kind] : void 0;
|
|
@@ -1063,9 +1089,10 @@ function laySide(d, side, cols, g, area2, f, walk, upInset, tall) {
|
|
|
1063
1089
|
// src/scene/solve.ts
|
|
1064
1090
|
function solve(given, options = {}) {
|
|
1065
1091
|
checkEdgeIds(given);
|
|
1066
|
-
const
|
|
1092
|
+
const shown = shownScene(given);
|
|
1093
|
+
const lay = (caps, gave = []) => layOut(shown, options, caps, gave);
|
|
1067
1094
|
const first = lay(/* @__PURE__ */ new Map());
|
|
1068
|
-
const way = barGiveWay(
|
|
1095
|
+
const way = barGiveWay(shown, first, lay);
|
|
1069
1096
|
return way ? lay(way.caps, way.notes) : first;
|
|
1070
1097
|
}
|
|
1071
1098
|
var withHeightOf = (area2, over) => rect(over.x, area2.y, over.width, area2.height);
|
|
@@ -1246,10 +1273,10 @@ function lift(scene, id) {
|
|
|
1246
1273
|
floats: inFloat ? scene.floats.filter((f) => f.id !== id) : scene.floats
|
|
1247
1274
|
});
|
|
1248
1275
|
}
|
|
1249
|
-
function newColumn(scene, side, kind, ring, items) {
|
|
1276
|
+
function newColumn(scene, side, kind, ring, items, others) {
|
|
1250
1277
|
const t = scene.columns?.[side];
|
|
1251
1278
|
if (!t || !t.accepts.includes(kind)) return null;
|
|
1252
|
-
const taken = new Set(scene.edges.map((e) => e.id));
|
|
1279
|
+
const taken = new Set([...scene.edges, ...others].map((e) => e.id));
|
|
1253
1280
|
let n = 0;
|
|
1254
1281
|
while (taken.has(`${side}-${n}`)) n++;
|
|
1255
1282
|
return columnFromTemplate(t, `${side}-${n}`, side, ring, items);
|
|
@@ -1263,13 +1290,13 @@ function columnFloor(edges, side) {
|
|
|
1263
1290
|
while (n < mine.length && mine[n].column !== true) n++;
|
|
1264
1291
|
return n;
|
|
1265
1292
|
}
|
|
1266
|
-
function insertColumn(scene0, id, side, ring) {
|
|
1293
|
+
function insertColumn(scene0, id, side, ring, others) {
|
|
1267
1294
|
const scene = { ...scene0, edges: closeRings(scene0.edges, /* @__PURE__ */ new Set([side])) };
|
|
1268
1295
|
const kind = scene.items[id].kind;
|
|
1269
1296
|
const mine = scene.edges.filter((e) => e.side === side);
|
|
1270
1297
|
const floor = columnFloor(scene.edges, side);
|
|
1271
1298
|
const r = Math.max(floor, Math.min(Number.isNaN(ring) ? Infinity : Math.floor(ring), mine.length === 0 ? 0 : Math.max(...mine.map((e) => e.ring)) + 1));
|
|
1272
|
-
const col = newColumn(scene, side, kind, r, [id]);
|
|
1299
|
+
const col = newColumn(scene, side, kind, r, [id], others);
|
|
1273
1300
|
if (!col) return null;
|
|
1274
1301
|
if (!zoneTakes(col, "start", kind)) return null;
|
|
1275
1302
|
const item = scene.items[id];
|
|
@@ -1292,6 +1319,9 @@ function insertIndex(scene, edge, zone, at) {
|
|
|
1292
1319
|
return idx;
|
|
1293
1320
|
}
|
|
1294
1321
|
function moveTo(scene, id, place) {
|
|
1322
|
+
return moveAmong(scene, id, place, []);
|
|
1323
|
+
}
|
|
1324
|
+
function moveAmong(scene, id, place, others) {
|
|
1295
1325
|
const item = itemOf(scene, id);
|
|
1296
1326
|
if (!item || item.fixed) return scene;
|
|
1297
1327
|
if (place.kind === "float") {
|
|
@@ -1302,17 +1332,17 @@ function moveTo(scene, id, place) {
|
|
|
1302
1332
|
}
|
|
1303
1333
|
const railColumn = place.kind === "rail" ? railColumnOf(scene, place.side, item.kind) : void 0;
|
|
1304
1334
|
if (railColumn) {
|
|
1305
|
-
const docked =
|
|
1335
|
+
const docked = moveAmong(scene, id, { edge: railColumn.id, zone: "start", at: Infinity }, others);
|
|
1306
1336
|
return docked === scene ? scene : withItem(docked, { ...docked.items[id], from: Math.max(1, item.from ?? 0) });
|
|
1307
1337
|
}
|
|
1308
1338
|
if (place.kind === "column" || place.kind === "rail") {
|
|
1309
1339
|
if (place.kind === "rail" && !scene.rails?.[place.side]?.accepts.includes(item.kind)) return scene;
|
|
1310
1340
|
const folded = place.kind === "rail" ? { ...item, from: Math.max(1, item.from ?? 0) } : item;
|
|
1311
|
-
const made = insertColumn(withItem(lift(scene, id), folded), id, place.side, place.ring);
|
|
1341
|
+
const made = insertColumn(withItem(lift(scene, id), folded), id, place.side, place.ring, others);
|
|
1312
1342
|
return made ?? scene;
|
|
1313
1343
|
}
|
|
1314
1344
|
const edge = scene.edges.find((e) => e.id === place.edge);
|
|
1315
|
-
if (!edge || !edge.accepts.includes(item.kind)) return scene;
|
|
1345
|
+
if (!edge || edge.hidden === true || !edge.accepts.includes(item.kind)) return scene;
|
|
1316
1346
|
const zone = place.zone ?? (zoneTakes(edge, zoneOf(item), item.kind) ? zoneOf(item) : zonesTaking(edge, item.kind)[0]);
|
|
1317
1347
|
if (!zone || !zoneTakes(edge, zone, item.kind)) return scene;
|
|
1318
1348
|
const { align: _drop, ...rest } = item;
|
|
@@ -1611,6 +1641,7 @@ function read(data, base) {
|
|
|
1611
1641
|
continue;
|
|
1612
1642
|
}
|
|
1613
1643
|
if (edge.column === true && isNum(e.ring)) rings.set(edge.id, e.ring);
|
|
1644
|
+
if (e.hidden !== void 0) drop(`edge:${edge.id}:hidden`);
|
|
1614
1645
|
if (e.side !== void 0 && !SIDES.includes(e.side)) drop(`edge:${e.id}:side`);
|
|
1615
1646
|
else if (!describesAnchor && edge.column !== true && typeof e.side === "string" && e.side !== edge.side && axisOf(e.side) === axisOf(edge.side)) moves.set(edge.id, e.side);
|
|
1616
1647
|
const ids = [];
|
|
@@ -1738,7 +1769,7 @@ function reservedRect(scene, l, id) {
|
|
|
1738
1769
|
return column ? rect(it.rect.x, it.rect.y + shift, it.rect.width, keep2) : rect(it.rect.x + shift, it.rect.y, keep2, it.rect.height);
|
|
1739
1770
|
}
|
|
1740
1771
|
function slotAt(c, zone, line, id, place, lands, home = false) {
|
|
1741
|
-
const result = c.settle(use(
|
|
1772
|
+
const result = c.settle(use(moveAmong(c.scene, c.dragged, place, c.others), c.dragged));
|
|
1742
1773
|
const isHome = home || c.isHome(result);
|
|
1743
1774
|
return { zone, line, id, place, result, home: isHome, ok: isHome || !!result.layout.items[c.dragged] && lands(result) && c.sound(result.layout) };
|
|
1744
1775
|
}
|
|
@@ -1952,7 +1983,7 @@ function soundness(scene, base, dragged) {
|
|
|
1952
1983
|
return !chrome.some((c) => overlaps(me.rect, c)) && !fixedAfter.some((f) => overlaps(me.rect, f));
|
|
1953
1984
|
};
|
|
1954
1985
|
}
|
|
1955
|
-
function context(scene, dragged, options) {
|
|
1986
|
+
function context(scene, dragged, options, others = []) {
|
|
1956
1987
|
const item = Object.hasOwn(scene.items, dragged) ? scene.items[dragged] : void 0;
|
|
1957
1988
|
if (!item || item.fixed || item.closed) return null;
|
|
1958
1989
|
const prev = { ...options.previous ? { previous: options.previous } : {}, ...options.fresh ? { fresh: options.fresh } : {} };
|
|
@@ -1963,6 +1994,7 @@ function context(scene, dragged, options) {
|
|
|
1963
1994
|
const here = placeKey(prune(scene), dragged);
|
|
1964
1995
|
const c = {
|
|
1965
1996
|
scene,
|
|
1997
|
+
others,
|
|
1966
1998
|
rest,
|
|
1967
1999
|
now,
|
|
1968
2000
|
base,
|
|
@@ -2526,7 +2558,7 @@ function columnStrip(c, side, policy) {
|
|
|
2526
2558
|
const own = c.now.items[c.dragged];
|
|
2527
2559
|
if (own?.edge === edge.id && isHandFolded(c.scene, c.dragged)) return null;
|
|
2528
2560
|
const place = { kind: "rail", side, ring: edge.ring };
|
|
2529
|
-
const moved =
|
|
2561
|
+
const moved = moveAmong(c.scene, c.dragged, place, c.others);
|
|
2530
2562
|
if (moved === c.scene) return null;
|
|
2531
2563
|
const result = c.settle(use(moved, c.dragged));
|
|
2532
2564
|
const el = result.layout.edges[edge.id];
|
|
@@ -2877,8 +2909,30 @@ function alongOfSlots(s, tiles) {
|
|
|
2877
2909
|
}
|
|
2878
2910
|
function generate(scene, dragged, options) {
|
|
2879
2911
|
checkEdgeIds(scene);
|
|
2912
|
+
const shown = shownScene(scene);
|
|
2913
|
+
if (shown === scene) return generateShown(scene, dragged, options, []);
|
|
2914
|
+
if (inHiddenEdge(scene, dragged)) return { targets: [], refusals: [], lost: [] };
|
|
2915
|
+
const hidden = scene.edges.filter((e) => e.hidden === true);
|
|
2916
|
+
const g = generateShown(shown, dragged, options, hidden);
|
|
2917
|
+
const prev = { ...options.previous ? { previous: options.previous } : {}, ...options.fresh ? { fresh: options.fresh } : {} };
|
|
2918
|
+
return {
|
|
2919
|
+
...g,
|
|
2920
|
+
targets: g.targets.map((t) => ({
|
|
2921
|
+
...t,
|
|
2922
|
+
after: (point, grab) => {
|
|
2923
|
+
const a = t.after(point, grab);
|
|
2924
|
+
if (a.scene === shown) return { scene, layout: a.layout };
|
|
2925
|
+
const restored = withHiddenOf(scene, a.scene);
|
|
2926
|
+
const ringOf = new Map(a.scene.edges.map((e) => [e.id, e.ring]));
|
|
2927
|
+
const renumbered = restored.edges.some((e) => e.hidden !== true && ringOf.get(e.id) !== e.ring);
|
|
2928
|
+
return { scene: restored, layout: renumbered ? solve(restored, prev) : a.layout };
|
|
2929
|
+
}
|
|
2930
|
+
}))
|
|
2931
|
+
};
|
|
2932
|
+
}
|
|
2933
|
+
function generateShown(scene, dragged, options, hidden) {
|
|
2880
2934
|
if (Object.hasOwn(scene.items, dragged) && scene.items[dragged].fixed) return anchorTargets(scene, dragged, options);
|
|
2881
|
-
const ctx = context(scene, dragged, options);
|
|
2935
|
+
const ctx = context(scene, dragged, options, hidden);
|
|
2882
2936
|
if (!ctx) return { targets: [], refusals: [], lost: [] };
|
|
2883
2937
|
const { c, item, prev } = ctx;
|
|
2884
2938
|
const { now } = c;
|
|
@@ -3041,4 +3095,4 @@ export {
|
|
|
3041
3095
|
refusalTargets,
|
|
3042
3096
|
stops
|
|
3043
3097
|
};
|
|
3044
|
-
//# sourceMappingURL=chunk-
|
|
3098
|
+
//# sourceMappingURL=chunk-2PWDUBPG.js.map
|