@lvce-editor/extension-management-worker 4.81.0 → 4.81.1

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.
@@ -5450,9 +5450,47 @@ const isRelativeIconPath = icon => {
5450
5450
  return icon.startsWith('./') || icon.startsWith('../') || icon.includes('/') || /\.(?:bmp|gif|ico|jpe?g|png|svg|webp)$/i.test(icon);
5451
5451
  };
5452
5452
 
5453
+ const getBuiltinIconPath = (extension, icon, assetDir, platform) => {
5454
+ const extensionPathUrl = extension.path || extension.uri || '';
5455
+ if (extension.builtin !== true || extension.isWeb === true || platform === Web || !extensionPathUrl.startsWith('file://')) {
5456
+ return undefined;
5457
+ }
5458
+ const isLocalFileUrl = icon.startsWith('file://');
5459
+ const isLocalAbsolutePath = icon.startsWith('/') || /^[A-Za-z]:[\\/]/.test(icon);
5460
+ const hasUrlScheme = /^[A-Za-z][A-Za-z\d+.-]*:/.test(icon);
5461
+ if (!isLocalFileUrl && (hasUrlScheme || !isLocalAbsolutePath && !isRelativeIconPath(icon))) {
5462
+ return undefined;
5463
+ }
5464
+ const extensionPath = new URL(extensionPathUrl).pathname.replaceAll('\\', '/').replace(/\/$/, '');
5465
+ let iconPath = icon;
5466
+ if (isLocalFileUrl) {
5467
+ iconPath = new URL(icon).pathname;
5468
+ } else if (!isLocalAbsolutePath) {
5469
+ iconPath = `${extensionPath}/${icon}`;
5470
+ }
5471
+ const normalizedIconPath = iconPath.replaceAll('\\', '/');
5472
+ const normalizedExtensionPath = extensionPath.replace(/^\/([A-Za-z]:\/)/, '$1');
5473
+ const normalizedAbsoluteIconPath = normalizedIconPath.replace(/^\/([A-Za-z]:\/)/, '$1');
5474
+ const isWindowsPath = /^[A-Za-z]:\//.test(normalizedExtensionPath);
5475
+ const pathToCompare = isWindowsPath ? normalizedExtensionPath.toLowerCase() : normalizedExtensionPath;
5476
+ const iconPathToCompare = isWindowsPath ? normalizedAbsoluteIconPath.toLowerCase() : normalizedAbsoluteIconPath;
5477
+ if (!iconPathToCompare.startsWith(`${pathToCompare}/`)) {
5478
+ return undefined;
5479
+ }
5480
+ const relativePath = normalizedAbsoluteIconPath.slice(normalizedExtensionPath.length + 1);
5481
+ const folderName = normalizedExtensionPath.split('/').findLast(Boolean);
5482
+ if (!relativePath || !folderName || relativePath.split('/').includes('..')) {
5483
+ return undefined;
5484
+ }
5485
+ return `${assetDir}/extensions/${folderName}/${relativePath}`;
5486
+ };
5453
5487
  const getIcon = (extension, manifestView, assetDir, platform) => {
5454
5488
  const manifestIcon = manifestView?.icon;
5455
5489
  if (typeof manifestIcon === 'string' && manifestIcon.length > 0) {
5490
+ const builtinIconPath = getBuiltinIconPath(extension, manifestIcon, assetDir, platform);
5491
+ if (builtinIconPath) {
5492
+ return builtinIconPath;
5493
+ }
5456
5494
  if (isAbsoluteIcon(manifestIcon) || !isRelativeIconPath(manifestIcon)) {
5457
5495
  return manifestIcon;
5458
5496
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-management-worker",
3
- "version": "4.81.0",
3
+ "version": "4.81.1",
4
4
  "description": "Webworker for the Extension Management functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"