@@ -48,8 +48,9 @@ type GalleryExtensionInfo = { readonly id: string; preRelease?: boolean; migrate
48
48
interface HostedExtensionInfo {
49
49
readonly location : UriComponents ;
50
50
readonly preRelease ?: boolean ;
51
- readonly packageNLSUris ?: Map < string , UriComponents > ;
52
- readonly fallbackPackageNLSUri ?: UriComponents ;
51
+ readonly packageJSON ?: IExtensionManifest ;
52
+ readonly defaultPackageTranslations ?: ITranslations | null ;
53
+ readonly packagetNLSUris ?: Map < string , UriComponents > ;
53
54
readonly readmeUri ?: UriComponents ;
54
55
readonly changelogUri ?: UriComponents ;
55
56
}
@@ -66,7 +67,8 @@ function isHostedExtensionInfo(obj: unknown): obj is HostedExtensionInfo {
66
67
const hostedExtensionInfo = obj as HostedExtensionInfo | undefined ;
67
68
return isUriComponents ( hostedExtensionInfo ?. location )
68
69
&& ( hostedExtensionInfo ?. preRelease === undefined || typeof hostedExtensionInfo . preRelease === 'boolean' )
69
- && ( hostedExtensionInfo ?. fallbackPackageNLSUri === undefined || isUriComponents ( hostedExtensionInfo ?. fallbackPackageNLSUri ) )
70
+ && ( hostedExtensionInfo ?. packageJSON === undefined || typeof hostedExtensionInfo . packageJSON === 'object' )
71
+ && ( hostedExtensionInfo ?. defaultPackageTranslations === undefined || hostedExtensionInfo ?. defaultPackageTranslations === null || typeof hostedExtensionInfo . defaultPackageTranslations === 'object' )
70
72
&& ( hostedExtensionInfo ?. changelogUri === undefined || isUriComponents ( hostedExtensionInfo ?. changelogUri ) )
71
73
&& ( hostedExtensionInfo ?. readmeUri === undefined || isUriComponents ( hostedExtensionInfo ?. readmeUri ) ) ;
72
74
}
@@ -241,11 +243,12 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
241
243
return [ ] ;
242
244
}
243
245
const result : IScannedExtension [ ] = [ ] ;
244
- await Promise . allSettled ( extensionLocations . map ( async ( { location, preRelease, packageNLSUris , fallbackPackageNLSUri , readmeUri, changelogUri } ) => {
246
+ await Promise . allSettled ( extensionLocations . map ( async ( { location, preRelease, packagetNLSUris , packageJSON , defaultPackageTranslations , readmeUri, changelogUri } ) => {
245
247
try {
246
248
const webExtension = await this . toWebExtension ( URI . revive ( location ) , undefined ,
247
- packageNLSUris ? [ ...packageNLSUris . entries ( ) ] . reduce ( ( result , [ key , value ] ) => { result . set ( key , URI . revive ( value ) ) ; return result ; } , new Map < string , URI > ( ) ) : undefined ,
248
- URI . revive ( fallbackPackageNLSUri ) ,
249
+ packageJSON ,
250
+ packagetNLSUris ? [ ...packagetNLSUris . entries ( ) ] . reduce ( ( result , [ key , value ] ) => { result . set ( key , URI . revive ( value ) ) ; return result ; } , new Map < string , URI > ( ) ) : undefined ,
251
+ defaultPackageTranslations ,
249
252
URI . revive ( readmeUri ) ,
250
253
URI . revive ( changelogUri ) ,
251
254
{ preRelease } ) ;
@@ -472,7 +475,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
472
475
}
473
476
474
477
async addExtension ( location : URI , metadata : Metadata , profileLocation : URI ) : Promise < IScannedExtension > {
475
- const webExtension = await this . toWebExtension ( location , undefined , undefined , undefined , undefined , undefined , metadata ) ;
478
+ const webExtension = await this . toWebExtension ( location , undefined , undefined , undefined , undefined , undefined , undefined , metadata ) ;
476
479
const extension = await this . toScannedExtension ( webExtension , false ) ;
477
480
await this . addToInstalledExtensions ( [ webExtension ] , profileLocation ) ;
478
481
return extension ;
@@ -611,6 +614,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
611
614
return this . toWebExtension (
612
615
extensionLocation ,
613
616
galleryExtension . identifier ,
617
+ undefined ,
614
618
packageNLSResources ,
615
619
fallbackPackageNLSResource ? URI . parse ( fallbackPackageNLSResource ) : null ,
616
620
galleryExtension . assets . readme ? URI . parse ( galleryExtension . assets . readme . uri ) : undefined ,
@@ -630,12 +634,13 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
630
634
return packageNLSResources ;
631
635
}
632
636
633
- private async toWebExtension ( extensionLocation : URI , identifier ?: IExtensionIdentifier , packageNLSUris ?: Map < string , URI > , fallbackPackageNLSUri ?: URI | null , readmeUri ?: URI , changelogUri ?: URI , metadata ?: Metadata ) : Promise < IWebExtension > {
634
- let manifest : IExtensionManifest ;
635
- try {
636
- manifest = await this . getExtensionManifest ( extensionLocation ) ;
637
- } catch ( error ) {
638
- throw new Error ( `Error while fetching manifest from the location '${ extensionLocation . toString ( ) } '. ${ getErrorMessage ( error ) } ` ) ;
637
+ private async toWebExtension ( extensionLocation : URI , identifier ?: IExtensionIdentifier , manifest ?: IExtensionManifest , packageNLSUris ?: Map < string , URI > , fallbackPackageNLSUri ?: URI | ITranslations | null , readmeUri ?: URI , changelogUri ?: URI , metadata ?: Metadata ) : Promise < IWebExtension > {
638
+ if ( ! manifest ) {
639
+ try {
640
+ manifest = await this . getExtensionManifest ( extensionLocation ) ;
641
+ } catch ( error ) {
642
+ throw new Error ( `Error while fetching manifest from the location '${ extensionLocation . toString ( ) } '. ${ getErrorMessage ( error ) } ` ) ;
643
+ }
639
644
}
640
645
641
646
if ( ! this . extensionManifestPropertiesService . canExecuteOnWeb ( manifest ) ) {
@@ -650,7 +655,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
650
655
fallbackPackageNLSUri = undefined ;
651
656
}
652
657
}
653
- const defaultManifestTranslations : ITranslations | null | undefined = fallbackPackageNLSUri ? await this . getTranslations ( fallbackPackageNLSUri ) : null ;
658
+ const defaultManifestTranslations : ITranslations | null | undefined = fallbackPackageNLSUri ? URI . isUri ( fallbackPackageNLSUri ) ? await this . getTranslations ( fallbackPackageNLSUri ) : fallbackPackageNLSUri : null ;
654
659
655
660
return {
656
661
identifier : { id : getGalleryExtensionId ( manifest . publisher , manifest . name ) , uuid : identifier ?. uuid } ,
@@ -660,7 +665,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
660
665
readmeUri,
661
666
changelogUri,
662
667
packageNLSUris,
663
- fallbackPackageNLSUri : fallbackPackageNLSUri ? fallbackPackageNLSUri : undefined ,
668
+ fallbackPackageNLSUri : URI . isUri ( fallbackPackageNLSUri ) ? fallbackPackageNLSUri : undefined ,
664
669
defaultManifestTranslations,
665
670
metadata,
666
671
} ;
0 commit comments