dsh-talk-map 0.1.10 → 0.1.12

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 +79 -20
  2. package/package.json +1 -1
package/client/client.js CHANGED
@@ -448,7 +448,7 @@ var zh = {
448
448
  "digest.empty": "这条对话还没有摘要,先刷新摘要再来看。",
449
449
  "digest.copy": "复制",
450
450
  "digest.close": "关闭",
451
- "global.searchPlaceholder": "搜地图上的卡片(标题/正文),回车开始",
451
+ "global.searchPlaceholder": "搜地图上的卡片(标题/正文)· v0.1.12",
452
452
  "global.searchRun": "搜索",
453
453
  "global.searchTitle": "搜索地图",
454
454
  "font.group": "文字大小",
@@ -599,7 +599,7 @@ var en = {
599
599
  "menu.noGroup": "Remove from group (free card)",
600
600
  "menu.open": "Open conversation",
601
601
  "menu.markUnread": "Mark as unread",
602
- "global.searchPlaceholder": "Search cards on the map (title/body), Enter",
602
+ "global.searchPlaceholder": "Search cards on the map · v0.1.12",
603
603
  "global.searchRun": "Search",
604
604
  "global.searchTitle": "Search the map",
605
605
  "font.group": "Text size",
@@ -11740,7 +11740,8 @@ function ContextMenu(props) {
11740
11740
 
11741
11741
  // src/client/edge-route.ts
11742
11742
  var __routeDebug = {};
11743
- var DEFAULTS = { margin: 14, stub: 22, minCorridor: 28 };
11743
+ var DEFAULTS = { margin: 8, stub: 22, minCorridor: 18 };
11744
+ var CROSS_PENALTY = 2e4;
11744
11745
  function anchorOf(rect, face) {
11745
11746
  switch (face) {
11746
11747
  case "r":
@@ -11774,22 +11775,24 @@ function insideStrict(rect, point) {
11774
11775
  function hitsHorizontal(rects, y, x1, x2) {
11775
11776
  const lo = Math.min(x1, x2);
11776
11777
  const hi = Math.max(x1, x2);
11778
+ let count = 0;
11777
11779
  for (const rect of rects) {
11778
11780
  if (y <= rect.y || y >= rect.y + rect.h) continue;
11779
11781
  if (hi <= rect.x || lo >= rect.x + rect.w) continue;
11780
- return true;
11782
+ count += 1;
11781
11783
  }
11782
- return false;
11784
+ return count;
11783
11785
  }
11784
11786
  function hitsVertical(rects, x, y1, y2) {
11785
11787
  const lo = Math.min(y1, y2);
11786
11788
  const hi = Math.max(y1, y2);
11789
+ let count = 0;
11787
11790
  for (const rect of rects) {
11788
11791
  if (x <= rect.x || x >= rect.x + rect.w) continue;
11789
11792
  if (hi <= rect.y || lo >= rect.y + rect.h) continue;
11790
- return true;
11793
+ count += 1;
11791
11794
  }
11792
- return false;
11795
+ return count;
11793
11796
  }
11794
11797
  function bands(rects, axis) {
11795
11798
  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);
@@ -11963,8 +11966,36 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
11963
11966
  const end = ends.end;
11964
11967
  const startNormal = normalOf(ends.startFace);
11965
11968
  const endNormal = normalOf(ends.endFace);
11966
- const startStub = { x: start2.x + startNormal.x * stub, y: start2.y + startNormal.y * stub };
11967
- const endStub = { x: end.x + endNormal.x * stub, y: end.y + endNormal.y * stub };
11969
+ const spaceAhead = (point, normal) => {
11970
+ let best2 = 240;
11971
+ for (const raw of obstacles) {
11972
+ const rect = expand(raw, margin);
11973
+ if (normal.x !== 0) {
11974
+ if (point.y <= rect.y || point.y >= rect.y + rect.h) continue;
11975
+ if (normal.x > 0 && rect.x >= point.x) best2 = Math.min(best2, rect.x - point.x);
11976
+ if (normal.x < 0 && rect.x + rect.w <= point.x) best2 = Math.min(best2, point.x - (rect.x + rect.w));
11977
+ } else {
11978
+ if (point.x <= rect.x || point.x >= rect.x + rect.w) continue;
11979
+ if (normal.y > 0 && rect.y >= point.y) best2 = Math.min(best2, rect.y - point.y);
11980
+ if (normal.y < 0 && rect.y + rect.h <= point.y) best2 = Math.min(best2, point.y - (rect.y + rect.h));
11981
+ }
11982
+ }
11983
+ return best2;
11984
+ };
11985
+ const stubFor = (space) => {
11986
+ const half = Math.max(0, (space - margin * 2) / 2);
11987
+ return Math.max(4, Math.min(stub, half));
11988
+ };
11989
+ const startStubLength = stubFor(spaceAhead(start2, startNormal));
11990
+ const endStubLength = stubFor(spaceAhead(end, { x: -endNormal.x, y: -endNormal.y }));
11991
+ const startStub = {
11992
+ x: start2.x + startNormal.x * startStubLength,
11993
+ y: start2.y + startNormal.y * startStubLength
11994
+ };
11995
+ const endStub = {
11996
+ x: end.x + endNormal.x * endStubLength,
11997
+ y: end.y + endNormal.y * endStubLength
11998
+ };
11968
11999
  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;
11969
12000
  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
12001
  const blocked = obstacles.filter((rect) => !sameRect(rect, from) && !sameRect(rect, to)).filter((rect) => !overlaps(rect, from) && !overlaps(rect, to)).map((rect) => expand(rect, margin));
@@ -11984,7 +12015,7 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
11984
12015
  const ys = corridors(near, "y", minCorridor).filter(withinY);
11985
12016
  const xOuter = outerLines(near, "x", margin + 6).filter(withinX);
11986
12017
  const yOuter = outerLines(near, "y", margin + 6).filter(withinY);
11987
- const hug = margin + 10;
12018
+ const hug = margin + 6;
11988
12019
  const xHug = near.flatMap((rect) => [rect.x - hug, rect.x + rect.w + hug]);
11989
12020
  const yHug = near.flatMap((rect) => [rect.y - hug, rect.y + rect.h + hug]);
11990
12021
  const xCands = dedupe([start2.x, end.x, startStub.x, endStub.x, ...xs, ...xOuter, ...xHug]);
@@ -12060,14 +12091,14 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
12060
12091
  if (nx < 0 || ny < 0 || nx >= xsTrimmed.length || ny >= ysTrimmed.length) continue;
12061
12092
  const next = { x: xsTrimmed[nx], y: ysTrimmed[ny] };
12062
12093
  const nextNode = nodeId(nx, ny);
12063
- if (nextNode !== goalNode && blocked.some((rect) => insideStrict(rect, next))) continue;
12064
- const clear = step2.axis === "x" ? !hitsHorizontal(blocked, here.y, here.x, next.x) : !hitsVertical(blocked, here.x, here.y, next.y);
12065
- if (!clear) continue;
12094
+ const insideCost = blocked.filter((rect) => insideStrict(rect, next)).length * CROSS_PENALTY;
12095
+ const crossing = step2.axis === "x" ? hitsHorizontal(blocked, here.y, here.x, next.x) : hitsVertical(blocked, here.x, here.y, next.y);
12096
+ const crossCost = crossing * CROSS_PENALTY;
12066
12097
  const distance2 = Math.abs(next.x - here.x) + Math.abs(next.y - here.y);
12067
12098
  const onCorridor = step2.axis === "x" ? corridorY.has(Math.round(here.y)) : corridorX.has(Math.round(here.x));
12068
12099
  const turn = dir === step2.axis ? 0 : 18;
12069
12100
  const prefer = onCorridor ? 0 : 40;
12070
- const nextCost = cost + distance2 + turn + prefer;
12101
+ const nextCost = cost + distance2 + turn + prefer + crossCost + insideCost;
12071
12102
  const nextState = withDir(nextNode, step2.axis);
12072
12103
  const known = best.get(nextState);
12073
12104
  if (known !== void 0 && known <= nextCost) continue;
@@ -12133,12 +12164,27 @@ function TalkMapEdge(props) {
12133
12164
  end: { x: props.targetX, y: props.targetY },
12134
12165
  endFace: faceOf(props.targetPosition)
12135
12166
  },
12136
- // Endpoint bodies for the corridor maths; the router skips them by value.
12137
- { x: props.sourceX, y: props.sourceY, w: 0, h: 0 },
12138
- { x: props.targetX, y: props.targetY, w: 0, h: 0 },
12167
+ // The endpoints' real boxes: the router excludes them from the obstacle
12168
+ // set by geometry. A degenerate 0×0 box never matches, so the endpoints
12169
+ // used to block their own handles and every line fell back to a straight L.
12170
+ data.fromRect ?? { x: props.sourceX, y: props.sourceY, w: 0, h: 0 },
12171
+ data.toRect ?? { x: props.targetX, y: props.targetY, w: 0, h: 0 },
12139
12172
  obstacles
12140
12173
  );
12141
12174
  const routed = route !== void 0 && route.length > 1;
12175
+ if (typeof window !== "undefined") {
12176
+ const w = window;
12177
+ w.__edgeDebug = w.__edgeDebug ?? [];
12178
+ w.__edgeDebug.push({
12179
+ id: props.id,
12180
+ obstacles: obstacles?.length ?? null,
12181
+ fromRect: data.fromRect ?? null,
12182
+ toRect: data.toRect ?? null,
12183
+ src: { x: props.sourceX, y: props.sourceY, pos: String(props.sourcePosition) },
12184
+ dst: { x: props.targetX, y: props.targetY, pos: String(props.targetPosition) },
12185
+ points: route ?? null
12186
+ });
12187
+ }
12142
12188
  const [smoothPath] = getSmoothStepPath({
12143
12189
  sourceX: props.sourceX,
12144
12190
  sourceY: props.sourceY,
@@ -13953,7 +13999,16 @@ function CanvasInner(props) {
13953
13999
  if (card === void 0) return void 0;
13954
14000
  return sessions.byId[card.sessionId]?.updatedAt;
13955
14001
  };
13956
- 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 }));
14002
+ const obstaclesFor = (fromCardId, toCardId) => Object.entries(canvasState.cards).filter(([id2]) => id2 !== fromCardId && id2 !== toCardId).filter(([id2]) => !foldedSet.has(id2)).map(([id2, card]) => {
14003
+ const slot = cardLayout[id2];
14004
+ return { x: slot?.x ?? card.x, y: slot?.y ?? card.y, w: CARD_W, h: CARD_H };
14005
+ });
14006
+ const boxOf = (cardId) => {
14007
+ const card = canvasState.cards[cardId];
14008
+ if (card === void 0) return void 0;
14009
+ const slot = cardLayout[cardId];
14010
+ return { x: slot?.x ?? card.x, y: slot?.y ?? card.y, w: CARD_W, h: CARD_H };
14011
+ };
13957
14012
  const routingObstacles = () => Object.entries(canvasState.cards).map(([id2, card]) => ({
13958
14013
  id: id2,
13959
14014
  x: card.x,
@@ -14007,7 +14062,9 @@ function CanvasInner(props) {
14007
14062
  fromCardId: edge.fromCardId,
14008
14063
  toCardId: edge.toCardId,
14009
14064
  sync,
14010
- obstacles: obstaclesFor(edge.fromCardId, edge.toCardId)
14065
+ obstacles: obstaclesFor(edge.fromCardId, edge.toCardId),
14066
+ ...boxOf(edge.fromCardId) !== void 0 ? { fromRect: boxOf(edge.fromCardId) } : {},
14067
+ ...boxOf(edge.toCardId) !== void 0 ? { toRect: boxOf(edge.toCardId) } : {}
14011
14068
  },
14012
14069
  // Every line carries its direction now: 「推送摘要」 always travels
14013
14070
  // source → target, so a link edge gets a lighter arrow instead of none.
@@ -14062,7 +14119,9 @@ function CanvasInner(props) {
14062
14119
  toCardId: cardId,
14063
14120
  sync: lineageSync,
14064
14121
  structural: true,
14065
- obstacles: obstaclesFor(parentCardId, cardId)
14122
+ obstacles: obstaclesFor(parentCardId, cardId),
14123
+ ...boxOf(parentCardId) !== void 0 ? { fromRect: boxOf(parentCardId) } : {},
14124
+ ...boxOf(cardId) !== void 0 ? { toRect: boxOf(cardId) } : {}
14066
14125
  },
14067
14126
  // No inline stroke: inline style beats everything the renderer draws.
14068
14127
  style: { opacity: 0.85 }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-talk-map",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
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",