@codingame/monaco-vscode-extension-gallery-service-override 21.0.1 → 21.2.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.
package/index.js CHANGED
@@ -1,50 +1,47 @@
1
1
 
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { SyncDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/descriptors';
4
- import { IAllowedExtensionsService, IExtensionTipsService, IGlobalExtensionEnablementService, IExtensionGalleryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement.service';
3
+ import { AllowedExtensionsService } from './vscode/src/vs/platform/extensionManagement/common/allowedExtensionsService.js';
5
4
  import { GlobalExtensionEnablementService } from '@codingame/monaco-vscode-249dc928-1da3-51c1-82d0-45e0ba9d08a1-common/vscode/vs/platform/extensionManagement/common/extensionEnablementService';
6
- import { IExtensionsWorkbenchService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/extensions/common/extensions.service';
7
- import { getLocale } from '@codingame/monaco-vscode-a654b07e-8806-5425-b124-18f03ba8e11a-common/vscode/vs/platform/languagePacks/common/languagePacks';
8
- import { ExtensionsWorkbenchService } from '@codingame/monaco-vscode-2673c6e2-17c1-5710-b169-46f3d4a28696-common/vscode/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService';
9
- import { IWorkbenchExtensionEnablementService, IWorkbenchExtensionManagementService, IWebExtensionsScannerService, IExtensionManagementServerService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionManagement/common/extensionManagement.service';
10
- import { ExtensionManagementServerService } from './vscode/src/vs/workbench/services/extensionManagement/common/extensionManagementServerService.js';
11
- import { IExtensionIgnoredRecommendationsService, IExtensionRecommendationsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionRecommendations/common/extensionRecommendations.service';
12
- import { ExtensionRecommendationsService } from '@codingame/monaco-vscode-2673c6e2-17c1-5710-b169-46f3d4a28696-common/vscode/vs/workbench/contrib/extensions/browser/extensionRecommendationsService';
13
- import { WebExtensionsScannerService } from './vscode/src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.js';
5
+ import { IExtensionGalleryManifestService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionGalleryManifest.service';
6
+ import { IAllowedExtensionsService, IExtensionTipsService, IGlobalExtensionEnablementService, IExtensionGalleryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement.service';
7
+ import { IExtensionsProfileScannerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionsProfileScannerService.service';
8
+ import { IExtensionsScannerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionsScannerService.service';
9
+ import { ExtensionTipsService } from './vscode/src/vs/platform/extensionManagement/common/extensionTipsService.js';
14
10
  import { IExtensionRecommendationNotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionRecommendations/common/extensionRecommendations.service';
11
+ import { SyncDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/descriptors';
12
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
13
+ import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
14
+ import { getLocale } from '@codingame/monaco-vscode-a654b07e-8806-5425-b124-18f03ba8e11a-common/vscode/vs/platform/languagePacks/common/languagePacks';
15
15
  import { IgnoredExtensionsManagementService } from './vscode/src/vs/platform/userDataSync/common/ignoredExtensions.js';
16
16
  import { IIgnoredExtensionsManagementService } from '@codingame/monaco-vscode-api/vscode/vs/platform/userDataSync/common/ignoredExtensions.service';
17
- import { ExtensionManifestPropertiesService } from '@codingame/monaco-vscode-571c8352-7953-5038-9f09-e03bb6219a0e-common/vscode/vs/workbench/services/extensions/common/extensionManifestPropertiesService';
18
- import { IExtensionManifestPropertiesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensionManifestPropertiesService.service';
19
- import { IBuiltinExtensionsScannerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions.service';
17
+ import { ExtensionRecommendationNotificationService } from '@codingame/monaco-vscode-2673c6e2-17c1-5710-b169-46f3d4a28696-common/vscode/vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService';
18
+ import { ExtensionRecommendationsService } from '@codingame/monaco-vscode-2673c6e2-17c1-5710-b169-46f3d4a28696-common/vscode/vs/workbench/contrib/extensions/browser/extensionRecommendationsService';
19
+ import { ExtensionsWorkbenchService } from '@codingame/monaco-vscode-2673c6e2-17c1-5710-b169-46f3d4a28696-common/vscode/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService';
20
+ import { IExtensionsWorkbenchService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/extensions/common/extensions.service';
21
+ import { ExtensionEnablementService } from './vscode/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.js';
22
+ import { WebExtensionGalleryManifestService } from './vscode/src/vs/workbench/services/extensionManagement/browser/extensionGalleryManifestService.js';
23
+ import { ExtensionsProfileScannerService } from './vscode/src/vs/workbench/services/extensionManagement/browser/extensionsProfileScannerService.js';
24
+ import { IExtensionFeaturesManagementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures.service';
25
+ import { ExtensionFeaturesManagementService } from './vscode/src/vs/workbench/services/extensionManagement/common/extensionFeaturesManagemetService.js';
26
+ import { WorkbenchExtensionGalleryService } from './vscode/src/vs/workbench/services/extensionManagement/common/extensionGalleryService.js';
27
+ import { IWorkbenchExtensionEnablementService, IWorkbenchExtensionManagementService, IExtensionManagementServerService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionManagement/common/extensionManagement.service';
28
+ import { ExtensionManagementServerService } from './vscode/src/vs/workbench/services/extensionManagement/common/extensionManagementServerService.js';
29
+ import { ExtensionManagementService } from './vscode/src/vs/workbench/services/extensionManagement/common/extensionManagementService.js';
20
30
  import { ExtensionIgnoredRecommendationsService } from './vscode/src/vs/workbench/services/extensionRecommendations/common/extensionIgnoredRecommendationsService.js';
31
+ import { IExtensionIgnoredRecommendationsService, IExtensionRecommendationsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionRecommendations/common/extensionRecommendations.service';
21
32
  import { WorkspaceExtensionsConfigService } from '@codingame/monaco-vscode-9ed6fe06-a052-57c2-a234-5d9b94d2e7e0-common/vscode/vs/workbench/services/extensionRecommendations/common/workspaceExtensionsConfig';
22
33
  import { IWorkspaceExtensionsConfigService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionRecommendations/common/workspaceExtensionsConfig.service';
23
- import { ExtensionRecommendationNotificationService } from '@codingame/monaco-vscode-2673c6e2-17c1-5710-b169-46f3d4a28696-common/vscode/vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService';
24
- import { ExtensionTipsService } from './vscode/src/vs/platform/extensionManagement/common/extensionTipsService.js';
25
- import { ExtensionManagementService } from './vscode/src/vs/workbench/services/extensionManagement/common/extensionManagementService.js';
26
- import { RemoteUserDataProfilesService } from './vscode/src/vs/workbench/services/userDataProfile/common/remoteUserDataProfiles.js';
27
- import { IRemoteUserDataProfilesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/remoteUserDataProfiles.service';
28
- import { ExtensionEnablementService } from './vscode/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.js';
34
+ import { ExtensionsScannerService } from './vscode/src/vs/workbench/services/extensions/browser/extensionsScannerService.js';
29
35
  import { ExtensionUrlHandler } from '@codingame/monaco-vscode-8c844347-a703-5de1-9eeb-5e0c7f503a58-common/vscode/vs/workbench/services/extensions/browser/extensionUrlHandler';
30
36
  import { IExtensionUrlHandler } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/browser/extensionUrlHandler.service';
37
+ import { ExtensionManifestPropertiesService } from '@codingame/monaco-vscode-571c8352-7953-5038-9f09-e03bb6219a0e-common/vscode/vs/workbench/services/extensions/common/extensionManifestPropertiesService';
38
+ import { IExtensionManifestPropertiesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensionManifestPropertiesService.service';
31
39
  import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
32
- import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
33
- import { IExtensionsScannerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionsScannerService.service';
34
- import { ExtensionsScannerService } from './vscode/src/vs/workbench/services/extensions/browser/extensionsScannerService.js';
35
- import { ExtensionsProfileScannerService } from './vscode/src/vs/workbench/services/extensionManagement/browser/extensionsProfileScannerService.js';
36
- import { IExtensionsProfileScannerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionsProfileScannerService.service';
37
- import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
38
- import { IExtensionFeaturesManagementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures.service';
39
- import { ExtensionFeaturesManagementService } from './vscode/src/vs/workbench/services/extensionManagement/common/extensionFeaturesManagemetService.js';
40
- import { AllowedExtensionsService } from './vscode/src/vs/platform/extensionManagement/common/allowedExtensionsService.js';
40
+ import { RemoteUserDataProfilesService } from './vscode/src/vs/workbench/services/userDataProfile/common/remoteUserDataProfiles.js';
41
+ import { IRemoteUserDataProfilesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/remoteUserDataProfiles.service';
41
42
  import { registerAssets } from '@codingame/monaco-vscode-api/assets';
42
- import { getExtensionManifests } from '@codingame/monaco-vscode-api/extensions';
43
43
  import { isLocaleAvailable } from '@codingame/monaco-vscode-api/l10n';
44
44
  import { unsupported } from '@codingame/monaco-vscode-api/tools';
45
- import { IExtensionGalleryManifestService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionGalleryManifest.service';
46
- import { WebExtensionGalleryManifestService } from './vscode/src/vs/workbench/services/extensionManagement/browser/extensionGalleryManifestService.js';
47
- import { WorkbenchExtensionGalleryService } from './vscode/src/vs/workbench/services/extensionManagement/common/extensionGalleryService.js';
48
45
  import '@codingame/monaco-vscode-2673c6e2-17c1-5710-b169-46f3d4a28696-common/vscode/vs/workbench/contrib/extensions/browser/extensions.contribution';
49
46
  import './vscode/src/vs/workbench/contrib/extensions/browser/extensions.web.contribution.js';
50
47
 
@@ -82,11 +79,6 @@ ExtensionManagementServerServiceOverride = __decorate([
82
79
  __param(2, ILabelService),
83
80
  __param(3, IInstantiationService)
84
81
  ], ExtensionManagementServerServiceOverride);
85
- class CustomBuiltinExtensionsScannerService {
86
- async scanBuiltinExtensions() {
87
- return getExtensionManifests();
88
- }
89
- }
90
82
  class ExtensionsWorkbenchServiceOverride extends ExtensionsWorkbenchService {
91
83
  canSetLanguage(extension) {
92
84
  if (super.canSetLanguage(extension)) {
@@ -104,12 +96,10 @@ function getServiceOverride(options = { webOnly: false }) {
104
96
  [IExtensionManagementServerService.toString()]: new SyncDescriptor(ExtensionManagementServerServiceOverride, [options.webOnly], true),
105
97
  [IExtensionRecommendationsService.toString()]: new SyncDescriptor(ExtensionRecommendationsService, [], true),
106
98
  [IExtensionRecommendationNotificationService.toString()]: new SyncDescriptor(ExtensionRecommendationNotificationService, [], true),
107
- [IWebExtensionsScannerService.toString()]: new SyncDescriptor(WebExtensionsScannerService, [], true),
108
99
  [IExtensionIgnoredRecommendationsService.toString()]: new SyncDescriptor(ExtensionIgnoredRecommendationsService, [], true),
109
100
  [IIgnoredExtensionsManagementService.toString()]: new SyncDescriptor(IgnoredExtensionsManagementService, [], true),
110
101
  [IExtensionManifestPropertiesService.toString()]: new SyncDescriptor(ExtensionManifestPropertiesService, [], true),
111
102
  [IWorkbenchExtensionManagementService.toString()]: new SyncDescriptor(ExtensionManagementService, [], true),
112
- [IBuiltinExtensionsScannerService.toString()]: new SyncDescriptor(CustomBuiltinExtensionsScannerService, [], true),
113
103
  [IWorkspaceExtensionsConfigService.toString()]: new SyncDescriptor(WorkspaceExtensionsConfigService, [], true),
114
104
  [IExtensionTipsService.toString()]: new SyncDescriptor(ExtensionTipsService, [], true),
115
105
  [IRemoteUserDataProfilesService.toString()]: new SyncDescriptor(RemoteUserDataProfilesService, [], true),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-extension-gallery-service-override",
3
- "version": "21.0.1",
3
+ "version": "21.2.0",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - extension-gallery service-override",
6
6
  "keywords": [],
@@ -15,16 +15,15 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-23aade48-f094-5c08-9555-97fc9cca96c9-common": "21.0.1",
19
- "@codingame/monaco-vscode-249dc928-1da3-51c1-82d0-45e0ba9d08a1-common": "21.0.1",
20
- "@codingame/monaco-vscode-2673c6e2-17c1-5710-b169-46f3d4a28696-common": "21.0.1",
21
- "@codingame/monaco-vscode-34a0ffd3-b9f5-5699-b43b-38af5732f38a-common": "21.0.1",
22
- "@codingame/monaco-vscode-571c8352-7953-5038-9f09-e03bb6219a0e-common": "21.0.1",
23
- "@codingame/monaco-vscode-5e2c24a1-3217-55e8-bc90-521eaf7df5a6-common": "21.0.1",
24
- "@codingame/monaco-vscode-8c844347-a703-5de1-9eeb-5e0c7f503a58-common": "21.0.1",
25
- "@codingame/monaco-vscode-9ed6fe06-a052-57c2-a234-5d9b94d2e7e0-common": "21.0.1",
26
- "@codingame/monaco-vscode-a654b07e-8806-5425-b124-18f03ba8e11a-common": "21.0.1",
27
- "@codingame/monaco-vscode-api": "21.0.1"
18
+ "@codingame/monaco-vscode-23aade48-f094-5c08-9555-97fc9cca96c9-common": "21.2.0",
19
+ "@codingame/monaco-vscode-249dc928-1da3-51c1-82d0-45e0ba9d08a1-common": "21.2.0",
20
+ "@codingame/monaco-vscode-2673c6e2-17c1-5710-b169-46f3d4a28696-common": "21.2.0",
21
+ "@codingame/monaco-vscode-571c8352-7953-5038-9f09-e03bb6219a0e-common": "21.2.0",
22
+ "@codingame/monaco-vscode-5e2c24a1-3217-55e8-bc90-521eaf7df5a6-common": "21.2.0",
23
+ "@codingame/monaco-vscode-8c844347-a703-5de1-9eeb-5e0c7f503a58-common": "21.2.0",
24
+ "@codingame/monaco-vscode-9ed6fe06-a052-57c2-a234-5d9b94d2e7e0-common": "21.2.0",
25
+ "@codingame/monaco-vscode-a654b07e-8806-5425-b124-18f03ba8e11a-common": "21.2.0",
26
+ "@codingame/monaco-vscode-api": "21.2.0"
28
27
  },
29
28
  "main": "index.js",
30
29
  "module": "index.js",
@@ -1,6 +1,7 @@
1
1
  import { IExtensionsProfileScannerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionsProfileScannerService.service";
2
2
  import { AbstractExtensionsScannerService, Translations } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionsScannerService";
3
3
  import { IExtensionsScannerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionsScannerService.service";
4
+ import { IExtensionResourceLoaderService } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionResourceLoader/common/extensionResourceLoader.service";
4
5
  import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
5
6
  import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
6
7
  import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
@@ -10,6 +11,6 @@ import { IUserDataProfilesService } from "@codingame/monaco-vscode-api/vscode/vs
10
11
  import { IWorkbenchEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service";
11
12
  import { IUserDataProfileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service";
12
13
  export declare class ExtensionsScannerService extends AbstractExtensionsScannerService implements IExtensionsScannerService {
13
- constructor(userDataProfileService: IUserDataProfileService, userDataProfilesService: IUserDataProfilesService, extensionsProfileScannerService: IExtensionsProfileScannerService, fileService: IFileService, logService: ILogService, environmentService: IWorkbenchEnvironmentService, productService: IProductService, uriIdentityService: IUriIdentityService, instantiationService: IInstantiationService);
14
+ constructor(userDataProfileService: IUserDataProfileService, userDataProfilesService: IUserDataProfilesService, extensionsProfileScannerService: IExtensionsProfileScannerService, extensionResourceLoaderService: IExtensionResourceLoaderService, fileService: IFileService, logService: ILogService, environmentService: IWorkbenchEnvironmentService, productService: IProductService, uriIdentityService: IUriIdentityService, instantiationService: IInstantiationService);
14
15
  protected getTranslations(): Promise<Translations>;
15
16
  }
@@ -3,6 +3,7 @@ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib
3
3
  import { IExtensionsProfileScannerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionsProfileScannerService.service';
4
4
  import { AbstractExtensionsScannerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionsScannerService';
5
5
  import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
6
+ import { IExtensionResourceLoaderService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionResourceLoader/common/extensionResourceLoader.service';
6
7
  import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
7
8
  import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
8
9
  import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
@@ -13,8 +14,8 @@ import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscod
13
14
  import { IUserDataProfileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
14
15
 
15
16
  let ExtensionsScannerService = class ExtensionsScannerService extends AbstractExtensionsScannerService {
16
- constructor(userDataProfileService, userDataProfilesService, extensionsProfileScannerService, fileService, logService, environmentService, productService, uriIdentityService, instantiationService) {
17
- super(uriIdentityService.extUri.joinPath(environmentService.userRoamingDataHome, 'systemExtensions'), uriIdentityService.extUri.joinPath(environmentService.userRoamingDataHome, 'userExtensions'), uriIdentityService.extUri.joinPath(environmentService.userRoamingDataHome, 'userExtensions', 'control.json'), userDataProfileService.currentProfile, userDataProfilesService, extensionsProfileScannerService, fileService, logService, environmentService, productService, uriIdentityService, instantiationService);
17
+ constructor(userDataProfileService, userDataProfilesService, extensionsProfileScannerService, extensionResourceLoaderService, fileService, logService, environmentService, productService, uriIdentityService, instantiationService) {
18
+ super(uriIdentityService.extUri.joinPath(environmentService.userRoamingDataHome, 'systemExtensions'), uriIdentityService.extUri.joinPath(environmentService.userRoamingDataHome, 'userExtensions'), uriIdentityService.extUri.joinPath(environmentService.userRoamingDataHome, 'userExtensions', 'control.json'), userDataProfileService.currentProfile, userDataProfilesService, extensionsProfileScannerService, extensionResourceLoaderService, fileService, logService, environmentService, productService, uriIdentityService, instantiationService);
18
19
  }
19
20
  async getTranslations() {
20
21
  return {};
@@ -24,12 +25,13 @@ ExtensionsScannerService = ( __decorate([
24
25
  ( __param(0, IUserDataProfileService)),
25
26
  ( __param(1, IUserDataProfilesService)),
26
27
  ( __param(2, IExtensionsProfileScannerService)),
27
- ( __param(3, IFileService)),
28
- ( __param(4, ILogService)),
29
- ( __param(5, IWorkbenchEnvironmentService)),
30
- ( __param(6, IProductService)),
31
- ( __param(7, IUriIdentityService)),
32
- ( __param(8, IInstantiationService))
28
+ ( __param(3, IExtensionResourceLoaderService)),
29
+ ( __param(4, IFileService)),
30
+ ( __param(5, ILogService)),
31
+ ( __param(6, IWorkbenchEnvironmentService)),
32
+ ( __param(7, IProductService)),
33
+ ( __param(8, IUriIdentityService)),
34
+ ( __param(9, IInstantiationService))
33
35
  ], ExtensionsScannerService));
34
36
 
35
37
  export { ExtensionsScannerService };
@@ -1,95 +0,0 @@
1
- import { ExtensionType, IExtension, IExtensionManifest } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions";
2
- import { IBuiltinExtensionsScannerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions.service";
3
- import { IBrowserWorkbenchEnvironmentService } from "@codingame/monaco-vscode-34a0ffd3-b9f5-5699-b43b-38af5732f38a-common/vscode/vs/workbench/services/environment/browser/environmentService.service";
4
- import { IScannedExtension, ScanOptions } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionManagement/common/extensionManagement";
5
- import { IWebExtensionsScannerService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionManagement/common/extensionManagement.service";
6
- import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
7
- import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
8
- import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
9
- import { IGalleryExtension, Metadata } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement";
10
- import { IExtensionGalleryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement.service";
11
- import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
12
- import { IExtensionManifestPropertiesService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensionManifestPropertiesService.service";
13
- import { IExtensionResourceLoaderService } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionResourceLoader/common/extensionResourceLoader.service";
14
- import { IExtensionStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionStorage.service";
15
- import { ILifecycleService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service";
16
- import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
17
- import { IProductService } from "@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service";
18
- import { IUserDataProfilesService } from "@codingame/monaco-vscode-api/vscode/vs/platform/userDataProfile/common/userDataProfile.service";
19
- import { IUriIdentityService } from "@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
20
- export declare class WebExtensionsScannerService extends Disposable implements IWebExtensionsScannerService {
21
- private readonly environmentService;
22
- private readonly builtinExtensionsScannerService;
23
- private readonly fileService;
24
- private readonly logService;
25
- private readonly galleryService;
26
- private readonly extensionManifestPropertiesService;
27
- private readonly extensionResourceLoaderService;
28
- private readonly extensionStorageService;
29
- private readonly storageService;
30
- private readonly productService;
31
- private readonly userDataProfilesService;
32
- private readonly uriIdentityService;
33
- readonly _serviceBrand: undefined;
34
- private readonly systemExtensionsCacheResource;
35
- private readonly customBuiltinExtensionsCacheResource;
36
- private readonly resourcesAccessQueueMap;
37
- private readonly extensionsEnabledWithApiProposalVersion;
38
- constructor(environmentService: IBrowserWorkbenchEnvironmentService, builtinExtensionsScannerService: IBuiltinExtensionsScannerService, fileService: IFileService, logService: ILogService, galleryService: IExtensionGalleryService, extensionManifestPropertiesService: IExtensionManifestPropertiesService, extensionResourceLoaderService: IExtensionResourceLoaderService, extensionStorageService: IExtensionStorageService, storageService: IStorageService, productService: IProductService, userDataProfilesService: IUserDataProfilesService, uriIdentityService: IUriIdentityService, lifecycleService: ILifecycleService);
39
- private _customBuiltinExtensionsInfoPromise;
40
- private readCustomBuiltinExtensionsInfoFromEnv;
41
- private checkAdditionalBuiltinExtensions;
42
- /**
43
- * All system extensions bundled with the product
44
- */
45
- private readSystemExtensions;
46
- /**
47
- * All extensions defined via `additionalBuiltinExtensions` API
48
- */
49
- private readCustomBuiltinExtensions;
50
- private getCustomBuiltinExtensionsFromLocations;
51
- private getCustomBuiltinExtensionsFromGallery;
52
- private getCustomBuiltinExtensionsFromCache;
53
- private _migrateExtensionsStoragePromise;
54
- private migrateExtensionsStorage;
55
- private updateCaches;
56
- private updateSystemExtensionsCache;
57
- private _updateCustomBuiltinExtensionsCachePromise;
58
- private updateCustomBuiltinExtensionsCache;
59
- private resolveBuiltinExtensionGalleryResources;
60
- private resolveBuiltinGalleryExtensions;
61
- private resolveDependenciesAndPackedExtensions;
62
- private getExtensionsWithDependenciesAndPackedExtensions;
63
- scanSystemExtensions(): Promise<IExtension[]>;
64
- scanUserExtensions(profileLocation: URI, scanOptions?: ScanOptions): Promise<IScannedExtension[]>;
65
- scanExtensionsUnderDevelopment(): Promise<IExtension[]>;
66
- scanExistingExtension(extensionLocation: URI, extensionType: ExtensionType, profileLocation: URI): Promise<IScannedExtension | null>;
67
- scanExtensionManifest(extensionLocation: URI): Promise<IExtensionManifest | null>;
68
- addExtensionFromGallery(galleryExtension: IGalleryExtension, metadata: Metadata, profileLocation: URI): Promise<IScannedExtension>;
69
- addExtension(location: URI, metadata: Metadata, profileLocation: URI): Promise<IScannedExtension>;
70
- removeExtension(extension: IScannedExtension, profileLocation: URI): Promise<void>;
71
- updateMetadata(extension: IScannedExtension, metadata: Partial<Metadata>, profileLocation: URI): Promise<IScannedExtension>;
72
- copyExtensions(fromProfileLocation: URI, toProfileLocation: URI, filter: (extension: IScannedExtension) => boolean): Promise<void>;
73
- private addWebExtension;
74
- private addToInstalledExtensions;
75
- private scanInstalledExtensions;
76
- private toWebExtensionFromGallery;
77
- private toWebExtensionFromExtensionGalleryResource;
78
- private getPackageNLSResourceMapFromResources;
79
- private toWebExtension;
80
- private toScannedExtension;
81
- private listExtensionResources;
82
- private translateManifest;
83
- private getExtensionManifest;
84
- private getTranslations;
85
- private readInstalledExtensions;
86
- private writeInstalledExtensions;
87
- private readCustomBuiltinExtensionsCache;
88
- private writeCustomBuiltinExtensionsCache;
89
- private readSystemExtensionsCache;
90
- private writeSystemExtensionsCache;
91
- private withWebExtensions;
92
- private migrateWebExtensions;
93
- private storeWebExtensions;
94
- private getResourceAccessQueue;
95
- }
@@ -1,906 +0,0 @@
1
-
2
- import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { ExtensionType, TargetPlatform, parseEnabledApiProposalNames } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions';
4
- import { IBuiltinExtensionsScannerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions.service';
5
- import { IBrowserWorkbenchEnvironmentService } from '@codingame/monaco-vscode-34a0ffd3-b9f5-5699-b43b-38af5732f38a-common/vscode/vs/workbench/services/environment/browser/environmentService.service';
6
- import { IExtensionGalleryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagement.service';
7
- import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
8
- import { isWeb, Language } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
9
- import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
10
- import { joinPath } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
11
- import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
12
- import { FileOperationResult } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
13
- import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
14
- import { Queue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
15
- import { VSBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
16
- import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
17
- import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
18
- import { isMalicious, areSameExtensions, getExtensionId, getGalleryExtensionId } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
19
- import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
20
- import { localizeManifest } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionNls';
21
- import { localize, localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
22
- import { semverExports } from '@codingame/monaco-vscode-api/_virtual/semver';
23
- import { isString, isUndefined } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
24
- import { getErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
25
- import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
26
- import { IExtensionManifestPropertiesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensionManifestPropertiesService.service';
27
- import { migratePlatformSpecificExtensionGalleryResourceURL } from '@codingame/monaco-vscode-571c8352-7953-5038-9f09-e03bb6219a0e-common/vscode/vs/platform/extensionResourceLoader/common/extensionResourceLoader';
28
- import { IExtensionResourceLoaderService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionResourceLoader/common/extensionResourceLoader.service';
29
- import { registerAction2, Action2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
30
- import { Categories } from '@codingame/monaco-vscode-api/vscode/vs/platform/action/common/actionCommonCategories';
31
- import { IsWebContext } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkeys';
32
- import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
33
- import { basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/path';
34
- import { IExtensionStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensionManagement/common/extensionStorage.service';
35
- import { isNonEmptyArray } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
36
- import { LifecyclePhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle';
37
- import { ILifecycleService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
38
- import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
39
- import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
40
- import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
41
- import { validateExtensionManifest } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensionValidator';
42
- import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
43
- import { IUserDataProfileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
44
- import { IUserDataProfilesService } from '@codingame/monaco-vscode-api/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
45
- import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
46
-
47
- function isGalleryExtensionInfo(obj) {
48
- const galleryExtensionInfo = obj;
49
- return typeof galleryExtensionInfo?.id === 'string'
50
- && (galleryExtensionInfo.preRelease === undefined || typeof galleryExtensionInfo.preRelease === 'boolean')
51
- && (galleryExtensionInfo.migrateStorageFrom === undefined || typeof galleryExtensionInfo.migrateStorageFrom === 'string');
52
- }
53
- function isUriComponents(thing) {
54
- if (!thing) {
55
- return false;
56
- }
57
- return isString(thing.path) &&
58
- isString(thing.scheme);
59
- }
60
- let WebExtensionsScannerService = class WebExtensionsScannerService extends Disposable {
61
- constructor(environmentService, builtinExtensionsScannerService, fileService, logService, galleryService, extensionManifestPropertiesService, extensionResourceLoaderService, extensionStorageService, storageService, productService, userDataProfilesService, uriIdentityService, lifecycleService) {
62
- super();
63
- this.environmentService = environmentService;
64
- this.builtinExtensionsScannerService = builtinExtensionsScannerService;
65
- this.fileService = fileService;
66
- this.logService = logService;
67
- this.galleryService = galleryService;
68
- this.extensionManifestPropertiesService = extensionManifestPropertiesService;
69
- this.extensionResourceLoaderService = extensionResourceLoaderService;
70
- this.extensionStorageService = extensionStorageService;
71
- this.storageService = storageService;
72
- this.productService = productService;
73
- this.userDataProfilesService = userDataProfilesService;
74
- this.uriIdentityService = uriIdentityService;
75
- this.systemExtensionsCacheResource = undefined;
76
- this.customBuiltinExtensionsCacheResource = undefined;
77
- this.resourcesAccessQueueMap = ( new ResourceMap());
78
- if (isWeb) {
79
- this.systemExtensionsCacheResource = joinPath(environmentService.userRoamingDataHome, 'systemExtensionsCache.json');
80
- this.customBuiltinExtensionsCacheResource = joinPath(environmentService.userRoamingDataHome, 'customBuiltinExtensionsCache.json');
81
- lifecycleService.when(LifecyclePhase.Eventually).then(() => this.updateCaches());
82
- }
83
- this.extensionsEnabledWithApiProposalVersion = productService.extensionsEnabledWithApiProposalVersion?.map(id => id.toLowerCase()) ?? [];
84
- }
85
- readCustomBuiltinExtensionsInfoFromEnv() {
86
- if (!this._customBuiltinExtensionsInfoPromise) {
87
- this._customBuiltinExtensionsInfoPromise = (async () => {
88
- let extensions = [];
89
- const extensionLocations = [];
90
- const extensionGalleryResources = [];
91
- const extensionsToMigrate = [];
92
- const customBuiltinExtensionsInfo = this.environmentService.options && Array.isArray(this.environmentService.options.additionalBuiltinExtensions)
93
- ? ( this.environmentService.options.additionalBuiltinExtensions.map(
94
- additionalBuiltinExtension => isString(additionalBuiltinExtension) ? { id: additionalBuiltinExtension } : additionalBuiltinExtension
95
- ))
96
- : [];
97
- for (const e of customBuiltinExtensionsInfo) {
98
- if (isGalleryExtensionInfo(e)) {
99
- extensions.push({ id: e.id, preRelease: !!e.preRelease });
100
- if (e.migrateStorageFrom) {
101
- extensionsToMigrate.push([e.migrateStorageFrom, e.id]);
102
- }
103
- }
104
- else if (isUriComponents(e)) {
105
- const extensionLocation = URI.revive(e);
106
- if (await this.extensionResourceLoaderService.isExtensionGalleryResource(extensionLocation)) {
107
- extensionGalleryResources.push(extensionLocation);
108
- }
109
- else {
110
- extensionLocations.push(extensionLocation);
111
- }
112
- }
113
- }
114
- if (extensions.length) {
115
- extensions = await this.checkAdditionalBuiltinExtensions(extensions);
116
- }
117
- if (extensions.length) {
118
- this.logService.info('Found additional builtin gallery extensions in env', extensions);
119
- }
120
- if (extensionLocations.length) {
121
- this.logService.info('Found additional builtin location extensions in env', ( extensionLocations.map(e => ( e.toString()))));
122
- }
123
- if (extensionGalleryResources.length) {
124
- this.logService.info('Found additional builtin extension gallery resources in env', ( extensionGalleryResources.map(e => ( e.toString()))));
125
- }
126
- return { extensions, extensionsToMigrate, extensionLocations, extensionGalleryResources };
127
- })();
128
- }
129
- return this._customBuiltinExtensionsInfoPromise;
130
- }
131
- async checkAdditionalBuiltinExtensions(extensions) {
132
- const extensionsControlManifest = await this.galleryService.getExtensionsControlManifest();
133
- const result = [];
134
- for (const extension of extensions) {
135
- if (isMalicious({ id: extension.id }, extensionsControlManifest.malicious)) {
136
- this.logService.info(`Checking additional builtin extensions: Ignoring '${extension.id}' because it is reported to be malicious.`);
137
- continue;
138
- }
139
- const deprecationInfo = extensionsControlManifest.deprecated[extension.id.toLowerCase()];
140
- if (deprecationInfo?.extension?.autoMigrate) {
141
- const preReleaseExtensionId = deprecationInfo.extension.id;
142
- this.logService.info(`Checking additional builtin extensions: '${extension.id}' is deprecated, instead using '${preReleaseExtensionId}'`);
143
- result.push({ id: preReleaseExtensionId, preRelease: !!extension.preRelease });
144
- }
145
- else {
146
- result.push(extension);
147
- }
148
- }
149
- return result;
150
- }
151
- async readSystemExtensions() {
152
- const systemExtensions = await this.builtinExtensionsScannerService.scanBuiltinExtensions();
153
- const cachedSystemExtensions = await Promise.all(( (await this.readSystemExtensionsCache()).map(e => this.toScannedExtension(e, true, ExtensionType.System))));
154
- const result = ( new Map());
155
- for (const extension of [...systemExtensions, ...cachedSystemExtensions]) {
156
- const existing = result.get(extension.identifier.id.toLowerCase());
157
- if (existing) {
158
- if (semverExports.gt(existing.manifest.version, extension.manifest.version)) {
159
- continue;
160
- }
161
- }
162
- result.set(extension.identifier.id.toLowerCase(), extension);
163
- }
164
- return [...( result.values())];
165
- }
166
- async readCustomBuiltinExtensions(scanOptions) {
167
- const [customBuiltinExtensionsFromLocations, customBuiltinExtensionsFromGallery] = await Promise.all([
168
- this.getCustomBuiltinExtensionsFromLocations(scanOptions),
169
- this.getCustomBuiltinExtensionsFromGallery(scanOptions),
170
- ]);
171
- const customBuiltinExtensions = [...customBuiltinExtensionsFromLocations, ...customBuiltinExtensionsFromGallery];
172
- await this.migrateExtensionsStorage(customBuiltinExtensions);
173
- return customBuiltinExtensions;
174
- }
175
- async getCustomBuiltinExtensionsFromLocations(scanOptions) {
176
- const { extensionLocations } = await this.readCustomBuiltinExtensionsInfoFromEnv();
177
- if (!extensionLocations.length) {
178
- return [];
179
- }
180
- const result = [];
181
- await Promise.allSettled(( extensionLocations.map(async (extensionLocation) => {
182
- try {
183
- const webExtension = await this.toWebExtension(extensionLocation);
184
- const extension = await this.toScannedExtension(webExtension, true);
185
- if (extension.isValid || !scanOptions?.skipInvalidExtensions) {
186
- result.push(extension);
187
- }
188
- else {
189
- this.logService.info(`Skipping invalid additional builtin extension ${webExtension.identifier.id}`);
190
- }
191
- }
192
- catch (error) {
193
- this.logService.info(`Error while fetching the additional builtin extension ${( extensionLocation.toString())}.`, getErrorMessage(error));
194
- }
195
- })));
196
- return result;
197
- }
198
- async getCustomBuiltinExtensionsFromGallery(scanOptions) {
199
- if (!this.galleryService.isEnabled()) {
200
- this.logService.info('Ignoring fetching additional builtin extensions from gallery as it is disabled.');
201
- return [];
202
- }
203
- const result = [];
204
- const { extensions, extensionGalleryResources } = await this.readCustomBuiltinExtensionsInfoFromEnv();
205
- try {
206
- const cacheValue = JSON.stringify({
207
- extensions: extensions.sort((a, b) => a.id.localeCompare(b.id)),
208
- extensionGalleryResources: ( extensionGalleryResources.map(e => ( e.toString()))).sort()
209
- });
210
- const useCache = this.storageService.get('additionalBuiltinExtensions', StorageScope.APPLICATION, '{}') === cacheValue;
211
- const webExtensions = await (useCache ? this.getCustomBuiltinExtensionsFromCache() : this.updateCustomBuiltinExtensionsCache());
212
- if (webExtensions.length) {
213
- await Promise.all(( webExtensions.map(async (webExtension) => {
214
- try {
215
- const extension = await this.toScannedExtension(webExtension, true);
216
- if (extension.isValid || !scanOptions?.skipInvalidExtensions) {
217
- result.push(extension);
218
- }
219
- else {
220
- this.logService.info(`Skipping invalid additional builtin gallery extension ${webExtension.identifier.id}`);
221
- }
222
- }
223
- catch (error) {
224
- this.logService.info(`Ignoring additional builtin extension ${webExtension.identifier.id} because there is an error while converting it into scanned extension`, getErrorMessage(error));
225
- }
226
- })));
227
- }
228
- this.storageService.store('additionalBuiltinExtensions', cacheValue, StorageScope.APPLICATION, StorageTarget.MACHINE);
229
- }
230
- catch (error) {
231
- this.logService.info('Ignoring following additional builtin extensions as there is an error while fetching them from gallery', ( extensions.map(({ id }) => id)), getErrorMessage(error));
232
- }
233
- return result;
234
- }
235
- async getCustomBuiltinExtensionsFromCache() {
236
- const cachedCustomBuiltinExtensions = await this.readCustomBuiltinExtensionsCache();
237
- const webExtensionsMap = ( new Map());
238
- for (const webExtension of cachedCustomBuiltinExtensions) {
239
- const existing = webExtensionsMap.get(webExtension.identifier.id.toLowerCase());
240
- if (existing) {
241
- if (semverExports.gt(existing.version, webExtension.version)) {
242
- continue;
243
- }
244
- }
245
- if (webExtension.metadata?.isPreReleaseVersion && !webExtension.metadata?.preRelease) {
246
- webExtension.metadata.preRelease = true;
247
- }
248
- webExtensionsMap.set(webExtension.identifier.id.toLowerCase(), webExtension);
249
- }
250
- return [...( webExtensionsMap.values())];
251
- }
252
- async migrateExtensionsStorage(customBuiltinExtensions) {
253
- if (!this._migrateExtensionsStoragePromise) {
254
- this._migrateExtensionsStoragePromise = (async () => {
255
- const { extensionsToMigrate } = await this.readCustomBuiltinExtensionsInfoFromEnv();
256
- if (!extensionsToMigrate.length) {
257
- return;
258
- }
259
- const fromExtensions = await this.galleryService.getExtensions(( extensionsToMigrate.map(([id]) => ({ id }))), CancellationToken.None);
260
- try {
261
- await Promise.allSettled(( extensionsToMigrate.map(async ([from, to]) => {
262
- const toExtension = customBuiltinExtensions.find(extension => areSameExtensions(extension.identifier, { id: to }));
263
- if (toExtension) {
264
- const fromExtension = fromExtensions.find(extension => areSameExtensions(extension.identifier, { id: from }));
265
- const fromExtensionManifest = fromExtension ? await this.galleryService.getManifest(fromExtension, CancellationToken.None) : null;
266
- const fromExtensionId = fromExtensionManifest ? getExtensionId(fromExtensionManifest.publisher, fromExtensionManifest.name) : from;
267
- const toExtensionId = getExtensionId(toExtension.manifest.publisher, toExtension.manifest.name);
268
- this.extensionStorageService.addToMigrationList(fromExtensionId, toExtensionId);
269
- }
270
- else {
271
- this.logService.info(`Skipped migrating extension storage from '${from}' to '${to}', because the '${to}' extension is not found.`);
272
- }
273
- })));
274
- }
275
- catch (error) {
276
- this.logService.error(error);
277
- }
278
- })();
279
- }
280
- return this._migrateExtensionsStoragePromise;
281
- }
282
- async updateCaches() {
283
- await this.updateSystemExtensionsCache();
284
- await this.updateCustomBuiltinExtensionsCache();
285
- }
286
- async updateSystemExtensionsCache() {
287
- const systemExtensions = await this.builtinExtensionsScannerService.scanBuiltinExtensions();
288
- const cachedSystemExtensions = (await this.readSystemExtensionsCache())
289
- .filter(cached => {
290
- const systemExtension = systemExtensions.find(e => areSameExtensions(e.identifier, cached.identifier));
291
- return systemExtension && semverExports.gt(cached.version, systemExtension.manifest.version);
292
- });
293
- await this.writeSystemExtensionsCache(() => cachedSystemExtensions);
294
- }
295
- async updateCustomBuiltinExtensionsCache() {
296
- if (!this._updateCustomBuiltinExtensionsCachePromise) {
297
- this._updateCustomBuiltinExtensionsCachePromise = (async () => {
298
- this.logService.info('Updating additional builtin extensions cache');
299
- const { extensions, extensionGalleryResources } = await this.readCustomBuiltinExtensionsInfoFromEnv();
300
- const [galleryWebExtensions, extensionGalleryResourceWebExtensions] = await Promise.all([
301
- this.resolveBuiltinGalleryExtensions(extensions),
302
- this.resolveBuiltinExtensionGalleryResources(extensionGalleryResources)
303
- ]);
304
- const webExtensionsMap = ( new Map());
305
- for (const webExtension of [...galleryWebExtensions, ...extensionGalleryResourceWebExtensions]) {
306
- webExtensionsMap.set(webExtension.identifier.id.toLowerCase(), webExtension);
307
- }
308
- await this.resolveDependenciesAndPackedExtensions(extensionGalleryResourceWebExtensions, webExtensionsMap);
309
- const webExtensions = [...( webExtensionsMap.values())];
310
- await this.writeCustomBuiltinExtensionsCache(() => webExtensions);
311
- return webExtensions;
312
- })();
313
- }
314
- return this._updateCustomBuiltinExtensionsCachePromise;
315
- }
316
- async resolveBuiltinExtensionGalleryResources(extensionGalleryResources) {
317
- if (extensionGalleryResources.length === 0) {
318
- return [];
319
- }
320
- const result = ( new Map());
321
- const extensionInfos = [];
322
- await Promise.all(( extensionGalleryResources.map(async (extensionGalleryResource) => {
323
- try {
324
- const webExtension = await this.toWebExtensionFromExtensionGalleryResource(extensionGalleryResource);
325
- result.set(webExtension.identifier.id.toLowerCase(), webExtension);
326
- extensionInfos.push({ id: webExtension.identifier.id, version: webExtension.version });
327
- }
328
- catch (error) {
329
- this.logService.info(`Ignoring additional builtin extension from gallery resource ${( extensionGalleryResource.toString())} because there is an error while converting it into web extension`, getErrorMessage(error));
330
- }
331
- })));
332
- const galleryExtensions = await this.galleryService.getExtensions(extensionInfos, CancellationToken.None);
333
- for (const galleryExtension of galleryExtensions) {
334
- const webExtension = result.get(galleryExtension.identifier.id.toLowerCase());
335
- if (webExtension) {
336
- result.set(galleryExtension.identifier.id.toLowerCase(), {
337
- ...webExtension,
338
- identifier: { id: webExtension.identifier.id, uuid: galleryExtension.identifier.uuid },
339
- readmeUri: galleryExtension.assets.readme ? ( URI.parse(galleryExtension.assets.readme.uri)) : undefined,
340
- changelogUri: galleryExtension.assets.changelog ? ( URI.parse(galleryExtension.assets.changelog.uri)) : undefined,
341
- metadata: { isPreReleaseVersion: galleryExtension.properties.isPreReleaseVersion, preRelease: galleryExtension.properties.isPreReleaseVersion, isBuiltin: true, pinned: true }
342
- });
343
- }
344
- }
345
- return [...( result.values())];
346
- }
347
- async resolveBuiltinGalleryExtensions(extensions) {
348
- if (extensions.length === 0) {
349
- return [];
350
- }
351
- const webExtensions = [];
352
- const galleryExtensionsMap = await this.getExtensionsWithDependenciesAndPackedExtensions(extensions);
353
- const missingExtensions = extensions.filter(({ id }) => !( galleryExtensionsMap.has(id.toLowerCase())));
354
- if (missingExtensions.length) {
355
- this.logService.info('Skipping the additional builtin extensions because their compatible versions are not found.', missingExtensions);
356
- }
357
- await Promise.all(( [...( galleryExtensionsMap.values())].map(async (gallery) => {
358
- try {
359
- const webExtension = await this.toWebExtensionFromGallery(gallery, { isPreReleaseVersion: gallery.properties.isPreReleaseVersion, preRelease: gallery.properties.isPreReleaseVersion, isBuiltin: true });
360
- webExtensions.push(webExtension);
361
- }
362
- catch (error) {
363
- this.logService.info(`Ignoring additional builtin extension ${gallery.identifier.id} because there is an error while converting it into web extension`, getErrorMessage(error));
364
- }
365
- })));
366
- return webExtensions;
367
- }
368
- async resolveDependenciesAndPackedExtensions(webExtensions, result) {
369
- const extensionInfos = [];
370
- for (const webExtension of webExtensions) {
371
- for (const e of [...(webExtension.manifest?.extensionDependencies ?? []), ...(webExtension.manifest?.extensionPack ?? [])]) {
372
- if (!( result.has(e.toLowerCase()))) {
373
- extensionInfos.push({ id: e, version: webExtension.version });
374
- }
375
- }
376
- }
377
- if (extensionInfos.length === 0) {
378
- return;
379
- }
380
- const galleryExtensions = await this.getExtensionsWithDependenciesAndPackedExtensions(extensionInfos, ( new Set([...( result.keys())])));
381
- await Promise.all(( [...( galleryExtensions.values())].map(async (gallery) => {
382
- try {
383
- const webExtension = await this.toWebExtensionFromGallery(gallery, { isPreReleaseVersion: gallery.properties.isPreReleaseVersion, preRelease: gallery.properties.isPreReleaseVersion, isBuiltin: true });
384
- result.set(webExtension.identifier.id.toLowerCase(), webExtension);
385
- }
386
- catch (error) {
387
- this.logService.info(`Ignoring additional builtin extension ${gallery.identifier.id} because there is an error while converting it into web extension`, getErrorMessage(error));
388
- }
389
- })));
390
- }
391
- async getExtensionsWithDependenciesAndPackedExtensions(toGet, seen = ( new Set()), result = ( new Map())) {
392
- if (toGet.length === 0) {
393
- return result;
394
- }
395
- const extensions = await this.galleryService.getExtensions(toGet, { compatible: true, targetPlatform: TargetPlatform.WEB }, CancellationToken.None);
396
- const packsAndDependencies = ( new Map());
397
- for (const extension of extensions) {
398
- result.set(extension.identifier.id.toLowerCase(), extension);
399
- for (const id of [...(isNonEmptyArray(extension.properties.dependencies) ? extension.properties.dependencies : []), ...(isNonEmptyArray(extension.properties.extensionPack) ? extension.properties.extensionPack : [])]) {
400
- if (!( result.has(id.toLowerCase())) && !( packsAndDependencies.has(id.toLowerCase())) && !( seen.has(id.toLowerCase()))) {
401
- const extensionInfo = toGet.find(e => areSameExtensions(e, extension.identifier));
402
- packsAndDependencies.set(id.toLowerCase(), { id, preRelease: extensionInfo?.preRelease });
403
- }
404
- }
405
- }
406
- return this.getExtensionsWithDependenciesAndPackedExtensions([...( packsAndDependencies.values())].filter(({ id }) => !( result.has(id.toLowerCase()))), seen, result);
407
- }
408
- async scanSystemExtensions() {
409
- return this.readSystemExtensions();
410
- }
411
- async scanUserExtensions(profileLocation, scanOptions) {
412
- const extensions = ( new Map());
413
- const customBuiltinExtensions = await this.readCustomBuiltinExtensions(scanOptions);
414
- for (const extension of customBuiltinExtensions) {
415
- extensions.set(extension.identifier.id.toLowerCase(), extension);
416
- }
417
- const installedExtensions = await this.scanInstalledExtensions(profileLocation, scanOptions);
418
- for (const extension of installedExtensions) {
419
- extensions.set(extension.identifier.id.toLowerCase(), extension);
420
- }
421
- return [...( extensions.values())];
422
- }
423
- async scanExtensionsUnderDevelopment() {
424
- const devExtensions = this.environmentService.options?.developmentOptions?.extensions;
425
- const result = [];
426
- if (Array.isArray(devExtensions)) {
427
- await Promise.allSettled(( devExtensions.map(async (devExtension) => {
428
- try {
429
- const location = URI.revive(devExtension);
430
- if (URI.isUri(location)) {
431
- const webExtension = await this.toWebExtension(location);
432
- result.push(await this.toScannedExtension(webExtension, false));
433
- }
434
- else {
435
- this.logService.info(`Skipping the extension under development ${devExtension} as it is not URI type.`);
436
- }
437
- }
438
- catch (error) {
439
- this.logService.info(`Error while fetching the extension under development ${( devExtension.toString())}.`, getErrorMessage(error));
440
- }
441
- })));
442
- }
443
- return result;
444
- }
445
- async scanExistingExtension(extensionLocation, extensionType, profileLocation) {
446
- if (extensionType === ExtensionType.System) {
447
- const systemExtensions = await this.scanSystemExtensions();
448
- return systemExtensions.find(e => ( e.location.toString()) === ( extensionLocation.toString())) || null;
449
- }
450
- const userExtensions = await this.scanUserExtensions(profileLocation);
451
- return userExtensions.find(e => ( e.location.toString()) === ( extensionLocation.toString())) || null;
452
- }
453
- async scanExtensionManifest(extensionLocation) {
454
- try {
455
- return await this.getExtensionManifest(extensionLocation);
456
- }
457
- catch (error) {
458
- this.logService.warn(`Error while fetching manifest from ${( extensionLocation.toString())}`, getErrorMessage(error));
459
- return null;
460
- }
461
- }
462
- async addExtensionFromGallery(galleryExtension, metadata, profileLocation) {
463
- const webExtension = await this.toWebExtensionFromGallery(galleryExtension, metadata);
464
- return this.addWebExtension(webExtension, profileLocation);
465
- }
466
- async addExtension(location, metadata, profileLocation) {
467
- const webExtension = await this.toWebExtension(location, undefined, undefined, undefined, undefined, undefined, undefined, metadata);
468
- const extension = await this.toScannedExtension(webExtension, false);
469
- await this.addToInstalledExtensions([webExtension], profileLocation);
470
- return extension;
471
- }
472
- async removeExtension(extension, profileLocation) {
473
- await this.writeInstalledExtensions(profileLocation, installedExtensions => installedExtensions.filter(installedExtension => !areSameExtensions(installedExtension.identifier, extension.identifier)));
474
- }
475
- async updateMetadata(extension, metadata, profileLocation) {
476
- let updatedExtension = undefined;
477
- await this.writeInstalledExtensions(profileLocation, installedExtensions => {
478
- const result = [];
479
- for (const installedExtension of installedExtensions) {
480
- if (areSameExtensions(extension.identifier, installedExtension.identifier)) {
481
- installedExtension.metadata = { ...installedExtension.metadata, ...metadata };
482
- updatedExtension = installedExtension;
483
- result.push(installedExtension);
484
- }
485
- else {
486
- result.push(installedExtension);
487
- }
488
- }
489
- return result;
490
- });
491
- if (!updatedExtension) {
492
- throw ( new Error('Extension not found'));
493
- }
494
- return this.toScannedExtension(updatedExtension, extension.isBuiltin);
495
- }
496
- async copyExtensions(fromProfileLocation, toProfileLocation, filter) {
497
- const extensionsToCopy = [];
498
- const fromWebExtensions = await this.readInstalledExtensions(fromProfileLocation);
499
- await Promise.all(( fromWebExtensions.map(async (webExtension) => {
500
- const scannedExtension = await this.toScannedExtension(webExtension, false);
501
- if (filter(scannedExtension)) {
502
- extensionsToCopy.push(webExtension);
503
- }
504
- })));
505
- if (extensionsToCopy.length) {
506
- await this.addToInstalledExtensions(extensionsToCopy, toProfileLocation);
507
- }
508
- }
509
- async addWebExtension(webExtension, profileLocation) {
510
- const isSystem = !!(await this.scanSystemExtensions()).find(e => areSameExtensions(e.identifier, webExtension.identifier));
511
- const isBuiltin = !!webExtension.metadata?.isBuiltin;
512
- const extension = await this.toScannedExtension(webExtension, isBuiltin);
513
- if (isSystem) {
514
- await this.writeSystemExtensionsCache(systemExtensions => {
515
- systemExtensions = systemExtensions.filter(extension => !areSameExtensions(extension.identifier, webExtension.identifier));
516
- systemExtensions.push(webExtension);
517
- return systemExtensions;
518
- });
519
- return extension;
520
- }
521
- if (isBuiltin) {
522
- await this.writeCustomBuiltinExtensionsCache(customBuiltinExtensions => {
523
- customBuiltinExtensions = customBuiltinExtensions.filter(extension => !areSameExtensions(extension.identifier, webExtension.identifier));
524
- customBuiltinExtensions.push(webExtension);
525
- return customBuiltinExtensions;
526
- });
527
- const installedExtensions = await this.readInstalledExtensions(profileLocation);
528
- if (( installedExtensions.some(e => areSameExtensions(e.identifier, webExtension.identifier)))) {
529
- await this.addToInstalledExtensions([webExtension], profileLocation);
530
- }
531
- return extension;
532
- }
533
- await this.addToInstalledExtensions([webExtension], profileLocation);
534
- return extension;
535
- }
536
- async addToInstalledExtensions(webExtensions, profileLocation) {
537
- await this.writeInstalledExtensions(profileLocation, installedExtensions => {
538
- installedExtensions = installedExtensions.filter(installedExtension => ( webExtensions.some(
539
- extension => !areSameExtensions(installedExtension.identifier, extension.identifier)
540
- )));
541
- installedExtensions.push(...webExtensions);
542
- return installedExtensions;
543
- });
544
- }
545
- async scanInstalledExtensions(profileLocation, scanOptions) {
546
- let installedExtensions = await this.readInstalledExtensions(profileLocation);
547
- if (!this.uriIdentityService.extUri.isEqual(profileLocation, this.userDataProfilesService.defaultProfile.extensionsResource)) {
548
- installedExtensions = installedExtensions.filter(i => !i.metadata?.isApplicationScoped);
549
- const defaultProfileExtensions = await this.readInstalledExtensions(this.userDataProfilesService.defaultProfile.extensionsResource);
550
- installedExtensions.push(...defaultProfileExtensions.filter(i => i.metadata?.isApplicationScoped));
551
- }
552
- installedExtensions.sort((a, b) => a.identifier.id < b.identifier.id ? -1 : a.identifier.id > b.identifier.id ? 1 : semverExports.rcompare(a.version, b.version));
553
- const result = ( new Map());
554
- for (const webExtension of installedExtensions) {
555
- const existing = result.get(webExtension.identifier.id.toLowerCase());
556
- if (existing && semverExports.gt(existing.manifest.version, webExtension.version)) {
557
- continue;
558
- }
559
- const extension = await this.toScannedExtension(webExtension, false);
560
- if (extension.isValid || !scanOptions?.skipInvalidExtensions) {
561
- result.set(extension.identifier.id.toLowerCase(), extension);
562
- }
563
- else {
564
- this.logService.info(`Skipping invalid installed extension ${webExtension.identifier.id}`);
565
- }
566
- }
567
- return [...( result.values())];
568
- }
569
- async toWebExtensionFromGallery(galleryExtension, metadata) {
570
- const extensionLocation = await this.extensionResourceLoaderService.getExtensionGalleryResourceURL({
571
- publisher: galleryExtension.publisher,
572
- name: galleryExtension.name,
573
- version: galleryExtension.version,
574
- targetPlatform: galleryExtension.properties.targetPlatform === TargetPlatform.WEB ? TargetPlatform.WEB : undefined
575
- }, 'extension');
576
- if (!extensionLocation) {
577
- throw ( new Error('No extension gallery service configured.'));
578
- }
579
- return this.toWebExtensionFromExtensionGalleryResource(extensionLocation, galleryExtension.identifier, galleryExtension.assets.readme ? ( URI.parse(galleryExtension.assets.readme.uri)) : undefined, galleryExtension.assets.changelog ? ( URI.parse(galleryExtension.assets.changelog.uri)) : undefined, metadata);
580
- }
581
- async toWebExtensionFromExtensionGalleryResource(extensionLocation, identifier, readmeUri, changelogUri, metadata) {
582
- const extensionResources = await this.listExtensionResources(extensionLocation);
583
- const packageNLSResources = this.getPackageNLSResourceMapFromResources(extensionResources);
584
- const fallbackPackageNLSResource = extensionResources.find(e => basename(e) === 'package.nls.json');
585
- return this.toWebExtension(extensionLocation, identifier, undefined, packageNLSResources, fallbackPackageNLSResource ? ( URI.parse(fallbackPackageNLSResource)) : null, readmeUri, changelogUri, metadata);
586
- }
587
- getPackageNLSResourceMapFromResources(extensionResources) {
588
- const packageNLSResources = ( new Map());
589
- extensionResources.forEach(e => {
590
- const regexResult = /package\.nls\.([\w-]+)\.json/.exec(basename(e));
591
- if (regexResult?.[1]) {
592
- packageNLSResources.set(regexResult[1], ( URI.parse(e)));
593
- }
594
- });
595
- return packageNLSResources;
596
- }
597
- async toWebExtension(extensionLocation, identifier, manifest, packageNLSUris, fallbackPackageNLSUri, readmeUri, changelogUri, metadata) {
598
- if (!manifest) {
599
- try {
600
- manifest = await this.getExtensionManifest(extensionLocation);
601
- }
602
- catch (error) {
603
- throw ( new Error(`Error while fetching manifest from the location '${( extensionLocation.toString())}'. ${getErrorMessage(error)}`));
604
- }
605
- }
606
- if (!this.extensionManifestPropertiesService.canExecuteOnWeb(manifest)) {
607
- throw ( new Error(( localize(
608
- 13249,
609
- "Cannot add '{0}' because this extension is not a web extension.",
610
- manifest.displayName || manifest.name
611
- ))));
612
- }
613
- if (fallbackPackageNLSUri === undefined) {
614
- try {
615
- fallbackPackageNLSUri = joinPath(extensionLocation, 'package.nls.json');
616
- await this.extensionResourceLoaderService.readExtensionResource(fallbackPackageNLSUri);
617
- }
618
- catch (error) {
619
- fallbackPackageNLSUri = undefined;
620
- }
621
- }
622
- const defaultManifestTranslations = fallbackPackageNLSUri ? URI.isUri(fallbackPackageNLSUri) ? await this.getTranslations(fallbackPackageNLSUri) : fallbackPackageNLSUri : null;
623
- return {
624
- identifier: { id: getGalleryExtensionId(manifest.publisher, manifest.name), uuid: identifier?.uuid },
625
- version: manifest.version,
626
- location: extensionLocation,
627
- manifest,
628
- readmeUri,
629
- changelogUri,
630
- packageNLSUris,
631
- fallbackPackageNLSUri: URI.isUri(fallbackPackageNLSUri) ? fallbackPackageNLSUri : undefined,
632
- defaultManifestTranslations,
633
- metadata,
634
- };
635
- }
636
- async toScannedExtension(webExtension, isBuiltin, type = ExtensionType.User) {
637
- const validations = [];
638
- let manifest = webExtension.manifest;
639
- if (!manifest) {
640
- try {
641
- manifest = await this.getExtensionManifest(webExtension.location);
642
- }
643
- catch (error) {
644
- validations.push([Severity.Error, `Error while fetching manifest from the location '${webExtension.location}'. ${getErrorMessage(error)}`]);
645
- }
646
- }
647
- if (!manifest) {
648
- const [publisher, name] = webExtension.identifier.id.split('.');
649
- manifest = {
650
- name,
651
- publisher,
652
- version: webExtension.version,
653
- engines: { vscode: '*' },
654
- };
655
- }
656
- const packageNLSUri = webExtension.packageNLSUris?.get(Language.value().toLowerCase());
657
- const fallbackPackageNLS = webExtension.defaultManifestTranslations ?? webExtension.fallbackPackageNLSUri;
658
- if (packageNLSUri) {
659
- manifest = await this.translateManifest(manifest, packageNLSUri, fallbackPackageNLS);
660
- }
661
- else if (fallbackPackageNLS) {
662
- manifest = await this.translateManifest(manifest, fallbackPackageNLS);
663
- }
664
- const uuid = webExtension.metadata?.id;
665
- const validateApiVersion = this.extensionsEnabledWithApiProposalVersion.includes(webExtension.identifier.id.toLowerCase());
666
- validations.push(...validateExtensionManifest(this.productService.version, this.productService.date, webExtension.location, manifest, false, validateApiVersion));
667
- let isValid = true;
668
- for (const [severity, message] of validations) {
669
- if (severity === Severity.Error) {
670
- isValid = false;
671
- this.logService.error(message);
672
- }
673
- }
674
- if (manifest.enabledApiProposals && validateApiVersion) {
675
- manifest.enabledApiProposals = parseEnabledApiProposalNames([...manifest.enabledApiProposals]);
676
- }
677
- return {
678
- identifier: { id: webExtension.identifier.id, uuid: webExtension.identifier.uuid || uuid },
679
- location: webExtension.location,
680
- manifest,
681
- type,
682
- isBuiltin,
683
- readmeUrl: webExtension.readmeUri,
684
- changelogUrl: webExtension.changelogUri,
685
- metadata: webExtension.metadata,
686
- targetPlatform: TargetPlatform.WEB,
687
- validations,
688
- isValid,
689
- preRelease: !!webExtension.metadata?.preRelease,
690
- };
691
- }
692
- async listExtensionResources(extensionLocation) {
693
- try {
694
- const result = await this.extensionResourceLoaderService.readExtensionResource(extensionLocation);
695
- return JSON.parse(result);
696
- }
697
- catch (error) {
698
- this.logService.warn('Error while fetching extension resources list', getErrorMessage(error));
699
- }
700
- return [];
701
- }
702
- async translateManifest(manifest, nlsURL, fallbackNLS) {
703
- try {
704
- const translations = URI.isUri(nlsURL) ? await this.getTranslations(nlsURL) : nlsURL;
705
- const fallbackTranslations = URI.isUri(fallbackNLS) ? await this.getTranslations(fallbackNLS) : fallbackNLS;
706
- if (translations) {
707
- manifest = localizeManifest(this.logService, manifest, translations, fallbackTranslations);
708
- }
709
- }
710
- catch (error) { }
711
- return manifest;
712
- }
713
- async getExtensionManifest(location) {
714
- const url = joinPath(location, 'package.json');
715
- const content = await this.extensionResourceLoaderService.readExtensionResource(url);
716
- return JSON.parse(content);
717
- }
718
- async getTranslations(nlsUrl) {
719
- try {
720
- const content = await this.extensionResourceLoaderService.readExtensionResource(nlsUrl);
721
- return JSON.parse(content);
722
- }
723
- catch (error) {
724
- this.logService.error(`Error while fetching translations of an extension`, ( nlsUrl.toString()), getErrorMessage(error));
725
- }
726
- return undefined;
727
- }
728
- async readInstalledExtensions(profileLocation) {
729
- return this.withWebExtensions(profileLocation);
730
- }
731
- writeInstalledExtensions(profileLocation, updateFn) {
732
- return this.withWebExtensions(profileLocation, updateFn);
733
- }
734
- readCustomBuiltinExtensionsCache() {
735
- return this.withWebExtensions(this.customBuiltinExtensionsCacheResource);
736
- }
737
- writeCustomBuiltinExtensionsCache(updateFn) {
738
- return this.withWebExtensions(this.customBuiltinExtensionsCacheResource, updateFn);
739
- }
740
- readSystemExtensionsCache() {
741
- return this.withWebExtensions(this.systemExtensionsCacheResource);
742
- }
743
- writeSystemExtensionsCache(updateFn) {
744
- return this.withWebExtensions(this.systemExtensionsCacheResource, updateFn);
745
- }
746
- async withWebExtensions(file, updateFn) {
747
- if (!file) {
748
- return [];
749
- }
750
- return this.getResourceAccessQueue(file).queue(async () => {
751
- let webExtensions = [];
752
- try {
753
- const content = await this.fileService.readFile(file);
754
- const storedWebExtensions = JSON.parse(( content.value.toString()));
755
- for (const e of storedWebExtensions) {
756
- if (!e.location || !e.identifier || !e.version) {
757
- this.logService.info('Ignoring invalid extension while scanning', storedWebExtensions);
758
- continue;
759
- }
760
- let packageNLSUris;
761
- if (e.packageNLSUris) {
762
- packageNLSUris = ( new Map());
763
- Object.entries(e.packageNLSUris).forEach(([key, value]) => packageNLSUris.set(key, URI.revive(value)));
764
- }
765
- webExtensions.push({
766
- identifier: e.identifier,
767
- version: e.version,
768
- location: URI.revive(e.location),
769
- manifest: e.manifest,
770
- readmeUri: URI.revive(e.readmeUri),
771
- changelogUri: URI.revive(e.changelogUri),
772
- packageNLSUris,
773
- fallbackPackageNLSUri: URI.revive(e.fallbackPackageNLSUri),
774
- defaultManifestTranslations: e.defaultManifestTranslations,
775
- packageNLSUri: URI.revive(e.packageNLSUri),
776
- metadata: e.metadata,
777
- });
778
- }
779
- try {
780
- webExtensions = await this.migrateWebExtensions(webExtensions, file);
781
- }
782
- catch (error) {
783
- this.logService.error(`Error while migrating scanned extensions in ${( file.toString())}`, getErrorMessage(error));
784
- }
785
- }
786
- catch (error) {
787
- if (error.fileOperationResult !== FileOperationResult.FILE_NOT_FOUND) {
788
- this.logService.error(error);
789
- }
790
- }
791
- if (updateFn) {
792
- await this.storeWebExtensions(webExtensions = updateFn(webExtensions), file);
793
- }
794
- return webExtensions;
795
- });
796
- }
797
- async migrateWebExtensions(webExtensions, file) {
798
- let update = false;
799
- webExtensions = await Promise.all(( webExtensions.map(async (webExtension) => {
800
- if (!webExtension.manifest) {
801
- try {
802
- webExtension.manifest = await this.getExtensionManifest(webExtension.location);
803
- update = true;
804
- }
805
- catch (error) {
806
- this.logService.error(`Error while updating manifest of an extension in ${( file.toString())}`, webExtension.identifier.id, getErrorMessage(error));
807
- }
808
- }
809
- if (isUndefined(webExtension.defaultManifestTranslations)) {
810
- if (webExtension.fallbackPackageNLSUri) {
811
- try {
812
- const content = await this.extensionResourceLoaderService.readExtensionResource(webExtension.fallbackPackageNLSUri);
813
- webExtension.defaultManifestTranslations = JSON.parse(content);
814
- update = true;
815
- }
816
- catch (error) {
817
- this.logService.error(`Error while fetching default manifest translations of an extension`, webExtension.identifier.id, getErrorMessage(error));
818
- }
819
- }
820
- else {
821
- update = true;
822
- webExtension.defaultManifestTranslations = null;
823
- }
824
- }
825
- const migratedLocation = migratePlatformSpecificExtensionGalleryResourceURL(webExtension.location, TargetPlatform.WEB);
826
- if (migratedLocation) {
827
- update = true;
828
- webExtension.location = migratedLocation;
829
- }
830
- if (isUndefined(webExtension.metadata?.hasPreReleaseVersion) && webExtension.metadata?.preRelease) {
831
- update = true;
832
- webExtension.metadata.hasPreReleaseVersion = true;
833
- }
834
- return webExtension;
835
- })));
836
- if (update) {
837
- await this.storeWebExtensions(webExtensions, file);
838
- }
839
- return webExtensions;
840
- }
841
- async storeWebExtensions(webExtensions, file) {
842
- function toStringDictionary(dictionary) {
843
- if (!dictionary) {
844
- return undefined;
845
- }
846
- const result = Object.create(null);
847
- dictionary.forEach((value, key) => result[key] = value.toJSON());
848
- return result;
849
- }
850
- const storedWebExtensions = ( webExtensions.map(e => ({
851
- identifier: e.identifier,
852
- version: e.version,
853
- manifest: e.manifest,
854
- location: e.location.toJSON(),
855
- readmeUri: e.readmeUri?.toJSON(),
856
- changelogUri: e.changelogUri?.toJSON(),
857
- packageNLSUris: toStringDictionary(e.packageNLSUris),
858
- defaultManifestTranslations: e.defaultManifestTranslations,
859
- fallbackPackageNLSUri: e.fallbackPackageNLSUri?.toJSON(),
860
- metadata: e.metadata
861
- })));
862
- await this.fileService.writeFile(file, VSBuffer.fromString(JSON.stringify(storedWebExtensions)));
863
- }
864
- getResourceAccessQueue(file) {
865
- let resourceQueue = this.resourcesAccessQueueMap.get(file);
866
- if (!resourceQueue) {
867
- this.resourcesAccessQueueMap.set(file, resourceQueue = ( new Queue()));
868
- }
869
- return resourceQueue;
870
- }
871
- };
872
- WebExtensionsScannerService = ( __decorate([
873
- ( __param(0, IBrowserWorkbenchEnvironmentService)),
874
- ( __param(1, IBuiltinExtensionsScannerService)),
875
- ( __param(2, IFileService)),
876
- ( __param(3, ILogService)),
877
- ( __param(4, IExtensionGalleryService)),
878
- ( __param(5, IExtensionManifestPropertiesService)),
879
- ( __param(6, IExtensionResourceLoaderService)),
880
- ( __param(7, IExtensionStorageService)),
881
- ( __param(8, IStorageService)),
882
- ( __param(9, IProductService)),
883
- ( __param(10, IUserDataProfilesService)),
884
- ( __param(11, IUriIdentityService)),
885
- ( __param(12, ILifecycleService))
886
- ], WebExtensionsScannerService));
887
- if (isWeb) {
888
- registerAction2(class extends Action2 {
889
- constructor() {
890
- super({
891
- id: 'workbench.extensions.action.openInstalledWebExtensionsResource',
892
- title: ( localize2(13250, 'Open Installed Web Extensions Resource')),
893
- category: Categories.Developer,
894
- f1: true,
895
- precondition: IsWebContext
896
- });
897
- }
898
- run(serviceAccessor) {
899
- const editorService = serviceAccessor.get(IEditorService);
900
- const userDataProfileService = serviceAccessor.get(IUserDataProfileService);
901
- editorService.openEditor({ resource: userDataProfileService.currentProfile.extensionsResource });
902
- }
903
- });
904
- }
905
-
906
- export { WebExtensionsScannerService };