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