3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
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' ;
7
7
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService' ;
8
8
import { IScannedExtension , IWebExtensionsScannerService , ScanOptions } from 'vs/workbench/services/extensionManagement/common/extensionManagement' ;
9
9
import { isWeb , Language } from 'vs/base/common/platform' ;
@@ -99,6 +99,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
99
99
private readonly systemExtensionsCacheResource : URI | undefined = undefined ;
100
100
private readonly customBuiltinExtensionsCacheResource : URI | undefined = undefined ;
101
101
private readonly resourcesAccessQueueMap = new ResourceMap < Queue < IWebExtension [ ] > > ( ) ;
102
+ private readonly extensionsEnabledWithApiProposalVersion : string [ ] ;
102
103
103
104
constructor (
104
105
@IBrowserWorkbenchEnvironmentService private readonly environmentService : IBrowserWorkbenchEnvironmentService ,
@@ -123,6 +124,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
123
124
// Eventually update caches
124
125
lifecycleService . when ( LifecyclePhase . Eventually ) . then ( ( ) => this . updateCaches ( ) ) ;
125
126
}
127
+ this . extensionsEnabledWithApiProposalVersion = productService . extensionsEnabledWithApiProposalVersion ?. map ( id => id . toLowerCase ( ) ) ?? [ ] ;
126
128
}
127
129
128
130
private _customBuiltinExtensionsInfoPromise : Promise < { extensions : ExtensionInfo [ ] ; extensionsToMigrate : [ string , string ] [ ] ; extensionLocations : URI [ ] ; extensionGalleryResources : URI [ ] } > | undefined ;
@@ -735,7 +737,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
735
737
736
738
private async toScannedExtension ( webExtension : IWebExtension , isBuiltin : boolean , type : ExtensionType = ExtensionType . User ) : Promise < IScannedExtension > {
737
739
const validations : [ Severity , string ] [ ] = [ ] ;
738
- let manifest : IExtensionManifest | undefined = webExtension . manifest ;
740
+ let manifest : IRelaxedExtensionManifest | undefined = webExtension . manifest ;
739
741
740
742
if ( ! manifest ) {
741
743
try {
@@ -766,7 +768,8 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
766
768
767
769
const uuid = ( < IGalleryMetadata | undefined > webExtension . metadata ) ?. id ;
768
770
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 ) ) ;
770
773
let isValid = true ;
771
774
for ( const [ severity , message ] of validations ) {
772
775
if ( severity === Severity . Error ) {
@@ -775,6 +778,10 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
775
778
}
776
779
}
777
780
781
+ if ( manifest . enabledApiProposals && validateApiVersion ) {
782
+ manifest . enabledApiProposals = parseEnabledApiProposalNames ( [ ...manifest . enabledApiProposals ] ) ;
783
+ }
784
+
778
785
return {
779
786
identifier : { id : webExtension . identifier . id , uuid : webExtension . identifier . uuid || uuid } ,
780
787
location : webExtension . location ,
@@ -800,7 +807,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
800
807
return [ ] ;
801
808
}
802
809
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 > {
804
811
try {
805
812
const translations = URI . isUri ( nlsURL ) ? await this . getTranslations ( nlsURL ) : nlsURL ;
806
813
const fallbackTranslations = URI . isUri ( fallbackNLS ) ? await this . getTranslations ( fallbackNLS ) : fallbackNLS ;
0 commit comments