@lvce-editor/main-process 6.37.2 → 6.37.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.
- package/dist/mainProcessMain.js +36 -9
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -6460,6 +6460,7 @@ const ElectronBrowserViewEventListenerLogin = {
|
|
|
6460
6460
|
};
|
|
6461
6461
|
|
|
6462
6462
|
const maxFaviconBytes = 1024 * 1024;
|
|
6463
|
+
const faviconFetchTimeout = 2000;
|
|
6463
6464
|
const key$3 = PageFaviconUpdated;
|
|
6464
6465
|
const attach$5 = (webContents, listener) => {
|
|
6465
6466
|
webContents.on(PageFaviconUpdated, listener);
|
|
@@ -6467,12 +6468,11 @@ const attach$5 = (webContents, listener) => {
|
|
|
6467
6468
|
const detach$3 = (webContents, listener) => {
|
|
6468
6469
|
webContents.off(PageFaviconUpdated, listener);
|
|
6469
6470
|
};
|
|
6470
|
-
const getFaviconDataUrl = async (
|
|
6471
|
-
if (favicon.startsWith('data:')) {
|
|
6472
|
-
return favicon;
|
|
6473
|
-
}
|
|
6471
|
+
const getFaviconDataUrl = async (fetcher, favicon, signal) => {
|
|
6474
6472
|
try {
|
|
6475
|
-
const response = await
|
|
6473
|
+
const response = await fetcher(favicon, {
|
|
6474
|
+
signal
|
|
6475
|
+
});
|
|
6476
6476
|
if (!response.ok) {
|
|
6477
6477
|
return '';
|
|
6478
6478
|
}
|
|
@@ -6494,14 +6494,41 @@ const getFaviconDataUrl = async (event, favicon) => {
|
|
|
6494
6494
|
return '';
|
|
6495
6495
|
}
|
|
6496
6496
|
};
|
|
6497
|
-
const
|
|
6497
|
+
const resolveWithFetcher = async (fetcher, favicons, signal) => {
|
|
6498
6498
|
for (const favicon of favicons) {
|
|
6499
|
-
const dataUrl = await getFaviconDataUrl(
|
|
6499
|
+
const dataUrl = await getFaviconDataUrl(fetcher, favicon, signal);
|
|
6500
6500
|
if (dataUrl) {
|
|
6501
|
-
return
|
|
6501
|
+
return dataUrl;
|
|
6502
6502
|
}
|
|
6503
6503
|
}
|
|
6504
|
-
return
|
|
6504
|
+
return '';
|
|
6505
|
+
};
|
|
6506
|
+
const resolveWithTimeout = async (fetcher, favicons) => {
|
|
6507
|
+
const controller = new AbortController();
|
|
6508
|
+
let timeout;
|
|
6509
|
+
const timeoutPromise = new Promise(resolve => {
|
|
6510
|
+
timeout = setTimeout(() => {
|
|
6511
|
+
controller.abort();
|
|
6512
|
+
resolve('');
|
|
6513
|
+
}, faviconFetchTimeout);
|
|
6514
|
+
});
|
|
6515
|
+
try {
|
|
6516
|
+
return await Promise.race([resolveWithFetcher(fetcher, favicons, controller.signal), timeoutPromise]);
|
|
6517
|
+
} finally {
|
|
6518
|
+
clearTimeout(timeout);
|
|
6519
|
+
}
|
|
6520
|
+
};
|
|
6521
|
+
const resolveFavicon = async (event, favicons) => {
|
|
6522
|
+
const dataUrl = favicons.find(favicon => favicon.startsWith('data:'));
|
|
6523
|
+
if (dataUrl) {
|
|
6524
|
+
return [dataUrl];
|
|
6525
|
+
}
|
|
6526
|
+
const sessionFavicon = await resolveWithTimeout((url, options) => event.sender.session.fetch(url, options), favicons);
|
|
6527
|
+
if (sessionFavicon) {
|
|
6528
|
+
return [sessionFavicon];
|
|
6529
|
+
}
|
|
6530
|
+
const networkFavicon = await resolveWithTimeout((url, options) => fetch(url, options), favicons);
|
|
6531
|
+
return networkFavicon ? [networkFavicon] : favicons;
|
|
6505
6532
|
};
|
|
6506
6533
|
const handler$3 = async (event, favicons) => {
|
|
6507
6534
|
const pageUrl = event.sender.getURL();
|