@fnndsc/fond 0.1.2 → 0.3.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/README.md +24 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/vfs/contract.d.ts +26 -0
- package/dist/vfs/contract.js +195 -0
- package/dist/vfs/contract.js.map +1 -0
- package/dist/vfs/dispatcher.d.ts +208 -0
- package/dist/vfs/dispatcher.js +409 -0
- package/dist/vfs/dispatcher.js.map +1 -0
- package/dist/vfs/fsViews.d.ts +39 -0
- package/dist/vfs/fsViews.js +91 -0
- package/dist/vfs/fsViews.js.map +1 -0
- package/dist/vfs/memory.d.ts +66 -0
- package/dist/vfs/memory.js +282 -0
- package/dist/vfs/memory.js.map +1 -0
- package/dist/vfs/outcome.d.ts +98 -0
- package/dist/vfs/outcome.js +151 -0
- package/dist/vfs/outcome.js.map +1 -0
- package/dist/vfs/provider.d.ts +159 -0
- package/dist/vfs/provider.js +13 -0
- package/dist/vfs/provider.js.map +1 -0
- package/dist/vfs/render.d.ts +73 -0
- package/dist/vfs/render.js +203 -0
- package/dist/vfs/render.js.map +1 -0
- package/dist/vfs/sort.d.ts +18 -0
- package/dist/vfs/sort.js +33 -0
- package/dist/vfs/sort.js.map +1 -0
- package/package.json +4 -1
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file The virtual filesystem's dispatcher: routes each request to the
|
|
4
|
+
* mount that owns the path.
|
|
5
|
+
*
|
|
6
|
+
* Mounts (providers) are registered with a path prefix; the longest prefix
|
|
7
|
+
* that matches at a segment boundary wins, so `/proc/jobs` takes precedence
|
|
8
|
+
* over `/proc`, and `/procs` is not under `/proc`. A path no mount claims
|
|
9
|
+
* goes to the fallback, the provider given to the constructor. The
|
|
10
|
+
* dispatcher itself knows no backend: a backend registers its mounts and
|
|
11
|
+
* names its fallback.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.VFSDispatcher = void 0;
|
|
17
|
+
const result_js_1 = require("../result.js");
|
|
18
|
+
const errorStack_js_1 = require("../errorStack.js");
|
|
19
|
+
const outcome_js_1 = require("./outcome.js");
|
|
20
|
+
/**
|
|
21
|
+
* The fallback when none is given: it holds nothing, and says so by name
|
|
22
|
+
* rather than answering with an empty folder.
|
|
23
|
+
*/
|
|
24
|
+
const VFS_FALLBACK_NONE = {
|
|
25
|
+
prefix: "",
|
|
26
|
+
async list(path) {
|
|
27
|
+
errorStack_js_1.errorStack.stack_push("error", `No mount serves ${path}.`);
|
|
28
|
+
return (0, result_js_1.Err)();
|
|
29
|
+
},
|
|
30
|
+
async cp(src) {
|
|
31
|
+
return (0, outcome_js_1.vfs_fail)("ENOENT", `cp: no mount serves ${src}`);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Routes filesystem requests to the mount that owns each path, or to the
|
|
36
|
+
* fallback.
|
|
37
|
+
*/
|
|
38
|
+
class VFSDispatcher {
|
|
39
|
+
/**
|
|
40
|
+
* @param fallback - The provider for paths no mount claims; one that holds
|
|
41
|
+
* nothing, and says so, when none is given.
|
|
42
|
+
*/
|
|
43
|
+
constructor(fallback = VFS_FALLBACK_NONE) {
|
|
44
|
+
this.providers = [];
|
|
45
|
+
this.defaultProvider = fallback;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Registers a path resolution hook that maps logical paths to physical paths.
|
|
49
|
+
*
|
|
50
|
+
* @param resolver - The resolver function mapping a logical path to a physical path.
|
|
51
|
+
*/
|
|
52
|
+
pathResolver_register(resolver) {
|
|
53
|
+
this.pathResolver = resolver;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Registers a new VFS Provider.
|
|
57
|
+
*
|
|
58
|
+
* @param provider - The provider instance to register.
|
|
59
|
+
*/
|
|
60
|
+
provider_register(provider) {
|
|
61
|
+
this.providers.push(provider);
|
|
62
|
+
// Sort by prefix length descending to match most specific prefix first
|
|
63
|
+
this.providers.sort((a, b) => b.prefix.length - a.prefix.length);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns every registered mount (not the fallback). Used by callers that
|
|
67
|
+
* need to detect parent-of-prefix paths.
|
|
68
|
+
*/
|
|
69
|
+
providers_get() {
|
|
70
|
+
return [...this.providers];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolves the matching provider for a given virtual path.
|
|
74
|
+
*
|
|
75
|
+
* @param pathStr - The absolute virtual path.
|
|
76
|
+
* @returns The matching mount, or the fallback.
|
|
77
|
+
*/
|
|
78
|
+
provider_get(pathStr) {
|
|
79
|
+
const absolutePath = pathStr.startsWith("/") ? pathStr : "/" + pathStr;
|
|
80
|
+
const match = this.providers.find((p) => absolutePath === p.prefix || absolutePath.startsWith(p.prefix + "/"));
|
|
81
|
+
return match || this.defaultProvider;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Whether a path belongs to a mount rather than to the fallback.
|
|
85
|
+
*
|
|
86
|
+
* Two shapes count: a path a mount owns (at or under its prefix), and a
|
|
87
|
+
* path that is a strict ancestor of a mount's prefix (`/proc` above
|
|
88
|
+
* `/proc/jobs`), whose only children are the mounts beneath it. The root
|
|
89
|
+
* `/` never counts: it is the fallback's own root.
|
|
90
|
+
*
|
|
91
|
+
* It keeps the fallback from being asked to answer for a path it has no
|
|
92
|
+
* folder behind, which cannot succeed and only fills the error stack once
|
|
93
|
+
* per ancestor a path walk visits.
|
|
94
|
+
*
|
|
95
|
+
* @param pathStr - The absolute (or root-relative) path to classify.
|
|
96
|
+
* @returns True when a mount owns, or is owned by, the path.
|
|
97
|
+
*/
|
|
98
|
+
path_isVirtual(pathStr) {
|
|
99
|
+
const absolutePath = pathStr.startsWith("/") ? pathStr : "/" + pathStr;
|
|
100
|
+
const clean = absolutePath.length > 1 && absolutePath.endsWith("/") ? absolutePath.slice(0, -1) : absolutePath;
|
|
101
|
+
if (clean === "/")
|
|
102
|
+
return false;
|
|
103
|
+
return this.providers.some((p) => p.prefix.length > 0 &&
|
|
104
|
+
(clean === p.prefix || clean.startsWith(p.prefix + "/") || p.prefix.startsWith(clean + "/")));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Dispatches directory listing to matched provider.
|
|
108
|
+
* Supports dynamic intermediate parent path synthesis for virtual prefixes.
|
|
109
|
+
*
|
|
110
|
+
* @param pathStr - The absolute virtual path to list.
|
|
111
|
+
* @param options - Sort controls.
|
|
112
|
+
* @returns Promise resolving to Result<VFSItem[]>.
|
|
113
|
+
*/
|
|
114
|
+
async list(pathStr, options) {
|
|
115
|
+
const absolutePath = pathStr.startsWith("/") ? pathStr : "/" + pathStr;
|
|
116
|
+
const cleanPath = absolutePath.endsWith("/") && absolutePath.length > 1 ? absolutePath.slice(0, -1) : absolutePath;
|
|
117
|
+
// Check if cleanPath is a parent of any registered provider's prefix
|
|
118
|
+
const prefixParent = cleanPath === "/" ? "/" : cleanPath + "/";
|
|
119
|
+
const children = this.providers.filter((p) => p.prefix.startsWith(prefixParent));
|
|
120
|
+
if (children.length > 0) {
|
|
121
|
+
const segmentIndex = cleanPath === "/" ? 1 : cleanPath.split("/").length;
|
|
122
|
+
const virtualSubdirs = new Set();
|
|
123
|
+
for (const p of children) {
|
|
124
|
+
const segments = p.prefix.split("/");
|
|
125
|
+
const nextSegment = segments[segmentIndex];
|
|
126
|
+
if (nextSegment) {
|
|
127
|
+
virtualSubdirs.add(nextSegment);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (virtualSubdirs.size > 0) {
|
|
131
|
+
const vfsItems = Array.from(virtualSubdirs).map((name) => ({
|
|
132
|
+
name,
|
|
133
|
+
type: "vfs",
|
|
134
|
+
size: 0,
|
|
135
|
+
owner: "root",
|
|
136
|
+
date: new Date().toISOString(),
|
|
137
|
+
}));
|
|
138
|
+
// The fallback may hold real items in this folder too: list them beside the mounts
|
|
139
|
+
let resolvedPathStr = pathStr;
|
|
140
|
+
if (this.pathResolver) {
|
|
141
|
+
try {
|
|
142
|
+
resolvedPathStr = await this.pathResolver(pathStr);
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
// Deliberate absorption: for a read-only listing, the logical
|
|
146
|
+
// path is a valid fallback (the provider lists what it can);
|
|
147
|
+
// contrast cp(), where a guessed path could write wrongly.
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// The store holding nothing here is an answer: the mounts are the
|
|
151
|
+
// listing, and what the store said is not left to fail the command.
|
|
152
|
+
const mark = errorStack_js_1.errorStack.checkpoint_mark();
|
|
153
|
+
const fallbackResult = await this.defaultProvider.list(resolvedPathStr, options);
|
|
154
|
+
if (!fallbackResult.ok)
|
|
155
|
+
errorStack_js_1.errorStack.checkpoint_drain(mark);
|
|
156
|
+
if (fallbackResult.ok && fallbackResult.value) {
|
|
157
|
+
const fallbackItems = fallbackResult.value;
|
|
158
|
+
for (const item of fallbackItems) {
|
|
159
|
+
if (!virtualSubdirs.has(item.name)) {
|
|
160
|
+
vfsItems.push(item);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return (0, result_js_1.Ok)(vfsItems);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const provider = this.provider_get(pathStr);
|
|
168
|
+
if (provider === this.defaultProvider && this.pathResolver) {
|
|
169
|
+
try {
|
|
170
|
+
const resolvedPath = await this.pathResolver(pathStr);
|
|
171
|
+
return provider.list(resolvedPath, options);
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
// Deliberate absorption: same read-only-listing rationale as above.
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return provider.list(pathStr, options);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The path a provider is asked with: as given for a mount, and through
|
|
181
|
+
* the path resolver for the fallback, when one is registered. An
|
|
182
|
+
* operation never proceeds on a guessed path: a path that does not
|
|
183
|
+
* resolve fails the operation.
|
|
184
|
+
*
|
|
185
|
+
* @param provider - The provider the path belongs to.
|
|
186
|
+
* @param pathStr - The path as asked.
|
|
187
|
+
* @param what - How a resolution failure names the path (`source path`, `path`).
|
|
188
|
+
* @param operation - The verb, for the failure's words.
|
|
189
|
+
* @returns The path to ask with, or why the operation cannot proceed.
|
|
190
|
+
*/
|
|
191
|
+
async pathFor_provider(provider, pathStr, what, operation) {
|
|
192
|
+
if (provider !== this.defaultProvider || !this.pathResolver)
|
|
193
|
+
return (0, outcome_js_1.vfs_ok)(pathStr);
|
|
194
|
+
try {
|
|
195
|
+
return (0, outcome_js_1.vfs_ok)(await this.pathResolver(pathStr));
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
199
|
+
return (0, outcome_js_1.vfs_fail)('EIO', `${operation}: cannot resolve ${what} ${pathStr}: ${msg}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Copies within or between paths, through the provider that owns the source.
|
|
204
|
+
*
|
|
205
|
+
* @param src - Source path.
|
|
206
|
+
* @param dest - Destination path.
|
|
207
|
+
* @param options - Copy options.
|
|
208
|
+
* @returns Done, or why not.
|
|
209
|
+
*/
|
|
210
|
+
async cp(src, dest, options) {
|
|
211
|
+
const provider = this.provider_get(src);
|
|
212
|
+
const from = await this.pathFor_provider(provider, src, 'source path', 'cp');
|
|
213
|
+
if (!from.ok)
|
|
214
|
+
return from;
|
|
215
|
+
const to = await this.pathFor_provider(provider, dest, 'destination path', 'cp');
|
|
216
|
+
if (!to.ok)
|
|
217
|
+
return to;
|
|
218
|
+
return provider.cp(from.value, to.value, options);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Reads a file whole, as text, through the provider that owns it.
|
|
222
|
+
*
|
|
223
|
+
* @param pathStr - The absolute path of the file.
|
|
224
|
+
* @returns Its content, or why not (`EROFS` where no read is offered).
|
|
225
|
+
*/
|
|
226
|
+
async read(pathStr) {
|
|
227
|
+
const provider = this.provider_get(pathStr);
|
|
228
|
+
if (!provider.read)
|
|
229
|
+
return this.readFailure_classify(pathStr, (0, outcome_js_1.vfs_fail)('EROFS'));
|
|
230
|
+
const at = await this.pathFor_provider(provider, pathStr, 'path', 'read');
|
|
231
|
+
return this.readFailure_classify(pathStr, at.ok ? await provider.read(at.value) : at);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* A failed read of a folder says so: whatever the owning mount answered
|
|
235
|
+
* (CUBE's "File not found", a projection's own words, a mount that reads
|
|
236
|
+
* nothing), a path its parent lists as a folder is a directory, as a
|
|
237
|
+
* disk says.
|
|
238
|
+
*
|
|
239
|
+
* @param pathStr - The path read.
|
|
240
|
+
* @param outcome - The read's answer.
|
|
241
|
+
* @returns The answer, or `EISDIR` when it failed on a folder.
|
|
242
|
+
*/
|
|
243
|
+
async readFailure_classify(pathStr, outcome) {
|
|
244
|
+
if (outcome.ok || outcome.errno === 'EISDIR')
|
|
245
|
+
return outcome;
|
|
246
|
+
const clean = pathStr.length > 1 && pathStr.endsWith('/') ? pathStr.slice(0, -1) : pathStr;
|
|
247
|
+
if (clean === '/')
|
|
248
|
+
return (0, outcome_js_1.vfs_fail)('EISDIR');
|
|
249
|
+
const slash = clean.lastIndexOf('/');
|
|
250
|
+
const name = clean.slice(slash + 1);
|
|
251
|
+
const mark = errorStack_js_1.errorStack.checkpoint_mark();
|
|
252
|
+
const siblings = await this.list(clean.slice(0, slash) || '/');
|
|
253
|
+
errorStack_js_1.errorStack.checkpoint_drain(mark);
|
|
254
|
+
const folder = siblings.ok && siblings.value.some((item) => item.name === name && (item.type === 'dir' || item.type === 'vfs'));
|
|
255
|
+
return folder ? (0, outcome_js_1.vfs_fail)('EISDIR') : outcome;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Reads a file whole, as bytes, through the provider that owns it.
|
|
259
|
+
*
|
|
260
|
+
* @param pathStr - The absolute path of the file.
|
|
261
|
+
* @returns Its bytes, or why not.
|
|
262
|
+
*/
|
|
263
|
+
async readBinary(pathStr) {
|
|
264
|
+
const provider = this.provider_get(pathStr);
|
|
265
|
+
if (!provider.readBinary)
|
|
266
|
+
return this.readFailure_classify(pathStr, (0, outcome_js_1.vfs_fail)('EROFS'));
|
|
267
|
+
const at = await this.pathFor_provider(provider, pathStr, 'path', 'read');
|
|
268
|
+
return this.readFailure_classify(pathStr, at.ok ? await provider.readBinary(at.value) : at);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Writes a file whole, through the provider that owns it; a mount that
|
|
272
|
+
* holds no writable files answers `EROFS`.
|
|
273
|
+
*
|
|
274
|
+
* @param pathStr - The absolute path of the file.
|
|
275
|
+
* @param content - The new content, whole.
|
|
276
|
+
* @returns Done, or why not.
|
|
277
|
+
*/
|
|
278
|
+
async write(pathStr, content) {
|
|
279
|
+
const provider = this.provider_get(pathStr);
|
|
280
|
+
if (!provider.write)
|
|
281
|
+
return (0, outcome_js_1.vfs_fail)('EROFS');
|
|
282
|
+
const at = await this.pathFor_provider(provider, pathStr, 'path', 'write');
|
|
283
|
+
return at.ok ? provider.write(at.value, content) : at;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Makes a folder, through the provider that owns its path.
|
|
287
|
+
*
|
|
288
|
+
* @param pathStr - The absolute path of the new folder.
|
|
289
|
+
* @returns Done, or why not.
|
|
290
|
+
*/
|
|
291
|
+
async mkdir(pathStr) {
|
|
292
|
+
const provider = this.provider_get(pathStr);
|
|
293
|
+
if (!provider.mkdir)
|
|
294
|
+
return (0, outcome_js_1.vfs_fail)('EROFS');
|
|
295
|
+
const at = await this.pathFor_provider(provider, pathStr, 'path', 'mkdir');
|
|
296
|
+
return at.ok ? provider.mkdir(at.value) : at;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Whether the provider that owns a folder makes it and its parents in one step.
|
|
300
|
+
*
|
|
301
|
+
* @param pathStr - The absolute path of the folder.
|
|
302
|
+
* @returns True when `mkdirTree` is offered there.
|
|
303
|
+
*/
|
|
304
|
+
mkdirTree_offered(pathStr) {
|
|
305
|
+
return this.provider_get(pathStr).mkdirTree !== undefined;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Makes a folder and any missing parents in one step, where the owning
|
|
309
|
+
* provider can; elsewhere `EROFS`, and `mkdir -p` walks instead.
|
|
310
|
+
*
|
|
311
|
+
* @param pathStr - The absolute path of the folder.
|
|
312
|
+
* @returns Done, or why not.
|
|
313
|
+
*/
|
|
314
|
+
async mkdirTree(pathStr) {
|
|
315
|
+
const provider = this.provider_get(pathStr);
|
|
316
|
+
if (!provider.mkdirTree)
|
|
317
|
+
return (0, outcome_js_1.vfs_fail)('EROFS');
|
|
318
|
+
const at = await this.pathFor_provider(provider, pathStr, 'path', 'mkdir');
|
|
319
|
+
return at.ok ? provider.mkdirTree(at.value) : at;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Removes an empty folder, through the provider that owns it.
|
|
323
|
+
*
|
|
324
|
+
* @param pathStr - The absolute path of the folder.
|
|
325
|
+
* @returns Done, or why not.
|
|
326
|
+
*/
|
|
327
|
+
async rmdir(pathStr) {
|
|
328
|
+
const provider = this.provider_get(pathStr);
|
|
329
|
+
if (!provider.rmdir)
|
|
330
|
+
return (0, outcome_js_1.vfs_fail)('EROFS');
|
|
331
|
+
const at = await this.pathFor_provider(provider, pathStr, 'path', 'rmdir');
|
|
332
|
+
return at.ok ? provider.rmdir(at.value) : at;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Renames within one mount; a rename across mounts answers `EXDEV`.
|
|
336
|
+
*
|
|
337
|
+
* @param src - The absolute path now.
|
|
338
|
+
* @param dest - The absolute path it takes.
|
|
339
|
+
* @returns Done, or why not.
|
|
340
|
+
*/
|
|
341
|
+
async rename(src, dest) {
|
|
342
|
+
const provider = this.provider_get(src);
|
|
343
|
+
if (provider !== this.provider_get(dest))
|
|
344
|
+
return (0, outcome_js_1.vfs_fail)('EXDEV');
|
|
345
|
+
if (!provider.rename)
|
|
346
|
+
return (0, outcome_js_1.vfs_fail)('EROFS');
|
|
347
|
+
const from = await this.pathFor_provider(provider, src, 'source path', 'mv');
|
|
348
|
+
if (!from.ok)
|
|
349
|
+
return from;
|
|
350
|
+
const to = await this.pathFor_provider(provider, dest, 'destination path', 'mv');
|
|
351
|
+
return to.ok ? provider.rename(from.value, to.value) : to;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Removes a file or a link, through the provider that owns it.
|
|
355
|
+
*
|
|
356
|
+
* @param pathStr - The absolute path of the entry.
|
|
357
|
+
* @returns Done, or why not.
|
|
358
|
+
*/
|
|
359
|
+
async rm(pathStr) {
|
|
360
|
+
const provider = this.provider_get(pathStr);
|
|
361
|
+
if (!provider.rm)
|
|
362
|
+
return (0, outcome_js_1.vfs_fail)('EROFS');
|
|
363
|
+
const at = await this.pathFor_provider(provider, pathStr, 'path', 'rm');
|
|
364
|
+
return at.ok ? provider.rm(at.value) : at;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Whether the provider that owns a folder removes it whole in one step.
|
|
368
|
+
*
|
|
369
|
+
* @param pathStr - The absolute path of the folder.
|
|
370
|
+
* @returns True when `rmTree` is offered there.
|
|
371
|
+
*/
|
|
372
|
+
rmTree_offered(pathStr) {
|
|
373
|
+
return this.provider_get(pathStr).rmTree !== undefined;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Removes a folder and everything under it in one step, where the
|
|
377
|
+
* owning provider can; elsewhere `EROFS`, and `rm -r` walks instead.
|
|
378
|
+
*
|
|
379
|
+
* @param pathStr - The absolute path of the folder.
|
|
380
|
+
* @returns Done, or why not.
|
|
381
|
+
*/
|
|
382
|
+
async rmTree(pathStr) {
|
|
383
|
+
const provider = this.provider_get(pathStr);
|
|
384
|
+
if (!provider.rmTree)
|
|
385
|
+
return (0, outcome_js_1.vfs_fail)('EROFS');
|
|
386
|
+
const at = await this.pathFor_provider(provider, pathStr, 'path', 'rm');
|
|
387
|
+
return at.ok ? provider.rmTree(at.value) : at;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Resolves a lazy link through the provider that owns it.
|
|
391
|
+
*
|
|
392
|
+
* This is deliberately distinct from {@link list}: a structural traversal
|
|
393
|
+
* can display an unresolved link without causing its provider to fetch the
|
|
394
|
+
* target from a remote service.
|
|
395
|
+
*
|
|
396
|
+
* @param pathStr - Absolute path of the provider-defined link.
|
|
397
|
+
* @returns The resolved target path, or an error if unsupported or absent.
|
|
398
|
+
*/
|
|
399
|
+
async linkTarget_resolve(pathStr) {
|
|
400
|
+
const provider = this.provider_get(pathStr);
|
|
401
|
+
if (provider.linkTarget_resolve) {
|
|
402
|
+
return provider.linkTarget_resolve(pathStr);
|
|
403
|
+
}
|
|
404
|
+
errorStack_js_1.errorStack.stack_push('error', `Link resolution not supported for path: ${pathStr}`);
|
|
405
|
+
return (0, result_js_1.Err)();
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
exports.VFSDispatcher = VFSDispatcher;
|
|
409
|
+
//# sourceMappingURL=dispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/vfs/dispatcher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,4CAA+C;AAC/C,oDAA8C;AAE9C,6CAAiE;AAEjE;;;GAGG;AACH,MAAM,iBAAiB,GAAgB;IACrC,MAAM,EAAE,EAAE;IACV,KAAK,CAAC,IAAI,CAAC,IAAY;QACrB,0BAAU,CAAC,UAAU,CAAC,OAAO,EAAE,mBAAmB,IAAI,GAAG,CAAC,CAAC;QAC3D,OAAO,IAAA,eAAG,GAAE,CAAC;IACf,CAAC;IACD,KAAK,CAAC,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,EAAE,CAAC;IAChD,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,kBAAkB,CAAC,OAAe;QACtC,MAAM,QAAQ,GAAgB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACzD,IAAI,QAAQ,CAAC,kBAAkB,EAAE,CAAC;YAChC,OAAO,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC9C,CAAC;QACD,0BAAU,CAAC,UAAU,CAAC,OAAO,EAAE,2CAA2C,OAAO,EAAE,CAAC,CAAC;QACrF,OAAO,IAAA,eAAG,GAAE,CAAC;IACf,CAAC;CACF;AAtYD,sCAsYC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders the result of a mkdir operation.
|
|
3
|
+
* @param path - The path created.
|
|
4
|
+
* @param success - Whether the operation succeeded.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mkdir_render(path: string, success: boolean): string;
|
|
7
|
+
/**
|
|
8
|
+
* Renders the result of a touch operation.
|
|
9
|
+
* @param path - The path created.
|
|
10
|
+
* @param success - Whether the operation succeeded.
|
|
11
|
+
* @param wrote - Whether content was written, rather than an empty file made.
|
|
12
|
+
*/
|
|
13
|
+
export declare function touch_render(path: string, success: boolean, wrote?: boolean): string;
|
|
14
|
+
/**
|
|
15
|
+
* Renders the result of a copy operation.
|
|
16
|
+
* @param src - Source path.
|
|
17
|
+
* @param dest - Destination path.
|
|
18
|
+
* @param success - Whether the operation succeeded.
|
|
19
|
+
*/
|
|
20
|
+
export declare function cp_render(src: string, dest: string, success: boolean): string;
|
|
21
|
+
/**
|
|
22
|
+
* Renders the result of a move operation.
|
|
23
|
+
* @param src - Source path.
|
|
24
|
+
* @param dest - Destination path.
|
|
25
|
+
* @param success - Whether the operation succeeded.
|
|
26
|
+
*/
|
|
27
|
+
export declare function mv_render(src: string, dest: string, success: boolean): string;
|
|
28
|
+
/**
|
|
29
|
+
* Renders the outcome of an rm operation for terminal display.
|
|
30
|
+
*
|
|
31
|
+
* @param result - The rm result.
|
|
32
|
+
* @returns Formatted status string.
|
|
33
|
+
*/
|
|
34
|
+
export declare function rm_render(result: {
|
|
35
|
+
success: boolean;
|
|
36
|
+
path: string;
|
|
37
|
+
type: 'file' | 'dir' | 'link' | null;
|
|
38
|
+
error?: string;
|
|
39
|
+
}): string;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mkdir_render = mkdir_render;
|
|
7
|
+
exports.touch_render = touch_render;
|
|
8
|
+
exports.cp_render = cp_render;
|
|
9
|
+
exports.mv_render = mv_render;
|
|
10
|
+
exports.rm_render = rm_render;
|
|
11
|
+
/**
|
|
12
|
+
* @file What the file tools say when they are done: a folder made, a file
|
|
13
|
+
* written, a copy or a move, an entry removed.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
/**
|
|
19
|
+
* Renders the result of a mkdir operation.
|
|
20
|
+
* @param path - The path created.
|
|
21
|
+
* @param success - Whether the operation succeeded.
|
|
22
|
+
*/
|
|
23
|
+
function mkdir_render(path, success) {
|
|
24
|
+
if (success) {
|
|
25
|
+
return chalk_1.default.green(`Created directory: ${path}`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return chalk_1.default.red(`Failed to create directory: ${path}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Renders the result of a touch operation.
|
|
33
|
+
* @param path - The path created.
|
|
34
|
+
* @param success - Whether the operation succeeded.
|
|
35
|
+
* @param wrote - Whether content was written, rather than an empty file made.
|
|
36
|
+
*/
|
|
37
|
+
function touch_render(path, success, wrote = false) {
|
|
38
|
+
if (success) {
|
|
39
|
+
// A touch that carried content WROTE the file, and may have replaced one
|
|
40
|
+
// that was already there: reporting "Created" for a rewrite told the
|
|
41
|
+
// operator a file was new when their old content had just been replaced.
|
|
42
|
+
return chalk_1.default.green(`${wrote ? 'Wrote' : 'Created'} file: ${path}`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return chalk_1.default.red(`Failed to ${wrote ? 'write' : 'create'} file: ${path}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Renders the result of a copy operation.
|
|
50
|
+
* @param src - Source path.
|
|
51
|
+
* @param dest - Destination path.
|
|
52
|
+
* @param success - Whether the operation succeeded.
|
|
53
|
+
*/
|
|
54
|
+
function cp_render(src, dest, success) {
|
|
55
|
+
if (success) {
|
|
56
|
+
return chalk_1.default.green(`Copied ${src} to ${dest}`);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return chalk_1.default.red(`Failed to copy ${src} to ${dest}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Renders the result of a move operation.
|
|
64
|
+
* @param src - Source path.
|
|
65
|
+
* @param dest - Destination path.
|
|
66
|
+
* @param success - Whether the operation succeeded.
|
|
67
|
+
*/
|
|
68
|
+
function mv_render(src, dest, success) {
|
|
69
|
+
if (success) {
|
|
70
|
+
return chalk_1.default.green(`Moved ${src} to ${dest}`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return chalk_1.default.red(`Failed to move ${src} to ${dest}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Renders the outcome of an rm operation for terminal display.
|
|
78
|
+
*
|
|
79
|
+
* @param result - The rm result.
|
|
80
|
+
* @returns Formatted status string.
|
|
81
|
+
*/
|
|
82
|
+
function rm_render(result) {
|
|
83
|
+
if (result.success) {
|
|
84
|
+
const typeStr = result.type || 'item';
|
|
85
|
+
return chalk_1.default.green(`Removed ${typeStr}: ${result.path}`);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return chalk_1.default.red(result.error || `Failed to remove: ${result.path}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=fsViews.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsViews.js","sourceRoot":"","sources":["../../src/vfs/fsViews.ts"],"names":[],"mappings":";;;;;AAaA,oCAMC;AAQD,oCASC;AAQD,8BAMC;AAQD,8BAMC;AAQD,8BAOC;AA/ED;;;;;GAKG;AACH,kDAA0B;AAE1B;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,OAAgB;IACzD,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,eAAK,CAAC,KAAK,CAAC,sBAAsB,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;SAAM,CAAC;QACN,OAAO,eAAK,CAAC,GAAG,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,OAAgB,EAAE,QAAiB,KAAK;IACjF,IAAI,OAAO,EAAE,CAAC;QACZ,yEAAyE;QACzE,qEAAqE;QACrE,yEAAyE;QACzE,OAAO,eAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,UAAU,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,OAAO,eAAK,CAAC,GAAG,CAAC,aAAa,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,UAAU,IAAI,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,GAAW,EAAE,IAAY,EAAE,OAAgB;IACnE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,eAAK,CAAC,KAAK,CAAC,UAAU,GAAG,OAAO,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;SAAM,CAAC;QACN,OAAO,eAAK,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,GAAW,EAAE,IAAY,EAAE,OAAgB;IACnE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,eAAK,CAAC,KAAK,CAAC,SAAS,GAAG,OAAO,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,OAAO,eAAK,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,MAAgG;IACxH,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,OAAO,GAAW,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC;QAC9C,OAAO,eAAK,CAAC,KAAK,CAAC,WAAW,OAAO,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;SAAM,CAAC;QACN,OAAO,eAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,qBAAqB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Result } from '../result.js';
|
|
2
|
+
import type { VFSProvider, VFSItem, CpOptions } from './provider.js';
|
|
3
|
+
import { type VfsOutcome } from './outcome.js';
|
|
4
|
+
/**
|
|
5
|
+
* What to put in a memory filesystem before it is used: each path with the
|
|
6
|
+
* text of its file, or null for a folder. Parents are made as needed.
|
|
7
|
+
*/
|
|
8
|
+
export type MemorySeed = Readonly<Record<string, string | null>>;
|
|
9
|
+
/** A filesystem held in memory, answering every operation the contract names. */
|
|
10
|
+
export declare class MemoryVfsProvider implements VFSProvider {
|
|
11
|
+
/** The prefix it claims; empty for a session's whole filesystem. */
|
|
12
|
+
prefix: string;
|
|
13
|
+
/** Who owns what it holds, as a listing says. */
|
|
14
|
+
private readonly owner;
|
|
15
|
+
/** Every entry, by absolute path; the root always exists. */
|
|
16
|
+
private readonly nodes;
|
|
17
|
+
/**
|
|
18
|
+
* Makes an empty filesystem, or one already holding what the seed names.
|
|
19
|
+
*
|
|
20
|
+
* @param prefix - The prefix it claims (`''` for the whole tree).
|
|
21
|
+
* @param seed - Paths to make first.
|
|
22
|
+
* @param owner - The owner its listings show.
|
|
23
|
+
*/
|
|
24
|
+
constructor(prefix?: string, seed?: MemorySeed, owner?: string);
|
|
25
|
+
/**
|
|
26
|
+
* Puts one seeded entry, making its parents.
|
|
27
|
+
*
|
|
28
|
+
* @param where - The path.
|
|
29
|
+
* @param text - The file's text, or null for a folder.
|
|
30
|
+
*/
|
|
31
|
+
seed_put(where: string, text: string | null): void;
|
|
32
|
+
/** The root of what it holds. */
|
|
33
|
+
private root_get;
|
|
34
|
+
/**
|
|
35
|
+
* A path in the form entries are kept under.
|
|
36
|
+
*
|
|
37
|
+
* @param where - The path asked.
|
|
38
|
+
* @returns It, normalised, without a trailing slash.
|
|
39
|
+
*/
|
|
40
|
+
private key_of;
|
|
41
|
+
/**
|
|
42
|
+
* The entries directly in a folder.
|
|
43
|
+
*
|
|
44
|
+
* @param folder - The folder's key.
|
|
45
|
+
* @returns Their keys.
|
|
46
|
+
*/
|
|
47
|
+
private children_of;
|
|
48
|
+
/**
|
|
49
|
+
* Whether a new entry may be made at a path: its parent is a folder.
|
|
50
|
+
*
|
|
51
|
+
* @param key - The new entry's key.
|
|
52
|
+
* @returns Null when it may, else why not.
|
|
53
|
+
*/
|
|
54
|
+
private parent_check;
|
|
55
|
+
list(where: string): Promise<Result<VFSItem[]>>;
|
|
56
|
+
read(where: string): Promise<VfsOutcome<string>>;
|
|
57
|
+
readBinary(where: string): Promise<VfsOutcome<Buffer>>;
|
|
58
|
+
write(where: string, content: string | Buffer): Promise<VfsOutcome>;
|
|
59
|
+
mkdir(where: string): Promise<VfsOutcome>;
|
|
60
|
+
mkdirTree(where: string): Promise<VfsOutcome>;
|
|
61
|
+
rmdir(where: string): Promise<VfsOutcome>;
|
|
62
|
+
rename(src: string, dest: string): Promise<VfsOutcome>;
|
|
63
|
+
rm(where: string): Promise<VfsOutcome>;
|
|
64
|
+
rmTree(where: string): Promise<VfsOutcome>;
|
|
65
|
+
cp(src: string, dest: string, options: CpOptions): Promise<VfsOutcome>;
|
|
66
|
+
}
|