@celestia-island/hikari 0.55.496 → 0.55.497

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.
@@ -47,6 +47,10 @@ export interface BoardNodeInput {
47
47
  kind?: string;
48
48
  /** Invisible junction node — routes edges, paints nothing. */
49
49
  hidden?: boolean;
50
+ /** Paint-only node: the shell renders but pointer gestures pass straight
51
+ * through to the board. Subgraph cluster frames need this — a frame covers
52
+ * its members' surroundings, and it must not swallow the pan drag. */
53
+ passthrough?: boolean;
50
54
  /** Opt in to pointer dragging (world-coord moves + `node-move` events). */
51
55
  draggable?: boolean;
52
56
  /** Page payload, handed back through the scoped slot. */
@@ -14,7 +14,7 @@
14
14
  * axis) so a doc can never collide two parts.
15
15
  */
16
16
  import type { MermaidDoc, MermaidGraphDoc } from "./types";
17
- export type MermaidNodeKind = "shape" | "participant" | "class" | "section" | "task" | "axis" | "pie" | "quadrant";
17
+ export type MermaidNodeKind = "shape" | "group" | "participant" | "class" | "section" | "task" | "axis" | "pie" | "quadrant";
18
18
  export interface LaidOutNode {
19
19
  id: string;
20
20
  x: number;
@@ -24,6 +24,9 @@ export interface LaidOutNode {
24
24
  kind: MermaidNodeKind;
25
25
  /** Invisible junction — routes edges, paints nothing, no minimap box. */
26
26
  hidden?: boolean;
27
+ /** Paint-only node: pointer gestures pass through to the board (cluster
28
+ * frames must not eat the pan drag). */
29
+ passthrough?: boolean;
27
30
  data: Record<string, unknown>;
28
31
  }
29
32
  export interface LaidOutEdge {
@@ -32,6 +35,11 @@ export interface LaidOutEdge {
32
35
  to: string;
33
36
  /** Board route style; bezier = mermaid flowchart feel. */
34
37
  style: "straight" | "bezier" | "orthogonal";
38
+ /** Border anchor overrides. An edge into a subgraph cluster lands on the
39
+ * frame's border (mermaid attaches there), not on its center — the center
40
+ * sits behind the frame's own members. */
41
+ anchorFrom?: "center" | "nearest" | "top" | "top-left" | "fan";
42
+ anchorTo?: "center" | "nearest" | "top" | "top-left" | "fan";
35
43
  dashed: boolean;
36
44
  arrow: "none" | "solid" | "open";
37
45
  label: string | null;
@@ -71,6 +79,12 @@ export interface GraphLayoutInput {
71
79
  to: string;
72
80
  }>;
73
81
  direction: MermaidGraphDoc["direction"];
82
+ /** Cross-axis gap between same-rank siblings, world px. Cluster frames pad
83
+ * their members on both sides (and reserve a caption band on the stacked
84
+ * axis), so a grouped graph widens this budget — `GROUP_CROSS_GAP_H` for
85
+ * TD/BT, `GROUP_CROSS_GAP_V` for LR/RL — or neighbouring frames would
86
+ * touch and overlap. */
87
+ crossGap?: number;
74
88
  }
75
89
  export interface GraphLayoutOutput {
76
90
  positions: Map<string, {
@@ -5,8 +5,13 @@
5
5
  * This is a faithful TS mirror of `ratatui-markdown`'s `mermaid/types.rs`
6
6
  * (the family's pest-driven Rust parser, v0.3.6). The Rust side stays the
7
7
  * semantic reference: when a syntax question arises, ratatui-markdown's
8
- * grammar wins, and the golden fixtures in `__tests__/hkMermaidParse.test.ts`
9
- * exist to keep the two implementations honest.
8
+ * grammar wins, and the golden fixtures in `__golden.test.ts` exist to keep
9
+ * the two implementations honest.
10
+ *
11
+ * Two fields are hikari-line EXTENSIONS over that vendor shape (see
12
+ * `packages/wasm/mermaid/src/mermaid/mod.rs`): `MermaidGroup`/`groups` for
13
+ * `subgraph … end` clusters, and the quote-stripped labels the shipped
14
+ * renderers paint.
10
15
  *
11
16
  * Framework-free on purpose: no Vue imports, safe in pure computation
12
17
  * modules (same rule as components/nodeCanvasTypes.ts).
@@ -28,6 +33,23 @@ export interface MermaidEdge {
28
33
  label: string | null;
29
34
  edgeType: MermaidEdgeType;
30
35
  }
36
+ /**
37
+ * A `subgraph` cluster — the frame drawn around its members. The Rust
38
+ * component omits the field entirely for a plain graph, so pre-cluster
39
+ * documents keep their exact JSON.
40
+ */
41
+ export interface MermaidGroup {
42
+ /** Subgraph id — the head's identifier, or a generated `_sg<N>`. Edges may
43
+ * point at it exactly like a node id. */
44
+ id: string;
45
+ /** Caption painted on the frame. */
46
+ label: string;
47
+ /** Node ids inside the cluster, parse order. A nested cluster's nodes also
48
+ * appear here, so the outer frame encloses the inner one. */
49
+ members: string[];
50
+ /** Enclosing cluster id for a nested subgraph. */
51
+ parent?: string | null;
52
+ }
31
53
  export interface MermaidGraphDoc {
32
54
  kind: "graph";
33
55
  /** `state` diagrams parse into the same shape; the flag only tunes
@@ -36,6 +58,9 @@ export interface MermaidGraphDoc {
36
58
  direction: MermaidDirection;
37
59
  nodes: MermaidNode[];
38
60
  edges: MermaidEdge[];
61
+ /** `subgraph` clusters, outer-first in parse order (absent for a plain
62
+ * graph — the Rust serializer omits an empty list). */
63
+ groups?: MermaidGroup[];
39
64
  }
40
65
  export type SeqArrowKind = "solid" | "dotted" | "solid-open" | "dotted-open";
41
66
  export interface SequenceMessage {
@@ -94,6 +94,15 @@ export declare function boardClampPan(cam: BoardCamera, content: BoardRect, view
94
94
  * boards shrink as far as needed to show everything — fit is allowed
95
95
  * below the interaction minimum (the ladder is for gestures, not for
96
96
  * the initial framing); tiny boards never blow up past the cap.
97
+ *
98
+ * The usable span is floored at zero, so k is never NEGATIVE. A viewport
99
+ * narrower than the padding is degenerate (a board mounted inside a
100
+ * hidden tab / collapsed panel / an unlaid-out flex item measures 0), and
101
+ * an unfloored `(0 - 80) / 1538 = -0.052` makes the whole world render
102
+ * mirrored and shrunken instead of merely unplaced — measured on the docs
103
+ * site, where the mermaid card's canvas collapsed and every diagram
104
+ * vanished. Zero is the honest answer for "no room"; the host re-fits
105
+ * once a real viewport exists (HkBoard's ResizeObserver path).
97
106
  */
98
107
  export declare function boardFit(content: BoardRect, viewport: BoardViewport, opts?: {
99
108
  pad?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.496",
3
+ "version": "0.55.497",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
@@ -138,3 +138,10 @@
138
138
  .hk-board-minimap > .hk-minimap {
139
139
  position: static;
140
140
  }
141
+
142
+ /* Paint-only nodes (subgraph cluster frames, decoration layers): visible, but
143
+ never the target of a pointer — a pan drag or a node tap must reach what is
144
+ underneath. */
145
+ .hk-board-node--passthrough {
146
+ pointer-events: none;
147
+ }
@@ -43,6 +43,7 @@ import {
43
43
  import { useBoardCamera } from "../composables/useBoardCamera";
44
44
  import HkMinimap, { type MinimapBox } from "./HkMinimap";
45
45
  import {
46
+ BOARD_FIT_PAD,
46
47
  boardBBox,
47
48
  boardStepRung,
48
49
  quantizeBoardK,
@@ -78,12 +79,20 @@ export interface BoardNodeInput {
78
79
  kind?: string;
79
80
  /** Invisible junction node — routes edges, paints nothing. */
80
81
  hidden?: boolean;
82
+ /** Paint-only node: the shell renders but pointer gestures pass straight
83
+ * through to the board. Subgraph cluster frames need this — a frame covers
84
+ * its members' surroundings, and it must not swallow the pan drag. */
85
+ passthrough?: boolean;
81
86
  /** Opt in to pointer dragging (world-coord moves + `node-move` events). */
82
87
  draggable?: boolean;
83
88
  /** Page payload, handed back through the scoped slot. */
84
89
  data?: Record<string, unknown>;
85
90
  }
86
91
 
92
+ /** Below twice the fit padding, `boardFit` has no room left after its own
93
+ * padding: the board is unplaced (k = 0) until its container grows past it. */
94
+ const FIT_FLOOR_PX = BOARD_FIT_PAD * 2;
95
+
87
96
  /** Per-instance sequence for document-unique marker ids (url(#id)
88
97
  * resolves document-wide — two boards must never mint the same id). */
89
98
  let boardInstanceCounter = 0;
@@ -309,10 +318,36 @@ export default defineComponent({
309
318
  cam.zoomByFactor(factor, localPoint(e));
310
319
  }
311
320
 
321
+ /** One-way latch: set by the first call the HOST makes into the camera
322
+ * through `expose` (`fit`, `reset`, `zoomIn`, `zoomOut`, `zoomToPercent`).
323
+ * Any such call — a single zoom included — means the framing is the
324
+ * host's, so the late recovery fit below must not take it back. The
325
+ * board's own chrome (the minimap reset) does not trip it: that is the
326
+ * component's UI, not a host decision. */
327
+ let hostOwnsCamera = false;
328
+
312
329
  function refreshSize(): void {
313
330
  const el = viewportRef.value;
314
331
  if (!el) return;
315
- viewportSize.value = { w: el.clientWidth, h: el.clientHeight };
332
+ const next = { w: el.clientWidth, h: el.clientHeight };
333
+ // "Unplaced" is the fit's own notion of no room: below twice the fit
334
+ // padding there is nothing left to frame into, so a fit on that box
335
+ // yields k = 0 and paints nothing. That covers a 0×0 hidden container
336
+ // AND the collapsed flex item measured on the docs hub (2px, its
337
+ // borders only) — a `w > 0` test would have missed the real case.
338
+ const unplaced = (s: BoardViewport): boolean => s.w <= FIT_FLOOR_PX || s.h <= FIT_FLOOR_PX;
339
+ const wasUnplaced = unplaced(viewportSize.value);
340
+ viewportSize.value = next;
341
+ // A board can mount before its container has a box: a hidden tab, a
342
+ // collapsed panel, a card whose own parent is still unmounted. The
343
+ // mount fit then frames against nothing and the camera stayed there
344
+ // forever — the diagram/chart only appeared after a manual reset.
345
+ // Re-fit on the FIRST size that follows an unplaced one; ordinary
346
+ // resizes keep the reader's camera, and a host that drives the camera
347
+ // itself keeps it too.
348
+ if (wasUnplaced && props.fitOnMount && !hostOwnsCamera) {
349
+ cam.fit();
350
+ }
316
351
  }
317
352
 
318
353
  let resizeObs: ResizeObserver | null = null;
@@ -470,11 +505,26 @@ export default defineComponent({
470
505
  });
471
506
 
472
507
  expose({
473
- fit: () => cam.fit(),
474
- zoomIn: () => cam.zoomIn(),
475
- zoomOut: () => cam.zoomOut(),
476
- zoomToPercent: (p: number, anchor?: BoardPoint) => cam.zoomToPercent(p, anchor),
477
- reset: () => cam.fit(),
508
+ fit: () => {
509
+ hostOwnsCamera = true;
510
+ cam.fit();
511
+ },
512
+ zoomIn: () => {
513
+ hostOwnsCamera = true;
514
+ cam.zoomIn();
515
+ },
516
+ zoomOut: () => {
517
+ hostOwnsCamera = true;
518
+ cam.zoomOut();
519
+ },
520
+ zoomToPercent: (p: number, anchor?: BoardPoint) => {
521
+ hostOwnsCamera = true;
522
+ cam.zoomToPercent(p, anchor);
523
+ },
524
+ reset: () => {
525
+ hostOwnsCamera = true;
526
+ cam.fit();
527
+ },
478
528
  camera,
479
529
  });
480
530
 
@@ -541,7 +591,10 @@ export default defineComponent({
541
591
  key={n.id}
542
592
  class={[
543
593
  "hk-board-node",
544
- { "hk-board-node--draggable": Boolean(n.draggable) },
594
+ {
595
+ "hk-board-node--draggable": Boolean(n.draggable),
596
+ "hk-board-node--passthrough": Boolean(n.passthrough),
597
+ },
545
598
  n.kind ? `hk-board-node--${n.kind}` : undefined,
546
599
  ]}
547
600
  style={{ left: `${n.x}px`, top: `${n.y}px`, width: `${n.w}px`, height: `${n.h}px` }}
@@ -0,0 +1,202 @@
1
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
+ import { createApp, defineComponent, h, nextTick, ref } from "vue";
3
+
4
+ import HkBoard, { type BoardNodeInput } from "./HkBoard";
5
+
6
+ /**
7
+ * A board must come back by itself when its container goes from "no box"
8
+ * to a real one.
9
+ *
10
+ * Measured on the docs site (2026-11-26): the mermaid card's canvas
11
+ * collapsed to 2px inside a flex row, HkBoard mounted against a 0-width
12
+ * viewport, and the camera stayed at that degenerate fit — the diagram was
13
+ * invisible until the reader pressed the minimap's reset. The fix has two
14
+ * halves: `boardFit` no longer returns a NEGATIVE scale, and the
15
+ * ResizeObserver path re-fits on the first real size after a degenerate
16
+ * one. This pins the second half.
17
+ */
18
+ const nodes: BoardNodeInput[] = [
19
+ { id: "a", x: 0, y: 0, w: 120, h: 80, label: "A" },
20
+ { id: "b", x: 400, y: 0, w: 120, h: 80, label: "B" },
21
+ ];
22
+
23
+ const VIEW_W = 800;
24
+ const VIEW_H = 600;
25
+
26
+ /** happy-dom lays nothing out; the box is whatever these getters say. */
27
+ const box = { w: 0, h: 0 };
28
+
29
+ let observers: Array<() => void> = [];
30
+
31
+ class FakeResizeObserver {
32
+ constructor(private readonly cb: () => void) {}
33
+ observe(): void {
34
+ // Browsers deliver one notification as soon as observation starts, not
35
+ // only on a later change; mirror that so a mount-time refresh is
36
+ // exercised the same way it is in Chrome.
37
+ observers.push(this.cb);
38
+ this.cb();
39
+ }
40
+ disconnect(): void {
41
+ observers = observers.filter((cb) => cb !== this.cb);
42
+ }
43
+ unobserve(): void {}
44
+ }
45
+
46
+ /** Fire every live observer once, as a browser would after a layout change. */
47
+ function triggerResize(): void {
48
+ for (const cb of [...observers]) cb();
49
+ }
50
+
51
+ function scaleOf(transform: string): number {
52
+ return Number(/scale\((-?[\d.]+)\)/.exec(transform)?.[1] ?? 0);
53
+ }
54
+
55
+ function mountBoard(props: Record<string, unknown> = {}): { transform: () => string; unmount: () => void } {
56
+ const host = document.createElement("div");
57
+ document.body.appendChild(host);
58
+ const app = createApp(defineComponent({
59
+ setup: () => () => h(HkBoard, { nodes, ...props }),
60
+ }));
61
+ app.mount(host);
62
+ return {
63
+ transform: () => document.body.querySelector<HTMLElement>(".hk-board-world")!.style.transform,
64
+ unmount: () => app.unmount(),
65
+ };
66
+ }
67
+
68
+ describe("HkBoard viewport recovery", () => {
69
+ // happy-dom defines neither of these as own prototype properties worth
70
+ // keeping, but the repo's convention is to snapshot + restore (see
71
+ // HkBoard.scale.test.ts) so a non-isolated runner cannot inherit the stubs.
72
+ let savedWidth: PropertyDescriptor | undefined;
73
+ let savedHeight: PropertyDescriptor | undefined;
74
+
75
+ beforeEach(() => {
76
+ savedWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "clientWidth");
77
+ savedHeight = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "clientHeight");
78
+ (globalThis as unknown as { ResizeObserver: unknown }).ResizeObserver = FakeResizeObserver;
79
+ Object.defineProperty(HTMLElement.prototype, "clientWidth", {
80
+ configurable: true,
81
+ get: () => box.w,
82
+ });
83
+ Object.defineProperty(HTMLElement.prototype, "clientHeight", {
84
+ configurable: true,
85
+ get: () => box.h,
86
+ });
87
+ observers = [];
88
+ box.w = 0;
89
+ box.h = 0;
90
+ });
91
+
92
+ afterEach(() => {
93
+ document.body.innerHTML = "";
94
+ observers = [];
95
+ if (savedWidth) Object.defineProperty(HTMLElement.prototype, "clientWidth", savedWidth);
96
+ else delete (HTMLElement.prototype as unknown as Record<string, unknown>).clientWidth;
97
+ if (savedHeight) Object.defineProperty(HTMLElement.prototype, "clientHeight", savedHeight);
98
+ else delete (HTMLElement.prototype as unknown as Record<string, unknown>).clientHeight;
99
+ delete (globalThis as unknown as Record<string, unknown>).ResizeObserver;
100
+ });
101
+
102
+ it("re-fits once the container grows from a degenerate box to a real one", async () => {
103
+ // The measured docs-hub shape: a 2px-wide canvas (its border only) with a
104
+ // real height, i.e. narrower than the fit padding.
105
+ box.w = 2;
106
+ box.h = 304;
107
+ const { transform, unmount } = mountBoard();
108
+ await nextTick();
109
+ await new Promise((r) => setTimeout(r, 30));
110
+ // No negative (mirrored) framing is allowed to survive the mount.
111
+ expect(scaleOf(transform())).toBeGreaterThanOrEqual(0);
112
+
113
+ box.w = VIEW_W;
114
+ box.h = VIEW_H;
115
+ triggerResize();
116
+ await nextTick();
117
+ await new Promise((r) => setTimeout(r, 260)); // fit tween is ~170ms
118
+
119
+ const k = scaleOf(transform());
120
+ // (800 - 80) / (620 content width incl. the 20px bbox margin) ≈ 1.16,
121
+ // capped at 1.25 — the point is that a real, positive fit happened
122
+ // without the reader pressing reset.
123
+ expect(k).toBeGreaterThan(0.5);
124
+ expect(k).toBeLessThanOrEqual(1.25 + 1e-6);
125
+ unmount();
126
+ });
127
+
128
+ it("does not overrule a host that drives its own camera", async () => {
129
+ box.w = VIEW_W;
130
+ box.h = VIEW_H;
131
+ const host = document.createElement("div");
132
+ document.body.appendChild(host);
133
+ const board = ref<{ zoomToPercent: (p: number) => void } | null>(null);
134
+ const app = createApp(defineComponent({
135
+ setup: () => () => h(HkBoard, { nodes, ref: board }),
136
+ }));
137
+ app.mount(host);
138
+ await nextTick();
139
+ await new Promise((r) => setTimeout(r, 260));
140
+
141
+ // The host picks its own framing (a 2× zoom, not the fit).
142
+ board.value?.zoomToPercent(200);
143
+ await nextTick();
144
+ await new Promise((r) => setTimeout(r, 260));
145
+ const hostChoice = scaleOf(document.body.querySelector<HTMLElement>(".hk-board-world")!.style.transform);
146
+ expect(hostChoice).toBeGreaterThan(1.5);
147
+
148
+ // Collapse to the docs-hub shape, then come back: the recovery path
149
+ // must NOT re-frame over the host's own choice.
150
+ box.w = 2;
151
+ box.h = 304;
152
+ triggerResize();
153
+ await nextTick();
154
+ box.w = VIEW_W;
155
+ box.h = VIEW_H;
156
+ triggerResize();
157
+ await nextTick();
158
+ await new Promise((r) => setTimeout(r, 260));
159
+ const after = scaleOf(document.body.querySelector<HTMLElement>(".hk-board-world")!.style.transform);
160
+ expect(after).toBeCloseTo(hostChoice, 6);
161
+ app.unmount();
162
+ });
163
+
164
+ it("leaves the camera alone when the host opted out of the mount fit", async () => {
165
+ // `fitOnMount: false` means "the host frames this board". A late recovery
166
+ // fit would overrule that opt-out even when the host never touched the
167
+ // camera itself, so the degenerate→real transition must not re-fit.
168
+ box.w = 2;
169
+ box.h = 304;
170
+ const { transform, unmount } = mountBoard({ fitOnMount: false });
171
+ await nextTick();
172
+ await new Promise((r) => setTimeout(r, 30));
173
+ const atMount = transform();
174
+
175
+ box.w = VIEW_W;
176
+ box.h = VIEW_H;
177
+ triggerResize();
178
+ await nextTick();
179
+ await new Promise((r) => setTimeout(r, 260));
180
+ expect(transform()).toBe(atMount);
181
+ unmount();
182
+ });
183
+
184
+ it("keeps a real mount fit untouched when the first size is already real", async () => {
185
+ box.w = VIEW_W;
186
+ box.h = VIEW_H;
187
+ const { transform, unmount } = mountBoard();
188
+ await nextTick();
189
+ await new Promise((r) => setTimeout(r, 260));
190
+ const mounted = scaleOf(transform());
191
+ expect(mounted).toBeGreaterThan(0.5);
192
+
193
+ // An ordinary resize (no degenerate predecessor) must not re-frame the
194
+ // camera — the reader owns it after mount.
195
+ box.w = 1000;
196
+ triggerResize();
197
+ await nextTick();
198
+ await new Promise((r) => setTimeout(r, 40));
199
+ expect(scaleOf(transform())).toBeCloseTo(mounted, 6);
200
+ unmount();
201
+ });
202
+ });
@@ -31,6 +31,35 @@
31
31
  }
32
32
  }
33
33
 
34
+ // ── Subgraph cluster frame ───────────────────────────────────────────
35
+ // Paint-only shell behind a subgraph's members: dashed outline + wash fill,
36
+ // caption pinned to the top-left inside the reserved header band. The fill
37
+ // stays translucent because the board paints edges UNDER nodes — an opaque
38
+ // frame would black out every edge inside the cluster.
39
+ .hk-mmd-group {
40
+ position: relative;
41
+ width: 100%;
42
+ height: 100%;
43
+ box-sizing: border-box;
44
+ border: 1px dashed rgb(var(--color-primary) / 45%);
45
+ border-radius: var(--radius-md, 8px);
46
+ background: rgb(var(--color-primary) / 4%);
47
+ pointer-events: none;
48
+
49
+ &__label {
50
+ position: absolute;
51
+ top: 5px;
52
+ inset-inline-start: 10px;
53
+ max-width: calc(100% - 20px);
54
+ overflow: hidden;
55
+ text-overflow: ellipsis;
56
+ white-space: nowrap;
57
+ font-size: 12px;
58
+ font-weight: 600;
59
+ color: rgb(var(--color-text) / 78%);
60
+ }
61
+ }
62
+
34
63
  // ── Graph node shells (shape kinds) ──────────────────────────────────
35
64
 
36
65
  .hk-mmd-node {
@@ -0,0 +1,52 @@
1
+ import { dirname, resolve } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+
4
+ import { compile } from "sass";
5
+ import { describe, expect, it } from "vitest";
6
+
7
+ /**
8
+ * Compiled-stylesheet guard for the subgraph cluster frame.
9
+ *
10
+ * Vitest stubs CSS, so the runtime suite can never see a lost rule: the
11
+ * `passthrough` flag is pinned twice as DATA (the layout node carries it, the
12
+ * board DOM node gets the class), but the declaration that gives it any
13
+ * effect — `pointer-events: none` on that class — could be neutralised to
14
+ * `auto` and leave every other test green. That would put the frame back in
15
+ * the pointer path, where it eats the pan drag. This compiles the sheets and
16
+ * asserts the contract, the same shape HkFilterPanel/DockBar already use.
17
+ */
18
+
19
+ const componentDir = resolve(dirname(fileURLToPath(import.meta.url)));
20
+
21
+ function compiled(file: string): string {
22
+ return compile(resolve(componentDir, file), { style: "expanded" }).css;
23
+ }
24
+
25
+ /** The declaration block of the FIRST rule whose selector text contains
26
+ * `selector`. Each caller passes a needle unique to its rule (the frame's
27
+ * carries the literal brace), so the first-brace scan cannot land on a
28
+ * neighbouring `__label` block. */
29
+ function ruleFor(css: string, selector: string): string {
30
+ const start = css.indexOf(selector);
31
+ expect(start, `${selector} present in the compiled sheet`).toBeGreaterThanOrEqual(0);
32
+ const open = css.indexOf("{", start);
33
+ const close = css.indexOf("}", open);
34
+ return css.slice(open + 1, close);
35
+ }
36
+
37
+ describe("mermaid cluster frame stylesheet contract", () => {
38
+ it("keeps passthrough nodes out of the pointer path", () => {
39
+ const css = compiled("HkBoard.scss");
40
+ expect(ruleFor(css, ".hk-board-node--passthrough")).toMatch(/pointer-events:\s*none/);
41
+ });
42
+
43
+ it("paints the frame as a dashed wash behind its members", () => {
44
+ const css = compiled("HkMermaidDiagram.scss");
45
+ const frame = ruleFor(css, ".hk-mmd-group {");
46
+ expect(frame).toMatch(/border:\s*1px dashed/);
47
+ expect(frame).toMatch(/background:/);
48
+ // The caption needs its own band; without it the label paints over the
49
+ // first member row.
50
+ expect(ruleFor(css, ".hk-mmd-group__label")).toMatch(/position:\s*absolute/);
51
+ });
52
+ });