@lvce-editor/main-process 2.3.0 → 2.4.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.
@@ -2710,7 +2710,7 @@ const callbacks = Object.create(null);
2710
2710
  const set$2 = (id, fn) => {
2711
2711
  callbacks[id] = fn;
2712
2712
  };
2713
- const get$3 = id => {
2713
+ const get$4 = id => {
2714
2714
  return callbacks[id];
2715
2715
  };
2716
2716
  const remove$2 = id => {
@@ -2883,7 +2883,7 @@ const warn = (...args) => {
2883
2883
  console.warn(...args);
2884
2884
  };
2885
2885
  const resolve = (id, response) => {
2886
- const fn = get$3(id);
2886
+ const fn = get$4(id);
2887
2887
  if (!fn) {
2888
2888
  console.log(response);
2889
2889
  warn(`callback ${id} may already be disposed`);
@@ -4803,7 +4803,7 @@ const hasWebContents = id => {
4803
4803
  * @param {number} id
4804
4804
  * @returns {{browserWindow: Electron.BrowserWindow, view: Electron.WebContentsView}}
4805
4805
  */
4806
- const get$2 = id => {
4806
+ const get$3 = id => {
4807
4807
  return state$5.views[id];
4808
4808
  };
4809
4809
  const remove$1 = id => {
@@ -5271,7 +5271,7 @@ const state$3 = {
5271
5271
  const has = () => {
5272
5272
  return Boolean(state$3.session);
5273
5273
  };
5274
- const get$1 = () => {
5274
+ const get$2 = () => {
5275
5275
  if (!state$3.session) {
5276
5276
  throw new Error('session is not defined');
5277
5277
  }
@@ -5374,11 +5374,11 @@ const create$1 = ipc => {
5374
5374
  return handleRequest;
5375
5375
  };
5376
5376
 
5377
- const get = () => {
5377
+ const get$1 = () => {
5378
5378
  if (!has()) {
5379
5379
  set$1(createElectronSession());
5380
5380
  }
5381
- return get$1();
5381
+ return get$2();
5382
5382
  };
5383
5383
  const registerWebviewProtocol = async port => {
5384
5384
  object(port);
@@ -5390,7 +5390,7 @@ const registerWebviewProtocol = async port => {
5390
5390
  console.log('do register protocol');
5391
5391
  handleIpc(ipc);
5392
5392
  port.start();
5393
- const session = get();
5393
+ const session = get$1();
5394
5394
  const handleRequest = create$1(ipc);
5395
5395
  // @ts-ignore
5396
5396
  handle(session.protocol, WebView, handleRequest);
@@ -5422,7 +5422,7 @@ const loadUrl = async (browserWindow, url) => {
5422
5422
 
5423
5423
  // TODO avoid mixing BrowserWindow, childprocess and various lifecycle methods in one file -> separate concerns
5424
5424
  const createAppWindow = async (windowOptions, parsedArgs, workingDirectory, titleBarItems, url) => {
5425
- const session = get();
5425
+ const session = get$1();
5426
5426
  mark(WillCreateCodeWindow);
5427
5427
  const window = new BrowserWindow({
5428
5428
  ...windowOptions,
@@ -5636,6 +5636,9 @@ const rpcs = Object.create(null);
5636
5636
  const set$3 = (id, rpc) => {
5637
5637
  rpcs[id] = rpc;
5638
5638
  };
5639
+ const get = id => {
5640
+ return rpcs[id];
5641
+ };
5639
5642
 
5640
5643
  const createUtilityProcessRpc = async options => {
5641
5644
  const rpc = await ElectronUtilityProcessRpcParent.create({
@@ -6691,7 +6694,7 @@ const attachEventListeners = webContentsId => {
6691
6694
  };
6692
6695
  const disposeWebContentsView = browserViewId => {
6693
6696
  console.log('[main process] dispose browser view', browserViewId);
6694
- const instance = get$2(browserViewId);
6697
+ const instance = get$3(browserViewId);
6695
6698
  if (!instance) {
6696
6699
  return;
6697
6700
  }
@@ -6709,7 +6712,7 @@ const webContentsViewErrorPath = join(root, 'packages', 'main-process', 'pages',
6709
6712
 
6710
6713
  const wrapBrowserViewCommand = fn => {
6711
6714
  const wrappedCommand = (id, ...args) => {
6712
- const state = get$2(id);
6715
+ const state = get$3(id);
6713
6716
  if (!state) {
6714
6717
  console.log(`[main process] no browser view with id ${id}`);
6715
6718
  return;
@@ -6844,7 +6847,7 @@ const cancelNavigation = view => {
6844
6847
  };
6845
6848
  const show = id => {
6846
6849
  // console.log('[main-process] show browser view', id)
6847
- const state = get$2(id);
6850
+ const state = get$3(id);
6848
6851
  if (!state) {
6849
6852
  debug('[main-process] failed to show browser view', id);
6850
6853
  return;
@@ -6856,7 +6859,7 @@ const show = id => {
6856
6859
  browserWindow.contentView.addChildView(view);
6857
6860
  };
6858
6861
  const addToWindow = (browserWindowId, browserViewId) => {
6859
- const state = get$2(browserViewId);
6862
+ const state = get$3(browserViewId);
6860
6863
  const {
6861
6864
  view
6862
6865
  } = state;
@@ -6867,7 +6870,7 @@ const addToWindow = (browserWindowId, browserViewId) => {
6867
6870
  browserWindow.contentView.addChildView(view);
6868
6871
  };
6869
6872
  const hide = id => {
6870
- const state = get$2(id);
6873
+ const state = get$3(id);
6871
6874
  if (!state) {
6872
6875
  debug('[main-process] failed to hide browser view', id);
6873
6876
  return;
@@ -6981,7 +6984,7 @@ const open2 = async (options, url) => {
6981
6984
  ...options,
6982
6985
  webPreferences: {
6983
6986
  ...options.webPreferences,
6984
- session: get()
6987
+ session: get$1()
6985
6988
  }
6986
6989
  };
6987
6990
  const processExplorerWindow = new BrowserWindow(allOptions);
@@ -7137,6 +7140,15 @@ const sendTo = async (port, name, ipcId) => {
7137
7140
  await invokeAndTransfer$1(utilityProcessIpc, 'HandleElectronMessagePort.handleElectronMessagePort', port, ipcId);
7138
7141
  unhandleIpc(utilityProcessIpc);
7139
7142
  };
7143
+
7144
+ // TODO use rpc id, and then use rpc.invokeAndtransfer
7145
+ const sendTo2 = async (port, rpcId) => {
7146
+ object(port);
7147
+ const rpc = get(rpcId);
7148
+ await rpc.invokeAndTransfer('HandleElectronMessagePort.handleElectronMessagePort', port, rpcId);
7149
+ };
7150
+
7151
+ // todo dispose the rpc by rpc id
7140
7152
  const dispose$1 = name => {
7141
7153
  string(name);
7142
7154
  const formattedName = formatUtilityProcessName(name);
@@ -7200,7 +7212,7 @@ const commandMap = {
7200
7212
  'ElectronWebContentsViewFunctions.reload': reload,
7201
7213
  'ElectronWebContentsViewFunctions.resizeBrowserView': resizeBrowserView,
7202
7214
  'ElectronWebContentsViewFunctions.setBackgroundColor': setBackgroundColor,
7203
- 'ElectronWebContentsViewFunctions.setFallthroughKeyBindings': undefined,
7215
+ 'ElectronWebContentsViewFunctions.setFallthroughKeyBindings': setFallThroughKeyBindings,
7204
7216
  'ElectronWebContentsViewFunctions.setIframeSrc': setIframeSrc,
7205
7217
  'ElectronWebContentsViewFunctions.setIframeSrcFallback': setIframeSrcFallback,
7206
7218
  'ElectronWebContentsViewFunctions.show': show,
@@ -7223,6 +7235,7 @@ const commandMap = {
7223
7235
  'TemporaryMessagePort.createPortTuple': createPortTuple,
7224
7236
  'TemporaryMessagePort.dispose': dispose$1,
7225
7237
  'TemporaryMessagePort.sendTo': sendTo,
7238
+ 'TemporaryMessagePort.sendTo2': sendTo2,
7226
7239
  'Trash.trash': trash
7227
7240
  };
7228
7241
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lvce-editor",
@@ -15,7 +15,7 @@
15
15
  "type": "module",
16
16
  "main": "dist/mainProcessMain.js",
17
17
  "dependencies": {
18
- "electron": "36.1.0"
18
+ "electron": "36.2.0"
19
19
  },
20
20
  "engines": {
21
21
  "node": ">=22"