dsh-talk-map 0.1.7 → 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.
Files changed (2) hide show
  1. package/client/client.js +42 -22
  2. package/package.json +1 -1
package/client/client.js CHANGED
@@ -11739,7 +11739,7 @@ function ContextMenu(props) {
11739
11739
  }
11740
11740
 
11741
11741
  // src/client/edge-route.ts
11742
- var DEFAULTS = { margin: 14, stub: 14, minCorridor: 28 };
11742
+ var DEFAULTS = { margin: 14, stub: 22, minCorridor: 28 };
11743
11743
  function anchorOf(rect, face) {
11744
11744
  switch (face) {
11745
11745
  case "r":
@@ -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 out = points.map((point) => ({ ...point }));
11900
- const rowBands = bands(obstacles, "y");
11901
- const colBands = bands(obstacles, "x");
11902
- const channelFor = (value, bandsList) => {
11903
- for (let index2 = 1; index2 < bandsList.length; index2 += 1) {
11904
- const lo = bandsList[index2 - 1].end;
11905
- const hi = bandsList[index2].start;
11906
- if (hi - lo < margin * 2 + 8) continue;
11907
- if (value > lo && value < hi) return (lo + hi) / 2;
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
- const centre = channelFor(a.y, rowBands);
11923
- if (centre !== void 0 && Math.abs(centre - a.y) > 0.6) {
11924
- a.y = centre;
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
- const centre = channelFor(a.x, colBands);
11929
- if (centre !== void 0 && Math.abs(centre - a.x) > 0.6) {
11930
- a.x = centre;
11931
- b.x = centre;
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 simplify(out);
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.7",
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",