@effect/platform-node-shared 4.0.0-beta.66 → 4.0.0-beta.67
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/NodeChildProcessSpawner.d.ts +3 -3
- package/dist/NodeChildProcessSpawner.js +2 -2
- package/dist/NodeClusterSocket.d.ts +8 -2
- package/dist/NodeClusterSocket.d.ts.map +1 -1
- package/dist/NodeClusterSocket.js +27 -3
- package/dist/NodeClusterSocket.js.map +1 -1
- package/dist/NodeFileSystem.d.ts +4 -1
- package/dist/NodeFileSystem.d.ts.map +1 -1
- package/dist/NodeFileSystem.js +23 -2
- package/dist/NodeFileSystem.js.map +1 -1
- package/dist/NodePath.d.ts +12 -3
- package/dist/NodePath.d.ts.map +1 -1
- package/dist/NodePath.js +27 -4
- package/dist/NodePath.js.map +1 -1
- package/dist/NodeRuntime.d.ts +33 -4
- package/dist/NodeRuntime.d.ts.map +1 -1
- package/dist/NodeRuntime.js +5 -1
- package/dist/NodeRuntime.js.map +1 -1
- package/dist/NodeSink.d.ts +33 -4
- package/dist/NodeSink.d.ts.map +1 -1
- package/dist/NodeSink.js +15 -3
- package/dist/NodeSink.js.map +1 -1
- package/dist/NodeSocket.d.ts +38 -7
- package/dist/NodeSocket.d.ts.map +1 -1
- package/dist/NodeSocket.js +23 -6
- package/dist/NodeSocket.js.map +1 -1
- package/dist/NodeSocketServer.d.ts +22 -5
- package/dist/NodeSocketServer.d.ts.map +1 -1
- package/dist/NodeSocketServer.js +22 -5
- package/dist/NodeSocketServer.js.map +1 -1
- package/dist/NodeStdio.d.ts +5 -1
- package/dist/NodeStdio.d.ts.map +1 -1
- package/dist/NodeStdio.js +22 -2
- package/dist/NodeStdio.js.map +1 -1
- package/dist/NodeStream.d.ts +79 -15
- package/dist/NodeStream.d.ts.map +1 -1
- package/dist/NodeStream.js +63 -11
- package/dist/NodeStream.js.map +1 -1
- package/dist/NodeTerminal.d.ts +9 -2
- package/dist/NodeTerminal.d.ts.map +1 -1
- package/dist/NodeTerminal.js +11 -2
- package/dist/NodeTerminal.js.map +1 -1
- package/package.json +5 -5
- package/src/NodeChildProcessSpawner.ts +3 -3
- package/src/NodeClusterSocket.ts +27 -3
- package/src/NodeFileSystem.ts +23 -2
- package/src/NodePath.ts +27 -4
- package/src/NodeRuntime.ts +33 -4
- package/src/NodeSink.ts +33 -4
- package/src/NodeSocket.ts +38 -7
- package/src/NodeSocketServer.ts +40 -6
- package/src/NodeStdio.ts +22 -2
- package/src/NodeStream.ts +79 -15
- package/src/NodeTerminal.ts +29 -3
package/dist/NodeSocket.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Shared Node socket constructors for adapting `node:net` connections and
|
|
3
|
+
* other Node `Duplex` streams to Effect's `Socket.Socket` interface.
|
|
4
|
+
*
|
|
5
|
+
* Use this module when building TCP clients, Unix domain socket clients, or
|
|
6
|
+
* higher-level protocols that already expose a Node `Duplex`. Connections are
|
|
7
|
+
* scoped, so finalizers close or destroy the underlying stream, open timeouts
|
|
8
|
+
* are reported as socket open errors, and Node read, write, and close events
|
|
9
|
+
* are translated into `SocketError` values.
|
|
10
|
+
*
|
|
11
|
+
* Node sockets have a few operational details worth keeping in mind: Unix
|
|
12
|
+
* socket paths are supplied through `NetConnectOpts.path`, writes complete only
|
|
13
|
+
* after Node accepts or flushes the chunk, and abnormal close events are
|
|
14
|
+
* surfaced as close errors while normal remote ends complete the socket run.
|
|
15
|
+
*
|
|
16
|
+
* @since 4.0.0
|
|
3
17
|
*/
|
|
4
18
|
import type { Array } from "effect";
|
|
5
19
|
import * as Channel from "effect/Channel";
|
|
@@ -12,39 +26,56 @@ import * as Socket from "effect/unstable/socket/Socket";
|
|
|
12
26
|
import * as Net from "node:net";
|
|
13
27
|
import type { Duplex } from "node:stream";
|
|
14
28
|
/**
|
|
15
|
-
* @since 1.0.0
|
|
16
29
|
* @category re-exports
|
|
30
|
+
* @since 4.0.0
|
|
17
31
|
*/
|
|
18
32
|
export * as NodeWS from "ws";
|
|
19
33
|
declare const NetSocket_base: Context.ServiceClass<NetSocket, "@effect/platform-node/NodeSocket/NetSocket", Net.Socket>;
|
|
20
34
|
/**
|
|
21
|
-
*
|
|
35
|
+
* Service tag for the underlying Node `net.Socket` associated with the current
|
|
36
|
+
* socket connection.
|
|
37
|
+
*
|
|
22
38
|
* @category tags
|
|
39
|
+
* @since 4.0.0
|
|
23
40
|
*/
|
|
24
41
|
export declare class NetSocket extends NetSocket_base {
|
|
25
42
|
}
|
|
26
43
|
/**
|
|
27
|
-
*
|
|
44
|
+
* Opens a TCP connection with Node `net.createConnection` and exposes it as a
|
|
45
|
+
* `Socket.Socket`, supporting `openTimeout` and closing or destroying the
|
|
46
|
+
* socket when the enclosing scope is finalized.
|
|
47
|
+
*
|
|
28
48
|
* @category constructors
|
|
49
|
+
* @since 4.0.0
|
|
29
50
|
*/
|
|
30
51
|
export declare const makeNet: (options: Net.NetConnectOpts & {
|
|
31
52
|
readonly openTimeout?: Duration.Input | undefined;
|
|
32
53
|
}) => Effect.Effect<Socket.Socket>;
|
|
33
54
|
/**
|
|
34
|
-
*
|
|
55
|
+
* Adapts a Node `Duplex` into a `Socket.Socket`, wiring data events to socket
|
|
56
|
+
* handlers, providing a scoped writer, and mapping open, read, write, and close
|
|
57
|
+
* failures to `SocketError`.
|
|
58
|
+
*
|
|
35
59
|
* @category constructors
|
|
60
|
+
* @since 4.0.0
|
|
36
61
|
*/
|
|
37
62
|
export declare const fromDuplex: <RO>(open: Effect.Effect<Duplex, Socket.SocketError, RO>, options?: {
|
|
38
63
|
readonly openTimeout?: Duration.Input | undefined;
|
|
39
64
|
}) => Effect.Effect<Socket.Socket, never, Exclude<RO, Scope.Scope>>;
|
|
40
65
|
/**
|
|
41
|
-
*
|
|
66
|
+
* Creates a `Channel` over a TCP socket, reading arrays of `Uint8Array`
|
|
67
|
+
* chunks and writing arrays of bytes, strings, or socket close events.
|
|
68
|
+
*
|
|
42
69
|
* @category constructors
|
|
70
|
+
* @since 4.0.0
|
|
43
71
|
*/
|
|
44
72
|
export declare const makeNetChannel: <IE = never>(options: Net.NetConnectOpts) => Channel.Channel<Array.NonEmptyReadonlyArray<Uint8Array>, Socket.SocketError | IE, void, Array.NonEmptyReadonlyArray<Uint8Array | string | Socket.CloseEvent>, IE>;
|
|
45
73
|
/**
|
|
46
|
-
*
|
|
74
|
+
* Provides a `Socket.Socket` by opening a TCP connection with the supplied
|
|
75
|
+
* Node `net` connection options.
|
|
76
|
+
*
|
|
47
77
|
* @category layers
|
|
78
|
+
* @since 4.0.0
|
|
48
79
|
*/
|
|
49
80
|
export declare const layerNet: (options: Net.NetConnectOpts) => Layer.Layer<Socket.Socket, Socket.SocketError>;
|
|
50
81
|
//# sourceMappingURL=NodeSocket.d.ts.map
|
package/dist/NodeSocket.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeSocket.d.ts","sourceRoot":"","sources":["../src/NodeSocket.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"NodeSocket.d.ts","sourceRoot":"","sources":["../src/NodeSocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAKvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAA;AACvD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAA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11,18 +11,25 @@ import * as Scope from "effect/Scope";
|
|
|
11
11
|
import * as Socket from "effect/unstable/socket/Socket";
|
|
12
12
|
import * as Net from "node:net";
|
|
13
13
|
/**
|
|
14
|
-
* @since 1.0.0
|
|
15
14
|
* @category re-exports
|
|
15
|
+
* @since 4.0.0
|
|
16
16
|
*/
|
|
17
17
|
export * as NodeWS from "ws";
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Service tag for the underlying Node `net.Socket` associated with the current
|
|
20
|
+
* socket connection.
|
|
21
|
+
*
|
|
20
22
|
* @category tags
|
|
23
|
+
* @since 4.0.0
|
|
21
24
|
*/
|
|
22
25
|
export class NetSocket extends /*#__PURE__*/Context.Service()("@effect/platform-node/NodeSocket/NetSocket") {}
|
|
23
26
|
/**
|
|
24
|
-
*
|
|
27
|
+
* Opens a TCP connection with Node `net.createConnection` and exposes it as a
|
|
28
|
+
* `Socket.Socket`, supporting `openTimeout` and closing or destroying the
|
|
29
|
+
* socket when the enclosing scope is finalized.
|
|
30
|
+
*
|
|
25
31
|
* @category constructors
|
|
32
|
+
* @since 4.0.0
|
|
26
33
|
*/
|
|
27
34
|
export const makeNet = options => fromDuplex(Effect.contextWith(context => {
|
|
28
35
|
let conn;
|
|
@@ -52,8 +59,12 @@ export const makeNet = options => fromDuplex(Effect.contextWith(context => {
|
|
|
52
59
|
}));
|
|
53
60
|
}), options);
|
|
54
61
|
/**
|
|
55
|
-
*
|
|
62
|
+
* Adapts a Node `Duplex` into a `Socket.Socket`, wiring data events to socket
|
|
63
|
+
* handlers, providing a scoped writer, and mapping open, read, write, and close
|
|
64
|
+
* failures to `SocketError`.
|
|
65
|
+
*
|
|
56
66
|
* @category constructors
|
|
67
|
+
* @since 4.0.0
|
|
57
68
|
*/
|
|
58
69
|
export const fromDuplex = (open, options) => Effect.withFiber(fiber => {
|
|
59
70
|
let currentSocket;
|
|
@@ -141,13 +152,19 @@ export const fromDuplex = (open, options) => Effect.withFiber(fiber => {
|
|
|
141
152
|
}));
|
|
142
153
|
});
|
|
143
154
|
/**
|
|
144
|
-
*
|
|
155
|
+
* Creates a `Channel` over a TCP socket, reading arrays of `Uint8Array`
|
|
156
|
+
* chunks and writing arrays of bytes, strings, or socket close events.
|
|
157
|
+
*
|
|
145
158
|
* @category constructors
|
|
159
|
+
* @since 4.0.0
|
|
146
160
|
*/
|
|
147
161
|
export const makeNetChannel = options => Channel.unwrap(Effect.map(makeNet(options), Socket.toChannelWith()));
|
|
148
162
|
/**
|
|
149
|
-
*
|
|
163
|
+
* Provides a `Socket.Socket` by opening a TCP connection with the supplied
|
|
164
|
+
* Node `net` connection options.
|
|
165
|
+
*
|
|
150
166
|
* @category layers
|
|
167
|
+
* @since 4.0.0
|
|
151
168
|
*/
|
|
152
169
|
export const layerNet = /*#__PURE__*/Function.flow(makeNet, /*#__PURE__*/Layer.effect(Socket.Socket));
|
|
153
170
|
//# sourceMappingURL=NodeSocket.js.map
|
package/dist/NodeSocket.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeSocket.js","names":["Channel","Context","Deferred","Effect","FiberSet","Function","identity","Latch","Layer","Scope","Socket","Net","NodeWS","NetSocket","Service","makeNet","options","fromDuplex","contextWith","context","conn","flatMap","addFinalizer","get","sync","closed","destroySoon","destroy","callback","resume","createConnection","once","succeed","on","cause","fail","SocketError","reason","SocketOpenError","kind","open","withFiber","fiber","currentSocket","latch","makeUnsafe","openServices","run","handler","opts","scopedWith","fnUntraced","scope","fiberSet","make","pipe","provide","undefined","off","onData","onEnd","onError","onClose","openTimeout","timeoutOrElse","duration","orElse","Error","provideService","runtime","openUnsafe","onOpen","join","chunk","result","isEffect","doneUnsafe","deferred","void","SocketReadError","hadError","SocketCloseError","code","updateContext","input","merge","onExit","closeUnsafe","write","whenOpen","isCloseEvent","SocketWriteError","writer","acquireRelease","writableEnded","end","runRaw","makeNetChannel","unwrap","map","toChannelWith","layerNet","flow","effect"],"sources":["../src/NodeSocket.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeSocket.js","names":["Channel","Context","Deferred","Effect","FiberSet","Function","identity","Latch","Layer","Scope","Socket","Net","NodeWS","NetSocket","Service","makeNet","options","fromDuplex","contextWith","context","conn","flatMap","addFinalizer","get","sync","closed","destroySoon","destroy","callback","resume","createConnection","once","succeed","on","cause","fail","SocketError","reason","SocketOpenError","kind","open","withFiber","fiber","currentSocket","latch","makeUnsafe","openServices","run","handler","opts","scopedWith","fnUntraced","scope","fiberSet","make","pipe","provide","undefined","off","onData","onEnd","onError","onClose","openTimeout","timeoutOrElse","duration","orElse","Error","provideService","runtime","openUnsafe","onOpen","join","chunk","result","isEffect","doneUnsafe","deferred","void","SocketReadError","hadError","SocketCloseError","code","updateContext","input","merge","onExit","closeUnsafe","write","whenOpen","isCloseEvent","SocketWriteError","writer","acquireRelease","writableEnded","end","runRaw","makeNetChannel","unwrap","map","toChannelWith","layerNet","flow","effect"],"sources":["../src/NodeSocket.ts"],"sourcesContent":[null],"mappings":"AAkBA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAE3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,+BAA+B;AACvD,OAAO,KAAKC,GAAG,MAAM,UAAU;AAG/B;;;;AAIA,OAAO,KAAKC,MAAM,MAAM,IAAI;AAE5B;;;;;;;AAOA,OAAM,MAAOC,SAAU,sBAAQZ,OAAO,CAACa,OAAO,EAAyB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gBAAgB,CAAC;UAAEzD,KAAK,EAAEA;QAAM,CAAE;OACtD,CAAC,CACH,GACC/B,MAAM,CAAC2E,IAAI,CAChB;IACH,CAAC,CAAC;EACJ,CAAC,CAAC,CAAC;EAEL,MAAMc,MAAM,GAAGzF,MAAM,CAAC0F,cAAc,CAClC1F,MAAM,CAAC6B,OAAO,CAACwD,KAAK,CAAC,EACrB,MACErF,MAAM,CAACqB,IAAI,CAAC,MAAK;IACf,IAAI,CAACmB,aAAa,IAAIA,aAAa,CAACmD,aAAa,EAAE;IACnDnD,aAAa,CAACoD,GAAG,EAAE;EACrB,CAAC,CAAC,CACL;EAED,OAAO5F,MAAM,CAAC6B,OAAO,CAACtB,MAAM,CAAC4C,IAAI,CAAC;IAChCP,GAAG;IACHiD,MAAM,EAAEjD,GAAG;IACX6C;GACD,CAAC,CAAC;AACL,CAAC,CAAC;AAEJ;;;;;;;AAOA,OAAO,MAAMK,cAAc,GACzBjF,OAA2B,IAQ3BhB,OAAO,CAACkG,MAAM,CACZ/F,MAAM,CAACgG,GAAG,CAACpF,OAAO,CAACC,OAAO,CAAC,EAAEN,MAAM,CAAC0F,aAAa,EAAM,CAAC,CACzD;AAEH;;;;;;;AAOA,OAAO,MAAMC,QAAQ,gBAGjBhG,QAAQ,CAACiG,IAAI,CAACvF,OAAO,eAAEP,KAAK,CAAC+F,MAAM,CAAC7F,MAAM,CAACA,MAAM,CAAC,CAAC","ignoreList":[]}
|
|
@@ -10,32 +10,49 @@ import * as NodeSocket from "./NodeSocket.ts";
|
|
|
10
10
|
import { NodeWS } from "./NodeSocket.ts";
|
|
11
11
|
declare const IncomingMessage_base: Context.ServiceClass<IncomingMessage, "@effect/platform-node-shared/NodeSocketServer/IncomingMessage", Http.IncomingMessage>;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Service tag for the Node `IncomingMessage` associated with the current
|
|
14
|
+
* WebSocket server connection.
|
|
15
|
+
*
|
|
14
16
|
* @category tags
|
|
17
|
+
* @since 4.0.0
|
|
15
18
|
*/
|
|
16
19
|
export declare class IncomingMessage extends IncomingMessage_base {
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
22
|
+
* Creates a scoped TCP `SocketServer` from a Node `net.Server`, starts
|
|
23
|
+
* listening with the supplied options, queues pending connections until `run`
|
|
24
|
+
* is called, and closes the server when the scope ends.
|
|
25
|
+
*
|
|
20
26
|
* @category constructors
|
|
27
|
+
* @since 4.0.0
|
|
21
28
|
*/
|
|
22
29
|
export declare const make: (options: Net.ServerOpts & Net.ListenOptions) => Effect.Effect<{
|
|
23
30
|
readonly address: SocketServer.Address;
|
|
24
31
|
readonly run: <R, E, _>(handler: (socket: Socket.Socket) => Effect.Effect<_, E, R>) => Effect.Effect<never, SocketServer.SocketServerError, R>;
|
|
25
32
|
}, SocketServer.SocketServerError, Scope.Scope>;
|
|
26
33
|
/**
|
|
27
|
-
*
|
|
34
|
+
* Provides a TCP `SocketServer` by creating and managing a scoped Node
|
|
35
|
+
* `net.Server` with the supplied server and listen options.
|
|
36
|
+
*
|
|
28
37
|
* @category layers
|
|
38
|
+
* @since 4.0.0
|
|
29
39
|
*/
|
|
30
40
|
export declare const layer: (options: Net.ServerOpts & Net.ListenOptions) => Layer.Layer<SocketServer.SocketServer, SocketServer.SocketServerError>;
|
|
31
41
|
/**
|
|
32
|
-
*
|
|
42
|
+
* Creates a scoped WebSocket `SocketServer` backed by the `ws` package,
|
|
43
|
+
* providing the WebSocket and its Node `IncomingMessage` to connection
|
|
44
|
+
* handlers and closing the server when the scope ends.
|
|
45
|
+
*
|
|
33
46
|
* @category constructors
|
|
47
|
+
* @since 4.0.0
|
|
34
48
|
*/
|
|
35
49
|
export declare const makeWebSocket: (options: NodeWS.ServerOptions<typeof NodeWS.WebSocket, typeof Http.IncomingMessage>) => Effect.Effect<SocketServer.SocketServer["Service"], SocketServer.SocketServerError, Scope.Scope>;
|
|
36
50
|
/**
|
|
37
|
-
*
|
|
51
|
+
* Provides a WebSocket `SocketServer` backed by the `ws` package and managed
|
|
52
|
+
* with the supplied server options.
|
|
53
|
+
*
|
|
38
54
|
* @category layers
|
|
55
|
+
* @since 4.0.0
|
|
39
56
|
*/
|
|
40
57
|
export declare const layerWebSocket: (options: NodeSocket.NodeWS.ServerOptions<typeof NodeSocket.NodeWS.WebSocket, typeof Http.IncomingMessage>) => Layer.Layer<SocketServer.SocketServer, SocketServer.SocketServerError>;
|
|
41
58
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeSocketServer.d.ts","sourceRoot":"","sources":["../src/NodeSocketServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeSocketServer.d.ts","sourceRoot":"","sources":["../src/NodeSocketServer.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAKvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAA;AACvD,OAAO,KAAK,YAAY,MAAM,qCAAqC,CAAA;AACnE,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAA;AACtC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;;AAExC;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,oBAG+B;CAAG;AAEvE;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI;;;+CA6Gf,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,CAClB,OAAO,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,aAAa,KACxC,KAAK,CAAC,KAAK,CACd,YAAY,CAAC,YAAY,EACzB,YAAY,CAAC,iBAAiB,CACgC,CAAA;AAEhE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,CAC1B,OAAO,EAAE,MAAM,CAAC,aAAa,CAAC,OAAO,MAAM,CAAC,SAAS,EAAE,OAAO,IAAI,CAAC,eAAe,CAAC,KAChF,MAAM,CAAC,MAAM,CAChB,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,EACpC,YAAY,CAAC,iBAAiB,EAC9B,KAAK,CAAC,KAAK,CAyFX,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,CAC3B,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,IAAI,CAAC,eAAe,CAAC,KACtG,KAAK,CAAC,KAAK,CACd,YAAY,CAAC,YAAY,EACzB,YAAY,CAAC,iBAAiB,CACyC,CAAA"}
|
package/dist/NodeSocketServer.js
CHANGED
|
@@ -14,13 +14,20 @@ import * as Net from "node:net";
|
|
|
14
14
|
import * as NodeSocket from "./NodeSocket.js";
|
|
15
15
|
import { NodeWS } from "./NodeSocket.js";
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Service tag for the Node `IncomingMessage` associated with the current
|
|
18
|
+
* WebSocket server connection.
|
|
19
|
+
*
|
|
18
20
|
* @category tags
|
|
21
|
+
* @since 4.0.0
|
|
19
22
|
*/
|
|
20
23
|
export class IncomingMessage extends /*#__PURE__*/Context.Service()("@effect/platform-node-shared/NodeSocketServer/IncomingMessage") {}
|
|
21
24
|
/**
|
|
22
|
-
*
|
|
25
|
+
* Creates a scoped TCP `SocketServer` from a Node `net.Server`, starts
|
|
26
|
+
* listening with the supplied options, queues pending connections until `run`
|
|
27
|
+
* is called, and closes the server when the scope ends.
|
|
28
|
+
*
|
|
23
29
|
* @category constructors
|
|
30
|
+
* @since 4.0.0
|
|
24
31
|
*/
|
|
25
32
|
export const make = /*#__PURE__*/Effect.fnUntraced(function* (options) {
|
|
26
33
|
const errorDeferred = Deferred.makeUnsafe();
|
|
@@ -107,13 +114,20 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* (options) {
|
|
|
107
114
|
});
|
|
108
115
|
});
|
|
109
116
|
/**
|
|
110
|
-
*
|
|
117
|
+
* Provides a TCP `SocketServer` by creating and managing a scoped Node
|
|
118
|
+
* `net.Server` with the supplied server and listen options.
|
|
119
|
+
*
|
|
111
120
|
* @category layers
|
|
121
|
+
* @since 4.0.0
|
|
112
122
|
*/
|
|
113
123
|
export const layer = /*#__PURE__*/Function.flow(make, /*#__PURE__*/Layer.effect(SocketServer.SocketServer));
|
|
114
124
|
/**
|
|
115
|
-
*
|
|
125
|
+
* Creates a scoped WebSocket `SocketServer` backed by the `ws` package,
|
|
126
|
+
* providing the WebSocket and its Node `IncomingMessage` to connection
|
|
127
|
+
* handlers and closing the server when the scope ends.
|
|
128
|
+
*
|
|
116
129
|
* @category constructors
|
|
130
|
+
* @since 4.0.0
|
|
117
131
|
*/
|
|
118
132
|
export const makeWebSocket = /*#__PURE__*/Effect.fnUntraced(function* (options) {
|
|
119
133
|
const server = yield* Effect.acquireRelease(Effect.sync(() => new NodeWS.WebSocketServer(options)), server => Effect.callback(resume => {
|
|
@@ -178,8 +192,11 @@ export const makeWebSocket = /*#__PURE__*/Effect.fnUntraced(function* (options)
|
|
|
178
192
|
});
|
|
179
193
|
});
|
|
180
194
|
/**
|
|
181
|
-
*
|
|
195
|
+
* Provides a WebSocket `SocketServer` backed by the `ws` package and managed
|
|
196
|
+
* with the supplied server options.
|
|
197
|
+
*
|
|
182
198
|
* @category layers
|
|
199
|
+
* @since 4.0.0
|
|
183
200
|
*/
|
|
184
201
|
export const layerWebSocket = /*#__PURE__*/Function.flow(makeWebSocket, /*#__PURE__*/Layer.effect(SocketServer.SocketServer));
|
|
185
202
|
const reportUnhandledError = cause => Effect.withFiber(fiber => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeSocketServer.js","names":["Context","Deferred","Effect","Exit","Fiber","pipe","Function","Layer","References","Scope","Socket","SocketServer","Net","NodeSocket","NodeWS","IncomingMessage","Service","make","fnUntraced","options","errorDeferred","makeUnsafe","pending","Set","defaultOnConnection","conn","add","remove","delete","on","onConnection","server","addFinalizer","callback","resume","close","void","createServer","err","doneUnsafe","fail","listen","raceFirst","mapError","await","SocketServerError","reason","SocketServerOpenError","cause","run","handler","scope","services","omit","context","trackFiber","runIn","prevOnConnection","error","fromDuplex","acquireRelease","suspend","SocketError","SocketOpenError","kind","closed","SocketCloseError","code","succeed","sync","destroySoon","flatMap","catchCause","reportUnhandledError","runForkWith","NetSocket","forEach","removeAllListeners","clear","_resume","address","of","_tag","path","hostname","port","layer","flow","effect","makeWebSocket","WebSocketServer","pendingConnections","defaultHandler","req","entry","addEventListener","once","map","Map","mapUnsafe","set","key","WebSocket","fromWebSocket","ensuring","layerWebSocket","withFiber","fiber","unhandledLogLevel","getRef","UnhandledLogLevel","logWithLevel"],"sources":["../src/NodeSocketServer.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeSocketServer.js","names":["Context","Deferred","Effect","Exit","Fiber","pipe","Function","Layer","References","Scope","Socket","SocketServer","Net","NodeSocket","NodeWS","IncomingMessage","Service","make","fnUntraced","options","errorDeferred","makeUnsafe","pending","Set","defaultOnConnection","conn","add","remove","delete","on","onConnection","server","addFinalizer","callback","resume","close","void","createServer","err","doneUnsafe","fail","listen","raceFirst","mapError","await","SocketServerError","reason","SocketServerOpenError","cause","run","handler","scope","services","omit","context","trackFiber","runIn","prevOnConnection","error","fromDuplex","acquireRelease","suspend","SocketError","SocketOpenError","kind","closed","SocketCloseError","code","succeed","sync","destroySoon","flatMap","catchCause","reportUnhandledError","runForkWith","NetSocket","forEach","removeAllListeners","clear","_resume","address","of","_tag","path","hostname","port","layer","flow","effect","makeWebSocket","WebSocketServer","pendingConnections","defaultHandler","req","entry","addEventListener","once","map","Map","mapUnsafe","set","key","WebSocket","fromWebSocket","ensuring","layerWebSocket","withFiber","fiber","unhandledLogLevel","getRef","UnhandledLogLevel","logWithLevel"],"sources":["../src/NodeSocketServer.ts"],"sourcesContent":[null],"mappings":"AAqBA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,IAAI,QAAQ,iBAAiB;AACtC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,UAAU,MAAM,mBAAmB;AAC/C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,+BAA+B;AACvD,OAAO,KAAKC,YAAY,MAAM,qCAAqC;AAEnE,OAAO,KAAKC,GAAG,MAAM,UAAU;AAC/B,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,iBAAiB;AAExC;;;;;;;AAOA,OAAM,MAAOC,eAAgB,sBAAQf,OAAO,CAACgB,OAAO,EAGjD,CAAC,+DAA+D,CAAC;AAEpE;;;;;;;;AAQA,OAAO,MAAMC,IAAI,gBAAGf,MAAM,CAACgB,UAAU,CAAC,WACpCC,OAA2C;EAE3C,MAAMC,aAAa,GAAGnB,QAAQ,CAACoB,UAAU,EAAgB;EACzD,MAAMC,OAAO,GAAG,IAAIC,GAAG,EAAc;EACrC,SAASC,mBAAmBA,CAACC,IAAgB;IAC3CH,OAAO,CAACI,GAAG,CAACD,IAAI,CAAC;IACjB,MAAME,MAAM,GAAGA,CAAA,KAAK;MAClBL,OAAO,CAACM,MAAM,CAACH,IAAI,CAAC;IACtB,CAAC;IACDA,IAAI,CAACI,EAAE,CAAC,OAAO,EAAEF,MAAM,CAAC;IACxBF,IAA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Stdio.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
2
|
import * as Stdio from "effect/Stdio";
|
|
3
3
|
/**
|
|
4
|
+
* Provides `Stdio` from `process.argv`, `process.stdin`, `process.stdout`,
|
|
5
|
+
* and `process.stderr`; stdin remains open and stdout/stderr are not ended by
|
|
6
|
+
* default.
|
|
7
|
+
*
|
|
4
8
|
* @category Layers
|
|
5
|
-
* @since
|
|
9
|
+
* @since 4.0.0
|
|
6
10
|
*/
|
|
7
11
|
export declare const layer: Layer.Layer<Stdio.Stdio>;
|
|
8
12
|
//# sourceMappingURL=NodeStdio.d.ts.map
|
package/dist/NodeStdio.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeStdio.d.ts","sourceRoot":"","sources":["../src/NodeStdio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeStdio.d.ts","sourceRoot":"","sources":["../src/NodeStdio.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAIrC;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAwC1C,CAAA"}
|
package/dist/NodeStdio.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Shared Node.js implementation of the Effect `Stdio` service.
|
|
3
|
+
*
|
|
4
|
+
* This module builds the `Stdio` layer used by Node platform packages by
|
|
5
|
+
* wiring the service to the current process: command-line arguments come from
|
|
6
|
+
* `process.argv`, input is read from `process.stdin`, and output and error
|
|
7
|
+
* output are written to `process.stdout` and `process.stderr`. It is intended
|
|
8
|
+
* for CLIs, scripts, command runners, test harnesses, and other
|
|
9
|
+
* process-oriented programs that need standard I/O through Effect services.
|
|
10
|
+
*
|
|
11
|
+
* The process stdio streams are global resources owned by Node. This layer
|
|
12
|
+
* leaves stdin open and does not end stdout or stderr by default, avoiding
|
|
13
|
+
* accidental closure of handles other code in the process may still use. Those
|
|
14
|
+
* streams may be pipes, files, or TTYs; interactive terminal behavior such as
|
|
15
|
+
* raw mode, echo, colors, and cursor movement should be coordinated with the
|
|
16
|
+
* terminal APIs instead of assuming this layer has exclusive control.
|
|
17
|
+
*
|
|
18
|
+
* @since 4.0.0
|
|
3
19
|
*/
|
|
4
20
|
import * as Effect from "effect/Effect";
|
|
5
21
|
import * as Layer from "effect/Layer";
|
|
@@ -8,8 +24,12 @@ import * as Stdio from "effect/Stdio";
|
|
|
8
24
|
import { fromWritable } from "./NodeSink.js";
|
|
9
25
|
import { fromReadable } from "./NodeStream.js";
|
|
10
26
|
/**
|
|
27
|
+
* Provides `Stdio` from `process.argv`, `process.stdin`, `process.stdout`,
|
|
28
|
+
* and `process.stderr`; stdin remains open and stdout/stderr are not ended by
|
|
29
|
+
* default.
|
|
30
|
+
*
|
|
11
31
|
* @category Layers
|
|
12
|
-
* @since
|
|
32
|
+
* @since 4.0.0
|
|
13
33
|
*/
|
|
14
34
|
export const layer = /*#__PURE__*/Layer.succeed(Stdio.Stdio, /*#__PURE__*/Stdio.make({
|
|
15
35
|
args: /*#__PURE__*/Effect.sync(() => process.argv.slice(2)),
|
package/dist/NodeStdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeStdio.js","names":["Effect","Layer","systemError","Stdio","fromWritable","fromReadable","layer","succeed","make","args","sync","process","argv","slice","stdout","options","evaluate","onError","cause","module","method","_tag","endOnDone","stderr","stdin","closeOnDone"],"sources":["../src/NodeStdio.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"NodeStdio.js","names":["Effect","Layer","systemError","Stdio","fromWritable","fromReadable","layer","succeed","make","args","sync","process","argv","slice","stdout","options","evaluate","onError","cause","module","method","_tag","endOnDone","stderr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W,CAAC;MACViB,MAAM,EAAE,OAAO;MACfC,MAAM,EAAE,OAAO;MACfC,IAAI,EAAE,SAAS;MACfH;KACD,CAAC;IACJO,WAAW,EAAE;GACd;CACF,CAAC,CACH","ignoreList":[]}
|
package/dist/NodeStream.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Interoperability between Node streams and Effect streams and channels.
|
|
3
|
+
*
|
|
4
|
+
* This module adapts `Readable` and `Duplex` instances at the boundary with
|
|
5
|
+
* Node APIs: wrapping sources such as files, HTTP responses, child process
|
|
6
|
+
* output, and compression transforms as Effect `Stream`s or `Channel`s, piping
|
|
7
|
+
* Effect streams through Node duplex transforms, exposing an Effect `Stream`
|
|
8
|
+
* back to Node as a `Readable`, and collecting small readable payloads into
|
|
9
|
+
* strings or binary buffers.
|
|
10
|
+
*
|
|
11
|
+
* The adapters preserve the Node stream semantics that matter for production
|
|
12
|
+
* code. Writes wait for `drain` when a writable side applies backpressure,
|
|
13
|
+
* readable streams are destroyed on scope finalization by default, and stream
|
|
14
|
+
* failures are routed through `onError` or `Cause.UnknownError`. For long-lived
|
|
15
|
+
* or externally owned streams, pass `closeOnDone` or `endOnDone` carefully, and
|
|
16
|
+
* use `maxBytes` on collection helpers to avoid buffering unbounded input.
|
|
17
|
+
*
|
|
18
|
+
* @since 4.0.0
|
|
3
19
|
*/
|
|
4
20
|
import * as Arr from "effect/Array";
|
|
5
21
|
import * as Cause from "effect/Cause";
|
|
@@ -11,8 +27,12 @@ import * as Stream from "effect/Stream";
|
|
|
11
27
|
import type { Duplex } from "node:stream";
|
|
12
28
|
import { Readable } from "node:stream";
|
|
13
29
|
/**
|
|
30
|
+
* Converts a Node readable stream into an Effect `Stream`, reading chunks with
|
|
31
|
+
* an optional chunk size, mapping stream errors with `onError`, and destroying
|
|
32
|
+
* the readable on completion unless `closeOnDone` is `false`.
|
|
33
|
+
*
|
|
14
34
|
* @category constructors
|
|
15
|
-
* @since
|
|
35
|
+
* @since 4.0.0
|
|
16
36
|
*/
|
|
17
37
|
export declare const fromReadable: <A = Uint8Array, E = Cause.UnknownError>(options: {
|
|
18
38
|
readonly evaluate: LazyArg<Readable | NodeJS.ReadableStream>;
|
|
@@ -22,8 +42,12 @@ export declare const fromReadable: <A = Uint8Array, E = Cause.UnknownError>(opti
|
|
|
22
42
|
readonly closeOnDone?: boolean | undefined;
|
|
23
43
|
}) => Stream.Stream<A, E>;
|
|
24
44
|
/**
|
|
45
|
+
* Creates a `Channel` that pulls chunks from a Node readable stream, mapping
|
|
46
|
+
* errors with `onError` and destroying the readable on completion unless
|
|
47
|
+
* `closeOnDone` is `false`.
|
|
48
|
+
*
|
|
25
49
|
* @category constructors
|
|
26
|
-
* @since
|
|
50
|
+
* @since 4.0.0
|
|
27
51
|
*/
|
|
28
52
|
export declare const fromReadableChannel: <A = Uint8Array, E = Cause.UnknownError>(options: {
|
|
29
53
|
readonly evaluate: LazyArg<Readable | NodeJS.ReadableStream>;
|
|
@@ -32,8 +56,12 @@ export declare const fromReadableChannel: <A = Uint8Array, E = Cause.UnknownErro
|
|
|
32
56
|
readonly closeOnDone?: boolean | undefined;
|
|
33
57
|
}) => Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E>;
|
|
34
58
|
/**
|
|
59
|
+
* Creates a `Channel` over a Node `Duplex`, writing upstream chunks with
|
|
60
|
+
* backpressure while emitting chunks read from the duplex and optionally ending
|
|
61
|
+
* the writable side when upstream completes.
|
|
62
|
+
*
|
|
35
63
|
* @category constructors
|
|
36
|
-
* @since
|
|
64
|
+
* @since 4.0.0
|
|
37
65
|
*/
|
|
38
66
|
export declare const fromDuplex: <IE, I = Uint8Array, O = Uint8Array, E = Cause.UnknownError>(options: {
|
|
39
67
|
readonly evaluate: LazyArg<Duplex>;
|
|
@@ -44,13 +72,19 @@ export declare const fromDuplex: <IE, I = Uint8Array, O = Uint8Array, E = Cause.
|
|
|
44
72
|
readonly encoding?: BufferEncoding | undefined;
|
|
45
73
|
}) => Channel.Channel<Arr.NonEmptyReadonlyArray<O>, IE | E, void, Arr.NonEmptyReadonlyArray<I>, IE>;
|
|
46
74
|
/**
|
|
75
|
+
* Pipes an Effect `Stream` through a Node `Duplex`, writing the stream's
|
|
76
|
+
* chunks to the duplex and emitting chunks read back from it.
|
|
77
|
+
*
|
|
47
78
|
* @category combinators
|
|
48
|
-
* @since
|
|
79
|
+
* @since 4.0.0
|
|
49
80
|
*/
|
|
50
81
|
export declare const pipeThroughDuplex: {
|
|
51
82
|
/**
|
|
83
|
+
* Pipes an Effect `Stream` through a Node `Duplex`, writing the stream's
|
|
84
|
+
* chunks to the duplex and emitting chunks read back from it.
|
|
85
|
+
*
|
|
52
86
|
* @category combinators
|
|
53
|
-
* @since
|
|
87
|
+
* @since 4.0.0
|
|
54
88
|
*/
|
|
55
89
|
<B = Uint8Array, E2 = Cause.UnknownError>(options: {
|
|
56
90
|
readonly evaluate: LazyArg<Duplex>;
|
|
@@ -61,8 +95,11 @@ export declare const pipeThroughDuplex: {
|
|
|
61
95
|
readonly encoding?: BufferEncoding | undefined;
|
|
62
96
|
}): <R, E, A>(self: Stream.Stream<A, E, R>) => Stream.Stream<B, E2 | E, R>;
|
|
63
97
|
/**
|
|
98
|
+
* Pipes an Effect `Stream` through a Node `Duplex`, writing the stream's
|
|
99
|
+
* chunks to the duplex and emitting chunks read back from it.
|
|
100
|
+
*
|
|
64
101
|
* @category combinators
|
|
65
|
-
* @since
|
|
102
|
+
* @since 4.0.0
|
|
66
103
|
*/
|
|
67
104
|
<R, E, A, B = Uint8Array, E2 = Cause.UnknownError>(self: Stream.Stream<A, E, R>, options: {
|
|
68
105
|
readonly evaluate: LazyArg<Duplex>;
|
|
@@ -74,34 +111,54 @@ export declare const pipeThroughDuplex: {
|
|
|
74
111
|
}): Stream.Stream<B, E | E2, R>;
|
|
75
112
|
};
|
|
76
113
|
/**
|
|
114
|
+
* Pipes a stream of strings or bytes through a Node `Duplex` using default
|
|
115
|
+
* options and `Cause.UnknownError` for stream failures.
|
|
116
|
+
*
|
|
77
117
|
* @category combinators
|
|
78
|
-
* @since
|
|
118
|
+
* @since 4.0.0
|
|
79
119
|
*/
|
|
80
120
|
export declare const pipeThroughSimple: {
|
|
81
121
|
/**
|
|
122
|
+
* Pipes a stream of strings or bytes through a Node `Duplex` using default
|
|
123
|
+
* options and `Cause.UnknownError` for stream failures.
|
|
124
|
+
*
|
|
82
125
|
* @category combinators
|
|
83
|
-
* @since
|
|
126
|
+
* @since 4.0.0
|
|
84
127
|
*/
|
|
85
128
|
(duplex: LazyArg<Duplex>): <R, E>(self: Stream.Stream<string | Uint8Array, E, R>) => Stream.Stream<Uint8Array, E | Cause.UnknownError, R>;
|
|
86
129
|
/**
|
|
130
|
+
* Pipes a stream of strings or bytes through a Node `Duplex` using default
|
|
131
|
+
* options and `Cause.UnknownError` for stream failures.
|
|
132
|
+
*
|
|
87
133
|
* @category combinators
|
|
88
|
-
* @since
|
|
134
|
+
* @since 4.0.0
|
|
89
135
|
*/
|
|
90
136
|
<R, E>(self: Stream.Stream<string | Uint8Array, E, R>, duplex: LazyArg<Duplex>): Stream.Stream<Uint8Array, Cause.UnknownError | E, R>;
|
|
91
137
|
};
|
|
92
138
|
/**
|
|
93
|
-
*
|
|
139
|
+
* Converts an Effect `Stream` into a Node `Readable`, using the caller's
|
|
140
|
+
* Effect context to run the stream and destroying the readable if the stream
|
|
141
|
+
* fails.
|
|
142
|
+
*
|
|
94
143
|
* @category conversions
|
|
144
|
+
* @since 4.0.0
|
|
95
145
|
*/
|
|
96
146
|
export declare const toReadable: <E, R>(stream: Stream.Stream<string | Uint8Array, E, R>) => Effect.Effect<Readable, never, R>;
|
|
97
147
|
/**
|
|
98
|
-
*
|
|
148
|
+
* Converts a service-free Effect `Stream` into a Node `Readable` using an
|
|
149
|
+
* empty Effect context.
|
|
150
|
+
*
|
|
99
151
|
* @category conversions
|
|
152
|
+
* @since 4.0.0
|
|
100
153
|
*/
|
|
101
154
|
export declare const toReadableNever: <E>(stream: Stream.Stream<string | Uint8Array, E, never>) => Readable;
|
|
102
155
|
/**
|
|
103
|
-
*
|
|
156
|
+
* Consumes a Node readable stream into a string using the selected encoding,
|
|
157
|
+
* failing through `onError` on stream errors or when `maxBytes` is exceeded
|
|
158
|
+
* and destroying the stream on interruption or failure.
|
|
159
|
+
*
|
|
104
160
|
* @category conversions
|
|
161
|
+
* @since 4.0.0
|
|
105
162
|
*/
|
|
106
163
|
export declare const toString: <E = Cause.UnknownError>(readable: LazyArg<Readable | NodeJS.ReadableStream>, options?: {
|
|
107
164
|
readonly onError?: (error: unknown) => E;
|
|
@@ -109,16 +166,23 @@ export declare const toString: <E = Cause.UnknownError>(readable: LazyArg<Readab
|
|
|
109
166
|
readonly maxBytes?: SizeInput | undefined;
|
|
110
167
|
}) => Effect.Effect<string, E>;
|
|
111
168
|
/**
|
|
112
|
-
*
|
|
169
|
+
* Consumes a Node readable stream into an `ArrayBuffer`, failing through
|
|
170
|
+
* `onError` on stream errors or when `maxBytes` is exceeded and destroying the
|
|
171
|
+
* stream on interruption or failure.
|
|
172
|
+
*
|
|
113
173
|
* @category conversions
|
|
174
|
+
* @since 4.0.0
|
|
114
175
|
*/
|
|
115
176
|
export declare const toArrayBuffer: <E = Cause.UnknownError>(readable: LazyArg<Readable | NodeJS.ReadableStream>, options?: {
|
|
116
177
|
readonly onError?: (error: unknown) => E;
|
|
117
178
|
readonly maxBytes?: SizeInput | undefined;
|
|
118
179
|
}) => Effect.Effect<ArrayBuffer, E>;
|
|
119
180
|
/**
|
|
120
|
-
*
|
|
181
|
+
* Consumes a Node readable stream into a `Uint8Array`, using the same error
|
|
182
|
+
* mapping and `maxBytes` handling as `toArrayBuffer`.
|
|
183
|
+
*
|
|
121
184
|
* @category conversions
|
|
185
|
+
* @since 4.0.0
|
|
122
186
|
*/
|
|
123
187
|
export declare const toUint8Array: <E = Cause.UnknownError>(readable: LazyArg<Readable | NodeJS.ReadableStream>, options?: {
|
|
124
188
|
readonly onError?: (error: unknown) => E;
|