@vinena/knobs 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +7 -6
- package/dist/context-amfyasb5.js +23 -0
- package/dist/context-svtr7vwt.js +22 -0
- package/dist/early.global.js +6 -6
- package/dist/edit/css.d.ts +59 -0
- package/dist/edit/html.d.ts +91 -0
- package/dist/edit/keep.d.ts +175 -0
- package/dist/edit/log.d.ts +107 -0
- package/dist/edit/replay.d.ts +28 -0
- package/dist/edit/risk.d.ts +33 -0
- package/dist/edit/rule.d.ts +31 -0
- package/dist/edit/source.d.ts +12 -0
- package/dist/edit/text.d.ts +66 -0
- package/dist/elementsview-fyc06wjt.js +3702 -0
- package/dist/elementsview-k6zvvcne.js +3701 -0
- 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/dock.d.ts +3 -4
- package/dist/engine/frame.d.ts +1 -1
- 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/style.d.ts +15 -0
- package/dist/engine/width.d.ts +3 -0
- package/dist/{framekit-w0v516w5.js → framekit-622h6w1f.js} +264 -105
- package/dist/{framekit-te90cjs0.js → framekit-yx612r28.js} +264 -105
- package/dist/index-0zp9py56.js +859 -0
- package/dist/{index-9re7sv56.js → index-1mstjadm.js} +126 -2167
- package/dist/{index-30fc6php.js → index-4a4x1bt2.js} +1 -1
- package/dist/index-58jdczmj.js +44 -0
- package/dist/index-5tv6sr74.js +23 -0
- package/dist/index-6bc2ztfd.js +688 -0
- package/dist/index-7cb4x1vj.js +1885 -0
- package/dist/index-a974q3aa.js +34 -0
- package/dist/{index-r72tz2vn.js → index-aymfvd8s.js} +1 -1
- package/dist/{index-trx7bxdk.js → index-aynkv7qk.js} +11 -8
- package/dist/{index-xjhwp5cj.js → index-dzm8ywq0.js} +504 -2362
- package/dist/{index-dan2kpsd.js → index-f60yax1j.js} +13 -8
- package/dist/index-f67wctn3.js +1858 -0
- package/dist/{index-agwr37gw.js → index-ftjdt358.js} +8 -171
- package/dist/{index-pewcdh28.js → index-gm51cthv.js} +2 -45
- package/dist/index-kfdzsyyw.js +1859 -0
- package/dist/index-t4kssacm.js +208 -0
- package/dist/index-v0ht9q0g.js +1518 -0
- package/dist/{index-sxe5079a.js → index-x59vz1xx.js} +262 -901
- package/dist/index-xh39jtkq.js +32 -0
- package/dist/index-yb7fc59g.js +718 -0
- package/dist/index-zd6adby9.js +496 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.global.js +447 -160
- package/dist/index.js +533 -485
- package/dist/react-0wepdf60.js +1519 -0
- package/dist/{react-4pvp6amm.js → react-1gqwa2yw.js} +1 -1
- package/dist/{index-hv02xka3.js → react-3mfz1x2a.js} +126 -2167
- package/dist/react-4rbjw9af.js +33 -0
- package/dist/react-5rq7bnsy.js +210 -0
- package/dist/react-6bz05qk1.js +860 -0
- package/dist/{react-05jh9jv5.js → react-6fnxxs30.js} +8 -171
- package/dist/react-6q2cw2ya.js +689 -0
- package/dist/{react-sw8d8c94.js → react-6t4dbdzn.js} +11 -8
- package/dist/react-88es9b5q.js +719 -0
- package/dist/react-97b5b8j4.js +46 -0
- package/dist/{react-16spgn0h.js → react-bxzn8vq5.js} +1 -1
- package/dist/{react-ayg1bgw3.js → react-cs62p9qh.js} +83 -722
- package/dist/react-ethftdxp.js +497 -0
- package/dist/react-fp73vhyd.js +36 -0
- package/dist/{react-exjcpxma.js → react-me102s1a.js} +2 -45
- package/dist/react-t2qnewz2.js +24 -0
- package/dist/react-ttj8f9qp.js +1886 -0
- package/dist/{react-zy1mmhgz.js → react-v8497a41.js} +13 -8
- package/dist/{react-fm9y8dbn.js → react-wqn4sx0n.js} +276 -2133
- package/dist/react.js +529 -485
- package/dist/replay-j18rw92k.js +258 -0
- package/dist/replay-vtg0vqj2.js +257 -0
- package/dist/{storageview-s7heg93p.js → storageview-6xj7zb63.js} +11 -7
- package/dist/{storageview-r595qpt9.js → storageview-pzn8yaad.js} +11 -7
- package/dist/styles/force.d.ts +66 -0
- package/dist/types.d.ts +7 -0
- package/dist/ui/bindings.d.ts +31 -5
- package/dist/ui/changes.d.ts +49 -0
- package/dist/ui/cssauto.d.ts +119 -0
- package/dist/ui/cssedit.d.ts +80 -0
- package/dist/ui/domedit.d.ts +99 -0
- package/dist/ui/domtree.d.ts +26 -1
- package/dist/ui/elementsview.d.ts +19 -2
- package/dist/ui/htmledit.d.ts +62 -0
- package/dist/ui/inspector.d.ts +6 -1
- package/dist/ui/keys.d.ts +12 -8
- package/dist/ui/pane.d.ts +0 -2
- package/dist/ui/panel.d.ts +3 -0
- package/dist/ui/prefs.d.ts +30 -10
- package/dist/ui/settings.d.ts +10 -0
- package/dist/ui/size.d.ts +14 -22
- package/dist/ui/stylesview.d.ts +30 -1
- package/package.json +1 -1
- package/skills/devknobs/SKILL.md +95 -0
- package/dist/elementsview-2z4pkrdz.js +0 -2873
- package/dist/elementsview-qn8qyksa.js +0 -2874
- package/dist/index-78r0f8pw.js +0 -27
- package/dist/react-adky72h9.js +0 -29
|
@@ -1,25 +1,106 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
|
|
3
|
+
// src/engine/clock.ts
|
|
4
|
+
var HOUR = 3600000;
|
|
5
|
+
var DAY = 86400000;
|
|
6
|
+
var CLOCK_SPEED_MIN = 0.001;
|
|
7
|
+
var CLOCK_SPEED_MAX = 1e6;
|
|
8
|
+
var CLOCK_PRESETS = [
|
|
9
|
+
{ label: "+1h", ms: HOUR },
|
|
10
|
+
{ label: "+1d", ms: DAY },
|
|
11
|
+
{ label: "+2d", ms: 2 * DAY },
|
|
12
|
+
{ label: "+1w", ms: 7 * DAY },
|
|
13
|
+
{ label: "+30d", ms: 30 * DAY }
|
|
14
|
+
];
|
|
15
|
+
var SHARED = Symbol.for("devknobs.clock");
|
|
16
|
+
var shared = globalThis[SHARED] ??= {
|
|
17
|
+
Date,
|
|
18
|
+
clock: null
|
|
15
19
|
};
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
var NativeDate = shared.Date;
|
|
21
|
+
function realNow() {
|
|
22
|
+
return NativeDate.now();
|
|
23
|
+
}
|
|
24
|
+
function virtualNow(clock, real) {
|
|
25
|
+
if (clock.mode === "frozen")
|
|
26
|
+
return clock.at;
|
|
27
|
+
if (clock.mode === "offset")
|
|
28
|
+
return Math.floor(clock.at + (real - clock.since) * clock.speed);
|
|
29
|
+
return real;
|
|
30
|
+
}
|
|
31
|
+
function mergeClock(clock, patch, real = realNow()) {
|
|
32
|
+
if (!patch)
|
|
33
|
+
return clock;
|
|
34
|
+
const next = { ...clock, ...patch };
|
|
35
|
+
if (patch.since !== undefined && patch.since !== clock.since)
|
|
36
|
+
return next;
|
|
37
|
+
if (patch.at !== undefined && patch.since === undefined)
|
|
38
|
+
return { ...next, since: real };
|
|
39
|
+
const moved = (key) => patch[key] !== undefined && patch[key] !== clock[key];
|
|
40
|
+
if (moved("mode") || moved("speed"))
|
|
41
|
+
return { ...next, at: virtualNow(clock, real), since: real };
|
|
42
|
+
return next;
|
|
43
|
+
}
|
|
44
|
+
function setClock(value) {
|
|
45
|
+
shared.clock = value && value.mode !== "system" ? { ...value } : null;
|
|
46
|
+
}
|
|
47
|
+
function clockOn() {
|
|
48
|
+
return shared.clock !== null;
|
|
49
|
+
}
|
|
50
|
+
function now() {
|
|
51
|
+
return shared.clock ? virtualNow(shared.clock, realNow()) : realNow();
|
|
52
|
+
}
|
|
53
|
+
function wrapDate(original, zone) {
|
|
54
|
+
return new Proxy(original, {
|
|
55
|
+
construct(target, args, newTarget) {
|
|
56
|
+
if (args.length === 0 && shared.clock)
|
|
57
|
+
return Reflect.construct(target, [now()], newTarget);
|
|
58
|
+
return Reflect.construct(target, zone ? zone.args(args) : args, newTarget);
|
|
59
|
+
},
|
|
60
|
+
apply(target, thisArg, args) {
|
|
61
|
+
if (!shared.clock && !zone?.on())
|
|
62
|
+
return Reflect.apply(target, thisArg, args);
|
|
63
|
+
return String(new NativeDate(now()));
|
|
64
|
+
},
|
|
65
|
+
get(target, key, receiver) {
|
|
66
|
+
if (key === "now")
|
|
67
|
+
return now;
|
|
68
|
+
if (key === "parse" && zone)
|
|
69
|
+
return zone.parse;
|
|
70
|
+
return Reflect.get(target, key, receiver);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
var READERS = {
|
|
75
|
+
instant: (instant) => instant,
|
|
76
|
+
zonedDateTimeISO: (instant, zone) => instant.toZonedDateTimeISO(zone),
|
|
77
|
+
plainDateTimeISO: (instant, zone) => instant.toZonedDateTimeISO(zone).toPlainDateTime(),
|
|
78
|
+
plainDateISO: (instant, zone) => instant.toZonedDateTimeISO(zone).toPlainDate(),
|
|
79
|
+
plainTimeISO: (instant, zone) => instant.toZonedDateTimeISO(zone).toPlainTime()
|
|
80
|
+
};
|
|
81
|
+
var NOW_READERS = Object.keys(READERS);
|
|
82
|
+
function temporalNow() {
|
|
83
|
+
return globalThis.Temporal?.Now;
|
|
84
|
+
}
|
|
85
|
+
function readNow(key, original, zoneOf) {
|
|
86
|
+
return function(timeZone) {
|
|
87
|
+
const zone = zoneOf(timeZone);
|
|
88
|
+
const temporal = globalThis.Temporal;
|
|
89
|
+
if (!shared.clock || !temporal?.Instant)
|
|
90
|
+
return original.call(this, zone);
|
|
91
|
+
const instant = temporal.Instant.fromEpochMilliseconds(now());
|
|
92
|
+
const timeZoneId = temporal.Now?.timeZoneId;
|
|
93
|
+
const host = typeof timeZoneId === "function" ? timeZoneId.call(temporal.Now) : undefined;
|
|
94
|
+
return READERS[key](instant, zone ?? host);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
var EARLY = Symbol.for("devknobs.early.clock");
|
|
98
|
+
function takeOver() {
|
|
99
|
+
const scope = globalThis;
|
|
100
|
+
const patches = scope[EARLY];
|
|
101
|
+
scope[EARLY] = null;
|
|
102
|
+
patches?.release();
|
|
103
|
+
}
|
|
23
104
|
|
|
24
105
|
// src/engine/devices.ts
|
|
25
106
|
var POSTURES = ["closed", "open"];
|
|
@@ -377,7 +458,7 @@ function hold(state, patch) {
|
|
|
377
458
|
}
|
|
378
459
|
return next;
|
|
379
460
|
}
|
|
380
|
-
function settle(state) {
|
|
461
|
+
function settle(state, dropUa = true) {
|
|
381
462
|
const { width, height } = state;
|
|
382
463
|
const sized = typeof width === "number" && typeof height === "number";
|
|
383
464
|
const orientation = sized && width > height ? "landscape" : "portrait";
|
|
@@ -388,7 +469,9 @@ function settle(state) {
|
|
|
388
469
|
const same = orientation === state.orientation && posture === state.posture;
|
|
389
470
|
if (same && id === state.device)
|
|
390
471
|
return state;
|
|
391
|
-
|
|
472
|
+
const dropped = dropUa && id !== state.device && device !== undefined && state.ua.preset === device.ua;
|
|
473
|
+
const ua = dropped ? { ...state.ua, preset: "system" } : state.ua;
|
|
474
|
+
return { ...state, orientation, posture, device: id, ua };
|
|
392
475
|
}
|
|
393
476
|
|
|
394
477
|
// src/engine/stored.ts
|
|
@@ -405,108 +488,6 @@ function stamped(value, v) {
|
|
|
405
488
|
return { v, ...value };
|
|
406
489
|
}
|
|
407
490
|
|
|
408
|
-
// src/engine/clock.ts
|
|
409
|
-
var HOUR = 3600000;
|
|
410
|
-
var DAY = 86400000;
|
|
411
|
-
var CLOCK_SPEED_MIN = 0.001;
|
|
412
|
-
var CLOCK_SPEED_MAX = 1e6;
|
|
413
|
-
var CLOCK_PRESETS = [
|
|
414
|
-
{ label: "+1h", ms: HOUR },
|
|
415
|
-
{ label: "+1d", ms: DAY },
|
|
416
|
-
{ label: "+2d", ms: 2 * DAY },
|
|
417
|
-
{ label: "+1w", ms: 7 * DAY },
|
|
418
|
-
{ label: "+30d", ms: 30 * DAY }
|
|
419
|
-
];
|
|
420
|
-
var SHARED = Symbol.for("devknobs.clock");
|
|
421
|
-
var shared = globalThis[SHARED] ??= {
|
|
422
|
-
Date,
|
|
423
|
-
clock: null
|
|
424
|
-
};
|
|
425
|
-
var NativeDate = shared.Date;
|
|
426
|
-
function realNow() {
|
|
427
|
-
return NativeDate.now();
|
|
428
|
-
}
|
|
429
|
-
function virtualNow(clock, real) {
|
|
430
|
-
if (clock.mode === "frozen")
|
|
431
|
-
return clock.at;
|
|
432
|
-
if (clock.mode === "offset")
|
|
433
|
-
return Math.floor(clock.at + (real - clock.since) * clock.speed);
|
|
434
|
-
return real;
|
|
435
|
-
}
|
|
436
|
-
function mergeClock(clock, patch, real = realNow()) {
|
|
437
|
-
if (!patch)
|
|
438
|
-
return clock;
|
|
439
|
-
const next = { ...clock, ...patch };
|
|
440
|
-
if (patch.since !== undefined && patch.since !== clock.since)
|
|
441
|
-
return next;
|
|
442
|
-
if (patch.at !== undefined && patch.since === undefined)
|
|
443
|
-
return { ...next, since: real };
|
|
444
|
-
const moved = (key) => patch[key] !== undefined && patch[key] !== clock[key];
|
|
445
|
-
if (moved("mode") || moved("speed"))
|
|
446
|
-
return { ...next, at: virtualNow(clock, real), since: real };
|
|
447
|
-
return next;
|
|
448
|
-
}
|
|
449
|
-
function setClock(value) {
|
|
450
|
-
shared.clock = value && value.mode !== "system" ? { ...value } : null;
|
|
451
|
-
}
|
|
452
|
-
function clockOn() {
|
|
453
|
-
return shared.clock !== null;
|
|
454
|
-
}
|
|
455
|
-
function now() {
|
|
456
|
-
return shared.clock ? virtualNow(shared.clock, realNow()) : realNow();
|
|
457
|
-
}
|
|
458
|
-
function wrapDate(original, zone) {
|
|
459
|
-
return new Proxy(original, {
|
|
460
|
-
construct(target, args, newTarget) {
|
|
461
|
-
if (args.length === 0 && shared.clock)
|
|
462
|
-
return Reflect.construct(target, [now()], newTarget);
|
|
463
|
-
return Reflect.construct(target, zone ? zone.args(args) : args, newTarget);
|
|
464
|
-
},
|
|
465
|
-
apply(target, thisArg, args) {
|
|
466
|
-
if (!shared.clock && !zone?.on())
|
|
467
|
-
return Reflect.apply(target, thisArg, args);
|
|
468
|
-
return String(new NativeDate(now()));
|
|
469
|
-
},
|
|
470
|
-
get(target, key, receiver) {
|
|
471
|
-
if (key === "now")
|
|
472
|
-
return now;
|
|
473
|
-
if (key === "parse" && zone)
|
|
474
|
-
return zone.parse;
|
|
475
|
-
return Reflect.get(target, key, receiver);
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
var READERS = {
|
|
480
|
-
instant: (instant) => instant,
|
|
481
|
-
zonedDateTimeISO: (instant, zone) => instant.toZonedDateTimeISO(zone),
|
|
482
|
-
plainDateTimeISO: (instant, zone) => instant.toZonedDateTimeISO(zone).toPlainDateTime(),
|
|
483
|
-
plainDateISO: (instant, zone) => instant.toZonedDateTimeISO(zone).toPlainDate(),
|
|
484
|
-
plainTimeISO: (instant, zone) => instant.toZonedDateTimeISO(zone).toPlainTime()
|
|
485
|
-
};
|
|
486
|
-
var NOW_READERS = Object.keys(READERS);
|
|
487
|
-
function temporalNow() {
|
|
488
|
-
return globalThis.Temporal?.Now;
|
|
489
|
-
}
|
|
490
|
-
function readNow(key, original, zoneOf) {
|
|
491
|
-
return function(timeZone) {
|
|
492
|
-
const zone = zoneOf(timeZone);
|
|
493
|
-
const temporal = globalThis.Temporal;
|
|
494
|
-
if (!shared.clock || !temporal?.Instant)
|
|
495
|
-
return original.call(this, zone);
|
|
496
|
-
const instant = temporal.Instant.fromEpochMilliseconds(now());
|
|
497
|
-
const timeZoneId = temporal.Now?.timeZoneId;
|
|
498
|
-
const host = typeof timeZoneId === "function" ? timeZoneId.call(temporal.Now) : undefined;
|
|
499
|
-
return READERS[key](instant, zone ?? host);
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
var EARLY = Symbol.for("devknobs.early.clock");
|
|
503
|
-
function takeOver() {
|
|
504
|
-
const scope = globalThis;
|
|
505
|
-
const patches = scope[EARLY];
|
|
506
|
-
scope[EARLY] = null;
|
|
507
|
-
patches?.release();
|
|
508
|
-
}
|
|
509
|
-
|
|
510
491
|
// src/grab/boxmodel.ts
|
|
511
492
|
var RINGS = ["margin", "border", "padding", "content"];
|
|
512
493
|
var SIDES = ["top", "right", "bottom", "left"];
|
|
@@ -1210,6 +1191,7 @@ var DEFAULT_STATE = {
|
|
|
1210
1191
|
docked: false,
|
|
1211
1192
|
handle: true,
|
|
1212
1193
|
devIcon: "auto",
|
|
1194
|
+
realPhone: false,
|
|
1213
1195
|
pinned: [...DEFAULT_PINNED]
|
|
1214
1196
|
}
|
|
1215
1197
|
};
|
|
@@ -1382,6 +1364,7 @@ function parse(json, place) {
|
|
|
1382
1364
|
...placeOf(panel, home),
|
|
1383
1365
|
handle: bool(panel.handle, DEFAULT_STATE.panel.handle),
|
|
1384
1366
|
devIcon: oneOf(panel.devIcon, DEV_ICONS, DEFAULT_STATE.panel.devIcon),
|
|
1367
|
+
realPhone: bool(panel.realPhone, DEFAULT_STATE.panel.realPhone),
|
|
1385
1368
|
pinned: state.panel === undefined ? [...DEFAULT_PINNED] : rowIds(panel.pinned)
|
|
1386
1369
|
}
|
|
1387
1370
|
};
|
|
@@ -1400,7 +1383,7 @@ function merge(state, patch) {
|
|
|
1400
1383
|
network: { ...state.network, ...held.network },
|
|
1401
1384
|
ua: { ...state.ua, ...held.ua },
|
|
1402
1385
|
panel: { ...state.panel, ...held.panel }
|
|
1403
|
-
});
|
|
1386
|
+
}, patch.ua === undefined);
|
|
1404
1387
|
}
|
|
1405
1388
|
function item(kind, key) {
|
|
1406
1389
|
try {
|
|
@@ -1410,11 +1393,13 @@ function item(kind, key) {
|
|
|
1410
1393
|
}
|
|
1411
1394
|
}
|
|
1412
1395
|
function load() {
|
|
1413
|
-
|
|
1396
|
+
const state = parse(item("session", STORAGE_KEY), item("local", PLACE_KEY));
|
|
1397
|
+
return { ...state, panel: { ...state.panel, realPhone: DEFAULT_STATE.panel.realPhone } };
|
|
1414
1398
|
}
|
|
1415
1399
|
function save(state) {
|
|
1416
1400
|
try {
|
|
1417
|
-
|
|
1401
|
+
const { realPhone: _, ...panel } = state.panel;
|
|
1402
|
+
webStorage("session")?.setItem(STORAGE_KEY, JSON.stringify(stamped({ ...state, panel }, STATE_VERSION)));
|
|
1418
1403
|
} catch {}
|
|
1419
1404
|
}
|
|
1420
1405
|
function keepPlace(state) {
|
|
@@ -1437,6 +1422,8 @@ var KEY_ACTIONS = [
|
|
|
1437
1422
|
"requests",
|
|
1438
1423
|
"reset",
|
|
1439
1424
|
"storage",
|
|
1425
|
+
"elements",
|
|
1426
|
+
"settings",
|
|
1440
1427
|
"search",
|
|
1441
1428
|
"zoom-in",
|
|
1442
1429
|
"zoom-out",
|
|
@@ -1707,174 +1694,6 @@ function ownReload() {
|
|
|
1707
1694
|
} catch {}
|
|
1708
1695
|
}
|
|
1709
1696
|
|
|
1710
|
-
// src/engine/scrollkeep.ts
|
|
1711
|
-
var SCROLL_KEY = "devknobs:scroll";
|
|
1712
|
-
var SCROLL_VERSION = 1;
|
|
1713
|
-
var SCROLL_WINDOW = 1e4;
|
|
1714
|
-
var HOLD = 2000;
|
|
1715
|
-
var HOLD_CAP = 1e4;
|
|
1716
|
-
var PUT_BUDGET = 20;
|
|
1717
|
-
var INPUTS = ["wheel", "touchstart", "keydown", "mousedown"];
|
|
1718
|
-
function placeOf2(value) {
|
|
1719
|
-
if (typeof value !== "object" || value === null)
|
|
1720
|
-
return;
|
|
1721
|
-
const path = Reflect.get(value, "path");
|
|
1722
|
-
const x = Reflect.get(value, "x");
|
|
1723
|
-
const y = Reflect.get(value, "y");
|
|
1724
|
-
if (typeof path !== "string" || typeof x !== "number" || typeof y !== "number")
|
|
1725
|
-
return;
|
|
1726
|
-
return Number.isFinite(x) && Number.isFinite(y) ? { path, x, y } : undefined;
|
|
1727
|
-
}
|
|
1728
|
-
function parseKept(text2) {
|
|
1729
|
-
if (!text2)
|
|
1730
|
-
return null;
|
|
1731
|
-
let raw;
|
|
1732
|
-
try {
|
|
1733
|
-
raw = JSON.parse(text2);
|
|
1734
|
-
} catch {
|
|
1735
|
-
return null;
|
|
1736
|
-
}
|
|
1737
|
-
if (typeof raw !== "object" || raw === null || newer(raw, SCROLL_VERSION))
|
|
1738
|
-
return null;
|
|
1739
|
-
const at = Reflect.get(raw, "at");
|
|
1740
|
-
if (typeof at !== "number")
|
|
1741
|
-
return null;
|
|
1742
|
-
const kept = { at };
|
|
1743
|
-
const page = placeOf2(Reflect.get(raw, "page"));
|
|
1744
|
-
const frame = placeOf2(Reflect.get(raw, "frame"));
|
|
1745
|
-
if (page)
|
|
1746
|
-
kept.page = page;
|
|
1747
|
-
if (frame)
|
|
1748
|
-
kept.frame = frame;
|
|
1749
|
-
return kept;
|
|
1750
|
-
}
|
|
1751
|
-
function stale(at, now2) {
|
|
1752
|
-
const age = now2 - at;
|
|
1753
|
-
return !(age >= 0 && age < SCROLL_WINDOW);
|
|
1754
|
-
}
|
|
1755
|
-
function keptWith(kept, role, place, now2) {
|
|
1756
|
-
const next = { at: now2 };
|
|
1757
|
-
const other = role === "page" ? "frame" : "page";
|
|
1758
|
-
const rest = kept && !stale(kept.at, now2) ? kept[other] : undefined;
|
|
1759
|
-
if (rest)
|
|
1760
|
-
next[other] = rest;
|
|
1761
|
-
if (place && (place.x !== 0 || place.y !== 0))
|
|
1762
|
-
next[role] = place;
|
|
1763
|
-
return next.page || next.frame ? next : null;
|
|
1764
|
-
}
|
|
1765
|
-
function take(kept, role, path, now2) {
|
|
1766
|
-
if (!kept || stale(kept.at, now2))
|
|
1767
|
-
return { place: null, rest: null };
|
|
1768
|
-
const own = kept[role];
|
|
1769
|
-
const other = role === "page" ? "frame" : "page";
|
|
1770
|
-
const left = kept[other];
|
|
1771
|
-
const rest = left ? { at: kept.at, [other]: left } : null;
|
|
1772
|
-
if (!own || own.path !== path)
|
|
1773
|
-
return { place: null, rest };
|
|
1774
|
-
return { place: { x: own.x, y: own.y }, rest };
|
|
1775
|
-
}
|
|
1776
|
-
function next(holding, seen) {
|
|
1777
|
-
const { target } = holding;
|
|
1778
|
-
const there = Math.abs(seen.x - target.x) <= 1 && Math.abs(seen.y - target.y) <= 1;
|
|
1779
|
-
const spent = holding.puts >= PUT_BUDGET;
|
|
1780
|
-
const over = seen.now - holding.start >= HOLD_CAP || holding.loadedAt !== null && seen.now - holding.loadedAt >= HOLD;
|
|
1781
|
-
if (over)
|
|
1782
|
-
return there || spent ? "done" : "last";
|
|
1783
|
-
if (spent)
|
|
1784
|
-
return "done";
|
|
1785
|
-
if (there)
|
|
1786
|
-
return "wait";
|
|
1787
|
-
return seen.maxX >= target.x - 1 && seen.maxY >= target.y - 1 ? "put" : "wait";
|
|
1788
|
-
}
|
|
1789
|
-
function hold2(view, target, now2 = realNow) {
|
|
1790
|
-
const holding = { target, start: now2(), loadedAt: null, puts: 0 };
|
|
1791
|
-
let over = false;
|
|
1792
|
-
const end = () => {
|
|
1793
|
-
over = true;
|
|
1794
|
-
for (const type of INPUTS)
|
|
1795
|
-
view.removeEventListener(type, end, true);
|
|
1796
|
-
};
|
|
1797
|
-
const frame = () => {
|
|
1798
|
-
if (over)
|
|
1799
|
-
return;
|
|
1800
|
-
const time = now2();
|
|
1801
|
-
if (holding.loadedAt === null && view.document.readyState === "complete")
|
|
1802
|
-
holding.loadedAt = time;
|
|
1803
|
-
const root = view.document.documentElement;
|
|
1804
|
-
const move = next(holding, {
|
|
1805
|
-
x: view.scrollX,
|
|
1806
|
-
y: view.scrollY,
|
|
1807
|
-
maxX: root ? root.scrollWidth - root.clientWidth : 0,
|
|
1808
|
-
maxY: root ? root.scrollHeight - root.clientHeight : 0,
|
|
1809
|
-
now: time
|
|
1810
|
-
});
|
|
1811
|
-
if (move === "put" || move === "last") {
|
|
1812
|
-
holding.puts++;
|
|
1813
|
-
view.scrollTo({ left: target.x, top: target.y, behavior: "instant" });
|
|
1814
|
-
}
|
|
1815
|
-
if (move === "last" || move === "done")
|
|
1816
|
-
end();
|
|
1817
|
-
else
|
|
1818
|
-
view.requestAnimationFrame(frame);
|
|
1819
|
-
};
|
|
1820
|
-
for (const type of INPUTS)
|
|
1821
|
-
view.addEventListener(type, end, true);
|
|
1822
|
-
frame();
|
|
1823
|
-
}
|
|
1824
|
-
var framed2 = null;
|
|
1825
|
-
function follow(view) {
|
|
1826
|
-
framed2 = view;
|
|
1827
|
-
}
|
|
1828
|
-
function placeIn(view) {
|
|
1829
|
-
try {
|
|
1830
|
-
return view ? { path: view.location.pathname, x: view.scrollX, y: view.scrollY } : null;
|
|
1831
|
-
} catch {
|
|
1832
|
-
return null;
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
function keep(view, role) {
|
|
1836
|
-
try {
|
|
1837
|
-
const session = webStorage("session");
|
|
1838
|
-
if (!session)
|
|
1839
|
-
return;
|
|
1840
|
-
const kept = keptWith(parseKept(session.getItem(SCROLL_KEY)), role, placeIn(view), realNow());
|
|
1841
|
-
if (kept)
|
|
1842
|
-
session.setItem(SCROLL_KEY, JSON.stringify(stamped(kept, SCROLL_VERSION)));
|
|
1843
|
-
else
|
|
1844
|
-
session.removeItem(SCROLL_KEY);
|
|
1845
|
-
} catch {}
|
|
1846
|
-
}
|
|
1847
|
-
function keepOwn() {
|
|
1848
|
-
if (isDevknobsFrame()) {
|
|
1849
|
-
keep(window, "frame");
|
|
1850
|
-
return;
|
|
1851
|
-
}
|
|
1852
|
-
keep(window, "page");
|
|
1853
|
-
keep(framed2?.() ?? null, "frame");
|
|
1854
|
-
}
|
|
1855
|
-
function resume() {
|
|
1856
|
-
if (typeof window === "undefined")
|
|
1857
|
-
return;
|
|
1858
|
-
let target = null;
|
|
1859
|
-
try {
|
|
1860
|
-
const session = webStorage("session");
|
|
1861
|
-
const text2 = session?.getItem(SCROLL_KEY) ?? null;
|
|
1862
|
-
if (!session || text2 === null)
|
|
1863
|
-
return;
|
|
1864
|
-
const role = isDevknobsFrame() ? "frame" : "page";
|
|
1865
|
-
const { place, rest } = take(parseKept(text2), role, window.location.pathname, realNow());
|
|
1866
|
-
if (rest)
|
|
1867
|
-
session.setItem(SCROLL_KEY, JSON.stringify(stamped(rest, SCROLL_VERSION)));
|
|
1868
|
-
else
|
|
1869
|
-
session.removeItem(SCROLL_KEY);
|
|
1870
|
-
target = place;
|
|
1871
|
-
} catch {
|
|
1872
|
-
return;
|
|
1873
|
-
}
|
|
1874
|
-
if (target)
|
|
1875
|
-
hold2(window, target);
|
|
1876
|
-
}
|
|
1877
|
-
|
|
1878
1697
|
// src/engine/system.ts
|
|
1879
1698
|
var current = null;
|
|
1880
1699
|
var listeners = new Set;
|
|
@@ -1896,7 +1715,7 @@ function run(at, query, below) {
|
|
|
1896
1715
|
for (let i = at;i < ORDER.length; i++) {
|
|
1897
1716
|
const layer = layers.get(ORDER[i]);
|
|
1898
1717
|
if (layer)
|
|
1899
|
-
return layer(query, (
|
|
1718
|
+
return layer(query, (next) => run(i + 1, next, below));
|
|
1900
1719
|
}
|
|
1901
1720
|
return below.call(window, query);
|
|
1902
1721
|
}
|
|
@@ -1936,1615 +1755,10 @@ function still() {
|
|
|
1936
1755
|
return baseMatchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1937
1756
|
}
|
|
1938
1757
|
|
|
1939
|
-
// src/engine/mockdata.ts
|
|
1940
|
-
function sides2(top, right, bottom, left) {
|
|
1941
|
-
return { top, right, bottom, left };
|
|
1942
|
-
}
|
|
1943
|
-
function pill(kind, x, y, width, height) {
|
|
1944
|
-
return { kind, x, y, width, height };
|
|
1945
|
-
}
|
|
1946
|
-
function dot(kind, x, y, size) {
|
|
1947
|
-
return { kind, x: x - size / 2, y: y - size / 2, width: size, height: size };
|
|
1948
|
-
}
|
|
1949
|
-
var left = (at, length) => ({ side: "left", at, length });
|
|
1950
|
-
var right = (at, length, out) => ({
|
|
1951
|
-
side: "right",
|
|
1952
|
-
at,
|
|
1953
|
-
length,
|
|
1954
|
-
out
|
|
1955
|
-
});
|
|
1956
|
-
var top = (at, length, out) => ({
|
|
1957
|
-
side: "top",
|
|
1958
|
-
at,
|
|
1959
|
-
length,
|
|
1960
|
-
out
|
|
1961
|
-
});
|
|
1962
|
-
var IPHONE_LEFT = [left(185, 41.7), left(257.4, 67.6), left(343.2, 67.6)];
|
|
1963
|
-
function iphoneRight(control) {
|
|
1964
|
-
return [right(280.7, 106.9), right(control, 103.3, 1)];
|
|
1965
|
-
}
|
|
1966
|
-
var BODIES = {
|
|
1967
|
-
"iphone-18-pro": {
|
|
1968
|
-
bezel: sides2(15.7, 16, 15.7, 15.7),
|
|
1969
|
-
screenRadius: 62,
|
|
1970
|
-
bodyRadius: 77.7,
|
|
1971
|
-
out: 3,
|
|
1972
|
-
front: [pill("sensor", 154, 14.3, 94, 36.1)],
|
|
1973
|
-
buttons: [left(186, 41.7), left(258.3, 67.7), left(344, 68), right(281.7, 107, 2.7)]
|
|
1974
|
-
},
|
|
1975
|
-
"iphone-18-pro-max": {
|
|
1976
|
-
bezel: sides2(15.3, 15.3, 15, 15.3),
|
|
1977
|
-
screenRadius: 62,
|
|
1978
|
-
bodyRadius: 77.3,
|
|
1979
|
-
out: 2.7,
|
|
1980
|
-
front: [pill("sensor", 173.2, 14.5, 93.6, 35.8)],
|
|
1981
|
-
buttons: [left(186.3, 41.7), left(258.7, 67.7), left(344.3, 67.7), right(282, 106.7)]
|
|
1982
|
-
},
|
|
1983
|
-
"iphone-duo-closed": {
|
|
1984
|
-
bezel: sides2(16.3, 16, 16, 25.7),
|
|
1985
|
-
screenRadius: [8, 59, 59, 8],
|
|
1986
|
-
bodyRadius: [10, 75, 75, 10],
|
|
1987
|
-
out: 2.7,
|
|
1988
|
-
front: [dot("sensor", 418.35, 47.75, 36.3)],
|
|
1989
|
-
buttons: [right(202.7, 112.7), top(235, 65.7, 2.3), top(316, 65.7, 2.3)]
|
|
1990
|
-
},
|
|
1991
|
-
"iphone-duo-open": {
|
|
1992
|
-
bezel: sides2(20.3, 20.7, 20.7, 20.7),
|
|
1993
|
-
screenRadius: 55,
|
|
1994
|
-
bodyRadius: 75.7,
|
|
1995
|
-
out: 2.7,
|
|
1996
|
-
front: [],
|
|
1997
|
-
buttons: [left(134.3, 57), left(206.3, 65.7), top(202.3, 112.7)]
|
|
1998
|
-
},
|
|
1999
|
-
"iphone-air": {
|
|
2000
|
-
bezel: sides2(15.3, 15.3, 15.3, 15.3),
|
|
2001
|
-
screenRadius: 65,
|
|
2002
|
-
bodyRadius: 77.3,
|
|
2003
|
-
out: 2.7,
|
|
2004
|
-
front: [pill("sensor", 147.33, 20, 125.33, 36.67)],
|
|
2005
|
-
buttons: [left(185, 41.7), left(257.3, 67.7), left(343, 67.7), right(280.7, 106.7, 3)]
|
|
2006
|
-
},
|
|
2007
|
-
"iphone-17": {
|
|
2008
|
-
bezel: sides2(14.3, 14.7, 14.3, 14.7),
|
|
2009
|
-
screenRadius: 62,
|
|
2010
|
-
bodyRadius: 76.7,
|
|
2011
|
-
out: 3,
|
|
2012
|
-
front: [pill("sensor", 138.33, 14, 125.33, 36.67)],
|
|
2013
|
-
buttons: [left(185, 41.7), left(257.3, 67.7), left(342.7, 68), right(280.3, 107, 2.7)]
|
|
2014
|
-
},
|
|
2015
|
-
"iphone-17-pro": {
|
|
2016
|
-
bezel: sides2(15.7, 16, 15.7, 15.7),
|
|
2017
|
-
screenRadius: 62,
|
|
2018
|
-
bodyRadius: 77.7,
|
|
2019
|
-
out: 3,
|
|
2020
|
-
front: [pill("sensor", 138.33, 14, 125.33, 36.67)],
|
|
2021
|
-
buttons: [left(186, 41.7), left(258.3, 67.7), left(344, 67.7), right(281.7, 107, 2.7)]
|
|
2022
|
-
},
|
|
2023
|
-
"iphone-17-pro-max": {
|
|
2024
|
-
bezel: sides2(15.3, 15.3, 15, 15.3),
|
|
2025
|
-
screenRadius: 62,
|
|
2026
|
-
bodyRadius: 77.3,
|
|
2027
|
-
out: 2.7,
|
|
2028
|
-
front: [pill("sensor", 157.33, 14, 125.33, 36.67)],
|
|
2029
|
-
buttons: [left(186.3, 41.7), left(258.7, 67.7), left(344.3, 67.7), right(282, 106.7)]
|
|
2030
|
-
},
|
|
2031
|
-
"iphone-16": {
|
|
2032
|
-
bezel: sides2(19.7, 19.7, 19.8, 19.7),
|
|
2033
|
-
screenRadius: 55,
|
|
2034
|
-
bodyRadius: 75.5,
|
|
2035
|
-
out: 2.7,
|
|
2036
|
-
front: [pill("sensor", 134, 11.3, 124.9, 36.7)],
|
|
2037
|
-
buttons: [...IPHONE_LEFT, ...iphoneRight(529.5)]
|
|
2038
|
-
},
|
|
2039
|
-
"iphone-16-plus": {
|
|
2040
|
-
bezel: sides2(19.7, 19.7, 19.7, 19.7),
|
|
2041
|
-
screenRadius: 55,
|
|
2042
|
-
bodyRadius: 75.5,
|
|
2043
|
-
out: 2.7,
|
|
2044
|
-
front: [pill("sensor", 152.3, 11.3, 125.4, 36.7)],
|
|
2045
|
-
buttons: [...IPHONE_LEFT, ...iphoneRight(608.5)]
|
|
2046
|
-
},
|
|
2047
|
-
"iphone-16-pro": {
|
|
2048
|
-
bezel: sides2(14.7, 14.7, 14.4, 14.7),
|
|
2049
|
-
screenRadius: 62,
|
|
2050
|
-
bodyRadius: 77.9,
|
|
2051
|
-
out: 2.7,
|
|
2052
|
-
front: [pill("sensor", 138.33, 14, 125.33, 36.67)],
|
|
2053
|
-
buttons: [...IPHONE_LEFT, ...iphoneRight(541.3)]
|
|
2054
|
-
},
|
|
2055
|
-
"iphone-16-pro-max": {
|
|
2056
|
-
bezel: sides2(14.3, 14.3, 14.3, 14.3),
|
|
2057
|
-
screenRadius: 62,
|
|
2058
|
-
bodyRadius: 77.9,
|
|
2059
|
-
out: 2.7,
|
|
2060
|
-
front: [pill("sensor", 157.3, 14, 125.4, 36.7)],
|
|
2061
|
-
buttons: [...IPHONE_LEFT, ...iphoneRight(622.4)]
|
|
2062
|
-
},
|
|
2063
|
-
"iphone-se": {
|
|
2064
|
-
bezel: sides2(110.2, 28.1, 110.3, 28.1),
|
|
2065
|
-
screenRadius: 0,
|
|
2066
|
-
bodyRadius: 65.6,
|
|
2067
|
-
out: 2.6,
|
|
2068
|
-
front: [
|
|
2069
|
-
pill("slot", 149.5, -55.4, 76.1, 7.7),
|
|
2070
|
-
dot("lens", 119.3, -51.5, 14),
|
|
2071
|
-
{ ...dot("home", 187.5, 718, 69.9), key: 60 }
|
|
2072
|
-
],
|
|
2073
|
-
buttons: [left(94.6, 36), left(187.5, 68.1), left(268.3, 68.1), right(188, 68.1)]
|
|
2074
|
-
},
|
|
2075
|
-
"pixel-10": {
|
|
2076
|
-
bezel: sides2(21, 22.1, 21.4, 22.5),
|
|
2077
|
-
screenRadius: 55,
|
|
2078
|
-
bodyRadius: 77,
|
|
2079
|
-
out: 3.1,
|
|
2080
|
-
front: [dot("sensor", 205.6, 33.9, 29.7)],
|
|
2081
|
-
buttons: [right(269.6, 77), right(389.3, 134.2)]
|
|
2082
|
-
},
|
|
2083
|
-
"pixel-10-pro": {
|
|
2084
|
-
bezel: sides2(20, 20.7, 17.3, 19.7),
|
|
2085
|
-
screenRadius: 59,
|
|
2086
|
-
bodyRadius: 79,
|
|
2087
|
-
out: 3,
|
|
2088
|
-
front: [dot("sensor", 213.6, 34.3, 30.6)],
|
|
2089
|
-
buttons: [right(276.4, 78.4), right(399.1, 137)]
|
|
2090
|
-
},
|
|
2091
|
-
"pixel-10-pro-xl": {
|
|
2092
|
-
bezel: sides2(18.3, 20.3, 18, 20),
|
|
2093
|
-
screenRadius: 52,
|
|
2094
|
-
bodyRadius: 71,
|
|
2095
|
-
out: 2.3,
|
|
2096
|
-
front: [dot("sensor", 224, 34.8, 30.2)],
|
|
2097
|
-
buttons: [right(280.5, 77), right(401.2, 134.4)]
|
|
2098
|
-
},
|
|
2099
|
-
"pixel-10a": {
|
|
2100
|
-
bezel: sides2(24, 24.8, 24, 24.8),
|
|
2101
|
-
screenRadius: 55,
|
|
2102
|
-
bodyRadius: 79,
|
|
2103
|
-
out: 3.1,
|
|
2104
|
-
front: [dot("sensor", 205.2, 33.3, 30.5)],
|
|
2105
|
-
buttons: [right(273, 75.9), right(393.1, 132.7)]
|
|
2106
|
-
},
|
|
2107
|
-
"pixel-9": {
|
|
2108
|
-
bezel: sides2(21.9, 22.2, 21.9, 22.2),
|
|
2109
|
-
screenRadius: 55,
|
|
2110
|
-
bodyRadius: 77,
|
|
2111
|
-
out: 2.5,
|
|
2112
|
-
front: [dot("sensor", 205.5, 33, 32)],
|
|
2113
|
-
buttons: [right(290, 70), right(385, 135)]
|
|
2114
|
-
},
|
|
2115
|
-
"pixel-9-pro": {
|
|
2116
|
-
bezel: sides2(20.3, 20.3, 19, 20),
|
|
2117
|
-
screenRadius: 58,
|
|
2118
|
-
bodyRadius: 78,
|
|
2119
|
-
out: 2.3,
|
|
2120
|
-
front: [dot("sensor", 213.4, 33.7, 30.9)],
|
|
2121
|
-
buttons: [right(269.7, 77.7), right(392.1, 142.7)]
|
|
2122
|
-
},
|
|
2123
|
-
"pixel-9-pro-xl": {
|
|
2124
|
-
bezel: sides2(18.7, 19.3, 17.3, 19),
|
|
2125
|
-
screenRadius: 57,
|
|
2126
|
-
bodyRadius: 76,
|
|
2127
|
-
out: 2.3,
|
|
2128
|
-
front: [dot("sensor", 224, 32.8, 30.8)],
|
|
2129
|
-
buttons: [right(274.1, 75.7), right(393.8, 139.4)]
|
|
2130
|
-
},
|
|
2131
|
-
"ipad-mini": {
|
|
2132
|
-
bezel: sides2(60.6, 60.4, 60.6, 60.4),
|
|
2133
|
-
screenRadius: 21.5,
|
|
2134
|
-
bodyRadius: 77,
|
|
2135
|
-
out: 2.5,
|
|
2136
|
-
front: [dot("lens", 372, -35, 16)],
|
|
2137
|
-
buttons: [top(82.3, 64.6), top(159.7, 64.6), top(673.5, 109.9)]
|
|
2138
|
-
},
|
|
2139
|
-
"ipad-air-11": {
|
|
2140
|
-
bezel: sides2(53.5, 53.9, 53.5, 53.9),
|
|
2141
|
-
screenRadius: 18,
|
|
2142
|
-
bodyRadius: 66.5,
|
|
2143
|
-
out: 2.5,
|
|
2144
|
-
front: [dot("lens", 850.5, 540.6, 16)],
|
|
2145
|
-
buttons: [top(772.9, 89), right(75.1, 52.3), right(137.8, 52.3)]
|
|
2146
|
-
},
|
|
2147
|
-
"ipad-pro-13": {
|
|
2148
|
-
bezel: sides2(43.7, 44, 43.7, 44),
|
|
2149
|
-
screenRadius: 30,
|
|
2150
|
-
bodyRadius: 74.8,
|
|
2151
|
-
out: 2.5,
|
|
2152
|
-
front: [dot("lens", 1051.6, 688, 13.9)],
|
|
2153
|
-
buttons: [top(984.7, 62.7), right(74.3, 52.3), right(137, 52.3)]
|
|
2154
|
-
}
|
|
2155
|
-
};
|
|
2156
|
-
|
|
2157
|
-
// src/engine/browserui.ts
|
|
2158
|
-
var LAYOUTS = {
|
|
2159
|
-
safari: ["compact", "bottom", "top", "off"],
|
|
2160
|
-
chrome: ["top", "bottom", "off"]
|
|
2161
|
-
};
|
|
2162
|
-
var DUO_COVER = {
|
|
2163
|
-
column: 84,
|
|
2164
|
-
bottom: 98,
|
|
2165
|
-
minimized: 60,
|
|
2166
|
-
axis: 48,
|
|
2167
|
-
time: { y: 91.5, size: 15.75 },
|
|
2168
|
-
ring: { y: 129.9, radius: 18.9, stroke: 3.5 },
|
|
2169
|
-
buttons: [174.2, 234.2],
|
|
2170
|
-
capsule: 102,
|
|
2171
|
-
gap: 34,
|
|
2172
|
-
inset: 24,
|
|
2173
|
-
across: {
|
|
2174
|
-
top: 80,
|
|
2175
|
-
minimized: 26,
|
|
2176
|
-
side: 7.33,
|
|
2177
|
-
address: { x: 209, width: 260 },
|
|
2178
|
-
end: 149.33
|
|
2179
|
-
}
|
|
2180
|
-
};
|
|
2181
|
-
var DUO_INNER = {
|
|
2182
|
-
top: 80,
|
|
2183
|
-
minimized: 51,
|
|
2184
|
-
axis: 47.67,
|
|
2185
|
-
time: { x: 99.83, y: 47.4, size: 15.75 },
|
|
2186
|
-
ring: { y: 47.9, radius: 18.9, stroke: 3.5 },
|
|
2187
|
-
side: 6,
|
|
2188
|
-
address: { landscape: { x: 295, width: 361 }, portrait: { x: 184, width: 241.5 } },
|
|
2189
|
-
end: 232,
|
|
2190
|
-
pill: 23.5
|
|
2191
|
-
};
|
|
2192
|
-
var DUO_ROW = 26;
|
|
2193
|
-
var DUO_PILL = { height: 20, size: 12, pad: 15 };
|
|
2194
|
-
function runsUnderBars(id) {
|
|
2195
|
-
return !SAFARI[id]?.duo;
|
|
2196
|
-
}
|
|
2197
|
-
var DUO_LAYOUTS = ["compact", "off"];
|
|
2198
|
-
var STATUS_PRO = { time: 73.83, right: 369.67 };
|
|
2199
|
-
var STATUS_MAX = { time: 83.17, right: 401.67 };
|
|
2200
|
-
var SAFARI = {
|
|
2201
|
-
"iphone-18-pro": { top: 62, side: 62, faceId: true },
|
|
2202
|
-
"iphone-18-pro-max": { top: 62, side: 62, faceId: true },
|
|
2203
|
-
"iphone-duo-closed": { top: 0, side: 0, faceId: true, duo: "cover" },
|
|
2204
|
-
"iphone-duo-open": { top: DUO_INNER.top, side: 0, faceId: true, duo: "inner" },
|
|
2205
|
-
"iphone-air": { top: 68, side: 68, faceId: true, status: { time: 77.17, right: 387.67 } },
|
|
2206
|
-
"iphone-17": { top: 62, side: 62, faceId: true, status: STATUS_PRO },
|
|
2207
|
-
"iphone-17-pro": { top: 62, side: 62, faceId: true, status: STATUS_PRO },
|
|
2208
|
-
"iphone-17-pro-max": { top: 62, side: 62, faceId: true, status: STATUS_MAX },
|
|
2209
|
-
"iphone-16": { top: 59, side: 59, faceId: true },
|
|
2210
|
-
"iphone-16-plus": { top: 59, side: 59, faceId: true },
|
|
2211
|
-
"iphone-16-pro": { top: 62, side: 62, faceId: true, status: STATUS_PRO },
|
|
2212
|
-
"iphone-16-pro-max": { top: 62, side: 62, faceId: true, status: STATUS_MAX },
|
|
2213
|
-
"iphone-se": { top: 20, side: 0, faceId: false }
|
|
2214
|
-
};
|
|
2215
|
-
var CHROME = {
|
|
2216
|
-
"pixel-10": { top: 69, tall: 923 },
|
|
2217
|
-
"pixel-10-pro": { top: 69 },
|
|
2218
|
-
"pixel-10-pro-xl": { top: 70, tall: 997 },
|
|
2219
|
-
"pixel-10a": { top: 68, tall: 923 },
|
|
2220
|
-
"pixel-9": { top: 66, tall: 923 },
|
|
2221
|
-
"pixel-9-pro": { top: 68 },
|
|
2222
|
-
"pixel-9-pro-xl": { top: 66, tall: 997 }
|
|
2223
|
-
};
|
|
2224
|
-
var SAFARI_BARS = {
|
|
2225
|
-
compact: 98,
|
|
2226
|
-
bottom: 158,
|
|
2227
|
-
bottomSe: 152,
|
|
2228
|
-
topBar: 60,
|
|
2229
|
-
topBottom: 92,
|
|
2230
|
-
pill: 58,
|
|
2231
|
-
topPill: 44,
|
|
2232
|
-
landscape: 64
|
|
2233
|
-
};
|
|
2234
|
-
var CHROME_BARS = { toolbar: 56, chin: 24, landscapeTop: 24 };
|
|
2235
|
-
function platformOf(id) {
|
|
2236
|
-
if (SAFARI[id])
|
|
2237
|
-
return "safari";
|
|
2238
|
-
if (CHROME[id])
|
|
2239
|
-
return "chrome";
|
|
2240
|
-
return null;
|
|
2241
|
-
}
|
|
2242
|
-
function layoutOptions(id) {
|
|
2243
|
-
if (SAFARI[id]?.duo)
|
|
2244
|
-
return DUO_LAYOUTS;
|
|
2245
|
-
const platform = platformOf(id);
|
|
2246
|
-
return platform ? LAYOUTS[platform] : [];
|
|
2247
|
-
}
|
|
2248
|
-
function layoutOf(id, browser) {
|
|
2249
|
-
const options = layoutOptions(id);
|
|
2250
|
-
const fallback = options[0];
|
|
2251
|
-
if (!fallback)
|
|
2252
|
-
return null;
|
|
2253
|
-
return browser !== "auto" && options.includes(browser) ? browser : fallback;
|
|
2254
|
-
}
|
|
2255
|
-
function rect(x, y, width, height) {
|
|
2256
|
-
return { x, y, width, height };
|
|
2257
|
-
}
|
|
2258
|
-
function viewportOf(device, orientation, layout, minimized, edge = false) {
|
|
2259
|
-
const { width: W, height: H } = turn(device, orientation);
|
|
2260
|
-
const whole = rect(0, 0, W, H);
|
|
2261
|
-
if (!layout || layout === "off")
|
|
2262
|
-
return whole;
|
|
2263
|
-
const safari = SAFARI[device.id];
|
|
2264
|
-
if (safari?.duo === "cover" && orientation === "landscape") {
|
|
2265
|
-
const { across } = DUO_COVER;
|
|
2266
|
-
const top2 = minimized ? across.minimized : across.top;
|
|
2267
|
-
return rect(0, top2, W, H - top2);
|
|
2268
|
-
}
|
|
2269
|
-
if (safari?.duo === "cover") {
|
|
2270
|
-
const bottom = minimized ? DUO_COVER.minimized : DUO_COVER.bottom;
|
|
2271
|
-
return rect(0, 0, W - DUO_COVER.column, H - bottom);
|
|
2272
|
-
}
|
|
2273
|
-
if (safari?.duo === "inner") {
|
|
2274
|
-
const top2 = minimized ? DUO_INNER.minimized : DUO_INNER.top;
|
|
2275
|
-
return rect(0, top2, W, H - top2);
|
|
2276
|
-
}
|
|
2277
|
-
if (safari) {
|
|
2278
|
-
if (edge && orientation === "landscape")
|
|
2279
|
-
return rect(safari.side, 0, W - 2 * safari.side, H);
|
|
2280
|
-
if (orientation === "landscape") {
|
|
2281
|
-
const top2 = minimized ? 0 : SAFARI_BARS.landscape;
|
|
2282
|
-
return rect(safari.side, top2, W - 2 * safari.side, H - top2);
|
|
2283
|
-
}
|
|
2284
|
-
const T = safari.top;
|
|
2285
|
-
if (layout === "top") {
|
|
2286
|
-
const top2 = T + (minimized ? SAFARI_BARS.topPill : SAFARI_BARS.topBar);
|
|
2287
|
-
const bottom = minimized ? H : H - SAFARI_BARS.topBottom;
|
|
2288
|
-
return rect(0, top2, W, bottom - top2);
|
|
2289
|
-
}
|
|
2290
|
-
const card = safari.faceId ? SAFARI_BARS.bottom : SAFARI_BARS.bottomSe;
|
|
2291
|
-
const bar = minimized ? SAFARI_BARS.pill : layout === "bottom" ? card : SAFARI_BARS.compact;
|
|
2292
|
-
return rect(0, T, W, H - bar - T);
|
|
2293
|
-
}
|
|
2294
|
-
const chrome = CHROME[device.id];
|
|
2295
|
-
if (!chrome)
|
|
2296
|
-
return whole;
|
|
2297
|
-
const toolbar = minimized ? 0 : CHROME_BARS.toolbar;
|
|
2298
|
-
if (orientation === "landscape") {
|
|
2299
|
-
const top2 = CHROME_BARS.landscapeTop + toolbar;
|
|
2300
|
-
return rect(0, top2, W, H - top2);
|
|
2301
|
-
}
|
|
2302
|
-
const tall = chrome.tall ?? H;
|
|
2303
|
-
const chin = minimized ? 0 : CHROME_BARS.chin;
|
|
2304
|
-
const height = tall - chrome.top - toolbar - chin;
|
|
2305
|
-
return rect(0, chrome.top + (layout === "top" ? toolbar : 0), W, height);
|
|
2306
|
-
}
|
|
2307
|
-
function capsule(kind, box, marks = []) {
|
|
2308
|
-
return { kind, ...box, radius: Math.min(box.width, box.height) / 2, marks };
|
|
2309
|
-
}
|
|
2310
|
-
function mark(glyph, x, y) {
|
|
2311
|
-
return { glyph, x, y };
|
|
2312
|
-
}
|
|
2313
|
-
var SCRIM = [
|
|
2314
|
-
[0, 0.81],
|
|
2315
|
-
[20, 0.67],
|
|
2316
|
-
[40, 0.41],
|
|
2317
|
-
[60, 0.16],
|
|
2318
|
-
[80, 0.03],
|
|
2319
|
-
[100, 0]
|
|
2320
|
-
];
|
|
2321
|
-
function alphaAt(fade, y) {
|
|
2322
|
-
const at = y - fade.y;
|
|
2323
|
-
const { stops } = fade;
|
|
2324
|
-
const first = stops[0];
|
|
2325
|
-
if (!first || at <= first.at)
|
|
2326
|
-
return first?.alpha ?? 0;
|
|
2327
|
-
for (let i = 1;i < stops.length; i++) {
|
|
2328
|
-
const from = stops[i - 1];
|
|
2329
|
-
const to = stops[i];
|
|
2330
|
-
if (!from || !to || at > to.at)
|
|
2331
|
-
continue;
|
|
2332
|
-
return from.alpha + (to.alpha - from.alpha) * (at - from.at) / (to.at - from.at || 1);
|
|
2333
|
-
}
|
|
2334
|
-
return stops.at(-1)?.alpha ?? 0;
|
|
2335
|
-
}
|
|
2336
|
-
function sensorMiddle(id) {
|
|
2337
|
-
const sensor = BODIES[id]?.front.find((front) => front.kind === "sensor");
|
|
2338
|
-
if (!sensor)
|
|
2339
|
-
return null;
|
|
2340
|
-
return { x: sensor.x + sensor.width / 2, y: sensor.y + sensor.height / 2, width: sensor.width };
|
|
2341
|
-
}
|
|
2342
|
-
var SAFARI_TEXT = { field: 17, pill: 13 };
|
|
2343
|
-
var SAFARI_PILL = { height: 32, size: SAFARI_TEXT.pill, pad: 33 };
|
|
2344
|
-
var BOTTOM_ROW = [0.1032, 0.3056, 0.4965, 0.6925, 0.8872];
|
|
2345
|
-
var TOP_ROW = [0.0884, 0.2986, 0.4962, 0.6994, 0.9012];
|
|
2346
|
-
var ROW = ["back", "forward", "share", "bookmarks", "tabs"];
|
|
2347
|
-
function domainPill(x, top2, look = SAFARI_PILL) {
|
|
2348
|
-
const { height, size, pad } = look;
|
|
2349
|
-
return {
|
|
2350
|
-
kind: "pill",
|
|
2351
|
-
x,
|
|
2352
|
-
y: top2,
|
|
2353
|
-
width: 0,
|
|
2354
|
-
height,
|
|
2355
|
-
radius: height / 2,
|
|
2356
|
-
marks: [],
|
|
2357
|
-
text: { x, y: top2 + height / 2, size, pad }
|
|
2358
|
-
};
|
|
2359
|
-
}
|
|
2360
|
-
function address(kind, box, page, reload) {
|
|
2361
|
-
const y = box.y + box.height / 2;
|
|
2362
|
-
return {
|
|
2363
|
-
...capsule(kind, box, [
|
|
2364
|
-
mark("page", box.x + page, y),
|
|
2365
|
-
mark("reload", box.x + box.width - reload, y)
|
|
2366
|
-
]),
|
|
2367
|
-
text: { x: box.x + box.width / 2, y, size: SAFARI_TEXT.field }
|
|
2368
|
-
};
|
|
2369
|
-
}
|
|
2370
|
-
function acrossRow(left2, right2, y) {
|
|
2371
|
-
const s = left2;
|
|
2372
|
-
const row = (x2, width2) => rect(x2, y, width2, 44);
|
|
2373
|
-
const end = row(right2 - 10 - 132, 132);
|
|
2374
|
-
const middle = y + 22;
|
|
2375
|
-
const [from, to] = [s + 66 + 44 + 8, end.x - 8];
|
|
2376
|
-
const width = Math.min(318, to - from);
|
|
2377
|
-
const x = Math.min(Math.max((left2 + right2) / 2 - width / 2, from), to - width);
|
|
2378
|
-
return [
|
|
2379
|
-
capsule("glass", row(s + 10, 44), [mark("back", s + 32, middle)]),
|
|
2380
|
-
capsule("glass", row(s + 66, 44), [mark("bookmarks", s + 88, middle)]),
|
|
2381
|
-
address("glass", row(x, width), 24, 22),
|
|
2382
|
-
capsule("glass", end, [
|
|
2383
|
-
mark("share", end.x + 22, middle),
|
|
2384
|
-
mark("plus", end.x + 66, middle),
|
|
2385
|
-
mark("tabs", end.x + 110, middle)
|
|
2386
|
-
])
|
|
2387
|
-
];
|
|
2388
|
-
}
|
|
2389
|
-
function duoRow(side, field, endX, end) {
|
|
2390
|
-
const y = DUO_ROW;
|
|
2391
|
-
const middle = y + 22;
|
|
2392
|
-
const row = (x, width) => rect(x, y, width, 44);
|
|
2393
|
-
return [
|
|
2394
|
-
capsule("glass", row(side + 10, 44), [mark("back", side + 32, middle)]),
|
|
2395
|
-
capsule("glass", row(side + 66, 44), [mark("bookmarks", side + 88, middle)]),
|
|
2396
|
-
address("glass", row(field.x, field.width), 22, 24.5),
|
|
2397
|
-
capsule("glass", row(endX, 44 * end.length), end.map((glyph, at) => mark(glyph, endX + 22 + 44 * at, middle)))
|
|
2398
|
-
];
|
|
2399
|
-
}
|
|
2400
|
-
function duoCover(bars, W, H, orientation, minimized) {
|
|
2401
|
-
const c = DUO_COVER;
|
|
2402
|
-
if (orientation === "landscape") {
|
|
2403
|
-
const { across } = c;
|
|
2404
|
-
if (minimized)
|
|
2405
|
-
bars.shapes = [domainPill(W / 2, (across.minimized - DUO_PILL.height) / 2, DUO_PILL)];
|
|
2406
|
-
else
|
|
2407
|
-
bars.shapes = duoRow(across.side, across.address, W - across.end, ["share", "plus", "tabs"]);
|
|
2408
|
-
return bars;
|
|
2409
|
-
}
|
|
2410
|
-
const page = W - c.column;
|
|
2411
|
-
const x = W - c.axis;
|
|
2412
|
-
bars.column = { x, strip: false, time: { x, ...c.time }, ring: { ...c.ring } };
|
|
2413
|
-
if (minimized) {
|
|
2414
|
-
bars.shapes = [domainPill(page / 2, H - 46)];
|
|
2415
|
-
return bars;
|
|
2416
|
-
}
|
|
2417
|
-
const button = (y, glyph) => capsule("glass", rect(x - 24, y, 48, 48), [mark(glyph, x, y + 24)]);
|
|
2418
|
-
const [back = 0, reader = 0] = c.buttons;
|
|
2419
|
-
const low = H - c.gap - c.capsule;
|
|
2420
|
-
bars.shapes = [
|
|
2421
|
-
address("glass", rect(c.inset, H - c.gap - 48, page - 2 * c.inset, 48), 24, 24),
|
|
2422
|
-
button(back, "back"),
|
|
2423
|
-
button(reader, "bookmarks"),
|
|
2424
|
-
capsule("glass", rect(x - 24, low, 48, c.capsule), [mark("plus", x, low + 24), mark("tabs", x, H - c.gap - 24)])
|
|
2425
|
-
];
|
|
2426
|
-
return bars;
|
|
2427
|
-
}
|
|
2428
|
-
function duoInner(bars, W, orientation, minimized) {
|
|
2429
|
-
const d = DUO_INNER;
|
|
2430
|
-
if (minimized) {
|
|
2431
|
-
bars.shapes = [domainPill(W / 2, d.pill, DUO_PILL)];
|
|
2432
|
-
return bars;
|
|
2433
|
-
}
|
|
2434
|
-
bars.column = { x: W - d.axis, strip: true, time: { ...d.time, x: W - d.time.x }, ring: { ...d.ring } };
|
|
2435
|
-
bars.shapes = duoRow(d.side, d.address[orientation], W - d.end, ["plus", "tabs"]);
|
|
2436
|
-
return bars;
|
|
2437
|
-
}
|
|
2438
|
-
function safariBars(device, spec, orientation, layout, minimized) {
|
|
2439
|
-
const { width: W, height: H } = turn(device, orientation);
|
|
2440
|
-
const bars = {
|
|
2441
|
-
platform: "safari",
|
|
2442
|
-
layout,
|
|
2443
|
-
screen: device,
|
|
2444
|
-
orientation,
|
|
2445
|
-
minimized,
|
|
2446
|
-
status: null,
|
|
2447
|
-
column: null,
|
|
2448
|
-
shapes: [],
|
|
2449
|
-
chin: null,
|
|
2450
|
-
hairline: null,
|
|
2451
|
-
scrim: null,
|
|
2452
|
-
edge: false
|
|
2453
|
-
};
|
|
2454
|
-
if (spec.duo === "cover")
|
|
2455
|
-
return duoCover(bars, W, H, orientation, minimized);
|
|
2456
|
-
if (spec.duo === "inner")
|
|
2457
|
-
return duoInner(bars, W, orientation, minimized);
|
|
2458
|
-
if (orientation === "landscape") {
|
|
2459
|
-
if (!minimized)
|
|
2460
|
-
bars.shapes = acrossRow(spec.side, W - spec.side, 10);
|
|
2461
|
-
return bars;
|
|
2462
|
-
}
|
|
2463
|
-
bars.status = safariStatus(device.id, spec, W);
|
|
2464
|
-
const page = viewportOf(device, orientation, layout, minimized);
|
|
2465
|
-
const T = spec.top;
|
|
2466
|
-
if (minimized) {
|
|
2467
|
-
bars.shapes = [domainPill(W / 2, layout === "top" ? T : H - 46)];
|
|
2468
|
-
const stops = SCRIM.map(([at, alpha]) => ({ at, alpha }));
|
|
2469
|
-
bars.scrim = { y: 0, height: 100, stops, at: { x: W / 2, y: page.y + 1 } };
|
|
2470
|
-
return bars;
|
|
2471
|
-
}
|
|
2472
|
-
if (layout === "compact") {
|
|
2473
|
-
const y = H - 82;
|
|
2474
|
-
const middle = y + 24;
|
|
2475
|
-
bars.shapes = [
|
|
2476
|
-
capsule("glass", rect(34, y, 48, 48), [mark("back", 58, middle)]),
|
|
2477
|
-
address("glass", rect(90, y, W - 180, 48), 24, 22),
|
|
2478
|
-
capsule("glass", rect(W - 82, y, 48, 48), [mark("tabs", W - 58, middle)])
|
|
2479
|
-
];
|
|
2480
|
-
return bars;
|
|
2481
|
-
}
|
|
2482
|
-
if (layout === "bottom") {
|
|
2483
|
-
const inset2 = spec.faceId ? 14 : 8;
|
|
2484
|
-
const card = rect(inset2, H - inset2 - 128, W - 2 * inset2, 128);
|
|
2485
|
-
const field = rect(card.x + 22, card.y + 16, card.width - 44, 48);
|
|
2486
|
-
const row2 = card.y + 92;
|
|
2487
|
-
bars.shapes = [
|
|
2488
|
-
{
|
|
2489
|
-
kind: "card",
|
|
2490
|
-
...card,
|
|
2491
|
-
radius: 40,
|
|
2492
|
-
marks: ROW.map((glyph, at) => {
|
|
2493
|
-
return mark(glyph, card.x + card.width * (BOTTOM_ROW[at] ?? 0), row2);
|
|
2494
|
-
})
|
|
2495
|
-
},
|
|
2496
|
-
address("field", field, 18, 16)
|
|
2497
|
-
];
|
|
2498
|
-
return bars;
|
|
2499
|
-
}
|
|
2500
|
-
const top2 = rect(16, T, W - 32, 44);
|
|
2501
|
-
const bottom = rect(28, H - 76, W - 56, 48);
|
|
2502
|
-
const row = bottom.y + 24;
|
|
2503
|
-
bars.shapes = [
|
|
2504
|
-
address("glass", top2, 23, 18),
|
|
2505
|
-
capsule("glass", bottom, ROW.map((glyph, at) => mark(glyph, bottom.x + bottom.width * (TOP_ROW[at] ?? 0), row)))
|
|
2506
|
-
];
|
|
2507
|
-
return bars;
|
|
2508
|
-
}
|
|
2509
|
-
function safariStatus(id, spec, W) {
|
|
2510
|
-
const island = sensorMiddle(id);
|
|
2511
|
-
if (!spec.faceId) {
|
|
2512
|
-
return {
|
|
2513
|
-
height: spec.top,
|
|
2514
|
-
time: { x: W / 2, y: 10, size: 15 },
|
|
2515
|
-
icons: { x: 6, y: 10, align: "start" },
|
|
2516
|
-
battery: { x: W - 7, y: 10 },
|
|
2517
|
-
large: false
|
|
2518
|
-
};
|
|
2519
|
-
}
|
|
2520
|
-
const large = W >= 420;
|
|
2521
|
-
const size = large ? 19 : 18;
|
|
2522
|
-
if (!island) {
|
|
2523
|
-
const y = spec.top / 2 + 2;
|
|
2524
|
-
return {
|
|
2525
|
-
height: spec.top,
|
|
2526
|
-
time: { x: 58, y, size },
|
|
2527
|
-
icons: { x: W - 36, y, align: "end" },
|
|
2528
|
-
large
|
|
2529
|
-
};
|
|
2530
|
-
}
|
|
2531
|
-
const left2 = island.x - island.width / 2;
|
|
2532
|
-
if (left2 > W / 2) {
|
|
2533
|
-
return {
|
|
2534
|
-
height: spec.top,
|
|
2535
|
-
time: { x: 52, y: island.y, size },
|
|
2536
|
-
icons: { x: left2 - 12, y: island.y, align: "end" },
|
|
2537
|
-
large
|
|
2538
|
-
};
|
|
2539
|
-
}
|
|
2540
|
-
return {
|
|
2541
|
-
height: spec.top,
|
|
2542
|
-
time: { x: spec.status?.time ?? left2 * 0.535, y: island.y, size },
|
|
2543
|
-
icons: { x: spec.status?.right ?? W - (large ? 38.33 : 32.33), y: island.y, align: "end" },
|
|
2544
|
-
large
|
|
2545
|
-
};
|
|
2546
|
-
}
|
|
2547
|
-
function chromeStatus(id, height, W, orientation) {
|
|
2548
|
-
const hole = orientation === "portrait" ? sensorMiddle(id) : null;
|
|
2549
|
-
const y = hole?.y ?? height / 2;
|
|
2550
|
-
const side = orientation === "portrait" ? 26 : 56;
|
|
2551
|
-
return {
|
|
2552
|
-
height,
|
|
2553
|
-
time: { x: side, y, size: 14 },
|
|
2554
|
-
icons: { x: W - side, y, align: "end" },
|
|
2555
|
-
large: false
|
|
2556
|
-
};
|
|
2557
|
-
}
|
|
2558
|
-
function chromeBars(device, spec, orientation, layout, minimized) {
|
|
2559
|
-
const { width: W, height: H } = turn(device, orientation);
|
|
2560
|
-
const portrait = orientation === "portrait";
|
|
2561
|
-
const statusHeight = portrait ? spec.top : CHROME_BARS.landscapeTop;
|
|
2562
|
-
const page = viewportOf(device, orientation, layout, minimized);
|
|
2563
|
-
const bars = {
|
|
2564
|
-
platform: "chrome",
|
|
2565
|
-
layout,
|
|
2566
|
-
screen: device,
|
|
2567
|
-
orientation,
|
|
2568
|
-
minimized,
|
|
2569
|
-
status: chromeStatus(device.id, statusHeight, W, orientation),
|
|
2570
|
-
column: null,
|
|
2571
|
-
shapes: [],
|
|
2572
|
-
chin: null,
|
|
2573
|
-
hairline: null,
|
|
2574
|
-
scrim: null,
|
|
2575
|
-
edge: false
|
|
2576
|
-
};
|
|
2577
|
-
if (minimized)
|
|
2578
|
-
return bars;
|
|
2579
|
-
const atTop = layout === "top" || !portrait;
|
|
2580
|
-
const toolbarY = atTop ? statusHeight : page.y + page.height;
|
|
2581
|
-
const toolbar = rect(0, toolbarY, W, CHROME_BARS.toolbar);
|
|
2582
|
-
const under = toolbarY + CHROME_BARS.toolbar;
|
|
2583
|
-
const chin = atTop ? page.y + page.height : under;
|
|
2584
|
-
bars.chin = portrait ? rect(0, chin, W, H - chin) : null;
|
|
2585
|
-
bars.hairline = rect(0, atTop ? under : toolbarY, W, 1);
|
|
2586
|
-
const middle = toolbarY + CHROME_BARS.toolbar / 2;
|
|
2587
|
-
const menu = W - 8 - 24;
|
|
2588
|
-
const tabs = menu - 48;
|
|
2589
|
-
const plus = tabs - 24 - 26;
|
|
2590
|
-
const pillLeft = 48 + 4;
|
|
2591
|
-
const pillRight = plus - 26 - 4;
|
|
2592
|
-
const pill2 = rect(pillLeft, middle - 20, pillRight - pillLeft, 40);
|
|
2593
|
-
bars.shapes = [
|
|
2594
|
-
{
|
|
2595
|
-
kind: "toolbar",
|
|
2596
|
-
...toolbar,
|
|
2597
|
-
radius: 0,
|
|
2598
|
-
marks: [
|
|
2599
|
-
mark("home", 24, middle),
|
|
2600
|
-
mark("plus", plus, middle),
|
|
2601
|
-
mark("switcher", tabs, middle),
|
|
2602
|
-
mark("menu", menu, middle)
|
|
2603
|
-
]
|
|
2604
|
-
},
|
|
2605
|
-
{
|
|
2606
|
-
...capsule("field", pill2, [mark("tune", pill2.x + 4 + 14, middle)]),
|
|
2607
|
-
text: { x: pill2.x + 4 + 28 + 4, y: middle, size: 16 }
|
|
2608
|
-
}
|
|
2609
|
-
];
|
|
2610
|
-
return bars;
|
|
2611
|
-
}
|
|
2612
|
-
function barsOf(device, orientation, layout, minimized, edge = false) {
|
|
2613
|
-
if (!layout || layout === "off")
|
|
2614
|
-
return null;
|
|
2615
|
-
const safari = SAFARI[device.id];
|
|
2616
|
-
if (safari) {
|
|
2617
|
-
const bars = safariBars(device, safari, orientation, layout, minimized);
|
|
2618
|
-
const upright = orientation === "portrait" || safari.duo !== undefined;
|
|
2619
|
-
return { ...bars, edge: edge || upright };
|
|
2620
|
-
}
|
|
2621
|
-
const chrome = CHROME[device.id];
|
|
2622
|
-
if (chrome)
|
|
2623
|
-
return chromeBars(device, chrome, orientation, layout, minimized);
|
|
2624
|
-
return null;
|
|
2625
|
-
}
|
|
2626
|
-
var BARS_DOWN = 16;
|
|
2627
|
-
var BARS_UP = 40;
|
|
2628
|
-
var BARS_TOP = 1;
|
|
2629
|
-
var BARS_LOCK = 450;
|
|
2630
|
-
var BARS_START = { minimized: false, anchor: 0, y: 0, lockUntil: 0 };
|
|
2631
|
-
function barsStep(state, event) {
|
|
2632
|
-
if (event.type === "navigate")
|
|
2633
|
-
return BARS_START;
|
|
2634
|
-
if (event.type === "tap")
|
|
2635
|
-
return { ...state, minimized: false, anchor: state.y };
|
|
2636
|
-
if (event.type === "resize")
|
|
2637
|
-
return { ...state, lockUntil: event.time + BARS_LOCK };
|
|
2638
|
-
const { y, time } = event;
|
|
2639
|
-
const room = event.room ?? 0;
|
|
2640
|
-
const near = state.minimized && room > 0 && y - room <= BARS_TOP;
|
|
2641
|
-
if (near)
|
|
2642
|
-
return { ...state, minimized: false, y, anchor: y };
|
|
2643
|
-
if (time < state.lockUntil)
|
|
2644
|
-
return { ...state, y, anchor: y };
|
|
2645
|
-
if (y <= BARS_TOP)
|
|
2646
|
-
return { ...state, minimized: false, y, anchor: y };
|
|
2647
|
-
if (state.minimized) {
|
|
2648
|
-
const anchor2 = Math.max(state.anchor, y);
|
|
2649
|
-
if (anchor2 - y >= BARS_UP)
|
|
2650
|
-
return { ...state, minimized: false, y, anchor: y };
|
|
2651
|
-
return { ...state, y, anchor: anchor2 };
|
|
2652
|
-
}
|
|
2653
|
-
const anchor = Math.min(state.anchor, y);
|
|
2654
|
-
const left2 = room > 0 ? Math.min(y, event.rest ?? Infinity) : y;
|
|
2655
|
-
const clear = left2 - 2 * room >= BARS_DOWN;
|
|
2656
|
-
if (y - anchor >= BARS_DOWN && clear)
|
|
2657
|
-
return { ...state, minimized: true, y, anchor: y };
|
|
2658
|
-
return { ...state, y, anchor };
|
|
2659
|
-
}
|
|
2660
|
-
|
|
2661
|
-
// src/engine/ua.ts
|
|
2662
|
-
var CHROME2 = "154.0.8037.98";
|
|
2663
|
-
var EDGE = "154.0.4258.53";
|
|
2664
|
-
var SAFARI2 = "27.0";
|
|
2665
|
-
var FIREFOX = "157.0";
|
|
2666
|
-
var GREASE = { brand: "Not/A)Brand", version: "24.0.0.0" };
|
|
2667
|
-
var APPLE = "Apple Computer, Inc.";
|
|
2668
|
-
var GOOGLE = "Google Inc.";
|
|
2669
|
-
function major(version) {
|
|
2670
|
-
return version.split(".")[0] ?? version;
|
|
2671
|
-
}
|
|
2672
|
-
function chromeAgent(system, mobile = false) {
|
|
2673
|
-
const browser = `Chrome/${major(CHROME2)}.0.0.0 ${mobile ? "Mobile " : ""}Safari/537.36`;
|
|
2674
|
-
return `Mozilla/5.0 (${system}) AppleWebKit/537.36 (KHTML, like Gecko) ${browser}`;
|
|
2675
|
-
}
|
|
2676
|
-
function chromium(own, hints) {
|
|
2677
|
-
const full = [{ brand: "Chromium", version: CHROME2 }, GREASE, ...own ? [own] : []];
|
|
2678
|
-
return {
|
|
2679
|
-
brands: full.map(({ brand, version }) => ({ brand, version: major(version) })),
|
|
2680
|
-
hints: { ...hints, fullVersionList: full, uaFullVersion: own?.version ?? CHROME2 }
|
|
2681
|
-
};
|
|
2682
|
-
}
|
|
2683
|
-
var CHROME_BRAND = { brand: "Google Chrome", version: CHROME2 };
|
|
2684
|
-
var DESKTOP = { model: "", bitness: "64" };
|
|
2685
|
-
var WINDOWS = { ...DESKTOP, platformVersion: "19.0.0", architecture: "x86" };
|
|
2686
|
-
var MAC_SAFARI = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/${SAFARI2} Safari/605.1.15`;
|
|
2687
|
-
var UA_PRESETS = [
|
|
2688
|
-
{
|
|
2689
|
-
id: "iphone-safari",
|
|
2690
|
-
label: "iPhone Safari",
|
|
2691
|
-
userAgent: `Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/${SAFARI2} Mobile/15E148 Safari/604.1`,
|
|
2692
|
-
platform: "iPhone",
|
|
2693
|
-
vendor: APPLE,
|
|
2694
|
-
mobile: true,
|
|
2695
|
-
brands: [],
|
|
2696
|
-
uaPlatform: "iOS",
|
|
2697
|
-
maxTouchPoints: 5
|
|
2698
|
-
},
|
|
2699
|
-
{
|
|
2700
|
-
id: "android-chrome",
|
|
2701
|
-
label: "Android Chrome",
|
|
2702
|
-
userAgent: chromeAgent("Linux; Android 10; K", true),
|
|
2703
|
-
platform: "Linux armv81",
|
|
2704
|
-
vendor: GOOGLE,
|
|
2705
|
-
mobile: true,
|
|
2706
|
-
uaPlatform: "Android",
|
|
2707
|
-
maxTouchPoints: 5,
|
|
2708
|
-
...chromium(CHROME_BRAND, {
|
|
2709
|
-
platformVersion: "16.0.0",
|
|
2710
|
-
model: "Pixel 10",
|
|
2711
|
-
architecture: "",
|
|
2712
|
-
bitness: ""
|
|
2713
|
-
})
|
|
2714
|
-
},
|
|
2715
|
-
{
|
|
2716
|
-
id: "ipad-safari",
|
|
2717
|
-
label: "iPad Safari",
|
|
2718
|
-
userAgent: MAC_SAFARI,
|
|
2719
|
-
platform: "MacIntel",
|
|
2720
|
-
vendor: APPLE,
|
|
2721
|
-
mobile: false,
|
|
2722
|
-
brands: [],
|
|
2723
|
-
uaPlatform: "iOS",
|
|
2724
|
-
maxTouchPoints: 5
|
|
2725
|
-
},
|
|
2726
|
-
{
|
|
2727
|
-
id: "mac-safari",
|
|
2728
|
-
label: "Mac Safari",
|
|
2729
|
-
userAgent: MAC_SAFARI,
|
|
2730
|
-
platform: "MacIntel",
|
|
2731
|
-
vendor: APPLE,
|
|
2732
|
-
mobile: false,
|
|
2733
|
-
brands: [],
|
|
2734
|
-
uaPlatform: "macOS",
|
|
2735
|
-
maxTouchPoints: 0
|
|
2736
|
-
},
|
|
2737
|
-
{
|
|
2738
|
-
id: "mac-chrome",
|
|
2739
|
-
label: "Mac Chrome",
|
|
2740
|
-
userAgent: chromeAgent("Macintosh; Intel Mac OS X 10_15_7"),
|
|
2741
|
-
platform: "MacIntel",
|
|
2742
|
-
vendor: GOOGLE,
|
|
2743
|
-
mobile: false,
|
|
2744
|
-
uaPlatform: "macOS",
|
|
2745
|
-
maxTouchPoints: 0,
|
|
2746
|
-
...chromium(CHROME_BRAND, { ...DESKTOP, platformVersion: "26.7.1", architecture: "arm" })
|
|
2747
|
-
},
|
|
2748
|
-
{
|
|
2749
|
-
id: "windows-chrome",
|
|
2750
|
-
label: "Windows Chrome",
|
|
2751
|
-
userAgent: chromeAgent("Windows NT 10.0; Win64; x64"),
|
|
2752
|
-
platform: "Win32",
|
|
2753
|
-
vendor: GOOGLE,
|
|
2754
|
-
mobile: false,
|
|
2755
|
-
uaPlatform: "Windows",
|
|
2756
|
-
maxTouchPoints: 0,
|
|
2757
|
-
...chromium(CHROME_BRAND, WINDOWS)
|
|
2758
|
-
},
|
|
2759
|
-
{
|
|
2760
|
-
id: "windows-edge",
|
|
2761
|
-
label: "Windows Edge",
|
|
2762
|
-
userAgent: `${chromeAgent("Windows NT 10.0; Win64; x64")} Edg/${EDGE}`,
|
|
2763
|
-
platform: "Win32",
|
|
2764
|
-
vendor: GOOGLE,
|
|
2765
|
-
mobile: false,
|
|
2766
|
-
uaPlatform: "Windows",
|
|
2767
|
-
maxTouchPoints: 0,
|
|
2768
|
-
...chromium({ brand: "Microsoft Edge", version: EDGE }, WINDOWS)
|
|
2769
|
-
},
|
|
2770
|
-
{
|
|
2771
|
-
id: "linux-firefox",
|
|
2772
|
-
label: "Linux Firefox",
|
|
2773
|
-
userAgent: `Mozilla/5.0 (X11; Linux x86_64; rv:${FIREFOX}) Gecko/20100101 Firefox/${FIREFOX}`,
|
|
2774
|
-
platform: "Linux x86_64",
|
|
2775
|
-
vendor: "",
|
|
2776
|
-
mobile: false,
|
|
2777
|
-
brands: [],
|
|
2778
|
-
uaPlatform: "Linux",
|
|
2779
|
-
maxTouchPoints: 0,
|
|
2780
|
-
appVersion: "5.0 (X11)"
|
|
2781
|
-
},
|
|
2782
|
-
{
|
|
2783
|
-
id: "googlebot",
|
|
2784
|
-
label: "Googlebot",
|
|
2785
|
-
userAgent: `Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${CHROME2} Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)`,
|
|
2786
|
-
platform: "Linux armv81",
|
|
2787
|
-
vendor: GOOGLE,
|
|
2788
|
-
mobile: true,
|
|
2789
|
-
uaPlatform: "Android",
|
|
2790
|
-
maxTouchPoints: 1,
|
|
2791
|
-
...chromium(null, {
|
|
2792
|
-
platformVersion: "6.0.1",
|
|
2793
|
-
model: "Nexus 5X",
|
|
2794
|
-
architecture: "",
|
|
2795
|
-
bitness: ""
|
|
2796
|
-
})
|
|
2797
|
-
}
|
|
2798
|
-
];
|
|
2799
|
-
function uaPreset(id) {
|
|
2800
|
-
return UA_PRESETS.find((preset) => preset.id === id);
|
|
2801
|
-
}
|
|
2802
|
-
function userAgentOf(value) {
|
|
2803
|
-
if (value.preset === "custom")
|
|
2804
|
-
return value.custom.trim();
|
|
2805
|
-
return uaPreset(value.preset)?.userAgent ?? "";
|
|
2806
|
-
}
|
|
2807
|
-
function appVersionOf(userAgent) {
|
|
2808
|
-
return userAgent.replace(/^Mozilla\//, "");
|
|
2809
|
-
}
|
|
2810
|
-
var KEYS = [
|
|
2811
|
-
"userAgent",
|
|
2812
|
-
"appVersion",
|
|
2813
|
-
"platform",
|
|
2814
|
-
"vendor",
|
|
2815
|
-
"maxTouchPoints",
|
|
2816
|
-
"userAgentData"
|
|
2817
|
-
];
|
|
2818
|
-
var SHARED2 = Symbol.for("devknobs.ua");
|
|
2819
|
-
function isShared(value) {
|
|
2820
|
-
return typeof value === "object" && value !== null && "originals" in value;
|
|
2821
|
-
}
|
|
2822
|
-
function sharedOf(scope) {
|
|
2823
|
-
const had = Reflect.get(scope, SHARED2);
|
|
2824
|
-
if (isShared(had))
|
|
2825
|
-
return had;
|
|
2826
|
-
const shared2 = { originals: null };
|
|
2827
|
-
Reflect.set(scope, SHARED2, shared2);
|
|
2828
|
-
return shared2;
|
|
2829
|
-
}
|
|
2830
|
-
function prototypeOf(scope) {
|
|
2831
|
-
const navigator2 = Reflect.get(scope, "Navigator");
|
|
2832
|
-
return typeof navigator2 === "function" ? navigator2.prototype : null;
|
|
2833
|
-
}
|
|
2834
|
-
function put(target, key, value) {
|
|
2835
|
-
Object.defineProperty(target, key, { configurable: true, enumerable: true, get: () => value });
|
|
2836
|
-
}
|
|
2837
|
-
function restore(shared2, target, key) {
|
|
2838
|
-
const descriptor = shared2.originals?.get(key);
|
|
2839
|
-
if (descriptor)
|
|
2840
|
-
Object.defineProperty(target, key, descriptor);
|
|
2841
|
-
else
|
|
2842
|
-
Reflect.deleteProperty(target, key);
|
|
2843
|
-
}
|
|
2844
|
-
function copy(brands) {
|
|
2845
|
-
return brands.map(({ brand, version }) => ({ brand, version }));
|
|
2846
|
-
}
|
|
2847
|
-
var NO_HINTS = { brands: [], mobile: false, uaPlatform: "" };
|
|
2848
|
-
function uaData(source, scope) {
|
|
2849
|
-
const brands = Object.freeze(source.brands.map((brand) => Object.freeze({ ...brand })));
|
|
2850
|
-
const low = () => ({ brands: copy(brands), mobile: source.mobile, platform: source.uaPlatform });
|
|
2851
|
-
const hints = source.hints;
|
|
2852
|
-
const high = () => ({
|
|
2853
|
-
architecture: hints?.architecture ?? "",
|
|
2854
|
-
bitness: hints?.bitness ?? "",
|
|
2855
|
-
fullVersionList: copy(hints?.fullVersionList ?? []),
|
|
2856
|
-
model: hints?.model ?? "",
|
|
2857
|
-
platformVersion: hints?.platformVersion ?? "",
|
|
2858
|
-
uaFullVersion: hints?.uaFullVersion ?? ""
|
|
2859
|
-
});
|
|
2860
|
-
const native = Reflect.get(scope, "NavigatorUAData");
|
|
2861
|
-
const proto = typeof native === "function" ? native.prototype : Object.prototype;
|
|
2862
|
-
return Object.create(proto, {
|
|
2863
|
-
brands: { enumerable: true, get: () => brands },
|
|
2864
|
-
mobile: { enumerable: true, get: () => source.mobile },
|
|
2865
|
-
platform: { enumerable: true, get: () => source.uaPlatform },
|
|
2866
|
-
getHighEntropyValues: {
|
|
2867
|
-
value: (asked) => {
|
|
2868
|
-
try {
|
|
2869
|
-
const values = low();
|
|
2870
|
-
const all = high();
|
|
2871
|
-
for (const hint of Array.from(asked, String)) {
|
|
2872
|
-
if (Object.hasOwn(all, hint))
|
|
2873
|
-
values[hint] = all[hint];
|
|
2874
|
-
}
|
|
2875
|
-
return Promise.resolve(values);
|
|
2876
|
-
} catch (error) {
|
|
2877
|
-
return Promise.reject(error);
|
|
2878
|
-
}
|
|
2879
|
-
}
|
|
2880
|
-
},
|
|
2881
|
-
toJSON: { value: low }
|
|
2882
|
-
});
|
|
2883
|
-
}
|
|
2884
|
-
function apply2(value, scope = globalThis) {
|
|
2885
|
-
const target = prototypeOf(scope);
|
|
2886
|
-
const preset = value.preset === "custom" ? undefined : uaPreset(value.preset);
|
|
2887
|
-
const userAgent = userAgentOf(value);
|
|
2888
|
-
if (!target || userAgent === "") {
|
|
2889
|
-
reset2(scope);
|
|
2890
|
-
return;
|
|
2891
|
-
}
|
|
2892
|
-
const shared2 = sharedOf(scope);
|
|
2893
|
-
shared2.originals ??= new Map(KEYS.map((key) => [key, Object.getOwnPropertyDescriptor(target, key)]));
|
|
2894
|
-
put(target, "userAgent", userAgent);
|
|
2895
|
-
put(target, "appVersion", preset?.appVersion ?? appVersionOf(userAgent));
|
|
2896
|
-
if (!preset) {
|
|
2897
|
-
for (const key of ["platform", "vendor", "maxTouchPoints"]) {
|
|
2898
|
-
restore(shared2, target, key);
|
|
2899
|
-
}
|
|
2900
|
-
if (shared2.originals.get("userAgentData")) {
|
|
2901
|
-
put(target, "userAgentData", uaData(NO_HINTS, scope));
|
|
2902
|
-
} else
|
|
2903
|
-
restore(shared2, target, "userAgentData");
|
|
2904
|
-
return;
|
|
2905
|
-
}
|
|
2906
|
-
put(target, "platform", preset.platform);
|
|
2907
|
-
put(target, "vendor", preset.vendor);
|
|
2908
|
-
put(target, "maxTouchPoints", preset.maxTouchPoints);
|
|
2909
|
-
if (preset.brands.length > 0)
|
|
2910
|
-
put(target, "userAgentData", uaData(preset, scope));
|
|
2911
|
-
else
|
|
2912
|
-
Reflect.deleteProperty(target, "userAgentData");
|
|
2913
|
-
}
|
|
2914
|
-
function realPlatform() {
|
|
2915
|
-
const getter = sharedOf(globalThis).originals?.get("platform")?.get;
|
|
2916
|
-
try {
|
|
2917
|
-
return String(getter ? getter.call(navigator) : navigator.platform);
|
|
2918
|
-
} catch {
|
|
2919
|
-
return "";
|
|
2920
|
-
}
|
|
2921
|
-
}
|
|
2922
|
-
function isMac() {
|
|
2923
|
-
return /mac|iphone|ipad|ipod/i.test(realPlatform());
|
|
2924
|
-
}
|
|
2925
|
-
function reset2(scope = globalThis) {
|
|
2926
|
-
const shared2 = sharedOf(scope);
|
|
2927
|
-
const target = prototypeOf(scope);
|
|
2928
|
-
if (!shared2.originals)
|
|
2929
|
-
return;
|
|
2930
|
-
if (target)
|
|
2931
|
-
for (const key of KEYS)
|
|
2932
|
-
restore(shared2, target, key);
|
|
2933
|
-
shared2.originals = null;
|
|
2934
|
-
}
|
|
2935
|
-
|
|
2936
|
-
// src/engine/mock.ts
|
|
2937
|
-
function islandOf(id) {
|
|
2938
|
-
const sensor = BODIES[id]?.front.find((front) => front.kind === "sensor");
|
|
2939
|
-
return sensor && sensor.width > sensor.height ? sensor : null;
|
|
2940
|
-
}
|
|
2941
|
-
function round(kind, rect2) {
|
|
2942
|
-
return { kind, ...rect2, radius: Math.min(rect2.width, rect2.height) / 2 };
|
|
2943
|
-
}
|
|
2944
|
-
function bar(button, out, body) {
|
|
2945
|
-
const { side, at, length } = button;
|
|
2946
|
-
if (side === "top") {
|
|
2947
|
-
const y = body.y - out;
|
|
2948
|
-
return { kind: "button", x: body.x + at, y, width: length, height: 2 * out, radius: out };
|
|
2949
|
-
}
|
|
2950
|
-
const x = side === "left" ? body.x - out : body.x + body.width - out;
|
|
2951
|
-
return { kind: "button", x, y: body.y + at, width: 2 * out, height: length, radius: out };
|
|
2952
|
-
}
|
|
2953
|
-
function keyOf(front) {
|
|
2954
|
-
if (front.key === undefined)
|
|
2955
|
-
return null;
|
|
2956
|
-
const gap = (front.width - front.key) / 2;
|
|
2957
|
-
return { x: front.x + gap, y: front.y + gap, width: front.key, height: front.key };
|
|
2958
|
-
}
|
|
2959
|
-
function turnRect(rect2, width, height, clockwise) {
|
|
2960
|
-
const { x, y } = rect2;
|
|
2961
|
-
const turned = { width: rect2.height, height: rect2.width };
|
|
2962
|
-
return clockwise ? { ...rect2, ...turned, x: height - y - rect2.height, y: x } : { ...rect2, ...turned, x: y, y: width - x - rect2.width };
|
|
2963
|
-
}
|
|
2964
|
-
function turnSides(sides3, clockwise = false) {
|
|
2965
|
-
return clockwise ? { top: sides3.left, right: sides3.top, bottom: sides3.right, left: sides3.bottom } : { top: sides3.right, right: sides3.bottom, bottom: sides3.left, left: sides3.top };
|
|
2966
|
-
}
|
|
2967
|
-
function turnRadius(radius, clockwise = false) {
|
|
2968
|
-
if (typeof radius === "number")
|
|
2969
|
-
return radius;
|
|
2970
|
-
const [topLeft, topRight, bottomRight, bottomLeft] = radius;
|
|
2971
|
-
return clockwise ? [bottomLeft, topLeft, topRight, bottomRight] : [topRight, bottomRight, bottomLeft, topLeft];
|
|
2972
|
-
}
|
|
2973
|
-
function placeIn2(mock, room) {
|
|
2974
|
-
const dx = room.inset.left - mock.inset.left;
|
|
2975
|
-
const dy = room.inset.top - mock.inset.top;
|
|
2976
|
-
const move = (rect2) => ({ ...rect2, x: rect2.x + dx, y: rect2.y + dy });
|
|
2977
|
-
const { width, height, inset: inset2 } = room;
|
|
2978
|
-
return { ...mock, width, height, inset: inset2, body: move(mock.body), parts: mock.parts.map(move) };
|
|
2979
|
-
}
|
|
2980
|
-
function mockOf(id, orientation) {
|
|
2981
|
-
const device = screenOf(id);
|
|
2982
|
-
const shape = BODIES[id];
|
|
2983
|
-
if (!device || !shape)
|
|
2984
|
-
return null;
|
|
2985
|
-
const { bezel, screenRadius, bodyRadius } = shape;
|
|
2986
|
-
const out = (button) => button.out ?? shape.out;
|
|
2987
|
-
const most = (side) => Math.max(0, ...shape.buttons.filter((button) => button.side === side).map(out));
|
|
2988
|
-
const room = { top: most("top"), right: most("right"), left: most("left") };
|
|
2989
|
-
const size = turn(device, "portrait");
|
|
2990
|
-
const inset2 = {
|
|
2991
|
-
top: bezel.top + room.top,
|
|
2992
|
-
right: bezel.right + room.right,
|
|
2993
|
-
bottom: bezel.bottom,
|
|
2994
|
-
left: bezel.left + room.left
|
|
2995
|
-
};
|
|
2996
|
-
const width = size.width + inset2.left + inset2.right;
|
|
2997
|
-
const height = size.height + inset2.top + inset2.bottom;
|
|
2998
|
-
const body = {
|
|
2999
|
-
x: room.left,
|
|
3000
|
-
y: room.top,
|
|
3001
|
-
width: size.width + bezel.left + bezel.right,
|
|
3002
|
-
height: size.height + bezel.top + bezel.bottom
|
|
3003
|
-
};
|
|
3004
|
-
const at = ({ x, y, width: width2, height: height2 }) => {
|
|
3005
|
-
return { x: inset2.left + x, y: inset2.top + y, width: width2, height: height2 };
|
|
3006
|
-
};
|
|
3007
|
-
const parts = [
|
|
3008
|
-
...shape.buttons.map((button) => bar(button, out(button), body)),
|
|
3009
|
-
...shape.front.flatMap((front) => {
|
|
3010
|
-
const key = keyOf(front);
|
|
3011
|
-
const shown = round(front.kind, at(front));
|
|
3012
|
-
return key ? [shown, round("key", at(key))] : [shown];
|
|
3013
|
-
})
|
|
3014
|
-
];
|
|
3015
|
-
const continuous = islandOf(id) !== null;
|
|
3016
|
-
const upright = { width, height, inset: inset2, body, screenRadius, continuous, bodyRadius, parts };
|
|
3017
|
-
if (orientation === "portrait")
|
|
3018
|
-
return upright;
|
|
3019
|
-
const clockwise = device.clockwise === true;
|
|
3020
|
-
return {
|
|
3021
|
-
...upright,
|
|
3022
|
-
width: height,
|
|
3023
|
-
height: width,
|
|
3024
|
-
inset: turnSides(inset2, clockwise),
|
|
3025
|
-
body: turnRect(body, width, height, clockwise),
|
|
3026
|
-
screenRadius: turnRadius(screenRadius, clockwise),
|
|
3027
|
-
bodyRadius: turnRadius(bodyRadius, clockwise),
|
|
3028
|
-
parts: upright.parts.map((part2) => turnRect(part2, width, height, clockwise))
|
|
3029
|
-
};
|
|
3030
|
-
}
|
|
3031
|
-
|
|
3032
|
-
// src/engine/native.ts
|
|
3033
|
-
var HAND_WAIT = 2000;
|
|
3034
|
-
var SYSTEM_MEDIA = {
|
|
3035
|
-
scheme: "system",
|
|
3036
|
-
motion: "system",
|
|
3037
|
-
contrast: "system",
|
|
3038
|
-
transparency: "system"
|
|
3039
|
-
};
|
|
3040
|
-
function drawnAround(state) {
|
|
3041
|
-
if (state.panel.docked || state.frame || state.vision !== "none" || state.zoom !== "fit")
|
|
3042
|
-
return true;
|
|
3043
|
-
const device = deviceOf(state.device);
|
|
3044
|
-
if (!device)
|
|
3045
|
-
return false;
|
|
3046
|
-
if (device.postures)
|
|
3047
|
-
return true;
|
|
3048
|
-
const id = formId(state.device, state.posture);
|
|
3049
|
-
if (state.mock && mockOf(id, state.orientation) !== null)
|
|
3050
|
-
return true;
|
|
3051
|
-
const layout = layoutOf(id, state.browser);
|
|
3052
|
-
return layout !== null && layout !== "off";
|
|
3053
|
-
}
|
|
3054
|
-
function nativeViewport(state) {
|
|
3055
|
-
if (!knobFrame(state) || drawnAround(state))
|
|
3056
|
-
return null;
|
|
3057
|
-
const device = deviceOf(state.device);
|
|
3058
|
-
const touch = device?.touch === true;
|
|
3059
|
-
return {
|
|
3060
|
-
width: typeof state.width === "number" ? state.width : null,
|
|
3061
|
-
height: typeof state.height === "number" ? state.height : null,
|
|
3062
|
-
dpr: typeof state.dpr === "number" ? state.dpr : null,
|
|
3063
|
-
mobile: device?.kind === "phone" || device?.kind === "tablet",
|
|
3064
|
-
touch,
|
|
3065
|
-
touchPointer: touch && state.touchPointer
|
|
3066
|
-
};
|
|
3067
|
-
}
|
|
3068
|
-
function nativeUa(value) {
|
|
3069
|
-
const preset = uaPreset(value.preset);
|
|
3070
|
-
if (preset) {
|
|
3071
|
-
const { userAgent: userAgent2, platform, mobile, brands, uaPlatform, hints } = preset;
|
|
3072
|
-
return { userAgent: userAgent2, platform, mobile, brands, uaPlatform, ...hints ? { hints } : {} };
|
|
3073
|
-
}
|
|
3074
|
-
const userAgent = userAgentOf(value);
|
|
3075
|
-
return userAgent === "" ? null : { userAgent, platform: "", mobile: false, brands: [], uaPlatform: "" };
|
|
3076
|
-
}
|
|
3077
|
-
function inPage(state, driver) {
|
|
3078
|
-
if (!driver)
|
|
3079
|
-
return state;
|
|
3080
|
-
let next2 = state;
|
|
3081
|
-
if (driver.text)
|
|
3082
|
-
next2 = { ...next2, text: "system" };
|
|
3083
|
-
if (driver.offline)
|
|
3084
|
-
next2 = { ...next2, network: { ...next2.network, online: "system" } };
|
|
3085
|
-
if (driver.media)
|
|
3086
|
-
next2 = { ...next2, ...SYSTEM_MEDIA };
|
|
3087
|
-
return next2;
|
|
3088
|
-
}
|
|
3089
|
-
function framing(state, driver) {
|
|
3090
|
-
if (!driver?.viewport || !nativeViewport(state))
|
|
3091
|
-
return state;
|
|
3092
|
-
return { ...state, width: "full", height: "full", dpr: "system" };
|
|
3093
|
-
}
|
|
3094
|
-
var enabled = true;
|
|
3095
|
-
function nativeEnabled() {
|
|
3096
|
-
return enabled;
|
|
3097
|
-
}
|
|
3098
|
-
function enableNative(on) {
|
|
3099
|
-
enabled = on;
|
|
3100
|
-
}
|
|
3101
|
-
var sent = new Map;
|
|
3102
|
-
var pending = null;
|
|
3103
|
-
function handing() {
|
|
3104
|
-
return pending;
|
|
3105
|
-
}
|
|
3106
|
-
function hand(driver, part2, value) {
|
|
3107
|
-
const call = driver[part2];
|
|
3108
|
-
if (!call)
|
|
3109
|
-
return;
|
|
3110
|
-
const key = JSON.stringify(value);
|
|
3111
|
-
if (sent.get(part2) === key)
|
|
3112
|
-
return;
|
|
3113
|
-
sent.set(part2, key);
|
|
3114
|
-
const settled = settles(call(value))?.then(() => {
|
|
3115
|
-
if (pending === settled)
|
|
3116
|
-
pending = null;
|
|
3117
|
-
});
|
|
3118
|
-
if (settled)
|
|
3119
|
-
pending = settled;
|
|
3120
|
-
}
|
|
3121
|
-
function settles(result) {
|
|
3122
|
-
if (!(result instanceof Promise))
|
|
3123
|
-
return null;
|
|
3124
|
-
return Promise.race([
|
|
3125
|
-
result.then(() => {}, () => {}),
|
|
3126
|
-
new Promise((resolve) => setTimeout(resolve, HAND_WAIT))
|
|
3127
|
-
]);
|
|
3128
|
-
}
|
|
3129
|
-
function drive(driver, state) {
|
|
3130
|
-
hand(driver, "text", state.text);
|
|
3131
|
-
hand(driver, "offline", state.network.online === "offline");
|
|
3132
|
-
const { scheme, motion, contrast: contrast2, transparency } = state;
|
|
3133
|
-
hand(driver, "media", { scheme, motion, contrast: contrast2, transparency });
|
|
3134
|
-
if (driver.viewport)
|
|
3135
|
-
hand(driver, "viewport", nativeViewport(state));
|
|
3136
|
-
driveUa(driver, state);
|
|
3137
|
-
}
|
|
3138
|
-
function driveUa(driver, state) {
|
|
3139
|
-
if (driver.ua)
|
|
3140
|
-
hand(driver, "ua", nativeUa(state.ua));
|
|
3141
|
-
}
|
|
3142
|
-
function release(driver, ua = true) {
|
|
3143
|
-
if (sent.size === 0)
|
|
3144
|
-
return;
|
|
3145
|
-
hand(driver, "text", "system");
|
|
3146
|
-
hand(driver, "offline", false);
|
|
3147
|
-
hand(driver, "media", SYSTEM_MEDIA);
|
|
3148
|
-
hand(driver, "viewport", null);
|
|
3149
|
-
if (ua)
|
|
3150
|
-
hand(driver, "ua", null);
|
|
3151
|
-
for (const part2 of Array.from(sent.keys()))
|
|
3152
|
-
if (ua || part2 !== "ua")
|
|
3153
|
-
sent.delete(part2);
|
|
3154
|
-
}
|
|
3155
|
-
|
|
3156
|
-
// src/engine/style.ts
|
|
3157
|
-
var OWN = Symbol.for("devknobs.own");
|
|
3158
|
-
var NAME = Symbol.for("devknobs.name");
|
|
3159
|
-
var TEXT = Symbol.for("devknobs.text");
|
|
3160
|
-
var wrapped = new WeakMap;
|
|
3161
|
-
function isDocument(root) {
|
|
3162
|
-
return root.nodeType === 9;
|
|
3163
|
-
}
|
|
3164
|
-
function documentOf(root) {
|
|
3165
|
-
return isDocument(root) ? root : root.ownerDocument ?? document;
|
|
3166
|
-
}
|
|
3167
|
-
function constructable(root) {
|
|
3168
|
-
const doc = isDocument(root) ? root : root.ownerDocument;
|
|
3169
|
-
const Sheet = doc?.defaultView?.CSSStyleSheet;
|
|
3170
|
-
if (typeof Sheet !== "function" || typeof Sheet.prototype.replaceSync !== "function")
|
|
3171
|
-
return null;
|
|
3172
|
-
return "adoptedStyleSheets" in root ? Sheet : null;
|
|
3173
|
-
}
|
|
3174
|
-
function styleNode(style) {
|
|
3175
|
-
return "nodeType" in style ? style : null;
|
|
3176
|
-
}
|
|
3177
|
-
function isOwnSheet(sheet) {
|
|
3178
|
-
return Reflect.get(sheet, OWN) === true;
|
|
3179
|
-
}
|
|
3180
|
-
function wrap(root, sheet) {
|
|
3181
|
-
const had = wrapped.get(sheet);
|
|
3182
|
-
if (had)
|
|
3183
|
-
return had;
|
|
3184
|
-
const style = {
|
|
3185
|
-
get textContent() {
|
|
3186
|
-
const text2 = Reflect.get(sheet, TEXT);
|
|
3187
|
-
return typeof text2 === "string" ? text2 : "";
|
|
3188
|
-
},
|
|
3189
|
-
set textContent(value) {
|
|
3190
|
-
Reflect.set(sheet, TEXT, value ?? "");
|
|
3191
|
-
sheet.replaceSync(value ?? "");
|
|
3192
|
-
},
|
|
3193
|
-
sheet,
|
|
3194
|
-
remove() {
|
|
3195
|
-
root.adoptedStyleSheets = root.adoptedStyleSheets.filter((other) => other !== sheet);
|
|
3196
|
-
}
|
|
3197
|
-
};
|
|
3198
|
-
wrapped.set(sheet, style);
|
|
3199
|
-
return style;
|
|
3200
|
-
}
|
|
3201
|
-
function adopt(root, Sheet, name) {
|
|
3202
|
-
const sheet = new Sheet;
|
|
3203
|
-
Reflect.set(sheet, OWN, true);
|
|
3204
|
-
if (name !== undefined)
|
|
3205
|
-
Reflect.set(sheet, NAME, name);
|
|
3206
|
-
root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
|
|
3207
|
-
return wrap(root, sheet);
|
|
3208
|
-
}
|
|
3209
|
-
function addStyle(root, css) {
|
|
3210
|
-
const Sheet = constructable(root);
|
|
3211
|
-
if (Sheet) {
|
|
3212
|
-
const style2 = adopt(root, Sheet);
|
|
3213
|
-
style2.textContent = css;
|
|
3214
|
-
return style2;
|
|
3215
|
-
}
|
|
3216
|
-
const style = documentOf(root).createElement("style");
|
|
3217
|
-
style.textContent = css;
|
|
3218
|
-
if (isDocument(root))
|
|
3219
|
-
(root.head ?? root.documentElement).appendChild(style);
|
|
3220
|
-
else
|
|
3221
|
-
root.append(style);
|
|
3222
|
-
return style;
|
|
3223
|
-
}
|
|
3224
|
-
function findStyle(name, doc = document) {
|
|
3225
|
-
const sheet = "adoptedStyleSheets" in doc ? doc.adoptedStyleSheets.find((own) => Reflect.get(own, NAME) === name) : undefined;
|
|
3226
|
-
return sheet ? wrap(doc, sheet) : doc.querySelector(`style[data-devknobs="${name}"]`);
|
|
3227
|
-
}
|
|
3228
|
-
function ensureStyle(name, doc = document) {
|
|
3229
|
-
const existing = findStyle(name, doc);
|
|
3230
|
-
if (existing)
|
|
3231
|
-
return existing;
|
|
3232
|
-
const Sheet = constructable(doc);
|
|
3233
|
-
if (Sheet)
|
|
3234
|
-
return adopt(doc, Sheet, name);
|
|
3235
|
-
const style = doc.createElement("style");
|
|
3236
|
-
style.setAttribute("data-devknobs", name);
|
|
3237
|
-
(doc.head ?? doc.documentElement).appendChild(style);
|
|
3238
|
-
return style;
|
|
3239
|
-
}
|
|
3240
|
-
function removeStyle(name, doc = document) {
|
|
3241
|
-
findStyle(name, doc)?.remove();
|
|
3242
|
-
}
|
|
3243
|
-
|
|
3244
|
-
// src/engine/matcolors.ts
|
|
3245
|
-
var MAT_COLORS2 = {
|
|
3246
|
-
blue: {
|
|
3247
|
-
srgb: ["rgb(20, 70, 152)", "rgb(12, 48, 114)", "rgb(7, 31, 80)"],
|
|
3248
|
-
p3: [
|
|
3249
|
-
"color(display-p3 0.1 0.27 0.61)",
|
|
3250
|
-
"color(display-p3 0.06 0.19 0.46)",
|
|
3251
|
-
"color(display-p3 0.035 0.12 0.32)"
|
|
3252
|
-
],
|
|
3253
|
-
line: "rgb(170, 205, 255)"
|
|
3254
|
-
},
|
|
3255
|
-
green: {
|
|
3256
|
-
srgb: ["rgb(26, 96, 71)", "rgb(14, 71, 51)", "rgb(8, 49, 35)"],
|
|
3257
|
-
p3: [
|
|
3258
|
-
"color(display-p3 0.159 0.377 0.279)",
|
|
3259
|
-
"color(display-p3 0.102 0.277 0.2)",
|
|
3260
|
-
"color(display-p3 0.065 0.194 0.136)"
|
|
3261
|
-
],
|
|
3262
|
-
line: "rgb(160, 218, 191)"
|
|
3263
|
-
},
|
|
3264
|
-
magenta: {
|
|
3265
|
-
srgb: ["rgb(123, 37, 88)", "rgb(90, 22, 63)", "rgb(62, 12, 42)"],
|
|
3266
|
-
p3: [
|
|
3267
|
-
"color(display-p3 0.462 0.14 0.342)",
|
|
3268
|
-
"color(display-p3 0.34 0.081 0.246)",
|
|
3269
|
-
"color(display-p3 0.234 0.043 0.165)"
|
|
3270
|
-
],
|
|
3271
|
-
line: "rgb(238, 185, 211)"
|
|
3272
|
-
},
|
|
3273
|
-
purple: {
|
|
3274
|
-
srgb: ["rgb(86, 56, 130)", "rgb(62, 38, 96)", "rgb(42, 24, 67)"],
|
|
3275
|
-
p3: [
|
|
3276
|
-
"color(display-p3 0.326 0.209 0.521)",
|
|
3277
|
-
"color(display-p3 0.233 0.138 0.387)",
|
|
3278
|
-
"color(display-p3 0.156 0.086 0.269)"
|
|
3279
|
-
],
|
|
3280
|
-
line: "rgb(209, 193, 242)"
|
|
3281
|
-
},
|
|
3282
|
-
red: {
|
|
3283
|
-
srgb: ["rgb(132, 36, 36)", "rgb(97, 21, 22)", "rgb(68, 11, 12)"],
|
|
3284
|
-
p3: [
|
|
3285
|
-
"color(display-p3 0.499 0.139 0.133)",
|
|
3286
|
-
"color(display-p3 0.369 0.079 0.078)",
|
|
3287
|
-
"color(display-p3 0.256 0.041 0.042)"
|
|
3288
|
-
],
|
|
3289
|
-
line: "rgb(239, 188, 183)"
|
|
3290
|
-
},
|
|
3291
|
-
graphite: {
|
|
3292
|
-
srgb: ["rgb(64, 68, 74)", "rgb(43, 46, 51)", "rgb(26, 28, 32)"],
|
|
3293
|
-
p3: [
|
|
3294
|
-
"color(display-p3 0.25 0.264 0.291)",
|
|
3295
|
-
"color(display-p3 0.169 0.179 0.2)",
|
|
3296
|
-
"color(display-p3 0.102 0.11 0.126)"
|
|
3297
|
-
],
|
|
3298
|
-
line: "rgb(198, 203, 211)"
|
|
3299
|
-
}
|
|
3300
|
-
};
|
|
3301
|
-
var MAT_COLOR_NAMES = [
|
|
3302
|
-
"blue",
|
|
3303
|
-
"green",
|
|
3304
|
-
"magenta",
|
|
3305
|
-
"purple",
|
|
3306
|
-
"red",
|
|
3307
|
-
"graphite"
|
|
3308
|
-
];
|
|
3309
|
-
function matGradient(stops) {
|
|
3310
|
-
return `radial-gradient(140% 100% at 50% 0%, ${stops[0]}, ${stops[1]} 60%, ${stops[2]})`;
|
|
3311
|
-
}
|
|
3312
|
-
function isMatName(value) {
|
|
3313
|
-
return MAT_COLOR_NAMES.some((name) => name === value);
|
|
3314
|
-
}
|
|
3315
|
-
var SHADE = [1, 0.82, 0.64];
|
|
3316
|
-
function rgb(color) {
|
|
3317
|
-
return `rgb(${Math.round(color.red)}, ${Math.round(color.green)}, ${Math.round(color.blue)})`;
|
|
3318
|
-
}
|
|
3319
|
-
function shades(color) {
|
|
3320
|
-
const shade = (share) => ({
|
|
3321
|
-
red: color.red * share,
|
|
3322
|
-
green: color.green * share,
|
|
3323
|
-
blue: color.blue * share,
|
|
3324
|
-
alpha: 1
|
|
3325
|
-
});
|
|
3326
|
-
return [shade(SHADE[0]), shade(SHADE[1]), shade(SHADE[2])];
|
|
3327
|
-
}
|
|
3328
|
-
function customColor(mat) {
|
|
3329
|
-
return isCustomColor(mat) ? parseHex(mat) : null;
|
|
3330
|
-
}
|
|
3331
|
-
function matStops(mat) {
|
|
3332
|
-
if (isMatName(mat))
|
|
3333
|
-
return MAT_COLORS2[mat];
|
|
3334
|
-
const color = customColor(mat);
|
|
3335
|
-
if (!color)
|
|
3336
|
-
return MAT_COLORS2.blue;
|
|
3337
|
-
const [top2, middle, edge] = shades(color);
|
|
3338
|
-
const stops = [rgb(top2), rgb(middle), rgb(edge)];
|
|
3339
|
-
return { srgb: stops, p3: stops };
|
|
3340
|
-
}
|
|
3341
|
-
function matPaint(mat) {
|
|
3342
|
-
if (isMatName(mat))
|
|
3343
|
-
return MAT_COLORS2[mat];
|
|
3344
|
-
const color = customColor(mat);
|
|
3345
|
-
return color ? { ...matStops(mat), line: rgb(inkOn(color, shades(color))) } : MAT_COLORS2.blue;
|
|
3346
|
-
}
|
|
3347
|
-
var MAT_VARIABLES = ["--mat", "--mat-p3", "--mat-line"];
|
|
3348
|
-
function putMat(node, mat) {
|
|
3349
|
-
if (mat === null)
|
|
3350
|
-
node.removeAttribute("data-mat");
|
|
3351
|
-
else
|
|
3352
|
-
node.setAttribute("data-mat", mat);
|
|
3353
|
-
if (mat === null || isMatName(mat)) {
|
|
3354
|
-
for (const name of MAT_VARIABLES)
|
|
3355
|
-
node.style.removeProperty(name);
|
|
3356
|
-
return;
|
|
3357
|
-
}
|
|
3358
|
-
const paint = matPaint(mat);
|
|
3359
|
-
node.style.setProperty("--mat", matGradient(paint.srgb));
|
|
3360
|
-
node.style.setProperty("--mat-p3", matGradient(paint.p3));
|
|
3361
|
-
node.style.setProperty("--mat-line", paint.line);
|
|
3362
|
-
}
|
|
3363
|
-
|
|
3364
|
-
// src/engine/placeholder.ts
|
|
3365
|
-
var Z_INDEX = 2147483645;
|
|
3366
|
-
var EARLY2 = "early";
|
|
3367
|
-
var SNAPSHOT_KEY = "devknobs:snapshot";
|
|
3368
|
-
var SNAPSHOT_VERSION = 1;
|
|
3369
|
-
var EARLY_FRAMES = 60;
|
|
3370
|
-
var earlyWait = 0;
|
|
3371
|
-
function snapshotKey(knobs, view) {
|
|
3372
|
-
return JSON.stringify([
|
|
3373
|
-
knobs.width,
|
|
3374
|
-
knobs.height,
|
|
3375
|
-
knobs.frame,
|
|
3376
|
-
knobs.dpr,
|
|
3377
|
-
knobs.vision,
|
|
3378
|
-
knobs.scheme,
|
|
3379
|
-
knobs.device,
|
|
3380
|
-
knobs.orientation,
|
|
3381
|
-
knobs.posture,
|
|
3382
|
-
knobs.mock,
|
|
3383
|
-
knobs.browser,
|
|
3384
|
-
knobs.bars,
|
|
3385
|
-
knobs.edgeToEdge,
|
|
3386
|
-
knobs.zoom,
|
|
3387
|
-
knobs.mat,
|
|
3388
|
-
knobs.panel.open,
|
|
3389
|
-
knobs.panel.side,
|
|
3390
|
-
knobs.panel.docked,
|
|
3391
|
-
view.innerWidth,
|
|
3392
|
-
view.innerHeight,
|
|
3393
|
-
view.devicePixelRatio
|
|
3394
|
-
]);
|
|
3395
|
-
}
|
|
3396
|
-
var RGB = /^rgb\(\d{1,3}, \d{1,3}, \d{1,3}\)$/;
|
|
3397
|
-
function lookOf(value) {
|
|
3398
|
-
if (typeof value !== "object" || value === null)
|
|
3399
|
-
return null;
|
|
3400
|
-
const read2 = (key) => Reflect.get(value, key);
|
|
3401
|
-
const background = read2("background");
|
|
3402
|
-
const scheme = read2("scheme");
|
|
3403
|
-
const host = read2("host");
|
|
3404
|
-
const flags = [read2("dark"), read2("canBack"), read2("canForward")];
|
|
3405
|
-
if (typeof background !== "string" || !RGB.test(background)) {
|
|
3406
|
-
return null;
|
|
3407
|
-
}
|
|
3408
|
-
if (scheme !== "light" && scheme !== "dark" || typeof host !== "string")
|
|
3409
|
-
return null;
|
|
3410
|
-
const [dark, canBack, canForward] = flags;
|
|
3411
|
-
if (typeof dark !== "boolean" || typeof canBack !== "boolean")
|
|
3412
|
-
return null;
|
|
3413
|
-
if (typeof canForward !== "boolean")
|
|
3414
|
-
return null;
|
|
3415
|
-
const color = (key) => {
|
|
3416
|
-
const value2 = read2(key);
|
|
3417
|
-
return typeof value2 === "string" && RGB.test(value2) ? value2 : background;
|
|
3418
|
-
};
|
|
3419
|
-
const top2 = color("top");
|
|
3420
|
-
const bottom = color("bottom");
|
|
3421
|
-
return { background, top: top2, bottom, footer: read2("footer") === true, under: [], dark, scheme, host, canBack, canForward };
|
|
3422
|
-
}
|
|
3423
|
-
function readSnapshot(knobs, view) {
|
|
3424
|
-
try {
|
|
3425
|
-
const text2 = webStorage("session")?.getItem(SNAPSHOT_KEY);
|
|
3426
|
-
if (!text2)
|
|
3427
|
-
return null;
|
|
3428
|
-
const data = JSON.parse(text2);
|
|
3429
|
-
if (typeof data !== "object" || data === null || newer(data, SNAPSHOT_VERSION))
|
|
3430
|
-
return null;
|
|
3431
|
-
const key = Reflect.get(data, "key");
|
|
3432
|
-
const css = Reflect.get(data, "css");
|
|
3433
|
-
const html = Reflect.get(data, "html");
|
|
3434
|
-
const look = lookOf(Reflect.get(data, "look"));
|
|
3435
|
-
if (key !== snapshotKey(knobs, view) || typeof css !== "string")
|
|
3436
|
-
return null;
|
|
3437
|
-
if (typeof html !== "string" || !look)
|
|
3438
|
-
return null;
|
|
3439
|
-
return { key, css, html, look };
|
|
3440
|
-
} catch {
|
|
3441
|
-
return null;
|
|
3442
|
-
}
|
|
3443
|
-
}
|
|
3444
|
-
function writeSnapshot(snapshot) {
|
|
3445
|
-
try {
|
|
3446
|
-
webStorage("session")?.setItem(SNAPSHOT_KEY, JSON.stringify(stamped(snapshot, SNAPSHOT_VERSION)));
|
|
3447
|
-
} catch {
|
|
3448
|
-
clearSnapshot();
|
|
3449
|
-
}
|
|
3450
|
-
}
|
|
3451
|
-
function keepDrawing({ letterbox, zoom, key, css, look }) {
|
|
3452
|
-
const copy2 = letterbox.cloneNode(true);
|
|
3453
|
-
if (!(copy2 instanceof HTMLElement))
|
|
3454
|
-
return;
|
|
3455
|
-
copy2.querySelector("iframe")?.remove();
|
|
3456
|
-
copy2.querySelector(".touchdot")?.remove();
|
|
3457
|
-
copy2.querySelector(".glass")?.removeAttribute("data-touch");
|
|
3458
|
-
for (const line of Array.from(copy2.querySelectorAll(".progress")))
|
|
3459
|
-
line.hidden = true;
|
|
3460
|
-
const blank = copy2.querySelector(".screenblank");
|
|
3461
|
-
if (blank) {
|
|
3462
|
-
blank.hidden = false;
|
|
3463
|
-
blank.style.background = look.background;
|
|
3464
|
-
}
|
|
3465
|
-
for (const option of Array.from(copy2.querySelectorAll("option"))) {
|
|
3466
|
-
option.toggleAttribute("selected", option.value === zoom);
|
|
3467
|
-
}
|
|
3468
|
-
writeSnapshot({ key, css, html: copy2.outerHTML, look });
|
|
3469
|
-
}
|
|
3470
|
-
function clearSnapshot() {
|
|
3471
|
-
try {
|
|
3472
|
-
webStorage("session")?.removeItem(SNAPSHOT_KEY);
|
|
3473
|
-
} catch {}
|
|
3474
|
-
}
|
|
3475
|
-
function earlyHost() {
|
|
3476
|
-
return document.querySelector(`div[data-devknobs="${EARLY2}"]`);
|
|
3477
|
-
}
|
|
3478
|
-
function dropEarly() {
|
|
3479
|
-
for (const node of Array.from(document.querySelectorAll(`[data-devknobs="${EARLY2}"]`))) {
|
|
3480
|
-
node.remove();
|
|
3481
|
-
}
|
|
3482
|
-
removeStyle(EARLY2);
|
|
3483
|
-
}
|
|
3484
|
-
function adoptEarly(pictureLoading) {
|
|
3485
|
-
const early = earlyHost();
|
|
3486
|
-
if (!early || !document.body) {
|
|
3487
|
-
dropEarly();
|
|
3488
|
-
return;
|
|
3489
|
-
}
|
|
3490
|
-
document.body.append(early);
|
|
3491
|
-
let frames = 0;
|
|
3492
|
-
const step = () => {
|
|
3493
|
-
earlyWait = 0;
|
|
3494
|
-
if (pictureLoading() && ++frames < EARLY_FRAMES) {
|
|
3495
|
-
earlyWait = window.requestAnimationFrame(step);
|
|
3496
|
-
return;
|
|
3497
|
-
}
|
|
3498
|
-
earlyWait = window.requestAnimationFrame(() => {
|
|
3499
|
-
earlyWait = 0;
|
|
3500
|
-
dropEarly();
|
|
3501
|
-
});
|
|
3502
|
-
};
|
|
3503
|
-
earlyWait = window.requestAnimationFrame(step);
|
|
3504
|
-
}
|
|
3505
|
-
function stopAdopting() {
|
|
3506
|
-
if (earlyWait)
|
|
3507
|
-
window.cancelAnimationFrame(earlyWait);
|
|
3508
|
-
earlyWait = 0;
|
|
3509
|
-
}
|
|
3510
|
-
|
|
3511
|
-
// src/requests/shared.ts
|
|
3512
|
-
var SHARED_VERSION = 2;
|
|
3513
|
-
var SHARED3 = Symbol.for("devknobs.requests");
|
|
3514
|
-
var QUIET = Symbol.for("devknobs.quiet");
|
|
3515
|
-
function isShared2(value) {
|
|
3516
|
-
return typeof value === "object" && value !== null && Reflect.get(value, "version") === SHARED_VERSION;
|
|
3517
|
-
}
|
|
3518
|
-
function shared2(scope = globalThis) {
|
|
3519
|
-
try {
|
|
3520
|
-
const value = Reflect.get(scope, SHARED3);
|
|
3521
|
-
return isShared2(value) ? value : null;
|
|
3522
|
-
} catch {
|
|
3523
|
-
return null;
|
|
3524
|
-
}
|
|
3525
|
-
}
|
|
3526
|
-
function share(recorder) {
|
|
3527
|
-
if (recorder)
|
|
3528
|
-
Reflect.set(globalThis, SHARED3, recorder);
|
|
3529
|
-
else
|
|
3530
|
-
Reflect.deleteProperty(globalThis, SHARED3);
|
|
3531
|
-
}
|
|
3532
|
-
function evict() {
|
|
3533
|
-
const other = Reflect.get(globalThis, SHARED3);
|
|
3534
|
-
if (typeof other !== "object" || other === null)
|
|
3535
|
-
return;
|
|
3536
|
-
const uninstall = Reflect.get(other, "uninstall");
|
|
3537
|
-
try {
|
|
3538
|
-
if (typeof uninstall === "function")
|
|
3539
|
-
uninstall.call(other);
|
|
3540
|
-
} catch {}
|
|
3541
|
-
Reflect.deleteProperty(globalThis, SHARED3);
|
|
3542
|
-
}
|
|
3543
|
-
|
|
3544
1758
|
// src/engine/owninline.ts
|
|
3545
|
-
var
|
|
1759
|
+
var OWN = Symbol.for("devknobs.inline");
|
|
3546
1760
|
function notes(element) {
|
|
3547
|
-
const value = Reflect.get(element,
|
|
1761
|
+
const value = Reflect.get(element, OWN);
|
|
3548
1762
|
return typeof value === "object" && value !== null ? value : null;
|
|
3549
1763
|
}
|
|
3550
1764
|
function markInline(element, property, value) {
|
|
@@ -3557,7 +1771,7 @@ function markInline(element, property, value) {
|
|
|
3557
1771
|
if (kept)
|
|
3558
1772
|
Reflect.set(kept, property, value);
|
|
3559
1773
|
else
|
|
3560
|
-
Reflect.set(element,
|
|
1774
|
+
Reflect.set(element, OWN, { [property]: value });
|
|
3561
1775
|
}
|
|
3562
1776
|
function ownInline(element, property) {
|
|
3563
1777
|
const kept = notes(element);
|
|
@@ -3597,24 +1811,24 @@ function emulatedFontSize(value, size) {
|
|
|
3597
1811
|
if (keyword !== undefined)
|
|
3598
1812
|
return px(keyword * size);
|
|
3599
1813
|
let relative = false;
|
|
3600
|
-
const
|
|
1814
|
+
const next = value.replace(RELATIVE, (_whole, amount, unit) => {
|
|
3601
1815
|
relative = true;
|
|
3602
1816
|
return px(Number(amount) * size / (unit === "%" ? 100 : 1));
|
|
3603
1817
|
});
|
|
3604
|
-
return relative ?
|
|
1818
|
+
return relative ? next : null;
|
|
3605
1819
|
}
|
|
3606
1820
|
function emulateMediaText(text2, size) {
|
|
3607
1821
|
return text2.replace(MEDIA_RELATIVE, (_whole, amount) => px(Number(amount) * size));
|
|
3608
1822
|
}
|
|
3609
1823
|
function substituteVars(value, lookup) {
|
|
3610
|
-
let
|
|
3611
|
-
for (let depth = 0;depth < 5 &&
|
|
3612
|
-
|
|
1824
|
+
let next = value;
|
|
1825
|
+
for (let depth = 0;depth < 5 && next.includes("var("); depth++) {
|
|
1826
|
+
next = next.replace(VAR, (_whole, name, fallback) => {
|
|
3613
1827
|
const found = lookup(name).trim();
|
|
3614
1828
|
return found || fallback?.trim() || "var()";
|
|
3615
1829
|
});
|
|
3616
1830
|
}
|
|
3617
|
-
return
|
|
1831
|
+
return next.includes("var(") ? null : next;
|
|
3618
1832
|
}
|
|
3619
1833
|
function splitSelectors(text2) {
|
|
3620
1834
|
const parts = [];
|
|
@@ -3725,12 +1939,12 @@ function rewriteMedia() {
|
|
|
3725
1939
|
const known = rewrites.get(rule);
|
|
3726
1940
|
const ours = known !== undefined && text2 === known.written;
|
|
3727
1941
|
const source = ours ? known.original : text2;
|
|
3728
|
-
const
|
|
3729
|
-
if (
|
|
1942
|
+
const next = size === null ? source : emulateMediaText(source, size);
|
|
1943
|
+
if (next === source && !ours)
|
|
3730
1944
|
return;
|
|
3731
|
-
if (
|
|
1945
|
+
if (next !== text2) {
|
|
3732
1946
|
try {
|
|
3733
|
-
rule.media.mediaText =
|
|
1947
|
+
rule.media.mediaText = next;
|
|
3734
1948
|
} catch {}
|
|
3735
1949
|
}
|
|
3736
1950
|
if (size === null)
|
|
@@ -3791,8 +2005,8 @@ function rootDeclarations() {
|
|
|
3791
2005
|
continue;
|
|
3792
2006
|
seen.add(imported.styleSheet);
|
|
3793
2007
|
const media = imported.media.mediaText;
|
|
3794
|
-
const
|
|
3795
|
-
walk(rulesOf(imported.styleSheet), layered || imported.layerName != null,
|
|
2008
|
+
const next = media ? [...conditions, () => matches(media)] : conditions;
|
|
2009
|
+
walk(rulesOf(imported.styleSheet), layered || imported.layerName != null, next);
|
|
3796
2010
|
} else if (kind === "CSSMediaRule") {
|
|
3797
2011
|
const media = rule.media.mediaText;
|
|
3798
2012
|
walk(rule.cssRules, layered, [...conditions, () => matches(media)]);
|
|
@@ -3871,12 +2085,12 @@ function applyRoot() {
|
|
|
3871
2085
|
const value = authorFontSize();
|
|
3872
2086
|
const lookup = (name) => getComputedStyle(root).getPropertyValue(name);
|
|
3873
2087
|
const resolved = value === null ? null : substituteVars(value, lookup);
|
|
3874
|
-
const
|
|
3875
|
-
if (
|
|
2088
|
+
const next = resolved === null ? px(computedSize() * size / INITIAL) : emulatedFontSize(resolved, size);
|
|
2089
|
+
if (next === null) {
|
|
3876
2090
|
restoreRoot();
|
|
3877
2091
|
return;
|
|
3878
2092
|
}
|
|
3879
|
-
root.style.setProperty("font-size",
|
|
2093
|
+
root.style.setProperty("font-size", next, "important");
|
|
3880
2094
|
wrote = root.style.getPropertyValue("font-size");
|
|
3881
2095
|
markInline(root, "font-size", wrote);
|
|
3882
2096
|
}
|
|
@@ -3919,16 +2133,16 @@ function watchSheets() {
|
|
|
3919
2133
|
observer.observe(document.documentElement, { childList: true, subtree: true });
|
|
3920
2134
|
window.addEventListener("resize", onResize);
|
|
3921
2135
|
}
|
|
3922
|
-
function sizeQuery(query,
|
|
2136
|
+
function sizeQuery(query, next) {
|
|
3923
2137
|
const emulated = size === null ? query : emulateMediaText(query, size);
|
|
3924
|
-
const list =
|
|
2138
|
+
const list = next(emulated);
|
|
3925
2139
|
if (emulated !== query)
|
|
3926
2140
|
Object.defineProperty(list, "media", { configurable: true, value: query });
|
|
3927
2141
|
return list;
|
|
3928
2142
|
}
|
|
3929
|
-
function
|
|
2143
|
+
function apply2(value) {
|
|
3930
2144
|
if (typeof value !== "number" || !(value > 0)) {
|
|
3931
|
-
|
|
2145
|
+
reset2();
|
|
3932
2146
|
return;
|
|
3933
2147
|
}
|
|
3934
2148
|
active = true;
|
|
@@ -3937,7 +2151,7 @@ function apply3(value) {
|
|
|
3937
2151
|
watchSheets();
|
|
3938
2152
|
refresh();
|
|
3939
2153
|
}
|
|
3940
|
-
function
|
|
2154
|
+
function reset2() {
|
|
3941
2155
|
if (!active)
|
|
3942
2156
|
return;
|
|
3943
2157
|
size = null;
|
|
@@ -3955,7 +2169,7 @@ function reset3() {
|
|
|
3955
2169
|
}
|
|
3956
2170
|
|
|
3957
2171
|
// src/engine/media.ts
|
|
3958
|
-
var
|
|
2172
|
+
var SYSTEM_MEDIA = {
|
|
3959
2173
|
scheme: "system",
|
|
3960
2174
|
motion: "system",
|
|
3961
2175
|
contrast: "system",
|
|
@@ -4048,16 +2262,16 @@ function rewriteMediaText(text2, feature, value) {
|
|
|
4048
2262
|
return queries.map((query) => rewriteQuery(query, feature, value)).join(", ");
|
|
4049
2263
|
}
|
|
4050
2264
|
function rewriteAll(text2, value) {
|
|
4051
|
-
let
|
|
2265
|
+
let next = text2;
|
|
4052
2266
|
for (const [feature, reads] of emulated(value))
|
|
4053
|
-
|
|
4054
|
-
return
|
|
2267
|
+
next = rewriteMediaText(next, feature, reads);
|
|
2268
|
+
return next;
|
|
4055
2269
|
}
|
|
4056
2270
|
function mentionsFeature(text2) {
|
|
4057
2271
|
const lower = text2.toLowerCase();
|
|
4058
2272
|
return FEATURES.some((feature) => lower.includes(feature));
|
|
4059
2273
|
}
|
|
4060
|
-
var
|
|
2274
|
+
var EARLY2 = Symbol.for("devknobs.early");
|
|
4061
2275
|
var originals = new WeakMap;
|
|
4062
2276
|
var tracked = new Set;
|
|
4063
2277
|
var heard = new WeakMap;
|
|
@@ -4065,7 +2279,7 @@ var queries = new WeakMap;
|
|
|
4065
2279
|
var guarded = new WeakSet;
|
|
4066
2280
|
var PRUNE_FROM = 256;
|
|
4067
2281
|
var pruneAt = PRUNE_FROM;
|
|
4068
|
-
var current2 =
|
|
2282
|
+
var current2 = SYSTEM_MEDIA;
|
|
4069
2283
|
var nativeMatches = null;
|
|
4070
2284
|
var readMatches = null;
|
|
4071
2285
|
var nativeListen = null;
|
|
@@ -4124,11 +2338,11 @@ function applyCss() {
|
|
|
4124
2338
|
return;
|
|
4125
2339
|
originals.set(rule, original2);
|
|
4126
2340
|
}
|
|
4127
|
-
const
|
|
4128
|
-
if (
|
|
2341
|
+
const next = rewriteAll(original2, current2);
|
|
2342
|
+
if (next === text2)
|
|
4129
2343
|
return;
|
|
4130
2344
|
try {
|
|
4131
|
-
rule.media.mediaText =
|
|
2345
|
+
rule.media.mediaText = next;
|
|
4132
2346
|
} catch {}
|
|
4133
2347
|
}, seen);
|
|
4134
2348
|
}
|
|
@@ -4277,8 +2491,8 @@ function restoreListen() {
|
|
|
4277
2491
|
nativeListen = null;
|
|
4278
2492
|
addNative = null;
|
|
4279
2493
|
}
|
|
4280
|
-
function trackLists(query,
|
|
4281
|
-
const list =
|
|
2494
|
+
function trackLists(query, next) {
|
|
2495
|
+
const list = next(query);
|
|
4282
2496
|
if (mentionsFeature(query))
|
|
4283
2497
|
track2(list, query);
|
|
4284
2498
|
return list;
|
|
@@ -4287,8 +2501,8 @@ function ensureMatchMedia() {
|
|
|
4287
2501
|
if (patched)
|
|
4288
2502
|
return;
|
|
4289
2503
|
const scope = window;
|
|
4290
|
-
const early = scope[
|
|
4291
|
-
scope[
|
|
2504
|
+
const early = scope[EARLY2];
|
|
2505
|
+
scope[EARLY2] = null;
|
|
4292
2506
|
const handed = early?.release(guard) ?? [];
|
|
4293
2507
|
patched = true;
|
|
4294
2508
|
for (const { list, query, heard: value, guarded: on } of handed) {
|
|
@@ -4331,12 +2545,12 @@ function applyColorScheme() {
|
|
|
4331
2545
|
}
|
|
4332
2546
|
function coarse(view) {
|
|
4333
2547
|
const below = view.matchMedia;
|
|
4334
|
-
const touch = { ...
|
|
2548
|
+
const touch = { ...SYSTEM_MEDIA, touch: true };
|
|
4335
2549
|
view.matchMedia = function matchMedia(query) {
|
|
4336
2550
|
return below.call(view, rewriteAll(String(query), touch));
|
|
4337
2551
|
};
|
|
4338
2552
|
}
|
|
4339
|
-
function
|
|
2553
|
+
function apply3(value) {
|
|
4340
2554
|
current2 = value;
|
|
4341
2555
|
ensureMatchMedia();
|
|
4342
2556
|
ensureObserver();
|
|
@@ -4344,8 +2558,8 @@ function apply4(value) {
|
|
|
4344
2558
|
applyCss();
|
|
4345
2559
|
refresh2();
|
|
4346
2560
|
}
|
|
4347
|
-
function
|
|
4348
|
-
|
|
2561
|
+
function reset3() {
|
|
2562
|
+
apply3(SYSTEM_MEDIA);
|
|
4349
2563
|
}
|
|
4350
2564
|
function teardown() {
|
|
4351
2565
|
observer2?.disconnect();
|
|
@@ -4366,218 +2580,147 @@ function teardown() {
|
|
|
4366
2580
|
colorScheme = null;
|
|
4367
2581
|
}
|
|
4368
2582
|
function destroy() {
|
|
4369
|
-
|
|
2583
|
+
reset3();
|
|
4370
2584
|
for (const ref of tracked) {
|
|
4371
2585
|
const list = ref.deref();
|
|
4372
2586
|
if (list)
|
|
4373
2587
|
guardFirst(list);
|
|
4374
2588
|
}
|
|
4375
2589
|
teardown();
|
|
4376
|
-
Reflect.deleteProperty(window,
|
|
2590
|
+
Reflect.deleteProperty(window, EARLY2);
|
|
4377
2591
|
}
|
|
4378
2592
|
|
|
4379
|
-
// src/engine/
|
|
4380
|
-
var
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
return turn(device, state.orientation);
|
|
4387
|
-
const { width, height } = turn(deviceOf(state.device) ?? device, "portrait");
|
|
4388
|
-
const across = device.postures !== undefined && state.posture !== "open" && state.orientation === "landscape";
|
|
4389
|
-
return across ? { width, height, availHeight: width } : { width, height };
|
|
4390
|
-
}
|
|
4391
|
-
var ORIGINALS = Symbol.for("devknobs.screen");
|
|
4392
|
-
function originalsOf(own) {
|
|
4393
|
-
const held = Reflect.get(own, ORIGINALS);
|
|
4394
|
-
return held instanceof Map ? held : undefined;
|
|
4395
|
-
}
|
|
4396
|
-
function apply5(size2, scope = globalThis) {
|
|
4397
|
-
const own = Reflect.get(scope, "screen");
|
|
4398
|
-
if (typeof own !== "object" || own === null)
|
|
4399
|
-
return;
|
|
4400
|
-
const originals2 = originalsOf(own);
|
|
4401
|
-
if (!size2) {
|
|
4402
|
-
if (!originals2)
|
|
4403
|
-
return;
|
|
4404
|
-
for (const [key, descriptor] of originals2) {
|
|
4405
|
-
if (descriptor)
|
|
4406
|
-
Object.defineProperty(own, key, descriptor);
|
|
4407
|
-
else
|
|
4408
|
-
Reflect.deleteProperty(own, key);
|
|
4409
|
-
}
|
|
4410
|
-
Reflect.deleteProperty(own, ORIGINALS);
|
|
4411
|
-
return;
|
|
4412
|
-
}
|
|
4413
|
-
if (!originals2) {
|
|
4414
|
-
const kept = new Map(KEYS2.map((key) => [key, Object.getOwnPropertyDescriptor(own, key)]));
|
|
4415
|
-
Object.defineProperty(own, ORIGINALS, { configurable: true, value: kept });
|
|
4416
|
-
}
|
|
4417
|
-
for (const key of KEYS2) {
|
|
4418
|
-
const value = key === "width" || key === "availWidth" ? size2.width : key === "availHeight" ? size2.availHeight ?? size2.height : size2.height;
|
|
4419
|
-
Object.defineProperty(own, key, { configurable: true, enumerable: true, get: () => value });
|
|
4420
|
-
}
|
|
2593
|
+
// src/engine/style.ts
|
|
2594
|
+
var OWN2 = Symbol.for("devknobs.own");
|
|
2595
|
+
var NAME = Symbol.for("devknobs.name");
|
|
2596
|
+
var TEXT = Symbol.for("devknobs.text");
|
|
2597
|
+
var wrapped = new WeakMap;
|
|
2598
|
+
function isDocument(root) {
|
|
2599
|
+
return root.nodeType === 9;
|
|
4421
2600
|
}
|
|
4422
|
-
function
|
|
4423
|
-
|
|
2601
|
+
function documentOf(root) {
|
|
2602
|
+
return isDocument(root) ? root : root.ownerDocument ?? document;
|
|
4424
2603
|
}
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
if (!value) {
|
|
4432
|
-
reset6();
|
|
4433
|
-
return;
|
|
4434
|
-
}
|
|
4435
|
-
ensureStyle(NAME2).textContent = CSS2;
|
|
2604
|
+
function constructable(root) {
|
|
2605
|
+
const doc = isDocument(root) ? root : root.ownerDocument;
|
|
2606
|
+
const Sheet = doc?.defaultView?.CSSStyleSheet;
|
|
2607
|
+
if (typeof Sheet !== "function" || typeof Sheet.prototype.replaceSync !== "function")
|
|
2608
|
+
return null;
|
|
2609
|
+
return "adoptedStyleSheets" in root ? Sheet : null;
|
|
4436
2610
|
}
|
|
4437
|
-
function
|
|
4438
|
-
|
|
4439
|
-
ensureStyle(NAME2, doc).textContent = CSS2;
|
|
4440
|
-
return;
|
|
4441
|
-
}
|
|
4442
|
-
const observer3 = new MutationObserver(() => {
|
|
4443
|
-
if (!doc.documentElement)
|
|
4444
|
-
return;
|
|
4445
|
-
observer3.disconnect();
|
|
4446
|
-
ensureStyle(NAME2, doc).textContent = CSS2;
|
|
4447
|
-
});
|
|
4448
|
-
observer3.observe(doc, { childList: true });
|
|
2611
|
+
function styleNode(style) {
|
|
2612
|
+
return "nodeType" in style ? style : null;
|
|
4449
2613
|
}
|
|
4450
|
-
function
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
return;
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
return;
|
|
2614
|
+
function isOwnSheet(sheet) {
|
|
2615
|
+
return Reflect.get(sheet, OWN2) === true;
|
|
2616
|
+
}
|
|
2617
|
+
function wrap(root, sheet) {
|
|
2618
|
+
const had = wrapped.get(sheet);
|
|
2619
|
+
if (had)
|
|
2620
|
+
return had;
|
|
2621
|
+
const style = {
|
|
2622
|
+
get textContent() {
|
|
2623
|
+
const text2 = Reflect.get(sheet, TEXT);
|
|
2624
|
+
return typeof text2 === "string" ? text2 : "";
|
|
2625
|
+
},
|
|
2626
|
+
set textContent(value) {
|
|
2627
|
+
Reflect.set(sheet, TEXT, value ?? "");
|
|
2628
|
+
sheet.replaceSync(value ?? "");
|
|
2629
|
+
},
|
|
2630
|
+
sheet,
|
|
2631
|
+
remove() {
|
|
2632
|
+
root.adoptedStyleSheets = root.adoptedStyleSheets.filter((other) => other !== sheet);
|
|
4470
2633
|
}
|
|
4471
|
-
channel.port1.close();
|
|
4472
2634
|
};
|
|
4473
|
-
|
|
2635
|
+
wrapped.set(sheet, style);
|
|
2636
|
+
return style;
|
|
4474
2637
|
}
|
|
4475
|
-
function
|
|
4476
|
-
|
|
2638
|
+
function adopt(root, Sheet, name) {
|
|
2639
|
+
const sheet = new Sheet;
|
|
2640
|
+
Reflect.set(sheet, OWN2, true);
|
|
2641
|
+
if (name !== undefined)
|
|
2642
|
+
Reflect.set(sheet, NAME, name);
|
|
2643
|
+
root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
|
|
2644
|
+
return wrap(root, sheet);
|
|
4477
2645
|
}
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
if (value.on && !handler && !("ontouchstart" in window)) {
|
|
4485
|
-
Object.defineProperty(window, "ontouchstart", {
|
|
4486
|
-
configurable: true,
|
|
4487
|
-
enumerable: true,
|
|
4488
|
-
writable: true,
|
|
4489
|
-
value: null
|
|
4490
|
-
});
|
|
4491
|
-
handler = true;
|
|
4492
|
-
} else if (!value.on && handler) {
|
|
4493
|
-
Reflect.deleteProperty(window, "ontouchstart");
|
|
4494
|
-
handler = false;
|
|
4495
|
-
}
|
|
4496
|
-
const report = value.on && value.points;
|
|
4497
|
-
if (report && !points) {
|
|
4498
|
-
Object.defineProperty(navigator, "maxTouchPoints", {
|
|
4499
|
-
configurable: true,
|
|
4500
|
-
enumerable: true,
|
|
4501
|
-
get: () => TOUCH_POINTS
|
|
4502
|
-
});
|
|
4503
|
-
points = true;
|
|
4504
|
-
} else if (!report && points) {
|
|
4505
|
-
Reflect.deleteProperty(navigator, "maxTouchPoints");
|
|
4506
|
-
points = false;
|
|
2646
|
+
function addStyle(root, css) {
|
|
2647
|
+
const Sheet = constructable(root);
|
|
2648
|
+
if (Sheet) {
|
|
2649
|
+
const style2 = adopt(root, Sheet);
|
|
2650
|
+
style2.textContent = css;
|
|
2651
|
+
return style2;
|
|
4507
2652
|
}
|
|
2653
|
+
const style = documentOf(root).createElement("style");
|
|
2654
|
+
style.textContent = css;
|
|
2655
|
+
if (isDocument(root))
|
|
2656
|
+
(root.head ?? root.documentElement).appendChild(style);
|
|
2657
|
+
else
|
|
2658
|
+
root.append(style);
|
|
2659
|
+
return style;
|
|
4508
2660
|
}
|
|
4509
|
-
function
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
}
|
|
2661
|
+
function switchedSheet(root, name) {
|
|
2662
|
+
const Sheet = constructable(root);
|
|
2663
|
+
if (Sheet) {
|
|
2664
|
+
const sheet2 = new Sheet;
|
|
2665
|
+
Reflect.set(sheet2, OWN2, true);
|
|
2666
|
+
const off = () => {
|
|
2667
|
+
root.adoptedStyleSheets = root.adoptedStyleSheets.filter((other) => other !== sheet2);
|
|
2668
|
+
};
|
|
2669
|
+
let gone = false;
|
|
2670
|
+
return {
|
|
2671
|
+
sheet: sheet2,
|
|
2672
|
+
on() {
|
|
2673
|
+
if (!gone && !root.adoptedStyleSheets.includes(sheet2))
|
|
2674
|
+
root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet2];
|
|
2675
|
+
},
|
|
2676
|
+
off,
|
|
2677
|
+
remove() {
|
|
2678
|
+
gone = true;
|
|
2679
|
+
off();
|
|
2680
|
+
}
|
|
2681
|
+
};
|
|
4517
2682
|
}
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
2683
|
+
const style = documentOf(root).createElement("style");
|
|
2684
|
+
style.setAttribute("data-devknobs", name);
|
|
2685
|
+
if (isDocument(root))
|
|
2686
|
+
(root.head ?? root.documentElement).appendChild(style);
|
|
2687
|
+
else
|
|
2688
|
+
root.append(style);
|
|
2689
|
+
const sheet = style.sheet;
|
|
2690
|
+
if (!sheet) {
|
|
2691
|
+
style.remove();
|
|
2692
|
+
return null;
|
|
2693
|
+
}
|
|
2694
|
+
sheet.disabled = true;
|
|
2695
|
+
return {
|
|
2696
|
+
sheet,
|
|
2697
|
+
on() {
|
|
2698
|
+
sheet.disabled = false;
|
|
2699
|
+
},
|
|
2700
|
+
off() {
|
|
2701
|
+
sheet.disabled = true;
|
|
2702
|
+
},
|
|
2703
|
+
remove: () => style.remove()
|
|
2704
|
+
};
|
|
4525
2705
|
}
|
|
4526
|
-
function
|
|
4527
|
-
|
|
2706
|
+
function findStyle(name, doc = document) {
|
|
2707
|
+
const sheet = "adoptedStyleSheets" in doc ? doc.adoptedStyleSheets.find((own) => Reflect.get(own, NAME) === name) : undefined;
|
|
2708
|
+
return sheet ? wrap(doc, sheet) : doc.querySelector(`style[data-devknobs="${name}"]`);
|
|
4528
2709
|
}
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
.dot::after {
|
|
4544
|
-
content: "";
|
|
4545
|
-
position: absolute;
|
|
4546
|
-
inset: 0;
|
|
4547
|
-
box-sizing: border-box;
|
|
4548
|
-
border-radius: 50%;
|
|
4549
|
-
background: rgb(0 0 0 / 0.28);
|
|
4550
|
-
border: 1.5px solid rgb(255 255 255 / 0.85);
|
|
4551
|
-
box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25);
|
|
4552
|
-
transition: transform 80ms ease-out, background-color 80ms ease-out;
|
|
4553
|
-
}
|
|
4554
|
-
.dot.pressed::after {
|
|
4555
|
-
transform: scale(0.82);
|
|
4556
|
-
background: rgb(0 0 0 / 0.45);
|
|
4557
|
-
}
|
|
4558
|
-
@media (prefers-reduced-motion: reduce) {
|
|
4559
|
-
.dot::after { transition: none; }
|
|
4560
|
-
}
|
|
4561
|
-
`;
|
|
4562
|
-
var MARK_EVENT = "devknobs-touch-mark";
|
|
4563
|
-
function finite(value) {
|
|
4564
|
-
return typeof value === "number" && Number.isFinite(value);
|
|
4565
|
-
}
|
|
4566
|
-
function readMark(detail) {
|
|
4567
|
-
if (typeof detail !== "object" || detail === null)
|
|
4568
|
-
return null;
|
|
4569
|
-
const at = Reflect.get(detail, "at");
|
|
4570
|
-
const pressed = Reflect.get(detail, "pressed");
|
|
4571
|
-
const held = Reflect.get(detail, "held");
|
|
4572
|
-
if (typeof pressed !== "boolean" || typeof held !== "boolean")
|
|
4573
|
-
return null;
|
|
4574
|
-
if (at === null)
|
|
4575
|
-
return { at: null, pressed, held };
|
|
4576
|
-
if (typeof at !== "object")
|
|
4577
|
-
return null;
|
|
4578
|
-
const x = Reflect.get(at, "x");
|
|
4579
|
-
const y = Reflect.get(at, "y");
|
|
4580
|
-
return finite(x) && finite(y) ? { at: { x, y }, pressed, held } : null;
|
|
2710
|
+
function ensureStyle(name, doc = document) {
|
|
2711
|
+
const existing = findStyle(name, doc);
|
|
2712
|
+
if (existing)
|
|
2713
|
+
return existing;
|
|
2714
|
+
const Sheet = constructable(doc);
|
|
2715
|
+
if (Sheet)
|
|
2716
|
+
return adopt(doc, Sheet, name);
|
|
2717
|
+
const style = doc.createElement("style");
|
|
2718
|
+
style.setAttribute("data-devknobs", name);
|
|
2719
|
+
(doc.head ?? doc.documentElement).appendChild(style);
|
|
2720
|
+
return style;
|
|
2721
|
+
}
|
|
2722
|
+
function removeStyle(name, doc = document) {
|
|
2723
|
+
findStyle(name, doc)?.remove();
|
|
4581
2724
|
}
|
|
4582
2725
|
|
|
4583
|
-
export {
|
|
2726
|
+
export { CLOCK_SPEED_MIN, CLOCK_SPEED_MAX, CLOCK_PRESETS, NativeDate, realNow, setClock, clockOn, now, wrapDate, NOW_READERS, temporalNow, readNow, takeOver, RINGS, SIDES, pxOf, boxModel, contentSize, hasBox, ringQuads, oneQuad, isPlain, alignQuads, ringPaths, luminance, parseColor, isCustomColor, toHex, parseHex, readColor, inkOn, POSTURES, openOf, DEVICES, deviceOf, formOf, formId, screenOf, hasTouch, turn, versionOf, newer, stamped, FRESH_ATTRIBUTE, fresh, webStorage, loads, carried, ownReload, GEO_PRESETS, resolveGeo, apply, reset, ZOOM_PRESETS, ZOOM_MIN, ZOOM_MAX, percent, stepZoom, wheelZoom, anchorScroll, DEFAULT_PINNED, DEFAULT_STATE, SCHEMES, MOTIONS, CONTRASTS, TRANSPARENCIES, DIRS, GEO_ERRORS, CLOCK_MODES, ONLINES, CONNECTIONS, SAVE_DATAS, BARS, BROWSERS, ORIENTATIONS, EDGES, SIDES2 as SIDES1, DEV_ICONS, VISIONS, GRAB_COLORS, resetState, merge, load, save, keepPlace, FRAME_ATTRIBUTE, FRAME_NAME, SIZE_MIN, SIZE_MAX, DPR_MIN, DPR_MAX, isDevknobsFrame, nativeScheme, handsSchemeDown, UNFRAMED, EXITED, knobFrame, needsFrame, plainFrame, frameForced, framed, readMessage, leaveFor, post, systemMedia, watchSystemMedia, baseMatchMedia, still, ownInline, TEXT_MIN, TEXT_MAX, apply2 as apply1, reset2 as reset1, rewriteMediaText, authoredQuery, coarse, apply3 as apply2, destroy, isDocument, styleNode, isOwnSheet, addStyle, switchedSheet, ensureStyle, removeStyle };
|