@lvce-editor/activity-bar-worker 7.10.0 → 7.10.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 +118 -20
- 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
|
|
@@ -2174,14 +2215,14 @@ const handleBlur = state => {
|
|
|
2174
2215
|
};
|
|
2175
2216
|
};
|
|
2176
2217
|
|
|
2177
|
-
const isBottomItem = item => {
|
|
2218
|
+
const isBottomItem$1 = item => {
|
|
2178
2219
|
return item.id === 'Account' || item.id === 'Settings';
|
|
2179
2220
|
};
|
|
2180
2221
|
const getBottomItemCount = items => {
|
|
2181
2222
|
if (typeof items === 'number') {
|
|
2182
2223
|
return items > 1 ? 1 : 0;
|
|
2183
2224
|
}
|
|
2184
|
-
return items.filter(isBottomItem).length;
|
|
2225
|
+
return items.filter(isBottomItem$1).length;
|
|
2185
2226
|
};
|
|
2186
2227
|
const getItemCount = items => {
|
|
2187
2228
|
if (typeof items === 'number') {
|
|
@@ -2556,10 +2597,25 @@ const handleExtensionsChanged = async state => {
|
|
|
2556
2597
|
};
|
|
2557
2598
|
};
|
|
2558
2599
|
|
|
2600
|
+
const getFocusedIndex = state => {
|
|
2601
|
+
const {
|
|
2602
|
+
filteredItems,
|
|
2603
|
+
focusedIndex
|
|
2604
|
+
} = state;
|
|
2605
|
+
if (focusedIndex >= 0 && focusedIndex < filteredItems.length) {
|
|
2606
|
+
return focusedIndex;
|
|
2607
|
+
}
|
|
2608
|
+
const selectedIndex = filteredItems.findIndex(item => item.flags & Selected);
|
|
2609
|
+
if (selectedIndex !== -1) {
|
|
2610
|
+
return selectedIndex;
|
|
2611
|
+
}
|
|
2612
|
+
return filteredItems.length === 0 ? -1 : 0;
|
|
2613
|
+
};
|
|
2559
2614
|
const handleFocus = state => {
|
|
2560
2615
|
return {
|
|
2561
2616
|
...state,
|
|
2562
|
-
focused: true
|
|
2617
|
+
focused: true,
|
|
2618
|
+
focusedIndex: getFocusedIndex(state)
|
|
2563
2619
|
};
|
|
2564
2620
|
};
|
|
2565
2621
|
|
|
@@ -3320,16 +3376,22 @@ const getActivityBarVirtualDom = visibleItems => {
|
|
|
3320
3376
|
}, ...getVirtualDom(visibleItems)];
|
|
3321
3377
|
};
|
|
3322
3378
|
|
|
3379
|
+
const getVisibleActivityBarItems = (items, focusedIndex) => {
|
|
3380
|
+
return items.map((item, index) => setFlag(item, Focused, index === focusedIndex));
|
|
3381
|
+
};
|
|
3382
|
+
|
|
3323
3383
|
const renderItems = (oldState, newState) => {
|
|
3324
3384
|
const {
|
|
3325
3385
|
filteredItems,
|
|
3386
|
+
focusedIndex,
|
|
3326
3387
|
initial,
|
|
3327
3388
|
uid
|
|
3328
3389
|
} = newState;
|
|
3329
3390
|
if (initial) {
|
|
3330
3391
|
return [SetDom2, uid, []];
|
|
3331
3392
|
}
|
|
3332
|
-
const
|
|
3393
|
+
const visibleItems = getVisibleActivityBarItems(filteredItems, focusedIndex);
|
|
3394
|
+
const dom = getActivityBarVirtualDom(visibleItems);
|
|
3333
3395
|
return [SetDom2, uid, dom];
|
|
3334
3396
|
};
|
|
3335
3397
|
|
|
@@ -3405,6 +3467,40 @@ const saveState = state => {
|
|
|
3405
3467
|
return {};
|
|
3406
3468
|
};
|
|
3407
3469
|
|
|
3470
|
+
const isBottomItem = id => {
|
|
3471
|
+
return id === 'Account' || id === 'Settings';
|
|
3472
|
+
};
|
|
3473
|
+
const getItemPosition = (state, index) => {
|
|
3474
|
+
const {
|
|
3475
|
+
filteredItems,
|
|
3476
|
+
height,
|
|
3477
|
+
itemHeight,
|
|
3478
|
+
width,
|
|
3479
|
+
x,
|
|
3480
|
+
y
|
|
3481
|
+
} = state;
|
|
3482
|
+
const item = filteredItems[index];
|
|
3483
|
+
const bottomItems = filteredItems.filter(({
|
|
3484
|
+
id
|
|
3485
|
+
}) => isBottomItem(id));
|
|
3486
|
+
const bottomIndex = bottomItems.findIndex(({
|
|
3487
|
+
id
|
|
3488
|
+
}) => id === item.id);
|
|
3489
|
+
const itemY = bottomIndex === -1 ? y + index * itemHeight : y + height - (bottomItems.length - bottomIndex) * itemHeight;
|
|
3490
|
+
return [x + width / 2, itemY + itemHeight / 2];
|
|
3491
|
+
};
|
|
3492
|
+
const selectCurrent = async state => {
|
|
3493
|
+
const {
|
|
3494
|
+
filteredItems,
|
|
3495
|
+
focusedIndex
|
|
3496
|
+
} = state;
|
|
3497
|
+
if (focusedIndex < 0 || focusedIndex >= filteredItems.length) {
|
|
3498
|
+
return state;
|
|
3499
|
+
}
|
|
3500
|
+
const [x, y] = getItemPosition(state, focusedIndex);
|
|
3501
|
+
return handleClickIndex(state, LeftClick, focusedIndex, x, y);
|
|
3502
|
+
};
|
|
3503
|
+
|
|
3408
3504
|
const setAccountEnabled = (state, enabled) => {
|
|
3409
3505
|
const {
|
|
3410
3506
|
height,
|
|
@@ -3428,7 +3524,7 @@ const setAccountEnabled = (state, enabled) => {
|
|
|
3428
3524
|
const providerKeys = ['userLoginProvider', 'loginProvider', 'authProvider', 'provider'];
|
|
3429
3525
|
const getUserLoginProvider = userInfo => {
|
|
3430
3526
|
if (!userInfo || typeof userInfo !== 'object') {
|
|
3431
|
-
return '
|
|
3527
|
+
return 'Lvce Editor';
|
|
3432
3528
|
}
|
|
3433
3529
|
const record = userInfo;
|
|
3434
3530
|
for (const key of providerKeys) {
|
|
@@ -3436,7 +3532,7 @@ const getUserLoginProvider = userInfo => {
|
|
|
3436
3532
|
return record[key];
|
|
3437
3533
|
}
|
|
3438
3534
|
}
|
|
3439
|
-
return '
|
|
3535
|
+
return 'Lvce Editor';
|
|
3440
3536
|
};
|
|
3441
3537
|
|
|
3442
3538
|
const getUserName = userInfo => {
|
|
@@ -3491,6 +3587,7 @@ const commandMap = {
|
|
|
3491
3587
|
'ActivityBar.focusLast': wrapCommand(focusLast),
|
|
3492
3588
|
'ActivityBar.focusNext': wrapCommand(focusNext),
|
|
3493
3589
|
'ActivityBar.focusNone': wrapCommand(focusNone),
|
|
3590
|
+
'ActivityBar.focusPrevious': wrapCommand(focusPrevious),
|
|
3494
3591
|
'ActivityBar.getCommandIds': getCommandIds,
|
|
3495
3592
|
'ActivityBar.getKeyBindings': getKeyBindings,
|
|
3496
3593
|
'ActivityBar.getMenuEntries': wrapGetter(getMenuEntries),
|
|
@@ -3516,6 +3613,7 @@ const commandMap = {
|
|
|
3516
3613
|
'ActivityBar.renderEventListeners': renderEventListeners,
|
|
3517
3614
|
'ActivityBar.resize': wrapCommand(handleResize),
|
|
3518
3615
|
'ActivityBar.saveState': wrapGetter(saveState),
|
|
3616
|
+
'ActivityBar.selectCurrent': wrapCommand(selectCurrent),
|
|
3519
3617
|
'ActivityBar.setAccountEnabled': wrapCommand(setAccountEnabled),
|
|
3520
3618
|
'ActivityBar.setUserLoginState': wrapCommand(setUserLoginState),
|
|
3521
3619
|
'ActivityBar.terminate': terminate,
|