@effect/platform-node 4.0.0-beta.78 → 4.0.0-beta.79
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/NodeClusterHttp.d.ts +8 -32
- package/dist/NodeClusterHttp.d.ts.map +1 -1
- package/dist/NodeClusterHttp.js.map +1 -1
- package/dist/NodeClusterSocket.d.ts +7 -27
- package/dist/NodeClusterSocket.d.ts.map +1 -1
- package/dist/NodeClusterSocket.js +7 -27
- package/dist/NodeClusterSocket.js.map +1 -1
- package/dist/NodeFileSystem.d.ts.map +1 -1
- package/dist/NodeFileSystem.js +0 -18
- package/dist/NodeFileSystem.js.map +1 -1
- package/dist/NodeHttpClient.d.ts +4 -31
- package/dist/NodeHttpClient.d.ts.map +1 -1
- package/dist/NodeHttpClient.js +4 -31
- package/dist/NodeHttpClient.js.map +1 -1
- package/dist/NodeHttpIncomingMessage.d.ts +0 -15
- package/dist/NodeHttpIncomingMessage.d.ts.map +1 -1
- package/dist/NodeHttpIncomingMessage.js +0 -15
- package/dist/NodeHttpIncomingMessage.js.map +1 -1
- package/dist/NodeHttpPlatform.d.ts.map +1 -1
- package/dist/NodeHttpPlatform.js +3 -17
- package/dist/NodeHttpPlatform.js.map +1 -1
- package/dist/NodeHttpServer.d.ts.map +1 -1
- package/dist/NodeHttpServer.js +3 -21
- package/dist/NodeHttpServer.js.map +1 -1
- package/dist/NodeHttpServerRequest.d.ts +4 -17
- package/dist/NodeHttpServerRequest.d.ts.map +1 -1
- package/dist/NodeHttpServerRequest.js.map +1 -1
- package/dist/NodeMultipart.d.ts +5 -28
- package/dist/NodeMultipart.d.ts.map +1 -1
- package/dist/NodeMultipart.js +5 -28
- package/dist/NodeMultipart.js.map +1 -1
- package/dist/NodePath.d.ts.map +1 -1
- package/dist/NodePath.js +4 -24
- package/dist/NodePath.js.map +1 -1
- package/dist/NodeRedis.d.ts +4 -33
- package/dist/NodeRedis.d.ts.map +1 -1
- package/dist/NodeRedis.js +4 -33
- package/dist/NodeRedis.js.map +1 -1
- package/dist/NodeRuntime.d.ts.map +1 -1
- package/dist/NodeRuntime.js +5 -26
- package/dist/NodeRuntime.js.map +1 -1
- package/dist/NodeServices.d.ts +5 -30
- package/dist/NodeServices.d.ts.map +1 -1
- package/dist/NodeServices.js.map +1 -1
- package/dist/NodeSocket.d.ts.map +1 -1
- package/dist/NodeSocket.js +5 -29
- package/dist/NodeSocket.js.map +1 -1
- package/dist/NodeStdio.d.ts.map +1 -1
- package/dist/NodeStdio.js +4 -21
- package/dist/NodeStdio.js.map +1 -1
- package/dist/NodeTerminal.d.ts.map +1 -1
- package/dist/NodeTerminal.js +3 -17
- package/dist/NodeTerminal.js.map +1 -1
- package/dist/NodeWorker.d.ts.map +1 -1
- package/dist/NodeWorker.js +6 -29
- package/dist/NodeWorker.js.map +1 -1
- package/dist/NodeWorkerRunner.d.ts.map +1 -1
- package/dist/NodeWorkerRunner.js +5 -34
- package/dist/NodeWorkerRunner.js.map +1 -1
- package/package.json +4 -4
- package/src/NodeClusterHttp.ts +7 -31
- package/src/NodeClusterSocket.ts +7 -27
- package/src/NodeFileSystem.ts +0 -18
- package/src/NodeHttpClient.ts +4 -31
- package/src/NodeHttpIncomingMessage.ts +0 -15
- package/src/NodeHttpPlatform.ts +3 -17
- package/src/NodeHttpServer.ts +3 -21
- package/src/NodeHttpServerRequest.ts +4 -17
- package/src/NodeMultipart.ts +5 -28
- package/src/NodePath.ts +4 -24
- package/src/NodeRedis.ts +4 -33
- package/src/NodeRuntime.ts +5 -26
- package/src/NodeServices.ts +5 -30
- package/src/NodeSocket.ts +5 -29
- package/src/NodeStdio.ts +4 -21
- package/src/NodeTerminal.ts +3 -17
- package/src/NodeWorker.ts +6 -29
- package/src/NodeWorkerRunner.ts +5 -34
package/src/NodeRuntime.ts
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Node.js process runner for
|
|
3
|
-
* edge.
|
|
2
|
+
* Node.js process runner for Effect programs.
|
|
4
3
|
*
|
|
5
|
-
* This module
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* **Mental model**
|
|
11
|
-
*
|
|
12
|
-
* `runMain` is the last call in `main.ts`: build the effect, provide the layers
|
|
13
|
-
* it needs, then hand the self-contained program to this module. The function
|
|
14
|
-
* does not provide Node services itself; use `NodeServices.layer` or narrower
|
|
15
|
-
* platform layers before launching.
|
|
16
|
-
*
|
|
17
|
-
* **Common tasks**
|
|
18
|
-
*
|
|
19
|
-
* - Run a CLI command or script and let failures become process failures.
|
|
20
|
-
* - Keep a server or worker fiber alive as the process main program.
|
|
21
|
-
* - Override teardown or disable automatic error reporting at the boundary.
|
|
22
|
-
*
|
|
23
|
-
* **Gotchas**
|
|
24
|
-
*
|
|
25
|
-
* `SIGINT` and `SIGTERM` interrupt the main fiber so scoped finalizers can run.
|
|
26
|
-
* Clean success lets the event loop drain naturally, while signal-triggered
|
|
27
|
-
* interruption or a non-zero teardown code exits the process. Keep long-lived
|
|
28
|
-
* resources in Effect scopes and avoid finalizers that never complete.
|
|
4
|
+
* This module exports `runMain`, which runs one Effect as the main process
|
|
5
|
+
* fiber in Node.js. It reuses the shared Node runtime runner, including its
|
|
6
|
+
* error reporting, `SIGINT` / `SIGTERM` interruption, and optional teardown
|
|
7
|
+
* behavior.
|
|
29
8
|
*
|
|
30
9
|
* @since 4.0.0
|
|
31
10
|
*/
|
package/src/NodeServices.ts
CHANGED
|
@@ -1,35 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Aggregate Node.js platform services layer.
|
|
3
3
|
*
|
|
4
|
-
* `NodeServices
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* **Mental model**
|
|
10
|
-
*
|
|
11
|
-
* Application code should depend on the individual Effect service tags it uses,
|
|
12
|
-
* such as `FileSystem`, `Path`, or `Stdio`. This module is the composition
|
|
13
|
-
* point for a Node runtime: provide the aggregate layer once near the program
|
|
14
|
-
* boundary, and those service requirements are satisfied by Node-backed
|
|
15
|
-
* implementations.
|
|
16
|
-
*
|
|
17
|
-
* **Common tasks**
|
|
18
|
-
*
|
|
19
|
-
* - Install the default Node platform services for a CLI, script, or process
|
|
20
|
-
* entrypoint with {@link layer}
|
|
21
|
-
* - Use narrower modules such as `NodeFileSystem`, `NodePath`, or `NodeStdio`
|
|
22
|
-
* when a test or embedded runtime should expose only one service
|
|
23
|
-
* - Keep libraries platform-independent by requiring service tags instead of
|
|
24
|
-
* importing this module directly
|
|
25
|
-
*
|
|
26
|
-
* **Gotchas**
|
|
27
|
-
*
|
|
28
|
-
* This is not every Node integration in `@effect/platform-node`. HTTP clients,
|
|
29
|
-
* HTTP servers, sockets, workers, Redis, and other specialized integrations
|
|
30
|
-
* still have their own modules and layers. Providing this layer also means
|
|
31
|
-
* effects can reach real process resources such as the filesystem, stdio,
|
|
32
|
-
* terminal handles, and child processes.
|
|
4
|
+
* This module defines the `NodeServices` union and a single `layer` that
|
|
5
|
+
* provides Node-backed child process spawning, crypto, filesystem, path, stdio,
|
|
6
|
+
* and terminal services. Use the layer when a Node program wants the standard
|
|
7
|
+
* platform services from one place.
|
|
33
8
|
*
|
|
34
9
|
* @since 4.0.0
|
|
35
10
|
*/
|
package/src/NodeSocket.ts
CHANGED
|
@@ -1,35 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node.js socket constructors and layers for Effect sockets.
|
|
3
3
|
*
|
|
4
|
-
* This module
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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.
|
|
4
|
+
* This module re-exports the shared Node socket support for TCP connections,
|
|
5
|
+
* Unix domain socket connections, and Node `Duplex` streams. It also provides
|
|
6
|
+
* WebSocket constructor layers: one that uses `globalThis.WebSocket` when
|
|
7
|
+
* present and falls back to `ws`, one that always uses `ws`, and one that
|
|
8
|
+
* creates a `Socket.Socket` layer for a WebSocket URL.
|
|
33
9
|
*
|
|
34
10
|
* @since 4.0.0
|
|
35
11
|
*/
|
package/src/NodeStdio.ts
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node.js `Stdio` layer for the current process.
|
|
3
3
|
*
|
|
4
|
-
* The exported layer
|
|
5
|
-
*
|
|
6
|
-
* `process.
|
|
7
|
-
* `process.stderr`.
|
|
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.
|
|
4
|
+
* The exported layer reuses the shared Node stdio implementation. It satisfies
|
|
5
|
+
* the platform-independent `Stdio` service by reading command-line arguments
|
|
6
|
+
* from `process.argv`, consuming input from `process.stdin`, and writing output
|
|
7
|
+
* streams to `process.stdout` and `process.stderr`.
|
|
25
8
|
*
|
|
26
9
|
* @since 4.0.0
|
|
27
10
|
*/
|
package/src/NodeTerminal.ts
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node.js implementation of the Effect `Terminal` service.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
4
|
+
* This module reuses the shared Node terminal implementation. `make` creates a
|
|
5
|
+
* scoped process-backed `Terminal` service, and `layer` provides the default
|
|
6
|
+
* service with the standard quit behavior for key input.
|
|
21
7
|
*
|
|
22
8
|
* @since 4.0.0
|
|
23
9
|
*/
|
package/src/NodeWorker.ts
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parent-side Node.js support for Effect workers.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* workers. It supports both `node:worker_threads` workers and IPC-enabled
|
|
6
|
-
* processes, routing messages through Effect's worker protocol
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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`.
|
|
4
|
+
* `layerPlatform` installs the `WorkerPlatform` used by a Node program that
|
|
5
|
+
* owns workers. It supports both `node:worker_threads` workers and IPC-enabled
|
|
6
|
+
* child processes, routing messages through Effect's worker protocol. `layer`
|
|
7
|
+
* combines that platform with a `Spawner` callback, and the platform asks
|
|
8
|
+
* workers to close on scope finalization before forcefully terminating them on
|
|
9
|
+
* timeout.
|
|
33
10
|
*
|
|
34
11
|
* @since 4.0.0
|
|
35
12
|
*/
|
package/src/NodeWorkerRunner.ts
CHANGED
|
@@ -2,40 +2,11 @@
|
|
|
2
2
|
* Node.js runtime support for workers that serve Effect worker requests.
|
|
3
3
|
*
|
|
4
4
|
* `NodeWorkerRunner` supplies the Node implementation of the Effect worker
|
|
5
|
-
* runner platform.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `WorkerRunner`,
|
|
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.
|
|
5
|
+
* runner platform. The exported `layer` runs inside a `node:worker_threads`
|
|
6
|
+
* worker through `parentPort`, or inside a child process through
|
|
7
|
+
* `process.send`. It listens for parent messages, runs handlers registered with
|
|
8
|
+
* `WorkerRunner`, sends replies over the same channel, and closes when the
|
|
9
|
+
* parent sends the close message.
|
|
39
10
|
*
|
|
40
11
|
* @since 4.0.0
|
|
41
12
|
*/
|