cspell-io 8.1.2 → 8.2.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/esm/CSpellIO.d.ts +19 -12
- package/dist/esm/CSpellIONode.d.ts +4 -5
- package/dist/esm/CSpellIONode.js +9 -0
- package/dist/esm/CSpellIOWeb.d.ts +5 -4
- package/dist/esm/CSpellIOWeb.js +3 -0
- package/dist/esm/VirtualFS/redirectProvider.d.ts +30 -0
- package/dist/esm/VirtualFS/redirectProvider.js +147 -0
- package/dist/esm/VirtualFS.d.ts +107 -0
- package/dist/esm/VirtualFS.js +326 -0
- package/dist/esm/common/CFileReference.d.ts +1 -0
- package/dist/esm/common/CFileReference.js +3 -0
- package/dist/esm/common/CFileResource.d.ts +7 -4
- package/dist/esm/common/CFileResource.js +12 -1
- package/dist/esm/common/index.d.ts +3 -2
- package/dist/esm/common/index.js +3 -2
- package/dist/esm/common/urlOrReferenceToUrl.d.ts +5 -0
- package/dist/esm/common/urlOrReferenceToUrl.js +4 -0
- package/dist/esm/handlers/node/file.js +38 -1
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/models/FileResource.d.ts +2 -2
- package/dist/esm/models/Stats.d.ts +23 -0
- package/dist/esm/models/Stats.js +15 -4
- package/dist/esm/models/disposable.d.ts +4 -0
- package/dist/esm/models/disposable.js +2 -0
- package/dist/esm/models/index.d.ts +5 -1
- package/dist/esm/models/index.js +1 -1
- package/dist/esm/node/file/fetch.js +3 -0
- package/dist/esm/node/file/url.d.ts +2 -0
- package/dist/esm/node/file/url.js +20 -7
- package/dist/esm/requests/RequestFsReadDirectory.d.ts +9 -0
- package/dist/esm/requests/RequestFsReadDirectory.js +4 -0
- package/dist/esm/requests/RequestFsReadFile.d.ts +2 -2
- package/dist/esm/requests/RequestFsReadFileSync.d.ts +2 -2
- package/dist/esm/test/test.helper.d.ts +15 -3
- package/dist/esm/test/test.helper.js +36 -9
- package/package.json +4 -4
package/dist/esm/CSpellIO.d.ts
CHANGED
|
@@ -1,41 +1,48 @@
|
|
|
1
1
|
import type { BufferEncoding } from './models/BufferEncoding.js';
|
|
2
|
-
import type { FileReference,
|
|
3
|
-
import type { Stats } from './models/index.js';
|
|
2
|
+
import type { FileReference, TextFileResource, UrlOrFilename, UrlOrReference } from './models/FileResource.js';
|
|
3
|
+
import type { DirEntry, Stats } from './models/index.js';
|
|
4
4
|
export interface CSpellIO {
|
|
5
5
|
/**
|
|
6
6
|
* Read a file
|
|
7
|
-
* @param
|
|
7
|
+
* @param urlOrFilename - uri of the file to read
|
|
8
8
|
* @param encoding - optional encoding.
|
|
9
9
|
* @returns A TextFileResource.
|
|
10
10
|
*/
|
|
11
|
-
readFile(
|
|
11
|
+
readFile(urlOrFilename: UrlOrReference, encoding?: BufferEncoding): Promise<TextFileResource>;
|
|
12
12
|
/**
|
|
13
13
|
* Read a file in Sync mode.
|
|
14
14
|
* Note: `http` requests will fail.
|
|
15
|
-
* @param
|
|
15
|
+
* @param urlOrFilename - uri of the file to read
|
|
16
16
|
* @param encoding - optional encoding.
|
|
17
17
|
* @returns A TextFileResource.
|
|
18
|
+
* @deprecated Use `readFile` instead.
|
|
18
19
|
*/
|
|
19
|
-
readFileSync(
|
|
20
|
+
readFileSync(urlOrFilename: UrlOrReference, encoding?: BufferEncoding): TextFileResource;
|
|
20
21
|
/**
|
|
21
22
|
* Write content to a file using utf-8 encoding.
|
|
22
23
|
* It will fail to write to non-file uris.
|
|
23
|
-
* @param
|
|
24
|
+
* @param urlOrFilename - uri
|
|
24
25
|
* @param content - string to write.
|
|
25
26
|
*/
|
|
26
|
-
writeFile(
|
|
27
|
+
writeFile(urlOrFilename: UrlOrReference, content: string | ArrayBufferView): Promise<FileReference>;
|
|
28
|
+
/**
|
|
29
|
+
* Read a directory.
|
|
30
|
+
* @param urlOrFilename - uri
|
|
31
|
+
*/
|
|
32
|
+
readDirectory(urlOrFilename: string | URL): Promise<DirEntry[]>;
|
|
27
33
|
/**
|
|
28
34
|
* Get Stats on a uri.
|
|
29
|
-
* @param
|
|
35
|
+
* @param urlOrFilename - uri to fetch stats on
|
|
30
36
|
* @returns Stats if successful.
|
|
31
37
|
*/
|
|
32
|
-
getStat(
|
|
38
|
+
getStat(urlOrFilename: UrlOrReference): Promise<Stats>;
|
|
33
39
|
/**
|
|
34
40
|
* Get Stats on a uri.
|
|
35
|
-
* @param
|
|
41
|
+
* @param urlOrFilename - uri to fetch stats on
|
|
36
42
|
* @returns Stats if successful, otherwise it throws an error.
|
|
43
|
+
* @deprecated Use `getStat` instead.
|
|
37
44
|
*/
|
|
38
|
-
getStatSync(
|
|
45
|
+
getStatSync(urlOrFilename: UrlOrReference): Stats;
|
|
39
46
|
/**
|
|
40
47
|
* Compare two Stats.
|
|
41
48
|
* @param left - left stat
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { ServiceBus } from '@cspell/cspell-service-bus';
|
|
2
2
|
import type { CSpellIO } from './CSpellIO.js';
|
|
3
|
-
import type { BufferEncoding } from './models/
|
|
4
|
-
import type { FileReference, FileResource, UrlOrReference } from './models/FileResource.js';
|
|
5
|
-
import type { Stats } from './models/Stats.js';
|
|
3
|
+
import type { BufferEncoding, DirEntry, FileReference, Stats, TextFileResource, UrlOrReference } from './models/index.js';
|
|
6
4
|
export declare class CSpellIONode implements CSpellIO {
|
|
7
5
|
readonly serviceBus: ServiceBus;
|
|
8
6
|
constructor(serviceBus?: ServiceBus);
|
|
9
|
-
readFile(urlOrFilename: UrlOrReference, encoding?: BufferEncoding): Promise<
|
|
10
|
-
|
|
7
|
+
readFile(urlOrFilename: UrlOrReference, encoding?: BufferEncoding): Promise<TextFileResource>;
|
|
8
|
+
readDirectory(urlOrFilename: string | URL): Promise<DirEntry[]>;
|
|
9
|
+
readFileSync(urlOrFilename: UrlOrReference, encoding?: BufferEncoding): TextFileResource;
|
|
11
10
|
writeFile(urlOrFilename: UrlOrReference, content: string | ArrayBufferView): Promise<FileReference>;
|
|
12
11
|
getStat(urlOrFilename: UrlOrReference): Promise<Stats>;
|
|
13
12
|
getStatSync(urlOrFilename: UrlOrReference): Stats;
|
package/dist/esm/CSpellIONode.js
CHANGED
|
@@ -6,6 +6,7 @@ import { ErrorNotImplemented } from './errors/errors.js';
|
|
|
6
6
|
import { registerHandlers } from './handlers/node/file.js';
|
|
7
7
|
import { toFileURL, toURL, urlBasename, urlDirname } from './node/file/url.js';
|
|
8
8
|
import { RequestFsReadFile, RequestFsReadFileSync, RequestFsStat, RequestFsStatSync, RequestFsWriteFile, } from './requests/index.js';
|
|
9
|
+
import { RequestFsReadDirectory } from './requests/RequestFsReadDirectory.js';
|
|
9
10
|
let defaultCSpellIONode = undefined;
|
|
10
11
|
export class CSpellIONode {
|
|
11
12
|
serviceBus;
|
|
@@ -21,6 +22,14 @@ export class CSpellIONode {
|
|
|
21
22
|
}
|
|
22
23
|
return res.value;
|
|
23
24
|
}
|
|
25
|
+
readDirectory(urlOrFilename) {
|
|
26
|
+
const ref = toFileReference(urlOrFilename);
|
|
27
|
+
const res = this.serviceBus.dispatch(RequestFsReadDirectory.create(ref));
|
|
28
|
+
if (!isServiceResponseSuccess(res)) {
|
|
29
|
+
throw genError(res.error, 'readDirectory');
|
|
30
|
+
}
|
|
31
|
+
return res.value;
|
|
32
|
+
}
|
|
24
33
|
readFileSync(urlOrFilename, encoding) {
|
|
25
34
|
const ref = toFileReference(urlOrFilename, encoding);
|
|
26
35
|
const res = this.serviceBus.dispatch(RequestFsReadFileSync.create(ref));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { CSpellIO } from './CSpellIO.js';
|
|
2
|
-
import type { FileReference,
|
|
3
|
-
import type { Stats } from './models/
|
|
2
|
+
import type { FileReference, TextFileResource, UrlOrFilename, UrlOrReference } from './models/FileResource.js';
|
|
3
|
+
import type { DirEntry, Stats } from './models/index.js';
|
|
4
4
|
export declare class CSpellIOWeb implements CSpellIO {
|
|
5
|
-
readFile(_uriOrFilename: string | URL): Promise<
|
|
6
|
-
readFileSync(_uriOrFilename: string | URL):
|
|
5
|
+
readFile(_uriOrFilename: string | URL): Promise<TextFileResource>;
|
|
6
|
+
readFileSync(_uriOrFilename: string | URL): TextFileResource;
|
|
7
|
+
readDirectory(_urlOrFilename: string | URL): Promise<DirEntry[]>;
|
|
7
8
|
writeFile(_uriOrFilename: UrlOrReference, _content: string | ArrayBufferView): Promise<FileReference>;
|
|
8
9
|
getStat(_uriOrFilename: string | URL): Promise<Stats>;
|
|
9
10
|
getStatSync(_uriOrFilename: string | URL): Stats;
|
package/dist/esm/CSpellIOWeb.js
CHANGED
|
@@ -7,6 +7,9 @@ export class CSpellIOWeb {
|
|
|
7
7
|
readFileSync(_uriOrFilename) {
|
|
8
8
|
throw new ErrorNotImplemented('readFileSync');
|
|
9
9
|
}
|
|
10
|
+
readDirectory(_urlOrFilename) {
|
|
11
|
+
throw new ErrorNotImplemented('readDirectory');
|
|
12
|
+
}
|
|
10
13
|
writeFile(_uriOrFilename, _content) {
|
|
11
14
|
throw new ErrorNotImplemented('writeFile');
|
|
12
15
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FSCapabilityFlags, VFileSystemProvider } from '../VirtualFS.js';
|
|
2
|
+
export interface RedirectOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Option ts to mask the capabilities of the provider.
|
|
5
|
+
* @default: -1
|
|
6
|
+
*/
|
|
7
|
+
capabilitiesMask?: number;
|
|
8
|
+
capabilities?: FSCapabilityFlags;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create a provider that will redirect requests from the publicRoot to the privateRoot.
|
|
12
|
+
* This is useful for creating a virtual file system that is a subset of another file system.
|
|
13
|
+
*
|
|
14
|
+
* Example:
|
|
15
|
+
* ```ts
|
|
16
|
+
* const vfs = createVirtualFS();
|
|
17
|
+
* const provider = createRedirectProvider('test', new URL('file:///public/'), new URL('file:///private/'))
|
|
18
|
+
* vfs.registerFileSystemProvider(provider);
|
|
19
|
+
* // Read the content of `file:///private/file.txt`
|
|
20
|
+
* const file = vfs.fs.readFile(new URL('file:///public/file.txt');
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param name - name of the provider
|
|
24
|
+
* @param publicRoot - the root of the public file system.
|
|
25
|
+
* @param privateRoot - the root of the private file system.
|
|
26
|
+
* @param options - options for the provider.
|
|
27
|
+
* @returns FileSystemProvider
|
|
28
|
+
*/
|
|
29
|
+
export declare function createRedirectProvider(name: string, publicRoot: URL, privateRoot: URL, options?: RedirectOptions): VFileSystemProvider;
|
|
30
|
+
//# sourceMappingURL=redirectProvider.d.ts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import { renameFileReference, renameFileResource, urlOrReferenceToUrl } from '../common/index.js';
|
|
3
|
+
import { fsCapabilities, VFSErrorUnsupportedRequest } from '../VirtualFS.js';
|
|
4
|
+
class RedirectProvider {
|
|
5
|
+
name;
|
|
6
|
+
publicRoot;
|
|
7
|
+
privateRoot;
|
|
8
|
+
options;
|
|
9
|
+
constructor(name, publicRoot, privateRoot, options = { capabilitiesMask: -1 }) {
|
|
10
|
+
this.name = name;
|
|
11
|
+
this.publicRoot = publicRoot;
|
|
12
|
+
this.privateRoot = privateRoot;
|
|
13
|
+
this.options = options;
|
|
14
|
+
}
|
|
15
|
+
getFileSystem(url, next) {
|
|
16
|
+
if (url.protocol !== this.publicRoot.protocol || url.host !== this.publicRoot.host) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
const privateFs = next(this.privateRoot);
|
|
20
|
+
if (!privateFs) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const shadowFS = next(url);
|
|
24
|
+
return remapFS(this.name, privateFs, shadowFS, this.publicRoot, this.privateRoot, this.options);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a provider that will redirect requests from the publicRoot to the privateRoot.
|
|
29
|
+
* This is useful for creating a virtual file system that is a subset of another file system.
|
|
30
|
+
*
|
|
31
|
+
* Example:
|
|
32
|
+
* ```ts
|
|
33
|
+
* const vfs = createVirtualFS();
|
|
34
|
+
* const provider = createRedirectProvider('test', new URL('file:///public/'), new URL('file:///private/'))
|
|
35
|
+
* vfs.registerFileSystemProvider(provider);
|
|
36
|
+
* // Read the content of `file:///private/file.txt`
|
|
37
|
+
* const file = vfs.fs.readFile(new URL('file:///public/file.txt');
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param name - name of the provider
|
|
41
|
+
* @param publicRoot - the root of the public file system.
|
|
42
|
+
* @param privateRoot - the root of the private file system.
|
|
43
|
+
* @param options - options for the provider.
|
|
44
|
+
* @returns FileSystemProvider
|
|
45
|
+
*/
|
|
46
|
+
export function createRedirectProvider(name, publicRoot, privateRoot, options) {
|
|
47
|
+
assert(publicRoot.pathname.endsWith('/'), 'publicRoot must end with a slash');
|
|
48
|
+
assert(privateRoot.pathname.endsWith('/'), 'privateRoot must end with a slash');
|
|
49
|
+
return new RedirectProvider(name, publicRoot, privateRoot, options);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a Remapped file system that will redirect requests from the publicRoot to the privateRoot.
|
|
53
|
+
* Requests that do not match the publicRoot will be passed to the shadowFs.
|
|
54
|
+
* @param name - name of the provider
|
|
55
|
+
* @param fs - the private file system
|
|
56
|
+
* @param shadowFs - the file system that is obscured by the redirect.
|
|
57
|
+
* @param publicRoot - the root of the public file system.
|
|
58
|
+
* @param privateRoot - the root of the private file system.
|
|
59
|
+
* @returns ProviderFileSystem
|
|
60
|
+
*/
|
|
61
|
+
function remapFS(name, fs, shadowFs, publicRoot, privateRoot, options) {
|
|
62
|
+
const { capabilitiesMask = -1, capabilities } = options;
|
|
63
|
+
function mapToPrivate(url) {
|
|
64
|
+
const relativePath = url.pathname.slice(publicRoot.pathname.length);
|
|
65
|
+
return new URL(relativePath, privateRoot);
|
|
66
|
+
}
|
|
67
|
+
function mapToPublic(url) {
|
|
68
|
+
const relativePath = url.pathname.slice(privateRoot.pathname.length);
|
|
69
|
+
return new URL(relativePath, publicRoot);
|
|
70
|
+
}
|
|
71
|
+
const mapFileReferenceToPrivate = (ref) => {
|
|
72
|
+
return renameFileReference(ref, mapToPrivate(ref.url));
|
|
73
|
+
};
|
|
74
|
+
const mapFileReferenceToPublic = (ref) => {
|
|
75
|
+
return renameFileReference(ref, mapToPublic(ref.url));
|
|
76
|
+
};
|
|
77
|
+
const mapUrlOrReferenceToPrivate = (urlOrRef) => {
|
|
78
|
+
return urlOrRef instanceof URL ? mapToPrivate(urlOrRef) : mapFileReferenceToPrivate(urlOrRef);
|
|
79
|
+
};
|
|
80
|
+
const mapFileResourceToPublic = (res) => {
|
|
81
|
+
return renameFileResource(res, mapToPublic(res.url));
|
|
82
|
+
};
|
|
83
|
+
const mapFileResourceToPrivate = (res) => {
|
|
84
|
+
return renameFileResource(res, mapToPrivate(res.url));
|
|
85
|
+
};
|
|
86
|
+
const mapDirEntryToPublic = (de) => {
|
|
87
|
+
const dir = mapToPublic(de.dir);
|
|
88
|
+
return { ...de, dir };
|
|
89
|
+
};
|
|
90
|
+
const fs2 = {
|
|
91
|
+
stat: async (url) => {
|
|
92
|
+
const url2 = mapUrlOrReferenceToPrivate(url);
|
|
93
|
+
const stat = await fs.stat(url2);
|
|
94
|
+
return stat;
|
|
95
|
+
},
|
|
96
|
+
readFile: async (url) => {
|
|
97
|
+
const url2 = mapUrlOrReferenceToPrivate(url);
|
|
98
|
+
const file = await fs.readFile(url2);
|
|
99
|
+
return mapFileResourceToPublic(file);
|
|
100
|
+
},
|
|
101
|
+
readDirectory: async (url) => {
|
|
102
|
+
const url2 = mapToPrivate(url);
|
|
103
|
+
const dir = await fs.readDirectory(url2);
|
|
104
|
+
return dir.map(mapDirEntryToPublic);
|
|
105
|
+
},
|
|
106
|
+
writeFile: async (file) => {
|
|
107
|
+
const fileRef2 = mapFileResourceToPrivate(file);
|
|
108
|
+
const fileRef3 = await fs.writeFile(fileRef2);
|
|
109
|
+
return mapFileReferenceToPublic(fileRef3);
|
|
110
|
+
},
|
|
111
|
+
providerInfo: { ...fs.providerInfo, name },
|
|
112
|
+
capabilities: capabilities ?? fs.capabilities & capabilitiesMask,
|
|
113
|
+
dispose: () => fs.dispose(),
|
|
114
|
+
};
|
|
115
|
+
return fsPassThrough(fs2, shadowFs, publicRoot);
|
|
116
|
+
}
|
|
117
|
+
function fsPassThrough(fs, shadowFs, root) {
|
|
118
|
+
function gfs(ur, name) {
|
|
119
|
+
const url = urlOrReferenceToUrl(ur);
|
|
120
|
+
const f = url.href.startsWith(root.href) ? fs : shadowFs;
|
|
121
|
+
if (!f)
|
|
122
|
+
throw new VFSErrorUnsupportedRequest(name, url, ur instanceof URL ? undefined : { url: ur.url.toString(), encoding: ur.encoding });
|
|
123
|
+
return f;
|
|
124
|
+
}
|
|
125
|
+
const passThroughFs = {
|
|
126
|
+
get providerInfo() {
|
|
127
|
+
return fs.providerInfo;
|
|
128
|
+
},
|
|
129
|
+
get capabilities() {
|
|
130
|
+
return fs.capabilities;
|
|
131
|
+
},
|
|
132
|
+
stat: async (url) => gfs(url, 'stat').stat(url),
|
|
133
|
+
readFile: async (url) => gfs(url, 'readFile').readFile(url),
|
|
134
|
+
writeFile: async (file) => gfs(file, 'writeFile').writeFile(file),
|
|
135
|
+
readDirectory: async (url) => gfs(url, 'readDirectory').readDirectory(url),
|
|
136
|
+
getCapabilities(url) {
|
|
137
|
+
const f = gfs(url, 'getCapabilities');
|
|
138
|
+
return f.getCapabilities ? f.getCapabilities(url) : fsCapabilities(f.capabilities);
|
|
139
|
+
},
|
|
140
|
+
dispose: () => {
|
|
141
|
+
fs.dispose();
|
|
142
|
+
shadowFs?.dispose();
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
return passThroughFs;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=redirectProvider.js.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { CSpellIO } from './CSpellIO.js';
|
|
2
|
+
import { type DirEntry, type Disposable, type FileReference, type FileResource, type Stats } from './models/index.js';
|
|
3
|
+
type UrlOrReference = URL | FileReference;
|
|
4
|
+
type NextProvider = (url: URL) => VProviderFileSystem | undefined;
|
|
5
|
+
export interface VirtualFS extends Disposable {
|
|
6
|
+
registerFileSystemProvider(provider: VFileSystemProvider, ...providers: VFileSystemProvider[]): Disposable;
|
|
7
|
+
/**
|
|
8
|
+
* Get the fs for a given url.
|
|
9
|
+
*/
|
|
10
|
+
getFS(url: URL): VFileSystem;
|
|
11
|
+
/**
|
|
12
|
+
* The file system. All requests will first use getFileSystem to get the file system before making the request.
|
|
13
|
+
*/
|
|
14
|
+
readonly fs: Required<VFileSystem>;
|
|
15
|
+
/**
|
|
16
|
+
* Clear the cache of file systems.
|
|
17
|
+
*/
|
|
18
|
+
reset(): void;
|
|
19
|
+
}
|
|
20
|
+
export declare enum FSCapabilityFlags {
|
|
21
|
+
None = 0,
|
|
22
|
+
Stat = 1,
|
|
23
|
+
Read = 2,
|
|
24
|
+
Write = 4,
|
|
25
|
+
ReadWrite = 6,
|
|
26
|
+
ReadDir = 8,
|
|
27
|
+
WriteDir = 16,
|
|
28
|
+
ReadWriteDir = 24
|
|
29
|
+
}
|
|
30
|
+
interface FileSystemProviderInfo {
|
|
31
|
+
name: string;
|
|
32
|
+
}
|
|
33
|
+
interface FileSystemBase {
|
|
34
|
+
readFile(url: UrlOrReference): Promise<FileResource>;
|
|
35
|
+
writeFile(file: FileResource): Promise<FileReference>;
|
|
36
|
+
/**
|
|
37
|
+
* Information about the provider.
|
|
38
|
+
* It is up to the provider to define what information is available.
|
|
39
|
+
*/
|
|
40
|
+
providerInfo: FileSystemProviderInfo;
|
|
41
|
+
}
|
|
42
|
+
export interface VFileSystem extends FileSystemBase {
|
|
43
|
+
stat(url: UrlOrReference): Promise<VfsStat>;
|
|
44
|
+
readDirectory(url: URL): Promise<VfsDirEntry[]>;
|
|
45
|
+
getCapabilities(url: URL): FSCapabilities;
|
|
46
|
+
hasProvider: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface VProviderFileSystem extends FileSystemBase, Disposable {
|
|
49
|
+
stat(url: UrlOrReference): Stats | Promise<Stats>;
|
|
50
|
+
readDirectory(url: URL): Promise<DirEntry[]>;
|
|
51
|
+
/**
|
|
52
|
+
* These are the general capabilities for the provider's file system.
|
|
53
|
+
* It is possible for a provider to support more capabilities for a given url by providing a getCapabilities function.
|
|
54
|
+
*/
|
|
55
|
+
capabilities: FSCapabilityFlags;
|
|
56
|
+
/**
|
|
57
|
+
* Get the capabilities for a URL. Make it possible for a provider to support more capabilities for a given url.
|
|
58
|
+
* These capabilities should be more restrictive than the general capabilities.
|
|
59
|
+
* @param url - the url to try
|
|
60
|
+
* @returns the capabilities for the url.
|
|
61
|
+
*/
|
|
62
|
+
getCapabilities?: (url: URL) => FSCapabilities;
|
|
63
|
+
}
|
|
64
|
+
export interface VFileSystemProvider extends Partial<Disposable> {
|
|
65
|
+
/** Name of the Provider */
|
|
66
|
+
name: string;
|
|
67
|
+
/**
|
|
68
|
+
* Get the file system for a given url. The provider is cached based upon the protocol and hostname.
|
|
69
|
+
* @param url - the url to get the file system for.
|
|
70
|
+
* @param next - call this function to get the next provider to try. This is useful for chaining providers that operate on the same protocol.
|
|
71
|
+
*/
|
|
72
|
+
getFileSystem(url: URL, next: NextProvider): VProviderFileSystem | undefined;
|
|
73
|
+
}
|
|
74
|
+
export declare function createVirtualFS(cspellIO?: CSpellIO): VirtualFS;
|
|
75
|
+
export declare function getDefaultVirtualFs(): VirtualFS;
|
|
76
|
+
export declare class VFSError extends Error {
|
|
77
|
+
constructor(message: string, options?: {
|
|
78
|
+
cause?: unknown;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export declare class VFSErrorUnsupportedRequest extends VFSError {
|
|
82
|
+
readonly request: string;
|
|
83
|
+
readonly parameters?: unknown;
|
|
84
|
+
readonly url?: string | undefined;
|
|
85
|
+
constructor(request: string, url?: URL | string, parameters?: unknown);
|
|
86
|
+
}
|
|
87
|
+
export interface FSCapabilities {
|
|
88
|
+
readonly flags: FSCapabilityFlags;
|
|
89
|
+
readonly readFile: boolean;
|
|
90
|
+
readonly writeFile: boolean;
|
|
91
|
+
readonly readDirectory: boolean;
|
|
92
|
+
readonly writeDirectory: boolean;
|
|
93
|
+
readonly stat: boolean;
|
|
94
|
+
}
|
|
95
|
+
export declare function fsCapabilities(flags: FSCapabilityFlags): FSCapabilities;
|
|
96
|
+
export interface VfsStat extends Stats {
|
|
97
|
+
isDirectory(): boolean;
|
|
98
|
+
isFile(): boolean;
|
|
99
|
+
isUnknown(): boolean;
|
|
100
|
+
}
|
|
101
|
+
export interface VfsDirEntry extends DirEntry {
|
|
102
|
+
isDirectory(): boolean;
|
|
103
|
+
isFile(): boolean;
|
|
104
|
+
isUnknown(): boolean;
|
|
105
|
+
}
|
|
106
|
+
export {};
|
|
107
|
+
//# sourceMappingURL=VirtualFS.d.ts.map
|