-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathhttpgdTypes.d.ts
More file actions
88 lines (66 loc) · 2.43 KB
/
httpgdTypes.d.ts
File metadata and controls
88 lines (66 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { Httpgd } from 'httpgd';
import { HttpgdPlotId } from 'httpgd/lib/types';
import * as vscode from 'vscode';
import { HttpgdManager } from '.';
import { PreviewPlotLayout } from './webviewMessages';
export type MaybePromise<T> = T | Promise<T>;
export interface HttpgdPlot<T> {
// unique ID for this plot (w.r.t. this connection/device)
id: HttpgdPlotId;
// data of the plot
data: T;
// Size
height: number;
width: number;
zoom: number;
}
// Example for possible viewer creation options:
export interface HttpgdViewerOptions {
parent: HttpgdManager;
token?: string;
preserveFocus?: boolean;
viewColumn?: vscode.ViewColumn;
htmlRoot: string;
stripStyles?: boolean;
fullWindow?: boolean;
previewPlotLayout?: PreviewPlotLayout,
resizeTimeoutLength?: number;
refreshTimeoutLength?: number;
}
// Roughly combines the functionality of HttpgdNavigator and HttpgdViewer
export class IHttpgdViewer {
// Actual webview where the plot viewer is shown
// Will have to be created anew, if the user closes it and the plot changes
webviewPanel?: vscode.WebviewPanel;
// Api that provides plot contents etc.
api: Httpgd;
// active plots
plots: HttpgdPlot<string>[];
// Id of the currently viewed plot
activePlot?: HttpgdPlotId;
// Size of the view area:
viewHeight: number;
viewWidth: number;
// constructor called by the session watcher if a corresponding function was called in R
// creates a new api instance itself
constructor(options: HttpgdViewerOptions);
// Methods to interact with the webview
// Can e.g. be called by vscode commands + menu items:
// Called to create a new webview if the user closed the old one:
show(preserveFocus?: boolean): void;
// focus a specific plot id
focusPlot(id: HttpgdPlotId): void;
// navigate through plots (supply `true` to go to end/beginning of list)
nextPlot(last?: boolean): void;
prevPlot(first?: boolean): void;
// restore closed plots, show most recent plot etc.?
resetPlots(): void;
// export plot
// if no format supplied, show a quickpick menu etc.
// if no filename supplied, show selector window
exportPlot(id: HttpgdPlotId, format?: string, outFile?: string): void;
// Dispose-function to clean up when vscode closes
// E.g. to close connections etc., notify R, ...
// Not sure if sensible here
dispose?(): void;
}