@lvce-editor/main-process 6.30.0 → 6.31.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.
@@ -754,19 +754,6 @@ function unhandled(inputOptions) {
754
754
  }
755
755
  }
756
756
 
757
- const setUserDataPath = value => {
758
- app.setPath('userData', value);
759
- };
760
- const setSessionDataPath = value => {
761
- app.setPath('sessionData', value);
762
- };
763
- const setCrashDumpsPath = value => {
764
- app.setPath('crashDumps', value);
765
- };
766
- const setLogsPath = value => {
767
- app.setPath('logs', value);
768
- };
769
-
770
757
  const Success = 0;
771
758
  const Error$3 = 1;
772
759
 
@@ -800,13 +787,16 @@ const homeDirectory = homedir();
800
787
 
801
788
  const xdgCache = env.XDG_CACHE_HOME || (homeDirectory ? join(homeDirectory, '.cache') : undefined);
802
789
  const xdgConfig = env.XDG_CONFIG_HOME || (homeDirectory ? join(homeDirectory, '.config') : undefined);
790
+ const configDir = join(xdgConfig || tmpdir(), applicationName);
803
791
  const xdgData = env.XDG_DATA_HOME || (homeDirectory ? join(homeDirectory, '.local', 'share') : undefined);
804
792
  join(xdgData || tmpdir(), applicationName);
805
793
  const xdgState = env.XDG_STATE_HOME || (homeDirectory ? join(homeDirectory, '.local', 'state') : undefined);
806
794
  const logsDir = join(xdgState || tmpdir(), applicationName, 'logs');
807
- const chromeUserDataPath = xdgCache ? join(xdgCache, applicationName, 'userdata') : '';
795
+ const electronUserDataPath = join(configDir, 'electron');
796
+ const crashDumpsPath = join(electronUserDataPath, 'Crashpad');
797
+ const electronSessionDataPath = join(xdgCache || tmpdir(), applicationName, 'userdata');
808
798
  const getArgvConfigPath = () => {
809
- return join(xdgConfig || tmpdir(), applicationName, 'argv.json');
799
+ return join(configDir, 'argv.json');
810
800
  };
811
801
 
812
802
  const useIpcForResponse = true;
@@ -3453,7 +3443,7 @@ const remove$1 = pid => {
3453
3443
  number(pid);
3454
3444
  delete state$5.all[pid];
3455
3445
  };
3456
- const getAll = () => {
3446
+ const getAll$1 = () => {
3457
3447
  return Object.entries(state$5.all);
3458
3448
  };
3459
3449
  const getByName = name => {
@@ -4127,6 +4117,9 @@ const hasWebContents = id => {
4127
4117
  const get$3 = id => {
4128
4118
  return state$2.views[id];
4129
4119
  };
4120
+ const getAll = () => {
4121
+ return Object.values(state$2.views);
4122
+ };
4130
4123
  const remove = id => {
4131
4124
  delete state$2.views[id];
4132
4125
  };
@@ -4230,7 +4223,7 @@ const requestSingleInstanceLock = argv => {
4230
4223
  // currently launching shared process takes 170ms
4231
4224
  // which means first paint is delayed by a lot
4232
4225
 
4233
- const hydrate = async (isLinux, chromeUserDataPath, argv) => {
4226
+ const hydrate = async argv => {
4234
4227
  setMenu(null); // performance
4235
4228
  unhandled({
4236
4229
  logger() {},
@@ -4254,12 +4247,6 @@ const hydrate = async (isLinux, chromeUserDataPath, argv) => {
4254
4247
  await handleFastCliArgs(moduleId, parsedCliArgs);
4255
4248
  return;
4256
4249
  }
4257
- if (isLinux && chromeUserDataPath) {
4258
- setUserDataPath(chromeUserDataPath);
4259
- setSessionDataPath(chromeUserDataPath);
4260
- setCrashDumpsPath(chromeUserDataPath);
4261
- setLogsPath(chromeUserDataPath);
4262
- }
4263
4250
  if (!isPromptMode$1) {
4264
4251
  const hasLock = requestSingleInstanceLock(argv);
4265
4252
  if (!hasLock) {
@@ -4293,6 +4280,23 @@ const hydrate = async (isLinux, chromeUserDataPath, argv) => {
4293
4280
  await handleReady(parsedCliArgs, cwd());
4294
4281
  };
4295
4282
 
4283
+ const configure = ({
4284
+ crashDumpsPath,
4285
+ logsPath,
4286
+ sessionDataPath,
4287
+ userDataPath
4288
+ }) => {
4289
+ for (const path of [crashDumpsPath, logsPath, sessionDataPath, userDataPath]) {
4290
+ mkdirSync(path, {
4291
+ recursive: true
4292
+ });
4293
+ }
4294
+ app.setPath('userData', userDataPath);
4295
+ app.setPath('sessionData', sessionDataPath);
4296
+ app.setPath('crashDumps', crashDumpsPath);
4297
+ app.setPath('logs', logsPath);
4298
+ };
4299
+
4296
4300
  const {
4297
4301
  argv
4298
4302
  } = process;
@@ -5153,9 +5157,21 @@ const createMessagePort = async (ipcId, port, webContentsId) => {
5153
5157
  return webContentsId;
5154
5158
  };
5155
5159
 
5160
+ const getWebContentsViewName = url => {
5161
+ if (URL.canParse(url)) {
5162
+ const {
5163
+ hostname
5164
+ } = new URL(url);
5165
+ if (hostname) {
5166
+ return `renderer (webcontentsview, ${hostname})`;
5167
+ }
5168
+ }
5169
+ return 'renderer (webcontentsview)';
5170
+ };
5156
5171
  const createPidMap = () => {
5157
5172
  const browserWindows = BrowserWindow.getAllWindows();
5158
- const utilityProcesses = getAll();
5173
+ const webContentsViews = getAll();
5174
+ const utilityProcesses = getAll$1();
5159
5175
  const pidWindowMap = Object.create(null);
5160
5176
  for (const browserWindow of browserWindows) {
5161
5177
  const {
@@ -5170,13 +5186,13 @@ const createPidMap = () => {
5170
5186
  const pid = devToolsWebContents.getOSProcessId();
5171
5187
  pidWindowMap[pid] = 'chrome-devtools';
5172
5188
  }
5173
- const views = browserWindow.getBrowserViews(); // TODO use webcontents views
5174
- for (const view of views) {
5175
- const viewWebContents = view.webContents;
5176
- const pid = viewWebContents.getOSProcessId();
5177
- const displayName = `browser-view-${viewWebContents.id}`;
5178
- pidWindowMap[pid] = displayName;
5179
- }
5189
+ }
5190
+ for (const value of webContentsViews) {
5191
+ const {
5192
+ webContents
5193
+ } = value.view;
5194
+ const pid = webContents.getOSProcessId();
5195
+ pidWindowMap[pid] = getWebContentsViewName(webContents.getURL());
5180
5196
  }
5181
5197
  for (const [pid, value] of utilityProcesses) {
5182
5198
  // @ts-ignore
@@ -7600,6 +7616,14 @@ const setStackTraceLimit = value => {
7600
7616
  // @ts-ignore
7601
7617
  performance.mark('code/start');
7602
7618
  const main = async () => {
7619
+ if (isLinux) {
7620
+ configure({
7621
+ crashDumpsPath: crashDumpsPath,
7622
+ logsPath: logsDir,
7623
+ sessionDataPath: electronSessionDataPath,
7624
+ userDataPath: electronUserDataPath
7625
+ });
7626
+ }
7603
7627
  const configArguments = await load(getArgvConfigPath());
7604
7628
  prepend(configArguments);
7605
7629
  Object.assign(commandMapRef, commandMap);
@@ -7607,7 +7631,7 @@ const main = async () => {
7607
7631
  on$1('uncaughtExceptionMonitor', handleUncaughtExceptionMonitor);
7608
7632
  // workaround for https://github.com/electron/electron/issues/36526
7609
7633
  on$1('unhandledRejection', handleUnhandledRejection);
7610
- await hydrate(isLinux, chromeUserDataPath, argv);
7634
+ await hydrate(argv);
7611
7635
  };
7612
7636
 
7613
7637
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.30.0",
3
+ "version": "6.31.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"