@vinena/knobs 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +7 -0
  3. package/dist/early.global.js +6 -6
  4. package/dist/{elementsview-6g274ptr.js → elementsview-2z4pkrdz.js} +4 -4
  5. package/dist/{elementsview-pkzp9kc6.js → elementsview-qn8qyksa.js} +4 -4
  6. package/dist/engine/browserdraw.d.ts +24 -2
  7. package/dist/engine/browserkit.d.ts +18 -1
  8. package/dist/engine/browserui.d.ts +162 -22
  9. package/dist/engine/devicon.d.ts +59 -0
  10. package/dist/engine/fit.d.ts +4 -3
  11. package/dist/engine/foldflip.d.ts +40 -0
  12. package/dist/engine/identity.d.ts +7 -4
  13. package/dist/engine/mock.d.ts +16 -0
  14. package/dist/engine/mockdata.d.ts +4 -1
  15. package/dist/engine/mockdraw.d.ts +14 -2
  16. package/dist/engine/pageshot.d.ts +5 -2
  17. package/dist/engine/safaridraw.d.ts +162 -10
  18. package/dist/engine/screen.d.ts +24 -0
  19. package/dist/engine/store.d.ts +2 -1
  20. package/dist/engine/tabicon.d.ts +43 -0
  21. package/dist/engine/toplayer.d.ts +62 -0
  22. package/dist/engine/touchpointer.d.ts +0 -21
  23. package/dist/engine/underbar.d.ts +61 -0
  24. package/dist/{framekit-g96t6nmq.js → framekit-te90cjs0.js} +2325 -1572
  25. package/dist/{framekit-3n7p79ht.js → framekit-w0v516w5.js} +2325 -1572
  26. package/dist/host.d.ts +51 -0
  27. package/dist/{index-64rd634h.js → index-30fc6php.js} +1 -1
  28. package/dist/{index-dvr4x91q.js → index-9re7sv56.js} +20 -8
  29. package/dist/{index-0casarhy.js → index-agwr37gw.js} +1 -1
  30. package/dist/{index-2d6wvs8h.js → index-dan2kpsd.js} +4 -4
  31. package/dist/{index-kzsb9drs.js → index-hv02xka3.js} +20 -8
  32. package/dist/{index-peh33xjv.js → index-pewcdh28.js} +1 -1
  33. package/dist/{index-d0cjxjsm.js → index-r72tz2vn.js} +1 -1
  34. package/dist/{index-33x9hxe3.js → index-sxe5079a.js} +605 -187
  35. package/dist/{index-5d6qzte3.js → index-trx7bxdk.js} +4 -4
  36. package/dist/{index-5baxvd3v.js → index-xjhwp5cj.js} +275 -112
  37. package/dist/index.d.ts +26 -1
  38. package/dist/index.global.js +270 -176
  39. package/dist/index.js +398 -124
  40. package/dist/instance.d.ts +23 -4
  41. package/dist/{react-pdvseef0.js → react-05jh9jv5.js} +1 -1
  42. package/dist/{react-4kbj1t4h.js → react-16spgn0h.js} +1 -1
  43. package/dist/{react-65tgdbs8.js → react-4pvp6amm.js} +1 -1
  44. package/dist/{react-qv0nykcv.js → react-ayg1bgw3.js} +602 -184
  45. package/dist/{react-xxfpfddf.js → react-exjcpxma.js} +1 -1
  46. package/dist/{react-carf84xv.js → react-fm9y8dbn.js} +275 -112
  47. package/dist/{react-mv9y20jy.js → react-sw8d8c94.js} +4 -4
  48. package/dist/{react-71a9ypex.js → react-zy1mmhgz.js} +4 -4
  49. package/dist/react.js +394 -123
  50. package/dist/{storageview-vdkbp6rt.js → storageview-r595qpt9.js} +4 -4
  51. package/dist/{storageview-j9d44f99.js → storageview-s7heg93p.js} +4 -4
  52. package/dist/types.d.ts +7 -0
  53. package/dist/ui/footer.d.ts +9 -2
  54. package/dist/ui/panel.d.ts +16 -2
  55. package/dist/ui/settings.d.ts +17 -1
  56. package/dist/version.d.ts +2 -0
  57. package/package.json +3 -2
  58. package/skills/devknobs/SKILL.md +1 -1
  59. package/dist/elementsview-jnkbhzkj.js +0 -2873
  60. package/dist/elementsview-tf4qzmtw.js +0 -2874
  61. package/dist/engine/endroom.d.ts +0 -21
  62. package/dist/framekit-095qevka.js +0 -8838
  63. package/dist/framekit-q5aad770.js +0 -8839
  64. package/dist/index-hw56t3zy.js +0 -4800
  65. package/dist/index-k015tb6c.js +0 -357
  66. package/dist/index-ke6v7919.js +0 -4801
  67. package/dist/index-qxye1j73.js +0 -528
  68. package/dist/index-z5ytnj01.js +0 -4563
  69. package/dist/index-zvze25nf.js +0 -686
  70. package/dist/react-eygws6cx.js +0 -358
  71. package/dist/react-sq9pkw4k.js +0 -687
  72. package/dist/react-vjm88w4t.js +0 -4564
  73. package/dist/react-znfrjqk8.js +0 -529
  74. package/dist/storageview-sb23henh.js +0 -2729
  75. package/dist/storageview-vf8v8q8j.js +0 -2728
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  lerp,
9
9
  setDockWidth,
10
10
  watchColumn
11
- } from "./index-peh33xjv.js";
11
+ } from "./index-pewcdh28.js";
12
12
  import {
13
13
  GRAB_COLORS as GRAB_COLORS2,
14
14
  GRAB_COLOR_NAMES,
@@ -17,10 +17,10 @@ import {
17
17
  createGrab,
18
18
  createInspect,
19
19
  oneAtATime
20
- } from "./index-2d6wvs8h.js";
20
+ } from "./index-dan2kpsd.js";
21
21
  import {
22
22
  hushOnce
23
- } from "./index-d0cjxjsm.js";
23
+ } from "./index-r72tz2vn.js";
24
24
  import {
25
25
  label
26
26
  } from "./index-78r0f8pw.js";
@@ -38,7 +38,7 @@ import {
38
38
  showPane,
39
39
  stopOnLoad,
40
40
  viewHead
41
- } from "./index-k015tb6c.js";
41
+ } from "./index-trx7bxdk.js";
42
42
  import {
43
43
  actButton,
44
44
  button,
@@ -67,11 +67,13 @@ import {
67
67
  tabBar,
68
68
  textField,
69
69
  toolbar
70
- } from "./index-zvze25nf.js";
70
+ } from "./index-30fc6php.js";
71
71
  import {
72
72
  BINDING_ICONS,
73
73
  BODY_CAP,
74
+ HOST_RESET,
74
75
  KEYS_FIELD,
76
+ LAYER,
75
77
  LOCALE_PRESETS,
76
78
  READ_MS,
77
79
  ROW_ICONS,
@@ -84,6 +86,8 @@ import {
84
86
  comboSpoken,
85
87
  comboText,
86
88
  defaultKeys,
89
+ devIconFor,
90
+ devIconShown,
87
91
  escapeStep,
88
92
  exports_engine,
89
93
  foldRest,
@@ -92,6 +96,7 @@ import {
92
96
  getState,
93
97
  glyph,
94
98
  highlightAt,
99
+ holdInTopLayer,
95
100
  holdingHinge,
96
101
  icon,
97
102
  isFunctionKey,
@@ -127,7 +132,7 @@ import {
127
132
  watchPanel,
128
133
  zoomAction,
129
134
  zoomKey
130
- } from "./index-33x9hxe3.js";
135
+ } from "./index-sxe5079a.js";
131
136
  import {
132
137
  BARS,
133
138
  BROWSERS,
@@ -140,6 +145,7 @@ import {
140
145
  DEFAULT_PINNED,
141
146
  DEFAULT_STATE,
142
147
  DEVICES,
148
+ DEV_ICONS,
143
149
  DIRS,
144
150
  DPR_MAX,
145
151
  DPR_MIN,
@@ -196,6 +202,7 @@ import {
196
202
  realNow,
197
203
  resolveGeo,
198
204
  rewriteMediaText,
205
+ runsUnderBars,
199
206
  setSystemMedia,
200
207
  stamped,
201
208
  still,
@@ -204,7 +211,7 @@ import {
204
211
  userAgentOf,
205
212
  watchSystemMedia,
206
213
  webStorage
207
- } from "./index-5baxvd3v.js";
214
+ } from "./index-xjhwp5cj.js";
208
215
 
209
216
  // src/ui/knobs.ts
210
217
  var MINUTE = 60000;
@@ -806,6 +813,9 @@ var BARS2 = {
806
813
  function safariShown(state) {
807
814
  return platformOf(screenNow(state)) === "safari" && barsShown(state);
808
815
  }
816
+ function safariSideways(state) {
817
+ return safariShown(state) && state.orientation === "landscape" && runsUnderBars(screenNow(state));
818
+ }
809
819
  var EDGE_TO_EDGE = {
810
820
  id: "edgeToEdge",
811
821
  label: "edge to edge",
@@ -813,11 +823,11 @@ var EDGE_TO_EDGE = {
813
823
  control: "switch",
814
824
  options: OFF_ON,
815
825
  aliases: ["edge", "under bars", "true height", "full height"],
816
- read: (state) => flag(state.edgeToEdge && safariShown(state)),
826
+ read: (state) => flag(state.edgeToEdge && safariSideways(state)),
817
827
  write: (value) => ({ edgeToEdge: value === "on" }),
818
828
  reset: { edgeToEdge: DEFAULT_STATE.edgeToEdge },
819
829
  brief: () => "",
820
- offers: (state) => safariShown(state) ? ["off", "on"] : []
830
+ offers: (state) => safariSideways(state) ? ["off", "on"] : []
821
831
  };
822
832
  var WIDTH = {
823
833
  id: "width",
@@ -1412,7 +1422,7 @@ function knobs() {
1412
1422
  touchPointer: spec("On a touch device, the mouse acts as a finger in its frame.", flag2),
1413
1423
  browser: spec("Where a phone's browser keeps its bars, or off.", oneOf(BROWSERS)),
1414
1424
  bars: spec("Whether the browser bars follow the scroll or stay one way.", oneOf(BARS)),
1415
- edgeToEdge: spec("Safari draws the page under its bars to the bottom of the screen.", flag2),
1425
+ edgeToEdge: spec("On an iPhone held sideways, the page runs under Safari's top row. Upright, and on the iPhone Duo, it is ignored.", flag2),
1416
1426
  frame: spec("Render the page in a full-width frame even at full width.", flag2, "frame"),
1417
1427
  dpr: spec("Device pixel ratio inside the frame.", { type: "number", min: DPR_MIN, max: DPR_MAX, or: ["system"] }, "frame"),
1418
1428
  zoom: spec("How big the frame is drawn. The page sees the same viewport.", {
@@ -1441,7 +1451,8 @@ function knobs() {
1441
1451
  fields: {
1442
1452
  open: field2("The panel is open.", flag2),
1443
1453
  docked: field2("Pinned to its side as a column, with the page in a frame beside it.", flag2),
1444
- handle: field2("Show the knobs handle on the window's edge while the panel is closed. false keeps it out of screenshots for this tab.", flag2)
1454
+ handle: field2("Show the knobs handle on the window's edge while the panel is closed. false keeps it out of screenshots for this tab.", flag2),
1455
+ devIcon: field2("The yellow DEV ribbon on the tab's icon and the apple-touch-icon. auto shows it on a local host only: localhost, *.localhost, *.local, 0.0.0.0, a loopback or private network address.", oneOf(DEV_ICONS))
1445
1456
  }
1446
1457
  }, "frame")
1447
1458
  };
@@ -1453,8 +1464,8 @@ function describe() {
1453
1464
  }
1454
1465
  function defaultOf(key) {
1455
1466
  if (key === "panel") {
1456
- const { open, docked, handle } = DEFAULT_STATE.panel;
1457
- return { open, docked, handle };
1467
+ const { open, docked, handle, devIcon } = DEFAULT_STATE.panel;
1468
+ return { open, docked, handle, devIcon };
1458
1469
  }
1459
1470
  if (key === "clock") {
1460
1471
  const { mode, at, speed, header } = DEFAULT_STATE.clock;
@@ -1579,6 +1590,62 @@ function pageChoices(options2) {
1579
1590
  }
1580
1591
  return chosen;
1581
1592
  }
1593
+ var PREFER_HINT = "page: a site's own knobs, say a local build, runs the panel where the site has one; real browser settings are off then";
1594
+ function preferOf(handed) {
1595
+ const prefer = Reflect.get(handed, "prefer");
1596
+ if (typeof prefer !== "object" || prefer === null)
1597
+ return null;
1598
+ const value = Reflect.get(prefer, "value");
1599
+ const change = Reflect.get(prefer, "change");
1600
+ if (value !== "extension" && value !== "page" || typeof change !== "function")
1601
+ return null;
1602
+ const now2 = Reflect.get(prefer, "now");
1603
+ return {
1604
+ value,
1605
+ change: (next) => void Reflect.apply(change, prefer, [next]),
1606
+ ...typeof now2 === "function" ? {
1607
+ now: () => {
1608
+ const current = Reflect.apply(now2, prefer, []);
1609
+ return current === "extension" ? "extension" : "page";
1610
+ }
1611
+ } : {}
1612
+ };
1613
+ }
1614
+ function stepsAside(prefer, take) {
1615
+ return prefer === "page" && typeof take === "function";
1616
+ }
1617
+ function takesBack(prefer) {
1618
+ return prefer !== "page";
1619
+ }
1620
+ function rankOf(host) {
1621
+ const rank = Reflect.get(host, "rank");
1622
+ if (typeof rank !== "object" || rank === null)
1623
+ return null;
1624
+ const build = Reflect.get(rank, "build");
1625
+ const version = Reflect.get(rank, "version");
1626
+ if (build !== "store" && build !== "local" || typeof version !== "string")
1627
+ return null;
1628
+ return { build, version };
1629
+ }
1630
+ function numbers(version) {
1631
+ const found = /^(\d+)\.(\d+)\.(\d+)/.exec(version);
1632
+ return found ? found.slice(1).map(Number) : [0, 0, 0];
1633
+ }
1634
+ function outranks(a, b) {
1635
+ if (!b)
1636
+ return true;
1637
+ if (a.build !== b.build)
1638
+ return a.build === "local";
1639
+ const [x, y] = [numbers(a.version), numbers(b.version)];
1640
+ for (let index = 0;index < 3; index++) {
1641
+ if (x[index] !== y[index])
1642
+ return (x[index] ?? 0) > (y[index] ?? 0);
1643
+ }
1644
+ return a.version > b.version;
1645
+ }
1646
+ function stoodDownNote(other) {
1647
+ return `${other?.build ?? "older"} extension stood down`;
1648
+ }
1582
1649
 
1583
1650
  // src/instance.ts
1584
1651
  var OWNER = Symbol.for("devknobs.owner");
@@ -1586,13 +1653,13 @@ var HOST = Symbol.for("devknobs.host");
1586
1653
  function isHost(value) {
1587
1654
  return typeof value === "object" && value !== null && typeof Reflect.get(value, "release") === "function" && typeof Reflect.get(value, "adopt") === "function";
1588
1655
  }
1589
- function claim(scope, release, adopt, api) {
1656
+ function claim(scope, release, adopt, api, extras = {}) {
1590
1657
  const previous = Reflect.get(scope, OWNER);
1591
1658
  if (typeof previous === "function" && previous !== release)
1592
1659
  previous();
1593
1660
  Reflect.set(scope, OWNER, release);
1594
1661
  if (adopt)
1595
- Reflect.set(scope, HOST, { release, adopt, api });
1662
+ Reflect.set(scope, HOST, { release, adopt, api, ...extras });
1596
1663
  else
1597
1664
  Reflect.deleteProperty(scope, HOST);
1598
1665
  }
@@ -1852,6 +1919,101 @@ function createKeys(options2 = {}) {
1852
1919
  };
1853
1920
  }
1854
1921
 
1922
+ // src/ui/footer.ts
1923
+ var FRESH_NOTE = "fresh mode: nothing is kept";
1924
+ function runtimeLabel(host, version) {
1925
+ return `${host ? "extension" : "page"} ${version}`;
1926
+ }
1927
+ function overflowBadge(on, count) {
1928
+ return on && count !== null ? `${count} overflowing` : "";
1929
+ }
1930
+ function keyLabel(combo, mac) {
1931
+ return combo ? comboLabel(combo, mac) : "";
1932
+ }
1933
+ function keyChips(keys, grab, mac, inspect = false) {
1934
+ const chips = [
1935
+ { command: "panel", key: comboLabel(keys.panel, mac), word: BINDING_WORDS.panel },
1936
+ { command: "search", key: "/", word: "search" }
1937
+ ];
1938
+ if (grab) {
1939
+ chips.push({ command: "grab", key: keyLabel(keys.grab, mac), word: BINDING_WORDS.grab });
1940
+ }
1941
+ if (inspect) {
1942
+ const key = keyLabel(keys.inspect, mac);
1943
+ chips.push({ command: "inspect", key, word: BINDING_WORDS.inspect });
1944
+ }
1945
+ chips.push({ command: "replay", key: keyLabel(keys.replay, mac), word: BINDING_WORDS.replay }, { command: "reset", key: keyLabel(keys.reset, mac), word: BINDING_WORDS.reset });
1946
+ return chips;
1947
+ }
1948
+ function iconHint(className, label2, glyph2) {
1949
+ const node = button(`hint ${className}`, "");
1950
+ if (glyph2)
1951
+ node.append(glyph2);
1952
+ node.setAttribute("aria-label", label2);
1953
+ return node;
1954
+ }
1955
+ function createFooter(keys, grab, mac, inspect = null, runtime = null) {
1956
+ const foot = el("div", "foot");
1957
+ const badge = el("span", "badge");
1958
+ const meta = el("div", "meta");
1959
+ const hints = new Map;
1960
+ const hintKeys = new Map;
1961
+ for (const chip of keyChips(keys.get(), grab !== null, mac, inspect !== null)) {
1962
+ const node = button("hint", "");
1963
+ node.dataset.command = chip.command;
1964
+ const key = el("kbd", "hint-key", chip.key);
1965
+ node.append(key, chip.word);
1966
+ meta.append(node);
1967
+ hints.set(chip.command, node);
1968
+ hintKeys.set(chip.command, key);
1969
+ }
1970
+ const pin = iconHint("pin-toggle", pinWord(false));
1971
+ let pinShown = null;
1972
+ const sided = (name) => {
1973
+ const glyph2 = icon(name, 12);
1974
+ glyph2.setAttribute("class", "glyph sided");
1975
+ return glyph2;
1976
+ };
1977
+ const flip = iconHint("flip-toggle", SIDE_WORD, sided("panel-left"));
1978
+ const collapse = iconHint("collapse-toggle", COLLAPSE_WORD, sided("panel-right-close"));
1979
+ const keysToggle = iconHint("keys-toggle", "settings", icon("settings", 12));
1980
+ meta.append(flip, collapse, pin, keysToggle);
1981
+ function drawPin(docked) {
1982
+ if (docked === pinShown)
1983
+ return;
1984
+ pinShown = docked;
1985
+ flip.hidden = !docked;
1986
+ collapse.hidden = !docked;
1987
+ pin.replaceChildren(icon(docked ? "pin-off" : "pin", 12));
1988
+ pin.setAttribute("aria-label", pinWord(docked));
1989
+ pin.setAttribute("aria-pressed", docked ? "true" : "false");
1990
+ }
1991
+ drawPin(false);
1992
+ foot.append(badge);
1993
+ if (fresh())
1994
+ foot.append(el("span", "fresh-note", FRESH_NOTE));
1995
+ if (runtime)
1996
+ foot.append(el("span", "runtime", runtime));
1997
+ foot.append(meta);
1998
+ return {
1999
+ foot,
2000
+ badge,
2001
+ hints,
2002
+ pin,
2003
+ flip,
2004
+ collapse,
2005
+ keysToggle,
2006
+ drawPin,
2007
+ drawKeys(now2) {
2008
+ for (const chip of keyChips(now2, grab !== null, mac, inspect !== null)) {
2009
+ const key = hintKeys.get(chip.command);
2010
+ if (key)
2011
+ key.textContent = chip.key;
2012
+ }
2013
+ }
2014
+ };
2015
+ }
2016
+
1855
2017
  // src/ui/list.ts
1856
2018
  function rowOrder(state) {
1857
2019
  const ids = ROWS.map((row) => row.id);
@@ -2257,8 +2419,8 @@ function createDrag(context) {
2257
2419
  if (wrap.dataset.side !== side) {
2258
2420
  jump(() => {
2259
2421
  wrap.dataset.side = side;
2260
- host.style.left = side === "left" ? "0" : "";
2261
- host.style.right = side === "right" ? "0" : "";
2422
+ host.style.left = side === "left" ? "0" : "auto";
2423
+ host.style.right = side === "right" ? "0" : "auto";
2262
2424
  });
2263
2425
  }
2264
2426
  if (getState().panel.docked) {
@@ -2500,96 +2662,6 @@ function createDrag(context) {
2500
2662
  };
2501
2663
  }
2502
2664
 
2503
- // src/ui/footer.ts
2504
- var FRESH_NOTE = "fresh mode: nothing is kept";
2505
- function overflowBadge(on, count) {
2506
- return on && count !== null ? `${count} overflowing` : "";
2507
- }
2508
- function keyLabel(combo, mac) {
2509
- return combo ? comboLabel(combo, mac) : "";
2510
- }
2511
- function keyChips(keys, grab, mac, inspect = false) {
2512
- const chips = [
2513
- { command: "panel", key: comboLabel(keys.panel, mac), word: BINDING_WORDS.panel },
2514
- { command: "search", key: "/", word: "search" }
2515
- ];
2516
- if (grab) {
2517
- chips.push({ command: "grab", key: keyLabel(keys.grab, mac), word: BINDING_WORDS.grab });
2518
- }
2519
- if (inspect) {
2520
- const key = keyLabel(keys.inspect, mac);
2521
- chips.push({ command: "inspect", key, word: BINDING_WORDS.inspect });
2522
- }
2523
- chips.push({ command: "replay", key: keyLabel(keys.replay, mac), word: BINDING_WORDS.replay }, { command: "reset", key: keyLabel(keys.reset, mac), word: BINDING_WORDS.reset });
2524
- return chips;
2525
- }
2526
- function iconHint(className, label2, glyph2) {
2527
- const node = button(`hint ${className}`, "");
2528
- if (glyph2)
2529
- node.append(glyph2);
2530
- node.setAttribute("aria-label", label2);
2531
- return node;
2532
- }
2533
- function createFooter(keys, grab, mac, inspect = null) {
2534
- const foot = el("div", "foot");
2535
- const badge = el("span", "badge");
2536
- const meta = el("div", "meta");
2537
- const hints = new Map;
2538
- const hintKeys = new Map;
2539
- for (const chip of keyChips(keys.get(), grab !== null, mac, inspect !== null)) {
2540
- const node = button("hint", "");
2541
- node.dataset.command = chip.command;
2542
- const key = el("kbd", "hint-key", chip.key);
2543
- node.append(key, chip.word);
2544
- meta.append(node);
2545
- hints.set(chip.command, node);
2546
- hintKeys.set(chip.command, key);
2547
- }
2548
- const pin = iconHint("pin-toggle", pinWord(false));
2549
- let pinShown = null;
2550
- const sided = (name) => {
2551
- const glyph2 = icon(name, 12);
2552
- glyph2.setAttribute("class", "glyph sided");
2553
- return glyph2;
2554
- };
2555
- const flip = iconHint("flip-toggle", SIDE_WORD, sided("panel-left"));
2556
- const collapse = iconHint("collapse-toggle", COLLAPSE_WORD, sided("panel-right-close"));
2557
- const keysToggle = iconHint("keys-toggle", "settings", icon("settings", 12));
2558
- meta.append(flip, collapse, pin, keysToggle);
2559
- function drawPin(docked) {
2560
- if (docked === pinShown)
2561
- return;
2562
- pinShown = docked;
2563
- flip.hidden = !docked;
2564
- collapse.hidden = !docked;
2565
- pin.replaceChildren(icon(docked ? "pin-off" : "pin", 12));
2566
- pin.setAttribute("aria-label", pinWord(docked));
2567
- pin.setAttribute("aria-pressed", docked ? "true" : "false");
2568
- }
2569
- drawPin(false);
2570
- foot.append(badge);
2571
- if (fresh())
2572
- foot.append(el("span", "fresh-note", FRESH_NOTE));
2573
- foot.append(meta);
2574
- return {
2575
- foot,
2576
- badge,
2577
- hints,
2578
- pin,
2579
- flip,
2580
- collapse,
2581
- keysToggle,
2582
- drawPin,
2583
- drawKeys(now2) {
2584
- for (const chip of keyChips(now2, grab !== null, mac, inspect !== null)) {
2585
- const key = hintKeys.get(chip.command);
2586
- if (key)
2587
- key.textContent = chip.key;
2588
- }
2589
- }
2590
- };
2591
- }
2592
-
2593
2665
  // src/ui/inspector.ts
2594
2666
  var STYLES_VIEW = "styles";
2595
2667
  var SELECT = "select an element";
@@ -2597,7 +2669,7 @@ var PANE = { openPane, paneView, onPane, retitlePane, showPane };
2597
2669
  function here(element) {
2598
2670
  return element.isConnected && element.ownerDocument.defaultView !== null;
2599
2671
  }
2600
- function createInspector(context, load = () => import("./elementsview-jnkbhzkj.js").then(({ createElementsView }) => ({ createStylesView: createElementsView })), pane = PANE) {
2672
+ function createInspector(context, load = () => import("./elementsview-2z4pkrdz.js").then(({ createElementsView }) => ({ createStylesView: createElementsView })), pane = PANE) {
2601
2673
  const { inspect, tips, prefs } = context;
2602
2674
  const listeners = new Set;
2603
2675
  let view = null;
@@ -6603,6 +6675,39 @@ function createSettings(context) {
6603
6675
  keysView.append(row);
6604
6676
  nativeSwitch2.addEventListener("click", () => context.setNative(nativeSwitch2.getAttribute("aria-checked") !== "true"));
6605
6677
  }
6678
+ const prefer = context.prefer;
6679
+ const preferChoice = segments({
6680
+ options: [
6681
+ { value: "extension", label: "extension" },
6682
+ { value: "page", label: "page" }
6683
+ ],
6684
+ label: "prefer",
6685
+ onChange: (value) => context.setPrefer(value === "page" ? "page" : "extension")
6686
+ });
6687
+ if (prefer) {
6688
+ preferChoice.node.classList.add("row-control");
6689
+ const hint = el("div", "row-hint", PREFER_HINT);
6690
+ hint.id = "devknobs-prefer-hint";
6691
+ preferChoice.node.setAttribute("aria-describedby", hint.id);
6692
+ const row = rowBox({
6693
+ main: el("div", "main"),
6694
+ glyph: icon("chevrons-left-right"),
6695
+ title: "prefer",
6696
+ ends: [preferChoice.node]
6697
+ }).box;
6698
+ row.append(hint);
6699
+ keysView.append(row);
6700
+ }
6701
+ const devIconSwitch = button("switch row-control", "");
6702
+ devIconSwitch.setAttribute("role", "switch");
6703
+ devIconSwitch.setAttribute("aria-label", "dev tab icon");
6704
+ keysView.append(rowBox({
6705
+ main: el("div", "main"),
6706
+ glyph: icon("image"),
6707
+ title: "dev tab icon",
6708
+ ends: [devIconSwitch]
6709
+ }).box);
6710
+ devIconSwitch.addEventListener("click", () => context.setDevIcon(!context.devIconShown()));
6606
6711
  keysView.append(rowsLabel("shortcuts"));
6607
6712
  const keyViews = new Map;
6608
6713
  for (const binding of bindingsHere) {
@@ -6734,6 +6839,9 @@ function createSettings(context) {
6734
6839
  drawHandle(shown2) {
6735
6840
  mark(handleSwitch, shown2, "aria-checked");
6736
6841
  },
6842
+ drawDevIcon(shown2) {
6843
+ mark(devIconSwitch, shown2, "aria-checked");
6844
+ },
6737
6845
  drawNative(on, note) {
6738
6846
  mark(nativeSwitch2, on, "aria-checked");
6739
6847
  const hint = note ?? native?.hint ?? "";
@@ -6743,6 +6851,10 @@ function createSettings(context) {
6743
6851
  if (note)
6744
6852
  said.textContent = note;
6745
6853
  },
6854
+ drawPrefer() {
6855
+ if (prefer)
6856
+ preferChoice.set(prefer.value());
6857
+ },
6746
6858
  recordingKey(event) {
6747
6859
  if (recording === null)
6748
6860
  return false;
@@ -7632,6 +7744,8 @@ button:focus-visible { outline: 1px solid var(--faint); outline-offset: -1px; }
7632
7744
  .badge.hot { color: var(--hot); }
7633
7745
  /* Says fresh mode is on, as quiet as the key hints under it. */
7634
7746
  .fresh-note { font-size: 10px; line-height: 1.4; color: var(--faint); }
7747
+ /* Which copy runs the panel, as quiet. */
7748
+ .runtime { font-size: 10px; line-height: 1.4; color: var(--faint); font-variant-numeric: tabular-nums; }
7635
7749
  /* The key hints, each a button for what its key does. Where they leave no
7636
7750
  room, the line wraps. */
7637
7751
  .meta {
@@ -7717,6 +7831,8 @@ button:focus-visible { outline: 1px solid var(--faint); outline-offset: -1px; }
7717
7831
  takes no height of its own, so the row is as tall as any. */
7718
7832
  .main > .row-button { align-self: center; margin: -2px 0 -2px auto; }
7719
7833
  .main > .row-button:not([hidden]) + .row-control { margin-left: 0; }
7834
+ /* Segments at a row's end, as the settings' choice of who runs the panel, take no more height than its title. */
7835
+ .main > .seg.row-control { margin-top: -3px; margin-bottom: -3px; }
7720
7836
  /* The panel's icons face the side the panel is on. */
7721
7837
  .wrap[data-side="left"] .glyph.sided { transform: scaleX(-1); }
7722
7838
  .key-set {
@@ -7763,11 +7879,17 @@ button:focus-visible { outline: 1px solid var(--faint); outline-offset: -1px; }
7763
7879
  its slots, and starts where the view's layout says. Its body under that scrolls on its own. The view asks for the panel's tallest and the panel's
7764
7880
  own limit shrinks it to what the window has, so the panel is as tall as it
7765
7881
  gets whatever the view holds. The body is a container, so what a view
7766
- holds can lay itself out by how wide the view is. */
7882
+ holds can lay itself out by how wide the view is. A view takes the
7883
+ window's whole height, past the limit a list keeps. */
7884
+ .wrap[data-mode="view"] .panel {
7885
+ max-height: calc(100vh - 16px);
7886
+ max-height: calc(100dvh - 16px);
7887
+ }
7767
7888
  .view {
7768
7889
  flex: 0 1 auto;
7769
7890
  min-height: 0;
7770
- height: 672px;
7891
+ height: 100vh;
7892
+ height: 100dvh;
7771
7893
  display: flex;
7772
7894
  flex-direction: column;
7773
7895
  gap: 4px;
@@ -8121,9 +8243,13 @@ button:focus-visible { outline: 1px solid var(--faint); outline-offset: -1px; }
8121
8243
  as deep lines do in the browser's tools. The selected line has a ground of
8122
8244
  its own, a blue one while the tree has the focus, and ends with a quiet
8123
8245
  reference to it. A node that changed lights for a moment. */
8124
- .elements { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
8246
+ /* The tree takes what the styles leave of the view, and keeps the height its
8247
+ edge was dragged to once it was. */
8248
+ .elements { display: flex; flex-direction: column; min-height: 100%; gap: 4px; }
8249
+ .elements > * { min-width: 0; }
8125
8250
  .dom {
8126
8251
  position: relative;
8252
+ flex: 1 0 auto;
8127
8253
  height: 40vh;
8128
8254
  min-height: 96px;
8129
8255
  max-height: 85vh;
@@ -8133,6 +8259,7 @@ button:focus-visible { outline: 1px solid var(--faint); outline-offset: -1px; }
8133
8259
  scrollbar-width: thin;
8134
8260
  scrollbar-color: var(--line) transparent;
8135
8261
  }
8262
+ .dom[style*="height"] { flex-grow: 0; }
8136
8263
  .dom-tree { width: min-content; min-width: 100%; font: 11px/1.6 var(--mono); }
8137
8264
  .dom-row {
8138
8265
  display: flex;
@@ -8575,7 +8702,7 @@ s.css-decl, s.css-decl .css-var, s.css-decl .css-name { color: var(--faint); tex
8575
8702
  `;
8576
8703
 
8577
8704
  // src/ui/panel.ts
8578
- var HOST_STYLE = "position:fixed;top:0;z-index:2147483646;pointer-events:none";
8705
+ var HOST_STYLE = "position:fixed;top:0;right:auto;bottom:auto;left:auto;width:auto;height:auto;z-index:2147483647;pointer-events:none";
8579
8706
  function ownCss(media) {
8580
8707
  const settle2 = (_whole, query) => {
8581
8708
  const scheme = rewriteMediaText(query.trim(), "prefers-color-scheme", media.scheme);
@@ -8613,6 +8740,7 @@ function createPanel(options2 = {}) {
8613
8740
  host.setAttribute("data-devknobs", "panel");
8614
8741
  host.style.cssText = HOST_STYLE;
8615
8742
  const root = host.attachShadow({ mode: "open" });
8743
+ addStyle(root, HOST_RESET);
8616
8744
  const style = addStyle(root, "");
8617
8745
  const stopSystem = watchSystemMedia((media) => {
8618
8746
  style.textContent = media ? ownCss(media) : CSS;
@@ -8654,7 +8782,7 @@ function createPanel(options2 = {}) {
8654
8782
  const home = el("div", "home pane");
8655
8783
  lay(home, "rows");
8656
8784
  home.append(rows, empty, add, head, results);
8657
- const footer = createFooter(keys, grab, mac, inspect);
8785
+ const footer = createFooter(keys, grab, mac, inspect, options2.prefer?.runtime ?? null);
8658
8786
  const { foot, badge, hints, keysToggle, pin, collapse } = footer;
8659
8787
  const tip = el("div", "tip");
8660
8788
  tip.setAttribute("aria-hidden", "true");
@@ -8679,11 +8807,15 @@ function createPanel(options2 = {}) {
8679
8807
  renderKeys,
8680
8808
  handleShown: handleShows,
8681
8809
  showHandle: () => setState({ panel: { handle: true } }),
8810
+ devIconShown: () => devIconShown(getState().panel.devIcon, window.location.hostname),
8811
+ setDevIcon: (on) => setState({ panel: { devIcon: devIconFor(on, window.location.hostname) } }),
8682
8812
  native: nativeSwitch()?.setting ?? null,
8683
8813
  setNative: (on) => {
8684
8814
  nativeSwitch()?.setting.change(on);
8685
8815
  setNative(on, null);
8686
8816
  },
8817
+ prefer: options2.prefer ?? null,
8818
+ setPrefer: (value) => options2.prefer?.change(value),
8687
8819
  searching: () => palette.searching(),
8688
8820
  leaveSearch: () => palette.leaveSearch()
8689
8821
  });
@@ -8777,9 +8909,11 @@ function createPanel(options2 = {}) {
8777
8909
  const handleShown = handleShows();
8778
8910
  wrap.dataset.handle = handleShown ? "shown" : "hidden";
8779
8911
  settings.drawHandle(handleShown);
8912
+ settings.drawDevIcon(devIconShown(state.panel.devIcon, window.location.hostname));
8780
8913
  const nativeNow = nativeSwitch();
8781
8914
  if (nativeNow)
8782
8915
  settings.drawNative(nativeNow.on, nativeNow.note);
8916
+ settings.drawPrefer();
8783
8917
  dockSlide.aim({
8784
8918
  docked: state.panel.docked,
8785
8919
  side: state.panel.side,
@@ -9028,16 +9162,20 @@ function createPanel(options2 = {}) {
9028
9162
  const resizes = new ResizeObserver(() => layout());
9029
9163
  resizes.observe(panel);
9030
9164
  function attach() {
9031
- if (document.body && host.parentNode !== document.body)
9032
- document.body.append(host);
9165
+ if (!document.body || host.parentNode === document.body)
9166
+ return;
9167
+ document.body.append(host);
9168
+ hold.raise();
9033
9169
  }
9034
9170
  render();
9035
9171
  (document.body ?? document.documentElement).append(host);
9172
+ const hold = holdInTopLayer(host, LAYER.panel);
9036
9173
  if (!document.body)
9037
9174
  document.addEventListener("DOMContentLoaded", attach, { once: true });
9038
- const stopKeeping = keepMounted(host);
9175
+ const stopKeeping = keepMounted(host, { restored: () => hold.raise() });
9039
9176
  layout("edge");
9040
9177
  return {
9178
+ drawPrefer: () => settings.drawPrefer(),
9041
9179
  destroy() {
9042
9180
  settings.stopRecording();
9043
9181
  unsubscribe();
@@ -9085,11 +9223,15 @@ function createPanel(options2 = {}) {
9085
9223
  dockSlide.destroy();
9086
9224
  document.removeEventListener("DOMContentLoaded", attach);
9087
9225
  stopKeeping();
9226
+ hold.release();
9088
9227
  host.remove();
9089
9228
  }
9090
9229
  };
9091
9230
  }
9092
9231
 
9232
+ // src/version.ts
9233
+ var VERSION = "0.5.2";
9234
+
9093
9235
  // src/index.ts
9094
9236
  var PRESETS = {
9095
9237
  locale: LOCALE_PRESETS,
@@ -9107,18 +9249,40 @@ var mounted = null;
9107
9249
  var hostedBy = null;
9108
9250
  var RETAKES = 3;
9109
9251
  var retaken = 0;
9252
+ var preferNow = null;
9253
+ var waiting = null;
9254
+ var deferred = null;
9255
+ var handedPrefer = null;
9256
+ var beaten = null;
9110
9257
  function mount(options2 = {}) {
9111
9258
  if (panel || stopKeys)
9112
9259
  return;
9113
9260
  const host = options2.host ? null : hostOf(window);
9114
9261
  if (host) {
9262
+ handedPrefer = null;
9115
9263
  hostedBy = host;
9116
- host.adopt(options2);
9264
+ deferred = options2;
9265
+ const take = Object.assign((handed) => takeFrom(options2, handed), {
9266
+ pending: () => deferred === options2 && !panel && !stopKeys
9267
+ });
9268
+ host.adopt(options2, take);
9117
9269
  return;
9118
9270
  }
9271
+ if (options2.host && options2.build) {
9272
+ const holder = hostOf(window);
9273
+ if (holder && !beats(options2.build, holder)) {
9274
+ standDown(options2, holder);
9275
+ return;
9276
+ }
9277
+ if (holder)
9278
+ beaten = { other: rankOf(holder) };
9279
+ }
9280
+ preferNow = options2.host ? options2.prefer?.value ?? null : null;
9281
+ if (!options2.host && !options2.prefer && handedPrefer)
9282
+ options2 = { ...options2, prefer: handedPrefer };
9119
9283
  applyOnLoad();
9120
9284
  if (options2.host)
9121
- claim(window, unmount, adopt, api);
9285
+ claim(window, unmount, adopt, api, options2.build ? { rank: rankFor(options2.build), outranked } : {});
9122
9286
  else
9123
9287
  claim(window, unmount);
9124
9288
  expose(window, api);
@@ -9145,7 +9309,57 @@ function attach(options2) {
9145
9309
  return;
9146
9310
  }
9147
9311
  choose(options2);
9148
- panel = createPanel({ keys: live, grab: grabControl, inspect, handle: options2.handle });
9312
+ panel = createPanel({
9313
+ keys: live,
9314
+ grab: grabControl,
9315
+ inspect,
9316
+ handle: options2.handle,
9317
+ prefer: panelPrefer(options2)
9318
+ });
9319
+ }
9320
+ function panelPrefer(options2) {
9321
+ const setting = options2.prefer;
9322
+ if (!setting)
9323
+ return;
9324
+ return {
9325
+ value: () => preferNow ?? setting.now?.() ?? setting.value,
9326
+ change: (value) => {
9327
+ setting.change(value);
9328
+ setPrefer(value);
9329
+ },
9330
+ runtime: [runtimeLabel(options2.host === true, VERSION), ...options2.host && beaten ? [stoodDownNote(beaten.other)] : []].join(" · ")
9331
+ };
9332
+ }
9333
+ function rankFor(build) {
9334
+ return { build, version: VERSION };
9335
+ }
9336
+ function beats(build, holder) {
9337
+ const theirs = rankOf(holder);
9338
+ if (!theirs && holder.rank !== undefined)
9339
+ return false;
9340
+ return outranks(rankFor(build), theirs);
9341
+ }
9342
+ function standDown(options2, holder) {
9343
+ options2.stoodDown?.();
9344
+ if (options2.build)
9345
+ holder.outranked?.(rankFor(options2.build));
9346
+ }
9347
+ function outranked(other) {
9348
+ beaten = { other: rankOf({ rank: other }) };
9349
+ if (!mounted || !panel)
9350
+ return;
9351
+ detach();
9352
+ attach(mounted);
9353
+ }
9354
+ function takeFrom(options2, handed) {
9355
+ if (deferred !== options2 || panel || stopKeys || hostOf(window))
9356
+ return false;
9357
+ deferred = null;
9358
+ hostedBy = null;
9359
+ const prefer = preferOf(handed);
9360
+ handedPrefer = prefer;
9361
+ mount(prefer ? { ...options2, prefer } : options2);
9362
+ return true;
9149
9363
  }
9150
9364
  function choose(options2) {
9151
9365
  if (options2.open !== undefined)
@@ -9165,9 +9379,15 @@ function detach() {
9165
9379
  keys?.destroy();
9166
9380
  keys = null;
9167
9381
  }
9168
- function adopt(options2) {
9382
+ function adopt(options2, take) {
9169
9383
  if (!mounted)
9170
9384
  return;
9385
+ if (typeof take === "function")
9386
+ waiting = take;
9387
+ if (stepsAside(preferNow, waiting)) {
9388
+ handOver();
9389
+ return;
9390
+ }
9171
9391
  const chosen = pageChoices(options2);
9172
9392
  const rebuild = ["hotkey", "grabKey", "grab"].some((key) => chosen[key] !== undefined && chosen[key] !== mounted?.[key]);
9173
9393
  mounted = { ...mounted, ...chosen };
@@ -9179,8 +9399,42 @@ function adopt(options2) {
9179
9399
  detach();
9180
9400
  attach(mounted);
9181
9401
  }
9402
+ function handOver() {
9403
+ const take = waiting;
9404
+ const options2 = mounted;
9405
+ if (!take || !options2?.host)
9406
+ return;
9407
+ const pending = Reflect.get(take, "pending");
9408
+ if (typeof pending === "function" && Reflect.apply(pending, take, []) !== true) {
9409
+ waiting = null;
9410
+ return;
9411
+ }
9412
+ const native = nativeSwitch();
9413
+ unmount();
9414
+ const prefer = options2.prefer;
9415
+ let took = false;
9416
+ try {
9417
+ took = take(prefer ? { prefer: { value: "page", change: prefer.change, now: prefer.now } } : {}) === true;
9418
+ } catch {}
9419
+ if (took)
9420
+ return;
9421
+ if (native && !native.on)
9422
+ setNative(false, native.note);
9423
+ mount(current(options2));
9424
+ }
9425
+ function current(options2) {
9426
+ return options2.prefer && preferNow ? { ...options2, prefer: { ...options2.prefer, value: preferNow } } : options2;
9427
+ }
9428
+ function setPrefer(value) {
9429
+ preferNow = value;
9430
+ panel?.drawPrefer();
9431
+ if (mounted?.host && stepsAside(value, waiting))
9432
+ handOver();
9433
+ }
9182
9434
  function unmount() {
9183
9435
  hostedBy = null;
9436
+ deferred = null;
9437
+ waiting = null;
9184
9438
  if (superseded(window, unmount))
9185
9439
  return;
9186
9440
  detach();
@@ -9194,8 +9448,25 @@ function unmount() {
9194
9448
  queueMicrotask(() => retake(was, native));
9195
9449
  }
9196
9450
  function retake(options2, native) {
9197
- if (mounted || !owned(window) || hostOf(window))
9451
+ if (mounted || !owned(window))
9452
+ return;
9453
+ const holder = hostOf(window);
9454
+ if (holder) {
9455
+ if (!options2.build)
9456
+ return;
9457
+ if (!beats(options2.build, holder)) {
9458
+ standDown(options2, holder);
9459
+ return;
9460
+ }
9461
+ if (native && !native.on)
9462
+ setNative(false, native.note);
9463
+ mount(current(options2));
9464
+ return;
9465
+ }
9466
+ if (!takesBack(preferNow)) {
9467
+ options2.prefer?.yielded?.();
9198
9468
  return;
9469
+ }
9199
9470
  if (retaken++ >= RETAKES) {
9200
9471
  if (retaken === RETAKES + 1) {
9201
9472
  console.warn("devknobs: this page runs its own copy of devknobs, which does not know hosts; it keeps the page");
@@ -9204,7 +9475,7 @@ function retake(options2, native) {
9204
9475
  }
9205
9476
  if (native && !native.on)
9206
9477
  setNative(false, native.note);
9207
- mount(options2);
9478
+ mount(current(options2));
9208
9479
  }
9209
9480
  function hosted(name) {
9210
9481
  if (!hostedBy)
@@ -9242,7 +9513,7 @@ async function grab(elements, options2) {
9242
9513
  const host = hosted("grab");
9243
9514
  if (host)
9244
9515
  return host(elements, options2);
9245
- const loaded = await import("./index-dvr4x91q.js");
9516
+ const loaded = await import("./index-9re7sv56.js");
9246
9517
  return loaded.grab(elements, options2);
9247
9518
  }
9248
9519
  var api = { mount, unmount, getState: getState2, setState: setState2, reset: reset2, replay: replay2, grab, describe: describe2, ready: ready2 };
@@ -9250,13 +9521,16 @@ export {
9250
9521
  unmount,
9251
9522
  setSystemMedia,
9252
9523
  setState2 as setState,
9524
+ setPrefer,
9253
9525
  setNative2 as setNative,
9254
9526
  reset2 as reset,
9255
9527
  replay2 as replay,
9256
9528
  ready2 as ready,
9257
9529
  mount,
9530
+ holdInTopLayer,
9258
9531
  grab,
9259
9532
  getState2 as getState,
9260
9533
  describe2 as describe,
9261
- PRESETS
9534
+ PRESETS,
9535
+ LAYER
9262
9536
  };