dsh-talk-map 0.1.5 → 0.1.6
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/client/client.js +415 -391
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -10844,275 +10844,6 @@ function pickFaces(from, to, obstacles, options) {
|
|
|
10844
10844
|
return { fromHandle: fromSide, toHandle: toSide };
|
|
10845
10845
|
}
|
|
10846
10846
|
|
|
10847
|
-
// src/client/edge-route.ts
|
|
10848
|
-
var DEFAULTS = { margin: 10, stub: 14, minCorridor: 28 };
|
|
10849
|
-
function anchorOf(rect, face) {
|
|
10850
|
-
switch (face) {
|
|
10851
|
-
case "r":
|
|
10852
|
-
return { x: rect.x + rect.w, y: rect.y + rect.h / 2 };
|
|
10853
|
-
case "l":
|
|
10854
|
-
return { x: rect.x, y: rect.y + rect.h / 2 };
|
|
10855
|
-
case "t":
|
|
10856
|
-
return { x: rect.x + rect.w / 2, y: rect.y };
|
|
10857
|
-
default:
|
|
10858
|
-
return { x: rect.x + rect.w / 2, y: rect.y + rect.h };
|
|
10859
|
-
}
|
|
10860
|
-
}
|
|
10861
|
-
function normalOf(face) {
|
|
10862
|
-
switch (face) {
|
|
10863
|
-
case "r":
|
|
10864
|
-
return { x: 1, y: 0 };
|
|
10865
|
-
case "l":
|
|
10866
|
-
return { x: -1, y: 0 };
|
|
10867
|
-
case "t":
|
|
10868
|
-
return { x: 0, y: -1 };
|
|
10869
|
-
default:
|
|
10870
|
-
return { x: 0, y: 1 };
|
|
10871
|
-
}
|
|
10872
|
-
}
|
|
10873
|
-
function expand(rect, by) {
|
|
10874
|
-
return { x: rect.x - by, y: rect.y - by, w: rect.w + by * 2, h: rect.h + by * 2 };
|
|
10875
|
-
}
|
|
10876
|
-
function insideStrict(rect, point) {
|
|
10877
|
-
return point.x > rect.x && point.x < rect.x + rect.w && point.y > rect.y && point.y < rect.y + rect.h;
|
|
10878
|
-
}
|
|
10879
|
-
function hitsHorizontal(rects, y, x1, x2) {
|
|
10880
|
-
const lo = Math.min(x1, x2);
|
|
10881
|
-
const hi = Math.max(x1, x2);
|
|
10882
|
-
for (const rect of rects) {
|
|
10883
|
-
if (y <= rect.y || y >= rect.y + rect.h) continue;
|
|
10884
|
-
if (hi <= rect.x || lo >= rect.x + rect.w) continue;
|
|
10885
|
-
return true;
|
|
10886
|
-
}
|
|
10887
|
-
return false;
|
|
10888
|
-
}
|
|
10889
|
-
function hitsVertical(rects, x, y1, y2) {
|
|
10890
|
-
const lo = Math.min(y1, y2);
|
|
10891
|
-
const hi = Math.max(y1, y2);
|
|
10892
|
-
for (const rect of rects) {
|
|
10893
|
-
if (x <= rect.x || x >= rect.x + rect.w) continue;
|
|
10894
|
-
if (hi <= rect.y || lo >= rect.y + rect.h) continue;
|
|
10895
|
-
return true;
|
|
10896
|
-
}
|
|
10897
|
-
return false;
|
|
10898
|
-
}
|
|
10899
|
-
function bands(rects, axis) {
|
|
10900
|
-
const spans = rects.map((rect) => axis === "x" ? { start: rect.x, end: rect.x + rect.w } : { start: rect.y, end: rect.y + rect.h }).sort((a, b) => a.start - b.start);
|
|
10901
|
-
const out = [];
|
|
10902
|
-
for (const span of spans) {
|
|
10903
|
-
const last = out[out.length - 1];
|
|
10904
|
-
if (last !== void 0 && span.start <= last.end) {
|
|
10905
|
-
last.end = Math.max(last.end, span.end);
|
|
10906
|
-
} else {
|
|
10907
|
-
out.push({ ...span });
|
|
10908
|
-
}
|
|
10909
|
-
}
|
|
10910
|
-
return out;
|
|
10911
|
-
}
|
|
10912
|
-
function corridors(rects, axis, minCorridor) {
|
|
10913
|
-
const merged = bands(rects, axis);
|
|
10914
|
-
const out = [];
|
|
10915
|
-
for (let index2 = 1; index2 < merged.length; index2 += 1) {
|
|
10916
|
-
const gap = merged[index2].start - merged[index2 - 1].end;
|
|
10917
|
-
if (gap >= minCorridor) out.push((merged[index2 - 1].end + merged[index2].start) / 2);
|
|
10918
|
-
}
|
|
10919
|
-
return out;
|
|
10920
|
-
}
|
|
10921
|
-
function outerLines(rects, axis, clearance) {
|
|
10922
|
-
const merged = bands(rects, axis);
|
|
10923
|
-
const out = [];
|
|
10924
|
-
for (const band of merged) {
|
|
10925
|
-
out.push(band.start - clearance, band.end + clearance);
|
|
10926
|
-
}
|
|
10927
|
-
return out;
|
|
10928
|
-
}
|
|
10929
|
-
var Heap = class {
|
|
10930
|
-
items = [];
|
|
10931
|
-
push(cost, key, node) {
|
|
10932
|
-
this.items.push({ cost, key, node });
|
|
10933
|
-
let index2 = this.items.length - 1;
|
|
10934
|
-
while (index2 > 0) {
|
|
10935
|
-
const parent = index2 - 1 >> 1;
|
|
10936
|
-
if (this.items[parent].cost <= this.items[index2].cost) break;
|
|
10937
|
-
const tmp = this.items[parent];
|
|
10938
|
-
this.items[parent] = this.items[index2];
|
|
10939
|
-
this.items[index2] = tmp;
|
|
10940
|
-
index2 = parent;
|
|
10941
|
-
}
|
|
10942
|
-
}
|
|
10943
|
-
pop() {
|
|
10944
|
-
if (this.items.length === 0) return void 0;
|
|
10945
|
-
const top = this.items[0];
|
|
10946
|
-
const last = this.items.pop();
|
|
10947
|
-
if (this.items.length > 0) {
|
|
10948
|
-
this.items[0] = last;
|
|
10949
|
-
let index2 = 0;
|
|
10950
|
-
for (; ; ) {
|
|
10951
|
-
const left = index2 * 2 + 1;
|
|
10952
|
-
const right = left + 1;
|
|
10953
|
-
let smallest = index2;
|
|
10954
|
-
if (left < this.items.length && this.items[left].cost < this.items[smallest].cost) smallest = left;
|
|
10955
|
-
if (right < this.items.length && this.items[right].cost < this.items[smallest].cost) smallest = right;
|
|
10956
|
-
if (smallest === index2) break;
|
|
10957
|
-
const tmp = this.items[smallest];
|
|
10958
|
-
this.items[smallest] = this.items[index2];
|
|
10959
|
-
this.items[index2] = tmp;
|
|
10960
|
-
index2 = smallest;
|
|
10961
|
-
}
|
|
10962
|
-
}
|
|
10963
|
-
return { key: top.key, node: top.node };
|
|
10964
|
-
}
|
|
10965
|
-
get size() {
|
|
10966
|
-
return this.items.length;
|
|
10967
|
-
}
|
|
10968
|
-
};
|
|
10969
|
-
function dedupe(values, epsilon = 0.5) {
|
|
10970
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
10971
|
-
const out = [];
|
|
10972
|
-
for (const value of sorted) {
|
|
10973
|
-
if (out.length === 0 || Math.abs(value - out[out.length - 1]) > epsilon) out.push(value);
|
|
10974
|
-
}
|
|
10975
|
-
return out;
|
|
10976
|
-
}
|
|
10977
|
-
function simplify(points) {
|
|
10978
|
-
const out = [];
|
|
10979
|
-
for (const point of points) {
|
|
10980
|
-
const last = out[out.length - 1];
|
|
10981
|
-
if (last !== void 0 && Math.abs(last.x - point.x) < 0.5 && Math.abs(last.y - point.y) < 0.5) continue;
|
|
10982
|
-
out.push(point);
|
|
10983
|
-
}
|
|
10984
|
-
for (let index2 = 1; index2 < out.length - 1; ) {
|
|
10985
|
-
const a = out[index2 - 1];
|
|
10986
|
-
const b = out[index2];
|
|
10987
|
-
const c = out[index2 + 1];
|
|
10988
|
-
const collinear = Math.abs(a.x - b.x) < 0.5 && Math.abs(b.x - c.x) < 0.5 || Math.abs(a.y - b.y) < 0.5 && Math.abs(b.y - c.y) < 0.5;
|
|
10989
|
-
if (collinear) out.splice(index2, 1);
|
|
10990
|
-
else index2 += 1;
|
|
10991
|
-
}
|
|
10992
|
-
return out;
|
|
10993
|
-
}
|
|
10994
|
-
function routeEdge(from, to, fromFace, toFace, obstacles, options = {}) {
|
|
10995
|
-
const margin = options.margin ?? DEFAULTS.margin;
|
|
10996
|
-
const stub = options.stub ?? DEFAULTS.stub;
|
|
10997
|
-
const minCorridor = options.minCorridor ?? DEFAULTS.minCorridor;
|
|
10998
|
-
const start2 = anchorOf(from, fromFace);
|
|
10999
|
-
const end = anchorOf(to, toFace);
|
|
11000
|
-
const startNormal = normalOf(fromFace);
|
|
11001
|
-
const endNormal = normalOf(toFace);
|
|
11002
|
-
const startStub = { x: start2.x + startNormal.x * stub, y: start2.y + startNormal.y * stub };
|
|
11003
|
-
const endStub = { x: end.x + endNormal.x * stub, y: end.y + endNormal.y * stub };
|
|
11004
|
-
const blocked = obstacles.filter((rect) => rect !== from && rect !== to).map((rect) => expand(rect, margin));
|
|
11005
|
-
const fallback = simplify([start2, startStub, { x: endStub.x, y: startStub.y }, endStub, end]);
|
|
11006
|
-
const xs = corridors(obstacles, "x", minCorridor);
|
|
11007
|
-
const ys = corridors(obstacles, "y", minCorridor);
|
|
11008
|
-
const xOuter = outerLines(obstacles, "x", margin + 6);
|
|
11009
|
-
const yOuter = outerLines(obstacles, "y", margin + 6);
|
|
11010
|
-
const xCands = dedupe([start2.x, end.x, startStub.x, endStub.x, ...xs, ...xOuter]);
|
|
11011
|
-
const yCands = dedupe([start2.y, end.y, startStub.y, endStub.y, ...ys, ...yOuter]);
|
|
11012
|
-
if (xCands.length > 60 || yCands.length > 60) return fallback;
|
|
11013
|
-
const corridorX = new Set(xs.map((value) => Math.round(value)));
|
|
11014
|
-
const corridorY = new Set(ys.map((value) => Math.round(value)));
|
|
11015
|
-
const nodeId = (ix, iy) => `${ix},${iy}`;
|
|
11016
|
-
const pointAt = (id2) => {
|
|
11017
|
-
const [ix, iy] = id2.split(",").map(Number);
|
|
11018
|
-
return { x: xCands[ix], y: yCands[iy] };
|
|
11019
|
-
};
|
|
11020
|
-
const startIndex = { x: xCands.findIndex((value) => Math.abs(value - startStub.x) < 0.5), y: yCands.findIndex((value) => Math.abs(value - startStub.y) < 0.5) };
|
|
11021
|
-
const endIndex = { x: xCands.findIndex((value) => Math.abs(value - endStub.x) < 0.5), y: yCands.findIndex((value) => Math.abs(value - endStub.y) < 0.5) };
|
|
11022
|
-
if (startIndex.x < 0 || startIndex.y < 0 || endIndex.x < 0 || endIndex.y < 0) return fallback;
|
|
11023
|
-
const goal = { x: endStub.x, y: endStub.y };
|
|
11024
|
-
const startNode = nodeId(startIndex.x, startIndex.y);
|
|
11025
|
-
const goalNode = nodeId(endIndex.x, endIndex.y);
|
|
11026
|
-
const best = /* @__PURE__ */ new Map();
|
|
11027
|
-
const cameFrom = /* @__PURE__ */ new Map();
|
|
11028
|
-
const heap = new Heap();
|
|
11029
|
-
const withDir = (node, dir) => `${node}|${dir}`;
|
|
11030
|
-
best.set(withDir(startNode, "x"), 0);
|
|
11031
|
-
heap.push(0, 0, withDir(startNode, "x"));
|
|
11032
|
-
const estimate = (point) => Math.abs(point.x - goal.x) + Math.abs(point.y - goal.y);
|
|
11033
|
-
while (heap.size > 0) {
|
|
11034
|
-
const popped = heap.pop();
|
|
11035
|
-
const state3 = popped.node;
|
|
11036
|
-
const [node, dir] = state3.split("|");
|
|
11037
|
-
const cost = best.get(state3);
|
|
11038
|
-
if (cost === void 0) continue;
|
|
11039
|
-
if (node === goalNode) {
|
|
11040
|
-
const path = [];
|
|
11041
|
-
let cursor = state3;
|
|
11042
|
-
while (cursor !== void 0) {
|
|
11043
|
-
const [cell] = cursor.split("|");
|
|
11044
|
-
path.push(pointAt(cell));
|
|
11045
|
-
cursor = cameFrom.get(cursor);
|
|
11046
|
-
}
|
|
11047
|
-
path.reverse();
|
|
11048
|
-
return simplify([start2, startStub, ...path.slice(1), endStub, end]);
|
|
11049
|
-
}
|
|
11050
|
-
const [ix, iy] = node.split(",").map(Number);
|
|
11051
|
-
const here = pointAt(node);
|
|
11052
|
-
const steps = [
|
|
11053
|
-
{ dx: 1, dy: 0, axis: "x" },
|
|
11054
|
-
{ dx: -1, dy: 0, axis: "x" },
|
|
11055
|
-
{ dx: 0, dy: 1, axis: "y" },
|
|
11056
|
-
{ dx: 0, dy: -1, axis: "y" }
|
|
11057
|
-
];
|
|
11058
|
-
for (const step2 of steps) {
|
|
11059
|
-
const nx = ix + step2.dx;
|
|
11060
|
-
const ny = iy + step2.dy;
|
|
11061
|
-
if (nx < 0 || ny < 0 || nx >= xCands.length || ny >= yCands.length) continue;
|
|
11062
|
-
const next = { x: xCands[nx], y: yCands[ny] };
|
|
11063
|
-
const nextNode = nodeId(nx, ny);
|
|
11064
|
-
if (nextNode !== goalNode && blocked.some((rect) => insideStrict(rect, next))) continue;
|
|
11065
|
-
const clear = step2.axis === "x" ? !hitsHorizontal(blocked, here.y, here.x, next.x) : !hitsVertical(blocked, here.x, here.y, next.y);
|
|
11066
|
-
if (!clear) continue;
|
|
11067
|
-
const distance2 = Math.abs(next.x - here.x) + Math.abs(next.y - here.y);
|
|
11068
|
-
const onCorridor = step2.axis === "x" ? corridorY.has(Math.round(here.y)) : corridorX.has(Math.round(here.x));
|
|
11069
|
-
const turn = dir === step2.axis ? 0 : 18;
|
|
11070
|
-
const prefer = onCorridor ? 0 : 6;
|
|
11071
|
-
const nextCost = cost + distance2 + turn + prefer;
|
|
11072
|
-
const nextState = withDir(nextNode, step2.axis);
|
|
11073
|
-
const known = best.get(nextState);
|
|
11074
|
-
if (known !== void 0 && known <= nextCost) continue;
|
|
11075
|
-
best.set(nextState, nextCost);
|
|
11076
|
-
cameFrom.set(nextState, state3);
|
|
11077
|
-
heap.push(nextCost + estimate(next), nextCost, nextState);
|
|
11078
|
-
}
|
|
11079
|
-
}
|
|
11080
|
-
return fallback;
|
|
11081
|
-
}
|
|
11082
|
-
function roundedPath(points, radius = 10) {
|
|
11083
|
-
if (points.length === 0) return "";
|
|
11084
|
-
if (points.length === 1) return `M ${round(points[0].x)} ${round(points[0].y)}`;
|
|
11085
|
-
const parts = [`M ${round(points[0].x)} ${round(points[0].y)}`];
|
|
11086
|
-
for (let index2 = 1; index2 < points.length - 1; index2 += 1) {
|
|
11087
|
-
const prev = points[index2 - 1];
|
|
11088
|
-
const here = points[index2];
|
|
11089
|
-
const next = points[index2 + 1];
|
|
11090
|
-
const inLength = Math.hypot(here.x - prev.x, here.y - prev.y);
|
|
11091
|
-
const outLength = Math.hypot(next.x - here.x, next.y - here.y);
|
|
11092
|
-
const corner = Math.min(radius, inLength / 2, outLength / 2);
|
|
11093
|
-
if (corner < 0.5) {
|
|
11094
|
-
parts.push(`L ${round(here.x)} ${round(here.y)}`);
|
|
11095
|
-
continue;
|
|
11096
|
-
}
|
|
11097
|
-
const enter = {
|
|
11098
|
-
x: here.x + (prev.x - here.x) / (inLength || 1) * corner,
|
|
11099
|
-
y: here.y + (prev.y - here.y) / (inLength || 1) * corner
|
|
11100
|
-
};
|
|
11101
|
-
const leave = {
|
|
11102
|
-
x: here.x + (next.x - here.x) / (outLength || 1) * corner,
|
|
11103
|
-
y: here.y + (next.y - here.y) / (outLength || 1) * corner
|
|
11104
|
-
};
|
|
11105
|
-
parts.push(`L ${round(enter.x)} ${round(enter.y)}`);
|
|
11106
|
-
parts.push(`Q ${round(here.x)} ${round(here.y)} ${round(leave.x)} ${round(leave.y)}`);
|
|
11107
|
-
}
|
|
11108
|
-
const last = points[points.length - 1];
|
|
11109
|
-
parts.push(`L ${round(last.x)} ${round(last.y)}`);
|
|
11110
|
-
return parts.join(" ");
|
|
11111
|
-
}
|
|
11112
|
-
function round(value) {
|
|
11113
|
-
return Math.round(value * 100) / 100;
|
|
11114
|
-
}
|
|
11115
|
-
|
|
11116
10847
|
// src/client/push-log.ts
|
|
11117
10848
|
var KEY = "dsh.talk-map.push-log.v1";
|
|
11118
10849
|
function pairKey(fromCardId, toCardId) {
|
|
@@ -11899,112 +11630,401 @@ function ContextMenu(props) {
|
|
|
11899
11630
|
setBusy(false);
|
|
11900
11631
|
}
|
|
11901
11632
|
};
|
|
11902
|
-
(0, import_react5.useEffect)(() => {
|
|
11903
|
-
const release = mapUi.claimEscape("context-menu");
|
|
11904
|
-
const onKeyDown = (event) => {
|
|
11905
|
-
if (event.key === "Escape") {
|
|
11906
|
-
event.stopPropagation();
|
|
11907
|
-
props.onClose();
|
|
11633
|
+
(0, import_react5.useEffect)(() => {
|
|
11634
|
+
const release = mapUi.claimEscape("context-menu");
|
|
11635
|
+
const onKeyDown = (event) => {
|
|
11636
|
+
if (event.key === "Escape") {
|
|
11637
|
+
event.stopPropagation();
|
|
11638
|
+
props.onClose();
|
|
11639
|
+
}
|
|
11640
|
+
};
|
|
11641
|
+
window.addEventListener("keydown", onKeyDown);
|
|
11642
|
+
return () => {
|
|
11643
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
11644
|
+
release();
|
|
11645
|
+
};
|
|
11646
|
+
}, []);
|
|
11647
|
+
(0, import_react5.useEffect)(() => {
|
|
11648
|
+
if (menu.searchable === true || menu.prompt !== void 0) inputRef.current?.focus();
|
|
11649
|
+
}, [menu.searchable, menu.prompt]);
|
|
11650
|
+
const normalized = query.trim().toLowerCase();
|
|
11651
|
+
const visible = normalized === "" ? menu.items : menu.items.filter((item) => item.label.toLowerCase().includes(normalized));
|
|
11652
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
11653
|
+
"div",
|
|
11654
|
+
{
|
|
11655
|
+
className: talk_map_default["menu"],
|
|
11656
|
+
style: { left: menu.left, top: menu.top },
|
|
11657
|
+
role: "menu",
|
|
11658
|
+
onClick: (event) => {
|
|
11659
|
+
event.stopPropagation();
|
|
11660
|
+
},
|
|
11661
|
+
onPointerDown: (event) => {
|
|
11662
|
+
event.stopPropagation();
|
|
11663
|
+
},
|
|
11664
|
+
onContextMenu: (event) => {
|
|
11665
|
+
event.preventDefault();
|
|
11666
|
+
},
|
|
11667
|
+
children: [
|
|
11668
|
+
menu.title !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: talk_map_default["menuTitle"], children: menu.title }) : null,
|
|
11669
|
+
menu.prompt !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
11670
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
11671
|
+
"input",
|
|
11672
|
+
{
|
|
11673
|
+
ref: inputRef,
|
|
11674
|
+
className: talk_map_default["menuSearch"],
|
|
11675
|
+
placeholder: menu.prompt.placeholder,
|
|
11676
|
+
value: query,
|
|
11677
|
+
onChange: (event) => {
|
|
11678
|
+
setQuery(event.target.value);
|
|
11679
|
+
},
|
|
11680
|
+
onKeyDown: (event) => {
|
|
11681
|
+
if (event.key === "Enter") {
|
|
11682
|
+
event.preventDefault();
|
|
11683
|
+
void submitPrompt();
|
|
11684
|
+
}
|
|
11685
|
+
}
|
|
11686
|
+
}
|
|
11687
|
+
),
|
|
11688
|
+
menu.prompt.preview !== void 0 && query.trim() !== "" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: talk_map_default["menuPreview"], children: menu.prompt.preview(query.trim()) }) : null,
|
|
11689
|
+
error !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: talk_map_default["menuError"], children: error }) : null,
|
|
11690
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
11691
|
+
"button",
|
|
11692
|
+
{
|
|
11693
|
+
type: "button",
|
|
11694
|
+
className: talk_map_default["menuItem"],
|
|
11695
|
+
disabled: busy || query.trim() === "",
|
|
11696
|
+
onClick: () => {
|
|
11697
|
+
void submitPrompt();
|
|
11698
|
+
},
|
|
11699
|
+
children: busy ? t("menu.working") : menu.prompt.submitLabel
|
|
11700
|
+
}
|
|
11701
|
+
)
|
|
11702
|
+
] }) : null,
|
|
11703
|
+
menu.searchable === true ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
11704
|
+
"input",
|
|
11705
|
+
{
|
|
11706
|
+
ref: inputRef,
|
|
11707
|
+
className: talk_map_default["menuSearch"],
|
|
11708
|
+
placeholder: t("menu.search"),
|
|
11709
|
+
value: query,
|
|
11710
|
+
onChange: (event) => {
|
|
11711
|
+
setQuery(event.target.value);
|
|
11712
|
+
}
|
|
11713
|
+
}
|
|
11714
|
+
) : null,
|
|
11715
|
+
menu.prompt !== void 0 ? null : visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: talk_map_default["menuEmpty"], children: t("menu.empty") }) : visible.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
11716
|
+
"button",
|
|
11717
|
+
{
|
|
11718
|
+
type: "button",
|
|
11719
|
+
role: "menuitem",
|
|
11720
|
+
className: `${talk_map_default["menuItem"]}${item.danger === true ? ` ${talk_map_default["menuItemDanger"] ?? ""}` : ""}`,
|
|
11721
|
+
disabled: item.disabled === true,
|
|
11722
|
+
onClick: () => {
|
|
11723
|
+
item.onPick();
|
|
11724
|
+
},
|
|
11725
|
+
children: [
|
|
11726
|
+
item.icon !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MenuIcon, { name: item.icon }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: talk_map_default["menuIcon"] }),
|
|
11727
|
+
item.label,
|
|
11728
|
+
item.hint !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: talk_map_default["menuHint"], children: [
|
|
11729
|
+
" ",
|
|
11730
|
+
item.hint
|
|
11731
|
+
] }) : null
|
|
11732
|
+
]
|
|
11733
|
+
},
|
|
11734
|
+
item.key
|
|
11735
|
+
))
|
|
11736
|
+
]
|
|
11737
|
+
}
|
|
11738
|
+
);
|
|
11739
|
+
}
|
|
11740
|
+
|
|
11741
|
+
// src/client/edge-route.ts
|
|
11742
|
+
var DEFAULTS = { margin: 10, stub: 14, minCorridor: 28 };
|
|
11743
|
+
function anchorOf(rect, face) {
|
|
11744
|
+
switch (face) {
|
|
11745
|
+
case "r":
|
|
11746
|
+
return { x: rect.x + rect.w, y: rect.y + rect.h / 2 };
|
|
11747
|
+
case "l":
|
|
11748
|
+
return { x: rect.x, y: rect.y + rect.h / 2 };
|
|
11749
|
+
case "t":
|
|
11750
|
+
return { x: rect.x + rect.w / 2, y: rect.y };
|
|
11751
|
+
default:
|
|
11752
|
+
return { x: rect.x + rect.w / 2, y: rect.y + rect.h };
|
|
11753
|
+
}
|
|
11754
|
+
}
|
|
11755
|
+
function normalOf(face) {
|
|
11756
|
+
switch (face) {
|
|
11757
|
+
case "r":
|
|
11758
|
+
return { x: 1, y: 0 };
|
|
11759
|
+
case "l":
|
|
11760
|
+
return { x: -1, y: 0 };
|
|
11761
|
+
case "t":
|
|
11762
|
+
return { x: 0, y: -1 };
|
|
11763
|
+
default:
|
|
11764
|
+
return { x: 0, y: 1 };
|
|
11765
|
+
}
|
|
11766
|
+
}
|
|
11767
|
+
function expand(rect, by) {
|
|
11768
|
+
return { x: rect.x - by, y: rect.y - by, w: rect.w + by * 2, h: rect.h + by * 2 };
|
|
11769
|
+
}
|
|
11770
|
+
function insideStrict(rect, point) {
|
|
11771
|
+
return point.x > rect.x && point.x < rect.x + rect.w && point.y > rect.y && point.y < rect.y + rect.h;
|
|
11772
|
+
}
|
|
11773
|
+
function hitsHorizontal(rects, y, x1, x2) {
|
|
11774
|
+
const lo = Math.min(x1, x2);
|
|
11775
|
+
const hi = Math.max(x1, x2);
|
|
11776
|
+
for (const rect of rects) {
|
|
11777
|
+
if (y <= rect.y || y >= rect.y + rect.h) continue;
|
|
11778
|
+
if (hi <= rect.x || lo >= rect.x + rect.w) continue;
|
|
11779
|
+
return true;
|
|
11780
|
+
}
|
|
11781
|
+
return false;
|
|
11782
|
+
}
|
|
11783
|
+
function hitsVertical(rects, x, y1, y2) {
|
|
11784
|
+
const lo = Math.min(y1, y2);
|
|
11785
|
+
const hi = Math.max(y1, y2);
|
|
11786
|
+
for (const rect of rects) {
|
|
11787
|
+
if (x <= rect.x || x >= rect.x + rect.w) continue;
|
|
11788
|
+
if (hi <= rect.y || lo >= rect.y + rect.h) continue;
|
|
11789
|
+
return true;
|
|
11790
|
+
}
|
|
11791
|
+
return false;
|
|
11792
|
+
}
|
|
11793
|
+
function bands(rects, axis) {
|
|
11794
|
+
const spans = rects.map((rect) => axis === "x" ? { start: rect.x, end: rect.x + rect.w } : { start: rect.y, end: rect.y + rect.h }).sort((a, b) => a.start - b.start);
|
|
11795
|
+
const out = [];
|
|
11796
|
+
for (const span of spans) {
|
|
11797
|
+
const last = out[out.length - 1];
|
|
11798
|
+
if (last !== void 0 && span.start <= last.end) {
|
|
11799
|
+
last.end = Math.max(last.end, span.end);
|
|
11800
|
+
} else {
|
|
11801
|
+
out.push({ ...span });
|
|
11802
|
+
}
|
|
11803
|
+
}
|
|
11804
|
+
return out;
|
|
11805
|
+
}
|
|
11806
|
+
function corridors(rects, axis, minCorridor) {
|
|
11807
|
+
const merged = bands(rects, axis);
|
|
11808
|
+
const out = [];
|
|
11809
|
+
for (let index2 = 1; index2 < merged.length; index2 += 1) {
|
|
11810
|
+
const gap = merged[index2].start - merged[index2 - 1].end;
|
|
11811
|
+
if (gap >= minCorridor) out.push((merged[index2 - 1].end + merged[index2].start) / 2);
|
|
11812
|
+
}
|
|
11813
|
+
return out;
|
|
11814
|
+
}
|
|
11815
|
+
function outerLines(rects, axis, clearance) {
|
|
11816
|
+
const merged = bands(rects, axis);
|
|
11817
|
+
const out = [];
|
|
11818
|
+
for (const band of merged) {
|
|
11819
|
+
out.push(band.start - clearance, band.end + clearance);
|
|
11820
|
+
}
|
|
11821
|
+
return out;
|
|
11822
|
+
}
|
|
11823
|
+
var Heap = class {
|
|
11824
|
+
items = [];
|
|
11825
|
+
push(cost, key, node) {
|
|
11826
|
+
this.items.push({ cost, key, node });
|
|
11827
|
+
let index2 = this.items.length - 1;
|
|
11828
|
+
while (index2 > 0) {
|
|
11829
|
+
const parent = index2 - 1 >> 1;
|
|
11830
|
+
if (this.items[parent].cost <= this.items[index2].cost) break;
|
|
11831
|
+
const tmp = this.items[parent];
|
|
11832
|
+
this.items[parent] = this.items[index2];
|
|
11833
|
+
this.items[index2] = tmp;
|
|
11834
|
+
index2 = parent;
|
|
11835
|
+
}
|
|
11836
|
+
}
|
|
11837
|
+
pop() {
|
|
11838
|
+
if (this.items.length === 0) return void 0;
|
|
11839
|
+
const top = this.items[0];
|
|
11840
|
+
const last = this.items.pop();
|
|
11841
|
+
if (this.items.length > 0) {
|
|
11842
|
+
this.items[0] = last;
|
|
11843
|
+
let index2 = 0;
|
|
11844
|
+
for (; ; ) {
|
|
11845
|
+
const left = index2 * 2 + 1;
|
|
11846
|
+
const right = left + 1;
|
|
11847
|
+
let smallest = index2;
|
|
11848
|
+
if (left < this.items.length && this.items[left].cost < this.items[smallest].cost) smallest = left;
|
|
11849
|
+
if (right < this.items.length && this.items[right].cost < this.items[smallest].cost) smallest = right;
|
|
11850
|
+
if (smallest === index2) break;
|
|
11851
|
+
const tmp = this.items[smallest];
|
|
11852
|
+
this.items[smallest] = this.items[index2];
|
|
11853
|
+
this.items[index2] = tmp;
|
|
11854
|
+
index2 = smallest;
|
|
11855
|
+
}
|
|
11856
|
+
}
|
|
11857
|
+
return { key: top.key, node: top.node };
|
|
11858
|
+
}
|
|
11859
|
+
get size() {
|
|
11860
|
+
return this.items.length;
|
|
11861
|
+
}
|
|
11862
|
+
};
|
|
11863
|
+
function dedupe(values, epsilon = 0.5) {
|
|
11864
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
11865
|
+
const out = [];
|
|
11866
|
+
for (const value of sorted) {
|
|
11867
|
+
if (out.length === 0 || Math.abs(value - out[out.length - 1]) > epsilon) out.push(value);
|
|
11868
|
+
}
|
|
11869
|
+
return out;
|
|
11870
|
+
}
|
|
11871
|
+
function simplify(points) {
|
|
11872
|
+
const out = [];
|
|
11873
|
+
for (const point of points) {
|
|
11874
|
+
const last = out[out.length - 1];
|
|
11875
|
+
if (last !== void 0 && Math.abs(last.x - point.x) < 0.5 && Math.abs(last.y - point.y) < 0.5) continue;
|
|
11876
|
+
out.push(point);
|
|
11877
|
+
}
|
|
11878
|
+
for (let index2 = 1; index2 < out.length - 1; ) {
|
|
11879
|
+
const a = out[index2 - 1];
|
|
11880
|
+
const b = out[index2];
|
|
11881
|
+
const c = out[index2 + 1];
|
|
11882
|
+
const collinear = Math.abs(a.x - b.x) < 0.5 && Math.abs(b.x - c.x) < 0.5 || Math.abs(a.y - b.y) < 0.5 && Math.abs(b.y - c.y) < 0.5;
|
|
11883
|
+
if (collinear) out.splice(index2, 1);
|
|
11884
|
+
else index2 += 1;
|
|
11885
|
+
}
|
|
11886
|
+
return out;
|
|
11887
|
+
}
|
|
11888
|
+
function routeEdge(from, to, fromFace, toFace, obstacles, options = {}) {
|
|
11889
|
+
return routeBetween(
|
|
11890
|
+
{ start: anchorOf(from, fromFace), startFace: fromFace, end: anchorOf(to, toFace), endFace: toFace },
|
|
11891
|
+
from,
|
|
11892
|
+
to,
|
|
11893
|
+
obstacles,
|
|
11894
|
+
options
|
|
11895
|
+
);
|
|
11896
|
+
}
|
|
11897
|
+
function routeBetween(ends, from, to, obstacles, options = {}) {
|
|
11898
|
+
const margin = options.margin ?? DEFAULTS.margin;
|
|
11899
|
+
const stub = options.stub ?? DEFAULTS.stub;
|
|
11900
|
+
const minCorridor = options.minCorridor ?? DEFAULTS.minCorridor;
|
|
11901
|
+
const start2 = ends.start;
|
|
11902
|
+
const end = ends.end;
|
|
11903
|
+
const startNormal = normalOf(ends.startFace);
|
|
11904
|
+
const endNormal = normalOf(ends.endFace);
|
|
11905
|
+
const startStub = { x: start2.x + startNormal.x * stub, y: start2.y + startNormal.y * stub };
|
|
11906
|
+
const endStub = { x: end.x + endNormal.x * stub, y: end.y + endNormal.y * stub };
|
|
11907
|
+
const sameRect = (a, b) => Math.abs(a.x - b.x) < 0.5 && Math.abs(a.y - b.y) < 0.5 && Math.abs(a.w - b.w) < 0.5 && Math.abs(a.h - b.h) < 0.5;
|
|
11908
|
+
const blocked = obstacles.filter((rect) => !sameRect(rect, from) && !sameRect(rect, to)).map((rect) => expand(rect, margin));
|
|
11909
|
+
const fallback = simplify([start2, startStub, { x: endStub.x, y: startStub.y }, endStub, end]);
|
|
11910
|
+
const pad = 260;
|
|
11911
|
+
const window2 = {
|
|
11912
|
+
x1: Math.min(start2.x, end.x) - pad,
|
|
11913
|
+
x2: Math.max(start2.x, end.x) + pad,
|
|
11914
|
+
y1: Math.min(start2.y, end.y) - pad,
|
|
11915
|
+
y2: Math.max(start2.y, end.y) + pad
|
|
11916
|
+
};
|
|
11917
|
+
const near = obstacles.filter((rect) => rect.x + rect.w >= window2.x1 && rect.x <= window2.x2 && rect.y + rect.h >= window2.y1 && rect.y <= window2.y2);
|
|
11918
|
+
const withinX = (value) => value >= window2.x1 && value <= window2.x2;
|
|
11919
|
+
const withinY = (value) => value >= window2.y1 && value <= window2.y2;
|
|
11920
|
+
const xs = corridors(near, "x", minCorridor).filter(withinX);
|
|
11921
|
+
const ys = corridors(near, "y", minCorridor).filter(withinY);
|
|
11922
|
+
const xOuter = outerLines(near, "x", margin + 6).filter(withinX);
|
|
11923
|
+
const yOuter = outerLines(near, "y", margin + 6).filter(withinY);
|
|
11924
|
+
const xCands = dedupe([start2.x, end.x, startStub.x, endStub.x, ...xs, ...xOuter]);
|
|
11925
|
+
const yCands = dedupe([start2.y, end.y, startStub.y, endStub.y, ...ys, ...yOuter]);
|
|
11926
|
+
if (xCands.length > 96 || yCands.length > 96) return fallback;
|
|
11927
|
+
const corridorX = new Set(xs.map((value) => Math.round(value)));
|
|
11928
|
+
const corridorY = new Set(ys.map((value) => Math.round(value)));
|
|
11929
|
+
const nodeId = (ix, iy) => `${ix},${iy}`;
|
|
11930
|
+
const pointAt = (id2) => {
|
|
11931
|
+
const [ix, iy] = id2.split(",").map(Number);
|
|
11932
|
+
return { x: xCands[ix], y: yCands[iy] };
|
|
11933
|
+
};
|
|
11934
|
+
const startIndex = { x: xCands.findIndex((value) => Math.abs(value - startStub.x) < 0.5), y: yCands.findIndex((value) => Math.abs(value - startStub.y) < 0.5) };
|
|
11935
|
+
const endIndex = { x: xCands.findIndex((value) => Math.abs(value - endStub.x) < 0.5), y: yCands.findIndex((value) => Math.abs(value - endStub.y) < 0.5) };
|
|
11936
|
+
if (startIndex.x < 0 || startIndex.y < 0 || endIndex.x < 0 || endIndex.y < 0) return fallback;
|
|
11937
|
+
const goal = { x: endStub.x, y: endStub.y };
|
|
11938
|
+
const startNode = nodeId(startIndex.x, startIndex.y);
|
|
11939
|
+
const goalNode = nodeId(endIndex.x, endIndex.y);
|
|
11940
|
+
const best = /* @__PURE__ */ new Map();
|
|
11941
|
+
const cameFrom = /* @__PURE__ */ new Map();
|
|
11942
|
+
const heap = new Heap();
|
|
11943
|
+
const withDir = (node, dir) => `${node}|${dir}`;
|
|
11944
|
+
best.set(withDir(startNode, "x"), 0);
|
|
11945
|
+
heap.push(0, 0, withDir(startNode, "x"));
|
|
11946
|
+
const estimate = (point) => Math.abs(point.x - goal.x) + Math.abs(point.y - goal.y);
|
|
11947
|
+
while (heap.size > 0) {
|
|
11948
|
+
const popped = heap.pop();
|
|
11949
|
+
const state3 = popped.node;
|
|
11950
|
+
const [node, dir] = state3.split("|");
|
|
11951
|
+
const cost = best.get(state3);
|
|
11952
|
+
if (cost === void 0) continue;
|
|
11953
|
+
if (node === goalNode) {
|
|
11954
|
+
const path = [];
|
|
11955
|
+
let cursor = state3;
|
|
11956
|
+
while (cursor !== void 0) {
|
|
11957
|
+
const [cell] = cursor.split("|");
|
|
11958
|
+
path.push(pointAt(cell));
|
|
11959
|
+
cursor = cameFrom.get(cursor);
|
|
11908
11960
|
}
|
|
11961
|
+
path.reverse();
|
|
11962
|
+
return simplify([start2, startStub, ...path.slice(1), endStub, end]);
|
|
11963
|
+
}
|
|
11964
|
+
const [ix, iy] = node.split(",").map(Number);
|
|
11965
|
+
const here = pointAt(node);
|
|
11966
|
+
const steps = [
|
|
11967
|
+
{ dx: 1, dy: 0, axis: "x" },
|
|
11968
|
+
{ dx: -1, dy: 0, axis: "x" },
|
|
11969
|
+
{ dx: 0, dy: 1, axis: "y" },
|
|
11970
|
+
{ dx: 0, dy: -1, axis: "y" }
|
|
11971
|
+
];
|
|
11972
|
+
for (const step2 of steps) {
|
|
11973
|
+
const nx = ix + step2.dx;
|
|
11974
|
+
const ny = iy + step2.dy;
|
|
11975
|
+
if (nx < 0 || ny < 0 || nx >= xCands.length || ny >= yCands.length) continue;
|
|
11976
|
+
const next = { x: xCands[nx], y: yCands[ny] };
|
|
11977
|
+
const nextNode = nodeId(nx, ny);
|
|
11978
|
+
if (nextNode !== goalNode && blocked.some((rect) => insideStrict(rect, next))) continue;
|
|
11979
|
+
const clear = step2.axis === "x" ? !hitsHorizontal(blocked, here.y, here.x, next.x) : !hitsVertical(blocked, here.x, here.y, next.y);
|
|
11980
|
+
if (!clear) continue;
|
|
11981
|
+
const distance2 = Math.abs(next.x - here.x) + Math.abs(next.y - here.y);
|
|
11982
|
+
const onCorridor = step2.axis === "x" ? corridorY.has(Math.round(here.y)) : corridorX.has(Math.round(here.x));
|
|
11983
|
+
const turn = dir === step2.axis ? 0 : 18;
|
|
11984
|
+
const prefer = onCorridor ? 0 : 6;
|
|
11985
|
+
const nextCost = cost + distance2 + turn + prefer;
|
|
11986
|
+
const nextState = withDir(nextNode, step2.axis);
|
|
11987
|
+
const known = best.get(nextState);
|
|
11988
|
+
if (known !== void 0 && known <= nextCost) continue;
|
|
11989
|
+
best.set(nextState, nextCost);
|
|
11990
|
+
cameFrom.set(nextState, state3);
|
|
11991
|
+
heap.push(nextCost + estimate(next), nextCost, nextState);
|
|
11992
|
+
}
|
|
11993
|
+
}
|
|
11994
|
+
return fallback;
|
|
11995
|
+
}
|
|
11996
|
+
function roundedPath(points, radius = 10) {
|
|
11997
|
+
if (points.length === 0) return "";
|
|
11998
|
+
if (points.length === 1) return `M ${round(points[0].x)} ${round(points[0].y)}`;
|
|
11999
|
+
const parts = [`M ${round(points[0].x)} ${round(points[0].y)}`];
|
|
12000
|
+
for (let index2 = 1; index2 < points.length - 1; index2 += 1) {
|
|
12001
|
+
const prev = points[index2 - 1];
|
|
12002
|
+
const here = points[index2];
|
|
12003
|
+
const next = points[index2 + 1];
|
|
12004
|
+
const inLength = Math.hypot(here.x - prev.x, here.y - prev.y);
|
|
12005
|
+
const outLength = Math.hypot(next.x - here.x, next.y - here.y);
|
|
12006
|
+
const corner = Math.min(radius, inLength / 2, outLength / 2);
|
|
12007
|
+
if (corner < 0.5) {
|
|
12008
|
+
parts.push(`L ${round(here.x)} ${round(here.y)}`);
|
|
12009
|
+
continue;
|
|
12010
|
+
}
|
|
12011
|
+
const enter = {
|
|
12012
|
+
x: here.x + (prev.x - here.x) / (inLength || 1) * corner,
|
|
12013
|
+
y: here.y + (prev.y - here.y) / (inLength || 1) * corner
|
|
11909
12014
|
};
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
release();
|
|
12015
|
+
const leave = {
|
|
12016
|
+
x: here.x + (next.x - here.x) / (outLength || 1) * corner,
|
|
12017
|
+
y: here.y + (next.y - here.y) / (outLength || 1) * corner
|
|
11914
12018
|
};
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
|
|
11918
|
-
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11922
|
-
|
|
11923
|
-
|
|
11924
|
-
className: talk_map_default["menu"],
|
|
11925
|
-
style: { left: menu.left, top: menu.top },
|
|
11926
|
-
role: "menu",
|
|
11927
|
-
onClick: (event) => {
|
|
11928
|
-
event.stopPropagation();
|
|
11929
|
-
},
|
|
11930
|
-
onPointerDown: (event) => {
|
|
11931
|
-
event.stopPropagation();
|
|
11932
|
-
},
|
|
11933
|
-
onContextMenu: (event) => {
|
|
11934
|
-
event.preventDefault();
|
|
11935
|
-
},
|
|
11936
|
-
children: [
|
|
11937
|
-
menu.title !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: talk_map_default["menuTitle"], children: menu.title }) : null,
|
|
11938
|
-
menu.prompt !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
11939
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
11940
|
-
"input",
|
|
11941
|
-
{
|
|
11942
|
-
ref: inputRef,
|
|
11943
|
-
className: talk_map_default["menuSearch"],
|
|
11944
|
-
placeholder: menu.prompt.placeholder,
|
|
11945
|
-
value: query,
|
|
11946
|
-
onChange: (event) => {
|
|
11947
|
-
setQuery(event.target.value);
|
|
11948
|
-
},
|
|
11949
|
-
onKeyDown: (event) => {
|
|
11950
|
-
if (event.key === "Enter") {
|
|
11951
|
-
event.preventDefault();
|
|
11952
|
-
void submitPrompt();
|
|
11953
|
-
}
|
|
11954
|
-
}
|
|
11955
|
-
}
|
|
11956
|
-
),
|
|
11957
|
-
menu.prompt.preview !== void 0 && query.trim() !== "" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: talk_map_default["menuPreview"], children: menu.prompt.preview(query.trim()) }) : null,
|
|
11958
|
-
error !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: talk_map_default["menuError"], children: error }) : null,
|
|
11959
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
11960
|
-
"button",
|
|
11961
|
-
{
|
|
11962
|
-
type: "button",
|
|
11963
|
-
className: talk_map_default["menuItem"],
|
|
11964
|
-
disabled: busy || query.trim() === "",
|
|
11965
|
-
onClick: () => {
|
|
11966
|
-
void submitPrompt();
|
|
11967
|
-
},
|
|
11968
|
-
children: busy ? t("menu.working") : menu.prompt.submitLabel
|
|
11969
|
-
}
|
|
11970
|
-
)
|
|
11971
|
-
] }) : null,
|
|
11972
|
-
menu.searchable === true ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
11973
|
-
"input",
|
|
11974
|
-
{
|
|
11975
|
-
ref: inputRef,
|
|
11976
|
-
className: talk_map_default["menuSearch"],
|
|
11977
|
-
placeholder: t("menu.search"),
|
|
11978
|
-
value: query,
|
|
11979
|
-
onChange: (event) => {
|
|
11980
|
-
setQuery(event.target.value);
|
|
11981
|
-
}
|
|
11982
|
-
}
|
|
11983
|
-
) : null,
|
|
11984
|
-
menu.prompt !== void 0 ? null : visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: talk_map_default["menuEmpty"], children: t("menu.empty") }) : visible.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
11985
|
-
"button",
|
|
11986
|
-
{
|
|
11987
|
-
type: "button",
|
|
11988
|
-
role: "menuitem",
|
|
11989
|
-
className: `${talk_map_default["menuItem"]}${item.danger === true ? ` ${talk_map_default["menuItemDanger"] ?? ""}` : ""}`,
|
|
11990
|
-
disabled: item.disabled === true,
|
|
11991
|
-
onClick: () => {
|
|
11992
|
-
item.onPick();
|
|
11993
|
-
},
|
|
11994
|
-
children: [
|
|
11995
|
-
item.icon !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MenuIcon, { name: item.icon }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: talk_map_default["menuIcon"] }),
|
|
11996
|
-
item.label,
|
|
11997
|
-
item.hint !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: talk_map_default["menuHint"], children: [
|
|
11998
|
-
" ",
|
|
11999
|
-
item.hint
|
|
12000
|
-
] }) : null
|
|
12001
|
-
]
|
|
12002
|
-
},
|
|
12003
|
-
item.key
|
|
12004
|
-
))
|
|
12005
|
-
]
|
|
12006
|
-
}
|
|
12007
|
-
);
|
|
12019
|
+
parts.push(`L ${round(enter.x)} ${round(enter.y)}`);
|
|
12020
|
+
parts.push(`Q ${round(here.x)} ${round(here.y)} ${round(leave.x)} ${round(leave.y)}`);
|
|
12021
|
+
}
|
|
12022
|
+
const last = points[points.length - 1];
|
|
12023
|
+
parts.push(`L ${round(last.x)} ${round(last.y)}`);
|
|
12024
|
+
return parts.join(" ");
|
|
12025
|
+
}
|
|
12026
|
+
function round(value) {
|
|
12027
|
+
return Math.round(value * 100) / 100;
|
|
12008
12028
|
}
|
|
12009
12029
|
|
|
12010
12030
|
// src/client/TalkMapEdge.tsx
|
|
@@ -12013,7 +12033,26 @@ function TalkMapEdge(props) {
|
|
|
12013
12033
|
const data = props.data ?? {};
|
|
12014
12034
|
const synced = data.sync === "synced";
|
|
12015
12035
|
const hidden = synced && data.structural !== true;
|
|
12016
|
-
const
|
|
12036
|
+
const faceOf = (position) => {
|
|
12037
|
+
const name2 = String(position ?? "left");
|
|
12038
|
+
if (name2 === "right") return "r";
|
|
12039
|
+
if (name2 === "top") return "t";
|
|
12040
|
+
if (name2 === "bottom") return "b";
|
|
12041
|
+
return "l";
|
|
12042
|
+
};
|
|
12043
|
+
const obstacles = data.obstacles;
|
|
12044
|
+
const route = obstacles === void 0 ? void 0 : routeBetween(
|
|
12045
|
+
{
|
|
12046
|
+
start: { x: props.sourceX, y: props.sourceY },
|
|
12047
|
+
startFace: faceOf(props.sourcePosition),
|
|
12048
|
+
end: { x: props.targetX, y: props.targetY },
|
|
12049
|
+
endFace: faceOf(props.targetPosition)
|
|
12050
|
+
},
|
|
12051
|
+
// Endpoint bodies for the corridor maths; the router skips them by value.
|
|
12052
|
+
{ x: props.sourceX, y: props.sourceY, w: 0, h: 0 },
|
|
12053
|
+
{ x: props.targetX, y: props.targetY, w: 0, h: 0 },
|
|
12054
|
+
obstacles
|
|
12055
|
+
);
|
|
12017
12056
|
const routed = route !== void 0 && route.length > 1;
|
|
12018
12057
|
const [smoothPath] = getSmoothStepPath({
|
|
12019
12058
|
sourceX: props.sourceX,
|
|
@@ -13829,22 +13868,7 @@ function CanvasInner(props) {
|
|
|
13829
13868
|
if (card === void 0) return void 0;
|
|
13830
13869
|
return sessions.byId[card.sessionId]?.updatedAt;
|
|
13831
13870
|
};
|
|
13832
|
-
const
|
|
13833
|
-
const fromCard = canvasState.cards[fromCardId];
|
|
13834
|
-
const toCard = canvasState.cards[toCardId];
|
|
13835
|
-
if (fromCard === void 0 || toCard === void 0) return [];
|
|
13836
|
-
const faces = sideHandles(fromCardId, toCardId);
|
|
13837
|
-
const fromRect = { x: fromCard.x, y: fromCard.y, w: CARD_W, h: CARD_H };
|
|
13838
|
-
const toRect = { x: toCard.x, y: toCard.y, w: CARD_W, h: CARD_H };
|
|
13839
|
-
const others = Object.entries(canvasState.cards).filter(([id2]) => id2 !== fromCardId && id2 !== toCardId).filter(([id2]) => !foldedSet.has(id2)).map(([, card]) => ({ x: card.x, y: card.y, w: CARD_W, h: CARD_H }));
|
|
13840
|
-
return routeEdge(
|
|
13841
|
-
fromRect,
|
|
13842
|
-
toRect,
|
|
13843
|
-
faces.fromHandle,
|
|
13844
|
-
faces.toHandle,
|
|
13845
|
-
[fromRect, toRect, ...others]
|
|
13846
|
-
);
|
|
13847
|
-
};
|
|
13871
|
+
const obstaclesFor = (fromCardId, toCardId) => Object.entries(canvasState.cards).filter(([id2]) => id2 !== fromCardId && id2 !== toCardId).filter(([id2]) => !foldedSet.has(id2)).map(([, card]) => ({ x: card.x, y: card.y, w: CARD_W, h: CARD_H }));
|
|
13848
13872
|
const routingObstacles = () => Object.entries(canvasState.cards).map(([id2, card]) => ({
|
|
13849
13873
|
id: id2,
|
|
13850
13874
|
x: card.x,
|
|
@@ -13898,7 +13922,7 @@ function CanvasInner(props) {
|
|
|
13898
13922
|
fromCardId: edge.fromCardId,
|
|
13899
13923
|
toCardId: edge.toCardId,
|
|
13900
13924
|
sync,
|
|
13901
|
-
|
|
13925
|
+
obstacles: obstaclesFor(edge.fromCardId, edge.toCardId)
|
|
13902
13926
|
},
|
|
13903
13927
|
// Every line carries its direction now: 「推送摘要」 always travels
|
|
13904
13928
|
// source → target, so a link edge gets a lighter arrow instead of none.
|
|
@@ -13953,7 +13977,7 @@ function CanvasInner(props) {
|
|
|
13953
13977
|
toCardId: cardId,
|
|
13954
13978
|
sync: lineageSync,
|
|
13955
13979
|
structural: true,
|
|
13956
|
-
|
|
13980
|
+
obstacles: obstaclesFor(parentCardId, cardId)
|
|
13957
13981
|
},
|
|
13958
13982
|
// No inline stroke: inline style beats everything the renderer draws.
|
|
13959
13983
|
style: { opacity: 0.85 }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-talk-map",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Visual conversation map for DeepSeek Harness: an infinite whiteboard where every session is a card — drag to arrange, double-click to start a chat in place, draw an edge to fork a new session with injected context. Built for ADHD-friendly spatial memory. · DSH 可视化对话地图:会话即卡片,双击即聊,连线分叉带上下文的新对话。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|