@64mb/freelens-power 2.21.4 → 2.21.5
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 +116 -4
- package/dist/main.js.map +1 -1
- package/dist/renderer.js +26 -1
- package/dist/renderer.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -10617,6 +10617,73 @@ var DASHBOARD_VIEWS_LOADING = "freelens-power:dashboard-views:loading";
|
|
|
10617
10617
|
var DASHBOARD_SITE_ICONS = "freelens-power:dashboard-site-icons";
|
|
10618
10618
|
var DASHBOARD_VIEWS_PIN = "freelens-power:dashboard-views:pin";
|
|
10619
10619
|
var DASHBOARD_VIEWS_PINNED = "freelens-power:dashboard-views:pinned";
|
|
10620
|
+
var DASHBOARD_VIEWS_OPEN = "freelens-power:dashboard-views:open";
|
|
10621
|
+
// src/main/dashboard-floating-refresh.ts
|
|
10622
|
+
var toggleUrl = "https://freelens-power.invalid/dashboard-toggle-refresh";
|
|
10623
|
+
function createDashboardFloatingRefresh(window, enabled, toggle) {
|
|
10624
|
+
const view = new WebContentsView({ webPreferences: {
|
|
10625
|
+
nodeIntegration: false,
|
|
10626
|
+
contextIsolation: true,
|
|
10627
|
+
sandbox: true,
|
|
10628
|
+
webSecurity: true
|
|
10629
|
+
} });
|
|
10630
|
+
const contents = view.webContents;
|
|
10631
|
+
const preferences = AppearancePreferencesStore.getInstanceOrCreate();
|
|
10632
|
+
let disposed = false;
|
|
10633
|
+
let selected = enabled;
|
|
10634
|
+
let previous = "";
|
|
10635
|
+
const render = () => {
|
|
10636
|
+
if (disposed || contents.isDestroyed()) return;
|
|
10637
|
+
const dark = nativeTheme.shouldUseDarkColors;
|
|
10638
|
+
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
|
+
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>`;
|
|
10643
|
+
if (html === previous) return;
|
|
10644
|
+
previous = html;
|
|
10645
|
+
contents.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`).catch(() => {});
|
|
10646
|
+
};
|
|
10647
|
+
contents.setWindowOpenHandler(({ url }) => {
|
|
10648
|
+
if (!disposed && !window.isDestroyed() && (url === toggleUrl || url === `${toggleUrl}?`)) toggle();
|
|
10649
|
+
return { action: "deny" };
|
|
10650
|
+
});
|
|
10651
|
+
const blockNavigation = (event) => event.preventDefault();
|
|
10652
|
+
contents.on("will-navigate", blockNavigation);
|
|
10653
|
+
const layout = () => {
|
|
10654
|
+
if (disposed || window.isDestroyed()) return;
|
|
10655
|
+
const { width, height } = window.getContentBounds();
|
|
10656
|
+
view.setBounds({
|
|
10657
|
+
x: Math.max(0, width - 28),
|
|
10658
|
+
y: Math.max(0, height - 28),
|
|
10659
|
+
width: 20,
|
|
10660
|
+
height: 20
|
|
10661
|
+
});
|
|
10662
|
+
};
|
|
10663
|
+
view.setBackgroundColor("#00000000");
|
|
10664
|
+
window.contentView.addChildView(view);
|
|
10665
|
+
window.on("resize", layout);
|
|
10666
|
+
const stop = reaction(() => [preferences.enabled, preferences.accentColor], render);
|
|
10667
|
+
nativeTheme.on("updated", render);
|
|
10668
|
+
layout();
|
|
10669
|
+
render();
|
|
10670
|
+
return {
|
|
10671
|
+
update(value) {
|
|
10672
|
+
selected = value;
|
|
10673
|
+
render();
|
|
10674
|
+
},
|
|
10675
|
+
dispose() {
|
|
10676
|
+
if (disposed) return;
|
|
10677
|
+
disposed = true;
|
|
10678
|
+
stop();
|
|
10679
|
+
nativeTheme.removeListener("updated", render);
|
|
10680
|
+
window.removeListener("resize", layout);
|
|
10681
|
+
contents.removeListener("will-navigate", blockNavigation);
|
|
10682
|
+
if (!window.isDestroyed()) window.contentView.removeChildView(view);
|
|
10683
|
+
if (!contents.isDestroyed()) contents.close();
|
|
10684
|
+
}
|
|
10685
|
+
};
|
|
10686
|
+
}
|
|
10620
10687
|
// src/main/dashboard-icon-cache.ts
|
|
10621
10688
|
var maxBytes = 2097152;
|
|
10622
10689
|
function boundedDashboardIcons(value) {
|
|
@@ -11118,6 +11185,7 @@ function startDashboardViews(onIconsChanged = () => {}) {
|
|
|
11118
11185
|
card.floatingPreparation?.selectorChanged();
|
|
11119
11186
|
}
|
|
11120
11187
|
if (card.floating && !card.floating.isDestroyed()) card.floating.setTitle(setting.title);
|
|
11188
|
+
card.floatingRefresh?.update(setting.refreshEvery10Seconds === true);
|
|
11121
11189
|
if (card.floatingStyles) {
|
|
11122
11190
|
const scrollbars = setting.size === "l" || setting.size === "xl";
|
|
11123
11191
|
if (card.floatingStyles.scrollbars !== scrollbars) {
|
|
@@ -11171,6 +11239,7 @@ function startDashboardViews(onIconsChanged = () => {}) {
|
|
|
11171
11239
|
refreshEvery10Seconds,
|
|
11172
11240
|
selector
|
|
11173
11241
|
}))), refreshTimers);
|
|
11242
|
+
const trustedRenderer = (event) => event.senderFrame === event.sender.mainFrame && rendererUrl(event.senderFrame?.url ?? "") && rendererUrl(event.sender.getURL());
|
|
11174
11243
|
const trusted = (event) => event.senderFrame === event.sender.mainFrame && dashboardUrl(event.senderFrame?.url ?? "") && dashboardUrl(event.sender.getURL());
|
|
11175
11244
|
powerIpc.handle(DASHBOARD_SITE_ICONS, async (event) => {
|
|
11176
11245
|
if (event.senderFrame !== event.sender.mainFrame || !rendererUrl(event.senderFrame?.url ?? "") || !rendererUrl(event.sender.getURL()) || !BrowserWindow.fromWebContents(event.sender)) return [];
|
|
@@ -11181,7 +11250,7 @@ function startDashboardViews(onIconsChanged = () => {}) {
|
|
|
11181
11250
|
});
|
|
11182
11251
|
});
|
|
11183
11252
|
const syncViews = async (event, payload, prepareHidden = false) => {
|
|
11184
|
-
if (!trusted(event)) return;
|
|
11253
|
+
if (!(prepareHidden ? trustedRenderer(event) : trusted(event))) return;
|
|
11185
11254
|
const window = BrowserWindow.fromWebContents(event.sender);
|
|
11186
11255
|
if (!window || window.isDestroyed()) return;
|
|
11187
11256
|
const requested = payload && typeof payload === "object" && "cards" in payload && Array.isArray(payload.cards) ? payload.cards : [];
|
|
@@ -11458,8 +11527,8 @@ function startDashboardViews(onIconsChanged = () => {}) {
|
|
|
11458
11527
|
const publishPinned = (sender, owner) => {
|
|
11459
11528
|
if (!sender.isDestroyed()) powerIpc.sendToContents(sender, DASHBOARD_VIEWS_PINNED, [...owner.cards].filter(([, card]) => card.floating).map(([id]) => id));
|
|
11460
11529
|
};
|
|
11461
|
-
|
|
11462
|
-
if (!
|
|
11530
|
+
const setPinned = (event, payload) => {
|
|
11531
|
+
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
11532
|
const id = payload.id;
|
|
11464
11533
|
const owner = owners.get(event.sender);
|
|
11465
11534
|
const card = owner?.cards.get(payload.id);
|
|
@@ -11626,8 +11695,18 @@ function startDashboardViews(onIconsChanged = () => {}) {
|
|
|
11626
11695
|
++generation;
|
|
11627
11696
|
stopPreparation();
|
|
11628
11697
|
});
|
|
11698
|
+
card.floatingRefresh = createDashboardFloatingRefresh(floating, configured.refreshEvery10Seconds === true, () => {
|
|
11699
|
+
const latest = configuredCards().find((item) => item.id === id && item.url === card.url);
|
|
11700
|
+
if (card.floating !== floating || floating.isDestroyed() || !latest) return;
|
|
11701
|
+
DashboardPreferencesStore.getInstanceOrCreate().upsertCard({
|
|
11702
|
+
...latest,
|
|
11703
|
+
refreshEvery10Seconds: !latest.refreshEvery10Seconds
|
|
11704
|
+
});
|
|
11705
|
+
});
|
|
11629
11706
|
floating.on("closed", () => {
|
|
11630
11707
|
if (card.floating !== floating) return;
|
|
11708
|
+
card.floatingRefresh?.dispose();
|
|
11709
|
+
card.floatingRefresh = void 0;
|
|
11631
11710
|
card.floatingPreparation?.stop();
|
|
11632
11711
|
card.floatingPreparation = void 0;
|
|
11633
11712
|
floatingStyles.websiteStylesGeneration = (floatingStyles.websiteStylesGeneration ?? 0) + 1;
|
|
@@ -11641,6 +11720,38 @@ function startDashboardViews(onIconsChanged = () => {}) {
|
|
|
11641
11720
|
}
|
|
11642
11721
|
publishPinned(event.sender, owner);
|
|
11643
11722
|
return { pinned: [...owner.cards].filter(([, item]) => item.floating).map(([id]) => id) };
|
|
11723
|
+
};
|
|
11724
|
+
powerIpc.handle(DASHBOARD_VIEWS_PIN, (event, payload) => {
|
|
11725
|
+
if (!trusted(event)) return;
|
|
11726
|
+
return setPinned(event, payload);
|
|
11727
|
+
});
|
|
11728
|
+
powerIpc.handle(DASHBOARD_VIEWS_OPEN, async (event, payload) => {
|
|
11729
|
+
if (!trustedRenderer(event) || !payload || typeof payload !== "object" || !("id" in payload)) return;
|
|
11730
|
+
const configured = configuredCards().find((item) => item.id === payload.id);
|
|
11731
|
+
if (!configured) return;
|
|
11732
|
+
const cached = owners.get(event.sender)?.cards.get(configured.id);
|
|
11733
|
+
if (!cached || cached.url !== configured.url) {
|
|
11734
|
+
const bounds = {
|
|
11735
|
+
x: 0,
|
|
11736
|
+
y: 0,
|
|
11737
|
+
width: 1024,
|
|
11738
|
+
height: 768
|
|
11739
|
+
};
|
|
11740
|
+
await syncViews(event, { cards: [{
|
|
11741
|
+
id: configured.id,
|
|
11742
|
+
bounds,
|
|
11743
|
+
clip: bounds
|
|
11744
|
+
}] }, true);
|
|
11745
|
+
}
|
|
11746
|
+
if (!trustedRenderer(event)) return;
|
|
11747
|
+
const card = owners.get(event.sender)?.cards.get(configured.id);
|
|
11748
|
+
return setPinned(event, card?.floating ? {
|
|
11749
|
+
id: configured.id,
|
|
11750
|
+
focus: true
|
|
11751
|
+
} : {
|
|
11752
|
+
id: configured.id,
|
|
11753
|
+
pinned: true
|
|
11754
|
+
});
|
|
11644
11755
|
});
|
|
11645
11756
|
powerIpc.handle(clearChannel, (event) => {
|
|
11646
11757
|
if (event.senderFrame === event.sender.mainFrame && rendererUrl(event.senderFrame?.url ?? "") && rendererUrl(event.sender.getURL())) hide(event.sender);
|
|
@@ -11657,6 +11768,7 @@ function startDashboardViews(onIconsChanged = () => {}) {
|
|
|
11657
11768
|
setDashboardAiReader(void 0);
|
|
11658
11769
|
stopSettingsReaction();
|
|
11659
11770
|
powerIpc.removeHandler(DASHBOARD_VIEWS_PIN);
|
|
11771
|
+
powerIpc.removeHandler(DASHBOARD_VIEWS_OPEN);
|
|
11660
11772
|
powerIpc.removeHandler(DASHBOARD_SITE_ICONS);
|
|
11661
11773
|
powerIpc.removeHandler(syncChannel);
|
|
11662
11774
|
powerIpc.removeHandler(clearChannel);
|
|
@@ -11773,7 +11885,7 @@ function startDockIconOverride() {
|
|
|
11773
11885
|
};
|
|
11774
11886
|
}
|
|
11775
11887
|
// package.json
|
|
11776
|
-
var version = "2.21.
|
|
11888
|
+
var version = "2.21.5";
|
|
11777
11889
|
// src/common/extension-updates.ts
|
|
11778
11890
|
var EXTENSION_UPDATES_CHANNEL = "freelens-power:extension-updates";
|
|
11779
11891
|
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-]+)*)?$/;
|