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

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.
@@ -3994,6 +3994,9 @@ const executeFileSystemProviderReadDirWithFileTypes = (extensionsState, provider
3994
3994
  const executeFileSystemProviderReadFile = (extensionsState, providerId, uri) => {
3995
3995
  return executeFileSystemProviderMethod(extensionsState, 'ExtensionApi.executeFileSystemProviderReadFile', providerId, uri);
3996
3996
  };
3997
+ const executeFileSystemProviderGetOpenExternalPath = (extensionsState, providerId, uri) => {
3998
+ return executeFileSystemProviderMethod(extensionsState, 'ExtensionApi.executeFileSystemProviderGetOpenExternalPath', providerId, uri);
3999
+ };
3997
4000
  const executeFileSystemProviderStat = (extensionsState, providerId, uri) => {
3998
4001
  return executeFileSystemProviderMethod(extensionsState, 'ExtensionApi.executeFileSystemProviderStat', providerId, uri);
3999
4002
  };
@@ -5450,9 +5453,47 @@ const isRelativeIconPath = icon => {
5450
5453
  return icon.startsWith('./') || icon.startsWith('../') || icon.includes('/') || /\.(?:bmp|gif|ico|jpe?g|png|svg|webp)$/i.test(icon);
5451
5454
  };
5452
5455
 
5456
+ const getBuiltinIconPath = (extension, icon, assetDir, platform) => {
5457
+ const extensionPathUrl = extension.path || extension.uri || '';
5458
+ if (extension.builtin !== true || extension.isWeb === true || platform === Web || !extensionPathUrl.startsWith('file://')) {
5459
+ return undefined;
5460
+ }
5461
+ const isLocalFileUrl = icon.startsWith('file://');
5462
+ const isLocalAbsolutePath = icon.startsWith('/') || /^[A-Za-z]:[\\/]/.test(icon);
5463
+ const hasUrlScheme = /^[A-Za-z][A-Za-z\d+.-]*:/.test(icon);
5464
+ if (!isLocalFileUrl && (hasUrlScheme || !isLocalAbsolutePath && !isRelativeIconPath(icon))) {
5465
+ return undefined;
5466
+ }
5467
+ const extensionPath = new URL(extensionPathUrl).pathname.replaceAll('\\', '/').replace(/\/$/, '');
5468
+ let iconPath = icon;
5469
+ if (isLocalFileUrl) {
5470
+ iconPath = new URL(icon).pathname;
5471
+ } else if (!isLocalAbsolutePath) {
5472
+ iconPath = `${extensionPath}/${icon}`;
5473
+ }
5474
+ const normalizedIconPath = iconPath.replaceAll('\\', '/');
5475
+ const normalizedExtensionPath = extensionPath.replace(/^\/([A-Za-z]:\/)/, '$1');
5476
+ const normalizedAbsoluteIconPath = normalizedIconPath.replace(/^\/([A-Za-z]:\/)/, '$1');
5477
+ const isWindowsPath = /^[A-Za-z]:\//.test(normalizedExtensionPath);
5478
+ const pathToCompare = isWindowsPath ? normalizedExtensionPath.toLowerCase() : normalizedExtensionPath;
5479
+ const iconPathToCompare = isWindowsPath ? normalizedAbsoluteIconPath.toLowerCase() : normalizedAbsoluteIconPath;
5480
+ if (!iconPathToCompare.startsWith(`${pathToCompare}/`)) {
5481
+ return undefined;
5482
+ }
5483
+ const relativePath = normalizedAbsoluteIconPath.slice(normalizedExtensionPath.length + 1);
5484
+ const folderName = normalizedExtensionPath.split('/').findLast(Boolean);
5485
+ if (!relativePath || !folderName || relativePath.split('/').includes('..')) {
5486
+ return undefined;
5487
+ }
5488
+ return `${assetDir}/extensions/${folderName}/${relativePath}`;
5489
+ };
5453
5490
  const getIcon = (extension, manifestView, assetDir, platform) => {
5454
5491
  const manifestIcon = manifestView?.icon;
5455
5492
  if (typeof manifestIcon === 'string' && manifestIcon.length > 0) {
5493
+ const builtinIconPath = getBuiltinIconPath(extension, manifestIcon, assetDir, platform);
5494
+ if (builtinIconPath) {
5495
+ return builtinIconPath;
5496
+ }
5456
5497
  if (isAbsoluteIcon(manifestIcon) || !isRelativeIconPath(manifestIcon)) {
5457
5498
  return manifestIcon;
5458
5499
  }
@@ -6256,6 +6297,7 @@ const commandMap = {
6256
6297
  'Extensions.executeCompletionProvider': wrapCommand(executeCompletionProvider),
6257
6298
  'Extensions.executeDiagnosticProvider': wrapCommand(executeDiagnosticProvider),
6258
6299
  'Extensions.executeExtensionCommand': wrapCommand(executeExtensionCommand),
6300
+ 'Extensions.executeFileSystemProviderGetOpenExternalPath': wrapCommand(executeFileSystemProviderGetOpenExternalPath),
6259
6301
  'Extensions.executeFileSystemProviderIsReadonly': wrapCommand(executeFileSystemProviderIsReadonly),
6260
6302
  'Extensions.executeFileSystemProviderMkdir': wrapCommand(executeFileSystemProviderMkdir),
6261
6303
  'Extensions.executeFileSystemProviderReadDirWithFileTypes': wrapCommand(executeFileSystemProviderReadDirWithFileTypes),
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.2",
4
4
  "description": "Webworker for the Extension Management functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"