dsh-talk-map 0.1.8 → 0.1.9
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 +41 -21
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -11896,18 +11896,27 @@ function routeEdge(from, to, fromFace, toFace, obstacles, options = {}) {
|
|
|
11896
11896
|
}
|
|
11897
11897
|
function snapToChannels(points, obstacles, margin) {
|
|
11898
11898
|
if (points.length < 3) return points;
|
|
11899
|
-
const
|
|
11900
|
-
const
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
for (
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11899
|
+
const rects = obstacles;
|
|
11900
|
+
const centreFor = (horizontal, fixed, lo, hi) => {
|
|
11901
|
+
let low = -Infinity;
|
|
11902
|
+
let high = Infinity;
|
|
11903
|
+
for (const rect of rects) {
|
|
11904
|
+
if (horizontal) {
|
|
11905
|
+
if (rect.x + rect.w <= lo || rect.x >= hi) continue;
|
|
11906
|
+
if (rect.y + rect.h <= fixed + 0.5) low = Math.max(low, rect.y + rect.h);
|
|
11907
|
+
else if (rect.y >= fixed - 0.5) high = Math.min(high, rect.y);
|
|
11908
|
+
} else {
|
|
11909
|
+
if (rect.y + rect.h <= lo || rect.y >= hi) continue;
|
|
11910
|
+
if (rect.x + rect.w <= fixed + 0.5) low = Math.max(low, rect.x + rect.w);
|
|
11911
|
+
else if (rect.x >= fixed - 0.5) high = Math.min(high, rect.x);
|
|
11912
|
+
}
|
|
11908
11913
|
}
|
|
11909
|
-
return void 0;
|
|
11914
|
+
if (!Number.isFinite(low) || !Number.isFinite(high)) return void 0;
|
|
11915
|
+
const gap = high - low;
|
|
11916
|
+
if (gap < margin * 2 + 6) return void 0;
|
|
11917
|
+
return (low + high) / 2;
|
|
11910
11918
|
};
|
|
11919
|
+
const out = points.map((point) => ({ ...point }));
|
|
11911
11920
|
const last = out.length - 1;
|
|
11912
11921
|
const horizontalSegment = (index2) => Math.abs(out[index2 - 1].y - out[index2].y) < 0.6;
|
|
11913
11922
|
const fromStubHorizontal = horizontalSegment(1);
|
|
@@ -11918,21 +11927,32 @@ function snapToChannels(points, obstacles, margin) {
|
|
|
11918
11927
|
const horizontalRun = Math.abs(a.y - b.y) < 0.6;
|
|
11919
11928
|
if (index2 === 1 && horizontalRun === fromStubHorizontal) continue;
|
|
11920
11929
|
if (index2 === last - 1 && horizontalRun === toStubHorizontal) continue;
|
|
11930
|
+
const lo = horizontalRun ? Math.min(a.x, b.x) : Math.min(a.y, b.y);
|
|
11931
|
+
const hi = horizontalRun ? Math.max(a.x, b.x) : Math.max(a.y, b.y);
|
|
11932
|
+
const centre = centreFor(horizontalRun, horizontalRun ? a.y : a.x, lo, hi);
|
|
11933
|
+
if (centre === void 0) continue;
|
|
11921
11934
|
if (horizontalRun) {
|
|
11922
|
-
|
|
11923
|
-
|
|
11924
|
-
|
|
11925
|
-
b.y = centre;
|
|
11926
|
-
}
|
|
11935
|
+
if (Math.abs(centre - a.y) < 0.6) continue;
|
|
11936
|
+
a.y = centre;
|
|
11937
|
+
b.y = centre;
|
|
11927
11938
|
} else {
|
|
11928
|
-
|
|
11929
|
-
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
|
|
11939
|
+
if (Math.abs(centre - a.x) < 0.6) continue;
|
|
11940
|
+
a.x = centre;
|
|
11941
|
+
b.x = centre;
|
|
11942
|
+
}
|
|
11943
|
+
}
|
|
11944
|
+
const candidate = simplify(out);
|
|
11945
|
+
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);
|
|
11946
|
+
for (let index2 = 1; index2 < candidate.length; index2 += 1) {
|
|
11947
|
+
const a = candidate[index2 - 1];
|
|
11948
|
+
const b = candidate[index2];
|
|
11949
|
+
const steps = Math.max(2, Math.ceil((Math.abs(b.x - a.x) + Math.abs(b.y - a.y)) / 4));
|
|
11950
|
+
for (let step2 = 0; step2 <= steps; step2 += 1) {
|
|
11951
|
+
const t2 = step2 / steps;
|
|
11952
|
+
if (sameRectSet({ x: a.x + (b.x - a.x) * t2, y: a.y + (b.y - a.y) * t2 })) return points;
|
|
11933
11953
|
}
|
|
11934
11954
|
}
|
|
11935
|
-
return
|
|
11955
|
+
return candidate;
|
|
11936
11956
|
}
|
|
11937
11957
|
function routeBetween(ends, from, to, obstacles, options = {}) {
|
|
11938
11958
|
const margin = options.margin ?? DEFAULTS.margin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-talk-map",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
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",
|