vscode-fs 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vscode.d.mts CHANGED
@@ -1,5 +1,405 @@
1
- import { r as FileSystem } from "./types-DIuEgbpF.mjs";
1
+ import { URI } from "vscode-uri";
2
2
 
3
+ //#region src/types.d.ts
4
+ /**
5
+ * Enumeration of file types. The types `File` and `Directory` can also be
6
+ * a symbolic links, in that case use `FileType.File | FileType.SymbolicLink` and
7
+ * `FileType.Directory | FileType.SymbolicLink`.
8
+ */
9
+ declare enum FileType {
10
+ /**
11
+ * The file type is unknown.
12
+ */
13
+ Unknown = 0,
14
+ /**
15
+ * A regular file.
16
+ */
17
+ File = 1,
18
+ /**
19
+ * A directory.
20
+ */
21
+ Directory = 2,
22
+ /**
23
+ * A symbolic link to a file.
24
+ */
25
+ SymbolicLink = 64
26
+ }
27
+ /**
28
+ * The file system interface exposes the editor's built-in and contributed
29
+ * {@link FileSystemProvider file system providers}. It allows extensions to work
30
+ * with files from the local disk as well as files from remote places, like the
31
+ * remote extension host or ftp-servers.
32
+ */
33
+ interface FileSystem {
34
+ /**
35
+ * Retrieve metadata about a file.
36
+ *
37
+ * @param uri The uri of the file to retrieve metadata about.
38
+ * @returns The file metadata about the file.
39
+ */
40
+ stat(uri: URI): Promise<FileStat>;
41
+ /**
42
+ * Retrieve all entries of a {@link FileType.Directory directory}.
43
+ *
44
+ * @param uri The uri of the folder.
45
+ * @returns An array of name/type-tuples or a thenable that resolves to such.
46
+ */
47
+ readDirectory(uri: URI): Promise<[string, FileType][]>;
48
+ /**
49
+ * Create a new directory (Note, that new files are created via `write`-calls).
50
+ *
51
+ * Note* that missing directories are created automatically, e.g this call has
52
+ * `mkdirp` semantics.
53
+ *
54
+ * @param uri The uri of the new folder.
55
+ */
56
+ createDirectory(uri: URI): Promise<void>;
57
+ /**
58
+ * Read the entire contents of a file.
59
+ *
60
+ * @param uri The uri of the file.
61
+ * @returns An array of bytes or a thenable that resolves to such.
62
+ */
63
+ readFile(uri: URI): Promise<Uint8Array>;
64
+ /**
65
+ * Write data to a file, replacing its entire contents.
66
+ *
67
+ * @param uri The uri of the file.
68
+ * @param content The new content of the file.
69
+ */
70
+ writeFile(uri: URI, content: Uint8Array): Promise<void>;
71
+ /**
72
+ * Delete a file.
73
+ *
74
+ * @param uri The resource that is to be deleted.
75
+ * @param options Defines if trash can should be used and if deletion of folders is recursive
76
+ * @param options.recursive Delete the content recursively if a folder is denoted.
77
+ * @param options.useTrash Use the os's trashcan instead of permanently deleting files whenever possible.
78
+ */
79
+ delete(uri: URI, options?: {
80
+ /**
81
+ * Delete the content recursively if a folder is denoted.
82
+ */
83
+ recursive?: boolean;
84
+ /**
85
+ * Use the os's trashcan instead of permanently deleting files whenever possible.
86
+ */
87
+ useTrash?: boolean;
88
+ }): Promise<void>;
89
+ /**
90
+ * Rename a file or folder.
91
+ *
92
+ * @param source The existing file.
93
+ * @param target The new location.
94
+ * @param options Defines if existing files should be overwritten.
95
+ * @param options.overwrite Overwrite the file if it does exist.
96
+ */
97
+ rename(source: URI, target: URI, options?: {
98
+ /**
99
+ * Overwrite the file if it does exist.
100
+ */
101
+ overwrite?: boolean;
102
+ }): Promise<void>;
103
+ /**
104
+ * Copy files or folders.
105
+ *
106
+ * @param source The existing file.
107
+ * @param target The destination location.
108
+ * @param options Defines if existing files should be overwritten.
109
+ * @param options.overwrite Overwrite the file if it does exist.
110
+ */
111
+ copy(source: URI, target: URI, options?: {
112
+ /**
113
+ * Overwrite the file if it does exist.
114
+ */
115
+ overwrite?: boolean;
116
+ }): Promise<void>;
117
+ /**
118
+ * Check if a file exists.
119
+ *
120
+ * @param uri The uri of the file.
121
+ * @returns True if the file exists, false otherwise.
122
+ * @throws It will not throw any errors if the file does not exist.
123
+ */
124
+ isFile(uri: URI): Promise<IsFile | false>;
125
+ /**
126
+ * Check if a directory exists.
127
+ *
128
+ * @param uri The uri of the directory.
129
+ * @returns True if the directory exists, false otherwise.
130
+ * @throws It will not throw any errors if the directory does not exist.
131
+ */
132
+ isDirectory(uri: URI): Promise<IsDirectory | false>;
133
+ /**
134
+ * Check if a symbolic link exists.
135
+ *
136
+ * @param uri The uri of the symbolic link.
137
+ * @returns True if the symbolic link exists, false otherwise.
138
+ * @throws It will not throw any errors if the symbolic link does not exist.
139
+ */
140
+ isSymbolicLink(uri: URI): Promise<IsSymbolicLink | false>;
141
+ /**
142
+ * Check if the path is exists.
143
+ *
144
+ * @param uri The uri of the file, directory, or symbolic link.
145
+ * @returns True if the file, directory, or symbolic link exists, false otherwise.
146
+ * @throws It will not throw any errors if the file, directory, or symbolic link does not exist.
147
+ */
148
+ exists(uri: URI): Promise<FileStat | false>;
149
+ /**
150
+ * Glob files by pattern.
151
+ *
152
+ * @param globPattern The glob pattern.
153
+ * @param options The options for the glob.
154
+ * @param options.onlyFiles Only include files in the results. Default is `true`.
155
+ * @param options.onlyDirectories Only include directories in the results. Default is `false`.
156
+ * @param options.followSymbolicLinks Follow symbolic links in the results. Default is `true`.
157
+ * @param options.ignore Ignore files in the results. Default is `[]`.
158
+ * @param options.dot Include files and directories that start with a dot like `.gitignore`. Default is `true`.
159
+ * @param options.expandDirectories Whether to automatically expand directory patterns. Default is `true`. Important to disable if migrating from [`fast-glob`](https://github.com/mrmlnc/fast-glob).
160
+ * @param options.extglob Enables support for extglobs, like `+(pattern)`. Default is `true`.
161
+ * @param options.deep Maximum directory depth to crawl. Default is `Infinity`.
162
+ * @returns An array of file uris.
163
+ */
164
+ glob(globPattern: RelativePattern, options?: {
165
+ /**
166
+ * Only include files in the results.
167
+ *
168
+ * @default true
169
+ */
170
+ onlyFiles?: boolean;
171
+ /**
172
+ * Only include directories in the results.
173
+ *
174
+ * @default false
175
+ */
176
+ onlyDirectories?: boolean;
177
+ /**
178
+ * Follow symbolic links in the results.
179
+ *
180
+ * @default true
181
+ */
182
+ followSymbolicLinks?: boolean;
183
+ /**
184
+ * Ignore files in the results.
185
+ *
186
+ * @default []
187
+ */
188
+ ignore?: string[] | RelativePattern;
189
+ /**
190
+ * Include files and directories that start with a dot like `.gitignore`.
191
+ *
192
+ * @default true
193
+ */
194
+ dot?: boolean;
195
+ /**
196
+ * Whether to automatically expand directory patterns.
197
+ *
198
+ * Important to disable if migrating from [`fast-glob`](https://github.com/mrmlnc/fast-glob).
199
+ *
200
+ * @default true
201
+ */
202
+ expandDirectories?: boolean;
203
+ /**
204
+ * Enables support for extglobs, like `+(pattern)`.
205
+ *
206
+ * @default true
207
+ */
208
+ extglob?: boolean;
209
+ /**
210
+ * Maximum directory depth to crawl.
211
+ * @default Infinity
212
+ */
213
+ deep?: number;
214
+ }): Promise<URI[]>;
215
+ createWatcher(pattern: RelativePattern, options?: {
216
+ /**
217
+ * Ignore create events.
218
+ *
219
+ * @default false
220
+ */
221
+ ignoreCreateEvents?: boolean;
222
+ /**
223
+ * Ignore change events.
224
+ *
225
+ * @default false
226
+ */
227
+ ignoreChangeEvents?: boolean;
228
+ /**
229
+ * Ignore delete events.
230
+ *
231
+ * @default false
232
+ */
233
+ ignoreDeleteEvents?: boolean;
234
+ }): Promise<FileSystemWatcher>;
235
+ /**
236
+ * Create a writer for a file.
237
+ *
238
+ * @param uri The uri of the file to write to.
239
+ * @returns A writer for the file.
240
+ */
241
+ createWritableStream(uri: URI, options?: {
242
+ /**
243
+ * The encoding to use for the file.
244
+ */
245
+ readonly encoding?: NodeJS.BufferEncoding | (string & {});
246
+ /**
247
+ * The flag to use for the file.
248
+ */
249
+ readonly flags?: WriteableFlags | (string & {});
250
+ /**
251
+ * Additional options.
252
+ */
253
+ readonly [key: string]: unknown;
254
+ }): Promise<WritableStream<Uint8Array>>;
255
+ /**
256
+ * Create a readable stream for a file.
257
+ *
258
+ * @param uri The uri of the file to read from.
259
+ * @returns A readable stream for the file.
260
+ */
261
+ createReadableStream(uri: URI): Promise<ReadableStream<Uint8Array>>;
262
+ }
263
+ /**
264
+ * The flags to use for the file.
265
+ */
266
+ declare enum WriteableFlags {
267
+ /**
268
+ * Append to the file.
269
+ */
270
+ Append = "a"
271
+ }
272
+ interface Disposable {
273
+ /** Dispose resources. */
274
+ dispose(): unknown;
275
+ }
276
+ /**
277
+ * A file system watcher notifies about changes to files and folders
278
+ * on disk or from other {@link FileSystemProvider FileSystemProviders}.
279
+ *
280
+ * To get an instance of a `FileSystemWatcher` use
281
+ * {@link workspace.createFileSystemWatcher createFileSystemWatcher}.
282
+ */
283
+ interface FileSystemWatcher extends Disposable {
284
+ /**
285
+ * true if this file system watcher has been created such that
286
+ * it ignores creation file system events.
287
+ */
288
+ readonly ignoreCreateEvents: boolean;
289
+ /**
290
+ * true if this file system watcher has been created such that
291
+ * it ignores change file system events.
292
+ */
293
+ readonly ignoreChangeEvents: boolean;
294
+ /**
295
+ * true if this file system watcher has been created such that
296
+ * it ignores delete file system events.
297
+ */
298
+ readonly ignoreDeleteEvents: boolean;
299
+ /**
300
+ * true if this file system watcher has been disposed.
301
+ */
302
+ readonly isDisposed: boolean;
303
+ /**
304
+ * An event which fires on file/folder creation.
305
+ */
306
+ onDidCreate(listener: (e: URI) => unknown): Disposable;
307
+ /**
308
+ * An event which fires on file/folder change.
309
+ */
310
+ onDidChange(listener: (e: URI) => unknown): Disposable;
311
+ /**
312
+ * An event which fires on file/folder deletion.
313
+ */
314
+ onDidDelete(listener: (e: URI) => unknown): Disposable;
315
+ }
316
+ /**
317
+ * The `FileStat`-type represents metadata about a file
318
+ */
319
+ interface FileStat {
320
+ /**
321
+ * The type of the file, e.g. is a regular file, a directory, or symbolic link
322
+ * to a file.
323
+ *
324
+ * Note:* This value might be a bitmask, e.g. `FileType.File | FileType.SymbolicLink`.
325
+ */
326
+ type: FileType;
327
+ /**
328
+ * The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
329
+ */
330
+ ctime: number;
331
+ /**
332
+ * The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
333
+ *
334
+ * Note:* If the file changed, it is important to provide an updated `mtime` that advanced
335
+ * from the previous value. Otherwise there may be optimizations in place that will not show
336
+ * the updated file contents in an editor for example.
337
+ */
338
+ mtime: number;
339
+ /**
340
+ * The size in bytes.
341
+ *
342
+ * Note:* If the file changed, it is important to provide an updated `size`. Otherwise there
343
+ * may be optimizations in place that will not show the updated file contents in an editor for
344
+ * example.
345
+ */
346
+ size: number;
347
+ }
348
+ type IsFile = Omit<FileStat, 'type'> & {
349
+ type: FileType.File;
350
+ };
351
+ type IsDirectory = Omit<FileStat, 'type'> & {
352
+ type: FileType.Directory;
353
+ };
354
+ type IsSymbolicLink = Omit<FileStat, 'type'> & {
355
+ type: FileType.SymbolicLink;
356
+ };
357
+ /**
358
+ * A relative pattern is a helper to construct glob patterns that are matched
359
+ * relatively to a base file path. The base path can either be an absolute file
360
+ * path as string or uri or a {@link WorkspaceFolder workspace folder}, which is the
361
+ * preferred way of creating the relative pattern.
362
+ */
363
+ declare class RelativePattern {
364
+ /**
365
+ * A base file path to which this pattern will be matched against relatively. The
366
+ * file path must be absolute, should not have any trailing path separators and
367
+ * not include any relative segments (`.` or `..`).
368
+ */
369
+ baseUri: URI;
370
+ /**
371
+ * A file glob pattern like `*.{ts,js}` that will be matched on file paths
372
+ * relative to the base path.
373
+ *
374
+ * Example: Given a base of `/home/work/folder` and a file path of `/home/work/folder/index.js`,
375
+ * the file glob pattern will match on `index.js`.
376
+ */
377
+ pattern: string;
378
+ /**
379
+ * Creates a new relative pattern object with a base file path and pattern to match. This pattern
380
+ * will be matched on file paths relative to the base.
381
+ *
382
+ * Example:
383
+ * ```ts
384
+ * const folder = vscode.workspace.workspaceFolders?.[0];
385
+ * if (folder) {
386
+ *
387
+ * // Match any TypeScript file in the root of this workspace folder
388
+ * const pattern1 = new vscode.RelativePattern(folder, '*.ts');
389
+ *
390
+ * // Match any TypeScript file in `someFolder` inside this workspace folder
391
+ * const pattern2 = new vscode.RelativePattern(folder, 'someFolder/*.ts');
392
+ * }
393
+ * ```
394
+ *
395
+ * @param base A base to which this pattern will be matched against relatively. It is recommended
396
+ * to pass in a {@link WorkspaceFolder workspace folder} if the pattern should match inside the workspace.
397
+ * Otherwise, a uri or string should only be used if the pattern is for a file path outside the workspace.
398
+ * @param pattern A file glob pattern like `*.{ts,js}` that will be matched on paths relative to the base.
399
+ */
400
+ constructor(base: URI, pattern: string);
401
+ }
402
+ //#endregion
3
403
  //#region src/vscode.d.ts
4
404
  declare function createVSCodeFileSystem(): Promise<FileSystem>;
5
405
  //#endregion