@lvce-editor/activity-bar-worker 7.26.0 → 7.27.1
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 +470 -76
- package/dist/settings.json +8 -0
- package/package.json +1 -1
|
@@ -249,7 +249,7 @@ const {
|
|
|
249
249
|
get: get$2,
|
|
250
250
|
getCommandIds,
|
|
251
251
|
registerCommands,
|
|
252
|
-
set: set$
|
|
252
|
+
set: set$6,
|
|
253
253
|
wrapAsyncCommand,
|
|
254
254
|
wrapCommand,
|
|
255
255
|
wrapGetter
|
|
@@ -261,6 +261,7 @@ const create$9 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
261
261
|
accountEnabled: true,
|
|
262
262
|
activityBarItems: [],
|
|
263
263
|
currentViewletId: '',
|
|
264
|
+
dragAndDropEnabled: false,
|
|
264
265
|
filteredItems: [],
|
|
265
266
|
focus: 0,
|
|
266
267
|
focused: false,
|
|
@@ -284,7 +285,7 @@ const create$9 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
284
285
|
x,
|
|
285
286
|
y
|
|
286
287
|
};
|
|
287
|
-
set$
|
|
288
|
+
set$6(id, state, state);
|
|
288
289
|
return state;
|
|
289
290
|
};
|
|
290
291
|
|
|
@@ -297,16 +298,20 @@ const getCustomIconSignature = items => {
|
|
|
297
298
|
}).filter(Boolean).join('\n');
|
|
298
299
|
};
|
|
299
300
|
|
|
300
|
-
const isEqual$
|
|
301
|
+
const isEqual$3 = (oldState, newState) => {
|
|
301
302
|
return oldState.itemHeight === newState.itemHeight && getCustomIconSignature(oldState.filteredItems) === getCustomIconSignature(newState.filteredItems);
|
|
302
303
|
};
|
|
303
304
|
|
|
305
|
+
const isEqual$2 = (oldState, newState) => {
|
|
306
|
+
return oldState.draggedItemId === newState.draggedItemId;
|
|
307
|
+
};
|
|
308
|
+
|
|
304
309
|
const isEqual$1 = (oldState, newState) => {
|
|
305
310
|
return oldState.focused === newState.focused && oldState.focus === newState.focus;
|
|
306
311
|
};
|
|
307
312
|
|
|
308
313
|
const isEqual = (oldState, newState) => {
|
|
309
|
-
return oldState.activityBarItems === newState.activityBarItems && oldState.filteredItems === newState.filteredItems && oldState.focused === newState.focused && oldState.focusedIndex === newState.focusedIndex && oldState.sideBarLocation === newState.sideBarLocation && oldState.sideBarVisible === newState.sideBarVisible && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
|
|
314
|
+
return oldState.activityBarItems === newState.activityBarItems && oldState.dragAndDropEnabled === newState.dragAndDropEnabled && oldState.draggedItemId === newState.draggedItemId && oldState.dropIndicator === newState.dropIndicator && oldState.filteredItems === newState.filteredItems && oldState.focused === newState.focused && oldState.focusedIndex === newState.focusedIndex && oldState.sideBarLocation === newState.sideBarLocation && oldState.sideBarVisible === newState.sideBarVisible && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
|
|
310
315
|
};
|
|
311
316
|
|
|
312
317
|
const RenderItems = 4;
|
|
@@ -314,9 +319,10 @@ const RenderFocus = 6;
|
|
|
314
319
|
const RenderFocusContext = 7;
|
|
315
320
|
const RenderCss = 11;
|
|
316
321
|
const RenderIncremental = 12;
|
|
322
|
+
const RenderDragData = 13;
|
|
317
323
|
|
|
318
|
-
const modules = [isEqual, isEqual$1, isEqual$1, isEqual$2];
|
|
319
|
-
const numbers = [RenderIncremental, RenderFocus, RenderFocusContext, RenderCss];
|
|
324
|
+
const modules = [isEqual, isEqual$1, isEqual$1, isEqual$3, isEqual$2];
|
|
325
|
+
const numbers = [RenderIncremental, RenderFocus, RenderFocusContext, RenderCss, RenderDragData];
|
|
320
326
|
|
|
321
327
|
const diff2 = uid => {
|
|
322
328
|
return diff(uid, modules, numbers);
|
|
@@ -593,6 +599,7 @@ const LeftClick = 0;
|
|
|
593
599
|
|
|
594
600
|
const Electron = 2;
|
|
595
601
|
|
|
602
|
+
const DragAndDropWorker = 3404;
|
|
596
603
|
const ExtensionManagementWorker = 9006;
|
|
597
604
|
const RendererProcess = 1670;
|
|
598
605
|
const RendererWorker = 1;
|
|
@@ -1495,6 +1502,9 @@ const restoreExistingError = (error, currentStack) => {
|
|
|
1495
1502
|
};
|
|
1496
1503
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
1497
1504
|
const restoredError = new JsonRpcError(error.message);
|
|
1505
|
+
Object.assign(restoredError, {
|
|
1506
|
+
code: error.code
|
|
1507
|
+
});
|
|
1498
1508
|
const parentStack = getParentStack(error);
|
|
1499
1509
|
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
1500
1510
|
return restoredError;
|
|
@@ -1514,9 +1524,13 @@ const applyDataProperties = (restoredError, error) => {
|
|
|
1514
1524
|
// @ts-ignore
|
|
1515
1525
|
restoredError.codeFrame = error.data.codeFrame;
|
|
1516
1526
|
}
|
|
1517
|
-
if (error.data.code) {
|
|
1527
|
+
if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
|
|
1518
1528
|
// @ts-ignore
|
|
1519
|
-
restoredError
|
|
1529
|
+
Object.defineProperty(restoredError, 'code', {
|
|
1530
|
+
configurable: true,
|
|
1531
|
+
value: error.data.code,
|
|
1532
|
+
writable: true
|
|
1533
|
+
});
|
|
1520
1534
|
}
|
|
1521
1535
|
if (error.data.type) {
|
|
1522
1536
|
// @ts-ignore
|
|
@@ -1538,6 +1552,13 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
1538
1552
|
};
|
|
1539
1553
|
const restoreMessageError = (error, _currentStack) => {
|
|
1540
1554
|
const restoredError = constructError(error.message, error.type, error.name);
|
|
1555
|
+
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
1556
|
+
Object.defineProperty(restoredError, 'code', {
|
|
1557
|
+
configurable: true,
|
|
1558
|
+
value: error.code,
|
|
1559
|
+
writable: true
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1541
1562
|
if (error.data) {
|
|
1542
1563
|
applyDataProperties(restoredError, error);
|
|
1543
1564
|
} else {
|
|
@@ -1616,7 +1637,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
1616
1637
|
return {
|
|
1617
1638
|
code: Custom,
|
|
1618
1639
|
data: {
|
|
1619
|
-
code: prettyError.code,
|
|
1640
|
+
code: prettyError.code ?? error?.code,
|
|
1620
1641
|
codeFrame: prettyError.codeFrame,
|
|
1621
1642
|
name: prettyError.name,
|
|
1622
1643
|
stack: getStack(prettyError),
|
|
@@ -1653,7 +1674,12 @@ const getErrorResponseSimple = (id, error) => {
|
|
|
1653
1674
|
return {
|
|
1654
1675
|
error: {
|
|
1655
1676
|
code: Custom,
|
|
1656
|
-
data: error
|
|
1677
|
+
data: error instanceof Error ? {
|
|
1678
|
+
...error,
|
|
1679
|
+
code: 'code' in error ? error.code : undefined,
|
|
1680
|
+
stack: error.stack,
|
|
1681
|
+
type: error.name
|
|
1682
|
+
} : error,
|
|
1657
1683
|
// @ts-ignore
|
|
1658
1684
|
message: error.message
|
|
1659
1685
|
},
|
|
@@ -1967,7 +1993,7 @@ const createMockRpc = ({
|
|
|
1967
1993
|
};
|
|
1968
1994
|
|
|
1969
1995
|
const rpcs = Object.create(null);
|
|
1970
|
-
const set$
|
|
1996
|
+
const set$5 = (id, rpc) => {
|
|
1971
1997
|
rpcs[id] = rpc;
|
|
1972
1998
|
};
|
|
1973
1999
|
const get = id => {
|
|
@@ -2000,7 +2026,7 @@ const create = rpcId => {
|
|
|
2000
2026
|
const mockRpc = createMockRpc({
|
|
2001
2027
|
commandMap
|
|
2002
2028
|
});
|
|
2003
|
-
set$
|
|
2029
|
+
set$5(rpcId, mockRpc);
|
|
2004
2030
|
// @ts-ignore
|
|
2005
2031
|
mockRpc[Symbol.dispose] = () => {
|
|
2006
2032
|
remove(rpcId);
|
|
@@ -2009,11 +2035,16 @@ const create = rpcId => {
|
|
|
2009
2035
|
return mockRpc;
|
|
2010
2036
|
},
|
|
2011
2037
|
set(rpc) {
|
|
2012
|
-
set$
|
|
2038
|
+
set$5(rpcId, rpc);
|
|
2013
2039
|
}
|
|
2014
2040
|
};
|
|
2015
2041
|
};
|
|
2016
2042
|
|
|
2043
|
+
const {
|
|
2044
|
+
invoke: invoke$4,
|
|
2045
|
+
set: set$4
|
|
2046
|
+
} = create(DragAndDropWorker);
|
|
2047
|
+
|
|
2017
2048
|
const {
|
|
2018
2049
|
invoke: invoke$3,
|
|
2019
2050
|
set: set$3
|
|
@@ -2021,12 +2052,13 @@ const {
|
|
|
2021
2052
|
|
|
2022
2053
|
const {
|
|
2023
2054
|
invoke: invoke$2,
|
|
2055
|
+
invokeAndTransfer: invokeAndTransfer$2,
|
|
2024
2056
|
set: set$2
|
|
2025
2057
|
} = create(RendererProcess);
|
|
2026
2058
|
|
|
2027
2059
|
const {
|
|
2028
2060
|
invoke: invoke$1,
|
|
2029
|
-
invokeAndTransfer,
|
|
2061
|
+
invokeAndTransfer: invokeAndTransfer$1,
|
|
2030
2062
|
set: set$1
|
|
2031
2063
|
} = create(RendererWorker);
|
|
2032
2064
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
@@ -2038,7 +2070,7 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
2038
2070
|
};
|
|
2039
2071
|
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
2040
2072
|
const command = 'Extensions.handleMessagePort';
|
|
2041
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
2073
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
2042
2074
|
};
|
|
2043
2075
|
|
|
2044
2076
|
const show2 = async (uid, menuId, x, y, args) => {
|
|
@@ -2174,6 +2206,10 @@ const getActiveViewIds = items => {
|
|
|
2174
2206
|
return items.filter(item => item.flags & Selected).map(item => item.id);
|
|
2175
2207
|
};
|
|
2176
2208
|
|
|
2209
|
+
const Default = 0;
|
|
2210
|
+
const Preview = 1;
|
|
2211
|
+
const SideBar = 2;
|
|
2212
|
+
|
|
2177
2213
|
const Account = 'Account';
|
|
2178
2214
|
const DebugAlt2 = 'DebugAlt2';
|
|
2179
2215
|
const Extensions$1 = 'Extensions';
|
|
@@ -2194,10 +2230,17 @@ const getFilteredActivityBarItems = (items, height, itemHeight) => {
|
|
|
2194
2230
|
return enabledItems;
|
|
2195
2231
|
}
|
|
2196
2232
|
const showMoreItem = {
|
|
2233
|
+
badgeIcon: '',
|
|
2234
|
+
badgeText: '',
|
|
2235
|
+
customIconClass: '',
|
|
2236
|
+
customIconUrl: '',
|
|
2237
|
+
enabled: false,
|
|
2197
2238
|
flags: Button,
|
|
2239
|
+
hasPopup: false,
|
|
2198
2240
|
icon: Ellipsis,
|
|
2199
2241
|
id: 'Additional Views',
|
|
2200
2242
|
keyShortcuts: '',
|
|
2243
|
+
preferredLocation: Default,
|
|
2201
2244
|
title: additionalViews()
|
|
2202
2245
|
};
|
|
2203
2246
|
return [...enabledItems.slice(0, numberOfVisibleItems - 2), showMoreItem, enabledItems.at(-1)];
|
|
@@ -2308,14 +2351,14 @@ const handleBlur = state => {
|
|
|
2308
2351
|
};
|
|
2309
2352
|
};
|
|
2310
2353
|
|
|
2311
|
-
const isBottomItem$
|
|
2354
|
+
const isBottomItem$3 = item => {
|
|
2312
2355
|
return item.id === 'Account' || item.id === 'Settings';
|
|
2313
2356
|
};
|
|
2314
2357
|
const getBottomItemCount = items => {
|
|
2315
2358
|
if (typeof items === 'number') {
|
|
2316
2359
|
return items > 1 ? 1 : 0;
|
|
2317
2360
|
}
|
|
2318
|
-
return items.filter(isBottomItem$
|
|
2361
|
+
return items.filter(isBottomItem$3).length;
|
|
2319
2362
|
};
|
|
2320
2363
|
const getItemCount = items => {
|
|
2321
2364
|
if (typeof items === 'number') {
|
|
@@ -2410,7 +2453,7 @@ const handleClickOther = async (state, viewletId) => {
|
|
|
2410
2453
|
const selectedItem = activityBarItems.find(item => item.id === viewletId);
|
|
2411
2454
|
const sideBarChange = getSideBarChange(sideBarVisible, currentViewletId, viewletId);
|
|
2412
2455
|
await toggle(viewletId);
|
|
2413
|
-
if (selectedItem?.preferredLocation ===
|
|
2456
|
+
if (selectedItem?.preferredLocation === Preview) {
|
|
2414
2457
|
const isActive = activeViewIds.includes(viewletId);
|
|
2415
2458
|
const newActiveViewIds = isActive ? activeViewIds.filter(id => id !== viewletId) : [...activeViewIds, viewletId];
|
|
2416
2459
|
const newActivityBarItems = markActiveViews(activityBarItems, newActiveViewIds);
|
|
@@ -2541,6 +2584,163 @@ const handleContextMenu = async (context, button, eventX, eventY) => {
|
|
|
2541
2584
|
});
|
|
2542
2585
|
};
|
|
2543
2586
|
|
|
2587
|
+
const handleDragEnd = state => {
|
|
2588
|
+
const {
|
|
2589
|
+
draggedItemId,
|
|
2590
|
+
dropIndicator
|
|
2591
|
+
} = state;
|
|
2592
|
+
if (!draggedItemId && !dropIndicator) {
|
|
2593
|
+
return state;
|
|
2594
|
+
}
|
|
2595
|
+
return {
|
|
2596
|
+
...state,
|
|
2597
|
+
draggedItemId: undefined,
|
|
2598
|
+
dropIndicator: undefined
|
|
2599
|
+
};
|
|
2600
|
+
};
|
|
2601
|
+
|
|
2602
|
+
const handleDragLeave = state => {
|
|
2603
|
+
const {
|
|
2604
|
+
dropIndicator
|
|
2605
|
+
} = state;
|
|
2606
|
+
if (!dropIndicator) {
|
|
2607
|
+
return state;
|
|
2608
|
+
}
|
|
2609
|
+
return {
|
|
2610
|
+
...state,
|
|
2611
|
+
dropIndicator: undefined
|
|
2612
|
+
};
|
|
2613
|
+
};
|
|
2614
|
+
|
|
2615
|
+
const isMovableActivityBarItem = item => {
|
|
2616
|
+
return Boolean(item && item.flags & Tab && item.id !== 'Additional Views');
|
|
2617
|
+
};
|
|
2618
|
+
|
|
2619
|
+
const isBottomItem$2 = item => item.id === 'Account' || item.id === 'Settings';
|
|
2620
|
+
const getDropIndicator = (state, clientY) => {
|
|
2621
|
+
const {
|
|
2622
|
+
draggedItemId,
|
|
2623
|
+
filteredItems,
|
|
2624
|
+
itemHeight,
|
|
2625
|
+
y
|
|
2626
|
+
} = state;
|
|
2627
|
+
if (!draggedItemId || !isMovableActivityBarItem(filteredItems.find(item => item.id === draggedItemId))) {
|
|
2628
|
+
return undefined;
|
|
2629
|
+
}
|
|
2630
|
+
const topItems = filteredItems.filter(item => !isBottomItem$2(item));
|
|
2631
|
+
for (let index = 0; index < topItems.length; index++) {
|
|
2632
|
+
const item = topItems[index];
|
|
2633
|
+
const itemY = y + index * itemHeight;
|
|
2634
|
+
if (clientY < itemY || clientY >= itemY + itemHeight) {
|
|
2635
|
+
continue;
|
|
2636
|
+
}
|
|
2637
|
+
if (!isMovableActivityBarItem(item)) {
|
|
2638
|
+
return undefined;
|
|
2639
|
+
}
|
|
2640
|
+
if (item.id === draggedItemId) {
|
|
2641
|
+
return undefined;
|
|
2642
|
+
}
|
|
2643
|
+
const position = clientY < itemY + itemHeight / 2 ? 'before' : 'after';
|
|
2644
|
+
const sourceIndex = topItems.findIndex(candidate => candidate.id === draggedItemId);
|
|
2645
|
+
if (position === 'before' && sourceIndex === index - 1 || position === 'after' && sourceIndex === index + 1) {
|
|
2646
|
+
return undefined;
|
|
2647
|
+
}
|
|
2648
|
+
return {
|
|
2649
|
+
id: item.id,
|
|
2650
|
+
position
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
return undefined;
|
|
2654
|
+
};
|
|
2655
|
+
const handleDragOver = (state, clientY) => {
|
|
2656
|
+
const dropIndicator = getDropIndicator(state, clientY);
|
|
2657
|
+
const {
|
|
2658
|
+
dropIndicator: oldIndicator
|
|
2659
|
+
} = state;
|
|
2660
|
+
if (oldIndicator?.id === dropIndicator?.id && oldIndicator?.position === dropIndicator?.position) {
|
|
2661
|
+
return state;
|
|
2662
|
+
}
|
|
2663
|
+
return {
|
|
2664
|
+
...state,
|
|
2665
|
+
dropIndicator
|
|
2666
|
+
};
|
|
2667
|
+
};
|
|
2668
|
+
|
|
2669
|
+
const handleDragStart = (state, id) => {
|
|
2670
|
+
const {
|
|
2671
|
+
dragAndDropEnabled,
|
|
2672
|
+
filteredItems
|
|
2673
|
+
} = state;
|
|
2674
|
+
if (!dragAndDropEnabled || !isMovableActivityBarItem(filteredItems.find(item => item.id === id))) {
|
|
2675
|
+
return state;
|
|
2676
|
+
}
|
|
2677
|
+
return {
|
|
2678
|
+
...state,
|
|
2679
|
+
draggedItemId: id,
|
|
2680
|
+
dropIndicator: undefined
|
|
2681
|
+
};
|
|
2682
|
+
};
|
|
2683
|
+
|
|
2684
|
+
const Type = 'application/x-lvce-editor-activity-bar-item';
|
|
2685
|
+
const getData = id => `${Type}:${id}`;
|
|
2686
|
+
const getId = value => {
|
|
2687
|
+
const prefix = `${Type}:`;
|
|
2688
|
+
return value.startsWith(prefix) ? value.slice(prefix.length) : undefined;
|
|
2689
|
+
};
|
|
2690
|
+
|
|
2691
|
+
const reorderActivityBarItems = (items, draggedItemId, targetId, position) => {
|
|
2692
|
+
const sourceIndex = items.findIndex(item => item.id === draggedItemId);
|
|
2693
|
+
const targetIndex = items.findIndex(item => item.id === targetId);
|
|
2694
|
+
if (sourceIndex === -1 || targetIndex === -1 || sourceIndex === targetIndex || !isMovableActivityBarItem(items[sourceIndex]) || !isMovableActivityBarItem(items[targetIndex])) {
|
|
2695
|
+
return items;
|
|
2696
|
+
}
|
|
2697
|
+
const result = [...items];
|
|
2698
|
+
const [source] = result.splice(sourceIndex, 1);
|
|
2699
|
+
const newTargetIndex = result.findIndex(item => item.id === targetId);
|
|
2700
|
+
const insertionIndex = newTargetIndex + (position === 'after' ? 1 : 0);
|
|
2701
|
+
result.splice(insertionIndex, 0, source);
|
|
2702
|
+
return result;
|
|
2703
|
+
};
|
|
2704
|
+
|
|
2705
|
+
const handleDrop = async (context, dropId) => {
|
|
2706
|
+
const state = context.getState();
|
|
2707
|
+
const {
|
|
2708
|
+
activityBarItems: initialActivityBarItems,
|
|
2709
|
+
dragAndDropEnabled,
|
|
2710
|
+
draggedItemId,
|
|
2711
|
+
dropIndicator,
|
|
2712
|
+
filteredItems: initialFilteredItems,
|
|
2713
|
+
focusedIndex: initialFocusedIndex,
|
|
2714
|
+
height,
|
|
2715
|
+
itemHeight,
|
|
2716
|
+
platform,
|
|
2717
|
+
selectedIndex: initialSelectedIndex
|
|
2718
|
+
} = state;
|
|
2719
|
+
const clearState = handleDragEnd(state);
|
|
2720
|
+
if (!dragAndDropEnabled || !draggedItemId || !dropIndicator) {
|
|
2721
|
+
await context.updateState(() => clearState);
|
|
2722
|
+
return;
|
|
2723
|
+
}
|
|
2724
|
+
const isElectron = platform === Electron;
|
|
2725
|
+
const result = await invoke$4('DragAndDrop.getDroppedItemsByDropId', dropId, isElectron);
|
|
2726
|
+
const values = Array.isArray(result?.strings) ? result.strings : [];
|
|
2727
|
+
if (values.length !== 1 || getId(values[0]) !== draggedItemId) {
|
|
2728
|
+
await context.updateState(() => clearState);
|
|
2729
|
+
return;
|
|
2730
|
+
}
|
|
2731
|
+
const activityBarItems = reorderActivityBarItems(initialActivityBarItems, draggedItemId, dropIndicator.id, dropIndicator.position);
|
|
2732
|
+
const filteredItems = getFilteredActivityBarItems(activityBarItems, height, itemHeight);
|
|
2733
|
+
const selectedId = initialActivityBarItems.find(item => item.flags & Selected)?.id;
|
|
2734
|
+
const focusedId = initialFilteredItems[initialFocusedIndex]?.id;
|
|
2735
|
+
await context.updateState(() => ({
|
|
2736
|
+
...clearState,
|
|
2737
|
+
activityBarItems,
|
|
2738
|
+
filteredItems,
|
|
2739
|
+
focusedIndex: focusedId ? filteredItems.findIndex(item => item.id === focusedId) : initialFocusedIndex,
|
|
2740
|
+
selectedIndex: selectedId ? filteredItems.findIndex(item => item.id === selectedId) : initialSelectedIndex
|
|
2741
|
+
}));
|
|
2742
|
+
};
|
|
2743
|
+
|
|
2544
2744
|
const commandMap$1 = {};
|
|
2545
2745
|
|
|
2546
2746
|
const handleExtensionManagementMessagePort = async port => {
|
|
@@ -2576,27 +2776,36 @@ const Search = 'Search';
|
|
|
2576
2776
|
const SourceControl = 'Source Control';
|
|
2577
2777
|
|
|
2578
2778
|
const toActivityBarItem = view => {
|
|
2779
|
+
const defaultLocation = view.preferredLocation === 'sideBar' ? SideBar : Default;
|
|
2579
2780
|
const icon = view.icon || Extensions$1;
|
|
2580
|
-
const customIconUrl = isCustomIconUrl(icon) ? icon :
|
|
2581
|
-
const customIconClass = customIconUrl ? getCustomIconClass(view.id, customIconUrl) :
|
|
2582
|
-
|
|
2781
|
+
const customIconUrl = isCustomIconUrl(icon) ? icon : '';
|
|
2782
|
+
const customIconClass = customIconUrl ? getCustomIconClass(view.id, customIconUrl) : '';
|
|
2783
|
+
return {
|
|
2784
|
+
badgeIcon: '',
|
|
2785
|
+
badgeText: '',
|
|
2786
|
+
customIconClass,
|
|
2787
|
+
customIconUrl,
|
|
2788
|
+
enabled: false,
|
|
2583
2789
|
flags: Tab | Enabled,
|
|
2790
|
+
hasPopup: false,
|
|
2584
2791
|
icon,
|
|
2585
2792
|
id: view.id,
|
|
2586
2793
|
keyShortcuts: '',
|
|
2587
|
-
|
|
2588
|
-
preferredLocation: 'preview'
|
|
2589
|
-
}),
|
|
2794
|
+
preferredLocation: view.preferredLocation === 'preview' ? Preview : defaultLocation,
|
|
2590
2795
|
title: view.title || view.id
|
|
2591
2796
|
};
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
};
|
|
2797
|
+
};
|
|
2798
|
+
const isBottomItem$1 = item => item.id === 'Account' || item.id === 'Settings';
|
|
2799
|
+
const applyExistingOrder = (items, existingItems) => {
|
|
2800
|
+
if (existingItems.length === 0) {
|
|
2801
|
+
return items;
|
|
2598
2802
|
}
|
|
2599
|
-
|
|
2803
|
+
const itemsById = new Map(items.map(item => [item.id, item]));
|
|
2804
|
+
const orderedTopItems = existingItems.filter(item => !isBottomItem$1(item)).map(item => itemsById.get(item.id)).filter(item => Boolean(item));
|
|
2805
|
+
const orderedTopIds = new Set(orderedTopItems.map(item => item.id));
|
|
2806
|
+
const newTopItems = items.filter(item => !isBottomItem$1(item) && !orderedTopIds.has(item.id));
|
|
2807
|
+
const bottomItems = items.filter(isBottomItem$1);
|
|
2808
|
+
return [...orderedTopItems, ...newTopItems, ...bottomItems];
|
|
2600
2809
|
};
|
|
2601
2810
|
const getActivityBarItems = (state, contributedViews = []) => {
|
|
2602
2811
|
const {
|
|
@@ -2608,61 +2817,117 @@ const getActivityBarItems = (state, contributedViews = []) => {
|
|
|
2608
2817
|
const items = [
|
|
2609
2818
|
// Top
|
|
2610
2819
|
{
|
|
2820
|
+
badgeIcon: '',
|
|
2821
|
+
badgeText: '',
|
|
2822
|
+
customIconClass: '',
|
|
2823
|
+
customIconUrl: '',
|
|
2824
|
+
enabled: false,
|
|
2611
2825
|
flags: Tab | Enabled,
|
|
2826
|
+
hasPopup: false,
|
|
2612
2827
|
icon: Files,
|
|
2613
2828
|
id: Explorer,
|
|
2614
2829
|
keyShortcuts: 'Control+Shift+E',
|
|
2830
|
+
preferredLocation: Default,
|
|
2615
2831
|
title: explorer()
|
|
2616
2832
|
}, {
|
|
2833
|
+
badgeIcon: '',
|
|
2834
|
+
badgeText: '',
|
|
2835
|
+
customIconClass: '',
|
|
2836
|
+
customIconUrl: '',
|
|
2837
|
+
enabled: false,
|
|
2617
2838
|
flags: Tab | Enabled,
|
|
2839
|
+
hasPopup: false,
|
|
2618
2840
|
icon: Search$1,
|
|
2619
2841
|
id: Search,
|
|
2620
2842
|
keyShortcuts: 'Control+Shift+F',
|
|
2843
|
+
preferredLocation: Default,
|
|
2621
2844
|
title: search()
|
|
2622
2845
|
}, {
|
|
2846
|
+
badgeIcon: '',
|
|
2847
|
+
badgeText: '',
|
|
2848
|
+
customIconClass: '',
|
|
2849
|
+
customIconUrl: '',
|
|
2850
|
+
enabled: false,
|
|
2623
2851
|
flags: Tab | Enabled,
|
|
2852
|
+
hasPopup: false,
|
|
2624
2853
|
icon: SourceControl$1,
|
|
2625
2854
|
id: SourceControl,
|
|
2626
2855
|
keyShortcuts: 'Control+Shift+G',
|
|
2856
|
+
preferredLocation: Default,
|
|
2627
2857
|
title: sourceControl()
|
|
2628
2858
|
}, {
|
|
2859
|
+
badgeIcon: '',
|
|
2860
|
+
badgeText: '',
|
|
2861
|
+
customIconClass: '',
|
|
2862
|
+
customIconUrl: '',
|
|
2863
|
+
enabled: false,
|
|
2629
2864
|
flags: Tab | Enabled,
|
|
2865
|
+
hasPopup: false,
|
|
2630
2866
|
icon: DebugAlt2,
|
|
2631
2867
|
id: RunAndDebug,
|
|
2632
2868
|
keyShortcuts: 'Control+Shift+D',
|
|
2869
|
+
preferredLocation: Default,
|
|
2633
2870
|
title: runAndDebug()
|
|
2634
2871
|
}, {
|
|
2872
|
+
badgeIcon: '',
|
|
2873
|
+
badgeText: '',
|
|
2874
|
+
customIconClass: '',
|
|
2875
|
+
customIconUrl: '',
|
|
2876
|
+
enabled: false,
|
|
2635
2877
|
flags: Tab | Enabled,
|
|
2878
|
+
hasPopup: false,
|
|
2636
2879
|
icon: Extensions$1,
|
|
2637
2880
|
id: Extensions,
|
|
2638
2881
|
keyShortcuts: 'Control+Shift+X',
|
|
2882
|
+
preferredLocation: Default,
|
|
2639
2883
|
title: extensions()
|
|
2640
2884
|
}, {
|
|
2885
|
+
badgeIcon: '',
|
|
2886
|
+
badgeText: '',
|
|
2887
|
+
customIconClass: '',
|
|
2888
|
+
customIconUrl: '',
|
|
2889
|
+
enabled: false,
|
|
2641
2890
|
flags: Tab | (referencesEnabled ? Enabled : 0),
|
|
2891
|
+
hasPopup: false,
|
|
2642
2892
|
icon: References$1,
|
|
2643
2893
|
id: References,
|
|
2644
2894
|
keyShortcuts: '',
|
|
2895
|
+
preferredLocation: Default,
|
|
2645
2896
|
title: references()
|
|
2646
2897
|
}, ...contributedViews.map(toActivityBarItem)
|
|
2647
2898
|
// Bottom
|
|
2648
2899
|
];
|
|
2649
2900
|
if (accountEnabled) {
|
|
2650
2901
|
items.push({
|
|
2902
|
+
badgeIcon: '',
|
|
2903
|
+
badgeText: '',
|
|
2904
|
+
customIconClass: '',
|
|
2905
|
+
customIconUrl: '',
|
|
2906
|
+
enabled: false,
|
|
2651
2907
|
flags: Button | Enabled | MarginTop,
|
|
2908
|
+
hasPopup: true,
|
|
2652
2909
|
icon: Account,
|
|
2653
2910
|
id: 'Account',
|
|
2654
2911
|
keyShortcuts: '',
|
|
2912
|
+
preferredLocation: Default,
|
|
2655
2913
|
title: account()
|
|
2656
2914
|
});
|
|
2657
2915
|
}
|
|
2658
2916
|
items.push({
|
|
2917
|
+
badgeIcon: '',
|
|
2918
|
+
badgeText: '',
|
|
2919
|
+
customIconClass: '',
|
|
2920
|
+
customIconUrl: '',
|
|
2921
|
+
enabled: false,
|
|
2659
2922
|
flags: settingsFlags,
|
|
2923
|
+
hasPopup: true,
|
|
2660
2924
|
icon: SettingsGear,
|
|
2661
2925
|
id: 'Settings',
|
|
2662
2926
|
keyShortcuts: '',
|
|
2927
|
+
preferredLocation: Default,
|
|
2663
2928
|
title: settings()
|
|
2664
2929
|
});
|
|
2665
|
-
return items;
|
|
2930
|
+
return applyExistingOrder(items, activityBarItems);
|
|
2666
2931
|
};
|
|
2667
2932
|
|
|
2668
2933
|
const getContributedViews = async platform => {
|
|
@@ -2743,6 +3008,9 @@ const isConnected = () => {
|
|
|
2743
3008
|
const invoke = (method, ...params) => {
|
|
2744
3009
|
return invoke$2(method, ...params);
|
|
2745
3010
|
};
|
|
3011
|
+
const invokeAndTransfer = (method, ...params) => {
|
|
3012
|
+
return invokeAndTransfer$2(method, ...params);
|
|
3013
|
+
};
|
|
2746
3014
|
const set = rpc => {
|
|
2747
3015
|
set$2(rpc);
|
|
2748
3016
|
state.connected = true;
|
|
@@ -2799,17 +3067,28 @@ const getAccountEnabled = async defaultValue => {
|
|
|
2799
3067
|
}
|
|
2800
3068
|
};
|
|
2801
3069
|
|
|
3070
|
+
const getDragAndDropEnabled = async defaultValue => {
|
|
3071
|
+
try {
|
|
3072
|
+
const value = await invoke$1('Preferences.get', 'activityBar.dragAndDropEnabled');
|
|
3073
|
+
return typeof value === 'boolean' ? value : defaultValue;
|
|
3074
|
+
} catch {
|
|
3075
|
+
return defaultValue;
|
|
3076
|
+
}
|
|
3077
|
+
};
|
|
3078
|
+
|
|
2802
3079
|
const handleSettingsChanged = async state => {
|
|
2803
3080
|
const {
|
|
2804
3081
|
accountEnabled: currentAccountEnabled,
|
|
3082
|
+
dragAndDropEnabled: currentDragAndDropEnabled,
|
|
2805
3083
|
height,
|
|
2806
3084
|
itemHeight,
|
|
2807
3085
|
platform
|
|
2808
3086
|
} = state;
|
|
2809
|
-
const [accountEnabled, contributedViews, sidebarLocation] = await Promise.all([getAccountEnabled(currentAccountEnabled), getContributedViews(platform), getSideBarPosition()]);
|
|
3087
|
+
const [accountEnabled, dragAndDropEnabled, contributedViews, sidebarLocation] = await Promise.all([getAccountEnabled(currentAccountEnabled), getDragAndDropEnabled(Boolean(currentDragAndDropEnabled)), getContributedViews(platform), getSideBarPosition()]);
|
|
2810
3088
|
const newState = {
|
|
2811
3089
|
...state,
|
|
2812
|
-
accountEnabled
|
|
3090
|
+
accountEnabled,
|
|
3091
|
+
dragAndDropEnabled
|
|
2813
3092
|
};
|
|
2814
3093
|
const items = getActivityBarItems(newState, contributedViews);
|
|
2815
3094
|
const activeViewIds = resolveActiveViewIds(state, items);
|
|
@@ -2930,11 +3209,12 @@ const getActiveView = async () => {
|
|
|
2930
3209
|
};
|
|
2931
3210
|
|
|
2932
3211
|
const loadPreferences = async (accountEnabled, platform) => {
|
|
2933
|
-
const [accountEnabledNew, activeView, contributedViews, sidebarLocation, sideBarVisible] = await Promise.all([getAccountEnabled(accountEnabled), getActiveView(), getContributedViews(platform), getSideBarPosition(), getSideBarVisible()]);
|
|
3212
|
+
const [accountEnabledNew, dragAndDropEnabled, activeView, contributedViews, sidebarLocation, sideBarVisible] = await Promise.all([getAccountEnabled(accountEnabled), getDragAndDropEnabled(false), getActiveView(), getContributedViews(platform), getSideBarPosition(), getSideBarVisible()]);
|
|
2934
3213
|
return {
|
|
2935
3214
|
accountEnabled: accountEnabledNew,
|
|
2936
3215
|
activeView,
|
|
2937
3216
|
contributedViews,
|
|
3217
|
+
dragAndDropEnabled,
|
|
2938
3218
|
sidebarLocation,
|
|
2939
3219
|
sideBarVisible
|
|
2940
3220
|
};
|
|
@@ -2977,28 +3257,39 @@ const loadContent = async state => {
|
|
|
2977
3257
|
};
|
|
2978
3258
|
};
|
|
2979
3259
|
|
|
2980
|
-
const
|
|
2981
|
-
return url.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', '\\a ').replaceAll('\r', '\\d ').replaceAll('\f', '\\c ');
|
|
2982
|
-
};
|
|
2983
|
-
|
|
2984
|
-
const getCustomIconCss = items => {
|
|
3260
|
+
const getCustomIconItems = items => {
|
|
2985
3261
|
const seen = new Set();
|
|
2986
|
-
|
|
2987
|
-
for (const item of items) {
|
|
3262
|
+
return items.filter(item => {
|
|
2988
3263
|
const {
|
|
2989
3264
|
customIconClass,
|
|
2990
3265
|
customIconUrl
|
|
2991
3266
|
} = item;
|
|
2992
3267
|
if (!customIconClass || !customIconUrl || seen.has(customIconClass)) {
|
|
2993
|
-
|
|
3268
|
+
return false;
|
|
2994
3269
|
}
|
|
2995
3270
|
seen.add(customIconClass);
|
|
2996
|
-
|
|
3271
|
+
return true;
|
|
3272
|
+
});
|
|
3273
|
+
};
|
|
3274
|
+
|
|
3275
|
+
const escapeCssUrl = url => {
|
|
3276
|
+
return url.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', '\\a ').replaceAll('\r', '\\d ').replaceAll('\f', '\\c ');
|
|
3277
|
+
};
|
|
3278
|
+
|
|
3279
|
+
const getCustomIconRule = item => {
|
|
3280
|
+
const {
|
|
3281
|
+
customIconClass,
|
|
3282
|
+
customIconUrl
|
|
3283
|
+
} = item;
|
|
3284
|
+
return `.${customIconClass} {
|
|
2997
3285
|
mask-image: url("${escapeCssUrl(customIconUrl)}");
|
|
2998
|
-
}
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3286
|
+
}`;
|
|
3287
|
+
};
|
|
3288
|
+
|
|
3289
|
+
const getCustomIconCss = items => {
|
|
3290
|
+
const customIconItems = getCustomIconItems(items);
|
|
3291
|
+
const cssRules = customIconItems.map(getCustomIconRule);
|
|
3292
|
+
return cssRules.join('\n');
|
|
3002
3293
|
};
|
|
3003
3294
|
|
|
3004
3295
|
const getCss = (itemHeight, items = []) => {
|
|
@@ -3018,6 +3309,25 @@ const renderCss = (oldState, newState) => {
|
|
|
3018
3309
|
return [SetCss, uid, css];
|
|
3019
3310
|
};
|
|
3020
3311
|
|
|
3312
|
+
const renderDragData = (_oldState, newState) => {
|
|
3313
|
+
const {
|
|
3314
|
+
draggedItemId,
|
|
3315
|
+
filteredItems,
|
|
3316
|
+
uid
|
|
3317
|
+
} = newState;
|
|
3318
|
+
const item = filteredItems.find(candidate => candidate.id === draggedItemId);
|
|
3319
|
+
if (!draggedItemId || !item) {
|
|
3320
|
+
return [];
|
|
3321
|
+
}
|
|
3322
|
+
return ['Viewlet.setDragData', uid, {
|
|
3323
|
+
items: [{
|
|
3324
|
+
data: getData(draggedItemId),
|
|
3325
|
+
type: Type
|
|
3326
|
+
}],
|
|
3327
|
+
label: item.title
|
|
3328
|
+
}];
|
|
3329
|
+
};
|
|
3330
|
+
|
|
3021
3331
|
const ActivityBar$1 = 'ActivityBar';
|
|
3022
3332
|
|
|
3023
3333
|
const renderFocus = (oldState, newState) => {
|
|
@@ -3325,9 +3635,14 @@ const HandleBlur = 1;
|
|
|
3325
3635
|
const HandleContextMenu = 2;
|
|
3326
3636
|
const HandleFocus = 3;
|
|
3327
3637
|
const HandleMouseDown = 4;
|
|
3638
|
+
const HandleDragOver = 5;
|
|
3639
|
+
const HandleDragLeave = 6;
|
|
3640
|
+
const HandleDrop = 7;
|
|
3641
|
+
const HandleDragStart = 8;
|
|
3642
|
+
const HandleDragEnd = 9;
|
|
3328
3643
|
|
|
3329
3644
|
const getActivityBarItemHasPopup = item => {
|
|
3330
|
-
return item.
|
|
3645
|
+
return item.hasPopup;
|
|
3331
3646
|
};
|
|
3332
3647
|
|
|
3333
3648
|
const getAriaSelected = (isTab, isSelected) => {
|
|
@@ -3455,7 +3770,13 @@ const getIconVirtualDom = (icon, type = Div, customIconClass = '') => {
|
|
|
3455
3770
|
};
|
|
3456
3771
|
};
|
|
3457
3772
|
|
|
3458
|
-
const
|
|
3773
|
+
const getDropIndicatorStyle = (dropIndicator, id) => {
|
|
3774
|
+
if (!dropIndicator || dropIndicator.id !== id) {
|
|
3775
|
+
return undefined;
|
|
3776
|
+
}
|
|
3777
|
+
return dropIndicator.position === 'before' ? 'box-shadow:inset 0 2px 0 white;' : 'box-shadow:inset 0 -2px 0 white;';
|
|
3778
|
+
};
|
|
3779
|
+
const getActivityBarItemVirtualDom = (item, draggable = false, dropIndicator) => {
|
|
3459
3780
|
const {
|
|
3460
3781
|
badgeText,
|
|
3461
3782
|
flags,
|
|
@@ -3472,8 +3793,9 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
3472
3793
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
3473
3794
|
const marginTop = flags & MarginTop;
|
|
3474
3795
|
const className = getClassName(isFocused, marginTop, isSelected);
|
|
3796
|
+
let dom;
|
|
3475
3797
|
if (isSelected && !badgeText) {
|
|
3476
|
-
|
|
3798
|
+
dom = [{
|
|
3477
3799
|
ariaHasPopup,
|
|
3478
3800
|
ariaSelected,
|
|
3479
3801
|
childCount: 1,
|
|
@@ -3486,36 +3808,47 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
3486
3808
|
...getIconVirtualDom(icon, Div, item.customIconClass),
|
|
3487
3809
|
name: id
|
|
3488
3810
|
}];
|
|
3811
|
+
} else if (isProgress) {
|
|
3812
|
+
dom = getActivityBarItemInProgressDom(item);
|
|
3813
|
+
} else if (badgeText) {
|
|
3814
|
+
dom = getActivityBarItemWithBadgeDom(item);
|
|
3815
|
+
} else {
|
|
3816
|
+
dom = [{
|
|
3817
|
+
ariaHasPopup,
|
|
3818
|
+
ariaSelected,
|
|
3819
|
+
childCount: 0,
|
|
3820
|
+
className: mergeClassNames(className, getIconClass(item, 'Icon')),
|
|
3821
|
+
name: id,
|
|
3822
|
+
role,
|
|
3823
|
+
title,
|
|
3824
|
+
type: Div
|
|
3825
|
+
}];
|
|
3489
3826
|
}
|
|
3490
|
-
|
|
3491
|
-
// TODO support progress on selected activity bar item
|
|
3492
|
-
if (isProgress) {
|
|
3493
|
-
return getActivityBarItemInProgressDom(item);
|
|
3494
|
-
}
|
|
3495
|
-
if (badgeText) {
|
|
3496
|
-
return getActivityBarItemWithBadgeDom(item);
|
|
3497
|
-
}
|
|
3827
|
+
const [root, ...children] = dom;
|
|
3498
3828
|
return [{
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3829
|
+
...root,
|
|
3830
|
+
...(draggable && {
|
|
3831
|
+
draggable: true
|
|
3832
|
+
}),
|
|
3833
|
+
...(draggable && {
|
|
3834
|
+
onDragEnd: HandleDragEnd,
|
|
3835
|
+
onDragStart: HandleDragStart
|
|
3836
|
+
}),
|
|
3837
|
+
...(getDropIndicatorStyle(dropIndicator, id) && {
|
|
3838
|
+
style: getDropIndicatorStyle(dropIndicator, id)
|
|
3839
|
+
})
|
|
3840
|
+
}, ...children];
|
|
3508
3841
|
};
|
|
3509
3842
|
|
|
3510
|
-
const getVirtualDom = visibleItems => {
|
|
3511
|
-
const dom = visibleItems.flatMap(getActivityBarItemVirtualDom);
|
|
3843
|
+
const getVirtualDom = (visibleItems, dragAndDropEnabled = false, dropIndicator) => {
|
|
3844
|
+
const dom = visibleItems.flatMap(item => getActivityBarItemVirtualDom(item, dragAndDropEnabled && isMovableActivityBarItem(item), dropIndicator));
|
|
3512
3845
|
return dom;
|
|
3513
3846
|
};
|
|
3514
3847
|
|
|
3515
3848
|
const Focusable = 0;
|
|
3516
3849
|
|
|
3517
3850
|
const className = mergeClassNames(Viewlet, ActivityBar);
|
|
3518
|
-
const getActivityBarVirtualDom = visibleItems => {
|
|
3851
|
+
const getActivityBarVirtualDom = (visibleItems, dragAndDropEnabled = false, dropIndicator) => {
|
|
3519
3852
|
return [{
|
|
3520
3853
|
ariaOrientation: Vertical,
|
|
3521
3854
|
ariaRoleDescription: activityBar(),
|
|
@@ -3524,12 +3857,15 @@ const getActivityBarVirtualDom = visibleItems => {
|
|
|
3524
3857
|
id: ActivityBar$1,
|
|
3525
3858
|
onBlur: HandleBlur,
|
|
3526
3859
|
onContextMenu: HandleContextMenu,
|
|
3860
|
+
onDragLeave: HandleDragLeave,
|
|
3861
|
+
onDragOver: HandleDragOver,
|
|
3862
|
+
onDrop: HandleDrop,
|
|
3527
3863
|
onFocus: HandleFocus,
|
|
3528
3864
|
onMouseDown: HandleMouseDown,
|
|
3529
3865
|
role: ToolBar,
|
|
3530
3866
|
tabIndex: Focusable,
|
|
3531
3867
|
type: Div
|
|
3532
|
-
}, ...getVirtualDom(visibleItems)];
|
|
3868
|
+
}, ...getVirtualDom(visibleItems, dragAndDropEnabled, dropIndicator)];
|
|
3533
3869
|
};
|
|
3534
3870
|
|
|
3535
3871
|
const getVisibleActivityBarItems = (items, focusedIndex) => {
|
|
@@ -3538,6 +3874,8 @@ const getVisibleActivityBarItems = (items, focusedIndex) => {
|
|
|
3538
3874
|
|
|
3539
3875
|
const renderItems = (oldState, newState) => {
|
|
3540
3876
|
const {
|
|
3877
|
+
dragAndDropEnabled,
|
|
3878
|
+
dropIndicator,
|
|
3541
3879
|
filteredItems,
|
|
3542
3880
|
focused,
|
|
3543
3881
|
focusedIndex,
|
|
@@ -3548,7 +3886,7 @@ const renderItems = (oldState, newState) => {
|
|
|
3548
3886
|
return [SetDom2, uid, []];
|
|
3549
3887
|
}
|
|
3550
3888
|
const visibleItems = getVisibleActivityBarItems(filteredItems, focused ? focusedIndex : -1);
|
|
3551
|
-
const dom = getActivityBarVirtualDom(visibleItems);
|
|
3889
|
+
const dom = getActivityBarVirtualDom(visibleItems, Boolean(dragAndDropEnabled), dropIndicator);
|
|
3552
3890
|
return [SetDom2, uid, dom];
|
|
3553
3891
|
};
|
|
3554
3892
|
|
|
@@ -3566,6 +3904,8 @@ const getRenderer = diffType => {
|
|
|
3566
3904
|
switch (diffType) {
|
|
3567
3905
|
case RenderCss:
|
|
3568
3906
|
return renderCss;
|
|
3907
|
+
case RenderDragData:
|
|
3908
|
+
return renderDragData;
|
|
3569
3909
|
case RenderFocus:
|
|
3570
3910
|
return renderFocus;
|
|
3571
3911
|
case RenderFocusContext:
|
|
@@ -3602,7 +3942,7 @@ const render2 = (uid, diffResult) => {
|
|
|
3602
3942
|
newState,
|
|
3603
3943
|
oldState
|
|
3604
3944
|
} = get$2(uid);
|
|
3605
|
-
set$
|
|
3945
|
+
set$6(uid, newState, newState);
|
|
3606
3946
|
const commands = applyRender(oldState, newState, diffResult);
|
|
3607
3947
|
if (!isConnected()) {
|
|
3608
3948
|
return commands;
|
|
@@ -3611,6 +3951,7 @@ const render2 = (uid, diffResult) => {
|
|
|
3611
3951
|
};
|
|
3612
3952
|
|
|
3613
3953
|
const renderEventListeners = () => {
|
|
3954
|
+
const DropId = 'event.dropId';
|
|
3614
3955
|
return [{
|
|
3615
3956
|
name: HandleBlur,
|
|
3616
3957
|
params: ['handleBlur']
|
|
@@ -3626,6 +3967,25 @@ const renderEventListeners = () => {
|
|
|
3626
3967
|
params: ['handleClick', Button$1, ClientX, ClientY, TargetName],
|
|
3627
3968
|
preventDefault: false,
|
|
3628
3969
|
stopPropagation: false
|
|
3970
|
+
}, {
|
|
3971
|
+
name: HandleDragOver,
|
|
3972
|
+
params: ['handleDragOver', ClientY],
|
|
3973
|
+
preventDefault: true
|
|
3974
|
+
}, {
|
|
3975
|
+
name: HandleDragLeave,
|
|
3976
|
+
params: ['handleDragLeave']
|
|
3977
|
+
}, {
|
|
3978
|
+
name: HandleDrop,
|
|
3979
|
+
params: ['handleDrop', DropId],
|
|
3980
|
+
preventDefault: true
|
|
3981
|
+
}, {
|
|
3982
|
+
// @ts-ignore
|
|
3983
|
+
dragEffect: 'move',
|
|
3984
|
+
name: HandleDragStart,
|
|
3985
|
+
params: ['handleDragStart', TargetName]
|
|
3986
|
+
}, {
|
|
3987
|
+
name: HandleDragEnd,
|
|
3988
|
+
params: ['handleDragEnd']
|
|
3629
3989
|
}];
|
|
3630
3990
|
};
|
|
3631
3991
|
|
|
@@ -3633,6 +3993,7 @@ const createDefaultState = () => ({
|
|
|
3633
3993
|
accountEnabled: true,
|
|
3634
3994
|
activityBarItems: [],
|
|
3635
3995
|
currentViewletId: '',
|
|
3996
|
+
dragAndDropEnabled: false,
|
|
3636
3997
|
filteredItems: [],
|
|
3637
3998
|
focus: 0,
|
|
3638
3999
|
focused: false,
|
|
@@ -3750,6 +4111,19 @@ const setAccountEnabled = (state, enabled) => {
|
|
|
3750
4111
|
};
|
|
3751
4112
|
};
|
|
3752
4113
|
|
|
4114
|
+
const setDragAndDropEnabled = (state, enabled) => {
|
|
4115
|
+
const {
|
|
4116
|
+
dragAndDropEnabled
|
|
4117
|
+
} = state;
|
|
4118
|
+
if (dragAndDropEnabled === enabled) {
|
|
4119
|
+
return state;
|
|
4120
|
+
}
|
|
4121
|
+
return {
|
|
4122
|
+
...state,
|
|
4123
|
+
dragAndDropEnabled: enabled
|
|
4124
|
+
};
|
|
4125
|
+
};
|
|
4126
|
+
|
|
3753
4127
|
const providerKeys = ['userLoginProvider', 'loginProvider', 'authProvider', 'provider'];
|
|
3754
4128
|
const getUserLoginProvider = userInfo => {
|
|
3755
4129
|
if (!userInfo || typeof userInfo !== 'object') {
|
|
@@ -3815,7 +4189,7 @@ const toggleActivityBarItem = async (state, itemId) => {
|
|
|
3815
4189
|
};
|
|
3816
4190
|
|
|
3817
4191
|
const wakeUp = sleepState => {
|
|
3818
|
-
set$
|
|
4192
|
+
set$6(sleepState.uid, sleepState, sleepState);
|
|
3819
4193
|
};
|
|
3820
4194
|
|
|
3821
4195
|
const handleDirectMessagePort = (port, setAsRendererProcess) => handleMessagePort(port, commandMap, setAsRendererProcess);
|
|
@@ -3845,6 +4219,11 @@ const commandMap = {
|
|
|
3845
4219
|
'ActivityBar.handleClickSignIn': wrapCommand(handleClickSignIn),
|
|
3846
4220
|
'ActivityBar.handleClickSignOut': wrapCommand(handleClickSignOut),
|
|
3847
4221
|
'ActivityBar.handleContextMenu': wrapAsyncCommand(handleContextMenu),
|
|
4222
|
+
'ActivityBar.handleDragEnd': wrapCommand(handleDragEnd),
|
|
4223
|
+
'ActivityBar.handleDragLeave': wrapCommand(handleDragLeave),
|
|
4224
|
+
'ActivityBar.handleDragOver': wrapCommand(handleDragOver),
|
|
4225
|
+
'ActivityBar.handleDragStart': wrapCommand(handleDragStart),
|
|
4226
|
+
'ActivityBar.handleDrop': wrapAsyncCommand(handleDrop),
|
|
3848
4227
|
'ActivityBar.handleExtensionManagementMessagePort': handleExtensionManagementMessagePort,
|
|
3849
4228
|
'ActivityBar.handleExtensionsChanged': wrapCommand(handleExtensionsChanged),
|
|
3850
4229
|
'ActivityBar.handleFocus': wrapCommand(handleFocus),
|
|
@@ -3860,6 +4239,7 @@ const commandMap = {
|
|
|
3860
4239
|
'ActivityBar.saveState': wrapGetter(saveState),
|
|
3861
4240
|
'ActivityBar.selectCurrent': wrapCommand(selectCurrent),
|
|
3862
4241
|
'ActivityBar.setAccountEnabled': wrapCommand(setAccountEnabled),
|
|
4242
|
+
'ActivityBar.setDragAndDropEnabled': wrapCommand(setDragAndDropEnabled),
|
|
3863
4243
|
'ActivityBar.setUserLoginState': wrapCommand(setUserLoginState),
|
|
3864
4244
|
'ActivityBar.sleep': sleep,
|
|
3865
4245
|
'ActivityBar.terminate': terminate,
|
|
@@ -3867,6 +4247,20 @@ const commandMap = {
|
|
|
3867
4247
|
'ActivityBar.wakeUp': wakeUp
|
|
3868
4248
|
};
|
|
3869
4249
|
|
|
4250
|
+
const send$1 = async port => {
|
|
4251
|
+
await invokeAndTransfer('DragAndDrop.handleMessagePort', port);
|
|
4252
|
+
};
|
|
4253
|
+
const createDragAndDropWorkerRpc = async () => {
|
|
4254
|
+
return create$2({
|
|
4255
|
+
commandMap: {},
|
|
4256
|
+
send: send$1
|
|
4257
|
+
});
|
|
4258
|
+
};
|
|
4259
|
+
|
|
4260
|
+
const initializeDragAndDropWorker = async () => {
|
|
4261
|
+
set$4(await createDragAndDropWorkerRpc());
|
|
4262
|
+
};
|
|
4263
|
+
|
|
3870
4264
|
const send = async port => {
|
|
3871
4265
|
await sendMessagePortToExtensionManagementWorker(port, 0);
|
|
3872
4266
|
};
|
|
@@ -3887,7 +4281,7 @@ const initializeRendererWorker = async () => {
|
|
|
3887
4281
|
|
|
3888
4282
|
const listen = async () => {
|
|
3889
4283
|
registerCommands(commandMap);
|
|
3890
|
-
await Promise.all([initializeRendererWorker(), initializeExtensionManagementWorker()]);
|
|
4284
|
+
await Promise.all([initializeRendererWorker(), initializeExtensionManagementWorker(), initializeDragAndDropWorker()]);
|
|
3891
4285
|
};
|
|
3892
4286
|
|
|
3893
4287
|
const main = async () => {
|
package/dist/settings.json
CHANGED
|
@@ -6,5 +6,13 @@
|
|
|
6
6
|
"id": "activityBar.accountEnabled",
|
|
7
7
|
"type": "boolean",
|
|
8
8
|
"value": true
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"category": "workbench",
|
|
12
|
+
"description": "Enable dragging activity bar items to reorder them",
|
|
13
|
+
"heading": "Activity Bar",
|
|
14
|
+
"id": "activityBar.dragAndDropEnabled",
|
|
15
|
+
"type": "boolean",
|
|
16
|
+
"value": false
|
|
9
17
|
}
|
|
10
18
|
]
|