@effect/platform-node-shared 4.0.0-beta.7 → 4.0.0-beta.70

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 (66) hide show
  1. package/dist/NodeChildProcessSpawner.d.ts +3 -3
  2. package/dist/NodeChildProcessSpawner.d.ts.map +1 -1
  3. package/dist/NodeChildProcessSpawner.js +76 -17
  4. package/dist/NodeChildProcessSpawner.js.map +1 -1
  5. package/dist/NodeClusterSocket.d.ts +10 -4
  6. package/dist/NodeClusterSocket.d.ts.map +1 -1
  7. package/dist/NodeClusterSocket.js +33 -8
  8. package/dist/NodeClusterSocket.js.map +1 -1
  9. package/dist/NodeCrypto.d.ts +22 -0
  10. package/dist/NodeCrypto.d.ts.map +1 -0
  11. package/dist/NodeCrypto.js +50 -0
  12. package/dist/NodeCrypto.js.map +1 -0
  13. package/dist/NodeFileSystem.d.ts +5 -2
  14. package/dist/NodeFileSystem.d.ts.map +1 -1
  15. package/dist/NodeFileSystem.js +43 -26
  16. package/dist/NodeFileSystem.js.map +1 -1
  17. package/dist/NodePath.d.ts +15 -6
  18. package/dist/NodePath.d.ts.map +1 -1
  19. package/dist/NodePath.js +30 -7
  20. package/dist/NodePath.js.map +1 -1
  21. package/dist/NodeRuntime.d.ts +36 -7
  22. package/dist/NodeRuntime.d.ts.map +1 -1
  23. package/dist/NodeRuntime.js +8 -8
  24. package/dist/NodeRuntime.js.map +1 -1
  25. package/dist/NodeSink.d.ts +34 -4
  26. package/dist/NodeSink.d.ts.map +1 -1
  27. package/dist/NodeSink.js +23 -4
  28. package/dist/NodeSink.js.map +1 -1
  29. package/dist/NodeSocket.d.ts +40 -9
  30. package/dist/NodeSocket.d.ts.map +1 -1
  31. package/dist/NodeSocket.js +31 -15
  32. package/dist/NodeSocket.js.map +1 -1
  33. package/dist/NodeSocketServer.d.ts +24 -7
  34. package/dist/NodeSocketServer.d.ts.map +1 -1
  35. package/dist/NodeSocketServer.js +28 -11
  36. package/dist/NodeSocketServer.js.map +1 -1
  37. package/dist/NodeStdio.d.ts +6 -5
  38. package/dist/NodeStdio.d.ts.map +1 -1
  39. package/dist/NodeStdio.js +31 -7
  40. package/dist/NodeStdio.js.map +1 -1
  41. package/dist/NodeStream.d.ts +84 -20
  42. package/dist/NodeStream.d.ts.map +1 -1
  43. package/dist/NodeStream.js +76 -23
  44. package/dist/NodeStream.js.map +1 -1
  45. package/dist/NodeTerminal.d.ts +9 -2
  46. package/dist/NodeTerminal.d.ts.map +1 -1
  47. package/dist/NodeTerminal.js +13 -3
  48. package/dist/NodeTerminal.js.map +1 -1
  49. package/dist/index.d.ts +220 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +221 -0
  52. package/dist/index.js.map +1 -0
  53. package/package.json +7 -6
  54. package/src/NodeChildProcessSpawner.ts +101 -27
  55. package/src/NodeClusterSocket.ts +33 -8
  56. package/src/NodeCrypto.ts +55 -0
  57. package/src/NodeFileSystem.ts +50 -28
  58. package/src/NodePath.ts +30 -7
  59. package/src/NodeRuntime.ts +38 -13
  60. package/src/NodeSink.ts +41 -4
  61. package/src/NodeSocket.ts +46 -16
  62. package/src/NodeSocketServer.ts +46 -12
  63. package/src/NodeStdio.ts +49 -23
  64. package/src/NodeStream.ts +97 -30
  65. package/src/NodeTerminal.ts +31 -4
  66. package/src/index.ts +233 -0
package/src/NodeStream.ts CHANGED
@@ -1,9 +1,26 @@
1
1
  /**
2
- * @since 1.0.0
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"
6
22
  import * as Channel from "effect/Channel"
23
+ import * as Context from "effect/Context"
7
24
  import * as Effect from "effect/Effect"
8
25
  import * as Exit from "effect/Exit"
9
26
  import * as Fiber from "effect/Fiber"
@@ -13,15 +30,18 @@ import * as Latch from "effect/Latch"
13
30
  import * as MutableRef from "effect/MutableRef"
14
31
  import * as Pull from "effect/Pull"
15
32
  import * as Scope from "effect/Scope"
16
- import * as ServiceMap from "effect/ServiceMap"
17
33
  import * as Stream from "effect/Stream"
18
34
  import type { Duplex } from "node:stream"
19
35
  import { Readable } from "node:stream"
20
36
  import { pullIntoWritable } from "./NodeSink.ts"
21
37
 
22
38
  /**
39
+ * Converts a Node readable stream into an Effect `Stream`, reading chunks with
40
+ * an optional chunk size, mapping stream errors with `onError`, and destroying
41
+ * the readable on completion unless `closeOnDone` is `false`.
42
+ *
23
43
  * @category constructors
24
- * @since 1.0.0
44
+ * @since 4.0.0
25
45
  */
26
46
  export const fromReadable = <A = Uint8Array, E = Cause.UnknownError>(options: {
27
47
  readonly evaluate: LazyArg<Readable | NodeJS.ReadableStream>
@@ -32,8 +52,12 @@ export const fromReadable = <A = Uint8Array, E = Cause.UnknownError>(options: {
32
52
  }): Stream.Stream<A, E> => Stream.fromChannel(fromReadableChannel<A, E>(options))
33
53
 
34
54
  /**
55
+ * Creates a `Channel` that pulls chunks from a Node readable stream, mapping
56
+ * errors with `onError` and destroying the readable on completion unless
57
+ * `closeOnDone` is `false`.
58
+ *
35
59
  * @category constructors
36
- * @since 1.0.0
60
+ * @since 4.0.0
37
61
  */
38
62
  export const fromReadableChannel = <A = Uint8Array, E = Cause.UnknownError>(options: {
39
63
  readonly evaluate: LazyArg<Readable | NodeJS.ReadableStream>
@@ -52,8 +76,12 @@ export const fromReadableChannel = <A = Uint8Array, E = Cause.UnknownError>(opti
52
76
  )
53
77
 
54
78
  /**
79
+ * Creates a `Channel` over a Node `Duplex`, writing upstream chunks with
80
+ * backpressure while emitting chunks read from the duplex and optionally ending
81
+ * the writable side when upstream completes.
82
+ *
55
83
  * @category constructors
56
- * @since 1.0.0
84
+ * @since 4.0.0
57
85
  */
58
86
  export const fromDuplex = <IE, I = Uint8Array, O = Uint8Array, E = Cause.UnknownError>(
59
87
  options: {
@@ -95,13 +123,19 @@ export const fromDuplex = <IE, I = Uint8Array, O = Uint8Array, E = Cause.Unknown
95
123
  })
96
124
 
97
125
  /**
126
+ * Pipes an Effect `Stream` through a Node `Duplex`, writing the stream's
127
+ * chunks to the duplex and emitting chunks read back from it.
128
+ *
98
129
  * @category combinators
99
- * @since 1.0.0
130
+ * @since 4.0.0
100
131
  */
101
132
  export const pipeThroughDuplex: {
102
133
  /**
134
+ * Pipes an Effect `Stream` through a Node `Duplex`, writing the stream's
135
+ * chunks to the duplex and emitting chunks read back from it.
136
+ *
103
137
  * @category combinators
104
- * @since 1.0.0
138
+ * @since 4.0.0
105
139
  */
106
140
  <B = Uint8Array, E2 = Cause.UnknownError>(
107
141
  options: {
@@ -114,8 +148,11 @@ export const pipeThroughDuplex: {
114
148
  }
115
149
  ): <R, E, A>(self: Stream.Stream<A, E, R>) => Stream.Stream<B, E2 | E, R>
116
150
  /**
151
+ * Pipes an Effect `Stream` through a Node `Duplex`, writing the stream's
152
+ * chunks to the duplex and emitting chunks read back from it.
153
+ *
117
154
  * @category combinators
118
- * @since 1.0.0
155
+ * @since 4.0.0
119
156
  */
120
157
  <R, E, A, B = Uint8Array, E2 = Cause.UnknownError>(
121
158
  self: Stream.Stream<A, E, R>,
@@ -145,18 +182,27 @@ export const pipeThroughDuplex: {
145
182
  ))
146
183
 
147
184
  /**
185
+ * Pipes a stream of strings or bytes through a Node `Duplex` using default
186
+ * options and `Cause.UnknownError` for stream failures.
187
+ *
148
188
  * @category combinators
149
- * @since 1.0.0
189
+ * @since 4.0.0
150
190
  */
151
191
  export const pipeThroughSimple: {
152
192
  /**
193
+ * Pipes a stream of strings or bytes through a Node `Duplex` using default
194
+ * options and `Cause.UnknownError` for stream failures.
195
+ *
153
196
  * @category combinators
154
- * @since 1.0.0
197
+ * @since 4.0.0
155
198
  */
156
199
  (duplex: LazyArg<Duplex>): <R, E>(self: Stream.Stream<string | Uint8Array, E, R>) => Stream.Stream<Uint8Array, E | Cause.UnknownError, R>
157
200
  /**
201
+ * Pipes a stream of strings or bytes through a Node `Duplex` using default
202
+ * options and `Cause.UnknownError` for stream failures.
203
+ *
158
204
  * @category combinators
159
- * @since 1.0.0
205
+ * @since 4.0.0
160
206
  */
161
207
  <R, E>(self: Stream.Stream<string | Uint8Array, E, R>, duplex: LazyArg<Duplex>): Stream.Stream<Uint8Array, Cause.UnknownError | E, R>
162
208
  } = dual(2, <R, E>(
@@ -165,28 +211,39 @@ export const pipeThroughSimple: {
165
211
  ): Stream.Stream<Uint8Array, Cause.UnknownError | E, R> => pipeThroughDuplex(self, { evaluate: duplex }))
166
212
 
167
213
  /**
168
- * @since 1.0.0
169
- * @category conversions
214
+ * Converts an Effect `Stream` into a Node `Readable`, using the caller's
215
+ * Effect context to run the stream and destroying the readable if the stream
216
+ * fails.
217
+ *
218
+ * @category converting
219
+ * @since 4.0.0
170
220
  */
171
221
  export const toReadable = <E, R>(stream: Stream.Stream<string | Uint8Array, E, R>): Effect.Effect<Readable, never, R> =>
172
222
  Effect.map(
173
- Effect.services<R>(),
223
+ Effect.context<R>(),
174
224
  (context) => new StreamAdapter(context, stream)
175
225
  )
176
226
 
177
227
  /**
178
- * @since 1.0.0
179
- * @category conversions
228
+ * Converts a service-free Effect `Stream` into a Node `Readable` using an
229
+ * empty Effect context.
230
+ *
231
+ * @category converting
232
+ * @since 4.0.0
180
233
  */
181
234
  export const toReadableNever = <E>(stream: Stream.Stream<string | Uint8Array, E, never>): Readable =>
182
235
  new StreamAdapter(
183
- ServiceMap.empty(),
236
+ Context.empty(),
184
237
  stream
185
238
  )
186
239
 
187
240
  /**
188
- * @since 1.0.0
189
- * @category conversions
241
+ * Consumes a Node readable stream into a string using the selected encoding,
242
+ * failing through `onError` on stream errors or when `maxBytes` is exceeded
243
+ * and destroying the stream on interruption or failure.
244
+ *
245
+ * @category converting
246
+ * @since 4.0.0
190
247
  */
191
248
  export const toString = <E = Cause.UnknownError>(
192
249
  readable: LazyArg<Readable | NodeJS.ReadableStream>,
@@ -234,8 +291,12 @@ export const toString = <E = Cause.UnknownError>(
234
291
  }
235
292
 
236
293
  /**
237
- * @since 1.0.0
238
- * @category conversions
294
+ * Consumes a Node readable stream into an `ArrayBuffer`, failing through
295
+ * `onError` on stream errors or when `maxBytes` is exceeded and destroying the
296
+ * stream on interruption or failure.
297
+ *
298
+ * @category converting
299
+ * @since 4.0.0
239
300
  */
240
301
  export const toArrayBuffer = <E = Cause.UnknownError>(
241
302
  readable: LazyArg<Readable | NodeJS.ReadableStream>,
@@ -248,7 +309,7 @@ export const toArrayBuffer = <E = Cause.UnknownError>(
248
309
  const onError = options?.onError ?? defaultOnError
249
310
  return Effect.callback((resume) => {
250
311
  const stream = readable() as Readable
251
- let buffer = Buffer.alloc(0)
312
+ const buffers: Array<Uint8Array> = []
252
313
  let bytes = 0
253
314
  stream.once("error", (err) => {
254
315
  if ("closed" in stream && !stream.closed) {
@@ -257,13 +318,16 @@ export const toArrayBuffer = <E = Cause.UnknownError>(
257
318
  resume(Effect.fail(onError(err) as E))
258
319
  })
259
320
  stream.once("end", () => {
260
- if (buffer.buffer.byteLength === buffer.byteLength) {
261
- return resume(Effect.succeed(buffer.buffer))
321
+ const buffer = buffers.length === 1 ? buffers[0] : Buffer.concat(buffers)
322
+ if (buffer.byteOffset === 0 && buffer.buffer.byteLength === buffer.byteLength) {
323
+ return resume(Effect.succeed(buffer.buffer as ArrayBuffer))
262
324
  }
263
- resume(Effect.succeed(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)))
325
+ resume(
326
+ Effect.succeed(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength) as ArrayBuffer)
327
+ )
264
328
  })
265
329
  stream.on("data", (chunk) => {
266
- buffer = Buffer.concat([buffer, chunk])
330
+ buffers.push(chunk)
267
331
  bytes += chunk.length
268
332
  if (maxBytesNumber && bytes > maxBytesNumber) {
269
333
  resume(Effect.fail(onError(new Error("maxBytes exceeded")) as E))
@@ -278,8 +342,11 @@ export const toArrayBuffer = <E = Cause.UnknownError>(
278
342
  }
279
343
 
280
344
  /**
281
- * @since 1.0.0
282
- * @category conversions
345
+ * Consumes a Node readable stream into a `Uint8Array`, using the same error
346
+ * mapping and `maxBytes` handling as `toArrayBuffer`.
347
+ *
348
+ * @category converting
349
+ * @since 4.0.0
283
350
  */
284
351
  export const toUint8Array = <E = Cause.UnknownError>(
285
352
  readable: LazyArg<Readable | NodeJS.ReadableStream>,
@@ -361,7 +428,7 @@ class StreamAdapter<E, R> extends Readable {
361
428
  private fiber: Fiber.Fiber<void, E> | undefined = undefined
362
429
 
363
430
  constructor(
364
- context: ServiceMap.ServiceMap<R>,
431
+ context: Context.Context<R>,
365
432
  stream: Stream.Stream<Uint8Array | string, E, R>
366
433
  ) {
367
434
  super({})
@@ -379,7 +446,7 @@ class StreamAdapter<E, R> extends Readable {
379
446
  }
380
447
  }))).pipe(
381
448
  this.readLatch.whenOpen,
382
- Effect.provideServices(context),
449
+ Effect.provideContext(context),
383
450
  Effect.runFork
384
451
  )
385
452
  this.fiber.addObserver((exit) => {
@@ -1,9 +1,27 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Shared Node.js implementation of Effect's `Terminal` service.
3
+ *
4
+ * This module is the process-backed terminal implementation used by Node
5
+ * platform packages. It adapts Node's `readline` APIs and the current
6
+ * process' `stdin` and `stdout` streams into a `Terminal`, making it suitable
7
+ * for CLIs, REPLs, prompts, full-screen terminal programs, and other
8
+ * command-line tools that need line input, keypress input, terminal
9
+ * dimensions, or prompt output.
10
+ *
11
+ * The implementation works with global process streams, so callers should
12
+ * acquire it with a scope or provide `layer` to ensure cleanup. When `stdin`
13
+ * is a TTY, raw mode is enabled while the scoped readline interface is active
14
+ * and restored on release; raw mode changes how keys are delivered and can
15
+ * affect other code reading stdin. In non-TTY environments such as pipes,
16
+ * redirected input, or CI, raw mode is unavailable, keypress behavior is
17
+ * limited, and stdout dimensions may be reported as zero.
18
+ *
19
+ * @since 4.0.0
3
20
  */
4
21
  import type * as Cause from "effect/Cause"
5
22
  import * as Effect from "effect/Effect"
6
23
  import * as Layer from "effect/Layer"
24
+ import * as Option from "effect/Option"
7
25
  import { badArgument, type PlatformError } from "effect/PlatformError"
8
26
  import * as Predicate from "effect/Predicate"
9
27
  import * as Queue from "effect/Queue"
@@ -13,8 +31,12 @@ import * as Terminal from "effect/Terminal"
13
31
  import * as readline from "node:readline"
14
32
 
15
33
  /**
16
- * @since 1.0.0
34
+ * Creates a scoped process-backed `Terminal` using Node `readline`, enabling
35
+ * TTY raw mode while in scope and using the supplied predicate to decide when
36
+ * key input should end.
37
+ *
17
38
  * @category constructors
39
+ * @since 4.0.0
18
40
  */
19
41
  export const make: (
20
42
  shouldQuit?: (input: Terminal.UserInput) => boolean
@@ -46,13 +68,14 @@ export const make: (
46
68
  })
47
69
 
48
70
  const columns = Effect.sync(() => stdout.columns ?? 0)
71
+ const rows = Effect.sync(() => stdout.rows ?? 0)
49
72
 
50
73
  const readInput = Effect.gen(function*() {
51
74
  yield* RcRef.get(rlRef)
52
75
  const queue = yield* Queue.make<Terminal.UserInput, Cause.Done>()
53
76
  const handleKeypress = (s: string | undefined, k: readline.Key) => {
54
77
  const userInput = {
55
- input: s,
78
+ input: Option.fromUndefinedOr(s),
56
79
  key: { name: k.name ?? "", ctrl: !!k.ctrl, meta: !!k.meta, shift: !!k.shift }
57
80
  }
58
81
  Queue.offerUnsafe(queue, userInput)
@@ -93,6 +116,7 @@ export const make: (
93
116
 
94
117
  return Terminal.make({
95
118
  columns,
119
+ rows,
96
120
  readInput,
97
121
  readLine,
98
122
  display
@@ -101,8 +125,11 @@ export const make: (
101
125
  )
102
126
 
103
127
  /**
104
- * @since 1.0.0
128
+ * Provides the default process-backed `Terminal` service, ending key input on
129
+ * Ctrl+C or Ctrl+D.
130
+ *
105
131
  * @category layers
132
+ * @since 4.0.0
106
133
  */
107
134
  export const layer: Layer.Layer<Terminal.Terminal> = Layer.effect(Terminal.Terminal, make(defaultShouldQuit))
108
135
 
package/src/index.ts ADDED
@@ -0,0 +1,233 @@
1
+ /**
2
+ * @since 4.0.0
3
+ */
4
+
5
+ // @barrel: Auto-generated exports. Do not edit manually.
6
+
7
+ /**
8
+ * Node.js implementation of `ChildProcessSpawner`.
9
+ *
10
+ * @since 4.0.0
11
+ */
12
+ export * as NodeChildProcessSpawner from "./NodeChildProcessSpawner.ts"
13
+
14
+ /**
15
+ * Node TCP socket integration for Effect Cluster runner communication.
16
+ *
17
+ * This module provides the shared Node layers used by socket-based cluster
18
+ * transports: a client protocol that opens TCP sockets to runner addresses and
19
+ * a socket server that listens for incoming runner RPC traffic. It is useful
20
+ * when wiring Node or Node-compatible cluster runners, sharing the same socket
21
+ * implementation across platform packages, or building tests and deployments
22
+ * that need direct runner-to-runner RPC over TCP rather than HTTP.
23
+ *
24
+ * Cluster runners must advertise an address that peers can reach while the
25
+ * server may listen on a different address via `runnerListenAddress`, which is
26
+ * common behind containers, port mappings, or Kubernetes services. Serialization
27
+ * is supplied by the surrounding layer, and gossip, shard discovery, health
28
+ * checks, and storage-backed delivery are coordinated by the cluster services
29
+ * that use this transport. Keep those responsibilities separate when debugging:
30
+ * a reachable socket does not by itself guarantee that runner membership,
31
+ * shard ownership, or persisted message notification is current.
32
+ *
33
+ * @since 4.0.0
34
+ */
35
+ export * as NodeClusterSocket from "./NodeClusterSocket.ts"
36
+
37
+ /**
38
+ * Node.js implementation of the Crypto service.
39
+ *
40
+ * @since 1.0.0
41
+ */
42
+ export * as NodeCrypto from "./NodeCrypto.ts"
43
+
44
+ /**
45
+ * Shared Node-compatible implementation of Effect's `FileSystem` service.
46
+ *
47
+ * This module adapts Node's `node:fs`, `node:os`, and `node:path` APIs into a
48
+ * layer that can be provided to Effect programs running on Node-compatible
49
+ * runtimes. It is used by platform packages to provide file and directory I/O,
50
+ * permissions, links, metadata, temporary files and directories, and file
51
+ * watching through the `FileSystem` service.
52
+ *
53
+ * Paths are passed to Node filesystem APIs, so relative paths are resolved by
54
+ * the current working directory and platform path rules still apply. Node
55
+ * filesystem failures are translated into `PlatformError` values, while invalid
56
+ * arguments become `BadArgument` failures. Open files are scoped resources with
57
+ * tracked read and write positions; append mode lets the operating system choose
58
+ * the write offset. File watching is exposed as a stream and follows
59
+ * `node:fs.watch` semantics unless a `WatchBackend` is provided, so recursive
60
+ * support, event coalescing, and reported paths can vary by runtime and
61
+ * platform.
62
+ *
63
+ * @since 4.0.0
64
+ */
65
+ export * as NodeFileSystem from "./NodeFileSystem.ts"
66
+
67
+ /**
68
+ * Shared Node-compatible implementation of Effect's `Path` service.
69
+ *
70
+ * This module adapts Node's `node:path` and `node:url` APIs into layers that
71
+ * can be provided to Effect programs needing path manipulation, such as
72
+ * resolving configuration files, building file system locations, parsing
73
+ * names and extensions, or converting between file paths and `file:` URLs.
74
+ *
75
+ * The default layer follows the host platform semantics exposed by
76
+ * `node:path`, while `layerPosix` and `layerWin32` provide stable POSIX or
77
+ * Windows behavior regardless of the current runtime. Path operations are
78
+ * syntactic and do not check whether files exist; separators, drive letters,
79
+ * UNC paths, and URL encoding rules can also differ by platform. Invalid
80
+ * file URL conversions are reported through `BadArgument`.
81
+ *
82
+ * @since 4.0.0
83
+ */
84
+ export * as NodePath from "./NodePath.ts"
85
+
86
+ /**
87
+ * Shared runtime helpers for running Effect programs as Node-compatible
88
+ * process entry points.
89
+ *
90
+ * This module provides the common `runMain` implementation used by
91
+ * Node-compatible platform packages. It is intended for CLIs, scripts,
92
+ * workers, servers, and other process-oriented programs that should run an
93
+ * Effect as their main fiber while still following Node process conventions.
94
+ *
95
+ * The runner installs `SIGINT` and `SIGTERM` handlers for the lifetime of the
96
+ * main fiber, translating those process signals into fiber interruption so
97
+ * Effect finalizers and the configured teardown can run. When the fiber exits,
98
+ * the signal listeners are removed and teardown determines the exit code. Clean
99
+ * success lets the Node event loop drain naturally instead of forcing
100
+ * `process.exit(0)`, while signal-triggered or non-zero exits call
101
+ * `process.exit` after teardown, so long-running resources should be modeled
102
+ * in the Effect scope and finalized explicitly.
103
+ *
104
+ * @since 4.0.0
105
+ */
106
+ export * as NodeRuntime from "./NodeRuntime.ts"
107
+
108
+ /**
109
+ * Sink adapters for writing Effect stream chunks into Node writable streams.
110
+ *
111
+ * This module is used at the boundary where Effect `Stream`s or `Channel`s need
112
+ * to push data into Node's writable side: file streams, HTTP request or
113
+ * response bodies, process stdio, sockets, and transform inputs such as
114
+ * compression or encryption streams. It exposes both a `Sink` constructor for
115
+ * ordinary stream pipelines and lower-level `Channel` and pull helpers used by
116
+ * other Node stream adapters.
117
+ *
118
+ * The implementation follows Node writable semantics. Chunks are written in
119
+ * order; when `write` returns `false`, pulling pauses until `drain` so upstream
120
+ * producers do not overrun the writable buffer. Writable `error` events are
121
+ * mapped through `onError`, and the writable is ended and awaited via `finish`
122
+ * when upstream completes unless `endOnDone` is `false`. Use `endOnDone: false`
123
+ * for externally owned or long-lived writables, and make sure `onError` keeps
124
+ * Node's untyped errors meaningful for the calling Effect workflow.
125
+ *
126
+ * @since 4.0.0
127
+ */
128
+ export * as NodeSink from "./NodeSink.ts"
129
+
130
+ /**
131
+ * Shared Node socket constructors for adapting `node:net` connections and
132
+ * other Node `Duplex` streams to Effect's `Socket.Socket` interface.
133
+ *
134
+ * Use this module when building TCP clients, Unix domain socket clients, or
135
+ * higher-level protocols that already expose a Node `Duplex`. Connections are
136
+ * scoped, so finalizers close or destroy the underlying stream, open timeouts
137
+ * are reported as socket open errors, and Node read, write, and close events
138
+ * are translated into `SocketError` values.
139
+ *
140
+ * Node sockets have a few operational details worth keeping in mind: Unix
141
+ * socket paths are supplied through `NetConnectOpts.path`, writes complete only
142
+ * after Node accepts or flushes the chunk, and abnormal close events are
143
+ * surfaced as close errors while normal remote ends complete the socket run.
144
+ *
145
+ * @since 4.0.0
146
+ */
147
+ export * as NodeSocket from "./NodeSocket.ts"
148
+
149
+ /**
150
+ * Shared Node socket server constructors for exposing `node:net` servers and
151
+ * `ws` WebSocket servers as Effect `SocketServer.SocketServer` services.
152
+ *
153
+ * Use this module when implementing TCP services, Unix domain socket services,
154
+ * WebSocket endpoints, or higher-level protocols such as RPC transports that
155
+ * need to accept incoming connections through Effect's socket APIs. TCP
156
+ * connections are adapted through `NodeSocket.fromDuplex`, while WebSocket
157
+ * handlers also receive the underlying `WebSocket` and Node `IncomingMessage`
158
+ * in their fiber context.
159
+ *
160
+ * The server starts listening before the constructor returns, and the exported
161
+ * `address` is derived from the actual Node server after binding. Prefer that
162
+ * address when using port `0`, wildcard hosts, or Unix socket paths. Incoming
163
+ * connections accepted before `run` is installed are queued and then handed to
164
+ * the handler, each `run` call owns the scope for its connection fibers, and
165
+ * the enclosing scope closes the underlying Node server.
166
+ *
167
+ * @since 4.0.0
168
+ */
169
+ export * as NodeSocketServer from "./NodeSocketServer.ts"
170
+
171
+ /**
172
+ * Shared Node.js implementation of the Effect `Stdio` service.
173
+ *
174
+ * This module builds the `Stdio` layer used by Node platform packages by
175
+ * wiring the service to the current process: command-line arguments come from
176
+ * `process.argv`, input is read from `process.stdin`, and output and error
177
+ * output are written to `process.stdout` and `process.stderr`. It is intended
178
+ * for CLIs, scripts, command runners, test harnesses, and other
179
+ * process-oriented programs that need standard I/O through Effect services.
180
+ *
181
+ * The process stdio streams are global resources owned by Node. This layer
182
+ * leaves stdin open and does not end stdout or stderr by default, avoiding
183
+ * accidental closure of handles other code in the process may still use. Those
184
+ * streams may be pipes, files, or TTYs; interactive terminal behavior such as
185
+ * raw mode, echo, colors, and cursor movement should be coordinated with the
186
+ * terminal APIs instead of assuming this layer has exclusive control.
187
+ *
188
+ * @since 4.0.0
189
+ */
190
+ export * as NodeStdio from "./NodeStdio.ts"
191
+
192
+ /**
193
+ * Interoperability between Node streams and Effect streams and channels.
194
+ *
195
+ * This module adapts `Readable` and `Duplex` instances at the boundary with
196
+ * Node APIs: wrapping sources such as files, HTTP responses, child process
197
+ * output, and compression transforms as Effect `Stream`s or `Channel`s, piping
198
+ * Effect streams through Node duplex transforms, exposing an Effect `Stream`
199
+ * back to Node as a `Readable`, and collecting small readable payloads into
200
+ * strings or binary buffers.
201
+ *
202
+ * The adapters preserve the Node stream semantics that matter for production
203
+ * code. Writes wait for `drain` when a writable side applies backpressure,
204
+ * readable streams are destroyed on scope finalization by default, and stream
205
+ * failures are routed through `onError` or `Cause.UnknownError`. For long-lived
206
+ * or externally owned streams, pass `closeOnDone` or `endOnDone` carefully, and
207
+ * use `maxBytes` on collection helpers to avoid buffering unbounded input.
208
+ *
209
+ * @since 4.0.0
210
+ */
211
+ export * as NodeStream from "./NodeStream.ts"
212
+
213
+ /**
214
+ * Shared Node.js implementation of Effect's `Terminal` service.
215
+ *
216
+ * This module is the process-backed terminal implementation used by Node
217
+ * platform packages. It adapts Node's `readline` APIs and the current
218
+ * process' `stdin` and `stdout` streams into a `Terminal`, making it suitable
219
+ * for CLIs, REPLs, prompts, full-screen terminal programs, and other
220
+ * command-line tools that need line input, keypress input, terminal
221
+ * dimensions, or prompt output.
222
+ *
223
+ * The implementation works with global process streams, so callers should
224
+ * acquire it with a scope or provide `layer` to ensure cleanup. When `stdin`
225
+ * is a TTY, raw mode is enabled while the scoped readline interface is active
226
+ * and restored on release; raw mode changes how keys are delivered and can
227
+ * affect other code reading stdin. In non-TTY environments such as pipes,
228
+ * redirected input, or CI, raw mode is unavailable, keypress behavior is
229
+ * limited, and stdout dimensions may be reported as zero.
230
+ *
231
+ * @since 4.0.0
232
+ */
233
+ export * as NodeTerminal from "./NodeTerminal.ts"