cspell-io 9.0.2 → 9.1.0
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/index.d.ts +440 -408
- package/dist/index.js +1316 -1290
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,490 +1,522 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { isFileURL, isUrlLike, toFileURL, toURL, urlBasename, urlParent as urlDirname } from "@cspell/url";
|
|
2
|
+
import { ServiceBus } from "@cspell/cspell-service-bus";
|
|
3
3
|
|
|
4
|
+
//#region src/async/asyncIterable.d.ts
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* Reads an entire iterable and converts it into a promise.
|
|
7
|
+
* @param asyncIterable the async iterable to wait for.
|
|
8
|
+
*/
|
|
8
9
|
declare function toArray<T>(asyncIterable: AsyncIterable<T> | Iterable<T> | Iterable<Promise<T>>): Promise<T[]>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/models/BufferEncoding.d.ts
|
|
12
|
+
// eslint-disable-next-line unicorn/text-encoding-identifier-case
|
|
13
|
+
type TextEncoding = "utf-8" | "utf8" | "utf16le" | "utf16be" | "utf-16le" | "utf-16be";
|
|
14
|
+
type BufferEncoding = "base64" | "base64url" | "hex" | TextEncoding;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/models/FileResource.d.ts
|
|
13
17
|
interface FileReference {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The URL of the File
|
|
20
|
+
*/
|
|
21
|
+
readonly url: URL;
|
|
22
|
+
/**
|
|
23
|
+
* The filename of the file if known.
|
|
24
|
+
* Useful for `data:` urls.
|
|
25
|
+
*/
|
|
26
|
+
readonly baseFilename?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The encoding to use when reading the file.
|
|
29
|
+
*/
|
|
30
|
+
readonly encoding?: BufferEncoding | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* - `true` if the content had been gzip compressed.
|
|
33
|
+
* - `false` if the content was NOT gzip compressed.
|
|
34
|
+
* - `undefined` if it is unknown
|
|
35
|
+
*/
|
|
36
|
+
readonly gz?: boolean | undefined;
|
|
33
37
|
}
|
|
34
38
|
interface FileResource extends FileReference {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The contents of the file
|
|
41
|
+
*/
|
|
42
|
+
readonly content: string | ArrayBufferView;
|
|
39
43
|
}
|
|
40
44
|
interface TextFileResource extends FileResource {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Extract the text of the file.
|
|
47
|
+
* @param encoding - optional encoding to use when decoding the content.
|
|
48
|
+
* by default it uses the encoding of the file if one was specified, otherwise it uses `utf8`.
|
|
49
|
+
* If the content is a string, then the encoding is ignored.
|
|
50
|
+
*/
|
|
51
|
+
getText(encoding?: BufferEncoding): string;
|
|
52
|
+
/**
|
|
53
|
+
* Get the bytes of the file.
|
|
54
|
+
*/
|
|
55
|
+
getBytes(): Uint8Array;
|
|
52
56
|
}
|
|
53
57
|
type UrlOrFilename = string | URL;
|
|
54
|
-
type UrlOrReference$
|
|
55
|
-
|
|
58
|
+
type UrlOrReference$1 = UrlOrFilename | FileReference;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/common/CFileReference.d.ts
|
|
61
|
+
interface CFileReferenceJson {
|
|
62
|
+
url: string;
|
|
63
|
+
encoding?: string | undefined;
|
|
64
|
+
baseFilename?: string | undefined;
|
|
65
|
+
gz?: boolean | undefined;
|
|
66
|
+
}
|
|
56
67
|
declare class CFileReference implements FileReference {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
url: string;
|
|
72
|
-
encoding: BufferEncoding | undefined;
|
|
73
|
-
baseFilename: string | undefined;
|
|
74
|
-
gz: boolean | undefined;
|
|
75
|
-
};
|
|
68
|
+
readonly url: URL;
|
|
69
|
+
readonly encoding: BufferEncoding | undefined;
|
|
70
|
+
readonly baseFilename: string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Use to ensure the nominal type separation between CFileReference and FileReference
|
|
73
|
+
* See: https://github.com/microsoft/TypeScript/wiki/FAQ#when-and-why-are-classes-nominal
|
|
74
|
+
*/
|
|
75
|
+
private _?;
|
|
76
|
+
readonly gz: boolean | undefined;
|
|
77
|
+
constructor(url: URL, encoding: BufferEncoding | undefined, baseFilename: string | undefined, gz: boolean | undefined);
|
|
78
|
+
static isCFileReference(obj: unknown): obj is CFileReference;
|
|
79
|
+
static from(fileReference: FileReference): CFileReference;
|
|
80
|
+
static from(url: URL, encoding?: BufferEncoding, baseFilename?: string | undefined, gz?: boolean | undefined): CFileReference;
|
|
81
|
+
toJson(): CFileReferenceJson;
|
|
76
82
|
}
|
|
77
|
-
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @param file - a URL, file path, or FileReference
|
|
86
|
+
* @param encoding - optional encoding used to decode the file.
|
|
87
|
+
* @param baseFilename - optional base filename used with data URLs.
|
|
88
|
+
* @param gz - optional flag to indicate if the file is gzipped.
|
|
89
|
+
* @returns a FileReference
|
|
90
|
+
*/
|
|
78
91
|
|
|
92
|
+
declare function renameFileReference(ref: FileReference, newUrl: URL): FileReference;
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/common/CFileResource.d.ts
|
|
95
|
+
interface CFileResourceJson {
|
|
96
|
+
url: string;
|
|
97
|
+
content: string;
|
|
98
|
+
encoding?: string | undefined;
|
|
99
|
+
baseFilename?: string | undefined;
|
|
100
|
+
gz: boolean;
|
|
101
|
+
}
|
|
79
102
|
declare class CFileResource implements TextFileResource {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
static isCFileResource(obj: unknown): obj is CFileResource;
|
|
98
|
-
static from(fileResource: FileResource): CFileResource;
|
|
99
|
-
static from(fileReference: FileReference, content: string | ArrayBufferView): CFileResource;
|
|
100
|
-
static from(fileReference: FileReference | URL, content: string | ArrayBufferView): CFileResource;
|
|
101
|
-
static from(url: URL, content: string | ArrayBufferView, encoding?: BufferEncoding | undefined, baseFilename?: string | undefined, gz?: boolean): CFileResource;
|
|
103
|
+
readonly url: URL;
|
|
104
|
+
readonly content: string | ArrayBufferView;
|
|
105
|
+
readonly encoding: BufferEncoding | undefined;
|
|
106
|
+
private _text?;
|
|
107
|
+
readonly baseFilename?: string | undefined;
|
|
108
|
+
private _gz?;
|
|
109
|
+
constructor(url: URL, content: string | ArrayBufferView, encoding: BufferEncoding | undefined, baseFilename: string | undefined, gz: boolean | undefined);
|
|
110
|
+
get gz(): boolean;
|
|
111
|
+
getText(encoding?: BufferEncoding): string;
|
|
112
|
+
getBytes(): Uint8Array;
|
|
113
|
+
toJson(): CFileResourceJson;
|
|
114
|
+
static isCFileResource(obj: unknown): obj is CFileResource;
|
|
115
|
+
static from(fileResource: FileResource): CFileResource;
|
|
116
|
+
static from(fileReference: FileReference, content: string | ArrayBufferView): CFileResource;
|
|
117
|
+
static from(fileReference: FileReference | URL, content: string | ArrayBufferView): CFileResource;
|
|
118
|
+
static from(url: URL, content: string | ArrayBufferView, encoding?: BufferEncoding | undefined, baseFilename?: string | undefined, gz?: boolean): CFileResource;
|
|
102
119
|
}
|
|
103
120
|
declare function fromFileResource(fileResource: FileResource, encoding?: BufferEncoding): TextFileResource;
|
|
104
121
|
declare function renameFileResource(fileResource: FileResource, url: URL): FileResource;
|
|
105
|
-
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/models/Stats.d.ts
|
|
106
124
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
125
|
+
* Subset of definition from the Node definition to avoid a dependency upon a specific version of Node
|
|
126
|
+
*/
|
|
109
127
|
interface Stats {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Size of file in byes, -1 if unknown.
|
|
130
|
+
*/
|
|
131
|
+
size: number;
|
|
132
|
+
/**
|
|
133
|
+
* Modification time, 0 if unknown.
|
|
134
|
+
*/
|
|
135
|
+
mtimeMs: number;
|
|
136
|
+
/**
|
|
137
|
+
* Used by web requests to see if a resource has changed.
|
|
138
|
+
*/
|
|
139
|
+
eTag?: string | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* The file type.
|
|
142
|
+
*/
|
|
143
|
+
fileType?: FileType | undefined;
|
|
126
144
|
}
|
|
127
145
|
declare enum FileType {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
/**
|
|
147
|
+
* The file type is unknown.
|
|
148
|
+
*/
|
|
149
|
+
Unknown = 0,
|
|
150
|
+
/**
|
|
151
|
+
* A regular file.
|
|
152
|
+
*/
|
|
153
|
+
File = 1,
|
|
154
|
+
/**
|
|
155
|
+
* A directory.
|
|
156
|
+
*/
|
|
157
|
+
Directory = 2,
|
|
158
|
+
/**
|
|
159
|
+
* A symbolic link.
|
|
160
|
+
*/
|
|
161
|
+
SymbolicLink = 64,
|
|
144
162
|
}
|
|
145
163
|
interface DirEntry {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
164
|
+
name: string;
|
|
165
|
+
dir: URL;
|
|
166
|
+
fileType: FileType;
|
|
149
167
|
}
|
|
150
|
-
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/common/stat.d.ts
|
|
151
170
|
/**
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
171
|
+
* Compare two Stats to see if they have the same value.
|
|
172
|
+
* @param left - Stats
|
|
173
|
+
* @param right - Stats
|
|
174
|
+
* @returns 0 - equal; 1 - left > right; -1 left < right
|
|
175
|
+
*/
|
|
157
176
|
declare function compareStats(left: Stats, right: Stats): number;
|
|
158
|
-
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/models/disposable.d.ts
|
|
159
179
|
interface Disposable {
|
|
160
|
-
|
|
180
|
+
dispose(): void;
|
|
161
181
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/common/urlOrReferenceToUrl.d.ts
|
|
184
|
+
type UrlOrReference$2 = URL | FileReference;
|
|
185
|
+
declare function urlOrReferenceToUrl(urlOrReference: UrlOrReference$2): URL;
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/CSpellIO.d.ts
|
|
166
188
|
interface ReadFileOptions$1 {
|
|
167
|
-
|
|
168
|
-
|
|
189
|
+
signal?: AbortSignal;
|
|
190
|
+
encoding?: BufferEncoding;
|
|
169
191
|
}
|
|
170
192
|
type ReadFileOptionsOrEncoding = ReadFileOptions$1 | BufferEncoding;
|
|
171
193
|
interface CSpellIO {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Read a file
|
|
196
|
+
* @param urlOrFilename - uri of the file to read
|
|
197
|
+
* @param options - optional options for reading the file.
|
|
198
|
+
* @returns A TextFileResource.
|
|
199
|
+
*/
|
|
200
|
+
readFile(urlOrFilename: UrlOrReference$1, options?: ReadFileOptionsOrEncoding): Promise<TextFileResource>;
|
|
201
|
+
/**
|
|
202
|
+
* Read a file in Sync mode.
|
|
203
|
+
* Note: `http` requests will fail.
|
|
204
|
+
* @param urlOrFilename - uri of the file to read
|
|
205
|
+
* @param encoding - optional encoding.
|
|
206
|
+
* @returns A TextFileResource.
|
|
207
|
+
* @deprecated Use `readFile` instead.
|
|
208
|
+
*/
|
|
209
|
+
readFileSync(urlOrFilename: UrlOrReference$1, encoding?: BufferEncoding): TextFileResource;
|
|
210
|
+
/**
|
|
211
|
+
* Write content to a file using utf-8 encoding.
|
|
212
|
+
* It will fail to write to non-file uris.
|
|
213
|
+
* @param urlOrFilename - uri
|
|
214
|
+
* @param content - string to write.
|
|
215
|
+
*/
|
|
216
|
+
writeFile(urlOrFilename: UrlOrReference$1, content: string | ArrayBufferView): Promise<FileReference>;
|
|
217
|
+
/**
|
|
218
|
+
* Read a directory.
|
|
219
|
+
* @param urlOrFilename - uri
|
|
220
|
+
*/
|
|
221
|
+
readDirectory(urlOrFilename: string | URL): Promise<DirEntry[]>;
|
|
222
|
+
/**
|
|
223
|
+
* Get Stats on a uri.
|
|
224
|
+
* @param urlOrFilename - uri to fetch stats on
|
|
225
|
+
* @returns Stats if successful.
|
|
226
|
+
*/
|
|
227
|
+
getStat(urlOrFilename: UrlOrReference$1): Promise<Stats>;
|
|
228
|
+
/**
|
|
229
|
+
* Get Stats on a uri.
|
|
230
|
+
* @param urlOrFilename - uri to fetch stats on
|
|
231
|
+
* @returns Stats if successful, otherwise it throws an error.
|
|
232
|
+
* @deprecated Use `getStat` instead.
|
|
233
|
+
*/
|
|
234
|
+
getStatSync(urlOrFilename: UrlOrReference$1): Stats;
|
|
235
|
+
/**
|
|
236
|
+
* Compare two Stats.
|
|
237
|
+
* @param left - left stat
|
|
238
|
+
* @param right - right stat
|
|
239
|
+
* @returns 0 if they are equal and non-zero if they are not.
|
|
240
|
+
*/
|
|
241
|
+
compareStats(left: Stats, right: Stats): number;
|
|
242
|
+
/**
|
|
243
|
+
* Convert a string to a URL
|
|
244
|
+
* @param urlOrFilename - string or URL to convert.
|
|
245
|
+
* If it is a URL, then it is just returned as is.
|
|
246
|
+
* If is is a string and fully formed URL, then it is parsed.
|
|
247
|
+
* If it is a string without a protocol/scheme it is assumed to be relative to `relativeTo`.
|
|
248
|
+
* @param relativeTo - optional
|
|
249
|
+
*/
|
|
250
|
+
toURL(urlOrFilename: UrlOrReference$1, relativeTo?: string | URL): URL;
|
|
251
|
+
/**
|
|
252
|
+
* Convert a string to a File URL
|
|
253
|
+
* @param urlOrFilename - string or URL to convert.
|
|
254
|
+
* @param relativeTo - optional
|
|
255
|
+
*/
|
|
256
|
+
toFileURL(urlOrFilename: UrlOrFilename, relativeTo?: string | URL): URL;
|
|
257
|
+
/**
|
|
258
|
+
* Try to determine the base name of a URL.
|
|
259
|
+
*
|
|
260
|
+
* Note: this handles `data:` URLs with `filename` attribute:
|
|
261
|
+
*
|
|
262
|
+
* Example:
|
|
263
|
+
* - `data:text/plain;charset=utf8;filename=hello.txt,Hello` would have a filename of `hello.txt`
|
|
264
|
+
* - `file:///user/project/cspell.config.yaml` would have a filename of `cspell.config.yaml`
|
|
265
|
+
* - `https://raw.guc.com/sss/cspell/main/cspell.schema.json` would have a filename of `cspell.schema.json`
|
|
266
|
+
* @param urlOrFilename - string or URL to extract the basename from.
|
|
267
|
+
*/
|
|
268
|
+
urlBasename(urlOrFilename: UrlOrReference$1): string;
|
|
269
|
+
/**
|
|
270
|
+
* Try to determine the directory URL of the uri.
|
|
271
|
+
*
|
|
272
|
+
* Example:
|
|
273
|
+
* - `file:///user/local/file.txt` becomes `file:///user/local/`
|
|
274
|
+
* - `file:///user/local/` becomes `file:///user/`
|
|
275
|
+
*
|
|
276
|
+
* @param urlOrFilename - string or URL
|
|
277
|
+
*/
|
|
278
|
+
urlDirname(urlOrFilename: UrlOrReference$1): URL;
|
|
257
279
|
}
|
|
258
|
-
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/CSpellIONode.d.ts
|
|
259
282
|
declare class CSpellIONode implements CSpellIO {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
283
|
+
readonly serviceBus: ServiceBus;
|
|
284
|
+
constructor(serviceBus?: ServiceBus);
|
|
285
|
+
readFile(urlOrFilename: UrlOrReference$1, options?: ReadFileOptionsOrEncoding): Promise<TextFileResource>;
|
|
286
|
+
readDirectory(urlOrFilename: string | URL): Promise<DirEntry[]>;
|
|
287
|
+
readFileSync(urlOrFilename: UrlOrReference$1, encoding?: BufferEncoding): TextFileResource;
|
|
288
|
+
writeFile(urlOrFilename: UrlOrReference$1, content: string | ArrayBufferView): Promise<FileReference>;
|
|
289
|
+
getStat(urlOrFilename: UrlOrReference$1): Promise<Stats>;
|
|
290
|
+
getStatSync(urlOrFilename: UrlOrReference$1): Stats;
|
|
291
|
+
compareStats(left: Stats, right: Stats): number;
|
|
292
|
+
toURL(urlOrFilename: UrlOrReference$1, relativeTo?: string | URL): URL;
|
|
293
|
+
toFileURL(urlOrFilename: UrlOrReference$1, relativeTo?: string | URL): URL;
|
|
294
|
+
urlBasename(urlOrFilename: UrlOrReference$1): string;
|
|
295
|
+
urlDirname(urlOrFilename: UrlOrReference$1): URL;
|
|
273
296
|
}
|
|
274
297
|
declare function getDefaultCSpellIO(): CSpellIO;
|
|
275
|
-
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region src/VFileSystem.d.ts
|
|
276
300
|
type UrlOrReference = URL | FileReference;
|
|
277
301
|
declare enum FSCapabilityFlags {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
302
|
+
None = 0,
|
|
303
|
+
Stat = 1,
|
|
304
|
+
Read = 2,
|
|
305
|
+
Write = 4,
|
|
306
|
+
ReadWrite = 6,
|
|
307
|
+
ReadDir = 8,
|
|
308
|
+
WriteDir = 16,
|
|
309
|
+
ReadWriteDir = 24,
|
|
286
310
|
}
|
|
287
311
|
interface FileSystemProviderInfo {
|
|
288
|
-
|
|
312
|
+
name: string;
|
|
289
313
|
}
|
|
290
314
|
interface ReadFileOptions {
|
|
291
|
-
|
|
292
|
-
|
|
315
|
+
signal?: AbortSignal;
|
|
316
|
+
encoding?: BufferEncoding;
|
|
293
317
|
}
|
|
294
318
|
interface VFileSystemCore {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Read a file.
|
|
321
|
+
* @param url - URL to read
|
|
322
|
+
* @param encoding - optional encoding
|
|
323
|
+
* @returns A FileResource, the content will not be decoded. Use `.getText()` to get the decoded text.
|
|
324
|
+
*/
|
|
325
|
+
readFile(url: UrlOrReference, encoding: BufferEncoding): Promise<TextFileResource>;
|
|
326
|
+
/**
|
|
327
|
+
* Read a file.
|
|
328
|
+
* @param url - URL to read
|
|
329
|
+
* @param options - options for reading the file.
|
|
330
|
+
* @returns A FileResource, the content will not be decoded. Use `.getText()` to get the decoded text.
|
|
331
|
+
*/
|
|
332
|
+
readFile(url: UrlOrReference, options?: ReadFileOptions | BufferEncoding): Promise<TextFileResource>;
|
|
333
|
+
/**
|
|
334
|
+
* Write a file
|
|
335
|
+
* @param file - the file to write
|
|
336
|
+
*/
|
|
337
|
+
writeFile(file: FileResource): Promise<FileReference>;
|
|
338
|
+
/**
|
|
339
|
+
* Get the stats for a url.
|
|
340
|
+
* @param url - Url to fetch stats for.
|
|
341
|
+
*/
|
|
342
|
+
stat(url: UrlOrReference): Promise<VfsStat>;
|
|
343
|
+
/**
|
|
344
|
+
* Read the directory entries for a url.
|
|
345
|
+
* The url should end with `/` to indicate a directory.
|
|
346
|
+
* @param url - the url to read the directory entries for.
|
|
347
|
+
*/
|
|
348
|
+
readDirectory(url: URL): Promise<VfsDirEntry[]>;
|
|
349
|
+
/**
|
|
350
|
+
* Get the capabilities for a URL.
|
|
351
|
+
* The capabilities can be more restrictive than the general capabilities of the provider.
|
|
352
|
+
* @param url - the url to try
|
|
353
|
+
*/
|
|
354
|
+
getCapabilities(url: URL): FSCapabilities;
|
|
355
|
+
/**
|
|
356
|
+
* Information about the provider.
|
|
357
|
+
* It is up to the provider to define what information is available.
|
|
358
|
+
*/
|
|
359
|
+
providerInfo: FileSystemProviderInfo;
|
|
360
|
+
/**
|
|
361
|
+
* Indicates that a provider was found for the url.
|
|
362
|
+
*/
|
|
363
|
+
hasProvider: boolean;
|
|
340
364
|
}
|
|
341
365
|
interface VFileSystem extends VFileSystemCore {
|
|
342
|
-
|
|
366
|
+
findUp(name: string | string[] | VFindUpPredicate, from: URL, options?: VFindUpURLOptions): Promise<URL | undefined>;
|
|
343
367
|
}
|
|
344
368
|
interface FSCapabilities {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
369
|
+
readonly flags: FSCapabilityFlags;
|
|
370
|
+
readonly readFile: boolean;
|
|
371
|
+
readonly writeFile: boolean;
|
|
372
|
+
readonly readDirectory: boolean;
|
|
373
|
+
readonly writeDirectory: boolean;
|
|
374
|
+
readonly stat: boolean;
|
|
351
375
|
}
|
|
352
376
|
interface VfsStat extends Stats {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
377
|
+
isDirectory(): boolean;
|
|
378
|
+
isFile(): boolean;
|
|
379
|
+
isUnknown(): boolean;
|
|
380
|
+
isSymbolicLink(): boolean;
|
|
357
381
|
}
|
|
358
382
|
interface VfsDirEntry extends DirEntry {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
383
|
+
isDirectory(): boolean;
|
|
384
|
+
isFile(): boolean;
|
|
385
|
+
isUnknown(): boolean;
|
|
386
|
+
isSymbolicLink(): boolean;
|
|
363
387
|
}
|
|
364
|
-
type VFindEntryType =
|
|
388
|
+
type VFindEntryType = "file" | "directory" | "!file" | "!directory";
|
|
365
389
|
interface VFindUpURLOptions {
|
|
366
|
-
|
|
367
|
-
|
|
390
|
+
type?: VFindEntryType;
|
|
391
|
+
stopAt?: URL | URL[];
|
|
368
392
|
}
|
|
369
393
|
type VFindUpPredicate = (dir: URL) => URL | undefined | Promise<URL | undefined>;
|
|
370
|
-
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/VirtualFS.d.ts
|
|
371
396
|
type NextProvider = (url: URL) => VProviderFileSystem | undefined;
|
|
372
397
|
interface VirtualFS extends Disposable {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
398
|
+
registerFileSystemProvider(provider: VFileSystemProvider, ...providers: VFileSystemProvider[]): Disposable;
|
|
399
|
+
/**
|
|
400
|
+
* Get the fs for a given url.
|
|
401
|
+
*/
|
|
402
|
+
getFS(url: URL): VFileSystem;
|
|
403
|
+
/**
|
|
404
|
+
* The file system. All requests will first use getFileSystem to get the file system before making the request.
|
|
405
|
+
*/
|
|
406
|
+
readonly fs: Required<VFileSystem>;
|
|
407
|
+
/**
|
|
408
|
+
* The file system core. All requests will first use getFileSystem to get the file system before making the request.
|
|
409
|
+
*/
|
|
410
|
+
readonly fsc: Required<VFileSystemCore>;
|
|
411
|
+
/**
|
|
412
|
+
* Clear the cache of file systems.
|
|
413
|
+
*/
|
|
414
|
+
reset(): void;
|
|
415
|
+
/**
|
|
416
|
+
* Indicates that logging has been enabled.
|
|
417
|
+
*/
|
|
418
|
+
loggingEnabled: boolean;
|
|
419
|
+
enableLogging(value?: boolean): void;
|
|
395
420
|
}
|
|
396
421
|
interface OptionAbort {
|
|
397
|
-
|
|
422
|
+
signal?: AbortSignal;
|
|
398
423
|
}
|
|
399
424
|
type VProviderFileSystemReadFileOptions = OptionAbort;
|
|
400
425
|
interface VProviderFileSystem extends Disposable {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
426
|
+
readFile(url: UrlOrReference, options?: VProviderFileSystemReadFileOptions): Promise<FileResource>;
|
|
427
|
+
writeFile(file: FileResource): Promise<FileReference>;
|
|
428
|
+
/**
|
|
429
|
+
* Information about the provider.
|
|
430
|
+
* It is up to the provider to define what information is available.
|
|
431
|
+
*/
|
|
432
|
+
providerInfo: FileSystemProviderInfo;
|
|
433
|
+
stat(url: UrlOrReference): Stats | Promise<Stats>;
|
|
434
|
+
readDirectory(url: URL): Promise<DirEntry[]>;
|
|
435
|
+
/**
|
|
436
|
+
* These are the general capabilities for the provider's file system.
|
|
437
|
+
* It is possible for a provider to support more capabilities for a given url by providing a getCapabilities function.
|
|
438
|
+
*/
|
|
439
|
+
capabilities: FSCapabilityFlags;
|
|
440
|
+
/**
|
|
441
|
+
* Get the capabilities for a URL. Make it possible for a provider to support more capabilities for a given url.
|
|
442
|
+
* These capabilities should be more restrictive than the general capabilities.
|
|
443
|
+
* @param url - the url to try
|
|
444
|
+
* @returns the capabilities for the url.
|
|
445
|
+
*/
|
|
446
|
+
getCapabilities?: (url: URL) => FSCapabilities;
|
|
422
447
|
}
|
|
423
448
|
interface VFileSystemProvider extends Partial<Disposable> {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
449
|
+
/** Name of the Provider */
|
|
450
|
+
name: string;
|
|
451
|
+
/**
|
|
452
|
+
* Get the file system for a given url. The provider is cached based upon the protocol and hostname.
|
|
453
|
+
* @param url - the url to get the file system for.
|
|
454
|
+
* @param next - call this function to get the next provider to try. This is useful for chaining providers that operate on the same protocol.
|
|
455
|
+
*/
|
|
456
|
+
getFileSystem(url: URL, next: NextProvider): VProviderFileSystem | undefined;
|
|
432
457
|
}
|
|
433
|
-
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region src/CVirtualFS.d.ts
|
|
434
460
|
declare function createVirtualFS(cspellIO?: CSpellIO): VirtualFS;
|
|
435
461
|
declare function getDefaultVirtualFs(): VirtualFS;
|
|
436
|
-
|
|
437
|
-
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region src/common/BufferEncoding.d.ts
|
|
464
|
+
type TextEncodingExtra = "utf-16be" | "utf-16le" | "utf16be" | "utf16le";
|
|
438
465
|
type BufferEncodingExt = BufferEncoding | TextEncodingExtra;
|
|
439
|
-
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region src/node/file/fileWriter.d.ts
|
|
440
468
|
declare function writeToFile(filename: string, data: string | Iterable<string> | AsyncIterable<string>, encoding?: BufferEncoding): Promise<void>;
|
|
441
469
|
declare function writeToFileIterable(filename: string, data: Iterable<string> | AsyncIterable<string>, encoding?: BufferEncodingExt): Promise<void>;
|
|
442
|
-
|
|
470
|
+
//#endregion
|
|
471
|
+
//#region src/file/file.d.ts
|
|
443
472
|
declare function readFileText(filename: string | URL, encoding?: BufferEncoding): Promise<string>;
|
|
444
473
|
declare function readFileTextSync(filename: string | URL, encoding?: BufferEncoding): string;
|
|
445
474
|
declare function getStat(filenameOrUri: string): Promise<Stats | Error>;
|
|
446
475
|
declare function getStatSync(filenameOrUri: string): Stats | Error;
|
|
447
|
-
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/node/dataUrl.d.ts
|
|
448
478
|
/**
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
479
|
+
* Generates a string of the following format:
|
|
480
|
+
*
|
|
481
|
+
* `data:[mediaType][;charset=<encoding>[;base64],<data>`
|
|
482
|
+
*
|
|
483
|
+
* - `encoding` - defaults to `utf8` for text data
|
|
484
|
+
* @param data
|
|
485
|
+
* @param mediaType - The mediaType is a [MIME](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) type string
|
|
486
|
+
* @param attributes - Additional attributes
|
|
487
|
+
*/
|
|
458
488
|
declare function encodeDataUrl(data: string | Buffer | ArrayBufferView, mediaType: string, attributes?: Iterable<readonly [string, string]> | undefined): string;
|
|
459
489
|
declare function toDataUrl(data: string | Buffer | ArrayBufferView, mediaType: string, attributes?: Iterable<[string, string]> | undefined): URL;
|
|
460
|
-
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/VirtualFS/redirectProvider.d.ts
|
|
461
492
|
interface RedirectOptions {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
493
|
+
/**
|
|
494
|
+
* Option ts to mask the capabilities of the provider.
|
|
495
|
+
* @default: -1
|
|
496
|
+
*/
|
|
497
|
+
capabilitiesMask?: number;
|
|
498
|
+
capabilities?: FSCapabilityFlags;
|
|
468
499
|
}
|
|
469
500
|
/**
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
501
|
+
* Create a provider that will redirect requests from the publicRoot to the privateRoot.
|
|
502
|
+
* This is useful for creating a virtual file system that is a subset of another file system.
|
|
503
|
+
*
|
|
504
|
+
* Example:
|
|
505
|
+
* ```ts
|
|
506
|
+
* const vfs = createVirtualFS();
|
|
507
|
+
* const provider = createRedirectProvider('test', new URL('file:///public/'), new URL('file:///private/'))
|
|
508
|
+
* vfs.registerFileSystemProvider(provider);
|
|
509
|
+
* // Read the content of `file:///private/file.txt`
|
|
510
|
+
* const file = vfs.fs.readFile(new URL('file:///public/file.txt');
|
|
511
|
+
* ```
|
|
512
|
+
*
|
|
513
|
+
* @param name - name of the provider
|
|
514
|
+
* @param publicRoot - the root of the public file system.
|
|
515
|
+
* @param privateRoot - the root of the private file system.
|
|
516
|
+
* @param options - options for the provider.
|
|
517
|
+
* @returns FileSystemProvider
|
|
518
|
+
*/
|
|
488
519
|
declare function createRedirectProvider(name: string, publicRoot: URL, privateRoot: URL, options?: RedirectOptions): VFileSystemProvider;
|
|
489
|
-
|
|
490
|
-
export {
|
|
520
|
+
//#endregion
|
|
521
|
+
export { BufferEncoding, CFileReference, CFileResource, CSpellIO, CSpellIONode, FSCapabilityFlags, Stats, TextEncoding, VFileSystem, VFileSystemCore, VFileSystemProvider, FileType as VFileType, VFindEntryType, VFindUpPredicate, VFindUpURLOptions, VProviderFileSystem, VfsDirEntry, VfsStat, VirtualFS, toArray as asyncIterableToArray, compareStats, createRedirectProvider, fromFileResource as createTextFileResource, createVirtualFS, encodeDataUrl, getDefaultCSpellIO, getDefaultVirtualFs, getStat, getStatSync, isFileURL, isUrlLike, readFileText, readFileTextSync, renameFileReference, renameFileResource, toDataUrl, toFileURL, toURL, urlBasename, urlDirname, urlOrReferenceToUrl, writeToFile, writeToFileIterable, writeToFileIterable as writeToFileIterableP };
|
|
522
|
+
//# sourceMappingURL=index.d.ts.map
|