@effect/platform-node 4.0.0-beta.77 → 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.
Files changed (78) hide show
  1. package/dist/NodeClusterHttp.d.ts +8 -32
  2. package/dist/NodeClusterHttp.d.ts.map +1 -1
  3. package/dist/NodeClusterHttp.js.map +1 -1
  4. package/dist/NodeClusterSocket.d.ts +7 -27
  5. package/dist/NodeClusterSocket.d.ts.map +1 -1
  6. package/dist/NodeClusterSocket.js +7 -27
  7. package/dist/NodeClusterSocket.js.map +1 -1
  8. package/dist/NodeFileSystem.d.ts.map +1 -1
  9. package/dist/NodeFileSystem.js +0 -18
  10. package/dist/NodeFileSystem.js.map +1 -1
  11. package/dist/NodeHttpClient.d.ts +4 -31
  12. package/dist/NodeHttpClient.d.ts.map +1 -1
  13. package/dist/NodeHttpClient.js +4 -31
  14. package/dist/NodeHttpClient.js.map +1 -1
  15. package/dist/NodeHttpIncomingMessage.d.ts +0 -15
  16. package/dist/NodeHttpIncomingMessage.d.ts.map +1 -1
  17. package/dist/NodeHttpIncomingMessage.js +0 -15
  18. package/dist/NodeHttpIncomingMessage.js.map +1 -1
  19. package/dist/NodeHttpPlatform.d.ts.map +1 -1
  20. package/dist/NodeHttpPlatform.js +3 -17
  21. package/dist/NodeHttpPlatform.js.map +1 -1
  22. package/dist/NodeHttpServer.d.ts.map +1 -1
  23. package/dist/NodeHttpServer.js +3 -21
  24. package/dist/NodeHttpServer.js.map +1 -1
  25. package/dist/NodeHttpServerRequest.d.ts +4 -17
  26. package/dist/NodeHttpServerRequest.d.ts.map +1 -1
  27. package/dist/NodeHttpServerRequest.js.map +1 -1
  28. package/dist/NodeMultipart.d.ts +5 -28
  29. package/dist/NodeMultipart.d.ts.map +1 -1
  30. package/dist/NodeMultipart.js +5 -28
  31. package/dist/NodeMultipart.js.map +1 -1
  32. package/dist/NodePath.d.ts.map +1 -1
  33. package/dist/NodePath.js +4 -24
  34. package/dist/NodePath.js.map +1 -1
  35. package/dist/NodeRedis.d.ts +4 -33
  36. package/dist/NodeRedis.d.ts.map +1 -1
  37. package/dist/NodeRedis.js +4 -33
  38. package/dist/NodeRedis.js.map +1 -1
  39. package/dist/NodeRuntime.d.ts.map +1 -1
  40. package/dist/NodeRuntime.js +5 -26
  41. package/dist/NodeRuntime.js.map +1 -1
  42. package/dist/NodeServices.d.ts +5 -30
  43. package/dist/NodeServices.d.ts.map +1 -1
  44. package/dist/NodeServices.js.map +1 -1
  45. package/dist/NodeSocket.d.ts.map +1 -1
  46. package/dist/NodeSocket.js +5 -29
  47. package/dist/NodeSocket.js.map +1 -1
  48. package/dist/NodeStdio.d.ts.map +1 -1
  49. package/dist/NodeStdio.js +4 -21
  50. package/dist/NodeStdio.js.map +1 -1
  51. package/dist/NodeTerminal.d.ts.map +1 -1
  52. package/dist/NodeTerminal.js +3 -17
  53. package/dist/NodeTerminal.js.map +1 -1
  54. package/dist/NodeWorker.d.ts.map +1 -1
  55. package/dist/NodeWorker.js +6 -29
  56. package/dist/NodeWorker.js.map +1 -1
  57. package/dist/NodeWorkerRunner.d.ts.map +1 -1
  58. package/dist/NodeWorkerRunner.js +5 -34
  59. package/dist/NodeWorkerRunner.js.map +1 -1
  60. package/package.json +4 -4
  61. package/src/NodeClusterHttp.ts +7 -31
  62. package/src/NodeClusterSocket.ts +7 -27
  63. package/src/NodeFileSystem.ts +0 -18
  64. package/src/NodeHttpClient.ts +4 -31
  65. package/src/NodeHttpIncomingMessage.ts +0 -15
  66. package/src/NodeHttpPlatform.ts +3 -17
  67. package/src/NodeHttpServer.ts +3 -21
  68. package/src/NodeHttpServerRequest.ts +4 -17
  69. package/src/NodeMultipart.ts +5 -28
  70. package/src/NodePath.ts +4 -24
  71. package/src/NodeRedis.ts +4 -33
  72. package/src/NodeRuntime.ts +5 -26
  73. package/src/NodeServices.ts +5 -30
  74. package/src/NodeSocket.ts +5 -29
  75. package/src/NodeStdio.ts +4 -21
  76. package/src/NodeTerminal.ts +3 -17
  77. package/src/NodeWorker.ts +6 -29
  78. package/src/NodeWorkerRunner.ts +5 -34
@@ -1,31 +1,10 @@
1
1
  /**
2
- * Node.js process runner for starting an Effect program at the application
3
- * edge.
2
+ * Node.js process runner for Effect programs.
4
3
  *
5
- * This module exposes `runMain`, the launcher used by Node CLIs, scripts,
6
- * servers, and workers when a single Effect should become the process root. It
7
- * handles runtime error reporting, Node process signals, and teardown so the
8
- * rest of the program can stay inside Effect.
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
  */
@@ -1,35 +1,10 @@
1
1
  /**
2
- * Standard Node.js service bundle for Effect applications.
2
+ * Aggregate Node.js platform services layer.
3
3
  *
4
- * `NodeServices.layer` provides the Node implementations of the core services
5
- * most command-line programs and server entrypoints need: child process
6
- * spawning, cryptography, filesystem access, path operations, stdio, terminal
7
- * interaction, and related process I/O.
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 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.
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 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.
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
  */
@@ -1,23 +1,9 @@
1
1
  /**
2
2
  * Node.js implementation of the Effect `Terminal` service.
3
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.
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
- * 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`.
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
  */
@@ -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. 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.
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
  */