@lvce-editor/output-view 1.15.0 → 1.16.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.
@@ -1597,12 +1597,12 @@ const getKeyBindings = () => {
1597
1597
  }];
1598
1598
  };
1599
1599
 
1600
- const Filter = 'filter';
1600
+ const Filter$1 = 'filter';
1601
1601
  const Output$1 = 'output';
1602
1602
  const MainProcess = 'MainProcess';
1603
1603
  const SharedProcess = 'SharedProcess';
1604
1604
  const Clear = 'Clear';
1605
- const Settings = 'Settings';
1605
+ const Settings$1 = 'Settings';
1606
1606
  const ScrollLock = 'ScrollLock';
1607
1607
 
1608
1608
  const noop = async state => {
@@ -1794,25 +1794,58 @@ const initialize = async () => {
1794
1794
 
1795
1795
  const Web = 1;
1796
1796
 
1797
- const getSelectedItem = platform => {
1797
+ const getSelectedItem = (selectedOption, platform) => {
1798
+ if (selectedOption) {
1799
+ return selectedOption;
1800
+ }
1798
1801
  if (platform === Web) {
1799
1802
  return '';
1800
1803
  }
1801
1804
  return MainProcess;
1802
1805
  };
1803
1806
 
1807
+ const emptyObject = {};
1808
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1809
+ const i18nString = (key, placeholders = emptyObject) => {
1810
+ if (placeholders === emptyObject) {
1811
+ return key;
1812
+ }
1813
+ const replacer = (match, rest) => {
1814
+ return placeholders[rest];
1815
+ };
1816
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1817
+ };
1818
+
1819
+ const ClearOutput = 'clear output';
1820
+ const LogFileNotFound$1 = 'The log file was not found.';
1821
+ const Settings = 'Settings';
1822
+ const TurnOffAutoScroll = 'Turn auto scrolling off';
1823
+
1824
+ const clearOutput = () => {
1825
+ return i18nString(ClearOutput);
1826
+ };
1827
+ const turnOffAutoScroll = () => {
1828
+ return i18nString(TurnOffAutoScroll);
1829
+ };
1830
+ const settings = () => {
1831
+ return i18nString(Settings);
1832
+ };
1833
+ const logFileNotFound = () => {
1834
+ return i18nString(LogFileNotFound$1);
1835
+ };
1836
+
1804
1837
  const loadButtons = () => {
1805
1838
  return [{
1806
1839
  id: Clear,
1807
- label: 'Clear',
1840
+ label: clearOutput(),
1808
1841
  icon: 'MaskIconClearAll'
1809
1842
  }, {
1810
1843
  id: ScrollLock,
1811
- label: 'Scroll Lock',
1844
+ label: turnOffAutoScroll(),
1812
1845
  icon: 'MaskIconListFlat'
1813
1846
  }, {
1814
- id: Settings,
1815
- label: 'Settings',
1847
+ id: Settings$1,
1848
+ label: settings(),
1816
1849
  icon: 'MaskIconSettingsGear'
1817
1850
  }];
1818
1851
  };
@@ -1852,6 +1885,35 @@ const loadOptions = async platform => {
1852
1885
  }, ...extensionOptions];
1853
1886
  };
1854
1887
 
1888
+ const getSavedFilterValue = savedState => {
1889
+ if (savedState && typeof savedState.filterValue === 'string') {
1890
+ return savedState.filterValue;
1891
+ }
1892
+ return '';
1893
+ };
1894
+ const getSavedSelectedOption = savedState => {
1895
+ if (savedState && typeof savedState.selectedOption === 'string') {
1896
+ return savedState.selectedOption;
1897
+ }
1898
+ return '';
1899
+ };
1900
+ const getSavedScrollLockEnabled = savedState => {
1901
+ if (savedState && typeof savedState.scrollLockEnabled === 'boolean') {
1902
+ return savedState.scrollLockEnabled;
1903
+ }
1904
+ return false;
1905
+ };
1906
+ const restoreState = savedState => {
1907
+ const filterValue = getSavedFilterValue(savedState);
1908
+ const selectedOption = getSavedSelectedOption(savedState);
1909
+ const scrollLockEnabled = getSavedScrollLockEnabled(savedState);
1910
+ return {
1911
+ filterValue,
1912
+ selectedOption,
1913
+ scrollLockEnabled
1914
+ };
1915
+ };
1916
+
1855
1917
  const isString = value => {
1856
1918
  return typeof value === 'string';
1857
1919
  };
@@ -1870,7 +1932,12 @@ const loadContent = async (state, savedState) => {
1870
1932
  watchId
1871
1933
  } = state;
1872
1934
  const collapsedUris = getSavedCollapsedUris(savedState);
1873
- const selectedId = getSelectedItem(platform);
1935
+ const {
1936
+ selectedOption,
1937
+ filterValue,
1938
+ scrollLockEnabled
1939
+ } = restoreState(savedState);
1940
+ const selectedId = getSelectedItem(selectedOption, platform);
1874
1941
  const options = await loadOptions(platform);
1875
1942
  const option = getMatchingOpen(options, selectedId);
1876
1943
  if (!option) {
@@ -1884,20 +1951,23 @@ const loadContent = async (state, savedState) => {
1884
1951
  error,
1885
1952
  code
1886
1953
  } = await loadLines(uri);
1954
+ const filteredItems = filterItems(lines, filterValue);
1887
1955
  const newWatchId = createWatchId();
1888
1956
  await setupChangeListener(watchId, newWatchId, uri);
1889
1957
  const buttons = loadButtons();
1890
1958
  return {
1891
1959
  ...state,
1960
+ buttons,
1892
1961
  collapsedUris,
1893
1962
  error,
1894
1963
  errorCode: code,
1964
+ filteredItems,
1965
+ filterValue,
1895
1966
  inputSource: Script,
1896
1967
  listItems: lines,
1897
- filteredItems: lines,
1898
1968
  options,
1969
+ scrollLockEnabled,
1899
1970
  selectedOption: selectedId,
1900
- buttons,
1901
1971
  watchId: newWatchId
1902
1972
  };
1903
1973
  };
@@ -1939,20 +2009,27 @@ const refresh = async state => {
1939
2009
  };
1940
2010
 
1941
2011
  const renderFilterValue = (oldState, newState) => {
1942
- return ['Viewlet.setValueByName', newState.parentId, Filter, newState.filterValue];
2012
+ return ['Viewlet.setValueByName', newState.parentId, Filter$1, newState.filterValue];
1943
2013
  };
1944
2014
 
2015
+ const Filter = 'Filter';
1945
2016
  const IconButton = 'IconButton';
2017
+ const InputBox = 'InputBox';
1946
2018
  const MaskIcon = 'MaskIcon';
2019
+ const FilterInput = 'FilterInput';
2020
+ const OutputContent = 'OutputContent';
1947
2021
  const Actions = 'Actions';
2022
+ const Message = 'Message';
1948
2023
  const Viewlet = 'Viewlet';
1949
2024
  const Output = 'Output';
1950
2025
  const Option = 'Option';
1951
2026
  const Select = 'Select';
2027
+ const Error$1 = 'Error';
2028
+ const Line = 'Line';
1952
2029
 
1953
2030
  const parentNode = {
1954
2031
  type: VirtualDomElements.Div,
1955
- className: 'Line',
2032
+ className: Line,
1956
2033
  childCount: 1
1957
2034
  };
1958
2035
  const getLineDom = line => {
@@ -1965,37 +2042,19 @@ const getContentDom = (lines, error) => {
1965
2042
  }
1966
2043
  return [{
1967
2044
  type: VirtualDomElements.Div,
1968
- className: 'OutputContent',
2045
+ className: OutputContent,
1969
2046
  role: 'log',
1970
2047
  tabIndex: 0,
1971
2048
  childCount: lines.length
1972
2049
  }, ...lines.flatMap(getLineDom)];
1973
2050
  };
1974
2051
 
1975
- const LogFileNotFound$1 = 1;
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
- };
2052
+ const LogFileNotFound = 1;
1994
2053
 
1995
2054
  const getLogFileNotFoundDom = () => {
1996
2055
  return [{
1997
2056
  type: VirtualDomElements.Div,
1998
- className: 'Message',
2057
+ className: Message,
1999
2058
  tabIndex: 0,
2000
2059
  childCount: 1
2001
2060
  }, text(logFileNotFound())];
@@ -2005,12 +2064,12 @@ const getErrorDom = (errorCode, error) => {
2005
2064
  if (!error) {
2006
2065
  return [];
2007
2066
  }
2008
- if (errorCode === LogFileNotFound$1) {
2067
+ if (errorCode === LogFileNotFound) {
2009
2068
  return getLogFileNotFoundDom();
2010
2069
  }
2011
2070
  return [{
2012
2071
  type: VirtualDomElements.Div,
2013
- className: 'Error',
2072
+ className: Error$1,
2014
2073
  tabIndex: 0,
2015
2074
  childCount: 1
2016
2075
  }, text(error)];
@@ -2102,15 +2161,15 @@ const getFilterVirtualDom = () => {
2102
2161
  const placeholder = 'Filter';
2103
2162
  return [{
2104
2163
  type: VirtualDomElements.Div,
2105
- className: 'Filter',
2164
+ className: Filter,
2106
2165
  childCount: 1
2107
2166
  }, {
2108
2167
  type: VirtualDomElements.Input,
2109
- className: 'InputBox FilterInput',
2168
+ className: mergeClassNames(InputBox, FilterInput),
2110
2169
  childCount: 0,
2111
2170
  placeholder,
2112
2171
  onInput: HandleFilterInput,
2113
- name: Filter
2172
+ name: Filter$1
2114
2173
  }];
2115
2174
  };
2116
2175
 
@@ -2206,12 +2265,14 @@ const saveState = state => {
2206
2265
  const {
2207
2266
  filterValue,
2208
2267
  collapsedUris,
2209
- selectedOption
2268
+ selectedOption,
2269
+ scrollLockEnabled
2210
2270
  } = state;
2211
2271
  return {
2212
2272
  filterValue,
2213
2273
  collapsedUris,
2214
- selectedOption
2274
+ selectedOption,
2275
+ scrollLockEnabled
2215
2276
  };
2216
2277
  };
2217
2278
 
@@ -2256,7 +2317,7 @@ const commandMap = {
2256
2317
  'Output.renderEventListeners': renderEventListeners,
2257
2318
  'Output.resize': resize,
2258
2319
  'Output.saveOutputAs': wrapCommand(saveOutputAs),
2259
- 'Output.saveState': saveState,
2320
+ 'Output.saveState': wrapGetter(saveState),
2260
2321
  'Output.selectChannel': wrapCommand(selectChannel),
2261
2322
  'Output.setLogLevel': setLogLevel,
2262
2323
  'Output.setOutputChannel': wrapCommand(setOutputChannel),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",