@vinena/knobs 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +7 -6
  3. package/dist/context-amfyasb5.js +23 -0
  4. package/dist/context-svtr7vwt.js +22 -0
  5. package/dist/early.global.js +6 -6
  6. package/dist/edit/css.d.ts +59 -0
  7. package/dist/edit/html.d.ts +91 -0
  8. package/dist/edit/keep.d.ts +175 -0
  9. package/dist/edit/log.d.ts +107 -0
  10. package/dist/edit/replay.d.ts +28 -0
  11. package/dist/edit/risk.d.ts +33 -0
  12. package/dist/edit/rule.d.ts +31 -0
  13. package/dist/edit/source.d.ts +12 -0
  14. package/dist/edit/text.d.ts +66 -0
  15. package/dist/elementsview-fyc06wjt.js +3702 -0
  16. package/dist/elementsview-k6zvvcne.js +3701 -0
  17. package/dist/engine/browserdraw.d.ts +5 -0
  18. package/dist/engine/browserkit.d.ts +2 -0
  19. package/dist/engine/devices.d.ts +3 -2
  20. package/dist/engine/dock.d.ts +3 -4
  21. package/dist/engine/frame.d.ts +1 -1
  22. package/dist/engine/frames.d.ts +1 -0
  23. package/dist/engine/identity.d.ts +5 -1
  24. package/dist/engine/index.d.ts +2 -0
  25. package/dist/engine/mock.d.ts +0 -2
  26. package/dist/engine/mockdata.d.ts +4 -3
  27. package/dist/engine/mockdraw.d.ts +2 -14
  28. package/dist/engine/morphrun.d.ts +4 -0
  29. package/dist/engine/native.d.ts +31 -3
  30. package/dist/engine/notice.d.ts +1 -2
  31. package/dist/engine/style.d.ts +15 -0
  32. package/dist/engine/width.d.ts +3 -0
  33. package/dist/{framekit-w0v516w5.js → framekit-622h6w1f.js} +264 -105
  34. package/dist/{framekit-te90cjs0.js → framekit-yx612r28.js} +264 -105
  35. package/dist/index-0zp9py56.js +859 -0
  36. package/dist/{index-9re7sv56.js → index-1mstjadm.js} +126 -2167
  37. package/dist/{index-30fc6php.js → index-4a4x1bt2.js} +1 -1
  38. package/dist/index-58jdczmj.js +44 -0
  39. package/dist/index-5tv6sr74.js +23 -0
  40. package/dist/index-6bc2ztfd.js +688 -0
  41. package/dist/index-7cb4x1vj.js +1885 -0
  42. package/dist/index-a974q3aa.js +34 -0
  43. package/dist/{index-r72tz2vn.js → index-aymfvd8s.js} +1 -1
  44. package/dist/{index-trx7bxdk.js → index-aynkv7qk.js} +11 -8
  45. package/dist/{index-xjhwp5cj.js → index-dzm8ywq0.js} +504 -2362
  46. package/dist/{index-dan2kpsd.js → index-f60yax1j.js} +13 -8
  47. package/dist/index-f67wctn3.js +1858 -0
  48. package/dist/{index-agwr37gw.js → index-ftjdt358.js} +8 -171
  49. package/dist/{index-pewcdh28.js → index-gm51cthv.js} +2 -45
  50. package/dist/index-kfdzsyyw.js +1859 -0
  51. package/dist/index-t4kssacm.js +208 -0
  52. package/dist/index-v0ht9q0g.js +1518 -0
  53. package/dist/{index-sxe5079a.js → index-x59vz1xx.js} +262 -901
  54. package/dist/index-xh39jtkq.js +32 -0
  55. package/dist/index-yb7fc59g.js +718 -0
  56. package/dist/index-zd6adby9.js +496 -0
  57. package/dist/index.d.ts +62 -0
  58. package/dist/index.global.js +447 -160
  59. package/dist/index.js +533 -485
  60. package/dist/react-0wepdf60.js +1519 -0
  61. package/dist/{react-4pvp6amm.js → react-1gqwa2yw.js} +1 -1
  62. package/dist/{index-hv02xka3.js → react-3mfz1x2a.js} +126 -2167
  63. package/dist/react-4rbjw9af.js +33 -0
  64. package/dist/react-5rq7bnsy.js +210 -0
  65. package/dist/react-6bz05qk1.js +860 -0
  66. package/dist/{react-05jh9jv5.js → react-6fnxxs30.js} +8 -171
  67. package/dist/react-6q2cw2ya.js +689 -0
  68. package/dist/{react-sw8d8c94.js → react-6t4dbdzn.js} +11 -8
  69. package/dist/react-88es9b5q.js +719 -0
  70. package/dist/react-97b5b8j4.js +46 -0
  71. package/dist/{react-16spgn0h.js → react-bxzn8vq5.js} +1 -1
  72. package/dist/{react-ayg1bgw3.js → react-cs62p9qh.js} +83 -722
  73. package/dist/react-ethftdxp.js +497 -0
  74. package/dist/react-fp73vhyd.js +36 -0
  75. package/dist/{react-exjcpxma.js → react-me102s1a.js} +2 -45
  76. package/dist/react-t2qnewz2.js +24 -0
  77. package/dist/react-ttj8f9qp.js +1886 -0
  78. package/dist/{react-zy1mmhgz.js → react-v8497a41.js} +13 -8
  79. package/dist/{react-fm9y8dbn.js → react-wqn4sx0n.js} +276 -2133
  80. package/dist/react.js +529 -485
  81. package/dist/replay-j18rw92k.js +258 -0
  82. package/dist/replay-vtg0vqj2.js +257 -0
  83. package/dist/{storageview-s7heg93p.js → storageview-6xj7zb63.js} +11 -7
  84. package/dist/{storageview-r595qpt9.js → storageview-pzn8yaad.js} +11 -7
  85. package/dist/styles/force.d.ts +66 -0
  86. package/dist/types.d.ts +7 -0
  87. package/dist/ui/bindings.d.ts +31 -5
  88. package/dist/ui/changes.d.ts +49 -0
  89. package/dist/ui/cssauto.d.ts +119 -0
  90. package/dist/ui/cssedit.d.ts +80 -0
  91. package/dist/ui/domedit.d.ts +99 -0
  92. package/dist/ui/domtree.d.ts +26 -1
  93. package/dist/ui/elementsview.d.ts +19 -2
  94. package/dist/ui/htmledit.d.ts +62 -0
  95. package/dist/ui/inspector.d.ts +6 -1
  96. package/dist/ui/keys.d.ts +12 -8
  97. package/dist/ui/pane.d.ts +0 -2
  98. package/dist/ui/panel.d.ts +3 -0
  99. package/dist/ui/prefs.d.ts +30 -10
  100. package/dist/ui/settings.d.ts +10 -0
  101. package/dist/ui/size.d.ts +14 -22
  102. package/dist/ui/stylesview.d.ts +30 -1
  103. package/package.json +1 -1
  104. package/skills/devknobs/SKILL.md +95 -0
  105. package/dist/elementsview-2z4pkrdz.js +0 -2873
  106. package/dist/elementsview-qn8qyksa.js +0 -2874
  107. package/dist/index-78r0f8pw.js +0 -27
  108. package/dist/react-adky72h9.js +0 -29
@@ -2,10 +2,7 @@ import {
2
2
  FADE_CURVE,
3
3
  MORPH_TIME,
4
4
  bezier,
5
- columnEdge,
6
5
  coverAt,
7
- dockEdges,
8
- dockWidth,
9
6
  ease,
10
7
  fitCorners,
11
8
  folds,
@@ -14,7 +11,6 @@ import {
14
11
  keepMounted,
15
12
  lerp,
16
13
  moves,
17
- onDockWidth,
18
14
  plan,
19
15
  poseAt,
20
16
  poseOf,
@@ -28,97 +24,108 @@ import {
28
24
  turnOf,
29
25
  turnedPose,
30
26
  windowRect
31
- } from "./index-pewcdh28.js";
27
+ } from "./index-gm51cthv.js";
32
28
  import {
33
29
  hush,
34
30
  hushOnce,
35
31
  quietFetch
36
- } from "./index-r72tz2vn.js";
32
+ } from "./index-aymfvd8s.js";
33
+ import {
34
+ columnEdge,
35
+ dockEdges,
36
+ dockWidth,
37
+ onDockWidth
38
+ } from "./index-58jdczmj.js";
37
39
  import {
38
40
  copyText
39
41
  } from "./index-ztnjefrh.js";
40
42
  import {
41
43
  BARS_START,
42
44
  DOT_LOOK,
43
- FRAME_ATTRIBUTE,
44
- FRAME_NAME,
45
- FRESH_ATTRIBUTE,
46
45
  MARK_EVENT,
47
46
  MAT_COLORS,
48
47
  MAT_COLOR_NAMES,
49
48
  SAFARI_TEXT,
50
- UNFRAMED,
51
- ZOOM_MAX,
52
- ZOOM_PRESETS,
53
49
  Z_INDEX,
54
- __export,
55
- addStyle,
56
50
  adoptEarly,
57
51
  alphaAt,
58
- anchorScroll,
59
- apply3 as apply,
60
- apply4 as apply2,
52
+ apply,
53
+ apply1 as apply2,
61
54
  barsOf,
62
55
  barsStep,
63
- baseMatchMedia,
64
- carried,
65
56
  clearSnapshot,
66
- coarse,
67
- deviceOf,
68
57
  dropEarly,
69
- ensureStyle,
70
58
  equip,
71
59
  equip1 as equip2,
72
60
  follow,
73
- formId,
74
- formOf,
75
- fresh,
76
61
  handing,
77
- handsSchemeDown,
78
- hasTouch,
79
62
  islandOf,
80
63
  keep,
81
64
  keepDrawing,
82
65
  layoutOf,
83
- loads,
84
- luminance,
85
66
  matGradient,
86
- merge,
87
67
  mockOf,
88
68
  nativeEnabled,
89
- needsFrame,
90
- openOf,
91
- ownReload,
92
- parseColor,
93
- parseHex,
94
- percent,
95
69
  placeIn,
96
- plainFrame,
97
- post,
98
70
  putMat,
99
71
  readMark,
100
- readMessage,
101
72
  readSnapshot,
102
- removeStyle,
103
73
  round,
104
74
  runsUnderBars,
105
- screenOf,
106
75
  screenSizeOf,
107
76
  settles,
108
77
  snapshotKey,
109
- stepZoom,
110
- still,
111
78
  stopAdopting,
112
- styleNode,
113
- turn,
114
79
  turnRadius,
115
80
  turnRect,
116
81
  turnSides,
117
82
  uaPreset,
118
83
  userAgentOf,
119
- viewportOf,
84
+ viewportOf
85
+ } from "./index-7cb4x1vj.js";
86
+ import {
87
+ FRAME_ATTRIBUTE,
88
+ FRAME_NAME,
89
+ FRESH_ATTRIBUTE,
90
+ UNFRAMED,
91
+ ZOOM_MAX,
92
+ ZOOM_PRESETS,
93
+ addStyle,
94
+ anchorScroll,
95
+ baseMatchMedia,
96
+ carried,
97
+ coarse,
98
+ deviceOf,
99
+ ensureStyle,
100
+ formId,
101
+ formOf,
102
+ fresh,
103
+ handsSchemeDown,
104
+ hasTouch,
105
+ loads,
106
+ luminance,
107
+ merge,
108
+ needsFrame,
109
+ openOf,
110
+ ownReload,
111
+ parseColor,
112
+ parseHex,
113
+ percent,
114
+ plainFrame,
115
+ post,
116
+ readMessage,
117
+ removeStyle,
118
+ screenOf,
119
+ stepZoom,
120
+ still,
121
+ styleNode,
122
+ turn,
120
123
  wheelZoom
121
- } from "./index-xjhwp5cj.js";
124
+ } from "./index-dzm8ywq0.js";
125
+ import"./index-a974q3aa.js";
126
+ import {
127
+ __export
128
+ } from "./index-5tv6sr74.js";
122
129
 
123
130
  // src/engine/width.ts
124
131
  var exports_width = {};
@@ -130,6 +137,7 @@ __export(exports_width, {
130
137
  origin: () => origin,
131
138
  onZoom: () => onZoom,
132
139
  onRefused: () => onRefused,
140
+ onLoader: () => onLoader,
133
141
  onFramed: () => onFramed,
134
142
  onExit: () => onExit,
135
143
  label: () => label,
@@ -140,16 +148,17 @@ __export(exports_width, {
140
148
  apply: () => apply3,
141
149
  STRIP: () => STRIP,
142
150
  RIDE_SLOW: () => RIDE_SLOW,
143
- FRAME_API_WAIT: () => FRAME_API_WAIT
151
+ FRAME_API_WAIT: () => FRAME_API_WAIT,
152
+ COVER_CAP: () => COVER_CAP
144
153
  });
145
154
 
146
155
  // src/engine/identity.ts
147
156
  function identityOf(state) {
148
157
  const agent = uaPreset(state.ua.preset) ? state.ua.preset : userAgentOf(state.ua);
149
- return { agent, touch: hasTouch(state.device), dpr: state.dpr };
158
+ return { agent, touch: hasTouch(state.device), dpr: state.dpr, ...state.panel?.realPhone ? { served: true } : {} };
150
159
  }
151
160
  function stale(loaded, next) {
152
- return loaded !== null && (loaded.agent !== next.agent || loaded.touch !== next.touch || loaded.dpr !== next.dpr);
161
+ return loaded !== null && (loaded.agent !== next.agent || loaded.touch !== next.touch || loaded.dpr !== next.dpr || (loaded.served ?? false) !== (next.served ?? false));
153
162
  }
154
163
  var PATCHED = Symbol.for("devknobs.identity");
155
164
  function isIdentity(value) {
@@ -3190,7 +3199,6 @@ function bezelMock(id, orientation) {
3190
3199
  inset: sides,
3191
3200
  body: { x: 0, y: 0, ...size },
3192
3201
  screenRadius: turned ? turnRadius(bezel.radius, clockwise) : bezel.radius,
3193
- continuous: island !== null,
3194
3202
  bodyRadius: 0,
3195
3203
  parts,
3196
3204
  image: {
@@ -5300,6 +5308,7 @@ function readLook(frame2, probe = null) {
5300
5308
  background: white,
5301
5309
  top: white,
5302
5310
  bottom: white,
5311
+ header: false,
5303
5312
  footer: false,
5304
5313
  under: [],
5305
5314
  dark: false,
@@ -5317,7 +5326,8 @@ function readLook(frame2, probe = null) {
5317
5326
  const base = backgroundOf(doc, view, scheme === "dark");
5318
5327
  const [r, g, b] = base;
5319
5328
  const background = rgbText(base);
5320
- const top = edgeBar(doc, view, "top", base) ?? background;
5329
+ const header = edgeBar(doc, view, "top", base);
5330
+ const top = header ?? background;
5321
5331
  const last = () => colorAt(doc, view, view.innerWidth / 2, view.innerHeight - 1, base);
5322
5332
  const footer = edgeBar(doc, view, "bottom", base);
5323
5333
  const bottom = footer ?? last() ?? background;
@@ -5342,6 +5352,7 @@ function readLook(frame2, probe = null) {
5342
5352
  background,
5343
5353
  top,
5344
5354
  bottom,
5355
+ header: header !== null,
5345
5356
  footer: footer !== null,
5346
5357
  under,
5347
5358
  dark: luminance(r, g, b) < 0.4,
@@ -5392,6 +5403,12 @@ function createBrowser(glass, frame2, onChange, onReload = () => {}, ready = ()
5392
5403
  const band = createUnderbar(glass, frame2);
5393
5404
  const layer = el("div", "browser");
5394
5405
  layer.setAttribute("aria-hidden", "true");
5406
+ const seams = [el("div", "seam"), el("div", "seam")];
5407
+ for (const seam of seams) {
5408
+ seam.setAttribute("aria-hidden", "true");
5409
+ seam.style.cssText = "position:absolute;pointer-events:none";
5410
+ seam.hidden = true;
5411
+ }
5395
5412
  let view = null;
5396
5413
  let look = null;
5397
5414
  let painted = null;
@@ -5436,6 +5453,25 @@ function createBrowser(glass, frame2, onChange, onReload = () => {}, ready = ()
5436
5453
  const bars = view?.bars ?? null;
5437
5454
  const shown2 = view && showsBand(bars, look) && reaches(frame2) ? bandRect(applied, view.size.height) : null;
5438
5455
  band.show(shown2, view?.zoom ?? 1, look);
5456
+ placeSeams();
5457
+ };
5458
+ const placeSeams = () => {
5459
+ const ratio = glass.offsetWidth > 0 ? glass.getBoundingClientRect().width / glass.offsetWidth : 1;
5460
+ const unit = 1 / ((window.devicePixelRatio || 1) * (ratio || 1));
5461
+ const rects = look && reaches(frame2) ? seamRects(applied, view?.zoom ?? 1, unit, look) : { top: null, bottom: null };
5462
+ const colors = [look?.top ?? "", look?.bottom ?? ""];
5463
+ [rects.top, rects.bottom].forEach((rect, index) => {
5464
+ const seam = seams[index];
5465
+ if (!seam)
5466
+ return;
5467
+ seam.hidden = rect === null;
5468
+ if (!rect)
5469
+ return;
5470
+ if (!seam.isConnected)
5471
+ glass.insertBefore(seam, layer.isConnected ? layer : null);
5472
+ place(seam, rect.x, rect.y, rect.width, rect.height);
5473
+ seam.style.background = colors[index] ?? "";
5474
+ });
5439
5475
  };
5440
5476
  const resample = () => {
5441
5477
  sampling = 0;
@@ -5653,6 +5689,9 @@ function createBrowser(glass, frame2, onChange, onReload = () => {}, ready = ()
5653
5689
  view = next;
5654
5690
  if (next.bars && !layer.isConnected)
5655
5691
  glass.append(layer);
5692
+ for (const seam of seams)
5693
+ if (seam.isConnected)
5694
+ glass.insertBefore(seam, layer.isConnected ? layer : null);
5656
5695
  if (!next.bars)
5657
5696
  layer.remove();
5658
5697
  place(layer, 0, 0, next.size.width, next.size.height);
@@ -5693,12 +5732,25 @@ function createBrowser(glass, frame2, onChange, onReload = () => {}, ready = ()
5693
5732
  query = null;
5694
5733
  watched2 = null;
5695
5734
  layer.remove();
5735
+ for (const seam of seams)
5736
+ seam.remove();
5696
5737
  blank.remove();
5697
5738
  band.remove();
5698
5739
  }
5699
5740
  };
5700
5741
  return browser;
5701
5742
  }
5743
+ function seamRects(page, zoom, unit, look) {
5744
+ if (!page)
5745
+ return { top: null, bottom: null };
5746
+ const x = page.x * zoom;
5747
+ const width = page.width * zoom;
5748
+ const edge = (y) => ({ x, y: y - 2 * unit, width, height: 4 * unit });
5749
+ return {
5750
+ top: look.header ? edge(page.y * zoom) : null,
5751
+ bottom: look.footer ? edge((page.y + page.height) * zoom) : null
5752
+ };
5753
+ }
5702
5754
 
5703
5755
  // src/engine/fit.ts
5704
5756
  var STRIP_TOP = 8;
@@ -6383,7 +6435,6 @@ var EDGE = "#48484a";
6383
6435
  var RIM2 = "#2a2a2c";
6384
6436
  var BAND = 2.5;
6385
6437
  var UNDER = 2;
6386
- var CONTINUOUS = { extent: 1.363, shape: 1.52 };
6387
6438
  var MOCK_CSS = `
6388
6439
  /* Clips the frame to the screen's corners in a mock, in the body's color so
6389
6440
  no blue shows at the seam. */
@@ -6392,14 +6443,6 @@ var MOCK_CSS = `
6392
6443
  overflow: hidden;
6393
6444
  background: ${BODY};
6394
6445
  }
6395
- /* A phone with an island: its continuous corners where the browser draws
6396
- them, over the round radius set on it, which the mat still reads. */
6397
- @supports (corner-shape: superellipse(2)) {
6398
- .glass.continuous {
6399
- border-radius: var(--continuous) !important;
6400
- corner-shape: superellipse(${CONTINUOUS.shape});
6401
- }
6402
- }
6403
6446
  /* Over the frame, and never in the way of a pointer. */
6404
6447
  .mock {
6405
6448
  position: absolute;
@@ -6431,28 +6474,6 @@ function roundRect(rect, radius) {
6431
6474
  `V${y + a}${arc2(a)} ${x + a} ${y}Z`
6432
6475
  ].join("");
6433
6476
  }
6434
- function continuousRect(rect, radius) {
6435
- const { x, y, width, height } = rect;
6436
- const power = 2 / 2 ** CONTINUOUS.shape;
6437
- const most = Math.min(width, height) / 2;
6438
- const lengths = corners(radius).map((r) => Math.max(0, Math.min(r * CONTINUOUS.extent, most)));
6439
- const ends = [
6440
- [x, y, 1, 1],
6441
- [x + width, y, -1, 1],
6442
- [x + width, y + height, -1, -1],
6443
- [x, y + height, 1, -1]
6444
- ];
6445
- const points = ends.flatMap(([cx, cy, sx, sy], at) => {
6446
- const length = lengths[at] ?? 0;
6447
- return Array.from({ length: 17 }, (_, step) => {
6448
- const t = (at % 2 === 0 ? step : 16 - step) / 16 * (Math.PI / 2);
6449
- const px = cx + sx * length * (1 - Math.cos(t) ** power);
6450
- const py = cy + sy * length * (1 - Math.sin(t) ** power);
6451
- return `${px.toFixed(2)} ${py.toFixed(2)}`;
6452
- });
6453
- });
6454
- return `M${points.join("L")}Z`;
6455
- }
6456
6477
  function drawMock(mock, screenSize, href) {
6457
6478
  const svg = svgNode("svg", {
6458
6479
  class: "mock",
@@ -6479,10 +6500,9 @@ function drawMock(mock, screenSize, href) {
6479
6500
  }
6480
6501
  const opening = { x: mock.inset.left, y: mock.inset.top, ...screenSize };
6481
6502
  const { x, y, width, height } = mock.body;
6482
- const screen = mock.continuous ? continuousRect : roundRect;
6483
6503
  const front = { x: x + BAND, y: y + BAND, width: width - 2 * BAND, height: height - 2 * BAND };
6484
6504
  const inside = roundRect(front, corners(mock.bodyRadius, -BAND));
6485
- svg.append(...mock.parts.filter((shape) => shape.kind === "button").map(part), svgNode("path", { class: "band", d: roundRect(mock.body, mock.bodyRadius) + inside }), svgNode("path", { class: "body", d: inside + screen(opening, mock.screenRadius) }), ...mock.parts.filter((shape) => shape.kind !== "button").map(part));
6505
+ svg.append(...mock.parts.filter((shape) => shape.kind === "button").map(part), svgNode("path", { class: "band", d: roundRect(mock.body, mock.bodyRadius) + inside }), svgNode("path", { class: "body", d: inside + roundRect(opening, mock.screenRadius) }), ...mock.parts.filter((shape) => shape.kind !== "button").map(part));
6486
6506
  return svg;
6487
6507
  }
6488
6508
 
@@ -7615,12 +7635,22 @@ function clear3(color) {
7615
7635
  return color === "" || color === "transparent" || /[,/]\s*0\)$/.test(color);
7616
7636
  }
7617
7637
  function paintVeil(veil) {
7638
+ veil.className = "veil";
7618
7639
  const root = getComputedStyle(document.documentElement);
7619
7640
  const body = document.body ? getComputedStyle(document.body).backgroundColor : "";
7620
7641
  const color = [root.backgroundColor, body].find((value) => !clear3(value));
7621
7642
  veil.style.background = color ?? "Canvas";
7622
7643
  veil.style.colorScheme = root.colorScheme || "normal";
7623
7644
  }
7645
+ function paintCover(scene) {
7646
+ scene.veil.className = "veil loading";
7647
+ scene.veil.style.background = "";
7648
+ scene.veil.style.colorScheme = scene.scheme();
7649
+ }
7650
+ function evenHole(hole) {
7651
+ const round3 = Math.max(...hole.radius);
7652
+ return { ...hole, radius: [round3, round3, round3, round3] };
7653
+ }
7624
7654
  function openVeiled(scene, share) {
7625
7655
  seen = { veil: share, content: 0, hole: scene.fullRect() };
7626
7656
  paintVeil(scene.veil);
@@ -7702,6 +7732,8 @@ function moveHole(scene, to, time) {
7702
7732
  }
7703
7733
  function placeHole(scene, hole) {
7704
7734
  seen.hole = hole;
7735
+ scene.veil.style.setProperty("--dot-x", `${hole.x + hole.width / 2}px`);
7736
+ scene.veil.style.setProperty("--dot-y", `${hole.y + hole.height / 2}px`);
7705
7737
  const path3 = holePath(hole);
7706
7738
  if (path3 === cut2)
7707
7739
  return;
@@ -7713,7 +7745,7 @@ function track2(scene) {
7713
7745
  const step = () => {
7714
7746
  if (tracking !== frame2)
7715
7747
  return;
7716
- placeHole(scene, scene.screenRect());
7748
+ placeHole(scene, evenHole(scene.screenRect()));
7717
7749
  frame2 = window.requestAnimationFrame(step);
7718
7750
  tracking = frame2;
7719
7751
  };
@@ -7763,7 +7795,7 @@ async function perform(scene, step, target, instant) {
7763
7795
  } else if (step.kind === "layout") {
7764
7796
  scene.layout();
7765
7797
  } else if (step.kind === "mat") {
7766
- const to = step.to === "screen" ? scene.screenRect : step.to === "round" ? () => rounded(scene.fullRect()) : scene.fullRect;
7798
+ const to = step.to === "screen" ? () => evenHole(scene.screenRect()) : step.to === "round" ? () => rounded(scene.fullRect()) : scene.fullRect;
7767
7799
  const going = run;
7768
7800
  await moveHole(scene, to, instant ? 0 : step.time);
7769
7801
  if (step.to === "screen" && !instant && going?.live())
@@ -7780,13 +7812,16 @@ async function perform(scene, step, target, instant) {
7780
7812
  }
7781
7813
  function start(scene, target) {
7782
7814
  if (!clipped) {
7783
- seen = { veil: 1, content: 1, hole: scene.screenRect() };
7784
- paintVeil(scene.veil);
7815
+ seen = { veil: 1, content: 1, hole: evenHole(scene.screenRect()) };
7816
+ if (target === "closed")
7817
+ paintVeil(scene.veil);
7785
7818
  scene.veil.style.opacity = "1";
7786
7819
  cut2 = "";
7787
7820
  placeHole(scene, seen.hole);
7788
7821
  clipped = true;
7789
7822
  }
7823
+ if (target === "open")
7824
+ paintCover(scene);
7790
7825
  const shown3 = { ...seen, covered: scene.covered(), open: sameHole(seen.hole, scene.fullRect()) };
7791
7826
  const next = sequence(plan(shown3, target), target);
7792
7827
  run = next;
@@ -8064,8 +8099,6 @@ function explain(box2, refusal, again) {
8064
8099
  };
8065
8100
  button.addEventListener("click", run2);
8066
8101
  why.append(button);
8067
- if (retry.now)
8068
- run2();
8069
8102
  }
8070
8103
  }
8071
8104
 
@@ -8456,8 +8489,45 @@ var VIEWPORT_CSS = `
8456
8489
  top: 0;
8457
8490
  left: 0;
8458
8491
  }
8492
+ /* Holds the cover over the frame. */
8493
+ .page { position: relative; }
8459
8494
  /* Where a phone's browser leaves the page in its screen. */
8460
8495
  .page.placed { position: absolute; }
8496
+ /* Over the frame while its page loads or a host loads it again, so a browser's
8497
+ error page never flashes: the frame's own canvas, a dot that breathes. */
8498
+ .loading {
8499
+ position: absolute;
8500
+ inset: 0;
8501
+ display: flex;
8502
+ align-items: center;
8503
+ justify-content: center;
8504
+ background: Canvas;
8505
+ color: CanvasText;
8506
+ /* The user's own scheme, unless the knob forces one. */
8507
+ color-scheme: light dark;
8508
+ pointer-events: none;
8509
+ }
8510
+ .loading[hidden] { display: none; }
8511
+ /* The veil wears the cover between two devices, its dot in the mat's opening. */
8512
+ .veil.loading::after {
8513
+ position: absolute;
8514
+ left: var(--dot-x, 50%);
8515
+ top: var(--dot-y, 50%);
8516
+ translate: -50% -50%;
8517
+ }
8518
+ .loading::after {
8519
+ content: "";
8520
+ width: 6px;
8521
+ height: 6px;
8522
+ border-radius: 50%;
8523
+ background: currentColor;
8524
+ opacity: 0.25;
8525
+ animation: devknobs-breathe 1.2s ease-in-out infinite alternate;
8526
+ }
8527
+ @keyframes devknobs-breathe { to { opacity: 0.08; } }
8528
+ @media (prefers-reduced-motion: reduce) {
8529
+ .loading::after { animation: none; }
8530
+ }
8461
8531
  iframe {
8462
8532
  display: block;
8463
8533
  border: 0;
@@ -8593,7 +8663,14 @@ var notice = null;
8593
8663
  var exit2 = null;
8594
8664
  var askWhy = null;
8595
8665
  var framed = null;
8666
+ var loader = null;
8667
+ var ANSWER_WAIT = 6000;
8596
8668
  var refusals = 0;
8669
+ var loadCover = null;
8670
+ var coverPoll = 0;
8671
+ var coverCap = 0;
8672
+ var COVER_POLL = 50;
8673
+ var COVER_CAP = ANSWER_WAIT + 2000;
8597
8674
  var current = {
8598
8675
  ...UNFRAMED,
8599
8676
  scheme: "system",
@@ -8652,16 +8729,78 @@ function onRefused(handler) {
8652
8729
  function onFramed(handler) {
8653
8730
  framed = handler;
8654
8731
  }
8732
+ function onLoader(handler) {
8733
+ loader = handler;
8734
+ }
8735
+ function navigate(target, url) {
8736
+ if (!loader?.(target, url))
8737
+ target.src = url;
8738
+ }
8655
8739
  function whyRefused() {
8656
8740
  const box2 = notice;
8657
8741
  const turn2 = ++refusals;
8658
8742
  if (!box2)
8659
8743
  return;
8660
8744
  explain(box2, null, loadAgain);
8661
- askWhy?.(frameUrl).then((refusal) => {
8662
- if (turn2 === refusals && notice === box2 && !box2.hidden)
8663
- explain(box2, refusal, loadAgain);
8664
- }, () => {});
8745
+ if (!askWhy) {
8746
+ hideCover();
8747
+ box2.hidden = false;
8748
+ return;
8749
+ }
8750
+ showCover();
8751
+ const still2 = () => turn2 === refusals && notice === box2;
8752
+ let answered = false;
8753
+ const show2 = (refusal) => {
8754
+ if (!still2())
8755
+ return;
8756
+ hideCover();
8757
+ box2.hidden = false;
8758
+ explain(box2, refusal, loadAgain);
8759
+ };
8760
+ window.setTimeout(() => {
8761
+ if (!answered)
8762
+ show2(null);
8763
+ }, ANSWER_WAIT);
8764
+ askWhy(frameUrl).then((refusal) => {
8765
+ answered = true;
8766
+ const retry = refusal?.retry;
8767
+ if (!retry?.now) {
8768
+ show2(refusal);
8769
+ return;
8770
+ }
8771
+ retry.run().then(() => {
8772
+ if (still2())
8773
+ loadAgain();
8774
+ }, (error) => show2({ why: error instanceof Error ? error.message : String(error) }));
8775
+ }, () => {
8776
+ answered = true;
8777
+ show2(null);
8778
+ });
8779
+ }
8780
+ function readable() {
8781
+ const doc = frameDocument();
8782
+ return doc !== null && doc.URL !== "about:blank" && doc.readyState !== "loading";
8783
+ }
8784
+ function showCover() {
8785
+ if (!loadCover)
8786
+ return;
8787
+ clearTimeout(coverPoll);
8788
+ clearTimeout(coverCap);
8789
+ loadCover.hidden = false;
8790
+ const look = () => {
8791
+ if (readable())
8792
+ hideCover();
8793
+ else
8794
+ coverPoll = window.setTimeout(look, COVER_POLL);
8795
+ };
8796
+ coverPoll = window.setTimeout(look, COVER_POLL);
8797
+ coverCap = window.setTimeout(hideCover, COVER_CAP);
8798
+ }
8799
+ function hideCover() {
8800
+ clearTimeout(coverPoll);
8801
+ clearTimeout(coverCap);
8802
+ if (loadCover)
8803
+ loadCover.hidden = true;
8665
8804
  }
8666
8805
  function loadAgain() {
8667
8806
  if (!frame3)
@@ -8671,7 +8810,8 @@ function loadAgain() {
8671
8810
  refusals += 1;
8672
8811
  if (notice)
8673
8812
  notice.hidden = true;
8674
- frame3.src = frameUrl;
8813
+ showCover();
8814
+ navigate(frame3, frameUrl);
8675
8815
  }
8676
8816
  function onZoom(handler) {
8677
8817
  zoomTo = handler;
@@ -8693,9 +8833,13 @@ function onLoad() {
8693
8833
  loadedAt = performance.now();
8694
8834
  const doc = frameDocument();
8695
8835
  if (notice)
8696
- notice.hidden = doc !== null;
8836
+ notice.hidden = true;
8697
8837
  if (doc === null)
8698
8838
  whyRefused();
8839
+ else {
8840
+ refusals += 1;
8841
+ hideCover();
8842
+ }
8699
8843
  locate();
8700
8844
  const view = frameWindow();
8701
8845
  if (view && doc) {
@@ -8881,16 +9025,13 @@ function showMock(mock, place2) {
8881
9025
  mockDrawing = mock ? drawMock(mock, place2, href) : null;
8882
9026
  if (mockDrawing)
8883
9027
  screen.append(mockDrawing);
8884
- glass.className = mock ? `glass mocked${mock.continuous ? " continuous" : ""}` : "glass";
9028
+ glass.className = mock ? "glass mocked" : "glass";
8885
9029
  }
8886
9030
  const zoom = place2.zoom;
8887
9031
  glass.style.left = mock ? `${mock.inset.left * zoom}px` : "";
8888
9032
  glass.style.top = mock ? `${mock.inset.top * zoom}px` : "";
8889
9033
  const round4 = mock ? corners(mock.screenRadius).map((radius) => `${radius * zoom}px`) : [];
8890
9034
  glass.style.borderRadius = round4.join(" ");
8891
- const [corner = 0] = mock ? corners(mock.screenRadius) : [];
8892
- const continuous = mock?.continuous ? `${corner * CONTINUOUS.extent * zoom}px` : "";
8893
- glass.style.setProperty("--continuous", continuous);
8894
9035
  glass.style.boxShadow = href ? `0 0 0 ${UNDER * zoom}px #000` : "";
8895
9036
  if (mock && mockDrawing) {
8896
9037
  mockDrawing.style.width = `${mock.width * zoom}px`;
@@ -8982,6 +9123,10 @@ function resize() {
8982
9123
  frame3.style.colorScheme = current.scheme;
8983
9124
  else
8984
9125
  frame3.style.removeProperty("color-scheme");
9126
+ if (loadCover)
9127
+ loadCover.style.colorScheme = coverScheme();
9128
+ if (veil?.className === "veil loading")
9129
+ veil.style.colorScheme = coverScheme();
8985
9130
  frame3.style.filter = visionFilter(current.vision);
8986
9131
  checkZoom();
8987
9132
  warmFold();
@@ -9214,6 +9359,9 @@ function handBack() {
9214
9359
  showPage();
9215
9360
  window.scrollTo({ left: scroll.x, top: scroll.y, behavior: "instant" });
9216
9361
  }
9362
+ function coverScheme() {
9363
+ return current.scheme === "system" ? "" : current.scheme;
9364
+ }
9217
9365
  function scene() {
9218
9366
  if (!host || !back || !veil)
9219
9367
  return null;
@@ -9223,6 +9371,7 @@ function scene() {
9223
9371
  content: contentNodes,
9224
9372
  screenRect,
9225
9373
  fullRect,
9374
+ scheme: coverScheme,
9226
9375
  covered: () => covered,
9227
9376
  hidePage,
9228
9377
  painted,
@@ -9313,12 +9462,12 @@ function open(veiled, first) {
9313
9462
  waiting2.then(() => {
9314
9463
  if (frame3 !== opened)
9315
9464
  return;
9316
- opened.src = frameUrl;
9317
9465
  opened.addEventListener("load", onLoad);
9466
+ navigate(opened, frameUrl);
9318
9467
  });
9319
- } else {
9320
- frame3.src = frameUrl;
9468
+ } else if (!loader) {
9321
9469
  frame3.addEventListener("load", onLoad);
9470
+ navigate(frame3, frameUrl);
9322
9471
  }
9323
9472
  track({
9324
9473
  view: frameWindow,
@@ -9329,7 +9478,11 @@ function open(veiled, first) {
9329
9478
  notice = createNotice(() => exit2?.());
9330
9479
  pageBox = document.createElement("div");
9331
9480
  pageBox.className = "page";
9332
- pageBox.append(frame3);
9481
+ loadCover = document.createElement("div");
9482
+ loadCover.className = "loading";
9483
+ loadCover.setAttribute("aria-hidden", "true");
9484
+ pageBox.append(frame3, loadCover);
9485
+ showCover();
9333
9486
  glass.append(pageBox);
9334
9487
  browser = createBrowser(glass, frame3, resize, onReloading, painted);
9335
9488
  touchDot = createTouchDot({
@@ -9354,6 +9507,10 @@ function open(veiled, first) {
9354
9507
  window.addEventListener("resize", resize);
9355
9508
  window.addEventListener("pagehide", keep2);
9356
9509
  body.append(host);
9510
+ if (!waiting2 && loader) {
9511
+ frame3.addEventListener("load", onLoad);
9512
+ navigate(frame3, frameUrl);
9513
+ }
9357
9514
  stopKeeping = keepMounted(host, { restored: remounted });
9358
9515
  const now = scene();
9359
9516
  if (veiled !== null && now)
@@ -9416,6 +9573,8 @@ function teardown() {
9416
9573
  mockDrawing = null;
9417
9574
  mockKey = "";
9418
9575
  frame3 = null;
9576
+ hideCover();
9577
+ loadCover = null;
9419
9578
  notice = null;
9420
9579
  readout = null;
9421
9580
  caption = null;