@lvce-editor/output-view 1.15.0 → 1.17.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/dist/outputViewWorkerMain.js +109 -57
- package/package.json +1 -1
|
@@ -1008,7 +1008,7 @@ const WebWorkerRpcClient = {
|
|
|
1008
1008
|
create: create$4
|
|
1009
1009
|
};
|
|
1010
1010
|
|
|
1011
|
-
const toCommandId
|
|
1011
|
+
const toCommandId = key => {
|
|
1012
1012
|
const dotIndex = key.indexOf('.');
|
|
1013
1013
|
return key.slice(dotIndex + 1);
|
|
1014
1014
|
};
|
|
@@ -1080,7 +1080,7 @@ const create$2 = () => {
|
|
|
1080
1080
|
},
|
|
1081
1081
|
getCommandIds() {
|
|
1082
1082
|
const keys = Object.keys(commandMapRef);
|
|
1083
|
-
const ids = keys.map(toCommandId
|
|
1083
|
+
const ids = keys.map(toCommandId);
|
|
1084
1084
|
return ids;
|
|
1085
1085
|
},
|
|
1086
1086
|
registerCommands(commandMap) {
|
|
@@ -1302,7 +1302,7 @@ const filterItems = (items, filterValue) => {
|
|
|
1302
1302
|
};
|
|
1303
1303
|
|
|
1304
1304
|
const isFileNotFoundError = error => {
|
|
1305
|
-
return error
|
|
1305
|
+
return error?.message?.includes('File not found') ?? false;
|
|
1306
1306
|
};
|
|
1307
1307
|
|
|
1308
1308
|
const loadLines = async uri => {
|
|
@@ -1376,7 +1376,8 @@ const {
|
|
|
1376
1376
|
set: set$2,
|
|
1377
1377
|
wrapCommand,
|
|
1378
1378
|
wrapGetter,
|
|
1379
|
-
getKeys
|
|
1379
|
+
getKeys,
|
|
1380
|
+
getCommandIds
|
|
1380
1381
|
} = create$2();
|
|
1381
1382
|
|
|
1382
1383
|
const create = (id, uri, x, y, width, height, platform, parentId) => {
|
|
@@ -1486,18 +1487,6 @@ const focusIndex = (state, index) => {
|
|
|
1486
1487
|
};
|
|
1487
1488
|
};
|
|
1488
1489
|
|
|
1489
|
-
const commandMapRef = {};
|
|
1490
|
-
|
|
1491
|
-
const toCommandId = key => {
|
|
1492
|
-
const dotIndex = key.indexOf('.');
|
|
1493
|
-
return key.slice(dotIndex + 1);
|
|
1494
|
-
};
|
|
1495
|
-
const getCommandIds = () => {
|
|
1496
|
-
const keys = Object.keys(commandMapRef);
|
|
1497
|
-
const ids = keys.map(toCommandId);
|
|
1498
|
-
return ids;
|
|
1499
|
-
};
|
|
1500
|
-
|
|
1501
1490
|
const ToolBar = 'toolbar';
|
|
1502
1491
|
const AriaRoles = {
|
|
1503
1492
|
__proto__: null,
|
|
@@ -1597,12 +1586,12 @@ const getKeyBindings = () => {
|
|
|
1597
1586
|
}];
|
|
1598
1587
|
};
|
|
1599
1588
|
|
|
1600
|
-
const Filter = 'filter';
|
|
1589
|
+
const Filter$1 = 'filter';
|
|
1601
1590
|
const Output$1 = 'output';
|
|
1602
1591
|
const MainProcess = 'MainProcess';
|
|
1603
1592
|
const SharedProcess = 'SharedProcess';
|
|
1604
1593
|
const Clear = 'Clear';
|
|
1605
|
-
const Settings = 'Settings';
|
|
1594
|
+
const Settings$1 = 'Settings';
|
|
1606
1595
|
const ScrollLock = 'ScrollLock';
|
|
1607
1596
|
|
|
1608
1597
|
const noop = async state => {
|
|
@@ -1794,25 +1783,58 @@ const initialize = async () => {
|
|
|
1794
1783
|
|
|
1795
1784
|
const Web = 1;
|
|
1796
1785
|
|
|
1797
|
-
const getSelectedItem = platform => {
|
|
1786
|
+
const getSelectedItem = (selectedOption, platform) => {
|
|
1787
|
+
if (selectedOption) {
|
|
1788
|
+
return selectedOption;
|
|
1789
|
+
}
|
|
1798
1790
|
if (platform === Web) {
|
|
1799
1791
|
return '';
|
|
1800
1792
|
}
|
|
1801
1793
|
return MainProcess;
|
|
1802
1794
|
};
|
|
1803
1795
|
|
|
1796
|
+
const emptyObject = {};
|
|
1797
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1798
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
1799
|
+
if (placeholders === emptyObject) {
|
|
1800
|
+
return key;
|
|
1801
|
+
}
|
|
1802
|
+
const replacer = (match, rest) => {
|
|
1803
|
+
return placeholders[rest];
|
|
1804
|
+
};
|
|
1805
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1806
|
+
};
|
|
1807
|
+
|
|
1808
|
+
const ClearOutput = 'clear output';
|
|
1809
|
+
const LogFileNotFound$1 = 'The log file was not found.';
|
|
1810
|
+
const Settings = 'Settings';
|
|
1811
|
+
const TurnOffAutoScroll = 'Turn auto scrolling off';
|
|
1812
|
+
|
|
1813
|
+
const clearOutput = () => {
|
|
1814
|
+
return i18nString(ClearOutput);
|
|
1815
|
+
};
|
|
1816
|
+
const turnOffAutoScroll = () => {
|
|
1817
|
+
return i18nString(TurnOffAutoScroll);
|
|
1818
|
+
};
|
|
1819
|
+
const settings = () => {
|
|
1820
|
+
return i18nString(Settings);
|
|
1821
|
+
};
|
|
1822
|
+
const logFileNotFound = () => {
|
|
1823
|
+
return i18nString(LogFileNotFound$1);
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1804
1826
|
const loadButtons = () => {
|
|
1805
1827
|
return [{
|
|
1806
1828
|
id: Clear,
|
|
1807
|
-
label:
|
|
1829
|
+
label: clearOutput(),
|
|
1808
1830
|
icon: 'MaskIconClearAll'
|
|
1809
1831
|
}, {
|
|
1810
1832
|
id: ScrollLock,
|
|
1811
|
-
label:
|
|
1833
|
+
label: turnOffAutoScroll(),
|
|
1812
1834
|
icon: 'MaskIconListFlat'
|
|
1813
1835
|
}, {
|
|
1814
|
-
id: Settings,
|
|
1815
|
-
label:
|
|
1836
|
+
id: Settings$1,
|
|
1837
|
+
label: settings(),
|
|
1816
1838
|
icon: 'MaskIconSettingsGear'
|
|
1817
1839
|
}];
|
|
1818
1840
|
};
|
|
@@ -1852,6 +1874,35 @@ const loadOptions = async platform => {
|
|
|
1852
1874
|
}, ...extensionOptions];
|
|
1853
1875
|
};
|
|
1854
1876
|
|
|
1877
|
+
const getSavedFilterValue = savedState => {
|
|
1878
|
+
if (savedState && typeof savedState.filterValue === 'string') {
|
|
1879
|
+
return savedState.filterValue;
|
|
1880
|
+
}
|
|
1881
|
+
return '';
|
|
1882
|
+
};
|
|
1883
|
+
const getSavedSelectedOption = savedState => {
|
|
1884
|
+
if (savedState && typeof savedState.selectedOption === 'string') {
|
|
1885
|
+
return savedState.selectedOption;
|
|
1886
|
+
}
|
|
1887
|
+
return '';
|
|
1888
|
+
};
|
|
1889
|
+
const getSavedScrollLockEnabled = savedState => {
|
|
1890
|
+
if (savedState && typeof savedState.scrollLockEnabled === 'boolean') {
|
|
1891
|
+
return savedState.scrollLockEnabled;
|
|
1892
|
+
}
|
|
1893
|
+
return false;
|
|
1894
|
+
};
|
|
1895
|
+
const restoreState = savedState => {
|
|
1896
|
+
const filterValue = getSavedFilterValue(savedState);
|
|
1897
|
+
const selectedOption = getSavedSelectedOption(savedState);
|
|
1898
|
+
const scrollLockEnabled = getSavedScrollLockEnabled(savedState);
|
|
1899
|
+
return {
|
|
1900
|
+
filterValue,
|
|
1901
|
+
selectedOption,
|
|
1902
|
+
scrollLockEnabled
|
|
1903
|
+
};
|
|
1904
|
+
};
|
|
1905
|
+
|
|
1855
1906
|
const isString = value => {
|
|
1856
1907
|
return typeof value === 'string';
|
|
1857
1908
|
};
|
|
@@ -1870,7 +1921,12 @@ const loadContent = async (state, savedState) => {
|
|
|
1870
1921
|
watchId
|
|
1871
1922
|
} = state;
|
|
1872
1923
|
const collapsedUris = getSavedCollapsedUris(savedState);
|
|
1873
|
-
const
|
|
1924
|
+
const {
|
|
1925
|
+
selectedOption,
|
|
1926
|
+
filterValue,
|
|
1927
|
+
scrollLockEnabled
|
|
1928
|
+
} = restoreState(savedState);
|
|
1929
|
+
const selectedId = getSelectedItem(selectedOption, platform);
|
|
1874
1930
|
const options = await loadOptions(platform);
|
|
1875
1931
|
const option = getMatchingOpen(options, selectedId);
|
|
1876
1932
|
if (!option) {
|
|
@@ -1884,20 +1940,23 @@ const loadContent = async (state, savedState) => {
|
|
|
1884
1940
|
error,
|
|
1885
1941
|
code
|
|
1886
1942
|
} = await loadLines(uri);
|
|
1943
|
+
const filteredItems = filterItems(lines, filterValue);
|
|
1887
1944
|
const newWatchId = createWatchId();
|
|
1888
1945
|
await setupChangeListener(watchId, newWatchId, uri);
|
|
1889
1946
|
const buttons = loadButtons();
|
|
1890
1947
|
return {
|
|
1891
1948
|
...state,
|
|
1949
|
+
buttons,
|
|
1892
1950
|
collapsedUris,
|
|
1893
1951
|
error,
|
|
1894
1952
|
errorCode: code,
|
|
1953
|
+
filteredItems,
|
|
1954
|
+
filterValue,
|
|
1895
1955
|
inputSource: Script,
|
|
1896
1956
|
listItems: lines,
|
|
1897
|
-
filteredItems: lines,
|
|
1898
1957
|
options,
|
|
1958
|
+
scrollLockEnabled,
|
|
1899
1959
|
selectedOption: selectedId,
|
|
1900
|
-
buttons,
|
|
1901
1960
|
watchId: newWatchId
|
|
1902
1961
|
};
|
|
1903
1962
|
};
|
|
@@ -1939,20 +1998,27 @@ const refresh = async state => {
|
|
|
1939
1998
|
};
|
|
1940
1999
|
|
|
1941
2000
|
const renderFilterValue = (oldState, newState) => {
|
|
1942
|
-
return ['Viewlet.setValueByName', newState.parentId, Filter, newState.filterValue];
|
|
2001
|
+
return ['Viewlet.setValueByName', newState.parentId, Filter$1, newState.filterValue];
|
|
1943
2002
|
};
|
|
1944
2003
|
|
|
2004
|
+
const Filter = 'Filter';
|
|
1945
2005
|
const IconButton = 'IconButton';
|
|
2006
|
+
const InputBox = 'InputBox';
|
|
1946
2007
|
const MaskIcon = 'MaskIcon';
|
|
2008
|
+
const FilterInput = 'FilterInput';
|
|
2009
|
+
const OutputContent = 'OutputContent';
|
|
1947
2010
|
const Actions = 'Actions';
|
|
2011
|
+
const Message = 'Message';
|
|
1948
2012
|
const Viewlet = 'Viewlet';
|
|
1949
2013
|
const Output = 'Output';
|
|
1950
2014
|
const Option = 'Option';
|
|
1951
2015
|
const Select = 'Select';
|
|
2016
|
+
const Error$1 = 'Error';
|
|
2017
|
+
const Line = 'Line';
|
|
1952
2018
|
|
|
1953
2019
|
const parentNode = {
|
|
1954
2020
|
type: VirtualDomElements.Div,
|
|
1955
|
-
className:
|
|
2021
|
+
className: Line,
|
|
1956
2022
|
childCount: 1
|
|
1957
2023
|
};
|
|
1958
2024
|
const getLineDom = line => {
|
|
@@ -1965,37 +2031,19 @@ const getContentDom = (lines, error) => {
|
|
|
1965
2031
|
}
|
|
1966
2032
|
return [{
|
|
1967
2033
|
type: VirtualDomElements.Div,
|
|
1968
|
-
className:
|
|
2034
|
+
className: OutputContent,
|
|
1969
2035
|
role: 'log',
|
|
1970
2036
|
tabIndex: 0,
|
|
1971
2037
|
childCount: lines.length
|
|
1972
2038
|
}, ...lines.flatMap(getLineDom)];
|
|
1973
2039
|
};
|
|
1974
2040
|
|
|
1975
|
-
const LogFileNotFound
|
|
1976
|
-
|
|
1977
|
-
const emptyObject = {};
|
|
1978
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1979
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
1980
|
-
if (placeholders === emptyObject) {
|
|
1981
|
-
return key;
|
|
1982
|
-
}
|
|
1983
|
-
const replacer = (match, rest) => {
|
|
1984
|
-
return placeholders[rest];
|
|
1985
|
-
};
|
|
1986
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1987
|
-
};
|
|
1988
|
-
|
|
1989
|
-
const LogFileNotFound = 'The log file was not found.';
|
|
1990
|
-
|
|
1991
|
-
const logFileNotFound = () => {
|
|
1992
|
-
return i18nString(LogFileNotFound);
|
|
1993
|
-
};
|
|
2041
|
+
const LogFileNotFound = 1;
|
|
1994
2042
|
|
|
1995
2043
|
const getLogFileNotFoundDom = () => {
|
|
1996
2044
|
return [{
|
|
1997
2045
|
type: VirtualDomElements.Div,
|
|
1998
|
-
className:
|
|
2046
|
+
className: Message,
|
|
1999
2047
|
tabIndex: 0,
|
|
2000
2048
|
childCount: 1
|
|
2001
2049
|
}, text(logFileNotFound())];
|
|
@@ -2005,12 +2053,12 @@ const getErrorDom = (errorCode, error) => {
|
|
|
2005
2053
|
if (!error) {
|
|
2006
2054
|
return [];
|
|
2007
2055
|
}
|
|
2008
|
-
if (errorCode === LogFileNotFound
|
|
2056
|
+
if (errorCode === LogFileNotFound) {
|
|
2009
2057
|
return getLogFileNotFoundDom();
|
|
2010
2058
|
}
|
|
2011
2059
|
return [{
|
|
2012
2060
|
type: VirtualDomElements.Div,
|
|
2013
|
-
className:
|
|
2061
|
+
className: Error$1,
|
|
2014
2062
|
tabIndex: 0,
|
|
2015
2063
|
childCount: 1
|
|
2016
2064
|
}, text(error)];
|
|
@@ -2102,15 +2150,15 @@ const getFilterVirtualDom = () => {
|
|
|
2102
2150
|
const placeholder = 'Filter';
|
|
2103
2151
|
return [{
|
|
2104
2152
|
type: VirtualDomElements.Div,
|
|
2105
|
-
className:
|
|
2153
|
+
className: Filter,
|
|
2106
2154
|
childCount: 1
|
|
2107
2155
|
}, {
|
|
2108
2156
|
type: VirtualDomElements.Input,
|
|
2109
|
-
className:
|
|
2157
|
+
className: mergeClassNames(InputBox, FilterInput),
|
|
2110
2158
|
childCount: 0,
|
|
2111
2159
|
placeholder,
|
|
2112
2160
|
onInput: HandleFilterInput,
|
|
2113
|
-
name: Filter
|
|
2161
|
+
name: Filter$1
|
|
2114
2162
|
}];
|
|
2115
2163
|
};
|
|
2116
2164
|
|
|
@@ -2206,12 +2254,14 @@ const saveState = state => {
|
|
|
2206
2254
|
const {
|
|
2207
2255
|
filterValue,
|
|
2208
2256
|
collapsedUris,
|
|
2209
|
-
selectedOption
|
|
2257
|
+
selectedOption,
|
|
2258
|
+
scrollLockEnabled
|
|
2210
2259
|
} = state;
|
|
2211
2260
|
return {
|
|
2212
2261
|
filterValue,
|
|
2213
2262
|
collapsedUris,
|
|
2214
|
-
selectedOption
|
|
2263
|
+
selectedOption,
|
|
2264
|
+
scrollLockEnabled
|
|
2215
2265
|
};
|
|
2216
2266
|
};
|
|
2217
2267
|
|
|
@@ -2256,13 +2306,15 @@ const commandMap = {
|
|
|
2256
2306
|
'Output.renderEventListeners': renderEventListeners,
|
|
2257
2307
|
'Output.resize': resize,
|
|
2258
2308
|
'Output.saveOutputAs': wrapCommand(saveOutputAs),
|
|
2259
|
-
'Output.saveState': saveState,
|
|
2309
|
+
'Output.saveState': wrapGetter(saveState),
|
|
2260
2310
|
'Output.selectChannel': wrapCommand(selectChannel),
|
|
2261
2311
|
'Output.setLogLevel': setLogLevel,
|
|
2262
2312
|
'Output.setOutputChannel': wrapCommand(setOutputChannel),
|
|
2263
2313
|
'Output.terminate': terminate
|
|
2264
2314
|
};
|
|
2265
2315
|
|
|
2316
|
+
const commandMapRef = {};
|
|
2317
|
+
|
|
2266
2318
|
const listen = async () => {
|
|
2267
2319
|
Object.assign(commandMapRef, commandMap);
|
|
2268
2320
|
const rpc = await WebWorkerRpcClient.create({
|