@64mb/freelens-power 2.21.5 → 2.21.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -3,7 +3,7 @@ import { n as normalizePowerLogsLimits, t as applyPowerLogsLimits } from "./powe
3
3
  import { i as POWER_LOGS_STORAGE_CHANNEL, r as POWER_LOGS_LIMITS, t as POWER_LOGS_CHANNEL } from "./power-logs-D2eUB0f0.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { X509Certificate, createHash, randomUUID } from "node:crypto";
6
- import { BrowserWindow, View, WebContentsView, app, dialog, nativeImage, nativeTheme, session, shell, utilityProcess } from "electron";
6
+ import { BrowserWindow, View, WebContentsView, app, dialog, nativeImage, nativeTheme, screen, session, shell, utilityProcess } from "electron";
7
7
  import { execFile, spawn } from "node:child_process";
8
8
  import { chmod, lstat, mkdir, mkdtemp, open, readFile, readdir, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
9
9
  import { homedir, tmpdir, userInfo } from "node:os";
@@ -7894,6 +7894,7 @@ var PowerPreferencesStore = class extends Common.Store.ExtensionStore {
7894
7894
  checkUpdates = true;
7895
7895
  nodeBulkActions = true;
7896
7896
  hotbarShortcuts = true;
7897
+ hotbarItemShortcuts = true;
7897
7898
  constructor() {
7898
7899
  super({
7899
7900
  configName: "power-preferences",
@@ -7901,14 +7902,16 @@ var PowerPreferencesStore = class extends Common.Store.ExtensionStore {
7901
7902
  enabled: true,
7902
7903
  checkUpdates: true,
7903
7904
  nodeBulkActions: true,
7904
- hotbarShortcuts: true
7905
+ hotbarShortcuts: true,
7906
+ hotbarItemShortcuts: true
7905
7907
  }
7906
7908
  });
7907
7909
  makeObservable(this, {
7908
7910
  enabled: observable,
7909
7911
  checkUpdates: observable,
7910
7912
  nodeBulkActions: observable,
7911
- hotbarShortcuts: observable
7913
+ hotbarShortcuts: observable,
7914
+ hotbarItemShortcuts: observable
7912
7915
  });
7913
7916
  }
7914
7917
  fromStore(data) {
@@ -7916,13 +7919,15 @@ var PowerPreferencesStore = class extends Common.Store.ExtensionStore {
7916
7919
  this.checkUpdates = data.checkUpdates !== false;
7917
7920
  this.nodeBulkActions = data.nodeBulkActions !== false;
7918
7921
  this.hotbarShortcuts = data.hotbarShortcuts !== false;
7922
+ this.hotbarItemShortcuts = data.hotbarItemShortcuts !== false;
7919
7923
  }
7920
7924
  toJSON() {
7921
7925
  return {
7922
7926
  enabled: this.enabled,
7923
7927
  checkUpdates: this.checkUpdates,
7924
7928
  nodeBulkActions: this.nodeBulkActions,
7925
- hotbarShortcuts: this.hotbarShortcuts
7929
+ hotbarShortcuts: this.hotbarShortcuts,
7930
+ hotbarItemShortcuts: this.hotbarItemShortcuts
7926
7931
  };
7927
7932
  }
7928
7933
  };
@@ -10632,14 +10637,74 @@ function createDashboardFloatingRefresh(window, enabled, toggle) {
10632
10637
  let disposed = false;
10633
10638
  let selected = enabled;
10634
10639
  let previous = "";
10640
+ let tooltip;
10641
+ let tooltipAttached = false;
10642
+ let hoverStarted = 0;
10643
+ let hoverTimer;
10644
+ const hideTooltip = () => {
10645
+ if (tooltipAttached && !window.isDestroyed() && tooltip) window.contentView.removeChildView(tooltip);
10646
+ tooltipAttached = false;
10647
+ };
10648
+ const stopHover = () => {
10649
+ if (hoverTimer) clearInterval(hoverTimer);
10650
+ hoverTimer = void 0;
10651
+ hoverStarted = 0;
10652
+ hideTooltip();
10653
+ };
10654
+ const renderTooltip = () => {
10655
+ if (!tooltip || tooltip.webContents.isDestroyed()) return;
10656
+ const dark = nativeTheme.shouldUseDarkColors;
10657
+ const html = `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'"><style>html,body{margin:0;background:transparent;overflow:hidden;font-family:Arial,sans-serif}.Tooltip{position:absolute;right:12px;top:0;border-radius:3px;padding:6.5px;background:${dark ? "#1e2124" : "#f1f1f1"};color:${dark ? "#ffffff" : "#222222"};font-size:13px;font-weight:normal;white-space:nowrap;box-shadow:0 8px 16px rgba(0,0,0,.24);pointer-events:none}</style></head><body><div class="Tooltip" role="tooltip">${selected ? "Disable refresh" : "Enable refresh (10s)"}</div></body></html>`;
10658
+ tooltip.webContents.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`).catch(() => {});
10659
+ };
10660
+ const layoutTooltip = () => {
10661
+ if (!tooltip || window.isDestroyed()) return;
10662
+ const { width, height } = window.getContentBounds();
10663
+ tooltip.setBounds({
10664
+ x: Math.max(0, width - 204),
10665
+ y: Math.max(0, height - 70),
10666
+ width: 204,
10667
+ height: 34
10668
+ });
10669
+ };
10670
+ const checkHover = () => {
10671
+ if (disposed || window.isDestroyed()) return stopHover();
10672
+ const bounds = window.getContentBounds();
10673
+ const cursor = screen.getCursorScreenPoint();
10674
+ const x = cursor.x - bounds.x;
10675
+ const y = cursor.y - bounds.y;
10676
+ if (!window.isVisible() || !window.isFocused() || x < bounds.width - 36 || x >= bounds.width - 12 || y < bounds.height - 36 || y >= bounds.height - 12) return stopHover();
10677
+ if (!hoverStarted) hoverStarted = Date.now();
10678
+ if (Date.now() - hoverStarted < 150 || tooltipAttached) return;
10679
+ if (!tooltip) {
10680
+ tooltip = new WebContentsView({ webPreferences: {
10681
+ nodeIntegration: false,
10682
+ contextIsolation: true,
10683
+ sandbox: true,
10684
+ webSecurity: true
10685
+ } });
10686
+ tooltip.setBackgroundColor("#00000000");
10687
+ tooltip.webContents.setWindowOpenHandler(() => ({ action: "deny" }));
10688
+ tooltip.webContents.on("will-navigate", blockNavigation);
10689
+ renderTooltip();
10690
+ }
10691
+ layoutTooltip();
10692
+ window.contentView.addChildView(tooltip);
10693
+ tooltipAttached = true;
10694
+ };
10695
+ const onCursorChanged = (_event, type) => {
10696
+ if (type !== "pointer" || hoverTimer || disposed) return;
10697
+ checkHover();
10698
+ hoverTimer = setInterval(checkHover, 50);
10699
+ };
10635
10700
  const render = () => {
10636
10701
  if (disposed || contents.isDestroyed()) return;
10637
10702
  const dark = nativeTheme.shouldUseDarkColors;
10638
10703
  const accent = preferences.enabled ? ACCENT_COLOR_OPTIONS.find((option) => option.value === preferences.accentColor)?.color ?? "#7060e8" : "#00a7a0";
10639
- const label = selected ? "Disable refresh" : "Enable refresh (10s)";
10640
10704
  const html = `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; form-action https://freelens-power.invalid"><style>
10641
- html,body,form{margin:0;width:100%;height:100%;overflow:hidden;background:transparent}button{box-sizing:border-box;width:20px;height:20px;display:grid;place-items:center;padding:0;border:1px solid ${selected ? accent : dark ? "#54585e" : "#c5c8ce"};border-radius:3px;background:${dark ? "#292d32" : "#f5f6f8"};color:${selected ? accent : dark ? "#aeb5be" : "#5f6873"};cursor:pointer}button:hover{background:color-mix(in srgb,${accent} 8%,${dark ? "#292d32" : "#f5f6f8"})}button:focus-visible{outline:2px solid ${accent};outline-offset:-3px}svg{width:12px;height:12px;fill:currentColor;pointer-events:none}
10642
- </style></head><body><form action="${toggleUrl}" target="_blank"><button type="submit" aria-label="${label}" title="${label}" aria-pressed="${selected}"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 6v3l4-4-4-4v3a8 8 0 0 0-6.76 12.26l1.46-1.46A6 6 0 0 1 12 6zm6.76 1.74L17.3 9.2A6 6 0 0 1 12 18v-3l-4 4 4 4v-3a8 8 0 0 0 6.76-12.26z"/></svg></button></form></body></html>`;
10705
+ html,body,form{margin:0;width:100%;height:100%;overflow:hidden;background:transparent}button{box-sizing:border-box;width:24px;height:24px;display:grid;place-items:center;padding:0;border:1px solid ${selected ? accent : dark ? "#54585e" : "#c5c8ce"};border-radius:3px;background:${dark ? "#292d32" : "#f5f6f8"};color:${selected ? accent : dark ? "#aeb5be" : "#5f6873"};cursor:pointer}button:hover{background:color-mix(in srgb,${accent} 8%,${dark ? "#292d32" : "#f5f6f8"})}button:focus-visible{outline:2px solid ${accent};outline-offset:-3px}svg{width:14px;height:14px;fill:currentColor;pointer-events:none}
10706
+ </style></head><body><form action="${toggleUrl}" target="_blank"><button type="submit" aria-label="${selected ? "Disable refresh" : "Enable refresh (10s)"}" aria-pressed="${selected}"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 6v3l4-4-4-4v3a8 8 0 0 0-6.76 12.26l1.46-1.46A6 6 0 0 1 12 6zm6.76 1.74L17.3 9.2A6 6 0 0 1 12 18v-3l-4 4 4 4v-3a8 8 0 0 0 6.76-12.26z"/></svg></button></form></body></html>`;
10707
+ renderTooltip();
10643
10708
  if (html === previous) return;
10644
10709
  previous = html;
10645
10710
  contents.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`).catch(() => {});
@@ -10653,16 +10718,20 @@ html,body,form{margin:0;width:100%;height:100%;overflow:hidden;background:transp
10653
10718
  const layout = () => {
10654
10719
  if (disposed || window.isDestroyed()) return;
10655
10720
  const { width, height } = window.getContentBounds();
10721
+ layoutTooltip();
10656
10722
  view.setBounds({
10657
- x: Math.max(0, width - 28),
10658
- y: Math.max(0, height - 28),
10659
- width: 20,
10660
- height: 20
10723
+ x: Math.max(0, width - 36),
10724
+ y: Math.max(0, height - 36),
10725
+ width: 24,
10726
+ height: 24
10661
10727
  });
10662
10728
  };
10663
10729
  view.setBackgroundColor("#00000000");
10664
10730
  window.contentView.addChildView(view);
10665
10731
  window.on("resize", layout);
10732
+ window.on("blur", stopHover);
10733
+ window.on("hide", stopHover);
10734
+ contents.on("cursor-changed", onCursorChanged);
10666
10735
  const stop = reaction(() => [preferences.enabled, preferences.accentColor], render);
10667
10736
  nativeTheme.on("updated", render);
10668
10737
  layout();
@@ -10676,6 +10745,14 @@ html,body,form{margin:0;width:100%;height:100%;overflow:hidden;background:transp
10676
10745
  if (disposed) return;
10677
10746
  disposed = true;
10678
10747
  stop();
10748
+ stopHover();
10749
+ window.removeListener("blur", stopHover);
10750
+ window.removeListener("hide", stopHover);
10751
+ contents.removeListener("cursor-changed", onCursorChanged);
10752
+ if (tooltip && !tooltip.webContents.isDestroyed()) {
10753
+ tooltip.webContents.removeListener("will-navigate", blockNavigation);
10754
+ tooltip.webContents.close();
10755
+ }
10679
10756
  nativeTheme.removeListener("updated", render);
10680
10757
  window.removeListener("resize", layout);
10681
10758
  contents.removeListener("will-navigate", blockNavigation);
@@ -11885,7 +11962,7 @@ function startDockIconOverride() {
11885
11962
  };
11886
11963
  }
11887
11964
  // package.json
11888
- var version = "2.21.5";
11965
+ var version = "2.21.6";
11889
11966
  // src/common/extension-updates.ts
11890
11967
  var EXTENSION_UPDATES_CHANNEL = "freelens-power:extension-updates";
11891
11968
  var semver = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;