@vinena/knobs 0.7.0 → 0.7.2

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 (116) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +2 -2
  3. package/dist/cli.js +2 -2
  4. package/dist/{context-eawqn680.js → context-2r76ext7.js} +3 -3
  5. package/dist/{context-vd2xep5t.js → context-h1bdt8w3.js} +3 -3
  6. package/dist/early.global.js +7 -8
  7. package/dist/edit/html.d.ts +7 -3
  8. package/dist/edit/keep.d.ts +1 -1
  9. package/dist/{elementsview-m33ejs4r.js → elementsview-1bar694x.js} +21 -19
  10. package/dist/{elementsview-jg4edt86.js → elementsview-p2wc9b0s.js} +21 -19
  11. package/dist/engine/bandmedia.d.ts +119 -0
  12. package/dist/engine/bezels.d.ts +2 -2
  13. package/dist/engine/browserui.d.ts +3 -1
  14. package/dist/engine/check.d.ts +2 -2
  15. package/dist/engine/describe.d.ts +2 -2
  16. package/dist/engine/devices.d.ts +3 -3
  17. package/dist/engine/fit.d.ts +4 -4
  18. package/dist/engine/foldhand.d.ts +2 -2
  19. package/dist/engine/frame.d.ts +6 -6
  20. package/dist/engine/frames.d.ts +4 -4
  21. package/dist/engine/fresh.d.ts +12 -5
  22. package/dist/engine/header.d.ts +3 -1
  23. package/dist/engine/identity.d.ts +4 -4
  24. package/dist/engine/index.d.ts +7 -7
  25. package/dist/engine/locale.d.ts +2 -2
  26. package/dist/engine/morph.d.ts +2 -2
  27. package/dist/engine/native.d.ts +8 -8
  28. package/dist/engine/pageshot.d.ts +24 -4
  29. package/dist/engine/placeholder.d.ts +3 -3
  30. package/dist/engine/reload.d.ts +2 -2
  31. package/dist/engine/safaridraw.d.ts +24 -3
  32. package/dist/engine/screen.d.ts +2 -2
  33. package/dist/engine/scrollkeep.d.ts +1 -1
  34. package/dist/engine/store.d.ts +11 -11
  35. package/dist/engine/storekeys.d.ts +34 -0
  36. package/dist/engine/style.d.ts +1 -1
  37. package/dist/engine/tabicon.d.ts +2 -2
  38. package/dist/engine/underbar.d.ts +26 -7
  39. package/dist/engine/underneath.d.ts +1 -0
  40. package/dist/engine/width.d.ts +3 -3
  41. package/dist/{framekit-r16k97n7.js → framekit-n57ts9zt.js} +959 -87
  42. package/dist/{framekit-40pzennw.js → framekit-wqp811a2.js} +959 -87
  43. package/dist/grab/clipboard.d.ts +2 -0
  44. package/dist/{index-jfv7vavj.js → index-311fys81.js} +93 -29
  45. package/dist/index-3dcgysws.js +77 -0
  46. package/dist/{index-ztnjefrh.js → index-585hs9tp.js} +5 -1
  47. package/dist/{index-za4ppxay.js → index-6t0w5s7p.js} +1 -1
  48. package/dist/{index-tqq2ygpj.js → index-9targr2f.js} +26 -16
  49. package/dist/{index-t4kssacm.js → index-abwqw8jh.js} +6 -1
  50. package/dist/{index-s6yzsvs4.js → index-b8cnnbpr.js} +25 -18
  51. package/dist/{index-xxbb8y41.js → index-cfrnrg24.js} +20 -14
  52. package/dist/{index-v2v4rmpe.js → index-dvtbh3c8.js} +24 -18
  53. package/dist/{index-0qkj2mgb.js → index-j8hrzag1.js} +14 -11
  54. package/dist/{index-cb91vcka.js → index-k4w5v53q.js} +1 -1
  55. package/dist/{index-q53j8wg5.js → index-n31pn4ax.js} +19 -15
  56. package/dist/{index-s6fya8pm.js → index-pvknvvkw.js} +11 -10
  57. package/dist/{index-3nwycv3p.js → index-qz04adp5.js} +20 -14
  58. package/dist/{index-ymqm185m.js → index-rps0bdq9.js} +1 -1
  59. package/dist/{index-a8ffw5ft.js → index-szd9bddn.js} +1 -1
  60. package/dist/{index-8d1yk9d2.js → index-t7a07nm9.js} +59 -39
  61. package/dist/{index-2jc9dnta.js → index-vhda420r.js} +11 -5
  62. package/dist/{index-xs29b55n.js → index-vmprrfwe.js} +5 -2
  63. package/dist/{index-fjrrgd9h.js → index-vmz7htwn.js} +1 -1
  64. package/dist/index.d.ts +14 -8
  65. package/dist/index.global.js +182 -165
  66. package/dist/index.js +57 -32
  67. package/dist/instance.d.ts +7 -1
  68. package/dist/mark.d.ts +50 -0
  69. package/dist/{react-vvc4x9kq.js → react-0tbd51s3.js} +14 -11
  70. package/dist/{react-0gxs9aef.js → react-4ezjf7mq.js} +24 -18
  71. package/dist/react-4qn9vsjw.js +78 -0
  72. package/dist/{react-73reavv4.js → react-4tcwpama.js} +1 -1
  73. package/dist/{react-6ngtb6p9.js → react-7eyps0cg.js} +1 -1
  74. package/dist/{react-zp7fdw8e.js → react-881wvm1z.js} +59 -39
  75. package/dist/{react-yx3g9k55.js → react-amvrbng8.js} +5 -2
  76. package/dist/{react-5rq7bnsy.js → react-atw9y8ny.js} +5 -1
  77. package/dist/{react-4phtr2nd.js → react-dg4bjv3j.js} +1 -1
  78. package/dist/{react-meve34wp.js → react-hdneb4v3.js} +11 -5
  79. package/dist/{react-h9w04skh.js → react-j87bdhhe.js} +4 -1
  80. package/dist/{react-wtgvkf6g.js → react-mkafgzqf.js} +1 -1
  81. package/dist/{react-fq4551ks.js → react-pf7fc2f3.js} +11 -10
  82. package/dist/{react-0r5418av.js → react-rbmk30xk.js} +92 -29
  83. package/dist/{react-actmnkwp.js → react-rxw73n04.js} +1 -1
  84. package/dist/{react-8nmtt0ge.js → react-w94cfn87.js} +19 -15
  85. package/dist/{react-3ev6rwqz.js → react-x209et38.js} +26 -16
  86. package/dist/{react-5h7pxnax.js → react-zj0dbpdg.js} +25 -18
  87. package/dist/react.d.ts +3 -1
  88. package/dist/react.js +60 -33
  89. package/dist/{replay-pmesjfa3.js → replay-3xqgt3xg.js} +8 -8
  90. package/dist/{replay-m5g8km9y.js → replay-48gn27bj.js} +8 -8
  91. package/dist/storage/onload.d.ts +1 -1
  92. package/dist/{storageview-9a6zm47z.js → storageview-5tvmca8y.js} +16 -13
  93. package/dist/{storageview-x62v1c3j.js → storageview-ec52x60p.js} +16 -13
  94. package/dist/styles/force.d.ts +3 -1
  95. package/dist/types.d.ts +4 -4
  96. package/dist/ui/actions.d.ts +3 -3
  97. package/dist/ui/bindings.d.ts +1 -1
  98. package/dist/ui/catalog.d.ts +14 -14
  99. package/dist/ui/changes.d.ts +1 -1
  100. package/dist/ui/colors.d.ts +1 -1
  101. package/dist/ui/deviceknobs.d.ts +2 -2
  102. package/dist/ui/editors.d.ts +3 -3
  103. package/dist/ui/foldslider.d.ts +2 -2
  104. package/dist/ui/keys.d.ts +1 -1
  105. package/dist/ui/list.d.ts +10 -10
  106. package/dist/ui/palette.d.ts +2 -2
  107. package/dist/ui/pin.d.ts +2 -2
  108. package/dist/ui/prefs.d.ts +1 -1
  109. package/dist/ui/rows.d.ts +3 -3
  110. package/dist/ui/storageview.d.ts +2 -2
  111. package/dist/ui/stylesview.d.ts +3 -3
  112. package/dist/ui/swatches.d.ts +2 -2
  113. package/package.json +2 -1
  114. package/skills/knobs/SKILL.md +36 -35
  115. package/dist/index-5tv6sr74.js +0 -23
  116. package/dist/react-t2qnewz2.js +0 -24
@@ -24,7 +24,7 @@ import {
24
24
  turnOf,
25
25
  turnedPose,
26
26
  windowRect
27
- } from "./index-cb91vcka.js";
27
+ } from "./index-k4w5v53q.js";
28
28
  import {
29
29
  hush,
30
30
  hushOnce,
@@ -38,7 +38,7 @@ import {
38
38
  } from "./index-58jdczmj.js";
39
39
  import {
40
40
  copyText
41
- } from "./index-ztnjefrh.js";
41
+ } from "./index-585hs9tp.js";
42
42
  import {
43
43
  BARS_START,
44
44
  DOT_LOOK,
@@ -82,7 +82,7 @@ import {
82
82
  uaPreset,
83
83
  userAgentOf,
84
84
  viewportOf
85
- } from "./index-s6yzsvs4.js";
85
+ } from "./index-b8cnnbpr.js";
86
86
  import {
87
87
  FRAME_ATTRIBUTE,
88
88
  FRAME_NAME,
@@ -124,11 +124,16 @@ import {
124
124
  turn,
125
125
  walkRules,
126
126
  wheelZoom
127
- } from "./index-jfv7vavj.js";
127
+ } from "./index-311fys81.js";
128
128
  import"./index-a974q3aa.js";
129
129
  import {
130
- __export
131
- } from "./index-5tv6sr74.js";
130
+ __export,
131
+ findOwn,
132
+ isMarked,
133
+ markOwn,
134
+ ownSelector,
135
+ setMark
136
+ } from "./index-3dcgysws.js";
132
137
 
133
138
  // src/engine/width.ts
134
139
  var exports_width = {};
@@ -3672,6 +3677,7 @@ function buildChrome(full, mini, look) {
3672
3677
 
3673
3678
  // src/engine/safaridraw.ts
3674
3679
  var DOMAIN_WEIGHT = 500;
3680
+ var DOMAIN_PAD = 0.15;
3675
3681
  var SAFARI_CSS = `
3676
3682
  .safari {
3677
3683
  color: #000;
@@ -3740,14 +3746,27 @@ var SAFARI_CSS = `
3740
3746
  .safari .glyph.off { stroke-opacity: 0.3; fill-opacity: 0.3; }
3741
3747
  .safari .domain {
3742
3748
  left: 50%;
3749
+ /* A host that does not fit keeps its end and loses its start, never to an ellipsis. */
3750
+ display: flex;
3751
+ justify-content: flex-end;
3743
3752
  white-space: nowrap;
3744
3753
  overflow: hidden;
3745
- text-overflow: ellipsis;
3746
- text-align: center;
3747
3754
  font-size: ${SAFARI_TEXT.field}px;
3748
3755
  font-weight: ${DOMAIN_WEIGHT};
3756
+ /* Its box is one line high, less than the font's ascent and descent: padded the same above and below, a g's tail is drawn whole and the baseline stays. */
3757
+ padding-block: ${DOMAIN_PAD}em;
3749
3758
  transform: translate(-50%, -50%);
3750
- }
3759
+ /* Its start fades over 9 px where it is cut; where it fits, the fade slides out past the start. */
3760
+ -webkit-mask-image: linear-gradient(to right, transparent, #000 9px);
3761
+ mask-image: linear-gradient(to right, transparent, #000 9px);
3762
+ -webkit-mask-size: calc(100% + 9px) 100%;
3763
+ mask-size: calc(100% + 9px) 100%;
3764
+ -webkit-mask-repeat: no-repeat;
3765
+ mask-repeat: no-repeat;
3766
+ -webkit-mask-position: -9px 0;
3767
+ mask-position: -9px 0;
3768
+ }
3769
+ .safari .domain[data-cut="true"] { -webkit-mask-position: 0 0; mask-position: 0 0; }
3751
3770
  .safari .time { font-weight: 600; transform: translate(-50%, -50%); }
3752
3771
  .safari .status { fill: currentColor; }
3753
3772
  /* The battery's uncharged rest: #b2b2b2 on white, #808080 on black. */
@@ -3772,7 +3791,10 @@ var SAFARI_CSS = `
3772
3791
  transition:
3773
3792
  top var(--main) ${MORPH.ease},
3774
3793
  height var(--main) ${MORPH.ease},
3775
- transform var(--main) ${MORPH.ease};
3794
+ transform var(--main) ${MORPH.ease},
3795
+ max-width var(--main) ${MORPH.ease},
3796
+ -webkit-mask-position var(--main) ${MORPH.ease},
3797
+ mask-position var(--main) ${MORPH.ease};
3776
3798
  }
3777
3799
  /* The parts only the expanded bars have: an icon swap, out early, in late. */
3778
3800
  .safari .full {
@@ -4040,19 +4062,59 @@ function pressOf(glyph, actions) {
4040
4062
  return actions.reload;
4041
4063
  return;
4042
4064
  }
4065
+ var GLYPH_BOX = 30;
4043
4066
  function glyphIn(mark, origin, className, actions) {
4044
- const svg = glyphAt(mark, GLYPHS2, 30, className, pressOf(mark.glyph, actions));
4045
- svg.style.left = `${mark.x - origin.x - 15}px`;
4046
- svg.style.top = `${mark.y - origin.y - 15}px`;
4067
+ const svg = glyphAt(mark, GLYPHS2, GLYPH_BOX, className, pressOf(mark.glyph, actions));
4068
+ svg.style.left = `${mark.x - origin.x - GLYPH_BOX / 2}px`;
4069
+ svg.style.top = `${mark.y - origin.y - GLYPH_BOX / 2}px`;
4047
4070
  return svg;
4048
4071
  }
4049
4072
  function domainOf(host) {
4050
4073
  return host.replace(/:\d+$/, "");
4051
4074
  }
4052
- function pillBox(pill, host) {
4053
- const size = pill.text?.size ?? SAFARI_TEXT.pill;
4054
- const width = Math.round(textWidth(domainOf(host), size, DOMAIN_WEIGHT)) + (pill.text?.pad ?? 0);
4055
- return { x: pill.x - width / 2, y: pill.y, width, height: pill.height };
4075
+ var PILL_MARGIN = 16;
4076
+ var MARK_CLEAR = 21;
4077
+ var FIELD_LEAST = 13;
4078
+ var FIT_STEPS = 6;
4079
+ var FIT_SLACK = 0.5;
4080
+ function domainRoom(shape, host, width) {
4081
+ const middle = shape.text?.x ?? shape.x + shape.width / 2;
4082
+ if (shape.kind === "pill") {
4083
+ const text = Math.ceil(textWidth(domainOf(host), shape.text?.size ?? SAFARI_TEXT.pill, DOMAIN_WEIGHT));
4084
+ const most = 2 * (Math.min(middle, width - middle) - PILL_MARGIN) - (shape.text?.pad ?? 0);
4085
+ return Math.max(0, Math.min(text, most));
4086
+ }
4087
+ let half = shape.width / 2;
4088
+ for (const { x } of shape.marks) {
4089
+ half = Math.min(half, Math.abs(x - middle) - (shape.text?.clear ?? MARK_CLEAR));
4090
+ }
4091
+ return Math.max(0, 2 * half);
4092
+ }
4093
+ function domainFit(shape, host, width) {
4094
+ const room = domainRoom(shape, host, width);
4095
+ const text = domainOf(host);
4096
+ if (shape.kind === "pill") {
4097
+ const size2 = shape.text?.size ?? SAFARI_TEXT.pill;
4098
+ return { size: size2, room, cut: room < textWidth(text, size2, DOMAIN_WEIGHT) };
4099
+ }
4100
+ let size = shape.text?.size ?? SAFARI_TEXT.field;
4101
+ for (let step = 0;step < FIT_STEPS && size > FIELD_LEAST; step++) {
4102
+ const advance = textWidth(text, size, DOMAIN_WEIGHT);
4103
+ if (advance <= room + FIT_SLACK)
4104
+ break;
4105
+ size = Math.max(FIELD_LEAST, size * room / advance);
4106
+ }
4107
+ return { size, room, cut: textWidth(text, size, DOMAIN_WEIGHT) > room + FIT_SLACK };
4108
+ }
4109
+ function pillBox(pill, host, width) {
4110
+ const box2 = domainRoom(pill, host, width) + (pill.text?.pad ?? 0);
4111
+ return { x: pill.x - box2 / 2, y: pill.y, width: box2, height: pill.height };
4112
+ }
4113
+ function drawnScale(node) {
4114
+ if (typeof getComputedStyle !== "function")
4115
+ return 1;
4116
+ const scale = /^matrix\(([^,]+),/.exec(getComputedStyle(node).transform)?.[1];
4117
+ return Number(scale) || 1;
4056
4118
  }
4057
4119
  function hslOf({ red, green, blue }) {
4058
4120
  const [r, g, b] = [red / 255, green / 255, blue / 255];
@@ -4179,14 +4241,16 @@ function buildSafari(full, mini, look, actions) {
4179
4241
  const main = pill ? full.shapes.find((shape) => shape.kind === "card") ?? full.shapes.find((shape) => shape.text !== undefined) ?? null : null;
4180
4242
  let surface = null;
4181
4243
  let domain = null;
4244
+ const screen = turn(full.screen, full.orientation).width;
4245
+ const texts = [];
4182
4246
  const glyphs = [];
4183
4247
  const keep2 = (node, glyph) => {
4184
4248
  glyphs.push({ node, glyph });
4185
4249
  return node;
4186
4250
  };
4251
+ const field = full.shapes.find((shape) => shape.kind === "field");
4187
4252
  if (main && pill) {
4188
4253
  surface = el("div", main.kind === "card" ? "surface from-card" : "surface");
4189
- const field = full.shapes.find((shape) => shape.kind === "field");
4190
4254
  if (field) {
4191
4255
  const inner = el("div", "field full");
4192
4256
  placeBox(inner, { ...field, x: field.x - main.x, y: field.y - main.y }, field.radius);
@@ -4207,7 +4271,6 @@ function buildSafari(full, mini, look, actions) {
4207
4271
  }
4208
4272
  domain = el("div", "domain");
4209
4273
  const text = (field ?? main).text;
4210
- domain.style.maxWidth = `${(field ?? main).width - 96}px`;
4211
4274
  domain.dataset.top = String((text?.y ?? main.y) - main.y);
4212
4275
  surface.append(domain);
4213
4276
  const expand = actions.expand;
@@ -4243,7 +4306,7 @@ function buildSafari(full, mini, look, actions) {
4243
4306
  if (shape.text) {
4244
4307
  const text = el("div", "domain");
4245
4308
  text.style.top = `${shape.text.y - shape.y}px`;
4246
- text.style.maxWidth = `${shape.width - 96}px`;
4309
+ texts.push({ node: text, shape });
4247
4310
  side.append(text);
4248
4311
  }
4249
4312
  root.append(side);
@@ -4262,6 +4325,12 @@ function buildSafari(full, mini, look, actions) {
4262
4325
  for (const text of Array.from(root.querySelectorAll(".domain"))) {
4263
4326
  text.textContent = domainOf(sight.host);
4264
4327
  }
4328
+ for (const { node, shape } of texts) {
4329
+ const fit = domainFit(shape, sight.host, screen);
4330
+ node.style.fontSize = `${fit.size}px`;
4331
+ node.style.maxWidth = `${fit.room}px`;
4332
+ node.dataset.cut = String(fit.cut);
4333
+ }
4265
4334
  for (const { node, box: box2 } of sides)
4266
4335
  tintGlass(node, box2, sight);
4267
4336
  for (const { node, glyph } of glyphs) {
@@ -4270,13 +4339,33 @@ function buildSafari(full, mini, look, actions) {
4270
4339
  node.classList.toggle("press", !off && pressOf(glyph, actions) !== undefined);
4271
4340
  }
4272
4341
  if (surface && domain && main && pill) {
4273
- const box2 = minimized ? pillBox(pill, sight.host) : main;
4342
+ const box2 = minimized ? pillBox(pill, sight.host, screen) : main;
4274
4343
  placeBox(surface, box2, minimized ? pill.radius : main.radius);
4275
4344
  tintGlass(surface, box2, sight);
4345
+ const shown2 = minimized ? pill : field ?? main;
4346
+ const { size, room, cut } = domainFit(shown2, sight.host, screen);
4347
+ const was = Number(domain.dataset.size) || size;
4348
+ const turned = domain.dataset.min !== undefined && domain.dataset.min !== String(minimized);
4349
+ domain.dataset.size = String(size);
4350
+ domain.dataset.min = String(minimized);
4351
+ domain.dataset.cut = String(cut);
4352
+ if (turned && was !== size) {
4353
+ const seen = domain.getBoundingClientRect().width;
4354
+ const host = domainOf(sight.host);
4355
+ const advance = textWidth(host, was, DOMAIN_WEIGHT) / textWidth(host, size, DOMAIN_WEIGHT);
4356
+ const scale = drawnScale(domain) * (advance || was / size);
4357
+ domain.style.transitionProperty = "top, height, -webkit-mask-position, mask-position";
4358
+ domain.style.fontSize = `${size}px`;
4359
+ domain.style.transform = `translate(-50%, -50%) scale(${scale})`;
4360
+ domain.style.maxWidth = `${seen / scale}px`;
4361
+ domain.offsetWidth;
4362
+ domain.style.transitionProperty = "";
4363
+ }
4364
+ domain.style.fontSize = `${size}px`;
4365
+ domain.style.maxWidth = `${room}px`;
4276
4366
  const top = minimized ? pill.height / 2 : Number(domain.dataset.top);
4277
4367
  domain.style.top = `${top}px`;
4278
- const scale = minimized ? (pill.text?.size ?? SAFARI_TEXT.pill) / SAFARI_TEXT.field : 1;
4279
- domain.style.transform = `translate(-50%, -50%) scale(${scale})`;
4368
+ domain.style.transform = "translate(-50%, -50%)";
4280
4369
  }
4281
4370
  },
4282
4371
  loading(on, still2) {
@@ -4758,7 +4847,8 @@ function drawMedia(pen, media, rect, style) {
4758
4847
  }
4759
4848
  if (style.imageRendering === "pixelated" || style.imageRendering === "crisp-edges")
4760
4849
  pen.imageSmoothingEnabled = false;
4761
- pen.drawImage(media.source, from.x, from.y, from.width, from.height, to.x, to.y, to.width, to.height);
4850
+ const scale = media.scale ?? 1;
4851
+ pen.drawImage(media.source, from.x * scale, from.y * scale, from.width * scale, from.height * scale, to.x, to.y, to.width, to.height);
4762
4852
  pen.restore();
4763
4853
  }
4764
4854
  function picturesKey(doc) {
@@ -4829,7 +4919,7 @@ function shootPage(frame2, glass, size, color, layout = "") {
4829
4919
  const draw = (node, alpha, lifted) => {
4830
4920
  if (seen++ > MOST || seen % 50 === 0 && performance.now() > deadline)
4831
4921
  return;
4832
- if (node.hasAttribute("data-devknobs"))
4922
+ if (isMarked(node))
4833
4923
  return;
4834
4924
  const style = view.getComputedStyle(node);
4835
4925
  if (style.display === "none")
@@ -4986,7 +5076,19 @@ function blankPictures(live, copy) {
4986
5076
  image.setAttribute("src", blankUrl(from.naturalWidth, from.naturalHeight));
4987
5077
  });
4988
5078
  }
4989
- function copyPage(frame2, leave) {
5079
+ var NO_CONTROLS = "video::-webkit-media-controls { display: none !important; }";
5080
+ function cuts(overflow) {
5081
+ return overflow === "hidden" || overflow === "auto" || overflow === "scroll" || overflow === "clip";
5082
+ }
5083
+ function viewportOverflow(doc, view) {
5084
+ const root = doc.documentElement;
5085
+ const style = view.getComputedStyle(root);
5086
+ if (cuts(style.overflowX) || cuts(style.overflowY))
5087
+ return root;
5088
+ const { body } = doc;
5089
+ return body?.localName === "body" && body.parentElement === root ? body : null;
5090
+ }
5091
+ function copyPage(frame2, leave, each) {
4990
5092
  const doc = frame2.contentDocument;
4991
5093
  if (!doc?.documentElement)
4992
5094
  return null;
@@ -5026,7 +5128,7 @@ ${own.join(`
5026
5128
  const inert = doc.implementation.createHTMLDocument("");
5027
5129
  const root = inert.importNode(doc.documentElement, true);
5028
5130
  pin(doc.documentElement, root);
5029
- if (leave || pinned) {
5131
+ if (leave || pinned || each) {
5030
5132
  const live = doc.documentElement.getElementsByTagName("*");
5031
5133
  const copied = root.getElementsByTagName("*");
5032
5134
  for (let index = 0;index < live.length; index++) {
@@ -5035,17 +5137,27 @@ ${own.join(`
5035
5137
  if (!node || !copy)
5036
5138
  continue;
5037
5139
  if (leave?.(node))
5038
- copy.setAttribute("data-devknobs", "");
5140
+ markOwn(copy);
5039
5141
  pin(node, copy);
5142
+ each?.(node, copy);
5040
5143
  }
5041
5144
  }
5042
5145
  blankPictures(doc.documentElement, root);
5043
- for (const node of root.querySelectorAll("script, link, style, noscript, [data-devknobs]"))
5146
+ const lifted = view ? viewportOverflow(doc, view) : null;
5147
+ const liftedCopy = lifted === doc.documentElement ? root : lifted ? root.querySelector("body") : null;
5148
+ const liftedStyle = lifted && view ? view.getComputedStyle(lifted) : null;
5149
+ if (liftedCopy && liftedStyle && (cuts(liftedStyle.overflowX) || cuts(liftedStyle.overflowY))) {
5150
+ const own = liftedCopy === root && liftedStyle.display === "block" ? ";display:flow-root !important" : "";
5151
+ liftedCopy.setAttribute("style", `${liftedCopy.getAttribute("style") ?? ""};overflow:visible !important${own}`);
5152
+ }
5153
+ for (const node of root.querySelectorAll(`script, link, style, noscript, ${ownSelector()}`))
5044
5154
  node.remove();
5155
+ const quiet = inert.createElement("style");
5156
+ quiet.textContent = NO_CONTROLS;
5045
5157
  const style = inert.createElement("style");
5046
5158
  style.textContent = frozen.rules.join(`
5047
5159
  `);
5048
- (root.querySelector("head") ?? root).append(style);
5160
+ (root.querySelector("head") ?? root).append(style, quiet);
5049
5161
  return root;
5050
5162
  }
5051
5163
  var LONE_HALF = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
@@ -5088,7 +5200,7 @@ async function paintPage(frame2, glass, size, color, copy) {
5088
5200
  const at = { x: (box2.left - screen.left) * css, y: (box2.top - screen.top) * css };
5089
5201
  let over2 = null;
5090
5202
  for (const node of doc.querySelectorAll(MEDIA)) {
5091
- const media = node.closest("[data-devknobs]") ? null : mediaOf(node);
5203
+ const media = node.closest(ownSelector()) ? null : mediaOf(node);
5092
5204
  const rect = node.getBoundingClientRect();
5093
5205
  if (!media || rect.bottom <= 0 || rect.top >= height || rect.width <= 0)
5094
5206
  continue;
@@ -5135,6 +5247,592 @@ async function paintPage(frame2, glass, size, color, copy) {
5135
5247
  return canvas;
5136
5248
  }
5137
5249
 
5250
+ // src/engine/bandmedia.ts
5251
+ var REACH = 1;
5252
+ var MOST2 = 20000;
5253
+ var LARGEST = 4000000;
5254
+ var SHARPEST = 3;
5255
+ var KEEP_LENGTH = 48000000;
5256
+ var REFUSALS = 2;
5257
+ var MOST_REFUSED = 5000;
5258
+ function bandSpan(scrollY, innerHeight, band) {
5259
+ const top = scrollY + innerHeight;
5260
+ const reach = innerHeight * REACH;
5261
+ return { top: Math.max(0, top - reach), bottom: top + band + reach };
5262
+ }
5263
+ function inSpan(span, scrollY, innerHeight, band) {
5264
+ const top = scrollY + innerHeight;
5265
+ return top >= span.top && top + band <= span.bottom;
5266
+ }
5267
+ function meets(rect, scrollY, span) {
5268
+ return rect.width > 0 && rect.height > 0 && rect.bottom + scrollY > span.top && rect.top + scrollY < span.bottom;
5269
+ }
5270
+ function readSize(media, wide, tall, ratio) {
5271
+ const shows = ratio * Math.max(wide / media.width, tall / media.height);
5272
+ const scale = Math.min(1, shows, Math.sqrt(LARGEST / (media.width * media.height)));
5273
+ return { width: Math.max(1, Math.round(media.width * scale)), height: Math.max(1, Math.round(media.height * scale)) };
5274
+ }
5275
+ function sizedPicture(data, width, height, rendering = "") {
5276
+ const crisp = rendering === "pixelated" || rendering === "crisp-edges" ? ` style="image-rendering:${rendering}"` : "";
5277
+ return svgUrl(`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" preserveAspectRatio="none">` + `<image href="${data}" width="${width}" height="${height}" preserveAspectRatio="none"${crisp}/></svg>`);
5278
+ }
5279
+ function readPixels(source, size) {
5280
+ const canvas = document.createElement("canvas");
5281
+ canvas.width = size.width;
5282
+ canvas.height = size.height;
5283
+ try {
5284
+ const pen = canvas.getContext("2d");
5285
+ if (!pen)
5286
+ return null;
5287
+ pen.drawImage(source, 0, 0, size.width, size.height);
5288
+ return canvas.toDataURL("image/webp", 0.9);
5289
+ } catch {
5290
+ return null;
5291
+ } finally {
5292
+ canvas.width = 0;
5293
+ canvas.height = 0;
5294
+ }
5295
+ }
5296
+ var kept3 = new Map;
5297
+ var keptLength = 0;
5298
+ function keptPixels(key, read) {
5299
+ if (kept3.has(key)) {
5300
+ const data2 = kept3.get(key) ?? null;
5301
+ kept3.delete(key);
5302
+ kept3.set(key, data2);
5303
+ return data2;
5304
+ }
5305
+ const data = read();
5306
+ kept3.set(key, data);
5307
+ keptLength += key.length + (data?.length ?? 0);
5308
+ for (const [old, value] of kept3) {
5309
+ if (keptLength <= KEEP_LENGTH || old === key)
5310
+ break;
5311
+ kept3.delete(old);
5312
+ keptLength -= old.length + (value?.length ?? 0);
5313
+ }
5314
+ return data;
5315
+ }
5316
+ var probes = new Map;
5317
+ function forgetPixels() {
5318
+ kept3.clear();
5319
+ keptLength = 0;
5320
+ probes.clear();
5321
+ asking.clear();
5322
+ }
5323
+ var refused = new Set;
5324
+ var refusedOrigins = new Map;
5325
+ var allowed = new Set;
5326
+ var asking = new Map;
5327
+ function originOf(address) {
5328
+ try {
5329
+ return new URL(address).origin;
5330
+ } catch {
5331
+ return null;
5332
+ }
5333
+ }
5334
+ function sameOrigin(address, base, origin) {
5335
+ try {
5336
+ return new URL(address, base).origin === origin;
5337
+ } catch {
5338
+ return false;
5339
+ }
5340
+ }
5341
+ function refuse(address, origin, found) {
5342
+ if (refused.has(address))
5343
+ return;
5344
+ refused.add(address);
5345
+ if (refused.size > MOST_REFUSED) {
5346
+ const [oldest] = refused;
5347
+ if (oldest !== undefined)
5348
+ refused.delete(oldest);
5349
+ }
5350
+ if (origin !== null && found && !allowed.has(origin))
5351
+ refusedOrigins.set(origin, (refusedOrigins.get(origin) ?? 0) + 1);
5352
+ }
5353
+ function probeOf(doc, address, cors, loaded, used) {
5354
+ const known = used.get(address) ?? probes.get(address);
5355
+ if (known && known.ownerDocument === doc) {
5356
+ used.set(address, known);
5357
+ return known;
5358
+ }
5359
+ const origin = cors ? originOf(address) : null;
5360
+ const shut = () => refused.has(address) || origin !== null && !allowed.has(origin) && (refusedOrigins.get(origin) ?? 0) >= REFUSALS;
5361
+ if (shut())
5362
+ return null;
5363
+ const ask = (withCors2) => {
5364
+ const image = doc.createElement("img");
5365
+ if (withCors2)
5366
+ image.crossOrigin = "anonymous";
5367
+ image.src = address;
5368
+ return image;
5369
+ };
5370
+ if (origin === null || allowed.has(origin)) {
5371
+ const probe = ask(cors);
5372
+ if (!probe.complete) {
5373
+ probe.addEventListener("load", loaded, { once: true });
5374
+ probe.addEventListener("error", () => refuse(address, origin, false), { once: true });
5375
+ }
5376
+ used.set(address, probe);
5377
+ return probe;
5378
+ }
5379
+ const first = asking.get(origin);
5380
+ if (first && first.ownerDocument === doc && !first.complete)
5381
+ return null;
5382
+ const withCors = () => {
5383
+ const probe = ask(true);
5384
+ if (probe.complete) {
5385
+ if (probe.naturalWidth > 0)
5386
+ allowed.add(origin);
5387
+ else
5388
+ refuse(address, origin, true);
5389
+ return probe;
5390
+ }
5391
+ asking.set(origin, probe);
5392
+ const settle2 = (came) => {
5393
+ if (came)
5394
+ allowed.add(origin);
5395
+ else
5396
+ refuse(address, origin, true);
5397
+ if (asking.get(origin) === probe) {
5398
+ asking.delete(origin);
5399
+ loaded();
5400
+ }
5401
+ };
5402
+ probe.addEventListener("load", () => settle2(true), { once: true });
5403
+ probe.addEventListener("error", () => settle2(false), { once: true });
5404
+ return probe;
5405
+ };
5406
+ const plain = ask(false);
5407
+ if (plain.complete) {
5408
+ if (plain.naturalWidth === 0) {
5409
+ refuse(address, origin, false);
5410
+ return null;
5411
+ }
5412
+ const probe = withCors();
5413
+ used.set(address, probe);
5414
+ return probe;
5415
+ }
5416
+ asking.set(origin, plain);
5417
+ plain.addEventListener("load", () => {
5418
+ if (asking.get(origin) !== plain)
5419
+ return;
5420
+ asking.delete(origin);
5421
+ if (shut()) {
5422
+ loaded();
5423
+ return;
5424
+ }
5425
+ const probe = withCors();
5426
+ probes.set(address, probe);
5427
+ if (probe.complete)
5428
+ loaded();
5429
+ }, { once: true });
5430
+ plain.addEventListener("error", () => {
5431
+ refuse(address, origin, false);
5432
+ if (asking.get(origin) === plain) {
5433
+ asking.delete(origin);
5434
+ loaded();
5435
+ }
5436
+ }, { once: true });
5437
+ return null;
5438
+ }
5439
+ function plainOf(doc, address, loaded, used) {
5440
+ const key = `plain|${address}`;
5441
+ const known = used.get(key) ?? probes.get(key);
5442
+ if (known && known.ownerDocument === doc) {
5443
+ used.set(key, known);
5444
+ return known;
5445
+ }
5446
+ if (refused.has(key))
5447
+ return null;
5448
+ const image = doc.createElement("img");
5449
+ image.src = address;
5450
+ if (!image.complete) {
5451
+ image.addEventListener("load", loaded, { once: true });
5452
+ image.addEventListener("error", () => refuse(key, null, false), { once: true });
5453
+ }
5454
+ used.set(key, image);
5455
+ return image;
5456
+ }
5457
+ function showsPoster(video) {
5458
+ if (!video.poster)
5459
+ return false;
5460
+ return video.readyState < 2 || video.paused && video.played.length === 0 && video.currentTime === 0;
5461
+ }
5462
+ function layersOf(value) {
5463
+ const parts = [];
5464
+ let depth = 0;
5465
+ let part = "";
5466
+ for (const char of value) {
5467
+ if (char === "(")
5468
+ depth++;
5469
+ if (char === ")")
5470
+ depth--;
5471
+ if (char === "," && depth === 0) {
5472
+ parts.push(part.trim());
5473
+ part = "";
5474
+ } else
5475
+ part += char;
5476
+ }
5477
+ parts.push(part.trim());
5478
+ return parts;
5479
+ }
5480
+ function urlOf(layer) {
5481
+ const found = /^url\(\s*(["']?)(.*)\1\s*\)$/s.exec(layer);
5482
+ return found?.[2] ?? null;
5483
+ }
5484
+ function sizeOf(fit, media, wide, tall) {
5485
+ if (fit === "cover" || fit === "contain")
5486
+ return fit;
5487
+ if (fit === "none")
5488
+ return "auto";
5489
+ if (fit === "scale-down")
5490
+ return media.width > wide || media.height > tall ? "contain" : "auto";
5491
+ return "100% 100%";
5492
+ }
5493
+ function clipOf(node, doc, view, boxOf2) {
5494
+ for (let at = node.parentElement;at && at !== doc.body && at !== doc.documentElement; at = at.parentElement) {
5495
+ const style = view.getComputedStyle(at);
5496
+ if (style.overflowX === "visible" && style.overflowY === "visible")
5497
+ continue;
5498
+ return { rect: boxOf2(at.getBoundingClientRect()), radius: Number.parseFloat(style.borderTopLeftRadius) || 0 };
5499
+ }
5500
+ return;
5501
+ }
5502
+ function pinned(node, view) {
5503
+ for (let at = node;at; at = at.parentElement) {
5504
+ if (view.getComputedStyle(at).position === "fixed")
5505
+ return true;
5506
+ }
5507
+ return false;
5508
+ }
5509
+ function visible(node) {
5510
+ if (typeof node.checkVisibility !== "function")
5511
+ return true;
5512
+ return node.checkVisibility({ opacityProperty: true, visibilityProperty: true, checkOpacity: true, checkVisibilityCSS: true });
5513
+ }
5514
+ function overlap(a, b) {
5515
+ return Math.min(a.right, b.right) - Math.max(a.left, b.left) > 0.5 && Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top) > 0.5;
5516
+ }
5517
+ var STACKS_CHILDREN = new Set(["flex", "inline-flex", "grid", "inline-grid"]);
5518
+ var inEffect = (value, initial = "none") => (value || initial) !== initial;
5519
+ var names = (value, words2) => (value ?? "").split(/[\s,]+/).some((word) => words2.has(word));
5520
+ var CONTAINS = new Set(["paint", "layout", "strict", "content"]);
5521
+ var CHANGES = new Set(["transform", "opacity", "filter", "scale", "rotate", "translate", "isolation", "mix-blend-mode", "perspective", "clip-path", "mask", "contain", "backdrop-filter", "mask-image", "-webkit-mask-image", "position", "view-transition-name", "offset-path"]);
5522
+ function boxOf2(node, view) {
5523
+ for (let at = node.parentElement;at; at = at.parentElement) {
5524
+ const style = view.getComputedStyle(at);
5525
+ if (style.display !== "contents")
5526
+ return style;
5527
+ }
5528
+ return null;
5529
+ }
5530
+ function contextOf(style) {
5531
+ return style.position === "fixed" || style.position === "sticky" || inEffect(style.transform) || inEffect(style.scale) || inEffect(style.rotate) || inEffect(style.translate) || inEffect(style.filter) || inEffect(style.backdropFilter) || inEffect(style.perspective) || inEffect(style.clipPath) || inEffect(style.maskImage) || inEffect(style.webkitMaskImage) || inEffect(style.mixBlendMode, "normal") || Number.parseFloat(style.opacity) < 1 || style.isolation === "isolate" || names(style.contain, CONTAINS) || inEffect(style.viewTransitionName) || style.contentVisibility === "auto" || inEffect(style.offsetPath) || names(style.willChange, CHANGES);
5532
+ }
5533
+ function rankOf(node, top, view) {
5534
+ let rank = 0;
5535
+ for (let at = node;at && at !== top; at = at.parentElement) {
5536
+ const style = view.getComputedStyle(at);
5537
+ if (style.display === "contents")
5538
+ continue;
5539
+ const positioned = style.position !== "static";
5540
+ const holder = boxOf2(at, view)?.display;
5541
+ const z = positioned || holder && STACKS_CHILDREN.has(holder) ? Number.parseInt(style.zIndex, 10) : Number.NaN;
5542
+ if (Number.isFinite(z) || contextOf(style))
5543
+ rank = !Number.isFinite(z) || z === 0 ? 1 : z < 0 ? z : 1 + z;
5544
+ else if (positioned && rank === 0)
5545
+ rank = 1;
5546
+ }
5547
+ return rank;
5548
+ }
5549
+ function paintsOver(node, media, after, view) {
5550
+ let top = node.parentElement;
5551
+ while (top && !top.contains(media))
5552
+ top = top.parentElement;
5553
+ if (!top)
5554
+ return false;
5555
+ const rank = rankOf(node, top, view) - rankOf(media, top, view);
5556
+ return rank > 0 || rank === 0 && after;
5557
+ }
5558
+ function covered(doc, view, own, pending2) {
5559
+ const over2 = new Set;
5560
+ const above = new Set;
5561
+ const nodes = new Set(pending2.map((one) => one.node));
5562
+ const met = new Set;
5563
+ const all = doc.documentElement.getElementsByTagName("*");
5564
+ for (let index = 0;index < all.length && index < MOST2; index++) {
5565
+ const node = all[index];
5566
+ if (!node)
5567
+ continue;
5568
+ if (nodes.has(node))
5569
+ met.add(node);
5570
+ const rect = node.getBoundingClientRect();
5571
+ if (rect.width <= 0 || rect.height <= 0)
5572
+ continue;
5573
+ for (const one of pending2) {
5574
+ if (node === one.node || node.contains(one.node) || !overlap(rect, one.rect))
5575
+ continue;
5576
+ if (!visible(node) || node.closest(own) || pinned(node, view) || !paintsOver(node, one.node, met.has(one.node), view))
5577
+ continue;
5578
+ over2.add(one.node);
5579
+ above.add(node);
5580
+ }
5581
+ }
5582
+ return { over: over2, above };
5583
+ }
5584
+ function bandMedia(doc, view, span, loaded, scrollY = view.scrollY) {
5585
+ const fills = new Map;
5586
+ const pending2 = [];
5587
+ const used = new Map;
5588
+ const ratio = Math.min(SHARPEST, Math.max(1, view.devicePixelRatio || 1));
5589
+ const { scrollX } = view;
5590
+ const own = ownSelector();
5591
+ const origin = view.location.origin;
5592
+ const boxOf3 = (rect) => ({ left: rect.left + scrollX, top: rect.top + scrollY, width: rect.width, height: rect.height });
5593
+ const add = (node, put) => {
5594
+ const before = fills.get(node);
5595
+ fills.set(node, before ? (copy) => (before(copy), put(copy)) : put);
5596
+ };
5597
+ const restyle = (copy, css) => copy.setAttribute("style", `${copy.getAttribute("style") ?? ""};${css}`);
5598
+ const fill = (node, rect, style, media, data) => {
5599
+ const px = (value) => Number.parseFloat(value) || 0;
5600
+ const wide = rect.width - px(style.borderLeftWidth) - px(style.paddingLeft) - px(style.borderRightWidth) - px(style.paddingRight);
5601
+ const tall = rect.height - px(style.borderTopWidth) - px(style.paddingTop) - px(style.borderBottomWidth) - px(style.paddingBottom);
5602
+ const picture = sizedPicture(data, media.width, media.height, style.imageRendering);
5603
+ const size = "videoWidth" in node ? node.videoWidth > 0 ? { width: node.videoWidth, height: node.videoHeight } : media : null;
5604
+ add(node, (copy) => {
5605
+ if (size && !copy.hasAttribute("width") && !copy.hasAttribute("height")) {
5606
+ copy.setAttribute("width", String(size.width));
5607
+ copy.setAttribute("height", String(size.height));
5608
+ }
5609
+ restyle(copy, `background-image:url("${picture}") !important;background-size:${sizeOf(style.objectFit, media, wide, tall)} !important;` + `background-position:${style.objectPosition} !important;background-repeat:no-repeat !important;background-origin:content-box !important`);
5610
+ });
5611
+ };
5612
+ for (const node of doc.querySelectorAll(MEDIA)) {
5613
+ const rect = node.getBoundingClientRect();
5614
+ if (!meets(rect, scrollY, span) || node.closest(own))
5615
+ continue;
5616
+ if ("videoWidth" in node && showsPoster(node)) {
5617
+ if (pinned(node, view))
5618
+ continue;
5619
+ const address = node.poster;
5620
+ const style2 = view.getComputedStyle(node);
5621
+ const cors = !sameOrigin(address, doc.baseURI, origin);
5622
+ const probe = probeOf(doc, address, cors, loaded, used);
5623
+ const media2 = probe && mediaOf(probe);
5624
+ if (probe && media2) {
5625
+ const size2 = readSize(media2, rect.width, rect.height, ratio);
5626
+ const data2 = keptPixels(`${address}|${cors ? "cors|" : ""}${size2.width}x${size2.height}`, () => readPixels(probe, size2));
5627
+ if (data2 !== null) {
5628
+ fill(node, rect, style2, media2, data2);
5629
+ continue;
5630
+ }
5631
+ }
5632
+ const plain = visible(node) ? plainOf(doc, address, loaded, used) : null;
5633
+ const shown2 = plain && mediaOf(plain);
5634
+ if (shown2)
5635
+ pending2.push({ node, rect, draw: () => ({ media: shown2, rect: boxOf3(rect), style: style2, clip: clipOf(node, doc, view, boxOf3) }) });
5636
+ continue;
5637
+ }
5638
+ const media = mediaOf(node);
5639
+ if (!media || pinned(node, view))
5640
+ continue;
5641
+ const style = view.getComputedStyle(node);
5642
+ if ("naturalWidth" in node) {
5643
+ const address = node.currentSrc || node.src;
5644
+ if (address.startsWith("data:")) {
5645
+ add(node, (copy) => copy.setAttribute("src", address));
5646
+ continue;
5647
+ }
5648
+ const dense = node.srcset || node.parentElement?.localName === "picture" ? ratio : 1;
5649
+ const size2 = readSize({ width: media.width * dense, height: media.height * dense }, rect.width, rect.height, ratio);
5650
+ const sized = `${size2.width}x${size2.height}`;
5651
+ let data2 = keptPixels(`${address}|${sized}`, () => readPixels(node, size2));
5652
+ if (data2 === null) {
5653
+ const probe = probeOf(doc, address, true, loaded, used);
5654
+ if (probe && mediaOf(probe))
5655
+ data2 = keptPixels(`${address}|cors|${sized}`, () => readPixels(probe, size2));
5656
+ }
5657
+ if (data2 !== null) {
5658
+ const read = data2;
5659
+ add(node, (copy) => copy.setAttribute("src", sizedPicture(read, media.width, media.height, style.imageRendering)));
5660
+ continue;
5661
+ }
5662
+ if (!visible(node))
5663
+ continue;
5664
+ pending2.push({
5665
+ node,
5666
+ rect,
5667
+ draw: () => {
5668
+ const whole = document.createElement("canvas");
5669
+ whole.width = size2.width;
5670
+ whole.height = size2.height;
5671
+ try {
5672
+ whole.getContext("2d")?.drawImage(node, 0, 0, size2.width, size2.height);
5673
+ } catch {
5674
+ whole.width = 0;
5675
+ whole.height = 0;
5676
+ return null;
5677
+ }
5678
+ const drawn = { source: whole, width: media.width, height: media.height, scale: size2.width / media.width };
5679
+ return { media: drawn, rect: boxOf3(rect), style, made: whole, clip: clipOf(node, doc, view, boxOf3) };
5680
+ }
5681
+ });
5682
+ continue;
5683
+ }
5684
+ if ("videoWidth" in node && !node.paused) {
5685
+ if (visible(node))
5686
+ pending2.push({ node, rect, draw: () => ({ media, rect: boxOf3(rect), style, clip: clipOf(node, doc, view, boxOf3), live: node }) });
5687
+ continue;
5688
+ }
5689
+ const size = readSize(media, rect.width, rect.height, ratio);
5690
+ const data = readPixels(node, size);
5691
+ if (data === null) {
5692
+ if (visible(node))
5693
+ pending2.push({ node, rect, draw: () => ({ media, rect: boxOf3(rect), style, clip: clipOf(node, doc, view, boxOf3) }) });
5694
+ continue;
5695
+ }
5696
+ fill(node, rect, style, media, data);
5697
+ }
5698
+ const all = doc.documentElement.getElementsByTagName("*");
5699
+ for (let index = 0;index < all.length && index < MOST2; index++) {
5700
+ const node = all[index];
5701
+ if (!node)
5702
+ continue;
5703
+ const rect = node.getBoundingClientRect();
5704
+ if (!meets(rect, scrollY, span))
5705
+ continue;
5706
+ const style = view.getComputedStyle(node);
5707
+ const value = style.backgroundImage;
5708
+ if (!value?.includes("url(") || node.closest(own) || pinned(node, view))
5709
+ continue;
5710
+ let read = false;
5711
+ const shown2 = layersOf(value).map((layer) => {
5712
+ const address = urlOf(layer);
5713
+ if (address === null || address.startsWith("data:"))
5714
+ return layer;
5715
+ const cors = !sameOrigin(address, doc.baseURI, origin);
5716
+ const probe = probeOf(doc, address, cors, loaded, used);
5717
+ const media = probe && mediaOf(probe);
5718
+ if (!media)
5719
+ return layer;
5720
+ const size = readSize(media, rect.width, rect.height, ratio);
5721
+ const data = keptPixels(`${address}|${cors ? "cors|" : ""}${size.width}x${size.height}`, () => readPixels(probe, size));
5722
+ if (data === null)
5723
+ return layer;
5724
+ read = true;
5725
+ return `url("${sizedPicture(data, media.width, media.height, style.imageRendering)}")`;
5726
+ });
5727
+ if (read) {
5728
+ const css = `background-image:${shown2.join(", ")} !important`;
5729
+ add(node, (copy) => restyle(copy, css));
5730
+ }
5731
+ }
5732
+ probes = used;
5733
+ const { over: over2, above } = pending2.length > 0 ? covered(doc, view, own, pending2) : { over: new Set, above: new Set };
5734
+ const unread = [];
5735
+ for (const one of pending2) {
5736
+ const drawn = one.draw();
5737
+ if (drawn)
5738
+ unread.push(over2.has(one.node) ? { ...drawn, covered: true } : drawn);
5739
+ }
5740
+ return { fills, unread, above };
5741
+ }
5742
+ function clipTo(pen, one) {
5743
+ const { rect, clip } = one;
5744
+ if (clip) {
5745
+ pen.beginPath();
5746
+ pen.roundRect(clip.rect.left, clip.rect.top, clip.rect.width, clip.rect.height, clip.radius);
5747
+ pen.clip();
5748
+ }
5749
+ pen.beginPath();
5750
+ pen.rect(rect.left, rect.top, rect.width, rect.height);
5751
+ pen.clip();
5752
+ }
5753
+ function drawOne(pen, one) {
5754
+ pen.save();
5755
+ try {
5756
+ if (one.clip) {
5757
+ pen.beginPath();
5758
+ pen.roundRect(one.clip.rect.left, one.clip.rect.top, one.clip.rect.width, one.clip.rect.height, one.clip.radius);
5759
+ pen.clip();
5760
+ }
5761
+ drawMedia(pen, one.media, one.rect, one.style);
5762
+ } catch {}
5763
+ pen.restore();
5764
+ }
5765
+ function overlayOf(unread, span, width, ratio, above = null) {
5766
+ if (unread.length === 0)
5767
+ return null;
5768
+ const canvas = document.createElement("canvas");
5769
+ canvas.width = Math.max(1, Math.round(width * ratio));
5770
+ canvas.height = Math.max(1, Math.round((span.bottom - span.top) * ratio));
5771
+ const pen = canvas.getContext("2d");
5772
+ if (!pen)
5773
+ return null;
5774
+ pen.setTransform(ratio, 0, 0, ratio, 0, -span.top * ratio);
5775
+ for (const one of unread) {
5776
+ drawOne(pen, one);
5777
+ if (one.made) {
5778
+ one.made.width = 0;
5779
+ one.made.height = 0;
5780
+ }
5781
+ }
5782
+ const parts = unread.filter((one) => one.covered);
5783
+ return { canvas, span, width, ratio, live: unread.filter((one) => one.live), above: above && parts.length > 0 ? { src: above, parts } : null };
5784
+ }
5785
+ function raiseOf(overlay, image) {
5786
+ const { span, width, ratio } = overlay;
5787
+ const canvas = document.createElement("canvas");
5788
+ canvas.width = overlay.canvas.width;
5789
+ canvas.height = overlay.canvas.height;
5790
+ const pen = canvas.getContext("2d");
5791
+ if (!pen)
5792
+ return null;
5793
+ const tall = span.bottom - span.top;
5794
+ pen.setTransform(ratio, 0, 0, ratio, 0, -span.top * ratio);
5795
+ try {
5796
+ pen.drawImage(image, 0, span.top, width, tall, 0, span.top, width, tall);
5797
+ } catch {
5798
+ canvas.width = 0;
5799
+ canvas.height = 0;
5800
+ return null;
5801
+ }
5802
+ return canvas;
5803
+ }
5804
+ function drawAbove(overlay, raised, only) {
5805
+ const { canvas, span, width, ratio, above } = overlay;
5806
+ const pen = above && canvas.getContext("2d");
5807
+ if (!above || !pen)
5808
+ return;
5809
+ pen.setTransform(ratio, 0, 0, ratio, 0, -span.top * ratio);
5810
+ for (const part of above.parts) {
5811
+ if (only && part !== only)
5812
+ continue;
5813
+ pen.save();
5814
+ try {
5815
+ clipTo(pen, part);
5816
+ pen.drawImage(raised, 0, span.top, width, span.bottom - span.top);
5817
+ } catch {}
5818
+ pen.restore();
5819
+ }
5820
+ }
5821
+ function redrawLive(overlay, one, raised) {
5822
+ const { canvas, span, ratio } = overlay;
5823
+ const pen = canvas.getContext("2d");
5824
+ if (!pen)
5825
+ return;
5826
+ pen.setTransform(ratio, 0, 0, ratio, 0, -span.top * ratio);
5827
+ pen.save();
5828
+ clipTo(pen, one);
5829
+ pen.clearRect(one.rect.left, one.rect.top, one.rect.width, one.rect.height);
5830
+ pen.restore();
5831
+ drawOne(pen, one);
5832
+ if (raised && one.covered)
5833
+ drawAbove(overlay, raised, one);
5834
+ }
5835
+
5138
5836
  // src/engine/underbar.ts
5139
5837
  var UNDERBAR_CSS = `
5140
5838
  .underbar {
@@ -5144,7 +5842,8 @@ var UNDERBAR_CSS = `
5144
5842
  transform-origin: 0 0;
5145
5843
  }
5146
5844
  .underbar[hidden] { display: none; }
5147
- .underbar > img {
5845
+ .underbar > img,
5846
+ .underbar > canvas {
5148
5847
  position: absolute;
5149
5848
  left: 0;
5150
5849
  top: 0;
@@ -5152,6 +5851,7 @@ var UNDERBAR_CSS = `
5152
5851
  will-change: transform;
5153
5852
  }
5154
5853
  `;
5854
+ var LOADS = ["load", "loadeddata", "seeked", "playing"];
5155
5855
  var GAP = 250;
5156
5856
  var SHARE = 10;
5157
5857
  function bandRect(page, height) {
@@ -5173,13 +5873,54 @@ var VH = /(-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)[sld]?vh\b/gi;
5173
5873
  function viewportUnits(css, height) {
5174
5874
  return css.replace(VH, (_, amount) => `${Math.round(Number(amount) * height) / 100}px`);
5175
5875
  }
5176
- function pictureOf(frame2) {
5876
+ function bodyScroller(doc, view) {
5877
+ const { body } = doc;
5878
+ if (!body || viewportOverflow(doc, view) !== doc.documentElement)
5879
+ return null;
5880
+ const { overflowY } = view.getComputedStyle(body);
5881
+ return cuts(overflowY) && overflowY !== "clip" ? body : null;
5882
+ }
5883
+ function scrollOf(doc, view) {
5884
+ return view.scrollY + (bodyScroller(doc, view)?.scrollTop ?? 0);
5885
+ }
5886
+ function heightOf(doc, view) {
5887
+ const full = doc.documentElement.scrollHeight;
5888
+ const body = bodyScroller(doc, view);
5889
+ if (!body)
5890
+ return full;
5891
+ return Math.max(full, body.getBoundingClientRect().top + view.scrollY + body.clientTop + body.scrollHeight);
5892
+ }
5893
+ function unscroll(copy, body, view) {
5894
+ const style = view.getComputedStyle(body);
5895
+ const own = style.display === "block" ? ";display:flow-root !important" : "";
5896
+ copy.setAttribute("style", `${copy.getAttribute("style") ?? ""};overflow-x:clip !important;overflow-y:visible !important${own}`);
5897
+ }
5898
+ function isMedia(target) {
5899
+ return target !== null && "currentSrc" in target;
5900
+ }
5901
+ function nearLoad(target, scrollY, span) {
5902
+ if (!isMedia(target))
5903
+ return false;
5904
+ return meets(target.getBoundingClientRect(), scrollY, span);
5905
+ }
5906
+ function pictureOf(frame2, band = 0, loaded = () => {}) {
5177
5907
  const doc = frame2.contentDocument;
5178
5908
  const view = frame2.contentWindow;
5179
5909
  if (!doc?.documentElement || !view || view.innerWidth <= 0)
5180
5910
  return null;
5181
5911
  const { innerWidth: width, innerHeight: tall } = view;
5182
- const copy = copyPage(frame2, (node) => view.getComputedStyle(node).position === "fixed");
5912
+ const scrolled = scrollOf(doc, view);
5913
+ const span = bandSpan(scrolled, tall, band);
5914
+ const media = bandMedia(doc, view, span, loaded, scrolled);
5915
+ const puts = [];
5916
+ const above = [];
5917
+ const copy = copyPage(frame2, (node) => view.getComputedStyle(node).position === "fixed", (node, copied) => {
5918
+ const put = media.fills.get(node);
5919
+ if (put)
5920
+ puts.push(() => put(copied));
5921
+ if (media.above.has(node))
5922
+ above.push(copied);
5923
+ });
5183
5924
  if (!copy)
5184
5925
  return null;
5185
5926
  for (const style of copy.querySelectorAll("style")) {
@@ -5188,14 +5929,35 @@ function pictureOf(frame2) {
5188
5929
  for (const node of copy.querySelectorAll("[style]")) {
5189
5930
  node.setAttribute("style", viewportUnits(node.getAttribute("style") ?? "", tall));
5190
5931
  }
5191
- const full = Math.max(doc.documentElement.scrollHeight, tall);
5932
+ for (const put of puts)
5933
+ put();
5934
+ const scroller = bodyScroller(doc, view);
5935
+ const body = scroller ? copy.querySelector("body") : null;
5936
+ if (scroller && body)
5937
+ unscroll(body, scroller, view);
5938
+ const full = Math.max(heightOf(doc, view), tall);
5192
5939
  const root = doc.documentElement.getBoundingClientRect().height / ownZoom(doc, view);
5193
5940
  const sized = rootSize(doc, view);
5194
5941
  const zoom = layoutZoom(view);
5195
5942
  const zoomed = rootZoom(doc, view, zoom);
5196
5943
  copy.setAttribute("style", `${copy.getAttribute("style") ?? ""};${sized};height:${root}px !important${zoomed}`);
5197
5944
  const markup = new XMLSerializer().serializeToString(copy);
5198
- return { src: svgUrl(drawing(markup, width, full, sized, zoom)), width, height: full };
5945
+ const shows = doc.querySelector(MEDIA) !== null || /url\(\s*(?!["']?data:|&quot;data:)/i.test(markup);
5946
+ const ratio = Math.min(2, Math.max(1, window.devicePixelRatio || 1));
5947
+ return {
5948
+ src: svgUrl(drawing(markup, width, full, sized, zoom)),
5949
+ width,
5950
+ height: full,
5951
+ span: shows ? span : null,
5952
+ overlay: overlayOf(media.unread, span, width, ratio, above.length > 0 ? svgUrl(drawing(aboveOnly(copy, above), width, full, sized, zoom)) : null)
5953
+ };
5954
+ }
5955
+ function aboveOnly(copy, shown2) {
5956
+ const restyle = (node, css) => node.setAttribute("style", `${node.getAttribute("style") ?? ""};${css}`);
5957
+ restyle(copy, "visibility:hidden !important");
5958
+ for (const node of shown2)
5959
+ restyle(node, "visibility:visible !important");
5960
+ return new XMLSerializer().serializeToString(copy);
5199
5961
  }
5200
5962
  function createUnderbar(glass, frame2) {
5201
5963
  const band = el("div", "underbar");
@@ -5204,6 +5966,7 @@ function createUnderbar(glass, frame2) {
5204
5966
  glass.append(band);
5205
5967
  let image = null;
5206
5968
  let picture = null;
5969
+ let cover = null;
5207
5970
  let taken = "";
5208
5971
  let watched2 = null;
5209
5972
  let observer = null;
@@ -5213,6 +5976,68 @@ function createUnderbar(glass, frame2) {
5213
5976
  let last = 0;
5214
5977
  let cost = 0;
5215
5978
  let wide = 0;
5979
+ let high = 0;
5980
+ const again = () => {
5981
+ changed = true;
5982
+ soon();
5983
+ };
5984
+ const bandOf = (across) => wide > 0 ? high * across / wide : 0;
5985
+ const onLoad = (event) => {
5986
+ if (picture?.overlay?.live.some((one) => one.live === event.target))
5987
+ return;
5988
+ try {
5989
+ const view = frame2.contentWindow;
5990
+ const doc = frame2.contentDocument;
5991
+ if (!view || !doc || band.hidden)
5992
+ return;
5993
+ const scrolled = scrollOf(doc, view);
5994
+ const span = bandSpan(scrolled, view.innerHeight, bandOf(view.innerWidth));
5995
+ if (nearLoad(event.target, scrolled, span))
5996
+ again();
5997
+ } catch {}
5998
+ };
5999
+ const onScroll = (event) => {
6000
+ if (event.target === watched2?.body)
6001
+ move();
6002
+ };
6003
+ const spend2 = (canvas) => {
6004
+ if (!canvas)
6005
+ return;
6006
+ canvas.width = 0;
6007
+ canvas.height = 0;
6008
+ };
6009
+ let raised = null;
6010
+ const dropCover = () => {
6011
+ spend2(raised);
6012
+ raised = null;
6013
+ if (!cover)
6014
+ return;
6015
+ cover.remove();
6016
+ cover.width = 0;
6017
+ cover.height = 0;
6018
+ cover = null;
6019
+ };
6020
+ const follow4 = (overlay) => {
6021
+ for (const one of overlay.live) {
6022
+ const video = one.live;
6023
+ if (!video)
6024
+ continue;
6025
+ const ask = () => {
6026
+ if (typeof video.requestVideoFrameCallback === "function")
6027
+ video.requestVideoFrameCallback(step);
6028
+ else
6029
+ window.requestAnimationFrame(step);
6030
+ };
6031
+ const step = () => {
6032
+ if (cover !== overlay.canvas)
6033
+ return;
6034
+ if (!band.hidden)
6035
+ redrawLive(overlay, one, raised);
6036
+ ask();
6037
+ };
6038
+ ask();
6039
+ }
6040
+ };
5216
6041
  const keyOf = () => {
5217
6042
  try {
5218
6043
  const doc = frame2.contentDocument;
@@ -5221,20 +6046,24 @@ function createUnderbar(glass, frame2) {
5221
6046
  return null;
5222
6047
  if (doc !== watched2) {
5223
6048
  observer?.disconnect();
5224
- const next = new MutationObserver(() => {
5225
- changed = true;
5226
- soon();
5227
- });
6049
+ for (const type of LOADS)
6050
+ watched2?.removeEventListener(type, onLoad, true);
6051
+ watched2?.removeEventListener("scroll", onScroll, true);
6052
+ const next = new MutationObserver(again);
5228
6053
  next.observe(doc, { subtree: true, childList: true, attributes: true, characterData: true });
6054
+ for (const type of LOADS)
6055
+ doc.addEventListener(type, onLoad, true);
6056
+ doc.addEventListener("scroll", onScroll, true);
5229
6057
  observer = next;
5230
6058
  watched2 = doc;
5231
6059
  changed = true;
5232
6060
  image?.remove();
5233
6061
  image = null;
5234
6062
  picture = null;
6063
+ dropCover();
5235
6064
  taken = "";
5236
6065
  }
5237
- return `${view.innerWidth}|${view.innerHeight}|${doc.documentElement.scrollHeight}`;
6066
+ return `${view.innerWidth}|${view.innerHeight}|${heightOf(doc, view)}`;
5238
6067
  } catch {
5239
6068
  return null;
5240
6069
  }
@@ -5244,10 +6073,17 @@ function createUnderbar(glass, frame2) {
5244
6073
  return;
5245
6074
  try {
5246
6075
  const view = frame2.contentWindow;
5247
- if (!view)
6076
+ const doc = frame2.contentDocument;
6077
+ if (!view || !doc)
5248
6078
  return;
5249
- const shift = bandShift(view.scrollY, view.innerHeight, wide / picture.width);
6079
+ const scale = wide / picture.width;
6080
+ const scrolled = scrollOf(doc, view);
6081
+ const shift = bandShift(scrolled, view.innerHeight, scale);
5250
6082
  image.style.transform = `translate3d(0, ${shift}px, 0)`;
6083
+ if (cover && picture.overlay)
6084
+ cover.style.transform = `translate3d(0, ${shift + picture.overlay.span.top * scale}px, 0)`;
6085
+ if (picture.span && !inSpan(picture.span, scrolled, view.innerHeight, bandOf(picture.width)))
6086
+ again();
5251
6087
  } catch {}
5252
6088
  };
5253
6089
  const paint = async () => {
@@ -5259,6 +6095,7 @@ function createUnderbar(glass, frame2) {
5259
6095
  image?.remove();
5260
6096
  image = null;
5261
6097
  picture = null;
6098
+ dropCover();
5262
6099
  return;
5263
6100
  }
5264
6101
  if (!changed && key === taken)
@@ -5268,22 +6105,36 @@ function createUnderbar(glass, frame2) {
5268
6105
  const start = performance.now();
5269
6106
  let next = null;
5270
6107
  try {
5271
- next = pictureOf(frame2);
6108
+ next = pictureOf(frame2, bandOf(frame2.contentWindow?.innerWidth ?? 0), again);
5272
6109
  } catch {
5273
6110
  next = null;
5274
6111
  }
5275
6112
  const fresh2 = new Image;
5276
6113
  let drawn = false;
6114
+ let lifted = null;
5277
6115
  if (next) {
5278
6116
  fresh2.src = next.src;
5279
6117
  drawn = await fresh2.decode().then(() => true, () => false);
6118
+ const above = next.overlay?.above;
6119
+ if (drawn && next.overlay && above) {
6120
+ const over2 = new Image;
6121
+ over2.src = above.src;
6122
+ const decoded = await over2.decode().then(() => true, () => false);
6123
+ lifted = decoded ? raiseOf(next.overlay, over2) : null;
6124
+ if (lifted)
6125
+ drawAbove(next.overlay, lifted);
6126
+ }
5280
6127
  }
5281
6128
  cost = performance.now() - start;
5282
6129
  last = performance.now();
5283
6130
  performance.measure("devknobs underbar picture", { start, duration: cost });
5284
6131
  painting = false;
5285
- if (!next || !drawn)
6132
+ if (!next || !drawn) {
6133
+ if (next?.overlay)
6134
+ next.overlay.canvas.width = 0;
6135
+ spend2(lifted);
5286
6136
  return;
6137
+ }
5287
6138
  fresh2.alt = "";
5288
6139
  if (image)
5289
6140
  image.replaceWith(fresh2);
@@ -5291,6 +6142,16 @@ function createUnderbar(glass, frame2) {
5291
6142
  band.append(fresh2);
5292
6143
  image = fresh2;
5293
6144
  picture = next;
6145
+ dropCover();
6146
+ cover = next.overlay?.canvas ?? null;
6147
+ if (cover)
6148
+ band.append(cover);
6149
+ if (next.overlay?.live.length)
6150
+ raised = lifted;
6151
+ else
6152
+ spend2(lifted);
6153
+ if (next.overlay)
6154
+ follow4(next.overlay);
5294
6155
  taken = key;
5295
6156
  fit();
5296
6157
  if (changed)
@@ -5307,6 +6168,11 @@ function createUnderbar(glass, frame2) {
5307
6168
  return;
5308
6169
  image.style.width = `${wide}px`;
5309
6170
  image.style.height = `${picture.height * wide / picture.width}px`;
6171
+ if (cover && picture.overlay) {
6172
+ const { span } = picture.overlay;
6173
+ cover.style.width = `${wide}px`;
6174
+ cover.style.height = `${(span.bottom - span.top) * wide / picture.width}px`;
6175
+ }
5310
6176
  move();
5311
6177
  }
5312
6178
  return {
@@ -5320,8 +6186,9 @@ function createUnderbar(glass, frame2) {
5320
6186
  }
5321
6187
  place(band, rect.x * zoom, rect.y * zoom, rect.width, rect.height);
5322
6188
  wide = rect.width;
6189
+ high = rect.height;
5323
6190
  band.style.transform = zoom === 1 ? "" : `scale(${zoom})`;
5324
- band.style.background = look.background;
6191
+ band.style.background = `linear-gradient(${look.background}, ${look.background})`;
5325
6192
  const key = keyOf();
5326
6193
  if (key !== taken || changed)
5327
6194
  soon();
@@ -5336,7 +6203,12 @@ function createUnderbar(glass, frame2) {
5336
6203
  clearTimeout(waiting);
5337
6204
  observer?.disconnect();
5338
6205
  observer = null;
6206
+ for (const type of LOADS)
6207
+ watched2?.removeEventListener(type, onLoad, true);
6208
+ watched2?.removeEventListener("scroll", onScroll, true);
5339
6209
  watched2 = null;
6210
+ dropCover();
6211
+ forgetPixels();
5340
6212
  band.remove();
5341
6213
  }
5342
6214
  };
@@ -5943,11 +6815,11 @@ function fit(knobs2, size, options = {}) {
5943
6815
  const whole = Math.min(sized && tall ? ZOOM_MAX : 1, across, tall ? upright : 1);
5944
6816
  const height = typeof knobs2.height === "number" ? knobs2.height : room.height / whole;
5945
6817
  const outer = { width: width + sides.width, height: height + sides.height };
5946
- const covered = sized && aside > 0 && aside <= room.width / 2 && (room.width + outer.width * whole) / 2 + x > room.width - aside;
5947
- const loose = covered ? Math.min(whole, (room.width - aside - 2 * x) / outer.width) : whole;
6818
+ const covered2 = sized && aside > 0 && aside <= room.width / 2 && (room.width + outer.width * whole) / 2 + x > room.width - aside;
6819
+ const loose = covered2 ? Math.min(whole, (room.width - aside - 2 * x) / outer.width) : whole;
5948
6820
  const fitted = mock === BARE ? loose : snapScale(loose, height, ratio);
5949
6821
  const scale = knobs2.zoom === "fit" ? fitted : knobs2.zoom;
5950
- const beside = knobs2.zoom === "fit" && covered ? aside : 0;
6822
+ const beside = knobs2.zoom === "fit" && covered2 ? aside : 0;
5951
6823
  const before = side === "left" ? beside : 0;
5952
6824
  return {
5953
6825
  width,
@@ -6269,7 +7141,7 @@ function hingeLine(pane, across, part) {
6269
7141
  return pane === "inner" ? [-1 / width, 0, (x + width) / width] : [1 / width, 0, -x / width];
6270
7142
  return pane === "inner" ? [0, 1 / height, -y / height] : [0, -1 / height, (y + height) / height];
6271
7143
  }
6272
- function contextOf(canvas) {
7144
+ function contextOf2(canvas) {
6273
7145
  if (typeof WebGL2RenderingContext === "undefined")
6274
7146
  return null;
6275
7147
  const gl = canvas.getContext("webgl2", {
@@ -6387,11 +7259,11 @@ function uploadWhy(error) {
6387
7259
  const tainted = "the browser holds the picture as another origin's, as one with a picture, video or canvas from another origin drawn in, or a drawing of the page this browser does not trust";
6388
7260
  return `the picture could not be uploaded: ${name}${name === "SecurityError" ? `, ${tainted}` : ""}`;
6389
7261
  }
6390
- function screenGl(place2, refused) {
7262
+ function screenGl(place2, refused2) {
6391
7263
  const canvas = document.createElement("canvas");
6392
- const gl = contextOf(canvas);
7264
+ const gl = contextOf2(canvas);
6393
7265
  if (!gl) {
6394
- refused(typeof WebGL2RenderingContext === "undefined" ? "this browser has no WebGL2" : "the canvas gave no WebGL2 context", null);
7266
+ refused2(typeof WebGL2RenderingContext === "undefined" ? "this browser has no WebGL2" : "the canvas gave no WebGL2 context", null);
6395
7267
  return null;
6396
7268
  }
6397
7269
  const rect = canvasRect(place2);
@@ -6422,7 +7294,7 @@ function screenGl(place2, refused) {
6422
7294
  if (!vertex2 || !fragment || !program || !corners || !texture) {
6423
7295
  const why = gl.isContextLost() ? "the WebGL2 context was lost as it was made" : "WebGL2 made no shader, program, buffer or texture";
6424
7296
  free();
6425
- refused(why, null);
7297
+ refused2(why, null);
6426
7298
  return null;
6427
7299
  }
6428
7300
  gl.attachShader(program, vertex2);
@@ -6432,7 +7304,7 @@ function screenGl(place2, refused) {
6432
7304
  const log = [vertex2, fragment].map((shader) => gl.getShaderInfoLog(shader)).find((said) => said?.trim()) ?? gl.getProgramInfoLog(program);
6433
7305
  const lost = gl.isContextLost();
6434
7306
  free();
6435
- refused(lost ? "the WebGL2 context was lost as it was made" : `the shader did not compile or link: ${firstLine(log, "no reason given")}`, null);
7307
+ refused2(lost ? "the WebGL2 context was lost as it was made" : `the shader did not compile or link: ${firstLine(log, "no reason given")}`, null);
6436
7308
  return null;
6437
7309
  }
6438
7310
  gl.useProgram(program);
@@ -6484,31 +7356,31 @@ function screenGl(place2, refused) {
6484
7356
  return;
6485
7357
  gone = true;
6486
7358
  canvas.remove();
6487
- refused("the WebGL2 context was lost", shot);
7359
+ refused2("the WebGL2 context was lost", shot);
6488
7360
  });
6489
- const refuse = (why, next) => {
7361
+ const refuse2 = (why, next) => {
6490
7362
  if (!gone)
6491
7363
  free();
6492
7364
  gone = true;
6493
- refused(why, next);
7365
+ refused2(why, next);
6494
7366
  };
6495
7367
  return {
6496
7368
  canvas,
6497
7369
  paint(next) {
6498
7370
  if (gone)
6499
- return refuse("the WebGL2 context is gone", next);
7371
+ return refuse2("the WebGL2 context is gone", next);
6500
7372
  if (Math.max(next.width, next.height) > widest) {
6501
- return refuse(`the picture, ${next.width} by ${next.height} px, is larger than MAX_TEXTURE_SIZE, ${widest}`, next);
7373
+ return refuse2(`the picture, ${next.width} by ${next.height} px, is larger than MAX_TEXTURE_SIZE, ${widest}`, next);
6502
7374
  }
6503
7375
  gl.getError();
6504
7376
  try {
6505
7377
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, next);
6506
7378
  } catch (error) {
6507
- return refuse(uploadWhy(error), next);
7379
+ return refuse2(uploadWhy(error), next);
6508
7380
  }
6509
7381
  const failed = gl.getError();
6510
7382
  if (failed !== gl.NO_ERROR)
6511
- return refuse(`the picture could not be uploaded: WebGL2 error 0x${failed.toString(16)}`, next);
7383
+ return refuse2(`the picture could not be uploaded: WebGL2 error 0x${failed.toString(16)}`, next);
6512
7384
  gl.generateMipmap(gl.TEXTURE_2D);
6513
7385
  shot = next;
6514
7386
  if (look)
@@ -6526,7 +7398,7 @@ function screenGl(place2, refused) {
6526
7398
 
6527
7399
  // src/engine/barshot.ts
6528
7400
  var GLASS = "blur(10px) saturate(1.8)";
6529
- var REACH = 30;
7401
+ var REACH2 = 30;
6530
7402
  var STILL_CSS = `
6531
7403
  .browser { transform: none !important; }
6532
7404
  .browser, .browser * {
@@ -6548,7 +7420,7 @@ function glassOf(bars, host) {
6548
7420
  return bars.shapes.filter((shape) => shape.kind !== "field").map(({ x, y, width, height, radius }) => ({ rect: { x, y, width, height }, radius }));
6549
7421
  }
6550
7422
  const pill = bars.shapes.find((shape) => shape.kind === "pill");
6551
- return pill ? [{ rect: pillBox(pill, host), radius: pill.radius }] : [];
7423
+ return pill ? [{ rect: pillBox(pill, host, turn(bars.screen, bars.orientation).width), radius: pill.radius }] : [];
6552
7424
  }
6553
7425
  function copyBars(shown2, value, size) {
6554
7426
  const minimized = shown2.querySelector("[data-state]")?.getAttribute("data-state") === "min";
@@ -6586,8 +7458,8 @@ async function paintBars(shot, bars) {
6586
7458
  pen.roundRect(rect.x, rect.y, rect.width, rect.height, radius);
6587
7459
  pen.clip();
6588
7460
  pen.filter = GLASS;
6589
- const [x, y] = [rect.x - REACH, rect.y - REACH];
6590
- const [width, height] = [rect.width + 2 * REACH, rect.height + 2 * REACH];
7461
+ const [x, y] = [rect.x - REACH2, rect.y - REACH2];
7462
+ const [width, height] = [rect.width + 2 * REACH2, rect.height + 2 * REACH2];
6591
7463
  pen.drawImage(under, x * scale, y * scale, width * scale, height * scale, x, y, width, height);
6592
7464
  pen.restore();
6593
7465
  }
@@ -6964,12 +7836,12 @@ function pick(turning, open) {
6964
7836
  const { at } = shownAt(shots2, ready, open);
6965
7837
  const next = at === null ? null : shots2.frames[at];
6966
7838
  const bitmap = at === null ? null : ready[at];
6967
- const kept3 = next && shots2.stills[next.still];
7839
+ const kept4 = next && shots2.stills[next.still];
6968
7840
  const keptBitmap = next && found?.stills[next.still];
6969
7841
  if (next && bitmap && next !== plane.shot)
6970
7842
  drawOn(plane, next, bitmap, shots2.scale);
6971
- if (kept3 && keptBitmap && kept3 !== turning.still.shot)
6972
- drawOn(turning.still, kept3, keptBitmap, shots2.scale);
7843
+ if (kept4 && keptBitmap && kept4 !== turning.still.shot)
7844
+ drawOn(turning.still, kept4, keptBitmap, shots2.scale);
6973
7845
  return plane.shot ? shotOpen(plane.shot) : open;
6974
7846
  }
6975
7847
  function pose(turning, layout, open, shown2, still2) {
@@ -8493,7 +9365,7 @@ var bodyObserver = null;
8493
9365
  function hide(node) {
8494
9366
  if (!(node instanceof HTMLElement || node instanceof SVGElement))
8495
9367
  return;
8496
- if (node.hasAttribute("data-devknobs") || hidden.has(node))
9368
+ if (isMarked(node) || hidden.has(node))
8497
9369
  return;
8498
9370
  const style = node.style;
8499
9371
  hidden.set(node, {
@@ -8524,7 +9396,7 @@ function holdModals() {
8524
9396
  const native = HTMLDialogElement.prototype.showModal;
8525
9397
  showModal = native;
8526
9398
  HTMLDialogElement.prototype.showModal = function() {
8527
- if (this.closest("[data-devknobs]"))
9399
+ if (this.closest(ownSelector()))
8528
9400
  native.call(this);
8529
9401
  else
8530
9402
  this.show();
@@ -8534,7 +9406,7 @@ function holdModals() {
8534
9406
  modals = Array.from(document.querySelectorAll("dialog:modal"));
8535
9407
  } catch {}
8536
9408
  for (const dialog of modals) {
8537
- if (dialog.closest("[data-devknobs]"))
9409
+ if (dialog.closest(ownSelector()))
8538
9410
  continue;
8539
9411
  dialog.close();
8540
9412
  dialog.show();
@@ -8878,7 +9750,7 @@ var latest2 = null;
8878
9750
  var heading = "closed";
8879
9751
  var settled = false;
8880
9752
  var pending2 = null;
8881
- var covered = false;
9753
+ var covered2 = false;
8882
9754
  var released = false;
8883
9755
  function frameWindow() {
8884
9756
  return frame3?.contentWindow ?? null;
@@ -9091,7 +9963,7 @@ function showZoom(place2) {
9091
9963
  picker.value = String(zoom);
9092
9964
  }
9093
9965
  function panelWidth() {
9094
- return document.querySelector('[data-devknobs="panel"]')?.offsetWidth ?? 0;
9966
+ return findOwn(document, "panel")?.offsetWidth ?? 0;
9095
9967
  }
9096
9968
  function asideOf(panel) {
9097
9969
  return panel.open && !panel.docked ? panelWidth() : 0;
@@ -9179,9 +10051,9 @@ function stageSize() {
9179
10051
  return { width: Math.max(0, width), height: letterbox?.clientHeight ?? 0 };
9180
10052
  }
9181
10053
  function panelSized(glide) {
9182
- const pinned = current.panel.docked;
10054
+ const pinned2 = current.panel.docked;
9183
10055
  if (!glide) {
9184
- if (!pinned)
10056
+ if (!pinned2)
9185
10057
  resize();
9186
10058
  else if (ride) {
9187
10059
  endRide();
@@ -9192,7 +10064,7 @@ function panelSized(glide) {
9192
10064
  if (following)
9193
10065
  window.cancelAnimationFrame(following);
9194
10066
  following = 0;
9195
- if (pinned)
10067
+ if (pinned2)
9196
10068
  follow4(resize);
9197
10069
  else
9198
10070
  glideFrame(screen, { first: false, from: current.panel, to: current.panel, sized: true }, resize);
@@ -9519,27 +10391,27 @@ function foldDevice2(value, held2 = false) {
9519
10391
  }
9520
10392
  function hidePage() {
9521
10393
  const body = document.body;
9522
- if (covered || !body)
10394
+ if (covered2 || !body)
9523
10395
  return;
9524
- covered = true;
10396
+ covered2 = true;
9525
10397
  cover2(body);
9526
10398
  const style = ensureStyle(NAME);
9527
- style.textContent = "html{overflow:hidden!important}:popover-open:not([data-devknobs]){display:none!important}";
10399
+ style.textContent = `html{overflow:hidden!important}:popover-open:not(${ownSelector()}){display:none!important}`;
9528
10400
  const node = styleNode(style);
9529
10401
  if (node)
9530
10402
  stopKeepingStyle = keepMounted(node, { home: () => document.head ?? document.documentElement });
9531
10403
  }
9532
10404
  function showPage() {
9533
- if (!covered)
10405
+ if (!covered2)
9534
10406
  return;
9535
- covered = false;
10407
+ covered2 = false;
9536
10408
  stopKeepingStyle?.();
9537
10409
  stopKeepingStyle = null;
9538
10410
  uncover2();
9539
10411
  removeStyle(NAME);
9540
10412
  }
9541
10413
  function remounted() {
9542
- if (covered) {
10414
+ if (covered2) {
9543
10415
  showPage();
9544
10416
  hidePage();
9545
10417
  }
@@ -9609,7 +10481,7 @@ function scene() {
9609
10481
  screenRect,
9610
10482
  fullRect,
9611
10483
  scheme: coverScheme,
9612
- covered: () => covered,
10484
+ covered: () => covered2,
9613
10485
  hidePage,
9614
10486
  painted,
9615
10487
  layout,
@@ -9649,7 +10521,7 @@ function open(veiled, first) {
9649
10521
  if (host || !needsFrame(current) || !body)
9650
10522
  return;
9651
10523
  host = document.createElement("div");
9652
- host.setAttribute("data-devknobs", "viewport");
10524
+ markOwn(host, "viewport");
9653
10525
  host.style.cssText = `position:fixed;inset:0;z-index:${Z_INDEX}`;
9654
10526
  const root = host.attachShadow({ mode: "open" });
9655
10527
  addStyle(root, VIEWPORT_CSS);
@@ -9676,9 +10548,9 @@ function open(veiled, first) {
9676
10548
  glass = document.createElement("div");
9677
10549
  glass.className = "glass";
9678
10550
  frame3 = document.createElement("iframe");
9679
- frame3.setAttribute(FRAME_ATTRIBUTE, "");
10551
+ setMark(frame3, FRAME_ATTRIBUTE);
9680
10552
  if (fresh())
9681
- frame3.setAttribute(FRESH_ATTRIBUTE, "");
10553
+ setMark(frame3, FRESH_ATTRIBUTE);
9682
10554
  frame3.name = FRAME_NAME;
9683
10555
  frame3.title = "knobs viewport";
9684
10556
  frame3.setAttribute("sandbox", SANDBOX);