@celestia-island/hikari 0.55.441 → 0.55.445
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/HkAdminHeader.tsx +12 -14
- package/src/components/HkAdminShell.tsx +9 -3
- package/src/components/HkAvatar.test.tsx +107 -0
- package/src/components/HkAvatar.tsx +8 -2
- package/src/components/HkAvatarButton.test.tsx +69 -0
- package/src/components/HkAvatarButton.tsx +7 -10
- package/src/components/HkDebugFloat.scss +21 -0
- package/src/components/HkDebugFloat.test.tsx +95 -0
- package/src/components/HkDebugFloat.tsx +54 -12
- package/src/components/HkDeleteGateWindow.test.ts +22 -9
- package/src/components/HkMenuIdentityItem.test.tsx +88 -0
- package/src/components/HkMenuIdentityItem.tsx +11 -2
- package/src/components/HkThemeToggle.test.ts +5 -2
- package/src/components/avatarImage.ts +50 -0
- package/src/composables/useActionBar.test.ts +303 -0
- package/src/composables/useActionBar.ts +164 -21
- package/src/index.ts +2 -2
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { computed, defineComponent, ref,
|
|
1
|
+
import { computed, defineComponent, ref, type PropType, type Ref, type SlotsType, type VNode } from "vue";
|
|
2
2
|
import { Camera, ExternalLink, Languages, LogOut, Menu } from "lucide-vue-next";
|
|
3
3
|
import { HBadge, HButton, HSpinner } from "@celestia-island/hikari";
|
|
4
4
|
import { useI18n } from "../i18n/context";
|
|
5
5
|
import { CHROME_BAND_DRAG_REGION } from "../runtime/windowChrome";
|
|
6
6
|
import HkMenu, { type HkMenuItem } from "./HkMenu";
|
|
7
7
|
import { HkAvatarButton } from "./HkAvatarButton";
|
|
8
|
+
import { useAvatarImage } from "./avatarImage";
|
|
8
9
|
|
|
9
10
|
export interface LocaleOption {
|
|
10
11
|
code: string;
|
|
@@ -154,6 +155,7 @@ export const HkAdminHeader = defineComponent({
|
|
|
154
155
|
},
|
|
155
156
|
setup(props, { emit, slots }) {
|
|
156
157
|
const { t } = useI18n();
|
|
158
|
+
const menuAvatar = useAvatarImage(() => props.avatarUrl);
|
|
157
159
|
const userMenuOpen = ref(false);
|
|
158
160
|
const userTriggerRef = ref<HTMLElement>();
|
|
159
161
|
const avatarModalOpen = ref(false);
|
|
@@ -162,16 +164,12 @@ export const HkAdminHeader = defineComponent({
|
|
|
162
164
|
// THIS popup instead of the built-in children cascade — anchored to
|
|
163
165
|
// the avatar trigger, so the popup opens exactly where the menu was.
|
|
164
166
|
const localePickerOpen = ref(false);
|
|
165
|
-
// The DROPDOWN identity image
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
watch(
|
|
172
|
-
() => props.avatarUrl,
|
|
173
|
-
() => { menuAvatarFailed.value = false; },
|
|
174
|
-
);
|
|
167
|
+
// The DROPDOWN identity image rides the SAME failed-load latch as the
|
|
168
|
+
// trigger (HkAvatarButton) and the avatar primitives — an avatar
|
|
169
|
+
// re-upload or account switch must heal BOTH faces, and one shared
|
|
170
|
+
// implementation is what keeps them from drifting (R2's S2 on #909
|
|
171
|
+
// was the missing reset; R2 on #1429 caught this fourth hand-rolled
|
|
172
|
+
// copy).
|
|
175
173
|
|
|
176
174
|
// The identity cluster is INJECTED, not assumed (2026-10-24): the
|
|
177
175
|
// trigger renders only when the host actually supplied an identity
|
|
@@ -384,12 +382,12 @@ export const HkAdminHeader = defineComponent({
|
|
|
384
382
|
// s-user-header profile variant).
|
|
385
383
|
<div class="s-user-header s-user-header--profile">
|
|
386
384
|
<span class="s-user-avatar-chip" aria-hidden="true">
|
|
387
|
-
{
|
|
385
|
+
{menuAvatar.src.value ? (
|
|
388
386
|
<img
|
|
389
|
-
src={
|
|
387
|
+
src={menuAvatar.src.value}
|
|
390
388
|
alt=""
|
|
391
389
|
class="s-user-avatar-img"
|
|
392
|
-
onError={
|
|
390
|
+
onError={menuAvatar.onError}
|
|
393
391
|
/>
|
|
394
392
|
) : (
|
|
395
393
|
<span class="s-user-avatar">
|
|
@@ -28,7 +28,11 @@ export type { PaddingSidesScan } from "./HkFaceShell";
|
|
|
28
28
|
* The one thing the wrapper ADDS is its own action-bar provide: hosts
|
|
29
29
|
* of the pre-extraction contract read the registered actions through
|
|
30
30
|
* the header slot's `actions` param (the bar this shell provides
|
|
31
|
-
* itself).
|
|
31
|
+
* itself). The param keeps its shape — a flat VNode[] of the current
|
|
32
|
+
* registrations — while the bar itself went ranked-additive
|
|
33
|
+
* (PageActionSlot / SLOT_RANK): the array now carries every registered
|
|
34
|
+
* affordance in slot order instead of the last single renderer's
|
|
35
|
+
* output. Faces that own their action bar — or their whole content
|
|
32
36
|
* lifecycle, like a canvas stage — consume HkFaceShell directly and
|
|
33
37
|
* provide whatever they want, closest to their pages.
|
|
34
38
|
*/
|
|
@@ -155,8 +159,10 @@ export const HkAdminShell = defineComponent({
|
|
|
155
159
|
...shellParams,
|
|
156
160
|
// The legacy channel this wrapper exists to keep: the
|
|
157
161
|
// actions of the bar provided above, handed to the header
|
|
158
|
-
// slot exactly as before the extraction
|
|
159
|
-
|
|
162
|
+
// slot exactly as before the extraction — still a flat
|
|
163
|
+
// VNode[] (now one entry per registered affordance, in
|
|
164
|
+
// slot order).
|
|
165
|
+
actions: actionBar.actions.value.flatMap((render) => render()),
|
|
160
166
|
})
|
|
161
167
|
: undefined,
|
|
162
168
|
sidebar: slots.sidebar,
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { createApp, defineComponent, h, nextTick, ref } from "vue";
|
|
3
|
+
|
|
4
|
+
import HkAvatar from "./HkAvatar";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* HkAvatar — the shared avatar primitive.
|
|
8
|
+
*
|
|
9
|
+
* The 2026-11-20 report: a member row whose stored `/static/avatars/…` URL
|
|
10
|
+
* had gone stale rendered the browser's broken-picture glyph instead of the
|
|
11
|
+
* default letter avatar. The primitive must treat "the URL 404s" exactly like
|
|
12
|
+
* "no URL was ever stored": same letter chip, same centred glyph. The latch
|
|
13
|
+
* is per-URL, so an account switch / fresh upload gets a real retry.
|
|
14
|
+
*
|
|
15
|
+
* (Repo test convention: raw createApp + container queries, no
|
|
16
|
+
* @vue/test-utils dependency.)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
|
|
20
|
+
|
|
21
|
+
function mount(node: ReturnType<typeof h>) {
|
|
22
|
+
const container = document.createElement("div");
|
|
23
|
+
document.body.appendChild(container);
|
|
24
|
+
const app = createApp({ render: () => node });
|
|
25
|
+
app.mount(container);
|
|
26
|
+
mounts.push({ app, container });
|
|
27
|
+
return container;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
for (const { app, container } of mounts.splice(0)) {
|
|
32
|
+
app.unmount();
|
|
33
|
+
container.remove();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("HkAvatar", () => {
|
|
38
|
+
it("renders the letter fallback when no src is given", () => {
|
|
39
|
+
const c = mount(h(HkAvatar, { name: "yuzu" }));
|
|
40
|
+
expect(c.querySelector(".hk-avatar-fallback")?.textContent).toBe("Y");
|
|
41
|
+
expect(c.querySelector("img")).toBeNull();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("renders the image with the name as alt", () => {
|
|
45
|
+
const c = mount(h(HkAvatar, { name: "yuzu", src: "/static/avatars/y.webp" }));
|
|
46
|
+
const img = c.querySelector("img") as HTMLImageElement | null;
|
|
47
|
+
expect(img).toBeTruthy();
|
|
48
|
+
expect(img!.getAttribute("src")).toBe("/static/avatars/y.webp");
|
|
49
|
+
expect(img!.getAttribute("alt")).toBe("yuzu");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("swaps a broken image for the SAME letter fallback instead of the broken-picture glyph", async () => {
|
|
53
|
+
const c = mount(h(HkAvatar, { name: "demiurge", src: "/static/avatars/gone.webp" }));
|
|
54
|
+
const img = c.querySelector("img") as HTMLImageElement;
|
|
55
|
+
expect(img).toBeTruthy();
|
|
56
|
+
img.dispatchEvent(new Event("error"));
|
|
57
|
+
await nextTick();
|
|
58
|
+
expect(c.querySelector("img"), "a 404 must not leave a broken <img>").toBeNull();
|
|
59
|
+
expect(c.querySelector(".hk-avatar-fallback")?.textContent).toBe("D");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("retries on the same instance when the src changes", async () => {
|
|
63
|
+
// A remount proves nothing (a fresh instance starts unlatched): the host
|
|
64
|
+
// re-renders the avatar with a new URL while it stays mounted, which is
|
|
65
|
+
// the account-switch / avatar-upload path.
|
|
66
|
+
const src = ref("/a.webp");
|
|
67
|
+
const Host = defineComponent({
|
|
68
|
+
setup: () => () => h(HkAvatar, { name: "yuzu", src: src.value }),
|
|
69
|
+
});
|
|
70
|
+
const c = mount(h(Host));
|
|
71
|
+
(c.querySelector("img") as HTMLImageElement).dispatchEvent(new Event("error"));
|
|
72
|
+
await nextTick();
|
|
73
|
+
expect(c.querySelector("img")).toBeNull();
|
|
74
|
+
|
|
75
|
+
src.value = "/b.webp";
|
|
76
|
+
await nextTick();
|
|
77
|
+
await nextTick();
|
|
78
|
+
const retry = c.querySelector("img") as HTMLImageElement | null;
|
|
79
|
+
expect(retry, "the latch reset — the new URL gets a fresh attempt").toBeTruthy();
|
|
80
|
+
expect(retry!.getAttribute("src")).toBe("/b.webp");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("renders the NORMALIZED src, not the raw prop", () => {
|
|
84
|
+
// Pins the BINDING (mirrors the other two call sites): a padded URL
|
|
85
|
+
// must reach the <img> trimmed. A revert to the raw prop renders the
|
|
86
|
+
// padded value and fails this test — a whitespace-ONLY input cannot
|
|
87
|
+
// discriminate, because the guard hides the <img> in both
|
|
88
|
+
// implementations.
|
|
89
|
+
const c = mount(h(HkAvatar, { name: "yuzu", src: " /a.webp " }));
|
|
90
|
+
const img = c.querySelector("img") as HTMLImageElement | null;
|
|
91
|
+
expect(img).toBeTruthy();
|
|
92
|
+
expect(img!.getAttribute("src")).toBe("/a.webp");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("treats a whitespace-only src as absent", () => {
|
|
96
|
+
// The shared latch normalizes the URL; master rendered `<img src=" ">`
|
|
97
|
+
// (a broken glyph) for a padded value.
|
|
98
|
+
const c = mount(h(HkAvatar, { name: "yuzu", src: " " }));
|
|
99
|
+
expect(c.querySelector("img")).toBeNull();
|
|
100
|
+
expect(c.querySelector(".hk-avatar-fallback")?.textContent).toBe("Y");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("falls back to ? when the name is absent", () => {
|
|
104
|
+
const c = mount(h(HkAvatar, {}));
|
|
105
|
+
expect(c.querySelector(".hk-avatar-fallback")?.textContent).toBe("?");
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed, defineComponent, type PropType } from "vue";
|
|
2
2
|
import { useI18n } from "../i18n/context";
|
|
3
|
+
import { useAvatarImage } from "./avatarImage";
|
|
3
4
|
import "./HkAvatar.scss";
|
|
4
5
|
|
|
5
6
|
export default defineComponent({
|
|
@@ -15,11 +16,16 @@ export default defineComponent({
|
|
|
15
16
|
"hk-avatar",
|
|
16
17
|
`hk-avatar-${props.size}`,
|
|
17
18
|
]);
|
|
19
|
+
// A stored URL is not a guarantee: the blob can 404 (deleted upload,
|
|
20
|
+
// external provider unreachable, mirror cold). The failed-load latch
|
|
21
|
+
// swaps the broken <img> for the SAME letter chip the absent-src branch
|
|
22
|
+
// renders, so the roster never shows a browser broken-picture glyph.
|
|
23
|
+
const avatar = useAvatarImage(() => props.src);
|
|
18
24
|
|
|
19
25
|
return () => (
|
|
20
26
|
<div class={cls.value}>
|
|
21
|
-
{
|
|
22
|
-
<img src={
|
|
27
|
+
{avatar.src.value ? (
|
|
28
|
+
<img src={avatar.src.value} alt={props.name} onError={avatar.onError} />
|
|
23
29
|
) : (
|
|
24
30
|
<span class="hk-avatar-fallback">{props.name?.charAt(0)?.toUpperCase() ?? t("hikari::avatar.fallback", "?")}</span>
|
|
25
31
|
)}
|
|
@@ -182,6 +182,75 @@ describe("HkAdminHeader × HkAvatarButton / identity slot", () => {
|
|
|
182
182
|
expect(c.querySelector(".s-admin-header-user")).toBeTruthy();
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
+
it("renders the NORMALIZED url in the dropdown identity image", () => {
|
|
186
|
+
// Pins the BINDING of the admin-header call site (R3 mutation D): a
|
|
187
|
+
// padded URL must reach the <img> trimmed; a raw-prop revert renders
|
|
188
|
+
// the padded value and fails this test.
|
|
189
|
+
const c = mount(h(HkAdminHeader, { username: "yuzu", avatarUrl: " /a.png ", title: "D" }));
|
|
190
|
+
trigger(c).dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
191
|
+
return Promise.resolve().then(async () => {
|
|
192
|
+
await nextTick();
|
|
193
|
+
await nextTick();
|
|
194
|
+
const img = document.body.querySelector(
|
|
195
|
+
".s-user-header--profile img.s-user-avatar-img",
|
|
196
|
+
) as HTMLImageElement | null;
|
|
197
|
+
expect(img).toBeTruthy();
|
|
198
|
+
expect(img!.getAttribute("src")).toBe("/a.png");
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("treats a whitespace-only avatarUrl as absent — the dropdown <img> never mounts", () => {
|
|
203
|
+
const c = mount(h(HkAdminHeader, { username: "yuzu", avatarUrl: " ", title: "D" }));
|
|
204
|
+
trigger(c).dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
205
|
+
return Promise.resolve().then(async () => {
|
|
206
|
+
await nextTick();
|
|
207
|
+
await nextTick();
|
|
208
|
+
expect(
|
|
209
|
+
document.body.querySelector(".s-user-header--profile img.s-user-avatar-img"),
|
|
210
|
+
).toBeNull();
|
|
211
|
+
expect(
|
|
212
|
+
document.body.querySelector(".s-user-header--profile .s-user-avatar")?.textContent,
|
|
213
|
+
).toBe("Y");
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("heals the dropdown identity image with the shared latch", async () => {
|
|
218
|
+
// The fourth copy R2 caught: HkAdminHeader's in-menu identity image
|
|
219
|
+
// used its own failed-load ref. It must behave exactly like the trigger
|
|
220
|
+
// — an error shows the letter chip, and a URL change retries on the
|
|
221
|
+
// SAME mounted header (account switch / avatar re-upload).
|
|
222
|
+
const url = ref("/a.png");
|
|
223
|
+
const Host = defineComponent({
|
|
224
|
+
setup: () => () => h(HkAdminHeader, { username: "yuzu", avatarUrl: url.value, title: "D" }),
|
|
225
|
+
});
|
|
226
|
+
const c = mount(h(Host));
|
|
227
|
+
trigger(c).dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
228
|
+
await nextTick();
|
|
229
|
+
await nextTick();
|
|
230
|
+
const first = document.body.querySelector(
|
|
231
|
+
".s-user-header--profile img.s-user-avatar-img",
|
|
232
|
+
) as HTMLImageElement | null;
|
|
233
|
+
expect(first, "the dropdown identity image renders").toBeTruthy();
|
|
234
|
+
first!.dispatchEvent(new Event("error"));
|
|
235
|
+
await nextTick();
|
|
236
|
+
expect(
|
|
237
|
+
document.body.querySelector(".s-user-header--profile img.s-user-avatar-img"),
|
|
238
|
+
"a broken identity image leaves the letter chip, not a broken glyph",
|
|
239
|
+
).toBeNull();
|
|
240
|
+
expect(
|
|
241
|
+
document.body.querySelector(".s-user-header--profile .s-user-avatar")?.textContent,
|
|
242
|
+
).toBe("Y");
|
|
243
|
+
|
|
244
|
+
url.value = "/b.png";
|
|
245
|
+
await nextTick();
|
|
246
|
+
await nextTick();
|
|
247
|
+
const retry = document.body.querySelector(
|
|
248
|
+
".s-user-header--profile img.s-user-avatar-img",
|
|
249
|
+
) as HTMLImageElement | null;
|
|
250
|
+
expect(retry, "the latch reset — the new URL gets a fresh attempt").toBeTruthy();
|
|
251
|
+
expect(retry!.getAttribute("src")).toBe("/b.png");
|
|
252
|
+
});
|
|
253
|
+
|
|
185
254
|
it("an identity slot replaces the built-in dropdown block; the pending branch stays built-in", async () => {
|
|
186
255
|
const opened = h(HkAdminHeader, {
|
|
187
256
|
username: "yuzu",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { defineComponent,
|
|
1
|
+
import { defineComponent, type PropType } from "vue";
|
|
2
|
+
import { useAvatarImage } from "./avatarImage";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* HkAvatarButton — the avatar trigger button, ONE component for every
|
|
@@ -40,13 +41,9 @@ export const HkAvatarButton = defineComponent({
|
|
|
40
41
|
click: (_e: MouseEvent) => true,
|
|
41
42
|
},
|
|
42
43
|
setup(props, { emit }) {
|
|
43
|
-
const avatarFailed = ref(false);
|
|
44
44
|
// A new URL deserves a fresh attempt (account switch, avatar upload)
|
|
45
|
-
// — the
|
|
46
|
-
|
|
47
|
-
() => props.avatarUrl,
|
|
48
|
-
() => { avatarFailed.value = false; },
|
|
49
|
-
);
|
|
45
|
+
// — the shared failed-load latch owns the reset (avatarImage.ts).
|
|
46
|
+
const avatar = useAvatarImage(() => props.avatarUrl);
|
|
50
47
|
|
|
51
48
|
return () => (
|
|
52
49
|
<button
|
|
@@ -56,12 +53,12 @@ export const HkAvatarButton = defineComponent({
|
|
|
56
53
|
aria-expanded={props.expanded}
|
|
57
54
|
onClick={(e: MouseEvent) => { emit("click", e); }}
|
|
58
55
|
>
|
|
59
|
-
{
|
|
56
|
+
{avatar.src.value ? (
|
|
60
57
|
<img
|
|
61
|
-
src={
|
|
58
|
+
src={avatar.src.value}
|
|
62
59
|
alt={props.username}
|
|
63
60
|
class="s-admin-header-avatar-img"
|
|
64
|
-
onError={
|
|
61
|
+
onError={avatar.onError}
|
|
65
62
|
/>
|
|
66
63
|
) : (
|
|
67
64
|
// Letter fallback on the shared avatar primitive — the same
|
|
@@ -46,6 +46,27 @@
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
/* ---------- click-through lock (host-driven `interactive={false}`) ---------- */
|
|
50
|
+
/* The window suspends every pointer affordance of its own — hover yield,
|
|
51
|
+
* drag, close, overlay reveal — and lets pointers fall through to the page
|
|
52
|
+
* it measures. Clicks outside the window already passed through; this makes
|
|
53
|
+
* the window itself pass through too. A subtree the host marks
|
|
54
|
+
* `data-hk-debug-float-pointer` re-enables pointer-events explicitly
|
|
55
|
+
* (descendants may re-enable under a none ancestor), so exactly the host's
|
|
56
|
+
* own unlock control stays live (the wowsp pin button). The locked visual is
|
|
57
|
+
* the host's: its content fades itself (a static lock, not a hover fade). */
|
|
58
|
+
.hk-debug-float[data-interactive="false"] {
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
|
|
61
|
+
& [data-el="fade"] {
|
|
62
|
+
transition: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
& [data-hk-debug-float-pointer] {
|
|
66
|
+
pointer-events: auto;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
49
70
|
/* ---------- the card (visual chrome + the hover fade) ---------- */
|
|
50
71
|
.hk-debug-float [data-el="fade"] {
|
|
51
72
|
overflow: hidden;
|
|
@@ -440,6 +440,85 @@ describe("HkDebugFloat headerless chrome", () => {
|
|
|
440
440
|
});
|
|
441
441
|
});
|
|
442
442
|
|
|
443
|
+
describe("HkDebugFloat chrome ownership (closable / interactive)", () => {
|
|
444
|
+
it("drops the header close when closable is false", () => {
|
|
445
|
+
mount(() => h(HkDebugFloat, { closable: false }, () => "fps 60"));
|
|
446
|
+
const win = floatWindow()!;
|
|
447
|
+
expect(win.querySelector(".hk-debug-float-close")).toBeNull();
|
|
448
|
+
// The header itself stays: the title and the drag handle are chrome
|
|
449
|
+
// the host did not ask to surrender.
|
|
450
|
+
expect(win.querySelector("[data-el='header']")).toBeTruthy();
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
it("keeps the header close by default", () => {
|
|
454
|
+
mount(() => h(HkDebugFloat, null, () => "fps 60"));
|
|
455
|
+
expect(
|
|
456
|
+
floatWindow()!.querySelector("[data-el='header'] .hk-debug-float-close"),
|
|
457
|
+
).toBeTruthy();
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
it("drops the headerless close and its empty overlay when closable is false", () => {
|
|
461
|
+
mount(() => h(HkDebugFloat, { chrome: "none", closable: false }, () => "fps 60"));
|
|
462
|
+
const win = floatWindow()!;
|
|
463
|
+
// No close left to hold open → no empty hover chrome box either.
|
|
464
|
+
expect(win.querySelector("[data-el='overlay']")).toBeNull();
|
|
465
|
+
expect(win.querySelector(".hk-debug-float-close")).toBeNull();
|
|
466
|
+
expect(win.getAttribute("data-chrome")).toBe("none");
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
it("keeps the overlay when sections are set, even without a close", () => {
|
|
470
|
+
mount(() =>
|
|
471
|
+
h(HkDebugFloat, {
|
|
472
|
+
chrome: "none",
|
|
473
|
+
closable: false,
|
|
474
|
+
sections: [{ key: "timing", label: "timing" }],
|
|
475
|
+
}),
|
|
476
|
+
);
|
|
477
|
+
const overlay = floatWindow()!.querySelector("[data-el='overlay']");
|
|
478
|
+
expect(overlay).toBeTruthy();
|
|
479
|
+
expect(overlay!.querySelector("button.hk-debug-float-section")).toBeTruthy();
|
|
480
|
+
expect(overlay!.querySelector(".hk-debug-float-close")).toBeNull();
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
it("suspends hover yield and drag while interactive is false", async () => {
|
|
484
|
+
mount(() => h(HkDebugFloat, { chrome: "none", interactive: false }, () => "fps 60"));
|
|
485
|
+
const win = floatWindow()!;
|
|
486
|
+
expect(win.getAttribute("data-interactive")).toBe("");
|
|
487
|
+
dispatchMouse("pointerenter", win);
|
|
488
|
+
await nextTick();
|
|
489
|
+
expect(win.hasAttribute("data-hovered")).toBe(false);
|
|
490
|
+
dispatchMouse("pointerdown", win, { clientX: 100, clientY: 100, button: 0, buttons: 1 });
|
|
491
|
+
await nextTick();
|
|
492
|
+
expect(win.hasAttribute("data-dragging")).toBe(false);
|
|
493
|
+
expect(win.style.left).toBe("");
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
it("drops the yielded state when the lock engages mid-hover", async () => {
|
|
497
|
+
const interactive = ref(true);
|
|
498
|
+
mount(() =>
|
|
499
|
+
h(HkDebugFloat, { chrome: "none", interactive: interactive.value }, () => "fps 60"),
|
|
500
|
+
);
|
|
501
|
+
const win = floatWindow()!;
|
|
502
|
+
dispatchMouse("pointerenter", win);
|
|
503
|
+
await nextTick();
|
|
504
|
+
expect(win.hasAttribute("data-hovered")).toBe(true);
|
|
505
|
+
interactive.value = false;
|
|
506
|
+
await nextTick();
|
|
507
|
+
expect(win.hasAttribute("data-hovered")).toBe(false);
|
|
508
|
+
expect(win.getAttribute("data-interactive")).toBe("");
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it("keeps a host-marked unlock control addressable while locked", () => {
|
|
512
|
+
mount(() =>
|
|
513
|
+
h(HkDebugFloat, { chrome: "none", interactive: false }, () =>
|
|
514
|
+
h("button", { "data-hk-debug-float-pointer": "", class: "pin" }, "pin"),
|
|
515
|
+
),
|
|
516
|
+
);
|
|
517
|
+
const pin = floatWindow()!.querySelector("button.pin")!;
|
|
518
|
+
expect(pin.hasAttribute("data-hk-debug-float-pointer")).toBe(true);
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
|
|
443
522
|
describe("HkDebugFloat width", () => {
|
|
444
523
|
it("marks the auto seat and drops the inline px width", () => {
|
|
445
524
|
mount(() => h(HkDebugFloat, { width: "auto" }));
|
|
@@ -787,6 +866,22 @@ describe("HkDebugFloat stylesheet contract", () => {
|
|
|
787
866
|
);
|
|
788
867
|
});
|
|
789
868
|
|
|
869
|
+
it("locks the window out of the pointer layer when non-interactive", () => {
|
|
870
|
+
// interactive={false}: the whole window stops taking pointers, and a
|
|
871
|
+
// host-marked subtree re-enables hit testing explicitly so exactly
|
|
872
|
+
// one control (the unlock affordance) stays live.
|
|
873
|
+
expect(css).toMatch(
|
|
874
|
+
/\.hk-debug-float\[data-interactive=false\]\s*\{\s*pointer-events:\s*none;/,
|
|
875
|
+
);
|
|
876
|
+
expect(css).toMatch(
|
|
877
|
+
/\.hk-debug-float\[data-interactive=false\] \[data-hk-debug-float-pointer\]\s*\{\s*pointer-events:\s*auto;/,
|
|
878
|
+
);
|
|
879
|
+
// The lock is static — a click-through window has no hover to fade on.
|
|
880
|
+
expect(css).toMatch(
|
|
881
|
+
/\.hk-debug-float\[data-interactive=false\] \[data-el=fade\]\s*\{\s*transition:\s*none;/,
|
|
882
|
+
);
|
|
883
|
+
});
|
|
884
|
+
|
|
790
885
|
it("keeps the hover chrome out of the fading card and click-transparent until revealed", () => {
|
|
791
886
|
// Structure: the overlay is a sibling of the card, never inside it —
|
|
792
887
|
// a nested overlay would fade (and unclickable) with the content.
|
|
@@ -57,7 +57,18 @@
|
|
|
57
57
|
* - **Close (×)** emits `update:open` (v-model:open) and persists the
|
|
58
58
|
* closed state. With `persistKey` set, open-state, dragged position
|
|
59
59
|
* and hidden sections round-trip via localStorage under
|
|
60
|
-
* `hk-debug-float:<key>`; reopening restores them.
|
|
60
|
+
* `hk-debug-float:<key>`; reopening restores them. `closable={false}`
|
|
61
|
+
* drops the in-window close entirely (header × and the headerless
|
|
62
|
+
* hover close) for hosts that own their chrome — the wowsp perf HUD
|
|
63
|
+
* replaces it with a pin control and closes from its own content.
|
|
64
|
+
* - **Click-through lock (`interactive={false}`).** The window suspends
|
|
65
|
+
* every pointer affordance of its own — hover yield, drag, close,
|
|
66
|
+
* overlay reveal — and paints `pointer-events: none`, so pointers
|
|
67
|
+
* fall through to the page it measures. A subtree the host marks
|
|
68
|
+
* `data-hk-debug-float-pointer` keeps `pointer-events: auto`
|
|
69
|
+
* (descendants may re-enable under a none ancestor), so exactly the
|
|
70
|
+
* host's own unlock control stays live — the wowsp pin button. The
|
|
71
|
+
* host owns the locked visual (its content fades itself).
|
|
61
72
|
* - The window intercepts pointers ONLY on its own box (no backdrop,
|
|
62
73
|
* no inset-0 overlay) — clicks outside it always reach the page.
|
|
63
74
|
*/
|
|
@@ -118,6 +129,18 @@ export default defineComponent({
|
|
|
118
129
|
width: { type: [Number, String] as PropType<number | "auto">, default: 280 },
|
|
119
130
|
/** Opacity the window fades to while hovered, 0..1. */
|
|
120
131
|
hoverOpacity: { type: Number, default: 0.45 },
|
|
132
|
+
/** Whether the window renders its own close affordance — the header
|
|
133
|
+
* × or the headerless hover close. Hosts that own their chrome (the
|
|
134
|
+
* wowsp perf HUD replaces it with a pin control) pass false and
|
|
135
|
+
* close through v-model:open themselves. */
|
|
136
|
+
closable: { type: Boolean, default: true },
|
|
137
|
+
/** Interactive pointer mode. When false the window suspends ALL of
|
|
138
|
+
* its own pointer handling — hover yield, drag, close, overlay
|
|
139
|
+
* reveal — and paints pointer-events: none, letting pointers fall
|
|
140
|
+
* through to the page (a click-through HUD lock). Subtrees marked
|
|
141
|
+
* `data-hk-debug-float-pointer` keep pointer-events: auto so the
|
|
142
|
+
* host's own unlock control stays clickable. */
|
|
143
|
+
interactive: { type: Boolean, default: true },
|
|
121
144
|
/** Uncontrolled initial open state (superseded by any persisted one). */
|
|
122
145
|
defaultOpen: { type: Boolean, default: true },
|
|
123
146
|
/** When set: open-state + position (+ hidden sections) persist under
|
|
@@ -243,6 +266,7 @@ export default defineComponent({
|
|
|
243
266
|
function onDragPointerDown(e: PointerEvent): void {
|
|
244
267
|
// Primary button only; interactive chrome (close, section chips,
|
|
245
268
|
// producer content controls) keeps its own pointer semantics.
|
|
269
|
+
if (!props.interactive) return;
|
|
246
270
|
if (e.button !== 0) return;
|
|
247
271
|
if ((e.target as HTMLElement).closest("button, a, input, select, textarea")) return;
|
|
248
272
|
const el = windowEl.value;
|
|
@@ -297,6 +321,8 @@ export default defineComponent({
|
|
|
297
321
|
|
|
298
322
|
// -- hover → yield --
|
|
299
323
|
function onPointerEnter(): void {
|
|
324
|
+
// A locked (click-through) window has no hover affordance.
|
|
325
|
+
if (!props.interactive) return;
|
|
300
326
|
hovered.value = true;
|
|
301
327
|
}
|
|
302
328
|
|
|
@@ -304,6 +330,15 @@ export default defineComponent({
|
|
|
304
330
|
hovered.value = false;
|
|
305
331
|
}
|
|
306
332
|
|
|
333
|
+
// Locking mid-hover must drop the yielded state: the pointer leaves a
|
|
334
|
+
// click-through window without a leave event (it never received one).
|
|
335
|
+
watch(
|
|
336
|
+
() => props.interactive,
|
|
337
|
+
(interactive) => {
|
|
338
|
+
if (!interactive) hovered.value = false;
|
|
339
|
+
},
|
|
340
|
+
);
|
|
341
|
+
|
|
307
342
|
// A restored position clamps once the real box is measurable.
|
|
308
343
|
onMounted(() => {
|
|
309
344
|
void nextTick(reclampToViewport);
|
|
@@ -358,7 +393,11 @@ export default defineComponent({
|
|
|
358
393
|
onPointerup: endDrag,
|
|
359
394
|
onPointercancel: endDrag,
|
|
360
395
|
};
|
|
361
|
-
|
|
396
|
+
// The hover chrome renders only when it has something to hold: the
|
|
397
|
+
// section chips, or (headerless) the close — drop the empty box for
|
|
398
|
+
// a closable={false} HUD that carries no sections.
|
|
399
|
+
const hasSectionChips = (props.sections ?? []).length > 0;
|
|
400
|
+
const showOverlay = hasSectionChips || (!headered && props.closable);
|
|
362
401
|
return (
|
|
363
402
|
// Directly to <body> — NOT into #hk-overlay-root: this window
|
|
364
403
|
// is not a functional popup (no popup-manager band, no scroll
|
|
@@ -370,6 +409,7 @@ export default defineComponent({
|
|
|
370
409
|
class="hk-debug-float"
|
|
371
410
|
data-corner={props.position}
|
|
372
411
|
data-chrome={props.chrome}
|
|
412
|
+
data-interactive={props.interactive ? undefined : ""}
|
|
373
413
|
data-auto-width={props.width === "auto" ? "" : undefined}
|
|
374
414
|
data-hovered={hovered.value ? "" : undefined}
|
|
375
415
|
data-dragging={dragging.value ? "" : undefined}
|
|
@@ -386,15 +426,17 @@ export default defineComponent({
|
|
|
386
426
|
{headered && (
|
|
387
427
|
<div ref={headerEl} data-el="header" {...handleProps}>
|
|
388
428
|
<span data-el="title">{slots.title ? slots.title() : titleText.value}</span>
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
429
|
+
{props.closable && (
|
|
430
|
+
<HIconButton
|
|
431
|
+
class="hk-debug-float-close"
|
|
432
|
+
size={24}
|
|
433
|
+
variant="ghost"
|
|
434
|
+
aria-label={t("hikari::alert.close", "Close")}
|
|
435
|
+
onClick={() => setOpen(false)}
|
|
436
|
+
>
|
|
437
|
+
{{ icon: () => <X aria-hidden="true" /> }}
|
|
438
|
+
</HIconButton>
|
|
439
|
+
)}
|
|
398
440
|
</div>
|
|
399
441
|
)}
|
|
400
442
|
<div data-el="body">
|
|
@@ -432,7 +474,7 @@ export default defineComponent({
|
|
|
432
474
|
</button>
|
|
433
475
|
);
|
|
434
476
|
})}
|
|
435
|
-
{!headered && (
|
|
477
|
+
{!headered && props.closable && (
|
|
436
478
|
<HIconButton
|
|
437
479
|
class="hk-debug-float-close"
|
|
438
480
|
size={24}
|
|
@@ -95,6 +95,8 @@ describe("HkDeleteGateWindow", () => {
|
|
|
95
95
|
// and release: the window must emit confirm (the parent performs the
|
|
96
96
|
// delete) AND close itself (update:open=false). A short release must
|
|
97
97
|
// NOT close — it only emits cancel with the progress.
|
|
98
|
+
confirmSpy.mockClear();
|
|
99
|
+
cancelSpy.mockClear();
|
|
98
100
|
const onUpdate = vi.fn();
|
|
99
101
|
const c = mountWindow("<p>msg</p>", {
|
|
100
102
|
"onUpdate:open": onUpdate,
|
|
@@ -103,22 +105,33 @@ describe("HkDeleteGateWindow", () => {
|
|
|
103
105
|
onCancel: (p: number) => cancelSpy(p),
|
|
104
106
|
});
|
|
105
107
|
const el = c.querySelector(".hk-serpentine")!;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
// Fresh event objects per gesture: an Event instance is effectively
|
|
109
|
+
// single-use — re-dispatching the same object is engine-dependent (the
|
|
110
|
+
// CI runner ignores the second dispatch, so the walk below never
|
|
111
|
+
// started there and the confirm assertion saw zero calls).
|
|
112
|
+
const press = (clientX: number, clientY: number) =>
|
|
113
|
+
el.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, clientX, clientY, pointerId: 1 }));
|
|
114
|
+
const move = (clientX: number, clientY: number) =>
|
|
115
|
+
el.dispatchEvent(new PointerEvent("pointermove", { bubbles: true, clientX, clientY, pointerId: 1 }));
|
|
116
|
+
const release = (clientX: number, clientY: number) =>
|
|
117
|
+
el.dispatchEvent(new PointerEvent("pointerup", { bubbles: true, clientX, clientY, pointerId: 1 }));
|
|
118
|
+
|
|
119
|
+
press(24, 48);
|
|
108
120
|
// Mid-lane release: cancel only.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
el.dispatchEvent(up);
|
|
121
|
+
move(300, 48);
|
|
122
|
+
release(300, 48);
|
|
123
|
+
await nextTick();
|
|
113
124
|
expect(confirmSpy).not.toHaveBeenCalled();
|
|
114
125
|
expect(cancelSpy).toHaveBeenCalled();
|
|
115
126
|
expect(onUpdate).not.toHaveBeenCalled(); // stays open
|
|
116
127
|
// Re-open state is already open; a full walk then confirms and closes.
|
|
117
|
-
|
|
128
|
+
await nextTick();
|
|
129
|
+
press(24, 48);
|
|
118
130
|
for (let x = 30; x <= 600; x += 10) {
|
|
119
|
-
|
|
131
|
+
move(x, 48);
|
|
120
132
|
}
|
|
121
|
-
|
|
133
|
+
release(600, 48);
|
|
134
|
+
await nextTick();
|
|
122
135
|
expect(confirmSpy).toHaveBeenCalledTimes(1);
|
|
123
136
|
expect(onUpdate).toHaveBeenCalledWith(false);
|
|
124
137
|
});
|