@lvce-editor/main-process 6.33.0 → 6.33.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.
- package/dist/mainProcessMain.js +41 -19
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -6561,6 +6561,16 @@ const cancelIfStartsWith = (url, canceledUrls) => {
|
|
|
6561
6561
|
}
|
|
6562
6562
|
return {};
|
|
6563
6563
|
};
|
|
6564
|
+
const canceledAdUrls = ['https://c.amazon-adsystem.com/', 'https://cadmus.script.ac/', 'https://config.aps.amazon-adsystem.com/', 'https://dn0qt3r0xannq.cloudfront.net/', 'https://edge.aditude.io/', 'https://ep1.adtrafficquality.google/', 'https://event-ingestor.judy.pnap.aditude.cloud/', 'https://pagead2.googlesyndication.com/', 'https://raven-static.aditude.io/', 'https://securepubads.g.doubleclick.net/'];
|
|
6565
|
+
const safeframeUrlRegex = /^https:\/\/[^/]+\.safeframe\.googlesyndication\.com\//;
|
|
6566
|
+
const getBeforeRequestResponseAd = url => {
|
|
6567
|
+
if (safeframeUrlRegex.test(url)) {
|
|
6568
|
+
return {
|
|
6569
|
+
cancel: true
|
|
6570
|
+
};
|
|
6571
|
+
}
|
|
6572
|
+
return cancelIfStartsWith(url, canceledAdUrls);
|
|
6573
|
+
};
|
|
6564
6574
|
const getBeforeRequestResponseXhrPost = url => {
|
|
6565
6575
|
const canceledUrls = ['https://www.youtube.com/api/stats/qoe', 'https://www.youtube.com/youtubei/v1/log_event', 'https://play.google.com/log'];
|
|
6566
6576
|
return cancelIfStartsWith(url, canceledUrls);
|
|
@@ -6604,6 +6614,10 @@ const getBeforeRequestResponse = details => {
|
|
|
6604
6614
|
resourceType,
|
|
6605
6615
|
url
|
|
6606
6616
|
} = details;
|
|
6617
|
+
const adResponse = getBeforeRequestResponseAd(url);
|
|
6618
|
+
if (adResponse.cancel) {
|
|
6619
|
+
return adResponse;
|
|
6620
|
+
}
|
|
6607
6621
|
switch (resourceType) {
|
|
6608
6622
|
case MainFrame:
|
|
6609
6623
|
return getBeforeRequestResponseMainFrame();
|
|
@@ -6692,6 +6706,31 @@ const send = (method, ...params) => {
|
|
|
6692
6706
|
return rpc.send(method, ...params);
|
|
6693
6707
|
};
|
|
6694
6708
|
|
|
6709
|
+
const webContentsWithEventListeners = new WeakSet();
|
|
6710
|
+
const attachEventListenersToWebContents = (webContentsId, webContents, browserWindow) => {
|
|
6711
|
+
if (webContentsWithEventListeners.has(webContents)) {
|
|
6712
|
+
return;
|
|
6713
|
+
}
|
|
6714
|
+
attach(webContents, browserWindow.webContents);
|
|
6715
|
+
const values = Object.values(ElectronBrowserViewEventListeners);
|
|
6716
|
+
for (const value of values) {
|
|
6717
|
+
const wrappedListener = (...args) => {
|
|
6718
|
+
// @ts-ignore
|
|
6719
|
+
const {
|
|
6720
|
+
messages,
|
|
6721
|
+
result
|
|
6722
|
+
} = value.handler(...args, webContentsId);
|
|
6723
|
+
for (const message of messages) {
|
|
6724
|
+
const [key, ...rest] = message;
|
|
6725
|
+
send(`ElectronWebContents.${key}`, webContentsId, ...rest);
|
|
6726
|
+
}
|
|
6727
|
+
return result;
|
|
6728
|
+
};
|
|
6729
|
+
value.attach(webContents, wrappedListener);
|
|
6730
|
+
}
|
|
6731
|
+
webContentsWithEventListeners.add(webContents);
|
|
6732
|
+
};
|
|
6733
|
+
|
|
6695
6734
|
// TODO use electron 30 webcontentsview api
|
|
6696
6735
|
const createWebContentsView = async () => {
|
|
6697
6736
|
const view = new WebContentsView({
|
|
@@ -6715,6 +6754,7 @@ const createWebContentsView = async () => {
|
|
|
6715
6754
|
id
|
|
6716
6755
|
} = webContents;
|
|
6717
6756
|
add$1(id, browserWindow, view);
|
|
6757
|
+
attachEventListenersToWebContents(id, webContents, browserWindow);
|
|
6718
6758
|
return id;
|
|
6719
6759
|
};
|
|
6720
6760
|
const attachEventListeners = webContentsId => {
|
|
@@ -6724,25 +6764,7 @@ const attachEventListeners = webContentsId => {
|
|
|
6724
6764
|
if (!webContents || !state) {
|
|
6725
6765
|
return;
|
|
6726
6766
|
}
|
|
6727
|
-
|
|
6728
|
-
const values = Object.values(ElectronBrowserViewEventListeners);
|
|
6729
|
-
for (const value of values) {
|
|
6730
|
-
const wrappedListener = (...args) => {
|
|
6731
|
-
// @ts-ignore
|
|
6732
|
-
const {
|
|
6733
|
-
messages,
|
|
6734
|
-
result
|
|
6735
|
-
} = value.handler(...args, webContentsId);
|
|
6736
|
-
for (const message of messages) {
|
|
6737
|
-
const [key, ...rest] = message;
|
|
6738
|
-
send(`ElectronWebContents.${key}`, webContentsId, ...rest);
|
|
6739
|
-
}
|
|
6740
|
-
return result;
|
|
6741
|
-
};
|
|
6742
|
-
// TODO detached listeners when webcontents are disposed
|
|
6743
|
-
// to avoid potential memory leaks
|
|
6744
|
-
value.attach(webContents, wrappedListener);
|
|
6745
|
-
}
|
|
6767
|
+
attachEventListenersToWebContents(webContentsId, webContents, state.browserWindow);
|
|
6746
6768
|
};
|
|
6747
6769
|
const disposeWebContentsView = browserViewId => {
|
|
6748
6770
|
console.log('[main process] dispose browser view', browserViewId);
|