@n-uf/docking 26.11.55 → 26.11.57
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 +110 -0
- package/dist/{chunk-4V35LE5X.js → chunk-JBKUC72Z.js} +410 -238
- package/dist/chunk-JBKUC72Z.js.map +1 -0
- package/dist/{drag-yfr_Ng9Q.d.ts → drag-CyrphFye.d.ts} +126 -20
- package/dist/index.d.ts +11 -6
- package/dist/index.js +3 -1
- package/dist/testing.d.ts +12 -6
- package/dist/testing.js +7 -8
- package/dist/testing.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-4V35LE5X.js.map +0 -1
|
@@ -50,7 +50,13 @@ var columnFromTemplate = (t, id, side, ring, items) => ({
|
|
|
50
50
|
});
|
|
51
51
|
var railModeOf = (state, side) => side === "left" || side === "right" ? state.railModes?.[side] === "icons" ? "icons" : "titles" : "icons";
|
|
52
52
|
var axisOf = (side) => side === "left" || side === "right" ? "column" : "row";
|
|
53
|
-
var
|
|
53
|
+
var isAnchoredKeepClear = (c) => "region" in c;
|
|
54
|
+
var keepClearFor = (state, layout, who) => {
|
|
55
|
+
const takes = (f) => who === "floats" || f !== "floats";
|
|
56
|
+
const fixed = (state.keepClear ?? []).filter((c) => !isAnchoredKeepClear(c) && takes(c.for)).map((c) => ({ x: c.x, y: c.y, width: c.width, height: c.height }));
|
|
57
|
+
const anchored2 = (layout.keepClear ?? []).filter((c) => takes(c.for)).map((c) => ({ ...c.rect }));
|
|
58
|
+
return anchored2.length === 0 ? fixed : [...fixed, ...anchored2];
|
|
59
|
+
};
|
|
54
60
|
function railColumnOf(state, side, kind) {
|
|
55
61
|
if (state.rails?.[side]) return void 0;
|
|
56
62
|
return state.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);
|
|
@@ -261,7 +267,7 @@ function floatShape(item, f) {
|
|
|
261
267
|
}
|
|
262
268
|
|
|
263
269
|
// src/solve.ts
|
|
264
|
-
import { rect as
|
|
270
|
+
import { rect as rect7 } from "@n-uf/placement";
|
|
265
271
|
|
|
266
272
|
// src/targets/ids.ts
|
|
267
273
|
function targetId(parts) {
|
|
@@ -429,7 +435,7 @@ import { cutEdges } from "@n-uf/placement/stack";
|
|
|
429
435
|
|
|
430
436
|
// src/solve/draft.ts
|
|
431
437
|
import { EPS as EPS2, rect } from "@n-uf/placement";
|
|
432
|
-
import { formMain, wrapLines } from "@n-uf/placement/stack";
|
|
438
|
+
import { formMain, itemSteps, wrapLines } from "@n-uf/placement/stack";
|
|
433
439
|
function createDraft(given, options, caps = /* @__PURE__ */ new Map()) {
|
|
434
440
|
const previous = options.previous;
|
|
435
441
|
const opened = /* @__PURE__ */ new Set();
|
|
@@ -483,7 +489,7 @@ function zoneStarts(state, fit, input) {
|
|
|
483
489
|
const at = (r) => column ? r.y : r.x;
|
|
484
490
|
const out = /* @__PURE__ */ new Map();
|
|
485
491
|
const lengths = /* @__PURE__ */ new Map();
|
|
486
|
-
const drawn = fit.items.filter((p) => p.
|
|
492
|
+
const drawn = fit.items.filter((p) => !fit.menu?.items.includes(p.id));
|
|
487
493
|
for (const p of drawn) {
|
|
488
494
|
out.set(p.id, at(p.rect));
|
|
489
495
|
lengths.set(p.id, column ? p.rect.height : p.rect.width);
|
|
@@ -500,7 +506,7 @@ function zoneStarts(state, fit, input) {
|
|
|
500
506
|
const title = column ? void 0 : s.find((p) => {
|
|
501
507
|
const it = state.items[p.id];
|
|
502
508
|
const f = formsOf(it, "row")[p.form];
|
|
503
|
-
return it
|
|
509
|
+
return !itemSteps(it) && f?.main.grows && len2(p) > formMain(f, "natural", fit.cross) + EPS2;
|
|
504
510
|
});
|
|
505
511
|
if (title) lengths.set(title.id, formMain(formsOf(state.items[title.id], "row")[title.form], "natural", fit.cross));
|
|
506
512
|
const used = drawn.reduce((sum, p) => sum + len2(p), 0) + Math.max(0, drawn.length - 1) * gap;
|
|
@@ -557,7 +563,7 @@ function emit(d, edge, r, solved, extra = {}) {
|
|
|
557
563
|
for (const id of solved.leftOutIcons ?? []) notes.push({ code: "no-icons-form", edge: edge.id, id });
|
|
558
564
|
for (const p of stack.items) {
|
|
559
565
|
const it = state.items[p.id];
|
|
560
|
-
const inMenu = p.
|
|
566
|
+
const inMenu = !!stack.menu?.items.includes(p.id);
|
|
561
567
|
const drawnRect2 = toStage(p.rect, inMenu ? void 0 : p.id);
|
|
562
568
|
const f = formsOf(it, column ? "column" : "row")[p.form];
|
|
563
569
|
const shape = inMenu ? {} : shapeOf(f, drawnRect2, column ? "column" : "row", stack.cross);
|
|
@@ -598,7 +604,7 @@ function emit(d, edge, r, solved, extra = {}) {
|
|
|
598
604
|
|
|
599
605
|
// src/solve/edge.ts
|
|
600
606
|
import { EPS as EPS3 } from "@n-uf/placement";
|
|
601
|
-
import { fitStack, formCompact, formCrossMin as formCrossMin2, formSetsCross as formSetsCross2 } from "@n-uf/placement/stack";
|
|
607
|
+
import { fitStack, formCompact, formCrossMin as formCrossMin2, formMenu, formSetsCross as formSetsCross2, itemSteps as itemSteps2 } from "@n-uf/placement/stack";
|
|
602
608
|
var stackItemOf = (item, forms, edge, from) => ({
|
|
603
609
|
id: item.id,
|
|
604
610
|
forms,
|
|
@@ -607,12 +613,13 @@ var stackItemOf = (item, forms, edge, from) => ({
|
|
|
607
613
|
// Where its ladder starts: as asked, else its hand fold resolved on this axis (`startOf`: its folded form).
|
|
608
614
|
...from !== void 0 ? { from } : startOf(item, forms, edge) > 0 ? { from: startOf(item, forms, edge) } : {},
|
|
609
615
|
...item.fixed ? { fixed: true } : {},
|
|
616
|
+
...item.fixed && item.stepping ? { stepping: true } : {},
|
|
610
617
|
...item.lengths ? { lengths: item.lengths } : {}
|
|
611
618
|
});
|
|
612
619
|
var inputs = /* @__PURE__ */ new WeakMap();
|
|
613
620
|
var inputOf = (stack) => inputs.get(stack);
|
|
614
621
|
function hasSetter(fit, forms) {
|
|
615
|
-
return fit.items.some((p) => p.
|
|
622
|
+
return fit.items.some((p) => !formMenu(forms(p.id)[p.form]) && formSetsCross2(forms(p.id)[p.form]));
|
|
616
623
|
}
|
|
617
624
|
var TRAY_RANK = 100;
|
|
618
625
|
var startsOf = (input) => new Map(input.items.map((i) => [i.id, i.from ?? 0]));
|
|
@@ -632,7 +639,7 @@ function compactEdge(f) {
|
|
|
632
639
|
function railEdge(f, free, asStackItem, starts) {
|
|
633
640
|
const { state, edge, formsById } = f;
|
|
634
641
|
const railIndex = (item, forms) => {
|
|
635
|
-
if (item
|
|
642
|
+
if (!itemSteps2(item)) return -1;
|
|
636
643
|
for (let j = startOf(item, forms, edge); j < forms.length; j++) if (forms[j].kind === "rail") return j;
|
|
637
644
|
return -1;
|
|
638
645
|
};
|
|
@@ -717,8 +724,8 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
|
|
|
717
724
|
let moved = false;
|
|
718
725
|
const items = input.items.map((it) => {
|
|
719
726
|
const from = it.from ?? 0;
|
|
720
|
-
if (it
|
|
721
|
-
const j = it.forms.findIndex((f, k) => k > from && f
|
|
727
|
+
if (!itemSteps2(it) || fits(it.forms[from])) return it;
|
|
728
|
+
const j = it.forms.findIndex((f, k) => k > from && !formMenu(f) && fits(f));
|
|
722
729
|
if (j < 0) return it;
|
|
723
730
|
moved = true;
|
|
724
731
|
return { ...it, from: j };
|
|
@@ -730,7 +737,7 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
|
|
|
730
737
|
}
|
|
731
738
|
const size = edge.size;
|
|
732
739
|
if (typeof size === "number" && Number.isFinite(size) && hasSetter(free, formsById)) {
|
|
733
|
-
const setters = free.items.filter((p) => p.
|
|
740
|
+
const setters = free.items.filter((p) => !formMenu(formsById(p.id)[p.form]) && formSetsCross2(formsById(p.id)[p.form]));
|
|
734
741
|
const lo2 = Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin2(formsById(p.id)[p.form])));
|
|
735
742
|
const s = Math.min(Math.max(size, lo2), Math.max(lo2, maxOf), room);
|
|
736
743
|
if (Math.abs(s - free.cross) > EPS3) {
|
|
@@ -743,20 +750,20 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
|
|
|
743
750
|
}
|
|
744
751
|
|
|
745
752
|
// src/solve/bars.ts
|
|
746
|
-
function cutEdge(d, edge,
|
|
753
|
+
function cutEdge(d, edge, area9, cut2) {
|
|
747
754
|
const column = axisOf(edge.side) === "column";
|
|
748
|
-
const length = column ?
|
|
749
|
-
const room = Math.max(0, column ?
|
|
755
|
+
const length = column ? area9.height : area9.width;
|
|
756
|
+
const room = Math.max(0, column ? area9.width : area9.height);
|
|
750
757
|
const cap = d.caps.get(edge.id);
|
|
751
758
|
const solvedAs = cap === void 0 ? edge : { ...edge, cross: { ...edge.cross, max: Math.min(edge.cross.max, cap) } };
|
|
752
759
|
const solved = solveEdge(d.state, solvedAs, d.owned.get(edge), length, room, d.prevEdge(edge));
|
|
753
|
-
const band = cutEdges(
|
|
760
|
+
const band = cutEdges(area9, [{ id: edge.id, side: edge.side, size: solved.stack.items.length === 0 ? 0 : solved.stack.cross }]);
|
|
754
761
|
emit(d, edge, band.bands[edge.id], solved);
|
|
755
|
-
return cut2 ? band.rest :
|
|
762
|
+
return cut2 ? band.rest : area9;
|
|
756
763
|
}
|
|
757
764
|
|
|
758
765
|
// src/solve/floats.ts
|
|
759
|
-
import { EPS as EPS4, rect as rect2 } from "@n-uf/placement";
|
|
766
|
+
import { EPS as EPS4, clampInto as clampInto2, overlaps, rect as rect2 } from "@n-uf/placement";
|
|
760
767
|
import { fitFloat, formFolded as formFolded2 } from "@n-uf/placement/stack";
|
|
761
768
|
var sinceOf = (f) => isSince(f.since) ? f.since : 0;
|
|
762
769
|
function anchored(content, w, h, given) {
|
|
@@ -813,7 +820,26 @@ function fitBeside(want, region, avoid, earlier) {
|
|
|
813
820
|
const both = fitFloat(want, region, [...avoid, ...earlier]);
|
|
814
821
|
return both.covers.length === 0 ? both : fitFloat(want, region, avoid);
|
|
815
822
|
}
|
|
816
|
-
function
|
|
823
|
+
function clearOfWalls(r, region, walls) {
|
|
824
|
+
const under = (c) => walls.filter((w) => overlaps(c, w, 1e-3));
|
|
825
|
+
if (under(r).length === 0) return r;
|
|
826
|
+
const pushes2 = (c) => under(c).flatMap(
|
|
827
|
+
(w) => [rect2(w.x - c.width, c.y, c.width, c.height), rect2(w.x + w.width, c.y, c.width, c.height), rect2(c.x, w.y - c.height, c.width, c.height), rect2(c.x, w.y + w.height, c.width, c.height)].map((m) => clampInto2(m, region))
|
|
828
|
+
);
|
|
829
|
+
const far = (c) => Math.abs(c.x - r.x) + Math.abs(c.y - r.y);
|
|
830
|
+
let best = null;
|
|
831
|
+
for (const a of pushes2(r))
|
|
832
|
+
for (const c of under(a).length === 0 ? [a] : pushes2(a)) if (under(c).length === 0 && (!best || far(c) < far(best) - 1e-9)) best = c;
|
|
833
|
+
return best;
|
|
834
|
+
}
|
|
835
|
+
function fitStays(want, region, avoid, docked) {
|
|
836
|
+
const walls = avoid.slice(docked).filter((w) => w.width > 0 && w.height > 0);
|
|
837
|
+
const inside = clampInto2(want, region);
|
|
838
|
+
const kept = clearOfWalls(inside, region, walls) ?? fitFloat(want, region, walls).rect;
|
|
839
|
+
const over2 = fitFloat(kept, region, avoid, { stay: true });
|
|
840
|
+
return { rect: kept, clamped: kept.x !== want.x || kept.y !== want.y, snapped: false, covers: over2.covers, searchCapped: false };
|
|
841
|
+
}
|
|
842
|
+
function placeFloat(item, f, region, avoid, content, stage, earlier = [], docked = 0) {
|
|
817
843
|
const shape = floatShape(item, f);
|
|
818
844
|
const from = shape.form;
|
|
819
845
|
const fo = f.orient ?? floatOrientOf(item);
|
|
@@ -825,19 +851,20 @@ function placeFloat(item, f, region, avoid, content, stage, earlier = []) {
|
|
|
825
851
|
const folded = !!form && formFolded2(form);
|
|
826
852
|
const h = folded ? shape.height : Math.max(floor.height, Math.min(shape.height, clear.height, cap.height));
|
|
827
853
|
const want = f.anchor ? anchored(content, w, h, f.anchor) : rect2(finite(f.rect.x, stage.x), finite(f.rect.y, stage.y), w, h);
|
|
828
|
-
const fit0 = f.anchor ? fitBeside(want, region, avoid, earlier) : fitFloat(want, region, avoid);
|
|
854
|
+
const fit0 = f.anchor ? fitBeside(want, region, avoid, earlier) : f.stays ? fitStays(want, region, avoid, docked) : fitFloat(want, region, avoid);
|
|
829
855
|
const fit = w > region.width + EPS4 ? { ...fit0, rect: rect2(region.x, fit0.rect.y, w, fit0.rect.height) } : fit0;
|
|
830
856
|
return { from, fo, form, fit };
|
|
831
857
|
}
|
|
832
|
-
function layFloats(d, stage, content, inset) {
|
|
858
|
+
function layFloats(d, stage, content, inset, chrome) {
|
|
833
859
|
const { state, notes, items, edges } = d;
|
|
834
860
|
const avoid = [];
|
|
835
861
|
for (const l of Object.values(items)) avoid.push(l.rect);
|
|
862
|
+
const docked = avoid.length;
|
|
836
863
|
for (const e of Object.values(edges)) {
|
|
837
864
|
if (axisOf(e.side) === "row" && e.cross > 0) avoid.push(e.rect);
|
|
838
865
|
if (e.menu) avoid.push(e.menu.rect);
|
|
839
866
|
}
|
|
840
|
-
for (const c of
|
|
867
|
+
for (const c of chrome) avoid.push(c);
|
|
841
868
|
const floatRegion2 = rect2(stage.x + px(inset.left), stage.y, Math.max(0, stage.width - px(inset.left) - px(inset.right)), stage.height);
|
|
842
869
|
const drawn = [];
|
|
843
870
|
const noForm = /* @__PURE__ */ new Set();
|
|
@@ -850,13 +877,16 @@ function layFloats(d, stage, content, inset) {
|
|
|
850
877
|
}
|
|
851
878
|
const placed = /* @__PURE__ */ new Map();
|
|
852
879
|
const place = (f, earlier = []) => {
|
|
853
|
-
placed.set(f.id, placeFloat(state.items[f.id], f, floatRegion2, avoid, content, stage, earlier));
|
|
880
|
+
placed.set(f.id, placeFloat(state.items[f.id], f, floatRegion2, avoid, content, stage, earlier, docked));
|
|
854
881
|
};
|
|
855
882
|
const live = drawn.filter((f) => !noForm.has(f.id));
|
|
856
|
-
|
|
857
|
-
const
|
|
883
|
+
const own = live.filter((f) => !f.anchor);
|
|
884
|
+
for (const f of own) place(f);
|
|
858
885
|
const anchored2 = live.filter((f) => f.anchor).sort((a, b) => sinceOf(a) - sinceOf(b) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
859
|
-
anchored2.forEach((f, i) =>
|
|
886
|
+
anchored2.forEach((f, i) => {
|
|
887
|
+
const before = own.filter((o) => sinceOf(o) < sinceOf(f)).map((o) => placed.get(o.id).fit.rect);
|
|
888
|
+
place(f, [...before, ...anchored2.slice(0, i).map((a) => placed.get(a.id).fit.rect)]);
|
|
889
|
+
});
|
|
860
890
|
const floats = [];
|
|
861
891
|
for (const f of drawn) {
|
|
862
892
|
if (noForm.has(f.id)) {
|
|
@@ -875,18 +905,55 @@ function layFloats(d, stage, content, inset) {
|
|
|
875
905
|
return floats;
|
|
876
906
|
}
|
|
877
907
|
|
|
908
|
+
// src/solve/keep-clear.ts
|
|
909
|
+
import { rect as rect3 } from "@n-uf/placement";
|
|
910
|
+
var regionRect = (region, content) => region === "content" ? content : null;
|
|
911
|
+
var roomFor = (c, region) => {
|
|
912
|
+
const w = c.minRegion?.width;
|
|
913
|
+
const h = c.minRegion?.height;
|
|
914
|
+
return !(Number.isFinite(w) && region.width < w) && !(Number.isFinite(h) && region.height < h);
|
|
915
|
+
};
|
|
916
|
+
function anchoredRect(c, region) {
|
|
917
|
+
if (!(region.width > 0) || !(region.height > 0) || !Number.isFinite(c.size) || c.size <= 0 || !roomFor(c, region)) return null;
|
|
918
|
+
const w = Math.min(c.size, region.width);
|
|
919
|
+
const h = Math.min(c.size, region.height);
|
|
920
|
+
switch (c.side) {
|
|
921
|
+
case "left":
|
|
922
|
+
return rect3(region.x, region.y, w, region.height);
|
|
923
|
+
case "right":
|
|
924
|
+
return rect3(region.x + region.width - w, region.y, w, region.height);
|
|
925
|
+
case "top":
|
|
926
|
+
return rect3(region.x, region.y, region.width, h);
|
|
927
|
+
case "bottom":
|
|
928
|
+
return rect3(region.x, region.y + region.height - h, region.width, h);
|
|
929
|
+
default:
|
|
930
|
+
return null;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
function resolveKeepClear(state, content) {
|
|
934
|
+
const anchored2 = (state.keepClear ?? []).filter(isAnchoredKeepClear);
|
|
935
|
+
if (anchored2.length === 0) return void 0;
|
|
936
|
+
const out = [];
|
|
937
|
+
for (const c of anchored2) {
|
|
938
|
+
const region = regionRect(c.region, content);
|
|
939
|
+
const r = region ? anchoredRect(c, region) : null;
|
|
940
|
+
if (r) out.push({ rect: r, for: c.for === "floats" ? "floats" : "all", ...typeof c.id === "string" ? { id: c.id } : {} });
|
|
941
|
+
}
|
|
942
|
+
return out;
|
|
943
|
+
}
|
|
944
|
+
|
|
878
945
|
// src/solve/insets.ts
|
|
879
|
-
import { EPS as EPS5, rect as
|
|
946
|
+
import { EPS as EPS5, rect as rect4 } from "@n-uf/placement";
|
|
880
947
|
function insetOf(d) {
|
|
881
948
|
const { state } = d;
|
|
882
949
|
const docked = d.order.some((e) => isSide(e) && e.accepts.length > 0 && d.owned.get(e).some((id) => isDockingPanel(state.items[id])));
|
|
883
950
|
const inset = state.insetWhen === "docked" && !docked ? {} : state.inset ?? {};
|
|
884
951
|
return { inset, docked };
|
|
885
952
|
}
|
|
886
|
-
var insideInset = (outer, inset) =>
|
|
887
|
-
function insetReach(
|
|
888
|
-
const up =
|
|
889
|
-
const down =
|
|
953
|
+
var insideInset = (outer, inset) => rect4(outer.x + px(inset.left), outer.y + px(inset.top), Math.max(0, outer.width - px(inset.left) - px(inset.right)), Math.max(0, outer.height - px(inset.top) - px(inset.bottom)));
|
|
954
|
+
function insetReach(area9, f) {
|
|
955
|
+
const up = area9.y <= f.outer.y + px(f.inset.top) + EPS5 ? px(f.inset.top) : 0;
|
|
956
|
+
const down = area9.y + area9.height >= f.outer.y + f.outer.height - px(f.inset.bottom) - EPS5 ? px(f.inset.bottom) : 0;
|
|
890
957
|
return { up, down };
|
|
891
958
|
}
|
|
892
959
|
|
|
@@ -909,22 +976,22 @@ function contentNotes(d, content) {
|
|
|
909
976
|
}
|
|
910
977
|
|
|
911
978
|
// src/solve/sides.ts
|
|
912
|
-
import { EPS as EPS8, rect as
|
|
979
|
+
import { EPS as EPS8, rect as rect6 } from "@n-uf/placement";
|
|
913
980
|
|
|
914
981
|
// src/solve/columns.ts
|
|
915
982
|
import { EPS as EPS7 } from "@n-uf/placement";
|
|
916
|
-
import { formCrossMin as formCrossMin3, formSetsCross as formSetsCross3 } from "@n-uf/placement/stack";
|
|
983
|
+
import { formCrossMin as formCrossMin3, formMenu as formMenu2, formSetsCross as formSetsCross3 } from "@n-uf/placement/stack";
|
|
917
984
|
var isChrome = (state, c) => !c.dyn && isSideBar(state, c.edge);
|
|
918
|
-
function columnsOf(d, sideEdges,
|
|
985
|
+
function columnsOf(d, sideEdges, area9, tall) {
|
|
919
986
|
const { state } = d;
|
|
920
987
|
return sideEdges.map((edge) => {
|
|
921
988
|
const side = edge.side;
|
|
922
|
-
const solved = solveEdge(state, edge, d.owned.get(edge), tall(edge), Math.max(0,
|
|
923
|
-
const width = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross,
|
|
989
|
+
const solved = solveEdge(state, edge, d.owned.get(edge), tall(edge), Math.max(0, area9.width), d.prevEdge(edge));
|
|
990
|
+
const width = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross, area9.width);
|
|
924
991
|
const visible = d.owned.get(edge).filter((id) => !state.items[id].closed);
|
|
925
992
|
const dyn = (edge.column === true || edge.giveWay === true) && state.rails?.[side] !== void 0 && visible.length > 0;
|
|
926
993
|
const forms = (id) => formsOf(state.items[id], "column");
|
|
927
|
-
const setters = solved.free.items.filter((p) => p.
|
|
994
|
+
const setters = solved.free.items.filter((p) => !formMenu2(forms(p.id)[p.form]) && formSetsCross3(forms(p.id)[p.form]));
|
|
928
995
|
const min = setters.length > 0 ? Math.min(width, Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin3(forms(p.id)[p.form])))) : width;
|
|
929
996
|
return {
|
|
930
997
|
edge,
|
|
@@ -940,7 +1007,7 @@ function columnsOf(d, sideEdges, area7, tall) {
|
|
|
940
1007
|
};
|
|
941
1008
|
});
|
|
942
1009
|
}
|
|
943
|
-
function giveWay(d, cols,
|
|
1010
|
+
function giveWay(d, cols, area9, gutter) {
|
|
944
1011
|
const { state, previous, fresh, opened } = d;
|
|
945
1012
|
const ride = state.handFold === "ride";
|
|
946
1013
|
const cmin = state.contentMin ? px(state.contentMin.width) : void 0;
|
|
@@ -962,7 +1029,7 @@ function giveWay(d, cols, area7, gutter) {
|
|
|
962
1029
|
let used = 0;
|
|
963
1030
|
for (const [c, w] of widths) used += w > 0 ? w + (c.edge.outsideInset === true ? 0 : gutter) : 0;
|
|
964
1031
|
for (const s of railSides) used += railW(s) + gutter;
|
|
965
|
-
let excess = cmin === void 0 ? -Infinity : floor === void 0 ? used + cmin -
|
|
1032
|
+
let excess = cmin === void 0 ? -Infinity : floor === void 0 ? used + cmin - area9.width : Math.max(used - chrome + cmin, used + floor) - area9.width;
|
|
966
1033
|
for (const c of shrinkOrder) {
|
|
967
1034
|
if (excess <= EPS7) break;
|
|
968
1035
|
const w = widths.get(c);
|
|
@@ -1002,7 +1069,7 @@ function giveWay(d, cols, area7, gutter) {
|
|
|
1002
1069
|
}
|
|
1003
1070
|
return evaluate(auto);
|
|
1004
1071
|
}
|
|
1005
|
-
function columnRoom(d, cols,
|
|
1072
|
+
function columnRoom(d, cols, area9, f) {
|
|
1006
1073
|
const { state } = d;
|
|
1007
1074
|
const cmin = state.contentMin ? px(state.contentMin.width) : void 0;
|
|
1008
1075
|
const openMin = (ids, least) => Math.max(
|
|
@@ -1023,7 +1090,7 @@ function columnRoom(d, cols, area7, f) {
|
|
|
1023
1090
|
if (cmin === void 0 || colMins.length === 0) return;
|
|
1024
1091
|
const allBars = cols.filter((c) => c.width > 0 && isChrome(state, c)).reduce((s, c) => s + c.width + (c.edge.outsideInset === true ? 0 : f.gutter), 0);
|
|
1025
1092
|
const bars = d.chromeAllowance === void 0 ? allBars : allBars - Math.min(allBars, d.chromeAllowance);
|
|
1026
|
-
const width =
|
|
1093
|
+
const width = area9.width - bars - (state.insetWhen === "docked" && !f.docked ? px(state.inset?.left) + px(state.inset?.right) : 0);
|
|
1027
1094
|
const need = cmin + Math.min(...colMins) + f.gutter;
|
|
1028
1095
|
d.columnRoom = width >= need - EPS7;
|
|
1029
1096
|
if (!d.columnRoom) d.notes.push({ code: "no-column-room", width, need });
|
|
@@ -1056,7 +1123,7 @@ function giveWayNotes(d, g, cols) {
|
|
|
1056
1123
|
}
|
|
1057
1124
|
|
|
1058
1125
|
// src/solve/rails.ts
|
|
1059
|
-
import { rect as
|
|
1126
|
+
import { rect as rect5 } from "@n-uf/placement";
|
|
1060
1127
|
import { fitStack as fitStack2 } from "@n-uf/placement/stack";
|
|
1061
1128
|
function riderBars(d, c) {
|
|
1062
1129
|
const { state } = d;
|
|
@@ -1075,12 +1142,12 @@ function layRiders(d, host, riders, top) {
|
|
|
1075
1142
|
const bars = riderBars(d, c);
|
|
1076
1143
|
const y0 = y;
|
|
1077
1144
|
for (const b of bars) {
|
|
1078
|
-
const at =
|
|
1145
|
+
const at = rect5(hr.x, y, hr.width, b.h);
|
|
1079
1146
|
const it = state.items[b.id];
|
|
1080
1147
|
items[b.id] = { rect: at, ...controlsOf(b.f), kind: it.kind, axis: "column", form: b.form, formKind: b.f?.kind ?? "header", edge: c.edge.id, zone: zoneOf(it), rides: host.edge.id, folded: "hand", foldedBy: "hand" };
|
|
1081
1148
|
y += b.h;
|
|
1082
1149
|
}
|
|
1083
|
-
edges[c.edge.id] = { side: c.edge.side, ring: finite(c.edge.ring, 0), rect:
|
|
1150
|
+
edges[c.edge.id] = { side: c.edge.side, ring: finite(c.edge.ring, 0), rect: rect5(hr.x, y0, hr.width, y - y0), cross: 0, menu: null, items: bars.map((b) => b.id), tabs: [], stack: c.solved.stack, free: c.solved.free, rides: host.edge.id, folded: "hand" };
|
|
1084
1151
|
}
|
|
1085
1152
|
}
|
|
1086
1153
|
function layRail(d, side, railRect, railed, g) {
|
|
@@ -1120,7 +1187,7 @@ function layRail(d, side, railRect, railed, g) {
|
|
|
1120
1187
|
const ri = tileOf(id);
|
|
1121
1188
|
const p = placed.get(id);
|
|
1122
1189
|
const form = p ? p.form : ri >= 0 ? ri : forms.length === 0 ? 0 : startOf(it, forms);
|
|
1123
|
-
const at = p ?
|
|
1190
|
+
const at = p ? rect5(railRect.x, railRect.y + p.rect.y, railRect.width, p.rect.height) : rect5(railRect.x, y, railRect.width, ri >= 0 ? px(forms[ri].main.natural) : railRect.width);
|
|
1124
1191
|
const title = forms[form]?.title === true;
|
|
1125
1192
|
items[id] = { rect: at, ...controlsOf(forms[form]), kind: it.kind, axis: "column", form, formKind: "rail", edge: c.edge.id, zone: zoneOf(it), rail: side, ...title ? { railTitle: side } : {}, folded: g.auto.has(c) ? "auto" : "hand", foldedBy: startOf(it, forms) > 0 ? "hand" : "auto" };
|
|
1126
1193
|
segments.push({ id, edge: c.edge.id, rect: at });
|
|
@@ -1130,26 +1197,26 @@ function layRail(d, side, railRect, railed, g) {
|
|
|
1130
1197
|
}
|
|
1131
1198
|
|
|
1132
1199
|
// src/solve/sides.ts
|
|
1133
|
-
function laySides(d, sideEdges,
|
|
1134
|
-
const H =
|
|
1135
|
-
const reach = insetReach(
|
|
1200
|
+
function laySides(d, sideEdges, area9, f) {
|
|
1201
|
+
const H = area9.height;
|
|
1202
|
+
const reach = insetReach(area9, f);
|
|
1136
1203
|
const tall = (edge) => H + (edge.outsideInset === true ? reach.up + reach.down : 0);
|
|
1137
|
-
const cols = columnsOf(d, sideEdges,
|
|
1138
|
-
const g = giveWay(d, cols,
|
|
1139
|
-
columnRoom(d, cols,
|
|
1204
|
+
const cols = columnsOf(d, sideEdges, area9, tall);
|
|
1205
|
+
const g = giveWay(d, cols, area9, f.gutter);
|
|
1206
|
+
columnRoom(d, cols, area9, f);
|
|
1140
1207
|
giveWayNotes(d, g, cols);
|
|
1141
|
-
const walk = { x0:
|
|
1142
|
-
for (const side of ["left", "right"]) laySide(d, side, cols, g,
|
|
1143
|
-
return
|
|
1208
|
+
const walk = { x0: area9.x, x1: area9.x + area9.width };
|
|
1209
|
+
for (const side of ["left", "right"]) laySide(d, side, cols, g, area9, f, walk, reach.up, tall);
|
|
1210
|
+
return rect6(walk.x0, area9.y, Math.max(0, walk.x1 - walk.x0), H);
|
|
1144
1211
|
}
|
|
1145
1212
|
function forced(d, c, length, w) {
|
|
1146
1213
|
const edge = { ...c.edge, cross: { ...c.edge.cross, min: w, max: w } };
|
|
1147
1214
|
const { size: _s, ...plain } = edge;
|
|
1148
1215
|
return solveEdge(d.state, plain, d.owned.get(c.edge), length, w, d.prevEdge(c.edge));
|
|
1149
1216
|
}
|
|
1150
|
-
function laySide(d, side, cols, g,
|
|
1217
|
+
function laySide(d, side, cols, g, area9, f, walk, upInset, tall) {
|
|
1151
1218
|
const { state, edges } = d;
|
|
1152
|
-
const H =
|
|
1219
|
+
const H = area9.height;
|
|
1153
1220
|
const outsideSideBar = (c) => c.width > 0 && isOutsideSideBar(state, c.edge) && !g.railed(c) && !g.riding(c);
|
|
1154
1221
|
const all = cols.filter((c) => c.side === side);
|
|
1155
1222
|
const mine = [...all.filter(outsideSideBar), ...all.filter((c) => !outsideSideBar(c))];
|
|
@@ -1164,7 +1231,7 @@ function laySide(d, side, cols, g, area7, f, walk, upInset, tall) {
|
|
|
1164
1231
|
let railPlace = null;
|
|
1165
1232
|
const placeRail = () => {
|
|
1166
1233
|
const lead = barLaid ? gap : 0;
|
|
1167
|
-
return side === "left" ?
|
|
1234
|
+
return side === "left" ? rect6(walk.x0 - lead, area9.y, railW, H) : rect6(walk.x1 + lead - railW, area9.y, railW, H);
|
|
1168
1235
|
};
|
|
1169
1236
|
for (const c of mine) {
|
|
1170
1237
|
if (!railPlace && !outsideSideBar(c)) {
|
|
@@ -1181,7 +1248,7 @@ function laySide(d, side, cols, g, area7, f, walk, upInset, tall) {
|
|
|
1181
1248
|
if (outsideSideBar(c)) barLaid = true;
|
|
1182
1249
|
const base = { side: c.edge.side, ring: finite(c.edge.ring, 0), cross: 0, menu: null, items: zoneSorted(state, c.visible), tabs: [], stack: c.solved.stack, free: c.solved.free };
|
|
1183
1250
|
if (g.railed(c)) {
|
|
1184
|
-
edges[c.edge.id] = { ...base, rect:
|
|
1251
|
+
edges[c.edge.id] = { ...base, rect: rect6(railRect.x, area9.y, 0, H), folded: g.auto.has(c) ? "auto" : "hand" };
|
|
1185
1252
|
continue;
|
|
1186
1253
|
}
|
|
1187
1254
|
if (g.riding(c)) continue;
|
|
@@ -1190,29 +1257,29 @@ function laySide(d, side, cols, g, area7, f, walk, upInset, tall) {
|
|
|
1190
1257
|
let solved = top > 0 || Math.abs(w - c.width) > EPS8 ? forced(d, c, H - top, w) : c.solved;
|
|
1191
1258
|
let r;
|
|
1192
1259
|
if (c.edge.outsideInset === true) {
|
|
1193
|
-
const y0 =
|
|
1260
|
+
const y0 = area9.y - upInset;
|
|
1194
1261
|
const h = tall(c.edge);
|
|
1195
1262
|
if (side === "left") {
|
|
1196
|
-
r =
|
|
1263
|
+
r = rect6(walk.x0 - gap, y0, w, h);
|
|
1197
1264
|
walk.x0 += w;
|
|
1198
1265
|
} else {
|
|
1199
|
-
r =
|
|
1266
|
+
r = rect6(walk.x1 + gap - w, y0, w, h);
|
|
1200
1267
|
walk.x1 -= w;
|
|
1201
1268
|
}
|
|
1202
1269
|
if (Math.abs(h - H) > EPS8 || Math.abs(w - c.width) > EPS8) solved = forced(d, c, h, w);
|
|
1203
1270
|
} else if (side === "left") {
|
|
1204
|
-
r =
|
|
1271
|
+
r = rect6(walk.x0, area9.y + top, w, H - top);
|
|
1205
1272
|
walk.x0 += w > 0 ? w + f.gutter : 0;
|
|
1206
1273
|
if (w > 0) gap = f.gutter;
|
|
1207
1274
|
} else {
|
|
1208
1275
|
walk.x1 -= w;
|
|
1209
|
-
r =
|
|
1276
|
+
r = rect6(walk.x1, area9.y + top, w, H - top);
|
|
1210
1277
|
walk.x1 -= w > 0 ? f.gutter : 0;
|
|
1211
1278
|
if (w > 0) gap = f.gutter;
|
|
1212
1279
|
}
|
|
1213
1280
|
emit(d, c.edge, r, solved, w < c.width - EPS8 ? { shrunk: true } : {});
|
|
1214
1281
|
}
|
|
1215
|
-
if (host && riders.length > 0) layRiders(d, host, riders,
|
|
1282
|
+
if (host && riders.length > 0) layRiders(d, host, riders, area9.y);
|
|
1216
1283
|
if (railRect) layRail(d, side, railRect, railed, g);
|
|
1217
1284
|
if (state.rails?.[side]) d.railPlaces[side] = railPlace ?? placeRail();
|
|
1218
1285
|
}
|
|
@@ -1234,29 +1301,29 @@ function solveState(given, options) {
|
|
|
1234
1301
|
const l = way ? lay(way.caps, way.notes) : first;
|
|
1235
1302
|
return ignored.length === 0 ? l : { ...l, notes: [...l.notes, ...ignored.map((edge) => ({ code: "show-in-ignored", edge }))] };
|
|
1236
1303
|
}
|
|
1237
|
-
var withHeightOf = (
|
|
1304
|
+
var withHeightOf = (area9, over2) => rect7(over2.x, area9.y, over2.width, area9.height);
|
|
1238
1305
|
function layOut(given, options, caps, gave) {
|
|
1239
1306
|
const d = createDraft(given, options, caps);
|
|
1240
1307
|
const { state, order } = d;
|
|
1241
|
-
const stage =
|
|
1308
|
+
const stage = rect7(finite(state.stage.x, 0), finite(state.stage.y, 0), px(state.stage.width), px(state.stage.height));
|
|
1242
1309
|
const { inset, docked } = insetOf(d);
|
|
1243
1310
|
const reserved = order.filter((e) => e.mode !== "overlay");
|
|
1244
1311
|
const outsideBar = (e) => !isSide(e) && e.span !== "between" && e.outsideInset === true;
|
|
1245
1312
|
let outer = stage;
|
|
1246
1313
|
for (const e of reserved) if (outsideBar(e)) outer = cutEdge(d, e, outer, true);
|
|
1247
|
-
let
|
|
1248
|
-
for (const e of reserved) if (!isSide(e) && e.span !== "between" && !outsideBar(e))
|
|
1249
|
-
const wide =
|
|
1250
|
-
|
|
1251
|
-
for (const e of reserved) if (!isSide(e) && e.span === "between")
|
|
1252
|
-
const content =
|
|
1314
|
+
let area9 = insideInset(outer, inset);
|
|
1315
|
+
for (const e of reserved) if (!isSide(e) && e.span !== "between" && !outsideBar(e)) area9 = cutEdge(d, e, area9, true);
|
|
1316
|
+
const wide = area9;
|
|
1317
|
+
area9 = laySides(d, reserved.filter(isSide), area9, { inset, gutter: px(state.gutter), docked, outer });
|
|
1318
|
+
for (const e of reserved) if (!isSide(e) && e.span === "between") area9 = cutEdge(d, e, area9, true);
|
|
1319
|
+
const content = area9;
|
|
1253
1320
|
let over2 = content;
|
|
1254
1321
|
for (const e of order) {
|
|
1255
1322
|
if (e.mode !== "overlay") continue;
|
|
1256
1323
|
if (isSide(e) || e.span !== "full") over2 = cutEdge(d, e, over2, true);
|
|
1257
1324
|
else {
|
|
1258
1325
|
const across2 = e.outsideInset === true ? outer : wide;
|
|
1259
|
-
over2 = withHeightOf(cutEdge(d, e,
|
|
1326
|
+
over2 = withHeightOf(cutEdge(d, e, rect7(across2.x, over2.y, across2.width, over2.height), true), over2);
|
|
1260
1327
|
}
|
|
1261
1328
|
}
|
|
1262
1329
|
for (const n of gave) {
|
|
@@ -1264,13 +1331,14 @@ function layOut(given, options, caps, gave) {
|
|
|
1264
1331
|
if (n.code === "bar-shrunk" && d.edges[n.edge]) d.edges[n.edge] = { ...d.edges[n.edge], shrunk: true };
|
|
1265
1332
|
}
|
|
1266
1333
|
contentNotes(d, content);
|
|
1267
|
-
const
|
|
1334
|
+
const keepClear = resolveKeepClear(state, content);
|
|
1335
|
+
const floats = layFloats(d, stage, content, inset, keepClearFor(state, { keepClear }, "floats"));
|
|
1268
1336
|
const { items, edges, rails, railPlaces, columnRoom: columnRoom2, notes } = d;
|
|
1269
|
-
return { items, edges, content, floats, rails, railPlaces, ...columnRoom2 !== void 0 ? { columnRoom: columnRoom2 } : {}, notes };
|
|
1337
|
+
return { items, edges, content, floats, rails, railPlaces, ...columnRoom2 !== void 0 ? { columnRoom: columnRoom2 } : {}, ...keepClear ? { keepClear } : {}, notes };
|
|
1270
1338
|
}
|
|
1271
1339
|
|
|
1272
1340
|
// src/dividers.ts
|
|
1273
|
-
import { rect as
|
|
1341
|
+
import { rect as rect8 } from "@n-uf/placement";
|
|
1274
1342
|
import { dividers as stackDividers, resetBetween as stackReset, resizeBetween as stackResize } from "@n-uf/placement/stack";
|
|
1275
1343
|
var laid = (state, layout) => layout && stateOf(layout) === state && Object.values(layout.edges).every((e) => inputOf(e.stack) !== void 0) ? layout : solve(state);
|
|
1276
1344
|
function dividers(state, layout) {
|
|
@@ -1279,7 +1347,7 @@ function dividers(state, layout) {
|
|
|
1279
1347
|
for (const [edge, e] of Object.entries(lay.edges)) {
|
|
1280
1348
|
const input = inputOf(e.stack);
|
|
1281
1349
|
if (!input) continue;
|
|
1282
|
-
for (const d of stackDividers(input, e.stack)) out.push({ edge, before: d.before, after: d.after, rect:
|
|
1350
|
+
for (const d of stackDividers(input, e.stack)) out.push({ edge, before: d.before, after: d.after, rect: rect8(e.rect.x + d.rect.x, e.rect.y + d.rect.y, d.rect.width, d.rect.height), range: d.range });
|
|
1283
1351
|
}
|
|
1284
1352
|
return out;
|
|
1285
1353
|
}
|
|
@@ -1319,7 +1387,7 @@ function resetLengths(state, edgeId) {
|
|
|
1319
1387
|
}
|
|
1320
1388
|
|
|
1321
1389
|
// src/changes.ts
|
|
1322
|
-
import { clampInto as
|
|
1390
|
+
import { clampInto as clampInto3 } from "@n-uf/placement";
|
|
1323
1391
|
|
|
1324
1392
|
// src/float-resize.ts
|
|
1325
1393
|
var LIMITS = ["min", "max", "region", "docked"];
|
|
@@ -1327,14 +1395,16 @@ var EPS9 = 0.5;
|
|
|
1327
1395
|
var TOUCH = 1e-3;
|
|
1328
1396
|
var fin = (v, d) => Number.isFinite(v) ? v : d;
|
|
1329
1397
|
function floatObstacles(state, l, id) {
|
|
1330
|
-
const
|
|
1331
|
-
|
|
1398
|
+
const some = (r) => r.width > 0 && r.height > 0;
|
|
1399
|
+
const rects = [];
|
|
1400
|
+
for (const [k, p] of Object.entries(l.items)) if (k !== id && !p.floating && some(p.rect)) rects.push(p.rect);
|
|
1401
|
+
const docked = rects.length;
|
|
1332
1402
|
for (const e of Object.values(l.edges)) {
|
|
1333
|
-
if (axisOf(e.side) === "row" && e.cross > 0)
|
|
1334
|
-
if (e.menu)
|
|
1403
|
+
if (axisOf(e.side) === "row" && e.cross > 0) rects.push(e.rect);
|
|
1404
|
+
if (e.menu) rects.push(e.menu.rect);
|
|
1335
1405
|
}
|
|
1336
|
-
for (const c of keepClearFor(state, "floats"))
|
|
1337
|
-
return
|
|
1406
|
+
for (const c of keepClearFor(state, l, "floats")) rects.push(c);
|
|
1407
|
+
return { rects: rects.filter(some), docked };
|
|
1338
1408
|
}
|
|
1339
1409
|
function obstacleStop(drawn, obstacles, axis, drag, span) {
|
|
1340
1410
|
const none = drag === "start" ? -Infinity : Infinity;
|
|
@@ -1400,7 +1470,7 @@ function fitAxis(start, length, b, drag, hit) {
|
|
|
1400
1470
|
}
|
|
1401
1471
|
return [a, to - a];
|
|
1402
1472
|
}
|
|
1403
|
-
function fitResize(state, id,
|
|
1473
|
+
function fitResize(state, id, rect20, moving) {
|
|
1404
1474
|
const f = state.floats.find((x2) => x2.id === id);
|
|
1405
1475
|
const item = Object.hasOwn(state.items, id) ? state.items[id] : void 0;
|
|
1406
1476
|
if (!f || !item || item.fixed) return null;
|
|
@@ -1415,12 +1485,13 @@ function fitResize(state, id, rect19, moving) {
|
|
|
1415
1485
|
const region = floatRegion(state);
|
|
1416
1486
|
const dragX = moving.left ? "start" : moving.right ? "end" : null;
|
|
1417
1487
|
const dragY = moving.top ? "start" : moving.bottom ? "end" : null;
|
|
1418
|
-
const obstacles = floatObstacles(state, l, id);
|
|
1488
|
+
const { rects: obstacles, docked } = floatObstacles(state, l, id);
|
|
1419
1489
|
const hit = /* @__PURE__ */ new Set();
|
|
1420
|
-
const
|
|
1421
|
-
const [
|
|
1490
|
+
const stops2 = f.stays ? obstacles.slice(docked) : obstacles;
|
|
1491
|
+
const [x, width] = fitAxis(rect20.x, rect20.width, { min: min.width, max: max.width, lo: region.x, hi: region.x + region.width, stop: obstacleStop(drawn, stops2, "x", dragX ?? "end", [drawn.y, drawn.y + drawn.height]) }, dragX, hit);
|
|
1492
|
+
const [y, height] = fitAxis(rect20.y, rect20.height, { min: min.height, max: max.height, lo: region.y, hi: region.y + region.height, stop: obstacleStop(drawn, stops2, "y", dragY ?? "end", [x, x + width]) }, dragY, hit);
|
|
1422
1493
|
const { anchor: _a, ...plain } = f;
|
|
1423
|
-
const placed = placeFloat(item, { ...plain, rect: { x, y, width, height } }, region, obstacles, l.content, state.stage).fit.rect;
|
|
1494
|
+
const placed = placeFloat(item, { ...plain, rect: { x, y, width, height } }, region, obstacles, l.content, state.stage, [], docked).fit.rect;
|
|
1424
1495
|
if (Math.abs(placed.x - x) > EPS9 || Math.abs(placed.y - y) > EPS9) hit.add("docked");
|
|
1425
1496
|
if (Math.abs(placed.width - width) > EPS9 || Math.abs(placed.height - height) > EPS9) hit.add("min");
|
|
1426
1497
|
return { rect: placed, limits: LIMITS.filter((k) => hit.has(k)) };
|
|
@@ -1553,8 +1624,9 @@ function moveAmong(state, id, place, others) {
|
|
|
1553
1624
|
if (place.kind === "float") {
|
|
1554
1625
|
const out = floatAt(state, id, place.rect);
|
|
1555
1626
|
const anchor = place.anchor;
|
|
1556
|
-
|
|
1557
|
-
|
|
1627
|
+
const stays = place.stays === true && !anchor && !!place.rect;
|
|
1628
|
+
if (!anchor && !stays || out === state) return out;
|
|
1629
|
+
return { ...out, floats: out.floats.map((f) => f.id === id ? anchor ? { ...f, anchor } : { ...f, stays: true } : f) };
|
|
1558
1630
|
}
|
|
1559
1631
|
const railColumn = place.kind === "rail" ? railColumnOf(state, place.side, item.kind) : void 0;
|
|
1560
1632
|
if (railColumn) {
|
|
@@ -1593,6 +1665,18 @@ function nextSince(state) {
|
|
|
1593
1665
|
const most = state.floats.reduce((m, f) => Math.max(m, isSince(f.since) ? f.since : 0), 0);
|
|
1594
1666
|
return Math.min(most + 1, Number.MAX_SAFE_INTEGER);
|
|
1595
1667
|
}
|
|
1668
|
+
var anchoredDrawn = /* @__PURE__ */ new WeakMap();
|
|
1669
|
+
function overAnchored(state, id, r) {
|
|
1670
|
+
if (!state.floats.some((f) => f.anchor && f.id !== id)) return false;
|
|
1671
|
+
let drawn = anchoredDrawn.get(state);
|
|
1672
|
+
if (!drawn) {
|
|
1673
|
+
const l = solve(state);
|
|
1674
|
+
drawn = state.floats.filter((f) => f.anchor && l.items[f.id]?.floating).map((f) => ({ id: f.id, rect: l.items[f.id].rect }));
|
|
1675
|
+
anchoredDrawn.set(state, drawn);
|
|
1676
|
+
}
|
|
1677
|
+
const touch = 1e-3;
|
|
1678
|
+
return drawn.some((d) => d.id !== id && Math.min(r.x + r.width, d.rect.x + d.rect.width) - Math.max(r.x, d.rect.x) > touch && Math.min(r.y + r.height, d.rect.y + d.rect.height) - Math.max(r.y, d.rect.y) > touch);
|
|
1679
|
+
}
|
|
1596
1680
|
function floatAt(state, id, at, orient) {
|
|
1597
1681
|
const item = itemOf(state, id);
|
|
1598
1682
|
if (!item || item.fixed || !state.floatKinds.includes(item.kind)) return state;
|
|
@@ -1600,7 +1684,7 @@ function floatAt(state, id, at, orient) {
|
|
|
1600
1684
|
const o = orient ?? was?.orient;
|
|
1601
1685
|
const fo = o ?? floatOrientOf(item);
|
|
1602
1686
|
const size = floatSizeOf(item, fo);
|
|
1603
|
-
const since = was ? was.since : nextSince(state);
|
|
1687
|
+
const since = was && !(at && overAnchored(state, id, at)) ? was.since : nextSince(state);
|
|
1604
1688
|
const seq = since !== void 0 ? { since } : {};
|
|
1605
1689
|
const float = at ? { id, rect: { x: at.x, y: at.y, width: at.width, height: at.height }, ...o ? { orient: o } : {}, ...seq } : { id, rect: { x: 0, y: 0, width: size.width, height: size.height }, anchor: "content-top-right", ...o ? { orient: o } : {}, ...seq };
|
|
1606
1690
|
const { space: _space, ...unspaced } = item;
|
|
@@ -1673,13 +1757,14 @@ function orientFloat(state, id, to) {
|
|
|
1673
1757
|
const turned = { ...f, rect: { x: f.rect.x, y: f.rect.y, width: size.width, height: size.height }, orient: to };
|
|
1674
1758
|
return withItem({ ...state, floats: state.floats.map((g, k) => k === i ? turned : g) }, kept);
|
|
1675
1759
|
}
|
|
1676
|
-
function resizeFloat(state, floatId,
|
|
1677
|
-
const fit = fitResize(state, floatId,
|
|
1760
|
+
function resizeFloat(state, floatId, rect20, moving = { right: true, bottom: true }) {
|
|
1761
|
+
const fit = fitResize(state, floatId, rect20, moving);
|
|
1678
1762
|
const i = state.floats.findIndex((f) => f.id === floatId);
|
|
1679
1763
|
const item = itemOf(state, floatId);
|
|
1680
1764
|
if (!fit || i < 0 || !item) return state;
|
|
1681
1765
|
const { anchor: _a, ...plain } = state.floats[i];
|
|
1682
|
-
const
|
|
1766
|
+
const renew = overAnchored(state, floatId, fit.rect);
|
|
1767
|
+
const float = renew ? { ...plain, rect: fit.rect, since: nextSince(state) } : { ...plain, rect: fit.rect };
|
|
1683
1768
|
const fo = float.orient ?? floatOrientOf(item);
|
|
1684
1769
|
return withItem({ ...state, floats: state.floats.map((g, k) => k === i ? float : g) }, withFloatSizes(item, { orient: fo, size: { width: fit.rect.width, height: fit.rect.height } }));
|
|
1685
1770
|
}
|
|
@@ -1721,7 +1806,7 @@ function homeFor(state, id, start) {
|
|
|
1721
1806
|
return null;
|
|
1722
1807
|
}
|
|
1723
1808
|
const f = start.floats.find((x) => x.id === id);
|
|
1724
|
-
if (f) return { kind: "float", rect: f.rect, ...f.anchor ? { anchor: f.anchor } : {} };
|
|
1809
|
+
if (f) return { kind: "float", rect: f.rect, ...f.anchor ? { anchor: f.anchor } : f.stays ? { stays: true } : {} };
|
|
1725
1810
|
return null;
|
|
1726
1811
|
}
|
|
1727
1812
|
function dockHome(state, id, start) {
|
|
@@ -1744,7 +1829,7 @@ function dockHome(state, id, start) {
|
|
|
1744
1829
|
return out === item ? moved : withItem(moved, out);
|
|
1745
1830
|
}
|
|
1746
1831
|
function clampFloat(r, stage, drawn = r) {
|
|
1747
|
-
const at =
|
|
1832
|
+
const at = clampInto3({ x: r.x, y: r.y, width: drawn.width, height: drawn.height }, stage);
|
|
1748
1833
|
return { x: at.x, y: at.y, width: r.width, height: r.height };
|
|
1749
1834
|
}
|
|
1750
1835
|
function drawnFloatSize(item, f) {
|
|
@@ -1753,7 +1838,7 @@ function drawnFloatSize(item, f) {
|
|
|
1753
1838
|
}
|
|
1754
1839
|
|
|
1755
1840
|
// src/store.ts
|
|
1756
|
-
import { EPS as EPS10, rect as
|
|
1841
|
+
import { EPS as EPS10, rect as rect9 } from "@n-uf/placement";
|
|
1757
1842
|
var isNum = (x) => typeof x === "number" && Number.isFinite(x);
|
|
1758
1843
|
var isSize = (x) => isNum(x) && x > 0;
|
|
1759
1844
|
var isObject = (x) => typeof x === "object" && x !== null && !Array.isArray(x);
|
|
@@ -1823,7 +1908,7 @@ function storeDockState(state) {
|
|
|
1823
1908
|
edges: state.edges.map((e) => ({ id: e.id, side: e.side, ring: e.ring, items: [...e.items], ...isNum(e.size) ? { size: e.size } : {}, ...e.column === true ? { column: true } : {} })),
|
|
1824
1909
|
floats: state.floats.filter((f) => isNum(f.rect.x) && isNum(f.rect.y) && isSize(f.rect.width) && isSize(f.rect.height)).map((f) => {
|
|
1825
1910
|
const anchor = anchorOf(f.anchor);
|
|
1826
|
-
return { id: f.id, x: f.rect.x, y: f.rect.y, width: f.rect.width, height: f.rect.height, ...f.orient ? { orient: f.orient } : {}, ...anchor ? { anchor } : {}, ...isSince(f.since) ? { since: f.since } : {} };
|
|
1911
|
+
return { id: f.id, x: f.rect.x, y: f.rect.y, width: f.rect.width, height: f.rect.height, ...f.orient ? { orient: f.orient } : {}, ...anchor ? { anchor } : {}, ...isSince(f.since) ? { since: f.since } : {}, ...f.stays === true && !anchor ? { stays: true } : {} };
|
|
1827
1912
|
}),
|
|
1828
1913
|
items,
|
|
1829
1914
|
...modes ? { railModes: modes } : {}
|
|
@@ -1987,16 +2072,18 @@ function read(data, base) {
|
|
|
1987
2072
|
continue;
|
|
1988
2073
|
}
|
|
1989
2074
|
for (const k of Object.keys(f)) if (k === "pinned") drop(`pinned:${id}`);
|
|
1990
|
-
else if (!["id", "x", "y", "width", "height", "orient", "anchor", "since"].includes(k)) drop(`float:${id}:${k}`);
|
|
2075
|
+
else if (!["id", "x", "y", "width", "height", "orient", "anchor", "since", "stays"].includes(k)) drop(`float:${id}:${k}`);
|
|
1991
2076
|
const o = f.orient === "row" || f.orient === "column" ? f.orient : void 0;
|
|
1992
2077
|
if (f.orient !== void 0 && !o) drop(`float:${id}:orient`);
|
|
1993
2078
|
const a = anchorOf(f.anchor, (what) => drop(`float:${id}:anchor${what}`));
|
|
1994
2079
|
const since = isSince(f.since) ? f.since : void 0;
|
|
1995
2080
|
if (f.since !== void 0 && since === void 0) drop(`float:${id}:since`);
|
|
2081
|
+
const stays = f.stays === true && !a;
|
|
2082
|
+
if (f.stays !== void 0 && !stays) drop(`float:${id}:stays`);
|
|
1996
2083
|
placed.add(id);
|
|
1997
|
-
const r =
|
|
2084
|
+
const r = rect9(f.x, f.y, f.width, f.height);
|
|
1998
2085
|
const drawn = drawnFloatSize(items[id], { rect: r, ...o ? { orient: o } : {} });
|
|
1999
|
-
floats.push({ id, rect: clampFloat(r, base.stage, drawn), ...o ? { orient: o } : {}, ...a ? { anchor: a } : {}, ...since !== void 0 ? { since } : {} });
|
|
2086
|
+
floats.push({ id, rect: clampFloat(r, base.stage, drawn), ...o ? { orient: o } : {}, ...a ? { anchor: a } : {}, ...since !== void 0 ? { since } : {}, ...stays ? { stays: true } : {} });
|
|
2000
2087
|
}
|
|
2001
2088
|
const edges = [...base.edges, ...made].map((edge) => {
|
|
2002
2089
|
const stored = order.get(edge.id) ?? [];
|
|
@@ -2027,10 +2114,10 @@ function read(data, base) {
|
|
|
2027
2114
|
}
|
|
2028
2115
|
|
|
2029
2116
|
// src/targets.ts
|
|
2030
|
-
import { EPS as EPS20, PLANE, area as area6, overlaps as
|
|
2117
|
+
import { EPS as EPS20, PLANE, area as area6, clamp as clamp2, contains, overlaps as overlaps7, rect as rect18 } from "@n-uf/placement";
|
|
2031
2118
|
|
|
2032
2119
|
// src/targets/anchor.ts
|
|
2033
|
-
import { EPS as EPS11, area, rect as
|
|
2120
|
+
import { EPS as EPS11, area, rect as rect10, subtract } from "@n-uf/placement";
|
|
2034
2121
|
var OTHER = { left: "right", right: "left", top: "bottom", bottom: "top" };
|
|
2035
2122
|
function anchorTargets(state, dragged, options) {
|
|
2036
2123
|
const none = { targets: [], refusals: [], lost: [] };
|
|
@@ -2047,7 +2134,7 @@ function anchorTargets(state, dragged, options) {
|
|
|
2047
2134
|
const placed = layout.edges[edge.id]?.rect;
|
|
2048
2135
|
const slot = layout.items[dragged]?.rect;
|
|
2049
2136
|
if (placed && slot && area(placed) > EPS11) {
|
|
2050
|
-
const pieces = keepClearFor(state, "targets").reduce((ps, c) => ps.flatMap((p) => subtract(p,
|
|
2137
|
+
const pieces = keepClearFor(state, now, "targets").reduce((ps, c) => ps.flatMap((p) => subtract(p, rect10(c.x, c.y, c.width, c.height))), [placed]).filter((p) => p.width >= 1 && p.height >= 1);
|
|
2051
2138
|
if (pieces.length > 0) {
|
|
2052
2139
|
const hit = pieces.reduce((a, p) => area(p) > area(a) ? p : a);
|
|
2053
2140
|
const result = { state: moved, layout };
|
|
@@ -2059,8 +2146,8 @@ function anchorTargets(state, dragged, options) {
|
|
|
2059
2146
|
}
|
|
2060
2147
|
|
|
2061
2148
|
// src/targets/edges.ts
|
|
2062
|
-
import { EPS as EPS12, area as area2, rect as
|
|
2063
|
-
import { formCrossMin as formCrossMin4,
|
|
2149
|
+
import { EPS as EPS12, area as area2, rect as rect11 } from "@n-uf/placement";
|
|
2150
|
+
import { formCrossMin as formCrossMin4, formMenu as formMenu3, formSetsCross as formSetsCross4, itemSteps as itemSteps3 } from "@n-uf/placement/stack";
|
|
2064
2151
|
|
|
2065
2152
|
// src/targets/kinds.ts
|
|
2066
2153
|
var COLUMN_REACH = 22;
|
|
@@ -2094,7 +2181,7 @@ function reservedRect(state, l, id) {
|
|
|
2094
2181
|
const len2 = column ? it.rect.height : it.rect.width;
|
|
2095
2182
|
const keep = Math.min(len2, Math.max(0, Number.isFinite(f.main.natural) ? f.main.natural : len2));
|
|
2096
2183
|
const shift = it.zone === "end" ? len2 - keep : it.zone === "center" ? (len2 - keep) / 2 : 0;
|
|
2097
|
-
return column ?
|
|
2184
|
+
return column ? rect11(it.rect.x, it.rect.y + shift, it.rect.width, keep) : rect11(it.rect.x + shift, it.rect.y, keep, it.rect.height);
|
|
2098
2185
|
}
|
|
2099
2186
|
function slotAt(c, zone, line, id, place, lands, home = false) {
|
|
2100
2187
|
const result = c.settle(markUsed(moveAmong(c.state, c.dragged, place, c.others), c.dragged));
|
|
@@ -2178,21 +2265,9 @@ function edgeSlots(c, edge, accepts) {
|
|
|
2178
2265
|
const length = len2(el.rect);
|
|
2179
2266
|
const members0 = rest.edges.find((e) => e.id === edge.id)?.items ?? [];
|
|
2180
2267
|
const slotId = (zone, k) => targetId(members0.length === 0 ? { kind: "strip", edge: edge.id, zone } : { kind: "gap", edge: edge.id, zone, at: k });
|
|
2181
|
-
const firstKind = formsOf(state.items[dragged], axisOf(edge.side))[0]?.kind;
|
|
2182
|
-
const titles = edge.items.filter((id) => base.items[id]?.edge === edge.id && base.items[id].fixed && !!formsOf(state.items[id], axisOf(edge.side))[base.items[id].form]?.main.grows);
|
|
2183
2268
|
const lands = ({ layout: after }) => {
|
|
2184
2269
|
const me = after.items[dragged];
|
|
2185
|
-
|
|
2186
|
-
if (titles.length === 0) return true;
|
|
2187
|
-
if (formsOf(state.items[dragged], axisOf(edge.side))[me.form]?.kind !== firstKind) return false;
|
|
2188
|
-
return edge.items.every((id) => {
|
|
2189
|
-
const a = after.items[id];
|
|
2190
|
-
const b = base.items[id];
|
|
2191
|
-
if (!a || !b || b.edge !== edge.id || id === dragged) return true;
|
|
2192
|
-
if (!titles.includes(id)) return a.form === b.form && !!a.inMenu === !!b.inMenu;
|
|
2193
|
-
const f = formsOf(state.items[id], axisOf(edge.side))[a.form];
|
|
2194
|
-
return !f || (column ? a.rect.height : a.rect.width) >= formMain2(f, "natural", after.edges[edge.id].cross) - 0.5;
|
|
2195
|
-
});
|
|
2270
|
+
return me.edge === edge.id && !me.inMenu;
|
|
2196
2271
|
};
|
|
2197
2272
|
const pad = { start: Math.max(0, edge.pad?.start ?? 0), end: Math.max(0, edge.pad?.end ?? 0) };
|
|
2198
2273
|
const menuLen = el.menu ? len2(el.menu.rect) : 0;
|
|
@@ -2232,7 +2307,12 @@ function edgeSlots(c, edge, accepts) {
|
|
|
2232
2307
|
const b = base.items[id];
|
|
2233
2308
|
const a = s.result.layout.items[id];
|
|
2234
2309
|
if (fixedHere(id) && !a) return true;
|
|
2235
|
-
|
|
2310
|
+
if (!isProtected(id)) return false;
|
|
2311
|
+
if (itemSteps3(state.items[id]) && (a.inMenu || b.inMenu)) {
|
|
2312
|
+
const i = members.indexOf(id);
|
|
2313
|
+
return i >= 0 && anchored2.has(id) && (zone === "end" ? k > i : k <= i);
|
|
2314
|
+
}
|
|
2315
|
+
return Math.abs(a.rect.x - b.rect.x) > 0.5 || Math.abs(a.rect.y - b.rect.y) > 0.5;
|
|
2236
2316
|
});
|
|
2237
2317
|
if (!movesFixed) slots.push(s);
|
|
2238
2318
|
}
|
|
@@ -2240,7 +2320,7 @@ function edgeSlots(c, edge, accepts) {
|
|
|
2240
2320
|
return slots;
|
|
2241
2321
|
}
|
|
2242
2322
|
function thickerThan(forms, cross) {
|
|
2243
|
-
const shown = forms.filter((f) => f
|
|
2323
|
+
const shown = forms.filter((f) => !formMenu3(f));
|
|
2244
2324
|
return shown.length > 0 && shown.every((f) => !formSetsCross4(f) && formCrossMin4(f) > cross + EPS12);
|
|
2245
2325
|
}
|
|
2246
2326
|
var roomReason = (spec, zone) => spec.refuse(zone) === "too-thick" ? "too-thick" : "no-room";
|
|
@@ -2253,7 +2333,7 @@ function edgeSpec(c, edge, as) {
|
|
|
2253
2333
|
const column = axisOf(edge.side) === "column";
|
|
2254
2334
|
const at = (r2) => column ? r2.y : r2.x;
|
|
2255
2335
|
const len2 = (r2) => column ? r2.height : r2.width;
|
|
2256
|
-
const empty = el.stack.items.every((p) => p.
|
|
2336
|
+
const empty = el.stack.items.every((p) => el.stack.menu?.items.includes(p.id)) && !el.menu;
|
|
2257
2337
|
const accepts = edgeTakes(edge, kind);
|
|
2258
2338
|
if (!accepts && (empty || area2(el.rect) <= EPS12)) return null;
|
|
2259
2339
|
if (accepts && empty && !opensEmpty(state, edge, kind)) return null;
|
|
@@ -2282,7 +2362,7 @@ function edgeSpec(c, edge, as) {
|
|
|
2282
2362
|
const marker = (s) => {
|
|
2283
2363
|
const slot = s.result.layout.items[dragged].rect;
|
|
2284
2364
|
const e = s.result.layout.edges[edge.id];
|
|
2285
|
-
return column ?
|
|
2365
|
+
return column ? rect11(e.rect.x, slot.y, e.cross, 0) : rect11(slot.x, e.rect.y, 0, e.cross);
|
|
2286
2366
|
};
|
|
2287
2367
|
const takes = (zone) => accepts && zoneTakes(edge, zone, kind);
|
|
2288
2368
|
const tooThick = thickerThan(formsOf(state.items[dragged], axisOf(edge.side)), el.stack.cross);
|
|
@@ -2319,8 +2399,8 @@ function railColumnSpec(c, edge, run) {
|
|
|
2319
2399
|
}
|
|
2320
2400
|
|
|
2321
2401
|
// src/targets/filter.ts
|
|
2322
|
-
import { overlaps } from "@n-uf/placement";
|
|
2323
|
-
import { formMain as
|
|
2402
|
+
import { overlaps as overlaps2 } from "@n-uf/placement";
|
|
2403
|
+
import { formMain as formMain2, itemSteps as itemSteps4 } from "@n-uf/placement/stack";
|
|
2324
2404
|
function placeKey(s, id) {
|
|
2325
2405
|
const it = Object.hasOwn(s.items, id) ? s.items[id] : void 0;
|
|
2326
2406
|
const byZone = (items) => ZONES.flatMap((z) => items.filter((x) => zoneOf(s.items[x]) === z));
|
|
@@ -2332,9 +2412,9 @@ function placeKey(s, id) {
|
|
|
2332
2412
|
});
|
|
2333
2413
|
}
|
|
2334
2414
|
function soundness(state, base, dragged) {
|
|
2335
|
-
const chrome = keepClearFor(state, "targets");
|
|
2336
2415
|
const noteKey = (n) => "edge" in n && (n.code === "overflow" || n.code === "too-wide") ? `${n.edge}:${n.code}:${"id" in n ? n.id : ""}` : null;
|
|
2337
2416
|
const hadNotes = new Set(base.notes.map(noteKey).filter((k) => k !== null));
|
|
2417
|
+
const chrome = keepClearFor(state, {}, "targets");
|
|
2338
2418
|
return (after) => {
|
|
2339
2419
|
if (after.notes.some((n) => {
|
|
2340
2420
|
const k = noteKey(n);
|
|
@@ -2344,15 +2424,20 @@ function soundness(state, base, dragged) {
|
|
|
2344
2424
|
if (!b.fixed) continue;
|
|
2345
2425
|
const a = after.items[id];
|
|
2346
2426
|
const e = a?.edge ? after.edges[a.edge] : void 0;
|
|
2347
|
-
if (!a || !e
|
|
2427
|
+
if (!a || !e) return false;
|
|
2428
|
+
const steps = itemSteps4(state.items[id]);
|
|
2429
|
+
if (!steps && (a.form !== b.form || a.formKind !== b.formKind)) return false;
|
|
2430
|
+
if (a.inMenu) continue;
|
|
2348
2431
|
const f = formsOf(state.items[id], axisOf(e.side))[a.form];
|
|
2349
2432
|
const len2 = axisOf(e.side) === "column" ? a.rect.height : a.rect.width;
|
|
2350
|
-
|
|
2433
|
+
const holds = !steps && f?.main.grows === true;
|
|
2434
|
+
if (f && len2 < formMain2(f, holds ? "natural" : "min", e.cross) - 0.5) return false;
|
|
2351
2435
|
}
|
|
2352
2436
|
const me = after.items[dragged];
|
|
2353
2437
|
if (!me) return true;
|
|
2354
|
-
const fixedAfter = Object.entries(after.items).filter(([id, it]) => it.fixed && id !== dragged).map(([id]) => reservedRect(state, after, id));
|
|
2355
|
-
|
|
2438
|
+
const fixedAfter = Object.entries(after.items).filter(([id, it]) => it.fixed && !(it.inMenu && itemSteps4(state.items[id])) && id !== dragged).map(([id]) => reservedRect(state, after, id));
|
|
2439
|
+
const onChrome = chrome.some((c) => overlaps2(me.rect, c)) || (after.keepClear ?? []).some((c) => c.for !== "floats" && overlaps2(me.rect, c.rect));
|
|
2440
|
+
return !onChrome && !fixedAfter.some((f) => overlaps2(me.rect, f));
|
|
2356
2441
|
};
|
|
2357
2442
|
}
|
|
2358
2443
|
function context(state, dragged, options, others = []) {
|
|
@@ -2382,17 +2467,17 @@ function context(state, dragged, options, others = []) {
|
|
|
2382
2467
|
}
|
|
2383
2468
|
|
|
2384
2469
|
// src/targets/ownership.ts
|
|
2385
|
-
import { EPS as EPS15, area as area3, overlaps as
|
|
2386
|
-
import { formBody } from "@n-uf/placement/stack";
|
|
2470
|
+
import { EPS as EPS15, area as area3, overlaps as overlaps3, rect as rect13, subtract as subtract2 } from "@n-uf/placement";
|
|
2471
|
+
import { formBody, itemSteps as itemSteps5 } from "@n-uf/placement/stack";
|
|
2387
2472
|
|
|
2388
2473
|
// src/targets/meet.ts
|
|
2389
|
-
import { EPS as EPS13, rect as
|
|
2474
|
+
import { EPS as EPS13, rect as rect12 } from "@n-uf/placement";
|
|
2390
2475
|
function meet(a, b) {
|
|
2391
2476
|
const x = Math.max(a.x, b.x);
|
|
2392
2477
|
const y = Math.max(a.y, b.y);
|
|
2393
2478
|
const w = Math.min(a.x + a.width, b.x + b.width) - x;
|
|
2394
2479
|
const h = Math.min(a.y + a.height, b.y + b.height) - y;
|
|
2395
|
-
return w > EPS13 && h > EPS13 ?
|
|
2480
|
+
return w > EPS13 && h > EPS13 ? rect12(x, y, w, h) : null;
|
|
2396
2481
|
}
|
|
2397
2482
|
|
|
2398
2483
|
// src/targets/model.ts
|
|
@@ -2404,28 +2489,42 @@ var isBody = (f) => !!f && formBody(f);
|
|
|
2404
2489
|
var bandOf = (s) => {
|
|
2405
2490
|
const a = Math.min(...s.zones.map((z) => z.a));
|
|
2406
2491
|
const b = Math.max(...s.zones.map((z) => z.b));
|
|
2407
|
-
return s.vertical ?
|
|
2492
|
+
return s.vertical ? rect13(s.owned[0], a, s.owned[1] - s.owned[0], b - a) : rect13(a, s.owned[0], b - a, s.owned[1] - s.owned[0]);
|
|
2408
2493
|
};
|
|
2409
2494
|
var ownedRectOf = (s) => {
|
|
2410
2495
|
const b = bandOf(s);
|
|
2411
2496
|
if (!s.ownedAlong) return b;
|
|
2412
2497
|
const [a0, a1] = s.ownedAlong;
|
|
2413
|
-
return s.vertical ?
|
|
2498
|
+
return s.vertical ? rect13(b.x, a0, b.width, a1 - a0) : rect13(a0, b.y, a1 - a0, b.height);
|
|
2414
2499
|
};
|
|
2415
2500
|
function ownedRectsOf(s, along2) {
|
|
2416
2501
|
if (along2.length === 0) return [];
|
|
2417
2502
|
const o = ownedRectOf(s);
|
|
2418
2503
|
if (s.ownedAlong) return [o];
|
|
2419
|
-
return along2.map(([a, b]) => s.vertical ?
|
|
2504
|
+
return along2.map(([a, b]) => s.vertical ? rect13(o.x, a, o.width, b - a) : rect13(a, o.y, b - a, o.height));
|
|
2420
2505
|
}
|
|
2421
2506
|
function drawnOf(c, live) {
|
|
2422
|
-
|
|
2507
|
+
const edges = Object.entries(c.now.edges).filter(([id, e]) => area3(e.rect) > EPS15 && c.lay.has(id)).map(([id, e]) => ({ spec: live.find((s) => s.edge?.id === id) ?? null, rect: e.rect, lay: c.lay.get(id) }));
|
|
2508
|
+
const rails = ["left", "right"].flatMap((side) => {
|
|
2509
|
+
const rail = c.now.rails[side];
|
|
2510
|
+
if (!rail || rail.segments.length === 0 || area3(rail.rect) <= EPS15) return [];
|
|
2511
|
+
const spec = live.find((s) => s.kind === "railStop" && s.lay.side === side) ?? null;
|
|
2512
|
+
const lay = spec?.lay ?? { phase: EDGE_KINDS.railStop.phase, side, at: -1 };
|
|
2513
|
+
const me = c.now.items[c.dragged];
|
|
2514
|
+
const run = me?.rail === side ? rail.segments.filter((g) => g.edge === me.edge).map((g) => g.rect) : [];
|
|
2515
|
+
if (run.length === 0) return [{ spec, rect: rail.rect, lay }];
|
|
2516
|
+
const top = Math.min(...run.map((r) => r.y));
|
|
2517
|
+
const own = rect13(rail.rect.x, top, rail.rect.width, Math.max(...run.map((r) => r.y + r.height)) - top);
|
|
2518
|
+
const column = live.find((s) => s.kind === "railColumn" && s.edge?.id === me.edge);
|
|
2519
|
+
return [...subtract2(rail.rect, own).map((r) => ({ spec, rect: r, lay })), ...column ? [{ spec: column, rect: own, lay: column.lay }] : []];
|
|
2520
|
+
});
|
|
2521
|
+
return [...edges, ...rails];
|
|
2423
2522
|
}
|
|
2424
2523
|
function homeRectOf(c, ownSpec) {
|
|
2425
2524
|
const own = c.now.items[c.dragged];
|
|
2426
2525
|
if (!own || own.floating || !own.edge) return null;
|
|
2427
2526
|
const o = own.rect;
|
|
2428
|
-
const hull3 = (a, b) =>
|
|
2527
|
+
const hull3 = (a, b) => rect13(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.x + a.width, b.x + b.width) - Math.min(a.x, b.x), Math.max(a.y + a.height, b.y + b.height) - Math.min(a.y, b.y));
|
|
2429
2528
|
if (own.inMenu) return o;
|
|
2430
2529
|
if (!ownSpec) {
|
|
2431
2530
|
const e = c.now.edges[own.edge];
|
|
@@ -2433,7 +2532,7 @@ function homeRectOf(c, ownSpec) {
|
|
|
2433
2532
|
return e && vanishes && !e.folded && !e.rides && area3(e.rect) > EPS15 ? hull3(o, e.rect) : o;
|
|
2434
2533
|
}
|
|
2435
2534
|
const [c0, c1] = ownSpec.across();
|
|
2436
|
-
return ownSpec.vertical ? hull3(o,
|
|
2535
|
+
return ownSpec.vertical ? hull3(o, rect13(c0, o.y, c1 - c0, o.height)) : hull3(o, rect13(o.x, c0, o.width, c1 - c0));
|
|
2437
2536
|
}
|
|
2438
2537
|
function ownersOf(c, live, drawn, alongOf) {
|
|
2439
2538
|
const ownEdge = c.now.items[c.dragged]?.edge;
|
|
@@ -2448,14 +2547,14 @@ function ownersOf(c, live, drawn, alongOf) {
|
|
|
2448
2547
|
...live.flatMap((s) => {
|
|
2449
2548
|
const rects = ownedRectsOf(s, alongOf(s));
|
|
2450
2549
|
if (!s.thinOwned) return rects.map((r) => ({ spec: s, rect: r, lay: s.lay, place: !s.drawn }));
|
|
2451
|
-
const thin = (r) => s.vertical ?
|
|
2550
|
+
const thin = (r) => s.vertical ? rect13(Math.max(r.x, s.thinOwned[0]), r.y, Math.min(r.x + r.width, s.thinOwned[1]) - Math.max(r.x, s.thinOwned[0]), r.height) : rect13(r.x, Math.max(r.y, s.thinOwned[0]), r.width, Math.min(r.y + r.height, s.thinOwned[1]) - Math.max(r.y, s.thinOwned[0]));
|
|
2452
2551
|
return rects.flatMap((r) => [{ spec: s, rect: thin(r), lay: s.lay, place: true }, ...subtract2(r, thin(r)).map((d) => ({ spec: s, rect: d, lay: s.lay, place: true, deep: true }))]);
|
|
2453
2552
|
}).filter((o) => area3(o.rect) > EPS15),
|
|
2454
2553
|
// Every seen rect: the edges the tiler doesn't read (folded, riding, taking nothing) among them.
|
|
2455
2554
|
...drawn.map((d) => ({ ...d, place: false }))
|
|
2456
2555
|
];
|
|
2457
2556
|
}
|
|
2458
|
-
function ownership(c, live, alongOf) {
|
|
2557
|
+
function ownership(c, live, alongOf, aloneOf) {
|
|
2459
2558
|
const { state, now, dragged } = c;
|
|
2460
2559
|
const drawn = drawnOf(c, live);
|
|
2461
2560
|
const owners = ownersOf(c, live, drawn, alongOf);
|
|
@@ -2466,15 +2565,15 @@ function ownership(c, live, alongOf) {
|
|
|
2466
2565
|
const place = !s.drawn;
|
|
2467
2566
|
return o.place === place ? !place || o.lay.at < s.lay.at : !o.place;
|
|
2468
2567
|
};
|
|
2469
|
-
const takingRects = (s) => s.drawn ? s.zones.filter((z) => s.slots.some((sl) => sl.ok && sl.zone === z.zone)).map((z) => s.vertical ?
|
|
2568
|
+
const takingRects = (s) => s.drawn ? s.zones.filter((z) => s.slots.some((sl) => sl.ok && sl.zone === z.zone)).map((z) => s.vertical ? rect13(s.owned[0], z.a, s.owned[1] - s.owned[0], z.b - z.a) : rect13(z.a, s.owned[0], z.b - z.a, s.owned[1] - s.owned[0])) : [];
|
|
2470
2569
|
const thinRectOf = (s) => {
|
|
2471
2570
|
const b = bandOf(s);
|
|
2472
2571
|
const [t0, t1] = s.thinOwned;
|
|
2473
|
-
return s.vertical ?
|
|
2572
|
+
return s.vertical ? rect13(t0, b.y, t1 - t0, b.height) : rect13(b.x, t0, b.width, t1 - t0);
|
|
2474
2573
|
};
|
|
2475
2574
|
const endsOf = (s) => {
|
|
2476
2575
|
const e = s.edge ? now.edges[s.id] : void 0;
|
|
2477
|
-
if (!e
|
|
2576
|
+
if (!e) return null;
|
|
2478
2577
|
const span = s.vertical ? [e.rect.y, e.rect.y + e.rect.height] : [e.rect.x, e.rect.x + e.rect.width];
|
|
2479
2578
|
return span[1] - span[0] > EPS15 ? span : null;
|
|
2480
2579
|
};
|
|
@@ -2482,33 +2581,39 @@ function ownership(c, live, alongOf) {
|
|
|
2482
2581
|
const ends = endsOf(s);
|
|
2483
2582
|
if (!ends) return [];
|
|
2484
2583
|
const [lo2, hi] = s.vertical ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
|
|
2485
|
-
return less([[lo2, hi]], [ends]).map(([u, w]) => s.vertical ?
|
|
2584
|
+
return less([[lo2, hi]], [ends]).map(([u, w]) => s.vertical ? rect13(r.x, u, r.width, w - u) : rect13(u, r.y, w - u, r.height));
|
|
2486
2585
|
};
|
|
2487
2586
|
const ownSpanOf = (s) => {
|
|
2488
2587
|
const ends = endsOf(s);
|
|
2489
2588
|
if (!ends) return null;
|
|
2490
2589
|
const [o0, o1] = s.owned;
|
|
2491
|
-
return s.vertical ?
|
|
2590
|
+
return s.vertical ? rect13(o0, ends[0], o1 - o0, ends[1] - ends[0]) : rect13(ends[0], o0, ends[1] - ends[0], o1 - o0);
|
|
2591
|
+
};
|
|
2592
|
+
const heldBySpec = /* @__PURE__ */ new Map();
|
|
2593
|
+
const heldOf = (d) => {
|
|
2594
|
+
let held = heldBySpec.get(d);
|
|
2595
|
+
if (!held) {
|
|
2596
|
+
const span = ownSpanOf(d);
|
|
2597
|
+
heldBySpec.set(d, held = span ? ownedRectsOf(d, alongOf(d)).flatMap((r) => meet(r, span) ?? []) : aloneOf(d));
|
|
2598
|
+
}
|
|
2599
|
+
return held;
|
|
2492
2600
|
};
|
|
2493
2601
|
const reachLess = (o, r, s) => {
|
|
2494
|
-
const
|
|
2495
|
-
if (!o.spec ||
|
|
2496
|
-
return pastEnds(o.spec, r).flatMap((p) => meet(p,
|
|
2602
|
+
const held = heldOf(s);
|
|
2603
|
+
if (!o.spec || held.length === 0) return [r];
|
|
2604
|
+
return pastEnds(o.spec, r).flatMap((p) => held.flatMap((h) => meet(p, h) ?? [])).reduce((acc, cut2) => acc.flatMap((q) => subtract2(q, cut2)), [r]);
|
|
2497
2605
|
};
|
|
2498
2606
|
const reachYields = (s) => {
|
|
2499
2607
|
const past = pastEnds(s, bandOf(s));
|
|
2500
2608
|
if (past.length === 0) return [];
|
|
2501
|
-
return live.filter((d) => d !== s).flatMap((d) =>
|
|
2502
|
-
const span = ownSpanOf(d);
|
|
2503
|
-
return span ? ownedRectsOf(d, alongOf(d)).flatMap((r) => meet(r, span) ?? []) : [];
|
|
2504
|
-
}).flatMap((q) => past.flatMap((p) => meet(p, q) ?? []));
|
|
2609
|
+
return live.filter((d) => d !== s).flatMap((d) => heldOf(d)).flatMap((q) => past.flatMap((p) => meet(p, q) ?? []));
|
|
2505
2610
|
};
|
|
2506
2611
|
const taken = new Map(
|
|
2507
2612
|
live.map((s) => [
|
|
2508
2613
|
s,
|
|
2509
2614
|
[
|
|
2510
2615
|
...owners.filter((o) => wins(o, s)).flatMap((o) => (o.deep ? takingRects(s).reduce((acc, t) => acc.flatMap((r) => subtract2(r, t)), [o.rect]) : [o.rect]).flatMap((r) => reachLess(o, r, s))),
|
|
2511
|
-
...EDGE_KINDS[s.kind].virtual ? owners.filter((o) => o.spec !== s && !wins(o, s)).flatMap((o) => subtract2(o.rect, ownedRectOf(s))) : [],
|
|
2616
|
+
...EDGE_KINDS[s.kind].virtual ? owners.filter((o) => o.spec !== s && !wins(o, s)).flatMap((o) => subtract2(o.rect, ownedRectOf(s)).flatMap((r) => reachLess(o, r, s))) : [],
|
|
2512
2617
|
...s.thinOwned ? live.filter((d) => d !== s).flatMap((d) => takingRects(d).flatMap((t) => subtract2(t, thinRectOf(s)))) : [],
|
|
2513
2618
|
...reachYields(s)
|
|
2514
2619
|
]
|
|
@@ -2534,7 +2639,7 @@ function ownership(c, live, alongOf) {
|
|
|
2534
2639
|
const b = bandOf(s);
|
|
2535
2640
|
const along2 = (r) => s.vertical ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
|
|
2536
2641
|
const across2 = (r) => s.vertical ? [r.x, r.x + r.width] : [r.y, r.y + r.height];
|
|
2537
|
-
const rs = taken.get(s).filter((r) =>
|
|
2642
|
+
const rs = taken.get(s).filter((r) => overlaps3(r, b));
|
|
2538
2643
|
const ends = [.../* @__PURE__ */ new Set([...along2(b), ...rs.flatMap(along2)])].filter((x) => x >= along2(b)[0] && x <= along2(b)[1]).sort((p, q) => p - q);
|
|
2539
2644
|
const owned = [];
|
|
2540
2645
|
for (let k = 1; k < ends.length; k++) {
|
|
@@ -2566,12 +2671,12 @@ function ownership(c, live, alongOf) {
|
|
|
2566
2671
|
const e = it.edge ? now.edges[it.edge] : void 0;
|
|
2567
2672
|
return !!e && !!formsOf(state.items[id], axisOf(e.side))[it.form]?.main.grows;
|
|
2568
2673
|
};
|
|
2569
|
-
const solid = Object.entries(now.items).filter(([id, it]) => it.fixed && !grows(id)).map(([, it]) => it.rect);
|
|
2674
|
+
const solid = Object.entries(now.items).filter(([id, it]) => it.fixed && !grows(id) && !(it.inMenu && itemSteps5(state.items[id]))).map(([, it]) => it.rect);
|
|
2570
2675
|
const bodies = (s) => {
|
|
2571
2676
|
const e = s.edge;
|
|
2572
2677
|
if (!e) return [];
|
|
2573
2678
|
const column = axisOf(e.side) === "column";
|
|
2574
|
-
const across2 = (a, b) => column ?
|
|
2679
|
+
const across2 = (a, b) => column ? rect13(-1e9, a, 2e9, b - a) : rect13(a, -1e9, b - a, 2e9);
|
|
2575
2680
|
const reserved = Object.entries(now.items).filter(([iid, p]) => p.edge === e.id && p.fixed && !p.inMenu && !grows(iid)).map(([, p]) => column ? across2(p.rect.y, p.rect.y + p.rect.height) : across2(p.rect.x, p.rect.x + p.rect.width));
|
|
2576
2681
|
return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area3(b) > EPS15);
|
|
2577
2682
|
};
|
|
@@ -2585,13 +2690,13 @@ function ownership(c, live, alongOf) {
|
|
|
2585
2690
|
}
|
|
2586
2691
|
|
|
2587
2692
|
// src/targets/tiles.ts
|
|
2588
|
-
import { EPS as EPS16, area as area4, overlaps as
|
|
2693
|
+
import { EPS as EPS16, area as area4, overlaps as overlaps4, rect as rect14, subtract as subtract3 } from "@n-uf/placement";
|
|
2589
2694
|
function tilerOf(spec) {
|
|
2590
2695
|
const data = EDGE_KINDS[spec.kind];
|
|
2591
2696
|
const v = spec.vertical;
|
|
2592
2697
|
const band = (a, b, after) => {
|
|
2593
2698
|
const [c0, c1] = spec.across(after);
|
|
2594
|
-
return v ?
|
|
2699
|
+
return v ? rect14(c0, a, c1 - c0, b - a) : rect14(a, c0, b - a, c1 - c0);
|
|
2595
2700
|
};
|
|
2596
2701
|
const keepAt = (line, h) => v ? { x: h.x + h.width / 2, y: line } : { x: line, y: h.y + h.height / 2 };
|
|
2597
2702
|
const tile = (zone, hit, more) => ({ edge: spec.id, spec, edgeKind: spec.kind, vertical: v, zone, hit, ...more });
|
|
@@ -2599,7 +2704,7 @@ function tilerOf(spec) {
|
|
|
2599
2704
|
const h = t.hit;
|
|
2600
2705
|
const [h0, h1] = v ? [h.x, h.x + h.width] : [h.y, h.y + h.height];
|
|
2601
2706
|
const [c0, c1] = [Math.max(h0, spec.owned[0]), Math.min(h1, spec.owned[1])];
|
|
2602
|
-
const part = (a, b) => v ?
|
|
2707
|
+
const part = (a, b) => v ? rect14(a, h.y, b - a, h.height) : rect14(h.x, a, h.width, b - a);
|
|
2603
2708
|
const beyond = less([[h0, h1]], [spec.owned]);
|
|
2604
2709
|
if (beyond.length === 0) return [t];
|
|
2605
2710
|
if (c1 - c0 <= EPS16) return [{ ...t, order: data.overreach }];
|
|
@@ -2652,9 +2757,9 @@ function reachStrips(c, spec, room, ends) {
|
|
|
2652
2757
|
const pieces = room.filter(inEdge);
|
|
2653
2758
|
if (!ends || pieces.length === 0) return { pieces: [...room], before: [], after: [] };
|
|
2654
2759
|
const [c0, c1] = spec.across();
|
|
2655
|
-
const bandOf2 = (a, b) => spec.vertical ?
|
|
2760
|
+
const bandOf2 = (a, b) => spec.vertical ? rect14(c0, a, c1 - c0, b - a) : rect14(a, c0, b - a, c1 - c0);
|
|
2656
2761
|
const across2 = c.state.edges.filter((e) => axisOf(e.side) === "column" !== spec.vertical).map((e) => c.now.edges[e.id]);
|
|
2657
|
-
const drawnBetween = (a, b) => b - a > EPS16 && across2.some((e) => !!e && e.cross > EPS16 && area4(e.rect) > EPS16 &&
|
|
2762
|
+
const drawnBetween = (a, b) => b - a > EPS16 && across2.some((e) => !!e && e.cross > EPS16 && area4(e.rect) > EPS16 && overlaps4(e.rect, bandOf2(a, b)));
|
|
2658
2763
|
const first = pieces[0][0];
|
|
2659
2764
|
const last = pieces[pieces.length - 1][1];
|
|
2660
2765
|
return {
|
|
@@ -2671,7 +2776,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
|
|
|
2671
2776
|
const own = spec.own ? v ? [spec.own.y, spec.own.y + spec.own.height] : [spec.own.x, spec.own.x + spec.own.width] : null;
|
|
2672
2777
|
const { band, keepAt, tile, split } = tilerOf(spec);
|
|
2673
2778
|
const drawn = spec.edge ? c.now.edges[spec.id]?.rect : void 0;
|
|
2674
|
-
const alongLimit = drawn && (v ? drawn.height : drawn.width) > EPS16 ? v ?
|
|
2779
|
+
const alongLimit = drawn && (v ? drawn.height : drawn.width) > EPS16 ? v ? rect14(-1e9, drawn.y, 2e9, drawn.height) : rect14(drawn.x, -1e9, drawn.width, 2e9) : null;
|
|
2675
2780
|
const refused = (zone, hit, reason) => {
|
|
2676
2781
|
const inEdge = alongLimit ? meet(hit, alongLimit) : hit;
|
|
2677
2782
|
const shown = inEdge && meet(inEdge, c.state.stage);
|
|
@@ -2751,7 +2856,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
|
|
|
2751
2856
|
const [a, b] = own;
|
|
2752
2857
|
const h = band(a, b);
|
|
2753
2858
|
const o = spec.own;
|
|
2754
|
-
const hit = v ?
|
|
2859
|
+
const hit = v ? rect14(Math.min(h.x, o.x), a, Math.max(h.x + h.width, o.x + o.width) - Math.min(h.x, o.x), b - a) : rect14(a, Math.min(h.y, o.y), b - a, Math.max(h.y + h.height, o.y + o.height) - Math.min(h.y, o.y));
|
|
2755
2860
|
out.push(tile(home?.zone ?? zoneOf(c.state.items[c.dragged]), hit, { kind: "home", id: home ? home.id : targetId({ kind: "home", item: c.dragged }), order: 0, priority: home ? data.priority : 1, keep: null, place: { kind: "home" } }));
|
|
2756
2861
|
}
|
|
2757
2862
|
return out;
|
|
@@ -2785,7 +2890,7 @@ function placeReach(t, pieces, placed, landed, gone) {
|
|
|
2785
2890
|
(p) => t.vertical ? p.y <= h.y + EPS16 && p.y + p.height >= h.y + h.height - EPS16 && (Math.abs(p.x - h.x - h.width) < EPS16 || Math.abs(p.x + p.width - h.x) < EPS16) : p.x <= h.x + EPS16 && p.x + p.width >= h.x + h.width - EPS16 && (Math.abs(p.y - h.y - h.height) < EPS16 || Math.abs(p.y + p.height - h.y) < EPS16)
|
|
2786
2891
|
);
|
|
2787
2892
|
if (!joint) continue;
|
|
2788
|
-
const merged = t.vertical ?
|
|
2893
|
+
const merged = t.vertical ? rect14(Math.min(h.x, joint.x), h.y, Math.max(h.x + h.width, joint.x + joint.width) - Math.min(h.x, joint.x), h.height) : rect14(h.x, Math.min(h.y, joint.y), h.width, Math.max(h.y + h.height, joint.y + joint.height) - Math.min(h.y, joint.y));
|
|
2789
2894
|
placed[i] = cover.length > 1 ? withPieces(placed[i], cover.map((r, j) => j === k ? merged : r)) : { ...placed[i], hit: merged };
|
|
2790
2895
|
return;
|
|
2791
2896
|
}
|
|
@@ -2853,10 +2958,10 @@ function clipTiles(tiles, own, chrome, lost) {
|
|
|
2853
2958
|
}
|
|
2854
2959
|
|
|
2855
2960
|
// src/targets/rail-strip.ts
|
|
2856
|
-
import { EPS as EPS18, overlaps as
|
|
2961
|
+
import { EPS as EPS18, overlaps as overlaps5, rect as rect16, subtract as subtract4 } from "@n-uf/placement";
|
|
2857
2962
|
|
|
2858
2963
|
// src/targets/virtual.ts
|
|
2859
|
-
import { EPS as EPS17, clamp, rect as
|
|
2964
|
+
import { EPS as EPS17, clamp, rect as rect15 } from "@n-uf/placement";
|
|
2860
2965
|
function ringsOf(c, side) {
|
|
2861
2966
|
const seen = sideRings(c.state.edges, side);
|
|
2862
2967
|
const kept = c.rest.edges.filter((e) => e.side === side).map((e) => seen.get(e.id) ?? e.ring);
|
|
@@ -2934,7 +3039,7 @@ function columnLines(c, side, railLands) {
|
|
|
2934
3039
|
ownedAlong: p.owned,
|
|
2935
3040
|
drawn: false,
|
|
2936
3041
|
// Where the new column's edge lands: the line itself, inside the stage.
|
|
2937
|
-
marker: () =>
|
|
3042
|
+
marker: () => rect15(clamp(l.x, stage.x, stage.x + stage.width), span.y, 0, span.height)
|
|
2938
3043
|
};
|
|
2939
3044
|
});
|
|
2940
3045
|
}
|
|
@@ -2961,7 +3066,7 @@ function ownColumnRun(c, side, rail) {
|
|
|
2961
3066
|
const tiles = shown.segments.filter((s) => s.edge === edge.id).map((s) => s.rect);
|
|
2962
3067
|
if (tiles.length === 0) return null;
|
|
2963
3068
|
const top = Math.min(...tiles.map((r) => r.y));
|
|
2964
|
-
const spec = railColumnSpec(c, edge,
|
|
3069
|
+
const spec = railColumnSpec(c, edge, rect15(shown.rect.x, top, shown.rect.width, Math.max(...tiles.map((r) => r.y + r.height)) - top));
|
|
2965
3070
|
if (!spec) return null;
|
|
2966
3071
|
const stays = ({ layout }) => layout.items[dragged]?.rail === side && layout.items[dragged]?.edge === edge.id;
|
|
2967
3072
|
return { ...spec, own: null, holds: false, homePriority: EDGE_KINDS.railStop.priority, slots: spec.slots.map((s) => s.home ? { ...s, id: homeId } : { ...s, ok: s.ok && stays(s.result) }) };
|
|
@@ -2999,7 +3104,7 @@ function railStops(c, side) {
|
|
|
2999
3104
|
} else {
|
|
3000
3105
|
const firstCol = mine.find((e) => e.column === true);
|
|
3001
3106
|
const outer = railOuter(c, side);
|
|
3002
|
-
zone =
|
|
3107
|
+
zone = rect15(side === "left" ? outer : outer - RAIL_EDGE, placeRect.y, RAIL_EDGE, placeRect.height);
|
|
3003
3108
|
stops2.push({ y: placeRect.y, ring: firstCol ? rings.before(firstCol) : rings.count });
|
|
3004
3109
|
}
|
|
3005
3110
|
const ownRail = now.items[dragged]?.rail === side;
|
|
@@ -3030,7 +3135,7 @@ function railStops(c, side) {
|
|
|
3030
3135
|
owned: rail && rail.segments.length > 0 ? [at.x, at.x + at.width] : side === "left" ? [at.x, at.x + Math.min(at.width, EDGE_KINDS.railStop.place)] : [at.x + at.width - Math.min(at.width, EDGE_KINDS.railStop.place), at.x + at.width],
|
|
3031
3136
|
ownedAlong: null,
|
|
3032
3137
|
drawn: !!rail && rail.segments.length > 0,
|
|
3033
|
-
marker: (s) =>
|
|
3138
|
+
marker: (s) => rect15(at.x, s.result.layout.items[dragged].rect.y, at.width, 0)
|
|
3034
3139
|
};
|
|
3035
3140
|
}
|
|
3036
3141
|
|
|
@@ -3050,7 +3155,7 @@ function columnStrip(c, side, policy) {
|
|
|
3050
3155
|
const r = el.rect;
|
|
3051
3156
|
const railWidth = result.layout.items[c.dragged].tab ? r.width : edge.cross.rail ?? 30;
|
|
3052
3157
|
const [x, w] = across(side, side === "left" ? r.x : r.x + r.width, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, railWidth));
|
|
3053
|
-
return { side, rect:
|
|
3158
|
+
return { side, rect: rect16(x, r.y, w, r.height), slots: [{ id: targetId({ kind: "rail", side, ring: edge.ring }), place, along: [r.y, r.y + r.height], result }] };
|
|
3054
3159
|
}
|
|
3055
3160
|
function declaredStrip(c, side, policy) {
|
|
3056
3161
|
const template = c.state.columns?.[side];
|
|
@@ -3067,11 +3172,11 @@ function declaredStrip(c, side, policy) {
|
|
|
3067
3172
|
const cuts = [a, ...slots.slice(1).map((s, i) => (slots[i].line + s.line) / 2), b];
|
|
3068
3173
|
return {
|
|
3069
3174
|
side,
|
|
3070
|
-
rect:
|
|
3175
|
+
rect: rect16(x, a, w, b - a),
|
|
3071
3176
|
slots: slots.map((s, i) => ({ id: s.id, place: s.place, along: [cuts[i], cuts[i + 1]], result: s.result }))
|
|
3072
3177
|
};
|
|
3073
3178
|
}
|
|
3074
|
-
var outside = (pieces, strips) => strips.reduce((acc, s) => acc.flatMap((p) =>
|
|
3179
|
+
var outside = (pieces, strips) => strips.reduce((acc, s) => acc.flatMap((p) => overlaps5(p, s) ? subtract4(p, s) : [p]), [...pieces]).filter((p) => p.width >= 1 && p.height >= 1);
|
|
3075
3180
|
var largest2 = (rs) => rs.reduce((m, r) => r.width * r.height > m.width * m.height ? r : m);
|
|
3076
3181
|
var sameRects = (a, b) => a.length === b.length && a.every((r, i) => r.x === b[i].x && r.y === b[i].y && r.width === b[i].width && r.height === b[i].height);
|
|
3077
3182
|
function withRailStrips(c, targets2, refusals2) {
|
|
@@ -3152,7 +3257,7 @@ ${r.zone}`) ?? [], r]);
|
|
|
3152
3257
|
group.sort((a, b) => pos(a)[0] - pos(b)[0] || pos(a)[1] - pos(b)[1]).forEach((r, n) => numbered.set(r, targetId({ kind: "refuse", edge: r.edge, zone: r.zone, n })));
|
|
3153
3258
|
const renumbered = refused.map((r) => numbered.get(r) === r.id ? r : { ...r, id: numbered.get(r) });
|
|
3154
3259
|
for (const s of strips) {
|
|
3155
|
-
const grown = s.side === "left" ?
|
|
3260
|
+
const grown = s.side === "left" ? rect16(s.rect.x, s.rect.y, s.rect.width + policy.magnet, s.rect.height) : rect16(s.rect.x - policy.magnet, s.rect.y, s.rect.width + policy.magnet, s.rect.height);
|
|
3156
3261
|
for (const sl of s.slots) {
|
|
3157
3262
|
const [a, b] = sl.along;
|
|
3158
3263
|
const slot = sl.result.layout.items[c.dragged].rect;
|
|
@@ -3160,8 +3265,8 @@ ${r.zone}`) ?? [], r]);
|
|
|
3160
3265
|
out.push({
|
|
3161
3266
|
id: sl.id,
|
|
3162
3267
|
priority: 1,
|
|
3163
|
-
hit:
|
|
3164
|
-
armedHit:
|
|
3268
|
+
hit: rect16(s.rect.x, a, s.rect.width, b - a),
|
|
3269
|
+
armedHit: rect16(grown.x, a, grown.width, b - a),
|
|
3165
3270
|
arm: "dwell",
|
|
3166
3271
|
// Armed, its room opens at once: a host that draws only a marker reads that from this one flag, as for any target.
|
|
3167
3272
|
opensRoom: true,
|
|
@@ -3180,9 +3285,9 @@ var withoutHits = (t) => {
|
|
|
3180
3285
|
return rest;
|
|
3181
3286
|
};
|
|
3182
3287
|
function insideStrips(r, strips) {
|
|
3183
|
-
const s = strips.find((x) =>
|
|
3288
|
+
const s = strips.find((x) => overlaps5(x.rect, r));
|
|
3184
3289
|
if (!s) return null;
|
|
3185
|
-
return s.side === "left" ?
|
|
3290
|
+
return s.side === "left" ? rect16(s.rect.x + s.rect.width, r.y, r.width, r.height) : rect16(s.rect.x - r.width, r.y, r.width, r.height);
|
|
3186
3291
|
}
|
|
3187
3292
|
function clearOfStrips(t, dragged, strips) {
|
|
3188
3293
|
return {
|
|
@@ -3193,8 +3298,8 @@ function clearOfStrips(t, dragged, strips) {
|
|
|
3193
3298
|
if (!at) return first;
|
|
3194
3299
|
let dx = 0;
|
|
3195
3300
|
for (const s of strips) {
|
|
3196
|
-
const r =
|
|
3197
|
-
if (!
|
|
3301
|
+
const r = rect16(at.x + dx, at.y, at.width, at.height);
|
|
3302
|
+
if (!overlaps5(r, s)) continue;
|
|
3198
3303
|
dx += s.x + s.width / 2 < r.x + r.width / 2 ? s.x + s.width - r.x : s.x - (r.x + r.width);
|
|
3199
3304
|
}
|
|
3200
3305
|
return dx === 0 ? first : t.after({ x: at.x + dx + (grab?.x ?? at.width / 2), y: point.y }, grab);
|
|
@@ -3203,7 +3308,7 @@ function clearOfStrips(t, dragged, strips) {
|
|
|
3203
3308
|
}
|
|
3204
3309
|
|
|
3205
3310
|
// src/targets/min-hit.ts
|
|
3206
|
-
import { EPS as EPS19, area as area5, rect as
|
|
3311
|
+
import { EPS as EPS19, area as area5, rect as rect17, subtract as subtract5 } from "@n-uf/placement";
|
|
3207
3312
|
function kindOf(c, t) {
|
|
3208
3313
|
const p = parseTargetId(t.id);
|
|
3209
3314
|
if (!p) return null;
|
|
@@ -3217,7 +3322,7 @@ function kindOf(c, t) {
|
|
|
3217
3322
|
}
|
|
3218
3323
|
var largest3 = (ps) => ps.reduce((a, p) => area5(p) > area5(a) ? p : a);
|
|
3219
3324
|
var keepsMinHit = (r, m) => Math.min(r.width, r.height) >= m.across - EPS19 && Math.max(r.width, r.height) >= m.along - EPS19;
|
|
3220
|
-
var
|
|
3325
|
+
var overlaps6 = (a, b) => Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > EPS19 && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > EPS19;
|
|
3221
3326
|
var cut = (ps, g) => ps.flatMap((p) => subtract5(p, g)).filter((p) => p.width >= 1 && p.height >= 1);
|
|
3222
3327
|
var piecesOf = (t) => t.hits ?? [t.hit];
|
|
3223
3328
|
var withPieces2 = (t, ps) => {
|
|
@@ -3225,25 +3330,25 @@ var withPieces2 = (t, ps) => {
|
|
|
3225
3330
|
return { ...rest, hit: largest3(ps), ...ps.length > 1 ? { hits: ps } : {} };
|
|
3226
3331
|
};
|
|
3227
3332
|
function growths(r, axis, d) {
|
|
3228
|
-
const [lo2, hi] = axis === "x" ? [
|
|
3333
|
+
const [lo2, hi] = axis === "x" ? [rect17(r.x - d, r.y, d, r.height), rect17(r.x + r.width, r.y, d, r.height)] : [rect17(r.x, r.y - d, r.width, d), rect17(r.x, r.y + r.height, r.width, d)];
|
|
3229
3334
|
const h = d / 2;
|
|
3230
|
-
const halves = axis === "x" ? [
|
|
3335
|
+
const halves = axis === "x" ? [rect17(r.x - h, r.y, h, r.height), rect17(r.x + r.width, r.y, h, r.height)] : [rect17(r.x, r.y - h, r.width, h), rect17(r.x, r.y + r.height, r.width, h)];
|
|
3231
3336
|
return [[lo2], [hi], halves];
|
|
3232
3337
|
}
|
|
3233
3338
|
var union = (a, gs) => {
|
|
3234
3339
|
const x0 = Math.min(a.x, ...gs.map((g) => g.x));
|
|
3235
3340
|
const y0 = Math.min(a.y, ...gs.map((g) => g.y));
|
|
3236
|
-
return
|
|
3341
|
+
return rect17(x0, y0, Math.max(a.x + a.width, ...gs.map((g) => g.x + g.width)) - x0, Math.max(a.y + a.height, ...gs.map((g) => g.y + g.height)) - y0);
|
|
3237
3342
|
};
|
|
3238
3343
|
function mayGrow(c, targets2, i, grow, minOf, zone, away) {
|
|
3239
3344
|
const s = c.state.stage;
|
|
3240
3345
|
for (const g of grow) {
|
|
3241
3346
|
if (g.x < s.x - EPS19 || g.y < s.y - EPS19 || g.x + g.width > s.x + s.width + EPS19 || g.y + g.height > s.y + s.height + EPS19) return false;
|
|
3242
|
-
if ([...keepClearFor(c.state, "targets"), ...away].some((r) =>
|
|
3347
|
+
if ([...keepClearFor(c.state, c.now, "targets"), ...away].some((r) => overlaps6(r, g))) return false;
|
|
3243
3348
|
if (zone.reduce((ps, z) => ps.flatMap((p) => subtract5(p, z)), [g]).some((p) => area5(p) > EPS19)) return false;
|
|
3244
3349
|
}
|
|
3245
3350
|
return targets2.every((o, j) => {
|
|
3246
|
-
if (j === i || o.free || !piecesOf(o).some((p) => grow.some((g) =>
|
|
3351
|
+
if (j === i || o.free || !piecesOf(o).some((p) => grow.some((g) => overlaps6(p, g)))) return true;
|
|
3247
3352
|
if (o.place.kind === "home" || o.place.kind === "none" || o.strip) return false;
|
|
3248
3353
|
const m = minOf(o);
|
|
3249
3354
|
const left = grow.reduce((ps, g) => cut(ps, g), [...piecesOf(o)]);
|
|
@@ -3255,11 +3360,11 @@ function partialGrowth(c, targets2, i, l, axis, d, m, minOf, zone, away) {
|
|
|
3255
3360
|
let best = null;
|
|
3256
3361
|
for (const [side] of growths(l, axis, d)) {
|
|
3257
3362
|
const g = side;
|
|
3258
|
-
const strip = (a, b) => axis === "x" ?
|
|
3363
|
+
const strip = (a, b) => axis === "x" ? rect17(g.x, a, g.width, b - a) : rect17(a, g.y, b - a, g.height);
|
|
3259
3364
|
const cuts = /* @__PURE__ */ new Set([along2[0], along2[1]]);
|
|
3260
3365
|
for (const o of targets2)
|
|
3261
3366
|
for (const p of piecesOf(o))
|
|
3262
|
-
if (
|
|
3367
|
+
if (overlaps6(p, g)) {
|
|
3263
3368
|
for (const v of axis === "x" ? [p.y, p.y + p.height] : [p.x, p.x + p.width]) if (v > along2[0] && v < along2[1]) cuts.add(v);
|
|
3264
3369
|
}
|
|
3265
3370
|
const marks = [...cuts].sort((a, b) => a - b);
|
|
@@ -3314,11 +3419,11 @@ function withMinHit(c, targets2, refusals2, zones) {
|
|
|
3314
3419
|
for (let j = 0; j < out.length; j++) {
|
|
3315
3420
|
if (j === i || out[j].free) continue;
|
|
3316
3421
|
const o = out[j];
|
|
3317
|
-
if (!piecesOf(o).some((p) => grow.some((g) =>
|
|
3422
|
+
if (!piecesOf(o).some((p) => grow.some((g) => overlaps6(p, g)))) continue;
|
|
3318
3423
|
out[j] = withPieces2(o, grow.reduce((ps, g) => cut(ps, g), [...piecesOf(o)]));
|
|
3319
3424
|
}
|
|
3320
3425
|
const g0 = grow[0];
|
|
3321
|
-
const span = axis === "x" ?
|
|
3426
|
+
const span = axis === "x" ? rect17(l.x, g0.y, l.width, g0.height) : rect17(g0.x, l.y, g0.width, l.height);
|
|
3322
3427
|
const grown = union(span, grow);
|
|
3323
3428
|
const others = piecesOf(out[i]).filter((p) => p !== l);
|
|
3324
3429
|
out[i] = withPieces2(out[i], [...cut([...others, l], grown), grown]);
|
|
@@ -3391,7 +3496,7 @@ function emit2(c, placed) {
|
|
|
3391
3496
|
function hull(a, b) {
|
|
3392
3497
|
const x = Math.min(a.x, b.x);
|
|
3393
3498
|
const y = Math.min(a.y, b.y);
|
|
3394
|
-
return
|
|
3499
|
+
return rect18(x, y, Math.max(a.x + a.width, b.x + b.width) - x, Math.max(a.y + a.height, b.y + b.height) - y);
|
|
3395
3500
|
}
|
|
3396
3501
|
var thicknessChanges = (now, after) => {
|
|
3397
3502
|
const a = now.content;
|
|
@@ -3403,12 +3508,15 @@ var touchesSide = (stage, pieces) => pieces.some((r) => r.x <= stage.x + EPS20 |
|
|
|
3403
3508
|
function slotOverMoved(now, lifted, after, slot, dragged, onto) {
|
|
3404
3509
|
const from = now.items[dragged]?.edge;
|
|
3405
3510
|
return Object.entries(now.items).some(([id, was]) => {
|
|
3406
|
-
if (!
|
|
3511
|
+
if (!overlaps7(slot, was.rect) || id === dragged || was.floating || was.edge === onto) return false;
|
|
3407
3512
|
const r = after.items[id]?.rect;
|
|
3408
3513
|
const start = (from !== void 0 && was.edge === from ? lifted.items[id]?.rect : void 0) ?? was.rect;
|
|
3409
3514
|
return !!r && (Math.abs(r.x - start.x) > EPS20 || Math.abs(r.y - start.y) > EPS20 || Math.abs(r.width - start.width) > EPS20 || Math.abs(r.height - start.height) > EPS20);
|
|
3410
3515
|
});
|
|
3411
3516
|
}
|
|
3517
|
+
function aloneRects(tiles) {
|
|
3518
|
+
return tiles.filter((t) => t.kind !== "refuse" && !(t.kind === "reach" && t.of.kind === "refuse")).map((t) => t.hit);
|
|
3519
|
+
}
|
|
3412
3520
|
function alongOfSlots(s, tiles) {
|
|
3413
3521
|
const spans = tiles.filter((t) => t.kind === "slot").map((t) => s.vertical ? [t.hit.y, t.hit.y + t.hit.height] : [t.hit.x, t.hit.x + t.hit.width]).sort((a, b) => a[0] - b[0]);
|
|
3414
3522
|
const out = [];
|
|
@@ -3456,7 +3564,7 @@ function generateShown(state, dragged, options, hidden) {
|
|
|
3456
3564
|
const live = specsOf(c, item.kind);
|
|
3457
3565
|
const alone = new Map(live.map((s) => [s, tileEdge(c, s, { cuts: [], bodies: [] }, [])]));
|
|
3458
3566
|
const along2 = new Map(live.map((s) => [s, alongOfSlots(s, alone.get(s))]));
|
|
3459
|
-
const own = ownership(c, live, (s) => along2.get(s));
|
|
3567
|
+
const own = ownership(c, live, (s) => along2.get(s), (s) => aloneRects(alone.get(s)));
|
|
3460
3568
|
const lost = [];
|
|
3461
3569
|
const tiles = live.flatMap((spec) => tileEdge(c, spec, own.cutsOf(spec), lost));
|
|
3462
3570
|
const ownRect = now.items[dragged];
|
|
@@ -3464,7 +3572,7 @@ function generateShown(state, dragged, options, hidden) {
|
|
|
3464
3572
|
const homeHit = homeRectOf(c, null);
|
|
3465
3573
|
if (ownRect && homeEdge && homeHit && !tiles.some((t) => t.order === 0))
|
|
3466
3574
|
tiles.push({ edge: homeEdge.id, spec: null, edgeKind: edgeKindOf(state, homeEdge), vertical: axisOf(homeEdge.side) === "column", zone: zoneOf(item), order: 0, kind: "home", id: targetId({ kind: "home", item: dragged }), priority: 1, place: { kind: "home" }, hit: homeHit, keep: null });
|
|
3467
|
-
const placed = clipTiles(tiles, own, keepClearFor(state, "targets"), lost);
|
|
3575
|
+
const placed = clipTiles(tiles, own, keepClearFor(state, now, "targets"), lost);
|
|
3468
3576
|
const { targets: targets2, refused, ownHome } = emit2(c, placed);
|
|
3469
3577
|
const homeAfter = () => ({ state, layout: now });
|
|
3470
3578
|
if (state.floatKinds.includes(item.kind)) {
|
|
@@ -3483,15 +3591,27 @@ function generateShown(state, dragged, options, hidden) {
|
|
|
3483
3591
|
place: { kind: "float" },
|
|
3484
3592
|
after(point, grab) {
|
|
3485
3593
|
const g = grab ?? { x: size.width / 2, y: size.height / 2 };
|
|
3486
|
-
const raw = options.floatFromHeld ? heldRect(state, dragged, size, point, g) :
|
|
3594
|
+
const raw = options.floatFromHeld ? heldRect(state, dragged, size, point, g) : rect18(point.x - g.x, point.y - g.y, size.width, size.height);
|
|
3487
3595
|
const first = solve(markUsed(floatAt(state, dragged, raw, options.floatOrient), dragged), prev);
|
|
3488
|
-
const
|
|
3489
|
-
|
|
3596
|
+
const fitted = first.items[dragged]?.rect;
|
|
3597
|
+
const at = fitted ?? raw;
|
|
3598
|
+
const placed2 = (x, y, stays) => {
|
|
3599
|
+
const s = floatAt(state, dragged, rect18(x, y, size.width, size.height), options.floatOrient);
|
|
3600
|
+
return c.settle(markUsed(stays ? { ...s, floats: s.floats.map((f) => f.id === dragged ? { ...f, stays: true } : f) } : s, dragged));
|
|
3601
|
+
};
|
|
3602
|
+
const hand = heldRect(state, dragged, fitted ?? size, point, g);
|
|
3603
|
+
const on = { x: clamp2(point.x, hand.x, hand.x + hand.width), y: clamp2(point.y, hand.y, hand.y + hand.height) };
|
|
3604
|
+
const clear = !first.notes.some((n) => n.code === "float-covers" && n.id === dragged);
|
|
3605
|
+
if (!fitted || clear && contains(fitted, on)) return placed2(at.x, at.y, false);
|
|
3606
|
+
const left = placed2(hand.x, hand.y, true);
|
|
3607
|
+
const covers = left.layout.notes.some((n) => n.code === "float-covers" && n.id === dragged);
|
|
3608
|
+
const kept = left.layout.items[dragged]?.rect ?? hand;
|
|
3609
|
+
return covers ? left : placed2(kept.x, kept.y, false);
|
|
3490
3610
|
}
|
|
3491
3611
|
});
|
|
3492
3612
|
}
|
|
3493
3613
|
(state.blocked ?? []).forEach((b, i) => {
|
|
3494
|
-
targets2.push({ id: targetId({ kind: "none", index: i }), priority: 1, hit:
|
|
3614
|
+
targets2.push({ id: targetId({ kind: "none", index: i }), priority: 1, hit: rect18(b.x, b.y, b.width, b.height), item: dragged, place: { kind: "none" }, after: homeAfter });
|
|
3495
3615
|
});
|
|
3496
3616
|
const sameAsHome = targets2.filter((t) => t.place.kind === "home" && parseTargetId(t.id)?.kind === "column");
|
|
3497
3617
|
const homePieces = sameAsHome.flatMap((t) => t.hits ?? [t.hit]);
|
|
@@ -3514,7 +3634,7 @@ function generateShown(state, dragged, options, hidden) {
|
|
|
3514
3634
|
const held = withMinHit(c, layered.targets, layered.refusals, zones).map((t) => t.roomHit && t.slot ? { ...t, roomHit: hull(t.hit, t.slot) } : t);
|
|
3515
3635
|
return { targets: held, refusals: layered.refusals.map((r) => ({ ...r, bounds })), lost: lostIds, zones };
|
|
3516
3636
|
}
|
|
3517
|
-
var stageOf = (state) =>
|
|
3637
|
+
var stageOf = (state) => rect18(state.stage.x, state.stage.y, state.stage.width, state.stage.height);
|
|
3518
3638
|
function targets(state, dragged, options = {}) {
|
|
3519
3639
|
return generate(state, dragged, options).targets;
|
|
3520
3640
|
}
|
|
@@ -3573,7 +3693,8 @@ function orderedStops(state, dragged, options) {
|
|
|
3573
3693
|
}
|
|
3574
3694
|
|
|
3575
3695
|
// src/lanes.ts
|
|
3576
|
-
import { EPS as EPS21, clamp as
|
|
3696
|
+
import { EPS as EPS21, area as area7, clamp as clamp3, rect as rect19, subtract as subtract6 } from "@n-uf/placement";
|
|
3697
|
+
import { itemSteps as itemSteps6 } from "@n-uf/placement/stack";
|
|
3577
3698
|
var SPOT_PITCH = 40;
|
|
3578
3699
|
var SNAP_DISTANCE = 8;
|
|
3579
3700
|
var STEP = 1;
|
|
@@ -3583,7 +3704,7 @@ var len = (r, axis) => axis === "x" ? r.width : r.height;
|
|
|
3583
3704
|
var hull2 = (a, b) => {
|
|
3584
3705
|
const x = Math.min(a.x, b.x);
|
|
3585
3706
|
const y = Math.min(a.y, b.y);
|
|
3586
|
-
return
|
|
3707
|
+
return rect19(x, y, Math.max(a.x + a.width, b.x + b.width) - x, Math.max(a.y + a.height, b.y + b.height) - y);
|
|
3587
3708
|
};
|
|
3588
3709
|
var nonNeg = (v) => Number.isFinite(v) && v > 0 ? v : 0;
|
|
3589
3710
|
var sameRect = (a, b) => Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y), Math.abs(a.width - b.width), Math.abs(a.height - b.height)) < 0.5;
|
|
@@ -3737,19 +3858,22 @@ function build(state, dragged, options) {
|
|
|
3737
3858
|
gap: (edge) => nonNeg(state.edges.find((e) => e.id === edge)?.gap),
|
|
3738
3859
|
crossing: (edge, over2) => state.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over2.edges[e.id]?.cross ?? 0) > EPS21 && axisOfEdge(e.id) !== axisOfEdge(edge)).map((e) => over2.edges[e.id].rect)
|
|
3739
3860
|
};
|
|
3740
|
-
const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <= EPS21 ? 0.5 :
|
|
3861
|
+
const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <= EPS21 ? 0.5 : clamp3(g / size, 0, 1);
|
|
3741
3862
|
const w = own?.rect.width ?? 0;
|
|
3742
3863
|
const h = own?.rect.height ?? 0;
|
|
3743
3864
|
const share = { x: w >= h ? shareOf(options.grab?.x, w) : 0.5, y: h > w ? shareOf(options.grab?.y, h) : 0.5 };
|
|
3744
3865
|
const built = [...byLane].map(([id, list]) => laneFrom(id, list, seen, seen, dragged, rs, halves.has(id), share, marking)).filter((l) => !!l);
|
|
3745
|
-
const laneList = newColumnsGiveWay(built.map((l) => settle(l, seen, state, dragged, built, options.emptyLanes)), (l) => l.id, state);
|
|
3866
|
+
const laneList = newColumnsGiveWay(built.map((l) => settle(l, seen, state, dragged, built, options.emptyLanes)), (l) => l.id, state).map((l) => clearOfRail(l, seen, byLane.get(l.id)));
|
|
3746
3867
|
const onLanes = new Set(laneList.map((l) => l.id));
|
|
3747
3868
|
const rails = Object.values(seen.rails).flatMap((r) => r && r.rect.width > EPS21 && r.rect.height > EPS21 ? [r.rect] : []);
|
|
3748
3869
|
const blocked = [
|
|
3749
3870
|
...Object.values(seen.edges).filter((e) => e.cross > EPS21).map((e) => e.rect),
|
|
3750
3871
|
...Object.entries(seen.items).filter(([id, it]) => id !== dragged && !it.floating && !it.inMenu).map(([, it]) => it.rect),
|
|
3751
|
-
...keepClearFor(state, "targets"),
|
|
3872
|
+
...keepClearFor(state, seen, "targets"),
|
|
3752
3873
|
...rails,
|
|
3874
|
+
// A held tile's own rail: every stop is home's in `targets()`, with the new-column lines about its folded column
|
|
3875
|
+
// joined to it (the strip beside the rail). A home place takes no float, so it is blocked as `targets()` has it.
|
|
3876
|
+
...own?.rail ? ts.filter((t) => t.place.kind === "home" && parseTargetId(t.id)?.kind === "rail").flatMap((t) => t.hits ?? [t.hit]) : [],
|
|
3753
3877
|
// Spots where a release cancels (`DockState.blocked`): no float lands there.
|
|
3754
3878
|
...state.blocked ?? []
|
|
3755
3879
|
];
|
|
@@ -3773,6 +3897,15 @@ function build(state, dragged, options) {
|
|
|
3773
3897
|
}
|
|
3774
3898
|
};
|
|
3775
3899
|
}
|
|
3900
|
+
function clearOfRail(lane, seen, raws) {
|
|
3901
|
+
const place = raws?.[0]?.target.place;
|
|
3902
|
+
const rail = place?.kind === "column" ? seen.rails[place.side] : void 0;
|
|
3903
|
+
if (!rail || rail.segments.length === 0) return lane;
|
|
3904
|
+
const pieces = subtract6(lane.rect, rail.rect);
|
|
3905
|
+
if (pieces.length === 0) return lane;
|
|
3906
|
+
const largest4 = pieces.reduce((m, p) => area7(p) > area7(m) ? p : m);
|
|
3907
|
+
return largest4 === lane.rect ? lane : { ...lane, rect: largest4 };
|
|
3908
|
+
}
|
|
3776
3909
|
function laneRectOver(list, over2, marking) {
|
|
3777
3910
|
const first = list[0];
|
|
3778
3911
|
const axis = first.axis;
|
|
@@ -3781,7 +3914,7 @@ function laneRectOver(list, over2, marking) {
|
|
|
3781
3914
|
if (!edgeLayout) return { rect: list.every((r) => r.strip) ? list.map((r) => r.hit).reduce(hull2) : list.map((r) => r.hit).reduce(hull2, band) };
|
|
3782
3915
|
const drawnAt = drawnRect(over2, first.edge);
|
|
3783
3916
|
if (drawnAt) return { rect: drawnAt };
|
|
3784
|
-
const whole = axis === "x" ?
|
|
3917
|
+
const whole = axis === "x" ? rect19(edgeLayout.rect.x, band.y, edgeLayout.rect.width, band.height) : rect19(band.x, edgeLayout.rect.y, band.width, edgeLayout.rect.height);
|
|
3785
3918
|
return { rect: clipAtDrawn(whole, axis, marking.crossing(first.edge, over2)), band: whole };
|
|
3786
3919
|
}
|
|
3787
3920
|
function drawnIn(layout, id) {
|
|
@@ -3830,14 +3963,14 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, sh
|
|
|
3830
3963
|
const across2 = (aEnd + lo(bLanding, axis)) / 2;
|
|
3831
3964
|
const overlap = lo(bLanding, axis) < aEnd - EPS21;
|
|
3832
3965
|
const slack = Math.max(0, marking.pitch) / 2;
|
|
3833
|
-
const atGrab =
|
|
3966
|
+
const atGrab = clamp3(across2 + (held - 0.5) * (len(aLanding, axis) + len(bLanding, axis)) / 2, lo(bLanding, axis) - slack, aEnd + slack);
|
|
3834
3967
|
const raw = shared ? mid(shared, axis) : overlap ? atGrab : across2;
|
|
3835
|
-
cuts.push(
|
|
3968
|
+
cuts.push(clamp3(Math.max(raw, cuts[i - 1] ?? bandStart), bandStart, bandEnd));
|
|
3836
3969
|
}
|
|
3837
3970
|
const spots = unique.flatMap((x, i) => {
|
|
3838
3971
|
const a = i === 0 ? bandStart : cuts[i - 1];
|
|
3839
3972
|
const b = i === unique.length - 1 ? bandEnd : cuts[i];
|
|
3840
|
-
const along2 = [
|
|
3973
|
+
const along2 = [clamp3(a, start, end), clamp3(b, start, end)];
|
|
3841
3974
|
return along2[1] - along2[0] > EPS21 || b - a <= EPS21 || x.home ? [{ x, along: along2 }] : [];
|
|
3842
3975
|
}).map(({ x, along: along2 }) => ({
|
|
3843
3976
|
id: x.id,
|
|
@@ -3850,7 +3983,7 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, sh
|
|
|
3850
3983
|
others: othersKey(x.layout, dragged)
|
|
3851
3984
|
}));
|
|
3852
3985
|
const itemLen = Math.min(...unique.map((x) => len(x.landing, axis)));
|
|
3853
|
-
const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [
|
|
3986
|
+
const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp3(lo(h, axis), start, end), clamp3(lo(h, axis) + len(h, axis), start, end)], reason: f.reason }))).filter((f) => f.along[1] - f.along[0] >= itemLen - EPS21) : [];
|
|
3854
3987
|
const places = new Set(unique.map((x) => `${x.before}|${x.next}`));
|
|
3855
3988
|
const drawnEdge = first.edge ? drawn.edges[first.edge] : void 0;
|
|
3856
3989
|
const markRect = (first.edge ? drawnRect(drawn, first.edge) : void 0) ?? laneRectOver(list, drawn, marking).band ?? markBand ?? laneRect;
|
|
@@ -3875,7 +4008,7 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, sh
|
|
|
3875
4008
|
}) : virtualMarks(id, unique, drawn.items[dragged]);
|
|
3876
4009
|
return { id, rect: laneRect, axis, spots, refused, marks, ...list.every((r) => r.strip) ? { owns: true } : {} };
|
|
3877
4010
|
}
|
|
3878
|
-
var along = (r, axis, a, b) => axis === "x" ?
|
|
4011
|
+
var along = (r, axis, a, b) => axis === "x" ? rect19(a, r.y, b - a, r.height) : rect19(r.x, a, r.width, b - a);
|
|
3879
4012
|
var LINE2 = 2;
|
|
3880
4013
|
var MIN_BOX = 8;
|
|
3881
4014
|
var HATCH_END = 8;
|
|
@@ -3894,8 +4027,8 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
3894
4027
|
const ends = [{ id: "^", a: start, b: start }, ...items.map((o) => ({ id: o.id, a: lo(o.r, axis), b: lo(o.r, axis) + len(o.r, axis) })), { id: "$", a: end, b: end }];
|
|
3895
4028
|
const isRefused2 = (v) => refused.some((f) => v >= f.along[0] && v <= f.along[1]);
|
|
3896
4029
|
for (let i = 0; i + 1 < ends.length; i++) {
|
|
3897
|
-
const a =
|
|
3898
|
-
const b =
|
|
4030
|
+
const a = clamp3(ends[i].b, start, end);
|
|
4031
|
+
const b = clamp3(ends[i + 1].a, start, end);
|
|
3899
4032
|
const pair = `${ends[i].id}|${ends[i + 1].id}`;
|
|
3900
4033
|
if (ends[i + 1].a < start - EPS21 || ends[i].b > end + EPS21 || !lands(pair)) continue;
|
|
3901
4034
|
const left = ends[i].id === held ? ends[i - 1]?.id ?? "^" : ends[i].id;
|
|
@@ -3937,9 +4070,9 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
3937
4070
|
function virtualMarks(lane, spots, held) {
|
|
3938
4071
|
return spots.map((s) => {
|
|
3939
4072
|
const l = s.landing;
|
|
3940
|
-
if (!held || held.floating || !
|
|
4073
|
+
if (!held || held.floating || !overlaps8(l, held.rect)) return { id: `${lane}/box/${s.id}`, kind: "box", rect: l };
|
|
3941
4074
|
const x = mid(held.rect, "x") < mid(l, "x") ? l.x + l.width : l.x;
|
|
3942
|
-
return { id: `${lane}/line/${s.id}`, kind: "line", rect:
|
|
4075
|
+
return { id: `${lane}/line/${s.id}`, kind: "line", rect: rect19(x, l.y, 0, l.height) };
|
|
3943
4076
|
});
|
|
3944
4077
|
}
|
|
3945
4078
|
function inLane(l, r) {
|
|
@@ -3950,7 +4083,7 @@ function inLane(l, r) {
|
|
|
3950
4083
|
const y1 = Math.min(m.rect.y + m.rect.height, r.y + r.height);
|
|
3951
4084
|
if (m.kind === "line") return x1 - x0 >= m.rect.width - EPS21 && y1 - y0 >= m.rect.height - EPS21 ? [m] : [];
|
|
3952
4085
|
if (x1 - x0 <= EPS21 || y1 - y0 <= EPS21) return [];
|
|
3953
|
-
return x1 - x0 >= m.rect.width - EPS21 && y1 - y0 >= m.rect.height - EPS21 ? [m] : [{ ...m, rect:
|
|
4086
|
+
return x1 - x0 >= m.rect.width - EPS21 && y1 - y0 >= m.rect.height - EPS21 ? [m] : [{ ...m, rect: rect19(x0, y0, x1 - x0, y1 - y0) }];
|
|
3954
4087
|
});
|
|
3955
4088
|
return marks.length === l.marks.length && marks.every((m, i) => m === l.marks[i]) ? l : { ...l, marks };
|
|
3956
4089
|
}
|
|
@@ -3975,7 +4108,7 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
|
|
|
3975
4108
|
return !!e && (e.side === "top" || e.side === "bottom" || !!e.compact);
|
|
3976
4109
|
};
|
|
3977
4110
|
const stays = empty ? Object.entries(drawn.items).filter(([id, it]) => id !== dragged && it.edge !== l.id && barOrRail(it.edge) && !it.floating && !it.inMenu && it.rect.width > EPS21 && it.rect.height > EPS21).map(([, it]) => it.rect) : [];
|
|
3978
|
-
if (cuts.length === 0 && !(empty && (emptyLanes === "edge" || l.marks.some((m) => m.kind === "box" && stays.some((s) =>
|
|
4111
|
+
if (cuts.length === 0 && !(empty && (emptyLanes === "edge" || l.marks.some((m) => m.kind === "box" && stays.some((s) => overlaps8(m.rect, s)))))) return l;
|
|
3979
4112
|
const cut2 = (r, cs) => piecesLess(r, l.axis, cs);
|
|
3980
4113
|
const marks = [];
|
|
3981
4114
|
for (const m of l.marks) {
|
|
@@ -3994,11 +4127,11 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
|
|
|
3994
4127
|
if (l.axis === "y") {
|
|
3995
4128
|
const outerRight = side === "right" ? true : side === "left" ? false : Math.abs(piece.x + piece.width - (st.x + st.width)) <= Math.abs(piece.x - st.x);
|
|
3996
4129
|
const t = Math.min(HATCH_EDGE, piece.width);
|
|
3997
|
-
r =
|
|
4130
|
+
r = rect19(outerRight ? piece.x + piece.width - t : piece.x, piece.y, t, piece.height);
|
|
3998
4131
|
} else {
|
|
3999
4132
|
const outerBottom = side === "bottom" ? true : side === "top" ? false : Math.abs(piece.y + piece.height - (st.y + st.height)) <= Math.abs(piece.y - st.y);
|
|
4000
4133
|
const t = Math.min(HATCH_EDGE, piece.height);
|
|
4001
|
-
r =
|
|
4134
|
+
r = rect19(piece.x, outerBottom ? piece.y + piece.height - t : piece.y, piece.width, t);
|
|
4002
4135
|
}
|
|
4003
4136
|
marks.push({ id: id.replace("/box/", "/hatch/"), kind: "hatch", rect: r });
|
|
4004
4137
|
});
|
|
@@ -4020,14 +4153,14 @@ function marksLess(marks, axis, cs, options = {}) {
|
|
|
4020
4153
|
const suffix = options.suffix ?? "~c";
|
|
4021
4154
|
const minBox = options.minBox ?? 0;
|
|
4022
4155
|
return marks.flatMap((m) => {
|
|
4023
|
-
const over2 = cs.filter((c) =>
|
|
4156
|
+
const over2 = cs.filter((c) => overlaps8(m.rect, c));
|
|
4024
4157
|
if (over2.length === 0) return [m];
|
|
4025
4158
|
const kept = piecesLess(m.rect, axis, over2);
|
|
4026
4159
|
if (m.kind === "line") return (options.lines === "covered" ? kept.length > 0 : kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, axis)) < EPS21) ? [m] : [];
|
|
4027
4160
|
return kept.filter(([p, q]) => m.kind !== "box" || q - p > minBox).map(([p, q], i) => ({ ...m, id: i ? `${m.id}${suffix}${i}` : m.id, rect: along(m.rect, axis, p, q) }));
|
|
4028
4161
|
});
|
|
4029
4162
|
}
|
|
4030
|
-
var
|
|
4163
|
+
var overlaps8 = (a, b) => a.x < b.x + b.width - EPS21 && b.x < a.x + a.width - EPS21 && a.y < b.y + b.height - EPS21 && b.y < a.y + a.height - EPS21;
|
|
4031
4164
|
function pitchedSpots(state, dragged, options, seen, lifted, raws, pitch) {
|
|
4032
4165
|
const out = [];
|
|
4033
4166
|
stretches(state, dragged, options, seen, lifted, raws, (run) => {
|
|
@@ -4166,10 +4299,12 @@ function landsAt(state, dragged, run, place, x0) {
|
|
|
4166
4299
|
const landed = layout.items[dragged];
|
|
4167
4300
|
const { axis } = run;
|
|
4168
4301
|
if (!landed || landed.inMenu || landed.edge !== run.e.id || Math.abs(lo(landed.rect, axis) - x0) > 1) return null;
|
|
4169
|
-
|
|
4170
|
-
const
|
|
4171
|
-
|
|
4172
|
-
|
|
4302
|
+
const kept = (f) => {
|
|
4303
|
+
const it = layout.items[f.id];
|
|
4304
|
+
if (it?.inMenu && itemSteps6(state.items[f.id])) return true;
|
|
4305
|
+
return !!it && Math.abs(lo(it.rect, axis) - lo(f.r, axis)) <= 1;
|
|
4306
|
+
};
|
|
4307
|
+
if (!run.fixed.every(kept)) return null;
|
|
4173
4308
|
return { next, layout };
|
|
4174
4309
|
}
|
|
4175
4310
|
function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
@@ -4251,9 +4386,9 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4251
4386
|
return best;
|
|
4252
4387
|
};
|
|
4253
4388
|
const startAt = (raw) => {
|
|
4254
|
-
const c =
|
|
4389
|
+
const c = clamp3(raw, from, to);
|
|
4255
4390
|
const s = snapped(c);
|
|
4256
|
-
return snaps.includes(s) ? s :
|
|
4391
|
+
return snaps.includes(s) ? s : clamp3(Math.round(c / STEP) * STEP, from, to);
|
|
4257
4392
|
};
|
|
4258
4393
|
const results = /* @__PURE__ */ new Map();
|
|
4259
4394
|
const commitAt = (x0) => {
|
|
@@ -4265,7 +4400,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4265
4400
|
results.set(k, result);
|
|
4266
4401
|
return result;
|
|
4267
4402
|
};
|
|
4268
|
-
const rest = homeRaw ? lo(homeRaw.landing, axis) : ownEdge === e.id && own ? snapped(
|
|
4403
|
+
const rest = homeRaw ? lo(homeRaw.landing, axis) : ownEdge === e.id && own ? snapped(clamp3(lo(own.rect, axis), from, to)) : from;
|
|
4269
4404
|
const restResult = commitAt(rest);
|
|
4270
4405
|
const ownZone = own?.zone;
|
|
4271
4406
|
const restPlace = (() => {
|
|
@@ -4285,7 +4420,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4285
4420
|
place: { kind: "gap", edge: e.id, zone: restPlace?.zone ?? zones[0], at: restPlace?.at ?? atOf(zones[0]), ...restPlace?.space ? { space: restPlace.space } : {} },
|
|
4286
4421
|
after: (point, grab) => {
|
|
4287
4422
|
const g = grab ? grab[long] : ownLen / 2;
|
|
4288
|
-
const share = axis === long && ownLen > EPS21 && Number.isFinite(g) ?
|
|
4423
|
+
const share = axis === long && ownLen > EPS21 && Number.isFinite(g) ? clamp3(g / ownLen, 0, 1) : 0.5;
|
|
4289
4424
|
return commitAt(startAt((axis === "x" ? point.x : point.y) - share * w));
|
|
4290
4425
|
}
|
|
4291
4426
|
};
|
|
@@ -4310,8 +4445,41 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4310
4445
|
}
|
|
4311
4446
|
|
|
4312
4447
|
// src/drag.ts
|
|
4313
|
-
import { EPS as EPS22 } from "@n-uf/placement";
|
|
4448
|
+
import { EPS as EPS22, area as area8, overlaps as overlaps9, subtract as subtract7 } from "@n-uf/placement";
|
|
4314
4449
|
var MIN_PIECE = 8;
|
|
4450
|
+
function trimmedBy(marks, cs) {
|
|
4451
|
+
if (cs.length === 0) return [...marks];
|
|
4452
|
+
return marks.flatMap((m) => {
|
|
4453
|
+
const r = m.rect;
|
|
4454
|
+
if (r.width <= EPS22 || r.height <= EPS22) {
|
|
4455
|
+
const across2 = r.height <= EPS22;
|
|
4456
|
+
const at = across2 ? r.y : r.x;
|
|
4457
|
+
let pieces2 = [across2 ? [r.x, r.x + r.width] : [r.y, r.y + r.height]];
|
|
4458
|
+
let touched = false;
|
|
4459
|
+
for (const c of cs) {
|
|
4460
|
+
const [lo2, hi] = across2 ? [c.y, c.y + c.height] : [c.x, c.x + c.width];
|
|
4461
|
+
if (!(at > lo2 + EPS22 && at < hi - EPS22)) continue;
|
|
4462
|
+
const [a, b] = across2 ? [c.x, c.x + c.width] : [c.y, c.y + c.height];
|
|
4463
|
+
pieces2 = pieces2.flatMap(([s2, e2]) => {
|
|
4464
|
+
if (b <= s2 || a >= e2) return [[s2, e2]];
|
|
4465
|
+
touched = true;
|
|
4466
|
+
return [...a > s2 ? [[s2, a]] : [], ...b < e2 ? [[b, e2]] : []];
|
|
4467
|
+
});
|
|
4468
|
+
}
|
|
4469
|
+
if (!touched) return [m];
|
|
4470
|
+
const kept = pieces2.filter(([s2, e2]) => e2 - s2 >= 1);
|
|
4471
|
+
if (kept.length === 0) return [];
|
|
4472
|
+
const [s, e] = kept.reduce((x, y) => y[1] - y[0] > x[1] - x[0] ? y : x);
|
|
4473
|
+
if (Math.abs(s - (across2 ? r.x : r.y)) < EPS22 && Math.abs(e - s - (across2 ? r.width : r.height)) < EPS22) return [m];
|
|
4474
|
+
return [{ ...m, rect: across2 ? { x: s, y: r.y, width: e - s, height: r.height } : { x: r.x, y: s, width: r.width, height: e - s } }];
|
|
4475
|
+
}
|
|
4476
|
+
const over2 = cs.filter((c) => overlaps9(m.rect, c));
|
|
4477
|
+
if (over2.length === 0) return [m];
|
|
4478
|
+
const pieces = over2.reduce((ps, c) => ps.flatMap((p) => subtract7(p, c)), [m.rect]).filter((p) => p.width >= 1 && p.height >= 1);
|
|
4479
|
+
if (pieces.length === 0) return [];
|
|
4480
|
+
return [{ ...m, rect: pieces.reduce((a, p) => area8(p) > area8(a) ? p : a) }];
|
|
4481
|
+
});
|
|
4482
|
+
}
|
|
4315
4483
|
var ORIGIN2 = { x: 0, y: 0 };
|
|
4316
4484
|
function dockDrag(state, dragged, options = {}) {
|
|
4317
4485
|
const base = baseOf(state, dragged, options);
|
|
@@ -4374,6 +4542,7 @@ function dockDrag(state, dragged, options = {}) {
|
|
|
4374
4542
|
if (frame.guides.length === 0) return [];
|
|
4375
4543
|
const held = after(frame.held);
|
|
4376
4544
|
const screen = screenOf(frame);
|
|
4545
|
+
const screenClear = (screen.layout.keepClear ?? []).filter((c) => c.for !== "floats").map((c) => c.rect);
|
|
4377
4546
|
let near = null;
|
|
4378
4547
|
const shown = [];
|
|
4379
4548
|
const drawnThere = (id) => drawnIn(screen.layout, id);
|
|
@@ -4389,7 +4558,8 @@ function dockDrag(state, dragged, options = {}) {
|
|
|
4389
4558
|
const onScreen2 = drawnThere(g.lane);
|
|
4390
4559
|
const axis2 = axisOf2.get(g.lane) ?? "x";
|
|
4391
4560
|
const own = screen.marks.filter((m) => m.lane === g.lane);
|
|
4392
|
-
const
|
|
4561
|
+
const predicted = mine.marks.filter((m) => m.lane === g.lane);
|
|
4562
|
+
const marks = onScreen2 ? mine.landing ? marksLess(own, axis2, [mine.landing], { suffix: "~l", minBox: MIN_PIECE, lines: "covered" }) : own : trimmedBy(predicted, screenClear);
|
|
4393
4563
|
near = { lane: g.lane, marks };
|
|
4394
4564
|
shown.push(near);
|
|
4395
4565
|
}
|
|
@@ -4402,14 +4572,15 @@ function dockDrag(state, dragged, options = {}) {
|
|
|
4402
4572
|
const made = shown.filter((s) => s.created).sort((a, b) => axis(a.lane) === axis(b.lane) ? 0 : axis(a.lane) === "x" ? -1 : 1);
|
|
4403
4573
|
const kept = [];
|
|
4404
4574
|
for (const s of made) {
|
|
4405
|
-
s.marks = marksLess(s.marks, axis(s.lane), [...onScreen, ...kept]);
|
|
4575
|
+
s.marks = marksLess(trimmedBy(s.marks, screenClear), axis(s.lane), [...onScreen, ...kept]);
|
|
4406
4576
|
kept.push(...s.marks.map((m) => m.rect));
|
|
4407
4577
|
}
|
|
4408
4578
|
if (!near) return shown.flatMap((s) => s.marks);
|
|
4409
4579
|
const cut2 = near.marks.map((m) => m.rect);
|
|
4410
4580
|
return shown.flatMap((s) => s === near ? s.marks : marksLess(s.marks, axis(s.lane), cut2));
|
|
4411
4581
|
};
|
|
4412
|
-
|
|
4582
|
+
const home = base.lanes.flatMap((l) => l.spots.filter((s) => s.home).map((s) => ({ lane: l.id, spot: s.id })))[0];
|
|
4583
|
+
return { regions, ...home ? { home } : {}, after, landingOf, spotsOf, shown: shownLayout, guides };
|
|
4413
4584
|
}
|
|
4414
4585
|
|
|
4415
4586
|
export {
|
|
@@ -4430,6 +4601,7 @@ export {
|
|
|
4430
4601
|
zonesTaking,
|
|
4431
4602
|
edgeTakes,
|
|
4432
4603
|
railModeOf,
|
|
4604
|
+
isAnchoredKeepClear,
|
|
4433
4605
|
zoneIn,
|
|
4434
4606
|
namesZone,
|
|
4435
4607
|
isOutsideSideBar,
|
|
@@ -4479,4 +4651,4 @@ export {
|
|
|
4479
4651
|
HATCH_EDGE,
|
|
4480
4652
|
dockDrag
|
|
4481
4653
|
};
|
|
4482
|
-
//# sourceMappingURL=chunk-
|
|
4654
|
+
//# sourceMappingURL=chunk-JBKUC72Z.js.map
|