@lvce-editor/process-explorer-worker 3.2.0 → 3.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.
Files changed (2) hide show
  1. package/index.js +382 -290
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -119,7 +119,7 @@ const terminate = () => {
119
119
  globalThis.close();
120
120
  };
121
121
 
122
- const None$1 = 0;
122
+ const None$2 = 0;
123
123
  const Collapsed = 1;
124
124
  const Expanded = 2;
125
125
 
@@ -144,7 +144,7 @@ const getChildren = (processes, collapsedPids, process, depth) => {
144
144
  };
145
145
  const withChildren = (processes, collapsedPids, process, depth) => {
146
146
  const processHasChildren = hasChildren(processes, process.pid);
147
- let flags = None$1;
147
+ let flags = None$2;
148
148
  if (processHasChildren && collapsedPids.includes(process.pid)) {
149
149
  flags = Collapsed;
150
150
  } else if (processHasChildren) {
@@ -181,11 +181,14 @@ const collapseAll = state => {
181
181
  };
182
182
 
183
183
  const {
184
+ dispose: dispose$3,
184
185
  get: get$2,
185
186
  getCommandIds,
187
+ getKeys,
186
188
  registerCommands,
187
189
  set: set$9,
188
190
  wrapCommand,
191
+ wrapGetter,
189
192
  wrapLoadContent
190
193
  } = create$e();
191
194
 
@@ -215,264 +218,6 @@ const create$d = (id, _uri, x, y, width, height, _args, parentUid, platform = 0,
215
218
  return state;
216
219
  };
217
220
 
218
- const isEqual$1 = (oldState, newState) => {
219
- return oldState.focused === newState.focused && oldState.focusedIndex === newState.focusedIndex;
220
- };
221
-
222
- const isEqual = (oldState, newState) => {
223
- return oldState.initial === newState.initial && oldState.errorCodeFrame === newState.errorCodeFrame && oldState.errorMessage === newState.errorMessage && oldState.errorStack === newState.errorStack && oldState.visibleProcesses === newState.visibleProcesses;
224
- };
225
-
226
- const RenderItems = 1;
227
- const RenderFocus = 2;
228
- const RenderFocusContext = 3;
229
-
230
- const modules = [isEqual, isEqual$1, isEqual$1];
231
- const numbers = [RenderItems, RenderFocus, RenderFocusContext];
232
-
233
- const diff = (oldState, newState) => {
234
- const diffResult = [];
235
- for (let i = 0; i < modules.length; i++) {
236
- const fn = modules[i];
237
- if (!fn(oldState, newState)) {
238
- diffResult.push(numbers[i]);
239
- }
240
- }
241
- return diffResult;
242
- };
243
-
244
- const diff2 = uid => {
245
- const {
246
- oldState,
247
- scheduledState
248
- } = get$2(uid);
249
- return diff(oldState, scheduledState);
250
- };
251
-
252
- const expandAll = state => {
253
- const collapsedPids = [];
254
- const visibleProcesses = getVisibleProcesses(state.processes, collapsedPids, state.rootPid);
255
- return {
256
- ...state,
257
- collapsedPids,
258
- visibleProcesses
259
- };
260
- };
261
-
262
- const focusIndex = (state, index) => {
263
- if (index < -1 || index >= state.visibleProcesses.length) {
264
- return state;
265
- }
266
- return {
267
- ...state,
268
- focusedIndex: index
269
- };
270
- };
271
-
272
- const focusFirst = state => {
273
- if (state.visibleProcesses.length === 0) {
274
- return state;
275
- }
276
- return focusIndex(state, 0);
277
- };
278
-
279
- const focusLast = state => {
280
- if (state.visibleProcesses.length === 0) {
281
- return state;
282
- }
283
- return focusIndex(state, state.visibleProcesses.length - 1);
284
- };
285
-
286
- const focusNext = state => {
287
- if (state.focusedIndex >= state.visibleProcesses.length - 1) {
288
- return state;
289
- }
290
- return focusIndex(state, state.focusedIndex + 1);
291
- };
292
-
293
- const focusPrevious = state => {
294
- if (state.focusedIndex === -1 && state.visibleProcesses.length > 0) {
295
- return focusIndex(state, state.visibleProcesses.length - 1);
296
- }
297
- if (state.focusedIndex <= 0) {
298
- return state;
299
- }
300
- return focusIndex(state, state.focusedIndex - 1);
301
- };
302
-
303
- const Div = 4;
304
- const Table$1 = 9;
305
- const TBody = 10;
306
- const Td = 11;
307
- const Text = 12;
308
- const Th = 13;
309
- const THead = 14;
310
- const Tr = 15;
311
- const Pre = 51;
312
-
313
- const ClientX = 'event.clientX';
314
- const ClientY = 'event.clientY';
315
- const TargetName = 'event.target.name';
316
-
317
- const Enter = 3;
318
- const Space = 9;
319
- const End = 255;
320
- const Home = 12;
321
- const LeftArrow = 13;
322
- const UpArrow = 14;
323
- const RightArrow = 15;
324
- const DownArrow = 16;
325
- const ContextMenu = 56;
326
- const Star = 131;
327
-
328
- const Script = 2;
329
-
330
- const CtrlCmd = 1 << 11 >>> 0;
331
-
332
- const Electron = 2;
333
- const Remote = 3;
334
-
335
- const DebugWorker = 55;
336
- const EditorWorker = 99;
337
- const ErrorWorker = 3308;
338
- const FileSystemWorker$1 = 209;
339
- const IconThemeWorker = 7009;
340
- const OpenerWorker = 4561;
341
- const RendererWorker$1 = 1;
342
- const TestWorker = 9001;
343
-
344
- const FocusSelector = 'Viewlet.focusSelector';
345
- const SetDom2 = 'Viewlet.setDom2';
346
- const SetFocusContext = 'Viewlet.setFocusContext';
347
-
348
- const Empty = 0;
349
- const FocusExplorer = 13;
350
-
351
- const getKeyBindings$1 = () => {
352
- return [{
353
- command: 'ProcessExplorer.handleArrowRight',
354
- key: RightArrow,
355
- when: FocusExplorer
356
- }, {
357
- command: 'ProcessExplorer.handleArrowLeft',
358
- key: LeftArrow,
359
- when: FocusExplorer
360
- }, {
361
- command: 'ProcessExplorer.focusFirst',
362
- key: Home,
363
- when: FocusExplorer
364
- }, {
365
- command: 'ProcessExplorer.focusLast',
366
- key: End,
367
- when: FocusExplorer
368
- }, {
369
- command: 'ProcessExplorer.focusPrevious',
370
- key: UpArrow,
371
- when: FocusExplorer
372
- }, {
373
- command: 'ProcessExplorer.focusNext',
374
- key: DownArrow,
375
- when: FocusExplorer
376
- }, {
377
- command: 'ProcessExplorer.collapseAll',
378
- key: CtrlCmd | LeftArrow,
379
- when: FocusExplorer
380
- }, {
381
- command: 'ProcessExplorer.expandAll',
382
- key: CtrlCmd | RightArrow,
383
- when: FocusExplorer
384
- }, {
385
- command: 'ProcessExplorer.expandAll',
386
- key: CtrlCmd | Star,
387
- when: FocusExplorer
388
- }, {
389
- command: 'ProcessExplorer.handleDoubleClick',
390
- key: Enter,
391
- when: FocusExplorer
392
- }, {
393
- command: 'ProcessExplorer.handleDoubleClick',
394
- key: Space,
395
- when: FocusExplorer
396
- }, {
397
- command: 'ProcessExplorer.handleContextMenu',
398
- key: ContextMenu,
399
- when: FocusExplorer
400
- }];
401
- };
402
-
403
- const toggleIndex = (state, index) => {
404
- const process = state.visibleProcesses[index];
405
- if (!process || process.flags === None$1) {
406
- return state;
407
- }
408
- const collapsedPids = state.collapsedPids.includes(process.pid) ? state.collapsedPids.filter(pid => pid !== process.pid) : [...state.collapsedPids, process.pid];
409
- const visibleProcesses = getVisibleProcesses(state.processes, collapsedPids, state.rootPid);
410
- return {
411
- ...state,
412
- collapsedPids,
413
- focusedIndex: Math.min(index, visibleProcesses.length - 1),
414
- visibleProcesses
415
- };
416
- };
417
-
418
- const getParentIndex = state => {
419
- const process = state.visibleProcesses[state.focusedIndex];
420
- if (!process) {
421
- return -1;
422
- }
423
- for (let i = state.focusedIndex - 1; i >= 0; i--) {
424
- const otherProcess = state.visibleProcesses[i];
425
- if (otherProcess.depth === process.depth - 1) {
426
- return i;
427
- }
428
- }
429
- return -1;
430
- };
431
- const handleArrowLeft = state => {
432
- const process = state.visibleProcesses[state.focusedIndex];
433
- if (!process) {
434
- return state;
435
- }
436
- if (process.flags === Expanded) {
437
- return toggleIndex(state, state.focusedIndex);
438
- }
439
- const parentIndex = getParentIndex(state);
440
- if (parentIndex === -1) {
441
- return state;
442
- }
443
- return focusIndex(state, parentIndex);
444
- };
445
-
446
- const handleArrowRight = state => {
447
- const {
448
- focusedIndex,
449
- visibleProcesses
450
- } = state;
451
- const process = visibleProcesses[focusedIndex];
452
- if (!process) {
453
- return state;
454
- }
455
- if (process.flags === Collapsed) {
456
- return toggleIndex(state, focusedIndex);
457
- }
458
- const nextProcess = visibleProcesses[focusedIndex + 1];
459
- if (process.flags === Expanded && nextProcess && nextProcess.depth > process.depth) {
460
- return focusIndex(state, focusedIndex + 1);
461
- }
462
- return state;
463
- };
464
-
465
- const handleBlur = state => {
466
- return {
467
- ...state,
468
- focused: false
469
- };
470
- };
471
-
472
- const handleClickAt = (state, index) => {
473
- return focusIndex(state, index);
474
- };
475
-
476
221
  const normalizeLine = line => {
477
222
  if (line.startsWith('Error: ')) {
478
223
  return line.slice('Error: '.length);
@@ -1717,6 +1462,56 @@ const create = rpcId => {
1717
1462
  };
1718
1463
  };
1719
1464
 
1465
+ const Div = 4;
1466
+ const Table$1 = 9;
1467
+ const TBody = 10;
1468
+ const Td = 11;
1469
+ const Text = 12;
1470
+ const Th = 13;
1471
+ const THead = 14;
1472
+ const Tr = 15;
1473
+ const Pre = 51;
1474
+
1475
+ const ClientX = 'event.clientX';
1476
+ const ClientY = 'event.clientY';
1477
+ const TargetName = 'event.target.name';
1478
+
1479
+ const Enter = 3;
1480
+ const Space = 9;
1481
+ const End = 255;
1482
+ const Home = 12;
1483
+ const LeftArrow = 13;
1484
+ const UpArrow = 14;
1485
+ const RightArrow = 15;
1486
+ const DownArrow = 16;
1487
+ const ContextMenu = 56;
1488
+ const Star = 131;
1489
+
1490
+ const Script = 2;
1491
+
1492
+ const CtrlCmd = 1 << 11 >>> 0;
1493
+
1494
+ const None$1 = 0;
1495
+
1496
+ const Electron = 2;
1497
+ const Remote = 3;
1498
+
1499
+ const DebugWorker = 55;
1500
+ const EditorWorker = 99;
1501
+ const ErrorWorker = 3308;
1502
+ const FileSystemWorker$1 = 209;
1503
+ const IconThemeWorker = 7009;
1504
+ const OpenerWorker = 4561;
1505
+ const RendererWorker$1 = 1;
1506
+ const TestWorker = 9001;
1507
+
1508
+ const FocusSelector = 'Viewlet.focusSelector';
1509
+ const SetDom2 = 'Viewlet.setDom2';
1510
+ const SetFocusContext = 'Viewlet.setFocusContext';
1511
+
1512
+ const Empty = 0;
1513
+ const FocusExplorer = 13;
1514
+
1720
1515
  const {
1721
1516
  set: set$7
1722
1517
  } = create(EditorWorker);
@@ -1747,7 +1542,7 @@ const {
1747
1542
  } = create(IconThemeWorker);
1748
1543
 
1749
1544
  const {
1750
- dispose,
1545
+ dispose: dispose$2,
1751
1546
  invoke: invoke$1,
1752
1547
  invokeAndTransfer,
1753
1548
  registerMockRpc,
@@ -1974,7 +1769,7 @@ const confirm = async (message, options) => {
1974
1769
  const getRecentlyOpened = async () => {
1975
1770
  return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1976
1771
  };
1977
- const getKeyBindings = async () => {
1772
+ const getKeyBindings$1 = async () => {
1978
1773
  return invoke$1('KeyBindingsInitial.getKeyBindings');
1979
1774
  };
1980
1775
  const writeClipBoardText = async text => {
@@ -2195,7 +1990,7 @@ const RendererWorker = {
2195
1990
  confirm,
2196
1991
  createViewlet,
2197
1992
  disableExtension,
2198
- dispose,
1993
+ dispose: dispose$2,
2199
1994
  disposeEditor,
2200
1995
  enableExtension,
2201
1996
  getActiveEditorId,
@@ -2214,7 +2009,7 @@ const RendererWorker = {
2214
2009
  getFolderIcon,
2215
2010
  getFolderSize,
2216
2011
  getIcons,
2217
- getKeyBindings,
2012
+ getKeyBindings: getKeyBindings$1,
2218
2013
  getLogsDir,
2219
2014
  getMarkdownDom,
2220
2015
  getNodeVersion,
@@ -2319,52 +2114,328 @@ const RendererWorker = {
2319
2114
  writeFile
2320
2115
  };
2321
2116
 
2117
+ const debugProcess = async (state, index = state.focusedIndex) => {
2118
+ const process = state.visibleProcesses[index];
2119
+ if (!process) {
2120
+ return state;
2121
+ }
2122
+ await invoke$1('AttachDebugger.attachDebugger', process.pid);
2123
+ return state;
2124
+ };
2125
+
2126
+ const isEqual$1 = (oldState, newState) => {
2127
+ return oldState.focused === newState.focused && oldState.focusedIndex === newState.focusedIndex;
2128
+ };
2129
+
2130
+ const isEqual = (oldState, newState) => {
2131
+ return oldState.initial === newState.initial && oldState.errorCodeFrame === newState.errorCodeFrame && oldState.errorMessage === newState.errorMessage && oldState.errorStack === newState.errorStack && oldState.visibleProcesses === newState.visibleProcesses;
2132
+ };
2133
+
2134
+ const RenderItems = 1;
2135
+ const RenderFocus = 2;
2136
+ const RenderFocusContext = 3;
2137
+
2138
+ const modules = [isEqual, isEqual$1, isEqual$1];
2139
+ const numbers = [RenderItems, RenderFocus, RenderFocusContext];
2140
+
2141
+ const diff = (oldState, newState) => {
2142
+ const diffResult = [];
2143
+ for (let i = 0; i < modules.length; i++) {
2144
+ const fn = modules[i];
2145
+ if (!fn(oldState, newState)) {
2146
+ diffResult.push(numbers[i]);
2147
+ }
2148
+ }
2149
+ return diffResult;
2150
+ };
2151
+
2152
+ const diff2 = uid => {
2153
+ const {
2154
+ oldState,
2155
+ scheduledState
2156
+ } = get$2(uid);
2157
+ return diff(oldState, scheduledState);
2158
+ };
2159
+
2160
+ const processExplorerUpdateInterval = 1000;
2161
+
2162
+ const intervals = new Map();
2163
+ const pending = new Set();
2164
+ const dispose$1 = uid => {
2165
+ const interval = intervals.get(uid);
2166
+ if (interval) {
2167
+ clearInterval(interval);
2168
+ intervals.delete(uid);
2169
+ }
2170
+ pending.delete(uid);
2171
+ };
2172
+ const update = async uid => {
2173
+ if (!getKeys().includes(uid)) {
2174
+ dispose$1(uid);
2175
+ return;
2176
+ }
2177
+ if (pending.has(uid)) {
2178
+ return;
2179
+ }
2180
+ pending.add(uid);
2181
+ try {
2182
+ await invoke$1('ProcessExplorer.update');
2183
+ } catch (error) {
2184
+ console.error(error);
2185
+ } finally {
2186
+ pending.delete(uid);
2187
+ }
2188
+ };
2189
+ const start = (uid, interval = processExplorerUpdateInterval) => {
2190
+ if (interval === 0 || intervals.has(uid)) {
2191
+ return;
2192
+ }
2193
+ const intervalId = setInterval(() => {
2194
+ void update(uid);
2195
+ }, interval);
2196
+ intervals.set(uid, intervalId);
2197
+ };
2198
+
2199
+ const dispose = uid => {
2200
+ dispose$1(uid);
2201
+ dispose$3(uid);
2202
+ };
2203
+
2204
+ const expandAll = state => {
2205
+ const collapsedPids = [];
2206
+ const visibleProcesses = getVisibleProcesses(state.processes, collapsedPids, state.rootPid);
2207
+ return {
2208
+ ...state,
2209
+ collapsedPids,
2210
+ visibleProcesses
2211
+ };
2212
+ };
2213
+
2214
+ const focusIndex = (state, index) => {
2215
+ if (index < -1 || index >= state.visibleProcesses.length) {
2216
+ return state;
2217
+ }
2218
+ return {
2219
+ ...state,
2220
+ focusedIndex: index
2221
+ };
2222
+ };
2223
+
2224
+ const focusFirst = state => {
2225
+ if (state.visibleProcesses.length === 0) {
2226
+ return state;
2227
+ }
2228
+ return focusIndex(state, 0);
2229
+ };
2230
+
2231
+ const focusLast = state => {
2232
+ if (state.visibleProcesses.length === 0) {
2233
+ return state;
2234
+ }
2235
+ return focusIndex(state, state.visibleProcesses.length - 1);
2236
+ };
2237
+
2238
+ const focusNext = state => {
2239
+ if (state.focusedIndex >= state.visibleProcesses.length - 1) {
2240
+ return state;
2241
+ }
2242
+ return focusIndex(state, state.focusedIndex + 1);
2243
+ };
2244
+
2245
+ const focusPrevious = state => {
2246
+ if (state.focusedIndex === -1 && state.visibleProcesses.length > 0) {
2247
+ return focusIndex(state, state.visibleProcesses.length - 1);
2248
+ }
2249
+ if (state.focusedIndex <= 0) {
2250
+ return state;
2251
+ }
2252
+ return focusIndex(state, state.focusedIndex - 1);
2253
+ };
2254
+
2255
+ const getKeyBindings = () => {
2256
+ return [{
2257
+ command: 'ProcessExplorer.handleArrowRight',
2258
+ key: RightArrow,
2259
+ when: FocusExplorer
2260
+ }, {
2261
+ command: 'ProcessExplorer.handleArrowLeft',
2262
+ key: LeftArrow,
2263
+ when: FocusExplorer
2264
+ }, {
2265
+ command: 'ProcessExplorer.focusFirst',
2266
+ key: Home,
2267
+ when: FocusExplorer
2268
+ }, {
2269
+ command: 'ProcessExplorer.focusLast',
2270
+ key: End,
2271
+ when: FocusExplorer
2272
+ }, {
2273
+ command: 'ProcessExplorer.focusPrevious',
2274
+ key: UpArrow,
2275
+ when: FocusExplorer
2276
+ }, {
2277
+ command: 'ProcessExplorer.focusNext',
2278
+ key: DownArrow,
2279
+ when: FocusExplorer
2280
+ }, {
2281
+ command: 'ProcessExplorer.collapseAll',
2282
+ key: CtrlCmd | LeftArrow,
2283
+ when: FocusExplorer
2284
+ }, {
2285
+ command: 'ProcessExplorer.expandAll',
2286
+ key: CtrlCmd | RightArrow,
2287
+ when: FocusExplorer
2288
+ }, {
2289
+ command: 'ProcessExplorer.expandAll',
2290
+ key: CtrlCmd | Star,
2291
+ when: FocusExplorer
2292
+ }, {
2293
+ command: 'ProcessExplorer.handleDoubleClick',
2294
+ key: Enter,
2295
+ when: FocusExplorer
2296
+ }, {
2297
+ command: 'ProcessExplorer.handleDoubleClick',
2298
+ key: Space,
2299
+ when: FocusExplorer
2300
+ }, {
2301
+ command: 'ProcessExplorer.handleContextMenu',
2302
+ key: ContextMenu,
2303
+ when: FocusExplorer
2304
+ }];
2305
+ };
2306
+
2322
2307
  const isDebuggable = command => {
2323
2308
  return command.includes('node ') || command.includes('node.exe') || command.includes('node.mojom.NodeService');
2324
2309
  };
2325
2310
 
2326
2311
  const KillProcess = 'Kill Process';
2327
2312
  const DebugProcess = 'Debug Process';
2328
- const getMenuItems = process => {
2329
- const menuItems = [{
2313
+
2314
+ const getMenuEntries = state => {
2315
+ const process = state.visibleProcesses[state.focusedIndex];
2316
+ if (!process) {
2317
+ return [];
2318
+ }
2319
+ const menuEntries = [{
2320
+ args: [state.focusedIndex],
2321
+ command: 'ProcessExplorer.killProcess',
2322
+ flags: None$1,
2323
+ id: 'killProcess',
2330
2324
  label: KillProcess
2331
2325
  }];
2332
2326
  if (isDebuggable(process.cmd)) {
2333
- menuItems.push({
2327
+ menuEntries.push({
2328
+ args: [state.focusedIndex],
2329
+ command: 'ProcessExplorer.debugProcess',
2330
+ flags: None$1,
2331
+ id: 'debugProcess',
2334
2332
  label: DebugProcess
2335
2333
  });
2336
2334
  }
2337
- return menuItems;
2335
+ return menuEntries;
2338
2336
  };
2339
2337
 
2340
- const SigTerm = 'SIGTERM';
2338
+ const ProcessExplorer$1 = 29;
2341
2339
 
2342
- const handleContextMenuSelect = async (label, process) => {
2343
- switch (label) {
2344
- case DebugProcess:
2345
- await invoke$1('AttachDebugger.attachDebugger', process.pid);
2346
- return;
2347
- case KillProcess:
2348
- await invoke$1('Process.kill', process.pid, SigTerm);
2349
- return;
2350
- default:
2351
- return;
2352
- }
2340
+ const getMenuEntryIds = () => {
2341
+ return [ProcessExplorer$1];
2353
2342
  };
2354
- const handleContextMenu = async (state, index = state.focusedIndex, x = 0, y = 0) => {
2343
+
2344
+ const toggleIndex = (state, index) => {
2355
2345
  const process = state.visibleProcesses[index];
2346
+ if (!process || process.flags === None$2) {
2347
+ return state;
2348
+ }
2349
+ const collapsedPids = state.collapsedPids.includes(process.pid) ? state.collapsedPids.filter(pid => pid !== process.pid) : [...state.collapsedPids, process.pid];
2350
+ const visibleProcesses = getVisibleProcesses(state.processes, collapsedPids, state.rootPid);
2351
+ return {
2352
+ ...state,
2353
+ collapsedPids,
2354
+ focusedIndex: Math.min(index, visibleProcesses.length - 1),
2355
+ visibleProcesses
2356
+ };
2357
+ };
2358
+
2359
+ const getParentIndex = state => {
2360
+ const process = state.visibleProcesses[state.focusedIndex];
2361
+ if (!process) {
2362
+ return -1;
2363
+ }
2364
+ for (let i = state.focusedIndex - 1; i >= 0; i--) {
2365
+ const otherProcess = state.visibleProcesses[i];
2366
+ if (otherProcess.depth === process.depth - 1) {
2367
+ return i;
2368
+ }
2369
+ }
2370
+ return -1;
2371
+ };
2372
+ const handleArrowLeft = state => {
2373
+ const process = state.visibleProcesses[state.focusedIndex];
2356
2374
  if (!process) {
2357
2375
  return state;
2358
2376
  }
2359
- const menuItems = getMenuItems(process);
2360
- const event = await invoke$1('ElectronContextMenu.openContextMenu', menuItems, x, y, process);
2361
- if (event.type === 'close' || !event.data) {
2377
+ if (process.flags === Expanded) {
2378
+ return toggleIndex(state, state.focusedIndex);
2379
+ }
2380
+ const parentIndex = getParentIndex(state);
2381
+ if (parentIndex === -1) {
2382
+ return state;
2383
+ }
2384
+ return focusIndex(state, parentIndex);
2385
+ };
2386
+
2387
+ const handleArrowRight = state => {
2388
+ const {
2389
+ focusedIndex,
2390
+ visibleProcesses
2391
+ } = state;
2392
+ const process = visibleProcesses[focusedIndex];
2393
+ if (!process) {
2362
2394
  return state;
2363
2395
  }
2364
- await handleContextMenuSelect(event.data, process);
2396
+ if (process.flags === Collapsed) {
2397
+ return toggleIndex(state, focusedIndex);
2398
+ }
2399
+ const nextProcess = visibleProcesses[focusedIndex + 1];
2400
+ if (process.flags === Expanded && nextProcess && nextProcess.depth > process.depth) {
2401
+ return focusIndex(state, focusedIndex + 1);
2402
+ }
2365
2403
  return state;
2366
2404
  };
2367
2405
 
2406
+ const handleBlur = state => {
2407
+ return {
2408
+ ...state,
2409
+ focused: false
2410
+ };
2411
+ };
2412
+
2413
+ const handleClickAt = (state, index) => {
2414
+ return focusIndex(state, index);
2415
+ };
2416
+
2417
+ const show2 = async (uid, menuId, x, y, args) => {
2418
+ await showContextMenu2(uid, menuId, x, y, args);
2419
+ };
2420
+
2421
+ const handleContextMenu = async (state, index = state.focusedIndex, x = 0, y = 0) => {
2422
+ const process = state.visibleProcesses[index];
2423
+ if (!process) {
2424
+ return state;
2425
+ }
2426
+ const newState = {
2427
+ ...state,
2428
+ focused: false,
2429
+ focusedIndex: index
2430
+ };
2431
+ set$9(state.uid, state, newState);
2432
+ await show2(state.uid, ProcessExplorer$1, x, y, {
2433
+ index,
2434
+ menuId: ProcessExplorer$1
2435
+ });
2436
+ return newState;
2437
+ };
2438
+
2368
2439
  const handleDoubleClick = (state, index = state.focusedIndex) => {
2369
2440
  return toggleIndex(state, index);
2370
2441
  };
@@ -2376,6 +2447,17 @@ const handleFocus = state => {
2376
2447
  };
2377
2448
  };
2378
2449
 
2450
+ const SigTerm = 'SIGTERM';
2451
+
2452
+ const killProcess = async (state, index = state.focusedIndex) => {
2453
+ const process = state.visibleProcesses[index];
2454
+ if (!process) {
2455
+ return state;
2456
+ }
2457
+ await invoke$1('Process.kill', process.pid, SigTerm);
2458
+ return state;
2459
+ };
2460
+
2379
2461
  const sendMessagePortToProcessExplorer = async port => {
2380
2462
  const rendererWorker = RendererWorker;
2381
2463
  await rendererWorker.sendMessagePortToProcessExplorer(port);
@@ -2467,8 +2549,11 @@ const getFocusedIndex = (oldFocusedIndex, visibleProcesses) => {
2467
2549
  const refresh = async state => {
2468
2550
  try {
2469
2551
  await initializeProcessExplorer(state.platform);
2470
- const rootPid = state.rootPid || (await invoke('ProcessId.getMainProcessId'));
2471
- const processes = await invoke('ListProcessesWithMemoryUsage.listProcessesWithMemoryUsage', rootPid);
2552
+ const includeElectronData = state.platform === Electron;
2553
+ const rootPid = state.rootPid || (await invoke('ProcessId.getMainProcessId', {
2554
+ includeElectronData
2555
+ }));
2556
+ const processes = await invoke('ListProcessesWithMemoryUsage.listProcessesWithMemoryUsage', rootPid, includeElectronData);
2472
2557
  const visibleProcesses = getVisibleProcesses(processes, state.collapsedPids, rootPid);
2473
2558
  return {
2474
2559
  ...state,
@@ -2495,6 +2580,7 @@ const refresh = async state => {
2495
2580
 
2496
2581
  const loadContent = async state => {
2497
2582
  const newState = await refresh(state);
2583
+ start(state.uid);
2498
2584
  return {
2499
2585
  error: undefined,
2500
2586
  state: newState
@@ -2578,7 +2664,7 @@ const getPaddingLeft = process => {
2578
2664
  return '0';
2579
2665
  }
2580
2666
  const depthCh = (process.depth - 1) * 1.5;
2581
- if (process.flags === None$1) {
2667
+ if (process.flags === None$2) {
2582
2668
  return `calc(${depthCh}ch + 17px)`;
2583
2669
  }
2584
2670
  return `${depthCh}ch`;
@@ -2773,14 +2859,18 @@ const renderEventListeners = () => {
2773
2859
  const commandMap = {
2774
2860
  'ProcessExplorer.collapseAll': wrapCommand(collapseAll),
2775
2861
  'ProcessExplorer.create': create$d,
2862
+ 'ProcessExplorer.debugProcess': wrapCommand(debugProcess),
2776
2863
  'ProcessExplorer.diff2': diff2,
2864
+ 'ProcessExplorer.dispose': dispose,
2777
2865
  'ProcessExplorer.expandAll': wrapCommand(expandAll),
2778
2866
  'ProcessExplorer.focusFirst': wrapCommand(focusFirst),
2779
2867
  'ProcessExplorer.focusLast': wrapCommand(focusLast),
2780
2868
  'ProcessExplorer.focusNext': wrapCommand(focusNext),
2781
2869
  'ProcessExplorer.focusPrevious': wrapCommand(focusPrevious),
2782
2870
  'ProcessExplorer.getCommandIds': getCommandIds,
2783
- 'ProcessExplorer.getKeyBindings': getKeyBindings$1,
2871
+ 'ProcessExplorer.getKeyBindings': getKeyBindings,
2872
+ 'ProcessExplorer.getMenuEntries': wrapGetter(getMenuEntries),
2873
+ 'ProcessExplorer.getMenuEntryIds': getMenuEntryIds,
2784
2874
  'ProcessExplorer.handleArrowLeft': wrapCommand(handleArrowLeft),
2785
2875
  'ProcessExplorer.handleArrowRight': wrapCommand(handleArrowRight),
2786
2876
  'ProcessExplorer.handleBlur': wrapCommand(handleBlur),
@@ -2788,11 +2878,13 @@ const commandMap = {
2788
2878
  'ProcessExplorer.handleContextMenu': wrapCommand(handleContextMenu),
2789
2879
  'ProcessExplorer.handleDoubleClick': wrapCommand(handleDoubleClick),
2790
2880
  'ProcessExplorer.handleFocus': wrapCommand(handleFocus),
2881
+ 'ProcessExplorer.killProcess': wrapCommand(killProcess),
2791
2882
  'ProcessExplorer.loadContent': wrapLoadContent(loadContent),
2792
2883
  'ProcessExplorer.refresh': wrapCommand(refresh),
2793
2884
  'ProcessExplorer.render2': render2,
2794
2885
  'ProcessExplorer.renderEventListeners': renderEventListeners,
2795
- 'ProcessExplorer.terminate': terminate
2886
+ 'ProcessExplorer.terminate': terminate,
2887
+ 'ProcessExplorer.update': wrapCommand(refresh)
2796
2888
  };
2797
2889
 
2798
2890
  const sendMessagePortToErrorWorker = async port => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/process-explorer-worker",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",