dsh-talk-map 0.1.30 → 0.1.32

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 +134 -8
  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.30",
451
+ "global.searchPlaceholder": "搜地图上的卡片(标题/正文)· v0.1.32",
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.30",
602
+ "global.searchPlaceholder": "Search cards on the map · v0.1.32",
603
603
  "global.searchRun": "Search",
604
604
  "global.searchTitle": "Search the map",
605
605
  "font.group": "Text size",
@@ -11957,7 +11957,7 @@ function snapToChannels(points, obstacles, margin) {
11957
11957
  }
11958
11958
  return candidate;
11959
11959
  }
11960
- function routeBetween(ends, from, to, obstacles, options = {}) {
11960
+ function routeRaw(ends, from, to, obstacles, options = {}) {
11961
11961
  const margin = options.margin ?? DEFAULTS.margin;
11962
11962
  const stub = options.stub ?? DEFAULTS.stub;
11963
11963
  const minCorridor = options.minCorridor ?? DEFAULTS.minCorridor;
@@ -12019,12 +12019,20 @@ function routeBetween(ends, from, to, obstacles, options = {}) {
12019
12019
  }
12020
12020
  candidates.push([start2, startStub, { x: left, y: startStub.y }, { x: left, y: endStub.y }, endStub, end]);
12021
12021
  candidates.push([start2, startStub, { x: right, y: startStub.y }, { x: right, y: endStub.y }, endStub, end]);
12022
+ const pairTop = Math.min(from.y, to.y) - margin - 8;
12023
+ const pairBottom = Math.max(from.y + from.h, to.y + to.h) + margin + 8;
12024
+ const pairLeft = Math.min(from.x, to.x) - margin - 8;
12025
+ const pairRight = Math.max(from.x + from.w, to.x + to.w) + margin + 8;
12026
+ candidates.push([start2, startStub, { x: startStub.x, y: pairTop }, { x: endStub.x, y: pairTop }, endStub, end]);
12027
+ candidates.push([start2, startStub, { x: startStub.x, y: pairBottom }, { x: endStub.x, y: pairBottom }, endStub, end]);
12028
+ candidates.push([start2, startStub, { x: pairLeft, y: startStub.y }, { x: pairLeft, y: endStub.y }, endStub, end]);
12029
+ candidates.push([start2, startStub, { x: pairRight, y: startStub.y }, { x: pairRight, y: endStub.y }, endStub, end]);
12022
12030
  let best2;
12023
12031
  let bestHits = Infinity;
12024
12032
  for (const candidate of candidates) {
12025
12033
  const points = simplify(candidate);
12026
12034
  let hits = 0;
12027
- for (let index2 = 1; index2 < points.length; index2 += 1) {
12035
+ for (let index2 = 2; index2 < points.length - 1; index2 += 1) {
12028
12036
  const a = points[index2 - 1];
12029
12037
  const b = points[index2];
12030
12038
  hits += a.x === b.x ? hitsVertical(blocked, a.x, a.y, b.y) : hitsHorizontal(blocked, a.y, a.x, b.x);
@@ -12188,6 +12196,76 @@ function roundedPath(points, radius = 10) {
12188
12196
  function round(value) {
12189
12197
  return Math.round(value * 100) / 100;
12190
12198
  }
12199
+ function routeBetween(ends, from, to, obstacles, options = {}) {
12200
+ const raw = routeRaw(ends, from, to, obstacles, options);
12201
+ const margin = options.margin ?? DEFAULTS.margin;
12202
+ const near = (point, anchor) => Math.abs(point.x - anchor.x) <= 26 && Math.abs(point.y - anchor.y) <= 26;
12203
+ const hits = (points, boxes) => {
12204
+ let count = 0;
12205
+ for (let index2 = 1; index2 < points.length; index2 += 1) {
12206
+ const a = points[index2 - 1];
12207
+ const b = points[index2];
12208
+ const steps = Math.max(2, Math.ceil((Math.abs(b.x - a.x) + Math.abs(b.y - a.y)) / 3));
12209
+ for (let step2 = 0; step2 <= steps; step2 += 1) {
12210
+ const t2 = step2 / steps;
12211
+ const point = { x: a.x + (b.x - a.x) * t2, y: a.y + (b.y - a.y) * t2 };
12212
+ if (near(point, ends.start) || near(point, ends.end)) continue;
12213
+ for (const box of boxes) {
12214
+ const inside = point.x > box.x + 1 && point.x < box.x + box.w - 1 && point.y > box.y + 1 && point.y < box.y + box.h - 1;
12215
+ if (inside) {
12216
+ count += 1;
12217
+ continue;
12218
+ }
12219
+ const dx = Math.max(box.x - point.x, 0, point.x - (box.x + box.w));
12220
+ const dy = Math.max(box.y - point.y, 0, point.y - (box.y + box.h));
12221
+ if (Math.hypot(dx, dy) < 8) count += 1;
12222
+ }
12223
+ }
12224
+ }
12225
+ return count;
12226
+ };
12227
+ if (hits(raw, [from, to]) === 0) return raw;
12228
+ const spread = margin + 24;
12229
+ const boxTop = Math.min(from.y, to.y) - spread;
12230
+ const boxBottom = Math.max(from.y + from.h, to.y + to.h) + spread;
12231
+ const boxLeft = Math.min(from.x, to.x) - spread;
12232
+ const boxRight = Math.max(from.x + from.w, to.x + to.w) + spread;
12233
+ const startNormal = normalOf(ends.startFace);
12234
+ const endNormal = normalOf(ends.endFace);
12235
+ const stubLength = Math.max(options.stub ?? DEFAULTS.stub, margin + 3);
12236
+ const startStub = {
12237
+ x: ends.start.x + startNormal.x * stubLength,
12238
+ y: ends.start.y + startNormal.y * stubLength
12239
+ };
12240
+ const endStub = {
12241
+ x: ends.end.x + endNormal.x * stubLength,
12242
+ y: ends.end.y + endNormal.y * stubLength
12243
+ };
12244
+ const wraps = [
12245
+ [ends.start, startStub, { x: startStub.x, y: boxTop }, { x: endStub.x, y: boxTop }, endStub, ends.end],
12246
+ [ends.start, startStub, { x: startStub.x, y: boxBottom }, { x: endStub.x, y: boxBottom }, endStub, ends.end],
12247
+ [ends.start, startStub, { x: boxLeft, y: startStub.y }, { x: boxLeft, y: endStub.y }, endStub, ends.end],
12248
+ [ends.start, startStub, { x: boxRight, y: startStub.y }, { x: boxRight, y: endStub.y }, endStub, ends.end]
12249
+ ];
12250
+ let best;
12251
+ let bestHits = Infinity;
12252
+ let bestLength = Infinity;
12253
+ for (const wrap of wraps) {
12254
+ const points = simplify(wrap);
12255
+ const wrapped = hits(points, [from, to, ...obstacles]);
12256
+ let length = 0;
12257
+ for (let index2 = 1; index2 < points.length; index2 += 1) {
12258
+ length += Math.abs(points[index2].x - points[index2 - 1].x) + Math.abs(points[index2].y - points[index2 - 1].y);
12259
+ }
12260
+ if (wrapped < bestHits || wrapped === bestHits && length < bestLength) {
12261
+ best = points;
12262
+ bestHits = wrapped;
12263
+ bestLength = length;
12264
+ }
12265
+ if (wrapped === 0) break;
12266
+ }
12267
+ return bestHits === 0 && best !== void 0 ? best : raw;
12268
+ }
12191
12269
 
12192
12270
  // src/client/TalkMapEdge.tsx
12193
12271
  var import_jsx_runtime8 = require("react/jsx-runtime");
@@ -12234,7 +12312,7 @@ function TalkMapEdge(props) {
12234
12312
  const measuredBoxes = boardBoxes();
12235
12313
  const sameCorner = (box, other) => other !== void 0 && Math.abs(box.x - other.x) < 6 && Math.abs(box.y - other.y) < 6;
12236
12314
  const merged = (obstacles !== void 0 && obstacles.length > 0 ? obstacles : measuredBoxes).filter((box) => !sameCorner(box, data.fromRect)).filter((box) => !sameCorner(box, data.toRect)).filter((box) => !sameCorner(box, data.fromRect)).filter((box) => !sameCorner(box, data.toRect));
12237
- const route = merged.length === 0 ? void 0 : routeBetween(
12315
+ const route = data.fromRect === void 0 || data.toRect === void 0 ? void 0 : routeBetween(
12238
12316
  {
12239
12317
  // Rounded to whole flow pixels: anchors carry sub-pixel noise after a zoom,
12240
12318
  // which shifted the clipped endpoints by a pixel between renders.
@@ -12249,7 +12327,51 @@ function TalkMapEdge(props) {
12249
12327
  data.toRect ?? { x: props.targetX, y: props.targetY, w: 0, h: 0 },
12250
12328
  merged
12251
12329
  );
12252
- const routed = route !== void 0 && route.length > 1;
12330
+ let finalRoute = route;
12331
+ if (route !== void 0 && route.length > 1 && data.fromRect !== void 0 && data.toRect !== void 0) {
12332
+ const boxesForHit = [
12333
+ ...data.fromRect === void 0 ? [] : [data.fromRect],
12334
+ ...data.toRect === void 0 ? [] : [data.toRect],
12335
+ ...merged
12336
+ ];
12337
+ const nearAnchor = (point) => Math.hypot(point.x - props.sourceX, point.y - props.sourceY) <= 26 || Math.hypot(point.x - props.targetX, point.y - props.targetY) <= 26;
12338
+ const hitsCard = (points) => {
12339
+ for (let index2 = 1; index2 < points.length; index2 += 1) {
12340
+ const a = points[index2 - 1];
12341
+ const b = points[index2];
12342
+ const steps = Math.max(2, Math.ceil((Math.abs(b.x - a.x) + Math.abs(b.y - a.y)) / 4));
12343
+ for (let step2 = 0; step2 <= steps; step2 += 1) {
12344
+ const t2 = step2 / steps;
12345
+ const point = { x: a.x + (b.x - a.x) * t2, y: a.y + (b.y - a.y) * t2 };
12346
+ if (nearAnchor(point)) continue;
12347
+ if (boxesForHit.some((box) => point.x > box.x + 1 && point.x < box.x + box.w - 1 && point.y > box.y + 1 && point.y < box.y + box.h - 1)) return true;
12348
+ }
12349
+ }
12350
+ return false;
12351
+ };
12352
+ const sameSide = faceOf(props.sourcePosition) === faceOf(props.targetPosition);
12353
+ if (hitsCard(route) || route.length <= 2 && sameSide) {
12354
+ const faces = pickFaces(
12355
+ { id: "from", x: data.fromRect.x, y: data.fromRect.y },
12356
+ { id: "to", x: data.toRect.x, y: data.toRect.y },
12357
+ merged.map((box, index2) => ({ id: `o${index2}`, x: box.x, y: box.y })),
12358
+ { cardWidth: data.fromRect.w, cardHeight: data.fromRect.h }
12359
+ );
12360
+ const retry = routeBetween(
12361
+ {
12362
+ start: { x: Math.round(props.sourceX), y: Math.round(props.sourceY) },
12363
+ startFace: faces.fromHandle,
12364
+ end: { x: Math.round(props.targetX), y: Math.round(props.targetY) },
12365
+ endFace: faces.toHandle
12366
+ },
12367
+ data.fromRect,
12368
+ data.toRect,
12369
+ merged
12370
+ );
12371
+ if (retry.length > 1 && !hitsCard(retry)) finalRoute = retry;
12372
+ }
12373
+ }
12374
+ const routed = finalRoute !== void 0 && finalRoute.length > 1;
12253
12375
  const routeHitsCard = (points, rects) => {
12254
12376
  if (points === void 0 || rects === void 0) return false;
12255
12377
  for (let index2 = 1; index2 < points.length; index2 += 1) {
@@ -12291,7 +12413,7 @@ function TalkMapEdge(props) {
12291
12413
  targetY: props.targetY,
12292
12414
  targetPosition: props.targetPosition
12293
12415
  });
12294
- const safeRoute = routed ? route : void 0;
12416
+ const safeRoute = routed ? finalRoute : void 0;
12295
12417
  const path = safeRoute !== void 0 ? roundedPath(safeRoute, 10) : smoothPath;
12296
12418
  const arrowAngle = (() => {
12297
12419
  if (routed) {
@@ -14172,7 +14294,11 @@ function CanvasInner(props) {
14172
14294
  target: edge.toCardId,
14173
14295
  // Faces are recomputed from the live positions — a stored handle would
14174
14296
  // keep a 12px stub forever after the cards were laid out side by side.
14175
- ...computedHandles(edge.fromCardId, edge.toCardId),
14297
+ // Honour the handles the user picked. Recomputing them unconditionally meant a
14298
+ // connection drawn from the left face of two stacked cards came out of their
14299
+ // *bottom* faces instead, and then had to loop back — the loop is what cut
14300
+ // through the cards. Only fall back to geometry when nothing was stored.
14301
+ ...edge.fromHandle !== void 0 && edge.toHandle !== void 0 ? { sourceHandle: edge.fromHandle, targetHandle: edge.toHandle } : computedHandles(edge.fromCardId, edge.toCardId),
14176
14302
  type: TALK_MAP_EDGE_TYPE,
14177
14303
  selected: liveSelectedEdgeIds.has(edgeId),
14178
14304
  // Endpoints ride along for the edge context menu (id parsing would
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-talk-map",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
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",