@lvce-editor/main-process 6.26.0 → 6.27.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.
@@ -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;
@@ -7130,13 +7137,42 @@ const insertCss = async (view, code) => {
7130
7137
  const key = await webContents.insertCSS(code);
7131
7138
  return key;
7132
7139
  };
7133
- const executeJavaScript = async (view, code) => {
7140
+ const executeJavaScript = async (view, code, userGesture = false) => {
7134
7141
  const {
7135
7142
  webContents
7136
7143
  } = view;
7137
- const key = await webContents.executeJavaScript(code);
7144
+ const key = await webContents.executeJavaScript(code, userGesture);
7138
7145
  return key;
7139
7146
  };
7147
+ const click = async (view, selector) => {
7148
+ string(selector);
7149
+ const {
7150
+ webContents
7151
+ } = view;
7152
+ 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) } })()`);
7153
+ if (!point) {
7154
+ return false;
7155
+ }
7156
+ const input = {
7157
+ button: 'left',
7158
+ clickCount: 1,
7159
+ x: point.x,
7160
+ y: point.y
7161
+ };
7162
+ webContents.sendInputEvent({
7163
+ ...input,
7164
+ type: 'mouseMove'
7165
+ });
7166
+ webContents.sendInputEvent({
7167
+ ...input,
7168
+ type: 'mouseDown'
7169
+ });
7170
+ webContents.sendInputEvent({
7171
+ ...input,
7172
+ type: 'mouseUp'
7173
+ });
7174
+ return true;
7175
+ };
7140
7176
  const reload = view => {
7141
7177
  const {
7142
7178
  webContents
@@ -7829,6 +7865,7 @@ const commandMap = {
7829
7865
  'ElectronWebContentsViewFunctions.backward': wrapBrowserViewCommand(backward),
7830
7866
  'ElectronWebContentsViewFunctions.cancelNavigation': wrapBrowserViewCommand(cancelNavigation),
7831
7867
  'ElectronWebContentsViewFunctions.capturePage': wrapBrowserViewCommand(capturePage),
7868
+ 'ElectronWebContentsViewFunctions.click': wrapBrowserViewCommand(click),
7832
7869
  'ElectronWebContentsViewFunctions.copyImageAt': wrapBrowserViewCommand(copyImageAt),
7833
7870
  'ElectronWebContentsViewFunctions.executeJavaScript': wrapBrowserViewCommand(executeJavaScript),
7834
7871
  'ElectronWebContentsViewFunctions.focus': wrapBrowserViewCommand(focus),
@@ -7840,7 +7877,7 @@ const commandMap = {
7840
7877
  'ElectronWebContentsViewFunctions.insertJavaScript': wrapBrowserViewCommand(executeJavaScript),
7841
7878
  'ElectronWebContentsViewFunctions.inspectElement': wrapBrowserViewCommand(inspectElement),
7842
7879
  'ElectronWebContentsViewFunctions.openDevtools': wrapBrowserViewCommand(openDevtools),
7843
- 'ElectronWebContentsViewFunctions.reload': wrapBrowserViewCommand(wrapBrowserViewCommand(reload)),
7880
+ 'ElectronWebContentsViewFunctions.reload': wrapBrowserViewCommand(reload),
7844
7881
  'ElectronWebContentsViewFunctions.resizeBrowserView': wrapBrowserViewCommand(resizeBrowserView),
7845
7882
  'ElectronWebContentsViewFunctions.setBackgroundColor': wrapBrowserViewCommand(setBackgroundColor),
7846
7883
  'ElectronWebContentsViewFunctions.setFallthroughKeyBindings': wrapBrowserViewCommand(setFallThroughKeyBindings),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.26.0",
3
+ "version": "6.27.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"