@64mb/freelens-power 2.21.4 → 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
  };
@@ -10617,6 +10622,145 @@ var DASHBOARD_VIEWS_LOADING = "freelens-power:dashboard-views:loading";
10617
10622
  var DASHBOARD_SITE_ICONS = "freelens-power:dashboard-site-icons";
10618
10623
  var DASHBOARD_VIEWS_PIN = "freelens-power:dashboard-views:pin";
10619
10624
  var DASHBOARD_VIEWS_PINNED = "freelens-power:dashboard-views:pinned";
10625
+ var DASHBOARD_VIEWS_OPEN = "freelens-power:dashboard-views:open";
10626
+ // src/main/dashboard-floating-refresh.ts
10627
+ var toggleUrl = "https://freelens-power.invalid/dashboard-toggle-refresh";
10628
+ function createDashboardFloatingRefresh(window, enabled, toggle) {
10629
+ const view = new WebContentsView({ webPreferences: {
10630
+ nodeIntegration: false,
10631
+ contextIsolation: true,
10632
+ sandbox: true,
10633
+ webSecurity: true
10634
+ } });
10635
+ const contents = view.webContents;
10636
+ const preferences = AppearancePreferencesStore.getInstanceOrCreate();
10637
+ let disposed = false;
10638
+ let selected = enabled;
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
+ };
10700
+ const render = () => {
10701
+ if (disposed || contents.isDestroyed()) return;
10702
+ const dark = nativeTheme.shouldUseDarkColors;
10703
+ const accent = preferences.enabled ? ACCENT_COLOR_OPTIONS.find((option) => option.value === preferences.accentColor)?.color ?? "#7060e8" : "#00a7a0";
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>
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();
10708
+ if (html === previous) return;
10709
+ previous = html;
10710
+ contents.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`).catch(() => {});
10711
+ };
10712
+ contents.setWindowOpenHandler(({ url }) => {
10713
+ if (!disposed && !window.isDestroyed() && (url === toggleUrl || url === `${toggleUrl}?`)) toggle();
10714
+ return { action: "deny" };
10715
+ });
10716
+ const blockNavigation = (event) => event.preventDefault();
10717
+ contents.on("will-navigate", blockNavigation);
10718
+ const layout = () => {
10719
+ if (disposed || window.isDestroyed()) return;
10720
+ const { width, height } = window.getContentBounds();
10721
+ layoutTooltip();
10722
+ view.setBounds({
10723
+ x: Math.max(0, width - 36),
10724
+ y: Math.max(0, height - 36),
10725
+ width: 24,
10726
+ height: 24
10727
+ });
10728
+ };
10729
+ view.setBackgroundColor("#00000000");
10730
+ window.contentView.addChildView(view);
10731
+ window.on("resize", layout);
10732
+ window.on("blur", stopHover);
10733
+ window.on("hide", stopHover);
10734
+ contents.on("cursor-changed", onCursorChanged);
10735
+ const stop = reaction(() => [preferences.enabled, preferences.accentColor], render);
10736
+ nativeTheme.on("updated", render);
10737
+ layout();
10738
+ render();
10739
+ return {
10740
+ update(value) {
10741
+ selected = value;
10742
+ render();
10743
+ },
10744
+ dispose() {
10745
+ if (disposed) return;
10746
+ disposed = true;
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
+ }
10756
+ nativeTheme.removeListener("updated", render);
10757
+ window.removeListener("resize", layout);
10758
+ contents.removeListener("will-navigate", blockNavigation);
10759
+ if (!window.isDestroyed()) window.contentView.removeChildView(view);
10760
+ if (!contents.isDestroyed()) contents.close();
10761
+ }
10762
+ };
10763
+ }
10620
10764
  // src/main/dashboard-icon-cache.ts
10621
10765
  var maxBytes = 2097152;
10622
10766
  function boundedDashboardIcons(value) {
@@ -11118,6 +11262,7 @@ function startDashboardViews(onIconsChanged = () => {}) {
11118
11262
  card.floatingPreparation?.selectorChanged();
11119
11263
  }
11120
11264
  if (card.floating && !card.floating.isDestroyed()) card.floating.setTitle(setting.title);
11265
+ card.floatingRefresh?.update(setting.refreshEvery10Seconds === true);
11121
11266
  if (card.floatingStyles) {
11122
11267
  const scrollbars = setting.size === "l" || setting.size === "xl";
11123
11268
  if (card.floatingStyles.scrollbars !== scrollbars) {
@@ -11171,6 +11316,7 @@ function startDashboardViews(onIconsChanged = () => {}) {
11171
11316
  refreshEvery10Seconds,
11172
11317
  selector
11173
11318
  }))), refreshTimers);
11319
+ const trustedRenderer = (event) => event.senderFrame === event.sender.mainFrame && rendererUrl(event.senderFrame?.url ?? "") && rendererUrl(event.sender.getURL());
11174
11320
  const trusted = (event) => event.senderFrame === event.sender.mainFrame && dashboardUrl(event.senderFrame?.url ?? "") && dashboardUrl(event.sender.getURL());
11175
11321
  powerIpc.handle(DASHBOARD_SITE_ICONS, async (event) => {
11176
11322
  if (event.senderFrame !== event.sender.mainFrame || !rendererUrl(event.senderFrame?.url ?? "") || !rendererUrl(event.sender.getURL()) || !BrowserWindow.fromWebContents(event.sender)) return [];
@@ -11181,7 +11327,7 @@ function startDashboardViews(onIconsChanged = () => {}) {
11181
11327
  });
11182
11328
  });
11183
11329
  const syncViews = async (event, payload, prepareHidden = false) => {
11184
- if (!trusted(event)) return;
11330
+ if (!(prepareHidden ? trustedRenderer(event) : trusted(event))) return;
11185
11331
  const window = BrowserWindow.fromWebContents(event.sender);
11186
11332
  if (!window || window.isDestroyed()) return;
11187
11333
  const requested = payload && typeof payload === "object" && "cards" in payload && Array.isArray(payload.cards) ? payload.cards : [];
@@ -11458,8 +11604,8 @@ function startDashboardViews(onIconsChanged = () => {}) {
11458
11604
  const publishPinned = (sender, owner) => {
11459
11605
  if (!sender.isDestroyed()) powerIpc.sendToContents(sender, DASHBOARD_VIEWS_PINNED, [...owner.cards].filter(([, card]) => card.floating).map(([id]) => id));
11460
11606
  };
11461
- powerIpc.handle(DASHBOARD_VIEWS_PIN, (event, payload) => {
11462
- if (!trusted(event) || !payload || typeof payload !== "object" || !("id" in payload) || typeof payload.id !== "string" || !("pinned" in payload && typeof payload.pinned === "boolean" || "focus" in payload && payload.focus === true)) return;
11607
+ const setPinned = (event, payload) => {
11608
+ if (!payload || typeof payload !== "object" || !("id" in payload) || typeof payload.id !== "string" || !("pinned" in payload && typeof payload.pinned === "boolean" || "focus" in payload && payload.focus === true)) return;
11463
11609
  const id = payload.id;
11464
11610
  const owner = owners.get(event.sender);
11465
11611
  const card = owner?.cards.get(payload.id);
@@ -11626,8 +11772,18 @@ function startDashboardViews(onIconsChanged = () => {}) {
11626
11772
  ++generation;
11627
11773
  stopPreparation();
11628
11774
  });
11775
+ card.floatingRefresh = createDashboardFloatingRefresh(floating, configured.refreshEvery10Seconds === true, () => {
11776
+ const latest = configuredCards().find((item) => item.id === id && item.url === card.url);
11777
+ if (card.floating !== floating || floating.isDestroyed() || !latest) return;
11778
+ DashboardPreferencesStore.getInstanceOrCreate().upsertCard({
11779
+ ...latest,
11780
+ refreshEvery10Seconds: !latest.refreshEvery10Seconds
11781
+ });
11782
+ });
11629
11783
  floating.on("closed", () => {
11630
11784
  if (card.floating !== floating) return;
11785
+ card.floatingRefresh?.dispose();
11786
+ card.floatingRefresh = void 0;
11631
11787
  card.floatingPreparation?.stop();
11632
11788
  card.floatingPreparation = void 0;
11633
11789
  floatingStyles.websiteStylesGeneration = (floatingStyles.websiteStylesGeneration ?? 0) + 1;
@@ -11641,6 +11797,38 @@ function startDashboardViews(onIconsChanged = () => {}) {
11641
11797
  }
11642
11798
  publishPinned(event.sender, owner);
11643
11799
  return { pinned: [...owner.cards].filter(([, item]) => item.floating).map(([id]) => id) };
11800
+ };
11801
+ powerIpc.handle(DASHBOARD_VIEWS_PIN, (event, payload) => {
11802
+ if (!trusted(event)) return;
11803
+ return setPinned(event, payload);
11804
+ });
11805
+ powerIpc.handle(DASHBOARD_VIEWS_OPEN, async (event, payload) => {
11806
+ if (!trustedRenderer(event) || !payload || typeof payload !== "object" || !("id" in payload)) return;
11807
+ const configured = configuredCards().find((item) => item.id === payload.id);
11808
+ if (!configured) return;
11809
+ const cached = owners.get(event.sender)?.cards.get(configured.id);
11810
+ if (!cached || cached.url !== configured.url) {
11811
+ const bounds = {
11812
+ x: 0,
11813
+ y: 0,
11814
+ width: 1024,
11815
+ height: 768
11816
+ };
11817
+ await syncViews(event, { cards: [{
11818
+ id: configured.id,
11819
+ bounds,
11820
+ clip: bounds
11821
+ }] }, true);
11822
+ }
11823
+ if (!trustedRenderer(event)) return;
11824
+ const card = owners.get(event.sender)?.cards.get(configured.id);
11825
+ return setPinned(event, card?.floating ? {
11826
+ id: configured.id,
11827
+ focus: true
11828
+ } : {
11829
+ id: configured.id,
11830
+ pinned: true
11831
+ });
11644
11832
  });
11645
11833
  powerIpc.handle(clearChannel, (event) => {
11646
11834
  if (event.senderFrame === event.sender.mainFrame && rendererUrl(event.senderFrame?.url ?? "") && rendererUrl(event.sender.getURL())) hide(event.sender);
@@ -11657,6 +11845,7 @@ function startDashboardViews(onIconsChanged = () => {}) {
11657
11845
  setDashboardAiReader(void 0);
11658
11846
  stopSettingsReaction();
11659
11847
  powerIpc.removeHandler(DASHBOARD_VIEWS_PIN);
11848
+ powerIpc.removeHandler(DASHBOARD_VIEWS_OPEN);
11660
11849
  powerIpc.removeHandler(DASHBOARD_SITE_ICONS);
11661
11850
  powerIpc.removeHandler(syncChannel);
11662
11851
  powerIpc.removeHandler(clearChannel);
@@ -11773,7 +11962,7 @@ function startDockIconOverride() {
11773
11962
  };
11774
11963
  }
11775
11964
  // package.json
11776
- var version = "2.21.4";
11965
+ var version = "2.21.6";
11777
11966
  // src/common/extension-updates.ts
11778
11967
  var EXTENSION_UPDATES_CHANNEL = "freelens-power:extension-updates";
11779
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-]+)*)?$/;