@lvce-editor/main-process 6.7.0 → 6.8.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.
@@ -2794,6 +2794,78 @@ const create$4 = async ({
2794
2794
 
2795
2795
  const commandMapRef = Object.create(null);
2796
2796
 
2797
+ const Dash = '-';
2798
+ const Space$2 = ' ';
2799
+
2800
+ const firstLetterLowerCase = string => {
2801
+ return string[0].toLowerCase() + string.slice(1);
2802
+ };
2803
+ const camelCase = string => {
2804
+ const parts = string.split(Space$2);
2805
+ const lowerParts = parts.map(firstLetterLowerCase);
2806
+ return lowerParts.join(Dash);
2807
+ };
2808
+
2809
+ const formatUtilityProcessName = name => {
2810
+ return camelCase(name);
2811
+ };
2812
+
2813
+ const state$5 = {
2814
+ all: Object.create(null)
2815
+ };
2816
+ const add$1 = (pid, process, name) => {
2817
+ number(pid);
2818
+ object(process);
2819
+ string(name);
2820
+ state$5.all[pid] = {
2821
+ name,
2822
+ process
2823
+ };
2824
+ };
2825
+ const remove$1 = pid => {
2826
+ number(pid);
2827
+ delete state$5.all[pid];
2828
+ };
2829
+ const getAll = () => {
2830
+ return Object.entries(state$5.all);
2831
+ };
2832
+ const getByName = name => {
2833
+ for (const value of Object.values(state$5.all)) {
2834
+ // @ts-ignore
2835
+ if (value.name === name) {
2836
+ // @ts-ignore
2837
+ return value.process;
2838
+ }
2839
+ }
2840
+ return undefined;
2841
+ };
2842
+
2843
+ const trackUtilityProcess = (rawIpc, name) => {
2844
+ if (!rawIpc?.pid) {
2845
+ return;
2846
+ }
2847
+ const {
2848
+ pid
2849
+ } = rawIpc;
2850
+ const formattedName = formatUtilityProcessName(name);
2851
+ add$1(pid, rawIpc, formattedName);
2852
+ const cleanup = () => {
2853
+ remove$1(pid);
2854
+ rawIpc.off('exit', handleExit);
2855
+ };
2856
+ const handleExit = () => {
2857
+ cleanup();
2858
+ };
2859
+ rawIpc.on('exit', handleExit);
2860
+ };
2861
+
2862
+ const createElectronUtilityProcessRpc = async options => {
2863
+ const rpc = await create$5(options);
2864
+ const rpcWithRawIpc = rpc;
2865
+ trackUtilityProcess(rpcWithRawIpc.ipc?._rawIpc, options.name);
2866
+ return rpc;
2867
+ };
2868
+
2797
2869
  const getPortTuple = () => {
2798
2870
  const {
2799
2871
  port1,
@@ -2904,7 +2976,7 @@ const launchSharedProcess = async ({
2904
2976
  ...process.env,
2905
2977
  ...env
2906
2978
  };
2907
- const sharedProcessRpc = await create$5({
2979
+ const sharedProcessRpc = await createElectronUtilityProcessRpc({
2908
2980
  argv: [],
2909
2981
  commandMap: commandMapRef,
2910
2982
  env: fullEnv,
@@ -2942,7 +3014,7 @@ const launchSharedProcess = async ({
2942
3014
  return sharedProcessRpc;
2943
3015
  };
2944
3016
 
2945
- const state$5 = {
3017
+ const state$4 = {
2946
3018
  /**
2947
3019
  * @type {any}
2948
3020
  */
@@ -2953,14 +3025,14 @@ const getOrCreate = async ({
2953
3025
  env = {},
2954
3026
  method
2955
3027
  }) => {
2956
- if (!state$5.promise) {
3028
+ if (!state$4.promise) {
2957
3029
  // @ts-ignore
2958
- state$5.promise = launchSharedProcess({
3030
+ state$4.promise = launchSharedProcess({
2959
3031
  env,
2960
3032
  method
2961
3033
  });
2962
3034
  }
2963
- return state$5.promise;
3035
+ return state$4.promise;
2964
3036
  };
2965
3037
  const send$1 = async (method, ...params) => {
2966
3038
  const rpc = await getOrCreate({
@@ -3123,14 +3195,14 @@ const createTitleBar = items => {
3123
3195
 
3124
3196
  const PHASE_DEFAULT = 0;
3125
3197
  const PHASE_SHUTDOWN = -1;
3126
- const state$4 = {
3198
+ const state$3 = {
3127
3199
  phase: PHASE_DEFAULT
3128
3200
  };
3129
3201
  const isShutDown = () => {
3130
- return state$4.phase === PHASE_SHUTDOWN;
3202
+ return state$3.phase === PHASE_SHUTDOWN;
3131
3203
  };
3132
3204
  const setShutDown = () => {
3133
- state$4.phase = PHASE_SHUTDOWN;
3205
+ state$3.phase = PHASE_SHUTDOWN;
3134
3206
  };
3135
3207
 
3136
3208
  // TODO move this function to shared process
@@ -3427,21 +3499,21 @@ const openExternal = async url => {
3427
3499
  await shell.openExternal(url);
3428
3500
  };
3429
3501
 
3430
- const state$3 = {
3502
+ const state$2 = {
3431
3503
  canceled: Object.create(null),
3432
3504
  fallThroughKeyBindings: [],
3433
3505
  views: Object.create(null)
3434
3506
  };
3435
- const add$1 = (id, browserWindow, view) => {
3507
+ const add = (id, browserWindow, view) => {
3436
3508
  // state
3437
- state$3.views[id] = {
3509
+ state$2.views[id] = {
3438
3510
  browserWindow,
3439
3511
  view
3440
3512
  };
3441
3513
  };
3442
3514
  const hasWebContents = id => {
3443
3515
  number(id);
3444
- return id in state$3.views;
3516
+ return id in state$2.views;
3445
3517
  };
3446
3518
  /**
3447
3519
  *
@@ -3449,19 +3521,19 @@ const hasWebContents = id => {
3449
3521
  * @returns {{browserWindow: Electron.BrowserWindow, view: Electron.WebContentsView}}
3450
3522
  */
3451
3523
  const get$3 = id => {
3452
- return state$3.views[id];
3524
+ return state$2.views[id];
3453
3525
  };
3454
- const remove$1 = id => {
3455
- delete state$3.views[id];
3526
+ const remove = id => {
3527
+ delete state$2.views[id];
3456
3528
  };
3457
3529
  const setFallthroughKeyBindings = fallthroughKeyBindings => {
3458
- state$3.fallThroughKeyBindings = fallthroughKeyBindings;
3530
+ state$2.fallThroughKeyBindings = fallthroughKeyBindings;
3459
3531
  };
3460
3532
  const getFallthroughKeyBindings = () => {
3461
- return state$3.fallThroughKeyBindings;
3533
+ return state$2.fallThroughKeyBindings;
3462
3534
  };
3463
3535
  const setCanceled = id => {
3464
- state$3.canceled[id] = true;
3536
+ state$2.canceled[id] = true;
3465
3537
  };
3466
3538
 
3467
3539
  const shouldAllowNavigation = webContentsId => {
@@ -3775,20 +3847,20 @@ const createElectronSession = () => {
3775
3847
  return session;
3776
3848
  };
3777
3849
 
3778
- const state$2 = {
3850
+ const state$1 = {
3779
3851
  session: undefined
3780
3852
  };
3781
3853
  const has = () => {
3782
- return Boolean(state$2.session);
3854
+ return Boolean(state$1.session);
3783
3855
  };
3784
3856
  const get$2 = () => {
3785
- if (!state$2.session) {
3857
+ if (!state$1.session) {
3786
3858
  throw new Error('session is not defined');
3787
3859
  }
3788
- return state$2.session;
3860
+ return state$1.session;
3789
3861
  };
3790
3862
  const set$1 = value => {
3791
- state$2.session = value;
3863
+ state$1.session = value;
3792
3864
  };
3793
3865
 
3794
3866
  const create$3 = rpc => {
@@ -4009,36 +4081,6 @@ const createMessagePort = async (ipcId, port, webContentsId) => {
4009
4081
  return webContentsId;
4010
4082
  };
4011
4083
 
4012
- const state$1 = {
4013
- all: Object.create(null)
4014
- };
4015
- const add = (pid, process, name) => {
4016
- number(pid);
4017
- object(process);
4018
- string(name);
4019
- state$1.all[pid] = {
4020
- name,
4021
- process
4022
- };
4023
- };
4024
- const remove = pid => {
4025
- number(pid);
4026
- delete state$1.all[pid];
4027
- };
4028
- const getAll = () => {
4029
- return Object.entries(state$1.all);
4030
- };
4031
- const getByName = name => {
4032
- for (const value of Object.values(state$1.all)) {
4033
- // @ts-ignore
4034
- if (value.name === name) {
4035
- // @ts-ignore
4036
- return value.process;
4037
- }
4038
- }
4039
- return undefined;
4040
- };
4041
-
4042
4084
  const createPidMap = () => {
4043
4085
  const browserWindows = BrowserWindow.getAllWindows();
4044
4086
  const utilityProcesses = getAll();
@@ -4080,7 +4122,7 @@ const get = id => {
4080
4122
  };
4081
4123
 
4082
4124
  const createUtilityProcessRpc = async options => {
4083
- const rpc = await create$5({
4125
+ const rpc = await createElectronUtilityProcessRpc({
4084
4126
  commandMap: commandMapRef,
4085
4127
  ...options
4086
4128
  });
@@ -4590,7 +4632,7 @@ const KeyDown = 'keyDown';
4590
4632
 
4591
4633
  const Backspace$1 = 'Backspace';
4592
4634
  const Tab$1 = 'Tab';
4593
- const Space$2 = ' ';
4635
+ const Space$1 = ' ';
4594
4636
  const Enter$1 = 'Enter';
4595
4637
  const Escape$1 = 'Escape';
4596
4638
  const PageUp$1 = 'PageUp';
@@ -4682,7 +4724,7 @@ const Backspace = 1;
4682
4724
  const Tab = 2;
4683
4725
  const Enter = 3;
4684
4726
  const Escape = 8;
4685
- const Space$1 = 9;
4727
+ const Space = 9;
4686
4728
  const PageUp = 10;
4687
4729
  const PageDown = 11;
4688
4730
  const End = 255;
@@ -4852,7 +4894,7 @@ const keyCodeMap = {
4852
4894
  [RightArrow$1]: RightArrow,
4853
4895
  [SemiColon$1]: SemiColon,
4854
4896
  [Slash$1]: Slash,
4855
- [Space$2]: Space$1,
4897
+ [Space$1]: Space,
4856
4898
  [Star$1]: Star,
4857
4899
  [Tab$1]: Tab,
4858
4900
  [UpArrow$1]: UpArrow
@@ -5260,7 +5302,7 @@ const createWebContentsView = async () => {
5260
5302
  const {
5261
5303
  id
5262
5304
  } = webContents;
5263
- add$1(id, browserWindow, view);
5305
+ add(id, browserWindow, view);
5264
5306
  return id;
5265
5307
  };
5266
5308
  const attachEventListeners = webContentsId => {
@@ -5298,7 +5340,7 @@ const disposeWebContentsView = browserViewId => {
5298
5340
  browserWindow,
5299
5341
  view
5300
5342
  } = instance;
5301
- remove$1(browserViewId);
5343
+ remove(browserViewId);
5302
5344
  browserWindow.contentView.removeChildView(view);
5303
5345
  };
5304
5346
 
@@ -5527,6 +5569,32 @@ const getStats = view => {
5527
5569
  };
5528
5570
  };
5529
5571
 
5572
+ const gpuInfoUrl = 'chrome://gpu';
5573
+ let gpuInfoWindow;
5574
+ const open = async () => {
5575
+ if (gpuInfoWindow) {
5576
+ gpuInfoWindow.focus();
5577
+ return;
5578
+ }
5579
+ gpuInfoWindow = new BrowserWindow({
5580
+ height: 800,
5581
+ title: 'GPU Internals',
5582
+ webPreferences: {
5583
+ sandbox: true,
5584
+ spellcheck: false
5585
+ },
5586
+ width: 1200
5587
+ });
5588
+ const currentGpuInfoWindow = gpuInfoWindow;
5589
+ gpuInfoWindow.once('closed', () => {
5590
+ if (gpuInfoWindow === currentGpuInfoWindow) {
5591
+ gpuInfoWindow = undefined;
5592
+ }
5593
+ });
5594
+ gpuInfoWindow.setMenuBarVisibility(false);
5595
+ await gpuInfoWindow.loadURL(gpuInfoUrl);
5596
+ };
5597
+
5530
5598
  const printPrettyError = (prettyError, prefix = '') => {
5531
5599
  error(`${prefix}${prettyError.type}: ${prettyError.message}\n\n${prettyError.codeFrame}\n\n${prettyError.stack}\n`);
5532
5600
  };
@@ -6692,22 +6760,6 @@ const create$1 = async ({
6692
6760
  return ipc;
6693
6761
  };
6694
6762
 
6695
- const Dash = '-';
6696
- const Space = ' ';
6697
-
6698
- const firstLetterLowerCase = string => {
6699
- return string[0].toLowerCase() + string.slice(1);
6700
- };
6701
- const camelCase = string => {
6702
- const parts = string.split(Space);
6703
- const lowerParts = parts.map(firstLetterLowerCase);
6704
- return lowerParts.join(Dash);
6705
- };
6706
-
6707
- const formatUtilityProcessName = name => {
6708
- return camelCase(name);
6709
- };
6710
-
6711
6763
  const {
6712
6764
  create
6713
6765
  } = IpcParentWithElectronUtilityProcess$1$1;
@@ -6718,22 +6770,7 @@ const effects = ({
6718
6770
  name,
6719
6771
  rawIpc
6720
6772
  }) => {
6721
- if (!rawIpc.pid) {
6722
- return;
6723
- }
6724
- const {
6725
- pid
6726
- } = rawIpc;
6727
- const formattedName = formatUtilityProcessName(name);
6728
- add(pid, rawIpc, formattedName);
6729
- const cleanup = () => {
6730
- remove(pid);
6731
- rawIpc.off('exit', handleExit);
6732
- };
6733
- const handleExit = () => {
6734
- cleanup();
6735
- };
6736
- rawIpc.on('exit', handleExit);
6773
+ trackUtilityProcess(rawIpc, name);
6737
6774
  };
6738
6775
 
6739
6776
  const IpcParentWithElectronUtilityProcess = {
@@ -6870,6 +6907,7 @@ const commandMap = {
6870
6907
  'ElectronWindow.executeWindowFunction': executeWindowFunction,
6871
6908
  'ElectronWindow.getFocusedWindowId': getFocusedWindowId,
6872
6909
  'ElectronWindow.getZoom': getZoom,
6910
+ 'ElectronWindowGpuInfo.open': open,
6873
6911
  'ElectronWindowProcessExplorer.open2': open2,
6874
6912
  'Exit.exit': exit,
6875
6913
  'GetWindowId.getWindowId': getWindowId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.7.0",
3
+ "version": "6.8.1",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"