@lvce-editor/activity-bar-worker 1.29.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.
@@ -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,19 +1399,15 @@ const getMenuEntriesSettings = () => {
1347
1399
  }];
1348
1400
  };
1349
1401
 
1350
- const getMenuEntries = id => {
1351
- const tuple = get(id);
1352
- if (!tuple) {
1353
- return [];
1354
- }
1402
+ const getMenuEntries = (state, options) => {
1355
1403
  const {
1356
- newState
1357
- } = tuple;
1358
- switch (id) {
1404
+ menuId
1405
+ } = options;
1406
+ switch (menuId) {
1359
1407
  case ActivityBar$3:
1360
- return getMenuEntriesActivityBar(newState);
1408
+ return getMenuEntriesActivityBar(state);
1361
1409
  case ActivityBarAdditionalViews:
1362
- return getMenuEntriesAdditionalViews(newState);
1410
+ return getMenuEntriesAdditionalViews(state);
1363
1411
  case Settings$1:
1364
1412
  return getMenuEntriesSettings();
1365
1413
  default:
@@ -1408,8 +1456,7 @@ const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount, height)
1408
1456
  };
1409
1457
 
1410
1458
  const show2 = async (uid, menuId, x, y, args) => {
1411
- // @ts-ignore
1412
- await invoke('ContextMenu.show2', uid, menuId, x, y, args);
1459
+ await showContextMenu2(uid, menuId, x, y, args);
1413
1460
  };
1414
1461
 
1415
1462
  const handleClickAdditionalViews = async (state, eventX, eventY, viewletId) => {
@@ -2057,7 +2104,7 @@ const commandMap = {
2057
2104
  'ActivityBar.focusNone': wrapCommand(focusNone),
2058
2105
  'ActivityBar.getCommandIds': getCommandIds,
2059
2106
  'ActivityBar.getKeyBindings': getKeyBindings,
2060
- 'ActivityBar.getMenuEntries': getMenuEntries,
2107
+ 'ActivityBar.getMenuEntries': wrapGetter(getMenuEntries),
2061
2108
  'ActivityBar.getMenuEntryIds': getMenuEntryIds,
2062
2109
  'ActivityBar.handleBlur': wrapCommand(handleBlur),
2063
2110
  'ActivityBar.handleClick': wrapCommand(handleClick),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "1.29.0",
3
+ "version": "2.0.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",