@lvce-editor/main-process 6.26.0 → 6.27.1
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 +44 -6
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -3755,7 +3755,7 @@ const WebContentsCreated = 'web-contents-created';
|
|
|
3755
3755
|
const setMenu = menu => {
|
|
3756
3756
|
Menu.setApplicationMenu(menu);
|
|
3757
3757
|
};
|
|
3758
|
-
const click = async (menuItem, browserWindow, keys) => {
|
|
3758
|
+
const click$1 = async (menuItem, browserWindow, keys) => {
|
|
3759
3759
|
if (!browserWindow) {
|
|
3760
3760
|
return;
|
|
3761
3761
|
}
|
|
@@ -3765,13 +3765,13 @@ const addClickListener = item => {
|
|
|
3765
3765
|
if (item.submenu) {
|
|
3766
3766
|
return {
|
|
3767
3767
|
...item,
|
|
3768
|
-
click,
|
|
3768
|
+
click: click$1,
|
|
3769
3769
|
submenu: item.submenu.map(addClickListener)
|
|
3770
3770
|
};
|
|
3771
3771
|
}
|
|
3772
3772
|
return {
|
|
3773
3773
|
...item,
|
|
3774
|
-
click,
|
|
3774
|
+
click: click$1,
|
|
3775
3775
|
submenu: undefined
|
|
3776
3776
|
};
|
|
3777
3777
|
};
|
|
@@ -6984,6 +6984,13 @@ const createWebContentsView = async () => {
|
|
|
6984
6984
|
});
|
|
6985
6985
|
// TODO get browser window id from renderer worker
|
|
6986
6986
|
const browserWindow = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
|
|
6987
|
+
view.setBounds({
|
|
6988
|
+
height: 720,
|
|
6989
|
+
width: 1280,
|
|
6990
|
+
x: 0,
|
|
6991
|
+
y: 0
|
|
6992
|
+
});
|
|
6993
|
+
browserWindow.contentView.addChildView(view, 0);
|
|
6987
6994
|
const {
|
|
6988
6995
|
webContents
|
|
6989
6996
|
} = view;
|
|
@@ -7033,6 +7040,7 @@ const disposeWebContentsView = browserViewId => {
|
|
|
7033
7040
|
} = instance;
|
|
7034
7041
|
remove(browserViewId);
|
|
7035
7042
|
browserWindow.contentView.removeChildView(view);
|
|
7043
|
+
disposeWebContents(view.webContents);
|
|
7036
7044
|
};
|
|
7037
7045
|
|
|
7038
7046
|
const webContentsViewErrorPath = join(root, 'packages', 'main-process', 'pages', 'error', 'error.html');
|
|
@@ -7130,13 +7138,42 @@ const insertCss = async (view, code) => {
|
|
|
7130
7138
|
const key = await webContents.insertCSS(code);
|
|
7131
7139
|
return key;
|
|
7132
7140
|
};
|
|
7133
|
-
const executeJavaScript = async (view, code) => {
|
|
7141
|
+
const executeJavaScript = async (view, code, userGesture = false) => {
|
|
7134
7142
|
const {
|
|
7135
7143
|
webContents
|
|
7136
7144
|
} = view;
|
|
7137
|
-
const key = await webContents.executeJavaScript(code);
|
|
7145
|
+
const key = await webContents.executeJavaScript(code, userGesture);
|
|
7138
7146
|
return key;
|
|
7139
7147
|
};
|
|
7148
|
+
const click = async (view, selector) => {
|
|
7149
|
+
string(selector);
|
|
7150
|
+
const {
|
|
7151
|
+
webContents
|
|
7152
|
+
} = view;
|
|
7153
|
+
const point = await webContents.executeJavaScript(`(() => { const element = document.querySelector(${JSON.stringify(selector)}); if (!element) return undefined; const rect = element.getBoundingClientRect(); return { x: Math.round(rect.left + rect.width / 2), y: Math.round(rect.top + rect.height / 2) } })()`);
|
|
7154
|
+
if (!point) {
|
|
7155
|
+
return false;
|
|
7156
|
+
}
|
|
7157
|
+
const input = {
|
|
7158
|
+
button: 'left',
|
|
7159
|
+
clickCount: 1,
|
|
7160
|
+
x: point.x,
|
|
7161
|
+
y: point.y
|
|
7162
|
+
};
|
|
7163
|
+
webContents.sendInputEvent({
|
|
7164
|
+
...input,
|
|
7165
|
+
type: 'mouseMove'
|
|
7166
|
+
});
|
|
7167
|
+
webContents.sendInputEvent({
|
|
7168
|
+
...input,
|
|
7169
|
+
type: 'mouseDown'
|
|
7170
|
+
});
|
|
7171
|
+
webContents.sendInputEvent({
|
|
7172
|
+
...input,
|
|
7173
|
+
type: 'mouseUp'
|
|
7174
|
+
});
|
|
7175
|
+
return true;
|
|
7176
|
+
};
|
|
7140
7177
|
const reload = view => {
|
|
7141
7178
|
const {
|
|
7142
7179
|
webContents
|
|
@@ -7829,6 +7866,7 @@ const commandMap = {
|
|
|
7829
7866
|
'ElectronWebContentsViewFunctions.backward': wrapBrowserViewCommand(backward),
|
|
7830
7867
|
'ElectronWebContentsViewFunctions.cancelNavigation': wrapBrowserViewCommand(cancelNavigation),
|
|
7831
7868
|
'ElectronWebContentsViewFunctions.capturePage': wrapBrowserViewCommand(capturePage),
|
|
7869
|
+
'ElectronWebContentsViewFunctions.click': wrapBrowserViewCommand(click),
|
|
7832
7870
|
'ElectronWebContentsViewFunctions.copyImageAt': wrapBrowserViewCommand(copyImageAt),
|
|
7833
7871
|
'ElectronWebContentsViewFunctions.executeJavaScript': wrapBrowserViewCommand(executeJavaScript),
|
|
7834
7872
|
'ElectronWebContentsViewFunctions.focus': wrapBrowserViewCommand(focus),
|
|
@@ -7840,7 +7878,7 @@ const commandMap = {
|
|
|
7840
7878
|
'ElectronWebContentsViewFunctions.insertJavaScript': wrapBrowserViewCommand(executeJavaScript),
|
|
7841
7879
|
'ElectronWebContentsViewFunctions.inspectElement': wrapBrowserViewCommand(inspectElement),
|
|
7842
7880
|
'ElectronWebContentsViewFunctions.openDevtools': wrapBrowserViewCommand(openDevtools),
|
|
7843
|
-
'ElectronWebContentsViewFunctions.reload': wrapBrowserViewCommand(
|
|
7881
|
+
'ElectronWebContentsViewFunctions.reload': wrapBrowserViewCommand(reload),
|
|
7844
7882
|
'ElectronWebContentsViewFunctions.resizeBrowserView': wrapBrowserViewCommand(resizeBrowserView),
|
|
7845
7883
|
'ElectronWebContentsViewFunctions.setBackgroundColor': wrapBrowserViewCommand(setBackgroundColor),
|
|
7846
7884
|
'ElectronWebContentsViewFunctions.setFallthroughKeyBindings': wrapBrowserViewCommand(setFallThroughKeyBindings),
|