@lvce-editor/status-bar-worker 2.6.0 → 3.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.
@@ -121,8 +121,9 @@ const terminate = () => {
121
121
  const {
122
122
  get: get$3,
123
123
  getCommandIds,
124
+ getKeys: getKeys$1,
124
125
  registerCommands,
125
- set: set$3,
126
+ set: set$4,
126
127
  wrapCommand,
127
128
  wrapGetter
128
129
  } = create$a();
@@ -138,7 +139,7 @@ const create$9 = (uid, uri, x, y, width, height, platform, assetDir) => {
138
139
  uid,
139
140
  warningCount: 0
140
141
  };
141
- set$3(uid, state, state);
142
+ set$4(uid, state, state);
142
143
  };
143
144
 
144
145
  const isEqual = (oldState, newState) => {
@@ -239,6 +240,49 @@ class VError extends Error {
239
240
  }
240
241
  }
241
242
 
243
+ class AssertionError extends Error {
244
+ constructor(message) {
245
+ super(message);
246
+ this.name = 'AssertionError';
247
+ }
248
+ }
249
+ const Object$1 = 1;
250
+ const Number$1 = 2;
251
+ const Array$1 = 3;
252
+ const String = 4;
253
+ const Boolean$1 = 5;
254
+ const Function = 6;
255
+ const Null = 7;
256
+ const Unknown = 8;
257
+ const getType = value => {
258
+ switch (typeof value) {
259
+ case 'number':
260
+ return Number$1;
261
+ case 'function':
262
+ return Function;
263
+ case 'string':
264
+ return String;
265
+ case 'object':
266
+ if (value === null) {
267
+ return Null;
268
+ }
269
+ if (Array.isArray(value)) {
270
+ return Array$1;
271
+ }
272
+ return Object$1;
273
+ case 'boolean':
274
+ return Boolean$1;
275
+ default:
276
+ return Unknown;
277
+ }
278
+ };
279
+ const number = value => {
280
+ const type = getType(value);
281
+ if (type !== Number$1) {
282
+ throw new AssertionError('expected value to be of type number');
283
+ }
284
+ };
285
+
242
286
  const isMessagePort = value => {
243
287
  return value && value instanceof MessagePort;
244
288
  };
@@ -1212,7 +1256,7 @@ const createMockRpc = ({
1212
1256
  };
1213
1257
 
1214
1258
  const rpcs = Object.create(null);
1215
- const set$2 = (id, rpc) => {
1259
+ const set$3 = (id, rpc) => {
1216
1260
  rpcs[id] = rpc;
1217
1261
  };
1218
1262
  const get$1 = id => {
@@ -1245,7 +1289,7 @@ const create = rpcId => {
1245
1289
  const mockRpc = createMockRpc({
1246
1290
  commandMap
1247
1291
  });
1248
- set$2(rpcId, mockRpc);
1292
+ set$3(rpcId, mockRpc);
1249
1293
  // @ts-ignore
1250
1294
  mockRpc[Symbol.dispose] = () => {
1251
1295
  remove(rpcId);
@@ -1254,47 +1298,60 @@ const create = rpcId => {
1254
1298
  return mockRpc;
1255
1299
  },
1256
1300
  set(rpc) {
1257
- set$2(rpcId, rpc);
1301
+ set$3(rpcId, rpc);
1258
1302
  }
1259
1303
  };
1260
1304
  };
1261
1305
 
1262
- const Button$1 = 'button';
1306
+ const Button$2 = 'button';
1263
1307
  const Status = 'status';
1264
1308
 
1265
1309
  const MaskIcon = 'MaskIcon';
1266
1310
 
1267
- const Button = 1;
1311
+ const Button$1 = 1;
1268
1312
  const Div = 4;
1269
1313
  const Span = 8;
1270
1314
  const Text = 12;
1271
1315
  const Reference = 100;
1272
1316
 
1317
+ const Button = 'event.button';
1318
+ const ClientX = 'event.clientX';
1319
+ const ClientY = 'event.clientY';
1273
1320
  const TargetName = 'event.target.name';
1274
1321
 
1275
1322
  const ExtensionHostWorker = 44;
1323
+ const ExtensionManagementWorker = 9006;
1276
1324
  const RendererWorker = 1;
1277
1325
 
1278
1326
  const SetDom2 = 'Viewlet.setDom2';
1279
1327
  const SetPatches = 'Viewlet.setPatches';
1280
1328
 
1329
+ const {
1330
+ invoke: invoke$2,
1331
+ set: set$2
1332
+ } = create(ExtensionHostWorker);
1333
+
1281
1334
  const {
1282
1335
  invoke: invoke$1,
1283
1336
  set: set$1
1284
- } = create(ExtensionHostWorker);
1337
+ } = create(ExtensionManagementWorker);
1285
1338
 
1286
1339
  const {
1287
1340
  invoke,
1288
1341
  invokeAndTransfer,
1289
1342
  set
1290
1343
  } = create(RendererWorker);
1344
+ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1345
+ number(uid);
1346
+ number(menuId);
1347
+ number(x);
1348
+ number(y);
1349
+ await invoke('ContextMenu.show2', uid, menuId, x, y, args);
1350
+ };
1291
1351
  const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1292
1352
  const command = 'HandleMessagePort.handleMessagePort2';
1293
1353
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1294
1354
  };
1295
- const activateByEvent$1 = (event, assetDir, platform) => {
1296
- return invoke('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
1297
- };
1298
1355
  const getPreference = async key => {
1299
1356
  return await invoke('Preferences.get', key);
1300
1357
  };
@@ -1305,7 +1362,7 @@ const handleClickExtensionStatusBarItem = async name => {
1305
1362
 
1306
1363
  try {
1307
1364
  // @ts-ignore
1308
- await invoke$1(`ExtensionHostStatusBar.executeCommand`, name);
1365
+ await invoke$2(`ExtensionHostStatusBar.executeCommand`, name);
1309
1366
  } catch (error) {
1310
1367
  console.error(new VError(error, `Failed to execute status bar command: ${name}`));
1311
1368
  }
@@ -1349,7 +1406,16 @@ const handleClick = async (state, name) => {
1349
1406
  return state;
1350
1407
  };
1351
1408
 
1352
- const handleContextMenu = async state => {
1409
+ const show2 = async (uid, menuId, x, y, args) => {
1410
+ await showContextMenu2(uid, menuId, x, y, args);
1411
+ };
1412
+
1413
+ const StatusBar = 31;
1414
+
1415
+ const handleContextMenu = async (state, button, x, y) => {
1416
+ await show2(state.uid, StatusBar, x, y, {
1417
+ menuId: StatusBar
1418
+ });
1353
1419
  return state;
1354
1420
  };
1355
1421
 
@@ -1358,12 +1424,10 @@ const OnStatusBarItem = 'onStatusBarItem';
1358
1424
  const GetStatusBarItems = 'ExtensionHost.getStatusBarItems2';
1359
1425
 
1360
1426
  const activateByEvent = (event, assetDir, platform) => {
1361
- // @ts-ignore
1362
- return activateByEvent$1(event, assetDir, platform);
1427
+ return invoke$1('Extensions.activateByEvent', event, assetDir, platform);
1363
1428
  };
1364
1429
  const getStatusBarItems$2 = () => {
1365
- // @ts-ignore
1366
- return invoke('ExtensionHostManagement.getStatusBarItems');
1430
+ return invoke$1('Extensions.getStatusBarItems');
1367
1431
  };
1368
1432
 
1369
1433
  const executeProviders = async ({
@@ -1378,7 +1442,7 @@ const executeProviders = async ({
1378
1442
  }) => {
1379
1443
  await activateByEvent(event, assetDir, platform);
1380
1444
  // @ts-ignore
1381
- const result = await invoke$1(method, ...params);
1445
+ const result = await invoke$2(method, ...params);
1382
1446
  return result;
1383
1447
  };
1384
1448
 
@@ -1536,7 +1600,6 @@ const getStatusBarItems = async ({
1536
1600
  return [];
1537
1601
  }
1538
1602
  await activateByEvent('onStatusBarItem', assetDir, platform);
1539
- await activateByEvent('onSourceControl', assetDir, platform);
1540
1603
  const extensionStatusBarItems = await getStatusBarItems$1(assetDir, platform);
1541
1604
  const uiStatusBarItems = toUiStatusBarItems(extensionStatusBarItems);
1542
1605
  const extraItems = await getBuiltinStatusBarItems(errorCount, warningCount, {
@@ -1573,6 +1636,36 @@ const handleItemsChanged = async state => {
1573
1636
  return handleExtensionsChanged(state);
1574
1637
  };
1575
1638
 
1639
+ const handleExtensionManagementChange = async () => {
1640
+ const uids = getKeys$1();
1641
+ for (const uid of uids) {
1642
+ const {
1643
+ newState,
1644
+ oldState
1645
+ } = get$3(uid);
1646
+ const newerState = await handleItemsChanged(newState);
1647
+ if (newState === newerState || oldState === newerState) {
1648
+ continue;
1649
+ }
1650
+ set$4(uid, oldState, {
1651
+ ...newState,
1652
+ ...newerState
1653
+ });
1654
+ }
1655
+ };
1656
+
1657
+ const commandMap$1 = {
1658
+ 'StatusBar.handleChange': handleExtensionManagementChange
1659
+ };
1660
+
1661
+ const handleExtensionManagementMessagePort = async port => {
1662
+ const rpc = await create$4({
1663
+ commandMap: commandMap$1,
1664
+ messagePort: port
1665
+ });
1666
+ set$1(rpc);
1667
+ };
1668
+
1576
1669
  const id = 7201;
1577
1670
  const sendMessagePortToExtensionHostWorker = async port => {
1578
1671
  await sendMessagePortToExtensionHostWorker$1(port, id);
@@ -1583,7 +1676,7 @@ const initializeExtensionHostWorker = async () => {
1583
1676
  commandMap: {},
1584
1677
  send: sendMessagePortToExtensionHostWorker
1585
1678
  });
1586
- set$1(rpc);
1679
+ set$2(rpc);
1587
1680
  };
1588
1681
 
1589
1682
  const initialize = async () => {
@@ -1996,10 +2089,10 @@ const getStatusBarItemVirtualDom = statusBarItem => {
1996
2089
  childCount: elements.length,
1997
2090
  className: StatusBarItem,
1998
2091
  name,
1999
- role: Button$1,
2092
+ role: Button$2,
2000
2093
  tabIndex: -1,
2001
2094
  title: tooltip,
2002
- type: Button
2095
+ type: Button$1
2003
2096
  };
2004
2097
  return [buttonNode, ...elementNodes];
2005
2098
  };
@@ -2094,7 +2187,7 @@ const render2 = (uid, diffResult) => {
2094
2187
  newState,
2095
2188
  oldState
2096
2189
  } = get$3(uid);
2097
- set$3(uid, newState, newState);
2190
+ set$4(uid, newState, newState);
2098
2191
  const commands = applyRender(oldState, newState, diffResult);
2099
2192
  return commands;
2100
2193
  };
@@ -2102,7 +2195,7 @@ const render2 = (uid, diffResult) => {
2102
2195
  const renderEventListeners = () => {
2103
2196
  return [{
2104
2197
  name: HandleContextMenu,
2105
- params: ['handleContextMenu'],
2198
+ params: ['handleContextMenu', Button, ClientX, ClientY],
2106
2199
  preventDefault: true
2107
2200
  }, {
2108
2201
  name: HandleClick,
@@ -2135,6 +2228,7 @@ const commandMap = {
2135
2228
  'StatusBar.handleChange': wrapCommand(handleItemsChanged),
2136
2229
  'StatusBar.handleClick': wrapCommand(handleClick),
2137
2230
  'StatusBar.handleContextMenu': wrapCommand(handleContextMenu),
2231
+ 'StatusBar.handleExtensionManagementMessagePort': handleExtensionManagementMessagePort,
2138
2232
  'StatusBar.handleExtensionsChanged': wrapCommand(handleExtensionsChanged),
2139
2233
  'StatusBar.handleItemsChanged': wrapCommand(handleItemsChanged),
2140
2234
  'StatusBar.initialize': initialize,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "2.6.0",
3
+ "version": "3.1.0",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",