dsh-talk-map 0.1.8 → 0.1.10
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 +71 -30
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -11739,6 +11739,7 @@ function ContextMenu(props) {
|
|
|
11739
11739
|
}
|
|
11740
11740
|
|
|
11741
11741
|
// src/client/edge-route.ts
|
|
11742
|
+
var __routeDebug = {};
|
|
11742
11743
|
var DEFAULTS = { margin: 14, stub: 22, minCorridor: 28 };
|
|
11743
11744
|
function anchorOf(rect, face) {
|
|
11744
11745
|
switch (face) {
|
|
@@ -11896,18 +11897,27 @@ function routeEdge(from, to, fromFace, toFace, obstacles, options = {}) {
|
|
|
11896
11897
|
}
|
|
11897
11898
|
function snapToChannels(points, obstacles, margin) {
|
|
11898
11899
|
if (points.length < 3) return points;
|
|
11899
|
-
const
|
|
11900
|
-
const
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
for (
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11900
|
+
const rects = obstacles;
|
|
11901
|
+
const centreFor = (horizontal, fixed, lo, hi) => {
|
|
11902
|
+
let low = -Infinity;
|
|
11903
|
+
let high = Infinity;
|
|
11904
|
+
for (const rect of rects) {
|
|
11905
|
+
if (horizontal) {
|
|
11906
|
+
if (rect.x + rect.w <= lo || rect.x >= hi) continue;
|
|
11907
|
+
if (rect.y + rect.h <= fixed + 0.5) low = Math.max(low, rect.y + rect.h);
|
|
11908
|
+
else if (rect.y >= fixed - 0.5) high = Math.min(high, rect.y);
|
|
11909
|
+
} else {
|
|
11910
|
+
if (rect.y + rect.h <= lo || rect.y >= hi) continue;
|
|
11911
|
+
if (rect.x + rect.w <= fixed + 0.5) low = Math.max(low, rect.x + rect.w);
|
|
11912
|
+
else if (rect.x >= fixed - 0.5) high = Math.min(high, rect.x);
|
|
11913
|
+
}
|
|
11908
11914
|
}
|
|
11909
|
-
return void 0;
|
|
11915
|
+
if (!Number.isFinite(low) || !Number.isFinite(high)) return void 0;
|
|
11916
|
+
const gap = high - low;
|
|
11917
|
+
if (gap < margin * 2 + 6) return void 0;
|
|
11918
|
+
return (low + high) / 2;
|
|
11910
11919
|
};
|
|
11920
|
+
const out = points.map((point) => ({ ...point }));
|
|
11911
11921
|
const last = out.length - 1;
|
|
11912
11922
|
const horizontalSegment = (index2) => Math.abs(out[index2 - 1].y - out[index2].y) < 0.6;
|
|
11913
11923
|
const fromStubHorizontal = horizontalSegment(1);
|
|
@@ -11918,21 +11928,32 @@ function snapToChannels(points, obstacles, margin) {
|
|
|
11918
11928
|
const horizontalRun = Math.abs(a.y - b.y) < 0.6;
|
|
11919
11929
|
if (index2 === 1 && horizontalRun === fromStubHorizontal) continue;
|
|
11920
11930
|
if (index2 === last - 1 && horizontalRun === toStubHorizontal) continue;
|
|
11931
|
+
const lo = horizontalRun ? Math.min(a.x, b.x) : Math.min(a.y, b.y);
|
|
11932
|
+
const hi = horizontalRun ? Math.max(a.x, b.x) : Math.max(a.y, b.y);
|
|
11933
|
+
const centre = centreFor(horizontalRun, horizontalRun ? a.y : a.x, lo, hi);
|
|
11934
|
+
if (centre === void 0) continue;
|
|
11921
11935
|
if (horizontalRun) {
|
|
11922
|
-
|
|
11923
|
-
|
|
11924
|
-
|
|
11925
|
-
b.y = centre;
|
|
11926
|
-
}
|
|
11936
|
+
if (Math.abs(centre - a.y) < 0.6) continue;
|
|
11937
|
+
a.y = centre;
|
|
11938
|
+
b.y = centre;
|
|
11927
11939
|
} else {
|
|
11928
|
-
|
|
11929
|
-
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
|
|
11940
|
+
if (Math.abs(centre - a.x) < 0.6) continue;
|
|
11941
|
+
a.x = centre;
|
|
11942
|
+
b.x = centre;
|
|
11943
|
+
}
|
|
11944
|
+
}
|
|
11945
|
+
const candidate = simplify(out);
|
|
11946
|
+
const sameRectSet = (point) => rects.some((rect) => point.x > rect.x && point.x < rect.x + rect.w && point.y > rect.y && point.y < rect.y + rect.h);
|
|
11947
|
+
for (let index2 = 1; index2 < candidate.length; index2 += 1) {
|
|
11948
|
+
const a = candidate[index2 - 1];
|
|
11949
|
+
const b = candidate[index2];
|
|
11950
|
+
const steps = Math.max(2, Math.ceil((Math.abs(b.x - a.x) + Math.abs(b.y - a.y)) / 4));
|
|
11951
|
+
for (let step2 = 0; step2 <= steps; step2 += 1) {
|
|
11952
|
+
const t2 = step2 / steps;
|
|
11953
|
+
if (sameRectSet({ x: a.x + (b.x - a.x) * t2, y: a.y + (b.y - a.y) * t2 })) return points;
|
|
11933
11954
|
}
|
|
11934
11955
|
}
|
|
11935
|
-
return
|
|
11956
|
+
return candidate;
|
|
11936
11957
|
}
|
|
11937
11958
|
function routeBetween(ends, from, to, obstacles, options = {}) {
|
|
11938
11959
|
const margin = options.margin ?? DEFAULTS.margin;
|
|
@@ -11945,8 +11966,10 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
|
|
|
11945
11966
|
const startStub = { x: start2.x + startNormal.x * stub, y: start2.y + startNormal.y * stub };
|
|
11946
11967
|
const endStub = { x: end.x + endNormal.x * stub, y: end.y + endNormal.y * stub };
|
|
11947
11968
|
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;
|
|
11948
|
-
const
|
|
11969
|
+
const overlaps = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
|
|
11970
|
+
const blocked = obstacles.filter((rect) => !sameRect(rect, from) && !sameRect(rect, to)).filter((rect) => !overlaps(rect, from) && !overlaps(rect, to)).map((rect) => expand(rect, margin));
|
|
11949
11971
|
const fallback = simplify([start2, startStub, { x: endStub.x, y: startStub.y }, endStub, end]);
|
|
11972
|
+
__routeDebug.last = { usedFallback: true };
|
|
11950
11973
|
const pad = 260;
|
|
11951
11974
|
const window2 = {
|
|
11952
11975
|
x1: Math.min(start2.x, end.x) - pad,
|
|
@@ -11961,18 +11984,35 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
|
|
|
11961
11984
|
const ys = corridors(near, "y", minCorridor).filter(withinY);
|
|
11962
11985
|
const xOuter = outerLines(near, "x", margin + 6).filter(withinX);
|
|
11963
11986
|
const yOuter = outerLines(near, "y", margin + 6).filter(withinY);
|
|
11964
|
-
const
|
|
11965
|
-
const
|
|
11966
|
-
|
|
11987
|
+
const hug = margin + 10;
|
|
11988
|
+
const xHug = near.flatMap((rect) => [rect.x - hug, rect.x + rect.w + hug]);
|
|
11989
|
+
const yHug = near.flatMap((rect) => [rect.y - hug, rect.y + rect.h + hug]);
|
|
11990
|
+
const xCands = dedupe([start2.x, end.x, startStub.x, endStub.x, ...xs, ...xOuter, ...xHug]);
|
|
11991
|
+
const yCands = dedupe([start2.y, end.y, startStub.y, endStub.y, ...ys, ...yOuter, ...yHug]);
|
|
11992
|
+
const trim = (values, mustKeep, limit) => {
|
|
11993
|
+
if (values.length <= limit) return values;
|
|
11994
|
+
const keep = new Set(mustKeep);
|
|
11995
|
+
const rest = values.filter((value) => !keep.has(value));
|
|
11996
|
+
const slots = Math.max(1, limit - keep.size);
|
|
11997
|
+
const stride = Math.max(1, Math.floor(rest.length / slots));
|
|
11998
|
+
for (let index2 = 0; index2 < rest.length && keep.size < limit; index2 += stride) {
|
|
11999
|
+
keep.add(rest[index2]);
|
|
12000
|
+
}
|
|
12001
|
+
return values.filter((value) => keep.has(value));
|
|
12002
|
+
};
|
|
12003
|
+
const MAX_LINES = 72;
|
|
12004
|
+
const xsTrimmed = xCands.length > MAX_LINES ? trim(xCands, [start2.x, end.x, startStub.x, endStub.x], MAX_LINES) : xCands;
|
|
12005
|
+
const ysTrimmed = yCands.length > MAX_LINES ? trim(yCands, [start2.y, end.y, startStub.y, endStub.y], MAX_LINES) : yCands;
|
|
12006
|
+
__routeDebug.candidates = { x: xsTrimmed.length, y: ysTrimmed.length, near: near.length };
|
|
11967
12007
|
const corridorX = new Set(xs.map((value) => Math.round(value)));
|
|
11968
12008
|
const corridorY = new Set(ys.map((value) => Math.round(value)));
|
|
11969
12009
|
const nodeId = (ix, iy) => `${ix},${iy}`;
|
|
11970
12010
|
const pointAt = (id2) => {
|
|
11971
12011
|
const [ix, iy] = id2.split(",").map(Number);
|
|
11972
|
-
return { x:
|
|
12012
|
+
return { x: xsTrimmed[ix], y: ysTrimmed[iy] };
|
|
11973
12013
|
};
|
|
11974
|
-
const startIndex = { x:
|
|
11975
|
-
const endIndex = { x:
|
|
12014
|
+
const startIndex = { x: xsTrimmed.findIndex((value) => Math.abs(value - startStub.x) < 0.5), y: ysTrimmed.findIndex((value) => Math.abs(value - startStub.y) < 0.5) };
|
|
12015
|
+
const endIndex = { x: xsTrimmed.findIndex((value) => Math.abs(value - endStub.x) < 0.5), y: ysTrimmed.findIndex((value) => Math.abs(value - endStub.y) < 0.5) };
|
|
11976
12016
|
if (startIndex.x < 0 || startIndex.y < 0 || endIndex.x < 0 || endIndex.y < 0) return fallback;
|
|
11977
12017
|
const goal = { x: endStub.x, y: endStub.y };
|
|
11978
12018
|
const startNode = nodeId(startIndex.x, startIndex.y);
|
|
@@ -11999,6 +12039,7 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
|
|
|
11999
12039
|
cursor = cameFrom.get(cursor);
|
|
12000
12040
|
}
|
|
12001
12041
|
path.reverse();
|
|
12042
|
+
__routeDebug.last = { usedFallback: false, steps: path.length };
|
|
12002
12043
|
return snapToChannels(
|
|
12003
12044
|
simplify([start2, startStub, ...path.slice(1), endStub, end]),
|
|
12004
12045
|
obstacles,
|
|
@@ -12016,8 +12057,8 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
|
|
|
12016
12057
|
for (const step2 of steps) {
|
|
12017
12058
|
const nx = ix + step2.dx;
|
|
12018
12059
|
const ny = iy + step2.dy;
|
|
12019
|
-
if (nx < 0 || ny < 0 || nx >=
|
|
12020
|
-
const next = { x:
|
|
12060
|
+
if (nx < 0 || ny < 0 || nx >= xsTrimmed.length || ny >= ysTrimmed.length) continue;
|
|
12061
|
+
const next = { x: xsTrimmed[nx], y: ysTrimmed[ny] };
|
|
12021
12062
|
const nextNode = nodeId(nx, ny);
|
|
12022
12063
|
if (nextNode !== goalNode && blocked.some((rect) => insideStrict(rect, next))) continue;
|
|
12023
12064
|
const clear = step2.axis === "x" ? !hitsHorizontal(blocked, here.y, here.x, next.x) : !hitsVertical(blocked, here.x, here.y, next.y);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-talk-map",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
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",
|