@scrypted/server 0.123.57 → 0.123.58
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.
@@ -10,12 +10,9 @@ export declare class HttpResponseImpl implements HttpResponse {
|
|
10
10
|
constructor(res: Response, unzippedDir: string, filesPath: string);
|
11
11
|
[RpcPeer.PROPERTY_PROXY_ONEWAY_METHODS]: string[];
|
12
12
|
sent: boolean;
|
13
|
-
send(body: string): void;
|
14
|
-
|
15
|
-
send(body: Buffer): void;
|
16
|
-
send(body: Buffer, options: HttpResponseOptions): void;
|
17
|
-
sendFile(path: string): void;
|
18
|
-
sendFile(path: string, options: HttpResponseOptions): void;
|
13
|
+
send(body: string | Buffer, options?: any): void;
|
14
|
+
sendFile(path: string, options?: HttpResponseOptions): void;
|
19
15
|
sendSocket(socket: net.Socket, options: HttpResponseOptions): void;
|
16
|
+
sendStream(stream: AsyncGenerator<Buffer, void>, options?: HttpResponseOptions): void;
|
20
17
|
}
|
21
18
|
export declare function createResponseInterface(res: Response, unzippedDir: string, filesPath: string): HttpResponseImpl;
|
package/dist/http-interfaces.js
CHANGED
@@ -16,6 +16,9 @@ class HttpResponseImpl {
|
|
16
16
|
this.res = res;
|
17
17
|
this.unzippedDir = unzippedDir;
|
18
18
|
this.filesPath = filesPath;
|
19
|
+
res.on('error', e => {
|
20
|
+
console.warn("Error while sending response from plugin", e);
|
21
|
+
});
|
19
22
|
}
|
20
23
|
[rpc_1.RpcPeer.PROPERTY_PROXY_ONEWAY_METHODS] = [
|
21
24
|
'send',
|
@@ -69,6 +72,23 @@ class HttpResponseImpl {
|
|
69
72
|
this.#setHeaders(options);
|
70
73
|
socket.pipe(this.res);
|
71
74
|
}
|
75
|
+
sendStream(stream, options) {
|
76
|
+
this.sent = true;
|
77
|
+
if (options?.code)
|
78
|
+
this.res.status(options.code);
|
79
|
+
this.#setHeaders(options);
|
80
|
+
(async () => {
|
81
|
+
try {
|
82
|
+
for await (const chunk of stream) {
|
83
|
+
this.res.write(chunk);
|
84
|
+
}
|
85
|
+
this.res.end();
|
86
|
+
}
|
87
|
+
catch (e) {
|
88
|
+
this.res.destroy(e);
|
89
|
+
}
|
90
|
+
})();
|
91
|
+
}
|
72
92
|
}
|
73
93
|
exports.HttpResponseImpl = HttpResponseImpl;
|
74
94
|
function createResponseInterface(res, unzippedDir, filesPath) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"http-interfaces.js","sourceRoot":"","sources":["../src/http-interfaces.ts"],"names":[],"mappings":";;;;;;
|
1
|
+
{"version":3,"file":"http-interfaces.js","sourceRoot":"","sources":["../src/http-interfaces.ts"],"names":[],"mappings":";;;;;;AA6FA,0DAEC;AA7FD,4CAAoB;AAEpB,+BAAwC;AACxC,+BAAgC;AAEhC,MAAa,gBAAgB;IACN;IAAsB;IAA4B;IAArE,YAAmB,GAAa,EAAS,WAAmB,EAAS,SAAiB;QAAnE,QAAG,GAAH,GAAG,CAAU;QAAS,gBAAW,GAAX,WAAW,CAAQ;QAAS,cAAS,GAAT,SAAS,CAAQ;QAClF,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YAChB,OAAO,CAAC,IAAI,CAAC,0CAA0C,EAAE,CAAC,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACP,CAAC;IAED,CAAC,aAAO,CAAC,6BAA6B,CAAC,GAAG;QACtC,MAAM;QACN,UAAU;QACV,YAAY;KACf,CAAC;IACF,IAAI,GAAG,KAAK,CAAC;IAEb,WAAW,CAAC,OAA6B;QACrC,IAAI,CAAC,OAAO,EAAE,OAAO;YACjB,OAAO;QACX,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAChD,MAAM,GAAG,GAAI,OAAO,CAAC,OAAe,CAAC,MAAM,CAAC,CAAC;YAC7C,4DAA4D;YAC5D,IAAI,GAAG,IAAI,IAAI;gBACX,IAAI,CAAC,G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",
|
3
|
-
"version": "0.123.
|
3
|
+
"version": "0.123.58",
|
4
4
|
"description": "",
|
5
5
|
"dependencies": {
|
6
6
|
"@scrypted/ffmpeg-static": "^6.1.0-build3",
|
7
7
|
"@scrypted/node-pty": "^1.0.22",
|
8
|
-
"@scrypted/types": "^0.3.
|
8
|
+
"@scrypted/types": "^0.3.92",
|
9
9
|
"adm-zip": "^0.5.16",
|
10
10
|
"body-parser": "^1.20.3",
|
11
11
|
"cookie-parser": "^1.4.7",
|
package/src/http-interfaces.ts
CHANGED
@@ -7,6 +7,9 @@ import { RpcPeer } from "./rpc";
|
|
7
7
|
|
8
8
|
export class HttpResponseImpl implements HttpResponse {
|
9
9
|
constructor(public res: Response, public unzippedDir: string, public filesPath: string) {
|
10
|
+
res.on('error', e => {
|
11
|
+
console.warn("Error while sending response from plugin", e);
|
12
|
+
});
|
10
13
|
}
|
11
14
|
|
12
15
|
[RpcPeer.PROPERTY_PROXY_ONEWAY_METHODS] = [
|
@@ -27,11 +30,7 @@ export class HttpResponseImpl implements HttpResponse {
|
|
27
30
|
}
|
28
31
|
}
|
29
32
|
|
30
|
-
send(body: string)
|
31
|
-
send(body: string, options: HttpResponseOptions): void;
|
32
|
-
send(body: Buffer): void;
|
33
|
-
send(body: Buffer, options: HttpResponseOptions): void;
|
34
|
-
send(body: any, options?: any) {
|
33
|
+
send(body: string|Buffer, options?: any) {
|
35
34
|
this.sent = true;
|
36
35
|
if (options?.code)
|
37
36
|
this.res.status(options.code);
|
@@ -40,9 +39,7 @@ export class HttpResponseImpl implements HttpResponse {
|
|
40
39
|
this.res.send(body);
|
41
40
|
}
|
42
41
|
|
43
|
-
sendFile(path: string)
|
44
|
-
sendFile(path: string, options: HttpResponseOptions): void;
|
45
|
-
sendFile(path: any, options?: HttpResponseOptions) {
|
42
|
+
sendFile(path: string, options?: HttpResponseOptions) {
|
46
43
|
this.sent = true;
|
47
44
|
if (options?.code)
|
48
45
|
this.res.status(options.code);
|
@@ -74,6 +71,24 @@ export class HttpResponseImpl implements HttpResponse {
|
|
74
71
|
this.#setHeaders(options);
|
75
72
|
socket.pipe(this.res);
|
76
73
|
}
|
74
|
+
|
75
|
+
sendStream(stream: AsyncGenerator<Buffer, void>, options?: HttpResponseOptions): void {
|
76
|
+
this.sent = true;
|
77
|
+
if (options?.code)
|
78
|
+
this.res.status(options.code);
|
79
|
+
this.#setHeaders(options);
|
80
|
+
(async() => {
|
81
|
+
try {
|
82
|
+
for await (const chunk of stream) {
|
83
|
+
this.res.write(chunk);
|
84
|
+
}
|
85
|
+
this.res.end();
|
86
|
+
}
|
87
|
+
catch (e) {
|
88
|
+
this.res.destroy(e);
|
89
|
+
}
|
90
|
+
})();
|
91
|
+
}
|
77
92
|
}
|
78
93
|
|
79
94
|
export function createResponseInterface(res: Response, unzippedDir: string, filesPath: string): HttpResponseImpl {
|