main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

8
node_modules/next/dist/server/web/adapter.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type { NextMiddleware, RequestData, FetchEventResult } from './types';
export type AdapterOptions = {
handler: NextMiddleware;
page: string;
request: RequestData;
IncrementalCache?: typeof import('../lib/incremental-cache').IncrementalCache;
};
export declare function adapter(params: AdapterOptions): Promise<FetchEventResult>;

262
node_modules/next/dist/server/web/adapter.js generated vendored Normal file
View File

@@ -0,0 +1,262 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "adapter", {
enumerable: true,
get: function() {
return adapter;
}
});
const _error = require("./error");
const _utils = require("./utils");
const _fetchevent = require("./spec-extension/fetch-event");
const _request = require("./spec-extension/request");
const _response = require("./spec-extension/response");
const _relativizeurl = require("../../shared/lib/router/utils/relativize-url");
const _nexturl = require("./next-url");
const _internalutils = require("../internal-utils");
const _apppaths = require("../../shared/lib/router/utils/app-paths");
const _approuterheaders = require("../../client/components/app-router-headers");
const _constants = require("../../lib/constants");
const _globals = require("./globals");
const _requestasyncstoragewrapper = require("../async-storage/request-async-storage-wrapper");
const _requestasyncstorageexternal = require("../../client/components/request-async-storage.external");
class NextRequestHint extends _request.NextRequest {
constructor(params){
super(params.input, params.init);
this.sourcePage = params.page;
}
get request() {
throw new _error.PageSignatureError({
page: this.sourcePage
});
}
respondWith() {
throw new _error.PageSignatureError({
page: this.sourcePage
});
}
waitUntil() {
throw new _error.PageSignatureError({
page: this.sourcePage
});
}
}
const FLIGHT_PARAMETERS = [
[
_approuterheaders.RSC
],
[
_approuterheaders.NEXT_ROUTER_STATE_TREE
],
[
_approuterheaders.NEXT_ROUTER_PREFETCH
]
];
async function adapter(params) {
await (0, _globals.ensureInstrumentationRegistered)();
// TODO-APP: use explicit marker for this
const isEdgeRendering = typeof self.__BUILD_MANIFEST !== "undefined";
const prerenderManifest = typeof self.__PRERENDER_MANIFEST === "string" ? JSON.parse(self.__PRERENDER_MANIFEST) : undefined;
params.request.url = (0, _apppaths.normalizeRscPath)(params.request.url, true);
const requestUrl = new _nexturl.NextURL(params.request.url, {
headers: params.request.headers,
nextConfig: params.request.nextConfig
});
// Iterator uses an index to keep track of the current iteration. Because of deleting and appending below we can't just use the iterator.
// Instead we use the keys before iteration.
const keys = [
...requestUrl.searchParams.keys()
];
for (const key of keys){
const value = requestUrl.searchParams.getAll(key);
if (key !== _constants.NEXT_QUERY_PARAM_PREFIX && key.startsWith(_constants.NEXT_QUERY_PARAM_PREFIX)) {
const normalizedKey = key.substring(_constants.NEXT_QUERY_PARAM_PREFIX.length);
requestUrl.searchParams.delete(normalizedKey);
for (const val of value){
requestUrl.searchParams.append(normalizedKey, val);
}
requestUrl.searchParams.delete(key);
}
}
// Ensure users only see page requests, never data requests.
const buildId = requestUrl.buildId;
requestUrl.buildId = "";
const isDataReq = params.request.headers["x-nextjs-data"];
if (isDataReq && requestUrl.pathname === "/index") {
requestUrl.pathname = "/";
}
const requestHeaders = (0, _utils.fromNodeOutgoingHttpHeaders)(params.request.headers);
const flightHeaders = new Map();
// Parameters should only be stripped for middleware
if (!isEdgeRendering) {
for (const param of FLIGHT_PARAMETERS){
const key = param.toString().toLowerCase();
const value = requestHeaders.get(key);
if (value) {
flightHeaders.set(key, requestHeaders.get(key));
requestHeaders.delete(key);
}
}
}
const normalizeUrl = process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE ? new URL(params.request.url) : requestUrl;
const request = new NextRequestHint({
page: params.page,
// Strip internal query parameters off the request.
input: (0, _internalutils.stripInternalSearchParams)(normalizeUrl, true).toString(),
init: {
body: params.request.body,
geo: params.request.geo,
headers: requestHeaders,
ip: params.request.ip,
method: params.request.method,
nextConfig: params.request.nextConfig,
signal: params.request.signal
}
});
/**
* This allows to identify the request as a data request. The user doesn't
* need to know about this property neither use it. We add it for testing
* purposes.
*/ if (isDataReq) {
Object.defineProperty(request, "__isData", {
enumerable: false,
value: true
});
}
if (!globalThis.__incrementalCache && params.IncrementalCache) {
globalThis.__incrementalCache = new params.IncrementalCache({
appDir: true,
fetchCache: true,
minimalMode: process.env.NODE_ENV !== "development",
fetchCacheKeyPrefix: process.env.__NEXT_FETCH_CACHE_KEY_PREFIX,
dev: process.env.NODE_ENV === "development",
requestHeaders: params.request.headers,
requestProtocol: "https",
getPrerenderManifest: ()=>{
return {
version: -1,
routes: {},
dynamicRoutes: {},
notFoundRoutes: [],
preview: {
previewModeId: "development-id"
}
};
}
});
}
const event = new _fetchevent.NextFetchEvent({
request,
page: params.page
});
let response;
let cookiesFromResponse;
// we only care to make async storage available for middleware
const isMiddleware = params.page === "/middleware" || params.page === "/src/middleware";
if (isMiddleware) {
response = await _requestasyncstoragewrapper.RequestAsyncStorageWrapper.wrap(_requestasyncstorageexternal.requestAsyncStorage, {
req: request,
renderOpts: {
onUpdateCookies: (cookies)=>{
cookiesFromResponse = cookies;
},
// @ts-expect-error: TODO: investigate why previewProps isn't on RenderOpts
previewProps: (prerenderManifest == null ? void 0 : prerenderManifest.preview) || {
previewModeId: "development-id",
previewModeEncryptionKey: "",
previewModeSigningKey: ""
}
}
}, ()=>params.handler(request, event));
} else {
response = await params.handler(request, event);
}
// check if response is a Response object
if (response && !(response instanceof Response)) {
throw new TypeError("Expected an instance of Response to be returned");
}
if (response && cookiesFromResponse) {
response.headers.set("set-cookie", cookiesFromResponse);
}
/**
* For rewrites we must always include the locale in the final pathname
* so we re-create the NextURL forcing it to include it when the it is
* an internal rewrite. Also we make sure the outgoing rewrite URL is
* a data URL if the request was a data request.
*/ const rewrite = response == null ? void 0 : response.headers.get("x-middleware-rewrite");
if (response && rewrite) {
const rewriteUrl = new _nexturl.NextURL(rewrite, {
forceLocale: true,
headers: params.request.headers,
nextConfig: params.request.nextConfig
});
if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE) {
if (rewriteUrl.host === request.nextUrl.host) {
rewriteUrl.buildId = buildId || rewriteUrl.buildId;
response.headers.set("x-middleware-rewrite", String(rewriteUrl));
}
}
/**
* When the request is a data request we must show if there was a rewrite
* with an internal header so the client knows which component to load
* from the data request.
*/ const relativizedRewrite = (0, _relativizeurl.relativizeURL)(String(rewriteUrl), String(requestUrl));
if (isDataReq && // if the rewrite is external and external rewrite
// resolving config is enabled don't add this header
// so the upstream app can set it instead
!(process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE && relativizedRewrite.match(/http(s)?:\/\//))) {
response.headers.set("x-nextjs-rewrite", relativizedRewrite);
}
}
/**
* For redirects we will not include the locale in case when it is the
* default and we must also make sure the outgoing URL is a data one if
* the incoming request was a data request.
*/ const redirect = response == null ? void 0 : response.headers.get("Location");
if (response && redirect && !isEdgeRendering) {
const redirectURL = new _nexturl.NextURL(redirect, {
forceLocale: false,
headers: params.request.headers,
nextConfig: params.request.nextConfig
});
/**
* Responses created from redirects have immutable headers so we have
* to clone the response to be able to modify it.
*/ response = new Response(response.body, response);
if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE) {
if (redirectURL.host === request.nextUrl.host) {
redirectURL.buildId = buildId || redirectURL.buildId;
response.headers.set("Location", String(redirectURL));
}
}
/**
* When the request is a data request we can't use the location header as
* it may end up with CORS error. Instead we map to an internal header so
* the client knows the destination.
*/ if (isDataReq) {
response.headers.delete("Location");
response.headers.set("x-nextjs-redirect", (0, _relativizeurl.relativizeURL)(String(redirectURL), String(requestUrl)));
}
}
const finalResponse = response ? response : _response.NextResponse.next();
// Flight headers are not overridable / removable so they are applied at the end.
const middlewareOverrideHeaders = finalResponse.headers.get("x-middleware-override-headers");
const overwrittenHeaders = [];
if (middlewareOverrideHeaders) {
for (const [key, value] of flightHeaders){
finalResponse.headers.set(`x-middleware-request-${key}`, value);
overwrittenHeaders.push(key);
}
if (overwrittenHeaders.length > 0) {
finalResponse.headers.set("x-middleware-override-headers", middlewareOverrideHeaders + "," + overwrittenHeaders.join(","));
}
}
return {
response: finalResponse,
waitUntil: Promise.all(event[_fetchevent.waitUntilSymbol])
};
}
//# sourceMappingURL=adapter.js.map

1
node_modules/next/dist/server/web/adapter.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
import type { AppRouteRouteModule } from '../future/route-modules/app-route/module';
import './globals';
import { type AdapterOptions } from './adapter';
type WrapOptions = Partial<Pick<AdapterOptions, 'page'>>;
/**
* EdgeRouteModuleWrapper is a wrapper around a route module.
*
* Note that this class should only be used in the edge runtime.
*/
export declare class EdgeRouteModuleWrapper {
private readonly routeModule;
private readonly matcher;
/**
* The constructor is wrapped with private to ensure that it can only be
* constructed by the static wrap method.
*
* @param routeModule the route module to wrap
*/
private constructor();
/**
* This will wrap a module with the EdgeModuleWrapper and return a function
* that can be used as a handler for the edge runtime.
*
* @param module the module to wrap
* @param options any options that should be passed to the adapter and
* override the ones passed from the runtime
* @returns a function that can be used as a handler for the edge runtime
*/
static wrap(routeModule: AppRouteRouteModule, options?: WrapOptions): (opts: AdapterOptions) => Promise<import("./types").FetchEventResult>;
private handler;
}
export {};

View File

@@ -0,0 +1,90 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "EdgeRouteModuleWrapper", {
enumerable: true,
get: function() {
return EdgeRouteModuleWrapper;
}
});
require("./globals");
const _adapter = require("./adapter");
const _incrementalcache = require("../lib/incremental-cache");
const _routematcher = require("../future/route-matchers/route-matcher");
const _removetrailingslash = require("../../shared/lib/router/utils/remove-trailing-slash");
const _removepathprefix = require("../../shared/lib/router/utils/remove-path-prefix");
class EdgeRouteModuleWrapper {
/**
* The constructor is wrapped with private to ensure that it can only be
* constructed by the static wrap method.
*
* @param routeModule the route module to wrap
*/ constructor(routeModule){
this.routeModule = routeModule;
// TODO: (wyattjoh) possibly allow the module to define it's own matcher
this.matcher = new _routematcher.RouteMatcher(routeModule.definition);
}
/**
* This will wrap a module with the EdgeModuleWrapper and return a function
* that can be used as a handler for the edge runtime.
*
* @param module the module to wrap
* @param options any options that should be passed to the adapter and
* override the ones passed from the runtime
* @returns a function that can be used as a handler for the edge runtime
*/ static wrap(routeModule, options = {}) {
// Create the module wrapper.
const wrapper = new EdgeRouteModuleWrapper(routeModule);
// Return the wrapping function.
return (opts)=>{
return (0, _adapter.adapter)({
...opts,
...options,
IncrementalCache: _incrementalcache.IncrementalCache,
// Bind the handler method to the wrapper so it still has context.
handler: wrapper.handler.bind(wrapper)
});
};
}
async handler(request) {
// Get the pathname for the matcher. Pathnames should not have trailing
// slashes for matching.
let pathname = (0, _removetrailingslash.removeTrailingSlash)(new URL(request.url).pathname);
// Get the base path and strip it from the pathname if it exists.
const { basePath } = request.nextUrl;
if (basePath) {
// If the path prefix doesn't exist, then this will do nothing.
pathname = (0, _removepathprefix.removePathPrefix)(pathname, basePath);
}
// Get the match for this request.
const match = this.matcher.match(pathname);
if (!match) {
throw new Error(`Invariant: no match found for request. Pathname '${pathname}' should have matched '${this.matcher.definition.pathname}'`);
}
const prerenderManifest = typeof self.__PRERENDER_MANIFEST === "string" ? JSON.parse(self.__PRERENDER_MANIFEST) : undefined;
// Create the context for the handler. This contains the params from the
// match (if any).
const context = {
params: match.params,
prerenderManifest: {
version: 4,
routes: {},
dynamicRoutes: {},
preview: (prerenderManifest == null ? void 0 : prerenderManifest.preview) || {
previewModeEncryptionKey: "",
previewModeId: "development-id",
previewModeSigningKey: ""
},
notFoundRoutes: []
},
staticGenerationContext: {
supportsDynamicHTML: true
}
};
// Get the response from the handler.
return await this.routeModule.handle(request, context);
}
}
//# sourceMappingURL=edge-route-module-wrapper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/web/edge-route-module-wrapper.ts"],"names":["EdgeRouteModuleWrapper","routeModule","matcher","RouteMatcher","definition","wrap","options","wrapper","opts","adapter","IncrementalCache","handler","bind","request","pathname","removeTrailingSlash","URL","url","basePath","nextUrl","removePathPrefix","match","Error","prerenderManifest","self","__PRERENDER_MANIFEST","JSON","parse","undefined","context","params","version","routes","dynamicRoutes","preview","previewModeEncryptionKey","previewModeId","previewModeSigningKey","notFoundRoutes","staticGenerationContext","supportsDynamicHTML","handle"],"mappings":";;;;+BAsBaA;;;eAAAA;;;QAfN;yBAEsC;kCACZ;8BACJ;qCACO;kCACH;AAS1B,MAAMA;IAGX;;;;;GAKC,GACD,YAAqCC,YAAkC;2BAAlCA;QACnC,wEAAwE;QACxE,IAAI,CAACC,OAAO,GAAG,IAAIC,0BAAY,CAACF,YAAYG,UAAU;IACxD;IAEA;;;;;;;;GAQC,GACD,OAAcC,KACZJ,WAAgC,EAChCK,UAAuB,CAAC,CAAC,EACzB;QACA,6BAA6B;QAC7B,MAAMC,UAAU,IAAIP,uBAAuBC;QAE3C,gCAAgC;QAChC,OAAO,CAACO;YACN,OAAOC,IAAAA,gBAAO,EAAC;gBACb,GAAGD,IAAI;gBACP,GAAGF,OAAO;gBACVI,kBAAAA,kCAAgB;gBAChB,kEAAkE;gBAClEC,SAASJ,QAAQI,OAAO,CAACC,IAAI,CAACL;YAChC;QACF;IACF;IAEA,MAAcI,QAAQE,OAAoB,EAAqB;QAC7D,uEAAuE;QACvE,wBAAwB;QACxB,IAAIC,WAAWC,IAAAA,wCAAmB,EAAC,IAAIC,IAAIH,QAAQI,GAAG,EAAEH,QAAQ;QAEhE,iEAAiE;QACjE,MAAM,EAAEI,QAAQ,EAAE,GAAGL,QAAQM,OAAO;QACpC,IAAID,UAAU;YACZ,+DAA+D;YAC/DJ,WAAWM,IAAAA,kCAAgB,EAACN,UAAUI;QACxC;QAEA,kCAAkC;QAClC,MAAMG,QAAQ,IAAI,CAACnB,OAAO,CAACmB,KAAK,CAACP;QACjC,IAAI,CAACO,OAAO;YACV,MAAM,IAAIC,MACR,CAAC,iDAAiD,EAAER,SAAS,uBAAuB,EAAE,IAAI,CAACZ,OAAO,CAACE,UAAU,CAACU,QAAQ,CAAC,CAAC,CAAC;QAE7H;QAEA,MAAMS,oBACJ,OAAOC,KAAKC,oBAAoB,KAAK,WACjCC,KAAKC,KAAK,CAACH,KAAKC,oBAAoB,IACpCG;QAEN,wEAAwE;QACxE,kBAAkB;QAClB,MAAMC,UAAuC;YAC3CC,QAAQT,MAAMS,MAAM;YACpBP,mBAAmB;gBACjBQ,SAAS;gBACTC,QAAQ,CAAC;gBACTC,eAAe,CAAC;gBAChBC,SAASX,CAAAA,qCAAAA,kBAAmBW,OAAO,KAAI;oBACrCC,0BAA0B;oBAC1BC,eAAe;oBACfC,uBAAuB;gBACzB;gBACAC,gBAAgB,EAAE;YACpB;YACAC,yBAAyB;gBACvBC,qBAAqB;YACvB;QACF;QAEA,qCAAqC;QACrC,OAAO,MAAM,IAAI,CAACvC,WAAW,CAACwC,MAAM,CAAC5B,SAASgB;IAChD;AACF"}

11
node_modules/next/dist/server/web/error.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
export declare class PageSignatureError extends Error {
constructor({ page }: {
page: string;
});
}
export declare class RemovedPageError extends Error {
constructor();
}
export declare class RemovedUAError extends Error {
constructor();
}

54
node_modules/next/dist/server/web/error.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
PageSignatureError: null,
RemovedPageError: null,
RemovedUAError: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
PageSignatureError: function() {
return PageSignatureError;
},
RemovedPageError: function() {
return RemovedPageError;
},
RemovedUAError: function() {
return RemovedUAError;
}
});
class PageSignatureError extends Error {
constructor({ page }){
super(`The middleware "${page}" accepts an async API directly with the form:
export function middleware(request, event) {
return NextResponse.redirect('/new-location')
}
Read more: https://nextjs.org/docs/messages/middleware-new-signature
`);
}
}
class RemovedPageError extends Error {
constructor(){
super(`The request.page has been deprecated in favour of \`URLPattern\`.
Read more: https://nextjs.org/docs/messages/middleware-request-page
`);
}
}
class RemovedUAError extends Error {
constructor(){
super(`The request.ua has been removed in favour of \`userAgent\` function.
Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
`);
}
}
//# sourceMappingURL=error.js.map

1
node_modules/next/dist/server/web/error.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/web/error.ts"],"names":["PageSignatureError","RemovedPageError","RemovedUAError","Error","constructor","page"],"mappings":";;;;;;;;;;;;;;;;IAAaA,kBAAkB;eAAlBA;;IAaAC,gBAAgB;eAAhBA;;IAQAC,cAAc;eAAdA;;;AArBN,MAAMF,2BAA2BG;IACtCC,YAAY,EAAEC,IAAI,EAAoB,CAAE;QACtC,KAAK,CAAC,CAAC,gBAAgB,EAAEA,KAAK;;;;;;;EAOhC,CAAC;IACD;AACF;AAEO,MAAMJ,yBAAyBE;IACpCC,aAAc;QACZ,KAAK,CAAC,CAAC;;EAET,CAAC;IACD;AACF;AAEO,MAAMF,uBAAuBC;IAClCC,aAAc;QACZ,KAAK,CAAC,CAAC;;EAET,CAAC;IACD;AACF"}

View File

@@ -0,0 +1 @@
export { ImageResponse as default } from '../spec-extension/image-response';

View File

@@ -0,0 +1,14 @@
// This file is for modularized imports for next/server to get fully-treeshaking.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _imageresponse.ImageResponse;
}
});
const _imageresponse = require("../spec-extension/image-response");
//# sourceMappingURL=image-response.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/exports/image-response.ts"],"names":["default","ImageResponse"],"mappings":"AAAA,iFAAiF;;;;;+BACvDA;;;eAAjBC,4BAAa;;;+BAAmB"}

6
node_modules/next/dist/server/web/exports/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export { default as ImageResponse } from './image-response';
export { default as NextRequest } from './next-request';
export { default as NextResponse } from './next-response';
export { default as userAgent } from './user-agent';
export { default as userAgentFromString } from './user-agent-from-string';
export { default as URLPattern } from './url-pattern';

52
node_modules/next/dist/server/web/exports/index.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
// Alias index file of next/server for edge runtime for tree-shaking purpose
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
ImageResponse: null,
NextRequest: null,
NextResponse: null,
userAgent: null,
userAgentFromString: null,
URLPattern: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
ImageResponse: function() {
return _imageresponse.default;
},
NextRequest: function() {
return _nextrequest.default;
},
NextResponse: function() {
return _nextresponse.default;
},
userAgent: function() {
return _useragent.default;
},
userAgentFromString: function() {
return _useragentfromstring.default;
},
URLPattern: function() {
return _urlpattern.default;
}
});
const _imageresponse = /*#__PURE__*/ _interop_require_default(require("./image-response"));
const _nextrequest = /*#__PURE__*/ _interop_require_default(require("./next-request"));
const _nextresponse = /*#__PURE__*/ _interop_require_default(require("./next-response"));
const _useragent = /*#__PURE__*/ _interop_require_default(require("./user-agent"));
const _useragentfromstring = /*#__PURE__*/ _interop_require_default(require("./user-agent-from-string"));
const _urlpattern = /*#__PURE__*/ _interop_require_default(require("./url-pattern"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/exports/index.ts"],"names":["ImageResponse","NextRequest","NextResponse","userAgent","userAgentFromString","URLPattern"],"mappings":"AAAA,4EAA4E;;;;;;;;;;;;;;;;;;;;IAExDA,aAAa;eAAbA,sBAAa;;IACbC,WAAW;eAAXA,oBAAW;;IACXC,YAAY;eAAZA,qBAAY;;IACZC,SAAS;eAATA,kBAAS;;IACTC,mBAAmB;eAAnBA,4BAAmB;;IACnBC,UAAU;eAAVA,mBAAU;;;sEALW;oEACF;qEACC;kEACH;4EACU;mEACT"}

View File

@@ -0,0 +1 @@
export { NextRequest as default } from '../spec-extension/request';

View File

@@ -0,0 +1,14 @@
// This file is for modularized imports for next/server to get fully-treeshaking.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _request.NextRequest;
}
});
const _request = require("../spec-extension/request");
//# sourceMappingURL=next-request.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/exports/next-request.ts"],"names":["default","NextRequest"],"mappings":"AAAA,iFAAiF;;;;;+BACzDA;;;eAAfC,oBAAW;;;yBAAmB"}

View File

@@ -0,0 +1 @@
export { NextResponse as default } from '../spec-extension/response';

View File

@@ -0,0 +1,14 @@
// This file is for modularized imports for next/server to get fully-treeshaking.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _response.NextResponse;
}
});
const _response = require("../spec-extension/response");
//# sourceMappingURL=next-response.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/exports/next-response.ts"],"names":["default","NextResponse"],"mappings":"AAAA,iFAAiF;;;;;+BACxDA;;;eAAhBC,sBAAY;;;0BAAmB"}

View File

@@ -0,0 +1 @@
export { revalidatePath as default } from '../spec-extension/revalidate-path';

View File

@@ -0,0 +1,14 @@
// This file is for modularized imports for next/server to get fully-treeshaking.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _revalidatepath.revalidatePath;
}
});
const _revalidatepath = require("../spec-extension/revalidate-path");
//# sourceMappingURL=revalidate-path.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/exports/revalidate-path.ts"],"names":["default","revalidatePath"],"mappings":"AAAA,iFAAiF;;;;;+BACtDA;;;eAAlBC,8BAAc;;;gCAAmB"}

View File

@@ -0,0 +1 @@
export { revalidateTag as default } from '../spec-extension/revalidate-tag';

View File

@@ -0,0 +1,14 @@
// This file is for modularized imports for next/server to get fully-treeshaking.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _revalidatetag.revalidateTag;
}
});
const _revalidatetag = require("../spec-extension/revalidate-tag");
//# sourceMappingURL=revalidate-tag.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/exports/revalidate-tag.ts"],"names":["default","revalidateTag"],"mappings":"AAAA,iFAAiF;;;;;+BACvDA;;;eAAjBC,4BAAa;;;+BAAmB"}

View File

@@ -0,0 +1 @@
export { unstable_cache as default } from '../spec-extension/unstable-cache';

View File

@@ -0,0 +1,14 @@
// This file is for modularized imports for next/server to get fully-treeshaking.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _unstablecache.unstable_cache;
}
});
const _unstablecache = require("../spec-extension/unstable-cache");
//# sourceMappingURL=unstable-cache.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/exports/unstable-cache.ts"],"names":["default","unstable_cache"],"mappings":"AAAA,iFAAiF;;;;;+BACtDA;;;eAAlBC,6BAAc;;;+BAAmB"}

View File

@@ -0,0 +1,2 @@
declare const GlobalURLPattern: any;
export default GlobalURLPattern;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _default;
}
});
const GlobalURLPattern = // @ts-expect-error: URLPattern is not available in Node.js
typeof URLPattern === "undefined" ? undefined : URLPattern;
const _default = GlobalURLPattern;
//# sourceMappingURL=url-pattern.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/exports/url-pattern.ts"],"names":["GlobalURLPattern","URLPattern","undefined"],"mappings":";;;;+BAIA;;;eAAA;;;AAJA,MAAMA,mBACJ,2DAA2D;AAC3D,OAAOC,eAAe,cAAcC,YAAYD;MAElD,WAAeD"}

View File

@@ -0,0 +1 @@
export { userAgentFromString as default } from '../spec-extension/user-agent';

View File

@@ -0,0 +1,14 @@
// This file is for modularized imports for next/server to get fully-treeshaking.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _useragent.userAgentFromString;
}
});
const _useragent = require("../spec-extension/user-agent");
//# sourceMappingURL=user-agent-from-string.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/exports/user-agent-from-string.ts"],"names":["default","userAgentFromString"],"mappings":"AAAA,iFAAiF;;;;;+BACjDA;;;eAAvBC,8BAAmB;;;2BAAmB"}

View File

@@ -0,0 +1 @@
export { userAgent as default } from '../spec-extension/user-agent';

View File

@@ -0,0 +1,14 @@
// This file is for modularized imports for next/server to get fully-treeshaking.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _useragent.userAgent;
}
});
const _useragent = require("../spec-extension/user-agent");
//# sourceMappingURL=user-agent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/exports/user-agent.ts"],"names":["default","userAgent"],"mappings":"AAAA,iFAAiF;;;;;+BAC3DA;;;eAAbC,oBAAS;;;2BAAmB"}

1
node_modules/next/dist/server/web/globals.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare function ensureInstrumentationRegistered(): Promise<void>;

74
node_modules/next/dist/server/web/globals.js generated vendored Normal file
View File

@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "ensureInstrumentationRegistered", {
enumerable: true,
get: function() {
return ensureInstrumentationRegistered;
}
});
async function registerInstrumentation() {
if ("_ENTRIES" in globalThis && _ENTRIES.middleware_instrumentation && _ENTRIES.middleware_instrumentation.register) {
try {
await _ENTRIES.middleware_instrumentation.register();
} catch (err) {
err.message = `An error occurred while loading instrumentation hook: ${err.message}`;
throw err;
}
}
}
let registerInstrumentationPromise = null;
function ensureInstrumentationRegistered() {
if (!registerInstrumentationPromise) {
registerInstrumentationPromise = registerInstrumentation();
}
return registerInstrumentationPromise;
}
function getUnsupportedModuleErrorMessage(module) {
// warning: if you change these messages, you must adjust how react-dev-overlay's middleware detects modules not found
return `The edge runtime does not support Node.js '${module}' module.
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
}
function __import_unsupported(moduleName) {
const proxy = new Proxy(function() {}, {
get (_obj, prop) {
if (prop === "then") {
return {};
}
throw new Error(getUnsupportedModuleErrorMessage(moduleName));
},
construct () {
throw new Error(getUnsupportedModuleErrorMessage(moduleName));
},
apply (_target, _this, args) {
if (typeof args[0] === "function") {
return args[0](proxy);
}
throw new Error(getUnsupportedModuleErrorMessage(moduleName));
}
});
return new Proxy({}, {
get: ()=>proxy
});
}
function enhanceGlobals() {
// The condition is true when the "process" module is provided
if (process !== global.process) {
// prefer local process but global.process has correct "env"
process.env = global.process.env;
global.process = process;
}
// to allow building code that import but does not use node.js modules,
// webpack will expect this function to exist in global scope
Object.defineProperty(globalThis, "__import_unsupported", {
value: __import_unsupported,
enumerable: false,
configurable: false
});
// Eagerly fire instrumentation hook to make the startup faster.
void ensureInstrumentationRegistered();
}
enhanceGlobals();
//# sourceMappingURL=globals.js.map

1
node_modules/next/dist/server/web/globals.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/web/globals.ts"],"names":["ensureInstrumentationRegistered","registerInstrumentation","globalThis","_ENTRIES","middleware_instrumentation","register","err","message","registerInstrumentationPromise","getUnsupportedModuleErrorMessage","module","__import_unsupported","moduleName","proxy","Proxy","get","_obj","prop","Error","construct","apply","_target","_this","args","enhanceGlobals","process","global","env","Object","defineProperty","value","enumerable","configurable"],"mappings":";;;;+BAkBgBA;;;eAAAA;;;AAhBhB,eAAeC;IACb,IACE,cAAcC,cACdC,SAASC,0BAA0B,IACnCD,SAASC,0BAA0B,CAACC,QAAQ,EAC5C;QACA,IAAI;YACF,MAAMF,SAASC,0BAA0B,CAACC,QAAQ;QACpD,EAAE,OAAOC,KAAU;YACjBA,IAAIC,OAAO,GAAG,CAAC,sDAAsD,EAAED,IAAIC,OAAO,CAAC,CAAC;YACpF,MAAMD;QACR;IACF;AACF;AAEA,IAAIE,iCAAuD;AACpD,SAASR;IACd,IAAI,CAACQ,gCAAgC;QACnCA,iCAAiCP;IACnC;IACA,OAAOO;AACT;AAEA,SAASC,iCAAiCC,MAAc;IACtD,sHAAsH;IACtH,OAAO,CAAC,2CAA2C,EAAEA,OAAO;wEACU,CAAC;AACzE;AAEA,SAASC,qBAAqBC,UAAkB;IAC9C,MAAMC,QAAa,IAAIC,MAAM,YAAa,GAAG;QAC3CC,KAAIC,IAAI,EAAEC,IAAI;YACZ,IAAIA,SAAS,QAAQ;gBACnB,OAAO,CAAC;YACV;YACA,MAAM,IAAIC,MAAMT,iCAAiCG;QACnD;QACAO;YACE,MAAM,IAAID,MAAMT,iCAAiCG;QACnD;QACAQ,OAAMC,OAAO,EAAEC,KAAK,EAAEC,IAAI;YACxB,IAAI,OAAOA,IAAI,CAAC,EAAE,KAAK,YAAY;gBACjC,OAAOA,IAAI,CAAC,EAAE,CAACV;YACjB;YACA,MAAM,IAAIK,MAAMT,iCAAiCG;QACnD;IACF;IACA,OAAO,IAAIE,MAAM,CAAC,GAAG;QAAEC,KAAK,IAAMF;IAAM;AAC1C;AAEA,SAASW;IACP,8DAA8D;IAC9D,IAAIC,YAAYC,OAAOD,OAAO,EAAE;QAC9B,4DAA4D;QAC5DA,QAAQE,GAAG,GAAGD,OAAOD,OAAO,CAACE,GAAG;QAChCD,OAAOD,OAAO,GAAGA;IACnB;IAEA,uEAAuE;IACvE,6DAA6D;IAC7DG,OAAOC,cAAc,CAAC3B,YAAY,wBAAwB;QACxD4B,OAAOnB;QACPoB,YAAY;QACZC,cAAc;IAChB;IAEA,gEAAgE;IAChE,KAAKhC;AACP;AAEAwB"}

18
node_modules/next/dist/server/web/http.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
/**
* List of valid HTTP methods that can be implemented by Next.js's Custom App
* Routes.
*/
export declare const HTTP_METHODS: readonly ["GET", "HEAD", "OPTIONS", "POST", "PUT", "DELETE", "PATCH"];
/**
* A type representing the valid HTTP methods that can be implemented by
* Next.js's Custom App Routes.
*/
export type HTTP_METHOD = (typeof HTTP_METHODS)[number];
/**
* Checks to see if the passed string is an HTTP method. Note that this is case
* sensitive.
*
* @param maybeMethod the string that may be an HTTP method
* @returns true if the string is an HTTP method
*/
export declare function isHTTPMethod(maybeMethod: string): maybeMethod is HTTP_METHOD;

39
node_modules/next/dist/server/web/http.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
/**
* List of valid HTTP methods that can be implemented by Next.js's Custom App
* Routes.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
HTTP_METHODS: null,
isHTTPMethod: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
HTTP_METHODS: function() {
return HTTP_METHODS;
},
isHTTPMethod: function() {
return isHTTPMethod;
}
});
const HTTP_METHODS = [
"GET",
"HEAD",
"OPTIONS",
"POST",
"PUT",
"DELETE",
"PATCH"
];
function isHTTPMethod(maybeMethod) {
return HTTP_METHODS.includes(maybeMethod);
}
//# sourceMappingURL=http.js.map

1
node_modules/next/dist/server/web/http.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/web/http.ts"],"names":["HTTP_METHODS","isHTTPMethod","maybeMethod","includes"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;;;;;IACYA,YAAY;eAAZA;;IAuBGC,YAAY;eAAZA;;;AAvBT,MAAMD,eAAe;IAC1B;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAeM,SAASC,aAAaC,WAAmB;IAC9C,OAAOF,aAAaG,QAAQ,CAACD;AAC/B"}

58
node_modules/next/dist/server/web/next-url.d.ts generated vendored Normal file
View File

@@ -0,0 +1,58 @@
/// <reference types="node" />
import type { OutgoingHttpHeaders } from 'http';
import type { DomainLocale, I18NConfig } from '../config-shared';
import type { I18NProvider } from '../future/helpers/i18n-provider';
interface Options {
base?: string | URL;
headers?: OutgoingHttpHeaders;
forceLocale?: boolean;
nextConfig?: {
basePath?: string;
i18n?: I18NConfig | null;
trailingSlash?: boolean;
};
i18nProvider?: I18NProvider;
}
declare const Internal: unique symbol;
export declare class NextURL {
private [Internal];
constructor(input: string | URL, base?: string | URL, opts?: Options);
constructor(input: string | URL, opts?: Options);
private analyze;
private formatPathname;
private formatSearch;
get buildId(): string | undefined;
set buildId(buildId: string | undefined);
get locale(): string;
set locale(locale: string);
get defaultLocale(): string | undefined;
get domainLocale(): DomainLocale | undefined;
get searchParams(): URLSearchParams;
get host(): string;
set host(value: string);
get hostname(): string;
set hostname(value: string);
get port(): string;
set port(value: string);
get protocol(): string;
set protocol(value: string);
get href(): string;
set href(url: string);
get origin(): string;
get pathname(): string;
set pathname(value: string);
get hash(): string;
set hash(value: string);
get search(): string;
set search(value: string);
get password(): string;
set password(value: string);
get username(): string;
set username(value: string);
get basePath(): string;
set basePath(value: string);
toString(): string;
toJSON(): string;
clone(): NextURL;
}
export {};

191
node_modules/next/dist/server/web/next-url.js generated vendored Normal file
View File

@@ -0,0 +1,191 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "NextURL", {
enumerable: true,
get: function() {
return NextURL;
}
});
const _detectdomainlocale = require("../../shared/lib/i18n/detect-domain-locale");
const _formatnextpathnameinfo = require("../../shared/lib/router/utils/format-next-pathname-info");
const _gethostname = require("../../shared/lib/get-hostname");
const _getnextpathnameinfo = require("../../shared/lib/router/utils/get-next-pathname-info");
const REGEX_LOCALHOST_HOSTNAME = /(?!^https?:\/\/)(127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|\[::1\]|localhost)/;
function parseURL(url, base) {
return new URL(String(url).replace(REGEX_LOCALHOST_HOSTNAME, "localhost"), base && String(base).replace(REGEX_LOCALHOST_HOSTNAME, "localhost"));
}
const Internal = Symbol("NextURLInternal");
class NextURL {
constructor(input, baseOrOpts, opts){
let base;
let options;
if (typeof baseOrOpts === "object" && "pathname" in baseOrOpts || typeof baseOrOpts === "string") {
base = baseOrOpts;
options = opts || {};
} else {
options = opts || baseOrOpts || {};
}
this[Internal] = {
url: parseURL(input, base ?? options.base),
options: options,
basePath: ""
};
this.analyze();
}
analyze() {
var _this_Internal_options_nextConfig_i18n, _this_Internal_options_nextConfig, _this_Internal_domainLocale, _this_Internal_options_nextConfig_i18n1, _this_Internal_options_nextConfig1;
const info = (0, _getnextpathnameinfo.getNextPathnameInfo)(this[Internal].url.pathname, {
nextConfig: this[Internal].options.nextConfig,
parseData: !process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE,
i18nProvider: this[Internal].options.i18nProvider
});
const hostname = (0, _gethostname.getHostname)(this[Internal].url, this[Internal].options.headers);
this[Internal].domainLocale = this[Internal].options.i18nProvider ? this[Internal].options.i18nProvider.detectDomainLocale(hostname) : (0, _detectdomainlocale.detectDomainLocale)((_this_Internal_options_nextConfig = this[Internal].options.nextConfig) == null ? void 0 : (_this_Internal_options_nextConfig_i18n = _this_Internal_options_nextConfig.i18n) == null ? void 0 : _this_Internal_options_nextConfig_i18n.domains, hostname);
const defaultLocale = ((_this_Internal_domainLocale = this[Internal].domainLocale) == null ? void 0 : _this_Internal_domainLocale.defaultLocale) || ((_this_Internal_options_nextConfig1 = this[Internal].options.nextConfig) == null ? void 0 : (_this_Internal_options_nextConfig_i18n1 = _this_Internal_options_nextConfig1.i18n) == null ? void 0 : _this_Internal_options_nextConfig_i18n1.defaultLocale);
this[Internal].url.pathname = info.pathname;
this[Internal].defaultLocale = defaultLocale;
this[Internal].basePath = info.basePath ?? "";
this[Internal].buildId = info.buildId;
this[Internal].locale = info.locale ?? defaultLocale;
this[Internal].trailingSlash = info.trailingSlash;
}
formatPathname() {
return (0, _formatnextpathnameinfo.formatNextPathnameInfo)({
basePath: this[Internal].basePath,
buildId: this[Internal].buildId,
defaultLocale: !this[Internal].options.forceLocale ? this[Internal].defaultLocale : undefined,
locale: this[Internal].locale,
pathname: this[Internal].url.pathname,
trailingSlash: this[Internal].trailingSlash
});
}
formatSearch() {
return this[Internal].url.search;
}
get buildId() {
return this[Internal].buildId;
}
set buildId(buildId) {
this[Internal].buildId = buildId;
}
get locale() {
return this[Internal].locale ?? "";
}
set locale(locale) {
var _this_Internal_options_nextConfig_i18n, _this_Internal_options_nextConfig;
if (!this[Internal].locale || !((_this_Internal_options_nextConfig = this[Internal].options.nextConfig) == null ? void 0 : (_this_Internal_options_nextConfig_i18n = _this_Internal_options_nextConfig.i18n) == null ? void 0 : _this_Internal_options_nextConfig_i18n.locales.includes(locale))) {
throw new TypeError(`The NextURL configuration includes no locale "${locale}"`);
}
this[Internal].locale = locale;
}
get defaultLocale() {
return this[Internal].defaultLocale;
}
get domainLocale() {
return this[Internal].domainLocale;
}
get searchParams() {
return this[Internal].url.searchParams;
}
get host() {
return this[Internal].url.host;
}
set host(value) {
this[Internal].url.host = value;
}
get hostname() {
return this[Internal].url.hostname;
}
set hostname(value) {
this[Internal].url.hostname = value;
}
get port() {
return this[Internal].url.port;
}
set port(value) {
this[Internal].url.port = value;
}
get protocol() {
return this[Internal].url.protocol;
}
set protocol(value) {
this[Internal].url.protocol = value;
}
get href() {
const pathname = this.formatPathname();
const search = this.formatSearch();
return `${this.protocol}//${this.host}${pathname}${search}${this.hash}`;
}
set href(url) {
this[Internal].url = parseURL(url);
this.analyze();
}
get origin() {
return this[Internal].url.origin;
}
get pathname() {
return this[Internal].url.pathname;
}
set pathname(value) {
this[Internal].url.pathname = value;
}
get hash() {
return this[Internal].url.hash;
}
set hash(value) {
this[Internal].url.hash = value;
}
get search() {
return this[Internal].url.search;
}
set search(value) {
this[Internal].url.search = value;
}
get password() {
return this[Internal].url.password;
}
set password(value) {
this[Internal].url.password = value;
}
get username() {
return this[Internal].url.username;
}
set username(value) {
this[Internal].url.username = value;
}
get basePath() {
return this[Internal].basePath;
}
set basePath(value) {
this[Internal].basePath = value.startsWith("/") ? value : `/${value}`;
}
toString() {
return this.href;
}
toJSON() {
return this.href;
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return {
href: this.href,
origin: this.origin,
protocol: this.protocol,
username: this.username,
password: this.password,
host: this.host,
hostname: this.hostname,
port: this.port,
pathname: this.pathname,
search: this.search,
searchParams: this.searchParams,
hash: this.hash
};
}
clone() {
return new NextURL(String(this), this[Internal].options);
}
}
//# sourceMappingURL=next-url.js.map

1
node_modules/next/dist/server/web/next-url.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

28
node_modules/next/dist/server/web/sandbox/context.d.ts generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import { EdgeRuntime } from 'next/dist/compiled/edge-runtime';
import type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin';
/**
* For a given path a context, this function checks if there is any module
* context that contains the path with an older content and, if that's the
* case, removes the context from the cache.
*/
export declare function clearModuleContext(path: string): Promise<void>;
interface ModuleContextOptions {
moduleName: string;
onWarning: (warn: Error) => void;
useCache: boolean;
distDir: string;
edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'assets' | 'wasm'>;
}
/**
* For a given module name this function will get a cached module
* context or create it. It will return the module context along
* with a function that allows to run some code from a given
* filepath within the context.
*/
export declare function getModuleContext(options: ModuleContextOptions): Promise<{
evaluateInContext: (filepath: string) => void;
runtime: EdgeRuntime;
paths: Map<string, string>;
warnedEvals: Set<string>;
}>;
export {};

375
node_modules/next/dist/server/web/sandbox/context.js generated vendored Normal file
View File

@@ -0,0 +1,375 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
clearModuleContext: null,
getModuleContext: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
clearModuleContext: function() {
return clearModuleContext;
},
getModuleContext: function() {
return getModuleContext;
}
});
const _async_hooks = require("async_hooks");
const _middleware = require("next/dist/compiled/@next/react-dev-overlay/dist/middleware");
const _constants = require("../../../shared/lib/constants");
const _edgeruntime = require("next/dist/compiled/edge-runtime");
const _fs = require("fs");
const _utils = require("../utils");
const _pick = require("../../../lib/pick");
const _fetchinlineassets = require("./fetch-inline-assets");
const _vm = require("vm");
const _nodebuffer = /*#__PURE__*/ _interop_require_default(require("node:buffer"));
const _nodeevents = /*#__PURE__*/ _interop_require_default(require("node:events"));
const _nodeassert = /*#__PURE__*/ _interop_require_default(require("node:assert"));
const _nodeutil = /*#__PURE__*/ _interop_require_default(require("node:util"));
const _nodeasync_hooks = /*#__PURE__*/ _interop_require_default(require("node:async_hooks"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
/**
* A Map of cached module contexts indexed by the module name. It allows
* to have a different cache scoped per module name or depending on the
* provided module key on creation.
*/ const moduleContexts = new Map();
const pendingModuleCaches = new Map();
async function clearModuleContext(path) {
const handleContext = (key, cache, context)=>{
if (cache == null ? void 0 : cache.paths.has(path)) {
context.delete(key);
}
};
for (const [key, cache] of moduleContexts){
handleContext(key, cache, moduleContexts);
}
for (const [key, cache] of pendingModuleCaches){
handleContext(key, await cache, pendingModuleCaches);
}
}
async function loadWasm(wasm) {
const modules = {};
await Promise.all(wasm.map(async (binding)=>{
const module1 = await WebAssembly.compile(await _fs.promises.readFile(binding.filePath));
modules[binding.name] = module1;
}));
return modules;
}
function buildEnvironmentVariablesFrom() {
const pairs = Object.keys(process.env).map((key)=>[
key,
process.env[key]
]);
const env = Object.fromEntries(pairs);
env.NEXT_RUNTIME = "edge";
return env;
}
function throwUnsupportedAPIError(name) {
const error = new Error(`A Node.js API is used (${name}) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime`);
(0, _middleware.decorateServerError)(error, _constants.COMPILER_NAMES.edgeServer);
throw error;
}
function createProcessPolyfill() {
const processPolyfill = {
env: buildEnvironmentVariablesFrom()
};
const overridenValue = {};
for (const key of Object.keys(process)){
if (key === "env") continue;
Object.defineProperty(processPolyfill, key, {
get () {
if (overridenValue[key] !== undefined) {
return overridenValue[key];
}
if (typeof process[key] === "function") {
return ()=>throwUnsupportedAPIError(`process.${key}`);
}
return undefined;
},
set (value) {
overridenValue[key] = value;
},
enumerable: false
});
}
return processPolyfill;
}
function addStub(context, name) {
Object.defineProperty(context, name, {
get () {
return function() {
throwUnsupportedAPIError(name);
};
},
enumerable: false
});
}
function getDecorateUnhandledError(runtime) {
const EdgeRuntimeError = runtime.evaluate(`Error`);
return (error)=>{
if (error instanceof EdgeRuntimeError) {
(0, _middleware.decorateServerError)(error, _constants.COMPILER_NAMES.edgeServer);
}
};
}
function getDecorateUnhandledRejection(runtime) {
const EdgeRuntimeError = runtime.evaluate(`Error`);
return (rejected)=>{
if (rejected.reason instanceof EdgeRuntimeError) {
(0, _middleware.decorateServerError)(rejected.reason, _constants.COMPILER_NAMES.edgeServer);
}
};
}
const NativeModuleMap = (()=>{
const mods = {
"node:buffer": (0, _pick.pick)(_nodebuffer.default, [
"constants",
"kMaxLength",
"kStringMaxLength",
"Buffer",
"SlowBuffer"
]),
"node:events": (0, _pick.pick)(_nodeevents.default, [
"EventEmitter",
"captureRejectionSymbol",
"defaultMaxListeners",
"errorMonitor",
"listenerCount",
"on",
"once"
]),
"node:async_hooks": (0, _pick.pick)(_nodeasync_hooks.default, [
"AsyncLocalStorage",
"AsyncResource"
]),
"node:assert": (0, _pick.pick)(_nodeassert.default, [
"AssertionError",
"deepEqual",
"deepStrictEqual",
"doesNotMatch",
"doesNotReject",
"doesNotThrow",
"equal",
"fail",
"ifError",
"match",
"notDeepEqual",
"notDeepStrictEqual",
"notEqual",
"notStrictEqual",
"ok",
"rejects",
"strict",
"strictEqual",
"throws"
]),
"node:util": (0, _pick.pick)(_nodeutil.default, [
"_extend",
"callbackify",
"format",
"inherits",
"promisify",
"types"
])
};
return new Map(Object.entries(mods));
})();
/**
* Create a module cache specific for the provided parameters. It includes
* a runtime context, require cache and paths cache.
*/ async function createModuleContext(options) {
const warnedEvals = new Set();
const warnedWasmCodegens = new Set();
const wasm = await loadWasm(options.edgeFunctionEntry.wasm ?? []);
const runtime = new _edgeruntime.EdgeRuntime({
codeGeneration: process.env.NODE_ENV !== "production" ? {
strings: true,
wasm: true
} : undefined,
extend: (context)=>{
context.process = createProcessPolyfill();
Object.defineProperty(context, "require", {
enumerable: false,
value: (id)=>{
const value = NativeModuleMap.get(id);
if (!value) {
throw TypeError("Native module not found: " + id);
}
return value;
}
});
context.__next_eval__ = function __next_eval__(fn) {
const key = fn.toString();
if (!warnedEvals.has(key)) {
const warning = (0, _middleware.getServerError)(new Error(`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`), _constants.COMPILER_NAMES.edgeServer);
warning.name = "DynamicCodeEvaluationWarning";
Error.captureStackTrace(warning, __next_eval__);
warnedEvals.add(key);
options.onWarning(warning);
}
return fn();
};
context.__next_webassembly_compile__ = function __next_webassembly_compile__(fn) {
const key = fn.toString();
if (!warnedWasmCodegens.has(key)) {
const warning = (0, _middleware.getServerError)(new Error(`Dynamic WASM code generation (e. g. 'WebAssembly.compile') not allowed in Edge Runtime.
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`), _constants.COMPILER_NAMES.edgeServer);
warning.name = "DynamicWasmCodeGenerationWarning";
Error.captureStackTrace(warning, __next_webassembly_compile__);
warnedWasmCodegens.add(key);
options.onWarning(warning);
}
return fn();
};
context.__next_webassembly_instantiate__ = async function __next_webassembly_instantiate__(fn) {
const result = await fn();
// If a buffer is given, WebAssembly.instantiate returns an object
// containing both a module and an instance while it returns only an
// instance if a WASM module is given. Utilize the fact to determine
// if the WASM code generation happens.
//
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate#primary_overload_%E2%80%94_taking_wasm_binary_code
const instantiatedFromBuffer = result.hasOwnProperty("module");
const key = fn.toString();
if (instantiatedFromBuffer && !warnedWasmCodegens.has(key)) {
const warning = (0, _middleware.getServerError)(new Error(`Dynamic WASM code generation ('WebAssembly.instantiate' with a buffer parameter) not allowed in Edge Runtime.
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`), _constants.COMPILER_NAMES.edgeServer);
warning.name = "DynamicWasmCodeGenerationWarning";
Error.captureStackTrace(warning, __next_webassembly_instantiate__);
warnedWasmCodegens.add(key);
options.onWarning(warning);
}
return result;
};
const __fetch = context.fetch;
context.fetch = async (input, init = {})=>{
var _init_headers_get;
const callingError = new Error("[internal]");
const assetResponse = await (0, _fetchinlineassets.fetchInlineAsset)({
input,
assets: options.edgeFunctionEntry.assets,
distDir: options.distDir,
context
});
if (assetResponse) {
return assetResponse;
}
init.headers = new Headers(init.headers ?? {});
const prevs = ((_init_headers_get = init.headers.get(`x-middleware-subrequest`)) == null ? void 0 : _init_headers_get.split(":")) || [];
const value = prevs.concat(options.moduleName).join(":");
init.headers.set("x-middleware-subrequest", value);
if (!init.headers.has("user-agent")) {
init.headers.set(`user-agent`, `Next.js Middleware`);
}
const response = typeof input === "object" && "url" in input ? __fetch(input.url, {
...(0, _pick.pick)(input, [
"method",
"body",
"cache",
"credentials",
"integrity",
"keepalive",
"mode",
"redirect",
"referrer",
"referrerPolicy",
"signal"
]),
...init,
headers: {
...Object.fromEntries(input.headers),
...Object.fromEntries(init.headers)
}
}) : __fetch(String(input), init);
return await response.catch((err)=>{
callingError.message = err.message;
err.stack = callingError.stack;
throw err;
});
};
const __Request = context.Request;
context.Request = class extends __Request {
constructor(input, init){
const url = typeof input !== "string" && "url" in input ? input.url : String(input);
(0, _utils.validateURL)(url);
super(url, init);
this.next = init == null ? void 0 : init.next;
}
};
const __redirect = context.Response.redirect.bind(context.Response);
context.Response.redirect = (...args)=>{
(0, _utils.validateURL)(args[0]);
return __redirect(...args);
};
for (const name of _constants.EDGE_UNSUPPORTED_NODE_APIS){
addStub(context, name);
}
Object.assign(context, wasm);
context.AsyncLocalStorage = _async_hooks.AsyncLocalStorage;
return context;
}
});
const decorateUnhandledError = getDecorateUnhandledError(runtime);
runtime.context.addEventListener("error", decorateUnhandledError);
const decorateUnhandledRejection = getDecorateUnhandledRejection(runtime);
runtime.context.addEventListener("unhandledrejection", decorateUnhandledRejection);
return {
runtime,
paths: new Map(),
warnedEvals: new Set()
};
}
function getModuleContextShared(options) {
let deferredModuleContext = pendingModuleCaches.get(options.moduleName);
if (!deferredModuleContext) {
deferredModuleContext = createModuleContext(options);
pendingModuleCaches.set(options.moduleName, deferredModuleContext);
}
return deferredModuleContext;
}
async function getModuleContext(options) {
let lazyModuleContext;
if (options.useCache) {
lazyModuleContext = moduleContexts.get(options.moduleName) || await getModuleContextShared(options);
}
if (!lazyModuleContext) {
lazyModuleContext = await createModuleContext(options);
moduleContexts.set(options.moduleName, lazyModuleContext);
}
const moduleContext = lazyModuleContext;
const evaluateInContext = (filepath)=>{
if (!moduleContext.paths.has(filepath)) {
const content = (0, _fs.readFileSync)(filepath, "utf-8");
try {
(0, _vm.runInContext)(content, moduleContext.runtime.context, {
filename: filepath
});
moduleContext.paths.set(filepath, content);
} catch (error) {
if (options.useCache) {
moduleContext == null ? void 0 : moduleContext.paths.delete(filepath);
}
throw error;
}
}
};
return {
...moduleContext,
evaluateInContext
};
}
//# sourceMappingURL=context.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
import type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin';
/**
* Short-circuits the `fetch` function
* to return a stream for a given asset, if a user used `new URL("file", import.meta.url)`.
* This allows to embed assets in Edge Runtime.
*/
export declare function fetchInlineAsset(options: {
input: RequestInfo | URL;
distDir: string;
assets: EdgeFunctionDefinition['assets'];
context: {
Response: typeof Response;
ReadableStream: typeof ReadableStream;
};
}): Promise<Response | undefined>;

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "fetchInlineAsset", {
enumerable: true,
get: function() {
return fetchInlineAsset;
}
});
const _fs = require("fs");
const _bodystreams = require("../../body-streams");
const _path = require("path");
async function fetchInlineAsset(options) {
var _options_assets;
const inputString = String(options.input);
if (!inputString.startsWith("blob:")) {
return;
}
const hash = inputString.replace("blob:", "");
const asset = (_options_assets = options.assets) == null ? void 0 : _options_assets.find((x)=>x.name === hash);
if (!asset) {
return;
}
const filePath = (0, _path.resolve)(options.distDir, asset.filePath);
const fileIsReadable = await _fs.promises.access(filePath).then(()=>true, ()=>false);
if (fileIsReadable) {
const readStream = (0, _fs.createReadStream)(filePath);
return new options.context.Response((0, _bodystreams.requestToBodyStream)(options.context, Uint8Array, readStream));
}
}
//# sourceMappingURL=fetch-inline-assets.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/sandbox/fetch-inline-assets.ts"],"names":["fetchInlineAsset","options","inputString","String","input","startsWith","hash","replace","asset","assets","find","x","name","filePath","resolve","distDir","fileIsReadable","fs","access","then","readStream","createReadStream","context","Response","requestToBodyStream","Uint8Array"],"mappings":";;;;+BAUsBA;;;eAAAA;;;oBAT2B;6BACb;sBACZ;AAOjB,eAAeA,iBAAiBC,OAKtC;QAOeA;IANd,MAAMC,cAAcC,OAAOF,QAAQG,KAAK;IACxC,IAAI,CAACF,YAAYG,UAAU,CAAC,UAAU;QACpC;IACF;IAEA,MAAMC,OAAOJ,YAAYK,OAAO,CAAC,SAAS;IAC1C,MAAMC,SAAQP,kBAAAA,QAAQQ,MAAM,qBAAdR,gBAAgBS,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKN;IACrD,IAAI,CAACE,OAAO;QACV;IACF;IAEA,MAAMK,WAAWC,IAAAA,aAAO,EAACb,QAAQc,OAAO,EAAEP,MAAMK,QAAQ;IACxD,MAAMG,iBAAiB,MAAMC,YAAE,CAACC,MAAM,CAACL,UAAUM,IAAI,CACnD,IAAM,MACN,IAAM;IAGR,IAAIH,gBAAgB;QAClB,MAAMI,aAAaC,IAAAA,oBAAgB,EAACR;QACpC,OAAO,IAAIZ,QAAQqB,OAAO,CAACC,QAAQ,CACjCC,IAAAA,gCAAmB,EAACvB,QAAQqB,OAAO,EAAEG,YAAYL;IAErD;AACF"}

2
node_modules/next/dist/server/web/sandbox/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export * from './sandbox';
export { clearModuleContext } from './context';

28
node_modules/next/dist/server/web/sandbox/index.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "clearModuleContext", {
enumerable: true,
get: function() {
return _context.clearModuleContext;
}
});
0 && __export(require("./sandbox"));
_export_star(require("./sandbox"), exports);
const _context = require("./context");
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});
return from;
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/sandbox/index.ts"],"names":["clearModuleContext"],"mappings":";;;;+BACSA;;;eAAAA,2BAAkB;;;;qBADb;yBACqB"}

25
node_modules/next/dist/server/web/sandbox/sandbox.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import type { NodejsRequestData, FetchEventResult } from '../types';
import { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin';
import type { EdgeRuntime } from 'next/dist/compiled/edge-runtime';
export declare const ErrorSource: unique symbol;
type RunnerFn = (params: {
name: string;
onWarning?: (warn: Error) => void;
paths: string[];
request: NodejsRequestData;
useCache: boolean;
edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'wasm' | 'assets'>;
distDir: string;
incrementalCache?: any;
}) => Promise<FetchEventResult>;
export declare function getRuntimeContext(params: {
name: string;
onWarning?: any;
useCache: boolean;
edgeFunctionEntry: any;
distDir: string;
paths: string[];
incrementalCache?: any;
}): Promise<EdgeRuntime<any>>;
export declare const run: RunnerFn;
export {};

112
node_modules/next/dist/server/web/sandbox/sandbox.js generated vendored Normal file
View File

@@ -0,0 +1,112 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
ErrorSource: null,
getRuntimeContext: null,
run: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
ErrorSource: function() {
return ErrorSource;
},
getRuntimeContext: function() {
return getRuntimeContext;
},
run: function() {
return run;
}
});
const _middleware = require("next/dist/compiled/@next/react-dev-overlay/dist/middleware");
const _context = require("./context");
const _bodystreams = require("../../body-streams");
const _approuterheaders = require("../../../client/components/app-router-headers");
const ErrorSource = Symbol("SandboxError");
const FORBIDDEN_HEADERS = [
"content-length",
"content-encoding",
"transfer-encoding"
];
/**
* Decorates the runner function making sure all errors it can produce are
* tagged with `edge-server` so they can properly be rendered in dev.
*/ function withTaggedErrors(fn) {
return (params)=>fn(params).then((result)=>{
var _result_waitUntil;
return {
...result,
waitUntil: result == null ? void 0 : (_result_waitUntil = result.waitUntil) == null ? void 0 : _result_waitUntil.catch((error)=>{
// TODO: used COMPILER_NAMES.edgeServer instead. Verify that it does not increase the runtime size.
throw (0, _middleware.getServerError)(error, "edge-server");
})
};
}).catch((error)=>{
// TODO: used COMPILER_NAMES.edgeServer instead
throw (0, _middleware.getServerError)(error, "edge-server");
});
}
async function getRuntimeContext(params) {
const { runtime, evaluateInContext } = await (0, _context.getModuleContext)({
moduleName: params.name,
onWarning: params.onWarning ?? (()=>{}),
useCache: params.useCache !== false,
edgeFunctionEntry: params.edgeFunctionEntry,
distDir: params.distDir
});
if (params.incrementalCache) {
runtime.context.globalThis.__incrementalCache = params.incrementalCache;
}
for (const paramPath of params.paths){
evaluateInContext(paramPath);
}
return runtime;
}
const run = withTaggedErrors(async function runWithTaggedErrors(params) {
var _params_request_body;
const runtime = await getRuntimeContext(params);
const subreq = params.request.headers[`x-middleware-subrequest`];
const subrequests = typeof subreq === "string" ? subreq.split(":") : [];
if (subrequests.includes(params.name)) {
return {
waitUntil: Promise.resolve(),
response: new runtime.context.Response(null, {
headers: {
"x-middleware-next": "1"
}
})
};
}
const edgeFunction = runtime.context._ENTRIES[`middleware_${params.name}`].default;
const cloned = ![
"HEAD",
"GET"
].includes(params.request.method) ? (_params_request_body = params.request.body) == null ? void 0 : _params_request_body.cloneBodyStream() : undefined;
const KUint8Array = runtime.evaluate("Uint8Array");
const urlInstance = new URL(params.request.url);
urlInstance.searchParams.delete(_approuterheaders.NEXT_RSC_UNION_QUERY);
params.request.url = urlInstance.toString();
try {
const result = await edgeFunction({
request: {
...params.request,
body: cloned && (0, _bodystreams.requestToBodyStream)(runtime.context, KUint8Array, cloned)
}
});
for (const headerName of FORBIDDEN_HEADERS){
result.response.headers.delete(headerName);
}
return result;
} finally{
var _params_request_body1;
await ((_params_request_body1 = params.request.body) == null ? void 0 : _params_request_body1.finalize());
}
});
//# sourceMappingURL=sandbox.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/sandbox/sandbox.ts"],"names":["ErrorSource","getRuntimeContext","run","Symbol","FORBIDDEN_HEADERS","withTaggedErrors","fn","params","then","result","waitUntil","catch","error","getServerError","runtime","evaluateInContext","getModuleContext","moduleName","name","onWarning","useCache","edgeFunctionEntry","distDir","incrementalCache","context","globalThis","__incrementalCache","paramPath","paths","runWithTaggedErrors","subreq","request","headers","subrequests","split","includes","Promise","resolve","response","Response","edgeFunction","_ENTRIES","default","cloned","method","body","cloneBodyStream","undefined","KUint8Array","evaluate","urlInstance","URL","url","searchParams","delete","NEXT_RSC_UNION_QUERY","toString","requestToBodyStream","headerName","finalize"],"mappings":";;;;;;;;;;;;;;;;IAQaA,WAAW;eAAXA;;IAuCSC,iBAAiB;eAAjBA;;IA2BTC,GAAG;eAAHA;;;4BAzEkB;yBACE;6BAEG;kCAEC;AAE9B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,IAAI,GAAG;QACrC,OAAO;YACLR,WAAW0B,QAAQC,OAAO;YAC1BC,UAAU,IAAIxB,QAAQU,OAAO,CAACe,QAAQ,CAAC,MAAM;gBAC3CP,SAAS;oBACP,qBAAqB;gBACvB;YACF;QACF;IACF;IAEA,MAAMQ,eAGJ1B,QAAQU,OAAO,CAACiB,QAAQ,CAAC,CAAC,WAAW,EAAElC,OAAOW,IAAI,CAAC,CAAC,CAAC,CAACwB,OAAO;IAE/D,MAAMC,SAAS,CAAC;QAAC;QAAQ;KAAM,CAACR,QAAQ,CAAC5B,OAAOwB,OAAO,CAACa,MAAM,KAC1DrC,uBAAAA,OAAOwB,OAAO,CAACc,IAAI,qBAAnBtC,qBAAqBuC,eAAe,KACpCC;IAEJ,MAAMC,cAAclC,QAAQmC,QAAQ,CAAC;IACrC,MAAMC,cAAc,IAAIC,IAAI5C,OAAOwB,OAAO,CAACqB,GAAG;IAC9CF,YAAYG,YAAY,CAACC,MAAM,CAACC,sCAAoB;IAEpDhD,OAAOwB,OAAO,CAACqB,GAAG,GAAGF,YAAYM,QAAQ;IAEzC,IAAI;QACF,MAAM/C,SAAS,MAAM+B,aAAa;YAChCT,SAAS;gBACP,GAAGxB,OAAOwB,OAAO;gBACjBc,MACEF,UAAUc,IAAAA,gCAAmB,EAAC3C,QAAQU,OAAO,EAAEwB,aAAaL;YAChE;QACF;QACA,KAAK,MAAMe,cAActD,kBAAmB;YAC1CK,OAAO6B,QAAQ,CAACN,OAAO,CAACsB,MAAM,CAACI;QACjC;QACA,OAAOjD;IACT,SAAU;YACFF;QAAN,QAAMA,wBAAAA,OAAOwB,OAAO,CAACc,IAAI,qBAAnBtC,sBAAqBoD,QAAQ;IACrC;AACF"}

View File

@@ -0,0 +1,44 @@
/// <reference types="node" />
import type { IncomingHttpHeaders } from 'http';
export type ReadonlyHeaders = Headers & {
/** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */
append(...args: any[]): void;
/** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */
set(...args: any[]): void;
/** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */
delete(...args: any[]): void;
};
export declare class HeadersAdapter extends Headers {
private readonly headers;
constructor(headers: IncomingHttpHeaders);
/**
* Seals a Headers instance to prevent modification by throwing an error when
* any mutating method is called.
*/
static seal(headers: Headers): ReadonlyHeaders;
/**
* Merges a header value into a string. This stores multiple values as an
* array, so we need to merge them into a string.
*
* @param value a header value
* @returns a merged header value (a string)
*/
private merge;
/**
* Creates a Headers instance from a plain object or a Headers instance.
*
* @param headers a plain object or a Headers instance
* @returns a headers instance
*/
static from(headers: IncomingHttpHeaders | Headers): Headers;
append(name: string, value: string): void;
delete(name: string): void;
get(name: string): string | null;
has(name: string): boolean;
set(name: string, value: string): void;
forEach(callbackfn: (value: string, name: string, parent: Headers) => void, thisArg?: any): void;
entries(): IterableIterator<[string, string]>;
keys(): IterableIterator<string>;
values(): IterableIterator<string>;
[Symbol.iterator](): IterableIterator<[string, string]>;
}

View File

@@ -0,0 +1,192 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
ReadonlyHeadersError: null,
HeadersAdapter: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
ReadonlyHeadersError: function() {
return ReadonlyHeadersError;
},
HeadersAdapter: function() {
return HeadersAdapter;
}
});
const _reflect = require("./reflect");
class ReadonlyHeadersError extends Error {
constructor(){
super("Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers");
}
static callable() {
throw new ReadonlyHeadersError();
}
}
class HeadersAdapter extends Headers {
constructor(headers){
// We've already overridden the methods that would be called, so we're just
// calling the super constructor to ensure that the instanceof check works.
super();
this.headers = new Proxy(headers, {
get (target, prop, receiver) {
// Because this is just an object, we expect that all "get" operations
// are for properties. If it's a "get" for a symbol, we'll just return
// the symbol.
if (typeof prop === "symbol") {
return _reflect.ReflectAdapter.get(target, prop, receiver);
}
const lowercased = prop.toLowerCase();
// Let's find the original casing of the key. This assumes that there is
// no mixed case keys (e.g. "Content-Type" and "content-type") in the
// headers object.
const original = Object.keys(headers).find((o)=>o.toLowerCase() === lowercased);
// If the original casing doesn't exist, return undefined.
if (typeof original === "undefined") return;
// If the original casing exists, return the value.
return _reflect.ReflectAdapter.get(target, original, receiver);
},
set (target, prop, value, receiver) {
if (typeof prop === "symbol") {
return _reflect.ReflectAdapter.set(target, prop, value, receiver);
}
const lowercased = prop.toLowerCase();
// Let's find the original casing of the key. This assumes that there is
// no mixed case keys (e.g. "Content-Type" and "content-type") in the
// headers object.
const original = Object.keys(headers).find((o)=>o.toLowerCase() === lowercased);
// If the original casing doesn't exist, use the prop as the key.
return _reflect.ReflectAdapter.set(target, original ?? prop, value, receiver);
},
has (target, prop) {
if (typeof prop === "symbol") return _reflect.ReflectAdapter.has(target, prop);
const lowercased = prop.toLowerCase();
// Let's find the original casing of the key. This assumes that there is
// no mixed case keys (e.g. "Content-Type" and "content-type") in the
// headers object.
const original = Object.keys(headers).find((o)=>o.toLowerCase() === lowercased);
// If the original casing doesn't exist, return false.
if (typeof original === "undefined") return false;
// If the original casing exists, return true.
return _reflect.ReflectAdapter.has(target, original);
},
deleteProperty (target, prop) {
if (typeof prop === "symbol") return _reflect.ReflectAdapter.deleteProperty(target, prop);
const lowercased = prop.toLowerCase();
// Let's find the original casing of the key. This assumes that there is
// no mixed case keys (e.g. "Content-Type" and "content-type") in the
// headers object.
const original = Object.keys(headers).find((o)=>o.toLowerCase() === lowercased);
// If the original casing doesn't exist, return true.
if (typeof original === "undefined") return true;
// If the original casing exists, delete the property.
return _reflect.ReflectAdapter.deleteProperty(target, original);
}
});
}
/**
* Seals a Headers instance to prevent modification by throwing an error when
* any mutating method is called.
*/ static seal(headers) {
return new Proxy(headers, {
get (target, prop, receiver) {
switch(prop){
case "append":
case "delete":
case "set":
return ReadonlyHeadersError.callable;
default:
return _reflect.ReflectAdapter.get(target, prop, receiver);
}
}
});
}
/**
* Merges a header value into a string. This stores multiple values as an
* array, so we need to merge them into a string.
*
* @param value a header value
* @returns a merged header value (a string)
*/ merge(value) {
if (Array.isArray(value)) return value.join(", ");
return value;
}
/**
* Creates a Headers instance from a plain object or a Headers instance.
*
* @param headers a plain object or a Headers instance
* @returns a headers instance
*/ static from(headers) {
if (headers instanceof Headers) return headers;
return new HeadersAdapter(headers);
}
append(name, value) {
const existing = this.headers[name];
if (typeof existing === "string") {
this.headers[name] = [
existing,
value
];
} else if (Array.isArray(existing)) {
existing.push(value);
} else {
this.headers[name] = value;
}
}
delete(name) {
delete this.headers[name];
}
get(name) {
const value = this.headers[name];
if (typeof value !== "undefined") return this.merge(value);
return null;
}
has(name) {
return typeof this.headers[name] !== "undefined";
}
set(name, value) {
this.headers[name] = value;
}
forEach(callbackfn, thisArg) {
for (const [name, value] of this.entries()){
callbackfn.call(thisArg, value, name, this);
}
}
*entries() {
for (const key of Object.keys(this.headers)){
const name = key.toLowerCase();
// We assert here that this is a string because we got it from the
// Object.keys() call above.
const value = this.get(name);
yield [
name,
value
];
}
}
*keys() {
for (const key of Object.keys(this.headers)){
const name = key.toLowerCase();
yield name;
}
}
*values() {
for (const key of Object.keys(this.headers)){
// We assert here that this is a string because we got it from the
// Object.keys() call above.
const value = this.get(key);
yield value;
}
}
[Symbol.iterator]() {
return this.entries();
}
}
//# sourceMappingURL=headers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/web/spec-extension/adapters/headers.ts"],"names":["ReadonlyHeadersError","HeadersAdapter","Error","constructor","callable","Headers","headers","Proxy","get","target","prop","receiver","ReflectAdapter","lowercased","toLowerCase","original","Object","keys","find","o","set","value","has","deleteProperty","seal","merge","Array","isArray","join","from","append","name","existing","push","delete","forEach","callbackfn","thisArg","entries","call","key","values","Symbol","iterator"],"mappings":";;;;;;;;;;;;;;;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YAClE,4BAA4B;YAC5B,MAAMO,QAAQ,IAAI,CAACb,GAAG,CAACuB;YAEvB,MAAM;gBAACA;gBAAMV;aAAM;QACrB;IACF;IAEA,CAAQJ,OAAiC;QACvC,KAAK,MAAMuB,OAAOxB,OAAOC,IAAI,CAAC,IAAI,CAACX,OAAO,EAAG;YAC3C,MAAMyB,OAAOS,IAAI1B,WAAW;YAC5B,MAAMiB;QACR;IACF;IAEA,CAAQU,SAAmC;QACzC,KAAK,MAAMD,OAAOxB,OAAOC,IAAI,CAAC,IAAI,CAACX,OAAO,EAAG;YAC3C,kEAAkE;YAClE,4BAA4B;YAC5B,MAAMe,QAAQ,IAAI,CAACb,GAAG,CAACgC;YAEvB,MAAMnB;QACR;IACF;IAEO,CAACqB,OAAOC,QAAQ,CAAC,GAAuC;QAC7D,OAAO,IAAI,CAACL,OAAO;IACrB;AACF"}

View File

@@ -0,0 +1 @@
import '../../../node-polyfill-fetch';

View File

@@ -0,0 +1,20 @@
/// <reference types="node" />
import type { BaseNextRequest } from '../../../base-http';
import type { NodeNextRequest } from '../../../base-http/node';
import type { WebNextRequest } from '../../../base-http/web';
import type { Writable } from 'node:stream';
import { NextRequest } from '../request';
/**
* Creates an AbortSignal tied to the closing of a ServerResponse (or other
* appropriate Writable).
*
* This cannot be done with the request (IncomingMessage or Readable) because
* the `abort` event will not fire if to data has been fully read (because that
* will "close" the readable stream and nothing fires after that).
*/
export declare function signalFromNodeResponse(response: Writable): AbortSignal;
export declare class NextRequestAdapter {
static fromBaseNextRequest(request: BaseNextRequest, signal: AbortSignal): NextRequest;
static fromNodeNextRequest(request: NodeNextRequest, signal: AbortSignal): NextRequest;
static fromWebNextRequest(request: WebNextRequest): NextRequest;
}

View File

@@ -0,0 +1,101 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
signalFromNodeResponse: null,
NextRequestAdapter: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
signalFromNodeResponse: function() {
return signalFromNodeResponse;
},
NextRequestAdapter: function() {
return NextRequestAdapter;
}
});
const _requestmeta = require("../../../request-meta");
const _utils = require("../../utils");
const _request = require("../request");
function signalFromNodeResponse(response) {
const { errored, destroyed } = response;
if (errored || destroyed) return AbortSignal.abort(errored);
const controller = new AbortController();
// If `finish` fires first, then `res.end()` has been called and the close is
// just us finishing the stream on our side. If `close` fires first, then we
// know the client disconnected before we finished.
function onClose() {
controller.abort();
// eslint-disable-next-line @typescript-eslint/no-use-before-define
response.off("finish", onFinish);
}
function onFinish() {
response.off("close", onClose);
}
response.once("close", onClose);
response.once("finish", onFinish);
return controller.signal;
}
class NextRequestAdapter {
static fromBaseNextRequest(request, signal) {
// TODO: look at refining this check
if ("request" in request && request.request) {
return NextRequestAdapter.fromWebNextRequest(request);
}
return NextRequestAdapter.fromNodeNextRequest(request, signal);
}
static fromNodeNextRequest(request, signal) {
// HEAD and GET requests can not have a body.
let body = null;
if (request.method !== "GET" && request.method !== "HEAD" && request.body) {
// @ts-expect-error - this is handled by undici, when streams/web land use it instead
body = request.body;
}
let url;
if (request.url.startsWith("http")) {
url = new URL(request.url);
} else {
// Grab the full URL from the request metadata.
const base = (0, _requestmeta.getRequestMeta)(request, "__NEXT_INIT_URL");
if (!base || !base.startsWith("http")) {
// Because the URL construction relies on the fact that the URL provided
// is absolute, we need to provide a base URL. We can't use the request
// URL because it's relative, so we use a dummy URL instead.
url = new URL(request.url, "http://n");
} else {
url = new URL(request.url, base);
}
}
return new _request.NextRequest(url, {
body,
method: request.method,
headers: (0, _utils.fromNodeOutgoingHttpHeaders)(request.headers),
// @ts-expect-error - see https://github.com/whatwg/fetch/pull/1457
duplex: "half",
signal
});
}
static fromWebNextRequest(request) {
// HEAD and GET requests can not have a body.
let body = null;
if (request.method !== "GET" && request.method !== "HEAD") {
body = request.body;
}
return new _request.NextRequest(request.url, {
body,
method: request.method,
headers: (0, _utils.fromNodeOutgoingHttpHeaders)(request.headers),
// @ts-expect-error - see https://github.com/whatwg/fetch/pull/1457
duplex: "half",
signal: request.request.signal
});
}
}
//# sourceMappingURL=next-request.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/web/spec-extension/adapters/next-request.ts"],"names":["signalFromNodeResponse","NextRequestAdapter","response","errored","destroyed","AbortSignal","abort","controller","AbortController","onClose","off","onFinish","once","signal","fromBaseNextRequest","request","fromWebNextRequest","fromNodeNextRequest","body","method","url","startsWith","URL","base","getRequestMeta","NextRequest","headers","fromNodeOutgoingHttpHeaders","duplex"],"mappings":";;;;;;;;;;;;;;;IAiBgBA,sBAAsB;eAAtBA;;IAsBHC,kBAAkB;eAAlBA;;;6BAlCkB;uBACa;yBAChB;AAUrB,SAASD,uBAAuBE,QAAkB;IACvD,MAAM,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGF;IAC/B,IAAIC,WAAWC,WAAW,OAAOC,YAAYC,KAAK,CAACH;IAEnD,MAAMI,aAAa,IAAIC;IACvB,6EAA6E;IAC7E,4EAA4E;IAC5E,mDAAmD;IACnD,SAASC;QACPF,WAAWD,KAAK;QAChB,mEAAmE;QACnEJ,SAASQ,GAAG,CAAC,UAAUC;IACzB;IACA,SAASA;QACPT,SAASQ,GAAG,CAAC,SAASD;IACxB;IACAP,SAASU,IAAI,CAAC,SAASH;IACvBP,SAASU,IAAI,CAAC,UAAUD;IAExB,OAAOJ,WAAWM,MAAM;AAC1B;AAEO,MAAMZ;IACX,OAAca,oBACZC,OAAwB,EACxBF,MAAmB,EACN;QACb,oCAAoC;QACpC,IAAI,aAAaE,WAAW,AAACA,QAA2BA,OAAO,EAAE;YAC/D,OAAOd,mBAAmBe,kBAAkB,CAACD;QAC/C;QAEA,OAAOd,mBAAmBgB,mBAAmB,CAC3CF,SACAF;IAEJ;IAEA,OAAcI,oBACZF,OAAwB,EACxBF,MAAmB,EACN;QACb,6CAA6C;QAC7C,IAAIK,OAAwB;QAC5B,IAAIH,QAAQI,MAAM,KAAK,SAASJ,QAAQI,MAAM,KAAK,UAAUJ,QAAQG,IAAI,EAAE;YACzE,qFAAqF;YACrFA,OAAOH,QAAQG,IAAI;QACrB;QAEA,IAAIE;QACJ,IAAIL,QAAQK,GAAG,CAACC,UAAU,CAAC,SAAS;YAClCD,MAAM,IAAIE,IAAIP,QAAQK,GAAG;QAC3B,OAAO;YACL,+CAA+C;YAC/C,MAAMG,OAAOC,IAAAA,2BAAc,EAACT,SAAS;YACrC,IAAI,CAACQ,QAAQ,CAACA,KAAKF,UAAU,CAAC,SAAS;gBACrC,wEAAwE;gBACxE,uEAAuE;gBACvE,4DAA4D;gBAC5DD,MAAM,IAAIE,IAAIP,QAAQK,GAAG,EAAE;YAC7B,OAAO;gBACLA,MAAM,IAAIE,IAAIP,QAAQK,GAAG,EAAEG;YAC7B;QACF;QAEA,OAAO,IAAIE,oBAAW,CAACL,KAAK;YAC1BF;YACAC,QAAQJ,QAAQI,MAAM;YACtBO,SAASC,IAAAA,kCAA2B,EAACZ,QAAQW,OAAO;YACpD,mEAAmE;YACnEE,QAAQ;YACRf;QAIF;IACF;IAEA,OAAcG,mBAAmBD,OAAuB,EAAe;QACrE,6CAA6C;QAC7C,IAAIG,OAA8B;QAClC,IAAIH,QAAQI,MAAM,KAAK,SAASJ,QAAQI,MAAM,KAAK,QAAQ;YACzDD,OAAOH,QAAQG,IAAI;QACrB;QAEA,OAAO,IAAIO,oBAAW,CAACV,QAAQK,GAAG,EAAE;YAClCF;YACAC,QAAQJ,QAAQI,MAAM;YACtBO,SAASC,IAAAA,kCAA2B,EAACZ,QAAQW,OAAO;YACpD,mEAAmE;YACnEE,QAAQ;YACRf,QAAQE,QAAQA,OAAO,CAACF,MAAM;QAIhC;IACF;AACF"}

View File

@@ -0,0 +1,6 @@
export declare class ReflectAdapter {
static get<T extends object>(target: T, prop: string | symbol, receiver: unknown): any;
static set<T extends object>(target: T, prop: string | symbol, value: any, receiver: any): boolean;
static has<T extends object>(target: T, prop: string | symbol): boolean;
static deleteProperty<T extends object>(target: T, prop: string | symbol): boolean;
}

View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "ReflectAdapter", {
enumerable: true,
get: function() {
return ReflectAdapter;
}
});
class ReflectAdapter {
static get(target, prop, receiver) {
const value = Reflect.get(target, prop, receiver);
if (typeof value === "function") {
return value.bind(target);
}
return value;
}
static set(target, prop, value, receiver) {
return Reflect.set(target, prop, value, receiver);
}
static has(target, prop) {
return Reflect.has(target, prop);
}
static deleteProperty(target, prop) {
return Reflect.deleteProperty(target, prop);
}
}
//# sourceMappingURL=reflect.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/web/spec-extension/adapters/reflect.ts"],"names":["ReflectAdapter","get","target","prop","receiver","value","Reflect","bind","set","has","deleteProperty"],"mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA;IACX,OAAOC,IACLC,MAAS,EACTC,IAAqB,EACrBC,QAAiB,EACZ;QACL,MAAMC,QAAQC,QAAQL,GAAG,CAACC,QAAQC,MAAMC;QACxC,IAAI,OAAOC,UAAU,YAAY;YAC/B,OAAOA,MAAME,IAAI,CAACL;QACpB;QAEA,OAAOG;IACT;IAEA,OAAOG,IACLN,MAAS,EACTC,IAAqB,EACrBE,KAAU,EACVD,QAAa,EACJ;QACT,OAAOE,QAAQE,GAAG,CAACN,QAAQC,MAAME,OAAOD;IAC1C;IAEA,OAAOK,IAAsBP,MAAS,EAAEC,IAAqB,EAAW;QACtE,OAAOG,QAAQG,GAAG,CAACP,QAAQC;IAC7B;IAEA,OAAOO,eACLR,MAAS,EACTC,IAAqB,EACZ;QACT,OAAOG,QAAQI,cAAc,CAACR,QAAQC;IACxC;AACF"}

View File

@@ -0,0 +1,13 @@
import type { RequestCookies } from '../cookies';
import { ResponseCookies } from '../cookies';
export type ReadonlyRequestCookies = Omit<RequestCookies, 'set' | 'clear' | 'delete'> & Pick<ResponseCookies, 'set' | 'delete'>;
export declare class RequestCookiesAdapter {
static seal(cookies: RequestCookies): ReadonlyRequestCookies;
}
export declare function getModifiedCookieValues(cookies: ResponseCookies): ResponseCookie[];
export declare function appendMutableCookies(headers: Headers, mutableCookies: ResponseCookies): boolean;
type ResponseCookie = NonNullable<ReturnType<InstanceType<typeof ResponseCookies>['get']>>;
export declare class MutableRequestCookiesAdapter {
static wrap(cookies: RequestCookies, onUpdateCookies?: (cookies: string[]) => void): ResponseCookies;
}
export {};

View File

@@ -0,0 +1,150 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
ReadonlyRequestCookiesError: null,
RequestCookiesAdapter: null,
getModifiedCookieValues: null,
appendMutableCookies: null,
MutableRequestCookiesAdapter: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
ReadonlyRequestCookiesError: function() {
return ReadonlyRequestCookiesError;
},
RequestCookiesAdapter: function() {
return RequestCookiesAdapter;
},
getModifiedCookieValues: function() {
return getModifiedCookieValues;
},
appendMutableCookies: function() {
return appendMutableCookies;
},
MutableRequestCookiesAdapter: function() {
return MutableRequestCookiesAdapter;
}
});
const _cookies = require("../cookies");
const _reflect = require("./reflect");
class ReadonlyRequestCookiesError extends Error {
constructor(){
super("Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options");
}
static callable() {
throw new ReadonlyRequestCookiesError();
}
}
class RequestCookiesAdapter {
static seal(cookies) {
return new Proxy(cookies, {
get (target, prop, receiver) {
switch(prop){
case "clear":
case "delete":
case "set":
return ReadonlyRequestCookiesError.callable;
default:
return _reflect.ReflectAdapter.get(target, prop, receiver);
}
}
});
}
}
const SYMBOL_MODIFY_COOKIE_VALUES = Symbol.for("next.mutated.cookies");
function getModifiedCookieValues(cookies) {
const modified = cookies[SYMBOL_MODIFY_COOKIE_VALUES];
if (!modified || !Array.isArray(modified) || modified.length === 0) {
return [];
}
return modified;
}
function appendMutableCookies(headers, mutableCookies) {
const modifiedCookieValues = getModifiedCookieValues(mutableCookies);
if (modifiedCookieValues.length === 0) {
return false;
}
// Return a new response that extends the response with
// the modified cookies as fallbacks. `res` cookies
// will still take precedence.
const resCookies = new _cookies.ResponseCookies(headers);
const returnedCookies = resCookies.getAll();
// Set the modified cookies as fallbacks.
for (const cookie of modifiedCookieValues){
resCookies.set(cookie);
}
// Set the original cookies as the final values.
for (const cookie of returnedCookies){
resCookies.set(cookie);
}
return true;
}
class MutableRequestCookiesAdapter {
static wrap(cookies, onUpdateCookies) {
const responseCookes = new _cookies.ResponseCookies(new Headers());
for (const cookie of cookies.getAll()){
responseCookes.set(cookie);
}
let modifiedValues = [];
const modifiedCookies = new Set();
const updateResponseCookies = ()=>{
var _fetch___nextGetStaticStore;
// TODO-APP: change method of getting staticGenerationAsyncStore
const staticGenerationAsyncStore = fetch.__nextGetStaticStore == null ? void 0 : (_fetch___nextGetStaticStore = fetch.__nextGetStaticStore.call(fetch)) == null ? void 0 : _fetch___nextGetStaticStore.getStore();
if (staticGenerationAsyncStore) {
staticGenerationAsyncStore.pathWasRevalidated = true;
}
const allCookies = responseCookes.getAll();
modifiedValues = allCookies.filter((c)=>modifiedCookies.has(c.name));
if (onUpdateCookies) {
const serializedCookies = [];
for (const cookie of modifiedValues){
const tempCookies = new _cookies.ResponseCookies(new Headers());
tempCookies.set(cookie);
serializedCookies.push(tempCookies.toString());
}
onUpdateCookies(serializedCookies);
}
};
return new Proxy(responseCookes, {
get (target, prop, receiver) {
switch(prop){
// A special symbol to get the modified cookie values
case SYMBOL_MODIFY_COOKIE_VALUES:
return modifiedValues;
// TODO: Throw error if trying to set a cookie after the response
// headers have been set.
case "delete":
return function(...args) {
modifiedCookies.add(typeof args[0] === "string" ? args[0] : args[0].name);
try {
target.delete(...args);
} finally{
updateResponseCookies();
}
};
case "set":
return function(...args) {
modifiedCookies.add(typeof args[0] === "string" ? args[0] : args[0].name);
try {
return target.set(...args);
} finally{
updateResponseCookies();
}
};
default:
return _reflect.ReflectAdapter.get(target, prop, receiver);
}
}
});
}
}
//# sourceMappingURL=request-cookies.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/web/spec-extension/adapters/request-cookies.ts"],"names":["ReadonlyRequestCookiesError","RequestCookiesAdapter","getModifiedCookieValues","appendMutableCookies","MutableRequestCookiesAdapter","Error","constructor","callable","seal","cookies","Proxy","get","target","prop","receiver","ReflectAdapter","SYMBOL_MODIFY_COOKIE_VALUES","Symbol","for","modified","Array","isArray","length","headers","mutableCookies","modifiedCookieValues","resCookies","ResponseCookies","returnedCookies","getAll","cookie","set","wrap","onUpdateCookies","responseCookes","Headers","modifiedValues","modifiedCookies","Set","updateResponseCookies","staticGenerationAsyncStore","fetch","__nextGetStaticStore","getStore","pathWasRevalidated","allCookies","filter","c","has","name","serializedCookies","tempCookies","push","toString","args","add","delete"],"mappings":";;;;;;;;;;;;;;;;;;IASaA,2BAA2B;eAA3BA;;IAqBAC,qBAAqB;eAArBA;;IAmBGC,uBAAuB;eAAvBA;;IAaAC,oBAAoB;eAApBA;;IAgCHC,4BAA4B;eAA5BA;;;yBA3FmB;yBACD;AAKxB,MAAMJ,oCAAoCK;IAC/CC,aAAc;QACZ,KAAK,CACH;IAEJ;IAEA,OAAcC,WAAW;QACvB,MAAM,IAAIP;IACZ;AACF;AAWO,MAAMC;IACX,OAAcO,KAAKC,OAAuB,EAA0B;QAClE,OAAO,IAAIC,MAAMD,SAAgB;YAC/BE,KAAIC,MAAM,EAAEC,IAAI,EAAEC,QAAQ;gBACxB,OAAQD;oBACN,KAAK;oBACL,KAAK;oBACL,KAAK;wBACH,OAAOb,4BAA4BO,QAAQ;oBAC7C;wBACE,OAAOQ,uBAAc,CAACJ,GAAG,CAACC,QAAQC,MAAMC;gBAC5C;YACF;QACF;IACF;AACF;AAEA,MAAME,8BAA8BC,OAAOC,GAAG,CAAC;AAExC,SAAShB,wBACdO,OAAwB;IAExB,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,EAAE;gBACtC,KAAK,MAAMpB,UAAUM,eAAgB;oBACnC,MAAMe,cAAc,IAAIxB,wBAAe,CAAC,IAAIQ;oBAC5CgB,YAAYpB,GAAG,CAACD;oBAChBoB,kBAAkBE,IAAI,CAACD,YAAYE,QAAQ;gBAC7C;gBAEApB,gBAAgBiB;YAClB;QACF;QAEA,OAAO,IAAIxC,MAAMwB,gBAAgB;YAC/BvB,KAAIC,MAAM,EAAEC,IAAI,EAAEC,QAAQ;gBACxB,OAAQD;oBACN,qDAAqD;oBACrD,KAAKG;wBACH,OAAOoB;oBAET,iEAAiE;oBACjE,yBAAyB;oBACzB,KAAK;wBACH,OAAO,SAAU,GAAGkB,IAAiC;4BACnDjB,gBAAgBkB,GAAG,CACjB,OAAOD,IAAI,CAAC,EAAE,KAAK,WAAWA,IAAI,CAAC,EAAE,GAAGA,IAAI,CAAC,EAAE,CAACL,IAAI;4BAEtD,IAAI;gCACFrC,OAAO4C,MAAM,IAAIF;4BACnB,SAAU;gCACRf;4BACF;wBACF;oBACF,KAAK;wBACH,OAAO,SACL,GAAGe,IAE0B;4BAE7BjB,gBAAgBkB,GAAG,CACjB,OAAOD,IAAI,CAAC,EAAE,KAAK,WAAWA,IAAI,CAAC,EAAE,GAAGA,IAAI,CAAC,EAAE,CAACL,IAAI;4BAEtD,IAAI;gCACF,OAAOrC,OAAOmB,GAAG,IAAIuB;4BACvB,SAAU;gCACRf;4BACF;wBACF;oBACF;wBACE,OAAOxB,uBAAc,CAACJ,GAAG,CAACC,QAAQC,MAAMC;gBAC5C;YACF;QACF;IACF;AACF"}

View File

@@ -0,0 +1 @@
import '../../../node-polyfill-fetch';

View File

@@ -0,0 +1 @@
export { RequestCookies, ResponseCookies, } from 'next/dist/compiled/@edge-runtime/cookies';

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
RequestCookies: null,
ResponseCookies: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
RequestCookies: function() {
return _cookies.RequestCookies;
},
ResponseCookies: function() {
return _cookies.ResponseCookies;
}
});
const _cookies = require("next/dist/compiled/@edge-runtime/cookies");
//# sourceMappingURL=cookies.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/spec-extension/cookies.ts"],"names":["RequestCookies","ResponseCookies"],"mappings":";;;;;;;;;;;;;;;IACEA,cAAc;eAAdA,uBAAc;;IACdC,eAAe;eAAfA,wBAAe;;;yBACV"}

View File

@@ -0,0 +1,33 @@
import { NextRequest } from './request';
declare const responseSymbol: unique symbol;
declare const passThroughSymbol: unique symbol;
export declare const waitUntilSymbol: unique symbol;
declare class FetchEvent {
readonly [waitUntilSymbol]: Promise<any>[];
[responseSymbol]?: Promise<Response>;
[passThroughSymbol]: boolean;
constructor(_request: Request);
respondWith(response: Response | Promise<Response>): void;
passThroughOnException(): void;
waitUntil(promise: Promise<any>): void;
}
export declare class NextFetchEvent extends FetchEvent {
sourcePage: string;
constructor(params: {
request: NextRequest;
page: string;
});
/**
* @deprecated The `request` is now the first parameter and the API is now async.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/
get request(): void;
/**
* @deprecated Using `respondWith` is no longer needed.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/
respondWith(): void;
}
export {};

View File

@@ -0,0 +1,70 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
waitUntilSymbol: null,
NextFetchEvent: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
waitUntilSymbol: function() {
return waitUntilSymbol;
},
NextFetchEvent: function() {
return NextFetchEvent;
}
});
const _error = require("../error");
const responseSymbol = Symbol("response");
const passThroughSymbol = Symbol("passThrough");
const waitUntilSymbol = Symbol("waitUntil");
class FetchEvent {
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(_request){
this[waitUntilSymbol] = [];
this[passThroughSymbol] = false;
}
respondWith(response) {
if (!this[responseSymbol]) {
this[responseSymbol] = Promise.resolve(response);
}
}
passThroughOnException() {
this[passThroughSymbol] = true;
}
waitUntil(promise) {
this[waitUntilSymbol].push(promise);
}
}
class NextFetchEvent extends FetchEvent {
constructor(params){
super(params.request);
this.sourcePage = params.page;
}
/**
* @deprecated The `request` is now the first parameter and the API is now async.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/ get request() {
throw new _error.PageSignatureError({
page: this.sourcePage
});
}
/**
* @deprecated Using `respondWith` is no longer needed.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/ respondWith() {
throw new _error.PageSignatureError({
page: this.sourcePage
});
}
}
//# sourceMappingURL=fetch-event.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/spec-extension/fetch-event.ts"],"names":["waitUntilSymbol","NextFetchEvent","responseSymbol","Symbol","passThroughSymbol","FetchEvent","constructor","_request","respondWith","response","Promise","resolve","passThroughOnException","waitUntil","promise","push","params","request","sourcePage","page","PageSignatureError"],"mappings":";;;;;;;;;;;;;;;IAKaA,eAAe;eAAfA;;IAyBAC,cAAc;eAAdA;;;uBA9BsB;AAGnC,MAAMC,iBAAiBC,OAAO;AAC9B,MAAMC,oBAAoBD,OAAO;AAC1B,MAAMH,kBAAkBG,OAAO;AAEtC,MAAME;IAKJ,qEAAqE;IACrEC,YAAYC,QAAiB,CAAE;YALtB,CAACP,gBAAgB,GAAmB,EAAE;YAE/C,CAACI,kBAAkB,GAAG;IAGU;IAEhCI,YAAYC,QAAsC,EAAQ;QACxD,IAAI,CAAC,IAAI,CAACP,eAAe,EAAE;YACzB,IAAI,CAACA,eAAe,GAAGQ,QAAQC,OAAO,CAACF;QACzC;IACF;IAEAG,yBAA+B;QAC7B,IAAI,CAACR,kBAAkB,GAAG;IAC5B;IAEAS,UAAUC,OAAqB,EAAQ;QACrC,IAAI,CAACd,gBAAgB,CAACe,IAAI,CAACD;IAC7B;AACF;AAEO,MAAMb,uBAAuBI;IAGlCC,YAAYU,MAA8C,CAAE;QAC1D,KAAK,CAACA,OAAOC,OAAO;QACpB,IAAI,CAACC,UAAU,GAAGF,OAAOG,IAAI;IAC/B;IAEA;;;;GAIC,GACD,IAAIF,UAAU;QACZ,MAAM,IAAIG,yBAAkB,CAAC;YAC3BD,MAAM,IAAI,CAACD,UAAU;QACvB;IACF;IAEA;;;;GAIC,GACDV,cAAc;QACZ,MAAM,IAAIY,yBAAkB,CAAC;YAC3BD,MAAM,IAAI,CAACD,UAAU;QACvB;IACF;AACF"}

View File

@@ -0,0 +1,4 @@
export declare class ImageResponse extends Response {
static displayName: string;
constructor(...args: ConstructorParameters<typeof import('next/dist/compiled/@vercel/og').ImageResponse>);
}

View File

@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "ImageResponse", {
enumerable: true,
get: function() {
return ImageResponse;
}
});
class ImageResponse extends Response {
static #_ = this.displayName = "NextImageResponse";
constructor(...args){
const readable = new ReadableStream({
async start (controller) {
const OGImageResponse = // So far we have to manually determine which build to use,
// as the auto resolving is not working
(await import(process.env.NEXT_RUNTIME === "edge" ? "next/dist/compiled/@vercel/og/index.edge.js" : "next/dist/compiled/@vercel/og/index.node.js")).ImageResponse;
const imageResponse = new OGImageResponse(...args);
if (!imageResponse.body) {
return controller.close();
}
const reader = imageResponse.body.getReader();
while(true){
const { done, value } = await reader.read();
if (done) {
return controller.close();
}
controller.enqueue(value);
}
}
});
const options = args[1] || {};
super(readable, {
headers: {
"content-type": "image/png",
"cache-control": process.env.NODE_ENV === "development" ? "no-cache, no-store" : "public, immutable, no-transform, max-age=31536000",
...options.headers
},
status: options.status,
statusText: options.statusText
});
}
}
//# sourceMappingURL=image-response.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/spec-extension/image-response.ts"],"names":["ImageResponse","Response","displayName","constructor","args","readable","ReadableStream","start","controller","OGImageResponse","process","env","NEXT_RUNTIME","imageResponse","body","close","reader","getReader","done","value","read","enqueue","options","headers","NODE_ENV","status","statusText"],"mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA,sBAAsBC;qBACnBC,cAAc;IAC5BC,YACE,GAAGC,IAEF,CACD;QACA,MAAMC,WAAW,IAAIC,eAAe;YAClC,MAAMC,OAAMC,UAAU;gBACpB,MAAMC,kBAGJ,AAFA,2DAA2D;gBAC3D,uCAAuC;gBAErC,CAAA,MAAM,MAAM,CACVC,QAAQC,GAAG,CAACC,YAAY,KAAK,SACzB,gDACA,8CACN,EACAZ,aAAa;gBACjB,MAAMa,gBAAgB,IAAIJ,mBAAmBL;gBAE7C,IAAI,CAACS,cAAcC,IAAI,EAAE;oBACvB,OAAON,WAAWO,KAAK;gBACzB;gBAEA,MAAMC,SAASH,cAAcC,IAAI,CAAEG,SAAS;gBAC5C,MAAO,KAAM;oBACX,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAG,MAAMH,OAAOI,IAAI;oBACzC,IAAIF,MAAM;wBACR,OAAOV,WAAWO,KAAK;oBACzB;oBACAP,WAAWa,OAAO,CAACF;gBACrB;YACF;QACF;QAEA,MAAMG,UAAUlB,IAAI,CAAC,EAAE,IAAI,CAAC;QAE5B,KAAK,CAACC,UAAU;YACdkB,SAAS;gBACP,gBAAgB;gBAChB,iBACEb,QAAQC,GAAG,CAACa,QAAQ,KAAK,gBACrB,uBACA;gBACN,GAAGF,QAAQC,OAAO;YACpB;YACAE,QAAQH,QAAQG,MAAM;YACtBC,YAAYJ,QAAQI,UAAU;QAChC;IACF;AACF"}

View File

@@ -0,0 +1,52 @@
import type { I18NConfig } from '../../config-shared';
import type { RequestData } from '../types';
import { NextURL } from '../next-url';
import { RequestCookies } from './cookies';
export declare const INTERNALS: unique symbol;
export declare class NextRequest extends Request {
[INTERNALS]: {
cookies: RequestCookies;
geo: RequestData['geo'];
ip?: string;
url: string;
nextUrl: NextURL;
};
constructor(input: URL | RequestInfo, init?: RequestInit);
get cookies(): RequestCookies;
get geo(): {
city?: string | undefined;
country?: string | undefined;
region?: string | undefined;
latitude?: string | undefined;
longitude?: string | undefined;
} | undefined;
get ip(): string | undefined;
get nextUrl(): NextURL;
/**
* @deprecated
* `page` has been deprecated in favour of `URLPattern`.
* Read more: https://nextjs.org/docs/messages/middleware-request-page
*/
get page(): void;
/**
* @deprecated
* `ua` has been removed in favour of \`userAgent\` function.
* Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
*/
get ua(): void;
get url(): string;
}
export interface RequestInit extends globalThis.RequestInit {
geo?: {
city?: string;
country?: string;
region?: string;
};
ip?: string;
nextConfig?: {
basePath?: string;
i18n?: I18NConfig | null;
trailingSlash?: boolean;
};
signal?: AbortSignal;
}

View File

@@ -0,0 +1,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
INTERNALS: null,
NextRequest: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
INTERNALS: function() {
return INTERNALS;
},
NextRequest: function() {
return NextRequest;
}
});
const _nexturl = require("../next-url");
const _utils = require("../utils");
const _error = require("../error");
const _cookies = require("./cookies");
const INTERNALS = Symbol("internal request");
class NextRequest extends Request {
constructor(input, init = {}){
const url = typeof input !== "string" && "url" in input ? input.url : String(input);
(0, _utils.validateURL)(url);
if (input instanceof Request) super(input, init);
else super(url, init);
const nextUrl = new _nexturl.NextURL(url, {
headers: (0, _utils.toNodeOutgoingHttpHeaders)(this.headers),
nextConfig: init.nextConfig
});
this[INTERNALS] = {
cookies: new _cookies.RequestCookies(this.headers),
geo: init.geo || {},
ip: init.ip,
nextUrl,
url: process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE ? url : nextUrl.toString()
};
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return {
cookies: this.cookies,
geo: this.geo,
ip: this.ip,
nextUrl: this.nextUrl,
url: this.url,
// rest of props come from Request
bodyUsed: this.bodyUsed,
cache: this.cache,
credentials: this.credentials,
destination: this.destination,
headers: Object.fromEntries(this.headers),
integrity: this.integrity,
keepalive: this.keepalive,
method: this.method,
mode: this.mode,
redirect: this.redirect,
referrer: this.referrer,
referrerPolicy: this.referrerPolicy,
signal: this.signal
};
}
get cookies() {
return this[INTERNALS].cookies;
}
get geo() {
return this[INTERNALS].geo;
}
get ip() {
return this[INTERNALS].ip;
}
get nextUrl() {
return this[INTERNALS].nextUrl;
}
/**
* @deprecated
* `page` has been deprecated in favour of `URLPattern`.
* Read more: https://nextjs.org/docs/messages/middleware-request-page
*/ get page() {
throw new _error.RemovedPageError();
}
/**
* @deprecated
* `ua` has been removed in favour of \`userAgent\` function.
* Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
*/ get ua() {
throw new _error.RemovedUAError();
}
get url() {
return this[INTERNALS].url;
}
}
//# sourceMappingURL=request.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/spec-extension/request.ts"],"names":["INTERNALS","NextRequest","Symbol","Request","constructor","input","init","url","String","validateURL","nextUrl","NextURL","headers","toNodeOutgoingHttpHeaders","nextConfig","cookies","RequestCookies","geo","ip","process","env","__NEXT_NO_MIDDLEWARE_URL_NORMALIZE","toString","for","bodyUsed","cache","credentials","destination","Object","fromEntries","integrity","keepalive","method","mode","redirect","referrer","referrerPolicy","signal","page","RemovedPageError","ua","RemovedUAError"],"mappings":";;;;;;;;;;;;;;;IAOaA,SAAS;eAATA;;IAEAC,WAAW;eAAXA;;;yBAPW;uBAC+B;uBACN;yBAClB;AAExB,MAAMD,YAAYE,OAAO;AAEzB,MAAMD,oBAAoBE;IAS/BC,YAAYC,KAAwB,EAAEC,OAAoB,CAAC,CAAC,CAAE;QAC5D,MAAMC,MACJ,OAAOF,UAAU,YAAY,SAASA,QAAQA,MAAME,GAAG,GAAGC,OAAOH;QACnEI,IAAAA,kBAAW,EAACF;QACZ,IAAIF,iBAAiB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B,GAAG;IAC5B;IAEA,IAAWC,KAAK;QACd,OAAO,IAAI,CAAClB,UAAU,CAACkB,EAAE;IAC3B;IAEA,IAAWR,UAAU;QACnB,OAAO,IAAI,CAACV,UAAU,CAACU,OAAO;IAChC;IAEA;;;;GAIC,GACD,IAAW4B,OAAO;QAChB,MAAM,IAAIC,uBAAgB;IAC5B;IAEA;;;;GAIC,GACD,IAAWC,KAAK;QACd,MAAM,IAAIC,qBAAc;IAC1B;IAEA,IAAWlC,MAAM;QACf,OAAO,IAAI,CAACP,UAAU,CAACO,GAAG;IAC5B;AACF"}

View File

@@ -0,0 +1,38 @@
import type { I18NConfig } from '../../config-shared';
import { NextURL } from '../next-url';
import { ResponseCookies } from './cookies';
declare const INTERNALS: unique symbol;
export declare class NextResponse<Body = unknown> extends Response {
[INTERNALS]: {
cookies: ResponseCookies;
url?: NextURL;
body?: Body;
};
constructor(body?: BodyInit | null, init?: ResponseInit);
get cookies(): ResponseCookies;
static json<JsonBody>(body: JsonBody, init?: ResponseInit): NextResponse<JsonBody>;
static redirect(url: string | NextURL | URL, init?: number | ResponseInit): NextResponse<unknown>;
static rewrite(destination: string | NextURL | URL, init?: MiddlewareResponseInit): NextResponse<unknown>;
static next(init?: MiddlewareResponseInit): NextResponse<unknown>;
}
interface ResponseInit extends globalThis.ResponseInit {
nextConfig?: {
basePath?: string;
i18n?: I18NConfig;
trailingSlash?: boolean;
};
url?: string;
}
interface ModifiedRequest {
/**
* If this is set, the request headers will be overridden with this value.
*/
headers?: Headers;
}
interface MiddlewareResponseInit extends globalThis.ResponseInit {
/**
* These fields will override the request from clients.
*/
request?: ModifiedRequest;
}
export {};

View File

@@ -0,0 +1,103 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "NextResponse", {
enumerable: true,
get: function() {
return NextResponse;
}
});
const _nexturl = require("../next-url");
const _utils = require("../utils");
const _cookies = require("./cookies");
const INTERNALS = Symbol("internal response");
const REDIRECTS = new Set([
301,
302,
303,
307,
308
]);
function handleMiddlewareField(init, headers) {
var _init_request;
if (init == null ? void 0 : (_init_request = init.request) == null ? void 0 : _init_request.headers) {
if (!(init.request.headers instanceof Headers)) {
throw new Error("request.headers must be an instance of Headers");
}
const keys = [];
for (const [key, value] of init.request.headers){
headers.set("x-middleware-request-" + key, value);
keys.push(key);
}
headers.set("x-middleware-override-headers", keys.join(","));
}
}
class NextResponse extends Response {
constructor(body, init = {}){
super(body, init);
this[INTERNALS] = {
cookies: new _cookies.ResponseCookies(this.headers),
url: init.url ? new _nexturl.NextURL(init.url, {
headers: (0, _utils.toNodeOutgoingHttpHeaders)(this.headers),
nextConfig: init.nextConfig
}) : undefined
};
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return {
cookies: this.cookies,
url: this.url,
// rest of props come from Response
body: this.body,
bodyUsed: this.bodyUsed,
headers: Object.fromEntries(this.headers),
ok: this.ok,
redirected: this.redirected,
status: this.status,
statusText: this.statusText,
type: this.type
};
}
get cookies() {
return this[INTERNALS].cookies;
}
static json(body, init) {
const response = Response.json(body, init);
return new NextResponse(response.body, response);
}
static redirect(url, init) {
const status = typeof init === "number" ? init : (init == null ? void 0 : init.status) ?? 307;
if (!REDIRECTS.has(status)) {
throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
}
const initObj = typeof init === "object" ? init : {};
const headers = new Headers(initObj == null ? void 0 : initObj.headers);
headers.set("Location", (0, _utils.validateURL)(url));
return new NextResponse(null, {
...initObj,
headers,
status
});
}
static rewrite(destination, init) {
const headers = new Headers(init == null ? void 0 : init.headers);
headers.set("x-middleware-rewrite", (0, _utils.validateURL)(destination));
handleMiddlewareField(init, headers);
return new NextResponse(null, {
...init,
headers
});
}
static next(init) {
const headers = new Headers(init == null ? void 0 : init.headers);
headers.set("x-middleware-next", "1");
handleMiddlewareField(init, headers);
return new NextResponse(null, {
...init,
headers
});
}
}
//# sourceMappingURL=response.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/spec-extension/response.ts"],"names":["NextResponse","INTERNALS","Symbol","REDIRECTS","Set","handleMiddlewareField","init","headers","request","Headers","Error","keys","key","value","set","push","join","Response","constructor","body","cookies","ResponseCookies","url","NextURL","toNodeOutgoingHttpHeaders","nextConfig","undefined","for","bodyUsed","Object","fromEntries","ok","redirected","status","statusText","type","json","response","redirect","has","RangeError","initObj","validateURL","rewrite","destination","next"],"mappings":";;;;+BA4BaA;;;eAAAA;;;yBA3BW;uBAC+B;yBAEvB;AAEhC,MAAMC,YAAYC,OAAO;AACzB,MAAMC,YAAY,IAAIC,IAAI;IAAC;IAAK;IAAK;IAAK;IAAK;CAAI;AAEnD,SAASC,sBACPC,IAAwC,EACxCC,OAAgB;QAEZD;IAAJ,IAAIA,yBAAAA,gBAAAA,KAAME,OAAO,qBAAbF,cAAeC,OAAO,EAAE;QAC1B,IAAI,CAAED,CAAAA,KAAKE,OAAO,CAACD,OAAO,YAAYE,OAAM,GAAI;YAC9C,MAAM,IAAIC,MAAM;QAClB;QAEA,MAAMC,OAAO,EAAE;QACf,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIP,KAAKE,OAAO,CAACD,OAAO,CAAE;YAC/CA,QAAQO,GAAG,CAAC,0BAA0BF,KAAKC;YAC3CF,KAAKI,IAAI,CAACH;QACZ;QAEAL,QAAQO,GAAG,CAAC,iCAAiCH,KAAKK,IAAI,CAAC;IACzD;AACF;AAEO,MAAMhB,qBAAqCiB;IAOhDC,YAAYC,IAAsB,EAAEb,OAAqB,CAAC,CAAC,CAAE;QAC3D,KAAK,CAACa,MAAMb;QAEZ,IAAI,CAACL,UAAU,GAAG;YAChBmB,SAAS,IAAIC,wBAAe,CAAC,IAAI,CAACd,OAAO;YACzCe,KAAKhB,KAAKgB,GAAG,GACT,IAAIC,gBAAO,CAACjB,KAAKgB,GAAG,EAAE;gBACpBf,SAASiB,IAAAA,gCAAyB,EAAC,IAAI,CAACjB,OAAO;gBAC/CkB,YAAYnB,KAAKmB,UAAU;YAC7B,K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AAQO,GAAG,CAAC,wBAAwB4B,IAAAA,kBAAW,EAACE;QAEhDvC,sBAAsBC,MAAMC;QAC5B,OAAO,IAAIP,aAAa,MAAM;YAAE,GAAGM,IAAI;YAAEC;QAAQ;IACnD;IAEA,OAAOsC,KAAKvC,IAA6B,EAAE;QACzC,MAAMC,UAAU,IAAIE,QAAQH,wBAAAA,KAAMC,OAAO;QACzCA,QAAQO,GAAG,CAAC,qBAAqB;QAEjCT,sBAAsBC,MAAMC;QAC5B,OAAO,IAAIP,aAAa,MAAM;YAAE,GAAGM,IAAI;YAAEC;QAAQ;IACnD;AACF"}

View File

@@ -0,0 +1 @@
export declare function revalidatePath(originalPath: string, type?: 'layout' | 'page'): void;

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "revalidatePath", {
enumerable: true,
get: function() {
return revalidatePath;
}
});
const _revalidatetag = require("./revalidate-tag");
const _utils = require("../../../shared/lib/router/utils");
const _constants = require("../../../lib/constants");
function revalidatePath(originalPath, type) {
if (originalPath.length > _constants.NEXT_CACHE_SOFT_TAG_MAX_LENGTH) {
console.warn(`Warning: revalidatePath received "${originalPath}" which exceeded max length of ${_constants.NEXT_CACHE_SOFT_TAG_MAX_LENGTH}. See more info here https://nextjs.org/docs/app/api-reference/functions/revalidatePath`);
return;
}
let normalizedPath = `${_constants.NEXT_CACHE_IMPLICIT_TAG_ID}${originalPath}`;
if (type) {
normalizedPath += `${normalizedPath.endsWith("/") ? "" : "/"}${type}`;
} else if ((0, _utils.isDynamicRoute)(originalPath)) {
console.warn(`Warning: a dynamic page path "${originalPath}" was passed to "revalidatePath" without the "page" argument. This has no affect by default, see more info here https://nextjs.org/docs/app/api-reference/functions/revalidatePath`);
}
return (0, _revalidatetag.revalidateTag)(normalizedPath);
}
//# sourceMappingURL=revalidate-path.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/spec-extension/revalidate-path.ts"],"names":["revalidatePath","originalPath","type","length","NEXT_CACHE_SOFT_TAG_MAX_LENGTH","console","warn","normalizedPath","NEXT_CACHE_IMPLICIT_TAG_ID","endsWith","isDynamicRoute","revalidateTag"],"mappings":";;;;+BAOgBA;;;eAAAA;;;+BAPc;uBACC;2BAIxB;AAEA,SAASA,eAAeC,YAAoB,EAAEC,IAAwB;IAC3E,IAAID,aAAaE,MAAM,GAAGC,yCAA8B,EAAE;QACxDC,QAAQC,IAAI,CACV,CAAC,kCAAkC,EAAEL,aAAa,+BAA+B,EAAEG,yCAA8B,CAAC,uFAAuF,CAAC;QAE5M;IACF;IAEA,IAAIG,iBAAiB,CAAC,EAAEC,qCAA0B,CAAC,EAAEP,aAAa,CAAC;IAEnE,IAAIC,MAAM;QACRK,kBAAkB,CAAC,EAAEA,eAAeE,QAAQ,CAAC,OAAO,KAAK,IAAI,EAAEP,KAAK,CAAC;IACvE,OAAO,IAAIQ,IAAAA,qBAAc,EAACT,eAAe;QACvCI,QAAQC,IAAI,CACV,CAAC,8BAA8B,EAAEL,aAAa,kLAAkL,CAAC;IAErO;IACA,OAAOU,IAAAA,4BAAa,EAACJ;AACvB"}

View File

@@ -0,0 +1 @@
export declare function revalidateTag(tag: string): void;

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "revalidateTag", {
enumerable: true,
get: function() {
return revalidateTag;
}
});
function revalidateTag(tag) {
const staticGenerationAsyncStorage = fetch.__nextGetStaticStore == null ? void 0 : fetch.__nextGetStaticStore.call(fetch);
const store = staticGenerationAsyncStorage == null ? void 0 : staticGenerationAsyncStorage.getStore();
if (!store || !store.incrementalCache) {
throw new Error(`Invariant: static generation store missing in revalidateTag ${tag}`);
}
if (!store.revalidatedTags) {
store.revalidatedTags = [];
}
if (!store.revalidatedTags.includes(tag)) {
store.revalidatedTags.push(tag);
}
if (!store.pendingRevalidates) {
store.pendingRevalidates = [];
}
store.pendingRevalidates.push(store.incrementalCache.revalidateTag == null ? void 0 : store.incrementalCache.revalidateTag.call(store.incrementalCache, tag).catch((err)=>{
console.error(`revalidateTag failed for ${tag}`, err);
}));
// TODO: only revalidate if the path matches
store.pathWasRevalidated = true;
}
//# sourceMappingURL=revalidate-tag.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/spec-extension/revalidate-tag.ts"],"names":["revalidateTag","tag","staticGenerationAsyncStorage","fetch","__nextGetStaticStore","store","getStore","incrementalCache","Error","revalidatedTags","includes","push","pendingRevalidates","catch","err","console","error","pathWasRevalidated"],"mappings":";;;;+BAKgBA;;;eAAAA;;;AAAT,SAASA,cAAcC,GAAW;IACvC,MAAMC,+BAA+B,AACnCC,MACAC,oBAAoB,oBAFe,AACnCD,MACAC,oBAAoB,MADpBD;IAGF,MAAME,QACJH,gDAAAA,6BAA8BI,QAAQ;IAExC,IAAI,CAACD,SAAS,CAACA,MAAME,gBAAgB,EAAE;QACrC,MAAM,IAAIC,MACR,CAAC,4DAA4D,EAAEP,IAAI,CAAC;IAExE;IACA,IAAI,CAACI,MAAMI,eAAe,EAAE;QAC1BJ,MAAMI,eAAe,GAAG,EAAE;IAC5B;IACA,IAAI,CAACJ,MAAMI,eAAe,CAACC,QAAQ,CAACT,MAAM;QACxCI,MAAMI,eAAe,CAACE,IAAI,CAACV;IAC7B;IAEA,IAAI,CAACI,MAAMO,kBAAkB,EAAE;QAC7BP,MAAMO,kBAAkB,GAAG,EAAE;IAC/B;IACAP,MAAMO,kBAAkB,CAACD,IAAI,CAC3BN,MAAME,gBAAgB,CAACP,aAAa,oBAApCK,MAAME,gBAAgB,CAACP,aAAa,MAApCK,MAAME,gBAAgB,EAAiBN,KAAKY,KAAK,CAAC,CAACC;QACjDC,QAAQC,KAAK,CAAC,CAAC,yBAAyB,EAAEf,IAAI,CAAC,EAAEa;IACnD;IAGF,4CAA4C;IAC5CT,MAAMY,kBAAkB,GAAG;AAC7B"}

View File

@@ -0,0 +1,6 @@
type Callback = (...args: any[]) => Promise<any>;
export declare function unstable_cache<T extends Callback>(cb: T, keyParts?: string[], options?: {
revalidate?: number | false;
tags?: string[];
}): T;
export {};

View File

@@ -0,0 +1,106 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "unstable_cache", {
enumerable: true,
get: function() {
return unstable_cache;
}
});
const _staticgenerationasyncstorageexternal = require("../../../client/components/static-generation-async-storage.external");
const _constants = require("../../../lib/constants");
const _patchfetch = require("../../lib/patch-fetch");
function unstable_cache(cb, keyParts, options = {}) {
const staticGenerationAsyncStorage = (fetch.__nextGetStaticStore == null ? void 0 : fetch.__nextGetStaticStore.call(fetch)) || _staticgenerationasyncstorageexternal.staticGenerationAsyncStorage;
if (options.revalidate === 0) {
throw new Error(`Invariant revalidate: 0 can not be passed to unstable_cache(), must be "false" or "> 0" ${cb.toString()}`);
}
const cachedCb = async (...args)=>{
const store = staticGenerationAsyncStorage == null ? void 0 : staticGenerationAsyncStorage.getStore();
const incrementalCache = (store == null ? void 0 : store.incrementalCache) || globalThis.__incrementalCache;
if (!incrementalCache) {
throw new Error(`Invariant: incrementalCache missing in unstable_cache ${cb.toString()}`);
}
const joinedKey = `${cb.toString()}-${Array.isArray(keyParts) && keyParts.join(",")}-${JSON.stringify(args)}`;
// We override the default fetch cache handling inside of the
// cache callback so that we only cache the specific values returned
// from the callback instead of also caching any fetches done inside
// of the callback as well
return staticGenerationAsyncStorage.run({
...store,
fetchCache: "only-no-store",
urlPathname: (store == null ? void 0 : store.urlPathname) || "/",
isStaticGeneration: !!(store == null ? void 0 : store.isStaticGeneration)
}, async ()=>{
const tags = (0, _patchfetch.validateTags)(options.tags || [], `unstable_cache ${cb.toString()}`);
if (Array.isArray(tags) && store) {
if (!store.tags) {
store.tags = [];
}
for (const tag of tags){
if (!store.tags.includes(tag)) {
store.tags.push(tag);
}
}
}
const implicitTags = (0, _patchfetch.addImplicitTags)(store);
const cacheKey = await (incrementalCache == null ? void 0 : incrementalCache.fetchCacheKey(joinedKey));
const cacheEntry = cacheKey && !((store == null ? void 0 : store.isOnDemandRevalidate) || incrementalCache.isOnDemandRevalidate) && await (incrementalCache == null ? void 0 : incrementalCache.get(cacheKey, {
fetchCache: true,
revalidate: options.revalidate,
tags,
softTags: implicitTags
}));
const invokeCallback = async ()=>{
const result = await cb(...args);
if (cacheKey && incrementalCache) {
await incrementalCache.set(cacheKey, {
kind: "FETCH",
data: {
headers: {},
// TODO: handle non-JSON values?
body: JSON.stringify(result),
status: 200,
url: ""
},
revalidate: typeof options.revalidate !== "number" ? _constants.CACHE_ONE_YEAR : options.revalidate
}, {
revalidate: options.revalidate,
fetchCache: true,
tags
});
}
return result;
};
if (!cacheEntry || !cacheEntry.value) {
return invokeCallback();
}
if (cacheEntry.value.kind !== "FETCH") {
console.error(`Invariant invalid cacheEntry returned for ${joinedKey}`);
return invokeCallback();
}
let cachedValue;
const isStale = cacheEntry.isStale;
if (cacheEntry) {
const resData = cacheEntry.value.data;
cachedValue = JSON.parse(resData.body);
}
if (isStale) {
if (!store) {
return invokeCallback();
} else {
if (!store.pendingRevalidates) {
store.pendingRevalidates = [];
}
store.pendingRevalidates.push(invokeCallback().catch((err)=>console.error(`revalidating cache with key: ${joinedKey}`, err)));
}
}
return cachedValue;
});
};
// TODO: once AsyncLocalStorage.run() returns the correct types this override will no longer be necessary
return cachedCb;
}
//# sourceMappingURL=unstable-cache.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/web/spec-extension/unstable-cache.ts"],"names":["unstable_cache","cb","keyParts","options","staticGenerationAsyncStorage","fetch","__nextGetStaticStore","_staticGenerationAsyncStorage","revalidate","Error","toString","cachedCb","args","store","getStore","incrementalCache","globalThis","__incrementalCache","joinedKey","Array","isArray","join","JSON","stringify","run","fetchCache","urlPathname","isStaticGeneration","tags","validateTags","tag","includes","push","implicitTags","addImplicitTags","cacheKey","fetchCacheKey","cacheEntry","isOnDemandRevalidate","get","softTags","invokeCallback","result","set","kind","data","headers","body","status","url","CACHE_ONE_YEAR","value","console","error","cachedValue","isStale","resData","parse","pendingRevalidates","catch","err"],"mappings":";;;;+BAUgBA;;;eAAAA;;;sDANT;2BACwB;4BACe;AAIvC,SAASA,eACdC,EAAK,EACLC,QAAmB,EACnBC,UAGI,CAAC,CAAC;IAEN,MAAMC,+BACJ,CAAA,AAACC,MAAcC,oBAAoB,oBAAnC,AAACD,MAAcC,oBAAoB,MAAlCD,WAA0CE,kEAA6B;IAE1E,IAAIJ,QAAQK,UAAU,KAAK,GAAG;QAC5B,MAAM,IAAIC,MACR,CAAC,wFAAwF,EAAER,GAAGS,QAAQ,GAAG,CAAC;IAE9G;IAEA,MAAMC,WAAW,OAAO,GAAGC;QACzB,MAAMC,QACJT,gDAAAA,6BAA8BU,QAAQ;QAExC,MAAMC,mBAGJF,CAAAA,yBAAAA,MAAOE,gBAAgB,KAAI,AAACC,WAAmBC,kBAAkB;QAEnE,IAAI,CAACF,kBAAkB;YACrB,MAAM,IAAIN,MACR,CAAC,sDAAsD,EAAER,GAAGS,QAAQ,GAAG,CAAC;QAE5E;QAEA,MAAMQ,YAAY,CAAC,EAAEjB,GAAGS,QAAQ,GAAG,CAAC,EAClCS,MAAMC,OAAO,CAAClB,aAAaA,SAASmB,IAAI,CAAC,KAC1C,CAAC,EAAEC,KAAKC,SAAS,CAACX,MAAM,CAAC;QAE1B,6DAA6D;QAC7D,oEAAoE;QACpE,oEAAoE;QACpE,0BAA0B;QAC1B,OAAOR,6BAA6BoB,GAAG,CACrC;YACE,GAAGX,KAAK;YACRY,YAAY;YACZC,aAAab,CAAAA,yBAAAA,MAAOa,WAAW,KAAI;YACnCC,oBAAoB,CAAC,EAACd,yBAAAA,MAAOc,kBAAkB;QACjD,GACA;YACE,MAAMC,OAAOC,IAAAA,wBAAY,EACvB1B,QAAQyB,IAAI,IAAI,EAAE,EAClB,CAAC,eAAe,EAAE3B,GAAGS,QAAQ,GAAG,CAAC;YAGnC,IAAIS,MAAMC,OAAO,CAACQ,SAASf,O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MAAMC,UAAUlB,WAAWkB,OAAO;YAElC,IAAIlB,YAAY;gBACd,MAAMmB,UAAUnB,WAAWc,KAAK,CAACN,IAAI;gBACrCS,cAAchC,KAAKmC,KAAK,CAACD,QAAQT,IAAI;YACvC;YAEA,IAAIQ,SAAS;gBACX,IAAI,CAAC1C,OAAO;oBACV,OAAO4B;gBACT,OAAO;oBACL,IAAI,CAAC5B,MAAM6C,kBAAkB,EAAE;wBAC7B7C,MAAM6C,kBAAkB,GAAG,EAAE;oBAC/B;oBACA7C,MAAM6C,kBAAkB,CAAC1B,IAAI,CAC3BS,iBAAiBkB,KAAK,CAAC,CAACC,MACtBR,QAAQC,KAAK,CAAC,CAAC,6BAA6B,EAAEnC,UAAU,CAAC,EAAE0C;gBAGjE;YACF;YACA,OAAON;QACT;IAEJ;IACA,yGAAyG;IACzG,OAAO3C;AACT"}

View File

@@ -0,0 +1,30 @@
interface UserAgent {
isBot: boolean;
ua: string;
browser: {
name?: string;
version?: string;
};
device: {
model?: string;
type?: string;
vendor?: string;
};
engine: {
name?: string;
version?: string;
};
os: {
name?: string;
version?: string;
};
cpu: {
architecture?: string;
};
}
export declare function isBot(input: string): boolean;
export declare function userAgentFromString(input: string | undefined): UserAgent;
export declare function userAgent({ headers }: {
headers: Headers;
}): UserAgent;
export {};

View File

@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
isBot: null,
userAgentFromString: null,
userAgent: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
isBot: function() {
return isBot;
},
userAgentFromString: function() {
return userAgentFromString;
},
userAgent: function() {
return userAgent;
}
});
const _uaparserjs = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/ua-parser-js"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function isBot(input) {
return /Googlebot|Mediapartners-Google|AdsBot-Google|googleweblight|Storebot-Google|Google-PageRenderer|Google-InspectionTool|Bingbot|BingPreview|Slurp|DuckDuckBot|baiduspider|yandex|sogou|LinkedInBot|bitlybot|tumblr|vkShare|quora link preview|facebookexternalhit|facebookcatalog|Twitterbot|applebot|redditbot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|ia_archiver/i.test(input);
}
function userAgentFromString(input) {
return {
...(0, _uaparserjs.default)(input),
isBot: input === undefined ? false : isBot(input)
};
}
function userAgent({ headers }) {
return userAgentFromString(headers.get("user-agent") || undefined);
}
//# sourceMappingURL=user-agent.js.map

Some files were not shown because too many files have changed in this diff Show More