@hagicode/hagilight-mermaid 0.16.0 → 0.16.1-dev.166.1.019796a

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/dist/chip.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import type { MermaidLabels, MermaidTraceSummary } from './types.js';
2
+ /** Identifies what a chip shows, so an unchanged summary can keep the chip it already has. */
3
+ export declare function traceChipKey(summary: MermaidTraceSummary | null, labels: MermaidLabels): string;
2
4
  /**
3
5
  * Fills a live region with the trace or focus summary: the name, then either the upstream and
4
6
  * downstream counts of a traced node or the place of a focused chart part. A pinned summary carries a
package/dist/chip.js CHANGED
@@ -1,11 +1,22 @@
1
1
  import { el, icon } from './dom.js';
2
2
  import { formatLabel } from './labels.js';
3
+ const renderedKeys = new WeakMap();
4
+ /** Identifies what a chip shows, so an unchanged summary can keep the chip it already has. */
5
+ export function traceChipKey(summary, labels) {
6
+ return JSON.stringify([summary, labels.trace]);
7
+ }
3
8
  /**
4
9
  * Fills a live region with the trace or focus summary: the name, then either the upstream and
5
10
  * downstream counts of a traced node or the place of a focused chart part. A pinned summary carries a
6
11
  * clear button.
7
12
  */
8
13
  export function renderTraceChip(status, summary, labels, onClear) {
14
+ // Focus leaving a pinned node re-reports the same summary. Rebuilding the chip then detaches the
15
+ // clear button under a mouse press, and the click never reaches it, so an unchanged chip stays.
16
+ const key = traceChipKey(summary, labels);
17
+ if (renderedKeys.get(status) === key)
18
+ return;
19
+ renderedKeys.set(status, key);
9
20
  status.replaceChildren();
10
21
  if (!summary)
11
22
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hagicode/hagilight-mermaid",
3
- "version": "0.16.0",
3
+ "version": "0.16.1-dev.166.1.019796a",
4
4
  "type": "module",
5
5
  "description": "Framework-agnostic Mermaid rendering with the HagiCode look: themes, presets, entrance reveal and path tracing for Astro, Starlight and Docusaurus sites",
6
6
  "repository": {