@lvce-editor/output-view 2.22.0 → 2.23.1

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.
@@ -1164,6 +1164,28 @@ const create$2 = rpcId => {
1164
1164
  };
1165
1165
  };
1166
1166
 
1167
+ const Log = 'log';
1168
+ const ToolBar = 'toolbar';
1169
+
1170
+ const Button = 1;
1171
+ const Div = 4;
1172
+ const Input = 6;
1173
+ const Span = 8;
1174
+ const Text$1 = 12;
1175
+ const A = 53;
1176
+ const Select$1 = 63;
1177
+ const Option$1 = 64;
1178
+
1179
+ const Space = 9;
1180
+ const PageUp = 10;
1181
+ const PageDown = 11;
1182
+ const End = 255;
1183
+ const Home = 12;
1184
+ const LeftArrow = 13;
1185
+ const UpArrow = 14;
1186
+ const RightArrow = 15;
1187
+ const DownArrow = 16;
1188
+
1167
1189
  const ExtensionManagementWorker = 9006;
1168
1190
  const FileSystemWorker = 209;
1169
1191
  const OutputWorker = 7001;
@@ -1231,42 +1253,68 @@ const create$1 = () => {
1231
1253
  const states = Object.create(null);
1232
1254
  const commandMapRef = {};
1233
1255
  return {
1234
- get(uid) {
1235
- return states[uid];
1256
+ clear() {
1257
+ for (const key of Object.keys(states)) {
1258
+ delete states[key];
1259
+ }
1236
1260
  },
1237
- set(uid, oldState, newState) {
1238
- states[uid] = {
1239
- oldState,
1240
- newState
1241
- };
1261
+ diff(uid, modules, numbers) {
1262
+ const {
1263
+ newState,
1264
+ oldState
1265
+ } = states[uid];
1266
+ const diffResult = [];
1267
+ for (let i = 0; i < modules.length; i++) {
1268
+ const fn = modules[i];
1269
+ if (!fn(oldState, newState)) {
1270
+ diffResult.push(numbers[i]);
1271
+ }
1272
+ }
1273
+ return diffResult;
1242
1274
  },
1243
1275
  dispose(uid) {
1244
1276
  delete states[uid];
1245
1277
  },
1278
+ get(uid) {
1279
+ return states[uid];
1280
+ },
1281
+ getCommandIds() {
1282
+ const keys = Object.keys(commandMapRef);
1283
+ const ids = keys.map(toCommandId);
1284
+ return ids;
1285
+ },
1246
1286
  getKeys() {
1247
1287
  return Object.keys(states).map(key => {
1248
- return Number.parseInt(key);
1288
+ return Number.parseFloat(key);
1249
1289
  });
1250
1290
  },
1251
- clear() {
1252
- for (const key of Object.keys(states)) {
1253
- delete states[key];
1254
- }
1291
+ registerCommands(commandMap) {
1292
+ Object.assign(commandMapRef, commandMap);
1293
+ },
1294
+ set(uid, oldState, newState) {
1295
+ states[uid] = {
1296
+ newState,
1297
+ oldState
1298
+ };
1255
1299
  },
1256
1300
  wrapCommand(fn) {
1257
1301
  const wrapped = async (uid, ...args) => {
1258
1302
  const {
1259
- oldState,
1260
- newState
1303
+ newState,
1304
+ oldState
1261
1305
  } = states[uid];
1262
1306
  const newerState = await fn(newState, ...args);
1263
1307
  if (oldState === newerState || newState === newerState) {
1264
1308
  return;
1265
1309
  }
1266
- const latest = states[uid];
1310
+ const latestOld = states[uid];
1311
+ const latestNew = {
1312
+ ...latestOld.newState,
1313
+ ...newerState
1314
+ };
1267
1315
  states[uid] = {
1268
- oldState: latest.oldState,
1269
- newState: newerState
1316
+ newState: latestNew,
1317
+ oldState: latestOld.oldState
1270
1318
  };
1271
1319
  };
1272
1320
  return wrapped;
@@ -1280,27 +1328,36 @@ const create$1 = () => {
1280
1328
  };
1281
1329
  return wrapped;
1282
1330
  },
1283
- diff(uid, modules, numbers) {
1284
- const {
1285
- oldState,
1286
- newState
1287
- } = states[uid];
1288
- const diffResult = [];
1289
- for (let i = 0; i < modules.length; i++) {
1290
- const fn = modules[i];
1291
- if (!fn(oldState, newState)) {
1292
- diffResult.push(numbers[i]);
1331
+ wrapLoadContent(fn) {
1332
+ const wrapped = async (uid, ...args) => {
1333
+ const {
1334
+ newState,
1335
+ oldState
1336
+ } = states[uid];
1337
+ const result = await fn(newState, ...args);
1338
+ const {
1339
+ error,
1340
+ state
1341
+ } = result;
1342
+ if (oldState === state || newState === state) {
1343
+ return {
1344
+ error
1345
+ };
1293
1346
  }
1294
- }
1295
- return diffResult;
1296
- },
1297
- getCommandIds() {
1298
- const keys = Object.keys(commandMapRef);
1299
- const ids = keys.map(toCommandId);
1300
- return ids;
1301
- },
1302
- registerCommands(commandMap) {
1303
- Object.assign(commandMapRef, commandMap);
1347
+ const latestOld = states[uid];
1348
+ const latestNew = {
1349
+ ...latestOld.newState,
1350
+ ...state
1351
+ };
1352
+ states[uid] = {
1353
+ newState: latestNew,
1354
+ oldState: latestOld.oldState
1355
+ };
1356
+ return {
1357
+ error
1358
+ };
1359
+ };
1360
+ return wrapped;
1304
1361
  }
1305
1362
  };
1306
1363
  };
@@ -1308,7 +1365,7 @@ const terminate = () => {
1308
1365
  globalThis.close();
1309
1366
  };
1310
1367
 
1311
- const Text$1 = 1;
1368
+ const Text = 1;
1312
1369
  const Link = 2;
1313
1370
  const LogLevel = 3;
1314
1371
  const RepeatCount = 4;
@@ -1379,12 +1436,16 @@ const Actions = 'Actions';
1379
1436
  const Message = 'Message';
1380
1437
  const Viewlet = 'Viewlet';
1381
1438
  const Output$1 = 'Output';
1382
- const Option$1 = 'Option';
1383
- const Select$1 = 'Select';
1439
+ const Option = 'Option';
1440
+ const Select = 'Select';
1384
1441
  const Error$1 = 'Error';
1385
1442
  const Line = 'Line';
1386
1443
  const OutputRepeatCount = 'OutputRepeatCount';
1387
1444
  const OutputSourceLink = 'OutputSourceLink';
1445
+ const ScrollBar = 'ScrollBar';
1446
+ const ScrollBarSmall = 'ScrollBarSmall';
1447
+ const ScrollBarThumb = 'ScrollBarThumb';
1448
+ const ScrollBarThumbActive = 'ScrollBarThumbActive';
1388
1449
 
1389
1450
  const RE_URL = /(?:https?:\/\/|file:\/\/|lvce(?:-oss)?:\/\/)\S+/;
1390
1451
  const trailingPunctuation = '!),.;?]}';
@@ -1429,14 +1490,14 @@ const parseStructuredLogLine = line => {
1429
1490
  type: LogLevel,
1430
1491
  value: normalizeLevel(parsed.level)
1431
1492
  }, {
1432
- type: Text$1,
1493
+ type: Text,
1433
1494
  value: parsed.message
1434
1495
  }];
1435
1496
  if (!parsed.source) {
1436
1497
  return parts;
1437
1498
  }
1438
1499
  return [...parts, {
1439
- type: Text$1,
1500
+ type: Text,
1440
1501
  value: ' '
1441
1502
  }, {
1442
1503
  className: OutputSourceLink,
@@ -1484,7 +1545,7 @@ const parseLine = line => {
1484
1545
  if (!match) {
1485
1546
  if (rest) {
1486
1547
  parts.push({
1487
- type: Text$1,
1548
+ type: Text,
1488
1549
  value: rest
1489
1550
  });
1490
1551
  }
@@ -1493,7 +1554,7 @@ const parseLine = line => {
1493
1554
  const index = rest.indexOf(match);
1494
1555
  if (index > 0) {
1495
1556
  parts.push({
1496
- type: Text$1,
1557
+ type: Text,
1497
1558
  value: rest.slice(0, index)
1498
1559
  });
1499
1560
  }
@@ -1502,7 +1563,7 @@ const parseLine = line => {
1502
1563
  }
1503
1564
  if (parts.length === 0) {
1504
1565
  return [{
1505
- type: Text$1,
1566
+ type: Text,
1506
1567
  value: ''
1507
1568
  }];
1508
1569
  }
@@ -1602,14 +1663,18 @@ const create = (id, uri, x, y, width, height, platform, parentId) => {
1602
1663
  const state = {
1603
1664
  buttons: [],
1604
1665
  collapsedUris: [],
1666
+ deltaY: 0,
1605
1667
  error: '',
1606
1668
  errorCode: 0,
1607
1669
  filteredItems: [],
1608
1670
  filterValue: '',
1671
+ finalDeltaY: 0,
1609
1672
  focusedIndex: -2,
1673
+ followOutput: true,
1674
+ handleOffset: 0,
1610
1675
  height,
1611
1676
  inputSource: User,
1612
- itemHeight: 22,
1677
+ itemHeight: 18,
1613
1678
  listItems: [],
1614
1679
  logLevel: 0,
1615
1680
  maxLineY: 0,
@@ -1618,6 +1683,8 @@ const create = (id, uri, x, y, width, height, platform, parentId) => {
1618
1683
  options: [],
1619
1684
  parentId,
1620
1685
  platform,
1686
+ scrollBarActive: false,
1687
+ scrollBarHeight: 0,
1621
1688
  scrollLockEnabled: false,
1622
1689
  selectedOption: '',
1623
1690
  smallWidthBreakPoint: 650,
@@ -1637,19 +1704,20 @@ const isEqual$2 = (oldState, newState) => {
1637
1704
  };
1638
1705
 
1639
1706
  const isEqual$1 = (oldState, newState) => {
1640
- return oldState.selectedOption === newState.selectedOption && oldState.listItems === newState.listItems && oldState.filteredItems === newState.filteredItems;
1707
+ return oldState.deltaY === newState.deltaY && oldState.height === newState.height && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarActive === newState.scrollBarActive && oldState.error === newState.error && oldState.errorCode === newState.errorCode && oldState.selectedOption === newState.selectedOption && oldState.listItems === newState.listItems && oldState.filteredItems === newState.filteredItems;
1641
1708
  };
1642
1709
 
1643
1710
  const isEqual = (oldState, newState) => {
1644
1711
  return oldState.selectedOption === newState.selectedOption;
1645
1712
  };
1646
1713
 
1714
+ const RenderCss = 4;
1647
1715
  const RenderItems = 1;
1648
1716
  const RenderFilterValue = 2;
1649
1717
  const RenderSelectedItem = 3;
1650
1718
 
1651
- const modules = [isEqual$1, isEqual$2, isEqual];
1652
- const numbers = [RenderItems, RenderFilterValue, RenderSelectedItem];
1719
+ const modules = [isEqual$1, isEqual$1, isEqual$2, isEqual];
1720
+ const numbers = [RenderCss, RenderItems, RenderFilterValue, RenderSelectedItem];
1653
1721
 
1654
1722
  const diff = (oldState, newState) => {
1655
1723
  const diffResult = [];
@@ -1662,12 +1730,46 @@ const diff = (oldState, newState) => {
1662
1730
  return diffResult;
1663
1731
  };
1664
1732
 
1733
+ const updateVirtualList = (state, requestedDeltaY) => {
1734
+ const {
1735
+ deltaY: currentDeltaY,
1736
+ filteredItems,
1737
+ followOutput,
1738
+ height,
1739
+ itemHeight,
1740
+ scrollLockEnabled
1741
+ } = state;
1742
+ const listHeight = Math.max(0, height);
1743
+ const contentHeight = filteredItems.length * itemHeight;
1744
+ const finalDeltaY = Math.max(0, contentHeight - listHeight);
1745
+ const requested = requestedDeltaY ?? (followOutput && !scrollLockEnabled ? finalDeltaY : currentDeltaY);
1746
+ const deltaY = Math.max(0, Math.min(Number.isFinite(requested) ? requested : 0, finalDeltaY));
1747
+ const minLineY = itemHeight > 0 ? Math.floor(deltaY / itemHeight) : 0;
1748
+ const maxLineY = itemHeight > 0 && listHeight > 0 ? Math.min(filteredItems.length, Math.ceil((deltaY + listHeight) / itemHeight)) : minLineY;
1749
+ const scrollBarHeight = finalDeltaY > 0 && listHeight > 0 ? Math.min(listHeight, Math.max(20, listHeight ** 2 / contentHeight)) : 0;
1750
+ return {
1751
+ ...state,
1752
+ deltaY,
1753
+ finalDeltaY,
1754
+ maxLineY,
1755
+ minLineY,
1756
+ scrollBarHeight
1757
+ };
1758
+ };
1759
+
1665
1760
  const diff2 = uid => {
1666
1761
  const {
1667
1762
  newState,
1668
1763
  oldState
1669
1764
  } = get(uid);
1670
- const diffResult = diff(oldState, newState);
1765
+ const reset = oldState.selectedOption !== newState.selectedOption || oldState.filterValue !== newState.filterValue;
1766
+ const updatedState = updateVirtualList(reset ? {
1767
+ ...newState,
1768
+ deltaY: 0,
1769
+ followOutput: true
1770
+ } : newState);
1771
+ set$1(uid, oldState, updatedState);
1772
+ const diffResult = diff(oldState, updatedState);
1671
1773
  return diffResult;
1672
1774
  };
1673
1775
 
@@ -1680,6 +1782,7 @@ const disableScrollLock = async state => {
1680
1782
  }
1681
1783
  return {
1682
1784
  ...state,
1785
+ followOutput: true,
1683
1786
  scrollLockEnabled: false
1684
1787
  };
1685
1788
  };
@@ -1704,28 +1807,6 @@ const focusIndex = (state, index) => {
1704
1807
  };
1705
1808
  };
1706
1809
 
1707
- const Log = 'log';
1708
- const ToolBar = 'toolbar';
1709
-
1710
- const Button = 1;
1711
- const Div = 4;
1712
- const Input = 6;
1713
- const Span = 8;
1714
- const Text = 12;
1715
- const A = 53;
1716
- const Select = 63;
1717
- const Option = 64;
1718
-
1719
- const Space = 9;
1720
- const PageUp = 10;
1721
- const PageDown = 11;
1722
- const End = 255;
1723
- const Home = 12;
1724
- const LeftArrow = 13;
1725
- const UpArrow = 14;
1726
- const RightArrow = 15;
1727
- const DownArrow = 16;
1728
-
1729
1810
  const mergeClassNames = (...classNames) => {
1730
1811
  return classNames.filter(Boolean).join(' ');
1731
1812
  };
@@ -1734,7 +1815,7 @@ const text = data => {
1734
1815
  return {
1735
1816
  childCount: 0,
1736
1817
  text: data,
1737
- type: Text
1818
+ type: Text$1
1738
1819
  };
1739
1820
  };
1740
1821
 
@@ -1846,6 +1927,39 @@ const handleFilterInput = async (state, value, inputSource = User) => {
1846
1927
  };
1847
1928
  };
1848
1929
 
1930
+ const setDeltaY = (state, deltaY) => {
1931
+ const newState = updateVirtualList(state, deltaY);
1932
+ return {
1933
+ ...newState,
1934
+ followOutput: newState.deltaY === newState.finalDeltaY
1935
+ };
1936
+ };
1937
+
1938
+ const handleKeyDown = (state, key) => {
1939
+ const {
1940
+ deltaY,
1941
+ finalDeltaY,
1942
+ height,
1943
+ itemHeight
1944
+ } = state;
1945
+ switch (key) {
1946
+ case 'ArrowDown':
1947
+ return setDeltaY(state, deltaY + itemHeight);
1948
+ case 'ArrowUp':
1949
+ return setDeltaY(state, deltaY - itemHeight);
1950
+ case 'End':
1951
+ return setDeltaY(state, finalDeltaY);
1952
+ case 'Home':
1953
+ return setDeltaY(state, 0);
1954
+ case 'PageDown':
1955
+ return setDeltaY(state, deltaY + height);
1956
+ case 'PageUp':
1957
+ return setDeltaY(state, deltaY - height);
1958
+ default:
1959
+ return state;
1960
+ }
1961
+ };
1962
+
1849
1963
  const state = {
1850
1964
  connected: false
1851
1965
  };
@@ -1883,6 +1997,69 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
1883
1997
  }
1884
1998
  };
1885
1999
 
2000
+ const handleScrollBarCaptureLost = state => {
2001
+ return {
2002
+ ...state,
2003
+ scrollBarActive: false
2004
+ };
2005
+ };
2006
+
2007
+ const getScrollBarTop = state => {
2008
+ const {
2009
+ deltaY,
2010
+ finalDeltaY,
2011
+ height,
2012
+ scrollBarHeight
2013
+ } = state;
2014
+ return finalDeltaY > 0 ? deltaY / finalDeltaY * (height - scrollBarHeight) : 0;
2015
+ };
2016
+
2017
+ const handleScrollBarClick = (state, eventY) => {
2018
+ const {
2019
+ finalDeltaY,
2020
+ height,
2021
+ scrollBarHeight,
2022
+ y
2023
+ } = state;
2024
+ if (scrollBarHeight <= 0) {
2025
+ return state;
2026
+ }
2027
+ const relativeY = eventY - y;
2028
+ const offset = relativeY - getScrollBarTop(state);
2029
+ if (offset >= 0 && offset < scrollBarHeight) {
2030
+ return {
2031
+ ...state,
2032
+ handleOffset: offset,
2033
+ scrollBarActive: true
2034
+ };
2035
+ }
2036
+ const handleOffset = scrollBarHeight / 2;
2037
+ const trackHeight = height - scrollBarHeight;
2038
+ const deltaY = trackHeight > 0 ? (relativeY - handleOffset) / trackHeight * finalDeltaY : 0;
2039
+ return {
2040
+ ...setDeltaY(state, deltaY),
2041
+ handleOffset,
2042
+ scrollBarActive: true
2043
+ };
2044
+ };
2045
+
2046
+ const handleScrollBarMove = (state, eventY) => {
2047
+ const {
2048
+ finalDeltaY,
2049
+ handleOffset,
2050
+ height,
2051
+ scrollBarActive,
2052
+ scrollBarHeight,
2053
+ y
2054
+ } = state;
2055
+ if (!scrollBarActive) {
2056
+ return state;
2057
+ }
2058
+ const trackHeight = height - scrollBarHeight;
2059
+ const deltaY = trackHeight > 0 ? (eventY - y - handleOffset) / trackHeight * finalDeltaY : 0;
2060
+ return setDeltaY(state, deltaY);
2061
+ };
2062
+
1886
2063
  const createWatchId = () => {
1887
2064
  const watchId = Math.random();
1888
2065
  return watchId;
@@ -1981,6 +2158,21 @@ const handleSourceLinkClick = async (state, uri, lineNumber, columnNumber) => {
1981
2158
  return state;
1982
2159
  };
1983
2160
 
2161
+ const handleWheel = (state, deltaMode, deltaY) => {
2162
+ const {
2163
+ deltaY: currentDeltaY,
2164
+ height,
2165
+ itemHeight
2166
+ } = state;
2167
+ let multiplier = 1;
2168
+ if (deltaMode === 1) {
2169
+ multiplier = itemHeight;
2170
+ } else if (deltaMode === 2) {
2171
+ multiplier = height;
2172
+ }
2173
+ return setDeltaY(state, currentDeltaY + deltaY * multiplier);
2174
+ };
2175
+
1984
2176
  const createExtensionManagementWorkerRpc = async () => {
1985
2177
  const rpc = await create$4({
1986
2178
  commandMap: {},
@@ -2199,6 +2391,7 @@ const getMatchingOpen = (options, id) => {
2199
2391
  const loadContent = async (state, savedState) => {
2200
2392
  const {
2201
2393
  platform,
2394
+ uri: requestedChannel,
2202
2395
  watchId
2203
2396
  } = state;
2204
2397
  const collapsedUris = getSavedCollapsedUris(savedState);
@@ -2207,7 +2400,7 @@ const loadContent = async (state, savedState) => {
2207
2400
  scrollLockEnabled,
2208
2401
  selectedOption
2209
2402
  } = restoreState(savedState);
2210
- const selectedId = getSelectedItem(selectedOption, platform);
2403
+ const selectedId = getSelectedItem(requestedChannel || selectedOption, platform);
2211
2404
  const options = await loadOptions(platform);
2212
2405
  const option = getMatchingOpen(options, selectedId);
2213
2406
  if (!option) {
@@ -2237,7 +2430,7 @@ const loadContent = async (state, savedState) => {
2237
2430
  listItems: lines,
2238
2431
  options,
2239
2432
  scrollLockEnabled,
2240
- selectedOption: selectedId,
2433
+ selectedOption: option.id,
2241
2434
  watchId: newWatchId
2242
2435
  };
2243
2436
  };
@@ -2278,6 +2471,43 @@ const refresh = async state => {
2278
2471
  };
2279
2472
  };
2280
2473
 
2474
+ const renderCss = (oldState, newState) => {
2475
+ const {
2476
+ deltaY,
2477
+ itemHeight,
2478
+ minLineY,
2479
+ scrollBarHeight,
2480
+ uid
2481
+ } = newState;
2482
+ const offset = minLineY * itemHeight - deltaY;
2483
+ const css = `.Output {
2484
+ position: relative;
2485
+ overflow: hidden;
2486
+ }
2487
+ .OutputContent {
2488
+ overflow-x: auto;
2489
+ overflow-y: hidden;
2490
+ scrollbar-width: none;
2491
+ padding-right: ${scrollBarHeight > 0 ? 14 : 0}px;
2492
+ }
2493
+ .OutputContent::-webkit-scrollbar {
2494
+ display: none;
2495
+ }
2496
+ .Output .Line {
2497
+ height: ${itemHeight}px;
2498
+ min-height: ${itemHeight}px;
2499
+ line-height: ${itemHeight}px;
2500
+ }
2501
+ .Output .Line:first-child {
2502
+ margin-top: ${offset}px;
2503
+ }
2504
+ .Output .ScrollBarThumb {
2505
+ height: ${scrollBarHeight}px;
2506
+ translate: 0 ${getScrollBarTop(newState)}px;
2507
+ }`;
2508
+ return ['Viewlet.setCss', uid, css];
2509
+ };
2510
+
2281
2511
  const renderFilterValue = (oldState, newState) => {
2282
2512
  return ['Viewlet.setValueByName', newState.uid, Filter$1, newState.filterValue];
2283
2513
  };
@@ -2290,6 +2520,11 @@ const HandlePointerDown = 'handlePointerDown';
2290
2520
  const HandleSelect = 'handleSelect';
2291
2521
  const HandleButtonClick = 'handleButtonClick';
2292
2522
  const HandleSourceLinkClick = 'handleSourceLinkClick';
2523
+ const HandleWheel = 'handleWheel';
2524
+ const HandleKeyDown = 'handleKeyDown';
2525
+ const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
2526
+ const HandleScrollBarMove = 'handleScrollBarMove';
2527
+ const HandleScrollBarPointerCaptureLost = 'handleScrollBarPointerCaptureLost';
2293
2528
 
2294
2529
  const noNodes = [];
2295
2530
  const repeatCountNode = {
@@ -2335,7 +2570,7 @@ const getLinePartDom = part => {
2335
2570
  childCount: 2,
2336
2571
  nodes: [repeatCountNode, text(part.value), spaceNode]
2337
2572
  };
2338
- case Text$1:
2573
+ case Text:
2339
2574
  return {
2340
2575
  childCount: 1,
2341
2576
  nodes: [text(part.value)]
@@ -2374,6 +2609,8 @@ const getContentDom = (lines, error) => {
2374
2609
  return [{
2375
2610
  childCount: lines.length,
2376
2611
  className: OutputContent,
2612
+ onKeyDown: HandleKeyDown,
2613
+ onWheel: HandleWheel,
2377
2614
  role: Log,
2378
2615
  tabIndex: Focusable,
2379
2616
  type: Div
@@ -2408,17 +2645,38 @@ const getErrorDom = (errorCode, error) => {
2408
2645
  return [errorNode, text(error)];
2409
2646
  };
2410
2647
 
2648
+ const scrollBarNode = {
2649
+ childCount: 1,
2650
+ className: mergeClassNames(ScrollBar, ScrollBarSmall),
2651
+ onPointerDown: HandleScrollBarPointerDown,
2652
+ type: Div
2653
+ };
2654
+ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarActive) => {
2655
+ if (scrollBarHeight <= 0) {
2656
+ return [];
2657
+ }
2658
+ return [scrollBarNode, {
2659
+ childCount: 0,
2660
+ className: mergeClassNames(ScrollBarThumb, scrollBarActive ? ScrollBarThumbActive : ''),
2661
+ type: Div
2662
+ }];
2663
+ };
2664
+
2411
2665
  const outputNode = {
2412
2666
  childCount: 1,
2413
2667
  className: mergeClassNames(Viewlet, Output$1),
2414
2668
  type: Div
2415
2669
  };
2416
- const getOutputVirtualDom = (lines, errorCode, error) => {
2417
- return [outputNode, ...getContentDom(lines, error), ...getErrorDom(errorCode, error)];
2670
+ const getOutputVirtualDom = (lines, errorCode, error, scrollBarHeight = 0, scrollBarActive = false) => {
2671
+ const scrollBarDom = error ? [] : getScrollBarVirtualDom(scrollBarHeight, scrollBarActive);
2672
+ return [{
2673
+ ...outputNode,
2674
+ childCount: scrollBarDom.length > 0 ? 2 : 1
2675
+ }, ...getContentDom(lines, error), ...getErrorDom(errorCode, error), ...scrollBarDom];
2418
2676
  };
2419
2677
 
2420
2678
  const renderItems = (oldState, newState) => {
2421
- const dom = getOutputVirtualDom(newState.filteredItems, newState.errorCode, newState.error);
2679
+ const dom = getOutputVirtualDom(newState.filteredItems.slice(newState.minLineY, newState.maxLineY), newState.errorCode, newState.error, newState.scrollBarHeight, newState.scrollBarActive);
2422
2680
  return ['Viewlet.setDom2', newState.uid, dom];
2423
2681
  };
2424
2682
 
@@ -2430,6 +2688,8 @@ const renderSelectedItem = (oldState, newState) => {
2430
2688
 
2431
2689
  const getRenderer = diffType => {
2432
2690
  switch (diffType) {
2691
+ case RenderCss:
2692
+ return renderCss;
2433
2693
  case RenderFilterValue:
2434
2694
  return renderFilterValue;
2435
2695
  case RenderItems:
@@ -2509,27 +2769,28 @@ const getFilterVirtualDom = () => {
2509
2769
  }];
2510
2770
  };
2511
2771
 
2512
- const getOptionVirtualDom = option => {
2772
+ const getOptionVirtualDom = (option, selected = false) => {
2513
2773
  const {
2514
2774
  id,
2515
2775
  label
2516
2776
  } = option;
2517
2777
  return [{
2518
2778
  childCount: 1,
2519
- className: Option$1,
2520
- type: Option,
2779
+ className: Option,
2780
+ selected,
2781
+ type: Option$1,
2521
2782
  value: id
2522
2783
  }, text(label)];
2523
2784
  };
2524
2785
 
2525
- const getSelectVirtualDom = options => {
2786
+ const getSelectVirtualDom = (options, selectedOption = '') => {
2526
2787
  return [{
2527
2788
  childCount: options.length,
2528
- className: Select$1,
2789
+ className: Select,
2529
2790
  name: Output,
2530
2791
  onChange: HandleSelect,
2531
- type: Select
2532
- }, ...options.flatMap(getOptionVirtualDom)];
2792
+ type: Select$1
2793
+ }, ...options.flatMap(option => getOptionVirtualDom(option, option.id === selectedOption))];
2533
2794
  };
2534
2795
 
2535
2796
  const getChildCount = buttonsLength => {
@@ -2537,27 +2798,47 @@ const getChildCount = buttonsLength => {
2537
2798
  const filterCount = 1;
2538
2799
  return buttonsLength + filterCount + selectLength;
2539
2800
  };
2540
- const getActionsVirtualDom = (options, buttons) => {
2801
+ const getActionsVirtualDom = (options, buttons, selectedOption = '') => {
2541
2802
  const childCount = getChildCount(buttons.length);
2542
2803
  return [{
2543
2804
  childCount,
2544
2805
  className: Actions,
2545
2806
  role: ToolBar,
2546
2807
  type: Div
2547
- }, ...getFilterVirtualDom(), ...getSelectVirtualDom(options), ...getActionButtonsVirtualDom(buttons)];
2808
+ }, ...getFilterVirtualDom(), ...getSelectVirtualDom(options, selectedOption), ...getActionButtonsVirtualDom(buttons)];
2548
2809
  };
2549
2810
 
2550
2811
  const renderActions = state => {
2551
2812
  const {
2552
2813
  buttons,
2553
- options
2814
+ options,
2815
+ selectedOption
2554
2816
  } = state;
2555
- const dom = getActionsVirtualDom(options, buttons);
2817
+ const dom = getActionsVirtualDom(options, buttons, selectedOption);
2556
2818
  return dom;
2557
2819
  };
2558
2820
 
2559
2821
  const renderEventListeners = () => {
2560
2822
  return [{
2823
+ name: HandleWheel,
2824
+ params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
2825
+ passive: true
2826
+ }, {
2827
+ name: HandleKeyDown,
2828
+ params: ['handleKeyDown', 'event.key']
2829
+ }, {
2830
+ name: HandleScrollBarPointerDown,
2831
+ params: ['handleScrollBarClick', 'event.clientY'],
2832
+ preventDefault: true,
2833
+ stopPropagation: true,
2834
+ trackPointerEvents: [HandleScrollBarMove, HandleScrollBarPointerCaptureLost]
2835
+ }, {
2836
+ name: HandleScrollBarMove,
2837
+ params: ['handleScrollBarMove', 'event.clientY']
2838
+ }, {
2839
+ name: HandleScrollBarPointerCaptureLost,
2840
+ params: ['handleScrollBarCaptureLost']
2841
+ }, {
2561
2842
  name: HandleBlur,
2562
2843
  params: ['handleBlur']
2563
2844
  }, {
@@ -2668,9 +2949,14 @@ const commandMap = {
2668
2949
  'Output.handleData': wrapCommand(handleData),
2669
2950
  'Output.handleError': wrapCommand(handleError),
2670
2951
  'Output.handleFilterInput': wrapCommand(handleFilterInput),
2952
+ 'Output.handleKeyDown': wrapCommand(handleKeyDown),
2671
2953
  'Output.handleMessagePort': handleDirectMessagePort,
2954
+ 'Output.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
2955
+ 'Output.handleScrollBarClick': wrapCommand(handleScrollBarClick),
2956
+ 'Output.handleScrollBarMove': wrapCommand(handleScrollBarMove),
2672
2957
  'Output.handleSelect': wrapCommand(handleSelect),
2673
2958
  'Output.handleSourceLinkClick': wrapCommand(handleSourceLinkClick),
2959
+ 'Output.handleWheel': wrapCommand(handleWheel),
2674
2960
  'Output.initialize': initialize,
2675
2961
  'Output.loadContent2': wrapCommand(loadContent),
2676
2962
  'Output.openFindWidget': wrapCommand(openFindWidget),
@@ -2678,10 +2964,11 @@ const commandMap = {
2678
2964
  'Output.render2': render2,
2679
2965
  'Output.renderActions': wrapGetter(renderActions),
2680
2966
  'Output.renderEventListeners': renderEventListeners,
2681
- 'Output.resize': resize,
2967
+ 'Output.resize': wrapCommand(resize),
2682
2968
  'Output.saveAs': wrapCommand(saveOutputAs),
2683
2969
  'Output.saveState': wrapGetter(saveState),
2684
2970
  'Output.selectChannel': wrapCommand(selectChannel),
2971
+ 'Output.setDeltaY': wrapCommand(setDeltaY),
2685
2972
  'Output.setLogLevel': setLogLevel,
2686
2973
  'Output.setOutputChannel': wrapCommand(setOutputChannel),
2687
2974
  'Output.terminate': terminate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.22.0",
3
+ "version": "2.23.1",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",