1
1
import * as fs from "fs" ;
2
2
import { callbackify } from "util" ;
3
- import { ClientProxy , Batch } from "../../common/proxy" ;
3
+ import { Batch , ClientProxy , Module } from "../../common/proxy" ;
4
4
import { IEncodingOptions , IEncodingOptionsCallback } from "../../common/util" ;
5
5
import { FsModuleProxy , ReadStreamProxy , Stats as IStats , WatcherProxy , WriteStreamProxy } from "../../node/modules/fs" ;
6
6
import { Readable , Writable } from "./stream" ;
@@ -38,7 +38,11 @@ class ReaddirBatch extends Batch<Buffer[] | fs.Dirent[] | string[], { path: fs.P
38
38
}
39
39
}
40
40
41
- class Watcher extends ClientProxy < WatcherProxy > implements fs . FSWatcher {
41
+ interface ClientWatcherProxy extends WatcherProxy {
42
+ proxyId : number | Module ;
43
+ }
44
+
45
+ class Watcher extends ClientProxy < ClientWatcherProxy > implements fs . FSWatcher {
42
46
public close ( ) : void {
43
47
this . catch ( this . proxy . close ( ) ) ;
44
48
}
@@ -48,7 +52,11 @@ class Watcher extends ClientProxy<WatcherProxy> implements fs.FSWatcher {
48
52
}
49
53
}
50
54
51
- class ReadStream extends Readable < ReadStreamProxy > implements fs . ReadStream {
55
+ interface ClientReadStreamProxy extends ReadStreamProxy {
56
+ proxyId : number | Module ;
57
+ }
58
+
59
+ class ReadStream extends Readable < ClientReadStreamProxy > implements fs . ReadStream {
52
60
public get bytesRead ( ) : number {
53
61
throw new Error ( "not implemented" ) ;
54
62
}
@@ -62,7 +70,11 @@ class ReadStream extends Readable<ReadStreamProxy> implements fs.ReadStream {
62
70
}
63
71
}
64
72
65
- class WriteStream extends Writable < WriteStreamProxy > implements fs . WriteStream {
73
+ interface ClientWriteStreamProxy extends WriteStreamProxy {
74
+ proxyId : number | Module ;
75
+ }
76
+
77
+ class WriteStream extends Writable < ClientWriteStreamProxy > implements fs . WriteStream {
66
78
public get bytesWritten ( ) : number {
67
79
throw new Error ( "not implemented" ) ;
68
80
}
@@ -76,12 +88,19 @@ class WriteStream extends Writable<WriteStreamProxy> implements fs.WriteStream {
76
88
}
77
89
}
78
90
91
+ interface ClientFsModuleProxy extends FsModuleProxy {
92
+ proxyId : number | Module ;
93
+ createReadStream ( path : fs . PathLike , options ?: any ) : Promise < ClientReadStreamProxy > ;
94
+ createWriteStream ( path : fs . PathLike , options ?: any ) : Promise < ClientWriteStreamProxy > ;
95
+ watch ( filename : fs . PathLike , options ?: IEncodingOptions ) : Promise < ClientWatcherProxy > ;
96
+ }
97
+
79
98
export class FsModule {
80
99
private readonly statBatch : StatBatch ;
81
100
private readonly lstatBatch : LstatBatch ;
82
101
private readonly readdirBatch : ReaddirBatch ;
83
102
84
- public constructor ( private readonly proxy : FsModuleProxy ) {
103
+ public constructor ( private readonly proxy : ClientFsModuleProxy ) {
85
104
this . statBatch = new StatBatch ( this . proxy ) ;
86
105
this . lstatBatch = new LstatBatch ( this . proxy ) ;
87
106
this . readdirBatch = new ReaddirBatch ( this . proxy ) ;
0 commit comments