@lvce-editor/main-process 6.46.0 → 6.46.2

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.
@@ -6741,40 +6741,44 @@ const attach$9 = (webContents, listener) => {
6741
6741
  const detach$6 = (webContents, listener) => {
6742
6742
  webContents.off(PageFaviconUpdated, listener);
6743
6743
  };
6744
- const getFaviconDataUrl = async (fetcher, favicon, signal) => {
6744
+ const getFaviconData = async (fetcher, favicon, signal) => {
6745
6745
  try {
6746
6746
  const response = await fetcher(favicon, {
6747
6747
  signal
6748
6748
  });
6749
6749
  if (!response.ok) {
6750
- return '';
6750
+ return undefined;
6751
6751
  }
6752
6752
  const contentLength = Number(response.headers.get('content-length'));
6753
6753
  if (contentLength > maxFaviconBytes) {
6754
- return '';
6754
+ return undefined;
6755
6755
  }
6756
- const bytes = Buffer.from(await response.arrayBuffer());
6756
+ const bytes = new Uint8Array(await response.arrayBuffer());
6757
6757
  if (bytes.byteLength > maxFaviconBytes) {
6758
- return '';
6758
+ return undefined;
6759
6759
  }
6760
6760
  const contentType = response.headers.get('content-type') || 'image/x-icon';
6761
6761
  const mimeType = contentType.split(';', 1)[0].trim();
6762
6762
  if (!mimeType.startsWith('image/') && mimeType !== 'application/octet-stream') {
6763
- return '';
6763
+ return undefined;
6764
6764
  }
6765
- return `data:${mimeType};base64,${bytes.toString('base64')}`;
6765
+ return {
6766
+ bytes,
6767
+ mimeType,
6768
+ url: favicon
6769
+ };
6766
6770
  } catch {
6767
- return '';
6771
+ return undefined;
6768
6772
  }
6769
6773
  };
6770
6774
  const resolveWithFetcher = async (fetcher, favicons, signal) => {
6771
6775
  for (const favicon of favicons) {
6772
- const dataUrl = await getFaviconDataUrl(fetcher, favicon, signal);
6773
- if (dataUrl) {
6774
- return dataUrl;
6776
+ const data = await getFaviconData(fetcher, favicon, signal);
6777
+ if (data) {
6778
+ return data;
6775
6779
  }
6776
6780
  }
6777
- return '';
6781
+ return undefined;
6778
6782
  };
6779
6783
  const resolveWithTimeout = async (fetcher, favicons) => {
6780
6784
  const controller = new AbortController();
@@ -6782,7 +6786,7 @@ const resolveWithTimeout = async (fetcher, favicons) => {
6782
6786
  const timeoutPromise = new Promise(resolve => {
6783
6787
  timeout = setTimeout(() => {
6784
6788
  controller.abort();
6785
- resolve('');
6789
+ resolve(undefined);
6786
6790
  }, faviconFetchTimeout);
6787
6791
  });
6788
6792
  try {
@@ -6794,7 +6798,8 @@ const resolveWithTimeout = async (fetcher, favicons) => {
6794
6798
  const resolveFavicon = async (webContents, favicons) => {
6795
6799
  const dataUrl = favicons.find(favicon => favicon.startsWith('data:'));
6796
6800
  if (dataUrl) {
6797
- return [dataUrl];
6801
+ const data = await resolveWithTimeout((url, options) => fetch(url, options), [dataUrl]);
6802
+ return data ? [data] : [dataUrl];
6798
6803
  }
6799
6804
  const sessionFavicon = await resolveWithTimeout((url, options) => webContents.session.fetch(url, options), favicons);
6800
6805
  if (sessionFavicon) {
@@ -6806,7 +6811,8 @@ const resolveFavicon = async (webContents, favicons) => {
6806
6811
  const resolveNetworkFavicon = async favicons => {
6807
6812
  const dataUrl = favicons.find(favicon => favicon.startsWith('data:'));
6808
6813
  if (dataUrl) {
6809
- return [dataUrl];
6814
+ const data = await resolveWithTimeout((url, options) => fetch(url, options), [dataUrl]);
6815
+ return data ? [data] : [dataUrl];
6810
6816
  }
6811
6817
  const networkFavicon = await resolveWithTimeout((url, options) => fetch(url, options), favicons);
6812
6818
  return networkFavicon ? [networkFavicon] : [];
@@ -7313,6 +7319,9 @@ const createWebContentsViewForWindow = (browserWindow, options = {}) => {
7313
7319
  }),
7314
7320
  webPreferences: {
7315
7321
  ...options.webPreferences,
7322
+ // Tab selection controls focus. A hidden background tab must not steal it
7323
+ // when Electron commits its navigation while the view remains attached.
7324
+ focusOnNavigation: false,
7316
7325
  session: getSession()
7317
7326
  }
7318
7327
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.46.0",
3
+ "version": "6.46.2",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"