forked from esm-dev/modern-monaco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkspace.d.ts
More file actions
85 lines (74 loc) · 2.87 KB
/
workspace.d.ts
File metadata and controls
85 lines (74 loc) · 2.87 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
import type { editor } from "./monaco.d.ts";
import type { showInputBox, showQuickPick } from "./vscode.d.ts";
export interface WorkspaceInit {
/** name of the workspace. */
name?: string;
/** initial files in the workspace */
initialFiles?: Record<string, string | Uint8Array>;
/** file to open when the editor is loaded at first time */
entryFile?: string;
/** whether to use browser history for navigation. */
browserHistory?: boolean | { basePath: string };
/** custom filesystem implementation to override the default IndexedDB filesystem */
customFS?: FileSystem;
}
export class Workspace {
constructor(options?: WorkspaceInit);
readonly entryFile?: string;
readonly fs: FileSystem;
readonly history: WorkspaceHistory;
readonly viewState: WorkspaceViewState;
openTextDocument(uri: string | URL, content?: string): Promise<editor.ITextModel>;
showInputBox: typeof showInputBox;
showQuickPick: typeof showQuickPick;
}
export interface WorkspaceViewState {
get(uri: string | URL): Promise<editor.ICodeEditorViewState | undefined>;
save(uri: string | URL, viewState: editor.ICodeEditorViewState): Promise<void>;
}
export interface WorkspaceHistoryState {
readonly current: string;
}
export interface WorkspaceHistory {
readonly state: WorkspaceHistoryState;
back(): void;
forward(): void;
push(path: string): void;
replace(path: string): void;
onChange(callback: (state: WorkspaceHistoryState) => void): () => void;
}
/**
* The type of a file system entry.
* - `0`: unknown
* - `1`: file
* - `2`: directory
* - `64`: symlink
*/
export type FileSystemEntryType = 0 | 1 | 2 | 64;
export interface FileSystemWatchContext {
isModelContentChange?: boolean;
}
export interface FileSystemWatchHandle {
(kind: "create" | "modify" | "remove", filename: string, type?: number, context?: FileSystemWatchContext): void;
}
export interface FileStat {
readonly type: FileSystemEntryType;
readonly ctime: number;
readonly mtime: number;
readonly version: number;
readonly size: number;
}
export interface FileSystem {
copy(source: string, target: string, options?: { overwrite: boolean }): Promise<void>;
createDirectory(dir: string): Promise<void>;
delete(filename: string, options?: { recursive: boolean }): Promise<void>;
readDirectory(filename: string): Promise<[string, number][]>;
readFile(filename: string): Promise<Uint8Array>;
readTextFile(filename: string): Promise<string>;
rename(oldName: string, newName: string, options?: { overwrite: boolean }): Promise<void>;
stat(filename: string): Promise<FileStat>;
writeFile(filename: string, content: string | Uint8Array, context?: FileSystemWatchContext): Promise<void>;
watch(filename: string, options: { recursive: boolean }, handle: FileSystemWatchHandle): () => void;
watch(filename: string, handle: FileSystemWatchHandle): () => void;
}
export class NotFoundError extends Error {}