@lvce-editor/about-view 7.22.0 → 7.24.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];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/about-view",
3
- "version": "7.22.0",
3
+ "version": "7.24.0",
4
4
  "description": "About View Worker",
5
5
  "keywords": [
6
6
  "about-view"