@lvce-editor/about-view 7.21.0 → 7.23.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.
@@ -1372,7 +1372,8 @@ const create$1 = () => {
1372
1372
  const commandQueues = new Map();
1373
1373
  const generations = Object.create(null);
1374
1374
  const states = Object.create(null);
1375
- const commandMapRef = {};
1375
+ const commandMapRef = Object.create(null);
1376
+ const commandsById = Object.create(null);
1376
1377
  const getGeneration = uid => generations[uid] || 0;
1377
1378
  const isCurrentGeneration = (uid, generation) => {
1378
1379
  return states[uid] !== undefined && getGeneration(uid) === generation;
@@ -1434,6 +1435,18 @@ const create$1 = () => {
1434
1435
  delete states[key];
1435
1436
  }
1436
1437
  },
1438
+ createDirectEventCommandMap(requestRender) {
1439
+ return {
1440
+ async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
1441
+ const fn = commandsById[command];
1442
+ if (!fn) {
1443
+ throw new Error(`Viewlet command not found: ${command}`);
1444
+ }
1445
+ await fn(uid, ...args);
1446
+ await requestRender(uid);
1447
+ }
1448
+ };
1449
+ },
1437
1450
  diff(uid, modules, numbers) {
1438
1451
  const {
1439
1452
  oldState,
@@ -1465,6 +1478,9 @@ const create$1 = () => {
1465
1478
  },
1466
1479
  registerCommands(commandMap) {
1467
1480
  Object.assign(commandMapRef, commandMap);
1481
+ for (const [key, fn] of Object.entries(commandMap)) {
1482
+ commandsById[toCommandId(key)] = fn;
1483
+ }
1468
1484
  },
1469
1485
  set(uid, oldState, newState, scheduledState) {
1470
1486
  const current = states[uid];
@@ -1851,7 +1867,7 @@ const set = rpc => {
1851
1867
  state.connected = true;
1852
1868
  };
1853
1869
 
1854
- const handleMessagePort = async (port, viewletCommandMap) => {
1870
+ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
1855
1871
  const executeViewletCommand = async (uid, command, ...args) => {
1856
1872
  const fn = viewletCommandMap[`About.${command}`];
1857
1873
  if (typeof fn !== 'function') {
@@ -1866,7 +1882,9 @@ const handleMessagePort = async (port, viewletCommandMap) => {
1866
1882
  },
1867
1883
  messagePort: port
1868
1884
  });
1869
- set(rpc);
1885
+ if (setAsRendererProcess) {
1886
+ set(rpc);
1887
+ }
1870
1888
  };
1871
1889
 
1872
1890
  const OneSecondAgo = '1 second ago';
@@ -2546,7 +2564,7 @@ const showAbout = async platform => {
2546
2564
  await fn();
2547
2565
  };
2548
2566
 
2549
- const handleDirectMessagePort = port => handleMessagePort(port, commandMap);
2567
+ const handleDirectMessagePort = (port, setAsRendererProcess) => handleMessagePort(port, commandMap, setAsRendererProcess);
2550
2568
  const commandMap = {
2551
2569
  'About.create': create,
2552
2570
  'About.diff2': diff2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/about-view",
3
- "version": "7.21.0",
3
+ "version": "7.23.0",
4
4
  "description": "About View Worker",
5
5
  "keywords": [
6
6
  "about-view"