diff --git a/CHANGELOG.md b/CHANGELOG.md index d28243b..5226a77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,12 @@ green-tea uses calendar versioning: `YY.MM.PATCH`. ### Changed - App-scope providers now boot exactly once (memoized): a second `app.listen()` call no longer re-runs provider factories or their side effects. +- **`WsOpenCtx.req`** (available in `@Ws`/`@Sse` handlers) is now a neutral + `WsRequest` (`{ url, headers, protocol, ip }`) instead of the Node + `http.IncomingMessage`, so it works the same across Node and Deno. Node-only + fields such as `req.socket` / `req.rawHeaders` are no longer available on + `ctx.req`; use `ctx.protocol` / `ctx.ip` / `ctx.query` / `ctx.headers` + instead — all still provided. ## [26.7.0-beta.0] - 2026-07-07 diff --git a/src/deno.ts b/src/deno.ts index 008653e..eafe6dc 100644 --- a/src/deno.ts +++ b/src/deno.ts @@ -6,12 +6,13 @@ import type { WsSocket, WsRequest } from './http/ws-core'; // doesn't declare a global `WebSocket` either — so we ambient-declare just the shape we use // (both the instance interface and the `OPEN` static, mirroring the real WebSocket). interface WebSocketEventMap { - message: { data: unknown }; + message: { data: string | ArrayBuffer }; close: object; error: object; } interface WebSocket { readonly readyState: number; + binaryType: string; send(data: string): void; close(code?: number, reason?: string): void; addEventListener(type: K, listener: (event: WebSocketEventMap[K]) => void): void; @@ -58,7 +59,12 @@ function toWsRequest(request: Request, info: DenoServeHandlerInfo): WsRequest { function denoSocket(ws: WebSocket): WsSocket { const inbound = channel(); const ac = new AbortController(); - ws.addEventListener('message', (e) => inbound.push(typeof e.data === 'string' ? e.data : String(e.data))); + ws.binaryType = 'arraybuffer'; + const decoder = new TextDecoder(); + ws.addEventListener('message', (e) => { + const data = e.data; + inbound.push(typeof data === 'string' ? data : decoder.decode(data as ArrayBuffer)); + }); ws.addEventListener('close', () => { inbound.close(); ac.abort();