alink-cli 0.7.2 → 0.7.4

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeHttpServer-BGJlR_Kf.mjs","names":["Inspectable.Class","IncomingMessage.TypeId","Headers.fromInput","Option.fromNullishOr","Effect.runSync","Effect.cached","Effect.flatMap","IncomingMessage.MaxBodySize","NodeStream.toString","Effect.map","Effect.try","UrlParams.fromInput","NodeStream.fromReadable","Effect.withFiber","NodeStream.toArrayBuffer","Effect.callback","Effect.succeed","Effect.die","make","Effect.map","Response.setHeader","Response.setBody","HttpBody.uint8Array","ServerResponse.removeHeader","ServerResponse.setBody","NodeHttpCompression.algorithms","Effect.succeed","HttpBody.stream","NodeStream.pipeThroughDuplex","NodeHttpCompression.compressTransform","HttpBody.raw","make","ServerResponse.raw","Mime","Headers.merge","Headers.fromRecordUnsafe","layer","Platform.HttpPlatform","NodeFileSystem.layer","EtagImpl.layer","MP.make","make","Multipart.makeConfig","Effect.map","NodeStream.fromReadable","MP.make","Stream.unwrap","Stream.map","Multipart.toPersisted","Effect.tryPromise","NFS","Inspectable.Class","Multipart.TypeId","MP.decodeField","NodeStream.toUint8Array","scope","Effect.scope","Effect.callback","Effect.void","Effect.die","Effect.cached","Effect.timeoutOrElse","Duration.seconds","Scope.addFinalizer","Effect.fail","Effect.acquireRelease","Effect.sync","Scope.provide","HttpServer.make","Effect.fnUntraced","Scope.forkUnsafe","Scope.addFinalizerExit","HttpEffect.toHandled","Effect.withFiber","Effect.succeed","Context.add","Fiber.runIn","Effect.runForkWith","Socket.fromWebSocket","Effect.flatMap","Request.TypeId","Cookies.parseHeader","Effect.runSync","NodeMultipart.persisted","NodeMultipart.stream","HttpIncomingMessage.inspect","HttpServer.HttpServer","NodeHttpPlatform.layer","Etag.layerWeak","NodeServices.layer","Layer.mergeAll","Layer.effect","Config.unwrap","FetchHttpClient.layer","FetchHttpClient.RequestInit","Cookies.isEmpty","Cookies.toSetCookieHeaders","Effect.andThen","Effect.tryPromise","Effect.interruptible","Effect.tapCause","Effect.suspend","Latch.makeUnsafe","Stream.orDie","Stream.runForEachArray","Effect.matchCauseEffect","Effect.failCause","Cause.combine","Cause.die"],"sources":["../../../node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_bufferutil@4.1.0_effect@4.0.0-beta.103_patch_hash=_7eec308fcf6351488fccaf9a0edac255/node_modules/@effect/platform-node/dist/NodeHttpIncomingMessage.js","../../../node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.103_bufferutil@4.1.0_effect@4.0.0-beta.103_patc_c414c3b6e1e822e230993f828f7aeb31/node_modules/@effect/platform-node-shared/dist/NodeHttpCompression.js","../../../node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_bufferutil@4.1.0_effect@4.0.0-beta.103_patch_hash=_7eec308fcf6351488fccaf9a0edac255/node_modules/@effect/platform-node/dist/NodeHttpPlatform.js","../../../node_modules/.pnpm/multipasta@0.2.8/node_modules/multipasta/dist/esm/node.js","../../../node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_bufferutil@4.1.0_effect@4.0.0-beta.103_patch_hash=_7eec308fcf6351488fccaf9a0edac255/node_modules/@effect/platform-node/dist/NodeMultipart.js","../../../node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_bufferutil@4.1.0_effect@4.0.0-beta.103_patch_hash=_7eec308fcf6351488fccaf9a0edac255/node_modules/@effect/platform-node/dist/NodeHttpServer.js"],"sourcesContent":["/**\n * Adapter base for exposing Node `http.IncomingMessage` values as Effect HTTP\n * incoming messages.\n *\n * Server requests and Node client responses both arrive as Node readable\n * streams with raw header objects, socket metadata, and one-shot body\n * consumption. This module's `NodeHttpIncomingMessage` class keeps the original\n * Node message available while presenting Effect's `HttpIncomingMessage` shape:\n * typed headers, remote address lookup, stream access, and text, JSON,\n * URL-encoded, and array-buffer body readers.\n *\n * @since 4.0.0\n */\nimport * as Effect from \"effect/Effect\";\nimport * as Inspectable from \"effect/Inspectable\";\nimport * as Option from \"effect/Option\";\nimport * as Headers from \"effect/unstable/http/Headers\";\nimport * as IncomingMessage from \"effect/unstable/http/HttpIncomingMessage\";\nimport * as UrlParams from \"effect/unstable/http/UrlParams\";\nimport * as NodeStream from \"./NodeStream.js\";\n/**\n * Adapts a Node `IncomingMessage` to Effect HTTP incoming messages.\n *\n * **When to use**\n *\n * Use to implement Node HTTP request or response adapters that expose the\n * Effect HTTP incoming-message interface.\n *\n * **Details**\n *\n * The adapter exposes headers, remote address, stream access, and cached body\n * decoders. Subclasses provide the error mapping for unknown Node errors.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport class NodeHttpIncomingMessage extends Inspectable.Class {\n /**\n * Marks this value as an HTTP incoming message for runtime guards.\n *\n * @since 4.0.0\n */\n [IncomingMessage.TypeId];\n source;\n onError;\n remoteAddressOverride;\n constructor(source, onError, remoteAddressOverride) {\n super();\n this[IncomingMessage.TypeId] = IncomingMessage.TypeId;\n this.source = source;\n this.onError = onError;\n this.remoteAddressOverride = remoteAddressOverride;\n }\n get headers() {\n return Headers.fromInput(this.source.headers);\n }\n get remoteAddress() {\n return this.remoteAddressOverride ?? Option.fromNullishOr(this.source.socket.remoteAddress);\n }\n textEffect;\n get text() {\n if (this.textEffect) {\n return this.textEffect;\n }\n this.textEffect = Effect.runSync(Effect.cached(Effect.flatMap(IncomingMessage.MaxBodySize, maxBodySize => NodeStream.toString(() => this.source, {\n onError: this.onError,\n maxBytes: maxBodySize\n }))));\n this.arrayBufferEffect = Effect.map(this.textEffect, _ => new TextEncoder().encode(_).buffer);\n return this.textEffect;\n }\n get textUnsafe() {\n return Effect.runSync(this.text);\n }\n get json() {\n return Effect.flatMap(this.text, text => Effect.try({\n try: () => text === \"\" ? null : JSON.parse(text),\n catch: this.onError\n }));\n }\n get jsonUnsafe() {\n return Effect.runSync(this.json);\n }\n get urlParamsBody() {\n return Effect.flatMap(this.text, _ => Effect.try({\n try: () => UrlParams.fromInput(new URLSearchParams(_)),\n catch: this.onError\n }));\n }\n get stream() {\n return NodeStream.fromReadable({\n evaluate: () => this.source,\n onError: this.onError\n });\n }\n arrayBufferEffect;\n get arrayBuffer() {\n if (this.arrayBufferEffect) {\n return this.arrayBufferEffect;\n }\n this.arrayBufferEffect = Effect.withFiber(fiber => NodeStream.toArrayBuffer(() => this.source, {\n onError: this.onError,\n maxBytes: fiber.getRef(IncomingMessage.MaxBodySize)\n })).pipe(Effect.cached, Effect.runSync);\n this.textEffect = Effect.map(this.arrayBufferEffect, _ => new TextDecoder().decode(_));\n return this.arrayBufferEffect;\n }\n}\n//# sourceMappingURL=NodeHttpIncomingMessage.js.map","/**\n * HTTP response compression backed by `node:zlib`, shared by the Node.js, Bun,\n * and Deno platforms.\n *\n * Byte-array bodies are compressed in one shot with the asynchronous\n * `node:zlib` APIs, preserving an exact `Content-Length`. Streaming bodies go\n * through `node:zlib` transform streams that flush each input chunk.\n *\n * @since 4.0.0\n */\nimport * as Effect from \"effect/Effect\";\nimport * as HttpBody from \"effect/unstable/http/HttpBody\";\nimport * as Response from \"effect/unstable/http/HttpServerResponse\";\nimport { Readable } from \"node:stream\";\nimport * as Zlib from \"node:zlib\";\n/**\n * The compression algorithms supported by the runtime's `node:zlib`. `zstd`\n * requires Node.js 22.15 or newer.\n *\n * @category constants\n * @since 4.0.0\n */\nexport const algorithms = /*#__PURE__*/new Set(typeof Zlib.zstdCompress === \"function\" ? [\"gzip\", \"deflate\", \"br\", \"zstd\"] : [\"gzip\", \"deflate\", \"br\"]);\nconst brotliParams = (level, sizeHint) => {\n const params = {};\n if (level !== undefined) {\n params[Zlib.constants.BROTLI_PARAM_QUALITY] = level;\n }\n if (sizeHint !== undefined) {\n params[Zlib.constants.BROTLI_PARAM_SIZE_HINT] = sizeHint;\n }\n return {\n params\n };\n};\nconst zstdParams = level => level === undefined || level === 3 ? undefined : {\n params: {\n [Zlib.constants.ZSTD_c_compressionLevel]: level\n }\n};\nconst compress = (data, algorithm, options) => Effect.callback(resume => {\n const complete = (error, result) => resume(error === null ? Effect.succeed(result) : Effect.die(error));\n switch (algorithm) {\n case \"gzip\":\n {\n Zlib.gzip(data, {\n level: options?.level\n }, complete);\n break;\n }\n case \"deflate\":\n {\n Zlib.deflate(data, {\n level: options?.level\n }, complete);\n break;\n }\n case \"br\":\n {\n Zlib.brotliCompress(data, brotliParams(options?.level, data.byteLength), complete);\n break;\n }\n case \"zstd\":\n {\n const params = zstdParams(options?.level);\n if (params === undefined) {\n Zlib.zstdCompress(data, complete);\n } else {\n Zlib.zstdCompress(data, params, complete);\n }\n break;\n }\n }\n});\n/**\n * Creates a `Compression` that compresses byte-array bodies in one shot with\n * the asynchronous `node:zlib` APIs, setting the exact `Content-Length` of the\n * compressed body. All other bodies are delegated to `fallback`.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = fallback => ({\n algorithms: fallback.algorithms,\n compressResponse(response, algorithm, options) {\n const body = response.body;\n if (body._tag !== \"Uint8Array\") {\n return fallback.compressResponse(response, algorithm, options);\n }\n return Effect.map(compress(body.body, algorithm, options), result => Response.setHeader(Response.setBody(response, HttpBody.uint8Array(result, body.contentType)), \"content-length\", result.byteLength.toString()));\n }\n});\n/**\n * Creates a `node:zlib` compression transform stream that flushes each input\n * chunk, for streaming response bodies.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const compressTransform = (algorithm, options) => {\n switch (algorithm) {\n case \"gzip\":\n {\n return Zlib.createGzip({\n level: options?.level,\n flush: Zlib.constants.Z_SYNC_FLUSH\n });\n }\n case \"deflate\":\n {\n return Zlib.createDeflate({\n level: options?.level,\n flush: Zlib.constants.Z_SYNC_FLUSH\n });\n }\n case \"br\":\n {\n return Zlib.createBrotliCompress({\n ...brotliParams(options?.level),\n flush: Zlib.constants.BROTLI_OPERATION_FLUSH\n });\n }\n case \"zstd\":\n {\n return Zlib.createZstdCompress({\n ...zstdParams(options?.level),\n flush: Zlib.constants.ZSTD_e_flush\n });\n }\n }\n};\n/**\n * A Web `ReadableStream` version of `compressTransform`, for platforms that\n * stream response bodies as Web streams.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const compressTransformWeb = (algorithm, options) => stream => {\n const transform = compressTransform(algorithm, options);\n const source = Readable.fromWeb(stream);\n source.on(\"error\", cause => transform.destroy(cause));\n transform.on(\"close\", () => source.destroy());\n return Readable.toWeb(source.pipe(transform));\n};\n//# sourceMappingURL=NodeHttpCompression.js.map","/**\n * Node.js implementation of the Effect HTTP platform service.\n *\n * This module connects the portable `HttpPlatform` file response helpers to\n * Node runtime primitives. It serves local files through Node readable streams,\n * supports byte ranges, converts Web `File` values to readable streams, and\n * fills in content type and content length headers when needed.\n *\n * @since 4.0.0\n */\nimport * as NodeHttpCompression from \"@effect/platform-node-shared/NodeHttpCompression\";\nimport * as Effect from \"effect/Effect\";\nimport { pipe } from \"effect/Function\";\nimport * as Layer from \"effect/Layer\";\nimport * as EtagImpl from \"effect/unstable/http/Etag\";\nimport * as Headers from \"effect/unstable/http/Headers\";\nimport * as HttpBody from \"effect/unstable/http/HttpBody\";\nimport * as Platform from \"effect/unstable/http/HttpPlatform\";\nimport * as ServerResponse from \"effect/unstable/http/HttpServerResponse\";\nimport * as Fs from \"node:fs\";\nimport { Readable } from \"node:stream\";\nimport Mime from \"./Mime.js\";\nimport * as NodeFileSystem from \"./NodeFileSystem.js\";\nimport * as NodeStream from \"./NodeStream.js\";\n// replaces the response body while keeping every other field, dropping the\n// now-stale Content-Length header\nconst compressedBody = (response, body) => ServerResponse.removeHeader(ServerResponse.setBody(response, body), \"content-length\");\nconst compression = /*#__PURE__*/NodeHttpCompression.make({\n algorithms: NodeHttpCompression.algorithms,\n compressResponse(response, algorithm, options) {\n const body = response.body;\n switch (body._tag) {\n case \"Stream\":\n {\n return Effect.succeed(compressedBody(response, HttpBody.stream(NodeStream.pipeThroughDuplex(body.stream, {\n evaluate: () => NodeHttpCompression.compressTransform(algorithm, options)\n }), body.contentType)));\n }\n case \"Raw\":\n {\n const readable = body.body instanceof Readable ? body.body : Readable.fromWeb(new Response(body.body).body);\n const transform = NodeHttpCompression.compressTransform(algorithm, options);\n readable.on(\"error\", cause => transform.destroy(cause));\n transform.on(\"error\", cause => readable.destroy(cause));\n transform.on(\"close\", () => readable.destroy());\n return Effect.succeed(compressedBody(response, HttpBody.raw(readable.pipe(transform), {\n contentType: body.contentType\n })));\n }\n default:\n {\n return Effect.succeed(response);\n }\n }\n }\n});\n/**\n * Creates the Node `HttpPlatform`, serving file responses from Node readable\n * streams and adding MIME type and content-length headers when needed.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = /*#__PURE__*/Platform.make({\n platform: \"node\",\n compression,\n fileResponse(path, status, statusText, headers, start, end, contentLength) {\n const stream = contentLength === 0 ? Readable.from([]) : Fs.createReadStream(path, {\n start,\n end: end === undefined ? undefined : end - 1\n });\n return ServerResponse.raw(stream, {\n headers: {\n ...headers,\n \"content-type\": headers[\"content-type\"] ?? Mime.getType(path) ?? \"application/octet-stream\",\n \"content-length\": contentLength.toString()\n },\n status,\n statusText\n });\n },\n fileWebResponse(file, status, statusText, headers, _options) {\n return ServerResponse.raw(Readable.fromWeb(file.stream()), {\n headers: Headers.merge(headers, Headers.fromRecordUnsafe({\n \"content-type\": headers[\"content-type\"] ?? Mime.getType(file.name) ?? \"application/octet-stream\",\n \"content-length\": file.size.toString()\n })),\n status,\n statusText\n });\n }\n});\n/**\n * Provides the Node `HttpPlatform` together with the filesystem and ETag\n * services it needs for file responses.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/pipe(/*#__PURE__*/Layer.effect(Platform.HttpPlatform)(make), /*#__PURE__*/Layer.provide(NodeFileSystem.layer), /*#__PURE__*/Layer.provide(EtagImpl.layer));\n//# sourceMappingURL=NodeHttpPlatform.js.map","import * as MP from \"./index.js\";\nimport { Duplex, Readable } from \"node:stream\";\nexport { decodeField } from \"./index.js\";\nexport class MultipastaStream extends Duplex {\n _parser;\n _canWrite = true;\n _writeCallback;\n constructor(config) {\n super({\n readableObjectMode: true\n });\n let currentError;\n let currentFile;\n this._parser = MP.make({\n ...config,\n onField: (info, value) => {\n if (currentError !== undefined) return;\n const field = {\n _tag: \"Field\",\n info,\n value\n };\n this.push(field);\n this.emit(\"field\", field);\n },\n onFile: info => {\n if (currentError !== undefined) return _ => {};\n const file = new FileStream(info, this);\n currentFile = file;\n this.push(file);\n this.emit(\"file\", file);\n return chunk => {\n this._canWrite = file.push(chunk);\n if (chunk === null && !this._canWrite) {\n currentFile = undefined;\n this._resume();\n }\n };\n },\n onError: error => {\n this.emit(\"error\", error);\n currentFile?.emit(\"error\", error);\n currentError = error;\n },\n onDone: () => {\n this.push(null);\n }\n });\n }\n _resume() {\n this._canWrite = true;\n if (this._writeCallback !== undefined) {\n const callback = this._writeCallback;\n this._writeCallback = undefined;\n callback();\n }\n }\n _read(_size) {}\n _write(chunk, encoding, callback) {\n this._parser.write(chunk instanceof Uint8Array ? chunk : Buffer.from(chunk, encoding));\n if (this._canWrite) {\n callback();\n } else {\n this._writeCallback = callback;\n }\n }\n _final(callback) {\n this._parser.end();\n callback();\n }\n}\nexport const make = config => new MultipastaStream(config);\nexport class FileStream extends Readable {\n info;\n _parent;\n _tag = \"File\";\n filename;\n constructor(info, _parent) {\n super();\n this.info = info;\n this._parent = _parent;\n this.filename = info.filename;\n }\n _read(_size) {\n if (this._parent._canWrite === false) {\n this._parent._resume();\n }\n }\n}\n//# sourceMappingURL=node.js.map","/**\n * Node.js multipart parsing for HTTP `multipart/form-data` request bodies.\n *\n * `NodeMultipart` adapts a Node `Readable` plus incoming HTTP headers into\n * Effect's shared multipart model. It can expose form parts as a stream or\n * collect a complete persisted form by writing file uploads to scoped temporary\n * files through the current `FileSystem` and `Path` services. `fileToReadable`\n * returns the underlying Node readable stream for file parts produced by this\n * parser.\n *\n * @since 4.0.0\n */\nimport * as Effect from \"effect/Effect\";\nimport * as Inspectable from \"effect/Inspectable\";\nimport * as Stream from \"effect/Stream\";\nimport * as Multipart from \"effect/unstable/http/Multipart\";\nimport * as MP from \"effect/unstable/http/Multipasta/Node\";\nimport * as NFS from \"node:fs\";\nimport * as NodeStreamP from \"node:stream/promises\";\nimport * as NodeStream from \"./NodeStream.js\";\n/**\n * Parses multipart data from a Node readable request body and headers into a\n * stream of `Multipart.Part` values, converting parser failures to\n * `MultipartError`.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const stream = (source, headers) => Multipart.makeConfig(headers).pipe(Effect.map(config => NodeStream.fromReadable({\n evaluate() {\n const parser = MP.make(config);\n source.pipe(parser);\n return parser;\n },\n onError: error => convertError(error)\n})), Stream.unwrap, Stream.map(convertPart));\n/**\n * Parses multipart data from a Node readable request body and persists file\n * parts using the current `FileSystem`, `Path`, and `Scope` services.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const persisted = (source, headers) => Multipart.toPersisted(stream(source, headers), (path, file) => Effect.tryPromise({\n try: signal => NodeStreamP.pipeline(file.file, NFS.createWriteStream(path), {\n signal\n }),\n catch: cause => Multipart.MultipartError.fromReason(\"InternalError\", cause)\n}));\n/**\n * Returns the underlying Node readable stream for a multipart file produced by\n * the Node multipart parser.\n *\n * @category converting\n * @since 4.0.0\n */\nexport const fileToReadable = file => file.file;\n// -----------------------------------------------------------------------------\n// Internal\n// -----------------------------------------------------------------------------\nconst convertPart = part => part._tag === \"Field\" ? new FieldImpl(part.info, part.value) : new FileImpl(part);\nclass PartBase extends Inspectable.Class {\n [Multipart.TypeId];\n constructor() {\n super();\n this[Multipart.TypeId] = Multipart.TypeId;\n }\n}\nclass FieldImpl extends PartBase {\n _tag = \"Field\";\n key;\n contentType;\n value;\n constructor(info, value) {\n super();\n this.key = info.name;\n this.contentType = info.contentType;\n this.value = MP.decodeField(info, value);\n }\n toJSON() {\n return {\n _id: \"@effect/platform/Multipart/Part\",\n _tag: \"Field\",\n key: this.key,\n value: this.value,\n contentType: this.contentType\n };\n }\n}\nclass FileImpl extends PartBase {\n _tag = \"File\";\n key;\n name;\n contentType;\n content;\n contentEffect;\n file;\n constructor(file) {\n super();\n this.file = file;\n this.key = file.info.name;\n this.name = file.filename ?? file.info.name;\n this.contentType = file.info.contentType;\n this.content = NodeStream.fromReadable({\n evaluate: () => file,\n onError: cause => Multipart.MultipartError.fromReason(\"InternalError\", cause)\n });\n this.contentEffect = NodeStream.toUint8Array(() => file, {\n onError: cause => Multipart.MultipartError.fromReason(\"InternalError\", cause)\n });\n }\n toJSON() {\n return {\n _id: \"@effect/platform/Multipart/Part\",\n _tag: \"File\",\n key: this.key,\n name: this.name,\n contentType: this.contentType\n };\n }\n}\nfunction convertError(cause) {\n switch (cause._tag) {\n case \"ReachedLimit\":\n {\n switch (cause.limit) {\n case \"MaxParts\":\n {\n return Multipart.MultipartError.fromReason(\"TooManyParts\", cause);\n }\n case \"MaxFieldSize\":\n {\n return Multipart.MultipartError.fromReason(\"FieldTooLarge\", cause);\n }\n case \"MaxPartSize\":\n {\n return Multipart.MultipartError.fromReason(\"FileTooLarge\", cause);\n }\n case \"MaxTotalSize\":\n {\n return Multipart.MultipartError.fromReason(\"BodyTooLarge\", cause);\n }\n }\n }\n default:\n {\n return Multipart.MultipartError.fromReason(\"Parse\", cause);\n }\n }\n}\n//# sourceMappingURL=NodeMultipart.js.map","/**\n * Node.js implementation of the Effect `HttpServer`.\n *\n * This module adapts a supplied Node `http.Server` into Effect's\n * platform-independent HTTP server service. It starts the server with Node\n * `listen` options, converts `request` events into `HttpServerRequest` values,\n * writes `HttpServerResponse` bodies through Node's `ServerResponse`, and\n * handles `upgrade` events by exposing the upgraded socket through\n * `HttpServerRequest.upgrade`. It also exports request and upgrade handler\n * constructors plus layers for the server alone, HTTP support services, the\n * combined server, configurable options, and tests.\n *\n * @since 4.0.0\n */\nimport * as Cause from \"effect/Cause\";\nimport * as Config from \"effect/Config\";\nimport * as Context from \"effect/Context\";\nimport * as Duration from \"effect/Duration\";\nimport * as Effect from \"effect/Effect\";\nimport * as Fiber from \"effect/Fiber\";\nimport { flow } from \"effect/Function\";\nimport * as Latch from \"effect/Latch\";\nimport * as Layer from \"effect/Layer\";\nimport * as Scope from \"effect/Scope\";\nimport * as Stream from \"effect/Stream\";\nimport * as Cookies from \"effect/unstable/http/Cookies\";\nimport * as Etag from \"effect/unstable/http/Etag\";\nimport * as FetchHttpClient from \"effect/unstable/http/FetchHttpClient\";\nimport * as HttpEffect from \"effect/unstable/http/HttpEffect\";\nimport * as HttpIncomingMessage from \"effect/unstable/http/HttpIncomingMessage\";\nimport * as HttpServer from \"effect/unstable/http/HttpServer\";\nimport { causeResponse, ClientAbort, HttpServerError, RequestParseError, ResponseError, ServeError } from \"effect/unstable/http/HttpServerError\";\nimport * as Request from \"effect/unstable/http/HttpServerRequest\";\nimport { HttpServerRequest } from \"effect/unstable/http/HttpServerRequest\";\nimport * as Socket from \"effect/unstable/socket/Socket\";\nimport * as Http from \"node:http\";\nimport { Readable } from \"node:stream\";\nimport { pipeline } from \"node:stream/promises\";\nimport { NodeHttpIncomingMessage } from \"./NodeHttpIncomingMessage.js\";\nimport * as NodeHttpPlatform from \"./NodeHttpPlatform.js\";\nimport * as NodeMultipart from \"./NodeMultipart.js\";\nimport * as NodeServices from \"./NodeServices.js\";\nimport { NodeWS } from \"./NodeSocket.js\";\n/**\n * Creates a scoped `HttpServer` from a Node `http.Server`, starts listening\n * with the supplied options, registers request and upgrade handling, and closes\n * the server during scope finalization with optional graceful-shutdown control.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = /*#__PURE__*/Effect.fnUntraced(function* (evaluate, options) {\n const scope = yield* Effect.scope;\n const server = evaluate();\n const shutdown = yield* Effect.callback(resume => {\n if (!server.listening) {\n return resume(Effect.void);\n }\n server.close(error => {\n if (error) {\n resume(Effect.die(error));\n } else {\n resume(Effect.void);\n }\n });\n }).pipe(Effect.cached);\n const preemptiveShutdown = options.disablePreemptiveShutdown ? Effect.void : Effect.timeoutOrElse(shutdown, {\n duration: options.gracefulShutdownTimeout ?? Duration.seconds(20),\n orElse: () => Effect.void\n });\n yield* Scope.addFinalizer(scope, shutdown);\n yield* Effect.callback(resume => {\n function onError(cause) {\n resume(Effect.fail(new ServeError({\n cause\n })));\n }\n server.on(\"error\", onError);\n server.listen(options, () => {\n server.off(\"error\", onError);\n resume(Effect.void);\n });\n });\n const address = server.address();\n const wss = yield* Effect.acquireRelease(Effect.sync(() => new NodeWS.WebSocketServer({\n ...options.websocket,\n noServer: true\n })), wss => Effect.callback(resume => {\n wss.close(() => resume(Effect.void));\n })).pipe(Scope.provide(scope), Effect.cached);\n return HttpServer.make({\n address: typeof address === \"string\" ? {\n _tag: \"UnixAddress\",\n path: address\n } : {\n _tag: \"TcpAddress\",\n hostname: address.address === \"::\" ? \"0.0.0.0\" : address.address,\n port: address.port\n },\n serve: Effect.fnUntraced(function* (httpApp, middleware) {\n const serveScope = yield* Effect.scope;\n const scope = Scope.forkUnsafe(serveScope, \"parallel\");\n const handler = yield* makeHandler(httpApp, {\n middleware: middleware,\n scope\n });\n const upgradeHandler = yield* makeUpgradeHandler(wss, httpApp, {\n middleware: middleware,\n scope\n });\n yield* Scope.addFinalizerExit(serveScope, () => {\n server.off(\"request\", handler);\n server.off(\"upgrade\", upgradeHandler);\n return preemptiveShutdown;\n });\n server.on(\"request\", handler);\n server.on(\"upgrade\", upgradeHandler);\n })\n });\n});\n/**\n * Creates a Node `request` event handler for an Effect HTTP application,\n * injecting a `HttpServerRequest` and interrupting the request fiber if the\n * client closes the response before it finishes.\n *\n * @category handlers\n * @since 4.0.0\n */\nexport const makeHandler = (httpEffect, options) => {\n const handled = HttpEffect.toHandled(httpEffect, handleResponse, options.middleware);\n return Effect.withFiber(parent => {\n const services = parent.context;\n return Effect.succeed(function handler(nodeRequest, nodeResponse) {\n const context = Context.add(services, HttpServerRequest, new ServerRequestImpl(nodeRequest, nodeResponse));\n const fiber = Fiber.runIn(Effect.runForkWith(context)(handled), options.scope);\n nodeResponse.on(\"close\", () => {\n if (!nodeResponse.writableEnded) {\n fiber.interruptUnsafe(parent.id, ClientAbort.annotation);\n }\n });\n });\n });\n};\n/**\n * Creates a Node `upgrade` event handler for an Effect HTTP application,\n * exposing the upgraded WebSocket as the request's `upgrade` effect and\n * interrupting the request fiber when the socket closes early.\n *\n * @category handlers\n * @since 4.0.0\n */\nexport const makeUpgradeHandler = (lazyWss, httpEffect, options) => {\n const handledApp = HttpEffect.toHandled(httpEffect, handleResponse, options.middleware);\n return Effect.withFiber(parent => {\n const services = parent.context;\n return Effect.succeed(function handler(nodeRequest, socket, head) {\n let nodeResponse_ = undefined;\n const nodeResponse = () => {\n if (nodeResponse_ === undefined) {\n nodeResponse_ = new Http.ServerResponse(nodeRequest);\n nodeResponse_.assignSocket(socket);\n nodeResponse_.on(\"finish\", () => {\n socket.end();\n });\n }\n return nodeResponse_;\n };\n const upgradeEffect = Socket.fromWebSocket(Effect.flatMap(lazyWss, wss => Effect.acquireRelease(Effect.callback(resume => wss.handleUpgrade(nodeRequest, socket, head, ws => {\n resume(Effect.succeed(ws));\n })), ws => Effect.sync(() => ws.close()))));\n const context = Context.add(services, HttpServerRequest, new ServerRequestImpl(nodeRequest, nodeResponse, upgradeEffect));\n const fiber = Fiber.runIn(Effect.runForkWith(context)(handledApp), options.scope);\n socket.on(\"close\", () => {\n if (!socket.writableEnded) {\n fiber.interruptUnsafe(parent.id, ClientAbort.annotation);\n }\n });\n });\n });\n};\nclass ServerRequestImpl extends NodeHttpIncomingMessage {\n [Request.TypeId];\n response;\n upgradeEffect;\n url;\n headersOverride;\n constructor(source, response, upgradeEffect, url = source.url, headersOverride, remoteAddressOverride) {\n super(source, cause => new HttpServerError({\n reason: new RequestParseError({\n request: this,\n cause\n })\n }), remoteAddressOverride);\n this[Request.TypeId] = Request.TypeId;\n this.response = response;\n this.upgradeEffect = upgradeEffect;\n this.url = url;\n this.headersOverride = headersOverride;\n }\n cachedCookies;\n get cookies() {\n if (this.cachedCookies) {\n return this.cachedCookies;\n }\n return this.cachedCookies = Cookies.parseHeader(this.headers.cookie ?? \"\");\n }\n get resolvedResponse() {\n return typeof this.response === \"function\" ? this.response() : this.response;\n }\n modify(options) {\n return new ServerRequestImpl(this.source, this.response, this.upgradeEffect, options.url ?? this.url, options.headers ?? this.headersOverride, \"remoteAddress\" in options ? options.remoteAddress : this.remoteAddressOverride);\n }\n get originalUrl() {\n return this.source.url;\n }\n cachedMethod;\n get method() {\n return this.cachedMethod ??= this.source.method.toUpperCase();\n }\n get headers() {\n this.headersOverride ??= this.source.headers;\n return this.headersOverride;\n }\n multipartEffect;\n get multipart() {\n if (this.multipartEffect) {\n return this.multipartEffect;\n }\n this.multipartEffect = Effect.runSync(Effect.cached(NodeMultipart.persisted(this.source, this.source.headers)));\n return this.multipartEffect;\n }\n get multipartStream() {\n return NodeMultipart.stream(this.source, this.source.headers);\n }\n get upgrade() {\n return this.upgradeEffect ?? Effect.fail(new HttpServerError({\n reason: new RequestParseError({\n request: this,\n description: \"not an upgradeable ServerRequest\"\n })\n }));\n }\n toString() {\n return `ServerRequest(${this.method} ${this.url})`;\n }\n toJSON() {\n return HttpIncomingMessage.inspect(this, {\n _id: \"HttpServerRequest\",\n method: this.method,\n url: this.originalUrl\n });\n }\n}\n/**\n * Provides an `HttpServer` by creating and managing a scoped Node\n * `http.Server` with the supplied listen and shutdown options.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerServer = /*#__PURE__*/flow(make, /*#__PURE__*/Layer.effect(HttpServer.HttpServer));\n/**\n * Provides the Node HTTP support services used by `NodeHttpServer`, including\n * the HTTP platform, ETag generator, and core Node platform services.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerHttpServices = /*#__PURE__*/Layer.mergeAll(NodeHttpPlatform.layer, Etag.layerWeak, NodeServices.layer);\n/**\n * Provides a Node `HttpServer` together with the Node HTTP platform, ETag, and\n * core platform services required to serve requests.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layer = (evaluate, options) => Layer.mergeAll(layerServer(evaluate, options), layerHttpServices);\n/**\n * Provides a Node `HttpServer` together with the Node HTTP platform, ETag,\n * and core Node platform services, reading the listen and shutdown options from\n * a `Config` value.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerConfig = (evaluate, options) => Layer.mergeAll(Layer.effect(HttpServer.HttpServer)(Effect.flatMap(Config.unwrap(options), options => make(evaluate, options))), layerHttpServices);\n/**\n * Provides a test HTTP server listening on an ephemeral port together with a\n * Fetch-backed `HttpClient` configured for server integration tests.\n *\n * @category testing\n * @since 4.0.0\n */\nexport const layerTest = /*#__PURE__*/HttpServer.layerTestClient.pipe(/*#__PURE__*/Layer.provide(/*#__PURE__*/Layer.fresh(FetchHttpClient.layer).pipe(/*#__PURE__*/Layer.provide(/*#__PURE__*/Layer.succeed(FetchHttpClient.RequestInit)({\n keepalive: false\n})))), /*#__PURE__*/Layer.provideMerge(/*#__PURE__*/layer(Http.createServer, {\n port: 0\n})));\n// -----------------------------------------------------------------------------\n// Internal\n// -----------------------------------------------------------------------------\nconst handleResponse = (request, response) => {\n const nodeResponse = request.resolvedResponse;\n if (nodeResponse.writableEnded) {\n return Effect.void;\n }\n let headers = response.headers;\n if (!Cookies.isEmpty(response.cookies)) {\n headers = {\n ...headers\n };\n const toSet = Cookies.toSetCookieHeaders(response.cookies);\n if (headers[\"set-cookie\"] !== undefined) {\n toSet.push(headers[\"set-cookie\"]);\n }\n headers[\"set-cookie\"] = toSet;\n }\n if (request.method === \"HEAD\") {\n nodeResponse.writeHead(response.status, headers);\n return Effect.andThen(cancelResponseBody(response.body), Effect.callback(resume => {\n let completed = false;\n const done = () => {\n if (completed) return;\n completed = true;\n nodeResponse.off(\"close\", done);\n resume(Effect.void);\n };\n nodeResponse.once(\"close\", done);\n nodeResponse.end(done);\n }));\n }\n const body = response.body;\n switch (body._tag) {\n case \"Empty\":\n {\n nodeResponse.writeHead(response.status, headers);\n nodeResponse.end();\n return Effect.void;\n }\n case \"Raw\":\n {\n nodeResponse.writeHead(response.status, headers);\n if (typeof body.body === \"object\" && body.body !== null && \"pipe\" in body.body && typeof body.body.pipe === \"function\") {\n return Effect.tryPromise({\n try: signal => pipeline(body.body, nodeResponse, {\n signal,\n end: true\n }),\n catch: cause => new HttpServerError({\n reason: new ResponseError({\n request,\n response,\n description: \"Error writing raw response\",\n cause\n })\n })\n }).pipe(Effect.interruptible, Effect.tapCause(handleCause(nodeResponse, response)));\n }\n return Effect.callback(resume => {\n nodeResponse.end(body.body, () => resume(Effect.void));\n });\n }\n case \"Uint8Array\":\n {\n nodeResponse.writeHead(response.status, headers);\n // If the body is less than 1MB, we skip the callback\n if (body.body.length < 1024 * 1024) {\n nodeResponse.end(body.body);\n return Effect.void;\n }\n return Effect.callback(resume => {\n nodeResponse.end(body.body, () => resume(Effect.void));\n });\n }\n case \"FormData\":\n {\n return Effect.suspend(() => {\n const r = new globalThis.Response(body.formData);\n nodeResponse.writeHead(response.status, {\n ...headers,\n ...Object.fromEntries(r.headers)\n });\n return Effect.callback((resume, signal) => {\n Readable.fromWeb(r.body, {\n signal\n }).pipe(nodeResponse).on(\"error\", cause => {\n resume(Effect.fail(new HttpServerError({\n reason: new ResponseError({\n request,\n response,\n description: \"Error writing FormData response\",\n cause\n })\n })));\n }).once(\"finish\", () => {\n resume(Effect.void);\n });\n }).pipe(Effect.interruptible, Effect.tapCause(handleCause(nodeResponse, response)));\n });\n }\n case \"Stream\":\n {\n nodeResponse.writeHead(response.status, headers);\n const drainLatch = Latch.makeUnsafe();\n nodeResponse.on(\"drain\", () => drainLatch.openUnsafe());\n return body.stream.pipe(Stream.orDie, Stream.runForEachArray(array => {\n const chunk = array.length > 1 ? Buffer.concat(array) : array[0];\n if (nodeResponse.write(chunk)) return Effect.void;\n drainLatch.closeUnsafe();\n return drainLatch.await;\n }), Effect.interruptible, Effect.matchCauseEffect({\n onSuccess: () => Effect.sync(() => nodeResponse.end()),\n onFailure: handleCause(nodeResponse, response)\n }));\n }\n }\n};\nconst cancelResponseBody = body => {\n const stream = body._tag === \"Raw\" ? body.body : undefined;\n if (stream instanceof Readable) {\n return Effect.sync(() => stream.destroy());\n }\n return Effect.void;\n};\nconst handleCause = (nodeResponse, originalResponse) => originalCause => Effect.flatMap(causeResponse(originalCause), ([response, cause]) => {\n const headersSent = nodeResponse.headersSent;\n if (!headersSent) {\n nodeResponse.writeHead(response.status);\n }\n if (!nodeResponse.writableEnded) {\n nodeResponse.end();\n }\n return Effect.failCause(headersSent ? Cause.combine(originalCause, Cause.die(originalResponse)) : cause);\n});\n//# sourceMappingURL=NodeHttpServer.js.map"],"x_google_ignoreList":[0,1,2,3,4,5],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAa,0BAAb,cAA6CA,MAAkB;;;;;;CAM7D,CAACC;CACD;CACA;CACA;CACA,YAAY,QAAQ,SAAS,uBAAuB;EAClD,MAAM;EACN,KAAKA,UAA0BA;EAC/B,KAAK,SAAS;EACd,KAAK,UAAU;EACf,KAAK,wBAAwB;CAC/B;CACA,IAAI,UAAU;EACZ,OAAOC,UAAkB,KAAK,OAAO,OAAO;CAC9C;CACA,IAAI,gBAAgB;EAClB,OAAO,KAAK,yBAAyBC,cAAqB,KAAK,OAAO,OAAO,aAAa;CAC5F;CACA;CACA,IAAI,OAAO;EACT,IAAI,KAAK,YACP,OAAO,KAAK;EAEd,KAAK,aAAaC,QAAeC,OAAcC,QAAeC,cAA6B,gBAAeC,eAA0B,KAAK,QAAQ;GAC/I,SAAS,KAAK;GACd,UAAU;EACZ,CAAC,CAAC,CAAC,CAAC;EACJ,KAAK,oBAAoBC,IAAW,KAAK,aAAY,MAAK,IAAI,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;EAC5F,OAAO,KAAK;CACd;CACA,IAAI,aAAa;EACf,OAAOL,QAAe,KAAK,IAAI;CACjC;CACA,IAAI,OAAO;EACT,OAAOE,QAAe,KAAK,OAAM,SAAQI,KAAW;GAClD,WAAW,SAAS,KAAK,OAAO,KAAK,MAAM,IAAI;GAC/C,OAAO,KAAK;E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