@@ -16,7 +16,7 @@ import { URI } from 'vs/base/common/uri';
16
16
import { IHeaders , IRequestContext , IRequestOptions } from 'vs/base/parts/request/common/request' ;
17
17
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
18
18
import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
19
- import { DefaultIconPath , getFallbackTargetPlarforms , getTargetPlatform , IExtensionGalleryService , IExtensionIdentifier , IExtensionIdentifierWithVersion , IGalleryExtension , IGalleryExtensionAsset , IGalleryExtensionAssets , IGalleryExtensionVersion , InstallOperation , IQueryOptions , IExtensionsControlManifest , isIExtensionIdentifier , isNotWebExtensionInWebTargetPlatform , isTargetPlatformCompatible , ITranslation , SortBy , SortOrder , StatisticType , TargetPlatform , toTargetPlatform , WEB_EXTENSION_TAG , IExtensionIdentifierWithPreRelease } from 'vs/platform/extensionManagement/common/extensionManagement' ;
19
+ import { DefaultIconPath , getFallbackTargetPlarforms , getTargetPlatform , IExtensionGalleryService , IExtensionIdentifier , IExtensionInfo , IGalleryExtension , IGalleryExtensionAsset , IGalleryExtensionAssets , IGalleryExtensionVersion , InstallOperation , IQueryOptions , IExtensionsControlManifest , isNotWebExtensionInWebTargetPlatform , isTargetPlatformCompatible , ITranslation , SortBy , SortOrder , StatisticType , TargetPlatform , toTargetPlatform , WEB_EXTENSION_TAG } from 'vs/platform/extensionManagement/common/extensionManagement' ;
20
20
import { adoptToGalleryExtensionId , areSameExtensions , getGalleryExtensionId , getGalleryExtensionTelemetryData } from 'vs/platform/extensionManagement/common/extensionManagementUtil' ;
21
21
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions' ;
22
22
import { isEngineValid } from 'vs/platform/extensions/common/extensionValidator' ;
@@ -278,8 +278,8 @@ type GalleryServiceAdditionalQueryEvent = {
278
278
interface IExtensionCriteria {
279
279
readonly targetPlatform : TargetPlatform ;
280
280
readonly compatible : boolean ;
281
- readonly preRelease : boolean | IExtensionIdentifierWithPreRelease [ ] ;
282
- readonly versions ?: IExtensionIdentifierWithVersion [ ] ;
281
+ readonly preRelease : boolean | ( IExtensionIdentifier & { preRelease : boolean } ) [ ] ;
282
+ readonly versions ?: ( IExtensionIdentifier & { version : string } ) [ ] ;
283
283
}
284
284
285
285
class Query {
@@ -562,65 +562,52 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
562
562
return ! ! this . extensionsGalleryUrl ;
563
563
}
564
564
565
- getExtensions ( identifiers : ReadonlyArray < IExtensionIdentifier | IExtensionIdentifierWithVersion > , token : CancellationToken ) : Promise < IGalleryExtension [ ] > ;
566
- getExtensions ( identifiers : ReadonlyArray < IExtensionIdentifier | IExtensionIdentifierWithVersion > , includePreRelease : boolean , token : CancellationToken ) : Promise < IGalleryExtension [ ] > ;
567
- async getExtensions ( identifiers : ReadonlyArray < IExtensionIdentifier | IExtensionIdentifierWithVersion > , arg1 : any , arg2 ?: any ) : Promise < IGalleryExtension [ ] > {
568
- const preRelease = isBoolean ( arg1 ) ? arg1 : false ;
569
- const token : CancellationToken = isBoolean ( arg1 ) ? arg2 : arg1 ;
570
- const versions : IExtensionIdentifierWithVersion [ ] = ( identifiers as ReadonlyArray < IExtensionIdentifierWithVersion > ) . filter ( identifier => ! ! identifier . version ) ;
571
- const query = new Query ( )
572
- . withPage ( 1 , identifiers . length )
573
- . withFilter ( FilterType . ExtensionName , ...identifiers . map ( ( { id } ) => id . toLowerCase ( ) ) ) ;
574
-
575
- const { extensions } = await this . queryGalleryExtensions ( query , { targetPlatform : CURRENT_TARGET_PLATFORM , preRelease, versions, compatible : false } , token ) ;
576
- return extensions ;
577
- }
578
-
579
- async getCompatibleExtensions ( identifiers : ReadonlyArray < IExtensionIdentifierWithPreRelease > , targetPlatform : TargetPlatform ) : Promise < IGalleryExtension [ ] > {
580
- const names : string [ ] = [ ] ; const ids : string [ ] = [ ] ;
581
- for ( const identifier of identifiers ) {
582
- if ( identifier . uuid ) {
583
- ids . push ( identifier . uuid ) ;
565
+ getExtensions ( extensionInfos : ReadonlyArray < IExtensionInfo > , token : CancellationToken ) : Promise < IGalleryExtension [ ] > ;
566
+ getExtensions ( extensionInfos : ReadonlyArray < IExtensionInfo > , options : { targetPlatform : TargetPlatform , compatible ?: boolean } , token : CancellationToken ) : Promise < IGalleryExtension [ ] > ;
567
+ async getExtensions ( extensionInfos : ReadonlyArray < IExtensionInfo > , arg1 : any , arg2 ?: any ) : Promise < IGalleryExtension [ ] > {
568
+ const options = CancellationToken . isCancellationToken ( arg1 ) ? { targetPlatform : CURRENT_TARGET_PLATFORM } : arg1 as { targetPlatform : TargetPlatform , compatible ?: boolean } ;
569
+ const token = CancellationToken . isCancellationToken ( arg1 ) ? arg1 : arg2 as CancellationToken ;
570
+ const names : string [ ] = [ ] ; const ids : string [ ] = [ ] , preRelease : ( IExtensionIdentifier & { preRelease : boolean } ) [ ] = [ ] , versions : ( IExtensionIdentifier & { version : string } ) [ ] = [ ] ;
571
+ for ( const extensionInfo of extensionInfos ) {
572
+ if ( extensionInfo . uuid ) {
573
+ ids . push ( extensionInfo . uuid ) ;
584
574
} else {
585
- names . push ( identifier . id . toLowerCase ( ) ) ;
575
+ names . push ( extensionInfo . id ) ;
576
+ }
577
+ preRelease . push ( { ...extensionInfo , preRelease : ! ! extensionInfo . preRelease } ) ;
578
+ if ( extensionInfo . version ) {
579
+ versions . push ( { ...extensionInfo , version : extensionInfo . version } ) ;
586
580
}
587
581
}
588
582
589
583
if ( ! ids . length && ! names . length ) {
590
584
return [ ] ;
591
585
}
592
586
593
- let query = new Query ( ) . withPage ( 1 , identifiers . length ) ;
587
+ let query = new Query ( ) . withPage ( 1 , extensionInfos . length ) ;
594
588
if ( ids . length ) {
595
589
query = query . withFilter ( FilterType . ExtensionId , ...ids ) ;
596
590
}
597
591
if ( names . length ) {
598
592
query = query . withFilter ( FilterType . ExtensionName , ...names ) ;
599
593
}
600
594
601
- const { extensions } = await this . queryGalleryExtensions ( query , { targetPlatform, compatible : true , preRelease : [ ... identifiers ] } , CancellationToken . None ) ;
595
+ const { extensions } = await this . queryGalleryExtensions ( query , { targetPlatform : options . targetPlatform , preRelease, versions , compatible : ! ! options . compatible } , token ) ;
602
596
return extensions ;
603
597
}
604
598
605
- async getCompatibleExtension ( arg1 : IExtensionIdentifier | IGalleryExtension , includePreRelease : boolean , targetPlatform : TargetPlatform ) : Promise < IGalleryExtension | null > {
606
- const extension : IGalleryExtension | null = isIExtensionIdentifier ( arg1 ) ? null : arg1 ;
607
-
608
- if ( extension ) {
609
- if ( isNotWebExtensionInWebTargetPlatform ( extension . allTargetPlatforms , targetPlatform ) ) {
610
- return null ;
611
- }
612
- if ( await this . isExtensionCompatible ( extension , includePreRelease , targetPlatform ) ) {
613
- return extension ;
614
- }
615
- const query = new Query ( )
616
- . withFlags ( Flags . IncludeVersions )
617
- . withPage ( 1 , 1 )
618
- . withFilter ( FilterType . ExtensionId , extension . identifier . uuid ) ;
619
- const { extensions } = await this . queryGalleryExtensions ( query , { targetPlatform, compatible : true , preRelease : includePreRelease } , CancellationToken . None ) ;
620
- return extensions [ 0 ] || null ;
599
+ async getCompatibleExtension ( extension : IGalleryExtension , includePreRelease : boolean , targetPlatform : TargetPlatform ) : Promise < IGalleryExtension | null > {
600
+ if ( isNotWebExtensionInWebTargetPlatform ( extension . allTargetPlatforms , targetPlatform ) ) {
601
+ return null ;
621
602
}
622
-
623
- const extensions = await this . getCompatibleExtensions ( [ { ...( < IExtensionIdentifier > arg1 ) , preRelease : includePreRelease } ] , targetPlatform ) ;
603
+ if ( await this . isExtensionCompatible ( extension , includePreRelease , targetPlatform ) ) {
604
+ return extension ;
605
+ }
606
+ const query = new Query ( )
607
+ . withFlags ( Flags . IncludeVersions )
608
+ . withPage ( 1 , 1 )
609
+ . withFilter ( FilterType . ExtensionId , extension . identifier . uuid ) ;
610
+ const { extensions } = await this . queryGalleryExtensions ( query , { targetPlatform, compatible : true , preRelease : includePreRelease } , CancellationToken . None ) ;
624
611
return extensions [ 0 ] || null ;
625
612
}
626
613
0 commit comments