@lvce-editor/status-bar-worker 3.15.1 → 3.16.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.
@@ -123,7 +123,7 @@ const {
123
123
  getCommandIds,
124
124
  getKeys,
125
125
  registerCommands,
126
- set: set$3,
126
+ set: set$5,
127
127
  wrapCommand,
128
128
  wrapGetter
129
129
  } = create$8();
@@ -139,7 +139,7 @@ const create$7 = (uid, uri, x, y, width, height, platform, assetDir) => {
139
139
  uid,
140
140
  warningCount: 0
141
141
  };
142
- set$3(uid, state, state);
142
+ set$5(uid, state, state);
143
143
  };
144
144
 
145
145
  const isEqual = (oldState, newState) => {
@@ -1244,7 +1244,7 @@ const createMockRpc = ({
1244
1244
  };
1245
1245
 
1246
1246
  const rpcs = Object.create(null);
1247
- const set$2 = (id, rpc) => {
1247
+ const set$4 = (id, rpc) => {
1248
1248
  rpcs[id] = rpc;
1249
1249
  };
1250
1250
  const get$1 = id => {
@@ -1277,7 +1277,7 @@ const create = rpcId => {
1277
1277
  const mockRpc = createMockRpc({
1278
1278
  commandMap
1279
1279
  });
1280
- set$2(rpcId, mockRpc);
1280
+ set$4(rpcId, mockRpc);
1281
1281
  // @ts-ignore
1282
1282
  mockRpc[Symbol.dispose] = () => {
1283
1283
  remove(rpcId);
@@ -1286,7 +1286,7 @@ const create = rpcId => {
1286
1286
  return mockRpc;
1287
1287
  },
1288
1288
  set(rpc) {
1289
- set$2(rpcId, rpc);
1289
+ set$4(rpcId, rpc);
1290
1290
  }
1291
1291
  };
1292
1292
  };
@@ -1307,47 +1307,54 @@ const ClientY = 'event.clientY';
1307
1307
  const TargetName = 'event.target.name';
1308
1308
 
1309
1309
  const ExtensionManagementWorker = 9006;
1310
+ const RendererProcess = 1670;
1310
1311
  const RendererWorker = 1;
1311
1312
 
1312
1313
  const SetDom2 = 'Viewlet.setDom2';
1314
+ const SetFocusContext = 'Viewlet.setFocusContext';
1313
1315
 
1314
1316
  const {
1315
- invoke: invoke$1,
1316
- set: set$1
1317
+ invoke: invoke$3,
1318
+ set: set$3
1317
1319
  } = create(ExtensionManagementWorker);
1318
1320
 
1319
1321
  const {
1320
- invoke,
1321
- set
1322
+ invoke: invoke$2,
1323
+ set: set$2
1324
+ } = create(RendererProcess);
1325
+
1326
+ const {
1327
+ invoke: invoke$1,
1328
+ set: set$1
1322
1329
  } = create(RendererWorker);
1323
1330
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1324
1331
  number(uid);
1325
1332
  number(menuId);
1326
1333
  number(x);
1327
1334
  number(y);
1328
- await invoke('ContextMenu.show2', uid, menuId, x, y, args);
1335
+ await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1329
1336
  };
1330
1337
  const getPreference = async key => {
1331
- return await invoke('Preferences.get', key);
1338
+ return await invoke$1('Preferences.get', key);
1332
1339
  };
1333
1340
 
1334
1341
  const handleClickExtensionStatusBarItem = async name => {
1335
1342
  try {
1336
- await invoke$1('Extensions.executeCommand', name);
1343
+ await invoke$3('Extensions.executeCommand', name);
1337
1344
  } catch (error) {
1338
1345
  console.error(new VError(error, `Failed to execute status bar command: ${name}`));
1339
1346
  }
1340
1347
  };
1341
1348
 
1342
1349
  const handleClickNotification = async () => {
1343
- await invoke('Viewlet.openWidget', 'NotificationCenter');
1350
+ await invoke$1('Viewlet.openWidget', 'NotificationCenter');
1344
1351
  };
1345
1352
 
1346
1353
  const handleClickProblems = async () => {
1347
1354
  // @ts-ignore
1348
- await invoke('Layout.showPanel');
1355
+ await invoke$1('Layout.showPanel');
1349
1356
  // @ts-ignore
1350
- await invoke('Panel.toggleView', 'Problems');
1357
+ await invoke$1('Panel.toggleView', 'Problems');
1351
1358
  };
1352
1359
 
1353
1360
  const Notifications = 'Notifications';
@@ -1390,6 +1397,31 @@ const handleContextMenu = async (state, button, x, y) => {
1390
1397
  return state;
1391
1398
  };
1392
1399
 
1400
+ const handleExtensionManagementChange = async () => {
1401
+ for (const uid of getKeys()) {
1402
+ await invoke$1('Viewlet.executeViewletCommand', uid, 'handleItemsChanged');
1403
+ }
1404
+ };
1405
+
1406
+ const handleNotificationCountChangedAll = async count => {
1407
+ for (const uid of getKeys()) {
1408
+ await invoke$1('Viewlet.executeViewletCommand', uid, 'handleNotificationCountChanged', count);
1409
+ }
1410
+ };
1411
+
1412
+ const commandMap$1 = {
1413
+ 'StatusBar.handleChange': handleExtensionManagementChange,
1414
+ 'StatusBar.handleNotificationCountChanged': handleNotificationCountChangedAll
1415
+ };
1416
+
1417
+ const handleExtensionManagementMessagePort = async port => {
1418
+ const rpc = await create$2({
1419
+ commandMap: commandMap$1,
1420
+ messagePort: port
1421
+ });
1422
+ set$3(rpc);
1423
+ };
1424
+
1393
1425
  const getAriaLabel = count => {
1394
1426
  if (count === 0) {
1395
1427
  return 'No Notifications';
@@ -1473,8 +1505,8 @@ const getBuiltinStatusBarItems = async (errorCount, warningCount, {
1473
1505
  };
1474
1506
 
1475
1507
  const getExtensionStatusBarItems = async (assetDir, platform) => {
1476
- await invoke$1('Extensions.activateByEvent', 'onStatusBarItem', assetDir, platform);
1477
- return invoke$1('Extensions.getStatusBarItems');
1508
+ await invoke$3('Extensions.activateByEvent', 'onStatusBarItem', assetDir, platform);
1509
+ return invoke$3('Extensions.getStatusBarItems');
1478
1510
  };
1479
1511
 
1480
1512
  const toStatusBarItem = uiStatusBarItem => {
@@ -1540,7 +1572,7 @@ const toUiStatusBarItems = statusBarItems => {
1540
1572
 
1541
1573
  const getNotificationCount = async () => {
1542
1574
  try {
1543
- return await invoke$1('Extensions.getNotificationCount');
1575
+ return await invoke$3('Extensions.getNotificationCount');
1544
1576
  } catch {
1545
1577
  return 0;
1546
1578
  }
@@ -1595,22 +1627,29 @@ const handleItemsChanged = async state => {
1595
1627
  return handleExtensionsChanged(state);
1596
1628
  };
1597
1629
 
1598
- const handleExtensionManagementChange = async () => {
1599
- const uids = getKeys();
1600
- for (const uid of uids) {
1601
- const {
1602
- newState,
1603
- oldState
1604
- } = get$3(uid);
1605
- const newerState = await handleItemsChanged(newState);
1606
- if (newState === newerState || oldState === newerState) {
1607
- continue;
1608
- }
1609
- set$3(uid, oldState, {
1610
- ...newState,
1611
- ...newerState
1612
- });
1613
- }
1630
+ const state = {
1631
+ connected: false
1632
+ };
1633
+ const isConnected = () => {
1634
+ const {
1635
+ connected
1636
+ } = state;
1637
+ return connected;
1638
+ };
1639
+ const invoke = (method, ...params) => {
1640
+ return invoke$2(method, ...params);
1641
+ };
1642
+ const set = rpc => {
1643
+ set$2(rpc);
1644
+ state.connected = true;
1645
+ };
1646
+
1647
+ const handleMessagePort = async port => {
1648
+ const rpc = await create$2({
1649
+ commandMap: {},
1650
+ messagePort: port
1651
+ });
1652
+ set(rpc);
1614
1653
  };
1615
1654
 
1616
1655
  const handleNotificationCountChanged = (state, count) => {
@@ -1631,33 +1670,6 @@ const handleNotificationCountChanged = (state, count) => {
1631
1670
  };
1632
1671
  };
1633
1672
 
1634
- const handleNotificationCountChangedAll = async count => {
1635
- for (const uid of getKeys()) {
1636
- const {
1637
- newState,
1638
- oldState
1639
- } = get$3(uid);
1640
- const newerState = handleNotificationCountChanged(newState, count);
1641
- if (newState === newerState || oldState === newerState) {
1642
- continue;
1643
- }
1644
- set$3(uid, oldState, newerState);
1645
- }
1646
- };
1647
-
1648
- const commandMap$1 = {
1649
- 'StatusBar.handleChange': handleExtensionManagementChange,
1650
- 'StatusBar.handleNotificationCountChanged': handleNotificationCountChangedAll
1651
- };
1652
-
1653
- const handleExtensionManagementMessagePort = async port => {
1654
- const rpc = await create$2({
1655
- commandMap: commandMap$1,
1656
- messagePort: port
1657
- });
1658
- set$1(rpc);
1659
- };
1660
-
1661
1673
  const handleProblemsSummaryChange = (state, summary) => {
1662
1674
  const {
1663
1675
  errorCount: oldErrorCount,
@@ -1918,14 +1930,23 @@ const applyRender = (oldState, newState, diffResult) => {
1918
1930
  return commands;
1919
1931
  };
1920
1932
 
1933
+ const renderDirect = async (uid, commands) => {
1934
+ const rendererWorkerCommands = commands.filter(command => command[0] === SetFocusContext);
1935
+ const rendererProcessCommands = commands.filter(command => command[0] !== SetFocusContext);
1936
+ const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
1937
+ return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
1938
+ };
1921
1939
  const render2 = (uid, diffResult) => {
1922
1940
  const {
1923
1941
  newState,
1924
1942
  oldState
1925
1943
  } = get$3(uid);
1926
- set$3(uid, newState, newState);
1944
+ set$5(uid, newState, newState);
1927
1945
  const commands = applyRender(oldState, newState, diffResult);
1928
- return commands;
1946
+ if (!isConnected()) {
1947
+ return commands;
1948
+ }
1949
+ return renderDirect(uid, commands);
1929
1950
  };
1930
1951
 
1931
1952
  const renderEventListeners = () => {
@@ -1967,6 +1988,7 @@ const commandMap = {
1967
1988
  'StatusBar.handleExtensionManagementMessagePort': handleExtensionManagementMessagePort,
1968
1989
  'StatusBar.handleExtensionsChanged': wrapCommand(handleExtensionsChanged),
1969
1990
  'StatusBar.handleItemsChanged': wrapCommand(handleItemsChanged),
1991
+ 'StatusBar.handleMessagePort': handleMessagePort,
1970
1992
  'StatusBar.handleNotificationCountChanged': wrapCommand(handleNotificationCountChanged),
1971
1993
  'StatusBar.handleProblemsSummaryChange': wrapCommand(handleProblemsSummaryChange),
1972
1994
  'StatusBar.initialize': initialize,
@@ -1985,7 +2007,7 @@ const initializeRenderWorker = async () => {
1985
2007
  const rpc = await create$1({
1986
2008
  commandMap: commandMap
1987
2009
  });
1988
- set(rpc);
2010
+ set$1(rpc);
1989
2011
  };
1990
2012
 
1991
2013
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "3.15.1",
3
+ "version": "3.16.0",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",