@lvce-editor/extension-management-worker 4.31.3 → 4.31.5

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.
@@ -581,12 +581,12 @@ const IpcParentWithWebSocket$1 = {
581
581
  wrap
582
582
  };
583
583
 
584
- class CommandNotFoundError extends Error {
584
+ let CommandNotFoundError$1 = class CommandNotFoundError extends Error {
585
585
  constructor(command) {
586
586
  super(`Command not found ${command}`);
587
587
  this.name = 'CommandNotFoundError';
588
588
  }
589
- }
589
+ };
590
590
  const commands = Object.create(null);
591
591
  const register = commandMap => {
592
592
  Object.assign(commands, commandMap);
@@ -597,7 +597,7 @@ const getCommand = key => {
597
597
  const execute = (command, ...args) => {
598
598
  const fn = getCommand(command);
599
599
  if (!fn) {
600
- throw new CommandNotFoundError(command);
600
+ throw new CommandNotFoundError$1(command);
601
601
  }
602
602
  return fn(...args);
603
603
  };
@@ -1642,6 +1642,14 @@ const getNodeRpcInfo = async (extensionId, rpcId) => {
1642
1642
  };
1643
1643
  };
1644
1644
 
1645
+ class CommandNotFoundError extends Error {
1646
+ constructor(command) {
1647
+ super(`Command not found ${command}`);
1648
+ Object.defineProperty(this, 'name', {
1649
+ value: 'CommandNotFoundError'
1650
+ });
1651
+ }
1652
+ }
1645
1653
  const createExtensionCommandMap = extensionId => {
1646
1654
  return {
1647
1655
  ...commandMapRef,
@@ -1650,6 +1658,15 @@ const createExtensionCommandMap = extensionId => {
1650
1658
  }
1651
1659
  };
1652
1660
  };
1661
+ const createExtensionCommandExecutor = commandMap => {
1662
+ return (method, ...params) => {
1663
+ const command = commandMap[method];
1664
+ if (!command) {
1665
+ throw new CommandNotFoundError(method);
1666
+ }
1667
+ return command(...params);
1668
+ };
1669
+ };
1653
1670
 
1654
1671
  const rpcs$1 = Object.create(null);
1655
1672
  const get$3 = extensionId => {
@@ -1670,15 +1687,25 @@ const invokeAndTransfer = (method, ...params) => {
1670
1687
  return invokeAndTransfer$1(method, ...params);
1671
1688
  };
1672
1689
 
1690
+ /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
1691
+
1673
1692
  const pendingRpcs = Object.create(null);
1693
+ const bindCommandMap = (rpc, commandMap) => {
1694
+ if (rpc.ipc) {
1695
+ rpc.ipc.execute = createExtensionCommandExecutor(commandMap);
1696
+ }
1697
+ return rpc;
1698
+ };
1674
1699
  const createIsolatedExtensionHostWorker = async (extensionId, absolutePath, workerName, createRpc, invokeAndTransfer) => {
1675
- return createRpc({
1676
- commandMap: createExtensionCommandMap(extensionId),
1700
+ const commandMap = createExtensionCommandMap(extensionId);
1701
+ const rpc = await createRpc({
1702
+ commandMap,
1677
1703
  isMessagePortOpen: true,
1678
1704
  send(port) {
1679
1705
  return invokeAndTransfer('LaunchIsolatedExtensionHostWorker.launchIsolatedExtensionHostWorker', port, extensionId, absolutePath, workerName);
1680
1706
  }
1681
1707
  });
1708
+ return bindCommandMap(rpc, commandMap);
1682
1709
  };
1683
1710
  const createWorker = (extensionId, absolutePath, workerName) => {
1684
1711
  return createIsolatedExtensionHostWorker(extensionId, absolutePath, workerName, create$7, invokeAndTransfer);
@@ -2585,6 +2612,7 @@ const getRpc$1 = async (extension, assetDir, platform) => {
2585
2612
  if (existingRpc) {
2586
2613
  return existingRpc;
2587
2614
  }
2615
+ handleRpcInfos(extension, platform);
2588
2616
  const absolutePath = getAbsolutePath(extension, assetDir, platform);
2589
2617
  return getOrCreateIsolatedExtensionHostWorker(extensionId, absolutePath, extension.workerName || '');
2590
2618
  };
@@ -3359,26 +3387,59 @@ const getRpcInfo = rpcId => {
3359
3387
  return info;
3360
3388
  };
3361
3389
 
3362
- const getRunningExtensionsFromState = (extensions, runtimeStatuses) => {
3390
+ const isAbsoluteIcon = icon => {
3391
+ return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('/');
3392
+ };
3393
+
3394
+ const isRelativeIconPath = icon => {
3395
+ return icon.startsWith('./') || icon.startsWith('../') || icon.includes('/') || /\.(?:bmp|gif|ico|jpe?g|png|svg|webp)$/i.test(icon);
3396
+ };
3397
+
3398
+ const getIcon = (extension, manifestView, assetDir, platform) => {
3399
+ const manifestIcon = manifestView?.icon;
3400
+ if (typeof manifestIcon === 'string' && manifestIcon.length > 0) {
3401
+ if (isAbsoluteIcon(manifestIcon) || !isRelativeIconPath(manifestIcon)) {
3402
+ return manifestIcon;
3403
+ }
3404
+ return getAbsolutePath({
3405
+ ...extension,
3406
+ browser: manifestIcon
3407
+ }, assetDir, platform);
3408
+ }
3409
+ return '';
3410
+ };
3411
+
3412
+ const getRunningExtensionsFromState = (extensions, runtimeStatuses, assetDir, platform) => {
3363
3413
  return extensions.flatMap(extension => {
3364
3414
  const runtimeStatus = runtimeStatuses[extension.id];
3365
3415
  if (!runtimeStatus || runtimeStatus.status !== Activated) {
3366
3416
  return [];
3367
3417
  }
3418
+ const manifestIcon = typeof extension.icon === 'string' ? extension.icon.replace(/^\.\//, '') : undefined;
3419
+ const icon = getIcon(extension, {
3420
+ icon: manifestIcon
3421
+ }, assetDir, platform);
3368
3422
  return [{
3369
3423
  ...extension,
3370
3424
  activationEvent: runtimeStatus.activationEvent,
3371
- activationTime: runtimeStatus.activationTime
3425
+ activationTime: runtimeStatus.activationTime,
3426
+ ...(icon && {
3427
+ icon
3428
+ })
3372
3429
  }];
3373
3430
  }).toSorted((a, b) => b.activationTime - a.activationTime);
3374
3431
  };
3375
3432
 
3376
3433
  const getRunningExtensions = async (assetDir, platform) => {
3377
- const extensions = await getAllExtensions(assetDir, platform);
3434
+ const {
3435
+ assetDir: resolvedAssetDir,
3436
+ platform: resolvedPlatform
3437
+ } = await getRuntimeContext(assetDir, platform);
3438
+ const extensions = await getAllExtensions(resolvedAssetDir, resolvedPlatform);
3378
3439
  const {
3379
3440
  runtimeStatuses
3380
3441
  } = get$5();
3381
- return getRunningExtensionsFromState(extensions, runtimeStatuses);
3442
+ return getRunningExtensionsFromState(extensions, runtimeStatuses, resolvedAssetDir, resolvedPlatform);
3382
3443
  };
3383
3444
 
3384
3445
  const emptyStatus = {
@@ -3416,28 +3477,6 @@ const getCss = (extension, manifestView, assetDir, platform) => {
3416
3477
  }, assetDir, platform);
3417
3478
  };
3418
3479
 
3419
- const isAbsoluteIcon = icon => {
3420
- return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('/');
3421
- };
3422
-
3423
- const isRelativeIconPath = icon => {
3424
- return icon.startsWith('./') || icon.startsWith('../') || icon.includes('/') || /\.(?:bmp|gif|ico|jpe?g|png|svg|webp)$/i.test(icon);
3425
- };
3426
-
3427
- const getIcon = (extension, manifestView, assetDir, platform) => {
3428
- const manifestIcon = manifestView?.icon;
3429
- if (typeof manifestIcon === 'string' && manifestIcon.length > 0) {
3430
- if (isAbsoluteIcon(manifestIcon) || !isRelativeIconPath(manifestIcon)) {
3431
- return manifestIcon;
3432
- }
3433
- return getAbsolutePath({
3434
- ...extension,
3435
- browser: manifestIcon
3436
- }, assetDir, platform);
3437
- }
3438
- return '';
3439
- };
3440
-
3441
3480
  const getIframe = (extension, manifestView, assetDir, platform) => {
3442
3481
  const iframe = manifestView?.iframe;
3443
3482
  if (!iframe || typeof iframe.path !== 'string' || iframe.path.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-management-worker",
3
- "version": "4.31.3",
3
+ "version": "4.31.5",
4
4
  "description": "Webworker for the Extension Management functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"