@isopodlabs/vscode_utils 0.0.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/fs.d.ts ADDED
@@ -0,0 +1,119 @@
1
+ import * as vscode from 'vscode';
2
+ export type Filename = string | vscode.Uri;
3
+ export interface FileRange {
4
+ fromOffset: number;
5
+ toOffset: number;
6
+ }
7
+ export interface File {
8
+ dispose(): void;
9
+ read(pos: number, length: number): Promise<Uint8Array>;
10
+ write(pos: number, data: Uint8Array): Promise<number>;
11
+ }
12
+ export declare function isFile(obj: any): obj is File;
13
+ interface FileSystem extends vscode.FileSystemProvider {
14
+ openFile(uri: vscode.Uri): File | Promise<File>;
15
+ }
16
+ export declare abstract class BaseFileSystem implements FileSystem {
17
+ protected _onDidChangeFile: vscode.EventEmitter<vscode.FileChangeEvent[]>;
18
+ constructor(context: vscode.ExtensionContext, scheme: string);
19
+ get onDidChangeFile(): vscode.Event<vscode.FileChangeEvent[]>;
20
+ abstract openFile(uri: vscode.Uri): File | Promise<File>;
21
+ abstract readFile(uri: vscode.Uri): Uint8Array | Thenable<Uint8Array>;
22
+ watch(_uri: vscode.Uri, _options: {
23
+ readonly recursive: boolean;
24
+ readonly excludes: readonly string[];
25
+ }): vscode.Disposable;
26
+ stat(_uri: vscode.Uri): vscode.FileStat | Thenable<vscode.FileStat>;
27
+ readDirectory(_uri: vscode.Uri): [string, vscode.FileType][];
28
+ createDirectory(_uri: vscode.Uri): void;
29
+ writeFile(_uri: vscode.Uri, _content: Uint8Array, _options: {
30
+ readonly create: boolean;
31
+ readonly overwrite: boolean;
32
+ }): void;
33
+ delete(_uri: vscode.Uri, _options: {
34
+ readonly recursive: boolean;
35
+ }): void;
36
+ rename(_oldUri: vscode.Uri, _newUri: vscode.Uri, _options: {
37
+ readonly overwrite: boolean;
38
+ }): void;
39
+ }
40
+ export declare function withOffset(file: File, offset: FileRange): File;
41
+ export declare function withOffset(file: vscode.Uri, offset: FileRange): vscode.Uri;
42
+ export declare function openFile(uri: vscode.Uri): File | Promise<File>;
43
+ export declare class NormalFile implements File {
44
+ fd: number;
45
+ constructor(fd: number);
46
+ static open(uri: vscode.Uri): Promise<NormalFile>;
47
+ dispose(): void;
48
+ read(pos: number, length: number): Promise<Uint8Array<ArrayBufferLike>>;
49
+ write(pos: number, data: Uint8Array): Promise<number>;
50
+ }
51
+ export declare class ReadOnlyFilesystem extends BaseFileSystem {
52
+ static SCHEME: string;
53
+ constructor(context: vscode.ExtensionContext);
54
+ stat(uri: vscode.Uri): Promise<{
55
+ permissions: vscode.FilePermission;
56
+ type: vscode.FileType;
57
+ ctime: number;
58
+ mtime: number;
59
+ size: number;
60
+ }>;
61
+ openFile(uri: vscode.Uri): File | Promise<File>;
62
+ readFile(uri: vscode.Uri): Thenable<Uint8Array<ArrayBufferLike>>;
63
+ }
64
+ export declare class SubfileFileSystem extends BaseFileSystem {
65
+ static SCHEME: string;
66
+ static makeUri(uri: vscode.Uri, offset: FileRange): vscode.Uri;
67
+ static parseUri(uri: vscode.Uri): {
68
+ uri: vscode.Uri;
69
+ offset: {
70
+ fromOffset: number;
71
+ toOffset: number;
72
+ };
73
+ };
74
+ constructor(context: vscode.ExtensionContext);
75
+ stat(uri: vscode.Uri): Promise<{
76
+ size: number;
77
+ type: vscode.FileType;
78
+ ctime: number;
79
+ mtime: number;
80
+ permissions?: vscode.FilePermission;
81
+ }>;
82
+ readFile(uri: vscode.Uri): Promise<Uint8Array<ArrayBufferLike>>;
83
+ openFile(uri: vscode.Uri): Promise<File>;
84
+ }
85
+ export declare class Glob {
86
+ private readonly regexp;
87
+ constructor(pattern: string | string[]);
88
+ test(input: string): boolean;
89
+ }
90
+ export declare function toOSPath(input: string | undefined): string;
91
+ export type Entry = [string, vscode.FileType];
92
+ export declare function readDirectory(dir: Filename): Thenable<Entry[]>;
93
+ export declare function directories(entries: Entry[]): string[];
94
+ export declare function files(entries: Entry[], glob?: string | Glob): string[];
95
+ export declare function search(pattern: string, _exclude?: string | string[], want?: vscode.FileType): Promise<string[]>;
96
+ export declare function mapDirs<T>(root: string, glob: string | Glob, onFile: (filename: string) => T, combine: (...results: T[]) => T): Promise<T>;
97
+ export declare function stat_reject(value: Filename): Thenable<vscode.FileStat>;
98
+ export declare function exists(value: Filename): Thenable<boolean>;
99
+ export declare function getStat(value: Filename): Thenable<vscode.FileStat | undefined>;
100
+ export declare function isDirectory(value: Filename): Thenable<boolean>;
101
+ export declare function loadFile(file: Filename): Promise<Uint8Array | void>;
102
+ export declare function writeFile(file: Filename, bytes: Uint8Array): PromiseLike<boolean>;
103
+ export declare function deleteFile(file: Filename): PromiseLike<boolean>;
104
+ export declare function createDirectory(path: Filename): PromiseLike<boolean>;
105
+ export declare function createNewName(filepath: string): Promise<string>;
106
+ export declare function createNewName(filepath: vscode.Uri): Promise<vscode.Uri>;
107
+ export declare function copyFile(sourcepath: string, destpath: string): Promise<void>;
108
+ export declare function copyFileToDir(sourcepath: Filename, destdir: Filename): Promise<Filename>;
109
+ export declare function copyDirectory(sourcepath: Filename, targetpath: Filename): Promise<Filename[]>;
110
+ export declare const Change: {
111
+ readonly changed: 0;
112
+ readonly created: 1;
113
+ readonly deleted: 2;
114
+ readonly renamed: 3;
115
+ };
116
+ export declare function onChange(filename: Filename, func: (path: string, mode: number) => void): void;
117
+ export declare function arrayRemove<T>(array: T[], item: T): boolean;
118
+ export declare function removeOnChange(filename: Filename, func: (path: string) => void): void;
119
+ export {};