@n-uf/placement 26.11.37 → 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 +50 -0
- package/README.md +35 -3
- package/dist/chunk-2IZ6JZV5.js +9 -0
- package/dist/chunk-2IZ6JZV5.js.map +1 -0
- package/dist/{chunk-2PWDUBPG.js → chunk-US2TGS3W.js} +126 -41
- package/dist/chunk-US2TGS3W.js.map +1 -0
- package/dist/desk.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/{model-CuE-ML-f.d.ts → model-gUF8juqt.d.ts} +34 -5
- package/dist/panels.d.ts +3 -3
- package/dist/scene-cases.d.ts +17 -9
- package/dist/scene-cases.js +40 -6
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +16 -5
- package/dist/scene.js +3 -1
- package/dist/stack.d.ts +1 -1
- package/dist/target-Db9z1bWt.d.ts +50 -0
- package/dist/{targets-DnVNZVQW.d.ts → targets-CYs16P4K.d.ts} +1 -1
- package/dist/targets.d.ts +2 -2
- package/dist/tiling.d.ts +1 -1
- package/package.json +2 -2
- package/dist/chunk-2PWDUBPG.js.map +0 -1
- package/dist/target-fhD5UVlt.d.ts +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,56 @@
|
|
|
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
|
+
|
|
27
|
+
## 26.11.38
|
|
28
|
+
|
|
29
|
+
- `./scene`, **`Edge.showIn`** (additive): a hidden edge that names another, static edge lends it its items, which lay
|
|
30
|
+
out, target and stop as if they sat at the end of that edge, while the stored scene keeps them in the hidden edge. Home
|
|
31
|
+
gives back the scene itself; a real move takes the item out of the hidden edge; shown again, the hidden edge holds
|
|
32
|
+
every item no drop moved. Only items whose kind that edge takes are lent (in the first zone that takes them, where
|
|
33
|
+
their own doesn't). Never stored (`readScene` lists a stored one as `edge:<id>:showIn`); a `showIn` naming the edge
|
|
34
|
+
itself, no edge, another hidden edge or a dynamic column (drops make and delete those) is ignored and noted as
|
|
35
|
+
`show-in-ignored`: `SceneNote` gains that code, so an exhaustive `switch` over `code` needs a case for it. A moved
|
|
36
|
+
item keeps its stored zone unless the drop names one. `canFold` and `fold` read a lent item where it is drawn. Scenes
|
|
37
|
+
without it are unchanged.
|
|
38
|
+
|
|
39
|
+
- `./scene`, **the window's edge belongs only to the targets drawn against it** (pick change). Every refusal now
|
|
40
|
+
carries the stage as `bounds` (`SceneRefusal.bounds`, passed on by `refusalTargets`), and so does the float target
|
|
41
|
+
(`Target.bounds`): with `@n-uf/motion/drag` 26.11.38 they hold only points strictly inside the window. A pointer a
|
|
42
|
+
host clamps exactly onto the window's edge (`x + width`; one clamped to `width - 0.5` still picks inside) picks a gap
|
|
43
|
+
or slot whose hit reaches the edge (P7-end-reach still lands in the last gap), else nothing: a drop past the window over open space, or past a refused bar, commits nothing, where it floated
|
|
44
|
+
before. Conformance row C17's expected answer changed (the float dropped past the stage's right edge stays where it
|
|
45
|
+
was), and new row `P7-past-a-refused-bar`; a host on an older library fails them until it upgrades. The reference
|
|
46
|
+
host's `pickTarget` and `PickCandidate.bounds` follow.
|
|
47
|
+
|
|
48
|
+
- `./scene`, **a target always beats a refusal where they meet** (pick change). A refusal ranks at the new
|
|
49
|
+
`REFUSAL_RANK` (2.5, from the package root with `pickRank`), whatever its `priority`: an ordering rank, not a
|
|
50
|
+
priority (priorities stay the integers 1 to 3; `refuse: true` is the tier), after every target of priority 1 and 2,
|
|
51
|
+
before priority 3. A test holds it equal to the drag intent's `REFUSAL_RANK`. `@n-uf/motion/drag`'s `targetAt` (26.11.38) applies it; the reference host's
|
|
52
|
+
`pickTarget` and `PickCandidate.refuse` follow. A refusal that shared an edge with a larger target took that edge (a
|
|
53
|
+
gap's last row of px on a refused bar, the outer new-column line where it ends on a status line); now the target
|
|
54
|
+
does. New conformance row `P7-target-meets-a-refusal`. A host on an older drag intent fails it until it upgrades.
|
|
55
|
+
|
|
6
56
|
## 26.11.37
|
|
7
57
|
|
|
8
58
|
- `./scene`, **`Edge.hidden`** (additive): an edge kept in the scene with its items but not in the window, such as a
|
package/README.md
CHANGED
|
@@ -823,6 +823,22 @@ a blocked rect) gives back the scene itself. `moveTo` into it is refused, as int
|
|
|
823
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
824
|
ring put it in the order. Side columns, rails and bars alike.
|
|
825
825
|
|
|
826
|
+
**Showing a hidden edge's items elsewhere.** A hidden edge with `Edge.showIn` (the id of another, static edge) lends
|
|
827
|
+
its items to that edge: a rail turned off on a narrow window whose panels show in the column beside it, say. Like `hidden`, it
|
|
828
|
+
comes from `base` and is never stored. The lent items lay out, target and stop as if they sat at the end of that edge,
|
|
829
|
+
after its own items: `solve` draws them there (the hidden edge itself stays out of the layout), and a drag of one gets
|
|
830
|
+
exactly the targets, refusals, stops and release layouts it would get there. The stored scene keeps them in the hidden
|
|
831
|
+
edge: the home target, or one that commits nothing, gives back the scene itself; a drop that moves one for real takes
|
|
832
|
+
it out of the hidden edge, to the drop's place; a drop of another item never moves them out. Shown again
|
|
833
|
+
(`hidden: false`), the hidden edge holds every item no drop moved. An item is lent only where that edge takes its kind
|
|
834
|
+
(`edgeTakes`), in its own zone where the edge takes it there, else in the first zone that does; fixed items are never
|
|
835
|
+
lent, and one that isn't stays as in a hidden edge (drawn nowhere, no targets). A moved item keeps its stored zone
|
|
836
|
+
(`align`), not the one it was shown in, unless the drop names a zone (a gap in an edge). `canFold`, `fold` and the
|
|
837
|
+
hand fold read a lent item along the edge it is drawn in. A `showIn` that names the edge itself, no edge, another
|
|
838
|
+
hidden edge or a dynamic column (`column: true`) is ignored, and `solve` lists it in `notes` as `show-in-ignored`:
|
|
839
|
+
drops make and delete dynamic columns, so they never hold lent items, and a lent item never vanishes because another
|
|
840
|
+
drop emptied the column it showed in.
|
|
841
|
+
|
|
826
842
|
**Each edge is a stack.** Left and right edges are columns (`forms.column`), top and bottom ones bars (`forms.row`),
|
|
827
843
|
each solved by `fitStack` along the length it gets, with `gap`, `pad` and `menu` passed through, its cross limits never
|
|
828
844
|
wider than the room the cut leaves. Group forms in a column take their own width (`ownCross`); open panels and headers
|
|
@@ -856,9 +872,15 @@ Hits, clicks, drags and `after()` work as for the tile, at the title's length.
|
|
|
856
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
|
|
857
873
|
least and `cross.max` at most; `resize` sets it.
|
|
858
874
|
|
|
859
|
-
**Zones.** An item's `align` (`start`, the default, `center` or `end`) is its zone
|
|
860
|
-
|
|
861
|
-
|
|
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.
|
|
862
884
|
|
|
863
885
|
**Bar alignment zones.** A horizontal bar picks the zone of a drop by thirds of its length: a pointer in the left third
|
|
864
886
|
is over the leading zone (`start`), in the middle third over the center zone, in the right third over the trailing zone
|
|
@@ -1186,6 +1208,16 @@ facing halves is home's, and is no target of its own. The slot is where the item
|
|
|
1186
1208
|
reaches past the stage. Hand them to the drag intent with the targets: `refusalTargets(refusals(scene, id))` gives
|
|
1187
1209
|
each one as a target marked `refuse: true` (its `refusal` the `SceneRefusal`), which the intent never holds or
|
|
1188
1210
|
shows, so a held target's band never covers a refusal; read "No room here" from the frame's `refused`.
|
|
1211
|
+
In the pick a refusal ranks at `REFUSAL_RANK` (2.5, exported with `pickRank`, the drag intent's value): an ordering
|
|
1212
|
+
rank, not a priority (priorities stay 1, 2 and 3; `refuse: true` is a refusal's tier), after every target of
|
|
1213
|
+
priority 1 and 2, before the float's 3. Where a refusal and a target meet or overlap (a gap's end on a refused bar's edge), the
|
|
1214
|
+
target wins however small the refusal is; over the refusal alone it wins over the float.
|
|
1215
|
+
The window's edge belongs only to the targets drawn against it: every refusal (`SceneRefusal.bounds`, passed on by
|
|
1216
|
+
`refusalTargets`) and the float target carry the stage as `bounds` (`Target.bounds`), so they hold only points
|
|
1217
|
+
strictly inside the window. A pointer a host clamps exactly onto the window's edge (the host contract: `x + width`,
|
|
1218
|
+
`y + height`) picks a gap or slot whose hit reaches the edge, else nothing: a drop past the window over open space or
|
|
1219
|
+
past a refused bar commits nothing, and a held gap keeps its band. A host that clamps to `width - 0.5` still picks
|
|
1220
|
+
inside the window, the float or a refusal there included.
|
|
1189
1221
|
Every target keeps a reachable hit: its largest piece is at least 12 px across by 24 px along (`minHit`, data per
|
|
1190
1222
|
edge kind), taken from the space beside it in its own zone (a column line's band, a gap's tile) where nothing else is
|
|
1191
1223
|
aimed at, or from a neighbor that keeps its own minimum. Home, a drop strip, a refusal, the chrome and the stage's
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/target.ts"],"sourcesContent":["import type { Rect } from \"./geometry\";\n\n/**\n * A drop target in the shape @n-uf/motion/drag takes: an id, a priority (1 most precise: a rail or a tab strip;\n * 2 a slot; 3 a broad area such as floating anywhere), the zone the pointer hits, and optionally where the item\n * lands, a label and whether it lands freely (no room is made for it). `hits`, when given, is the whole zone as several\n * rects (a zone that isn't one rect), `hit` the largest of them: the pointer is in the zone when it is in any of them.\n * `arm: \"dwell\"` marks a spring-loaded target (the drag intent arms it once the pointer dwells in it), `armedHit` its\n * zone once armed.\n */\nexport interface Target {\n readonly id: string;\n readonly priority: 1 | 2 | 3;\n readonly hit: Rect;\n readonly hits?: readonly Rect[];\n /** Spring-loaded: no target until the pointer dwells in it. */\n readonly arm?: \"dwell\";\n /** Its zone once armed (the strip grown by its magnet). */\n readonly armedHit?: Rect;\n readonly slot?: Rect;\n readonly label?: string;\n readonly free?: boolean;\n /**\n * A refusal, not a target: it takes part in the pick under the pointer, ranked after every target of priority 1 and 2\n * and before priority 3 (`REFUSAL_RANK`, whatever its `priority`), but nothing lands on it (`refusalTargets`).\n */\n readonly refuse?: true;\n /**\n * The drawn space the zone belongs to (the window's stage): the zone, and a drag intent's band and gap grace about\n * it, hold only points strictly inside it. The window's boundary belongs only to the targets drawn against it: the\n * scene gives `bounds` to every refusal and to the float (whole-plane), never to a gap or a slot, so a pointer clamped\n * onto the window's edge picks a gap that reaches it, else nothing. That relies on the host clamping exactly onto the\n * stage's edge (`x + width`, `y + height`): a host that clamps to `width - 0.5` still picks inside the window.\n */\n readonly bounds?: Rect;\n}\n\n/**\n * Where a refusal ranks in the pick (the drag intent's `REFUSAL_RANK`, the same value): an ordering rank, not a\n * priority. Priorities stay the integers 1, 2 and 3; a refusal's tier is `refuse: true`, ordered by this rank on the\n * same scale: after every target of priority 1 and 2, so a real target wins wherever the two meet or overlap, and\n * before priority 3 (the float).\n */\nexport const REFUSAL_RANK = 2.5;\n\n/** A target's rank in the pick: its `priority`, a refusal's {@link REFUSAL_RANK}. Lower wins. */\nexport const pickRank = (t: { readonly priority: number; readonly refuse?: true }): number => (t.refuse === true ? REFUSAL_RANK : t.priority);\n"],"mappings":";AA2CO,IAAM,eAAe;AAGrB,IAAM,WAAW,CAAC,MAAsE,EAAE,WAAW,OAAO,eAAe,EAAE;","names":[]}
|
|
@@ -59,23 +59,82 @@ 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
|
|
63
|
-
|
|
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
|
+
}
|
|
67
|
+
var showInOf = (scene, e) => {
|
|
68
|
+
if (e.hidden !== true || e.showIn === void 0) return void 0;
|
|
69
|
+
const to = scene.edges.find((x) => x.id === e.showIn);
|
|
70
|
+
return to && to !== e && to.hidden !== true && to.column !== true ? to : void 0;
|
|
71
|
+
};
|
|
72
|
+
function viewOf(scene) {
|
|
73
|
+
const lent = /* @__PURE__ */ new Map();
|
|
74
|
+
const ignored = [];
|
|
75
|
+
const added = /* @__PURE__ */ new Map();
|
|
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
|
+
}
|
|
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) {
|
|
97
|
+
for (const id of e.items) {
|
|
98
|
+
const item = Object.hasOwn(scene.items, id) ? scene.items[id] : void 0;
|
|
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);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!hidden && !items) return { view: scene, lent, ignored, rezoned };
|
|
109
|
+
return { view: { ...scene, edges, ...items ? { items } : {} }, lent, ignored, rezoned };
|
|
64
110
|
}
|
|
65
111
|
var inHiddenEdge = (scene, id) => scene.edges.some((e) => e.hidden === true && e.items.includes(id));
|
|
66
|
-
function withHiddenOf(scene, shown) {
|
|
67
|
-
if (shown === scene
|
|
68
|
-
const
|
|
112
|
+
function withHiddenOf(scene, shown, lent = /* @__PURE__ */ new Map(), moved, zoned = false, rezoned = /* @__PURE__ */ new Set()) {
|
|
113
|
+
if (shown === scene) return shown;
|
|
114
|
+
const back = [...lent.keys()].filter((id) => id !== moved);
|
|
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);
|
|
69
116
|
scene.edges.forEach((e, i) => {
|
|
70
|
-
if (e.hidden
|
|
117
|
+
if (e.hidden !== true) return;
|
|
118
|
+
const own = moved !== void 0 && lent.get(moved) === e.id ? { ...e, items: e.items.filter((id) => id !== moved) } : e;
|
|
119
|
+
edges.splice(Math.min(i, edges.length), 0, own);
|
|
71
120
|
});
|
|
121
|
+
const items = back.length > 0 ? { ...shown.items, ...Object.fromEntries(back.map((id) => [id, scene.items[id]])) } : { ...shown.items };
|
|
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 };
|
|
130
|
+
}
|
|
72
131
|
const ringBefore = new Map(scene.edges.filter((e) => e.hidden !== true).map((e) => [e.id, e.ring]));
|
|
73
132
|
for (const side of new Set(scene.edges.filter((e) => e.hidden === true).map((e) => e.side))) {
|
|
74
133
|
const was = scene.edges.filter((e) => e.side === side && e.hidden !== true).map((e) => e.id).sort();
|
|
75
134
|
const now = edges.filter((e) => e.side === side && e.hidden !== true);
|
|
76
135
|
if (now.length === was.length && now.every((e) => was.includes(e.id))) continue;
|
|
77
136
|
const order = [...now].sort((a, b) => a.ring - b.ring || edges.indexOf(a) - edges.indexOf(b));
|
|
78
|
-
for (const h of
|
|
137
|
+
for (const h of edges.filter((e) => e.side === side && e.hidden === true).sort((a, b) => a.ring - b.ring)) {
|
|
79
138
|
const k = order.findIndex((e) => e.hidden !== true && (ringBefore.get(e.id) ?? -Infinity) > h.ring);
|
|
80
139
|
order.splice(k < 0 ? order.length : k, 0, h);
|
|
81
140
|
}
|
|
@@ -83,7 +142,7 @@ function withHiddenOf(scene, shown) {
|
|
|
83
142
|
if (e.ring !== ring) edges[edges.indexOf(e)] = { ...e, ring };
|
|
84
143
|
});
|
|
85
144
|
}
|
|
86
|
-
return { ...shown, edges };
|
|
145
|
+
return { ...shown, edges, items };
|
|
87
146
|
}
|
|
88
147
|
function railPolicyOf(scene, kind) {
|
|
89
148
|
const p = Object.hasOwn(scene.railDrop ?? {}, kind) ? scene.railDrop[kind] : void 0;
|
|
@@ -143,15 +202,22 @@ function startOf(item, forms, edge) {
|
|
|
143
202
|
const folded = foldedIndex(item, forms, edge);
|
|
144
203
|
return folded < 0 ? 0 : Math.min(Math.max(folded, Math.floor(item.from)), forms.length - 1);
|
|
145
204
|
}
|
|
146
|
-
function
|
|
205
|
+
function placingOf(scene, id) {
|
|
206
|
+
if (!scene.edges.some((e) => e.hidden === true && e.showIn !== void 0 && e.items.includes(id))) return scene;
|
|
207
|
+
const { view, lent } = viewOf(scene);
|
|
208
|
+
return lent.has(id) ? view : scene;
|
|
209
|
+
}
|
|
210
|
+
function axesOf(given, id) {
|
|
211
|
+
const scene = placingOf(given, id);
|
|
147
212
|
const item = scene.items[id];
|
|
148
213
|
const edge = scene.edges.find((e) => e.items.includes(id));
|
|
149
214
|
if (edge) return [axisOf(edge.side)];
|
|
150
215
|
const float = scene.floats.find((f) => f.id === id);
|
|
151
216
|
return float && item ? [float.orient ?? floatOrientOf(item)] : ["row", "column"];
|
|
152
217
|
}
|
|
153
|
-
function isHandFolded(
|
|
154
|
-
const
|
|
218
|
+
function isHandFolded(given, id) {
|
|
219
|
+
const scene = placingOf(given, id);
|
|
220
|
+
const item = Object.hasOwn(given.items, id) ? given.items[id] : void 0;
|
|
155
221
|
const edge = scene.edges.find((e) => e.items.includes(id));
|
|
156
222
|
return !!item && axesOf(scene, id).some((a) => startOf(item, formsOf(item, a), edge) > 0);
|
|
157
223
|
}
|
|
@@ -1089,11 +1155,12 @@ function laySide(d, side, cols, g, area2, f, walk, upInset, tall) {
|
|
|
1089
1155
|
// src/scene/solve.ts
|
|
1090
1156
|
function solve(given, options = {}) {
|
|
1091
1157
|
checkEdgeIds(given);
|
|
1092
|
-
const shown =
|
|
1158
|
+
const { view: shown, ignored } = viewOf(given);
|
|
1093
1159
|
const lay = (caps, gave = []) => layOut(shown, options, caps, gave);
|
|
1094
1160
|
const first = lay(/* @__PURE__ */ new Map());
|
|
1095
1161
|
const way = barGiveWay(shown, first, lay);
|
|
1096
|
-
|
|
1162
|
+
const l = way ? lay(way.caps, way.notes) : first;
|
|
1163
|
+
return ignored.length === 0 ? l : { ...l, notes: [...l.notes, ...ignored.map((edge) => ({ code: "show-in-ignored", edge }))] };
|
|
1097
1164
|
}
|
|
1098
1165
|
var withHeightOf = (area2, over) => rect(over.x, area2.y, over.width, area2.height);
|
|
1099
1166
|
function layOut(given, options, caps, gave) {
|
|
@@ -1299,22 +1366,22 @@ function insertColumn(scene0, id, side, ring, others) {
|
|
|
1299
1366
|
const col = newColumn(scene, side, kind, r, [id], others);
|
|
1300
1367
|
if (!col) return null;
|
|
1301
1368
|
if (!zoneTakes(col, "start", kind)) return null;
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1304
|
-
const { align: _a, ...plain } = item;
|
|
1305
|
-
const placed = withItem(scene, zone === "start" ? plain : { ...plain, align: zone });
|
|
1306
|
-
const shifted = placed.edges.map((e) => e.side === side && e.ring >= r ? { ...e, ring: e.ring + 1 } : e);
|
|
1307
|
-
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])) };
|
|
1308
1371
|
}
|
|
1372
|
+
var zoneAt = (scene, edge, id) => {
|
|
1373
|
+
const it = itemOf(scene, id);
|
|
1374
|
+
return it ? zoneIn(edge, it) : "start";
|
|
1375
|
+
};
|
|
1309
1376
|
function insertIndex(scene, edge, zone, at) {
|
|
1310
1377
|
const rank = { start: 0, center: 1, end: 2 };
|
|
1311
|
-
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);
|
|
1312
1379
|
const k = Math.min(Math.max(0, Math.floor(Number.isFinite(at) ? at : inZone.length)), inZone.length);
|
|
1313
1380
|
if (k < inZone.length) return inZone[k].i;
|
|
1314
1381
|
if (inZone.length > 0) return inZone[inZone.length - 1].i + 1;
|
|
1315
1382
|
let idx = 0;
|
|
1316
1383
|
edge.items.forEach((id, i) => {
|
|
1317
|
-
if (rank[
|
|
1384
|
+
if (rank[zoneAt(scene, edge, id)] < rank[zone]) idx = i + 1;
|
|
1318
1385
|
});
|
|
1319
1386
|
return idx;
|
|
1320
1387
|
}
|
|
@@ -1332,7 +1399,7 @@ function moveAmong(scene, id, place, others) {
|
|
|
1332
1399
|
}
|
|
1333
1400
|
const railColumn = place.kind === "rail" ? railColumnOf(scene, place.side, item.kind) : void 0;
|
|
1334
1401
|
if (railColumn) {
|
|
1335
|
-
const docked = moveAmong(scene, id, { edge: railColumn.id,
|
|
1402
|
+
const docked = moveAmong(scene, id, { edge: railColumn.id, at: Infinity }, others);
|
|
1336
1403
|
return docked === scene ? scene : withItem(docked, { ...docked.items[id], from: Math.max(1, item.from ?? 0) });
|
|
1337
1404
|
}
|
|
1338
1405
|
if (place.kind === "column" || place.kind === "rail") {
|
|
@@ -1343,10 +1410,10 @@ function moveAmong(scene, id, place, others) {
|
|
|
1343
1410
|
}
|
|
1344
1411
|
const edge = scene.edges.find((e) => e.id === place.edge);
|
|
1345
1412
|
if (!edge || edge.hidden === true || !edge.accepts.includes(item.kind)) return scene;
|
|
1346
|
-
const zone = place.zone ?? (
|
|
1347
|
-
if (!
|
|
1413
|
+
const zone = place.zone ?? zoneIn(edge, item);
|
|
1414
|
+
if (!zoneTakes(edge, zone, item.kind)) return scene;
|
|
1348
1415
|
const { align: _drop, ...rest } = item;
|
|
1349
|
-
const moved = zone === "start" ? rest : { ...rest, align: zone };
|
|
1416
|
+
const moved = place.zone === void 0 ? item : zone === "start" ? rest : { ...rest, align: zone };
|
|
1350
1417
|
const lifted = withItem(lift(scene, id), moved);
|
|
1351
1418
|
const target = lifted.edges.find((e) => e.id === place.edge);
|
|
1352
1419
|
if (!target) return scene;
|
|
@@ -1373,7 +1440,7 @@ function floatAt(scene, id, at, orient2) {
|
|
|
1373
1440
|
function canFold(scene, id) {
|
|
1374
1441
|
const item = itemOf(scene, id);
|
|
1375
1442
|
if (!item || item.fixed && !scene.edges.some((e) => e.foldable === true && e.items.includes(id))) return false;
|
|
1376
|
-
const edge = scene.edges.find((e) => e.items.includes(id));
|
|
1443
|
+
const edge = placingOf(scene, id).edges.find((e) => e.items.includes(id));
|
|
1377
1444
|
return axesOf(scene, id).some((a) => foldedIndex(item, formsOf(item, a), edge) >= 0);
|
|
1378
1445
|
}
|
|
1379
1446
|
function fold(scene, id, on) {
|
|
@@ -1454,11 +1521,12 @@ function homeFor(scene, id, start) {
|
|
|
1454
1521
|
for (const e of start.edges) {
|
|
1455
1522
|
const k = e.items.indexOf(id);
|
|
1456
1523
|
if (k < 0) continue;
|
|
1457
|
-
const
|
|
1524
|
+
const own = itemOf(start, id) ?? itemOf(scene, id);
|
|
1458
1525
|
const found = scene.edges.find((x) => x.id === e.id);
|
|
1459
1526
|
const here = found && (e.column !== true || found.items.some((x) => e.items.includes(x))) ? found : void 0;
|
|
1460
1527
|
if (here) {
|
|
1461
|
-
const
|
|
1528
|
+
const zone = own ? zoneIn(here, own) : "start";
|
|
1529
|
+
const now = here.items.filter((x) => x !== id && zoneAt(scene, here, x) === zone);
|
|
1462
1530
|
const next = e.items.slice(k + 1).find((x) => now.includes(x));
|
|
1463
1531
|
return { kind: "gap", edge: e.id, zone, at: next ? now.indexOf(next) : now.length };
|
|
1464
1532
|
}
|
|
@@ -1475,10 +1543,18 @@ function dockHome(scene, id, start) {
|
|
|
1475
1543
|
const moved = moveTo(scene, id, place);
|
|
1476
1544
|
const item = itemOf(moved, id);
|
|
1477
1545
|
if (!item) return scene;
|
|
1478
|
-
const
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
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);
|
|
1482
1558
|
}
|
|
1483
1559
|
function clampFloat(r, stage, drawn = r) {
|
|
1484
1560
|
const at = clampInto({ x: r.x, y: r.y, width: drawn.width, height: drawn.height }, stage);
|
|
@@ -1642,6 +1718,7 @@ function read(data, base) {
|
|
|
1642
1718
|
}
|
|
1643
1719
|
if (edge.column === true && isNum(e.ring)) rings.set(edge.id, e.ring);
|
|
1644
1720
|
if (e.hidden !== void 0) drop(`edge:${edge.id}:hidden`);
|
|
1721
|
+
if (e.showIn !== void 0) drop(`edge:${edge.id}:showIn`);
|
|
1645
1722
|
if (e.side !== void 0 && !SIDES.includes(e.side)) drop(`edge:${e.id}:side`);
|
|
1646
1723
|
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);
|
|
1647
1724
|
const ids = [];
|
|
@@ -1796,7 +1873,7 @@ function zoneSpans(scene, seen, edge, reach, probe) {
|
|
|
1796
1873
|
const placed = /* @__PURE__ */ new Map();
|
|
1797
1874
|
for (const [id, it] of Object.entries(seen.items)) {
|
|
1798
1875
|
if (it.edge !== edge.id || it.inMenu) continue;
|
|
1799
|
-
const z = zoneOf(scene.items[id]);
|
|
1876
|
+
const z = it.zone ?? zoneOf(scene.items[id]);
|
|
1800
1877
|
const [a, b] = at(thirds && it.fixed ? reservedRect(scene, seen, id) : it.rect);
|
|
1801
1878
|
const was = placed.get(z);
|
|
1802
1879
|
placed.set(z, was ? [Math.min(was[0], a), Math.max(was[1], b)] : [a, b]);
|
|
@@ -2909,23 +2986,26 @@ function alongOfSlots(s, tiles) {
|
|
|
2909
2986
|
}
|
|
2910
2987
|
function generate(scene, dragged, options) {
|
|
2911
2988
|
checkEdgeIds(scene);
|
|
2912
|
-
const shown =
|
|
2989
|
+
const { view: shown, lent, rezoned } = viewOf(scene);
|
|
2913
2990
|
if (shown === scene) return generateShown(scene, dragged, options, []);
|
|
2914
|
-
if (inHiddenEdge(scene, dragged)) return { targets: [], refusals: [], lost: [] };
|
|
2991
|
+
if (inHiddenEdge(scene, dragged) && !lent.has(dragged)) return { targets: [], refusals: [], lost: [] };
|
|
2915
2992
|
const hidden = scene.edges.filter((e) => e.hidden === true);
|
|
2916
2993
|
const g = generateShown(shown, dragged, options, hidden);
|
|
2917
2994
|
const prev = { ...options.previous ? { previous: options.previous } : {}, ...options.fresh ? { fresh: options.fresh } : {} };
|
|
2995
|
+
const showsIn = hidden.some((e) => e.showIn !== void 0);
|
|
2918
2996
|
return {
|
|
2919
2997
|
...g,
|
|
2920
2998
|
targets: g.targets.map((t) => ({
|
|
2921
2999
|
...t,
|
|
2922
3000
|
after: (point, grab) => {
|
|
2923
3001
|
const a = t.after(point, grab);
|
|
2924
|
-
if (a.scene === shown) return { scene, layout: a.layout };
|
|
2925
|
-
const
|
|
3002
|
+
if (a.scene === shown) return { scene, layout: showsIn ? solve(scene, prev) : a.layout };
|
|
3003
|
+
const back = withHiddenOf(scene, a.scene, lent, dragged, t.place.kind === "gap", rezoned);
|
|
3004
|
+
const restored = showsIn ? prune(back) : back;
|
|
2926
3005
|
const ringOf = new Map(a.scene.edges.map((e) => [e.id, e.ring]));
|
|
2927
3006
|
const renumbered = restored.edges.some((e) => e.hidden !== true && ringOf.get(e.id) !== e.ring);
|
|
2928
|
-
|
|
3007
|
+
const layout = renumbered || showsIn || rezoned.size > 0 ? solve(restored, prev) : a.layout;
|
|
3008
|
+
return { scene: restored, layout };
|
|
2929
3009
|
}
|
|
2930
3010
|
}))
|
|
2931
3011
|
};
|
|
@@ -2959,6 +3039,8 @@ function generateShown(scene, dragged, options, hidden) {
|
|
|
2959
3039
|
priority: 3,
|
|
2960
3040
|
free: true,
|
|
2961
3041
|
hit: PLANE,
|
|
3042
|
+
// Over the whole plane, but only strictly inside the stage: its edge belongs to the targets drawn against it.
|
|
3043
|
+
bounds: stageOf(scene),
|
|
2962
3044
|
item: dragged,
|
|
2963
3045
|
place: { kind: "float" },
|
|
2964
3046
|
after(point, grab) {
|
|
@@ -2990,8 +3072,10 @@ function generateShown(scene, dragged, options, hidden) {
|
|
|
2990
3072
|
const layered = withRailStrips(c, targets2, refused);
|
|
2991
3073
|
const zones = /* @__PURE__ */ new Map();
|
|
2992
3074
|
for (const t of [...alone.values()].flat()) if (t.kind !== "refuse" && t.id) zones.set(t.id, [...zones.get(t.id) ?? [], t.hit]);
|
|
2993
|
-
|
|
3075
|
+
const bounds = stageOf(scene);
|
|
3076
|
+
return { targets: withMinHit(c, layered.targets, layered.refusals, zones), refusals: layered.refusals.map((r) => ({ ...r, bounds })), lost: lostIds, zones };
|
|
2994
3077
|
}
|
|
3078
|
+
var stageOf = (scene) => rect(scene.stage.x, scene.stage.y, scene.stage.width, scene.stage.height);
|
|
2995
3079
|
function targets(scene, dragged, options = {}) {
|
|
2996
3080
|
return generate(scene, dragged, options).targets;
|
|
2997
3081
|
}
|
|
@@ -2999,7 +3083,7 @@ function refusals(scene, dragged, options = {}) {
|
|
|
2999
3083
|
return generate(scene, dragged, options).refusals;
|
|
3000
3084
|
}
|
|
3001
3085
|
function refusalTargets(list) {
|
|
3002
|
-
return list.map((r) => ({ id: r.id, priority: 2, hit: r.hit, ...r.hits ? { hits: r.hits } : {}, refuse: true, refusal: r }));
|
|
3086
|
+
return list.map((r) => ({ id: r.id, priority: 2, hit: r.hit, ...r.hits ? { hits: r.hits } : {}, ...r.bounds ? { bounds: r.bounds } : {}, refuse: true, refusal: r }));
|
|
3003
3087
|
}
|
|
3004
3088
|
var SIDE_RANK = { left: 0, top: 1, bottom: 2, right: 3 };
|
|
3005
3089
|
function stops(scene, dragged, options = {}) {
|
|
@@ -3061,6 +3145,7 @@ export {
|
|
|
3061
3145
|
zonesTaking,
|
|
3062
3146
|
edgeTakes,
|
|
3063
3147
|
railModeOf,
|
|
3148
|
+
zoneIn,
|
|
3064
3149
|
isOutsideSideBar,
|
|
3065
3150
|
isSideBar,
|
|
3066
3151
|
floatOrientOf,
|
|
@@ -3095,4 +3180,4 @@ export {
|
|
|
3095
3180
|
refusalTargets,
|
|
3096
3181
|
stops
|
|
3097
3182
|
};
|
|
3098
|
-
//# sourceMappingURL=chunk-
|
|
3183
|
+
//# sourceMappingURL=chunk-US2TGS3W.js.map
|