@@ -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 , 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' ;
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,39 +506,9 @@ 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 , preRelease : includePreRelease } ;
509
+ return { rawGalleryExtension, version : ( < IExtensionIdentifierWithVersion | undefined > identifiers . find ( identifier => areSameExtensions ( identifier , { id } ) ) ) ?. version } ;
510
510
} ) ;
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 ) ;
511
+ return this . converToGalleryExtensions ( galleryExtensionsByVersion , includePreRelease , CURRENT_TARGET_PLATFORM , ( ) => undefined , token ) ;
542
512
}
543
513
544
514
async getCompatibleExtension ( arg1 : IExtensionIdentifier | IGalleryExtension , includePreRelease : boolean , targetPlatform : TargetPlatform ) : Promise < IGalleryExtension | null > {
@@ -683,43 +653,43 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
683
653
684
654
const { galleryExtensions, total } = await this . queryGallery ( query , CURRENT_TARGET_PLATFORM , token ) ;
685
655
const telemetryData = ( index : number ) => ( { index : ( ( query . pageNumber - 1 ) * query . pageSize ) + index , querySource : options . source } ) ;
686
- const extensions = await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension, preRelease : ! ! options . includePreRelease } ) ) , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
656
+ const extensions = await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension } ) ) , ! ! options . includePreRelease , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
687
657
const getPage = async ( pageIndex : number , ct : CancellationToken ) => {
688
658
if ( ct . isCancellationRequested ) {
689
659
throw canceled ( ) ;
690
660
}
691
661
const nextPageQuery = query . withPage ( pageIndex + 1 ) ;
692
662
const { galleryExtensions } = await this . queryGallery ( nextPageQuery , CURRENT_TARGET_PLATFORM , ct ) ;
693
- return await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension, preRelease : ! ! options . includePreRelease } ) ) , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
663
+ return await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension } ) ) , ! ! options . includePreRelease , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
694
664
} ;
695
665
696
666
return { firstPage : extensions , total, pageSize : query . pageSize , getPage } as IPager < IGalleryExtension > ;
697
667
}
698
668
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 => {
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 => {
701
671
const allTargetPlatforms = getAllTargetPlatforms ( galleryExtension ) ;
702
672
let latestVersion = galleryExtension . versions [ 0 ] ;
703
673
latestVersion = galleryExtension . versions . find ( version => version . version === latestVersion . version && isTargetPlatformCompatible ( getTargetPlatformForExtensionVersion ( version ) , allTargetPlatforms , targetPlatform ) ) || latestVersion ;
704
- if ( isPreReleaseVersion ( latestVersion ) && ! preRelease ) {
674
+ if ( isPreReleaseVersion ( latestVersion ) && ! includePreRelease ) {
705
675
latestVersion = galleryExtension . versions . find ( version => version . version !== latestVersion . version && ! isPreReleaseVersion ( version ) ) || latestVersion ;
706
676
}
707
677
return toExtension ( galleryExtension , latestVersion , allTargetPlatforms , hasReleaseVersion , telemetryData ( index ) ) ;
708
678
} ;
709
679
const result : [ number , IGalleryExtension ] [ ] = [ ] ;
710
- const preReleaseVersions = new Map < string , { index : number , preRelease : boolean } > ( ) ;
680
+ const preReleaseVersions = new Map < string , number > ( ) ;
711
681
for ( let index = 0 ; index < rawGalleryExtensions . length ; index ++ ) {
712
- const { rawGalleryExtension, version, preRelease } = rawGalleryExtensions [ index ] ;
682
+ const { rawGalleryExtension, version } = rawGalleryExtensions [ index ] ;
713
683
const hasReleaseVersion = rawGalleryExtension . versions . some ( version => ! isPreReleaseVersion ( version ) ) ;
714
684
if ( version ) {
715
685
const versionAsset = rawGalleryExtension . versions . find ( v => v . version === version ) ;
716
686
if ( versionAsset ) {
717
687
result . push ( [ index , toExtension ( rawGalleryExtension , versionAsset , getAllTargetPlatforms ( rawGalleryExtension ) , hasReleaseVersion ) ] ) ;
718
688
}
719
689
} else {
720
- const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion , preRelease ) ;
690
+ const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion ) ;
721
691
if ( extension . properties . isPreReleaseVersion ) {
722
- preReleaseVersions . set ( extension . identifier . uuid , { index, preRelease } ) ;
692
+ preReleaseVersions . set ( extension . identifier . uuid , index ) ;
723
693
} else {
724
694
result . push ( [ index , extension ] ) ;
725
695
}
@@ -743,8 +713,8 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
743
713
}
744
714
for ( const rawGalleryExtension of galleryExtensions ) {
745
715
const hasReleaseVersion = rawGalleryExtension . versions . some ( version => ! isPreReleaseVersion ( version ) ) ;
746
- const { index, preRelease } = preReleaseVersions . get ( rawGalleryExtension . extensionId ) ! ;
747
- const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion , preRelease ) ;
716
+ const index = preReleaseVersions . get ( rawGalleryExtension . extensionId ) ! ;
717
+ const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion ) ;
748
718
result . push ( [ index , extension ] ) ;
749
719
}
750
720
}
0 commit comments