|
| 1 | +// @effect-diagnostics nodeBuiltinImport:off |
| 2 | +import * as NodeHttp from "node:http"; |
| 3 | + |
| 4 | +import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer"; |
| 5 | +import * as NodeServices from "@effect/platform-node/NodeServices"; |
1 | 6 | import { EnvironmentHttpApi, ProviderDriverKind } from "@t3tools/contracts"; |
2 | 7 | import * as Cause from "effect/Cause"; |
3 | 8 | import * as Duration from "effect/Duration"; |
@@ -25,6 +30,7 @@ import { guardHttpResponseWriteErrors } from "./httpResponseErrorGuard.ts"; |
25 | 30 | import { fixPath } from "./os-jank.ts"; |
26 | 31 | import { websocketRpcRouteLayer } from "./ws.ts"; |
27 | 32 | import * as ExternalLauncher from "./process/externalLauncher.ts"; |
| 33 | +import * as NodePtyAdapter from "./terminal/NodePtyAdapter.ts"; |
28 | 34 | import { pullRequestHttpApiLayer } from "./pullRequest/http.ts"; |
29 | 35 | import * as PullRequestProviderRegistry from "./pullRequest/PullRequestProviderRegistry.ts"; |
30 | 36 | import * as PullRequestService from "./pullRequest/PullRequestService.ts"; |
@@ -158,17 +164,7 @@ const ApplicationObservabilityLive = ObservabilityLive.pipe( |
158 | 164 | Layer.provideMerge(ResourceAttributionLayerLive), |
159 | 165 | ); |
160 | 166 |
|
161 | | -const PtyAdapterLive = Layer.unwrap( |
162 | | - Effect.gen(function* () { |
163 | | - if (typeof Bun !== "undefined") { |
164 | | - const BunPtyAdapter = yield* Effect.promise(() => import("./terminal/BunPtyAdapter.ts")); |
165 | | - return BunPtyAdapter.layer; |
166 | | - } else { |
167 | | - const NodePtyAdapter = yield* Effect.promise(() => import("./terminal/NodePtyAdapter.ts")); |
168 | | - return NodePtyAdapter.layer; |
169 | | - } |
170 | | - }), |
171 | | -); |
| 167 | +const PtyAdapterLive = NodePtyAdapter.layer; |
172 | 168 |
|
173 | 169 | const ServerSettingsLayerLive = ServerSettings.layer.pipe( |
174 | 170 | Layer.provide(ServerSecretStore.layer), |
@@ -221,61 +217,22 @@ const RelayClientLive = Layer.unwrap( |
221 | 217 | const HttpServerLive = Layer.unwrap( |
222 | 218 | Effect.gen(function* () { |
223 | 219 | const config = yield* ServerConfig.ServerConfig; |
224 | | - if (typeof Bun !== "undefined") { |
225 | | - const BunHttpServer = yield* Effect.promise( |
226 | | - () => import("@effect/platform-bun/BunHttpServer"), |
227 | | - ); |
228 | | - return BunHttpServer.layer({ |
229 | | - port: config.port, |
230 | | - hostname: config.host ?? "127.0.0.1", |
231 | | - gracefulShutdownTimeout: HTTP_PREEMPTIVE_SHUTDOWN_GRACE_MS, |
232 | | - websocket: { |
233 | | - // Negotiate permessage-deflate with clients that offer it; clients |
234 | | - // that don't still get uncompressed frames on their connection. A |
235 | | - // dedicated compressor keeps a per-connection sliding window |
236 | | - // (context takeover) so the compression dictionary is shared across |
237 | | - // server-to-client frames. Decompression uses the shared |
238 | | - // decompressor: uWebSockets' dedicated decompressor path can abort |
239 | | - // connections (close 1006) on valid DEFLATE input — see |
240 | | - // https://github.com/uNetworking/uWebSockets.js/issues/633. |
241 | | - perMessageDeflate: { |
242 | | - compress: "dedicated", |
243 | | - decompress: "shared", |
244 | | - }, |
245 | | - }, |
246 | | - }); |
247 | | - } else { |
248 | | - const [NodeHttpServer, NodeHttp] = yield* Effect.all([ |
249 | | - Effect.promise(() => import("@effect/platform-node/NodeHttpServer")), |
250 | | - Effect.promise(() => import("node:http")), |
251 | | - ]); |
252 | | - return NodeHttpServer.layer(() => guardHttpResponseWriteErrors(NodeHttp.createServer()), { |
253 | | - host: config.host ?? "127.0.0.1", |
254 | | - port: config.port, |
255 | | - gracefulShutdownTimeout: HTTP_PREEMPTIVE_SHUTDOWN_GRACE_MS, |
256 | | - // Negotiate permessage-deflate with clients that offer it; clients |
257 | | - // that don't still get uncompressed frames on their connection. |
258 | | - // Context takeover stays enabled (ws default) so the compression |
259 | | - // window is shared across frames — that also makes small frames cheap |
260 | | - // to compress, so no size threshold is set (ws only honors |
261 | | - // `threshold` when context takeover is disabled). |
262 | | - websocket: { perMessageDeflate: true }, |
263 | | - }); |
264 | | - } |
| 220 | + return NodeHttpServer.layer(() => guardHttpResponseWriteErrors(NodeHttp.createServer()), { |
| 221 | + host: config.host ?? "127.0.0.1", |
| 222 | + port: config.port, |
| 223 | + gracefulShutdownTimeout: HTTP_PREEMPTIVE_SHUTDOWN_GRACE_MS, |
| 224 | + // Negotiate permessage-deflate with clients that offer it; clients |
| 225 | + // that don't still get uncompressed frames on their connection. |
| 226 | + // Context takeover stays enabled (ws default) so the compression |
| 227 | + // window is shared across frames — that also makes small frames cheap |
| 228 | + // to compress, so no size threshold is set (ws only honors |
| 229 | + // `threshold` when context takeover is disabled). |
| 230 | + websocket: { perMessageDeflate: true }, |
| 231 | + }); |
265 | 232 | }), |
266 | 233 | ); |
267 | 234 |
|
268 | | -const PlatformServicesLive = Layer.unwrap( |
269 | | - Effect.gen(function* () { |
270 | | - if (typeof Bun !== "undefined") { |
271 | | - const { layer } = yield* Effect.promise(() => import("@effect/platform-bun/BunServices")); |
272 | | - return layer; |
273 | | - } else { |
274 | | - const { layer } = yield* Effect.promise(() => import("@effect/platform-node/NodeServices")); |
275 | | - return layer; |
276 | | - } |
277 | | - }), |
278 | | -); |
| 235 | +const PlatformServicesLive = NodeServices.layer; |
279 | 236 |
|
280 | 237 | const ReactorLayerLive = Layer.empty.pipe( |
281 | 238 | Layer.provideMerge(OrchestrationReactorLive), |
|
0 commit comments