@celestia-island/hikari 0.55.372 → 0.55.375

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.
Files changed (27) hide show
  1. package/package.json +1 -1
  2. package/src/components/HkDebugFloat.scss +105 -15
  3. package/src/components/HkDebugFloat.test.tsx +428 -19
  4. package/src/components/HkDebugFloat.tsx +197 -36
  5. package/src/components/HkEmergencyAlert.layering.contract.test.ts +23 -0
  6. package/src/components/HkEmergencyAlert.scss +22 -0
  7. package/src/components/HkEmergencyAlert.test.tsx +5 -0
  8. package/src/components/debugFloat.ts +24 -1
  9. package/src/composables/wasmHighlight.ts +20 -0
  10. package/src/index.ts +1 -0
  11. package/src/wasm/highlight/hikari_wasm_highlight.d.ts +21 -0
  12. package/src/wasm/highlight/hikari_wasm_highlight.js +6172 -0
  13. package/src/wasm/highlight/interfaces/hikari-highlight-types.d.ts +4 -0
  14. package/src/wasm/highlight/interfaces/wasi-cli-environment.d.ts +2 -0
  15. package/src/wasm/highlight/interfaces/wasi-cli-exit.d.ts +3 -0
  16. package/src/wasm/highlight/interfaces/wasi-cli-stderr.d.ts +3 -0
  17. package/src/wasm/highlight/interfaces/wasi-cli-stdin.d.ts +3 -0
  18. package/src/wasm/highlight/interfaces/wasi-cli-stdout.d.ts +3 -0
  19. package/src/wasm/highlight/interfaces/wasi-cli-terminal-input.d.ts +8 -0
  20. package/src/wasm/highlight/interfaces/wasi-cli-terminal-output.d.ts +8 -0
  21. package/src/wasm/highlight/interfaces/wasi-cli-terminal-stderr.d.ts +3 -0
  22. package/src/wasm/highlight/interfaces/wasi-cli-terminal-stdin.d.ts +3 -0
  23. package/src/wasm/highlight/interfaces/wasi-cli-terminal-stdout.d.ts +3 -0
  24. package/src/wasm/highlight/interfaces/wasi-clocks-monotonic-clock.d.ts +4 -0
  25. package/src/wasm/highlight/interfaces/wasi-io-error.d.ts +8 -0
  26. package/src/wasm/highlight/interfaces/wasi-io-poll.d.ts +10 -0
  27. package/src/wasm/highlight/interfaces/wasi-io-streams.d.ts +38 -0
@@ -12,6 +12,7 @@ import {
12
12
  clampDebugFloatPosition,
13
13
  debugFloatStorageKey,
14
14
  HK_DEBUG_FLOAT_DOCUMENT_Z,
15
+ readDebugFloatPersisted,
15
16
  } from "./debugFloat";
16
17
 
17
18
  const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
@@ -278,16 +279,21 @@ describe("HkDebugFloat drag", () => {
278
279
  expect(win.getBoundingClientRect().bottom).toBeLessThanOrEqual(window.innerHeight);
279
280
  });
280
281
 
281
- it("ignores non-primary-button grabs and pointerdowns on the close button", () => {
282
+ it("ignores non-primary-button grabs and pointerdowns on the close button", async () => {
282
283
  mount(() => h(HkDebugFloat));
283
284
  const win = floatWindow()!;
284
285
  const header = win.querySelector("[data-el='header']")!;
285
286
 
286
287
  dispatchMouse("pointerdown", header, { clientX: 100, clientY: 100, button: 2, buttons: 2 });
288
+ // Vue patches the DOM on a microtask — without the tick the
289
+ // assertion reads the PRE-drag DOM and passes vacuously even when a
290
+ // drag started.
291
+ await nextTick();
287
292
  expect(win.hasAttribute("data-dragging")).toBe(false);
288
293
 
289
294
  const close = win.querySelector("button.hk-icon-button")!;
290
295
  dispatchMouse("pointerdown", close, { clientX: 100, clientY: 100, button: 0, buttons: 1 });
296
+ await nextTick();
291
297
  expect(win.hasAttribute("data-dragging")).toBe(false);
292
298
  // The close button also never starts a drag position.
293
299
  expect(win.style.left).toBe("");
@@ -307,6 +313,39 @@ describe("HkDebugFloat drag", () => {
307
313
  });
308
314
  });
309
315
 
316
+ describe("readDebugFloatPersisted", () => {
317
+ it("parses a record that carries a hidden-section list", () => {
318
+ localStorage.setItem(
319
+ debugFloatStorageKey("unit-hidden"),
320
+ JSON.stringify({ open: true, x: 4, y: 5, hidden: ["gpu", "draws"] }),
321
+ );
322
+ expect(readDebugFloatPersisted("unit-hidden")).toEqual({
323
+ open: true,
324
+ x: 4,
325
+ y: 5,
326
+ hidden: ["gpu", "draws"],
327
+ });
328
+ });
329
+
330
+ it("rejects a non-array hidden list (corrupted payloads degrade to null)", () => {
331
+ localStorage.setItem(
332
+ debugFloatStorageKey("unit-bad-hidden"),
333
+ JSON.stringify({ open: true, hidden: "gpu" }),
334
+ );
335
+ expect(readDebugFloatPersisted("unit-bad-hidden")).toBeNull();
336
+ localStorage.setItem(
337
+ debugFloatStorageKey("unit-bad-hidden2"),
338
+ JSON.stringify({ open: true, hidden: ["gpu", 3] }),
339
+ );
340
+ expect(readDebugFloatPersisted("unit-bad-hidden2")).toBeNull();
341
+ });
342
+
343
+ it("accepts a record with no hidden half (older writers)", () => {
344
+ localStorage.setItem(debugFloatStorageKey("unit-legacy"), JSON.stringify({ open: false }));
345
+ expect(readDebugFloatPersisted("unit-legacy")).toEqual({ open: false });
346
+ });
347
+ });
348
+
310
349
  describe("clampDebugFloatPosition", () => {
311
350
  const VW = 1024;
312
351
  const VH = 768;
@@ -331,41 +370,357 @@ describe("clampDebugFloatPosition", () => {
331
370
  });
332
371
  });
333
372
 
373
+ describe("HkDebugFloat headerless chrome", () => {
374
+ function mountHeaderless(extra: Record<string, unknown> = {}) {
375
+ mount(() => h(HkDebugFloat, { chrome: "none", title: "PERF", ...extra }, () => "fps 60"));
376
+ return floatWindow()!;
377
+ }
378
+
379
+ it("renders no title bar and carries the chrome marker", () => {
380
+ const win = mountHeaderless();
381
+ expect(win.getAttribute("data-chrome")).toBe("none");
382
+ expect(win.querySelector("[data-el='header']")).toBeNull();
383
+ expect(win.querySelector("[data-el='title']")).toBeNull();
384
+ // The slot content still lands in the body.
385
+ expect(win.querySelector("[data-el='body']")!.textContent).toContain("fps 60");
386
+ });
387
+
388
+ it("keeps the title as the accessible name even without a header", () => {
389
+ const win = mountHeaderless();
390
+ expect(win.getAttribute("aria-label")).toBe("PERF");
391
+ expect(win.getAttribute("role")).toBe("group");
392
+ });
393
+
394
+ it("exposes the close button through the hover chrome overlay", () => {
395
+ const win = mountHeaderless();
396
+ const overlay = win.querySelector("[data-el='overlay']")!;
397
+ expect(overlay).toBeTruthy();
398
+ const close = overlay.querySelector("button.hk-debug-float-close")!;
399
+ expect(close).toBeTruthy();
400
+ expect(close.getAttribute("aria-label")).toBe("Close");
401
+ });
402
+
403
+ it("close hides the window and emits update:open false", async () => {
404
+ const emitted: boolean[] = [];
405
+ mount(() =>
406
+ h(HkDebugFloat, { chrome: "none", "onUpdate:open": (v: boolean) => emitted.push(v) }),
407
+ );
408
+ const close = floatWindow()!.querySelector("[data-el='overlay'] button") as HTMLButtonElement;
409
+ close.click();
410
+ expect(emitted).toEqual([false]);
411
+ await nextTick();
412
+ expect(floatWindow()).toBeNull();
413
+ });
414
+
415
+ it("drags from the whole window body — no header to grab", async () => {
416
+ mount(() => h(HkDebugFloat, { chrome: "none", width: "auto" }));
417
+ const win = floatWindow()!;
418
+ // A press on the window body itself (no [data-el='header'] exists).
419
+ dispatchMouse("pointerdown", win, { clientX: 100, clientY: 100, button: 0, buttons: 1 });
420
+ await nextTick();
421
+ expect(win.hasAttribute("data-dragging")).toBe(true);
422
+ dispatchMouse("pointermove", win, { clientX: 140, clientY: 120, buttons: 1 });
423
+ await nextTick();
424
+ expect(win.style.left).toBe("40px");
425
+ expect(win.style.top).toBe("20px");
426
+ dispatchMouse("pointerup", win);
427
+ await nextTick();
428
+ expect(win.hasAttribute("data-dragging")).toBe(false);
429
+ });
430
+
431
+ it("a press on the overlay's close button never starts a body drag", async () => {
432
+ mount(() => h(HkDebugFloat, { chrome: "none" }));
433
+ const win = floatWindow()!;
434
+ const close = win.querySelector("[data-el='overlay'] button")!;
435
+ dispatchMouse("pointerdown", close, { clientX: 100, clientY: 100, button: 0, buttons: 1 });
436
+ // Await the DOM flush so a (broken) drag start is actually visible.
437
+ await nextTick();
438
+ expect(win.hasAttribute("data-dragging")).toBe(false);
439
+ expect(win.style.left).toBe("");
440
+ });
441
+ });
442
+
443
+ describe("HkDebugFloat width", () => {
444
+ it("marks the auto seat and drops the inline px width", () => {
445
+ mount(() => h(HkDebugFloat, { width: "auto" }));
446
+ const win = floatWindow()!;
447
+ expect(win.getAttribute("data-auto-width")).toBe("");
448
+ expect(win.style.width).toBe("");
449
+ });
450
+
451
+ it("keeps the numeric seat inline (no auto marker)", () => {
452
+ mount(() => h(HkDebugFloat, { width: 320 }));
453
+ const win = floatWindow()!;
454
+ expect(win.hasAttribute("data-auto-width")).toBe(false);
455
+ expect(win.style.width).toBe("320px");
456
+ });
457
+ });
458
+
459
+ describe("HkDebugFloat sections", () => {
460
+ const SECTIONS = [
461
+ { key: "timing", label: "timing" },
462
+ { key: "draws", label: "draws" },
463
+ { key: "gpu", label: "gpu" },
464
+ ];
465
+
466
+ function mountSections(
467
+ propsExtra: Record<string, unknown> = {},
468
+ slots?: Record<string, () => ReturnType<typeof h>>,
469
+ ) {
470
+ mount(
471
+ () =>
472
+ h(
473
+ HkDebugFloat,
474
+ { sections: SECTIONS, chrome: "none", ...propsExtra },
475
+ slots ?? {
476
+ timing: () => h("div", null, "render 60 fps"),
477
+ draws: () => h("div", null, "draws 325"),
478
+ gpu: () => h("div", null, "ANGLE (Intel)"),
479
+ },
480
+ ),
481
+ );
482
+ return floatWindow()!;
483
+ }
484
+
485
+ function section(win: HTMLElement, key: string): HTMLElement | null {
486
+ return win.querySelector<HTMLElement>(`[data-el='section'][data-key='${key}']`);
487
+ }
488
+
489
+ it("renders each section through its same-named slot, in declared order", () => {
490
+ const win = mountSections();
491
+ const keys = [...win.querySelectorAll("[data-el='section']")].map(
492
+ (el) => el.getAttribute("data-key"),
493
+ );
494
+ expect(keys).toEqual(["timing", "draws", "gpu"]);
495
+ expect(section(win, "draws")!.textContent).toContain("draws 325");
496
+ // The plain default slot is not part of the sections contract.
497
+ expect(win.querySelector("[data-el='body']")!.textContent).not.toContain("unsectioned");
498
+ });
499
+
500
+ it("drops a section whose slot is missing instead of crashing", () => {
501
+ const win = mountSections(
502
+ {},
503
+ { timing: () => h("div", null, "render 60 fps"), gpu: () => h("div", null, "ANGLE") },
504
+ );
505
+ expect(section(win, "timing")).toBeTruthy();
506
+ expect(section(win, "draws")).toBeNull();
507
+ expect(section(win, "gpu")).toBeTruthy();
508
+ });
509
+
510
+ it("every section gets a toggle chip, pressed = visible", () => {
511
+ const win = mountSections();
512
+ for (const s of SECTIONS) {
513
+ const chip = win.querySelector<HTMLButtonElement>(`.hk-debug-float-section[data-key='${s.key}']`);
514
+ expect(chip, `chip for ${s.key}`).toBeTruthy();
515
+ expect(chip!.textContent).toBe(s.label);
516
+ expect(chip!.getAttribute("aria-pressed")).toBe("true");
517
+ }
518
+ });
519
+
520
+ it("toggling a chip hides that section (uncontrolled) and persists it", async () => {
521
+ const win = mountSections({ persistKey: "sections" });
522
+ const chip = win.querySelector<HTMLButtonElement>(
523
+ ".hk-debug-float-section[data-key='draws']",
524
+ )!;
525
+ chip.click();
526
+ await nextTick();
527
+ expect(section(floatWindow()!, "draws")).toBeNull();
528
+ expect(section(floatWindow()!, "timing")).toBeTruthy();
529
+ const raw = localStorage.getItem(debugFloatStorageKey("sections"));
530
+ expect(JSON.parse(raw!)).toEqual({ open: true, hidden: ["draws"] });
531
+ });
532
+
533
+ it("a remount restores the hidden set from the persisted record", () => {
534
+ localStorage.setItem(debugFloatStorageKey("restore-hidden"), JSON.stringify({
535
+ open: true,
536
+ hidden: ["gpu", "timing"],
537
+ }));
538
+ const win = mountSections({ persistKey: "restore-hidden" });
539
+ expect(section(win, "gpu")).toBeNull();
540
+ expect(section(win, "timing")).toBeNull();
541
+ expect(section(win, "draws")).toBeTruthy();
542
+ // The chip mirrors the persisted state.
543
+ expect(
544
+ win.querySelector<HTMLButtonElement>(".hk-debug-float-section[data-key='gpu']")!
545
+ .getAttribute("aria-pressed"),
546
+ ).toBe("false");
547
+ });
548
+
549
+ it("toggling back re-shows the section and clears the persisted list", async () => {
550
+ localStorage.setItem(
551
+ debugFloatStorageKey("toggle-back"),
552
+ JSON.stringify({ open: true, hidden: ["gpu"] }),
553
+ );
554
+ const win = mountSections({ persistKey: "toggle-back" });
555
+ const chip = win.querySelector<HTMLButtonElement>(".hk-debug-float-section[data-key='gpu']")!;
556
+ expect(chip.getAttribute("aria-pressed")).toBe("false");
557
+ chip.click();
558
+ await nextTick();
559
+ expect(section(floatWindow()!, "gpu")).toBeTruthy();
560
+ const raw = localStorage.getItem(debugFloatStorageKey("toggle-back"));
561
+ expect(JSON.parse(raw!)).toEqual({ open: true });
562
+ });
563
+
564
+ it("corrupted hidden lists degrade to all-visible instead of crashing", () => {
565
+ localStorage.setItem(
566
+ debugFloatStorageKey("corrupt-hidden"),
567
+ JSON.stringify({ open: true, hidden: "draws" }),
568
+ );
569
+ const win = mountSections({ persistKey: "corrupt-hidden" });
570
+ expect(section(win, "draws")).toBeTruthy();
571
+ expect(section(win, "gpu")).toBeTruthy();
572
+
573
+ // A NON-ARRAY hidden that slipped past the reader would throw at
574
+ // mount time (new Set(3) on a number) — the mount itself succeeding
575
+ // is part of the contract, so pin the numeric shape on a fresh
576
+ // record too (the new window is the LAST in document order).
577
+ localStorage.setItem(
578
+ debugFloatStorageKey("corrupt-hidden-2"),
579
+ JSON.stringify({ open: true, hidden: 3 }),
580
+ );
581
+ mountSections({ persistKey: "corrupt-hidden-2" });
582
+ const windows = document.querySelectorAll<HTMLElement>(".hk-debug-float");
583
+ const win2 = windows[windows.length - 1];
584
+ expect(section(win2, "draws")).toBeTruthy();
585
+ expect(section(win2, "timing")).toBeTruthy();
586
+ });
587
+
588
+ it("controlled visibleSections wins over the internal state and emits the next list", async () => {
589
+ const emitted: string[][] = [];
590
+ const win = mountSections(
591
+ {
592
+ visibleSections: ["timing", "gpu"],
593
+ "onUpdate:visibleSections": (keys: string[]) => emitted.push(keys),
594
+ },
595
+ );
596
+ // The prop is the visible list: draws never renders.
597
+ expect(section(win, "draws")).toBeNull();
598
+ expect(section(win, "timing")).toBeTruthy();
599
+ // Toggling the hidden one emits its RETURN, in sections order…
600
+ const chip = win.querySelector<HTMLButtonElement>(".hk-debug-float-section[data-key='draws']")!;
601
+ chip.click();
602
+ await nextTick();
603
+ expect(emitted).toEqual([["timing", "draws", "gpu"]]);
604
+ // …and the uncontrolled state/persistence stay untouched (the prop
605
+ // remains authoritative until the parent round-trips).
606
+ expect(section(win, "draws")).toBeNull();
607
+ // Toggling a visible one removes it from the emitted list.
608
+ win.querySelector<HTMLButtonElement>(".hk-debug-float-section[data-key='timing']")!.click();
609
+ await nextTick();
610
+ expect(emitted[1]).toEqual(["gpu"]);
611
+ });
612
+
613
+ it("a drag under controlled visibility persists the prop-derived set, not a stale internal one", async () => {
614
+ // A record from an uncontrolled era must not resurrect through a
615
+ // controlled mount: the visibleSections prop is authoritative, so
616
+ // the drag-drop persistence writes the DERIVED hidden set (empty
617
+ // here) — never the mount-time internal list.
618
+ localStorage.setItem(
619
+ debugFloatStorageKey("ctl-stale"),
620
+ JSON.stringify({ open: true, hidden: ["gpu"] }),
621
+ );
622
+ const win = mountSections({
623
+ persistKey: "ctl-stale",
624
+ visibleSections: ["timing", "draws", "gpu"],
625
+ });
626
+ expect(section(win, "gpu")).toBeTruthy();
627
+ dispatchMouse("pointerdown", win, { clientX: 10, clientY: 10, button: 0, buttons: 1 });
628
+ dispatchMouse("pointermove", win, { clientX: 30, clientY: 20, buttons: 1 });
629
+ dispatchMouse("pointerup", win);
630
+ await nextTick();
631
+ expect(JSON.parse(localStorage.getItem(debugFloatStorageKey("ctl-stale"))!)).toEqual({
632
+ open: true,
633
+ x: 20,
634
+ y: 10,
635
+ });
636
+ // The inverse direction: a controlled prop that HIDES a section
637
+ // persists that same set on drop (prop-derived, both ways). Two
638
+ // windows are mounted by now — the new one is the LAST in document
639
+ // order (floatWindow() would return the first).
640
+ localStorage.setItem(
641
+ debugFloatStorageKey("ctl-stale2"),
642
+ JSON.stringify({ open: true }),
643
+ );
644
+ mountSections({
645
+ persistKey: "ctl-stale2",
646
+ visibleSections: ["timing"],
647
+ });
648
+ const windows = document.querySelectorAll<HTMLElement>(".hk-debug-float");
649
+ const win2 = windows[windows.length - 1];
650
+ dispatchMouse("pointerdown", win2, { clientX: 10, clientY: 10, button: 0, buttons: 1 });
651
+ dispatchMouse("pointermove", win2, { clientX: 30, clientY: 20, buttons: 1 });
652
+ dispatchMouse("pointerup", win2);
653
+ await nextTick();
654
+ expect(JSON.parse(localStorage.getItem(debugFloatStorageKey("ctl-stale2"))!)).toEqual({
655
+ open: true,
656
+ x: 20,
657
+ y: 10,
658
+ hidden: ["draws", "gpu"],
659
+ });
660
+ });
661
+
662
+ it("keeps the default-slot contract when no sections are declared", () => {
663
+ mount(() => h(HkDebugFloat, null, () => "fps 60"));
664
+ const win = floatWindow()!;
665
+ expect(win.querySelector("[data-el='section']")).toBeNull();
666
+ expect(win.querySelector("[data-el='body']")!.textContent).toContain("fps 60");
667
+ expect(win.querySelector(".hk-debug-float-section")).toBeNull();
668
+ expect(win.querySelector("[data-el='overlay']")).toBeNull();
669
+ });
670
+
671
+ it("headered mode parks the chips overlay but keeps the header close button", () => {
672
+ mount(() => h(HkDebugFloat, { sections: SECTIONS }, {
673
+ timing: () => h("div", null, "t"),
674
+ draws: () => h("div", null, "d"),
675
+ gpu: () => h("div", null, "g"),
676
+ }));
677
+ const win = floatWindow()!;
678
+ expect(win.getAttribute("data-chrome")).toBe("header");
679
+ expect(win.querySelector("[data-el='header'] .hk-debug-float-close")).toBeTruthy();
680
+ // Chips still exist — in the hover overlay, not the header.
681
+ expect(win.querySelectorAll(".hk-debug-float-section").length).toBe(3);
682
+ });
683
+ });
684
+
334
685
  describe("HkDebugFloat stylesheet contract", () => {
335
686
  const here = dirname(fileURLToPath(import.meta.url));
336
687
  const css = compile(resolve(here, "HkDebugFloat.scss"), { style: "expanded" }).css;
337
688
  const scale = readFileSync(resolve(here, "..", "scale.scss"), "utf8");
338
689
 
339
- it("fades to the prop-driven opacity on hover (the wowsp HUD idiom)", () => {
690
+ it("fades the CARD to the prop-driven opacity on hover (the wowsp HUD idiom)", () => {
691
+ // The fade lives on [data-el="fade"], never the root — the hover
692
+ // chrome is the card's sibling and must stay legible while the
693
+ // content dims (at a 0.15 dim an in-card close would fade too).
340
694
  // Sass compiles quoted attribute selectors unquoted ([data-hovered]).
341
695
  expect(css).toMatch(
342
- /\.hk-debug-float:hover,\s*\.hk-debug-float\[data-hovered\]\s*\{\s*opacity:\s*var\(--hk-debug-float-hover-opacity,\s*0\.45\);/,
696
+ /\.hk-debug-float:hover \[data-el=fade\],\s*\.hk-debug-float\[data-hovered\] \[data-el=fade\]\s*\{\s*opacity:\s*var\(--hk-debug-float-hover-opacity,\s*0\.45\);/,
343
697
  );
344
698
  });
345
699
 
346
- it("runs the fade as an opacity-only ~150ms transition on the root", () => {
700
+ it("runs the fade as an opacity-only ~150ms transition on the card", () => {
347
701
  expect(css).toMatch(
348
- /\.hk-debug-float\s*\{[^}]*transition:\s*opacity\s+var\(--duration-short\)/,
702
+ /\.hk-debug-float \[data-el=fade\]\s*\{[^}]*transition:\s*opacity\s+var\(--duration-short\)/,
349
703
  );
350
704
  // Opacity-only: nothing about the fade may move layout.
351
- expect(css).toMatch(/\.hk-debug-float\s*\{[^}]*transition:\s*opacity[^;]*;/);
705
+ expect(css).toMatch(/\.hk-debug-float \[data-el=fade\]\s*\{[^}]*transition:\s*opacity[^;]*;/);
352
706
  });
353
707
 
354
- it("keeps the drag exception: a grabbed window stays opaque", () => {
355
- expect(css).toMatch(/\.hk-debug-float\[data-dragging\]\s*\{\s*opacity:\s*1;/);
708
+ it("keeps the drag exception: a grabbed window's card stays opaque", () => {
709
+ expect(css).toMatch(/\.hk-debug-float\[data-dragging\] \[data-el=fade\]\s*\{\s*opacity:\s*1;/);
356
710
  });
357
711
 
358
712
  it("pins the drag exception AFTER the hover rule (equal specificity — order is the cascade)", () => {
359
- // `.hk-debug-float:hover`/`[data-hovered]` and `[data-dragging]` have
360
- // EQUAL specificity (0,2,0): mid-grab both match (the pointer is captured
361
- // over the header, so :hover holds and pointerleave cannot fire). Which
362
- // rule wins is decided purely by source order — moving the drag exception
363
- // above the hover rule fades the window mid-grab, and no runtime test
364
- // exercises that co-occurrence (happy-dom has no real hover pipeline).
713
+ // `.hk-debug-float:hover [data-el=fade]` and
714
+ // `[data-dragging] [data-el=fade]` have EQUAL specificity: mid-grab
715
+ // both match (the pointer is captured over the handle, so :hover
716
+ // holds and pointerleave cannot fire). Which rule wins is decided
717
+ // purely by source order — moving the drag exception above the hover
718
+ // rule fades the window mid-grab, and no runtime test exercises that
719
+ // co-occurrence (happy-dom has no real hover pipeline).
365
720
  const hoverIdx = css.search(
366
- /\.hk-debug-float:hover,\s*\.hk-debug-float\[data-hovered\]\s*\{/,
721
+ /\.hk-debug-float:hover \[data-el=fade\],\s*\.hk-debug-float\[data-hovered\] \[data-el=fade\]\s*\{/,
367
722
  );
368
- const dragIdx = css.search(/\.hk-debug-float\[data-dragging\]\s*\{/);
723
+ const dragIdx = css.search(/\.hk-debug-float\[data-dragging\] \[data-el=fade\]\s*\{/);
369
724
  expect(hoverIdx).toBeGreaterThan(-1);
370
725
  expect(dragIdx).toBeGreaterThan(hoverIdx);
371
726
  });
@@ -400,14 +755,23 @@ describe("HkDebugFloat stylesheet contract", () => {
400
755
  expect(css).not.toMatch(/\.hk-debug-float\s*\{[^}]*position:\s*absolute/);
401
756
  });
402
757
 
403
- it("gives the header the grab affordances and the body the tabular mono face", () => {
758
+ it("gives the header the grab affordances and the card the tabular mono face", () => {
404
759
  expect(css).toMatch(/\.hk-debug-float \[data-el=header\]\s*\{[^}]*cursor:\s*grab;/);
405
760
  expect(css).toMatch(/\.hk-debug-float \[data-el=header\]\s*\{[^}]*touch-action:\s*none;/);
406
761
  expect(css).toMatch(
407
762
  /\.hk-debug-float\[data-dragging\] \[data-el=header\]\s*\{[^}]*cursor:\s*grabbing;/,
408
763
  );
409
- expect(css).toMatch(/\.hk-debug-float\s*\{[^}]*font-family:\s*var\(--font-mono\);/);
410
- expect(css).toMatch(/\.hk-debug-float\s*\{[^}]*font-variant-numeric:\s*tabular-nums;/);
764
+ expect(css).toMatch(/\.hk-debug-float \[data-el=fade\]\s*\{[^}]*font-family:\s*var\(--font-mono\);/);
765
+ expect(css).toMatch(
766
+ /\.hk-debug-float \[data-el=fade\]\s*\{[^}]*font-variant-numeric:\s*tabular-nums;/,
767
+ );
768
+ });
769
+
770
+ it("makes the whole headerless window the drag handle", () => {
771
+ expect(css).toMatch(/\.hk-debug-float\[data-chrome=none\]\s*\{[^}]*cursor:\s*grab;/);
772
+ expect(css).toMatch(
773
+ /\.hk-debug-float\[data-chrome=none\]\[data-dragging\]\s*\{[^}]*cursor:\s*grabbing;/,
774
+ );
411
775
  });
412
776
 
413
777
  it("caps the body so a fat dump cannot cover the viewport", () => {
@@ -415,4 +779,49 @@ describe("HkDebugFloat stylesheet contract", () => {
415
779
  /\.hk-debug-float \[data-el=body\]\s*\{[^}]*max-height:\s*40vh;[^}]*overflow:\s*auto;/,
416
780
  );
417
781
  });
782
+
783
+ it("sizes the auto seat to its content, guarded against the viewport", () => {
784
+ expect(css).toMatch(/\.hk-debug-float\[data-auto-width\]\s*\{[^}]*width:\s*max-content;/);
785
+ expect(css).toMatch(
786
+ /\.hk-debug-float\[data-auto-width\]\s*\{[^}]*max-width:\s*calc\(100vw - 2 \* var\(--hk-debug-float-offset,\s*16px\)\);/,
787
+ );
788
+ });
789
+
790
+ it("keeps the hover chrome out of the fading card and click-transparent until revealed", () => {
791
+ // Structure: the overlay is a sibling of the card, never inside it —
792
+ // a nested overlay would fade (and unclickable) with the content.
793
+ // dart-sass compiles the attribute selectors UNQUOTED, so search the
794
+ // compiled form — the quoted spelling only survives inside comments
795
+ // and would make this assertion vacuous.
796
+ const fadeIdx = css.indexOf("[data-el=fade]");
797
+ const overlayIdx = css.indexOf("[data-el=overlay]");
798
+ expect(fadeIdx).toBeGreaterThan(-1);
799
+ expect(overlayIdx).toBeGreaterThan(fadeIdx);
800
+ expect(css).not.toMatch(/\.hk-debug-float \[data-el=fade\][^{]*\[data-el=overlay\]/);
801
+ // Hidden until revealed, and reveal never happens inside the card.
802
+ expect(css).toMatch(
803
+ /\.hk-debug-float \[data-el=overlay\]\s*\{[^}]*opacity:\s*0;[^}]*pointer-events:\s*none;/,
804
+ );
805
+ expect(css).toMatch(
806
+ /\.hk-debug-float:hover \[data-el=overlay\],[\s\S]*?\.hk-debug-float\[data-dragging\] \[data-el=overlay\],[\s\S]*?\.hk-debug-float:focus-within \[data-el=overlay\]\s*\{\s*opacity:\s*1;\s*pointer-events:\s*auto;/,
807
+ );
808
+ });
809
+
810
+ it("pins the hover chrome INSIDE the window box so wide chip rows cannot catch off-window clicks", () => {
811
+ // The overlay spans both insets and wraps: a chip row wider than a
812
+ // fixed seat stays inside the window instead of painting (and, while
813
+ // revealed, clicking) past its edge.
814
+ expect(css).toMatch(
815
+ /\.hk-debug-float \[data-el=overlay\]\s*\{[^}]*left:\s*var\(--space-4\);[^}]*right:\s*var\(--space-4\);[^}]*flex-wrap:\s*wrap;/,
816
+ );
817
+ });
818
+
819
+ it("parks the hover chrome on the top edge when headerless and the bottom edge when headered", () => {
820
+ expect(css).toMatch(
821
+ /\.hk-debug-float\[data-chrome=none\] \[data-el=overlay\]\s*\{[^}]*top:\s*var\(--space-4\);/,
822
+ );
823
+ expect(css).toMatch(
824
+ /\.hk-debug-float\[data-chrome=header\] \[data-el=overlay\]\s*\{[^}]*bottom:\s*var\(--space-4\);/,
825
+ );
826
+ });
418
827
  });