@celestia-island/hikari 0.55.506 → 0.55.508

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.506",
3
+ "version": "0.55.508",
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",
@@ -89,6 +89,23 @@
89
89
 
90
90
  // Outline shapes: the SVG strip paints the border, so the outer div keeps
91
91
  // no border/background of its own and the label floats on top.
92
+ &__label {
93
+ position: absolute;
94
+ top: 5px;
95
+ inset-inline-start: 10px;
96
+ max-width: calc(100% - 20px);
97
+ overflow: hidden;
98
+ text-overflow: ellipsis;
99
+ white-space: nowrap;
100
+ font-size: 12px;
101
+ font-weight: 600;
102
+ color: rgb(var(--color-text) / 78%);
103
+ }
104
+ }
105
+
106
+ // ── Graph node shells (shape kinds) ──────────────────────────────────
107
+
108
+ .hk-mmd-node {
92
109
  &--outline {
93
110
  position: relative;
94
111
  border: none;
@@ -120,23 +137,6 @@
120
137
  }
121
138
  }
122
139
 
123
- &__label {
124
- position: absolute;
125
- top: 5px;
126
- inset-inline-start: 10px;
127
- max-width: calc(100% - 20px);
128
- overflow: hidden;
129
- text-overflow: ellipsis;
130
- white-space: nowrap;
131
- font-size: 12px;
132
- font-weight: 600;
133
- color: rgb(var(--color-text) / 78%);
134
- }
135
- }
136
-
137
- // ── Graph node shells (shape kinds) ──────────────────────────────────
138
-
139
- .hk-mmd-node {
140
140
  width: 100%;
141
141
  height: 100%;
142
142
  display: flex;
@@ -203,6 +203,13 @@
203
203
  // all 11. 100% keeps the ellipsis as a last resort while letting the
204
204
  // sized box do its job.
205
205
  max-width: 100%;
206
+ // …but a flex item does not stop at its content width: with the default
207
+ // `flex-shrink: 1` the label SHRANK to a third of the box and ellipsized
208
+ // anyway (measured on the shape sample 2026-11-28: stadium's label box was
209
+ // 31px inside a 104px node, so all seven outline shapes clipped). The
210
+ // label takes its content width and never more than the box.
211
+ flex: 0 0 auto;
212
+ width: max-content;
206
213
  overflow: hidden;
207
214
  text-overflow: ellipsis;
208
215
  white-space: nowrap;
@@ -112,4 +112,31 @@ describe("mermaid zoom bar placement contract", () => {
112
112
  expect(bar).toMatch(/position:\s*relative/);
113
113
  expect(bar).toMatch(/inset:\s*auto/);
114
114
  });
115
+
116
+ /// The shape sample's labels ellipsized inside boxes that were BIG ENOUGH:
117
+ /// the node is a flex row, and a `flex-shrink: 1` label shrank to a third of
118
+ /// the box (measured 2026-11-28: stadium's label box 31px inside a 104px
119
+ /// node). Seven of eleven shapes clipped. The layout already sizes the box
120
+ /// from the label, so the label must take its content width and stop at the
121
+ /// box — never shrink below it.
122
+ ///
123
+ /// MUT: dropping `flex: 0 0 auto` / `width: max-content` brings every
124
+ /// ellipsis back while the box stays correct, which no width assertion sees.
125
+ it("the outline label takes its content width instead of shrinking", () => {
126
+ // The compiled sheet names the descendant rule, so the needle is the
127
+ // outline node class plus the label — unique among the sheet's rules.
128
+ const css = compiled("HkMermaidDiagram.scss");
129
+ // The label rule sits in the NODE block, so its compiled selector is the
130
+ // bare class — the outline node already scopes it (a node is either an
131
+ // outline or not, never both shapes at once).
132
+ const body = ruleFor(css, ".hk-mmd-node__label {");
133
+ // …and the outline's absolute strip really is absolute: an unscoped SVG
134
+ // spends flex space and squeezes the label (the actual clipping cause).
135
+ expect(ruleFor(css, ".hk-mmd-node__outline {")).toMatch(/position:\s*absolute/);
136
+ expect(ruleFor(css, ".hk-mmd-node--outline {")).toMatch(/border:\s*none/);
137
+ expect(body).toMatch(/flex:\s*0 0 auto/);
138
+ expect(body).toMatch(/width:\s*max-content/);
139
+ // The percentage cap stays: a genuinely longer label still ellipsizes.
140
+ expect(body).toMatch(/max-width:\s*100%/);
141
+ });
115
142
  });
@@ -133,6 +133,34 @@ describe("link head adornments", () => {
133
133
  });
134
134
  });
135
135
 
136
+ describe("state notes", () => {
137
+ /// `note right of X : text` is an ANNOTATION, and an unrecognised statement
138
+ /// in a state diagram fails the WHOLE parse — the card falls back to a plain
139
+ /// code block. A composite-state sample carrying one note did exactly that
140
+ /// (found by the two-lane audit harness, not by any unit test here).
141
+ ///
142
+ /// MUT: dropping the note branch makes the parse return null again.
143
+ it("a note never costs the whole diagram", async () => {
144
+ await mermaidReady;
145
+ const doc = wasmMermaidEngine.parse(
146
+ "stateDiagram-v2\n [*] --> Outer\n state Outer {\n [*] --> InnerA\n InnerA --> InnerB : go\n InnerB --> [*]\n }\n Outer --> Done : finish\n note right of Done : terminal\n Done --> [*]",
147
+ );
148
+ expect(doc, "the note must not fail the parse").not.toBeNull();
149
+ const g = doc as unknown as {
150
+ nodes: Array<{ id: string; label: string; shape: string }>;
151
+ groups: Array<{ id: string; members: string[] }>;
152
+ };
153
+ // The note is its own small node carrying its text…
154
+ const note = g.nodes.find((n) => n.id.startsWith("__hk_note_"));
155
+ expect(note, "a note node").toBeTruthy();
156
+ expect(note!.label).toBe("terminal");
157
+ // …and the composite still closed correctly around its members.
158
+ expect(g.groups.map((x) => x.id)).toEqual(["Outer"]);
159
+ expect(g.groups[0].members).toContain("InnerA");
160
+ expect(g.groups[0].members).toContain("InnerB");
161
+ });
162
+ });
163
+
136
164
  describe("stateDiagram", () => {
137
165
  it("parses state transitions as graph", async () => {
138
166
  await mermaidReady;
@@ -1,7 +1,7 @@
1
1
  <!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta name="hk-error-landing" content="v1 0.55.506 <dev>">
4
+ <meta name="hk-error-landing" content="v1 0.55.508 <dev>">
5
5
  <meta charset="utf-8" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
7
  <meta name="robots" content="noindex" />
@@ -22,6 +22,11 @@ exports[`mermaid golden snapshots (wasm is the reference) > mermaid: class-basic
22
22
  ],
23
23
  "name": "Animal",
24
24
  },
25
+ {
26
+ "attributes": [],
27
+ "methods": [],
28
+ "name": "Dog",
29
+ },
25
30
  ],
26
31
  "kind": "class",
27
32
  "relationships": [
@@ -64,8 +64,10 @@ describe("wasmMermaidEngine", () => {
64
64
  ) as MermaidClassDoc;
65
65
  expect(doc).not.toBeNull();
66
66
  expect(doc!.kind).toBe("class");
67
- expect(doc!.classes).toHaveLength(1);
68
- expect(doc!.classes[0]!.name).toBe("Animal");
67
+ // MUT:implied-classes — `Dog <|-- Animal` implies Dog (an endpoint is a
68
+ // class even without a `class` block); dropping the pass never passes
69
+ // this length assertion.
70
+ expect(doc!.classes.map((c) => c.name)).toEqual(["Animal", "Dog"]);
69
71
  // Members split: +name is an attribute, +speak() is a method.
70
72
  expect(doc!.classes[0]!.attributes).toHaveLength(1);
71
73
  expect(doc!.classes[0]!.methods).toHaveLength(1);
@@ -127,6 +127,7 @@ export function normalizeStateDiagram(source: string): string {
127
127
  // with the top-level one (merging is the defect this rewrite exists to
128
128
  // remove, and it reappears one level down if the id is global).
129
129
  let depth = 0;
130
+ let noteSeq = 0;
130
131
  for (const raw of source.split("\n")) {
131
132
  const line = raw.replace(/^\s*stateDiagram(-v\d+)?/, "graph TD");
132
133
 
@@ -147,6 +148,23 @@ export function normalizeStateDiagram(source: string): string {
147
148
  }
148
149
 
149
150
  const scope = depth > 0 ? `_${depth}` : "";
151
+
152
+ // `note right of X : text` / `note over X : text` / `note left of X`.
153
+ // A note is an ANNOTATION, and an unrecognised statement in a state
154
+ // diagram fails the WHOLE parse (the card falls back to a code block), so
155
+ // the line becomes a small note node joined to its subject by a dotted
156
+ // link — close to what mermaid draws, and never fatal.
157
+ const note = /^\s*note\s+(?:right\s+of|left\s+of|over|on)\s+([A-Za-z0-9_,\s]+?)\s*:\s*(.*)$/i.exec(line);
158
+ if (note) {
159
+ noteSeq += 1;
160
+ const text = note[2].trim().replace(/"/g, "'");
161
+ const subjects = note[1].split(",").map((t) => t.trim()).filter(Boolean);
162
+ out.push(`${note[0].match(/^\s*/)?.[0] ?? ""}__hk_note_${noteSeq}(["${text}"])`);
163
+ for (const subject of subjects) {
164
+ out.push(`${note[0].match(/^\s*/)?.[0] ?? ""}__hk_note_${noteSeq} -.-> ${subject}`);
165
+ }
166
+ continue;
167
+ }
150
168
  const START = `__hk_state_start${scope}`;
151
169
  const END = `__hk_state_end${scope}`;
152
170
  const rewritten = line