@lvce-editor/menu-worker 2.0.0 → 2.1.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/menuWorkerMain.js +98 -58
- package/package.json +1 -1
package/dist/menuWorkerMain.js
CHANGED
|
@@ -785,7 +785,7 @@ const send = (transport, method, ...params) => {
|
|
|
785
785
|
const message = create$4(method, params);
|
|
786
786
|
transport.send(message);
|
|
787
787
|
};
|
|
788
|
-
const invoke$
|
|
788
|
+
const invoke$4 = (ipc, method, ...params) => {
|
|
789
789
|
return invokeHelper(ipc, method, params, false);
|
|
790
790
|
};
|
|
791
791
|
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
@@ -824,7 +824,7 @@ const createRpc = ipc => {
|
|
|
824
824
|
send(ipc, method, ...params);
|
|
825
825
|
},
|
|
826
826
|
invoke(method, ...params) {
|
|
827
|
-
return invoke$
|
|
827
|
+
return invoke$4(ipc, method, ...params);
|
|
828
828
|
},
|
|
829
829
|
invokeAndTransfer(method, ...params) {
|
|
830
830
|
return invokeAndTransfer$1(ipc, method, ...params);
|
|
@@ -1167,6 +1167,8 @@ const getKeyCodeString = keyCode => {
|
|
|
1167
1167
|
}
|
|
1168
1168
|
};
|
|
1169
1169
|
|
|
1170
|
+
const Script = 2;
|
|
1171
|
+
|
|
1170
1172
|
const CtrlCmd = 1 << 11 >>> 0;
|
|
1171
1173
|
const Shift = 1 << 10 >>> 0;
|
|
1172
1174
|
|
|
@@ -1190,6 +1192,7 @@ const parseKey = rawKey => {
|
|
|
1190
1192
|
};
|
|
1191
1193
|
|
|
1192
1194
|
const DebugWorker = 55;
|
|
1195
|
+
const RendererProcess = 1670;
|
|
1193
1196
|
const RendererWorker$1 = 1;
|
|
1194
1197
|
|
|
1195
1198
|
const rpcs = Object.create(null);
|
|
@@ -1224,6 +1227,9 @@ const create$1 = rpcId => {
|
|
|
1224
1227
|
};
|
|
1225
1228
|
};
|
|
1226
1229
|
|
|
1230
|
+
const {
|
|
1231
|
+
invoke: invoke$3} = create$1(RendererProcess);
|
|
1232
|
+
|
|
1227
1233
|
const {
|
|
1228
1234
|
invoke: invoke$2,
|
|
1229
1235
|
invokeAndTransfer,
|
|
@@ -1239,6 +1245,14 @@ const getFilePathElectron = async file => {
|
|
|
1239
1245
|
const showContextMenu = async (x, y, id, ...args) => {
|
|
1240
1246
|
return invoke$2('ContextMenu.show', x, y, id, ...args);
|
|
1241
1247
|
};
|
|
1248
|
+
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1249
|
+
number(uid);
|
|
1250
|
+
number(menuId);
|
|
1251
|
+
number(x);
|
|
1252
|
+
number(y);
|
|
1253
|
+
// @ts-ignore
|
|
1254
|
+
await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1255
|
+
};
|
|
1242
1256
|
const getElectronVersion = async () => {
|
|
1243
1257
|
return invoke$2('Process.getElectronVersion');
|
|
1244
1258
|
};
|
|
@@ -1354,6 +1368,9 @@ const getKeyBindings$1 = async () => {
|
|
|
1354
1368
|
const writeClipBoardText = async text => {
|
|
1355
1369
|
await invoke$2('ClipBoard.writeText', /* text */text);
|
|
1356
1370
|
};
|
|
1371
|
+
const readClipBoardText = async () => {
|
|
1372
|
+
return invoke$2('ClipBoard.readText');
|
|
1373
|
+
};
|
|
1357
1374
|
const writeClipBoardImage = async blob => {
|
|
1358
1375
|
// @ts-ignore
|
|
1359
1376
|
await invoke$2('ClipBoard.writeImage', /* text */blob);
|
|
@@ -1397,6 +1414,16 @@ const sendMessagePortToRendererProcess = async port => {
|
|
|
1397
1414
|
// @ts-ignore
|
|
1398
1415
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
|
|
1399
1416
|
};
|
|
1417
|
+
const sendMessagePortToTextMeasurementWorker = async port => {
|
|
1418
|
+
const command = 'TextMeasurement.handleMessagePort';
|
|
1419
|
+
// @ts-ignore
|
|
1420
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
1421
|
+
};
|
|
1422
|
+
const sendMessagePortToSourceControlWorker = async port => {
|
|
1423
|
+
const command = 'SourceControl.handleMessagePort';
|
|
1424
|
+
// @ts-ignore
|
|
1425
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
|
|
1426
|
+
};
|
|
1400
1427
|
const getPreference = async key => {
|
|
1401
1428
|
return await invoke$2('Preferences.get', key);
|
|
1402
1429
|
};
|
|
@@ -1468,7 +1495,7 @@ const openExtensionSearch = async () => {
|
|
|
1468
1495
|
};
|
|
1469
1496
|
const setExtensionsSearchValue = async searchValue => {
|
|
1470
1497
|
// @ts-ignore
|
|
1471
|
-
return invoke$2('Extensions.handleInput', searchValue);
|
|
1498
|
+
return invoke$2('Extensions.handleInput', searchValue, Script);
|
|
1472
1499
|
};
|
|
1473
1500
|
const openExternal = async uri => {
|
|
1474
1501
|
// @ts-ignore
|
|
@@ -1545,6 +1572,7 @@ const RendererWorker = {
|
|
|
1545
1572
|
openUri,
|
|
1546
1573
|
openUrl,
|
|
1547
1574
|
openWidget,
|
|
1575
|
+
readClipBoardText,
|
|
1548
1576
|
readFile,
|
|
1549
1577
|
registerMockRpc,
|
|
1550
1578
|
registerWebViewInterceptor,
|
|
@@ -1561,7 +1589,9 @@ const RendererWorker = {
|
|
|
1561
1589
|
sendMessagePortToMarkdownWorker,
|
|
1562
1590
|
sendMessagePortToRendererProcess,
|
|
1563
1591
|
sendMessagePortToSearchProcess,
|
|
1592
|
+
sendMessagePortToSourceControlWorker,
|
|
1564
1593
|
sendMessagePortToSyntaxHighlightingWorker,
|
|
1594
|
+
sendMessagePortToTextMeasurementWorker,
|
|
1565
1595
|
set: set$2,
|
|
1566
1596
|
setAdditionalFocus,
|
|
1567
1597
|
setColorTheme,
|
|
@@ -1570,6 +1600,7 @@ const RendererWorker = {
|
|
|
1570
1600
|
setWebViewPort,
|
|
1571
1601
|
setWorkspacePath,
|
|
1572
1602
|
showContextMenu,
|
|
1603
|
+
showContextMenu2,
|
|
1573
1604
|
showErrorDialog,
|
|
1574
1605
|
showMessageBox,
|
|
1575
1606
|
showSaveFilePicker,
|
|
@@ -1579,6 +1610,54 @@ const RendererWorker = {
|
|
|
1579
1610
|
writeClipBoardText
|
|
1580
1611
|
};
|
|
1581
1612
|
|
|
1613
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
1614
|
+
// TODO lazyload menuEntries and use Command.execute (maybe)
|
|
1615
|
+
|
|
1616
|
+
// TODO difference between focusing with mouse or keyboard
|
|
1617
|
+
// with mouse -> open submenu
|
|
1618
|
+
// with keyboard -> don't open submenu, only focus
|
|
1619
|
+
|
|
1620
|
+
// TODO this code seems a bit too complicated, maybe it can be simplified
|
|
1621
|
+
|
|
1622
|
+
const state$1 = {
|
|
1623
|
+
menus: [],
|
|
1624
|
+
latestTimeStamp: 0};
|
|
1625
|
+
const addMenuInternal = menu => {
|
|
1626
|
+
if (state$1.menus.length > 5) {
|
|
1627
|
+
throw new Error('too many menus');
|
|
1628
|
+
}
|
|
1629
|
+
state$1.menus.push(menu);
|
|
1630
|
+
return menu;
|
|
1631
|
+
};
|
|
1632
|
+
const getCount = () => {
|
|
1633
|
+
return state$1.menus.length;
|
|
1634
|
+
};
|
|
1635
|
+
const reset = () => {
|
|
1636
|
+
state$1.menus = [];
|
|
1637
|
+
};
|
|
1638
|
+
const get$1 = index => {
|
|
1639
|
+
return state$1.menus[index];
|
|
1640
|
+
};
|
|
1641
|
+
const set$1 = menus => {
|
|
1642
|
+
state$1.menus = menus;
|
|
1643
|
+
};
|
|
1644
|
+
const getAll = () => {
|
|
1645
|
+
return state$1.menus;
|
|
1646
|
+
};
|
|
1647
|
+
const setTimestamp = timestamp => {
|
|
1648
|
+
state$1.latestTimeStamp = timestamp;
|
|
1649
|
+
};
|
|
1650
|
+
const getLatestTimestamp = () => {
|
|
1651
|
+
return state$1.latestTimeStamp;
|
|
1652
|
+
};
|
|
1653
|
+
|
|
1654
|
+
const closeSubMenu = async () => {
|
|
1655
|
+
const menus = getAll();
|
|
1656
|
+
const parentMenu = menus.at(-1);
|
|
1657
|
+
// @ts-ignore
|
|
1658
|
+
await invoke$3(/* Menu.hideSubMenu */7903, /* parentIndex */parentMenu.focusedIndex);
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1582
1661
|
const matchesArgs = (a, b) => {
|
|
1583
1662
|
if (!a && !b) {
|
|
1584
1663
|
return true;
|
|
@@ -1615,7 +1694,7 @@ const invoke$1 = async (method, ...params) => {
|
|
|
1615
1694
|
await invoke$2('WebView.compatRendererProcessInvoke', method, ...params);
|
|
1616
1695
|
};
|
|
1617
1696
|
|
|
1618
|
-
const state
|
|
1697
|
+
const state = {
|
|
1619
1698
|
/**
|
|
1620
1699
|
* @type {any}
|
|
1621
1700
|
*/
|
|
@@ -1698,6 +1777,13 @@ const Terminal$1 = 14;
|
|
|
1698
1777
|
const TitleBar = 15;
|
|
1699
1778
|
const View$1 = 16;
|
|
1700
1779
|
|
|
1780
|
+
const menuEntrySeparator = {
|
|
1781
|
+
id: 'separator',
|
|
1782
|
+
label: '',
|
|
1783
|
+
flags: Separator$2,
|
|
1784
|
+
command: ''
|
|
1785
|
+
};
|
|
1786
|
+
|
|
1701
1787
|
const Separator$1 = 1;
|
|
1702
1788
|
const None = 0;
|
|
1703
1789
|
const SubMenu = 4;
|
|
@@ -1707,13 +1793,6 @@ const Disabled = 5;
|
|
|
1707
1793
|
const RestoreFocus = 6;
|
|
1708
1794
|
const Ignore = 7;
|
|
1709
1795
|
|
|
1710
|
-
const menuEntrySeparator = {
|
|
1711
|
-
id: 'separator',
|
|
1712
|
-
label: '',
|
|
1713
|
-
flags: Separator$1,
|
|
1714
|
-
command: ''
|
|
1715
|
-
};
|
|
1716
|
-
|
|
1717
1796
|
const id$9 = Edit$1;
|
|
1718
1797
|
const getMenuEntries$d = () => {
|
|
1719
1798
|
return [{
|
|
@@ -2193,7 +2272,7 @@ const getMenuEntries2 = async (uid, menuId, ...args) => {
|
|
|
2193
2272
|
};
|
|
2194
2273
|
|
|
2195
2274
|
const addKeyBindings = menuEntries => {
|
|
2196
|
-
const keyBindings = state
|
|
2275
|
+
const keyBindings = state.matchingKeyBindings;
|
|
2197
2276
|
const newMenuEntries = [];
|
|
2198
2277
|
for (const menuEntry of menuEntries) {
|
|
2199
2278
|
const keyBinding = getCommandKeyBinding(keyBindings, menuEntry.command, menuEntry.args);
|
|
@@ -2449,47 +2528,6 @@ const getVisible = (items, focusedIndex, expanded, level) => {
|
|
|
2449
2528
|
return visibleItems;
|
|
2450
2529
|
};
|
|
2451
2530
|
|
|
2452
|
-
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
2453
|
-
// TODO lazyload menuEntries and use Command.execute (maybe)
|
|
2454
|
-
|
|
2455
|
-
// TODO difference between focusing with mouse or keyboard
|
|
2456
|
-
// with mouse -> open submenu
|
|
2457
|
-
// with keyboard -> don't open submenu, only focus
|
|
2458
|
-
|
|
2459
|
-
// TODO this code seems a bit too complicated, maybe it can be simplified
|
|
2460
|
-
|
|
2461
|
-
const state = {
|
|
2462
|
-
menus: [],
|
|
2463
|
-
latestTimeStamp: 0};
|
|
2464
|
-
const addMenuInternal = menu => {
|
|
2465
|
-
if (state.menus.length > 5) {
|
|
2466
|
-
throw new Error('too many menus');
|
|
2467
|
-
}
|
|
2468
|
-
state.menus.push(menu);
|
|
2469
|
-
return menu;
|
|
2470
|
-
};
|
|
2471
|
-
const getCount = () => {
|
|
2472
|
-
return state.menus.length;
|
|
2473
|
-
};
|
|
2474
|
-
const reset = () => {
|
|
2475
|
-
state.menus = [];
|
|
2476
|
-
};
|
|
2477
|
-
const get$1 = index => {
|
|
2478
|
-
return state.menus[index];
|
|
2479
|
-
};
|
|
2480
|
-
const set$1 = menus => {
|
|
2481
|
-
state.menus = menus;
|
|
2482
|
-
};
|
|
2483
|
-
const getAll = () => {
|
|
2484
|
-
return state.menus;
|
|
2485
|
-
};
|
|
2486
|
-
const setTimestamp = timestamp => {
|
|
2487
|
-
state.latestTimeStamp = timestamp;
|
|
2488
|
-
};
|
|
2489
|
-
const getLatestTimestamp = () => {
|
|
2490
|
-
return state.latestTimeStamp;
|
|
2491
|
-
};
|
|
2492
|
-
|
|
2493
2531
|
// TODO lazyload menuEntries and use Command.execute (maybe)
|
|
2494
2532
|
const CONTEXT_MENU_ITEM_HEIGHT$2 = 26;
|
|
2495
2533
|
const CONTEXT_MENU_SEPARATOR_HEIGHT$2 = 11;
|
|
@@ -2976,6 +3014,12 @@ const hideSubMenus = async level => {
|
|
|
2976
3014
|
}
|
|
2977
3015
|
};
|
|
2978
3016
|
|
|
3017
|
+
/* eslint-disable @typescript-eslint/no-implied-eval */
|
|
3018
|
+
const MENU_DELAY_TRIANGLE = 300;
|
|
3019
|
+
const resolveAfterTimeout = fn => {
|
|
3020
|
+
setTimeout(fn, MENU_DELAY_TRIANGLE);
|
|
3021
|
+
};
|
|
3022
|
+
|
|
2979
3023
|
const showSubMenuAtEnter = async (level, index, enterX, enterY) => {
|
|
2980
3024
|
// TODO delete old menus
|
|
2981
3025
|
set$1(getAll().slice(0, level + 1));
|
|
@@ -3005,11 +3049,6 @@ const showSubMenu = async (level, index) => {
|
|
|
3005
3049
|
return showSubMenuAtEnter(level, index, -1, -1);
|
|
3006
3050
|
};
|
|
3007
3051
|
|
|
3008
|
-
/* eslint-disable @typescript-eslint/no-implied-eval */
|
|
3009
|
-
const MENU_DELAY_TRIANGLE = 300;
|
|
3010
|
-
const resolveAfterTimeout = fn => {
|
|
3011
|
-
setTimeout(fn, MENU_DELAY_TRIANGLE);
|
|
3012
|
-
};
|
|
3013
3052
|
const handleMouseEnter = async (level, index, enterX, enterY, enterTimeStamp) => {
|
|
3014
3053
|
setTimestamp(enterTimeStamp);
|
|
3015
3054
|
if (level >= getCount()) {
|
|
@@ -3256,6 +3295,7 @@ const commandMap = {
|
|
|
3256
3295
|
'Menu.focusFirst': focusFirst,
|
|
3257
3296
|
'Menu.focusIndex': focusIndex,
|
|
3258
3297
|
'Menu.focusLast': focusLast,
|
|
3298
|
+
'Menu.closeSubMenu': closeSubMenu,
|
|
3259
3299
|
'Menu.focusNext': focusNext,
|
|
3260
3300
|
'Menu.getCommands': getCommandIds,
|
|
3261
3301
|
'Menu.getHideCommands': getMenuHideCommands,
|