@lvce-editor/activity-bar-worker 4.5.0 → 5.0.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 +333 -115
- package/package.json +1 -1
|
@@ -411,6 +411,100 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
411
411
|
listen: listen$6,
|
|
412
412
|
wrap: wrap$e
|
|
413
413
|
};
|
|
414
|
+
const addListener = (emitter, type, callback) => {
|
|
415
|
+
if ('addEventListener' in emitter) {
|
|
416
|
+
emitter.addEventListener(type, callback);
|
|
417
|
+
} else {
|
|
418
|
+
emitter.on(type, callback);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
const removeListener = (emitter, type, callback) => {
|
|
422
|
+
if ('removeEventListener' in emitter) {
|
|
423
|
+
emitter.removeEventListener(type, callback);
|
|
424
|
+
} else {
|
|
425
|
+
emitter.off(type, callback);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
429
|
+
const {
|
|
430
|
+
promise,
|
|
431
|
+
resolve
|
|
432
|
+
} = Promise.withResolvers();
|
|
433
|
+
const listenerMap = Object.create(null);
|
|
434
|
+
const cleanup = value => {
|
|
435
|
+
for (const event of Object.keys(eventMap)) {
|
|
436
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
437
|
+
}
|
|
438
|
+
resolve(value);
|
|
439
|
+
};
|
|
440
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
441
|
+
const listener = event => {
|
|
442
|
+
cleanup({
|
|
443
|
+
event,
|
|
444
|
+
type
|
|
445
|
+
});
|
|
446
|
+
};
|
|
447
|
+
addListener(eventEmitter, event, listener);
|
|
448
|
+
listenerMap[event] = listener;
|
|
449
|
+
}
|
|
450
|
+
return promise;
|
|
451
|
+
};
|
|
452
|
+
const Message$1 = 3;
|
|
453
|
+
const create$5$1 = async ({
|
|
454
|
+
isMessagePortOpen,
|
|
455
|
+
messagePort
|
|
456
|
+
}) => {
|
|
457
|
+
if (!isMessagePort(messagePort)) {
|
|
458
|
+
throw new IpcError('port must be of type MessagePort');
|
|
459
|
+
}
|
|
460
|
+
if (isMessagePortOpen) {
|
|
461
|
+
return messagePort;
|
|
462
|
+
}
|
|
463
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
464
|
+
message: Message$1
|
|
465
|
+
});
|
|
466
|
+
messagePort.start();
|
|
467
|
+
const {
|
|
468
|
+
event,
|
|
469
|
+
type
|
|
470
|
+
} = await eventPromise;
|
|
471
|
+
if (type !== Message$1) {
|
|
472
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
473
|
+
}
|
|
474
|
+
if (event.data !== readyMessage) {
|
|
475
|
+
throw new IpcError('unexpected first message');
|
|
476
|
+
}
|
|
477
|
+
return messagePort;
|
|
478
|
+
};
|
|
479
|
+
const signal$1 = messagePort => {
|
|
480
|
+
messagePort.start();
|
|
481
|
+
};
|
|
482
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
483
|
+
getData = getData$2;
|
|
484
|
+
send(message) {
|
|
485
|
+
this._rawIpc.postMessage(message);
|
|
486
|
+
}
|
|
487
|
+
sendAndTransfer(message) {
|
|
488
|
+
const transfer = getTransferrables(message);
|
|
489
|
+
this._rawIpc.postMessage(message, transfer);
|
|
490
|
+
}
|
|
491
|
+
dispose() {
|
|
492
|
+
this._rawIpc.close();
|
|
493
|
+
}
|
|
494
|
+
onMessage(callback) {
|
|
495
|
+
this._rawIpc.addEventListener('message', callback);
|
|
496
|
+
}
|
|
497
|
+
onClose(callback) {}
|
|
498
|
+
}
|
|
499
|
+
const wrap$5 = messagePort => {
|
|
500
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
501
|
+
};
|
|
502
|
+
const IpcParentWithMessagePort$1 = {
|
|
503
|
+
__proto__: null,
|
|
504
|
+
create: create$5$1,
|
|
505
|
+
signal: signal$1,
|
|
506
|
+
wrap: wrap$5
|
|
507
|
+
};
|
|
414
508
|
|
|
415
509
|
class CommandNotFoundError extends Error {
|
|
416
510
|
constructor(command) {
|
|
@@ -647,7 +741,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
647
741
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
648
742
|
return create$1$1(id, errorProperty);
|
|
649
743
|
};
|
|
650
|
-
const create$
|
|
744
|
+
const create$a = (message, result) => {
|
|
651
745
|
return {
|
|
652
746
|
id: message.id,
|
|
653
747
|
jsonrpc: Two$1,
|
|
@@ -656,7 +750,7 @@ const create$7 = (message, result) => {
|
|
|
656
750
|
};
|
|
657
751
|
const getSuccessResponse = (message, result) => {
|
|
658
752
|
const resultProperty = result ?? null;
|
|
659
|
-
return create$
|
|
753
|
+
return create$a(message, resultProperty);
|
|
660
754
|
};
|
|
661
755
|
const getErrorResponseSimple = (id, error) => {
|
|
662
756
|
return {
|
|
@@ -750,7 +844,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
750
844
|
|
|
751
845
|
const Two = '2.0';
|
|
752
846
|
|
|
753
|
-
const create$
|
|
847
|
+
const create$9 = (method, params) => {
|
|
754
848
|
return {
|
|
755
849
|
jsonrpc: Two,
|
|
756
850
|
method,
|
|
@@ -758,7 +852,7 @@ const create$6 = (method, params) => {
|
|
|
758
852
|
};
|
|
759
853
|
};
|
|
760
854
|
|
|
761
|
-
const create$
|
|
855
|
+
const create$8 = (id, method, params) => {
|
|
762
856
|
const message = {
|
|
763
857
|
id,
|
|
764
858
|
jsonrpc: Two,
|
|
@@ -769,12 +863,12 @@ const create$5 = (id, method, params) => {
|
|
|
769
863
|
};
|
|
770
864
|
|
|
771
865
|
let id = 0;
|
|
772
|
-
const create$
|
|
866
|
+
const create$7 = () => {
|
|
773
867
|
return ++id;
|
|
774
868
|
};
|
|
775
869
|
|
|
776
870
|
const registerPromise = map => {
|
|
777
|
-
const id = create$
|
|
871
|
+
const id = create$7();
|
|
778
872
|
const {
|
|
779
873
|
promise,
|
|
780
874
|
resolve
|
|
@@ -791,7 +885,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
791
885
|
id,
|
|
792
886
|
promise
|
|
793
887
|
} = registerPromise(callbacks);
|
|
794
|
-
const message = create$
|
|
888
|
+
const message = create$8(id, method, params);
|
|
795
889
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
796
890
|
ipc.sendAndTransfer(message);
|
|
797
891
|
} else {
|
|
@@ -827,7 +921,7 @@ const createRpc = ipc => {
|
|
|
827
921
|
* @deprecated
|
|
828
922
|
*/
|
|
829
923
|
send(method, ...params) {
|
|
830
|
-
const message = create$
|
|
924
|
+
const message = create$9(method, params);
|
|
831
925
|
ipc.send(message);
|
|
832
926
|
}
|
|
833
927
|
};
|
|
@@ -867,6 +961,83 @@ const listen$1 = async (module, options) => {
|
|
|
867
961
|
return ipc;
|
|
868
962
|
};
|
|
869
963
|
|
|
964
|
+
const create$6 = async ({
|
|
965
|
+
commandMap,
|
|
966
|
+
isMessagePortOpen = true,
|
|
967
|
+
messagePort
|
|
968
|
+
}) => {
|
|
969
|
+
// TODO create a commandMap per rpc instance
|
|
970
|
+
register(commandMap);
|
|
971
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
972
|
+
isMessagePortOpen,
|
|
973
|
+
messagePort
|
|
974
|
+
});
|
|
975
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
976
|
+
handleIpc(ipc);
|
|
977
|
+
const rpc = createRpc(ipc);
|
|
978
|
+
messagePort.start();
|
|
979
|
+
return rpc;
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
const create$5 = async ({
|
|
983
|
+
commandMap,
|
|
984
|
+
isMessagePortOpen,
|
|
985
|
+
send
|
|
986
|
+
}) => {
|
|
987
|
+
const {
|
|
988
|
+
port1,
|
|
989
|
+
port2
|
|
990
|
+
} = new MessageChannel();
|
|
991
|
+
await send(port1);
|
|
992
|
+
return create$6({
|
|
993
|
+
commandMap,
|
|
994
|
+
isMessagePortOpen,
|
|
995
|
+
messagePort: port2
|
|
996
|
+
});
|
|
997
|
+
};
|
|
998
|
+
|
|
999
|
+
const createSharedLazyRpc = factory => {
|
|
1000
|
+
let rpcPromise;
|
|
1001
|
+
const getOrCreate = () => {
|
|
1002
|
+
if (!rpcPromise) {
|
|
1003
|
+
rpcPromise = factory();
|
|
1004
|
+
}
|
|
1005
|
+
return rpcPromise;
|
|
1006
|
+
};
|
|
1007
|
+
return {
|
|
1008
|
+
async dispose() {
|
|
1009
|
+
const rpc = await getOrCreate();
|
|
1010
|
+
await rpc.dispose();
|
|
1011
|
+
},
|
|
1012
|
+
async invoke(method, ...params) {
|
|
1013
|
+
const rpc = await getOrCreate();
|
|
1014
|
+
return rpc.invoke(method, ...params);
|
|
1015
|
+
},
|
|
1016
|
+
async invokeAndTransfer(method, ...params) {
|
|
1017
|
+
const rpc = await getOrCreate();
|
|
1018
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1019
|
+
},
|
|
1020
|
+
async send(method, ...params) {
|
|
1021
|
+
const rpc = await getOrCreate();
|
|
1022
|
+
rpc.send(method, ...params);
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
};
|
|
1026
|
+
|
|
1027
|
+
const create$4 = async ({
|
|
1028
|
+
commandMap,
|
|
1029
|
+
isMessagePortOpen,
|
|
1030
|
+
send
|
|
1031
|
+
}) => {
|
|
1032
|
+
return createSharedLazyRpc(() => {
|
|
1033
|
+
return create$5({
|
|
1034
|
+
commandMap,
|
|
1035
|
+
isMessagePortOpen,
|
|
1036
|
+
send
|
|
1037
|
+
});
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
|
|
870
1041
|
const create$3 = async ({
|
|
871
1042
|
commandMap
|
|
872
1043
|
}) => {
|
|
@@ -899,7 +1070,7 @@ const createMockRpc = ({
|
|
|
899
1070
|
};
|
|
900
1071
|
|
|
901
1072
|
const rpcs = Object.create(null);
|
|
902
|
-
const set$
|
|
1073
|
+
const set$3 = (id, rpc) => {
|
|
903
1074
|
rpcs[id] = rpc;
|
|
904
1075
|
};
|
|
905
1076
|
const get$1 = id => {
|
|
@@ -932,7 +1103,7 @@ const create$2 = rpcId => {
|
|
|
932
1103
|
const mockRpc = createMockRpc({
|
|
933
1104
|
commandMap
|
|
934
1105
|
});
|
|
935
|
-
set$
|
|
1106
|
+
set$3(rpcId, mockRpc);
|
|
936
1107
|
// @ts-ignore
|
|
937
1108
|
mockRpc[Symbol.dispose] = () => {
|
|
938
1109
|
remove(rpcId);
|
|
@@ -941,11 +1112,16 @@ const create$2 = rpcId => {
|
|
|
941
1112
|
return mockRpc;
|
|
942
1113
|
},
|
|
943
1114
|
set(rpc) {
|
|
944
|
-
set$
|
|
1115
|
+
set$3(rpcId, rpc);
|
|
945
1116
|
}
|
|
946
1117
|
};
|
|
947
1118
|
};
|
|
948
1119
|
|
|
1120
|
+
const {
|
|
1121
|
+
invoke: invoke$1,
|
|
1122
|
+
set: set$2
|
|
1123
|
+
} = create$2(6010);
|
|
1124
|
+
|
|
949
1125
|
const Button$2 = 'button';
|
|
950
1126
|
const None$1 = 'none';
|
|
951
1127
|
const Tab$1 = 'tab';
|
|
@@ -996,6 +1172,7 @@ const FocusExplorer = 13;
|
|
|
996
1172
|
|
|
997
1173
|
const {
|
|
998
1174
|
invoke,
|
|
1175
|
+
invokeAndTransfer,
|
|
999
1176
|
set: set$1
|
|
1000
1177
|
} = create$2(RendererWorker);
|
|
1001
1178
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
@@ -1005,6 +1182,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1005
1182
|
number(y);
|
|
1006
1183
|
await invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1007
1184
|
};
|
|
1185
|
+
const sendMessagePortToAuthWorker = async (port, rpcId) => {
|
|
1186
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1187
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToAuthWorker', port, command, rpcId);
|
|
1188
|
+
};
|
|
1008
1189
|
|
|
1009
1190
|
const toCommandId = key => {
|
|
1010
1191
|
const dotIndex = key.indexOf('.');
|
|
@@ -1628,33 +1809,110 @@ const handleClickAdditionalViews = async (state, eventX, eventY, viewletId) => {
|
|
|
1628
1809
|
return state;
|
|
1629
1810
|
};
|
|
1630
1811
|
|
|
1631
|
-
const
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1812
|
+
const findIndex = (activityBarItems, id) => {
|
|
1813
|
+
for (let i = 0; i < activityBarItems.length; i++) {
|
|
1814
|
+
if (activityBarItems[i].id === id) {
|
|
1815
|
+
return i;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
return -1;
|
|
1819
|
+
};
|
|
1820
|
+
|
|
1821
|
+
const Account = 'Account';
|
|
1822
|
+
const DebugAlt2 = 'DebugAlt2';
|
|
1823
|
+
const Extensions$1 = 'Extensions';
|
|
1824
|
+
const Files = 'Files';
|
|
1825
|
+
const Search$1 = 'Search';
|
|
1826
|
+
const SettingsGear = 'SettingsGear';
|
|
1827
|
+
const SourceControl$1 = 'SourceControl';
|
|
1828
|
+
const Ellipsis = 'Ellipsis';
|
|
1829
|
+
|
|
1830
|
+
const getFilteredActivityBarItems = (items, height, itemHeight) => {
|
|
1831
|
+
const numberOfVisibleItems = getNumberOfVisibleItems({
|
|
1832
|
+
height,
|
|
1833
|
+
itemHeight
|
|
1834
|
+
});
|
|
1835
|
+
if (numberOfVisibleItems >= items.length) {
|
|
1836
|
+
return items;
|
|
1637
1837
|
}
|
|
1838
|
+
const showMoreItem = {
|
|
1839
|
+
flags: Button,
|
|
1840
|
+
icon: Ellipsis,
|
|
1841
|
+
id: 'Additional Views',
|
|
1842
|
+
keyShortcuts: '',
|
|
1843
|
+
title: additionalViews()
|
|
1844
|
+
};
|
|
1845
|
+
return [...items.slice(0, numberOfVisibleItems - 2), showMoreItem, items.at(-1)];
|
|
1638
1846
|
};
|
|
1639
|
-
|
|
1640
|
-
|
|
1847
|
+
|
|
1848
|
+
const setFlag = (item, flag, enabled) => {
|
|
1849
|
+
return {
|
|
1850
|
+
...item,
|
|
1851
|
+
flags: enabled ? item.flags | flag : item.flags & ~flag
|
|
1852
|
+
};
|
|
1641
1853
|
};
|
|
1642
1854
|
|
|
1855
|
+
const markSelected = (items, selectedIndex) => {
|
|
1856
|
+
return items.map((item, index) => {
|
|
1857
|
+
const isSelected = index === selectedIndex;
|
|
1858
|
+
return setFlag(item, Selected, isSelected);
|
|
1859
|
+
});
|
|
1860
|
+
};
|
|
1861
|
+
|
|
1862
|
+
const toggle = async id => {
|
|
1863
|
+
await invoke('SideBar.toggle', id);
|
|
1864
|
+
};
|
|
1865
|
+
|
|
1866
|
+
const getSideBarChange = (sideBarVisible, currentViewletId, viewletId) => {
|
|
1867
|
+
if (sideBarVisible) {
|
|
1868
|
+
if (currentViewletId === viewletId) {
|
|
1869
|
+
return {
|
|
1870
|
+
type: 'hide',
|
|
1871
|
+
viewletId
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
return {
|
|
1875
|
+
type: 'switch',
|
|
1876
|
+
viewletId
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1879
|
+
return {
|
|
1880
|
+
type: 'show',
|
|
1881
|
+
viewletId
|
|
1882
|
+
};
|
|
1883
|
+
};
|
|
1643
1884
|
const handleClickOther = async (state, viewletId) => {
|
|
1644
1885
|
const {
|
|
1886
|
+
activityBarItems,
|
|
1645
1887
|
currentViewletId,
|
|
1888
|
+
height,
|
|
1889
|
+
itemHeight,
|
|
1646
1890
|
sideBarVisible
|
|
1647
1891
|
} = state;
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1892
|
+
const sideBarChange = getSideBarChange(sideBarVisible, currentViewletId, viewletId);
|
|
1893
|
+
await toggle(viewletId);
|
|
1894
|
+
if (sideBarChange.type === 'hide') {
|
|
1895
|
+
const newActivityBarItems = markSelected(activityBarItems, -1);
|
|
1896
|
+
const filteredItems = getFilteredActivityBarItems(newActivityBarItems, height, itemHeight);
|
|
1897
|
+
return {
|
|
1898
|
+
...state,
|
|
1899
|
+
activityBarItems: newActivityBarItems,
|
|
1900
|
+
filteredItems,
|
|
1901
|
+
selectedIndex: -1,
|
|
1902
|
+
sideBarVisible: false
|
|
1903
|
+
};
|
|
1655
1904
|
}
|
|
1656
|
-
|
|
1657
|
-
|
|
1905
|
+
const selectedIndex = findIndex(activityBarItems, viewletId);
|
|
1906
|
+
const newActivityBarItems = markSelected(activityBarItems, selectedIndex);
|
|
1907
|
+
const filteredItems = getFilteredActivityBarItems(newActivityBarItems, height, itemHeight);
|
|
1908
|
+
return {
|
|
1909
|
+
...state,
|
|
1910
|
+
activityBarItems: newActivityBarItems,
|
|
1911
|
+
currentViewletId: viewletId,
|
|
1912
|
+
filteredItems,
|
|
1913
|
+
selectedIndex,
|
|
1914
|
+
sideBarVisible: true
|
|
1915
|
+
};
|
|
1658
1916
|
};
|
|
1659
1917
|
|
|
1660
1918
|
const handleClickSettings = async (state, eventX, eventY, viewletId) => {
|
|
@@ -1703,6 +1961,14 @@ const handleClick = async (state, button, eventX, eventY) => {
|
|
|
1703
1961
|
};
|
|
1704
1962
|
|
|
1705
1963
|
const handleClickSignIn = async state => {
|
|
1964
|
+
const {
|
|
1965
|
+
platform
|
|
1966
|
+
} = state;
|
|
1967
|
+
const backendUrl = await invoke('Layout.getBackendUrl');
|
|
1968
|
+
await invoke$1('Auth.login', {
|
|
1969
|
+
backendUrl,
|
|
1970
|
+
platform
|
|
1971
|
+
});
|
|
1706
1972
|
return state;
|
|
1707
1973
|
};
|
|
1708
1974
|
|
|
@@ -1727,33 +1993,6 @@ const handleFocus = state => {
|
|
|
1727
1993
|
};
|
|
1728
1994
|
};
|
|
1729
1995
|
|
|
1730
|
-
const Account = 'Account';
|
|
1731
|
-
const DebugAlt2 = 'DebugAlt2';
|
|
1732
|
-
const Extensions$1 = 'Extensions';
|
|
1733
|
-
const Files = 'Files';
|
|
1734
|
-
const Search$1 = 'Search';
|
|
1735
|
-
const SettingsGear = 'SettingsGear';
|
|
1736
|
-
const SourceControl$1 = 'SourceControl';
|
|
1737
|
-
const Ellipsis = 'Ellipsis';
|
|
1738
|
-
|
|
1739
|
-
const getFilteredActivityBarItems = (items, height, itemHeight) => {
|
|
1740
|
-
const numberOfVisibleItems = getNumberOfVisibleItems({
|
|
1741
|
-
height,
|
|
1742
|
-
itemHeight
|
|
1743
|
-
});
|
|
1744
|
-
if (numberOfVisibleItems >= items.length) {
|
|
1745
|
-
return items;
|
|
1746
|
-
}
|
|
1747
|
-
const showMoreItem = {
|
|
1748
|
-
flags: Button,
|
|
1749
|
-
icon: Ellipsis,
|
|
1750
|
-
id: 'Additional Views',
|
|
1751
|
-
keyShortcuts: '',
|
|
1752
|
-
title: additionalViews()
|
|
1753
|
-
};
|
|
1754
|
-
return [...items.slice(0, numberOfVisibleItems - 2), showMoreItem, items.at(-1)];
|
|
1755
|
-
};
|
|
1756
|
-
|
|
1757
1996
|
const handleResize = (state, dimensions) => {
|
|
1758
1997
|
const {
|
|
1759
1998
|
activityBarItems,
|
|
@@ -1858,20 +2097,6 @@ const getSideBarPosition = async () => {
|
|
|
1858
2097
|
}
|
|
1859
2098
|
};
|
|
1860
2099
|
|
|
1861
|
-
const setFlag = (item, flag, enabled) => {
|
|
1862
|
-
return {
|
|
1863
|
-
...item,
|
|
1864
|
-
flags: enabled ? item.flags | flag : item.flags & ~flag
|
|
1865
|
-
};
|
|
1866
|
-
};
|
|
1867
|
-
|
|
1868
|
-
const markSelected = (items, selectedIndex) => {
|
|
1869
|
-
return items.map((item, index) => {
|
|
1870
|
-
const isSelected = index === selectedIndex;
|
|
1871
|
-
return setFlag(item, Selected, isSelected);
|
|
1872
|
-
});
|
|
1873
|
-
};
|
|
1874
|
-
|
|
1875
2100
|
const handleSettingsChanged = async state => {
|
|
1876
2101
|
const {
|
|
1877
2102
|
height,
|
|
@@ -1895,37 +2120,6 @@ const handleSettingsChanged = async state => {
|
|
|
1895
2120
|
};
|
|
1896
2121
|
};
|
|
1897
2122
|
|
|
1898
|
-
const clearItem = item => {
|
|
1899
|
-
const withoutSelected = setFlag(item, Selected, false);
|
|
1900
|
-
return setFlag(withoutSelected, Focused, false);
|
|
1901
|
-
};
|
|
1902
|
-
const handleSideBarHidden = state => {
|
|
1903
|
-
const {
|
|
1904
|
-
activityBarItems,
|
|
1905
|
-
height,
|
|
1906
|
-
itemHeight
|
|
1907
|
-
} = state;
|
|
1908
|
-
const itemsCleared = activityBarItems.map(clearItem);
|
|
1909
|
-
const filteredItems = getFilteredActivityBarItems(itemsCleared, height, itemHeight);
|
|
1910
|
-
return {
|
|
1911
|
-
...state,
|
|
1912
|
-
activityBarItems: itemsCleared,
|
|
1913
|
-
filteredItems,
|
|
1914
|
-
focusedIndex: -1,
|
|
1915
|
-
selectedIndex: -1,
|
|
1916
|
-
sideBarVisible: false
|
|
1917
|
-
};
|
|
1918
|
-
};
|
|
1919
|
-
|
|
1920
|
-
const findIndex = (activityBarItems, id) => {
|
|
1921
|
-
for (let i = 0; i < activityBarItems.length; i++) {
|
|
1922
|
-
if (activityBarItems[i].id === id) {
|
|
1923
|
-
return i;
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
return -1;
|
|
1927
|
-
};
|
|
1928
|
-
|
|
1929
2123
|
const getSideBarVisible = async () => {
|
|
1930
2124
|
try {
|
|
1931
2125
|
const visible = await invoke('Layout.getSideBarVisible');
|
|
@@ -1935,22 +2129,38 @@ const getSideBarVisible = async () => {
|
|
|
1935
2129
|
}
|
|
1936
2130
|
};
|
|
1937
2131
|
|
|
1938
|
-
const
|
|
2132
|
+
const clearItem = item => {
|
|
2133
|
+
const withoutSelected = setFlag(item, Selected, false);
|
|
2134
|
+
return setFlag(withoutSelected, Focused, false);
|
|
2135
|
+
};
|
|
2136
|
+
const handleSideBarStateChange = async (state, id = state.currentViewletId, sideBarVisibleOverride) => {
|
|
1939
2137
|
const {
|
|
1940
2138
|
activityBarItems,
|
|
1941
2139
|
height,
|
|
1942
2140
|
itemHeight
|
|
1943
2141
|
} = state;
|
|
1944
|
-
const sideBarVisible = await getSideBarVisible();
|
|
1945
|
-
|
|
1946
|
-
|
|
2142
|
+
const sideBarVisible = typeof sideBarVisibleOverride === 'boolean' ? sideBarVisibleOverride : await getSideBarVisible();
|
|
2143
|
+
if (!sideBarVisible) {
|
|
2144
|
+
const itemsCleared = activityBarItems.map(clearItem);
|
|
2145
|
+
const filteredItems = getFilteredActivityBarItems(itemsCleared, height, itemHeight);
|
|
2146
|
+
return {
|
|
2147
|
+
...state,
|
|
2148
|
+
activityBarItems: itemsCleared,
|
|
2149
|
+
filteredItems,
|
|
2150
|
+
focusedIndex: -1,
|
|
2151
|
+
selectedIndex: -1,
|
|
2152
|
+
sideBarVisible: false
|
|
2153
|
+
};
|
|
2154
|
+
}
|
|
2155
|
+
const selectedIndex = findIndex(activityBarItems, id);
|
|
2156
|
+
const newActivityBarItems = markSelected(activityBarItems, selectedIndex);
|
|
1947
2157
|
const filteredItems = getFilteredActivityBarItems(newActivityBarItems, height, itemHeight);
|
|
1948
2158
|
return {
|
|
1949
2159
|
...state,
|
|
1950
2160
|
activityBarItems: newActivityBarItems,
|
|
1951
2161
|
currentViewletId: id,
|
|
1952
2162
|
filteredItems,
|
|
1953
|
-
selectedIndex
|
|
2163
|
+
selectedIndex,
|
|
1954
2164
|
sideBarVisible
|
|
1955
2165
|
};
|
|
1956
2166
|
};
|
|
@@ -2004,13 +2214,14 @@ const getActiveView = async () => {
|
|
|
2004
2214
|
|
|
2005
2215
|
const loadContent = async state => {
|
|
2006
2216
|
const {
|
|
2217
|
+
accountEnabled,
|
|
2007
2218
|
height,
|
|
2008
2219
|
itemHeight
|
|
2009
2220
|
} = state;
|
|
2010
|
-
const [
|
|
2221
|
+
const [accountEnabledNew, activeView, sideBarVisible, sidebarLocation] = await Promise.all([getAccountEnabled(accountEnabled), getActiveView(), getSideBarVisible(), getSideBarPosition()]);
|
|
2011
2222
|
const newState = {
|
|
2012
2223
|
...state,
|
|
2013
|
-
accountEnabled
|
|
2224
|
+
accountEnabled: accountEnabledNew
|
|
2014
2225
|
};
|
|
2015
2226
|
const items = getActivityBarItems(newState);
|
|
2016
2227
|
const index = items.findIndex(item => item.id === activeView);
|
|
@@ -2651,12 +2862,7 @@ const renderEventListeners = () => {
|
|
|
2651
2862
|
};
|
|
2652
2863
|
|
|
2653
2864
|
const saveState = state => {
|
|
2654
|
-
|
|
2655
|
-
currentViewletId
|
|
2656
|
-
} = state;
|
|
2657
|
-
return {
|
|
2658
|
-
currentViewletId
|
|
2659
|
-
};
|
|
2865
|
+
return {};
|
|
2660
2866
|
};
|
|
2661
2867
|
|
|
2662
2868
|
const setAccountEnabled = (state, enabled) => {
|
|
@@ -2729,8 +2935,7 @@ const commandMap = {
|
|
|
2729
2935
|
'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
|
|
2730
2936
|
'ActivityBar.handleFocus': wrapCommand(handleFocus),
|
|
2731
2937
|
'ActivityBar.handleSettingsChanged': wrapCommand(handleSettingsChanged),
|
|
2732
|
-
'ActivityBar.
|
|
2733
|
-
'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
|
|
2938
|
+
'ActivityBar.handleSideBarStateChange': wrapCommand(handleSideBarStateChange),
|
|
2734
2939
|
'ActivityBar.handleUpdateStateChange': wrapCommand(handleUpdateStateChange),
|
|
2735
2940
|
'ActivityBar.loadContent': wrapCommand(loadContent),
|
|
2736
2941
|
'ActivityBar.render2': render2,
|
|
@@ -2743,12 +2948,25 @@ const commandMap = {
|
|
|
2743
2948
|
'ActivityBar.toggleActivityBarItem': wrapCommand(toggleActivityBarItem)
|
|
2744
2949
|
};
|
|
2745
2950
|
|
|
2951
|
+
const send = async port => {
|
|
2952
|
+
// @ts-ignore
|
|
2953
|
+
await sendMessagePortToAuthWorker(port);
|
|
2954
|
+
};
|
|
2955
|
+
const initializeAuthWorker = async () => {
|
|
2956
|
+
const rpc = await create$4({
|
|
2957
|
+
commandMap: {},
|
|
2958
|
+
send
|
|
2959
|
+
});
|
|
2960
|
+
set$2(rpc);
|
|
2961
|
+
};
|
|
2962
|
+
|
|
2746
2963
|
const listen = async () => {
|
|
2747
2964
|
registerCommands(commandMap);
|
|
2748
2965
|
const rpc = await create$3({
|
|
2749
2966
|
commandMap: commandMap
|
|
2750
2967
|
});
|
|
2751
2968
|
set$1(rpc);
|
|
2969
|
+
await initializeAuthWorker();
|
|
2752
2970
|
};
|
|
2753
2971
|
|
|
2754
2972
|
const main = async () => {
|