@n-uf/placement 26.11.20 → 26.11.22
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 +86 -0
- package/README.md +73 -17
- package/dist/{chunk-GCSVZGVX.js → chunk-4DEXHBXT.js} +224 -47
- package/dist/chunk-4DEXHBXT.js.map +1 -0
- package/dist/{chunk-RUITEOZ7.js → chunk-RL3QB5SM.js} +61 -7
- package/dist/chunk-RL3QB5SM.js.map +1 -0
- package/dist/{model-DU7MovDa.d.ts → model-DPTu2EtG.d.ts} +24 -10
- package/dist/scene-cases.d.ts +2 -2
- package/dist/scene-cases.js +2 -2
- package/dist/scene.d.ts +3 -3
- package/dist/scene.js +10 -2
- package/dist/stack.d.ts +9 -8
- package/dist/stack.js +1 -1
- package/dist/{targets-CYJN0Hba.d.ts → targets-DgmHP5PY.d.ts} +82 -13
- package/package.json +1 -1
- package/dist/chunk-GCSVZGVX.js.map +0 -1
- package/dist/chunk-RUITEOZ7.js.map +0 -1
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
formMain,
|
|
6
6
|
formSetsCross,
|
|
7
7
|
wrapLines
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RL3QB5SM.js";
|
|
9
9
|
import {
|
|
10
10
|
clampInto,
|
|
11
11
|
rect
|
|
@@ -22,12 +22,34 @@ var DEFAULT_FLOAT_SIZE = { width: 280, height: 360 };
|
|
|
22
22
|
var axisOf = (side) => side === "left" || side === "right" ? "column" : "row";
|
|
23
23
|
var zoneOf = (item) => item?.align === "center" || item?.align === "end" ? item.align : "start";
|
|
24
24
|
var formsOf = (item, axis) => item.forms[axis] ?? [];
|
|
25
|
+
function isOutsideSideBar(scene, e) {
|
|
26
|
+
if (e.side !== "left" && e.side !== "right" || e.outsideInset !== true || e.column === true || e.accepts.length === 0) return false;
|
|
27
|
+
const template = scene.columns?.[e.side];
|
|
28
|
+
const rail = scene.rails?.[e.side];
|
|
29
|
+
if (!template && !rail) return false;
|
|
30
|
+
const panelKinds = [...template?.accepts ?? [], ...rail?.accepts ?? []];
|
|
31
|
+
return !e.accepts.some((k) => panelKinds.includes(k));
|
|
32
|
+
}
|
|
33
|
+
var floatOrientOf = (item) => {
|
|
34
|
+
if (item.floatOrient === "row" || item.floatOrient === "column") return item.floatOrient;
|
|
35
|
+
for (const k of Object.keys(item.forms)) if ((k === "row" || k === "column") && formsOf(item, k).length > 0) return k;
|
|
36
|
+
return "column";
|
|
37
|
+
};
|
|
38
|
+
function floatSizeOf(item, orient2 = floatOrientOf(item)) {
|
|
39
|
+
if (item.floatSize) return item.floatSize;
|
|
40
|
+
const f = formsOf(item, orient2)[0];
|
|
41
|
+
if (!f || f.main.grows) return DEFAULT_FLOAT_SIZE;
|
|
42
|
+
const main = Number.isFinite(f.main.natural) ? Math.max(0, f.main.natural) : 0;
|
|
43
|
+
const cross = Number.isFinite(f.cross.natural) ? Math.max(0, f.cross.natural) : 0;
|
|
44
|
+
if (main <= 0 || cross <= 0) return DEFAULT_FLOAT_SIZE;
|
|
45
|
+
return orient2 === "row" ? { width: main, height: cross } : { width: cross, height: main };
|
|
46
|
+
}
|
|
25
47
|
function pastWrap(forms, from) {
|
|
26
48
|
for (let j = Math.max(0, Math.floor(from)); j < forms.length; j++) if (forms[j].kind !== "wrap" && !forms[j].wrap) return j;
|
|
27
49
|
return void 0;
|
|
28
50
|
}
|
|
29
51
|
function floatShape(item, f) {
|
|
30
|
-
const orient2 = f.orient
|
|
52
|
+
const orient2 = f.orient ?? floatOrientOf(item);
|
|
31
53
|
const forms = formsOf(item, orient2);
|
|
32
54
|
const px2 = (v) => Number.isFinite(v) ? Math.max(0, v) : 0;
|
|
33
55
|
const w = px2(f.rect.width);
|
|
@@ -84,7 +106,12 @@ function solveEdge(scene, edge, ids, length, room, previous) {
|
|
|
84
106
|
const axis = axisOf(edge.side);
|
|
85
107
|
const column = axis === "column";
|
|
86
108
|
const ordered = zoneSorted(scene, ids);
|
|
87
|
-
const
|
|
109
|
+
const priorityOf = (id) => finite(scene.items[id].priority ?? edge.priority ?? 0, 0);
|
|
110
|
+
const formsById = (id) => {
|
|
111
|
+
const forms = formsOf(scene.items[id], axis);
|
|
112
|
+
const p = priorityOf(id);
|
|
113
|
+
return p === 0 ? forms : forms.map((f) => ({ ...f, rank: finite(f.rank ?? 0, 0) + p }));
|
|
114
|
+
};
|
|
88
115
|
const maxOf = Number.isNaN(edge.cross.max) ? Infinity : edge.cross.max;
|
|
89
116
|
const cross = { min: Math.min(px(edge.cross.min), room), max: Math.min(maxOf, room), rail: Math.min(px(edge.cross.rail ?? 30), room) };
|
|
90
117
|
const base = {
|
|
@@ -337,14 +364,20 @@ function solve(given, options = {}) {
|
|
|
337
364
|
const rails = {};
|
|
338
365
|
const gutter = px(scene.gutter);
|
|
339
366
|
let columnRoom;
|
|
367
|
+
let outerArea = stage;
|
|
340
368
|
const isSide = (e) => e.side === "left" || e.side === "right";
|
|
341
|
-
const
|
|
369
|
+
const PANEL_FORMS = /* @__PURE__ */ new Set(["open", "header", "rail"]);
|
|
370
|
+
const isPanel = (id) => {
|
|
371
|
+
const it = scene.items[id];
|
|
372
|
+
return !it.closed && !it.fixed && PANEL_FORMS.has(formsOf(it, "column")[0]?.kind ?? "");
|
|
373
|
+
};
|
|
374
|
+
const docked = order.some((e) => isSide(e) && e.accepts.length > 0 && owned.get(e).some(isPanel));
|
|
342
375
|
const inset = scene.insetWhen === "docked" && !docked ? {} : scene.inset ?? {};
|
|
343
376
|
const laySides = (sideEdges, area3) => {
|
|
344
377
|
const H = area3.height;
|
|
345
378
|
const ride = scene.handFold === "ride";
|
|
346
|
-
const upInset = area3.y <=
|
|
347
|
-
const downInset = area3.y + area3.height >=
|
|
379
|
+
const upInset = area3.y <= outerArea.y + px(inset.top) + EPS ? px(inset.top) : 0;
|
|
380
|
+
const downInset = area3.y + area3.height >= outerArea.y + outerArea.height - px(inset.bottom) - EPS ? px(inset.bottom) : 0;
|
|
348
381
|
const tall = (edge) => H + (edge.outsideInset === true ? upInset + downInset : 0);
|
|
349
382
|
const cols = sideEdges.map((edge) => {
|
|
350
383
|
const side = edge.side;
|
|
@@ -422,22 +455,26 @@ function solve(given, options = {}) {
|
|
|
422
455
|
}
|
|
423
456
|
}
|
|
424
457
|
const g = evaluate(auto);
|
|
425
|
-
const
|
|
458
|
+
const openMin = (ids, least) => Math.max(
|
|
459
|
+
least,
|
|
460
|
+
...ids.map((id) => {
|
|
461
|
+
const f = formsOf(scene.items[id], "column")[0];
|
|
462
|
+
return f && formSetsCross(f) ? formCrossMin(f) : 0;
|
|
463
|
+
})
|
|
464
|
+
);
|
|
465
|
+
const open2 = cols.filter((c) => c.edge.column === true && c.visible.length > 0).map((c) => c.hand ? openMin(c.visible, px(c.edge.cross.min)) : c.min);
|
|
426
466
|
const templates = ["left", "right"].flatMap((s) => {
|
|
427
467
|
const t = scene.columns?.[s];
|
|
428
468
|
if (!t) return [];
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
const f = forms[Math.min(Math.max(0, Math.floor(finite(it.from, 0))), Math.max(0, forms.length - 1))];
|
|
432
|
-
return f && formSetsCross(f) ? formCrossMin(f) : 0;
|
|
433
|
-
});
|
|
434
|
-
return [Math.max(px(t.cross.min), ...needs)];
|
|
469
|
+
const takes = Object.values(scene.items).filter((it) => !it.fixed && !it.closed && t.accepts.includes(it.kind));
|
|
470
|
+
return [openMin(takes.map((it) => it.id), px(t.cross.min))];
|
|
435
471
|
});
|
|
436
472
|
const colMins = open2.length > 0 ? open2 : templates;
|
|
437
473
|
if (cmin !== void 0 && colMins.length > 0) {
|
|
474
|
+
const width = area3.width - (scene.insetWhen === "docked" && !docked ? px(scene.inset?.left) + px(scene.inset?.right) : 0);
|
|
438
475
|
const need = cmin + Math.min(...colMins) + gutter;
|
|
439
|
-
columnRoom =
|
|
440
|
-
if (!columnRoom) notes.push({ code: "no-column-room", width
|
|
476
|
+
columnRoom = width >= need - EPS;
|
|
477
|
+
if (!columnRoom) notes.push({ code: "no-column-room", width, need });
|
|
441
478
|
}
|
|
442
479
|
for (const c of shrinkOrder) {
|
|
443
480
|
const w = g.widths.get(c);
|
|
@@ -447,7 +484,9 @@ function solve(given, options = {}) {
|
|
|
447
484
|
let x0 = area3.x;
|
|
448
485
|
let x1 = area3.x + area3.width;
|
|
449
486
|
for (const side of ["left", "right"]) {
|
|
450
|
-
const
|
|
487
|
+
const outsideSideBar = (c) => isOutsideSideBar(scene, c.edge) && !g.railed(c) && !g.riding(c);
|
|
488
|
+
const all = cols.filter((c) => c.side === side);
|
|
489
|
+
const mine = [...all.filter(outsideSideBar), ...all.filter((c) => !outsideSideBar(c))];
|
|
451
490
|
const railed = mine.filter((c) => g.railed(c));
|
|
452
491
|
const riders = mine.filter((c) => g.riding(c));
|
|
453
492
|
const host = mine.find((c) => c.dyn && c.edge.column === true && !c.hand && !g.auto.has(c) && c.width > 0);
|
|
@@ -459,19 +498,22 @@ function solve(given, options = {}) {
|
|
|
459
498
|
const ridersTop = riders.reduce((s, c) => s + riderBars(c).reduce((t, b) => t + b.h, 0), 0);
|
|
460
499
|
let railRect = null;
|
|
461
500
|
let gap = px(side === "left" ? inset.left : inset.right);
|
|
501
|
+
let barLaid = false;
|
|
462
502
|
for (const c of mine) {
|
|
463
|
-
if (!railRect && railed.length > 0) {
|
|
503
|
+
if (!railRect && railed.length > 0 && !outsideSideBar(c)) {
|
|
464
504
|
const w2 = railW(side);
|
|
505
|
+
const lead = barLaid ? gap : 0;
|
|
506
|
+
const after = barLaid ? Math.max(gap, gutter) : gutter;
|
|
465
507
|
if (side === "left") {
|
|
466
|
-
railRect = rect(x0, area3.y, w2, H);
|
|
467
|
-
x0 += w2 +
|
|
508
|
+
railRect = rect(x0 - lead, area3.y, w2, H);
|
|
509
|
+
x0 += w2 - lead + after;
|
|
468
510
|
} else {
|
|
469
|
-
x1
|
|
470
|
-
|
|
471
|
-
x1 -= gutter;
|
|
511
|
+
railRect = rect(x1 + lead - w2, area3.y, w2, H);
|
|
512
|
+
x1 -= w2 - lead + after;
|
|
472
513
|
}
|
|
473
|
-
gap =
|
|
514
|
+
gap = after;
|
|
474
515
|
}
|
|
516
|
+
if (outsideSideBar(c)) barLaid = true;
|
|
475
517
|
const base = { side: c.edge.side, ring: finite(c.edge.ring, 0), cross: 0, menu: null, tabs: [], stack: c.solved.stack, free: c.solved.free };
|
|
476
518
|
if (g.railed(c)) {
|
|
477
519
|
edges[c.edge.id] = { ...base, rect: rect(railRect.x, area3.y, 0, H), folded: g.auto.has(c) ? "auto" : "hand" };
|
|
@@ -550,9 +592,13 @@ function solve(given, options = {}) {
|
|
|
550
592
|
}
|
|
551
593
|
return rect(x0, area3.y, Math.max(0, x1 - x0), H);
|
|
552
594
|
};
|
|
553
|
-
let area2 = rect(stage.x + px(inset.left), stage.y + px(inset.top), Math.max(0, stage.width - px(inset.left) - px(inset.right)), Math.max(0, stage.height - px(inset.top) - px(inset.bottom)));
|
|
554
595
|
const reserved = order.filter((e) => e.mode !== "overlay");
|
|
555
|
-
|
|
596
|
+
const outsideBar = (e) => !isSide(e) && e.span !== "between" && e.outsideInset === true;
|
|
597
|
+
let outer = stage;
|
|
598
|
+
for (const e of reserved) if (outsideBar(e)) outer = lay(e, outer, true);
|
|
599
|
+
outerArea = outer;
|
|
600
|
+
let area2 = rect(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)));
|
|
601
|
+
for (const e of reserved) if (!isSide(e) && e.span !== "between" && !outsideBar(e)) area2 = lay(e, area2, true);
|
|
556
602
|
area2 = laySides(reserved.filter(isSide), area2);
|
|
557
603
|
for (const e of reserved) if (!isSide(e) && e.span === "between") area2 = lay(e, area2, true);
|
|
558
604
|
const content = area2;
|
|
@@ -589,8 +635,9 @@ function solve(given, options = {}) {
|
|
|
589
635
|
continue;
|
|
590
636
|
}
|
|
591
637
|
const from = shape.form;
|
|
592
|
-
const
|
|
593
|
-
const
|
|
638
|
+
const fo = f.orient ?? floatOrientOf(it);
|
|
639
|
+
const form = formsOf(it, fo)[from];
|
|
640
|
+
const row = fo === "row";
|
|
594
641
|
const floor = {
|
|
595
642
|
width: it.floatMin ? px(it.floatMin.width) : Math.min(shape.width, px(row ? form?.main.min : form?.cross.min)),
|
|
596
643
|
height: it.floatMin ? px(it.floatMin.height) : Math.min(shape.height, px(row ? form?.cross.min : form?.main.min))
|
|
@@ -604,7 +651,7 @@ function solve(given, options = {}) {
|
|
|
604
651
|
if (fit.clamped) notes.push({ code: "float-clamped", id: f.id });
|
|
605
652
|
if (fit.snapped) notes.push({ code: "float-moved", id: f.id });
|
|
606
653
|
if (fit.covers.length > 0) notes.push({ code: "float-covers", id: f.id });
|
|
607
|
-
items[f.id] = { ...shapeOf(form, fit.rect,
|
|
654
|
+
items[f.id] = { ...shapeOf(form, fit.rect, fo, fit.rect.width), rect: fit.rect, kind: it.kind, form: from, formKind: form?.kind ?? "open", floating: true };
|
|
608
655
|
floats.push(f.id);
|
|
609
656
|
}
|
|
610
657
|
return { items, edges, content, floats, rails, ...columnRoom !== void 0 ? { columnRoom } : {}, notes };
|
|
@@ -660,10 +707,21 @@ function newColumn(scene, side, kind, ring, items) {
|
|
|
660
707
|
column: true
|
|
661
708
|
};
|
|
662
709
|
}
|
|
663
|
-
function
|
|
710
|
+
function sideRings(edges, side) {
|
|
711
|
+
return new Map(closeRings(edges, /* @__PURE__ */ new Set([side])).filter((e) => e.side === side).map((e) => [e.id, e.ring]));
|
|
712
|
+
}
|
|
713
|
+
function columnFloor(edges, side) {
|
|
714
|
+
const mine = edges.filter((e) => e.side === side).sort((a, b) => a.ring - b.ring);
|
|
715
|
+
let n = 0;
|
|
716
|
+
while (n < mine.length && mine[n].column !== true) n++;
|
|
717
|
+
return n;
|
|
718
|
+
}
|
|
719
|
+
function insertColumn(scene0, id, side, ring) {
|
|
720
|
+
const scene = { ...scene0, edges: closeRings(scene0.edges, /* @__PURE__ */ new Set([side])) };
|
|
664
721
|
const kind = scene.items[id].kind;
|
|
665
722
|
const mine = scene.edges.filter((e) => e.side === side);
|
|
666
|
-
const
|
|
723
|
+
const floor = columnFloor(scene.edges, side);
|
|
724
|
+
const r = Math.max(floor, Math.min(Number.isNaN(ring) ? Infinity : Math.floor(ring), mine.length === 0 ? 0 : Math.max(...mine.map((e) => e.ring)) + 1));
|
|
667
725
|
const col = newColumn(scene, side, kind, r, [id]);
|
|
668
726
|
if (!col) return null;
|
|
669
727
|
if (!zoneTakes(col, "start", kind)) return null;
|
|
@@ -718,7 +776,7 @@ function floatAt(scene, id, at, orient2) {
|
|
|
718
776
|
if (!item || item.fixed || !scene.floatKinds.includes(item.kind)) return scene;
|
|
719
777
|
const was = scene.floats.find((f) => f.id === id);
|
|
720
778
|
const o = orient2 ?? was?.orient;
|
|
721
|
-
const size = item
|
|
779
|
+
const size = floatSizeOf(item, o ?? floatOrientOf(item));
|
|
722
780
|
const float = at ? { id, rect: { x: at.x, y: at.y, width: at.width, height: at.height }, ...o ? { orient: o } : {} } : { id, rect: { x: 0, y: 0, width: size.width, height: size.height }, anchor: "content-top-right", ...o ? { orient: o } : {} };
|
|
723
781
|
const next = at && at.width > 0 && at.height > 0 ? { ...item, floatSize: { width: at.width, height: at.height } } : item;
|
|
724
782
|
const lifted = lift(withItem(scene, next), id);
|
|
@@ -763,7 +821,8 @@ function raise(scene, id) {
|
|
|
763
821
|
}
|
|
764
822
|
function orient(scene, id, to) {
|
|
765
823
|
const i = scene.floats.findIndex((f) => f.id === id);
|
|
766
|
-
|
|
824
|
+
const item = scene.items[id];
|
|
825
|
+
if (i < 0 || !item || (scene.floats[i].orient ?? floatOrientOf(item)) === to) return scene;
|
|
767
826
|
return { ...scene, floats: scene.floats.map((f, k) => k === i ? { ...f, orient: to } : f) };
|
|
768
827
|
}
|
|
769
828
|
function resize(scene, edgeId, size) {
|
|
@@ -795,7 +854,7 @@ function homeFor(scene, id, start) {
|
|
|
795
854
|
const next = e.items.slice(k + 1).find((x) => now.includes(x));
|
|
796
855
|
return { kind: "gap", edge: e.id, zone, at: next ? now.indexOf(next) : now.length };
|
|
797
856
|
}
|
|
798
|
-
if (e.column === true && (e.side === "left" || e.side === "right")) return { kind: "column", side: e.side, ring: e.ring };
|
|
857
|
+
if (e.column === true && (e.side === "left" || e.side === "right")) return { kind: "column", side: e.side, ring: sideRings(start.edges, e.side).get(e.id) ?? e.ring };
|
|
799
858
|
return null;
|
|
800
859
|
}
|
|
801
860
|
const f = start.floats.find((x) => x.id === id);
|
|
@@ -1034,6 +1093,73 @@ function cutClear(hit, blockers, keep2) {
|
|
|
1034
1093
|
}
|
|
1035
1094
|
return area(h) > EPS2 ? h : null;
|
|
1036
1095
|
}
|
|
1096
|
+
var GAP_KEEP = 16;
|
|
1097
|
+
function homeOnlyOverItsPlace(out, now) {
|
|
1098
|
+
const dragged = out[0]?.item;
|
|
1099
|
+
const mine = dragged !== void 0 ? now.items[dragged] : void 0;
|
|
1100
|
+
const side = mine?.edge ? now.edges[mine.edge]?.side : void 0;
|
|
1101
|
+
if (!mine || !side) return;
|
|
1102
|
+
const column = side === "left" || side === "right";
|
|
1103
|
+
const r = mine.rect;
|
|
1104
|
+
const band = DEFAULT_HIT_BAND / 2;
|
|
1105
|
+
const edgeOf = (t) => t.id.startsWith("gap:") ? t.id.split(":")[1] : void 0;
|
|
1106
|
+
const zoneOfId = (t) => t.id.startsWith("gap:") ? t.id.split(":")[2] : void 0;
|
|
1107
|
+
const span = (x) => column ? [x.hit.y, x.hit.y + x.hit.height] : [x.hit.x, x.hit.x + x.hit.width];
|
|
1108
|
+
const cross = (x) => column ? [x.hit.x, x.hit.x + x.hit.width] : [x.hit.y, x.hit.y + x.hit.height];
|
|
1109
|
+
const make = (x, from, to, c) => {
|
|
1110
|
+
const [c02, c12] = c ?? cross(x);
|
|
1111
|
+
return { ...x, hit: column ? rect(c02, from, c12 - c02, to - from) : rect(from, c02, to - from, c12 - c02) };
|
|
1112
|
+
};
|
|
1113
|
+
const homes = out.filter((t) => t.place.kind === "home" && edgeOf(t) === mine.edge);
|
|
1114
|
+
const mid = column ? r.y + r.height / 2 : r.x + r.width / 2;
|
|
1115
|
+
let h0 = (column ? r.y : r.x) - band;
|
|
1116
|
+
let h1 = (column ? r.y + r.height : r.x + r.width) + band;
|
|
1117
|
+
const c0 = Math.min(...homes.map((h) => cross(h)[0]));
|
|
1118
|
+
const c1 = Math.max(...homes.map((h) => cross(h)[1]));
|
|
1119
|
+
const first = homes[0];
|
|
1120
|
+
for (const h of homes.slice(1)) out.splice(out.indexOf(h), 1);
|
|
1121
|
+
const at = first ? out.indexOf(first) : -1;
|
|
1122
|
+
if (first) out.splice(at, 1);
|
|
1123
|
+
for (let i = 0; i < out.length; i++) {
|
|
1124
|
+
const x = out[i];
|
|
1125
|
+
if (x.place.kind !== "gap" || edgeOf(x) !== mine.edge) continue;
|
|
1126
|
+
const [s0, s1] = span(x);
|
|
1127
|
+
if (s1 <= h0 + EPS2 || s0 >= h1 - EPS2) continue;
|
|
1128
|
+
const keep2 = Math.min(GAP_KEEP, s1 - s0);
|
|
1129
|
+
if (s0 < h0) {
|
|
1130
|
+
const e = Math.min(s1, Math.max(h0, s0 + keep2));
|
|
1131
|
+
out[i] = make(x, s0, e);
|
|
1132
|
+
h0 = Math.max(h0, e);
|
|
1133
|
+
} else if (s1 > h1) {
|
|
1134
|
+
const b = Math.max(s0, Math.min(h1, s1 - keep2));
|
|
1135
|
+
out[i] = make(x, b, s1);
|
|
1136
|
+
h1 = Math.min(h1, b);
|
|
1137
|
+
} else {
|
|
1138
|
+
const line = x.marker ? column ? x.marker.y : x.marker.x : (s0 + s1) / 2;
|
|
1139
|
+
let a = Math.min(Math.max(line - keep2 / 2, s0), s1 - keep2);
|
|
1140
|
+
if (a <= mid + 1 && a + keep2 >= mid - 1) a = (s0 + s1) / 2 < mid ? mid - 1 - keep2 : mid + 1;
|
|
1141
|
+
out[i] = make(x, a, a + keep2);
|
|
1142
|
+
if (a + keep2 <= mid + EPS2) h0 = Math.max(h0, a + keep2);
|
|
1143
|
+
else h1 = Math.min(h1, a);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
const others = (x) => out.filter((y) => y !== x && y.place.kind === "gap" && edgeOf(y) === mine.edge).map(span);
|
|
1147
|
+
for (const h of homes) {
|
|
1148
|
+
const [a0, a1] = span(h);
|
|
1149
|
+
const near = out.filter((x) => x.place.kind === "gap" && edgeOf(x) === mine.edge && zoneOfId(x) === zoneOfId(h));
|
|
1150
|
+
const before = near.find((x) => Math.abs(span(x)[1] - a0) < 1);
|
|
1151
|
+
const after = near.find((x) => Math.abs(span(x)[0] - a1) < 1);
|
|
1152
|
+
if (before && a0 < h0 - EPS2) {
|
|
1153
|
+
const stop = Math.min(a1, h0, ...others(before).filter(([b]) => b >= span(before)[1] - EPS2).map(([b]) => b));
|
|
1154
|
+
if (stop > span(before)[1]) out[out.indexOf(before)] = make(before, span(before)[0], stop);
|
|
1155
|
+
}
|
|
1156
|
+
if (after && a1 > h1 + EPS2) {
|
|
1157
|
+
const stop = Math.max(a0, h1, ...others(after).filter(([, e]) => e <= span(after)[0] + EPS2).map(([, e]) => e));
|
|
1158
|
+
if (stop < span(after)[0]) out[out.indexOf(after)] = make(after, stop, span(after)[1]);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
if (first && h1 - h0 > EPS2) out.splice(Math.min(at, out.length), 0, make(first, h0, h1, [c0, c1]));
|
|
1162
|
+
}
|
|
1037
1163
|
function targets(scene, dragged, options = {}) {
|
|
1038
1164
|
const item = Object.hasOwn(scene.items, dragged) ? scene.items[dragged] : void 0;
|
|
1039
1165
|
if (!item || item.fixed || item.closed) return [];
|
|
@@ -1092,6 +1218,7 @@ function targets(scene, dragged, options = {}) {
|
|
|
1092
1218
|
if (own2) out.push({ id: t.id, priority: t.priority, hit: t.hit, item: dragged, place: { kind: "home" }, after: () => ({ scene, layout: now }) });
|
|
1093
1219
|
else if (sound(t.after({ x: 0, y: 0 }).layout)) out.push(t);
|
|
1094
1220
|
}
|
|
1221
|
+
homeOnlyOverItsPlace(out, now);
|
|
1095
1222
|
const edgeOfGap = (t) => t.place.kind === "gap" ? rest.edges.find((e) => e.id === t.place.edge) : void 0;
|
|
1096
1223
|
const plainGapHits = out.filter((t) => t.id.startsWith("gap:") && !edgeOfGap(t)?.compact).map((t) => t.hit);
|
|
1097
1224
|
for (let i = 0; i < out.length; i++) {
|
|
@@ -1114,6 +1241,8 @@ function targets(scene, dragged, options = {}) {
|
|
|
1114
1241
|
const x1 = Math.min(t.hit.x + t.hit.width, c.x + c.width);
|
|
1115
1242
|
const y1 = Math.min(t.hit.y + t.hit.height, c.y + c.height);
|
|
1116
1243
|
const docks = [...Object.entries(base.edges), ...Object.entries(now.edges).filter(([id]) => id !== now.items[dragged]?.edge)].filter(([id, d]) => id !== e.id && area(d.rect) > EPS2).map(([, d]) => d.rect);
|
|
1244
|
+
const mineNow = now.items[dragged];
|
|
1245
|
+
if (mineNow?.edge && !mineNow.floating) docks.push(mineNow.rect);
|
|
1117
1246
|
const h = e.compact ? t.hit : x1 - x0 > EPS2 && y1 - y0 > EPS2 ? cutAway(rect(x0, y0, x1 - x0, y1 - y0), docks) : null;
|
|
1118
1247
|
if (!h) {
|
|
1119
1248
|
out.splice(i, 1);
|
|
@@ -1128,15 +1257,26 @@ function targets(scene, dragged, options = {}) {
|
|
|
1128
1257
|
if (g0 <= a0 + EPS2 && g1 > a0) a0 = Math.min(a1, g1);
|
|
1129
1258
|
else if (g1 >= a1 - EPS2 && g0 < a1) a1 = Math.max(a0, g0);
|
|
1130
1259
|
}
|
|
1131
|
-
if (a1 - a0
|
|
1260
|
+
if (a1 - a0 < 1) out.splice(i, 1);
|
|
1132
1261
|
else {
|
|
1133
1262
|
const hit = vertical ? rect(h.x, a0, h.width, a1 - a0) : rect(a0, h.y, a1 - a0, h.height);
|
|
1134
1263
|
if (hit.x !== t.hit.x || hit.y !== t.hit.y || hit.width !== t.hit.width || hit.height !== t.hit.height) out[i] = { ...t, hit };
|
|
1135
1264
|
}
|
|
1136
1265
|
}
|
|
1266
|
+
const mineHere = now.items[dragged];
|
|
1267
|
+
if (mineHere?.edge && !mineHere.floating) {
|
|
1268
|
+
for (let i = out.length - 1; i >= 0; i--) {
|
|
1269
|
+
const t = out[i];
|
|
1270
|
+
if (t.place.kind !== "rail" || !overlaps(t.hit, mineHere.rect)) continue;
|
|
1271
|
+
const h = cutAway(t.hit, [mineHere.rect]);
|
|
1272
|
+
if (!h || h.width < 1 || h.height < 1) out.splice(i, 1);
|
|
1273
|
+
else out[i] = { ...t, hit: h };
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1137
1276
|
if (scene.floatKinds.includes(item.kind)) {
|
|
1138
1277
|
const was = scene.floats.find((f) => f.id === dragged);
|
|
1139
|
-
const
|
|
1278
|
+
const fo = options.floatOrient ?? was?.orient ?? floatOrientOf(item);
|
|
1279
|
+
const size = options.floatSize ?? (was ? { width: was.rect.width, height: was.rect.height } : floatSizeOf(item, fo));
|
|
1140
1280
|
out.push({
|
|
1141
1281
|
id: `float:${dragged}`,
|
|
1142
1282
|
priority: 3,
|
|
@@ -1147,9 +1287,9 @@ function targets(scene, dragged, options = {}) {
|
|
|
1147
1287
|
after(point, grab) {
|
|
1148
1288
|
const g = grab ?? { x: size.width / 2, y: size.height / 2 };
|
|
1149
1289
|
const raw = rect(point.x - g.x, point.y - g.y, size.width, size.height);
|
|
1150
|
-
const first = solve(use(floatAt(scene, dragged, raw), dragged), prev);
|
|
1290
|
+
const first = solve(use(floatAt(scene, dragged, raw, options.floatOrient), dragged), prev);
|
|
1151
1291
|
const at = first.items[dragged]?.rect ?? raw;
|
|
1152
|
-
return settle(use(floatAt(scene, dragged, rect(at.x, at.y, size.width, size.height)), dragged));
|
|
1292
|
+
return settle(use(floatAt(scene, dragged, rect(at.x, at.y, size.width, size.height), options.floatOrient), dragged));
|
|
1153
1293
|
}
|
|
1154
1294
|
});
|
|
1155
1295
|
}
|
|
@@ -1193,13 +1333,14 @@ function sideSpan(base, side) {
|
|
|
1193
1333
|
function columnTargets(scene, rest, base, side, dragged, blockers, settle) {
|
|
1194
1334
|
const cols = openColumns(rest, base, side);
|
|
1195
1335
|
const span = sideSpan(base, side);
|
|
1196
|
-
const
|
|
1197
|
-
const
|
|
1336
|
+
const rings = sideRings(rest.edges, side);
|
|
1337
|
+
const ringOf = (e) => rings.get(e.id) ?? e.ring;
|
|
1338
|
+
const inner = rings.size;
|
|
1198
1339
|
const lines = [];
|
|
1199
1340
|
const outerX = (r) => side === "left" ? r.x : r.x + r.width;
|
|
1200
1341
|
const innerX = (r) => side === "left" ? r.x + r.width : r.x;
|
|
1201
|
-
cols.forEach((c) => lines.push({ x: outerX(c.r), ring: c.edge
|
|
1202
|
-
if (cols.length > 0) lines.push({ x: innerX(cols[cols.length - 1].r), ring: cols[cols.length - 1].edge
|
|
1342
|
+
cols.forEach((c) => lines.push({ x: outerX(c.r), ring: ringOf(c.edge) }));
|
|
1343
|
+
if (cols.length > 0) lines.push({ x: innerX(cols[cols.length - 1].r), ring: ringOf(cols[cols.length - 1].edge) + 1 });
|
|
1203
1344
|
else lines.push({ x: side === "left" ? base.content.x : base.content.x + base.content.width, ring: inner });
|
|
1204
1345
|
const out = [];
|
|
1205
1346
|
for (const line of lines) {
|
|
@@ -1217,8 +1358,9 @@ function columnTargets(scene, rest, base, side, dragged, blockers, settle) {
|
|
|
1217
1358
|
}
|
|
1218
1359
|
function railTargets(scene, rest, base, side, dragged, blockers, settle) {
|
|
1219
1360
|
const rail = base.rails[side];
|
|
1220
|
-
const
|
|
1221
|
-
const
|
|
1361
|
+
const rings = sideRings(rest.edges, side);
|
|
1362
|
+
const mine = rest.edges.filter((e) => e.side === side).sort((a, b) => (rings.get(a.id) ?? 0) - (rings.get(b.id) ?? 0));
|
|
1363
|
+
const ringOf = (id) => rings.get(id) ?? 0;
|
|
1222
1364
|
const stops2 = [];
|
|
1223
1365
|
let zone;
|
|
1224
1366
|
if (rail && rail.segments.length > 0) {
|
|
@@ -1235,10 +1377,12 @@ function railTargets(scene, rest, base, side, dragged, blockers, settle) {
|
|
|
1235
1377
|
} else {
|
|
1236
1378
|
const span = sideSpan(base, side);
|
|
1237
1379
|
const firstCol = mine.find((e) => e.column === true);
|
|
1238
|
-
const
|
|
1239
|
-
const
|
|
1380
|
+
const bars = new Set(rest.edges.filter((e) => e.side === side && isOutsideSideBar(rest, e)).map((e) => e.id));
|
|
1381
|
+
const inner = Object.entries(base.edges).filter(([id, e]) => bars.has(id) && e.rect.height > 0 && e.rect.width > 0).map(([, e]) => side === "left" ? e.rect.x + e.rect.width : e.rect.x);
|
|
1382
|
+
const pad = Number.isFinite(rest.inset?.[side]) ? Math.max(0, rest.inset[side]) : 0;
|
|
1383
|
+
const x = inner.length > 0 ? side === "left" ? Math.max(...inner) : Math.min(...inner) : side === "left" ? rest.stage.x + pad : rest.stage.x + rest.stage.width - pad;
|
|
1240
1384
|
zone = rect(side === "left" ? x : x - RAIL_EDGE, span.y, RAIL_EDGE, span.height);
|
|
1241
|
-
stops2.push({ y: span.y, ring: firstCol ? firstCol.
|
|
1385
|
+
stops2.push({ y: span.y, ring: firstCol ? ringOf(firstCol.id) : mine.length });
|
|
1242
1386
|
}
|
|
1243
1387
|
const out = [];
|
|
1244
1388
|
stops2.forEach((s, i) => {
|
|
@@ -1255,6 +1399,35 @@ function railTargets(scene, rest, base, side, dragged, blockers, settle) {
|
|
|
1255
1399
|
});
|
|
1256
1400
|
return out;
|
|
1257
1401
|
}
|
|
1402
|
+
function refusals(scene, dragged, options = {}) {
|
|
1403
|
+
const item = Object.hasOwn(scene.items, dragged) ? scene.items[dragged] : void 0;
|
|
1404
|
+
if (!item || item.fixed || item.closed) return [];
|
|
1405
|
+
const prev = { ...options.previous ? { previous: options.previous } : {}, ...options.fresh ? { fresh: options.fresh } : {} };
|
|
1406
|
+
const ts = targets(scene, dragged, options).filter((t) => !t.free);
|
|
1407
|
+
const base = solve(lift(scene, dragged), prev);
|
|
1408
|
+
const hits = ts.map((t) => t.hit);
|
|
1409
|
+
const out = [];
|
|
1410
|
+
const add = (edge, zone, hit, reason) => {
|
|
1411
|
+
const clear = cutAway(hit, hits);
|
|
1412
|
+
if (clear) out.push({ id: `refuse:${edge}:${zone}`, edge, zone, hit: clear, reason });
|
|
1413
|
+
};
|
|
1414
|
+
for (const e of scene.edges) {
|
|
1415
|
+
const r = base.edges[e.id]?.rect;
|
|
1416
|
+
if (!r || r.width <= EPS2 || r.height <= EPS2) continue;
|
|
1417
|
+
const bar = (e.side === "top" || e.side === "bottom") && !e.compact;
|
|
1418
|
+
if (!bar) {
|
|
1419
|
+
if (!e.accepts.includes(item.kind)) add(e.id, "start", r, "not-accepted");
|
|
1420
|
+
continue;
|
|
1421
|
+
}
|
|
1422
|
+
ZONES.forEach((zone, k) => {
|
|
1423
|
+
const third = rect(r.x + r.width * k / 3, r.y, r.width / 3, r.height);
|
|
1424
|
+
const mine = ts.some((t) => (t.place.kind === "gap" || t.place.kind === "home") && t.id.startsWith(`gap:${e.id}:`) && overlaps(t.hit, third));
|
|
1425
|
+
if (mine) return;
|
|
1426
|
+
add(e.id, zone, third, zoneTakes(e, zone, item.kind) ? "no-room" : "not-accepted");
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
return out;
|
|
1430
|
+
}
|
|
1258
1431
|
var SIDE_RANK = { left: 0, top: 1, bottom: 2, right: 3 };
|
|
1259
1432
|
function stops(scene, dragged, options = {}) {
|
|
1260
1433
|
const list = targets(scene, dragged, options).filter((t) => t.place.kind !== "home" && t.place.kind !== "none");
|
|
@@ -1463,6 +1636,9 @@ export {
|
|
|
1463
1636
|
DEFAULT_STRIP,
|
|
1464
1637
|
DEFAULT_HIT_BAND,
|
|
1465
1638
|
DEFAULT_FLOAT_SIZE,
|
|
1639
|
+
isOutsideSideBar,
|
|
1640
|
+
floatOrientOf,
|
|
1641
|
+
floatSizeOf,
|
|
1466
1642
|
solve,
|
|
1467
1643
|
lift,
|
|
1468
1644
|
moveTo,
|
|
@@ -1482,6 +1658,7 @@ export {
|
|
|
1482
1658
|
readScene,
|
|
1483
1659
|
targets,
|
|
1484
1660
|
reservedRect,
|
|
1661
|
+
refusals,
|
|
1485
1662
|
stops
|
|
1486
1663
|
};
|
|
1487
|
-
//# sourceMappingURL=chunk-
|
|
1664
|
+
//# sourceMappingURL=chunk-4DEXHBXT.js.map
|