@lvce-editor/output-view 1.12.0 → 1.14.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.
@@ -879,7 +879,7 @@ const send = (transport, method, ...params) => {
879
879
  const message = create$4$1(method, params);
880
880
  transport.send(message);
881
881
  };
882
- const invoke$1 = (ipc, method, ...params) => {
882
+ const invoke$2 = (ipc, method, ...params) => {
883
883
  return invokeHelper(ipc, method, params, false);
884
884
  };
885
885
  const invokeAndTransfer = (ipc, method, ...params) => {
@@ -918,7 +918,7 @@ const createRpc = ipc => {
918
918
  send(ipc, method, ...params);
919
919
  },
920
920
  invoke(method, ...params) {
921
- return invoke$1(ipc, method, ...params);
921
+ return invoke$2(ipc, method, ...params);
922
922
  },
923
923
  invokeAndTransfer(method, ...params) {
924
924
  return invokeAndTransfer(ipc, method, ...params);
@@ -1148,7 +1148,7 @@ const isEqual$2 = (oldState, newState) => {
1148
1148
  };
1149
1149
 
1150
1150
  const isEqual$1 = (oldState, newState) => {
1151
- return oldState.selectedOption === newState.selectedOption && oldState.listItems === newState.listItems;
1151
+ return oldState.selectedOption === newState.selectedOption && oldState.listItems === newState.listItems && oldState.filteredItems === newState.filteredItems;
1152
1152
  };
1153
1153
 
1154
1154
  const isEqual = (oldState, newState) => {
@@ -1333,9 +1333,59 @@ const create = rpcId => {
1333
1333
  }
1334
1334
  };
1335
1335
  };
1336
+ const DebugWorker$1 = 55;
1337
+ const EditorWorker$1 = 99;
1336
1338
  const ExtensionHostWorker = 44;
1339
+ const MainProcess$1 = -5;
1337
1340
  const RendererWorker$1 = 1;
1341
+ const RendererProcess$1 = 1670;
1342
+ const SearchProcess$1 = 77;
1343
+ const SearchProcessElectron = 2;
1344
+ const SharedProcess$1 = 1;
1345
+ const SourceControlWorker = 66;
1346
+ const EmbedsProcess$1 = 207;
1347
+ const EmbedsWorker = 208;
1338
1348
  const FileSystemWorker$1 = 209;
1349
+ const FileSystemProcess$1 = 210;
1350
+ const MarkdownWorker$1 = 300;
1351
+ const CompletionWorker = 301;
1352
+ const ColorPickerWorker = 302;
1353
+ const SourceActionWorker = 303;
1354
+ const ErrorWorker$1 = 3308;
1355
+ const SyntaxHighlightingWorker$1 = 3309;
1356
+ const ClipBoardWorker$1 = 3400;
1357
+ const ClipBoardProcess$1 = 3401;
1358
+ const ExtensionDetailWorker = 3402;
1359
+ const ProblemsWorker = 3403;
1360
+ const OutputWorker = 7001;
1361
+ const RpcId = {
1362
+ __proto__: null,
1363
+ ClipBoardProcess: ClipBoardProcess$1,
1364
+ ClipBoardWorker: ClipBoardWorker$1,
1365
+ ColorPickerWorker,
1366
+ CompletionWorker,
1367
+ DebugWorker: DebugWorker$1,
1368
+ EditorWorker: EditorWorker$1,
1369
+ EmbedsProcess: EmbedsProcess$1,
1370
+ EmbedsWorker,
1371
+ ErrorWorker: ErrorWorker$1,
1372
+ ExtensionDetailWorker,
1373
+ ExtensionHostWorker,
1374
+ FileSystemProcess: FileSystemProcess$1,
1375
+ FileSystemWorker: FileSystemWorker$1,
1376
+ MainProcess: MainProcess$1,
1377
+ MarkdownWorker: MarkdownWorker$1,
1378
+ OutputWorker,
1379
+ ProblemsWorker,
1380
+ RendererProcess: RendererProcess$1,
1381
+ RendererWorker: RendererWorker$1,
1382
+ SearchProcess: SearchProcess$1,
1383
+ SearchProcessElectron,
1384
+ SharedProcess: SharedProcess$1,
1385
+ SourceActionWorker,
1386
+ SourceControlWorker,
1387
+ SyntaxHighlightingWorker: SyntaxHighlightingWorker$1
1388
+ };
1339
1389
  const {
1340
1390
  invoke: invoke$9,
1341
1391
  set: set$9} = create(ExtensionHostWorker);
@@ -1441,6 +1491,7 @@ const activateByEvent$1 = event => {
1441
1491
  const RendererWorker = {
1442
1492
  __proto__: null,
1443
1493
  activateByEvent: activateByEvent$1,
1494
+ invoke: invoke$3,
1444
1495
  sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
1445
1496
  sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$2,
1446
1497
  set: set$3};
@@ -1553,7 +1604,7 @@ const filterItems = (items, filterValue) => {
1553
1604
  return items.filter(item => item.includes(filterValue));
1554
1605
  };
1555
1606
 
1556
- const handleFilterInput = async (state, value) => {
1607
+ const handleFilterInput = async (state, value, inputSource = User) => {
1557
1608
  const {
1558
1609
  listItems
1559
1610
  } = state;
@@ -1561,29 +1612,47 @@ const handleFilterInput = async (state, value) => {
1561
1612
  return {
1562
1613
  ...state,
1563
1614
  filterValue: value,
1564
- filteredItems: filteredItems
1615
+ filteredItems: filteredItems,
1616
+ inputSource
1565
1617
  };
1566
1618
  };
1567
1619
 
1620
+ const createWatchId = () => {
1621
+ const watchId = Math.random();
1622
+ return watchId;
1623
+ };
1624
+
1625
+ const {
1626
+ invoke: invoke$1,
1627
+ sendMessagePortToExtensionHostWorker,
1628
+ sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$1,
1629
+ set: set$1,
1630
+ activateByEvent
1631
+ } = RendererWorker;
1632
+
1633
+ const handleFileChange = async watchId => {
1634
+ const keys = getKeys();
1635
+ for (const key of keys) {
1636
+ const instance = get$1(key);
1637
+ if (instance.newState.watchId === watchId) {
1638
+ // @ts-ignore
1639
+ await invoke$1('Output.refresh');
1640
+ }
1641
+ }
1642
+ };
1643
+
1568
1644
  const watchCallbacks = Object.create(null);
1569
1645
  const registerWatchCallback = (id, fn) => {
1570
1646
  watchCallbacks[id] = fn;
1571
1647
  };
1572
1648
  const executeWatchCallBack = id => {
1573
- watchCallbacks[id]();
1649
+ watchCallbacks[id](id);
1574
1650
  };
1575
1651
 
1576
- const handleChange = watchId => {
1577
- // console.log('channel changed', watchId)
1578
- const keys = getKeys();
1579
- for (const key of keys) {
1580
- }
1581
- };
1582
- const setupChangeListener = async uri => {
1652
+ const setupChangeListener = async (watchId, uri) => {
1583
1653
  try {
1584
- const watchId = Math.random();
1585
- const rpcId = 7001;
1586
- registerWatchCallback(watchId, handleChange);
1654
+ const rpcId = RpcId.OutputWorker;
1655
+ registerWatchCallback(watchId, handleFileChange);
1587
1656
  // @ts-ignore
1588
1657
  await FileSystemWorker.invoke(/* OutputChannel.open */'FileSystem.watchFile', watchId, /* path */uri, rpcId);
1589
1658
  } catch {
@@ -1608,7 +1677,8 @@ const selectChannel = async (state, id) => {
1608
1677
  } = await loadLines(matchingOption.uri);
1609
1678
 
1610
1679
  // TODO memory leak and race condition, need to dispose file watcher of previous uri
1611
- await setupChangeListener(matchingOption.uri);
1680
+ const watchId = createWatchId();
1681
+ await setupChangeListener(watchId, matchingOption.uri);
1612
1682
  const filteredItems = filterItems(lines, filterValue);
1613
1683
  return {
1614
1684
  ...state,
@@ -1616,7 +1686,8 @@ const selectChannel = async (state, id) => {
1616
1686
  errorCode: code,
1617
1687
  listItems: lines,
1618
1688
  filteredItems,
1619
- selectedOption: id
1689
+ selectedOption: id,
1690
+ watchId
1620
1691
  };
1621
1692
  };
1622
1693
 
@@ -1624,13 +1695,6 @@ const handleSelect = async (state, id) => {
1624
1695
  return selectChannel(state, id);
1625
1696
  };
1626
1697
 
1627
- const {
1628
- sendMessagePortToExtensionHostWorker,
1629
- sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$1,
1630
- set: set$1,
1631
- activateByEvent
1632
- } = RendererWorker;
1633
-
1634
1698
  const sendMessagePortToExtensionHostWorker2 = async port => {
1635
1699
  await sendMessagePortToExtensionHostWorker(port);
1636
1700
  };
@@ -1657,7 +1721,7 @@ const initializeExtensionHost = async () => {
1657
1721
  };
1658
1722
 
1659
1723
  const sendMessagePortToFileSystemWorker = async port => {
1660
- await sendMessagePortToFileSystemWorker$1(port, 0);
1724
+ await sendMessagePortToFileSystemWorker$1(port, RpcId.OutputWorker);
1661
1725
  };
1662
1726
 
1663
1727
  const createFileSystemWorkerRpc = async () => {
@@ -1772,7 +1836,8 @@ const loadContent = async (state, savedState) => {
1772
1836
  error,
1773
1837
  code
1774
1838
  } = await loadLines(uri);
1775
- await setupChangeListener(uri);
1839
+ const watchId = createWatchId();
1840
+ await setupChangeListener(watchId, uri);
1776
1841
  const buttons = loadButtons();
1777
1842
  return {
1778
1843
  ...state,
@@ -1784,7 +1849,8 @@ const loadContent = async (state, savedState) => {
1784
1849
  filteredItems: lines,
1785
1850
  options,
1786
1851
  selectedOption: selectedId,
1787
- buttons
1852
+ buttons,
1853
+ watchId
1788
1854
  };
1789
1855
  };
1790
1856
 
@@ -1864,8 +1930,33 @@ const getActions = state => {
1864
1930
  }];
1865
1931
  };
1866
1932
 
1933
+ const refresh = async state => {
1934
+ const {
1935
+ filterValue,
1936
+ options,
1937
+ selectedOption
1938
+ } = state;
1939
+ const matchingOption = options.find(option => option.id === selectedOption);
1940
+ if (!matchingOption) {
1941
+ return state;
1942
+ }
1943
+ const {
1944
+ lines,
1945
+ error,
1946
+ code
1947
+ } = await loadLines(matchingOption.uri);
1948
+ const filteredItems = filterItems(lines, filterValue);
1949
+ return {
1950
+ ...state,
1951
+ listItems: lines,
1952
+ filteredItems,
1953
+ error,
1954
+ errorCode: code
1955
+ };
1956
+ };
1957
+
1867
1958
  const renderFilterValue = (oldState, newState) => {
1868
- return ['Viewlet.setValueByName', Filter, newState.filterValue];
1959
+ return ['Viewlet.setValueByName', newState.parentId, Filter, newState.filterValue];
1869
1960
  };
1870
1961
 
1871
1962
  const IconButton = 'IconButton';
@@ -2017,7 +2108,8 @@ const getFilterVirtualDom = () => {
2017
2108
  className: 'InputBox FilterInput',
2018
2109
  childCount: 0,
2019
2110
  placeholder,
2020
- onInput: HandleFilterInput
2111
+ onInput: HandleFilterInput,
2112
+ name: Filter
2021
2113
  }];
2022
2114
  };
2023
2115
 
@@ -2144,7 +2236,8 @@ const commandMap = {
2144
2236
  'Output.resize': resize,
2145
2237
  'Output.saveState': saveState,
2146
2238
  'Output.setOutputChannel': wrapCommand(setOutputChannel),
2147
- 'Output.terminate': terminate
2239
+ 'Output.terminate': terminate,
2240
+ 'Output.refresh': wrapCommand(refresh)
2148
2241
  };
2149
2242
 
2150
2243
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",