@weasel-js/hud 1.11.0 → 1.11.1

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/index.js CHANGED
@@ -10,7 +10,7 @@ import { releaseImageSource as se } from "@weasel-js/core/renderer";
10
10
  import { createLoupeModel as ce, loupeInnerView as le, loupeInnerView as F } from "@weasel-js/loupe";
11
11
  //#region src/menu/accessibleMenu.ts
12
12
  function ue(e, t) {
13
- return t.kind === "number" ? `${t.label}: ${ee(e.numberValue(t), t)}` : t.kind === "color" ? `${t.label}: ${t.value ?? "—"}` : t.label;
13
+ return t.kind === "number" ? `${t.label}: ${ee(e.numberValue(t), t)}` : t.kind === "color" ? `${t.label}: ${t.value ?? "—"}` : t.kind === "text" ? `${t.label}: ${e.textValue(t) ?? "—"}` : t.label;
14
14
  }
15
15
  function I(e, t) {
16
16
  let n = e.stack(), r = t === n.length - 1;
@@ -26,7 +26,7 @@ function I(e, t) {
26
26
  label: ue(e, i),
27
27
  ...r && n[t] === a ? { active: !0 } : {},
28
28
  ...i.kind === "item" && i.checked !== void 0 ? { checked: i.checked } : {},
29
- ...i.disabled || i.kind === "color" ? { disabled: !0 } : {},
29
+ ...i.disabled || i.kind === "color" || i.kind === "text" ? { disabled: !0 } : {},
30
30
  ...i.kind === "submenu" ? { expanded: s } : {},
31
31
  ...s ? { children: [{
32
32
  role: "menu",
@@ -314,6 +314,7 @@ function Ce(e, t, n) {
314
314
  function we(e, t, n) {
315
315
  if (e.kind === "number") return t.padX + K(0, t).width;
316
316
  if (e.kind === "color") return Math.max(t.rowHeight, t.padX + n(e.value ?? "—", t.fontSize));
317
+ if (e.kind === "text") return t.padX + n(e.value ?? "—", t.fontSize);
317
318
  }
318
319
  var q = (e) => ({ paint: {
319
320
  kind: "solid",
@@ -345,6 +346,15 @@ function Te(e, t, n, r, i, a) {
345
346
  ];
346
347
  }
347
348
  function Ee(e, t, n, r, i) {
349
+ return [h(e.x + r.padX, e.y + t.y, [{
350
+ text: n ?? "—",
351
+ fill: q(i.muted)
352
+ }], {
353
+ ...i.font,
354
+ align: "right"
355
+ }, void 0, t.h, "center", void 0, e.w - r.padX * 2)];
356
+ }
357
+ function De(e, t, n, r, i) {
348
358
  let a = [];
349
359
  if (n.value !== void 0) {
350
360
  let o = e.x + r.padX + (r.rowHeight - 12) / 2, s = e.y + t.y + (t.h - 12) / 2;
@@ -395,13 +405,13 @@ function X(e, t) {
395
405
  return n += r, i;
396
406
  });
397
407
  }
398
- var De = (e) => e.kind === "item" ? ae(e.shortcut) : void 0;
399
- function Oe(e, t, n) {
408
+ var Oe = (e) => e.kind === "item" ? ae(e.shortcut) : void 0;
409
+ function ke(e, t, n) {
400
410
  let r = X(e, t).at(-1), i = Math.max(0, ...e.map((e) => {
401
411
  if (e.kind === "separator") return 0;
402
412
  let r = we(e, t, n);
403
413
  if (r !== void 0) return n(e.label, t.fontSize) + r;
404
- let i = De(e);
414
+ let i = Oe(e);
405
415
  return n(e.label, t.fontSize) + Math.max(t.rowHeight, i ? t.padX + n(i, t.fontSize) : 0);
406
416
  }));
407
417
  return {
@@ -412,7 +422,7 @@ function Oe(e, t, n) {
412
422
  var Z = (e) => ({ paint: {
413
423
  kind: "solid",
414
424
  color: e
415
- } }), ke = (e, t, n, r, i) => ({
425
+ } }), Ae = (e, t, n, r, i) => ({
416
426
  kind: "path",
417
427
  path: {
418
428
  kind: "rect",
@@ -423,7 +433,7 @@ var Z = (e) => ({ paint: {
423
433
  },
424
434
  fill: Z(i)
425
435
  });
426
- function Ae(e, t, n) {
436
+ function je(e, t, n) {
427
437
  return {
428
438
  kind: "path",
429
439
  path: p(`M ${e - 3 / 2} ${t - 3} L ${e + 3 / 2} ${t} L ${e - 3 / 2} ${t + 3}`),
@@ -437,7 +447,7 @@ function Ae(e, t, n) {
437
447
  }
438
448
  };
439
449
  }
440
- function je(e, t, n) {
450
+ function Me(e, t, n) {
441
451
  return {
442
452
  kind: "path",
443
453
  path: p(`M ${e - 4} ${t} L ${e - 1.5} ${t + 2.5} L ${e + 4} ${t - 3}`),
@@ -452,12 +462,12 @@ function je(e, t, n) {
452
462
  }
453
463
  };
454
464
  }
455
- var Q = 16, Me = "var(--wzl-bevel-raised, 0 8px 24px var(--wzl-shadow))";
456
- function Ne(e, t, n, r, i, a, o = (e) => e.value) {
465
+ var Q = 16, Ne = "var(--wzl-bevel-raised, 0 8px 24px var(--wzl-shadow))";
466
+ function Pe(e, t, n, r, i, a, o = (e) => e.value) {
457
467
  let s = e.tokens, c = s["--wzl-fg"], l = O(s["--wzl-fg-muted"], c), u = k("--wzl-radius-md", s), d = {
458
468
  fontFamily: e.defaultFont,
459
469
  fontSize: i.fontSize
460
- }, f = z(t, u, D(E(Me, s)), c, {
470
+ }, f = z(t, u, D(E(Ne, s)), c, {
461
471
  x: t.x + 1,
462
472
  y: t.y + 1,
463
473
  w: t.w - 2,
@@ -481,23 +491,23 @@ function Ne(e, t, n, r, i, a, o = (e) => e.value) {
481
491
  return n.forEach((e, n) => {
482
492
  let u = m[n];
483
493
  if (e.kind === "separator") {
484
- p.push(ke(t.x + i.padX, t.y + u.y + Math.floor(u.h / 2), t.w - i.padX * 2, 1, s["--wzl-border"]));
494
+ p.push(Ae(t.x + i.padX, t.y + u.y + Math.floor(u.h / 2), t.w - i.padX * 2, 1, s["--wzl-border"]));
485
495
  return;
486
496
  }
487
- n === r && p.push(ke(t.x + 2, t.y + u.y, t.w - 4, u.h, s["--wzl-surface-hover"]));
488
- let f = e.disabled || e.kind === "color" ? l : c;
497
+ n === r && p.push(Ae(t.x + 2, t.y + u.y, t.w - 4, u.h, s["--wzl-surface-hover"]));
498
+ let f = e.disabled || e.kind === "color" || e.kind === "text" ? l : c;
489
499
  p.push(h(t.x + i.padX + i.rowHeight, t.y + u.y, [{
490
500
  text: e.label,
491
501
  fill: Z(f)
492
502
  }], d, void 0, u.h, "center"));
493
503
  let g = t.x + i.padX + i.rowHeight / 2, _ = t.y + u.y + u.h / 2, v = e.kind !== "color" && typeof e.icon == "string" ? oe(e.icon) : void 0, y = v ? a?.get(v) : void 0;
494
- e.kind === "item" && e.checked ? p.push(je(g, _, f)) : y && p.push(...G(y, {
504
+ e.kind === "item" && e.checked ? p.push(Me(g, _, f)) : y && p.push(...G(y, {
495
505
  x: g - Q / 2,
496
506
  y: _ - Q / 2,
497
507
  size: Q,
498
508
  color: f
499
509
  }));
500
- let b = De(e);
510
+ let b = Oe(e);
501
511
  b && p.push(h(t.x + i.padX, t.y + u.y, [{
502
512
  text: b,
503
513
  fill: Z(l)
@@ -511,21 +521,21 @@ function Ne(e, t, n, r, i, a, o = (e) => e.value) {
511
521
  border: s["--wzl-border"],
512
522
  font: d
513
523
  };
514
- e.kind === "number" && p.push(...Te(t, u, e, o(e), i, x)), e.kind === "color" && p.push(...Ee(t, u, e, i, x)), e.kind === "submenu" && p.push(Ae(t.x + t.w - i.padX - i.rowHeight / 2, t.y + u.y + u.h / 2, f));
524
+ e.kind === "number" && p.push(...Te(t, u, e, o(e), i, x)), e.kind === "color" && p.push(...De(t, u, e, i, x)), e.kind === "text" && p.push(...Ee(t, u, e.value, i, x)), e.kind === "submenu" && p.push(je(t.x + t.w - i.padX - i.rowHeight / 2, t.y + u.y + u.h / 2, f));
515
525
  }), p;
516
526
  }
517
- function Pe(e, t, n) {
527
+ function Fe(e, t, n) {
518
528
  let r = X(e, t).findIndex((e) => n >= e.y && n < e.y + e.h);
519
529
  return r < 0 ? null : r;
520
530
  }
521
531
  //#endregion
522
532
  //#region src/menu/measureLabel.ts
523
- function Fe(e, t) {
533
+ function Ie(e, t) {
524
534
  return e.length * t * .55;
525
535
  }
526
- function Ie(e, t, n) {
536
+ function Le(e, t, n) {
527
537
  let r = j(M(n, 400, "normal"));
528
- if (!r) return Fe(e, t);
538
+ if (!r) return Ie(e, t);
529
539
  let i = 0, a = null;
530
540
  for (let t of e) {
531
541
  let e = t.codePointAt(0);
@@ -535,7 +545,7 @@ function Ie(e, t, n) {
535
545
  }
536
546
  //#endregion
537
547
  //#region src/menu/placePanels.ts
538
- function Le(e) {
548
+ function Re(e) {
539
549
  let t = [], n = null;
540
550
  return (r, i) => {
541
551
  let a = A();
@@ -556,7 +566,7 @@ function Le(e) {
556
566
  continue;
557
567
  }
558
568
  f = !1;
559
- let p = Oe(a, l, (t, n) => i === null ? Fe(t, n) : e.measure(t, n, i)), m;
569
+ let p = ke(a, l, (t, n) => i === null ? Ie(t, n) : e.measure(t, n, i)), m;
560
570
  if (n === 0) m = e.under ? ne(p, e.under, c) : te(p, e.anchor, c);
561
571
  else {
562
572
  let e = d[n - 1].rect, t = X(r.entriesAt(n - 1), l)[o];
@@ -584,14 +594,14 @@ function Le(e) {
584
594
  }
585
595
  //#endregion
586
596
  //#region src/menu/menuWidget.ts
587
- var Re = [
597
+ var ze = [
588
598
  "pointer",
589
599
  "doubleClick",
590
600
  "contextMenu",
591
601
  "longPress",
592
602
  "wheel"
593
603
  ];
594
- function ze(e, t) {
604
+ function Be(e, t) {
595
605
  let n = t({
596
606
  x: e.x,
597
607
  y: e.y
@@ -606,16 +616,16 @@ function ze(e, t) {
606
616
  h: r.y - n.y
607
617
  };
608
618
  }
609
- function Be(e) {
619
+ function Ve(e) {
610
620
  let t = e.metrics ?? Y, r = n(e.onChange), i = N({
611
621
  entries: ie(e.open.entries, (e) => window.location.assign(e)),
612
622
  highlightFirst: e.open.source === "keyboard",
613
623
  onClose: e.close
614
- }), a = Le({
624
+ }), a = Re({
615
625
  anchor: e.toCanvas(e.open.client),
616
- ...e.open.under ? { under: ze(e.open.under, e.toCanvas) } : {},
626
+ ...e.open.under ? { under: Be(e.open.under, e.toCanvas) } : {},
617
627
  canvasSize: e.canvasSize,
618
- measure: e.measure ?? Ie,
628
+ measure: e.measure ?? Le,
619
629
  metrics: t
620
630
  }), o = null, s = a(i, o), c = !1, l = !1, u = null;
621
631
  i.subscribe(() => {
@@ -653,7 +663,7 @@ function Be(e) {
653
663
  if (e.type !== "hovermove" && e.type !== "move" && e.type !== "up") return;
654
664
  let n = d(e.x, e.y), r = e.type === "up" && l;
655
665
  if (e.type === "up" && (l = !1), r || p(n < 0 ? null : n), n < 0) return;
656
- let a = i.entriesAt(n), o = Pe(a, t, e.y - s[n].y);
666
+ let a = i.entriesAt(n), o = Fe(a, t, e.y - s[n].y);
657
667
  if (!r) i.hover(n, o, {
658
668
  x: e.x,
659
669
  y: e.y
@@ -676,7 +686,7 @@ function Be(e) {
676
686
  get disposed() {
677
687
  return c;
678
688
  },
679
- claims: Re,
689
+ claims: ze,
680
690
  focusable: !0,
681
691
  focusRing: !1,
682
692
  accessibleName: "Context menu",
@@ -687,7 +697,7 @@ function Be(e) {
687
697
  A(),
688
698
  e.icons?.getVersion()
689
699
  ],
690
- draw: (n) => (o = n.defaultFont, s = a(i, o), s.flatMap((r, a) => Ne(n, r, i.entriesAt(a), i.stack()[a] ?? null, t, e.icons, i.numberValue))),
700
+ draw: (n) => (o = n.defaultFont, s = a(i, o), s.flatMap((r, a) => Pe(n, r, i.entriesAt(a), i.stack()[a] ?? null, t, e.icons, i.numberValue))),
691
701
  hitTest: (e, t) => d(e, t) >= 0,
692
702
  cursorAt: () => "default",
693
703
  onPointer: m,
@@ -699,7 +709,7 @@ function Be(e) {
699
709
  }
700
710
  //#endregion
701
711
  //#region src/menu/attachMenuHost.ts
702
- function Ve(e, t, n) {
712
+ function He(e, t, n) {
703
713
  let r = null, i = {
704
714
  widget: null,
705
715
  visible: !1
@@ -723,7 +733,7 @@ function Ve(e, t, n) {
723
733
  c && o();
724
734
  return;
725
735
  }
726
- let l = Be({
736
+ let l = Ve({
727
737
  ...n,
728
738
  open: s,
729
739
  close: () => {
@@ -753,7 +763,7 @@ function Ve(e, t, n) {
753
763
  }
754
764
  //#endregion
755
765
  //#region src/loupe/contentWatch.ts
756
- function He(e) {
766
+ function Ue(e) {
757
767
  let t = "", n = null;
758
768
  return {
759
769
  drew(e) {
@@ -770,12 +780,12 @@ function He(e) {
770
780
  }
771
781
  //#endregion
772
782
  //#region src/loupe/pointerAim.ts
773
- var Ue = [
783
+ var We = [
774
784
  "pointerup",
775
785
  "pointercancel",
776
786
  "lostpointercapture"
777
787
  ];
778
- function We(e, t) {
788
+ function Ge(e, t) {
779
789
  let n = !1, r = (t) => {
780
790
  let n = e.getBoundingClientRect();
781
791
  return {
@@ -790,15 +800,15 @@ function We(e, t) {
790
800
  n = !1;
791
801
  };
792
802
  e.addEventListener("pointermove", i), e.addEventListener("pointerdown", a);
793
- for (let t of Ue) e.addEventListener(t, o);
803
+ for (let t of We) e.addEventListener(t, o);
794
804
  return () => {
795
805
  e.removeEventListener("pointermove", i), e.removeEventListener("pointerdown", a);
796
- for (let t of Ue) e.removeEventListener(t, o);
806
+ for (let t of We) e.removeEventListener(t, o);
797
807
  };
798
808
  }
799
809
  //#endregion
800
810
  //#region src/loupe/readback.ts
801
- function Ge(e, t, n, r, i, a, o) {
811
+ function Ke(e, t, n, r, i, a, o) {
802
812
  let s = n.x + Math.round(r.x * i), c = n.y + Math.round(r.y * i), l = _(s - Math.floor(a / 2), n.x, n.x + Math.max(0, n.width - a)), u = t - _(c - Math.floor(o / 2), n.y, n.y + Math.max(0, n.height - o)) - o, d = new Uint8Array(a * o * 4);
803
813
  e.readPixels(l, u, a, o, e.RGBA, e.UNSIGNED_BYTE, d);
804
814
  let f = new Uint8ClampedArray(a * o * 4), p = a * 4;
@@ -810,7 +820,7 @@ function Ge(e, t, n, r, i, a, o) {
810
820
  }
811
821
  //#endregion
812
822
  //#region src/loupe/createLoupe.ts
813
- var Ke = (e, t) => ({
823
+ var qe = (e, t) => ({
814
824
  kind: "path",
815
825
  path: {
816
826
  kind: "rect",
@@ -823,13 +833,13 @@ var Ke = (e, t) => ({
823
833
  kind: "solid",
824
834
  color: t
825
835
  } }
826
- }), $ = "weasel-loupe:lens", qe = {
836
+ }), $ = "weasel-loupe:lens", Je = {
827
837
  x: 0,
828
838
  y: 0,
829
839
  w: 0,
830
840
  h: 0
831
841
  };
832
- function Je(e, t, n, r, i) {
842
+ function Ye(e, t, n, r, i) {
833
843
  if (t && t.id !== null) {
834
844
  let n = {
835
845
  x: (e.x - t.rect.x) / t.view.scale.x + t.view.x,
@@ -843,7 +853,7 @@ function Je(e, t, n, r, i) {
843
853
  y: a[1]
844
854
  }, n, r, i);
845
855
  }
846
- function Ye(e) {
856
+ function Xe(e) {
847
857
  let { hud: t, canvas: n, requestRedraw: r } = e, i = e.views, a = i !== void 0 && e.interactive === !0, o = e.input ?? n, s = null, c = null, l = () => {
848
858
  c &&= (se(c), c.close(), null);
849
859
  }, u = !1, d = !1, p = !1, m = !1, h = e.bounds ?? {
@@ -851,7 +861,7 @@ function Ye(e) {
851
861
  y: 24,
852
862
  w: 220,
853
863
  h: 200
854
- }, g = He(e.contentVersion ?? i?.getPaintedVersion), _ = !1, v = (e) => (g.drew(e.view), j.mode === "vector" ? S(e) : C(e)), y = (t) => e.background ?? t.tokens["--wzl-surface"], b = (e) => Ke(e, y(e)), x = (e, t) => Je(j.aim, i?.viewAt?.(j.aim, { except: $ }) ?? null, e, t, j.factor), S = (t) => i ? s ? [b(t), ...s.draw(t.data, t.view, t.dims)] : [b(t)] : f({
864
+ }, g = Ue(e.contentVersion ?? i?.getPaintedVersion), _ = !1, v = (e) => (g.drew(e.view), j.mode === "vector" ? S(e) : C(e)), y = (t) => e.background ?? t.tokens["--wzl-surface"], b = (e) => qe(e, y(e)), x = (e, t) => Ye(j.aim, i?.viewAt?.(j.aim, { except: $ }) ?? null, e, t, j.factor), S = (t) => i ? s ? [b(t), ...s.draw(t.data, t.view, t.dims)] : [b(t)] : f({
855
865
  id: `${O.id}:lens`,
856
866
  label: "Loupe content",
857
867
  source: e.source ?? [],
@@ -888,7 +898,7 @@ function Ye(e) {
888
898
  width: n.width,
889
899
  height: n.height
890
900
  };
891
- return Ge(o, n.height, u, t, c, r(c), a(c));
901
+ return Ke(o, n.height, u, t, c, r(c), a(c));
892
902
  }, E = () => {
893
903
  if (p || j.mode !== "pixel") return;
894
904
  let e = O.contentRect, t = T(j.aim, (t) => Math.max(1, Math.round(e.w * t / j.factor)), (t) => Math.max(1, Math.round(e.h * t / j.factor)));
@@ -948,13 +958,13 @@ function Ye(e) {
948
958
  i && (s = i.addView({
949
959
  id: $,
950
960
  label: "Loupe",
951
- bounds: () => O.hidden ? qe : O.contentRect,
961
+ bounds: () => O.hidden ? Je : O.contentRect,
952
962
  view: (e) => x(e, O.contentRect),
953
963
  paint: !1,
954
964
  interactive: a,
955
965
  ...e.source ? { layers: () => e.source } : {}
956
966
  }));
957
- let M = We(o, {
967
+ let M = Ge(o, {
958
968
  aimAt: (e) => j.aimAt(e),
959
969
  holds: (e) => a && k.covers(e)
960
970
  }), N = () => {
@@ -987,6 +997,6 @@ function Ye(e) {
987
997
  };
988
998
  }
989
999
  //#endregion
990
- export { i as DEFAULT_FONT_FAMILY, Y as DEFAULT_MENU_METRICS, a as DEFAULT_WIDGET_CLAIMS, l as DEFAULT_WINDOW_METRICS, u as HUD_AFFORDANCE_KIND, c as attachHud, Ve as attachMenuHost, z as boxShadowCommands, d as claimsOf, s as createHud, o as createHudContribution, Ye as createLoupe, Be as createMenuWidget, t as cursorForZone, G as glyphCommands, r as isFocusable, le as loupeInnerView, Ie as measureLabel, e as registerDefaultFont };
1000
+ export { i as DEFAULT_FONT_FAMILY, Y as DEFAULT_MENU_METRICS, a as DEFAULT_WIDGET_CLAIMS, l as DEFAULT_WINDOW_METRICS, u as HUD_AFFORDANCE_KIND, c as attachHud, He as attachMenuHost, z as boxShadowCommands, d as claimsOf, s as createHud, o as createHudContribution, Xe as createLoupe, Ve as createMenuWidget, t as cursorForZone, G as glyphCommands, r as isFocusable, le as loupeInnerView, Le as measureLabel, e as registerDefaultFont };
991
1001
 
992
1002
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["solid","pathFromD","pathFromD","solid","loupeInnerView","registerDefaultFont","cursorForZone","createRevision","isFocusable","DEFAULT_WIDGET_CLAIMS","createHudContribution","createHud","attachHud","DEFAULT_WINDOW_METRICS","HUD_AFFORDANCE_KIND","claimsOf","pathFromD$1","loupeInnerView$1","labelOf","e","menuNumberText","c","level","stack","deepest","at","checkable","open","i","accessibleMenu","BLUR_LAYERS","BLUR_LAYER_ALPHA","solid$2","roundRectD","k","r","w","h","x","y","outer","rect","b","roundRectPath","s","radius","p","color","children","step","inset","margin","hole","ring","boxShadowCommands","under","over","innerRadius","padding","layers","resolveCurrentColor","current","ROOT","INHERITED","tags","m","body","attrs","a","num","v","d","nums","transformOf","identity","fn","args","next","translate","scale","rotateAboutPoint","multiply","arcRectD","rx","ry","ellipseD","cx","cy","shapeD","name","pts","paintOf","shapeCommands","out","fill","cmd","path","alpha","stroke","dash","frameFor","parent","t","group","mat3","glyphCommands","root","skipping","glyph","top","f","cmds","numberChips","end","panelW","chipAt","inside","plus","minus","valueRowWidth","measure","solid$1","mark","pathFromD","numberCommands","cell","live","ink","low","value","menuNumberCanStep","high","textCommandFromRuns","colorCommands","DEFAULT_MENU_METRICS","rowLayout","entries","row","shortcutOf","formatShortcut","panelSize","last","text","chip","solid","caret","check","ICON_SIZE","PANEL_SHADOW","drawPanel","ctx","fg","muted","tokenPx","font","shadow","parseBoxShadow","expandVars","rows","highlight","iconX","iconY","ref","toIconRef","icons","shown","rowAt","estimateWidth","fontSize","measureLabel","metrics","metricsOf","resolveFontVariant","fontFamily","units","prev","ch","cp","createPlacer","placed","measured","faces","faceGeneration","opts","bounds","width","height","kept","parentRow","old","size","placeMenuUnder","placeMenu","placeSubmenu","CLAIMS","underOnCanvas","toCanvas","createMenuWidget","rev","createMenuController","withLinks","href","place","family","panels","disposed","armed","hoverPanel","levelAt","union","x0","y0","x1","y1","enter","pointer","evt","choose","index","dir","key","accessibleTree","attachMenuHost","widget","returnTo","drop","hud","giveBack","sync","host","held","dismiss","wheel","unsubscribe","unfocus","createContentWatch","camera","seen","view","now","version","moved","POINTER_ENDS","followPointer","holding","local","input","onPointerMove","lens","onPointerDown","onPointerEnd","type","readbackRegion","target","dpr","gx","clamp","rw","gy","bufferHeight","rh","raw","gl","flipped","stride","src","backdropOf","LENS_VIEW","NO_RECT","lensCamera","world","aim","factor","screenToWorld","viewToTransform","createLoupe","element","interactive","pixels","dropPixels","releaseImageSource","pixelsPending","refreshWanted","landed","watch","refreshAsked","content","model","drawVector","drawPixels","backdropColor","backdrop","innerView","createViewportLayer","win","scheduleRefresh","read","cssRect","refreshPixels","data","bmp","requestRedraw","readHex","px","surface","unsubscribeFrame","createLoupeModel","teardown","unfollow","DEFAULT_FONT_FAMILY","loupeInnerView"],"sources":["../src/menu/accessibleMenu.ts","../src/boxShadow.ts","../src/glyph.ts","../src/menu/valueRows.ts","../src/menu/drawPanel.ts","../src/menu/measureLabel.ts","../src/menu/placePanels.ts","../src/menu/menuWidget.ts","../src/menu/attachMenuHost.ts","../src/loupe/contentWatch.ts","../src/loupe/pointerAim.ts","../src/loupe/readback.ts","../src/loupe/createLoupe.ts"],"sourcesContent":["import { menuNumberText, type MenuController, type MenuRowEntry } from '@weasel-js/menu';\nimport type { HudAccessibleNode } from '../widget';\n\n/** A row's name: a value row's label and the value it holds now. */\nfunction labelOf(c: MenuController, e: MenuRowEntry): string {\n if (e.kind === 'number') return `${e.label}: ${menuNumberText(c.numberValue(e), e)}`;\n if (e.kind === 'color') return `${e.label}: ${e.value ?? '—'}`;\n return e.label;\n}\n\n/** One level's rows, with the open submenu nested under the row it hangs from. */\nfunction level(c: MenuController, at: number): HudAccessibleNode[] {\n const stack = c.stack();\n const deepest = at === stack.length - 1;\n return c.entriesAt(at).map((e, i): HudAccessibleNode => {\n if (e.kind === 'separator') return { role: 'separator', key: e.key };\n const checkable = e.kind === 'item' && e.checked !== undefined;\n const open = e.kind === 'submenu' && stack[at] === i && stack.length > at + 1;\n return {\n role: checkable ? 'menuitemcheckbox' : 'menuitem',\n key: e.key,\n label: labelOf(c, e),\n ...(deepest && stack[at] === i ? { active: true } : {}),\n ...(e.kind === 'item' && e.checked !== undefined ? { checked: e.checked } : {}),\n ...(e.disabled || e.kind === 'color' ? { disabled: true } : {}),\n ...(e.kind === 'submenu' ? { expanded: open } : {}),\n ...(open ? { children: [{ role: 'menu', key: 'menu', label: e.label, children: level(c, at + 1) }] } : {}),\n };\n });\n}\n\n/** An open menu as the accessibility tree a DOM menu's panels show: rows with their roles and states, and the\n * highlighted row of the innermost open level active. */\nexport function accessibleMenu(c: MenuController): HudAccessibleNode {\n return { role: 'menu', key: 'menu', label: 'Context menu', children: level(c, 0) };\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, roundRectPath, type Path } from '@weasel-js/geom';\nimport { resolveCurrentColor, type BoxShadow } from '@weasel-js/theme';\nimport type { WidgetBounds } from './widget';\n\n// A blurred layer is drawn as nested rounded rects reaching blur / 2 either side of its edge,\n// whose overlap builds the falloff.\nconst BLUR_LAYERS = 7;\nconst BLUR_LAYER_ALPHA = 0.16;\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\n\nfunction roundRectD(x: number, y: number, w: number, h: number, r: number): string {\n const k = Math.max(0, Math.min(r, w / 2, h / 2));\n if (k === 0) return `M ${x} ${y} H ${x + w} V ${y + h} H ${x} Z`;\n return `M ${x + k} ${y} H ${x + w - k} A ${k} ${k} 0 0 1 ${x + w} ${y + k} V ${y + h - k} `\n + `A ${k} ${k} 0 0 1 ${x + w - k} ${y + h} H ${x + k} A ${k} ${k} 0 0 1 ${x} ${y + h - k} `\n + `V ${y + k} A ${k} ${k} 0 0 1 ${x + k} ${y} Z`;\n}\n\nfunction outer(b: WidgetBounds, radius: number, s: BoxShadow, color: string): DrawCommand {\n const rect = (e: number): Path | null => {\n const w = b.w + e * 2;\n const h = b.h + e * 2;\n return w > 0 && h > 0 ? roundRectPath(b.x + s.x - e, b.y + s.y - e, w, h, Math.max(0, radius + e)) : null;\n };\n if (s.blur <= 0) {\n const p = rect(s.spread);\n return { kind: 'group', children: p ? [{ kind: 'path', path: p, fill: solid(color) }] : [] };\n }\n const children: DrawCommand[] = [];\n const step = s.blur / (BLUR_LAYERS - 1);\n for (let i = 0; i < BLUR_LAYERS; i++) {\n const p = rect(s.spread + s.blur / 2 - i * step);\n if (p) children.push({ kind: 'path', path: p, fill: solid(color) });\n }\n return { kind: 'group', alpha: BLUR_LAYER_ALPHA, children };\n}\n\n/** An inset layer, hard-edged whatever its blur: the box less itself moved by the offset and shrunk by the spread. */\nfunction inset(b: WidgetBounds, radius: number, s: BoxShadow, color: string): DrawCommand {\n const margin = Math.abs(s.x) + Math.abs(s.y) + Math.abs(s.spread) + 1;\n const hole = roundRectD(b.x + s.x + s.spread, b.y + s.y + s.spread, b.w - s.spread * 2, b.h - s.spread * 2,\n Math.max(0, radius - s.spread));\n const ring = pathFromD(`${roundRectD(b.x - margin, b.y - margin, b.w + margin * 2, b.h + margin * 2, 0)} ${hole}`);\n return {\n kind: 'group',\n clip: roundRectPath(b.x, b.y, b.w, b.h, radius),\n children: [{ kind: 'path', path: ring.kind === 'polygon' ? { ...ring, fillRule: 'evenodd' } : ring, fill: solid(color) }],\n };\n}\n\n/**\n * A CSS `box-shadow` list cast by a rounded box, as draw commands: `under` goes beneath the box's\n * face and `over` on top of it, for `inset` layers, which fall inside `padding` (the box less its\n * border). Layers draw last-first, so the first is topmost, as in CSS. `current` is what a layer\n * written in `currentColor` takes.\n */\nexport function boxShadowCommands(\n b: WidgetBounds, radius: number, layers: readonly BoxShadow[], current: string, padding: WidgetBounds = b,\n): { under: DrawCommand[]; over: DrawCommand[] } {\n const under: DrawCommand[] = [];\n const over: DrawCommand[] = [];\n const innerRadius = Math.max(0, radius - (padding.x - b.x));\n for (const s of [...layers].reverse()) {\n const color = resolveCurrentColor(s.color, current);\n if (s.inset) over.push(inset(padding, innerRadius, s, color));\n else under.push(outer(b, radius, s, color));\n }\n return { under, over };\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport {\n identity, mat3, multiply, pathFromD, rotateAboutPoint, scale, translate, type Affine, type Path,\n} from '@weasel-js/geom';\nimport type { IconGlyph } from '@weasel-js/icons';\n\n/** The attributes a glyph's elements inherit, as `<Icon>`'s root `<svg>` sets them. */\nconst ROOT: Readonly<Record<string, string>> = {\n fill: 'none', stroke: 'currentColor', 'stroke-width': '1.5',\n 'stroke-linecap': 'round', 'stroke-linejoin': 'round',\n};\n\nconst INHERITED = new Set([\n 'fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-width', 'stroke-opacity',\n 'stroke-linecap', 'stroke-linejoin', 'stroke-dasharray',\n]);\n\n/** What a glyph is drawn in the place of `currentColor` with, and where. */\nexport interface GlyphPlacement {\n x: number;\n y: number;\n /** Width and height; the glyph's 20×20 viewBox scales to it. */\n size: number;\n color: string;\n}\n\ninterface Tag { close: boolean; name: string; attrs: Record<string, string>; selfClosing: boolean }\n\nfunction* tags(body: string): Generator<Tag> {\n for (const m of body.matchAll(/<(\\/?)([a-zA-Z]+)((?:\\s+[\\w:-]+=\"[^\"]*\")*)\\s*(\\/?)>/g)) {\n const attrs: Record<string, string> = {};\n for (const a of m[3]!.matchAll(/([\\w:-]+)=\"([^\"]*)\"/g)) attrs[a[1]!] = a[2]!;\n yield { close: m[1] === '/', name: m[2]!, attrs, selfClosing: m[4] === '/' };\n }\n}\n\nconst num = (v: string | undefined, d = 0) => (v === undefined || v === '' ? d : Number(v));\nconst nums = (v: string) => v.trim().split(/[\\s,]+/).filter((s) => s !== '').map(Number);\n\n/** An SVG `transform` list as one affine. */\nfunction transformOf(v: string | undefined): Affine {\n let m = identity();\n if (!v) return m;\n for (const [, fn, args] of v.matchAll(/(\\w+)\\s*\\(([^)]*)\\)/g)) {\n const a = nums(args!);\n const next: Affine | null = fn === 'translate' ? translate(a[0] ?? 0, a[1] ?? 0)\n : fn === 'scale' ? scale(a[0] ?? 1, a[1] ?? a[0] ?? 1)\n : fn === 'rotate' ? rotateAboutPoint(a[1] ?? 0, a[2] ?? 0, ((a[0] ?? 0) * Math.PI) / 180)\n : fn === 'matrix' && a.length === 6 ? (a as unknown as Affine) : null;\n if (next) m = multiply(m, next);\n }\n return m;\n}\n\nfunction arcRectD(x: number, y: number, w: number, h: number, rx: number, ry: number): string {\n if (rx <= 0 || ry <= 0) return `M ${x} ${y} H ${x + w} V ${y + h} H ${x} Z`;\n return `M ${x + rx} ${y} H ${x + w - rx} A ${rx} ${ry} 0 0 1 ${x + w} ${y + ry} V ${y + h - ry} `\n + `A ${rx} ${ry} 0 0 1 ${x + w - rx} ${y + h} H ${x + rx} A ${rx} ${ry} 0 0 1 ${x} ${y + h - ry} `\n + `V ${y + ry} A ${rx} ${ry} 0 0 1 ${x + rx} ${y} Z`;\n}\n\nconst ellipseD = (cx: number, cy: number, rx: number, ry: number) =>\n `M ${cx - rx} ${cy} A ${rx} ${ry} 0 1 0 ${cx + rx} ${cy} A ${rx} ${ry} 0 1 0 ${cx - rx} ${cy} Z`;\n\n/** A shape element's outline as path data, or undefined for an element that draws none. */\nfunction shapeD(name: string, a: Readonly<Record<string, string>>): string | undefined {\n switch (name) {\n case 'path': return a.d;\n case 'rect': {\n const w = num(a.width), h = num(a.height);\n const rx = Math.min(num(a.rx, num(a.ry)), w / 2), ry = Math.min(num(a.ry, num(a.rx)), h / 2);\n return arcRectD(num(a.x), num(a.y), w, h, rx, ry);\n }\n case 'circle': return ellipseD(num(a.cx), num(a.cy), num(a.r), num(a.r));\n case 'ellipse': return ellipseD(num(a.cx), num(a.cy), num(a.rx), num(a.ry));\n case 'line': return `M ${num(a.x1)} ${num(a.y1)} L ${num(a.x2)} ${num(a.y2)}`;\n case 'polygon':\n case 'polyline': {\n const p = nums(a.points ?? '');\n if (p.length < 4) return undefined;\n const pts = [];\n for (let i = 0; i + 1 < p.length; i += 2) pts.push(`${p[i]} ${p[i + 1]}`);\n return `M ${pts.join(' L ')}${name === 'polygon' ? ' Z' : ''}`;\n }\n default: return undefined;\n }\n}\n\nconst paintOf = (v: string | undefined, color: string): string | null =>\n (v === undefined || v === 'none' ? null : /^currentcolor$/i.test(v) ? color : v);\n\n/** One shape's commands: its fill, then its stroke, each at its own opacity. */\nfunction shapeCommands(path: Path, a: Readonly<Record<string, string>>, color: string): DrawCommand[] {\n const out: DrawCommand[] = [];\n const fill = paintOf(a.fill, color);\n if (fill) {\n const p = path.kind === 'polygon' && a['fill-rule'] === 'evenodd' ? { ...path, fillRule: 'evenodd' as const } : path;\n const cmd: DrawCommand = { kind: 'path', path: p, fill: { paint: { kind: 'solid', color: fill } } };\n const alpha = num(a['fill-opacity'], 1);\n out.push(alpha < 1 ? { kind: 'group', alpha, children: [cmd] } : cmd);\n }\n const stroke = paintOf(a.stroke, color);\n if (stroke) {\n const dash = a['stroke-dasharray'] && a['stroke-dasharray'] !== 'none' ? nums(a['stroke-dasharray']) : undefined;\n const cmd: DrawCommand = {\n kind: 'path', path,\n stroke: {\n paint: { kind: 'solid', color: stroke },\n width: num(a['stroke-width'], 1),\n cap: a['stroke-linecap'] as 'butt' | 'round' | 'square' | undefined,\n join: a['stroke-linejoin'] as 'miter' | 'round' | 'bevel' | undefined,\n ...(dash ? { dash } : {}),\n },\n };\n const alpha = num(a['stroke-opacity'], 1);\n out.push(alpha < 1 ? { kind: 'group', alpha, children: [cmd] } : cmd);\n }\n return out;\n}\n\ninterface Frame { attrs: Readonly<Record<string, string>>; children: DrawCommand[]; group: DrawCommand & { kind: 'group' } }\n\nfunction frameFor(t: Tag, parent: Readonly<Record<string, string>>): Frame {\n const attrs = { ...parent };\n for (const [k, v] of Object.entries(t.attrs)) if (INHERITED.has(k)) attrs[k] = v;\n const children: DrawCommand[] = [];\n const group: Frame['group'] = { kind: 'group', children };\n const m = transformOf(t.attrs.transform);\n if (m.some((v, i) => v !== identity()[i])) group.transform = mat3.fromAffine(m);\n // Every nested `<svg>` a glyph uses has a viewBox matching its own box, so it only clips.\n if (t.name === 'svg') {\n group.clip = { kind: 'rect', x: num(t.attrs.x), y: num(t.attrs.y), width: num(t.attrs.width), height: num(t.attrs.height) };\n }\n return { attrs, children, group };\n}\n\n/**\n * A glyph as draw commands, placed in a square and drawn in `color` wherever it says\n * `currentColor`, as `<Icon>` draws it in the DOM. Reads the elements the icon tables use — `path`,\n * `rect`, `circle`, `ellipse`, `line`, `polygon`, `polyline`, `g` and a nested `svg` — with their\n * presentation attributes and transforms. `defs` and what they hold are skipped, so a `clip-path`\n * pointing into them does not clip.\n */\nexport function glyphCommands(glyph: IconGlyph, at: GlyphPlacement): DrawCommand[] {\n const k = at.size / 20;\n const root: Frame = {\n attrs: ROOT, children: [],\n group: { kind: 'group', transform: mat3.fromAffine([k, 0, 0, k, at.x, at.y]), children: [] },\n };\n root.group.children = root.children;\n const stack: Frame[] = [root];\n let skipping = 0;\n for (const t of tags(glyph.body)) {\n const top = stack.at(-1)!;\n if (skipping > 0 || t.name === 'defs' || t.name === 'clipPath') {\n if (!t.selfClosing) skipping += t.close ? -1 : 1;\n continue;\n }\n if (t.close) {\n if ((t.name === 'g' || t.name === 'svg') && stack.length > 1) stack.pop();\n continue;\n }\n if (t.name === 'g' || t.name === 'svg') {\n const f = frameFor(t, top.attrs);\n top.children.push(f.group);\n if (!t.selfClosing) stack.push(f);\n continue;\n }\n const d = shapeD(t.name, t.attrs);\n if (d === undefined) continue;\n const f = frameFor(t, top.attrs);\n const cmds = shapeCommands(pathFromD(d), f.attrs, at.color);\n if (f.group.transform) top.children.push({ kind: 'group', transform: f.group.transform, children: cmds });\n else top.children.push(...cmds);\n }\n return [root.group];\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, textCommandFromRuns } from '@weasel-js/core';\nimport { menuNumberCanStep, menuNumberText, type MenuColorEntry, type MenuEntry, type MenuNumberEntry } from '@weasel-js/menu';\nimport type { WidgetBounds } from '../widget';\nimport type { MenuMetrics } from './drawPanel';\n\n/** A span across a panel, from its left edge. */\nexport interface Span { x: number; w: number }\n\n/**\n * Where a number row's step chips and value sit, at the row's end: a minus chip, the value in a cell of fixed\n * width so a changing value moves nothing, and a plus chip. `width` is all three.\n */\nexport function numberChips(panelW: number, m: MenuMetrics): { minus: Span; value: Span; plus: Span; width: number } {\n const s = m.rowHeight;\n const end = panelW - m.padX;\n return { minus: { x: end - 4 * s, w: s }, value: { x: end - 3 * s, w: 2 * s }, plus: { x: end - s, w: s }, width: 4 * s };\n}\n\n/** Which way the chip under panel-local `x` steps a number row: 1, -1, or null off both. */\nexport function chipAt(panelW: number, m: MenuMetrics, x: number): 1 | -1 | null {\n const { minus, plus } = numberChips(panelW, m);\n const inside = (s: Span) => x >= s.x && x < s.x + s.w;\n return inside(plus) ? 1 : inside(minus) ? -1 : null;\n}\n\n/** What a value row needs past its label, for sizing the panel; undefined for any other row. */\nexport function valueRowWidth(e: MenuEntry, m: MenuMetrics, measure: (text: string, fontSize: number) => number): number | undefined {\n if (e.kind === 'number') return m.padX + numberChips(0, m).width;\n if (e.kind === 'color') return Math.max(m.rowHeight, m.padX + measure(e.value ?? '—', m.fontSize));\n return undefined;\n}\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\nconst mark = (d: string, color: string): DrawCommand => ({\n kind: 'path', path: pathFromD(d), stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round' },\n});\n\n/** The colors and font a value row draws in. */\nexport interface ValueInk { fg: string; muted: string; border: string; font: { fontFamily: string; fontSize: number } }\n\n/** A number row's chips and value. A chip with nowhere to step to is muted, as is all of a disabled row. */\nexport function numberCommands(\n b: WidgetBounds, r: { y: number; h: number }, e: MenuNumberEntry, value: number | undefined, m: MenuMetrics, ink: ValueInk,\n): DrawCommand[] {\n const { minus, value: cell, plus } = numberChips(b.w, m);\n const cy = b.y + r.y + r.h / 2;\n const color = (live: boolean) => (live && !e.disabled ? ink.fg : ink.muted);\n const cx = (s: Span) => b.x + s.x + s.w / 2;\n const low = value !== undefined && !menuNumberCanStep(e, value, -1);\n const high = value !== undefined && !menuNumberCanStep(e, value, 1);\n return [\n mark(`M ${cx(minus) - 4} ${cy} L ${cx(minus) + 4} ${cy}`, color(!low)),\n textCommandFromRuns(\n b.x + cell.x, b.y + r.y, [{ text: menuNumberText(value, e), fill: solid(color(true)) }],\n { ...ink.font, align: 'center' }, undefined, r.h, 'center', undefined, cell.w,\n ),\n mark(`M ${cx(plus) - 4} ${cy} L ${cx(plus) + 4} ${cy} M ${cx(plus)} ${cy - 4} L ${cx(plus)} ${cy + 4}`, color(!high)),\n ];\n}\n\n/** The swatch a color row draws in its icon column, and its hex at the row's end. */\nexport function colorCommands(\n b: WidgetBounds, r: { y: number; h: number }, e: MenuColorEntry, m: MenuMetrics, ink: ValueInk,\n): DrawCommand[] {\n const out: DrawCommand[] = [];\n if (e.value !== undefined) {\n const size = 12;\n const x = b.x + m.padX + (m.rowHeight - size) / 2;\n const y = b.y + r.y + (r.h - size) / 2;\n out.push({\n kind: 'path', path: { kind: 'rect', x, y, width: size, height: size },\n fill: solid(e.value), stroke: { paint: { kind: 'solid', color: ink.border }, width: 1 },\n });\n }\n out.push(textCommandFromRuns(\n b.x + m.padX, b.y + r.y, [{ text: e.value ?? '—', fill: solid(ink.muted) }],\n { ...ink.font, align: 'right' }, undefined, r.h, 'center', undefined, b.w - m.padX * 2,\n ));\n return out;\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, textCommandFromRuns } from '@weasel-js/core';\nimport { roundRectPath } from '@weasel-js/geom';\nimport { formatShortcut } from '@weasel-js/gestures';\nimport type { MenuEntry, MenuNumberEntry } from '@weasel-js/menu';\nimport { expandVars, parseBoxShadow, resolveCurrentColor, tokenPx } from '@weasel-js/theme';\nimport { toIconRef, type IconRegistry } from '@weasel-js/icons';\nimport { boxShadowCommands } from '../boxShadow';\nimport { glyphCommands } from '../glyph';\nimport type { HudDrawCtx, WidgetBounds } from '../widget';\nimport { colorCommands, numberCommands, valueRowWidth } from './valueRows';\n\n/** Sizes of a HUD menu panel, in CSS pixels. */\nexport interface MenuMetrics {\n rowHeight: number;\n padX: number;\n padY: number;\n separatorHeight: number;\n minWidth: number;\n fontSize: number;\n}\n\n/** The metrics a menu widget uses when given none, close to the DOM menu's. */\nexport const DEFAULT_MENU_METRICS: MenuMetrics = {\n rowHeight: 24, padX: 8, padY: 4, separatorHeight: 9, minWidth: 180, fontSize: 13,\n};\n\n/** Each entry's y offset and height inside a panel. */\nexport function rowLayout(entries: readonly MenuEntry[], m: MenuMetrics): { y: number; h: number }[] {\n let y = m.padY;\n return entries.map((e) => {\n const h = e.kind === 'separator' ? m.separatorHeight : m.rowHeight;\n const row = { y, h };\n y += h;\n return row;\n });\n}\n\n/** A row's shortcut as the DOM menu prints it, or undefined. */\nconst shortcutOf = (e: MenuEntry): string | undefined =>\n (e.kind === 'item' ? formatShortcut(e.shortcut) : undefined);\n\n/** A panel's size: its widest row — label, then a shortcut or the caret column —\n * plus the icon column, never under `minWidth`. */\nexport function panelSize(\n entries: readonly MenuEntry[], m: MenuMetrics, measure: (text: string, fontSize: number) => number,\n): { w: number; h: number } {\n const rows = rowLayout(entries, m);\n const last = rows.at(-1);\n const rowWidth = (e: MenuEntry) => {\n if (e.kind === 'separator') return 0;\n const value = valueRowWidth(e, m, measure);\n if (value !== undefined) return measure(e.label, m.fontSize) + value;\n const chip = shortcutOf(e);\n return measure(e.label, m.fontSize) + Math.max(m.rowHeight, chip ? m.padX + measure(chip, m.fontSize) : 0);\n };\n const text = Math.max(0, ...entries.map(rowWidth));\n return {\n w: Math.max(m.minWidth, Math.ceil(text) + m.padX * 2 + m.rowHeight),\n h: (last ? last.y + last.h : 0) + m.padY,\n };\n}\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\nconst rect = (x: number, y: number, width: number, height: number, color: string): DrawCommand => ({\n kind: 'path', path: { kind: 'rect', x, y, width, height }, fill: solid(color),\n});\n\n/** A right-pointing chevron centered on (cx, cy). The bundled atlas has no `›` glyph. */\nfunction caret(cx: number, cy: number, color: string): DrawCommand {\n const s = 3;\n return {\n kind: 'path',\n path: pathFromD(`M ${cx - s / 2} ${cy - s} L ${cx + s / 2} ${cy} L ${cx - s / 2} ${cy + s}`),\n stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round' },\n };\n}\n\n/** A check mark centered on (cx, cy), for a row whose action is on. */\nfunction check(cx: number, cy: number, color: string): DrawCommand {\n return {\n kind: 'path',\n path: pathFromD(`M ${cx - 4} ${cy} L ${cx - 1.5} ${cy + 2.5} L ${cx + 4} ${cy - 3}`),\n stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round', join: 'round' },\n };\n}\n\n/** Where a menu finds the glyph a row's `icon` names: an icon registry, or anything answering as one. */\nexport type MenuIcons = Pick<IconRegistry, 'get' | 'getVersion'>;\n\n/** The DOM row draws its icon at 16px. */\nconst ICON_SIZE = 16;\n\n// The shadow `.surface` in ui's listbox.module.css gives the DOM panel.\nconst PANEL_SHADOW = 'var(--wzl-bevel-raised, 0 8px 24px var(--wzl-shadow))';\n\n/** One panel's commands: its rounded face and the DOM panel's box shadow, a highlight behind row\n * `highlight`, and every row, with the glyph `icons` holds for each row's icon. A number row shows what\n * `shown` says it holds, by default what it opened with. */\nexport function drawPanel(\n ctx: HudDrawCtx, b: WidgetBounds, entries: readonly MenuEntry[], highlight: number | null, m: MenuMetrics,\n icons?: MenuIcons, shown: (e: MenuNumberEntry) => number | undefined = (e) => e.value,\n): DrawCommand[] {\n const t = ctx.tokens;\n const fg = t['--wzl-fg'];\n const muted = resolveCurrentColor(t['--wzl-fg-muted'], fg);\n const radius = tokenPx('--wzl-radius-md', t);\n const font = { fontFamily: ctx.defaultFont, fontSize: m.fontSize };\n const shadow = boxShadowCommands(b, radius, parseBoxShadow(expandVars(PANEL_SHADOW, t)), fg,\n { x: b.x + 1, y: b.y + 1, w: b.w - 2, h: b.h - 2 });\n const out: DrawCommand[] = [...shadow.under, {\n kind: 'path',\n path: roundRectPath(b.x, b.y, b.w, b.h, radius),\n fill: solid(t['--wzl-surface-popover']),\n stroke: { paint: { kind: 'solid', color: t['--wzl-border'] }, width: 1 },\n }, ...shadow.over];\n const rows = rowLayout(entries, m);\n entries.forEach((e, i) => {\n const r = rows[i]!;\n if (e.kind === 'separator') {\n out.push(rect(b.x + m.padX, b.y + r.y + Math.floor(r.h / 2), b.w - m.padX * 2, 1, t['--wzl-border']));\n return;\n }\n if (i === highlight) out.push(rect(b.x + 2, b.y + r.y, b.w - 4, r.h, t['--wzl-surface-hover']));\n // Nothing edits a color row, so it reads as a disabled one does.\n const color = e.disabled || e.kind === 'color' ? muted : fg;\n out.push(textCommandFromRuns(\n b.x + m.padX + m.rowHeight, b.y + r.y,\n [{ text: e.label, fill: solid(color) }],\n font, undefined, r.h, 'center',\n ));\n const iconX = b.x + m.padX + m.rowHeight / 2;\n const iconY = b.y + r.y + r.h / 2;\n const ref = e.kind !== 'color' && typeof e.icon === 'string' ? toIconRef(e.icon) : undefined;\n const glyph = ref ? icons?.get(ref) : undefined;\n if (e.kind === 'item' && e.checked) out.push(check(iconX, iconY, color));\n else if (glyph) out.push(...glyphCommands(glyph, { x: iconX - ICON_SIZE / 2, y: iconY - ICON_SIZE / 2, size: ICON_SIZE, color }));\n const chip = shortcutOf(e);\n if (chip) {\n out.push(textCommandFromRuns(\n b.x + m.padX, b.y + r.y, [{ text: chip, fill: solid(muted) }],\n { ...font, align: 'right' }, undefined, r.h, 'center', undefined, b.w - m.padX * 2,\n ));\n }\n const ink = { fg, muted, border: t['--wzl-border'], font };\n if (e.kind === 'number') out.push(...numberCommands(b, r, e, shown(e), m, ink));\n if (e.kind === 'color') out.push(...colorCommands(b, r, e, m, ink));\n if (e.kind === 'submenu') out.push(caret(b.x + b.w - m.padX - m.rowHeight / 2, b.y + r.y + r.h / 2, color));\n });\n return out;\n}\n\n/** Index of the entry under panel-local `y`, or null. */\nexport function rowAt(entries: readonly MenuEntry[], m: MenuMetrics, y: number): number | null {\n const i = rowLayout(entries, m).findIndex((r) => y >= r.y && y < r.y + r.h);\n return i < 0 ? null : i;\n}\n","import { metricsOf, resolveFontVariant } from '@weasel-js/font';\n\n/** A width for `text` with no face to measure it in. */\nexport function estimateWidth(text: string, fontSize: number): number {\n return text.length * fontSize * 0.55;\n}\n\n/** Width of `text` at `fontSize` in `fontFamily`, from the advances and\n * kerning of the face the text command lays it out with. A face not loaded\n * yet gives an estimate; `faceGeneration` moves when it lands. */\nexport function measureLabel(text: string, fontSize: number, fontFamily: string): number {\n const metrics = metricsOf(resolveFontVariant(fontFamily, 400, 'normal'));\n if (!metrics) return estimateWidth(text, fontSize);\n let units = 0;\n let prev: number | null = null;\n for (const ch of text) {\n const cp = ch.codePointAt(0)!;\n units += metrics.advanceOf(cp) ?? metrics.size * 0.55;\n if (prev !== null) units += metrics.kernOf(prev, cp);\n prev = cp;\n }\n return units * fontSize / metrics.size;\n}\n","import { placeMenu, placeMenuUnder, placeSubmenu, type MenuController, type MenuEntry, type Rect } from '@weasel-js/menu';\nimport { faceGeneration } from '@weasel-js/font';\nimport { panelSize, rowLayout, type MenuMetrics } from './drawPanel';\nimport { estimateWidth } from './measureLabel';\n\ntype XY = { x: number; y: number };\n\n/** What placing needs: where the menu opened, the canvas, and how to measure. */\nexport interface PlaceOptions {\n anchor: XY;\n /** The button the menu hangs from, in canvas pixels; when set, `anchor` is not used. */\n under?: Rect;\n canvasSize(): { width: number; height: number };\n measure(text: string, fontSize: number, fontFamily: string): number;\n metrics: MenuMetrics;\n}\n\ninterface Placed {\n entries: readonly MenuEntry[];\n parentRow: number | null;\n rect: Rect;\n}\n\n/**\n * Places each open level once, when it opens: a level keeps its rect for as\n * long as its entries and the parent row it hangs from stay the same. A new\n * font family, or a face landing, re-measures everything. With no family yet\n * — the hud has not drawn — widths are estimated rather than measured in a\n * guessed family.\n */\nexport function createPlacer(opts: PlaceOptions): (c: MenuController, fontFamily: string | null) => Rect[] {\n let placed: Placed[] = [];\n let measured: { family: string | null; faces: number } | null = null;\n\n return (c, fontFamily) => {\n const faces = faceGeneration();\n if (measured?.family !== fontFamily || measured.faces !== faces) {\n placed = [];\n measured = { family: fontFamily, faces };\n }\n const { width, height } = opts.canvasSize();\n const bounds = { x: 0, y: 0, w: width, h: height };\n const m = opts.metrics;\n const stack = c.stack();\n const next: Placed[] = [];\n let kept = true;\n for (let level = 0; level < stack.length; level++) {\n const entries = c.entriesAt(level);\n const parentRow = level === 0 ? null : stack[level - 1] ?? null;\n const old = placed[level];\n if (kept && old && old.entries === entries && old.parentRow === parentRow) {\n next.push(old);\n continue;\n }\n kept = false;\n const size = panelSize(entries, m, (t, s) => (fontFamily === null ? estimateWidth(t, s) : opts.measure(t, s, fontFamily)));\n let at: XY;\n if (level === 0) {\n at = opts.under ? placeMenuUnder(size, opts.under, bounds) : placeMenu(size, opts.anchor, bounds);\n } else {\n const parent = next[level - 1]!.rect;\n const row = rowLayout(c.entriesAt(level - 1), m)[parentRow!]!;\n at = placeSubmenu(size, { x: parent.x, y: parent.y + row.y, w: parent.w, h: row.h }, bounds);\n }\n const rect = { x: at.x, y: at.y, w: size.w, h: size.h };\n next.push({ entries, parentRow, rect });\n c.setPanel(level, rect);\n }\n placed = next;\n return next.map((p) => p.rect);\n };\n}\n","import { createMenuController, withLinks, type Rect } from '@weasel-js/menu';\nimport { faceGeneration } from '@weasel-js/font';\nimport type { ClaimableGesture, OpenMenu } from '@weasel-js/core';\nimport { createRevision, type HudAccessibleTree, type HudKeyEvent, type HudPointerEvent, type Widget, type WidgetBounds } from '../widget';\nimport { accessibleMenu } from './accessibleMenu';\nimport { DEFAULT_MENU_METRICS, drawPanel, rowAt, type MenuIcons, type MenuMetrics } from './drawPanel';\nimport { measureLabel } from './measureLabel';\nimport { createPlacer } from './placePanels';\nimport { chipAt } from './valueRows';\nimport type { Point } from '@weasel-js/geom';\n\nconst CLAIMS: readonly ClaimableGesture[] = ['pointer', 'doubleClick', 'contextMenu', 'longPress', 'wheel'];\n\n/** What {@link createMenuWidget} needs: the open menu, how to close it, and the canvas it draws on. */\nexport interface MenuWidgetOptions {\n open: OpenMenu;\n /** The menu is done: an item was chosen, or it was dismissed. */\n close(): void;\n /** Viewport point to canvas CSS pixels, for `open.client` and `open.under`. */\n toCanvas(client: Point): Point;\n canvasSize(): { width: number; height: number };\n /** Width of a label in the family the hud draws with. Defaults to the\n * registered face's own advances, which is what the text is laid out with. */\n measure?(text: string, fontSize: number, fontFamily: string): number;\n metrics?: MenuMetrics;\n /** Where a row's icon is looked up; without it no row draws one. */\n icons?: MenuIcons;\n onChange(): void;\n}\n\nfunction underOnCanvas(r: Rect, toCanvas: (client: Point) => Point): Rect {\n const a = toCanvas({ x: r.x, y: r.y });\n const b = toCanvas({ x: r.x + r.w, y: r.y + r.h });\n return { x: a.x, y: a.y, w: b.x - a.x, h: b.y - a.y };\n}\n\n/** A widget that draws `open` as one panel per open level, driven by a menu controller it owns. */\nexport function createMenuWidget(opts: MenuWidgetOptions): Widget {\n const m = opts.metrics ?? DEFAULT_MENU_METRICS;\n const rev = createRevision(opts.onChange);\n const c = createMenuController({\n entries: withLinks(opts.open.entries, (href) => window.location.assign(href)),\n highlightFirst: opts.open.source === 'keyboard', onClose: opts.close,\n });\n const place = createPlacer({\n anchor: opts.toCanvas(opts.open.client),\n ...(opts.open.under ? { under: underOnCanvas(opts.open.under, opts.toCanvas) } : {}),\n canvasSize: opts.canvasSize,\n measure: opts.measure ?? measureLabel, metrics: m,\n });\n // The hud's font is known only once it draws.\n let family: string | null = null;\n let panels: Rect[] = place(c, family);\n let disposed = false;\n let armed = false;\n let hoverPanel: number | null = null;\n c.subscribe(() => { panels = place(c, family); rev.changed(); });\n\n /** The topmost panel under (x, y), or -1. */\n const levelAt = (x: number, y: number): number => {\n for (let i = panels.length - 1; i >= 0; i--) {\n const p = panels[i]!;\n if (x >= p.x && x < p.x + p.w && y >= p.y && y < p.y + p.h) return i;\n }\n return -1;\n };\n\n const union = (): WidgetBounds => {\n const x0 = Math.min(...panels.map((p) => p.x));\n const y0 = Math.min(...panels.map((p) => p.y));\n const x1 = Math.max(...panels.map((p) => p.x + p.w));\n const y1 = Math.max(...panels.map((p) => p.y + p.h));\n return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };\n };\n\n /** The pointer is now over `level` (null: no panel). Leaving a panel clears\n * its row, as the DOM menu's per-panel `pointerleave` does. */\n const enter = (level: number | null) => {\n if (hoverPanel !== null && hoverPanel !== level) c.hover(hoverPanel, null);\n hoverPanel = level;\n };\n\n const pointer = (evt: HudPointerEvent) => {\n if (evt.type === 'hoverleave') { enter(null); return; }\n if (evt.type === 'cancel') { armed = false; return; }\n if (evt.type === 'down') { armed = true; return; }\n if (evt.type !== 'hovermove' && evt.type !== 'move' && evt.type !== 'up') return;\n const level = levelAt(evt.x, evt.y);\n // Only a release that follows a press here chooses: the release of the\n // right-click or long-press that opened the menu must not.\n const choose = evt.type === 'up' && armed;\n if (evt.type === 'up') armed = false;\n if (!choose) enter(level < 0 ? null : level);\n if (level < 0) return;\n const entries = c.entriesAt(level);\n const index = rowAt(entries, m, evt.y - panels[level]!.y);\n if (!choose) c.hover(level, index, { x: evt.x, y: evt.y });\n else if (index !== null) {\n c.press(level, index);\n // A number row's chips step it, since this menu has no field to type in.\n const e = entries[index];\n const dir = e?.kind === 'number' ? chipAt(panels[level]!.w, m, evt.x - panels[level]!.x) : null;\n if (e?.kind === 'number' && dir !== null) c.spin(e, dir > 0 ? 'ArrowUp' : 'ArrowDown');\n }\n };\n\n const key = (evt: HudKeyEvent): boolean => {\n if (evt.type !== 'keydown') return false;\n if (!evt.ctrlKey && !evt.metaKey && !evt.altKey) c.key(evt.key);\n // Every key belongs to the open menu, so no canvas binding fires under it.\n return true;\n };\n\n const accessibleTree: HudAccessibleTree = { read: () => accessibleMenu(c), subscribe: c.subscribe };\n\n return {\n id: `weasel-menu-${opts.open.seq}`,\n get bounds() { return union(); },\n hidden: false,\n get disposed() { return disposed; },\n claims: CLAIMS,\n focusable: true,\n focusRing: false,\n accessibleName: 'Context menu',\n accessibleTree,\n deps: (ctx) => [...rev.deps(), ctx.defaultFont, faceGeneration(), opts.icons?.getVersion()],\n draw: (ctx) => {\n family = ctx.defaultFont;\n panels = place(c, family);\n return panels.flatMap((p, level) => drawPanel(ctx, p, c.entriesAt(level), c.stack()[level] ?? null, m, opts.icons, c.numberValue));\n },\n hitTest: (x, y) => levelAt(x, y) >= 0,\n cursorAt: () => 'default',\n onPointer: pointer,\n onKey: key,\n dispose() { disposed = true; c.dispose(); },\n };\n}\n","import type { MenuHost } from '@weasel-js/core';\nimport type { Hud } from '../hud';\nimport type { Widget } from '../widget';\nimport { createMenuWidget, type MenuWidgetOptions } from './menuWidget';\n\n/** What {@link attachMenuHost} needs beyond the hud and host. */\nexport type AttachMenuHostOptions =\n Pick<MenuWidgetOptions, 'toCanvas' | 'canvasSize' | 'measure' | 'metrics' | 'icons'>;\n\n/** Draw `host`'s open menu as a widget on `hud`, focused while open. A press\n * anywhere else takes focus from it, which closes the menu, as do a wheel\n * outside it, the window losing focus and a resize. Closing any other way\n * gives focus back to the widget that held it when the menu opened. Returns a detach. */\nexport function attachMenuHost(hud: Hud, host: MenuHost, opts: AttachMenuHostOptions): () => void {\n let widget: Widget | null = null;\n let returnTo: { widget: Widget | null; visible: boolean } = { widget: null, visible: false };\n\n // Cleared before removal: removing the focused widget blurs it, and that\n // blur must not read as a press elsewhere.\n const drop = () => {\n const w = widget;\n widget = null;\n if (!w) return;\n hud.remove(w);\n if (!w.disposed) w.dispose();\n };\n\n const giveBack = () => {\n const { widget: w, visible } = returnTo;\n returnTo = { widget: null, visible: false };\n if (w) hud.focus(w, { visible });\n };\n\n const sync = () => {\n const open = host.current();\n if (!widget) returnTo = { widget: hud.focused, visible: hud.focusVisible };\n const held = widget !== null && hud.focused === widget;\n drop();\n if (!open) {\n if (held) giveBack();\n return;\n }\n const w = createMenuWidget({\n ...opts, open,\n close: () => { if (host.current() === open) host.close(); },\n onChange: () => hud.markDirty(),\n });\n widget = w;\n hud.add(w);\n // A menu that cannot take focus could never be dismissed, so it does not open.\n if (!hud.focus(w)) { drop(); host.close(); }\n };\n\n const dismiss = () => { if (widget) host.close(); };\n const wheel = (e: WheelEvent) => {\n if (!widget) return;\n const p = opts.toCanvas({ x: e.clientX, y: e.clientY });\n if (!widget.hitTest(p.x, p.y)) host.close();\n };\n\n const unsubscribe = host.subscribe(sync);\n const unfocus = hud.subscribeFocus((f) => { if (widget && f !== widget) host.close(); });\n window.addEventListener('wheel', wheel, { capture: true, passive: true });\n window.addEventListener('blur', dismiss);\n window.addEventListener('resize', dismiss);\n sync();\n return () => {\n unsubscribe();\n unfocus();\n window.removeEventListener('wheel', wheel, true);\n window.removeEventListener('blur', dismiss);\n window.removeEventListener('resize', dismiss);\n drop();\n };\n}\n","import type { View } from '@weasel-js/core';\n\n/** Says whether what a lens reads from changed between one landed frame and the next. */\nexport interface ContentWatch {\n /** The camera the lens was just drawn through. */\n drew(view: View): void;\n /** Whether the content version or the camera differs from the last time this was asked. The first ask only\n * takes its bearings, and answers `false`. */\n changed(): boolean;\n}\n\n/**\n * Watches the two things that change the pixels under an aim that holds still: the content, through `version`\n * when the lens is given one, and the camera it is drawn through. A lens redrawing itself moves neither, which is\n * what lets it read the framebuffer again on a change without that read's own redraw asking for another.\n */\nexport function createContentWatch(version: (() => number) | undefined): ContentWatch {\n let camera = '';\n let seen: { version: number | undefined; camera: string } | null = null;\n return {\n drew(view) {\n camera = `${view.x},${view.y},${view.scale.x},${view.scale.y}`;\n },\n changed() {\n const now = { version: version?.(), camera };\n const moved = seen !== null && (seen.version !== now.version || seen.camera !== now.camera);\n seen = now;\n return moved;\n },\n };\n}\n","interface Point { x: number; y: number }\n\nconst POINTER_ENDS = ['pointerup', 'pointercancel', 'lostpointercapture'] as const;\n\n/**\n * Aims a lens from the pointer moving over `input`, in CSS px relative to it. A gesture that begins where\n * `holds` answers true freezes the aim until it ends: the lens camera follows the aim, so re-aiming mid-drag\n * would move the world under the pointer. Returns a detach.\n */\nexport function followPointer(\n input: HTMLElement,\n lens: { aimAt(p: Point): void; holds(p: Point): boolean },\n): () => void {\n let holding = false;\n const local = (evt: PointerEvent): Point => {\n const r = input.getBoundingClientRect();\n return { x: evt.clientX - r.left, y: evt.clientY - r.top };\n };\n const onPointerMove = (evt: PointerEvent) => {\n if (!holding) lens.aimAt(local(evt));\n };\n const onPointerDown = (evt: PointerEvent) => {\n if (lens.holds(local(evt))) holding = true;\n };\n const onPointerEnd = () => { holding = false; };\n\n input.addEventListener('pointermove', onPointerMove);\n input.addEventListener('pointerdown', onPointerDown);\n for (const type of POINTER_ENDS) input.addEventListener(type, onPointerEnd);\n return () => {\n input.removeEventListener('pointermove', onPointerMove);\n input.removeEventListener('pointerdown', onPointerDown);\n for (const type of POINTER_ENDS) input.removeEventListener(type, onPointerEnd);\n };\n}\n","import { clamp } from '@weasel-js/geom';\n\n/**\n * Read a `rw × rh` device-pixel region of the drawing buffer centered on\n * `pointer`, returned top-down. `pointer` is in CSS px relative to `target`,\n * the rect of the buffer the canvas paints into (device px, top-left origin),\n * and the read is clamped to stay inside that rect.\n *\n * GL reports rows bottom-up; every consumer here wants top-down, so both the\n * read origin and the returned rows are flipped.\n */\nexport function readbackRegion(\n gl: WebGL2RenderingContext,\n bufferHeight: number,\n target: { x: number; y: number; width: number; height: number },\n pointer: { x: number; y: number },\n dpr: number,\n rw: number,\n rh: number,\n): ImageData {\n const cx = target.x + Math.round(pointer.x * dpr);\n const cy = target.y + Math.round(pointer.y * dpr);\n const gx = clamp(cx - Math.floor(rw / 2), target.x, target.x + Math.max(0, target.width - rw));\n const gyTop = clamp(cy - Math.floor(rh / 2), target.y, target.y + Math.max(0, target.height - rh));\n const gy = bufferHeight - gyTop - rh;\n\n const raw = new Uint8Array(rw * rh * 4);\n gl.readPixels(gx, gy, rw, rh, gl.RGBA, gl.UNSIGNED_BYTE, raw);\n\n const flipped = new Uint8ClampedArray(rw * rh * 4);\n const stride = rw * 4;\n for (let row = 0; row < rh; row++) {\n const src = (rh - 1 - row) * stride;\n flipped.set(raw.subarray(src, src + stride), row * stride);\n }\n return new ImageData(flipped, rw, rh);\n}\n","import {\n createViewportLayer, screenToWorld, viewToTransform,\n type CanvasViewHandle, type RenderLayer, type SceneCanvasApi, type View, type ViewAt,\n} from '@weasel-js/core';\nimport { releaseImageSource, type DrawCommand } from '@weasel-js/core/renderer';\nimport {\n createLoupeModel, loupeInnerView,\n type LoupeMode, type LoupeModel, type LoupeSurface,\n} from '@weasel-js/loupe';\nimport type { Hud } from '../hud';\nimport type { WindowWidget } from '../widgets/window/window';\nimport type { HudContentCtx, WidgetBounds } from '../widget';\nimport { createContentWatch } from './contentWatch';\nimport { followPointer } from './pointerAim';\nimport { readbackRegion } from './readback';\n\nexport type { LoupeMode };\n\n/** Options for `createLoupe` shared by a plain lens and an interactive one. */\nexport interface LoupeBaseOptions {\n hud: Hud;\n /** The canvas pixel mode reads back from. Supplies the GL context and the\n * drawing-buffer dimensions. */\n canvas: HTMLCanvasElement;\n /** Where the aim comes from: the element pointer events are taken from and\n * the rect client coords are measured against. Defaults to `canvas`, which\n * is right whenever the canvas is also the thing under the pointer. */\n input?: HTMLElement;\n /** The rect of `canvas` the magnified picture occupies, in its CSS px — the\n * one the aim is relative to. Pass `CanvasExtensionApi.getSurfaceRect` for\n * a pane painted into a shared canvas. Defaults to `views.getSurfaceRect`\n * when the lens is a view, and to the whole canvas otherwise. */\n region?: () => { x: number; y: number; width: number; height: number };\n requestRedraw: () => void;\n /**\n * The version of what the canvas paints, read on every landed frame: when it moves, a lens whose aim has not\n * reads the framebuffer and the color under it again. Pass `CanvasExtensionApi.getPaintedVersion`. Defaults to\n * `views.getPaintedVersion` when the lens is a view. Without one the lens follows an edit under a parked aim\n * only in vector mode, or when told through `refresh()`; a camera move it follows either way.\n */\n contentVersion?: () => number;\n mode?: LoupeMode;\n factor?: number;\n bounds?: WidgetBounds;\n title?: string;\n /** Draw the window's titlebar and close box. Default `true`. Pass `false`\n * for a bare lens; the interior then doubles as the move handle, or, for an\n * `interactive` lens, a grip strip across its top does. */\n titlebar?: boolean;\n /** Called with the hex color under the aim point whenever it changes.\n * Sampled from the framebuffer in both modes — vector content is a\n * re-render whose edge colors differ from the screen's, so reading the\n * color off it would report something the user cannot see. */\n onColorChange?: (hex: string) => void;\n /** Fired when a click inside the lens picks a color — an eyedropper on the\n * magnified surface. Where the color goes is the consumer's: the loupe\n * reports the pick and nothing else. An `interactive` lens gives its clicks\n * to the canvas, so only `pick()` reaches this. */\n onPick?: (hex: string) => void;\n /** Fired by the window's close box. The window does not hide itself —\n * whoever owns the loupe's visibility decides what closing means. */\n onClose?: () => void;\n /** Backdrop painted behind the magnified content in both modes, so the\n * outer canvas does not show through where the lens is empty. Defaults to\n * the theme's surface color. */\n background?: string;\n}\n\n/** Options for `createLoupe`. */\nexport type LoupeOptions = LoupeBaseOptions & (\n | {\n /** Layers re-rendered through the magnified inner view in vector mode. */\n source: RenderLayer<unknown>[];\n views?: undefined;\n interactive?: false;\n }\n | {\n /**\n * The canvas, as a host for views. The lens becomes a view on it: vector\n * mode paints the canvas's own stack — scene and selection chrome — and\n * the lens can take input. It magnifies the camera of whatever view is\n * under its aim: aimed over a `<CanvasView>` panel, it shows and edits\n * that panel's world at the panel's zoom times its own factor. A host\n * without `viewAt` gets the canvas's camera wherever it aims.\n */\n views: Pick<SceneCanvasApi, 'addView' | 'getSurfaceRect'> & Partial<Pick<SceneCanvasApi, 'getPaintedVersion' | 'viewAt'>>;\n /** Narrows what vector mode paints. Defaults to the canvas's stack. */\n source?: RenderLayer<unknown>[];\n /**\n * Route input inside the lens to what it shows: a press selects the node\n * magnified under the pointer, and a drag moves it by the pointer travel\n * divided by the magnification. Default `false` — the window keeps its\n * interior, and a click there picks a color.\n */\n interactive?: boolean;\n }\n);\n\nconst backdropOf = (ctx: HudContentCtx, color: string): DrawCommand => ({\n kind: 'path',\n path: { kind: 'rect', x: ctx.rect.x, y: ctx.rect.y, width: ctx.rect.w, height: ctx.rect.h },\n fill: { paint: { kind: 'solid', color } },\n});\n\n/** The id the lens's view takes on its canvas. */\nconst LENS_VIEW = 'weasel-loupe:lens';\n\n/** Where an interactive lens routes while its window is hidden: nowhere. */\nconst NO_RECT = { x: 0, y: 0, w: 0, h: 0 };\n\n/** The lens camera aimed at `aim`: magnifying the view under it, or the\n * canvas's own camera `outer` where no view is. */\nfunction lensCamera(\n aim: { x: number; y: number }, under: ViewAt | null, outer: View, rect: WidgetBounds, factor: number,\n): View {\n if (under && under.id !== null) {\n const world = {\n x: (aim.x - under.rect.x) / under.view.scale.x + under.view.x,\n y: (aim.y - under.rect.y) / under.view.scale.y + under.view.y,\n };\n return loupeInnerView(world, under.view, rect, factor);\n }\n const world = screenToWorld(aim.x, aim.y, viewToTransform(outer));\n return loupeInnerView({ x: world[0], y: world[1] }, outer, rect, factor);\n}\n\n/** Control surface for a live loupe: where it is aimed, how it magnifies,\n * what color it is over, and the window it lives in. */\nexport interface LoupeHandle {\n readonly window: WindowWidget;\n readonly mode: LoupeMode;\n readonly factor: number;\n /** Last aimed point, in screen-space CSS px relative to the canvas. */\n readonly aim: { x: number; y: number };\n /** Hex color under the aim point, read off the framebuffer on the first\n * frame to land after the aim. `null` until then, or when the GL context\n * is unavailable. */\n readonly color: string | null;\n setMode(mode: LoupeMode): void;\n setFactor(factor: number): void;\n /** Aim at a screen point. Ignored while the point is over the window —\n * that is the freeze rule that makes the borders reachable. */\n aimAt(p: { x: number; y: number }): void;\n /** Sample the color the lens is showing at `p` — a screen point inside the\n * lens — and report it to `onPick`. Omit `p` to pick at the aim point.\n * Returns the hex, or `null` when the framebuffer cannot answer for that\n * point, including before any frame has landed. Leaves the aim, and\n * `color`, alone. */\n pick(p?: { x: number; y: number }): string | null;\n /** Ask for a paint, and on the frame that lands read the picture and the color under the aim again: what is\n * under the aim changed in a way no `contentVersion` reports. */\n refresh(): void;\n dispose(): void;\n}\n\n/**\n * Build a magnifier: a HUD window whose interior shows the canvas around an\n * aim point, enlarged. Adds the window to the HUD and starts following the\n * pointer; `dispose` removes it again.\n */\nexport function createLoupe(opts: LoupeOptions): LoupeHandle {\n const { hud, canvas: element, requestRedraw } = opts;\n const host = opts.views;\n const interactive = host !== undefined && opts.interactive === true;\n const input = opts.input ?? element;\n let lens: CanvasViewHandle | null = null;\n let pixels: ImageBitmap | null = null;\n const dropPixels = () => {\n if (!pixels) return;\n releaseImageSource(pixels);\n pixels.close();\n pixels = null;\n };\n let pixelsPending = false;\n let refreshWanted = false;\n let disposed = false;\n // Until a paint lands, the context on a shared canvas may not exist yet, and\n // opening it here would give every tenant one with no stencil buffer.\n let landed = false;\n\n const b = opts.bounds ?? { x: 24, y: 24, w: 220, h: 200 };\n\n const watch = createContentWatch(opts.contentVersion ?? host?.getPaintedVersion);\n let refreshAsked = false;\n\n const content = (ctx: HudContentCtx): DrawCommand[] => {\n watch.drew(ctx.view);\n return model.mode === 'vector' ? drawVector(ctx) : drawPixels(ctx);\n };\n\n const backdropColor = (ctx: HudContentCtx): string =>\n opts.background ?? ctx.tokens['--wzl-surface'];\n const backdrop = (ctx: HudContentCtx): DrawCommand => backdropOf(ctx, backdropColor(ctx));\n\n const innerView = (outer: View, rect: WidgetBounds): View => (\n lensCamera(model.aim, host?.viewAt?.(model.aim, { except: LENS_VIEW }) ?? null, outer, rect, model.factor)\n );\n\n const drawVector = (ctx: HudContentCtx): DrawCommand[] => {\n if (host) return lens ? [backdrop(ctx), ...lens.draw(ctx.data, ctx.view, ctx.dims)] : [backdrop(ctx)];\n // A fresh lens per frame: CreateViewportLayerOpts.view is static, and the\n // inner view moves with the pointer.\n const picture = createViewportLayer<unknown>({\n id: `${win.id}:lens`,\n label: 'Loupe content',\n source: opts.source ?? [],\n view: innerView(ctx.view, ctx.rect),\n bounds: () => ctx.rect,\n background: backdropColor(ctx),\n });\n return picture.draw(ctx.data, ctx.view, ctx.dims);\n };\n\n const drawPixels = (ctx: HudContentCtx): DrawCommand[] => {\n // The backdrop paints even with a bitmap in hand: a readback of a\n // transparent framebuffer is transparent, and before the first one\n // settles there is nothing at all, either of which leaves the lens a\n // hole onto the unmagnified canvas.\n const out: DrawCommand[] = [backdrop(ctx)];\n if (pixels) {\n out.push({\n kind: 'image',\n image: pixels,\n x: ctx.rect.x, y: ctx.rect.y, w: ctx.rect.w, h: ctx.rect.h,\n sampling: 'nearest',\n });\n }\n return out;\n };\n\n // `gl.readPixels` outside a landed paint returns the *previous* frame, so an\n // aim only marks the lens dirty; the read itself happens in the frame\n // subscriber below, on the frame that painted.\n const scheduleRefresh = () => {\n if (disposed || model.mode !== 'pixel') return;\n refreshWanted = true;\n };\n\n /** Read device px of the loupe's region around `at`, sized for the\n * canvas's pixel ratio, or `null` when the framebuffer cannot answer. */\n const read = (\n at: { x: number; y: number },\n rw: (dpr: number) => number,\n rh: (dpr: number) => number,\n ): ImageData | null => {\n if (!landed) return null;\n const gl = element.getContext('webgl2');\n if (!gl) return null;\n const cssRect = element.getBoundingClientRect();\n if (cssRect.width === 0) return null;\n const dpr = element.width / cssRect.width;\n // A view-backed lens knows its canvas, so over a detached pane it reads\n // that pane's pixels without being told where the pane is.\n const r = (opts.region ?? host?.getSurfaceRect)?.();\n const target = r\n ? {\n x: Math.round(r.x * dpr), y: Math.round(r.y * dpr),\n width: Math.round(r.width * dpr), height: Math.round(r.height * dpr),\n }\n : { x: 0, y: 0, width: element.width, height: element.height };\n return readbackRegion(gl, element.height, target, at, dpr, rw(dpr), rh(dpr));\n };\n\n const refreshPixels = () => {\n if (disposed || model.mode !== 'pixel') return;\n const rect = win.contentRect;\n const data = read(\n model.aim,\n (dpr) => Math.max(1, Math.round((rect.w * dpr) / model.factor)),\n (dpr) => Math.max(1, Math.round((rect.h * dpr) / model.factor)),\n );\n if (!data) return;\n pixelsPending = true;\n createImageBitmap(data)\n .then((bmp) => {\n if (disposed) { bmp.close(); return; }\n dropPixels();\n pixels = bmp;\n pixelsPending = false;\n requestRedraw();\n })\n .catch(() => {\n pixelsPending = false;\n requestRedraw();\n });\n };\n\n const readHex = (at: { x: number; y: number }): string | null => {\n const px = read(at, () => 1, () => 1);\n if (!px || px.data[3] === 0) return null;\n return '#' + [px.data[0], px.data[1], px.data[2]]\n .map((c) => c.toString(16).padStart(2, '0')).join('');\n };\n\n const win = hud.window({\n id: 'weasel-loupe',\n x: b.x, y: b.y, w: b.w, h: b.h,\n title: opts.title ?? 'Loupe',\n titlebar: opts.titlebar,\n content,\n interior: interactive ? 'pass' : 'claim',\n onResize: () => { scheduleRefresh(); },\n ...(interactive ? {} : { onContentClick: (p: { x: number; y: number }) => { model.pick(p); } }),\n ...(opts.onClose ? { onClose: opts.onClose } : {}),\n });\n\n const surface: LoupeSurface = {\n lens: () => win.contentRect,\n covers: (p) => win.hitTest(p.x, p.y) || (win.passes?.(p.x, p.y) ?? false),\n sample: readHex,\n hidden: () => win.hidden,\n gone: () => win.disposed === true,\n changed: () => { scheduleRefresh(); requestRedraw(); },\n subscribeFrame: hud.subscribeFrame,\n };\n\n // Subscribed ahead of the model, so the frame that lands first is already\n // readable by the time the model samples on it.\n const unsubscribeFrame = hud.subscribeFrame(() => {\n landed = true;\n if (watch.changed() || refreshAsked) {\n refreshAsked = false;\n scheduleRefresh();\n model.resample();\n }\n // A refresh wanted while a bitmap is in flight is remembered rather than\n // dropped: the flag survives until a frame finds it settled, so the aim\n // the user ends a fast drag on is the one that gets read.\n if (!refreshWanted || pixelsPending) return;\n refreshWanted = false;\n refreshPixels();\n });\n\n const model: LoupeModel = createLoupeModel({\n surface,\n ...(opts.mode ? { mode: opts.mode } : {}),\n ...(opts.factor !== undefined ? { factor: opts.factor } : {}),\n ...(opts.onColorChange ? { onColorChange: opts.onColorChange } : {}),\n ...(opts.onPick ? { onPick: opts.onPick } : {}),\n onDispose: () => teardown(),\n });\n\n if (host) {\n lens = host.addView({\n id: LENS_VIEW,\n label: 'Loupe',\n bounds: () => (win.hidden ? NO_RECT : win.contentRect),\n view: (outer) => innerView(outer, win.contentRect),\n paint: false,\n interactive,\n ...(opts.source ? { layers: () => opts.source! } : {}),\n });\n }\n\n const unfollow = followPointer(input, {\n aimAt: (p) => model.aimAt(p),\n holds: (p) => interactive && surface.covers(p),\n });\n\n const teardown = () => {\n disposed = true;\n unsubscribeFrame();\n unfollow();\n lens?.remove();\n lens = null;\n dropPixels();\n };\n\n return {\n window: win,\n get mode() { return model.mode; },\n get factor() { return model.factor; },\n get aim() { return model.aim; },\n get color() { return model.color; },\n setMode: model.setMode,\n setFactor: model.setFactor,\n aimAt: model.aimAt,\n pick: model.pick,\n refresh() {\n if (disposed) return;\n refreshAsked = true;\n requestRedraw();\n },\n dispose() {\n model.dispose();\n win.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAIA,SAASkB,GAAQ,GAAmB,GAAyB;CAG3D,OAFIC,EAAE,SAAS,WAAiB,GAAGA,EAAE,MAAM,IAAIC,GAAeC,EAAE,YAAYF,CAAC,GAAGA,CAAC,MAC7EA,EAAE,SAAS,UAAgB,GAAGA,EAAE,MAAM,IAAIA,EAAE,SAAS,QAClDA,EAAE;AACX;AAGA,SAASG,EAAM,GAAmB,GAAiC;CACjE,IAAMC,IAAQF,EAAE,MAAM,GAChBG,IAAUC,MAAOF,EAAM,SAAS;CACtC,OAAOF,EAAE,UAAUI,CAAE,CAAC,CAAC,KAAK,GAAG,MAAyB;EACtD,IAAIN,EAAE,SAAS,aAAa,OAAO;GAAE,MAAM;GAAa,KAAKA,EAAE;EAAI;EACnE,IAAMO,IAAYP,EAAE,SAAS,UAAUA,EAAE,YAAY,KAAA,GAC/CQ,IAAOR,EAAE,SAAS,aAAaI,EAAME,OAAQG,KAAKL,EAAM,SAASE,IAAK;EAC5E,OAAO;GACL,MAAMC,IAAY,qBAAqB;GACvC,KAAKP,EAAE;GACP,OAAOD,GAAQG,GAAGF,CAAC;GACnB,GAAIK,KAAWD,EAAME,OAAQG,IAAI,EAAE,QAAQ,GAAK,IAAI,CAAC;GACrD,GAAIT,EAAE,SAAS,UAAUA,EAAE,YAAY,KAAA,IAAY,EAAE,SAASA,EAAE,QAAQ,IAAI,CAAC;GAC7E,GAAIA,EAAE,YAAYA,EAAE,SAAS,UAAU,E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OAAOA,EAAM;EAAK;EAC9B,IAAI,QAAQ;GAAE,OAAOA,EAAM;EAAO;EAClC,SAASA,EAAM;EACf,WAAWA,EAAM;EACjB,OAAOA,EAAM;EACb,MAAMA,EAAM;EACZ,UAAU;GACR,AAAIlF,MACJ,IAAe,IACfgG,EAAc;EAChB;EACA,UAAU;GAER,AADAd,EAAM,QAAQ,GACdO,EAAI,QAAQ;EACd;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":["solid","pathFromD","pathFromD","solid","loupeInnerView","registerDefaultFont","cursorForZone","createRevision","isFocusable","DEFAULT_WIDGET_CLAIMS","createHudContribution","createHud","attachHud","DEFAULT_WINDOW_METRICS","HUD_AFFORDANCE_KIND","claimsOf","pathFromD$1","loupeInnerView$1","labelOf","e","menuNumberText","c","level","stack","deepest","at","checkable","open","i","accessibleMenu","BLUR_LAYERS","BLUR_LAYER_ALPHA","solid$2","roundRectD","k","r","w","h","x","y","outer","rect","b","roundRectPath","s","radius","p","color","children","step","inset","margin","hole","ring","boxShadowCommands","under","over","innerRadius","padding","layers","resolveCurrentColor","current","ROOT","INHERITED","tags","m","body","attrs","a","num","v","d","nums","transformOf","identity","fn","args","next","translate","scale","rotateAboutPoint","multiply","arcRectD","rx","ry","ellipseD","cx","cy","shapeD","name","pts","paintOf","shapeCommands","out","fill","cmd","path","alpha","stroke","dash","frameFor","parent","t","group","mat3","glyphCommands","root","skipping","glyph","top","f","cmds","numberChips","end","panelW","chipAt","inside","plus","minus","valueRowWidth","measure","solid$1","mark","pathFromD","numberCommands","cell","live","ink","low","value","menuNumberCanStep","high","textCommandFromRuns","textCommands","colorCommands","DEFAULT_MENU_METRICS","rowLayout","entries","row","shortcutOf","formatShortcut","panelSize","last","text","chip","solid","caret","check","ICON_SIZE","PANEL_SHADOW","drawPanel","ctx","fg","muted","tokenPx","font","shadow","parseBoxShadow","expandVars","rows","highlight","iconX","iconY","ref","toIconRef","icons","shown","rowAt","estimateWidth","fontSize","measureLabel","metrics","metricsOf","resolveFontVariant","fontFamily","units","prev","ch","cp","createPlacer","placed","measured","faces","faceGeneration","opts","bounds","width","height","kept","parentRow","old","size","placeMenuUnder","placeMenu","placeSubmenu","CLAIMS","underOnCanvas","toCanvas","createMenuWidget","rev","createMenuController","withLinks","href","place","family","panels","disposed","armed","hoverPanel","levelAt","union","x0","y0","x1","y1","enter","pointer","evt","choose","index","dir","key","accessibleTree","attachMenuHost","widget","returnTo","drop","hud","giveBack","sync","host","held","dismiss","wheel","unsubscribe","unfocus","createContentWatch","camera","seen","view","now","version","moved","POINTER_ENDS","followPointer","holding","local","input","onPointerMove","lens","onPointerDown","onPointerEnd","type","readbackRegion","target","dpr","gx","clamp","rw","gy","bufferHeight","rh","raw","gl","flipped","stride","src","backdropOf","LENS_VIEW","NO_RECT","lensCamera","world","aim","factor","screenToWorld","viewToTransform","createLoupe","element","interactive","pixels","dropPixels","releaseImageSource","pixelsPending","refreshWanted","landed","watch","refreshAsked","content","model","drawVector","drawPixels","backdropColor","backdrop","innerView","createViewportLayer","win","scheduleRefresh","read","cssRect","refreshPixels","data","bmp","requestRedraw","readHex","px","surface","unsubscribeFrame","createLoupeModel","teardown","unfollow","DEFAULT_FONT_FAMILY","loupeInnerView"],"sources":["../src/menu/accessibleMenu.ts","../src/boxShadow.ts","../src/glyph.ts","../src/menu/valueRows.ts","../src/menu/drawPanel.ts","../src/menu/measureLabel.ts","../src/menu/placePanels.ts","../src/menu/menuWidget.ts","../src/menu/attachMenuHost.ts","../src/loupe/contentWatch.ts","../src/loupe/pointerAim.ts","../src/loupe/readback.ts","../src/loupe/createLoupe.ts"],"sourcesContent":["import { menuNumberText, type MenuController, type MenuRowEntry } from '@weasel-js/menu';\nimport type { HudAccessibleNode } from '../widget';\n\n/** A row's name: a value row's label and the value it holds now. */\nfunction labelOf(c: MenuController, e: MenuRowEntry): string {\n if (e.kind === 'number') return `${e.label}: ${menuNumberText(c.numberValue(e), e)}`;\n if (e.kind === 'color') return `${e.label}: ${e.value ?? '—'}`;\n if (e.kind === 'text') return `${e.label}: ${c.textValue(e) ?? '—'}`;\n return e.label;\n}\n\n/** One level's rows, with the open submenu nested under the row it hangs from. */\nfunction level(c: MenuController, at: number): HudAccessibleNode[] {\n const stack = c.stack();\n const deepest = at === stack.length - 1;\n return c.entriesAt(at).map((e, i): HudAccessibleNode => {\n if (e.kind === 'separator') return { role: 'separator', key: e.key };\n const checkable = e.kind === 'item' && e.checked !== undefined;\n const open = e.kind === 'submenu' && stack[at] === i && stack.length > at + 1;\n return {\n role: checkable ? 'menuitemcheckbox' : 'menuitem',\n key: e.key,\n label: labelOf(c, e),\n ...(deepest && stack[at] === i ? { active: true } : {}),\n ...(e.kind === 'item' && e.checked !== undefined ? { checked: e.checked } : {}),\n ...(e.disabled || e.kind === 'color' || e.kind === 'text' ? { disabled: true } : {}),\n ...(e.kind === 'submenu' ? { expanded: open } : {}),\n ...(open ? { children: [{ role: 'menu', key: 'menu', label: e.label, children: level(c, at + 1) }] } : {}),\n };\n });\n}\n\n/** An open menu as the accessibility tree a DOM menu's panels show: rows with their roles and states, and the\n * highlighted row of the innermost open level active. */\nexport function accessibleMenu(c: MenuController): HudAccessibleNode {\n return { role: 'menu', key: 'menu', label: 'Context menu', children: level(c, 0) };\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, roundRectPath, type Path } from '@weasel-js/geom';\nimport { resolveCurrentColor, type BoxShadow } from '@weasel-js/theme';\nimport type { WidgetBounds } from './widget';\n\n// A blurred layer is drawn as nested rounded rects reaching blur / 2 either side of its edge,\n// whose overlap builds the falloff.\nconst BLUR_LAYERS = 7;\nconst BLUR_LAYER_ALPHA = 0.16;\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\n\nfunction roundRectD(x: number, y: number, w: number, h: number, r: number): string {\n const k = Math.max(0, Math.min(r, w / 2, h / 2));\n if (k === 0) return `M ${x} ${y} H ${x + w} V ${y + h} H ${x} Z`;\n return `M ${x + k} ${y} H ${x + w - k} A ${k} ${k} 0 0 1 ${x + w} ${y + k} V ${y + h - k} `\n + `A ${k} ${k} 0 0 1 ${x + w - k} ${y + h} H ${x + k} A ${k} ${k} 0 0 1 ${x} ${y + h - k} `\n + `V ${y + k} A ${k} ${k} 0 0 1 ${x + k} ${y} Z`;\n}\n\nfunction outer(b: WidgetBounds, radius: number, s: BoxShadow, color: string): DrawCommand {\n const rect = (e: number): Path | null => {\n const w = b.w + e * 2;\n const h = b.h + e * 2;\n return w > 0 && h > 0 ? roundRectPath(b.x + s.x - e, b.y + s.y - e, w, h, Math.max(0, radius + e)) : null;\n };\n if (s.blur <= 0) {\n const p = rect(s.spread);\n return { kind: 'group', children: p ? [{ kind: 'path', path: p, fill: solid(color) }] : [] };\n }\n const children: DrawCommand[] = [];\n const step = s.blur / (BLUR_LAYERS - 1);\n for (let i = 0; i < BLUR_LAYERS; i++) {\n const p = rect(s.spread + s.blur / 2 - i * step);\n if (p) children.push({ kind: 'path', path: p, fill: solid(color) });\n }\n return { kind: 'group', alpha: BLUR_LAYER_ALPHA, children };\n}\n\n/** An inset layer, hard-edged whatever its blur: the box less itself moved by the offset and shrunk by the spread. */\nfunction inset(b: WidgetBounds, radius: number, s: BoxShadow, color: string): DrawCommand {\n const margin = Math.abs(s.x) + Math.abs(s.y) + Math.abs(s.spread) + 1;\n const hole = roundRectD(b.x + s.x + s.spread, b.y + s.y + s.spread, b.w - s.spread * 2, b.h - s.spread * 2,\n Math.max(0, radius - s.spread));\n const ring = pathFromD(`${roundRectD(b.x - margin, b.y - margin, b.w + margin * 2, b.h + margin * 2, 0)} ${hole}`);\n return {\n kind: 'group',\n clip: roundRectPath(b.x, b.y, b.w, b.h, radius),\n children: [{ kind: 'path', path: ring.kind === 'polygon' ? { ...ring, fillRule: 'evenodd' } : ring, fill: solid(color) }],\n };\n}\n\n/**\n * A CSS `box-shadow` list cast by a rounded box, as draw commands: `under` goes beneath the box's\n * face and `over` on top of it, for `inset` layers, which fall inside `padding` (the box less its\n * border). Layers draw last-first, so the first is topmost, as in CSS. `current` is what a layer\n * written in `currentColor` takes.\n */\nexport function boxShadowCommands(\n b: WidgetBounds, radius: number, layers: readonly BoxShadow[], current: string, padding: WidgetBounds = b,\n): { under: DrawCommand[]; over: DrawCommand[] } {\n const under: DrawCommand[] = [];\n const over: DrawCommand[] = [];\n const innerRadius = Math.max(0, radius - (padding.x - b.x));\n for (const s of [...layers].reverse()) {\n const color = resolveCurrentColor(s.color, current);\n if (s.inset) over.push(inset(padding, innerRadius, s, color));\n else under.push(outer(b, radius, s, color));\n }\n return { under, over };\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport {\n identity, mat3, multiply, pathFromD, rotateAboutPoint, scale, translate, type Affine, type Path,\n} from '@weasel-js/geom';\nimport type { IconGlyph } from '@weasel-js/icons';\n\n/** The attributes a glyph's elements inherit, as `<Icon>`'s root `<svg>` sets them. */\nconst ROOT: Readonly<Record<string, string>> = {\n fill: 'none', stroke: 'currentColor', 'stroke-width': '1.5',\n 'stroke-linecap': 'round', 'stroke-linejoin': 'round',\n};\n\nconst INHERITED = new Set([\n 'fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-width', 'stroke-opacity',\n 'stroke-linecap', 'stroke-linejoin', 'stroke-dasharray',\n]);\n\n/** What a glyph is drawn in the place of `currentColor` with, and where. */\nexport interface GlyphPlacement {\n x: number;\n y: number;\n /** Width and height; the glyph's 20×20 viewBox scales to it. */\n size: number;\n color: string;\n}\n\ninterface Tag { close: boolean; name: string; attrs: Record<string, string>; selfClosing: boolean }\n\nfunction* tags(body: string): Generator<Tag> {\n for (const m of body.matchAll(/<(\\/?)([a-zA-Z]+)((?:\\s+[\\w:-]+=\"[^\"]*\")*)\\s*(\\/?)>/g)) {\n const attrs: Record<string, string> = {};\n for (const a of m[3]!.matchAll(/([\\w:-]+)=\"([^\"]*)\"/g)) attrs[a[1]!] = a[2]!;\n yield { close: m[1] === '/', name: m[2]!, attrs, selfClosing: m[4] === '/' };\n }\n}\n\nconst num = (v: string | undefined, d = 0) => (v === undefined || v === '' ? d : Number(v));\nconst nums = (v: string) => v.trim().split(/[\\s,]+/).filter((s) => s !== '').map(Number);\n\n/** An SVG `transform` list as one affine. */\nfunction transformOf(v: string | undefined): Affine {\n let m = identity();\n if (!v) return m;\n for (const [, fn, args] of v.matchAll(/(\\w+)\\s*\\(([^)]*)\\)/g)) {\n const a = nums(args!);\n const next: Affine | null = fn === 'translate' ? translate(a[0] ?? 0, a[1] ?? 0)\n : fn === 'scale' ? scale(a[0] ?? 1, a[1] ?? a[0] ?? 1)\n : fn === 'rotate' ? rotateAboutPoint(a[1] ?? 0, a[2] ?? 0, ((a[0] ?? 0) * Math.PI) / 180)\n : fn === 'matrix' && a.length === 6 ? (a as unknown as Affine) : null;\n if (next) m = multiply(m, next);\n }\n return m;\n}\n\nfunction arcRectD(x: number, y: number, w: number, h: number, rx: number, ry: number): string {\n if (rx <= 0 || ry <= 0) return `M ${x} ${y} H ${x + w} V ${y + h} H ${x} Z`;\n return `M ${x + rx} ${y} H ${x + w - rx} A ${rx} ${ry} 0 0 1 ${x + w} ${y + ry} V ${y + h - ry} `\n + `A ${rx} ${ry} 0 0 1 ${x + w - rx} ${y + h} H ${x + rx} A ${rx} ${ry} 0 0 1 ${x} ${y + h - ry} `\n + `V ${y + ry} A ${rx} ${ry} 0 0 1 ${x + rx} ${y} Z`;\n}\n\nconst ellipseD = (cx: number, cy: number, rx: number, ry: number) =>\n `M ${cx - rx} ${cy} A ${rx} ${ry} 0 1 0 ${cx + rx} ${cy} A ${rx} ${ry} 0 1 0 ${cx - rx} ${cy} Z`;\n\n/** A shape element's outline as path data, or undefined for an element that draws none. */\nfunction shapeD(name: string, a: Readonly<Record<string, string>>): string | undefined {\n switch (name) {\n case 'path': return a.d;\n case 'rect': {\n const w = num(a.width), h = num(a.height);\n const rx = Math.min(num(a.rx, num(a.ry)), w / 2), ry = Math.min(num(a.ry, num(a.rx)), h / 2);\n return arcRectD(num(a.x), num(a.y), w, h, rx, ry);\n }\n case 'circle': return ellipseD(num(a.cx), num(a.cy), num(a.r), num(a.r));\n case 'ellipse': return ellipseD(num(a.cx), num(a.cy), num(a.rx), num(a.ry));\n case 'line': return `M ${num(a.x1)} ${num(a.y1)} L ${num(a.x2)} ${num(a.y2)}`;\n case 'polygon':\n case 'polyline': {\n const p = nums(a.points ?? '');\n if (p.length < 4) return undefined;\n const pts = [];\n for (let i = 0; i + 1 < p.length; i += 2) pts.push(`${p[i]} ${p[i + 1]}`);\n return `M ${pts.join(' L ')}${name === 'polygon' ? ' Z' : ''}`;\n }\n default: return undefined;\n }\n}\n\nconst paintOf = (v: string | undefined, color: string): string | null =>\n (v === undefined || v === 'none' ? null : /^currentcolor$/i.test(v) ? color : v);\n\n/** One shape's commands: its fill, then its stroke, each at its own opacity. */\nfunction shapeCommands(path: Path, a: Readonly<Record<string, string>>, color: string): DrawCommand[] {\n const out: DrawCommand[] = [];\n const fill = paintOf(a.fill, color);\n if (fill) {\n const p = path.kind === 'polygon' && a['fill-rule'] === 'evenodd' ? { ...path, fillRule: 'evenodd' as const } : path;\n const cmd: DrawCommand = { kind: 'path', path: p, fill: { paint: { kind: 'solid', color: fill } } };\n const alpha = num(a['fill-opacity'], 1);\n out.push(alpha < 1 ? { kind: 'group', alpha, children: [cmd] } : cmd);\n }\n const stroke = paintOf(a.stroke, color);\n if (stroke) {\n const dash = a['stroke-dasharray'] && a['stroke-dasharray'] !== 'none' ? nums(a['stroke-dasharray']) : undefined;\n const cmd: DrawCommand = {\n kind: 'path', path,\n stroke: {\n paint: { kind: 'solid', color: stroke },\n width: num(a['stroke-width'], 1),\n cap: a['stroke-linecap'] as 'butt' | 'round' | 'square' | undefined,\n join: a['stroke-linejoin'] as 'miter' | 'round' | 'bevel' | undefined,\n ...(dash ? { dash } : {}),\n },\n };\n const alpha = num(a['stroke-opacity'], 1);\n out.push(alpha < 1 ? { kind: 'group', alpha, children: [cmd] } : cmd);\n }\n return out;\n}\n\ninterface Frame { attrs: Readonly<Record<string, string>>; children: DrawCommand[]; group: DrawCommand & { kind: 'group' } }\n\nfunction frameFor(t: Tag, parent: Readonly<Record<string, string>>): Frame {\n const attrs = { ...parent };\n for (const [k, v] of Object.entries(t.attrs)) if (INHERITED.has(k)) attrs[k] = v;\n const children: DrawCommand[] = [];\n const group: Frame['group'] = { kind: 'group', children };\n const m = transformOf(t.attrs.transform);\n if (m.some((v, i) => v !== identity()[i])) group.transform = mat3.fromAffine(m);\n // Every nested `<svg>` a glyph uses has a viewBox matching its own box, so it only clips.\n if (t.name === 'svg') {\n group.clip = { kind: 'rect', x: num(t.attrs.x), y: num(t.attrs.y), width: num(t.attrs.width), height: num(t.attrs.height) };\n }\n return { attrs, children, group };\n}\n\n/**\n * A glyph as draw commands, placed in a square and drawn in `color` wherever it says\n * `currentColor`, as `<Icon>` draws it in the DOM. Reads the elements the icon tables use — `path`,\n * `rect`, `circle`, `ellipse`, `line`, `polygon`, `polyline`, `g` and a nested `svg` — with their\n * presentation attributes and transforms. `defs` and what they hold are skipped, so a `clip-path`\n * pointing into them does not clip.\n */\nexport function glyphCommands(glyph: IconGlyph, at: GlyphPlacement): DrawCommand[] {\n const k = at.size / 20;\n const root: Frame = {\n attrs: ROOT, children: [],\n group: { kind: 'group', transform: mat3.fromAffine([k, 0, 0, k, at.x, at.y]), children: [] },\n };\n root.group.children = root.children;\n const stack: Frame[] = [root];\n let skipping = 0;\n for (const t of tags(glyph.body)) {\n const top = stack.at(-1)!;\n if (skipping > 0 || t.name === 'defs' || t.name === 'clipPath') {\n if (!t.selfClosing) skipping += t.close ? -1 : 1;\n continue;\n }\n if (t.close) {\n if ((t.name === 'g' || t.name === 'svg') && stack.length > 1) stack.pop();\n continue;\n }\n if (t.name === 'g' || t.name === 'svg') {\n const f = frameFor(t, top.attrs);\n top.children.push(f.group);\n if (!t.selfClosing) stack.push(f);\n continue;\n }\n const d = shapeD(t.name, t.attrs);\n if (d === undefined) continue;\n const f = frameFor(t, top.attrs);\n const cmds = shapeCommands(pathFromD(d), f.attrs, at.color);\n if (f.group.transform) top.children.push({ kind: 'group', transform: f.group.transform, children: cmds });\n else top.children.push(...cmds);\n }\n return [root.group];\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, textCommandFromRuns } from '@weasel-js/core';\nimport { menuNumberCanStep, menuNumberText, type MenuColorEntry, type MenuEntry, type MenuNumberEntry } from '@weasel-js/menu';\nimport type { WidgetBounds } from '../widget';\nimport type { MenuMetrics } from './drawPanel';\n\n/** A span across a panel, from its left edge. */\nexport interface Span { x: number; w: number }\n\n/**\n * Where a number row's step chips and value sit, at the row's end: a minus chip, the value in a cell of fixed\n * width so a changing value moves nothing, and a plus chip. `width` is all three.\n */\nexport function numberChips(panelW: number, m: MenuMetrics): { minus: Span; value: Span; plus: Span; width: number } {\n const s = m.rowHeight;\n const end = panelW - m.padX;\n return { minus: { x: end - 4 * s, w: s }, value: { x: end - 3 * s, w: 2 * s }, plus: { x: end - s, w: s }, width: 4 * s };\n}\n\n/** Which way the chip under panel-local `x` steps a number row: 1, -1, or null off both. */\nexport function chipAt(panelW: number, m: MenuMetrics, x: number): 1 | -1 | null {\n const { minus, plus } = numberChips(panelW, m);\n const inside = (s: Span) => x >= s.x && x < s.x + s.w;\n return inside(plus) ? 1 : inside(minus) ? -1 : null;\n}\n\n/** What a value row needs past its label, for sizing the panel; undefined for any other row. */\nexport function valueRowWidth(e: MenuEntry, m: MenuMetrics, measure: (text: string, fontSize: number) => number): number | undefined {\n if (e.kind === 'number') return m.padX + numberChips(0, m).width;\n if (e.kind === 'color') return Math.max(m.rowHeight, m.padX + measure(e.value ?? '—', m.fontSize));\n if (e.kind === 'text') return m.padX + measure(e.value ?? '—', m.fontSize);\n return undefined;\n}\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\nconst mark = (d: string, color: string): DrawCommand => ({\n kind: 'path', path: pathFromD(d), stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round' },\n});\n\n/** The colors and font a value row draws in. */\nexport interface ValueInk { fg: string; muted: string; border: string; font: { fontFamily: string; fontSize: number } }\n\n/** A number row's chips and value. A chip with nowhere to step to is muted, as is all of a disabled row. */\nexport function numberCommands(\n b: WidgetBounds, r: { y: number; h: number }, e: MenuNumberEntry, value: number | undefined, m: MenuMetrics, ink: ValueInk,\n): DrawCommand[] {\n const { minus, value: cell, plus } = numberChips(b.w, m);\n const cy = b.y + r.y + r.h / 2;\n const color = (live: boolean) => (live && !e.disabled ? ink.fg : ink.muted);\n const cx = (s: Span) => b.x + s.x + s.w / 2;\n const low = value !== undefined && !menuNumberCanStep(e, value, -1);\n const high = value !== undefined && !menuNumberCanStep(e, value, 1);\n return [\n mark(`M ${cx(minus) - 4} ${cy} L ${cx(minus) + 4} ${cy}`, color(!low)),\n textCommandFromRuns(\n b.x + cell.x, b.y + r.y, [{ text: menuNumberText(value, e), fill: solid(color(true)) }],\n { ...ink.font, align: 'center' }, undefined, r.h, 'center', undefined, cell.w,\n ),\n mark(`M ${cx(plus) - 4} ${cy} L ${cx(plus) + 4} ${cy} M ${cx(plus)} ${cy - 4} L ${cx(plus)} ${cy + 4}`, color(!high)),\n ];\n}\n\n/** A text row's value at the row's end, muted: nothing in a HUD menu edits it. */\nexport function textCommands(\n b: WidgetBounds, r: { y: number; h: number }, value: string | undefined, m: MenuMetrics, ink: ValueInk,\n): DrawCommand[] {\n return [textCommandFromRuns(\n b.x + m.padX, b.y + r.y, [{ text: value ?? '—', fill: solid(ink.muted) }],\n { ...ink.font, align: 'right' }, undefined, r.h, 'center', undefined, b.w - m.padX * 2,\n )];\n}\n\n/** The swatch a color row draws in its icon column, and its hex at the row's end. */\nexport function colorCommands(\n b: WidgetBounds, r: { y: number; h: number }, e: MenuColorEntry, m: MenuMetrics, ink: ValueInk,\n): DrawCommand[] {\n const out: DrawCommand[] = [];\n if (e.value !== undefined) {\n const size = 12;\n const x = b.x + m.padX + (m.rowHeight - size) / 2;\n const y = b.y + r.y + (r.h - size) / 2;\n out.push({\n kind: 'path', path: { kind: 'rect', x, y, width: size, height: size },\n fill: solid(e.value), stroke: { paint: { kind: 'solid', color: ink.border }, width: 1 },\n });\n }\n out.push(textCommandFromRuns(\n b.x + m.padX, b.y + r.y, [{ text: e.value ?? '—', fill: solid(ink.muted) }],\n { ...ink.font, align: 'right' }, undefined, r.h, 'center', undefined, b.w - m.padX * 2,\n ));\n return out;\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, textCommandFromRuns } from '@weasel-js/core';\nimport { roundRectPath } from '@weasel-js/geom';\nimport { formatShortcut } from '@weasel-js/gestures';\nimport type { MenuEntry, MenuNumberEntry } from '@weasel-js/menu';\nimport { expandVars, parseBoxShadow, resolveCurrentColor, tokenPx } from '@weasel-js/theme';\nimport { toIconRef, type IconRegistry } from '@weasel-js/icons';\nimport { boxShadowCommands } from '../boxShadow';\nimport { glyphCommands } from '../glyph';\nimport type { HudDrawCtx, WidgetBounds } from '../widget';\nimport { colorCommands, numberCommands, textCommands, valueRowWidth } from './valueRows';\n\n/** Sizes of a HUD menu panel, in CSS pixels. */\nexport interface MenuMetrics {\n rowHeight: number;\n padX: number;\n padY: number;\n separatorHeight: number;\n minWidth: number;\n fontSize: number;\n}\n\n/** The metrics a menu widget uses when given none, close to the DOM menu's. */\nexport const DEFAULT_MENU_METRICS: MenuMetrics = {\n rowHeight: 24, padX: 8, padY: 4, separatorHeight: 9, minWidth: 180, fontSize: 13,\n};\n\n/** Each entry's y offset and height inside a panel. */\nexport function rowLayout(entries: readonly MenuEntry[], m: MenuMetrics): { y: number; h: number }[] {\n let y = m.padY;\n return entries.map((e) => {\n const h = e.kind === 'separator' ? m.separatorHeight : m.rowHeight;\n const row = { y, h };\n y += h;\n return row;\n });\n}\n\n/** A row's shortcut as the DOM menu prints it, or undefined. */\nconst shortcutOf = (e: MenuEntry): string | undefined =>\n (e.kind === 'item' ? formatShortcut(e.shortcut) : undefined);\n\n/** A panel's size: its widest row — label, then a shortcut or the caret column —\n * plus the icon column, never under `minWidth`. */\nexport function panelSize(\n entries: readonly MenuEntry[], m: MenuMetrics, measure: (text: string, fontSize: number) => number,\n): { w: number; h: number } {\n const rows = rowLayout(entries, m);\n const last = rows.at(-1);\n const rowWidth = (e: MenuEntry) => {\n if (e.kind === 'separator') return 0;\n const value = valueRowWidth(e, m, measure);\n if (value !== undefined) return measure(e.label, m.fontSize) + value;\n const chip = shortcutOf(e);\n return measure(e.label, m.fontSize) + Math.max(m.rowHeight, chip ? m.padX + measure(chip, m.fontSize) : 0);\n };\n const text = Math.max(0, ...entries.map(rowWidth));\n return {\n w: Math.max(m.minWidth, Math.ceil(text) + m.padX * 2 + m.rowHeight),\n h: (last ? last.y + last.h : 0) + m.padY,\n };\n}\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\nconst rect = (x: number, y: number, width: number, height: number, color: string): DrawCommand => ({\n kind: 'path', path: { kind: 'rect', x, y, width, height }, fill: solid(color),\n});\n\n/** A right-pointing chevron centered on (cx, cy). The bundled atlas has no `›` glyph. */\nfunction caret(cx: number, cy: number, color: string): DrawCommand {\n const s = 3;\n return {\n kind: 'path',\n path: pathFromD(`M ${cx - s / 2} ${cy - s} L ${cx + s / 2} ${cy} L ${cx - s / 2} ${cy + s}`),\n stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round' },\n };\n}\n\n/** A check mark centered on (cx, cy), for a row whose action is on. */\nfunction check(cx: number, cy: number, color: string): DrawCommand {\n return {\n kind: 'path',\n path: pathFromD(`M ${cx - 4} ${cy} L ${cx - 1.5} ${cy + 2.5} L ${cx + 4} ${cy - 3}`),\n stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round', join: 'round' },\n };\n}\n\n/** Where a menu finds the glyph a row's `icon` names: an icon registry, or anything answering as one. */\nexport type MenuIcons = Pick<IconRegistry, 'get' | 'getVersion'>;\n\n/** The DOM row draws its icon at 16px. */\nconst ICON_SIZE = 16;\n\n// The shadow `.surface` in ui's listbox.module.css gives the DOM panel.\nconst PANEL_SHADOW = 'var(--wzl-bevel-raised, 0 8px 24px var(--wzl-shadow))';\n\n/** One panel's commands: its rounded face and the DOM panel's box shadow, a highlight behind row\n * `highlight`, and every row, with the glyph `icons` holds for each row's icon. A number row shows what\n * `shown` says it holds, by default what it opened with. */\nexport function drawPanel(\n ctx: HudDrawCtx, b: WidgetBounds, entries: readonly MenuEntry[], highlight: number | null, m: MenuMetrics,\n icons?: MenuIcons, shown: (e: MenuNumberEntry) => number | undefined = (e) => e.value,\n): DrawCommand[] {\n const t = ctx.tokens;\n const fg = t['--wzl-fg'];\n const muted = resolveCurrentColor(t['--wzl-fg-muted'], fg);\n const radius = tokenPx('--wzl-radius-md', t);\n const font = { fontFamily: ctx.defaultFont, fontSize: m.fontSize };\n const shadow = boxShadowCommands(b, radius, parseBoxShadow(expandVars(PANEL_SHADOW, t)), fg,\n { x: b.x + 1, y: b.y + 1, w: b.w - 2, h: b.h - 2 });\n const out: DrawCommand[] = [...shadow.under, {\n kind: 'path',\n path: roundRectPath(b.x, b.y, b.w, b.h, radius),\n fill: solid(t['--wzl-surface-popover']),\n stroke: { paint: { kind: 'solid', color: t['--wzl-border'] }, width: 1 },\n }, ...shadow.over];\n const rows = rowLayout(entries, m);\n entries.forEach((e, i) => {\n const r = rows[i]!;\n if (e.kind === 'separator') {\n out.push(rect(b.x + m.padX, b.y + r.y + Math.floor(r.h / 2), b.w - m.padX * 2, 1, t['--wzl-border']));\n return;\n }\n if (i === highlight) out.push(rect(b.x + 2, b.y + r.y, b.w - 4, r.h, t['--wzl-surface-hover']));\n // Nothing here edits a color or a text row, so each reads as a disabled one does.\n const color = e.disabled || e.kind === 'color' || e.kind === 'text' ? muted : fg;\n out.push(textCommandFromRuns(\n b.x + m.padX + m.rowHeight, b.y + r.y,\n [{ text: e.label, fill: solid(color) }],\n font, undefined, r.h, 'center',\n ));\n const iconX = b.x + m.padX + m.rowHeight / 2;\n const iconY = b.y + r.y + r.h / 2;\n const ref = e.kind !== 'color' && typeof e.icon === 'string' ? toIconRef(e.icon) : undefined;\n const glyph = ref ? icons?.get(ref) : undefined;\n if (e.kind === 'item' && e.checked) out.push(check(iconX, iconY, color));\n else if (glyph) out.push(...glyphCommands(glyph, { x: iconX - ICON_SIZE / 2, y: iconY - ICON_SIZE / 2, size: ICON_SIZE, color }));\n const chip = shortcutOf(e);\n if (chip) {\n out.push(textCommandFromRuns(\n b.x + m.padX, b.y + r.y, [{ text: chip, fill: solid(muted) }],\n { ...font, align: 'right' }, undefined, r.h, 'center', undefined, b.w - m.padX * 2,\n ));\n }\n const ink = { fg, muted, border: t['--wzl-border'], font };\n if (e.kind === 'number') out.push(...numberCommands(b, r, e, shown(e), m, ink));\n if (e.kind === 'color') out.push(...colorCommands(b, r, e, m, ink));\n if (e.kind === 'text') out.push(...textCommands(b, r, e.value, m, ink));\n if (e.kind === 'submenu') out.push(caret(b.x + b.w - m.padX - m.rowHeight / 2, b.y + r.y + r.h / 2, color));\n });\n return out;\n}\n\n/** Index of the entry under panel-local `y`, or null. */\nexport function rowAt(entries: readonly MenuEntry[], m: MenuMetrics, y: number): number | null {\n const i = rowLayout(entries, m).findIndex((r) => y >= r.y && y < r.y + r.h);\n return i < 0 ? null : i;\n}\n","import { metricsOf, resolveFontVariant } from '@weasel-js/font';\n\n/** A width for `text` with no face to measure it in. */\nexport function estimateWidth(text: string, fontSize: number): number {\n return text.length * fontSize * 0.55;\n}\n\n/** Width of `text` at `fontSize` in `fontFamily`, from the advances and\n * kerning of the face the text command lays it out with. A face not loaded\n * yet gives an estimate; `faceGeneration` moves when it lands. */\nexport function measureLabel(text: string, fontSize: number, fontFamily: string): number {\n const metrics = metricsOf(resolveFontVariant(fontFamily, 400, 'normal'));\n if (!metrics) return estimateWidth(text, fontSize);\n let units = 0;\n let prev: number | null = null;\n for (const ch of text) {\n const cp = ch.codePointAt(0)!;\n units += metrics.advanceOf(cp) ?? metrics.size * 0.55;\n if (prev !== null) units += metrics.kernOf(prev, cp);\n prev = cp;\n }\n return units * fontSize / metrics.size;\n}\n","import { placeMenu, placeMenuUnder, placeSubmenu, type MenuController, type MenuEntry, type Rect } from '@weasel-js/menu';\nimport { faceGeneration } from '@weasel-js/font';\nimport { panelSize, rowLayout, type MenuMetrics } from './drawPanel';\nimport { estimateWidth } from './measureLabel';\n\ntype XY = { x: number; y: number };\n\n/** What placing needs: where the menu opened, the canvas, and how to measure. */\nexport interface PlaceOptions {\n anchor: XY;\n /** The button the menu hangs from, in canvas pixels; when set, `anchor` is not used. */\n under?: Rect;\n canvasSize(): { width: number; height: number };\n measure(text: string, fontSize: number, fontFamily: string): number;\n metrics: MenuMetrics;\n}\n\ninterface Placed {\n entries: readonly MenuEntry[];\n parentRow: number | null;\n rect: Rect;\n}\n\n/**\n * Places each open level once, when it opens: a level keeps its rect for as\n * long as its entries and the parent row it hangs from stay the same. A new\n * font family, or a face landing, re-measures everything. With no family yet\n * — the hud has not drawn — widths are estimated rather than measured in a\n * guessed family.\n */\nexport function createPlacer(opts: PlaceOptions): (c: MenuController, fontFamily: string | null) => Rect[] {\n let placed: Placed[] = [];\n let measured: { family: string | null; faces: number } | null = null;\n\n return (c, fontFamily) => {\n const faces = faceGeneration();\n if (measured?.family !== fontFamily || measured.faces !== faces) {\n placed = [];\n measured = { family: fontFamily, faces };\n }\n const { width, height } = opts.canvasSize();\n const bounds = { x: 0, y: 0, w: width, h: height };\n const m = opts.metrics;\n const stack = c.stack();\n const next: Placed[] = [];\n let kept = true;\n for (let level = 0; level < stack.length; level++) {\n const entries = c.entriesAt(level);\n const parentRow = level === 0 ? null : stack[level - 1] ?? null;\n const old = placed[level];\n if (kept && old && old.entries === entries && old.parentRow === parentRow) {\n next.push(old);\n continue;\n }\n kept = false;\n const size = panelSize(entries, m, (t, s) => (fontFamily === null ? estimateWidth(t, s) : opts.measure(t, s, fontFamily)));\n let at: XY;\n if (level === 0) {\n at = opts.under ? placeMenuUnder(size, opts.under, bounds) : placeMenu(size, opts.anchor, bounds);\n } else {\n const parent = next[level - 1]!.rect;\n const row = rowLayout(c.entriesAt(level - 1), m)[parentRow!]!;\n at = placeSubmenu(size, { x: parent.x, y: parent.y + row.y, w: parent.w, h: row.h }, bounds);\n }\n const rect = { x: at.x, y: at.y, w: size.w, h: size.h };\n next.push({ entries, parentRow, rect });\n c.setPanel(level, rect);\n }\n placed = next;\n return next.map((p) => p.rect);\n };\n}\n","import { createMenuController, withLinks, type Rect } from '@weasel-js/menu';\nimport { faceGeneration } from '@weasel-js/font';\nimport type { ClaimableGesture, OpenMenu } from '@weasel-js/core';\nimport { createRevision, type HudAccessibleTree, type HudKeyEvent, type HudPointerEvent, type Widget, type WidgetBounds } from '../widget';\nimport { accessibleMenu } from './accessibleMenu';\nimport { DEFAULT_MENU_METRICS, drawPanel, rowAt, type MenuIcons, type MenuMetrics } from './drawPanel';\nimport { measureLabel } from './measureLabel';\nimport { createPlacer } from './placePanels';\nimport { chipAt } from './valueRows';\nimport type { Point } from '@weasel-js/geom';\n\nconst CLAIMS: readonly ClaimableGesture[] = ['pointer', 'doubleClick', 'contextMenu', 'longPress', 'wheel'];\n\n/** What {@link createMenuWidget} needs: the open menu, how to close it, and the canvas it draws on. */\nexport interface MenuWidgetOptions {\n open: OpenMenu;\n /** The menu is done: an item was chosen, or it was dismissed. */\n close(): void;\n /** Viewport point to canvas CSS pixels, for `open.client` and `open.under`. */\n toCanvas(client: Point): Point;\n canvasSize(): { width: number; height: number };\n /** Width of a label in the family the hud draws with. Defaults to the\n * registered face's own advances, which is what the text is laid out with. */\n measure?(text: string, fontSize: number, fontFamily: string): number;\n metrics?: MenuMetrics;\n /** Where a row's icon is looked up; without it no row draws one. */\n icons?: MenuIcons;\n onChange(): void;\n}\n\nfunction underOnCanvas(r: Rect, toCanvas: (client: Point) => Point): Rect {\n const a = toCanvas({ x: r.x, y: r.y });\n const b = toCanvas({ x: r.x + r.w, y: r.y + r.h });\n return { x: a.x, y: a.y, w: b.x - a.x, h: b.y - a.y };\n}\n\n/** A widget that draws `open` as one panel per open level, driven by a menu controller it owns. */\nexport function createMenuWidget(opts: MenuWidgetOptions): Widget {\n const m = opts.metrics ?? DEFAULT_MENU_METRICS;\n const rev = createRevision(opts.onChange);\n const c = createMenuController({\n entries: withLinks(opts.open.entries, (href) => window.location.assign(href)),\n highlightFirst: opts.open.source === 'keyboard', onClose: opts.close,\n });\n const place = createPlacer({\n anchor: opts.toCanvas(opts.open.client),\n ...(opts.open.under ? { under: underOnCanvas(opts.open.under, opts.toCanvas) } : {}),\n canvasSize: opts.canvasSize,\n measure: opts.measure ?? measureLabel, metrics: m,\n });\n // The hud's font is known only once it draws.\n let family: string | null = null;\n let panels: Rect[] = place(c, family);\n let disposed = false;\n let armed = false;\n let hoverPanel: number | null = null;\n c.subscribe(() => { panels = place(c, family); rev.changed(); });\n\n /** The topmost panel under (x, y), or -1. */\n const levelAt = (x: number, y: number): number => {\n for (let i = panels.length - 1; i >= 0; i--) {\n const p = panels[i]!;\n if (x >= p.x && x < p.x + p.w && y >= p.y && y < p.y + p.h) return i;\n }\n return -1;\n };\n\n const union = (): WidgetBounds => {\n const x0 = Math.min(...panels.map((p) => p.x));\n const y0 = Math.min(...panels.map((p) => p.y));\n const x1 = Math.max(...panels.map((p) => p.x + p.w));\n const y1 = Math.max(...panels.map((p) => p.y + p.h));\n return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };\n };\n\n /** The pointer is now over `level` (null: no panel). Leaving a panel clears\n * its row, as the DOM menu's per-panel `pointerleave` does. */\n const enter = (level: number | null) => {\n if (hoverPanel !== null && hoverPanel !== level) c.hover(hoverPanel, null);\n hoverPanel = level;\n };\n\n const pointer = (evt: HudPointerEvent) => {\n if (evt.type === 'hoverleave') { enter(null); return; }\n if (evt.type === 'cancel') { armed = false; return; }\n if (evt.type === 'down') { armed = true; return; }\n if (evt.type !== 'hovermove' && evt.type !== 'move' && evt.type !== 'up') return;\n const level = levelAt(evt.x, evt.y);\n // Only a release that follows a press here chooses: the release of the\n // right-click or long-press that opened the menu must not.\n const choose = evt.type === 'up' && armed;\n if (evt.type === 'up') armed = false;\n if (!choose) enter(level < 0 ? null : level);\n if (level < 0) return;\n const entries = c.entriesAt(level);\n const index = rowAt(entries, m, evt.y - panels[level]!.y);\n if (!choose) c.hover(level, index, { x: evt.x, y: evt.y });\n else if (index !== null) {\n c.press(level, index);\n // A number row's chips step it, since this menu has no field to type in.\n const e = entries[index];\n const dir = e?.kind === 'number' ? chipAt(panels[level]!.w, m, evt.x - panels[level]!.x) : null;\n if (e?.kind === 'number' && dir !== null) c.spin(e, dir > 0 ? 'ArrowUp' : 'ArrowDown');\n }\n };\n\n const key = (evt: HudKeyEvent): boolean => {\n if (evt.type !== 'keydown') return false;\n if (!evt.ctrlKey && !evt.metaKey && !evt.altKey) c.key(evt.key);\n // Every key belongs to the open menu, so no canvas binding fires under it.\n return true;\n };\n\n const accessibleTree: HudAccessibleTree = { read: () => accessibleMenu(c), subscribe: c.subscribe };\n\n return {\n id: `weasel-menu-${opts.open.seq}`,\n get bounds() { return union(); },\n hidden: false,\n get disposed() { return disposed; },\n claims: CLAIMS,\n focusable: true,\n focusRing: false,\n accessibleName: 'Context menu',\n accessibleTree,\n deps: (ctx) => [...rev.deps(), ctx.defaultFont, faceGeneration(), opts.icons?.getVersion()],\n draw: (ctx) => {\n family = ctx.defaultFont;\n panels = place(c, family);\n return panels.flatMap((p, level) => drawPanel(ctx, p, c.entriesAt(level), c.stack()[level] ?? null, m, opts.icons, c.numberValue));\n },\n hitTest: (x, y) => levelAt(x, y) >= 0,\n cursorAt: () => 'default',\n onPointer: pointer,\n onKey: key,\n dispose() { disposed = true; c.dispose(); },\n };\n}\n","import type { MenuHost } from '@weasel-js/core';\nimport type { Hud } from '../hud';\nimport type { Widget } from '../widget';\nimport { createMenuWidget, type MenuWidgetOptions } from './menuWidget';\n\n/** What {@link attachMenuHost} needs beyond the hud and host. */\nexport type AttachMenuHostOptions =\n Pick<MenuWidgetOptions, 'toCanvas' | 'canvasSize' | 'measure' | 'metrics' | 'icons'>;\n\n/** Draw `host`'s open menu as a widget on `hud`, focused while open. A press\n * anywhere else takes focus from it, which closes the menu, as do a wheel\n * outside it, the window losing focus and a resize. Closing any other way\n * gives focus back to the widget that held it when the menu opened. Returns a detach. */\nexport function attachMenuHost(hud: Hud, host: MenuHost, opts: AttachMenuHostOptions): () => void {\n let widget: Widget | null = null;\n let returnTo: { widget: Widget | null; visible: boolean } = { widget: null, visible: false };\n\n // Cleared before removal: removing the focused widget blurs it, and that\n // blur must not read as a press elsewhere.\n const drop = () => {\n const w = widget;\n widget = null;\n if (!w) return;\n hud.remove(w);\n if (!w.disposed) w.dispose();\n };\n\n const giveBack = () => {\n const { widget: w, visible } = returnTo;\n returnTo = { widget: null, visible: false };\n if (w) hud.focus(w, { visible });\n };\n\n const sync = () => {\n const open = host.current();\n if (!widget) returnTo = { widget: hud.focused, visible: hud.focusVisible };\n const held = widget !== null && hud.focused === widget;\n drop();\n if (!open) {\n if (held) giveBack();\n return;\n }\n const w = createMenuWidget({\n ...opts, open,\n close: () => { if (host.current() === open) host.close(); },\n onChange: () => hud.markDirty(),\n });\n widget = w;\n hud.add(w);\n // A menu that cannot take focus could never be dismissed, so it does not open.\n if (!hud.focus(w)) { drop(); host.close(); }\n };\n\n const dismiss = () => { if (widget) host.close(); };\n const wheel = (e: WheelEvent) => {\n if (!widget) return;\n const p = opts.toCanvas({ x: e.clientX, y: e.clientY });\n if (!widget.hitTest(p.x, p.y)) host.close();\n };\n\n const unsubscribe = host.subscribe(sync);\n const unfocus = hud.subscribeFocus((f) => { if (widget && f !== widget) host.close(); });\n window.addEventListener('wheel', wheel, { capture: true, passive: true });\n window.addEventListener('blur', dismiss);\n window.addEventListener('resize', dismiss);\n sync();\n return () => {\n unsubscribe();\n unfocus();\n window.removeEventListener('wheel', wheel, true);\n window.removeEventListener('blur', dismiss);\n window.removeEventListener('resize', dismiss);\n drop();\n };\n}\n","import type { View } from '@weasel-js/core';\n\n/** Says whether what a lens reads from changed between one landed frame and the next. */\nexport interface ContentWatch {\n /** The camera the lens was just drawn through. */\n drew(view: View): void;\n /** Whether the content version or the camera differs from the last time this was asked. The first ask only\n * takes its bearings, and answers `false`. */\n changed(): boolean;\n}\n\n/**\n * Watches the two things that change the pixels under an aim that holds still: the content, through `version`\n * when the lens is given one, and the camera it is drawn through. A lens redrawing itself moves neither, which is\n * what lets it read the framebuffer again on a change without that read's own redraw asking for another.\n */\nexport function createContentWatch(version: (() => number) | undefined): ContentWatch {\n let camera = '';\n let seen: { version: number | undefined; camera: string } | null = null;\n return {\n drew(view) {\n camera = `${view.x},${view.y},${view.scale.x},${view.scale.y}`;\n },\n changed() {\n const now = { version: version?.(), camera };\n const moved = seen !== null && (seen.version !== now.version || seen.camera !== now.camera);\n seen = now;\n return moved;\n },\n };\n}\n","interface Point { x: number; y: number }\n\nconst POINTER_ENDS = ['pointerup', 'pointercancel', 'lostpointercapture'] as const;\n\n/**\n * Aims a lens from the pointer moving over `input`, in CSS px relative to it. A gesture that begins where\n * `holds` answers true freezes the aim until it ends: the lens camera follows the aim, so re-aiming mid-drag\n * would move the world under the pointer. Returns a detach.\n */\nexport function followPointer(\n input: HTMLElement,\n lens: { aimAt(p: Point): void; holds(p: Point): boolean },\n): () => void {\n let holding = false;\n const local = (evt: PointerEvent): Point => {\n const r = input.getBoundingClientRect();\n return { x: evt.clientX - r.left, y: evt.clientY - r.top };\n };\n const onPointerMove = (evt: PointerEvent) => {\n if (!holding) lens.aimAt(local(evt));\n };\n const onPointerDown = (evt: PointerEvent) => {\n if (lens.holds(local(evt))) holding = true;\n };\n const onPointerEnd = () => { holding = false; };\n\n input.addEventListener('pointermove', onPointerMove);\n input.addEventListener('pointerdown', onPointerDown);\n for (const type of POINTER_ENDS) input.addEventListener(type, onPointerEnd);\n return () => {\n input.removeEventListener('pointermove', onPointerMove);\n input.removeEventListener('pointerdown', onPointerDown);\n for (const type of POINTER_ENDS) input.removeEventListener(type, onPointerEnd);\n };\n}\n","import { clamp } from '@weasel-js/geom';\n\n/**\n * Read a `rw × rh` device-pixel region of the drawing buffer centered on\n * `pointer`, returned top-down. `pointer` is in CSS px relative to `target`,\n * the rect of the buffer the canvas paints into (device px, top-left origin),\n * and the read is clamped to stay inside that rect.\n *\n * GL reports rows bottom-up; every consumer here wants top-down, so both the\n * read origin and the returned rows are flipped.\n */\nexport function readbackRegion(\n gl: WebGL2RenderingContext,\n bufferHeight: number,\n target: { x: number; y: number; width: number; height: number },\n pointer: { x: number; y: number },\n dpr: number,\n rw: number,\n rh: number,\n): ImageData {\n const cx = target.x + Math.round(pointer.x * dpr);\n const cy = target.y + Math.round(pointer.y * dpr);\n const gx = clamp(cx - Math.floor(rw / 2), target.x, target.x + Math.max(0, target.width - rw));\n const gyTop = clamp(cy - Math.floor(rh / 2), target.y, target.y + Math.max(0, target.height - rh));\n const gy = bufferHeight - gyTop - rh;\n\n const raw = new Uint8Array(rw * rh * 4);\n gl.readPixels(gx, gy, rw, rh, gl.RGBA, gl.UNSIGNED_BYTE, raw);\n\n const flipped = new Uint8ClampedArray(rw * rh * 4);\n const stride = rw * 4;\n for (let row = 0; row < rh; row++) {\n const src = (rh - 1 - row) * stride;\n flipped.set(raw.subarray(src, src + stride), row * stride);\n }\n return new ImageData(flipped, rw, rh);\n}\n","import {\n createViewportLayer, screenToWorld, viewToTransform,\n type CanvasViewHandle, type RenderLayer, type SceneCanvasApi, type View, type ViewAt,\n} from '@weasel-js/core';\nimport { releaseImageSource, type DrawCommand } from '@weasel-js/core/renderer';\nimport {\n createLoupeModel, loupeInnerView,\n type LoupeMode, type LoupeModel, type LoupeSurface,\n} from '@weasel-js/loupe';\nimport type { Hud } from '../hud';\nimport type { WindowWidget } from '../widgets/window/window';\nimport type { HudContentCtx, WidgetBounds } from '../widget';\nimport { createContentWatch } from './contentWatch';\nimport { followPointer } from './pointerAim';\nimport { readbackRegion } from './readback';\n\nexport type { LoupeMode };\n\n/** Options for `createLoupe` shared by a plain lens and an interactive one. */\nexport interface LoupeBaseOptions {\n hud: Hud;\n /** The canvas pixel mode reads back from. Supplies the GL context and the\n * drawing-buffer dimensions. */\n canvas: HTMLCanvasElement;\n /** Where the aim comes from: the element pointer events are taken from and\n * the rect client coords are measured against. Defaults to `canvas`, which\n * is right whenever the canvas is also the thing under the pointer. */\n input?: HTMLElement;\n /** The rect of `canvas` the magnified picture occupies, in its CSS px — the\n * one the aim is relative to. Pass `CanvasExtensionApi.getSurfaceRect` for\n * a pane painted into a shared canvas. Defaults to `views.getSurfaceRect`\n * when the lens is a view, and to the whole canvas otherwise. */\n region?: () => { x: number; y: number; width: number; height: number };\n requestRedraw: () => void;\n /**\n * The version of what the canvas paints, read on every landed frame: when it moves, a lens whose aim has not\n * reads the framebuffer and the color under it again. Pass `CanvasExtensionApi.getPaintedVersion`. Defaults to\n * `views.getPaintedVersion` when the lens is a view. Without one the lens follows an edit under a parked aim\n * only in vector mode, or when told through `refresh()`; a camera move it follows either way.\n */\n contentVersion?: () => number;\n mode?: LoupeMode;\n factor?: number;\n bounds?: WidgetBounds;\n title?: string;\n /** Draw the window's titlebar and close box. Default `true`. Pass `false`\n * for a bare lens; the interior then doubles as the move handle, or, for an\n * `interactive` lens, a grip strip across its top does. */\n titlebar?: boolean;\n /** Called with the hex color under the aim point whenever it changes.\n * Sampled from the framebuffer in both modes — vector content is a\n * re-render whose edge colors differ from the screen's, so reading the\n * color off it would report something the user cannot see. */\n onColorChange?: (hex: string) => void;\n /** Fired when a click inside the lens picks a color — an eyedropper on the\n * magnified surface. Where the color goes is the consumer's: the loupe\n * reports the pick and nothing else. An `interactive` lens gives its clicks\n * to the canvas, so only `pick()` reaches this. */\n onPick?: (hex: string) => void;\n /** Fired by the window's close box. The window does not hide itself —\n * whoever owns the loupe's visibility decides what closing means. */\n onClose?: () => void;\n /** Backdrop painted behind the magnified content in both modes, so the\n * outer canvas does not show through where the lens is empty. Defaults to\n * the theme's surface color. */\n background?: string;\n}\n\n/** Options for `createLoupe`. */\nexport type LoupeOptions = LoupeBaseOptions & (\n | {\n /** Layers re-rendered through the magnified inner view in vector mode. */\n source: RenderLayer<unknown>[];\n views?: undefined;\n interactive?: false;\n }\n | {\n /**\n * The canvas, as a host for views. The lens becomes a view on it: vector\n * mode paints the canvas's own stack — scene and selection chrome — and\n * the lens can take input. It magnifies the camera of whatever view is\n * under its aim: aimed over a `<CanvasView>` panel, it shows and edits\n * that panel's world at the panel's zoom times its own factor. A host\n * without `viewAt` gets the canvas's camera wherever it aims.\n */\n views: Pick<SceneCanvasApi, 'addView' | 'getSurfaceRect'> & Partial<Pick<SceneCanvasApi, 'getPaintedVersion' | 'viewAt'>>;\n /** Narrows what vector mode paints. Defaults to the canvas's stack. */\n source?: RenderLayer<unknown>[];\n /**\n * Route input inside the lens to what it shows: a press selects the node\n * magnified under the pointer, and a drag moves it by the pointer travel\n * divided by the magnification. Default `false` — the window keeps its\n * interior, and a click there picks a color.\n */\n interactive?: boolean;\n }\n);\n\nconst backdropOf = (ctx: HudContentCtx, color: string): DrawCommand => ({\n kind: 'path',\n path: { kind: 'rect', x: ctx.rect.x, y: ctx.rect.y, width: ctx.rect.w, height: ctx.rect.h },\n fill: { paint: { kind: 'solid', color } },\n});\n\n/** The id the lens's view takes on its canvas. */\nconst LENS_VIEW = 'weasel-loupe:lens';\n\n/** Where an interactive lens routes while its window is hidden: nowhere. */\nconst NO_RECT = { x: 0, y: 0, w: 0, h: 0 };\n\n/** The lens camera aimed at `aim`: magnifying the view under it, or the\n * canvas's own camera `outer` where no view is. */\nfunction lensCamera(\n aim: { x: number; y: number }, under: ViewAt | null, outer: View, rect: WidgetBounds, factor: number,\n): View {\n if (under && under.id !== null) {\n const world = {\n x: (aim.x - under.rect.x) / under.view.scale.x + under.view.x,\n y: (aim.y - under.rect.y) / under.view.scale.y + under.view.y,\n };\n return loupeInnerView(world, under.view, rect, factor);\n }\n const world = screenToWorld(aim.x, aim.y, viewToTransform(outer));\n return loupeInnerView({ x: world[0], y: world[1] }, outer, rect, factor);\n}\n\n/** Control surface for a live loupe: where it is aimed, how it magnifies,\n * what color it is over, and the window it lives in. */\nexport interface LoupeHandle {\n readonly window: WindowWidget;\n readonly mode: LoupeMode;\n readonly factor: number;\n /** Last aimed point, in screen-space CSS px relative to the canvas. */\n readonly aim: { x: number; y: number };\n /** Hex color under the aim point, read off the framebuffer on the first\n * frame to land after the aim. `null` until then, or when the GL context\n * is unavailable. */\n readonly color: string | null;\n setMode(mode: LoupeMode): void;\n setFactor(factor: number): void;\n /** Aim at a screen point. Ignored while the point is over the window —\n * that is the freeze rule that makes the borders reachable. */\n aimAt(p: { x: number; y: number }): void;\n /** Sample the color the lens is showing at `p` — a screen point inside the\n * lens — and report it to `onPick`. Omit `p` to pick at the aim point.\n * Returns the hex, or `null` when the framebuffer cannot answer for that\n * point, including before any frame has landed. Leaves the aim, and\n * `color`, alone. */\n pick(p?: { x: number; y: number }): string | null;\n /** Ask for a paint, and on the frame that lands read the picture and the color under the aim again: what is\n * under the aim changed in a way no `contentVersion` reports. */\n refresh(): void;\n dispose(): void;\n}\n\n/**\n * Build a magnifier: a HUD window whose interior shows the canvas around an\n * aim point, enlarged. Adds the window to the HUD and starts following the\n * pointer; `dispose` removes it again.\n */\nexport function createLoupe(opts: LoupeOptions): LoupeHandle {\n const { hud, canvas: element, requestRedraw } = opts;\n const host = opts.views;\n const interactive = host !== undefined && opts.interactive === true;\n const input = opts.input ?? element;\n let lens: CanvasViewHandle | null = null;\n let pixels: ImageBitmap | null = null;\n const dropPixels = () => {\n if (!pixels) return;\n releaseImageSource(pixels);\n pixels.close();\n pixels = null;\n };\n let pixelsPending = false;\n let refreshWanted = false;\n let disposed = false;\n // Until a paint lands, the context on a shared canvas may not exist yet, and\n // opening it here would give every tenant one with no stencil buffer.\n let landed = false;\n\n const b = opts.bounds ?? { x: 24, y: 24, w: 220, h: 200 };\n\n const watch = createContentWatch(opts.contentVersion ?? host?.getPaintedVersion);\n let refreshAsked = false;\n\n const content = (ctx: HudContentCtx): DrawCommand[] => {\n watch.drew(ctx.view);\n return model.mode === 'vector' ? drawVector(ctx) : drawPixels(ctx);\n };\n\n const backdropColor = (ctx: HudContentCtx): string =>\n opts.background ?? ctx.tokens['--wzl-surface'];\n const backdrop = (ctx: HudContentCtx): DrawCommand => backdropOf(ctx, backdropColor(ctx));\n\n const innerView = (outer: View, rect: WidgetBounds): View => (\n lensCamera(model.aim, host?.viewAt?.(model.aim, { except: LENS_VIEW }) ?? null, outer, rect, model.factor)\n );\n\n const drawVector = (ctx: HudContentCtx): DrawCommand[] => {\n if (host) return lens ? [backdrop(ctx), ...lens.draw(ctx.data, ctx.view, ctx.dims)] : [backdrop(ctx)];\n // A fresh lens per frame: CreateViewportLayerOpts.view is static, and the\n // inner view moves with the pointer.\n const picture = createViewportLayer<unknown>({\n id: `${win.id}:lens`,\n label: 'Loupe content',\n source: opts.source ?? [],\n view: innerView(ctx.view, ctx.rect),\n bounds: () => ctx.rect,\n background: backdropColor(ctx),\n });\n return picture.draw(ctx.data, ctx.view, ctx.dims);\n };\n\n const drawPixels = (ctx: HudContentCtx): DrawCommand[] => {\n // The backdrop paints even with a bitmap in hand: a readback of a\n // transparent framebuffer is transparent, and before the first one\n // settles there is nothing at all, either of which leaves the lens a\n // hole onto the unmagnified canvas.\n const out: DrawCommand[] = [backdrop(ctx)];\n if (pixels) {\n out.push({\n kind: 'image',\n image: pixels,\n x: ctx.rect.x, y: ctx.rect.y, w: ctx.rect.w, h: ctx.rect.h,\n sampling: 'nearest',\n });\n }\n return out;\n };\n\n // `gl.readPixels` outside a landed paint returns the *previous* frame, so an\n // aim only marks the lens dirty; the read itself happens in the frame\n // subscriber below, on the frame that painted.\n const scheduleRefresh = () => {\n if (disposed || model.mode !== 'pixel') return;\n refreshWanted = true;\n };\n\n /** Read device px of the loupe's region around `at`, sized for the\n * canvas's pixel ratio, or `null` when the framebuffer cannot answer. */\n const read = (\n at: { x: number; y: number },\n rw: (dpr: number) => number,\n rh: (dpr: number) => number,\n ): ImageData | null => {\n if (!landed) return null;\n const gl = element.getContext('webgl2');\n if (!gl) return null;\n const cssRect = element.getBoundingClientRect();\n if (cssRect.width === 0) return null;\n const dpr = element.width / cssRect.width;\n // A view-backed lens knows its canvas, so over a detached pane it reads\n // that pane's pixels without being told where the pane is.\n const r = (opts.region ?? host?.getSurfaceRect)?.();\n const target = r\n ? {\n x: Math.round(r.x * dpr), y: Math.round(r.y * dpr),\n width: Math.round(r.width * dpr), height: Math.round(r.height * dpr),\n }\n : { x: 0, y: 0, width: element.width, height: element.height };\n return readbackRegion(gl, element.height, target, at, dpr, rw(dpr), rh(dpr));\n };\n\n const refreshPixels = () => {\n if (disposed || model.mode !== 'pixel') return;\n const rect = win.contentRect;\n const data = read(\n model.aim,\n (dpr) => Math.max(1, Math.round((rect.w * dpr) / model.factor)),\n (dpr) => Math.max(1, Math.round((rect.h * dpr) / model.factor)),\n );\n if (!data) return;\n pixelsPending = true;\n createImageBitmap(data)\n .then((bmp) => {\n if (disposed) { bmp.close(); return; }\n dropPixels();\n pixels = bmp;\n pixelsPending = false;\n requestRedraw();\n })\n .catch(() => {\n pixelsPending = false;\n requestRedraw();\n });\n };\n\n const readHex = (at: { x: number; y: number }): string | null => {\n const px = read(at, () => 1, () => 1);\n if (!px || px.data[3] === 0) return null;\n return '#' + [px.data[0], px.data[1], px.data[2]]\n .map((c) => c.toString(16).padStart(2, '0')).join('');\n };\n\n const win = hud.window({\n id: 'weasel-loupe',\n x: b.x, y: b.y, w: b.w, h: b.h,\n title: opts.title ?? 'Loupe',\n titlebar: opts.titlebar,\n content,\n interior: interactive ? 'pass' : 'claim',\n onResize: () => { scheduleRefresh(); },\n ...(interactive ? {} : { onContentClick: (p: { x: number; y: number }) => { model.pick(p); } }),\n ...(opts.onClose ? { onClose: opts.onClose } : {}),\n });\n\n const surface: LoupeSurface = {\n lens: () => win.contentRect,\n covers: (p) => win.hitTest(p.x, p.y) || (win.passes?.(p.x, p.y) ?? false),\n sample: readHex,\n hidden: () => win.hidden,\n gone: () => win.disposed === true,\n changed: () => { scheduleRefresh(); requestRedraw(); },\n subscribeFrame: hud.subscribeFrame,\n };\n\n // Subscribed ahead of the model, so the frame that lands first is already\n // readable by the time the model samples on it.\n const unsubscribeFrame = hud.subscribeFrame(() => {\n landed = true;\n if (watch.changed() || refreshAsked) {\n refreshAsked = false;\n scheduleRefresh();\n model.resample();\n }\n // A refresh wanted while a bitmap is in flight is remembered rather than\n // dropped: the flag survives until a frame finds it settled, so the aim\n // the user ends a fast drag on is the one that gets read.\n if (!refreshWanted || pixelsPending) return;\n refreshWanted = false;\n refreshPixels();\n });\n\n const model: LoupeModel = createLoupeModel({\n surface,\n ...(opts.mode ? { mode: opts.mode } : {}),\n ...(opts.factor !== undefined ? { factor: opts.factor } : {}),\n ...(opts.onColorChange ? { onColorChange: opts.onColorChange } : {}),\n ...(opts.onPick ? { onPick: opts.onPick } : {}),\n onDispose: () => teardown(),\n });\n\n if (host) {\n lens = host.addView({\n id: LENS_VIEW,\n label: 'Loupe',\n bounds: () => (win.hidden ? NO_RECT : win.contentRect),\n view: (outer) => innerView(outer, win.contentRect),\n paint: false,\n interactive,\n ...(opts.source ? { layers: () => opts.source! } : {}),\n });\n }\n\n const unfollow = followPointer(input, {\n aimAt: (p) => model.aimAt(p),\n holds: (p) => interactive && surface.covers(p),\n });\n\n const teardown = () => {\n disposed = true;\n unsubscribeFrame();\n unfollow();\n lens?.remove();\n lens = null;\n dropPixels();\n };\n\n return {\n window: win,\n get mode() { return model.mode; },\n get factor() { return model.factor; },\n get aim() { return model.aim; },\n get color() { return model.color; },\n setMode: model.setMode,\n setFactor: model.setFactor,\n aimAt: model.aimAt,\n pick: model.pick,\n refresh() {\n if (disposed) return;\n refreshAsked = true;\n requestRedraw();\n },\n dispose() {\n model.dispose();\n win.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAIA,SAASkB,GAAQ,GAAmB,GAAyB;CAI3D,OAHIC,EAAE,SAAS,WAAiB,GAAGA,EAAE,MA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EKsQ,UAAiB;EAMrB,AALA,IAAW,IACXF,EAAiB,GACjBG,EAAS,GACT5D,GAAM,OAAO,GACb,IAAO,MACP+B,EAAW;CACb;CAEA,OAAO;EACL,QAAQe;EACR,IAAI,OAAO;GAAE,OAAOP,EAAM;EAAM;EAChC,IAAI,SAAS;GAAE,OAAOA,EAAM;EAAQ;EACpC,IAAI,MAAM;GAAE,OAAOA,EAAM;EAAK;EAC9B,IAAI,QAAQ;GAAE,OAAOA,EAAM;EAAO;EAClC,SAASA,EAAM;EACf,WAAWA,EAAM;EACjB,OAAOA,EAAM;EACb,MAAMA,EAAM;EACZ,UAAU;GACR,AAAIlF,MACJ,IAAe,IACfgG,EAAc;EAChB;EACA,UAAU;GAER,AADAd,EAAM,QAAQ,GACdO,EAAI,QAAQ;EACd;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"accessibleMenu.d.ts","sourceRoot":"","sources":["../../src/menu/accessibleMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,cAAc,EAAqB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AA8BnD;0DAC0D;AAC1D,wBAAgB,cAAc,CAAC,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAEnE"}
1
+ {"version":3,"file":"accessibleMenu.d.ts","sourceRoot":"","sources":["../../src/menu/accessibleMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,cAAc,EAAqB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AA+BnD;0DAC0D;AAC1D,wBAAgB,cAAc,CAAC,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAEnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"drawPanel.d.ts","sourceRoot":"","sources":["../../src/menu/drawPanel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BA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AAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAe1B;AA0BD,yGAAyG;AACzG,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,KAAK,GAAG,YAAY,CAAC,CAAC;AAQjE;;6DAE6D;AAC7D,wBAAgB,SAAS,CACvB,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,CAAC,EAAE,WAAW,EACzG,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,GAAE,CAAC,CAAC,EAAE,eAAe,KAAK,MAAM,GAAG,SAA0B,GACpF,WAAW,EAAE,CAiDf;AAED,yDAAyD;AACzD,wBAAgB,KAAK,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG7F"}
@@ -36,6 +36,11 @@ export declare function numberCommands(b: WidgetBounds, r: {
36
36
  y: number;
37
37
  h: number;
38
38
  }, e: MenuNumberEntry, value: number | undefined, m: MenuMetrics, ink: ValueInk): DrawCommand[];
39
+ /** A text row's value at the row's end, muted: nothing in a HUD menu edits it. */
40
+ export declare function textCommands(b: WidgetBounds, r: {
41
+ y: number;
42
+ h: number;
43
+ }, value: string | undefined, m: MenuMetrics, ink: ValueInk): DrawCommand[];
39
44
  /** The swatch a color row draws in its icon column, and its hex at the row's end. */
40
45
  export declare function colorCommands(b: WidgetBounds, r: {
41
46
  y: number;
@@ -1 +1 @@
1
- {"version":3,"file":"valueRows.d.ts","sourceRoot":"","sources":["../../src/menu/valueRows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAqC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB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a weasel canvas",
5
5
  "weasel": {
6
6
  "needs": ["webgl2"]
@@ -24,18 +24,18 @@
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": ">=18",
27
- "@weasel-js/core": "1.11.0",
28
- "@weasel-js/font": "1.11.0"
27
+ "@weasel-js/core": "1.11.1",
28
+ "@weasel-js/font": "1.11.1"
29
29
  },
30
30
  "dependencies": {
31
- "@weasel-js/geom": "1.11.0",
32
- "@weasel-js/gestures": "1.11.0",
33
- "@weasel-js/icons": "1.11.0",
34
- "@weasel-js/loupe": "1.11.0",
35
- "@weasel-js/menu": "1.11.0",
36
- "@weasel-js/paint": "1.11.0",
37
- "@weasel-js/registry": "1.11.0",
38
- "@weasel-js/theme": "1.11.0"
31
+ "@weasel-js/geom": "1.11.1",
32
+ "@weasel-js/gestures": "1.11.1",
33
+ "@weasel-js/icons": "1.11.1",
34
+ "@weasel-js/loupe": "1.11.1",
35
+ "@weasel-js/menu": "1.11.1",
36
+ "@weasel-js/paint": "1.11.1",
37
+ "@weasel-js/registry": "1.11.1",
38
+ "@weasel-js/theme": "1.11.1"
39
39
  },
40
40
  "author": "orochi235",
41
41
  "homepage": "https://orochi235.github.io/weasel/",