@nmtjs/protocol 0.15.0-beta.34 → 0.15.0-beta.35
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/server/stream.d.ts +3 -0
- package/dist/server/stream.js +20 -1
- package/dist/server/stream.js.map +1 -1
- package/package.json +9 -9
- package/src/server/stream.ts +22 -1
package/dist/server/stream.d.ts
CHANGED
|
@@ -9,7 +9,10 @@ export declare class ProtocolClientStream extends PassThrough {
|
|
|
9
9
|
_read(size: number): void;
|
|
10
10
|
}
|
|
11
11
|
export declare class ProtocolServerStream extends PassThrough {
|
|
12
|
+
#private;
|
|
12
13
|
readonly id: number;
|
|
13
14
|
readonly metadata: ProtocolBlobMetadata;
|
|
14
15
|
constructor(id: number, blob: ProtocolBlob);
|
|
16
|
+
resume(): this;
|
|
17
|
+
destroy(error?: Error | null): this;
|
|
15
18
|
}
|
package/dist/server/stream.js
CHANGED
|
@@ -21,6 +21,8 @@ export class ProtocolClientStream extends PassThrough {
|
|
|
21
21
|
export class ProtocolServerStream extends PassThrough {
|
|
22
22
|
id;
|
|
23
23
|
metadata;
|
|
24
|
+
#source;
|
|
25
|
+
#piped = false;
|
|
24
26
|
constructor(id, blob) {
|
|
25
27
|
let readable;
|
|
26
28
|
if (blob.source instanceof Readable) {
|
|
@@ -34,9 +36,26 @@ export class ProtocolServerStream extends PassThrough {
|
|
|
34
36
|
}
|
|
35
37
|
super();
|
|
36
38
|
this.pause();
|
|
37
|
-
readable
|
|
39
|
+
this.#source = readable;
|
|
40
|
+
this.#source.on('error', (error) => {
|
|
41
|
+
this.destroy(error);
|
|
42
|
+
});
|
|
38
43
|
this.id = id;
|
|
39
44
|
this.metadata = blob.metadata;
|
|
40
45
|
}
|
|
46
|
+
resume() {
|
|
47
|
+
if (!this.#piped) {
|
|
48
|
+
this.#piped = true;
|
|
49
|
+
this.#source.pipe(this);
|
|
50
|
+
}
|
|
51
|
+
return super.resume();
|
|
52
|
+
}
|
|
53
|
+
destroy(error) {
|
|
54
|
+
if (!this.#piped) {
|
|
55
|
+
this.#piped = true;
|
|
56
|
+
}
|
|
57
|
+
this.#source.destroy?.(error ?? undefined);
|
|
58
|
+
return super.destroy(error ?? undefined);
|
|
59
|
+
}
|
|
41
60
|
}
|
|
42
61
|
//# sourceMappingURL=stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/server/stream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAIhD,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IAIjC,EAAE;IACF,QAAQ;IAJjB,KAAK,CAA0B;IAExC,YACkB,EAAU,EACV,QAA8B,EAC9C,OAAyB,EACzB;QACA,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QACvC,KAAK,CAAC,IAAI,CAAC,CAAA;kBALK,EAAE;wBACF,QAAQ;QAKxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IAAA,CAClB;IAEQ,KAAK,CAAC,IAAY,EAAQ;QACjC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC7B,CAAC;QACD,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAAA,CAClB;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnC,EAAE,CAAQ;IACV,QAAQ,CAAsB;
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/server/stream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAA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AAC,KAAK,EAAE,EAAE,CAAC;YAClC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAAA,CACpB,CAAC,CAAA;QAEF,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAAA,CAC9B;IAEQ,MAAM,GAAS;QACtB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;YAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,EAAE,CAAA;IAAA,CACtB;IAEQ,OAAO,CAAC,KAAoB,EAAE;QACrC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACpB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,SAAS,CAAC,CAAA;QAC1C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,SAAS,CAAC,CAAA;IAAA,CACzC;CACF"}
|
package/package.json
CHANGED
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"hookable": "6.0.0-rc.1",
|
|
11
|
-
"@nmtjs/common": "0.15.0-beta.
|
|
12
|
-
"@nmtjs/
|
|
13
|
-
"@nmtjs/
|
|
11
|
+
"@nmtjs/common": "0.15.0-beta.35",
|
|
12
|
+
"@nmtjs/contract": "0.15.0-beta.35",
|
|
13
|
+
"@nmtjs/type": "0.15.0-beta.35"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@nmtjs/core": "0.15.0-beta.
|
|
16
|
+
"@nmtjs/core": "0.15.0-beta.35"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@nmtjs/
|
|
20
|
-
"@nmtjs/
|
|
21
|
-
"@nmtjs/
|
|
22
|
-
"@nmtjs/
|
|
19
|
+
"@nmtjs/core": "0.15.0-beta.35",
|
|
20
|
+
"@nmtjs/type": "0.15.0-beta.35",
|
|
21
|
+
"@nmtjs/contract": "0.15.0-beta.35",
|
|
22
|
+
"@nmtjs/common": "0.15.0-beta.35"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"LICENSE.md",
|
|
28
28
|
"README.md"
|
|
29
29
|
],
|
|
30
|
-
"version": "0.15.0-beta.
|
|
30
|
+
"version": "0.15.0-beta.35",
|
|
31
31
|
"scripts": {
|
|
32
32
|
"clean-build": "rm -rf ./dist"
|
|
33
33
|
}
|
package/src/server/stream.ts
CHANGED
|
@@ -28,6 +28,8 @@ export class ProtocolClientStream extends PassThrough {
|
|
|
28
28
|
export class ProtocolServerStream extends PassThrough {
|
|
29
29
|
public readonly id: number
|
|
30
30
|
public readonly metadata: ProtocolBlobMetadata
|
|
31
|
+
readonly #source: Readable
|
|
32
|
+
#piped = false
|
|
31
33
|
|
|
32
34
|
constructor(id: number, blob: ProtocolBlob) {
|
|
33
35
|
let readable: Readable
|
|
@@ -43,9 +45,28 @@ export class ProtocolServerStream extends PassThrough {
|
|
|
43
45
|
super()
|
|
44
46
|
|
|
45
47
|
this.pause()
|
|
46
|
-
readable
|
|
48
|
+
this.#source = readable
|
|
49
|
+
this.#source.on('error', (error) => {
|
|
50
|
+
this.destroy(error)
|
|
51
|
+
})
|
|
47
52
|
|
|
48
53
|
this.id = id
|
|
49
54
|
this.metadata = blob.metadata
|
|
50
55
|
}
|
|
56
|
+
|
|
57
|
+
override resume(): this {
|
|
58
|
+
if (!this.#piped) {
|
|
59
|
+
this.#piped = true
|
|
60
|
+
this.#source.pipe(this)
|
|
61
|
+
}
|
|
62
|
+
return super.resume()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override destroy(error?: Error | null) {
|
|
66
|
+
if (!this.#piped) {
|
|
67
|
+
this.#piped = true
|
|
68
|
+
}
|
|
69
|
+
this.#source.destroy?.(error ?? undefined)
|
|
70
|
+
return super.destroy(error ?? undefined)
|
|
71
|
+
}
|
|
51
72
|
}
|