Skip to content

Commit 393e122

Browse files
authored
1 parent 01ef3f7 commit 393e122

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/vs/platform/extensionManagement/common/extensionsScannerService.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,7 @@ class ExtensionsScanner extends Disposable {
657657
const type = metadata?.isSystem ? ExtensionType.System : input.type;
658658
const isBuiltin = type === ExtensionType.System || !!metadata?.isBuiltin;
659659
manifest = await this.translateManifest(input.location, manifest, ExtensionScannerInput.createNlsConfiguration(input));
660-
if (manifest.enabledApiProposals && this.extensionsEnabledWithApiProposalVersion?.includes(id.toLowerCase())) {
661-
manifest.enabledApiProposals = parseEnabledApiProposalNames([...manifest.enabledApiProposals]);
662-
}
663-
const extension: IRelaxedScannedExtension = {
660+
let extension: IRelaxedScannedExtension = {
664661
type,
665662
identifier,
666663
manifest,
@@ -672,7 +669,13 @@ class ExtensionsScanner extends Disposable {
672669
isValid: true,
673670
validations: []
674671
};
675-
return input.validate ? this.validate(extension, input) : extension;
672+
if (input.validate) {
673+
extension = this.validate(extension, input);
674+
}
675+
if (manifest.enabledApiProposals && this.extensionsEnabledWithApiProposalVersion.includes(id.toLowerCase())) {
676+
manifest.enabledApiProposals = parseEnabledApiProposalNames([...manifest.enabledApiProposals]);
677+
}
678+
return extension;
676679
}
677680
} catch (e) {
678681
if (input.type !== ExtensionType.System) {
@@ -684,7 +687,8 @@ class ExtensionsScanner extends Disposable {
684687

685688
validate(extension: IRelaxedScannedExtension, input: ExtensionScannerInput): IRelaxedScannedExtension {
686689
let isValid = true;
687-
const validations = validateExtensionManifest(input.productVersion, input.productDate, input.location, extension.manifest, extension.isBuiltin);
690+
const validateApiVersion = this.extensionsEnabledWithApiProposalVersion.includes(extension.identifier.id.toLowerCase());
691+
const validations = validateExtensionManifest(input.productVersion, input.productDate, input.location, extension.manifest, extension.isBuiltin, validateApiVersion);
688692
for (const [severity, message] of validations) {
689693
if (severity === Severity.Error) {
690694
isValid = false;

src/vs/platform/extensions/common/extensionValidator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export function isValidVersion(_inputVersion: string | INormalizedVersion, _inpu
240240

241241
type ProductDate = string | Date | undefined;
242242

243-
export function validateExtensionManifest(productVersion: string, productDate: ProductDate, extensionLocation: URI, extensionManifest: IExtensionManifest, extensionIsBuiltin: boolean): readonly [Severity, string][] {
243+
export function validateExtensionManifest(productVersion: string, productDate: ProductDate, extensionLocation: URI, extensionManifest: IExtensionManifest, extensionIsBuiltin: boolean, validateApiVersion: boolean): readonly [Severity, string][] {
244244
const validations: [Severity, string][] = [];
245245
if (typeof extensionManifest.publisher !== 'undefined' && typeof extensionManifest.publisher !== 'string') {
246246
validations.push([Severity.Error, nls.localize('extensionDescription.publisher', "property publisher must be of type `string`.")]);
@@ -322,7 +322,7 @@ export function validateExtensionManifest(productVersion: string, productDate: P
322322
}
323323
}
324324

325-
if (extensionManifest.enabledApiProposals?.length) {
325+
if (validateApiVersion && extensionManifest.enabledApiProposals?.length) {
326326
const incompatibleNotices: string[] = [];
327327
if (!areApiProposalsCompatible([...extensionManifest.enabledApiProposals], incompatibleNotices)) {
328328
for (const notice of incompatibleNotices) {

src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { IBuiltinExtensionsScannerService, ExtensionType, IExtensionIdentifier, IExtension, IExtensionManifest, TargetPlatform } from 'vs/platform/extensions/common/extensions';
6+
import { IBuiltinExtensionsScannerService, ExtensionType, IExtensionIdentifier, IExtension, IExtensionManifest, TargetPlatform, IRelaxedExtensionManifest, parseEnabledApiProposalNames } from 'vs/platform/extensions/common/extensions';
77
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
88
import { IScannedExtension, IWebExtensionsScannerService, ScanOptions } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
99
import { isWeb, Language } from 'vs/base/common/platform';
@@ -99,6 +99,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
9999
private readonly systemExtensionsCacheResource: URI | undefined = undefined;
100100
private readonly customBuiltinExtensionsCacheResource: URI | undefined = undefined;
101101
private readonly resourcesAccessQueueMap = new ResourceMap<Queue<IWebExtension[]>>();
102+
private readonly extensionsEnabledWithApiProposalVersion: string[];
102103

103104
constructor(
104105
@IBrowserWorkbenchEnvironmentService private readonly environmentService: IBrowserWorkbenchEnvironmentService,
@@ -123,6 +124,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
123124
// Eventually update caches
124125
lifecycleService.when(LifecyclePhase.Eventually).then(() => this.updateCaches());
125126
}
127+
this.extensionsEnabledWithApiProposalVersion = productService.extensionsEnabledWithApiProposalVersion?.map(id => id.toLowerCase()) ?? [];
126128
}
127129

128130
private _customBuiltinExtensionsInfoPromise: Promise<{ extensions: ExtensionInfo[]; extensionsToMigrate: [string, string][]; extensionLocations: URI[]; extensionGalleryResources: URI[] }> | undefined;
@@ -735,7 +737,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
735737

736738
private async toScannedExtension(webExtension: IWebExtension, isBuiltin: boolean, type: ExtensionType = ExtensionType.User): Promise<IScannedExtension> {
737739
const validations: [Severity, string][] = [];
738-
let manifest: IExtensionManifest | undefined = webExtension.manifest;
740+
let manifest: IRelaxedExtensionManifest | undefined = webExtension.manifest;
739741

740742
if (!manifest) {
741743
try {
@@ -766,7 +768,8 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
766768

767769
const uuid = (<IGalleryMetadata | undefined>webExtension.metadata)?.id;
768770

769-
validations.push(...validateExtensionManifest(this.productService.version, this.productService.date, webExtension.location, manifest, false));
771+
const validateApiVersion = this.extensionsEnabledWithApiProposalVersion.includes(webExtension.identifier.id.toLowerCase());
772+
validations.push(...validateExtensionManifest(this.productService.version, this.productService.date, webExtension.location, manifest, false, validateApiVersion));
770773
let isValid = true;
771774
for (const [severity, message] of validations) {
772775
if (severity === Severity.Error) {
@@ -775,6 +778,10 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
775778
}
776779
}
777780

781+
if (manifest.enabledApiProposals && validateApiVersion) {
782+
manifest.enabledApiProposals = parseEnabledApiProposalNames([...manifest.enabledApiProposals]);
783+
}
784+
778785
return {
779786
identifier: { id: webExtension.identifier.id, uuid: webExtension.identifier.uuid || uuid },
780787
location: webExtension.location,
@@ -800,7 +807,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
800807
return [];
801808
}
802809

803-
private async translateManifest(manifest: IExtensionManifest, nlsURL: ITranslations | URI, fallbackNLS?: ITranslations | URI): Promise<IExtensionManifest> {
810+
private async translateManifest(manifest: IExtensionManifest, nlsURL: ITranslations | URI, fallbackNLS?: ITranslations | URI): Promise<IRelaxedExtensionManifest> {
804811
try {
805812
const translations = URI.isUri(nlsURL) ? await this.getTranslations(nlsURL) : nlsURL;
806813
const fallbackTranslations = URI.isUri(fallbackNLS) ? await this.getTranslations(fallbackNLS) : fallbackNLS;

0 commit comments

Comments
 (0)