@waffle-os/runtime 0.0.147 → 0.0.148
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/browser/filesystem-backend.ts +26 -5
- package/browser/fs-worker.ts +5 -2
- package/browser/shared-fs.ts +93 -10
- package/core/filesystem.ts +2 -0
- package/dist/browser/filesystem-backend.js +19 -2
- package/dist/browser/fs-worker.js +7 -2
- package/dist/browser/shared-fs.js +77 -8
- package/dist/fs/client.js +82 -21
- package/dist/fs/directory-pages.js +22 -7
- package/dist/fs/guest-watch.js +9 -3
- package/dist/fs/idle-database.js +1 -1
- package/dist/fs/idle-owner.js +35 -4
- package/dist/fs/indexeddb.js +322 -63
- package/dist/fs/memory.js +18 -9
- package/dist/fs/multitab-backend.js +5065 -0
- package/dist/fs/multitab-protocol.js +301 -0
- package/dist/fs/opfs.js +21 -0
- package/dist/fs/persistent.js +70 -1
- package/dist/fs/protocol.js +1 -1
- package/dist/fs/service.js +266 -86
- package/dist/fs/shared.js +45 -0
- package/dist/fs/vfs.js +26 -8
- package/dist/fs/watch-ring.js +7 -3
- package/dist/proc/command-stdio.js +56 -1
- package/dist/runtime.js +4 -2
- package/dist/tooling/program/program-transformer.json +1 -1
- package/fs/backend.ts +36 -0
- package/fs/client.ts +81 -19
- package/fs/directory-pages.ts +40 -6
- package/fs/guest-watch.ts +8 -3
- package/fs/idle-database.ts +1 -0
- package/fs/idle-owner.ts +48 -12
- package/fs/indexeddb.ts +396 -78
- package/fs/memory.ts +33 -9
- package/fs/multitab-backend.ts +6870 -0
- package/fs/multitab-protocol.ts +655 -0
- package/fs/opfs.ts +21 -0
- package/fs/persistent.ts +70 -1
- package/fs/protocol.ts +1 -1
- package/fs/service.ts +314 -109
- package/fs/shared.ts +45 -0
- package/fs/storage.ts +3 -0
- package/fs/vfs.ts +44 -15
- package/fs/watch-ring.ts +5 -2
- package/package.json +1 -1
- package/proc/command-stdio.ts +72 -2
- package/runtime.ts +12 -3
- package/tooling/program/program-transformer.json +1 -1
package/fs/memory.ts
CHANGED
|
@@ -355,12 +355,27 @@ export class MemFS implements FileSystem {
|
|
|
355
355
|
if (node) pages.set({ name, ino: node.ino, kind: nodeKind(node) });
|
|
356
356
|
else pages.delete(name);
|
|
357
357
|
}
|
|
358
|
-
readdirPage(
|
|
358
|
+
readdirPage(
|
|
359
|
+
handle: FileHandle,
|
|
360
|
+
cookie: bigint,
|
|
361
|
+
byteLength: number,
|
|
362
|
+
cookieTag?: bigint,
|
|
363
|
+
maxBytes?: number,
|
|
364
|
+
hardCapBytes?: number,
|
|
365
|
+
): Uint8Array {
|
|
359
366
|
checkDirectoryPage(cookie, byteLength);
|
|
360
367
|
const node = this.directory(handle);
|
|
361
368
|
this.require(node, 4);
|
|
362
369
|
const parent = this.directoryParents.get(node) ?? node;
|
|
363
|
-
return this.directoryPages(node).page(
|
|
370
|
+
return this.directoryPages(node).page(
|
|
371
|
+
cookie,
|
|
372
|
+
byteLength,
|
|
373
|
+
node.ino,
|
|
374
|
+
parent.ino,
|
|
375
|
+
cookieTag,
|
|
376
|
+
maxBytes,
|
|
377
|
+
hardCapBytes,
|
|
378
|
+
);
|
|
364
379
|
}
|
|
365
380
|
private linkCounts = new WeakMap<Node, number>();
|
|
366
381
|
|
|
@@ -637,18 +652,23 @@ export class MemFS implements FileSystem {
|
|
|
637
652
|
this.changed(node);
|
|
638
653
|
return 0;
|
|
639
654
|
}
|
|
640
|
-
|
|
655
|
+
forEachDirEntry(handle: FileHandle, visit: (entry: DirectoryEntry) => void): void {
|
|
641
656
|
const node = this.directory(handle);
|
|
642
657
|
this.require(node, 4);
|
|
643
658
|
const parent = this.directoryParents.get(node) ?? node;
|
|
644
|
-
const entry = (name: string,
|
|
659
|
+
const entry = (name: string, item: Node): DirectoryEntry => ({
|
|
645
660
|
name,
|
|
646
|
-
ino:
|
|
647
|
-
kind: nodeKind(
|
|
661
|
+
ino: item.ino,
|
|
662
|
+
kind: nodeKind(item),
|
|
648
663
|
});
|
|
649
|
-
|
|
664
|
+
visit(entry(".", node));
|
|
665
|
+
visit(entry("..", parent));
|
|
666
|
+
for (const [name, child] of node.children) visit(entry(name, child));
|
|
667
|
+
}
|
|
668
|
+
readdir(handle: FileHandle): DirectoryEntry[] {
|
|
669
|
+
const list: DirectoryEntry[] = [];
|
|
650
670
|
// One list per call, not one list per entry or cookie. No file buffers cross the boundary.
|
|
651
|
-
|
|
671
|
+
this.forEachDirEntry(handle, (entry) => list.push(entry));
|
|
652
672
|
return list;
|
|
653
673
|
}
|
|
654
674
|
private parentOf(path: ResolvedPath): DirNode | number {
|
|
@@ -1261,10 +1281,11 @@ export class MemFS implements FileSystem {
|
|
|
1261
1281
|
}
|
|
1262
1282
|
|
|
1263
1283
|
/** Every regular file under `dir`, as absolute paths, sorted. */
|
|
1264
|
-
|
|
1284
|
+
collectBoundedFilePaths(dir = "/", onFile?: (path: string) => void): string[] {
|
|
1265
1285
|
const out: string[] = [];
|
|
1266
1286
|
const walk = (node: Node, path: string) => {
|
|
1267
1287
|
if (node.kind === "file") {
|
|
1288
|
+
onFile?.(path);
|
|
1268
1289
|
out.push(path);
|
|
1269
1290
|
return;
|
|
1270
1291
|
}
|
|
@@ -1281,6 +1302,9 @@ export class MemFS implements FileSystem {
|
|
|
1281
1302
|
if (start.node !== undefined) walk(this.nodeForHandle(start.node), start.canonicalPath);
|
|
1282
1303
|
return out.sort();
|
|
1283
1304
|
}
|
|
1305
|
+
listFiles(dir = "/"): string[] {
|
|
1306
|
+
return this.collectBoundedFilePaths(dir);
|
|
1307
|
+
}
|
|
1284
1308
|
}
|
|
1285
1309
|
|
|
1286
1310
|
/** Grow a file's buffer geometrically so many small writes stay linear. */
|