@lvce-editor/main-process 6.37.2 → 6.37.4

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.
@@ -2825,7 +2825,7 @@ const execute$1 = (command, ...args) => {
2825
2825
 
2826
2826
  const Two$2 = '2.0';
2827
2827
  const callbacks = Object.create(null);
2828
- const set$2 = (id, fn) => {
2828
+ const set$3 = (id, fn) => {
2829
2829
  callbacks[id] = fn;
2830
2830
  };
2831
2831
  const get$5 = id => {
@@ -2846,7 +2846,7 @@ const registerPromise$1 = () => {
2846
2846
  promise,
2847
2847
  resolve
2848
2848
  } = Promise.withResolvers();
2849
- set$2(id, resolve);
2849
+ set$3(id, resolve);
2850
2850
  return {
2851
2851
  id,
2852
2852
  promise
@@ -4909,7 +4909,7 @@ const createElectronSession = () => {
4909
4909
  const state$1 = {
4910
4910
  session: undefined
4911
4911
  };
4912
- const has = () => {
4912
+ const has$1 = () => {
4913
4913
  return Boolean(state$1.session);
4914
4914
  };
4915
4915
  const get$3 = () => {
@@ -4918,7 +4918,7 @@ const get$3 = () => {
4918
4918
  }
4919
4919
  return state$1.session;
4920
4920
  };
4921
- const set$1 = value => {
4921
+ const set$2 = value => {
4922
4922
  state$1.session = value;
4923
4923
  };
4924
4924
 
@@ -4938,8 +4938,8 @@ const create$2 = rpc => {
4938
4938
  };
4939
4939
 
4940
4940
  const get$2 = () => {
4941
- if (!has()) {
4942
- set$1(createElectronSession());
4941
+ if (!has$1()) {
4942
+ set$2(createElectronSession());
4943
4943
  }
4944
4944
  return get$3();
4945
4945
  };
@@ -5222,7 +5222,7 @@ const createPidMap = () => {
5222
5222
  };
5223
5223
 
5224
5224
  const rpcs = Object.create(null);
5225
- const set = (id, rpc) => {
5225
+ const set$1 = (id, rpc) => {
5226
5226
  rpcs[id] = rpc;
5227
5227
  };
5228
5228
  const get$1 = id => {
@@ -5235,7 +5235,7 @@ const createUtilityProcessRpc = async options => {
5235
5235
  ...options
5236
5236
  });
5237
5237
  const rpcId = options.targetRpcId || options.rpcId || options.ipcId;
5238
- set(rpcId, rpc);
5238
+ set$1(rpcId, rpc);
5239
5239
  };
5240
5240
 
5241
5241
  const serializeDeskopCapturerSource = source => {
@@ -6372,26 +6372,160 @@ const ElectronBrowserViewEventListenerDestroyed = {
6372
6372
  key: key$6
6373
6373
  };
6374
6374
 
6375
- const key$5 = 'did-navigate';
6375
+ const faviconUrls = new WeakMap();
6376
+ const set = (webContents, url) => {
6377
+ faviconUrls.set(webContents, url);
6378
+ };
6379
+ const has = (webContents, url) => {
6380
+ return faviconUrls.get(webContents) === url;
6381
+ };
6382
+
6383
+ const maxFaviconBytes = 1024 * 1024;
6384
+ const faviconFetchTimeout = 2000;
6385
+ const key$5 = PageFaviconUpdated;
6376
6386
  const attach$7 = (webContents, listener) => {
6377
- webContents.on(DidNavigate, listener);
6387
+ webContents.on(PageFaviconUpdated, listener);
6378
6388
  };
6379
6389
  const detach$5 = (webContents, listener) => {
6380
- webContents.off(DidNavigate, listener);
6390
+ webContents.off(PageFaviconUpdated, listener);
6391
+ };
6392
+ const getFaviconDataUrl = async (fetcher, favicon, signal) => {
6393
+ try {
6394
+ const response = await fetcher(favicon, {
6395
+ signal
6396
+ });
6397
+ if (!response.ok) {
6398
+ return '';
6399
+ }
6400
+ const contentLength = Number(response.headers.get('content-length'));
6401
+ if (contentLength > maxFaviconBytes) {
6402
+ return '';
6403
+ }
6404
+ const bytes = Buffer.from(await response.arrayBuffer());
6405
+ if (bytes.byteLength > maxFaviconBytes) {
6406
+ return '';
6407
+ }
6408
+ const contentType = response.headers.get('content-type') || 'image/x-icon';
6409
+ const mimeType = contentType.split(';', 1)[0].trim();
6410
+ if (!mimeType.startsWith('image/') && mimeType !== 'application/octet-stream') {
6411
+ return '';
6412
+ }
6413
+ return `data:${mimeType};base64,${bytes.toString('base64')}`;
6414
+ } catch {
6415
+ return '';
6416
+ }
6417
+ };
6418
+ const resolveWithFetcher = async (fetcher, favicons, signal) => {
6419
+ for (const favicon of favicons) {
6420
+ const dataUrl = await getFaviconDataUrl(fetcher, favicon, signal);
6421
+ if (dataUrl) {
6422
+ return dataUrl;
6423
+ }
6424
+ }
6425
+ return '';
6426
+ };
6427
+ const resolveWithTimeout = async (fetcher, favicons) => {
6428
+ const controller = new AbortController();
6429
+ let timeout;
6430
+ const timeoutPromise = new Promise(resolve => {
6431
+ timeout = setTimeout(() => {
6432
+ controller.abort();
6433
+ resolve('');
6434
+ }, faviconFetchTimeout);
6435
+ });
6436
+ try {
6437
+ return await Promise.race([resolveWithFetcher(fetcher, favicons, controller.signal), timeoutPromise]);
6438
+ } finally {
6439
+ clearTimeout(timeout);
6440
+ }
6441
+ };
6442
+ const resolveFavicon = async (event, favicons) => {
6443
+ const dataUrl = favicons.find(favicon => favicon.startsWith('data:'));
6444
+ if (dataUrl) {
6445
+ return [dataUrl];
6446
+ }
6447
+ const sessionFavicon = await resolveWithTimeout((url, options) => event.sender.session.fetch(url, options), favicons);
6448
+ if (sessionFavicon) {
6449
+ return [sessionFavicon];
6450
+ }
6451
+ const networkFavicons = await resolveNetworkFavicon(favicons);
6452
+ return networkFavicons.length > 0 ? networkFavicons : favicons;
6381
6453
  };
6382
- const handler$5 = (event, url) => {
6454
+ const resolveNetworkFavicon = async favicons => {
6455
+ const dataUrl = favicons.find(favicon => favicon.startsWith('data:'));
6456
+ if (dataUrl) {
6457
+ return [dataUrl];
6458
+ }
6459
+ const networkFavicon = await resolveWithTimeout((url, options) => fetch(url, options), favicons);
6460
+ return networkFavicon ? [networkFavicon] : [];
6461
+ };
6462
+ const handler$5 = async (event, favicons) => {
6463
+ const pageUrl = event.sender.getURL();
6464
+ if (favicons.length > 0) {
6465
+ set(event.sender, pageUrl);
6466
+ }
6467
+ const resolvedFavicons = await resolveFavicon(event, favicons);
6383
6468
  return {
6384
- messages: [['handleDidNavigate', url]],
6469
+ messages: event.sender.getURL() === pageUrl ? [['handlePageFaviconUpdated', resolvedFavicons]] : [],
6385
6470
  result: undefined
6386
6471
  };
6387
6472
  };
6388
6473
 
6389
- const ElectronBrowserViewEventListenerDidNavigate = {
6474
+ const ElectronBrowserViewEventListenerPageFaviconUpdated = {
6390
6475
  __proto__: null,
6391
6476
  attach: attach$7,
6392
6477
  detach: detach$5,
6393
6478
  handler: handler$5,
6394
- key: key$5
6479
+ key: key$5,
6480
+ resolveNetworkFavicon
6481
+ };
6482
+
6483
+ const send = (method, ...params) => {
6484
+ const rpc = get$1(EmbedsProcess);
6485
+ if (!rpc) {
6486
+ return;
6487
+ }
6488
+ return rpc.send(method, ...params);
6489
+ };
6490
+
6491
+ const key$4 = 'did-navigate';
6492
+ const attach$6 = (webContents, listener) => {
6493
+ webContents.on(DidNavigate, listener);
6494
+ };
6495
+ const detach$4 = (webContents, listener) => {
6496
+ webContents.off(DidNavigate, listener);
6497
+ };
6498
+ const loadDefaultFavicon = async (event, url, webContentsId) => {
6499
+ let faviconUrl;
6500
+ try {
6501
+ const parsedUrl = new URL(url);
6502
+ if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
6503
+ return;
6504
+ }
6505
+ faviconUrl = new URL('/favicon.ico', parsedUrl).href;
6506
+ } catch {
6507
+ return;
6508
+ }
6509
+ const favicons = await resolveNetworkFavicon([faviconUrl]);
6510
+ if (favicons.length === 0 || event.sender.getURL() !== url || has(event.sender, url)) {
6511
+ return;
6512
+ }
6513
+ send('ElectronWebContents.handlePageFaviconUpdated', webContentsId, favicons);
6514
+ };
6515
+ const handler$4 = (event, url, _httpResponseCode, _httpStatusText, webContentsId) => {
6516
+ void loadDefaultFavicon(event, url, webContentsId);
6517
+ return {
6518
+ messages: [['handleDidNavigate', url]],
6519
+ result: undefined
6520
+ };
6521
+ };
6522
+
6523
+ const ElectronBrowserViewEventListenerDidNavigate = {
6524
+ __proto__: null,
6525
+ attach: attach$6,
6526
+ detach: detach$4,
6527
+ handler: handler$4,
6528
+ key: key$4
6395
6529
  };
6396
6530
 
6397
6531
  const pendingLogins = new Map();
@@ -6427,14 +6561,14 @@ const cancelForWebContents = webContentsId => {
6427
6561
  }
6428
6562
  };
6429
6563
 
6430
- const key$4 = Login;
6431
- const attach$6 = (webContents, listener) => {
6564
+ const key$3 = Login;
6565
+ const attach$5 = (webContents, listener) => {
6432
6566
  webContents.on(Login, listener);
6433
6567
  };
6434
- const detach$4 = (webContents, listener) => {
6568
+ const detach$3 = (webContents, listener) => {
6435
6569
  webContents.off(Login, listener);
6436
6570
  };
6437
- const handler$4 = (event, authenticationResponseDetails, authInfo, callback, webContentsId) => {
6571
+ const handler$3 = (event, authenticationResponseDetails, authInfo, callback, webContentsId) => {
6438
6572
  event.preventDefault();
6439
6573
  const requestId = add(webContentsId, callback);
6440
6574
  return {
@@ -6452,67 +6586,6 @@ const handler$4 = (event, authenticationResponseDetails, authInfo, callback, web
6452
6586
  };
6453
6587
 
6454
6588
  const ElectronBrowserViewEventListenerLogin = {
6455
- __proto__: null,
6456
- attach: attach$6,
6457
- detach: detach$4,
6458
- handler: handler$4,
6459
- key: key$4
6460
- };
6461
-
6462
- const maxFaviconBytes = 1024 * 1024;
6463
- const key$3 = PageFaviconUpdated;
6464
- const attach$5 = (webContents, listener) => {
6465
- webContents.on(PageFaviconUpdated, listener);
6466
- };
6467
- const detach$3 = (webContents, listener) => {
6468
- webContents.off(PageFaviconUpdated, listener);
6469
- };
6470
- const getFaviconDataUrl = async (event, favicon) => {
6471
- if (favicon.startsWith('data:')) {
6472
- return favicon;
6473
- }
6474
- try {
6475
- const response = await event.sender.session.fetch(favicon);
6476
- if (!response.ok) {
6477
- return '';
6478
- }
6479
- const contentLength = Number(response.headers.get('content-length'));
6480
- if (contentLength > maxFaviconBytes) {
6481
- return '';
6482
- }
6483
- const bytes = Buffer.from(await response.arrayBuffer());
6484
- if (bytes.byteLength > maxFaviconBytes) {
6485
- return '';
6486
- }
6487
- const contentType = response.headers.get('content-type') || 'image/x-icon';
6488
- const mimeType = contentType.split(';', 1)[0].trim();
6489
- if (!mimeType.startsWith('image/') && mimeType !== 'application/octet-stream') {
6490
- return '';
6491
- }
6492
- return `data:${mimeType};base64,${bytes.toString('base64')}`;
6493
- } catch {
6494
- return '';
6495
- }
6496
- };
6497
- const resolveFavicon = async (event, favicons) => {
6498
- for (const favicon of favicons) {
6499
- const dataUrl = await getFaviconDataUrl(event, favicon);
6500
- if (dataUrl) {
6501
- return [dataUrl];
6502
- }
6503
- }
6504
- return favicons;
6505
- };
6506
- const handler$3 = async (event, favicons) => {
6507
- const pageUrl = event.sender.getURL();
6508
- const resolvedFavicons = await resolveFavicon(event, favicons);
6509
- return {
6510
- messages: event.sender.getURL() === pageUrl ? [['handlePageFaviconUpdated', resolvedFavicons]] : [],
6511
- result: undefined
6512
- };
6513
- };
6514
-
6515
- const ElectronBrowserViewEventListenerPageFaviconUpdated = {
6516
6589
  __proto__: null,
6517
6590
  attach: attach$5,
6518
6591
  detach: detach$3,
@@ -6808,14 +6881,6 @@ const attach = webContents => {
6808
6881
  });
6809
6882
  };
6810
6883
 
6811
- const send = (method, ...params) => {
6812
- const rpc = get$1(EmbedsProcess);
6813
- if (!rpc) {
6814
- return;
6815
- }
6816
- return rpc.send(method, ...params);
6817
- };
6818
-
6819
6884
  const webContentsWithEventListeners = new WeakSet();
6820
6885
  const attachEventListenersToWebContents = (webContentsId, webContents, browserWindow) => {
6821
6886
  if (webContentsWithEventListeners.has(webContents)) {
@@ -7369,7 +7434,7 @@ const handleElectronMessagePort = async (messagePort, rpcId) => {
7369
7434
  requiresSocket: requiresSocket
7370
7435
  });
7371
7436
  if (rpcId) {
7372
- set(rpcId, rpc);
7437
+ set$1(rpcId, rpc);
7373
7438
  }
7374
7439
  };
7375
7440
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.37.2",
3
+ "version": "6.37.4",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"