@lvce-editor/status-bar-worker 1.14.0 → 1.15.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.
@@ -407,7 +407,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
407
407
  return promise;
408
408
  };
409
409
  const Message$1 = 3;
410
- const create$5 = async ({
410
+ const create$5$1 = async ({
411
411
  isMessagePortOpen,
412
412
  messagePort
413
413
  }) => {
@@ -458,7 +458,7 @@ const wrap$5 = messagePort => {
458
458
  };
459
459
  const IpcParentWithMessagePort$1 = {
460
460
  __proto__: null,
461
- create: create$5,
461
+ create: create$5$1,
462
462
  signal: signal$1,
463
463
  wrap: wrap$5
464
464
  };
@@ -664,7 +664,7 @@ const getErrorProperty = (error, prettyError) => {
664
664
  }
665
665
  };
666
666
  };
667
- const create$1$2 = (id, error) => {
667
+ const create$1$1 = (id, error) => {
668
668
  return {
669
669
  jsonrpc: Two$1,
670
670
  id,
@@ -675,9 +675,9 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
675
675
  const prettyError = preparePrettyError(error);
676
676
  logError(error, prettyError);
677
677
  const errorProperty = getErrorProperty(error, prettyError);
678
- return create$1$2(id, errorProperty);
678
+ return create$1$1(id, errorProperty);
679
679
  };
680
- const create$3 = (message, result) => {
680
+ const create$4 = (message, result) => {
681
681
  return {
682
682
  jsonrpc: Two$1,
683
683
  id: message.id,
@@ -686,7 +686,7 @@ const create$3 = (message, result) => {
686
686
  };
687
687
  const getSuccessResponse = (message, result) => {
688
688
  const resultProperty = result ?? null;
689
- return create$3(message, resultProperty);
689
+ return create$4(message, resultProperty);
690
690
  };
691
691
  const getErrorResponseSimple = (id, error) => {
692
692
  return {
@@ -800,14 +800,14 @@ const execute = (command, ...args) => {
800
800
  };
801
801
 
802
802
  const Two = '2.0';
803
- const create$s = (method, params) => {
803
+ const create$t = (method, params) => {
804
804
  return {
805
805
  jsonrpc: Two,
806
806
  method,
807
807
  params
808
808
  };
809
809
  };
810
- const create$r = (id, method, params) => {
810
+ const create$s = (id, method, params) => {
811
811
  const message = {
812
812
  id,
813
813
  jsonrpc: Two,
@@ -817,14 +817,14 @@ const create$r = (id, method, params) => {
817
817
  return message;
818
818
  };
819
819
  let id$1 = 0;
820
- const create$q = () => {
820
+ const create$r = () => {
821
821
  return ++id$1;
822
822
  };
823
823
 
824
824
  /* eslint-disable n/no-unsupported-features/es-syntax */
825
825
 
826
826
  const registerPromise = map => {
827
- const id = create$q();
827
+ const id = create$r();
828
828
  const {
829
829
  promise,
830
830
  resolve
@@ -842,7 +842,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
842
842
  id,
843
843
  promise
844
844
  } = registerPromise(callbacks);
845
- const message = create$r(id, method, params);
845
+ const message = create$s(id, method, params);
846
846
  if (useSendAndTransfer && ipc.sendAndTransfer) {
847
847
  ipc.sendAndTransfer(message);
848
848
  } else {
@@ -878,7 +878,7 @@ const createRpc = ipc => {
878
878
  * @deprecated
879
879
  */
880
880
  send(method, ...params) {
881
- const message = create$s(method, params);
881
+ const message = create$t(method, params);
882
882
  ipc.send(message);
883
883
  }
884
884
  };
@@ -914,7 +914,7 @@ const listen$1 = async (module, options) => {
914
914
  const ipc = module.wrap(rawIpc);
915
915
  return ipc;
916
916
  };
917
- const create$4 = async ({
917
+ const create$5 = async ({
918
918
  commandMap,
919
919
  isMessagePortOpen = true,
920
920
  messagePort
@@ -931,7 +931,7 @@ const create$4 = async ({
931
931
  messagePort.start();
932
932
  return rpc;
933
933
  };
934
- const create$2$1 = async ({
934
+ const create$3 = async ({
935
935
  commandMap,
936
936
  isMessagePortOpen,
937
937
  send
@@ -941,7 +941,7 @@ const create$2$1 = async ({
941
941
  port2
942
942
  } = new MessageChannel();
943
943
  await send(port1);
944
- return create$4({
944
+ return create$5({
945
945
  commandMap,
946
946
  isMessagePortOpen,
947
947
  messagePort: port2
@@ -949,9 +949,9 @@ const create$2$1 = async ({
949
949
  };
950
950
  const TransferMessagePortRpcParent = {
951
951
  __proto__: null,
952
- create: create$2$1
952
+ create: create$3
953
953
  };
954
- const create$1$1 = async ({
954
+ const create$2$1 = async ({
955
955
  commandMap
956
956
  }) => {
957
957
  // TODO create a commandMap per rpc instance
@@ -963,7 +963,7 @@ const create$1$1 = async ({
963
963
  };
964
964
  const WebWorkerRpcClient = {
965
965
  __proto__: null,
966
- create: create$1$1
966
+ create: create$2$1
967
967
  };
968
968
  const createMockRpc = ({
969
969
  commandMap
@@ -985,9 +985,14 @@ const createMockRpc = ({
985
985
  return mockRpc;
986
986
  };
987
987
 
988
+ const TargetName = 'event.target.name';
989
+
988
990
  const ExtensionHostWorker = 44;
989
991
  const RendererWorker = 1;
990
992
 
993
+ const SetDom2 = 'Viewlet.setDom2';
994
+ const SetPatches = 'Viewlet.setPatches';
995
+
991
996
  const rpcs = Object.create(null);
992
997
  const set$3 = (id, rpc) => {
993
998
  rpcs[id] = rpc;
@@ -1065,42 +1070,68 @@ const create$1 = () => {
1065
1070
  const states = Object.create(null);
1066
1071
  const commandMapRef = {};
1067
1072
  return {
1068
- get(uid) {
1069
- return states[uid];
1073
+ clear() {
1074
+ for (const key of Object.keys(states)) {
1075
+ delete states[key];
1076
+ }
1070
1077
  },
1071
- set(uid, oldState, newState) {
1072
- states[uid] = {
1073
- oldState,
1074
- newState
1075
- };
1078
+ diff(uid, modules, numbers) {
1079
+ const {
1080
+ newState,
1081
+ oldState
1082
+ } = states[uid];
1083
+ const diffResult = [];
1084
+ for (let i = 0; i < modules.length; i++) {
1085
+ const fn = modules[i];
1086
+ if (!fn(oldState, newState)) {
1087
+ diffResult.push(numbers[i]);
1088
+ }
1089
+ }
1090
+ return diffResult;
1076
1091
  },
1077
1092
  dispose(uid) {
1078
1093
  delete states[uid];
1079
1094
  },
1095
+ get(uid) {
1096
+ return states[uid];
1097
+ },
1098
+ getCommandIds() {
1099
+ const keys = Object.keys(commandMapRef);
1100
+ const ids = keys.map(toCommandId);
1101
+ return ids;
1102
+ },
1080
1103
  getKeys() {
1081
1104
  return Object.keys(states).map(key => {
1082
1105
  return Number.parseInt(key);
1083
1106
  });
1084
1107
  },
1085
- clear() {
1086
- for (const key of Object.keys(states)) {
1087
- delete states[key];
1088
- }
1108
+ registerCommands(commandMap) {
1109
+ Object.assign(commandMapRef, commandMap);
1110
+ },
1111
+ set(uid, oldState, newState) {
1112
+ states[uid] = {
1113
+ newState,
1114
+ oldState
1115
+ };
1089
1116
  },
1090
1117
  wrapCommand(fn) {
1091
1118
  const wrapped = async (uid, ...args) => {
1092
1119
  const {
1093
- oldState,
1094
- newState
1120
+ newState,
1121
+ oldState
1095
1122
  } = states[uid];
1096
1123
  const newerState = await fn(newState, ...args);
1097
1124
  if (oldState === newerState || newState === newerState) {
1098
1125
  return;
1099
1126
  }
1100
- const latest = states[uid];
1127
+ const latestOld = states[uid];
1128
+ const latestNew = {
1129
+ ...latestOld.newState,
1130
+ ...newerState
1131
+ };
1101
1132
  states[uid] = {
1102
- oldState: latest.oldState,
1103
- newState: newerState
1133
+ newState: latestNew,
1134
+ oldState: latestOld.oldState
1104
1135
  };
1105
1136
  };
1106
1137
  return wrapped;
@@ -1113,28 +1144,6 @@ const create$1 = () => {
1113
1144
  return fn(newState, ...args);
1114
1145
  };
1115
1146
  return wrapped;
1116
- },
1117
- diff(uid, modules, numbers) {
1118
- const {
1119
- oldState,
1120
- newState
1121
- } = states[uid];
1122
- const diffResult = [];
1123
- for (let i = 0; i < modules.length; i++) {
1124
- const fn = modules[i];
1125
- if (!fn(oldState, newState)) {
1126
- diffResult.push(numbers[i]);
1127
- }
1128
- }
1129
- return diffResult;
1130
- },
1131
- getCommandIds() {
1132
- const keys = Object.keys(commandMapRef);
1133
- const ids = keys.map(toCommandId);
1134
- return ids;
1135
- },
1136
- registerCommands(commandMap) {
1137
- Object.assign(commandMapRef, commandMap);
1138
1147
  }
1139
1148
  };
1140
1149
  };
@@ -1155,6 +1164,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
1155
1164
  const state = {
1156
1165
  assetDir,
1157
1166
  errorCount: 0,
1167
+ initial: true,
1158
1168
  platform,
1159
1169
  statusBarItemsLeft: [],
1160
1170
  statusBarItemsRight: [],
@@ -1169,6 +1179,7 @@ const isEqual = (oldState, newState) => {
1169
1179
  };
1170
1180
 
1171
1181
  const RenderItems = 4;
1182
+ const RenderIncremental = 11;
1172
1183
 
1173
1184
  const modules = [isEqual];
1174
1185
  const numbers = [RenderItems];
@@ -1364,32 +1375,49 @@ const StatusBarItem = 'StatusBarItem';
1364
1375
  const StatusBarItemsLeft = 'StatusBarItemsLeft';
1365
1376
  const StatusBarItemsRight = 'StatusBarItemsRight';
1366
1377
 
1367
- const getBuiltinStatusBarItems = async () => {
1378
+ const getProblemsAriaLabel = (errorCount, warningCount) => {
1379
+ const parts = [];
1380
+ if (errorCount > 0) {
1381
+ parts.push(`${errorCount} ${errorCount === 1 ? 'Problem' : 'Problems'}`);
1382
+ }
1383
+ if (warningCount > 0) {
1384
+ parts.push(`${warningCount} ${warningCount === 1 ? 'Warning' : 'Warnings'}`);
1385
+ }
1386
+ if (parts.length === 0) {
1387
+ return 'No Problems';
1388
+ }
1389
+ return parts.join(', ');
1390
+ };
1391
+ const getBuiltinStatusBarItems = async (errorCount, warningCount) => {
1368
1392
  const extraItems = [{
1369
- command: undefined,
1393
+ ariaLabel: 'Notifications',
1394
+ command: '',
1395
+ // TODO should show notifications center
1370
1396
  elements: [{
1371
1397
  type: 'text',
1372
1398
  value: 'Notifications'
1373
1399
  }],
1374
1400
  name: Notifications,
1375
- tooltip: ''
1401
+ tooltip: 'Notifications'
1376
1402
  }, {
1377
- command: undefined,
1403
+ ariaLabel: getProblemsAriaLabel(errorCount, warningCount),
1404
+ command: '',
1405
+ // TODO should show problems view
1378
1406
  elements: [{
1379
1407
  type: 'icon',
1380
1408
  value: ProblemsErrorIcon
1381
1409
  }, {
1382
1410
  type: 'text',
1383
- value: '0'
1411
+ value: `${errorCount}`
1384
1412
  }, {
1385
1413
  type: 'icon',
1386
1414
  value: ProblemsWarningIcon
1387
1415
  }, {
1388
1416
  type: 'text',
1389
- value: '0'
1417
+ value: `${warningCount}`
1390
1418
  }],
1391
1419
  name: Problems,
1392
- tooltip: ''
1420
+ tooltip: 'Problems'
1393
1421
  }];
1394
1422
  return extraItems;
1395
1423
  };
@@ -1414,7 +1442,9 @@ const toStatusBarItem = uiStatusBarItem => {
1414
1442
  value: ''
1415
1443
  });
1416
1444
  }
1445
+ const ariaLabel = uiStatusBarItem.text || uiStatusBarItem.tooltip || uiStatusBarItem.name;
1417
1446
  return {
1447
+ ariaLabel,
1418
1448
  command: uiStatusBarItem.command || undefined,
1419
1449
  elements,
1420
1450
  name: uiStatusBarItem.name,
@@ -1445,14 +1475,14 @@ const toUiStatusBarItems = statusBarItems => {
1445
1475
  return statusBarItems.map(toUiStatusBarItem);
1446
1476
  };
1447
1477
 
1448
- const getStatusBarItems = async (showItems, assetDir, platform) => {
1478
+ const getStatusBarItems = async (showItems, assetDir, platform, errorCount, warningCount) => {
1449
1479
  if (!showItems) {
1450
1480
  return [];
1451
1481
  }
1452
1482
  await activateByEvent('onSourceControl', assetDir, platform);
1453
1483
  const extensionStatusBarItems = await getStatusBarItems$1(assetDir, platform);
1454
1484
  const uiStatusBarItems = toUiStatusBarItems(extensionStatusBarItems);
1455
- const extraItems = await getBuiltinStatusBarItems();
1485
+ const extraItems = await getBuiltinStatusBarItems(errorCount, warningCount);
1456
1486
  return [...uiStatusBarItems.map(toStatusBarItem), ...extraItems];
1457
1487
  };
1458
1488
 
@@ -1468,13 +1498,16 @@ const itemsVisible = async () => {
1468
1498
  const loadContent = async state => {
1469
1499
  const {
1470
1500
  assetDir,
1471
- platform
1501
+ errorCount,
1502
+ platform,
1503
+ warningCount
1472
1504
  } = state;
1473
1505
  const statusBarItemsPreference = await itemsVisible();
1474
- const statusBarItems = await getStatusBarItems(statusBarItemsPreference, assetDir, platform);
1506
+ const statusBarItems = await getStatusBarItems(statusBarItemsPreference, assetDir, platform, errorCount, warningCount);
1475
1507
  return {
1476
1508
  ...state,
1477
1509
  errorCount: 0,
1510
+ initial: false,
1478
1511
  statusBarItemsLeft: [...statusBarItems],
1479
1512
  statusBarItemsRight: [],
1480
1513
  warningCount: 0
@@ -1482,6 +1515,7 @@ const loadContent = async state => {
1482
1515
  };
1483
1516
 
1484
1517
  const Button$1 = 'button';
1518
+ const Status = 'status';
1485
1519
 
1486
1520
  const MaskIcon = 'MaskIcon';
1487
1521
 
@@ -1490,22 +1524,295 @@ const Div = 4;
1490
1524
  const Span = 8;
1491
1525
  const Text = 12;
1492
1526
 
1493
- const TargetName = 'event.target.name';
1494
-
1495
- const SetDom2 = 'Viewlet.setDom2';
1496
-
1497
1527
  const mergeClassNames = (...classNames) => {
1498
1528
  return classNames.filter(Boolean).join(' ');
1499
1529
  };
1500
1530
 
1501
1531
  const text = data => {
1502
1532
  return {
1503
- type: Text,
1533
+ childCount: 0,
1504
1534
  text: data,
1505
- childCount: 0
1535
+ type: Text
1536
+ };
1537
+ };
1538
+
1539
+ const SetText = 1;
1540
+ const Replace = 2;
1541
+ const SetAttribute = 3;
1542
+ const RemoveAttribute = 4;
1543
+ const Add = 6;
1544
+ const NavigateChild = 7;
1545
+ const NavigateParent = 8;
1546
+ const RemoveChild = 9;
1547
+ const NavigateSibling = 10;
1548
+
1549
+ const isKey = key => {
1550
+ return key !== 'type' && key !== 'childCount';
1551
+ };
1552
+
1553
+ const getKeys = node => {
1554
+ const keys = Object.keys(node).filter(isKey);
1555
+ return keys;
1556
+ };
1557
+
1558
+ const arrayToTree = nodes => {
1559
+ const result = [];
1560
+ let i = 0;
1561
+ while (i < nodes.length) {
1562
+ const node = nodes[i];
1563
+ const {
1564
+ children,
1565
+ nodesConsumed
1566
+ } = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
1567
+ result.push({
1568
+ node,
1569
+ children
1570
+ });
1571
+ i += 1 + nodesConsumed;
1572
+ }
1573
+ return result;
1574
+ };
1575
+ const getChildrenWithCount = (nodes, startIndex, childCount) => {
1576
+ if (childCount === 0) {
1577
+ return {
1578
+ children: [],
1579
+ nodesConsumed: 0
1580
+ };
1581
+ }
1582
+ const children = [];
1583
+ let i = startIndex;
1584
+ let remaining = childCount;
1585
+ let totalConsumed = 0;
1586
+ while (remaining > 0 && i < nodes.length) {
1587
+ const node = nodes[i];
1588
+ const nodeChildCount = node.childCount || 0;
1589
+ const {
1590
+ children: nodeChildren,
1591
+ nodesConsumed
1592
+ } = getChildrenWithCount(nodes, i + 1, nodeChildCount);
1593
+ children.push({
1594
+ node,
1595
+ children: nodeChildren
1596
+ });
1597
+ const nodeSize = 1 + nodesConsumed;
1598
+ i += nodeSize;
1599
+ totalConsumed += nodeSize;
1600
+ remaining--;
1601
+ }
1602
+ return {
1603
+ children,
1604
+ nodesConsumed: totalConsumed
1506
1605
  };
1507
1606
  };
1508
1607
 
1608
+ const compareNodes = (oldNode, newNode) => {
1609
+ const patches = [];
1610
+ // Check if node type changed - return null to signal incompatible nodes
1611
+ // (caller should handle this with a Replace operation)
1612
+ if (oldNode.type !== newNode.type) {
1613
+ return null;
1614
+ }
1615
+ // Handle text nodes
1616
+ if (oldNode.type === Text && newNode.type === Text) {
1617
+ if (oldNode.text !== newNode.text) {
1618
+ patches.push({
1619
+ type: SetText,
1620
+ value: newNode.text
1621
+ });
1622
+ }
1623
+ return patches;
1624
+ }
1625
+ // Compare attributes
1626
+ const oldKeys = getKeys(oldNode);
1627
+ const newKeys = getKeys(newNode);
1628
+ // Check for attribute changes
1629
+ for (const key of newKeys) {
1630
+ if (oldNode[key] !== newNode[key]) {
1631
+ patches.push({
1632
+ type: SetAttribute,
1633
+ key,
1634
+ value: newNode[key]
1635
+ });
1636
+ }
1637
+ }
1638
+ // Check for removed attributes
1639
+ for (const key of oldKeys) {
1640
+ if (!(key in newNode)) {
1641
+ patches.push({
1642
+ type: RemoveAttribute,
1643
+ key
1644
+ });
1645
+ }
1646
+ }
1647
+ return patches;
1648
+ };
1649
+
1650
+ const treeToArray = node => {
1651
+ const result = [node.node];
1652
+ for (const child of node.children) {
1653
+ result.push(...treeToArray(child));
1654
+ }
1655
+ return result;
1656
+ };
1657
+
1658
+ const diffChildren = (oldChildren, newChildren, patches) => {
1659
+ const maxLength = Math.max(oldChildren.length, newChildren.length);
1660
+ // Track where we are: -1 means at parent, >= 0 means at child index
1661
+ let currentChildIndex = -1;
1662
+ // Collect indices of children to remove (we'll add these patches at the end in reverse order)
1663
+ const indicesToRemove = [];
1664
+ for (let i = 0; i < maxLength; i++) {
1665
+ const oldNode = oldChildren[i];
1666
+ const newNode = newChildren[i];
1667
+ if (!oldNode && !newNode) {
1668
+ continue;
1669
+ }
1670
+ if (!oldNode) {
1671
+ // Add new node - we should be at the parent
1672
+ if (currentChildIndex >= 0) {
1673
+ // Navigate back to parent
1674
+ patches.push({
1675
+ type: NavigateParent
1676
+ });
1677
+ currentChildIndex = -1;
1678
+ }
1679
+ // Flatten the entire subtree so renderInternal can handle it
1680
+ const flatNodes = treeToArray(newNode);
1681
+ patches.push({
1682
+ type: Add,
1683
+ nodes: flatNodes
1684
+ });
1685
+ } else if (newNode) {
1686
+ // Compare nodes to see if we need any patches
1687
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
1688
+ // If nodePatches is null, the node types are incompatible - need to replace
1689
+ if (nodePatches === null) {
1690
+ // Navigate to this child
1691
+ if (currentChildIndex === -1) {
1692
+ patches.push({
1693
+ type: NavigateChild,
1694
+ index: i
1695
+ });
1696
+ currentChildIndex = i;
1697
+ } else if (currentChildIndex !== i) {
1698
+ patches.push({
1699
+ type: NavigateSibling,
1700
+ index: i
1701
+ });
1702
+ currentChildIndex = i;
1703
+ }
1704
+ // Replace the entire subtree
1705
+ const flatNodes = treeToArray(newNode);
1706
+ patches.push({
1707
+ type: Replace,
1708
+ nodes: flatNodes
1709
+ });
1710
+ // After replace, we're at the new element (same position)
1711
+ continue;
1712
+ }
1713
+ // Check if we need to recurse into children
1714
+ const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
1715
+ // Only navigate to this element if we need to do something
1716
+ if (nodePatches.length > 0 || hasChildrenToCompare) {
1717
+ // Navigate to this child if not already there
1718
+ if (currentChildIndex === -1) {
1719
+ patches.push({
1720
+ type: NavigateChild,
1721
+ index: i
1722
+ });
1723
+ currentChildIndex = i;
1724
+ } else if (currentChildIndex !== i) {
1725
+ patches.push({
1726
+ type: NavigateSibling,
1727
+ index: i
1728
+ });
1729
+ currentChildIndex = i;
1730
+ }
1731
+ // Apply node patches (these apply to the current element, not children)
1732
+ if (nodePatches.length > 0) {
1733
+ patches.push(...nodePatches);
1734
+ }
1735
+ // Compare children recursively
1736
+ if (hasChildrenToCompare) {
1737
+ diffChildren(oldNode.children, newNode.children, patches);
1738
+ }
1739
+ }
1740
+ } else {
1741
+ // Remove old node - collect the index for later removal
1742
+ indicesToRemove.push(i);
1743
+ }
1744
+ }
1745
+ // Navigate back to parent if we ended at a child
1746
+ if (currentChildIndex >= 0) {
1747
+ patches.push({
1748
+ type: NavigateParent
1749
+ });
1750
+ currentChildIndex = -1;
1751
+ }
1752
+ // Add remove patches in reverse order (highest index first)
1753
+ // This ensures indices remain valid as we remove
1754
+ for (let j = indicesToRemove.length - 1; j >= 0; j--) {
1755
+ patches.push({
1756
+ type: RemoveChild,
1757
+ index: indicesToRemove[j]
1758
+ });
1759
+ }
1760
+ };
1761
+ const diffTrees = (oldTree, newTree, patches, path) => {
1762
+ // At the root level (path.length === 0), we're already AT the element
1763
+ // So we compare the root node directly, then compare its children
1764
+ if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
1765
+ const oldNode = oldTree[0];
1766
+ const newNode = newTree[0];
1767
+ // Compare root nodes
1768
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
1769
+ // If nodePatches is null, the root node types are incompatible - need to replace
1770
+ if (nodePatches === null) {
1771
+ const flatNodes = treeToArray(newNode);
1772
+ patches.push({
1773
+ type: Replace,
1774
+ nodes: flatNodes
1775
+ });
1776
+ return;
1777
+ }
1778
+ if (nodePatches.length > 0) {
1779
+ patches.push(...nodePatches);
1780
+ }
1781
+ // Compare children
1782
+ if (oldNode.children.length > 0 || newNode.children.length > 0) {
1783
+ diffChildren(oldNode.children, newNode.children, patches);
1784
+ }
1785
+ } else {
1786
+ // Non-root level or multiple root elements - use the regular comparison
1787
+ diffChildren(oldTree, newTree, patches);
1788
+ }
1789
+ };
1790
+
1791
+ const removeTrailingNavigationPatches = patches => {
1792
+ // Find the last non-navigation patch
1793
+ let lastNonNavigationIndex = -1;
1794
+ for (let i = patches.length - 1; i >= 0; i--) {
1795
+ const patch = patches[i];
1796
+ if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
1797
+ lastNonNavigationIndex = i;
1798
+ break;
1799
+ }
1800
+ }
1801
+ // Return patches up to and including the last non-navigation patch
1802
+ return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
1803
+ };
1804
+
1805
+ const diffTree = (oldNodes, newNodes) => {
1806
+ // Step 1: Convert flat arrays to tree structures
1807
+ const oldTree = arrayToTree(oldNodes);
1808
+ const newTree = arrayToTree(newNodes);
1809
+ // Step 3: Compare the trees
1810
+ const patches = [];
1811
+ diffTrees(oldTree, newTree, patches, []);
1812
+ // Remove trailing navigation patches since they serve no purpose
1813
+ return removeTrailingNavigationPatches(patches);
1814
+ };
1815
+
1509
1816
  const HandleClick = 11;
1510
1817
 
1511
1818
  const getTextVirtualDom = element => {
@@ -1534,12 +1841,14 @@ const getStatusBarItemElementVirtualDom = element => {
1534
1841
 
1535
1842
  const getStatusBarItemVirtualDom = statusBarItem => {
1536
1843
  const {
1844
+ ariaLabel,
1537
1845
  elements,
1538
1846
  name,
1539
1847
  tooltip
1540
1848
  } = statusBarItem;
1541
1849
  const elementNodes = elements.flatMap(getStatusBarItemElementVirtualDom);
1542
- return [{
1850
+ const buttonNode = {
1851
+ ariaLabel,
1543
1852
  childCount: elements.length,
1544
1853
  className: StatusBarItem,
1545
1854
  name,
@@ -1547,7 +1856,8 @@ const getStatusBarItemVirtualDom = statusBarItem => {
1547
1856
  tabIndex: -1,
1548
1857
  title: tooltip,
1549
1858
  type: Button
1550
- }, ...elementNodes];
1859
+ };
1860
+ return [buttonNode, ...elementNodes];
1551
1861
  };
1552
1862
 
1553
1863
  const getStatusBarItemsVirtualDom = (items, className) => {
@@ -1576,6 +1886,7 @@ const getStatusBarVirtualDom = (statusBarItemsLeft, statusBarItemsRight) => {
1576
1886
  childCount: getChildCount(statusBarItemsLeft.length, statusBarItemsRight.length),
1577
1887
  className: 'StatusBar',
1578
1888
  onClick: HandleClick,
1889
+ role: Status,
1579
1890
  type: Div
1580
1891
  }, ...getStatusBarItemsVirtualDom(statusBarItemsLeft, StatusBarItemsLeft), ...getStatusBarItemsVirtualDom(statusBarItemsRight, StatusBarItemsRight)];
1581
1892
  return dom;
@@ -1591,8 +1902,17 @@ const renderItems = (oldState, newState) => {
1591
1902
  return [SetDom2, uid, dom];
1592
1903
  };
1593
1904
 
1905
+ const renderIcremental = (oldState, newState) => {
1906
+ const oldDom = renderItems(oldState, oldState)[2];
1907
+ const newDom = renderItems(newState, newState)[2];
1908
+ const patches = diffTree(oldDom, newDom);
1909
+ return [SetPatches, newState.uid, patches];
1910
+ };
1911
+
1594
1912
  const getRenderer = diffType => {
1595
1913
  switch (diffType) {
1914
+ case RenderIncremental:
1915
+ return renderIcremental;
1596
1916
  case RenderItems:
1597
1917
  return renderItems;
1598
1918
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,6 +11,6 @@
11
11
  "type": "module",
12
12
  "main": "dist/statusBarWorkerMain.js",
13
13
  "dependencies": {
14
- "@lvce-editor/virtual-dom-worker": "^4.0.0"
14
+ "@lvce-editor/virtual-dom-worker": "^6.8.0"
15
15
  }
16
16
  }