Initial boiler plate project
This commit is contained in:
1
node_modules/next/dist/server/accept-header.d.ts
generated
vendored
Normal file
1
node_modules/next/dist/server/accept-header.d.ts
generated
vendored
Normal 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
120
node_modules/next/dist/server/accept-header.js
generated
vendored
Normal 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
1
node_modules/next/dist/server/accept-header.js.map
generated
vendored
Normal 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"}
|
||||
8
node_modules/next/dist/server/api-utils/get-cookie-parser.d.ts
generated
vendored
Normal file
8
node_modules/next/dist/server/api-utils/get-cookie-parser.d.ts
generated
vendored
Normal 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;
|
||||
22
node_modules/next/dist/server/api-utils/get-cookie-parser.js
generated
vendored
Normal file
22
node_modules/next/dist/server/api-utils/get-cookie-parser.js
generated
vendored
Normal 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
|
||||
1
node_modules/next/dist/server/api-utils/get-cookie-parser.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/api-utils/get-cookie-parser.js.map
generated
vendored
Normal 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"}
|
||||
66
node_modules/next/dist/server/api-utils/index.d.ts
generated
vendored
Normal file
66
node_modules/next/dist/server/api-utils/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/// <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;
|
||||
};
|
||||
export declare function wrapApiHandler<T extends (...args: any[]) => any>(page: string, handler: T): T;
|
||||
/**
|
||||
*
|
||||
* @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 {};
|
||||
198
node_modules/next/dist/server/api-utils/index.js
generated
vendored
Normal file
198
node_modules/next/dist/server/api-utils/index.js
generated
vendored
Normal file
@ -0,0 +1,198 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
ApiError: null,
|
||||
COOKIE_NAME_PRERENDER_BYPASS: null,
|
||||
COOKIE_NAME_PRERENDER_DATA: null,
|
||||
RESPONSE_LIMIT_DEFAULT: null,
|
||||
SYMBOL_CLEARED_COOKIES: null,
|
||||
SYMBOL_PREVIEW_DATA: null,
|
||||
checkIsOnDemandRevalidate: null,
|
||||
clearPreviewData: null,
|
||||
redirect: null,
|
||||
sendError: null,
|
||||
sendStatusCode: null,
|
||||
setLazyProp: null,
|
||||
wrapApiHandler: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
ApiError: function() {
|
||||
return ApiError;
|
||||
},
|
||||
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_CLEARED_COOKIES: function() {
|
||||
return SYMBOL_CLEARED_COOKIES;
|
||||
},
|
||||
SYMBOL_PREVIEW_DATA: function() {
|
||||
return SYMBOL_PREVIEW_DATA;
|
||||
},
|
||||
checkIsOnDemandRevalidate: function() {
|
||||
return checkIsOnDemandRevalidate;
|
||||
},
|
||||
clearPreviewData: function() {
|
||||
return clearPreviewData;
|
||||
},
|
||||
redirect: function() {
|
||||
return redirect;
|
||||
},
|
||||
sendError: function() {
|
||||
return sendError;
|
||||
},
|
||||
sendStatusCode: function() {
|
||||
return sendStatusCode;
|
||||
},
|
||||
setLazyProp: function() {
|
||||
return setLazyProp;
|
||||
},
|
||||
wrapApiHandler: function() {
|
||||
return wrapApiHandler;
|
||||
}
|
||||
});
|
||||
const _headers = require("../web/spec-extension/adapters/headers");
|
||||
const _constants = require("../../lib/constants");
|
||||
const _tracer = require("../lib/trace/tracer");
|
||||
const _constants1 = require("../lib/trace/constants");
|
||||
function wrapApiHandler(page, handler) {
|
||||
return (...args)=>{
|
||||
var _getTracer_getRootSpanAttributes;
|
||||
(_getTracer_getRootSpanAttributes = (0, _tracer.getTracer)().getRootSpanAttributes()) == null ? void 0 : _getTracer_getRootSpanAttributes.set("next.route", page);
|
||||
// Call API route method
|
||||
return (0, _tracer.getTracer)().trace(_constants1.NodeSpan.runHandler, {
|
||||
spanName: `executing api route (pages) ${page}`
|
||||
}, ()=>handler(...args));
|
||||
};
|
||||
}
|
||||
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
1
node_modules/next/dist/server/api-utils/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/api-utils/index.ts"],"names":["ApiError","COOKIE_NAME_PRERENDER_BYPASS","COOKIE_NAME_PRERENDER_DATA","RESPONSE_LIMIT_DEFAULT","SYMBOL_CLEARED_COOKIES","SYMBOL_PREVIEW_DATA","checkIsOnDemandRevalidate","clearPreviewData","redirect","sendError","sendStatusCode","setLazyProp","wrapApiHandler","page","handler","args","getTracer","getRootSpanAttributes","set","trace","NodeSpan","runHandler","spanName","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;IAkKaA,QAAQ;eAARA;;IAjEAC,4BAA4B;eAA5BA;;IACAC,0BAA0B;eAA1BA;;IAEAC,sBAAsB;eAAtBA;;IAGAC,sBAAsB;eAAtBA;;IADAC,mBAAmB;eAAnBA;;IAxBGC,yBAAyB;eAAzBA;;IA2BAC,gBAAgB;eAAhBA;;IA/CAC,QAAQ;eAARA;;IAuHAC,SAAS;eAATA;;IArIAC,cAAc;eAAdA;;IAyJAC,WAAW;eAAXA;;IA/KAC,cAAc;eAAdA;;;yBAjBe;2BAIxB;wBACmB;4BACD;AAWlB,SAASA,eACdC,IAAY,EACZC,OAAU;IAEV,OAAQ,CAAC,GAAGC;YACVC;SAAAA,mCAAAA,IAAAA,iBAAS,IAAGC,qBAAqB,uBAAjCD,iCAAqCE,GAAG,CAAC,cAAcL;QACvD,wBAAwB;QACxB,OAAOG,IAAAA,iBAAS,IAAGG,KAAK,CACtBC,oBAAQ,CAACC,UAAU,EACnB;YACEC,UAAU,CAAC,4BAA4B,EAAET,KAAK,CAAC;QACjD,GACA,IAAMC,WAAWC;IAErB;AACF;AAOO,SAASL,eACda,GAAoB,EACpBC,UAAkB;IAElBD,IAAIC,UAAU,GAAGA;IACjB,OAAOD;AACT;AAQO,SAASf,SACde,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,SAASjB,0BACd0B,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,MAAMxC,+BAA+B,CAAC,kBAAkB,CAAC;AACzD,MAAMC,6BAA6B,CAAC,mBAAmB,CAAC;AAExD,MAAMC,yBAAyB,IAAI,OAAO;AAE1C,MAAME,sBAAsBuC,OAAO1C;AACnC,MAAME,yBAAyBwC,OAAO3C;AAEtC,SAASM,iBACdgB,GAAuB,EACvBsB,UAEI,CAAC,CAAC;IAEN,IAAIzC,0BAA0BmB,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,UAAU7C,8BAA8B,IAAI;YAC1C,2DAA2D;YAC3D,oDAAoD;YACpD,wEAAwE;YACxEoD,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,UAAU5C,4BAA4B,IAAI;YACxC,2DAA2D;YAC3D,oDAAoD;YACpD,wEAAwE;YACxEmD,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,KAAKnB,wBAAwB;QACjD6D,OAAO;QACPC,YAAY;IACd;IACA,OAAO3C;AACT;AAKO,MAAMvB,iBAAiB2B;IAG5BwC,YAAY3C,UAAkB,EAAE4C,OAAe,CAAE;QAC/C,KAAK,CAACA;QACN,IAAI,CAAC5C,UAAU,GAAGA;IACpB;AACF;AAQO,SAASf,UACdc,GAAoB,EACpBC,UAAkB,EAClB4C,OAAe;IAEf7C,IAAIC,UAAU,GAAGA;IACjBD,IAAI8C,aAAa,GAAGD;IACpB7C,IAAIQ,GAAG,CAACqC;AACV;AAYO,SAASzD,YACd,EAAEqB,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;QACA/C,KAAK,CAAC+C;YACJF,OAAOC,cAAc,CAAChC,KAAKsC,MAAM;gBAAE,GAAGI,SAAS;gBAAET;YAAM;QACzD;IACF;AACF"}
|
||||
21
node_modules/next/dist/server/api-utils/node/api-resolver.d.ts
generated
vendored
Normal file
21
node_modules/next/dist/server/api-utils/node/api-resolver.d.ts
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/// <reference types="node" />
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import type { __ApiPreviewProps } from '../.';
|
||||
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;
|
||||
multiZoneDraftMode?: boolean;
|
||||
};
|
||||
export declare function apiResolver(req: IncomingMessage, res: ServerResponse, query: any, resolverModule: any, apiContext: ApiContext, propagateError: boolean, dev?: boolean, page?: string): Promise<void>;
|
||||
export {};
|
||||
330
node_modules/next/dist/server/api-utils/node/api-resolver.js
generated
vendored
Normal file
330
node_modules/next/dist/server/api-utils/node/api-resolver.js
generated
vendored
Normal file
@ -0,0 +1,330 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "apiResolver", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return apiResolver;
|
||||
}
|
||||
});
|
||||
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 _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 _constants = require("../../../lib/constants");
|
||||
const _trygetpreviewdata = require("./try-get-preview-data");
|
||||
const _parsebody = require("./parse-body");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
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 = {
|
||||
[_constants.PRERENDER_REVALIDATE_HEADER]: context.previewModeId,
|
||||
...opts.unstable_onlyGenerated ? {
|
||||
[_constants.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;
|
||||
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", ()=>(0, _trygetpreviewdata.tryGetPreviewData)(req, res, apiContext, !!apiContext.multiZoneDraftMode));
|
||||
// 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 (0, _parsebody.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);
|
||||
}
|
||||
const apiRouteResult = await 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=api-resolver.js.map
|
||||
1
node_modules/next/dist/server/api-utils/node/api-resolver.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/api-utils/node/api-resolver.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
node_modules/next/dist/server/api-utils/node/parse-body.d.ts
generated
vendored
Normal file
8
node_modules/next/dist/server/api-utils/node/parse-body.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/// <reference types="node" />
|
||||
import type { IncomingMessage } from 'http';
|
||||
import type { SizeLimit } from 'next/types';
|
||||
/**
|
||||
* Parse incoming message like `json` or `urlencoded`
|
||||
* @param req request object
|
||||
*/
|
||||
export declare function parseBody(req: IncomingMessage, limit: SizeLimit): Promise<any>;
|
||||
67
node_modules/next/dist/server/api-utils/node/parse-body.js
generated
vendored
Normal file
67
node_modules/next/dist/server/api-utils/node/parse-body.js
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "parseBody", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return parseBody;
|
||||
}
|
||||
});
|
||||
const _contenttype = require("next/dist/compiled/content-type");
|
||||
const _iserror = /*#__PURE__*/ _interop_require_default(require("../../../lib/is-error"));
|
||||
const _index = require("../index");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parse-body.js.map
|
||||
1
node_modules/next/dist/server/api-utils/node/parse-body.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/api-utils/node/parse-body.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/server/api-utils/node/parse-body.ts"],"names":["parseBody","parseJson","str","length","JSON","parse","e","ApiError","req","limit","contentType","headers","type","parameters","encoding","charset","buffer","getRawBody","require","isError","body","toString","qs","decode"],"mappings":";;;;+BA4BsBA;;;eAAAA;;;6BAzBA;gEACF;uBACK;;;;;;AAEzB;;;CAGC,GACD,SAASC,UAAUC,GAAW;IAC5B,IAAIA,IAAIC,MAAM,KAAK,GAAG;QACpB,qEAAqE;QACrE,OAAO,CAAC;IACV;IAEA,IAAI;QACF,OAAOC,KAAKC,KAAK,CAACH;IACpB,EAAE,OAAOI,GAAG;QACV,MAAM,IAAIC,eAAQ,CAAC,KAAK;IAC1B;AACF;AAMO,eAAeP,UACpBQ,GAAoB,EACpBC,KAAgB;IAEhB,IAAIC;IACJ,IAAI;QACFA,cAAcL,IAAAA,kBAAK,EAACG,IAAIG,OAAO,CAAC,eAAe,IAAI;IACrD,EAAE,OAAM;QACND,cAAcL,IAAAA,kBAAK,EAAC;IACtB;IACA,MAAM,EAAEO,IAAI,EAAEC,UAAU,EAAE,GAAGH;IAC7B,MAAMI,WAAWD,WAAWE,OAAO,IAAI;IAEvC,IAAIC;IAEJ,IAAI;QACF,MAAMC,aACJC,QAAQ;QACVF,SAAS,MAAMC,WAAWT,KAAK;YAAEM;YAAUL;QAAM;IACnD,EAAE,OAAOH,GAAG;QACV,IAAIa,IAAAA,gBAAO,EAACb,MAAMA,EAAEM,IAAI,KAAK,oBAAoB;YAC/C,MAAM,IAAIL,eAAQ,CAAC,KAAK,CAAC,cAAc,EAAEE,MAAM,MAAM,CAAC;QACxD,OAAO;YACL,MAAM,IAAIF,eAAQ,CAAC,KAAK;QAC1B;IACF;IAEA,MAAMa,OAAOJ,OAAOK,QAAQ;IAE5B,IAAIT,SAAS,sBAAsBA,SAAS,uBAAuB;QACjE,OAAOX,UAAUmB;IACnB,OAAO,IAAIR,SAAS,qCAAqC;QACvD,MAAMU,KAAKJ,QAAQ;QACnB,OAAOI,GAAGC,MAAM,CAACH;IACnB,OAAO;QACL,OAAOA;IACT;AACF"}
|
||||
6
node_modules/next/dist/server/api-utils/node/try-get-preview-data.d.ts
generated
vendored
Normal file
6
node_modules/next/dist/server/api-utils/node/try-get-preview-data.d.ts
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/// <reference types="node" />
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import type { __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, multiZoneDraftMode: boolean): PreviewData;
|
||||
86
node_modules/next/dist/server/api-utils/node/try-get-preview-data.js
generated
vendored
Normal file
86
node_modules/next/dist/server/api-utils/node/try-get-preview-data.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "tryGetPreviewData", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return tryGetPreviewData;
|
||||
}
|
||||
});
|
||||
const _ = require("../.");
|
||||
const _index = require("../index");
|
||||
const _cookies = require("../../web/spec-extension/cookies");
|
||||
const _headers = require("../../web/spec-extension/adapters/headers");
|
||||
function tryGetPreviewData(req, res, options, multiZoneDraftMode) {
|
||||
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) {
|
||||
if (!multiZoneDraftMode) {
|
||||
(0, _index.clearPreviewData)(res);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Case: preview session is for an old build.
|
||||
if (previewModeId !== options.previewModeId) {
|
||||
if (!multiZoneDraftMode) {
|
||||
(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;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=try-get-preview-data.js.map
|
||||
1
node_modules/next/dist/server/api-utils/node/try-get-preview-data.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/api-utils/node/try-get-preview-data.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/server/api-utils/node/try-get-preview-data.ts"],"names":["tryGetPreviewData","req","res","options","multiZoneDraftMode","cookies","checkIsOnDemandRevalidate","isOnDemandRevalidate","SYMBOL_PREVIEW_DATA","headers","HeadersAdapter","from","RequestCookies","previewModeId","get","COOKIE_NAME_PRERENDER_BYPASS","value","tokenPreviewData","COOKIE_NAME_PRERENDER_DATA","data","Object","defineProperty","enumerable","clearPreviewData","encryptedPreviewData","jsonwebtoken","require","verify","previewModeSigningKey","decryptWithSecret","decryptedPreviewData","Buffer","previewModeEncryptionKey","JSON","parse"],"mappings":";;;;+BAgBgBA;;;eAAAA;;;kBAd0B;uBAUnC;yBACwB;yBACA;AAExB,SAASA,kBACdC,GAAgD,EAChDC,GAAsC,EACtCC,OAA0B,EAC1BC,kBAA2B;QAiBLC,cACGA;IAhBzB,0DAA0D;IAC1D,cAAc;IACd,IAAIF,WAAWG,IAAAA,2BAAyB,EAACL,KAAKE,SAASI,oBAAoB,EAAE;QAC3E,OAAO;IACT;IAEA,sCAAsC;IACtC,iDAAiD;IACjD,IAAIC,0BAAmB,IAAIP,KAAK;QAC9B,OAAO,AAACA,GAAW,CAACO,0BAAmB,CAAC;IAC1C;IAEA,MAAMC,UAAUC,uBAAc,CAACC,IAAI,CAACV,IAAIQ,OAAO;IAC/C,MAAMJ,UAAU,IAAIO,uBAAc,CAACH;IAEnC,MAAMI,iBAAgBR,eAAAA,QAAQS,GAAG,CAACC,mCAA4B,sBAAxCV,aAA2CW,KAAK;IACtE,MAAMC,oBAAmBZ,gBAAAA,QAAQS,GAAG,CAACI,iCAA0B,sBAAtCb,cAAyCW,KAAK;IAEvE,2DAA2D;IAC3D,IACEH,iBACA,CAACI,oBACDJ,kBAAkBV,QAAQU,aAAa,EACvC;QACA,yCAAyC;QACzC,4CAA4C;QAC5C,4CAA4C;QAC5C,MAAMM,OAAO,CAAC;QACdC,OAAOC,cAAc,CAACpB,KAAKO,0BAAmB,EAAE;YAC9CQ,OAAOG;YACPG,YAAY;QACd;QACA,OAAOH;IACT;IAEA,+BAA+B;IAC/B,IAAI,CAACN,iBAAiB,CAACI,kBAAkB;QACvC,OAAO;IACT;IAEA,8CAA8C;IAC9C,IAAI,CAACJ,iBAAiB,CAACI,kBAAkB;QACvC,IAAI,CAACb,oBAAoB;YACvBmB,IAAAA,uBAAgB,EAACrB;QACnB;QACA,OAAO;IACT;IAEA,6CAA6C;IAC7C,IAAIW,kBAAkBV,QAAQU,aAAa,EAAE;QAC3C,IAAI,CAACT,oBAAoB;YACvBmB,IAAAA,uBAAgB,EAACrB;QACnB;QACA,OAAO;IACT;IAEA,IAAIsB;IAGJ,IAAI;QACF,MAAMC,eACJC,QAAQ;QACVF,uBAAuBC,aAAaE,MAAM,CACxCV,kBACAd,QAAQyB,qBAAqB;IAEjC,EAAE,OAAM;QACN,aAAa;QACbL,IAAAA,uBAAgB,EAACrB;QACjB,OAAO;IACT;IAEA,MAAM,EAAE2B,iBAAiB,EAAE,GACzBH,QAAQ;IACV,MAAMI,uBAAuBD,kBAC3BE,OAAOpB,IAAI,CAACR,QAAQ6B,wBAAwB,GAC5CR,qBAAqBL,IAAI;IAG3B,IAAI;QACF,qCAAqC;QACrC,MAAMA,OAAOc,KAAKC,KAAK,CAACJ;QACxB,eAAe;QACfV,OAAOC,cAAc,CAACpB,KAAKO,0BAAmB,EAAE;YAC9CQ,OAAOG;YACPG,YAAY;QACd;QACA,OAAOH;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
||||
1
node_modules/next/dist/server/api-utils/web.d.ts
generated
vendored
Normal file
1
node_modules/next/dist/server/api-utils/web.d.ts
generated
vendored
Normal 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
17
node_modules/next/dist/server/api-utils/web.js
generated
vendored
Normal 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
1
node_modules/next/dist/server/api-utils/web.js.map
generated
vendored
Normal 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"}
|
||||
34
node_modules/next/dist/server/app-render/action-handler.d.ts
generated
vendored
Normal file
34
node_modules/next/dist/server/app-render/action-handler.d.ts
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/// <reference types="node" />
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import type { SizeLimit } from '../../../types';
|
||||
import type { RequestStore } from '../../client/components/request-async-storage.external';
|
||||
import type { AppRenderContext, GenerateFlight } from './app-render';
|
||||
import type { AppPageModule } from '../../server/future/route-modules/app-page/module';
|
||||
import RenderResult from '../render-result';
|
||||
import type { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external';
|
||||
type ServerModuleMap = Record<string, {
|
||||
id: string;
|
||||
chunks: string[];
|
||||
name: string;
|
||||
} | undefined>;
|
||||
export declare function handleAction({ req, res, ComponentMod, serverModuleMap, generateFlight, staticGenerationStore, requestStore, serverActions, ctx, }: {
|
||||
req: IncomingMessage;
|
||||
res: ServerResponse;
|
||||
ComponentMod: AppPageModule;
|
||||
serverModuleMap: ServerModuleMap;
|
||||
generateFlight: GenerateFlight;
|
||||
staticGenerationStore: StaticGenerationStore;
|
||||
requestStore: RequestStore;
|
||||
serverActions?: {
|
||||
bodySizeLimit?: SizeLimit;
|
||||
allowedOrigins?: string[];
|
||||
};
|
||||
ctx: AppRenderContext;
|
||||
}): Promise<undefined | {
|
||||
type: 'not-found';
|
||||
} | {
|
||||
type: 'done';
|
||||
result: RenderResult | undefined;
|
||||
formState?: any;
|
||||
}>;
|
||||
export {};
|
||||
618
node_modules/next/dist/server/app-render/action-handler.js
generated
vendored
Normal file
618
node_modules/next/dist/server/app-render/action-handler.js
generated
vendored
Normal file
@ -0,0 +1,618 @@
|
||||
"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");
|
||||
const _serveractionrequestmeta = require("../lib/server-action-request-meta");
|
||||
const _csrfprotection = require("./csrf-protection");
|
||||
const _log = require("../../build/output/log");
|
||||
const _cookies = require("../web/spec-extension/cookies");
|
||||
const _headers = require("../web/spec-extension/adapters/headers");
|
||||
const _utils1 = require("../web/utils");
|
||||
const _actionutils = require("./action-utils");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
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 = new _cookies.RequestCookies(_headers.HeadersAdapter.from(requestHeaders));
|
||||
// Get response headers and cookies
|
||||
const responseHeaders = res.getHeaders();
|
||||
const responseCookies = new _cookies.ResponseCookies((0, _utils1.fromNodeOutgoingHttpHeaders)(responseHeaders));
|
||||
// Merge request and response headers
|
||||
const mergedHeaders = (0, _utils.filterReqHeaders)({
|
||||
...nodeHeadersToRecord(requestHeaders),
|
||||
...nodeHeadersToRecord(responseHeaders)
|
||||
}, _utils.actionsForbiddenHeaders);
|
||||
// Merge cookies into requestCookies, so responseCookies always take precedence
|
||||
// and overwrite/delete those from requestCookies.
|
||||
responseCookies.getAll().forEach((cookie)=>{
|
||||
if (typeof cookie.value === "undefined") {
|
||||
requestCookies.delete(cookie.name);
|
||||
} else {
|
||||
requestCookies.set(cookie);
|
||||
}
|
||||
});
|
||||
// Update the 'cookie' header with the merged cookies
|
||||
mergedHeaders["cookie"] = requestCookies.toString();
|
||||
// Remove headers that should not be forwarded
|
||||
delete mergedHeaders["transfer-encoding"];
|
||||
return new Headers(mergedHeaders);
|
||||
}
|
||||
async function addRevalidationHeader(res, { staticGenerationStore, requestStore }) {
|
||||
var _staticGenerationStore_incrementalCache, _staticGenerationStore_revalidatedTags;
|
||||
await Promise.all([
|
||||
(_staticGenerationStore_incrementalCache = staticGenerationStore.incrementalCache) == null ? void 0 : _staticGenerationStore_incrementalCache.revalidateTag(staticGenerationStore.revalidatedTags || []),
|
||||
...Object.values(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
|
||||
]));
|
||||
}
|
||||
/**
|
||||
* Forwards a server action request to a separate worker. Used when the requested action is not available in the current worker.
|
||||
*/ async function createForwardedActionResponse(req, res, host, workerPathname, basePath, staticGenerationStore) {
|
||||
var _staticGenerationStore_incrementalCache;
|
||||
if (!host) {
|
||||
throw new Error("Invariant: Missing `host` header from a forwarded Server Actions request.");
|
||||
}
|
||||
const forwardedHeaders = getForwardedHeaders(req, res);
|
||||
// indicate that this action request was forwarded from another worker
|
||||
// we use this to skip rendering the flight tree so that we don't update the UI
|
||||
// with the response from the forwarded worker
|
||||
forwardedHeaders.set("x-action-forwarded", "1");
|
||||
const proto = ((_staticGenerationStore_incrementalCache = staticGenerationStore.incrementalCache) == null ? void 0 : _staticGenerationStore_incrementalCache.requestProtocol) || "https";
|
||||
// For standalone or the serverful mode, use the internal origin directly
|
||||
// other than the host headers from the request.
|
||||
const origin = process.env.__NEXT_PRIVATE_ORIGIN || `${proto}://${host.value}`;
|
||||
const fetchUrl = new URL(`${origin}${basePath}${workerPathname}`);
|
||||
try {
|
||||
let readableStream;
|
||||
if (process.env.NEXT_RUNTIME === "edge") {
|
||||
const webRequest = req;
|
||||
if (!webRequest.body) {
|
||||
throw new Error("invariant: Missing request body.");
|
||||
}
|
||||
readableStream = webRequest.body;
|
||||
} else {
|
||||
// Convert the Node.js readable stream to a Web Stream.
|
||||
readableStream = new ReadableStream({
|
||||
start (controller) {
|
||||
req.on("data", (chunk)=>{
|
||||
controller.enqueue(new Uint8Array(chunk));
|
||||
});
|
||||
req.on("end", ()=>{
|
||||
controller.close();
|
||||
});
|
||||
req.on("error", (err)=>{
|
||||
controller.error(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// Forward the request to the new worker
|
||||
const response = await fetch(fetchUrl, {
|
||||
method: "POST",
|
||||
body: readableStream,
|
||||
duplex: "half",
|
||||
headers: forwardedHeaders,
|
||||
next: {
|
||||
// @ts-ignore
|
||||
internal: 1
|
||||
}
|
||||
});
|
||||
if (response.headers.get("content-type") === _approuterheaders.RSC_CONTENT_TYPE_HEADER) {
|
||||
// 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);
|
||||
} else {
|
||||
var // Since we aren't consuming the response body, we cancel it to avoid memory leaks
|
||||
_response_body;
|
||||
(_response_body = response.body) == null ? void 0 : _response_body.cancel();
|
||||
}
|
||||
} catch (err) {
|
||||
// we couldn't stream the forwarded response, so we'll just do a normal redirect
|
||||
console.error(`failed to forward action response`, err);
|
||||
}
|
||||
}
|
||||
async function createRedirectRenderResult(req, res, originalHost, redirectUrl, basePath, staticGenerationStore) {
|
||||
res.setHeader("x-action-redirect", redirectUrl);
|
||||
// If we're redirecting to another route of this Next.js application, we'll
|
||||
// try to stream the response from the other worker path. When that works,
|
||||
// we can save an extra roundtrip and avoid a full page reload.
|
||||
// When the redirect URL starts with a `/`, or to the same host as application,
|
||||
// we treat it as an app-relative redirect.
|
||||
const parsedRedirectUrl = new URL(redirectUrl, "http://n");
|
||||
const isAppRelativeRedirect = redirectUrl.startsWith("/") || originalHost && originalHost.value === parsedRedirectUrl.host;
|
||||
if (isAppRelativeRedirect) {
|
||||
var _staticGenerationStore_incrementalCache;
|
||||
if (!originalHost) {
|
||||
throw new Error("Invariant: Missing `host` header from a forwarded Server Actions request.");
|
||||
}
|
||||
const forwardedHeaders = getForwardedHeaders(req, res);
|
||||
forwardedHeaders.set(_approuterheaders.RSC_HEADER, "1");
|
||||
const proto = ((_staticGenerationStore_incrementalCache = staticGenerationStore.incrementalCache) == null ? void 0 : _staticGenerationStore_incrementalCache.requestProtocol) || "https";
|
||||
// For standalone or the serverful mode, use the internal origin directly
|
||||
// other than the host headers from the request.
|
||||
const origin = process.env.__NEXT_PRIVATE_ORIGIN || `${proto}://${originalHost.value}`;
|
||||
const fetchUrl = new URL(`${origin}${basePath}${parsedRedirectUrl.pathname}${parsedRedirectUrl.search}`);
|
||||
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
|
||||
forwardedHeaders.delete("next-router-state-tree");
|
||||
try {
|
||||
const response = await fetch(fetchUrl, {
|
||||
method: "GET",
|
||||
headers: forwardedHeaders,
|
||||
next: {
|
||||
// @ts-ignore
|
||||
internal: 1
|
||||
}
|
||||
});
|
||||
if (response.headers.get("content-type") === _approuterheaders.RSC_CONTENT_TYPE_HEADER) {
|
||||
// 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);
|
||||
} else {
|
||||
var // Since we aren't consuming the response body, we cancel it to avoid memory leaks
|
||||
_response_body;
|
||||
(_response_body = response.body) == null ? void 0 : _response_body.cancel();
|
||||
}
|
||||
} 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 _renderresult.default.fromStatic("{}");
|
||||
}
|
||||
var HostType;
|
||||
/**
|
||||
* Ensures the value of the header can't create long logs.
|
||||
*/ function limitUntrustedHeaderValueForLogs(value) {
|
||||
return value.length > 100 ? value.slice(0, 100) + "..." : value;
|
||||
}
|
||||
async function handleAction({ req, res, ComponentMod, serverModuleMap, generateFlight, staticGenerationStore, requestStore, serverActions, ctx }) {
|
||||
const contentType = req.headers["content-type"];
|
||||
const { serverActionsManifest, page } = ctx.renderOpts;
|
||||
const { actionId, isURLEncodedAction, isMultipartAction, isFetchAction, isServerAction } = (0, _serveractionrequestmeta.getServerActionRequestMetadata)(req);
|
||||
// If it's not a Server Action, skip handling.
|
||||
if (!isServerAction) {
|
||||
return;
|
||||
}
|
||||
if (staticGenerationStore.isStaticGeneration) {
|
||||
throw new Error("Invariant: server actions can't be handled during static rendering");
|
||||
}
|
||||
// When running actions the default is no-store, you can still `cache: 'force-cache'`
|
||||
staticGenerationStore.fetchCache = "default-no-store";
|
||||
const originDomain = typeof req.headers["origin"] === "string" ? new URL(req.headers["origin"]).host : undefined;
|
||||
const forwardedHostHeader = req.headers["x-forwarded-host"];
|
||||
const hostHeader = req.headers["host"];
|
||||
const host = forwardedHostHeader ? {
|
||||
type: "x-forwarded-host",
|
||||
value: forwardedHostHeader
|
||||
} : hostHeader ? {
|
||||
type: "host",
|
||||
value: hostHeader
|
||||
} : undefined;
|
||||
let warning = undefined;
|
||||
function warnBadServerActionRequest() {
|
||||
if (warning) {
|
||||
(0, _log.warn)(warning);
|
||||
}
|
||||
}
|
||||
// This is to prevent CSRF attacks. If `x-forwarded-host` is set, we need to
|
||||
// ensure that the request is coming from the same host.
|
||||
if (!originDomain) {
|
||||
// This might be an old browser that doesn't send `host` header. We ignore
|
||||
// this case.
|
||||
warning = "Missing `origin` header from a forwarded Server Actions request.";
|
||||
} else if (!host || originDomain !== host.value) {
|
||||
// If the customer sets a list of allowed origins, we'll allow the request.
|
||||
// These are considered safe but might be different from forwarded host set
|
||||
// by the infra (i.e. reverse proxies).
|
||||
if ((0, _csrfprotection.isCsrfOriginAllowed)(originDomain, serverActions == null ? void 0 : serverActions.allowedOrigins)) {
|
||||
// Ignore it
|
||||
} else {
|
||||
if (host) {
|
||||
// This seems to be an CSRF attack. We should not proceed the action.
|
||||
console.error(`\`${host.type}\` header with value \`${limitUntrustedHeaderValueForLogs(host.value)}\` does not match \`origin\` header with value \`${limitUntrustedHeaderValueForLogs(originDomain)}\` from a forwarded Server Actions request. Aborting the action.`);
|
||||
} else {
|
||||
// This is an attack. We should not proceed the action.
|
||||
console.error(`\`x-forwarded-host\` or \`host\` headers are not provided. One of these is needed to compare the \`origin\` header from a forwarded Server Actions request. Aborting the action.`);
|
||||
}
|
||||
const error = new Error("Invalid Server Actions request.");
|
||||
if (isFetchAction) {
|
||||
var _staticGenerationStore_incrementalCache;
|
||||
res.statusCode = 500;
|
||||
await Promise.all([
|
||||
(_staticGenerationStore_incrementalCache = staticGenerationStore.incrementalCache) == null ? void 0 : _staticGenerationStore_incrementalCache.revalidateTag(staticGenerationStore.revalidatedTags || []),
|
||||
...Object.values(staticGenerationStore.pendingRevalidates || {})
|
||||
]);
|
||||
const promise = Promise.reject(error);
|
||||
try {
|
||||
// we need to await the promise to trigger the rejection early
|
||||
// so that it's already handled by the time we call
|
||||
// the RSC runtime. Otherwise, it will throw an unhandled
|
||||
// promise rejection error in the renderer.
|
||||
await promise;
|
||||
} catch {
|
||||
// swallow error, it's gonna be handled on the client
|
||||
}
|
||||
return {
|
||||
type: "done",
|
||||
result: await generateFlight(ctx, {
|
||||
actionResult: promise,
|
||||
// if the page was not revalidated, we can skip the rendering the flight tree
|
||||
skipFlight: !staticGenerationStore.pathWasRevalidated
|
||||
})
|
||||
};
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
// ensure we avoid caching server actions unexpectedly
|
||||
res.setHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
|
||||
let bound = [];
|
||||
const { actionAsyncStorage } = ComponentMod;
|
||||
let actionResult;
|
||||
let formState;
|
||||
let actionModId;
|
||||
const actionWasForwarded = Boolean(req.headers["x-action-forwarded"]);
|
||||
if (actionId) {
|
||||
const forwardedWorker = (0, _actionutils.selectWorkerForForwarding)(actionId, page, serverActionsManifest);
|
||||
// If forwardedWorker is truthy, it means there isn't a worker for the action
|
||||
// in the current handler, so we forward the request to a worker that has the action.
|
||||
if (forwardedWorker) {
|
||||
return {
|
||||
type: "done",
|
||||
result: await createForwardedActionResponse(req, res, host, forwardedWorker, ctx.renderOpts.basePath, staticGenerationStore)
|
||||
};
|
||||
}
|
||||
}
|
||||
try {
|
||||
await actionAsyncStorage.run({
|
||||
isAction: true
|
||||
}, async ()=>{
|
||||
if (process.env.NEXT_RUNTIME === "edge") {
|
||||
// Use react-server-dom-webpack/server.edge
|
||||
const { decodeReply, decodeAction, decodeFormState } = 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);
|
||||
if (typeof action === "function") {
|
||||
// Only warn if it's a server action, otherwise skip for other post requests
|
||||
warnBadServerActionRequest();
|
||||
const actionReturnedState = await action();
|
||||
formState = decodeFormState(actionReturnedState, formData);
|
||||
}
|
||||
// Skip the fetch path
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
actionModId = getActionModIdOrError(actionId, serverModuleMap);
|
||||
} catch (err) {
|
||||
if (actionId !== null) {
|
||||
console.error(err);
|
||||
}
|
||||
return {
|
||||
type: "not-found"
|
||||
};
|
||||
}
|
||||
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, decodeFormState } = require(`./react-server.node`);
|
||||
if (isMultipartAction) {
|
||||
if (isFetchAction) {
|
||||
const readableLimit = (serverActions == null ? void 0 : serverActions.bodySizeLimit) ?? "1 MB";
|
||||
const limit = require("next/dist/compiled/bytes").parse(readableLimit);
|
||||
const busboy = require("busboy");
|
||||
const bb = busboy({
|
||||
headers: req.headers,
|
||||
limits: {
|
||||
fieldSize: limit
|
||||
}
|
||||
});
|
||||
req.pipe(bb);
|
||||
bound = await decodeReplyFromBusboy(bb, serverModuleMap);
|
||||
} else {
|
||||
// Convert the Node.js readable stream to a Web Stream.
|
||||
const readableStream = new ReadableStream({
|
||||
start (controller) {
|
||||
req.on("data", (chunk)=>{
|
||||
controller.enqueue(new Uint8Array(chunk));
|
||||
});
|
||||
req.on("end", ()=>{
|
||||
controller.close();
|
||||
});
|
||||
req.on("error", (err)=>{
|
||||
controller.error(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
// React doesn't yet publish a busboy version of decodeAction
|
||||
// so we polyfill the parsing of FormData.
|
||||
const fakeRequest = new Request("http://localhost", {
|
||||
method: "POST",
|
||||
// @ts-expect-error
|
||||
headers: {
|
||||
"Content-Type": contentType
|
||||
},
|
||||
body: readableStream,
|
||||
duplex: "half"
|
||||
});
|
||||
const formData = await fakeRequest.formData();
|
||||
const action = await decodeAction(formData, serverModuleMap);
|
||||
if (typeof action === "function") {
|
||||
// Only warn if it's a server action, otherwise skip for other post requests
|
||||
warnBadServerActionRequest();
|
||||
const actionReturnedState = await action();
|
||||
formState = await decodeFormState(actionReturnedState, formData);
|
||||
}
|
||||
// Skip the fetch path
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
actionModId = getActionModIdOrError(actionId, serverModuleMap);
|
||||
} catch (err) {
|
||||
if (actionId !== null) {
|
||||
console.error(err);
|
||||
}
|
||||
return {
|
||||
type: "not-found"
|
||||
};
|
||||
}
|
||||
const chunks = [];
|
||||
for await (const chunk of req){
|
||||
chunks.push(Buffer.from(chunk));
|
||||
}
|
||||
const actionData = Buffer.concat(chunks).toString("utf-8");
|
||||
const readableLimit = (serverActions == null ? void 0 : serverActions.bodySizeLimit) ?? "1 MB";
|
||||
const limit = require("next/dist/compiled/bytes").parse(readableLimit);
|
||||
if (actionData.length > limit) {
|
||||
const { ApiError } = require("../api-utils");
|
||||
throw new ApiError(413, `Body exceeded ${readableLimit} limit.
|
||||
To configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit`);
|
||||
}
|
||||
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
|
||||
try {
|
||||
actionModId = actionModId ?? getActionModIdOrError(actionId, serverModuleMap);
|
||||
} catch (err) {
|
||||
if (actionId !== null) {
|
||||
console.error(err);
|
||||
}
|
||||
return {
|
||||
type: "not-found"
|
||||
};
|
||||
}
|
||||
const actionHandler = (await ComponentMod.__next_app__.require(actionModId))[// `actionId` must exist if we got here, as otherwise we would have thrown an error above
|
||||
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(ctx, {
|
||||
actionResult: Promise.resolve(returnVal),
|
||||
// if the page was not revalidated, or if the action was forwarded from another worker, we can skip the rendering the flight tree
|
||||
skipFlight: !staticGenerationStore.pathWasRevalidated || actionWasForwarded
|
||||
});
|
||||
}
|
||||
});
|
||||
return {
|
||||
type: "done",
|
||||
result: actionResult,
|
||||
formState
|
||||
};
|
||||
} catch (err) {
|
||||
if ((0, _redirect.isRedirectError)(err)) {
|
||||
const redirectUrl = (0, _redirect.getURLFromRedirectError)(err);
|
||||
const statusCode = (0, _redirect.getRedirectStatusCodeFromError)(err);
|
||||
await addRevalidationHeader(res, {
|
||||
staticGenerationStore,
|
||||
requestStore
|
||||
});
|
||||
// if it's a fetch action, we'll set the status code for logging/debugging purposes
|
||||
// but we won't set a Location header, as the redirect will be handled by the client router
|
||||
res.statusCode = statusCode;
|
||||
if (isFetchAction) {
|
||||
return {
|
||||
type: "done",
|
||||
result: await createRedirectRenderResult(req, res, host, redirectUrl, ctx.renderOpts.basePath, 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);
|
||||
return {
|
||||
type: "done",
|
||||
result: _renderresult.default.fromStatic("")
|
||||
};
|
||||
} else if ((0, _notfound.isNotFoundError)(err)) {
|
||||
res.statusCode = 404;
|
||||
await addRevalidationHeader(res, {
|
||||
staticGenerationStore,
|
||||
requestStore
|
||||
});
|
||||
if (isFetchAction) {
|
||||
const promise = Promise.reject(err);
|
||||
try {
|
||||
// we need to await the promise to trigger the rejection early
|
||||
// so that it's already handled by the time we call
|
||||
// the RSC runtime. Otherwise, it will throw an unhandled
|
||||
// promise rejection error in the renderer.
|
||||
await promise;
|
||||
} catch {
|
||||
// swallow error, it's gonna be handled on the client
|
||||
}
|
||||
return {
|
||||
type: "done",
|
||||
result: await generateFlight(ctx, {
|
||||
skipFlight: false,
|
||||
actionResult: promise,
|
||||
asNotFound: true
|
||||
})
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: "not-found"
|
||||
};
|
||||
}
|
||||
if (isFetchAction) {
|
||||
var _staticGenerationStore_incrementalCache1;
|
||||
res.statusCode = 500;
|
||||
await Promise.all([
|
||||
(_staticGenerationStore_incrementalCache1 = staticGenerationStore.incrementalCache) == null ? void 0 : _staticGenerationStore_incrementalCache1.revalidateTag(staticGenerationStore.revalidatedTags || []),
|
||||
...Object.values(staticGenerationStore.pendingRevalidates || {})
|
||||
]);
|
||||
const promise = Promise.reject(err);
|
||||
try {
|
||||
// we need to await the promise to trigger the rejection early
|
||||
// so that it's already handled by the time we call
|
||||
// the RSC runtime. Otherwise, it will throw an unhandled
|
||||
// promise rejection error in the renderer.
|
||||
await promise;
|
||||
} catch {
|
||||
// swallow error, it's gonna be handled on the client
|
||||
}
|
||||
return {
|
||||
type: "done",
|
||||
result: await generateFlight(ctx, {
|
||||
actionResult: promise,
|
||||
// if the page was not revalidated, or if the action was forwarded from another worker, we can skip the rendering the flight tree
|
||||
skipFlight: !staticGenerationStore.pathWasRevalidated || actionWasForwarded
|
||||
})
|
||||
};
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Attempts to find the module ID for the action from the module map. When this fails, it could be a deployment skew where
|
||||
* the action came from a different deployment. It could also simply be an invalid POST request that is not a server action.
|
||||
* In either case, we'll throw an error to be handled by the caller.
|
||||
*/ function getActionModIdOrError(actionId, serverModuleMap) {
|
||||
try {
|
||||
var _serverModuleMap_actionId;
|
||||
// if we're missing the action ID header, we can't do any further processing
|
||||
if (!actionId) {
|
||||
throw new Error("Invariant: Missing 'next-action' header.");
|
||||
}
|
||||
const actionModId = serverModuleMap == null ? void 0 : (_serverModuleMap_actionId = serverModuleMap[actionId]) == null ? void 0 : _serverModuleMap_actionId.id;
|
||||
if (!actionModId) {
|
||||
throw new Error("Invariant: Couldn't find action module ID from module map.");
|
||||
}
|
||||
return actionModId;
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to find Server Action "${actionId}". This request might be from an older or newer deployment. ${err instanceof Error ? `Original error: ${err.message}` : ""}`);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=action-handler.js.map
|
||||
1
node_modules/next/dist/server/app-render/action-handler.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/action-handler.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
10
node_modules/next/dist/server/app-render/action-utils.d.ts
generated
vendored
Normal file
10
node_modules/next/dist/server/app-render/action-utils.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import type { ActionManifest } from '../../build/webpack/plugins/flight-client-entry-plugin';
|
||||
export declare function createServerModuleMap({ serverActionsManifest, pageName, }: {
|
||||
serverActionsManifest: ActionManifest;
|
||||
pageName: string;
|
||||
}): {};
|
||||
/**
|
||||
* Checks if the requested action has a worker for the current page.
|
||||
* If not, it returns the first worker that has a handler for the action.
|
||||
*/
|
||||
export declare function selectWorkerForForwarding(actionId: string, pageName: string, serverActionsManifest: ActionManifest): string | undefined;
|
||||
65
node_modules/next/dist/server/app-render/action-utils.js
generated
vendored
Normal file
65
node_modules/next/dist/server/app-render/action-utils.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
createServerModuleMap: null,
|
||||
selectWorkerForForwarding: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
createServerModuleMap: function() {
|
||||
return createServerModuleMap;
|
||||
},
|
||||
selectWorkerForForwarding: function() {
|
||||
return selectWorkerForForwarding;
|
||||
}
|
||||
});
|
||||
const _apppaths = require("../../shared/lib/router/utils/app-paths");
|
||||
const _pathhasprefix = require("../../shared/lib/router/utils/path-has-prefix");
|
||||
const _removepathprefix = require("../../shared/lib/router/utils/remove-path-prefix");
|
||||
function createServerModuleMap({ serverActionsManifest, pageName }) {
|
||||
return new Proxy({}, {
|
||||
get: (_, id)=>{
|
||||
return {
|
||||
id: serverActionsManifest[process.env.NEXT_RUNTIME === "edge" ? "edge" : "node"][id].workers[normalizeWorkerPageName(pageName)],
|
||||
name: id,
|
||||
chunks: []
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
function selectWorkerForForwarding(actionId, pageName, serverActionsManifest) {
|
||||
var _serverActionsManifest__actionId;
|
||||
const workers = (_serverActionsManifest__actionId = serverActionsManifest[process.env.NEXT_RUNTIME === "edge" ? "edge" : "node"][actionId]) == null ? void 0 : _serverActionsManifest__actionId.workers;
|
||||
const workerName = normalizeWorkerPageName(pageName);
|
||||
// no workers, nothing to forward to
|
||||
if (!workers) return;
|
||||
// if there is a worker for this page, no need to forward it.
|
||||
if (workers[workerName]) {
|
||||
return;
|
||||
}
|
||||
// otherwise, grab the first worker that has a handler for this action id
|
||||
return denormalizeWorkerPageName(Object.keys(workers)[0]);
|
||||
}
|
||||
/**
|
||||
* The flight entry loader keys actions by bundlePath.
|
||||
* bundlePath corresponds with the relative path (including 'app') to the page entrypoint.
|
||||
*/ function normalizeWorkerPageName(pageName) {
|
||||
if ((0, _pathhasprefix.pathHasPrefix)(pageName, "app")) {
|
||||
return pageName;
|
||||
}
|
||||
return "app" + pageName;
|
||||
}
|
||||
/**
|
||||
* Converts a bundlePath (relative path to the entrypoint) to a routable page name
|
||||
*/ function denormalizeWorkerPageName(bundlePath) {
|
||||
return (0, _apppaths.normalizeAppPath)((0, _removepathprefix.removePathPrefix)(bundlePath, "app"));
|
||||
}
|
||||
|
||||
//# sourceMappingURL=action-utils.js.map
|
||||
1
node_modules/next/dist/server/app-render/action-utils.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/action-utils.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/action-utils.ts"],"names":["createServerModuleMap","selectWorkerForForwarding","serverActionsManifest","pageName","Proxy","get","_","id","process","env","NEXT_RUNTIME","workers","normalizeWorkerPageName","name","chunks","actionId","workerName","denormalizeWorkerPageName","Object","keys","pathHasPrefix","bundlePath","normalizeAppPath","removePathPrefix"],"mappings":";;;;;;;;;;;;;;;IASgBA,qBAAqB;eAArBA;;IA2BAC,yBAAyB;eAAzBA;;;0BAnCiB;+BACH;kCACG;AAM1B,SAASD,sBAAsB,EACpCE,qBAAqB,EACrBC,QAAQ,EAIT;IACC,OAAO,IAAIC,MACT,CAAC,GACD;QACEC,KAAK,CAACC,GAAGC;YACP,OAAO;gBACLA,IAAIL,qBAAqB,CACvBM,QAAQC,GAAG,CAACC,YAAY,KAAK,SAAS,SAAS,OAChD,CAACH,GAAG,CAACI,OAAO,CAACC,wBAAwBT,UAAU;gBAChDU,MAAMN;gBACNO,QAAQ,EAAE;YACZ;QACF;IACF;AAEJ;AAMO,SAASb,0BACdc,QAAgB,EAChBZ,QAAgB,EAChBD,qBAAqC;QAGnCA;IADF,MAAMS,WACJT,mCAAAA,qBAAqB,CACnBM,QAAQC,GAAG,CAACC,YAAY,KAAK,SAAS,SAAS,OAChD,CAACK,SAAS,qBAFXb,iCAEaS,OAAO;IACtB,MAAMK,aAAaJ,wBAAwBT;IAE3C,oCAAoC;IACpC,IAAI,CAACQ,SAAS;IAEd,6DAA6D;IAC7D,IAAIA,OAAO,CAACK,WAAW,EAAE;QACvB;IACF;IAEA,yEAAyE;IACzE,OAAOC,0BAA0BC,OAAOC,IAAI,CAACR,QAAQ,CAAC,EAAE;AAC1D;AAEA;;;CAGC,GACD,SAASC,wBAAwBT,QAAgB;IAC/C,IAAIiB,IAAAA,4BAAa,EAACjB,UAAU,QAAQ;QAClC,OAAOA;IACT;IAEA,OAAO,QAAQA;AACjB;AAEA;;CAEC,GACD,SAASc,0BAA0BI,UAAkB;IACnD,OAAOC,IAAAA,0BAAgB,EAACC,IAAAA,kCAAgB,EAACF,YAAY;AACvD"}
|
||||
52
node_modules/next/dist/server/app-render/app-render.d.ts
generated
vendored
Normal file
52
node_modules/next/dist/server/app-render/app-render.d.ts
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
/// <reference types="node" />
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import type { ActionResult, DynamicParamTypesShort, FlightRouterState, FlightSegmentPath, RenderOpts, Segment } from './types';
|
||||
import type { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external';
|
||||
import type { RequestStore } from '../../client/components/request-async-storage.external';
|
||||
import type { NextParsedUrlQuery } from '../request-meta';
|
||||
import type { AppPageModule } from '../future/route-modules/app-page/module';
|
||||
import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin';
|
||||
import type { Revalidate } from '../lib/revalidate';
|
||||
import RenderResult, { type AppPageRenderResultMetadata } from '../render-result';
|
||||
import { type ErrorHandler } from './create-error-handler';
|
||||
import type { DeepReadonly } from '../../shared/lib/deep-readonly';
|
||||
export type GetDynamicParamFromSegment = (segment: string) => {
|
||||
param: string;
|
||||
value: string | string[] | null;
|
||||
treeSegment: Segment;
|
||||
type: DynamicParamTypesShort;
|
||||
} | null;
|
||||
type AppRenderBaseContext = {
|
||||
staticGenerationStore: StaticGenerationStore;
|
||||
requestStore: RequestStore;
|
||||
componentMod: AppPageModule;
|
||||
renderOpts: RenderOpts;
|
||||
};
|
||||
export type GenerateFlight = typeof generateFlight;
|
||||
export type AppRenderContext = AppRenderBaseContext & {
|
||||
getDynamicParamFromSegment: GetDynamicParamFromSegment;
|
||||
query: NextParsedUrlQuery;
|
||||
isPrefetch: boolean;
|
||||
requestTimestamp: number;
|
||||
appUsingSizeAdjustment: boolean;
|
||||
flightRouterState?: FlightRouterState;
|
||||
requestId: string;
|
||||
defaultRevalidate: Revalidate;
|
||||
pagePath: string;
|
||||
clientReferenceManifest: DeepReadonly<ClientReferenceManifest>;
|
||||
assetPrefix: string;
|
||||
flightDataRendererErrorHandler: ErrorHandler;
|
||||
serverComponentsErrorHandler: ErrorHandler;
|
||||
isNotFoundPath: boolean;
|
||||
res: ServerResponse;
|
||||
};
|
||||
export type CreateSegmentPath = (child: FlightSegmentPath) => FlightSegmentPath;
|
||||
declare function generateFlight(ctx: AppRenderContext, options?: {
|
||||
actionResult: ActionResult;
|
||||
skipFlight: boolean;
|
||||
asNotFound?: boolean;
|
||||
}): Promise<RenderResult>;
|
||||
export type BinaryStreamOf<T> = ReadableStream<Uint8Array>;
|
||||
export type AppPageRender = (req: IncomingMessage, res: ServerResponse, pagePath: string, query: NextParsedUrlQuery, renderOpts: RenderOpts) => Promise<RenderResult<AppPageRenderResultMetadata>>;
|
||||
export declare const renderToHTMLOrFlight: AppPageRender;
|
||||
export {};
|
||||
977
node_modules/next/dist/server/app-render/app-render.js
generated
vendored
Normal file
977
node_modules/next/dist/server/app-render/app-render.js
generated
vendored
Normal file
@ -0,0 +1,977 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "renderToHTMLOrFlight", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return renderToHTMLOrFlight;
|
||||
}
|
||||
});
|
||||
const _jsxruntime = require("react/jsx-runtime");
|
||||
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
||||
const _renderresult = /*#__PURE__*/ _interop_require_default(require("../render-result"));
|
||||
const _nodewebstreamshelper = require("../stream-utils/node-web-streams-helper");
|
||||
const _matchsegments = require("../../client/components/match-segments");
|
||||
const _internalutils = require("../internal-utils");
|
||||
const _approuterheaders = require("../../client/components/app-router-headers");
|
||||
const _metadata = require("../../lib/metadata/metadata");
|
||||
const _requestasyncstoragewrapper = require("../async-storage/request-async-storage-wrapper");
|
||||
const _staticgenerationasyncstoragewrapper = require("../async-storage/static-generation-async-storage-wrapper");
|
||||
const _notfound = require("../../client/components/not-found");
|
||||
const _redirect = require("../../client/components/redirect");
|
||||
const _patchfetch = require("../lib/patch-fetch");
|
||||
const _constants = require("../lib/trace/constants");
|
||||
const _tracer = require("../lib/trace/tracer");
|
||||
const _flightrenderresult = require("./flight-render-result");
|
||||
const _createerrorhandler = require("./create-error-handler");
|
||||
const _getshortdynamicparamtype = require("./get-short-dynamic-param-type");
|
||||
const _getsegmentparam = require("./get-segment-param");
|
||||
const _getscriptnoncefromheader = require("./get-script-nonce-from-header");
|
||||
const _parseandvalidateflightrouterstate = require("./parse-and-validate-flight-router-state");
|
||||
const _validateurl = require("./validate-url");
|
||||
const _createflightrouterstatefromloadertree = require("./create-flight-router-state-from-loader-tree");
|
||||
const _actionhandler = require("./action-handler");
|
||||
const _bailouttocsr = require("../../shared/lib/lazy-dynamic/bailout-to-csr");
|
||||
const _log = require("../../build/output/log");
|
||||
const _requestcookies = require("../web/spec-extension/adapters/request-cookies");
|
||||
const _serverinsertedhtml = require("./server-inserted-html");
|
||||
const _requiredscripts = require("./required-scripts");
|
||||
const _addpathprefix = require("../../shared/lib/router/utils/add-path-prefix");
|
||||
const _makegetserverinsertedhtml = require("./make-get-server-inserted-html");
|
||||
const _walktreewithflightrouterstate = require("./walk-tree-with-flight-router-state");
|
||||
const _createcomponenttree = require("./create-component-tree");
|
||||
const _getassetquerystring = require("./get-asset-query-string");
|
||||
const _encryptionutils = require("./encryption-utils");
|
||||
const _staticrenderer = require("./static/static-renderer");
|
||||
const _hooksservercontext = require("../../client/components/hooks-server-context");
|
||||
const _useflightresponse = require("./use-flight-response");
|
||||
const _staticgenerationbailout = require("../../client/components/static-generation-bailout");
|
||||
const _interceptionroutes = require("../future/helpers/interception-routes");
|
||||
const _formatservererror = require("../../lib/format-server-error");
|
||||
const _dynamicrendering = require("./dynamic-rendering");
|
||||
const _clientcomponentrendererlogger = require("../client-component-renderer-logger");
|
||||
const _actionutils = require("./action-utils");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function createNotFoundLoaderTree(loaderTree) {
|
||||
// Align the segment with parallel-route-default in next-app-loader
|
||||
return [
|
||||
"",
|
||||
{},
|
||||
loaderTree[2]
|
||||
];
|
||||
}
|
||||
/* This method is important for intercepted routes to function:
|
||||
* when a route is intercepted, e.g. /blog/[slug], it will be rendered
|
||||
* with the layout of the previous page, e.g. /profile/[id]. The problem is
|
||||
* that the loader tree needs to know the dynamic param in order to render (id and slug in the example).
|
||||
* Normally they are read from the path but since we are intercepting the route, the path would not contain id,
|
||||
* so we need to read it from the router state.
|
||||
*/ function findDynamicParamFromRouterState(flightRouterState, segment) {
|
||||
if (!flightRouterState) {
|
||||
return null;
|
||||
}
|
||||
const treeSegment = flightRouterState[0];
|
||||
if ((0, _matchsegments.canSegmentBeOverridden)(segment, treeSegment)) {
|
||||
if (!Array.isArray(treeSegment) || Array.isArray(segment)) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
param: treeSegment[0],
|
||||
value: treeSegment[1],
|
||||
treeSegment: treeSegment,
|
||||
type: treeSegment[2]
|
||||
};
|
||||
}
|
||||
for (const parallelRouterState of Object.values(flightRouterState[1])){
|
||||
const maybeDynamicParam = findDynamicParamFromRouterState(parallelRouterState, segment);
|
||||
if (maybeDynamicParam) {
|
||||
return maybeDynamicParam;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns a function that parses the dynamic segment and return the associated value.
|
||||
*/ function makeGetDynamicParamFromSegment(params, flightRouterState) {
|
||||
return function getDynamicParamFromSegment(// [slug] / [[slug]] / [...slug]
|
||||
segment) {
|
||||
const segmentParam = (0, _getsegmentparam.getSegmentParam)(segment);
|
||||
if (!segmentParam) {
|
||||
return null;
|
||||
}
|
||||
const key = segmentParam.param;
|
||||
let value = params[key];
|
||||
// this is a special marker that will be present for interception routes
|
||||
if (value === "__NEXT_EMPTY_PARAM__") {
|
||||
value = undefined;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
value = value.map((i)=>encodeURIComponent(i));
|
||||
} else if (typeof value === "string") {
|
||||
value = encodeURIComponent(value);
|
||||
}
|
||||
if (!value) {
|
||||
// Handle case where optional catchall does not have a value, e.g. `/dashboard/[...slug]` when requesting `/dashboard`
|
||||
if (segmentParam.type === "optional-catchall") {
|
||||
const type = _getshortdynamicparamtype.dynamicParamTypes[segmentParam.type];
|
||||
return {
|
||||
param: key,
|
||||
value: null,
|
||||
type: type,
|
||||
// This value always has to be a string.
|
||||
treeSegment: [
|
||||
key,
|
||||
"",
|
||||
type
|
||||
]
|
||||
};
|
||||
}
|
||||
return findDynamicParamFromRouterState(flightRouterState, segment);
|
||||
}
|
||||
const type = (0, _getshortdynamicparamtype.getShortDynamicParamType)(segmentParam.type);
|
||||
return {
|
||||
param: key,
|
||||
// The value that is passed to user code.
|
||||
value: value,
|
||||
// The value that is rendered in the router tree.
|
||||
treeSegment: [
|
||||
key,
|
||||
Array.isArray(value) ? value.join("/") : value,
|
||||
type
|
||||
],
|
||||
type: type
|
||||
};
|
||||
};
|
||||
}
|
||||
function NonIndex({ ctx }) {
|
||||
const is404Page = ctx.pagePath === "/404";
|
||||
const isInvalidStatusCode = typeof ctx.res.statusCode === "number" && ctx.res.statusCode > 400;
|
||||
if (is404Page || isInvalidStatusCode) {
|
||||
return /*#__PURE__*/ (0, _jsxruntime.jsx)("meta", {
|
||||
name: "robots",
|
||||
content: "noindex"
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Handle Flight render request. This is only used when client-side navigating. E.g. when you `router.push('/dashboard')` or `router.reload()`.
|
||||
async function generateFlight(ctx, options) {
|
||||
// Flight data that is going to be passed to the browser.
|
||||
// Currently a single item array but in the future multiple patches might be combined in a single request.
|
||||
let flightData = null;
|
||||
const { componentMod: { tree: loaderTree, renderToReadableStream, createDynamicallyTrackedSearchParams }, getDynamicParamFromSegment, appUsingSizeAdjustment, staticGenerationStore: { urlPathname }, query, requestId, flightRouterState } = ctx;
|
||||
if (!(options == null ? void 0 : options.skipFlight)) {
|
||||
const [MetadataTree, MetadataOutlet] = (0, _metadata.createMetadataComponents)({
|
||||
tree: loaderTree,
|
||||
query,
|
||||
metadataContext: (0, _metadata.createMetadataContext)(urlPathname, ctx.renderOpts),
|
||||
getDynamicParamFromSegment,
|
||||
appUsingSizeAdjustment,
|
||||
createDynamicallyTrackedSearchParams
|
||||
});
|
||||
flightData = (await (0, _walktreewithflightrouterstate.walkTreeWithFlightRouterState)({
|
||||
ctx,
|
||||
createSegmentPath: (child)=>child,
|
||||
loaderTreeToFilter: loaderTree,
|
||||
parentParams: {},
|
||||
flightRouterState,
|
||||
isFirst: true,
|
||||
// For flight, render metadata inside leaf page
|
||||
// NOTE: in 14.2, fragment doesn't work well with React, using array instead
|
||||
rscPayloadHead: [
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(MetadataTree, {}, requestId),
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(NonIndex, {
|
||||
ctx: ctx
|
||||
}, "noindex")
|
||||
],
|
||||
injectedCSS: new Set(),
|
||||
injectedJS: new Set(),
|
||||
injectedFontPreloadTags: new Set(),
|
||||
rootLayoutIncluded: false,
|
||||
asNotFound: ctx.isNotFoundPath || (options == null ? void 0 : options.asNotFound),
|
||||
metadataOutlet: /*#__PURE__*/ (0, _jsxruntime.jsx)(MetadataOutlet, {})
|
||||
})).map((path)=>path.slice(1)) // remove the '' (root) segment
|
||||
;
|
||||
}
|
||||
const buildIdFlightDataPair = [
|
||||
ctx.renderOpts.buildId,
|
||||
flightData
|
||||
];
|
||||
// For app dir, use the bundled version of Flight server renderer (renderToReadableStream)
|
||||
// which contains the subset React.
|
||||
const flightReadableStream = renderToReadableStream(options ? [
|
||||
options.actionResult,
|
||||
buildIdFlightDataPair
|
||||
] : buildIdFlightDataPair, ctx.clientReferenceManifest.clientModules, {
|
||||
onError: ctx.flightDataRendererErrorHandler
|
||||
});
|
||||
return new _flightrenderresult.FlightRenderResult(flightReadableStream);
|
||||
}
|
||||
/**
|
||||
* Creates a resolver that eagerly generates a flight payload that is then
|
||||
* resolved when the resolver is called.
|
||||
*/ function createFlightDataResolver(ctx) {
|
||||
// Generate the flight data and as soon as it can, convert it into a string.
|
||||
const promise = generateFlight(ctx).then(async (result)=>({
|
||||
flightData: await result.toUnchunkedString(true)
|
||||
}))// Otherwise if it errored, return the error.
|
||||
.catch((err)=>({
|
||||
err
|
||||
}));
|
||||
return async ()=>{
|
||||
// Resolve the promise to get the flight data or error.
|
||||
const result = await promise;
|
||||
// If the flight data failed to render due to an error, re-throw the error
|
||||
// here.
|
||||
if ("err" in result) {
|
||||
throw result.err;
|
||||
}
|
||||
// Otherwise, return the flight data.
|
||||
return result.flightData;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Crawlers will inadvertently think the canonicalUrl in the RSC payload should be crawled
|
||||
* when our intention is to just seed the router state with the current URL.
|
||||
* This function splits up the pathname so that we can later join it on
|
||||
* when we're ready to consume the path.
|
||||
*/ function prepareInitialCanonicalUrl(pathname) {
|
||||
return pathname.split("/");
|
||||
}
|
||||
// This is the root component that runs in the RSC context
|
||||
async function ReactServerApp({ tree, ctx, asNotFound }) {
|
||||
// Create full component tree from root to leaf.
|
||||
const injectedCSS = new Set();
|
||||
const injectedJS = new Set();
|
||||
const injectedFontPreloadTags = new Set();
|
||||
const missingSlots = new Set();
|
||||
const { getDynamicParamFromSegment, query, appUsingSizeAdjustment, componentMod: { AppRouter, GlobalError, createDynamicallyTrackedSearchParams }, staticGenerationStore: { urlPathname } } = ctx;
|
||||
const initialTree = (0, _createflightrouterstatefromloadertree.createFlightRouterStateFromLoaderTree)(tree, getDynamicParamFromSegment, query);
|
||||
const [MetadataTree, MetadataOutlet] = (0, _metadata.createMetadataComponents)({
|
||||
tree,
|
||||
errorType: asNotFound ? "not-found" : undefined,
|
||||
query,
|
||||
metadataContext: (0, _metadata.createMetadataContext)(urlPathname, ctx.renderOpts),
|
||||
getDynamicParamFromSegment: getDynamicParamFromSegment,
|
||||
appUsingSizeAdjustment: appUsingSizeAdjustment,
|
||||
createDynamicallyTrackedSearchParams
|
||||
});
|
||||
const seedData = await (0, _createcomponenttree.createComponentTree)({
|
||||
ctx,
|
||||
createSegmentPath: (child)=>child,
|
||||
loaderTree: tree,
|
||||
parentParams: {},
|
||||
firstItem: true,
|
||||
injectedCSS,
|
||||
injectedJS,
|
||||
injectedFontPreloadTags,
|
||||
rootLayoutIncluded: false,
|
||||
asNotFound: asNotFound,
|
||||
metadataOutlet: /*#__PURE__*/ (0, _jsxruntime.jsx)(MetadataOutlet, {}),
|
||||
missingSlots
|
||||
});
|
||||
// When the `vary` response header is present with `Next-URL`, that means there's a chance
|
||||
// it could respond differently if there's an interception route. We provide this information
|
||||
// to `AppRouter` so that it can properly seed the prefetch cache with a prefix, if needed.
|
||||
const varyHeader = ctx.res.getHeader("vary");
|
||||
const couldBeIntercepted = typeof varyHeader === "string" && varyHeader.includes(_approuterheaders.NEXT_URL);
|
||||
return /*#__PURE__*/ (0, _jsxruntime.jsx)(AppRouter, {
|
||||
buildId: ctx.renderOpts.buildId,
|
||||
assetPrefix: ctx.assetPrefix,
|
||||
urlParts: prepareInitialCanonicalUrl(urlPathname),
|
||||
// This is the router state tree.
|
||||
initialTree: initialTree,
|
||||
// This is the tree of React nodes that are seeded into the cache
|
||||
initialSeedData: seedData,
|
||||
couldBeIntercepted: couldBeIntercepted,
|
||||
initialHead: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(NonIndex, {
|
||||
ctx: ctx
|
||||
}),
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(MetadataTree, {}, ctx.requestId)
|
||||
]
|
||||
}),
|
||||
globalErrorComponent: GlobalError,
|
||||
// This is used to provide debug information (when in development mode)
|
||||
// about which slots were not filled by page components while creating the component tree.
|
||||
missingSlots: missingSlots
|
||||
});
|
||||
}
|
||||
// This is the root component that runs in the RSC context
|
||||
async function ReactServerError({ tree, ctx, errorType }) {
|
||||
const { getDynamicParamFromSegment, query, appUsingSizeAdjustment, componentMod: { AppRouter, GlobalError, createDynamicallyTrackedSearchParams }, staticGenerationStore: { urlPathname }, requestId } = ctx;
|
||||
const [MetadataTree] = (0, _metadata.createMetadataComponents)({
|
||||
tree,
|
||||
metadataContext: (0, _metadata.createMetadataContext)(urlPathname, ctx.renderOpts),
|
||||
errorType,
|
||||
query,
|
||||
getDynamicParamFromSegment,
|
||||
appUsingSizeAdjustment,
|
||||
createDynamicallyTrackedSearchParams
|
||||
});
|
||||
const head = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(MetadataTree, {}, requestId),
|
||||
process.env.NODE_ENV === "development" && /*#__PURE__*/ (0, _jsxruntime.jsx)("meta", {
|
||||
name: "next-error",
|
||||
content: "not-found"
|
||||
}),
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(NonIndex, {
|
||||
ctx: ctx
|
||||
})
|
||||
]
|
||||
});
|
||||
const initialTree = (0, _createflightrouterstatefromloadertree.createFlightRouterStateFromLoaderTree)(tree, getDynamicParamFromSegment, query);
|
||||
// For metadata notFound error there's no global not found boundary on top
|
||||
// so we create a not found page with AppRouter
|
||||
const initialSeedData = [
|
||||
initialTree[0],
|
||||
{},
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsxs)("html", {
|
||||
id: "__next_error__",
|
||||
children: [
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)("head", {}),
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)("body", {})
|
||||
]
|
||||
}),
|
||||
null
|
||||
];
|
||||
return /*#__PURE__*/ (0, _jsxruntime.jsx)(AppRouter, {
|
||||
buildId: ctx.renderOpts.buildId,
|
||||
assetPrefix: ctx.assetPrefix,
|
||||
urlParts: prepareInitialCanonicalUrl(urlPathname),
|
||||
initialTree: initialTree,
|
||||
initialHead: head,
|
||||
globalErrorComponent: GlobalError,
|
||||
initialSeedData: initialSeedData,
|
||||
missingSlots: new Set()
|
||||
});
|
||||
}
|
||||
// This component must run in an SSR context. It will render the RSC root component
|
||||
function ReactServerEntrypoint({ reactServerStream, preinitScripts, clientReferenceManifest, nonce }) {
|
||||
preinitScripts();
|
||||
const response = (0, _useflightresponse.useFlightStream)(reactServerStream, clientReferenceManifest, nonce);
|
||||
return _react.default.use(response);
|
||||
}
|
||||
async function renderToHTMLOrFlightImpl(req, res, pagePath, query, renderOpts, baseCtx, requestEndedState) {
|
||||
var _getTracer_getRootSpanAttributes, _staticGenerationStore_prerenderState;
|
||||
const isNotFoundPath = pagePath === "/404";
|
||||
// A unique request timestamp used by development to ensure that it's
|
||||
// consistent and won't change during this request. This is important to
|
||||
// avoid that resources can be deduped by React Float if the same resource is
|
||||
// rendered or preloaded multiple times: `<link href="a.css?v={Date.now()}"/>`.
|
||||
const requestTimestamp = Date.now();
|
||||
const { buildManifest, subresourceIntegrityManifest, serverActionsManifest, ComponentMod, dev, nextFontManifest, supportsDynamicResponse, serverActions, appDirDevErrorLogger, assetPrefix = "", enableTainting } = renderOpts;
|
||||
// We need to expose the bundled `require` API globally for
|
||||
// react-server-dom-webpack. This is a hack until we find a better way.
|
||||
if (ComponentMod.__next_app__) {
|
||||
const instrumented = (0, _clientcomponentrendererlogger.wrapClientComponentLoader)(ComponentMod);
|
||||
// @ts-ignore
|
||||
globalThis.__next_require__ = instrumented.require;
|
||||
// @ts-ignore
|
||||
globalThis.__next_chunk_load__ = instrumented.loadChunk;
|
||||
}
|
||||
if (typeof req.on === "function") {
|
||||
req.on("end", ()=>{
|
||||
requestEndedState.ended = true;
|
||||
if ("performance" in globalThis) {
|
||||
const metrics = (0, _clientcomponentrendererlogger.getClientComponentLoaderMetrics)({
|
||||
reset: true
|
||||
});
|
||||
if (metrics) {
|
||||
(0, _tracer.getTracer)().startSpan(_constants.NextNodeServerSpan.clientComponentLoading, {
|
||||
startTime: metrics.clientComponentLoadStart,
|
||||
attributes: {
|
||||
"next.clientComponentLoadCount": metrics.clientComponentLoadCount
|
||||
}
|
||||
}).end(metrics.clientComponentLoadStart + metrics.clientComponentLoadTimes);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
const metadata = {};
|
||||
const appUsingSizeAdjustment = !!(nextFontManifest == null ? void 0 : nextFontManifest.appUsingSizeAdjust);
|
||||
// TODO: fix this typescript
|
||||
const clientReferenceManifest = renderOpts.clientReferenceManifest;
|
||||
const serverModuleMap = (0, _actionutils.createServerModuleMap)({
|
||||
serverActionsManifest,
|
||||
pageName: renderOpts.page
|
||||
});
|
||||
(0, _encryptionutils.setReferenceManifestsSingleton)({
|
||||
clientReferenceManifest,
|
||||
serverActionsManifest,
|
||||
serverModuleMap
|
||||
});
|
||||
const digestErrorsMap = new Map();
|
||||
const allCapturedErrors = [];
|
||||
const isNextExport = !!renderOpts.nextExport;
|
||||
const { staticGenerationStore, requestStore } = baseCtx;
|
||||
const { isStaticGeneration } = staticGenerationStore;
|
||||
// when static generation fails during PPR, we log the errors separately. We intentionally
|
||||
// silence the error logger in this case to avoid double logging.
|
||||
const silenceStaticGenerationErrors = renderOpts.experimental.ppr && isStaticGeneration;
|
||||
const serverComponentsErrorHandler = (0, _createerrorhandler.createErrorHandler)({
|
||||
source: _createerrorhandler.ErrorHandlerSource.serverComponents,
|
||||
dev,
|
||||
isNextExport,
|
||||
errorLogger: appDirDevErrorLogger,
|
||||
digestErrorsMap,
|
||||
silenceLogger: silenceStaticGenerationErrors
|
||||
});
|
||||
const flightDataRendererErrorHandler = (0, _createerrorhandler.createErrorHandler)({
|
||||
source: _createerrorhandler.ErrorHandlerSource.flightData,
|
||||
dev,
|
||||
isNextExport,
|
||||
errorLogger: appDirDevErrorLogger,
|
||||
digestErrorsMap,
|
||||
silenceLogger: silenceStaticGenerationErrors
|
||||
});
|
||||
const htmlRendererErrorHandler = (0, _createerrorhandler.createErrorHandler)({
|
||||
source: _createerrorhandler.ErrorHandlerSource.html,
|
||||
dev,
|
||||
isNextExport,
|
||||
errorLogger: appDirDevErrorLogger,
|
||||
digestErrorsMap,
|
||||
allCapturedErrors,
|
||||
silenceLogger: silenceStaticGenerationErrors
|
||||
});
|
||||
ComponentMod.patchFetch();
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* These rules help ensure that other existing features like request caching,
|
||||
* coalescing, and ISR continue working as intended.
|
||||
*/ const generateStaticHTML = supportsDynamicResponse !== true;
|
||||
// Pull out the hooks/references from the component.
|
||||
const { tree: loaderTree, taintObjectReference } = ComponentMod;
|
||||
if (enableTainting) {
|
||||
taintObjectReference("Do not pass process.env to client components since it will leak sensitive data", process.env);
|
||||
}
|
||||
staticGenerationStore.fetchMetrics = [];
|
||||
metadata.fetchMetrics = staticGenerationStore.fetchMetrics;
|
||||
// don't modify original query object
|
||||
query = {
|
||||
...query
|
||||
};
|
||||
(0, _internalutils.stripInternalQueries)(query);
|
||||
const isRSCRequest = req.headers[_approuterheaders.RSC_HEADER.toLowerCase()] !== undefined;
|
||||
const isPrefetchRSCRequest = isRSCRequest && req.headers[_approuterheaders.NEXT_ROUTER_PREFETCH_HEADER.toLowerCase()] !== undefined;
|
||||
/**
|
||||
* Router state provided from the client-side router. Used to handle rendering
|
||||
* from the common layout down. This value will be undefined if the request
|
||||
* is not a client-side navigation request or if the request is a prefetch
|
||||
* request (except when it's a prefetch request for an interception route
|
||||
* which is always dynamic).
|
||||
*/ const shouldProvideFlightRouterState = isRSCRequest && (!isPrefetchRSCRequest || !renderOpts.experimental.ppr || // Interception routes currently depend on the flight router state to
|
||||
// extract dynamic params.
|
||||
(0, _interceptionroutes.isInterceptionRouteAppPath)(pagePath));
|
||||
const parsedFlightRouterState = (0, _parseandvalidateflightrouterstate.parseAndValidateFlightRouterState)(req.headers[_approuterheaders.NEXT_ROUTER_STATE_TREE.toLowerCase()]);
|
||||
/**
|
||||
* The metadata items array created in next-app-loader with all relevant information
|
||||
* that we need to resolve the final metadata.
|
||||
*/ let requestId;
|
||||
if (process.env.NEXT_RUNTIME === "edge") {
|
||||
requestId = crypto.randomUUID();
|
||||
} else {
|
||||
requestId = require("next/dist/compiled/nanoid").nanoid();
|
||||
}
|
||||
/**
|
||||
* Dynamic parameters. E.g. when you visit `/dashboard/vercel` which is rendered by `/dashboard/[slug]` the value will be {"slug": "vercel"}.
|
||||
*/ const params = renderOpts.params ?? {};
|
||||
const getDynamicParamFromSegment = makeGetDynamicParamFromSegment(params, // `FlightRouterState` is unconditionally provided here because this method uses it
|
||||
// to extract dynamic params as a fallback if they're not present in the path.
|
||||
parsedFlightRouterState);
|
||||
const ctx = {
|
||||
...baseCtx,
|
||||
getDynamicParamFromSegment,
|
||||
query,
|
||||
isPrefetch: isPrefetchRSCRequest,
|
||||
requestTimestamp,
|
||||
appUsingSizeAdjustment,
|
||||
flightRouterState: shouldProvideFlightRouterState ? parsedFlightRouterState : undefined,
|
||||
requestId,
|
||||
defaultRevalidate: false,
|
||||
pagePath,
|
||||
clientReferenceManifest,
|
||||
assetPrefix,
|
||||
flightDataRendererErrorHandler,
|
||||
serverComponentsErrorHandler,
|
||||
isNotFoundPath,
|
||||
res
|
||||
};
|
||||
if (isRSCRequest && !isStaticGeneration) {
|
||||
return generateFlight(ctx);
|
||||
}
|
||||
// Create the resolver that can get the flight payload when it's ready or
|
||||
// throw the error if it occurred. If we are not generating static HTML, we
|
||||
// don't need to generate the flight payload because it's a dynamic request
|
||||
// which means we're either getting the flight payload only or just the
|
||||
// regular HTML.
|
||||
const flightDataResolver = isStaticGeneration ? createFlightDataResolver(ctx) : null;
|
||||
// Get the nonce from the incoming request if it has one.
|
||||
const csp = req.headers["content-security-policy"] || req.headers["content-security-policy-report-only"];
|
||||
let nonce;
|
||||
if (csp && typeof csp === "string") {
|
||||
nonce = (0, _getscriptnoncefromheader.getScriptNonceFromHeader)(csp);
|
||||
}
|
||||
const validateRootLayout = dev;
|
||||
const { HeadManagerContext } = require("../../shared/lib/head-manager-context.shared-runtime");
|
||||
// On each render, create a new `ServerInsertedHTML` context to capture
|
||||
// injected nodes from user code (`useServerInsertedHTML`).
|
||||
const { ServerInsertedHTMLProvider, renderServerInsertedHTML } = (0, _serverinsertedhtml.createServerInsertedHTML)();
|
||||
(_getTracer_getRootSpanAttributes = (0, _tracer.getTracer)().getRootSpanAttributes()) == null ? void 0 : _getTracer_getRootSpanAttributes.set("next.route", pagePath);
|
||||
const renderToStream = (0, _tracer.getTracer)().wrap(_constants.AppRenderSpan.getBodyResult, {
|
||||
spanName: `render route (app) ${pagePath}`,
|
||||
attributes: {
|
||||
"next.route": pagePath
|
||||
}
|
||||
}, async ({ asNotFound, tree, formState })=>{
|
||||
const polyfills = buildManifest.polyfillFiles.filter((polyfill)=>polyfill.endsWith(".js") && !polyfill.endsWith(".module.js")).map((polyfill)=>({
|
||||
src: `${assetPrefix}/_next/${polyfill}${(0, _getassetquerystring.getAssetQueryString)(ctx, false)}`,
|
||||
integrity: subresourceIntegrityManifest == null ? void 0 : subresourceIntegrityManifest[polyfill],
|
||||
crossOrigin: renderOpts.crossOrigin,
|
||||
noModule: true,
|
||||
nonce
|
||||
}));
|
||||
const [preinitScripts, bootstrapScript] = (0, _requiredscripts.getRequiredScripts)(buildManifest, assetPrefix, renderOpts.crossOrigin, subresourceIntegrityManifest, (0, _getassetquerystring.getAssetQueryString)(ctx, true), nonce);
|
||||
// We kick off the Flight Request (render) here. It is ok to initiate the render in an arbitrary
|
||||
// place however it is critical that we only construct the Flight Response inside the SSR
|
||||
// render so that directives like preloads are correctly piped through
|
||||
const serverStream = ComponentMod.renderToReadableStream(/*#__PURE__*/ (0, _jsxruntime.jsx)(ReactServerApp, {
|
||||
tree: tree,
|
||||
ctx: ctx,
|
||||
asNotFound: asNotFound
|
||||
}), clientReferenceManifest.clientModules, {
|
||||
onError: serverComponentsErrorHandler
|
||||
});
|
||||
// We are going to consume this render both for SSR and for inlining the flight data
|
||||
let [renderStream, dataStream] = serverStream.tee();
|
||||
const children = /*#__PURE__*/ (0, _jsxruntime.jsx)(HeadManagerContext.Provider, {
|
||||
value: {
|
||||
appDir: true,
|
||||
nonce
|
||||
},
|
||||
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(ServerInsertedHTMLProvider, {
|
||||
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(ReactServerEntrypoint, {
|
||||
reactServerStream: renderStream,
|
||||
preinitScripts: preinitScripts,
|
||||
clientReferenceManifest: clientReferenceManifest,
|
||||
nonce: nonce
|
||||
})
|
||||
})
|
||||
});
|
||||
const isResume = !!renderOpts.postponed;
|
||||
const onHeaders = staticGenerationStore.prerenderState ? (headers)=>{
|
||||
headers.forEach((value, key)=>{
|
||||
metadata.headers ??= {};
|
||||
metadata.headers[key] = value;
|
||||
});
|
||||
} : isStaticGeneration || isResume ? // ask React to emit headers. For Resume this is just not supported
|
||||
// For static generation we know there will be an entire HTML document
|
||||
// output and so moving from tag to header for preloading can only
|
||||
// server to alter preloading priorities in unwanted ways
|
||||
undefined : // early headers to the response
|
||||
(headers)=>{
|
||||
headers.forEach((value, key)=>{
|
||||
res.appendHeader(key, value);
|
||||
});
|
||||
};
|
||||
const getServerInsertedHTML = (0, _makegetserverinsertedhtml.makeGetServerInsertedHTML)({
|
||||
polyfills,
|
||||
renderServerInsertedHTML,
|
||||
serverCapturedErrors: allCapturedErrors,
|
||||
basePath: renderOpts.basePath
|
||||
});
|
||||
const renderer = (0, _staticrenderer.createStaticRenderer)({
|
||||
ppr: renderOpts.experimental.ppr,
|
||||
isStaticGeneration,
|
||||
// If provided, the postpone state should be parsed as JSON so it can be
|
||||
// provided to React.
|
||||
postponed: typeof renderOpts.postponed === "string" ? JSON.parse(renderOpts.postponed) : null,
|
||||
streamOptions: {
|
||||
onError: htmlRendererErrorHandler,
|
||||
onHeaders,
|
||||
maxHeadersLength: 600,
|
||||
nonce,
|
||||
bootstrapScripts: [
|
||||
bootstrapScript
|
||||
],
|
||||
formState
|
||||
}
|
||||
});
|
||||
try {
|
||||
let { stream, postponed, resumed } = await renderer.render(children);
|
||||
const prerenderState = staticGenerationStore.prerenderState;
|
||||
if (prerenderState) {
|
||||
/**
|
||||
* When prerendering there are three outcomes to consider
|
||||
*
|
||||
* Dynamic HTML: The prerender has dynamic holes (caused by using Next.js Dynamic Rendering APIs)
|
||||
* We will need to resume this result when requests are handled and we don't include
|
||||
* any server inserted HTML or inlined flight data in the static HTML
|
||||
*
|
||||
* Dynamic Data: The prerender has no dynamic holes but dynamic APIs were used. We will not
|
||||
* resume this render when requests are handled but we will generate new inlined
|
||||
* flight data since it is dynamic and differences may end up reconciling on the client
|
||||
*
|
||||
* Static: The prerender has no dynamic holes and no dynamic APIs were used. We statically encode
|
||||
* all server inserted HTML and flight data
|
||||
*/ // First we check if we have any dynamic holes in our HTML prerender
|
||||
if ((0, _dynamicrendering.usedDynamicAPIs)(prerenderState)) {
|
||||
if (postponed != null) {
|
||||
// This is the Dynamic HTML case.
|
||||
metadata.postponed = JSON.stringify((0, _staticrenderer.getDynamicHTMLPostponedState)(postponed));
|
||||
} else {
|
||||
// This is the Dynamic Data case
|
||||
metadata.postponed = JSON.stringify((0, _staticrenderer.getDynamicDataPostponedState)());
|
||||
}
|
||||
// Regardless of whether this is the Dynamic HTML or Dynamic Data case we need to ensure we include
|
||||
// server inserted html in the static response because the html that is part of the prerender may depend on it
|
||||
// It is possible in the set of stream transforms for Dynamic HTML vs Dynamic Data may differ but currently both states
|
||||
// require the same set so we unify the code path here
|
||||
return {
|
||||
stream: await (0, _nodewebstreamshelper.continueDynamicPrerender)(stream, {
|
||||
getServerInsertedHTML
|
||||
})
|
||||
};
|
||||
} else {
|
||||
// We may still be rendering the RSC stream even though the HTML is finished.
|
||||
// We wait for the RSC stream to complete and check again if dynamic was used
|
||||
const [original, flightSpy] = dataStream.tee();
|
||||
dataStream = original;
|
||||
await (0, _useflightresponse.flightRenderComplete)(flightSpy);
|
||||
if ((0, _dynamicrendering.usedDynamicAPIs)(prerenderState)) {
|
||||
// This is the same logic above just repeated after ensuring the RSC stream itself has completed
|
||||
if (postponed != null) {
|
||||
// This is the Dynamic HTML case.
|
||||
metadata.postponed = JSON.stringify((0, _staticrenderer.getDynamicHTMLPostponedState)(postponed));
|
||||
} else {
|
||||
// This is the Dynamic Data case
|
||||
metadata.postponed = JSON.stringify((0, _staticrenderer.getDynamicDataPostponedState)());
|
||||
}
|
||||
// Regardless of whether this is the Dynamic HTML or Dynamic Data case we need to ensure we include
|
||||
// server inserted html in the static response because the html that is part of the prerender may depend on it
|
||||
// It is possible in the set of stream transforms for Dynamic HTML vs Dynamic Data may differ but currently both states
|
||||
// require the same set so we unify the code path here
|
||||
return {
|
||||
stream: await (0, _nodewebstreamshelper.continueDynamicPrerender)(stream, {
|
||||
getServerInsertedHTML
|
||||
})
|
||||
};
|
||||
} else {
|
||||
// This is the Static case
|
||||
// We still have not used any dynamic APIs. At this point we can produce an entirely static prerender response
|
||||
let renderedHTMLStream = stream;
|
||||
if (staticGenerationStore.forceDynamic) {
|
||||
throw new _staticgenerationbailout.StaticGenBailoutError('Invariant: a Page with `dynamic = "force-dynamic"` did not trigger the dynamic pathway. This is a bug in Next.js');
|
||||
}
|
||||
if (postponed != null) {
|
||||
// We postponed but nothing dynamic was used. We resume the render now and immediately abort it
|
||||
// so we can set all the postponed boundaries to client render mode before we store the HTML response
|
||||
const resumeRenderer = (0, _staticrenderer.createStaticRenderer)({
|
||||
ppr: true,
|
||||
isStaticGeneration: false,
|
||||
postponed: (0, _staticrenderer.getDynamicHTMLPostponedState)(postponed),
|
||||
streamOptions: {
|
||||
signal: (0, _dynamicrendering.createPostponedAbortSignal)("static prerender resume"),
|
||||
onError: htmlRendererErrorHandler,
|
||||
nonce
|
||||
}
|
||||
});
|
||||
// We don't actually want to render anything so we just pass a stream
|
||||
// that never resolves. The resume call is going to abort immediately anyway
|
||||
const foreverStream = new ReadableStream();
|
||||
const resumeChildren = /*#__PURE__*/ (0, _jsxruntime.jsx)(HeadManagerContext.Provider, {
|
||||
value: {
|
||||
appDir: true,
|
||||
nonce
|
||||
},
|
||||
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(ServerInsertedHTMLProvider, {
|
||||
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(ReactServerEntrypoint, {
|
||||
reactServerStream: foreverStream,
|
||||
preinitScripts: ()=>{},
|
||||
clientReferenceManifest: clientReferenceManifest,
|
||||
nonce: nonce
|
||||
})
|
||||
})
|
||||
});
|
||||
const { stream: resumeStream } = await resumeRenderer.render(resumeChildren);
|
||||
// First we write everything from the prerender, then we write everything from the aborted resume render
|
||||
renderedHTMLStream = (0, _nodewebstreamshelper.chainStreams)(stream, resumeStream);
|
||||
}
|
||||
return {
|
||||
stream: await (0, _nodewebstreamshelper.continueStaticPrerender)(renderedHTMLStream, {
|
||||
inlinedDataStream: (0, _useflightresponse.createInlinedDataReadableStream)(dataStream, nonce, formState),
|
||||
getServerInsertedHTML
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
} else if (renderOpts.postponed) {
|
||||
// This is a continuation of either an Incomplete or Dynamic Data Prerender.
|
||||
const inlinedDataStream = (0, _useflightresponse.createInlinedDataReadableStream)(dataStream, nonce, formState);
|
||||
if (resumed) {
|
||||
// We have new HTML to stream and we also need to include server inserted HTML
|
||||
return {
|
||||
stream: await (0, _nodewebstreamshelper.continueDynamicHTMLResume)(stream, {
|
||||
inlinedDataStream,
|
||||
getServerInsertedHTML
|
||||
})
|
||||
};
|
||||
} else {
|
||||
// We are continuing a Dynamic Data Prerender and simply need to append new inlined flight data
|
||||
return {
|
||||
stream: await (0, _nodewebstreamshelper.continueDynamicDataResume)(stream, {
|
||||
inlinedDataStream
|
||||
})
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// This may be a static render or a dynamic render
|
||||
// @TODO factor this further to make the render types more clearly defined and remove
|
||||
// the deluge of optional params that passed to configure the various behaviors
|
||||
return {
|
||||
stream: await (0, _nodewebstreamshelper.continueFizzStream)(stream, {
|
||||
inlinedDataStream: (0, _useflightresponse.createInlinedDataReadableStream)(dataStream, nonce, formState),
|
||||
isStaticGeneration: isStaticGeneration || generateStaticHTML,
|
||||
getServerInsertedHTML,
|
||||
serverInsertedHTMLToHead: true,
|
||||
validateRootLayout
|
||||
})
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
if ((0, _staticgenerationbailout.isStaticGenBailoutError)(err) || typeof err === "object" && err !== null && "message" in err && typeof err.message === "string" && err.message.includes("https://nextjs.org/docs/advanced-features/static-html-export")) {
|
||||
// Ensure that "next dev" prints the red error overlay
|
||||
throw err;
|
||||
}
|
||||
// If this is a static generation error, we need to throw it so that it
|
||||
// can be handled by the caller if we're in static generation mode.
|
||||
if (isStaticGeneration && (0, _hooksservercontext.isDynamicServerError)(err)) {
|
||||
throw err;
|
||||
}
|
||||
// If a bailout made it to this point, it means it wasn't wrapped inside
|
||||
// a suspense boundary.
|
||||
const shouldBailoutToCSR = (0, _bailouttocsr.isBailoutToCSRError)(err);
|
||||
if (shouldBailoutToCSR) {
|
||||
const stack = (0, _formatservererror.getStackWithoutErrorMessage)(err);
|
||||
if (renderOpts.experimental.missingSuspenseWithCSRBailout) {
|
||||
(0, _log.error)(`${err.reason} should be wrapped in a suspense boundary at page "${pagePath}". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout\n${stack}`);
|
||||
throw err;
|
||||
}
|
||||
(0, _log.warn)(`Entire page "${pagePath}" deopted into client-side rendering due to "${err.reason}". Read more: https://nextjs.org/docs/messages/deopted-into-client-rendering\n${stack}`);
|
||||
}
|
||||
if ((0, _notfound.isNotFoundError)(err)) {
|
||||
res.statusCode = 404;
|
||||
}
|
||||
let hasRedirectError = false;
|
||||
if ((0, _redirect.isRedirectError)(err)) {
|
||||
hasRedirectError = true;
|
||||
res.statusCode = (0, _redirect.getRedirectStatusCodeFromError)(err);
|
||||
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()));
|
||||
}
|
||||
}
|
||||
const redirectUrl = (0, _addpathprefix.addPathPrefix)((0, _redirect.getURLFromRedirectError)(err), renderOpts.basePath);
|
||||
res.setHeader("Location", redirectUrl);
|
||||
}
|
||||
const is404 = ctx.res.statusCode === 404;
|
||||
if (!is404 && !hasRedirectError && !shouldBailoutToCSR) {
|
||||
res.statusCode = 500;
|
||||
}
|
||||
const errorType = is404 ? "not-found" : hasRedirectError ? "redirect" : undefined;
|
||||
const [errorPreinitScripts, errorBootstrapScript] = (0, _requiredscripts.getRequiredScripts)(buildManifest, assetPrefix, renderOpts.crossOrigin, subresourceIntegrityManifest, (0, _getassetquerystring.getAssetQueryString)(ctx, false), nonce);
|
||||
const errorServerStream = ComponentMod.renderToReadableStream(/*#__PURE__*/ (0, _jsxruntime.jsx)(ReactServerError, {
|
||||
tree: tree,
|
||||
ctx: ctx,
|
||||
errorType: errorType
|
||||
}), clientReferenceManifest.clientModules, {
|
||||
onError: serverComponentsErrorHandler
|
||||
});
|
||||
try {
|
||||
const fizzStream = await (0, _nodewebstreamshelper.renderToInitialFizzStream)({
|
||||
ReactDOMServer: require("react-dom/server.edge"),
|
||||
element: /*#__PURE__*/ (0, _jsxruntime.jsx)(ReactServerEntrypoint, {
|
||||
reactServerStream: errorServerStream,
|
||||
preinitScripts: errorPreinitScripts,
|
||||
clientReferenceManifest: clientReferenceManifest,
|
||||
nonce: nonce
|
||||
}),
|
||||
streamOptions: {
|
||||
nonce,
|
||||
// Include hydration scripts in the HTML
|
||||
bootstrapScripts: [
|
||||
errorBootstrapScript
|
||||
],
|
||||
formState
|
||||
}
|
||||
});
|
||||
return {
|
||||
// Returning the error that was thrown so it can be used to handle
|
||||
// the response in the caller.
|
||||
err,
|
||||
stream: await (0, _nodewebstreamshelper.continueFizzStream)(fizzStream, {
|
||||
inlinedDataStream: (0, _useflightresponse.createInlinedDataReadableStream)(// This is intentionally using the readable datastream from the
|
||||
// main render rather than the flight data from the error page
|
||||
// render
|
||||
dataStream, nonce, formState),
|
||||
isStaticGeneration,
|
||||
getServerInsertedHTML: (0, _makegetserverinsertedhtml.makeGetServerInsertedHTML)({
|
||||
polyfills,
|
||||
renderServerInsertedHTML,
|
||||
serverCapturedErrors: [],
|
||||
basePath: renderOpts.basePath
|
||||
}),
|
||||
serverInsertedHTMLToHead: true,
|
||||
validateRootLayout
|
||||
})
|
||||
};
|
||||
} catch (finalErr) {
|
||||
if (process.env.NODE_ENV === "development" && (0, _notfound.isNotFoundError)(finalErr)) {
|
||||
const bailOnNotFound = require("../../client/components/dev-root-not-found-boundary").bailOnNotFound;
|
||||
bailOnNotFound();
|
||||
}
|
||||
throw finalErr;
|
||||
}
|
||||
}
|
||||
});
|
||||
// For action requests, we handle them differently with a special render result.
|
||||
const actionRequestResult = await (0, _actionhandler.handleAction)({
|
||||
req,
|
||||
res,
|
||||
ComponentMod,
|
||||
serverModuleMap,
|
||||
generateFlight,
|
||||
staticGenerationStore,
|
||||
requestStore,
|
||||
serverActions,
|
||||
ctx
|
||||
});
|
||||
let formState = null;
|
||||
if (actionRequestResult) {
|
||||
if (actionRequestResult.type === "not-found") {
|
||||
const notFoundLoaderTree = createNotFoundLoaderTree(loaderTree);
|
||||
const response = await renderToStream({
|
||||
asNotFound: true,
|
||||
tree: notFoundLoaderTree,
|
||||
formState
|
||||
});
|
||||
return new _renderresult.default(response.stream, {
|
||||
metadata
|
||||
});
|
||||
} else if (actionRequestResult.type === "done") {
|
||||
if (actionRequestResult.result) {
|
||||
actionRequestResult.result.assignMetadata(metadata);
|
||||
return actionRequestResult.result;
|
||||
} else if (actionRequestResult.formState) {
|
||||
formState = actionRequestResult.formState;
|
||||
}
|
||||
}
|
||||
}
|
||||
const options = {
|
||||
metadata
|
||||
};
|
||||
let response = await renderToStream({
|
||||
asNotFound: isNotFoundPath,
|
||||
tree: loaderTree,
|
||||
formState
|
||||
});
|
||||
// If we have pending revalidates, wait until they are all resolved.
|
||||
if (staticGenerationStore.pendingRevalidates) {
|
||||
var _staticGenerationStore_incrementalCache;
|
||||
options.waitUntil = Promise.all([
|
||||
(_staticGenerationStore_incrementalCache = staticGenerationStore.incrementalCache) == null ? void 0 : _staticGenerationStore_incrementalCache.revalidateTag(staticGenerationStore.revalidatedTags || []),
|
||||
...Object.values(staticGenerationStore.pendingRevalidates || {})
|
||||
]);
|
||||
}
|
||||
(0, _patchfetch.addImplicitTags)(staticGenerationStore);
|
||||
if (staticGenerationStore.tags) {
|
||||
metadata.fetchTags = staticGenerationStore.tags.join(",");
|
||||
}
|
||||
// Create the new render result for the response.
|
||||
const result = new _renderresult.default(response.stream, options);
|
||||
// If we aren't performing static generation, we can return the result now.
|
||||
if (!isStaticGeneration) {
|
||||
return result;
|
||||
}
|
||||
// If this is static generation, we should read this in now rather than
|
||||
// sending it back to be sent to the client.
|
||||
response.stream = await result.toUnchunkedString(true);
|
||||
const buildFailingError = digestErrorsMap.size > 0 ? digestErrorsMap.values().next().value : null;
|
||||
// If we're debugging partial prerendering, print all the dynamic API accesses
|
||||
// that occurred during the render.
|
||||
if (staticGenerationStore.prerenderState && (0, _dynamicrendering.usedDynamicAPIs)(staticGenerationStore.prerenderState) && ((_staticGenerationStore_prerenderState = staticGenerationStore.prerenderState) == null ? void 0 : _staticGenerationStore_prerenderState.isDebugSkeleton)) {
|
||||
(0, _log.warn)("The following dynamic usage was detected:");
|
||||
for (const access of (0, _dynamicrendering.formatDynamicAPIAccesses)(staticGenerationStore.prerenderState)){
|
||||
(0, _log.warn)(access);
|
||||
}
|
||||
}
|
||||
if (!flightDataResolver) {
|
||||
throw new Error("Invariant: Flight data resolver is missing when generating static HTML");
|
||||
}
|
||||
// If we encountered any unexpected errors during build we fail the
|
||||
// prerendering phase and the build.
|
||||
if (buildFailingError) {
|
||||
throw buildFailingError;
|
||||
}
|
||||
// Wait for and collect the flight payload data if we don't have it
|
||||
// already
|
||||
const flightData = await flightDataResolver();
|
||||
if (flightData) {
|
||||
metadata.flightData = flightData;
|
||||
}
|
||||
// If force static is specifically set to false, we should not revalidate
|
||||
// the page.
|
||||
if (staticGenerationStore.forceStatic === false) {
|
||||
staticGenerationStore.revalidate = 0;
|
||||
}
|
||||
// Copy the revalidation value onto the render result metadata.
|
||||
metadata.revalidate = staticGenerationStore.revalidate ?? ctx.defaultRevalidate;
|
||||
// provide bailout info for debugging
|
||||
if (metadata.revalidate === 0) {
|
||||
metadata.staticBailoutInfo = {
|
||||
description: staticGenerationStore.dynamicUsageDescription,
|
||||
stack: staticGenerationStore.dynamicUsageStack
|
||||
};
|
||||
}
|
||||
return new _renderresult.default(response.stream, options);
|
||||
}
|
||||
const renderToHTMLOrFlight = (req, res, pagePath, query, renderOpts)=>{
|
||||
// TODO: this includes query string, should it?
|
||||
const pathname = (0, _validateurl.validateURL)(req.url);
|
||||
return _requestasyncstoragewrapper.RequestAsyncStorageWrapper.wrap(renderOpts.ComponentMod.requestAsyncStorage, {
|
||||
req,
|
||||
res,
|
||||
renderOpts
|
||||
}, (requestStore)=>_staticgenerationasyncstoragewrapper.StaticGenerationAsyncStorageWrapper.wrap(renderOpts.ComponentMod.staticGenerationAsyncStorage, {
|
||||
urlPathname: pathname,
|
||||
renderOpts,
|
||||
requestEndedState: {
|
||||
ended: false
|
||||
}
|
||||
}, (staticGenerationStore)=>renderToHTMLOrFlightImpl(req, res, pagePath, query, renderOpts, {
|
||||
requestStore,
|
||||
staticGenerationStore,
|
||||
componentMod: renderOpts.ComponentMod,
|
||||
renderOpts
|
||||
}, staticGenerationStore.requestEndedState || {})));
|
||||
};
|
||||
|
||||
//# sourceMappingURL=app-render.js.map
|
||||
1
node_modules/next/dist/server/app-render/app-render.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/app-render.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/next/dist/server/app-render/create-component-styles-and-scripts.d.ts
generated
vendored
Normal file
9
node_modules/next/dist/server/app-render/create-component-styles-and-scripts.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import type { AppRenderContext } from './app-render';
|
||||
export declare function createComponentStylesAndScripts({ filePath, getComponent, injectedCSS, injectedJS, ctx, }: {
|
||||
filePath: string;
|
||||
getComponent: () => any;
|
||||
injectedCSS: Set<string>;
|
||||
injectedJS: Set<string>;
|
||||
ctx: AppRenderContext;
|
||||
}): Promise<[React.ComponentType<any>, React.ReactNode, React.ReactNode]>;
|
||||
53
node_modules/next/dist/server/app-render/create-component-styles-and-scripts.js
generated
vendored
Normal file
53
node_modules/next/dist/server/app-render/create-component-styles-and-scripts.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "createComponentStylesAndScripts", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return createComponentStylesAndScripts;
|
||||
}
|
||||
});
|
||||
const _jsxruntime = require("react/jsx-runtime");
|
||||
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
||||
const _interopdefault = require("./interop-default");
|
||||
const _getcssinlinedlinktags = require("./get-css-inlined-link-tags");
|
||||
const _getassetquerystring = require("./get-asset-query-string");
|
||||
const _encodeuripath = require("../../shared/lib/encode-uri-path");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
async function createComponentStylesAndScripts({ filePath, getComponent, injectedCSS, injectedJS, ctx }) {
|
||||
const { styles: cssHrefs, scripts: jsHrefs } = (0, _getcssinlinedlinktags.getLinkAndScriptTags)(ctx.clientReferenceManifest, filePath, injectedCSS, injectedJS);
|
||||
const styles = cssHrefs ? cssHrefs.map((href, index)=>{
|
||||
const fullHref = `${ctx.assetPrefix}/_next/${(0, _encodeuripath.encodeURIPath)(href)}${(0, _getassetquerystring.getAssetQueryString)(ctx, true)}`;
|
||||
// `Precedence` is an opt-in signal for React to handle resource
|
||||
// loading and deduplication, etc. It's also used as the key to sort
|
||||
// resources so they will be injected in the correct order.
|
||||
// During HMR, it's critical to use different `precedence` values
|
||||
// for different stylesheets, so their order will be kept.
|
||||
// https://github.com/facebook/react/pull/25060
|
||||
const precedence = process.env.NODE_ENV === "development" ? "next_" + href : "next";
|
||||
return /*#__PURE__*/ (0, _jsxruntime.jsx)("link", {
|
||||
rel: "stylesheet",
|
||||
href: fullHref,
|
||||
// @ts-ignore
|
||||
precedence: precedence,
|
||||
crossOrigin: ctx.renderOpts.crossOrigin
|
||||
}, index);
|
||||
}) : null;
|
||||
const scripts = jsHrefs ? jsHrefs.map((href)=>/*#__PURE__*/ (0, _jsxruntime.jsx)("script", {
|
||||
src: `${ctx.assetPrefix}/_next/${(0, _encodeuripath.encodeURIPath)(href)}${(0, _getassetquerystring.getAssetQueryString)(ctx, true)}`,
|
||||
async: true
|
||||
})) : null;
|
||||
const Comp = (0, _interopdefault.interopDefault)(await getComponent());
|
||||
return [
|
||||
Comp,
|
||||
styles,
|
||||
scripts
|
||||
];
|
||||
}
|
||||
|
||||
//# sourceMappingURL=create-component-styles-and-scripts.js.map
|
||||
1
node_modules/next/dist/server/app-render/create-component-styles-and-scripts.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/create-component-styles-and-scripts.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/create-component-styles-and-scripts.tsx"],"names":["createComponentStylesAndScripts","filePath","getComponent","injectedCSS","injectedJS","ctx","styles","cssHrefs","scripts","jsHrefs","getLinkAndScriptTags","clientReferenceManifest","map","href","index","fullHref","assetPrefix","encodeURIPath","getAssetQueryString","precedence","process","env","NODE_ENV","link","rel","crossOrigin","renderOpts","script","src","async","Comp","interopDefault"],"mappings":";;;;+BAOsBA;;;eAAAA;;;;8DAPJ;gCACa;uCACM;qCAED;+BACN;;;;;;AAEvB,eAAeA,gCAAgC,EACpDC,QAAQ,EACRC,YAAY,EACZC,WAAW,EACXC,UAAU,EACVC,GAAG,EAOJ;IACC,MAAM,EAAEC,QAAQC,QAAQ,EAAEC,SAASC,OAAO,EAAE,GAAGC,IAAAA,2CAAoB,EACjEL,IAAIM,uBAAuB,EAC3BV,UACAE,aACAC;IAGF,MAAME,SAASC,WACXA,SAASK,GAAG,CAAC,CAACC,MAAMC;QAClB,MAAMC,WAAW,CAAC,EAAEV,IAAIW,WAAW,CAAC,OAAO,EAAEC,IAAAA,4BAAa,EACxDJ,MACA,EAAEK,IAAAA,wCAAmB,EAACb,KAAK,MAAM,CAAC;QAEpC,gEAAgE;QAChE,oEAAoE;QACpE,2DAA2D;QAC3D,iEAAiE;QACjE,0DAA0D;QAC1D,+CAA+C;QAC/C,MAAMc,aACJC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBAAgB,UAAUT,OAAO;QAE5D,qBACE,qBAACU;YACCC,KAAI;YACJX,MAAME;YACN,aAAa;YACbI,YAAYA;YACZM,aAAapB,IAAIqB,UAAU,CAACD,WAAW;WAClCX;IAGX,KACA;IAEJ,MAAMN,UAAUC,UACZA,QAAQG,GAAG,CAAC,CAACC,qBACX,qBAACc;YACCC,KAAK,CAAC,EAAEvB,IAAIW,WAAW,CAAC,OAAO,EAAEC,IAAAA,4BAAa,EAC5CJ,MACA,EAAEK,IAAAA,wCAAmB,EAACb,KAAK,MAAM,CAAC;YACpCwB,OAAO;cAGX;IAEJ,MAAMC,OAAOC,IAAAA,8BAAc,EAAC,MAAM7B;IAElC,OAAO;QAAC4B;QAAMxB;QAAQE;KAAQ;AAChC"}
|
||||
25
node_modules/next/dist/server/app-render/create-component-tree.d.ts
generated
vendored
Normal file
25
node_modules/next/dist/server/app-render/create-component-tree.d.ts
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
import type { CacheNodeSeedData } from './types';
|
||||
import React from 'react';
|
||||
import type { LoaderTree } from '../lib/app-dir-module';
|
||||
import type { CreateSegmentPath, AppRenderContext } from './app-render';
|
||||
type Params = {
|
||||
[key: string]: string | string[];
|
||||
};
|
||||
/**
|
||||
* Use the provided loader tree to create the React Component tree.
|
||||
*/
|
||||
export declare function createComponentTree(props: {
|
||||
createSegmentPath: CreateSegmentPath;
|
||||
loaderTree: LoaderTree;
|
||||
parentParams: Params;
|
||||
rootLayoutIncluded: boolean;
|
||||
firstItem?: boolean;
|
||||
injectedCSS: Set<string>;
|
||||
injectedJS: Set<string>;
|
||||
injectedFontPreloadTags: Set<string>;
|
||||
asNotFound?: boolean;
|
||||
metadataOutlet?: React.ReactNode;
|
||||
ctx: AppRenderContext;
|
||||
missingSlots?: Set<string>;
|
||||
}): Promise<CacheNodeSeedData>;
|
||||
export {};
|
||||
455
node_modules/next/dist/server/app-render/create-component-tree.js
generated
vendored
Normal file
455
node_modules/next/dist/server/app-render/create-component-tree.js
generated
vendored
Normal file
@ -0,0 +1,455 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "createComponentTree", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return createComponentTree;
|
||||
}
|
||||
});
|
||||
const _jsxruntime = require("react/jsx-runtime");
|
||||
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
||||
const _clientreference = require("../../lib/client-reference");
|
||||
const _appdirmodule = require("../lib/app-dir-module");
|
||||
const _interopdefault = require("./interop-default");
|
||||
const _parseloadertree = require("./parse-loader-tree");
|
||||
const _createcomponentstylesandscripts = require("./create-component-styles-and-scripts");
|
||||
const _getlayerassets = require("./get-layer-assets");
|
||||
const _hasloadingcomponentintree = require("./has-loading-component-in-tree");
|
||||
const _patchfetch = require("../lib/patch-fetch");
|
||||
const _parallelroutedefault = require("../../client/components/parallel-route-default");
|
||||
const _tracer = require("../lib/trace/tracer");
|
||||
const _constants = require("../lib/trace/constants");
|
||||
const _staticgenerationbailout = require("../../client/components/static-generation-bailout");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function createComponentTree(props) {
|
||||
return (0, _tracer.getTracer)().trace(_constants.NextNodeServerSpan.createComponentTree, {
|
||||
spanName: "build component tree"
|
||||
}, ()=>createComponentTreeInternal(props));
|
||||
}
|
||||
async function createComponentTreeInternal({ createSegmentPath, loaderTree: tree, parentParams, firstItem, rootLayoutIncluded, injectedCSS, injectedJS, injectedFontPreloadTags, asNotFound, metadataOutlet, ctx, missingSlots }) {
|
||||
const { renderOpts: { nextConfigOutput, experimental }, staticGenerationStore, componentMod: { NotFoundBoundary, LayoutRouter, RenderFromTemplateContext, ClientPageRoot, createUntrackedSearchParams, createDynamicallyTrackedSearchParams, serverHooks: { DynamicServerError }, Postpone }, pagePath, getDynamicParamFromSegment, isPrefetch, query } = ctx;
|
||||
const { page, layoutOrPagePath, segment, components, parallelRoutes } = (0, _parseloadertree.parseLoaderTree)(tree);
|
||||
const { layout, template, error, loading, "not-found": notFound } = components;
|
||||
const injectedCSSWithCurrentLayout = new Set(injectedCSS);
|
||||
const injectedJSWithCurrentLayout = new Set(injectedJS);
|
||||
const injectedFontPreloadTagsWithCurrentLayout = new Set(injectedFontPreloadTags);
|
||||
const layerAssets = (0, _getlayerassets.getLayerAssets)({
|
||||
ctx,
|
||||
layoutOrPagePath,
|
||||
injectedCSS: injectedCSSWithCurrentLayout,
|
||||
injectedJS: injectedJSWithCurrentLayout,
|
||||
injectedFontPreloadTags: injectedFontPreloadTagsWithCurrentLayout
|
||||
});
|
||||
const [Template, templateStyles, templateScripts] = template ? await (0, _createcomponentstylesandscripts.createComponentStylesAndScripts)({
|
||||
ctx,
|
||||
filePath: template[1],
|
||||
getComponent: template[0],
|
||||
injectedCSS: injectedCSSWithCurrentLayout,
|
||||
injectedJS: injectedJSWithCurrentLayout
|
||||
}) : [
|
||||
_react.default.Fragment
|
||||
];
|
||||
const [ErrorComponent, errorStyles, errorScripts] = error ? await (0, _createcomponentstylesandscripts.createComponentStylesAndScripts)({
|
||||
ctx,
|
||||
filePath: error[1],
|
||||
getComponent: error[0],
|
||||
injectedCSS: injectedCSSWithCurrentLayout,
|
||||
injectedJS: injectedJSWithCurrentLayout
|
||||
}) : [];
|
||||
const [Loading, loadingStyles, loadingScripts] = loading ? await (0, _createcomponentstylesandscripts.createComponentStylesAndScripts)({
|
||||
ctx,
|
||||
filePath: loading[1],
|
||||
getComponent: loading[0],
|
||||
injectedCSS: injectedCSSWithCurrentLayout,
|
||||
injectedJS: injectedJSWithCurrentLayout
|
||||
}) : [];
|
||||
const isLayout = typeof layout !== "undefined";
|
||||
const isPage = typeof page !== "undefined";
|
||||
const [layoutOrPageMod] = await (0, _tracer.getTracer)().trace(_constants.NextNodeServerSpan.getLayoutOrPageModule, {
|
||||
hideSpan: !(isLayout || isPage),
|
||||
spanName: "resolve segment modules",
|
||||
attributes: {
|
||||
"next.segment": segment
|
||||
}
|
||||
}, ()=>(0, _appdirmodule.getLayoutOrPageModule)(tree));
|
||||
/**
|
||||
* Checks if the current segment is a root layout.
|
||||
*/ const rootLayoutAtThisLevel = isLayout && !rootLayoutIncluded;
|
||||
/**
|
||||
* Checks if the current segment or any level above it has a root layout.
|
||||
*/ const rootLayoutIncludedAtThisLevelOrAbove = rootLayoutIncluded || rootLayoutAtThisLevel;
|
||||
const [NotFound, notFoundStyles] = notFound ? await (0, _createcomponentstylesandscripts.createComponentStylesAndScripts)({
|
||||
ctx,
|
||||
filePath: notFound[1],
|
||||
getComponent: notFound[0],
|
||||
injectedCSS: injectedCSSWithCurrentLayout,
|
||||
injectedJS: injectedJSWithCurrentLayout
|
||||
}) : [];
|
||||
let dynamic = layoutOrPageMod == null ? void 0 : layoutOrPageMod.dynamic;
|
||||
if (nextConfigOutput === "export") {
|
||||
if (!dynamic || dynamic === "auto") {
|
||||
dynamic = "error";
|
||||
} else if (dynamic === "force-dynamic") {
|
||||
// force-dynamic is always incompatible with 'export'. We must interrupt the build
|
||||
throw new _staticgenerationbailout.StaticGenBailoutError(`Page with \`dynamic = "force-dynamic"\` couldn't be exported. \`output: "export"\` requires all pages be renderable statically because there is not runtime server to dynamic render routes in this output format. Learn more: https://nextjs.org/docs/app/building-your-application/deploying/static-exports`);
|
||||
}
|
||||
}
|
||||
if (typeof dynamic === "string") {
|
||||
// the nested most config wins so we only force-static
|
||||
// if it's configured above any parent that configured
|
||||
// otherwise
|
||||
if (dynamic === "error") {
|
||||
staticGenerationStore.dynamicShouldError = true;
|
||||
} else if (dynamic === "force-dynamic") {
|
||||
staticGenerationStore.forceDynamic = true;
|
||||
// TODO: (PPR) remove this bailout once PPR is the default
|
||||
if (staticGenerationStore.isStaticGeneration && !staticGenerationStore.prerenderState) {
|
||||
// If the postpone API isn't available, we can't postpone the render and
|
||||
// therefore we can't use the dynamic API.
|
||||
const err = new DynamicServerError(`Page with \`dynamic = "force-dynamic"\` won't be rendered statically.`);
|
||||
staticGenerationStore.dynamicUsageDescription = err.message;
|
||||
staticGenerationStore.dynamicUsageStack = err.stack;
|
||||
throw err;
|
||||
}
|
||||
} else {
|
||||
staticGenerationStore.dynamicShouldError = false;
|
||||
staticGenerationStore.forceStatic = dynamic === "force-static";
|
||||
}
|
||||
}
|
||||
if (typeof (layoutOrPageMod == null ? void 0 : layoutOrPageMod.fetchCache) === "string") {
|
||||
staticGenerationStore.fetchCache = layoutOrPageMod == null ? void 0 : layoutOrPageMod.fetchCache;
|
||||
}
|
||||
if (typeof (layoutOrPageMod == null ? void 0 : layoutOrPageMod.revalidate) !== "undefined") {
|
||||
(0, _patchfetch.validateRevalidate)(layoutOrPageMod == null ? void 0 : layoutOrPageMod.revalidate, staticGenerationStore.urlPathname);
|
||||
}
|
||||
if (typeof (layoutOrPageMod == null ? void 0 : layoutOrPageMod.revalidate) === "number") {
|
||||
ctx.defaultRevalidate = layoutOrPageMod.revalidate;
|
||||
if (typeof staticGenerationStore.revalidate === "undefined" || typeof staticGenerationStore.revalidate === "number" && staticGenerationStore.revalidate > ctx.defaultRevalidate) {
|
||||
staticGenerationStore.revalidate = ctx.defaultRevalidate;
|
||||
}
|
||||
if (!staticGenerationStore.forceStatic && staticGenerationStore.isStaticGeneration && ctx.defaultRevalidate === 0 && // If the postpone API isn't available, we can't postpone the render and
|
||||
// therefore we can't use the dynamic API.
|
||||
!staticGenerationStore.prerenderState) {
|
||||
const dynamicUsageDescription = `revalidate: 0 configured ${segment}`;
|
||||
staticGenerationStore.dynamicUsageDescription = dynamicUsageDescription;
|
||||
throw new DynamicServerError(dynamicUsageDescription);
|
||||
}
|
||||
}
|
||||
// If there's a dynamic usage error attached to the store, throw it.
|
||||
if (staticGenerationStore.dynamicUsageErr) {
|
||||
throw staticGenerationStore.dynamicUsageErr;
|
||||
}
|
||||
const LayoutOrPage = layoutOrPageMod ? await (0, _interopdefault.interopDefault)(layoutOrPageMod) : undefined;
|
||||
/**
|
||||
* The React Component to render.
|
||||
*/ let Component = LayoutOrPage;
|
||||
const parallelKeys = Object.keys(parallelRoutes);
|
||||
const hasSlotKey = parallelKeys.length > 1;
|
||||
// TODO-APP: This is a hack to support unmatched parallel routes, which will throw `notFound()`.
|
||||
// This ensures that a `NotFoundBoundary` is available for when that happens,
|
||||
// but it's not ideal, as it needlessly invokes the `NotFound` component and renders the `RootLayout` twice.
|
||||
// We should instead look into handling the fallback behavior differently in development mode so that it doesn't
|
||||
// rely on the `NotFound` behavior.
|
||||
if (hasSlotKey && rootLayoutAtThisLevel && LayoutOrPage) {
|
||||
Component = (componentProps)=>{
|
||||
const NotFoundComponent = NotFound;
|
||||
const RootLayoutComponent = LayoutOrPage;
|
||||
return /*#__PURE__*/ (0, _jsxruntime.jsx)(NotFoundBoundary, {
|
||||
notFound: NotFoundComponent ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
layerAssets,
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsxs)(RootLayoutComponent, {
|
||||
params: componentProps.params,
|
||||
children: [
|
||||
notFoundStyles,
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(NotFoundComponent, {})
|
||||
]
|
||||
})
|
||||
]
|
||||
}) : undefined,
|
||||
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(RootLayoutComponent, {
|
||||
...componentProps
|
||||
})
|
||||
});
|
||||
};
|
||||
}
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
const { isValidElementType } = require("next/dist/compiled/react-is");
|
||||
if ((isPage || typeof Component !== "undefined") && !isValidElementType(Component)) {
|
||||
throw new Error(`The default export is not a React Component in page: "${pagePath}"`);
|
||||
}
|
||||
if (typeof ErrorComponent !== "undefined" && !isValidElementType(ErrorComponent)) {
|
||||
throw new Error(`The default export of error is not a React Component in page: ${segment}`);
|
||||
}
|
||||
if (typeof Loading !== "undefined" && !isValidElementType(Loading)) {
|
||||
throw new Error(`The default export of loading is not a React Component in ${segment}`);
|
||||
}
|
||||
if (typeof NotFound !== "undefined" && !isValidElementType(NotFound)) {
|
||||
throw new Error(`The default export of notFound is not a React Component in ${segment}`);
|
||||
}
|
||||
}
|
||||
// Handle dynamic segment params.
|
||||
const segmentParam = getDynamicParamFromSegment(segment);
|
||||
/**
|
||||
* Create object holding the parent params and current params
|
||||
*/ const currentParams = // Handle null case where dynamic param is optional
|
||||
segmentParam && segmentParam.value !== null ? {
|
||||
...parentParams,
|
||||
[segmentParam.param]: segmentParam.value
|
||||
} : parentParams;
|
||||
// Resolve the segment param
|
||||
const actualSegment = segmentParam ? segmentParam.treeSegment : segment;
|
||||
//
|
||||
// TODO: Combine this `map` traversal with the loop below that turns the array
|
||||
// into an object.
|
||||
const parallelRouteMap = await Promise.all(Object.keys(parallelRoutes).map(async (parallelRouteKey)=>{
|
||||
const isChildrenRouteKey = parallelRouteKey === "children";
|
||||
const currentSegmentPath = firstItem ? [
|
||||
parallelRouteKey
|
||||
] : [
|
||||
actualSegment,
|
||||
parallelRouteKey
|
||||
];
|
||||
const parallelRoute = parallelRoutes[parallelRouteKey];
|
||||
const notFoundComponent = NotFound && isChildrenRouteKey ? /*#__PURE__*/ (0, _jsxruntime.jsx)(NotFound, {}) : undefined;
|
||||
// if we're prefetching and that there's a Loading component, we bail out
|
||||
// otherwise we keep rendering for the prefetch.
|
||||
// We also want to bail out if there's no Loading component in the tree.
|
||||
let childCacheNodeSeedData = null;
|
||||
if (// Before PPR, the way instant navigations work in Next.js is we
|
||||
// prefetch everything up to the first route segment that defines a
|
||||
// loading.tsx boundary. (We do the same if there's no loading
|
||||
// boundary in the entire tree, because we don't want to prefetch too
|
||||
// much) The rest of the tree is defered until the actual navigation.
|
||||
// It does not take into account whether the data is dynamic — even if
|
||||
// the tree is completely static, it will still defer everything
|
||||
// inside the loading boundary.
|
||||
//
|
||||
// This behavior predates PPR and is only relevant if the
|
||||
// PPR flag is not enabled.
|
||||
isPrefetch && (Loading || !(0, _hasloadingcomponentintree.hasLoadingComponentInTree)(parallelRoute)) && // The approach with PPR is different — loading.tsx behaves like a
|
||||
// regular Suspense boundary and has no special behavior.
|
||||
//
|
||||
// With PPR, we prefetch as deeply as possible, and only defer when
|
||||
// dynamic data is accessed. If so, we only defer the nearest parent
|
||||
// Suspense boundary of the dynamic data access, regardless of whether
|
||||
// the boundary is defined by loading.tsx or a normal <Suspense>
|
||||
// component in userspace.
|
||||
//
|
||||
// NOTE: In practice this usually means we'll end up prefetching more
|
||||
// than we were before PPR, which may or may not be considered a
|
||||
// performance regression by some apps. The plan is to address this
|
||||
// before General Availability of PPR by introducing granular
|
||||
// per-segment fetching, so we can reuse as much of the tree as
|
||||
// possible during both prefetches and dynamic navigations. But during
|
||||
// the beta period, we should be clear about this trade off in our
|
||||
// communications.
|
||||
!experimental.ppr) {
|
||||
// Don't prefetch this child. This will trigger a lazy fetch by the
|
||||
// client router.
|
||||
} else {
|
||||
// Create the child component
|
||||
if (process.env.NODE_ENV === "development" && missingSlots) {
|
||||
var _parsedTree_layoutOrPagePath;
|
||||
// When we detect the default fallback (which triggers a 404), we collect the missing slots
|
||||
// to provide more helpful debug information during development mode.
|
||||
const parsedTree = (0, _parseloadertree.parseLoaderTree)(parallelRoute);
|
||||
if ((_parsedTree_layoutOrPagePath = parsedTree.layoutOrPagePath) == null ? void 0 : _parsedTree_layoutOrPagePath.endsWith(_parallelroutedefault.PARALLEL_ROUTE_DEFAULT_PATH)) {
|
||||
missingSlots.add(parallelRouteKey);
|
||||
}
|
||||
}
|
||||
const seedData = await createComponentTreeInternal({
|
||||
createSegmentPath: (child)=>{
|
||||
return createSegmentPath([
|
||||
...currentSegmentPath,
|
||||
...child
|
||||
]);
|
||||
},
|
||||
loaderTree: parallelRoute,
|
||||
parentParams: currentParams,
|
||||
rootLayoutIncluded: rootLayoutIncludedAtThisLevelOrAbove,
|
||||
injectedCSS: injectedCSSWithCurrentLayout,
|
||||
injectedJS: injectedJSWithCurrentLayout,
|
||||
injectedFontPreloadTags: injectedFontPreloadTagsWithCurrentLayout,
|
||||
asNotFound,
|
||||
metadataOutlet,
|
||||
ctx,
|
||||
missingSlots
|
||||
});
|
||||
childCacheNodeSeedData = seedData;
|
||||
}
|
||||
// This is turned back into an object below.
|
||||
return [
|
||||
parallelRouteKey,
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(LayoutRouter, {
|
||||
parallelRouterKey: parallelRouteKey,
|
||||
segmentPath: createSegmentPath(currentSegmentPath),
|
||||
// TODO-APP: Add test for loading returning `undefined`. This currently can't be tested as the `webdriver()` tab will wait for the full page to load before returning.
|
||||
error: ErrorComponent,
|
||||
errorStyles: errorStyles,
|
||||
errorScripts: errorScripts,
|
||||
template: /*#__PURE__*/ (0, _jsxruntime.jsx)(Template, {
|
||||
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(RenderFromTemplateContext, {})
|
||||
}),
|
||||
templateStyles: templateStyles,
|
||||
templateScripts: templateScripts,
|
||||
notFound: notFoundComponent,
|
||||
notFoundStyles: notFoundStyles
|
||||
}),
|
||||
childCacheNodeSeedData
|
||||
];
|
||||
}));
|
||||
// Convert the parallel route map into an object after all promises have been resolved.
|
||||
let parallelRouteProps = {};
|
||||
let parallelRouteCacheNodeSeedData = {};
|
||||
for (const parallelRoute of parallelRouteMap){
|
||||
const [parallelRouteKey, parallelRouteProp, flightData] = parallelRoute;
|
||||
parallelRouteProps[parallelRouteKey] = parallelRouteProp;
|
||||
parallelRouteCacheNodeSeedData[parallelRouteKey] = flightData;
|
||||
}
|
||||
const loadingData = Loading ? [
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(Loading, {}),
|
||||
loadingStyles,
|
||||
loadingScripts
|
||||
] : null;
|
||||
// When the segment does not have a layout or page we still have to add the layout router to ensure the path holds the loading component
|
||||
if (!Component) {
|
||||
return [
|
||||
actualSegment,
|
||||
parallelRouteCacheNodeSeedData,
|
||||
// TODO: I don't think the extra fragment is necessary. React treats top
|
||||
// level fragments as transparent, i.e. the runtime behavior should be
|
||||
// identical even without it. But maybe there's some findDOMNode-related
|
||||
// reason that I'm not aware of, so I'm leaving it as-is out of extreme
|
||||
// caution, for now.
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
layerAssets,
|
||||
parallelRouteProps.children
|
||||
]
|
||||
}),
|
||||
loadingData
|
||||
];
|
||||
}
|
||||
// If force-dynamic is used and the current render supports postponing, we
|
||||
// replace it with a node that will postpone the render. This ensures that the
|
||||
// postpone is invoked during the react render phase and not during the next
|
||||
// render phase.
|
||||
// @TODO this does not actually do what it seems like it would or should do. The idea is that
|
||||
// if we are rendering in a force-dynamic mode and we can postpone we should only make the segments
|
||||
// that ask for force-dynamic to be dynamic, allowing other segments to still prerender. However
|
||||
// because this comes after the children traversal and the static generation store is mutated every segment
|
||||
// along the parent path of a force-dynamic segment will hit this condition effectively making the entire
|
||||
// render force-dynamic. We should refactor this function so that we can correctly track which segments
|
||||
// need to be dynamic
|
||||
if (staticGenerationStore.forceDynamic && staticGenerationStore.prerenderState) {
|
||||
return [
|
||||
actualSegment,
|
||||
parallelRouteCacheNodeSeedData,
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(Postpone, {
|
||||
prerenderState: staticGenerationStore.prerenderState,
|
||||
reason: 'dynamic = "force-dynamic" was used',
|
||||
pathname: staticGenerationStore.urlPathname
|
||||
}),
|
||||
layerAssets
|
||||
]
|
||||
}),
|
||||
loadingData
|
||||
];
|
||||
}
|
||||
const isClientComponent = (0, _clientreference.isClientReference)(layoutOrPageMod);
|
||||
// We avoid cloning this object because it gets consumed here exclusively.
|
||||
const props = parallelRouteProps;
|
||||
// If it's a not found route, and we don't have any matched parallel
|
||||
// routes, we try to render the not found component if it exists.
|
||||
if (NotFound && asNotFound && // In development, it could hit the parallel-route-default not found, so we only need to check the segment.
|
||||
// Or if there's no parallel routes means it reaches the end.
|
||||
!parallelRouteMap.length) {
|
||||
props.children = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)("meta", {
|
||||
name: "robots",
|
||||
content: "noindex"
|
||||
}),
|
||||
process.env.NODE_ENV === "development" && /*#__PURE__*/ (0, _jsxruntime.jsx)("meta", {
|
||||
name: "next-error",
|
||||
content: "not-found"
|
||||
}),
|
||||
notFoundStyles,
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(NotFound, {})
|
||||
]
|
||||
});
|
||||
}
|
||||
// Assign params to props
|
||||
if (process.env.NODE_ENV === "development" && "params" in parallelRouteProps) {
|
||||
// @TODO consider making this an error and running the check in build as well
|
||||
console.error(`"params" is a reserved prop in Layouts and Pages and cannot be used as the name of a parallel route in ${segment}`);
|
||||
}
|
||||
props.params = currentParams;
|
||||
let segmentElement;
|
||||
if (isPage) {
|
||||
// Assign searchParams to props if this is a page
|
||||
if (isClientComponent) {
|
||||
// When we are passing searchParams to a client component Page we don't want to track the dynamic access
|
||||
// here in the RSC layer because the serialization will trigger a dynamic API usage.
|
||||
// Instead we pass the searchParams untracked but we wrap the Page in a root client component
|
||||
// which can among other things adds the dynamic tracking before rendering the page.
|
||||
// @TODO make the root wrapper part of next-app-loader so we don't need the extra client component
|
||||
props.searchParams = createUntrackedSearchParams(query);
|
||||
segmentElement = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
metadataOutlet,
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(ClientPageRoot, {
|
||||
props: props,
|
||||
Component: Component
|
||||
}),
|
||||
layerAssets
|
||||
]
|
||||
});
|
||||
} else {
|
||||
// If we are passing searchParams to a server component Page we need to track their usage in case
|
||||
// the current render mode tracks dynamic API usage.
|
||||
props.searchParams = createDynamicallyTrackedSearchParams(query);
|
||||
segmentElement = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
metadataOutlet,
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(Component, {
|
||||
...props
|
||||
}),
|
||||
layerAssets
|
||||
]
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// For layouts we just render the component
|
||||
segmentElement = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
layerAssets,
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsx)(Component, {
|
||||
...props
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
return [
|
||||
actualSegment,
|
||||
parallelRouteCacheNodeSeedData,
|
||||
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
segmentElement,
|
||||
null
|
||||
]
|
||||
}),
|
||||
loadingData
|
||||
];
|
||||
}
|
||||
|
||||
//# sourceMappingURL=create-component-tree.js.map
|
||||
1
node_modules/next/dist/server/app-render/create-component-tree.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/create-component-tree.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
27
node_modules/next/dist/server/app-render/create-error-handler.d.ts
generated
vendored
Normal file
27
node_modules/next/dist/server/app-render/create-error-handler.d.ts
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
declare global {
|
||||
var __next_log_error__: undefined | ((err: unknown) => void);
|
||||
}
|
||||
export type ErrorHandler = (err: unknown, errorInfo: unknown) => string | undefined;
|
||||
export declare const ErrorHandlerSource: {
|
||||
readonly serverComponents: "serverComponents";
|
||||
readonly flightData: "flightData";
|
||||
readonly html: "html";
|
||||
};
|
||||
/**
|
||||
* 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, digestErrorsMap, allCapturedErrors, silenceLogger, }: {
|
||||
source: (typeof ErrorHandlerSource)[keyof typeof ErrorHandlerSource];
|
||||
dev?: boolean;
|
||||
isNextExport?: boolean;
|
||||
errorLogger?: (err: any) => Promise<void>;
|
||||
digestErrorsMap: Map<string, Error>;
|
||||
allCapturedErrors?: Error[];
|
||||
silenceLogger?: boolean;
|
||||
}): ErrorHandler;
|
||||
99
node_modules/next/dist/server/app-render/create-error-handler.js
generated
vendored
Normal file
99
node_modules/next/dist/server/app-render/create-error-handler.js
generated
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
ErrorHandlerSource: null,
|
||||
createErrorHandler: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
ErrorHandlerSource: function() {
|
||||
return ErrorHandlerSource;
|
||||
},
|
||||
createErrorHandler: function() {
|
||||
return createErrorHandler;
|
||||
}
|
||||
});
|
||||
const _stringhash = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/string-hash"));
|
||||
const _formatservererror = require("../../lib/format-server-error");
|
||||
const _tracer = require("../lib/trace/tracer");
|
||||
const _pipereadable = require("../pipe-readable");
|
||||
const _isdynamicusageerror = require("../../export/helpers/is-dynamic-usage-error");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const ErrorHandlerSource = {
|
||||
serverComponents: "serverComponents",
|
||||
flightData: "flightData",
|
||||
html: "html"
|
||||
};
|
||||
function createErrorHandler({ /**
|
||||
* Used for debugging
|
||||
*/ source, dev, isNextExport, errorLogger, digestErrorsMap, allCapturedErrors, silenceLogger }) {
|
||||
return (err, errorInfo)=>{
|
||||
var _err_message;
|
||||
// If the error already has a digest, respect the original digest,
|
||||
// so it won't get re-generated into another new error.
|
||||
if (!err.digest) {
|
||||
// TODO-APP: look at using webcrypto instead. Requires a promise to be awaited.
|
||||
err.digest = (0, _stringhash.default)(err.message + ((errorInfo == null ? void 0 : errorInfo.stack) || err.stack || "")).toString();
|
||||
}
|
||||
const digest = err.digest;
|
||||
if (allCapturedErrors) allCapturedErrors.push(err);
|
||||
// These errors are expected. We return the digest
|
||||
// so that they can be properly handled.
|
||||
if ((0, _isdynamicusageerror.isDynamicUsageError)(err)) return err.digest;
|
||||
// If the response was closed, we don't need to log the error.
|
||||
if ((0, _pipereadable.isAbortError)(err)) return;
|
||||
if (!digestErrorsMap.has(digest)) {
|
||||
digestErrorsMap.set(digest, err);
|
||||
} else if (source === ErrorHandlerSource.html) {
|
||||
// For SSR errors, if we have the existing digest in errors map,
|
||||
// we should use the existing error object to avoid duplicate error logs.
|
||||
err = digestErrorsMap.get(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 (!silenceLogger) {
|
||||
if (errorLogger) {
|
||||
errorLogger(err).catch(()=>{});
|
||||
} else {
|
||||
// The error logger is currently not provided in the edge runtime.
|
||||
// Use the exposed `__next_log_error__` instead.
|
||||
// This will trace error traces to the original source code.
|
||||
if (typeof __next_log_error__ === "function") {
|
||||
__next_log_error__(err);
|
||||
} else {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return err.digest;
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=create-error-handler.js.map
|
||||
1
node_modules/next/dist/server/app-render/create-error-handler.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/create-error-handler.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/create-error-handler.tsx"],"names":["ErrorHandlerSource","createErrorHandler","serverComponents","flightData","html","source","dev","isNextExport","errorLogger","digestErrorsMap","allCapturedErrors","silenceLogger","err","errorInfo","digest","stringHash","message","stack","toString","push","isDynamicUsageError","isAbortError","has","set","get","formatServerError","includes","span","getTracer","getActiveScopeSpan","recordException","setStatus","code","SpanStatusCode","ERROR","catch","__next_log_error__","console","error"],"mappings":";;;;;;;;;;;;;;;IAeaA,kBAAkB;eAAlBA;;IAWGC,kBAAkB;eAAlBA;;;mEA1BO;mCACW;wBACQ;8BACb;qCACO;;;;;;AAW7B,MAAMD,qBAAqB;IAChCE,kBAAkB;IAClBC,YAAY;IACZC,MAAM;AACR;AAOO,SAASH,mBAAmB,EACjC;;GAEC,GACDI,MAAM,EACNC,GAAG,EACHC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,iBAAiB,EACjBC,aAAa,EASd;IACC,OAAO,CAACC,KAAUC;YAsCZD;QArCJ,kEAAkE;QAClE,uDAAuD;QACvD,IAAI,CAACA,IAAIE,MAAM,EAAE;YACf,+EAA+E;YAC/EF,IAAIE,MAAM,GAAGC,IAAAA,mBAAU,EACrBH,IAAII,OAAO,GAAIH,CAAAA,CAAAA,6BAAAA,UAAWI,KAAK,KAAIL,IAAIK,KAAK,IAAI,EAAC,GACjDC,QAAQ;QACZ;QACA,MAAMJ,SAASF,IAAIE,MAAM;QAEzB,IAAIJ,mBAAmBA,kBAAkBS,IAAI,CAACP;QAE9C,kDAAkD;QAClD,wCAAwC;QACxC,IAAIQ,IAAAA,wCAAmB,EAACR,MAAM,OAAOA,IAAIE,MAAM;QAE/C,8DAA8D;QAC9D,IAAIO,IAAAA,0BAAY,EAACT,MAAM;QAEvB,IAAI,CAACH,gBAAgBa,GAAG,CAACR,SAAS;YAChCL,gBAAgBc,GAAG,CAACT,QAAQF;QAC9B,OAAO,IAAIP,WAAWL,mBAAmBI,IAAI,EAAE;YAC7C,gEAAgE;YAChE,yEAAyE;YACzEQ,MAAMH,gBAAgBe,GAAG,CAACV;QAC5B;QAEA,yEAAyE;QACzE,IAAIR,KAAK;YACPmB,IAAAA,oCAAiB,EAACb;QACpB;QACA,kCAAkC;QAClC,6BAA6B;QAC7B,+CAA+C;QAC/C,IACE,CACEL,CAAAA,iBACAK,wBAAAA,eAAAA,IAAKI,OAAO,qBAAZJ,aAAcc,QAAQ,CACpB,4FACF,GAEF;YACA,oDAAoD;YACpD,MAAMC,OAAOC,IAAAA,iBAAS,IAAGC,kBAAkB;YAC3C,IAAIF,MAAM;gBACRA,KAAKG,eAAe,CAAClB;gBACrBe,KAAKI,SAAS,CAAC;oBACbC,MAAMC,sBAAc,CAACC,KAAK;oBAC1BlB,SAASJ,IAAII,OAAO;gBACtB;YACF;YAEA,IAAI,CAACL,eAAe;gBAClB,IAAIH,aAAa;oBACfA,YAAYI,KAAKuB,KAAK,CAAC,KAAO;gBAChC,OAAO;oBACL,kEAAkE;oBAClE,gDAAgD;oBAChD,4DAA4D;oBAC5D,IAAI,OAAOC,uBAAuB,YAAY;wBAC5CA,mBAAmBxB;oBACrB,OAAO;wBACLyB,QAAQC,KAAK,CAAC1B;oBAChB;gBACF;YACF;QACF;QAEA,OAAOA,IAAIE,MAAM;IACnB;AACF"}
|
||||
5
node_modules/next/dist/server/app-render/create-flight-router-state-from-loader-tree.d.ts
generated
vendored
Normal file
5
node_modules/next/dist/server/app-render/create-flight-router-state-from-loader-tree.d.ts
generated
vendored
Normal 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" | "ci" | "oc" | "di"];
|
||||
export declare function createFlightRouterStateFromLoaderTree([segment, parallelRoutes, { layout }]: LoaderTree, getDynamicParamFromSegment: GetDynamicParamFromSegment, searchParams: any, rootLayoutIncluded?: boolean): FlightRouterState;
|
||||
50
node_modules/next/dist/server/app-render/create-flight-router-state-from-loader-tree.js
generated
vendored
Normal file
50
node_modules/next/dist/server/app-render/create-flight-router-state-from-loader-tree.js
generated
vendored
Normal 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 _segment = require("../../shared/lib/segment");
|
||||
function addSearchParamsIfPageSegment(segment, searchParams) {
|
||||
const isPageSegment = segment === _segment.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
|
||||
1
node_modules/next/dist/server/app-render/create-flight-router-state-from-loader-tree.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/create-flight-router-state-from-loader-tree.js.map
generated
vendored
Normal 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;;;yBAlBiB;AAE1B,SAASD,6BACdE,OAAgB,EAChBC,YAAiB;IAEjB,MAAMC,gBAAgBF,YAAYG,yBAAgB;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"}
|
||||
1
node_modules/next/dist/server/app-render/csrf-protection.d.ts
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/csrf-protection.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare const isCsrfOriginAllowed: (originDomain: string, allowedOrigins?: string[]) => boolean;
|
||||
90
node_modules/next/dist/server/app-render/csrf-protection.js
generated
vendored
Normal file
90
node_modules/next/dist/server/app-render/csrf-protection.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// micromatch is only available at node runtime, so it cannot be used here since the code path that calls this function
|
||||
// can be run from edge. This is a simple implementation that safely achieves the required functionality.
|
||||
// the goal is to match the functionality for remotePatterns as defined here -
|
||||
// https://nextjs.org/docs/app/api-reference/components/image#remotepatterns
|
||||
// TODO - retrofit micromatch to work in edge and use that instead
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "isCsrfOriginAllowed", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return isCsrfOriginAllowed;
|
||||
}
|
||||
});
|
||||
function matchWildcardDomain(domain, pattern) {
|
||||
const domainParts = domain.split(".");
|
||||
const patternParts = pattern.split(".");
|
||||
if (patternParts.length < 1) {
|
||||
// pattern is empty and therefore invalid to match against
|
||||
return false;
|
||||
}
|
||||
if (domainParts.length < patternParts.length) {
|
||||
// domain has too few segments and thus cannot match
|
||||
return false;
|
||||
}
|
||||
let depth = 0;
|
||||
while(patternParts.length && depth++ < 2){
|
||||
const patternPart = patternParts.pop();
|
||||
const domainPart = domainParts.pop();
|
||||
switch(patternPart){
|
||||
case "":
|
||||
case "*":
|
||||
case "**":
|
||||
{
|
||||
// invalid pattern. pattern segments must be non empty
|
||||
// Additionally wildcards are only supported below the domain level
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (domainPart !== patternPart) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while(patternParts.length){
|
||||
const patternPart = patternParts.pop();
|
||||
const domainPart = domainParts.pop();
|
||||
switch(patternPart){
|
||||
case "":
|
||||
{
|
||||
// invalid pattern. pattern segments must be non empty
|
||||
return false;
|
||||
}
|
||||
case "*":
|
||||
{
|
||||
// wildcard matches anything so we continue if the domain part is non-empty
|
||||
if (domainPart) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case "**":
|
||||
{
|
||||
// if this is not the last item in the pattern the pattern is invalid
|
||||
if (patternParts.length > 0) {
|
||||
return false;
|
||||
}
|
||||
// recursive wildcard matches anything so we terminate here if the domain part is non empty
|
||||
return domainPart !== undefined;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (domainPart !== patternPart) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// We exhausted the pattern. If we also exhausted the domain we have a match
|
||||
return domainParts.length === 0;
|
||||
}
|
||||
const isCsrfOriginAllowed = (originDomain, allowedOrigins = [])=>{
|
||||
return allowedOrigins.some((allowedOrigin)=>allowedOrigin && (allowedOrigin === originDomain || matchWildcardDomain(originDomain, allowedOrigin)));
|
||||
};
|
||||
|
||||
//# sourceMappingURL=csrf-protection.js.map
|
||||
1
node_modules/next/dist/server/app-render/csrf-protection.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/csrf-protection.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/csrf-protection.ts"],"names":["isCsrfOriginAllowed","matchWildcardDomain","domain","pattern","domainParts","split","patternParts","length","depth","patternPart","pop","domainPart","undefined","originDomain","allowedOrigins","some","allowedOrigin"],"mappings":"AAAA,uHAAuH;AACvH,yGAAyG;AACzG,8EAA8E;AAC9E,4EAA4E;AAC5E,kEAAkE;;;;;+BAyErDA;;;eAAAA;;;AAxEb,SAASC,oBAAoBC,MAAc,EAAEC,OAAe;IAC1D,MAAMC,cAAcF,OAAOG,KAAK,CAAC;IACjC,MAAMC,eAAeH,QAAQE,KAAK,CAAC;IAEnC,IAAIC,aAAaC,MAAM,GAAG,GAAG;QAC3B,0DAA0D;QAC1D,OAAO;IACT;IAEA,IAAIH,YAAYG,MAAM,GAAGD,aAAaC,MAAM,EAAE;QAC5C,oDAAoD;QACpD,OAAO;IACT;IAEA,IAAIC,QAAQ;IACZ,MAAOF,aAAaC,MAAM,IAAIC,UAAU,EAAG;QACzC,MAAMC,cAAcH,aAAaI,GAAG;QACpC,MAAMC,aAAaP,YAAYM,GAAG;QAElC,OAAQD;YACN,KAAK;YACL,KAAK;YACL,KAAK;gBAAM;oBACT,sDAAsD;oBACtD,mEAAmE;oBACnE,OAAO;gBACT;YACA;gBAAS;oBACP,IAAIE,eAAeF,aAAa;wBAC9B,OAAO;oBACT;gBACF;QACF;IACF;IAEA,MAAOH,aAAaC,MAAM,CAAE;QAC1B,MAAME,cAAcH,aAAaI,GAAG;QACpC,MAAMC,aAAaP,YAAYM,GAAG;QAElC,OAAQD;YACN,KAAK;gBAAI;oBACP,sDAAsD;oBACtD,OAAO;gBACT;YACA,KAAK;gBAAK;oBACR,2EAA2E;oBAC3E,IAAIE,YAAY;wBACd;oBACF,OAAO;wBACL,OAAO;oBACT;gBACF;YACA,KAAK;gBAAM;oBACT,qEAAqE;oBACrE,IAAIL,aAAaC,MAAM,GAAG,GAAG;wBAC3B,OAAO;oBACT;oBACA,2FAA2F;oBAC3F,OAAOI,eAAeC;gBACxB;YACA;gBAAS;oBACP,IAAID,eAAeF,aAAa;wBAC9B,OAAO;oBACT;gBACF;QACF;IACF;IAEA,4EAA4E;IAC5E,OAAOL,YAAYG,MAAM,KAAK;AAChC;AAEO,MAAMP,sBAAsB,CACjCa,cACAC,iBAA2B,EAAE;IAE7B,OAAOA,eAAeC,IAAI,CACxB,CAACC,gBACCA,iBACCA,CAAAA,kBAAkBH,gBACjBZ,oBAAoBY,cAAcG,cAAa;AAEvD"}
|
||||
1
node_modules/next/dist/server/app-render/csrf-protection.test.d.ts
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/csrf-protection.test.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
80
node_modules/next/dist/server/app-render/dynamic-rendering.d.ts
generated
vendored
Normal file
80
node_modules/next/dist/server/app-render/dynamic-rendering.d.ts
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
/**
|
||||
* The functions provided by this module are used to communicate certain properties
|
||||
* about the currently running code so that Next.js can make decisions on how to handle
|
||||
* the current execution in different rendering modes such as pre-rendering, resuming, and SSR.
|
||||
*
|
||||
* Today Next.js treats all code as potentially static. Certain APIs may only make sense when dynamically rendering.
|
||||
* Traditionally this meant deopting the entire render to dynamic however with PPR we can now deopt parts
|
||||
* of a React tree as dynamic while still keeping other parts static. There are really two different kinds of
|
||||
* Dynamic indications.
|
||||
*
|
||||
* The first is simply an intention to be dynamic. unstable_noStore is an example of this where
|
||||
* the currently executing code simply declares that the current scope is dynamic but if you use it
|
||||
* inside unstable_cache it can still be cached. This type of indication can be removed if we ever
|
||||
* make the default dynamic to begin with because the only way you would ever be static is inside
|
||||
* a cache scope which this indication does not affect.
|
||||
*
|
||||
* The second is an indication that a dynamic data source was read. This is a stronger form of dynamic
|
||||
* because it means that it is inappropriate to cache this at all. using a dynamic data source inside
|
||||
* unstable_cache should error. If you want to use some dynamic data inside unstable_cache you should
|
||||
* read that data outside the cache and pass it in as an argument to the cached function.
|
||||
*/
|
||||
import type { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external';
|
||||
type DynamicAccess = {
|
||||
/**
|
||||
* If debugging, this will contain the stack trace of where the dynamic access
|
||||
* occurred. This is used to provide more information to the user about why
|
||||
* their page is being rendered dynamically.
|
||||
*/
|
||||
stack?: string;
|
||||
/**
|
||||
* The expression that was accessed dynamically.
|
||||
*/
|
||||
expression: string;
|
||||
};
|
||||
export type PrerenderState = {
|
||||
/**
|
||||
* When true, stack information will also be tracked during dynamic access.
|
||||
*/
|
||||
readonly isDebugSkeleton: boolean | undefined;
|
||||
/**
|
||||
* The dynamic accesses that occurred during the render.
|
||||
*/
|
||||
readonly dynamicAccesses: DynamicAccess[];
|
||||
};
|
||||
export declare function createPrerenderState(isDebugSkeleton: boolean | undefined): PrerenderState;
|
||||
/**
|
||||
* This function communicates that the current scope should be treated as dynamic.
|
||||
*
|
||||
* In most cases this function is a no-op but if called during
|
||||
* a PPR prerender it will postpone the current sub-tree.
|
||||
*/
|
||||
export declare function markCurrentScopeAsDynamic(store: StaticGenerationStore, expression: string): void;
|
||||
/**
|
||||
* This function communicates that some dynamic data was read. This typically would refer to accessing
|
||||
* a Request specific data store such as cookies or headers. This function is not how end-users will
|
||||
* describe reading from dynamic data sources which are valid to cache and up to the author to make
|
||||
* a determination of when to do so.
|
||||
*
|
||||
* If we are inside a cache scope we error
|
||||
* Also during a PPR Prerender we postpone
|
||||
*/
|
||||
export declare function trackDynamicDataAccessed(store: StaticGenerationStore, expression: string): void;
|
||||
/**
|
||||
* This component will call `React.postpone` that throws the postponed error.
|
||||
*/
|
||||
type PostponeProps = {
|
||||
reason: string;
|
||||
prerenderState: PrerenderState;
|
||||
pathname: string;
|
||||
};
|
||||
export declare function Postpone({ reason, prerenderState, pathname, }: PostponeProps): never;
|
||||
export declare function trackDynamicFetch(store: StaticGenerationStore, expression: string): void;
|
||||
export declare function usedDynamicAPIs(prerenderState: PrerenderState): boolean;
|
||||
export declare function formatDynamicAPIAccesses(prerenderState: PrerenderState): string[];
|
||||
/**
|
||||
* This is a bit of a hack to allow us to abort a render using a Postpone instance instead of an Error which changes React's
|
||||
* abort semantics slightly.
|
||||
*/
|
||||
export declare function createPostponedAbortSignal(reason: string): AbortSignal;
|
||||
export {};
|
||||
195
node_modules/next/dist/server/app-render/dynamic-rendering.js
generated
vendored
Normal file
195
node_modules/next/dist/server/app-render/dynamic-rendering.js
generated
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
/**
|
||||
* The functions provided by this module are used to communicate certain properties
|
||||
* about the currently running code so that Next.js can make decisions on how to handle
|
||||
* the current execution in different rendering modes such as pre-rendering, resuming, and SSR.
|
||||
*
|
||||
* Today Next.js treats all code as potentially static. Certain APIs may only make sense when dynamically rendering.
|
||||
* Traditionally this meant deopting the entire render to dynamic however with PPR we can now deopt parts
|
||||
* of a React tree as dynamic while still keeping other parts static. There are really two different kinds of
|
||||
* Dynamic indications.
|
||||
*
|
||||
* The first is simply an intention to be dynamic. unstable_noStore is an example of this where
|
||||
* the currently executing code simply declares that the current scope is dynamic but if you use it
|
||||
* inside unstable_cache it can still be cached. This type of indication can be removed if we ever
|
||||
* make the default dynamic to begin with because the only way you would ever be static is inside
|
||||
* a cache scope which this indication does not affect.
|
||||
*
|
||||
* The second is an indication that a dynamic data source was read. This is a stronger form of dynamic
|
||||
* because it means that it is inappropriate to cache this at all. using a dynamic data source inside
|
||||
* unstable_cache should error. If you want to use some dynamic data inside unstable_cache you should
|
||||
* read that data outside the cache and pass it in as an argument to the cached function.
|
||||
*/ // Once postpone is in stable we should switch to importing the postpone export directly
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
Postpone: null,
|
||||
createPostponedAbortSignal: null,
|
||||
createPrerenderState: null,
|
||||
formatDynamicAPIAccesses: null,
|
||||
markCurrentScopeAsDynamic: null,
|
||||
trackDynamicDataAccessed: null,
|
||||
trackDynamicFetch: null,
|
||||
usedDynamicAPIs: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
Postpone: function() {
|
||||
return Postpone;
|
||||
},
|
||||
createPostponedAbortSignal: function() {
|
||||
return createPostponedAbortSignal;
|
||||
},
|
||||
createPrerenderState: function() {
|
||||
return createPrerenderState;
|
||||
},
|
||||
formatDynamicAPIAccesses: function() {
|
||||
return formatDynamicAPIAccesses;
|
||||
},
|
||||
markCurrentScopeAsDynamic: function() {
|
||||
return markCurrentScopeAsDynamic;
|
||||
},
|
||||
trackDynamicDataAccessed: function() {
|
||||
return trackDynamicDataAccessed;
|
||||
},
|
||||
trackDynamicFetch: function() {
|
||||
return trackDynamicFetch;
|
||||
},
|
||||
usedDynamicAPIs: function() {
|
||||
return usedDynamicAPIs;
|
||||
}
|
||||
});
|
||||
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
||||
const _hooksservercontext = require("../../client/components/hooks-server-context");
|
||||
const _staticgenerationbailout = require("../../client/components/static-generation-bailout");
|
||||
const _url = require("../../lib/url");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const hasPostpone = typeof _react.default.unstable_postpone === "function";
|
||||
function createPrerenderState(isDebugSkeleton) {
|
||||
return {
|
||||
isDebugSkeleton,
|
||||
dynamicAccesses: []
|
||||
};
|
||||
}
|
||||
function markCurrentScopeAsDynamic(store, expression) {
|
||||
const pathname = (0, _url.getPathname)(store.urlPathname);
|
||||
if (store.isUnstableCacheCallback) {
|
||||
// inside cache scopes marking a scope as dynamic has no effect because the outer cache scope
|
||||
// creates a cache boundary. This is subtly different from reading a dynamic data source which is
|
||||
// forbidden inside a cache scope.
|
||||
return;
|
||||
} else if (store.dynamicShouldError) {
|
||||
throw new _staticgenerationbailout.StaticGenBailoutError(`Route ${pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`);
|
||||
} else if (// We are in a prerender (PPR enabled, during build)
|
||||
store.prerenderState) {
|
||||
// We track that we had a dynamic scope that postponed.
|
||||
// This will be used by the renderer to decide whether
|
||||
// the prerender requires a resume
|
||||
postponeWithTracking(store.prerenderState, expression, pathname);
|
||||
} else {
|
||||
store.revalidate = 0;
|
||||
if (store.isStaticGeneration) {
|
||||
// We aren't prerendering but we are generating a static page. We need to bail out of static generation
|
||||
const err = new _hooksservercontext.DynamicServerError(`Route ${pathname} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`);
|
||||
store.dynamicUsageDescription = expression;
|
||||
store.dynamicUsageStack = err.stack;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
function trackDynamicDataAccessed(store, expression) {
|
||||
const pathname = (0, _url.getPathname)(store.urlPathname);
|
||||
if (store.isUnstableCacheCallback) {
|
||||
throw new Error(`Route ${pathname} used "${expression}" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "${expression}" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`);
|
||||
} else if (store.dynamicShouldError) {
|
||||
throw new _staticgenerationbailout.StaticGenBailoutError(`Route ${pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`);
|
||||
} else if (// We are in a prerender (PPR enabled, during build)
|
||||
store.prerenderState) {
|
||||
// We track that we had a dynamic scope that postponed.
|
||||
// This will be used by the renderer to decide whether
|
||||
// the prerender requires a resume
|
||||
postponeWithTracking(store.prerenderState, expression, pathname);
|
||||
} else {
|
||||
store.revalidate = 0;
|
||||
if (store.isStaticGeneration) {
|
||||
// We aren't prerendering but we are generating a static page. We need to bail out of static generation
|
||||
const err = new _hooksservercontext.DynamicServerError(`Route ${pathname} couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`);
|
||||
store.dynamicUsageDescription = expression;
|
||||
store.dynamicUsageStack = err.stack;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
function Postpone({ reason, prerenderState, pathname }) {
|
||||
postponeWithTracking(prerenderState, reason, pathname);
|
||||
}
|
||||
function trackDynamicFetch(store, expression) {
|
||||
if (store.prerenderState) {
|
||||
postponeWithTracking(store.prerenderState, expression, store.urlPathname);
|
||||
}
|
||||
}
|
||||
function postponeWithTracking(prerenderState, expression, pathname) {
|
||||
assertPostpone();
|
||||
const reason = `Route ${pathname} needs to bail out of prerendering at this point because it used ${expression}. ` + `React throws this special object to indicate where. It should not be caught by ` + `your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error`;
|
||||
prerenderState.dynamicAccesses.push({
|
||||
// When we aren't debugging, we don't need to create another error for the
|
||||
// stack trace.
|
||||
stack: prerenderState.isDebugSkeleton ? new Error().stack : undefined,
|
||||
expression
|
||||
});
|
||||
_react.default.unstable_postpone(reason);
|
||||
}
|
||||
function usedDynamicAPIs(prerenderState) {
|
||||
return prerenderState.dynamicAccesses.length > 0;
|
||||
}
|
||||
function formatDynamicAPIAccesses(prerenderState) {
|
||||
return prerenderState.dynamicAccesses.filter((access)=>typeof access.stack === "string" && access.stack.length > 0).map(({ expression, stack })=>{
|
||||
stack = stack.split("\n")// Remove the "Error: " prefix from the first line of the stack trace as
|
||||
// well as the first 4 lines of the stack trace which is the distance
|
||||
// from the user code and the `new Error().stack` call.
|
||||
.slice(4).filter((line)=>{
|
||||
// Exclude Next.js internals from the stack trace.
|
||||
if (line.includes("node_modules/next/")) {
|
||||
return false;
|
||||
}
|
||||
// Exclude anonymous functions from the stack trace.
|
||||
if (line.includes(" (<anonymous>)")) {
|
||||
return false;
|
||||
}
|
||||
// Exclude Node.js internals from the stack trace.
|
||||
if (line.includes(" (node:")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).join("\n");
|
||||
return `Dynamic API Usage Debug - ${expression}:\n${stack}`;
|
||||
});
|
||||
}
|
||||
function assertPostpone() {
|
||||
if (!hasPostpone) {
|
||||
throw new Error(`Invariant: React.unstable_postpone is not defined. This suggests the wrong version of React was loaded. This is a bug in Next.js`);
|
||||
}
|
||||
}
|
||||
function createPostponedAbortSignal(reason) {
|
||||
assertPostpone();
|
||||
const controller = new AbortController();
|
||||
// We get our hands on a postpone instance by calling postpone and catching the throw
|
||||
try {
|
||||
_react.default.unstable_postpone(reason);
|
||||
} catch (x) {
|
||||
controller.abort(x);
|
||||
}
|
||||
return controller.signal;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dynamic-rendering.js.map
|
||||
1
node_modules/next/dist/server/app-render/dynamic-rendering.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/dynamic-rendering.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/dynamic-rendering.ts"],"names":["Postpone","createPostponedAbortSignal","createPrerenderState","formatDynamicAPIAccesses","markCurrentScopeAsDynamic","trackDynamicDataAccessed","trackDynamicFetch","usedDynamicAPIs","hasPostpone","React","unstable_postpone","isDebugSkeleton","dynamicAccesses","store","expression","pathname","getPathname","urlPathname","isUnstableCacheCallback","dynamicShouldError","StaticGenBailoutError","prerenderState","postponeWithTracking","revalidate","isStaticGeneration","err","DynamicServerError","dynamicUsageDescription","dynamicUsageStack","stack","Error","reason","assertPostpone","push","undefined","length","filter","access","map","split","slice","line","includes","join","controller","AbortController","x","abort","signal"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;CAoBC,GAED,wFAAwF;;;;;;;;;;;;;;;;;;;;;;IAgJxEA,QAAQ;eAARA;;IAgGAC,0BAA0B;eAA1BA;;IA3MAC,oBAAoB;eAApBA;;IAyJAC,wBAAwB;eAAxBA;;IA1IAC,yBAAyB;eAAzBA;;IA+CAC,wBAAwB;eAAxBA;;IAyDAC,iBAAiB;eAAjBA;;IA8BAC,eAAe;eAAfA;;;8DAzLE;oCAGiB;yCACG;qBACV;;;;;;AAE5B,MAAMC,cAAc,OAAOC,cAAK,CAACC,iBAAiB,KAAK;AA6BhD,SAASR,qBACdS,eAAoC;IAEpC,OAAO;QACLA;QACAC,iBAAiB,EAAE;IACrB;AACF;AAQO,SAASR,0BACdS,KAA4B,EAC5BC,UAAkB;IAElB,MAAMC,WAAWC,IAAAA,gBAAW,EAACH,MAAMI,WAAW;IAC9C,IAAIJ,MAAMK,uBAAuB,EAAE;QACjC,6FAA6F;QAC7F,iGAAiG;QACjG,kCAAkC;QAClC;IACF,OAAO,IAAIL,MAAMM,kBAAkB,EAAE;QACnC,MAAM,IAAIC,8CAAqB,CAC7B,CAAC,MAAM,EAAEL,SAAS,8EAA8E,EAAED,WAAW,4HAA4H,CAAC;IAE9O,OAAO,IACL,oDAAoD;IACpDD,MAAMQ,cAAc,EACpB;QACA,uDAAuD;QACvD,sDAAsD;QACtD,kCAAkC;QAClCC,qBAAqBT,MAAMQ,cAAc,EAAEP,YAAYC;IACzD,OAAO;QACLF,MAAMU,UAAU,GAAG;QAEnB,IAAIV,MAAMW,kBAAkB,EAAE;YAC5B,uGAAuG;YACvG,MAAMC,MAAM,IAAIC,sCAAkB,CAChC,CAAC,MAAM,EAAEX,SAAS,iDAAiD,EAAED,WAAW,2EAA2E,CAAC;YAE9JD,MAAMc,uBAAuB,GAAGb;YAChCD,MAAMe,iBAAiB,GAAGH,IAAII,KAAK;YAEnC,MAAMJ;QACR;IACF;AACF;AAWO,SAASpB,yBACdQ,KAA4B,EAC5BC,UAAkB;IAElB,MAAMC,WAAWC,IAAAA,gBAAW,EAACH,MAAMI,WAAW;IAC9C,IAAIJ,MAAMK,uBAAuB,EAAE;QACjC,MAAM,IAAIY,MACR,CAAC,MAAM,EAAEf,SAAS,OAAO,EAAED,WAAW,iLAAiL,EAAEA,WAAW,6KAA6K,CAAC;IAEtZ,OAAO,IAAID,MAAMM,kBAAkB,EAAE;QACnC,MAAM,IAAIC,8CAAqB,CAC7B,CAAC,MAAM,EAAEL,SAAS,8EAA8E,EAAED,WAAW,4HAA4H,CAAC;IAE9O,OAAO,IACL,oDAAoD;IACpDD,MAAMQ,cAAc,EACpB;QACA,uDAAuD;QACvD,sDAAsD;QACtD,kCAAkC;QAClCC,qBAAqBT,MAAMQ,cAAc,EAAEP,YAAYC;IACzD,OAAO;QACLF,MAAMU,UAAU,GAAG;QAEnB,IAAIV,MAAMW,kBAAkB,EAAE;YAC5B,uGAAuG;YACvG,MAAMC,MAAM,IAAIC,sCAAkB,CAChC,CAAC,MAAM,EAAEX,SAAS,mDAAmD,EAAED,WAAW,6EAA6E,CAAC;YAElKD,MAAMc,uBAAuB,GAAGb;YAChCD,MAAMe,iBAAiB,GAAGH,IAAII,KAAK;YAEnC,MAAMJ;QACR;IACF;AACF;AAUO,SAASzB,SAAS,EACvB+B,MAAM,EACNV,cAAc,EACdN,QAAQ,EACM;IACdO,qBAAqBD,gBAAgBU,QAAQhB;AAC/C;AAMO,SAAST,kBACdO,KAA4B,EAC5BC,UAAkB;IAElB,IAAID,MAAMQ,cAAc,EAAE;QACxBC,qBAAqBT,MAAMQ,cAAc,EAAEP,YAAYD,MAAMI,WAAW;IAC1E;AACF;AAEA,SAASK,qBACPD,cAA8B,EAC9BP,UAAkB,EAClBC,QAAgB;IAEhBiB;IACA,MAAMD,SACJ,CAAC,MAAM,EAAEhB,SAAS,iEAAiE,EAAED,WAAW,EAAE,CAAC,GACnG,CAAC,+EAA+E,CAAC,GACjF,CAAC,iFAAiF,CAAC;IAErFO,eAAeT,eAAe,CAACqB,IAAI,CAAC;QAClC,0EAA0E;QAC1E,eAAe;QACfJ,OAAOR,eAAeV,eAAe,GAAG,IAAImB,QAAQD,KAAK,GAAGK;QAC5DpB;IACF;IAEAL,cAAK,CAACC,iBAAiB,CAACqB;AAC1B;AAEO,SAASxB,gBAAgBc,cAA8B;IAC5D,OAAOA,eAAeT,eAAe,CAACuB,MAAM,GAAG;AACjD;AAEO,SAAShC,yBACdkB,cAA8B;IAE9B,OAAOA,eAAeT,eAAe,CAClCwB,MAAM,CACL,CAACC,SACC,OAAOA,OAAOR,KAAK,KAAK,YAAYQ,OAAOR,KAAK,CAACM,MAAM,GAAG,GAE7DG,GAAG,CAAC,CAAC,EAAExB,UAAU,EAAEe,KAAK,EAAE;QACzBA,QAAQA,MACLU,KAAK,CAAC,KACP,wEAAwE;QACxE,qEAAqE;QACrE,uDAAuD;SACtDC,KAAK,CAAC,GACNJ,MAAM,CAAC,CAACK;YACP,kDAAkD;YAClD,IAAIA,KAAKC,QAAQ,CAAC,uBAAuB;gBACvC,OAAO;YACT;YAEA,oDAAoD;YACpD,IAAID,KAAKC,QAAQ,CAAC,mBAAmB;gBACnC,OAAO;YACT;YAEA,kDAAkD;YAClD,IAAID,KAAKC,QAAQ,CAAC,YAAY;gBAC5B,OAAO;YACT;YAEA,OAAO;QACT,GACCC,IAAI,CAAC;QACR,OAAO,CAAC,0BAA0B,EAAE7B,WAAW,GAAG,EAAEe,MAAM,CAAC;IAC7D;AACJ;AAEA,SAASG;IACP,IAAI,CAACxB,aAAa;QAChB,MAAM,IAAIsB,MACR,CAAC,gIAAgI,CAAC;IAEtI;AACF;AAMO,SAAS7B,2BAA2B8B,MAAc;IACvDC;IACA,MAAMY,aAAa,IAAIC;IACvB,qFAAqF;IACrF,IAAI;QACFpC,cAAK,CAACC,iBAAiB,CAACqB;IAC1B,EAAE,OAAOe,GAAY;QACnBF,WAAWG,KAAK,CAACD;IACnB;IACA,OAAOF,WAAWI,MAAM;AAC1B"}
|
||||
67
node_modules/next/dist/server/app-render/encryption-utils.d.ts
generated
vendored
Normal file
67
node_modules/next/dist/server/app-render/encryption-utils.d.ts
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
import type { ActionManifest } from '../../build/webpack/plugins/flight-client-entry-plugin';
|
||||
import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin';
|
||||
import type { DeepReadonly } from '../../shared/lib/deep-readonly';
|
||||
export declare function arrayBufferToString(buffer: ArrayBuffer): string;
|
||||
export declare function stringToUint8Array(binary: string): Uint8Array;
|
||||
export declare function encrypt(key: CryptoKey, iv: Uint8Array, data: Uint8Array): Promise<ArrayBuffer>;
|
||||
export declare function decrypt(key: CryptoKey, iv: Uint8Array, data: Uint8Array): Promise<ArrayBuffer>;
|
||||
export declare function generateEncryptionKeyBase64(dev?: boolean): Promise<string>;
|
||||
export declare function setReferenceManifestsSingleton({ clientReferenceManifest, serverActionsManifest, serverModuleMap, }: {
|
||||
clientReferenceManifest: DeepReadonly<ClientReferenceManifest>;
|
||||
serverActionsManifest: DeepReadonly<ActionManifest>;
|
||||
serverModuleMap: {
|
||||
[id: string]: {
|
||||
id: string;
|
||||
chunks: string[];
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
}): void;
|
||||
export declare function getServerModuleMap(): {
|
||||
[id: string]: {
|
||||
id: string;
|
||||
chunks: string[];
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
export declare function getClientReferenceManifestSingleton(): {
|
||||
readonly moduleLoading: {
|
||||
readonly prefix: string;
|
||||
readonly crossOrigin: string | null;
|
||||
};
|
||||
readonly clientModules: {
|
||||
readonly [x: string]: {
|
||||
readonly id: string | number;
|
||||
readonly name: string;
|
||||
readonly chunks: readonly string[];
|
||||
readonly async?: boolean | undefined;
|
||||
};
|
||||
};
|
||||
readonly ssrModuleMapping: {
|
||||
readonly [x: string]: {
|
||||
readonly [x: string]: {
|
||||
readonly id: string | number;
|
||||
readonly name: string;
|
||||
readonly chunks: readonly string[];
|
||||
readonly async?: boolean | undefined;
|
||||
};
|
||||
};
|
||||
};
|
||||
readonly edgeSSRModuleMapping: {
|
||||
readonly [x: string]: {
|
||||
readonly [x: string]: {
|
||||
readonly id: string | number;
|
||||
readonly name: string;
|
||||
readonly chunks: readonly string[];
|
||||
readonly async?: boolean | undefined;
|
||||
};
|
||||
};
|
||||
};
|
||||
readonly entryCSSFiles: {
|
||||
readonly [x: string]: readonly string[];
|
||||
};
|
||||
readonly entryJSFiles?: {
|
||||
readonly [x: string]: readonly string[];
|
||||
} | undefined;
|
||||
};
|
||||
export declare function getActionEncryptionKey(): Promise<CryptoKey>;
|
||||
174
node_modules/next/dist/server/app-render/encryption-utils.js
generated
vendored
Normal file
174
node_modules/next/dist/server/app-render/encryption-utils.js
generated
vendored
Normal file
@ -0,0 +1,174 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
arrayBufferToString: null,
|
||||
decrypt: null,
|
||||
encrypt: null,
|
||||
generateEncryptionKeyBase64: null,
|
||||
getActionEncryptionKey: null,
|
||||
getClientReferenceManifestSingleton: null,
|
||||
getServerModuleMap: null,
|
||||
setReferenceManifestsSingleton: null,
|
||||
stringToUint8Array: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
arrayBufferToString: function() {
|
||||
return arrayBufferToString;
|
||||
},
|
||||
decrypt: function() {
|
||||
return decrypt;
|
||||
},
|
||||
encrypt: function() {
|
||||
return encrypt;
|
||||
},
|
||||
generateEncryptionKeyBase64: function() {
|
||||
return generateEncryptionKeyBase64;
|
||||
},
|
||||
getActionEncryptionKey: function() {
|
||||
return getActionEncryptionKey;
|
||||
},
|
||||
getClientReferenceManifestSingleton: function() {
|
||||
return getClientReferenceManifestSingleton;
|
||||
},
|
||||
getServerModuleMap: function() {
|
||||
return getServerModuleMap;
|
||||
},
|
||||
setReferenceManifestsSingleton: function() {
|
||||
return setReferenceManifestsSingleton;
|
||||
},
|
||||
stringToUint8Array: function() {
|
||||
return stringToUint8Array;
|
||||
}
|
||||
});
|
||||
// Keep the key in memory as it should never change during the lifetime of the server in
|
||||
// both development and production.
|
||||
let __next_encryption_key_generation_promise = null;
|
||||
let __next_loaded_action_key;
|
||||
let __next_internal_development_raw_action_key;
|
||||
function arrayBufferToString(buffer) {
|
||||
const bytes = new Uint8Array(buffer);
|
||||
const len = bytes.byteLength;
|
||||
// @anonrig: V8 has a limit of 65535 arguments in a function.
|
||||
// For len < 65535, this is faster.
|
||||
// https://github.com/vercel/next.js/pull/56377#pullrequestreview-1656181623
|
||||
if (len < 65535) {
|
||||
return String.fromCharCode.apply(null, bytes);
|
||||
}
|
||||
let binary = "";
|
||||
for(let i = 0; i < len; i++){
|
||||
binary += String.fromCharCode(bytes[i]);
|
||||
}
|
||||
return binary;
|
||||
}
|
||||
function stringToUint8Array(binary) {
|
||||
const len = binary.length;
|
||||
const arr = new Uint8Array(len);
|
||||
for(let i = 0; i < len; i++){
|
||||
arr[i] = binary.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
function encrypt(key, iv, data) {
|
||||
return crypto.subtle.encrypt({
|
||||
name: "AES-GCM",
|
||||
iv
|
||||
}, key, data);
|
||||
}
|
||||
function decrypt(key, iv, data) {
|
||||
return crypto.subtle.decrypt({
|
||||
name: "AES-GCM",
|
||||
iv
|
||||
}, key, data);
|
||||
}
|
||||
async function generateEncryptionKeyBase64(dev) {
|
||||
// For development, we just keep one key in memory for all actions.
|
||||
// This makes things faster.
|
||||
if (dev) {
|
||||
if (typeof __next_internal_development_raw_action_key !== "undefined") {
|
||||
return __next_internal_development_raw_action_key;
|
||||
}
|
||||
}
|
||||
// This avoids it being generated multiple times in parallel.
|
||||
if (!__next_encryption_key_generation_promise) {
|
||||
__next_encryption_key_generation_promise = new Promise(async (resolve, reject)=>{
|
||||
try {
|
||||
const key = await crypto.subtle.generateKey({
|
||||
name: "AES-GCM",
|
||||
length: 256
|
||||
}, true, [
|
||||
"encrypt",
|
||||
"decrypt"
|
||||
]);
|
||||
const exported = await crypto.subtle.exportKey("raw", key);
|
||||
const b64 = btoa(arrayBufferToString(exported));
|
||||
resolve([
|
||||
key,
|
||||
b64
|
||||
]);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
const [key, b64] = await __next_encryption_key_generation_promise;
|
||||
__next_loaded_action_key = key;
|
||||
if (dev) {
|
||||
__next_internal_development_raw_action_key = b64;
|
||||
}
|
||||
return b64;
|
||||
}
|
||||
// This is a global singleton that is used to encode/decode the action bound args from
|
||||
// the closure. This can't be using a AsyncLocalStorage as it might happen on the module
|
||||
// level. Since the client reference manifest won't be mutated, let's use a global singleton
|
||||
// to keep it.
|
||||
const SERVER_ACTION_MANIFESTS_SINGLETON = Symbol.for("next.server.action-manifests");
|
||||
function setReferenceManifestsSingleton({ clientReferenceManifest, serverActionsManifest, serverModuleMap }) {
|
||||
// @ts-ignore
|
||||
globalThis[SERVER_ACTION_MANIFESTS_SINGLETON] = {
|
||||
clientReferenceManifest,
|
||||
serverActionsManifest,
|
||||
serverModuleMap
|
||||
};
|
||||
}
|
||||
function getServerModuleMap() {
|
||||
const serverActionsManifestSingleton = globalThis[SERVER_ACTION_MANIFESTS_SINGLETON];
|
||||
if (!serverActionsManifestSingleton) {
|
||||
throw new Error("Missing manifest for Server Actions. This is a bug in Next.js");
|
||||
}
|
||||
return serverActionsManifestSingleton.serverModuleMap;
|
||||
}
|
||||
function getClientReferenceManifestSingleton() {
|
||||
const serverActionsManifestSingleton = globalThis[SERVER_ACTION_MANIFESTS_SINGLETON];
|
||||
if (!serverActionsManifestSingleton) {
|
||||
throw new Error("Missing manifest for Server Actions. This is a bug in Next.js");
|
||||
}
|
||||
return serverActionsManifestSingleton.clientReferenceManifest;
|
||||
}
|
||||
async function getActionEncryptionKey() {
|
||||
if (__next_loaded_action_key) {
|
||||
return __next_loaded_action_key;
|
||||
}
|
||||
const serverActionsManifestSingleton = globalThis[SERVER_ACTION_MANIFESTS_SINGLETON];
|
||||
if (!serverActionsManifestSingleton) {
|
||||
throw new Error("Missing manifest for Server Actions. This is a bug in Next.js");
|
||||
}
|
||||
const rawKey = process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY || serverActionsManifestSingleton.serverActionsManifest.encryptionKey;
|
||||
if (rawKey === undefined) {
|
||||
throw new Error("Missing encryption key for Server Actions");
|
||||
}
|
||||
__next_loaded_action_key = await crypto.subtle.importKey("raw", stringToUint8Array(atob(rawKey)), "AES-GCM", true, [
|
||||
"encrypt",
|
||||
"decrypt"
|
||||
]);
|
||||
return __next_loaded_action_key;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=encryption-utils.js.map
|
||||
1
node_modules/next/dist/server/app-render/encryption-utils.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/encryption-utils.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/encryption-utils.ts"],"names":["arrayBufferToString","decrypt","encrypt","generateEncryptionKeyBase64","getActionEncryptionKey","getClientReferenceManifestSingleton","getServerModuleMap","setReferenceManifestsSingleton","stringToUint8Array","__next_encryption_key_generation_promise","__next_loaded_action_key","__next_internal_development_raw_action_key","buffer","bytes","Uint8Array","len","byteLength","String","fromCharCode","apply","binary","i","length","arr","charCodeAt","key","iv","data","crypto","subtle","name","dev","Promise","resolve","reject","generateKey","exported","exportKey","b64","btoa","error","SERVER_ACTION_MANIFESTS_SINGLETON","Symbol","for","clientReferenceManifest","serverActionsManifest","serverModuleMap","globalThis","serverActionsManifestSingleton","Error","rawKey","process","env","NEXT_SERVER_ACTIONS_ENCRYPTION_KEY","encryptionKey","undefined","importKey","atob"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAYgBA,mBAAmB;eAAnBA;;IAwCAC,OAAO;eAAPA;;IAXAC,OAAO;eAAPA;;IAsBMC,2BAA2B;eAA3BA;;IAiHAC,sBAAsB;eAAtBA;;IAjBNC,mCAAmC;eAAnCA;;IAtBAC,kBAAkB;eAAlBA;;IAvBAC,8BAA8B;eAA9BA;;IApFAC,kBAAkB;eAAlBA;;;AA1BhB,wFAAwF;AACxF,mCAAmC;AACnC,IAAIC,2CAEO;AACX,IAAIC;AACJ,IAAIC;AAEG,SAASX,oBAAoBY,MAAmB;IACrD,MAAMC,QAAQ,IAAIC,WAAWF;IAC7B,MAAMG,MAAMF,MAAMG,UAAU;IAE5B,6DAA6D;IAC7D,mCAAmC;IACnC,4EAA4E;IAC5E,IAAID,MAAM,OAAO;QACf,OAAOE,OAAOC,YAAY,CAACC,KAAK,CAAC,MAAMN;IACzC;IAEA,IAAIO,SAAS;IACb,IAAK,IAAIC,IAAI,GAAGA,IAAIN,KAAKM,IAAK;QAC5BD,UAAUH,OAAOC,YAAY,CAACL,KAAK,CAACQ,EAAE;IACxC;IACA,OAAOD;AACT;AAEO,SAASZ,mBAAmBY,MAAc;IAC/C,MAAML,MAAMK,OAAOE,MAAM;IACzB,MAAMC,MAAM,IAAIT,WAAWC;IAE3B,IAAK,IAAIM,IAAI,GAAGA,IAAIN,KAAKM,IAAK;QAC5BE,GAAG,CAACF,EAAE,GAAGD,OAAOI,UAAU,CAACH;IAC7B;IAEA,OAAOE;AACT;AAEO,SAASrB,QAAQuB,GAAc,EAAEC,EAAc,EAAEC,IAAgB;IACtE,OAAOC,OAAOC,MAAM,CAAC3B,OAAO,CAC1B;QACE4B,MAAM;QACNJ;IACF,GACAD,KACAE;AAEJ;AAEO,SAAS1B,QAAQwB,GAAc,EAAEC,EAAc,EAAEC,IAAgB;IACtE,OAAOC,OAAOC,MAAM,CAAC5B,OAAO,CAC1B;QACE6B,MAAM;QACNJ;IACF,GACAD,KACAE;AAEJ;AAEO,eAAexB,4BAA4B4B,GAAa;IAC7D,mEAAmE;IACnE,4BAA4B;IAC5B,IAAIA,KAAK;QACP,IAAI,OAAOpB,+CAA+C,aAAa;YACrE,OAAOA;QACT;IACF;IAEA,6DAA6D;IAC7D,IAAI,CAACF,0CAA0C;QAC7CA,2CAA2C,IAAIuB,QAC7C,OAAOC,SAASC;YACd,IAAI;gBACF,MAAMT,MAAM,MAAMG,OAAOC,MAAM,CAACM,WAAW,CACzC;oBACEL,MAAM;oBACNR,QAAQ;gBACV,GACA,MACA;oBAAC;oBAAW;iBAAU;gBAExB,MAAMc,WAAW,MAAMR,OAAOC,MAAM,CAACQ,SAAS,CAAC,OAAOZ;gBACtD,MAAMa,MAAMC,KAAKvC,oBAAoBoC;gBAErCH,QAAQ;oBAACR;oBAAKa;iBAAI;YACpB,EAAE,OAAOE,OAAO;gBACdN,OAAOM;YACT;QACF;IAEJ;IAEA,MAAM,CAACf,KAAKa,IAAI,GAAG,MAAM7B;IAEzBC,2BAA2Be;IAC3B,IAAIM,KAAK;QACPpB,6CAA6C2B;IAC/C;IAEA,OAAOA;AACT;AAEA,sFAAsF;AACtF,wFAAwF;AACxF,4FAA4F;AAC5F,cAAc;AACd,MAAMG,oCAAoCC,OAAOC,GAAG,CAClD;AAGK,SAASpC,+BAA+B,EAC7CqC,uBAAuB,EACvBC,qBAAqB,EACrBC,eAAe,EAWhB;IACC,aAAa;IACbC,UAAU,CAACN,kCAAkC,GAAG;QAC9CG;QACAC;QACAC;IACF;AACF;AAEO,SAASxC;IACd,MAAM0C,iCAAiC,AAACD,UAAkB,CACxDN,kCACD;IAUD,IAAI,CAACO,gCAAgC;QACnC,MAAM,IAAIC,MACR;IAEJ;IAEA,OAAOD,+BAA+BF,eAAe;AACvD;AAEO,SAASzC;IACd,MAAM2C,iCAAiC,AAACD,UAAkB,CACxDN,kCACD;IAKD,IAAI,CAACO,gCAAgC;QACnC,MAAM,IAAIC,MACR;IAEJ;IAEA,OAAOD,+BAA+BJ,uBAAuB;AAC/D;AAEO,eAAexC;IACpB,IAAIM,0BAA0B;QAC5B,OAAOA;IACT;IAEA,MAAMsC,iCAAiC,AAACD,UAAkB,CACxDN,kCACD;IAKD,IAAI,CAACO,gCAAgC;QACnC,MAAM,IAAIC,MACR;IAEJ;IAEA,MAAMC,SACJC,QAAQC,GAAG,CAACC,kCAAkC,IAC9CL,+BAA+BH,qBAAqB,CAACS,aAAa;IAEpE,IAAIJ,WAAWK,WAAW;QACxB,MAAM,IAAIN,MAAM;IAClB;IAEAvC,2BAA2B,MAAMkB,OAAOC,MAAM,CAAC2B,SAAS,CACtD,OACAhD,mBAAmBiD,KAAKP,UACxB,WACA,MACA;QAAC;QAAW;KAAU;IAGxB,OAAOxC;AACT"}
|
||||
3
node_modules/next/dist/server/app-render/encryption.d.ts
generated
vendored
Normal file
3
node_modules/next/dist/server/app-render/encryption.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import 'server-only';
|
||||
export declare function encryptActionBoundArgs(actionId: string, args: any[]): Promise<string>;
|
||||
export declare function decryptActionBoundArgs(actionId: string, encrypted: Promise<string>): Promise<any>;
|
||||
92
node_modules/next/dist/server/app-render/encryption.js
generated
vendored
Normal file
92
node_modules/next/dist/server/app-render/encryption.js
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */ "use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
decryptActionBoundArgs: null,
|
||||
encryptActionBoundArgs: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
decryptActionBoundArgs: function() {
|
||||
return decryptActionBoundArgs;
|
||||
},
|
||||
encryptActionBoundArgs: function() {
|
||||
return encryptActionBoundArgs;
|
||||
}
|
||||
});
|
||||
require("server-only");
|
||||
const _serveredge = require("react-server-dom-webpack/server.edge");
|
||||
const _clientedge = require("react-server-dom-webpack/client.edge");
|
||||
const _nodewebstreamshelper = require("../stream-utils/node-web-streams-helper");
|
||||
const _encryptionutils = require("./encryption-utils");
|
||||
const textEncoder = new TextEncoder();
|
||||
const textDecoder = new TextDecoder();
|
||||
async function decodeActionBoundArg(actionId, arg) {
|
||||
const key = await (0, _encryptionutils.getActionEncryptionKey)();
|
||||
if (typeof key === "undefined") {
|
||||
throw new Error(`Missing encryption key for Server Action. This is a bug in Next.js`);
|
||||
}
|
||||
// Get the iv (16 bytes) and the payload from the arg.
|
||||
const originalPayload = atob(arg);
|
||||
const ivValue = originalPayload.slice(0, 16);
|
||||
const payload = originalPayload.slice(16);
|
||||
const decrypted = textDecoder.decode(await (0, _encryptionutils.decrypt)(key, (0, _encryptionutils.stringToUint8Array)(ivValue), (0, _encryptionutils.stringToUint8Array)(payload)));
|
||||
if (!decrypted.startsWith(actionId)) {
|
||||
throw new Error("Invalid Server Action payload: failed to decrypt.");
|
||||
}
|
||||
return decrypted.slice(actionId.length);
|
||||
}
|
||||
async function encodeActionBoundArg(actionId, arg) {
|
||||
const key = await (0, _encryptionutils.getActionEncryptionKey)();
|
||||
if (key === undefined) {
|
||||
throw new Error(`Missing encryption key for Server Action. This is a bug in Next.js`);
|
||||
}
|
||||
// Get 16 random bytes as iv.
|
||||
const randomBytes = new Uint8Array(16);
|
||||
crypto.getRandomValues(randomBytes);
|
||||
const ivValue = (0, _encryptionutils.arrayBufferToString)(randomBytes.buffer);
|
||||
const encrypted = await (0, _encryptionutils.encrypt)(key, randomBytes, textEncoder.encode(actionId + arg));
|
||||
return btoa(ivValue + (0, _encryptionutils.arrayBufferToString)(encrypted));
|
||||
}
|
||||
async function encryptActionBoundArgs(actionId, args) {
|
||||
const clientReferenceManifestSingleton = (0, _encryptionutils.getClientReferenceManifestSingleton)();
|
||||
// Using Flight to serialize the args into a string.
|
||||
const serialized = await (0, _nodewebstreamshelper.streamToString)((0, _serveredge.renderToReadableStream)(args, clientReferenceManifestSingleton.clientModules));
|
||||
// Encrypt the serialized string with the action id as the salt.
|
||||
// Add a prefix to later ensure that the payload is correctly decrypted, similar
|
||||
// to a checksum.
|
||||
const encrypted = await encodeActionBoundArg(actionId, serialized);
|
||||
return encrypted;
|
||||
}
|
||||
async function decryptActionBoundArgs(actionId, encrypted) {
|
||||
// Decrypt the serialized string with the action id as the salt.
|
||||
const decryped = await decodeActionBoundArg(actionId, await encrypted);
|
||||
// Using Flight to deserialize the args from the string.
|
||||
const deserialized = await (0, _clientedge.createFromReadableStream)(new ReadableStream({
|
||||
start (controller) {
|
||||
controller.enqueue(textEncoder.encode(decryped));
|
||||
controller.close();
|
||||
}
|
||||
}), {
|
||||
ssrManifest: {
|
||||
// TODO: We can't use the client reference manifest to resolve the modules
|
||||
// on the server side - instead they need to be recovered as the module
|
||||
// references (proxies) again.
|
||||
// For now, we'll just use an empty module map.
|
||||
moduleLoading: {},
|
||||
moduleMap: {}
|
||||
}
|
||||
});
|
||||
// This extra step ensures that the server references are recovered.
|
||||
const serverModuleMap = (0, _encryptionutils.getServerModuleMap)();
|
||||
const transformed = await (0, _serveredge.decodeReply)(await (0, _clientedge.encodeReply)(deserialized), serverModuleMap);
|
||||
return transformed;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=encryption.js.map
|
||||
1
node_modules/next/dist/server/app-render/encryption.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/encryption.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/encryption.ts"],"names":["decryptActionBoundArgs","encryptActionBoundArgs","textEncoder","TextEncoder","textDecoder","TextDecoder","decodeActionBoundArg","actionId","arg","key","getActionEncryptionKey","Error","originalPayload","atob","ivValue","slice","payload","decrypted","decode","decrypt","stringToUint8Array","startsWith","length","encodeActionBoundArg","undefined","randomBytes","Uint8Array","crypto","getRandomValues","arrayBufferToString","buffer","encrypted","encrypt","encode","btoa","args","clientReferenceManifestSingleton","getClientReferenceManifestSingleton","serialized","streamToString","renderToReadableStream","clientModules","decryped","deserialized","createFromReadableStream","ReadableStream","start","controller","enqueue","close","ssrManifest","moduleLoading","moduleMap","serverModuleMap","getServerModuleMap","transformed","decodeReply","encodeReply"],"mappings":"AAAA,oDAAoD;;;;;;;;;;;;;;;IA4F9BA,sBAAsB;eAAtBA;;IAjBAC,sBAAsB;eAAtBA;;;QA1Ef;4BAMA;4BAKA;sCAEwB;iCASxB;AAEP,MAAMC,cAAc,IAAIC;AACxB,MAAMC,cAAc,IAAIC;AAExB,eAAeC,qBAAqBC,QAAgB,EAAEC,GAAW;IAC/D,MAAMC,MAAM,MAAMC,IAAAA,uCAAsB;IACxC,IAAI,OAAOD,QAAQ,aAAa;QAC9B,MAAM,IAAIE,MACR,CAAC,kEAAkE,CAAC;IAExE;IAEA,sDAAsD;IACtD,MAAMC,kBAAkBC,KAAKL;IAC7B,MAAMM,UAAUF,gBAAgBG,KAAK,CAAC,GAAG;IACzC,MAAMC,UAAUJ,gBAAgBG,KAAK,CAAC;IAEtC,MAAME,YAAYb,YAAYc,MAAM,CAClC,MAAMC,IAAAA,wBAAO,EAACV,KAAKW,IAAAA,mCAAkB,EAACN,UAAUM,IAAAA,mCAAkB,EAACJ;IAGrE,IAAI,CAACC,UAAUI,UAAU,CAACd,WAAW;QACnC,MAAM,IAAII,MAAM;IAClB;IAEA,OAAOM,UAAUF,KAAK,CAACR,SAASe,MAAM;AACxC;AAEA,eAAeC,qBAAqBhB,QAAgB,EAAEC,GAAW;IAC/D,MAAMC,MAAM,MAAMC,IAAAA,uCAAsB;IACxC,IAAID,QAAQe,WAAW;QACrB,MAAM,IAAIb,MACR,CAAC,kEAAkE,CAAC;IAExE;IAEA,6BAA6B;IAC7B,MAAMc,cAAc,IAAIC,WAAW;IACnCC,OAAOC,eAAe,CAACH;IACvB,MAAMX,UAAUe,IAAAA,oCAAmB,EAACJ,YAAYK,MAAM;IAEtD,MAAMC,YAAY,MAAMC,IAAAA,wBAAO,EAC7BvB,KACAgB,aACAvB,YAAY+B,MAAM,CAAC1B,WAAWC;IAGhC,OAAO0B,KAAKpB,UAAUe,IAAAA,oCAAmB,EAACE;AAC5C;AAGO,eAAe9B,uBAAuBM,QAAgB,EAAE4B,IAAW;IACxE,MAAMC,mCAAmCC,IAAAA,oDAAmC;IAE5E,oDAAoD;IACpD,MAAMC,aAAa,MAAMC,IAAAA,oCAAc,EACrCC,IAAAA,kCAAsB,EAACL,MAAMC,iCAAiCK,aAAa;IAG7E,gEAAgE;IAChE,gFAAgF;IAChF,iBAAiB;IACjB,MAAMV,YAAY,MAAMR,qBAAqBhB,UAAU+B;IAEvD,OAAOP;AACT;AAGO,eAAe/B,uBACpBO,QAAgB,EAChBwB,SAA0B;IAE1B,gEAAgE;IAChE,MAAMW,WAAW,MAAMpC,qBAAqBC,UAAU,MAAMwB;IAE5D,wDAAwD;IACxD,MAAMY,eAAe,MAAMC,IAAAA,oCAAwB,EACjD,IAAIC,eAAe;QACjBC,OAAMC,UAAU;YACdA,WAAWC,OAAO,CAAC9C,YAAY+B,MAAM,CAACS;YACtCK,WAAWE,KAAK;QAClB;IACF,IACA;QACEC,aAAa;YACX,0EAA0E;YAC1E,uEAAuE;YACvE,8BAA8B;YAC9B,+CAA+C;YAC/CC,eAAe,CAAC;YAChBC,WAAW,CAAC;QACd;IACF;IAGF,oEAAoE;IACpE,MAAMC,kBAAkBC,IAAAA,mCAAkB;IAC1C,MAAMC,cAAc,MAAMC,IAAAA,uBAAW,EACnC,MAAMC,IAAAA,uBAAW,EAACd,eAClBU;IAGF,OAAOE;AACT"}
|
||||
17
node_modules/next/dist/server/app-render/entry-base.d.ts
generated
vendored
Normal file
17
node_modules/next/dist/server/app-render/entry-base.d.ts
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
export { renderToReadableStream, decodeReply, decodeAction, decodeFormState, } from 'react-server-dom-webpack/server.edge';
|
||||
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 { ClientPageRoot } from '../../client/components/client-page';
|
||||
import { createUntrackedSearchParams, createDynamicallyTrackedSearchParams } from '../../client/components/search-params';
|
||||
import * as serverHooks from '../../client/components/hooks-server-context';
|
||||
import { NotFoundBoundary } from '../../client/components/not-found-boundary';
|
||||
import '../../client/components/error-boundary';
|
||||
import { preloadStyle, preloadFont, preconnect } from '../../server/app-render/rsc/preloads';
|
||||
import { Postpone } from '../../server/app-render/rsc/postpone';
|
||||
import { taintObjectReference } from '../../server/app-render/rsc/taint';
|
||||
declare function patchFetch(): void;
|
||||
export { AppRouter, LayoutRouter, RenderFromTemplateContext, staticGenerationAsyncStorage, requestAsyncStorage, actionAsyncStorage, createUntrackedSearchParams, createDynamicallyTrackedSearchParams, serverHooks, preloadStyle, preloadFont, preconnect, Postpone, taintObjectReference, ClientPageRoot, NotFoundBoundary, patchFetch, };
|
||||
171
node_modules/next/dist/server/app-render/entry-base.js
generated
vendored
Normal file
171
node_modules/next/dist/server/app-render/entry-base.js
generated
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
AppRouter: null,
|
||||
ClientPageRoot: null,
|
||||
LayoutRouter: null,
|
||||
NotFoundBoundary: null,
|
||||
Postpone: null,
|
||||
RenderFromTemplateContext: null,
|
||||
actionAsyncStorage: null,
|
||||
createDynamicallyTrackedSearchParams: null,
|
||||
createUntrackedSearchParams: null,
|
||||
decodeAction: null,
|
||||
decodeFormState: null,
|
||||
decodeReply: null,
|
||||
patchFetch: null,
|
||||
preconnect: null,
|
||||
preloadFont: null,
|
||||
preloadStyle: null,
|
||||
renderToReadableStream: null,
|
||||
requestAsyncStorage: null,
|
||||
serverHooks: null,
|
||||
staticGenerationAsyncStorage: null,
|
||||
taintObjectReference: 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;
|
||||
},
|
||||
ClientPageRoot: function() {
|
||||
return _clientpage.ClientPageRoot;
|
||||
},
|
||||
LayoutRouter: function() {
|
||||
return _layoutrouter.default;
|
||||
},
|
||||
NotFoundBoundary: function() {
|
||||
return _notfoundboundary.NotFoundBoundary;
|
||||
},
|
||||
Postpone: function() {
|
||||
return _postpone.Postpone;
|
||||
},
|
||||
RenderFromTemplateContext: function() {
|
||||
return _renderfromtemplatecontext.default;
|
||||
},
|
||||
actionAsyncStorage: function() {
|
||||
return _actionasyncstorageexternal.actionAsyncStorage;
|
||||
},
|
||||
createDynamicallyTrackedSearchParams: function() {
|
||||
return _searchparams.createDynamicallyTrackedSearchParams;
|
||||
},
|
||||
createUntrackedSearchParams: function() {
|
||||
return _searchparams.createUntrackedSearchParams;
|
||||
},
|
||||
decodeAction: function() {
|
||||
return _serveredge.decodeAction;
|
||||
},
|
||||
decodeFormState: function() {
|
||||
return _serveredge.decodeFormState;
|
||||
},
|
||||
decodeReply: function() {
|
||||
return _serveredge.decodeReply;
|
||||
},
|
||||
patchFetch: function() {
|
||||
return patchFetch;
|
||||
},
|
||||
preconnect: function() {
|
||||
return _preloads.preconnect;
|
||||
},
|
||||
preloadFont: function() {
|
||||
return _preloads.preloadFont;
|
||||
},
|
||||
preloadStyle: function() {
|
||||
return _preloads.preloadStyle;
|
||||
},
|
||||
renderToReadableStream: function() {
|
||||
return _serveredge.renderToReadableStream;
|
||||
},
|
||||
requestAsyncStorage: function() {
|
||||
return _requestasyncstorageexternal.requestAsyncStorage;
|
||||
},
|
||||
serverHooks: function() {
|
||||
return _hooksservercontext;
|
||||
},
|
||||
staticGenerationAsyncStorage: function() {
|
||||
return _staticgenerationasyncstorageexternal.staticGenerationAsyncStorage;
|
||||
},
|
||||
taintObjectReference: function() {
|
||||
return _taint.taintObjectReference;
|
||||
}
|
||||
});
|
||||
const _serveredge = require("react-server-dom-webpack/server.edge");
|
||||
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 _clientpage = require("../../client/components/client-page");
|
||||
const _searchparams = require("../../client/components/search-params");
|
||||
const _hooksservercontext = /*#__PURE__*/ _interop_require_wildcard(require("../../client/components/hooks-server-context"));
|
||||
const _notfoundboundary = require("../../client/components/not-found-boundary");
|
||||
const _patchfetch = require("../lib/patch-fetch");
|
||||
require("../../client/components/error-boundary");
|
||||
const _preloads = require("../../server/app-render/rsc/preloads");
|
||||
const _postpone = require("../../server/app-render/rsc/postpone");
|
||||
const _taint = require("../../server/app-render/rsc/taint");
|
||||
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 = {
|
||||
__proto__: null
|
||||
};
|
||||
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;
|
||||
}
|
||||
// patchFetch makes use of APIs such as `React.unstable_postpone` which are only available
|
||||
// in the experimental channel of React, so export it from here so that it comes from the bundled runtime
|
||||
function patchFetch() {
|
||||
return (0, _patchfetch.patchFetch)({
|
||||
serverHooks: _hooksservercontext,
|
||||
staticGenerationAsyncStorage: _staticgenerationasyncstorageexternal.staticGenerationAsyncStorage
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=entry-base.js.map
|
||||
1
node_modules/next/dist/server/app-render/entry-base.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/entry-base.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/entry-base.ts"],"names":["AppRouter","ClientPageRoot","LayoutRouter","NotFoundBoundary","Postpone","RenderFromTemplateContext","actionAsyncStorage","createDynamicallyTrackedSearchParams","createUntrackedSearchParams","decodeAction","decodeFormState","decodeReply","patchFetch","preconnect","preloadFont","preloadStyle","renderToReadableStream","requestAsyncStorage","serverHooks","staticGenerationAsyncStorage","taintObjectReference","_patchFetch"],"mappings":"AAAA,6DAA6D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwC3DA,SAAS;eAATA,kBAAS;;IAcTC,cAAc;eAAdA,0BAAc;;IAbdC,YAAY;eAAZA,qBAAY;;IAcZC,gBAAgB;eAAhBA,kCAAgB;;IAHhBC,QAAQ;eAARA,kBAAQ;;IAVRC,yBAAyB;eAAzBA,kCAAyB;;IAGzBC,kBAAkB;eAAlBA,8CAAkB;;IAElBC,oCAAoC;eAApCA,kDAAoC;;IADpCC,2BAA2B;eAA3BA,yCAA2B;;IA1C3BC,YAAY;eAAZA,wBAAY;;IACZC,eAAe;eAAfA,2BAAe;;IAFfC,WAAW;eAAXA,uBAAW;;IAqDXC,UAAU;eAAVA;;IALAC,UAAU;eAAVA,oBAAU;;IADVC,WAAW;eAAXA,qBAAW;;IADXC,YAAY;eAAZA,sBAAY;;IA/CZC,sBAAsB;eAAtBA,kCAAsB;;IA0CtBC,mBAAmB;eAAnBA,gDAAmB;;IAInBC,WAAW;eAAXA;;IALAC,4BAA4B;eAA5BA,kEAA4B;;IAU5BC,oBAAoB;eAApBA,2BAAoB;;;4BA/Cf;kEAEe;qEACG;kFACa;sDACO;6CACT;4CACD;4BACJ;8BAIxB;4EACsB;kCACI;4BACS;QAEnC;0BAMA;0BACkB;uBACY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErC,0FAA0F;AAC1F,yGAAyG;AACzG,SAASR;IACP,OAAOS,IAAAA,sBAAW,EAAC;QAAEH,aAAAA;QAAaC,8BAAAA,kEAA4B;IAAC;AACjE"}
|
||||
7
node_modules/next/dist/server/app-render/flight-render-result.d.ts
generated
vendored
Normal file
7
node_modules/next/dist/server/app-render/flight-render-result.d.ts
generated
vendored
Normal 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>);
|
||||
}
|
||||
27
node_modules/next/dist/server/app-render/flight-render-result.js
generated
vendored
Normal file
27
node_modules/next/dist/server/app-render/flight-render-result.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
"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,
|
||||
metadata: {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=flight-render-result.js.map
|
||||
1
node_modules/next/dist/server/app-render/flight-render-result.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/flight-render-result.js.map
generated
vendored
Normal 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","metadata"],"mappings":";;;;+BAMaA;;;eAAAA;;;kCAN2B;qEACf;;;;;;AAKlB,MAAMA,2BAA2BC,qBAAY;IAClDC,YAAYC,QAA6C,CAAE;QACzD,KAAK,CAACA,UAAU;YAAEC,aAAaC,yCAAuB;YAAEC,UAAU,CAAC;QAAE;IACvE;AACF"}
|
||||
2
node_modules/next/dist/server/app-render/get-asset-query-string.d.ts
generated
vendored
Normal file
2
node_modules/next/dist/server/app-render/get-asset-query-string.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import type { AppRenderContext } from './app-render';
|
||||
export declare function getAssetQueryString(ctx: AppRenderContext, addTimestamp: boolean): string;
|
||||
28
node_modules/next/dist/server/app-render/get-asset-query-string.js
generated
vendored
Normal file
28
node_modules/next/dist/server/app-render/get-asset-query-string.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getAssetQueryString", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getAssetQueryString;
|
||||
}
|
||||
});
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
const isTurbopack = !!process.env.TURBOPACK;
|
||||
function getAssetQueryString(ctx, addTimestamp) {
|
||||
let qs = "";
|
||||
// In development we add the request timestamp to allow react to
|
||||
// reload assets when a new RSC response is received.
|
||||
// Turbopack handles HMR of assets itself and react doesn't need to reload them
|
||||
// so this approach is not needed for Turbopack.
|
||||
if (isDev && !isTurbopack && addTimestamp) {
|
||||
qs += `?v=${ctx.requestTimestamp}`;
|
||||
}
|
||||
if (ctx.renderOpts.deploymentId) {
|
||||
qs += `${isDev ? "&" : "?"}dpl=${ctx.renderOpts.deploymentId}`;
|
||||
}
|
||||
return qs;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-asset-query-string.js.map
|
||||
1
node_modules/next/dist/server/app-render/get-asset-query-string.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/get-asset-query-string.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/get-asset-query-string.ts"],"names":["getAssetQueryString","isDev","process","env","NODE_ENV","isTurbopack","TURBOPACK","ctx","addTimestamp","qs","requestTimestamp","renderOpts","deploymentId"],"mappings":";;;;+BAIgBA;;;eAAAA;;;AAFhB,MAAMC,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK;AACvC,MAAMC,cAAc,CAAC,CAACH,QAAQC,GAAG,CAACG,SAAS;AACpC,SAASN,oBACdO,GAAqB,EACrBC,YAAqB;IAErB,IAAIC,KAAK;IAET,gEAAgE;IAChE,qDAAqD;IACrD,+EAA+E;IAC/E,gDAAgD;IAChD,IAAIR,SAAS,CAACI,eAAeG,cAAc;QACzCC,MAAM,CAAC,GAAG,EAAEF,IAAIG,gBAAgB,CAAC,CAAC;IACpC;IAEA,IAAIH,IAAII,UAAU,CAACC,YAAY,EAAE;QAC/BH,MAAM,CAAC,EAAER,QAAQ,MAAM,IAAI,IAAI,EAAEM,IAAII,UAAU,CAACC,YAAY,CAAC,CAAC;IAChE;IACA,OAAOH;AACT"}
|
||||
9
node_modules/next/dist/server/app-render/get-css-inlined-link-tags.d.ts
generated
vendored
Normal file
9
node_modules/next/dist/server/app-render/get-css-inlined-link-tags.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin';
|
||||
import type { DeepReadonly } from '../../shared/lib/deep-readonly';
|
||||
/**
|
||||
* Get external stylesheet link hrefs based on server CSS manifest.
|
||||
*/
|
||||
export declare function getLinkAndScriptTags(clientReferenceManifest: DeepReadonly<ClientReferenceManifest>, filePath: string, injectedCSS: Set<string>, injectedScripts: Set<string>, collectNewImports?: boolean): {
|
||||
styles: string[];
|
||||
scripts: string[];
|
||||
};
|
||||
48
node_modules/next/dist/server/app-render/get-css-inlined-link-tags.js
generated
vendored
Normal file
48
node_modules/next/dist/server/app-render/get-css-inlined-link-tags.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getLinkAndScriptTags", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getLinkAndScriptTags;
|
||||
}
|
||||
});
|
||||
function getLinkAndScriptTags(clientReferenceManifest, filePath, injectedCSS, injectedScripts, collectNewImports) {
|
||||
var _clientReferenceManifest_entryJSFiles;
|
||||
const filePathWithoutExt = filePath.replace(/\.[^.]+$/, "");
|
||||
const cssChunks = new Set();
|
||||
const jsChunks = new Set();
|
||||
const entryCSSFiles = clientReferenceManifest.entryCSSFiles[filePathWithoutExt];
|
||||
const entryJSFiles = ((_clientReferenceManifest_entryJSFiles = clientReferenceManifest.entryJSFiles) == null ? void 0 : _clientReferenceManifest_entryJSFiles[filePathWithoutExt]) ?? [];
|
||||
if (entryCSSFiles) {
|
||||
for (const file of entryCSSFiles){
|
||||
if (!injectedCSS.has(file)) {
|
||||
if (collectNewImports) {
|
||||
injectedCSS.add(file);
|
||||
}
|
||||
cssChunks.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entryJSFiles) {
|
||||
for (const file of entryJSFiles){
|
||||
if (!injectedScripts.has(file)) {
|
||||
if (collectNewImports) {
|
||||
injectedScripts.add(file);
|
||||
}
|
||||
jsChunks.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
styles: [
|
||||
...cssChunks
|
||||
],
|
||||
scripts: [
|
||||
...jsChunks
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-css-inlined-link-tags.js.map
|
||||
1
node_modules/next/dist/server/app-render/get-css-inlined-link-tags.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/get-css-inlined-link-tags.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/get-css-inlined-link-tags.tsx"],"names":["getLinkAndScriptTags","clientReferenceManifest","filePath","injectedCSS","injectedScripts","collectNewImports","filePathWithoutExt","replace","cssChunks","Set","jsChunks","entryCSSFiles","entryJSFiles","file","has","add","styles","scripts"],"mappings":";;;;+BAMgBA;;;eAAAA;;;AAAT,SAASA,qBACdC,uBAA8D,EAC9DC,QAAgB,EAChBC,WAAwB,EACxBC,eAA4B,EAC5BC,iBAA2B;QASzBJ;IAPF,MAAMK,qBAAqBJ,SAASK,OAAO,CAAC,YAAY;IACxD,MAAMC,YAAY,IAAIC;IACtB,MAAMC,WAAW,IAAID;IAErB,MAAME,gBACJV,wBAAwBU,aAAa,CAACL,mBAAmB;IAC3D,MAAMM,eACJX,EAAAA,wCAAAA,wBAAwBW,YAAY,qBAApCX,qCAAsC,CAACK,mBAAmB,KAAI,EAAE;IAElE,IAAIK,eAAe;QACjB,KAAK,MAAME,QAAQF,cAAe;YAChC,IAAI,CAACR,YAAYW,GAAG,CAACD,OAAO;gBAC1B,IAAIR,mBAAmB;oBACrBF,YAAYY,GAAG,CAACF;gBAClB;gBACAL,UAAUO,GAAG,CAACF;YAChB;QACF;IACF;IAEA,IAAID,cAAc;QAChB,KAAK,MAAMC,QAAQD,aAAc;YAC/B,IAAI,CAACR,gBAAgBU,GAAG,CAACD,OAAO;gBAC9B,IAAIR,mBAAmB;oBACrBD,gBAAgBW,GAAG,CAACF;gBACtB;gBACAH,SAASK,GAAG,CAACF;YACf;QACF;IACF;IAEA,OAAO;QAAEG,QAAQ;eAAIR;SAAU;QAAES,SAAS;eAAIP;SAAS;IAAC;AAC1D"}
|
||||
9
node_modules/next/dist/server/app-render/get-layer-assets.d.ts
generated
vendored
Normal file
9
node_modules/next/dist/server/app-render/get-layer-assets.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import type { AppRenderContext } from './app-render';
|
||||
export declare function getLayerAssets({ ctx, layoutOrPagePath, injectedCSS: injectedCSSWithCurrentLayout, injectedJS: injectedJSWithCurrentLayout, injectedFontPreloadTags: injectedFontPreloadTagsWithCurrentLayout, }: {
|
||||
layoutOrPagePath: string | undefined;
|
||||
injectedCSS: Set<string>;
|
||||
injectedJS: Set<string>;
|
||||
injectedFontPreloadTags: Set<string>;
|
||||
ctx: AppRenderContext;
|
||||
}): React.ReactNode;
|
||||
85
node_modules/next/dist/server/app-render/get-layer-assets.js
generated
vendored
Normal file
85
node_modules/next/dist/server/app-render/get-layer-assets.js
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getLayerAssets", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getLayerAssets;
|
||||
}
|
||||
});
|
||||
const _jsxruntime = require("react/jsx-runtime");
|
||||
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
||||
const _getcssinlinedlinktags = require("./get-css-inlined-link-tags");
|
||||
const _getpreloadablefonts = require("./get-preloadable-fonts");
|
||||
const _getassetquerystring = require("./get-asset-query-string");
|
||||
const _encodeuripath = require("../../shared/lib/encode-uri-path");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function getLayerAssets({ ctx, layoutOrPagePath, injectedCSS: injectedCSSWithCurrentLayout, injectedJS: injectedJSWithCurrentLayout, injectedFontPreloadTags: injectedFontPreloadTagsWithCurrentLayout }) {
|
||||
const { styles: styleTags, scripts: scriptTags } = layoutOrPagePath ? (0, _getcssinlinedlinktags.getLinkAndScriptTags)(ctx.clientReferenceManifest, layoutOrPagePath, injectedCSSWithCurrentLayout, injectedJSWithCurrentLayout, true) : {
|
||||
styles: [],
|
||||
scripts: []
|
||||
};
|
||||
const preloadedFontFiles = layoutOrPagePath ? (0, _getpreloadablefonts.getPreloadableFonts)(ctx.renderOpts.nextFontManifest, layoutOrPagePath, injectedFontPreloadTagsWithCurrentLayout) : null;
|
||||
if (preloadedFontFiles) {
|
||||
if (preloadedFontFiles.length) {
|
||||
for(let i = 0; i < preloadedFontFiles.length; i++){
|
||||
const fontFilename = preloadedFontFiles[i];
|
||||
const ext = /\.(woff|woff2|eot|ttf|otf)$/.exec(fontFilename)[1];
|
||||
const type = `font/${ext}`;
|
||||
const href = `${ctx.assetPrefix}/_next/${(0, _encodeuripath.encodeURIPath)(fontFilename)}`;
|
||||
ctx.componentMod.preloadFont(href, type, ctx.renderOpts.crossOrigin);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
let url = new URL(ctx.assetPrefix);
|
||||
ctx.componentMod.preconnect(url.origin, "anonymous");
|
||||
} catch (error) {
|
||||
// assetPrefix must not be a fully qualified domain name. We assume
|
||||
// we should preconnect to same origin instead
|
||||
ctx.componentMod.preconnect("/", "anonymous");
|
||||
}
|
||||
}
|
||||
}
|
||||
const styles = styleTags ? styleTags.map((href, index)=>{
|
||||
// In dev, Safari and Firefox will cache the resource during HMR:
|
||||
// - https://github.com/vercel/next.js/issues/5860
|
||||
// - https://bugs.webkit.org/show_bug.cgi?id=187726
|
||||
// Because of this, we add a `?v=` query to bypass the cache during
|
||||
// development. We need to also make sure that the number is always
|
||||
// increasing.
|
||||
const fullHref = `${ctx.assetPrefix}/_next/${(0, _encodeuripath.encodeURIPath)(href)}${(0, _getassetquerystring.getAssetQueryString)(ctx, true)}`;
|
||||
// `Precedence` is an opt-in signal for React to handle resource
|
||||
// loading and deduplication, etc. It's also used as the key to sort
|
||||
// resources so they will be injected in the correct order.
|
||||
// During HMR, it's critical to use different `precedence` values
|
||||
// for different stylesheets, so their order will be kept.
|
||||
// https://github.com/facebook/react/pull/25060
|
||||
const precedence = process.env.NODE_ENV === "development" ? "next_" + href : "next";
|
||||
ctx.componentMod.preloadStyle(fullHref, ctx.renderOpts.crossOrigin);
|
||||
return /*#__PURE__*/ (0, _jsxruntime.jsx)("link", {
|
||||
rel: "stylesheet",
|
||||
href: fullHref,
|
||||
// @ts-ignore
|
||||
precedence: precedence,
|
||||
crossOrigin: ctx.renderOpts.crossOrigin
|
||||
}, index);
|
||||
}) : [];
|
||||
const scripts = scriptTags ? scriptTags.map((href, index)=>{
|
||||
const fullSrc = `${ctx.assetPrefix}/_next/${(0, _encodeuripath.encodeURIPath)(href)}${(0, _getassetquerystring.getAssetQueryString)(ctx, true)}`;
|
||||
return /*#__PURE__*/ (0, _jsxruntime.jsx)("script", {
|
||||
src: fullSrc,
|
||||
async: true
|
||||
}, `script-${index}`);
|
||||
}) : [];
|
||||
return styles.length || scripts.length ? [
|
||||
...styles,
|
||||
...scripts
|
||||
] : null;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-layer-assets.js.map
|
||||
1
node_modules/next/dist/server/app-render/get-layer-assets.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/get-layer-assets.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/get-layer-assets.tsx"],"names":["getLayerAssets","ctx","layoutOrPagePath","injectedCSS","injectedCSSWithCurrentLayout","injectedJS","injectedJSWithCurrentLayout","injectedFontPreloadTags","injectedFontPreloadTagsWithCurrentLayout","styles","styleTags","scripts","scriptTags","getLinkAndScriptTags","clientReferenceManifest","preloadedFontFiles","getPreloadableFonts","renderOpts","nextFontManifest","length","i","fontFilename","ext","exec","type","href","assetPrefix","encodeURIPath","componentMod","preloadFont","crossOrigin","url","URL","preconnect","origin","error","map","index","fullHref","getAssetQueryString","precedence","process","env","NODE_ENV","preloadStyle","link","rel","fullSrc","script","src","async"],"mappings":";;;;+BAOgBA;;;eAAAA;;;;8DAPE;uCACmB;qCACD;qCAEA;+BACN;;;;;;AAEvB,SAASA,eAAe,EAC7BC,GAAG,EACHC,gBAAgB,EAChBC,aAAaC,4BAA4B,EACzCC,YAAYC,2BAA2B,EACvCC,yBAAyBC,wCAAwC,EAOlE;IACC,MAAM,EAAEC,QAAQC,SAAS,EAAEC,SAASC,UAAU,EAAE,GAAGV,mBAC/CW,IAAAA,2CAAoB,EAClBZ,IAAIa,uBAAuB,EAC3BZ,kBACAE,8BACAE,6BACA,QAEF;QAAEG,QAAQ,EAAE;QAAEE,SAAS,EAAE;IAAC;IAE9B,MAAMI,qBAAqBb,mBACvBc,IAAAA,wCAAmB,EACjBf,IAAIgB,UAAU,CAACC,gBAAgB,EAC/BhB,kBACAM,4CAEF;IAEJ,IAAIO,oBAAoB;QACtB,IAAIA,mBAAmBI,MAAM,EAAE;YAC7B,IAAK,IAAIC,IAAI,GAAGA,IAAIL,mBAAmBI,MAAM,EAAEC,IAAK;gBAClD,MAAMC,eAAeN,kBAAkB,CAACK,EAAE;gBAC1C,MAAME,MAAM,8BAA8BC,IAAI,CAACF,aAAc,CAAC,EAAE;gBAChE,MAAMG,OAAO,CAAC,KAAK,EAAEF,IAAI,CAAC;gBAC1B,MAAMG,OAAO,CAAC,EAAExB,IAAIyB,WAAW,CAAC,OAAO,EAAEC,IAAAA,4BAAa,EAACN,cAAc,CAAC;gBACtEpB,IAAI2B,YAAY,CAACC,WAAW,CAACJ,MAAMD,MAAMvB,IAAIgB,UAAU,CAACa,WAAW;YACrE;QACF,OAAO;YACL,IAAI;gBACF,IAAIC,MAAM,IAAIC,IAAI/B,IAAIyB,WAAW;gBACjCzB,IAAI2B,YAAY,CAACK,UAAU,CAACF,IAAIG,MAAM,EAAE;YAC1C,EAAE,OAAOC,OAAO;gBACd,mEAAmE;gBACnE,8CAA8C;gBAC9ClC,IAAI2B,YAAY,CAACK,UAAU,CAAC,KAAK;YACnC;QACF;IACF;IAEA,MAAMxB,SAASC,YACXA,UAAU0B,GAAG,CAAC,CAACX,MAAMY;QACnB,iEAAiE;QACjE,kDAAkD;QAClD,mDAAmD;QACnD,mEAAmE;QACnE,mEAAmE;QACnE,cAAc;QACd,MAAMC,WAAW,CAAC,EAAErC,IAAIyB,WAAW,CAAC,OAAO,EAAEC,IAAAA,4BAAa,EACxDF,MACA,EAAEc,IAAAA,wCAAmB,EAACtC,KAAK,MAAM,CAAC;QAEpC,gEAAgE;QAChE,oEAAoE;QACpE,2DAA2D;QAC3D,iEAAiE;QACjE,0DAA0D;QAC1D,+CAA+C;QAC/C,MAAMuC,aACJC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBAAgB,UAAUlB,OAAO;QAE5DxB,IAAI2B,YAAY,CAACgB,YAAY,CAACN,UAAUrC,IAAIgB,UAAU,CAACa,WAAW;QAElE,qBACE,qBAACe;YACCC,KAAI;YACJrB,MAAMa;YACN,aAAa;YACbE,YAAYA;YACZV,aAAa7B,IAAIgB,UAAU,CAACa,WAAW;WAClCO;IAGX,KACA,EAAE;IAEN,MAAM1B,UAAUC,aACZA,WAAWwB,GAAG,CAAC,CAACX,MAAMY;QACpB,MAAMU,UAAU,CAAC,EAAE9C,IAAIyB,WAAW,CAAC,OAAO,EAAEC,IAAAA,4BAAa,EACvDF,MACA,EAAEc,IAAAA,wCAAmB,EAACtC,KAAK,MAAM,CAAC;QAEpC,qBAAO,qBAAC+C;YAAOC,KAAKF;YAASG,OAAO;WAAW,CAAC,OAAO,EAAEb,MAAM,CAAC;IAClE,KACA,EAAE;IAEN,OAAO5B,OAAOU,MAAM,IAAIR,QAAQQ,MAAM,GAAG;WAAIV;WAAWE;KAAQ,GAAG;AACrE"}
|
||||
10
node_modules/next/dist/server/app-render/get-preloadable-fonts.d.ts
generated
vendored
Normal file
10
node_modules/next/dist/server/app-render/get-preloadable-fonts.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin';
|
||||
import type { DeepReadonly } from '../../shared/lib/deep-readonly';
|
||||
/**
|
||||
* 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: DeepReadonly<NextFontManifest> | undefined, filePath: string | undefined, injectedFontPreloadTags: Set<string>): string[] | null;
|
||||
39
node_modules/next/dist/server/app-render/get-preloadable-fonts.js
generated
vendored
Normal file
39
node_modules/next/dist/server/app-render/get-preloadable-fonts.js
generated
vendored
Normal 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
|
||||
1
node_modules/next/dist/server/app-render/get-preloadable-fonts.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/get-preloadable-fonts.js.map
generated
vendored
Normal 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":";;;;+BAUgBA;;;eAAAA;;;AAAT,SAASA,oBACdC,gBAA4D,EAC5DC,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"}
|
||||
1
node_modules/next/dist/server/app-render/get-script-nonce-from-header.d.ts
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/get-script-nonce-from-header.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function getScriptNonceFromHeader(cspHeaderValue: string): string | undefined;
|
||||
40
node_modules/next/dist/server/app-render/get-script-nonce-from-header.js
generated
vendored
Normal file
40
node_modules/next/dist/server/app-render/get-script-nonce-from-header.js
generated
vendored
Normal 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
|
||||
1
node_modules/next/dist/server/app-render/get-script-nonce-from-header.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/get-script-nonce-from-header.js.map
generated
vendored
Normal 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"}
|
||||
8
node_modules/next/dist/server/app-render/get-segment-param.d.ts
generated
vendored
Normal file
8
node_modules/next/dist/server/app-render/get-segment-param.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import type { DynamicParamTypes } from './types';
|
||||
/**
|
||||
* Parse dynamic route segment to type of parameter
|
||||
*/
|
||||
export declare function getSegmentParam(segment: string): {
|
||||
param: string;
|
||||
type: DynamicParamTypes;
|
||||
} | null;
|
||||
42
node_modules/next/dist/server/app-render/get-segment-param.js
generated
vendored
Normal file
42
node_modules/next/dist/server/app-render/get-segment-param.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
"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 {
|
||||
// TODO-APP: Optional catchall does not currently work with parallel routes,
|
||||
// so for now aren't handling a potential interception marker.
|
||||
type: "optional-catchall",
|
||||
param: segment.slice(5, -2)
|
||||
};
|
||||
}
|
||||
if (segment.startsWith("[...") && segment.endsWith("]")) {
|
||||
return {
|
||||
type: interceptionMarker ? "catchall-intercepted" : "catchall",
|
||||
param: segment.slice(4, -1)
|
||||
};
|
||||
}
|
||||
if (segment.startsWith("[") && segment.endsWith("]")) {
|
||||
return {
|
||||
type: interceptionMarker ? "dynamic-intercepted" : "dynamic",
|
||||
param: segment.slice(1, -1)
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-segment-param.js.map
|
||||
1
node_modules/next/dist/server/app-render/get-segment-param.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/get-segment-param.js.map
generated
vendored
Normal 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;YACL,4EAA4E;YAC5E,8DAA8D;YAC9DC,MAAM;YACNC,OAAOV,QAAQM,KAAK,CAAC,GAAG,CAAC;QAC3B;IACF;IAEA,IAAIN,QAAQK,UAAU,CAAC,WAAWL,QAAQQ,QAAQ,CAAC,MAAM;QACvD,OAAO;YACLC,MAAMR,qBAAqB,yBAAyB;YACpDS,OAAOV,QAAQM,KAAK,CAAC,GAAG,CAAC;QAC3B;IACF;IAEA,IAAIN,QAAQK,UAAU,CAAC,QAAQL,QAAQQ,QAAQ,CAAC,MAAM;QACpD,OAAO;YACLC,MAAMR,qBAAqB,wBAAwB;YACnDS,OAAOV,QAAQM,KAAK,CAAC,GAAG,CAAC;QAC3B;IACF;IAEA,OAAO;AACT"}
|
||||
6
node_modules/next/dist/server/app-render/get-short-dynamic-param-type.d.ts
generated
vendored
Normal file
6
node_modules/next/dist/server/app-render/get-short-dynamic-param-type.d.ts
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import type { 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;
|
||||
38
node_modules/next/dist/server/app-render/get-short-dynamic-param-type.js
generated
vendored
Normal file
38
node_modules/next/dist/server/app-render/get-short-dynamic-param-type.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
"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",
|
||||
"catchall-intercepted": "ci",
|
||||
"optional-catchall": "oc",
|
||||
dynamic: "d",
|
||||
"dynamic-intercepted": "di"
|
||||
};
|
||||
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
|
||||
1
node_modules/next/dist/server/app-render/get-short-dynamic-param-type.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/get-short-dynamic-param-type.js.map
generated
vendored
Normal 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;;IAcGC,wBAAwB;eAAxBA;;;AAdT,MAAMD,oBAGT;IACFE,UAAU;IACV,wBAAwB;IACxB,qBAAqB;IACrBC,SAAS;IACT,uBAAuB;AACzB;AAKO,SAASF,yBACdG,IAAuB;IAEvB,MAAMC,QAAQL,iBAAiB,CAACI,KAAK;IACrC,IAAI,CAACC,OAAO;QACV,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOD;AACT"}
|
||||
2
node_modules/next/dist/server/app-render/has-loading-component-in-tree.d.ts
generated
vendored
Normal file
2
node_modules/next/dist/server/app-render/has-loading-component-in-tree.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import type { LoaderTree } from '../lib/app-dir-module';
|
||||
export declare function hasLoadingComponentInTree(tree: LoaderTree): boolean;
|
||||
19
node_modules/next/dist/server/app-render/has-loading-component-in-tree.js
generated
vendored
Normal file
19
node_modules/next/dist/server/app-render/has-loading-component-in-tree.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "hasLoadingComponentInTree", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return hasLoadingComponentInTree;
|
||||
}
|
||||
});
|
||||
function hasLoadingComponentInTree(tree) {
|
||||
const [, parallelRoutes, { loading }] = tree;
|
||||
if (loading) {
|
||||
return true;
|
||||
}
|
||||
return Object.values(parallelRoutes).some((parallelRoute)=>hasLoadingComponentInTree(parallelRoute));
|
||||
}
|
||||
|
||||
//# sourceMappingURL=has-loading-component-in-tree.js.map
|
||||
1
node_modules/next/dist/server/app-render/has-loading-component-in-tree.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/has-loading-component-in-tree.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/has-loading-component-in-tree.tsx"],"names":["hasLoadingComponentInTree","tree","parallelRoutes","loading","Object","values","some","parallelRoute"],"mappings":";;;;+BAEgBA;;;eAAAA;;;AAAT,SAASA,0BAA0BC,IAAgB;IACxD,MAAM,GAAGC,gBAAgB,EAAEC,OAAO,EAAE,CAAC,GAAGF;IAExC,IAAIE,SAAS;QACX,OAAO;IACT;IAEA,OAAOC,OAAOC,MAAM,CAACH,gBAAgBI,IAAI,CAAC,CAACC,gBACzCP,0BAA0BO;AAE9B"}
|
||||
4
node_modules/next/dist/server/app-render/interop-default.d.ts
generated
vendored
Normal file
4
node_modules/next/dist/server/app-render/interop-default.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Interop between "export default" and "module.exports".
|
||||
*/
|
||||
export declare function interopDefault(mod: any): any;
|
||||
17
node_modules/next/dist/server/app-render/interop-default.js
generated
vendored
Normal file
17
node_modules/next/dist/server/app-render/interop-default.js
generated
vendored
Normal 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
|
||||
1
node_modules/next/dist/server/app-render/interop-default.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/interop-default.js.map
generated
vendored
Normal 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"}
|
||||
7
node_modules/next/dist/server/app-render/make-get-server-inserted-html.d.ts
generated
vendored
Normal file
7
node_modules/next/dist/server/app-render/make-get-server-inserted-html.d.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
export declare function makeGetServerInsertedHTML({ polyfills, renderServerInsertedHTML, serverCapturedErrors, basePath, }: {
|
||||
polyfills: JSX.IntrinsicElements['script'][];
|
||||
renderServerInsertedHTML: () => React.ReactNode;
|
||||
serverCapturedErrors: Error[];
|
||||
basePath: string;
|
||||
}): () => Promise<string>;
|
||||
83
node_modules/next/dist/server/app-render/make-get-server-inserted-html.js
generated
vendored
Normal file
83
node_modules/next/dist/server/app-render/make-get-server-inserted-html.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "makeGetServerInsertedHTML", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return makeGetServerInsertedHTML;
|
||||
}
|
||||
});
|
||||
const _jsxruntime = require("react/jsx-runtime");
|
||||
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
||||
const _notfound = require("../../client/components/not-found");
|
||||
const _redirect = require("../../client/components/redirect");
|
||||
const _serveredge = require("react-dom/server.edge");
|
||||
const _nodewebstreamshelper = require("../stream-utils/node-web-streams-helper");
|
||||
const _redirectstatuscode = require("../../client/components/redirect-status-code");
|
||||
const _addpathprefix = require("../../shared/lib/router/utils/add-path-prefix");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function makeGetServerInsertedHTML({ polyfills, renderServerInsertedHTML, serverCapturedErrors, basePath }) {
|
||||
let flushedErrorMetaTagsUntilIndex = 0;
|
||||
let hasUnflushedPolyfills = polyfills.length !== 0;
|
||||
return async function getServerInsertedHTML() {
|
||||
// Loop through all the errors that have been captured but not yet
|
||||
// flushed.
|
||||
const errorMetaTags = [];
|
||||
while(flushedErrorMetaTagsUntilIndex < serverCapturedErrors.length){
|
||||
const error = serverCapturedErrors[flushedErrorMetaTagsUntilIndex];
|
||||
flushedErrorMetaTagsUntilIndex++;
|
||||
if ((0, _notfound.isNotFoundError)(error)) {
|
||||
errorMetaTags.push(/*#__PURE__*/ (0, _jsxruntime.jsx)("meta", {
|
||||
name: "robots",
|
||||
content: "noindex"
|
||||
}, error.digest), process.env.NODE_ENV === "development" ? /*#__PURE__*/ (0, _jsxruntime.jsx)("meta", {
|
||||
name: "next-error",
|
||||
content: "not-found"
|
||||
}, "next-error") : null);
|
||||
} else if ((0, _redirect.isRedirectError)(error)) {
|
||||
const redirectUrl = (0, _addpathprefix.addPathPrefix)((0, _redirect.getURLFromRedirectError)(error), basePath);
|
||||
const statusCode = (0, _redirect.getRedirectStatusCodeFromError)(error);
|
||||
const isPermanent = statusCode === _redirectstatuscode.RedirectStatusCode.PermanentRedirect ? true : false;
|
||||
if (redirectUrl) {
|
||||
errorMetaTags.push(/*#__PURE__*/ (0, _jsxruntime.jsx)("meta", {
|
||||
id: "__next-page-redirect",
|
||||
httpEquiv: "refresh",
|
||||
content: `${isPermanent ? 0 : 1};url=${redirectUrl}`
|
||||
}, error.digest));
|
||||
}
|
||||
}
|
||||
}
|
||||
const serverInsertedHTML = renderServerInsertedHTML();
|
||||
// Skip React rendering if we know the content is empty.
|
||||
if (!hasUnflushedPolyfills && errorMetaTags.length === 0 && Array.isArray(serverInsertedHTML) && serverInsertedHTML.length === 0) {
|
||||
return "";
|
||||
}
|
||||
const stream = await (0, _serveredge.renderToReadableStream)(/*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
||||
children: [
|
||||
/* Insert the polyfills if they haven't been flushed yet. */ hasUnflushedPolyfills && polyfills.map((polyfill)=>{
|
||||
return /*#__PURE__*/ (0, _jsxruntime.jsx)("script", {
|
||||
...polyfill
|
||||
}, polyfill.src);
|
||||
}),
|
||||
serverInsertedHTML,
|
||||
errorMetaTags
|
||||
]
|
||||
}), {
|
||||
// Larger chunk because this isn't sent over the network.
|
||||
// Let's set it to 1MB.
|
||||
progressiveChunkSize: 1024 * 1024
|
||||
});
|
||||
hasUnflushedPolyfills = false;
|
||||
// There's no need to wait for the stream to be ready
|
||||
// e.g. calling `await stream.allReady` because `streamToString` will
|
||||
// wait and decode the stream progressively with better parallelism.
|
||||
return (0, _nodewebstreamshelper.streamToString)(stream);
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=make-get-server-inserted-html.js.map
|
||||
1
node_modules/next/dist/server/app-render/make-get-server-inserted-html.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/make-get-server-inserted-html.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/make-get-server-inserted-html.tsx"],"names":["makeGetServerInsertedHTML","polyfills","renderServerInsertedHTML","serverCapturedErrors","basePath","flushedErrorMetaTagsUntilIndex","hasUnflushedPolyfills","length","getServerInsertedHTML","errorMetaTags","error","isNotFoundError","push","meta","name","content","digest","process","env","NODE_ENV","isRedirectError","redirectUrl","addPathPrefix","getURLFromRedirectError","statusCode","getRedirectStatusCodeFromError","isPermanent","RedirectStatusCode","PermanentRedirect","id","httpEquiv","serverInsertedHTML","Array","isArray","stream","renderToReadableStream","map","polyfill","script","src","progressiveChunkSize","streamToString"],"mappings":";;;;+BAYgBA;;;eAAAA;;;;8DAZE;0BACc;0BAKzB;4BACgC;sCACR;oCACI;+BACL;;;;;;AAEvB,SAASA,0BAA0B,EACxCC,SAAS,EACTC,wBAAwB,EACxBC,oBAAoB,EACpBC,QAAQ,EAMT;IACC,IAAIC,iCAAiC;IACrC,IAAIC,wBAAwBL,UAAUM,MAAM,KAAK;IAEjD,OAAO,eAAeC;QACpB,kEAAkE;QAClE,WAAW;QACX,MAAMC,gBAAgB,EAAE;QACxB,MAAOJ,iCAAiCF,qBAAqBI,MAAM,CAAE;YACnE,MAAMG,QAAQP,oBAAoB,CAACE,+BAA+B;YAClEA;YAEA,IAAIM,IAAAA,yBAAe,EAACD,QAAQ;gBAC1BD,cAAcG,IAAI,eAChB,qBAACC;oBAAKC,MAAK;oBAASC,SAAQ;mBAAeL,MAAMM,MAAM,GACvDC,QAAQC,GAAG,CAACC,QAAQ,KAAK,8BACvB,qBAACN;oBAAKC,MAAK;oBAAaC,SAAQ;mBAAgB,gBAC9C;YAER,OAAO,IAAIK,IAAAA,yBAAe,EAACV,QAAQ;gBACjC,MAAMW,cAAcC,IAAAA,4BAAa,EAC/BC,IAAAA,iCAAuB,EAACb,QACxBN;gBAEF,MAAMoB,aAAaC,IAAAA,wCAA8B,EAACf;gBAClD,MAAMgB,cACJF,eAAeG,sCAAkB,CAACC,iBAAiB,GAAG,OAAO;gBAC/D,IAAIP,aAAa;oBACfZ,cAAcG,IAAI,eAChB,qBAACC;wBACCgB,IAAG;wBACHC,WAAU;wBACVf,SAAS,CAAC,EAAEW,cAAc,IAAI,EAAE,KAAK,EAAEL,YAAY,CAAC;uBAC/CX,MAAMM,MAAM;gBAGvB;YACF;QACF;QAEA,MAAMe,qBAAqB7B;QAE3B,wDAAwD;QACxD,IACE,CAACI,yBACDG,cAAcF,MAAM,KAAK,KACzByB,MAAMC,OAAO,CAACF,uBACdA,mBAAmBxB,MAAM,KAAK,GAC9B;YACA,OAAO;QACT;QAEA,MAAM2B,SAAS,MAAMC,IAAAA,kCAAsB,gBACzC;;gBAEI,0DAA0D,GAC1D7B,yBACEL,UAAUmC,GAAG,CAAC,CAACC;oBACb,qBAAO,qBAACC;wBAA2B,GAAGD,QAAQ;uBAA1BA,SAASE,GAAG;gBAClC;gBAEHR;gBACAtB;;YAEH;YACE,yDAAyD;YACzD,uBAAuB;YACvB+B,sBAAsB,OAAO;QAC/B;QAGFlC,wBAAwB;QAExB,qDAAqD;QACrD,qEAAqE;QACrE,oEAAoE;QACpE,OAAOmC,IAAAA,oCAAc,EAACP;IACxB;AACF"}
|
||||
2
node_modules/next/dist/server/app-render/parse-and-validate-flight-router-state.d.ts
generated
vendored
Normal file
2
node_modules/next/dist/server/app-render/parse-and-validate-flight-router-state.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import type { FlightRouterState } from './types';
|
||||
export declare function parseAndValidateFlightRouterState(stateHeader: string | string[] | undefined): FlightRouterState | undefined;
|
||||
37
node_modules/next/dist/server/app-render/parse-and-validate-flight-router-state.js
generated
vendored
Normal file
37
node_modules/next/dist/server/app-render/parse-and-validate-flight-router-state.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "parseAndValidateFlightRouterState", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return parseAndValidateFlightRouterState;
|
||||
}
|
||||
});
|
||||
const _types = require("./types");
|
||||
const _superstruct = require("next/dist/compiled/superstruct");
|
||||
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 {
|
||||
const state = JSON.parse(decodeURIComponent(stateHeader));
|
||||
(0, _superstruct.assert)(state, _types.flightRouterStateSchema);
|
||||
return state;
|
||||
} catch {
|
||||
throw new Error("The router state header was sent but could not be parsed.");
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parse-and-validate-flight-router-state.js.map
|
||||
1
node_modules/next/dist/server/app-render/parse-and-validate-flight-router-state.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/parse-and-validate-flight-router-state.js.map
generated
vendored
Normal 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","state","JSON","parse","decodeURIComponent","assert","flightRouterStateSchema"],"mappings":";;;;+BAIgBA;;;eAAAA;;;uBAHwB;6BACjB;AAEhB,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,MAAME,QAAQC,KAAKC,KAAK,CAACC,mBAAmBT;QAC5CU,IAAAA,mBAAM,EAACJ,OAAOK,8BAAuB;QACrC,OAAOL;IACT,EAAE,OAAM;QACN,MAAM,IAAIF,MAAM;IAClB;AACF"}
|
||||
10
node_modules/next/dist/server/app-render/parse-loader-tree.d.ts
generated
vendored
Normal file
10
node_modules/next/dist/server/app-render/parse-loader-tree.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import type { LoaderTree } from '../lib/app-dir-module';
|
||||
export declare function parseLoaderTree(tree: LoaderTree): {
|
||||
page: import("../../build/webpack/loaders/metadata/types").ModuleReference | undefined;
|
||||
segment: string;
|
||||
components: import("../../build/webpack/loaders/next-app-loader").ComponentsType;
|
||||
layoutOrPagePath: string | undefined;
|
||||
parallelRoutes: {
|
||||
[parallelRouterKey: string]: LoaderTree;
|
||||
};
|
||||
};
|
||||
29
node_modules/next/dist/server/app-render/parse-loader-tree.js
generated
vendored
Normal file
29
node_modules/next/dist/server/app-render/parse-loader-tree.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "parseLoaderTree", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return parseLoaderTree;
|
||||
}
|
||||
});
|
||||
const _segment = require("../../shared/lib/segment");
|
||||
function parseLoaderTree(tree) {
|
||||
const [segment, parallelRoutes, components] = tree;
|
||||
const { layout } = components;
|
||||
let { page } = components;
|
||||
// a __DEFAULT__ segment means that this route didn't match any of the
|
||||
// segments in the route, so we should use the default page
|
||||
page = segment === _segment.DEFAULT_SEGMENT_KEY ? components.defaultPage : page;
|
||||
const layoutOrPagePath = (layout == null ? void 0 : layout[1]) || (page == null ? void 0 : page[1]);
|
||||
return {
|
||||
page,
|
||||
segment,
|
||||
components,
|
||||
layoutOrPagePath,
|
||||
parallelRoutes
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parse-loader-tree.js.map
|
||||
1
node_modules/next/dist/server/app-render/parse-loader-tree.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/parse-loader-tree.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/parse-loader-tree.ts"],"names":["parseLoaderTree","tree","segment","parallelRoutes","components","layout","page","DEFAULT_SEGMENT_KEY","defaultPage","layoutOrPagePath"],"mappings":";;;;+BAGgBA;;;eAAAA;;;yBAHoB;AAG7B,SAASA,gBAAgBC,IAAgB;IAC9C,MAAM,CAACC,SAASC,gBAAgBC,WAAW,GAAGH;IAC9C,MAAM,EAAEI,MAAM,EAAE,GAAGD;IACnB,IAAI,EAAEE,IAAI,EAAE,GAAGF;IACf,sEAAsE;IACtE,2DAA2D;IAC3DE,OAAOJ,YAAYK,4BAAmB,GAAGH,WAAWI,WAAW,GAAGF;IAElE,MAAMG,mBAAmBJ,CAAAA,0BAAAA,MAAQ,CAAC,EAAE,MAAIC,wBAAAA,IAAM,CAAC,EAAE;IAEjD,OAAO;QACLA;QACAJ;QACAE;QACAK;QACAN;IACF;AACF"}
|
||||
1
node_modules/next/dist/server/app-render/react-server.node.d.ts
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/react-server.node.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export { decodeReply, decodeReplyFromBusboy, decodeAction, decodeFormState, } from 'react-server-dom-webpack/server.node';
|
||||
35
node_modules/next/dist/server/app-render/react-server.node.js
generated
vendored
Normal file
35
node_modules/next/dist/server/app-render/react-server.node.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
// This file should be opted into the react-server layer
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
decodeAction: null,
|
||||
decodeFormState: null,
|
||||
decodeReply: null,
|
||||
decodeReplyFromBusboy: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
decodeAction: function() {
|
||||
return _servernode.decodeAction;
|
||||
},
|
||||
decodeFormState: function() {
|
||||
return _servernode.decodeFormState;
|
||||
},
|
||||
decodeReply: function() {
|
||||
return _servernode.decodeReply;
|
||||
},
|
||||
decodeReplyFromBusboy: function() {
|
||||
return _servernode.decodeReplyFromBusboy;
|
||||
}
|
||||
});
|
||||
const _servernode = require("react-server-dom-webpack/server.node");
|
||||
|
||||
//# sourceMappingURL=react-server.node.js.map
|
||||
1
node_modules/next/dist/server/app-render/react-server.node.js.map
generated
vendored
Normal file
1
node_modules/next/dist/server/app-render/react-server.node.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/app-render/react-server.node.ts"],"names":["decodeAction","decodeFormState","decodeReply","decodeReplyFromBusboy"],"mappings":"AAAA,wDAAwD;AAExD,6DAA6D;;;;;;;;;;;;;;;;;;IAI3DA,YAAY;eAAZA,wBAAY;;IACZC,eAAe;eAAfA,2BAAe;;IAHfC,WAAW;eAAXA,uBAAW;;IACXC,qBAAqB;eAArBA,iCAAqB;;;4BAGhB"}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user