@lvce-editor/main-process 2.6.0 → 2.7.0
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 +21 -4
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -5544,7 +5544,7 @@ const createPidMap = () => {
|
|
|
5544
5544
|
};
|
|
5545
5545
|
|
|
5546
5546
|
const rpcs = Object.create(null);
|
|
5547
|
-
const set$
|
|
5547
|
+
const set$5 = (id, rpc) => {
|
|
5548
5548
|
rpcs[id] = rpc;
|
|
5549
5549
|
};
|
|
5550
5550
|
const get = id => {
|
|
@@ -5557,7 +5557,7 @@ const createUtilityProcessRpc = async options => {
|
|
|
5557
5557
|
...options
|
|
5558
5558
|
});
|
|
5559
5559
|
const rpcId = options.targetRpcId || options.rpcId || options.ipcId;
|
|
5560
|
-
set$
|
|
5560
|
+
set$5(rpcId, rpc);
|
|
5561
5561
|
};
|
|
5562
5562
|
|
|
5563
5563
|
const serializeDeskopCapturerSource = source => {
|
|
@@ -6724,6 +6724,21 @@ const openDevtools = view => {
|
|
|
6724
6724
|
// TODO return promise that resolves once devtools are actually open
|
|
6725
6725
|
webContents.openDevTools();
|
|
6726
6726
|
};
|
|
6727
|
+
const getSlimCode = html => {
|
|
6728
|
+
let result = html;
|
|
6729
|
+
result = result.replaceAll(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script\s*>/gi, '');
|
|
6730
|
+
result = result.replaceAll(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style\s*>/gi, '');
|
|
6731
|
+
return result;
|
|
6732
|
+
};
|
|
6733
|
+
const getDomTree = async view => {
|
|
6734
|
+
const {
|
|
6735
|
+
webContents
|
|
6736
|
+
} = view;
|
|
6737
|
+
const code = `document.body.outerHTML`;
|
|
6738
|
+
const result = await webContents.executeJavaScript(code);
|
|
6739
|
+
const slimCode = getSlimCode(result);
|
|
6740
|
+
return slimCode;
|
|
6741
|
+
};
|
|
6727
6742
|
const reload = view => {
|
|
6728
6743
|
const {
|
|
6729
6744
|
webContents
|
|
@@ -6979,7 +6994,7 @@ const handleElectronMessagePort = async (messagePort, rpcId) => {
|
|
|
6979
6994
|
requiresSocket: requiresSocket
|
|
6980
6995
|
});
|
|
6981
6996
|
if (rpcId) {
|
|
6982
|
-
set$
|
|
6997
|
+
set$5(rpcId, rpc);
|
|
6983
6998
|
}
|
|
6984
6999
|
};
|
|
6985
7000
|
|
|
@@ -7192,6 +7207,7 @@ const commandMap = {
|
|
|
7192
7207
|
'ElectronWebContentsView.createWebContentsView': createWebContentsView,
|
|
7193
7208
|
'ElectronWebContentsView.disposeWebContentsView': disposeWebContentsView,
|
|
7194
7209
|
'ElectronWebContentsViewFunctions.addToWindow': addToWindow,
|
|
7210
|
+
'ElectronWebContentsViewFunctions.getDomTree': wrapBrowserViewCommand(getDomTree),
|
|
7195
7211
|
'ElectronWebContentsViewFunctions.backward': wrapBrowserViewCommand(backward),
|
|
7196
7212
|
'ElectronWebContentsViewFunctions.cancelNavigation': wrapBrowserViewCommand(cancelNavigation),
|
|
7197
7213
|
'ElectronWebContentsViewFunctions.copyImageAt': wrapBrowserViewCommand(copyImageAt),
|
|
@@ -7801,7 +7817,8 @@ const Commands$4 = {
|
|
|
7801
7817
|
setFallthroughKeyBindings: setFallThroughKeyBindings,
|
|
7802
7818
|
setIframeSrc: wrapBrowserViewCommand(setIframeSrc),
|
|
7803
7819
|
setIframeSrcFallback: wrapBrowserViewCommand(setIframeSrcFallback),
|
|
7804
|
-
show: show
|
|
7820
|
+
show: show,
|
|
7821
|
+
getDomTree: getDomTree
|
|
7805
7822
|
};
|
|
7806
7823
|
|
|
7807
7824
|
const ElectronWebContentsViewFunctions_ipc = {
|