@@ -18,6 +18,7 @@ import { TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
18
18
import { getTelemetryLevel , supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils' ;
19
19
import { RemoteAuthorities } from 'vs/base/common/network' ;
20
20
import { getRemoteServerRootPath } from 'vs/platform/remote/common/remoteHosts' ;
21
+ import { TargetPlatform } from 'vs/platform/extensions/common/extensions' ;
21
22
22
23
const WEB_EXTENSION_RESOURCE_END_POINT = 'web-extension-resource' ;
23
24
@@ -42,9 +43,20 @@ export interface IExtensionResourceLoaderService {
42
43
/**
43
44
* Computes the URL of a extension gallery resource. Returns `undefined` if gallery does not provide extension resources.
44
45
*/
45
- getExtensionGalleryResourceURL ( galleryExtension : { publisher : string ; name : string ; version : string } , path ?: string ) : URI | undefined ;
46
+ getExtensionGalleryResourceURL ( galleryExtension : { publisher : string ; name : string ; version : string ; targetPlatform ?: TargetPlatform } , path ?: string ) : URI | undefined ;
46
47
}
47
48
49
+ export function migratePlatformSpecificExtensionGalleryResourceURL ( resource : URI , targetPlatform : TargetPlatform ) : URI | undefined {
50
+ if ( resource . query !== `target=${ targetPlatform } ` ) {
51
+ return undefined ;
52
+ }
53
+ const paths = resource . path . split ( '/' ) ;
54
+ if ( ! paths [ 3 ] ) {
55
+ return undefined ;
56
+ }
57
+ paths [ 3 ] = `${ paths [ 3 ] } +${ targetPlatform } ` ;
58
+ return resource . with ( { query : null , path : paths . join ( '/' ) } ) ;
59
+ }
48
60
49
61
export abstract class AbstractExtensionResourceLoaderService implements IExtensionResourceLoaderService {
50
62
@@ -72,15 +84,24 @@ export abstract class AbstractExtensionResourceLoaderService implements IExtensi
72
84
return this . _extensionGalleryResourceUrlTemplate !== undefined ;
73
85
}
74
86
75
- public getExtensionGalleryResourceURL ( galleryExtension : { publisher : string ; name : string ; version : string } , path ?: string ) : URI | undefined {
87
+ public getExtensionGalleryResourceURL ( { publisher , name , version , targetPlatform } : { publisher : string ; name : string ; version : string ; targetPlatform ?: TargetPlatform } , path ?: string ) : URI | undefined {
76
88
if ( this . _extensionGalleryResourceUrlTemplate ) {
77
- const uri = URI . parse ( format2 ( this . _extensionGalleryResourceUrlTemplate , { publisher : galleryExtension . publisher , name : galleryExtension . name , version : galleryExtension . version , path : 'extension' } ) ) ;
89
+ const uri = URI . parse ( format2 ( this . _extensionGalleryResourceUrlTemplate , {
90
+ publisher,
91
+ name,
92
+ version : targetPlatform !== undefined
93
+ && targetPlatform !== TargetPlatform . UNDEFINED
94
+ && targetPlatform !== TargetPlatform . UNKNOWN
95
+ && targetPlatform !== TargetPlatform . UNIVERSAL
96
+ ? `${ version } +${ targetPlatform } `
97
+ : version ,
98
+ path : 'extension'
99
+ } ) ) ;
78
100
return this . _isWebExtensionResourceEndPoint ( uri ) ? uri . with ( { scheme : RemoteAuthorities . getPreferredWebSchema ( ) } ) : uri ;
79
101
}
80
102
return undefined ;
81
103
}
82
104
83
-
84
105
public abstract readExtensionResource ( uri : URI ) : Promise < string > ;
85
106
86
107
protected isExtensionGalleryResource ( uri : URI ) {
0 commit comments