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