@vinena/knobs 0.5.2 → 0.6.0

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