dsh-talk-map 0.1.46 → 0.1.49

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 +147 -50
  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.33",
451
+ "global.searchPlaceholder": "b49 · 搜地图上的卡片(标题/正文)",
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.33",
602
+ "global.searchPlaceholder": "b49 · Search cards on the map",
603
603
  "global.searchRun": "Search",
604
604
  "global.searchTitle": "Search the map",
605
605
  "font.group": "Text size",
@@ -11720,18 +11720,6 @@ function ContextMenu(props) {
11720
11720
  // src/client/edge-route.ts
11721
11721
  var __routeDebug = {};
11722
11722
  var DEFAULTS = { margin: 4, stub: 22, minCorridor: 10 };
11723
- function anchorOf(rect, face) {
11724
- switch (face) {
11725
- case "r":
11726
- return { x: rect.x + rect.w, y: rect.y + rect.h / 2 };
11727
- case "l":
11728
- return { x: rect.x, y: rect.y + rect.h / 2 };
11729
- case "t":
11730
- return { x: rect.x + rect.w / 2, y: rect.y };
11731
- default:
11732
- return { x: rect.x + rect.w / 2, y: rect.y + rect.h };
11733
- }
11734
- }
11735
11723
  function normalOf(face) {
11736
11724
  switch (face) {
11737
11725
  case "r":
@@ -11867,15 +11855,6 @@ function simplify(points) {
11867
11855
  }
11868
11856
  return out;
11869
11857
  }
11870
- function routeEdge(from, to, fromFace, toFace, obstacles, options = {}) {
11871
- return routeBetween(
11872
- { start: anchorOf(from, fromFace), startFace: fromFace, end: anchorOf(to, toFace), endFace: toFace },
11873
- from,
11874
- to,
11875
- obstacles,
11876
- options
11877
- );
11878
- }
11879
11858
  function snapToChannels(points, obstacles, margin) {
11880
11859
  if (points.length < 3) return points;
11881
11860
  const rects = obstacles;
@@ -13114,42 +13093,158 @@ function StackDrawer(props) {
13114
13093
  for (const box of obstacles) {
13115
13094
  if (point.x > box.x + 1 && point.x < box.x + box.w - 1 && point.y > box.y + 1 && point.y < box.y + box.h - 1) hits2 += 1;
13116
13095
  }
13096
+ for (const endpoint of [fromRect, toRect]) {
13097
+ if (point.x <= endpoint.x + 1 || point.x >= endpoint.x + endpoint.w - 1) continue;
13098
+ if (point.y <= endpoint.y + 1 || point.y >= endpoint.y + endpoint.h - 1) continue;
13099
+ const away = Math.min(
13100
+ Math.hypot(point.x - (endpoint.x + endpoint.w / 2), point.y - endpoint.y),
13101
+ Math.hypot(point.x - (endpoint.x + endpoint.w / 2), point.y - (endpoint.y + endpoint.h)),
13102
+ Math.hypot(point.x - endpoint.x, point.y - (endpoint.y + endpoint.h / 2)),
13103
+ Math.hypot(point.x - (endpoint.x + endpoint.w), point.y - (endpoint.y + endpoint.h / 2))
13104
+ );
13105
+ if (away > 14) hits2 += 1;
13106
+ }
13117
13107
  if (point.x < 2 || point.y < 2 || point.x > boundsWidth - 2 || point.y > boundsHeight - 2) hits2 += 1;
13118
13108
  }
13119
13109
  }
13120
13110
  return hits2;
13121
13111
  };
13122
- const FACES = ["t", "r", "b", "l"];
13123
- let points = routeEdge(
13124
- fromRect,
13125
- toRect,
13126
- faces.fromHandle,
13127
- faces.toHandle,
13128
- [fromRect, toRect, ...obstacles],
13129
- { stub: 10 }
13130
- );
13131
- let bestDirty = dirty(points);
13132
- if (bestDirty > 0) {
13133
- let bestPoints = points;
13134
- for (const fromFace of FACES) {
13135
- for (const toFace of FACES) {
13136
- if (fromFace === faces.fromHandle && toFace === faces.toHandle) continue;
13137
- const attempt = routeEdge(fromRect, toRect, fromFace, toFace, [fromRect, toRect, ...obstacles], { stub: 10 });
13138
- const attemptDirty = dirty(attempt);
13139
- if (attemptDirty < bestDirty) {
13140
- bestDirty = attemptDirty;
13141
- bestPoints = attempt;
13142
- if (bestDirty === 0) break;
13112
+ const sideOf = (rect, other) => {
13113
+ const dx = other.x + other.w / 2 - (rect.x + rect.w / 2);
13114
+ const dy = other.y + other.h / 2 - (rect.y + rect.h / 2);
13115
+ if (Math.abs(dx) >= Math.abs(dy)) return dx >= 0 ? "r" : "l";
13116
+ return dy >= 0 ? "b" : "t";
13117
+ };
13118
+ const anchorOf = (rect, side) => side === "t" ? { x: rect.x + rect.w / 2, y: rect.y } : side === "b" ? { x: rect.x + rect.w / 2, y: rect.y + rect.h } : side === "l" ? { x: rect.x, y: rect.y + rect.h / 2 } : { x: rect.x + rect.w, y: rect.y + rect.h / 2 };
13119
+ const normalOf2 = (side) => side === "t" ? { x: 0, y: -1 } : side === "b" ? { x: 0, y: 1 } : side === "l" ? { x: -1, y: 0 } : { x: 1, y: 0 };
13120
+ const fromSide = sideOf(fromRect, toRect);
13121
+ const toSide = sideOf(toRect, fromRect);
13122
+ const startPoint = anchorOf(fromRect, fromSide);
13123
+ const endPoint = anchorOf(toRect, toSide);
13124
+ const startNormal = normalOf2(fromSide);
13125
+ const endNormal = normalOf2(toSide);
13126
+ const span = Math.hypot(endPoint.x - startPoint.x, endPoint.y - startPoint.y);
13127
+ const badness = (sample) => {
13128
+ let bad = 0;
13129
+ for (let step2 = 0; step2 <= 40; step2 += 1) {
13130
+ const point = sample(step2 / 40);
13131
+ if (point.x < 6 || point.y < 6 || point.x > boundsWidth - 6 || point.y > boundsHeight - 6) bad += 1;
13132
+ for (const card of cardsInDrawer) {
13133
+ if (point.x <= card.x + 2 || point.x >= card.x + card.w - 2) continue;
13134
+ if (point.y <= card.y + 2 || point.y >= card.y + card.h - 2) continue;
13135
+ const own = card.id === link2.from || card.id === link2.to;
13136
+ const nearStart = Math.hypot(point.x - startPoint.x, point.y - startPoint.y) < 18;
13137
+ const nearEnd = Math.hypot(point.x - endPoint.x, point.y - endPoint.y) < 18;
13138
+ if (own && (nearStart || nearEnd)) continue;
13139
+ bad += 1;
13140
+ }
13141
+ }
13142
+ return bad;
13143
+ };
13144
+ let bestD;
13145
+ let bestCost = Number.POSITIVE_INFINITY;
13146
+ const tryCurve = (control1, control2) => {
13147
+ const u1 = (t2) => (1 - t2) * (1 - t2) * (1 - t2);
13148
+ const u2 = (t2) => 3 * (1 - t2) * (1 - t2) * t2;
13149
+ const u3 = (t2) => 3 * (1 - t2) * t2 * t2;
13150
+ const u4 = (t2) => t2 * t2 * t2;
13151
+ const sample = (t2) => ({
13152
+ x: u1(t2) * startPoint.x + u2(t2) * control1.x + u3(t2) * control2.x + u4(t2) * endPoint.x,
13153
+ y: u1(t2) * startPoint.y + u2(t2) * control1.y + u3(t2) * control2.y + u4(t2) * endPoint.y
13154
+ });
13155
+ const cost = badness(sample);
13156
+ if (cost < bestCost) {
13157
+ bestCost = cost;
13158
+ bestD = "M " + startPoint.x + " " + startPoint.y + " C " + control1.x + " " + control1.y + ", " + control2.x + " " + control2.y + ", " + endPoint.x + " " + endPoint.y;
13159
+ }
13160
+ };
13161
+ for (const bow of [0.15, 0.3, 0.5, 0.75, 1.1]) {
13162
+ const reach = Math.max(18, span * bow);
13163
+ const c1 = { x: startPoint.x + startNormal.x * reach, y: startPoint.y + startNormal.y * reach };
13164
+ const c2 = { x: endPoint.x + endNormal.x * reach, y: endPoint.y + endNormal.y * reach };
13165
+ tryCurve(c1, c2);
13166
+ if (bestCost === 0) break;
13167
+ }
13168
+ if (bestCost > 0) {
13169
+ const pad = 10;
13170
+ const pairTop = Math.min(fromRect.y, toRect.y);
13171
+ const pairBottom = Math.max(fromRect.y + fromRect.h, toRect.y + toRect.h);
13172
+ const pairLeft = Math.min(fromRect.x, toRect.x);
13173
+ const pairRight = Math.max(fromRect.x + fromRect.w, toRect.x + toRect.w);
13174
+ const midX = (startPoint.x + endPoint.x) / 2;
13175
+ const midY = (startPoint.y + endPoint.y) / 2;
13176
+ const waypoints = [
13177
+ { x: midX, y: Math.max(pad, pairTop - 16) },
13178
+ { x: midX, y: Math.min(boundsHeight - pad, pairBottom + 16) },
13179
+ { x: Math.max(pad, pairLeft - 16), y: midY },
13180
+ { x: Math.min(boundsWidth - pad, pairRight + 16), y: midY }
13181
+ ];
13182
+ for (const waypoint of waypoints) {
13183
+ tryCurve(waypoint, waypoint);
13184
+ if (bestCost === 0) break;
13185
+ }
13186
+ }
13187
+ if (bestCost > 0) {
13188
+ const bands2 = (values, size) => {
13189
+ const unique = [...new Set(values.map((value) => Math.round(value)))].sort((a, b) => a - b);
13190
+ const lanes = [];
13191
+ for (let index2 = 1; index2 < unique.length; index2 += 1) {
13192
+ lanes.push((unique[index2 - 1] + size + unique[index2]) / 2);
13193
+ }
13194
+ const first = unique[0];
13195
+ const last = unique[unique.length - 1];
13196
+ if (first !== void 0) lanes.unshift(Math.max(8, first - 14));
13197
+ if (last !== void 0) lanes.push(last + size + 14);
13198
+ return lanes;
13199
+ };
13200
+ const samplePolyline = (points) => (t2) => {
13201
+ let total = 0;
13202
+ for (let index2 = 1; index2 < points.length; index2 += 1) {
13203
+ total += Math.abs(points[index2].x - points[index2 - 1].x) + Math.abs(points[index2].y - points[index2 - 1].y);
13204
+ }
13205
+ let walked = 0;
13206
+ const target = t2 * total;
13207
+ for (let index2 = 1; index2 < points.length; index2 += 1) {
13208
+ const a = points[index2 - 1];
13209
+ const b = points[index2];
13210
+ const length = Math.abs(b.x - a.x) + Math.abs(b.y - a.y);
13211
+ if (walked + length >= target || index2 === points.length - 1) {
13212
+ const ratio = length === 0 ? 0 : Math.min(1, (target - walked) / length);
13213
+ return { x: a.x + (b.x - a.x) * ratio, y: a.y + (b.y - a.y) * ratio };
13143
13214
  }
13215
+ walked += length;
13216
+ }
13217
+ return points[points.length - 1];
13218
+ };
13219
+ const midY = (startPoint.y + endPoint.y) / 2;
13220
+ const midX = (startPoint.x + endPoint.x) / 2;
13221
+ const lanesY = bands2(cardsInDrawer.map((card) => card.y), 104).sort((a, b) => Math.abs(a - midY) - Math.abs(b - midY));
13222
+ const lanesX = bands2(cardsInDrawer.map((card) => card.x), 224).sort((a, b) => Math.abs(a - midX) - Math.abs(b - midX));
13223
+ const shapes = [];
13224
+ for (const lane of lanesY) {
13225
+ shapes.push([startPoint, { x: startPoint.x, y: lane }, { x: endPoint.x, y: lane }, endPoint]);
13226
+ }
13227
+ for (const lane of lanesX) {
13228
+ shapes.push([startPoint, { x: lane, y: startPoint.y }, { x: lane, y: endPoint.y }, endPoint]);
13229
+ }
13230
+ for (const shape of shapes) {
13231
+ const cost = badness(samplePolyline(shape));
13232
+ if (cost < bestCost) {
13233
+ bestCost = cost;
13234
+ bestD = roundedPath(shape, 10);
13235
+ if (cost === 0) break;
13144
13236
  }
13145
- if (bestDirty === 0) break;
13146
13237
  }
13147
- points = bestPoints;
13148
13238
  }
13149
- const tip = points[points.length - 1];
13150
- const prev = points[points.length - 2];
13151
- const angle = Math.abs(tip.x - prev.x) >= Math.abs(tip.y - prev.y) ? tip.x >= prev.x ? 0 : 180 : tip.y >= prev.y ? 90 : -90;
13152
- next.push({ d: roundedPath(points, 8), ax: tip.x, ay: tip.y, angle });
13239
+ const angle = toSide === "l" ? 180 : toSide === "r" ? 0 : toSide === "t" ? -90 : 90;
13240
+ next.push({
13241
+ d: bestD ?? "M " + startPoint.x + " " + startPoint.y + " L " + endPoint.x + " " + endPoint.y,
13242
+ ax: endPoint.x,
13243
+ ay: endPoint.y,
13244
+ angle,
13245
+ from: link2.from,
13246
+ to: link2.to
13247
+ });
13153
13248
  }
13154
13249
  setWires((current) => {
13155
13250
  if (current.length === next.length && current.every((wire, index2) => wire.d === next[index2]?.d)) {
@@ -13347,6 +13442,8 @@ function StackDrawer(props) {
13347
13442
  "path",
13348
13443
  {
13349
13444
  d: wire.d,
13445
+ "data-from": wire.from ?? "",
13446
+ "data-to": wire.to ?? "",
13350
13447
  fill: "none",
13351
13448
  stroke: "rgba(200, 206, 216, 0.42)",
13352
13449
  strokeWidth: 1.4,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-talk-map",
3
- "version": "0.1.46",
3
+ "version": "0.1.49",
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",