@lvce-editor/activity-bar-worker 3.3.0 → 4.1.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.
- package/dist/activityBarWorkerMain.js +83 -63
- package/package.json +1 -1
|
@@ -412,6 +412,27 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
412
412
|
wrap: wrap$e
|
|
413
413
|
};
|
|
414
414
|
|
|
415
|
+
class CommandNotFoundError extends Error {
|
|
416
|
+
constructor(command) {
|
|
417
|
+
super(`Command not found ${command}`);
|
|
418
|
+
this.name = 'CommandNotFoundError';
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
const commands = Object.create(null);
|
|
422
|
+
const register = commandMap => {
|
|
423
|
+
Object.assign(commands, commandMap);
|
|
424
|
+
};
|
|
425
|
+
const getCommand = key => {
|
|
426
|
+
return commands[key];
|
|
427
|
+
};
|
|
428
|
+
const execute = (command, ...args) => {
|
|
429
|
+
const fn = getCommand(command);
|
|
430
|
+
if (!fn) {
|
|
431
|
+
throw new CommandNotFoundError(command);
|
|
432
|
+
}
|
|
433
|
+
return fn(...args);
|
|
434
|
+
};
|
|
435
|
+
|
|
415
436
|
const Two$1 = '2.0';
|
|
416
437
|
const callbacks = Object.create(null);
|
|
417
438
|
const get$2 = id => {
|
|
@@ -626,7 +647,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
626
647
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
627
648
|
return create$1$1(id, errorProperty);
|
|
628
649
|
};
|
|
629
|
-
const create$
|
|
650
|
+
const create$7 = (message, result) => {
|
|
630
651
|
return {
|
|
631
652
|
jsonrpc: Two$1,
|
|
632
653
|
id: message.id,
|
|
@@ -635,7 +656,7 @@ const create$3 = (message, result) => {
|
|
|
635
656
|
};
|
|
636
657
|
const getSuccessResponse = (message, result) => {
|
|
637
658
|
const resultProperty = result ?? null;
|
|
638
|
-
return create$
|
|
659
|
+
return create$7(message, resultProperty);
|
|
639
660
|
};
|
|
640
661
|
const getErrorResponseSimple = (id, error) => {
|
|
641
662
|
return {
|
|
@@ -727,36 +748,17 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
727
748
|
throw new JsonRpcError('unexpected message');
|
|
728
749
|
};
|
|
729
750
|
|
|
730
|
-
class CommandNotFoundError extends Error {
|
|
731
|
-
constructor(command) {
|
|
732
|
-
super(`Command not found ${command}`);
|
|
733
|
-
this.name = 'CommandNotFoundError';
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
const commands = Object.create(null);
|
|
737
|
-
const register = commandMap => {
|
|
738
|
-
Object.assign(commands, commandMap);
|
|
739
|
-
};
|
|
740
|
-
const getCommand = key => {
|
|
741
|
-
return commands[key];
|
|
742
|
-
};
|
|
743
|
-
const execute = (command, ...args) => {
|
|
744
|
-
const fn = getCommand(command);
|
|
745
|
-
if (!fn) {
|
|
746
|
-
throw new CommandNotFoundError(command);
|
|
747
|
-
}
|
|
748
|
-
return fn(...args);
|
|
749
|
-
};
|
|
750
|
-
|
|
751
751
|
const Two = '2.0';
|
|
752
|
-
|
|
752
|
+
|
|
753
|
+
const create$6 = (method, params) => {
|
|
753
754
|
return {
|
|
754
755
|
jsonrpc: Two,
|
|
755
756
|
method,
|
|
756
757
|
params
|
|
757
758
|
};
|
|
758
759
|
};
|
|
759
|
-
|
|
760
|
+
|
|
761
|
+
const create$5 = (id, method, params) => {
|
|
760
762
|
const message = {
|
|
761
763
|
id,
|
|
762
764
|
jsonrpc: Two,
|
|
@@ -765,15 +767,14 @@ const create$s = (id, method, params) => {
|
|
|
765
767
|
};
|
|
766
768
|
return message;
|
|
767
769
|
};
|
|
770
|
+
|
|
768
771
|
let id = 0;
|
|
769
|
-
const create$
|
|
772
|
+
const create$4 = () => {
|
|
770
773
|
return ++id;
|
|
771
774
|
};
|
|
772
775
|
|
|
773
|
-
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
774
|
-
|
|
775
776
|
const registerPromise = map => {
|
|
776
|
-
const id = create$
|
|
777
|
+
const id = create$4();
|
|
777
778
|
const {
|
|
778
779
|
promise,
|
|
779
780
|
resolve
|
|
@@ -791,7 +792,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
791
792
|
id,
|
|
792
793
|
promise
|
|
793
794
|
} = registerPromise(callbacks);
|
|
794
|
-
const message = create$
|
|
795
|
+
const message = create$5(id, method, params);
|
|
795
796
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
796
797
|
ipc.sendAndTransfer(message);
|
|
797
798
|
} else {
|
|
@@ -827,12 +828,13 @@ const createRpc = ipc => {
|
|
|
827
828
|
* @deprecated
|
|
828
829
|
*/
|
|
829
830
|
send(method, ...params) {
|
|
830
|
-
const message = create$
|
|
831
|
+
const message = create$6(method, params);
|
|
831
832
|
ipc.send(message);
|
|
832
833
|
}
|
|
833
834
|
};
|
|
834
835
|
return rpc;
|
|
835
836
|
};
|
|
837
|
+
|
|
836
838
|
const requiresSocket = () => {
|
|
837
839
|
return false;
|
|
838
840
|
};
|
|
@@ -847,6 +849,7 @@ const handleMessage = event => {
|
|
|
847
849
|
const actualExecute = event?.target?.execute || execute;
|
|
848
850
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
849
851
|
};
|
|
852
|
+
|
|
850
853
|
const handleIpc = ipc => {
|
|
851
854
|
if ('addEventListener' in ipc) {
|
|
852
855
|
ipc.addEventListener('message', handleMessage);
|
|
@@ -855,6 +858,7 @@ const handleIpc = ipc => {
|
|
|
855
858
|
ipc.on('message', handleMessage);
|
|
856
859
|
}
|
|
857
860
|
};
|
|
861
|
+
|
|
858
862
|
const listen$1 = async (module, options) => {
|
|
859
863
|
const rawIpc = await module.listen(options);
|
|
860
864
|
if (module.signal) {
|
|
@@ -863,7 +867,8 @@ const listen$1 = async (module, options) => {
|
|
|
863
867
|
const ipc = module.wrap(rawIpc);
|
|
864
868
|
return ipc;
|
|
865
869
|
};
|
|
866
|
-
|
|
870
|
+
|
|
871
|
+
const create$3 = async ({
|
|
867
872
|
commandMap
|
|
868
873
|
}) => {
|
|
869
874
|
// TODO create a commandMap per rpc instance
|
|
@@ -873,29 +878,6 @@ const create$2$1 = async ({
|
|
|
873
878
|
const rpc = createRpc(ipc);
|
|
874
879
|
return rpc;
|
|
875
880
|
};
|
|
876
|
-
const WebWorkerRpcClient = {
|
|
877
|
-
__proto__: null,
|
|
878
|
-
create: create$2$1
|
|
879
|
-
};
|
|
880
|
-
const createMockRpc = ({
|
|
881
|
-
commandMap
|
|
882
|
-
}) => {
|
|
883
|
-
const invocations = [];
|
|
884
|
-
const invoke = (method, ...params) => {
|
|
885
|
-
invocations.push([method, ...params]);
|
|
886
|
-
const command = commandMap[method];
|
|
887
|
-
if (!command) {
|
|
888
|
-
throw new Error(`command ${method} not found`);
|
|
889
|
-
}
|
|
890
|
-
return command(...params);
|
|
891
|
-
};
|
|
892
|
-
const mockRpc = {
|
|
893
|
-
invocations,
|
|
894
|
-
invoke,
|
|
895
|
-
invokeAndTransfer: invoke
|
|
896
|
-
};
|
|
897
|
-
return mockRpc;
|
|
898
|
-
};
|
|
899
881
|
|
|
900
882
|
const Button$2 = 'button';
|
|
901
883
|
const None$1 = 'none';
|
|
@@ -945,6 +927,26 @@ const SetPatches = 'Viewlet.setPatches';
|
|
|
945
927
|
const FocusActivityBar = 5;
|
|
946
928
|
const FocusExplorer = 13;
|
|
947
929
|
|
|
930
|
+
const createMockRpc = ({
|
|
931
|
+
commandMap
|
|
932
|
+
}) => {
|
|
933
|
+
const invocations = [];
|
|
934
|
+
const invoke = (method, ...params) => {
|
|
935
|
+
invocations.push([method, ...params]);
|
|
936
|
+
const command = commandMap[method];
|
|
937
|
+
if (!command) {
|
|
938
|
+
throw new Error(`command ${method} not found`);
|
|
939
|
+
}
|
|
940
|
+
return command(...params);
|
|
941
|
+
};
|
|
942
|
+
const mockRpc = {
|
|
943
|
+
invocations,
|
|
944
|
+
invoke,
|
|
945
|
+
invokeAndTransfer: invoke
|
|
946
|
+
};
|
|
947
|
+
return mockRpc;
|
|
948
|
+
};
|
|
949
|
+
|
|
948
950
|
const rpcs = Object.create(null);
|
|
949
951
|
const set$2 = (id, rpc) => {
|
|
950
952
|
rpcs[id] = rpc;
|
|
@@ -1661,6 +1663,13 @@ const handleContextMenu = async (state, button, eventX, eventY) => {
|
|
|
1661
1663
|
return state;
|
|
1662
1664
|
};
|
|
1663
1665
|
|
|
1666
|
+
const handleFocus = state => {
|
|
1667
|
+
return {
|
|
1668
|
+
...state,
|
|
1669
|
+
focused: true
|
|
1670
|
+
};
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1664
1673
|
const Account = 'Account';
|
|
1665
1674
|
const DebugAlt2 = 'DebugAlt2';
|
|
1666
1675
|
const Extensions$1 = 'Extensions';
|
|
@@ -1838,12 +1847,22 @@ const findIndex = (activityBarItems, id) => {
|
|
|
1838
1847
|
return -1;
|
|
1839
1848
|
};
|
|
1840
1849
|
|
|
1841
|
-
const
|
|
1850
|
+
const getSideBarVisible = async () => {
|
|
1851
|
+
try {
|
|
1852
|
+
const visible = await invoke('Layout.getSideBarVisible');
|
|
1853
|
+
return visible;
|
|
1854
|
+
} catch {
|
|
1855
|
+
return true;
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
|
|
1859
|
+
const handleSideBarViewletChange = async (state, id, ...args) => {
|
|
1842
1860
|
const {
|
|
1843
1861
|
activityBarItems,
|
|
1844
1862
|
height,
|
|
1845
1863
|
itemHeight
|
|
1846
1864
|
} = state;
|
|
1865
|
+
const sideBarVisible = await getSideBarVisible();
|
|
1847
1866
|
const index = findIndex(activityBarItems, id);
|
|
1848
1867
|
const newActivityBarItems = markSelected(activityBarItems, index);
|
|
1849
1868
|
const filteredItems = getFilteredActivityBarItems(newActivityBarItems, height, itemHeight);
|
|
@@ -1853,7 +1872,7 @@ const handleSideBarViewletChange = (state, id, ...args) => {
|
|
|
1853
1872
|
currentViewletId: id,
|
|
1854
1873
|
filteredItems,
|
|
1855
1874
|
selectedIndex: index,
|
|
1856
|
-
sideBarVisible
|
|
1875
|
+
sideBarVisible
|
|
1857
1876
|
};
|
|
1858
1877
|
};
|
|
1859
1878
|
|
|
@@ -1910,21 +1929,21 @@ const loadContent = async state => {
|
|
|
1910
1929
|
itemHeight
|
|
1911
1930
|
} = state;
|
|
1912
1931
|
const items = getActivityBarItems(state);
|
|
1913
|
-
const activeView = await getActiveView();
|
|
1932
|
+
const [activeView, sideBarVisible, sidebarLocation] = await Promise.all([getActiveView(), getSideBarVisible(), getSideBarPosition()]);
|
|
1914
1933
|
const index = items.findIndex(item => item.id === activeView);
|
|
1915
|
-
const
|
|
1934
|
+
const selectedIndex = sideBarVisible ? index : -1;
|
|
1935
|
+
const itemsWithSelected = markSelected(items, selectedIndex);
|
|
1916
1936
|
const filteredItems = getFilteredActivityBarItems(itemsWithSelected, height, itemHeight);
|
|
1917
1937
|
const newItems = await updateItemsWithBadgeCount(filteredItems);
|
|
1918
|
-
const sidebarLocation = await getSideBarPosition();
|
|
1919
1938
|
return {
|
|
1920
1939
|
...state,
|
|
1921
1940
|
activityBarItems: itemsWithSelected,
|
|
1922
1941
|
currentViewletId: Explorer,
|
|
1923
1942
|
filteredItems: newItems,
|
|
1924
1943
|
initial: false,
|
|
1925
|
-
selectedIndex
|
|
1944
|
+
selectedIndex,
|
|
1926
1945
|
sideBarLocation: sidebarLocation,
|
|
1927
|
-
sideBarVisible
|
|
1946
|
+
sideBarVisible
|
|
1928
1947
|
};
|
|
1929
1948
|
};
|
|
1930
1949
|
|
|
@@ -2601,6 +2620,7 @@ const commandMap = {
|
|
|
2601
2620
|
'ActivityBar.handleClick': wrapCommand(handleClick),
|
|
2602
2621
|
'ActivityBar.handleClickIndex': wrapCommand(handleClickIndex),
|
|
2603
2622
|
'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
|
|
2623
|
+
'ActivityBar.handleFocus': wrapCommand(handleFocus),
|
|
2604
2624
|
'ActivityBar.handleSettingsChanged': wrapCommand(handleSettingsChanged),
|
|
2605
2625
|
'ActivityBar.handleSideBarHidden': wrapCommand(handleSideBarHidden),
|
|
2606
2626
|
'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
|
|
@@ -2617,7 +2637,7 @@ const commandMap = {
|
|
|
2617
2637
|
|
|
2618
2638
|
const listen = async () => {
|
|
2619
2639
|
registerCommands(commandMap);
|
|
2620
|
-
const rpc = await
|
|
2640
|
+
const rpc = await create$3({
|
|
2621
2641
|
commandMap: commandMap
|
|
2622
2642
|
});
|
|
2623
2643
|
set$1(rpc);
|