dsh-talk-map 0.1.18 → 0.1.20

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 +63 -11
  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": "搜地图上的卡片(标题/正文)· v0.1.18",
451
+ "global.searchPlaceholder": "搜地图上的卡片(标题/正文)· v0.1.20",
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 · v0.1.18",
602
+ "global.searchPlaceholder": "Search cards on the map · v0.1.20",
603
603
  "global.searchRun": "Search",
604
604
  "global.searchTitle": "Search the map",
605
605
  "font.group": "Text size",
@@ -12146,6 +12146,43 @@ function round(value) {
12146
12146
 
12147
12147
  // src/client/TalkMapEdge.tsx
12148
12148
  var import_jsx_runtime8 = require("react/jsx-runtime");
12149
+ var boardCache = { at: 0, boxes: [] };
12150
+ function boardBoxes() {
12151
+ if (typeof document === "undefined") return [];
12152
+ const now2 = Date.now();
12153
+ if (now2 - boardCache.at < 80) return boardCache.boxes;
12154
+ const viewport = document.querySelector(".react-flow__viewport");
12155
+ const viewportRect = viewport?.getBoundingClientRect();
12156
+ let scale = 1;
12157
+ if (viewport !== null) {
12158
+ const matrix = getComputedStyle(viewport).transform;
12159
+ const parsed = /matrix\(([^)]+)\)/.exec(matrix);
12160
+ if (parsed !== null) {
12161
+ const values = parsed[1].split(",").map(Number);
12162
+ scale = values[0] === void 0 || values[0] === 0 ? 1 : values[0];
12163
+ }
12164
+ }
12165
+ const boxes = [];
12166
+ for (const element of document.querySelectorAll("[data-talkmap-session]")) {
12167
+ const rect = element.getBoundingClientRect();
12168
+ if (rect.width < 8 || rect.height < 8) continue;
12169
+ boxes.push({
12170
+ x: (rect.left - (viewportRect?.left ?? 0)) / scale,
12171
+ y: (rect.top - (viewportRect?.top ?? 0)) / scale,
12172
+ w: rect.width / scale,
12173
+ h: rect.height / scale
12174
+ });
12175
+ }
12176
+ if (boxes.length > 0) {
12177
+ boardCache.at = now2;
12178
+ boardCache.boxes = boxes;
12179
+ }
12180
+ return boxes;
12181
+ }
12182
+ function containsPoint(box, x, y) {
12183
+ const pad = 40;
12184
+ return x >= box.x - pad && x <= box.x + box.w + pad && y >= box.y - pad && y <= box.y + box.h + pad;
12185
+ }
12149
12186
  function TalkMapEdge(props) {
12150
12187
  const data = props.data ?? {};
12151
12188
  const synced = data.sync === "synced";
@@ -12158,7 +12195,9 @@ function TalkMapEdge(props) {
12158
12195
  return "l";
12159
12196
  };
12160
12197
  const obstacles = data.obstacles;
12161
- const route = obstacles === void 0 ? void 0 : routeBetween(
12198
+ const sameCorner = (box, other) => other !== void 0 && Math.abs(box.x - other.x) < 3 && Math.abs(box.y - other.y) < 3;
12199
+ const merged = obstacles ?? [].filter((box) => !sameCorner(box, data.fromRect)).filter((box) => !sameCorner(box, data.toRect)).filter((box) => !containsPoint(box, props.sourceX, props.sourceY)).filter((box) => !containsPoint(box, props.targetX, props.targetY));
12200
+ const route = merged.length === 0 ? void 0 : routeBetween(
12162
12201
  {
12163
12202
  start: { x: props.sourceX, y: props.sourceY },
12164
12203
  startFace: faceOf(props.sourcePosition),
@@ -12166,11 +12205,10 @@ function TalkMapEdge(props) {
12166
12205
  endFace: faceOf(props.targetPosition)
12167
12206
  },
12168
12207
  // The endpoints' real boxes: the router excludes them from the obstacle
12169
- // set by geometry. A degenerate 0×0 box never matches, so the endpoints
12170
- // used to block their own handles and every line fell back to a straight L.
12208
+ // set by geometry.
12171
12209
  data.fromRect ?? { x: props.sourceX, y: props.sourceY, w: 0, h: 0 },
12172
12210
  data.toRect ?? { x: props.targetX, y: props.targetY, w: 0, h: 0 },
12173
- obstacles
12211
+ merged
12174
12212
  );
12175
12213
  const routed = route !== void 0 && route.length > 1;
12176
12214
  const routeHitsCard = (points, rects) => {
@@ -12190,15 +12228,17 @@ function TalkMapEdge(props) {
12190
12228
  }
12191
12229
  return false;
12192
12230
  };
12193
- const blockedRoute = routeHitsCard(route, obstacles ?? data.obstacles);
12231
+ const guardBoxes = merged.filter((box) => !containsPoint(box, props.sourceX, props.sourceY)).filter((box) => !containsPoint(box, props.targetX, props.targetY));
12232
+ const blockedRoute = routeHitsCard(route, guardBoxes);
12194
12233
  if (typeof window !== "undefined") {
12195
12234
  const w = window;
12196
12235
  w.__edgeDebug = w.__edgeDebug ?? [];
12197
12236
  w.__edgeDebug.push({
12198
12237
  id: props.id,
12199
12238
  obstacles: obstacles?.length ?? null,
12200
- fromRect: data.fromRect ?? null,
12201
- toRect: data.toRect ?? null,
12239
+ merged: merged.length,
12240
+ measured: boardBoxes().length,
12241
+ measuredFirst: boardBoxes().slice(0, 2),
12202
12242
  src: { x: props.sourceX, y: props.sourceY, pos: String(props.sourcePosition) },
12203
12243
  dst: { x: props.targetX, y: props.targetY, pos: String(props.targetPosition) },
12204
12244
  points: route ?? null
@@ -14032,10 +14072,22 @@ function CanvasInner(props) {
14032
14072
  const out = {};
14033
14073
  for (const node of liveNodes) {
14034
14074
  if (node.type !== "sessionCard" || node.hidden === true) continue;
14035
- out[node.id] = { x: node.position.x, y: node.position.y, w: CARD_W, h: CARD_H };
14075
+ const sessionId = canvasState.cards[node.id]?.sessionId;
14076
+ const element = sessionId === void 0 ? null : document.querySelector(`[data-talkmap-session="${sessionId}"]`);
14077
+ out[node.id] = {
14078
+ x: node.position.x,
14079
+ y: node.position.y,
14080
+ w: element?.offsetWidth ?? CARD_W,
14081
+ h: element?.offsetHeight ?? CARD_H
14082
+ };
14036
14083
  }
14037
14084
  return out;
14038
14085
  };
14086
+ const [boardTick, setBoardTick] = (0, import_react12.useState)(0);
14087
+ (0, import_react12.useEffect)(() => {
14088
+ const timer4 = window.setTimeout(() => setBoardTick((value) => value + 1), 150);
14089
+ return () => window.clearTimeout(timer4);
14090
+ }, []);
14039
14091
  const obstaclesFor = (fromCardId, toCardId) => Object.entries(renderedBoxes()).filter(([id2]) => id2 !== fromCardId && id2 !== toCardId).filter(([id2]) => !foldedSet.has(id2)).map(([, box]) => box);
14040
14092
  const boxOf = (cardId) => renderedBoxes()[cardId];
14041
14093
  const routingObstacles = () => Object.entries(canvasState.cards).map(([id2, card]) => ({
@@ -14156,7 +14208,7 @@ function CanvasInner(props) {
14156
14208
  }
14157
14209
  }
14158
14210
  return out;
14159
- }, [visibleCards, canvasState.edges, sessions, sessionIdToCardId, liveSelectedEdgeIds, foldedSet, locale, pushEpoch, lineageHidden, liveNodes]);
14211
+ }, [visibleCards, canvasState.edges, sessions, sessionIdToCardId, liveSelectedEdgeIds, foldedSet, locale, pushEpoch, lineageHidden, liveNodes, boardTick]);
14160
14212
  const drawerWireLinks = (0, import_react12.useMemo)(() => {
14161
14213
  if (drawer === null) return [];
14162
14214
  const layout = folderLayouts[drawer.groupId];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-talk-map",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
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",