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.
Files changed (3) hide show
  1. package/dist/index.d.ts +440 -408
  2. package/dist/index.js +1316 -1290
  3. package/package.json +6 -6
package/dist/index.d.ts CHANGED
@@ -1,490 +1,522 @@
1
- import { ServiceBus } from '@cspell/cspell-service-bus';
2
- export { isFileURL, isUrlLike, toFileURL, toURL, urlBasename, urlParent as urlDirname } from '@cspell/url';
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
- * Reads an entire iterable and converts it into a promise.
6
- * @param asyncIterable the async iterable to wait for.
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
- type TextEncoding = 'utf-8' | 'utf8' | 'utf16le' | 'utf16be' | 'utf-16le' | 'utf-16be';
11
- type BufferEncoding = 'base64' | 'base64url' | 'hex' | TextEncoding;
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
- * 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;
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
- * The contents of the file
37
- */
38
- readonly content: string | ArrayBufferView;
39
+ /**
40
+ * The contents of the file
41
+ */
42
+ readonly content: string | ArrayBufferView;
39
43
  }
40
44
  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;
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$2 = UrlOrFilename | FileReference;
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
- 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
- };
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
- declare function renameFileReference(ref: FileReference, newUrl: URL): FileReference;
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
- 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;
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
- * Subset of definition from the Node definition to avoid a dependency upon a specific version of Node
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
- * 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;
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
- * 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
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
- name: string;
147
- dir: URL;
148
- fileType: FileType;
164
+ name: string;
165
+ dir: URL;
166
+ fileType: FileType;
149
167
  }
150
-
168
+ //#endregion
169
+ //#region src/common/stat.d.ts
151
170
  /**
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
- */
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
- dispose(): void;
180
+ dispose(): void;
161
181
  }
162
-
163
- type UrlOrReference$1 = URL | FileReference;
164
- declare function urlOrReferenceToUrl(urlOrReference: UrlOrReference$1): URL;
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
- signal?: AbortSignal;
168
- encoding?: BufferEncoding;
189
+ signal?: AbortSignal;
190
+ encoding?: BufferEncoding;
169
191
  }
170
192
  type ReadFileOptionsOrEncoding = ReadFileOptions$1 | BufferEncoding;
171
193
  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;
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
- 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;
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
- None = 0,
279
- Stat = 1,
280
- Read = 2,
281
- Write = 4,
282
- ReadWrite = 6,
283
- ReadDir = 8,
284
- WriteDir = 16,
285
- ReadWriteDir = 24
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
- name: string;
312
+ name: string;
289
313
  }
290
314
  interface ReadFileOptions {
291
- signal?: AbortSignal;
292
- encoding?: BufferEncoding;
315
+ signal?: AbortSignal;
316
+ encoding?: BufferEncoding;
293
317
  }
294
318
  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;
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
- findUp(name: string | string[] | VFindUpPredicate, from: URL, options?: VFindUpURLOptions): Promise<URL | undefined>;
366
+ findUp(name: string | string[] | VFindUpPredicate, from: URL, options?: VFindUpURLOptions): Promise<URL | undefined>;
343
367
  }
344
368
  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;
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
- isDirectory(): boolean;
354
- isFile(): boolean;
355
- isUnknown(): boolean;
356
- isSymbolicLink(): boolean;
377
+ isDirectory(): boolean;
378
+ isFile(): boolean;
379
+ isUnknown(): boolean;
380
+ isSymbolicLink(): boolean;
357
381
  }
358
382
  interface VfsDirEntry extends DirEntry {
359
- isDirectory(): boolean;
360
- isFile(): boolean;
361
- isUnknown(): boolean;
362
- isSymbolicLink(): boolean;
383
+ isDirectory(): boolean;
384
+ isFile(): boolean;
385
+ isUnknown(): boolean;
386
+ isSymbolicLink(): boolean;
363
387
  }
364
- type VFindEntryType = 'file' | 'directory' | '!file' | '!directory';
388
+ type VFindEntryType = "file" | "directory" | "!file" | "!directory";
365
389
  interface VFindUpURLOptions {
366
- type?: VFindEntryType;
367
- stopAt?: URL;
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
- 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;
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
- signal?: AbortSignal;
422
+ signal?: AbortSignal;
398
423
  }
399
424
  type VProviderFileSystemReadFileOptions = OptionAbort;
400
425
  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;
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
- /** 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;
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
- type TextEncodingExtra = 'utf-16be' | 'utf-16le' | 'utf16be' | 'utf16le';
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
- * 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
- */
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
- * Option ts to mask the capabilities of the provider.
464
- * @default: -1
465
- */
466
- capabilitiesMask?: number;
467
- capabilities?: FSCapabilityFlags;
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
- * 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
- */
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 { 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 };
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