@vinena/knobs 0.5.3 → 0.6.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +7 -6
  3. package/dist/context-amfyasb5.js +23 -0
  4. package/dist/context-svtr7vwt.js +22 -0
  5. package/dist/early.global.js +5 -5
  6. package/dist/edit/css.d.ts +59 -0
  7. package/dist/edit/html.d.ts +91 -0
  8. package/dist/edit/keep.d.ts +175 -0
  9. package/dist/edit/log.d.ts +107 -0
  10. package/dist/edit/replay.d.ts +28 -0
  11. package/dist/edit/risk.d.ts +33 -0
  12. package/dist/edit/rule.d.ts +31 -0
  13. package/dist/edit/source.d.ts +12 -0
  14. package/dist/edit/text.d.ts +66 -0
  15. package/dist/elementsview-dm5v3z5a.js +3761 -0
  16. package/dist/elementsview-xm82cvs2.js +3762 -0
  17. package/dist/engine/dock.d.ts +3 -4
  18. package/dist/engine/frame.d.ts +1 -1
  19. package/dist/engine/style.d.ts +15 -0
  20. package/dist/{framekit-cjz0e4y8.js → framekit-622h6w1f.js} +54 -47
  21. package/dist/{framekit-yk1jxjv7.js → framekit-yx612r28.js} +54 -47
  22. package/dist/index-0zp9py56.js +859 -0
  23. package/dist/{index-prjpx67p.js → index-1mstjadm.js} +126 -2167
  24. package/dist/{index-begsqdm0.js → index-4a4x1bt2.js} +1 -1
  25. package/dist/index-58jdczmj.js +44 -0
  26. package/dist/index-5tv6sr74.js +23 -0
  27. package/dist/index-6bc2ztfd.js +688 -0
  28. package/dist/index-7cb4x1vj.js +1885 -0
  29. package/dist/index-a974q3aa.js +34 -0
  30. package/dist/{index-q73py563.js → index-aymfvd8s.js} +1 -1
  31. package/dist/{index-zt3rheck.js → index-aynkv7qk.js} +11 -8
  32. package/dist/{index-p57fdttx.js → index-dzm8ywq0.js} +492 -2365
  33. package/dist/{index-9jhatmky.js → index-f60yax1j.js} +13 -8
  34. package/dist/index-f67wctn3.js +1858 -0
  35. package/dist/{index-vgfn2n1h.js → index-ftjdt358.js} +8 -171
  36. package/dist/{index-j1h13ahg.js → index-gm51cthv.js} +2 -45
  37. package/dist/index-kfdzsyyw.js +1859 -0
  38. package/dist/index-t4kssacm.js +208 -0
  39. package/dist/index-v0ht9q0g.js +1518 -0
  40. package/dist/{index-6wbgqkdz.js → index-x59vz1xx.js} +247 -905
  41. package/dist/index-xh39jtkq.js +32 -0
  42. package/dist/index-yb7fc59g.js +718 -0
  43. package/dist/index-zd6adby9.js +496 -0
  44. package/dist/index.d.ts +62 -0
  45. package/dist/index.global.js +438 -153
  46. package/dist/index.js +594 -486
  47. package/dist/react-0wepdf60.js +1519 -0
  48. package/dist/{react-gefkdkdz.js → react-1gqwa2yw.js} +1 -1
  49. package/dist/{index-sn2y6j09.js → react-3mfz1x2a.js} +126 -2167
  50. package/dist/react-4rbjw9af.js +33 -0
  51. package/dist/react-5rq7bnsy.js +210 -0
  52. package/dist/react-6bz05qk1.js +860 -0
  53. package/dist/{react-qgz9afa2.js → react-6fnxxs30.js} +8 -171
  54. package/dist/react-6q2cw2ya.js +689 -0
  55. package/dist/{react-7vjfsh40.js → react-6t4dbdzn.js} +11 -8
  56. package/dist/react-88es9b5q.js +719 -0
  57. package/dist/react-97b5b8j4.js +46 -0
  58. package/dist/{react-mmq2zya3.js → react-bxzn8vq5.js} +1 -1
  59. package/dist/{react-3rhdj2k1.js → react-cs62p9qh.js} +62 -720
  60. package/dist/react-ethftdxp.js +497 -0
  61. package/dist/react-fp73vhyd.js +36 -0
  62. package/dist/{react-qfpg79hs.js → react-me102s1a.js} +2 -45
  63. package/dist/react-t2qnewz2.js +24 -0
  64. package/dist/react-ttj8f9qp.js +1886 -0
  65. package/dist/{react-806qmkyz.js → react-v8497a41.js} +13 -8
  66. package/dist/{react-6tss0r9f.js → react-wqn4sx0n.js} +265 -2137
  67. package/dist/react.js +590 -486
  68. package/dist/replay-j18rw92k.js +258 -0
  69. package/dist/replay-vtg0vqj2.js +257 -0
  70. package/dist/{storageview-7cv0vpdm.js → storageview-6xj7zb63.js} +11 -7
  71. package/dist/{storageview-dyhpgt8f.js → storageview-pzn8yaad.js} +11 -7
  72. package/dist/styles/force.d.ts +66 -0
  73. package/dist/ui/bindings.d.ts +31 -5
  74. package/dist/ui/changes.d.ts +49 -0
  75. package/dist/ui/cssauto.d.ts +119 -0
  76. package/dist/ui/cssedit.d.ts +80 -0
  77. package/dist/ui/domedit.d.ts +99 -0
  78. package/dist/ui/domtree.d.ts +26 -1
  79. package/dist/ui/elementsview.d.ts +17 -2
  80. package/dist/ui/htmledit.d.ts +62 -0
  81. package/dist/ui/inspector.d.ts +6 -1
  82. package/dist/ui/keys.d.ts +12 -8
  83. package/dist/ui/pane.d.ts +0 -2
  84. package/dist/ui/panel.d.ts +3 -0
  85. package/dist/ui/prefs.d.ts +30 -10
  86. package/dist/ui/settings.d.ts +22 -1
  87. package/dist/ui/size.d.ts +14 -22
  88. package/dist/ui/stylesview.d.ts +30 -1
  89. package/package.json +1 -1
  90. package/skills/devknobs/SKILL.md +95 -0
  91. package/dist/elementsview-1wsxcdtj.js +0 -2874
  92. package/dist/elementsview-3kv34jfx.js +0 -2873
  93. package/dist/index-78r0f8pw.js +0 -27
  94. package/dist/react-adky72h9.js +0 -29
@@ -1,25 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __returnValue = (v) => v;
3
- function __exportSetter(name, newValue) {
4
- this[name] = __returnValue.bind(null, newValue);
5
- }
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true,
11
- configurable: true,
12
- set: __exportSetter.bind(all, name)
13
- });
14
- };
15
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
16
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
17
- }) : x)(function(x) {
18
- if (typeof require !== "undefined")
19
- return require.apply(this, arguments);
20
- throw Error('Dynamic require of "' + x + '" is not supported');
21
- });
22
-
23
1
  // src/engine/devices.ts
24
2
  var POSTURES = ["closed", "open"];
25
3
  function openOf(posture) {
@@ -494,6 +472,249 @@ function takeOver() {
494
472
  patches?.release();
495
473
  }
496
474
 
475
+ // src/grab/boxmodel.ts
476
+ var RINGS = ["margin", "border", "padding", "content"];
477
+ var SIDES = ["top", "right", "bottom", "left"];
478
+ function pxOf(value) {
479
+ const match = /^(-?\d*\.?\d+(?:e-?\d+)?)px$/.exec(value.trim());
480
+ return match ? Number(match[1]) : null;
481
+ }
482
+ function sides(top, right, bottom, left) {
483
+ return {
484
+ top: pxOf(top) ?? 0,
485
+ right: pxOf(right) ?? 0,
486
+ bottom: pxOf(bottom) ?? 0,
487
+ left: pxOf(left) ?? 0
488
+ };
489
+ }
490
+ function boxModel(style) {
491
+ const offsets = {
492
+ top: pxOf(style.top),
493
+ right: pxOf(style.right),
494
+ bottom: pxOf(style.bottom),
495
+ left: pxOf(style.left)
496
+ };
497
+ const positioned = style.position !== "static" && SIDES.some((side) => offsets[side] !== null);
498
+ return {
499
+ margin: sides(style.marginTop, style.marginRight, style.marginBottom, style.marginLeft),
500
+ border: sides(style.borderTopWidth, style.borderRightWidth, style.borderBottomWidth, style.borderLeftWidth),
501
+ padding: sides(style.paddingTop, style.paddingRight, style.paddingBottom, style.paddingLeft),
502
+ offsets: positioned ? offsets : null,
503
+ boxSizing: style.boxSizing,
504
+ display: style.display,
505
+ position: style.position
506
+ };
507
+ }
508
+ function contentSize(model, computed, laid) {
509
+ const { border, padding } = model;
510
+ const one = (value, box, around) => {
511
+ const px = pxOf(value);
512
+ if (px === null)
513
+ return Math.max(0, box - around);
514
+ return model.boxSizing === "border-box" ? Math.max(0, px - around) : px;
515
+ };
516
+ return {
517
+ width: one(computed.width, laid.width, border.left + border.right + padding.left + padding.right),
518
+ height: one(computed.height, laid.height, border.top + border.bottom + padding.top + padding.bottom)
519
+ };
520
+ }
521
+ function hasBox(display, laid) {
522
+ if (display === "contents" || display === "none")
523
+ return false;
524
+ return laid.width > 0 || laid.height > 0;
525
+ }
526
+ function inset(rect, by) {
527
+ const width = Math.max(0, rect.width - by.left - by.right);
528
+ const height = Math.max(0, rect.height - by.top - by.bottom);
529
+ return {
530
+ x: Math.min(rect.x + by.left, rect.x + rect.width),
531
+ y: Math.min(rect.y + by.top, rect.y + rect.height),
532
+ width,
533
+ height
534
+ };
535
+ }
536
+ function ringRects(border, model) {
537
+ const { margin } = model;
538
+ const out = {
539
+ top: -Math.max(0, margin.top),
540
+ right: -Math.max(0, margin.right),
541
+ bottom: -Math.max(0, margin.bottom),
542
+ left: -Math.max(0, margin.left)
543
+ };
544
+ const padding = inset(border, model.border);
545
+ return {
546
+ margin: inset(border, out),
547
+ border,
548
+ padding,
549
+ content: inset(padding, model.padding)
550
+ };
551
+ }
552
+ function rectQuad(rect) {
553
+ const right = rect.x + rect.width;
554
+ const bottom = rect.y + rect.height;
555
+ return [
556
+ { x: rect.x, y: rect.y },
557
+ { x: right, y: rect.y },
558
+ { x: right, y: bottom },
559
+ { x: rect.x, y: bottom }
560
+ ];
561
+ }
562
+ function ringQuads(border, model) {
563
+ const rects = ringRects(border, model);
564
+ return {
565
+ margin: rectQuad(rects.margin),
566
+ border: rectQuad(rects.border),
567
+ padding: rectQuad(rects.padding),
568
+ content: rectQuad(rects.content)
569
+ };
570
+ }
571
+ function isPoint(value) {
572
+ if (typeof value !== "object" || value === null)
573
+ return false;
574
+ const x = Reflect.get(value, "x");
575
+ const y = Reflect.get(value, "y");
576
+ return typeof x === "number" && typeof y === "number" && Number.isFinite(x + y);
577
+ }
578
+ function oneQuad(value) {
579
+ if (typeof value !== "object" || value === null)
580
+ return null;
581
+ if (Reflect.get(value, "length") !== 1)
582
+ return null;
583
+ const quad = Reflect.get(value, 0);
584
+ if (typeof quad !== "object" || quad === null)
585
+ return null;
586
+ const corners = ["p1", "p2", "p3", "p4"].map((name) => Reflect.get(quad, name));
587
+ const [a, b, c, d] = corners;
588
+ if (!isPoint(a) || !isPoint(b) || !isPoint(c) || !isPoint(d))
589
+ return null;
590
+ return [
591
+ { x: a.x, y: a.y },
592
+ { x: b.x, y: b.y },
593
+ { x: c.x, y: c.y },
594
+ { x: d.x, y: d.y }
595
+ ];
596
+ }
597
+ var NEAR = 0.5;
598
+ function isPlain(quad, laid) {
599
+ const [a, b, c, d] = quad;
600
+ const straight = Math.abs(a.y - b.y) < NEAR && Math.abs(b.x - c.x) < NEAR && Math.abs(c.y - d.y) < NEAR && Math.abs(d.x - a.x) < NEAR;
601
+ if (!straight || !laid)
602
+ return straight;
603
+ return Math.abs(Math.abs(b.x - a.x) - laid.width) < NEAR && Math.abs(Math.abs(d.y - a.y) - laid.height) < NEAR;
604
+ }
605
+ function alignQuads(quads, bounds) {
606
+ const dx = bounds.x - Math.min(...quads.border.map((point) => point.x));
607
+ const dy = bounds.y - Math.min(...quads.border.map((point) => point.y));
608
+ const move = (quad) => [
609
+ { x: quad[0].x + dx, y: quad[0].y + dy },
610
+ { x: quad[1].x + dx, y: quad[1].y + dy },
611
+ { x: quad[2].x + dx, y: quad[2].y + dy },
612
+ { x: quad[3].x + dx, y: quad[3].y + dy }
613
+ ];
614
+ return {
615
+ margin: move(quads.margin),
616
+ border: move(quads.border),
617
+ padding: move(quads.padding),
618
+ content: move(quads.content)
619
+ };
620
+ }
621
+ function loop(quad, closed) {
622
+ const points = closed ? [...quad, quad[0]] : quad;
623
+ return points.map((point) => `${Math.round(point.x * 100) / 100}px ${Math.round(point.y * 100) / 100}px`).join(", ");
624
+ }
625
+ function ringPath(outer, inner) {
626
+ if (!inner)
627
+ return `polygon(${loop(outer, false)})`;
628
+ return `polygon(evenodd, ${loop(outer, true)}, ${loop(inner, true)})`;
629
+ }
630
+ function ringPaths(quads) {
631
+ return {
632
+ margin: ringPath(quads.margin, quads.border),
633
+ border: ringPath(quads.border, quads.padding),
634
+ padding: ringPath(quads.padding, quads.content),
635
+ content: ringPath(quads.content, null)
636
+ };
637
+ }
638
+
639
+ // src/engine/color.ts
640
+ function luminance(red, green, blue) {
641
+ const [r = 0, g = 0, b = 0] = [red, green, blue].map((channel) => {
642
+ const share = channel / 255;
643
+ return share <= 0.03928 ? share / 12.92 : ((share + 0.055) / 1.055) ** 2.4;
644
+ });
645
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
646
+ }
647
+ function part(value, whole) {
648
+ return value.endsWith("%") ? Number.parseFloat(value) / 100 * whole : Number.parseFloat(value);
649
+ }
650
+ function parseColor(value) {
651
+ const match = /^(rgba?|color)\(\s*(srgb\s+)?([^)]+)\)$/i.exec(value.trim());
652
+ if (!match)
653
+ return null;
654
+ const srgb = match[1]?.toLowerCase() === "color";
655
+ if (srgb !== Boolean(match[2]))
656
+ return null;
657
+ const parts = (match[3] ?? "").split(/[\s,/]+/).filter(Boolean);
658
+ if (parts.length < 3 || parts.length > 4)
659
+ return null;
660
+ const scale = srgb ? 255 : 1;
661
+ const [red, green, blue] = parts.slice(0, 3).map((channel) => channel.endsWith("%") ? part(channel, 255) : part(channel, 1) * scale);
662
+ const alpha = parts[3] === undefined ? 1 : part(parts[3], 1);
663
+ if (red === undefined || green === undefined || blue === undefined)
664
+ return null;
665
+ if ([red, green, blue, alpha].some((channel) => !Number.isFinite(channel)))
666
+ return null;
667
+ return { red, green, blue, alpha };
668
+ }
669
+ function isCustomColor(value) {
670
+ return typeof value === "string" && /^#[0-9a-f]{6}$/.test(value);
671
+ }
672
+ function toHex(color) {
673
+ const pair = (channel) => Math.min(255, Math.max(0, Math.round(channel))).toString(16).padStart(2, "0");
674
+ return `#${pair(color.red)}${pair(color.green)}${pair(color.blue)}`;
675
+ }
676
+ function parseHex(value) {
677
+ const match = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(value.trim());
678
+ const digits = match?.[1];
679
+ if (!digits)
680
+ return null;
681
+ const pairs = digits.length === 3 ? Array.from(digits, (digit) => digit + digit) : digits.match(/../g);
682
+ const [red = 0, green = 0, blue = 0] = (pairs ?? []).map((pair) => Number.parseInt(pair, 16));
683
+ return { red, green, blue, alpha: 1 };
684
+ }
685
+ function readColor(text) {
686
+ const value = text.trim();
687
+ const color = parseHex(value.startsWith("#") ? value : `#${value}`) ?? parseColor(value);
688
+ if (!color || color.alpha !== 1)
689
+ return null;
690
+ const channels = [color.red, color.green, color.blue];
691
+ return channels.every((channel) => channel >= 0 && channel <= 255) ? toHex(color) : null;
692
+ }
693
+ function contrast(a, b) {
694
+ return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
695
+ }
696
+ function mix(from, to, share) {
697
+ const at = (a, b) => a + (b - a) * share;
698
+ return {
699
+ red: at(from.red, to.red),
700
+ green: at(from.green, to.green),
701
+ blue: at(from.blue, to.blue),
702
+ alpha: 1
703
+ };
704
+ }
705
+ var WHITE = { red: 255, green: 255, blue: 255, alpha: 1 };
706
+ var BLACK = { red: 0, green: 0, blue: 0, alpha: 1 };
707
+ var INK = 0.9;
708
+ function inkOn(color, grounds) {
709
+ const least = (ink) => {
710
+ const own = luminance(ink.red, ink.green, ink.blue);
711
+ return Math.min(...grounds.map((ground) => contrast(own, luminance(ground.red, ground.green, ground.blue))));
712
+ };
713
+ const light = mix(color, WHITE, INK);
714
+ const dark = mix(color, BLACK, INK);
715
+ return least(light) >= least(dark) ? light : dark;
716
+ }
717
+
497
718
  // src/engine/geo.ts
498
719
  var GEO_PRESETS = [
499
720
  { id: "antalya", label: "Antalya", lat: 36.8969, lng: 30.7133, timeZone: "Europe/Istanbul" },
@@ -841,249 +1062,6 @@ function reset() {
841
1062
  restoreGeolocation();
842
1063
  }
843
1064
 
844
- // src/grab/boxmodel.ts
845
- var RINGS = ["margin", "border", "padding", "content"];
846
- var SIDES = ["top", "right", "bottom", "left"];
847
- function pxOf(value) {
848
- const match = /^(-?\d*\.?\d+(?:e-?\d+)?)px$/.exec(value.trim());
849
- return match ? Number(match[1]) : null;
850
- }
851
- function sides(top, right, bottom, left) {
852
- return {
853
- top: pxOf(top) ?? 0,
854
- right: pxOf(right) ?? 0,
855
- bottom: pxOf(bottom) ?? 0,
856
- left: pxOf(left) ?? 0
857
- };
858
- }
859
- function boxModel(style) {
860
- const offsets = {
861
- top: pxOf(style.top),
862
- right: pxOf(style.right),
863
- bottom: pxOf(style.bottom),
864
- left: pxOf(style.left)
865
- };
866
- const positioned = style.position !== "static" && SIDES.some((side) => offsets[side] !== null);
867
- return {
868
- margin: sides(style.marginTop, style.marginRight, style.marginBottom, style.marginLeft),
869
- border: sides(style.borderTopWidth, style.borderRightWidth, style.borderBottomWidth, style.borderLeftWidth),
870
- padding: sides(style.paddingTop, style.paddingRight, style.paddingBottom, style.paddingLeft),
871
- offsets: positioned ? offsets : null,
872
- boxSizing: style.boxSizing,
873
- display: style.display,
874
- position: style.position
875
- };
876
- }
877
- function contentSize(model, computed, laid) {
878
- const { border, padding } = model;
879
- const one = (value, box, around) => {
880
- const px = pxOf(value);
881
- if (px === null)
882
- return Math.max(0, box - around);
883
- return model.boxSizing === "border-box" ? Math.max(0, px - around) : px;
884
- };
885
- return {
886
- width: one(computed.width, laid.width, border.left + border.right + padding.left + padding.right),
887
- height: one(computed.height, laid.height, border.top + border.bottom + padding.top + padding.bottom)
888
- };
889
- }
890
- function hasBox(display, laid) {
891
- if (display === "contents" || display === "none")
892
- return false;
893
- return laid.width > 0 || laid.height > 0;
894
- }
895
- function inset(rect, by) {
896
- const width = Math.max(0, rect.width - by.left - by.right);
897
- const height = Math.max(0, rect.height - by.top - by.bottom);
898
- return {
899
- x: Math.min(rect.x + by.left, rect.x + rect.width),
900
- y: Math.min(rect.y + by.top, rect.y + rect.height),
901
- width,
902
- height
903
- };
904
- }
905
- function ringRects(border, model) {
906
- const { margin } = model;
907
- const out = {
908
- top: -Math.max(0, margin.top),
909
- right: -Math.max(0, margin.right),
910
- bottom: -Math.max(0, margin.bottom),
911
- left: -Math.max(0, margin.left)
912
- };
913
- const padding = inset(border, model.border);
914
- return {
915
- margin: inset(border, out),
916
- border,
917
- padding,
918
- content: inset(padding, model.padding)
919
- };
920
- }
921
- function rectQuad(rect) {
922
- const right = rect.x + rect.width;
923
- const bottom = rect.y + rect.height;
924
- return [
925
- { x: rect.x, y: rect.y },
926
- { x: right, y: rect.y },
927
- { x: right, y: bottom },
928
- { x: rect.x, y: bottom }
929
- ];
930
- }
931
- function ringQuads(border, model) {
932
- const rects = ringRects(border, model);
933
- return {
934
- margin: rectQuad(rects.margin),
935
- border: rectQuad(rects.border),
936
- padding: rectQuad(rects.padding),
937
- content: rectQuad(rects.content)
938
- };
939
- }
940
- function isPoint(value) {
941
- if (typeof value !== "object" || value === null)
942
- return false;
943
- const x = Reflect.get(value, "x");
944
- const y = Reflect.get(value, "y");
945
- return typeof x === "number" && typeof y === "number" && Number.isFinite(x + y);
946
- }
947
- function oneQuad(value) {
948
- if (typeof value !== "object" || value === null)
949
- return null;
950
- if (Reflect.get(value, "length") !== 1)
951
- return null;
952
- const quad = Reflect.get(value, 0);
953
- if (typeof quad !== "object" || quad === null)
954
- return null;
955
- const corners = ["p1", "p2", "p3", "p4"].map((name) => Reflect.get(quad, name));
956
- const [a, b, c, d] = corners;
957
- if (!isPoint(a) || !isPoint(b) || !isPoint(c) || !isPoint(d))
958
- return null;
959
- return [
960
- { x: a.x, y: a.y },
961
- { x: b.x, y: b.y },
962
- { x: c.x, y: c.y },
963
- { x: d.x, y: d.y }
964
- ];
965
- }
966
- var NEAR = 0.5;
967
- function isPlain(quad, laid) {
968
- const [a, b, c, d] = quad;
969
- const straight = Math.abs(a.y - b.y) < NEAR && Math.abs(b.x - c.x) < NEAR && Math.abs(c.y - d.y) < NEAR && Math.abs(d.x - a.x) < NEAR;
970
- if (!straight || !laid)
971
- return straight;
972
- return Math.abs(Math.abs(b.x - a.x) - laid.width) < NEAR && Math.abs(Math.abs(d.y - a.y) - laid.height) < NEAR;
973
- }
974
- function alignQuads(quads, bounds) {
975
- const dx = bounds.x - Math.min(...quads.border.map((point) => point.x));
976
- const dy = bounds.y - Math.min(...quads.border.map((point) => point.y));
977
- const move = (quad) => [
978
- { x: quad[0].x + dx, y: quad[0].y + dy },
979
- { x: quad[1].x + dx, y: quad[1].y + dy },
980
- { x: quad[2].x + dx, y: quad[2].y + dy },
981
- { x: quad[3].x + dx, y: quad[3].y + dy }
982
- ];
983
- return {
984
- margin: move(quads.margin),
985
- border: move(quads.border),
986
- padding: move(quads.padding),
987
- content: move(quads.content)
988
- };
989
- }
990
- function loop(quad, closed) {
991
- const points = closed ? [...quad, quad[0]] : quad;
992
- return points.map((point) => `${Math.round(point.x * 100) / 100}px ${Math.round(point.y * 100) / 100}px`).join(", ");
993
- }
994
- function ringPath(outer, inner) {
995
- if (!inner)
996
- return `polygon(${loop(outer, false)})`;
997
- return `polygon(evenodd, ${loop(outer, true)}, ${loop(inner, true)})`;
998
- }
999
- function ringPaths(quads) {
1000
- return {
1001
- margin: ringPath(quads.margin, quads.border),
1002
- border: ringPath(quads.border, quads.padding),
1003
- padding: ringPath(quads.padding, quads.content),
1004
- content: ringPath(quads.content, null)
1005
- };
1006
- }
1007
-
1008
- // src/engine/color.ts
1009
- function luminance(red, green, blue) {
1010
- const [r = 0, g = 0, b = 0] = [red, green, blue].map((channel) => {
1011
- const share = channel / 255;
1012
- return share <= 0.03928 ? share / 12.92 : ((share + 0.055) / 1.055) ** 2.4;
1013
- });
1014
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
1015
- }
1016
- function part(value, whole) {
1017
- return value.endsWith("%") ? Number.parseFloat(value) / 100 * whole : Number.parseFloat(value);
1018
- }
1019
- function parseColor(value) {
1020
- const match = /^(rgba?|color)\(\s*(srgb\s+)?([^)]+)\)$/i.exec(value.trim());
1021
- if (!match)
1022
- return null;
1023
- const srgb = match[1]?.toLowerCase() === "color";
1024
- if (srgb !== Boolean(match[2]))
1025
- return null;
1026
- const parts = (match[3] ?? "").split(/[\s,/]+/).filter(Boolean);
1027
- if (parts.length < 3 || parts.length > 4)
1028
- return null;
1029
- const scale = srgb ? 255 : 1;
1030
- const [red, green, blue] = parts.slice(0, 3).map((channel) => channel.endsWith("%") ? part(channel, 255) : part(channel, 1) * scale);
1031
- const alpha = parts[3] === undefined ? 1 : part(parts[3], 1);
1032
- if (red === undefined || green === undefined || blue === undefined)
1033
- return null;
1034
- if ([red, green, blue, alpha].some((channel) => !Number.isFinite(channel)))
1035
- return null;
1036
- return { red, green, blue, alpha };
1037
- }
1038
- function isCustomColor(value) {
1039
- return typeof value === "string" && /^#[0-9a-f]{6}$/.test(value);
1040
- }
1041
- function toHex(color) {
1042
- const pair = (channel) => Math.min(255, Math.max(0, Math.round(channel))).toString(16).padStart(2, "0");
1043
- return `#${pair(color.red)}${pair(color.green)}${pair(color.blue)}`;
1044
- }
1045
- function parseHex(value) {
1046
- const match = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(value.trim());
1047
- const digits = match?.[1];
1048
- if (!digits)
1049
- return null;
1050
- const pairs = digits.length === 3 ? Array.from(digits, (digit) => digit + digit) : digits.match(/../g);
1051
- const [red = 0, green = 0, blue = 0] = (pairs ?? []).map((pair) => Number.parseInt(pair, 16));
1052
- return { red, green, blue, alpha: 1 };
1053
- }
1054
- function readColor(text) {
1055
- const value = text.trim();
1056
- const color = parseHex(value.startsWith("#") ? value : `#${value}`) ?? parseColor(value);
1057
- if (!color || color.alpha !== 1)
1058
- return null;
1059
- const channels = [color.red, color.green, color.blue];
1060
- return channels.every((channel) => channel >= 0 && channel <= 255) ? toHex(color) : null;
1061
- }
1062
- function contrast(a, b) {
1063
- return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
1064
- }
1065
- function mix(from, to, share) {
1066
- const at = (a, b) => a + (b - a) * share;
1067
- return {
1068
- red: at(from.red, to.red),
1069
- green: at(from.green, to.green),
1070
- blue: at(from.blue, to.blue),
1071
- alpha: 1
1072
- };
1073
- }
1074
- var WHITE = { red: 255, green: 255, blue: 255, alpha: 1 };
1075
- var BLACK = { red: 0, green: 0, blue: 0, alpha: 1 };
1076
- var INK = 0.9;
1077
- function inkOn(color, grounds) {
1078
- const least = (ink) => {
1079
- const own = luminance(ink.red, ink.green, ink.blue);
1080
- return Math.min(...grounds.map((ground) => contrast(own, luminance(ground.red, ground.green, ground.blue))));
1081
- };
1082
- const light = mix(color, WHITE, INK);
1083
- const dark = mix(color, BLACK, INK);
1084
- return least(light) >= least(dark) ? light : dark;
1085
- }
1086
-
1087
1065
  // src/engine/stored.ts
1088
1066
  function versionOf(value) {
1089
1067
  if (typeof value !== "object" || value === null)
@@ -1098,136 +1076,6 @@ function stamped(value, v) {
1098
1076
  return { v, ...value };
1099
1077
  }
1100
1078
 
1101
- // src/engine/fresh.ts
1102
- var FRESH_PARAM = "devknobs";
1103
- var FRESH_VALUE = "fresh";
1104
- var FRESH_ATTRIBUTE = "data-devknobs-fresh";
1105
- var FRESH_RELOAD_KEY = "devknobs:fresh-reload";
1106
- var FRESH_RELOAD_VERSION = 1;
1107
- var FRESH_RELOAD_WINDOW = 1e4;
1108
- var KEPT = "devknobs:locale-";
1109
- var MODE = Symbol.for("devknobs.fresh");
1110
- function freshIn(search) {
1111
- try {
1112
- return new URLSearchParams(search).getAll(FRESH_PARAM).includes(FRESH_VALUE);
1113
- } catch {
1114
- return false;
1115
- }
1116
- }
1117
- function wiped(key) {
1118
- if (key === FRESH_PARAM)
1119
- return true;
1120
- return key.startsWith(`${FRESH_PARAM}:`) && !key.startsWith(KEPT);
1121
- }
1122
- function reloadAt(text) {
1123
- if (!text)
1124
- return 0;
1125
- try {
1126
- const raw = JSON.parse(text);
1127
- if (typeof raw !== "object" || raw === null || newer(raw, FRESH_RELOAD_VERSION))
1128
- return 0;
1129
- const at = Reflect.get(raw, "at");
1130
- return typeof at === "number" ? at : 0;
1131
- } catch {
1132
- return 0;
1133
- }
1134
- }
1135
- function begin() {
1136
- try {
1137
- const session = window.sessionStorage;
1138
- const age = realNow() - reloadAt(session.getItem(FRESH_RELOAD_KEY));
1139
- session.removeItem(FRESH_RELOAD_KEY);
1140
- if (age >= 0 && age < FRESH_RELOAD_WINDOW)
1141
- return;
1142
- const keys = [];
1143
- for (let index = 0;index < session.length; index++) {
1144
- const key = session.key(index);
1145
- if (key !== null && wiped(key))
1146
- keys.push(key);
1147
- }
1148
- for (const key of keys)
1149
- session.removeItem(key);
1150
- } catch {}
1151
- }
1152
- function settle2() {
1153
- try {
1154
- window.sessionStorage.removeItem(FRESH_RELOAD_KEY);
1155
- } catch {}
1156
- }
1157
- function framedFresh() {
1158
- try {
1159
- const owner = window.frameElement;
1160
- if (owner)
1161
- return owner.hasAttribute(FRESH_ATTRIBUTE);
1162
- } catch {}
1163
- return window.name === FRAME_NAME && freshIn(window.location?.search ?? "");
1164
- }
1165
- function fresh() {
1166
- if (typeof window === "undefined")
1167
- return false;
1168
- const known = Reflect.get(window, MODE);
1169
- if (typeof known === "boolean")
1170
- return known;
1171
- let on = false;
1172
- try {
1173
- if (isDevknobsFrame())
1174
- on = framedFresh();
1175
- else {
1176
- on = freshIn(window.location?.search ?? "");
1177
- if (on)
1178
- begin();
1179
- else
1180
- settle2();
1181
- }
1182
- } catch {
1183
- on = false;
1184
- }
1185
- Reflect.set(window, MODE, on);
1186
- return on;
1187
- }
1188
- function webStorage(kind) {
1189
- try {
1190
- if (typeof window === "undefined")
1191
- return null;
1192
- if (kind === "session") {
1193
- fresh();
1194
- return window.sessionStorage ?? null;
1195
- }
1196
- return fresh() ? null : window.localStorage ?? null;
1197
- } catch {
1198
- return null;
1199
- }
1200
- }
1201
- function loads(target, from) {
1202
- const bare = (address) => address.split("#", 1)[0];
1203
- return bare(target) !== bare(from);
1204
- }
1205
- function withFresh(target, origin) {
1206
- try {
1207
- const url = new URL(target);
1208
- if (url.origin !== origin || freshIn(url.search))
1209
- return target;
1210
- } catch {
1211
- return target;
1212
- }
1213
- const cut = target.indexOf("#");
1214
- const bare = cut < 0 ? target : target.slice(0, cut);
1215
- const hash = cut < 0 ? "" : target.slice(cut);
1216
- const join = !bare.includes("?") ? "?" : bare.endsWith("?") || bare.endsWith("&") ? "" : "&";
1217
- return `${bare}${join}${FRESH_PARAM}=${FRESH_VALUE}${hash}`;
1218
- }
1219
- function carried(target) {
1220
- return fresh() ? withFresh(target, window.location.origin) : target;
1221
- }
1222
- function ownReload() {
1223
- if (!fresh() || isDevknobsFrame())
1224
- return;
1225
- try {
1226
- const record = stamped({ at: realNow() }, FRESH_RELOAD_VERSION);
1227
- window.sessionStorage.setItem(FRESH_RELOAD_KEY, JSON.stringify(record));
1228
- } catch {}
1229
- }
1230
-
1231
1079
  // src/engine/zoom.ts
1232
1080
  var ZOOM_PRESETS = [0.5, 0.75, 1, 1.25, 1.5];
1233
1081
  var ZOOM_MIN = 0.25;
@@ -1572,6 +1420,8 @@ var KEY_ACTIONS = [
1572
1420
  "requests",
1573
1421
  "reset",
1574
1422
  "storage",
1423
+ "elements",
1424
+ "settings",
1575
1425
  "search",
1576
1426
  "zoom-in",
1577
1427
  "zoom-out",
@@ -1712,464 +1562,151 @@ function post(target, message) {
1712
1562
  target.postMessage(message, "/");
1713
1563
  }
1714
1564
 
1715
- // src/engine/system.ts
1716
- var current = null;
1717
- var listeners = new Set;
1718
- function systemMedia() {
1719
- return current;
1720
- }
1721
- function setSystemMedia(media) {
1722
- current = media ? { scheme: media.scheme, motion: media.motion } : null;
1723
- for (const listener of listeners)
1724
- listener(current);
1725
- }
1726
- function watchSystemMedia(listener) {
1727
- listeners.add(listener);
1728
- listener(current);
1729
- return () => listeners.delete(listener);
1730
- }
1731
-
1732
- // src/engine/ua.ts
1733
- var CHROME = "154.0.8037.98";
1734
- var EDGE = "154.0.4258.53";
1735
- var SAFARI = "27.0";
1736
- var FIREFOX = "157.0";
1737
- var GREASE = { brand: "Not/A)Brand", version: "24.0.0.0" };
1738
- var APPLE = "Apple Computer, Inc.";
1739
- var GOOGLE = "Google Inc.";
1740
- function major(version) {
1741
- return version.split(".")[0] ?? version;
1742
- }
1743
- function chromeAgent(system, mobile = false) {
1744
- const browser = `Chrome/${major(CHROME)}.0.0.0 ${mobile ? "Mobile " : ""}Safari/537.36`;
1745
- return `Mozilla/5.0 (${system}) AppleWebKit/537.36 (KHTML, like Gecko) ${browser}`;
1746
- }
1747
- function chromium(own, hints) {
1748
- const full = [{ brand: "Chromium", version: CHROME }, GREASE, ...own ? [own] : []];
1749
- return {
1750
- brands: full.map(({ brand, version }) => ({ brand, version: major(version) })),
1751
- hints: { ...hints, fullVersionList: full, uaFullVersion: own?.version ?? CHROME }
1752
- };
1753
- }
1754
- var CHROME_BRAND = { brand: "Google Chrome", version: CHROME };
1755
- var DESKTOP = { model: "", bitness: "64" };
1756
- var WINDOWS = { ...DESKTOP, platformVersion: "19.0.0", architecture: "x86" };
1757
- var MAC_SAFARI = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/${SAFARI} Safari/605.1.15`;
1758
- var UA_PRESETS = [
1759
- {
1760
- id: "iphone-safari",
1761
- label: "iPhone Safari",
1762
- userAgent: `Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/${SAFARI} Mobile/15E148 Safari/604.1`,
1763
- platform: "iPhone",
1764
- vendor: APPLE,
1765
- mobile: true,
1766
- brands: [],
1767
- uaPlatform: "iOS",
1768
- maxTouchPoints: 5
1769
- },
1770
- {
1771
- id: "android-chrome",
1772
- label: "Android Chrome",
1773
- userAgent: chromeAgent("Linux; Android 10; K", true),
1774
- platform: "Linux armv81",
1775
- vendor: GOOGLE,
1776
- mobile: true,
1777
- uaPlatform: "Android",
1778
- maxTouchPoints: 5,
1779
- ...chromium(CHROME_BRAND, {
1780
- platformVersion: "16.0.0",
1781
- model: "Pixel 10",
1782
- architecture: "",
1783
- bitness: ""
1784
- })
1785
- },
1786
- {
1787
- id: "ipad-safari",
1788
- label: "iPad Safari",
1789
- userAgent: MAC_SAFARI,
1790
- platform: "MacIntel",
1791
- vendor: APPLE,
1792
- mobile: false,
1793
- brands: [],
1794
- uaPlatform: "iOS",
1795
- maxTouchPoints: 5
1796
- },
1797
- {
1798
- id: "mac-safari",
1799
- label: "Mac Safari",
1800
- userAgent: MAC_SAFARI,
1801
- platform: "MacIntel",
1802
- vendor: APPLE,
1803
- mobile: false,
1804
- brands: [],
1805
- uaPlatform: "macOS",
1806
- maxTouchPoints: 0
1807
- },
1808
- {
1809
- id: "mac-chrome",
1810
- label: "Mac Chrome",
1811
- userAgent: chromeAgent("Macintosh; Intel Mac OS X 10_15_7"),
1812
- platform: "MacIntel",
1813
- vendor: GOOGLE,
1814
- mobile: false,
1815
- uaPlatform: "macOS",
1816
- maxTouchPoints: 0,
1817
- ...chromium(CHROME_BRAND, { ...DESKTOP, platformVersion: "26.7.1", architecture: "arm" })
1818
- },
1819
- {
1820
- id: "windows-chrome",
1821
- label: "Windows Chrome",
1822
- userAgent: chromeAgent("Windows NT 10.0; Win64; x64"),
1823
- platform: "Win32",
1824
- vendor: GOOGLE,
1825
- mobile: false,
1826
- uaPlatform: "Windows",
1827
- maxTouchPoints: 0,
1828
- ...chromium(CHROME_BRAND, WINDOWS)
1829
- },
1830
- {
1831
- id: "windows-edge",
1832
- label: "Windows Edge",
1833
- userAgent: `${chromeAgent("Windows NT 10.0; Win64; x64")} Edg/${EDGE}`,
1834
- platform: "Win32",
1835
- vendor: GOOGLE,
1836
- mobile: false,
1837
- uaPlatform: "Windows",
1838
- maxTouchPoints: 0,
1839
- ...chromium({ brand: "Microsoft Edge", version: EDGE }, WINDOWS)
1840
- },
1841
- {
1842
- id: "linux-firefox",
1843
- label: "Linux Firefox",
1844
- userAgent: `Mozilla/5.0 (X11; Linux x86_64; rv:${FIREFOX}) Gecko/20100101 Firefox/${FIREFOX}`,
1845
- platform: "Linux x86_64",
1846
- vendor: "",
1847
- mobile: false,
1848
- brands: [],
1849
- uaPlatform: "Linux",
1850
- maxTouchPoints: 0,
1851
- appVersion: "5.0 (X11)"
1852
- },
1853
- {
1854
- id: "googlebot",
1855
- label: "Googlebot",
1856
- userAgent: `Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${CHROME} Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)`,
1857
- platform: "Linux armv81",
1858
- vendor: GOOGLE,
1859
- mobile: true,
1860
- uaPlatform: "Android",
1861
- maxTouchPoints: 1,
1862
- ...chromium(null, {
1863
- platformVersion: "6.0.1",
1864
- model: "Nexus 5X",
1865
- architecture: "",
1866
- bitness: ""
1867
- })
1565
+ // src/engine/fresh.ts
1566
+ var FRESH_PARAM = "devknobs";
1567
+ var FRESH_VALUE = "fresh";
1568
+ var FRESH_ATTRIBUTE = "data-devknobs-fresh";
1569
+ var FRESH_RELOAD_KEY = "devknobs:fresh-reload";
1570
+ var FRESH_RELOAD_VERSION = 1;
1571
+ var FRESH_RELOAD_WINDOW = 1e4;
1572
+ var KEPT = "devknobs:locale-";
1573
+ var MODE = Symbol.for("devknobs.fresh");
1574
+ function freshIn(search) {
1575
+ try {
1576
+ return new URLSearchParams(search).getAll(FRESH_PARAM).includes(FRESH_VALUE);
1577
+ } catch {
1578
+ return false;
1868
1579
  }
1869
- ];
1870
- function uaPreset(id) {
1871
- return UA_PRESETS.find((preset) => preset.id === id);
1872
- }
1873
- function userAgentOf(value) {
1874
- if (value.preset === "custom")
1875
- return value.custom.trim();
1876
- return uaPreset(value.preset)?.userAgent ?? "";
1877
- }
1878
- function appVersionOf(userAgent) {
1879
- return userAgent.replace(/^Mozilla\//, "");
1880
- }
1881
- var KEYS = [
1882
- "userAgent",
1883
- "appVersion",
1884
- "platform",
1885
- "vendor",
1886
- "maxTouchPoints",
1887
- "userAgentData"
1888
- ];
1889
- var SHARED2 = Symbol.for("devknobs.ua");
1890
- function isShared(value) {
1891
- return typeof value === "object" && value !== null && "originals" in value;
1892
1580
  }
1893
- function sharedOf(scope) {
1894
- const had = Reflect.get(scope, SHARED2);
1895
- if (isShared(had))
1896
- return had;
1897
- const shared2 = { originals: null };
1898
- Reflect.set(scope, SHARED2, shared2);
1899
- return shared2;
1900
- }
1901
- function prototypeOf(scope) {
1902
- const navigator2 = Reflect.get(scope, "Navigator");
1903
- return typeof navigator2 === "function" ? navigator2.prototype : null;
1904
- }
1905
- function put(target, key, value) {
1906
- Object.defineProperty(target, key, { configurable: true, enumerable: true, get: () => value });
1907
- }
1908
- function restore(shared2, target, key) {
1909
- const descriptor = shared2.originals?.get(key);
1910
- if (descriptor)
1911
- Object.defineProperty(target, key, descriptor);
1912
- else
1913
- Reflect.deleteProperty(target, key);
1914
- }
1915
- function copy(brands) {
1916
- return brands.map(({ brand, version }) => ({ brand, version }));
1917
- }
1918
- var NO_HINTS = { brands: [], mobile: false, uaPlatform: "" };
1919
- function uaData(source, scope) {
1920
- const brands = Object.freeze(source.brands.map((brand) => Object.freeze({ ...brand })));
1921
- const low = () => ({ brands: copy(brands), mobile: source.mobile, platform: source.uaPlatform });
1922
- const hints = source.hints;
1923
- const high = () => ({
1924
- architecture: hints?.architecture ?? "",
1925
- bitness: hints?.bitness ?? "",
1926
- fullVersionList: copy(hints?.fullVersionList ?? []),
1927
- model: hints?.model ?? "",
1928
- platformVersion: hints?.platformVersion ?? "",
1929
- uaFullVersion: hints?.uaFullVersion ?? ""
1930
- });
1931
- const native = Reflect.get(scope, "NavigatorUAData");
1932
- const proto = typeof native === "function" ? native.prototype : Object.prototype;
1933
- return Object.create(proto, {
1934
- brands: { enumerable: true, get: () => brands },
1935
- mobile: { enumerable: true, get: () => source.mobile },
1936
- platform: { enumerable: true, get: () => source.uaPlatform },
1937
- getHighEntropyValues: {
1938
- value: (asked) => {
1939
- try {
1940
- const values = low();
1941
- const all = high();
1942
- for (const hint of Array.from(asked, String)) {
1943
- if (Object.hasOwn(all, hint))
1944
- values[hint] = all[hint];
1945
- }
1946
- return Promise.resolve(values);
1947
- } catch (error) {
1948
- return Promise.reject(error);
1949
- }
1950
- }
1951
- },
1952
- toJSON: { value: low }
1953
- });
1581
+ function wiped(key) {
1582
+ if (key === FRESH_PARAM)
1583
+ return true;
1584
+ return key.startsWith(`${FRESH_PARAM}:`) && !key.startsWith(KEPT);
1954
1585
  }
1955
- function apply2(value, scope = globalThis) {
1956
- const target = prototypeOf(scope);
1957
- const preset = value.preset === "custom" ? undefined : uaPreset(value.preset);
1958
- const userAgent = userAgentOf(value);
1959
- if (!target || userAgent === "") {
1960
- reset2(scope);
1961
- return;
1586
+ function reloadAt(text2) {
1587
+ if (!text2)
1588
+ return 0;
1589
+ try {
1590
+ const raw = JSON.parse(text2);
1591
+ if (typeof raw !== "object" || raw === null || newer(raw, FRESH_RELOAD_VERSION))
1592
+ return 0;
1593
+ const at = Reflect.get(raw, "at");
1594
+ return typeof at === "number" ? at : 0;
1595
+ } catch {
1596
+ return 0;
1962
1597
  }
1963
- const shared2 = sharedOf(scope);
1964
- shared2.originals ??= new Map(KEYS.map((key) => [key, Object.getOwnPropertyDescriptor(target, key)]));
1965
- put(target, "userAgent", userAgent);
1966
- put(target, "appVersion", preset?.appVersion ?? appVersionOf(userAgent));
1967
- if (!preset) {
1968
- for (const key of ["platform", "vendor", "maxTouchPoints"]) {
1969
- restore(shared2, target, key);
1598
+ }
1599
+ function begin() {
1600
+ try {
1601
+ const session = window.sessionStorage;
1602
+ const age = realNow() - reloadAt(session.getItem(FRESH_RELOAD_KEY));
1603
+ session.removeItem(FRESH_RELOAD_KEY);
1604
+ if (age >= 0 && age < FRESH_RELOAD_WINDOW)
1605
+ return;
1606
+ const keys = [];
1607
+ for (let index = 0;index < session.length; index++) {
1608
+ const key = session.key(index);
1609
+ if (key !== null && wiped(key))
1610
+ keys.push(key);
1970
1611
  }
1971
- if (shared2.originals.get("userAgentData")) {
1972
- put(target, "userAgentData", uaData(NO_HINTS, scope));
1973
- } else
1974
- restore(shared2, target, "userAgentData");
1975
- return;
1976
- }
1977
- put(target, "platform", preset.platform);
1978
- put(target, "vendor", preset.vendor);
1979
- put(target, "maxTouchPoints", preset.maxTouchPoints);
1980
- if (preset.brands.length > 0)
1981
- put(target, "userAgentData", uaData(preset, scope));
1982
- else
1983
- Reflect.deleteProperty(target, "userAgentData");
1612
+ for (const key of keys)
1613
+ session.removeItem(key);
1614
+ } catch {}
1984
1615
  }
1985
- function realPlatform() {
1986
- const getter = sharedOf(globalThis).originals?.get("platform")?.get;
1616
+ function settle2() {
1987
1617
  try {
1988
- return String(getter ? getter.call(navigator) : navigator.platform);
1989
- } catch {
1990
- return "";
1991
- }
1992
- }
1993
- function isMac() {
1994
- return /mac|iphone|ipad|ipod/i.test(realPlatform());
1618
+ window.sessionStorage.removeItem(FRESH_RELOAD_KEY);
1619
+ } catch {}
1995
1620
  }
1996
- function reset2(scope = globalThis) {
1997
- const shared2 = sharedOf(scope);
1998
- const target = prototypeOf(scope);
1999
- if (!shared2.originals)
2000
- return;
2001
- if (target)
2002
- for (const key of KEYS)
2003
- restore(shared2, target, key);
2004
- shared2.originals = null;
1621
+ function framedFresh() {
1622
+ try {
1623
+ const owner = window.frameElement;
1624
+ if (owner)
1625
+ return owner.hasAttribute(FRESH_ATTRIBUTE);
1626
+ } catch {}
1627
+ return window.name === FRAME_NAME && freshIn(window.location?.search ?? "");
2005
1628
  }
2006
-
2007
- // src/engine/scrollkeep.ts
2008
- var SCROLL_KEY = "devknobs:scroll";
2009
- var SCROLL_VERSION = 1;
2010
- var SCROLL_WINDOW = 1e4;
2011
- var HOLD = 2000;
2012
- var HOLD_CAP = 1e4;
2013
- var PUT_BUDGET = 20;
2014
- var INPUTS = ["wheel", "touchstart", "keydown", "mousedown"];
2015
- function placeOf2(value) {
2016
- if (typeof value !== "object" || value === null)
2017
- return;
2018
- const path = Reflect.get(value, "path");
2019
- const x = Reflect.get(value, "x");
2020
- const y = Reflect.get(value, "y");
2021
- if (typeof path !== "string" || typeof x !== "number" || typeof y !== "number")
2022
- return;
2023
- return Number.isFinite(x) && Number.isFinite(y) ? { path, x, y } : undefined;
1629
+ function fresh() {
1630
+ if (typeof window === "undefined")
1631
+ return false;
1632
+ const known = Reflect.get(window, MODE);
1633
+ if (typeof known === "boolean")
1634
+ return known;
1635
+ let on = false;
1636
+ try {
1637
+ if (isDevknobsFrame())
1638
+ on = framedFresh();
1639
+ else {
1640
+ on = freshIn(window.location?.search ?? "");
1641
+ if (on)
1642
+ begin();
1643
+ else
1644
+ settle2();
1645
+ }
1646
+ } catch {
1647
+ on = false;
1648
+ }
1649
+ Reflect.set(window, MODE, on);
1650
+ return on;
2024
1651
  }
2025
- function parseKept(text2) {
2026
- if (!text2)
2027
- return null;
2028
- let raw;
1652
+ function webStorage(kind) {
2029
1653
  try {
2030
- raw = JSON.parse(text2);
1654
+ if (typeof window === "undefined")
1655
+ return null;
1656
+ if (kind === "session") {
1657
+ fresh();
1658
+ return window.sessionStorage ?? null;
1659
+ }
1660
+ return fresh() ? null : window.localStorage ?? null;
2031
1661
  } catch {
2032
1662
  return null;
2033
1663
  }
2034
- if (typeof raw !== "object" || raw === null || newer(raw, SCROLL_VERSION))
2035
- return null;
2036
- const at = Reflect.get(raw, "at");
2037
- if (typeof at !== "number")
2038
- return null;
2039
- const kept = { at };
2040
- const page = placeOf2(Reflect.get(raw, "page"));
2041
- const frame = placeOf2(Reflect.get(raw, "frame"));
2042
- if (page)
2043
- kept.page = page;
2044
- if (frame)
2045
- kept.frame = frame;
2046
- return kept;
2047
- }
2048
- function stale(at, now2) {
2049
- const age = now2 - at;
2050
- return !(age >= 0 && age < SCROLL_WINDOW);
2051
- }
2052
- function keptWith(kept, role, place, now2) {
2053
- const next = { at: now2 };
2054
- const other = role === "page" ? "frame" : "page";
2055
- const rest = kept && !stale(kept.at, now2) ? kept[other] : undefined;
2056
- if (rest)
2057
- next[other] = rest;
2058
- if (place && (place.x !== 0 || place.y !== 0))
2059
- next[role] = place;
2060
- return next.page || next.frame ? next : null;
2061
- }
2062
- function take(kept, role, path, now2) {
2063
- if (!kept || stale(kept.at, now2))
2064
- return { place: null, rest: null };
2065
- const own = kept[role];
2066
- const other = role === "page" ? "frame" : "page";
2067
- const left = kept[other];
2068
- const rest = left ? { at: kept.at, [other]: left } : null;
2069
- if (!own || own.path !== path)
2070
- return { place: null, rest };
2071
- return { place: { x: own.x, y: own.y }, rest };
2072
- }
2073
- function next(holding, seen) {
2074
- const { target } = holding;
2075
- const there = Math.abs(seen.x - target.x) <= 1 && Math.abs(seen.y - target.y) <= 1;
2076
- const spent = holding.puts >= PUT_BUDGET;
2077
- const over = seen.now - holding.start >= HOLD_CAP || holding.loadedAt !== null && seen.now - holding.loadedAt >= HOLD;
2078
- if (over)
2079
- return there || spent ? "done" : "last";
2080
- if (spent)
2081
- return "done";
2082
- if (there)
2083
- return "wait";
2084
- return seen.maxX >= target.x - 1 && seen.maxY >= target.y - 1 ? "put" : "wait";
2085
- }
2086
- function hold2(view, target, now2 = realNow) {
2087
- const holding = { target, start: now2(), loadedAt: null, puts: 0 };
2088
- let over = false;
2089
- const end = () => {
2090
- over = true;
2091
- for (const type of INPUTS)
2092
- view.removeEventListener(type, end, true);
2093
- };
2094
- const frame = () => {
2095
- if (over)
2096
- return;
2097
- const time = now2();
2098
- if (holding.loadedAt === null && view.document.readyState === "complete")
2099
- holding.loadedAt = time;
2100
- const root = view.document.documentElement;
2101
- const move = next(holding, {
2102
- x: view.scrollX,
2103
- y: view.scrollY,
2104
- maxX: root ? root.scrollWidth - root.clientWidth : 0,
2105
- maxY: root ? root.scrollHeight - root.clientHeight : 0,
2106
- now: time
2107
- });
2108
- if (move === "put" || move === "last") {
2109
- holding.puts++;
2110
- view.scrollTo({ left: target.x, top: target.y, behavior: "instant" });
2111
- }
2112
- if (move === "last" || move === "done")
2113
- end();
2114
- else
2115
- view.requestAnimationFrame(frame);
2116
- };
2117
- for (const type of INPUTS)
2118
- view.addEventListener(type, end, true);
2119
- frame();
2120
1664
  }
2121
- var framed2 = null;
2122
- function follow(view) {
2123
- framed2 = view;
1665
+ function loads(target, from) {
1666
+ const bare = (address) => address.split("#", 1)[0];
1667
+ return bare(target) !== bare(from);
2124
1668
  }
2125
- function placeIn(view) {
1669
+ function withFresh(target, origin) {
2126
1670
  try {
2127
- return view ? { path: view.location.pathname, x: view.scrollX, y: view.scrollY } : null;
1671
+ const url = new URL(target);
1672
+ if (url.origin !== origin || freshIn(url.search))
1673
+ return target;
2128
1674
  } catch {
2129
- return null;
1675
+ return target;
2130
1676
  }
1677
+ const cut = target.indexOf("#");
1678
+ const bare = cut < 0 ? target : target.slice(0, cut);
1679
+ const hash = cut < 0 ? "" : target.slice(cut);
1680
+ const join = !bare.includes("?") ? "?" : bare.endsWith("?") || bare.endsWith("&") ? "" : "&";
1681
+ return `${bare}${join}${FRESH_PARAM}=${FRESH_VALUE}${hash}`;
2131
1682
  }
2132
- function keep(view, role) {
1683
+ function carried(target) {
1684
+ return fresh() ? withFresh(target, window.location.origin) : target;
1685
+ }
1686
+ function ownReload() {
1687
+ if (!fresh() || isDevknobsFrame())
1688
+ return;
2133
1689
  try {
2134
- const session = webStorage("session");
2135
- if (!session)
2136
- return;
2137
- const kept = keptWith(parseKept(session.getItem(SCROLL_KEY)), role, placeIn(view), realNow());
2138
- if (kept)
2139
- session.setItem(SCROLL_KEY, JSON.stringify(stamped(kept, SCROLL_VERSION)));
2140
- else
2141
- session.removeItem(SCROLL_KEY);
1690
+ const record2 = stamped({ at: realNow() }, FRESH_RELOAD_VERSION);
1691
+ window.sessionStorage.setItem(FRESH_RELOAD_KEY, JSON.stringify(record2));
2142
1692
  } catch {}
2143
1693
  }
2144
- function keepOwn() {
2145
- if (isDevknobsFrame()) {
2146
- keep(window, "frame");
2147
- return;
2148
- }
2149
- keep(window, "page");
2150
- keep(framed2?.() ?? null, "frame");
1694
+
1695
+ // src/engine/system.ts
1696
+ var current = null;
1697
+ var listeners = new Set;
1698
+ function systemMedia() {
1699
+ return current;
2151
1700
  }
2152
- function resume() {
2153
- if (typeof window === "undefined")
2154
- return;
2155
- let target = null;
2156
- try {
2157
- const session = webStorage("session");
2158
- const text2 = session?.getItem(SCROLL_KEY) ?? null;
2159
- if (!session || text2 === null)
2160
- return;
2161
- const role = isDevknobsFrame() ? "frame" : "page";
2162
- const { place, rest } = take(parseKept(text2), role, window.location.pathname, realNow());
2163
- if (rest)
2164
- session.setItem(SCROLL_KEY, JSON.stringify(stamped(rest, SCROLL_VERSION)));
2165
- else
2166
- session.removeItem(SCROLL_KEY);
2167
- target = place;
2168
- } catch {
2169
- return;
2170
- }
2171
- if (target)
2172
- hold2(window, target);
1701
+ function setSystemMedia(media) {
1702
+ current = media ? { scheme: media.scheme, motion: media.motion } : null;
1703
+ for (const listener of listeners)
1704
+ listener(current);
1705
+ }
1706
+ function watchSystemMedia(listener) {
1707
+ listeners.add(listener);
1708
+ listener(current);
1709
+ return () => listeners.delete(listener);
2173
1710
  }
2174
1711
 
2175
1712
  // src/engine/matchmedia.ts
@@ -2181,7 +1718,7 @@ function run(at, query, below) {
2181
1718
  for (let i = at;i < ORDER.length; i++) {
2182
1719
  const layer = layers.get(ORDER[i]);
2183
1720
  if (layer)
2184
- return layer(query, (next2) => run(i + 1, next2, below));
1721
+ return layer(query, (next) => run(i + 1, next, below));
2185
1722
  }
2186
1723
  return below.call(window, query);
2187
1724
  }
@@ -2277,24 +1814,24 @@ function emulatedFontSize(value, size) {
2277
1814
  if (keyword !== undefined)
2278
1815
  return px(keyword * size);
2279
1816
  let relative = false;
2280
- const next2 = value.replace(RELATIVE, (_whole, amount, unit) => {
1817
+ const next = value.replace(RELATIVE, (_whole, amount, unit) => {
2281
1818
  relative = true;
2282
1819
  return px(Number(amount) * size / (unit === "%" ? 100 : 1));
2283
1820
  });
2284
- return relative ? next2 : null;
1821
+ return relative ? next : null;
2285
1822
  }
2286
1823
  function emulateMediaText(text2, size) {
2287
1824
  return text2.replace(MEDIA_RELATIVE, (_whole, amount) => px(Number(amount) * size));
2288
1825
  }
2289
1826
  function substituteVars(value, lookup) {
2290
- let next2 = value;
2291
- for (let depth = 0;depth < 5 && next2.includes("var("); depth++) {
2292
- next2 = next2.replace(VAR, (_whole, name, fallback) => {
1827
+ let next = value;
1828
+ for (let depth = 0;depth < 5 && next.includes("var("); depth++) {
1829
+ next = next.replace(VAR, (_whole, name, fallback) => {
2293
1830
  const found = lookup(name).trim();
2294
1831
  return found || fallback?.trim() || "var()";
2295
1832
  });
2296
1833
  }
2297
- return next2.includes("var(") ? null : next2;
1834
+ return next.includes("var(") ? null : next;
2298
1835
  }
2299
1836
  function splitSelectors(text2) {
2300
1837
  const parts = [];
@@ -2405,12 +1942,12 @@ function rewriteMedia() {
2405
1942
  const known = rewrites.get(rule);
2406
1943
  const ours = known !== undefined && text2 === known.written;
2407
1944
  const source = ours ? known.original : text2;
2408
- const next2 = size === null ? source : emulateMediaText(source, size);
2409
- if (next2 === source && !ours)
1945
+ const next = size === null ? source : emulateMediaText(source, size);
1946
+ if (next === source && !ours)
2410
1947
  return;
2411
- if (next2 !== text2) {
1948
+ if (next !== text2) {
2412
1949
  try {
2413
- rule.media.mediaText = next2;
1950
+ rule.media.mediaText = next;
2414
1951
  } catch {}
2415
1952
  }
2416
1953
  if (size === null)
@@ -2471,8 +2008,8 @@ function rootDeclarations() {
2471
2008
  continue;
2472
2009
  seen.add(imported.styleSheet);
2473
2010
  const media = imported.media.mediaText;
2474
- const next2 = media ? [...conditions, () => matches(media)] : conditions;
2475
- walk(rulesOf(imported.styleSheet), layered || imported.layerName != null, next2);
2011
+ const next = media ? [...conditions, () => matches(media)] : conditions;
2012
+ walk(rulesOf(imported.styleSheet), layered || imported.layerName != null, next);
2476
2013
  } else if (kind === "CSSMediaRule") {
2477
2014
  const media = rule.media.mediaText;
2478
2015
  walk(rule.cssRules, layered, [...conditions, () => matches(media)]);
@@ -2551,12 +2088,12 @@ function applyRoot() {
2551
2088
  const value = authorFontSize();
2552
2089
  const lookup = (name) => getComputedStyle(root).getPropertyValue(name);
2553
2090
  const resolved = value === null ? null : substituteVars(value, lookup);
2554
- const next2 = resolved === null ? px(computedSize() * size / INITIAL) : emulatedFontSize(resolved, size);
2555
- if (next2 === null) {
2091
+ const next = resolved === null ? px(computedSize() * size / INITIAL) : emulatedFontSize(resolved, size);
2092
+ if (next === null) {
2556
2093
  restoreRoot();
2557
2094
  return;
2558
2095
  }
2559
- root.style.setProperty("font-size", next2, "important");
2096
+ root.style.setProperty("font-size", next, "important");
2560
2097
  wrote = root.style.getPropertyValue("font-size");
2561
2098
  markInline(root, "font-size", wrote);
2562
2099
  }
@@ -2599,16 +2136,16 @@ function watchSheets() {
2599
2136
  observer.observe(document.documentElement, { childList: true, subtree: true });
2600
2137
  window.addEventListener("resize", onResize);
2601
2138
  }
2602
- function sizeQuery(query, next2) {
2139
+ function sizeQuery(query, next) {
2603
2140
  const emulated = size === null ? query : emulateMediaText(query, size);
2604
- const list = next2(emulated);
2141
+ const list = next(emulated);
2605
2142
  if (emulated !== query)
2606
2143
  Object.defineProperty(list, "media", { configurable: true, value: query });
2607
2144
  return list;
2608
2145
  }
2609
- function apply3(value) {
2146
+ function apply2(value) {
2610
2147
  if (typeof value !== "number" || !(value > 0)) {
2611
- reset3();
2148
+ reset2();
2612
2149
  return;
2613
2150
  }
2614
2151
  active = true;
@@ -2617,7 +2154,7 @@ function apply3(value) {
2617
2154
  watchSheets();
2618
2155
  refresh();
2619
2156
  }
2620
- function reset3() {
2157
+ function reset2() {
2621
2158
  if (!active)
2622
2159
  return;
2623
2160
  size = null;
@@ -2728,10 +2265,10 @@ function rewriteMediaText(text2, feature, value) {
2728
2265
  return queries.map((query) => rewriteQuery(query, feature, value)).join(", ");
2729
2266
  }
2730
2267
  function rewriteAll(text2, value) {
2731
- let next2 = text2;
2268
+ let next = text2;
2732
2269
  for (const [feature, reads] of emulated(value))
2733
- next2 = rewriteMediaText(next2, feature, reads);
2734
- return next2;
2270
+ next = rewriteMediaText(next, feature, reads);
2271
+ return next;
2735
2272
  }
2736
2273
  function mentionsFeature(text2) {
2737
2274
  const lower = text2.toLowerCase();
@@ -2804,11 +2341,11 @@ function applyCss() {
2804
2341
  return;
2805
2342
  originals.set(rule, original2);
2806
2343
  }
2807
- const next2 = rewriteAll(original2, current2);
2808
- if (next2 === text2)
2344
+ const next = rewriteAll(original2, current2);
2345
+ if (next === text2)
2809
2346
  return;
2810
2347
  try {
2811
- rule.media.mediaText = next2;
2348
+ rule.media.mediaText = next;
2812
2349
  } catch {}
2813
2350
  }, seen);
2814
2351
  }
@@ -2957,8 +2494,8 @@ function restoreListen() {
2957
2494
  nativeListen = null;
2958
2495
  addNative = null;
2959
2496
  }
2960
- function trackLists(query, next2) {
2961
- const list = next2(query);
2497
+ function trackLists(query, next) {
2498
+ const list = next(query);
2962
2499
  if (mentionsFeature(query))
2963
2500
  track2(list, query);
2964
2501
  return list;
@@ -2993,1015 +2530,67 @@ function ensureMatchMedia() {
2993
2530
  if (!emulating())
2994
2531
  return read2.call(this);
2995
2532
  const query = queries.get(this) ?? this.media;
2996
- return mentionsFeature(query) ? evaluate(query) : read2.call(this);
2997
- }
2998
- });
2999
- }
3000
- function applyColorScheme() {
3001
- const root = document.documentElement;
3002
- if (colorScheme === null)
3003
- colorScheme = root.style.getPropertyValue("color-scheme");
3004
- const value = current2.scheme === "system" ? colorScheme : current2.scheme;
3005
- if (value)
3006
- root.style.setProperty("color-scheme", value);
3007
- else
3008
- root.style.removeProperty("color-scheme");
3009
- const own = current2.scheme !== "system" && value !== colorScheme;
3010
- markInline(root, "color-scheme", own ? root.style.getPropertyValue("color-scheme") : null);
3011
- }
3012
- function coarse(view) {
3013
- const below = view.matchMedia;
3014
- const touch = { ...SYSTEM_MEDIA, touch: true };
3015
- view.matchMedia = function matchMedia(query) {
3016
- return below.call(view, rewriteAll(String(query), touch));
3017
- };
3018
- }
3019
- function apply4(value) {
3020
- current2 = value;
3021
- ensureMatchMedia();
3022
- ensureObserver();
3023
- applyColorScheme();
3024
- applyCss();
3025
- refresh2();
3026
- }
3027
- function reset4() {
3028
- apply4(SYSTEM_MEDIA);
3029
- }
3030
- function teardown() {
3031
- observer2?.disconnect();
3032
- observer2 = null;
3033
- if (frame2) {
3034
- cancelAnimationFrame(frame2);
3035
- frame2 = 0;
3036
- }
3037
- if (patched) {
3038
- removeLayer("media");
3039
- restoreListen();
3040
- if (nativeMatches)
3041
- Object.defineProperty(MediaQueryList.prototype, "matches", nativeMatches);
3042
- nativeMatches = null;
3043
- readMatches = null;
3044
- patched = false;
3045
- }
3046
- colorScheme = null;
3047
- }
3048
- function destroy() {
3049
- reset4();
3050
- for (const ref of tracked) {
3051
- const list = ref.deref();
3052
- if (list)
3053
- guardFirst(list);
3054
- }
3055
- teardown();
3056
- Reflect.deleteProperty(window, EARLY2);
3057
- }
3058
-
3059
- // src/engine/mockdata.ts
3060
- function sides2(top, right, bottom, left) {
3061
- return { top, right, bottom, left };
3062
- }
3063
- function pill(kind, x, y, width, height) {
3064
- return { kind, x, y, width, height };
3065
- }
3066
- function dot(kind, x, y, size2) {
3067
- return { kind, x: x - size2 / 2, y: y - size2 / 2, width: size2, height: size2 };
3068
- }
3069
- var left = (at, length) => ({ side: "left", at, length });
3070
- var right = (at, length, out) => ({
3071
- side: "right",
3072
- at,
3073
- length,
3074
- out
3075
- });
3076
- var top = (at, length, out) => ({
3077
- side: "top",
3078
- at,
3079
- length,
3080
- out
3081
- });
3082
- var IPHONE_LEFT = [left(185, 41.7), left(257.4, 67.6), left(343.2, 67.6)];
3083
- function iphoneRight(control) {
3084
- return [right(280.7, 106.9), right(control, 103.3, 1)];
3085
- }
3086
- var BODIES = {
3087
- "iphone-18-pro": {
3088
- bezel: sides2(15.7, 15.7, 15.7, 15.7),
3089
- screenRadius: 62,
3090
- bodyRadius: 77.7,
3091
- out: 3,
3092
- front: [pill("sensor", 154, 14.3, 94, 36.1)],
3093
- buttons: [left(186, 41.7), left(258.3, 67.7), left(344, 68), right(281.7, 107, 2.7)]
3094
- },
3095
- "iphone-18-pro-max": {
3096
- bezel: sides2(15.3, 15.3, 15.3, 15.3),
3097
- screenRadius: 62,
3098
- bodyRadius: 77.3,
3099
- out: 2.7,
3100
- front: [pill("sensor", 173.2, 14.5, 93.6, 35.8)],
3101
- buttons: [left(186.3, 41.7), left(258.7, 67.7), left(344.3, 67.7), right(282, 106.7)]
3102
- },
3103
- "iphone-duo-closed": {
3104
- bezel: sides2(16.3, 16, 16, 25.7),
3105
- screenRadius: [8, 59, 59, 8],
3106
- bodyRadius: [10, 75, 75, 10],
3107
- out: 2.7,
3108
- front: [dot("sensor", 418.35, 47.75, 36.3)],
3109
- buttons: [right(202.7, 112.7), top(235, 65.7, 2.3), top(316, 65.7, 2.3)]
3110
- },
3111
- "iphone-duo-open": {
3112
- bezel: sides2(20.3, 20.7, 20.7, 20.7),
3113
- screenRadius: 55,
3114
- bodyRadius: 75.7,
3115
- out: 2.7,
3116
- front: [],
3117
- buttons: [left(134.3, 57), left(206.3, 65.7), top(202.3, 112.7)]
3118
- },
3119
- "iphone-air": {
3120
- bezel: sides2(15.3, 15.3, 15.3, 15.3),
3121
- screenRadius: 62,
3122
- bodyRadius: 77.3,
3123
- out: 2.7,
3124
- front: [pill("sensor", 147.33, 20, 125.33, 36.67)],
3125
- buttons: [left(185, 41.7), left(257.3, 67.7), left(343, 67.7), right(280.7, 106.7, 3)]
3126
- },
3127
- "iphone-17": {
3128
- bezel: sides2(14.7, 14.7, 14.7, 14.7),
3129
- screenRadius: 62,
3130
- bodyRadius: 76.7,
3131
- out: 3,
3132
- front: [pill("sensor", 138.33, 14, 125.33, 36.67)],
3133
- buttons: [left(185, 41.7), left(257.3, 67.7), left(342.7, 68), right(280.3, 107, 2.7)]
3134
- },
3135
- "iphone-17-pro": {
3136
- bezel: sides2(15.7, 15.7, 15.7, 15.7),
3137
- screenRadius: 62,
3138
- bodyRadius: 77.7,
3139
- out: 3,
3140
- front: [pill("sensor", 138.33, 14, 125.33, 36.67)],
3141
- buttons: [left(186, 41.7), left(258.3, 67.7), left(344, 67.7), right(281.7, 107, 2.7)]
3142
- },
3143
- "iphone-17-pro-max": {
3144
- bezel: sides2(15.3, 15.3, 15.3, 15.3),
3145
- screenRadius: 62,
3146
- bodyRadius: 77.3,
3147
- out: 2.7,
3148
- front: [pill("sensor", 157.33, 14, 125.33, 36.67)],
3149
- buttons: [left(186.3, 41.7), left(258.7, 67.7), left(344.3, 67.7), right(282, 106.7)]
3150
- },
3151
- "iphone-16": {
3152
- bezel: sides2(19.7, 19.7, 19.7, 19.7),
3153
- screenRadius: 55.8,
3154
- bodyRadius: 75.5,
3155
- out: 2.7,
3156
- front: [pill("sensor", 134, 11.3, 124.9, 36.7)],
3157
- buttons: [...IPHONE_LEFT, ...iphoneRight(529.5)]
3158
- },
3159
- "iphone-16-plus": {
3160
- bezel: sides2(19.7, 19.7, 19.7, 19.7),
3161
- screenRadius: 55.8,
3162
- bodyRadius: 75.5,
3163
- out: 2.7,
3164
- front: [pill("sensor", 152.3, 11.3, 125.4, 36.7)],
3165
- buttons: [...IPHONE_LEFT, ...iphoneRight(608.5)]
3166
- },
3167
- "iphone-16-pro": {
3168
- bezel: sides2(14.7, 14.7, 14.7, 14.7),
3169
- screenRadius: 63.2,
3170
- bodyRadius: 77.9,
3171
- out: 2.7,
3172
- front: [pill("sensor", 138.33, 14, 125.33, 36.67)],
3173
- buttons: [...IPHONE_LEFT, ...iphoneRight(541.3)]
3174
- },
3175
- "iphone-16-pro-max": {
3176
- bezel: sides2(14.3, 14.3, 14.3, 14.3),
3177
- screenRadius: 63.6,
3178
- bodyRadius: 77.9,
3179
- out: 2.7,
3180
- front: [pill("sensor", 157.3, 14, 125.4, 36.7)],
3181
- buttons: [...IPHONE_LEFT, ...iphoneRight(622.4)]
3182
- },
3183
- "iphone-se": {
3184
- bezel: sides2(110.2, 28.1, 110.3, 28.1),
3185
- screenRadius: 0,
3186
- bodyRadius: 65.6,
3187
- out: 2.6,
3188
- front: [
3189
- pill("slot", 149.5, -55.4, 76.1, 7.7),
3190
- dot("lens", 119.3, -51.5, 14),
3191
- { ...dot("home", 187.5, 718, 69.9), key: 60 }
3192
- ],
3193
- buttons: [left(94.6, 36), left(187.5, 68.1), left(268.3, 68.1), right(188, 68.1)]
3194
- },
3195
- "pixel-10": {
3196
- bezel: sides2(21, 22.1, 21.4, 22.5),
3197
- screenRadius: 55,
3198
- bodyRadius: 77,
3199
- out: 3.1,
3200
- front: [dot("sensor", 205.6, 33.9, 29.7)],
3201
- buttons: [right(269.6, 77), right(389.3, 134.2)]
3202
- },
3203
- "pixel-10-pro": {
3204
- bezel: sides2(20, 20.7, 17.3, 19.7),
3205
- screenRadius: 59,
3206
- bodyRadius: 79,
3207
- out: 3,
3208
- front: [dot("sensor", 213.6, 34.3, 30.6)],
3209
- buttons: [right(276.4, 78.4), right(399.1, 137)]
3210
- },
3211
- "pixel-10-pro-xl": {
3212
- bezel: sides2(18.3, 20.3, 18, 20),
3213
- screenRadius: 52,
3214
- bodyRadius: 71,
3215
- out: 2.3,
3216
- front: [dot("sensor", 224, 34.8, 30.2)],
3217
- buttons: [right(280.5, 77), right(401.2, 134.4)]
3218
- },
3219
- "pixel-10a": {
3220
- bezel: sides2(24, 24.8, 24, 24.8),
3221
- screenRadius: 55,
3222
- bodyRadius: 79,
3223
- out: 3.1,
3224
- front: [dot("sensor", 205.2, 33.3, 30.5)],
3225
- buttons: [right(273, 75.9), right(393.1, 132.7)]
3226
- },
3227
- "pixel-9": {
3228
- bezel: sides2(21.9, 22.2, 21.9, 22.2),
3229
- screenRadius: 55,
3230
- bodyRadius: 77,
3231
- out: 2.5,
3232
- front: [dot("sensor", 205.5, 33, 32)],
3233
- buttons: [right(290, 70), right(385, 135)]
3234
- },
3235
- "pixel-9-pro": {
3236
- bezel: sides2(20.3, 20.3, 19, 20),
3237
- screenRadius: 58,
3238
- bodyRadius: 78,
3239
- out: 2.3,
3240
- front: [dot("sensor", 213.4, 33.7, 30.9)],
3241
- buttons: [right(269.7, 77.7), right(392.1, 142.7)]
3242
- },
3243
- "pixel-9-pro-xl": {
3244
- bezel: sides2(18.7, 19.3, 17.3, 19),
3245
- screenRadius: 57,
3246
- bodyRadius: 76,
3247
- out: 2.3,
3248
- front: [dot("sensor", 224, 32.8, 30.8)],
3249
- buttons: [right(274.1, 75.7), right(393.8, 139.4)]
3250
- },
3251
- "ipad-mini": {
3252
- bezel: sides2(60.6, 60.4, 60.6, 60.4),
3253
- screenRadius: 21.5,
3254
- bodyRadius: 77,
3255
- out: 2.5,
3256
- front: [dot("lens", 372, -35, 16)],
3257
- buttons: [top(82.3, 64.6), top(159.7, 64.6), top(673.5, 109.9)]
3258
- },
3259
- "ipad-air-11": {
3260
- bezel: sides2(53.5, 53.9, 53.5, 53.9),
3261
- screenRadius: 18,
3262
- bodyRadius: 66.5,
3263
- out: 2.5,
3264
- front: [dot("lens", 850.5, 540.6, 16)],
3265
- buttons: [top(772.9, 89), right(75.1, 52.3), right(137.8, 52.3)]
3266
- },
3267
- "ipad-pro-13": {
3268
- bezel: sides2(43.7, 44, 43.7, 44),
3269
- screenRadius: 30,
3270
- bodyRadius: 74.8,
3271
- out: 2.5,
3272
- front: [dot("lens", 1051.6, 688, 13.9)],
3273
- buttons: [top(984.7, 62.7), right(74.3, 52.3), right(137, 52.3)]
3274
- }
3275
- };
3276
-
3277
- // src/engine/browserui.ts
3278
- var LAYOUTS = {
3279
- safari: ["compact", "bottom", "top", "off"],
3280
- chrome: ["top", "bottom", "off"]
3281
- };
3282
- var DUO_COVER = {
3283
- column: 84,
3284
- bottom: 98,
3285
- minimized: 60,
3286
- axis: 48,
3287
- time: { y: 91.5, size: 15.75 },
3288
- ring: { y: 129.9, radius: 18.9, stroke: 3.5 },
3289
- buttons: [174.2, 234.2],
3290
- capsule: 102,
3291
- gap: 34,
3292
- inset: 24,
3293
- across: {
3294
- top: 80,
3295
- minimized: 26,
3296
- side: 7.33,
3297
- address: { x: 209, width: 260 },
3298
- end: 149.33
3299
- }
3300
- };
3301
- var DUO_INNER = {
3302
- top: 80,
3303
- minimized: 51,
3304
- axis: 47.67,
3305
- time: { x: 99.83, y: 47.4, size: 15.75 },
3306
- ring: { y: 47.9, radius: 18.9, stroke: 3.5 },
3307
- side: 6,
3308
- address: { landscape: { x: 295, width: 361 }, portrait: { x: 184, width: 241.5 } },
3309
- end: 232,
3310
- pill: 23.5
3311
- };
3312
- var DUO_ROW = 26;
3313
- var DUO_PILL = { height: 20, size: 12, pad: 15 };
3314
- function runsUnderBars(id) {
3315
- return !SAFARI2[id]?.duo;
3316
- }
3317
- var DUO_LAYOUTS = ["compact", "off"];
3318
- var STATUS_PRO = { time: 73.83, right: 369.67 };
3319
- var STATUS_MAX = { time: 83.17, right: 401.67 };
3320
- var SAFARI2 = {
3321
- "iphone-18-pro": { top: 62, side: 62, faceId: true },
3322
- "iphone-18-pro-max": { top: 62, side: 62, faceId: true },
3323
- "iphone-duo-closed": { top: 0, side: 0, faceId: true, duo: "cover" },
3324
- "iphone-duo-open": { top: DUO_INNER.top, side: 0, faceId: true, duo: "inner" },
3325
- "iphone-air": { top: 68, side: 68, faceId: true, status: { time: 77.17, right: 387.67 } },
3326
- "iphone-17": { top: 62, side: 62, faceId: true, status: STATUS_PRO },
3327
- "iphone-17-pro": { top: 62, side: 62, faceId: true, status: STATUS_PRO },
3328
- "iphone-17-pro-max": { top: 62, side: 62, faceId: true, status: STATUS_MAX },
3329
- "iphone-16": { top: 59, side: 59, faceId: true },
3330
- "iphone-16-plus": { top: 59, side: 59, faceId: true },
3331
- "iphone-16-pro": { top: 62, side: 62, faceId: true, status: STATUS_PRO },
3332
- "iphone-16-pro-max": { top: 62, side: 62, faceId: true, status: STATUS_MAX },
3333
- "iphone-se": { top: 20, side: 0, faceId: false }
3334
- };
3335
- var CHROME2 = {
3336
- "pixel-10": { top: 69, tall: 923 },
3337
- "pixel-10-pro": { top: 69 },
3338
- "pixel-10-pro-xl": { top: 70, tall: 997 },
3339
- "pixel-10a": { top: 68, tall: 923 },
3340
- "pixel-9": { top: 66, tall: 923 },
3341
- "pixel-9-pro": { top: 68 },
3342
- "pixel-9-pro-xl": { top: 66, tall: 997 }
3343
- };
3344
- var SAFARI_BARS = {
3345
- compact: 98,
3346
- bottom: 158,
3347
- bottomSe: 152,
3348
- topBar: 60,
3349
- topBottom: 92,
3350
- pill: 58,
3351
- topPill: 44,
3352
- landscape: 64
3353
- };
3354
- var CHROME_BARS = { toolbar: 56, chin: 24, landscapeTop: 24 };
3355
- function platformOf(id) {
3356
- if (SAFARI2[id])
3357
- return "safari";
3358
- if (CHROME2[id])
3359
- return "chrome";
3360
- return null;
3361
- }
3362
- function layoutOptions(id) {
3363
- if (SAFARI2[id]?.duo)
3364
- return DUO_LAYOUTS;
3365
- const platform = platformOf(id);
3366
- return platform ? LAYOUTS[platform] : [];
3367
- }
3368
- function layoutOf(id, browser) {
3369
- const options = layoutOptions(id);
3370
- const fallback = options[0];
3371
- if (!fallback)
3372
- return null;
3373
- return browser !== "auto" && options.includes(browser) ? browser : fallback;
3374
- }
3375
- function rect(x, y, width, height) {
3376
- return { x, y, width, height };
3377
- }
3378
- function viewportOf(device, orientation, layout, minimized, edge = false) {
3379
- const { width: W, height: H } = turn(device, orientation);
3380
- const whole = rect(0, 0, W, H);
3381
- if (!layout || layout === "off")
3382
- return whole;
3383
- const safari = SAFARI2[device.id];
3384
- if (safari?.duo === "cover" && orientation === "landscape") {
3385
- const { across } = DUO_COVER;
3386
- const top2 = minimized ? across.minimized : across.top;
3387
- return rect(0, top2, W, H - top2);
3388
- }
3389
- if (safari?.duo === "cover") {
3390
- const bottom = minimized ? DUO_COVER.minimized : DUO_COVER.bottom;
3391
- return rect(0, 0, W - DUO_COVER.column, H - bottom);
3392
- }
3393
- if (safari?.duo === "inner") {
3394
- const top2 = minimized ? DUO_INNER.minimized : DUO_INNER.top;
3395
- return rect(0, top2, W, H - top2);
3396
- }
3397
- if (safari) {
3398
- if (edge && orientation === "landscape")
3399
- return rect(safari.side, 0, W - 2 * safari.side, H);
3400
- if (orientation === "landscape") {
3401
- const top2 = minimized ? 0 : SAFARI_BARS.landscape;
3402
- return rect(safari.side, top2, W - 2 * safari.side, H - top2);
3403
- }
3404
- const T = safari.top;
3405
- if (layout === "top") {
3406
- const top2 = T + (minimized ? SAFARI_BARS.topPill : SAFARI_BARS.topBar);
3407
- const bottom = minimized ? H : H - SAFARI_BARS.topBottom;
3408
- return rect(0, top2, W, bottom - top2);
3409
- }
3410
- const card = safari.faceId ? SAFARI_BARS.bottom : SAFARI_BARS.bottomSe;
3411
- const bar = minimized ? SAFARI_BARS.pill : layout === "bottom" ? card : SAFARI_BARS.compact;
3412
- return rect(0, T, W, H - bar - T);
3413
- }
3414
- const chrome = CHROME2[device.id];
3415
- if (!chrome)
3416
- return whole;
3417
- const toolbar = minimized ? 0 : CHROME_BARS.toolbar;
3418
- if (orientation === "landscape") {
3419
- const top2 = CHROME_BARS.landscapeTop + toolbar;
3420
- return rect(0, top2, W, H - top2);
3421
- }
3422
- const tall = chrome.tall ?? H;
3423
- const chin = minimized ? 0 : CHROME_BARS.chin;
3424
- const height = tall - chrome.top - toolbar - chin;
3425
- return rect(0, chrome.top + (layout === "top" ? toolbar : 0), W, height);
3426
- }
3427
- function capsule(kind, box, marks = []) {
3428
- return { kind, ...box, radius: Math.min(box.width, box.height) / 2, marks };
3429
- }
3430
- function mark(glyph, x, y) {
3431
- return { glyph, x, y };
3432
- }
3433
- var SCRIM = [
3434
- [0, 0.81],
3435
- [20, 0.67],
3436
- [40, 0.41],
3437
- [60, 0.16],
3438
- [80, 0.03],
3439
- [100, 0]
3440
- ];
3441
- function alphaAt(fade, y) {
3442
- const at = y - fade.y;
3443
- const { stops } = fade;
3444
- const first = stops[0];
3445
- if (!first || at <= first.at)
3446
- return first?.alpha ?? 0;
3447
- for (let i = 1;i < stops.length; i++) {
3448
- const from = stops[i - 1];
3449
- const to = stops[i];
3450
- if (!from || !to || at > to.at)
3451
- continue;
3452
- return from.alpha + (to.alpha - from.alpha) * (at - from.at) / (to.at - from.at || 1);
3453
- }
3454
- return stops.at(-1)?.alpha ?? 0;
3455
- }
3456
- function sensorMiddle(id) {
3457
- const sensor = BODIES[id]?.front.find((front) => front.kind === "sensor");
3458
- if (!sensor)
3459
- return null;
3460
- return { x: sensor.x + sensor.width / 2, y: sensor.y + sensor.height / 2, width: sensor.width };
3461
- }
3462
- var SAFARI_TEXT = { field: 17, pill: 13 };
3463
- var SAFARI_PILL = { height: 32, size: SAFARI_TEXT.pill, pad: 33 };
3464
- var BOTTOM_ROW = [0.1032, 0.3056, 0.4965, 0.6925, 0.8872];
3465
- var TOP_ROW = [0.0884, 0.2986, 0.4962, 0.6994, 0.9012];
3466
- var ROW = ["back", "forward", "share", "bookmarks", "tabs"];
3467
- function domainPill(x, top2, look = SAFARI_PILL) {
3468
- const { height, size: size2, pad } = look;
3469
- return {
3470
- kind: "pill",
3471
- x,
3472
- y: top2,
3473
- width: 0,
3474
- height,
3475
- radius: height / 2,
3476
- marks: [],
3477
- text: { x, y: top2 + height / 2, size: size2, pad }
3478
- };
3479
- }
3480
- function address(kind, box, page, reload) {
3481
- const y = box.y + box.height / 2;
3482
- return {
3483
- ...capsule(kind, box, [
3484
- mark("page", box.x + page, y),
3485
- mark("reload", box.x + box.width - reload, y)
3486
- ]),
3487
- text: { x: box.x + box.width / 2, y, size: SAFARI_TEXT.field }
3488
- };
3489
- }
3490
- function acrossRow(left2, right2, y) {
3491
- const s = left2;
3492
- const row = (x2, width2) => rect(x2, y, width2, 44);
3493
- const end = row(right2 - 10 - 132, 132);
3494
- const middle = y + 22;
3495
- const [from, to] = [s + 66 + 44 + 8, end.x - 8];
3496
- const width = Math.min(318, to - from);
3497
- const x = Math.min(Math.max((left2 + right2) / 2 - width / 2, from), to - width);
3498
- return [
3499
- capsule("glass", row(s + 10, 44), [mark("back", s + 32, middle)]),
3500
- capsule("glass", row(s + 66, 44), [mark("bookmarks", s + 88, middle)]),
3501
- address("glass", row(x, width), 24, 22),
3502
- capsule("glass", end, [
3503
- mark("share", end.x + 22, middle),
3504
- mark("plus", end.x + 66, middle),
3505
- mark("tabs", end.x + 110, middle)
3506
- ])
3507
- ];
3508
- }
3509
- function duoRow(side, field, endX, end) {
3510
- const y = DUO_ROW;
3511
- const middle = y + 22;
3512
- const row = (x, width) => rect(x, y, width, 44);
3513
- return [
3514
- capsule("glass", row(side + 10, 44), [mark("back", side + 32, middle)]),
3515
- capsule("glass", row(side + 66, 44), [mark("bookmarks", side + 88, middle)]),
3516
- address("glass", row(field.x, field.width), 22, 24.5),
3517
- capsule("glass", row(endX, 44 * end.length), end.map((glyph, at) => mark(glyph, endX + 22 + 44 * at, middle)))
3518
- ];
3519
- }
3520
- function duoCover(bars, W, H, orientation, minimized) {
3521
- const c = DUO_COVER;
3522
- if (orientation === "landscape") {
3523
- const { across } = c;
3524
- if (minimized)
3525
- bars.shapes = [domainPill(W / 2, (across.minimized - DUO_PILL.height) / 2, DUO_PILL)];
3526
- else
3527
- bars.shapes = duoRow(across.side, across.address, W - across.end, ["share", "plus", "tabs"]);
3528
- return bars;
3529
- }
3530
- const page = W - c.column;
3531
- const x = W - c.axis;
3532
- bars.column = { x, strip: false, time: { x, ...c.time }, ring: { ...c.ring } };
3533
- if (minimized) {
3534
- bars.shapes = [domainPill(page / 2, H - 46)];
3535
- return bars;
3536
- }
3537
- const button = (y, glyph) => capsule("glass", rect(x - 24, y, 48, 48), [mark(glyph, x, y + 24)]);
3538
- const [back = 0, reader = 0] = c.buttons;
3539
- const low = H - c.gap - c.capsule;
3540
- bars.shapes = [
3541
- address("glass", rect(c.inset, H - c.gap - 48, page - 2 * c.inset, 48), 24, 24),
3542
- button(back, "back"),
3543
- button(reader, "bookmarks"),
3544
- capsule("glass", rect(x - 24, low, 48, c.capsule), [mark("plus", x, low + 24), mark("tabs", x, H - c.gap - 24)])
3545
- ];
3546
- return bars;
3547
- }
3548
- function duoInner(bars, W, orientation, minimized) {
3549
- const d = DUO_INNER;
3550
- if (minimized) {
3551
- bars.shapes = [domainPill(W / 2, d.pill, DUO_PILL)];
3552
- return bars;
3553
- }
3554
- bars.column = { x: W - d.axis, strip: true, time: { ...d.time, x: W - d.time.x }, ring: { ...d.ring } };
3555
- bars.shapes = duoRow(d.side, d.address[orientation], W - d.end, ["plus", "tabs"]);
3556
- return bars;
3557
- }
3558
- function safariBars(device, spec, orientation, layout, minimized) {
3559
- const { width: W, height: H } = turn(device, orientation);
3560
- const bars = {
3561
- platform: "safari",
3562
- layout,
3563
- screen: device,
3564
- orientation,
3565
- minimized,
3566
- status: null,
3567
- column: null,
3568
- shapes: [],
3569
- chin: null,
3570
- hairline: null,
3571
- scrim: null,
3572
- edge: false
3573
- };
3574
- if (spec.duo === "cover")
3575
- return duoCover(bars, W, H, orientation, minimized);
3576
- if (spec.duo === "inner")
3577
- return duoInner(bars, W, orientation, minimized);
3578
- if (orientation === "landscape") {
3579
- if (!minimized)
3580
- bars.shapes = acrossRow(spec.side, W - spec.side, 10);
3581
- return bars;
3582
- }
3583
- bars.status = safariStatus(device.id, spec, W);
3584
- const page = viewportOf(device, orientation, layout, minimized);
3585
- const T = spec.top;
3586
- if (minimized) {
3587
- bars.shapes = [domainPill(W / 2, layout === "top" ? T : H - 46)];
3588
- const stops = SCRIM.map(([at, alpha]) => ({ at, alpha }));
3589
- bars.scrim = { y: 0, height: 100, stops, at: { x: W / 2, y: page.y + 1 } };
3590
- return bars;
3591
- }
3592
- if (layout === "compact") {
3593
- const y = H - 82;
3594
- const middle = y + 24;
3595
- bars.shapes = [
3596
- capsule("glass", rect(34, y, 48, 48), [mark("back", 58, middle)]),
3597
- address("glass", rect(90, y, W - 180, 48), 24, 22),
3598
- capsule("glass", rect(W - 82, y, 48, 48), [mark("tabs", W - 58, middle)])
3599
- ];
3600
- return bars;
3601
- }
3602
- if (layout === "bottom") {
3603
- const inset2 = spec.faceId ? 14 : 8;
3604
- const card = rect(inset2, H - inset2 - 128, W - 2 * inset2, 128);
3605
- const field = rect(card.x + 22, card.y + 16, card.width - 44, 48);
3606
- const row2 = card.y + 92;
3607
- bars.shapes = [
3608
- {
3609
- kind: "card",
3610
- ...card,
3611
- radius: 40,
3612
- marks: ROW.map((glyph, at) => {
3613
- return mark(glyph, card.x + card.width * (BOTTOM_ROW[at] ?? 0), row2);
3614
- })
3615
- },
3616
- address("field", field, 18, 16)
3617
- ];
3618
- return bars;
3619
- }
3620
- const top2 = rect(16, T, W - 32, 44);
3621
- const bottom = rect(28, H - 76, W - 56, 48);
3622
- const row = bottom.y + 24;
3623
- bars.shapes = [
3624
- address("glass", top2, 23, 18),
3625
- capsule("glass", bottom, ROW.map((glyph, at) => mark(glyph, bottom.x + bottom.width * (TOP_ROW[at] ?? 0), row)))
3626
- ];
3627
- return bars;
2533
+ return mentionsFeature(query) ? evaluate(query) : read2.call(this);
2534
+ }
2535
+ });
3628
2536
  }
3629
- function safariStatus(id, spec, W) {
3630
- const island = sensorMiddle(id);
3631
- if (!spec.faceId) {
3632
- return {
3633
- height: spec.top,
3634
- time: { x: W / 2, y: 10, size: 15 },
3635
- icons: { x: 6, y: 10, align: "start" },
3636
- battery: { x: W - 7, y: 10 },
3637
- large: false
3638
- };
3639
- }
3640
- const large = W >= 420;
3641
- const size2 = large ? 19 : 18;
3642
- if (!island) {
3643
- const y = spec.top / 2 + 2;
3644
- return {
3645
- height: spec.top,
3646
- time: { x: 58, y, size: size2 },
3647
- icons: { x: W - 36, y, align: "end" },
3648
- large
3649
- };
3650
- }
3651
- const left2 = island.x - island.width / 2;
3652
- if (left2 > W / 2) {
3653
- return {
3654
- height: spec.top,
3655
- time: { x: 52, y: island.y, size: size2 },
3656
- icons: { x: left2 - 12, y: island.y, align: "end" },
3657
- large
3658
- };
3659
- }
3660
- return {
3661
- height: spec.top,
3662
- time: { x: spec.status?.time ?? left2 * 0.535, y: island.y, size: size2 },
3663
- icons: { x: spec.status?.right ?? W - (large ? 38.33 : 32.33), y: island.y, align: "end" },
3664
- large
3665
- };
2537
+ function applyColorScheme() {
2538
+ const root = document.documentElement;
2539
+ if (colorScheme === null)
2540
+ colorScheme = root.style.getPropertyValue("color-scheme");
2541
+ const value = current2.scheme === "system" ? colorScheme : current2.scheme;
2542
+ if (value)
2543
+ root.style.setProperty("color-scheme", value);
2544
+ else
2545
+ root.style.removeProperty("color-scheme");
2546
+ const own = current2.scheme !== "system" && value !== colorScheme;
2547
+ markInline(root, "color-scheme", own ? root.style.getPropertyValue("color-scheme") : null);
3666
2548
  }
3667
- function chromeStatus(id, height, W, orientation) {
3668
- const hole = orientation === "portrait" ? sensorMiddle(id) : null;
3669
- const y = hole?.y ?? height / 2;
3670
- const side = orientation === "portrait" ? 26 : 56;
3671
- return {
3672
- height,
3673
- time: { x: side, y, size: 14 },
3674
- icons: { x: W - side, y, align: "end" },
3675
- large: false
2549
+ function coarse(view) {
2550
+ const below = view.matchMedia;
2551
+ const touch = { ...SYSTEM_MEDIA, touch: true };
2552
+ view.matchMedia = function matchMedia(query) {
2553
+ return below.call(view, rewriteAll(String(query), touch));
3676
2554
  };
3677
2555
  }
3678
- function chromeBars(device, spec, orientation, layout, minimized) {
3679
- const { width: W, height: H } = turn(device, orientation);
3680
- const portrait = orientation === "portrait";
3681
- const statusHeight = portrait ? spec.top : CHROME_BARS.landscapeTop;
3682
- const page = viewportOf(device, orientation, layout, minimized);
3683
- const bars = {
3684
- platform: "chrome",
3685
- layout,
3686
- screen: device,
3687
- orientation,
3688
- minimized,
3689
- status: chromeStatus(device.id, statusHeight, W, orientation),
3690
- column: null,
3691
- shapes: [],
3692
- chin: null,
3693
- hairline: null,
3694
- scrim: null,
3695
- edge: false
3696
- };
3697
- if (minimized)
3698
- return bars;
3699
- const atTop = layout === "top" || !portrait;
3700
- const toolbarY = atTop ? statusHeight : page.y + page.height;
3701
- const toolbar = rect(0, toolbarY, W, CHROME_BARS.toolbar);
3702
- const under = toolbarY + CHROME_BARS.toolbar;
3703
- const chin = atTop ? page.y + page.height : under;
3704
- bars.chin = portrait ? rect(0, chin, W, H - chin) : null;
3705
- bars.hairline = rect(0, atTop ? under : toolbarY, W, 1);
3706
- const middle = toolbarY + CHROME_BARS.toolbar / 2;
3707
- const menu = W - 8 - 24;
3708
- const tabs = menu - 48;
3709
- const plus = tabs - 24 - 26;
3710
- const pillLeft = 48 + 4;
3711
- const pillRight = plus - 26 - 4;
3712
- const pill2 = rect(pillLeft, middle - 20, pillRight - pillLeft, 40);
3713
- bars.shapes = [
3714
- {
3715
- kind: "toolbar",
3716
- ...toolbar,
3717
- radius: 0,
3718
- marks: [
3719
- mark("home", 24, middle),
3720
- mark("plus", plus, middle),
3721
- mark("switcher", tabs, middle),
3722
- mark("menu", menu, middle)
3723
- ]
3724
- },
3725
- {
3726
- ...capsule("field", pill2, [mark("tune", pill2.x + 4 + 14, middle)]),
3727
- text: { x: pill2.x + 4 + 28 + 4, y: middle, size: 16 }
3728
- }
3729
- ];
3730
- return bars;
2556
+ function apply3(value) {
2557
+ current2 = value;
2558
+ ensureMatchMedia();
2559
+ ensureObserver();
2560
+ applyColorScheme();
2561
+ applyCss();
2562
+ refresh2();
3731
2563
  }
3732
- function barsOf(device, orientation, layout, minimized, edge = false) {
3733
- if (!layout || layout === "off")
3734
- return null;
3735
- const safari = SAFARI2[device.id];
3736
- if (safari) {
3737
- const bars = safariBars(device, safari, orientation, layout, minimized);
3738
- const upright = orientation === "portrait" || safari.duo !== undefined;
3739
- return { ...bars, edge: edge || upright };
3740
- }
3741
- const chrome = CHROME2[device.id];
3742
- if (chrome)
3743
- return chromeBars(device, chrome, orientation, layout, minimized);
3744
- return null;
2564
+ function reset3() {
2565
+ apply3(SYSTEM_MEDIA);
3745
2566
  }
3746
- var BARS_DOWN = 16;
3747
- var BARS_UP = 40;
3748
- var BARS_TOP = 1;
3749
- var BARS_LOCK = 450;
3750
- var BARS_START = { minimized: false, anchor: 0, y: 0, lockUntil: 0 };
3751
- function barsStep(state, event) {
3752
- if (event.type === "navigate")
3753
- return BARS_START;
3754
- if (event.type === "tap")
3755
- return { ...state, minimized: false, anchor: state.y };
3756
- if (event.type === "resize")
3757
- return { ...state, lockUntil: event.time + BARS_LOCK };
3758
- const { y, time } = event;
3759
- const room = event.room ?? 0;
3760
- const near = state.minimized && room > 0 && y - room <= BARS_TOP;
3761
- if (near)
3762
- return { ...state, minimized: false, y, anchor: y };
3763
- if (time < state.lockUntil)
3764
- return { ...state, y, anchor: y };
3765
- if (y <= BARS_TOP)
3766
- return { ...state, minimized: false, y, anchor: y };
3767
- if (state.minimized) {
3768
- const anchor2 = Math.max(state.anchor, y);
3769
- if (anchor2 - y >= BARS_UP)
3770
- return { ...state, minimized: false, y, anchor: y };
3771
- return { ...state, y, anchor: anchor2 };
2567
+ function teardown() {
2568
+ observer2?.disconnect();
2569
+ observer2 = null;
2570
+ if (frame2) {
2571
+ cancelAnimationFrame(frame2);
2572
+ frame2 = 0;
3772
2573
  }
3773
- const anchor = Math.min(state.anchor, y);
3774
- const left2 = room > 0 ? Math.min(y, event.rest ?? Infinity) : y;
3775
- const clear = left2 - 2 * room >= BARS_DOWN;
3776
- if (y - anchor >= BARS_DOWN && clear)
3777
- return { ...state, minimized: true, y, anchor: y };
3778
- return { ...state, y, anchor };
3779
- }
3780
-
3781
- // src/engine/mock.ts
3782
- function islandOf(id) {
3783
- const sensor = BODIES[id]?.front.find((front) => front.kind === "sensor");
3784
- return sensor && sensor.width > sensor.height ? sensor : null;
3785
- }
3786
- function round(kind, rect2) {
3787
- return { kind, ...rect2, radius: Math.min(rect2.width, rect2.height) / 2 };
3788
- }
3789
- function bar(button, out, body) {
3790
- const { side, at, length } = button;
3791
- if (side === "top") {
3792
- const y = body.y - out;
3793
- return { kind: "button", x: body.x + at, y, width: length, height: 2 * out, radius: out };
2574
+ if (patched) {
2575
+ removeLayer("media");
2576
+ restoreListen();
2577
+ if (nativeMatches)
2578
+ Object.defineProperty(MediaQueryList.prototype, "matches", nativeMatches);
2579
+ nativeMatches = null;
2580
+ readMatches = null;
2581
+ patched = false;
3794
2582
  }
3795
- const x = side === "left" ? body.x - out : body.x + body.width - out;
3796
- return { kind: "button", x, y: body.y + at, width: 2 * out, height: length, radius: out };
3797
- }
3798
- function keyOf(front) {
3799
- if (front.key === undefined)
3800
- return null;
3801
- const gap = (front.width - front.key) / 2;
3802
- return { x: front.x + gap, y: front.y + gap, width: front.key, height: front.key };
3803
- }
3804
- function turnRect(rect2, width, height, clockwise) {
3805
- const { x, y } = rect2;
3806
- const turned = { width: rect2.height, height: rect2.width };
3807
- return clockwise ? { ...rect2, ...turned, x: height - y - rect2.height, y: x } : { ...rect2, ...turned, x: y, y: width - x - rect2.width };
3808
- }
3809
- function turnSides(sides3, clockwise = false) {
3810
- return clockwise ? { top: sides3.left, right: sides3.top, bottom: sides3.right, left: sides3.bottom } : { top: sides3.right, right: sides3.bottom, bottom: sides3.left, left: sides3.top };
3811
- }
3812
- function turnRadius(radius, clockwise = false) {
3813
- if (typeof radius === "number")
3814
- return radius;
3815
- const [topLeft, topRight, bottomRight, bottomLeft] = radius;
3816
- return clockwise ? [bottomLeft, topLeft, topRight, bottomRight] : [topRight, bottomRight, bottomLeft, topLeft];
3817
- }
3818
- function placeIn2(mock, room) {
3819
- const dx = room.inset.left - mock.inset.left;
3820
- const dy = room.inset.top - mock.inset.top;
3821
- const move = (rect2) => ({ ...rect2, x: rect2.x + dx, y: rect2.y + dy });
3822
- const { width, height, inset: inset2 } = room;
3823
- return { ...mock, width, height, inset: inset2, body: move(mock.body), parts: mock.parts.map(move) };
3824
- }
3825
- function mockOf(id, orientation) {
3826
- const device = screenOf(id);
3827
- const shape = BODIES[id];
3828
- if (!device || !shape)
3829
- return null;
3830
- const { bezel, screenRadius, bodyRadius } = shape;
3831
- const out = (button) => button.out ?? shape.out;
3832
- const most = (side) => Math.max(0, ...shape.buttons.filter((button) => button.side === side).map(out));
3833
- const room = { top: most("top"), right: most("right"), left: most("left") };
3834
- const size2 = turn(device, "portrait");
3835
- const inset2 = {
3836
- top: bezel.top + room.top,
3837
- right: bezel.right + room.right,
3838
- bottom: bezel.bottom,
3839
- left: bezel.left + room.left
3840
- };
3841
- const width = size2.width + inset2.left + inset2.right;
3842
- const height = size2.height + inset2.top + inset2.bottom;
3843
- const body = {
3844
- x: room.left,
3845
- y: room.top,
3846
- width: size2.width + bezel.left + bezel.right,
3847
- height: size2.height + bezel.top + bezel.bottom
3848
- };
3849
- const at = ({ x, y, width: width2, height: height2 }) => {
3850
- return { x: inset2.left + x, y: inset2.top + y, width: width2, height: height2 };
3851
- };
3852
- const parts = [
3853
- ...shape.buttons.map((button) => bar(button, out(button), body)),
3854
- ...shape.front.flatMap((front) => {
3855
- const key = keyOf(front);
3856
- const shown = round(front.kind, at(front));
3857
- return key ? [shown, round("key", at(key))] : [shown];
3858
- })
3859
- ];
3860
- const upright = { width, height, inset: inset2, body, screenRadius, bodyRadius, parts };
3861
- if (orientation === "portrait")
3862
- return upright;
3863
- const clockwise = device.clockwise === true;
3864
- return {
3865
- ...upright,
3866
- width: height,
3867
- height: width,
3868
- inset: turnSides(inset2, clockwise),
3869
- body: turnRect(body, width, height, clockwise),
3870
- screenRadius: turnRadius(screenRadius, clockwise),
3871
- bodyRadius: turnRadius(bodyRadius, clockwise),
3872
- parts: upright.parts.map((part2) => turnRect(part2, width, height, clockwise))
3873
- };
3874
- }
3875
-
3876
- // src/engine/native.ts
3877
- var HAND_WAIT = 2000;
3878
- var SYSTEM_MEDIA2 = {
3879
- scheme: "system",
3880
- motion: "system",
3881
- contrast: "system",
3882
- transparency: "system"
3883
- };
3884
- function drawnAround(state) {
3885
- if (state.panel.docked || state.frame || state.vision !== "none" || state.zoom !== "fit")
3886
- return true;
3887
- const device = deviceOf(state.device);
3888
- if (!device)
3889
- return false;
3890
- if (device.postures)
3891
- return true;
3892
- const id = formId(state.device, state.posture);
3893
- if (state.mock && mockOf(id, state.orientation) !== null)
3894
- return true;
3895
- const layout = layoutOf(id, state.browser);
3896
- return layout !== null && layout !== "off";
3897
- }
3898
- function nativeViewport(state) {
3899
- if (!knobFrame(state) || drawnAround(state))
3900
- return null;
3901
- const device = deviceOf(state.device);
3902
- const touch = device?.touch === true;
3903
- return {
3904
- width: typeof state.width === "number" ? state.width : null,
3905
- height: typeof state.height === "number" ? state.height : null,
3906
- dpr: typeof state.dpr === "number" ? state.dpr : null,
3907
- mobile: device?.kind === "phone" || device?.kind === "tablet",
3908
- touch,
3909
- touchPointer: touch && state.touchPointer
3910
- };
2583
+ colorScheme = null;
3911
2584
  }
3912
- function nativeUa(value) {
3913
- const preset = uaPreset(value.preset);
3914
- if (preset) {
3915
- const { userAgent: userAgent2, platform, mobile, brands, uaPlatform, hints } = preset;
3916
- return { userAgent: userAgent2, platform, mobile, brands, uaPlatform, ...hints ? { hints } : {} };
2585
+ function destroy() {
2586
+ reset3();
2587
+ for (const ref of tracked) {
2588
+ const list = ref.deref();
2589
+ if (list)
2590
+ guardFirst(list);
3917
2591
  }
3918
- const userAgent = userAgentOf(value);
3919
- return userAgent === "" ? null : { userAgent, platform: "", mobile: false, brands: [], uaPlatform: "" };
3920
- }
3921
- function inPage(state, driver) {
3922
- if (!driver)
3923
- return state;
3924
- let next2 = state;
3925
- if (driver.text)
3926
- next2 = { ...next2, text: "system" };
3927
- if (driver.offline)
3928
- next2 = { ...next2, network: { ...next2.network, online: "system" } };
3929
- if (driver.media)
3930
- next2 = { ...next2, ...SYSTEM_MEDIA2 };
3931
- return next2;
3932
- }
3933
- function framing(state, driver) {
3934
- if (!driver?.viewport || !nativeViewport(state))
3935
- return state;
3936
- return { ...state, width: "full", height: "full", dpr: "system" };
3937
- }
3938
- var enabled = true;
3939
- function nativeEnabled() {
3940
- return enabled;
3941
- }
3942
- function enableNative(on) {
3943
- enabled = on;
3944
- }
3945
- var sent = new Map;
3946
- var pending = null;
3947
- function handing() {
3948
- return pending;
3949
- }
3950
- function hand(driver, part2, value) {
3951
- const call = driver[part2];
3952
- if (!call)
3953
- return;
3954
- const key = JSON.stringify(value);
3955
- if (sent.get(part2) === key)
3956
- return;
3957
- sent.set(part2, key);
3958
- const settled = settles(call(value))?.then(() => {
3959
- if (pending === settled)
3960
- pending = null;
3961
- });
3962
- if (settled)
3963
- pending = settled;
3964
- }
3965
- function settles(result) {
3966
- if (!(result instanceof Promise))
3967
- return null;
3968
- return Promise.race([
3969
- result.then(() => {}, () => {}),
3970
- new Promise((resolve) => setTimeout(resolve, HAND_WAIT))
3971
- ]);
3972
- }
3973
- function drive(driver, state) {
3974
- hand(driver, "text", state.text);
3975
- hand(driver, "offline", state.network.online === "offline");
3976
- const { scheme, motion, contrast: contrast2, transparency } = state;
3977
- hand(driver, "media", { scheme, motion, contrast: contrast2, transparency });
3978
- if (driver.viewport)
3979
- hand(driver, "viewport", nativeViewport(state));
3980
- driveUa(driver, state, driver.viewport !== undefined && nativeViewport(state) !== null);
3981
- }
3982
- function hostUa(state, sized) {
3983
- const brought = [deviceOf(state.device)?.ua, formOf(state.device, state.posture)?.ua];
3984
- if (sized || !brought.includes(state.ua.preset))
3985
- return nativeUa(state.ua);
3986
- const ua = state.panel.realPhone ? nativeUa(state.ua) : null;
3987
- return ua && { ...ua, frame: true };
3988
- }
3989
- function driveUa(driver, state, sized = false) {
3990
- if (driver.ua)
3991
- hand(driver, "ua", hostUa(state, sized));
3992
- }
3993
- function release(driver, ua = true) {
3994
- if (sent.size === 0)
3995
- return;
3996
- hand(driver, "text", "system");
3997
- hand(driver, "offline", false);
3998
- hand(driver, "media", SYSTEM_MEDIA2);
3999
- hand(driver, "viewport", null);
4000
- if (ua)
4001
- hand(driver, "ua", null);
4002
- for (const part2 of Array.from(sent.keys()))
4003
- if (ua || part2 !== "ua")
4004
- sent.delete(part2);
2592
+ teardown();
2593
+ Reflect.deleteProperty(window, EARLY2);
4005
2594
  }
4006
2595
 
4007
2596
  // src/engine/style.ts
@@ -4072,6 +2661,51 @@ function addStyle(root, css) {
4072
2661
  root.append(style);
4073
2662
  return style;
4074
2663
  }
2664
+ function switchedSheet(root, name) {
2665
+ const Sheet = constructable(root);
2666
+ if (Sheet) {
2667
+ const sheet2 = new Sheet;
2668
+ Reflect.set(sheet2, OWN2, true);
2669
+ const off = () => {
2670
+ root.adoptedStyleSheets = root.adoptedStyleSheets.filter((other) => other !== sheet2);
2671
+ };
2672
+ let gone = false;
2673
+ return {
2674
+ sheet: sheet2,
2675
+ on() {
2676
+ if (!gone && !root.adoptedStyleSheets.includes(sheet2))
2677
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet2];
2678
+ },
2679
+ off,
2680
+ remove() {
2681
+ gone = true;
2682
+ off();
2683
+ }
2684
+ };
2685
+ }
2686
+ const style = documentOf(root).createElement("style");
2687
+ style.setAttribute("data-devknobs", name);
2688
+ if (isDocument(root))
2689
+ (root.head ?? root.documentElement).appendChild(style);
2690
+ else
2691
+ root.append(style);
2692
+ const sheet = style.sheet;
2693
+ if (!sheet) {
2694
+ style.remove();
2695
+ return null;
2696
+ }
2697
+ sheet.disabled = true;
2698
+ return {
2699
+ sheet,
2700
+ on() {
2701
+ sheet.disabled = false;
2702
+ },
2703
+ off() {
2704
+ sheet.disabled = true;
2705
+ },
2706
+ remove: () => style.remove()
2707
+ };
2708
+ }
4075
2709
  function findStyle(name, doc = document) {
4076
2710
  const sheet = "adoptedStyleSheets" in doc ? doc.adoptedStyleSheets.find((own) => Reflect.get(own, NAME) === name) : undefined;
4077
2711
  return sheet ? wrap(doc, sheet) : doc.querySelector(`style[data-devknobs="${name}"]`);
@@ -4092,511 +2726,4 @@ function removeStyle(name, doc = document) {
4092
2726
  findStyle(name, doc)?.remove();
4093
2727
  }
4094
2728
 
4095
- // src/engine/screen.ts
4096
- var KEYS2 = ["width", "height", "availWidth", "availHeight"];
4097
- function screenSizeOf(state) {
4098
- const device = formOf(state.device, state.posture);
4099
- if (!device || device.kind !== "phone" && device.kind !== "tablet")
4100
- return null;
4101
- if (device.ua !== "iphone-safari")
4102
- return turn(device, state.orientation);
4103
- const { width, height } = turn(deviceOf(state.device) ?? device, "portrait");
4104
- const across = device.postures !== undefined && state.posture !== "open" && state.orientation === "landscape";
4105
- return across ? { width, height, availHeight: width } : { width, height };
4106
- }
4107
- var ORIGINALS = Symbol.for("devknobs.screen");
4108
- function originalsOf(own) {
4109
- const held = Reflect.get(own, ORIGINALS);
4110
- return held instanceof Map ? held : undefined;
4111
- }
4112
- function apply5(size2, scope = globalThis) {
4113
- const own = Reflect.get(scope, "screen");
4114
- if (typeof own !== "object" || own === null)
4115
- return;
4116
- const originals2 = originalsOf(own);
4117
- if (!size2) {
4118
- if (!originals2)
4119
- return;
4120
- for (const [key, descriptor] of originals2) {
4121
- if (descriptor)
4122
- Object.defineProperty(own, key, descriptor);
4123
- else
4124
- Reflect.deleteProperty(own, key);
4125
- }
4126
- Reflect.deleteProperty(own, ORIGINALS);
4127
- return;
4128
- }
4129
- if (!originals2) {
4130
- const kept = new Map(KEYS2.map((key) => [key, Object.getOwnPropertyDescriptor(own, key)]));
4131
- Object.defineProperty(own, ORIGINALS, { configurable: true, value: kept });
4132
- }
4133
- for (const key of KEYS2) {
4134
- const value = key === "width" || key === "availWidth" ? size2.width : key === "availHeight" ? size2.availHeight ?? size2.height : size2.height;
4135
- Object.defineProperty(own, key, { configurable: true, enumerable: true, get: () => value });
4136
- }
4137
- }
4138
- function reset5() {
4139
- apply5(null);
4140
- }
4141
-
4142
- // src/engine/scrollbars.ts
4143
- var NAME2 = "scrollbars";
4144
- var COMMIT_WAIT = 1000;
4145
- var CSS2 = "*{scrollbar-width:none!important}::-webkit-scrollbar{display:none!important}";
4146
- function apply6(value) {
4147
- if (!value) {
4148
- reset6();
4149
- return;
4150
- }
4151
- ensureStyle(NAME2).textContent = CSS2;
4152
- }
4153
- function place(doc) {
4154
- if (doc.documentElement) {
4155
- ensureStyle(NAME2, doc).textContent = CSS2;
4156
- return;
4157
- }
4158
- const observer3 = new MutationObserver(() => {
4159
- if (!doc.documentElement)
4160
- return;
4161
- observer3.disconnect();
4162
- ensureStyle(NAME2, doc).textContent = CSS2;
4163
- });
4164
- observer3.observe(doc, { childList: true });
4165
- }
4166
- function equip(view) {
4167
- const blank = view.document;
4168
- if (!blank)
4169
- return;
4170
- if (blank.URL !== "about:blank") {
4171
- place(blank);
4172
- return;
4173
- }
4174
- const until = performance.now() + COMMIT_WAIT;
4175
- const channel = new MessageChannel;
4176
- channel.port1.onmessage = () => {
4177
- let doc = null;
4178
- try {
4179
- doc = view.document;
4180
- } catch {}
4181
- if (doc && doc !== blank)
4182
- place(doc);
4183
- else if (doc && performance.now() < until) {
4184
- channel.port2.postMessage(null);
4185
- return;
4186
- }
4187
- channel.port1.close();
4188
- };
4189
- channel.port2.postMessage(null);
4190
- }
4191
- function reset6() {
4192
- removeStyle(NAME2);
4193
- }
4194
-
4195
- // src/engine/touch.ts
4196
- var TOUCH_POINTS = 5;
4197
- var handler = false;
4198
- var points = false;
4199
- function apply7(value) {
4200
- if (value.on && !handler && !("ontouchstart" in window)) {
4201
- Object.defineProperty(window, "ontouchstart", {
4202
- configurable: true,
4203
- enumerable: true,
4204
- writable: true,
4205
- value: null
4206
- });
4207
- handler = true;
4208
- } else if (!value.on && handler) {
4209
- Reflect.deleteProperty(window, "ontouchstart");
4210
- handler = false;
4211
- }
4212
- const report = value.on && value.points;
4213
- if (report && !points) {
4214
- Object.defineProperty(navigator, "maxTouchPoints", {
4215
- configurable: true,
4216
- enumerable: true,
4217
- get: () => TOUCH_POINTS
4218
- });
4219
- points = true;
4220
- } else if (!report && points) {
4221
- Reflect.deleteProperty(navigator, "maxTouchPoints");
4222
- points = false;
4223
- }
4224
- }
4225
- function equip2(view, points2) {
4226
- if (!("ontouchstart" in view)) {
4227
- Object.defineProperty(view, "ontouchstart", {
4228
- configurable: true,
4229
- enumerable: true,
4230
- writable: true,
4231
- value: null
4232
- });
4233
- }
4234
- if (!points2)
4235
- return;
4236
- Object.defineProperty(view.navigator, "maxTouchPoints", {
4237
- configurable: true,
4238
- enumerable: true,
4239
- get: () => TOUCH_POINTS
4240
- });
4241
- }
4242
- function reset7() {
4243
- apply7({ on: false, points: false });
4244
- }
4245
-
4246
- // src/engine/matcolors.ts
4247
- var MAT_COLORS2 = {
4248
- blue: {
4249
- srgb: ["rgb(20, 70, 152)", "rgb(12, 48, 114)", "rgb(7, 31, 80)"],
4250
- p3: [
4251
- "color(display-p3 0.1 0.27 0.61)",
4252
- "color(display-p3 0.06 0.19 0.46)",
4253
- "color(display-p3 0.035 0.12 0.32)"
4254
- ],
4255
- line: "rgb(170, 205, 255)"
4256
- },
4257
- green: {
4258
- srgb: ["rgb(26, 96, 71)", "rgb(14, 71, 51)", "rgb(8, 49, 35)"],
4259
- p3: [
4260
- "color(display-p3 0.159 0.377 0.279)",
4261
- "color(display-p3 0.102 0.277 0.2)",
4262
- "color(display-p3 0.065 0.194 0.136)"
4263
- ],
4264
- line: "rgb(160, 218, 191)"
4265
- },
4266
- magenta: {
4267
- srgb: ["rgb(123, 37, 88)", "rgb(90, 22, 63)", "rgb(62, 12, 42)"],
4268
- p3: [
4269
- "color(display-p3 0.462 0.14 0.342)",
4270
- "color(display-p3 0.34 0.081 0.246)",
4271
- "color(display-p3 0.234 0.043 0.165)"
4272
- ],
4273
- line: "rgb(238, 185, 211)"
4274
- },
4275
- purple: {
4276
- srgb: ["rgb(86, 56, 130)", "rgb(62, 38, 96)", "rgb(42, 24, 67)"],
4277
- p3: [
4278
- "color(display-p3 0.326 0.209 0.521)",
4279
- "color(display-p3 0.233 0.138 0.387)",
4280
- "color(display-p3 0.156 0.086 0.269)"
4281
- ],
4282
- line: "rgb(209, 193, 242)"
4283
- },
4284
- red: {
4285
- srgb: ["rgb(132, 36, 36)", "rgb(97, 21, 22)", "rgb(68, 11, 12)"],
4286
- p3: [
4287
- "color(display-p3 0.499 0.139 0.133)",
4288
- "color(display-p3 0.369 0.079 0.078)",
4289
- "color(display-p3 0.256 0.041 0.042)"
4290
- ],
4291
- line: "rgb(239, 188, 183)"
4292
- },
4293
- graphite: {
4294
- srgb: ["rgb(64, 68, 74)", "rgb(43, 46, 51)", "rgb(26, 28, 32)"],
4295
- p3: [
4296
- "color(display-p3 0.25 0.264 0.291)",
4297
- "color(display-p3 0.169 0.179 0.2)",
4298
- "color(display-p3 0.102 0.11 0.126)"
4299
- ],
4300
- line: "rgb(198, 203, 211)"
4301
- }
4302
- };
4303
- var MAT_COLOR_NAMES = [
4304
- "blue",
4305
- "green",
4306
- "magenta",
4307
- "purple",
4308
- "red",
4309
- "graphite"
4310
- ];
4311
- function matGradient(stops) {
4312
- return `radial-gradient(140% 100% at 50% 0%, ${stops[0]}, ${stops[1]} 60%, ${stops[2]})`;
4313
- }
4314
- function isMatName(value) {
4315
- return MAT_COLOR_NAMES.some((name) => name === value);
4316
- }
4317
- var SHADE = [1, 0.82, 0.64];
4318
- function rgb(color) {
4319
- return `rgb(${Math.round(color.red)}, ${Math.round(color.green)}, ${Math.round(color.blue)})`;
4320
- }
4321
- function shades(color) {
4322
- const shade = (share) => ({
4323
- red: color.red * share,
4324
- green: color.green * share,
4325
- blue: color.blue * share,
4326
- alpha: 1
4327
- });
4328
- return [shade(SHADE[0]), shade(SHADE[1]), shade(SHADE[2])];
4329
- }
4330
- function customColor(mat) {
4331
- return isCustomColor(mat) ? parseHex(mat) : null;
4332
- }
4333
- function matStops(mat) {
4334
- if (isMatName(mat))
4335
- return MAT_COLORS2[mat];
4336
- const color = customColor(mat);
4337
- if (!color)
4338
- return MAT_COLORS2.blue;
4339
- const [top2, middle, edge] = shades(color);
4340
- const stops = [rgb(top2), rgb(middle), rgb(edge)];
4341
- return { srgb: stops, p3: stops };
4342
- }
4343
- function matPaint(mat) {
4344
- if (isMatName(mat))
4345
- return MAT_COLORS2[mat];
4346
- const color = customColor(mat);
4347
- return color ? { ...matStops(mat), line: rgb(inkOn(color, shades(color))) } : MAT_COLORS2.blue;
4348
- }
4349
- var MAT_VARIABLES = ["--mat", "--mat-p3", "--mat-line"];
4350
- function putMat(node, mat) {
4351
- if (mat === null)
4352
- node.removeAttribute("data-mat");
4353
- else
4354
- node.setAttribute("data-mat", mat);
4355
- if (mat === null || isMatName(mat)) {
4356
- for (const name of MAT_VARIABLES)
4357
- node.style.removeProperty(name);
4358
- return;
4359
- }
4360
- const paint = matPaint(mat);
4361
- node.style.setProperty("--mat", matGradient(paint.srgb));
4362
- node.style.setProperty("--mat-p3", matGradient(paint.p3));
4363
- node.style.setProperty("--mat-line", paint.line);
4364
- }
4365
-
4366
- // src/engine/placeholder.ts
4367
- var Z_INDEX = 2147483645;
4368
- var EARLY3 = "early";
4369
- var SNAPSHOT_KEY = "devknobs:snapshot";
4370
- var SNAPSHOT_VERSION = 1;
4371
- var EARLY_FRAMES = 60;
4372
- var earlyWait = 0;
4373
- function snapshotKey(knobs, view) {
4374
- return JSON.stringify([
4375
- knobs.width,
4376
- knobs.height,
4377
- knobs.frame,
4378
- knobs.dpr,
4379
- knobs.vision,
4380
- knobs.scheme,
4381
- knobs.device,
4382
- knobs.orientation,
4383
- knobs.posture,
4384
- knobs.mock,
4385
- knobs.browser,
4386
- knobs.bars,
4387
- knobs.edgeToEdge,
4388
- knobs.zoom,
4389
- knobs.mat,
4390
- knobs.panel.open,
4391
- knobs.panel.side,
4392
- knobs.panel.docked,
4393
- view.innerWidth,
4394
- view.innerHeight,
4395
- view.devicePixelRatio
4396
- ]);
4397
- }
4398
- var RGB = /^rgb\(\d{1,3}, \d{1,3}, \d{1,3}\)$/;
4399
- function lookOf(value) {
4400
- if (typeof value !== "object" || value === null)
4401
- return null;
4402
- const read2 = (key) => Reflect.get(value, key);
4403
- const background = read2("background");
4404
- const scheme = read2("scheme");
4405
- const host = read2("host");
4406
- const flags = [read2("dark"), read2("canBack"), read2("canForward")];
4407
- if (typeof background !== "string" || !RGB.test(background)) {
4408
- return null;
4409
- }
4410
- if (scheme !== "light" && scheme !== "dark" || typeof host !== "string")
4411
- return null;
4412
- const [dark, canBack, canForward] = flags;
4413
- if (typeof dark !== "boolean" || typeof canBack !== "boolean")
4414
- return null;
4415
- if (typeof canForward !== "boolean")
4416
- return null;
4417
- const color = (key) => {
4418
- const value2 = read2(key);
4419
- return typeof value2 === "string" && RGB.test(value2) ? value2 : background;
4420
- };
4421
- const top2 = color("top");
4422
- const bottom = color("bottom");
4423
- const header = read2("header");
4424
- if (typeof header !== "boolean")
4425
- return null;
4426
- return { background, top: top2, bottom, header, footer: read2("footer") === true, under: [], dark, scheme, host, canBack, canForward };
4427
- }
4428
- function readSnapshot(knobs, view) {
4429
- try {
4430
- const text2 = webStorage("session")?.getItem(SNAPSHOT_KEY);
4431
- if (!text2)
4432
- return null;
4433
- const data = JSON.parse(text2);
4434
- if (typeof data !== "object" || data === null || newer(data, SNAPSHOT_VERSION))
4435
- return null;
4436
- const key = Reflect.get(data, "key");
4437
- const css = Reflect.get(data, "css");
4438
- const html = Reflect.get(data, "html");
4439
- const look = lookOf(Reflect.get(data, "look"));
4440
- if (key !== snapshotKey(knobs, view) || typeof css !== "string")
4441
- return null;
4442
- if (typeof html !== "string" || !look)
4443
- return null;
4444
- return { key, css, html, look };
4445
- } catch {
4446
- return null;
4447
- }
4448
- }
4449
- function writeSnapshot(snapshot) {
4450
- try {
4451
- webStorage("session")?.setItem(SNAPSHOT_KEY, JSON.stringify(stamped(snapshot, SNAPSHOT_VERSION)));
4452
- } catch {
4453
- clearSnapshot();
4454
- }
4455
- }
4456
- function keepDrawing({ letterbox, zoom, key, css, look }) {
4457
- const copy2 = letterbox.cloneNode(true);
4458
- if (!(copy2 instanceof HTMLElement))
4459
- return;
4460
- copy2.querySelector("iframe")?.remove();
4461
- copy2.querySelector(".touchdot")?.remove();
4462
- copy2.querySelector(".glass")?.removeAttribute("data-touch");
4463
- for (const line of Array.from(copy2.querySelectorAll(".progress")))
4464
- line.hidden = true;
4465
- const blank = copy2.querySelector(".screenblank");
4466
- if (blank) {
4467
- blank.hidden = false;
4468
- blank.style.background = look.background;
4469
- }
4470
- for (const option of Array.from(copy2.querySelectorAll("option"))) {
4471
- option.toggleAttribute("selected", option.value === zoom);
4472
- }
4473
- writeSnapshot({ key, css, html: copy2.outerHTML, look });
4474
- }
4475
- function clearSnapshot() {
4476
- try {
4477
- webStorage("session")?.removeItem(SNAPSHOT_KEY);
4478
- } catch {}
4479
- }
4480
- function earlyHost() {
4481
- return document.querySelector(`div[data-devknobs="${EARLY3}"]`);
4482
- }
4483
- function dropEarly() {
4484
- for (const node of Array.from(document.querySelectorAll(`[data-devknobs="${EARLY3}"]`))) {
4485
- node.remove();
4486
- }
4487
- removeStyle(EARLY3);
4488
- }
4489
- function adoptEarly(pictureLoading) {
4490
- const early = earlyHost();
4491
- if (!early || !document.body) {
4492
- dropEarly();
4493
- return;
4494
- }
4495
- document.body.append(early);
4496
- let frames = 0;
4497
- const step = () => {
4498
- earlyWait = 0;
4499
- if (pictureLoading() && ++frames < EARLY_FRAMES) {
4500
- earlyWait = window.requestAnimationFrame(step);
4501
- return;
4502
- }
4503
- earlyWait = window.requestAnimationFrame(() => {
4504
- earlyWait = 0;
4505
- dropEarly();
4506
- });
4507
- };
4508
- earlyWait = window.requestAnimationFrame(step);
4509
- }
4510
- function stopAdopting() {
4511
- if (earlyWait)
4512
- window.cancelAnimationFrame(earlyWait);
4513
- earlyWait = 0;
4514
- }
4515
-
4516
- // src/requests/shared.ts
4517
- var SHARED_VERSION = 2;
4518
- var SHARED3 = Symbol.for("devknobs.requests");
4519
- var QUIET = Symbol.for("devknobs.quiet");
4520
- function isShared2(value) {
4521
- return typeof value === "object" && value !== null && Reflect.get(value, "version") === SHARED_VERSION;
4522
- }
4523
- function shared2(scope = globalThis) {
4524
- try {
4525
- const value = Reflect.get(scope, SHARED3);
4526
- return isShared2(value) ? value : null;
4527
- } catch {
4528
- return null;
4529
- }
4530
- }
4531
- function share(recorder) {
4532
- if (recorder)
4533
- Reflect.set(globalThis, SHARED3, recorder);
4534
- else
4535
- Reflect.deleteProperty(globalThis, SHARED3);
4536
- }
4537
- function evict() {
4538
- const other = Reflect.get(globalThis, SHARED3);
4539
- if (typeof other !== "object" || other === null)
4540
- return;
4541
- const uninstall = Reflect.get(other, "uninstall");
4542
- try {
4543
- if (typeof uninstall === "function")
4544
- uninstall.call(other);
4545
- } catch {}
4546
- Reflect.deleteProperty(globalThis, SHARED3);
4547
- }
4548
-
4549
- // src/engine/touchmark.ts
4550
- var RADIUS = 11;
4551
- var DOT_LOOK = `
4552
- .dot {
4553
- left: 0;
4554
- top: 0;
4555
- width: ${RADIUS * 2}px;
4556
- height: ${RADIUS * 2}px;
4557
- margin: -${RADIUS}px 0 0 -${RADIUS}px;
4558
- pointer-events: none;
4559
- will-change: transform;
4560
- }
4561
- .dot[hidden] { display: none; }
4562
- .dot::after {
4563
- content: "";
4564
- position: absolute;
4565
- inset: 0;
4566
- box-sizing: border-box;
4567
- border-radius: 50%;
4568
- background: rgb(0 0 0 / 0.28);
4569
- border: 1.5px solid rgb(255 255 255 / 0.85);
4570
- box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25);
4571
- transition: transform 80ms ease-out, background-color 80ms ease-out;
4572
- }
4573
- .dot.pressed::after {
4574
- transform: scale(0.82);
4575
- background: rgb(0 0 0 / 0.45);
4576
- }
4577
- @media (prefers-reduced-motion: reduce) {
4578
- .dot::after { transition: none; }
4579
- }
4580
- `;
4581
- var MARK_EVENT = "devknobs-touch-mark";
4582
- function finite(value) {
4583
- return typeof value === "number" && Number.isFinite(value);
4584
- }
4585
- function readMark(detail) {
4586
- if (typeof detail !== "object" || detail === null)
4587
- return null;
4588
- const at = Reflect.get(detail, "at");
4589
- const pressed = Reflect.get(detail, "pressed");
4590
- const held = Reflect.get(detail, "held");
4591
- if (typeof pressed !== "boolean" || typeof held !== "boolean")
4592
- return null;
4593
- if (at === null)
4594
- return { at: null, pressed, held };
4595
- if (typeof at !== "object")
4596
- return null;
4597
- const x = Reflect.get(at, "x");
4598
- const y = Reflect.get(at, "y");
4599
- return finite(x) && finite(y) ? { at: { x, y }, pressed, held } : null;
4600
- }
4601
-
4602
- export { __export, __require, CLOCK_SPEED_MIN, CLOCK_SPEED_MAX, CLOCK_PRESETS, NativeDate, realNow, setClock, clockOn, now, wrapDate, NOW_READERS, temporalNow, readNow, takeOver, RINGS, SIDES, pxOf, boxModel, contentSize, hasBox, ringQuads, oneQuad, isPlain, alignQuads, ringPaths, luminance, parseColor, isCustomColor, toHex, parseHex, readColor, POSTURES, openOf, DEVICES, deviceOf, formOf, formId, screenOf, hasTouch, turn, newer, stamped, FRESH_ATTRIBUTE, fresh, webStorage, loads, carried, ownReload, GEO_PRESETS, resolveGeo, apply, reset, ZOOM_PRESETS, ZOOM_MIN, ZOOM_MAX, percent, stepZoom, wheelZoom, anchorScroll, DEFAULT_PINNED, DEFAULT_STATE, SCHEMES, MOTIONS, CONTRASTS, TRANSPARENCIES, DIRS, GEO_ERRORS, CLOCK_MODES, ONLINES, CONNECTIONS, SAVE_DATAS, BARS, BROWSERS, ORIENTATIONS, EDGES, SIDES2 as SIDES1, DEV_ICONS, VISIONS, GRAB_COLORS, resetState, merge, load, save, keepPlace, FRAME_ATTRIBUTE, FRAME_NAME, SIZE_MIN, SIZE_MAX, DPR_MIN, DPR_MAX, isDevknobsFrame, nativeScheme, handsSchemeDown, UNFRAMED, EXITED, knobFrame, needsFrame, plainFrame, frameForced, framed, readMessage, leaveFor, post, SHARED_VERSION, QUIET, shared2 as shared, share, evict, follow, keep, keepOwn, resume, systemMedia, setSystemMedia, watchSystemMedia, baseMatchMedia, still, ownInline, TEXT_MIN, TEXT_MAX, apply3 as apply1, reset3 as reset1, rewriteMediaText, authoredQuery, coarse, apply4 as apply2, destroy, runsUnderBars, platformOf, layoutOptions, layoutOf, viewportOf, alphaAt, SAFARI_TEXT, barsOf, BARS_START, barsStep, islandOf, round, turnRect, turnSides, turnRadius, placeIn2 as placeIn, mockOf, UA_PRESETS, uaPreset, userAgentOf, apply2 as apply3, isMac, reset2, nativeViewport, inPage, framing, nativeEnabled, enableNative, handing, settles, drive, driveUa, release, styleNode, isOwnSheet, addStyle, ensureStyle, removeStyle, screenSizeOf, apply5 as apply4, reset5 as reset3, apply6 as apply5, equip, reset6 as reset4, apply7 as apply6, equip2 as equip1, reset7 as reset5, DOT_LOOK, MARK_EVENT, readMark, MAT_COLORS2 as MAT_COLORS, MAT_COLOR_NAMES, matGradient, isMatName, putMat, Z_INDEX, snapshotKey, readSnapshot, keepDrawing, clearSnapshot, dropEarly, adoptEarly, stopAdopting };
2729
+ export { CLOCK_SPEED_MIN, CLOCK_SPEED_MAX, CLOCK_PRESETS, NativeDate, realNow, setClock, clockOn, now, wrapDate, NOW_READERS, temporalNow, readNow, takeOver, RINGS, SIDES, pxOf, boxModel, contentSize, hasBox, ringQuads, oneQuad, isPlain, alignQuads, ringPaths, luminance, parseColor, isCustomColor, toHex, parseHex, readColor, inkOn, POSTURES, openOf, DEVICES, deviceOf, formOf, formId, screenOf, hasTouch, turn, versionOf, newer, stamped, FRESH_ATTRIBUTE, fresh, webStorage, loads, carried, ownReload, GEO_PRESETS, resolveGeo, apply, reset, ZOOM_PRESETS, ZOOM_MIN, ZOOM_MAX, percent, stepZoom, wheelZoom, anchorScroll, DEFAULT_PINNED, DEFAULT_STATE, SCHEMES, MOTIONS, CONTRASTS, TRANSPARENCIES, DIRS, GEO_ERRORS, CLOCK_MODES, ONLINES, CONNECTIONS, SAVE_DATAS, BARS, BROWSERS, ORIENTATIONS, EDGES, SIDES2 as SIDES1, DEV_ICONS, VISIONS, GRAB_COLORS, resetState, merge, load, save, keepPlace, FRAME_ATTRIBUTE, FRAME_NAME, SIZE_MIN, SIZE_MAX, DPR_MIN, DPR_MAX, isDevknobsFrame, nativeScheme, handsSchemeDown, UNFRAMED, EXITED, knobFrame, needsFrame, plainFrame, frameForced, framed, readMessage, leaveFor, post, systemMedia, setSystemMedia, watchSystemMedia, baseMatchMedia, still, ownInline, TEXT_MIN, TEXT_MAX, apply2 as apply1, reset2 as reset1, rewriteMediaText, authoredQuery, coarse, apply3 as apply2, destroy, isDocument, styleNode, isOwnSheet, addStyle, switchedSheet, ensureStyle, removeStyle };