dsh-prime-memory 0.26.33 → 0.26.34

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # 更新日志(Changelog)
2
2
 
3
+ ## [0.26.33] — 2026-11-04
4
+
5
+ - **根治 3D 记忆海「闪一下变暗」:不是掉帧,是 `resize()` 清空 canvas 位图后,空帧被合成器取样**
6
+
7
+ > 先说结论:前一轮「每帧重绘太贵 → 掉帧 → 分层缓存 + 空闲停摆」的修复方向是错的,`0.26.33-local.1..4` 的四次本地迭代都治的是另一个病。真正的机制是——给 `canvas.width` 赋值这个动作本身会清空整张位图(规范行为),而 `ResizeObserver` 回调落在渲染步骤的 **layout 之后、paint 之前**:此刻清空、本帧就 paint,擦白的那一帧必然上屏,下一 rAF 才补画回来。所以观感是「闪一下」,且只在外部尺寸事件触发时出现,与单帧耗时无关。
8
+
9
+ - **像素级取证(推翻多模态观察)**:多模态逐帧描述前后三轮互相矛盾(有说 t=7s 黑屏的、有说全片无黑屏的),改用 `ffmpeg signalstats` 拉全片 **324 帧(30fps / 10.8s)** 客观统计——整片 YAVG 只有 **两个离散值**:`49.20` 与 `40.46`;**22 张暗帧完全同参**(YAVG=40.46 / SATAVG=7.29 / SATMAX=75),说明它们是**同一张图反复出现**,不是渐进掉元素。
10
+ - **定位到「位图透明」而非「元素缺失」**:暗帧下画布三个区域全部塌到同一个纯色——黄簇 `28.69→22.00`、青簇 `26.13→22.00`、空白星空区 `30.95→22.89`,饱和全落到 `≈4.00`。Y=22 是 limited-range,换全范围 luma ≈ 7,而 canvas 元素 L779 的 inline background `#04070f` 实测 luma = **6.99**——对上了:看到的是 canvas 自己的背景色透出来,不是背景层或点层画了一半。
11
+ - **排除合成器/GPU/整窗级问题**:同帧内左侧栏 `61.94→61.81`(-0.2%)、顶部图例条 `100.52→100.52`(**像素零差异**)。窗体重排、resize 抖动、掉驱动都会被这一条否掉。
12
+ - **修复一(幂等 resize)**:`resize()` 改成返回布尔——尺寸与 DPR 都未变时整段跳过,不碰 `canvas.width`。RO 在布局抖动/滚动条出现时的重复触发从此是零成本,不再反复擦白。
13
+ - **修复二(RO 内同步出帧)**:新增 `presentNow()`,RO 里 `if (resize()) presentNow()`——真擦了就**当场画完上屏**,把「清空 → paint 空帧 → 下一 rAF 补画」压成同一渲染步骤内的原子操作。原来那句 `wake()` 只排下一 rAF,本帧照旧 paint 空位图,这是闪烁的直接成因。
14
+ - **修复三(帧句柄自清)**:`frame()` 入口 `raf = 0`。它现在会被 `presentNow()` 同步调用,留着旧句柄会让后续 `wake()` 以为还有链在跑而漏排帧。
15
+ - **附带(非闪烁,每帧税)**:`getComputedStyle` 解色从「每帧 4 次」改为脏标记缓存(`refreshColors()`,仅 resize 与本 effect 重建时置脏)。原实现每帧强制同步样式重算,是纯白交的开销;语义不变——令牌解析时机仍是「主题/尺寸变化」。
16
+
17
+ - **为什么分层缓存没能解决**:那套改动只降低单帧重绘成本、减少 rAF 次数,但闪烁发生在「可见 canvas 被清空」这条独立通路上,三层缓存(edgeCv / nodeCv / buffer)再快也救不了本帧已经 paint 出去的空位图。反过来说,分层缓存本身是有效的性能优化,保留。
18
+ - **未改任何对外契约**:无新配置键、无端点变化、无默认值变化;仅 `client/src/explorer/Scene3D.tsx` 内部渲染调度。
19
+ - **验证口径(可复现)**:重录 30s 后跑 `ffmpeg -i <rec> -vf "signalstats,metadata=print:file=signalstats.txt" -f null NUL`,**暗帧计数必须为 0**(修复前同一口径为 22/324 帧)。本机已核对:`desktop` profile 装的是 `v0.26.33-local.4`,`dist/client.js` 哈希 `A6879304…` 与源码构建一致——闪烁不是「没装上新代码」,是代码里还在。
20
+ - **测试**:全量 **2048 passed / 1 skipped**(200 文件);client typecheck 0、`eslint client/src/explorer/Scene3D.tsx` 0 error;`npm run build` 0。产物核对:`dist/client.js` 新哈希 `98DD1061…`,与装入 `desktop` profile 的副本逐字节一致(`v0.26.33-local.5`)。
21
+
3
22
  ## [0.26.31] — 2026-11-03
4
23
 
5
24
  - **回填 0.26.30 的测试缺口 + 让 npm 产物与 main 对齐(无运行时行为变更)**
package/dist/client.js CHANGED
@@ -44864,6 +44864,7 @@ var __create = Object.create;
44864
44864
 
44865
44865
  // client/src/explorer/projection.ts
44866
44866
  var FOCAL = 1100;
44867
+ var LABEL_SKIP_DIST = 2600;
44867
44868
  var CAM_DEFAULT = { yaw: 0.45, pitch: -0.3, dist: 1200, panX: 0, panY: 0 };
44868
44869
  var DIST_MIN = 380;
44869
44870
  var DIST_MAX = 3200;
@@ -45023,6 +45024,10 @@ var __create = Object.create;
45023
45024
  }
45024
45025
  return null;
45025
45026
  }
45027
+ var BREATH_PERIOD_MS = 260;
45028
+ function phaseOf(id) {
45029
+ return hash322(id) % 6283 / 1e3;
45030
+ }
45026
45031
  function easeInOut(p) {
45027
45032
  const k = Math.min(1, Math.max(0, p));
45028
45033
  return k < 0.5 ? 2 * k * k : 1 - Math.pow(-2 * k + 2, 2) / 2;
@@ -45074,6 +45079,7 @@ var __create = Object.create;
45074
45079
  const [pointSize, setPointSize] = (0, import_react32.useState)(2.2);
45075
45080
  const [driftOn, setDriftOn] = (0, import_react32.useState)(false);
45076
45081
  const [starry, setStarry] = (0, import_react32.useState)(true);
45082
+ const [twinkleOn, setTwinkleOn] = (0, import_react32.useState)(true);
45077
45083
  const camRef = (0, import_react32.useRef)({ ...CAM_DEFAULT });
45078
45084
  const modeRef = (0, import_react32.useRef)("cluster");
45079
45085
  const focusRef = (0, import_react32.useRef)(null);
@@ -45084,7 +45090,7 @@ var __create = Object.create;
45084
45090
  const clickRef = (0, import_react32.useRef)(null);
45085
45091
  const emphasisRef = (0, import_react32.useRef)(emphasisId);
45086
45092
  emphasisRef.current = emphasisId;
45087
- const dirtyRef = (0, import_react32.useRef)(true);
45093
+ const wakeRef = (0, import_react32.useRef)(null);
45088
45094
  const degree = (0, import_react32.useMemo)(() => degreeMapOf(full), [full]);
45089
45095
  const edgeList = (0, import_react32.useMemo)(
45090
45096
  () => full.edges.map((e) => ({ from: e.from, to: e.to, relation: e.relation, causal: e.causal })),
@@ -45126,6 +45132,7 @@ var __create = Object.create;
45126
45132
  camRef.current.dist = Math.min(3200, Math.max(380, EGO_HOPS_MAX2 * 300 * 1.55));
45127
45133
  camRef.current.panX = 0;
45128
45134
  camRef.current.panY = 0;
45135
+ wakeRef.current?.();
45129
45136
  }, [emphasisId, adj, clusterLayout]);
45130
45137
  const metasRef = (0, import_react32.useRef)(/* @__PURE__ */ new Map());
45131
45138
  const spritesRef = (0, import_react32.useRef)(/* @__PURE__ */ new Map());
@@ -45168,14 +45175,33 @@ var __create = Object.create;
45168
45175
  if (!host || !canvas) return;
45169
45176
  const ctx = canvas.getContext("2d");
45170
45177
  if (!ctx) return;
45171
- dirtyRef.current = true;
45172
45178
  const buffer = document.createElement("canvas");
45173
45179
  const bctx = buffer.getContext("2d");
45180
+ const edgeCv = document.createElement("canvas");
45181
+ const ectx = edgeCv.getContext("2d");
45182
+ const nodeCv = document.createElement("canvas");
45183
+ const nctx = nodeCv.getContext("2d");
45184
+ let edgeDirty = true;
45185
+ let nodeDirty = true;
45186
+ let needsPresent = true;
45187
+ let lastActiveKey = "";
45174
45188
  let raf = 0;
45189
+ let running = false;
45175
45190
  let disposed = false;
45176
45191
  let vw = 0;
45177
45192
  let vh = 0;
45178
45193
  const dprRef = { current: 1 };
45194
+ let colEdge = "";
45195
+ let colCausal = "";
45196
+ let colText = "";
45197
+ let colStale = true;
45198
+ const refreshColors = () => {
45199
+ if (!colStale) return;
45200
+ colEdge = resolveColor2(host, "--dsh-mem-border-strong");
45201
+ colCausal = resolveColor2(host, "--dsh-mem-accent");
45202
+ colText = resolveColor2(host, "--dsh-mem-text-2");
45203
+ colStale = false;
45204
+ };
45179
45205
  const spriteFor = (color) => {
45180
45206
  const hit = spritesRef.current.get(color);
45181
45207
  if (hit) return hit;
@@ -45247,23 +45273,41 @@ var __create = Object.create;
45247
45273
  }
45248
45274
  return cv;
45249
45275
  };
45276
+ let sized = false;
45250
45277
  const resize = () => {
45251
45278
  const dpr = Math.min(2, window.devicePixelRatio || 1);
45279
+ const nextW = host.clientWidth || 640;
45280
+ const nextH = host.clientHeight || host.offsetHeight || height;
45281
+ if (sized && nextW === vw && nextH === vh && dpr === dprRef.current) return false;
45282
+ sized = true;
45252
45283
  dprRef.current = dpr;
45253
- vw = host.clientWidth || 640;
45254
- vh = host.clientHeight || host.offsetHeight || height;
45284
+ vw = nextW;
45285
+ vh = nextH;
45255
45286
  canvas.width = Math.round(vw * dpr);
45256
45287
  canvas.height = Math.round(vh * dpr);
45257
45288
  canvas.style.width = `${vw}px`;
45258
45289
  canvas.style.height = `${vh}px`;
45259
45290
  buffer.width = canvas.width;
45260
45291
  buffer.height = canvas.height;
45292
+ edgeCv.width = canvas.width;
45293
+ edgeCv.height = canvas.height;
45294
+ nodeCv.width = canvas.width;
45295
+ nodeCv.height = canvas.height;
45296
+ ectx.setTransform(dpr, 0, 0, dpr, 0, 0);
45297
+ nctx.setTransform(dpr, 0, 0, dpr, 0, 0);
45261
45298
  bctx.setTransform(dpr, 0, 0, dpr, 0, 0);
45262
45299
  ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
45263
45300
  bgCache = null;
45301
+ edgeDirty = true;
45302
+ nodeDirty = true;
45303
+ colStale = true;
45304
+ needsPresent = true;
45305
+ return true;
45264
45306
  };
45265
45307
  resize();
45266
- const ro = new ResizeObserver(resize);
45308
+ const ro = new ResizeObserver(() => {
45309
+ if (resize()) presentNow();
45310
+ });
45267
45311
  ro.observe(host);
45268
45312
  const activeLayout = (now) => {
45269
45313
  const tr = transRef.current;
@@ -45278,133 +45322,192 @@ var __create = Object.create;
45278
45322
  };
45279
45323
  let lastProjected = [];
45280
45324
  const frame = (now) => {
45325
+ raf = 0;
45281
45326
  if (disposed) return;
45327
+ refreshColors();
45282
45328
  const cam = camRef.current;
45283
45329
  const layout = activeLayout(now);
45284
45330
  const ego = modeRef.current === "ego";
45285
45331
  const metas = metasRef.current;
45286
45332
  const hover = hoverRef.current;
45287
45333
  const focus = focusRef.current;
45288
- let nbSet = null;
45289
- if (hover) {
45290
- nbSet = /* @__PURE__ */ new Set([hover, ...adj.get(hover) ?? []]);
45291
- if (focus && focus !== hover) nbSet.add(focus);
45334
+ const emph = emphasisRef.current;
45335
+ if (transRef.current !== null || driftOn && !ego) {
45336
+ edgeDirty = true;
45337
+ nodeDirty = true;
45292
45338
  }
45293
45339
  const projected = projectAll(layout, cam, { w: vw, h: vh }, void 0, now, driftOn && !ego);
45294
45340
  lastProjected = projected;
45295
- const c = bctx;
45296
- c.clearRect(0, 0, vw, vh);
45297
- if (!bgCache || bgCacheW !== vw || bgCacheH !== vh || bgCacheStarry !== starry) {
45298
- bgCache = bakeBg(vw, vh, starry, nodeKeySeed);
45299
- bgCacheW = vw;
45300
- bgCacheH = vh;
45301
- bgCacheStarry = starry;
45302
- }
45303
- c.drawImage(bgCache, 0, 0);
45341
+ const activeKey = `${hover ?? ""}|${focus ?? ""}|${emph ?? ""}`;
45342
+ if (activeKey !== lastActiveKey) {
45343
+ lastActiveKey = activeKey;
45344
+ nodeDirty = true;
45345
+ }
45346
+ const activeIds = /* @__PURE__ */ new Set();
45347
+ if (hover) activeIds.add(hover);
45348
+ if (focus) activeIds.add(focus);
45349
+ if (emph) activeIds.add(emph);
45304
45350
  const pos = new Map(projected.map((p) => [p.id, p]));
45305
- if (edgesOn) {
45306
- const edgeBase = resolveColor2(host, "--dsh-mem-border-strong");
45307
- const causalC = resolveColor2(host, "--dsh-mem-accent");
45308
- c.globalCompositeOperation = "source-over";
45309
- for (const e of edgeList) {
45310
- const a = pos.get(e.from);
45311
- const b = pos.get(e.to);
45312
- if (!a || !b) continue;
45313
- const related = !hover || nbSet.has(e.from) && nbSet.has(e.to) && (e.from === hover || e.to === hover);
45314
- if (hover && !related) continue;
45315
- const avgF = (a.f + b.f) / 2;
45316
- const alpha = Math.min(0.9, Math.max(0.05, avgF * 0.34));
45317
- c.strokeStyle = e.causal ? causalC : edgeBase;
45318
- c.globalAlpha = hover ? Math.min(0.9, alpha + 0.25) : alpha;
45319
- c.lineWidth = e.causal ? 1.2 : 0.7;
45351
+ const edgeBase = colEdge;
45352
+ const causalC = colCausal;
45353
+ if (edgeDirty) {
45354
+ const c = ectx;
45355
+ c.clearRect(0, 0, vw, vh);
45356
+ if (!bgCache || bgCacheW !== vw || bgCacheH !== vh || bgCacheStarry !== starry) {
45357
+ bgCache = bakeBg(vw, vh, starry, nodeKeySeed);
45358
+ bgCacheW = vw;
45359
+ bgCacheH = vh;
45360
+ bgCacheStarry = starry;
45361
+ }
45362
+ c.drawImage(bgCache, 0, 0);
45363
+ if (edgesOn) {
45364
+ c.globalCompositeOperation = "source-over";
45365
+ for (const e of edgeList) {
45366
+ const a = pos.get(e.from);
45367
+ const b = pos.get(e.to);
45368
+ if (!a || !b) continue;
45369
+ const avgF = (a.f + b.f) / 2;
45370
+ c.strokeStyle = e.causal ? causalC : edgeBase;
45371
+ c.globalAlpha = Math.min(0.9, Math.max(0.05, avgF * 0.34));
45372
+ c.lineWidth = e.causal ? 1.2 : 0.7;
45373
+ c.beginPath();
45374
+ c.moveTo(a.x, a.y);
45375
+ c.lineTo(b.x, b.y);
45376
+ c.stroke();
45377
+ }
45378
+ c.globalAlpha = 1;
45379
+ }
45380
+ edgeDirty = false;
45381
+ needsPresent = true;
45382
+ }
45383
+ if (nodeDirty) {
45384
+ const c = nctx;
45385
+ c.clearRect(0, 0, vw, vh);
45386
+ for (const p of projected) {
45387
+ if (activeIds.has(p.id)) continue;
45388
+ const m = metas.get(p.id);
45389
+ if (!m) continue;
45390
+ const alpha = brightnessFor(p.f, agingOn ? m.aging : null, true);
45391
+ const r = Math.max(0.8, m.base * p.f * 1.75);
45392
+ if (glowOn) {
45393
+ c.globalCompositeOperation = "lighter";
45394
+ c.globalAlpha = alpha * 0.5;
45395
+ const sp = spriteFor(m.color);
45396
+ const gr = r * 3.4;
45397
+ c.drawImage(sp, p.x - gr, p.y - gr, gr * 2, gr * 2);
45398
+ }
45399
+ c.globalCompositeOperation = "source-over";
45400
+ c.globalAlpha = Math.min(1, alpha + 0.15);
45401
+ c.fillStyle = m.color;
45320
45402
  c.beginPath();
45321
- c.moveTo(a.x, a.y);
45322
- c.lineTo(b.x, b.y);
45323
- c.stroke();
45403
+ c.arc(p.x, p.y, r, 0, Math.PI * 2);
45404
+ c.fill();
45324
45405
  }
45325
45406
  c.globalAlpha = 1;
45326
- }
45327
- for (const p of projected) {
45328
- const m = metas.get(p.id);
45329
- if (!m) continue;
45330
- const isFocus = p.id === focus || p.id === emphasisRef.current;
45331
- const isHover = p.id === hover;
45332
- const dim = hover !== null && nbSet !== null && !nbSet.has(p.id) && !isFocus;
45333
- let alpha = brightnessFor(p.f, agingOn ? m.aging : null, true);
45334
- if (dim) alpha = Math.min(alpha, 0.12);
45335
- const r = Math.max(0.8, m.base * p.f * 1.75 * (isFocus || isHover ? 1.9 : 1));
45336
- if (glowOn) {
45337
- c.globalCompositeOperation = "lighter";
45338
- c.globalAlpha = alpha * 0.5;
45339
- const sp = spriteFor(m.color);
45340
- const gr = r * 3.4;
45341
- c.drawImage(sp, p.x - gr, p.y - gr, gr * 2, gr * 2);
45342
- }
45343
- c.globalCompositeOperation = "source-over";
45344
- c.globalAlpha = Math.min(1, alpha + 0.15);
45345
- c.fillStyle = m.color;
45346
- c.beginPath();
45347
- c.arc(p.x, p.y, r, 0, Math.PI * 2);
45348
- c.fill();
45349
- }
45350
- c.globalAlpha = 1;
45351
- if (labelsOn) {
45352
- const textColor = resolveColor2(host, "--dsh-mem-text-2");
45353
- const inSet = /* @__PURE__ */ new Set();
45354
- const cand = projected.filter((p) => metas.has(p.id)).map((p) => {
45355
- const m = metas.get(p.id);
45356
- const hot = p.id === focus || p.id === hover || p.id === emphasisRef.current;
45357
- if (hot) inSet.add(p.id);
45358
- return {
45359
- id: p.id,
45360
- x: p.x,
45361
- y: p.y,
45362
- f: p.f,
45363
- rank: (hot ? 1e6 : 0) + m.degree * 10 + (m.aging ?? 1) * 5 + hash322(p.id) % 7
45407
+ if (labelsOn && cam.dist <= LABEL_SKIP_DIST) {
45408
+ const textColor = colText;
45409
+ const cand = projected.filter((p) => metas.has(p.id) && !activeIds.has(p.id)).map((p) => {
45410
+ const m = metas.get(p.id);
45411
+ return { id: p.id, x: p.x, y: p.y, f: p.f, rank: m.degree * 10 + (m.aging ?? 1) * 5 + hash322(p.id) % 7 };
45412
+ });
45413
+ const widthOf = (id) => {
45414
+ const m = metas.get(id);
45415
+ return m ? clipByWidth(m.name).length * 6.4 : 0;
45364
45416
  };
45365
- });
45366
- const widthOf = (id) => {
45417
+ const picked = new Set(pickLabels(cand, labelBudget(cam.dist), widthOf, vw));
45418
+ c.globalCompositeOperation = "source-over";
45419
+ c.fillStyle = textColor;
45420
+ c.font = '11px system-ui, "Microsoft YaHei", sans-serif';
45421
+ for (const p of projected) {
45422
+ if (!picked.has(p.id)) continue;
45423
+ c.globalAlpha = Math.min(1, Math.max(0.35, p.f));
45424
+ c.fillText(clipByWidth(metas.get(p.id).name), p.x + 7, p.y - 5);
45425
+ }
45426
+ c.globalAlpha = 1;
45427
+ }
45428
+ nodeDirty = false;
45429
+ needsPresent = true;
45430
+ }
45431
+ const breathing = twinkleOn && activeIds.size > 0;
45432
+ if (breathing) {
45433
+ const c = bctx;
45434
+ c.setTransform(1, 0, 0, 1, 0, 0);
45435
+ c.drawImage(edgeCv, 0, 0);
45436
+ c.drawImage(nodeCv, 0, 0);
45437
+ c.setTransform(dprRef.current, 0, 0, dprRef.current, 0, 0);
45438
+ for (const id of activeIds) {
45439
+ const p = pos.get(id);
45367
45440
  const m = metas.get(id);
45368
- return m ? clipByWidth(m.name).length * 6.4 : 0;
45369
- };
45370
- const picked = /* @__PURE__ */ new Set([...pickLabels(cand, labelBudget(cam.dist), widthOf, vw), ...inSet]);
45371
- c.globalCompositeOperation = "source-over";
45372
- c.fillStyle = textColor;
45373
- c.font = '11px system-ui, "Microsoft YaHei", sans-serif';
45374
- for (const p of projected) {
45375
- if (!picked.has(p.id)) continue;
45376
- const m = metas.get(p.id);
45377
- const dim = hover !== null && nbSet !== null && !nbSet.has(p.id);
45378
- c.globalAlpha = dim ? 0.18 : Math.min(1, Math.max(0.35, p.f));
45379
- c.fillText(clipByWidth(m.name), p.x + 7, p.y - 5);
45380
- }
45381
- c.globalAlpha = 1;
45382
- }
45383
- if (hover && edgesOn) {
45384
- const causalC = resolveColor2(host, "--dsh-mem-accent");
45385
- const edgeBase = resolveColor2(host, "--dsh-mem-border-strong");
45386
- c.font = '10px system-ui, "Microsoft YaHei", sans-serif';
45387
- const used = /* @__PURE__ */ new Set();
45388
- const related = edgeList.filter((e) => (e.from === hover || e.to === hover) && pos.has(e.from) && pos.has(e.to)).sort((a, b) => Number(b.causal) - Number(a.causal));
45389
- for (const e of related.slice(0, 12)) {
45390
- const a = pos.get(e.from);
45391
- const b = pos.get(e.to);
45392
- const mx = (a.x + b.x) / 2;
45393
- const my = (a.y + b.y) / 2;
45394
- const cell = Math.floor(mx / 72) * 1e3 + Math.floor(my / 13);
45395
- if (used.has(cell)) continue;
45396
- used.add(cell);
45397
- c.fillStyle = e.causal ? causalC : edgeBase;
45398
- c.globalAlpha = 0.92;
45399
- c.fillText(e.relation, mx, my);
45400
- }
45401
- c.globalAlpha = 1;
45441
+ if (!p || !m) continue;
45442
+ const tw = 0.5 + 0.5 * Math.sin(now / BREATH_PERIOD_MS + phaseOf(id));
45443
+ const alpha = brightnessFor(p.f, agingOn ? m.aging : null, true);
45444
+ const r = Math.max(0.8, m.base * p.f * 1.75 * 1.9);
45445
+ if (glowOn) {
45446
+ c.globalCompositeOperation = "lighter";
45447
+ c.globalAlpha = Math.min(1, alpha * 0.5 + tw * 0.4);
45448
+ const sp = spriteFor(m.color);
45449
+ const gr = r * 3.4 * (1 + tw * 0.45);
45450
+ c.drawImage(sp, p.x - gr, p.y - gr, gr * 2, gr * 2);
45451
+ }
45452
+ c.globalCompositeOperation = "source-over";
45453
+ c.globalAlpha = Math.min(1, alpha + 0.15 + tw * 0.25);
45454
+ c.fillStyle = m.color;
45455
+ c.beginPath();
45456
+ c.arc(p.x, p.y, r, 0, Math.PI * 2);
45457
+ c.fill();
45458
+ if (labelsOn) {
45459
+ c.globalAlpha = 1;
45460
+ c.fillStyle = colText;
45461
+ c.font = '11px system-ui, "Microsoft YaHei", sans-serif';
45462
+ c.fillText(clipByWidth(m.name), p.x + 7, p.y - 5);
45463
+ }
45464
+ }
45465
+ if (hover && edgesOn) {
45466
+ c.font = '10px system-ui, "Microsoft YaHei", sans-serif';
45467
+ const used = /* @__PURE__ */ new Set();
45468
+ const related = edgeList.filter((e) => (e.from === hover || e.to === hover) && pos.has(e.from) && pos.has(e.to)).sort((a, b) => Number(b.causal) - Number(a.causal));
45469
+ for (const e of related.slice(0, 12)) {
45470
+ const a = pos.get(e.from);
45471
+ const b = pos.get(e.to);
45472
+ const mx = (a.x + b.x) / 2;
45473
+ const my = (a.y + b.y) / 2;
45474
+ const cell = Math.floor(mx / 72) * 1e3 + Math.floor(my / 13);
45475
+ if (used.has(cell)) continue;
45476
+ used.add(cell);
45477
+ c.fillStyle = e.causal ? causalC : edgeBase;
45478
+ c.globalAlpha = 0.92;
45479
+ c.fillText(e.relation, mx, my);
45480
+ }
45481
+ c.globalAlpha = 1;
45482
+ }
45483
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
45484
+ ctx.drawImage(buffer, 0, 0);
45485
+ ctx.setTransform(dprRef.current, 0, 0, dprRef.current, 0, 0);
45486
+ needsPresent = false;
45487
+ } else if (needsPresent) {
45488
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
45489
+ ctx.drawImage(edgeCv, 0, 0);
45490
+ ctx.drawImage(nodeCv, 0, 0);
45491
+ ctx.setTransform(dprRef.current, 0, 0, dprRef.current, 0, 0);
45492
+ needsPresent = false;
45493
+ }
45494
+ running = edgeDirty || nodeDirty || needsPresent || breathing || transRef.current !== null || driftOn && !ego;
45495
+ if (running) raf = requestAnimationFrame(frame);
45496
+ };
45497
+ const presentNow = () => {
45498
+ if (disposed) return;
45499
+ if (raf) cancelAnimationFrame(raf);
45500
+ raf = 0;
45501
+ running = false;
45502
+ frame(performance.now());
45503
+ };
45504
+ const wake = () => {
45505
+ if (!running && !disposed) {
45506
+ running = true;
45507
+ raf = requestAnimationFrame(frame);
45402
45508
  }
45403
- ctx.setTransform(1, 0, 0, 1, 0, 0);
45404
- ctx.drawImage(buffer, 0, 0);
45405
- ctx.setTransform(dprRef.current, 0, 0, dprRef.current, 0, 0);
45406
- raf = requestAnimationFrame(frame);
45407
45509
  };
45510
+ wakeRef.current = wake;
45408
45511
  frame(performance.now());
45409
45512
  const toLocal = (ev) => {
45410
45513
  const rect = canvas.getBoundingClientRect();
@@ -45428,13 +45531,15 @@ var __create = Object.create;
45428
45531
  }
45429
45532
  drag.x = pt.x;
45430
45533
  drag.y = pt.y;
45431
- dirtyRef.current = true;
45534
+ edgeDirty = true;
45535
+ nodeDirty = true;
45536
+ wake();
45432
45537
  return;
45433
45538
  }
45434
45539
  const hit = pickNearest(lastProjected, pt.x, pt.y, PICK_PX);
45435
45540
  if (hit !== hoverRef.current) {
45436
45541
  hoverRef.current = hit;
45437
- dirtyRef.current = true;
45542
+ wake();
45438
45543
  setHoverInfo(hit ? { id: hit, x: pt.x, y: pt.y } : null);
45439
45544
  } else if (hit) {
45440
45545
  setHoverInfo({ id: hit, x: pt.x, y: pt.y });
@@ -45487,7 +45592,9 @@ var __create = Object.create;
45487
45592
  const onWheel = (ev) => {
45488
45593
  ev.preventDefault();
45489
45594
  camRef.current.dist = zoomBy(camRef.current.dist, ev.deltaY);
45490
- dirtyRef.current = true;
45595
+ edgeDirty = true;
45596
+ nodeDirty = true;
45597
+ wake();
45491
45598
  };
45492
45599
  const onKey = (ev) => {
45493
45600
  if (ev.key === "Enter" && hoverRef.current) onPick(hoverRef.current);
@@ -45513,6 +45620,7 @@ var __create = Object.create;
45513
45620
  return () => {
45514
45621
  disposed = true;
45515
45622
  cancelAnimationFrame(raf);
45623
+ wakeRef.current = null;
45516
45624
  ro.disconnect();
45517
45625
  canvas.removeEventListener("mousedown", onDown);
45518
45626
  window.removeEventListener("mousemove", onMove);
@@ -45521,7 +45629,7 @@ var __create = Object.create;
45521
45629
  canvas.removeEventListener("mouseleave", onLeave);
45522
45630
  window.removeEventListener("keydown", onKey);
45523
45631
  };
45524
- }, [full, edgeList, adj, clusterLayout, glowOn, edgesOn, labelsOn, agingOn, driftOn, starry, nodeKeySeed, height, onPick]);
45632
+ }, [full, edgeList, adj, clusterLayout, glowOn, edgesOn, labelsOn, agingOn, driftOn, twinkleOn, starry, nodeKeySeed, pointSize, height, onPick]);
45525
45633
  const hoverMeta = hoverInfo ? metasRef.current.get(hoverInfo.id) : null;
45526
45634
  const ui = starry ? {
45527
45635
  barBg: "rgba(10, 13, 22, 0.72)",
@@ -45602,6 +45710,7 @@ var __create = Object.create;
45602
45710
  toggle("边", edgesOn, setEdgesOn),
45603
45711
  toggle("标签", labelsOn, setLabelsOn),
45604
45712
  toggle("老化亮度", agingOn, setAgingOn),
45713
+ toggle("呼吸", twinkleOn, setTwinkleOn),
45605
45714
  toggle("漂移", driftOn, setDriftOn),
45606
45715
  toggle(starry ? "星空底" : "白底", starry, setStarry),
45607
45716
  /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("label", { style: { fontSize: 11, color: ui.dim, display: "inline-flex", alignItems: "center", gap: 4 }, children: [
package/dsh.plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "dsh-prime-memory",
3
3
  "name": "dsh-prime-memory",
4
- "version": "0.26.33",
4
+ "version": "0.26.34",
5
5
  "description": {
6
6
  "en": "Layered distilled memory plugin (L0 capture → L1 atomic memory → L2 scenes → L3 persona) with automatic recall injection before each model step.",
7
7
  "zh": "L0~L3 分层蒸馏记忆插件:自动捕获对话、抽取原子记忆、整合场景块、蒸馏核心画像,并在模型步骤前自动召回注入。"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-prime-memory",
3
- "version": "0.26.33",
3
+ "version": "0.26.34",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public",