@lvce-editor/activity-bar-worker 1.30.0 → 2.0.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 +58 -14
- package/package.json +1 -1
|
@@ -54,6 +54,49 @@ class VError extends Error {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
class AssertionError extends Error {
|
|
58
|
+
constructor(message) {
|
|
59
|
+
super(message);
|
|
60
|
+
this.name = 'AssertionError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const Object$1 = 1;
|
|
64
|
+
const Number$1 = 2;
|
|
65
|
+
const Array$1 = 3;
|
|
66
|
+
const String = 4;
|
|
67
|
+
const Boolean$1 = 5;
|
|
68
|
+
const Function = 6;
|
|
69
|
+
const Null = 7;
|
|
70
|
+
const Unknown = 8;
|
|
71
|
+
const getType = value => {
|
|
72
|
+
switch (typeof value) {
|
|
73
|
+
case 'number':
|
|
74
|
+
return Number$1;
|
|
75
|
+
case 'function':
|
|
76
|
+
return Function;
|
|
77
|
+
case 'string':
|
|
78
|
+
return String;
|
|
79
|
+
case 'object':
|
|
80
|
+
if (value === null) {
|
|
81
|
+
return Null;
|
|
82
|
+
}
|
|
83
|
+
if (Array.isArray(value)) {
|
|
84
|
+
return Array$1;
|
|
85
|
+
}
|
|
86
|
+
return Object$1;
|
|
87
|
+
case 'boolean':
|
|
88
|
+
return Boolean$1;
|
|
89
|
+
default:
|
|
90
|
+
return Unknown;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const number = value => {
|
|
94
|
+
const type = getType(value);
|
|
95
|
+
if (type !== Number$1) {
|
|
96
|
+
throw new AssertionError('expected value to be of type number');
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
57
100
|
const isMessagePort = value => {
|
|
58
101
|
return value && value instanceof MessagePort;
|
|
59
102
|
};
|
|
@@ -913,6 +956,14 @@ const create$2 = rpcId => {
|
|
|
913
956
|
const {
|
|
914
957
|
invoke,
|
|
915
958
|
set: set$1} = create$2(RendererWorker);
|
|
959
|
+
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
960
|
+
number(uid);
|
|
961
|
+
number(menuId);
|
|
962
|
+
number(x);
|
|
963
|
+
number(y);
|
|
964
|
+
// @ts-ignore
|
|
965
|
+
await invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
966
|
+
};
|
|
916
967
|
|
|
917
968
|
const toCommandId = key => {
|
|
918
969
|
const dotIndex = key.indexOf('.');
|
|
@@ -947,10 +998,11 @@ const create$1 = () => {
|
|
|
947
998
|
wrapCommand(fn) {
|
|
948
999
|
const wrapped = async (uid, ...args) => {
|
|
949
1000
|
const {
|
|
1001
|
+
oldState,
|
|
950
1002
|
newState
|
|
951
1003
|
} = states[uid];
|
|
952
1004
|
const newerState = await fn(newState, ...args);
|
|
953
|
-
if (newState === newerState) {
|
|
1005
|
+
if (oldState === newerState || newState === newerState) {
|
|
954
1006
|
return;
|
|
955
1007
|
}
|
|
956
1008
|
const latest = states[uid];
|
|
@@ -1347,22 +1399,15 @@ const getMenuEntriesSettings = () => {
|
|
|
1347
1399
|
}];
|
|
1348
1400
|
};
|
|
1349
1401
|
|
|
1350
|
-
const getMenuEntries = (
|
|
1351
|
-
const tuple = get(id);
|
|
1352
|
-
if (!tuple) {
|
|
1353
|
-
return [];
|
|
1354
|
-
}
|
|
1355
|
-
const {
|
|
1356
|
-
newState
|
|
1357
|
-
} = tuple;
|
|
1402
|
+
const getMenuEntries = (state, options) => {
|
|
1358
1403
|
const {
|
|
1359
1404
|
menuId
|
|
1360
1405
|
} = options;
|
|
1361
1406
|
switch (menuId) {
|
|
1362
1407
|
case ActivityBar$3:
|
|
1363
|
-
return getMenuEntriesActivityBar(
|
|
1408
|
+
return getMenuEntriesActivityBar(state);
|
|
1364
1409
|
case ActivityBarAdditionalViews:
|
|
1365
|
-
return getMenuEntriesAdditionalViews(
|
|
1410
|
+
return getMenuEntriesAdditionalViews(state);
|
|
1366
1411
|
case Settings$1:
|
|
1367
1412
|
return getMenuEntriesSettings();
|
|
1368
1413
|
default:
|
|
@@ -1411,8 +1456,7 @@ const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount, height)
|
|
|
1411
1456
|
};
|
|
1412
1457
|
|
|
1413
1458
|
const show2 = async (uid, menuId, x, y, args) => {
|
|
1414
|
-
|
|
1415
|
-
await invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1459
|
+
await showContextMenu2(uid, menuId, x, y, args);
|
|
1416
1460
|
};
|
|
1417
1461
|
|
|
1418
1462
|
const handleClickAdditionalViews = async (state, eventX, eventY, viewletId) => {
|
|
@@ -2060,7 +2104,7 @@ const commandMap = {
|
|
|
2060
2104
|
'ActivityBar.focusNone': wrapCommand(focusNone),
|
|
2061
2105
|
'ActivityBar.getCommandIds': getCommandIds,
|
|
2062
2106
|
'ActivityBar.getKeyBindings': getKeyBindings,
|
|
2063
|
-
'ActivityBar.getMenuEntries': getMenuEntries,
|
|
2107
|
+
'ActivityBar.getMenuEntries': wrapGetter(getMenuEntries),
|
|
2064
2108
|
'ActivityBar.getMenuEntryIds': getMenuEntryIds,
|
|
2065
2109
|
'ActivityBar.handleBlur': wrapCommand(handleBlur),
|
|
2066
2110
|
'ActivityBar.handleClick': wrapCommand(handleClick),
|