@vinena/knobs 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +7 -0
  3. package/dist/early.global.js +6 -6
  4. package/dist/{elementsview-tf4qzmtw.js → elementsview-1wsxcdtj.js} +4 -4
  5. package/dist/{elementsview-jnkbhzkj.js → elementsview-3kv34jfx.js} +4 -4
  6. package/dist/engine/browserdraw.d.ts +29 -2
  7. package/dist/engine/browserkit.d.ts +20 -1
  8. package/dist/engine/browserui.d.ts +162 -22
  9. package/dist/engine/devices.d.ts +3 -2
  10. package/dist/engine/devicon.d.ts +59 -0
  11. package/dist/engine/fit.d.ts +4 -3
  12. package/dist/engine/foldflip.d.ts +40 -0
  13. package/dist/engine/frames.d.ts +1 -0
  14. package/dist/engine/identity.d.ts +12 -5
  15. package/dist/engine/index.d.ts +2 -0
  16. package/dist/engine/mock.d.ts +14 -0
  17. package/dist/engine/mockdata.d.ts +5 -1
  18. package/dist/engine/morphrun.d.ts +4 -0
  19. package/dist/engine/native.d.ts +31 -3
  20. package/dist/engine/notice.d.ts +1 -2
  21. package/dist/engine/pageshot.d.ts +5 -2
  22. package/dist/engine/safaridraw.d.ts +162 -10
  23. package/dist/engine/screen.d.ts +24 -0
  24. package/dist/engine/store.d.ts +2 -1
  25. package/dist/engine/tabicon.d.ts +43 -0
  26. package/dist/engine/toplayer.d.ts +62 -0
  27. package/dist/engine/touchpointer.d.ts +0 -21
  28. package/dist/engine/underbar.d.ts +61 -0
  29. package/dist/engine/width.d.ts +3 -0
  30. package/dist/{framekit-3n7p79ht.js → framekit-cjz0e4y8.js} +2492 -1587
  31. package/dist/{framekit-g96t6nmq.js → framekit-yk1jxjv7.js} +2492 -1587
  32. package/dist/host.d.ts +51 -0
  33. package/dist/{index-33x9hxe3.js → index-6wbgqkdz.js} +626 -189
  34. package/dist/{index-2d6wvs8h.js → index-9jhatmky.js} +4 -4
  35. package/dist/{index-zvze25nf.js → index-begsqdm0.js} +1 -1
  36. package/dist/{index-peh33xjv.js → index-j1h13ahg.js} +1 -1
  37. package/dist/{index-5baxvd3v.js → index-p57fdttx.js} +307 -129
  38. package/dist/{index-dvr4x91q.js → index-prjpx67p.js} +20 -8
  39. package/dist/{index-d0cjxjsm.js → index-q73py563.js} +1 -1
  40. package/dist/{index-ke6v7919.js → index-sn2y6j09.js} +20 -8
  41. package/dist/{index-0casarhy.js → index-vgfn2n1h.js} +1 -1
  42. package/dist/{index-k015tb6c.js → index-zt3rheck.js} +4 -4
  43. package/dist/index.d.ts +26 -1
  44. package/dist/index.global.js +299 -176
  45. package/dist/index.js +424 -124
  46. package/dist/instance.d.ts +23 -4
  47. package/dist/{react-qv0nykcv.js → react-3rhdj2k1.js} +623 -186
  48. package/dist/{react-carf84xv.js → react-6tss0r9f.js} +307 -129
  49. package/dist/{react-eygws6cx.js → react-7vjfsh40.js} +4 -4
  50. package/dist/{react-71a9ypex.js → react-806qmkyz.js} +4 -4
  51. package/dist/{react-65tgdbs8.js → react-gefkdkdz.js} +1 -1
  52. package/dist/{react-sq9pkw4k.js → react-mmq2zya3.js} +1 -1
  53. package/dist/{react-xxfpfddf.js → react-qfpg79hs.js} +1 -1
  54. package/dist/{react-pdvseef0.js → react-qgz9afa2.js} +1 -1
  55. package/dist/react.js +420 -123
  56. package/dist/{storageview-sb23henh.js → storageview-7cv0vpdm.js} +4 -4
  57. package/dist/{storageview-vf8v8q8j.js → storageview-dyhpgt8f.js} +4 -4
  58. package/dist/types.d.ts +14 -0
  59. package/dist/ui/footer.d.ts +9 -2
  60. package/dist/ui/panel.d.ts +16 -2
  61. package/dist/ui/settings.d.ts +25 -1
  62. package/dist/version.d.ts +2 -0
  63. package/package.json +3 -2
  64. package/skills/devknobs/SKILL.md +1 -1
  65. package/dist/engine/endroom.d.ts +0 -21
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-j1h13ahg.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-9jhatmky.js";
21
21
  import {
22
22
  hushOnce
23
- } from "./index-d0cjxjsm.js";
23
+ } from "./index-q73py563.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-zt3rheck.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-begsqdm0.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,7 +96,9 @@ import {
92
96
  getState,
93
97
  glyph,
94
98
  highlightAt,
99
+ holdInTopLayer,
95
100
  holdingHinge,
101
+ hostSendsUa,
96
102
  icon,
97
103
  isFunctionKey,
98
104
  isSearchKey,
@@ -127,7 +133,7 @@ import {
127
133
  watchPanel,
128
134
  zoomAction,
129
135
  zoomKey
130
- } from "./index-33x9hxe3.js";
136
+ } from "./index-6wbgqkdz.js";
131
137
  import {
132
138
  BARS,
133
139
  BROWSERS,
@@ -140,6 +146,7 @@ import {
140
146
  DEFAULT_PINNED,
141
147
  DEFAULT_STATE,
142
148
  DEVICES,
149
+ DEV_ICONS,
143
150
  DIRS,
144
151
  DPR_MAX,
145
152
  DPR_MIN,
@@ -196,6 +203,7 @@ import {
196
203
  realNow,
197
204
  resolveGeo,
198
205
  rewriteMediaText,
206
+ runsUnderBars,
199
207
  setSystemMedia,
200
208
  stamped,
201
209
  still,
@@ -204,7 +212,7 @@ import {
204
212
  userAgentOf,
205
213
  watchSystemMedia,
206
214
  webStorage
207
- } from "./index-5baxvd3v.js";
215
+ } from "./index-p57fdttx.js";
208
216
 
209
217
  // src/ui/knobs.ts
210
218
  var MINUTE = 60000;
@@ -806,6 +814,9 @@ var BARS2 = {
806
814
  function safariShown(state) {
807
815
  return platformOf(screenNow(state)) === "safari" && barsShown(state);
808
816
  }
817
+ function safariSideways(state) {
818
+ return safariShown(state) && state.orientation === "landscape" && runsUnderBars(screenNow(state));
819
+ }
809
820
  var EDGE_TO_EDGE = {
810
821
  id: "edgeToEdge",
811
822
  label: "edge to edge",
@@ -813,11 +824,11 @@ var EDGE_TO_EDGE = {
813
824
  control: "switch",
814
825
  options: OFF_ON,
815
826
  aliases: ["edge", "under bars", "true height", "full height"],
816
- read: (state) => flag(state.edgeToEdge && safariShown(state)),
827
+ read: (state) => flag(state.edgeToEdge && safariSideways(state)),
817
828
  write: (value) => ({ edgeToEdge: value === "on" }),
818
829
  reset: { edgeToEdge: DEFAULT_STATE.edgeToEdge },
819
830
  brief: () => "",
820
- offers: (state) => safariShown(state) ? ["off", "on"] : []
831
+ offers: (state) => safariSideways(state) ? ["off", "on"] : []
821
832
  };
822
833
  var WIDTH = {
823
834
  id: "width",
@@ -1412,7 +1423,7 @@ function knobs() {
1412
1423
  touchPointer: spec("On a touch device, the mouse acts as a finger in its frame.", flag2),
1413
1424
  browser: spec("Where a phone's browser keeps its bars, or off.", oneOf(BROWSERS)),
1414
1425
  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),
1426
+ 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
1427
  frame: spec("Render the page in a full-width frame even at full width.", flag2, "frame"),
1417
1428
  dpr: spec("Device pixel ratio inside the frame.", { type: "number", min: DPR_MIN, max: DPR_MAX, or: ["system"] }, "frame"),
1418
1429
  zoom: spec("How big the frame is drawn. The page sees the same viewport.", {
@@ -1441,7 +1452,9 @@ function knobs() {
1441
1452
  fields: {
1442
1453
  open: field2("The panel is open.", flag2),
1443
1454
  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)
1455
+ 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),
1456
+ 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)),
1457
+ realPhone: field2("Real phone mode. true has a host that sends requests as another browser, the extension, send the device's user agent to servers for the frame's page loads, so a site serves its mobile site; some sites may sign you out. false sends none for a device in the frame. The extension saves a change made during a user gesture, such as a click (the panel's switch included), for every tab and site; a change a script makes without one stays in this tab.", flag2)
1445
1458
  }
1446
1459
  }, "frame")
1447
1460
  };
@@ -1453,8 +1466,8 @@ function describe() {
1453
1466
  }
1454
1467
  function defaultOf(key) {
1455
1468
  if (key === "panel") {
1456
- const { open, docked, handle } = DEFAULT_STATE.panel;
1457
- return { open, docked, handle };
1469
+ const { open, docked, handle, devIcon, realPhone } = DEFAULT_STATE.panel;
1470
+ return { open, docked, handle, devIcon, realPhone };
1458
1471
  }
1459
1472
  if (key === "clock") {
1460
1473
  const { mode, at, speed, header } = DEFAULT_STATE.clock;
@@ -1579,6 +1592,62 @@ function pageChoices(options2) {
1579
1592
  }
1580
1593
  return chosen;
1581
1594
  }
1595
+ 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";
1596
+ function preferOf(handed) {
1597
+ const prefer = Reflect.get(handed, "prefer");
1598
+ if (typeof prefer !== "object" || prefer === null)
1599
+ return null;
1600
+ const value = Reflect.get(prefer, "value");
1601
+ const change = Reflect.get(prefer, "change");
1602
+ if (value !== "extension" && value !== "page" || typeof change !== "function")
1603
+ return null;
1604
+ const now2 = Reflect.get(prefer, "now");
1605
+ return {
1606
+ value,
1607
+ change: (next) => void Reflect.apply(change, prefer, [next]),
1608
+ ...typeof now2 === "function" ? {
1609
+ now: () => {
1610
+ const current = Reflect.apply(now2, prefer, []);
1611
+ return current === "extension" ? "extension" : "page";
1612
+ }
1613
+ } : {}
1614
+ };
1615
+ }
1616
+ function stepsAside(prefer, take) {
1617
+ return prefer === "page" && typeof take === "function";
1618
+ }
1619
+ function takesBack(prefer) {
1620
+ return prefer !== "page";
1621
+ }
1622
+ function rankOf(host) {
1623
+ const rank = Reflect.get(host, "rank");
1624
+ if (typeof rank !== "object" || rank === null)
1625
+ return null;
1626
+ const build = Reflect.get(rank, "build");
1627
+ const version = Reflect.get(rank, "version");
1628
+ if (build !== "store" && build !== "local" || typeof version !== "string")
1629
+ return null;
1630
+ return { build, version };
1631
+ }
1632
+ function numbers(version) {
1633
+ const found = /^(\d+)\.(\d+)\.(\d+)/.exec(version);
1634
+ return found ? found.slice(1).map(Number) : [0, 0, 0];
1635
+ }
1636
+ function outranks(a, b) {
1637
+ if (!b)
1638
+ return true;
1639
+ if (a.build !== b.build)
1640
+ return a.build === "local";
1641
+ const [x, y] = [numbers(a.version), numbers(b.version)];
1642
+ for (let index = 0;index < 3; index++) {
1643
+ if (x[index] !== y[index])
1644
+ return (x[index] ?? 0) > (y[index] ?? 0);
1645
+ }
1646
+ return a.version > b.version;
1647
+ }
1648
+ function stoodDownNote(other) {
1649
+ return `${other?.build ?? "older"} extension stood down`;
1650
+ }
1582
1651
 
1583
1652
  // src/instance.ts
1584
1653
  var OWNER = Symbol.for("devknobs.owner");
@@ -1586,13 +1655,13 @@ var HOST = Symbol.for("devknobs.host");
1586
1655
  function isHost(value) {
1587
1656
  return typeof value === "object" && value !== null && typeof Reflect.get(value, "release") === "function" && typeof Reflect.get(value, "adopt") === "function";
1588
1657
  }
1589
- function claim(scope, release, adopt, api) {
1658
+ function claim(scope, release, adopt, api, extras = {}) {
1590
1659
  const previous = Reflect.get(scope, OWNER);
1591
1660
  if (typeof previous === "function" && previous !== release)
1592
1661
  previous();
1593
1662
  Reflect.set(scope, OWNER, release);
1594
1663
  if (adopt)
1595
- Reflect.set(scope, HOST, { release, adopt, api });
1664
+ Reflect.set(scope, HOST, { release, adopt, api, ...extras });
1596
1665
  else
1597
1666
  Reflect.deleteProperty(scope, HOST);
1598
1667
  }
@@ -1852,6 +1921,101 @@ function createKeys(options2 = {}) {
1852
1921
  };
1853
1922
  }
1854
1923
 
1924
+ // src/ui/footer.ts
1925
+ var FRESH_NOTE = "fresh mode: nothing is kept";
1926
+ function runtimeLabel(host, version) {
1927
+ return `${host ? "extension" : "page"} ${version}`;
1928
+ }
1929
+ function overflowBadge(on, count) {
1930
+ return on && count !== null ? `${count} overflowing` : "";
1931
+ }
1932
+ function keyLabel(combo, mac) {
1933
+ return combo ? comboLabel(combo, mac) : "";
1934
+ }
1935
+ function keyChips(keys, grab, mac, inspect = false) {
1936
+ const chips = [
1937
+ { command: "panel", key: comboLabel(keys.panel, mac), word: BINDING_WORDS.panel },
1938
+ { command: "search", key: "/", word: "search" }
1939
+ ];
1940
+ if (grab) {
1941
+ chips.push({ command: "grab", key: keyLabel(keys.grab, mac), word: BINDING_WORDS.grab });
1942
+ }
1943
+ if (inspect) {
1944
+ const key = keyLabel(keys.inspect, mac);
1945
+ chips.push({ command: "inspect", key, word: BINDING_WORDS.inspect });
1946
+ }
1947
+ chips.push({ command: "replay", key: keyLabel(keys.replay, mac), word: BINDING_WORDS.replay }, { command: "reset", key: keyLabel(keys.reset, mac), word: BINDING_WORDS.reset });
1948
+ return chips;
1949
+ }
1950
+ function iconHint(className, label2, glyph2) {
1951
+ const node = button(`hint ${className}`, "");
1952
+ if (glyph2)
1953
+ node.append(glyph2);
1954
+ node.setAttribute("aria-label", label2);
1955
+ return node;
1956
+ }
1957
+ function createFooter(keys, grab, mac, inspect = null, runtime = null) {
1958
+ const foot = el("div", "foot");
1959
+ const badge = el("span", "badge");
1960
+ const meta = el("div", "meta");
1961
+ const hints = new Map;
1962
+ const hintKeys = new Map;
1963
+ for (const chip of keyChips(keys.get(), grab !== null, mac, inspect !== null)) {
1964
+ const node = button("hint", "");
1965
+ node.dataset.command = chip.command;
1966
+ const key = el("kbd", "hint-key", chip.key);
1967
+ node.append(key, chip.word);
1968
+ meta.append(node);
1969
+ hints.set(chip.command, node);
1970
+ hintKeys.set(chip.command, key);
1971
+ }
1972
+ const pin = iconHint("pin-toggle", pinWord(false));
1973
+ let pinShown = null;
1974
+ const sided = (name) => {
1975
+ const glyph2 = icon(name, 12);
1976
+ glyph2.setAttribute("class", "glyph sided");
1977
+ return glyph2;
1978
+ };
1979
+ const flip = iconHint("flip-toggle", SIDE_WORD, sided("panel-left"));
1980
+ const collapse = iconHint("collapse-toggle", COLLAPSE_WORD, sided("panel-right-close"));
1981
+ const keysToggle = iconHint("keys-toggle", "settings", icon("settings", 12));
1982
+ meta.append(flip, collapse, pin, keysToggle);
1983
+ function drawPin(docked) {
1984
+ if (docked === pinShown)
1985
+ return;
1986
+ pinShown = docked;
1987
+ flip.hidden = !docked;
1988
+ collapse.hidden = !docked;
1989
+ pin.replaceChildren(icon(docked ? "pin-off" : "pin", 12));
1990
+ pin.setAttribute("aria-label", pinWord(docked));
1991
+ pin.setAttribute("aria-pressed", docked ? "true" : "false");
1992
+ }
1993
+ drawPin(false);
1994
+ foot.append(badge);
1995
+ if (fresh())
1996
+ foot.append(el("span", "fresh-note", FRESH_NOTE));
1997
+ if (runtime)
1998
+ foot.append(el("span", "runtime", runtime));
1999
+ foot.append(meta);
2000
+ return {
2001
+ foot,
2002
+ badge,
2003
+ hints,
2004
+ pin,
2005
+ flip,
2006
+ collapse,
2007
+ keysToggle,
2008
+ drawPin,
2009
+ drawKeys(now2) {
2010
+ for (const chip of keyChips(now2, grab !== null, mac, inspect !== null)) {
2011
+ const key = hintKeys.get(chip.command);
2012
+ if (key)
2013
+ key.textContent = chip.key;
2014
+ }
2015
+ }
2016
+ };
2017
+ }
2018
+
1855
2019
  // src/ui/list.ts
1856
2020
  function rowOrder(state) {
1857
2021
  const ids = ROWS.map((row) => row.id);
@@ -2257,8 +2421,8 @@ function createDrag(context) {
2257
2421
  if (wrap.dataset.side !== side) {
2258
2422
  jump(() => {
2259
2423
  wrap.dataset.side = side;
2260
- host.style.left = side === "left" ? "0" : "";
2261
- host.style.right = side === "right" ? "0" : "";
2424
+ host.style.left = side === "left" ? "0" : "auto";
2425
+ host.style.right = side === "right" ? "0" : "auto";
2262
2426
  });
2263
2427
  }
2264
2428
  if (getState().panel.docked) {
@@ -2500,96 +2664,6 @@ function createDrag(context) {
2500
2664
  };
2501
2665
  }
2502
2666
 
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
2667
  // src/ui/inspector.ts
2594
2668
  var STYLES_VIEW = "styles";
2595
2669
  var SELECT = "select an element";
@@ -2597,7 +2671,7 @@ var PANE = { openPane, paneView, onPane, retitlePane, showPane };
2597
2671
  function here(element) {
2598
2672
  return element.isConnected && element.ownerDocument.defaultView !== null;
2599
2673
  }
2600
- function createInspector(context, load = () => import("./elementsview-jnkbhzkj.js").then(({ createElementsView }) => ({ createStylesView: createElementsView })), pane = PANE) {
2674
+ function createInspector(context, load = () => import("./elementsview-3kv34jfx.js").then(({ createElementsView }) => ({ createStylesView: createElementsView })), pane = PANE) {
2601
2675
  const { inspect, tips, prefs } = context;
2602
2676
  const listeners = new Set;
2603
2677
  let view = null;
@@ -6560,6 +6634,7 @@ var HANDLE_HINT = 4000;
6560
6634
  function handleHint(keys, mac) {
6561
6635
  return `press ${comboLabel(keys.panel, mac)} to open knobs`;
6562
6636
  }
6637
+ var REAL_PHONE_HINT = "sends the phone's user agent to sites, so they serve their mobile site. some sites may sign you out.";
6563
6638
  function createSettings(context) {
6564
6639
  const { keys, prefs, grab, mac, bindingsHere, keysToggle, said, tips, render, renderKeys } = context;
6565
6640
  const keysView = el("div", "keys pane");
@@ -6603,6 +6678,56 @@ function createSettings(context) {
6603
6678
  keysView.append(row);
6604
6679
  nativeSwitch2.addEventListener("click", () => context.setNative(nativeSwitch2.getAttribute("aria-checked") !== "true"));
6605
6680
  }
6681
+ const prefer = context.prefer;
6682
+ const preferChoice = segments({
6683
+ options: [
6684
+ { value: "extension", label: "extension" },
6685
+ { value: "page", label: "page" }
6686
+ ],
6687
+ label: "prefer",
6688
+ onChange: (value) => context.setPrefer(value === "page" ? "page" : "extension")
6689
+ });
6690
+ if (prefer) {
6691
+ preferChoice.node.classList.add("row-control");
6692
+ const hint = el("div", "row-hint", PREFER_HINT);
6693
+ hint.id = "devknobs-prefer-hint";
6694
+ preferChoice.node.setAttribute("aria-describedby", hint.id);
6695
+ const row = rowBox({
6696
+ main: el("div", "main"),
6697
+ glyph: icon("chevrons-left-right"),
6698
+ title: "prefer",
6699
+ ends: [preferChoice.node]
6700
+ }).box;
6701
+ row.append(hint);
6702
+ keysView.append(row);
6703
+ }
6704
+ const realPhoneSwitch = button("switch row-control", "");
6705
+ if (context.realPhone) {
6706
+ realPhoneSwitch.setAttribute("role", "switch");
6707
+ realPhoneSwitch.setAttribute("aria-label", "real phone mode");
6708
+ const hint = el("div", "row-hint", REAL_PHONE_HINT);
6709
+ hint.id = "devknobs-real-phone-hint";
6710
+ realPhoneSwitch.setAttribute("aria-describedby", hint.id);
6711
+ const row = rowBox({
6712
+ main: el("div", "main"),
6713
+ glyph: icon("smartphone"),
6714
+ title: "real phone mode",
6715
+ ends: [realPhoneSwitch]
6716
+ }).box;
6717
+ row.append(hint);
6718
+ keysView.append(row);
6719
+ realPhoneSwitch.addEventListener("click", () => context.setRealPhone(realPhoneSwitch.getAttribute("aria-checked") !== "true"));
6720
+ }
6721
+ const devIconSwitch = button("switch row-control", "");
6722
+ devIconSwitch.setAttribute("role", "switch");
6723
+ devIconSwitch.setAttribute("aria-label", "dev tab icon");
6724
+ keysView.append(rowBox({
6725
+ main: el("div", "main"),
6726
+ glyph: icon("image"),
6727
+ title: "dev tab icon",
6728
+ ends: [devIconSwitch]
6729
+ }).box);
6730
+ devIconSwitch.addEventListener("click", () => context.setDevIcon(!context.devIconShown()));
6606
6731
  keysView.append(rowsLabel("shortcuts"));
6607
6732
  const keyViews = new Map;
6608
6733
  for (const binding of bindingsHere) {
@@ -6734,6 +6859,12 @@ function createSettings(context) {
6734
6859
  drawHandle(shown2) {
6735
6860
  mark(handleSwitch, shown2, "aria-checked");
6736
6861
  },
6862
+ drawDevIcon(shown2) {
6863
+ mark(devIconSwitch, shown2, "aria-checked");
6864
+ },
6865
+ drawRealPhone(on) {
6866
+ mark(realPhoneSwitch, on, "aria-checked");
6867
+ },
6737
6868
  drawNative(on, note) {
6738
6869
  mark(nativeSwitch2, on, "aria-checked");
6739
6870
  const hint = note ?? native?.hint ?? "";
@@ -6743,6 +6874,10 @@ function createSettings(context) {
6743
6874
  if (note)
6744
6875
  said.textContent = note;
6745
6876
  },
6877
+ drawPrefer() {
6878
+ if (prefer)
6879
+ preferChoice.set(prefer.value());
6880
+ },
6746
6881
  recordingKey(event) {
6747
6882
  if (recording === null)
6748
6883
  return false;
@@ -7632,6 +7767,8 @@ button:focus-visible { outline: 1px solid var(--faint); outline-offset: -1px; }
7632
7767
  .badge.hot { color: var(--hot); }
7633
7768
  /* Says fresh mode is on, as quiet as the key hints under it. */
7634
7769
  .fresh-note { font-size: 10px; line-height: 1.4; color: var(--faint); }
7770
+ /* Which copy runs the panel, as quiet. */
7771
+ .runtime { font-size: 10px; line-height: 1.4; color: var(--faint); font-variant-numeric: tabular-nums; }
7635
7772
  /* The key hints, each a button for what its key does. Where they leave no
7636
7773
  room, the line wraps. */
7637
7774
  .meta {
@@ -7717,6 +7854,8 @@ button:focus-visible { outline: 1px solid var(--faint); outline-offset: -1px; }
7717
7854
  takes no height of its own, so the row is as tall as any. */
7718
7855
  .main > .row-button { align-self: center; margin: -2px 0 -2px auto; }
7719
7856
  .main > .row-button:not([hidden]) + .row-control { margin-left: 0; }
7857
+ /* Segments at a row's end, as the settings' choice of who runs the panel, take no more height than its title. */
7858
+ .main > .seg.row-control { margin-top: -3px; margin-bottom: -3px; }
7720
7859
  /* The panel's icons face the side the panel is on. */
7721
7860
  .wrap[data-side="left"] .glyph.sided { transform: scaleX(-1); }
7722
7861
  .key-set {
@@ -7763,11 +7902,17 @@ button:focus-visible { outline: 1px solid var(--faint); outline-offset: -1px; }
7763
7902
  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
7903
  own limit shrinks it to what the window has, so the panel is as tall as it
7765
7904
  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. */
7905
+ holds can lay itself out by how wide the view is. A view takes the
7906
+ window's whole height, past the limit a list keeps. */
7907
+ .wrap[data-mode="view"] .panel {
7908
+ max-height: calc(100vh - 16px);
7909
+ max-height: calc(100dvh - 16px);
7910
+ }
7767
7911
  .view {
7768
7912
  flex: 0 1 auto;
7769
7913
  min-height: 0;
7770
- height: 672px;
7914
+ height: 100vh;
7915
+ height: 100dvh;
7771
7916
  display: flex;
7772
7917
  flex-direction: column;
7773
7918
  gap: 4px;
@@ -8121,9 +8266,13 @@ button:focus-visible { outline: 1px solid var(--faint); outline-offset: -1px; }
8121
8266
  as deep lines do in the browser's tools. The selected line has a ground of
8122
8267
  its own, a blue one while the tree has the focus, and ends with a quiet
8123
8268
  reference to it. A node that changed lights for a moment. */
8124
- .elements { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
8269
+ /* The tree takes what the styles leave of the view, and keeps the height its
8270
+ edge was dragged to once it was. */
8271
+ .elements { display: flex; flex-direction: column; min-height: 100%; gap: 4px; }
8272
+ .elements > * { min-width: 0; }
8125
8273
  .dom {
8126
8274
  position: relative;
8275
+ flex: 1 0 auto;
8127
8276
  height: 40vh;
8128
8277
  min-height: 96px;
8129
8278
  max-height: 85vh;
@@ -8133,6 +8282,7 @@ button:focus-visible { outline: 1px solid var(--faint); outline-offset: -1px; }
8133
8282
  scrollbar-width: thin;
8134
8283
  scrollbar-color: var(--line) transparent;
8135
8284
  }
8285
+ .dom[style*="height"] { flex-grow: 0; }
8136
8286
  .dom-tree { width: min-content; min-width: 100%; font: 11px/1.6 var(--mono); }
8137
8287
  .dom-row {
8138
8288
  display: flex;
@@ -8575,7 +8725,7 @@ s.css-decl, s.css-decl .css-var, s.css-decl .css-name { color: var(--faint); tex
8575
8725
  `;
8576
8726
 
8577
8727
  // src/ui/panel.ts
8578
- var HOST_STYLE = "position:fixed;top:0;z-index:2147483646;pointer-events:none";
8728
+ var HOST_STYLE = "position:fixed;top:0;right:auto;bottom:auto;left:auto;width:auto;height:auto;z-index:2147483647;pointer-events:none";
8579
8729
  function ownCss(media) {
8580
8730
  const settle2 = (_whole, query) => {
8581
8731
  const scheme = rewriteMediaText(query.trim(), "prefers-color-scheme", media.scheme);
@@ -8613,6 +8763,7 @@ function createPanel(options2 = {}) {
8613
8763
  host.setAttribute("data-devknobs", "panel");
8614
8764
  host.style.cssText = HOST_STYLE;
8615
8765
  const root = host.attachShadow({ mode: "open" });
8766
+ addStyle(root, HOST_RESET);
8616
8767
  const style = addStyle(root, "");
8617
8768
  const stopSystem = watchSystemMedia((media) => {
8618
8769
  style.textContent = media ? ownCss(media) : CSS;
@@ -8654,7 +8805,7 @@ function createPanel(options2 = {}) {
8654
8805
  const home = el("div", "home pane");
8655
8806
  lay(home, "rows");
8656
8807
  home.append(rows, empty, add, head, results);
8657
- const footer = createFooter(keys, grab, mac, inspect);
8808
+ const footer = createFooter(keys, grab, mac, inspect, options2.prefer?.runtime ?? null);
8658
8809
  const { foot, badge, hints, keysToggle, pin, collapse } = footer;
8659
8810
  const tip = el("div", "tip");
8660
8811
  tip.setAttribute("aria-hidden", "true");
@@ -8679,11 +8830,17 @@ function createPanel(options2 = {}) {
8679
8830
  renderKeys,
8680
8831
  handleShown: handleShows,
8681
8832
  showHandle: () => setState({ panel: { handle: true } }),
8833
+ devIconShown: () => devIconShown(getState().panel.devIcon, window.location.hostname),
8834
+ setDevIcon: (on) => setState({ panel: { devIcon: devIconFor(on, window.location.hostname) } }),
8835
+ realPhone: hostSendsUa(),
8836
+ setRealPhone: (on) => setState({ panel: { realPhone: on } }),
8682
8837
  native: nativeSwitch()?.setting ?? null,
8683
8838
  setNative: (on) => {
8684
8839
  nativeSwitch()?.setting.change(on);
8685
8840
  setNative(on, null);
8686
8841
  },
8842
+ prefer: options2.prefer ?? null,
8843
+ setPrefer: (value) => options2.prefer?.change(value),
8687
8844
  searching: () => palette.searching(),
8688
8845
  leaveSearch: () => palette.leaveSearch()
8689
8846
  });
@@ -8777,9 +8934,12 @@ function createPanel(options2 = {}) {
8777
8934
  const handleShown = handleShows();
8778
8935
  wrap.dataset.handle = handleShown ? "shown" : "hidden";
8779
8936
  settings.drawHandle(handleShown);
8937
+ settings.drawDevIcon(devIconShown(state.panel.devIcon, window.location.hostname));
8938
+ settings.drawRealPhone(state.panel.realPhone);
8780
8939
  const nativeNow = nativeSwitch();
8781
8940
  if (nativeNow)
8782
8941
  settings.drawNative(nativeNow.on, nativeNow.note);
8942
+ settings.drawPrefer();
8783
8943
  dockSlide.aim({
8784
8944
  docked: state.panel.docked,
8785
8945
  side: state.panel.side,
@@ -9028,16 +9188,20 @@ function createPanel(options2 = {}) {
9028
9188
  const resizes = new ResizeObserver(() => layout());
9029
9189
  resizes.observe(panel);
9030
9190
  function attach() {
9031
- if (document.body && host.parentNode !== document.body)
9032
- document.body.append(host);
9191
+ if (!document.body || host.parentNode === document.body)
9192
+ return;
9193
+ document.body.append(host);
9194
+ hold.raise();
9033
9195
  }
9034
9196
  render();
9035
9197
  (document.body ?? document.documentElement).append(host);
9198
+ const hold = holdInTopLayer(host, LAYER.panel);
9036
9199
  if (!document.body)
9037
9200
  document.addEventListener("DOMContentLoaded", attach, { once: true });
9038
- const stopKeeping = keepMounted(host);
9201
+ const stopKeeping = keepMounted(host, { restored: () => hold.raise() });
9039
9202
  layout("edge");
9040
9203
  return {
9204
+ drawPrefer: () => settings.drawPrefer(),
9041
9205
  destroy() {
9042
9206
  settings.stopRecording();
9043
9207
  unsubscribe();
@@ -9085,11 +9249,15 @@ function createPanel(options2 = {}) {
9085
9249
  dockSlide.destroy();
9086
9250
  document.removeEventListener("DOMContentLoaded", attach);
9087
9251
  stopKeeping();
9252
+ hold.release();
9088
9253
  host.remove();
9089
9254
  }
9090
9255
  };
9091
9256
  }
9092
9257
 
9258
+ // src/version.ts
9259
+ var VERSION = "0.5.3";
9260
+
9093
9261
  // src/index.ts
9094
9262
  var PRESETS = {
9095
9263
  locale: LOCALE_PRESETS,
@@ -9107,18 +9275,40 @@ var mounted = null;
9107
9275
  var hostedBy = null;
9108
9276
  var RETAKES = 3;
9109
9277
  var retaken = 0;
9278
+ var preferNow = null;
9279
+ var waiting = null;
9280
+ var deferred = null;
9281
+ var handedPrefer = null;
9282
+ var beaten = null;
9110
9283
  function mount(options2 = {}) {
9111
9284
  if (panel || stopKeys)
9112
9285
  return;
9113
9286
  const host = options2.host ? null : hostOf(window);
9114
9287
  if (host) {
9288
+ handedPrefer = null;
9115
9289
  hostedBy = host;
9116
- host.adopt(options2);
9290
+ deferred = options2;
9291
+ const take = Object.assign((handed) => takeFrom(options2, handed), {
9292
+ pending: () => deferred === options2 && !panel && !stopKeys
9293
+ });
9294
+ host.adopt(options2, take);
9117
9295
  return;
9118
9296
  }
9297
+ if (options2.host && options2.build) {
9298
+ const holder = hostOf(window);
9299
+ if (holder && !beats(options2.build, holder)) {
9300
+ standDown(options2, holder);
9301
+ return;
9302
+ }
9303
+ if (holder)
9304
+ beaten = { other: rankOf(holder) };
9305
+ }
9306
+ preferNow = options2.host ? options2.prefer?.value ?? null : null;
9307
+ if (!options2.host && !options2.prefer && handedPrefer)
9308
+ options2 = { ...options2, prefer: handedPrefer };
9119
9309
  applyOnLoad();
9120
9310
  if (options2.host)
9121
- claim(window, unmount, adopt, api);
9311
+ claim(window, unmount, adopt, api, options2.build ? { rank: rankFor(options2.build), outranked } : {});
9122
9312
  else
9123
9313
  claim(window, unmount);
9124
9314
  expose(window, api);
@@ -9145,7 +9335,57 @@ function attach(options2) {
9145
9335
  return;
9146
9336
  }
9147
9337
  choose(options2);
9148
- panel = createPanel({ keys: live, grab: grabControl, inspect, handle: options2.handle });
9338
+ panel = createPanel({
9339
+ keys: live,
9340
+ grab: grabControl,
9341
+ inspect,
9342
+ handle: options2.handle,
9343
+ prefer: panelPrefer(options2)
9344
+ });
9345
+ }
9346
+ function panelPrefer(options2) {
9347
+ const setting = options2.prefer;
9348
+ if (!setting)
9349
+ return;
9350
+ return {
9351
+ value: () => preferNow ?? setting.now?.() ?? setting.value,
9352
+ change: (value) => {
9353
+ setting.change(value);
9354
+ setPrefer(value);
9355
+ },
9356
+ runtime: [runtimeLabel(options2.host === true, VERSION), ...options2.host && beaten ? [stoodDownNote(beaten.other)] : []].join(" · ")
9357
+ };
9358
+ }
9359
+ function rankFor(build) {
9360
+ return { build, version: VERSION };
9361
+ }
9362
+ function beats(build, holder) {
9363
+ const theirs = rankOf(holder);
9364
+ if (!theirs && holder.rank !== undefined)
9365
+ return false;
9366
+ return outranks(rankFor(build), theirs);
9367
+ }
9368
+ function standDown(options2, holder) {
9369
+ options2.stoodDown?.();
9370
+ if (options2.build)
9371
+ holder.outranked?.(rankFor(options2.build));
9372
+ }
9373
+ function outranked(other) {
9374
+ beaten = { other: rankOf({ rank: other }) };
9375
+ if (!mounted || !panel)
9376
+ return;
9377
+ detach();
9378
+ attach(mounted);
9379
+ }
9380
+ function takeFrom(options2, handed) {
9381
+ if (deferred !== options2 || panel || stopKeys || hostOf(window))
9382
+ return false;
9383
+ deferred = null;
9384
+ hostedBy = null;
9385
+ const prefer = preferOf(handed);
9386
+ handedPrefer = prefer;
9387
+ mount(prefer ? { ...options2, prefer } : options2);
9388
+ return true;
9149
9389
  }
9150
9390
  function choose(options2) {
9151
9391
  if (options2.open !== undefined)
@@ -9165,9 +9405,15 @@ function detach() {
9165
9405
  keys?.destroy();
9166
9406
  keys = null;
9167
9407
  }
9168
- function adopt(options2) {
9408
+ function adopt(options2, take) {
9169
9409
  if (!mounted)
9170
9410
  return;
9411
+ if (typeof take === "function")
9412
+ waiting = take;
9413
+ if (stepsAside(preferNow, waiting)) {
9414
+ handOver();
9415
+ return;
9416
+ }
9171
9417
  const chosen = pageChoices(options2);
9172
9418
  const rebuild = ["hotkey", "grabKey", "grab"].some((key) => chosen[key] !== undefined && chosen[key] !== mounted?.[key]);
9173
9419
  mounted = { ...mounted, ...chosen };
@@ -9179,8 +9425,42 @@ function adopt(options2) {
9179
9425
  detach();
9180
9426
  attach(mounted);
9181
9427
  }
9428
+ function handOver() {
9429
+ const take = waiting;
9430
+ const options2 = mounted;
9431
+ if (!take || !options2?.host)
9432
+ return;
9433
+ const pending = Reflect.get(take, "pending");
9434
+ if (typeof pending === "function" && Reflect.apply(pending, take, []) !== true) {
9435
+ waiting = null;
9436
+ return;
9437
+ }
9438
+ const native = nativeSwitch();
9439
+ unmount();
9440
+ const prefer = options2.prefer;
9441
+ let took = false;
9442
+ try {
9443
+ took = take(prefer ? { prefer: { value: "page", change: prefer.change, now: prefer.now } } : {}) === true;
9444
+ } catch {}
9445
+ if (took)
9446
+ return;
9447
+ if (native && !native.on)
9448
+ setNative(false, native.note);
9449
+ mount(current(options2));
9450
+ }
9451
+ function current(options2) {
9452
+ return options2.prefer && preferNow ? { ...options2, prefer: { ...options2.prefer, value: preferNow } } : options2;
9453
+ }
9454
+ function setPrefer(value) {
9455
+ preferNow = value;
9456
+ panel?.drawPrefer();
9457
+ if (mounted?.host && stepsAside(value, waiting))
9458
+ handOver();
9459
+ }
9182
9460
  function unmount() {
9183
9461
  hostedBy = null;
9462
+ deferred = null;
9463
+ waiting = null;
9184
9464
  if (superseded(window, unmount))
9185
9465
  return;
9186
9466
  detach();
@@ -9194,8 +9474,25 @@ function unmount() {
9194
9474
  queueMicrotask(() => retake(was, native));
9195
9475
  }
9196
9476
  function retake(options2, native) {
9197
- if (mounted || !owned(window) || hostOf(window))
9477
+ if (mounted || !owned(window))
9478
+ return;
9479
+ const holder = hostOf(window);
9480
+ if (holder) {
9481
+ if (!options2.build)
9482
+ return;
9483
+ if (!beats(options2.build, holder)) {
9484
+ standDown(options2, holder);
9485
+ return;
9486
+ }
9487
+ if (native && !native.on)
9488
+ setNative(false, native.note);
9489
+ mount(current(options2));
9490
+ return;
9491
+ }
9492
+ if (!takesBack(preferNow)) {
9493
+ options2.prefer?.yielded?.();
9198
9494
  return;
9495
+ }
9199
9496
  if (retaken++ >= RETAKES) {
9200
9497
  if (retaken === RETAKES + 1) {
9201
9498
  console.warn("devknobs: this page runs its own copy of devknobs, which does not know hosts; it keeps the page");
@@ -9204,7 +9501,7 @@ function retake(options2, native) {
9204
9501
  }
9205
9502
  if (native && !native.on)
9206
9503
  setNative(false, native.note);
9207
- mount(options2);
9504
+ mount(current(options2));
9208
9505
  }
9209
9506
  function hosted(name) {
9210
9507
  if (!hostedBy)
@@ -9242,7 +9539,7 @@ async function grab(elements, options2) {
9242
9539
  const host = hosted("grab");
9243
9540
  if (host)
9244
9541
  return host(elements, options2);
9245
- const loaded = await import("./index-dvr4x91q.js");
9542
+ const loaded = await import("./index-prjpx67p.js");
9246
9543
  return loaded.grab(elements, options2);
9247
9544
  }
9248
9545
  var api = { mount, unmount, getState: getState2, setState: setState2, reset: reset2, replay: replay2, grab, describe: describe2, ready: ready2 };
@@ -9250,13 +9547,16 @@ export {
9250
9547
  unmount,
9251
9548
  setSystemMedia,
9252
9549
  setState2 as setState,
9550
+ setPrefer,
9253
9551
  setNative2 as setNative,
9254
9552
  reset2 as reset,
9255
9553
  replay2 as replay,
9256
9554
  ready2 as ready,
9257
9555
  mount,
9556
+ holdInTopLayer,
9258
9557
  grab,
9259
9558
  getState2 as getState,
9260
9559
  describe2 as describe,
9261
- PRESETS
9560
+ PRESETS,
9561
+ LAYER
9262
9562
  };