@effect/platform-node 4.0.0-beta.7 → 4.0.0-beta.71
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/Mime.d.ts +9 -3
- package/dist/Mime.d.ts.map +1 -1
- package/dist/Mime.js +9 -3
- package/dist/Mime.js.map +1 -1
- package/dist/NodeChildProcessSpawner.d.ts +1 -1
- package/dist/NodeChildProcessSpawner.js +1 -1
- package/dist/NodeClusterHttp.d.ts +49 -7
- package/dist/NodeClusterHttp.d.ts.map +1 -1
- package/dist/NodeClusterHttp.js +20 -10
- package/dist/NodeClusterHttp.js.map +1 -1
- package/dist/NodeClusterSocket.d.ts +57 -11
- package/dist/NodeClusterSocket.d.ts.map +1 -1
- package/dist/NodeClusterSocket.js +57 -11
- package/dist/NodeClusterSocket.js.map +1 -1
- package/dist/NodeCrypto.d.ts +10 -0
- package/dist/NodeCrypto.d.ts.map +1 -0
- package/dist/NodeCrypto.js +22 -0
- package/dist/NodeCrypto.js.map +1 -0
- package/dist/NodeFileSystem.d.ts +4 -2
- package/dist/NodeFileSystem.d.ts.map +1 -1
- package/dist/NodeFileSystem.js +30 -3
- package/dist/NodeFileSystem.js.map +1 -1
- package/dist/NodeHttpClient.d.ts +111 -24
- package/dist/NodeHttpClient.d.ts.map +1 -1
- package/dist/NodeHttpClient.js +133 -28
- package/dist/NodeHttpClient.js.map +1 -1
- package/dist/NodeHttpIncomingMessage.d.ts +43 -9
- package/dist/NodeHttpIncomingMessage.d.ts.map +1 -1
- package/dist/NodeHttpIncomingMessage.js +47 -8
- package/dist/NodeHttpIncomingMessage.js.map +1 -1
- package/dist/NodeHttpPlatform.d.ts +10 -4
- package/dist/NodeHttpPlatform.d.ts.map +1 -1
- package/dist/NodeHttpPlatform.js +34 -7
- package/dist/NodeHttpPlatform.js.map +1 -1
- package/dist/NodeHttpServer.d.ts +56 -16
- package/dist/NodeHttpServer.d.ts.map +1 -1
- package/dist/NodeHttpServer.js +117 -49
- package/dist/NodeHttpServer.js.map +1 -1
- package/dist/NodeHttpServerRequest.d.ts +29 -3
- package/dist/NodeHttpServerRequest.d.ts.map +1 -1
- package/dist/NodeHttpServerRequest.js +9 -2
- package/dist/NodeHttpServerRequest.js.map +1 -1
- package/dist/NodeMultipart.d.ts +47 -4
- package/dist/NodeMultipart.d.ts.map +1 -1
- package/dist/NodeMultipart.js +47 -4
- package/dist/NodeMultipart.js.map +1 -1
- package/dist/NodePath.d.ts +15 -6
- package/dist/NodePath.d.ts.map +1 -1
- package/dist/NodePath.js +43 -7
- package/dist/NodePath.js.map +1 -1
- package/dist/NodeRedis.d.ts +56 -9
- package/dist/NodeRedis.d.ts.map +1 -1
- package/dist/NodeRedis.js +59 -12
- package/dist/NodeRedis.js.map +1 -1
- package/dist/NodeRuntime.d.ts +27 -36
- package/dist/NodeRuntime.d.ts.map +1 -1
- package/dist/NodeRuntime.js +38 -13
- package/dist/NodeRuntime.js.map +1 -1
- package/dist/NodeServices.d.ts +44 -5
- package/dist/NodeServices.d.ts.map +1 -1
- package/dist/NodeServices.js +7 -3
- package/dist/NodeServices.js.map +1 -1
- package/dist/NodeSink.d.ts +2 -2
- package/dist/NodeSink.js +2 -2
- package/dist/NodeSocket.d.ts +18 -3
- package/dist/NodeSocket.d.ts.map +1 -1
- package/dist/NodeSocket.js +51 -4
- package/dist/NodeSocket.js.map +1 -1
- package/dist/NodeSocketServer.d.ts +2 -2
- package/dist/NodeSocketServer.js +2 -2
- package/dist/NodeStdio.d.ts +5 -2
- package/dist/NodeStdio.d.ts.map +1 -1
- package/dist/NodeStdio.js +30 -3
- package/dist/NodeStdio.js.map +1 -1
- package/dist/NodeStream.d.ts +2 -2
- package/dist/NodeStream.js +2 -2
- package/dist/NodeTerminal.d.ts +8 -2
- package/dist/NodeTerminal.d.ts.map +1 -1
- package/dist/NodeTerminal.js +29 -3
- package/dist/NodeTerminal.js.map +1 -1
- package/dist/NodeWorker.d.ts +9 -2
- package/dist/NodeWorker.d.ts.map +1 -1
- package/dist/NodeWorker.js +45 -6
- package/dist/NodeWorker.js.map +1 -1
- package/dist/NodeWorkerRunner.d.ts +5 -1
- package/dist/NodeWorkerRunner.d.ts.map +1 -1
- package/dist/NodeWorkerRunner.js +47 -5
- package/dist/NodeWorkerRunner.js.map +1 -1
- package/dist/Undici.d.ts +16 -3
- package/dist/Undici.d.ts.map +1 -1
- package/dist/Undici.js +16 -3
- package/dist/Undici.js.map +1 -1
- package/dist/index.d.ts +28 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -26
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/Mime.ts +10 -3
- package/src/NodeChildProcessSpawner.ts +1 -1
- package/src/NodeClusterHttp.ts +54 -11
- package/src/NodeClusterSocket.ts +57 -11
- package/src/NodeCrypto.ts +24 -0
- package/src/NodeFileSystem.ts +30 -3
- package/src/NodeHttpClient.ts +141 -33
- package/src/NodeHttpIncomingMessage.ts +55 -12
- package/src/NodeHttpPlatform.ts +35 -6
- package/src/NodeHttpServer.ts +139 -53
- package/src/NodeHttpServerRequest.ts +29 -3
- package/src/NodeMultipart.ts +47 -4
- package/src/NodePath.ts +43 -7
- package/src/NodeRedis.ts +61 -14
- package/src/NodeRuntime.ts +56 -37
- package/src/NodeServices.ts +46 -5
- package/src/NodeSink.ts +2 -2
- package/src/NodeSocket.ts +56 -4
- package/src/NodeSocketServer.ts +2 -2
- package/src/NodeStdio.ts +30 -3
- package/src/NodeStream.ts +2 -2
- package/src/NodeTerminal.ts +29 -3
- package/src/NodeWorker.ts +45 -6
- package/src/NodeWorkerRunner.ts +47 -5
- package/src/Undici.ts +16 -3
- package/src/index.ts +29 -26
package/dist/NodeSocket.d.ts
CHANGED
|
@@ -3,17 +3,32 @@ import type * as Effect from "effect/Effect";
|
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
4
|
import * as Socket from "effect/unstable/socket/Socket";
|
|
5
5
|
/**
|
|
6
|
-
* @since
|
|
6
|
+
* @since 4.0.0
|
|
7
7
|
*/
|
|
8
8
|
export * from "@effect/platform-node-shared/NodeSocket";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Provides a `Socket.WebSocketConstructor`, using `globalThis.WebSocket` when
|
|
11
|
+
* available and falling back to the `ws` package otherwise.
|
|
12
|
+
*
|
|
11
13
|
* @category layers
|
|
14
|
+
* @since 4.0.0
|
|
12
15
|
*/
|
|
13
16
|
export declare const layerWebSocketConstructor: Layer.Layer<Socket.WebSocketConstructor>;
|
|
14
17
|
/**
|
|
15
|
-
*
|
|
18
|
+
* Provides a `Socket.WebSocketConstructor` backed explicitly by the `ws`
|
|
19
|
+
* package.
|
|
20
|
+
*
|
|
16
21
|
* @category layers
|
|
22
|
+
* @since 4.0.0
|
|
23
|
+
*/
|
|
24
|
+
export declare const layerWebSocketConstructorWS: Layer.Layer<Socket.WebSocketConstructor>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a `Socket.Socket` layer for a WebSocket URL using the Node WebSocket
|
|
27
|
+
* constructor layer, honoring protocol, open-timeout, and close-code error
|
|
28
|
+
* options.
|
|
29
|
+
*
|
|
30
|
+
* @category layers
|
|
31
|
+
* @since 4.0.0
|
|
17
32
|
*/
|
|
18
33
|
export declare const layerWebSocket: (url: string | Effect.Effect<string>, options?: {
|
|
19
34
|
readonly closeCodeIsError?: ((code: number) => boolean) | undefined;
|
package/dist/NodeSocket.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeSocket.d.ts","sourceRoot":"","sources":["../src/NodeSocket.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeSocket.d.ts","sourceRoot":"","sources":["../src/NodeSocket.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAE5C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAEvD;;GAEG;AACH,cAAc,yCAAyC,CAAA;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,KAAK,CACjD,MAAM,CAAC,oBAAoB,CAM3B,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,KAAK,CACnD,MAAM,CAAC,oBAAoB,CAG5B,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAAE,CAC3B,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EACnC,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,SAAS,CAAA;IACnE,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAA;IACjD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;CACxD,GAAG,SAAS,KACV,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAI3C,CAAA"}
|
package/dist/NodeSocket.js
CHANGED
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Node.js socket constructors and layers for Effect sockets.
|
|
3
|
+
*
|
|
4
|
+
* This module combines shared Node stream-backed socket support with
|
|
5
|
+
* Node-specific WebSocket constructor layers. Use it to open TCP clients, Unix
|
|
6
|
+
* domain socket clients, adapt existing Node `Duplex` streams, or provide
|
|
7
|
+
* WebSocket clients to protocols built on Effect's `Socket.Socket`.
|
|
8
|
+
*
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* TCP and Unix sockets come from `node:net` and are exposed as scoped
|
|
12
|
+
* `Socket.Socket` values. Stream open, read, write, and close events are
|
|
13
|
+
* translated to `SocketError` values, and finalization closes or destroys the
|
|
14
|
+
* underlying stream. WebSocket layers provide only the constructor service used
|
|
15
|
+
* by `Socket.makeWebSocket`; `layerWebSocket` combines that constructor with a
|
|
16
|
+
* URL to provide a socket layer.
|
|
17
|
+
*
|
|
18
|
+
* **Common tasks**
|
|
19
|
+
*
|
|
20
|
+
* - Use `makeNet`, `makeNetChannel`, or `layerNet` for TCP connections.
|
|
21
|
+
* - Set `NetConnectOpts.path` for Unix domain sockets.
|
|
22
|
+
* - Use `fromDuplex` when another library already owns a Node `Duplex`.
|
|
23
|
+
* - Use `layerWebSocketConstructor` for the native WebSocket when present, with
|
|
24
|
+
* fallback to `ws`; use `layerWebSocketConstructorWS` to force `ws`.
|
|
25
|
+
*
|
|
26
|
+
* **Gotchas**
|
|
27
|
+
*
|
|
28
|
+
* Socket lifetime is scoped, so release the layer or scope to close the
|
|
29
|
+
* connection. Writes complete when Node accepts or flushes the chunk, not when
|
|
30
|
+
* a peer processes it. Remote `end` events complete the socket run, while
|
|
31
|
+
* abnormal closes, open timeouts, and stream errors surface through
|
|
32
|
+
* `SocketError`; handle them in the Effect that runs the socket.
|
|
33
|
+
*
|
|
34
|
+
* @since 4.0.0
|
|
3
35
|
*/
|
|
4
36
|
import { NodeWS as WS } from "@effect/platform-node-shared/NodeSocket";
|
|
5
37
|
import { flow } from "effect/Function";
|
|
6
38
|
import * as Layer from "effect/Layer";
|
|
7
39
|
import * as Socket from "effect/unstable/socket/Socket";
|
|
8
40
|
/**
|
|
9
|
-
* @since
|
|
41
|
+
* @since 4.0.0
|
|
10
42
|
*/
|
|
11
43
|
export * from "@effect/platform-node-shared/NodeSocket";
|
|
12
44
|
/**
|
|
13
|
-
*
|
|
45
|
+
* Provides a `Socket.WebSocketConstructor`, using `globalThis.WebSocket` when
|
|
46
|
+
* available and falling back to the `ws` package otherwise.
|
|
47
|
+
*
|
|
14
48
|
* @category layers
|
|
49
|
+
* @since 4.0.0
|
|
15
50
|
*/
|
|
16
51
|
export const layerWebSocketConstructor = /*#__PURE__*/Layer.sync(Socket.WebSocketConstructor)(() => {
|
|
17
52
|
if ("WebSocket" in globalThis) {
|
|
@@ -20,8 +55,20 @@ export const layerWebSocketConstructor = /*#__PURE__*/Layer.sync(Socket.WebSocke
|
|
|
20
55
|
return (url, protocols) => new WS.WebSocket(url, protocols);
|
|
21
56
|
});
|
|
22
57
|
/**
|
|
23
|
-
*
|
|
58
|
+
* Provides a `Socket.WebSocketConstructor` backed explicitly by the `ws`
|
|
59
|
+
* package.
|
|
60
|
+
*
|
|
24
61
|
* @category layers
|
|
62
|
+
* @since 4.0.0
|
|
63
|
+
*/
|
|
64
|
+
export const layerWebSocketConstructorWS = /*#__PURE__*/Layer.succeed(Socket.WebSocketConstructor)((url, protocols) => new WS.WebSocket(url, protocols));
|
|
65
|
+
/**
|
|
66
|
+
* Creates a `Socket.Socket` layer for a WebSocket URL using the Node WebSocket
|
|
67
|
+
* constructor layer, honoring protocol, open-timeout, and close-code error
|
|
68
|
+
* options.
|
|
69
|
+
*
|
|
70
|
+
* @category layers
|
|
71
|
+
* @since 4.0.0
|
|
25
72
|
*/
|
|
26
73
|
export const layerWebSocket = /*#__PURE__*/flow(Socket.makeWebSocket, /*#__PURE__*/Layer.effect(Socket.Socket), /*#__PURE__*/Layer.provide(layerWebSocketConstructor));
|
|
27
74
|
//# sourceMappingURL=NodeSocket.js.map
|
package/dist/NodeSocket.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeSocket.js","names":["NodeWS","WS","flow","Layer","Socket","layerWebSocketConstructor","sync","WebSocketConstructor","globalThis","url","protocols","WebSocket","layerWebSocket","makeWebSocket","effect","provide"],"sources":["../src/NodeSocket.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"NodeSocket.js","names":["NodeWS","WS","flow","Layer","Socket","layerWebSocketConstructor","sync","WebSocketConstructor","globalThis","url","protocols","WebSocket","layerWebSocketConstructorWS","succeed","layerWebSocket","makeWebSocket","effect","provide"],"sources":["../src/NodeSocket.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAASA,MAAM,IAAIC,EAAE,QAAQ,yCAAyC;AAGtE,SAASC,IAAI,QAAQ,iBAAiB;AACtC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,+BAA+B;AAEvD;;;AAGA,cAAc,yCAAyC;AAEvD;;;;;;;AAOA,OAAO,MAAMC,yBAAyB,gBAElCF,KAAK,CAACG,IAAI,CAACF,MAAM,CAACG,oBAAoB,CAAC,CAAC,MAAK;EAC/C,IAAI,WAAW,IAAIC,UAAU,EAAE;IAC7B,OAAO,CAACC,GAAG,EAAEC,SAAS,KAAK,IAAIF,UAAU,CAACG,SAAS,CAACF,GAAG,EAAEC,SAAS,CAAC;EACrE;EACA,OAAO,CAACD,GAAG,EAAEC,SAAS,KAAK,IAAIT,EAAE,CAACU,SAAS,CAACF,GAAG,EAAEC,SAAS,CAAoC;AAChG,CAAC,CAAC;AAEF;;;;;;;AAOA,OAAO,MAAME,2BAA2B,gBAEpCT,KAAK,CAACU,OAAO,CAACT,MAAM,CAACG,oBAAoB,CAAC,CAC5C,CAACE,GAAG,EAAEC,SAAS,KAAK,IAAIT,EAAE,CAACU,SAAS,CAACF,GAAG,EAAEC,SAAS,CAAoC,CACxF;AAED;;;;;;;;AAQA,OAAO,MAAMI,cAAc,gBAOqBZ,IAAI,CAClDE,MAAM,CAACW,aAAa,eACpBZ,KAAK,CAACa,MAAM,CAACZ,MAAM,CAACA,MAAM,CAAC,eAC3BD,KAAK,CAACc,OAAO,CAACZ,yBAAyB,CAAC,CACzC","ignoreList":[]}
|
package/dist/NodeSocketServer.js
CHANGED
package/dist/NodeStdio.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type * as Layer from "effect/Layer";
|
|
2
2
|
import type { Stdio } from "effect/Stdio";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Provides the `Stdio` service backed by the current process arguments,
|
|
5
|
+
* stdin, stdout, and stderr streams.
|
|
6
|
+
*
|
|
7
|
+
* @category layers
|
|
8
|
+
* @since 4.0.0
|
|
6
9
|
*/
|
|
7
10
|
export declare const layer: Layer.Layer<Stdio>;
|
|
8
11
|
//# 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":"AA4BA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAmB,CAAA"}
|
package/dist/NodeStdio.js
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Node.js `Stdio` layer for the current process.
|
|
3
|
+
*
|
|
4
|
+
* The exported layer satisfies the platform-independent `Stdio` service by
|
|
5
|
+
* reading command-line arguments from `process.argv`, consuming input from
|
|
6
|
+
* `process.stdin`, and writing output streams to `process.stdout` and
|
|
7
|
+
* `process.stderr`. It is the stdio bridge used by CLIs, scripts, command
|
|
8
|
+
* runners, and tests that intentionally communicate through the host process.
|
|
9
|
+
*
|
|
10
|
+
* **Mental model**
|
|
11
|
+
*
|
|
12
|
+
* Effects should depend on `Stdio`; this module decides that the backing
|
|
13
|
+
* streams are the global Node process handles. Provide `NodeStdio.layer` when a
|
|
14
|
+
* program only needs standard input and output, or `NodeServices.layer` when the
|
|
15
|
+
* same entrypoint also needs the other default Node services.
|
|
16
|
+
*
|
|
17
|
+
* **Gotchas**
|
|
18
|
+
*
|
|
19
|
+
* The process stdio streams are shared resources. The layer leaves stdin open
|
|
20
|
+
* and does not end stdout or stderr by default, avoiding accidental closure of
|
|
21
|
+
* handles that other code in the same process may still use. Stdio might be a
|
|
22
|
+
* pipe, file, or TTY; terminal-specific behavior such as raw mode, echo, color
|
|
23
|
+
* detection, and cursor movement belongs with terminal APIs rather than this
|
|
24
|
+
* service.
|
|
25
|
+
*
|
|
26
|
+
* @since 4.0.0
|
|
3
27
|
*/
|
|
4
28
|
import * as NodeStdio from "@effect/platform-node-shared/NodeStdio";
|
|
5
29
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
30
|
+
* Provides the `Stdio` service backed by the current process arguments,
|
|
31
|
+
* stdin, stdout, and stderr streams.
|
|
32
|
+
*
|
|
33
|
+
* @category layers
|
|
34
|
+
* @since 4.0.0
|
|
8
35
|
*/
|
|
9
36
|
export const layer = NodeStdio.layer;
|
|
10
37
|
//# sourceMappingURL=NodeStdio.js.map
|
package/dist/NodeStdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeStdio.js","names":["NodeStdio","layer"],"sources":["../src/NodeStdio.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"NodeStdio.js","names":["NodeStdio","layer"],"sources":["../src/NodeStdio.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,OAAO,KAAKA,SAAS,MAAM,wCAAwC;AAInE;;;;;;;AAOA,OAAO,MAAMC,KAAK,GAAuBD,SAAS,CAACC,KAAK","ignoreList":[]}
|
package/dist/NodeStream.d.ts
CHANGED
package/dist/NodeStream.js
CHANGED
package/dist/NodeTerminal.d.ts
CHANGED
|
@@ -3,13 +3,19 @@ import type { Layer } from "effect/Layer";
|
|
|
3
3
|
import type { Scope } from "effect/Scope";
|
|
4
4
|
import type { Terminal, UserInput } from "effect/Terminal";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Creates a scoped `Terminal` service backed by process stdin/stdout, using the
|
|
7
|
+
* optional predicate to decide when key input should end the input stream.
|
|
8
|
+
*
|
|
7
9
|
* @category constructors
|
|
10
|
+
* @since 4.0.0
|
|
8
11
|
*/
|
|
9
12
|
export declare const make: (shouldQuit?: (input: UserInput) => boolean) => Effect<Terminal, never, Scope>;
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
14
|
+
* Provides the default process-backed `Terminal` service, ending key input on
|
|
15
|
+
* the default quit keys.
|
|
16
|
+
*
|
|
12
17
|
* @category layers
|
|
18
|
+
* @since 4.0.0
|
|
13
19
|
*/
|
|
14
20
|
export declare const layer: Layer<Terminal>;
|
|
15
21
|
//# sourceMappingURL=NodeTerminal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTerminal.d.ts","sourceRoot":"","sources":["../src/NodeTerminal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeTerminal.d.ts","sourceRoot":"","sources":["../src/NodeTerminal.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAqB,CAAA;AAErH;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAsB,CAAA"}
|
package/dist/NodeTerminal.js
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Node.js implementation of the Effect `Terminal` service.
|
|
3
|
+
*
|
|
4
|
+
* `NodeTerminal` connects `Terminal` to the current process' stdin and stdout
|
|
5
|
+
* so Node programs can read lines, stream key presses, write display output,
|
|
6
|
+
* and inspect terminal dimensions through the Effect service environment.
|
|
7
|
+
*
|
|
8
|
+
* **Mental model**
|
|
9
|
+
*
|
|
10
|
+
* `make` acquires a scoped terminal backed by process streams, and `layer`
|
|
11
|
+
* provides that service with the default key sequence for quitting input. When
|
|
12
|
+
* stdin is a TTY, low-level key input temporarily enables raw mode for the
|
|
13
|
+
* lifetime of the scope; finalization restores the previous terminal state.
|
|
14
|
+
*
|
|
15
|
+
* **Gotchas**
|
|
16
|
+
*
|
|
17
|
+
* In non-TTY environments such as CI, pipes, or redirected input, terminal
|
|
18
|
+
* dimensions may be reported as zero and raw-mode key handling is unavailable.
|
|
19
|
+
* For plain stdin/stdout byte streams, use the standard I/O service instead of
|
|
20
|
+
* the interactive terminal service.
|
|
21
|
+
*
|
|
22
|
+
* @since 4.0.0
|
|
3
23
|
*/
|
|
4
24
|
import * as NodeTerminal from "@effect/platform-node-shared/NodeTerminal";
|
|
5
25
|
/**
|
|
6
|
-
*
|
|
26
|
+
* Creates a scoped `Terminal` service backed by process stdin/stdout, using the
|
|
27
|
+
* optional predicate to decide when key input should end the input stream.
|
|
28
|
+
*
|
|
7
29
|
* @category constructors
|
|
30
|
+
* @since 4.0.0
|
|
8
31
|
*/
|
|
9
32
|
export const make = NodeTerminal.make;
|
|
10
33
|
/**
|
|
11
|
-
*
|
|
34
|
+
* Provides the default process-backed `Terminal` service, ending key input on
|
|
35
|
+
* the default quit keys.
|
|
36
|
+
*
|
|
12
37
|
* @category layers
|
|
38
|
+
* @since 4.0.0
|
|
13
39
|
*/
|
|
14
40
|
export const layer = NodeTerminal.layer;
|
|
15
41
|
//# sourceMappingURL=NodeTerminal.js.map
|
package/dist/NodeTerminal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTerminal.js","names":["NodeTerminal","make","layer"],"sources":["../src/NodeTerminal.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"NodeTerminal.js","names":["NodeTerminal","make","layer"],"sources":["../src/NodeTerminal.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAO,KAAKA,YAAY,MAAM,2CAA2C;AAMzE;;;;;;;AAOA,OAAO,MAAMC,IAAI,GAAmFD,YAAY,CAACC,IAAI;AAErH;;;;;;;AAOA,OAAO,MAAMC,KAAK,GAAoBF,YAAY,CAACE,KAAK","ignoreList":[]}
|
package/dist/NodeWorker.d.ts
CHANGED
|
@@ -3,13 +3,20 @@ import * as Worker from "effect/unstable/workers/Worker";
|
|
|
3
3
|
import type * as ChildProcess from "node:child_process";
|
|
4
4
|
import type * as WorkerThreads from "node:worker_threads";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Provides the Node `WorkerPlatform` for `worker_threads` workers and child
|
|
7
|
+
* process workers, wiring messages, errors, and exits into Effect workers and
|
|
8
|
+
* terminating the worker if graceful shutdown times out.
|
|
9
|
+
*
|
|
7
10
|
* @category layers
|
|
11
|
+
* @since 4.0.0
|
|
8
12
|
*/
|
|
9
13
|
export declare const layerPlatform: Layer.Layer<Worker.WorkerPlatform>;
|
|
10
14
|
/**
|
|
11
|
-
*
|
|
15
|
+
* Provides the Node `WorkerPlatform` together with a `Worker.Spawner` created
|
|
16
|
+
* from the supplied worker or child-process spawning function.
|
|
17
|
+
*
|
|
12
18
|
* @category layers
|
|
19
|
+
* @since 4.0.0
|
|
13
20
|
*/
|
|
14
21
|
export declare const layer: (spawn: (id: number) => WorkerThreads.Worker | ChildProcess.ChildProcess) => Layer.Layer<Worker.WorkerPlatform | Worker.Spawner>;
|
|
15
22
|
//# sourceMappingURL=NodeWorker.d.ts.map
|
package/dist/NodeWorker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeWorker.d.ts","sourceRoot":"","sources":["../src/NodeWorker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeWorker.d.ts","sourceRoot":"","sources":["../src/NodeWorker.ts"],"names":[],"mappings":"AAsCA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAA;AAExD,OAAO,KAAK,KAAK,YAAY,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,KAAK,aAAa,MAAM,qBAAqB,CAAA;AAEzD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CA2E5D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAChB,OAAO,CAAC,EAAE,EAAE,MAAM,KAAK,aAAa,CAAC,MAAM,GAAG,YAAY,CAAC,YAAY,KACtE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,OAAO,CAIlD,CAAA"}
|
package/dist/NodeWorker.js
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Parent-side Node.js support for Effect workers.
|
|
3
|
+
*
|
|
4
|
+
* This module installs the `WorkerPlatform` used by a Node program that owns
|
|
5
|
+
* workers. It supports both `node:worker_threads` workers and IPC-enabled child
|
|
6
|
+
* processes, routing messages through Effect's worker protocol so higher-level
|
|
7
|
+
* worker clients can treat either runtime as the same parent-side transport.
|
|
8
|
+
*
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* `NodeWorker` runs in the parent process. The worker entrypoint should install
|
|
12
|
+
* `NodeWorkerRunner`, which receives parent messages, runs the registered
|
|
13
|
+
* Effect handler, and sends replies back over the same channel. Use `layer`
|
|
14
|
+
* when you want this module to provide both the platform and a `Worker.Spawner`;
|
|
15
|
+
* use `layerPlatform` when the spawner is provided elsewhere.
|
|
16
|
+
*
|
|
17
|
+
* **Common tasks**
|
|
18
|
+
*
|
|
19
|
+
* - Spawn CPU-bound or resource-isolated work in `worker_threads`.
|
|
20
|
+
* - Spawn a child process that was created with an IPC channel.
|
|
21
|
+
* - Share one parent-side worker implementation across both Node transports.
|
|
22
|
+
*
|
|
23
|
+
* **Gotchas**
|
|
24
|
+
*
|
|
25
|
+
* Worker-thread spawners can use `postMessage` transfer lists for values such as
|
|
26
|
+
* `ArrayBuffer` and `MessagePort`; transferring moves ownership, and invalid
|
|
27
|
+
* transfer lists surface as send or receive failures. Child-process spawners
|
|
28
|
+
* must provide an IPC channel, for example via `child_process.fork` or
|
|
29
|
+
* `stdio: "ipc"`; their messages use Node IPC serialization and transfer lists
|
|
30
|
+
* are not forwarded to `ChildProcess.send`. Scope finalization sends the worker
|
|
31
|
+
* close signal and waits for exit before falling back to `terminate()` or
|
|
32
|
+
* `SIGKILL`.
|
|
33
|
+
*
|
|
34
|
+
* @since 4.0.0
|
|
3
35
|
*/
|
|
4
36
|
import * as Deferred from "effect/Deferred";
|
|
5
37
|
import * as Effect from "effect/Effect";
|
|
@@ -9,8 +41,12 @@ import * as Scope from "effect/Scope";
|
|
|
9
41
|
import * as Worker from "effect/unstable/workers/Worker";
|
|
10
42
|
import { WorkerError, WorkerReceiveError } from "effect/unstable/workers/WorkerError";
|
|
11
43
|
/**
|
|
12
|
-
*
|
|
44
|
+
* Provides the Node `WorkerPlatform` for `worker_threads` workers and child
|
|
45
|
+
* process workers, wiring messages, errors, and exits into Effect workers and
|
|
46
|
+
* terminating the worker if graceful shutdown times out.
|
|
47
|
+
*
|
|
13
48
|
* @category layers
|
|
49
|
+
* @since 4.0.0
|
|
14
50
|
*/
|
|
15
51
|
export const layerPlatform = /*#__PURE__*/Layer.succeed(Worker.WorkerPlatform)(/*#__PURE__*/Worker.makePlatform()({
|
|
16
52
|
setup({
|
|
@@ -53,7 +89,7 @@ export const layerPlatform = /*#__PURE__*/Layer.succeed(Worker.WorkerPlatform)(/
|
|
|
53
89
|
message: "An messageerror event was emitted",
|
|
54
90
|
cause
|
|
55
91
|
})
|
|
56
|
-
})
|
|
92
|
+
}));
|
|
57
93
|
});
|
|
58
94
|
port.worker.on("error", cause => {
|
|
59
95
|
Deferred.doneUnsafe(deferred, new WorkerError({
|
|
@@ -61,21 +97,24 @@ export const layerPlatform = /*#__PURE__*/Layer.succeed(Worker.WorkerPlatform)(/
|
|
|
61
97
|
message: "An error event was emitted",
|
|
62
98
|
cause
|
|
63
99
|
})
|
|
64
|
-
})
|
|
100
|
+
}));
|
|
65
101
|
});
|
|
66
102
|
port.worker.on("exit", code => {
|
|
67
103
|
Deferred.doneUnsafe(deferred, new WorkerError({
|
|
68
104
|
reason: new WorkerReceiveError({
|
|
69
105
|
message: "The worker has exited with code: " + code
|
|
70
106
|
})
|
|
71
|
-
})
|
|
107
|
+
}));
|
|
72
108
|
});
|
|
73
109
|
return Effect.void;
|
|
74
110
|
}
|
|
75
111
|
}));
|
|
76
112
|
/**
|
|
77
|
-
*
|
|
113
|
+
* Provides the Node `WorkerPlatform` together with a `Worker.Spawner` created
|
|
114
|
+
* from the supplied worker or child-process spawning function.
|
|
115
|
+
*
|
|
78
116
|
* @category layers
|
|
117
|
+
* @since 4.0.0
|
|
79
118
|
*/
|
|
80
119
|
export const layer = spawn => Layer.merge(Worker.layerSpawner(spawn), layerPlatform);
|
|
81
120
|
//# sourceMappingURL=NodeWorker.js.map
|
package/dist/NodeWorker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeWorker.js","names":["Deferred","Effect","Exit","Layer","Scope","Worker","WorkerError","WorkerReceiveError","layerPlatform","succeed","WorkerPlatform","makePlatform","setup","scope","worker","exitDeferred","makeUnsafe","thing","postMessage","msg","t","kill","terminate","_","send","on","doneUnsafe","void","as","addFinalizer","suspend","await","pipe","timeout","catchCause","sync","listen","deferred","emit","port","message","cause","reason","
|
|
1
|
+
{"version":3,"file":"NodeWorker.js","names":["Deferred","Effect","Exit","Layer","Scope","Worker","WorkerError","WorkerReceiveError","layerPlatform","succeed","WorkerPlatform","makePlatform","setup","scope","worker","exitDeferred","makeUnsafe","thing","postMessage","msg","t","kill","terminate","_","send","on","doneUnsafe","void","as","addFinalizer","suspend","await","pipe","timeout","catchCause","sync","listen","deferred","emit","port","message","cause","reason","code","layer","spawn","merge","layerSpawner"],"sources":["../src/NodeWorker.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
2
|
import * as WorkerRunner from "effect/unstable/workers/WorkerRunner";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Provides the `WorkerRunnerPlatform` for code running inside a Node worker
|
|
5
|
+
* thread or child process, routing parent messages to the registered handler
|
|
6
|
+
* and sending responses back through the parent channel.
|
|
7
|
+
*
|
|
5
8
|
* @category layers
|
|
9
|
+
* @since 4.0.0
|
|
6
10
|
*/
|
|
7
11
|
export declare const layer: Layer.Layer<WorkerRunner.WorkerRunnerPlatform>;
|
|
8
12
|
//# sourceMappingURL=NodeWorkerRunner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeWorkerRunner.d.ts","sourceRoot":"","sources":["../src/NodeWorkerRunner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeWorkerRunner.d.ts","sourceRoot":"","sources":["../src/NodeWorkerRunner.ts"],"names":[],"mappings":"AA8CA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,YAAY,MAAM,sCAAsC,CAAA;AAGpE;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,oBAAoB,CA+E/D,CAAA"}
|
package/dist/NodeWorkerRunner.js
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Node.js runtime support for workers that serve Effect worker requests.
|
|
3
|
+
*
|
|
4
|
+
* `NodeWorkerRunner` supplies the Node implementation of the Effect worker
|
|
5
|
+
* runner platform. Install {@link layer} inside code that is already running in
|
|
6
|
+
* a `node:worker_threads` worker or in a child process with an IPC channel. The
|
|
7
|
+
* layer listens for parent messages, runs handlers registered through
|
|
8
|
+
* `WorkerRunner`, and replies over the same parent channel.
|
|
9
|
+
*
|
|
10
|
+
* **Mental model**
|
|
11
|
+
*
|
|
12
|
+
* - The parent process creates a worker with the Node worker APIs.
|
|
13
|
+
* - The worker process provides this module's {@link layer} to its runner program.
|
|
14
|
+
* - Startup sends a ready message to the parent, then request messages are
|
|
15
|
+
* dispatched to the registered Effect handler.
|
|
16
|
+
* - Responses are sent with Node `postMessage` for worker threads or
|
|
17
|
+
* `process.send` for child processes.
|
|
18
|
+
* - Shutdown is initiated by the parent protocol and closes or unreferences the
|
|
19
|
+
* parent channel.
|
|
20
|
+
*
|
|
21
|
+
* **Common tasks**
|
|
22
|
+
*
|
|
23
|
+
* - Provide {@link layer} in the worker entrypoint before running `WorkerRunner`.
|
|
24
|
+
* - Host CPU-bound work or isolated Node resources behind the Effect worker protocol.
|
|
25
|
+
* - Return transferable values when using `worker_threads`.
|
|
26
|
+
*
|
|
27
|
+
* **Gotchas**
|
|
28
|
+
*
|
|
29
|
+
* - The runner must start inside an actual worker context; otherwise the layer
|
|
30
|
+
* fails because neither `parentPort` nor `process.send` is available.
|
|
31
|
+
* - Transfer lists only apply to `worker_threads`; child-process IPC uses Node
|
|
32
|
+
* serialization.
|
|
33
|
+
* - Long-running handlers should remain interruptible and keep cleanup in
|
|
34
|
+
* scopes so parent-driven shutdown can release resources.
|
|
35
|
+
*
|
|
36
|
+
* **See also**
|
|
37
|
+
*
|
|
38
|
+
* - {@link layer} for the Node worker runner platform.
|
|
39
|
+
*
|
|
40
|
+
* @since 4.0.0
|
|
3
41
|
*/
|
|
4
42
|
import * as Cause from "effect/Cause";
|
|
5
43
|
import * as Deferred from "effect/Deferred";
|
|
@@ -11,8 +49,12 @@ import { WorkerError, WorkerReceiveError, WorkerSpawnError } from "effect/unstab
|
|
|
11
49
|
import * as WorkerRunner from "effect/unstable/workers/WorkerRunner";
|
|
12
50
|
import * as WorkerThreads from "node:worker_threads";
|
|
13
51
|
/**
|
|
14
|
-
*
|
|
52
|
+
* Provides the `WorkerRunnerPlatform` for code running inside a Node worker
|
|
53
|
+
* thread or child process, routing parent messages to the registered handler
|
|
54
|
+
* and sending responses back through the parent channel.
|
|
55
|
+
*
|
|
15
56
|
* @category layers
|
|
57
|
+
* @since 4.0.0
|
|
16
58
|
*/
|
|
17
59
|
export const layer = /*#__PURE__*/Layer.succeed(WorkerRunner.WorkerRunnerPlatform)({
|
|
18
60
|
start() {
|
|
@@ -29,7 +71,7 @@ export const layer = /*#__PURE__*/Layer.succeed(WorkerRunner.WorkerRunnerPlatfor
|
|
|
29
71
|
const run = handler => Effect.scopedWith(Effect.fnUntraced(function* (scope) {
|
|
30
72
|
const closeLatch = Deferred.makeUnsafe();
|
|
31
73
|
const trackFiber = Fiber.runIn(scope);
|
|
32
|
-
const services = yield* Effect.
|
|
74
|
+
const services = yield* Effect.context();
|
|
33
75
|
const runFork = Effect.runForkWith(services);
|
|
34
76
|
const onExit = exit => {
|
|
35
77
|
if (exit._tag === "Failure" && !Cause.hasInterruptsOnly(exit.cause)) {
|
|
@@ -60,7 +102,7 @@ export const layer = /*#__PURE__*/Layer.succeed(WorkerRunner.WorkerRunnerPlatfor
|
|
|
60
102
|
message: "received messageerror event",
|
|
61
103
|
cause
|
|
62
104
|
})
|
|
63
|
-
})
|
|
105
|
+
}));
|
|
64
106
|
});
|
|
65
107
|
WorkerThreads.parentPort.on("error", cause => {
|
|
66
108
|
Deferred.doneUnsafe(closeLatch, new WorkerError({
|
|
@@ -68,7 +110,7 @@ export const layer = /*#__PURE__*/Layer.succeed(WorkerRunner.WorkerRunnerPlatfor
|
|
|
68
110
|
message: "received messageerror event",
|
|
69
111
|
cause
|
|
70
112
|
})
|
|
71
|
-
})
|
|
113
|
+
}));
|
|
72
114
|
});
|
|
73
115
|
}
|
|
74
116
|
sendUnsafe(0, [0]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeWorkerRunner.js","names":["Cause","Deferred","Effect","Exit","Fiber","Layer","WorkerError","WorkerReceiveError","WorkerSpawnError","WorkerRunner","WorkerThreads","layer","succeed","WorkerRunnerPlatform","start","gen","parentPort","process","send","reason","message","sendUnsafe","_portId","transfers","postMessage","_transfers","sync","run","handler","scopedWith","fnUntraced","scope","closeLatch","makeUnsafe","trackFiber","runIn","services","runFork","runForkWith","onExit","exit","_tag","hasInterruptsOnly","cause","logError","on","result","isEffect","fiber","addObserver","close","channel","unref","doneUnsafe","void","
|
|
1
|
+
{"version":3,"file":"NodeWorkerRunner.js","names":["Cause","Deferred","Effect","Exit","Fiber","Layer","WorkerError","WorkerReceiveError","WorkerSpawnError","WorkerRunner","WorkerThreads","layer","succeed","WorkerRunnerPlatform","start","gen","parentPort","process","send","reason","message","sendUnsafe","_portId","transfers","postMessage","_transfers","sync","run","handler","scopedWith","fnUntraced","scope","closeLatch","makeUnsafe","trackFiber","runIn","services","context","runFork","runForkWith","onExit","exit","_tag","hasInterruptsOnly","cause","logError","on","result","isEffect","fiber","addObserver","close","channel","unref","doneUnsafe","void","await"],"sources":["../src/NodeWorkerRunner.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
package/dist/Undici.d.ts
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Re-export of the Undici HTTP client package used by the Node platform.
|
|
3
|
+
*
|
|
4
|
+
* This module gives Effect applications a package-local import for Undici
|
|
5
|
+
* primitives while working with `@effect/platform-node`. Import named Undici
|
|
6
|
+
* APIs from here when configuring Node HTTP client dispatchers, creating agents
|
|
7
|
+
* or mock agents, setting the process-global dispatcher, or sharing the same
|
|
8
|
+
* Undici types with integrations that use the platform HTTP client.
|
|
9
|
+
*
|
|
10
|
+
* The module does not wrap or reinterpret Undici behavior. It forwards the
|
|
11
|
+
* installed `undici` named exports and default export, so connection pooling,
|
|
12
|
+
* dispatcher lifetimes, mocking, aborts, and request options follow Undici's
|
|
13
|
+
* own semantics.
|
|
14
|
+
*
|
|
15
|
+
* @since 4.0.0
|
|
3
16
|
*/
|
|
4
17
|
import Undici from "undici";
|
|
5
18
|
/**
|
|
6
|
-
* @since 1.0.0
|
|
7
19
|
* @category undici
|
|
20
|
+
* @since 4.0.0
|
|
8
21
|
*/
|
|
9
22
|
export * from "undici";
|
|
10
23
|
/**
|
|
11
|
-
* @since 1.0.0
|
|
12
24
|
* @category undici
|
|
25
|
+
* @since 4.0.0
|
|
13
26
|
*/
|
|
14
27
|
export default Undici;
|
|
15
28
|
//# sourceMappingURL=Undici.d.ts.map
|
package/dist/Undici.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Undici.d.ts","sourceRoot":"","sources":["../src/Undici.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Undici.d.ts","sourceRoot":"","sources":["../src/Undici.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B;;;GAGG;AACH,cAAc,QAAQ,CAAA;AAEtB;;;GAGG;AACH,eAAe,MAAM,CAAA"}
|