@lvce-editor/output-view 2.24.0 → 2.24.2
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/dist/outputViewWorkerMain.js +277 -207
- package/package.json +1 -1
|
@@ -645,6 +645,9 @@ const restoreExistingError = (error, currentStack) => {
|
|
|
645
645
|
};
|
|
646
646
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
647
647
|
const restoredError = new JsonRpcError(error.message);
|
|
648
|
+
Object.assign(restoredError, {
|
|
649
|
+
code: error.code
|
|
650
|
+
});
|
|
648
651
|
const parentStack = getParentStack(error);
|
|
649
652
|
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
650
653
|
return restoredError;
|
|
@@ -664,9 +667,13 @@ const applyDataProperties = (restoredError, error) => {
|
|
|
664
667
|
// @ts-ignore
|
|
665
668
|
restoredError.codeFrame = error.data.codeFrame;
|
|
666
669
|
}
|
|
667
|
-
if (error.data.code) {
|
|
670
|
+
if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
|
|
668
671
|
// @ts-ignore
|
|
669
|
-
restoredError
|
|
672
|
+
Object.defineProperty(restoredError, 'code', {
|
|
673
|
+
configurable: true,
|
|
674
|
+
value: error.data.code,
|
|
675
|
+
writable: true
|
|
676
|
+
});
|
|
670
677
|
}
|
|
671
678
|
if (error.data.type) {
|
|
672
679
|
// @ts-ignore
|
|
@@ -688,6 +695,13 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
688
695
|
};
|
|
689
696
|
const restoreMessageError = (error, _currentStack) => {
|
|
690
697
|
const restoredError = constructError(error.message, error.type, error.name);
|
|
698
|
+
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
699
|
+
Object.defineProperty(restoredError, 'code', {
|
|
700
|
+
configurable: true,
|
|
701
|
+
value: error.code,
|
|
702
|
+
writable: true
|
|
703
|
+
});
|
|
704
|
+
}
|
|
691
705
|
if (error.data) {
|
|
692
706
|
applyDataProperties(restoredError, error);
|
|
693
707
|
} else {
|
|
@@ -766,7 +780,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
766
780
|
return {
|
|
767
781
|
code: Custom,
|
|
768
782
|
data: {
|
|
769
|
-
code: prettyError.code,
|
|
783
|
+
code: prettyError.code ?? error?.code,
|
|
770
784
|
codeFrame: prettyError.codeFrame,
|
|
771
785
|
name: prettyError.name,
|
|
772
786
|
stack: getStack(prettyError),
|
|
@@ -803,7 +817,12 @@ const getErrorResponseSimple = (id, error) => {
|
|
|
803
817
|
return {
|
|
804
818
|
error: {
|
|
805
819
|
code: Custom,
|
|
806
|
-
data: error
|
|
820
|
+
data: error instanceof Error ? {
|
|
821
|
+
...error,
|
|
822
|
+
code: 'code' in error ? error.code : undefined,
|
|
823
|
+
stack: error.stack,
|
|
824
|
+
type: error.name
|
|
825
|
+
} : error,
|
|
807
826
|
// @ts-ignore
|
|
808
827
|
message: error.message
|
|
809
828
|
},
|
|
@@ -1210,6 +1229,9 @@ const readFile = async uri => {
|
|
|
1210
1229
|
const writeFile = async (uri, content) => {
|
|
1211
1230
|
return invoke$3('FileSystem.writeFile', uri, content);
|
|
1212
1231
|
};
|
|
1232
|
+
const exists = async uri => {
|
|
1233
|
+
return invoke$3('FileSystem.exists', uri);
|
|
1234
|
+
};
|
|
1213
1235
|
const watchFile = async (watchId, uri, rpcId) => {
|
|
1214
1236
|
await invoke$3('FileSystem.watchFile', watchId, uri, rpcId);
|
|
1215
1237
|
};
|
|
@@ -1819,6 +1841,214 @@ const text = data => {
|
|
|
1819
1841
|
};
|
|
1820
1842
|
};
|
|
1821
1843
|
|
|
1844
|
+
const HandleBlur = 'handleBlur';
|
|
1845
|
+
const HandleClearFilterClick = 'handleClearFilterClick';
|
|
1846
|
+
const HandleContextMenu = 'handleContextMenu';
|
|
1847
|
+
const HandleFilterInput = 'handleFilterInput';
|
|
1848
|
+
const HandlePointerDown = 'handlePointerDown';
|
|
1849
|
+
const HandleSelect = 'handleSelect';
|
|
1850
|
+
const HandleButtonClick = 'handleButtonClick';
|
|
1851
|
+
const HandleSourceLinkClick = 'handleSourceLinkClick';
|
|
1852
|
+
const HandleWheel = 'handleWheel';
|
|
1853
|
+
const HandleKeyDown = 'handleKeyDown';
|
|
1854
|
+
const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
|
|
1855
|
+
const HandleScrollBarMove = 'handleScrollBarMove';
|
|
1856
|
+
const HandleScrollBarPointerCaptureLost = 'handleScrollBarPointerCaptureLost';
|
|
1857
|
+
|
|
1858
|
+
const noNodes = [];
|
|
1859
|
+
const repeatCountNode = {
|
|
1860
|
+
childCount: 1,
|
|
1861
|
+
className: OutputRepeatCount,
|
|
1862
|
+
type: Span
|
|
1863
|
+
};
|
|
1864
|
+
const spaceNode = text(' ');
|
|
1865
|
+
const getLevel = parts => {
|
|
1866
|
+
return parts.find(part => part.type === LogLevel)?.value || '';
|
|
1867
|
+
};
|
|
1868
|
+
const getLinePartDom = part => {
|
|
1869
|
+
switch (part.type) {
|
|
1870
|
+
case Link:
|
|
1871
|
+
{
|
|
1872
|
+
const isSourceLink = part.className === OutputSourceLink;
|
|
1873
|
+
const linkNode = {
|
|
1874
|
+
childCount: 1,
|
|
1875
|
+
href: part.value,
|
|
1876
|
+
rel: 'noopener noreferrer',
|
|
1877
|
+
target: '_blank',
|
|
1878
|
+
type: A,
|
|
1879
|
+
...(part.className && {
|
|
1880
|
+
className: part.className
|
|
1881
|
+
}),
|
|
1882
|
+
...(part.columnNumber !== undefined && {
|
|
1883
|
+
'data-column': part.columnNumber
|
|
1884
|
+
}),
|
|
1885
|
+
...(part.lineNumber !== undefined && {
|
|
1886
|
+
'data-line': part.lineNumber
|
|
1887
|
+
}),
|
|
1888
|
+
...(isSourceLink && {
|
|
1889
|
+
onClick: HandleSourceLinkClick
|
|
1890
|
+
})
|
|
1891
|
+
};
|
|
1892
|
+
return {
|
|
1893
|
+
childCount: 1,
|
|
1894
|
+
nodes: [linkNode, text(part.label || part.value)]
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
case RepeatCount:
|
|
1898
|
+
return {
|
|
1899
|
+
childCount: 2,
|
|
1900
|
+
nodes: [repeatCountNode, text(part.value), spaceNode]
|
|
1901
|
+
};
|
|
1902
|
+
case Text:
|
|
1903
|
+
return {
|
|
1904
|
+
childCount: 1,
|
|
1905
|
+
nodes: [text(part.value)]
|
|
1906
|
+
};
|
|
1907
|
+
default:
|
|
1908
|
+
return {
|
|
1909
|
+
childCount: 0,
|
|
1910
|
+
nodes: noNodes
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
const getLineDom = parts => {
|
|
1915
|
+
const children = [];
|
|
1916
|
+
let childCount = 0;
|
|
1917
|
+
for (const part of parts) {
|
|
1918
|
+
const partDom = getLinePartDom(part);
|
|
1919
|
+
children.push(...partDom.nodes);
|
|
1920
|
+
childCount += partDom.childCount;
|
|
1921
|
+
}
|
|
1922
|
+
const level = getLevel(parts);
|
|
1923
|
+
const className = level ? mergeClassNames(Line, level) : Line;
|
|
1924
|
+
const lineNode = {
|
|
1925
|
+
childCount,
|
|
1926
|
+
className,
|
|
1927
|
+
type: Div
|
|
1928
|
+
};
|
|
1929
|
+
return [lineNode, ...children];
|
|
1930
|
+
};
|
|
1931
|
+
|
|
1932
|
+
const Focusable = 0;
|
|
1933
|
+
|
|
1934
|
+
const getContentDom = (lines, error) => {
|
|
1935
|
+
if (error) {
|
|
1936
|
+
return [];
|
|
1937
|
+
}
|
|
1938
|
+
return [{
|
|
1939
|
+
childCount: lines.length,
|
|
1940
|
+
className: OutputContent,
|
|
1941
|
+
onKeyDown: HandleKeyDown,
|
|
1942
|
+
onWheel: HandleWheel,
|
|
1943
|
+
role: Log,
|
|
1944
|
+
tabIndex: Focusable,
|
|
1945
|
+
type: Div
|
|
1946
|
+
}, ...lines.flatMap(getLineDom)];
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1949
|
+
const LogFileNotFound$1 = 1;
|
|
1950
|
+
|
|
1951
|
+
const emptyObject = {};
|
|
1952
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
1953
|
+
if (placeholders === emptyObject) {
|
|
1954
|
+
return key;
|
|
1955
|
+
}
|
|
1956
|
+
let result = key;
|
|
1957
|
+
for (const [placeholder, replacement] of Object.entries(placeholders)) {
|
|
1958
|
+
result = result.split(`{${placeholder}}`).join(String(replacement));
|
|
1959
|
+
}
|
|
1960
|
+
return result;
|
|
1961
|
+
};
|
|
1962
|
+
|
|
1963
|
+
const ClearOutput = 'clear output';
|
|
1964
|
+
const Filter$1 = 'Filter';
|
|
1965
|
+
const LogFileNotFound = 'The log file was not found.';
|
|
1966
|
+
const Settings$1 = 'Settings';
|
|
1967
|
+
const TurnOffAutoScroll = 'Turn auto scrolling off';
|
|
1968
|
+
|
|
1969
|
+
const clearOutput = () => {
|
|
1970
|
+
return i18nString(ClearOutput);
|
|
1971
|
+
};
|
|
1972
|
+
const turnOffAutoScroll = () => {
|
|
1973
|
+
return i18nString(TurnOffAutoScroll);
|
|
1974
|
+
};
|
|
1975
|
+
const settings = () => {
|
|
1976
|
+
return i18nString(Settings$1);
|
|
1977
|
+
};
|
|
1978
|
+
const logFileNotFound = () => {
|
|
1979
|
+
return i18nString(LogFileNotFound);
|
|
1980
|
+
};
|
|
1981
|
+
const filter = () => {
|
|
1982
|
+
return i18nString(Filter$1);
|
|
1983
|
+
};
|
|
1984
|
+
|
|
1985
|
+
const messageNode = {
|
|
1986
|
+
childCount: 1,
|
|
1987
|
+
className: Message,
|
|
1988
|
+
tabIndex: Focusable,
|
|
1989
|
+
type: Div
|
|
1990
|
+
};
|
|
1991
|
+
const getLogFileNotFoundDom = () => {
|
|
1992
|
+
return [messageNode, text(logFileNotFound())];
|
|
1993
|
+
};
|
|
1994
|
+
|
|
1995
|
+
const errorNode = {
|
|
1996
|
+
childCount: 1,
|
|
1997
|
+
className: Error$1,
|
|
1998
|
+
tabIndex: Focusable,
|
|
1999
|
+
type: Div
|
|
2000
|
+
};
|
|
2001
|
+
const getErrorDom = (errorCode, error) => {
|
|
2002
|
+
if (!error) {
|
|
2003
|
+
return [];
|
|
2004
|
+
}
|
|
2005
|
+
if (errorCode === LogFileNotFound$1) {
|
|
2006
|
+
return getLogFileNotFoundDom();
|
|
2007
|
+
}
|
|
2008
|
+
return [errorNode, text(error)];
|
|
2009
|
+
};
|
|
2010
|
+
|
|
2011
|
+
const scrollBarNode = {
|
|
2012
|
+
childCount: 1,
|
|
2013
|
+
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
2014
|
+
onPointerDown: HandleScrollBarPointerDown,
|
|
2015
|
+
type: Div
|
|
2016
|
+
};
|
|
2017
|
+
const getScrollBarVirtualDom = (scrollBarHeight, scrollBarActive) => {
|
|
2018
|
+
if (scrollBarHeight <= 0) {
|
|
2019
|
+
return [];
|
|
2020
|
+
}
|
|
2021
|
+
return [scrollBarNode, {
|
|
2022
|
+
childCount: 0,
|
|
2023
|
+
className: mergeClassNames(ScrollBarThumb, scrollBarActive ? ScrollBarThumbActive : ''),
|
|
2024
|
+
type: Div
|
|
2025
|
+
}];
|
|
2026
|
+
};
|
|
2027
|
+
|
|
2028
|
+
const outputNode = {
|
|
2029
|
+
childCount: 1,
|
|
2030
|
+
className: mergeClassNames(Viewlet, Output$1),
|
|
2031
|
+
type: Div
|
|
2032
|
+
};
|
|
2033
|
+
const getOutputVirtualDom = (lines, errorCode, error, scrollBarHeight = 0, scrollBarActive = false) => {
|
|
2034
|
+
const scrollBarDom = error ? [] : getScrollBarVirtualDom(scrollBarHeight, scrollBarActive);
|
|
2035
|
+
return [{
|
|
2036
|
+
...outputNode,
|
|
2037
|
+
childCount: scrollBarDom.length > 0 ? 2 : 1
|
|
2038
|
+
}, ...getContentDom(lines, error), ...getErrorDom(errorCode, error), ...scrollBarDom];
|
|
2039
|
+
};
|
|
2040
|
+
|
|
2041
|
+
const getComponentDom = uid => {
|
|
2042
|
+
const {
|
|
2043
|
+
newState
|
|
2044
|
+
} = get(uid);
|
|
2045
|
+
return getOutputVirtualDom(newState.filteredItems.slice(newState.minLineY, newState.maxLineY), newState.errorCode, newState.error, newState.scrollBarHeight, newState.scrollBarActive);
|
|
2046
|
+
};
|
|
2047
|
+
|
|
2048
|
+
const getComponentState = uid => {
|
|
2049
|
+
return get(uid).newState;
|
|
2050
|
+
};
|
|
2051
|
+
|
|
1822
2052
|
const FocusProblems = 19;
|
|
1823
2053
|
|
|
1824
2054
|
const getKeyBindings = () => {
|
|
@@ -1869,13 +2099,14 @@ const getKeyBindings = () => {
|
|
|
1869
2099
|
}];
|
|
1870
2100
|
};
|
|
1871
2101
|
|
|
1872
|
-
const Filter
|
|
2102
|
+
const Filter = 'filter';
|
|
1873
2103
|
const Output = 'output';
|
|
1874
2104
|
const MainProcess = 'MainProcess';
|
|
1875
2105
|
const SharedProcess = 'SharedProcess';
|
|
1876
2106
|
const Window = 'Window';
|
|
2107
|
+
const PreviewSandbox = 'PreviewSandbox';
|
|
1877
2108
|
const Clear = 'Clear';
|
|
1878
|
-
const Settings
|
|
2109
|
+
const Settings = 'Settings';
|
|
1879
2110
|
const ScrollLock = 'ScrollLock';
|
|
1880
2111
|
|
|
1881
2112
|
const noop = async state => {
|
|
@@ -2224,40 +2455,6 @@ const getSelectedItem = (selectedOption, platform) => {
|
|
|
2224
2455
|
return MainProcess;
|
|
2225
2456
|
};
|
|
2226
2457
|
|
|
2227
|
-
const emptyObject = {};
|
|
2228
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
2229
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
2230
|
-
if (placeholders === emptyObject) {
|
|
2231
|
-
return key;
|
|
2232
|
-
}
|
|
2233
|
-
const replacer = (match, rest) => {
|
|
2234
|
-
return placeholders[rest];
|
|
2235
|
-
};
|
|
2236
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
2237
|
-
};
|
|
2238
|
-
|
|
2239
|
-
const ClearOutput = 'clear output';
|
|
2240
|
-
const Filter = 'Filter';
|
|
2241
|
-
const LogFileNotFound$1 = 'The log file was not found.';
|
|
2242
|
-
const Settings = 'Settings';
|
|
2243
|
-
const TurnOffAutoScroll = 'Turn auto scrolling off';
|
|
2244
|
-
|
|
2245
|
-
const clearOutput = () => {
|
|
2246
|
-
return i18nString(ClearOutput);
|
|
2247
|
-
};
|
|
2248
|
-
const turnOffAutoScroll = () => {
|
|
2249
|
-
return i18nString(TurnOffAutoScroll);
|
|
2250
|
-
};
|
|
2251
|
-
const settings = () => {
|
|
2252
|
-
return i18nString(Settings);
|
|
2253
|
-
};
|
|
2254
|
-
const logFileNotFound = () => {
|
|
2255
|
-
return i18nString(LogFileNotFound$1);
|
|
2256
|
-
};
|
|
2257
|
-
const filter = () => {
|
|
2258
|
-
return i18nString(Filter);
|
|
2259
|
-
};
|
|
2260
|
-
|
|
2261
2458
|
const loadButtons = () => {
|
|
2262
2459
|
return [{
|
|
2263
2460
|
icon: 'MaskIconClearAll',
|
|
@@ -2269,7 +2466,7 @@ const loadButtons = () => {
|
|
|
2269
2466
|
label: turnOffAutoScroll()
|
|
2270
2467
|
}, {
|
|
2271
2468
|
icon: 'MaskIconSettingsGear',
|
|
2272
|
-
id: Settings
|
|
2469
|
+
id: Settings,
|
|
2273
2470
|
label: settings()
|
|
2274
2471
|
}];
|
|
2275
2472
|
};
|
|
@@ -2346,6 +2543,14 @@ const loadOptions = async platform => {
|
|
|
2346
2543
|
return [...detailOptions, ...extensionOptions];
|
|
2347
2544
|
}
|
|
2348
2545
|
const logsFolderUri = await getLogsDir();
|
|
2546
|
+
const previewSandboxLogUri = `${logsFolderUri}/log-preview-sandbox.txt`;
|
|
2547
|
+
try {
|
|
2548
|
+
if (!(await exists(previewSandboxLogUri))) {
|
|
2549
|
+
await writeFile(previewSandboxLogUri, '');
|
|
2550
|
+
}
|
|
2551
|
+
} catch {
|
|
2552
|
+
// Keep the Output view usable if the preview log cannot be initialized.
|
|
2553
|
+
}
|
|
2349
2554
|
const windowLogUri = platform === Electron ? await getWindowLogUri(logsFolderUri) : `${logsFolderUri}/log-window.txt`;
|
|
2350
2555
|
return [{
|
|
2351
2556
|
id: MainProcess,
|
|
@@ -2359,6 +2564,10 @@ const loadOptions = async platform => {
|
|
|
2359
2564
|
id: Window,
|
|
2360
2565
|
label: 'Window',
|
|
2361
2566
|
uri: windowLogUri
|
|
2567
|
+
}, {
|
|
2568
|
+
id: PreviewSandbox,
|
|
2569
|
+
label: 'Preview Sandbox',
|
|
2570
|
+
uri: previewSandboxLogUri
|
|
2362
2571
|
}, ...detailOptions, ...extensionOptions];
|
|
2363
2572
|
};
|
|
2364
2573
|
|
|
@@ -2524,170 +2733,7 @@ const renderCss = (oldState, newState) => {
|
|
|
2524
2733
|
};
|
|
2525
2734
|
|
|
2526
2735
|
const renderFilterValue = (oldState, newState) => {
|
|
2527
|
-
return ['Viewlet.setValueByName', newState.uid, Filter
|
|
2528
|
-
};
|
|
2529
|
-
|
|
2530
|
-
const HandleBlur = 'handleBlur';
|
|
2531
|
-
const HandleClearFilterClick = 'handleClearFilterClick';
|
|
2532
|
-
const HandleContextMenu = 'handleContextMenu';
|
|
2533
|
-
const HandleFilterInput = 'handleFilterInput';
|
|
2534
|
-
const HandlePointerDown = 'handlePointerDown';
|
|
2535
|
-
const HandleSelect = 'handleSelect';
|
|
2536
|
-
const HandleButtonClick = 'handleButtonClick';
|
|
2537
|
-
const HandleSourceLinkClick = 'handleSourceLinkClick';
|
|
2538
|
-
const HandleWheel = 'handleWheel';
|
|
2539
|
-
const HandleKeyDown = 'handleKeyDown';
|
|
2540
|
-
const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
|
|
2541
|
-
const HandleScrollBarMove = 'handleScrollBarMove';
|
|
2542
|
-
const HandleScrollBarPointerCaptureLost = 'handleScrollBarPointerCaptureLost';
|
|
2543
|
-
|
|
2544
|
-
const noNodes = [];
|
|
2545
|
-
const repeatCountNode = {
|
|
2546
|
-
childCount: 1,
|
|
2547
|
-
className: OutputRepeatCount,
|
|
2548
|
-
type: Span
|
|
2549
|
-
};
|
|
2550
|
-
const spaceNode = text(' ');
|
|
2551
|
-
const getLevel = parts => {
|
|
2552
|
-
return parts.find(part => part.type === LogLevel)?.value || '';
|
|
2553
|
-
};
|
|
2554
|
-
const getLinePartDom = part => {
|
|
2555
|
-
switch (part.type) {
|
|
2556
|
-
case Link:
|
|
2557
|
-
{
|
|
2558
|
-
const isSourceLink = part.className === OutputSourceLink;
|
|
2559
|
-
const linkNode = {
|
|
2560
|
-
childCount: 1,
|
|
2561
|
-
href: part.value,
|
|
2562
|
-
rel: 'noopener noreferrer',
|
|
2563
|
-
target: '_blank',
|
|
2564
|
-
type: A,
|
|
2565
|
-
...(part.className && {
|
|
2566
|
-
className: part.className
|
|
2567
|
-
}),
|
|
2568
|
-
...(part.columnNumber !== undefined && {
|
|
2569
|
-
'data-column': part.columnNumber
|
|
2570
|
-
}),
|
|
2571
|
-
...(part.lineNumber !== undefined && {
|
|
2572
|
-
'data-line': part.lineNumber
|
|
2573
|
-
}),
|
|
2574
|
-
...(isSourceLink && {
|
|
2575
|
-
onClick: HandleSourceLinkClick
|
|
2576
|
-
})
|
|
2577
|
-
};
|
|
2578
|
-
return {
|
|
2579
|
-
childCount: 1,
|
|
2580
|
-
nodes: [linkNode, text(part.label || part.value)]
|
|
2581
|
-
};
|
|
2582
|
-
}
|
|
2583
|
-
case RepeatCount:
|
|
2584
|
-
return {
|
|
2585
|
-
childCount: 2,
|
|
2586
|
-
nodes: [repeatCountNode, text(part.value), spaceNode]
|
|
2587
|
-
};
|
|
2588
|
-
case Text:
|
|
2589
|
-
return {
|
|
2590
|
-
childCount: 1,
|
|
2591
|
-
nodes: [text(part.value)]
|
|
2592
|
-
};
|
|
2593
|
-
default:
|
|
2594
|
-
return {
|
|
2595
|
-
childCount: 0,
|
|
2596
|
-
nodes: noNodes
|
|
2597
|
-
};
|
|
2598
|
-
}
|
|
2599
|
-
};
|
|
2600
|
-
const getLineDom = parts => {
|
|
2601
|
-
const children = [];
|
|
2602
|
-
let childCount = 0;
|
|
2603
|
-
for (const part of parts) {
|
|
2604
|
-
const partDom = getLinePartDom(part);
|
|
2605
|
-
children.push(...partDom.nodes);
|
|
2606
|
-
childCount += partDom.childCount;
|
|
2607
|
-
}
|
|
2608
|
-
const level = getLevel(parts);
|
|
2609
|
-
const className = level ? mergeClassNames(Line, level) : Line;
|
|
2610
|
-
const lineNode = {
|
|
2611
|
-
childCount,
|
|
2612
|
-
className,
|
|
2613
|
-
type: Div
|
|
2614
|
-
};
|
|
2615
|
-
return [lineNode, ...children];
|
|
2616
|
-
};
|
|
2617
|
-
|
|
2618
|
-
const Focusable = 0;
|
|
2619
|
-
|
|
2620
|
-
const getContentDom = (lines, error) => {
|
|
2621
|
-
if (error) {
|
|
2622
|
-
return [];
|
|
2623
|
-
}
|
|
2624
|
-
return [{
|
|
2625
|
-
childCount: lines.length,
|
|
2626
|
-
className: OutputContent,
|
|
2627
|
-
onKeyDown: HandleKeyDown,
|
|
2628
|
-
onWheel: HandleWheel,
|
|
2629
|
-
role: Log,
|
|
2630
|
-
tabIndex: Focusable,
|
|
2631
|
-
type: Div
|
|
2632
|
-
}, ...lines.flatMap(getLineDom)];
|
|
2633
|
-
};
|
|
2634
|
-
|
|
2635
|
-
const LogFileNotFound = 1;
|
|
2636
|
-
|
|
2637
|
-
const messageNode = {
|
|
2638
|
-
childCount: 1,
|
|
2639
|
-
className: Message,
|
|
2640
|
-
tabIndex: Focusable,
|
|
2641
|
-
type: Div
|
|
2642
|
-
};
|
|
2643
|
-
const getLogFileNotFoundDom = () => {
|
|
2644
|
-
return [messageNode, text(logFileNotFound())];
|
|
2645
|
-
};
|
|
2646
|
-
|
|
2647
|
-
const errorNode = {
|
|
2648
|
-
childCount: 1,
|
|
2649
|
-
className: Error$1,
|
|
2650
|
-
tabIndex: Focusable,
|
|
2651
|
-
type: Div
|
|
2652
|
-
};
|
|
2653
|
-
const getErrorDom = (errorCode, error) => {
|
|
2654
|
-
if (!error) {
|
|
2655
|
-
return [];
|
|
2656
|
-
}
|
|
2657
|
-
if (errorCode === LogFileNotFound) {
|
|
2658
|
-
return getLogFileNotFoundDom();
|
|
2659
|
-
}
|
|
2660
|
-
return [errorNode, text(error)];
|
|
2661
|
-
};
|
|
2662
|
-
|
|
2663
|
-
const scrollBarNode = {
|
|
2664
|
-
childCount: 1,
|
|
2665
|
-
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
2666
|
-
onPointerDown: HandleScrollBarPointerDown,
|
|
2667
|
-
type: Div
|
|
2668
|
-
};
|
|
2669
|
-
const getScrollBarVirtualDom = (scrollBarHeight, scrollBarActive) => {
|
|
2670
|
-
if (scrollBarHeight <= 0) {
|
|
2671
|
-
return [];
|
|
2672
|
-
}
|
|
2673
|
-
return [scrollBarNode, {
|
|
2674
|
-
childCount: 0,
|
|
2675
|
-
className: mergeClassNames(ScrollBarThumb, scrollBarActive ? ScrollBarThumbActive : ''),
|
|
2676
|
-
type: Div
|
|
2677
|
-
}];
|
|
2678
|
-
};
|
|
2679
|
-
|
|
2680
|
-
const outputNode = {
|
|
2681
|
-
childCount: 1,
|
|
2682
|
-
className: mergeClassNames(Viewlet, Output$1),
|
|
2683
|
-
type: Div
|
|
2684
|
-
};
|
|
2685
|
-
const getOutputVirtualDom = (lines, errorCode, error, scrollBarHeight = 0, scrollBarActive = false) => {
|
|
2686
|
-
const scrollBarDom = error ? [] : getScrollBarVirtualDom(scrollBarHeight, scrollBarActive);
|
|
2687
|
-
return [{
|
|
2688
|
-
...outputNode,
|
|
2689
|
-
childCount: scrollBarDom.length > 0 ? 2 : 1
|
|
2690
|
-
}, ...getContentDom(lines, error), ...getErrorDom(errorCode, error), ...scrollBarDom];
|
|
2736
|
+
return ['Viewlet.setValueByName', newState.uid, Filter, newState.filterValue];
|
|
2691
2737
|
};
|
|
2692
2738
|
|
|
2693
2739
|
const renderItems = (oldState, newState) => {
|
|
@@ -2767,6 +2813,7 @@ const getActionButtonsVirtualDom = buttons => {
|
|
|
2767
2813
|
return buttons.flatMap(getActionButtonVirtualDom);
|
|
2768
2814
|
};
|
|
2769
2815
|
|
|
2816
|
+
const filterInputClassName = mergeClassNames(InputBox, FilterInput);
|
|
2770
2817
|
const filterNode = {
|
|
2771
2818
|
childCount: 1,
|
|
2772
2819
|
className: Filter$2,
|
|
@@ -2776,8 +2823,8 @@ const getFilterVirtualDom = () => {
|
|
|
2776
2823
|
const placeholder = filter();
|
|
2777
2824
|
return [filterNode, {
|
|
2778
2825
|
childCount: 0,
|
|
2779
|
-
className:
|
|
2780
|
-
name: Filter
|
|
2826
|
+
className: filterInputClassName,
|
|
2827
|
+
name: Filter,
|
|
2781
2828
|
onInput: HandleFilterInput,
|
|
2782
2829
|
placeholder,
|
|
2783
2830
|
type: Input
|
|
@@ -2932,6 +2979,26 @@ const saveState = state => {
|
|
|
2932
2979
|
};
|
|
2933
2980
|
};
|
|
2934
2981
|
|
|
2982
|
+
const applyComponentState = (currentState, state) => {
|
|
2983
|
+
if (!state || typeof state !== 'object' || Array.isArray(state)) {
|
|
2984
|
+
throw new TypeError('Output state must be an object');
|
|
2985
|
+
}
|
|
2986
|
+
const {
|
|
2987
|
+
uid
|
|
2988
|
+
} = state;
|
|
2989
|
+
const {
|
|
2990
|
+
uid: currentUid
|
|
2991
|
+
} = currentState;
|
|
2992
|
+
if (uid !== currentUid) {
|
|
2993
|
+
throw new Error(`Output state uid must remain ${currentUid}`);
|
|
2994
|
+
}
|
|
2995
|
+
return {
|
|
2996
|
+
...state,
|
|
2997
|
+
watchId: currentState.watchId
|
|
2998
|
+
};
|
|
2999
|
+
};
|
|
3000
|
+
const setComponentState = wrapCommand(applyComponentState);
|
|
3001
|
+
|
|
2935
3002
|
const setLogLevel = async (state, logLevel) => {
|
|
2936
3003
|
return {
|
|
2937
3004
|
...state,
|
|
@@ -2958,6 +3025,8 @@ const commandMap = {
|
|
|
2958
3025
|
'Output.focusIndex': wrapCommand(focusIndex),
|
|
2959
3026
|
'Output.getActions': getActions,
|
|
2960
3027
|
'Output.getCommandIds': getCommandIds,
|
|
3028
|
+
'Output.getComponentDom': getComponentDom,
|
|
3029
|
+
'Output.getComponentState': getComponentState,
|
|
2961
3030
|
'Output.getKeyBindings': getKeyBindings,
|
|
2962
3031
|
'Output.handleButtonClick': wrapCommand(handleButtonClick),
|
|
2963
3032
|
'Output.handleContextMenu': wrapCommand(handleContextMenu),
|
|
@@ -2983,6 +3052,7 @@ const commandMap = {
|
|
|
2983
3052
|
'Output.saveAs': wrapCommand(saveOutputAs),
|
|
2984
3053
|
'Output.saveState': wrapGetter(saveState),
|
|
2985
3054
|
'Output.selectChannel': wrapCommand(selectChannel),
|
|
3055
|
+
'Output.setComponentState': setComponentState,
|
|
2986
3056
|
'Output.setDeltaY': wrapCommand(setDeltaY),
|
|
2987
3057
|
'Output.setLogLevel': setLogLevel,
|
|
2988
3058
|
'Output.setOutputChannel': wrapCommand(setOutputChannel),
|