@lvce-editor/process-explorer-worker 3.8.0 → 3.12.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 +324 -56
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3,8 +3,28 @@ const toCommandId = key => {
|
|
|
3
3
|
return key.slice(dotIndex + 1);
|
|
4
4
|
};
|
|
5
5
|
const create$e = () => {
|
|
6
|
+
const generations = Object.create(null);
|
|
6
7
|
const states = Object.create(null);
|
|
7
8
|
const commandMapRef = {};
|
|
9
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
10
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
11
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
12
|
+
};
|
|
13
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
14
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
15
|
+
return Promise.resolve(fallbackState);
|
|
16
|
+
}
|
|
17
|
+
const current = states[uid];
|
|
18
|
+
const updatedState = updater(current.newState);
|
|
19
|
+
if (updatedState !== current.newState) {
|
|
20
|
+
states[uid] = {
|
|
21
|
+
newState: updatedState,
|
|
22
|
+
oldState: current.oldState,
|
|
23
|
+
scheduledState: updatedState
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return Promise.resolve(updatedState);
|
|
27
|
+
};
|
|
8
28
|
return {
|
|
9
29
|
clear() {
|
|
10
30
|
for (const key of Object.keys(states)) {
|
|
@@ -43,14 +63,39 @@ const create$e = () => {
|
|
|
43
63
|
Object.assign(commandMapRef, commandMap);
|
|
44
64
|
},
|
|
45
65
|
set(uid, oldState, newState, scheduledState) {
|
|
66
|
+
const current = states[uid];
|
|
67
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
68
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
69
|
+
}
|
|
46
70
|
states[uid] = {
|
|
47
71
|
newState,
|
|
48
72
|
oldState,
|
|
49
73
|
scheduledState: scheduledState ?? newState
|
|
50
74
|
};
|
|
51
75
|
},
|
|
76
|
+
wrapAsyncCommand(fn) {
|
|
77
|
+
const wrapped = async (uid, ...args) => {
|
|
78
|
+
const generation = getGeneration(uid);
|
|
79
|
+
let latestState = states[uid].newState;
|
|
80
|
+
const context = {
|
|
81
|
+
getState: () => {
|
|
82
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
83
|
+
latestState = states[uid].newState;
|
|
84
|
+
}
|
|
85
|
+
return latestState;
|
|
86
|
+
},
|
|
87
|
+
updateState: async updater => {
|
|
88
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
89
|
+
return latestState;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
await fn(context, ...args);
|
|
93
|
+
};
|
|
94
|
+
return wrapped;
|
|
95
|
+
},
|
|
52
96
|
wrapCommand(fn) {
|
|
53
97
|
const wrapped = async (uid, ...args) => {
|
|
98
|
+
const generation = getGeneration(uid);
|
|
54
99
|
const {
|
|
55
100
|
newState,
|
|
56
101
|
oldState
|
|
@@ -59,6 +104,9 @@ const create$e = () => {
|
|
|
59
104
|
if (oldState === newerState || newState === newerState) {
|
|
60
105
|
return;
|
|
61
106
|
}
|
|
107
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
62
110
|
const latestOld = states[uid];
|
|
63
111
|
const latestNew = {
|
|
64
112
|
...latestOld.newState,
|
|
@@ -83,6 +131,7 @@ const create$e = () => {
|
|
|
83
131
|
},
|
|
84
132
|
wrapLoadContent(fn) {
|
|
85
133
|
const wrapped = async (uid, ...args) => {
|
|
134
|
+
const generation = getGeneration(uid);
|
|
86
135
|
const {
|
|
87
136
|
newState,
|
|
88
137
|
oldState
|
|
@@ -97,6 +146,11 @@ const create$e = () => {
|
|
|
97
146
|
error
|
|
98
147
|
};
|
|
99
148
|
}
|
|
149
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
150
|
+
return {
|
|
151
|
+
error
|
|
152
|
+
};
|
|
153
|
+
}
|
|
100
154
|
const latestOld = states[uid];
|
|
101
155
|
const latestNew = {
|
|
102
156
|
...latestOld.newState,
|
|
@@ -192,6 +246,8 @@ const {
|
|
|
192
246
|
wrapLoadContent
|
|
193
247
|
} = create$e();
|
|
194
248
|
|
|
249
|
+
const processExplorerUpdateInterval = 1000;
|
|
250
|
+
|
|
195
251
|
const getIncludeFrontendMemoryUsage = args => {
|
|
196
252
|
if (!args || typeof args !== 'object') {
|
|
197
253
|
return false;
|
|
@@ -199,6 +255,16 @@ const getIncludeFrontendMemoryUsage = args => {
|
|
|
199
255
|
const createArgs = args;
|
|
200
256
|
return createArgs.includeFrontendMemoryUsage === true;
|
|
201
257
|
};
|
|
258
|
+
const getUpdateInterval = args => {
|
|
259
|
+
if (!args || typeof args !== 'object') {
|
|
260
|
+
return processExplorerUpdateInterval;
|
|
261
|
+
}
|
|
262
|
+
const createArgs = args;
|
|
263
|
+
if (typeof createArgs.updateInterval !== 'number') {
|
|
264
|
+
return processExplorerUpdateInterval;
|
|
265
|
+
}
|
|
266
|
+
return createArgs.updateInterval;
|
|
267
|
+
};
|
|
202
268
|
const create$d = (id, _uri, x, y, width, height, args, parentUid, platform = 0, assetDir = '') => {
|
|
203
269
|
const state = {
|
|
204
270
|
assetDir,
|
|
@@ -217,6 +283,7 @@ const create$d = (id, _uri, x, y, width, height, args, parentUid, platform = 0,
|
|
|
217
283
|
processes: [],
|
|
218
284
|
rootPid: -1,
|
|
219
285
|
uid: id,
|
|
286
|
+
updateInterval: getUpdateInterval(args),
|
|
220
287
|
visibleProcesses: [],
|
|
221
288
|
width,
|
|
222
289
|
x,
|
|
@@ -367,7 +434,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
367
434
|
for (const property of Object.values(value)) {
|
|
368
435
|
walkValue(property, transferrables, isTransferrable);
|
|
369
436
|
}
|
|
370
|
-
return;
|
|
371
437
|
}
|
|
372
438
|
};
|
|
373
439
|
const getTransferrables = value => {
|
|
@@ -521,7 +587,14 @@ class IpcError extends VError {
|
|
|
521
587
|
const cause = new Error(message);
|
|
522
588
|
// @ts-ignore
|
|
523
589
|
cause.code = code;
|
|
524
|
-
|
|
590
|
+
if (stack) {
|
|
591
|
+
Object.defineProperty(cause, 'stack', {
|
|
592
|
+
configurable: true,
|
|
593
|
+
enumerable: false,
|
|
594
|
+
value: stack,
|
|
595
|
+
writable: true
|
|
596
|
+
});
|
|
597
|
+
}
|
|
525
598
|
super(cause, betterMessage);
|
|
526
599
|
} else {
|
|
527
600
|
super(betterMessage);
|
|
@@ -1379,9 +1452,14 @@ const create$4 = async ({
|
|
|
1379
1452
|
}) => {
|
|
1380
1453
|
// TODO create a commandMap per rpc instance
|
|
1381
1454
|
register(commandMap);
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1455
|
+
let rawIpc;
|
|
1456
|
+
try {
|
|
1457
|
+
rawIpc = await IpcParentWithWebSocket$1.create({
|
|
1458
|
+
webSocket
|
|
1459
|
+
});
|
|
1460
|
+
} catch (error) {
|
|
1461
|
+
throw new VError(error, 'Failed to create rpc connection');
|
|
1462
|
+
}
|
|
1385
1463
|
const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
|
|
1386
1464
|
handleIpc(ipc);
|
|
1387
1465
|
const rpc = createRpc(ipc);
|
|
@@ -1494,7 +1572,15 @@ const create = rpcId => {
|
|
|
1494
1572
|
};
|
|
1495
1573
|
};
|
|
1496
1574
|
|
|
1575
|
+
const Audio = 0;
|
|
1576
|
+
const Button = 1;
|
|
1577
|
+
const Col = 2;
|
|
1578
|
+
const ColGroup = 3;
|
|
1497
1579
|
const Div = 4;
|
|
1580
|
+
const H1 = 5;
|
|
1581
|
+
const Input = 6;
|
|
1582
|
+
const Kbd = 7;
|
|
1583
|
+
const Span = 8;
|
|
1498
1584
|
const Table$1 = 9;
|
|
1499
1585
|
const TBody = 10;
|
|
1500
1586
|
const Td = 11;
|
|
@@ -1502,12 +1588,161 @@ const Text = 12;
|
|
|
1502
1588
|
const Th = 13;
|
|
1503
1589
|
const THead = 14;
|
|
1504
1590
|
const Tr = 15;
|
|
1591
|
+
const I = 16;
|
|
1592
|
+
const Img = 17;
|
|
1593
|
+
const Root = 0;
|
|
1594
|
+
const Ins = 20;
|
|
1595
|
+
const Del = 21;
|
|
1596
|
+
const H2 = 22;
|
|
1597
|
+
const H3 = 23;
|
|
1598
|
+
const H4 = 24;
|
|
1599
|
+
const H5 = 25;
|
|
1600
|
+
const H6 = 26;
|
|
1601
|
+
const Article = 27;
|
|
1602
|
+
const Aside = 28;
|
|
1603
|
+
const Footer = 29;
|
|
1604
|
+
const Header = 30;
|
|
1605
|
+
const Nav = 40;
|
|
1606
|
+
const Section = 41;
|
|
1607
|
+
const Search = 42;
|
|
1608
|
+
const Dd = 43;
|
|
1609
|
+
const Dl = 44;
|
|
1610
|
+
const Figcaption = 45;
|
|
1611
|
+
const Figure = 46;
|
|
1612
|
+
const Hr = 47;
|
|
1613
|
+
const Li = 48;
|
|
1614
|
+
const Ol = 49;
|
|
1615
|
+
const P = 50;
|
|
1505
1616
|
const Pre = 51;
|
|
1617
|
+
const A = 53;
|
|
1618
|
+
const Abbr = 54;
|
|
1619
|
+
const Br = 55;
|
|
1620
|
+
const Cite = 56;
|
|
1621
|
+
const Data = 57;
|
|
1622
|
+
const Time = 58;
|
|
1623
|
+
const Tfoot = 59;
|
|
1624
|
+
const Ul = 60;
|
|
1625
|
+
const Video = 61;
|
|
1626
|
+
const TextArea = 62;
|
|
1627
|
+
const Select = 63;
|
|
1628
|
+
const Option = 64;
|
|
1629
|
+
const Code = 65;
|
|
1630
|
+
const Label = 66;
|
|
1631
|
+
const Dt = 67;
|
|
1632
|
+
const Iframe = 68;
|
|
1633
|
+
const Main = 69;
|
|
1634
|
+
const Strong = 70;
|
|
1635
|
+
const Em = 71;
|
|
1636
|
+
const Style = 72;
|
|
1637
|
+
const Html = 73;
|
|
1638
|
+
const Head = 74;
|
|
1639
|
+
const Title = 75;
|
|
1640
|
+
const Meta = 76;
|
|
1641
|
+
const Canvas = 77;
|
|
1642
|
+
const Form = 78;
|
|
1643
|
+
const BlockQuote = 79;
|
|
1644
|
+
const Quote = 80;
|
|
1645
|
+
const Circle = 81;
|
|
1646
|
+
const Defs = 82;
|
|
1647
|
+
const Ellipse = 83;
|
|
1648
|
+
const G = 84;
|
|
1649
|
+
const Line = 85;
|
|
1650
|
+
const Path = 86;
|
|
1651
|
+
const Polygon = 87;
|
|
1652
|
+
const Polyline = 88;
|
|
1653
|
+
const Rect = 89;
|
|
1654
|
+
const Svg = 90;
|
|
1655
|
+
const Use = 91;
|
|
1506
1656
|
const Reference = 100;
|
|
1507
1657
|
|
|
1658
|
+
const VirtualDomElements = {
|
|
1659
|
+
__proto__: null,
|
|
1660
|
+
A,
|
|
1661
|
+
Abbr,
|
|
1662
|
+
Article,
|
|
1663
|
+
Aside,
|
|
1664
|
+
Audio,
|
|
1665
|
+
BlockQuote,
|
|
1666
|
+
Br,
|
|
1667
|
+
Button,
|
|
1668
|
+
Canvas,
|
|
1669
|
+
Circle,
|
|
1670
|
+
Cite,
|
|
1671
|
+
Code,
|
|
1672
|
+
Col,
|
|
1673
|
+
ColGroup,
|
|
1674
|
+
Data,
|
|
1675
|
+
Dd,
|
|
1676
|
+
Defs,
|
|
1677
|
+
Del,
|
|
1678
|
+
Div,
|
|
1679
|
+
Dl,
|
|
1680
|
+
Dt,
|
|
1681
|
+
Ellipse,
|
|
1682
|
+
Em,
|
|
1683
|
+
Figcaption,
|
|
1684
|
+
Figure,
|
|
1685
|
+
Footer,
|
|
1686
|
+
Form,
|
|
1687
|
+
G,
|
|
1688
|
+
H1,
|
|
1689
|
+
H2,
|
|
1690
|
+
H3,
|
|
1691
|
+
H4,
|
|
1692
|
+
H5,
|
|
1693
|
+
H6,
|
|
1694
|
+
Head,
|
|
1695
|
+
Header,
|
|
1696
|
+
Hr,
|
|
1697
|
+
Html,
|
|
1698
|
+
I,
|
|
1699
|
+
Iframe,
|
|
1700
|
+
Img,
|
|
1701
|
+
Input,
|
|
1702
|
+
Ins,
|
|
1703
|
+
Kbd,
|
|
1704
|
+
Label,
|
|
1705
|
+
Li,
|
|
1706
|
+
Line,
|
|
1707
|
+
Main,
|
|
1708
|
+
Meta,
|
|
1709
|
+
Nav,
|
|
1710
|
+
Ol,
|
|
1711
|
+
Option,
|
|
1712
|
+
P,
|
|
1713
|
+
Path,
|
|
1714
|
+
Polygon,
|
|
1715
|
+
Polyline,
|
|
1716
|
+
Pre,
|
|
1717
|
+
Quote,
|
|
1718
|
+
Rect,
|
|
1719
|
+
Reference,
|
|
1720
|
+
Root,
|
|
1721
|
+
Search,
|
|
1722
|
+
Section,
|
|
1723
|
+
Select,
|
|
1724
|
+
Span,
|
|
1725
|
+
Strong,
|
|
1726
|
+
Style,
|
|
1727
|
+
Svg,
|
|
1728
|
+
TBody,
|
|
1729
|
+
THead,
|
|
1730
|
+
Table: Table$1,
|
|
1731
|
+
Td,
|
|
1732
|
+
Text,
|
|
1733
|
+
TextArea,
|
|
1734
|
+
Tfoot,
|
|
1735
|
+
Th,
|
|
1736
|
+
Time,
|
|
1737
|
+
Title,
|
|
1738
|
+
Tr,
|
|
1739
|
+
Ul,
|
|
1740
|
+
Use,
|
|
1741
|
+
Video
|
|
1742
|
+
};
|
|
1743
|
+
|
|
1508
1744
|
const ClientX = 'event.clientX';
|
|
1509
1745
|
const ClientY = 'event.clientY';
|
|
1510
|
-
const TargetName = 'event.target.name';
|
|
1511
1746
|
|
|
1512
1747
|
const Enter = 3;
|
|
1513
1748
|
const Space = 9;
|
|
@@ -1529,6 +1764,7 @@ const Remote = 3;
|
|
|
1529
1764
|
|
|
1530
1765
|
const ErrorWorker = 3308;
|
|
1531
1766
|
const FileSystemWorker$1 = 209;
|
|
1767
|
+
const ProcessExplorerRenderer = 33;
|
|
1532
1768
|
const RendererWorker = 1;
|
|
1533
1769
|
|
|
1534
1770
|
const FocusSelector = 'Viewlet.focusSelector';
|
|
@@ -1576,10 +1812,6 @@ const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
|
|
|
1576
1812
|
const command = 'FileSystem.handleMessagePort';
|
|
1577
1813
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1578
1814
|
};
|
|
1579
|
-
const sendMessagePortToProcessExplorer$1 = async port => {
|
|
1580
|
-
const command = 'ProcessExplorer.handleMessagePort';
|
|
1581
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToProcessExplorer', port, command, 0);
|
|
1582
|
-
};
|
|
1583
1815
|
|
|
1584
1816
|
const debugProcess = async (state, index = state.focusedIndex) => {
|
|
1585
1817
|
const process = state.visibleProcesses[index];
|
|
@@ -1625,8 +1857,6 @@ const diff2 = uid => {
|
|
|
1625
1857
|
return diff(oldState, scheduledState);
|
|
1626
1858
|
};
|
|
1627
1859
|
|
|
1628
|
-
const processExplorerUpdateInterval = 1000;
|
|
1629
|
-
|
|
1630
1860
|
const intervals = new Map();
|
|
1631
1861
|
const pending = new Set();
|
|
1632
1862
|
const dispose$3 = uid => {
|
|
@@ -1655,7 +1885,7 @@ const update = async uid => {
|
|
|
1655
1885
|
}
|
|
1656
1886
|
};
|
|
1657
1887
|
const start = (uid, interval = processExplorerUpdateInterval) => {
|
|
1658
|
-
if (interval
|
|
1888
|
+
if (interval <= 0 || intervals.has(uid)) {
|
|
1659
1889
|
return;
|
|
1660
1890
|
}
|
|
1661
1891
|
const intervalId = setInterval(() => {
|
|
@@ -1663,16 +1893,20 @@ const start = (uid, interval = processExplorerUpdateInterval) => {
|
|
|
1663
1893
|
}, interval);
|
|
1664
1894
|
intervals.set(uid, intervalId);
|
|
1665
1895
|
};
|
|
1896
|
+
const restart = (uid, interval) => {
|
|
1897
|
+
dispose$3(uid);
|
|
1898
|
+
start(uid, interval);
|
|
1899
|
+
};
|
|
1666
1900
|
|
|
1667
|
-
const
|
|
1668
|
-
await
|
|
1901
|
+
const sendMessagePortToMainProcess = async port => {
|
|
1902
|
+
await invokeAndTransfer('SendMessagePortToMainProcess.sendMessagePortToMainProcess', port, 'HandleElectronMessagePort.handleElectronMessagePort', ProcessExplorerRenderer);
|
|
1669
1903
|
};
|
|
1670
1904
|
|
|
1671
1905
|
const launchProcessExplorerElectron = async () => {
|
|
1672
1906
|
try {
|
|
1673
1907
|
const rpc = await create$5({
|
|
1674
1908
|
commandMap: {},
|
|
1675
|
-
send:
|
|
1909
|
+
send: sendMessagePortToMainProcess
|
|
1676
1910
|
});
|
|
1677
1911
|
return rpc;
|
|
1678
1912
|
} catch (error) {
|
|
@@ -1965,7 +2199,7 @@ const handleBlur = state => {
|
|
|
1965
2199
|
};
|
|
1966
2200
|
|
|
1967
2201
|
const handleClickAt = (state, index) => {
|
|
1968
|
-
return focusIndex(state, index);
|
|
2202
|
+
return focusIndex(state, Number(index));
|
|
1969
2203
|
};
|
|
1970
2204
|
|
|
1971
2205
|
const show2 = async (uid, menuId, x, y, args) => {
|
|
@@ -1973,25 +2207,26 @@ const show2 = async (uid, menuId, x, y, args) => {
|
|
|
1973
2207
|
};
|
|
1974
2208
|
|
|
1975
2209
|
const handleContextMenu = async (state, index = state.focusedIndex, x = 0, y = 0) => {
|
|
1976
|
-
const
|
|
2210
|
+
const numericIndex = Number(index);
|
|
2211
|
+
const process = state.visibleProcesses[numericIndex];
|
|
1977
2212
|
if (!process) {
|
|
1978
2213
|
return state;
|
|
1979
2214
|
}
|
|
1980
2215
|
const newState = {
|
|
1981
2216
|
...state,
|
|
1982
2217
|
focused: false,
|
|
1983
|
-
focusedIndex:
|
|
2218
|
+
focusedIndex: numericIndex
|
|
1984
2219
|
};
|
|
1985
2220
|
set$6(state.uid, state, newState);
|
|
1986
2221
|
await show2(state.uid, ProcessExplorer$1, x, y, {
|
|
1987
|
-
index,
|
|
2222
|
+
index: numericIndex,
|
|
1988
2223
|
menuId: ProcessExplorer$1
|
|
1989
2224
|
});
|
|
1990
2225
|
return newState;
|
|
1991
2226
|
};
|
|
1992
2227
|
|
|
1993
2228
|
const handleDoubleClick = (state, index = state.focusedIndex) => {
|
|
1994
|
-
return toggleIndex(state, index);
|
|
2229
|
+
return toggleIndex(state, Number(index));
|
|
1995
2230
|
};
|
|
1996
2231
|
|
|
1997
2232
|
const handleFocus = state => {
|
|
@@ -2165,7 +2400,7 @@ const hasError$1 = state => {
|
|
|
2165
2400
|
const loadContent = async state => {
|
|
2166
2401
|
const newState = await refresh(state);
|
|
2167
2402
|
if (!hasError$1(newState)) {
|
|
2168
|
-
start(newState.uid);
|
|
2403
|
+
start(newState.uid, newState.updateInterval);
|
|
2169
2404
|
}
|
|
2170
2405
|
return {
|
|
2171
2406
|
error: undefined,
|
|
@@ -2190,6 +2425,10 @@ const renderFocusContext = (oldState, newState) => {
|
|
|
2190
2425
|
return [SetFocusContext, newState.uid, newState.focused ? FocusExplorer : Empty];
|
|
2191
2426
|
};
|
|
2192
2427
|
|
|
2428
|
+
const mergeClassNames = (...classNames) => {
|
|
2429
|
+
return classNames.filter(Boolean).join(' ');
|
|
2430
|
+
};
|
|
2431
|
+
|
|
2193
2432
|
const text = data => {
|
|
2194
2433
|
return {
|
|
2195
2434
|
childCount: 0,
|
|
@@ -2198,6 +2437,8 @@ const text = data => {
|
|
|
2198
2437
|
};
|
|
2199
2438
|
};
|
|
2200
2439
|
|
|
2440
|
+
new Set(Object.values(VirtualDomElements));
|
|
2441
|
+
|
|
2201
2442
|
const SetText = 1;
|
|
2202
2443
|
const Replace = 2;
|
|
2203
2444
|
const SetAttribute = 3;
|
|
@@ -2500,9 +2741,28 @@ const formatMemory = memory => {
|
|
|
2500
2741
|
return `${(memory / 1000 ** 4).toFixed(1)} TB`;
|
|
2501
2742
|
};
|
|
2502
2743
|
|
|
2744
|
+
const Focusable = 0;
|
|
2745
|
+
|
|
2746
|
+
const tableHeadNode = {
|
|
2747
|
+
childCount: 1,
|
|
2748
|
+
className: TableHead,
|
|
2749
|
+
role: RowGroup,
|
|
2750
|
+
type: THead
|
|
2751
|
+
};
|
|
2752
|
+
const headerRowNode = {
|
|
2753
|
+
childCount: 3,
|
|
2754
|
+
className: Row,
|
|
2755
|
+
role: Row$1,
|
|
2756
|
+
type: Tr
|
|
2757
|
+
};
|
|
2758
|
+
const headerCellNode = {
|
|
2759
|
+
childCount: 1,
|
|
2760
|
+
className: HeaderCell,
|
|
2761
|
+
type: Th
|
|
2762
|
+
};
|
|
2503
2763
|
const getRowClassName = focused => {
|
|
2504
2764
|
if (focused) {
|
|
2505
|
-
return
|
|
2765
|
+
return mergeClassNames(Row, RowFocused);
|
|
2506
2766
|
}
|
|
2507
2767
|
return Row;
|
|
2508
2768
|
};
|
|
@@ -2511,9 +2771,6 @@ const getPaddingLeft = process => {
|
|
|
2511
2771
|
return '0';
|
|
2512
2772
|
}
|
|
2513
2773
|
const depthCh = (process.depth - 1) * 1.5;
|
|
2514
|
-
if (process.flags === None$2) {
|
|
2515
|
-
return `calc(${depthCh}ch + 17px)`;
|
|
2516
|
-
}
|
|
2517
2774
|
return `${depthCh}ch`;
|
|
2518
2775
|
};
|
|
2519
2776
|
const getAriaExpanded = process => {
|
|
@@ -2530,6 +2787,7 @@ const getCellDom = (className, value, index, paddingLeft) => {
|
|
|
2530
2787
|
return [{
|
|
2531
2788
|
childCount: 1,
|
|
2532
2789
|
className,
|
|
2790
|
+
'data-index': index,
|
|
2533
2791
|
name: String(index),
|
|
2534
2792
|
paddingLeft,
|
|
2535
2793
|
role: GridCell,
|
|
@@ -2538,25 +2796,10 @@ const getCellDom = (className, value, index, paddingLeft) => {
|
|
|
2538
2796
|
}, text(value)];
|
|
2539
2797
|
};
|
|
2540
2798
|
const getHeaderDom = () => {
|
|
2541
|
-
return [
|
|
2542
|
-
childCount: 1,
|
|
2543
|
-
className: TableHead,
|
|
2544
|
-
role: RowGroup,
|
|
2545
|
-
type: THead
|
|
2546
|
-
}, {
|
|
2547
|
-
childCount: 3,
|
|
2548
|
-
className: Row,
|
|
2549
|
-
role: Row$1,
|
|
2550
|
-
type: Tr
|
|
2551
|
-
}, ...['Name', 'PID', 'Memory'].flatMap(label => [{
|
|
2552
|
-
childCount: 1,
|
|
2553
|
-
className: HeaderCell,
|
|
2554
|
-
type: Th
|
|
2555
|
-
}, text(label)])];
|
|
2799
|
+
return [tableHeadNode, headerRowNode, ...['Name', 'PID', 'Memory'].flatMap(label => [headerCellNode, text(label)])];
|
|
2556
2800
|
};
|
|
2557
2801
|
const getRowDom = (process, index, focused) => {
|
|
2558
2802
|
return [{
|
|
2559
|
-
ariaDescription: '',
|
|
2560
2803
|
ariaExpanded: getAriaExpanded(process),
|
|
2561
2804
|
ariaLevel: process.depth,
|
|
2562
2805
|
childCount: 3,
|
|
@@ -2567,7 +2810,7 @@ const getRowDom = (process, index, focused) => {
|
|
|
2567
2810
|
tabIndex: focused ? 0 : -1,
|
|
2568
2811
|
title: process.cmd,
|
|
2569
2812
|
type: Tr
|
|
2570
|
-
}, ...getCellDom(
|
|
2813
|
+
}, ...getCellDom(mergeClassNames(Cell, NameCell), process.name, index, getPaddingLeft(process)), ...getCellDom(Cell, String(process.pid), index), ...getCellDom(Cell, formatMemory(process.memory), index)];
|
|
2571
2814
|
};
|
|
2572
2815
|
const getBodyDom = state => {
|
|
2573
2816
|
const {
|
|
@@ -2591,16 +2834,26 @@ const getErrorSectionDom = (value, type) => {
|
|
|
2591
2834
|
}, text(value)];
|
|
2592
2835
|
};
|
|
2593
2836
|
const hasError = state => {
|
|
2594
|
-
|
|
2837
|
+
const {
|
|
2838
|
+
errorCodeFrame,
|
|
2839
|
+
errorMessage,
|
|
2840
|
+
errorStack
|
|
2841
|
+
} = state;
|
|
2842
|
+
return Boolean(errorMessage || errorCodeFrame || errorStack);
|
|
2595
2843
|
};
|
|
2596
2844
|
const getErrorDom = state => {
|
|
2597
|
-
const
|
|
2598
|
-
|
|
2599
|
-
|
|
2845
|
+
const {
|
|
2846
|
+
errorCodeFrame,
|
|
2847
|
+
errorMessage,
|
|
2848
|
+
errorStack
|
|
2849
|
+
} = state;
|
|
2850
|
+
const messageDom = getErrorSectionDom(errorMessage, Div);
|
|
2851
|
+
const codeFrameDom = getErrorSectionDom(errorCodeFrame, Pre);
|
|
2852
|
+
const stackDom = getErrorSectionDom(errorStack, Pre);
|
|
2600
2853
|
const childCount = messageDom.length / 2 + codeFrameDom.length / 2 + stackDom.length / 2;
|
|
2601
2854
|
return [{
|
|
2602
2855
|
childCount: 1,
|
|
2603
|
-
className:
|
|
2856
|
+
className: mergeClassNames(Viewlet, ProcessExplorer),
|
|
2604
2857
|
role: None,
|
|
2605
2858
|
type: Div
|
|
2606
2859
|
}, {
|
|
@@ -2610,14 +2863,17 @@ const getErrorDom = state => {
|
|
|
2610
2863
|
}, ...messageDom, ...codeFrameDom, ...stackDom];
|
|
2611
2864
|
};
|
|
2612
2865
|
const getTableDom = state => {
|
|
2866
|
+
const {
|
|
2867
|
+
visibleProcesses
|
|
2868
|
+
} = state;
|
|
2613
2869
|
return [{
|
|
2614
2870
|
childCount: 1,
|
|
2615
|
-
className:
|
|
2871
|
+
className: mergeClassNames(Viewlet, ProcessExplorer),
|
|
2616
2872
|
role: None,
|
|
2617
2873
|
type: Div
|
|
2618
2874
|
}, {
|
|
2619
2875
|
ariaLabel: 'Process Explorer',
|
|
2620
|
-
ariaRowCount:
|
|
2876
|
+
ariaRowCount: visibleProcesses.length + 1,
|
|
2621
2877
|
childCount: 2,
|
|
2622
2878
|
className: Table,
|
|
2623
2879
|
onBlur: HandleBlur,
|
|
@@ -2627,12 +2883,15 @@ const getTableDom = state => {
|
|
|
2627
2883
|
onFocus: HandleFocus,
|
|
2628
2884
|
onPointerDown: HandlePointerDown,
|
|
2629
2885
|
role: Grid,
|
|
2630
|
-
tabIndex:
|
|
2886
|
+
tabIndex: Focusable,
|
|
2631
2887
|
type: Table$1
|
|
2632
2888
|
}, ...getHeaderDom(), ...getBodyDom(state)];
|
|
2633
2889
|
};
|
|
2634
2890
|
const getDom = state => {
|
|
2635
|
-
|
|
2891
|
+
const {
|
|
2892
|
+
initial
|
|
2893
|
+
} = state;
|
|
2894
|
+
if (initial) {
|
|
2636
2895
|
return [];
|
|
2637
2896
|
}
|
|
2638
2897
|
if (hasError(state)) {
|
|
@@ -2696,19 +2955,19 @@ const renderEventListeners = () => {
|
|
|
2696
2955
|
params: ['handleBlur']
|
|
2697
2956
|
}, {
|
|
2698
2957
|
name: HandleClick,
|
|
2699
|
-
params: ['handleClickAt',
|
|
2958
|
+
params: ['handleClickAt', 'event.target.dataset.index'],
|
|
2700
2959
|
preventDefault: true
|
|
2701
2960
|
}, {
|
|
2702
2961
|
name: HandleDoubleClick,
|
|
2703
|
-
params: ['handleDoubleClick',
|
|
2962
|
+
params: ['handleDoubleClick', 'event.target.dataset.index'],
|
|
2704
2963
|
preventDefault: true
|
|
2705
2964
|
}, {
|
|
2706
2965
|
name: HandleContextMenu,
|
|
2707
|
-
params: ['handleContextMenu',
|
|
2966
|
+
params: ['handleContextMenu', 'event.target.dataset.index', ClientX, ClientY],
|
|
2708
2967
|
preventDefault: true
|
|
2709
2968
|
}, {
|
|
2710
2969
|
name: HandlePointerDown,
|
|
2711
|
-
params: ['handleClickAt',
|
|
2970
|
+
params: ['handleClickAt', 'event.target.dataset.index']
|
|
2712
2971
|
}];
|
|
2713
2972
|
};
|
|
2714
2973
|
|
|
@@ -2762,6 +3021,14 @@ const setRootProcessId = (state, rootPid) => {
|
|
|
2762
3021
|
};
|
|
2763
3022
|
};
|
|
2764
3023
|
|
|
3024
|
+
const setUpdateInterval = (state, updateInterval) => {
|
|
3025
|
+
restart(state.uid, updateInterval);
|
|
3026
|
+
return {
|
|
3027
|
+
...state,
|
|
3028
|
+
updateInterval
|
|
3029
|
+
};
|
|
3030
|
+
};
|
|
3031
|
+
|
|
2765
3032
|
const commandMap = {
|
|
2766
3033
|
'ProcessExplorer.collapseAll': wrapCommand(collapseAll),
|
|
2767
3034
|
'ProcessExplorer.create': create$d,
|
|
@@ -2793,6 +3060,7 @@ const commandMap = {
|
|
|
2793
3060
|
'ProcessExplorer.renderEventListeners': renderEventListeners,
|
|
2794
3061
|
'ProcessExplorer.setError': wrapCommand(setError),
|
|
2795
3062
|
'ProcessExplorer.setRootProcessId': wrapCommand(setRootProcessId),
|
|
3063
|
+
'ProcessExplorer.setUpdateInterval': wrapCommand(setUpdateInterval),
|
|
2796
3064
|
'ProcessExplorer.terminate': terminate,
|
|
2797
3065
|
'ProcessExplorer.update': wrapCommand(refresh)
|
|
2798
3066
|
};
|