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

1
node_modules/next/dist/server/accept-header.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare function acceptLanguage(header?: string, preferences?: string[]): string;

120
node_modules/next/dist/server/accept-header.js generated vendored Normal file
View File

@@ -0,0 +1,120 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "acceptLanguage", {
enumerable: true,
get: function() {
return acceptLanguage;
}
});
function parse(raw, preferences, options) {
const lowers = new Map();
const header = raw.replace(/[ \t]/g, "");
if (preferences) {
let pos = 0;
for (const preference of preferences){
const lower = preference.toLowerCase();
lowers.set(lower, {
orig: preference,
pos: pos++
});
if (options.prefixMatch) {
const parts = lower.split("-");
while(parts.pop(), parts.length > 0){
const joined = parts.join("-");
if (!lowers.has(joined)) {
lowers.set(joined, {
orig: preference,
pos: pos++
});
}
}
}
}
}
const parts = header.split(",");
const selections = [];
const map = new Set();
for(let i = 0; i < parts.length; ++i){
const part = parts[i];
if (!part) {
continue;
}
const params = part.split(";");
if (params.length > 2) {
throw new Error(`Invalid ${options.type} header`);
}
let token = params[0].toLowerCase();
if (!token) {
throw new Error(`Invalid ${options.type} header`);
}
const selection = {
token,
pos: i,
q: 1
};
if (preferences && lowers.has(token)) {
selection.pref = lowers.get(token).pos;
}
map.add(selection.token);
if (params.length === 2) {
const q = params[1];
const [key, value] = q.split("=");
if (!value || key !== "q" && key !== "Q") {
throw new Error(`Invalid ${options.type} header`);
}
const score = parseFloat(value);
if (score === 0) {
continue;
}
if (Number.isFinite(score) && score <= 1 && score >= 0.001) {
selection.q = score;
}
}
selections.push(selection);
}
selections.sort((a, b)=>{
if (b.q !== a.q) {
return b.q - a.q;
}
if (b.pref !== a.pref) {
if (a.pref === undefined) {
return 1;
}
if (b.pref === undefined) {
return -1;
}
return a.pref - b.pref;
}
return a.pos - b.pos;
});
const values = selections.map((selection)=>selection.token);
if (!preferences || !preferences.length) {
return values;
}
const preferred = [];
for (const selection of values){
if (selection === "*") {
for (const [preference, value] of lowers){
if (!map.has(preference)) {
preferred.push(value.orig);
}
}
} else {
const lower = selection.toLowerCase();
if (lowers.has(lower)) {
preferred.push(lowers.get(lower).orig);
}
}
}
return preferred;
}
function acceptLanguage(header = "", preferences) {
return parse(header, preferences, {
type: "accept-language",
prefixMatch: true
})[0] || "";
}
//# sourceMappingURL=accept-header.js.map

1
node_modules/next/dist/server/accept-header.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/server/accept-header.ts"],"names":["acceptLanguage","parse","raw","preferences","options","lowers","Map","header","replace","pos","preference","lower","toLowerCase","set","orig","prefixMatch","parts","split","pop","length","joined","join","has","selections","map","Set","i","part","params","Error","type","token","selection","q","pref","get","add","key","value","score","parseFloat","Number","isFinite","push","sort","a","b","undefined","values","preferred"],"mappings":";;;;+BAiIgBA;;;eAAAA;;;AArHhB,SAASC,MACPC,GAAW,EACXC,WAAiC,EACjCC,OAAgB;IAEhB,MAAMC,SAAS,IAAIC;IACnB,MAAMC,SAASL,IAAIM,OAAO,CAAC,UAAU;IAErC,IAAIL,aAAa;QACf,IAAIM,MAAM;QACV,KAAK,MAAMC,cAAcP,YAAa;YACpC,MAAMQ,QAAQD,WAAWE,WAAW;YACpCP,OAAOQ,GAAG,CAACF,OAAO;gBAAEG,MAAMJ;gBAAYD,KAAKA;YAAM;YACjD,IAAIL,QAAQW,WAAW,EAAE;gBACvB,MAAMC,QAAQL,MAAMM,KAAK,CAAC;gBAC1B,MAAQD,MAAME,GAAG,IAAIF,MAAMG,MAAM,GAAG,EAAI;oBACtC,MAAMC,SAASJ,MAAMK,IAAI,CAAC;oBAC1B,IAAI,CAAChB,OAAOiB,GAAG,CAACF,SAAS;wBACvBf,OAAOQ,GAAG,CAACO,QAAQ;4BAAEN,MAAMJ;4BAAYD,KAAKA;wBAAM;oBACpD;gBACF;YACF;QACF;IACF;IAEA,MAAMO,QAAQT,OAAOU,KAAK,CAAC;IAC3B,MAAMM,aAA0B,EAAE;IAClC,MAAMC,MAAM,IAAIC;IAEhB,IAAK,IAAIC,IAAI,GAAGA,IAAIV,MAAMG,MAAM,EAAE,EAAEO,EAAG;QACrC,MAAMC,OAAOX,KAAK,CAACU,EAAE;QACrB,IAAI,CAACC,MAAM;YACT;QACF;QAEA,MAAMC,SAASD,KAAKV,KAAK,CAAC;QAC1B,IAAIW,OAAOT,MAAM,GAAG,GAAG;YACrB,MAAM,IAAIU,MAAM,CAAC,QAAQ,EAAEzB,QAAQ0B,IAAI,CAAC,OAAO,CAAC;QAClD;QAEA,IAAIC,QAAQH,MAAM,CAAC,EAAE,CAAChB,WAAW;QACjC,IAAI,CAACmB,OAAO;YACV,MAAM,IAAIF,MAAM,CAAC,QAAQ,EAAEzB,QAAQ0B,IAAI,CAAC,OAAO,CAAC;QAClD;QAEA,MAAME,YAAuB;YAAED;YAAOtB,KAAKiB;YAAGO,GAAG;QAAE;QACnD,IAAI9B,eAAeE,OAAOiB,GAAG,CAACS,QAAQ;YACpCC,UAAUE,IAAI,GAAG7B,OAAO8B,GAAG,CAACJ,OAAQtB,GAAG;QACzC;QAEAe,IAAIY,GAAG,CAACJ,UAAUD,KAAK;QAEvB,IAAIH,OAAOT,MAAM,KAAK,GAAG;YACvB,MAAMc,IAAIL,MAAM,CAAC,EAAE;YACnB,MAAM,CAACS,KAAKC,MAAM,GAAGL,EAAEhB,KAAK,CAAC;YAE7B,IAAI,CAACqB,SAAUD,QAAQ,OAAOA,QAAQ,KAAM;gBAC1C,MAAM,IAAIR,MAAM,CAAC,QAAQ,EAAEzB,QAAQ0B,IAAI,CAAC,OAAO,CAAC;YAClD;YAEA,MAAMS,QAAQC,WAAWF;YACzB,IAAIC,UAAU,GAAG;gBACf;YACF;YAEA,IAAIE,OAAOC,QAAQ,CAACH,UAAUA,SAAS,KAAKA,SAAS,OAAO;gBAC1DP,UAAUC,CAAC,GAAGM;YAChB;QACF;QAEAhB,WAAWoB,IAAI,CAACX;IAClB;IAEAT,WAAWqB,IAAI,CAAC,CAACC,GAAGC;QAClB,IAAIA,EAAEb,CAAC,KAAKY,EAAEZ,CAAC,EAAE;YACf,OAAOa,EAAEb,CAAC,GAAGY,EAAEZ,CAAC;QAClB;QAEA,IAAIa,EAAEZ,IAAI,KAAKW,EAAEX,IAAI,EAAE;YACrB,IAAIW,EAAEX,IAAI,KAAKa,WAAW;gBACxB,OAAO;YACT;YAEA,IAAID,EAAEZ,IAAI,KAAKa,WAAW;gBACxB,OAAO,CAAC;YACV;YAEA,OAAOF,EAAEX,IAAI,GAAGY,EAAEZ,IAAI;QACxB;QAEA,OAAOW,EAAEpC,GAAG,GAAGqC,EAAErC,GAAG;IACtB;IAEA,MAAMuC,SAASzB,WAAWC,GAAG,CAAC,CAACQ,YAAcA,UAAUD,KAAK;IAC5D,IAAI,CAAC5B,eAAe,CAACA,YAAYgB,MAAM,EAAE;QACvC,OAAO6B;IACT;IAEA,MAAMC,YAAsB,EAAE;IAC9B,KAAK,MAAMjB,aAAagB,OAAQ;QAC9B,IAAIhB,cAAc,KAAK;YACrB,KAAK,MAAM,CAACtB,YAAY4B,MAAM,IAAIjC,OAAQ;gBACxC,IAAI,CAACmB,IAAIF,GAAG,CAACZ,aAAa;oBACxBuC,UAAUN,IAAI,CAACL,MAAMxB,IAAI;gBAC3B;YACF;QACF,OAAO;YACL,MAAMH,QAAQqB,UAAUpB,WAAW;YACnC,IAAIP,OAAOiB,GAAG,CAACX,QAAQ;gBACrBsC,UAAUN,IAAI,CAACtC,OAAO8B,GAAG,CAACxB,OAAQG,IAAI;YACxC;QACF;IACF;IAEA,OAAOmC;AACT;AAEO,SAASjD,eAAeO,SAAS,EAAE,EAAEJ,WAAsB;IAChE,OACEF,MAAMM,QAAQJ,aAAa;QACzB2B,MAAM;QACNf,aAAa;IACf,EAAE,CAAC,EAAE,IAAI;AAEb"}

View File

@@ -0,0 +1,8 @@
import type { NextApiRequestCookies } from '.';
/**
* Parse cookies from the `headers` of request
* @param req request object
*/
export declare function getCookieParser(headers: {
[key: string]: string | string[] | null | undefined;
}): () => NextApiRequestCookies;

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getCookieParser", {
enumerable: true,
get: function() {
return getCookieParser;
}
});
function getCookieParser(headers) {
return function parseCookie() {
const { cookie } = headers;
if (!cookie) {
return {};
}
const { parse: parseCookieFn } = require("next/dist/compiled/cookie");
return parseCookieFn(Array.isArray(cookie) ? cookie.join("; ") : cookie);
};
}
//# sourceMappingURL=get-cookie-parser.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/api-utils/get-cookie-parser.ts"],"names":["getCookieParser","headers","parseCookie","cookie","parse","parseCookieFn","require","Array","isArray","join"],"mappings":";;;;+BAOgBA;;;eAAAA;;;AAAT,SAASA,gBAAgBC,OAE/B;IACC,OAAO,SAASC;QACd,MAAM,EAAEC,MAAM,EAAE,GAAGF;QAEnB,IAAI,CAACE,QAAQ;YACX,OAAO,CAAC;QACV;QAEA,MAAM,EAAEC,OAAOC,aAAa,EAAE,GAAGC,QAAQ;QACzC,OAAOD,cAAcE,MAAMC,OAAO,CAACL,UAAUA,OAAOM,IAAI,CAAC,QAAQN;IACnE;AACF"}

65
node_modules/next/dist/server/api-utils/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,65 @@
/// <reference types="node" />
import type { IncomingMessage } from 'http';
import type { BaseNextRequest } from '../base-http';
import type { NextApiResponse } from '../../shared/lib/utils';
export type NextApiRequestCookies = Partial<{
[key: string]: string;
}>;
export type NextApiRequestQuery = Partial<{
[key: string]: string | string[];
}>;
export type __ApiPreviewProps = {
previewModeId: string;
previewModeEncryptionKey: string;
previewModeSigningKey: string;
};
/**
*
* @param res response object
* @param statusCode `HTTP` status code of response
*/
export declare function sendStatusCode(res: NextApiResponse, statusCode: number): NextApiResponse<any>;
/**
*
* @param res response object
* @param [statusOrUrl] `HTTP` status code of redirect
* @param url URL of redirect
*/
export declare function redirect(res: NextApiResponse, statusOrUrl: string | number, url?: string): NextApiResponse<any>;
export declare function checkIsOnDemandRevalidate(req: Request | IncomingMessage | BaseNextRequest, previewProps: __ApiPreviewProps): {
isOnDemandRevalidate: boolean;
revalidateOnlyGenerated: boolean;
};
export declare const COOKIE_NAME_PRERENDER_BYPASS = "__prerender_bypass";
export declare const COOKIE_NAME_PRERENDER_DATA = "__next_preview_data";
export declare const RESPONSE_LIMIT_DEFAULT: number;
export declare const SYMBOL_PREVIEW_DATA: unique symbol;
export declare const SYMBOL_CLEARED_COOKIES: unique symbol;
export declare function clearPreviewData<T>(res: NextApiResponse<T>, options?: {
path?: string;
}): NextApiResponse<T>;
/**
* Custom error class
*/
export declare class ApiError extends Error {
readonly statusCode: number;
constructor(statusCode: number, message: string);
}
/**
* Sends error in `response`
* @param res response object
* @param statusCode of response
* @param message of response
*/
export declare function sendError(res: NextApiResponse, statusCode: number, message: string): void;
interface LazyProps {
req: IncomingMessage;
}
/**
* Execute getter function only if its needed
* @param LazyProps `req` and `params` for lazyProp
* @param prop name of property
* @param getter function to get data
*/
export declare function setLazyProp<T>({ req }: LazyProps, prop: string, getter: () => T): void;
export {};

182
node_modules/next/dist/server/api-utils/index.js generated vendored Normal file
View File

@@ -0,0 +1,182 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
sendStatusCode: null,
redirect: null,
checkIsOnDemandRevalidate: null,
COOKIE_NAME_PRERENDER_BYPASS: null,
COOKIE_NAME_PRERENDER_DATA: null,
RESPONSE_LIMIT_DEFAULT: null,
SYMBOL_PREVIEW_DATA: null,
SYMBOL_CLEARED_COOKIES: null,
clearPreviewData: null,
ApiError: null,
sendError: null,
setLazyProp: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
sendStatusCode: function() {
return sendStatusCode;
},
redirect: function() {
return redirect;
},
checkIsOnDemandRevalidate: function() {
return checkIsOnDemandRevalidate;
},
COOKIE_NAME_PRERENDER_BYPASS: function() {
return COOKIE_NAME_PRERENDER_BYPASS;
},
COOKIE_NAME_PRERENDER_DATA: function() {
return COOKIE_NAME_PRERENDER_DATA;
},
RESPONSE_LIMIT_DEFAULT: function() {
return RESPONSE_LIMIT_DEFAULT;
},
SYMBOL_PREVIEW_DATA: function() {
return SYMBOL_PREVIEW_DATA;
},
SYMBOL_CLEARED_COOKIES: function() {
return SYMBOL_CLEARED_COOKIES;
},
clearPreviewData: function() {
return clearPreviewData;
},
ApiError: function() {
return ApiError;
},
sendError: function() {
return sendError;
},
setLazyProp: function() {
return setLazyProp;
}
});
const _headers = require("../web/spec-extension/adapters/headers");
const _constants = require("../../lib/constants");
function sendStatusCode(res, statusCode) {
res.statusCode = statusCode;
return res;
}
function redirect(res, statusOrUrl, url) {
if (typeof statusOrUrl === "string") {
url = statusOrUrl;
statusOrUrl = 307;
}
if (typeof statusOrUrl !== "number" || typeof url !== "string") {
throw new Error(`Invalid redirect arguments. Please use a single argument URL, e.g. res.redirect('/destination') or use a status code and URL, e.g. res.redirect(307, '/destination').`);
}
res.writeHead(statusOrUrl, {
Location: url
});
res.write(url);
res.end();
return res;
}
function checkIsOnDemandRevalidate(req, previewProps) {
const headers = _headers.HeadersAdapter.from(req.headers);
const previewModeId = headers.get(_constants.PRERENDER_REVALIDATE_HEADER);
const isOnDemandRevalidate = previewModeId === previewProps.previewModeId;
const revalidateOnlyGenerated = headers.has(_constants.PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER);
return {
isOnDemandRevalidate,
revalidateOnlyGenerated
};
}
const COOKIE_NAME_PRERENDER_BYPASS = `__prerender_bypass`;
const COOKIE_NAME_PRERENDER_DATA = `__next_preview_data`;
const RESPONSE_LIMIT_DEFAULT = 4 * 1024 * 1024;
const SYMBOL_PREVIEW_DATA = Symbol(COOKIE_NAME_PRERENDER_DATA);
const SYMBOL_CLEARED_COOKIES = Symbol(COOKIE_NAME_PRERENDER_BYPASS);
function clearPreviewData(res, options = {}) {
if (SYMBOL_CLEARED_COOKIES in res) {
return res;
}
const { serialize } = require("next/dist/compiled/cookie");
const previous = res.getHeader("Set-Cookie");
res.setHeader(`Set-Cookie`, [
...typeof previous === "string" ? [
previous
] : Array.isArray(previous) ? previous : [],
serialize(COOKIE_NAME_PRERENDER_BYPASS, "", {
// To delete a cookie, set `expires` to a date in the past:
// https://tools.ietf.org/html/rfc6265#section-4.1.1
// `Max-Age: 0` is not valid, thus ignored, and the cookie is persisted.
expires: new Date(0),
httpOnly: true,
sameSite: process.env.NODE_ENV !== "development" ? "none" : "lax",
secure: process.env.NODE_ENV !== "development",
path: "/",
...options.path !== undefined ? {
path: options.path
} : undefined
}),
serialize(COOKIE_NAME_PRERENDER_DATA, "", {
// To delete a cookie, set `expires` to a date in the past:
// https://tools.ietf.org/html/rfc6265#section-4.1.1
// `Max-Age: 0` is not valid, thus ignored, and the cookie is persisted.
expires: new Date(0),
httpOnly: true,
sameSite: process.env.NODE_ENV !== "development" ? "none" : "lax",
secure: process.env.NODE_ENV !== "development",
path: "/",
...options.path !== undefined ? {
path: options.path
} : undefined
})
]);
Object.defineProperty(res, SYMBOL_CLEARED_COOKIES, {
value: true,
enumerable: false
});
return res;
}
class ApiError extends Error {
constructor(statusCode, message){
super(message);
this.statusCode = statusCode;
}
}
function sendError(res, statusCode, message) {
res.statusCode = statusCode;
res.statusMessage = message;
res.end(message);
}
function setLazyProp({ req }, prop, getter) {
const opts = {
configurable: true,
enumerable: true
};
const optsReset = {
...opts,
writable: true
};
Object.defineProperty(req, prop, {
...opts,
get: ()=>{
const value = getter();
// we set the property on the object to avoid recalculating it
Object.defineProperty(req, prop, {
...optsReset,
value
});
return value;
},
set: (value)=>{
Object.defineProperty(req, prop, {
...optsReset,
value
});
}
});
}
//# sourceMappingURL=index.js.map

1
node_modules/next/dist/server/api-utils/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/api-utils/index.ts"],"names":["sendStatusCode","redirect","checkIsOnDemandRevalidate","COOKIE_NAME_PRERENDER_BYPASS","COOKIE_NAME_PRERENDER_DATA","RESPONSE_LIMIT_DEFAULT","SYMBOL_PREVIEW_DATA","SYMBOL_CLEARED_COOKIES","clearPreviewData","ApiError","sendError","setLazyProp","res","statusCode","statusOrUrl","url","Error","writeHead","Location","write","end","req","previewProps","headers","HeadersAdapter","from","previewModeId","get","PRERENDER_REVALIDATE_HEADER","isOnDemandRevalidate","revalidateOnlyGenerated","has","PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER","Symbol","options","serialize","require","previous","getHeader","setHeader","Array","isArray","expires","Date","httpOnly","sameSite","process","env","NODE_ENV","secure","path","undefined","Object","defineProperty","value","enumerable","constructor","message","statusMessage","prop","getter","opts","configurable","optsReset","writable","set"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;IAyBgBA,cAAc;eAAdA;;IAcAC,QAAQ;eAARA;;IAoBAC,yBAAyB;eAAzBA;;IAmBHC,4BAA4B;eAA5BA;;IACAC,0BAA0B;eAA1BA;;IAEAC,sBAAsB;eAAtBA;;IAEAC,mBAAmB;eAAnBA;;IACAC,sBAAsB;eAAtBA;;IAEGC,gBAAgB;eAAhBA;;IAyDHC,QAAQ;eAARA;;IAeGC,SAAS;eAATA;;IAoBAC,WAAW;eAAXA;;;yBA7Ke;2BAIxB;AAgBA,SAASX,eACdY,GAAoB,EACpBC,UAAkB;IAElBD,IAAIC,UAAU,GAAGA;IACjB,OAAOD;AACT;AAQO,SAASX,SACdW,GAAoB,EACpBE,WAA4B,EAC5BC,GAAY;IAEZ,IAAI,OAAOD,gBAAgB,UAAU;QACnCC,MAAMD;QACNA,cAAc;IAChB;IACA,IAAI,OAAOA,gBAAgB,YAAY,OAAOC,QAAQ,UAAU;QAC9D,MAAM,IAAIC,MACR,CAAC,qKAAqK,CAAC;IAE3K;IACAJ,IAAIK,SAAS,CAACH,aAAa;QAAEI,UAAUH;IAAI;IAC3CH,IAAIO,KAAK,CAACJ;IACVH,IAAIQ,GAAG;IACP,OAAOR;AACT;AAEO,SAASV,0BACdmB,GAAgD,EAChDC,YAA+B;IAK/B,MAAMC,UAAUC,uBAAc,CAACC,IAAI,CAACJ,IAAIE,OAAO;IAE/C,MAAMG,gBAAgBH,QAAQI,GAAG,CAACC,sCAA2B;IAC7D,MAAMC,uBAAuBH,kBAAkBJ,aAAaI,aAAa;IAEzE,MAAMI,0BAA0BP,QAAQQ,GAAG,CACzCC,qDAA0C;IAG5C,OAAO;QAAEH;QAAsBC;IAAwB;AACzD;AAEO,MAAM3B,+BAA+B,CAAC,kBAAkB,CAAC;AACzD,MAAMC,6BAA6B,CAAC,mBAAmB,CAAC;AAExD,MAAMC,yBAAyB,IAAI,OAAO;AAE1C,MAAMC,sBAAsB2B,OAAO7B;AACnC,MAAMG,yBAAyB0B,OAAO9B;AAEtC,SAASK,iBACdI,GAAuB,EACvBsB,UAEI,CAAC,CAAC;IAEN,IAAI3B,0BAA0BK,KAAK;QACjC,OAAOA;IACT;IAEA,MAAM,EAAEuB,SAAS,EAAE,GACjBC,QAAQ;IACV,MAAMC,WAAWzB,IAAI0B,SAAS,CAAC;IAC/B1B,IAAI2B,SAAS,CAAC,CAAC,UAAU,CAAC,EAAE;WACtB,OAAOF,aAAa,WACpB;YAACA;SAAS,GACVG,MAAMC,OAAO,CAACJ,YACdA,WACA,EAAE;QACNF,UAAUhC,8BAA8B,IAAI;YAC1C,2DAA2D;YAC3D,oDAAoD;YACpD,wEAAwE;YACxEuC,SAAS,IAAIC,KAAK;YAClBC,UAAU;YACVC,UAAUC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBAAgB,SAAS;YAC5DC,QAAQH,QAAQC,GAAG,CAACC,QAAQ,KAAK;YACjCE,MAAM;YACN,GAAIhB,QAAQgB,IAAI,KAAKC,YAChB;gBAAED,MAAMhB,QAAQgB,IAAI;YAAC,IACtBC,SAAS;QACf;QACAhB,UAAU/B,4BAA4B,IAAI;YACxC,2DAA2D;YAC3D,oDAAoD;YACpD,wEAAwE;YACxEsC,SAAS,IAAIC,KAAK;YAClBC,UAAU;YACVC,UAAUC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBAAgB,SAAS;YAC5DC,QAAQH,QAAQC,GAAG,CAACC,QAAQ,KAAK;YACjCE,MAAM;YACN,GAAIhB,QAAQgB,IAAI,KAAKC,YAChB;gBAAED,MAAMhB,QAAQgB,IAAI;YAAC,IACtBC,SAAS;QACf;KACD;IAEDC,OAAOC,cAAc,CAACzC,KAAKL,wBAAwB;QACjD+C,OAAO;QACPC,YAAY;IACd;IACA,OAAO3C;AACT;AAKO,MAAMH,iBAAiBO;IAG5BwC,YAAY3C,UAAkB,EAAE4C,OAAe,CAAE;QAC/C,KAAK,CAACA;QACN,IAAI,CAAC5C,UAAU,GAAGA;IACpB;AACF;AAQO,SAASH,UACdE,GAAoB,EACpBC,UAAkB,EAClB4C,OAAe;IAEf7C,IAAIC,UAAU,GAAGA;IACjBD,IAAI8C,aAAa,GAAGD;IACpB7C,IAAIQ,GAAG,CAACqC;AACV;AAYO,SAAS9C,YACd,EAAEU,GAAG,EAAa,EAClBsC,IAAY,EACZC,MAAe;IAEf,MAAMC,OAAO;QAAEC,cAAc;QAAMP,YAAY;IAAK;IACpD,MAAMQ,YAAY;QAAE,GAAGF,IAAI;QAAEG,UAAU;IAAK;IAE5CZ,OAAOC,cAAc,CAAChC,KAAKsC,MAAM;QAC/B,GAAGE,IAAI;QACPlC,KAAK;YACH,MAAM2B,QAAQM;YACd,8DAA8D;YAC9DR,OAAOC,cAAc,CAAChC,KAAKsC,MAAM;gBAAE,GAAGI,SAAS;gBAAET;YAAM;YACvD,OAAOA;QACT;QACAW,KAAK,CAACX;YACJF,OAAOC,cAAc,CAAChC,KAAKsC,MAAM;gBAAE,GAAGI,SAAS;gBAAET;YAAM;QACzD;IACF;AACF"}

29
node_modules/next/dist/server/api-utils/node.d.ts generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/// <reference types="node" />
import type { IncomingMessage, ServerResponse } from 'http';
import type { SizeLimit } from 'next/types';
import { __ApiPreviewProps } from '.';
import type { BaseNextRequest, BaseNextResponse } from '../base-http';
import type { PreviewData } from 'next/types';
export declare function tryGetPreviewData(req: IncomingMessage | BaseNextRequest | Request, res: ServerResponse | BaseNextResponse, options: __ApiPreviewProps): PreviewData;
/**
* Parse incoming message like `json` or `urlencoded`
* @param req request object
*/
export declare function parseBody(req: IncomingMessage, limit: SizeLimit): Promise<any>;
type RevalidateFn = (config: {
urlPath: string;
revalidateHeaders: {
[key: string]: string | string[];
};
opts: {
unstable_onlyGenerated?: boolean;
};
}) => Promise<void>;
type ApiContext = __ApiPreviewProps & {
trustHostHeader?: boolean;
allowedRevalidateHeaderKeys?: string[];
hostname?: string;
revalidate?: RevalidateFn;
};
export declare function apiResolver(req: IncomingMessage, res: ServerResponse, query: any, resolverModule: any, apiContext: ApiContext, propagateError: boolean, dev?: boolean, page?: string): Promise<void>;
export {};

467
node_modules/next/dist/server/api-utils/node.js generated vendored Normal file
View File

@@ -0,0 +1,467 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
tryGetPreviewData: null,
parseBody: null,
apiResolver: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
tryGetPreviewData: function() {
return tryGetPreviewData;
},
parseBody: function() {
return parseBody;
},
apiResolver: function() {
return apiResolver;
}
});
const _ = require(".");
const _bytes = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/bytes"));
const _etag = require("../lib/etag");
const _sendpayload = require("../send-payload");
const _stream = require("stream");
const _contenttype = require("next/dist/compiled/content-type");
const _iserror = /*#__PURE__*/ _interop_require_default(require("../../lib/is-error"));
const _utils = require("../../shared/lib/utils");
const _interopdefault = require("../../lib/interop-default");
const _index = require("./index");
const _getcookieparser = require("./get-cookie-parser");
const _tracer = require("../lib/trace/tracer");
const _constants = require("../lib/trace/constants");
const _cookies = require("../web/spec-extension/cookies");
const _headers = require("../web/spec-extension/adapters/headers");
const _constants1 = require("../../lib/constants");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function tryGetPreviewData(req, res, options) {
var _cookies_get, _cookies_get1;
// if an On-Demand revalidation is being done preview mode
// is disabled
if (options && (0, _.checkIsOnDemandRevalidate)(req, options).isOnDemandRevalidate) {
return false;
}
// Read cached preview data if present
// TODO: use request metadata instead of a symbol
if (_index.SYMBOL_PREVIEW_DATA in req) {
return req[_index.SYMBOL_PREVIEW_DATA];
}
const headers = _headers.HeadersAdapter.from(req.headers);
const cookies = new _cookies.RequestCookies(headers);
const previewModeId = (_cookies_get = cookies.get(_index.COOKIE_NAME_PRERENDER_BYPASS)) == null ? void 0 : _cookies_get.value;
const tokenPreviewData = (_cookies_get1 = cookies.get(_index.COOKIE_NAME_PRERENDER_DATA)) == null ? void 0 : _cookies_get1.value;
// Case: preview mode cookie set but data cookie is not set
if (previewModeId && !tokenPreviewData && previewModeId === options.previewModeId) {
// This is "Draft Mode" which doesn't use
// previewData, so we return an empty object
// for backwards compat with "Preview Mode".
const data = {};
Object.defineProperty(req, _index.SYMBOL_PREVIEW_DATA, {
value: data,
enumerable: false
});
return data;
}
// Case: neither cookie is set.
if (!previewModeId && !tokenPreviewData) {
return false;
}
// Case: one cookie is set, but not the other.
if (!previewModeId || !tokenPreviewData) {
(0, _index.clearPreviewData)(res);
return false;
}
// Case: preview session is for an old build.
if (previewModeId !== options.previewModeId) {
(0, _index.clearPreviewData)(res);
return false;
}
let encryptedPreviewData;
try {
const jsonwebtoken = require("next/dist/compiled/jsonwebtoken");
encryptedPreviewData = jsonwebtoken.verify(tokenPreviewData, options.previewModeSigningKey);
} catch {
// TODO: warn
(0, _index.clearPreviewData)(res);
return false;
}
const { decryptWithSecret } = require("../crypto-utils");
const decryptedPreviewData = decryptWithSecret(Buffer.from(options.previewModeEncryptionKey), encryptedPreviewData.data);
try {
// TODO: strict runtime type checking
const data = JSON.parse(decryptedPreviewData);
// Cache lookup
Object.defineProperty(req, _index.SYMBOL_PREVIEW_DATA, {
value: data,
enumerable: false
});
return data;
} catch {
return false;
}
}
/**
* Parse `JSON` and handles invalid `JSON` strings
* @param str `JSON` string
*/ function parseJson(str) {
if (str.length === 0) {
// special-case empty json body, as it's a common client-side mistake
return {};
}
try {
return JSON.parse(str);
} catch (e) {
throw new _index.ApiError(400, "Invalid JSON");
}
}
async function parseBody(req, limit) {
let contentType;
try {
contentType = (0, _contenttype.parse)(req.headers["content-type"] || "text/plain");
} catch {
contentType = (0, _contenttype.parse)("text/plain");
}
const { type, parameters } = contentType;
const encoding = parameters.charset || "utf-8";
let buffer;
try {
const getRawBody = require("next/dist/compiled/raw-body");
buffer = await getRawBody(req, {
encoding,
limit
});
} catch (e) {
if ((0, _iserror.default)(e) && e.type === "entity.too.large") {
throw new _index.ApiError(413, `Body exceeded ${limit} limit`);
} else {
throw new _index.ApiError(400, "Invalid body");
}
}
const body = buffer.toString();
if (type === "application/json" || type === "application/ld+json") {
return parseJson(body);
} else if (type === "application/x-www-form-urlencoded") {
const qs = require("querystring");
return qs.decode(body);
} else {
return body;
}
}
function getMaxContentLength(responseLimit) {
if (responseLimit && typeof responseLimit !== "boolean") {
return _bytes.default.parse(responseLimit);
}
return _index.RESPONSE_LIMIT_DEFAULT;
}
/**
* Send `any` body to response
* @param req request object
* @param res response object
* @param body of response
*/ function sendData(req, res, body) {
if (body === null || body === undefined) {
res.end();
return;
}
// strip irrelevant headers/body
if (res.statusCode === 204 || res.statusCode === 304) {
res.removeHeader("Content-Type");
res.removeHeader("Content-Length");
res.removeHeader("Transfer-Encoding");
if (process.env.NODE_ENV === "development" && body) {
console.warn(`A body was attempted to be set with a 204 statusCode for ${req.url}, this is invalid and the body was ignored.\n` + `See more info here https://nextjs.org/docs/messages/invalid-api-status-body`);
}
res.end();
return;
}
const contentType = res.getHeader("Content-Type");
if (body instanceof _stream.Stream) {
if (!contentType) {
res.setHeader("Content-Type", "application/octet-stream");
}
body.pipe(res);
return;
}
const isJSONLike = [
"object",
"number",
"boolean"
].includes(typeof body);
const stringifiedBody = isJSONLike ? JSON.stringify(body) : body;
const etag = (0, _etag.generateETag)(stringifiedBody);
if ((0, _sendpayload.sendEtagResponse)(req, res, etag)) {
return;
}
if (Buffer.isBuffer(body)) {
if (!contentType) {
res.setHeader("Content-Type", "application/octet-stream");
}
res.setHeader("Content-Length", body.length);
res.end(body);
return;
}
if (isJSONLike) {
res.setHeader("Content-Type", "application/json; charset=utf-8");
}
res.setHeader("Content-Length", Buffer.byteLength(stringifiedBody));
res.end(stringifiedBody);
}
/**
* Send `JSON` object
* @param res response object
* @param jsonBody of data
*/ function sendJson(res, jsonBody) {
// Set header to application/json
res.setHeader("Content-Type", "application/json; charset=utf-8");
// Use send to handle request
res.send(JSON.stringify(jsonBody));
}
function isValidData(str) {
return typeof str === "string" && str.length >= 16;
}
function setDraftMode(res, options) {
if (!isValidData(options.previewModeId)) {
throw new Error("invariant: invalid previewModeId");
}
const expires = options.enable ? undefined : new Date(0);
// To delete a cookie, set `expires` to a date in the past:
// https://tools.ietf.org/html/rfc6265#section-4.1.1
// `Max-Age: 0` is not valid, thus ignored, and the cookie is persisted.
const { serialize } = require("next/dist/compiled/cookie");
const previous = res.getHeader("Set-Cookie");
res.setHeader(`Set-Cookie`, [
...typeof previous === "string" ? [
previous
] : Array.isArray(previous) ? previous : [],
serialize(_index.COOKIE_NAME_PRERENDER_BYPASS, options.previewModeId, {
httpOnly: true,
sameSite: process.env.NODE_ENV !== "development" ? "none" : "lax",
secure: process.env.NODE_ENV !== "development",
path: "/",
expires
})
]);
return res;
}
function setPreviewData(res, data, options) {
if (!isValidData(options.previewModeId)) {
throw new Error("invariant: invalid previewModeId");
}
if (!isValidData(options.previewModeEncryptionKey)) {
throw new Error("invariant: invalid previewModeEncryptionKey");
}
if (!isValidData(options.previewModeSigningKey)) {
throw new Error("invariant: invalid previewModeSigningKey");
}
const jsonwebtoken = require("next/dist/compiled/jsonwebtoken");
const { encryptWithSecret } = require("../crypto-utils");
const payload = jsonwebtoken.sign({
data: encryptWithSecret(Buffer.from(options.previewModeEncryptionKey), JSON.stringify(data))
}, options.previewModeSigningKey, {
algorithm: "HS256",
...options.maxAge !== undefined ? {
expiresIn: options.maxAge
} : undefined
});
// limit preview mode cookie to 2KB since we shouldn't store too much
// data here and browsers drop cookies over 4KB
if (payload.length > 2048) {
throw new Error(`Preview data is limited to 2KB currently, reduce how much data you are storing as preview data to continue`);
}
const { serialize } = require("next/dist/compiled/cookie");
const previous = res.getHeader("Set-Cookie");
res.setHeader(`Set-Cookie`, [
...typeof previous === "string" ? [
previous
] : Array.isArray(previous) ? previous : [],
serialize(_index.COOKIE_NAME_PRERENDER_BYPASS, options.previewModeId, {
httpOnly: true,
sameSite: process.env.NODE_ENV !== "development" ? "none" : "lax",
secure: process.env.NODE_ENV !== "development",
path: "/",
...options.maxAge !== undefined ? {
maxAge: options.maxAge
} : undefined,
...options.path !== undefined ? {
path: options.path
} : undefined
}),
serialize(_index.COOKIE_NAME_PRERENDER_DATA, payload, {
httpOnly: true,
sameSite: process.env.NODE_ENV !== "development" ? "none" : "lax",
secure: process.env.NODE_ENV !== "development",
path: "/",
...options.maxAge !== undefined ? {
maxAge: options.maxAge
} : undefined,
...options.path !== undefined ? {
path: options.path
} : undefined
})
]);
return res;
}
async function revalidate(urlPath, opts, req, context) {
if (typeof urlPath !== "string" || !urlPath.startsWith("/")) {
throw new Error(`Invalid urlPath provided to revalidate(), must be a path e.g. /blog/post-1, received ${urlPath}`);
}
const revalidateHeaders = {
[_constants1.PRERENDER_REVALIDATE_HEADER]: context.previewModeId,
...opts.unstable_onlyGenerated ? {
[_constants1.PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER]: "1"
} : {}
};
const allowedRevalidateHeaderKeys = [
...context.allowedRevalidateHeaderKeys || [],
...context.trustHostHeader ? [
"cookie",
"x-vercel-protection-bypass"
] : []
];
for (const key of Object.keys(req.headers)){
if (allowedRevalidateHeaderKeys.includes(key)) {
revalidateHeaders[key] = req.headers[key];
}
}
try {
if (context.trustHostHeader) {
const res = await fetch(`https://${req.headers.host}${urlPath}`, {
method: "HEAD",
headers: revalidateHeaders
});
// we use the cache header to determine successful revalidate as
// a non-200 status code can be returned from a successful revalidate
// e.g. notFound: true returns 404 status code but is successful
const cacheHeader = res.headers.get("x-vercel-cache") || res.headers.get("x-nextjs-cache");
if ((cacheHeader == null ? void 0 : cacheHeader.toUpperCase()) !== "REVALIDATED" && !(res.status === 404 && opts.unstable_onlyGenerated)) {
throw new Error(`Invalid response ${res.status}`);
}
} else if (context.revalidate) {
await context.revalidate({
urlPath,
revalidateHeaders,
opts
});
} else {
throw new Error(`Invariant: required internal revalidate method not passed to api-utils`);
}
} catch (err) {
throw new Error(`Failed to revalidate ${urlPath}: ${(0, _iserror.default)(err) ? err.message : err}`);
}
}
async function apiResolver(req, res, query, resolverModule, apiContext, propagateError, dev, page) {
const apiReq = req;
const apiRes = res;
try {
var _config_api, _config_api1, _config_api2, _getTracer_getRootSpanAttributes;
if (!resolverModule) {
res.statusCode = 404;
res.end("Not Found");
return;
}
const config = resolverModule.config || {};
const bodyParser = ((_config_api = config.api) == null ? void 0 : _config_api.bodyParser) !== false;
const responseLimit = ((_config_api1 = config.api) == null ? void 0 : _config_api1.responseLimit) ?? true;
const externalResolver = ((_config_api2 = config.api) == null ? void 0 : _config_api2.externalResolver) || false;
// Parsing of cookies
(0, _index.setLazyProp)({
req: apiReq
}, "cookies", (0, _getcookieparser.getCookieParser)(req.headers));
// Parsing query string
apiReq.query = query;
// Parsing preview data
(0, _index.setLazyProp)({
req: apiReq
}, "previewData", ()=>tryGetPreviewData(req, res, apiContext));
// Checking if preview mode is enabled
(0, _index.setLazyProp)({
req: apiReq
}, "preview", ()=>apiReq.previewData !== false ? true : undefined);
// Set draftMode to the same value as preview
(0, _index.setLazyProp)({
req: apiReq
}, "draftMode", ()=>apiReq.preview);
// Parsing of body
if (bodyParser && !apiReq.body) {
apiReq.body = await parseBody(apiReq, config.api && config.api.bodyParser && config.api.bodyParser.sizeLimit ? config.api.bodyParser.sizeLimit : "1mb");
}
let contentLength = 0;
const maxContentLength = getMaxContentLength(responseLimit);
const writeData = apiRes.write;
const endResponse = apiRes.end;
apiRes.write = (...args)=>{
contentLength += Buffer.byteLength(args[0] || "");
return writeData.apply(apiRes, args);
};
apiRes.end = (...args)=>{
if (args.length && typeof args[0] !== "function") {
contentLength += Buffer.byteLength(args[0] || "");
}
if (responseLimit && contentLength >= maxContentLength) {
console.warn(`API response for ${req.url} exceeds ${_bytes.default.format(maxContentLength)}. API Routes are meant to respond quickly. https://nextjs.org/docs/messages/api-routes-response-size-limit`);
}
return endResponse.apply(apiRes, args);
};
apiRes.status = (statusCode)=>(0, _index.sendStatusCode)(apiRes, statusCode);
apiRes.send = (data)=>sendData(apiReq, apiRes, data);
apiRes.json = (data)=>sendJson(apiRes, data);
apiRes.redirect = (statusOrUrl, url)=>(0, _index.redirect)(apiRes, statusOrUrl, url);
apiRes.setDraftMode = (options = {
enable: true
})=>setDraftMode(apiRes, Object.assign({}, apiContext, options));
apiRes.setPreviewData = (data, options = {})=>setPreviewData(apiRes, data, Object.assign({}, apiContext, options));
apiRes.clearPreviewData = (options = {})=>(0, _index.clearPreviewData)(apiRes, options);
apiRes.revalidate = (urlPath, opts)=>revalidate(urlPath, opts || {}, req, apiContext);
const resolver = (0, _interopdefault.interopDefault)(resolverModule);
let wasPiped = false;
if (process.env.NODE_ENV !== "production") {
// listen for pipe event and don't show resolve warning
res.once("pipe", ()=>wasPiped = true);
}
(_getTracer_getRootSpanAttributes = (0, _tracer.getTracer)().getRootSpanAttributes()) == null ? void 0 : _getTracer_getRootSpanAttributes.set("next.route", page);
// Call API route method
const apiRouteResult = await (0, _tracer.getTracer)().trace(_constants.NodeSpan.runHandler, {
spanName: `executing api route (pages) ${page}`
}, ()=>resolver(req, res));
if (process.env.NODE_ENV !== "production") {
if (typeof apiRouteResult !== "undefined") {
if (apiRouteResult instanceof Response) {
throw new Error('API route returned a Response object in the Node.js runtime, this is not supported. Please use `runtime: "edge"` instead: https://nextjs.org/docs/api-routes/edge-api-routes');
}
console.warn(`API handler should not return a value, received ${typeof apiRouteResult}.`);
}
if (!externalResolver && !(0, _utils.isResSent)(res) && !wasPiped) {
console.warn(`API resolved without sending a response for ${req.url}, this may result in stalled requests.`);
}
}
} catch (err) {
if (err instanceof _index.ApiError) {
(0, _index.sendError)(apiRes, err.statusCode, err.message);
} else {
if (dev) {
if ((0, _iserror.default)(err)) {
err.page = page;
}
throw err;
}
console.error(err);
if (propagateError) {
throw err;
}
(0, _index.sendError)(apiRes, 500, "Internal Server Error");
}
}
}
//# sourceMappingURL=node.js.map

1
node_modules/next/dist/server/api-utils/node.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

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

@@ -0,0 +1 @@
export declare function byteLength(payload: string): number;

17
node_modules/next/dist/server/api-utils/web.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
// Buffer.byteLength polyfill in the Edge runtime, with only utf8 strings
// supported at the moment.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "byteLength", {
enumerable: true,
get: function() {
return byteLength;
}
});
function byteLength(payload) {
return new TextEncoder().encode(payload).buffer.byteLength;
}
//# sourceMappingURL=web.js.map

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

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/api-utils/web.ts"],"names":["byteLength","payload","TextEncoder","encode","buffer"],"mappings":"AAAA,yEAAyE;AACzE,2BAA2B;;;;;+BACXA;;;eAAAA;;;AAAT,SAASA,WAAWC,OAAe;IACxC,OAAO,IAAIC,cAAcC,MAAM,CAACF,SAASG,MAAM,CAACJ,UAAU;AAC5D"}

View File

@@ -0,0 +1,22 @@
/// <reference types="node" />
import type { IncomingMessage, ServerResponse } from 'http';
import type { SizeLimit } from '../../../types';
import RenderResult from '../render-result';
import { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external';
import { ActionResult } from './types';
import { RequestStore } from '../../client/components/request-async-storage.external';
export declare function handleAction({ req, res, ComponentMod, page, serverActionsManifest, generateFlight, staticGenerationStore, requestStore, serverActionsBodySizeLimit, }: {
req: IncomingMessage;
res: ServerResponse;
ComponentMod: any;
page: string;
serverActionsManifest: any;
generateFlight: (options: {
actionResult: ActionResult;
skipFlight: boolean;
asNotFound?: boolean;
}) => Promise<RenderResult>;
staticGenerationStore: StaticGenerationStore;
requestStore: RequestStore;
serverActionsBodySizeLimit?: SizeLimit;
}): Promise<undefined | RenderResult | 'not-found'>;

View File

@@ -0,0 +1,360 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "handleAction", {
enumerable: true,
get: function() {
return handleAction;
}
});
const _approuterheaders = require("../../client/components/app-router-headers");
const _notfound = require("../../client/components/not-found");
const _redirect = require("../../client/components/redirect");
const _renderresult = /*#__PURE__*/ _interop_require_default(require("../render-result"));
const _flightrenderresult = require("./flight-render-result");
const _utils = require("../lib/server-ipc/utils");
const _requestcookies = require("../web/spec-extension/adapters/request-cookies");
const _constants = require("../../lib/constants");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function nodeToWebReadableStream(nodeReadable) {
if (process.env.NEXT_RUNTIME !== "edge") {
const { Readable } = require("stream");
if ("toWeb" in Readable && typeof Readable.toWeb === "function") {
return Readable.toWeb(nodeReadable);
}
return new ReadableStream({
start (controller) {
nodeReadable.on("data", (chunk)=>{
controller.enqueue(chunk);
});
nodeReadable.on("end", ()=>{
controller.close();
});
nodeReadable.on("error", (error)=>{
controller.error(error);
});
}
});
} else {
throw new Error("Invalid runtime");
}
}
function formDataFromSearchQueryString(query) {
const searchParams = new URLSearchParams(query);
const formData = new FormData();
for (const [key, value] of searchParams){
formData.append(key, value);
}
return formData;
}
function nodeHeadersToRecord(headers) {
const record = {};
for (const [key, value] of Object.entries(headers)){
if (value !== undefined) {
record[key] = Array.isArray(value) ? value.join(", ") : `${value}`;
}
}
return record;
}
function getForwardedHeaders(req, res) {
// Get request headers and cookies
const requestHeaders = req.headers;
const requestCookies = requestHeaders["cookie"] ?? "";
// Get response headers and Set-Cookie header
const responseHeaders = res.getHeaders();
const rawSetCookies = responseHeaders["set-cookie"];
const setCookies = (Array.isArray(rawSetCookies) ? rawSetCookies : [
rawSetCookies
]).map((setCookie)=>{
// remove the suffixes like 'HttpOnly' and 'SameSite'
const [cookie] = `${setCookie}`.split(";");
return cookie;
});
// Merge request and response headers
const mergedHeaders = (0, _utils.filterReqHeaders)({
...nodeHeadersToRecord(requestHeaders),
...nodeHeadersToRecord(responseHeaders)
}, _utils.actionsForbiddenHeaders);
// Merge cookies
const mergedCookies = requestCookies.split("; ").concat(setCookies).join("; ");
// Update the 'cookie' header with the merged cookies
mergedHeaders["cookie"] = mergedCookies;
// Remove headers that should not be forwarded
delete mergedHeaders["transfer-encoding"];
return new Headers(mergedHeaders);
}
async function addRevalidationHeader(res, { staticGenerationStore, requestStore }) {
var _staticGenerationStore_revalidatedTags;
await Promise.all(staticGenerationStore.pendingRevalidates || []);
// If a tag was revalidated, the client router needs to invalidate all the
// client router cache as they may be stale. And if a path was revalidated, the
// client needs to invalidate all subtrees below that path.
// To keep the header size small, we use a tuple of
// [[revalidatedPaths], isTagRevalidated ? 1 : 0, isCookieRevalidated ? 1 : 0]
// instead of a JSON object.
// TODO-APP: Currently the prefetch cache doesn't have subtree information,
// so we need to invalidate the entire cache if a path was revalidated.
// TODO-APP: Currently paths are treated as tags, so the second element of the tuple
// is always empty.
const isTagRevalidated = ((_staticGenerationStore_revalidatedTags = staticGenerationStore.revalidatedTags) == null ? void 0 : _staticGenerationStore_revalidatedTags.length) ? 1 : 0;
const isCookieRevalidated = (0, _requestcookies.getModifiedCookieValues)(requestStore.mutableCookies).length ? 1 : 0;
res.setHeader("x-action-revalidated", JSON.stringify([
[],
isTagRevalidated,
isCookieRevalidated
]));
}
async function createRedirectRenderResult(req, res, redirectUrl, staticGenerationStore) {
res.setHeader("x-action-redirect", redirectUrl);
// if we're redirecting to a relative path, we'll try to stream the response
if (redirectUrl.startsWith("/")) {
var _staticGenerationStore_incrementalCache;
const forwardedHeaders = getForwardedHeaders(req, res);
forwardedHeaders.set(_approuterheaders.RSC, "1");
const host = req.headers["host"];
const proto = ((_staticGenerationStore_incrementalCache = staticGenerationStore.incrementalCache) == null ? void 0 : _staticGenerationStore_incrementalCache.requestProtocol) || "https";
const fetchUrl = new URL(`${proto}://${host}${redirectUrl}`);
if (staticGenerationStore.revalidatedTags) {
var _staticGenerationStore_incrementalCache_prerenderManifest_preview, _staticGenerationStore_incrementalCache_prerenderManifest, _staticGenerationStore_incrementalCache1;
forwardedHeaders.set(_constants.NEXT_CACHE_REVALIDATED_TAGS_HEADER, staticGenerationStore.revalidatedTags.join(","));
forwardedHeaders.set(_constants.NEXT_CACHE_REVALIDATE_TAG_TOKEN_HEADER, ((_staticGenerationStore_incrementalCache1 = staticGenerationStore.incrementalCache) == null ? void 0 : (_staticGenerationStore_incrementalCache_prerenderManifest = _staticGenerationStore_incrementalCache1.prerenderManifest) == null ? void 0 : (_staticGenerationStore_incrementalCache_prerenderManifest_preview = _staticGenerationStore_incrementalCache_prerenderManifest.preview) == null ? void 0 : _staticGenerationStore_incrementalCache_prerenderManifest_preview.previewModeId) || "");
}
// Ensures that when the path was revalidated we don't return a partial response on redirects
// if (staticGenerationStore.pathWasRevalidated) {
forwardedHeaders.delete("next-router-state-tree");
// }
try {
const headResponse = await fetch(fetchUrl, {
method: "HEAD",
headers: forwardedHeaders,
next: {
// @ts-ignore
internal: 1
}
});
if (headResponse.headers.get("content-type") === _approuterheaders.RSC_CONTENT_TYPE_HEADER) {
const response = await fetch(fetchUrl, {
method: "GET",
headers: forwardedHeaders,
next: {
// @ts-ignore
internal: 1
}
});
// copy the headers from the redirect response to the response we're sending
for (const [key, value] of response.headers){
if (!_utils.actionsForbiddenHeaders.includes(key)) {
res.setHeader(key, value);
}
}
return new _flightrenderresult.FlightRenderResult(response.body);
}
} catch (err) {
// we couldn't stream the redirect response, so we'll just do a normal redirect
console.error(`failed to get redirect response`, err);
}
}
return new _renderresult.default(JSON.stringify({}));
}
async function handleAction({ req, res, ComponentMod, page, serverActionsManifest, generateFlight, staticGenerationStore, requestStore, serverActionsBodySizeLimit }) {
let actionId = req.headers[_approuterheaders.ACTION.toLowerCase()];
const contentType = req.headers["content-type"];
const isURLEncodedAction = req.method === "POST" && contentType === "application/x-www-form-urlencoded";
const isMultipartAction = req.method === "POST" && (contentType == null ? void 0 : contentType.startsWith("multipart/form-data"));
const isFetchAction = actionId !== undefined && typeof actionId === "string" && req.method === "POST";
if (isFetchAction || isURLEncodedAction || isMultipartAction) {
// ensure we avoid caching server actions unexpectedly
res.setHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
let bound = [];
const workerName = "app" + page;
const serverModuleMap = new Proxy({}, {
get: (_, id)=>{
return {
id: serverActionsManifest[process.env.NEXT_RUNTIME === "edge" ? "edge" : "node"][id].workers[workerName],
name: id,
chunks: []
};
}
});
const { actionAsyncStorage } = ComponentMod;
let actionResult;
try {
await actionAsyncStorage.run({
isAction: true
}, async ()=>{
if (process.env.NEXT_RUNTIME === "edge") {
// Use react-server-dom-webpack/server.edge
const { decodeReply, decodeAction } = ComponentMod;
const webRequest = req;
if (!webRequest.body) {
throw new Error("invariant: Missing request body.");
}
if (isMultipartAction) {
// TODO-APP: Add streaming support
const formData = await webRequest.request.formData();
if (isFetchAction) {
bound = await decodeReply(formData, serverModuleMap);
} else {
const action = await decodeAction(formData, serverModuleMap);
await action();
// Skip the fetch path
return;
}
} else {
let actionData = "";
const reader = webRequest.body.getReader();
while(true){
const { done, value } = await reader.read();
if (done) {
break;
}
actionData += new TextDecoder().decode(value);
}
if (isURLEncodedAction) {
const formData = formDataFromSearchQueryString(actionData);
bound = await decodeReply(formData, serverModuleMap);
} else {
bound = await decodeReply(actionData, serverModuleMap);
}
}
} else {
// Use react-server-dom-webpack/server.node which supports streaming
const { decodeReply, decodeReplyFromBusboy, decodeAction } = require(`react-server-dom-webpack/server.node`);
if (isMultipartAction) {
if (isFetchAction) {
const busboy = require("busboy");
const bb = busboy({
headers: req.headers
});
req.pipe(bb);
bound = await decodeReplyFromBusboy(bb, serverModuleMap);
} else {
// React doesn't yet publish a busboy version of decodeAction
// so we polyfill the parsing of FormData.
const UndiciRequest = require("next/dist/compiled/undici").Request;
const fakeRequest = new UndiciRequest("http://localhost", {
method: "POST",
headers: {
"Content-Type": req.headers["content-type"]
},
body: nodeToWebReadableStream(req),
duplex: "half"
});
const formData = await fakeRequest.formData();
const action = await decodeAction(formData, serverModuleMap);
await action();
// Skip the fetch path
return;
}
} else {
const { parseBody } = require("../api-utils/node");
let actionData;
try {
actionData = await parseBody(req, serverActionsBodySizeLimit ?? "1mb") || "";
} catch (e) {
if (e && e.statusCode === 413) {
// Exceeded the size limit
e.message = e.message + "\nTo configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/server-actions#size-limitation";
}
throw e;
}
if (isURLEncodedAction) {
const formData = formDataFromSearchQueryString(actionData);
bound = await decodeReply(formData, serverModuleMap);
} else {
bound = await decodeReply(actionData, serverModuleMap);
}
}
}
// actions.js
// app/page.js
// action worker1
// appRender1
// app/foo/page.js
// action worker2
// appRender
// / -> fire action -> POST / -> appRender1 -> modId for the action file
// /foo -> fire action -> POST /foo -> appRender2 -> modId for the action file
const actionModId = serverActionsManifest[process.env.NEXT_RUNTIME === "edge" ? "edge" : "node"][actionId].workers[workerName];
const actionHandler = ComponentMod.__next_app__.require(actionModId)[actionId];
const returnVal = await actionHandler.apply(null, bound);
// For form actions, we need to continue rendering the page.
if (isFetchAction) {
await addRevalidationHeader(res, {
staticGenerationStore,
requestStore
});
actionResult = await generateFlight({
actionResult: Promise.resolve(returnVal),
// if the page was not revalidated, we can skip the rendering the flight tree
skipFlight: !staticGenerationStore.pathWasRevalidated
});
}
});
return actionResult;
} catch (err) {
if ((0, _redirect.isRedirectError)(err)) {
const redirectUrl = (0, _redirect.getURLFromRedirectError)(err);
// if it's a fetch action, we don't want to mess with the status code
// and we'll handle it on the client router
await addRevalidationHeader(res, {
staticGenerationStore,
requestStore
});
if (isFetchAction) {
return createRedirectRenderResult(req, res, redirectUrl, staticGenerationStore);
}
if (err.mutableCookies) {
const headers = new Headers();
// If there were mutable cookies set, we need to set them on the
// response.
if ((0, _requestcookies.appendMutableCookies)(headers, err.mutableCookies)) {
res.setHeader("set-cookie", Array.from(headers.values()));
}
}
res.setHeader("Location", redirectUrl);
res.statusCode = 303;
return new _renderresult.default("");
} else if ((0, _notfound.isNotFoundError)(err)) {
res.statusCode = 404;
await addRevalidationHeader(res, {
staticGenerationStore,
requestStore
});
if (isFetchAction) {
const promise = Promise.reject(err);
try {
await promise;
} catch {}
return generateFlight({
skipFlight: false,
actionResult: promise,
asNotFound: true
});
}
return "not-found";
}
if (isFetchAction) {
res.statusCode = 500;
await Promise.all(staticGenerationStore.pendingRevalidates || []);
const promise = Promise.reject(err);
try {
await promise;
} catch {}
return generateFlight({
actionResult: promise,
// if the page was not revalidated, we can skip the rendering the flight tree
skipFlight: !staticGenerationStore.pathWasRevalidated
});
}
throw err;
}
}
}
//# sourceMappingURL=action-handler.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
/// <reference types="node" />
import type { IncomingMessage, ServerResponse } from 'http';
import type { DynamicParamTypesShort, RenderOpts, Segment } from './types';
import { NextParsedUrlQuery } from '../request-meta';
import RenderResult from '../render-result';
export type GetDynamicParamFromSegment = (segment: string) => {
param: string;
value: string | string[] | null;
treeSegment: Segment;
type: DynamicParamTypesShort;
} | null;
export declare function renderToHTMLOrFlight(req: IncomingMessage, res: ServerResponse, pagePath: string, query: NextParsedUrlQuery, renderOpts: RenderOpts): Promise<RenderResult>;

1141
node_modules/next/dist/server/app-render/app-render.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,17 @@
/**
* Create error handler for renderers.
* Tolerate dynamic server errors during prerendering so console
* isn't spammed with unactionable errors
*/
export declare function createErrorHandler({
/**
* Used for debugging
*/
_source, dev, isNextExport, errorLogger, capturedErrors, allCapturedErrors, }: {
_source: string;
dev?: boolean;
isNextExport?: boolean;
errorLogger?: (err: any) => Promise<void>;
capturedErrors: Error[];
allCapturedErrors?: Error[];
}): (err: any) => string;

View File

@@ -0,0 +1,70 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "createErrorHandler", {
enumerable: true,
get: function() {
return createErrorHandler;
}
});
const _hooksservercontext = require("../../client/components/hooks-server-context");
const _stringhash = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/string-hash"));
const _formatservererror = require("../../lib/format-server-error");
const _notfound = require("../../client/components/not-found");
const _redirect = require("../../client/components/redirect");
const _nossrerror = require("../../shared/lib/lazy-dynamic/no-ssr-error");
const _tracer = require("../lib/trace/tracer");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function createErrorHandler({ /**
* Used for debugging
*/ _source, dev, isNextExport, errorLogger, capturedErrors, allCapturedErrors }) {
return (err)=>{
var _err_message;
if (allCapturedErrors) allCapturedErrors.push(err);
if (err && (err.digest === _hooksservercontext.DYNAMIC_ERROR_CODE || (0, _notfound.isNotFoundError)(err) || err.digest === _nossrerror.NEXT_DYNAMIC_NO_SSR_CODE || (0, _redirect.isRedirectError)(err))) {
return err.digest;
}
// Format server errors in development to add more helpful error messages
if (dev) {
(0, _formatservererror.formatServerError)(err);
}
// Used for debugging error source
// console.error(_source, err)
// Don't log the suppressed error during export
if (!(isNextExport && (err == null ? void 0 : (_err_message = err.message) == null ? void 0 : _err_message.includes("The specific message is omitted in production builds to avoid leaking sensitive details.")))) {
// Record exception in an active span, if available.
const span = (0, _tracer.getTracer)().getActiveScopeSpan();
if (span) {
span.recordException(err);
span.setStatus({
code: _tracer.SpanStatusCode.ERROR,
message: err.message
});
}
if (errorLogger) {
errorLogger(err).catch(()=>{});
} else {
// The error logger is currently not provided in the edge runtime.
// Use `log-app-dir-error` instead.
// It won't log the source code, but the error will be more useful.
if (process.env.NODE_ENV !== "production") {
const { logAppDirError } = require("../dev/log-app-dir-error");
logAppDirError(err);
}
if (process.env.NODE_ENV === "production") {
console.error(err);
}
}
}
capturedErrors.push(err);
// TODO-APP: look at using webcrypto instead. Requires a promise to be awaited.
return (0, _stringhash.default)(err.message + err.stack + (err.digest || "")).toString();
};
}
//# sourceMappingURL=create-error-handler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/create-error-handler.tsx"],"names":["createErrorHandler","_source","dev","isNextExport","errorLogger","capturedErrors","allCapturedErrors","err","push","digest","DYNAMIC_ERROR_CODE","isNotFoundError","NEXT_DYNAMIC_NO_SSR_CODE","isRedirectError","formatServerError","message","includes","span","getTracer","getActiveScopeSpan","recordException","setStatus","code","SpanStatusCode","ERROR","catch","process","env","NODE_ENV","logAppDirError","require","console","error","stringHash","stack","toString"],"mappings":";;;;+BAagBA;;;eAAAA;;;oCAbmB;mEACZ;mCACW;0BACF;0BACA;4BACS;wBACC;;;;;;AAOnC,SAASA,mBAAmB,EACjC;;GAEC,GACDC,OAAO,EACPC,GAAG,EACHC,YAAY,EACZC,WAAW,EACXC,cAAc,EACdC,iBAAiB,EAQlB;IACC,OAAO,CAACC;YAuBFA;QAtBJ,IAAID,mBAAmBA,kBAAkBE,IAAI,CAACD;QAE9C,IACEA,OACCA,CAAAA,IAAIE,MAAM,KAAKC,sCAAkB,IAChCC,IAAAA,yBAAe,EAACJ,QAChBA,IAAIE,MAAM,KAAKG,oCAAwB,IACvCC,IAAAA,yBAAe,EAACN,IAAG,GACrB;YACA,OAAOA,IAAIE,MAAM;QACnB;QAEA,yEAAyE;QACzE,IAAIP,KAAK;YACPY,IAAAA,oCAAiB,EAACP;QACpB;QACA,kCAAkC;QAClC,8BAA8B;QAC9B,+CAA+C;QAC/C,IACE,CACEJ,CAAAA,iBACAI,wBAAAA,eAAAA,IAAKQ,OAAO,qBAAZR,aAAcS,QAAQ,CACpB,4FACF,GAEF;YACA,oDAAoD;YACpD,MAAMC,OAAOC,IAAAA,iBAAS,IAAGC,kBAAkB;YAC3C,IAAIF,MAAM;gBACRA,KAAKG,eAAe,CAACb;gBACrBU,KAAKI,SAAS,CAAC;oBACbC,MAAMC,sBAAc,CAACC,KAAK;oBAC1BT,SAASR,IAAIQ,OAAO;gBACtB;YACF;YAEA,IAAIX,aAAa;gBACfA,YAAYG,KAAKkB,KAAK,CAAC,KAAO;YAChC,OAAO;gBACL,kEAAkE;gBAClE,mCAAmC;gBACnC,mEAAmE;gBACnE,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;oBACzC,MAAM,EAAEC,cAAc,EAAE,GACtBC,QAAQ;oBACVD,eAAetB;gBACjB;gBACA,IAAImB,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;oBACzCG,QAAQC,KAAK,CAACzB;gBAChB;YACF;QACF;QAEAF,eAAeG,IAAI,CAACD;QACpB,+EAA+E;QAC/E,OAAO0B,IAAAA,mBAAU,EAAC1B,IAAIQ,OAAO,GAAGR,IAAI2B,KAAK,GAAI3B,CAAAA,IAAIE,MAAM,IAAI,EAAC,GAAI0B,QAAQ;IAC1E;AACF"}

View File

@@ -0,0 +1,5 @@
import type { LoaderTree } from '../lib/app-dir-module';
import type { FlightRouterState, Segment } from './types';
import type { GetDynamicParamFromSegment } from './app-render';
export declare function addSearchParamsIfPageSegment(segment: Segment, searchParams: any): string | [string, string, "d" | "c" | "oc"];
export declare function createFlightRouterStateFromLoaderTree([segment, parallelRoutes, { layout }]: LoaderTree, getDynamicParamFromSegment: GetDynamicParamFromSegment, searchParams: any, rootLayoutIncluded?: boolean): FlightRouterState;

View File

@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
addSearchParamsIfPageSegment: null,
createFlightRouterStateFromLoaderTree: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
addSearchParamsIfPageSegment: function() {
return addSearchParamsIfPageSegment;
},
createFlightRouterStateFromLoaderTree: function() {
return createFlightRouterStateFromLoaderTree;
}
});
const _constants = require("../../shared/lib/constants");
function addSearchParamsIfPageSegment(segment, searchParams) {
const isPageSegment = segment === _constants.PAGE_SEGMENT_KEY;
if (isPageSegment) {
const stringifiedQuery = JSON.stringify(searchParams);
return stringifiedQuery !== "{}" ? segment + "?" + stringifiedQuery : segment;
}
return segment;
}
function createFlightRouterStateFromLoaderTree([segment, parallelRoutes, { layout }], getDynamicParamFromSegment, searchParams, rootLayoutIncluded = false) {
const dynamicParam = getDynamicParamFromSegment(segment);
const treeSegment = dynamicParam ? dynamicParam.treeSegment : segment;
const segmentTree = [
addSearchParamsIfPageSegment(treeSegment, searchParams),
{}
];
if (!rootLayoutIncluded && typeof layout !== "undefined") {
rootLayoutIncluded = true;
segmentTree[4] = true;
}
segmentTree[1] = Object.keys(parallelRoutes).reduce((existingValue, currentValue)=>{
existingValue[currentValue] = createFlightRouterStateFromLoaderTree(parallelRoutes[currentValue], getDynamicParamFromSegment, searchParams, rootLayoutIncluded);
return existingValue;
}, {});
return segmentTree;
}
//# sourceMappingURL=create-flight-router-state-from-loader-tree.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/create-flight-router-state-from-loader-tree.ts"],"names":["addSearchParamsIfPageSegment","createFlightRouterStateFromLoaderTree","segment","searchParams","isPageSegment","PAGE_SEGMENT_KEY","stringifiedQuery","JSON","stringify","parallelRoutes","layout","getDynamicParamFromSegment","rootLayoutIncluded","dynamicParam","treeSegment","segmentTree","Object","keys","reduce","existingValue","currentValue"],"mappings":";;;;;;;;;;;;;;;IAKgBA,4BAA4B;eAA5BA;;IAgBAC,qCAAqC;eAArCA;;;2BAlBiB;AAE1B,SAASD,6BACdE,OAAgB,EAChBC,YAAiB;IAEjB,MAAMC,gBAAgBF,YAAYG,2BAAgB;IAElD,IAAID,eAAe;QACjB,MAAME,mBAAmBC,KAAKC,SAAS,CAACL;QACxC,OAAOG,qBAAqB,OACxBJ,UAAU,MAAMI,mBAChBJ;IACN;IAEA,OAAOA;AACT;AAEO,SAASD,sCACd,CAACC,SAASO,gBAAgB,EAAEC,MAAM,EAAE,CAAa,EACjDC,0BAAsD,EACtDR,YAAiB,EACjBS,qBAAqB,KAAK;IAE1B,MAAMC,eAAeF,2BAA2BT;IAChD,MAAMY,cAAcD,eAAeA,aAAaC,WAAW,GAAGZ;IAE9D,MAAMa,cAAiC;QACrCf,6BAA6Bc,aAAaX;QAC1C,CAAC;KACF;IAED,IAAI,CAACS,sBAAsB,OAAOF,WAAW,aAAa;QACxDE,qBAAqB;QACrBG,WAAW,CAAC,EAAE,GAAG;IACnB;IAEAA,WAAW,CAAC,EAAE,GAAGC,OAAOC,IAAI,CAACR,gBAAgBS,MAAM,CACjD,CAACC,eAAeC;QACdD,aAAa,CAACC,aAAa,GAAGnB,sCAC5BQ,cAAc,CAACW,aAAa,EAC5BT,4BACAR,cACAS;QAEF,OAAOO;IACT,GACA,CAAC;IAGH,OAAOJ;AACT"}

View File

@@ -0,0 +1,22 @@
/// <reference types="react" />
import type { RenderOpts } from './types';
import { createErrorHandler } from './create-error-handler';
/**
* Create a component that renders the Flight stream.
* This is only used for renderToHTML, the Flight response does not need additional wrappers.
*/
export declare function createServerComponentRenderer<Props>(ComponentToRender: (props: Props) => any, ComponentMod: {
renderToReadableStream: any;
__next_app__?: {
require: any;
loadChunk: any;
};
}, { transformStream, clientReferenceManifest, serverContexts, rscChunks, }: {
transformStream: TransformStream<Uint8Array, Uint8Array>;
clientReferenceManifest: NonNullable<RenderOpts['clientReferenceManifest']>;
serverContexts: Array<[
ServerContextName: string,
JSONValue: Object | number | string
]>;
rscChunks: Uint8Array[];
}, serverComponentsErrorHandler: ReturnType<typeof createErrorHandler>, nonce?: string): (props: Props) => JSX.Element;

View File

@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "createServerComponentRenderer", {
enumerable: true,
get: function() {
return createServerComponentRenderer;
}
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _useflightresponse = require("./use-flight-response");
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
function createServerComponentRenderer(ComponentToRender, ComponentMod, { transformStream, clientReferenceManifest, serverContexts, rscChunks }, serverComponentsErrorHandler, nonce) {
let RSCStream;
const createRSCStream = (props)=>{
if (!RSCStream) {
RSCStream = ComponentMod.renderToReadableStream(/*#__PURE__*/ _react.default.createElement(ComponentToRender, props), clientReferenceManifest.clientModules, {
context: serverContexts,
onError: serverComponentsErrorHandler
});
}
return RSCStream;
};
const flightResponseRef = {
current: null
};
const writable = transformStream.writable;
return function ServerComponentWrapper(props) {
const reqStream = createRSCStream(props);
const response = (0, _useflightresponse.useFlightResponse)(writable, reqStream, clientReferenceManifest, rscChunks, flightResponseRef, nonce);
return (0, _react.use)(response);
};
}
//# sourceMappingURL=create-server-components-renderer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/create-server-components-renderer.tsx"],"names":["createServerComponentRenderer","ComponentToRender","ComponentMod","transformStream","clientReferenceManifest","serverContexts","rscChunks","serverComponentsErrorHandler","nonce","RSCStream","createRSCStream","props","renderToReadableStream","clientModules","context","onError","flightResponseRef","current","writable","ServerComponentWrapper","reqStream","response","useFlightResponse","use"],"mappings":";;;;+BAWgBA;;;eAAAA;;;+DARW;mCAEO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM3B,SAASA,8BACdC,iBAAwC,EACxCC,YAMC,EACD,EACEC,eAAe,EACfC,uBAAuB,EACvBC,cAAc,EACdC,SAAS,EAQV,EACDC,4BAAmE,EACnEC,KAAc;IAEd,IAAIC;IACJ,MAAMC,kBAAkB,CAACC;QACvB,IAAI,CAACF,WAAW;YACdA,YAAYP,aAAaU,sBAAsB,eAC7C,6BAACX,mBAAuBU,QACxBP,wBAAwBS,aAAa,EACrC;gBACEC,SAAST;gBACTU,SAASR;YACX;QAEJ;QACA,OAAOE;IACT;IAEA,MAAMO,oBAAuC;QAAEC,SAAS;IAAK;IAE7D,MAAMC,WAAWf,gBAAgBe,QAAQ;IACzC,OAAO,SAASC,uBAAuBR,KAAY;QACjD,MAAMS,YAAYV,gBAAgBC;QAClC,MAAMU,WAAWC,IAAAA,oCAAiB,EAChCJ,UACAE,WACAhB,yBACAE,WACAU,mBACAR;QAEF,OAAOe,IAAAA,UAAG,EAACF;IACb;AACF"}

View File

@@ -0,0 +1,14 @@
declare const renderToReadableStream: any, decodeReply: any, decodeAction: any;
import AppRouter from '../../client/components/app-router';
import LayoutRouter from '../../client/components/layout-router';
import RenderFromTemplateContext from '../../client/components/render-from-template-context';
import { staticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage.external';
import { requestAsyncStorage } from '../../client/components/request-async-storage.external';
import { actionAsyncStorage } from '../../client/components/action-async-storage.external';
import { staticGenerationBailout } from '../../client/components/static-generation-bailout';
import StaticGenerationSearchParamsBailoutProvider from '../../client/components/static-generation-searchparams-bailout-provider';
import { createSearchParamsBailoutProxy } from '../../client/components/searchparams-bailout-proxy';
import * as serverHooks from '../../client/components/hooks-server-context';
import { preloadStyle, preloadFont, preconnect } from '../../server/app-render/rsc/preloads';
declare const NotFoundBoundary: typeof import("../../client/components/not-found-boundary").NotFoundBoundary;
export { AppRouter, LayoutRouter, RenderFromTemplateContext, staticGenerationAsyncStorage, requestAsyncStorage, actionAsyncStorage, staticGenerationBailout, createSearchParamsBailoutProxy, serverHooks, renderToReadableStream, decodeReply, decodeAction, preloadStyle, preloadFont, preconnect, StaticGenerationSearchParamsBailoutProvider, NotFoundBoundary, };

141
node_modules/next/dist/server/app-render/entry-base.js generated vendored Normal file
View File

@@ -0,0 +1,141 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
AppRouter: null,
LayoutRouter: null,
RenderFromTemplateContext: null,
staticGenerationAsyncStorage: null,
requestAsyncStorage: null,
actionAsyncStorage: null,
staticGenerationBailout: null,
createSearchParamsBailoutProxy: null,
serverHooks: null,
renderToReadableStream: null,
decodeReply: null,
decodeAction: null,
preloadStyle: null,
preloadFont: null,
preconnect: null,
StaticGenerationSearchParamsBailoutProvider: null,
NotFoundBoundary: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
AppRouter: function() {
return _approuter.default;
},
LayoutRouter: function() {
return _layoutrouter.default;
},
RenderFromTemplateContext: function() {
return _renderfromtemplatecontext.default;
},
staticGenerationAsyncStorage: function() {
return _staticgenerationasyncstorageexternal.staticGenerationAsyncStorage;
},
requestAsyncStorage: function() {
return _requestasyncstorageexternal.requestAsyncStorage;
},
actionAsyncStorage: function() {
return _actionasyncstorageexternal.actionAsyncStorage;
},
staticGenerationBailout: function() {
return _staticgenerationbailout.staticGenerationBailout;
},
createSearchParamsBailoutProxy: function() {
return _searchparamsbailoutproxy.createSearchParamsBailoutProxy;
},
serverHooks: function() {
return _hooksservercontext;
},
renderToReadableStream: function() {
return renderToReadableStream;
},
decodeReply: function() {
return decodeReply;
},
decodeAction: function() {
return decodeAction;
},
preloadStyle: function() {
return _preloads.preloadStyle;
},
preloadFont: function() {
return _preloads.preloadFont;
},
preconnect: function() {
return _preloads.preconnect;
},
StaticGenerationSearchParamsBailoutProvider: function() {
return _staticgenerationsearchparamsbailoutprovider.default;
},
NotFoundBoundary: function() {
return NotFoundBoundary;
}
});
const _approuter = /*#__PURE__*/ _interop_require_default(require("../../client/components/app-router"));
const _layoutrouter = /*#__PURE__*/ _interop_require_default(require("../../client/components/layout-router"));
const _renderfromtemplatecontext = /*#__PURE__*/ _interop_require_default(require("../../client/components/render-from-template-context"));
const _staticgenerationasyncstorageexternal = require("../../client/components/static-generation-async-storage.external");
const _requestasyncstorageexternal = require("../../client/components/request-async-storage.external");
const _actionasyncstorageexternal = require("../../client/components/action-async-storage.external");
const _staticgenerationbailout = require("../../client/components/static-generation-bailout");
const _staticgenerationsearchparamsbailoutprovider = /*#__PURE__*/ _interop_require_default(require("../../client/components/static-generation-searchparams-bailout-provider"));
const _searchparamsbailoutproxy = require("../../client/components/searchparams-bailout-proxy");
const _hooksservercontext = /*#__PURE__*/ _interop_require_wildcard(require("../../client/components/hooks-server-context"));
const _preloads = require("../../server/app-render/rsc/preloads");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
const { renderToReadableStream, decodeReply, decodeAction } = require("react-server-dom-webpack/server.edge");
const { NotFoundBoundary } = require("next/dist/client/components/not-found-boundary");
//# sourceMappingURL=entry-base.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/entry-base.ts"],"names":["AppRouter","LayoutRouter","RenderFromTemplateContext","staticGenerationAsyncStorage","requestAsyncStorage","actionAsyncStorage","staticGenerationBailout","createSearchParamsBailoutProxy","serverHooks","renderToReadableStream","decodeReply","decodeAction","preloadStyle","preloadFont","preconnect","StaticGenerationSearchParamsBailoutProvider","NotFoundBoundary","require"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4BEA,SAAS;eAATA,kBAAS;;IACTC,YAAY;eAAZA,qBAAY;;IACZC,yBAAyB;eAAzBA,kCAAyB;;IACzBC,4BAA4B;eAA5BA,kEAA4B;;IAC5BC,mBAAmB;eAAnBA,gDAAmB;;IACnBC,kBAAkB;eAAlBA,8CAAkB;;IAClBC,uBAAuB;eAAvBA,gDAAuB;;IACvBC,8BAA8B;eAA9BA,wDAA8B;;IAC9BC,WAAW;eAAXA;;IACAC,sBAAsB;eAAtBA;;IACAC,WAAW;eAAXA;;IACAC,YAAY;eAAZA;;IACAC,YAAY;eAAZA,sBAAY;;IACZC,WAAW;eAAXA,qBAAW;;IACXC,UAAU;eAAVA,oBAAU;;IACVC,2CAA2C;eAA3CA,oDAA2C;;IAC3CC,gBAAgB;eAAhBA;;;kEArCoB;qEACG;kFACa;sDACO;6CACT;4CACD;yCACK;oGACgB;0CACT;4EAClB;0BAMtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAtBP,MAAM,EACJP,sBAAsB,EACtBC,WAAW,EACXC,YAAY,EAEb,GAAGM,QAAQ;AAmBZ,MAAM,EAAED,gBAAgB,EAAE,GACxBC,QAAQ"}

View File

@@ -0,0 +1,7 @@
import RenderResult from '../render-result';
/**
* Flight Response is always set to RSC_CONTENT_TYPE_HEADER to ensure it does not get interpreted as HTML.
*/
export declare class FlightRenderResult extends RenderResult {
constructor(response: string | ReadableStream<Uint8Array>);
}

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "FlightRenderResult", {
enumerable: true,
get: function() {
return FlightRenderResult;
}
});
const _approuterheaders = require("../../client/components/app-router-headers");
const _renderresult = /*#__PURE__*/ _interop_require_default(require("../render-result"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
class FlightRenderResult extends _renderresult.default {
constructor(response){
super(response, {
contentType: _approuterheaders.RSC_CONTENT_TYPE_HEADER
});
}
}
//# sourceMappingURL=flight-render-result.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/flight-render-result.ts"],"names":["FlightRenderResult","RenderResult","constructor","response","contentType","RSC_CONTENT_TYPE_HEADER"],"mappings":";;;;+BAMaA;;;eAAAA;;;kCAN2B;qEACf;;;;;;AAKlB,MAAMA,2BAA2BC,qBAAY;IAClDC,YAAYC,QAA6C,CAAE;QACzD,KAAK,CAACA,UAAU;YAAEC,aAAaC,yCAAuB;QAAC;IACzD;AACF"}

View File

@@ -0,0 +1,4 @@
/// <reference types="react" />
export interface FlightResponseRef {
current: Promise<JSX.Element> | null;
}

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=flight-response-ref.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":""}

View File

@@ -0,0 +1,5 @@
import { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin';
/**
* Get external stylesheet link hrefs based on server CSS manifest.
*/
export declare function getCssInlinedLinkTags(clientReferenceManifest: ClientReferenceManifest, filePath: string, injectedCSS: Set<string>, collectNewCSSImports?: boolean): string[];

View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getCssInlinedLinkTags", {
enumerable: true,
get: function() {
return getCssInlinedLinkTags;
}
});
function getCssInlinedLinkTags(clientReferenceManifest, filePath, injectedCSS, collectNewCSSImports) {
const filePathWithoutExt = filePath.replace(/\.[^.]+$/, "");
const chunks = new Set();
const entryCSSFiles = clientReferenceManifest.entryCSSFiles[filePathWithoutExt];
if (entryCSSFiles) {
for (const file of entryCSSFiles){
if (!injectedCSS.has(file)) {
if (collectNewCSSImports) {
injectedCSS.add(file);
}
chunks.add(file);
}
}
}
return [
...chunks
];
}
//# sourceMappingURL=get-css-inlined-link-tags.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/get-css-inlined-link-tags.tsx"],"names":["getCssInlinedLinkTags","clientReferenceManifest","filePath","injectedCSS","collectNewCSSImports","filePathWithoutExt","replace","chunks","Set","entryCSSFiles","file","has","add"],"mappings":";;;;+BAKgBA;;;eAAAA;;;AAAT,SAASA,sBACdC,uBAAgD,EAChDC,QAAgB,EAChBC,WAAwB,EACxBC,oBAA8B;IAE9B,MAAMC,qBAAqBH,SAASI,OAAO,CAAC,YAAY;IACxD,MAAMC,SAAS,IAAIC;IAEnB,MAAMC,gBACJR,wBAAwBQ,aAAa,CAACJ,mBAAmB;IAE3D,IAAII,eAAe;QACjB,KAAK,MAAMC,QAAQD,cAAe;YAChC,IAAI,CAACN,YAAYQ,GAAG,CAACD,OAAO;gBAC1B,IAAIN,sBAAsB;oBACxBD,YAAYS,GAAG,CAACF;gBAClB;gBACAH,OAAOK,GAAG,CAACF;YACb;QACF;IACF;IAEA,OAAO;WAAIH;KAAO;AACpB"}

View File

@@ -0,0 +1,9 @@
import { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin';
/**
* Get hrefs for fonts to preload
* Returns null if there are no fonts at all.
* Returns string[] if there are fonts to preload (font paths)
* Returns empty string[] if there are fonts but none to preload and no other fonts have been preloaded
* Returns null if there are fonts but none to preload and at least some were previously preloaded
*/
export declare function getPreloadableFonts(nextFontManifest: NextFontManifest | undefined, filePath: string | undefined, injectedFontPreloadTags: Set<string>): string[] | null;

View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getPreloadableFonts", {
enumerable: true,
get: function() {
return getPreloadableFonts;
}
});
function getPreloadableFonts(nextFontManifest, filePath, injectedFontPreloadTags) {
if (!nextFontManifest || !filePath) {
return null;
}
const filepathWithoutExtension = filePath.replace(/\.[^.]+$/, "");
const fontFiles = new Set();
let foundFontUsage = false;
const preloadedFontFiles = nextFontManifest.app[filepathWithoutExtension];
if (preloadedFontFiles) {
foundFontUsage = true;
for (const fontFile of preloadedFontFiles){
if (!injectedFontPreloadTags.has(fontFile)) {
fontFiles.add(fontFile);
injectedFontPreloadTags.add(fontFile);
}
}
}
if (fontFiles.size) {
return [
...fontFiles
].sort();
} else if (foundFontUsage && injectedFontPreloadTags.size === 0) {
return [];
} else {
return null;
}
}
//# sourceMappingURL=get-preloadable-fonts.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/get-preloadable-fonts.tsx"],"names":["getPreloadableFonts","nextFontManifest","filePath","injectedFontPreloadTags","filepathWithoutExtension","replace","fontFiles","Set","foundFontUsage","preloadedFontFiles","app","fontFile","has","add","size","sort"],"mappings":";;;;+BASgBA;;;eAAAA;;;AAAT,SAASA,oBACdC,gBAA8C,EAC9CC,QAA4B,EAC5BC,uBAAoC;IAEpC,IAAI,CAACF,oBAAoB,CAACC,UAAU;QAClC,OAAO;IACT;IACA,MAAME,2BAA2BF,SAASG,OAAO,CAAC,YAAY;IAC9D,MAAMC,YAAY,IAAIC;IACtB,IAAIC,iBAAiB;IAErB,MAAMC,qBAAqBR,iBAAiBS,GAAG,CAACN,yBAAyB;IACzE,IAAIK,oBAAoB;QACtBD,iBAAiB;QACjB,KAAK,MAAMG,YAAYF,mBAAoB;YACzC,IAAI,CAACN,wBAAwBS,GAAG,CAACD,WAAW;gBAC1CL,UAAUO,GAAG,CAACF;gBACdR,wBAAwBU,GAAG,CAACF;YAC9B;QACF;IACF;IAEA,IAAIL,UAAUQ,IAAI,EAAE;QAClB,OAAO;eAAIR;SAAU,CAACS,IAAI;IAC5B,OAAO,IAAIP,kBAAkBL,wBAAwBW,IAAI,KAAK,GAAG;QAC/D,OAAO,EAAE;IACX,OAAO;QACL,OAAO;IACT;AACF"}

View File

@@ -0,0 +1 @@
export declare function getScriptNonceFromHeader(cspHeaderValue: string): string | undefined;

View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getScriptNonceFromHeader", {
enumerable: true,
get: function() {
return getScriptNonceFromHeader;
}
});
const _htmlescape = require("../htmlescape");
function getScriptNonceFromHeader(cspHeaderValue) {
var _directive_split_slice_map_find;
const directives = cspHeaderValue// Directives are split by ';'.
.split(";").map((directive)=>directive.trim());
// First try to find the directive for the 'script-src', otherwise try to
// fallback to the 'default-src'.
const directive = directives.find((dir)=>dir.startsWith("script-src")) || directives.find((dir)=>dir.startsWith("default-src"));
// If no directive could be found, then we're done.
if (!directive) {
return;
}
// Extract the nonce from the directive
const nonce = (_directive_split_slice_map_find = directive.split(" ")// Remove the 'strict-src'/'default-src' string, this can't be the nonce.
.slice(1).map((source)=>source.trim())// Find the first source with the 'nonce-' prefix.
.find((source)=>source.startsWith("'nonce-") && source.length > 8 && source.endsWith("'"))) == null ? void 0 : _directive_split_slice_map_find.slice(7, -1);
// If we could't find the nonce, then we're done.
if (!nonce) {
return;
}
// Don't accept the nonce value if it contains HTML escape characters.
// Technically, the spec requires a base64'd value, but this is just an
// extra layer.
if (_htmlescape.ESCAPE_REGEX.test(nonce)) {
throw new Error("Nonce value from Content-Security-Policy contained HTML escape characters.\nLearn more: https://nextjs.org/docs/messages/nonce-contained-invalid-characters");
}
return nonce;
}
//# sourceMappingURL=get-script-nonce-from-header.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/get-script-nonce-from-header.tsx"],"names":["getScriptNonceFromHeader","cspHeaderValue","directive","directives","split","map","trim","find","dir","startsWith","nonce","slice","source","length","endsWith","ESCAPE_REGEX","test","Error"],"mappings":";;;;+BAEgBA;;;eAAAA;;;4BAFa;AAEtB,SAASA,yBACdC,cAAsB;QAmBRC;IAjBd,MAAMC,aAAaF,cACjB,+BAA+B;KAC9BG,KAAK,CAAC,KACNC,GAAG,CAAC,CAACH,YAAcA,UAAUI,IAAI;IAEpC,yEAAyE;IACzE,iCAAiC;IACjC,MAAMJ,YACJC,WAAWI,IAAI,CAAC,CAACC,MAAQA,IAAIC,UAAU,CAAC,kBACxCN,WAAWI,IAAI,CAAC,CAACC,MAAQA,IAAIC,UAAU,CAAC;IAE1C,mDAAmD;IACnD,IAAI,CAACP,WAAW;QACd;IACF;IAEA,uCAAuC;IACvC,MAAMQ,SAAQR,kCAAAA,UACXE,KAAK,CAAC,IACP,yEAAyE;KACxEO,KAAK,CAAC,GACNN,GAAG,CAAC,CAACO,SAAWA,OAAON,IAAI,GAC5B,kDAAkD;KACjDC,IAAI,CACH,CAACK,SACCA,OAAOH,UAAU,CAAC,cAClBG,OAAOC,MAAM,GAAG,KAChBD,OAAOE,QAAQ,CAAC,0BAVRZ,gCAaVS,KAAK,CAAC,GAAG,CAAC;IAEd,iDAAiD;IACjD,IAAI,CAACD,OAAO;QACV;IACF;IAEA,sEAAsE;IACtE,uEAAuE;IACvE,eAAe;IACf,IAAIK,wBAAY,CAACC,IAAI,CAACN,QAAQ;QAC5B,MAAM,IAAIO,MACR;IAEJ;IAEA,OAAOP;AACT"}

View File

@@ -0,0 +1,8 @@
import { DynamicParamTypes } from './types';
/**
* Parse dynamic route segment to type of parameter
*/
export declare function getSegmentParam(segment: string): {
param: string;
type: DynamicParamTypes;
} | null;

View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getSegmentParam", {
enumerable: true,
get: function() {
return getSegmentParam;
}
});
const _interceptionroutes = require("../future/helpers/interception-routes");
function getSegmentParam(segment) {
const interceptionMarker = _interceptionroutes.INTERCEPTION_ROUTE_MARKERS.find((marker)=>segment.startsWith(marker));
// if an interception marker is part of the path segment, we need to jump ahead
// to the relevant portion for param parsing
if (interceptionMarker) {
segment = segment.slice(interceptionMarker.length);
}
if (segment.startsWith("[[...") && segment.endsWith("]]")) {
return {
type: "optional-catchall",
param: segment.slice(5, -2)
};
}
if (segment.startsWith("[...") && segment.endsWith("]")) {
return {
type: "catchall",
param: segment.slice(4, -1)
};
}
if (segment.startsWith("[") && segment.endsWith("]")) {
return {
type: "dynamic",
param: segment.slice(1, -1)
};
}
return null;
}
//# sourceMappingURL=get-segment-param.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/get-segment-param.tsx"],"names":["getSegmentParam","segment","interceptionMarker","INTERCEPTION_ROUTE_MARKERS","find","marker","startsWith","slice","length","endsWith","type","param"],"mappings":";;;;+BAMgBA;;;eAAAA;;;oCAN2B;AAMpC,SAASA,gBAAgBC,OAAe;IAI7C,MAAMC,qBAAqBC,8CAA0B,CAACC,IAAI,CAAC,CAACC,SAC1DJ,QAAQK,UAAU,CAACD;IAGrB,+EAA+E;IAC/E,4CAA4C;IAC5C,IAAIH,oBAAoB;QACtBD,UAAUA,QAAQM,KAAK,CAACL,mBAAmBM,MAAM;IACnD;IAEA,IAAIP,QAAQK,UAAU,CAAC,YAAYL,QAAQQ,QAAQ,CAAC,OAAO;QACzD,OAAO;YACLC,MAAM;YACNC,OAAOV,QAAQM,KAAK,CAAC,GAAG,CAAC;QAC3B;IACF;IAEA,IAAIN,QAAQK,UAAU,CAAC,WAAWL,QAAQQ,QAAQ,CAAC,MAAM;QACvD,OAAO;YACLC,MAAM;YACNC,OAAOV,QAAQM,KAAK,CAAC,GAAG,CAAC;QAC3B;IACF;IAEA,IAAIN,QAAQK,UAAU,CAAC,QAAQL,QAAQQ,QAAQ,CAAC,MAAM;QACpD,OAAO;YACLC,MAAM;YACNC,OAAOV,QAAQM,KAAK,CAAC,GAAG,CAAC;QAC3B;IACF;IAEA,OAAO;AACT"}

View File

@@ -0,0 +1,6 @@
import { DynamicParamTypes, DynamicParamTypesShort } from './types';
export declare const dynamicParamTypes: Record<DynamicParamTypes, DynamicParamTypesShort>;
/**
* Shorten the dynamic param in order to make it smaller when transmitted to the browser.
*/
export declare function getShortDynamicParamType(type: DynamicParamTypes): DynamicParamTypesShort;

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
dynamicParamTypes: null,
getShortDynamicParamType: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
dynamicParamTypes: function() {
return dynamicParamTypes;
},
getShortDynamicParamType: function() {
return getShortDynamicParamType;
}
});
const dynamicParamTypes = {
catchall: "c",
"optional-catchall": "oc",
dynamic: "d"
};
function getShortDynamicParamType(type) {
const short = dynamicParamTypes[type];
if (!short) {
throw new Error("Unknown dynamic param type");
}
return short;
}
//# sourceMappingURL=get-short-dynamic-param-type.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/get-short-dynamic-param-type.tsx"],"names":["dynamicParamTypes","getShortDynamicParamType","catchall","dynamic","type","short","Error"],"mappings":";;;;;;;;;;;;;;;IAEaA,iBAAiB;eAAjBA;;IAYGC,wBAAwB;eAAxBA;;;AAZT,MAAMD,oBAGT;IACFE,UAAU;IACV,qBAAqB;IACrBC,SAAS;AACX;AAKO,SAASF,yBACdG,IAAuB;IAEvB,MAAMC,QAAQL,iBAAiB,CAACI,KAAK;IACrC,IAAI,CAACC,OAAO;QACV,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOD;AACT"}

View File

@@ -0,0 +1,4 @@
/**
* Interop between "export default" and "module.exports".
*/
export declare function interopDefault(mod: any): any;

View File

@@ -0,0 +1,17 @@
/**
* Interop between "export default" and "module.exports".
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "interopDefault", {
enumerable: true,
get: function() {
return interopDefault;
}
});
function interopDefault(mod) {
return mod.default || mod;
}
//# sourceMappingURL=interop-default.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/interop-default.ts"],"names":["interopDefault","mod","default"],"mappings":"AAAA;;CAEC;;;;+BACeA;;;eAAAA;;;AAAT,SAASA,eAAeC,GAAQ;IACrC,OAAOA,IAAIC,OAAO,IAAID;AACxB"}

View File

@@ -0,0 +1,2 @@
import { FlightRouterState } from './types';
export declare function parseAndValidateFlightRouterState(stateHeader: string | string[] | undefined): FlightRouterState | undefined;

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "parseAndValidateFlightRouterState", {
enumerable: true,
get: function() {
return parseAndValidateFlightRouterState;
}
});
const _types = require("./types");
function parseAndValidateFlightRouterState(stateHeader) {
if (typeof stateHeader === "undefined") {
return undefined;
}
if (Array.isArray(stateHeader)) {
throw new Error("Multiple router state headers were sent. This is not allowed.");
}
// We limit the size of the router state header to ~40kb. This is to prevent
// a malicious user from sending a very large header and slowing down the
// resolving of the router state.
// This is around 2,000 nested or parallel route segment states:
// '{"children":["",{}]}'.length === 20.
if (stateHeader.length > 20 * 2000) {
throw new Error("The router state header was too large.");
}
try {
return _types.flightRouterStateSchema.parse(JSON.parse(decodeURIComponent(stateHeader)));
} catch {
throw new Error("The router state header was sent but could not be parsed.");
}
}
//# sourceMappingURL=parse-and-validate-flight-router-state.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/parse-and-validate-flight-router-state.tsx"],"names":["parseAndValidateFlightRouterState","stateHeader","undefined","Array","isArray","Error","length","flightRouterStateSchema","parse","JSON","decodeURIComponent"],"mappings":";;;;+BAGgBA;;;eAAAA;;;uBAFwB;AAEjC,SAASA,kCACdC,WAA0C;IAE1C,IAAI,OAAOA,gBAAgB,aAAa;QACtC,OAAOC;IACT;IACA,IAAIC,MAAMC,OAAO,CAACH,cAAc;QAC9B,MAAM,IAAII,MACR;IAEJ;IAEA,4EAA4E;IAC5E,yEAAyE;IACzE,iCAAiC;IACjC,gEAAgE;IAChE,wCAAwC;IACxC,IAAIJ,YAAYK,MAAM,GAAG,KAAK,MAAM;QAClC,MAAM,IAAID,MAAM;IAClB;IAEA,IAAI;QACF,OAAOE,8BAAuB,CAACC,KAAK,CAClCC,KAAKD,KAAK,CAACE,mBAAmBT;IAElC,EAAE,OAAM;QACN,MAAM,IAAII,MAAM;IAClB;AACF"}

View File

@@ -0,0 +1 @@
export declare function preloadComponent(Component: any, props: any): any;

View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "preloadComponent", {
enumerable: true,
get: function() {
return preloadComponent;
}
});
function preloadComponent(Component, props) {
const prev = console.error;
// Hide invalid hook call warning when calling component
console.error = function(msg) {
if (msg.startsWith("Warning: Invalid hook call.")) {
// ignore
} else {
// @ts-expect-error argument is defined
prev.apply(console, arguments);
}
};
try {
let result = Component(props);
if (result && typeof result.then === "function") {
// Catch promise rejections to prevent unhandledRejection errors
result.then(()=>{}, ()=>{});
}
return function() {
// We know what this component will render already.
return result;
};
} catch (x) {
// something suspended or errored, try again later
} finally{
console.error = prev;
}
return Component;
}
//# sourceMappingURL=preload-component.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/preload-component.ts"],"names":["preloadComponent","Component","props","prev","console","error","msg","startsWith","apply","arguments","result","then","x"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,iBAAiBC,SAAc,EAAEC,KAAU;IACzD,MAAMC,OAAOC,QAAQC,KAAK;IAC1B,wDAAwD;IACxDD,QAAQC,KAAK,GAAG,SAAUC,GAAG;QAC3B,IAAIA,IAAIC,UAAU,CAAC,gCAAgC;QACjD,SAAS;QACX,OAAO;YACL,uCAAuC;YACvCJ,KAAKK,KAAK,CAACJ,SAASK;QACtB;IACF;IACA,IAAI;QACF,IAAIC,SAAST,UAAUC;QACvB,IAAIQ,UAAU,OAAOA,OAAOC,IAAI,KAAK,YAAY;YAC/C,gEAAgE;YAChED,OAAOC,IAAI,CACT,KAAO,GACP,KAAO;QAEX;QACA,OAAO;YACL,mDAAmD;YACnD,OAAOD;QACT;IACF,EAAE,OAAOE,GAAG;IACV,kDAAkD;IACpD,SAAU;QACRR,QAAQC,KAAK,GAAGF;IAClB;IACA,OAAOF;AACT"}

View File

@@ -0,0 +1,5 @@
/// <reference types="react" />
export declare function renderToString({ ReactDOMServer, element, }: {
ReactDOMServer: typeof import('react-dom/server.edge');
element: React.ReactElement;
}): Promise<string>;

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "renderToString", {
enumerable: true,
get: function() {
return renderToString;
}
});
const _nodewebstreamshelper = require("../stream-utils/node-web-streams-helper");
const _constants = require("../lib/trace/constants");
const _tracer = require("../lib/trace/tracer");
async function renderToString({ ReactDOMServer, element }) {
return (0, _tracer.getTracer)().trace(_constants.AppRenderSpan.renderToString, async ()=>{
const renderStream = await ReactDOMServer.renderToReadableStream(element);
await renderStream.allReady;
return (0, _nodewebstreamshelper.streamToString)(renderStream);
});
}
//# sourceMappingURL=render-to-string.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/render-to-string.tsx"],"names":["renderToString","ReactDOMServer","element","getTracer","trace","AppRenderSpan","renderStream","renderToReadableStream","allReady","streamToString"],"mappings":";;;;+BAIsBA;;;eAAAA;;;sCAJS;2BACD;wBACJ;AAEnB,eAAeA,eAAe,EACnCC,cAAc,EACdC,OAAO,EAIR;IACC,OAAOC,IAAAA,iBAAS,IAAGC,KAAK,CAACC,wBAAa,CAACL,cAAc,EAAE;QACrD,MAAMM,eAAe,MAAML,eAAeM,sBAAsB,CAACL;QACjE,MAAMI,aAAaE,QAAQ;QAC3B,OAAOC,IAAAA,oCAAc,EAACH;IACxB;AACF"}

View File

@@ -0,0 +1,5 @@
import type { BuildManifest } from '../get-page-files';
export declare function getRequiredScripts(buildManifest: BuildManifest, assetPrefix: string, SRIManifest: undefined | Record<string, string>, qs: string, nonce: string | undefined): [() => void, string | {
src: string;
integrity: string;
}];

View File

@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getRequiredScripts", {
enumerable: true,
get: function() {
return getRequiredScripts;
}
});
const _reactdom = /*#__PURE__*/ _interop_require_default(require("react-dom"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function getRequiredScripts(buildManifest, assetPrefix, SRIManifest, qs, nonce) {
let preinitScripts;
let preinitScriptCommands = [];
let bootstrapScript = "";
const files = buildManifest.rootMainFiles;
if (files.length === 0) {
throw new Error("Invariant: missing bootstrap script. This is a bug in Next.js");
}
if (SRIManifest) {
bootstrapScript = {
src: `${assetPrefix}/_next/` + files[0] + qs,
integrity: SRIManifest[files[0]]
};
for(let i = 1; i < files.length; i++){
const src = `${assetPrefix}/_next/` + files[i] + qs;
const integrity = SRIManifest[files[i]];
preinitScriptCommands.push(src, integrity);
}
preinitScripts = ()=>{
// preinitScriptCommands is a double indexed array of src/integrity pairs
for(let i = 0; i < preinitScriptCommands.length; i += 2){
_reactdom.default.preinit(preinitScriptCommands[i], {
as: "script",
integrity: preinitScriptCommands[i + 1],
nonce
});
}
};
} else {
bootstrapScript = `${assetPrefix}/_next/` + files[0] + qs;
for(let i = 1; i < files.length; i++){
const src = `${assetPrefix}/_next/` + files[i] + qs;
preinitScriptCommands.push(src);
}
preinitScripts = ()=>{
// preinitScriptCommands is a singled indexed array of src values
for(let i = 0; i < preinitScriptCommands.length; i++){
_reactdom.default.preinit(preinitScriptCommands[i], {
as: "script",
nonce
});
}
};
}
return [
preinitScripts,
bootstrapScript
];
}
//# sourceMappingURL=required-scripts.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/required-scripts.tsx"],"names":["getRequiredScripts","buildManifest","assetPrefix","SRIManifest","qs","nonce","preinitScripts","preinitScriptCommands","bootstrapScript","files","rootMainFiles","length","Error","src","integrity","i","push","ReactDOM","preinit","as"],"mappings":";;;;+BAIgBA;;;eAAAA;;;iEAFK;;;;;;AAEd,SAASA,mBACdC,aAA4B,EAC5BC,WAAmB,EACnBC,WAA+C,EAC/CC,EAAU,EACVC,KAAyB;IAEzB,IAAIC;IACJ,IAAIC,wBAAkC,EAAE;IACxC,IAAIC,kBAA+D;IACnE,MAAMC,QAAQR,cAAcS,aAAa;IACzC,IAAID,MAAME,MAAM,KAAK,GAAG;QACtB,MAAM,IAAIC,MACR;IAEJ;IACA,IAAIT,aAAa;QACfK,kBAAkB;YAChBK,KAAK,CAAC,EAAEX,YAAY,OAAO,CAAC,GAAGO,KAAK,CAAC,EAAE,GAAGL;YAC1CU,WAAWX,WAAW,CAACM,KAAK,CAAC,EAAE,CAAC;QAClC;QACA,IAAK,IAAIM,IAAI,GAAGA,IAAIN,MAAME,MAAM,EAAEI,IAAK;YACrC,MAAMF,MAAM,CAAC,EAAEX,YAAY,OAAO,CAAC,GAAGO,KAAK,CAACM,EAAE,GAAGX;YACjD,MAAMU,YAAYX,WAAW,CAACM,KAAK,CAACM,EAAE,CAAC;YACvCR,sBAAsBS,IAAI,CAACH,KAAKC;QAClC;QACAR,iBAAiB;YACf,yEAAyE;YACzE,IAAK,IAAIS,IAAI,GAAGA,IAAIR,sBAAsBI,MAAM,EAAEI,KAAK,EAAG;gBACxDE,iBAAQ,CAACC,OAAO,CAACX,qBAAqB,CAACQ,EAAE,EAAE;oBACzCI,IAAI;oBACJL,WAAWP,qBAAqB,CAACQ,IAAI,EAAE;oBACvCV;gBACF;YACF;QACF;IACF,OAAO;QACLG,kBAAkB,CAAC,EAAEN,YAAY,OAAO,CAAC,GAAGO,KAAK,CAAC,EAAE,GAAGL;QACvD,IAAK,IAAIW,IAAI,GAAGA,IAAIN,MAAME,MAAM,EAAEI,IAAK;YACrC,MAAMF,MAAM,CAAC,EAAEX,YAAY,OAAO,CAAC,GAAGO,KAAK,CAACM,EAAE,GAAGX;YACjDG,sBAAsBS,IAAI,CAACH;QAC7B;QACAP,iBAAiB;YACf,iEAAiE;YACjE,IAAK,IAAIS,IAAI,GAAGA,IAAIR,sBAAsBI,MAAM,EAAEI,IAAK;gBACrDE,iBAAQ,CAACC,OAAO,CAACX,qBAAqB,CAACQ,EAAE,EAAE;oBACzCI,IAAI;oBACJd;gBACF;YACF;QACF;IACF;IAEA,OAAO;QAACC;QAAgBE;KAAgB;AAC1C"}

View File

@@ -0,0 +1,3 @@
export declare function preloadStyle(href: string): void;
export declare function preloadFont(href: string, type: string): void;
export declare function preconnect(href: string, crossOrigin?: string): void;

View File

@@ -0,0 +1,58 @@
/*
Files in the rsc directory are meant to be packaged as part of the RSC graph using next-app-loader.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
preloadStyle: null,
preloadFont: null,
preconnect: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
preloadStyle: function() {
return preloadStyle;
},
preloadFont: function() {
return preloadFont;
},
preconnect: function() {
return preconnect;
}
});
const _reactdom = /*#__PURE__*/ _interop_require_default(require("react-dom"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function preloadStyle(href) {
_reactdom.default.preload(href, {
as: "style"
});
}
function preloadFont(href, type) {
_reactdom.default.preload(href, {
as: "font",
type
});
}
function preconnect(href, crossOrigin) {
if (typeof crossOrigin === "string") {
_reactdom.default.preconnect(href, {
crossOrigin
});
} else {
_reactdom.default.preconnect(href);
}
}
//# sourceMappingURL=preloads.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/app-render/rsc/preloads.ts"],"names":["preloadStyle","preloadFont","preconnect","href","ReactDOM","preload","as","type","crossOrigin"],"mappings":"AAAA;;;;AAIA;;;;;;;;;;;;;;;;IAIgBA,YAAY;eAAZA;;IAIAC,WAAW;eAAXA;;IAIAC,UAAU;eAAVA;;;iEAVK;;;;;;AAEd,SAASF,aAAaG,IAAY;IACvCC,iBAAQ,CAACC,OAAO,CAACF,MAAM;QAAEG,IAAI;IAAQ;AACvC;AAEO,SAASL,YAAYE,IAAY,EAAEI,IAAY;IAClDH,iBAAQ,CAASC,OAAO,CAACF,MAAM;QAAEG,IAAI;QAAQC;IAAK;AACtD;AAEO,SAASL,WAAWC,IAAY,EAAEK,WAAoB;IAC3D,IAAI,OAAOA,gBAAgB,UAAU;QACjCJ,iBAAQ,CAASF,UAAU,CAACC,MAAM;YAAEK;QAAY;IACpD,OAAO;QACHJ,iBAAQ,CAASF,UAAU,CAACC;IAChC;AACF"}

View File

@@ -0,0 +1,7 @@
import React from 'react';
export declare function createServerInsertedHTML(): {
ServerInsertedHTMLProvider({ children }: {
children: JSX.Element;
}): React.JSX.Element;
renderServerInsertedHTML(): React.JSX.Element[];
};

View File

@@ -0,0 +1,39 @@
// Provider for the `useServerInsertedHTML` API to register callbacks to insert
// elements into the HTML stream.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "createServerInsertedHTML", {
enumerable: true,
get: function() {
return createServerInsertedHTML;
}
});
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
const _serverinsertedhtmlsharedruntime = require("../../shared/lib/server-inserted-html.shared-runtime");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function createServerInsertedHTML() {
const serverInsertedHTMLCallbacks = [];
const addInsertedHtml = (handler)=>{
serverInsertedHTMLCallbacks.push(handler);
};
return {
ServerInsertedHTMLProvider ({ children }) {
return /*#__PURE__*/ _react.default.createElement(_serverinsertedhtmlsharedruntime.ServerInsertedHTMLContext.Provider, {
value: addInsertedHtml
}, children);
},
renderServerInsertedHTML () {
return serverInsertedHTMLCallbacks.map((callback, index)=>/*#__PURE__*/ _react.default.createElement(_react.default.Fragment, {
key: "__next_server_inserted__" + index
}, callback()));
}
};
}
//# sourceMappingURL=server-inserted-html.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/server-inserted-html.tsx"],"names":["createServerInsertedHTML","serverInsertedHTMLCallbacks","addInsertedHtml","handler","push","ServerInsertedHTMLProvider","children","ServerInsertedHTMLContext","Provider","value","renderServerInsertedHTML","map","callback","index","React","Fragment","key"],"mappings":"AAAA,+EAA+E;AAC/E,iCAAiC;;;;;+BAKjBA;;;eAAAA;;;8DAHE;iDACwB;;;;;;AAEnC,SAASA;IACd,MAAMC,8BAAyD,EAAE;IACjE,MAAMC,kBAAkB,CAACC;QACvBF,4BAA4BG,IAAI,CAACD;IACnC;IAEA,OAAO;QACLE,4BAA2B,EAAEC,QAAQ,EAA6B;YAChE,qBACE,6BAACC,0DAAyB,CAACC,QAAQ;gBAACC,OAAOP;eACxCI;QAGP;QACAI;YACE,OAAOT,4BAA4BU,GAAG,CAAC,CAACC,UAAUC,sBAChD,6BAACC,cAAK,CAACC,QAAQ;oBAACC,KAAK,6BAA6BH;mBAC/CD;QAGP;IACF;AACF"}

95
node_modules/next/dist/server/app-render/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,95 @@
/// <reference types="react" />
import type { LoadComponentsReturnType } from '../load-components';
import type { ServerRuntime, SizeLimit } from '../../../types';
import { NextConfigComplete } from '../../server/config-shared';
import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin';
import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin';
import zod from 'zod';
export type DynamicParamTypes = 'catchall' | 'optional-catchall' | 'dynamic';
declare const dynamicParamTypesSchema: zod.ZodEnum<["c", "oc", "d"]>;
/**
* c = catchall
* oc = optional catchall
* d = dynamic
*/
export type DynamicParamTypesShort = zod.infer<typeof dynamicParamTypesSchema>;
declare const segmentSchema: zod.ZodUnion<[zod.ZodString, zod.ZodTuple<[zod.ZodString, zod.ZodString, zod.ZodEnum<["c", "oc", "d"]>], null>]>;
/**
* Segment in the router state.
*/
export type Segment = zod.infer<typeof segmentSchema>;
export declare const flightRouterStateSchema: zod.ZodType<FlightRouterState>;
/**
* Router state
*/
export type FlightRouterState = [
segment: Segment,
parallelRoutes: {
[parallelRouterKey: string]: FlightRouterState;
},
url?: string | null,
refresh?: 'refetch' | null,
isRootLayout?: boolean
];
/**
* Individual Flight response path
*/
export type FlightSegmentPath = any[] | [
segment: Segment,
parallelRouterKey: string,
segment: Segment,
parallelRouterKey: string,
segment: Segment,
parallelRouterKey: string
];
export type FlightDataPath = any[] | [
...FlightSegmentPath[],
Segment,
FlightRouterState,
React.ReactNode | null,
// Can be null during prefetch if there's no loading component
React.ReactNode | null
];
/**
* The Flight response data
*/
export type FlightData = Array<FlightDataPath> | string;
export type ActionResult = Promise<any>;
export type NextFlightResponse = [buildId: string, flightData: FlightData];
export type ActionFlightResponse = [ActionResult, [buildId: string, flightData: FlightData | null]] | NextFlightResponse;
/**
* Property holding the current subTreeData.
*/
export type ChildProp = {
/**
* Null indicates that the tree is partial
*/
current: React.ReactNode | null;
segment: Segment;
};
export type RenderOptsPartial = {
err?: Error | null;
dev?: boolean;
buildId: string;
basePath: string;
clientReferenceManifest?: ClientReferenceManifest;
supportsDynamicHTML: boolean;
runtime?: ServerRuntime;
serverComponents?: boolean;
assetPrefix?: string;
nextFontManifest?: NextFontManifest;
isBot?: boolean;
incrementalCache?: import('../lib/incremental-cache').IncrementalCache;
isRevalidate?: boolean;
nextExport?: boolean;
nextConfigOutput?: 'standalone' | 'export';
appDirDevErrorLogger?: (err: any) => Promise<void>;
originalPathname?: string;
isDraftMode?: boolean;
deploymentId?: string;
onUpdateCookies?: (cookies: string[]) => void;
loadConfig?: (phase: string, dir: string, customConfig?: object | null, rawConfig?: boolean, silent?: boolean) => Promise<NextConfigComplete>;
serverActionsBodySizeLimit?: SizeLimit;
};
export type RenderOpts = LoadComponentsReturnType & RenderOptsPartial;
export {};

63
node_modules/next/dist/server/app-render/types.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "flightRouterStateSchema", {
enumerable: true,
get: function() {
return flightRouterStateSchema;
}
});
const _zod = /*#__PURE__*/ _interop_require_default(require("zod"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const dynamicParamTypesSchema = _zod.default.enum([
"c",
"oc",
"d"
]);
const segmentSchema = _zod.default.union([
_zod.default.string(),
_zod.default.tuple([
_zod.default.string(),
_zod.default.string(),
dynamicParamTypesSchema
])
]);
const flightRouterStateSchema = _zod.default.lazy(()=>{
const parallelRoutesSchema = _zod.default.record(flightRouterStateSchema);
const urlSchema = _zod.default.string().nullable().optional();
const refreshSchema = _zod.default.literal("refetch").nullable().optional();
const isRootLayoutSchema = _zod.default.boolean().optional();
// Due to the lack of optional tuple types in Zod, we need to use union here.
// https://github.com/colinhacks/zod/issues/1465
return _zod.default.union([
_zod.default.tuple([
segmentSchema,
parallelRoutesSchema,
urlSchema,
refreshSchema,
isRootLayoutSchema
]),
_zod.default.tuple([
segmentSchema,
parallelRoutesSchema,
urlSchema,
refreshSchema
]),
_zod.default.tuple([
segmentSchema,
parallelRoutesSchema,
urlSchema
]),
_zod.default.tuple([
segmentSchema,
parallelRoutesSchema
])
]);
});
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/types.ts"],"names":["flightRouterStateSchema","dynamicParamTypesSchema","zod","enum","segmentSchema","union","string","tuple","lazy","parallelRoutesSchema","record","urlSchema","nullable","optional","refreshSchema","literal","isRootLayoutSchema","boolean"],"mappings":";;;;+BA2BaA;;;eAAAA;;;4DArBG;;;;;;AAIhB,MAAMC,0BAA0BC,YAAG,CAACC,IAAI,CAAC;IAAC;IAAK;IAAM;CAAI;AAQzD,MAAMC,gBAAgBF,YAAG,CAACG,KAAK,CAAC;IAC9BH,YAAG,CAACI,MAAM;IACVJ,YAAG,CAACK,KAAK,CAAC;QAACL,YAAG,CAACI,MAAM;QAAIJ,YAAG,CAACI,MAAM;QAAIL;KAAwB;CAChE;AAMM,MAAMD,0BAA0DE,YAAG,CAACM,IAAI,CAC7E;IACE,MAAMC,uBAAuBP,YAAG,CAACQ,MAAM,CAACV;IACxC,MAAMW,YAAYT,YAAG,CAACI,MAAM,GAAGM,QAAQ,GAAGC,QAAQ;IAClD,MAAMC,gBAAgBZ,YAAG,CAACa,OAAO,CAAC,WAAWH,QAAQ,GAAGC,QAAQ;IAChE,MAAMG,qBAAqBd,YAAG,CAACe,OAAO,GAAGJ,QAAQ;IAEjD,6EAA6E;IAC7E,gDAAgD;IAChD,OAAOX,YAAG,CAACG,KAAK,CAAC;QACfH,YAAG,CAACK,KAAK,CAAC;YACRH;YACAK;YACAE;YACAG;YACAE;SACD;QACDd,YAAG,CAACK,KAAK,CAAC;YACRH;YACAK;YACAE;YACAG;SACD;QACDZ,YAAG,CAACK,KAAK,CAAC;YAACH;YAAeK;YAAsBE;SAAU;QAC1DT,YAAG,CAACK,KAAK,CAAC;YAACH;YAAeK;SAAqB;KAChD;AACH"}

View File

@@ -0,0 +1,8 @@
/// <reference types="react" />
import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin';
import type { FlightResponseRef } from './flight-response-ref';
/**
* Render Flight stream.
* This is only used for renderToHTML, the Flight response does not need additional wrappers.
*/
export declare function useFlightResponse(writable: WritableStream<Uint8Array>, req: ReadableStream<Uint8Array>, clientReferenceManifest: ClientReferenceManifest, rscChunks: Uint8Array[], flightResponseRef: FlightResponseRef, nonce?: string): Promise<JSX.Element>;

View File

@@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useFlightResponse", {
enumerable: true,
get: function() {
return useFlightResponse;
}
});
const _encodedecode = require("../stream-utils/encode-decode");
const _htmlescape = require("../htmlescape");
const isEdgeRuntime = process.env.NEXT_RUNTIME === "edge";
function useFlightResponse(writable, req, clientReferenceManifest, rscChunks, flightResponseRef, nonce) {
if (flightResponseRef.current !== null) {
return flightResponseRef.current;
}
// react-server-dom-webpack/client.edge must not be hoisted for require cache clearing to work correctly
const { createFromReadableStream } = require(`react-server-dom-webpack/client.edge`);
const [renderStream, forwardStream] = req.tee();
const res = createFromReadableStream(renderStream, {
moduleMap: isEdgeRuntime ? clientReferenceManifest.edgeSSRModuleMapping : clientReferenceManifest.ssrModuleMapping
});
flightResponseRef.current = res;
let bootstrapped = false;
// We only attach CSS chunks to the inlined data.
const forwardReader = forwardStream.getReader();
const writer = writable.getWriter();
const startScriptTag = nonce ? `<script nonce=${JSON.stringify(nonce)}>` : "<script>";
const textDecoder = new TextDecoder();
function read() {
forwardReader.read().then(({ done, value })=>{
if (value) {
rscChunks.push(value);
}
if (!bootstrapped) {
bootstrapped = true;
writer.write((0, _encodedecode.encodeText)(`${startScriptTag}(self.__next_f=self.__next_f||[]).push(${(0, _htmlescape.htmlEscapeJsonString)(JSON.stringify([
0
]))})</script>`));
}
if (done) {
// Add a setTimeout here because the error component is too small, the first forwardReader.read() read will return the full chunk
// and then it immediately set flightResponseRef.current as null.
// react renders the component twice, the second render will run into the state with useFlightResponse where flightResponseRef.current is null,
// so it tries to render the flight payload again
setTimeout(()=>{
flightResponseRef.current = null;
});
writer.close();
} else {
const responsePartial = (0, _encodedecode.decodeText)(value, textDecoder);
const scripts = `${startScriptTag}self.__next_f.push(${(0, _htmlescape.htmlEscapeJsonString)(JSON.stringify([
1,
responsePartial
]))})</script>`;
writer.write((0, _encodedecode.encodeText)(scripts));
read();
}
});
}
read();
return res;
}
//# sourceMappingURL=use-flight-response.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/use-flight-response.tsx"],"names":["useFlightResponse","isEdgeRuntime","process","env","NEXT_RUNTIME","writable","req","clientReferenceManifest","rscChunks","flightResponseRef","nonce","current","createFromReadableStream","require","renderStream","forwardStream","tee","res","moduleMap","edgeSSRModuleMapping","ssrModuleMapping","bootstrapped","forwardReader","getReader","writer","getWriter","startScriptTag","JSON","stringify","textDecoder","TextDecoder","read","then","done","value","push","write","encodeText","htmlEscapeJsonString","setTimeout","close","responsePartial","decodeText","scripts"],"mappings":";;;;+BAWgBA;;;eAAAA;;;8BATuB;4BACF;AAErC,MAAMC,gBAAgBC,QAAQC,GAAG,CAACC,YAAY,KAAK;AAM5C,SAASJ,kBACdK,QAAoC,EACpCC,GAA+B,EAC/BC,uBAAgD,EAChDC,SAAuB,EACvBC,iBAAoC,EACpCC,KAAc;IAEd,IAAID,kBAAkBE,OAAO,KAAK,MAAM;QACtC,OAAOF,kBAAkBE,OAAO;IAClC;IACA,wGAAwG;IACxG,MAAM,EACJC,wBAAwB,EACzB,GAAGC,QAAQ,CAAC,oCAAoC,CAAC;IAElD,MAAM,CAACC,cAAcC,cAAc,GAAGT,IAAIU,GAAG;IAC7C,MAAMC,MAAML,yBAAyBE,cAAc;QACjDI,WAAWjB,gBACPM,wBAAwBY,oBAAoB,GAC5CZ,wBAAwBa,gBAAgB;IAC9C;IACAX,kBAAkBE,OAAO,GAAGM;IAE5B,IAAII,eAAe;IACnB,iDAAiD;IACjD,MAAMC,gBAAgBP,cAAcQ,SAAS;IAC7C,MAAMC,SAASnB,SAASoB,SAAS;IACjC,MAAMC,iBAAiBhB,QACnB,CAAC,cAAc,EAAEiB,KAAKC,SAAS,CAAClB,OAAO,CAAC,CAAC,GACzC;IACJ,MAAMmB,cAAc,IAAIC;IAExB,SAASC;QACPT,cAAcS,IAAI,GAAGC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAEC,KAAK,EAAE;YACxC,IAAIA,OAAO;gBACT1B,UAAU2B,IAAI,CAACD;YACjB;YAEA,IAAI,CAACb,cAAc;gBACjBA,eAAe;gBACfG,OAAOY,KAAK,CACVC,IAAAA,wBAAU,EACR,CAAC,EAAEX,eAAe,uCAAuC,EAAEY,IAAAA,gCAAoB,EAC7EX,KAAKC,SAAS,CAAC;oBAAC;iBAAE,GAClB,UAAU,CAAC;YAGnB;YACA,IAAIK,MAAM;gBACR,iIAAiI;gBACjI,iEAAiE;gBACjE,+IAA+I;gBAC/I,iDAAiD;gBACjDM,WAAW;oBACT9B,kBAAkBE,OAAO,GAAG;gBAC9B;gBACAa,OAAOgB,KAAK;YACd,OAAO;gBACL,MAAMC,kBAAkBC,IAAAA,wBAAU,EAACR,OAAOL;gBAC1C,MAAMc,UAAU,CAAC,EAAEjB,eAAe,mBAAmB,EAAEY,IAAAA,gCAAoB,EACzEX,KAAKC,SAAS,CAAC;oBAAC;oBAAGa;iBAAgB,GACnC,UAAU,CAAC;gBAEbjB,OAAOY,KAAK,CAACC,IAAAA,wBAAU,EAACM;gBACxBZ;YACF;QACF;IACF;IACAA;IAEA,OAAOd;AACT"}

View File

@@ -0,0 +1 @@
export declare function validateURL(url: string | undefined): string;

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "validateURL", {
enumerable: true,
get: function() {
return validateURL;
}
});
const DUMMY_ORIGIN = "http://n";
const INVALID_URL_MESSAGE = "Invalid request URL";
function validateURL(url) {
if (!url) {
throw new Error(INVALID_URL_MESSAGE);
}
try {
const parsed = new URL(url, DUMMY_ORIGIN);
// Avoid origin change by extra slashes in pathname
if (parsed.origin !== DUMMY_ORIGIN) {
throw new Error(INVALID_URL_MESSAGE);
}
return url;
} catch {
throw new Error(INVALID_URL_MESSAGE);
}
}
//# sourceMappingURL=validate-url.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/app-render/validate-url.tsx"],"names":["validateURL","DUMMY_ORIGIN","INVALID_URL_MESSAGE","url","Error","parsed","URL","origin"],"mappings":";;;;+BAGgBA;;;eAAAA;;;AAHhB,MAAMC,eAAe;AACrB,MAAMC,sBAAsB;AAErB,SAASF,YAAYG,GAAuB;IACjD,IAAI,CAACA,KAAK;QACR,MAAM,IAAIC,MAAMF;IAClB;IACA,IAAI;QACF,MAAMG,SAAS,IAAIC,IAAIH,KAAKF;QAC5B,mDAAmD;QACnD,IAAII,OAAOE,MAAM,KAAKN,cAAc;YAClC,MAAM,IAAIG,MAAMF;QAClB;QACA,OAAOC;IACT,EAAE,OAAM;QACN,MAAM,IAAIC,MAAMF;IAClB;AACF"}

View File

@@ -0,0 +1,17 @@
/// <reference types="node" />
import type { AsyncLocalStorage } from 'async_hooks';
/**
* Implementations provide a wrapping function that will provide the storage to
* async calls derived from the provided callback function.
*/
export interface AsyncStorageWrapper<Store extends {}, Context extends {}> {
/**
* Wraps the callback with the underlying storage.
*
* @param storage underlying storage object
* @param context context used to create the storage object
* @param callback function to call within the scope of the storage
* @returns the result of the callback
*/
wrap<Result>(storage: AsyncLocalStorage<Store>, context: Context, callback: (store: Store) => Result): Result;
}

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=async-storage-wrapper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":""}

View File

@@ -0,0 +1,13 @@
/// <reference types="node" />
import type { IncomingMessage } from 'http';
import type { ReadonlyRequestCookies } from '../web/spec-extension/adapters/request-cookies';
import type { ResponseCookies } from '../web/spec-extension/cookies';
import type { BaseNextRequest } from '../base-http';
import type { NextRequest } from '../web/spec-extension/request';
import { __ApiPreviewProps } from '../api-utils';
export declare class DraftModeProvider {
readonly isEnabled: boolean;
constructor(previewProps: __ApiPreviewProps | undefined, req: IncomingMessage | BaseNextRequest<unknown> | NextRequest, cookies: ReadonlyRequestCookies, mutableCookies: ResponseCookies);
enable(): void;
disable(): void;
}

View File

@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "DraftModeProvider", {
enumerable: true,
get: function() {
return DraftModeProvider;
}
});
const _apiutils = require("../api-utils");
class DraftModeProvider {
constructor(previewProps, req, cookies, mutableCookies){
var _cookies_get;
// The logic for draftMode() is very similar to tryGetPreviewData()
// but Draft Mode does not have any data associated with it.
const isOnDemandRevalidate = previewProps && (0, _apiutils.checkIsOnDemandRevalidate)(req, previewProps).isOnDemandRevalidate;
const cookieValue = (_cookies_get = cookies.get(_apiutils.COOKIE_NAME_PRERENDER_BYPASS)) == null ? void 0 : _cookies_get.value;
this.isEnabled = Boolean(!isOnDemandRevalidate && cookieValue && previewProps && cookieValue === previewProps.previewModeId);
this._previewModeId = previewProps == null ? void 0 : previewProps.previewModeId;
this._mutableCookies = mutableCookies;
}
enable() {
if (!this._previewModeId) {
throw new Error("Invariant: previewProps missing previewModeId this should never happen");
}
this._mutableCookies.set({
name: _apiutils.COOKIE_NAME_PRERENDER_BYPASS,
value: this._previewModeId,
httpOnly: true,
sameSite: process.env.NODE_ENV !== "development" ? "none" : "lax",
secure: process.env.NODE_ENV !== "development",
path: "/"
});
}
disable() {
// To delete a cookie, set `expires` to a date in the past:
// https://tools.ietf.org/html/rfc6265#section-4.1.1
// `Max-Age: 0` is not valid, thus ignored, and the cookie is persisted.
this._mutableCookies.set({
name: _apiutils.COOKIE_NAME_PRERENDER_BYPASS,
value: "",
httpOnly: true,
sameSite: process.env.NODE_ENV !== "development" ? "none" : "lax",
secure: process.env.NODE_ENV !== "development",
path: "/",
expires: new Date(0)
});
}
}
//# sourceMappingURL=draft-mode-provider.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/async-storage/draft-mode-provider.ts"],"names":["DraftModeProvider","constructor","previewProps","req","cookies","mutableCookies","isOnDemandRevalidate","checkIsOnDemandRevalidate","cookieValue","get","COOKIE_NAME_PRERENDER_BYPASS","value","isEnabled","Boolean","previewModeId","_previewModeId","_mutableCookies","enable","Error","set","name","httpOnly","sameSite","process","env","NODE_ENV","secure","path","disable","expires","Date"],"mappings":";;;;+BAYaA;;;eAAAA;;;0BAFN;AAEA,MAAMA;IAaXC,YACEC,YAA2C,EAC3CC,GAA6D,EAC7DC,OAA+B,EAC/BC,cAA+B,CAC/B;YAOoBD;QANpB,mEAAmE;QACnE,4DAA4D;QAC5D,MAAME,uBACJJ,gBACAK,IAAAA,mCAAyB,EAACJ,KAAKD,cAAcI,oBAAoB;QAEnE,MAAME,eAAcJ,eAAAA,QAAQK,GAAG,CAACC,sCAA4B,sBAAxCN,aAA2CO,KAAK;QAEpE,IAAI,CAACC,SAAS,GAAGC,QACf,CAACP,wBACCE,eACAN,gBACAM,gBAAgBN,aAAaY,aAAa;QAG9C,IAAI,CAACC,cAAc,GAAGb,gCAAAA,aAAcY,aAAa;QACjD,IAAI,CAACE,eAAe,GAAGX;IACzB;IAEAY,SAAS;QACP,IAAI,CAAC,IAAI,CAACF,cAAc,EAAE;YACxB,MAAM,IAAIG,MACR;QAEJ;QAEA,IAAI,CAACF,eAAe,CAACG,GAAG,CAAC;YACvBC,MAAMV,sCAA4B;YAClCC,OAAO,IAAI,CAACI,cAAc;YAC1BM,UAAU;YACVC,UAAUC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBAAgB,SAAS;YAC5DC,QAAQH,QAAQC,GAAG,CAACC,QAAQ,KAAK;YACjCE,MAAM;QACR;IACF;IAEAC,UAAU;QACR,2DAA2D;QAC3D,oDAAoD;QACpD,wEAAwE;QACxE,IAAI,CAACZ,eAAe,CAACG,GAAG,CAAC;YACvBC,MAAMV,sCAA4B;YAClCC,OAAO;YACPU,UAAU;YACVC,UAAUC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBAAgB,SAAS;YAC5DC,QAAQH,QAAQC,GAAG,CAACC,QAAQ,KAAK;YACjCE,MAAM;YACNE,SAAS,IAAIC,KAAK;QACpB;IACF;AACF"}

View File

@@ -0,0 +1,13 @@
/// <reference types="node" />
import type { BaseNextRequest, BaseNextResponse } from '../base-http';
import type { IncomingMessage, ServerResponse } from 'http';
import type { RequestStore } from '../../client/components/request-async-storage.external';
import type { RenderOpts } from '../app-render/types';
import type { AsyncStorageWrapper } from './async-storage-wrapper';
import type { NextRequest } from '../web/spec-extension/request';
export type RequestContext = {
req: IncomingMessage | BaseNextRequest | NextRequest;
res?: ServerResponse | BaseNextResponse;
renderOpts?: RenderOpts;
};
export declare const RequestAsyncStorageWrapper: AsyncStorageWrapper<RequestStore, RequestContext>;

View File

@@ -0,0 +1,86 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "RequestAsyncStorageWrapper", {
enumerable: true,
get: function() {
return RequestAsyncStorageWrapper;
}
});
const _approuterheaders = require("../../client/components/app-router-headers");
const _headers = require("../web/spec-extension/adapters/headers");
const _requestcookies = require("../web/spec-extension/adapters/request-cookies");
const _cookies = require("../web/spec-extension/cookies");
const _draftmodeprovider = require("./draft-mode-provider");
function getHeaders(headers) {
const cleaned = _headers.HeadersAdapter.from(headers);
for (const param of _approuterheaders.FLIGHT_PARAMETERS){
cleaned.delete(param.toString().toLowerCase());
}
return _headers.HeadersAdapter.seal(cleaned);
}
function getCookies(headers) {
const cookies = new _cookies.RequestCookies(_headers.HeadersAdapter.from(headers));
return _requestcookies.RequestCookiesAdapter.seal(cookies);
}
function getMutableCookies(headers, onUpdateCookies) {
const cookies = new _cookies.RequestCookies(_headers.HeadersAdapter.from(headers));
return _requestcookies.MutableRequestCookiesAdapter.wrap(cookies, onUpdateCookies);
}
const RequestAsyncStorageWrapper = {
/**
* Wrap the callback with the given store so it can access the underlying
* store using hooks.
*
* @param storage underlying storage object returned by the module
* @param context context to seed the store
* @param callback function to call within the scope of the context
* @returns the result returned by the callback
*/ wrap (storage, { req, res, renderOpts }, callback) {
let previewProps = undefined;
if (renderOpts && "previewProps" in renderOpts) {
// TODO: investigate why previewProps isn't on RenderOpts
previewProps = renderOpts.previewProps;
}
function defaultOnUpdateCookies(cookies) {
if (res) {
res.setHeader("Set-Cookie", cookies);
}
}
const cache = {};
const store = {
get headers () {
if (!cache.headers) {
// Seal the headers object that'll freeze out any methods that could
// mutate the underlying data.
cache.headers = getHeaders(req.headers);
}
return cache.headers;
},
get cookies () {
if (!cache.cookies) {
// Seal the cookies object that'll freeze out any methods that could
// mutate the underlying data.
cache.cookies = getCookies(req.headers);
}
return cache.cookies;
},
get mutableCookies () {
if (!cache.mutableCookies) {
cache.mutableCookies = getMutableCookies(req.headers, (renderOpts == null ? void 0 : renderOpts.onUpdateCookies) || (res ? defaultOnUpdateCookies : undefined));
}
return cache.mutableCookies;
},
get draftMode () {
if (!cache.draftMode) {
cache.draftMode = new _draftmodeprovider.DraftModeProvider(previewProps, req, this.cookies, this.mutableCookies);
}
return cache.draftMode;
}
};
return storage.run(store, callback, store);
}
};
//# sourceMappingURL=request-async-storage-wrapper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/async-storage/request-async-storage-wrapper.ts"],"names":["RequestAsyncStorageWrapper","getHeaders","headers","cleaned","HeadersAdapter","from","param","FLIGHT_PARAMETERS","delete","toString","toLowerCase","seal","getCookies","cookies","RequestCookies","RequestCookiesAdapter","getMutableCookies","onUpdateCookies","MutableRequestCookiesAdapter","wrap","storage","req","res","renderOpts","callback","previewProps","undefined","defaultOnUpdateCookies","setHeader","cache","store","mutableCookies","draftMode","DraftModeProvider","run"],"mappings":";;;;+BAoDaA;;;eAAAA;;;kCA5CqB;yBAI3B;gCAKA;yBACyC;mCAEd;AAElC,SAASC,WAAWC,OAAsC;IACxD,MAAMC,UAAUC,uBAAc,CAACC,IAAI,CAACH;IACpC,KAAK,MAAMI,SAASC,mCAAiB,CAAE;QACrCJ,QAAQK,MAAM,CAACF,MAAMG,QAAQ,GAAGC,WAAW;IAC7C;IAEA,OAAON,uBAAc,CAACO,IAAI,CAACR;AAC7B;AAEA,SAASS,WACPV,OAAsC;IAEtC,MAAMW,UAAU,IAAIC,uBAAc,CAACV,uBAAc,CAACC,IAAI,CAACH;IACvD,OAAOa,qCAAqB,CAACJ,IAAI,CAACE;AACpC;AAEA,SAASG,kBACPd,OAAsC,EACtCe,eAA6C;IAE7C,MAAMJ,UAAU,IAAIC,uBAAc,CAACV,uBAAc,CAACC,IAAI,CAACH;IACvD,OAAOgB,4CAA4B,CAACC,IAAI,CAACN,SAASI;AACpD;AAQO,MAAMjB,6BAGT;IACF;;;;;;;;GAQC,GACDmB,MACEC,OAAwC,EACxC,EAAEC,GAAG,EAAEC,GAAG,EAAEC,UAAU,EAAkB,EACxCC,QAAyC;QAEzC,IAAIC,eAA8CC;QAElD,IAAIH,cAAc,kBAAkBA,YAAY;YAC9C,yDAAyD;YACzDE,eAAe,AAACF,WAAmBE,YAAY;QACjD;QAEA,SAASE,uBAAuBd,OAAiB;YAC/C,IAAIS,KAAK;gBACPA,IAAIM,SAAS,CAAC,cAAcf;YAC9B;QACF;QAEA,MAAMgB,QAKF,CAAC;QAEL,MAAMC,QAAsB;YAC1B,IAAI5B,WAAU;gBACZ,IAAI,CAAC2B,MAAM3B,OAAO,EAAE;oBAClB,oEAAoE;oBACpE,8BAA8B;oBAC9B2B,MAAM3B,OAAO,GAAGD,WAAWoB,IAAInB,OAAO;gBACxC;gBAEA,OAAO2B,MAAM3B,OAAO;YACtB;YACA,IAAIW,WAAU;gBACZ,IAAI,CAACgB,MAAMhB,OAAO,EAAE;oBAClB,oEAAoE;oBACpE,8BAA8B;oBAC9BgB,MAAMhB,OAAO,GAAGD,WAAWS,IAAInB,OAAO;gBACxC;gBAEA,OAAO2B,MAAMhB,OAAO;YACtB;YACA,IAAIkB,kBAAiB;gBACnB,IAAI,CAACF,MAAME,cAAc,EAAE;oBACzBF,MAAME,cAAc,GAAGf,kBACrBK,IAAInB,OAAO,EACXqB,CAAAA,8BAAAA,WAAYN,eAAe,KACxBK,CAAAA,MAAMK,yBAAyBD,SAAQ;gBAE9C;gBACA,OAAOG,MAAME,cAAc;YAC7B;YACA,IAAIC,aAAY;gBACd,IAAI,CAACH,MAAMG,SAAS,EAAE;oBACpBH,MAAMG,SAAS,GAAG,IAAIC,oCAAiB,CACrCR,cACAJ,KACA,IAAI,CAACR,OAAO,EACZ,IAAI,CAACkB,cAAc;gBAEvB;gBAEA,OAAOF,MAAMG,SAAS;YACxB;QACF;QAEA,OAAOZ,QAAQc,GAAG,CAACJ,OAAON,UAAUM;IACtC;AACF"}

View File

@@ -0,0 +1,19 @@
import type { AsyncStorageWrapper } from './async-storage-wrapper';
import type { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external';
import type { IncrementalCache } from '../lib/incremental-cache';
export type StaticGenerationContext = {
urlPathname: string;
renderOpts: {
originalPathname?: string;
incrementalCache?: IncrementalCache;
supportsDynamicHTML: boolean;
isRevalidate?: boolean;
isOnDemandRevalidate?: boolean;
isBot?: boolean;
nextExport?: boolean;
fetchCache?: StaticGenerationStore['fetchCache'];
isDraftMode?: boolean;
isServerAction?: boolean;
};
};
export declare const StaticGenerationAsyncStorageWrapper: AsyncStorageWrapper<StaticGenerationStore, StaticGenerationContext>;

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "StaticGenerationAsyncStorageWrapper", {
enumerable: true,
get: function() {
return StaticGenerationAsyncStorageWrapper;
}
});
const StaticGenerationAsyncStorageWrapper = {
wrap (storage, { urlPathname, renderOpts }, callback) {
/**
* Rules of Static & Dynamic HTML:
*
* 1.) We must generate static HTML unless the caller explicitly opts
* in to dynamic HTML support.
*
* 2.) If dynamic HTML support is requested, we must honor that request
* or throw an error. It is the sole responsibility of the caller to
* ensure they aren't e.g. requesting dynamic HTML for an AMP page.
*
* 3.) If the request is in draft mode, we must generate dynamic HTML.
*
* 4.) If the request is a server action, we must generate dynamic HTML.
*
* These rules help ensure that other existing features like request caching,
* coalescing, and ISR continue working as intended.
*/ const isStaticGeneration = !renderOpts.supportsDynamicHTML && !renderOpts.isDraftMode && !renderOpts.isServerAction;
const store = {
isStaticGeneration,
urlPathname,
pagePath: renderOpts.originalPathname,
incrementalCache: // we fallback to a global incremental cache for edge-runtime locally
// so that it can access the fs cache without mocks
renderOpts.incrementalCache || globalThis.__incrementalCache,
isRevalidate: renderOpts.isRevalidate,
isPrerendering: renderOpts.nextExport,
fetchCache: renderOpts.fetchCache,
isOnDemandRevalidate: renderOpts.isOnDemandRevalidate,
isDraftMode: renderOpts.isDraftMode
};
// TODO: remove this when we resolve accessing the store outside the execution context
renderOpts.store = store;
return storage.run(store, callback, store);
}
};
//# sourceMappingURL=static-generation-async-storage-wrapper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/async-storage/static-generation-async-storage-wrapper.ts"],"names":["StaticGenerationAsyncStorageWrapper","wrap","storage","urlPathname","renderOpts","callback","isStaticGeneration","supportsDynamicHTML","isDraftMode","isServerAction","store","pagePath","originalPathname","incrementalCache","globalThis","__incrementalCache","isRevalidate","isPrerendering","nextExport","fetchCache","isOnDemandRevalidate","run"],"mappings":";;;;+BA+BaA;;;eAAAA;;;AAAN,MAAMA,sCAGT;IACFC,MACEC,OAAiD,EACjD,EAAEC,WAAW,EAAEC,UAAU,EAA2B,EACpDC,QAAkD;QAElD;;;;;;;;;;;;;;;;KAgBC,GACD,MAAMC,qBACJ,CAACF,WAAWG,mBAAmB,IAC/B,CAACH,WAAWI,WAAW,IACvB,CAACJ,WAAWK,cAAc;QAE5B,MAAMC,QAA+B;YACnCJ;YACAH;YACAQ,UAAUP,WAAWQ,gBAAgB;YACrCC,kBACE,qEAAqE;YACrE,mDAAmD;YACnDT,WAAWS,gBAAgB,IAAI,AAACC,WAAmBC,kBAAkB;YACvEC,cAAcZ,WAAWY,YAAY;YACrCC,gBAAgBb,WAAWc,UAAU;YACrCC,YAAYf,WAAWe,UAAU;YACjCC,sBAAsBhB,WAAWgB,oBAAoB;YAErDZ,aAAaJ,WAAWI,WAAW;QACrC;QAEA,sFAAsF;QACtFJ,WAAWM,KAAK,GAAGA;QAEnB,OAAOR,QAAQmB,GAAG,CAACX,OAAOL,UAAUK;IACtC;AACF"}

53
node_modules/next/dist/server/base-http/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,53 @@
/// <reference types="node" />
import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
import type { I18NConfig } from '../config-shared';
import { NextApiRequestCookies } from '../api-utils';
export interface BaseNextRequestConfig {
basePath: string | undefined;
i18n?: I18NConfig;
trailingSlash?: boolean | undefined;
}
export declare abstract class BaseNextRequest<Body = any> {
method: string;
url: string;
body: Body;
protected _cookies: NextApiRequestCookies | undefined;
abstract headers: IncomingHttpHeaders;
constructor(method: string, url: string, body: Body);
abstract parseBody(limit: string | number): Promise<any>;
get cookies(): Partial<{
[key: string]: string;
}>;
}
export declare abstract class BaseNextResponse<Destination = any> {
destination: Destination;
abstract statusCode: number | undefined;
abstract statusMessage: string | undefined;
abstract get sent(): boolean;
constructor(destination: Destination);
/**
* Sets a value for the header overwriting existing values
*/
abstract setHeader(name: string, value: string | string[]): this;
/**
* Removes a header
*/
abstract removeHeader(name: string): this;
/**
* Appends value for the given header name
*/
abstract appendHeader(name: string, value: string): this;
/**
* Get all vaues for a header as an array or undefined if no value is present
*/
abstract getHeaderValues(name: string): string[] | undefined;
abstract hasHeader(name: string): boolean;
/**
* Get vaues for a header concatenated using `,` or undefined if no value is present
*/
abstract getHeader(name: string): string | undefined;
abstract getHeaders(): OutgoingHttpHeaders;
abstract body(value: string): this;
abstract send(): void;
redirect(destination: string, statusCode: number): this;
}

54
node_modules/next/dist/server/base-http/index.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
BaseNextRequest: null,
BaseNextResponse: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
BaseNextRequest: function() {
return BaseNextRequest;
},
BaseNextResponse: function() {
return BaseNextResponse;
}
});
const _constants = require("../../shared/lib/constants");
const _getcookieparser = require("../api-utils/get-cookie-parser");
class BaseNextRequest {
constructor(method, url, body){
this.method = method;
this.url = url;
this.body = body;
}
// Utils implemented using the abstract methods above
get cookies() {
if (this._cookies) return this._cookies;
return this._cookies = (0, _getcookieparser.getCookieParser)(this.headers)();
}
}
class BaseNextResponse {
constructor(destination){
this.destination = destination;
}
// Utils implemented using the abstract methods above
redirect(destination, statusCode) {
this.setHeader("Location", destination);
this.statusCode = statusCode;
// Since IE11 doesn't support the 308 header add backwards
// compatibility using refresh header
if (statusCode === _constants.PERMANENT_REDIRECT_STATUS) {
this.setHeader("Refresh", `0;url=${destination}`);
}
return this;
}
}
//# sourceMappingURL=index.js.map

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

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/server/base-http/index.ts"],"names":["BaseNextRequest","BaseNextResponse","constructor","method","url","body","cookies","_cookies","getCookieParser","headers","destination","redirect","statusCode","setHeader","PERMANENT_REDIRECT_STATUS"],"mappings":";;;;;;;;;;;;;;;IAasBA,eAAe;eAAfA;;IAgBAC,gBAAgB;eAAhBA;;;2BA1BoB;iCAEV;AAQzB,MAAeD;IAIpBE,YAAmBC,QAAuBC,KAAoBC,KAAY;sBAAvDF;mBAAuBC;oBAAoBC;IAAa;IAI3E,qDAAqD;IAErD,IAAWC,UAAU;QACnB,IAAI,IAAI,CAACC,QAAQ,EAAE,OAAO,IAAI,CAACA,QAAQ;QACvC,OAAQ,IAAI,CAACA,QAAQ,GAAGC,IAAAA,gCAAe,EAAC,IAAI,CAACC,OAAO;IACtD;AACF;AAEO,MAAeR;IAKpBC,YAAmBQ,YAA0B;2BAA1BA;IAA2B;IAmC9C,qDAAqD;IAErDC,SAASD,WAAmB,EAAEE,UAAkB,EAAE;QAChD,IAAI,CAACC,SAAS,CAAC,YAAYH;QAC3B,IAAI,CAACE,UAAU,GAAGA;QAElB,0DAA0D;QAC1D,qCAAqC;QACrC,IAAIA,eAAeE,oCAAyB,EAAE;YAC5C,IAAI,CAACD,SAAS,CAAC,WAAW,CAAC,MAAM,EAAEH,YAAY,CAAC;QAClD;QACA,OAAO,IAAI;IACb;AACF"}

48
node_modules/next/dist/server/base-http/node.d.ts generated vendored Normal file
View File

@@ -0,0 +1,48 @@
/// <reference types="node" />
/// <reference types="node" />
import type { ServerResponse, IncomingMessage } from 'http';
import type { Writable, Readable } from 'stream';
import type { SizeLimit } from 'next/types';
import { NextApiRequestCookies, SYMBOL_CLEARED_COOKIES } from '../api-utils';
import { NEXT_REQUEST_META, RequestMeta } from '../request-meta';
import { BaseNextRequest, BaseNextResponse } from './index';
import { OutgoingHttpHeaders } from 'node:http';
type Req = IncomingMessage & {
[NEXT_REQUEST_META]?: RequestMeta;
cookies?: NextApiRequestCookies;
};
export declare class NodeNextRequest extends BaseNextRequest<Readable> {
private _req;
headers: import("http").IncomingHttpHeaders;
[NEXT_REQUEST_META]: RequestMeta;
get originalRequest(): Req;
set originalRequest(value: Req);
constructor(_req: Req);
parseBody(limit: SizeLimit): Promise<any>;
}
export declare class NodeNextResponse extends BaseNextResponse<Writable> {
private _res;
private textBody;
[SYMBOL_CLEARED_COOKIES]?: boolean;
get originalResponse(): ServerResponse<IncomingMessage> & {
[SYMBOL_CLEARED_COOKIES]?: boolean | undefined;
};
constructor(_res: ServerResponse & {
[SYMBOL_CLEARED_COOKIES]?: boolean;
});
get sent(): boolean;
get statusCode(): number;
set statusCode(value: number);
get statusMessage(): string;
set statusMessage(value: string);
setHeader(name: string, value: string | string[]): this;
removeHeader(name: string): this;
getHeaderValues(name: string): string[] | undefined;
hasHeader(name: string): boolean;
getHeader(name: string): string | undefined;
getHeaders(): OutgoingHttpHeaders;
appendHeader(name: string, value: string): this;
body(value: string): this;
send(): void;
}
export {};

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