dsh-talk-map 0.1.9 → 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.
Files changed (2) hide show
  1. package/client/client.js +30 -9
  2. 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) {
@@ -11965,8 +11966,10 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
11965
11966
  const startStub = { x: start2.x + startNormal.x * stub, y: start2.y + startNormal.y * stub };
11966
11967
  const endStub = { x: end.x + endNormal.x * stub, y: end.y + endNormal.y * stub };
11967
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;
11968
- const blocked = obstacles.filter((rect) => !sameRect(rect, from) && !sameRect(rect, to)).map((rect) => expand(rect, margin));
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));
11969
11971
  const fallback = simplify([start2, startStub, { x: endStub.x, y: startStub.y }, endStub, end]);
11972
+ __routeDebug.last = { usedFallback: true };
11970
11973
  const pad = 260;
11971
11974
  const window2 = {
11972
11975
  x1: Math.min(start2.x, end.x) - pad,
@@ -11981,18 +11984,35 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
11981
11984
  const ys = corridors(near, "y", minCorridor).filter(withinY);
11982
11985
  const xOuter = outerLines(near, "x", margin + 6).filter(withinX);
11983
11986
  const yOuter = outerLines(near, "y", margin + 6).filter(withinY);
11984
- const xCands = dedupe([start2.x, end.x, startStub.x, endStub.x, ...xs, ...xOuter]);
11985
- const yCands = dedupe([start2.y, end.y, startStub.y, endStub.y, ...ys, ...yOuter]);
11986
- if (xCands.length > 96 || yCands.length > 96) return fallback;
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 };
11987
12007
  const corridorX = new Set(xs.map((value) => Math.round(value)));
11988
12008
  const corridorY = new Set(ys.map((value) => Math.round(value)));
11989
12009
  const nodeId = (ix, iy) => `${ix},${iy}`;
11990
12010
  const pointAt = (id2) => {
11991
12011
  const [ix, iy] = id2.split(",").map(Number);
11992
- return { x: xCands[ix], y: yCands[iy] };
12012
+ return { x: xsTrimmed[ix], y: ysTrimmed[iy] };
11993
12013
  };
11994
- const startIndex = { x: xCands.findIndex((value) => Math.abs(value - startStub.x) < 0.5), y: yCands.findIndex((value) => Math.abs(value - startStub.y) < 0.5) };
11995
- const endIndex = { x: xCands.findIndex((value) => Math.abs(value - endStub.x) < 0.5), y: yCands.findIndex((value) => Math.abs(value - endStub.y) < 0.5) };
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) };
11996
12016
  if (startIndex.x < 0 || startIndex.y < 0 || endIndex.x < 0 || endIndex.y < 0) return fallback;
11997
12017
  const goal = { x: endStub.x, y: endStub.y };
11998
12018
  const startNode = nodeId(startIndex.x, startIndex.y);
@@ -12019,6 +12039,7 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
12019
12039
  cursor = cameFrom.get(cursor);
12020
12040
  }
12021
12041
  path.reverse();
12042
+ __routeDebug.last = { usedFallback: false, steps: path.length };
12022
12043
  return snapToChannels(
12023
12044
  simplify([start2, startStub, ...path.slice(1), endStub, end]),
12024
12045
  obstacles,
@@ -12036,8 +12057,8 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
12036
12057
  for (const step2 of steps) {
12037
12058
  const nx = ix + step2.dx;
12038
12059
  const ny = iy + step2.dy;
12039
- if (nx < 0 || ny < 0 || nx >= xCands.length || ny >= yCands.length) continue;
12040
- const next = { x: xCands[nx], y: yCands[ny] };
12060
+ if (nx < 0 || ny < 0 || nx >= xsTrimmed.length || ny >= ysTrimmed.length) continue;
12061
+ const next = { x: xsTrimmed[nx], y: ysTrimmed[ny] };
12041
12062
  const nextNode = nodeId(nx, ny);
12042
12063
  if (nextNode !== goalNode && blocked.some((rect) => insideStrict(rect, next))) continue;
12043
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.9",
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",