@lvce-editor/main-process 2.5.0 → 2.6.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 +63 -106
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Electron from 'electron';
|
|
2
|
-
import Electron__default, { dialog, app, clipboard, BrowserWindow, MessageChannelMain, Menu, shell, desktopCapturer, contentTracing, net, netLog, powerSaveBlocker, safeStorage, screen,
|
|
2
|
+
import Electron__default, { dialog, app, clipboard, BrowserWindow, MessageChannelMain, Menu, shell, desktopCapturer, contentTracing, net, netLog, powerSaveBlocker, safeStorage, screen, webContents, WebContentsView } from 'electron';
|
|
3
3
|
import process$1 from 'node:process';
|
|
4
4
|
import { inspect } from 'node:util';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
@@ -5805,6 +5805,53 @@ const getBounds = () => {
|
|
|
5805
5805
|
};
|
|
5806
5806
|
};
|
|
5807
5807
|
|
|
5808
|
+
const disposeWebContents = webContents => {
|
|
5809
|
+
if (webContents.close) {
|
|
5810
|
+
// electron v22
|
|
5811
|
+
webContents.close();
|
|
5812
|
+
// @ts-ignore
|
|
5813
|
+
} else if (webContents.destroy) {
|
|
5814
|
+
// older versions of electron
|
|
5815
|
+
// @ts-ignore
|
|
5816
|
+
webContents.destroy();
|
|
5817
|
+
}
|
|
5818
|
+
};
|
|
5819
|
+
|
|
5820
|
+
const getStats$1 = webContentsId => {
|
|
5821
|
+
number(webContentsId);
|
|
5822
|
+
const contents = webContents.fromId(webContentsId);
|
|
5823
|
+
if (!contents) {
|
|
5824
|
+
return undefined;
|
|
5825
|
+
}
|
|
5826
|
+
const canGoBack = contents.navigationHistory.canGoBack();
|
|
5827
|
+
const canGoForward = contents.navigationHistory.canGoForward();
|
|
5828
|
+
const url = contents.getURL();
|
|
5829
|
+
const title = contents.getTitle();
|
|
5830
|
+
return {
|
|
5831
|
+
canGoBack,
|
|
5832
|
+
canGoForward,
|
|
5833
|
+
url,
|
|
5834
|
+
title
|
|
5835
|
+
};
|
|
5836
|
+
};
|
|
5837
|
+
const dispose$1 = webContentsId => {
|
|
5838
|
+
number(webContentsId);
|
|
5839
|
+
const contents = webContents.fromId(webContentsId);
|
|
5840
|
+
if (!contents) {
|
|
5841
|
+
return;
|
|
5842
|
+
}
|
|
5843
|
+
disposeWebContents(contents);
|
|
5844
|
+
};
|
|
5845
|
+
const callFunction = (webContentsId, functionName, ...args) => {
|
|
5846
|
+
number(webContentsId);
|
|
5847
|
+
string(functionName);
|
|
5848
|
+
const contents = webContents.fromId(webContentsId);
|
|
5849
|
+
if (!contents) {
|
|
5850
|
+
return;
|
|
5851
|
+
}
|
|
5852
|
+
contents[functionName](...args);
|
|
5853
|
+
};
|
|
5854
|
+
|
|
5808
5855
|
const KeyDown = 'keyDown';
|
|
5809
5856
|
|
|
5810
5857
|
const Backspace$1 = 'Backspace';
|
|
@@ -6628,15 +6675,6 @@ const wrapBrowserViewCommand = fn => {
|
|
|
6628
6675
|
};
|
|
6629
6676
|
return wrappedCommand;
|
|
6630
6677
|
};
|
|
6631
|
-
|
|
6632
|
-
/**
|
|
6633
|
-
*
|
|
6634
|
-
* @param {Electron.BrowserView} view
|
|
6635
|
-
* @param {number} x
|
|
6636
|
-
* @param {number} y
|
|
6637
|
-
* @param {number} width
|
|
6638
|
-
* @param {number} height
|
|
6639
|
-
*/
|
|
6640
6678
|
const resizeBrowserView = (view, x, y, width, height) => {
|
|
6641
6679
|
object(view);
|
|
6642
6680
|
number(x);
|
|
@@ -6658,12 +6696,6 @@ const setIframeSrcFallback = async (view, code, message) => {
|
|
|
6658
6696
|
}
|
|
6659
6697
|
});
|
|
6660
6698
|
};
|
|
6661
|
-
|
|
6662
|
-
/**
|
|
6663
|
-
*
|
|
6664
|
-
* @param {Electron.BrowserView} view
|
|
6665
|
-
* @param {string} iframeSrc
|
|
6666
|
-
*/
|
|
6667
6699
|
const setIframeSrc = async (view, iframeSrc) => {
|
|
6668
6700
|
try {
|
|
6669
6701
|
object(view);
|
|
@@ -6679,21 +6711,12 @@ const setIframeSrc = async (view, iframeSrc) => {
|
|
|
6679
6711
|
throw betterError;
|
|
6680
6712
|
}
|
|
6681
6713
|
};
|
|
6682
|
-
/**
|
|
6683
|
-
*
|
|
6684
|
-
* @param {Electron.BrowserView} view
|
|
6685
|
-
*/
|
|
6686
6714
|
const focus = view => {
|
|
6687
6715
|
const {
|
|
6688
6716
|
webContents
|
|
6689
6717
|
} = view;
|
|
6690
6718
|
webContents.focus();
|
|
6691
6719
|
};
|
|
6692
|
-
|
|
6693
|
-
/**
|
|
6694
|
-
*
|
|
6695
|
-
* @param {Electron.BrowserView} view
|
|
6696
|
-
*/
|
|
6697
6720
|
const openDevtools = view => {
|
|
6698
6721
|
const {
|
|
6699
6722
|
webContents
|
|
@@ -6701,43 +6724,25 @@ const openDevtools = view => {
|
|
|
6701
6724
|
// TODO return promise that resolves once devtools are actually open
|
|
6702
6725
|
webContents.openDevTools();
|
|
6703
6726
|
};
|
|
6704
|
-
/**
|
|
6705
|
-
*
|
|
6706
|
-
* @param {Electron.BrowserView} view
|
|
6707
|
-
*/
|
|
6708
6727
|
const reload = view => {
|
|
6709
6728
|
const {
|
|
6710
6729
|
webContents
|
|
6711
6730
|
} = view;
|
|
6712
6731
|
webContents.reload();
|
|
6713
6732
|
};
|
|
6714
|
-
/**
|
|
6715
|
-
*
|
|
6716
|
-
* @param {Electron.BrowserView} view
|
|
6717
|
-
*/
|
|
6718
6733
|
const forward = view => {
|
|
6719
6734
|
const {
|
|
6720
6735
|
webContents
|
|
6721
6736
|
} = view;
|
|
6722
|
-
webContents.goForward();
|
|
6737
|
+
webContents.navigationHistory.goForward();
|
|
6723
6738
|
};
|
|
6724
|
-
|
|
6725
|
-
/**
|
|
6726
|
-
*
|
|
6727
|
-
* @param {Electron.BrowserView} view
|
|
6728
|
-
*/
|
|
6729
6739
|
const backward = view => {
|
|
6730
6740
|
// TODO return promise that resolves once devtools are actually open
|
|
6731
6741
|
const {
|
|
6732
6742
|
webContents
|
|
6733
6743
|
} = view;
|
|
6734
|
-
webContents.goBack();
|
|
6744
|
+
webContents.navigationHistory.goBack();
|
|
6735
6745
|
};
|
|
6736
|
-
|
|
6737
|
-
/**
|
|
6738
|
-
*
|
|
6739
|
-
* @param {Electron.BrowserView} view
|
|
6740
|
-
*/
|
|
6741
6746
|
const cancelNavigation = view => {
|
|
6742
6747
|
const {
|
|
6743
6748
|
webContents
|
|
@@ -6745,8 +6750,8 @@ const cancelNavigation = view => {
|
|
|
6745
6750
|
setCanceled(webContents.id);
|
|
6746
6751
|
debug(`[main process] canceled navigation to ${webContents.getURL()}`);
|
|
6747
6752
|
webContents.stop();
|
|
6748
|
-
if (webContents.canGoBack()) {
|
|
6749
|
-
webContents.goBack();
|
|
6753
|
+
if (webContents.navigationHistory.canGoBack()) {
|
|
6754
|
+
webContents.navigationHistory.goBack();
|
|
6750
6755
|
}
|
|
6751
6756
|
};
|
|
6752
6757
|
const show = id => {
|
|
@@ -6833,7 +6838,7 @@ const setFallThroughKeyBindings = fallthroughKeyBindings => {
|
|
|
6833
6838
|
/**
|
|
6834
6839
|
* @param {Electron.BrowserView} view
|
|
6835
6840
|
*/
|
|
6836
|
-
const getStats
|
|
6841
|
+
const getStats = view => {
|
|
6837
6842
|
const {
|
|
6838
6843
|
webContents
|
|
6839
6844
|
} = view;
|
|
@@ -7133,7 +7138,7 @@ const sendTo2 = async (port, targetRpcId, sourceRpcId) => {
|
|
|
7133
7138
|
};
|
|
7134
7139
|
|
|
7135
7140
|
// todo dispose the rpc by rpc id
|
|
7136
|
-
const dispose
|
|
7141
|
+
const dispose = name => {
|
|
7137
7142
|
string(name);
|
|
7138
7143
|
const formattedName = formatUtilityProcessName(name);
|
|
7139
7144
|
const utilityProcess = getByName(formattedName);
|
|
@@ -7180,6 +7185,9 @@ const commandMap = {
|
|
|
7180
7185
|
'ElectronShell.openExternal': openExternal,
|
|
7181
7186
|
'ElectronShell.openPath': openPath,
|
|
7182
7187
|
'ElectronShell.showItemInFolder': showItemInFolder,
|
|
7188
|
+
'ElectronWebContents.callFunction': callFunction,
|
|
7189
|
+
'ElectronWebContents.dispose': dispose$1,
|
|
7190
|
+
'ElectronWebContents.getStats': getStats$1,
|
|
7183
7191
|
'ElectronWebContentsView.attachEventListeners': attachEventListeners,
|
|
7184
7192
|
'ElectronWebContentsView.createWebContentsView': createWebContentsView,
|
|
7185
7193
|
'ElectronWebContentsView.disposeWebContentsView': disposeWebContentsView,
|
|
@@ -7189,7 +7197,7 @@ const commandMap = {
|
|
|
7189
7197
|
'ElectronWebContentsViewFunctions.copyImageAt': wrapBrowserViewCommand(copyImageAt),
|
|
7190
7198
|
'ElectronWebContentsViewFunctions.focus': wrapBrowserViewCommand(focus),
|
|
7191
7199
|
'ElectronWebContentsViewFunctions.forward': wrapBrowserViewCommand(forward),
|
|
7192
|
-
'ElectronWebContentsViewFunctions.getStats': wrapBrowserViewCommand(getStats
|
|
7200
|
+
'ElectronWebContentsViewFunctions.getStats': wrapBrowserViewCommand(getStats),
|
|
7193
7201
|
'ElectronWebContentsViewFunctions.hide': hide,
|
|
7194
7202
|
'ElectronWebContentsViewFunctions.inspectElement': wrapBrowserViewCommand(inspectElement),
|
|
7195
7203
|
'ElectronWebContentsViewFunctions.openDevtools': wrapBrowserViewCommand(openDevtools),
|
|
@@ -7217,7 +7225,7 @@ const commandMap = {
|
|
|
7217
7225
|
'Process.getPid': getPid,
|
|
7218
7226
|
'Process.getV8Version': getV8Version,
|
|
7219
7227
|
'TemporaryMessagePort.createPortTuple': createPortTuple,
|
|
7220
|
-
'TemporaryMessagePort.dispose': dispose
|
|
7228
|
+
'TemporaryMessagePort.dispose': dispose,
|
|
7221
7229
|
'TemporaryMessagePort.sendTo': sendTo,
|
|
7222
7230
|
'TemporaryMessagePort.sendTo2': sendTo2,
|
|
7223
7231
|
'Trash.trash': trash
|
|
@@ -7739,7 +7747,7 @@ const ElectronScreen_ipc = {
|
|
|
7739
7747
|
const name$7 = 'TemporaryMessagePort';
|
|
7740
7748
|
const Commands$7 = {
|
|
7741
7749
|
createPortTuple: createPortTuple,
|
|
7742
|
-
dispose: dispose
|
|
7750
|
+
dispose: dispose,
|
|
7743
7751
|
sendTo: sendTo
|
|
7744
7752
|
};
|
|
7745
7753
|
|
|
@@ -7749,61 +7757,10 @@ const TemporaryMessagePort_ipc = {
|
|
|
7749
7757
|
name: name$7
|
|
7750
7758
|
};
|
|
7751
7759
|
|
|
7752
|
-
/**
|
|
7753
|
-
*
|
|
7754
|
-
* @param {Electron.WebContents} webContents
|
|
7755
|
-
*/
|
|
7756
|
-
const disposeWebContents = webContents => {
|
|
7757
|
-
if (webContents.close) {
|
|
7758
|
-
// electron v22
|
|
7759
|
-
webContents.close();
|
|
7760
|
-
// @ts-ignore
|
|
7761
|
-
} else if (webContents.destroy) {
|
|
7762
|
-
// older versions of electron
|
|
7763
|
-
// @ts-ignore
|
|
7764
|
-
webContents.destroy();
|
|
7765
|
-
}
|
|
7766
|
-
};
|
|
7767
|
-
|
|
7768
|
-
const getStats = webContentsId => {
|
|
7769
|
-
number(webContentsId);
|
|
7770
|
-
const contents = webContents.fromId(webContentsId);
|
|
7771
|
-
if (!contents) {
|
|
7772
|
-
return undefined;
|
|
7773
|
-
}
|
|
7774
|
-
const canGoBack = contents.navigationHistory.canGoBack();
|
|
7775
|
-
const canGoForward = contents.navigationHistory.canGoForward();
|
|
7776
|
-
const url = contents.getURL();
|
|
7777
|
-
const title = contents.getTitle();
|
|
7778
|
-
return {
|
|
7779
|
-
canGoBack,
|
|
7780
|
-
canGoForward,
|
|
7781
|
-
url,
|
|
7782
|
-
title
|
|
7783
|
-
};
|
|
7784
|
-
};
|
|
7785
|
-
const dispose = webContentsId => {
|
|
7786
|
-
number(webContentsId);
|
|
7787
|
-
const contents = webContents.fromId(webContentsId);
|
|
7788
|
-
if (!contents) {
|
|
7789
|
-
return;
|
|
7790
|
-
}
|
|
7791
|
-
disposeWebContents(contents);
|
|
7792
|
-
};
|
|
7793
|
-
const callFunction = (webContentsId, functionName, ...args) => {
|
|
7794
|
-
number(webContentsId);
|
|
7795
|
-
string(functionName);
|
|
7796
|
-
const contents = webContents.fromId(webContentsId);
|
|
7797
|
-
if (!contents) {
|
|
7798
|
-
return;
|
|
7799
|
-
}
|
|
7800
|
-
contents[functionName](...args);
|
|
7801
|
-
};
|
|
7802
|
-
|
|
7803
7760
|
const name$6 = 'ElectronWebContents';
|
|
7804
7761
|
const Commands$6 = {
|
|
7805
|
-
dispose: dispose,
|
|
7806
|
-
getStats: getStats,
|
|
7762
|
+
dispose: dispose$1,
|
|
7763
|
+
getStats: getStats$1,
|
|
7807
7764
|
callFunction: callFunction
|
|
7808
7765
|
};
|
|
7809
7766
|
|
|
@@ -7834,7 +7791,7 @@ const Commands$4 = {
|
|
|
7834
7791
|
copyImageAt: wrapBrowserViewCommand(copyImageAt),
|
|
7835
7792
|
focus: wrapBrowserViewCommand(focus),
|
|
7836
7793
|
forward: wrapBrowserViewCommand(forward),
|
|
7837
|
-
getStats: wrapBrowserViewCommand(getStats
|
|
7794
|
+
getStats: wrapBrowserViewCommand(getStats),
|
|
7838
7795
|
hide: hide,
|
|
7839
7796
|
inspectElement: wrapBrowserViewCommand(inspectElement),
|
|
7840
7797
|
openDevtools: wrapBrowserViewCommand(openDevtools),
|