@vinena/knobs 0.5.2 → 0.5.3
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 +12 -0
- package/dist/early.global.js +5 -5
- package/dist/{elementsview-qn8qyksa.js → elementsview-1wsxcdtj.js} +4 -4
- package/dist/{elementsview-2z4pkrdz.js → elementsview-3kv34jfx.js} +4 -4
- package/dist/engine/browserdraw.d.ts +5 -0
- package/dist/engine/browserkit.d.ts +2 -0
- package/dist/engine/devices.d.ts +3 -2
- package/dist/engine/frames.d.ts +1 -0
- package/dist/engine/identity.d.ts +5 -1
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/mock.d.ts +0 -2
- package/dist/engine/mockdata.d.ts +4 -3
- package/dist/engine/mockdraw.d.ts +2 -14
- package/dist/engine/morphrun.d.ts +4 -0
- package/dist/engine/native.d.ts +31 -3
- package/dist/engine/notice.d.ts +1 -2
- package/dist/engine/width.d.ts +3 -0
- package/dist/{framekit-w0v516w5.js → framekit-cjz0e4y8.js} +213 -61
- package/dist/{framekit-te90cjs0.js → framekit-yk1jxjv7.js} +213 -61
- package/dist/{index-sxe5079a.js → index-6wbgqkdz.js} +24 -5
- package/dist/{index-dan2kpsd.js → index-9jhatmky.js} +4 -4
- package/dist/{index-30fc6php.js → index-begsqdm0.js} +1 -1
- package/dist/{index-pewcdh28.js → index-j1h13ahg.js} +1 -1
- package/dist/{index-xjhwp5cj.js → index-p57fdttx.js} +38 -23
- package/dist/{index-9re7sv56.js → index-prjpx67p.js} +5 -5
- package/dist/{index-r72tz2vn.js → index-q73py563.js} +1 -1
- package/dist/{index-hv02xka3.js → index-sn2y6j09.js} +5 -5
- package/dist/{index-agwr37gw.js → index-vgfn2n1h.js} +1 -1
- package/dist/{index-trx7bxdk.js → index-zt3rheck.js} +4 -4
- package/dist/index.global.js +183 -154
- package/dist/index.js +39 -13
- package/dist/{react-ayg1bgw3.js → react-3rhdj2k1.js} +24 -5
- package/dist/{react-fm9y8dbn.js → react-6tss0r9f.js} +38 -23
- package/dist/{react-sw8d8c94.js → react-7vjfsh40.js} +4 -4
- package/dist/{react-zy1mmhgz.js → react-806qmkyz.js} +4 -4
- package/dist/{react-4pvp6amm.js → react-gefkdkdz.js} +1 -1
- package/dist/{react-16spgn0h.js → react-mmq2zya3.js} +1 -1
- package/dist/{react-exjcpxma.js → react-qfpg79hs.js} +1 -1
- package/dist/{react-05jh9jv5.js → react-qgz9afa2.js} +1 -1
- package/dist/react.js +39 -13
- package/dist/{storageview-s7heg93p.js → storageview-7cv0vpdm.js} +4 -4
- package/dist/{storageview-r595qpt9.js → storageview-dyhpgt8f.js} +4 -4
- package/dist/types.d.ts +7 -0
- package/dist/ui/settings.d.ts +8 -0
- package/package.json +1 -1
package/dist/engine/notice.d.ts
CHANGED
|
@@ -8,8 +8,7 @@ import type { FrameRefusal } from "./native";
|
|
|
8
8
|
export declare function createNotice(close: () => void): HTMLElement;
|
|
9
9
|
/**
|
|
10
10
|
* Say why under the notice, as a host told it, with a button for its details
|
|
11
|
-
* and one to find out more, which runs the host's `retry` and then `again
|
|
12
|
-
* at once where the host says so.
|
|
11
|
+
* and one to find out more, which runs the host's `retry` and then `again`.
|
|
13
12
|
* Null takes it away.
|
|
14
13
|
*/
|
|
15
14
|
export declare function explain(box: HTMLElement, refusal: FrameRefusal | null, again: () => void): void;
|
package/dist/engine/width.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export declare const RIDE_SLOW = 50;
|
|
|
19
19
|
* an app may not mount devknobs in the frame at all.
|
|
20
20
|
*/
|
|
21
21
|
export declare const FRAME_API_WAIT = 1500;
|
|
22
|
+
/** The longest the cover stays up, in ms: past it, the frame shows whatever it has. */
|
|
23
|
+
export declare const COVER_CAP: number;
|
|
22
24
|
/** The window inside the frame, while there is one. */
|
|
23
25
|
export declare function frameWindow(): Window | null;
|
|
24
26
|
/** Keep the knobs and hand them to the frame, which applies them to its own page. */
|
|
@@ -26,6 +28,7 @@ export declare function sync(state: DevknobsState): void;
|
|
|
26
28
|
export declare function onExit(handler: (() => void) | null): void;
|
|
27
29
|
export declare function onRefused(handler: ((url: string) => Promise<FrameRefusal | null>) | null): void;
|
|
28
30
|
export declare function onFramed(handler: ((open: boolean) => void | Promise<void>) | null): void;
|
|
31
|
+
export declare function onLoader(handler: ((frame: HTMLIFrameElement, url: string) => boolean) | null): void;
|
|
29
32
|
export declare function onZoom(handler: ((zoom: ZoomValue) => void) | null): void;
|
|
30
33
|
/**
|
|
31
34
|
* The panel changed its width, and with `glide` it glides to it. A floating
|
|
@@ -29,12 +29,12 @@ import {
|
|
|
29
29
|
turnOf,
|
|
30
30
|
turnedPose,
|
|
31
31
|
windowRect
|
|
32
|
-
} from "./react-
|
|
32
|
+
} from "./react-qfpg79hs.js";
|
|
33
33
|
import {
|
|
34
34
|
hush,
|
|
35
35
|
hushOnce,
|
|
36
36
|
quietFetch
|
|
37
|
-
} from "./react-
|
|
37
|
+
} from "./react-gefkdkdz.js";
|
|
38
38
|
import {
|
|
39
39
|
copyText
|
|
40
40
|
} from "./react-h9w04skh.js";
|
|
@@ -119,7 +119,7 @@ import {
|
|
|
119
119
|
userAgentOf,
|
|
120
120
|
viewportOf,
|
|
121
121
|
wheelZoom
|
|
122
|
-
} from "./react-
|
|
122
|
+
} from "./react-6tss0r9f.js";
|
|
123
123
|
|
|
124
124
|
// src/engine/width.ts
|
|
125
125
|
var exports_width = {};
|
|
@@ -131,6 +131,7 @@ __export(exports_width, {
|
|
|
131
131
|
origin: () => origin,
|
|
132
132
|
onZoom: () => onZoom,
|
|
133
133
|
onRefused: () => onRefused,
|
|
134
|
+
onLoader: () => onLoader,
|
|
134
135
|
onFramed: () => onFramed,
|
|
135
136
|
onExit: () => onExit,
|
|
136
137
|
label: () => label,
|
|
@@ -141,16 +142,17 @@ __export(exports_width, {
|
|
|
141
142
|
apply: () => apply3,
|
|
142
143
|
STRIP: () => STRIP,
|
|
143
144
|
RIDE_SLOW: () => RIDE_SLOW,
|
|
144
|
-
FRAME_API_WAIT: () => FRAME_API_WAIT
|
|
145
|
+
FRAME_API_WAIT: () => FRAME_API_WAIT,
|
|
146
|
+
COVER_CAP: () => COVER_CAP
|
|
145
147
|
});
|
|
146
148
|
|
|
147
149
|
// src/engine/identity.ts
|
|
148
150
|
function identityOf(state) {
|
|
149
151
|
const agent = uaPreset(state.ua.preset) ? state.ua.preset : userAgentOf(state.ua);
|
|
150
|
-
return { agent, touch: hasTouch(state.device), dpr: state.dpr };
|
|
152
|
+
return { agent, touch: hasTouch(state.device), dpr: state.dpr, ...state.panel?.realPhone ? { served: true } : {} };
|
|
151
153
|
}
|
|
152
154
|
function stale(loaded, next) {
|
|
153
|
-
return loaded !== null && (loaded.agent !== next.agent || loaded.touch !== next.touch || loaded.dpr !== next.dpr);
|
|
155
|
+
return loaded !== null && (loaded.agent !== next.agent || loaded.touch !== next.touch || loaded.dpr !== next.dpr || (loaded.served ?? false) !== (next.served ?? false));
|
|
154
156
|
}
|
|
155
157
|
var PATCHED = Symbol.for("devknobs.identity");
|
|
156
158
|
function isIdentity(value) {
|
|
@@ -3191,7 +3193,6 @@ function bezelMock(id, orientation) {
|
|
|
3191
3193
|
inset: sides,
|
|
3192
3194
|
body: { x: 0, y: 0, ...size },
|
|
3193
3195
|
screenRadius: turned ? turnRadius(bezel.radius, clockwise) : bezel.radius,
|
|
3194
|
-
continuous: island !== null,
|
|
3195
3196
|
bodyRadius: 0,
|
|
3196
3197
|
parts,
|
|
3197
3198
|
image: {
|
|
@@ -5301,6 +5302,7 @@ function readLook(frame2, probe = null) {
|
|
|
5301
5302
|
background: white,
|
|
5302
5303
|
top: white,
|
|
5303
5304
|
bottom: white,
|
|
5305
|
+
header: false,
|
|
5304
5306
|
footer: false,
|
|
5305
5307
|
under: [],
|
|
5306
5308
|
dark: false,
|
|
@@ -5318,7 +5320,8 @@ function readLook(frame2, probe = null) {
|
|
|
5318
5320
|
const base = backgroundOf(doc, view, scheme === "dark");
|
|
5319
5321
|
const [r, g, b] = base;
|
|
5320
5322
|
const background = rgbText(base);
|
|
5321
|
-
const
|
|
5323
|
+
const header = edgeBar(doc, view, "top", base);
|
|
5324
|
+
const top = header ?? background;
|
|
5322
5325
|
const last = () => colorAt(doc, view, view.innerWidth / 2, view.innerHeight - 1, base);
|
|
5323
5326
|
const footer = edgeBar(doc, view, "bottom", base);
|
|
5324
5327
|
const bottom = footer ?? last() ?? background;
|
|
@@ -5343,6 +5346,7 @@ function readLook(frame2, probe = null) {
|
|
|
5343
5346
|
background,
|
|
5344
5347
|
top,
|
|
5345
5348
|
bottom,
|
|
5349
|
+
header: header !== null,
|
|
5346
5350
|
footer: footer !== null,
|
|
5347
5351
|
under,
|
|
5348
5352
|
dark: luminance(r, g, b) < 0.4,
|
|
@@ -5393,6 +5397,12 @@ function createBrowser(glass, frame2, onChange, onReload = () => {}, ready = ()
|
|
|
5393
5397
|
const band = createUnderbar(glass, frame2);
|
|
5394
5398
|
const layer = el("div", "browser");
|
|
5395
5399
|
layer.setAttribute("aria-hidden", "true");
|
|
5400
|
+
const seams = [el("div", "seam"), el("div", "seam")];
|
|
5401
|
+
for (const seam of seams) {
|
|
5402
|
+
seam.setAttribute("aria-hidden", "true");
|
|
5403
|
+
seam.style.cssText = "position:absolute;pointer-events:none";
|
|
5404
|
+
seam.hidden = true;
|
|
5405
|
+
}
|
|
5396
5406
|
let view = null;
|
|
5397
5407
|
let look = null;
|
|
5398
5408
|
let painted = null;
|
|
@@ -5437,6 +5447,25 @@ function createBrowser(glass, frame2, onChange, onReload = () => {}, ready = ()
|
|
|
5437
5447
|
const bars = view?.bars ?? null;
|
|
5438
5448
|
const shown2 = view && showsBand(bars, look) && reaches(frame2) ? bandRect(applied, view.size.height) : null;
|
|
5439
5449
|
band.show(shown2, view?.zoom ?? 1, look);
|
|
5450
|
+
placeSeams();
|
|
5451
|
+
};
|
|
5452
|
+
const placeSeams = () => {
|
|
5453
|
+
const ratio = glass.offsetWidth > 0 ? glass.getBoundingClientRect().width / glass.offsetWidth : 1;
|
|
5454
|
+
const unit = 1 / ((window.devicePixelRatio || 1) * (ratio || 1));
|
|
5455
|
+
const rects = look && reaches(frame2) ? seamRects(applied, view?.zoom ?? 1, unit, look) : { top: null, bottom: null };
|
|
5456
|
+
const colors = [look?.top ?? "", look?.bottom ?? ""];
|
|
5457
|
+
[rects.top, rects.bottom].forEach((rect, index) => {
|
|
5458
|
+
const seam = seams[index];
|
|
5459
|
+
if (!seam)
|
|
5460
|
+
return;
|
|
5461
|
+
seam.hidden = rect === null;
|
|
5462
|
+
if (!rect)
|
|
5463
|
+
return;
|
|
5464
|
+
if (!seam.isConnected)
|
|
5465
|
+
glass.insertBefore(seam, layer.isConnected ? layer : null);
|
|
5466
|
+
place(seam, rect.x, rect.y, rect.width, rect.height);
|
|
5467
|
+
seam.style.background = colors[index] ?? "";
|
|
5468
|
+
});
|
|
5440
5469
|
};
|
|
5441
5470
|
const resample = () => {
|
|
5442
5471
|
sampling = 0;
|
|
@@ -5654,6 +5683,9 @@ function createBrowser(glass, frame2, onChange, onReload = () => {}, ready = ()
|
|
|
5654
5683
|
view = next;
|
|
5655
5684
|
if (next.bars && !layer.isConnected)
|
|
5656
5685
|
glass.append(layer);
|
|
5686
|
+
for (const seam of seams)
|
|
5687
|
+
if (seam.isConnected)
|
|
5688
|
+
glass.insertBefore(seam, layer.isConnected ? layer : null);
|
|
5657
5689
|
if (!next.bars)
|
|
5658
5690
|
layer.remove();
|
|
5659
5691
|
place(layer, 0, 0, next.size.width, next.size.height);
|
|
@@ -5694,12 +5726,25 @@ function createBrowser(glass, frame2, onChange, onReload = () => {}, ready = ()
|
|
|
5694
5726
|
query = null;
|
|
5695
5727
|
watched2 = null;
|
|
5696
5728
|
layer.remove();
|
|
5729
|
+
for (const seam of seams)
|
|
5730
|
+
seam.remove();
|
|
5697
5731
|
blank.remove();
|
|
5698
5732
|
band.remove();
|
|
5699
5733
|
}
|
|
5700
5734
|
};
|
|
5701
5735
|
return browser;
|
|
5702
5736
|
}
|
|
5737
|
+
function seamRects(page, zoom, unit, look) {
|
|
5738
|
+
if (!page)
|
|
5739
|
+
return { top: null, bottom: null };
|
|
5740
|
+
const x = page.x * zoom;
|
|
5741
|
+
const width = page.width * zoom;
|
|
5742
|
+
const edge = (y) => ({ x, y: y - 2 * unit, width, height: 4 * unit });
|
|
5743
|
+
return {
|
|
5744
|
+
top: look.header ? edge(page.y * zoom) : null,
|
|
5745
|
+
bottom: look.footer ? edge((page.y + page.height) * zoom) : null
|
|
5746
|
+
};
|
|
5747
|
+
}
|
|
5703
5748
|
|
|
5704
5749
|
// src/engine/fit.ts
|
|
5705
5750
|
var STRIP_TOP = 8;
|
|
@@ -6384,7 +6429,6 @@ var EDGE = "#48484a";
|
|
|
6384
6429
|
var RIM2 = "#2a2a2c";
|
|
6385
6430
|
var BAND = 2.5;
|
|
6386
6431
|
var UNDER = 2;
|
|
6387
|
-
var CONTINUOUS = { extent: 1.363, shape: 1.52 };
|
|
6388
6432
|
var MOCK_CSS = `
|
|
6389
6433
|
/* Clips the frame to the screen's corners in a mock, in the body's color so
|
|
6390
6434
|
no blue shows at the seam. */
|
|
@@ -6393,14 +6437,6 @@ var MOCK_CSS = `
|
|
|
6393
6437
|
overflow: hidden;
|
|
6394
6438
|
background: ${BODY};
|
|
6395
6439
|
}
|
|
6396
|
-
/* A phone with an island: its continuous corners where the browser draws
|
|
6397
|
-
them, over the round radius set on it, which the mat still reads. */
|
|
6398
|
-
@supports (corner-shape: superellipse(2)) {
|
|
6399
|
-
.glass.continuous {
|
|
6400
|
-
border-radius: var(--continuous) !important;
|
|
6401
|
-
corner-shape: superellipse(${CONTINUOUS.shape});
|
|
6402
|
-
}
|
|
6403
|
-
}
|
|
6404
6440
|
/* Over the frame, and never in the way of a pointer. */
|
|
6405
6441
|
.mock {
|
|
6406
6442
|
position: absolute;
|
|
@@ -6432,28 +6468,6 @@ function roundRect(rect, radius) {
|
|
|
6432
6468
|
`V${y + a}${arc2(a)} ${x + a} ${y}Z`
|
|
6433
6469
|
].join("");
|
|
6434
6470
|
}
|
|
6435
|
-
function continuousRect(rect, radius) {
|
|
6436
|
-
const { x, y, width, height } = rect;
|
|
6437
|
-
const power = 2 / 2 ** CONTINUOUS.shape;
|
|
6438
|
-
const most = Math.min(width, height) / 2;
|
|
6439
|
-
const lengths = corners(radius).map((r) => Math.max(0, Math.min(r * CONTINUOUS.extent, most)));
|
|
6440
|
-
const ends = [
|
|
6441
|
-
[x, y, 1, 1],
|
|
6442
|
-
[x + width, y, -1, 1],
|
|
6443
|
-
[x + width, y + height, -1, -1],
|
|
6444
|
-
[x, y + height, 1, -1]
|
|
6445
|
-
];
|
|
6446
|
-
const points = ends.flatMap(([cx, cy, sx, sy], at) => {
|
|
6447
|
-
const length = lengths[at] ?? 0;
|
|
6448
|
-
return Array.from({ length: 17 }, (_, step) => {
|
|
6449
|
-
const t = (at % 2 === 0 ? step : 16 - step) / 16 * (Math.PI / 2);
|
|
6450
|
-
const px = cx + sx * length * (1 - Math.cos(t) ** power);
|
|
6451
|
-
const py = cy + sy * length * (1 - Math.sin(t) ** power);
|
|
6452
|
-
return `${px.toFixed(2)} ${py.toFixed(2)}`;
|
|
6453
|
-
});
|
|
6454
|
-
});
|
|
6455
|
-
return `M${points.join("L")}Z`;
|
|
6456
|
-
}
|
|
6457
6471
|
function drawMock(mock, screenSize, href) {
|
|
6458
6472
|
const svg = svgNode("svg", {
|
|
6459
6473
|
class: "mock",
|
|
@@ -6480,10 +6494,9 @@ function drawMock(mock, screenSize, href) {
|
|
|
6480
6494
|
}
|
|
6481
6495
|
const opening = { x: mock.inset.left, y: mock.inset.top, ...screenSize };
|
|
6482
6496
|
const { x, y, width, height } = mock.body;
|
|
6483
|
-
const screen = mock.continuous ? continuousRect : roundRect;
|
|
6484
6497
|
const front = { x: x + BAND, y: y + BAND, width: width - 2 * BAND, height: height - 2 * BAND };
|
|
6485
6498
|
const inside = roundRect(front, corners(mock.bodyRadius, -BAND));
|
|
6486
|
-
svg.append(...mock.parts.filter((shape) => shape.kind === "button").map(part), svgNode("path", { class: "band", d: roundRect(mock.body, mock.bodyRadius) + inside }), svgNode("path", { class: "body", d: inside +
|
|
6499
|
+
svg.append(...mock.parts.filter((shape) => shape.kind === "button").map(part), svgNode("path", { class: "band", d: roundRect(mock.body, mock.bodyRadius) + inside }), svgNode("path", { class: "body", d: inside + roundRect(opening, mock.screenRadius) }), ...mock.parts.filter((shape) => shape.kind !== "button").map(part));
|
|
6487
6500
|
return svg;
|
|
6488
6501
|
}
|
|
6489
6502
|
|
|
@@ -7616,12 +7629,22 @@ function clear3(color) {
|
|
|
7616
7629
|
return color === "" || color === "transparent" || /[,/]\s*0\)$/.test(color);
|
|
7617
7630
|
}
|
|
7618
7631
|
function paintVeil(veil) {
|
|
7632
|
+
veil.className = "veil";
|
|
7619
7633
|
const root = getComputedStyle(document.documentElement);
|
|
7620
7634
|
const body = document.body ? getComputedStyle(document.body).backgroundColor : "";
|
|
7621
7635
|
const color = [root.backgroundColor, body].find((value) => !clear3(value));
|
|
7622
7636
|
veil.style.background = color ?? "Canvas";
|
|
7623
7637
|
veil.style.colorScheme = root.colorScheme || "normal";
|
|
7624
7638
|
}
|
|
7639
|
+
function paintCover(scene) {
|
|
7640
|
+
scene.veil.className = "veil loading";
|
|
7641
|
+
scene.veil.style.background = "";
|
|
7642
|
+
scene.veil.style.colorScheme = scene.scheme();
|
|
7643
|
+
}
|
|
7644
|
+
function evenHole(hole) {
|
|
7645
|
+
const round3 = Math.max(...hole.radius);
|
|
7646
|
+
return { ...hole, radius: [round3, round3, round3, round3] };
|
|
7647
|
+
}
|
|
7625
7648
|
function openVeiled(scene, share) {
|
|
7626
7649
|
seen = { veil: share, content: 0, hole: scene.fullRect() };
|
|
7627
7650
|
paintVeil(scene.veil);
|
|
@@ -7703,6 +7726,8 @@ function moveHole(scene, to, time) {
|
|
|
7703
7726
|
}
|
|
7704
7727
|
function placeHole(scene, hole) {
|
|
7705
7728
|
seen.hole = hole;
|
|
7729
|
+
scene.veil.style.setProperty("--dot-x", `${hole.x + hole.width / 2}px`);
|
|
7730
|
+
scene.veil.style.setProperty("--dot-y", `${hole.y + hole.height / 2}px`);
|
|
7706
7731
|
const path3 = holePath(hole);
|
|
7707
7732
|
if (path3 === cut2)
|
|
7708
7733
|
return;
|
|
@@ -7714,7 +7739,7 @@ function track2(scene) {
|
|
|
7714
7739
|
const step = () => {
|
|
7715
7740
|
if (tracking !== frame2)
|
|
7716
7741
|
return;
|
|
7717
|
-
placeHole(scene, scene.screenRect());
|
|
7742
|
+
placeHole(scene, evenHole(scene.screenRect()));
|
|
7718
7743
|
frame2 = window.requestAnimationFrame(step);
|
|
7719
7744
|
tracking = frame2;
|
|
7720
7745
|
};
|
|
@@ -7764,7 +7789,7 @@ async function perform(scene, step, target, instant) {
|
|
|
7764
7789
|
} else if (step.kind === "layout") {
|
|
7765
7790
|
scene.layout();
|
|
7766
7791
|
} else if (step.kind === "mat") {
|
|
7767
|
-
const to = step.to === "screen" ? scene.screenRect : step.to === "round" ? () => rounded(scene.fullRect()) : scene.fullRect;
|
|
7792
|
+
const to = step.to === "screen" ? () => evenHole(scene.screenRect()) : step.to === "round" ? () => rounded(scene.fullRect()) : scene.fullRect;
|
|
7768
7793
|
const going = run;
|
|
7769
7794
|
await moveHole(scene, to, instant ? 0 : step.time);
|
|
7770
7795
|
if (step.to === "screen" && !instant && going?.live())
|
|
@@ -7781,13 +7806,16 @@ async function perform(scene, step, target, instant) {
|
|
|
7781
7806
|
}
|
|
7782
7807
|
function start(scene, target) {
|
|
7783
7808
|
if (!clipped) {
|
|
7784
|
-
seen = { veil: 1, content: 1, hole: scene.screenRect() };
|
|
7785
|
-
|
|
7809
|
+
seen = { veil: 1, content: 1, hole: evenHole(scene.screenRect()) };
|
|
7810
|
+
if (target === "closed")
|
|
7811
|
+
paintVeil(scene.veil);
|
|
7786
7812
|
scene.veil.style.opacity = "1";
|
|
7787
7813
|
cut2 = "";
|
|
7788
7814
|
placeHole(scene, seen.hole);
|
|
7789
7815
|
clipped = true;
|
|
7790
7816
|
}
|
|
7817
|
+
if (target === "open")
|
|
7818
|
+
paintCover(scene);
|
|
7791
7819
|
const shown3 = { ...seen, covered: scene.covered(), open: sameHole(seen.hole, scene.fullRect()) };
|
|
7792
7820
|
const next = sequence(plan(shown3, target), target);
|
|
7793
7821
|
run = next;
|
|
@@ -8065,8 +8093,6 @@ function explain(box2, refusal, again) {
|
|
|
8065
8093
|
};
|
|
8066
8094
|
button.addEventListener("click", run2);
|
|
8067
8095
|
why.append(button);
|
|
8068
|
-
if (retry.now)
|
|
8069
|
-
run2();
|
|
8070
8096
|
}
|
|
8071
8097
|
}
|
|
8072
8098
|
|
|
@@ -8457,8 +8483,45 @@ var VIEWPORT_CSS = `
|
|
|
8457
8483
|
top: 0;
|
|
8458
8484
|
left: 0;
|
|
8459
8485
|
}
|
|
8486
|
+
/* Holds the cover over the frame. */
|
|
8487
|
+
.page { position: relative; }
|
|
8460
8488
|
/* Where a phone's browser leaves the page in its screen. */
|
|
8461
8489
|
.page.placed { position: absolute; }
|
|
8490
|
+
/* Over the frame while its page loads or a host loads it again, so a browser's
|
|
8491
|
+
error page never flashes: the frame's own canvas, a dot that breathes. */
|
|
8492
|
+
.loading {
|
|
8493
|
+
position: absolute;
|
|
8494
|
+
inset: 0;
|
|
8495
|
+
display: flex;
|
|
8496
|
+
align-items: center;
|
|
8497
|
+
justify-content: center;
|
|
8498
|
+
background: Canvas;
|
|
8499
|
+
color: CanvasText;
|
|
8500
|
+
/* The user's own scheme, unless the knob forces one. */
|
|
8501
|
+
color-scheme: light dark;
|
|
8502
|
+
pointer-events: none;
|
|
8503
|
+
}
|
|
8504
|
+
.loading[hidden] { display: none; }
|
|
8505
|
+
/* The veil wears the cover between two devices, its dot in the mat's opening. */
|
|
8506
|
+
.veil.loading::after {
|
|
8507
|
+
position: absolute;
|
|
8508
|
+
left: var(--dot-x, 50%);
|
|
8509
|
+
top: var(--dot-y, 50%);
|
|
8510
|
+
translate: -50% -50%;
|
|
8511
|
+
}
|
|
8512
|
+
.loading::after {
|
|
8513
|
+
content: "";
|
|
8514
|
+
width: 6px;
|
|
8515
|
+
height: 6px;
|
|
8516
|
+
border-radius: 50%;
|
|
8517
|
+
background: currentColor;
|
|
8518
|
+
opacity: 0.25;
|
|
8519
|
+
animation: devknobs-breathe 1.2s ease-in-out infinite alternate;
|
|
8520
|
+
}
|
|
8521
|
+
@keyframes devknobs-breathe { to { opacity: 0.08; } }
|
|
8522
|
+
@media (prefers-reduced-motion: reduce) {
|
|
8523
|
+
.loading::after { animation: none; }
|
|
8524
|
+
}
|
|
8462
8525
|
iframe {
|
|
8463
8526
|
display: block;
|
|
8464
8527
|
border: 0;
|
|
@@ -8594,7 +8657,14 @@ var notice = null;
|
|
|
8594
8657
|
var exit2 = null;
|
|
8595
8658
|
var askWhy = null;
|
|
8596
8659
|
var framed = null;
|
|
8660
|
+
var loader = null;
|
|
8661
|
+
var ANSWER_WAIT = 6000;
|
|
8597
8662
|
var refusals = 0;
|
|
8663
|
+
var loadCover = null;
|
|
8664
|
+
var coverPoll = 0;
|
|
8665
|
+
var coverCap = 0;
|
|
8666
|
+
var COVER_POLL = 50;
|
|
8667
|
+
var COVER_CAP = ANSWER_WAIT + 2000;
|
|
8598
8668
|
var current = {
|
|
8599
8669
|
...UNFRAMED,
|
|
8600
8670
|
scheme: "system",
|
|
@@ -8653,16 +8723,78 @@ function onRefused(handler) {
|
|
|
8653
8723
|
function onFramed(handler) {
|
|
8654
8724
|
framed = handler;
|
|
8655
8725
|
}
|
|
8726
|
+
function onLoader(handler) {
|
|
8727
|
+
loader = handler;
|
|
8728
|
+
}
|
|
8729
|
+
function navigate(target, url) {
|
|
8730
|
+
if (!loader?.(target, url))
|
|
8731
|
+
target.src = url;
|
|
8732
|
+
}
|
|
8656
8733
|
function whyRefused() {
|
|
8657
8734
|
const box2 = notice;
|
|
8658
8735
|
const turn2 = ++refusals;
|
|
8659
8736
|
if (!box2)
|
|
8660
8737
|
return;
|
|
8661
8738
|
explain(box2, null, loadAgain);
|
|
8662
|
-
askWhy
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8739
|
+
if (!askWhy) {
|
|
8740
|
+
hideCover();
|
|
8741
|
+
box2.hidden = false;
|
|
8742
|
+
return;
|
|
8743
|
+
}
|
|
8744
|
+
showCover();
|
|
8745
|
+
const still2 = () => turn2 === refusals && notice === box2;
|
|
8746
|
+
let answered = false;
|
|
8747
|
+
const show2 = (refusal) => {
|
|
8748
|
+
if (!still2())
|
|
8749
|
+
return;
|
|
8750
|
+
hideCover();
|
|
8751
|
+
box2.hidden = false;
|
|
8752
|
+
explain(box2, refusal, loadAgain);
|
|
8753
|
+
};
|
|
8754
|
+
window.setTimeout(() => {
|
|
8755
|
+
if (!answered)
|
|
8756
|
+
show2(null);
|
|
8757
|
+
}, ANSWER_WAIT);
|
|
8758
|
+
askWhy(frameUrl).then((refusal) => {
|
|
8759
|
+
answered = true;
|
|
8760
|
+
const retry = refusal?.retry;
|
|
8761
|
+
if (!retry?.now) {
|
|
8762
|
+
show2(refusal);
|
|
8763
|
+
return;
|
|
8764
|
+
}
|
|
8765
|
+
retry.run().then(() => {
|
|
8766
|
+
if (still2())
|
|
8767
|
+
loadAgain();
|
|
8768
|
+
}, (error) => show2({ why: error instanceof Error ? error.message : String(error) }));
|
|
8769
|
+
}, () => {
|
|
8770
|
+
answered = true;
|
|
8771
|
+
show2(null);
|
|
8772
|
+
});
|
|
8773
|
+
}
|
|
8774
|
+
function readable() {
|
|
8775
|
+
const doc = frameDocument();
|
|
8776
|
+
return doc !== null && doc.URL !== "about:blank" && doc.readyState !== "loading";
|
|
8777
|
+
}
|
|
8778
|
+
function showCover() {
|
|
8779
|
+
if (!loadCover)
|
|
8780
|
+
return;
|
|
8781
|
+
clearTimeout(coverPoll);
|
|
8782
|
+
clearTimeout(coverCap);
|
|
8783
|
+
loadCover.hidden = false;
|
|
8784
|
+
const look = () => {
|
|
8785
|
+
if (readable())
|
|
8786
|
+
hideCover();
|
|
8787
|
+
else
|
|
8788
|
+
coverPoll = window.setTimeout(look, COVER_POLL);
|
|
8789
|
+
};
|
|
8790
|
+
coverPoll = window.setTimeout(look, COVER_POLL);
|
|
8791
|
+
coverCap = window.setTimeout(hideCover, COVER_CAP);
|
|
8792
|
+
}
|
|
8793
|
+
function hideCover() {
|
|
8794
|
+
clearTimeout(coverPoll);
|
|
8795
|
+
clearTimeout(coverCap);
|
|
8796
|
+
if (loadCover)
|
|
8797
|
+
loadCover.hidden = true;
|
|
8666
8798
|
}
|
|
8667
8799
|
function loadAgain() {
|
|
8668
8800
|
if (!frame3)
|
|
@@ -8672,7 +8804,8 @@ function loadAgain() {
|
|
|
8672
8804
|
refusals += 1;
|
|
8673
8805
|
if (notice)
|
|
8674
8806
|
notice.hidden = true;
|
|
8675
|
-
|
|
8807
|
+
showCover();
|
|
8808
|
+
navigate(frame3, frameUrl);
|
|
8676
8809
|
}
|
|
8677
8810
|
function onZoom(handler) {
|
|
8678
8811
|
zoomTo = handler;
|
|
@@ -8694,9 +8827,13 @@ function onLoad() {
|
|
|
8694
8827
|
loadedAt = performance.now();
|
|
8695
8828
|
const doc = frameDocument();
|
|
8696
8829
|
if (notice)
|
|
8697
|
-
notice.hidden =
|
|
8830
|
+
notice.hidden = true;
|
|
8698
8831
|
if (doc === null)
|
|
8699
8832
|
whyRefused();
|
|
8833
|
+
else {
|
|
8834
|
+
refusals += 1;
|
|
8835
|
+
hideCover();
|
|
8836
|
+
}
|
|
8700
8837
|
locate();
|
|
8701
8838
|
const view = frameWindow();
|
|
8702
8839
|
if (view && doc) {
|
|
@@ -8882,16 +9019,13 @@ function showMock(mock, place2) {
|
|
|
8882
9019
|
mockDrawing = mock ? drawMock(mock, place2, href) : null;
|
|
8883
9020
|
if (mockDrawing)
|
|
8884
9021
|
screen.append(mockDrawing);
|
|
8885
|
-
glass.className = mock ?
|
|
9022
|
+
glass.className = mock ? "glass mocked" : "glass";
|
|
8886
9023
|
}
|
|
8887
9024
|
const zoom = place2.zoom;
|
|
8888
9025
|
glass.style.left = mock ? `${mock.inset.left * zoom}px` : "";
|
|
8889
9026
|
glass.style.top = mock ? `${mock.inset.top * zoom}px` : "";
|
|
8890
9027
|
const round4 = mock ? corners(mock.screenRadius).map((radius) => `${radius * zoom}px`) : [];
|
|
8891
9028
|
glass.style.borderRadius = round4.join(" ");
|
|
8892
|
-
const [corner = 0] = mock ? corners(mock.screenRadius) : [];
|
|
8893
|
-
const continuous = mock?.continuous ? `${corner * CONTINUOUS.extent * zoom}px` : "";
|
|
8894
|
-
glass.style.setProperty("--continuous", continuous);
|
|
8895
9029
|
glass.style.boxShadow = href ? `0 0 0 ${UNDER * zoom}px #000` : "";
|
|
8896
9030
|
if (mock && mockDrawing) {
|
|
8897
9031
|
mockDrawing.style.width = `${mock.width * zoom}px`;
|
|
@@ -8983,6 +9117,10 @@ function resize() {
|
|
|
8983
9117
|
frame3.style.colorScheme = current.scheme;
|
|
8984
9118
|
else
|
|
8985
9119
|
frame3.style.removeProperty("color-scheme");
|
|
9120
|
+
if (loadCover)
|
|
9121
|
+
loadCover.style.colorScheme = coverScheme();
|
|
9122
|
+
if (veil?.className === "veil loading")
|
|
9123
|
+
veil.style.colorScheme = coverScheme();
|
|
8986
9124
|
frame3.style.filter = visionFilter(current.vision);
|
|
8987
9125
|
checkZoom();
|
|
8988
9126
|
warmFold();
|
|
@@ -9215,6 +9353,9 @@ function handBack() {
|
|
|
9215
9353
|
showPage();
|
|
9216
9354
|
window.scrollTo({ left: scroll.x, top: scroll.y, behavior: "instant" });
|
|
9217
9355
|
}
|
|
9356
|
+
function coverScheme() {
|
|
9357
|
+
return current.scheme === "system" ? "" : current.scheme;
|
|
9358
|
+
}
|
|
9218
9359
|
function scene() {
|
|
9219
9360
|
if (!host || !back || !veil)
|
|
9220
9361
|
return null;
|
|
@@ -9224,6 +9365,7 @@ function scene() {
|
|
|
9224
9365
|
content: contentNodes,
|
|
9225
9366
|
screenRect,
|
|
9226
9367
|
fullRect,
|
|
9368
|
+
scheme: coverScheme,
|
|
9227
9369
|
covered: () => covered,
|
|
9228
9370
|
hidePage,
|
|
9229
9371
|
painted,
|
|
@@ -9314,12 +9456,12 @@ function open(veiled, first) {
|
|
|
9314
9456
|
waiting2.then(() => {
|
|
9315
9457
|
if (frame3 !== opened)
|
|
9316
9458
|
return;
|
|
9317
|
-
opened.src = frameUrl;
|
|
9318
9459
|
opened.addEventListener("load", onLoad);
|
|
9460
|
+
navigate(opened, frameUrl);
|
|
9319
9461
|
});
|
|
9320
|
-
} else {
|
|
9321
|
-
frame3.src = frameUrl;
|
|
9462
|
+
} else if (!loader) {
|
|
9322
9463
|
frame3.addEventListener("load", onLoad);
|
|
9464
|
+
navigate(frame3, frameUrl);
|
|
9323
9465
|
}
|
|
9324
9466
|
track({
|
|
9325
9467
|
view: frameWindow,
|
|
@@ -9330,7 +9472,11 @@ function open(veiled, first) {
|
|
|
9330
9472
|
notice = createNotice(() => exit2?.());
|
|
9331
9473
|
pageBox = document.createElement("div");
|
|
9332
9474
|
pageBox.className = "page";
|
|
9333
|
-
|
|
9475
|
+
loadCover = document.createElement("div");
|
|
9476
|
+
loadCover.className = "loading";
|
|
9477
|
+
loadCover.setAttribute("aria-hidden", "true");
|
|
9478
|
+
pageBox.append(frame3, loadCover);
|
|
9479
|
+
showCover();
|
|
9334
9480
|
glass.append(pageBox);
|
|
9335
9481
|
browser = createBrowser(glass, frame3, resize, onReloading, painted);
|
|
9336
9482
|
touchDot = createTouchDot({
|
|
@@ -9355,6 +9501,10 @@ function open(veiled, first) {
|
|
|
9355
9501
|
window.addEventListener("resize", resize);
|
|
9356
9502
|
window.addEventListener("pagehide", keep2);
|
|
9357
9503
|
body.append(host);
|
|
9504
|
+
if (!waiting2 && loader) {
|
|
9505
|
+
frame3.addEventListener("load", onLoad);
|
|
9506
|
+
navigate(frame3, frameUrl);
|
|
9507
|
+
}
|
|
9358
9508
|
stopKeeping = keepMounted(host, { restored: remounted });
|
|
9359
9509
|
const now = scene();
|
|
9360
9510
|
if (veiled !== null && now)
|
|
@@ -9417,6 +9567,8 @@ function teardown() {
|
|
|
9417
9567
|
mockDrawing = null;
|
|
9418
9568
|
mockKey = "";
|
|
9419
9569
|
frame3 = null;
|
|
9570
|
+
hideCover();
|
|
9571
|
+
loadCover = null;
|
|
9420
9572
|
notice = null;
|
|
9421
9573
|
readout = null;
|
|
9422
9574
|
caption = null;
|