@lvce-editor/activity-bar-worker 7.10.0 → 7.11.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 +128 -21
- package/package.json +1 -1
|
@@ -276,7 +276,7 @@ const create$9 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
276
276
|
uid: id,
|
|
277
277
|
updateProgress: 0,
|
|
278
278
|
updateState: '',
|
|
279
|
-
userLoginProvider: '
|
|
279
|
+
userLoginProvider: 'Lvce Editor',
|
|
280
280
|
userLoginState: 'logged out',
|
|
281
281
|
userName: '',
|
|
282
282
|
width,
|
|
@@ -345,15 +345,29 @@ const focusIndex = (state, index) => {
|
|
|
345
345
|
};
|
|
346
346
|
|
|
347
347
|
const focusFirst = state => {
|
|
348
|
-
|
|
348
|
+
const {
|
|
349
|
+
filteredItems
|
|
350
|
+
} = state;
|
|
351
|
+
return focusIndex(state, filteredItems.length === 0 ? -1 : 0);
|
|
349
352
|
};
|
|
350
353
|
|
|
351
354
|
const focusLast = state => {
|
|
352
|
-
|
|
355
|
+
const {
|
|
356
|
+
filteredItems
|
|
357
|
+
} = state;
|
|
358
|
+
return focusIndex(state, filteredItems.length - 1);
|
|
353
359
|
};
|
|
354
360
|
|
|
355
361
|
const focusNext = state => {
|
|
356
|
-
|
|
362
|
+
const {
|
|
363
|
+
filteredItems,
|
|
364
|
+
focusedIndex
|
|
365
|
+
} = state;
|
|
366
|
+
const lastIndex = filteredItems.length - 1;
|
|
367
|
+
if (focusedIndex >= lastIndex) {
|
|
368
|
+
return state;
|
|
369
|
+
}
|
|
370
|
+
return focusIndex(state, focusedIndex + 1);
|
|
357
371
|
};
|
|
358
372
|
|
|
359
373
|
const focusNone = state => {
|
|
@@ -366,6 +380,16 @@ const focusNone = state => {
|
|
|
366
380
|
return focusIndex(state, -1);
|
|
367
381
|
};
|
|
368
382
|
|
|
383
|
+
const focusPrevious = state => {
|
|
384
|
+
const {
|
|
385
|
+
focusedIndex
|
|
386
|
+
} = state;
|
|
387
|
+
if (focusedIndex <= 0) {
|
|
388
|
+
return state;
|
|
389
|
+
}
|
|
390
|
+
return focusIndex(state, focusedIndex - 1);
|
|
391
|
+
};
|
|
392
|
+
|
|
369
393
|
const Button$3 = 'button';
|
|
370
394
|
const None$1 = 'none';
|
|
371
395
|
const Tab$1 = 'tab';
|
|
@@ -625,7 +649,7 @@ const getAccountLabel = state => {
|
|
|
625
649
|
userName
|
|
626
650
|
} = state;
|
|
627
651
|
const name = userName || 'Account';
|
|
628
|
-
const provider = userLoginProvider || '
|
|
652
|
+
const provider = userLoginProvider || 'Lvce Editor';
|
|
629
653
|
return `${name} (${provider})`;
|
|
630
654
|
};
|
|
631
655
|
const getMenuEntriesAccountLoggedIn = state => {
|
|
@@ -1479,7 +1503,10 @@ const constructError = (message, type, name) => {
|
|
|
1479
1503
|
if (ErrorConstructor === Error) {
|
|
1480
1504
|
const error = new Error(message);
|
|
1481
1505
|
if (name && name !== 'VError') {
|
|
1482
|
-
error
|
|
1506
|
+
Object.defineProperty(error, 'name', {
|
|
1507
|
+
configurable: true,
|
|
1508
|
+
value: name
|
|
1509
|
+
});
|
|
1483
1510
|
}
|
|
1484
1511
|
return error;
|
|
1485
1512
|
}
|
|
@@ -1510,31 +1537,45 @@ const getParentStack = error => {
|
|
|
1510
1537
|
};
|
|
1511
1538
|
const MethodNotFound = -32601;
|
|
1512
1539
|
const Custom = -32001;
|
|
1540
|
+
const setStack = (error, stack) => {
|
|
1541
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
1542
|
+
if (descriptor) {
|
|
1543
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
1547
|
+
error.stack = stack;
|
|
1548
|
+
return;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
Object.defineProperty(error, 'stack', {
|
|
1552
|
+
configurable: true,
|
|
1553
|
+
value: stack,
|
|
1554
|
+
writable: true
|
|
1555
|
+
});
|
|
1556
|
+
};
|
|
1513
1557
|
const restoreExistingError = (error, currentStack) => {
|
|
1514
1558
|
if (typeof error.stack === 'string') {
|
|
1515
|
-
error
|
|
1559
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
1516
1560
|
}
|
|
1517
1561
|
return error;
|
|
1518
1562
|
};
|
|
1519
1563
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
1520
1564
|
const restoredError = new JsonRpcError(error.message);
|
|
1521
1565
|
const parentStack = getParentStack(error);
|
|
1522
|
-
restoredError
|
|
1566
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
1523
1567
|
return restoredError;
|
|
1524
1568
|
};
|
|
1525
1569
|
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
1526
1570
|
if (error.data.stack && error.data.type && error.message) {
|
|
1527
|
-
restoredError
|
|
1571
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
1528
1572
|
return;
|
|
1529
1573
|
}
|
|
1530
1574
|
if (error.data.stack) {
|
|
1531
|
-
restoredError
|
|
1575
|
+
setStack(restoredError, error.data.stack);
|
|
1532
1576
|
}
|
|
1533
1577
|
};
|
|
1534
1578
|
const applyDataProperties = (restoredError, error) => {
|
|
1535
|
-
if (!error.data) {
|
|
1536
|
-
return;
|
|
1537
|
-
}
|
|
1538
1579
|
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
1539
1580
|
if (error.data.codeFrame) {
|
|
1540
1581
|
// @ts-ignore
|
|
@@ -1555,7 +1596,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
1555
1596
|
const indexNewLine = getNewLineIndex(lowerStack);
|
|
1556
1597
|
const parentStack = getParentStack(error);
|
|
1557
1598
|
// @ts-ignore
|
|
1558
|
-
restoredError
|
|
1599
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
1559
1600
|
}
|
|
1560
1601
|
if (error.codeFrame) {
|
|
1561
1602
|
// @ts-ignore
|
|
@@ -2108,12 +2149,21 @@ const getMenuEntryIds = () => {
|
|
|
2108
2149
|
return [ActivityBar$3, ActivityBarAdditionalViews, Settings$1, ACCOUNT_MENU_ID, ACCOUNT_SUBMENU_ID];
|
|
2109
2150
|
};
|
|
2110
2151
|
|
|
2152
|
+
const getBadgeText = badgeCount => {
|
|
2153
|
+
if (badgeCount <= 999) {
|
|
2154
|
+
return badgeCount ? String(badgeCount) : '';
|
|
2155
|
+
}
|
|
2156
|
+
const thousands = badgeCount / 1000;
|
|
2157
|
+
const roundedDown = Math.floor(thousands);
|
|
2158
|
+
return thousands > roundedDown ? `${roundedDown}K+` : `${roundedDown}K`;
|
|
2159
|
+
};
|
|
2160
|
+
|
|
2111
2161
|
const updateItemsWithBadgeCount = async items => {
|
|
2112
2162
|
try {
|
|
2113
2163
|
const badgeCounts = await invoke('Layout.getBadgeCounts');
|
|
2114
2164
|
const newItems = items.map(item => {
|
|
2115
2165
|
const badgeCount = badgeCounts[item.id] || 0;
|
|
2116
|
-
const badgeText =
|
|
2166
|
+
const badgeText = getBadgeText(badgeCount);
|
|
2117
2167
|
return {
|
|
2118
2168
|
...item,
|
|
2119
2169
|
badgeText
|
|
@@ -2174,14 +2224,14 @@ const handleBlur = state => {
|
|
|
2174
2224
|
};
|
|
2175
2225
|
};
|
|
2176
2226
|
|
|
2177
|
-
const isBottomItem = item => {
|
|
2227
|
+
const isBottomItem$1 = item => {
|
|
2178
2228
|
return item.id === 'Account' || item.id === 'Settings';
|
|
2179
2229
|
};
|
|
2180
2230
|
const getBottomItemCount = items => {
|
|
2181
2231
|
if (typeof items === 'number') {
|
|
2182
2232
|
return items > 1 ? 1 : 0;
|
|
2183
2233
|
}
|
|
2184
|
-
return items.filter(isBottomItem).length;
|
|
2234
|
+
return items.filter(isBottomItem$1).length;
|
|
2185
2235
|
};
|
|
2186
2236
|
const getItemCount = items => {
|
|
2187
2237
|
if (typeof items === 'number') {
|
|
@@ -2556,10 +2606,25 @@ const handleExtensionsChanged = async state => {
|
|
|
2556
2606
|
};
|
|
2557
2607
|
};
|
|
2558
2608
|
|
|
2609
|
+
const getFocusedIndex = state => {
|
|
2610
|
+
const {
|
|
2611
|
+
filteredItems,
|
|
2612
|
+
focusedIndex
|
|
2613
|
+
} = state;
|
|
2614
|
+
if (focusedIndex >= 0 && focusedIndex < filteredItems.length) {
|
|
2615
|
+
return focusedIndex;
|
|
2616
|
+
}
|
|
2617
|
+
const selectedIndex = filteredItems.findIndex(item => item.flags & Selected);
|
|
2618
|
+
if (selectedIndex !== -1) {
|
|
2619
|
+
return selectedIndex;
|
|
2620
|
+
}
|
|
2621
|
+
return filteredItems.length === 0 ? -1 : 0;
|
|
2622
|
+
};
|
|
2559
2623
|
const handleFocus = state => {
|
|
2560
2624
|
return {
|
|
2561
2625
|
...state,
|
|
2562
|
-
focused: true
|
|
2626
|
+
focused: true,
|
|
2627
|
+
focusedIndex: getFocusedIndex(state)
|
|
2563
2628
|
};
|
|
2564
2629
|
};
|
|
2565
2630
|
|
|
@@ -3320,16 +3385,22 @@ const getActivityBarVirtualDom = visibleItems => {
|
|
|
3320
3385
|
}, ...getVirtualDom(visibleItems)];
|
|
3321
3386
|
};
|
|
3322
3387
|
|
|
3388
|
+
const getVisibleActivityBarItems = (items, focusedIndex) => {
|
|
3389
|
+
return items.map((item, index) => setFlag(item, Focused, index === focusedIndex));
|
|
3390
|
+
};
|
|
3391
|
+
|
|
3323
3392
|
const renderItems = (oldState, newState) => {
|
|
3324
3393
|
const {
|
|
3325
3394
|
filteredItems,
|
|
3395
|
+
focusedIndex,
|
|
3326
3396
|
initial,
|
|
3327
3397
|
uid
|
|
3328
3398
|
} = newState;
|
|
3329
3399
|
if (initial) {
|
|
3330
3400
|
return [SetDom2, uid, []];
|
|
3331
3401
|
}
|
|
3332
|
-
const
|
|
3402
|
+
const visibleItems = getVisibleActivityBarItems(filteredItems, focusedIndex);
|
|
3403
|
+
const dom = getActivityBarVirtualDom(visibleItems);
|
|
3333
3404
|
return [SetDom2, uid, dom];
|
|
3334
3405
|
};
|
|
3335
3406
|
|
|
@@ -3405,6 +3476,40 @@ const saveState = state => {
|
|
|
3405
3476
|
return {};
|
|
3406
3477
|
};
|
|
3407
3478
|
|
|
3479
|
+
const isBottomItem = id => {
|
|
3480
|
+
return id === 'Account' || id === 'Settings';
|
|
3481
|
+
};
|
|
3482
|
+
const getItemPosition = (state, index) => {
|
|
3483
|
+
const {
|
|
3484
|
+
filteredItems,
|
|
3485
|
+
height,
|
|
3486
|
+
itemHeight,
|
|
3487
|
+
width,
|
|
3488
|
+
x,
|
|
3489
|
+
y
|
|
3490
|
+
} = state;
|
|
3491
|
+
const item = filteredItems[index];
|
|
3492
|
+
const bottomItems = filteredItems.filter(({
|
|
3493
|
+
id
|
|
3494
|
+
}) => isBottomItem(id));
|
|
3495
|
+
const bottomIndex = bottomItems.findIndex(({
|
|
3496
|
+
id
|
|
3497
|
+
}) => id === item.id);
|
|
3498
|
+
const itemY = bottomIndex === -1 ? y + index * itemHeight : y + height - (bottomItems.length - bottomIndex) * itemHeight;
|
|
3499
|
+
return [x + width / 2, itemY + itemHeight / 2];
|
|
3500
|
+
};
|
|
3501
|
+
const selectCurrent = async state => {
|
|
3502
|
+
const {
|
|
3503
|
+
filteredItems,
|
|
3504
|
+
focusedIndex
|
|
3505
|
+
} = state;
|
|
3506
|
+
if (focusedIndex < 0 || focusedIndex >= filteredItems.length) {
|
|
3507
|
+
return state;
|
|
3508
|
+
}
|
|
3509
|
+
const [x, y] = getItemPosition(state, focusedIndex);
|
|
3510
|
+
return handleClickIndex(state, LeftClick, focusedIndex, x, y);
|
|
3511
|
+
};
|
|
3512
|
+
|
|
3408
3513
|
const setAccountEnabled = (state, enabled) => {
|
|
3409
3514
|
const {
|
|
3410
3515
|
height,
|
|
@@ -3428,7 +3533,7 @@ const setAccountEnabled = (state, enabled) => {
|
|
|
3428
3533
|
const providerKeys = ['userLoginProvider', 'loginProvider', 'authProvider', 'provider'];
|
|
3429
3534
|
const getUserLoginProvider = userInfo => {
|
|
3430
3535
|
if (!userInfo || typeof userInfo !== 'object') {
|
|
3431
|
-
return '
|
|
3536
|
+
return 'Lvce Editor';
|
|
3432
3537
|
}
|
|
3433
3538
|
const record = userInfo;
|
|
3434
3539
|
for (const key of providerKeys) {
|
|
@@ -3436,7 +3541,7 @@ const getUserLoginProvider = userInfo => {
|
|
|
3436
3541
|
return record[key];
|
|
3437
3542
|
}
|
|
3438
3543
|
}
|
|
3439
|
-
return '
|
|
3544
|
+
return 'Lvce Editor';
|
|
3440
3545
|
};
|
|
3441
3546
|
|
|
3442
3547
|
const getUserName = userInfo => {
|
|
@@ -3491,6 +3596,7 @@ const commandMap = {
|
|
|
3491
3596
|
'ActivityBar.focusLast': wrapCommand(focusLast),
|
|
3492
3597
|
'ActivityBar.focusNext': wrapCommand(focusNext),
|
|
3493
3598
|
'ActivityBar.focusNone': wrapCommand(focusNone),
|
|
3599
|
+
'ActivityBar.focusPrevious': wrapCommand(focusPrevious),
|
|
3494
3600
|
'ActivityBar.getCommandIds': getCommandIds,
|
|
3495
3601
|
'ActivityBar.getKeyBindings': getKeyBindings,
|
|
3496
3602
|
'ActivityBar.getMenuEntries': wrapGetter(getMenuEntries),
|
|
@@ -3516,6 +3622,7 @@ const commandMap = {
|
|
|
3516
3622
|
'ActivityBar.renderEventListeners': renderEventListeners,
|
|
3517
3623
|
'ActivityBar.resize': wrapCommand(handleResize),
|
|
3518
3624
|
'ActivityBar.saveState': wrapGetter(saveState),
|
|
3625
|
+
'ActivityBar.selectCurrent': wrapCommand(selectCurrent),
|
|
3519
3626
|
'ActivityBar.setAccountEnabled': wrapCommand(setAccountEnabled),
|
|
3520
3627
|
'ActivityBar.setUserLoginState': wrapCommand(setUserLoginState),
|
|
3521
3628
|
'ActivityBar.terminate': terminate,
|