UNPKG

3.17 kBTypeScriptView Raw
1import { CancellationToken } from './cancellation';
2export declare const messageServicePath = "/services/messageService";
3export declare enum MessageType {
4 Error = 1,
5 Warning = 2,
6 Info = 3,
7 Log = 4,
8 Progress = 5
9}
10export interface Message {
11 /**
12 * Type of the message, i.e. error, warning, info, etc.
13 */
14 readonly type?: MessageType;
15 /**
16 * Message text.
17 */
18 readonly text: string;
19 /**
20 * Actions offered to the user in the context of the message.
21 */
22 readonly actions?: string[];
23 /**
24 * Additional options.
25 */
26 readonly options?: MessageOptions;
27 readonly source?: string;
28}
29export interface ProgressMessage extends Message {
30 readonly type?: MessageType.Progress;
31 readonly options?: ProgressMessageOptions;
32}
33export declare namespace ProgressMessage {
34 const Cancel = "Cancel";
35 function isCancelable(message: ProgressMessage): boolean;
36}
37export interface MessageOptions {
38 /**
39 * Timeout in milliseconds.
40 * `0` and negative values are treated as no timeout.
41 */
42 readonly timeout?: number;
43}
44export interface ProgressMessageOptions extends MessageOptions {
45 /**
46 * Default: `false`
47 */
48 readonly cancelable?: boolean;
49 /**
50 * Known values: `notification` | `window` | `scm`
51 */
52 readonly location?: string;
53}
54export interface Progress {
55 /**
56 * Unique progress id.
57 */
58 readonly id: string;
59 /**
60 * Update the current progress.
61 *
62 * @param update the data to update.
63 */
64 readonly report: (update: ProgressUpdate) => void;
65 /**
66 * Cancel or complete the current progress.
67 */
68 readonly cancel: () => void;
69 /**
70 * Result of the progress.
71 *
72 * @returns a promise which resolves to either 'Cancel', an alternative action or `undefined`.
73 */
74 readonly result: Promise<string | undefined>;
75}
76export interface ProgressUpdate {
77 /**
78 * Updated message for the progress.
79 */
80 readonly message?: string;
81 /**
82 * Updated ratio between steps done so far and total number of steps.
83 */
84 readonly work?: {
85 done: number;
86 total: number;
87 };
88}
89export declare class MessageClient {
90 /**
91 * Show a message of the given type and possible actions to the user.
92 * Resolve to a chosen action.
93 * Never reject.
94 *
95 * To be implemented by an extension, e.g. by the messages extension.
96 */
97 showMessage(message: Message): Promise<string | undefined>;
98 /**
99 * Show a progress message with possible actions to user.
100 *
101 * To be implemented by an extension, e.g. by the messages extension.
102 */
103 showProgress(progressId: string, message: ProgressMessage, cancellationToken: CancellationToken): Promise<string | undefined>;
104 /**
105 * Update a previously created progress message.
106 *
107 * To be implemented by an extension, e.g. by the messages extension.
108 */
109 reportProgress(progressId: string, update: ProgressUpdate, message: ProgressMessage, cancellationToken: CancellationToken): Promise<void>;
110}
111//# sourceMappingURL=message-service-protocol.d.ts.map
\No newline at end of file