extensionManagement.ts 2.8 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6 7
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

8
import nls = require('vs/nls');
9
import { TPromise } from 'vs/base/common/winjs.base';
E
Erich Gamma 已提交
10 11 12 13 14 15 16
import Event from 'vs/base/common/event';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';

export interface IExtensionManifest {
	name: string;
	publisher: string;
	version: string;
17
	engines: { vscode: string };
E
Erich Gamma 已提交
18 19
	displayName?: string;
	description?: string;
J
Joao Moreno 已提交
20
	main?: string;
E
Erich Gamma 已提交
21 22
}

23 24 25 26
export interface IGalleryVersion {
	version: string;
	date: string;
	manifestUrl: string;
J
Joao Moreno 已提交
27
	readmeUrl: string;
28
	downloadUrl: string;
J
Joao Moreno 已提交
29
	iconUrl: string;
30
	downloadHeaders: { [key: string]: string; };
31 32
}

J
Joao Moreno 已提交
33
export interface IGalleryMetadata {
E
Erich Gamma 已提交
34 35
	publisherId: string;
	publisherDisplayName: string;
J
Joao Moreno 已提交
36
	installCount: number;
37
	versions: IGalleryVersion[];
E
Erich Gamma 已提交
38 39
}

J
Joao Moreno 已提交
40 41 42 43 44 45
export interface IGalleryExtension {
	id: string;
	manifest: IExtensionManifest;
	metadata: IGalleryMetadata;
}

J
Joao Moreno 已提交
46
export interface IExtension {
J
Joao Moreno 已提交
47
	id: string;
J
Joao Moreno 已提交
48 49 50
	manifest: IExtensionManifest;
}

J
Joao Moreno 已提交
51 52
export const IExtensionManagementService = createDecorator<IExtensionManagementService>('extensionManagementService');
export const IExtensionGalleryService = createDecorator<IExtensionGalleryService>('extensionGalleryService');
E
Erich Gamma 已提交
53

J
Joao Moreno 已提交
54 55
export interface IQueryOptions {
	text?: string;
J
Joao Moreno 已提交
56
	ids?: string[];
J
Joao Moreno 已提交
57 58 59 60
	pageSize?: number;
}

export interface IQueryResult {
J
Joao Moreno 已提交
61
	firstPage: IGalleryExtension[];
J
Joao Moreno 已提交
62
	total: number;
J
Joao Moreno 已提交
63
	pageSize: number;
J
Joao Moreno 已提交
64
	getPage(pageNumber: number): TPromise<IGalleryExtension[]>;
J
Joao Moreno 已提交
65 66
}

J
Joao Moreno 已提交
67
export interface IExtensionGalleryService {
E
Erich Gamma 已提交
68 69
	serviceId: ServiceIdentifier<any>;
	isEnabled(): boolean;
J
Joao Moreno 已提交
70
	query(options?: IQueryOptions): TPromise<IQueryResult>;
E
Erich Gamma 已提交
71 72
}

J
Joao Moreno 已提交
73 74
export type DidInstallExtensionEvent = { id: string; error?: Error; };

J
Joao Moreno 已提交
75
export interface IExtensionManagementService {
E
Erich Gamma 已提交
76 77
	serviceId: ServiceIdentifier<any>;

J
Joao Moreno 已提交
78 79 80 81 82
	onInstallExtension: Event<string>;
	onDidInstallExtension: Event<DidInstallExtensionEvent>;
	onUninstallExtension: Event<string>;
	onDidUninstallExtension: Event<string>;

J
Joao Moreno 已提交
83
	install(extension: IGalleryExtension): TPromise<void>;
J
Joao Moreno 已提交
84
	install(zipPath: string): TPromise<void>;
E
Erich Gamma 已提交
85
	uninstall(extension: IExtension): TPromise<void>;
J
Joao Moreno 已提交
86
	getInstalled(includeDuplicateVersions?: boolean): TPromise<IExtension[]>;
E
Erich Gamma 已提交
87
}
88

J
Joao Moreno 已提交
89
export const IExtensionTipsService = createDecorator<IExtensionTipsService>('extensionTipsService');
90 91

export interface IExtensionTipsService {
J
Johannes Rieken 已提交
92
	serviceId: ServiceIdentifier<IExtensionTipsService>;
J
Joao Moreno 已提交
93
	getRecommendations(): TPromise<IExtension[]>;
94 95
}

I
isidor 已提交
96 97
export const ExtensionsLabel = nls.localize('extensions', "Extensions");
export const ExtensionsChannelId = 'extensions';