@celestia-island/hikari 0.55.529 → 0.55.531
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/types/composables/useActionBar.d.ts +50 -7
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/HkFaceShell.hud.test.tsx +201 -0
- package/src/components/HkInput.scss +15 -7
- package/src/composables/useActionBar.test.ts +274 -2
- package/src/composables/useActionBar.ts +75 -7
- package/src/errorLandingStandalone/error-landing.html +1 -1
- package/src/index.ts +15 -6
- package/src/styles/admin-tokens.scss +8 -2
- package/src/styles/inputAutofillFreeze.contract.test.ts +176 -0
- package/src/theme/_field.scss +9 -6
- package/src/wasm/highlight/inputs.sha256 +1 -0
- package/src/wasm/mermaid/inputs.sha256 +1 -0
- package/src/wasm/qr/inputs.sha256 +1 -0
- package/src/wasm/scene3d/inputs.sha256 +1 -0
|
@@ -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
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
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
|
-
|
|
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
|
|
157
|
-
*
|
|
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():
|
|
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 {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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
|
@@ -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
|
+
});
|
|
@@ -290,13 +290,17 @@
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
/* Autofill overrides */
|
|
293
|
-
/* The
|
|
293
|
+
/* The frozen autofill transition lives ONLY inside the autofill states.
|
|
294
|
+
An earlier revision hung it on every field (the "fidelity" port moved it
|
|
295
|
+
out of this block): a 100000000s step-end transition never completes, so
|
|
296
|
+
the field's painted `color` stayed at the PREVIOUS theme's value after a
|
|
297
|
+
theme switch — black text on the freshly dark surface, for the typed
|
|
298
|
+
value and the native placeholder alike (::placeholder inherits this
|
|
299
|
+
color). Scoped to the autofill states it still pins Chrome's own
|
|
300
|
+
autofill/preview paint for exactly as long as that paint exists, while
|
|
301
|
+
an ordinary field follows the theme instantly.
|
|
302
|
+
The finite duration (instead of `calc(infinity * 1s)`) keeps this sheet
|
|
294
303
|
compilable by the grass compiler the Rust form shares it with. */
|
|
295
|
-
.hk-input-box input,
|
|
296
|
-
.hk-input-box textarea {
|
|
297
|
-
transition: color 100000000s step-end, background-color 100000000s step-end;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
304
|
.hk-input-box input:-webkit-autofill,
|
|
301
305
|
.hk-input-box input:-webkit-autofill:hover,
|
|
302
306
|
.hk-input-box input:-webkit-autofill:focus,
|
|
@@ -307,6 +311,7 @@
|
|
|
307
311
|
-webkit-text-fill-color: rgb(var(--color-text)) !important;
|
|
308
312
|
-webkit-box-shadow: 0 0 0 1000px rgb(var(--color-surface)) inset !important;
|
|
309
313
|
caret-color: rgb(var(--color-text));
|
|
314
|
+
transition: color 100000000s step-end, background-color 100000000s step-end;
|
|
310
315
|
}
|
|
311
316
|
|
|
312
317
|
.hk-input-box input:-webkit-autofill::first-line,
|
|
@@ -317,10 +322,13 @@
|
|
|
317
322
|
}
|
|
318
323
|
|
|
319
324
|
.hk-input-box input:-internal-autofill-previewed,
|
|
320
|
-
.hk-input-box input:-internal-autofill-selected
|
|
325
|
+
.hk-input-box input:-internal-autofill-selected,
|
|
326
|
+
.hk-input-box textarea:-internal-autofill-previewed,
|
|
327
|
+
.hk-input-box textarea:-internal-autofill-selected {
|
|
321
328
|
-webkit-text-fill-color: rgb(var(--color-text)) !important;
|
|
322
329
|
-webkit-box-shadow: 0 0 0 1000px rgb(var(--color-surface)) inset !important;
|
|
323
330
|
caret-color: rgb(var(--color-text));
|
|
331
|
+
transition: color 100000000s step-end, background-color 100000000s step-end;
|
|
324
332
|
}
|
|
325
333
|
|
|
326
334
|
/* The password variant's right-edge affordance (hold-to-reveal eye /
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
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
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
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
|
-
|
|
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
|
|
209
|
-
*
|
|
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():
|
|
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.
|
|
4
|
+
<meta name="hk-error-landing" content="v1 0.55.531 <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
|
|
744
|
-
// sits under, without owning one): exported so a bespoke layout
|
|
745
|
-
//
|
|
746
|
-
// re-deriving
|
|
747
|
-
export {
|
|
748
|
-
|
|
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
|
|
@@ -1274,7 +1274,6 @@
|
|
|
1274
1274
|
}
|
|
1275
1275
|
|
|
1276
1276
|
.s-auth-card input:not(.hk-otp-cell) {
|
|
1277
|
-
transition: color 100000000s step-end, background-color 100000000s step-end;
|
|
1278
1277
|
appearance: none;
|
|
1279
1278
|
-webkit-appearance: none;
|
|
1280
1279
|
/* 0 radius here was always a visual no-op: the auth card's inputs are
|
|
@@ -1285,13 +1284,20 @@
|
|
|
1285
1284
|
border-radius: 0;
|
|
1286
1285
|
}
|
|
1287
1286
|
|
|
1287
|
+
/* The frozen autofill transition lives ONLY inside the autofill states
|
|
1288
|
+
(same contract as HkInput.scss): hung on every field it pins the
|
|
1289
|
+
painted color at the previous theme's value forever — black text on a
|
|
1290
|
+
freshly dark surface after one theme switch. */
|
|
1288
1291
|
.s-auth-card input:-webkit-autofill,
|
|
1289
1292
|
.s-auth-card input:-webkit-autofill:hover,
|
|
1290
1293
|
.s-auth-card input:-webkit-autofill:focus,
|
|
1291
|
-
.s-auth-card input:-webkit-autofill:active
|
|
1294
|
+
.s-auth-card input:-webkit-autofill:active,
|
|
1295
|
+
.s-auth-card input:-internal-autofill-previewed,
|
|
1296
|
+
.s-auth-card input:-internal-autofill-selected {
|
|
1292
1297
|
-webkit-text-fill-color: var(--hi-color-text-primary, #333) !important;
|
|
1293
1298
|
-webkit-box-shadow: 0 0 0 1000px var(--hi-color-surface, #fff) inset !important;
|
|
1294
1299
|
caret-color: var(--hi-color-text-primary, #333);
|
|
1300
|
+
transition: color 100000000s step-end, background-color 100000000s step-end;
|
|
1295
1301
|
}
|
|
1296
1302
|
|
|
1297
1303
|
.s-auth-card input:-webkit-autofill::first-line {
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { readdirSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
import { compile, compileString } from "sass";
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Autofill-freeze containment contract (family-wide input readability).
|
|
10
|
+
*
|
|
11
|
+
* Chrome's autofill paint is pinned back with a frozen transition
|
|
12
|
+
* (`color`/`background-color` at 100000000s step-end — the transition
|
|
13
|
+
* never completes, so the painted value stays wherever it was). That trick
|
|
14
|
+
* is ONLY sound inside an autofill state: hung on a field's base state it
|
|
15
|
+
* also freezes every THEME-driven color change, so one light→dark switch
|
|
16
|
+
* left every input painting black text (typed value and native placeholder
|
|
17
|
+
* alike — ::placeholder inherits `color`) on the freshly dark surface.
|
|
18
|
+
* That regression shipped once (the "fidelity" port moved the freeze out
|
|
19
|
+
* of the autofill block) and blackened every login field in the family.
|
|
20
|
+
*
|
|
21
|
+
* Mutation anchors for the two claims above:
|
|
22
|
+
* MUT:freeze-leak — re-hanging the freeze on a base-state selector flips
|
|
23
|
+
* the sweep and the HkInput/admin-tokens/mixin pins red (verified: the
|
|
24
|
+
* historical shape turns `2 failed | 4 passed`);
|
|
25
|
+
* MUT:autofill-anchor-lost — dropping the freeze from an autofill block
|
|
26
|
+
* turns the positive anchors red (`1 failed | 5 passed`);
|
|
27
|
+
* MUT:mixin-base-leak — the emitted mixin growing an unscoped base rule
|
|
28
|
+
* turns the wrapper pin red (`1 failed | 5 passed`).
|
|
29
|
+
*
|
|
30
|
+
* This pin walks the leaf rules of every sheet that carries the freeze and
|
|
31
|
+
* fails the build if any freeze appears outside an autofill selector —
|
|
32
|
+
* and, positively, that the autofill blocks still carry it (the anti-flash
|
|
33
|
+
* behavior must survive alongside the containment).
|
|
34
|
+
*/
|
|
35
|
+
const stylesDir = dirname(fileURLToPath(import.meta.url));
|
|
36
|
+
const srcDir = resolve(stylesDir, "..");
|
|
37
|
+
|
|
38
|
+
/** Every spelling the freeze has ever shipped as (the `1e8s` form is the
|
|
39
|
+
* same duration minified — guard both). */
|
|
40
|
+
const FREEZE_SPELLINGS = ["100000000s", "1e8s"];
|
|
41
|
+
|
|
42
|
+
/** A rule body counts as "frozen" when it carries the freeze duration on a
|
|
43
|
+
* color/background transition. */
|
|
44
|
+
function isFrozen(body: string): boolean {
|
|
45
|
+
return FREEZE_SPELLINGS.some((spelling) => body.includes(spelling));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The autofill STATES the freeze is allowed to live in — pseudo-class
|
|
49
|
+
* forms, not a bare substring (a class that merely contains the word
|
|
50
|
+
* "autofill", like `.promo-autofill-note`, must NOT pass). */
|
|
51
|
+
const AUTOFILL_STATE = /:(-webkit-autofill|-internal-autofill-previewed|-internal-autofill-selected)/i;
|
|
52
|
+
|
|
53
|
+
interface LeafRule {
|
|
54
|
+
selector: string;
|
|
55
|
+
body: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Flatten compiled CSS into leaf rules (bodies without braces). */
|
|
59
|
+
function leafRules(css: string): LeafRule[] {
|
|
60
|
+
const withoutComments = css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
61
|
+
const leaves: LeafRule[] = [];
|
|
62
|
+
const selectors: string[] = [];
|
|
63
|
+
let buf = "";
|
|
64
|
+
for (const ch of withoutComments) {
|
|
65
|
+
if (ch === "{") {
|
|
66
|
+
selectors.push(buf.trim());
|
|
67
|
+
buf = "";
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (ch === "}") {
|
|
71
|
+
const selector = selectors.pop() ?? "";
|
|
72
|
+
if (!selector.startsWith("@") && !buf.includes("{") && buf.trim().length > 0) {
|
|
73
|
+
leaves.push({ selector, body: buf.trim() });
|
|
74
|
+
}
|
|
75
|
+
buf = "";
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
buf += ch;
|
|
79
|
+
}
|
|
80
|
+
return leaves;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function sheetRules(relativePath: string): LeafRule[] {
|
|
84
|
+
const file = resolve(srcDir, relativePath);
|
|
85
|
+
return leafRules(compile(file, { style: "expanded" }).css);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The containment sweep: a freeze may only ride an autofill-state selector. */
|
|
89
|
+
function expectFreezeContained(rules: LeafRule[], label: string, requireFreeze = true): void {
|
|
90
|
+
const frozen = rules.filter((rule) => isFrozen(rule.body));
|
|
91
|
+
if (requireFreeze) {
|
|
92
|
+
expect(frozen.length, `${label}: the autofill freeze rules exist`).toBeGreaterThan(0);
|
|
93
|
+
}
|
|
94
|
+
for (const rule of frozen) {
|
|
95
|
+
expect(
|
|
96
|
+
rule.selector,
|
|
97
|
+
`${label}: freeze outside an autofill state leaks into ${JSON.stringify(rule.selector)}`,
|
|
98
|
+
).toMatch(AUTOFILL_STATE);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The positive anchor: an autofill block still carries the freeze. */
|
|
103
|
+
function expectAutofillFreeze(rules: LeafRule[], selectorFragment: string, label: string): void {
|
|
104
|
+
const hit = rules.find(
|
|
105
|
+
(rule) => rule.selector.toLowerCase().includes(selectorFragment) && isFrozen(rule.body),
|
|
106
|
+
);
|
|
107
|
+
expect(hit, `${label}: no autofill rule ${selectorFragment} carries the freeze`).toBeDefined();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Every component + style sheet that could carry an input — the sweep is a
|
|
111
|
+
* directory cursor, not a hand list, so a NEW sheet with the freeze is
|
|
112
|
+
* scanned too (mirrors of these sheets are byte-guarded separately by
|
|
113
|
+
* vue_mirror_drift_tests.rs). */
|
|
114
|
+
function sweptSheets(): string[] {
|
|
115
|
+
const sheets: string[] = [];
|
|
116
|
+
for (const dir of ["components", "styles"]) {
|
|
117
|
+
for (const entry of readdirSync(resolve(srcDir, dir))) {
|
|
118
|
+
if (entry.endsWith(".scss") && !entry.startsWith("_")) {
|
|
119
|
+
sheets.push(`${dir}/${entry}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return sheets;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
describe("input autofill freeze containment", () => {
|
|
127
|
+
// The sweep compiles ~40 small sheets; keep the shared parse one-shot.
|
|
128
|
+
const swept = new Map(sweptSheets().map((sheet) => [sheet, sheetRules(sheet)]));
|
|
129
|
+
|
|
130
|
+
it("no sheet carries the freeze outside an autofill state", () => {
|
|
131
|
+
for (const [sheet, rules] of swept) {
|
|
132
|
+
expectFreezeContained(rules, sheet, false);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("HkInput.scss keeps the freeze inside the autofill states", () => {
|
|
137
|
+
const rules = swept.get("components/HkInput.scss")!;
|
|
138
|
+
expectFreezeContained(rules, "HkInput");
|
|
139
|
+
expectAutofillFreeze(rules, "hk-input-box input:-webkit-autofill", "HkInput");
|
|
140
|
+
// The historical bug shape: the BASE field selector must not exist
|
|
141
|
+
// carrying a transition at all.
|
|
142
|
+
const base = rules.find((rule) => rule.selector.replace(/\s+/g, " ") === ".hk-input-box input, .hk-input-box textarea");
|
|
143
|
+
expect(base, "the unscoped base-field rule must stay deleted").toBeUndefined();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("admin-tokens.scss keeps the auth-card freeze inside the autofill states", () => {
|
|
147
|
+
const rules = swept.get("styles/admin-tokens.scss")!;
|
|
148
|
+
expectFreezeContained(rules, "admin-tokens");
|
|
149
|
+
expectAutofillFreeze(rules, "s-auth-card input:-webkit-autofill", "admin-tokens");
|
|
150
|
+
const base = rules.find((rule) => rule.selector.replace(/\s+/g, " ") === ".s-auth-card input:not(.hk-otp-cell)");
|
|
151
|
+
expect(base, "the auth-card base input rule exists").toBeDefined();
|
|
152
|
+
expect(isFrozen(base!.body), "the auth-card base input rule must not freeze").toBe(false);
|
|
153
|
+
expect(base!.body).not.toContain("transition:");
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("HkPasswordSurface.scss keeps the freeze scoped (already-correct shape, pinned)", () => {
|
|
157
|
+
expectFreezeContained(swept.get("components/HkPasswordSurface.scss")!, "HkPasswordSurface");
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("HkOtpInput.scss keeps the freeze scoped", () => {
|
|
161
|
+
// The OTP sheet pins autofill with a plain background override and
|
|
162
|
+
// carries no frozen transition today; the sweep only guards against
|
|
163
|
+
// one being introduced outside an autofill state.
|
|
164
|
+
expectFreezeContained(swept.get("components/HkOtpInput.scss")!, "HkOtpInput", false);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("field-autofill-overrides mixin emits the freeze only in autofill states", () => {
|
|
168
|
+
const wrapper = `@use "theme/field" as field;\n@include field.field-autofill-overrides("fx-box");\n`;
|
|
169
|
+
const css = compileString(wrapper, { loadPaths: [srcDir] }).css;
|
|
170
|
+
const rules = leafRules(css);
|
|
171
|
+
expectFreezeContained(rules, "field mixin");
|
|
172
|
+
expectAutofillFreeze(rules, "fx-box input:-webkit-autofill", "field mixin");
|
|
173
|
+
const base = rules.find((rule) => rule.selector.replace(/\s+/g, " ") === ".fx-box input, .fx-box textarea");
|
|
174
|
+
expect(base, "the mixin must not emit an unscoped base-field rule").toBeUndefined();
|
|
175
|
+
});
|
|
176
|
+
});
|
package/src/theme/_field.scss
CHANGED
|
@@ -85,11 +85,10 @@
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
@mixin field-autofill-overrides($box-class) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
/* The frozen autofill transition lives ONLY inside the autofill states
|
|
89
|
+
(same contract as HkInput.scss): an unscoped copy pins the field's
|
|
90
|
+
painted color at the previous theme's value forever, so one theme
|
|
91
|
+
switch paints black text on the new dark surface. */
|
|
93
92
|
.#{$box-class} input:-webkit-autofill,
|
|
94
93
|
.#{$box-class} input:-webkit-autofill:hover,
|
|
95
94
|
.#{$box-class} input:-webkit-autofill:focus,
|
|
@@ -100,6 +99,7 @@
|
|
|
100
99
|
-webkit-text-fill-color: rgb(var(--color-text)) !important;
|
|
101
100
|
-webkit-box-shadow: 0 0 0 1000px rgb(var(--color-surface)) inset !important;
|
|
102
101
|
caret-color: rgb(var(--color-text));
|
|
102
|
+
transition: color 100000000s step-end, background-color 100000000s step-end;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
.#{$box-class} input:-webkit-autofill::first-line,
|
|
@@ -110,9 +110,12 @@
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
.#{$box-class} input:-internal-autofill-previewed,
|
|
113
|
-
.#{$box-class} input:-internal-autofill-selected
|
|
113
|
+
.#{$box-class} input:-internal-autofill-selected,
|
|
114
|
+
.#{$box-class} textarea:-internal-autofill-previewed,
|
|
115
|
+
.#{$box-class} textarea:-internal-autofill-selected {
|
|
114
116
|
-webkit-text-fill-color: rgb(var(--color-text)) !important;
|
|
115
117
|
-webkit-box-shadow: 0 0 0 1000px rgb(var(--color-surface)) inset !important;
|
|
116
118
|
caret-color: rgb(var(--color-text));
|
|
119
|
+
transition: color 100000000s step-end, background-color 100000000s step-end;
|
|
117
120
|
}
|
|
118
121
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cdbbeba1943b0d79c1fe38dea2f057ba5c348612aca216f4fcec13e1eaed663b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
e4a3c4f5798e83106c0310d1177fe0d2cc8c999421bac6d9a9d0b164b018821a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4047e91066b919d2ed69ab904538e205443c29bb9a04315bf23d48697bfb1103
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aadec82eb0d97c2877ce6cca6e0354df07982173e4faa894c399860aeb025894
|