@lvce-editor/main-process 6.33.1 → 6.33.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 +88 -38
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -6252,7 +6252,7 @@ const handleWebContentsViewZoomKeyBinding = (webContentsId, input) => {
|
|
|
6252
6252
|
};
|
|
6253
6253
|
|
|
6254
6254
|
const key$8 = 'before-input';
|
|
6255
|
-
const attach$
|
|
6255
|
+
const attach$a = (webContents, listener) => {
|
|
6256
6256
|
webContents.on(BeforeInputEvent, listener);
|
|
6257
6257
|
};
|
|
6258
6258
|
const detach$8 = (webContents, listener) => {
|
|
@@ -6292,14 +6292,14 @@ const handler$8 = (event, input, webContentsId) => {
|
|
|
6292
6292
|
|
|
6293
6293
|
const ElectronBrowserViewEventListenerBeforeInput = {
|
|
6294
6294
|
__proto__: null,
|
|
6295
|
-
attach: attach$
|
|
6295
|
+
attach: attach$a,
|
|
6296
6296
|
detach: detach$8,
|
|
6297
6297
|
handler: handler$8,
|
|
6298
6298
|
key: key$8
|
|
6299
6299
|
};
|
|
6300
6300
|
|
|
6301
6301
|
const key$7 = 'context-menu';
|
|
6302
|
-
const attach$
|
|
6302
|
+
const attach$9 = (webContents, listener) => {
|
|
6303
6303
|
webContents.on(ContextMenu, listener);
|
|
6304
6304
|
};
|
|
6305
6305
|
const detach$7 = (webContents, listener) => {
|
|
@@ -6314,14 +6314,14 @@ const handler$7 = (event, params) => {
|
|
|
6314
6314
|
|
|
6315
6315
|
const ElectronBrowserViewEventListenerContextMenu = {
|
|
6316
6316
|
__proto__: null,
|
|
6317
|
-
attach: attach$
|
|
6317
|
+
attach: attach$9,
|
|
6318
6318
|
detach: detach$7,
|
|
6319
6319
|
handler: handler$7,
|
|
6320
6320
|
key: key$7
|
|
6321
6321
|
};
|
|
6322
6322
|
|
|
6323
6323
|
const key$6 = 'destroyed';
|
|
6324
|
-
const attach$
|
|
6324
|
+
const attach$8 = (webContents, listener) => {
|
|
6325
6325
|
webContents.on(Destroyed, listener);
|
|
6326
6326
|
};
|
|
6327
6327
|
const detach$6 = (webContents, listener) => {
|
|
@@ -6336,14 +6336,14 @@ const handler$6 = () => {
|
|
|
6336
6336
|
|
|
6337
6337
|
const ElectronBrowserViewEventListenerDestroyed = {
|
|
6338
6338
|
__proto__: null,
|
|
6339
|
-
attach: attach$
|
|
6339
|
+
attach: attach$8,
|
|
6340
6340
|
detach: detach$6,
|
|
6341
6341
|
handler: handler$6,
|
|
6342
6342
|
key: key$6
|
|
6343
6343
|
};
|
|
6344
6344
|
|
|
6345
6345
|
const key$5 = 'did-navigate';
|
|
6346
|
-
const attach$
|
|
6346
|
+
const attach$7 = (webContents, listener) => {
|
|
6347
6347
|
webContents.on(DidNavigate, listener);
|
|
6348
6348
|
};
|
|
6349
6349
|
const detach$5 = (webContents, listener) => {
|
|
@@ -6358,7 +6358,7 @@ const handler$5 = (event, url) => {
|
|
|
6358
6358
|
|
|
6359
6359
|
const ElectronBrowserViewEventListenerDidNavigate = {
|
|
6360
6360
|
__proto__: null,
|
|
6361
|
-
attach: attach$
|
|
6361
|
+
attach: attach$7,
|
|
6362
6362
|
detach: detach$5,
|
|
6363
6363
|
handler: handler$5,
|
|
6364
6364
|
key: key$5
|
|
@@ -6398,7 +6398,7 @@ const cancelForWebContents = webContentsId => {
|
|
|
6398
6398
|
};
|
|
6399
6399
|
|
|
6400
6400
|
const key$4 = Login;
|
|
6401
|
-
const attach$
|
|
6401
|
+
const attach$6 = (webContents, listener) => {
|
|
6402
6402
|
webContents.on(Login, listener);
|
|
6403
6403
|
};
|
|
6404
6404
|
const detach$4 = (webContents, listener) => {
|
|
@@ -6423,14 +6423,14 @@ const handler$4 = (event, authenticationResponseDetails, authInfo, callback, web
|
|
|
6423
6423
|
|
|
6424
6424
|
const ElectronBrowserViewEventListenerLogin = {
|
|
6425
6425
|
__proto__: null,
|
|
6426
|
-
attach: attach$
|
|
6426
|
+
attach: attach$6,
|
|
6427
6427
|
detach: detach$4,
|
|
6428
6428
|
handler: handler$4,
|
|
6429
6429
|
key: key$4
|
|
6430
6430
|
};
|
|
6431
6431
|
|
|
6432
6432
|
const key$3 = PageFaviconUpdated;
|
|
6433
|
-
const attach$
|
|
6433
|
+
const attach$5 = (webContents, listener) => {
|
|
6434
6434
|
webContents.on(PageFaviconUpdated, listener);
|
|
6435
6435
|
};
|
|
6436
6436
|
const detach$3 = (webContents, listener) => {
|
|
@@ -6445,14 +6445,14 @@ const handler$3 = (event, favicons) => {
|
|
|
6445
6445
|
|
|
6446
6446
|
const ElectronBrowserViewEventListenerPageFaviconUpdated = {
|
|
6447
6447
|
__proto__: null,
|
|
6448
|
-
attach: attach$
|
|
6448
|
+
attach: attach$5,
|
|
6449
6449
|
detach: detach$3,
|
|
6450
6450
|
handler: handler$3,
|
|
6451
6451
|
key: key$3
|
|
6452
6452
|
};
|
|
6453
6453
|
|
|
6454
6454
|
const key$2 = 'page-title-updated';
|
|
6455
|
-
const attach$
|
|
6455
|
+
const attach$4 = (webContents, listener) => {
|
|
6456
6456
|
webContents.on(PageTitleUpdated, listener);
|
|
6457
6457
|
};
|
|
6458
6458
|
const detach$2 = (webContents, listener) => {
|
|
@@ -6467,14 +6467,14 @@ const handler$2 = (event, title) => {
|
|
|
6467
6467
|
|
|
6468
6468
|
const ElectronBrowserViewEventListenerPageTitleUpdated = {
|
|
6469
6469
|
__proto__: null,
|
|
6470
|
-
attach: attach$
|
|
6470
|
+
attach: attach$4,
|
|
6471
6471
|
detach: detach$2,
|
|
6472
6472
|
handler: handler$2,
|
|
6473
6473
|
key: key$2
|
|
6474
6474
|
};
|
|
6475
6475
|
|
|
6476
6476
|
const key$1 = 'will-navigate';
|
|
6477
|
-
const attach$
|
|
6477
|
+
const attach$3 = (webContents, listener) => {
|
|
6478
6478
|
webContents.on(WillNavigate, listener);
|
|
6479
6479
|
};
|
|
6480
6480
|
const detach$1 = (webContents, listener) => {
|
|
@@ -6489,14 +6489,14 @@ const handler$1 = (event, url) => {
|
|
|
6489
6489
|
|
|
6490
6490
|
const ElectronBrowserViewEventListenerWillNavigate = {
|
|
6491
6491
|
__proto__: null,
|
|
6492
|
-
attach: attach$
|
|
6492
|
+
attach: attach$3,
|
|
6493
6493
|
detach: detach$1,
|
|
6494
6494
|
handler: handler$1,
|
|
6495
6495
|
key: key$1
|
|
6496
6496
|
};
|
|
6497
6497
|
|
|
6498
6498
|
const key = 'window-open';
|
|
6499
|
-
const attach$
|
|
6499
|
+
const attach$2 = (webContents, listener) => {
|
|
6500
6500
|
webContents.setWindowOpenHandler(listener);
|
|
6501
6501
|
};
|
|
6502
6502
|
const detach = (webContents, listener) => {
|
|
@@ -6518,7 +6518,7 @@ const handler = ({
|
|
|
6518
6518
|
|
|
6519
6519
|
const ElectronBrowserViewEventListenerWindowOpen = {
|
|
6520
6520
|
__proto__: null,
|
|
6521
|
-
attach: attach$
|
|
6521
|
+
attach: attach$2,
|
|
6522
6522
|
detach,
|
|
6523
6523
|
handler,
|
|
6524
6524
|
key
|
|
@@ -6681,7 +6681,7 @@ const getSession = () => {
|
|
|
6681
6681
|
return state.session;
|
|
6682
6682
|
};
|
|
6683
6683
|
|
|
6684
|
-
const attach = (webContents, parentWebContents) => {
|
|
6684
|
+
const attach$1 = (webContents, parentWebContents) => {
|
|
6685
6685
|
let shouldRestoreParentFocus = false;
|
|
6686
6686
|
webContents.on(DidStartNavigation, (_event, _url, _isInPlace, isMainFrame) => {
|
|
6687
6687
|
if (!isMainFrame) {
|
|
@@ -6698,6 +6698,47 @@ const attach = (webContents, parentWebContents) => {
|
|
|
6698
6698
|
});
|
|
6699
6699
|
};
|
|
6700
6700
|
|
|
6701
|
+
const installSoundCloudTimerOptimization = target => {
|
|
6702
|
+
const hostname = target.location.hostname;
|
|
6703
|
+
if (hostname !== 'soundcloud.com' && !hostname.endsWith('.soundcloud.com')) {
|
|
6704
|
+
return;
|
|
6705
|
+
}
|
|
6706
|
+
const marker = '__lvceSoundCloudTimerOptimization';
|
|
6707
|
+
if (Object.hasOwn(target, marker)) {
|
|
6708
|
+
return;
|
|
6709
|
+
}
|
|
6710
|
+
const originalSetTimeout = target.setTimeout.bind(target);
|
|
6711
|
+
Object.defineProperty(target, marker, {
|
|
6712
|
+
value: true
|
|
6713
|
+
});
|
|
6714
|
+
target.setTimeout = (callback, delay, ...args) => {
|
|
6715
|
+
// SoundCloud polls its player position at 60 Hz, causing a full lifecycle update even though its displayed time has one-second precision.
|
|
6716
|
+
const soundCloudPlayerPollingInterval = 1000 / 60;
|
|
6717
|
+
const optimizedPlayerPollingInterval = 100;
|
|
6718
|
+
const optimizedDelay = Object.is(delay, soundCloudPlayerPollingInterval) ? optimizedPlayerPollingInterval : delay;
|
|
6719
|
+
return originalSetTimeout(callback, optimizedDelay, ...args);
|
|
6720
|
+
};
|
|
6721
|
+
};
|
|
6722
|
+
const soundCloudTimerOptimizationScript = `(${installSoundCloudTimerOptimization.toString()})(globalThis)`;
|
|
6723
|
+
const isSoundCloudUrl = url => {
|
|
6724
|
+
try {
|
|
6725
|
+
const {
|
|
6726
|
+
hostname
|
|
6727
|
+
} = new URL(url);
|
|
6728
|
+
return hostname === 'soundcloud.com' || hostname.endsWith('.soundcloud.com');
|
|
6729
|
+
} catch {
|
|
6730
|
+
return false;
|
|
6731
|
+
}
|
|
6732
|
+
};
|
|
6733
|
+
const attach = webContents => {
|
|
6734
|
+
webContents.on(DidNavigate, (_event, url) => {
|
|
6735
|
+
if (!isSoundCloudUrl(url)) {
|
|
6736
|
+
return;
|
|
6737
|
+
}
|
|
6738
|
+
void webContents.executeJavaScript(soundCloudTimerOptimizationScript).catch(() => {});
|
|
6739
|
+
});
|
|
6740
|
+
};
|
|
6741
|
+
|
|
6701
6742
|
const send = (method, ...params) => {
|
|
6702
6743
|
const rpc = get(EmbedsProcess);
|
|
6703
6744
|
if (!rpc) {
|
|
@@ -6706,6 +6747,32 @@ const send = (method, ...params) => {
|
|
|
6706
6747
|
return rpc.send(method, ...params);
|
|
6707
6748
|
};
|
|
6708
6749
|
|
|
6750
|
+
const webContentsWithEventListeners = new WeakSet();
|
|
6751
|
+
const attachEventListenersToWebContents = (webContentsId, webContents, browserWindow) => {
|
|
6752
|
+
if (webContentsWithEventListeners.has(webContents)) {
|
|
6753
|
+
return;
|
|
6754
|
+
}
|
|
6755
|
+
attach$1(webContents, browserWindow.webContents);
|
|
6756
|
+
attach(webContents);
|
|
6757
|
+
const values = Object.values(ElectronBrowserViewEventListeners);
|
|
6758
|
+
for (const value of values) {
|
|
6759
|
+
const wrappedListener = (...args) => {
|
|
6760
|
+
// @ts-ignore
|
|
6761
|
+
const {
|
|
6762
|
+
messages,
|
|
6763
|
+
result
|
|
6764
|
+
} = value.handler(...args, webContentsId);
|
|
6765
|
+
for (const message of messages) {
|
|
6766
|
+
const [key, ...rest] = message;
|
|
6767
|
+
send(`ElectronWebContents.${key}`, webContentsId, ...rest);
|
|
6768
|
+
}
|
|
6769
|
+
return result;
|
|
6770
|
+
};
|
|
6771
|
+
value.attach(webContents, wrappedListener);
|
|
6772
|
+
}
|
|
6773
|
+
webContentsWithEventListeners.add(webContents);
|
|
6774
|
+
};
|
|
6775
|
+
|
|
6709
6776
|
// TODO use electron 30 webcontentsview api
|
|
6710
6777
|
const createWebContentsView = async () => {
|
|
6711
6778
|
const view = new WebContentsView({
|
|
@@ -6729,6 +6796,7 @@ const createWebContentsView = async () => {
|
|
|
6729
6796
|
id
|
|
6730
6797
|
} = webContents;
|
|
6731
6798
|
add$1(id, browserWindow, view);
|
|
6799
|
+
attachEventListenersToWebContents(id, webContents, browserWindow);
|
|
6732
6800
|
return id;
|
|
6733
6801
|
};
|
|
6734
6802
|
const attachEventListeners = webContentsId => {
|
|
@@ -6738,25 +6806,7 @@ const attachEventListeners = webContentsId => {
|
|
|
6738
6806
|
if (!webContents || !state) {
|
|
6739
6807
|
return;
|
|
6740
6808
|
}
|
|
6741
|
-
|
|
6742
|
-
const values = Object.values(ElectronBrowserViewEventListeners);
|
|
6743
|
-
for (const value of values) {
|
|
6744
|
-
const wrappedListener = (...args) => {
|
|
6745
|
-
// @ts-ignore
|
|
6746
|
-
const {
|
|
6747
|
-
messages,
|
|
6748
|
-
result
|
|
6749
|
-
} = value.handler(...args, webContentsId);
|
|
6750
|
-
for (const message of messages) {
|
|
6751
|
-
const [key, ...rest] = message;
|
|
6752
|
-
send(`ElectronWebContents.${key}`, webContentsId, ...rest);
|
|
6753
|
-
}
|
|
6754
|
-
return result;
|
|
6755
|
-
};
|
|
6756
|
-
// TODO detached listeners when webcontents are disposed
|
|
6757
|
-
// to avoid potential memory leaks
|
|
6758
|
-
value.attach(webContents, wrappedListener);
|
|
6759
|
-
}
|
|
6809
|
+
attachEventListenersToWebContents(webContentsId, webContents, state.browserWindow);
|
|
6760
6810
|
};
|
|
6761
6811
|
const disposeWebContentsView = browserViewId => {
|
|
6762
6812
|
console.log('[main process] dispose browser view', browserViewId);
|