@n-uf/docking 26.11.64 → 26.12.1
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 +19 -0
- package/dist/{chunk-AX6OK7XQ.js → chunk-GWRE7UD7.js} +145 -121
- package/dist/chunk-GWRE7UD7.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-AX6OK7XQ.js.map +0 -1
|
@@ -2183,7 +2183,7 @@ function read(data, base) {
|
|
|
2183
2183
|
}
|
|
2184
2184
|
|
|
2185
2185
|
// src/targets.ts
|
|
2186
|
-
import { EPS as
|
|
2186
|
+
import { EPS as EPS24, PLANE, area as area6, clamp as clamp4, contains, overlaps as overlaps7, rect as rect19 } from "@n-uf/placement";
|
|
2187
2187
|
|
|
2188
2188
|
// src/grab.ts
|
|
2189
2189
|
import { EPS as EPS12, clamp as clamp2 } from "@n-uf/placement";
|
|
@@ -2412,6 +2412,7 @@ function landedLayout(state, l, dragged, prev) {
|
|
|
2412
2412
|
if (!it || it.fixed || it.inMenu || it.floating || !it.edge) return l;
|
|
2413
2413
|
const e = state.edges.find((x) => x.id === it.edge);
|
|
2414
2414
|
if (!e || !growsOnBar(state, e, dragged, it.form)) return l;
|
|
2415
|
+
if (l.notes.some((n) => "edge" in n && n.code === "overflow" && n.edge === e.id)) return l;
|
|
2415
2416
|
return solve(withoutBarGrowth(state, dragged), prev);
|
|
2416
2417
|
}
|
|
2417
2418
|
var solveLanded = (state, dragged, prev) => solve(withoutBarGrowth(state, dragged), prev);
|
|
@@ -2502,7 +2503,7 @@ function edgeSlots(c, edge, accepts) {
|
|
|
2502
2503
|
return me.edge === edge.id && !me.inMenu;
|
|
2503
2504
|
};
|
|
2504
2505
|
const pad = { start: Math.max(0, edge.pad?.start ?? 0), end: Math.max(0, edge.pad?.end ?? 0) };
|
|
2505
|
-
const
|
|
2506
|
+
const endLine = el.menu ? at(el.menu.rect) : main0 + length - pad.end;
|
|
2506
2507
|
const occupied = (id) => c.room.items[id]?.fixed ? reservedRect(state, c.room, id) : c.room.items[id].rect;
|
|
2507
2508
|
const shown = (id) => now.items[id]?.edge === edge.id && !now.items[id].inMenu;
|
|
2508
2509
|
const drawnOf2 = (z) => members0.filter((id) => zoneOf(rest.items[id]) === z && shown(id)).map(occupied);
|
|
@@ -2512,9 +2513,9 @@ function edgeSlots(c, edge, accepts) {
|
|
|
2512
2513
|
})();
|
|
2513
2514
|
const endStart = (() => {
|
|
2514
2515
|
const e = drawnOf2("end");
|
|
2515
|
-
return e.length ? at(e[0]) :
|
|
2516
|
+
return e.length ? at(e[0]) : endLine;
|
|
2516
2517
|
})();
|
|
2517
|
-
const anchorLine = { start: main0 + pad.start, center: Math.min(Math.max(main0 + length / 2, startEnd), Math.max(startEnd, endStart)), end:
|
|
2518
|
+
const anchorLine = { start: main0 + pad.start, center: Math.min(Math.max(main0 + length / 2, startEnd), Math.max(startEnd, endStart)), end: endLine };
|
|
2518
2519
|
const slots = [];
|
|
2519
2520
|
const aimed = (id) => shown(id) && !now.items[id].fixed;
|
|
2520
2521
|
let earlier = 0;
|
|
@@ -2631,7 +2632,7 @@ function railColumnSpec(c, edge, run) {
|
|
|
2631
2632
|
}
|
|
2632
2633
|
|
|
2633
2634
|
// src/targets/filter.ts
|
|
2634
|
-
import { overlaps as overlaps2 } from "@n-uf/placement";
|
|
2635
|
+
import { EPS as EPS15, overlaps as overlaps2 } from "@n-uf/placement";
|
|
2635
2636
|
import { formMain as formMain2, itemSteps as itemSteps4 } from "@n-uf/placement/stack";
|
|
2636
2637
|
function placeKey(s, id) {
|
|
2637
2638
|
const it = Object.hasOwn(s.items, id) ? s.items[id] : void 0;
|
|
@@ -2644,14 +2645,21 @@ function placeKey(s, id) {
|
|
|
2644
2645
|
});
|
|
2645
2646
|
}
|
|
2646
2647
|
function soundness(state, base, dragged) {
|
|
2647
|
-
const
|
|
2648
|
-
const
|
|
2648
|
+
const tooWide = (n) => "edge" in n && n.code === "too-wide" ? `${n.edge}:${"id" in n ? n.id : ""}` : null;
|
|
2649
|
+
const hadWide = new Set(base.notes.map(tooWide).filter((k) => k !== null));
|
|
2650
|
+
const overOf = (l) => {
|
|
2651
|
+
const m = /* @__PURE__ */ new Map();
|
|
2652
|
+
for (const n of l.notes) if ("edge" in n && n.code === "overflow") m.set(n.edge, (m.get(n.edge) ?? 0) + n.over);
|
|
2653
|
+
return m;
|
|
2654
|
+
};
|
|
2655
|
+
const overBefore = overOf(base);
|
|
2649
2656
|
const chrome = keepClearFor(state, {}, "targets");
|
|
2650
2657
|
return (after) => {
|
|
2651
2658
|
if (after.notes.some((n) => {
|
|
2652
|
-
const k =
|
|
2653
|
-
return k !== null && !
|
|
2659
|
+
const k = tooWide(n);
|
|
2660
|
+
return k !== null && !hadWide.has(k);
|
|
2654
2661
|
})) return false;
|
|
2662
|
+
for (const [edge, over2] of overOf(after)) if (over2 > (overBefore.get(edge) ?? 0) + EPS15) return false;
|
|
2655
2663
|
for (const [id, b] of Object.entries(base.items)) {
|
|
2656
2664
|
if (!b.fixed) continue;
|
|
2657
2665
|
const a = after.items[id];
|
|
@@ -2663,7 +2671,9 @@ function soundness(state, base, dragged) {
|
|
|
2663
2671
|
const f = formsOf(state.items[id], axisOf(e.side))[a.form];
|
|
2664
2672
|
const len2 = axisOf(e.side) === "column" ? a.rect.height : a.rect.width;
|
|
2665
2673
|
const holds = !steps && f?.main.grows === true;
|
|
2666
|
-
|
|
2674
|
+
const be = b.edge === a.edge && !b.inMenu ? base.edges[b.edge] : void 0;
|
|
2675
|
+
const had = be ? axisOf(be.side) === "column" ? b.rect.height : b.rect.width : Infinity;
|
|
2676
|
+
if (f && len2 < Math.min(formMain2(f, holds ? "natural" : "min", e.cross), had) - 0.5) return false;
|
|
2667
2677
|
}
|
|
2668
2678
|
const me = after.items[dragged];
|
|
2669
2679
|
if (!me) return true;
|
|
@@ -2677,8 +2687,21 @@ function roomOf2(state, now, prev) {
|
|
|
2677
2687
|
return plain === state ? now : solve(plain, prev);
|
|
2678
2688
|
}
|
|
2679
2689
|
function liftIn(state, now, dragged, prev) {
|
|
2680
|
-
const
|
|
2681
|
-
|
|
2690
|
+
const landed = landedLayout(state, now, dragged, prev);
|
|
2691
|
+
const own = landed.items[dragged];
|
|
2692
|
+
return { own, lift: liftOf(state, now, dragged, heldRect2(state, landed, dragged)) };
|
|
2693
|
+
}
|
|
2694
|
+
function heldRect2(state, l, dragged) {
|
|
2695
|
+
const laid2 = l.items[dragged];
|
|
2696
|
+
const edge = laid2?.edge && !laid2.inMenu && !laid2.floating ? state.edges.find((x) => x.id === laid2.edge) : void 0;
|
|
2697
|
+
const e = edge ? l.edges[edge.id] : void 0;
|
|
2698
|
+
const f = e ? formsOf(state.items[dragged], axisOf(e.side))[laid2.form] : void 0;
|
|
2699
|
+
if (!laid2 || !edge || !e || !f) return laid2?.rect;
|
|
2700
|
+
const column = axisOf(e.side) === "column";
|
|
2701
|
+
const least = formMain2(f, "min", e.cross);
|
|
2702
|
+
if ((column ? laid2.rect.height : laid2.rect.width) >= least - EPS15) return laid2.rect;
|
|
2703
|
+
const held = Math.max(least, growsOnBar(state, edge, dragged, laid2.form) ? formMain2(f, "natural", e.cross) : least);
|
|
2704
|
+
return column ? { ...laid2.rect, height: held } : { ...laid2.rect, width: held };
|
|
2682
2705
|
}
|
|
2683
2706
|
function context(state, dragged, options, others = []) {
|
|
2684
2707
|
const item = Object.hasOwn(state.items, dragged) ? state.items[dragged] : void 0;
|
|
@@ -2715,22 +2738,22 @@ function context(state, dragged, options, others = []) {
|
|
|
2715
2738
|
}
|
|
2716
2739
|
|
|
2717
2740
|
// src/targets/meet.ts
|
|
2718
|
-
import { EPS as
|
|
2741
|
+
import { EPS as EPS16, rect as rect12 } from "@n-uf/placement";
|
|
2719
2742
|
function meet(a, b) {
|
|
2720
2743
|
const x = Math.max(a.x, b.x);
|
|
2721
2744
|
const y = Math.max(a.y, b.y);
|
|
2722
2745
|
const w = Math.min(a.x + a.width, b.x + b.width) - x;
|
|
2723
2746
|
const h = Math.min(a.y + a.height, b.y + b.height) - y;
|
|
2724
|
-
return w >
|
|
2747
|
+
return w > EPS16 && h > EPS16 ? rect12(x, y, w, h) : null;
|
|
2725
2748
|
}
|
|
2726
2749
|
|
|
2727
2750
|
// src/targets/ownership.ts
|
|
2728
|
-
import { EPS as
|
|
2751
|
+
import { EPS as EPS18, area as area3, overlaps as overlaps3, rect as rect13, subtract as subtract2 } from "@n-uf/placement";
|
|
2729
2752
|
import { formBody as formBody2, itemSteps as itemSteps5 } from "@n-uf/placement/stack";
|
|
2730
2753
|
|
|
2731
2754
|
// src/targets/model.ts
|
|
2732
|
-
import { EPS as
|
|
2733
|
-
var less = (spans, away) => away.reduce((acc, [ra, rb]) => acc.flatMap(([a, b]) => rb <= a || ra >= b ? [[a, b]] : [[a, Math.max(a, ra)], [Math.min(b, rb), b]].filter(([u, w]) => w - u >
|
|
2755
|
+
import { EPS as EPS17 } from "@n-uf/placement";
|
|
2756
|
+
var less = (spans, away) => away.reduce((acc, [ra, rb]) => acc.flatMap(([a, b]) => rb <= a || ra >= b ? [[a, b]] : [[a, Math.max(a, ra)], [Math.min(b, rb), b]].filter(([u, w]) => w - u > EPS17)), [...spans]);
|
|
2734
2757
|
|
|
2735
2758
|
// src/targets/ownership.ts
|
|
2736
2759
|
var isBody = (f) => !!f && formBody2(f);
|
|
@@ -2752,10 +2775,10 @@ function ownedRectsOf(s, along2) {
|
|
|
2752
2775
|
return along2.map(([a, b]) => s.vertical ? rect13(o.x, a, o.width, b - a) : rect13(a, o.y, b - a, o.height));
|
|
2753
2776
|
}
|
|
2754
2777
|
function drawnOf(c, live) {
|
|
2755
|
-
const edges = Object.entries(c.now.edges).filter(([id, e]) => area3(e.rect) >
|
|
2778
|
+
const edges = Object.entries(c.now.edges).filter(([id, e]) => area3(e.rect) > EPS18 && c.lay.has(id)).map(([id, e]) => ({ spec: live.find((s) => s.edge?.id === id) ?? null, rect: e.rect, lay: c.lay.get(id) }));
|
|
2756
2779
|
const rails = ["left", "right"].flatMap((side) => {
|
|
2757
2780
|
const rail = c.now.rails[side];
|
|
2758
|
-
if (!rail || rail.segments.length === 0 || area3(rail.rect) <=
|
|
2781
|
+
if (!rail || rail.segments.length === 0 || area3(rail.rect) <= EPS18) return [];
|
|
2759
2782
|
const spec = live.find((s) => s.kind === "railStop" && s.lay.side === side) ?? null;
|
|
2760
2783
|
const lay = spec?.lay ?? { phase: EDGE_KINDS.railStop.phase, side, at: -1 };
|
|
2761
2784
|
const me = c.now.items[c.dragged];
|
|
@@ -2777,7 +2800,7 @@ function homeRectOf(c, ownSpec) {
|
|
|
2777
2800
|
if (!ownSpec) {
|
|
2778
2801
|
const e = c.now.edges[own.edge];
|
|
2779
2802
|
const vanishes = !c.rest.edges.some((x) => x.id === own.edge);
|
|
2780
|
-
return e && vanishes && !e.folded && !e.rides && area3(e.rect) >
|
|
2803
|
+
return e && vanishes && !e.folded && !e.rides && area3(e.rect) > EPS18 ? hull3(o, e.rect) : o;
|
|
2781
2804
|
}
|
|
2782
2805
|
const [c0, c1] = ownSpec.across();
|
|
2783
2806
|
return ownSpec.vertical ? hull3(o, rect13(c0, o.y, c1 - c0, o.height)) : hull3(o, rect13(o.x, c0, o.width, c1 - c0));
|
|
@@ -2797,7 +2820,7 @@ function ownersOf(c, live, drawn, alongOf) {
|
|
|
2797
2820
|
if (!s.thinOwned) return rects.map((r) => ({ spec: s, rect: r, lay: s.lay, place: !s.drawn }));
|
|
2798
2821
|
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]));
|
|
2799
2822
|
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 }))]);
|
|
2800
|
-
}).filter((o) => area3(o.rect) >
|
|
2823
|
+
}).filter((o) => area3(o.rect) > EPS18),
|
|
2801
2824
|
// Every seen rect: the edges the tiler doesn't read (folded, riding, taking nothing) among them.
|
|
2802
2825
|
...drawn.map((d) => ({ ...d, place: false }))
|
|
2803
2826
|
];
|
|
@@ -2823,7 +2846,7 @@ function ownership(c, live, alongOf, aloneOf) {
|
|
|
2823
2846
|
const e = s.edge ? now.edges[s.id] : void 0;
|
|
2824
2847
|
if (!e) return null;
|
|
2825
2848
|
const span = s.vertical ? [e.rect.y, e.rect.y + e.rect.height] : [e.rect.x, e.rect.x + e.rect.width];
|
|
2826
|
-
return span[1] - span[0] >
|
|
2849
|
+
return span[1] - span[0] > EPS18 ? span : null;
|
|
2827
2850
|
};
|
|
2828
2851
|
const pastEnds = (s, r) => {
|
|
2829
2852
|
const ends = endsOf(s);
|
|
@@ -2875,7 +2898,7 @@ function ownership(c, live, alongOf, aloneOf) {
|
|
|
2875
2898
|
const half = e ? halfBandOf(e) : null;
|
|
2876
2899
|
if (!e || half === null) return [];
|
|
2877
2900
|
const column = axisOf(e.side) === "column";
|
|
2878
|
-
return Object.entries(now.items).filter(([iid, p]) => p.edge === e.id && iid !== dragged && isBody(formsOf(state.items[iid], axisOf(e.side))[p.form])).map(([, p]) => column ? [p.rect.y + half, p.rect.y + p.rect.height - half] : [p.rect.x + half, p.rect.x + p.rect.width - half]).filter(([a, b]) => b - a >
|
|
2901
|
+
return Object.entries(now.items).filter(([iid, p]) => p.edge === e.id && iid !== dragged && isBody(formsOf(state.items[iid], axisOf(e.side))[p.form])).map(([, p]) => column ? [p.rect.y + half, p.rect.y + p.rect.height - half] : [p.rect.x + half, p.rect.x + p.rect.width - half]).filter(([a, b]) => b - a > EPS18);
|
|
2879
2902
|
};
|
|
2880
2903
|
const rooms = /* @__PURE__ */ new Map();
|
|
2881
2904
|
const cutsOf = (s) => {
|
|
@@ -2892,23 +2915,23 @@ function ownership(c, live, alongOf, aloneOf) {
|
|
|
2892
2915
|
const owned = [];
|
|
2893
2916
|
for (let k = 1; k < ends.length; k++) {
|
|
2894
2917
|
const [u, w] = [ends[k - 1], ends[k]];
|
|
2895
|
-
const over2 = rs.filter((r) => along2(r)[0] <= u +
|
|
2896
|
-
if (w - u >
|
|
2918
|
+
const over2 = rs.filter((r) => along2(r)[0] <= u + EPS18 && along2(r)[1] >= w - EPS18).map(across2);
|
|
2919
|
+
if (w - u > EPS18 && less([across2(b)], over2).reduce((n, [p, q]) => n + q - p, 0) < 1) owned.push([u, w]);
|
|
2897
2920
|
}
|
|
2898
2921
|
const half = s.edge ? halfBandOf(s.edge) : null;
|
|
2899
2922
|
const raw = bodySpans(s.edge);
|
|
2900
2923
|
if (half === null || raw.length === 0) return { cuts: owned, bodies: raw };
|
|
2901
2924
|
const merged = owned.reduce((m, [u, w]) => {
|
|
2902
2925
|
const last = m[m.length - 1];
|
|
2903
|
-
if (last && u <= last[1] +
|
|
2926
|
+
if (last && u <= last[1] + EPS18) last[1] = Math.max(last[1], w);
|
|
2904
2927
|
else m.push([u, w]);
|
|
2905
2928
|
return m;
|
|
2906
2929
|
}, []);
|
|
2907
2930
|
const [lo2, hi] = endsOf(s) ?? along2(b);
|
|
2908
2931
|
const placed = (p) => {
|
|
2909
|
-
const cut2 = merged.find(([u, w]) => p >= u -
|
|
2932
|
+
const cut2 = merged.find(([u, w]) => p >= u - EPS18 && p <= w + EPS18);
|
|
2910
2933
|
if (!cut2) return p;
|
|
2911
|
-
const sides = [...cut2[0] > lo2 +
|
|
2934
|
+
const sides = [...cut2[0] > lo2 + EPS18 ? [cut2[0]] : [], ...cut2[1] < hi - EPS18 ? [cut2[1]] : []];
|
|
2912
2935
|
return sides.length === 0 ? p : sides.reduce((m, x) => Math.abs(x - p) < Math.abs(m - p) ? x : m);
|
|
2913
2936
|
};
|
|
2914
2937
|
const bands = s.slots.map((sl) => [placed(sl.line) - half, placed(sl.line) + half]);
|
|
@@ -2926,7 +2949,7 @@ function ownership(c, live, alongOf, aloneOf) {
|
|
|
2926
2949
|
const column = axisOf(e.side) === "column";
|
|
2927
2950
|
const across2 = (a, b) => column ? rect13(-1e9, a, 2e9, b - a) : rect13(a, -1e9, b - a, 2e9);
|
|
2928
2951
|
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));
|
|
2929
|
-
return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area3(b) >
|
|
2952
|
+
return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area3(b) > EPS18);
|
|
2930
2953
|
};
|
|
2931
2954
|
const drawnBySpec = /* @__PURE__ */ new Map();
|
|
2932
2955
|
const drawnBesides = (s) => {
|
|
@@ -2938,15 +2961,15 @@ function ownership(c, live, alongOf, aloneOf) {
|
|
|
2938
2961
|
}
|
|
2939
2962
|
|
|
2940
2963
|
// src/targets/tiles.ts
|
|
2941
|
-
import { EPS as
|
|
2964
|
+
import { EPS as EPS20, area as area4, overlaps as overlaps4, rect as rect15, subtract as subtract3 } from "@n-uf/placement";
|
|
2942
2965
|
|
|
2943
2966
|
// src/slide.ts
|
|
2944
|
-
import { EPS as
|
|
2967
|
+
import { EPS as EPS19, rect as rect14 } from "@n-uf/placement";
|
|
2945
2968
|
import { itemSteps as itemSteps6 } from "@n-uf/placement/stack";
|
|
2946
2969
|
var mid = (r, axis) => lo(r, axis) + len(r, axis) / 2;
|
|
2947
2970
|
var nonNeg = (v) => Number.isFinite(v) && v > 0 ? v : 0;
|
|
2948
2971
|
function onEdge(l, edge, dragged, axis) {
|
|
2949
|
-
return Object.entries(l.items).filter(([id, it]) => id !== dragged && it.edge === edge && !it.inMenu && !it.floating && it.rect.width >
|
|
2972
|
+
return Object.entries(l.items).filter(([id, it]) => id !== dragged && it.edge === edge && !it.inMenu && !it.floating && it.rect.width > EPS19 && it.rect.height > EPS19).map(([id, it]) => ({ id, r: it.rect, zone: it.zone })).sort((a, b) => lo(a.r, axis) - lo(b.r, axis));
|
|
2950
2973
|
}
|
|
2951
2974
|
function neighbors(after, edge, dragged, axis) {
|
|
2952
2975
|
const me = after.items[dragged];
|
|
@@ -2968,7 +2991,7 @@ function slackOf(state, id, axis, r) {
|
|
|
2968
2991
|
}
|
|
2969
2992
|
function placeOf(se, l) {
|
|
2970
2993
|
const counts = (id) => !(se.state.items[id]?.fixed && itemSteps6(se.state.items[id]));
|
|
2971
|
-
const shown = Object.entries(l.items).filter(([id, it]) => counts(id) && it.edge === se.e.id && !it.inMenu && !it.floating && it.rect.width >
|
|
2994
|
+
const shown = Object.entries(l.items).filter(([id, it]) => counts(id) && it.edge === se.e.id && !it.inMenu && !it.floating && it.rect.width > EPS19 && it.rect.height > EPS19).sort(([, p], [, q]) => lo(p.rect, se.axis) - lo(q.rect, se.axis)).map(([id]) => id);
|
|
2972
2995
|
const menu = Object.entries(l.items).filter(([id, it]) => counts(id) && it.inMenu && it.edge === se.e.id).map(([id]) => id).sort();
|
|
2973
2996
|
return `${shown.join(" ")} \xBB ${menu.join(" ")}`;
|
|
2974
2997
|
}
|
|
@@ -3036,7 +3059,7 @@ function slideLand(se, room, x0) {
|
|
|
3036
3059
|
for (const zone of [near, near === "start" ? "end" : "start"]) {
|
|
3037
3060
|
if (!room.zones.includes(zone)) continue;
|
|
3038
3061
|
const space = room.spaceAt(zone, x0);
|
|
3039
|
-
if (space < -
|
|
3062
|
+
if (space < -EPS19) continue;
|
|
3040
3063
|
const place = { edge: se.e.id, zone, at: room.atOf(zone), space: Math.max(0, space) };
|
|
3041
3064
|
const hit = landsAt(se, place, x0);
|
|
3042
3065
|
if (hit && (room.place === void 0 || placeOf(se, hit.layout) === room.place)) return { place, result: { state: hit.next, layout: hit.layout } };
|
|
@@ -3080,7 +3103,7 @@ function tilerOf(spec) {
|
|
|
3080
3103
|
const part = (a, b) => v ? rect15(a, h.y, b - a, h.height) : rect15(h.x, a, h.width, b - a);
|
|
3081
3104
|
const beyond = less([[h0, h1]], [spec.owned]);
|
|
3082
3105
|
if (beyond.length === 0) return [t];
|
|
3083
|
-
if (c1 - c0 <=
|
|
3106
|
+
if (c1 - c0 <= EPS20) return [{ ...t, order: data.overreach }];
|
|
3084
3107
|
const core = { ...t, hit: part(c0, c1), keep: t.keep && keepAt(v ? t.keep.y : t.keep.x, part(c0, c1)) };
|
|
3085
3108
|
return [core, ...beyond.map(([a, b]) => ({ ...t, kind: "reach", of: core, order: data.overreach, hit: part(a, b), keep: null }))];
|
|
3086
3109
|
};
|
|
@@ -3094,7 +3117,7 @@ function wholeRefusal(c, spec) {
|
|
|
3094
3117
|
const data = EDGE_KINDS[spec.kind];
|
|
3095
3118
|
return { edge: spec.id, spec, edgeKind: spec.kind, vertical: spec.vertical, zone: "start", hit, kind: "refuse", id: "", order: data.layer, priority: data.priority, keep: null, reason: "not-accepted", whole: true };
|
|
3096
3119
|
}
|
|
3097
|
-
var hasRoom = (spans, away) => less(spans, away).some(([a, b]) => b - a >
|
|
3120
|
+
var hasRoom = (spans, away) => less(spans, away).some(([a, b]) => b - a > EPS20);
|
|
3098
3121
|
function linesIn(spec, z, mine, pieces, [pa, pb], own) {
|
|
3099
3122
|
const reserved = spec.reserved;
|
|
3100
3123
|
const lines = mine.map((s) => s.line);
|
|
@@ -3103,42 +3126,42 @@ function linesIn(spec, z, mine, pieces, [pa, pb], own) {
|
|
|
3103
3126
|
const free = less([[z.a, z.b]], reserved);
|
|
3104
3127
|
const freeLen = free.reduce((n, [a, b]) => n + (b - a), 0);
|
|
3105
3128
|
const spread = (x) => {
|
|
3106
|
-
if (hi - lo2 <=
|
|
3129
|
+
if (hi - lo2 <= EPS20 || freeLen <= EPS20) return x;
|
|
3107
3130
|
let d = (x - lo2) / (hi - lo2) * freeLen;
|
|
3108
3131
|
for (const [a, b] of free) {
|
|
3109
|
-
if (d <= b - a +
|
|
3132
|
+
if (d <= b - a + EPS20) return a + Math.min(d, b - a);
|
|
3110
3133
|
d -= b - a;
|
|
3111
3134
|
}
|
|
3112
3135
|
return free[free.length - 1][1];
|
|
3113
3136
|
};
|
|
3114
|
-
const past = lines.some((x) => x < z.a -
|
|
3137
|
+
const past = lines.some((x) => x < z.a - EPS20 || x > z.b + EPS20);
|
|
3115
3138
|
const nearer = (p, [a, b]) => p > a && p < b ? p - a < b - p ? a : b : p;
|
|
3116
3139
|
const proj = (x) => {
|
|
3117
3140
|
const q = reserved.reduce((r, s) => nearer(r, s), past ? spread(x) : x);
|
|
3118
3141
|
const p = own ? nearer(q, own) : q;
|
|
3119
|
-
if (pieces.some(([a, b]) => p >= a -
|
|
3142
|
+
if (pieces.some(([a, b]) => p >= a - EPS20 && p <= b + EPS20)) return p;
|
|
3120
3143
|
return pieces.map(([a, b]) => Math.min(Math.max(p, a), b)).reduce((m, y) => Math.abs(y - p) < Math.abs(m - p) ? y : m);
|
|
3121
3144
|
};
|
|
3122
|
-
const ownEnd = (s) => !!own && s.home && (Math.abs(s.line - own[0]) <
|
|
3123
|
-
const inPiece = mine.filter((s) => ownEnd(s) ? s.line >= pa -
|
|
3145
|
+
const ownEnd = (s) => !!own && s.home && (Math.abs(s.line - own[0]) < EPS20 || Math.abs(s.line - own[1]) < EPS20);
|
|
3146
|
+
const inPiece = mine.filter((s) => ownEnd(s) ? s.line >= pa - EPS20 && s.line <= pb + EPS20 : proj(s.line) >= pa - EPS20 && proj(s.line) <= pb + EPS20).sort((a, b) => proj(a.line) - proj(b.line) || a.line - b.line);
|
|
3124
3147
|
const projected = inPiece.map((s) => proj(s.line));
|
|
3125
|
-
const at = projected.some((p, i) => i > 0 && p - projected[i - 1] <=
|
|
3148
|
+
const at = projected.some((p, i) => i > 0 && p - projected[i - 1] <= EPS20) ? inPiece.map((_, i) => pa + (i + 0.5) * (pb - pa) / inPiece.length) : projected;
|
|
3126
3149
|
return { inPiece, at };
|
|
3127
3150
|
}
|
|
3128
3151
|
function reachStrips(c, spec, room, ends) {
|
|
3129
|
-
const inEdge = (s) => !!ends && s[0] < ends[1] -
|
|
3152
|
+
const inEdge = (s) => !!ends && s[0] < ends[1] - EPS20 && s[1] > ends[0] + EPS20;
|
|
3130
3153
|
const pieces = room.filter(inEdge);
|
|
3131
3154
|
if (!ends || pieces.length === 0) return { pieces: [...room], before: [], after: [] };
|
|
3132
3155
|
const [c0, c1] = spec.across();
|
|
3133
3156
|
const bandOf2 = (a, b) => spec.vertical ? rect15(c0, a, c1 - c0, b - a) : rect15(a, c0, b - a, c1 - c0);
|
|
3134
3157
|
const across2 = c.state.edges.filter((e) => axisOf(e.side) === "column" !== spec.vertical).map((e) => c.now.edges[e.id]);
|
|
3135
|
-
const drawnBetween = (a, b) => b - a >
|
|
3158
|
+
const drawnBetween = (a, b) => b - a > EPS20 && across2.some((e) => !!e && e.cross > EPS20 && area4(e.rect) > EPS20 && overlaps4(e.rect, bandOf2(a, b)));
|
|
3136
3159
|
const first = pieces[0][0];
|
|
3137
3160
|
const last = pieces[pieces.length - 1][1];
|
|
3138
3161
|
return {
|
|
3139
3162
|
pieces,
|
|
3140
|
-
before: room.filter((s) => s[1] <= ends[0] +
|
|
3141
|
-
after: room.filter((s) => s[0] >= ends[1] -
|
|
3163
|
+
before: room.filter((s) => s[1] <= ends[0] + EPS20 && !drawnBetween(s[1], first)),
|
|
3164
|
+
after: room.filter((s) => s[0] >= ends[1] - EPS20 && !drawnBetween(last, s[0]))
|
|
3142
3165
|
};
|
|
3143
3166
|
}
|
|
3144
3167
|
function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
|
|
@@ -3150,7 +3173,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
|
|
|
3150
3173
|
const own = spec.own ? v ? [spec.own.y, spec.own.y + spec.own.height] : [spec.own.x, spec.own.x + spec.own.width] : null;
|
|
3151
3174
|
const { band, keepAt, tile, split } = tilerOf(spec);
|
|
3152
3175
|
const drawn = spec.edge ? c.now.edges[spec.id]?.rect : void 0;
|
|
3153
|
-
const alongLimit = drawn && (v ? drawn.height : drawn.width) >
|
|
3176
|
+
const alongLimit = drawn && (v ? drawn.height : drawn.width) > EPS20 ? v ? rect15(-1e9, drawn.y, 2e9, drawn.height) : rect15(drawn.x, -1e9, drawn.width, 2e9) : null;
|
|
3154
3177
|
const refused = (zone, hit, reason) => {
|
|
3155
3178
|
const inEdge = alongLimit ? meet(hit, alongLimit) : hit;
|
|
3156
3179
|
const shown = inEdge && meet(inEdge, c.state.stage);
|
|
@@ -3159,11 +3182,11 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
|
|
|
3159
3182
|
const slots = distinctSlots(c, spec.slots);
|
|
3160
3183
|
const runs = [...spec.reserved].sort((p, q) => p[0] - q[0]).reduce((acc, [a, b]) => {
|
|
3161
3184
|
const last = acc[acc.length - 1];
|
|
3162
|
-
if (last && a <= last[1] +
|
|
3185
|
+
if (last && a <= last[1] + EPS20) acc[acc.length - 1] = [last[0], Math.max(last[1], b)];
|
|
3163
3186
|
else acc.push([a, b]);
|
|
3164
3187
|
return acc;
|
|
3165
3188
|
}, []);
|
|
3166
|
-
const wedged = (line) => runs.some(([a, b]) => line > a +
|
|
3189
|
+
const wedged = (line) => runs.some(([a, b]) => line > a + EPS20 && line < b - EPS20);
|
|
3167
3190
|
const homeSlot = spec.holds && own ? slots.find((s) => s.home && s.order !== void 0) : void 0;
|
|
3168
3191
|
const ends = alongLimit && drawn ? v ? [drawn.y, drawn.y + drawn.height] : [drawn.x, drawn.x + drawn.width] : null;
|
|
3169
3192
|
const out = [];
|
|
@@ -3177,7 +3200,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
|
|
|
3177
3200
|
});
|
|
3178
3201
|
const axis = v ? "y" : "x";
|
|
3179
3202
|
const span = (r) => v ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
|
|
3180
|
-
const orderIn = (l) => Object.entries(l.items).filter(([, it]) => it.edge === spec.id && !it.inMenu && !it.floating && area4(it.rect) >
|
|
3203
|
+
const orderIn = (l) => Object.entries(l.items).filter(([, it]) => it.edge === spec.id && !it.inMenu && !it.floating && area4(it.rect) > EPS20).sort(([, p], [, q]) => span(p.rect)[0] - span(q.rect)[0]).map(([id]) => id).join(" ");
|
|
3181
3204
|
const homeOrder = orderIn(c.now);
|
|
3182
3205
|
const nearHome = (s) => {
|
|
3183
3206
|
if (halves || s.home || !spec.own || !ownRect || c.now.items[c.dragged]?.inMenu) return false;
|
|
@@ -3193,18 +3216,18 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
|
|
|
3193
3216
|
};
|
|
3194
3217
|
const stretchesOf = [];
|
|
3195
3218
|
for (const z of spec.zones) {
|
|
3196
|
-
const room = less([[z.a, z.b]], [...cuts, ...spec.reserved]).filter(([a, b]) => b - a >
|
|
3219
|
+
const room = less([[z.a, z.b]], [...cuts, ...spec.reserved]).filter(([a, b]) => b - a > EPS20);
|
|
3197
3220
|
const { pieces, before, after } = reachStrips(c, spec, own ? less(room, [own]) : room, ends);
|
|
3198
3221
|
if (!hasRoom(pieces, bodies)) continue;
|
|
3199
3222
|
const lined = slots.flatMap((s) => spec.holds && s.home ? own ? [{ ...s, line: own[0] }, { ...s, line: own[1] }] : [] : [s]);
|
|
3200
|
-
const mine = lined.filter((s) => s.zone === z.zone && !wedged(s.line) && pieces.some(([a, b]) => b > s.line - data.reach +
|
|
3223
|
+
const mine = lined.filter((s) => s.zone === z.zone && !wedged(s.line) && pieces.some(([a, b]) => b > s.line - data.reach + EPS20 && a < s.line + data.reach - EPS20));
|
|
3201
3224
|
const reason = spec.refuse(z.zone);
|
|
3202
3225
|
for (const [k, [pa, pb]] of pieces.entries()) {
|
|
3203
3226
|
const { inPiece, at } = linesIn(spec, z, mine, pieces, [pa, pb], own);
|
|
3204
3227
|
const stripsOf = (i) => [...k === 0 && i === 0 ? before : [], ...k === pieces.length - 1 && i === inPiece.length - 1 ? after : []];
|
|
3205
3228
|
if (inPiece.length === 0) {
|
|
3206
3229
|
const lone = (reason === "no-room" || reason === "too-thick") && mine.length === 0 && slots.some((s) => s.zone === z.zone && s.home);
|
|
3207
|
-
const near = mine.length === 0 || data.virtual || mine.some((s) => pb > s.line - data.reach +
|
|
3230
|
+
const near = mine.length === 0 || data.virtual || mine.some((s) => pb > s.line - data.reach + EPS20 && pa < s.line + data.reach - EPS20);
|
|
3208
3231
|
const joins = data.virtual ? mine.filter((s) => s.ok && !s.home) : [];
|
|
3209
3232
|
if (joins.length > 0) {
|
|
3210
3233
|
const s = joins.reduce((m, x) => Math.abs(x.line - (pa + pb) / 2) < Math.abs(m.line - (pa + pb) / 2) ? x : m);
|
|
@@ -3218,12 +3241,12 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
|
|
|
3218
3241
|
const meets = [];
|
|
3219
3242
|
for (let i = 1; i < inPiece.length; i++) {
|
|
3220
3243
|
const [lo2, hi] = [at[i - 1], at[i]];
|
|
3221
|
-
const between = spec.cards.filter(([u2, w2]) => u2 >= inPiece[i - 1].line -
|
|
3244
|
+
const between = spec.cards.filter(([u2, w2]) => u2 >= inPiece[i - 1].line - EPS20 && w2 <= inPiece[i].line + EPS20);
|
|
3222
3245
|
const la = landingOf(inPiece[i - 1]);
|
|
3223
3246
|
const lb = landingOf(inPiece[i]);
|
|
3224
3247
|
const [u, w] = between[0] ?? [NaN, NaN];
|
|
3225
3248
|
const mid3 = between.length === 1 ? aimCut(la ?? rect15(0, 0, 0, 0), lb ?? rect15(0, 0, 0, 0), v ? "y" : "x", 0, 0, 0, v ? rect15(0, u, 0, w - u) : rect15(u, 0, w - u, 0)) : NaN;
|
|
3226
|
-
meets[i] = mid3 > lo2 +
|
|
3249
|
+
meets[i] = mid3 > lo2 + EPS20 && mid3 < hi - EPS20 ? mid3 : (lo2 + hi) / 2;
|
|
3227
3250
|
}
|
|
3228
3251
|
const meet2 = (i) => meets[i];
|
|
3229
3252
|
inPiece.forEach((s, i) => {
|
|
@@ -3233,7 +3256,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
|
|
|
3233
3256
|
const b0 = Math.min(i === inPiece.length - 1 ? pb : meet2(i + 1), p + lim);
|
|
3234
3257
|
stretchesOf.push({ s, a: a0, b: b0, make: (a, b) => makeTiles(a, b) });
|
|
3235
3258
|
const makeTiles = (a, b) => {
|
|
3236
|
-
if (b - a <=
|
|
3259
|
+
if (b - a <= EPS20) {
|
|
3237
3260
|
if (s.ok && !s.home) lost.push(s.id);
|
|
3238
3261
|
return;
|
|
3239
3262
|
}
|
|
@@ -3246,7 +3269,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
|
|
|
3246
3269
|
for (const [u, w] of [[a, b], ...stripsOf(i)]) out.push(...split(homeTile(s.home ? s.id : homeSlot?.id ?? s.id, u, w, p)));
|
|
3247
3270
|
return;
|
|
3248
3271
|
}
|
|
3249
|
-
const faced = halves && homeSlot && s.order === homeSlot.order ? spec.cards.filter(([u, w]) => w > a +
|
|
3272
|
+
const faced = halves && homeSlot && s.order === homeSlot.order ? spec.cards.filter(([u, w]) => w > a + EPS20 && u < b - EPS20) : [];
|
|
3250
3273
|
for (const [u, w] of faced) out.push(...split(homeTile(homeSlot.id, Math.max(u, a), Math.min(w, b), p)));
|
|
3251
3274
|
for (const [u, w] of [...less([[a, b]], faced), ...stripsOf(i)]) {
|
|
3252
3275
|
const line = Math.min(Math.max(p, u), w);
|
|
@@ -3334,7 +3357,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
|
|
|
3334
3357
|
const cp = i > 0 ? cuts2[i - 1] : Math.min(...run.map((r) => r.a));
|
|
3335
3358
|
const cn = i + 1 < runs2.length ? cuts2[i] : Math.max(...run.map((r) => r.b));
|
|
3336
3359
|
for (const r of run) [r.a, r.b] = [Math.min(Math.max(r.a, cp), cn), Math.max(Math.min(r.b, cn), cp)];
|
|
3337
|
-
const held = run.filter((r) => r.b - r.a >
|
|
3360
|
+
const held = run.filter((r) => r.b - r.a > EPS20).sort((p, q) => p.a - q.a);
|
|
3338
3361
|
if (held.length === 0) {
|
|
3339
3362
|
const one = run.find((r) => !ownStretch.includes(r)) ?? run[0];
|
|
3340
3363
|
[one.a, one.b] = [cp, Math.max(cp, cn)];
|
|
@@ -3342,20 +3365,20 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
|
|
|
3342
3365
|
held[0].a = cp;
|
|
3343
3366
|
held.at(-1).b = Math.max(cp, cn);
|
|
3344
3367
|
}
|
|
3345
|
-
if (cn - cp >
|
|
3368
|
+
if (cn - cp > EPS20) spans.push([cp, cn]);
|
|
3346
3369
|
});
|
|
3347
3370
|
for (const r of dropped) r.a = r.b;
|
|
3348
3371
|
for (const r of lands) if (r.s.ok && !r.s.home) lost.push(r.s.id);
|
|
3349
|
-
if (ownStretch[0]) ownKept = ownStretch[0].b - ownStretch[0].a >
|
|
3372
|
+
if (ownStretch[0]) ownKept = ownStretch[0].b - ownStretch[0].a > EPS20 ? [[ownStretch[0].a, ownStretch[0].b]] : [];
|
|
3350
3373
|
for (const r of all.filter((x) => !lands.includes(x))) {
|
|
3351
|
-
const left = less([[r.a, r.b]], spans).filter(([u, w]) => w - u >
|
|
3374
|
+
const left = less([[r.a, r.b]], spans).filter(([u, w]) => w - u > EPS20);
|
|
3352
3375
|
[r.a, r.b] = left.length ? left.reduce((m, x) => x[1] - x[0] > m[1] - m[0] ? x : m) : [r.a, r.a];
|
|
3353
3376
|
}
|
|
3354
3377
|
}
|
|
3355
3378
|
for (const r of stretchesOf) r.make(r.a, r.b);
|
|
3356
3379
|
if (own && spec.own && (ownKept === null || ownKept.length > 0)) {
|
|
3357
3380
|
const home = spec.slots.find((s) => s.home);
|
|
3358
|
-
const kept = ownKept ?? (halves ? [] : less([own], slotSpans).filter(([u, w]) => w - u >
|
|
3381
|
+
const kept = ownKept ?? (halves ? [] : less([own], slotSpans).filter(([u, w]) => w - u > EPS20));
|
|
3359
3382
|
const [a, b] = kept.length > 0 ? kept.reduce((m, x) => x[1] - x[0] > m[1] - m[0] ? x : m) : own;
|
|
3360
3383
|
const h = band(a, b);
|
|
3361
3384
|
const o = spec.own;
|
|
@@ -3377,7 +3400,7 @@ function placeReach(t, pieces, placed, landed, gone) {
|
|
|
3377
3400
|
if (at.length === 0 && gone.has(of)) {
|
|
3378
3401
|
const line = t.vertical ? of.keep.y : of.keep.x;
|
|
3379
3402
|
const whole = pieces.filter((p) => p.width >= 1 && p.height >= 1);
|
|
3380
|
-
const on = whole.filter((p) => t.vertical ? p.y <= line +
|
|
3403
|
+
const on = whole.filter((p) => t.vertical ? p.y <= line + EPS20 && line <= p.y + p.height + EPS20 : p.x <= line + EPS20 && line <= p.x + p.width + EPS20);
|
|
3381
3404
|
const kept = (on.length > 0 ? on : whole).reduce((a, p) => !a || area4(p) > area4(a) ? p : a, null);
|
|
3382
3405
|
if (kept) {
|
|
3383
3406
|
placed.push({ ...of, hit: kept });
|
|
@@ -3390,7 +3413,7 @@ function placeReach(t, pieces, placed, landed, gone) {
|
|
|
3390
3413
|
for (let k = 0; k < cover.length; k++) {
|
|
3391
3414
|
const h = cover[k];
|
|
3392
3415
|
const joint = pieces.find(
|
|
3393
|
-
(p) => t.vertical ? p.y <= h.y +
|
|
3416
|
+
(p) => t.vertical ? p.y <= h.y + EPS20 && p.y + p.height >= h.y + h.height - EPS20 && (Math.abs(p.x - h.x - h.width) < EPS20 || Math.abs(p.x + p.width - h.x) < EPS20) : p.x <= h.x + EPS20 && p.x + p.width >= h.x + h.width - EPS20 && (Math.abs(p.y - h.y - h.height) < EPS20 || Math.abs(p.y + p.height - h.y) < EPS20)
|
|
3394
3417
|
);
|
|
3395
3418
|
if (!joint) continue;
|
|
3396
3419
|
const merged = t.vertical ? rect15(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) : rect15(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));
|
|
@@ -3461,10 +3484,10 @@ function clipTiles(tiles, own, chrome, lost) {
|
|
|
3461
3484
|
}
|
|
3462
3485
|
|
|
3463
3486
|
// src/targets/rail-strip.ts
|
|
3464
|
-
import { EPS as
|
|
3487
|
+
import { EPS as EPS22, overlaps as overlaps5, rect as rect17, subtract as subtract4 } from "@n-uf/placement";
|
|
3465
3488
|
|
|
3466
3489
|
// src/targets/virtual.ts
|
|
3467
|
-
import { EPS as
|
|
3490
|
+
import { EPS as EPS21, clamp as clamp3, rect as rect16 } from "@n-uf/placement";
|
|
3468
3491
|
function ringsOf(c, side) {
|
|
3469
3492
|
const seen = sideRings(c.state.edges, side);
|
|
3470
3493
|
const kept = c.rest.edges.filter((e) => e.side === side).map((e) => seen.get(e.id) ?? e.ring);
|
|
@@ -3477,7 +3500,7 @@ function railOuter(c, side) {
|
|
|
3477
3500
|
const windowEdge = side === "left" ? state.stage.x : state.stage.x + state.stage.width;
|
|
3478
3501
|
if (!place) return windowEdge;
|
|
3479
3502
|
const placeOuter = side === "left" ? place.x : place.x + place.width;
|
|
3480
|
-
const barOutside = Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= placeOuter +
|
|
3503
|
+
const barOutside = Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= placeOuter + EPS21 : e.rect.x >= placeOuter - EPS21));
|
|
3481
3504
|
return barOutside ? placeOuter : windowEdge;
|
|
3482
3505
|
}
|
|
3483
3506
|
function collapsesAt(c, result, side) {
|
|
@@ -3508,10 +3531,10 @@ function columnLines(c, side, railLands) {
|
|
|
3508
3531
|
const { reach, place, edgePlace } = EDGE_KINDS.columnLine;
|
|
3509
3532
|
const stage = c.state.stage;
|
|
3510
3533
|
const dir = side === "left" ? 1 : -1;
|
|
3511
|
-
const outside2 = (x) => Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= x +
|
|
3534
|
+
const outside2 = (x) => Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= x + EPS21 : e.rect.x >= x - EPS21));
|
|
3512
3535
|
const railFirst = railLands && !!c.state.rails?.[side]?.accepts.includes(c.kind) && !!now.railPlaces[side] && !(now.rails[side]?.segments.length ?? 0);
|
|
3513
3536
|
const placeOf2 = (l, i) => {
|
|
3514
|
-
const atEdge = side === "left" ? l.x <= stage.x +
|
|
3537
|
+
const atEdge = side === "left" ? l.x <= stage.x + EPS21 : l.x >= stage.x + stage.width - EPS21;
|
|
3515
3538
|
if (i > 0 || outside2(l.x) || !(atEdge || railFirst)) return { line: l.x, zone: [l.x - reach, l.x + reach], owned: [l.x - place / 2, l.x + place / 2] };
|
|
3516
3539
|
const windowEdge = side === "left" ? stage.x : stage.x + stage.width;
|
|
3517
3540
|
const boundary = clamp3(l.x, stage.x, stage.x + stage.width);
|
|
@@ -3654,7 +3677,7 @@ function columnStrip(c, side, policy) {
|
|
|
3654
3677
|
if (moved === c.state) return null;
|
|
3655
3678
|
const result = c.settle(markUsed(moved, c.dragged));
|
|
3656
3679
|
const el = result.layout.edges[edge.id];
|
|
3657
|
-
if (!el || el.rect.width <=
|
|
3680
|
+
if (!el || el.rect.width <= EPS22 || !collapsesAt(c, result, side)) return null;
|
|
3658
3681
|
const r = el.rect;
|
|
3659
3682
|
const railWidth = result.layout.items[c.dragged].tab ? r.width : edge.cross.rail ?? 30;
|
|
3660
3683
|
const [x, w] = across(side, side === "left" ? r.x : r.x + r.width, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, railWidth));
|
|
@@ -3811,7 +3834,7 @@ function clearOfStrips(t, dragged, strips) {
|
|
|
3811
3834
|
}
|
|
3812
3835
|
|
|
3813
3836
|
// src/targets/min-hit.ts
|
|
3814
|
-
import { EPS as
|
|
3837
|
+
import { EPS as EPS23, area as area5, rect as rect18, subtract as subtract5 } from "@n-uf/placement";
|
|
3815
3838
|
function kindOf(c, t) {
|
|
3816
3839
|
const p = parseTargetId(t.id);
|
|
3817
3840
|
if (!p) return null;
|
|
@@ -3824,8 +3847,8 @@ function kindOf(c, t) {
|
|
|
3824
3847
|
return null;
|
|
3825
3848
|
}
|
|
3826
3849
|
var largest3 = (ps) => ps.reduce((a, p) => area5(p) > area5(a) ? p : a);
|
|
3827
|
-
var keepsMinHit = (r, m) => Math.min(r.width, r.height) >= m.across -
|
|
3828
|
-
var overlaps6 = (a, b) => Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) >
|
|
3850
|
+
var keepsMinHit = (r, m) => Math.min(r.width, r.height) >= m.across - EPS23 && Math.max(r.width, r.height) >= m.along - EPS23;
|
|
3851
|
+
var overlaps6 = (a, b) => Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > EPS23 && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > EPS23;
|
|
3829
3852
|
var cut = (ps, g) => ps.flatMap((p) => subtract5(p, g)).filter((p) => p.width >= 1 && p.height >= 1);
|
|
3830
3853
|
var piecesOf = (t) => t.hits ?? [t.hit];
|
|
3831
3854
|
var withPieces2 = (t, ps) => {
|
|
@@ -3846,9 +3869,9 @@ var union = (a, gs) => {
|
|
|
3846
3869
|
function mayGrow(c, targets2, i, grow, minOf, zone, away) {
|
|
3847
3870
|
const s = c.state.stage;
|
|
3848
3871
|
for (const g of grow) {
|
|
3849
|
-
if (g.x < s.x -
|
|
3872
|
+
if (g.x < s.x - EPS23 || g.y < s.y - EPS23 || g.x + g.width > s.x + s.width + EPS23 || g.y + g.height > s.y + s.height + EPS23) return false;
|
|
3850
3873
|
if ([...keepClearFor(c.state, c.now, "targets"), ...away].some((r) => overlaps6(r, g))) return false;
|
|
3851
|
-
if (zone.reduce((ps, z) => ps.flatMap((p) => subtract5(p, z)), [g]).some((p) => area5(p) >
|
|
3874
|
+
if (zone.reduce((ps, z) => ps.flatMap((p) => subtract5(p, z)), [g]).some((p) => area5(p) > EPS23)) return false;
|
|
3852
3875
|
}
|
|
3853
3876
|
return targets2.every((o, j) => {
|
|
3854
3877
|
if (j === i || o.free || !piecesOf(o).some((p) => grow.some((g) => overlaps6(p, g)))) return true;
|
|
@@ -3883,7 +3906,7 @@ function partialGrowth(c, targets2, i, l, axis, d, m, minOf, zone, away) {
|
|
|
3883
3906
|
}
|
|
3884
3907
|
if (runStart !== null) runs.push([runStart, marks[marks.length - 1]]);
|
|
3885
3908
|
for (const [a, b] of runs.sort((p, q) => q[1] - q[0] - (p[1] - p[0]))) {
|
|
3886
|
-
if (b - a < m.along -
|
|
3909
|
+
if (b - a < m.along - EPS23) break;
|
|
3887
3910
|
const r = strip(a, b);
|
|
3888
3911
|
if (mayGrow(c, targets2, i, [r], minOf, zone, away) && (!best || area5(r) > area5(best))) best = r;
|
|
3889
3912
|
break;
|
|
@@ -3898,7 +3921,7 @@ function withMinHit(c, targets2, refusals2, zones) {
|
|
|
3898
3921
|
const k = kindOf(c, t);
|
|
3899
3922
|
return k ? EDGE_KINDS[k].minHit : null;
|
|
3900
3923
|
};
|
|
3901
|
-
const drawn = Object.entries(c.now.edges).filter(([, e]) => e.rect.width >
|
|
3924
|
+
const drawn = Object.entries(c.now.edges).filter(([, e]) => e.rect.width > EPS23 && e.rect.height > EPS23);
|
|
3902
3925
|
for (let i = 0; i < out.length; i++) {
|
|
3903
3926
|
const t = out[i];
|
|
3904
3927
|
const m = minOf(t);
|
|
@@ -3915,7 +3938,7 @@ function withMinHit(c, targets2, refusals2, zones) {
|
|
|
3915
3938
|
const axis = step === "across" ? narrowX ? "x" : "y" : narrowX ? "y" : "x";
|
|
3916
3939
|
const size = axis === "x" ? l.width : l.height;
|
|
3917
3940
|
const d = (step === "across" ? m.across : m.along) - size;
|
|
3918
|
-
if (d <=
|
|
3941
|
+
if (d <= EPS23) continue;
|
|
3919
3942
|
let grow = growths(l, axis, d).find((g) => mayGrow(c, out, i, g, minOf, zone, away));
|
|
3920
3943
|
if (!grow && step === "across") grow = partialGrowth(c, out, i, l, axis, d, m, minOf, zone, away) ?? void 0;
|
|
3921
3944
|
if (!grow) continue;
|
|
@@ -4017,17 +4040,17 @@ function hull(a, b) {
|
|
|
4017
4040
|
var thicknessChanges = (now, after) => {
|
|
4018
4041
|
const a = now.content;
|
|
4019
4042
|
const b = after.content;
|
|
4020
|
-
return Math.abs(b.x - a.x) >
|
|
4043
|
+
return Math.abs(b.x - a.x) > EPS24 || Math.abs(b.y - a.y) > EPS24 || Math.abs(b.x + b.width - (a.x + a.width)) > EPS24 || Math.abs(b.y + b.height - (a.y + a.height)) > EPS24;
|
|
4021
4044
|
};
|
|
4022
4045
|
var WINDOW_EDGE_KINDS = /* @__PURE__ */ new Set(["rail", "railStop", "sideBar", "columnLine"]);
|
|
4023
|
-
var touchesSide = (stage, pieces) => pieces.some((r) => r.x <= stage.x +
|
|
4046
|
+
var touchesSide = (stage, pieces) => pieces.some((r) => r.x <= stage.x + EPS24 || r.x + r.width >= stage.x + stage.width - EPS24);
|
|
4024
4047
|
function slotOverMoved(now, lifted, after, slot, dragged, onto) {
|
|
4025
4048
|
const from = now.items[dragged]?.edge;
|
|
4026
4049
|
return Object.entries(now.items).some(([id, was]) => {
|
|
4027
4050
|
if (!overlaps7(slot, was.rect) || id === dragged || was.floating || was.edge === onto) return false;
|
|
4028
4051
|
const r = after.items[id]?.rect;
|
|
4029
4052
|
const start = (from !== void 0 && was.edge === from ? lifted.items[id]?.rect : void 0) ?? was.rect;
|
|
4030
|
-
return !!r && (Math.abs(r.x - start.x) >
|
|
4053
|
+
return !!r && (Math.abs(r.x - start.x) > EPS24 || Math.abs(r.y - start.y) > EPS24 || Math.abs(r.width - start.width) > EPS24 || Math.abs(r.height - start.height) > EPS24);
|
|
4031
4054
|
});
|
|
4032
4055
|
}
|
|
4033
4056
|
function aloneRects(tiles) {
|
|
@@ -4260,7 +4283,7 @@ function orderedStops(state, dragged, options) {
|
|
|
4260
4283
|
}
|
|
4261
4284
|
|
|
4262
4285
|
// src/lanes.ts
|
|
4263
|
-
import { EPS as
|
|
4286
|
+
import { EPS as EPS25, area as area7, clamp as clamp5, rect as rect20, subtract as subtract6 } from "@n-uf/placement";
|
|
4264
4287
|
var STEP = 1;
|
|
4265
4288
|
var mid2 = (r, axis) => lo(r, axis) + len(r, axis) / 2;
|
|
4266
4289
|
var hull2 = (a, b) => {
|
|
@@ -4287,13 +4310,13 @@ function clipAtDrawn(band, axis, cuts) {
|
|
|
4287
4310
|
const x = axis === "x" ? "y" : "x";
|
|
4288
4311
|
const line = lo(band, x) + len(band, x) / 2;
|
|
4289
4312
|
for (const c of cuts) {
|
|
4290
|
-
if (!(lo(c, x) < line -
|
|
4313
|
+
if (!(lo(c, x) < line - EPS25 && line < lo(c, x) + len(c, x) - EPS25)) continue;
|
|
4291
4314
|
const c0 = lo(c, axis);
|
|
4292
4315
|
const c1 = c0 + len(c, axis);
|
|
4293
4316
|
if ((c0 + c1) / 2 <= center) a = Math.max(a, c1);
|
|
4294
4317
|
else b = Math.min(b, c0);
|
|
4295
4318
|
}
|
|
4296
|
-
return b - a >
|
|
4319
|
+
return b - a > EPS25 ? along(band, axis, a, b) : band;
|
|
4297
4320
|
}
|
|
4298
4321
|
var memo = /* @__PURE__ */ new WeakMap();
|
|
4299
4322
|
var previousIds = /* @__PURE__ */ new WeakMap();
|
|
@@ -4405,7 +4428,7 @@ function build(state, dragged, options) {
|
|
|
4405
4428
|
return it?.fixed && main?.grows ? main.natural : void 0;
|
|
4406
4429
|
},
|
|
4407
4430
|
gap: (edge) => nonNeg2(state.edges.find((e) => e.id === edge)?.gap),
|
|
4408
|
-
crossing: (edge, over2) => state.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over2.edges[e.id]?.cross ?? 0) >
|
|
4431
|
+
crossing: (edge, over2) => state.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over2.edges[e.id]?.cross ?? 0) > EPS25 && axisOfEdge(e.id) !== axisOfEdge(edge)).map((e) => over2.edges[e.id].rect)
|
|
4409
4432
|
};
|
|
4410
4433
|
const heldAt = /* @__PURE__ */ new WeakMap();
|
|
4411
4434
|
const held = (r, end) => {
|
|
@@ -4420,9 +4443,9 @@ function build(state, dragged, options) {
|
|
|
4420
4443
|
const built = [...byLane].map(([id, list]) => laneFrom(id, list, seen, seen, dragged, rs, halves.has(id), held, marking)).filter((l) => !!l);
|
|
4421
4444
|
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)));
|
|
4422
4445
|
const onLanes = new Set(laneList.map((l) => l.id));
|
|
4423
|
-
const rails = Object.values(seen.rails).flatMap((r) => r && r.rect.width >
|
|
4446
|
+
const rails = Object.values(seen.rails).flatMap((r) => r && r.rect.width > EPS25 && r.rect.height > EPS25 ? [r.rect] : []);
|
|
4424
4447
|
const blocked = [
|
|
4425
|
-
...Object.values(seen.edges).filter((e) => e.cross >
|
|
4448
|
+
...Object.values(seen.edges).filter((e) => e.cross > EPS25).map((e) => e.rect),
|
|
4426
4449
|
...Object.entries(seen.items).filter(([id, it]) => id !== dragged && !it.floating && !it.inMenu).map(([, it]) => it.rect),
|
|
4427
4450
|
...keepClearFor(state, seen, "targets"),
|
|
4428
4451
|
...rails,
|
|
@@ -4447,7 +4470,8 @@ function build(state, dragged, options) {
|
|
|
4447
4470
|
blocked,
|
|
4448
4471
|
stage: state.stage,
|
|
4449
4472
|
floatRegion: floatRegion(state, dragged),
|
|
4450
|
-
|
|
4473
|
+
// (The held size: a squeezed item is held at the length it lands at, `liftIn`'s lift.)
|
|
4474
|
+
item: lift.own ? { width: lift.own.width, height: lift.own.height } : own ? { width: own.rect.width, height: own.rect.height } : { width: 0, height: 0 },
|
|
4451
4475
|
float: ts.find((t) => t.free) ?? null,
|
|
4452
4476
|
refusals: rs
|
|
4453
4477
|
}
|
|
@@ -4479,7 +4503,7 @@ function drawnIn(layout, id) {
|
|
|
4479
4503
|
function drawnRect(layout, id) {
|
|
4480
4504
|
const e = layout.edges[id];
|
|
4481
4505
|
if (!e) return void 0;
|
|
4482
|
-
if (e.cross >
|
|
4506
|
+
if (e.cross > EPS25) return e.rect;
|
|
4483
4507
|
if (!e.folded) return void 0;
|
|
4484
4508
|
const run = Object.values(layout.rails).flatMap((r) => r?.segments.filter((g) => g.edge === id).map((g) => g.rect) ?? []);
|
|
4485
4509
|
return run.length > 0 ? run.reduce(hull2) : void 0;
|
|
@@ -4518,21 +4542,21 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, held, marking, sho
|
|
|
4518
4542
|
const a = i === 0 ? bandStart : cuts[i - 1];
|
|
4519
4543
|
const b = i === unique.length - 1 ? bandEnd : cuts[i];
|
|
4520
4544
|
const along2 = [clamp5(a, start, end), clamp5(b, start, end)];
|
|
4521
|
-
return along2[1] - along2[0] >
|
|
4545
|
+
return along2[1] - along2[0] > EPS25 || b - a <= EPS25 || x.home ? [{ x, along: along2 }] : [];
|
|
4522
4546
|
}).map(({ x, along: along2 }) => ({
|
|
4523
4547
|
id: x.id,
|
|
4524
4548
|
along: along2,
|
|
4525
4549
|
landing: x.landing,
|
|
4526
4550
|
// A sliding spot's target holds the pointer over its stretch only (its range of landings runs past the cuts either
|
|
4527
4551
|
// side, over the neighbors' stretches).
|
|
4528
|
-
target: x.slide && along2[1] - along2[0] >
|
|
4552
|
+
target: x.slide && along2[1] - along2[0] > EPS25 ? { ...x.target, hit: axis === "x" ? rect20(along2[0], x.target.hit.y, along2[1] - along2[0], x.target.hit.height) : rect20(x.target.hit.x, along2[0], x.target.hit.width, along2[1] - along2[0]) } : x.target,
|
|
4529
4553
|
...x.home ? { home: true } : {},
|
|
4530
4554
|
...x.pitched ? { pitched: true } : {},
|
|
4531
4555
|
...x.slide ? { slide: { from: x.slide.from, to: x.slide.to, snaps: x.slide.snaps, snapDistance: x.slide.snapDistance, step: x.slide.step } } : {},
|
|
4532
4556
|
others: othersKey(x.layout, dragged)
|
|
4533
4557
|
}));
|
|
4534
4558
|
const itemLen = Math.min(...unique.map((x) => len(x.landing, axis)));
|
|
4535
|
-
const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp5(lo(h, axis), start, end), clamp5(lo(h, axis) + len(h, axis), start, end)], reason: f.reason }))).filter((f) => f.along[1] - f.along[0] >= itemLen -
|
|
4559
|
+
const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp5(lo(h, axis), start, end), clamp5(lo(h, axis) + len(h, axis), start, end)], reason: f.reason }))).filter((f) => f.along[1] - f.along[0] >= itemLen - EPS25) : [];
|
|
4536
4560
|
const places = new Set(unique.map((x) => `${x.before}|${x.next}`));
|
|
4537
4561
|
const drawnEdge = first.edge ? drawn.edges[first.edge] : void 0;
|
|
4538
4562
|
const markRect = (first.edge ? drawnRect(drawn, first.edge) : void 0) ?? laneRectOver(list, drawn, marking).band ?? markBand ?? laneRect;
|
|
@@ -4565,8 +4589,8 @@ var HATCH_EDGE = 8;
|
|
|
4565
4589
|
function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, more) {
|
|
4566
4590
|
const { besideMin } = more;
|
|
4567
4591
|
const hatches = (pair, a, b, p, q, gl, gr) => {
|
|
4568
|
-
if (gl && Math.abs(p - a) <
|
|
4569
|
-
if (gr && Math.abs(q - b) <
|
|
4592
|
+
if (gl && Math.abs(p - a) < EPS25) out.push({ id: `${lane}/hatch/${pair}:before`, kind: "hatch", rect: along(laneRect, axis, p, p + Math.min(HATCH_END, (q - p) / 2)), givesWay: gl });
|
|
4593
|
+
if (gr && Math.abs(q - b) < EPS25) out.push({ id: `${lane}/hatch/${pair}:after`, kind: "hatch", rect: along(laneRect, axis, q - Math.min(HATCH_END, (q - p) / 2), q), givesWay: gr });
|
|
4570
4594
|
};
|
|
4571
4595
|
const heldAt = items.find((o) => o.id === held);
|
|
4572
4596
|
const heldSpan = heldAt ? [lo(heldAt.r, axis), lo(heldAt.r, axis) + len(heldAt.r, axis)] : null;
|
|
@@ -4579,7 +4603,7 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
4579
4603
|
const a = clamp5(ends[i].b, start, end);
|
|
4580
4604
|
const b = clamp5(ends[i + 1].a, start, end);
|
|
4581
4605
|
const pair = `${ends[i].id}|${ends[i + 1].id}`;
|
|
4582
|
-
if (ends[i + 1].a < start -
|
|
4606
|
+
if (ends[i + 1].a < start - EPS25 || ends[i].b > end + EPS25 || !lands(pair)) continue;
|
|
4583
4607
|
const left = ends[i].id === held ? ends[i - 1]?.id ?? "^" : ends[i].id;
|
|
4584
4608
|
const right = ends[i + 1].id === held ? ends[i + 2]?.id ?? "$" : ends[i + 1].id;
|
|
4585
4609
|
const named = `${left}|${right}`;
|
|
@@ -4588,12 +4612,12 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
4588
4612
|
const spot = !beside && named === pair && items.length > 0 && !isRefused2((a + b) / 2) ? more.landingOf(pair) : void 0;
|
|
4589
4613
|
const gl = spot && left !== "^" && more.givesWay(left, "before", spot.layout) ? left : null;
|
|
4590
4614
|
const gr = spot && right !== "$" && more.givesWay(right, "after", spot.layout) ? right : null;
|
|
4591
|
-
if (b - a < min -
|
|
4592
|
-
if (spot && b - a >= besideMin -
|
|
4615
|
+
if (b - a < min - EPS25) {
|
|
4616
|
+
if (spot && b - a >= besideMin - EPS25) {
|
|
4593
4617
|
let ps = [[a, b]];
|
|
4594
4618
|
for (const f of refused) ps = ps.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]);
|
|
4595
4619
|
if (heldSpan) ps = ps.flatMap(([p, q]) => [[p, Math.min(q, heldSpan[0])], [Math.max(p, heldSpan[1]), q]]);
|
|
4596
|
-
ps = ps.filter(([p, q]) => q - p >= MIN_BOX -
|
|
4620
|
+
ps = ps.filter(([p, q]) => q - p >= MIN_BOX - EPS25);
|
|
4597
4621
|
ps.forEach(([p, q], k2) => {
|
|
4598
4622
|
out.push({ id: `${lane}/box/${pair}${k2 ? `#${k2}` : ""}`, kind: "box", rect: along(laneRect, axis, p, q) });
|
|
4599
4623
|
hatches(pair, a, b, p, q, gl, gr);
|
|
@@ -4605,10 +4629,10 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
4605
4629
|
continue;
|
|
4606
4630
|
}
|
|
4607
4631
|
let pieces = [[a, b]];
|
|
4608
|
-
for (const f of refused) pieces = pieces.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]).filter(([p, q]) => q - p >
|
|
4632
|
+
for (const f of refused) pieces = pieces.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]).filter(([p, q]) => q - p > EPS25);
|
|
4609
4633
|
let k = 0;
|
|
4610
4634
|
for (const [p, q] of pieces) {
|
|
4611
|
-
if (q - p < min -
|
|
4635
|
+
if (q - p < min - EPS25) continue;
|
|
4612
4636
|
const base = `${lane}/box/${named}${beside ? `:${beside}` : ""}${k++ ? `#${k - 1}` : ""}`;
|
|
4613
4637
|
out.push({ id: out.some((m) => m.id === base) ? `${base}~2` : base, kind: "box", rect: along(laneRect, axis, p, q) });
|
|
4614
4638
|
hatches(pair, a, b, p, q, gl, gr);
|
|
@@ -4630,9 +4654,9 @@ function inLane(l, r) {
|
|
|
4630
4654
|
const y0 = Math.max(m.rect.y, r.y);
|
|
4631
4655
|
const x1 = Math.min(m.rect.x + m.rect.width, r.x + r.width);
|
|
4632
4656
|
const y1 = Math.min(m.rect.y + m.rect.height, r.y + r.height);
|
|
4633
|
-
if (m.kind === "line") return x1 - x0 >= m.rect.width -
|
|
4634
|
-
if (x1 - x0 <=
|
|
4635
|
-
return x1 - x0 >= m.rect.width -
|
|
4657
|
+
if (m.kind === "line") return x1 - x0 >= m.rect.width - EPS25 && y1 - y0 >= m.rect.height - EPS25 ? [m] : [];
|
|
4658
|
+
if (x1 - x0 <= EPS25 || y1 - y0 <= EPS25) return [];
|
|
4659
|
+
return x1 - x0 >= m.rect.width - EPS25 && y1 - y0 >= m.rect.height - EPS25 ? [m] : [{ ...m, rect: rect20(x0, y0, x1 - x0, y1 - y0) }];
|
|
4636
4660
|
});
|
|
4637
4661
|
return marks.length === l.marks.length && marks.every((m, i) => m === l.marks[i]) ? l : { ...l, marks };
|
|
4638
4662
|
}
|
|
@@ -4656,14 +4680,14 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
|
|
|
4656
4680
|
const e = edge ? edgeOf(edge) : void 0;
|
|
4657
4681
|
return !!e && (e.side === "top" || e.side === "bottom" || !!e.compact);
|
|
4658
4682
|
};
|
|
4659
|
-
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 >
|
|
4683
|
+
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 > EPS25 && it.rect.height > EPS25).map(([, it]) => it.rect) : [];
|
|
4660
4684
|
if (cuts.length === 0 && !(empty && (emptyLanes === "edge" || l.marks.some((m) => m.kind === "box" && stays.some((s) => overlaps8(m.rect, s)))))) return l;
|
|
4661
4685
|
const cut2 = (r, cs) => piecesLess(r, l.axis, cs);
|
|
4662
4686
|
const marks = [];
|
|
4663
4687
|
for (const m of l.marks) {
|
|
4664
4688
|
const kept = cut2(m.rect, m.kind === "box" ? [...cuts, ...stays] : cuts);
|
|
4665
4689
|
if (m.kind === "line") {
|
|
4666
|
-
if (kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, l.axis)) <
|
|
4690
|
+
if (kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, l.axis)) < EPS25) marks.push(m);
|
|
4667
4691
|
continue;
|
|
4668
4692
|
}
|
|
4669
4693
|
kept.forEach(([p, q], i) => {
|
|
@@ -4689,12 +4713,12 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
|
|
|
4689
4713
|
}
|
|
4690
4714
|
function piecesLess(r, axis, cs) {
|
|
4691
4715
|
const span = (x) => [lo(x, axis), lo(x, axis) + len(x, axis)];
|
|
4692
|
-
const crosses = (c) => axis === "x" ? c.y < r.y + r.height -
|
|
4716
|
+
const crosses = (c) => axis === "x" ? c.y < r.y + r.height - EPS25 && r.y < c.y + c.height - EPS25 : c.x < r.x + r.width - EPS25 && r.x < c.x + c.width - EPS25;
|
|
4693
4717
|
let ps = [span(r)];
|
|
4694
4718
|
for (const c of cs) {
|
|
4695
4719
|
if (!crosses(c)) continue;
|
|
4696
4720
|
const [c0, c1] = span(c);
|
|
4697
|
-
ps = ps.flatMap(([p, q]) => [[p, Math.min(q, c0)], [Math.max(p, c1), q]]).filter(([p, q]) => q - p >
|
|
4721
|
+
ps = ps.flatMap(([p, q]) => [[p, Math.min(q, c0)], [Math.max(p, c1), q]]).filter(([p, q]) => q - p > EPS25);
|
|
4698
4722
|
}
|
|
4699
4723
|
return ps;
|
|
4700
4724
|
}
|
|
@@ -4705,11 +4729,11 @@ function marksLess(marks, axis, cs, options = {}) {
|
|
|
4705
4729
|
const over2 = cs.filter((c) => overlaps8(m.rect, c));
|
|
4706
4730
|
if (over2.length === 0) return [m];
|
|
4707
4731
|
const kept = piecesLess(m.rect, axis, over2);
|
|
4708
|
-
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)) <
|
|
4732
|
+
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)) < EPS25) ? [m] : [];
|
|
4709
4733
|
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) }));
|
|
4710
4734
|
});
|
|
4711
4735
|
}
|
|
4712
|
-
var overlaps8 = (a, b) => a.x < b.x + b.width -
|
|
4736
|
+
var overlaps8 = (a, b) => a.x < b.x + b.width - EPS25 && b.x < a.x + a.width - EPS25 && a.y < b.y + b.height - EPS25 && b.y < a.y + a.height - EPS25;
|
|
4713
4737
|
function pitchedSpots(state, dragged, options, seen, lifted, raws, pitch) {
|
|
4714
4738
|
const out = [];
|
|
4715
4739
|
stretches(state, dragged, options, seen, lifted, raws, (run) => {
|
|
@@ -4734,12 +4758,12 @@ function pitchedSpots(state, dragged, options, seen, lifted, raws, pitch) {
|
|
|
4734
4758
|
};
|
|
4735
4759
|
return ({ a, b, w, zones, atOf, spaceAt, before, after }) => {
|
|
4736
4760
|
const end = (x0, order, flush) => {
|
|
4737
|
-
for (const zone of order) if (spaceAt(zone, x0) >= -
|
|
4761
|
+
for (const zone of order) if (spaceAt(zone, x0) >= -EPS25 && emit3(zone, atOf(zone), Math.max(0, spaceAt(zone, x0)), x0, flush)) return;
|
|
4738
4762
|
};
|
|
4739
4763
|
end(a, zones, before?.id ?? "^");
|
|
4740
|
-
if (b - w > a +
|
|
4764
|
+
if (b - w > a + EPS25) end(b - w, [...zones].reverse(), after?.id ?? "$");
|
|
4741
4765
|
if (b - a < w + pitch) return;
|
|
4742
|
-
for (let x0 = a + pitch; x0 + w <= b - pitch +
|
|
4766
|
+
for (let x0 = a + pitch; x0 + w <= b - pitch + EPS25; x0 += pitch) {
|
|
4743
4767
|
const zone = x0 + w / 2 < middle ? "start" : "end";
|
|
4744
4768
|
if (!zones.includes(zone)) continue;
|
|
4745
4769
|
emit3(zone, atOf(zone), spaceAt(zone, x0), x0);
|
|
@@ -4822,7 +4846,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample, grabs
|
|
|
4822
4846
|
const firstZone = (() => {
|
|
4823
4847
|
for (const zone3 of zones) {
|
|
4824
4848
|
const space = spaceAt(zone3, from);
|
|
4825
|
-
if (space < -
|
|
4849
|
+
if (space < -EPS25) continue;
|
|
4826
4850
|
const place2 = { edge: e.id, zone: zone3, at: atOf(zone3), space: Math.max(0, space) };
|
|
4827
4851
|
const hit = landsAt(run, place2, from);
|
|
4828
4852
|
if (hit) return { place: place2, result: { state: hit.next, layout: hit.layout } };
|
|
@@ -4939,20 +4963,20 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample, grabs
|
|
|
4939
4963
|
}
|
|
4940
4964
|
|
|
4941
4965
|
// src/drag.ts
|
|
4942
|
-
import { EPS as
|
|
4966
|
+
import { EPS as EPS26, area as area8, overlaps as overlaps9, subtract as subtract7 } from "@n-uf/placement";
|
|
4943
4967
|
var MIN_PIECE = 8;
|
|
4944
4968
|
function trimmedBy(marks, cs) {
|
|
4945
4969
|
if (cs.length === 0) return [...marks];
|
|
4946
4970
|
return marks.flatMap((m) => {
|
|
4947
4971
|
const r = m.rect;
|
|
4948
|
-
if (r.width <=
|
|
4949
|
-
const across2 = r.height <=
|
|
4972
|
+
if (r.width <= EPS26 || r.height <= EPS26) {
|
|
4973
|
+
const across2 = r.height <= EPS26;
|
|
4950
4974
|
const at = across2 ? r.y : r.x;
|
|
4951
4975
|
let pieces2 = [across2 ? [r.x, r.x + r.width] : [r.y, r.y + r.height]];
|
|
4952
4976
|
let touched = false;
|
|
4953
4977
|
for (const c of cs) {
|
|
4954
4978
|
const [lo2, hi] = across2 ? [c.y, c.y + c.height] : [c.x, c.x + c.width];
|
|
4955
|
-
if (!(at > lo2 +
|
|
4979
|
+
if (!(at > lo2 + EPS26 && at < hi - EPS26)) continue;
|
|
4956
4980
|
const [a, b] = across2 ? [c.x, c.x + c.width] : [c.y, c.y + c.height];
|
|
4957
4981
|
pieces2 = pieces2.flatMap(([s2, e2]) => {
|
|
4958
4982
|
if (b <= s2 || a >= e2) return [[s2, e2]];
|
|
@@ -4964,7 +4988,7 @@ function trimmedBy(marks, cs) {
|
|
|
4964
4988
|
const kept = pieces2.filter(([s2, e2]) => e2 - s2 >= 1);
|
|
4965
4989
|
if (kept.length === 0) return [];
|
|
4966
4990
|
const [s, e] = kept.reduce((x, y) => y[1] - y[0] > x[1] - x[0] ? y : x);
|
|
4967
|
-
if (Math.abs(s - (across2 ? r.x : r.y)) <
|
|
4991
|
+
if (Math.abs(s - (across2 ? r.x : r.y)) < EPS26 && Math.abs(e - s - (across2 ? r.width : r.height)) < EPS26) return [m];
|
|
4968
4992
|
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 } }];
|
|
4969
4993
|
}
|
|
4970
4994
|
const over2 = cs.filter((c) => overlaps9(m.rect, c));
|
|
@@ -5059,7 +5083,7 @@ function dockDrag(state, dragged, options = {}) {
|
|
|
5059
5083
|
shown.push(near);
|
|
5060
5084
|
}
|
|
5061
5085
|
const drawnStays = [
|
|
5062
|
-
...state.edges.filter((e) => (e.side === "top" || e.side === "bottom" || !!e.compact) && (screen.layout.edges[e.id]?.cross ?? 0) >
|
|
5086
|
+
...state.edges.filter((e) => (e.side === "top" || e.side === "bottom" || !!e.compact) && (screen.layout.edges[e.id]?.cross ?? 0) > EPS26).map((e) => screen.layout.edges[e.id].rect),
|
|
5063
5087
|
...Object.values(screen.layout.rails).flatMap((r) => r?.segments.filter((g) => g.id !== dragged).map((g) => g.rect) ?? [])
|
|
5064
5088
|
];
|
|
5065
5089
|
const onScreen = [...shown.filter((s) => !s.created && s !== near).flatMap((s) => s.marks.map((m) => m.rect)), ...drawnStays, ...screen.landing ? [screen.landing] : []];
|
|
@@ -5146,4 +5170,4 @@ export {
|
|
|
5146
5170
|
HATCH_EDGE,
|
|
5147
5171
|
dockDrag
|
|
5148
5172
|
};
|
|
5149
|
-
//# sourceMappingURL=chunk-
|
|
5173
|
+
//# sourceMappingURL=chunk-GWRE7UD7.js.map
|