@lvce-editor/status-bar-worker 3.32.0 → 3.32.2
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.
- package/dist/statusBarWorkerMain.js +452 -44
- package/package.json +1 -1
|
@@ -263,9 +263,9 @@ const terminate = () => {
|
|
|
263
263
|
const {
|
|
264
264
|
get: get$5,
|
|
265
265
|
getCommandIds,
|
|
266
|
-
getKeys,
|
|
266
|
+
getKeys: getKeys$1,
|
|
267
267
|
registerCommands,
|
|
268
|
-
set: set$
|
|
268
|
+
set: set$9,
|
|
269
269
|
wrapCommand,
|
|
270
270
|
wrapGetter,
|
|
271
271
|
wrapSerialAsyncCommand} = create$a();
|
|
@@ -279,13 +279,19 @@ const create$9 = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
279
279
|
statusBarItemsLeft: [],
|
|
280
280
|
statusBarItemsRight: [],
|
|
281
281
|
uid,
|
|
282
|
-
|
|
282
|
+
visibleStatusBarItemsLeft: [],
|
|
283
|
+
visibleStatusBarItemsRight: [],
|
|
284
|
+
warningCount: 0,
|
|
285
|
+
width
|
|
283
286
|
};
|
|
284
|
-
set$
|
|
287
|
+
set$9(uid, state, state);
|
|
285
288
|
};
|
|
286
289
|
|
|
290
|
+
const areItemsEqual = (left, right) => {
|
|
291
|
+
return left.length === right.length && left.every((item, index) => item === right[index]);
|
|
292
|
+
};
|
|
287
293
|
const isEqual = (oldState, newState) => {
|
|
288
|
-
return oldState.statusBarItemsLeft === newState.statusBarItemsLeft && oldState.statusBarItemsRight === newState.statusBarItemsRight;
|
|
294
|
+
return oldState.statusBarItemsLeft === newState.statusBarItemsLeft && oldState.statusBarItemsRight === newState.statusBarItemsRight && oldState.width === newState.width && areItemsEqual(oldState.visibleStatusBarItemsLeft, newState.visibleStatusBarItemsLeft) && areItemsEqual(oldState.visibleStatusBarItemsRight, newState.visibleStatusBarItemsRight);
|
|
289
295
|
};
|
|
290
296
|
|
|
291
297
|
const RenderItems = 4;
|
|
@@ -499,9 +505,11 @@ const TargetName = 'event.target.name';
|
|
|
499
505
|
const ExtensionManagementWorker = 9006;
|
|
500
506
|
const RendererProcess = 1670;
|
|
501
507
|
const RendererWorker = 1;
|
|
508
|
+
const TextMeasurementWorker = 7011;
|
|
502
509
|
|
|
503
510
|
const SetDom2 = 'Viewlet.setDom2';
|
|
504
511
|
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
512
|
+
const SetPatches = 'Viewlet.setPatches';
|
|
505
513
|
|
|
506
514
|
const mergeClassNames = (...classNames) => {
|
|
507
515
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -517,6 +525,266 @@ const text = data => {
|
|
|
517
525
|
|
|
518
526
|
new Set(Object.values(VirtualDomElements));
|
|
519
527
|
|
|
528
|
+
const SetText = 1;
|
|
529
|
+
const Replace = 2;
|
|
530
|
+
const SetAttribute = 3;
|
|
531
|
+
const RemoveAttribute = 4;
|
|
532
|
+
const Add = 6;
|
|
533
|
+
const NavigateChild = 7;
|
|
534
|
+
const NavigateParent = 8;
|
|
535
|
+
const RemoveChild = 9;
|
|
536
|
+
const NavigateSibling = 10;
|
|
537
|
+
const SetReferenceNodeUid = 11;
|
|
538
|
+
|
|
539
|
+
const isKey = key => {
|
|
540
|
+
return key !== 'type' && key !== 'childCount';
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
const getKeys = node => {
|
|
544
|
+
const keys = Object.keys(node).filter(isKey);
|
|
545
|
+
return keys;
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
const arrayToTree = nodes => {
|
|
549
|
+
const result = [];
|
|
550
|
+
let i = 0;
|
|
551
|
+
while (i < nodes.length) {
|
|
552
|
+
const node = nodes[i];
|
|
553
|
+
const {
|
|
554
|
+
children,
|
|
555
|
+
nodesConsumed
|
|
556
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
557
|
+
result.push({
|
|
558
|
+
node,
|
|
559
|
+
children
|
|
560
|
+
});
|
|
561
|
+
i += 1 + nodesConsumed;
|
|
562
|
+
}
|
|
563
|
+
return result;
|
|
564
|
+
};
|
|
565
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
566
|
+
if (childCount === 0) {
|
|
567
|
+
return {
|
|
568
|
+
children: [],
|
|
569
|
+
nodesConsumed: 0
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
const children = [];
|
|
573
|
+
let i = startIndex;
|
|
574
|
+
let remaining = childCount;
|
|
575
|
+
let totalConsumed = 0;
|
|
576
|
+
while (remaining > 0 && i < nodes.length) {
|
|
577
|
+
const node = nodes[i];
|
|
578
|
+
const nodeChildCount = node.childCount || 0;
|
|
579
|
+
const {
|
|
580
|
+
children: nodeChildren,
|
|
581
|
+
nodesConsumed
|
|
582
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
583
|
+
children.push({
|
|
584
|
+
node,
|
|
585
|
+
children: nodeChildren
|
|
586
|
+
});
|
|
587
|
+
const nodeSize = 1 + nodesConsumed;
|
|
588
|
+
i += nodeSize;
|
|
589
|
+
totalConsumed += nodeSize;
|
|
590
|
+
remaining--;
|
|
591
|
+
}
|
|
592
|
+
return {
|
|
593
|
+
children,
|
|
594
|
+
nodesConsumed: totalConsumed
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
const compareNodes = (oldNode, newNode) => {
|
|
599
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
600
|
+
// (caller should handle this with a Replace operation)
|
|
601
|
+
if (oldNode.type !== newNode.type) {
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
const patches = [];
|
|
605
|
+
// Handle reference nodes - special handling for uid changes
|
|
606
|
+
if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
|
|
607
|
+
patches.push({
|
|
608
|
+
type: SetReferenceNodeUid,
|
|
609
|
+
uid: newNode.uid
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
// Handle text nodes
|
|
613
|
+
if (oldNode.type === Text && newNode.type === Text) {
|
|
614
|
+
if (oldNode.text !== newNode.text) {
|
|
615
|
+
patches.push({
|
|
616
|
+
type: SetText,
|
|
617
|
+
value: newNode.text
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
return patches;
|
|
621
|
+
}
|
|
622
|
+
// Compare attributes
|
|
623
|
+
const oldKeys = getKeys(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
|
|
624
|
+
const newKeys = getKeys(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
|
|
625
|
+
// Check for attribute changes
|
|
626
|
+
for (const key of newKeys) {
|
|
627
|
+
if (oldNode[key] !== newNode[key]) {
|
|
628
|
+
patches.push({
|
|
629
|
+
type: SetAttribute,
|
|
630
|
+
key,
|
|
631
|
+
value: newNode[key]
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
// Check for removed attributes
|
|
636
|
+
for (const key of oldKeys) {
|
|
637
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
638
|
+
patches.push({
|
|
639
|
+
type: RemoveAttribute,
|
|
640
|
+
key
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return patches;
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
const treeToArray = node => {
|
|
648
|
+
const result = [];
|
|
649
|
+
const stack = [node];
|
|
650
|
+
while (stack.length > 0) {
|
|
651
|
+
const current = stack.pop();
|
|
652
|
+
result.push(current.node);
|
|
653
|
+
for (let i = current.children.length - 1; i >= 0; i--) {
|
|
654
|
+
stack.push(current.children[i]);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return result;
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
661
|
+
if (currentChildIndex === -1) {
|
|
662
|
+
patches.push({
|
|
663
|
+
type: NavigateChild,
|
|
664
|
+
index
|
|
665
|
+
});
|
|
666
|
+
return index;
|
|
667
|
+
}
|
|
668
|
+
if (currentChildIndex !== index) {
|
|
669
|
+
patches.push({
|
|
670
|
+
type: NavigateSibling,
|
|
671
|
+
index
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
return index;
|
|
675
|
+
};
|
|
676
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
677
|
+
if (currentChildIndex >= 0) {
|
|
678
|
+
patches.push({
|
|
679
|
+
type: NavigateParent
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
return -1;
|
|
683
|
+
};
|
|
684
|
+
const addTree = (newNode, patches) => {
|
|
685
|
+
patches.push({
|
|
686
|
+
type: Add,
|
|
687
|
+
nodes: treeToArray(newNode)
|
|
688
|
+
});
|
|
689
|
+
};
|
|
690
|
+
const replaceTree = (newNode, patches) => {
|
|
691
|
+
patches.push({
|
|
692
|
+
type: Replace,
|
|
693
|
+
nodes: treeToArray(newNode)
|
|
694
|
+
});
|
|
695
|
+
};
|
|
696
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
697
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
698
|
+
if (nodePatches === null) {
|
|
699
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
700
|
+
replaceTree(newNode, patches);
|
|
701
|
+
return nextChildIndex;
|
|
702
|
+
}
|
|
703
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
704
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
705
|
+
return currentChildIndex;
|
|
706
|
+
}
|
|
707
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
708
|
+
if (nodePatches.length > 0) {
|
|
709
|
+
patches.push(...nodePatches);
|
|
710
|
+
}
|
|
711
|
+
if (hasChildrenToCompare) {
|
|
712
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
713
|
+
}
|
|
714
|
+
return nextChildIndex;
|
|
715
|
+
};
|
|
716
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
717
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
718
|
+
if (nodePatches === null) {
|
|
719
|
+
replaceTree(newNode, patches);
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
if (nodePatches.length > 0) {
|
|
723
|
+
patches.push(...nodePatches);
|
|
724
|
+
}
|
|
725
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
726
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
730
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
731
|
+
let currentChildIndex = -1;
|
|
732
|
+
const indicesToRemove = [];
|
|
733
|
+
for (let i = 0; i < maxLength; i++) {
|
|
734
|
+
const oldNode = oldChildren[i];
|
|
735
|
+
const newNode = newChildren[i];
|
|
736
|
+
if (!oldNode && !newNode) {
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
if (!oldNode) {
|
|
740
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
741
|
+
addTree(newNode, patches);
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
if (!newNode) {
|
|
745
|
+
indicesToRemove.push(i);
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
749
|
+
}
|
|
750
|
+
navigateToParent(patches, currentChildIndex);
|
|
751
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
752
|
+
patches.push({
|
|
753
|
+
type: RemoveChild,
|
|
754
|
+
index: indicesToRemove[j]
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
759
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
760
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
diffChildren(oldTree, newTree, patches);
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
const removeTrailingNavigationPatches = patches => {
|
|
767
|
+
while (patches.length > 0) {
|
|
768
|
+
const patch = patches.at(-1);
|
|
769
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
770
|
+
break;
|
|
771
|
+
}
|
|
772
|
+
patches.pop();
|
|
773
|
+
}
|
|
774
|
+
return patches;
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
778
|
+
// Step 1: Convert flat arrays to tree structures
|
|
779
|
+
const oldTree = arrayToTree(oldNodes);
|
|
780
|
+
const newTree = arrayToTree(newNodes);
|
|
781
|
+
// Step 3: Compare the trees
|
|
782
|
+
const patches = [];
|
|
783
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
784
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
785
|
+
return removeTrailingNavigationPatches(patches);
|
|
786
|
+
};
|
|
787
|
+
|
|
520
788
|
const HandleContextMenu = 2;
|
|
521
789
|
const HandleClick = 11;
|
|
522
790
|
|
|
@@ -616,11 +884,11 @@ const getStatusBarVirtualDom = (statusBarItemsLeft, statusBarItemsRight) => {
|
|
|
616
884
|
|
|
617
885
|
const renderItems = (oldState, newState) => {
|
|
618
886
|
const {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
887
|
+
uid,
|
|
888
|
+
visibleStatusBarItemsLeft,
|
|
889
|
+
visibleStatusBarItemsRight
|
|
622
890
|
} = newState;
|
|
623
|
-
const dom = getStatusBarVirtualDom(
|
|
891
|
+
const dom = getStatusBarVirtualDom(visibleStatusBarItemsLeft, visibleStatusBarItemsRight);
|
|
624
892
|
return [SetDom2, uid, dom];
|
|
625
893
|
};
|
|
626
894
|
|
|
@@ -658,10 +926,10 @@ const isRight = name => {
|
|
|
658
926
|
const state$2 = {
|
|
659
927
|
rpc: undefined
|
|
660
928
|
};
|
|
661
|
-
const set$
|
|
929
|
+
const set$8 = rpc => {
|
|
662
930
|
state$2.rpc = rpc;
|
|
663
931
|
};
|
|
664
|
-
const invoke$
|
|
932
|
+
const invoke$6 = (method, ...args) => {
|
|
665
933
|
const {
|
|
666
934
|
rpc
|
|
667
935
|
} = state$2;
|
|
@@ -674,16 +942,16 @@ const handleClickEditorStatus = async (name, status) => {
|
|
|
674
942
|
}
|
|
675
943
|
switch (name) {
|
|
676
944
|
case EditorEndOfLine$1:
|
|
677
|
-
await invoke$
|
|
945
|
+
await invoke$6('QuickPick.openStatusBarPicker', 'end-of-line');
|
|
678
946
|
return;
|
|
679
947
|
case EditorIndentation:
|
|
680
|
-
await invoke$
|
|
948
|
+
await invoke$6('QuickPick.openStatusBarPicker', 'indentation');
|
|
681
949
|
return;
|
|
682
950
|
case EditorLanguage$1:
|
|
683
|
-
await invoke$
|
|
951
|
+
await invoke$6('QuickPick.openStatusBarPicker', 'language-mode');
|
|
684
952
|
return;
|
|
685
953
|
case EditorPosition$1:
|
|
686
|
-
await invoke$
|
|
954
|
+
await invoke$6('QuickPick.openStatusBarPicker', 'go-to-line', status.line, status.column);
|
|
687
955
|
return;
|
|
688
956
|
}
|
|
689
957
|
};
|
|
@@ -1800,7 +2068,7 @@ const createMockRpc = ({
|
|
|
1800
2068
|
};
|
|
1801
2069
|
|
|
1802
2070
|
const rpcs = Object.create(null);
|
|
1803
|
-
const set$
|
|
2071
|
+
const set$7 = (id, rpc) => {
|
|
1804
2072
|
rpcs[id] = rpc;
|
|
1805
2073
|
};
|
|
1806
2074
|
const get$3 = id => {
|
|
@@ -1833,7 +2101,7 @@ const create = rpcId => {
|
|
|
1833
2101
|
const mockRpc = createMockRpc({
|
|
1834
2102
|
commandMap
|
|
1835
2103
|
});
|
|
1836
|
-
set$
|
|
2104
|
+
set$7(rpcId, mockRpc);
|
|
1837
2105
|
// @ts-ignore
|
|
1838
2106
|
mockRpc[Symbol.dispose] = () => {
|
|
1839
2107
|
remove(rpcId);
|
|
@@ -1842,33 +2110,45 @@ const create = rpcId => {
|
|
|
1842
2110
|
return mockRpc;
|
|
1843
2111
|
},
|
|
1844
2112
|
set(rpc) {
|
|
1845
|
-
set$
|
|
2113
|
+
set$7(rpcId, rpc);
|
|
1846
2114
|
}
|
|
1847
2115
|
};
|
|
1848
2116
|
};
|
|
1849
2117
|
|
|
2118
|
+
const {
|
|
2119
|
+
invoke: invoke$5,
|
|
2120
|
+
set: set$6
|
|
2121
|
+
} = create(ExtensionManagementWorker);
|
|
2122
|
+
|
|
1850
2123
|
const {
|
|
1851
2124
|
invoke: invoke$4,
|
|
1852
2125
|
set: set$5
|
|
1853
|
-
} = create(
|
|
2126
|
+
} = create(RendererProcess);
|
|
1854
2127
|
|
|
1855
2128
|
const {
|
|
1856
2129
|
invoke: invoke$3,
|
|
1857
2130
|
set: set$4
|
|
1858
|
-
} = create(
|
|
2131
|
+
} = create(TextMeasurementWorker);
|
|
2132
|
+
const measureTextWidths$1 = async (texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
|
|
2133
|
+
return invoke$3('TextMeasurement.measureTextWidths', texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
|
|
2134
|
+
};
|
|
1859
2135
|
|
|
1860
2136
|
const {
|
|
1861
2137
|
invoke: invoke$2,
|
|
1862
2138
|
invokeAndTransfer,
|
|
1863
2139
|
set: set$3
|
|
1864
2140
|
} = create(RendererWorker);
|
|
2141
|
+
const sendMessagePortToTextMeasurementWorker = async port => {
|
|
2142
|
+
const command = 'TextMeasurement.handleMessagePort';
|
|
2143
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
2144
|
+
};
|
|
1865
2145
|
const getPreference = async key => {
|
|
1866
2146
|
return await invoke$2('Preferences.get', key);
|
|
1867
2147
|
};
|
|
1868
2148
|
|
|
1869
2149
|
const handleClickExtensionStatusBarItem = async name => {
|
|
1870
2150
|
try {
|
|
1871
|
-
await invoke$
|
|
2151
|
+
await invoke$5('Extensions.executeCommand', name);
|
|
1872
2152
|
} catch (error) {
|
|
1873
2153
|
console.error(new VError(error, `Failed to execute status bar command: ${name}`));
|
|
1874
2154
|
}
|
|
@@ -1929,7 +2209,7 @@ const show2 = async (uid, menuId, x, y, args) => {
|
|
|
1929
2209
|
|
|
1930
2210
|
const getStatusBarItemContextMenuItems = async (extensionId, providerId) => {
|
|
1931
2211
|
try {
|
|
1932
|
-
return await invoke$
|
|
2212
|
+
return await invoke$5('Extensions.getStatusBarItemContextMenuItems', extensionId, providerId);
|
|
1933
2213
|
} catch {
|
|
1934
2214
|
return [];
|
|
1935
2215
|
}
|
|
@@ -2171,7 +2451,25 @@ const handleEditorStatusChanged = (state, editorStatus, previous = state) => {
|
|
|
2171
2451
|
};
|
|
2172
2452
|
|
|
2173
2453
|
const renderIncremental = (oldState, newState) => {
|
|
2174
|
-
|
|
2454
|
+
if (oldState.initial) {
|
|
2455
|
+
return renderItems(oldState, newState);
|
|
2456
|
+
}
|
|
2457
|
+
const oldDom = getStatusBarVirtualDom(oldState.visibleStatusBarItemsLeft, oldState.visibleStatusBarItemsRight);
|
|
2458
|
+
const newDom = getStatusBarVirtualDom(newState.visibleStatusBarItemsLeft, newState.visibleStatusBarItemsRight);
|
|
2459
|
+
// Structural and visibility changes can replace or reorder item groups.
|
|
2460
|
+
// Keep their full-render fallback, including the renderer's ambiguous
|
|
2461
|
+
// solitary Add encoding. Only patch a stable tree of the same items.
|
|
2462
|
+
if (oldDom.length !== newDom.length || oldDom.some((node, index) => {
|
|
2463
|
+
const other = newDom[index];
|
|
2464
|
+
return node.type !== other.type || node.childCount !== other.childCount || node.className !== other.className || node.name !== other.name;
|
|
2465
|
+
})) {
|
|
2466
|
+
return renderItems(oldState, newState);
|
|
2467
|
+
}
|
|
2468
|
+
const patches = diffTree(oldDom, newDom);
|
|
2469
|
+
if (patches.length === 0) {
|
|
2470
|
+
return [];
|
|
2471
|
+
}
|
|
2472
|
+
return [SetPatches, newState.uid, patches];
|
|
2175
2473
|
};
|
|
2176
2474
|
|
|
2177
2475
|
const getRenderer = diffType => {
|
|
@@ -2197,6 +2495,81 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
2197
2495
|
return commands;
|
|
2198
2496
|
};
|
|
2199
2497
|
|
|
2498
|
+
const fontSize = 12;
|
|
2499
|
+
const fontFamily = 'system-ui, Ubuntu, Droid Sans, sans-serif';
|
|
2500
|
+
const itemPaddingAndMargin = 16;
|
|
2501
|
+
const iconWidth = 20;
|
|
2502
|
+
const horizontalGroupPadding = 14;
|
|
2503
|
+
const measuredWidths = new WeakMap();
|
|
2504
|
+
const fallbackTextWidth = 150;
|
|
2505
|
+
const measureTextWidths = async values => {
|
|
2506
|
+
if (values.length === 0) {
|
|
2507
|
+
return [];
|
|
2508
|
+
}
|
|
2509
|
+
try {
|
|
2510
|
+
return await measureTextWidths$1(values, 400, fontSize, fontFamily, 0, false, 0);
|
|
2511
|
+
} catch {
|
|
2512
|
+
return values.map(() => fallbackTextWidth);
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2515
|
+
const getItemWidths = async items => {
|
|
2516
|
+
const unmeasuredItems = [...new Set(items.filter(item => !measuredWidths.has(item)))];
|
|
2517
|
+
const textElements = unmeasuredItems.flatMap(item => item.elements.filter(element => element.type === 'text'));
|
|
2518
|
+
const textWidths = await measureTextWidths(textElements.map(element => element.value));
|
|
2519
|
+
let textIndex = 0;
|
|
2520
|
+
for (const item of unmeasuredItems) {
|
|
2521
|
+
let itemWidth = itemPaddingAndMargin;
|
|
2522
|
+
for (const element of item.elements) {
|
|
2523
|
+
if (element.type === 'icon') {
|
|
2524
|
+
itemWidth += iconWidth;
|
|
2525
|
+
} else {
|
|
2526
|
+
itemWidth += textWidths[textIndex];
|
|
2527
|
+
textIndex++;
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
measuredWidths.set(item, Promise.resolve(itemWidth));
|
|
2531
|
+
}
|
|
2532
|
+
return Promise.all(items.map(item => measuredWidths.get(item)));
|
|
2533
|
+
};
|
|
2534
|
+
const fitItems = (items, widths, availableWidth) => {
|
|
2535
|
+
const visible = [];
|
|
2536
|
+
let usedWidth = 0;
|
|
2537
|
+
for (let i = 0; i < items.length; i++) {
|
|
2538
|
+
const itemWidth = widths[i];
|
|
2539
|
+
if (itemWidth <= availableWidth - usedWidth) {
|
|
2540
|
+
visible.push(items[i]);
|
|
2541
|
+
usedWidth += itemWidth;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
return {
|
|
2545
|
+
items: visible,
|
|
2546
|
+
usedWidth
|
|
2547
|
+
};
|
|
2548
|
+
};
|
|
2549
|
+
const equalItems = (left, right) => {
|
|
2550
|
+
return left.length === right.length && left.every((item, index) => item === right[index]);
|
|
2551
|
+
};
|
|
2552
|
+
const getVisibleStatusBarItems = async state => {
|
|
2553
|
+
const {
|
|
2554
|
+
statusBarItemsLeft,
|
|
2555
|
+
statusBarItemsRight,
|
|
2556
|
+
visibleStatusBarItemsLeft,
|
|
2557
|
+
visibleStatusBarItemsRight,
|
|
2558
|
+
width
|
|
2559
|
+
} = state;
|
|
2560
|
+
const innerWidth = Math.max(0, width - horizontalGroupPadding);
|
|
2561
|
+
const itemWidths = await getItemWidths([...statusBarItemsLeft, ...statusBarItemsRight]);
|
|
2562
|
+
const leftWidths = itemWidths.slice(0, statusBarItemsLeft.length);
|
|
2563
|
+
const rightWidths = itemWidths.slice(statusBarItemsLeft.length);
|
|
2564
|
+
const right = fitItems(statusBarItemsRight, rightWidths, innerWidth);
|
|
2565
|
+
const left = fitItems(statusBarItemsLeft, leftWidths, innerWidth - right.usedWidth);
|
|
2566
|
+
return {
|
|
2567
|
+
...state,
|
|
2568
|
+
visibleStatusBarItemsLeft: equalItems(visibleStatusBarItemsLeft, left.items) ? visibleStatusBarItemsLeft : left.items,
|
|
2569
|
+
visibleStatusBarItemsRight: equalItems(visibleStatusBarItemsRight, right.items) ? visibleStatusBarItemsRight : right.items
|
|
2570
|
+
};
|
|
2571
|
+
};
|
|
2572
|
+
|
|
2200
2573
|
const state = {
|
|
2201
2574
|
connected: false
|
|
2202
2575
|
};
|
|
@@ -2207,10 +2580,10 @@ const isConnected = () => {
|
|
|
2207
2580
|
return connected;
|
|
2208
2581
|
};
|
|
2209
2582
|
const invoke = (method, ...params) => {
|
|
2210
|
-
return invoke$
|
|
2583
|
+
return invoke$4(method, ...params);
|
|
2211
2584
|
};
|
|
2212
2585
|
const set$1 = rpc => {
|
|
2213
|
-
set$
|
|
2586
|
+
set$5(rpc);
|
|
2214
2587
|
state.connected = true;
|
|
2215
2588
|
};
|
|
2216
2589
|
|
|
@@ -2220,13 +2593,36 @@ const renderDirect = async (uid, commands) => {
|
|
|
2220
2593
|
const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
|
|
2221
2594
|
return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
|
|
2222
2595
|
};
|
|
2223
|
-
const render2 = (uid,
|
|
2596
|
+
const render2 = async (uid, _diffResult) => {
|
|
2597
|
+
let current = get$5(uid);
|
|
2598
|
+
let {
|
|
2599
|
+
newState
|
|
2600
|
+
} = current;
|
|
2601
|
+
while (true) {
|
|
2602
|
+
const measuredState = await getVisibleStatusBarItems(newState);
|
|
2603
|
+
const latest = get$5(uid);
|
|
2604
|
+
const {
|
|
2605
|
+
newState: latestState
|
|
2606
|
+
} = latest;
|
|
2607
|
+
if (latestState === newState) {
|
|
2608
|
+
current = latest;
|
|
2609
|
+
newState = measuredState;
|
|
2610
|
+
set$9(uid, current.oldState, newState);
|
|
2611
|
+
break;
|
|
2612
|
+
}
|
|
2613
|
+
newState = latestState;
|
|
2614
|
+
}
|
|
2615
|
+
const changed = [...new Set([..._diffResult, ...diff(current.oldState, newState)])];
|
|
2616
|
+
// A full replacement already includes every change; do not patch its new tree
|
|
2617
|
+
// using paths calculated against the old tree.
|
|
2618
|
+
const diffResult = changed.includes(RenderItems) ? changed.filter(type => type !== RenderIncremental) : changed;
|
|
2224
2619
|
const {
|
|
2225
|
-
newState,
|
|
2226
2620
|
oldState
|
|
2227
|
-
} =
|
|
2228
|
-
set$8(uid, newState, newState);
|
|
2621
|
+
} = current;
|
|
2229
2622
|
const commands = applyRender(oldState, newState, diffResult);
|
|
2623
|
+
// Advance synchronously: subsequent out-of-band updates must diff against
|
|
2624
|
+
// the DOM commands just generated, including updates that revert a value.
|
|
2625
|
+
set$9(uid, newState, newState);
|
|
2230
2626
|
if (!isConnected()) {
|
|
2231
2627
|
return commands;
|
|
2232
2628
|
}
|
|
@@ -2260,7 +2656,7 @@ const handleEditorStatusChangedAll = async update => {
|
|
|
2260
2656
|
};
|
|
2261
2657
|
const editorStatus = applyUpdate(update);
|
|
2262
2658
|
const changedUids = [];
|
|
2263
|
-
for (const uid of getKeys()) {
|
|
2659
|
+
for (const uid of getKeys$1()) {
|
|
2264
2660
|
const {
|
|
2265
2661
|
newState,
|
|
2266
2662
|
oldState
|
|
@@ -2272,7 +2668,7 @@ const handleEditorStatusChangedAll = async update => {
|
|
|
2272
2668
|
if (newState === newerState || oldState === newerState) {
|
|
2273
2669
|
continue;
|
|
2274
2670
|
}
|
|
2275
|
-
set$
|
|
2671
|
+
set$9(uid, oldState, newerState);
|
|
2276
2672
|
changedUids.push(uid);
|
|
2277
2673
|
}
|
|
2278
2674
|
await Promise.all(changedUids.map(renderOutOfBand));
|
|
@@ -2304,7 +2700,7 @@ const handleEditorStatusVisibilityChangedAll = async visible => {
|
|
|
2304
2700
|
}
|
|
2305
2701
|
setVisible(visible);
|
|
2306
2702
|
const changedUids = [];
|
|
2307
|
-
for (const uid of getKeys()) {
|
|
2703
|
+
for (const uid of getKeys$1()) {
|
|
2308
2704
|
const {
|
|
2309
2705
|
newState,
|
|
2310
2706
|
oldState
|
|
@@ -2313,7 +2709,7 @@ const handleEditorStatusVisibilityChangedAll = async visible => {
|
|
|
2313
2709
|
if (newState === newerState || oldState === newerState) {
|
|
2314
2710
|
continue;
|
|
2315
2711
|
}
|
|
2316
|
-
set$
|
|
2712
|
+
set$9(uid, oldState, newerState);
|
|
2317
2713
|
changedUids.push(uid);
|
|
2318
2714
|
}
|
|
2319
2715
|
await Promise.all(changedUids.map(renderOutOfBand));
|
|
@@ -2400,8 +2796,8 @@ const getBuiltinStatusBarItems = async (errorCount, warningCount, {
|
|
|
2400
2796
|
};
|
|
2401
2797
|
|
|
2402
2798
|
const getExtensionStatusBarItems = async (assetDir, platform) => {
|
|
2403
|
-
await invoke$
|
|
2404
|
-
return invoke$
|
|
2799
|
+
await invoke$5('Extensions.activateByEvent', 'onStatusBarItem', assetDir, platform);
|
|
2800
|
+
return invoke$5('Extensions.getStatusBarItems');
|
|
2405
2801
|
};
|
|
2406
2802
|
|
|
2407
2803
|
const toStatusBarItem = uiStatusBarItem => {
|
|
@@ -2479,7 +2875,7 @@ const toUiStatusBarItems = statusBarItems => {
|
|
|
2479
2875
|
|
|
2480
2876
|
const getNotificationCount = async () => {
|
|
2481
2877
|
try {
|
|
2482
|
-
return await invoke$
|
|
2878
|
+
return await invoke$5('Extensions.getNotificationCount');
|
|
2483
2879
|
} catch {
|
|
2484
2880
|
return 0;
|
|
2485
2881
|
}
|
|
@@ -2546,7 +2942,7 @@ const handleItemsChanged = async state => {
|
|
|
2546
2942
|
};
|
|
2547
2943
|
|
|
2548
2944
|
const handleExtensionManagementChange = async () => {
|
|
2549
|
-
for (const uid of getKeys()) {
|
|
2945
|
+
for (const uid of getKeys$1()) {
|
|
2550
2946
|
const {
|
|
2551
2947
|
newState,
|
|
2552
2948
|
oldState
|
|
@@ -2558,7 +2954,7 @@ const handleExtensionManagementChange = async () => {
|
|
|
2558
2954
|
// Loading and other updates can finish while the provider query is pending.
|
|
2559
2955
|
// Only replace the extension items; retain the current lifecycle and render baseline.
|
|
2560
2956
|
const current = get$5(uid);
|
|
2561
|
-
set$
|
|
2957
|
+
set$9(uid, current.oldState, {
|
|
2562
2958
|
...current.newState,
|
|
2563
2959
|
statusBarItemsLeft: newerState.statusBarItemsLeft
|
|
2564
2960
|
});
|
|
@@ -2594,7 +2990,7 @@ const set = count => {
|
|
|
2594
2990
|
|
|
2595
2991
|
const handleNotificationCountChangedAll = async count => {
|
|
2596
2992
|
set(count);
|
|
2597
|
-
for (const uid of getKeys()) {
|
|
2993
|
+
for (const uid of getKeys$1()) {
|
|
2598
2994
|
const {
|
|
2599
2995
|
newState,
|
|
2600
2996
|
oldState
|
|
@@ -2603,7 +2999,7 @@ const handleNotificationCountChangedAll = async count => {
|
|
|
2603
2999
|
if (newState === newerState || oldState === newerState) {
|
|
2604
3000
|
continue;
|
|
2605
3001
|
}
|
|
2606
|
-
set$
|
|
3002
|
+
set$9(uid, oldState, newerState);
|
|
2607
3003
|
await renderOutOfBand(uid);
|
|
2608
3004
|
}
|
|
2609
3005
|
};
|
|
@@ -2618,7 +3014,7 @@ const handleExtensionManagementMessagePort = async port => {
|
|
|
2618
3014
|
commandMap: commandMap$1,
|
|
2619
3015
|
messagePort: port
|
|
2620
3016
|
});
|
|
2621
|
-
set$
|
|
3017
|
+
set$6(rpc);
|
|
2622
3018
|
};
|
|
2623
3019
|
|
|
2624
3020
|
const supportsEditorStatusDeltas = () => true;
|
|
@@ -2672,7 +3068,7 @@ const handleWorkspaceChange = async state => {
|
|
|
2672
3068
|
assetDir,
|
|
2673
3069
|
platform
|
|
2674
3070
|
} = state;
|
|
2675
|
-
await invoke$
|
|
3071
|
+
await invoke$5('Extensions.activateByEvent', 'onStatusBarItem', assetDir, platform);
|
|
2676
3072
|
return state;
|
|
2677
3073
|
};
|
|
2678
3074
|
|
|
@@ -2910,7 +3306,7 @@ const initializeQuickPickWorker = async () => {
|
|
|
2910
3306
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToQuickPickWorker', port, 'QuickPick.handleStatusBarMessagePort', 0);
|
|
2911
3307
|
}
|
|
2912
3308
|
});
|
|
2913
|
-
set$
|
|
3309
|
+
set$8(rpc);
|
|
2914
3310
|
};
|
|
2915
3311
|
|
|
2916
3312
|
const initializeRenderWorker = async () => {
|
|
@@ -2920,9 +3316,21 @@ const initializeRenderWorker = async () => {
|
|
|
2920
3316
|
set$3(rpc);
|
|
2921
3317
|
};
|
|
2922
3318
|
|
|
3319
|
+
const send = port => {
|
|
3320
|
+
// @ts-ignore
|
|
3321
|
+
return sendMessagePortToTextMeasurementWorker(port);
|
|
3322
|
+
};
|
|
3323
|
+
const initializeTextMeasurementWorkerRpc = async () => {
|
|
3324
|
+
const rpc = await create$2({
|
|
3325
|
+
commandMap: {},
|
|
3326
|
+
send
|
|
3327
|
+
});
|
|
3328
|
+
set$4(rpc);
|
|
3329
|
+
};
|
|
3330
|
+
|
|
2923
3331
|
const listen = async () => {
|
|
2924
3332
|
registerCommands(commandMap);
|
|
2925
|
-
await Promise.all([initializeRenderWorker(), initializeQuickPickWorker(), initializeMenuWorker()]);
|
|
3333
|
+
await Promise.all([initializeRenderWorker(), initializeQuickPickWorker(), initializeMenuWorker(), initializeTextMeasurementWorkerRpc()]);
|
|
2926
3334
|
};
|
|
2927
3335
|
|
|
2928
3336
|
const main = async () => {
|