@lvce-editor/process-explorer-worker 3.3.0 → 3.5.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/index.js +746 -292
- 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$
|
|
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$
|
|
147
|
+
let flags = None$2;
|
|
148
148
|
if (processHasChildren && collapsedPids.includes(process.pid)) {
|
|
149
149
|
flags = Collapsed;
|
|
150
150
|
} else if (processHasChildren) {
|
|
@@ -181,15 +181,25 @@ const collapseAll = state => {
|
|
|
181
181
|
};
|
|
182
182
|
|
|
183
183
|
const {
|
|
184
|
+
dispose: dispose$3,
|
|
184
185
|
get: get$2,
|
|
185
186
|
getCommandIds,
|
|
187
|
+
getKeys: getKeys$1,
|
|
186
188
|
registerCommands,
|
|
187
189
|
set: set$9,
|
|
188
190
|
wrapCommand,
|
|
191
|
+
wrapGetter,
|
|
189
192
|
wrapLoadContent
|
|
190
193
|
} = create$e();
|
|
191
194
|
|
|
192
|
-
const
|
|
195
|
+
const getIncludeFrontendMemoryUsage = args => {
|
|
196
|
+
if (!args || typeof args !== 'object') {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
const createArgs = args;
|
|
200
|
+
return createArgs.includeFrontendMemoryUsage === true;
|
|
201
|
+
};
|
|
202
|
+
const create$d = (id, _uri, x, y, width, height, args, parentUid, platform = 0, assetDir = '') => {
|
|
193
203
|
const state = {
|
|
194
204
|
assetDir,
|
|
195
205
|
collapsedPids: [],
|
|
@@ -200,6 +210,7 @@ const create$d = (id, _uri, x, y, width, height, _args, parentUid, platform = 0,
|
|
|
200
210
|
focused: false,
|
|
201
211
|
focusedIndex: -1,
|
|
202
212
|
height,
|
|
213
|
+
includeFrontendMemoryUsage: getIncludeFrontendMemoryUsage(args),
|
|
203
214
|
initial: true,
|
|
204
215
|
parentUid,
|
|
205
216
|
platform,
|
|
@@ -215,264 +226,6 @@ const create$d = (id, _uri, x, y, width, height, _args, parentUid, platform = 0,
|
|
|
215
226
|
return state;
|
|
216
227
|
};
|
|
217
228
|
|
|
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
229
|
const normalizeLine = line => {
|
|
477
230
|
if (line.startsWith('Error: ')) {
|
|
478
231
|
return line.slice('Error: '.length);
|
|
@@ -1717,6 +1470,58 @@ const create = rpcId => {
|
|
|
1717
1470
|
};
|
|
1718
1471
|
};
|
|
1719
1472
|
|
|
1473
|
+
const Div = 4;
|
|
1474
|
+
const Table$1 = 9;
|
|
1475
|
+
const TBody = 10;
|
|
1476
|
+
const Td = 11;
|
|
1477
|
+
const Text = 12;
|
|
1478
|
+
const Th = 13;
|
|
1479
|
+
const THead = 14;
|
|
1480
|
+
const Tr = 15;
|
|
1481
|
+
const Pre = 51;
|
|
1482
|
+
const Reference = 100;
|
|
1483
|
+
|
|
1484
|
+
const ClientX = 'event.clientX';
|
|
1485
|
+
const ClientY = 'event.clientY';
|
|
1486
|
+
const TargetName = 'event.target.name';
|
|
1487
|
+
|
|
1488
|
+
const Enter = 3;
|
|
1489
|
+
const Space = 9;
|
|
1490
|
+
const End = 255;
|
|
1491
|
+
const Home = 12;
|
|
1492
|
+
const LeftArrow = 13;
|
|
1493
|
+
const UpArrow = 14;
|
|
1494
|
+
const RightArrow = 15;
|
|
1495
|
+
const DownArrow = 16;
|
|
1496
|
+
const ContextMenu = 56;
|
|
1497
|
+
const Star = 131;
|
|
1498
|
+
|
|
1499
|
+
const Script = 2;
|
|
1500
|
+
|
|
1501
|
+
const CtrlCmd = 1 << 11 >>> 0;
|
|
1502
|
+
|
|
1503
|
+
const None$1 = 0;
|
|
1504
|
+
|
|
1505
|
+
const Electron = 2;
|
|
1506
|
+
const Remote = 3;
|
|
1507
|
+
|
|
1508
|
+
const DebugWorker = 55;
|
|
1509
|
+
const EditorWorker = 99;
|
|
1510
|
+
const ErrorWorker = 3308;
|
|
1511
|
+
const FileSystemWorker$1 = 209;
|
|
1512
|
+
const IconThemeWorker = 7009;
|
|
1513
|
+
const OpenerWorker = 4561;
|
|
1514
|
+
const RendererWorker$1 = 1;
|
|
1515
|
+
const TestWorker = 9001;
|
|
1516
|
+
|
|
1517
|
+
const FocusSelector = 'Viewlet.focusSelector';
|
|
1518
|
+
const SetDom2 = 'Viewlet.setDom2';
|
|
1519
|
+
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1520
|
+
const SetPatches = 'Viewlet.setPatches';
|
|
1521
|
+
|
|
1522
|
+
const Empty = 0;
|
|
1523
|
+
const FocusExplorer = 13;
|
|
1524
|
+
|
|
1720
1525
|
const {
|
|
1721
1526
|
set: set$7
|
|
1722
1527
|
} = create(EditorWorker);
|
|
@@ -1747,7 +1552,7 @@ const {
|
|
|
1747
1552
|
} = create(IconThemeWorker);
|
|
1748
1553
|
|
|
1749
1554
|
const {
|
|
1750
|
-
dispose,
|
|
1555
|
+
dispose: dispose$2,
|
|
1751
1556
|
invoke: invoke$1,
|
|
1752
1557
|
invokeAndTransfer,
|
|
1753
1558
|
registerMockRpc,
|
|
@@ -1974,7 +1779,7 @@ const confirm = async (message, options) => {
|
|
|
1974
1779
|
const getRecentlyOpened = async () => {
|
|
1975
1780
|
return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
|
|
1976
1781
|
};
|
|
1977
|
-
const getKeyBindings = async () => {
|
|
1782
|
+
const getKeyBindings$1 = async () => {
|
|
1978
1783
|
return invoke$1('KeyBindingsInitial.getKeyBindings');
|
|
1979
1784
|
};
|
|
1980
1785
|
const writeClipBoardText = async text => {
|
|
@@ -2195,7 +2000,7 @@ const RendererWorker = {
|
|
|
2195
2000
|
confirm,
|
|
2196
2001
|
createViewlet,
|
|
2197
2002
|
disableExtension,
|
|
2198
|
-
dispose,
|
|
2003
|
+
dispose: dispose$2,
|
|
2199
2004
|
disposeEditor,
|
|
2200
2005
|
enableExtension,
|
|
2201
2006
|
getActiveEditorId,
|
|
@@ -2214,7 +2019,7 @@ const RendererWorker = {
|
|
|
2214
2019
|
getFolderIcon,
|
|
2215
2020
|
getFolderSize,
|
|
2216
2021
|
getIcons,
|
|
2217
|
-
getKeyBindings,
|
|
2022
|
+
getKeyBindings: getKeyBindings$1,
|
|
2218
2023
|
getLogsDir,
|
|
2219
2024
|
getMarkdownDom,
|
|
2220
2025
|
getNodeVersion,
|
|
@@ -2319,52 +2124,329 @@ const RendererWorker = {
|
|
|
2319
2124
|
writeFile
|
|
2320
2125
|
};
|
|
2321
2126
|
|
|
2127
|
+
const debugProcess = async (state, index = state.focusedIndex) => {
|
|
2128
|
+
const process = state.visibleProcesses[index];
|
|
2129
|
+
if (!process) {
|
|
2130
|
+
return state;
|
|
2131
|
+
}
|
|
2132
|
+
await invoke$1('AttachDebugger.attachDebugger', process.pid);
|
|
2133
|
+
return state;
|
|
2134
|
+
};
|
|
2135
|
+
|
|
2136
|
+
const isEqual$1 = (oldState, newState) => {
|
|
2137
|
+
return oldState.focused === newState.focused && oldState.focusedIndex === newState.focusedIndex;
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2140
|
+
const isEqual = (oldState, newState) => {
|
|
2141
|
+
return oldState.initial === newState.initial && oldState.errorCodeFrame === newState.errorCodeFrame && oldState.errorMessage === newState.errorMessage && oldState.errorStack === newState.errorStack && oldState.focusedIndex === newState.focusedIndex && oldState.visibleProcesses === newState.visibleProcesses;
|
|
2142
|
+
};
|
|
2143
|
+
|
|
2144
|
+
const RenderItems = 1;
|
|
2145
|
+
const RenderFocus = 2;
|
|
2146
|
+
const RenderFocusContext = 3;
|
|
2147
|
+
const RenderIncremental = 4;
|
|
2148
|
+
|
|
2149
|
+
const modules = [isEqual, isEqual$1, isEqual$1];
|
|
2150
|
+
const numbers = [RenderIncremental, RenderFocus, RenderFocusContext];
|
|
2151
|
+
|
|
2152
|
+
const diff = (oldState, newState) => {
|
|
2153
|
+
const diffResult = [];
|
|
2154
|
+
for (let i = 0; i < modules.length; i++) {
|
|
2155
|
+
const fn = modules[i];
|
|
2156
|
+
if (!fn(oldState, newState)) {
|
|
2157
|
+
diffResult.push(numbers[i]);
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
return diffResult;
|
|
2161
|
+
};
|
|
2162
|
+
|
|
2163
|
+
const diff2 = uid => {
|
|
2164
|
+
const {
|
|
2165
|
+
oldState,
|
|
2166
|
+
scheduledState
|
|
2167
|
+
} = get$2(uid);
|
|
2168
|
+
return diff(oldState, scheduledState);
|
|
2169
|
+
};
|
|
2170
|
+
|
|
2171
|
+
const processExplorerUpdateInterval = 1000;
|
|
2172
|
+
|
|
2173
|
+
const intervals = new Map();
|
|
2174
|
+
const pending = new Set();
|
|
2175
|
+
const dispose$1 = uid => {
|
|
2176
|
+
const interval = intervals.get(uid);
|
|
2177
|
+
if (interval) {
|
|
2178
|
+
clearInterval(interval);
|
|
2179
|
+
intervals.delete(uid);
|
|
2180
|
+
}
|
|
2181
|
+
pending.delete(uid);
|
|
2182
|
+
};
|
|
2183
|
+
const update = async uid => {
|
|
2184
|
+
if (!getKeys$1().includes(uid)) {
|
|
2185
|
+
dispose$1(uid);
|
|
2186
|
+
return;
|
|
2187
|
+
}
|
|
2188
|
+
if (pending.has(uid)) {
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
pending.add(uid);
|
|
2192
|
+
try {
|
|
2193
|
+
await invoke$1('ProcessExplorer.update');
|
|
2194
|
+
} catch (error) {
|
|
2195
|
+
console.error(error);
|
|
2196
|
+
} finally {
|
|
2197
|
+
pending.delete(uid);
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
const start = (uid, interval = processExplorerUpdateInterval) => {
|
|
2201
|
+
if (interval === 0 || intervals.has(uid)) {
|
|
2202
|
+
return;
|
|
2203
|
+
}
|
|
2204
|
+
const intervalId = setInterval(() => {
|
|
2205
|
+
void update(uid);
|
|
2206
|
+
}, interval);
|
|
2207
|
+
intervals.set(uid, intervalId);
|
|
2208
|
+
};
|
|
2209
|
+
|
|
2210
|
+
const dispose = uid => {
|
|
2211
|
+
dispose$1(uid);
|
|
2212
|
+
dispose$3(uid);
|
|
2213
|
+
};
|
|
2214
|
+
|
|
2215
|
+
const expandAll = state => {
|
|
2216
|
+
const collapsedPids = [];
|
|
2217
|
+
const visibleProcesses = getVisibleProcesses(state.processes, collapsedPids, state.rootPid);
|
|
2218
|
+
return {
|
|
2219
|
+
...state,
|
|
2220
|
+
collapsedPids,
|
|
2221
|
+
visibleProcesses
|
|
2222
|
+
};
|
|
2223
|
+
};
|
|
2224
|
+
|
|
2225
|
+
const focusIndex = (state, index) => {
|
|
2226
|
+
if (index < -1 || index >= state.visibleProcesses.length) {
|
|
2227
|
+
return state;
|
|
2228
|
+
}
|
|
2229
|
+
return {
|
|
2230
|
+
...state,
|
|
2231
|
+
focusedIndex: index
|
|
2232
|
+
};
|
|
2233
|
+
};
|
|
2234
|
+
|
|
2235
|
+
const focusFirst = state => {
|
|
2236
|
+
if (state.visibleProcesses.length === 0) {
|
|
2237
|
+
return state;
|
|
2238
|
+
}
|
|
2239
|
+
return focusIndex(state, 0);
|
|
2240
|
+
};
|
|
2241
|
+
|
|
2242
|
+
const focusLast = state => {
|
|
2243
|
+
if (state.visibleProcesses.length === 0) {
|
|
2244
|
+
return state;
|
|
2245
|
+
}
|
|
2246
|
+
return focusIndex(state, state.visibleProcesses.length - 1);
|
|
2247
|
+
};
|
|
2248
|
+
|
|
2249
|
+
const focusNext = state => {
|
|
2250
|
+
if (state.focusedIndex >= state.visibleProcesses.length - 1) {
|
|
2251
|
+
return state;
|
|
2252
|
+
}
|
|
2253
|
+
return focusIndex(state, state.focusedIndex + 1);
|
|
2254
|
+
};
|
|
2255
|
+
|
|
2256
|
+
const focusPrevious = state => {
|
|
2257
|
+
if (state.focusedIndex === -1 && state.visibleProcesses.length > 0) {
|
|
2258
|
+
return focusIndex(state, state.visibleProcesses.length - 1);
|
|
2259
|
+
}
|
|
2260
|
+
if (state.focusedIndex <= 0) {
|
|
2261
|
+
return state;
|
|
2262
|
+
}
|
|
2263
|
+
return focusIndex(state, state.focusedIndex - 1);
|
|
2264
|
+
};
|
|
2265
|
+
|
|
2266
|
+
const getKeyBindings = () => {
|
|
2267
|
+
return [{
|
|
2268
|
+
command: 'ProcessExplorer.handleArrowRight',
|
|
2269
|
+
key: RightArrow,
|
|
2270
|
+
when: FocusExplorer
|
|
2271
|
+
}, {
|
|
2272
|
+
command: 'ProcessExplorer.handleArrowLeft',
|
|
2273
|
+
key: LeftArrow,
|
|
2274
|
+
when: FocusExplorer
|
|
2275
|
+
}, {
|
|
2276
|
+
command: 'ProcessExplorer.focusFirst',
|
|
2277
|
+
key: Home,
|
|
2278
|
+
when: FocusExplorer
|
|
2279
|
+
}, {
|
|
2280
|
+
command: 'ProcessExplorer.focusLast',
|
|
2281
|
+
key: End,
|
|
2282
|
+
when: FocusExplorer
|
|
2283
|
+
}, {
|
|
2284
|
+
command: 'ProcessExplorer.focusPrevious',
|
|
2285
|
+
key: UpArrow,
|
|
2286
|
+
when: FocusExplorer
|
|
2287
|
+
}, {
|
|
2288
|
+
command: 'ProcessExplorer.focusNext',
|
|
2289
|
+
key: DownArrow,
|
|
2290
|
+
when: FocusExplorer
|
|
2291
|
+
}, {
|
|
2292
|
+
command: 'ProcessExplorer.collapseAll',
|
|
2293
|
+
key: CtrlCmd | LeftArrow,
|
|
2294
|
+
when: FocusExplorer
|
|
2295
|
+
}, {
|
|
2296
|
+
command: 'ProcessExplorer.expandAll',
|
|
2297
|
+
key: CtrlCmd | RightArrow,
|
|
2298
|
+
when: FocusExplorer
|
|
2299
|
+
}, {
|
|
2300
|
+
command: 'ProcessExplorer.expandAll',
|
|
2301
|
+
key: CtrlCmd | Star,
|
|
2302
|
+
when: FocusExplorer
|
|
2303
|
+
}, {
|
|
2304
|
+
command: 'ProcessExplorer.handleDoubleClick',
|
|
2305
|
+
key: Enter,
|
|
2306
|
+
when: FocusExplorer
|
|
2307
|
+
}, {
|
|
2308
|
+
command: 'ProcessExplorer.handleDoubleClick',
|
|
2309
|
+
key: Space,
|
|
2310
|
+
when: FocusExplorer
|
|
2311
|
+
}, {
|
|
2312
|
+
command: 'ProcessExplorer.handleContextMenu',
|
|
2313
|
+
key: ContextMenu,
|
|
2314
|
+
when: FocusExplorer
|
|
2315
|
+
}];
|
|
2316
|
+
};
|
|
2317
|
+
|
|
2322
2318
|
const isDebuggable = command => {
|
|
2323
2319
|
return command.includes('node ') || command.includes('node.exe') || command.includes('node.mojom.NodeService');
|
|
2324
2320
|
};
|
|
2325
2321
|
|
|
2326
2322
|
const KillProcess = 'Kill Process';
|
|
2327
2323
|
const DebugProcess = 'Debug Process';
|
|
2328
|
-
|
|
2329
|
-
|
|
2324
|
+
|
|
2325
|
+
const getMenuEntries = state => {
|
|
2326
|
+
const process = state.visibleProcesses[state.focusedIndex];
|
|
2327
|
+
if (!process) {
|
|
2328
|
+
return [];
|
|
2329
|
+
}
|
|
2330
|
+
const menuEntries = [{
|
|
2331
|
+
args: [state.focusedIndex],
|
|
2332
|
+
command: 'ProcessExplorer.killProcess',
|
|
2333
|
+
flags: None$1,
|
|
2334
|
+
id: 'killProcess',
|
|
2330
2335
|
label: KillProcess
|
|
2331
2336
|
}];
|
|
2332
2337
|
if (isDebuggable(process.cmd)) {
|
|
2333
|
-
|
|
2338
|
+
menuEntries.push({
|
|
2339
|
+
args: [state.focusedIndex],
|
|
2340
|
+
command: 'ProcessExplorer.debugProcess',
|
|
2341
|
+
flags: None$1,
|
|
2342
|
+
id: 'debugProcess',
|
|
2334
2343
|
label: DebugProcess
|
|
2335
2344
|
});
|
|
2336
2345
|
}
|
|
2337
|
-
return
|
|
2346
|
+
return menuEntries;
|
|
2338
2347
|
};
|
|
2339
2348
|
|
|
2340
|
-
const
|
|
2349
|
+
const ProcessExplorer$1 = 29;
|
|
2341
2350
|
|
|
2342
|
-
const
|
|
2343
|
-
|
|
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
|
-
}
|
|
2351
|
+
const getMenuEntryIds = () => {
|
|
2352
|
+
return [ProcessExplorer$1];
|
|
2353
2353
|
};
|
|
2354
|
-
|
|
2354
|
+
|
|
2355
|
+
const toggleIndex = (state, index) => {
|
|
2355
2356
|
const process = state.visibleProcesses[index];
|
|
2357
|
+
if (!process || process.flags === None$2) {
|
|
2358
|
+
return state;
|
|
2359
|
+
}
|
|
2360
|
+
const collapsedPids = state.collapsedPids.includes(process.pid) ? state.collapsedPids.filter(pid => pid !== process.pid) : [...state.collapsedPids, process.pid];
|
|
2361
|
+
const visibleProcesses = getVisibleProcesses(state.processes, collapsedPids, state.rootPid);
|
|
2362
|
+
return {
|
|
2363
|
+
...state,
|
|
2364
|
+
collapsedPids,
|
|
2365
|
+
focusedIndex: Math.min(index, visibleProcesses.length - 1),
|
|
2366
|
+
visibleProcesses
|
|
2367
|
+
};
|
|
2368
|
+
};
|
|
2369
|
+
|
|
2370
|
+
const getParentIndex = state => {
|
|
2371
|
+
const process = state.visibleProcesses[state.focusedIndex];
|
|
2372
|
+
if (!process) {
|
|
2373
|
+
return -1;
|
|
2374
|
+
}
|
|
2375
|
+
for (let i = state.focusedIndex - 1; i >= 0; i--) {
|
|
2376
|
+
const otherProcess = state.visibleProcesses[i];
|
|
2377
|
+
if (otherProcess.depth === process.depth - 1) {
|
|
2378
|
+
return i;
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
return -1;
|
|
2382
|
+
};
|
|
2383
|
+
const handleArrowLeft = state => {
|
|
2384
|
+
const process = state.visibleProcesses[state.focusedIndex];
|
|
2356
2385
|
if (!process) {
|
|
2357
2386
|
return state;
|
|
2358
2387
|
}
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2388
|
+
if (process.flags === Expanded) {
|
|
2389
|
+
return toggleIndex(state, state.focusedIndex);
|
|
2390
|
+
}
|
|
2391
|
+
const parentIndex = getParentIndex(state);
|
|
2392
|
+
if (parentIndex === -1) {
|
|
2393
|
+
return state;
|
|
2394
|
+
}
|
|
2395
|
+
return focusIndex(state, parentIndex);
|
|
2396
|
+
};
|
|
2397
|
+
|
|
2398
|
+
const handleArrowRight = state => {
|
|
2399
|
+
const {
|
|
2400
|
+
focusedIndex,
|
|
2401
|
+
visibleProcesses
|
|
2402
|
+
} = state;
|
|
2403
|
+
const process = visibleProcesses[focusedIndex];
|
|
2404
|
+
if (!process) {
|
|
2362
2405
|
return state;
|
|
2363
2406
|
}
|
|
2364
|
-
|
|
2407
|
+
if (process.flags === Collapsed) {
|
|
2408
|
+
return toggleIndex(state, focusedIndex);
|
|
2409
|
+
}
|
|
2410
|
+
const nextProcess = visibleProcesses[focusedIndex + 1];
|
|
2411
|
+
if (process.flags === Expanded && nextProcess && nextProcess.depth > process.depth) {
|
|
2412
|
+
return focusIndex(state, focusedIndex + 1);
|
|
2413
|
+
}
|
|
2365
2414
|
return state;
|
|
2366
2415
|
};
|
|
2367
2416
|
|
|
2417
|
+
const handleBlur = state => {
|
|
2418
|
+
return {
|
|
2419
|
+
...state,
|
|
2420
|
+
focused: false
|
|
2421
|
+
};
|
|
2422
|
+
};
|
|
2423
|
+
|
|
2424
|
+
const handleClickAt = (state, index) => {
|
|
2425
|
+
return focusIndex(state, index);
|
|
2426
|
+
};
|
|
2427
|
+
|
|
2428
|
+
const show2 = async (uid, menuId, x, y, args) => {
|
|
2429
|
+
await showContextMenu2(uid, menuId, x, y, args);
|
|
2430
|
+
};
|
|
2431
|
+
|
|
2432
|
+
const handleContextMenu = async (state, index = state.focusedIndex, x = 0, y = 0) => {
|
|
2433
|
+
const process = state.visibleProcesses[index];
|
|
2434
|
+
if (!process) {
|
|
2435
|
+
return state;
|
|
2436
|
+
}
|
|
2437
|
+
const newState = {
|
|
2438
|
+
...state,
|
|
2439
|
+
focused: false,
|
|
2440
|
+
focusedIndex: index
|
|
2441
|
+
};
|
|
2442
|
+
set$9(state.uid, state, newState);
|
|
2443
|
+
await show2(state.uid, ProcessExplorer$1, x, y, {
|
|
2444
|
+
index,
|
|
2445
|
+
menuId: ProcessExplorer$1
|
|
2446
|
+
});
|
|
2447
|
+
return newState;
|
|
2448
|
+
};
|
|
2449
|
+
|
|
2368
2450
|
const handleDoubleClick = (state, index = state.focusedIndex) => {
|
|
2369
2451
|
return toggleIndex(state, index);
|
|
2370
2452
|
};
|
|
@@ -2376,6 +2458,97 @@ const handleFocus = state => {
|
|
|
2376
2458
|
};
|
|
2377
2459
|
};
|
|
2378
2460
|
|
|
2461
|
+
const SigTerm = 'SIGTERM';
|
|
2462
|
+
|
|
2463
|
+
const killProcess = async (state, index = state.focusedIndex) => {
|
|
2464
|
+
const process = state.visibleProcesses[index];
|
|
2465
|
+
if (!process) {
|
|
2466
|
+
return state;
|
|
2467
|
+
}
|
|
2468
|
+
await invoke$1('Process.kill', process.pid, SigTerm);
|
|
2469
|
+
return state;
|
|
2470
|
+
};
|
|
2471
|
+
|
|
2472
|
+
const WindowPid = -1;
|
|
2473
|
+
const isValidMemoryValue = value => {
|
|
2474
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
2475
|
+
};
|
|
2476
|
+
const getMeasureMemory = () => {
|
|
2477
|
+
const {
|
|
2478
|
+
measureUserAgentSpecificMemory
|
|
2479
|
+
} = performance;
|
|
2480
|
+
if (typeof measureUserAgentSpecificMemory !== 'function') {
|
|
2481
|
+
return undefined;
|
|
2482
|
+
}
|
|
2483
|
+
return measureUserAgentSpecificMemory.bind(performance);
|
|
2484
|
+
};
|
|
2485
|
+
const getUrlName = url => {
|
|
2486
|
+
if (!url || url === 'cross-origin-url') {
|
|
2487
|
+
return url;
|
|
2488
|
+
}
|
|
2489
|
+
try {
|
|
2490
|
+
const parsed = new URL(url);
|
|
2491
|
+
const parts = parsed.pathname.split('/').filter(Boolean);
|
|
2492
|
+
return parts.at(-1) || parsed.hostname || url;
|
|
2493
|
+
} catch {
|
|
2494
|
+
const withoutQuery = url.split(/[?#]/, 1)[0];
|
|
2495
|
+
const parts = withoutQuery.split('/').filter(Boolean);
|
|
2496
|
+
return parts.at(-1) || url;
|
|
2497
|
+
}
|
|
2498
|
+
};
|
|
2499
|
+
const getAttributionName = attribution => {
|
|
2500
|
+
const scope = attribution.scope || 'memory';
|
|
2501
|
+
const url = attribution.url ? getUrlName(attribution.url) : '';
|
|
2502
|
+
if (url) {
|
|
2503
|
+
return `${scope}: ${url}`;
|
|
2504
|
+
}
|
|
2505
|
+
return scope;
|
|
2506
|
+
};
|
|
2507
|
+
const getBreakdownName = (entry, index) => {
|
|
2508
|
+
if (entry.attribution && entry.attribution.length > 0) {
|
|
2509
|
+
return entry.attribution.map(getAttributionName).join(', ');
|
|
2510
|
+
}
|
|
2511
|
+
if (entry.types && entry.types.length > 0) {
|
|
2512
|
+
return entry.types.join(', ');
|
|
2513
|
+
}
|
|
2514
|
+
return `breakdown ${index + 1}`;
|
|
2515
|
+
};
|
|
2516
|
+
const toBreakdownProcess = (entry, index) => {
|
|
2517
|
+
const name = getBreakdownName(entry, index);
|
|
2518
|
+
return {
|
|
2519
|
+
cmd: name,
|
|
2520
|
+
memory: entry.bytes,
|
|
2521
|
+
name,
|
|
2522
|
+
pid: -2 - index,
|
|
2523
|
+
ppid: WindowPid,
|
|
2524
|
+
synthetic: true
|
|
2525
|
+
};
|
|
2526
|
+
};
|
|
2527
|
+
const getFrontendMemoryUsage = async rootPid => {
|
|
2528
|
+
const measureMemory = getMeasureMemory();
|
|
2529
|
+
if (!measureMemory) {
|
|
2530
|
+
return [];
|
|
2531
|
+
}
|
|
2532
|
+
try {
|
|
2533
|
+
const measurement = await measureMemory();
|
|
2534
|
+
if (!isValidMemoryValue(measurement.bytes)) {
|
|
2535
|
+
return [];
|
|
2536
|
+
}
|
|
2537
|
+
const breakdown = measurement.breakdown || [];
|
|
2538
|
+
const breakdownProcesses = breakdown.filter(entry => isValidMemoryValue(entry.bytes) && entry.bytes > 0).map(toBreakdownProcess);
|
|
2539
|
+
return [{
|
|
2540
|
+
cmd: 'window',
|
|
2541
|
+
memory: measurement.bytes,
|
|
2542
|
+
name: 'window',
|
|
2543
|
+
pid: WindowPid,
|
|
2544
|
+
ppid: rootPid,
|
|
2545
|
+
synthetic: true
|
|
2546
|
+
}, ...breakdownProcesses];
|
|
2547
|
+
} catch {
|
|
2548
|
+
return [];
|
|
2549
|
+
}
|
|
2550
|
+
};
|
|
2551
|
+
|
|
2379
2552
|
const sendMessagePortToProcessExplorer = async port => {
|
|
2380
2553
|
const rendererWorker = RendererWorker;
|
|
2381
2554
|
await rendererWorker.sendMessagePortToProcessExplorer(port);
|
|
@@ -2468,9 +2641,13 @@ const refresh = async state => {
|
|
|
2468
2641
|
try {
|
|
2469
2642
|
await initializeProcessExplorer(state.platform);
|
|
2470
2643
|
const includeElectronData = state.platform === Electron;
|
|
2471
|
-
const rootPid = state.rootPid || (await invoke('ProcessId.getMainProcessId',
|
|
2644
|
+
const rootPid = state.rootPid || (await invoke('ProcessId.getMainProcessId', {
|
|
2645
|
+
includeElectronData
|
|
2646
|
+
}));
|
|
2472
2647
|
const processes = await invoke('ListProcessesWithMemoryUsage.listProcessesWithMemoryUsage', rootPid, includeElectronData);
|
|
2473
|
-
const
|
|
2648
|
+
const frontendMemoryProcesses = state.includeFrontendMemoryUsage ? await getFrontendMemoryUsage(rootPid) : [];
|
|
2649
|
+
const allProcesses = [...processes, ...frontendMemoryProcesses];
|
|
2650
|
+
const visibleProcesses = getVisibleProcesses(allProcesses, state.collapsedPids, rootPid);
|
|
2474
2651
|
return {
|
|
2475
2652
|
...state,
|
|
2476
2653
|
errorCodeFrame: '',
|
|
@@ -2478,7 +2655,7 @@ const refresh = async state => {
|
|
|
2478
2655
|
errorStack: '',
|
|
2479
2656
|
focusedIndex: getFocusedIndex(state.focusedIndex, visibleProcesses),
|
|
2480
2657
|
initial: false,
|
|
2481
|
-
processes,
|
|
2658
|
+
processes: allProcesses,
|
|
2482
2659
|
rootPid,
|
|
2483
2660
|
visibleProcesses
|
|
2484
2661
|
};
|
|
@@ -2496,6 +2673,7 @@ const refresh = async state => {
|
|
|
2496
2673
|
|
|
2497
2674
|
const loadContent = async state => {
|
|
2498
2675
|
const newState = await refresh(state);
|
|
2676
|
+
start(state.uid);
|
|
2499
2677
|
return {
|
|
2500
2678
|
error: undefined,
|
|
2501
2679
|
state: newState
|
|
@@ -2527,6 +2705,267 @@ const text = data => {
|
|
|
2527
2705
|
};
|
|
2528
2706
|
};
|
|
2529
2707
|
|
|
2708
|
+
const SetText = 1;
|
|
2709
|
+
const Replace = 2;
|
|
2710
|
+
const SetAttribute = 3;
|
|
2711
|
+
const RemoveAttribute = 4;
|
|
2712
|
+
const Add = 6;
|
|
2713
|
+
const NavigateChild = 7;
|
|
2714
|
+
const NavigateParent = 8;
|
|
2715
|
+
const RemoveChild = 9;
|
|
2716
|
+
const NavigateSibling = 10;
|
|
2717
|
+
const SetReferenceNodeUid = 11;
|
|
2718
|
+
|
|
2719
|
+
const isKey = key => {
|
|
2720
|
+
return key !== 'type' && key !== 'childCount';
|
|
2721
|
+
};
|
|
2722
|
+
|
|
2723
|
+
const getKeys = node => {
|
|
2724
|
+
const keys = Object.keys(node).filter(isKey);
|
|
2725
|
+
return keys;
|
|
2726
|
+
};
|
|
2727
|
+
|
|
2728
|
+
const arrayToTree = nodes => {
|
|
2729
|
+
const result = [];
|
|
2730
|
+
let i = 0;
|
|
2731
|
+
while (i < nodes.length) {
|
|
2732
|
+
const node = nodes[i];
|
|
2733
|
+
const {
|
|
2734
|
+
children,
|
|
2735
|
+
nodesConsumed
|
|
2736
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
2737
|
+
result.push({
|
|
2738
|
+
node,
|
|
2739
|
+
children
|
|
2740
|
+
});
|
|
2741
|
+
i += 1 + nodesConsumed;
|
|
2742
|
+
}
|
|
2743
|
+
return result;
|
|
2744
|
+
};
|
|
2745
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
2746
|
+
if (childCount === 0) {
|
|
2747
|
+
return {
|
|
2748
|
+
children: [],
|
|
2749
|
+
nodesConsumed: 0
|
|
2750
|
+
};
|
|
2751
|
+
}
|
|
2752
|
+
const children = [];
|
|
2753
|
+
let i = startIndex;
|
|
2754
|
+
let remaining = childCount;
|
|
2755
|
+
let totalConsumed = 0;
|
|
2756
|
+
while (remaining > 0 && i < nodes.length) {
|
|
2757
|
+
const node = nodes[i];
|
|
2758
|
+
const nodeChildCount = node.childCount || 0;
|
|
2759
|
+
const {
|
|
2760
|
+
children: nodeChildren,
|
|
2761
|
+
nodesConsumed
|
|
2762
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
2763
|
+
children.push({
|
|
2764
|
+
node,
|
|
2765
|
+
children: nodeChildren
|
|
2766
|
+
});
|
|
2767
|
+
const nodeSize = 1 + nodesConsumed;
|
|
2768
|
+
i += nodeSize;
|
|
2769
|
+
totalConsumed += nodeSize;
|
|
2770
|
+
remaining--;
|
|
2771
|
+
}
|
|
2772
|
+
return {
|
|
2773
|
+
children,
|
|
2774
|
+
nodesConsumed: totalConsumed
|
|
2775
|
+
};
|
|
2776
|
+
};
|
|
2777
|
+
|
|
2778
|
+
const compareNodes = (oldNode, newNode) => {
|
|
2779
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
2780
|
+
// (caller should handle this with a Replace operation)
|
|
2781
|
+
if (oldNode.type !== newNode.type) {
|
|
2782
|
+
return null;
|
|
2783
|
+
}
|
|
2784
|
+
const patches = [];
|
|
2785
|
+
// Handle reference nodes - special handling for uid changes
|
|
2786
|
+
if (oldNode.type === Reference) {
|
|
2787
|
+
if (oldNode.uid !== newNode.uid) {
|
|
2788
|
+
patches.push({
|
|
2789
|
+
type: SetReferenceNodeUid,
|
|
2790
|
+
uid: newNode.uid
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
return patches;
|
|
2794
|
+
}
|
|
2795
|
+
// Handle text nodes
|
|
2796
|
+
if (oldNode.type === Text && newNode.type === Text) {
|
|
2797
|
+
if (oldNode.text !== newNode.text) {
|
|
2798
|
+
patches.push({
|
|
2799
|
+
type: SetText,
|
|
2800
|
+
value: newNode.text
|
|
2801
|
+
});
|
|
2802
|
+
}
|
|
2803
|
+
return patches;
|
|
2804
|
+
}
|
|
2805
|
+
// Compare attributes
|
|
2806
|
+
const oldKeys = getKeys(oldNode);
|
|
2807
|
+
const newKeys = getKeys(newNode);
|
|
2808
|
+
// Check for attribute changes
|
|
2809
|
+
for (const key of newKeys) {
|
|
2810
|
+
if (oldNode[key] !== newNode[key]) {
|
|
2811
|
+
patches.push({
|
|
2812
|
+
type: SetAttribute,
|
|
2813
|
+
key,
|
|
2814
|
+
value: newNode[key]
|
|
2815
|
+
});
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
// Check for removed attributes
|
|
2819
|
+
for (const key of oldKeys) {
|
|
2820
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
2821
|
+
patches.push({
|
|
2822
|
+
type: RemoveAttribute,
|
|
2823
|
+
key
|
|
2824
|
+
});
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
return patches;
|
|
2828
|
+
};
|
|
2829
|
+
|
|
2830
|
+
const treeToArray = node => {
|
|
2831
|
+
const result = [node.node];
|
|
2832
|
+
for (const child of node.children) {
|
|
2833
|
+
result.push(...treeToArray(child));
|
|
2834
|
+
}
|
|
2835
|
+
return result;
|
|
2836
|
+
};
|
|
2837
|
+
|
|
2838
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
2839
|
+
if (currentChildIndex === -1) {
|
|
2840
|
+
patches.push({
|
|
2841
|
+
type: NavigateChild,
|
|
2842
|
+
index
|
|
2843
|
+
});
|
|
2844
|
+
return index;
|
|
2845
|
+
}
|
|
2846
|
+
if (currentChildIndex !== index) {
|
|
2847
|
+
patches.push({
|
|
2848
|
+
type: NavigateSibling,
|
|
2849
|
+
index
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
return index;
|
|
2853
|
+
};
|
|
2854
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
2855
|
+
if (currentChildIndex >= 0) {
|
|
2856
|
+
patches.push({
|
|
2857
|
+
type: NavigateParent
|
|
2858
|
+
});
|
|
2859
|
+
}
|
|
2860
|
+
return -1;
|
|
2861
|
+
};
|
|
2862
|
+
const addTree = (newNode, patches) => {
|
|
2863
|
+
patches.push({
|
|
2864
|
+
type: Add,
|
|
2865
|
+
nodes: treeToArray(newNode)
|
|
2866
|
+
});
|
|
2867
|
+
};
|
|
2868
|
+
const replaceTree = (newNode, patches) => {
|
|
2869
|
+
patches.push({
|
|
2870
|
+
type: Replace,
|
|
2871
|
+
nodes: treeToArray(newNode)
|
|
2872
|
+
});
|
|
2873
|
+
};
|
|
2874
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
2875
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2876
|
+
if (nodePatches === null) {
|
|
2877
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2878
|
+
replaceTree(newNode, patches);
|
|
2879
|
+
return nextChildIndex;
|
|
2880
|
+
}
|
|
2881
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
2882
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
2883
|
+
return currentChildIndex;
|
|
2884
|
+
}
|
|
2885
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2886
|
+
if (nodePatches.length > 0) {
|
|
2887
|
+
patches.push(...nodePatches);
|
|
2888
|
+
}
|
|
2889
|
+
if (hasChildrenToCompare) {
|
|
2890
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2891
|
+
}
|
|
2892
|
+
return nextChildIndex;
|
|
2893
|
+
};
|
|
2894
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
2895
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2896
|
+
if (nodePatches === null) {
|
|
2897
|
+
replaceTree(newNode, patches);
|
|
2898
|
+
return;
|
|
2899
|
+
}
|
|
2900
|
+
if (nodePatches.length > 0) {
|
|
2901
|
+
patches.push(...nodePatches);
|
|
2902
|
+
}
|
|
2903
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
2904
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
2908
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
2909
|
+
let currentChildIndex = -1;
|
|
2910
|
+
const indicesToRemove = [];
|
|
2911
|
+
for (let i = 0; i < maxLength; i++) {
|
|
2912
|
+
const oldNode = oldChildren[i];
|
|
2913
|
+
const newNode = newChildren[i];
|
|
2914
|
+
if (!oldNode && !newNode) {
|
|
2915
|
+
continue;
|
|
2916
|
+
}
|
|
2917
|
+
if (!oldNode) {
|
|
2918
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
2919
|
+
addTree(newNode, patches);
|
|
2920
|
+
continue;
|
|
2921
|
+
}
|
|
2922
|
+
if (!newNode) {
|
|
2923
|
+
indicesToRemove.push(i);
|
|
2924
|
+
continue;
|
|
2925
|
+
}
|
|
2926
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
2927
|
+
}
|
|
2928
|
+
navigateToParent(patches, currentChildIndex);
|
|
2929
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
2930
|
+
patches.push({
|
|
2931
|
+
type: RemoveChild,
|
|
2932
|
+
index: indicesToRemove[j]
|
|
2933
|
+
});
|
|
2934
|
+
}
|
|
2935
|
+
};
|
|
2936
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
2937
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
2938
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
2939
|
+
return;
|
|
2940
|
+
}
|
|
2941
|
+
diffChildren(oldTree, newTree, patches);
|
|
2942
|
+
};
|
|
2943
|
+
|
|
2944
|
+
const removeTrailingNavigationPatches = patches => {
|
|
2945
|
+
// Find the last non-navigation patch
|
|
2946
|
+
let lastNonNavigationIndex = -1;
|
|
2947
|
+
for (let i = patches.length - 1; i >= 0; i--) {
|
|
2948
|
+
const patch = patches[i];
|
|
2949
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
2950
|
+
lastNonNavigationIndex = i;
|
|
2951
|
+
break;
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
// Return patches up to and including the last non-navigation patch
|
|
2955
|
+
return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
|
|
2956
|
+
};
|
|
2957
|
+
|
|
2958
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
2959
|
+
// Step 1: Convert flat arrays to tree structures
|
|
2960
|
+
const oldTree = arrayToTree(oldNodes);
|
|
2961
|
+
const newTree = arrayToTree(newNodes);
|
|
2962
|
+
// Step 3: Compare the trees
|
|
2963
|
+
const patches = [];
|
|
2964
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
2965
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
2966
|
+
return removeTrailingNavigationPatches(patches);
|
|
2967
|
+
};
|
|
2968
|
+
|
|
2530
2969
|
const Grid = 'grid';
|
|
2531
2970
|
const GridCell = 'gridcell';
|
|
2532
2971
|
const None = 'none';
|
|
@@ -2579,7 +3018,7 @@ const getPaddingLeft = process => {
|
|
|
2579
3018
|
return '0';
|
|
2580
3019
|
}
|
|
2581
3020
|
const depthCh = (process.depth - 1) * 1.5;
|
|
2582
|
-
if (process.flags === None$
|
|
3021
|
+
if (process.flags === None$2) {
|
|
2583
3022
|
return `calc(${depthCh}ch + 17px)`;
|
|
2584
3023
|
}
|
|
2585
3024
|
return `${depthCh}ch`;
|
|
@@ -2712,12 +3151,21 @@ const renderItems = (oldState, newState) => {
|
|
|
2712
3151
|
return [SetDom2, newState.uid, getDom(newState)];
|
|
2713
3152
|
};
|
|
2714
3153
|
|
|
3154
|
+
const renderIncremental = (oldState, newState) => {
|
|
3155
|
+
const oldDom = renderItems(oldState, oldState)[2];
|
|
3156
|
+
const newDom = renderItems(newState, newState)[2];
|
|
3157
|
+
const patches = diffTree(oldDom, newDom);
|
|
3158
|
+
return [SetPatches, newState.uid, patches];
|
|
3159
|
+
};
|
|
3160
|
+
|
|
2715
3161
|
const getRenderer = diffType => {
|
|
2716
3162
|
switch (diffType) {
|
|
2717
3163
|
case RenderFocus:
|
|
2718
3164
|
return renderFocus;
|
|
2719
3165
|
case RenderFocusContext:
|
|
2720
3166
|
return renderFocusContext;
|
|
3167
|
+
case RenderIncremental:
|
|
3168
|
+
return renderIncremental;
|
|
2721
3169
|
case RenderItems:
|
|
2722
3170
|
return renderItems;
|
|
2723
3171
|
default:
|
|
@@ -2774,14 +3222,18 @@ const renderEventListeners = () => {
|
|
|
2774
3222
|
const commandMap = {
|
|
2775
3223
|
'ProcessExplorer.collapseAll': wrapCommand(collapseAll),
|
|
2776
3224
|
'ProcessExplorer.create': create$d,
|
|
3225
|
+
'ProcessExplorer.debugProcess': wrapCommand(debugProcess),
|
|
2777
3226
|
'ProcessExplorer.diff2': diff2,
|
|
3227
|
+
'ProcessExplorer.dispose': dispose,
|
|
2778
3228
|
'ProcessExplorer.expandAll': wrapCommand(expandAll),
|
|
2779
3229
|
'ProcessExplorer.focusFirst': wrapCommand(focusFirst),
|
|
2780
3230
|
'ProcessExplorer.focusLast': wrapCommand(focusLast),
|
|
2781
3231
|
'ProcessExplorer.focusNext': wrapCommand(focusNext),
|
|
2782
3232
|
'ProcessExplorer.focusPrevious': wrapCommand(focusPrevious),
|
|
2783
3233
|
'ProcessExplorer.getCommandIds': getCommandIds,
|
|
2784
|
-
'ProcessExplorer.getKeyBindings': getKeyBindings
|
|
3234
|
+
'ProcessExplorer.getKeyBindings': getKeyBindings,
|
|
3235
|
+
'ProcessExplorer.getMenuEntries': wrapGetter(getMenuEntries),
|
|
3236
|
+
'ProcessExplorer.getMenuEntryIds': getMenuEntryIds,
|
|
2785
3237
|
'ProcessExplorer.handleArrowLeft': wrapCommand(handleArrowLeft),
|
|
2786
3238
|
'ProcessExplorer.handleArrowRight': wrapCommand(handleArrowRight),
|
|
2787
3239
|
'ProcessExplorer.handleBlur': wrapCommand(handleBlur),
|
|
@@ -2789,11 +3241,13 @@ const commandMap = {
|
|
|
2789
3241
|
'ProcessExplorer.handleContextMenu': wrapCommand(handleContextMenu),
|
|
2790
3242
|
'ProcessExplorer.handleDoubleClick': wrapCommand(handleDoubleClick),
|
|
2791
3243
|
'ProcessExplorer.handleFocus': wrapCommand(handleFocus),
|
|
3244
|
+
'ProcessExplorer.killProcess': wrapCommand(killProcess),
|
|
2792
3245
|
'ProcessExplorer.loadContent': wrapLoadContent(loadContent),
|
|
2793
3246
|
'ProcessExplorer.refresh': wrapCommand(refresh),
|
|
2794
3247
|
'ProcessExplorer.render2': render2,
|
|
2795
3248
|
'ProcessExplorer.renderEventListeners': renderEventListeners,
|
|
2796
|
-
'ProcessExplorer.terminate': terminate
|
|
3249
|
+
'ProcessExplorer.terminate': terminate,
|
|
3250
|
+
'ProcessExplorer.update': wrapCommand(refresh)
|
|
2797
3251
|
};
|
|
2798
3252
|
|
|
2799
3253
|
const sendMessagePortToErrorWorker = async port => {
|