import type Koa from "koa"; import type { VextResponse } from "../../types/response.js"; import type { RouteOptions } from "../../types/app.js"; /** * Koa Context → VextResponse 转换 * * 核心设计(与 Hono / Fastify / Express Adapter 的 response.ts 逻辑对齐): * * 1. 延迟绑定 requestId(getRequestId getter) * 2. 内建出口包装(_wrapEnabled 标志) * 3. 重复发送保护(_sent 标志) * 4. 链式调用(status / setHeader 返回 this) * 5. 204 No Content 合规(RFC 9110 §15.3.5) * 6. 手动 JSON 序列化 via ctx.res.end(JSON.stringify(...)) * 7. Deferred terminal flush — json/rawJson/text/html/redirect stage into * `_pending` and only write the host response in `_flush()` after the onion * chain unwinds, so post-`await next()` middleware can still setHeader/cookie. * * @param ctx Koa Context 对象 * @param getRequestId 延迟获取 requestId 的 getter 函数 * @returns VextResponse 实例(含内部方法 _enableWrap) */ export declare function createVextResponse(ctx: Koa.Context, getRequestId: () => string, closeToken?: object, routeOptions?: RouteOptions, routeMethod?: string): VextResponse;