@@ -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 } from 'vs/platform/extensionManagement/common/extensionManagement' ;
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' ;
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' ;
@@ -506,9 +506,39 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
506
506
const { galleryExtensions } = await this . queryGallery ( query , CURRENT_TARGET_PLATFORM , CancellationToken . None ) ;
507
507
const galleryExtensionsByVersion = galleryExtensions . map ( rawGalleryExtension => {
508
508
const id = getGalleryExtensionId ( rawGalleryExtension . publisher . publisherName , rawGalleryExtension . extensionName ) ;
509
- return { rawGalleryExtension, version : ( < IExtensionIdentifierWithVersion | undefined > identifiers . find ( identifier => areSameExtensions ( identifier , { id } ) ) ) ?. version } ;
509
+ return { rawGalleryExtension, version : ( < IExtensionIdentifierWithVersion | undefined > identifiers . find ( identifier => areSameExtensions ( identifier , { id } ) ) ) ?. version , preRelease : includePreRelease } ;
510
510
} ) ;
511
- return this . converToGalleryExtensions ( galleryExtensionsByVersion , includePreRelease , CURRENT_TARGET_PLATFORM , ( ) => undefined , token ) ;
511
+ return this . converToGalleryExtensions ( galleryExtensionsByVersion , CURRENT_TARGET_PLATFORM , ( ) => undefined , token ) ;
512
+ }
513
+
514
+ async getExtensions2 ( identifiers : ReadonlyArray < IExtensionIdentifierWithPreRelease > ) : Promise < IGalleryExtension [ ] > {
515
+ const names : string [ ] = [ ] ; const ids : string [ ] = [ ] ;
516
+ for ( const identifier of identifiers ) {
517
+ if ( identifier . uuid ) {
518
+ ids . push ( identifier . uuid ) ;
519
+ } else {
520
+ names . push ( identifier . id . toLowerCase ( ) ) ;
521
+ }
522
+ }
523
+ let query = new Query ( )
524
+ . withFlags ( Flags . IncludeAssetUri , Flags . IncludeStatistics , Flags . IncludeCategoryAndTags , Flags . IncludeFiles , Flags . IncludeVersionProperties , Flags . IncludeLatestVersionOnly )
525
+ . withPage ( 1 , identifiers . length )
526
+ . withFilter ( FilterType . Target , 'Microsoft.VisualStudio.Code' ) ;
527
+ if ( ids . length ) {
528
+ query = query . withFilter ( FilterType . ExtensionId , ...ids ) ;
529
+ }
530
+ if ( names . length ) {
531
+ query = query . withFilter ( FilterType . ExtensionId , ...names ) ;
532
+ }
533
+
534
+ const { galleryExtensions : rawGalleryExtensions } = await this . queryGallery ( query , CURRENT_TARGET_PLATFORM , CancellationToken . None ) ;
535
+ const rawGalleryExtensionsInput = rawGalleryExtensions . map ( rawGalleryExtension => {
536
+ const id = getGalleryExtensionId ( rawGalleryExtension . publisher . publisherName , rawGalleryExtension . extensionName ) ;
537
+ const identifier = identifiers . find ( identifier => areSameExtensions ( identifier , { id, uuid : rawGalleryExtension . extensionId } ) ) ;
538
+ return { rawGalleryExtension, preRelease : ! ! identifier ?. preRelease } ;
539
+ } ) ;
540
+
541
+ return this . converToGalleryExtensions ( rawGalleryExtensionsInput , CURRENT_TARGET_PLATFORM , ( ) => undefined , CancellationToken . None ) ;
512
542
}
513
543
514
544
async getCompatibleExtension ( arg1 : IExtensionIdentifier | IGalleryExtension , includePreRelease : boolean , targetPlatform : TargetPlatform ) : Promise < IGalleryExtension | null > {
@@ -653,43 +683,43 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
653
683
654
684
const { galleryExtensions, total } = await this . queryGallery ( query , CURRENT_TARGET_PLATFORM , token ) ;
655
685
const telemetryData = ( index : number ) => ( { index : ( ( query . pageNumber - 1 ) * query . pageSize ) + index , querySource : options . source } ) ;
656
- const extensions = await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension } ) ) , ! ! options . includePreRelease , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
686
+ const extensions = await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension, preRelease : ! ! options . includePreRelease } ) ) , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
657
687
const getPage = async ( pageIndex : number , ct : CancellationToken ) => {
658
688
if ( ct . isCancellationRequested ) {
659
689
throw canceled ( ) ;
660
690
}
661
691
const nextPageQuery = query . withPage ( pageIndex + 1 ) ;
662
692
const { galleryExtensions } = await this . queryGallery ( nextPageQuery , CURRENT_TARGET_PLATFORM , ct ) ;
663
- return await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension } ) ) , ! ! options . includePreRelease , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
693
+ return await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension, preRelease : ! ! options . includePreRelease } ) ) , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
664
694
} ;
665
695
666
696
return { firstPage : extensions , total, pageSize : query . pageSize , getPage } as IPager < IGalleryExtension > ;
667
697
}
668
698
669
- private async converToGalleryExtensions ( rawGalleryExtensions : { rawGalleryExtension : IRawGalleryExtension , version ?: string } [ ] , includePreRelease : boolean , targetPlatform : TargetPlatform , telemetryData : ( index : number ) => IStringDictionary < any > | undefined , token : CancellationToken ) : Promise < IGalleryExtension [ ] > {
670
- const toExtensionWithLatestVersion = ( galleryExtension : IRawGalleryExtension , index : number , hasReleaseVersion : boolean ) : IGalleryExtension => {
699
+ private async converToGalleryExtensions ( rawGalleryExtensions : { rawGalleryExtension : IRawGalleryExtension , preRelease : boolean , version ?: string } [ ] , targetPlatform : TargetPlatform , telemetryData : ( index : number ) => IStringDictionary < any > | undefined , token : CancellationToken ) : Promise < IGalleryExtension [ ] > {
700
+ const toExtensionWithLatestVersion = ( galleryExtension : IRawGalleryExtension , index : number , hasReleaseVersion : boolean , preRelease : boolean ) : IGalleryExtension => {
671
701
const allTargetPlatforms = getAllTargetPlatforms ( galleryExtension ) ;
672
702
let latestVersion = galleryExtension . versions [ 0 ] ;
673
703
latestVersion = galleryExtension . versions . find ( version => version . version === latestVersion . version && isTargetPlatformCompatible ( getTargetPlatformForExtensionVersion ( version ) , allTargetPlatforms , targetPlatform ) ) || latestVersion ;
674
- if ( isPreReleaseVersion ( latestVersion ) && ! includePreRelease ) {
704
+ if ( isPreReleaseVersion ( latestVersion ) && ! preRelease ) {
675
705
latestVersion = galleryExtension . versions . find ( version => version . version !== latestVersion . version && ! isPreReleaseVersion ( version ) ) || latestVersion ;
676
706
}
677
707
return toExtension ( galleryExtension , latestVersion , allTargetPlatforms , hasReleaseVersion , telemetryData ( index ) ) ;
678
708
} ;
679
709
const result : [ number , IGalleryExtension ] [ ] = [ ] ;
680
- const preReleaseVersions = new Map < string , number > ( ) ;
710
+ const preReleaseVersions = new Map < string , { index : number , preRelease : boolean } > ( ) ;
681
711
for ( let index = 0 ; index < rawGalleryExtensions . length ; index ++ ) {
682
- const { rawGalleryExtension, version } = rawGalleryExtensions [ index ] ;
712
+ const { rawGalleryExtension, version, preRelease } = rawGalleryExtensions [ index ] ;
683
713
const hasReleaseVersion = rawGalleryExtension . versions . some ( version => ! isPreReleaseVersion ( version ) ) ;
684
714
if ( version ) {
685
715
const versionAsset = rawGalleryExtension . versions . find ( v => v . version === version ) ;
686
716
if ( versionAsset ) {
687
717
result . push ( [ index , toExtension ( rawGalleryExtension , versionAsset , getAllTargetPlatforms ( rawGalleryExtension ) , hasReleaseVersion ) ] ) ;
688
718
}
689
719
} else {
690
- const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion ) ;
720
+ const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion , preRelease ) ;
691
721
if ( extension . properties . isPreReleaseVersion ) {
692
- preReleaseVersions . set ( extension . identifier . uuid , index ) ;
722
+ preReleaseVersions . set ( extension . identifier . uuid , { index, preRelease } ) ;
693
723
} else {
694
724
result . push ( [ index , extension ] ) ;
695
725
}
@@ -713,8 +743,8 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
713
743
}
714
744
for ( const rawGalleryExtension of galleryExtensions ) {
715
745
const hasReleaseVersion = rawGalleryExtension . versions . some ( version => ! isPreReleaseVersion ( version ) ) ;
716
- const index = preReleaseVersions . get ( rawGalleryExtension . extensionId ) ! ;
717
- const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion ) ;
746
+ const { index, preRelease } = preReleaseVersions . get ( rawGalleryExtension . extensionId ) ! ;
747
+ const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion , preRelease ) ;
718
748
result . push ( [ index , extension ] ) ;
719
749
}
720
750
}
0 commit comments