@celestia-island/hikari 0.55.530 → 0.55.532

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.
@@ -43,9 +43,23 @@ import { type Ref, type VNode } from "vue";
43
43
  * beside `actions`, so a page registers once and the host never touches
44
44
  * the composable to render it.
45
45
  *
46
- * Readout-style header zones (a left-wing HUD cluster) are host-side
47
- * extensions, not part of this contract: this module exposes only the
48
- * right cluster and the centre slot.
46
+ * **The hud slot** (2026-12-03, portable from shittim-chest's local copy of
47
+ * this module): the third zone pages can own — read-only INDICATORS (a
48
+ * scene's FPS tag, a streaming counter, a queue depth). The channel carries
49
+ * the registration only; WHERE the band renders is the rendering layout's
50
+ * business, because only that layout knows what else shares the edge. A
51
+ * layout with a readout area reads it through {@link useActionBarHud} and
52
+ * decides — from `has()` inside its own render — whether to mount the band
53
+ * at all. No shipped layout renders the zone today (`HkFaceShell` has no
54
+ * readout area and the admin header has no readout slot), so a console page
55
+ * that needs one extends its header first; the first consumer is a host
56
+ * layout (chest's chat header, whose placement is chest's own geometry).
57
+ * Same per-scope lifetime as the other zones: the registering view's
58
+ * readout lives exactly as long as the view (a later registration REPLACES
59
+ * it, the `setCenter` rule), so a plugin surface configures its own readout
60
+ * without touching the layouts. HUD entries are INDICATORS, never controls:
61
+ * a renderer must not render interactive chrome (buttons belong to
62
+ * `setActions`).
49
63
  */
50
64
  /** A function that produces fresh VNodes for the action bar on each render. */
51
65
  export type ActionBarRenderer = () => VNode[];
@@ -119,6 +133,12 @@ interface ActionBarContext {
119
133
  * switcher: a dropdown over the page's own subjects). `null` when the
120
134
  * page registers none, so the layout hands its footer no dead wrapper. */
121
135
  footerCenter: Ref<ActionBarRenderer | null>;
136
+ /** The hud zone's renderer — the readouts a view shows in the layout's
137
+ * readout area (see the module doc's hud slot note). `null` when the page
138
+ * registers none, so a layout with a readout area mounts no empty one; a
139
+ * view owns exactly one (setting it again REPLACES the previous
140
+ * registration). */
141
+ hud: Ref<ActionBarRenderer | null>;
122
142
  }
123
143
  export declare function provideActionBar(): ActionBarContext;
124
144
  /**
@@ -151,15 +171,35 @@ export declare function useActionBarCenter(): ActionBarRenderer | undefined;
151
171
  *
152
172
  * Call in setup — it injects.
153
173
  */
154
- export interface FooterCentreChannel {
174
+ /** The `has` / `render` pair a layout reads from a single-renderer action-bar
175
+ * zone — the footer centre ({@link useActionBarFooterCenter}) and the hud
176
+ * ({@link useActionBarHud}) share this one shape. */
177
+ export interface ActionBarChannel {
155
178
  /** True while a registration exists. Reading it inside a render collects
156
- * the dependency, which is how the shell decides whether to hand its
157
- * footer slot a `centre` at all (an absent field, not an empty wrapper). */
179
+ * the dependency, which is how the consuming layout decides whether to
180
+ * hand its slot a renderer at all (an absent field, not an empty
181
+ * wrapper). */
158
182
  has: () => boolean;
159
183
  /** The registered renderer (fresh VNodes per call — never cache them). */
160
184
  render: () => VNode[];
161
185
  }
162
- export declare function useActionBarFooterCenter(): FooterCentreChannel | undefined;
186
+ export declare function useActionBarFooterCenter(): ActionBarChannel | undefined;
187
+ /**
188
+ * The enclosing bar's HUD (readout) channel — the same pair as
189
+ * {@link useActionBarFooterCenter} (see it for why the pair is `has` +
190
+ * `render` rather than a bare renderer) applied to the third zone: a mounted
191
+ * view's read-only indicators (a scene's live FPS tag, a streaming counter),
192
+ * registered through `useActionBar().setHud`. A layout that owns a readout
193
+ * area reads it here; `has()` is read INSIDE that layout's render, so a
194
+ * registration arriving after the first render still repaints the band, and a
195
+ * layout with no registration renders no empty band.
196
+ *
197
+ * `undefined` when nothing provides a bar: such a layout keeps its readout
198
+ * band ABSENT instead of mounting an always-empty one.
199
+ *
200
+ * Call in setup — it injects.
201
+ */
202
+ export declare function useActionBarHud(): ActionBarChannel | undefined;
163
203
  export declare function useActionBar(): {
164
204
  setActions: (_renderer: ActionBarRenderer, _slot: string) => void;
165
205
  clearActions: () => void;
@@ -170,5 +210,8 @@ export declare function useActionBar(): {
170
210
  setFooterCenter: (_renderer: ActionBarRenderer) => void;
171
211
  clearFooterCenter: () => void;
172
212
  footerCenter: Ref<ActionBarRenderer | null, ActionBarRenderer | null>;
213
+ setHud: (_renderer: ActionBarRenderer) => void;
214
+ clearHud: () => void;
215
+ hud: Ref<ActionBarRenderer | null, ActionBarRenderer | null>;
173
216
  };
174
217
  export {};
@@ -246,8 +246,8 @@ export { HkAuthHandoff as HAuthHandoff } from "./components/HkAuthHandoff";
246
246
  export { HkMfaVerifyCard as HMfaVerifyCard, hkIsMfaFactor as isMfaFactor, hkPreferredMfaFactor as preferredMfaFactor, hkMfaVerifyTitle as mfaVerifyTitle, hkMfaVerifySubtitle as mfaVerifySubtitle, type HkMfaFactor as MfaFactor, } from "./components/HkMfaVerifyCard";
247
247
  export { usePageTitle, useRouteTitle } from "./composables/usePageTitle";
248
248
  export { provideActionBar, useActionBar, PageActionSlot, orderActionRegistrations } from "./composables/useActionBar";
249
- export { useActionBarCenter, useActionBarFooterCenter } from "./composables/useActionBar";
250
- export type { ActionBarRenderer, PageActionSlotValue, ActionBarRegistration } from "./composables/useActionBar";
249
+ export { useActionBarCenter, useActionBarFooterCenter, useActionBarHud, } from "./composables/useActionBar";
250
+ export type { ActionBarRenderer, ActionBarChannel, PageActionSlotValue, ActionBarRegistration, } from "./composables/useActionBar";
251
251
  export { useChromeActionSize } from "./composables/useChromeActionSize";
252
252
  export { usePageCreateAction } from "./composables/usePageCreateAction";
253
253
  export type { UsePageCreateActionOptions } from "./composables/usePageCreateAction";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.530",
3
+ "version": "0.55.532",
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",
@@ -0,0 +1,201 @@
1
+ // AI-generated: developed with the DeepSeek Harness agent (model GLM-5.4); human-directed.
2
+ import { afterEach, describe, expect, it } from "vitest";
3
+ import { createApp, defineComponent, h, nextTick, ref, type App, type Component, type Ref } from "vue";
4
+
5
+ import { HkFaceShell, type HkFaceShellHeaderSlot } from "./HkFaceShell";
6
+ import { provideActionBar, useActionBar, useActionBarHud } from "../composables/useActionBar";
7
+
8
+ /**
9
+ * The hud (readout) channel, in the shape a FACE uses it: the host
10
+ * provides the bar, the face reads it through `useActionBarHud()` and renders
11
+ * the band INSIDE its own render — the same delivery `HkFaceShell`'s footer
12
+ * centre uses (`HkFaceShell.footerCentre.test.tsx`), so the two channels are
13
+ * pinned against one another.
14
+ *
15
+ * The band here stands in the header slot because the family ships no header
16
+ * with a readout band yet (the admin header has none): what these cases pin is
17
+ * the channel a face consumes a readout through.
18
+ *
19
+ * comment-gate-ok: fixture rationale — no behaviour claim (the claims are the
20
+ * `MUT:`-anchored cases below).
21
+ */
22
+
23
+ const mounts: Array<{ app: App; container: HTMLElement }> = [];
24
+
25
+ /** The readout a mounted surface registers (the shape under test). */
26
+ const Readout = defineComponent({
27
+ name: "FpsReadout",
28
+ setup() {
29
+ useActionBar().setHud(() => [h("span", { class: "fps-tag" }, "62 FPS")]);
30
+ return () => h("div", { class: "page-body" }, "page");
31
+ },
32
+ });
33
+
34
+ /**
35
+ * A host face that renders the shell around the pages. It reads the bar its
36
+ * PARENT provided (provide and inject cannot meet inside one setup — the
37
+ * HkAdminShell / HkFaceShell split the family actually ships) and mounts the
38
+ * readout band only when `has()` says one is there.
39
+ *
40
+ * The binding is deliberately a FUNCTION the render body CALLS
41
+ * (`hudHas()`), not a value resolved at setup: a face must re-ask on every
42
+ * pass, and MUT:hud-read-once (caching the first answer) then reds the
43
+ * late-registration case instead of being swallowed by a setup-time read.
44
+ */
45
+ function harness(options: { show?: Ref<boolean> } = {}) {
46
+ const show = options.show ?? ref(true);
47
+ return defineComponent({
48
+ name: "HudShellHarness",
49
+ setup() {
50
+ const hud = useActionBarHud();
51
+ return {
52
+ hudHas: () => hud?.has() ?? false,
53
+ hudRender: () => hud?.render() ?? [],
54
+ };
55
+ },
56
+ render() {
57
+ const self = this;
58
+ return h(
59
+ HkFaceShell,
60
+ { sidebarWidth: "120px" },
61
+ {
62
+ // The readout band: `has()` is read inside this render, on every
63
+ // pass, so a late registration repaints it.
64
+ header: (_params: HkFaceShellHeaderSlot) => [
65
+ h("span", { class: "header-left-marker" }, "left"),
66
+ self.hudHas()
67
+ ? h("div", { class: "header-hud" }, self.hudRender())
68
+ : h("div", { class: "header-hud-empty" }),
69
+ ],
70
+ content: () =>
71
+ show.value ? h(Readout) : h("div", { class: "page-body" }, "page"),
72
+ },
73
+ );
74
+ },
75
+ });
76
+ }
77
+
78
+ async function flush(): Promise<void> {
79
+ // Two passes: the registering scope's dispose (ref = null) and the face's
80
+ // repaint are separate effects, and the order Vue schedules them depends
81
+ // on what else is mounted — one tick is a flaky budget (the footer-centre
82
+ // suite hit exactly this).
83
+ await nextTick();
84
+ await nextTick();
85
+ }
86
+
87
+ /** The face's PARENT: whoever owns the bar (the admin shell's seat). */
88
+ function withBar(inner: () => Component) {
89
+ return defineComponent({
90
+ name: "BarHost",
91
+ setup() {
92
+ provideActionBar();
93
+ return () => h(inner());
94
+ },
95
+ });
96
+ }
97
+
98
+ function mountShell(options: { show?: Ref<boolean> } = {}): HTMLElement {
99
+ const container = document.createElement("div");
100
+ document.body.appendChild(container);
101
+ const View = harness(options);
102
+ const app = createApp({ render: () => h(withBar(() => h(View))) });
103
+ app.mount(container);
104
+ mounts.push({ app, container });
105
+ return container;
106
+ }
107
+
108
+ afterEach(() => {
109
+ for (const { app, container } of mounts.splice(0)) {
110
+ app.unmount();
111
+ container.remove();
112
+ }
113
+ document.body.innerHTML = "";
114
+ });
115
+
116
+ describe("HkFaceShell hud channel", () => {
117
+ it("delivers a view's readout to the face's readout band", async () => {
118
+ // MUT:hud-not-delivered
119
+ const container = mountShell();
120
+ await flush();
121
+ const band = container.querySelector(".header-hud");
122
+ expect(band).not.toBeNull();
123
+ expect(band?.querySelector(".fps-tag")?.textContent).toBe("62 FPS");
124
+ // The header's own chrome keeps flowing around it.
125
+ expect(container.querySelector(".header-left-marker")).not.toBeNull();
126
+ // And it sits AFTER the wing's own chrome, not before it.
127
+ const header = container.querySelector(".header-hud")?.parentElement;
128
+ const order = Array.from(header?.children ?? []).map((c) => c.className);
129
+ expect(order.indexOf("header-hud")).toBeGreaterThan(order.indexOf("header-left-marker"));
130
+ });
131
+
132
+ it("leaves the band ABSENT (no empty wrapper) when nothing registered", async () => {
133
+ // A face with no readout must not gain a dead band at the end of its
134
+ // readout area: `has()` answers false and the face renders nothing there.
135
+ // MUT:hud-always-present
136
+ const container = mountShell({ show: ref(false) });
137
+ await flush();
138
+ expect(container.querySelector(".header-hud-empty")).not.toBeNull();
139
+ expect(container.querySelector(".header-hud")).toBeNull();
140
+ });
141
+
142
+ it("picks up a readout that registers AFTER the first render (the channel is a live dependency)", async () => {
143
+ // The shell's footer-centre case, applied to the hud: `has()` is read
144
+ // inside the face's render, so a registration arriving later must
145
+ // repaint the band. Caching the first (absent) answer freezes the band
146
+ // out of the tree forever — MUT:hud-read-once models that.
147
+ // MUT:hud-read-once
148
+ const show = ref(false);
149
+ const container = mountShell({ show });
150
+ // Settle the FIRST render completely before anything registers, so the
151
+ // band's absent answer is a committed observation, not a transient.
152
+ await flush();
153
+ expect(container.querySelector(".header-hud")).toBeNull();
154
+ show.value = true;
155
+ await flush();
156
+ expect(container.querySelector(".header-hud .fps-tag")).not.toBeNull();
157
+ });
158
+
159
+ it("clears the readout when the registering view unmounts", async () => {
160
+ // The registration dies with its scope, exactly like the footer
161
+ // switcher — a leftover FPS tag would report a scene that is gone.
162
+ // MUT:hud-dispose-dropped
163
+ const show = ref(true);
164
+ const container = mountShell({ show });
165
+ await flush();
166
+ expect(container.querySelector(".header-hud .fps-tag")).not.toBeNull();
167
+ show.value = false;
168
+ await flush();
169
+ expect(container.querySelector(".header-hud")).toBeNull();
170
+ expect(container.querySelector(".header-hud-empty")).not.toBeNull();
171
+ });
172
+
173
+ it("keeps a bare shell's face band out of the tree when NO bar is provided above", async () => {
174
+ // The channel reports itself ABSENT without a provider, so a face that
175
+ // reads it keeps its band out instead of mounting an empty one — the
176
+ // shell carries no action-bar provider of its own.
177
+ // MUT:hud-channel-without-provider
178
+ const container = document.createElement("div");
179
+ document.body.appendChild(container);
180
+ const Bare = defineComponent({
181
+ name: "BareFace",
182
+ setup() {
183
+ // No bar is provided above this face — the channel is `undefined`.
184
+ const hud = useActionBarHud();
185
+ return () =>
186
+ h(HkFaceShell, { sidebarWidth: "120px" }, {
187
+ header: (_params: HkFaceShellHeaderSlot) => [
188
+ hud ? h("div", { class: "header-hud-channel" }) : h("div", { class: "header-hud-absent" }),
189
+ ],
190
+ content: () => h("div", { class: "page-body" }, "page"),
191
+ });
192
+ },
193
+ });
194
+ const app = createApp({ render: () => h(Bare) });
195
+ app.mount(container);
196
+ mounts.push({ app, container });
197
+ await flush();
198
+ expect(container.querySelector(".header-hud-absent")).not.toBeNull();
199
+ expect(container.querySelector(".header-hud-channel")).toBeNull();
200
+ });
201
+ });
@@ -67,6 +67,21 @@ afterEach(() => {
67
67
  });
68
68
 
69
69
  describe("HkInput affix reservation contract", () => {
70
+ it("the affix's type matches the field element's triple", () => {
71
+ // 2026-12-03 ayane report: an affix carrying TEXT (the registration
72
+ // form's `@domain` suffix) rendered in another family/size than the
73
+ // handle beside it — the affix rule had no font at all, so its text
74
+ // inherited along the OUTER chain while the input element carried
75
+ // hikari's explicit triple. The rule must keep the triple on the
76
+ // affix itself (MUT:affix-type-triple-dropped — deleting any of the
77
+ // three lines reddens this).
78
+ const sheet = readFileSync(join(here, "HkInput.scss"), "utf8");
79
+ const rule = /\.hk-input-affix \{([^}]*)\}/.exec(sheet)?.[1] ?? "";
80
+ expect(rule).toContain("font-family: inherit");
81
+ expect(rule).toContain("font-size: var(--text-base)");
82
+ expect(rule).toContain("line-height: 1.5");
83
+ });
84
+
70
85
  it("pins the trailing affix to the right edge", () => {
71
86
  const rule = scss.match(/\.hk-input-affix\.hk-input-suffix\s*{[^}]*}/)?.[0] ?? "";
72
87
  expect(rule, "suffix rule must exist").toContain("margin-inline-start: auto");
@@ -166,9 +166,22 @@
166
166
  resize: none;
167
167
  }
168
168
 
169
+ // The affix's type MUST match the field element's triple (the input
170
+ // element itself is font-family inherit / font-size var(--text-base) /
171
+ // line-height 1.5). Without this the affix text inherits along the OUTER
172
+ // chain and renders in another family/size than the handle beside it
173
+ // (2026-12-03 ayane report: the registration form's domain suffix did not
174
+ // match the editable local part next to it). inherit here resolves inside
175
+ // the hikari box, so both sides land on the same family. The triple lives
176
+ // INSIDE the rule — HkInput.affix.test pins it there, and a doc comment
177
+ // inside the braces would satisfy a toContain even with the real lines
178
+ // deleted.
169
179
  .hk-input-affix {
170
180
  display: flex;
171
181
  align-items: center;
182
+ font-family: inherit;
183
+ font-size: var(--text-base);
184
+ line-height: 1.5;
172
185
  color: color-mix(in srgb, rgb(var(--color-muted)) 70%, rgb(var(--color-background)));
173
186
  flex-shrink: 0;
174
187
  position: relative;
@@ -1,11 +1,18 @@
1
- import { createApp, defineComponent, h, nextTick, ref } from "vue";
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ import { createApp, defineComponent, h, nextTick, ref, type Component } from "vue";
2
6
  import { afterEach, describe, expect, it } from "vitest";
3
7
 
8
+ import * as actionBarModule from "./useActionBar";
4
9
  import {
5
10
  orderActionRegistrations,
6
11
  PageActionSlot,
7
12
  provideActionBar,
8
13
  useActionBar,
14
+ useActionBarFooterCenter,
15
+ useActionBarHud,
9
16
  type ActionBarRegistration,
10
17
  } from "./useActionBar";
11
18
 
@@ -21,7 +28,10 @@ import {
21
28
  * - canonical slots render by rank regardless of registration order;
22
29
  * customs stuff right-to-left (first-registered = rightmost);
23
30
  * - the identity guard keeps a leaving view's dispose from wiping the
24
- * entering view's chrome (the crossfade instant).
31
+ * entering view's chrome (the crossfade instant);
32
+ * - the HUD (readout) zone follows the centre slot's contract:
33
+ * one renderer, replaced on re-registration, dropped with its scope —
34
+ * read by a layout through the `useActionBarHud` has/render pair.
25
35
  */
26
36
 
27
37
  const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
@@ -64,6 +74,17 @@ function makeCenterView(tag: string) {
64
74
  });
65
75
  }
66
76
 
77
+ function makeHudView(tag: string) {
78
+ return defineComponent({
79
+ name: `HudView-${tag}`,
80
+ setup() {
81
+ const bar = useActionBar();
82
+ bar.setHud(() => [h("span", { class: "reg-hud" }, tag)]);
83
+ return () => h("div", { class: `view-body view-${tag}` }, "view");
84
+ },
85
+ });
86
+ }
87
+
67
88
  function makeLayout(views: () => unknown[]) {
68
89
  return defineComponent({
69
90
  name: "Layout",
@@ -84,6 +105,57 @@ async function mountWithViews(views: () => unknown[]) {
84
105
  return container;
85
106
  }
86
107
 
108
+ /**
109
+ * The hud band, read the way a LAYOUT consumes it: `useActionBarHud()`'s
110
+ * `has` / `render` pair, with `has()` consulted inside the render so a
111
+ * late registration repaints the band.
112
+ *
113
+ * This is NOT the general fixture. `makeLayout` above provides the bar and
114
+ * renders `actions` / `center` straight off the returned context, and it
115
+ * serves every pre-existing case — the nine centre and action ones — exactly
116
+ * as it did before this change. Only the HUD cases use this fixture, and they
117
+ * must: `useActionBarHud()` is an `inject`, and `inject` cannot see a
118
+ * `provide` made in the same setup (it walks the parent chain). So the bar's
119
+ * owner (`makeHost`) sits one level up and this layout consumes it — which is
120
+ * also the family's own split, HkAdminShell owning the bar and HkFaceShell
121
+ * below it reading the zones.
122
+ */
123
+ function makeHudLayout(views: () => unknown[]) {
124
+ return defineComponent({
125
+ name: "HudLayout",
126
+ setup() {
127
+ const bar = useActionBar();
128
+ const hud = useActionBarHud();
129
+ if (!hud) throw new Error("useActionBarHud must resolve under a provider");
130
+ return () => [
131
+ h("div", { class: "layout-actions" }, bar.actions.value.flatMap((r) => r())),
132
+ h("div", { class: "layout-center" }, bar.center.value?.() ?? []),
133
+ views(),
134
+ // The readout band, read through the channel a real layout uses
135
+ // (`has()` decides whether the band exists at all).
136
+ hud.has() ? h("div", { class: "layout-hud" }, hud.render()) : null,
137
+ ];
138
+ },
139
+ });
140
+ }
141
+
142
+ /** The bar's OWNER, above the hud layout — the HkAdminShell seat. */
143
+ function makeHost(inner: () => Component) {
144
+ return defineComponent({
145
+ name: "Host",
146
+ setup() {
147
+ provideActionBar();
148
+ return () => h(inner());
149
+ },
150
+ });
151
+ }
152
+
153
+ async function mountHudWithViews(views: () => unknown[]) {
154
+ const container = mountApp(() => h(makeHost(() => h(makeHudLayout(views)))));
155
+ await nextTick();
156
+ return container;
157
+ }
158
+
87
159
  function registeredButtons(container: HTMLElement): string[] {
88
160
  return Array.from(container.querySelectorAll<HTMLElement>(".layout-actions .reg-action")).map(
89
161
  (b) => b.textContent ?? "",
@@ -247,6 +319,206 @@ describe("useActionBar", () => {
247
319
  });
248
320
  });
249
321
 
322
+ /**
323
+ * The HUD zone (2026-12-03): the readout band. Same channel shape
324
+ * as the footer centre (`useActionBarFooterCenter`: a `has` / `render` pair
325
+ * read INSIDE the layout's render), one renderer instead of a list — a view
326
+ * owns its readout, and a later registration replaces it.
327
+ */
328
+ describe("useActionBar hud zone", () => {
329
+ it("renders a descendant's registered hud readout in the layout's band", async () => {
330
+ // MUT:hud-not-delivered
331
+ const view = makeHudView("62 FPS");
332
+ const container = await mountHudWithViews(() => [h(view)]);
333
+ expect(container.querySelector(".layout-hud .reg-hud")?.textContent).toBe("62 FPS");
334
+ // The view body renders too — the readout mirrors, never replaces.
335
+ expect(container.querySelector(".view-body")).not.toBeNull();
336
+ });
337
+
338
+ it("mounts no hud band while nothing registers a readout", async () => {
339
+ // `has()` is what lets a layout leave the band OUT entirely instead of
340
+ // rendering an always-empty readout strip.
341
+ // MUT:hud-always-present
342
+ const bare = defineComponent({
343
+ name: "BareView",
344
+ setup: () => () => h("div", { class: "view-body" }, "view"),
345
+ });
346
+ const container = await mountHudWithViews(() => [h(bare)]);
347
+ expect(container.querySelector(".view-body")).not.toBeNull();
348
+ expect(container.querySelector(".layout-hud")).toBeNull();
349
+ });
350
+
351
+ it("lets a later registration REPLACE the hud readout (one per page)", async () => {
352
+ // The centre rule, inherited: the hud holds ONE renderer, so the page
353
+ // that registers last owns the band — two live views never interleave
354
+ // their readouts (a readout area shows one).
355
+ // MUT:hud-additive
356
+ const showA = ref(true);
357
+ const showB = ref(true);
358
+ const viewA = makeHudView("A");
359
+ const viewB = makeHudView("B");
360
+ const container = await mountHudWithViews(() => [
361
+ showA.value ? h(viewA) : null,
362
+ showB.value ? h(viewB) : null,
363
+ ]);
364
+ expect(container.querySelectorAll(".layout-hud .reg-hud")).toHaveLength(1);
365
+ expect(container.querySelector(".layout-hud .reg-hud")?.textContent).toBe("B");
366
+ });
367
+
368
+ it("drops the hud readout when the registering view unmounts", async () => {
369
+ // Per-scope lifetime, exactly like the buttons and the centre group: a
370
+ // readout must never outlive the page that shows it.
371
+ // MUT:hud-dispose-dropped
372
+ const show = ref(true);
373
+ const view = makeHudView("62 FPS");
374
+ const container = await mountHudWithViews(() => (show.value ? [h(view)] : []));
375
+ expect(container.querySelector(".layout-hud .reg-hud")).not.toBeNull();
376
+
377
+ show.value = false;
378
+ await nextTick();
379
+ expect(container.querySelector(".layout-hud .reg-hud")).toBeNull();
380
+ expect(container.querySelector(".layout-hud")).toBeNull();
381
+ });
382
+
383
+ it("keeps the SURVIVING hud readout when an overlapped view unmounts (identity guard)", async () => {
384
+ // The crossfade instant again: the leaving view (A) disposes AFTER the
385
+ // entering one (B) took the band. An unconditional clear would blank
386
+ // the readout of the page that is actually arriving.
387
+ // MUT:hud-dispose-unconditional
388
+ const showA = ref(true);
389
+ const showB = ref(true);
390
+ const viewA = makeHudView("A");
391
+ const viewB = makeHudView("B");
392
+ const container = await mountHudWithViews(() => [
393
+ showA.value ? h(viewA) : null,
394
+ showB.value ? h(viewB) : null,
395
+ ]);
396
+ expect(container.querySelector(".layout-hud .reg-hud")?.textContent).toBe("B");
397
+
398
+ showA.value = false;
399
+ await nextTick();
400
+ expect(container.querySelector(".layout-hud .reg-hud")?.textContent).toBe("B");
401
+
402
+ showB.value = false;
403
+ await nextTick();
404
+ expect(container.querySelector(".layout-hud")).toBeNull();
405
+ });
406
+
407
+ it("is a silent no-op (and offers no channel) outside any layout provider", async () => {
408
+ // No provider: registering must neither throw nor render, and the
409
+ // layout-side channel reports itself ABSENT (`undefined`) so a shell
410
+ // keeps its band out of the tree rather than mounting an empty one.
411
+ // MUT:hud-no-provider-throws MUT:hud-channel-without-provider
412
+ const probe = defineComponent({
413
+ name: "HudWithoutProvider",
414
+ setup() {
415
+ useActionBar().setHud(() => [h("span", { class: "reg-hud" }, "62 FPS")]);
416
+ return () => h("div", { class: "view-body" }, useActionBarHud() ? "channel" : "no-channel");
417
+ },
418
+ });
419
+ const container = mountApp(() => h(probe));
420
+ await nextTick();
421
+ expect(container.querySelector(".view-body")?.textContent).toBe("no-channel");
422
+ expect(container.querySelector(".reg-hud")).toBeNull();
423
+ });
424
+
425
+ it("picks up a readout that registers AFTER the first render (the channel is a live dependency)", async () => {
426
+ // A late-mounting surface (a canvas registering its FPS tag once the
427
+ // engine has booted) lands its registration after the band's first
428
+ // render. `has()` is read INSIDE the layout's render, so that
429
+ // registration must repaint the band; a layout that cached the first
430
+ // (absent) answer would keep the band out of the tree forever.
431
+ // MUT:hud-read-once
432
+ // The registering surface is created ONCE, outside the render fn (the
433
+ // fixture rule above), and only its MOUNT is deferred — so the second
434
+ // render is the registration's, not a fresh component's.
435
+ const showReadout = ref(false);
436
+ const view = makeHudView("62 FPS");
437
+ const container = await mountHudWithViews(() => (showReadout.value ? [h(view)] : []));
438
+ expect(container.querySelector(".reg-hud")).toBeNull();
439
+ // The band's absent answer is committed before the flip below.
440
+ expect(container.querySelector(".layout-hud")).toBeNull();
441
+
442
+ showReadout.value = true;
443
+ await nextTick();
444
+ expect(container.querySelector(".layout-hud .reg-hud")?.textContent).toBe("62 FPS");
445
+ });
446
+
447
+ });
448
+
449
+ /**
450
+ * The package-root EMISSION pin, read WITHOUT importing the barrel.
451
+ *
452
+ * What this measures, stated plainly: the barrel's export statement for this
453
+ * module carries the names a consumer needs. That is barrel EMISSION — the
454
+ * text of `index.ts` — not end-to-end delivery: a consumer that imports the
455
+ * package root still goes through the module graph this suite deliberately
456
+ * avoids (see below). Delivery across the zones is pinned where it actually
457
+ * happens, by the suites that render through the seams:
458
+ * `HkFaceShell.footerCentre.test.tsx` (the footer slot's `centre`) and
459
+ * `HkFaceShell.hud.test.tsx` (a face rendering the readout band). Those two
460
+ * plus this emission pin are what H8 stands on.
461
+ *
462
+ * Why not import the barrel: `import * as barrel from "../index"` drags its
463
+ * whole static graph into this suite — including the mermaid engine, which
464
+ * imports the gitignored jco bindings — so the composable's own suite could
465
+ * not load on a checkout that has not built them (a clean clone). Reading
466
+ * index.ts as SOURCE keeps that suite runnable everywhere.
467
+ */
468
+ describe("the package root re-exports the chrome", () => {
469
+ const srcDir = join(dirname(fileURLToPath(import.meta.url)), "..");
470
+ const source = readFileSync(join(srcDir, "index.ts"), "utf-8");
471
+
472
+ /** Every `export { a, b } from "<subpath>"` statement in the barrel, as
473
+ * { subpath, names }. */
474
+ function reExportBlocks(): Array<{ subpath: string; names: string[] }> {
475
+ const blocks: Array<{ subpath: string; names: string[] }> = [];
476
+ const statement = /export\s*(?:type\s*)?\{([^}]*)\}\s*from\s*"([^"]+)"/g;
477
+ for (const match of source.matchAll(statement)) {
478
+ blocks.push({
479
+ subpath: match[2],
480
+ names: match[1]
481
+ .split(",")
482
+ .map((entry) => entry.trim().split(/\s+as\s+/)[0].trim())
483
+ .filter(Boolean),
484
+ });
485
+ }
486
+ return blocks;
487
+ }
488
+
489
+ /** The names the barrel's statement for this module carries. */
490
+ function emittedNames(): string[] {
491
+ return reExportBlocks()
492
+ .filter((b) => b.subpath === "./composables/useActionBar")
493
+ .flatMap((b) => b.names);
494
+ }
495
+
496
+ it("emits the hud channel and the two centre reads through the package root", () => {
497
+ // A host reads these through the package root (`@celestia-island/hikari`),
498
+ // never a deep import — so the name must be on the barrel line.
499
+ // MUT:hud-barrel-dropped
500
+ const names = emittedNames();
501
+ expect(names.length).toBeGreaterThan(0);
502
+ for (const exported of ["useActionBarHud", "useActionBarFooterCenter", "useActionBarCenter"]) {
503
+ expect(names, `${exported} must be exported from the package root`).toContain(exported);
504
+ }
505
+ // And they name the very same functions the module ships — a barrel line
506
+ // that renames or re-sources them would break consumers.
507
+ const moduleExports: Record<string, unknown> = actionBarModule;
508
+ expect(moduleExports.useActionBarHud).toBe(useActionBarHud);
509
+ expect(moduleExports.useActionBarFooterCenter).toBe(useActionBarFooterCenter);
510
+ });
511
+
512
+ it("emits the channel TYPE through the package root (typed consumers need it)", () => {
513
+ // The hud and the footer centre share one return type; a host annotating
514
+ // its own layout helper with it needs the type exported too — dropping
515
+ // the type line leaves every consumer that names it red under vue-tsc
516
+ // while the value exports above stay green.
517
+ // MUT:channel-type-barrel-dropped
518
+ expect(emittedNames()).toContain("ActionBarChannel");
519
+ });
520
+ });
521
+
250
522
  describe("orderActionRegistrations (slot ranks + right-to-left customs)", () => {
251
523
  function reg(slot: string, seq: number): ActionBarRegistration {
252
524
  return { renderer: () => [], slot, seq };
@@ -44,9 +44,23 @@ import { computed, inject, onScopeDispose, provide, ref, type Ref, type VNode }
44
44
  * beside `actions`, so a page registers once and the host never touches
45
45
  * the composable to render it.
46
46
  *
47
- * Readout-style header zones (a left-wing HUD cluster) are host-side
48
- * extensions, not part of this contract: this module exposes only the
49
- * right cluster and the centre slot.
47
+ * **The hud slot** (2026-12-03, portable from shittim-chest's local copy of
48
+ * this module): the third zone pages can own — read-only INDICATORS (a
49
+ * scene's FPS tag, a streaming counter, a queue depth). The channel carries
50
+ * the registration only; WHERE the band renders is the rendering layout's
51
+ * business, because only that layout knows what else shares the edge. A
52
+ * layout with a readout area reads it through {@link useActionBarHud} and
53
+ * decides — from `has()` inside its own render — whether to mount the band
54
+ * at all. No shipped layout renders the zone today (`HkFaceShell` has no
55
+ * readout area and the admin header has no readout slot), so a console page
56
+ * that needs one extends its header first; the first consumer is a host
57
+ * layout (chest's chat header, whose placement is chest's own geometry).
58
+ * Same per-scope lifetime as the other zones: the registering view's
59
+ * readout lives exactly as long as the view (a later registration REPLACES
60
+ * it, the `setCenter` rule), so a plugin surface configures its own readout
61
+ * without touching the layouts. HUD entries are INDICATORS, never controls:
62
+ * a renderer must not render interactive chrome (buttons belong to
63
+ * `setActions`).
50
64
  */
51
65
 
52
66
  /** A function that produces fresh VNodes for the action bar on each render. */
@@ -147,6 +161,12 @@ interface ActionBarContext {
147
161
  * switcher: a dropdown over the page's own subjects). `null` when the
148
162
  * page registers none, so the layout hands its footer no dead wrapper. */
149
163
  footerCenter: Ref<ActionBarRenderer | null>;
164
+ /** The hud zone's renderer — the readouts a view shows in the layout's
165
+ * readout area (see the module doc's hud slot note). `null` when the page
166
+ * registers none, so a layout with a readout area mounts no empty one; a
167
+ * view owns exactly one (setting it again REPLACES the previous
168
+ * registration). */
169
+ hud: Ref<ActionBarRenderer | null>;
150
170
  }
151
171
 
152
172
  const KEY = Symbol("action-bar");
@@ -163,6 +183,7 @@ export function provideActionBar() {
163
183
  ),
164
184
  center: ref<ActionBarRenderer | null>(null),
165
185
  footerCenter: ref<ActionBarRenderer | null>(null),
186
+ hud: ref<ActionBarRenderer | null>(null),
166
187
  };
167
188
  provide(KEY, ctx);
168
189
  return ctx;
@@ -203,16 +224,20 @@ export function useActionBarCenter(): ActionBarRenderer | undefined {
203
224
  *
204
225
  * Call in setup — it injects.
205
226
  */
206
- export interface FooterCentreChannel {
227
+ /** The `has` / `render` pair a layout reads from a single-renderer action-bar
228
+ * zone — the footer centre ({@link useActionBarFooterCenter}) and the hud
229
+ * ({@link useActionBarHud}) share this one shape. */
230
+ export interface ActionBarChannel {
207
231
  /** True while a registration exists. Reading it inside a render collects
208
- * the dependency, which is how the shell decides whether to hand its
209
- * footer slot a `centre` at all (an absent field, not an empty wrapper). */
232
+ * the dependency, which is how the consuming layout decides whether to
233
+ * hand its slot a renderer at all (an absent field, not an empty
234
+ * wrapper). */
210
235
  has: () => boolean;
211
236
  /** The registered renderer (fresh VNodes per call — never cache them). */
212
237
  render: () => VNode[];
213
238
  }
214
239
 
215
- export function useActionBarFooterCenter(): FooterCentreChannel | undefined {
240
+ export function useActionBarFooterCenter(): ActionBarChannel | undefined {
216
241
  const ctx = inject<ActionBarContext | null>(KEY, null);
217
242
  if (!ctx) return undefined;
218
243
  return {
@@ -221,6 +246,30 @@ export function useActionBarFooterCenter(): FooterCentreChannel | undefined {
221
246
  };
222
247
  }
223
248
 
249
+ /**
250
+ * The enclosing bar's HUD (readout) channel — the same pair as
251
+ * {@link useActionBarFooterCenter} (see it for why the pair is `has` +
252
+ * `render` rather than a bare renderer) applied to the third zone: a mounted
253
+ * view's read-only indicators (a scene's live FPS tag, a streaming counter),
254
+ * registered through `useActionBar().setHud`. A layout that owns a readout
255
+ * area reads it here; `has()` is read INSIDE that layout's render, so a
256
+ * registration arriving after the first render still repaints the band, and a
257
+ * layout with no registration renders no empty band.
258
+ *
259
+ * `undefined` when nothing provides a bar: such a layout keeps its readout
260
+ * band ABSENT instead of mounting an always-empty one.
261
+ *
262
+ * Call in setup — it injects.
263
+ */
264
+ export function useActionBarHud(): ActionBarChannel | undefined {
265
+ const ctx = inject<ActionBarContext | null>(KEY, null);
266
+ if (!ctx) return undefined;
267
+ return {
268
+ has: () => ctx.hud.value !== null,
269
+ render: () => ctx.hud.value?.() ?? [],
270
+ };
271
+ }
272
+
224
273
  export function useActionBar() {
225
274
  const ctx = inject<ActionBarContext | null>(KEY, null);
226
275
  if (!ctx) {
@@ -237,6 +286,9 @@ export function useActionBar() {
237
286
  setFooterCenter: (_renderer: ActionBarRenderer) => {},
238
287
  clearFooterCenter: () => {},
239
288
  footerCenter: ref<ActionBarRenderer | null>(null),
289
+ setHud: (_renderer: ActionBarRenderer) => {},
290
+ clearHud: () => {},
291
+ hud: ref<ActionBarRenderer | null>(null),
240
292
  };
241
293
  }
242
294
  return {
@@ -292,5 +344,21 @@ export function useActionBar() {
292
344
  ctx.footerCenter.value = null;
293
345
  },
294
346
  footerCenter: ctx.footerCenter,
347
+ setHud: (renderer: ActionBarRenderer) => {
348
+ // Same per-scope lifetime as setCenter: the readout lives exactly as
349
+ // long as the view that shows it, and the identity guard keeps a
350
+ // leaving view's dispose from clearing a readout that already
351
+ // replaced it (the crossfade instant).
352
+ ctx.hud.value = renderer;
353
+ onScopeDispose(() => {
354
+ if (ctx.hud.value === renderer) {
355
+ ctx.hud.value = null;
356
+ }
357
+ });
358
+ },
359
+ clearHud: () => {
360
+ ctx.hud.value = null;
361
+ },
362
+ hud: ctx.hud,
295
363
  };
296
364
  }
@@ -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.530 <dev>">
4
+ <meta name="hk-error-landing" content="v1 0.55.532 <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" />
package/src/index.ts CHANGED
@@ -740,12 +740,21 @@ export {
740
740
  } from "./components/HkMfaVerifyCard";
741
741
  export { usePageTitle, useRouteTitle } from "./composables/usePageTitle";
742
742
  export { provideActionBar, useActionBar, PageActionSlot, orderActionRegistrations } from "./composables/useActionBar";
743
- // The centre channel's LAYOUT-side read (a shell that relays the bar it
744
- // sits under, without owning one): exported so a bespoke layout hands its
745
- // header slot the same `center` payload HkFaceShell does instead of
746
- // re-deriving a second source for the zone.
747
- export { useActionBarCenter, useActionBarFooterCenter } from "./composables/useActionBar";
748
- export type { ActionBarRenderer, PageActionSlotValue, ActionBarRegistration } from "./composables/useActionBar";
743
+ // The other zones' LAYOUT-side reads (a shell or face that relays the bar
744
+ // it sits under, without owning one): exported so a bespoke layout renders
745
+ // the zones from the same source a shipped layout does instead of
746
+ // re-deriving them — the header centre, the footer centre, and the hud.
747
+ export {
748
+ useActionBarCenter,
749
+ useActionBarFooterCenter,
750
+ useActionBarHud,
751
+ } from "./composables/useActionBar";
752
+ export type {
753
+ ActionBarRenderer,
754
+ ActionBarChannel,
755
+ PageActionSlotValue,
756
+ ActionBarRegistration,
757
+ } from "./composables/useActionBar";
749
758
  export { useChromeActionSize } from "./composables/useChromeActionSize";
750
759
  // The page-level helpers that make a view page-chrome-compliant
751
760
  // (design/page-chrome.md): each registers ONE purpose-declared slot of the
@@ -0,0 +1 @@
1
+ cdbbeba1943b0d79c1fe38dea2f057ba5c348612aca216f4fcec13e1eaed663b
@@ -0,0 +1 @@
1
+ e4a3c4f5798e83106c0310d1177fe0d2cc8c999421bac6d9a9d0b164b018821a
@@ -0,0 +1 @@
1
+ 4047e91066b919d2ed69ab904538e205443c29bb9a04315bf23d48697bfb1103
@@ -0,0 +1 @@
1
+ aadec82eb0d97c2877ce6cca6e0354df07982173e4faa894c399860aeb025894