extensionManagement.ts 3.1 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
import Event from 'vs/base/common/event';
J
Joao Moreno 已提交
11
import { IPager } from 'vs/base/common/paging';
E
Erich Gamma 已提交
12 13 14 15 16 17
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';

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

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

J
Joao Moreno 已提交
35 36 37 38 39 40 41 42 43
export interface IExtensionIdentity {
	name: string;
	publisher: string;
}

export interface IGalleryExtension {
	id: string;
	name: string;
	displayName: string;
E
Erich Gamma 已提交
44
	publisherId: string;
J
Joao Moreno 已提交
45
	publisher: string;
E
Erich Gamma 已提交
46
	publisherDisplayName: string;
J
Joao Moreno 已提交
47
	description: string;
J
Joao Moreno 已提交
48
	installCount: number;
49
	versions: IGalleryVersion[];
E
Erich Gamma 已提交
50 51
}

J
Joao Moreno 已提交
52
export interface IGalleryMetadata {
53 54 55
	id: string;
	publisherId: string;
	publisherDisplayName: string;
J
Joao Moreno 已提交
56 57
}

J
Joao Moreno 已提交
58
export interface ILocalExtension {
J
Joao Moreno 已提交
59
	id: string;
J
Joao Moreno 已提交
60
	manifest: IExtensionManifest;
J
Joao Moreno 已提交
61
	metadata: IGalleryMetadata;
J
Joao Moreno 已提交
62
	path: string;
J
Joao Moreno 已提交
63 64
}

J
Joao Moreno 已提交
65 66
export const IExtensionManagementService = createDecorator<IExtensionManagementService>('extensionManagementService');
export const IExtensionGalleryService = createDecorator<IExtensionGalleryService>('extensionGalleryService');
E
Erich Gamma 已提交
67

J
Joao Moreno 已提交
68 69
export interface IQueryOptions {
	text?: string;
J
Joao Moreno 已提交
70
	ids?: string[];
J
Joao Moreno 已提交
71 72 73
	pageSize?: number;
}

J
Joao Moreno 已提交
74
export interface IExtensionGalleryService {
E
Erich Gamma 已提交
75 76
	serviceId: ServiceIdentifier<any>;
	isEnabled(): boolean;
J
Joao Moreno 已提交
77
	query(options?: IQueryOptions): TPromise<IPager<IGalleryExtension>>;
E
Erich Gamma 已提交
78 79
}

J
Joao Moreno 已提交
80 81
export type InstallExtensionEvent = { id: string; gallery?: IGalleryExtension; };
export type DidInstallExtensionEvent = { id: string; local?: ILocalExtension; error?: Error; };
J
Joao Moreno 已提交
82

J
Joao Moreno 已提交
83
export interface IExtensionManagementService {
E
Erich Gamma 已提交
84 85
	serviceId: ServiceIdentifier<any>;

J
Joao Moreno 已提交
86
	onInstallExtension: Event<InstallExtensionEvent>;
J
Joao Moreno 已提交
87 88 89 90
	onDidInstallExtension: Event<DidInstallExtensionEvent>;
	onUninstallExtension: Event<string>;
	onDidUninstallExtension: Event<string>;

J
Joao Moreno 已提交
91
	install(extension: IGalleryExtension): TPromise<void>;
J
Joao Moreno 已提交
92
	install(zipPath: string): TPromise<void>;
J
Joao Moreno 已提交
93 94
	uninstall(extension: ILocalExtension): TPromise<void>;
	getInstalled(includeDuplicateVersions?: boolean): TPromise<ILocalExtension[]>;
E
Erich Gamma 已提交
95
}
96

J
Joao Moreno 已提交
97
export const IExtensionTipsService = createDecorator<IExtensionTipsService>('extensionTipsService');
98 99

export interface IExtensionTipsService {
J
Johannes Rieken 已提交
100
	serviceId: ServiceIdentifier<IExtensionTipsService>;
J
Joao Moreno 已提交
101
	getRecommendations(): TPromise<ILocalExtension[]>;
102 103
}

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