@lvce-editor/text-search-worker 7.4.0 → 7.5.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.
@@ -54,64 +54,52 @@ class VError extends Error {
54
54
  }
55
55
  }
56
56
 
57
- class AssertionError extends Error {
57
+ let AssertionError$1 = class AssertionError extends Error {
58
58
  constructor(message) {
59
59
  super(message);
60
60
  this.name = 'AssertionError';
61
61
  }
62
- }
63
- const Object$1 = 1;
64
- const Number$1 = 2;
65
- const Array$1 = 3;
66
- const String = 4;
67
- const Boolean$1 = 5;
68
- const Function = 6;
69
- const Null = 7;
70
- const Unknown = 8;
71
- const getType = value => {
62
+ };
63
+ const Object$1$1 = 1;
64
+ const Number$2 = 2;
65
+ const Array$1$1 = 3;
66
+ const String$2 = 4;
67
+ const Boolean$2 = 5;
68
+ const Function$1 = 6;
69
+ const Null$1 = 7;
70
+ const Unknown$1 = 8;
71
+ const getType$1 = value => {
72
72
  switch (typeof value) {
73
73
  case 'number':
74
- return Number$1;
74
+ return Number$2;
75
75
  case 'function':
76
- return Function;
76
+ return Function$1;
77
77
  case 'string':
78
- return String;
78
+ return String$2;
79
79
  case 'object':
80
80
  if (value === null) {
81
- return Null;
81
+ return Null$1;
82
82
  }
83
83
  if (Array.isArray(value)) {
84
- return Array$1;
84
+ return Array$1$1;
85
85
  }
86
- return Object$1;
86
+ return Object$1$1;
87
87
  case 'boolean':
88
- return Boolean$1;
88
+ return Boolean$2;
89
89
  default:
90
- return Unknown;
90
+ return Unknown$1;
91
91
  }
92
92
  };
93
93
  const object = value => {
94
- const type = getType(value);
95
- if (type !== Object$1) {
96
- throw new AssertionError('expected value to be of type object');
94
+ const type = getType$1(value);
95
+ if (type !== Object$1$1) {
96
+ throw new AssertionError$1('expected value to be of type object');
97
97
  }
98
98
  };
99
- const number = value => {
100
- const type = getType(value);
101
- if (type !== Number$1) {
102
- throw new AssertionError('expected value to be of type number');
103
- }
104
- };
105
- const array = value => {
106
- const type = getType(value);
107
- if (type !== Array$1) {
108
- throw new AssertionError('expected value to be of type array');
109
- }
110
- };
111
- const string = value => {
112
- const type = getType(value);
113
- if (type !== String) {
114
- throw new AssertionError('expected value to be of type string');
99
+ const number$1 = value => {
100
+ const type = getType$1(value);
101
+ if (type !== Number$2) {
102
+ throw new AssertionError$1('expected value to be of type number');
115
103
  }
116
104
  };
117
105
 
@@ -157,7 +145,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
157
145
  for (const property of Object.values(value)) {
158
146
  walkValue(property, transferrables, isTransferrable);
159
147
  }
160
- return;
161
148
  }
162
149
  };
163
150
  const getTransferrables = value => {
@@ -311,7 +298,14 @@ class IpcError extends VError {
311
298
  const cause = new Error(message);
312
299
  // @ts-ignore
313
300
  cause.code = code;
314
- cause.stack = stack;
301
+ if (stack) {
302
+ Object.defineProperty(cause, 'stack', {
303
+ configurable: true,
304
+ enumerable: false,
305
+ value: stack,
306
+ writable: true
307
+ });
308
+ }
315
309
  super(cause, betterMessage);
316
310
  } else {
317
311
  super(betterMessage);
@@ -1186,9 +1180,14 @@ const create$7 = async ({
1186
1180
  }) => {
1187
1181
  // TODO create a commandMap per rpc instance
1188
1182
  register(commandMap);
1189
- const rawIpc = await IpcParentWithWebSocket$1.create({
1190
- webSocket
1191
- });
1183
+ let rawIpc;
1184
+ try {
1185
+ rawIpc = await IpcParentWithWebSocket$1.create({
1186
+ webSocket
1187
+ });
1188
+ } catch (error) {
1189
+ throw new VError(error, 'Failed to create rpc connection');
1190
+ }
1192
1191
  const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
1193
1192
  handleIpc(ipc);
1194
1193
  const rpc = createRpc(ipc);
@@ -1301,10 +1300,299 @@ const create$3 = rpcId => {
1301
1300
  };
1302
1301
  };
1303
1302
 
1303
+ const Alert = 'alert';
1304
+ const Button$3 = 'button';
1305
+ const CheckBox = 'checkbox';
1306
+ const None$2 = 'none';
1307
+ const ScrollBar$1 = 'scrollbar';
1308
+ const Status = 'status';
1309
+ const ToolBar = 'toolbar';
1310
+ const Tree$1 = 'tree';
1311
+ const TreeItem$1 = 'treeitem';
1312
+
1313
+ const Actions = 'Actions';
1314
+ const Badge = 'Badge';
1315
+ const Chevron = 'Chevron';
1316
+ const CloseMaskIcon = 'MaskIcon MaskIconClose';
1317
+ const Empty$1 = '';
1318
+ const FileIcon = 'FileIcon';
1319
+ const FocusOutline = 'FocusOutline';
1320
+ const Grow = 'Grow';
1321
+ const Highlight = 'Highlight';
1322
+ const HighlightDeleted = 'HighlightDeleted';
1323
+ const HighlightInserted = 'HighlightInserted';
1324
+ const IconButton = 'IconButton';
1325
+ const IconButtonDisabled = 'IconButtonDisabled';
1326
+ const Label$1 = 'Label';
1327
+ const List$1 = 'List';
1328
+ const MaskIcon = 'MaskIcon';
1329
+ const MaskIconBook = 'MaskIconBook';
1330
+ const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1331
+ const MaskIconChevronDown = 'MaskIconChevronDown';
1332
+ const MaskIconChevronRight = 'MaskIconChevronRight';
1333
+ const MaskIconEllipsis = 'MaskIconEllipsis';
1334
+ const MaskIconExclude = 'MaskIconExclude';
1335
+ const MaskIconPreserveCase = 'MaskIconPreserveCase';
1336
+ const MaskIconRegex = 'MaskIconRegex';
1337
+ const MaskIconReplaceAll = 'MaskIconReplaceAll';
1338
+ const MaskIconWholeWord = 'MaskIconWholeWord';
1339
+ const MultilineInputBox = 'MultilineInputBox';
1340
+ const ScrollBar = 'ScrollBar';
1341
+ const ScrollBarThumb = 'ScrollBarThumb';
1342
+ const ScrollBarVertical = 'ScrollBarVertical';
1343
+ const Search$3 = 'Search';
1344
+ const SearchField = 'SearchField';
1345
+ const SearchFieldButton = 'SearchFieldButton';
1346
+ const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
1347
+ const SearchFieldButtonDisabled = 'SearchFieldButtonDisabled';
1348
+ const SearchFieldButtons = 'SearchFieldButtons';
1349
+ const SearchFieldContainer = 'SearchFieldContainer';
1350
+ const SearchFieldError = 'SearchFieldError';
1351
+ const SearchHeader = 'SearchHeader';
1352
+ const SearchHeaderDetails = 'SearchHeaderDetails';
1353
+ const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1354
+ const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
1355
+ const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
1356
+ const SearchHeaderTop = 'SearchHeaderTop';
1357
+ const SearchHeaderTopRight = 'SearchHeaderTopRight';
1358
+ const SearchInputError = 'SearchInputError';
1359
+ const SearchRemove = 'SearchRemove';
1360
+ const SearchToggleButton = 'SearchToggleButton';
1361
+ const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1362
+ const SourceControlBadge = 'SourceControlBadge';
1363
+ const ToggleDetails = 'ToggleDetails';
1364
+ const Tree = 'Tree';
1365
+ const TreeItem = 'TreeItem';
1366
+ const TreeItemActive = 'TreeItemActive';
1367
+ const TreeItems$1 = 'TreeItems';
1368
+ const Viewlet = 'Viewlet';
1369
+ const ViewletSearchMessage = 'ViewletSearchMessage';
1370
+ const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1371
+
1372
+ const File$2 = 7;
1373
+
1374
+ const Audio = 0;
1375
+ const Button$2 = 1;
1376
+ const Col = 2;
1377
+ const ColGroup = 3;
1378
+ const Div = 4;
1379
+ const H1 = 5;
1380
+ const Input = 6;
1381
+ const Kbd = 7;
1382
+ const Span = 8;
1383
+ const Table = 9;
1384
+ const TBody = 10;
1385
+ const Td = 11;
1386
+ const Text = 12;
1387
+ const Th = 13;
1388
+ const THead = 14;
1389
+ const Tr = 15;
1390
+ const I = 16;
1391
+ const Img = 17;
1392
+ const Root = 0;
1393
+ const Ins = 20;
1394
+ const Del = 21;
1395
+ const H2 = 22;
1396
+ const H3 = 23;
1397
+ const H4 = 24;
1398
+ const H5 = 25;
1399
+ const H6 = 26;
1400
+ const Article = 27;
1401
+ const Aside = 28;
1402
+ const Footer = 29;
1403
+ const Header = 30;
1404
+ const Nav = 40;
1405
+ const Section = 41;
1406
+ const Search$2 = 42;
1407
+ const Dd = 43;
1408
+ const Dl = 44;
1409
+ const Figcaption = 45;
1410
+ const Figure = 46;
1411
+ const Hr = 47;
1412
+ const Li = 48;
1413
+ const Ol = 49;
1414
+ const P = 50;
1415
+ const Pre = 51;
1416
+ const A = 53;
1417
+ const Abbr = 54;
1418
+ const Br = 55;
1419
+ const Cite = 56;
1420
+ const Data = 57;
1421
+ const Time = 58;
1422
+ const Tfoot = 59;
1423
+ const Ul = 60;
1424
+ const Video = 61;
1425
+ const TextArea = 62;
1426
+ const Select = 63;
1427
+ const Option = 64;
1428
+ const Code = 65;
1429
+ const Label = 66;
1430
+ const Dt = 67;
1431
+ const Iframe = 68;
1432
+ const Main = 69;
1433
+ const Strong = 70;
1434
+ const Em = 71;
1435
+ const Style = 72;
1436
+ const Html = 73;
1437
+ const Head = 74;
1438
+ const Title = 75;
1439
+ const Meta = 76;
1440
+ const Canvas = 77;
1441
+ const Form = 78;
1442
+ const BlockQuote = 79;
1443
+ const Quote = 80;
1444
+ const Circle = 81;
1445
+ const Defs = 82;
1446
+ const Ellipse = 83;
1447
+ const G = 84;
1448
+ const Line = 85;
1449
+ const Path = 86;
1450
+ const Polygon = 87;
1451
+ const Polyline = 88;
1452
+ const Rect = 89;
1453
+ const Svg = 90;
1454
+ const Use = 91;
1455
+ const Reference = 100;
1456
+
1457
+ const VirtualDomElements = {
1458
+ __proto__: null,
1459
+ A,
1460
+ Abbr,
1461
+ Article,
1462
+ Aside,
1463
+ Audio,
1464
+ BlockQuote,
1465
+ Br,
1466
+ Button: Button$2,
1467
+ Canvas,
1468
+ Circle,
1469
+ Cite,
1470
+ Code,
1471
+ Col,
1472
+ ColGroup,
1473
+ Data,
1474
+ Dd,
1475
+ Defs,
1476
+ Del,
1477
+ Div,
1478
+ Dl,
1479
+ Dt,
1480
+ Ellipse,
1481
+ Em,
1482
+ Figcaption,
1483
+ Figure,
1484
+ Footer,
1485
+ Form,
1486
+ G,
1487
+ H1,
1488
+ H2,
1489
+ H3,
1490
+ H4,
1491
+ H5,
1492
+ H6,
1493
+ Head,
1494
+ Header,
1495
+ Hr,
1496
+ Html,
1497
+ I,
1498
+ Iframe,
1499
+ Img,
1500
+ Input,
1501
+ Ins,
1502
+ Kbd,
1503
+ Label,
1504
+ Li,
1505
+ Line,
1506
+ Main,
1507
+ Meta,
1508
+ Nav,
1509
+ Ol,
1510
+ Option,
1511
+ P,
1512
+ Path,
1513
+ Polygon,
1514
+ Polyline,
1515
+ Pre,
1516
+ Quote,
1517
+ Rect,
1518
+ Reference,
1519
+ Root,
1520
+ Search: Search$2,
1521
+ Section,
1522
+ Select,
1523
+ Span,
1524
+ Strong,
1525
+ Style,
1526
+ Svg,
1527
+ TBody,
1528
+ THead,
1529
+ Table,
1530
+ Td,
1531
+ Text,
1532
+ TextArea,
1533
+ Tfoot,
1534
+ Th,
1535
+ Time,
1536
+ Title,
1537
+ Tr,
1538
+ Ul,
1539
+ Use,
1540
+ Video
1541
+ };
1542
+
1543
+ const Button$1 = 'event.button';
1544
+ const ClientX = 'event.clientX';
1545
+ const ClientY = 'event.clientY';
1546
+ const DeltaMode = 'event.deltaMode';
1547
+ const DeltaY = 'event.deltaY';
1548
+ const TargetName = 'event.target.name';
1549
+ const TargetSelectionEnd = 'event.target.selectionEnd';
1550
+ const TargetSelectionStart = 'event.target.selectionStart';
1551
+ const TargetValue = 'event.target.value';
1552
+
1553
+ const Script$1 = 2;
1554
+
1555
+ const Search$1 = 18;
1556
+ const InputContextMenu = 91;
1557
+
1558
+ const Separator = 1;
1559
+ const None$1 = 0;
1560
+
1561
+ const LeftClick = 0;
1562
+
1563
+ const Electron = 2;
1564
+ const Remote = 3;
1565
+
1304
1566
  const IconThemeWorker = 7009;
1305
1567
  const RendererWorker = 1;
1306
1568
  const SearchProcess = 77;
1307
1569
 
1570
+ const File$1 = 1;
1571
+ const Match$1 = 2;
1572
+
1573
+ const FocusElementByName = 'Viewlet.focusElementByName';
1574
+ const SetCss = 'Viewlet.setCss';
1575
+ const SetFocusContext = 'Viewlet.setFocusContext';
1576
+ const SetValueByName = 'Viewlet.setValueByName';
1577
+ const SetPatches = 'Viewlet.setPatches';
1578
+
1579
+ const Empty = 0;
1580
+ const FocusIgnoreFiles = 1012;
1581
+ const FocusSearch = 1013;
1582
+ const FocusSearchExcludeInput = 1008;
1583
+ const FocusSearchIncludeInput = 1007;
1584
+ const FocusSearchInput = 21;
1585
+ const FocusSearchMatchCase = 32;
1586
+ const FocusSearchOpenEditors = 1011;
1587
+ const FocusSearchPreserveCase = 36;
1588
+ const FocusSearchRegex = 33;
1589
+ const FocusSearchReplaceAll = 35;
1590
+ const FocusSearchReplaceInput = 31;
1591
+ const FocusSearchResults = 22;
1592
+ const FocusSearchWholeWord = 34;
1593
+ const FocusToggleDetails = 1010;
1594
+ const FocusToggleReplace = 1020;
1595
+
1308
1596
  const {
1309
1597
  invoke: invoke$2,
1310
1598
  set: set$3
@@ -1314,6 +1602,61 @@ const getIcons = async iconRequests => {
1314
1602
  return invoke$2('IconTheme.getIcons', iconRequests);
1315
1603
  };
1316
1604
 
1605
+ class AssertionError extends Error {
1606
+ constructor(message) {
1607
+ super(message);
1608
+ this.name = 'AssertionError';
1609
+ }
1610
+ }
1611
+ const Object$1 = 1;
1612
+ const Number$1 = 2;
1613
+ const Array$1 = 3;
1614
+ const String$1 = 4;
1615
+ const Boolean$1 = 5;
1616
+ const Function = 6;
1617
+ const Null = 7;
1618
+ const Unknown = 8;
1619
+ const getType = value => {
1620
+ switch (typeof value) {
1621
+ case 'number':
1622
+ return Number$1;
1623
+ case 'function':
1624
+ return Function;
1625
+ case 'string':
1626
+ return String$1;
1627
+ case 'object':
1628
+ if (value === null) {
1629
+ return Null;
1630
+ }
1631
+ if (Array.isArray(value)) {
1632
+ return Array$1;
1633
+ }
1634
+ return Object$1;
1635
+ case 'boolean':
1636
+ return Boolean$1;
1637
+ default:
1638
+ return Unknown;
1639
+ }
1640
+ };
1641
+ const number = value => {
1642
+ const type = getType(value);
1643
+ if (type !== Number$1) {
1644
+ throw new AssertionError('expected value to be of type number');
1645
+ }
1646
+ };
1647
+ const array = value => {
1648
+ const type = getType(value);
1649
+ if (type !== Array$1) {
1650
+ throw new AssertionError('expected value to be of type array');
1651
+ }
1652
+ };
1653
+ const string = value => {
1654
+ const type = getType(value);
1655
+ if (type !== String$1) {
1656
+ throw new AssertionError('expected value to be of type string');
1657
+ }
1658
+ };
1659
+
1317
1660
  const {
1318
1661
  invoke: invoke$1,
1319
1662
  invokeAndTransfer,
@@ -1356,29 +1699,87 @@ const toCommandId = key => {
1356
1699
  return key.slice(dotIndex + 1);
1357
1700
  };
1358
1701
  const create$2 = () => {
1702
+ const commandQueues = new Map();
1703
+ const generations = Object.create(null);
1359
1704
  const states = Object.create(null);
1360
1705
  const commandMapRef = {};
1706
+ const getGeneration = uid => generations[uid] || 0;
1707
+ const isCurrentGeneration = (uid, generation) => {
1708
+ return states[uid] !== undefined && getGeneration(uid) === generation;
1709
+ };
1710
+ const updateState = (uid, generation, fallbackState, updater) => {
1711
+ if (!isCurrentGeneration(uid, generation)) {
1712
+ return Promise.resolve(fallbackState);
1713
+ }
1714
+ const current = states[uid];
1715
+ const updatedState = updater(current.newState);
1716
+ if (updatedState !== current.newState) {
1717
+ states[uid] = {
1718
+ newState: updatedState,
1719
+ oldState: current.oldState,
1720
+ scheduledState: updatedState
1721
+ };
1722
+ }
1723
+ return Promise.resolve(updatedState);
1724
+ };
1725
+ const createAsyncCommandContext = (uid, generation) => {
1726
+ let latestState = states[uid].newState;
1727
+ return {
1728
+ getState: () => {
1729
+ if (isCurrentGeneration(uid, generation)) {
1730
+ latestState = states[uid].newState;
1731
+ }
1732
+ return latestState;
1733
+ },
1734
+ updateState: async updater => {
1735
+ latestState = await updateState(uid, generation, latestState, updater);
1736
+ return latestState;
1737
+ }
1738
+ };
1739
+ };
1740
+ const enqueueCommand = async (uid, command) => {
1741
+ const previous = commandQueues.get(uid) || Promise.resolve();
1742
+ const run = async () => {
1743
+ try {
1744
+ await previous;
1745
+ } catch {
1746
+ // The previous caller receives its error; later commands must still run.
1747
+ }
1748
+ await command();
1749
+ };
1750
+ const current = run();
1751
+ commandQueues.set(uid, current);
1752
+ try {
1753
+ await current;
1754
+ } finally {
1755
+ if (commandQueues.get(uid) === current) {
1756
+ commandQueues.delete(uid);
1757
+ }
1758
+ }
1759
+ };
1361
1760
  return {
1362
1761
  clear() {
1762
+ commandQueues.clear();
1363
1763
  for (const key of Object.keys(states)) {
1364
1764
  delete states[key];
1365
1765
  }
1366
1766
  },
1367
1767
  diff(uid, modules, numbers) {
1368
1768
  const {
1369
- newState,
1370
- oldState
1769
+ oldState,
1770
+ scheduledState
1371
1771
  } = states[uid];
1372
1772
  const diffResult = [];
1373
1773
  for (let i = 0; i < modules.length; i++) {
1374
1774
  const fn = modules[i];
1375
- if (!fn(oldState, newState)) {
1775
+ if (!fn(oldState, scheduledState)) {
1376
1776
  diffResult.push(numbers[i]);
1377
1777
  }
1378
1778
  }
1379
1779
  return diffResult;
1380
1780
  },
1381
1781
  dispose(uid) {
1782
+ commandQueues.delete(uid);
1382
1783
  delete states[uid];
1383
1784
  },
1384
1785
  get(uid) {
@@ -1390,21 +1791,33 @@ const create$2 = () => {
1390
1791
  return ids;
1391
1792
  },
1392
1793
  getKeys() {
1393
- return Object.keys(states).map(key => {
1394
- return Number.parseFloat(key);
1395
- });
1794
+ return Object.keys(states).map(Number);
1396
1795
  },
1397
1796
  registerCommands(commandMap) {
1398
1797
  Object.assign(commandMapRef, commandMap);
1399
1798
  },
1400
- set(uid, oldState, newState) {
1799
+ set(uid, oldState, newState, scheduledState) {
1800
+ const current = states[uid];
1801
+ if (!current || oldState === newState && newState !== current.newState) {
1802
+ generations[uid] = getGeneration(uid) + 1;
1803
+ }
1401
1804
  states[uid] = {
1402
1805
  newState,
1403
- oldState
1806
+ oldState,
1807
+ scheduledState: scheduledState ?? newState
1404
1808
  };
1405
1809
  },
1810
+ wrapAsyncCommand(fn) {
1811
+ const wrapped = async (uid, ...args) => {
1812
+ const generation = getGeneration(uid);
1813
+ const context = createAsyncCommandContext(uid, generation);
1814
+ await fn(context, ...args);
1815
+ };
1816
+ return wrapped;
1817
+ },
1406
1818
  wrapCommand(fn) {
1407
1819
  const wrapped = async (uid, ...args) => {
1820
+ const generation = getGeneration(uid);
1408
1821
  const {
1409
1822
  newState,
1410
1823
  oldState
@@ -1413,6 +1826,9 @@ const create$2 = () => {
1413
1826
  if (oldState === newerState || newState === newerState) {
1414
1827
  return;
1415
1828
  }
1829
+ if (!isCurrentGeneration(uid, generation)) {
1830
+ return;
1831
+ }
1416
1832
  const latestOld = states[uid];
1417
1833
  const latestNew = {
1418
1834
  ...latestOld.newState,
@@ -1420,7 +1836,8 @@ const create$2 = () => {
1420
1836
  };
1421
1837
  states[uid] = {
1422
1838
  newState: latestNew,
1423
- oldState: latestOld.oldState
1839
+ oldState: latestOld.oldState,
1840
+ scheduledState: latestNew
1424
1841
  };
1425
1842
  };
1426
1843
  return wrapped;
@@ -1436,6 +1853,7 @@ const create$2 = () => {
1436
1853
  },
1437
1854
  wrapLoadContent(fn) {
1438
1855
  const wrapped = async (uid, ...args) => {
1856
+ const generation = getGeneration(uid);
1439
1857
  const {
1440
1858
  newState,
1441
1859
  oldState
@@ -1450,6 +1868,11 @@ const create$2 = () => {
1450
1868
  error
1451
1869
  };
1452
1870
  }
1871
+ if (!isCurrentGeneration(uid, generation)) {
1872
+ return {
1873
+ error
1874
+ };
1875
+ }
1453
1876
  const latestOld = states[uid];
1454
1877
  const latestNew = {
1455
1878
  ...latestOld.newState,
@@ -1457,13 +1880,59 @@ const create$2 = () => {
1457
1880
  };
1458
1881
  states[uid] = {
1459
1882
  newState: latestNew,
1460
- oldState: latestOld.oldState
1883
+ oldState: latestOld.oldState,
1884
+ scheduledState: latestNew
1461
1885
  };
1462
1886
  return {
1463
1887
  error
1464
1888
  };
1465
1889
  };
1466
1890
  return wrapped;
1891
+ },
1892
+ wrapSerialAsyncCommand(fn) {
1893
+ const wrapped = async (uid, ...args) => {
1894
+ await enqueueCommand(uid, async () => {
1895
+ if (!states[uid]) {
1896
+ return;
1897
+ }
1898
+ const generation = getGeneration(uid);
1899
+ const context = createAsyncCommandContext(uid, generation);
1900
+ await fn(context, ...args);
1901
+ });
1902
+ };
1903
+ return wrapped;
1904
+ },
1905
+ wrapSerialCommand(fn) {
1906
+ const wrapped = async (uid, ...args) => {
1907
+ await enqueueCommand(uid, async () => {
1908
+ if (!states[uid]) {
1909
+ return;
1910
+ }
1911
+ const generation = getGeneration(uid);
1912
+ const {
1913
+ newState,
1914
+ oldState
1915
+ } = states[uid];
1916
+ const newerState = await fn(newState, ...args);
1917
+ if (oldState === newerState || newState === newerState) {
1918
+ return;
1919
+ }
1920
+ if (!isCurrentGeneration(uid, generation)) {
1921
+ return;
1922
+ }
1923
+ const latestOld = states[uid];
1924
+ const latestNew = {
1925
+ ...latestOld.newState,
1926
+ ...newerState
1927
+ };
1928
+ states[uid] = {
1929
+ newState: latestNew,
1930
+ oldState: latestOld.oldState,
1931
+ scheduledState: latestNew
1932
+ };
1933
+ });
1934
+ };
1935
+ return wrapped;
1467
1936
  }
1468
1937
  };
1469
1938
  };
@@ -1471,137 +1940,6 @@ const terminate = () => {
1471
1940
  globalThis.close();
1472
1941
  };
1473
1942
 
1474
- const Alert = 'alert';
1475
- const Button$3 = 'button';
1476
- const CheckBox = 'checkbox';
1477
- const None$2 = 'none';
1478
- const ScrollBar$1 = 'scrollbar';
1479
- const Status = 'status';
1480
- const ToolBar = 'toolbar';
1481
- const Tree$1 = 'tree';
1482
- const TreeItem$1 = 'treeitem';
1483
-
1484
- const Actions = 'Actions';
1485
- const Badge = 'Badge';
1486
- const Chevron = 'Chevron';
1487
- const CloseMaskIcon = 'MaskIcon MaskIconClose';
1488
- const Empty$1 = '';
1489
- const FileIcon = 'FileIcon';
1490
- const FocusOutline = 'FocusOutline';
1491
- const Grow = 'Grow';
1492
- const Highlight = 'Highlight';
1493
- const HighlightDeleted = 'HighlightDeleted';
1494
- const HighlightInserted = 'HighlightInserted';
1495
- const IconButton = 'IconButton';
1496
- const IconButtonDisabled = 'IconButtonDisabled';
1497
- const Label = 'Label';
1498
- const List$1 = 'List';
1499
- const MaskIcon = 'MaskIcon';
1500
- const MaskIconBook = 'MaskIconBook';
1501
- const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1502
- const MaskIconChevronDown = 'MaskIconChevronDown';
1503
- const MaskIconChevronRight = 'MaskIconChevronRight';
1504
- const MaskIconEllipsis = 'MaskIconEllipsis';
1505
- const MaskIconExclude = 'MaskIconExclude';
1506
- const MaskIconPreserveCase = 'MaskIconPreserveCase';
1507
- const MaskIconRegex = 'MaskIconRegex';
1508
- const MaskIconReplaceAll = 'MaskIconReplaceAll';
1509
- const MaskIconWholeWord = 'MaskIconWholeWord';
1510
- const MultilineInputBox = 'MultilineInputBox';
1511
- const ScrollBar = 'ScrollBar';
1512
- const ScrollBarThumb = 'ScrollBarThumb';
1513
- const ScrollBarVertical = 'ScrollBarVertical';
1514
- const Search$2 = 'Search';
1515
- const SearchField = 'SearchField';
1516
- const SearchFieldButton = 'SearchFieldButton';
1517
- const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
1518
- const SearchFieldButtonDisabled = 'SearchFieldButtonDisabled';
1519
- const SearchFieldButtons = 'SearchFieldButtons';
1520
- const SearchFieldContainer = 'SearchFieldContainer';
1521
- const SearchFieldError = 'SearchFieldError';
1522
- const SearchHeader = 'SearchHeader';
1523
- const SearchHeaderDetails = 'SearchHeaderDetails';
1524
- const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1525
- const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
1526
- const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
1527
- const SearchHeaderTop = 'SearchHeaderTop';
1528
- const SearchHeaderTopRight = 'SearchHeaderTopRight';
1529
- const SearchInputError = 'SearchInputError';
1530
- const SearchRemove = 'SearchRemove';
1531
- const SearchToggleButton = 'SearchToggleButton';
1532
- const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1533
- const SourceControlBadge = 'SourceControlBadge';
1534
- const ToggleDetails = 'ToggleDetails';
1535
- const Tree = 'Tree';
1536
- const TreeItem = 'TreeItem';
1537
- const TreeItemActive = 'TreeItemActive';
1538
- const TreeItems$1 = 'TreeItems';
1539
- const Viewlet = 'Viewlet';
1540
- const ViewletSearchMessage = 'ViewletSearchMessage';
1541
- const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1542
-
1543
- const File$2 = 7;
1544
-
1545
- const Button$2 = 1;
1546
- const Div = 4;
1547
- const Span = 8;
1548
- const Text = 12;
1549
- const Img = 17;
1550
- const Ins = 20;
1551
- const Del = 21;
1552
- const H4 = 24;
1553
- const TextArea = 62;
1554
- const Reference = 100;
1555
-
1556
- const Button$1 = 'event.button';
1557
- const ClientX = 'event.clientX';
1558
- const ClientY = 'event.clientY';
1559
- const DeltaMode = 'event.deltaMode';
1560
- const DeltaY = 'event.deltaY';
1561
- const TargetName = 'event.target.name';
1562
- const TargetSelectionEnd = 'event.target.selectionEnd';
1563
- const TargetSelectionStart = 'event.target.selectionStart';
1564
- const TargetValue = 'event.target.value';
1565
-
1566
- const Script$1 = 2;
1567
-
1568
- const Search$1 = 18;
1569
- const InputContextMenu = 91;
1570
-
1571
- const Separator = 1;
1572
- const None$1 = 0;
1573
-
1574
- const LeftClick = 0;
1575
-
1576
- const Electron = 2;
1577
- const Remote = 3;
1578
-
1579
- const File$1 = 1;
1580
- const Match$1 = 2;
1581
-
1582
- const FocusElementByName = 'Viewlet.focusElementByName';
1583
- const SetCss = 'Viewlet.setCss';
1584
- const SetFocusContext = 'Viewlet.setFocusContext';
1585
- const SetValueByName = 'Viewlet.setValueByName';
1586
- const SetPatches = 'Viewlet.setPatches';
1587
-
1588
- const Empty = 0;
1589
- const FocusIgnoreFiles = 1012;
1590
- const FocusSearch = 1013;
1591
- const FocusSearchExcludeInput = 1008;
1592
- const FocusSearchIncludeInput = 1007;
1593
- const FocusSearchInput = 21;
1594
- const FocusSearchMatchCase = 32;
1595
- const FocusSearchOpenEditors = 1011;
1596
- const FocusSearchPreserveCase = 36;
1597
- const FocusSearchRegex = 33;
1598
- const FocusSearchReplaceAll = 35;
1599
- const FocusSearchReplaceInput = 31;
1600
- const FocusSearchResults = 22;
1601
- const FocusSearchWholeWord = 34;
1602
- const FocusToggleDetails = 1010;
1603
- const FocusToggleReplace = 1020;
1604
-
1605
1943
  const mergeClassNames = (...classNames) => {
1606
1944
  return classNames.filter(Boolean).join(' ');
1607
1945
  };
@@ -1614,6 +1952,8 @@ const text = data => {
1614
1952
  };
1615
1953
  };
1616
1954
 
1955
+ new Set(Object.values(VirtualDomElements));
1956
+
1617
1957
  const SetText = 1;
1618
1958
  const Replace$1 = 2;
1619
1959
  const SetAttribute = 3;
@@ -1685,12 +2025,12 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
1685
2025
  };
1686
2026
 
1687
2027
  const compareNodes = (oldNode, newNode) => {
1688
- const patches = [];
1689
2028
  // Check if node type changed - return null to signal incompatible nodes
1690
2029
  // (caller should handle this with a Replace operation)
1691
2030
  if (oldNode.type !== newNode.type) {
1692
2031
  return null;
1693
2032
  }
2033
+ const patches = [];
1694
2034
  // Handle reference nodes - special handling for uid changes
1695
2035
  if (oldNode.type === Reference) {
1696
2036
  if (oldNode.uid !== newNode.uid) {
@@ -1726,29 +2066,96 @@ const compareNodes = (oldNode, newNode) => {
1726
2066
  }
1727
2067
  // Check for removed attributes
1728
2068
  for (const key of oldKeys) {
1729
- if (!(key in newNode)) {
2069
+ if (!Object.hasOwn(newNode, key)) {
1730
2070
  patches.push({
1731
2071
  type: RemoveAttribute,
1732
2072
  key
1733
2073
  });
1734
2074
  }
1735
2075
  }
1736
- return patches;
1737
- };
1738
-
1739
- const treeToArray = node => {
1740
- const result = [node.node];
1741
- for (const child of node.children) {
1742
- result.push(...treeToArray(child));
2076
+ return patches;
2077
+ };
2078
+
2079
+ const treeToArray = node => {
2080
+ const result = [node.node];
2081
+ for (const child of node.children) {
2082
+ result.push(...treeToArray(child));
2083
+ }
2084
+ return result;
2085
+ };
2086
+
2087
+ const navigateToChild = (patches, currentChildIndex, index) => {
2088
+ if (currentChildIndex === -1) {
2089
+ patches.push({
2090
+ type: NavigateChild,
2091
+ index
2092
+ });
2093
+ return index;
2094
+ }
2095
+ if (currentChildIndex !== index) {
2096
+ patches.push({
2097
+ type: NavigateSibling,
2098
+ index
2099
+ });
2100
+ }
2101
+ return index;
2102
+ };
2103
+ const navigateToParent = (patches, currentChildIndex) => {
2104
+ if (currentChildIndex >= 0) {
2105
+ patches.push({
2106
+ type: NavigateParent
2107
+ });
2108
+ }
2109
+ return -1;
2110
+ };
2111
+ const addTree = (newNode, patches) => {
2112
+ patches.push({
2113
+ type: Add,
2114
+ nodes: treeToArray(newNode)
2115
+ });
2116
+ };
2117
+ const replaceTree = (newNode, patches) => {
2118
+ patches.push({
2119
+ type: Replace$1,
2120
+ nodes: treeToArray(newNode)
2121
+ });
2122
+ };
2123
+ const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
2124
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
2125
+ if (nodePatches === null) {
2126
+ const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
2127
+ replaceTree(newNode, patches);
2128
+ return nextChildIndex;
2129
+ }
2130
+ const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
2131
+ if (nodePatches.length === 0 && !hasChildrenToCompare) {
2132
+ return currentChildIndex;
2133
+ }
2134
+ const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
2135
+ if (nodePatches.length > 0) {
2136
+ patches.push(...nodePatches);
2137
+ }
2138
+ if (hasChildrenToCompare) {
2139
+ diffChildren(oldNode.children, newNode.children, patches);
2140
+ }
2141
+ return nextChildIndex;
2142
+ };
2143
+ const diffRootNode = (oldNode, newNode, patches) => {
2144
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
2145
+ if (nodePatches === null) {
2146
+ replaceTree(newNode, patches);
2147
+ return;
2148
+ }
2149
+ if (nodePatches.length > 0) {
2150
+ patches.push(...nodePatches);
2151
+ }
2152
+ if (oldNode.children.length > 0 || newNode.children.length > 0) {
2153
+ diffChildren(oldNode.children, newNode.children, patches);
1743
2154
  }
1744
- return result;
1745
2155
  };
1746
-
1747
2156
  const diffChildren = (oldChildren, newChildren, patches) => {
1748
2157
  const maxLength = Math.max(oldChildren.length, newChildren.length);
1749
- // Track where we are: -1 means at parent, >= 0 means at child index
1750
2158
  let currentChildIndex = -1;
1751
- // Collect indices of children to remove (we'll add these patches at the end in reverse order)
1752
2159
  const indicesToRemove = [];
1753
2160
  for (let i = 0; i < maxLength; i++) {
1754
2161
  const oldNode = oldChildren[i];
@@ -1757,88 +2164,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
1757
2164
  continue;
1758
2165
  }
1759
2166
  if (!oldNode) {
1760
- // Add new node - we should be at the parent
1761
- if (currentChildIndex >= 0) {
1762
- // Navigate back to parent
1763
- patches.push({
1764
- type: NavigateParent
1765
- });
1766
- currentChildIndex = -1;
1767
- }
1768
- // Flatten the entire subtree so renderInternal can handle it
1769
- const flatNodes = treeToArray(newNode);
1770
- patches.push({
1771
- type: Add,
1772
- nodes: flatNodes
1773
- });
1774
- } else if (newNode) {
1775
- // Compare nodes to see if we need any patches
1776
- const nodePatches = compareNodes(oldNode.node, newNode.node);
1777
- // If nodePatches is null, the node types are incompatible - need to replace
1778
- if (nodePatches === null) {
1779
- // Navigate to this child
1780
- if (currentChildIndex === -1) {
1781
- patches.push({
1782
- type: NavigateChild,
1783
- index: i
1784
- });
1785
- currentChildIndex = i;
1786
- } else if (currentChildIndex !== i) {
1787
- patches.push({
1788
- type: NavigateSibling,
1789
- index: i
1790
- });
1791
- currentChildIndex = i;
1792
- }
1793
- // Replace the entire subtree
1794
- const flatNodes = treeToArray(newNode);
1795
- patches.push({
1796
- type: Replace$1,
1797
- nodes: flatNodes
1798
- });
1799
- // After replace, we're at the new element (same position)
1800
- continue;
1801
- }
1802
- // Check if we need to recurse into children
1803
- const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
1804
- // Only navigate to this element if we need to do something
1805
- if (nodePatches.length > 0 || hasChildrenToCompare) {
1806
- // Navigate to this child if not already there
1807
- if (currentChildIndex === -1) {
1808
- patches.push({
1809
- type: NavigateChild,
1810
- index: i
1811
- });
1812
- currentChildIndex = i;
1813
- } else if (currentChildIndex !== i) {
1814
- patches.push({
1815
- type: NavigateSibling,
1816
- index: i
1817
- });
1818
- currentChildIndex = i;
1819
- }
1820
- // Apply node patches (these apply to the current element, not children)
1821
- if (nodePatches.length > 0) {
1822
- patches.push(...nodePatches);
1823
- }
1824
- // Compare children recursively
1825
- if (hasChildrenToCompare) {
1826
- diffChildren(oldNode.children, newNode.children, patches);
1827
- }
1828
- }
1829
- } else {
1830
- // Remove old node - collect the index for later removal
2167
+ currentChildIndex = navigateToParent(patches, currentChildIndex);
2168
+ addTree(newNode, patches);
2169
+ continue;
2170
+ }
2171
+ if (!newNode) {
1831
2172
  indicesToRemove.push(i);
2173
+ continue;
1832
2174
  }
2175
+ currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
1833
2176
  }
1834
- // Navigate back to parent if we ended at a child
1835
- if (currentChildIndex >= 0) {
1836
- patches.push({
1837
- type: NavigateParent
1838
- });
1839
- }
1840
- // Add remove patches in reverse order (highest index first)
1841
- // This ensures indices remain valid as we remove
2177
+ navigateToParent(patches, currentChildIndex);
1842
2178
  for (let j = indicesToRemove.length - 1; j >= 0; j--) {
1843
2179
  patches.push({
1844
2180
  type: RemoveChild,
@@ -1847,47 +2183,22 @@ const diffChildren = (oldChildren, newChildren, patches) => {
1847
2183
  }
1848
2184
  };
1849
2185
  const diffTrees = (oldTree, newTree, patches, path) => {
1850
- // At the root level (path.length === 0), we're already AT the element
1851
- // So we compare the root node directly, then compare its children
1852
2186
  if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
1853
- const oldNode = oldTree[0];
1854
- const newNode = newTree[0];
1855
- // Compare root nodes
1856
- const nodePatches = compareNodes(oldNode.node, newNode.node);
1857
- // If nodePatches is null, the root node types are incompatible - need to replace
1858
- if (nodePatches === null) {
1859
- const flatNodes = treeToArray(newNode);
1860
- patches.push({
1861
- type: Replace$1,
1862
- nodes: flatNodes
1863
- });
1864
- return;
1865
- }
1866
- if (nodePatches.length > 0) {
1867
- patches.push(...nodePatches);
1868
- }
1869
- // Compare children
1870
- if (oldNode.children.length > 0 || newNode.children.length > 0) {
1871
- diffChildren(oldNode.children, newNode.children, patches);
1872
- }
1873
- } else {
1874
- // Non-root level or multiple root elements - use the regular comparison
1875
- diffChildren(oldTree, newTree, patches);
2187
+ diffRootNode(oldTree[0], newTree[0], patches);
2188
+ return;
1876
2189
  }
2190
+ diffChildren(oldTree, newTree, patches);
1877
2191
  };
1878
2192
 
1879
2193
  const removeTrailingNavigationPatches = patches => {
1880
- // Find the last non-navigation patch
1881
- let lastNonNavigationIndex = -1;
1882
- for (let i = patches.length - 1; i >= 0; i--) {
1883
- const patch = patches[i];
2194
+ while (patches.length > 0) {
2195
+ const patch = patches.at(-1);
1884
2196
  if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
1885
- lastNonNavigationIndex = i;
1886
2197
  break;
1887
2198
  }
2199
+ patches.pop();
1888
2200
  }
1889
- // Return patches up to and including the last non-navigation patch
1890
- return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
2201
+ return patches;
1891
2202
  };
1892
2203
 
1893
2204
  const diffTree = (oldNodes, newNodes) => {
@@ -2033,51 +2344,6 @@ const getFileIcons = async (items, fileIconCache) => {
2033
2344
  };
2034
2345
  };
2035
2346
 
2036
- // TODO optimize this function to return the minimum number
2037
- // of visible items needed, e.g. when not scrolled 5 items with
2038
- // 20px fill 100px but when scrolled 6 items are needed
2039
- const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
2040
- return Math.ceil(listHeight / itemHeight) + 1;
2041
- };
2042
-
2043
- const getPaths = items => {
2044
- const paths = [];
2045
- for (const item of items) {
2046
- if (item.type === File) {
2047
- paths.push(item.text);
2048
- }
2049
- }
2050
- return paths;
2051
- };
2052
- const collapseAll$1 = async state => {
2053
- const {
2054
- fileIconCache,
2055
- headerHeight,
2056
- height,
2057
- itemHeight,
2058
- items
2059
- } = state;
2060
- if (items.length === 0) {
2061
- return state;
2062
- }
2063
- const paths = getPaths(items);
2064
- const total = items.length;
2065
- const listHeight = height - headerHeight;
2066
- const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
2067
- const maxLineY = Math.min(numberOfVisible, total);
2068
- const visible = items.slice(0, maxLineY);
2069
- const {
2070
- icons,
2071
- newFileIconCache
2072
- } = await getFileIcons(visible, fileIconCache);
2073
- return {
2074
- ...state,
2075
- collapsedPaths: paths,
2076
- fileIconCache: newFileIconCache,
2077
- icons
2078
- };
2079
- };
2080
-
2081
2347
  const getFilteredResults = (results, collapsedPaths) => {
2082
2348
  if (collapsedPaths.length === 0) {
2083
2349
  return results;
@@ -2096,6 +2362,13 @@ const getFilteredResults = (results, collapsedPaths) => {
2096
2362
  return filteredResults;
2097
2363
  };
2098
2364
 
2365
+ // TODO optimize this function to return the minimum number
2366
+ // of visible items needed, e.g. when not scrolled 5 items with
2367
+ // 20px fill 100px but when scrolled 6 items are needed
2368
+ const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
2369
+ return Math.ceil(listHeight / itemHeight) + 1;
2370
+ };
2371
+
2099
2372
  const applyCollapsedPaths = async (state, collapsedPaths, listFocusedIndex) => {
2100
2373
  const {
2101
2374
  fileIconCache,
@@ -2127,6 +2400,27 @@ const applyCollapsedPaths = async (state, collapsedPaths, listFocusedIndex) => {
2127
2400
  };
2128
2401
  };
2129
2402
 
2403
+ const getPaths = items => {
2404
+ const paths = [];
2405
+ for (const item of items) {
2406
+ if (item.type === File) {
2407
+ paths.push(item.text);
2408
+ }
2409
+ }
2410
+ return paths;
2411
+ };
2412
+ const collapseAll$1 = async state => {
2413
+ const {
2414
+ items,
2415
+ listFocusedIndex
2416
+ } = state;
2417
+ if (items.length === 0) {
2418
+ return state;
2419
+ }
2420
+ const paths = getPaths(items);
2421
+ return applyCollapsedPaths(state, paths, listFocusedIndex);
2422
+ };
2423
+
2130
2424
  const collapseCurrent = async state => {
2131
2425
  const {
2132
2426
  collapsedPaths,
@@ -2591,15 +2885,15 @@ const getScrollBarOffset$1 = (delta, finalDelta, size, scrollBarSize) => {
2591
2885
  const getScrollBarY$1 = getScrollBarOffset$1;
2592
2886
 
2593
2887
  const emptyObject = {};
2594
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
2595
2888
  const i18nString = (key, placeholders = emptyObject) => {
2596
2889
  if (placeholders === emptyObject) {
2597
2890
  return key;
2598
2891
  }
2599
- const replacer = (match, rest) => {
2600
- return placeholders[rest];
2601
- };
2602
- return key.replaceAll(RE_PLACEHOLDER, replacer);
2892
+ let result = key;
2893
+ for (const [placeholder, replacement] of Object.entries(placeholders)) {
2894
+ result = result.split(`{${placeholder}}`).join(String(replacement));
2895
+ }
2896
+ return result;
2603
2897
  };
2604
2898
 
2605
2899
  const ClearSearchResults = 'Clear Search Results';
@@ -3032,7 +3326,11 @@ const getPreviousFocus = (focus, flags) => {
3032
3326
  };
3033
3327
 
3034
3328
  const focusPreviousInput = state => {
3035
- const previousFocus = getPreviousFocus(state.focus, state.flags);
3329
+ const {
3330
+ flags,
3331
+ focus
3332
+ } = state;
3333
+ const previousFocus = getPreviousFocus(focus, flags);
3036
3334
  return {
3037
3335
  ...state,
3038
3336
  focus: previousFocus,
@@ -3056,7 +3354,10 @@ const focusSearchValue$1 = async state => {
3056
3354
  };
3057
3355
 
3058
3356
  const focusSearchValueNext = state => {
3059
- if (state.flags & ReplaceExpanded) {
3357
+ const {
3358
+ flags
3359
+ } = state;
3360
+ if (flags & ReplaceExpanded) {
3060
3361
  return focusReplaceValue$1(state);
3061
3362
  }
3062
3363
  return focusMatchCase$1(state);
@@ -3297,11 +3598,17 @@ const Refresh$1 = 'Refresh';
3297
3598
  const OpenSearchEditor = 'OpenSearchEditor';
3298
3599
  const ViewAsTree = 'ViewAsTree';
3299
3600
 
3601
+ const openUri = async (path, focus = true, props = {}) => {
3602
+ await openUri$1(path, focus, props);
3603
+ };
3604
+
3300
3605
  const openSearchEditor = async state => {
3301
- // TODO
3302
- return {
3303
- ...state
3304
- };
3606
+ const {
3607
+ uid
3608
+ } = state;
3609
+ const uri = `search-editor://${uid}-${globalThis.crypto.randomUUID()}/Search`;
3610
+ await openUri(uri);
3611
+ return state;
3305
3612
  };
3306
3613
 
3307
3614
  const handleError = error => {
@@ -3423,6 +3730,9 @@ const textSearch$6 = async (root, query, options, assetDir, platform, searchId,
3423
3730
  };
3424
3731
 
3425
3732
  const handleUpdateFull = async (state, update) => {
3733
+ const {
3734
+ workspacePath
3735
+ } = state;
3426
3736
  const partialNewState = {
3427
3737
  ...state,
3428
3738
  ...update
@@ -3444,7 +3754,7 @@ const handleUpdateFull = async (state, update) => {
3444
3754
  value,
3445
3755
  width
3446
3756
  } = partialNewState;
3447
- const root = state.workspacePath;
3757
+ const root = workspacePath;
3448
3758
  const scheme = getProtocol(root);
3449
3759
  const isFileSearch = scheme === '' || scheme === 'file';
3450
3760
  const shouldUsePullBasedSearch = usePullBasedSearch && isFileSearch;
@@ -3604,6 +3914,9 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
3604
3914
  };
3605
3915
 
3606
3916
  const handleUpdateIncremental = async (state, update) => {
3917
+ const {
3918
+ workspacePath
3919
+ } = state;
3607
3920
  const partialNewState = {
3608
3921
  ...state,
3609
3922
  ...update
@@ -3620,7 +3933,7 @@ const handleUpdateIncremental = async (state, update) => {
3620
3933
  usePullBasedSearch,
3621
3934
  value
3622
3935
  } = partialNewState;
3623
- const root = state.workspacePath;
3936
+ const root = workspacePath;
3624
3937
  const scheme = getProtocol(root);
3625
3938
  const searchId = crypto.randomUUID(); // TODO try to avoid side effect
3626
3939
  const latest1 = get$1(uid);
@@ -3655,6 +3968,10 @@ const getsearchid = () => {
3655
3968
  return crypto.randomUUID();
3656
3969
  };
3657
3970
  const handleUpdatePullBased = async (state, update) => {
3971
+ const {
3972
+ uid: previousUid,
3973
+ workspacePath
3974
+ } = state;
3658
3975
  const searchId = getsearchid();
3659
3976
  const partialNewState = {
3660
3977
  ...state,
@@ -3665,7 +3982,7 @@ const handleUpdatePullBased = async (state, update) => {
3665
3982
  searchId,
3666
3983
  searchResults: []
3667
3984
  };
3668
- set(state.uid, state, partialNewState);
3985
+ set(previousUid, state, partialNewState);
3669
3986
  const {
3670
3987
  assetDir,
3671
3988
  excludeValue,
@@ -3679,7 +3996,7 @@ const handleUpdatePullBased = async (state, update) => {
3679
3996
  value,
3680
3997
  width
3681
3998
  } = partialNewState;
3682
- const root = state.workspacePath;
3999
+ const root = workspacePath;
3683
4000
  const scheme = getProtocol(root);
3684
4001
  const isFileSearch = scheme === '' || scheme === 'file';
3685
4002
  const shouldUsePullBasedSearch = usePullBasedSearch && isFileSearch;
@@ -3918,6 +4235,7 @@ const replaceAllInFocusedFile = async (state, fileIndex) => {
3918
4235
  height,
3919
4236
  itemHeight,
3920
4237
  items,
4238
+ matchCount: totalMatchCount,
3921
4239
  maxLineY,
3922
4240
  minimumSliderSize,
3923
4241
  minLineY,
@@ -3937,7 +4255,7 @@ const replaceAllInFocusedFile = async (state, fileIndex) => {
3937
4255
  newFocusedIndex,
3938
4256
  newItems,
3939
4257
  newMatchCount
3940
- } = removeItemFromItems(items, fileIndex, state.matchCount, fileCount);
4258
+ } = removeItemFromItems(items, fileIndex, totalMatchCount, fileCount);
3941
4259
  const {
3942
4260
  newDeltaY,
3943
4261
  newMaxLineY,
@@ -3999,15 +4317,21 @@ const replaceAll = async state => {
3999
4317
  };
4000
4318
 
4001
4319
  const toggleDetailsExpanded = state => {
4002
- if (hasDetailsExpanded(state.flags)) {
4320
+ const {
4321
+ flags
4322
+ } = state;
4323
+ if (hasDetailsExpanded(flags)) {
4003
4324
  return collapseDetails(state);
4004
4325
  }
4005
4326
  return expandDetails(state);
4006
4327
  };
4007
4328
 
4008
4329
  const toggleSearchFlag = (state, flag) => {
4330
+ const {
4331
+ flags
4332
+ } = state;
4009
4333
  return handleUpdate(state, {
4010
- flags: state.flags ^ flag
4334
+ flags: flags ^ flag
4011
4335
  });
4012
4336
  };
4013
4337
 
@@ -4054,7 +4378,10 @@ const expandReplace = state => {
4054
4378
  };
4055
4379
 
4056
4380
  const toggleReplace = async state => {
4057
- if (hasReplaceExpanded(state.flags)) {
4381
+ const {
4382
+ flags
4383
+ } = state;
4384
+ if (hasReplaceExpanded(flags)) {
4058
4385
  return collapseReplace(state);
4059
4386
  }
4060
4387
  return expandReplace(state);
@@ -4112,7 +4439,10 @@ const handleHeaderFocusIn = state => {
4112
4439
  };
4113
4440
 
4114
4441
  const handleHeaderFocusOut = state => {
4115
- if (!state.focus) {
4442
+ const {
4443
+ focus
4444
+ } = state;
4445
+ if (!focus) {
4116
4446
  return state;
4117
4447
  }
4118
4448
  return {
@@ -4201,15 +4531,21 @@ const handleInputContextMenu = async (state, name, button, x, y) => {
4201
4531
  };
4202
4532
 
4203
4533
  const getCurrentValue = (state, name) => {
4534
+ const {
4535
+ excludeValue,
4536
+ includeValue,
4537
+ replacement,
4538
+ value
4539
+ } = state;
4204
4540
  switch (name) {
4205
4541
  case FilesToExclude:
4206
- return state.excludeValue;
4542
+ return excludeValue;
4207
4543
  case FilesToInclude:
4208
- return state.includeValue;
4544
+ return includeValue;
4209
4545
  case ReplaceValue:
4210
- return state.replacement;
4546
+ return replacement;
4211
4547
  case SearchValue:
4212
- return state.value;
4548
+ return value;
4213
4549
  default:
4214
4550
  return '';
4215
4551
  }
@@ -4633,51 +4969,51 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
4633
4969
  if (relativeY <= halfScrollBarHeight) {
4634
4970
  // clicked at top
4635
4971
  return {
4636
- percent: 0,
4637
- handleOffset: relativeY
4972
+ handleOffset: relativeY,
4973
+ percent: 0
4638
4974
  };
4639
4975
  }
4640
4976
  if (relativeY <= height - halfScrollBarHeight) {
4641
4977
  // clicked in middle
4642
4978
  return {
4643
- percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight),
4644
- handleOffset: halfScrollBarHeight
4979
+ handleOffset: halfScrollBarHeight,
4980
+ percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight)
4645
4981
  };
4646
4982
  }
4647
4983
  // clicked at bottom
4648
4984
  return {
4649
- percent: 1,
4650
- handleOffset: scrollBarHeight - height + relativeY
4985
+ handleOffset: scrollBarHeight - height + relativeY,
4986
+ percent: 1
4651
4987
  };
4652
4988
  };
4653
4989
  const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength) => {
4654
4990
  const {
4655
4991
  finalDeltaY,
4656
- height,
4657
4992
  headerHeight,
4993
+ height,
4658
4994
  scrollBarHeight
4659
4995
  } = state;
4660
- const newMaxLineY = Math.min(index + 1, itemsLength);
4661
4996
  const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
4662
- const newMinLineY = Math.max(newMaxLineY - fittingItems, 0);
4663
- const newDeltaY = itemsLength < fittingItems ? 0 : newMinLineY * itemHeight - listHeight % itemHeight + itemHeight;
4997
+ const newDeltaY = Math.min(Math.max((index + 1) * itemHeight - listHeight, 0), finalDeltaY);
4998
+ const newMinLineY = Math.floor(newDeltaY / itemHeight);
4999
+ const newMaxLineY = Math.min(newMinLineY + fittingItems, itemsLength);
4664
5000
  const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
4665
5001
  return {
4666
5002
  ...state,
5003
+ deltaY: newDeltaY,
5004
+ focused: true,
4667
5005
  focusedIndex: index,
4668
5006
  listFocusedIndex: index,
4669
- minLineY: newMinLineY,
4670
5007
  maxLineY: newMaxLineY,
4671
- focused: true,
4672
- deltaY: newDeltaY,
5008
+ minLineY: newMinLineY,
4673
5009
  scrollBarY
4674
5010
  };
4675
5011
  };
4676
5012
  const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) => {
4677
5013
  const {
4678
5014
  finalDeltaY,
4679
- height,
4680
5015
  headerHeight,
5016
+ height,
4681
5017
  scrollBarHeight
4682
5018
  } = state;
4683
5019
  const newMinLineY = index;
@@ -4687,35 +5023,35 @@ const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) =
4687
5023
  const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
4688
5024
  return {
4689
5025
  ...state,
5026
+ deltaY: newDeltaY,
5027
+ focused: true,
4690
5028
  focusedIndex: index,
4691
5029
  listFocusedIndex: index,
4692
- minLineY: newMinLineY,
4693
5030
  maxLineY: newMaxLineY,
4694
- focused: true,
4695
- deltaY: newDeltaY,
5031
+ minLineY: newMinLineY,
4696
5032
  scrollBarY
4697
5033
  };
4698
5034
  };
4699
5035
  const focusIndex = (state, index) => {
4700
5036
  const {
4701
- itemHeight,
4702
- minLineY,
4703
- maxLineY,
4704
5037
  headerHeight,
4705
5038
  height,
4706
- items
5039
+ itemHeight,
5040
+ items,
5041
+ maxLineY,
5042
+ minLineY
4707
5043
  } = state;
4708
5044
  const itemsLength = items.length;
4709
5045
  if (itemsLength === 0) {
4710
5046
  return state;
4711
5047
  }
4712
- number(itemHeight);
5048
+ number$1(itemHeight);
4713
5049
  if (index === -1) {
4714
5050
  return {
4715
5051
  ...state,
5052
+ focused: true,
4716
5053
  focusedIndex: -1,
4717
- listFocusedIndex: -1,
4718
- focused: true
5054
+ listFocusedIndex: -1
4719
5055
  };
4720
5056
  }
4721
5057
  const listHeight = height - headerHeight;
@@ -4727,9 +5063,9 @@ const focusIndex = (state, index) => {
4727
5063
  }
4728
5064
  return {
4729
5065
  ...state,
5066
+ focused: true,
4730
5067
  focusedIndex: index,
4731
- listFocusedIndex: index,
4732
- focused: true
5068
+ listFocusedIndex: index
4733
5069
  };
4734
5070
  };
4735
5071
  const first = () => {
@@ -4742,7 +5078,7 @@ const next = (items, index) => {
4742
5078
  return (index + 1) % items.length;
4743
5079
  };
4744
5080
  const previous = (items, index) => {
4745
- return index === 0 ? items.length - 1 : index - 1;
5081
+ return (index === 0 ? items.length : index) - 1;
4746
5082
  };
4747
5083
  const focusFirst = state => {
4748
5084
  const firstIndex = first();
@@ -4799,8 +5135,8 @@ const focusPrevious = state => {
4799
5135
  const focusPreviousPage = state => {
4800
5136
  const {
4801
5137
  focusedIndex,
4802
- minLineY,
4803
- maxLineY
5138
+ maxLineY,
5139
+ minLineY
4804
5140
  } = state;
4805
5141
  if (focusedIndex === 0 || focusedIndex === -1) {
4806
5142
  return state;
@@ -4825,13 +5161,13 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
4825
5161
  };
4826
5162
  const setDeltaY = (state, value) => {
4827
5163
  object(state);
4828
- number(value);
5164
+ number$1(value);
4829
5165
  const {
4830
- itemHeight,
4831
- finalDeltaY,
4832
5166
  deltaY,
4833
- height,
5167
+ finalDeltaY,
4834
5168
  headerHeight,
5169
+ height,
5170
+ itemHeight,
4835
5171
  items,
4836
5172
  minimumSliderSize
4837
5173
  } = state;
@@ -4852,19 +5188,19 @@ const setDeltaY = (state, value) => {
4852
5188
  return {
4853
5189
  ...state,
4854
5190
  deltaY: newDeltaY,
4855
- minLineY,
4856
5191
  maxLineY,
5192
+ minLineY,
4857
5193
  scrollBarY
4858
5194
  };
4859
5195
  };
4860
5196
  const handleScrollBarClick = (state, eventY) => {
4861
5197
  const {
4862
- y,
4863
5198
  deltaY,
4864
- headerHeight,
4865
5199
  finalDeltaY,
5200
+ headerHeight,
5201
+ height,
4866
5202
  scrollBarHeight,
4867
- height
5203
+ y
4868
5204
  } = state;
4869
5205
  const contentHeight = height - headerHeight;
4870
5206
  const relativeY = eventY - y - headerHeight;
@@ -4878,8 +5214,8 @@ const handleScrollBarClick = (state, eventY) => {
4878
5214
  };
4879
5215
  }
4880
5216
  const {
4881
- percent,
4882
- handleOffset
5217
+ handleOffset,
5218
+ percent
4883
5219
  } = getNewDeltaPercent(contentHeight, scrollBarHeight, relativeY);
4884
5220
  const newDeltaY = percent * finalDeltaY;
4885
5221
  return {
@@ -4898,12 +5234,12 @@ const getNewPercent = (contentHeight, scrollBarHeight, relativeY) => {
4898
5234
  };
4899
5235
  const handleScrollBarMove = (state, eventY) => {
4900
5236
  const {
4901
- y,
4902
- headerHeight,
4903
- handleOffset,
4904
5237
  finalDeltaY,
5238
+ handleOffset,
5239
+ headerHeight,
4905
5240
  height,
4906
- scrollBarHeight
5241
+ scrollBarHeight,
5242
+ y
4907
5243
  } = state;
4908
5244
  const relativeY = eventY - y - headerHeight - handleOffset;
4909
5245
  const contentHeight = height - headerHeight;
@@ -4912,8 +5248,8 @@ const handleScrollBarMove = (state, eventY) => {
4912
5248
  return setDeltaY(state, newDeltaY);
4913
5249
  };
4914
5250
  const handleWheel = (state, deltaMode, deltaY) => {
4915
- number(deltaMode);
4916
- number(deltaY);
5251
+ number$1(deltaMode);
5252
+ number$1(deltaY);
4917
5253
  return setDeltaY(state, state.deltaY + deltaY);
4918
5254
  };
4919
5255
 
@@ -4953,10 +5289,6 @@ const getFileIndex = (items, index) => {
4953
5289
  return -1;
4954
5290
  };
4955
5291
 
4956
- const openUri = async (path, focus = true, props = {}) => {
4957
- await openUri$1(path, focus, props);
4958
- };
4959
-
4960
5292
  // TODO this should be in FileSystem module
4961
5293
  const pathBaseName = path => {
4962
5294
  return path.slice(path.lastIndexOf('/') + 1);
@@ -4986,13 +5318,18 @@ const selectIndexPreview = async (state, searchResult, index) => {
4986
5318
  throw new Error('Search result is missing file');
4987
5319
  }
4988
5320
  const {
4989
- lineNumber
5321
+ end,
5322
+ endColumnIndex = end,
5323
+ lineNumber,
5324
+ rowIndex = lineNumber,
5325
+ start,
5326
+ startColumnIndex = start
4990
5327
  } = searchResult;
4991
5328
  const fileResult = items[fileIndex];
4992
5329
  const relativePath = getRelativePath(fileResult.text);
4993
5330
  const absolutePath = `${workspacePath}${relativePath}`;
4994
5331
  await openUri(absolutePath, true, {
4995
- selections: new Uint32Array([lineNumber, 0, lineNumber, 0])
5332
+ selections: new Uint32Array([rowIndex, startColumnIndex, rowIndex, endColumnIndex])
4996
5333
  });
4997
5334
  return {
4998
5335
  ...state,
@@ -5148,6 +5485,10 @@ const restoreState = savedState => {
5148
5485
  };
5149
5486
 
5150
5487
  const loadContent = async (state, savedState) => {
5488
+ const {
5489
+ limitHitWarning,
5490
+ width
5491
+ } = state;
5151
5492
  const {
5152
5493
  excludeValue,
5153
5494
  flags,
@@ -5158,7 +5499,7 @@ const loadContent = async (state, savedState) => {
5158
5499
  threads
5159
5500
  } = restoreState(savedState);
5160
5501
  const usePullBasedSearch = await getUsePullBasedSearch();
5161
- const warningHeight = await getSearchWarningMessageHeight(state.limitHitWarning, state.width);
5502
+ const warningHeight = await getSearchWarningMessageHeight(limitHitWarning, width);
5162
5503
  const headerHeight = getTopHeight(flags) + warningHeight;
5163
5504
  const update = {
5164
5505
  collapsedPaths: savedCollapsedPaths,
@@ -5532,6 +5873,8 @@ const HandleInputContextMenu = 20;
5532
5873
  const HandleInputSelectionChange = 21;
5533
5874
  const HandleActionClick = 22;
5534
5875
 
5876
+ const Focusable = 0;
5877
+
5535
5878
  const getSearchDetailsToggleVirtualDom = () => {
5536
5879
  return [{
5537
5880
  ariaLabel: toggleSearchDetails(),
@@ -5540,7 +5883,7 @@ const getSearchDetailsToggleVirtualDom = () => {
5540
5883
  name: ToggleSearchDetails,
5541
5884
  onClick: HandleButtonClick,
5542
5885
  role: Button$3,
5543
- tabIndex: 0,
5886
+ tabIndex: Focusable,
5544
5887
  title: toggleSearchDetails(),
5545
5888
  type: Button$2
5546
5889
  }, {
@@ -5608,10 +5951,6 @@ const getInputActionsInclude = flags => {
5608
5951
  };
5609
5952
  };
5610
5953
 
5611
- const getSearchFieldButtonClassName = flag => {
5612
- return mergeClassNames(SearchFieldButton, flag === CheckBoxEnabled ? SearchFieldButtonChecked : '', flag === ButtonDisabled ? SearchFieldButtonDisabled : '');
5613
- };
5614
-
5615
5954
  // TODO maybe move logic to viewmodel, which returns ariaChecked 1 | 2 | 3
5616
5955
  const getAriaChecked = flag => {
5617
5956
  switch (flag) {
@@ -5624,6 +5963,15 @@ const getAriaChecked = flag => {
5624
5963
  }
5625
5964
  };
5626
5965
 
5966
+ const getDisabled = flag => {
5967
+ switch (flag) {
5968
+ case ButtonDisabled:
5969
+ return true;
5970
+ default:
5971
+ return undefined;
5972
+ }
5973
+ };
5974
+
5627
5975
  // TODO have have separate renderers for checkbox and button elements
5628
5976
  const getRole = flag => {
5629
5977
  switch (flag) {
@@ -5634,14 +5982,11 @@ const getRole = flag => {
5634
5982
  return undefined;
5635
5983
  }
5636
5984
  };
5637
- const getDisabled = flag => {
5638
- switch (flag) {
5639
- case ButtonDisabled:
5640
- return true;
5641
- default:
5642
- return undefined;
5643
- }
5985
+
5986
+ const getSearchFieldButtonClassName = flag => {
5987
+ return mergeClassNames(SearchFieldButton, flag === CheckBoxEnabled ? SearchFieldButtonChecked : '', flag === ButtonDisabled ? SearchFieldButtonDisabled : '');
5644
5988
  };
5989
+
5645
5990
  const getSearchFieldButtonVirtualDom = button => {
5646
5991
  const {
5647
5992
  flag,
@@ -5660,7 +6005,7 @@ const getSearchFieldButtonVirtualDom = button => {
5660
6005
  name,
5661
6006
  onClick: HandleButtonClick,
5662
6007
  role,
5663
- tabIndex: 0,
6008
+ tabIndex: Focusable,
5664
6009
  title,
5665
6010
  type: Button$2
5666
6011
  }, {
@@ -5688,12 +6033,18 @@ const getOutSideButtonsDom = outsideButtons => {
5688
6033
  };
5689
6034
  };
5690
6035
 
6036
+ const getSearchFieldClassName = hasError => {
6037
+ if (hasError) {
6038
+ return mergeClassNames(SearchField, SearchFieldError);
6039
+ }
6040
+ return SearchField;
6041
+ };
5691
6042
  const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, outsideButtons, hasError = false) => {
5692
6043
  const {
5693
6044
  postNodes,
5694
6045
  preNodes
5695
6046
  } = getOutSideButtonsDom(outsideButtons);
5696
- const searchFieldClassName = hasError ? mergeClassNames(SearchField, SearchFieldError) : SearchField;
6047
+ const searchFieldClassName = getSearchFieldClassName(hasError);
5697
6048
  const dom = [...preNodes, {
5698
6049
  childCount: 2,
5699
6050
  className: searchFieldClassName,
@@ -5908,7 +6259,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) =>
5908
6259
  type: Div
5909
6260
  }, {
5910
6261
  childCount: 0,
5911
- className: `${ScrollBarThumb} ScrollBarThumbTop-${roundedScrollBarY}`,
6262
+ className: mergeClassNames(ScrollBarThumb, `ScrollBarThumbTop-${roundedScrollBarY}`),
5912
6263
  height: scrollBarHeight,
5913
6264
  type: Div
5914
6265
  }];
@@ -5995,7 +6346,7 @@ const highlighted = {
5995
6346
  };
5996
6347
  const label1 = {
5997
6348
  childCount: 1,
5998
- className: mergeClassNames(Label, Grow),
6349
+ className: mergeClassNames(Label$1, Grow),
5999
6350
  type: Div
6000
6351
  };
6001
6352
  const label3 = {
@@ -6079,7 +6430,6 @@ const getSearchResultVirtualDom = rowInfo => {
6079
6430
  const className = `${getSearchResultClassName(focused)} Indent-${indent} IndentRight-${PaddingRight}`;
6080
6431
  const childCount = getChildCount(icon, expanded, badgeText);
6081
6432
  const dom = [{
6082
- ariaDescription: '',
6083
6433
  ariaExpanded: getAriaExpanded(expanded),
6084
6434
  ariaLabel: title,
6085
6435
  ariaLevel: depth,
@@ -6099,12 +6449,13 @@ const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
6099
6449
  const treeItemsTop = Math.round(-pixelOffset);
6100
6450
  return [{
6101
6451
  childCount: visibleItems.length,
6102
- className: `${TreeItems$1} TreeItemsTop-${treeItemsTop}`,
6452
+ className: mergeClassNames(TreeItems$1, `TreeItemsTop-${treeItemsTop}`),
6103
6453
  id: TreeItems,
6104
6454
  onBlur: HandleListBlur,
6105
6455
  onClick: HandleClick,
6106
6456
  onContextMenu: HandleListContextMenu,
6107
6457
  onWheel: HandleWheel,
6458
+ role: None$2,
6108
6459
  type: Div
6109
6460
  }, ...visibleItems.flatMap(getSearchResultVirtualDom)];
6110
6461
  };
@@ -6116,7 +6467,7 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
6116
6467
  className: mergeClassNames(Viewlet, List$1, Tree, focusOutline ? FocusOutline : Empty$1),
6117
6468
  onBlur: HandleListBlur,
6118
6469
  role: Tree$1,
6119
- tabIndex: 0,
6470
+ tabIndex: Focusable,
6120
6471
  type: Div
6121
6472
  // TODO renable this when dom diffing is supported
6122
6473
  // onPointerDown: HandleListPointerDown,
@@ -6124,7 +6475,7 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
6124
6475
  }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
6125
6476
  };
6126
6477
 
6127
- const className = mergeClassNames(Viewlet, Search$2);
6478
+ const className = mergeClassNames(Viewlet, Search$3);
6128
6479
  const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0, initial = false) => {
6129
6480
  if (initial) {
6130
6481
  return [];
@@ -6500,7 +6851,10 @@ const focusSearchValue = state => {
6500
6851
  return focusElement(state, FocusSearchInput);
6501
6852
  };
6502
6853
  const focusMatchCasePrevious = state => {
6503
- if (state.flags & ReplaceExpanded) {
6854
+ const {
6855
+ flags
6856
+ } = state;
6857
+ if (flags & ReplaceExpanded) {
6504
6858
  return focusReplaceValue(state);
6505
6859
  }
6506
6860
  return focusSearchValue(state);
@@ -6549,11 +6903,15 @@ const getNewHistory = (history, newValue) => {
6549
6903
  return cutHistory;
6550
6904
  };
6551
6905
  const submit = state => {
6552
- const newHistory = getNewHistory(state.history, state.value);
6906
+ const {
6907
+ history,
6908
+ value
6909
+ } = state;
6910
+ const newHistory = getNewHistory(history, value);
6553
6911
  return handleUpdate(state, {
6554
6912
  history: newHistory,
6555
6913
  inputSource: User,
6556
- value: state.value
6914
+ value
6557
6915
  });
6558
6916
  };
6559
6917