@lvce-editor/main-process 2.6.0 → 2.8.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.
@@ -5544,7 +5544,7 @@ const createPidMap = () => {
5544
5544
  };
5545
5545
 
5546
5546
  const rpcs = Object.create(null);
5547
- const set$3 = (id, rpc) => {
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$3(rpcId, rpc);
5560
+ set$5(rpcId, rpc);
5561
5561
  };
5562
5562
 
5563
5563
  const serializeDeskopCapturerSource = source => {
@@ -6724,6 +6724,35 @@ 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
+ };
6742
+ const insertCss = async (view, code) => {
6743
+ const {
6744
+ webContents
6745
+ } = view;
6746
+ const key = await webContents.insertCSS(code);
6747
+ return key;
6748
+ };
6749
+ const executeJavaScript = async (view, code) => {
6750
+ const {
6751
+ webContents
6752
+ } = view;
6753
+ const key = await webContents.executeJavaScript(code);
6754
+ return key;
6755
+ };
6727
6756
  const reload = view => {
6728
6757
  const {
6729
6758
  webContents
@@ -6979,7 +7008,7 @@ const handleElectronMessagePort = async (messagePort, rpcId) => {
6979
7008
  requiresSocket: requiresSocket
6980
7009
  });
6981
7010
  if (rpcId) {
6982
- set$3(rpcId, rpc);
7011
+ set$5(rpcId, rpc);
6983
7012
  }
6984
7013
  };
6985
7014
 
@@ -7192,10 +7221,14 @@ const commandMap = {
7192
7221
  'ElectronWebContentsView.createWebContentsView': createWebContentsView,
7193
7222
  'ElectronWebContentsView.disposeWebContentsView': disposeWebContentsView,
7194
7223
  'ElectronWebContentsViewFunctions.addToWindow': addToWindow,
7224
+ 'ElectronWebContentsViewFunctions.getDomTree': wrapBrowserViewCommand(getDomTree),
7195
7225
  'ElectronWebContentsViewFunctions.backward': wrapBrowserViewCommand(backward),
7196
7226
  'ElectronWebContentsViewFunctions.cancelNavigation': wrapBrowserViewCommand(cancelNavigation),
7197
7227
  'ElectronWebContentsViewFunctions.copyImageAt': wrapBrowserViewCommand(copyImageAt),
7198
7228
  'ElectronWebContentsViewFunctions.focus': wrapBrowserViewCommand(focus),
7229
+ 'ElectronWebContentsViewFunctions.insertCss': wrapBrowserViewCommand(insertCss),
7230
+ 'ElectronWebContentsViewFunctions.executeJavaScript': wrapBrowserViewCommand(executeJavaScript),
7231
+ 'ElectronWebContentsViewFunctions.insertJavaScript': wrapBrowserViewCommand(executeJavaScript),
7199
7232
  'ElectronWebContentsViewFunctions.forward': wrapBrowserViewCommand(forward),
7200
7233
  'ElectronWebContentsViewFunctions.getStats': wrapBrowserViewCommand(getStats),
7201
7234
  'ElectronWebContentsViewFunctions.hide': hide,
@@ -7801,7 +7834,11 @@ const Commands$4 = {
7801
7834
  setFallthroughKeyBindings: setFallThroughKeyBindings,
7802
7835
  setIframeSrc: wrapBrowserViewCommand(setIframeSrc),
7803
7836
  setIframeSrcFallback: wrapBrowserViewCommand(setIframeSrcFallback),
7804
- show: show
7837
+ show: show,
7838
+ getDomTree: wrapBrowserViewCommand(getDomTree),
7839
+ insertCss: wrapBrowserViewCommand(insertCss),
7840
+ executeJavaScript: wrapBrowserViewCommand(executeJavaScript),
7841
+ insertJavaScript: wrapBrowserViewCommand(executeJavaScript)
7805
7842
  };
7806
7843
 
7807
7844
  const ElectronWebContentsViewFunctions_ipc = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "2.6.0",
3
+ "version": "2.8.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lvce-editor",