@vinena/knobs 0.7.1 → 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.
- package/CHANGELOG.md +5 -0
- package/dist/{elementsview-mcg6d5zp.js → elementsview-1bar694x.js} +2 -2
- package/dist/{elementsview-mwr1s17z.js → elementsview-p2wc9b0s.js} +2 -2
- package/dist/engine/bandmedia.d.ts +119 -0
- package/dist/engine/browserui.d.ts +3 -1
- package/dist/engine/pageshot.d.ts +24 -4
- package/dist/engine/safaridraw.d.ts +24 -3
- package/dist/engine/underbar.d.ts +26 -7
- package/dist/{framekit-wyppj1se.js → framekit-n57ts9zt.js} +937 -70
- package/dist/{framekit-4v7nc3ea.js → framekit-wqp811a2.js} +937 -70
- package/dist/{index-bgzyc7rz.js → index-b8cnnbpr.js} +3 -3
- package/dist/{index-c1t6knbf.js → index-cfrnrg24.js} +3 -3
- package/dist/{index-82y8x8vv.js → index-j8hrzag1.js} +2 -2
- package/dist/{index-3s4v7gw5.js → index-pvknvvkw.js} +3 -3
- package/dist/{index-cqymjce4.js → index-qz04adp5.js} +3 -3
- package/dist/{index-a23nv5j4.js → index-t7a07nm9.js} +2 -2
- package/dist/index.global.js +183 -166
- package/dist/index.js +7 -7
- package/dist/{react-7tzwahsm.js → react-0tbd51s3.js} +2 -2
- package/dist/{react-ppyj3fg2.js → react-881wvm1z.js} +2 -2
- package/dist/{react-wzd3cfg8.js → react-pf7fc2f3.js} +3 -3
- package/dist/{react-tet7swk2.js → react-zj0dbpdg.js} +3 -3
- package/dist/react.js +7 -7
- package/dist/{storageview-2rvwk0v7.js → storageview-5tvmca8y.js} +3 -3
- package/dist/{storageview-6vq7nz02.js → storageview-ec52x60p.js} +3 -3
- package/package.json +2 -1
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
uaPreset,
|
|
83
83
|
userAgentOf,
|
|
84
84
|
viewportOf
|
|
85
|
-
} from "./index-
|
|
85
|
+
} from "./index-b8cnnbpr.js";
|
|
86
86
|
import {
|
|
87
87
|
FRAME_ATTRIBUTE,
|
|
88
88
|
FRAME_NAME,
|
|
@@ -3677,6 +3677,7 @@ function buildChrome(full, mini, look) {
|
|
|
3677
3677
|
|
|
3678
3678
|
// src/engine/safaridraw.ts
|
|
3679
3679
|
var DOMAIN_WEIGHT = 500;
|
|
3680
|
+
var DOMAIN_PAD = 0.15;
|
|
3680
3681
|
var SAFARI_CSS = `
|
|
3681
3682
|
.safari {
|
|
3682
3683
|
color: #000;
|
|
@@ -3745,14 +3746,27 @@ var SAFARI_CSS = `
|
|
|
3745
3746
|
.safari .glyph.off { stroke-opacity: 0.3; fill-opacity: 0.3; }
|
|
3746
3747
|
.safari .domain {
|
|
3747
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;
|
|
3748
3752
|
white-space: nowrap;
|
|
3749
3753
|
overflow: hidden;
|
|
3750
|
-
text-overflow: ellipsis;
|
|
3751
|
-
text-align: center;
|
|
3752
3754
|
font-size: ${SAFARI_TEXT.field}px;
|
|
3753
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;
|
|
3754
3758
|
transform: translate(-50%, -50%);
|
|
3755
|
-
|
|
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; }
|
|
3756
3770
|
.safari .time { font-weight: 600; transform: translate(-50%, -50%); }
|
|
3757
3771
|
.safari .status { fill: currentColor; }
|
|
3758
3772
|
/* The battery's uncharged rest: #b2b2b2 on white, #808080 on black. */
|
|
@@ -3777,7 +3791,10 @@ var SAFARI_CSS = `
|
|
|
3777
3791
|
transition:
|
|
3778
3792
|
top var(--main) ${MORPH.ease},
|
|
3779
3793
|
height var(--main) ${MORPH.ease},
|
|
3780
|
-
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};
|
|
3781
3798
|
}
|
|
3782
3799
|
/* The parts only the expanded bars have: an icon swap, out early, in late. */
|
|
3783
3800
|
.safari .full {
|
|
@@ -4045,19 +4062,59 @@ function pressOf(glyph, actions) {
|
|
|
4045
4062
|
return actions.reload;
|
|
4046
4063
|
return;
|
|
4047
4064
|
}
|
|
4065
|
+
var GLYPH_BOX = 30;
|
|
4048
4066
|
function glyphIn(mark, origin, className, actions) {
|
|
4049
|
-
const svg = glyphAt(mark, GLYPHS2,
|
|
4050
|
-
svg.style.left = `${mark.x - origin.x -
|
|
4051
|
-
svg.style.top = `${mark.y - origin.y -
|
|
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`;
|
|
4052
4070
|
return svg;
|
|
4053
4071
|
}
|
|
4054
4072
|
function domainOf(host) {
|
|
4055
4073
|
return host.replace(/:\d+$/, "");
|
|
4056
4074
|
}
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
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;
|
|
4061
4118
|
}
|
|
4062
4119
|
function hslOf({ red, green, blue }) {
|
|
4063
4120
|
const [r, g, b] = [red / 255, green / 255, blue / 255];
|
|
@@ -4184,14 +4241,16 @@ function buildSafari(full, mini, look, actions) {
|
|
|
4184
4241
|
const main = pill ? full.shapes.find((shape) => shape.kind === "card") ?? full.shapes.find((shape) => shape.text !== undefined) ?? null : null;
|
|
4185
4242
|
let surface = null;
|
|
4186
4243
|
let domain = null;
|
|
4244
|
+
const screen = turn(full.screen, full.orientation).width;
|
|
4245
|
+
const texts = [];
|
|
4187
4246
|
const glyphs = [];
|
|
4188
4247
|
const keep2 = (node, glyph) => {
|
|
4189
4248
|
glyphs.push({ node, glyph });
|
|
4190
4249
|
return node;
|
|
4191
4250
|
};
|
|
4251
|
+
const field = full.shapes.find((shape) => shape.kind === "field");
|
|
4192
4252
|
if (main && pill) {
|
|
4193
4253
|
surface = el("div", main.kind === "card" ? "surface from-card" : "surface");
|
|
4194
|
-
const field = full.shapes.find((shape) => shape.kind === "field");
|
|
4195
4254
|
if (field) {
|
|
4196
4255
|
const inner = el("div", "field full");
|
|
4197
4256
|
placeBox(inner, { ...field, x: field.x - main.x, y: field.y - main.y }, field.radius);
|
|
@@ -4212,7 +4271,6 @@ function buildSafari(full, mini, look, actions) {
|
|
|
4212
4271
|
}
|
|
4213
4272
|
domain = el("div", "domain");
|
|
4214
4273
|
const text = (field ?? main).text;
|
|
4215
|
-
domain.style.maxWidth = `${(field ?? main).width - 96}px`;
|
|
4216
4274
|
domain.dataset.top = String((text?.y ?? main.y) - main.y);
|
|
4217
4275
|
surface.append(domain);
|
|
4218
4276
|
const expand = actions.expand;
|
|
@@ -4248,7 +4306,7 @@ function buildSafari(full, mini, look, actions) {
|
|
|
4248
4306
|
if (shape.text) {
|
|
4249
4307
|
const text = el("div", "domain");
|
|
4250
4308
|
text.style.top = `${shape.text.y - shape.y}px`;
|
|
4251
|
-
|
|
4309
|
+
texts.push({ node: text, shape });
|
|
4252
4310
|
side.append(text);
|
|
4253
4311
|
}
|
|
4254
4312
|
root.append(side);
|
|
@@ -4267,6 +4325,12 @@ function buildSafari(full, mini, look, actions) {
|
|
|
4267
4325
|
for (const text of Array.from(root.querySelectorAll(".domain"))) {
|
|
4268
4326
|
text.textContent = domainOf(sight.host);
|
|
4269
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
|
+
}
|
|
4270
4334
|
for (const { node, box: box2 } of sides)
|
|
4271
4335
|
tintGlass(node, box2, sight);
|
|
4272
4336
|
for (const { node, glyph } of glyphs) {
|
|
@@ -4275,13 +4339,33 @@ function buildSafari(full, mini, look, actions) {
|
|
|
4275
4339
|
node.classList.toggle("press", !off && pressOf(glyph, actions) !== undefined);
|
|
4276
4340
|
}
|
|
4277
4341
|
if (surface && domain && main && pill) {
|
|
4278
|
-
const box2 = minimized ? pillBox(pill, sight.host) : main;
|
|
4342
|
+
const box2 = minimized ? pillBox(pill, sight.host, screen) : main;
|
|
4279
4343
|
placeBox(surface, box2, minimized ? pill.radius : main.radius);
|
|
4280
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`;
|
|
4281
4366
|
const top = minimized ? pill.height / 2 : Number(domain.dataset.top);
|
|
4282
4367
|
domain.style.top = `${top}px`;
|
|
4283
|
-
|
|
4284
|
-
domain.style.transform = `translate(-50%, -50%) scale(${scale})`;
|
|
4368
|
+
domain.style.transform = "translate(-50%, -50%)";
|
|
4285
4369
|
}
|
|
4286
4370
|
},
|
|
4287
4371
|
loading(on, still2) {
|
|
@@ -4763,7 +4847,8 @@ function drawMedia(pen, media, rect, style) {
|
|
|
4763
4847
|
}
|
|
4764
4848
|
if (style.imageRendering === "pixelated" || style.imageRendering === "crisp-edges")
|
|
4765
4849
|
pen.imageSmoothingEnabled = false;
|
|
4766
|
-
|
|
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);
|
|
4767
4852
|
pen.restore();
|
|
4768
4853
|
}
|
|
4769
4854
|
function picturesKey(doc) {
|
|
@@ -4991,7 +5076,19 @@ function blankPictures(live, copy) {
|
|
|
4991
5076
|
image.setAttribute("src", blankUrl(from.naturalWidth, from.naturalHeight));
|
|
4992
5077
|
});
|
|
4993
5078
|
}
|
|
4994
|
-
|
|
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) {
|
|
4995
5092
|
const doc = frame2.contentDocument;
|
|
4996
5093
|
if (!doc?.documentElement)
|
|
4997
5094
|
return null;
|
|
@@ -5031,7 +5128,7 @@ ${own.join(`
|
|
|
5031
5128
|
const inert = doc.implementation.createHTMLDocument("");
|
|
5032
5129
|
const root = inert.importNode(doc.documentElement, true);
|
|
5033
5130
|
pin(doc.documentElement, root);
|
|
5034
|
-
if (leave || pinned) {
|
|
5131
|
+
if (leave || pinned || each) {
|
|
5035
5132
|
const live = doc.documentElement.getElementsByTagName("*");
|
|
5036
5133
|
const copied = root.getElementsByTagName("*");
|
|
5037
5134
|
for (let index = 0;index < live.length; index++) {
|
|
@@ -5042,15 +5139,25 @@ ${own.join(`
|
|
|
5042
5139
|
if (leave?.(node))
|
|
5043
5140
|
markOwn(copy);
|
|
5044
5141
|
pin(node, copy);
|
|
5142
|
+
each?.(node, copy);
|
|
5045
5143
|
}
|
|
5046
5144
|
}
|
|
5047
5145
|
blankPictures(doc.documentElement, root);
|
|
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
|
+
}
|
|
5048
5153
|
for (const node of root.querySelectorAll(`script, link, style, noscript, ${ownSelector()}`))
|
|
5049
5154
|
node.remove();
|
|
5155
|
+
const quiet = inert.createElement("style");
|
|
5156
|
+
quiet.textContent = NO_CONTROLS;
|
|
5050
5157
|
const style = inert.createElement("style");
|
|
5051
5158
|
style.textContent = frozen.rules.join(`
|
|
5052
5159
|
`);
|
|
5053
|
-
(root.querySelector("head") ?? root).append(style);
|
|
5160
|
+
(root.querySelector("head") ?? root).append(style, quiet);
|
|
5054
5161
|
return root;
|
|
5055
5162
|
}
|
|
5056
5163
|
var LONE_HALF = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
|
|
@@ -5140,6 +5247,592 @@ async function paintPage(frame2, glass, size, color, copy) {
|
|
|
5140
5247
|
return canvas;
|
|
5141
5248
|
}
|
|
5142
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
|
+
|
|
5143
5836
|
// src/engine/underbar.ts
|
|
5144
5837
|
var UNDERBAR_CSS = `
|
|
5145
5838
|
.underbar {
|
|
@@ -5149,7 +5842,8 @@ var UNDERBAR_CSS = `
|
|
|
5149
5842
|
transform-origin: 0 0;
|
|
5150
5843
|
}
|
|
5151
5844
|
.underbar[hidden] { display: none; }
|
|
5152
|
-
.underbar > img
|
|
5845
|
+
.underbar > img,
|
|
5846
|
+
.underbar > canvas {
|
|
5153
5847
|
position: absolute;
|
|
5154
5848
|
left: 0;
|
|
5155
5849
|
top: 0;
|
|
@@ -5157,6 +5851,7 @@ var UNDERBAR_CSS = `
|
|
|
5157
5851
|
will-change: transform;
|
|
5158
5852
|
}
|
|
5159
5853
|
`;
|
|
5854
|
+
var LOADS = ["load", "loadeddata", "seeked", "playing"];
|
|
5160
5855
|
var GAP = 250;
|
|
5161
5856
|
var SHARE = 10;
|
|
5162
5857
|
function bandRect(page, height) {
|
|
@@ -5178,13 +5873,54 @@ var VH = /(-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)[sld]?vh\b/gi;
|
|
|
5178
5873
|
function viewportUnits(css, height) {
|
|
5179
5874
|
return css.replace(VH, (_, amount) => `${Math.round(Number(amount) * height) / 100}px`);
|
|
5180
5875
|
}
|
|
5181
|
-
function
|
|
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 = () => {}) {
|
|
5182
5907
|
const doc = frame2.contentDocument;
|
|
5183
5908
|
const view = frame2.contentWindow;
|
|
5184
5909
|
if (!doc?.documentElement || !view || view.innerWidth <= 0)
|
|
5185
5910
|
return null;
|
|
5186
5911
|
const { innerWidth: width, innerHeight: tall } = view;
|
|
5187
|
-
const
|
|
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
|
+
});
|
|
5188
5924
|
if (!copy)
|
|
5189
5925
|
return null;
|
|
5190
5926
|
for (const style of copy.querySelectorAll("style")) {
|
|
@@ -5193,14 +5929,35 @@ function pictureOf(frame2) {
|
|
|
5193
5929
|
for (const node of copy.querySelectorAll("[style]")) {
|
|
5194
5930
|
node.setAttribute("style", viewportUnits(node.getAttribute("style") ?? "", tall));
|
|
5195
5931
|
}
|
|
5196
|
-
const
|
|
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);
|
|
5197
5939
|
const root = doc.documentElement.getBoundingClientRect().height / ownZoom(doc, view);
|
|
5198
5940
|
const sized = rootSize(doc, view);
|
|
5199
5941
|
const zoom = layoutZoom(view);
|
|
5200
5942
|
const zoomed = rootZoom(doc, view, zoom);
|
|
5201
5943
|
copy.setAttribute("style", `${copy.getAttribute("style") ?? ""};${sized};height:${root}px !important${zoomed}`);
|
|
5202
5944
|
const markup = new XMLSerializer().serializeToString(copy);
|
|
5203
|
-
|
|
5945
|
+
const shows = doc.querySelector(MEDIA) !== null || /url\(\s*(?!["']?data:|"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);
|
|
5204
5961
|
}
|
|
5205
5962
|
function createUnderbar(glass, frame2) {
|
|
5206
5963
|
const band = el("div", "underbar");
|
|
@@ -5209,6 +5966,7 @@ function createUnderbar(glass, frame2) {
|
|
|
5209
5966
|
glass.append(band);
|
|
5210
5967
|
let image = null;
|
|
5211
5968
|
let picture = null;
|
|
5969
|
+
let cover = null;
|
|
5212
5970
|
let taken = "";
|
|
5213
5971
|
let watched2 = null;
|
|
5214
5972
|
let observer = null;
|
|
@@ -5218,6 +5976,68 @@ function createUnderbar(glass, frame2) {
|
|
|
5218
5976
|
let last = 0;
|
|
5219
5977
|
let cost = 0;
|
|
5220
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
|
+
};
|
|
5221
6041
|
const keyOf = () => {
|
|
5222
6042
|
try {
|
|
5223
6043
|
const doc = frame2.contentDocument;
|
|
@@ -5226,20 +6046,24 @@ function createUnderbar(glass, frame2) {
|
|
|
5226
6046
|
return null;
|
|
5227
6047
|
if (doc !== watched2) {
|
|
5228
6048
|
observer?.disconnect();
|
|
5229
|
-
const
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
6049
|
+
for (const type of LOADS)
|
|
6050
|
+
watched2?.removeEventListener(type, onLoad, true);
|
|
6051
|
+
watched2?.removeEventListener("scroll", onScroll, true);
|
|
6052
|
+
const next = new MutationObserver(again);
|
|
5233
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);
|
|
5234
6057
|
observer = next;
|
|
5235
6058
|
watched2 = doc;
|
|
5236
6059
|
changed = true;
|
|
5237
6060
|
image?.remove();
|
|
5238
6061
|
image = null;
|
|
5239
6062
|
picture = null;
|
|
6063
|
+
dropCover();
|
|
5240
6064
|
taken = "";
|
|
5241
6065
|
}
|
|
5242
|
-
return `${view.innerWidth}|${view.innerHeight}|${doc
|
|
6066
|
+
return `${view.innerWidth}|${view.innerHeight}|${heightOf(doc, view)}`;
|
|
5243
6067
|
} catch {
|
|
5244
6068
|
return null;
|
|
5245
6069
|
}
|
|
@@ -5249,10 +6073,17 @@ function createUnderbar(glass, frame2) {
|
|
|
5249
6073
|
return;
|
|
5250
6074
|
try {
|
|
5251
6075
|
const view = frame2.contentWindow;
|
|
5252
|
-
|
|
6076
|
+
const doc = frame2.contentDocument;
|
|
6077
|
+
if (!view || !doc)
|
|
5253
6078
|
return;
|
|
5254
|
-
const
|
|
6079
|
+
const scale = wide / picture.width;
|
|
6080
|
+
const scrolled = scrollOf(doc, view);
|
|
6081
|
+
const shift = bandShift(scrolled, view.innerHeight, scale);
|
|
5255
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();
|
|
5256
6087
|
} catch {}
|
|
5257
6088
|
};
|
|
5258
6089
|
const paint = async () => {
|
|
@@ -5264,6 +6095,7 @@ function createUnderbar(glass, frame2) {
|
|
|
5264
6095
|
image?.remove();
|
|
5265
6096
|
image = null;
|
|
5266
6097
|
picture = null;
|
|
6098
|
+
dropCover();
|
|
5267
6099
|
return;
|
|
5268
6100
|
}
|
|
5269
6101
|
if (!changed && key === taken)
|
|
@@ -5273,22 +6105,36 @@ function createUnderbar(glass, frame2) {
|
|
|
5273
6105
|
const start = performance.now();
|
|
5274
6106
|
let next = null;
|
|
5275
6107
|
try {
|
|
5276
|
-
next = pictureOf(frame2);
|
|
6108
|
+
next = pictureOf(frame2, bandOf(frame2.contentWindow?.innerWidth ?? 0), again);
|
|
5277
6109
|
} catch {
|
|
5278
6110
|
next = null;
|
|
5279
6111
|
}
|
|
5280
6112
|
const fresh2 = new Image;
|
|
5281
6113
|
let drawn = false;
|
|
6114
|
+
let lifted = null;
|
|
5282
6115
|
if (next) {
|
|
5283
6116
|
fresh2.src = next.src;
|
|
5284
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
|
+
}
|
|
5285
6127
|
}
|
|
5286
6128
|
cost = performance.now() - start;
|
|
5287
6129
|
last = performance.now();
|
|
5288
6130
|
performance.measure("devknobs underbar picture", { start, duration: cost });
|
|
5289
6131
|
painting = false;
|
|
5290
|
-
if (!next || !drawn)
|
|
6132
|
+
if (!next || !drawn) {
|
|
6133
|
+
if (next?.overlay)
|
|
6134
|
+
next.overlay.canvas.width = 0;
|
|
6135
|
+
spend2(lifted);
|
|
5291
6136
|
return;
|
|
6137
|
+
}
|
|
5292
6138
|
fresh2.alt = "";
|
|
5293
6139
|
if (image)
|
|
5294
6140
|
image.replaceWith(fresh2);
|
|
@@ -5296,6 +6142,16 @@ function createUnderbar(glass, frame2) {
|
|
|
5296
6142
|
band.append(fresh2);
|
|
5297
6143
|
image = fresh2;
|
|
5298
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);
|
|
5299
6155
|
taken = key;
|
|
5300
6156
|
fit();
|
|
5301
6157
|
if (changed)
|
|
@@ -5312,6 +6168,11 @@ function createUnderbar(glass, frame2) {
|
|
|
5312
6168
|
return;
|
|
5313
6169
|
image.style.width = `${wide}px`;
|
|
5314
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
|
+
}
|
|
5315
6176
|
move();
|
|
5316
6177
|
}
|
|
5317
6178
|
return {
|
|
@@ -5325,8 +6186,9 @@ function createUnderbar(glass, frame2) {
|
|
|
5325
6186
|
}
|
|
5326
6187
|
place(band, rect.x * zoom, rect.y * zoom, rect.width, rect.height);
|
|
5327
6188
|
wide = rect.width;
|
|
6189
|
+
high = rect.height;
|
|
5328
6190
|
band.style.transform = zoom === 1 ? "" : `scale(${zoom})`;
|
|
5329
|
-
band.style.background = look.background
|
|
6191
|
+
band.style.background = `linear-gradient(${look.background}, ${look.background})`;
|
|
5330
6192
|
const key = keyOf();
|
|
5331
6193
|
if (key !== taken || changed)
|
|
5332
6194
|
soon();
|
|
@@ -5341,7 +6203,12 @@ function createUnderbar(glass, frame2) {
|
|
|
5341
6203
|
clearTimeout(waiting);
|
|
5342
6204
|
observer?.disconnect();
|
|
5343
6205
|
observer = null;
|
|
6206
|
+
for (const type of LOADS)
|
|
6207
|
+
watched2?.removeEventListener(type, onLoad, true);
|
|
6208
|
+
watched2?.removeEventListener("scroll", onScroll, true);
|
|
5344
6209
|
watched2 = null;
|
|
6210
|
+
dropCover();
|
|
6211
|
+
forgetPixels();
|
|
5345
6212
|
band.remove();
|
|
5346
6213
|
}
|
|
5347
6214
|
};
|
|
@@ -5948,11 +6815,11 @@ function fit(knobs2, size, options = {}) {
|
|
|
5948
6815
|
const whole = Math.min(sized && tall ? ZOOM_MAX : 1, across, tall ? upright : 1);
|
|
5949
6816
|
const height = typeof knobs2.height === "number" ? knobs2.height : room.height / whole;
|
|
5950
6817
|
const outer = { width: width + sides.width, height: height + sides.height };
|
|
5951
|
-
const
|
|
5952
|
-
const loose =
|
|
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;
|
|
5953
6820
|
const fitted = mock === BARE ? loose : snapScale(loose, height, ratio);
|
|
5954
6821
|
const scale = knobs2.zoom === "fit" ? fitted : knobs2.zoom;
|
|
5955
|
-
const beside = knobs2.zoom === "fit" &&
|
|
6822
|
+
const beside = knobs2.zoom === "fit" && covered2 ? aside : 0;
|
|
5956
6823
|
const before = side === "left" ? beside : 0;
|
|
5957
6824
|
return {
|
|
5958
6825
|
width,
|
|
@@ -6274,7 +7141,7 @@ function hingeLine(pane, across, part) {
|
|
|
6274
7141
|
return pane === "inner" ? [-1 / width, 0, (x + width) / width] : [1 / width, 0, -x / width];
|
|
6275
7142
|
return pane === "inner" ? [0, 1 / height, -y / height] : [0, -1 / height, (y + height) / height];
|
|
6276
7143
|
}
|
|
6277
|
-
function
|
|
7144
|
+
function contextOf2(canvas) {
|
|
6278
7145
|
if (typeof WebGL2RenderingContext === "undefined")
|
|
6279
7146
|
return null;
|
|
6280
7147
|
const gl = canvas.getContext("webgl2", {
|
|
@@ -6392,11 +7259,11 @@ function uploadWhy(error) {
|
|
|
6392
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";
|
|
6393
7260
|
return `the picture could not be uploaded: ${name}${name === "SecurityError" ? `, ${tainted}` : ""}`;
|
|
6394
7261
|
}
|
|
6395
|
-
function screenGl(place2,
|
|
7262
|
+
function screenGl(place2, refused2) {
|
|
6396
7263
|
const canvas = document.createElement("canvas");
|
|
6397
|
-
const gl =
|
|
7264
|
+
const gl = contextOf2(canvas);
|
|
6398
7265
|
if (!gl) {
|
|
6399
|
-
|
|
7266
|
+
refused2(typeof WebGL2RenderingContext === "undefined" ? "this browser has no WebGL2" : "the canvas gave no WebGL2 context", null);
|
|
6400
7267
|
return null;
|
|
6401
7268
|
}
|
|
6402
7269
|
const rect = canvasRect(place2);
|
|
@@ -6427,7 +7294,7 @@ function screenGl(place2, refused) {
|
|
|
6427
7294
|
if (!vertex2 || !fragment || !program || !corners || !texture) {
|
|
6428
7295
|
const why = gl.isContextLost() ? "the WebGL2 context was lost as it was made" : "WebGL2 made no shader, program, buffer or texture";
|
|
6429
7296
|
free();
|
|
6430
|
-
|
|
7297
|
+
refused2(why, null);
|
|
6431
7298
|
return null;
|
|
6432
7299
|
}
|
|
6433
7300
|
gl.attachShader(program, vertex2);
|
|
@@ -6437,7 +7304,7 @@ function screenGl(place2, refused) {
|
|
|
6437
7304
|
const log = [vertex2, fragment].map((shader) => gl.getShaderInfoLog(shader)).find((said) => said?.trim()) ?? gl.getProgramInfoLog(program);
|
|
6438
7305
|
const lost = gl.isContextLost();
|
|
6439
7306
|
free();
|
|
6440
|
-
|
|
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);
|
|
6441
7308
|
return null;
|
|
6442
7309
|
}
|
|
6443
7310
|
gl.useProgram(program);
|
|
@@ -6489,31 +7356,31 @@ function screenGl(place2, refused) {
|
|
|
6489
7356
|
return;
|
|
6490
7357
|
gone = true;
|
|
6491
7358
|
canvas.remove();
|
|
6492
|
-
|
|
7359
|
+
refused2("the WebGL2 context was lost", shot);
|
|
6493
7360
|
});
|
|
6494
|
-
const
|
|
7361
|
+
const refuse2 = (why, next) => {
|
|
6495
7362
|
if (!gone)
|
|
6496
7363
|
free();
|
|
6497
7364
|
gone = true;
|
|
6498
|
-
|
|
7365
|
+
refused2(why, next);
|
|
6499
7366
|
};
|
|
6500
7367
|
return {
|
|
6501
7368
|
canvas,
|
|
6502
7369
|
paint(next) {
|
|
6503
7370
|
if (gone)
|
|
6504
|
-
return
|
|
7371
|
+
return refuse2("the WebGL2 context is gone", next);
|
|
6505
7372
|
if (Math.max(next.width, next.height) > widest) {
|
|
6506
|
-
return
|
|
7373
|
+
return refuse2(`the picture, ${next.width} by ${next.height} px, is larger than MAX_TEXTURE_SIZE, ${widest}`, next);
|
|
6507
7374
|
}
|
|
6508
7375
|
gl.getError();
|
|
6509
7376
|
try {
|
|
6510
7377
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, next);
|
|
6511
7378
|
} catch (error) {
|
|
6512
|
-
return
|
|
7379
|
+
return refuse2(uploadWhy(error), next);
|
|
6513
7380
|
}
|
|
6514
7381
|
const failed = gl.getError();
|
|
6515
7382
|
if (failed !== gl.NO_ERROR)
|
|
6516
|
-
return
|
|
7383
|
+
return refuse2(`the picture could not be uploaded: WebGL2 error 0x${failed.toString(16)}`, next);
|
|
6517
7384
|
gl.generateMipmap(gl.TEXTURE_2D);
|
|
6518
7385
|
shot = next;
|
|
6519
7386
|
if (look)
|
|
@@ -6531,7 +7398,7 @@ function screenGl(place2, refused) {
|
|
|
6531
7398
|
|
|
6532
7399
|
// src/engine/barshot.ts
|
|
6533
7400
|
var GLASS = "blur(10px) saturate(1.8)";
|
|
6534
|
-
var
|
|
7401
|
+
var REACH2 = 30;
|
|
6535
7402
|
var STILL_CSS = `
|
|
6536
7403
|
.browser { transform: none !important; }
|
|
6537
7404
|
.browser, .browser * {
|
|
@@ -6553,7 +7420,7 @@ function glassOf(bars, host) {
|
|
|
6553
7420
|
return bars.shapes.filter((shape) => shape.kind !== "field").map(({ x, y, width, height, radius }) => ({ rect: { x, y, width, height }, radius }));
|
|
6554
7421
|
}
|
|
6555
7422
|
const pill = bars.shapes.find((shape) => shape.kind === "pill");
|
|
6556
|
-
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 }] : [];
|
|
6557
7424
|
}
|
|
6558
7425
|
function copyBars(shown2, value, size) {
|
|
6559
7426
|
const minimized = shown2.querySelector("[data-state]")?.getAttribute("data-state") === "min";
|
|
@@ -6591,8 +7458,8 @@ async function paintBars(shot, bars) {
|
|
|
6591
7458
|
pen.roundRect(rect.x, rect.y, rect.width, rect.height, radius);
|
|
6592
7459
|
pen.clip();
|
|
6593
7460
|
pen.filter = GLASS;
|
|
6594
|
-
const [x, y] = [rect.x -
|
|
6595
|
-
const [width, height] = [rect.width + 2 *
|
|
7461
|
+
const [x, y] = [rect.x - REACH2, rect.y - REACH2];
|
|
7462
|
+
const [width, height] = [rect.width + 2 * REACH2, rect.height + 2 * REACH2];
|
|
6596
7463
|
pen.drawImage(under, x * scale, y * scale, width * scale, height * scale, x, y, width, height);
|
|
6597
7464
|
pen.restore();
|
|
6598
7465
|
}
|
|
@@ -6969,12 +7836,12 @@ function pick(turning, open) {
|
|
|
6969
7836
|
const { at } = shownAt(shots2, ready, open);
|
|
6970
7837
|
const next = at === null ? null : shots2.frames[at];
|
|
6971
7838
|
const bitmap = at === null ? null : ready[at];
|
|
6972
|
-
const
|
|
7839
|
+
const kept4 = next && shots2.stills[next.still];
|
|
6973
7840
|
const keptBitmap = next && found?.stills[next.still];
|
|
6974
7841
|
if (next && bitmap && next !== plane.shot)
|
|
6975
7842
|
drawOn(plane, next, bitmap, shots2.scale);
|
|
6976
|
-
if (
|
|
6977
|
-
drawOn(turning.still,
|
|
7843
|
+
if (kept4 && keptBitmap && kept4 !== turning.still.shot)
|
|
7844
|
+
drawOn(turning.still, kept4, keptBitmap, shots2.scale);
|
|
6978
7845
|
return plane.shot ? shotOpen(plane.shot) : open;
|
|
6979
7846
|
}
|
|
6980
7847
|
function pose(turning, layout, open, shown2, still2) {
|
|
@@ -8883,7 +9750,7 @@ var latest2 = null;
|
|
|
8883
9750
|
var heading = "closed";
|
|
8884
9751
|
var settled = false;
|
|
8885
9752
|
var pending2 = null;
|
|
8886
|
-
var
|
|
9753
|
+
var covered2 = false;
|
|
8887
9754
|
var released = false;
|
|
8888
9755
|
function frameWindow() {
|
|
8889
9756
|
return frame3?.contentWindow ?? null;
|
|
@@ -9184,9 +10051,9 @@ function stageSize() {
|
|
|
9184
10051
|
return { width: Math.max(0, width), height: letterbox?.clientHeight ?? 0 };
|
|
9185
10052
|
}
|
|
9186
10053
|
function panelSized(glide) {
|
|
9187
|
-
const
|
|
10054
|
+
const pinned2 = current.panel.docked;
|
|
9188
10055
|
if (!glide) {
|
|
9189
|
-
if (!
|
|
10056
|
+
if (!pinned2)
|
|
9190
10057
|
resize();
|
|
9191
10058
|
else if (ride) {
|
|
9192
10059
|
endRide();
|
|
@@ -9197,7 +10064,7 @@ function panelSized(glide) {
|
|
|
9197
10064
|
if (following)
|
|
9198
10065
|
window.cancelAnimationFrame(following);
|
|
9199
10066
|
following = 0;
|
|
9200
|
-
if (
|
|
10067
|
+
if (pinned2)
|
|
9201
10068
|
follow4(resize);
|
|
9202
10069
|
else
|
|
9203
10070
|
glideFrame(screen, { first: false, from: current.panel, to: current.panel, sized: true }, resize);
|
|
@@ -9524,9 +10391,9 @@ function foldDevice2(value, held2 = false) {
|
|
|
9524
10391
|
}
|
|
9525
10392
|
function hidePage() {
|
|
9526
10393
|
const body = document.body;
|
|
9527
|
-
if (
|
|
10394
|
+
if (covered2 || !body)
|
|
9528
10395
|
return;
|
|
9529
|
-
|
|
10396
|
+
covered2 = true;
|
|
9530
10397
|
cover2(body);
|
|
9531
10398
|
const style = ensureStyle(NAME);
|
|
9532
10399
|
style.textContent = `html{overflow:hidden!important}:popover-open:not(${ownSelector()}){display:none!important}`;
|
|
@@ -9535,16 +10402,16 @@ function hidePage() {
|
|
|
9535
10402
|
stopKeepingStyle = keepMounted(node, { home: () => document.head ?? document.documentElement });
|
|
9536
10403
|
}
|
|
9537
10404
|
function showPage() {
|
|
9538
|
-
if (!
|
|
10405
|
+
if (!covered2)
|
|
9539
10406
|
return;
|
|
9540
|
-
|
|
10407
|
+
covered2 = false;
|
|
9541
10408
|
stopKeepingStyle?.();
|
|
9542
10409
|
stopKeepingStyle = null;
|
|
9543
10410
|
uncover2();
|
|
9544
10411
|
removeStyle(NAME);
|
|
9545
10412
|
}
|
|
9546
10413
|
function remounted() {
|
|
9547
|
-
if (
|
|
10414
|
+
if (covered2) {
|
|
9548
10415
|
showPage();
|
|
9549
10416
|
hidePage();
|
|
9550
10417
|
}
|
|
@@ -9614,7 +10481,7 @@ function scene() {
|
|
|
9614
10481
|
screenRect,
|
|
9615
10482
|
fullRect,
|
|
9616
10483
|
scheme: coverScheme,
|
|
9617
|
-
covered: () =>
|
|
10484
|
+
covered: () => covered2,
|
|
9618
10485
|
hidePage,
|
|
9619
10486
|
painted,
|
|
9620
10487
|
layout,
|