@volter/tabnode 0.3.0 → 0.4.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/assets/{runtime-worker-BcDCBbhG.js → runtime-worker-DoV8lqBn.js} +202 -61
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +229 -78
- package/dist/node-lib/binding/fs.d.ts +8 -8
- package/dist/server-bridge.d.ts +1 -0
- package/dist/shims/child_process.d.ts +6 -0
- package/dist/virtual-fs.d.ts +3 -0
- package/package.json +1 -1
- package/src/index.ts +6 -1
- package/src/node-lib/binding/fs.ts +66 -48
- package/src/node-lib/binding/handles.ts +27 -1
- package/src/server-bridge.ts +12 -2
- package/src/shims/child_process.ts +58 -4
- package/src/virtual-fs.ts +28 -3
package/src/virtual-fs.ts
CHANGED
|
@@ -35,6 +35,7 @@ export interface FSNode {
|
|
|
35
35
|
target?: string;
|
|
36
36
|
children?: Map<string, FSNode>;
|
|
37
37
|
mtime: number;
|
|
38
|
+
mode?: number;
|
|
38
39
|
/**
|
|
39
40
|
* When the file was last read. Node reports it apart from the write time
|
|
40
41
|
* and `utimes` sets the two separately; this filesystem reported the write
|
|
@@ -45,6 +46,17 @@ export interface FSNode {
|
|
|
45
46
|
atime?: number;
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
// Identity belongs to the node, so writes and renames preserve it while an
|
|
50
|
+
// unlink followed by recreation receives a different inode. Weak keys do not
|
|
51
|
+
// retain deleted trees, and snapshots receive new identities when restored.
|
|
52
|
+
const nodeInodes = new WeakMap<FSNode, number>();
|
|
53
|
+
let nextInode = 1;
|
|
54
|
+
function inodeFor(node: FSNode): number {
|
|
55
|
+
let inode = nodeInodes.get(node);
|
|
56
|
+
if (inode === undefined) { inode = nextInode++; nodeInodes.set(node, inode); }
|
|
57
|
+
return inode;
|
|
58
|
+
}
|
|
59
|
+
|
|
48
60
|
// Simple EventEmitter for VFS change notifications
|
|
49
61
|
type VFSChangeListener = (path: string, content: string) => void;
|
|
50
62
|
type VFSDeleteListener = (path: string) => void;
|
|
@@ -459,6 +471,19 @@ export class VirtualFS {
|
|
|
459
471
|
/**
|
|
460
472
|
* Get stats for path
|
|
461
473
|
*/
|
|
474
|
+
chmodSync(path: string, mode: number): void {
|
|
475
|
+
const node = this.getNode(path);
|
|
476
|
+
if (!node) throw createNodeError('ENOENT', 'chmod', path);
|
|
477
|
+
node.mode = mode & 0o7777;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
utimesSync(path: string, atime: number | Date, mtime: number | Date): void {
|
|
481
|
+
const node = this.getNode(path);
|
|
482
|
+
if (!node) throw createNodeError('ENOENT', 'utimes', path);
|
|
483
|
+
node.atime = atime instanceof Date ? atime.getTime() : atime * 1000;
|
|
484
|
+
node.mtime = mtime instanceof Date ? mtime.getTime() : mtime * 1000;
|
|
485
|
+
}
|
|
486
|
+
|
|
462
487
|
statSync(path: string): Stats {
|
|
463
488
|
const node = this.getNode(path);
|
|
464
489
|
if (!node) {
|
|
@@ -478,7 +503,7 @@ export class VirtualFS {
|
|
|
478
503
|
isFIFO: () => false,
|
|
479
504
|
isSocket: () => false,
|
|
480
505
|
size,
|
|
481
|
-
mode: node.type === 'directory' ? 0o755 : 0o644,
|
|
506
|
+
mode: node.mode ?? (node.type === 'directory' ? 0o755 : 0o644),
|
|
482
507
|
mtime: new Date(mtime),
|
|
483
508
|
atime: new Date(atime),
|
|
484
509
|
ctime: new Date(mtime),
|
|
@@ -491,7 +516,7 @@ export class VirtualFS {
|
|
|
491
516
|
uid: 1000,
|
|
492
517
|
gid: 1000,
|
|
493
518
|
dev: 0,
|
|
494
|
-
ino:
|
|
519
|
+
ino: inodeFor(node),
|
|
495
520
|
rdev: 0,
|
|
496
521
|
blksize: 4096,
|
|
497
522
|
blocks: Math.ceil(size / 512),
|
|
@@ -531,7 +556,7 @@ export class VirtualFS {
|
|
|
531
556
|
uid: 1000,
|
|
532
557
|
gid: 1000,
|
|
533
558
|
dev: 0,
|
|
534
|
-
ino:
|
|
559
|
+
ino: inodeFor(node),
|
|
535
560
|
rdev: 0,
|
|
536
561
|
blksize: 4096,
|
|
537
562
|
blocks: 0
|