added fonts

This commit is contained in:
guus committed 2025-07-02 11:28:41 +02:00
1 parent 4134e3a234
commit 142d2986b6
9079 files changed
+1498421 -2

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
/**
* This file provides some helpers that should be used in conjunction with
* explicit environment checks. When combined with the environment checks, it
* will ensure that the correct typings are used as well as enable code
* elimination.
*/ /**
* Type guard to determine if a request is a WebNextRequest. This does not
* actually check the type of the request, but rather the runtime environment.
* It's expected that when the runtime environment is the edge runtime, that any
* base request is a WebNextRequest.
*/ export const isWebNextRequest = (req)=>process.env.NEXT_RUNTIME === 'edge';
/**
* Type guard to determine if a response is a WebNextResponse. This does not
* actually check the type of the response, but rather the runtime environment.
* It's expected that when the runtime environment is the edge runtime, that any
* base response is a WebNextResponse.
*/ export const isWebNextResponse = (res)=>process.env.NEXT_RUNTIME === 'edge';
/**
* Type guard to determine if a request is a NodeNextRequest. This does not
* actually check the type of the request, but rather the runtime environment.
* It's expected that when the runtime environment is the node runtime, that any
* base request is a NodeNextRequest.
*/ export const isNodeNextRequest = (req)=>process.env.NEXT_RUNTIME !== 'edge';
/**
* Type guard to determine if a response is a NodeNextResponse. This does not
* actually check the type of the response, but rather the runtime environment.
* It's expected that when the runtime environment is the node runtime, that any
* base response is a NodeNextResponse.
*/ export const isNodeNextResponse = (res)=>process.env.NEXT_RUNTIME !== 'edge';
//# sourceMappingURL=helpers.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/base-http/helpers.ts"],"sourcesContent":["import type { BaseNextRequest, BaseNextResponse } from './'\nimport type { NodeNextRequest, NodeNextResponse } from './node'\nimport type { WebNextRequest, WebNextResponse } from './web'\n\n/**\n * This file provides some helpers that should be used in conjunction with\n * explicit environment checks. When combined with the environment checks, it\n * will ensure that the correct typings are used as well as enable code\n * elimination.\n */\n\n/**\n * Type guard to determine if a request is a WebNextRequest. This does not\n * actually check the type of the request, but rather the runtime environment.\n * It's expected that when the runtime environment is the edge runtime, that any\n * base request is a WebNextRequest.\n */\nexport const isWebNextRequest = (req: BaseNextRequest): req is WebNextRequest =>\n process.env.NEXT_RUNTIME === 'edge'\n\n/**\n * Type guard to determine if a response is a WebNextResponse. This does not\n * actually check the type of the response, but rather the runtime environment.\n * It's expected that when the runtime environment is the edge runtime, that any\n * base response is a WebNextResponse.\n */\nexport const isWebNextResponse = (\n res: BaseNextResponse\n): res is WebNextResponse => process.env.NEXT_RUNTIME === 'edge'\n\n/**\n * Type guard to determine if a request is a NodeNextRequest. This does not\n * actually check the type of the request, but rather the runtime environment.\n * It's expected that when the runtime environment is the node runtime, that any\n * base request is a NodeNextRequest.\n */\nexport const isNodeNextRequest = (\n req: BaseNextRequest\n): req is NodeNextRequest => process.env.NEXT_RUNTIME !== 'edge'\n\n/**\n * Type guard to determine if a response is a NodeNextResponse. This does not\n * actually check the type of the response, but rather the runtime environment.\n * It's expected that when the runtime environment is the node runtime, that any\n * base response is a NodeNextResponse.\n */\nexport const isNodeNextResponse = (\n res: BaseNextResponse\n): res is NodeNextResponse => process.env.NEXT_RUNTIME !== 'edge'\n"],"names":["isWebNextRequest","req","process","env","NEXT_RUNTIME","isWebNextResponse","res","isNodeNextRequest","isNodeNextResponse"],"mappings":"AAIA;;;;;CAKC,GAED;;;;;CAKC,GACD,OAAO,MAAMA,mBAAmB,CAACC,MAC/BC,QAAQC,GAAG,CAACC,YAAY,KAAK,OAAM;AAErC;;;;;CAKC,GACD,OAAO,MAAMC,oBAAoB,CAC/BC,MAC2BJ,QAAQC,GAAG,CAACC,YAAY,KAAK,OAAM;AAEhE;;;;;CAKC,GACD,OAAO,MAAMG,oBAAoB,CAC/BN,MAC2BC,QAAQC,GAAG,CAACC,YAAY,KAAK,OAAM;AAEhE;;;;;CAKC,GACD,OAAO,MAAMI,qBAAqB,CAChCF,MAC4BJ,QAAQC,GAAG,CAACC,YAAY,KAAK,OAAM"}
+32
View File
@@ -0,0 +1,32 @@
import { RedirectStatusCode } from '../../client/components/redirect-status-code';
import { getCookieParser } from '../api-utils/get-cookie-parser';
export class BaseNextRequest {
constructor(method, url, body){
this.method = method;
this.url = url;
this.body = body;
}
// Utils implemented using the abstract methods above
get cookies() {
if (this._cookies) return this._cookies;
return this._cookies = getCookieParser(this.headers)();
}
}
export class BaseNextResponse {
constructor(destination){
this.destination = destination;
}
// Utils implemented using the abstract methods above
redirect(destination, statusCode) {
this.setHeader('Location', destination);
this.statusCode = statusCode;
// Since IE11 doesn't support the 308 header add backwards
// compatibility using refresh header
if (statusCode === RedirectStatusCode.PermanentRedirect) {
this.setHeader('Refresh', `0;url=${destination}`);
}
return this;
}
}
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/base-http/index.ts"],"sourcesContent":["import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http'\nimport type { I18NConfig } from '../config-shared'\n\nimport { RedirectStatusCode } from '../../client/components/redirect-status-code'\nimport type { NextApiRequestCookies } from '../api-utils'\nimport { getCookieParser } from '../api-utils/get-cookie-parser'\n\nexport interface BaseNextRequestConfig {\n basePath: string | undefined\n i18n?: I18NConfig\n trailingSlash?: boolean | undefined\n}\n\nexport type FetchMetric = {\n url: string\n idx: number\n end: number\n start: number\n method: string\n status: number\n cacheReason: string\n cacheStatus: 'hit' | 'miss' | 'skip' | 'hmr'\n cacheWarning?: string\n}\n\nexport type FetchMetrics = Array<FetchMetric>\n\nexport abstract class BaseNextRequest<Body = any> {\n protected _cookies: NextApiRequestCookies | undefined\n public abstract headers: IncomingHttpHeaders\n public abstract fetchMetrics: FetchMetric[] | undefined\n\n constructor(\n public method: string,\n public url: string,\n public body: Body\n ) {}\n\n // Utils implemented using the abstract methods above\n\n public get cookies() {\n if (this._cookies) return this._cookies\n return (this._cookies = getCookieParser(this.headers)())\n }\n}\n\nexport abstract class BaseNextResponse<Destination = any> {\n abstract statusCode: number | undefined\n abstract statusMessage: string | undefined\n abstract get sent(): boolean\n\n constructor(public destination: Destination) {}\n\n /**\n * Sets a value for the header overwriting existing values\n */\n abstract setHeader(name: string, value: string | string[]): this\n\n /**\n * Removes a header\n */\n abstract removeHeader(name: string): this\n\n /**\n * Appends value for the given header name\n */\n abstract appendHeader(name: string, value: string): this\n\n /**\n * Get all values for a header as an array or undefined if no value is present\n */\n abstract getHeaderValues(name: string): string[] | undefined\n\n abstract hasHeader(name: string): boolean\n\n /**\n * Get values for a header concatenated using `,` or undefined if no value is present\n */\n abstract getHeader(name: string): string | undefined\n\n abstract getHeaders(): OutgoingHttpHeaders\n\n abstract body(value: string): this\n\n abstract send(): void\n\n abstract onClose(callback: () => void): void\n\n // Utils implemented using the abstract methods above\n\n public redirect(destination: string, statusCode: number) {\n this.setHeader('Location', destination)\n this.statusCode = statusCode\n\n // Since IE11 doesn't support the 308 header add backwards\n // compatibility using refresh header\n if (statusCode === RedirectStatusCode.PermanentRedirect) {\n this.setHeader('Refresh', `0;url=${destination}`)\n }\n\n return this\n }\n}\n"],"names":["RedirectStatusCode","getCookieParser","BaseNextRequest","constructor","method","url","body","cookies","_cookies","headers","BaseNextResponse","destination","redirect","statusCode","setHeader","PermanentRedirect"],"mappings":"AAGA,SAASA,kBAAkB,QAAQ,+CAA8C;AAEjF,SAASC,eAAe,QAAQ,iCAAgC;AAsBhE,OAAO,MAAeC;IAKpBC,YACE,AAAOC,MAAc,EACrB,AAAOC,GAAW,EAClB,AAAOC,IAAU,CACjB;aAHOF,SAAAA;aACAC,MAAAA;aACAC,OAAAA;IACN;IAEH,qDAAqD;IAErD,IAAWC,UAAU;QACnB,IAAI,IAAI,CAACC,QAAQ,EAAE,OAAO,IAAI,CAACA,QAAQ;QACvC,OAAQ,IAAI,CAACA,QAAQ,GAAGP,gBAAgB,IAAI,CAACQ,OAAO;IACtD;AACF;AAEA,OAAO,MAAeC;IAKpBP,YAAY,AAAOQ,WAAwB,CAAE;aAA1BA,cAAAA;IAA2B;IAqC9C,qDAAqD;IAE9CC,SAASD,WAAmB,EAAEE,UAAkB,EAAE;QACvD,IAAI,CAACC,SAAS,CAAC,YAAYH;QAC3B,IAAI,CAACE,UAAU,GAAGA;QAElB,0DAA0D;QAC1D,qCAAqC;QACrC,IAAIA,eAAeb,mBAAmBe,iBAAiB,EAAE;YACvD,IAAI,CAACD,SAAS,CAAC,WAAW,CAAC,MAAM,EAAEH,aAAa;QAClD;QAEA,OAAO,IAAI;IACb;AACF"}
+125
View File
@@ -0,0 +1,125 @@
import { SYMBOL_CLEARED_COOKIES } from '../api-utils';
import { NEXT_REQUEST_META } from '../request-meta';
import { BaseNextRequest, BaseNextResponse } from './index';
let prop;
export class NodeNextRequest extends BaseNextRequest {
static #_ = prop = _NEXT_REQUEST_META = NEXT_REQUEST_META;
constructor(_req){
var _this__req;
super(_req.method.toUpperCase(), _req.url, _req), this._req = _req, this.headers = this._req.headers, this.fetchMetrics = (_this__req = this._req) == null ? void 0 : _this__req.fetchMetrics, this[_NEXT_REQUEST_META] = this._req[NEXT_REQUEST_META] || {}, this.streaming = false;
}
get originalRequest() {
// Need to mimic these changes to the original req object for places where we use it:
// render.tsx, api/ssg requests
this._req[NEXT_REQUEST_META] = this[NEXT_REQUEST_META];
this._req.url = this.url;
this._req.cookies = this.cookies;
return this._req;
}
set originalRequest(value) {
this._req = value;
}
/**
* Returns the request body as a Web Readable Stream. The body here can only
* be read once as the body will start flowing as soon as the data handler
* is attached.
*
* @internal
*/ stream() {
if (this.streaming) {
throw Object.defineProperty(new Error('Invariant: NodeNextRequest.stream() can only be called once'), "__NEXT_ERROR_CODE", {
value: "E467",
enumerable: false,
configurable: true
});
}
this.streaming = true;
return new ReadableStream({
start: (controller)=>{
this._req.on('data', (chunk)=>{
controller.enqueue(new Uint8Array(chunk));
});
this._req.on('end', ()=>{
controller.close();
});
this._req.on('error', (err)=>{
controller.error(err);
});
}
});
}
}
export class NodeNextResponse extends BaseNextResponse {
get originalResponse() {
if (SYMBOL_CLEARED_COOKIES in this) {
this._res[SYMBOL_CLEARED_COOKIES] = this[SYMBOL_CLEARED_COOKIES];
}
return this._res;
}
constructor(_res){
super(_res), this._res = _res, this.textBody = undefined;
}
get sent() {
return this._res.finished || this._res.headersSent;
}
get statusCode() {
return this._res.statusCode;
}
set statusCode(value) {
this._res.statusCode = value;
}
get statusMessage() {
return this._res.statusMessage;
}
set statusMessage(value) {
this._res.statusMessage = value;
}
setHeader(name, value) {
this._res.setHeader(name, value);
return this;
}
removeHeader(name) {
this._res.removeHeader(name);
return this;
}
getHeaderValues(name) {
const values = this._res.getHeader(name);
if (values === undefined) return undefined;
return (Array.isArray(values) ? values : [
values
]).map((value)=>value.toString());
}
hasHeader(name) {
return this._res.hasHeader(name);
}
getHeader(name) {
const values = this.getHeaderValues(name);
return Array.isArray(values) ? values.join(',') : undefined;
}
getHeaders() {
return this._res.getHeaders();
}
appendHeader(name, value) {
const currentValues = this.getHeaderValues(name) ?? [];
if (!currentValues.includes(value)) {
this._res.setHeader(name, [
...currentValues,
value
]);
}
return this;
}
body(value) {
this.textBody = value;
return this;
}
send() {
this._res.end(this.textBody);
}
onClose(callback) {
this.originalResponse.on('close', callback);
}
}
var _NEXT_REQUEST_META;
//# sourceMappingURL=node.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/base-http/node.ts"],"sourcesContent":["import type { ServerResponse, IncomingMessage } from 'http'\nimport type { Writable, Readable } from 'stream'\n\nimport { SYMBOL_CLEARED_COOKIES } from '../api-utils'\nimport type { NextApiRequestCookies } from '../api-utils'\n\nimport { NEXT_REQUEST_META } from '../request-meta'\nimport type { RequestMeta } from '../request-meta'\n\nimport { BaseNextRequest, BaseNextResponse, type FetchMetric } from './index'\nimport type { OutgoingHttpHeaders } from 'node:http'\n\ntype Req = IncomingMessage & {\n [NEXT_REQUEST_META]?: RequestMeta\n cookies?: NextApiRequestCookies\n fetchMetrics?: FetchMetric[]\n}\n\nexport class NodeNextRequest extends BaseNextRequest<Readable> {\n public headers = this._req.headers\n public fetchMetrics: FetchMetric[] | undefined = this._req?.fetchMetrics;\n\n [NEXT_REQUEST_META]: RequestMeta = this._req[NEXT_REQUEST_META] || {}\n\n constructor(private _req: Req) {\n super(_req.method!.toUpperCase(), _req.url!, _req)\n }\n\n get originalRequest() {\n // Need to mimic these changes to the original req object for places where we use it:\n // render.tsx, api/ssg requests\n this._req[NEXT_REQUEST_META] = this[NEXT_REQUEST_META]\n this._req.url = this.url\n this._req.cookies = this.cookies\n return this._req\n }\n\n set originalRequest(value: Req) {\n this._req = value\n }\n\n private streaming = false\n\n /**\n * Returns the request body as a Web Readable Stream. The body here can only\n * be read once as the body will start flowing as soon as the data handler\n * is attached.\n *\n * @internal\n */\n public stream() {\n if (this.streaming) {\n throw new Error(\n 'Invariant: NodeNextRequest.stream() can only be called once'\n )\n }\n this.streaming = true\n\n return new ReadableStream({\n start: (controller) => {\n this._req.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n this._req.on('end', () => {\n controller.close()\n })\n this._req.on('error', (err) => {\n controller.error(err)\n })\n },\n })\n }\n}\n\nexport class NodeNextResponse extends BaseNextResponse<Writable> {\n private textBody: string | undefined = undefined\n\n public [SYMBOL_CLEARED_COOKIES]?: boolean\n\n get originalResponse() {\n if (SYMBOL_CLEARED_COOKIES in this) {\n this._res[SYMBOL_CLEARED_COOKIES] = this[SYMBOL_CLEARED_COOKIES]\n }\n\n return this._res\n }\n\n constructor(\n private _res: ServerResponse & { [SYMBOL_CLEARED_COOKIES]?: boolean }\n ) {\n super(_res)\n }\n\n get sent() {\n return this._res.finished || this._res.headersSent\n }\n\n get statusCode() {\n return this._res.statusCode\n }\n\n set statusCode(value: number) {\n this._res.statusCode = value\n }\n\n get statusMessage() {\n return this._res.statusMessage\n }\n\n set statusMessage(value: string) {\n this._res.statusMessage = value\n }\n\n setHeader(name: string, value: string | string[]): this {\n this._res.setHeader(name, value)\n return this\n }\n\n removeHeader(name: string): this {\n this._res.removeHeader(name)\n return this\n }\n\n getHeaderValues(name: string): string[] | undefined {\n const values = this._res.getHeader(name)\n\n if (values === undefined) return undefined\n\n return (Array.isArray(values) ? values : [values]).map((value) =>\n value.toString()\n )\n }\n\n hasHeader(name: string): boolean {\n return this._res.hasHeader(name)\n }\n\n getHeader(name: string): string | undefined {\n const values = this.getHeaderValues(name)\n return Array.isArray(values) ? values.join(',') : undefined\n }\n\n getHeaders(): OutgoingHttpHeaders {\n return this._res.getHeaders()\n }\n\n appendHeader(name: string, value: string): this {\n const currentValues = this.getHeaderValues(name) ?? []\n\n if (!currentValues.includes(value)) {\n this._res.setHeader(name, [...currentValues, value])\n }\n\n return this\n }\n\n body(value: string) {\n this.textBody = value\n return this\n }\n\n send() {\n this._res.end(this.textBody)\n }\n\n public onClose(callback: () => void) {\n this.originalResponse.on('close', callback)\n }\n}\n"],"names":["SYMBOL_CLEARED_COOKIES","NEXT_REQUEST_META","BaseNextRequest","BaseNextResponse","NodeNextRequest","constructor","_req","method","toUpperCase","url","headers","fetchMetrics","streaming","originalRequest","cookies","value","stream","Error","ReadableStream","start","controller","on","chunk","enqueue","Uint8Array","close","err","error","NodeNextResponse","originalResponse","_res","textBody","undefined","sent","finished","headersSent","statusCode","statusMessage","setHeader","name","removeHeader","getHeaderValues","values","getHeader","Array","isArray","map","toString","hasHeader","join","getHeaders","appendHeader","cuLine truncated
+102
View File
@@ -0,0 +1,102 @@
import { toNodeOutgoingHttpHeaders } from '../web/utils';
import { BaseNextRequest, BaseNextResponse } from './index';
import { DetachedPromise } from '../../lib/detached-promise';
import { CloseController, trackBodyConsumed } from '../web/web-on-close';
import { InvariantError } from '../../shared/lib/invariant-error';
export class WebNextRequest extends BaseNextRequest {
constructor(request){
const url = new URL(request.url);
super(request.method, url.href.slice(url.origin.length), request.clone().body);
this.request = request;
this.fetchMetrics = request.fetchMetrics;
this.headers = {};
for (const [name, value] of request.headers.entries()){
this.headers[name] = value;
}
}
async parseBody(_limit) {
throw Object.defineProperty(new Error('parseBody is not implemented in the web runtime'), "__NEXT_ERROR_CODE", {
value: "E213",
enumerable: false,
configurable: true
});
}
}
export class WebNextResponse extends BaseNextResponse {
constructor(transformStream = new TransformStream()){
super(transformStream.writable), this.transformStream = transformStream, this.headers = new Headers(), this.textBody = undefined, this.closeController = new CloseController(), this.sendPromise = new DetachedPromise(), this._sent = false;
}
setHeader(name, value) {
this.headers.delete(name);
for (const val of Array.isArray(value) ? value : [
value
]){
this.headers.append(name, val);
}
return this;
}
removeHeader(name) {
this.headers.delete(name);
return this;
}
getHeaderValues(name) {
var _this_getHeader;
// https://developer.mozilla.org/docs/Web/API/Headers/get#example
return (_this_getHeader = this.getHeader(name)) == null ? void 0 : _this_getHeader.split(',').map((v)=>v.trimStart());
}
getHeader(name) {
return this.headers.get(name) ?? undefined;
}
getHeaders() {
return toNodeOutgoingHttpHeaders(this.headers);
}
hasHeader(name) {
return this.headers.has(name);
}
appendHeader(name, value) {
this.headers.append(name, value);
return this;
}
body(value) {
this.textBody = value;
return this;
}
send() {
this.sendPromise.resolve();
this._sent = true;
}
get sent() {
return this._sent;
}
async toResponse() {
// If we haven't called `send` yet, wait for it to be called.
if (!this.sent) await this.sendPromise.promise;
const body = this.textBody ?? this.transformStream.readable;
let bodyInit = body;
// if the response is streaming, onClose() can still be called after this point.
const canAddListenersLater = typeof bodyInit !== 'string';
const shouldTrackBody = canAddListenersLater ? true : this.closeController.listeners > 0;
if (shouldTrackBody) {
bodyInit = trackBodyConsumed(body, ()=>{
this.closeController.dispatchClose();
});
}
return new Response(bodyInit, {
headers: this.headers,
status: this.statusCode,
statusText: this.statusMessage
});
}
onClose(callback) {
if (this.closeController.isClosed) {
throw Object.defineProperty(new InvariantError('Cannot call onClose on a WebNextResponse that is already closed'), "__NEXT_ERROR_CODE", {
value: "E599",
enumerable: false,
configurable: true
});
}
return this.closeController.onClose(callback);
}
}
//# sourceMappingURL=web.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/base-http/web.ts"],"sourcesContent":["import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http'\nimport type { FetchMetrics } from './index'\n\nimport { toNodeOutgoingHttpHeaders } from '../web/utils'\nimport { BaseNextRequest, BaseNextResponse } from './index'\nimport { DetachedPromise } from '../../lib/detached-promise'\nimport type { NextRequestHint } from '../web/adapter'\nimport { CloseController, trackBodyConsumed } from '../web/web-on-close'\nimport { InvariantError } from '../../shared/lib/invariant-error'\n\nexport class WebNextRequest extends BaseNextRequest<ReadableStream | null> {\n public request: Request\n public headers: IncomingHttpHeaders\n public fetchMetrics: FetchMetrics | undefined\n\n constructor(request: NextRequestHint) {\n const url = new URL(request.url)\n\n super(\n request.method,\n url.href.slice(url.origin.length),\n request.clone().body\n )\n this.request = request\n this.fetchMetrics = request.fetchMetrics\n\n this.headers = {}\n for (const [name, value] of request.headers.entries()) {\n this.headers[name] = value\n }\n }\n\n async parseBody(_limit: string | number): Promise<any> {\n throw new Error('parseBody is not implemented in the web runtime')\n }\n}\n\nexport class WebNextResponse extends BaseNextResponse<WritableStream> {\n private headers = new Headers()\n private textBody: string | undefined = undefined\n\n private closeController = new CloseController()\n\n public statusCode: number | undefined\n public statusMessage: string | undefined\n\n constructor(public transformStream = new TransformStream()) {\n super(transformStream.writable)\n }\n\n setHeader(name: string, value: string | string[]): this {\n this.headers.delete(name)\n for (const val of Array.isArray(value) ? value : [value]) {\n this.headers.append(name, val)\n }\n return this\n }\n\n removeHeader(name: string): this {\n this.headers.delete(name)\n return this\n }\n\n getHeaderValues(name: string): string[] | undefined {\n // https://developer.mozilla.org/docs/Web/API/Headers/get#example\n return this.getHeader(name)\n ?.split(',')\n .map((v) => v.trimStart())\n }\n\n getHeader(name: string): string | undefined {\n return this.headers.get(name) ?? undefined\n }\n\n getHeaders(): OutgoingHttpHeaders {\n return toNodeOutgoingHttpHeaders(this.headers)\n }\n\n hasHeader(name: string): boolean {\n return this.headers.has(name)\n }\n\n appendHeader(name: string, value: string): this {\n this.headers.append(name, value)\n return this\n }\n\n body(value: string) {\n this.textBody = value\n return this\n }\n\n private readonly sendPromise = new DetachedPromise<void>()\n\n private _sent = false\n public send() {\n this.sendPromise.resolve()\n this._sent = true\n }\n\n get sent() {\n return this._sent\n }\n\n public async toResponse() {\n // If we haven't called `send` yet, wait for it to be called.\n if (!this.sent) await this.sendPromise.promise\n\n const body = this.textBody ?? this.transformStream.readable\n\n let bodyInit: BodyInit = body\n\n // if the response is streaming, onClose() can still be called after this point.\n const canAddListenersLater = typeof bodyInit !== 'string'\n const shouldTrackBody = canAddListenersLater\n ? true\n : this.closeController.listeners > 0\n\n if (shouldTrackBody) {\n bodyInit = trackBodyConsumed(body, () => {\n this.closeController.dispatchClose()\n })\n }\n\n return new Response(bodyInit, {\n headers: this.headers,\n status: this.statusCode,\n statusText: this.statusMessage,\n })\n }\n\n public onClose(callback: () => void) {\n if (this.closeController.isClosed) {\n throw new InvariantError(\n 'Cannot call onClose on a WebNextResponse that is already closed'\n )\n }\n return this.closeController.onClose(callback)\n }\n}\n"],"names":["toNodeOutgoingHttpHeaders","BaseNextRequest","BaseNextResponse","DetachedPromise","CloseController","trackBodyConsumed","InvariantError","WebNextRequest","constructor","request","url","URL","method","href","slice","origin","length","clone","body","fetchMetrics","headers","name","value","entries","parseBody","_limit","Error","WebNextResponse","transformStream","TransformStream","writable","Headers","textBody","undefined","closeController","sendPromise","_sent","setHeader","delete","val","Array","isArray","append","removeHeader","getHeaderValues","getHeader","split","map","v","trimStart","get","getHeaders","hasHeader","has","appendHeader","send","resolve","sent","toResponse","promise","readable","bodyInit","canAddListenersLater","shouldTrackBody","listeners","dispatchClose","Response","status","statusCode","statusText","statusMessage","onClose","callback","isClosed"],"mappings":"AAGA,SAASA,yBAAyB,QAAQ,eAAc;AACxD,SAASC,eAAe,EAAEC,gBAAgBLine truncated