dsh-md-plus 0.4.2 → 0.4.3

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,6 +1,16 @@
1
1
  # 更新日志
2
2
 
3
- ## 0.4.2 —— 未发布
3
+ ## 0.4.3 —— 未发布
4
+
5
+ - 修复补高亮语言映射:`hbs` / `jade` / `tscn` / `tres` 分别使用 handlebars / pug / gdresource 语法着色。
6
+ - 修复 Mermaid 12.1 在占位标签兜底路径下的图种识别:补充 `radar-beta`、`treemap-beta`、`venn-beta`、`ishikawa-beta`、`wardley-beta`、`cynefin-beta`、`treeView-beta`、`flowchart-elk` 等,并去掉无效裸关键字的误判。
7
+ - 修复插件卸载后 debounce 扫描重新插入按钮、设置入口和折叠控件的问题,同时清理 `data-md-plus-zoom` 属性。
8
+ - 修复 localStorage 不可用时设置保存和配色切换连当前会话都不生效的问题。
9
+ - 修复运行时路由 ETag 只依赖文件大小和 mtime、内容更新后仍可能返回 304 的问题。
10
+ - 同步能力展示页和 README 预览图到当前 DSH 样式,并把所有版本引用更新为 0.4.3。
11
+ - 测试补到 78 条,新增别名语言、Mermaid 新图种、卸载清理、localStorage 降级和 ETag 回归用例。
12
+
13
+ ## 0.4.2 —— 2026-10-30
4
14
 
5
15
  - 修复鼠标悬浮表格或折叠内容时吞掉页面滚轮:移除表格容器的 `overscroll-behavior` containment,折叠态改为保留横向滚动、纵向 `overflow-y: clip`,并覆盖 DSH 宿主 `.tableScroll` 自带的横向 containment。
6
16
  - 修复宽表横向滚动条出现 / 消失时鼠标移入移出表格造成的上下跳动:取消 hover 阶段的 padding 切换,固定底部留白。
package/README.md CHANGED
@@ -27,11 +27,13 @@ dsh plugin --profile desktop remove dsh-md-plus
27
27
  ```powershell
28
28
  npm install # 顺带跑 prepare → build
29
29
  npm run build # 产出 lib/ 下四个文件
30
- npm run check # 语法检查 + 73 条测试(先 build 再跑,check 不含 build)
30
+ npm run check # 语法检查 + 78 条测试(先 build 再跑,check 不含 build)
31
31
  npm run preview # 生成 preview.html(含真渲出来的 mermaid 图)
32
32
  npm run shot # 用 headless Chrome 把 preview.html 截成 docs/preview.png
33
33
  ```
34
34
 
35
+ `npm run preview` / `scripts/showcase.mjs` 需要读取 DSH 安装目录里的主题和前端资源;如果本机 DSH 是 `app.asar` 包,请先解包到目录,并把 `DSH_APP_DIR` 指向该目录。
36
+
35
37
  ## 已知限制
36
38
 
37
39
  - DSH 0.2.1-rc.4 的头部语言名由宿主决定:不认识的围栏只显示占位文案「代码块」。插件会从宿主的 React fiber 里兜底读取真实语言,读不到时才退回正文嗅探;宿主改 React 结构后这条兜底可能失效。
package/lib/client.js CHANGED
@@ -178,6 +178,8 @@ window.__ModuleLoader__.load({
178
178
  var STYLE_ATTR = "data-md-plus-style";
179
179
  var RUNTIME_ATTR = "data-md-plus-runtime";
180
180
  var DEBOUNCE_MS = 160;
181
+ var memorySettings = null;
182
+ var memoryTheme = null;
181
183
  function readSettings() {
182
184
  var settings = { ...DEFAULT_SETTINGS };
183
185
  try {
@@ -194,11 +196,14 @@ window.__ModuleLoader__.load({
194
196
  if (Number.isFinite(value) && value >= 0) settings[key] = Math.min(4e3, Math.round(value));
195
197
  }
196
198
  }
199
+ memorySettings = { ...settings };
197
200
  } catch {
201
+ if (memorySettings !== null) return { ...DEFAULT_SETTINGS, ...memorySettings };
198
202
  }
199
203
  return settings;
200
204
  }
201
205
  function saveSettings(next) {
206
+ memorySettings = { ...next };
202
207
  try {
203
208
  window.localStorage.setItem(SETTINGS_KEY, JSON.stringify(next));
204
209
  } catch {
@@ -331,10 +336,10 @@ window.__ModuleLoader__.load({
331
336
  "gradle"
332
337
  ]);
333
338
  var MMD_LANGS = /* @__PURE__ */ new Set(["mermaid", "mermaidjs", "mmd"]);
334
- var MMD_FLOW = /^\s*(flowchart|graph)(?:\s+(?:TD|TB|BT|RL|LR))?\s*;?\s*$/i;
335
- var MMD_PIE = /^\s*pie(?:\s+title\b.*)?\s*;?\s*$/i;
339
+ var MMD_FLOW = /^\s*(flowchart(?:-elk)?|graph)(?:\s+(?:TD|TB|BT|RL|LR))?\s*;?\s*$/i;
340
+ var MMD_PIE = /^\s*pie(?:\s+(?:showData|title)\b.*)?\s*;?\s*$/i;
336
341
  var MMD_GIT = /^\s*gitGraph(?:\s+(?:LR|TB|BT|RL))?:?\s*;?\s*$/i;
337
- var MMD_SINGLE = /^\s*(sequenceDiagram|classDiagram|stateDiagram(?:-v2)?|erDiagram|journey|gantt|mindmap|timeline|quadrantChart|xychart-beta|sankey-beta|block-beta|packet-beta|architecture-beta|usecase-beta|agentflow-beta|C4Context|requirementDiagram|kanban|radar|treemap|venn|ishikawa|wardley|cynefin|treeView|zenuml)\s*;?\s*$/i;
342
+ var MMD_SINGLE = /^\s*(sequenceDiagram|classDiagram|stateDiagram(?:-v2)?|erDiagram|journey|gantt|mindmap|timeline|quadrantChart|xychart-beta|sankey-beta|block-beta|packet-beta|architecture-beta|usecase-beta|agentflow-beta|C4Context|requirementDiagram|kanban|radar-beta|treemap(?:-beta)?|venn-beta|ishikawa(?:-beta)?|wardley-beta|cynefin-beta|treeView-beta|info|eventmodeling|swimlane-beta|railroad-beta|railroad-abnf-beta|railroad-ebnf-beta|railroad-peg-beta)\s*;?\s*$/i;
338
343
  function icon(paths) {
339
344
  var svg = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'>" + paths + "</svg>";
340
345
  return 'url("data:image/svg+xml,' + encodeURIComponent(svg) + '")';
@@ -533,6 +538,7 @@ window.__ModuleLoader__.load({
533
538
  var rescanQueued = false;
534
539
  var injected = /* @__PURE__ */ new Set();
535
540
  var diagramSeq = 0;
541
+ var disposed = false;
536
542
  function injectStyle() {
537
543
  if (document.querySelector("style[" + STYLE_ATTR + "]") !== null) return;
538
544
  var tag = document.createElement("style");
@@ -675,6 +681,7 @@ window.__ModuleLoader__.load({
675
681
  ) != null;
676
682
  }
677
683
  function schedule(block) {
684
+ if (disposed) return;
678
685
  if (block !== void 0) pending.add(block);
679
686
  else rescanQueued = true;
680
687
  if (timer !== null) return;
@@ -682,6 +689,7 @@ window.__ModuleLoader__.load({
682
689
  }
683
690
  function flush() {
684
691
  timer = null;
692
+ if (disposed) return;
685
693
  if (rescanQueued) {
686
694
  rescanQueued = false;
687
695
  for (const block of document.querySelectorAll(BLOCK)) pending.add(block);
@@ -843,7 +851,7 @@ window.__ModuleLoader__.load({
843
851
  if (lang === "") return;
844
852
  if (DSH_LANGS.has(lang)) return;
845
853
  var api = await loadScript(HL_URL, HL_GLOBAL);
846
- if (api === null || !api.supports(lang)) return;
854
+ if (disposed || api === null || !api.supports(lang)) return;
847
855
  if (!pre.isConnected) return;
848
856
  var code = pre.textContent ?? "";
849
857
  if (code.trim() === "") return;
@@ -855,6 +863,7 @@ window.__ModuleLoader__.load({
855
863
  } catch {
856
864
  return;
857
865
  }
866
+ if (disposed) return;
858
867
  if (typeof html !== "string" || html === "") return;
859
868
  if (!pre.isConnected || (pre.textContent ?? "") !== code) {
860
869
  schedule(block);
@@ -879,8 +888,13 @@ window.__ModuleLoader__.load({
879
888
  function getMermaidTheme() {
880
889
  try {
881
890
  var saved = window.localStorage.getItem(THEME_KEY);
882
- if (saved !== null && THEME_ORDER.indexOf(saved) !== -1) return saved;
891
+ if (saved !== null && THEME_ORDER.indexOf(saved) !== -1) {
892
+ memoryTheme = saved;
893
+ return saved;
894
+ }
895
+ memoryTheme = null;
883
896
  } catch {
897
+ if (memoryTheme !== null) return memoryTheme;
884
898
  }
885
899
  return "blue";
886
900
  }
@@ -898,6 +912,7 @@ window.__ModuleLoader__.load({
898
912
  var current = getMermaidTheme();
899
913
  var index = THEME_ORDER.indexOf(current);
900
914
  var next = THEME_ORDER[(index + 1) % THEME_ORDER.length];
915
+ memoryTheme = next;
901
916
  try {
902
917
  window.localStorage.setItem(THEME_KEY, next);
903
918
  } catch {
@@ -911,16 +926,18 @@ window.__ModuleLoader__.load({
911
926
  var key = "mmd\0" + code;
912
927
  if (block.getAttribute(KEY_ATTR) === key) return;
913
928
  var api = await loadScript(MMD_URL, MMD_GLOBAL);
914
- if (api === null) return;
929
+ if (disposed || api === null) return;
915
930
  if (!pre.isConnected) return;
916
931
  var svg;
917
932
  try {
918
933
  var dark = document.body.hasAttribute("data-ds-dark-theme");
919
934
  svg = await api.render("dsh-md-plus-mmd-" + ++diagramSeq, code, dark, getMermaidTheme());
920
935
  } catch (error) {
936
+ if (disposed) return;
921
937
  failDiagram(block, content, pre, key, error);
922
938
  return;
923
939
  }
940
+ if (disposed) return;
924
941
  if (typeof svg !== "string" || svg === "") return;
925
942
  if (svg.includes('aria-roledescription="error"')) {
926
943
  failDiagram(block, content, pre, key, new Error("mermaid \u8FD4\u56DE\u7684\u662F\u9519\u8BEF\u5361\u7247"));
@@ -1394,6 +1411,7 @@ window.__ModuleLoader__.load({
1394
1411
  foldTable: readNumber(foldTable, DEFAULT_SETTINGS.foldTable),
1395
1412
  foldDiagram: readNumber(foldDiagram, DEFAULT_SETTINGS.foldDiagram)
1396
1413
  });
1414
+ memoryTheme = themeSelect.value;
1397
1415
  try {
1398
1416
  window.localStorage.setItem(THEME_KEY, themeSelect.value);
1399
1417
  } catch {
@@ -1626,6 +1644,7 @@ window.__ModuleLoader__.load({
1626
1644
  function apply0(ctx) {
1627
1645
  if (typeof document === "undefined") return;
1628
1646
  ctx.effect(() => {
1647
+ disposed = false;
1629
1648
  injectStyle();
1630
1649
  applyCodeFontSize();
1631
1650
  ensureSettingsButton();
@@ -1641,6 +1660,13 @@ window.__ModuleLoader__.load({
1641
1660
  });
1642
1661
  schedule();
1643
1662
  return () => {
1663
+ disposed = true;
1664
+ if (timer !== null) {
1665
+ window.clearTimeout(timer);
1666
+ timer = null;
1667
+ }
1668
+ pending.clear();
1669
+ rescanQueued = false;
1644
1670
  observer.disconnect();
1645
1671
  document.removeEventListener("click", onDocumentClick, true);
1646
1672
  for (const node of injected) node.remove();
@@ -1650,7 +1676,7 @@ window.__ModuleLoader__.load({
1650
1676
  for (const node of document.querySelectorAll("." + FOLD_BTN_CLASS)) node.remove();
1651
1677
  for (const node of document.querySelectorAll("[" + FOLD_ATTR + "]")) resetFold(node);
1652
1678
  for (const node of document.querySelectorAll("." + TABLE_TOOLS_CLASS)) node.remove();
1653
- for (const attr of [DONE_ATTR, KEY_ATTR, WRAP_ATTR, MMD_ATTR, TABLE_DONE_ATTR, "data-md-plus-lang"]) {
1679
+ for (const attr of [DONE_ATTR, KEY_ATTR, WRAP_ATTR, MMD_ATTR, TABLE_DONE_ATTR, "data-md-plus-lang", ZOOM_ATTR]) {
1654
1680
  for (const node of document.querySelectorAll("[" + attr + "]")) node.removeAttribute(attr);
1655
1681
  }
1656
1682
  for (const node of document.querySelectorAll("[data-md-plus-original-label]")) {