diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a7c8e46..030dd5d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 1.4.8 +Change: +- make `file-type` optional to reduce bundle size +- [#1432](https://github.com/elysiajs/elysia/pull/1432) missing context (set) in mapResponse for ElysiaFile +- [#1435](https://github.com/elysiajs/elysia/pull/1435) missing cookies in SSE + # 1.4.7 - 22 Sep 2025 Feature: - experimental `adapter/cloudflare-worker` diff --git a/bun.lock b/bun.lock index 19ffd95f..c607881e 100644 --- a/bun.lock +++ b/bun.lock @@ -28,10 +28,6 @@ "valibot": "^1.1.0", "zod": "^4.1.5", }, - "optionalDependencies": { - "@sinclair/typebox": ">= 0.34.0 < 1", - "openapi-types": ">= 12.0.0", - }, "peerDependencies": { "@sinclair/typebox": ">= 0.34.0 < 1", "exact-mirror": ">= 0.0.9", @@ -39,6 +35,10 @@ "openapi-types": ">= 12.0.0", "typescript": ">= 5.0.0", }, + "optionalPeers": [ + "file-type", + "typescript", + ], }, }, "packages": { diff --git a/example/a.ts b/example/a.ts index 4bfe6808..ff56fc64 100644 --- a/example/a.ts +++ b/example/a.ts @@ -1,30 +1,9 @@ import { Elysia, t } from '../src' +import { sucrose } from '../src/sucrose' import { req } from '../test/utils' const app = new Elysia() - .wrap((fn, request) => { - const _request = request.clone() - - return () => { - try { - return fn(request.clone()) - } catch { - console.log('ER') - } - } - }) - .onError(({ error }) => { - if (error) throw error - }) - .get('/', () => { - throw new Error('A') - - return 'Hello World!' - }) + .get('/:id', ({ params: { id } }) => 'hello') .listen(3000) -// console.log(app.fetch.toString()) - -app.handle(req('/')) - .then((x) => x.text()) - .then(console.log) +// app.handle(req('/1')) diff --git a/package.json b/package.json index bf1dc4a0..223a0397 100644 --- a/package.json +++ b/package.json @@ -219,8 +219,12 @@ "openapi-types": ">= 12.0.0", "typescript": ">= 5.0.0" }, - "optionalDependencies": { - "@sinclair/typebox": ">= 0.34.0 < 1", - "openapi-types": ">= 12.0.0" + "peerDependenciesMeta": { + "file-type": { + "optional": true + }, + "typescript": { + "optional": true + } } } diff --git a/src/adapter/bun/handler.ts b/src/adapter/bun/handler.ts index daf754b9..aa26d2f7 100644 --- a/src/adapter/bun/handler.ts +++ b/src/adapter/bun/handler.ts @@ -8,9 +8,7 @@ import { createResponseHandler, createStreamHandler, handleFile, - handleSet, - responseToSetHeaders, - streamResponse + handleSet } from '../utils' import { ElysiaFile } from '../../universal/file' @@ -41,14 +39,14 @@ export const mapResponse = ( case 'ElysiaFile': return handleFile( (response as ElysiaFile).value as File, - set as any + set ) case 'File': - return handleFile(response as File, set as any) + return handleFile(response as File, set) case 'Blob': - return handleFile(response as Blob, set as any) + return handleFile(response as Blob, set) case 'ElysiaCustomStatusResponse': set.status = (response as ElysiaCustomStatusResponse<200>).code @@ -182,10 +180,10 @@ export const mapEarlyResponse = ( return new Response(JSON.stringify(response), set as any) case 'ElysiaFile': - return handleFile((response as ElysiaFile).value as File) + return handleFile((response as ElysiaFile).value as File, set) case 'File': - return handleFile(response as File, set as any) + return handleFile(response as File, set) case 'Blob': return handleFile(response as File | Blob, set) @@ -300,10 +298,10 @@ export const mapEarlyResponse = ( return new Response(JSON.stringify(response), set as any) case 'ElysiaFile': - return handleFile((response as ElysiaFile).value as File) + return handleFile((response as ElysiaFile).value as File, set) case 'File': - return handleFile(response as File, set as any) + return handleFile(response as File, set) case 'Blob': return handleFile(response as File | Blob, set) diff --git a/src/adapter/web-standard/handler.ts b/src/adapter/web-standard/handler.ts index 1743d0bc..18121d3b 100644 --- a/src/adapter/web-standard/handler.ts +++ b/src/adapter/web-standard/handler.ts @@ -70,10 +70,10 @@ export const mapResponse = ( return handleElysiaFile(response as ElysiaFile, set) case 'File': - return handleFile(response as File, set as any) + return handleFile(response as File, set) case 'Blob': - return handleFile(response as Blob, set as any) + return handleFile(response as Blob, set) case 'ElysiaCustomStatusResponse': set.status = (response as ElysiaCustomStatusResponse<200>).code @@ -211,7 +211,7 @@ export const mapEarlyResponse = ( return handleElysiaFile(response as ElysiaFile, set) case 'File': - return handleFile(response as File, set as any) + return handleFile(response as File, set) case 'Blob': return handleFile(response as File | Blob, set) @@ -330,7 +330,7 @@ export const mapEarlyResponse = ( return handleElysiaFile(response as ElysiaFile, set) case 'File': - return handleFile(response as File, set as any) + return handleFile(response as File, set) case 'Blob': return handleFile(response as File | Blob, set) diff --git a/src/compose.ts b/src/compose.ts index 52fde76d..5ab6cecf 100644 --- a/src/compose.ts +++ b/src/compose.ts @@ -484,11 +484,8 @@ export const composeHandler = ({ const hasTrace = !!hooks.trace?.length let fnLiteral = '' - inference = sucrose(hooks, inference) inference = sucrose( - { - handler: handler as any - }, + Object.assign({ handler: handler as any }, hooks), inference ) diff --git a/src/sucrose.ts b/src/sucrose.ts index 3bc567d0..cc451d19 100644 --- a/src/sucrose.ts +++ b/src/sucrose.ts @@ -642,7 +642,9 @@ export const sucrose = ( if (typeof event !== 'function') continue const content = event.toString() + console.log(content) const key = checksum(content) + console.log(key) const cachedInference = caches[key] if (cachedInference) { inference = mergeInference(inference, cachedInference)