dsh-timeback 0.7.0 → 0.7.2

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.
package/docs/MARKET.md CHANGED
@@ -78,12 +78,12 @@ dshmarket;要让所有人的 dshmarket 搜到,必须走下一节的公共目
78
78
 
79
79
  ## 4. npm(已发布 0.6.0)
80
80
 
81
- `dsh-timeback@0.7.0` 已发布到官方 npm(<https://www.npmjs.com/package/dsh-timeback>),
81
+ `dsh-timeback@0.7.2` 已发布到官方 npm(<https://www.npmjs.com/package/dsh-timeback>),
82
82
  用户可以直接安装/固定版本:
83
83
 
84
84
  ```bash
85
85
  dsh plugin --profile web add dsh-timeback
86
- dsh plugin --profile web add dsh-timeback@0.7.0
86
+ dsh plugin --profile web add dsh-timeback@0.7.2
87
87
  ```
88
88
 
89
89
  awesome 目录 CI 会从 npm 自动补充映射,之后市场安装和更新会走 registry。发布流程参考:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-timeback",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Conversation tree with per-turn workspace snapshots for DeepSeek Harness: branch at any checkpoint and restore the files that turn had.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/notes.js CHANGED
@@ -47,11 +47,36 @@ function normalizeEntry(input, now) {
47
47
  }
48
48
 
49
49
  /** One empty sticky-note board canvas. */
50
+ const BOARD_ANCHORS = new Set(['top', 'right', 'bottom', 'left'])
51
+ const MAX_EDGES = 200
52
+
50
53
  function emptyCanvas() {
51
- return { notes: {}, background: [], drawings: {} }
54
+ return { notes: {}, background: [], drawings: {}, edges: [] }
55
+ }
56
+
57
+ /** Clamp note-to-note connector edges. */
58
+ function normalizeEdges(list) {
59
+ if (!Array.isArray(list)) return []
60
+ const edges = []
61
+ for (const raw of list.slice(0, MAX_EDGES)) {
62
+ if (raw === null || typeof raw !== 'object') continue
63
+ const from = raw.from
64
+ const to = raw.to
65
+ if (!from || !to || typeof from.noteId !== 'string' || typeof to.noteId !== 'string') continue
66
+ if (!BOARD_ANCHORS.has(from.anchor) || !BOARD_ANCHORS.has(to.anchor)) continue
67
+ if (from.noteId === to.noteId) continue
68
+ edges.push({
69
+ id: typeof raw.id === 'string' && raw.id !== '' ? raw.id : `eg-${Math.random().toString(36).slice(2, 10)}`,
70
+ from: { noteId: from.noteId, anchor: from.anchor },
71
+ to: { noteId: to.noteId, anchor: to.anchor },
72
+ color: STROKE_COLORS.test(String(raw.color || '')) ? String(raw.color) : '#7aa2ff',
73
+ })
74
+ }
75
+ return edges
52
76
  }
53
77
 
54
78
  const STROKE_COLORS = /^#[0-9a-f]{3,8}$/i
79
+ const STROKE_KINDS = new Set(['pen', 'line', 'rect', 'ellipse', 'arrow', 'triangle'])
55
80
  const MAX_STROKES = 120
56
81
  const MAX_POINTS = 800
57
82
 
@@ -61,12 +86,15 @@ function normalizeStrokes(list) {
61
86
  const strokes = []
62
87
  for (const raw of list.slice(0, MAX_STROKES)) {
63
88
  if (raw === null || typeof raw !== 'object' || !Array.isArray(raw.points)) continue
64
- const points = raw.points
89
+ const kind = STROKE_KINDS.has(raw.kind) ? raw.kind : 'pen'
90
+ let points = raw.points
65
91
  .filter((point) => Array.isArray(point) && point.length >= 2)
66
92
  .map((point) => [Math.round(Number(point[0]) || 0), Math.round(Number(point[1]) || 0)])
67
93
  .slice(0, MAX_POINTS)
94
+ if (kind !== 'pen') points = points.slice(0, 2)
68
95
  if (points.length < 2) continue
69
96
  strokes.push({
97
+ kind,
70
98
  color: STROKE_COLORS.test(String(raw.color || '')) ? String(raw.color) : '#e6b84c',
71
99
  width: Math.min(8, Math.max(1, Number(raw.width) || 2)),
72
100
  points,
@@ -85,6 +113,8 @@ function normalizeCanvas(value) {
85
113
  notes[id] = {
86
114
  x: Math.round(Number(layout.x) || 0),
87
115
  y: Math.round(Number(layout.y) || 0),
116
+ width: Math.min(640, Math.max(160, Math.round(Number(layout.width) || 232))),
117
+ height: Math.min(560, Math.max(120, Math.round(Number(layout.height) || 176))),
88
118
  z: Math.round(Number(layout.z) || 0),
89
119
  color: STROKE_COLORS.test(String(layout.color || '')) ? String(layout.color) : '#f0c36b',
90
120
  }
@@ -97,7 +127,7 @@ function normalizeCanvas(value) {
97
127
  if (normalized.length > 0) drawings[id] = normalized
98
128
  }
99
129
  }
100
- return { notes, background: normalizeStrokes(canvas.background), drawings }
130
+ return { notes, background: normalizeStrokes(canvas.background), drawings, edges: normalizeEdges(canvas.edges) }
101
131
  }
102
132
 
103
133
  /** Clone one board state without sharing references. */
@@ -112,6 +142,7 @@ function cloneBoard(board) {
112
142
  drawings: Object.fromEntries(
113
143
  Object.entries(board.canvas?.drawings ?? {}).map(([id, strokes]) => [id, strokes.map((stroke) => ({ ...stroke, points: stroke.points.map((point) => [...point]) }))]),
114
144
  ),
145
+ edges: (board.canvas?.edges ?? []).map((edge) => ({ ...edge, from: { ...edge.from }, to: { ...edge.to } })),
115
146
  },
116
147
  }
117
148
  }
@@ -231,6 +262,7 @@ export class NotesStore {
231
262
  const [entry] = draft.entries.splice(index, 1)
232
263
  delete draft.canvas.notes[entry.id]
233
264
  delete draft.canvas.drawings[entry.id]
265
+ draft.canvas.edges = draft.canvas.edges.filter((edge) => edge.from.noteId !== entry.id && edge.to.noteId !== entry.id)
234
266
  return { entry }
235
267
  }, '删除记录')
236
268
  return { entry: outcome.result.entry, board: outcome.board }
@@ -252,6 +284,7 @@ export class NotesStore {
252
284
  for (const id of Object.keys(draft.canvas.notes)) {
253
285
  if (!ids.has(id)) delete draft.canvas.notes[id]
254
286
  }
287
+ draft.canvas.edges = draft.canvas.edges.filter((edge) => ids.has(edge.from.noteId) && ids.has(edge.to.noteId))
255
288
  return { canvas: draft.canvas }
256
289
  }, '更新便签板')
257
290
  return { board: outcome.board }