dsh-m 0.9.56 → 0.9.57

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
@@ -8,6 +8,13 @@ The full release history of dsh-m, maintained bilingually: **Chinese first, Engl
8
8
 
9
9
  ## 中文
10
10
 
11
+ ### 0.9.57 修复:精选切换后面板崩溃/无法重开 + 折叠筛选双框与 +N 重叠
12
+
13
+ - **根因(0.9.56 真机复现)**:精选区的标签对象可能每次父级重渲染都重建;layout effect 依赖 `chips` 数组引用及自身更新的 `geom`,同步测量反复进入、最终触发 React `Maximum update depth exceeded`(#185)。React 清空面板树但留下 `#dshm-panel-root`,旧入口守卫只检查容器存在,导致点击入口永久无效。叠加折叠筛选定位壳和按钮的双边框、以及 +N 位置夹取/文档流试验在窄宽下压住相邻 chip。
14
+ - **修复**:按实际渲染的分类 id/文案/计数生成稳定内容签名,layout effect 不再同步依赖自身 `geom`;预留槽变化改在上一轮状态提交后的 rAF 复测。回退 0.9.56 的 `display:none`/in-flow 反馈链,恢复分类全量占位 + 越界 `visibility:hidden`,以完整 `offsetTop` 按行纯派生隐藏数;+N 脱离文档流,独占右侧 52px 槽(筛选另占 96px),双类 CSS 选择器确保总预留不被 gutter 覆盖。末可见行顶按**去重行**而非第 N 颗 chip 计算。筛选外壳去边框仅保留定位;若崩溃留下无可见面板的空容器,再次点击时先移除再挂载。
15
+ - **取舍**:+N 优先保证零重叠、正确计数和可重开;不再强求其贴着最后一颗分类。窄宽下边界分类自然少显示,`+N` 如实计入;展开态 `⌃` 仍在分类列表末尾。
16
+ - **验证**:新增 3 个回归断言,累计 1224 测试全绿、typecheck 零错误;真实 DSH Web 加载候选客户端验证精选↔社区连续三次、关闭再开及崩溃残留空容器恢复;260–880px 六档 +N/chip/筛选相交面积恒 0,精选五类不出现错误 +N。
17
+
11
18
  ### 0.9.56 变更:ZoneChips +N 重叠根治——in-flow 文档流布局 + 折行减类(主人方案)
12
19
 
13
20
  - **缺陷(0.9.55 真机复现)**:折叠态 `+N` 采用「绝对定位 + contentW−48 夹取」,当末可见行剩余空间小于徽章宽时,徽章压住末可见 chip(真机:+9 压住「文档与渲染 61」右端计数)。
@@ -419,6 +426,13 @@ The full release history of dsh-m, maintained bilingually: **Chinese first, Engl
419
426
 
420
427
  ## English
421
428
 
429
+ ### Fixed in 0.9.57 — curated-zone update loop, dead panel entry, and collapsed filter/overflow overlaps
430
+
431
+ - **Root cause (reproduced on 0.9.56)**: curated labels may get a fresh object on every parent render; the layout effect depended on the `chips` array identity and on its own `geom` update. Synchronous remeasurement repeatedly entered the same commit, eventually throwing React `Maximum update depth exceeded` (#185). React emptied the panel tree while leaving `#dshm-panel-root`; the old entry guard checked only for a container and silently blocked every later open. The pinned Filter wrapper also added a second border around its bordered button, while the clamped/inline `+N` iterations overlapped neighboring chips at narrow widths.
432
+ - **Fix**: depend on a stable signature of rendered category IDs, labels and counts; defer geometry-dependent remeasurement to an animation frame after state commits. Retire the 0.9.56 `display:none`/in-flow feedback path in favor of a full in-flow chip layout with `visibility:hidden` beyond the clip; derive the hidden count from all chip row offsets. Give out-of-flow `+N` its own 52px right slot, separate from Filter's 96px, with a more specific selector so the total reservation wins the cascade. Measure the last visible **distinct row** rather than the Nth chip. Strip the redundant Filter-wrapper border; discard an orphaned panel root on the next open.
433
+ - **Tradeoff**: correctness, zero overlap and reopenability take precedence over keeping `+N` flush against the last chip. Its count remains truthful; expanded `⌃` remains at list end.
434
+ - **Verification**: three additional regression assertions, 1224 tests passing and clean typecheck; real DSH Web with the candidate client survived three curated↔community round trips, close/reopen and stale-root recovery; six widths from 260–880px showed zero badge/chip/Filter intersection, and curated's five categories showed no spurious `+N`.
435
+
422
436
  ### Fixed in 0.9.56 — ZoneChips +N overlap eradicated: in-flow document layout + wrap-yield-a-category (owner's design)
423
437
 
424
438
  - **Defect (reproduced on 0.9.55)**: the collapsed `+N` used "absolute positioning + contentW−48 clamp"; when the last visible row's leftover was narrower than the badge, the badge covered the last visible chip (real panel: +9 covering the tail of 文档与渲染 61).
package/lib/client.js CHANGED
@@ -41,6 +41,7 @@ __export(market_state_exports, {
41
41
  registryNotice: () => registryNotice,
42
42
  resetPageOnFilterChange: () => resetPageOnFilterChange,
43
43
  searchSourceOf: () => searchSourceOf,
44
+ visibleRowTop: () => visibleRowTop,
44
45
  zoneChips: () => zoneChips
45
46
  });
46
47
  function toSafeInt(value, fallback, min, max) {
@@ -278,6 +279,20 @@ function clipTopOf(offsets, maxRows) {
278
279
  }
279
280
  return Infinity;
280
281
  }
282
+ function visibleRowTop(offsets, maxRows) {
283
+ if (!Array.isArray(offsets) || !Number.isInteger(maxRows) || maxRows < 1) return 0;
284
+ let rows = 0;
285
+ let last = null;
286
+ for (const top of offsets) {
287
+ if (typeof top !== "number" || !Number.isFinite(top)) continue;
288
+ if (last === null || top !== last) {
289
+ rows += 1;
290
+ last = top;
291
+ if (rows === maxRows) return top;
292
+ }
293
+ }
294
+ return last ?? 0;
295
+ }
281
296
  function autoExpandDecision(activeTop, clipTop, autoRefMatched, expanded) {
282
297
  const beyond = typeof activeTop === "number" && Number.isFinite(activeTop) && typeof clipTop === "number" && Number.isFinite(clipTop) && activeTop >= clipTop;
283
298
  if (!beyond || autoRefMatched) return { record: false, expand: false };
@@ -1558,7 +1573,7 @@ var h = React.createElement;
1558
1573
  var { useState, useEffect, useLayoutEffect, useCallback, useMemo, useRef } = React;
1559
1574
  var PLUGIN_ID = "dsh-m";
1560
1575
  var API = "/dshm";
1561
- var { DEFAULT_PAGE_SIZE: DEFAULT_PAGE_SIZE2, MARKET_PAGE_SIZES: MARKET_PAGE_SIZES2, pageItems: pageItems2, createZoneState: createZoneState2, normalizeMarketQuery: normalizeMarketQuery2, resetPageOnFilterChange: resetPageOnFilterChange2, normalizeMarketResponse: normalizeMarketResponse2, registryNotice: registryNotice2, zoneChips: zoneChips2, marketNotice: marketNotice2, searchSourceOf: searchSourceOf2, mergeLatestFields: mergeLatestFields2, chipRows: chipRows2, countBeyondRows: countBeyondRows2, autoExpandDecision: autoExpandDecision2 } = (init_market_state(), __toCommonJS(market_state_exports));
1576
+ var { DEFAULT_PAGE_SIZE: DEFAULT_PAGE_SIZE2, MARKET_PAGE_SIZES: MARKET_PAGE_SIZES2, pageItems: pageItems2, createZoneState: createZoneState2, normalizeMarketQuery: normalizeMarketQuery2, resetPageOnFilterChange: resetPageOnFilterChange2, normalizeMarketResponse: normalizeMarketResponse2, registryNotice: registryNotice2, zoneChips: zoneChips2, marketNotice: marketNotice2, searchSourceOf: searchSourceOf2, mergeLatestFields: mergeLatestFields2, countBeyondRows: countBeyondRows2, clipTopOf: clipTopOf2, visibleRowTop: visibleRowTop2, autoExpandDecision: autoExpandDecision2 } = (init_market_state(), __toCommonJS(market_state_exports));
1562
1577
  var { readMarketSnapshot: readMarketSnapshot2, writeMarketSnapshot: writeMarketSnapshot2, isDefaultFirstPageQuery: isDefaultFirstPageQuery2 } = (init_market_snapshot(), __toCommonJS(market_snapshot_exports));
1563
1578
  var { backdropCloseHandlers: backdropCloseHandlers2 } = (init_backdrop(), __toCommonJS(backdrop_exports));
1564
1579
  var { createMarkdown: createMarkdown2 } = (init_markdown(), __toCommonJS(markdown_exports));
@@ -2189,7 +2204,11 @@ var CSS = `
2189
2204
  .dshm-chips{display:flex;flex-wrap:wrap;gap:6px;position:relative}
2190
2205
  .dshm-chips-clip{overflow:hidden}
2191
2206
  .dshm-chips-gutter{padding-right:var(--dshm-clip-gutter,96px)}
2192
- .dsvm-chipmore{position:absolute;right:8px;display:flex;align-items:center;gap:8px;min-height:28px;background-color:var(--dsw-alias-bg-base,#fff);background-image:linear-gradient(var(--dsw-alias-bg-base,#fff),var(--dsw-alias-bg-base,#fff)),linear-gradient(var(--dsw-alias-bg-base,#fff),var(--dsw-alias-bg-base,#fff));border:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.18));border-radius:999px;padding:2px 8px;box-sizing:border-box}
2207
+ /* +N/\u7B5B\u9009\u5206\u522B\u5360\u53F3\u4FA7 52/96px\uFF0C\u4E0D\u80FD\u8BA9 gutter \u540C\u7279\u5F02\u6027\u89C4\u5219\u8986\u76D6\u603B\u9884\u7559\u5BBD\u5EA6\u3002 */
2208
+ .dshm-chips.dshm-chips-clip.dshm-chips-reserve{padding-right:52px}
2209
+ .dshm-chips.dshm-chips-clip.dshm-chips-gutter.dshm-chips-reserve{padding-right:calc(var(--dshm-clip-gutter,96px) + 52px)}
2210
+ .dsvm-chipmore{position:absolute;right:8px}
2211
+ .dsvm-chipmore-plus{position:absolute;right:calc(var(--dshm-clip-gutter,96px) + 6px);z-index:1;background-color:var(--dsw-alias-bg-base,#fff);background-image:linear-gradient(var(--dsw-alias-bg-base,#fff),var(--dsw-alias-bg-base,#fff)),linear-gradient(var(--dsw-alias-bg-base,#fff),var(--dsw-alias-bg-base,#fff))}
2193
2212
  .dsvm-searchrow{display:flex;align-items:center;gap:8px}
2194
2213
  .dsvm-searchrow .dshm-search{flex:1;display:flex}
2195
2214
  .dshm-search{position:relative}
@@ -2710,6 +2729,7 @@ function SearchBox({ placeholder, initial, onCommit }) {
2710
2729
  }
2711
2730
  function ZoneChips({ zone, counts, labels, active, onPick, trailing, wrapTitle }) {
2712
2731
  const chips = useMemo(() => zoneChips2(counts, labels, zone), [counts, labels, zone]);
2732
+ const chipsSignature = JSON.stringify(chips.map((c) => [c.id, c.labelKey ? lookup(c.labelKey) : c.label, c.count]));
2713
2733
  const [expanded, setExpanded] = useState(false);
2714
2734
  const [stuck, setStuck] = useState(false);
2715
2735
  const [geom, setGeom] = useState(null);
@@ -2719,38 +2739,24 @@ function ZoneChips({ zone, counts, labels, active, onPick, trailing, wrapTitle }
2719
2739
  const autoRef = useRef(null);
2720
2740
  const maxRows = stuck ? 1 : 2;
2721
2741
  const activeIdx = active ? chips.findIndex((c) => c.id === active) : -1;
2722
- const plusWrapped = !!(geom && geom.plusWrapped);
2723
- const maxRowsEff = maxRows + (plusWrapped ? 1 : 0);
2724
- const maxH = maxRowsEff * (rowHeight || 22) + (maxRowsEff - 1) * 6;
2742
+ const maxH = maxRows * (rowHeight || 22) + (maxRows - 1) * 6;
2725
2743
  const measure = useCallback(() => {
2726
2744
  const el = wrapRef.current;
2727
2745
  if (!el || expanded) return;
2728
2746
  const tops = [];
2729
2747
  let rh = 0;
2730
- let plusTopMeas = null;
2731
- let hiddenMeas = 0;
2732
2748
  for (const k of el.children) {
2733
- if (!(k instanceof HTMLElement)) continue;
2734
- if (k.getAttribute("data-more") === "1") {
2735
- plusTopMeas = k.offsetTop;
2736
- continue;
2737
- }
2738
- if (k.getAttribute("data-chip") !== "1") continue;
2739
- if (getComputedStyle(k).display === "none") {
2740
- hiddenMeas += 1;
2741
- continue;
2742
- }
2749
+ if (!(k instanceof HTMLElement) || k.getAttribute("data-chip") !== "1") continue;
2743
2750
  tops.push(k.offsetTop);
2744
2751
  if (!rh && k.offsetHeight) rh = k.offsetHeight;
2745
2752
  }
2746
2753
  if (!tops.length) return;
2747
- const lastRowTop = tops[tops.length - 1];
2748
- const plusWrappedNow = plusTopMeas != null && plusTopMeas > lastRowTop;
2749
2754
  setGeom((prev) => {
2750
- const prevHC = prev ? prev.hiddenCount : countBeyondRows2(tops.slice(1), maxRows);
2751
- const hiddenCount2 = plusWrappedNow ? prevHC + 1 : prevHC;
2752
- const next = { tops, hiddenCount: hiddenCount2 };
2753
- const same = prev && prev.hiddenCount === next.hiddenCount && prev.tops.length === next.tops.length && prev.tops.every((t, i) => t === next.tops[i]);
2755
+ const clipTopV = clipTopOf2(tops, maxRows);
2756
+ const hiddenCount2 = countBeyondRows2(tops, maxRows);
2757
+ const lastVisTop2 = visibleRowTop2(tops, maxRows);
2758
+ const next = { tops, clipTop: clipTopV, hiddenCount: hiddenCount2, lastVisTop: lastVisTop2 };
2759
+ const same = prev && prev.hiddenCount === next.hiddenCount && prev.clipTop === next.clipTop && prev.lastVisTop === next.lastVisTop && prev.tops.length === next.tops.length && prev.tops.every((t, i) => t === next.tops[i]);
2754
2760
  return same ? prev : next;
2755
2761
  });
2756
2762
  setRowHeight((prev) => Math.abs(prev - rh) <= 0.5 ? prev : rh);
@@ -2763,14 +2769,19 @@ function ZoneChips({ zone, counts, labels, active, onPick, trailing, wrapTitle }
2763
2769
  }, [active]);
2764
2770
  useEffect(() => {
2765
2771
  if (!active || !geom) return;
2766
- const visCats = geom.tops.length - 1;
2767
- const d = autoExpandDecision2(activeIdx, visCats, autoRef.current === active, expanded);
2772
+ const activeTop = geom.tops[activeIdx + 1];
2773
+ const d = autoExpandDecision2(activeTop, geom.clipTop, autoRef.current === active, expanded);
2768
2774
  if (d.record) autoRef.current = active;
2769
2775
  if (d.expand) setExpanded(true);
2770
2776
  }, [active, activeIdx, expanded, geom]);
2771
2777
  useLayoutEffect(() => {
2772
2778
  if (!expanded) measure();
2773
- }, [chips, active, expanded, zone, stuck, rowHeight, measure, geom]);
2779
+ }, [chipsSignature, active, expanded, zone, stuck, rowHeight, measure]);
2780
+ useEffect(() => {
2781
+ if (expanded || !geom || typeof requestAnimationFrame !== "function") return;
2782
+ const raf = requestAnimationFrame(measure);
2783
+ return () => cancelAnimationFrame(raf);
2784
+ }, [geom, expanded, measure]);
2774
2785
  useEffect(() => {
2775
2786
  const el = wrapRef.current;
2776
2787
  if (!el || expanded || typeof ResizeObserver === "undefined") return;
@@ -2804,20 +2815,25 @@ function ZoneChips({ zone, counts, labels, active, onPick, trailing, wrapTitle }
2804
2815
  }, []);
2805
2816
  const clip = !expanded;
2806
2817
  const filterPinned = clip && trailing != null;
2818
+ const clipTop = geom ? geom.clipTop : Infinity;
2807
2819
  const hiddenCount = geom ? geom.hiddenCount : 0;
2808
- const visCount = geom ? Math.max(0, chips.length - hiddenCount) : chips.length;
2809
- const btn = (c, i, hide) => h(
2810
- "button",
2811
- {
2812
- key: c.id,
2813
- "data-chip": "1",
2814
- style: hide ? { display: "none" } : void 0,
2815
- className: `dshm-chip${active === c.id ? " on" : ""}${c.count === 0 ? " zero" : ""}`,
2816
- onClick: () => onPick(active === c.id ? null : c.id)
2817
- },
2818
- // 0.9.45 U3/U7:0 计数桶显式渲染「0」+ 降透明(社区区 chip 计数恒 >0,行为不变)
2819
- `${c.labelKey ? lookup(c.labelKey) : c.label} ${c.count || 0}`
2820
- );
2820
+ const lastVisTop = geom ? geom.lastVisTop : 0;
2821
+ const btn = (c, i) => {
2822
+ const top = geom ? geom.tops[i + 1] : null;
2823
+ const clipped = clip && geom && typeof top === "number" && top >= clipTop;
2824
+ return h(
2825
+ "button",
2826
+ {
2827
+ key: c.id,
2828
+ "data-chip": "1",
2829
+ style: clipped ? { visibility: "hidden" } : void 0,
2830
+ className: `dshm-chip${active === c.id ? " on" : ""}${c.count === 0 ? " zero" : ""}`,
2831
+ onClick: () => onPick(active === c.id ? null : c.id)
2832
+ },
2833
+ // 0.9.45 U3/U7:0 计数桶显式渲染「0」+ 降透明(社区区 chip 计数恒 >0,行为不变)
2834
+ `${c.labelKey ? lookup(c.labelKey) : c.label} ${c.count || 0}`
2835
+ );
2836
+ };
2821
2837
  return h(
2822
2838
  React.Fragment,
2823
2839
  null,
@@ -2834,15 +2850,22 @@ function ZoneChips({ zone, counts, labels, active, onPick, trailing, wrapTitle }
2834
2850
  "div",
2835
2851
  {
2836
2852
  ref: wrapRef,
2837
- className: `dshm-chips${clip ? " dshm-chips-clip" : ""}${filterPinned ? " dshm-chips-gutter" : ""}`,
2853
+ className: `dshm-chips${clip ? " dshm-chips-clip" : ""}${filterPinned ? " dshm-chips-gutter" : ""}${clip && hiddenCount > 0 ? " dshm-chips-reserve" : ""}`,
2838
2854
  title: wrapTitle || void 0,
2839
2855
  style: { maxHeight: clip ? `${maxH}px` : "none" }
2840
2856
  },
2841
2857
  h("button", { "data-chip": "1", className: `dshm-chip${active == null ? " on" : ""}`, onClick: () => onPick(null) }, lookup("cat.all")),
2842
- ...chips.slice(0, visCount).map((c, i) => btn(c, i, false)),
2843
- clip && chips.length > 0 && hiddenCount > 0 ? h("button", { key: "more", "data-more": "1", className: "dshm-chip", onClick: () => setExpanded(true) }, `+${hiddenCount}`) : null,
2844
- ...chips.slice(visCount).map((c, i) => btn(c, visCount + i, clip)),
2845
- // hide 仅折叠态生效;展开态全量可见
2858
+ ...chips.map((c, i) => btn(c, i)),
2859
+ // 折叠态 +N(0.9.57 终版):绝对定位钉在「末可见行右端预留槽」——出流不挤压 chip、不参与
2860
+ // 行分组(data-more);预留槽由 .dshm-chips-clip 的 padding-right 划出,几何保证零重叠;
2861
+ // 位置右对齐紧贴筛选 gutter 左侧,垂直对齐末可见行(top = lastVisTop,测量派生)。
2862
+ clip && geom && hiddenCount > 0 ? h("button", {
2863
+ key: "more",
2864
+ "data-more": "1",
2865
+ className: "dshm-chip dsvm-chipmore-plus",
2866
+ style: { top: `${lastVisTop}px` },
2867
+ onClick: () => setExpanded(true)
2868
+ }, `+${hiddenCount}`) : null,
2846
2869
  expanded ? [
2847
2870
  h("button", {
2848
2871
  key: "collapse",
@@ -4497,7 +4520,11 @@ function MarketPanel({ onClose }) {
4497
4520
  function mountPanel() {
4498
4521
  if (typeof document === "undefined") return;
4499
4522
  ensureCss();
4500
- if (document.getElementById("dshm-panel-root")) return;
4523
+ const existing = document.getElementById("dshm-panel-root");
4524
+ if (existing) {
4525
+ if (existing.querySelector(".dshm-panel")) return;
4526
+ existing.remove();
4527
+ }
4501
4528
  const container = document.createElement("div");
4502
4529
  container.id = "dshm-panel-root";
4503
4530
  document.body.appendChild(container);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-m",
3
- "version": "0.9.56",
3
+ "version": "0.9.57",
4
4
  "description": "可自定义收录清单的 DSH 插件市场:收录、安装、卸载、升级一站完成,附 agent 工具与 dshm CLI。",
5
5
  "license": "MIT",
6
6
  "type": "module",