@lvce-editor/panel-worker 2.13.2 → 2.13.3
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/panelWorkerMain.js +182 -13
- package/package.json +1 -1
package/dist/panelWorkerMain.js
CHANGED
|
@@ -96,6 +96,12 @@ const object = value => {
|
|
|
96
96
|
throw new AssertionError('expected value to be of type object');
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
+
const number = value => {
|
|
100
|
+
const type = getType(value);
|
|
101
|
+
if (type !== Number$1) {
|
|
102
|
+
throw new AssertionError('expected value to be of type number');
|
|
103
|
+
}
|
|
104
|
+
};
|
|
99
105
|
const string = value => {
|
|
100
106
|
const type = getType(value);
|
|
101
107
|
if (type !== String$1) {
|
|
@@ -1111,12 +1117,12 @@ const create$2 = rpcId => {
|
|
|
1111
1117
|
};
|
|
1112
1118
|
};
|
|
1113
1119
|
|
|
1114
|
-
const Tab = 'tab';
|
|
1120
|
+
const Tab$1 = 'tab';
|
|
1115
1121
|
const TabList = 'tablist';
|
|
1116
1122
|
const ToolBar = 'toolbar';
|
|
1117
1123
|
|
|
1118
1124
|
const Audio = 0;
|
|
1119
|
-
const Button = 1;
|
|
1125
|
+
const Button$1 = 1;
|
|
1120
1126
|
const Col = 2;
|
|
1121
1127
|
const ColGroup = 3;
|
|
1122
1128
|
const Div = 4;
|
|
@@ -1207,7 +1213,7 @@ const VirtualDomElements = {
|
|
|
1207
1213
|
Audio,
|
|
1208
1214
|
BlockQuote,
|
|
1209
1215
|
Br,
|
|
1210
|
-
Button,
|
|
1216
|
+
Button: Button$1,
|
|
1211
1217
|
Canvas,
|
|
1212
1218
|
Circle,
|
|
1213
1219
|
Cite,
|
|
@@ -1284,8 +1290,18 @@ const VirtualDomElements = {
|
|
|
1284
1290
|
Video
|
|
1285
1291
|
};
|
|
1286
1292
|
|
|
1293
|
+
const Button = 'event.button';
|
|
1294
|
+
const ClientX = 'event.clientX';
|
|
1295
|
+
const ClientY = 'event.clientY';
|
|
1287
1296
|
const TargetName = 'event.target.name';
|
|
1288
1297
|
|
|
1298
|
+
const Tab = 13;
|
|
1299
|
+
|
|
1300
|
+
const Separator = 1;
|
|
1301
|
+
const None = 0;
|
|
1302
|
+
const Checked = 2;
|
|
1303
|
+
const Unchecked = 3;
|
|
1304
|
+
|
|
1289
1305
|
const RendererProcess = 1670;
|
|
1290
1306
|
const RendererWorker = 1;
|
|
1291
1307
|
|
|
@@ -1300,6 +1316,13 @@ const {
|
|
|
1300
1316
|
invoke: invoke$1,
|
|
1301
1317
|
set: set$2
|
|
1302
1318
|
} = create$2(RendererWorker);
|
|
1319
|
+
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1320
|
+
number(uid);
|
|
1321
|
+
number(menuId);
|
|
1322
|
+
number(x);
|
|
1323
|
+
number(y);
|
|
1324
|
+
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1325
|
+
};
|
|
1303
1326
|
|
|
1304
1327
|
const toCommandId = key => {
|
|
1305
1328
|
const dotIndex = key.indexOf('.');
|
|
@@ -1560,12 +1583,14 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1560
1583
|
const state = {
|
|
1561
1584
|
actionsUid: 0,
|
|
1562
1585
|
assetDir,
|
|
1586
|
+
availableViews: [],
|
|
1563
1587
|
badgeCounts: {},
|
|
1564
1588
|
childUid: 0,
|
|
1565
1589
|
currentViewletId: '',
|
|
1566
1590
|
errorCount: 0,
|
|
1567
1591
|
headerHeight: 35,
|
|
1568
1592
|
height,
|
|
1593
|
+
hiddenViews: [],
|
|
1569
1594
|
initial: true,
|
|
1570
1595
|
maximized: false,
|
|
1571
1596
|
platform,
|
|
@@ -1632,6 +1657,60 @@ const getCurrentViewletId = state => {
|
|
|
1632
1657
|
return currentViewletId;
|
|
1633
1658
|
};
|
|
1634
1659
|
|
|
1660
|
+
const menuEntrySeparator = {
|
|
1661
|
+
command: '',
|
|
1662
|
+
flags: Separator,
|
|
1663
|
+
id: 'separator',
|
|
1664
|
+
label: ''
|
|
1665
|
+
};
|
|
1666
|
+
|
|
1667
|
+
const getViewMenuItemFlags = (state, view) => {
|
|
1668
|
+
const {
|
|
1669
|
+
views
|
|
1670
|
+
} = state;
|
|
1671
|
+
return views.includes(view) ? Checked : Unchecked;
|
|
1672
|
+
};
|
|
1673
|
+
const getViewMenuEntry = (state, view) => {
|
|
1674
|
+
const {
|
|
1675
|
+
uid
|
|
1676
|
+
} = state;
|
|
1677
|
+
return {
|
|
1678
|
+
args: [uid, view],
|
|
1679
|
+
command: 'Panel.toggleViewVisibility',
|
|
1680
|
+
flags: getViewMenuItemFlags(state, view),
|
|
1681
|
+
id: `panelTab.${view}`,
|
|
1682
|
+
label: view
|
|
1683
|
+
};
|
|
1684
|
+
};
|
|
1685
|
+
const getTabMenuEntries = state => {
|
|
1686
|
+
const {
|
|
1687
|
+
availableViews
|
|
1688
|
+
} = state;
|
|
1689
|
+
return [...availableViews.map(view => getViewMenuEntry(state, view)), menuEntrySeparator, {
|
|
1690
|
+
command: 'Layout.maximizePanel',
|
|
1691
|
+
flags: None,
|
|
1692
|
+
id: 'panel.maximize',
|
|
1693
|
+
label: 'Maximize Panel'
|
|
1694
|
+
}, {
|
|
1695
|
+
command: 'Layout.hidePanel',
|
|
1696
|
+
flags: None,
|
|
1697
|
+
id: 'panel.hide',
|
|
1698
|
+
label: 'Hide Panel'
|
|
1699
|
+
}];
|
|
1700
|
+
};
|
|
1701
|
+
const getMenuEntries = (state, props) => {
|
|
1702
|
+
switch (props.menuId) {
|
|
1703
|
+
case Tab:
|
|
1704
|
+
return getTabMenuEntries(state);
|
|
1705
|
+
default:
|
|
1706
|
+
return [];
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
|
|
1710
|
+
const getMenuIds = () => {
|
|
1711
|
+
return [Tab];
|
|
1712
|
+
};
|
|
1713
|
+
|
|
1635
1714
|
const state = {
|
|
1636
1715
|
connected: false
|
|
1637
1716
|
};
|
|
@@ -1713,6 +1792,22 @@ const handleProblemsSummaryChange = (state, summary) => {
|
|
|
1713
1792
|
return setBadgeCount(state, Problems, count);
|
|
1714
1793
|
};
|
|
1715
1794
|
|
|
1795
|
+
const show2 = async (uid, menuId, x, y, args) => {
|
|
1796
|
+
await showContextMenu2(uid, menuId, x, y, args);
|
|
1797
|
+
};
|
|
1798
|
+
|
|
1799
|
+
const handleTabContextMenu = async (state, _button, x, y) => {
|
|
1800
|
+
number(x);
|
|
1801
|
+
number(y);
|
|
1802
|
+
const {
|
|
1803
|
+
uid
|
|
1804
|
+
} = state;
|
|
1805
|
+
await show2(uid, Tab, x, y, {
|
|
1806
|
+
menuId: Tab
|
|
1807
|
+
});
|
|
1808
|
+
return state;
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1716
1811
|
const handleClickClose = async state => {
|
|
1717
1812
|
await invoke$1('Layout.hidePanel');
|
|
1718
1813
|
return state;
|
|
@@ -1862,14 +1957,21 @@ const loadContent = (state, savedState, workspaceUri = '') => {
|
|
|
1862
1957
|
currentViewletId: activeViewletId
|
|
1863
1958
|
} = state;
|
|
1864
1959
|
const savedViewletId = getSavedViewletId(savedState);
|
|
1865
|
-
const
|
|
1960
|
+
const availableViews = getPanelViews(workspaceUri);
|
|
1961
|
+
const hiddenViews = (savedState?.hiddenViews || []).filter(view => availableViews.includes(view));
|
|
1962
|
+
let views = availableViews.filter(view => !hiddenViews.includes(view));
|
|
1963
|
+
if (views.length === 0 && availableViews.length > 0) {
|
|
1964
|
+
views = [availableViews[0]];
|
|
1965
|
+
}
|
|
1866
1966
|
let currentViewletId = savedViewletId;
|
|
1867
1967
|
if (!views.includes(currentViewletId)) {
|
|
1868
1968
|
currentViewletId = views.includes(activeViewletId) ? activeViewletId : views[0];
|
|
1869
1969
|
}
|
|
1870
1970
|
const loaded = {
|
|
1871
1971
|
...state,
|
|
1972
|
+
availableViews,
|
|
1872
1973
|
currentViewletId,
|
|
1974
|
+
hiddenViews: availableViews.filter(view => !views.includes(view)),
|
|
1873
1975
|
views
|
|
1874
1976
|
};
|
|
1875
1977
|
return openViewlet(loaded, currentViewletId);
|
|
@@ -1891,13 +1993,24 @@ const selectRaw = async (state, rawIndex) => {
|
|
|
1891
1993
|
|
|
1892
1994
|
const toggleView = async (state, name, uri = '') => {
|
|
1893
1995
|
const {
|
|
1996
|
+
availableViews,
|
|
1894
1997
|
currentViewletId,
|
|
1998
|
+
hiddenViews,
|
|
1895
1999
|
views
|
|
1896
2000
|
} = state;
|
|
1897
|
-
|
|
1898
|
-
if (index === -1) {
|
|
2001
|
+
if (!availableViews.includes(name)) {
|
|
1899
2002
|
return state;
|
|
1900
2003
|
}
|
|
2004
|
+
if (!views.includes(name)) {
|
|
2005
|
+
const nextHiddenViews = hiddenViews.filter(view => view !== name);
|
|
2006
|
+
const nextViews = availableViews.filter(view => !nextHiddenViews.includes(view));
|
|
2007
|
+
return selectIndex({
|
|
2008
|
+
...state,
|
|
2009
|
+
hiddenViews: nextHiddenViews,
|
|
2010
|
+
views: nextViews
|
|
2011
|
+
}, nextViews.indexOf(name), uri);
|
|
2012
|
+
}
|
|
2013
|
+
const index = views.indexOf(name);
|
|
1901
2014
|
if (name === currentViewletId) {
|
|
1902
2015
|
return state;
|
|
1903
2016
|
}
|
|
@@ -2217,6 +2330,7 @@ const HandleClickMaximize = 'handleClickMaximize';
|
|
|
2217
2330
|
const HandleClickUnmaximize = 'handleClickUnmaximize';
|
|
2218
2331
|
const HandleClickSelectTab = 'HandleClickSelectTab';
|
|
2219
2332
|
const HandleClickTab = 'HandleClickTab';
|
|
2333
|
+
const HandleTabContextMenu = 'HandleTabContextMenu';
|
|
2220
2334
|
|
|
2221
2335
|
const emptyObject = {};
|
|
2222
2336
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
@@ -2268,7 +2382,7 @@ const getGlobalActionsDom = state => {
|
|
|
2268
2382
|
className: IconButton,
|
|
2269
2383
|
onClick: maximizeOnClick,
|
|
2270
2384
|
title: maximizeLabel,
|
|
2271
|
-
type: Button
|
|
2385
|
+
type: Button$1
|
|
2272
2386
|
}, {
|
|
2273
2387
|
childCount: 0,
|
|
2274
2388
|
className: mergeClassNames(MaskIcon, maximizeIcon),
|
|
@@ -2279,7 +2393,7 @@ const getGlobalActionsDom = state => {
|
|
|
2279
2393
|
className: IconButton,
|
|
2280
2394
|
onClick: HandleClickClose,
|
|
2281
2395
|
title: close(),
|
|
2282
|
-
type: Button
|
|
2396
|
+
type: Button$1
|
|
2283
2397
|
}, closeIconNode];
|
|
2284
2398
|
};
|
|
2285
2399
|
|
|
@@ -2306,8 +2420,9 @@ const createPanelTab = (tab, badgeCount, isSelected) => {
|
|
|
2306
2420
|
className,
|
|
2307
2421
|
name: tab,
|
|
2308
2422
|
onClick: HandleClickTab,
|
|
2309
|
-
|
|
2310
|
-
|
|
2423
|
+
onContextMenu: HandleTabContextMenu,
|
|
2424
|
+
role: Tab$1,
|
|
2425
|
+
type: Button$1
|
|
2311
2426
|
};
|
|
2312
2427
|
const dom = [tabDom, text(label)];
|
|
2313
2428
|
if (badgeCount) {
|
|
@@ -2452,6 +2567,10 @@ const renderEventListeners = () => {
|
|
|
2452
2567
|
}, {
|
|
2453
2568
|
name: HandleClickTab,
|
|
2454
2569
|
params: ['selectName', TargetName]
|
|
2570
|
+
}, {
|
|
2571
|
+
name: HandleTabContextMenu,
|
|
2572
|
+
params: ['handleTabContextMenu', Button, ClientX, ClientY],
|
|
2573
|
+
preventDefault: true
|
|
2455
2574
|
}];
|
|
2456
2575
|
};
|
|
2457
2576
|
|
|
@@ -2480,11 +2599,13 @@ const resize = async (state, dimensions) => {
|
|
|
2480
2599
|
const saveState = async state => {
|
|
2481
2600
|
const {
|
|
2482
2601
|
childUid,
|
|
2483
|
-
currentViewletId
|
|
2602
|
+
currentViewletId,
|
|
2603
|
+
hiddenViews
|
|
2484
2604
|
} = state;
|
|
2485
2605
|
await saveViewletState(childUid, currentViewletId);
|
|
2486
2606
|
return {
|
|
2487
|
-
currentViewletId
|
|
2607
|
+
currentViewletId,
|
|
2608
|
+
hiddenViews
|
|
2488
2609
|
};
|
|
2489
2610
|
};
|
|
2490
2611
|
|
|
@@ -2519,6 +2640,49 @@ const applyComponentState = (currentState, state) => {
|
|
|
2519
2640
|
};
|
|
2520
2641
|
const setComponentState = wrapCommand(applyComponentState);
|
|
2521
2642
|
|
|
2643
|
+
const toggleViewVisibility = async (state, name) => {
|
|
2644
|
+
const {
|
|
2645
|
+
availableViews,
|
|
2646
|
+
currentViewletId,
|
|
2647
|
+
hiddenViews,
|
|
2648
|
+
views
|
|
2649
|
+
} = state;
|
|
2650
|
+
if (!availableViews.includes(name)) {
|
|
2651
|
+
return state;
|
|
2652
|
+
}
|
|
2653
|
+
if (!views.includes(name)) {
|
|
2654
|
+
const nextHiddenViews = hiddenViews.filter(view => view !== name);
|
|
2655
|
+
const nextViews = availableViews.filter(view => !nextHiddenViews.includes(view));
|
|
2656
|
+
const nextState = {
|
|
2657
|
+
...state,
|
|
2658
|
+
hiddenViews: nextHiddenViews,
|
|
2659
|
+
selectedIndex: nextViews.indexOf(currentViewletId),
|
|
2660
|
+
views: nextViews
|
|
2661
|
+
};
|
|
2662
|
+
if (views.length === 0) {
|
|
2663
|
+
return openViewlet(nextState, name);
|
|
2664
|
+
}
|
|
2665
|
+
return nextState;
|
|
2666
|
+
}
|
|
2667
|
+
if (views.length <= 1) {
|
|
2668
|
+
return state;
|
|
2669
|
+
}
|
|
2670
|
+
const nextViews = views.filter(view => view !== name);
|
|
2671
|
+
const nextHiddenViews = availableViews.filter(view => !nextViews.includes(view));
|
|
2672
|
+
const nextState = {
|
|
2673
|
+
...state,
|
|
2674
|
+
hiddenViews: nextHiddenViews,
|
|
2675
|
+
selectedIndex: nextViews.indexOf(currentViewletId),
|
|
2676
|
+
views: nextViews
|
|
2677
|
+
};
|
|
2678
|
+
if (currentViewletId !== name) {
|
|
2679
|
+
return nextState;
|
|
2680
|
+
}
|
|
2681
|
+
const index = views.indexOf(name);
|
|
2682
|
+
const nextView = nextViews[Math.min(index, nextViews.length - 1)];
|
|
2683
|
+
return openViewlet(nextState, nextView);
|
|
2684
|
+
};
|
|
2685
|
+
|
|
2522
2686
|
const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
|
|
2523
2687
|
const commandMap = {
|
|
2524
2688
|
'Panel.create': create,
|
|
@@ -2526,6 +2690,9 @@ const commandMap = {
|
|
|
2526
2690
|
'Panel.getCommandIds': getCommandIds,
|
|
2527
2691
|
'Panel.getComponentState': getComponentState,
|
|
2528
2692
|
'Panel.getCurrentViewletId': wrapGetter(getCurrentViewletId),
|
|
2693
|
+
'Panel.getMenuEntries': wrapGetter(getMenuEntries),
|
|
2694
|
+
'Panel.getMenuEntries2': wrapGetter(getMenuEntries),
|
|
2695
|
+
'Panel.getMenuIds': getMenuIds,
|
|
2529
2696
|
'Panel.handleBlur': wrapCommand(handleBlur),
|
|
2530
2697
|
'Panel.handleClickClose': wrapCommand(handleClickClose),
|
|
2531
2698
|
'Panel.handleClickMaximize': wrapCommand(handleClickMaximize),
|
|
@@ -2534,6 +2701,7 @@ const commandMap = {
|
|
|
2534
2701
|
'Panel.handleMessagePort': handleDirectMessagePort,
|
|
2535
2702
|
'Panel.handlePanelLayoutChanged': wrapCommand(handlePanelLayoutChanged),
|
|
2536
2703
|
'Panel.handleProblemsSummaryChange': wrapCommand(handleProblemsSummaryChange),
|
|
2704
|
+
'Panel.handleTabContextMenu': wrapCommand(handleTabContextMenu),
|
|
2537
2705
|
'Panel.loadContent': wrapCommand(loadContent),
|
|
2538
2706
|
'Panel.openViewlet': wrapCommand(openViewlet),
|
|
2539
2707
|
'Panel.render2': render2,
|
|
@@ -2546,7 +2714,8 @@ const commandMap = {
|
|
|
2546
2714
|
'Panel.setBadgeCount': wrapCommand(setBadgeCount),
|
|
2547
2715
|
'Panel.setComponentState': setComponentState,
|
|
2548
2716
|
'Panel.terminate': terminate,
|
|
2549
|
-
'Panel.toggleView': wrapCommand(toggleView)
|
|
2717
|
+
'Panel.toggleView': wrapCommand(toggleView),
|
|
2718
|
+
'Panel.toggleViewVisibility': wrapCommand(toggleViewVisibility)
|
|
2550
2719
|
};
|
|
2551
2720
|
|
|
2552
2721
|
const listen = async () => {
|