@lvce-editor/main-process 6.30.1 → 6.32.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.
package/README.md CHANGED
@@ -15,3 +15,11 @@ npx electron --wait src/profile.js
15
15
  ```
16
16
 
17
17
  This will create a `profile.cpuprofile` file, which can be loaded inside the chrome devtools performance panel.
18
+
19
+ ## Benchmarking application startup
20
+
21
+ Use `--wait-10-seconds` to keep the application attached to the terminal and quit it after 10 seconds:
22
+
23
+ ```sh
24
+ time lvce --wait-10-seconds
25
+ ```
@@ -3443,7 +3443,7 @@ const remove$1 = pid => {
3443
3443
  number(pid);
3444
3444
  delete state$5.all[pid];
3445
3445
  };
3446
- const getAll = () => {
3446
+ const getAll$1 = () => {
3447
3447
  return Object.entries(state$5.all);
3448
3448
  };
3449
3449
  const getByName = name => {
@@ -3680,6 +3680,7 @@ const isPackagedDeb = () => {
3680
3680
  const Version = 'version';
3681
3681
  const Help = 'help';
3682
3682
  const Wait = 'wait';
3683
+ const Wait10Seconds = 'wait-10-seconds';
3683
3684
  const BuiltinSelfTest = 'built-in-self-test';
3684
3685
  const Web = 'web';
3685
3686
  const SandBox = 'sandbox';
@@ -4044,7 +4045,7 @@ const parseCliArgs = argv => {
4044
4045
  alias: {
4045
4046
  version: 'v'
4046
4047
  },
4047
- boolean: [Version, Help, Wait, BuiltinSelfTest, Web, SandBox],
4048
+ boolean: [Version, Help, Wait, Wait10Seconds, BuiltinSelfTest, Web, SandBox],
4048
4049
  default: {
4049
4050
  sandbox: true
4050
4051
  },
@@ -4117,6 +4118,9 @@ const hasWebContents = id => {
4117
4118
  const get$3 = id => {
4118
4119
  return state$2.views[id];
4119
4120
  };
4121
+ const getAll = () => {
4122
+ return Object.values(state$2.views);
4123
+ };
4120
4124
  const remove = id => {
4121
4125
  delete state$2.views[id];
4122
4126
  };
@@ -4215,6 +4219,15 @@ const requestSingleInstanceLock = argv => {
4215
4219
  return app.requestSingleInstanceLock(argv);
4216
4220
  };
4217
4221
 
4222
+ const exitDelay = 10_000;
4223
+ const schedule = parsedCliArgs => {
4224
+ if (!parsedCliArgs[Wait10Seconds]) {
4225
+ return false;
4226
+ }
4227
+ setTimeout(exit, exitDelay);
4228
+ return true;
4229
+ };
4230
+
4218
4231
  // TODO maybe handle critical (first render) request via ipcMain
4219
4232
  // and spawn shared process when page is idle/loaded
4220
4233
  // currently launching shared process takes 170ms
@@ -4251,9 +4264,10 @@ const hydrate = async argv => {
4251
4264
  return;
4252
4265
  }
4253
4266
  }
4267
+ const hasTimedExit = schedule(parsedCliArgs);
4254
4268
 
4255
4269
  // TODO tree shake out the .env.DEV check: reading from env variables is expensive
4256
- if (process.stdout.isTTY && !parsedCliArgs.wait && !isPromptMode$1 && !process.env.DEV) {
4270
+ if (process.stdout.isTTY && !parsedCliArgs.wait && !hasTimedExit && !isPromptMode$1 && !process.env.DEV) {
4257
4271
  spawn(execPath, argv.slice(1), {
4258
4272
  detached: true,
4259
4273
  stdio: 'ignore'
@@ -5154,9 +5168,21 @@ const createMessagePort = async (ipcId, port, webContentsId) => {
5154
5168
  return webContentsId;
5155
5169
  };
5156
5170
 
5171
+ const getWebContentsViewName = url => {
5172
+ if (URL.canParse(url)) {
5173
+ const {
5174
+ hostname
5175
+ } = new URL(url);
5176
+ if (hostname) {
5177
+ return `renderer (webcontentsview, ${hostname})`;
5178
+ }
5179
+ }
5180
+ return 'renderer (webcontentsview)';
5181
+ };
5157
5182
  const createPidMap = () => {
5158
5183
  const browserWindows = BrowserWindow.getAllWindows();
5159
- const utilityProcesses = getAll();
5184
+ const webContentsViews = getAll();
5185
+ const utilityProcesses = getAll$1();
5160
5186
  const pidWindowMap = Object.create(null);
5161
5187
  for (const browserWindow of browserWindows) {
5162
5188
  const {
@@ -5171,13 +5197,13 @@ const createPidMap = () => {
5171
5197
  const pid = devToolsWebContents.getOSProcessId();
5172
5198
  pidWindowMap[pid] = 'chrome-devtools';
5173
5199
  }
5174
- const views = browserWindow.getBrowserViews(); // TODO use webcontents views
5175
- for (const view of views) {
5176
- const viewWebContents = view.webContents;
5177
- const pid = viewWebContents.getOSProcessId();
5178
- const displayName = `browser-view-${viewWebContents.id}`;
5179
- pidWindowMap[pid] = displayName;
5180
- }
5200
+ }
5201
+ for (const value of webContentsViews) {
5202
+ const {
5203
+ webContents
5204
+ } = value.view;
5205
+ const pid = webContents.getOSProcessId();
5206
+ pidWindowMap[pid] = getWebContentsViewName(webContents.getURL());
5181
5207
  }
5182
5208
  for (const [pid, value] of utilityProcesses) {
5183
5209
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.30.1",
3
+ "version": "6.32.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"