@lvce-editor/process-explorer-worker 3.0.0 → 3.1.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 +95 -19
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -184,7 +184,7 @@ const {
|
|
|
184
184
|
get: get$2,
|
|
185
185
|
getCommandIds,
|
|
186
186
|
registerCommands,
|
|
187
|
-
set: set$
|
|
187
|
+
set: set$5,
|
|
188
188
|
wrapCommand,
|
|
189
189
|
wrapLoadContent
|
|
190
190
|
} = create$a();
|
|
@@ -193,7 +193,9 @@ const create$9 = (id, _uri, x, y, width, height, _args, parentUid, _platform = 0
|
|
|
193
193
|
const state = {
|
|
194
194
|
assetDir,
|
|
195
195
|
collapsedPids: [],
|
|
196
|
+
errorCodeFrame: '',
|
|
196
197
|
errorMessage: '',
|
|
198
|
+
errorStack: '',
|
|
197
199
|
focus: 0,
|
|
198
200
|
focused: false,
|
|
199
201
|
focusedIndex: -1,
|
|
@@ -208,7 +210,7 @@ const create$9 = (id, _uri, x, y, width, height, _args, parentUid, _platform = 0
|
|
|
208
210
|
x,
|
|
209
211
|
y
|
|
210
212
|
};
|
|
211
|
-
set$
|
|
213
|
+
set$5(state.uid, state, state);
|
|
212
214
|
return state;
|
|
213
215
|
};
|
|
214
216
|
|
|
@@ -217,7 +219,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
217
219
|
};
|
|
218
220
|
|
|
219
221
|
const isEqual = (oldState, newState) => {
|
|
220
|
-
return oldState.initial === newState.initial && oldState.errorMessage === newState.errorMessage && oldState.visibleProcesses === newState.visibleProcesses;
|
|
222
|
+
return oldState.initial === newState.initial && oldState.errorCodeFrame === newState.errorCodeFrame && oldState.errorMessage === newState.errorMessage && oldState.errorStack === newState.errorStack && oldState.visibleProcesses === newState.visibleProcesses;
|
|
221
223
|
};
|
|
222
224
|
|
|
223
225
|
const RenderItems = 1;
|
|
@@ -305,6 +307,7 @@ const Text = 12;
|
|
|
305
307
|
const Th = 13;
|
|
306
308
|
const THead = 14;
|
|
307
309
|
const Tr = 15;
|
|
310
|
+
const Pre = 51;
|
|
308
311
|
|
|
309
312
|
const ClientX = 'event.clientX';
|
|
310
313
|
const ClientY = 'event.clientY';
|
|
@@ -323,6 +326,7 @@ const Star = 131;
|
|
|
323
326
|
|
|
324
327
|
const CtrlCmd = 1 << 11 >>> 0;
|
|
325
328
|
|
|
329
|
+
const ErrorWorker = 3308;
|
|
326
330
|
const FileSystemWorker$1 = 209;
|
|
327
331
|
const RendererWorker = 1;
|
|
328
332
|
|
|
@@ -1487,7 +1491,7 @@ const createMockRpc = ({
|
|
|
1487
1491
|
};
|
|
1488
1492
|
|
|
1489
1493
|
const rpcs = Object.create(null);
|
|
1490
|
-
const set$
|
|
1494
|
+
const set$4 = (id, rpc) => {
|
|
1491
1495
|
rpcs[id] = rpc;
|
|
1492
1496
|
};
|
|
1493
1497
|
const get = id => {
|
|
@@ -1520,7 +1524,7 @@ const create = rpcId => {
|
|
|
1520
1524
|
const mockRpc = createMockRpc({
|
|
1521
1525
|
commandMap
|
|
1522
1526
|
});
|
|
1523
|
-
set$
|
|
1527
|
+
set$4(rpcId, mockRpc);
|
|
1524
1528
|
// @ts-ignore
|
|
1525
1529
|
mockRpc[Symbol.dispose] = () => {
|
|
1526
1530
|
remove(rpcId);
|
|
@@ -1529,11 +1533,19 @@ const create = rpcId => {
|
|
|
1529
1533
|
return mockRpc;
|
|
1530
1534
|
},
|
|
1531
1535
|
set(rpc) {
|
|
1532
|
-
set$
|
|
1536
|
+
set$4(rpcId, rpc);
|
|
1533
1537
|
}
|
|
1534
1538
|
};
|
|
1535
1539
|
};
|
|
1536
1540
|
|
|
1541
|
+
const {
|
|
1542
|
+
invoke: invoke$2,
|
|
1543
|
+
set: set$3
|
|
1544
|
+
} = create(ErrorWorker);
|
|
1545
|
+
const prepare = async error => {
|
|
1546
|
+
return invoke$2('Errors.prepare', error);
|
|
1547
|
+
};
|
|
1548
|
+
|
|
1537
1549
|
const {
|
|
1538
1550
|
set: set$2
|
|
1539
1551
|
} = create(FileSystemWorker$1);
|
|
@@ -1548,6 +1560,10 @@ const {
|
|
|
1548
1560
|
invokeAndTransfer,
|
|
1549
1561
|
set: set$1
|
|
1550
1562
|
} = create(RendererWorker);
|
|
1563
|
+
const sendMessagePortToErrorWorker$1 = async (port, rpcId) => {
|
|
1564
|
+
const command = 'Errors.handleMessagePort';
|
|
1565
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
|
|
1566
|
+
};
|
|
1551
1567
|
const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
|
|
1552
1568
|
const command = 'FileSystem.handleMessagePort';
|
|
1553
1569
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
@@ -1623,6 +1639,17 @@ const getErrorMessage = error => {
|
|
|
1623
1639
|
}
|
|
1624
1640
|
return String(error);
|
|
1625
1641
|
};
|
|
1642
|
+
const prepareError = async error => {
|
|
1643
|
+
try {
|
|
1644
|
+
return await prepare(error);
|
|
1645
|
+
} catch {
|
|
1646
|
+
return {
|
|
1647
|
+
codeFrame: undefined,
|
|
1648
|
+
message: getErrorMessage(error),
|
|
1649
|
+
stack: undefined
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1626
1653
|
const getFocusedIndex = (oldFocusedIndex, visibleProcesses) => {
|
|
1627
1654
|
if (visibleProcesses.length === 0) {
|
|
1628
1655
|
return -1;
|
|
@@ -1639,7 +1666,9 @@ const refresh = async state => {
|
|
|
1639
1666
|
const visibleProcesses = getVisibleProcesses(processes, state.collapsedPids, rootPid);
|
|
1640
1667
|
return {
|
|
1641
1668
|
...state,
|
|
1669
|
+
errorCodeFrame: '',
|
|
1642
1670
|
errorMessage: '',
|
|
1671
|
+
errorStack: '',
|
|
1643
1672
|
focusedIndex: getFocusedIndex(state.focusedIndex, visibleProcesses),
|
|
1644
1673
|
initial: false,
|
|
1645
1674
|
processes,
|
|
@@ -1647,9 +1676,12 @@ const refresh = async state => {
|
|
|
1647
1676
|
visibleProcesses
|
|
1648
1677
|
};
|
|
1649
1678
|
} catch (error) {
|
|
1679
|
+
const prettyError = await prepareError(error);
|
|
1650
1680
|
return {
|
|
1651
1681
|
...state,
|
|
1652
|
-
|
|
1682
|
+
errorCodeFrame: prettyError.codeFrame || '',
|
|
1683
|
+
errorMessage: prettyError.message || getErrorMessage(error),
|
|
1684
|
+
errorStack: prettyError.stack || '',
|
|
1653
1685
|
initial: false
|
|
1654
1686
|
};
|
|
1655
1687
|
}
|
|
@@ -1810,23 +1842,37 @@ const getBodyDom = state => {
|
|
|
1810
1842
|
type: TBody
|
|
1811
1843
|
}, ...visibleProcesses.flatMap((process, index) => getRowDom(process, index, index === focusedIndex))];
|
|
1812
1844
|
};
|
|
1813
|
-
const
|
|
1814
|
-
if (!
|
|
1845
|
+
const getErrorSectionDom = (value, type) => {
|
|
1846
|
+
if (!value) {
|
|
1815
1847
|
return [];
|
|
1816
1848
|
}
|
|
1817
1849
|
return [{
|
|
1818
1850
|
childCount: 1,
|
|
1851
|
+
type
|
|
1852
|
+
}, text(value)];
|
|
1853
|
+
};
|
|
1854
|
+
const hasError = state => {
|
|
1855
|
+
return Boolean(state.errorMessage || state.errorCodeFrame || state.errorStack);
|
|
1856
|
+
};
|
|
1857
|
+
const getErrorDom = state => {
|
|
1858
|
+
const messageDom = getErrorSectionDom(state.errorMessage, Div);
|
|
1859
|
+
const codeFrameDom = getErrorSectionDom(state.errorCodeFrame, Pre);
|
|
1860
|
+
const stackDom = getErrorSectionDom(state.errorStack, Pre);
|
|
1861
|
+
const childCount = messageDom.length / 2 + codeFrameDom.length / 2 + stackDom.length / 2;
|
|
1862
|
+
return [{
|
|
1863
|
+
childCount: 1,
|
|
1864
|
+
className: `${Viewlet} ${ProcessExplorer}`,
|
|
1865
|
+
role: None,
|
|
1866
|
+
type: Div
|
|
1867
|
+
}, {
|
|
1868
|
+
childCount,
|
|
1819
1869
|
className: Error$1,
|
|
1820
1870
|
type: Div
|
|
1821
|
-
},
|
|
1871
|
+
}, ...messageDom, ...codeFrameDom, ...stackDom];
|
|
1822
1872
|
};
|
|
1823
|
-
const
|
|
1824
|
-
if (state.initial) {
|
|
1825
|
-
return [];
|
|
1826
|
-
}
|
|
1827
|
-
const errorDom = getErrorDom(state.errorMessage);
|
|
1873
|
+
const getTableDom = state => {
|
|
1828
1874
|
return [{
|
|
1829
|
-
childCount: 1
|
|
1875
|
+
childCount: 1,
|
|
1830
1876
|
className: `${Viewlet} ${ProcessExplorer}`,
|
|
1831
1877
|
role: None,
|
|
1832
1878
|
type: Div
|
|
@@ -1844,7 +1890,16 @@ const getDom = state => {
|
|
|
1844
1890
|
role: Grid,
|
|
1845
1891
|
tabIndex: 0,
|
|
1846
1892
|
type: Table$1
|
|
1847
|
-
}, ...getHeaderDom(), ...getBodyDom(state)
|
|
1893
|
+
}, ...getHeaderDom(), ...getBodyDom(state)];
|
|
1894
|
+
};
|
|
1895
|
+
const getDom = state => {
|
|
1896
|
+
if (state.initial) {
|
|
1897
|
+
return [];
|
|
1898
|
+
}
|
|
1899
|
+
if (hasError(state)) {
|
|
1900
|
+
return getErrorDom(state);
|
|
1901
|
+
}
|
|
1902
|
+
return getTableDom(state);
|
|
1848
1903
|
};
|
|
1849
1904
|
const renderItems = (oldState, newState) => {
|
|
1850
1905
|
return [SetDom2, newState.uid, getDom(newState)];
|
|
@@ -1880,7 +1935,7 @@ const render2 = (uid, diffResult) => {
|
|
|
1880
1935
|
oldState,
|
|
1881
1936
|
scheduledState
|
|
1882
1937
|
} = get$2(uid);
|
|
1883
|
-
set$
|
|
1938
|
+
set$5(uid, scheduledState, scheduledState);
|
|
1884
1939
|
return applyRender(oldState, scheduledState, diffResult);
|
|
1885
1940
|
};
|
|
1886
1941
|
|
|
@@ -1934,6 +1989,27 @@ const commandMap = {
|
|
|
1934
1989
|
'ProcessExplorer.terminate': terminate
|
|
1935
1990
|
};
|
|
1936
1991
|
|
|
1992
|
+
const sendMessagePortToErrorWorker = async port => {
|
|
1993
|
+
await sendMessagePortToErrorWorker$1(port, 0);
|
|
1994
|
+
};
|
|
1995
|
+
|
|
1996
|
+
const createErrorWorkerRpc = async () => {
|
|
1997
|
+
try {
|
|
1998
|
+
const rpc = await create$2({
|
|
1999
|
+
commandMap: {},
|
|
2000
|
+
send: sendMessagePortToErrorWorker
|
|
2001
|
+
});
|
|
2002
|
+
return rpc;
|
|
2003
|
+
} catch (error) {
|
|
2004
|
+
throw new VError(error, `Failed to create error worker rpc`);
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
|
|
2008
|
+
const initializeErrorWorker = async () => {
|
|
2009
|
+
const rpc = await createErrorWorkerRpc();
|
|
2010
|
+
set$3(rpc);
|
|
2011
|
+
};
|
|
2012
|
+
|
|
1937
2013
|
const sendMessagePortToFileSystemWorker = async port => {
|
|
1938
2014
|
await sendMessagePortToFileSystemWorker$1(port, 0);
|
|
1939
2015
|
};
|
|
@@ -1964,7 +2040,7 @@ const initializeRendererWorker = async () => {
|
|
|
1964
2040
|
|
|
1965
2041
|
const listen = async () => {
|
|
1966
2042
|
registerCommands(commandMap);
|
|
1967
|
-
await Promise.all([initializeRendererWorker(), initializeFileSystemWorker()]);
|
|
2043
|
+
await Promise.all([initializeRendererWorker(), initializeFileSystemWorker(), initializeErrorWorker()]);
|
|
1968
2044
|
};
|
|
1969
2045
|
|
|
1970
2046
|
const main = async () => {
|