@lvce-editor/panel-worker 2.13.1 → 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 +221 -16
- 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;
|
|
@@ -1791,6 +1886,21 @@ const getUid = () => {
|
|
|
1791
1886
|
return Math.random();
|
|
1792
1887
|
};
|
|
1793
1888
|
|
|
1889
|
+
const pending = new Map();
|
|
1890
|
+
const add = (uid, childUid) => {
|
|
1891
|
+
let children = pending.get(uid);
|
|
1892
|
+
if (!children) {
|
|
1893
|
+
children = new Set();
|
|
1894
|
+
pending.set(uid, children);
|
|
1895
|
+
}
|
|
1896
|
+
children.add(childUid);
|
|
1897
|
+
};
|
|
1898
|
+
const take = uid => {
|
|
1899
|
+
const children = pending.get(uid);
|
|
1900
|
+
pending.delete(uid);
|
|
1901
|
+
return children ? [...children] : [];
|
|
1902
|
+
};
|
|
1903
|
+
|
|
1794
1904
|
const command = 'SaveState.saveViewletStateWithStorageId';
|
|
1795
1905
|
const isCommandNotFoundError = error => {
|
|
1796
1906
|
if (!(error instanceof Error)) {
|
|
@@ -1816,6 +1926,7 @@ const openViewlet = async (state, id, focus = false, uri = '') => {
|
|
|
1816
1926
|
const {
|
|
1817
1927
|
childUid: currentChildUid,
|
|
1818
1928
|
currentViewletId,
|
|
1929
|
+
uid,
|
|
1819
1930
|
views
|
|
1820
1931
|
} = state;
|
|
1821
1932
|
if (!views.includes(id)) {
|
|
@@ -1829,7 +1940,7 @@ const openViewlet = async (state, id, focus = false, uri = '') => {
|
|
|
1829
1940
|
const index = views.indexOf(id);
|
|
1830
1941
|
await createViewlet(id, childUid, tabId, actionsUid, childDimensions, uri, focus);
|
|
1831
1942
|
if (currentChildUid > 0) {
|
|
1832
|
-
|
|
1943
|
+
add(uid, currentChildUid);
|
|
1833
1944
|
}
|
|
1834
1945
|
return {
|
|
1835
1946
|
...state,
|
|
@@ -1846,14 +1957,21 @@ const loadContent = (state, savedState, workspaceUri = '') => {
|
|
|
1846
1957
|
currentViewletId: activeViewletId
|
|
1847
1958
|
} = state;
|
|
1848
1959
|
const savedViewletId = getSavedViewletId(savedState);
|
|
1849
|
-
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
|
+
}
|
|
1850
1966
|
let currentViewletId = savedViewletId;
|
|
1851
1967
|
if (!views.includes(currentViewletId)) {
|
|
1852
1968
|
currentViewletId = views.includes(activeViewletId) ? activeViewletId : views[0];
|
|
1853
1969
|
}
|
|
1854
1970
|
const loaded = {
|
|
1855
1971
|
...state,
|
|
1972
|
+
availableViews,
|
|
1856
1973
|
currentViewletId,
|
|
1974
|
+
hiddenViews: availableViews.filter(view => !views.includes(view)),
|
|
1857
1975
|
views
|
|
1858
1976
|
};
|
|
1859
1977
|
return openViewlet(loaded, currentViewletId);
|
|
@@ -1875,13 +1993,24 @@ const selectRaw = async (state, rawIndex) => {
|
|
|
1875
1993
|
|
|
1876
1994
|
const toggleView = async (state, name, uri = '') => {
|
|
1877
1995
|
const {
|
|
1996
|
+
availableViews,
|
|
1878
1997
|
currentViewletId,
|
|
1998
|
+
hiddenViews,
|
|
1879
1999
|
views
|
|
1880
2000
|
} = state;
|
|
1881
|
-
|
|
1882
|
-
if (index === -1) {
|
|
2001
|
+
if (!availableViews.includes(name)) {
|
|
1883
2002
|
return state;
|
|
1884
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);
|
|
1885
2014
|
if (name === currentViewletId) {
|
|
1886
2015
|
return state;
|
|
1887
2016
|
}
|
|
@@ -2201,6 +2330,7 @@ const HandleClickMaximize = 'handleClickMaximize';
|
|
|
2201
2330
|
const HandleClickUnmaximize = 'handleClickUnmaximize';
|
|
2202
2331
|
const HandleClickSelectTab = 'HandleClickSelectTab';
|
|
2203
2332
|
const HandleClickTab = 'HandleClickTab';
|
|
2333
|
+
const HandleTabContextMenu = 'HandleTabContextMenu';
|
|
2204
2334
|
|
|
2205
2335
|
const emptyObject = {};
|
|
2206
2336
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
@@ -2252,7 +2382,7 @@ const getGlobalActionsDom = state => {
|
|
|
2252
2382
|
className: IconButton,
|
|
2253
2383
|
onClick: maximizeOnClick,
|
|
2254
2384
|
title: maximizeLabel,
|
|
2255
|
-
type: Button
|
|
2385
|
+
type: Button$1
|
|
2256
2386
|
}, {
|
|
2257
2387
|
childCount: 0,
|
|
2258
2388
|
className: mergeClassNames(MaskIcon, maximizeIcon),
|
|
@@ -2263,7 +2393,7 @@ const getGlobalActionsDom = state => {
|
|
|
2263
2393
|
className: IconButton,
|
|
2264
2394
|
onClick: HandleClickClose,
|
|
2265
2395
|
title: close(),
|
|
2266
|
-
type: Button
|
|
2396
|
+
type: Button$1
|
|
2267
2397
|
}, closeIconNode];
|
|
2268
2398
|
};
|
|
2269
2399
|
|
|
@@ -2290,8 +2420,9 @@ const createPanelTab = (tab, badgeCount, isSelected) => {
|
|
|
2290
2420
|
className,
|
|
2291
2421
|
name: tab,
|
|
2292
2422
|
onClick: HandleClickTab,
|
|
2293
|
-
|
|
2294
|
-
|
|
2423
|
+
onContextMenu: HandleTabContextMenu,
|
|
2424
|
+
role: Tab$1,
|
|
2425
|
+
type: Button$1
|
|
2295
2426
|
};
|
|
2296
2427
|
const dom = [tabDom, text(label)];
|
|
2297
2428
|
if (badgeCount) {
|
|
@@ -2385,13 +2516,33 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
2385
2516
|
return commands;
|
|
2386
2517
|
};
|
|
2387
2518
|
|
|
2388
|
-
const
|
|
2519
|
+
const hideViewlet = async uid => {
|
|
2520
|
+
try {
|
|
2521
|
+
const commands = await invoke$1('Viewlet.hide', uid);
|
|
2522
|
+
if (Array.isArray(commands)) {
|
|
2523
|
+
return commands;
|
|
2524
|
+
}
|
|
2525
|
+
} catch (error) {
|
|
2526
|
+
// Older renderers do not support deferred container disposal yet.
|
|
2527
|
+
if (!(error instanceof Error) || !error.message.includes('Viewlet.hide') || !error.message.toLowerCase().includes('not found')) {
|
|
2528
|
+
throw error;
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
const commands = await invoke$1('Viewlet.dispose', uid, true);
|
|
2532
|
+
return Array.isArray(commands) ? commands : [];
|
|
2533
|
+
};
|
|
2534
|
+
|
|
2535
|
+
const render2 = async (uid, diffResult) => {
|
|
2389
2536
|
const {
|
|
2390
2537
|
newState,
|
|
2391
2538
|
oldState
|
|
2392
2539
|
} = get(uid);
|
|
2393
2540
|
set$1(uid, newState, newState);
|
|
2394
|
-
const commands = applyRender(oldState, newState, diffResult);
|
|
2541
|
+
const commands = [...applyRender(oldState, newState, diffResult)];
|
|
2542
|
+
// Keep referenced DOM nodes until the parent patches have replaced them.
|
|
2543
|
+
for (const childUid of take(uid)) {
|
|
2544
|
+
commands.push(...(await hideViewlet(childUid)));
|
|
2545
|
+
}
|
|
2395
2546
|
if (!isConnected()) return commands;
|
|
2396
2547
|
return renderDirect(uid, commands);
|
|
2397
2548
|
};
|
|
@@ -2416,6 +2567,10 @@ const renderEventListeners = () => {
|
|
|
2416
2567
|
}, {
|
|
2417
2568
|
name: HandleClickTab,
|
|
2418
2569
|
params: ['selectName', TargetName]
|
|
2570
|
+
}, {
|
|
2571
|
+
name: HandleTabContextMenu,
|
|
2572
|
+
params: ['handleTabContextMenu', Button, ClientX, ClientY],
|
|
2573
|
+
preventDefault: true
|
|
2419
2574
|
}];
|
|
2420
2575
|
};
|
|
2421
2576
|
|
|
@@ -2444,11 +2599,13 @@ const resize = async (state, dimensions) => {
|
|
|
2444
2599
|
const saveState = async state => {
|
|
2445
2600
|
const {
|
|
2446
2601
|
childUid,
|
|
2447
|
-
currentViewletId
|
|
2602
|
+
currentViewletId,
|
|
2603
|
+
hiddenViews
|
|
2448
2604
|
} = state;
|
|
2449
2605
|
await saveViewletState(childUid, currentViewletId);
|
|
2450
2606
|
return {
|
|
2451
|
-
currentViewletId
|
|
2607
|
+
currentViewletId,
|
|
2608
|
+
hiddenViews
|
|
2452
2609
|
};
|
|
2453
2610
|
};
|
|
2454
2611
|
|
|
@@ -2483,6 +2640,49 @@ const applyComponentState = (currentState, state) => {
|
|
|
2483
2640
|
};
|
|
2484
2641
|
const setComponentState = wrapCommand(applyComponentState);
|
|
2485
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
|
+
|
|
2486
2686
|
const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
|
|
2487
2687
|
const commandMap = {
|
|
2488
2688
|
'Panel.create': create,
|
|
@@ -2490,6 +2690,9 @@ const commandMap = {
|
|
|
2490
2690
|
'Panel.getCommandIds': getCommandIds,
|
|
2491
2691
|
'Panel.getComponentState': getComponentState,
|
|
2492
2692
|
'Panel.getCurrentViewletId': wrapGetter(getCurrentViewletId),
|
|
2693
|
+
'Panel.getMenuEntries': wrapGetter(getMenuEntries),
|
|
2694
|
+
'Panel.getMenuEntries2': wrapGetter(getMenuEntries),
|
|
2695
|
+
'Panel.getMenuIds': getMenuIds,
|
|
2493
2696
|
'Panel.handleBlur': wrapCommand(handleBlur),
|
|
2494
2697
|
'Panel.handleClickClose': wrapCommand(handleClickClose),
|
|
2495
2698
|
'Panel.handleClickMaximize': wrapCommand(handleClickMaximize),
|
|
@@ -2498,6 +2701,7 @@ const commandMap = {
|
|
|
2498
2701
|
'Panel.handleMessagePort': handleDirectMessagePort,
|
|
2499
2702
|
'Panel.handlePanelLayoutChanged': wrapCommand(handlePanelLayoutChanged),
|
|
2500
2703
|
'Panel.handleProblemsSummaryChange': wrapCommand(handleProblemsSummaryChange),
|
|
2704
|
+
'Panel.handleTabContextMenu': wrapCommand(handleTabContextMenu),
|
|
2501
2705
|
'Panel.loadContent': wrapCommand(loadContent),
|
|
2502
2706
|
'Panel.openViewlet': wrapCommand(openViewlet),
|
|
2503
2707
|
'Panel.render2': render2,
|
|
@@ -2510,7 +2714,8 @@ const commandMap = {
|
|
|
2510
2714
|
'Panel.setBadgeCount': wrapCommand(setBadgeCount),
|
|
2511
2715
|
'Panel.setComponentState': setComponentState,
|
|
2512
2716
|
'Panel.terminate': terminate,
|
|
2513
|
-
'Panel.toggleView': wrapCommand(toggleView)
|
|
2717
|
+
'Panel.toggleView': wrapCommand(toggleView),
|
|
2718
|
+
'Panel.toggleViewVisibility': wrapCommand(toggleViewVisibility)
|
|
2514
2719
|
};
|
|
2515
2720
|
|
|
2516
2721
|
const listen = async () => {
|