@lvce-editor/activity-bar-worker 4.1.0 → 4.5.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 +243 -135
- package/package.json +1 -1
|
@@ -457,12 +457,12 @@ const getErrorConstructor = (message, type) => {
|
|
|
457
457
|
switch (type) {
|
|
458
458
|
case DomException:
|
|
459
459
|
return DOMException;
|
|
460
|
-
case TypeError$1:
|
|
461
|
-
return TypeError;
|
|
462
|
-
case SyntaxError$1:
|
|
463
|
-
return SyntaxError;
|
|
464
460
|
case ReferenceError$1:
|
|
465
461
|
return ReferenceError;
|
|
462
|
+
case SyntaxError$1:
|
|
463
|
+
return SyntaxError;
|
|
464
|
+
case TypeError$1:
|
|
465
|
+
return TypeError;
|
|
466
466
|
default:
|
|
467
467
|
return Error;
|
|
468
468
|
}
|
|
@@ -618,27 +618,27 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
618
618
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
619
619
|
return {
|
|
620
620
|
code: MethodNotFound,
|
|
621
|
-
|
|
622
|
-
|
|
621
|
+
data: error.stack,
|
|
622
|
+
message: error.message
|
|
623
623
|
};
|
|
624
624
|
}
|
|
625
625
|
return {
|
|
626
626
|
code: Custom,
|
|
627
|
-
message: prettyError.message,
|
|
628
627
|
data: {
|
|
629
|
-
stack: getStack(prettyError),
|
|
630
|
-
codeFrame: prettyError.codeFrame,
|
|
631
|
-
type: getErrorType(prettyError),
|
|
632
628
|
code: prettyError.code,
|
|
633
|
-
|
|
634
|
-
|
|
629
|
+
codeFrame: prettyError.codeFrame,
|
|
630
|
+
name: prettyError.name,
|
|
631
|
+
stack: getStack(prettyError),
|
|
632
|
+
type: getErrorType(prettyError)
|
|
633
|
+
},
|
|
634
|
+
message: prettyError.message
|
|
635
635
|
};
|
|
636
636
|
};
|
|
637
637
|
const create$1$1 = (id, error) => {
|
|
638
638
|
return {
|
|
639
|
-
|
|
639
|
+
error,
|
|
640
640
|
id,
|
|
641
|
-
|
|
641
|
+
jsonrpc: Two$1
|
|
642
642
|
};
|
|
643
643
|
};
|
|
644
644
|
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
@@ -649,8 +649,8 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
649
649
|
};
|
|
650
650
|
const create$7 = (message, result) => {
|
|
651
651
|
return {
|
|
652
|
-
jsonrpc: Two$1,
|
|
653
652
|
id: message.id,
|
|
653
|
+
jsonrpc: Two$1,
|
|
654
654
|
result: result ?? null
|
|
655
655
|
};
|
|
656
656
|
};
|
|
@@ -660,14 +660,14 @@ const getSuccessResponse = (message, result) => {
|
|
|
660
660
|
};
|
|
661
661
|
const getErrorResponseSimple = (id, error) => {
|
|
662
662
|
return {
|
|
663
|
-
jsonrpc: Two$1,
|
|
664
|
-
id,
|
|
665
663
|
error: {
|
|
666
664
|
code: Custom,
|
|
665
|
+
data: error,
|
|
667
666
|
// @ts-ignore
|
|
668
|
-
message: error.message
|
|
669
|
-
|
|
670
|
-
|
|
667
|
+
message: error.message
|
|
668
|
+
},
|
|
669
|
+
id,
|
|
670
|
+
jsonrpc: Two$1
|
|
671
671
|
};
|
|
672
672
|
};
|
|
673
673
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
@@ -697,35 +697,35 @@ const normalizeParams = args => {
|
|
|
697
697
|
if (args.length === 1) {
|
|
698
698
|
const options = args[0];
|
|
699
699
|
return {
|
|
700
|
+
execute: options.execute,
|
|
700
701
|
ipc: options.ipc,
|
|
702
|
+
logError: options.logError || defaultLogError,
|
|
701
703
|
message: options.message,
|
|
702
|
-
execute: options.execute,
|
|
703
|
-
resolve: options.resolve || defaultResolve,
|
|
704
704
|
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
705
|
-
|
|
706
|
-
|
|
705
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
706
|
+
resolve: options.resolve || defaultResolve
|
|
707
707
|
};
|
|
708
708
|
}
|
|
709
709
|
return {
|
|
710
|
+
execute: args[2],
|
|
710
711
|
ipc: args[0],
|
|
712
|
+
logError: args[5],
|
|
711
713
|
message: args[1],
|
|
712
|
-
execute: args[2],
|
|
713
|
-
resolve: args[3],
|
|
714
714
|
preparePrettyError: args[4],
|
|
715
|
-
|
|
716
|
-
|
|
715
|
+
requiresSocket: args[6],
|
|
716
|
+
resolve: args[3]
|
|
717
717
|
};
|
|
718
718
|
};
|
|
719
719
|
const handleJsonRpcMessage = async (...args) => {
|
|
720
720
|
const options = normalizeParams(args);
|
|
721
721
|
const {
|
|
722
|
-
message,
|
|
723
|
-
ipc,
|
|
724
722
|
execute,
|
|
725
|
-
|
|
726
|
-
preparePrettyError,
|
|
723
|
+
ipc,
|
|
727
724
|
logError,
|
|
728
|
-
|
|
725
|
+
message,
|
|
726
|
+
preparePrettyError,
|
|
727
|
+
requiresSocket,
|
|
728
|
+
resolve
|
|
729
729
|
} = options;
|
|
730
730
|
if ('id' in message) {
|
|
731
731
|
if ('method' in message) {
|
|
@@ -786,7 +786,6 @@ const registerPromise = map => {
|
|
|
786
786
|
};
|
|
787
787
|
};
|
|
788
788
|
|
|
789
|
-
// @ts-ignore
|
|
790
789
|
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
791
790
|
const {
|
|
792
791
|
id,
|
|
@@ -879,54 +878,6 @@ const create$3 = async ({
|
|
|
879
878
|
return rpc;
|
|
880
879
|
};
|
|
881
880
|
|
|
882
|
-
const Button$2 = 'button';
|
|
883
|
-
const None$1 = 'none';
|
|
884
|
-
const Tab$1 = 'tab';
|
|
885
|
-
const ToolBar = 'toolbar';
|
|
886
|
-
|
|
887
|
-
const Div = 4;
|
|
888
|
-
const Text = 12;
|
|
889
|
-
const Reference = 100;
|
|
890
|
-
|
|
891
|
-
const Button$1 = 'event.button';
|
|
892
|
-
const ClientX = 'event.clientX';
|
|
893
|
-
const ClientY = 'event.clientY';
|
|
894
|
-
|
|
895
|
-
const Enter = 3;
|
|
896
|
-
const Space = 9;
|
|
897
|
-
const PageUp = 10;
|
|
898
|
-
const PageDown = 11;
|
|
899
|
-
const End = 255;
|
|
900
|
-
const Home = 12;
|
|
901
|
-
const UpArrow = 14;
|
|
902
|
-
const DownArrow = 16;
|
|
903
|
-
|
|
904
|
-
const ActivityBar$3 = 1;
|
|
905
|
-
const Settings$1 = 12;
|
|
906
|
-
const ActivityBarAdditionalViews = 17;
|
|
907
|
-
|
|
908
|
-
const Separator = 1;
|
|
909
|
-
const None = 0;
|
|
910
|
-
const Checked = 2;
|
|
911
|
-
const Unchecked = 3;
|
|
912
|
-
|
|
913
|
-
const LeftClick = 0;
|
|
914
|
-
|
|
915
|
-
const Web = 1;
|
|
916
|
-
|
|
917
|
-
const RendererWorker = 1;
|
|
918
|
-
|
|
919
|
-
const Left = 1;
|
|
920
|
-
const Right = 2;
|
|
921
|
-
|
|
922
|
-
const SetCss = 'Viewlet.setCss';
|
|
923
|
-
const SetDom2 = 'Viewlet.setDom2';
|
|
924
|
-
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
925
|
-
const SetPatches = 'Viewlet.setPatches';
|
|
926
|
-
|
|
927
|
-
const FocusActivityBar = 5;
|
|
928
|
-
const FocusExplorer = 13;
|
|
929
|
-
|
|
930
881
|
const createMockRpc = ({
|
|
931
882
|
commandMap
|
|
932
883
|
}) => {
|
|
@@ -995,6 +946,54 @@ const create$2 = rpcId => {
|
|
|
995
946
|
};
|
|
996
947
|
};
|
|
997
948
|
|
|
949
|
+
const Button$2 = 'button';
|
|
950
|
+
const None$1 = 'none';
|
|
951
|
+
const Tab$1 = 'tab';
|
|
952
|
+
const ToolBar = 'toolbar';
|
|
953
|
+
|
|
954
|
+
const Div = 4;
|
|
955
|
+
const Text = 12;
|
|
956
|
+
const Reference = 100;
|
|
957
|
+
|
|
958
|
+
const Button$1 = 'event.button';
|
|
959
|
+
const ClientX = 'event.clientX';
|
|
960
|
+
const ClientY = 'event.clientY';
|
|
961
|
+
|
|
962
|
+
const Enter = 3;
|
|
963
|
+
const Space = 9;
|
|
964
|
+
const PageUp = 10;
|
|
965
|
+
const PageDown = 11;
|
|
966
|
+
const End = 255;
|
|
967
|
+
const Home = 12;
|
|
968
|
+
const UpArrow = 14;
|
|
969
|
+
const DownArrow = 16;
|
|
970
|
+
|
|
971
|
+
const ActivityBar$3 = 1;
|
|
972
|
+
const Settings$1 = 12;
|
|
973
|
+
const ActivityBarAdditionalViews = 17;
|
|
974
|
+
|
|
975
|
+
const Separator = 1;
|
|
976
|
+
const None = 0;
|
|
977
|
+
const Checked = 2;
|
|
978
|
+
const Unchecked = 3;
|
|
979
|
+
|
|
980
|
+
const LeftClick = 0;
|
|
981
|
+
|
|
982
|
+
const Web = 1;
|
|
983
|
+
|
|
984
|
+
const RendererWorker = 1;
|
|
985
|
+
|
|
986
|
+
const Left = 1;
|
|
987
|
+
const Right = 2;
|
|
988
|
+
|
|
989
|
+
const SetCss = 'Viewlet.setCss';
|
|
990
|
+
const SetDom2 = 'Viewlet.setDom2';
|
|
991
|
+
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
992
|
+
const SetPatches = 'Viewlet.setPatches';
|
|
993
|
+
|
|
994
|
+
const FocusActivityBar = 5;
|
|
995
|
+
const FocusExplorer = 13;
|
|
996
|
+
|
|
998
997
|
const {
|
|
999
998
|
invoke,
|
|
1000
999
|
set: set$1
|
|
@@ -1047,7 +1046,7 @@ const create$1 = () => {
|
|
|
1047
1046
|
},
|
|
1048
1047
|
getKeys() {
|
|
1049
1048
|
return Object.keys(states).map(key => {
|
|
1050
|
-
return Number.
|
|
1049
|
+
return Number.parseFloat(key);
|
|
1051
1050
|
});
|
|
1052
1051
|
},
|
|
1053
1052
|
registerCommands(commandMap) {
|
|
@@ -1089,6 +1088,37 @@ const create$1 = () => {
|
|
|
1089
1088
|
return fn(newState, ...args);
|
|
1090
1089
|
};
|
|
1091
1090
|
return wrapped;
|
|
1091
|
+
},
|
|
1092
|
+
wrapLoadContent(fn) {
|
|
1093
|
+
const wrapped = async (uid, ...args) => {
|
|
1094
|
+
const {
|
|
1095
|
+
newState,
|
|
1096
|
+
oldState
|
|
1097
|
+
} = states[uid];
|
|
1098
|
+
const result = await fn(newState, ...args);
|
|
1099
|
+
const {
|
|
1100
|
+
error,
|
|
1101
|
+
state
|
|
1102
|
+
} = result;
|
|
1103
|
+
if (oldState === state || newState === state) {
|
|
1104
|
+
return {
|
|
1105
|
+
error
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
const latestOld = states[uid];
|
|
1109
|
+
const latestNew = {
|
|
1110
|
+
...latestOld.newState,
|
|
1111
|
+
...state
|
|
1112
|
+
};
|
|
1113
|
+
states[uid] = {
|
|
1114
|
+
newState: latestNew,
|
|
1115
|
+
oldState: latestOld.oldState
|
|
1116
|
+
};
|
|
1117
|
+
return {
|
|
1118
|
+
error
|
|
1119
|
+
};
|
|
1120
|
+
};
|
|
1121
|
+
return wrapped;
|
|
1092
1122
|
}
|
|
1093
1123
|
};
|
|
1094
1124
|
};
|
|
@@ -1128,6 +1158,7 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
1128
1158
|
uid: id,
|
|
1129
1159
|
updateProgress: 0,
|
|
1130
1160
|
updateState: '',
|
|
1161
|
+
userLoginState: 'logged out',
|
|
1131
1162
|
width,
|
|
1132
1163
|
x,
|
|
1133
1164
|
y
|
|
@@ -1145,7 +1176,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1145
1176
|
};
|
|
1146
1177
|
|
|
1147
1178
|
const isEqual = (oldState, newState) => {
|
|
1148
|
-
return oldState.activityBarItems === newState.activityBarItems && oldState.filteredItems === newState.filteredItems && oldState.focusedIndex === newState.focusedIndex && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
|
|
1179
|
+
return oldState.activityBarItems === newState.activityBarItems && oldState.filteredItems === newState.filteredItems && oldState.focusedIndex === newState.focusedIndex && oldState.sideBarLocation === newState.sideBarLocation && oldState.sideBarVisible === newState.sideBarVisible && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
|
|
1149
1180
|
};
|
|
1150
1181
|
|
|
1151
1182
|
const RenderItems = 4;
|
|
@@ -1243,16 +1274,21 @@ const getKeyBindings = () => {
|
|
|
1243
1274
|
};
|
|
1244
1275
|
|
|
1245
1276
|
const getMenuEntriesAccount = state => {
|
|
1277
|
+
const signInLabel = state.userLoginState === 'logging in' ? 'Signing In...' : 'Sign In';
|
|
1278
|
+
const signOutLabel = state.userLoginState === 'logging out' ? 'Signing Out...' : 'Sign Out';
|
|
1279
|
+
if (state.userLoginState === 'logged in' || state.userLoginState === 'logging out') {
|
|
1280
|
+
return [{
|
|
1281
|
+
command: 'ActivityBar.handleClickSignOut',
|
|
1282
|
+
flags: None,
|
|
1283
|
+
id: 'signOut',
|
|
1284
|
+
label: signOutLabel
|
|
1285
|
+
}];
|
|
1286
|
+
}
|
|
1246
1287
|
return [{
|
|
1247
|
-
command: '
|
|
1288
|
+
command: 'ActivityBar.handleClickSignIn',
|
|
1248
1289
|
flags: None,
|
|
1249
1290
|
id: 'signIn',
|
|
1250
|
-
label:
|
|
1251
|
-
}, {
|
|
1252
|
-
command: 'Account.signOut',
|
|
1253
|
-
flags: None,
|
|
1254
|
-
id: 'signOut',
|
|
1255
|
-
label: 'Sign Out'
|
|
1291
|
+
label: signInLabel
|
|
1256
1292
|
}];
|
|
1257
1293
|
};
|
|
1258
1294
|
|
|
@@ -1464,15 +1500,28 @@ const getMenuEntriesSettings = state => {
|
|
|
1464
1500
|
return items;
|
|
1465
1501
|
};
|
|
1466
1502
|
|
|
1467
|
-
|
|
1468
|
-
|
|
1503
|
+
const show2 = async (uid, menuId, x, y, args) => {
|
|
1504
|
+
await showContextMenu2(uid, menuId, x, y, args);
|
|
1505
|
+
};
|
|
1506
|
+
|
|
1507
|
+
const ACCOUNT_MENU_ID = 32_122;
|
|
1508
|
+
const handleClickAccount = async (state, eventX, eventY, viewletId) => {
|
|
1509
|
+
const {
|
|
1510
|
+
uid
|
|
1511
|
+
} = state;
|
|
1512
|
+
await show2(uid, ACCOUNT_MENU_ID, eventX, eventY, {
|
|
1513
|
+
menuId: ACCOUNT_MENU_ID
|
|
1514
|
+
});
|
|
1515
|
+
return state;
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1469
1518
|
const getMenuEntries = (state, options) => {
|
|
1470
1519
|
const {
|
|
1471
1520
|
menuId
|
|
1472
1521
|
} = options;
|
|
1473
1522
|
switch (menuId) {
|
|
1474
|
-
case ACCOUNT_MENU_ID
|
|
1475
|
-
return getMenuEntriesAccount();
|
|
1523
|
+
case ACCOUNT_MENU_ID:
|
|
1524
|
+
return getMenuEntriesAccount(state);
|
|
1476
1525
|
case ActivityBar$3:
|
|
1477
1526
|
return getMenuEntriesActivityBar(state);
|
|
1478
1527
|
case ActivityBarAdditionalViews:
|
|
@@ -1485,7 +1534,7 @@ const getMenuEntries = (state, options) => {
|
|
|
1485
1534
|
};
|
|
1486
1535
|
|
|
1487
1536
|
const getMenuEntryIds = () => {
|
|
1488
|
-
return [ActivityBar$3, ActivityBarAdditionalViews, Settings$1];
|
|
1537
|
+
return [ActivityBar$3, ActivityBarAdditionalViews, Settings$1, ACCOUNT_MENU_ID];
|
|
1489
1538
|
};
|
|
1490
1539
|
|
|
1491
1540
|
const updateItemsWithBadgeCount = async items => {
|
|
@@ -1523,7 +1572,23 @@ const handleBlur = state => {
|
|
|
1523
1572
|
};
|
|
1524
1573
|
};
|
|
1525
1574
|
|
|
1526
|
-
const
|
|
1575
|
+
const isBottomItem = item => {
|
|
1576
|
+
return item.id === 'Account' || item.id === 'Settings';
|
|
1577
|
+
};
|
|
1578
|
+
const getBottomItemCount = items => {
|
|
1579
|
+
if (typeof items === 'number') {
|
|
1580
|
+
return items > 1 ? 1 : 0;
|
|
1581
|
+
}
|
|
1582
|
+
return items.filter(isBottomItem).length;
|
|
1583
|
+
};
|
|
1584
|
+
const getItemCount = items => {
|
|
1585
|
+
if (typeof items === 'number') {
|
|
1586
|
+
return items;
|
|
1587
|
+
}
|
|
1588
|
+
return items.length;
|
|
1589
|
+
};
|
|
1590
|
+
const getIndexFromPosition = (y, eventX, eventY, itemHeight, items, height) => {
|
|
1591
|
+
const itemCount = getItemCount(items);
|
|
1527
1592
|
if (itemCount === 0) {
|
|
1528
1593
|
return -1;
|
|
1529
1594
|
}
|
|
@@ -1536,38 +1601,22 @@ const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount, height)
|
|
|
1536
1601
|
}
|
|
1537
1602
|
return index;
|
|
1538
1603
|
}
|
|
1539
|
-
|
|
1540
|
-
const
|
|
1541
|
-
const
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
return itemCount -
|
|
1604
|
+
const bottomItemCount = getBottomItemCount(items);
|
|
1605
|
+
const bottomItemsHeight = bottomItemCount * itemHeight;
|
|
1606
|
+
const bottomItemsTopY = y + height - bottomItemsHeight;
|
|
1607
|
+
if (bottomItemCount > 0 && eventY >= bottomItemsTopY && eventY < y + height) {
|
|
1608
|
+
const relativeBottomY = eventY - bottomItemsTopY;
|
|
1609
|
+
return itemCount - bottomItemCount + Math.floor(relativeBottomY / itemHeight);
|
|
1545
1610
|
}
|
|
1546
|
-
|
|
1611
|
+
const topItemCount = itemCount - bottomItemCount;
|
|
1547
1612
|
const relativeY = eventY - y;
|
|
1548
1613
|
const index = Math.floor(relativeY / itemHeight);
|
|
1549
|
-
if (index < 0 || index >=
|
|
1614
|
+
if (index < 0 || index >= topItemCount) {
|
|
1550
1615
|
return -1;
|
|
1551
1616
|
}
|
|
1552
1617
|
return index;
|
|
1553
1618
|
};
|
|
1554
1619
|
|
|
1555
|
-
const show2 = async (uid, menuId, x, y, args) => {
|
|
1556
|
-
await showContextMenu2(uid, menuId, x, y, args);
|
|
1557
|
-
};
|
|
1558
|
-
|
|
1559
|
-
// Use a unique number for the Account menu ID
|
|
1560
|
-
const ACCOUNT_MENU_ID = 1000;
|
|
1561
|
-
const handleClickAccount = async (state, eventX, eventY, viewletId) => {
|
|
1562
|
-
const {
|
|
1563
|
-
uid
|
|
1564
|
-
} = state;
|
|
1565
|
-
await show2(uid, ACCOUNT_MENU_ID, eventX, eventY, {
|
|
1566
|
-
menuId: ACCOUNT_MENU_ID
|
|
1567
|
-
});
|
|
1568
|
-
return state;
|
|
1569
|
-
};
|
|
1570
|
-
|
|
1571
1620
|
const handleClickAdditionalViews = async (state, eventX, eventY, viewletId) => {
|
|
1572
1621
|
const {
|
|
1573
1622
|
uid
|
|
@@ -1591,7 +1640,7 @@ const hide = async () => {
|
|
|
1591
1640
|
await invoke('Layout.hideSideBar');
|
|
1592
1641
|
};
|
|
1593
1642
|
|
|
1594
|
-
const handleClickOther = async (state,
|
|
1643
|
+
const handleClickOther = async (state, viewletId) => {
|
|
1595
1644
|
const {
|
|
1596
1645
|
currentViewletId,
|
|
1597
1646
|
sideBarVisible
|
|
@@ -1638,7 +1687,7 @@ const handleClickIndex = async (state, button, index, x, y) => {
|
|
|
1638
1687
|
case 'Settings':
|
|
1639
1688
|
return handleClickSettings(state, x, y);
|
|
1640
1689
|
default:
|
|
1641
|
-
return handleClickOther(state,
|
|
1690
|
+
return handleClickOther(state, viewletId);
|
|
1642
1691
|
}
|
|
1643
1692
|
};
|
|
1644
1693
|
|
|
@@ -1649,10 +1698,18 @@ const handleClick = async (state, button, eventX, eventY) => {
|
|
|
1649
1698
|
itemHeight,
|
|
1650
1699
|
y
|
|
1651
1700
|
} = state;
|
|
1652
|
-
const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems
|
|
1701
|
+
const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems, height);
|
|
1653
1702
|
return handleClickIndex(state, button, index, eventX, eventY);
|
|
1654
1703
|
};
|
|
1655
1704
|
|
|
1705
|
+
const handleClickSignIn = async state => {
|
|
1706
|
+
return state;
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
const handleClickSignOut = async state => {
|
|
1710
|
+
return state;
|
|
1711
|
+
};
|
|
1712
|
+
|
|
1656
1713
|
const handleContextMenu = async (state, button, eventX, eventY) => {
|
|
1657
1714
|
const {
|
|
1658
1715
|
uid
|
|
@@ -1719,6 +1776,15 @@ const handleResize = (state, dimensions) => {
|
|
|
1719
1776
|
};
|
|
1720
1777
|
};
|
|
1721
1778
|
|
|
1779
|
+
const getAccountEnabled = async defaultValue => {
|
|
1780
|
+
try {
|
|
1781
|
+
const value = await invoke('Preferences.get', 'activityBar.accountEnabled');
|
|
1782
|
+
return typeof value === 'boolean' ? value : defaultValue;
|
|
1783
|
+
} catch {
|
|
1784
|
+
return defaultValue;
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1787
|
+
|
|
1722
1788
|
const Explorer = 'Explorer';
|
|
1723
1789
|
const Extensions = 'Extensions';
|
|
1724
1790
|
const RunAndDebug = 'Run And Debug';
|
|
@@ -1729,6 +1795,7 @@ const getActivityBarItems = state => {
|
|
|
1729
1795
|
const {
|
|
1730
1796
|
accountEnabled
|
|
1731
1797
|
} = state;
|
|
1798
|
+
const settingsFlags = Button | Enabled | (accountEnabled ? 0 : MarginTop);
|
|
1732
1799
|
const items = [
|
|
1733
1800
|
// Top
|
|
1734
1801
|
{
|
|
@@ -1774,7 +1841,7 @@ const getActivityBarItems = state => {
|
|
|
1774
1841
|
});
|
|
1775
1842
|
}
|
|
1776
1843
|
items.push({
|
|
1777
|
-
flags:
|
|
1844
|
+
flags: settingsFlags,
|
|
1778
1845
|
icon: SettingsGear,
|
|
1779
1846
|
id: 'Settings',
|
|
1780
1847
|
keyShortcuts: '',
|
|
@@ -1811,27 +1878,39 @@ const handleSettingsChanged = async state => {
|
|
|
1811
1878
|
itemHeight,
|
|
1812
1879
|
selectedIndex
|
|
1813
1880
|
} = state;
|
|
1814
|
-
const
|
|
1881
|
+
const [accountEnabled, sidebarLocation] = await Promise.all([getAccountEnabled(state.accountEnabled), getSideBarPosition()]);
|
|
1882
|
+
const newState = {
|
|
1883
|
+
...state,
|
|
1884
|
+
accountEnabled
|
|
1885
|
+
};
|
|
1886
|
+
const items = getActivityBarItems(newState);
|
|
1815
1887
|
const itemsWithSelected = markSelected(items, selectedIndex);
|
|
1816
1888
|
const filteredItems = getFilteredActivityBarItems(itemsWithSelected, height, itemHeight);
|
|
1817
1889
|
const newItems = await updateItemsWithBadgeCount(filteredItems);
|
|
1818
|
-
const sidebarLocation = await getSideBarPosition();
|
|
1819
1890
|
return {
|
|
1820
|
-
...
|
|
1891
|
+
...newState,
|
|
1821
1892
|
activityBarItems: itemsWithSelected,
|
|
1822
1893
|
filteredItems: newItems,
|
|
1823
1894
|
sideBarLocation: sidebarLocation
|
|
1824
1895
|
};
|
|
1825
1896
|
};
|
|
1826
1897
|
|
|
1898
|
+
const clearItem = item => {
|
|
1899
|
+
const withoutSelected = setFlag(item, Selected, false);
|
|
1900
|
+
return setFlag(withoutSelected, Focused, false);
|
|
1901
|
+
};
|
|
1827
1902
|
const handleSideBarHidden = state => {
|
|
1828
|
-
const
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1903
|
+
const {
|
|
1904
|
+
activityBarItems,
|
|
1905
|
+
height,
|
|
1906
|
+
itemHeight
|
|
1907
|
+
} = state;
|
|
1908
|
+
const itemsCleared = activityBarItems.map(clearItem);
|
|
1909
|
+
const filteredItems = getFilteredActivityBarItems(itemsCleared, height, itemHeight);
|
|
1832
1910
|
return {
|
|
1833
1911
|
...state,
|
|
1834
1912
|
activityBarItems: itemsCleared,
|
|
1913
|
+
filteredItems,
|
|
1835
1914
|
focusedIndex: -1,
|
|
1836
1915
|
selectedIndex: -1,
|
|
1837
1916
|
sideBarVisible: false
|
|
@@ -1928,15 +2007,19 @@ const loadContent = async state => {
|
|
|
1928
2007
|
height,
|
|
1929
2008
|
itemHeight
|
|
1930
2009
|
} = state;
|
|
1931
|
-
const
|
|
1932
|
-
const
|
|
2010
|
+
const [accountEnabled, activeView, sideBarVisible, sidebarLocation] = await Promise.all([getAccountEnabled(state.accountEnabled), getActiveView(), getSideBarVisible(), getSideBarPosition()]);
|
|
2011
|
+
const newState = {
|
|
2012
|
+
...state,
|
|
2013
|
+
accountEnabled
|
|
2014
|
+
};
|
|
2015
|
+
const items = getActivityBarItems(newState);
|
|
1933
2016
|
const index = items.findIndex(item => item.id === activeView);
|
|
1934
2017
|
const selectedIndex = sideBarVisible ? index : -1;
|
|
1935
2018
|
const itemsWithSelected = markSelected(items, selectedIndex);
|
|
1936
2019
|
const filteredItems = getFilteredActivityBarItems(itemsWithSelected, height, itemHeight);
|
|
1937
2020
|
const newItems = await updateItemsWithBadgeCount(filteredItems);
|
|
1938
2021
|
return {
|
|
1939
|
-
...
|
|
2022
|
+
...newState,
|
|
1940
2023
|
activityBarItems: itemsWithSelected,
|
|
1941
2024
|
currentViewletId: Explorer,
|
|
1942
2025
|
filteredItems: newItems,
|
|
@@ -2292,6 +2375,10 @@ const HandleMouseDown = 4;
|
|
|
2292
2375
|
|
|
2293
2376
|
const ActivityBar = 'ActivityBar';
|
|
2294
2377
|
|
|
2378
|
+
const getActivityBarItemHasPopup = item => {
|
|
2379
|
+
return item.id === 'Account' || item.id === 'Settings';
|
|
2380
|
+
};
|
|
2381
|
+
|
|
2295
2382
|
const getAriaSelected = (isTab, isSelected) => {
|
|
2296
2383
|
if (!isTab) {
|
|
2297
2384
|
return undefined;
|
|
@@ -2340,10 +2427,12 @@ const getActivityBarItemInProgressDom = item => {
|
|
|
2340
2427
|
const isFocused = flags & Focused;
|
|
2341
2428
|
const role = isTab ? Tab$1 : Button$2;
|
|
2342
2429
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
2430
|
+
const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
|
|
2343
2431
|
const marginTop = flags & MarginTop;
|
|
2344
2432
|
let className = getClassName(isFocused, marginTop, isSelected);
|
|
2345
2433
|
className += ' ' + ActivityBarItemNested;
|
|
2346
2434
|
return [{
|
|
2435
|
+
ariaHasPopup,
|
|
2347
2436
|
ariaLabel: '',
|
|
2348
2437
|
ariaSelected,
|
|
2349
2438
|
childCount: 2,
|
|
@@ -2375,10 +2464,12 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
2375
2464
|
const isFocused = flags & Focused;
|
|
2376
2465
|
const role = isTab ? Tab$1 : Button$2;
|
|
2377
2466
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
2467
|
+
const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
|
|
2378
2468
|
const marginTop = flags & MarginTop;
|
|
2379
2469
|
let className = getClassName(isFocused, marginTop, isSelected);
|
|
2380
2470
|
className += ' ' + ActivityBarItemNested;
|
|
2381
2471
|
return [{
|
|
2472
|
+
ariaHasPopup,
|
|
2382
2473
|
ariaLabel: '',
|
|
2383
2474
|
ariaSelected,
|
|
2384
2475
|
childCount: 2,
|
|
@@ -2414,6 +2505,7 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
2414
2505
|
icon,
|
|
2415
2506
|
title
|
|
2416
2507
|
} = item;
|
|
2508
|
+
const ariaHasPopup = getActivityBarItemHasPopup(item) || undefined;
|
|
2417
2509
|
const isTab = flags & Tab;
|
|
2418
2510
|
const isSelected = flags & Selected;
|
|
2419
2511
|
const isFocused = flags & Focused;
|
|
@@ -2424,6 +2516,7 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
2424
2516
|
const className = getClassName(isFocused, marginTop, isSelected);
|
|
2425
2517
|
if (isSelected) {
|
|
2426
2518
|
return [{
|
|
2519
|
+
ariaHasPopup,
|
|
2427
2520
|
ariaLabel: '',
|
|
2428
2521
|
ariaSelected,
|
|
2429
2522
|
childCount: 1,
|
|
@@ -2442,6 +2535,7 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
2442
2535
|
return getActivityBarItemWithBadgeDom(item);
|
|
2443
2536
|
}
|
|
2444
2537
|
return [{
|
|
2538
|
+
ariaHasPopup,
|
|
2445
2539
|
ariaLabel: '',
|
|
2446
2540
|
ariaSelected,
|
|
2447
2541
|
childCount: 0,
|
|
@@ -2492,6 +2586,9 @@ const renderIncremental = (oldState, newState) => {
|
|
|
2492
2586
|
const oldDom = renderItems(oldState, oldState)[2];
|
|
2493
2587
|
const newDom = renderItems(newState, newState)[2];
|
|
2494
2588
|
const patches = diffTree(oldDom, newDom);
|
|
2589
|
+
if (patches.length === 0) {
|
|
2590
|
+
return [];
|
|
2591
|
+
}
|
|
2495
2592
|
return [SetPatches, newState.uid, patches];
|
|
2496
2593
|
};
|
|
2497
2594
|
|
|
@@ -2582,6 +2679,13 @@ const setAccountEnabled = (state, enabled) => {
|
|
|
2582
2679
|
};
|
|
2583
2680
|
};
|
|
2584
2681
|
|
|
2682
|
+
const setUserLoginState = (state, userLoginState) => {
|
|
2683
|
+
return {
|
|
2684
|
+
...state,
|
|
2685
|
+
userLoginState
|
|
2686
|
+
};
|
|
2687
|
+
};
|
|
2688
|
+
|
|
2585
2689
|
const toggleActivityBarItem = async (state, itemId) => {
|
|
2586
2690
|
const {
|
|
2587
2691
|
activityBarItems
|
|
@@ -2619,6 +2723,9 @@ const commandMap = {
|
|
|
2619
2723
|
'ActivityBar.handleBlur': wrapCommand(handleBlur),
|
|
2620
2724
|
'ActivityBar.handleClick': wrapCommand(handleClick),
|
|
2621
2725
|
'ActivityBar.handleClickIndex': wrapCommand(handleClickIndex),
|
|
2726
|
+
'ActivityBar.handleClickSettings': wrapCommand(handleClickSettings),
|
|
2727
|
+
'ActivityBar.handleClickSignIn': wrapCommand(handleClickSignIn),
|
|
2728
|
+
'ActivityBar.handleClickSignOut': wrapCommand(handleClickSignOut),
|
|
2622
2729
|
'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
|
|
2623
2730
|
'ActivityBar.handleFocus': wrapCommand(handleFocus),
|
|
2624
2731
|
'ActivityBar.handleSettingsChanged': wrapCommand(handleSettingsChanged),
|
|
@@ -2631,6 +2738,7 @@ const commandMap = {
|
|
|
2631
2738
|
'ActivityBar.resize': wrapCommand(handleResize),
|
|
2632
2739
|
'ActivityBar.saveState': wrapGetter(saveState),
|
|
2633
2740
|
'ActivityBar.setAccountEnabled': wrapCommand(setAccountEnabled),
|
|
2741
|
+
'ActivityBar.setUserLoginState': wrapCommand(setUserLoginState),
|
|
2634
2742
|
'ActivityBar.terminate': terminate,
|
|
2635
2743
|
'ActivityBar.toggleActivityBarItem': wrapCommand(toggleActivityBarItem)
|
|
2636
2744
|
};
|