Initial boiler plate project
This commit is contained in:
172
node_modules/next/dist/esm/server/web/spec-extension/adapters/headers.js
generated
vendored
Normal file
172
node_modules/next/dist/esm/server/web/spec-extension/adapters/headers.js
generated
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
import { ReflectAdapter } from "./reflect";
|
||||
/**
|
||||
* @internal
|
||||
*/ export class ReadonlyHeadersError extends Error {
|
||||
constructor(){
|
||||
super("Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers");
|
||||
}
|
||||
static callable() {
|
||||
throw new ReadonlyHeadersError();
|
||||
}
|
||||
}
|
||||
export class HeadersAdapter extends Headers {
|
||||
constructor(headers){
|
||||
// We've already overridden the methods that would be called, so we're just
|
||||
// calling the super constructor to ensure that the instanceof check works.
|
||||
super();
|
||||
this.headers = new Proxy(headers, {
|
||||
get (target, prop, receiver) {
|
||||
// Because this is just an object, we expect that all "get" operations
|
||||
// are for properties. If it's a "get" for a symbol, we'll just return
|
||||
// the symbol.
|
||||
if (typeof prop === "symbol") {
|
||||
return ReflectAdapter.get(target, prop, receiver);
|
||||
}
|
||||
const lowercased = prop.toLowerCase();
|
||||
// Let's find the original casing of the key. This assumes that there is
|
||||
// no mixed case keys (e.g. "Content-Type" and "content-type") in the
|
||||
// headers object.
|
||||
const original = Object.keys(headers).find((o)=>o.toLowerCase() === lowercased);
|
||||
// If the original casing doesn't exist, return undefined.
|
||||
if (typeof original === "undefined") return;
|
||||
// If the original casing exists, return the value.
|
||||
return ReflectAdapter.get(target, original, receiver);
|
||||
},
|
||||
set (target, prop, value, receiver) {
|
||||
if (typeof prop === "symbol") {
|
||||
return ReflectAdapter.set(target, prop, value, receiver);
|
||||
}
|
||||
const lowercased = prop.toLowerCase();
|
||||
// Let's find the original casing of the key. This assumes that there is
|
||||
// no mixed case keys (e.g. "Content-Type" and "content-type") in the
|
||||
// headers object.
|
||||
const original = Object.keys(headers).find((o)=>o.toLowerCase() === lowercased);
|
||||
// If the original casing doesn't exist, use the prop as the key.
|
||||
return ReflectAdapter.set(target, original ?? prop, value, receiver);
|
||||
},
|
||||
has (target, prop) {
|
||||
if (typeof prop === "symbol") return ReflectAdapter.has(target, prop);
|
||||
const lowercased = prop.toLowerCase();
|
||||
// Let's find the original casing of the key. This assumes that there is
|
||||
// no mixed case keys (e.g. "Content-Type" and "content-type") in the
|
||||
// headers object.
|
||||
const original = Object.keys(headers).find((o)=>o.toLowerCase() === lowercased);
|
||||
// If the original casing doesn't exist, return false.
|
||||
if (typeof original === "undefined") return false;
|
||||
// If the original casing exists, return true.
|
||||
return ReflectAdapter.has(target, original);
|
||||
},
|
||||
deleteProperty (target, prop) {
|
||||
if (typeof prop === "symbol") return ReflectAdapter.deleteProperty(target, prop);
|
||||
const lowercased = prop.toLowerCase();
|
||||
// Let's find the original casing of the key. This assumes that there is
|
||||
// no mixed case keys (e.g. "Content-Type" and "content-type") in the
|
||||
// headers object.
|
||||
const original = Object.keys(headers).find((o)=>o.toLowerCase() === lowercased);
|
||||
// If the original casing doesn't exist, return true.
|
||||
if (typeof original === "undefined") return true;
|
||||
// If the original casing exists, delete the property.
|
||||
return ReflectAdapter.deleteProperty(target, original);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Seals a Headers instance to prevent modification by throwing an error when
|
||||
* any mutating method is called.
|
||||
*/ static seal(headers) {
|
||||
return new Proxy(headers, {
|
||||
get (target, prop, receiver) {
|
||||
switch(prop){
|
||||
case "append":
|
||||
case "delete":
|
||||
case "set":
|
||||
return ReadonlyHeadersError.callable;
|
||||
default:
|
||||
return ReflectAdapter.get(target, prop, receiver);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Merges a header value into a string. This stores multiple values as an
|
||||
* array, so we need to merge them into a string.
|
||||
*
|
||||
* @param value a header value
|
||||
* @returns a merged header value (a string)
|
||||
*/ merge(value) {
|
||||
if (Array.isArray(value)) return value.join(", ");
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* Creates a Headers instance from a plain object or a Headers instance.
|
||||
*
|
||||
* @param headers a plain object or a Headers instance
|
||||
* @returns a headers instance
|
||||
*/ static from(headers) {
|
||||
if (headers instanceof Headers) return headers;
|
||||
return new HeadersAdapter(headers);
|
||||
}
|
||||
append(name, value) {
|
||||
const existing = this.headers[name];
|
||||
if (typeof existing === "string") {
|
||||
this.headers[name] = [
|
||||
existing,
|
||||
value
|
||||
];
|
||||
} else if (Array.isArray(existing)) {
|
||||
existing.push(value);
|
||||
} else {
|
||||
this.headers[name] = value;
|
||||
}
|
||||
}
|
||||
delete(name) {
|
||||
delete this.headers[name];
|
||||
}
|
||||
get(name) {
|
||||
const value = this.headers[name];
|
||||
if (typeof value !== "undefined") return this.merge(value);
|
||||
return null;
|
||||
}
|
||||
has(name) {
|
||||
return typeof this.headers[name] !== "undefined";
|
||||
}
|
||||
set(name, value) {
|
||||
this.headers[name] = value;
|
||||
}
|
||||
forEach(callbackfn, thisArg) {
|
||||
for (const [name, value] of this.entries()){
|
||||
callbackfn.call(thisArg, value, name, this);
|
||||
}
|
||||
}
|
||||
*entries() {
|
||||
for (const key of Object.keys(this.headers)){
|
||||
const name = key.toLowerCase();
|
||||
// We assert here that this is a string because we got it from the
|
||||
// Object.keys() call above.
|
||||
const value = this.get(name);
|
||||
yield [
|
||||
name,
|
||||
value
|
||||
];
|
||||
}
|
||||
}
|
||||
*keys() {
|
||||
for (const key of Object.keys(this.headers)){
|
||||
const name = key.toLowerCase();
|
||||
yield name;
|
||||
}
|
||||
}
|
||||
*values() {
|
||||
for (const key of Object.keys(this.headers)){
|
||||
// We assert here that this is a string because we got it from the
|
||||
// Object.keys() call above.
|
||||
const value = this.get(key);
|
||||
yield value;
|
||||
}
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return this.entries();
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=headers.js.map
|
||||
1
node_modules/next/dist/esm/server/web/spec-extension/adapters/headers.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/server/web/spec-extension/adapters/headers.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/web/spec-extension/adapters/headers.ts"],"names":["ReflectAdapter","ReadonlyHeadersError","Error","constructor","callable","HeadersAdapter","Headers","headers","Proxy","get","target","prop","receiver","lowercased","toLowerCase","original","Object","keys","find","o","set","value","has","deleteProperty","seal","merge","Array","isArray","join","from","append","name","existing","push","delete","forEach","callbackfn","thisArg","entries","call","key","values","Symbol","iterator"],"mappings":"AAEA,SAASA,cAAc,QAAQ,YAAW;AAE1C;;CAEC,GACD,OAAO,MAAMC,6BAA6BC;IACxCC,aAAc;QACZ,KAAK,CACH;IAEJ;IAEA,OAAcC,WAAW;QACvB,MAAM,IAAIH;IACZ;AACF;AAUA,OAAO,MAAMI,uBAAuBC;IAGlCH,YAAYI,OAA4B,CAAE;QACxC,2EAA2E;QAC3E,2EAA2E;QAC3E,KAAK;QAEL,IAAI,CAACA,OAAO,GAAG,IAAIC,MAAMD,SAAS;YAChCE,KAAIC,MAAM,EAAEC,IAAI,EAAEC,QAAQ;gBACxB,sEAAsE;gBACtE,sEAAsE;gBACtE,cAAc;gBACd,IAAI,OAAOD,SAAS,UAAU;oBAC5B,OAAOX,eAAeS,GAAG,CAACC,QAAQC,MAAMC;gBAC1C;gBAEA,MAAMC,aAAaF,KAAKG,WAAW;gBAEnC,wEAAwE;gBACxE,qEAAqE;gBACrE,kBAAkB;gBAClB,MAAMC,WAAWC,OAAOC,IAAI,CAACV,SAASW,IAAI,CACxC,CAACC,IAAMA,EAAEL,WAAW,OAAOD;gBAG7B,0DAA0D;gBAC1D,IAAI,OAAOE,aAAa,aAAa;gBAErC,mDAAmD;gBACnD,OAAOf,eAAeS,GAAG,CAACC,QAAQK,UAAUH;YAC9C;YACAQ,KAAIV,MAAM,EAAEC,IAAI,EAAEU,KAAK,EAAET,QAAQ;gBAC/B,IAAI,OAAOD,SAAS,UAAU;oBAC5B,OAAOX,eAAeoB,GAAG,CAACV,Q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MAAMV,MAAM,IAAI,IAAI,CAACiB,OAAO,GAAI;YAC1CF,WAAWG,IAAI,CAACF,SAAShB,OAAOU,MAAM,IAAI;QAC5C;IACF;IAEA,CAAQO,UAA8C;QACpD,KAAK,MAAME,OAAOxB,OAAOC,IAAI,CAAC,IAAI,CAACV,OAAO,EAAG;YAC3C,MAAMwB,OAAOS,IAAI1B,WAAW;YAC5B,kEAAkE;YAClE,4BAA4B;YAC5B,MAAMO,QAAQ,IAAI,CAACZ,GAAG,CAACsB;YAEvB,MAAM;gBAACA;gBAAMV;aAAM;QACrB;IACF;IAEA,CAAQJ,OAAiC;QACvC,KAAK,MAAMuB,OAAOxB,OAAOC,IAAI,CAAC,IAAI,CAACV,OAAO,EAAG;YAC3C,MAAMwB,OAAOS,IAAI1B,WAAW;YAC5B,MAAMiB;QACR;IACF;IAEA,CAAQU,SAAmC;QACzC,KAAK,MAAMD,OAAOxB,OAAOC,IAAI,CAAC,IAAI,CAACV,OAAO,EAAG;YAC3C,kEAAkE;YAClE,4BAA4B;YAC5B,MAAMc,QAAQ,IAAI,CAACZ,GAAG,CAAC+B;YAEvB,MAAMnB;QACR;IACF;IAEO,CAACqB,OAAOC,QAAQ,CAAC,GAAuC;QAC7D,OAAO,IAAI,CAACL,OAAO;IACrB;AACF"}
|
||||
113
node_modules/next/dist/esm/server/web/spec-extension/adapters/next-request.js
generated
vendored
Normal file
113
node_modules/next/dist/esm/server/web/spec-extension/adapters/next-request.js
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
import { getRequestMeta } from "../../../request-meta";
|
||||
import { fromNodeOutgoingHttpHeaders } from "../../utils";
|
||||
import { NextRequest } from "../request";
|
||||
export const ResponseAbortedName = "ResponseAborted";
|
||||
export class ResponseAborted extends Error {
|
||||
constructor(...args){
|
||||
super(...args);
|
||||
this.name = ResponseAbortedName;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Creates an AbortController tied to the closing of a ServerResponse (or other
|
||||
* appropriate Writable).
|
||||
*
|
||||
* If the `close` event is fired before the `finish` event, then we'll send the
|
||||
* `abort` signal.
|
||||
*/ export function createAbortController(response) {
|
||||
const controller = new AbortController();
|
||||
// If `finish` fires first, then `res.end()` has been called and the close is
|
||||
// just us finishing the stream on our side. If `close` fires first, then we
|
||||
// know the client disconnected before we finished.
|
||||
response.once("close", ()=>{
|
||||
if (response.writableFinished) return;
|
||||
controller.abort(new ResponseAborted());
|
||||
});
|
||||
return controller;
|
||||
}
|
||||
/**
|
||||
* Creates an AbortSignal tied to the closing of a ServerResponse (or other
|
||||
* appropriate Writable).
|
||||
*
|
||||
* This cannot be done with the request (IncomingMessage or Readable) because
|
||||
* the `abort` event will not fire if to data has been fully read (because that
|
||||
* will "close" the readable stream and nothing fires after that).
|
||||
*/ export function signalFromNodeResponse(response) {
|
||||
const { errored, destroyed } = response;
|
||||
if (errored || destroyed) {
|
||||
return AbortSignal.abort(errored ?? new ResponseAborted());
|
||||
}
|
||||
const { signal } = createAbortController(response);
|
||||
return signal;
|
||||
}
|
||||
export class NextRequestAdapter {
|
||||
static fromBaseNextRequest(request, signal) {
|
||||
// TODO: look at refining this check
|
||||
if ("request" in request && request.request) {
|
||||
return NextRequestAdapter.fromWebNextRequest(request);
|
||||
}
|
||||
return NextRequestAdapter.fromNodeNextRequest(request, signal);
|
||||
}
|
||||
static fromNodeNextRequest(request, signal) {
|
||||
// HEAD and GET requests can not have a body.
|
||||
let body = null;
|
||||
if (request.method !== "GET" && request.method !== "HEAD" && request.body) {
|
||||
// @ts-expect-error - this is handled by undici, when streams/web land use it instead
|
||||
body = request.body;
|
||||
}
|
||||
let url;
|
||||
if (request.url.startsWith("http")) {
|
||||
url = new URL(request.url);
|
||||
} else {
|
||||
// Grab the full URL from the request metadata.
|
||||
const base = getRequestMeta(request, "initURL");
|
||||
if (!base || !base.startsWith("http")) {
|
||||
// Because the URL construction relies on the fact that the URL provided
|
||||
// is absolute, we need to provide a base URL. We can't use the request
|
||||
// URL because it's relative, so we use a dummy URL instead.
|
||||
url = new URL(request.url, "http://n");
|
||||
} else {
|
||||
url = new URL(request.url, base);
|
||||
}
|
||||
}
|
||||
return new NextRequest(url, {
|
||||
method: request.method,
|
||||
headers: fromNodeOutgoingHttpHeaders(request.headers),
|
||||
// @ts-expect-error - see https://github.com/whatwg/fetch/pull/1457
|
||||
duplex: "half",
|
||||
signal,
|
||||
// geo
|
||||
// ip
|
||||
// nextConfig
|
||||
// body can not be passed if request was aborted
|
||||
// or we get a Request body was disturbed error
|
||||
...signal.aborted ? {} : {
|
||||
body
|
||||
}
|
||||
});
|
||||
}
|
||||
static fromWebNextRequest(request) {
|
||||
// HEAD and GET requests can not have a body.
|
||||
let body = null;
|
||||
if (request.method !== "GET" && request.method !== "HEAD") {
|
||||
body = request.body;
|
||||
}
|
||||
return new NextRequest(request.url, {
|
||||
method: request.method,
|
||||
headers: fromNodeOutgoingHttpHeaders(request.headers),
|
||||
// @ts-expect-error - see https://github.com/whatwg/fetch/pull/1457
|
||||
duplex: "half",
|
||||
signal: request.request.signal,
|
||||
// geo
|
||||
// ip
|
||||
// nextConfig
|
||||
// body can not be passed if request was aborted
|
||||
// or we get a Request body was disturbed error
|
||||
...request.request.signal.aborted ? {} : {
|
||||
body
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=next-request.js.map
|
||||
1
node_modules/next/dist/esm/server/web/spec-extension/adapters/next-request.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/server/web/spec-extension/adapters/next-request.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/web/spec-extension/adapters/next-request.ts"],"names":["getRequestMeta","fromNodeOutgoingHttpHeaders","NextRequest","ResponseAbortedName","ResponseAborted","Error","name","createAbortController","response","controller","AbortController","once","writableFinished","abort","signalFromNodeResponse","errored","destroyed","AbortSignal","signal","NextRequestAdapter","fromBaseNextRequest","request","fromWebNextRequest","fromNodeNextRequest","body","method","url","startsWith","URL","base","headers","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AAIE,IAAIP,QAAQK,GAAG;QAC3B,OAAO;YACL,+CAA+C;YAC/C,MAAMG,OAAO7B,eAAeqB,SAAS;YACrC,IAAI,CAACQ,QAAQ,CAACA,KAAKF,UAAU,CAAC,SAAS;gBACrC,wEAAwE;gBACxE,uEAAuE;gBACvE,4DAA4D;gBAC5DD,MAAM,IAAIE,IAAIP,QAAQK,GAAG,EAAE;YAC7B,OAAO;gBACLA,MAAM,IAAIE,IAAIP,QAAQK,GAAG,EAAEG;YAC7B;QACF;QAEA,OAAO,IAAI3B,YAAYwB,KAAK;YAC1BD,QAAQJ,QAAQI,MAAM;YACtBK,SAAS7B,4BAA4BoB,QAAQS,OAAO;YACpD,mEAAmE;YACnEC,QAAQ;YACRb;YACA,MAAM;YACN,KAAK;YACL,aAAa;YAEb,gDAAgD;YAChD,+CAA+C;YAC/C,GAAIA,OAAOc,OAAO,GACd,CAAC,IACD;gBACER;YACF,CAAC;QACP;IACF;IAEA,OAAcF,mBAAmBD,OAAuB,EAAe;QACrE,6CAA6C;QAC7C,IAAIG,OAA8B;QAClC,IAAIH,QAAQI,MAAM,KAAK,SAASJ,QAAQI,MAAM,KAAK,QAAQ;YACzDD,OAAOH,QAAQG,IAAI;QACrB;QAEA,OAAO,IAAItB,YAAYmB,QAAQK,GAAG,EAAE;YAClCD,QAAQJ,QAAQI,MAAM;YACtBK,SAAS7B,4BAA4BoB,QAAQS,OAAO;YACpD,mEAAmE;YACnEC,QAAQ;YACRb,QAAQG,QAAQA,OAAO,CAACH,MAAM;YAC9B,MAAM;YACN,KAAK;YACL,aAAa;YAEb,gDAAgD;YAChD,+CAA+C;YAC/C,GAAIG,QAAQA,OAAO,CAACH,MAAM,CAACc,OAAO,GAC9B,CAAC,IACD;gBACER;YACF,CAAC;QACP;IACF;AACF"}
|
||||
20
node_modules/next/dist/esm/server/web/spec-extension/adapters/reflect.js
generated
vendored
Normal file
20
node_modules/next/dist/esm/server/web/spec-extension/adapters/reflect.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
export class ReflectAdapter {
|
||||
static get(target, prop, receiver) {
|
||||
const value = Reflect.get(target, prop, receiver);
|
||||
if (typeof value === "function") {
|
||||
return value.bind(target);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
static set(target, prop, value, receiver) {
|
||||
return Reflect.set(target, prop, value, receiver);
|
||||
}
|
||||
static has(target, prop) {
|
||||
return Reflect.has(target, prop);
|
||||
}
|
||||
static deleteProperty(target, prop) {
|
||||
return Reflect.deleteProperty(target, prop);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=reflect.js.map
|
||||
1
node_modules/next/dist/esm/server/web/spec-extension/adapters/reflect.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/server/web/spec-extension/adapters/reflect.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/web/spec-extension/adapters/reflect.ts"],"names":["ReflectAdapter","get","target","prop","receiver","value","Reflect","bind","set","has","deleteProperty"],"mappings":"AAAA,OAAO,MAAMA;IACX,OAAOC,IACLC,MAAS,EACTC,IAAqB,EACrBC,QAAiB,EACZ;QACL,MAAMC,QAAQC,QAAQL,GAAG,CAACC,QAAQC,MAAMC;QACxC,IAAI,OAAOC,UAAU,YAAY;YAC/B,OAAOA,MAAME,IAAI,CAACL;QACpB;QAEA,OAAOG;IACT;IAEA,OAAOG,IACLN,MAAS,EACTC,IAAqB,EACrBE,KAAU,EACVD,QAAa,EACJ;QACT,OAAOE,QAAQE,GAAG,CAACN,QAAQC,MAAME,OAAOD;IAC1C;IAEA,OAAOK,IAAsBP,MAAS,EAAEC,IAAqB,EAAW;QACtE,OAAOG,QAAQG,GAAG,CAACP,QAAQC;IAC7B;IAEA,OAAOO,eACLR,MAAS,EACTC,IAAqB,EACZ;QACT,OAAOG,QAAQI,cAAc,CAACR,QAAQC;IACxC;AACF"}
|
||||
118
node_modules/next/dist/esm/server/web/spec-extension/adapters/request-cookies.js
generated
vendored
Normal file
118
node_modules/next/dist/esm/server/web/spec-extension/adapters/request-cookies.js
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
import { ResponseCookies } from "../cookies";
|
||||
import { ReflectAdapter } from "./reflect";
|
||||
import { staticGenerationAsyncStorage } from "../../../../client/components/static-generation-async-storage.external";
|
||||
/**
|
||||
* @internal
|
||||
*/ export class ReadonlyRequestCookiesError extends Error {
|
||||
constructor(){
|
||||
super("Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options");
|
||||
}
|
||||
static callable() {
|
||||
throw new ReadonlyRequestCookiesError();
|
||||
}
|
||||
}
|
||||
export class RequestCookiesAdapter {
|
||||
static seal(cookies) {
|
||||
return new Proxy(cookies, {
|
||||
get (target, prop, receiver) {
|
||||
switch(prop){
|
||||
case "clear":
|
||||
case "delete":
|
||||
case "set":
|
||||
return ReadonlyRequestCookiesError.callable;
|
||||
default:
|
||||
return ReflectAdapter.get(target, prop, receiver);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
const SYMBOL_MODIFY_COOKIE_VALUES = Symbol.for("next.mutated.cookies");
|
||||
export function getModifiedCookieValues(cookies) {
|
||||
const modified = cookies[SYMBOL_MODIFY_COOKIE_VALUES];
|
||||
if (!modified || !Array.isArray(modified) || modified.length === 0) {
|
||||
return [];
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
export function appendMutableCookies(headers, mutableCookies) {
|
||||
const modifiedCookieValues = getModifiedCookieValues(mutableCookies);
|
||||
if (modifiedCookieValues.length === 0) {
|
||||
return false;
|
||||
}
|
||||
// Return a new response that extends the response with
|
||||
// the modified cookies as fallbacks. `res` cookies
|
||||
// will still take precedence.
|
||||
const resCookies = new ResponseCookies(headers);
|
||||
const returnedCookies = resCookies.getAll();
|
||||
// Set the modified cookies as fallbacks.
|
||||
for (const cookie of modifiedCookieValues){
|
||||
resCookies.set(cookie);
|
||||
}
|
||||
// Set the original cookies as the final values.
|
||||
for (const cookie of returnedCookies){
|
||||
resCookies.set(cookie);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
export class MutableRequestCookiesAdapter {
|
||||
static wrap(cookies, onUpdateCookies) {
|
||||
const responseCookies = new ResponseCookies(new Headers());
|
||||
for (const cookie of cookies.getAll()){
|
||||
responseCookies.set(cookie);
|
||||
}
|
||||
let modifiedValues = [];
|
||||
const modifiedCookies = new Set();
|
||||
const updateResponseCookies = ()=>{
|
||||
// TODO-APP: change method of getting staticGenerationAsyncStore
|
||||
const staticGenerationAsyncStore = staticGenerationAsyncStorage.getStore();
|
||||
if (staticGenerationAsyncStore) {
|
||||
staticGenerationAsyncStore.pathWasRevalidated = true;
|
||||
}
|
||||
const allCookies = responseCookies.getAll();
|
||||
modifiedValues = allCookies.filter((c)=>modifiedCookies.has(c.name));
|
||||
if (onUpdateCookies) {
|
||||
const serializedCookies = [];
|
||||
for (const cookie of modifiedValues){
|
||||
const tempCookies = new ResponseCookies(new Headers());
|
||||
tempCookies.set(cookie);
|
||||
serializedCookies.push(tempCookies.toString());
|
||||
}
|
||||
onUpdateCookies(serializedCookies);
|
||||
}
|
||||
};
|
||||
return new Proxy(responseCookies, {
|
||||
get (target, prop, receiver) {
|
||||
switch(prop){
|
||||
// A special symbol to get the modified cookie values
|
||||
case SYMBOL_MODIFY_COOKIE_VALUES:
|
||||
return modifiedValues;
|
||||
// TODO: Throw error if trying to set a cookie after the response
|
||||
// headers have been set.
|
||||
case "delete":
|
||||
return function(...args) {
|
||||
modifiedCookies.add(typeof args[0] === "string" ? args[0] : args[0].name);
|
||||
try {
|
||||
target.delete(...args);
|
||||
} finally{
|
||||
updateResponseCookies();
|
||||
}
|
||||
};
|
||||
case "set":
|
||||
return function(...args) {
|
||||
modifiedCookies.add(typeof args[0] === "string" ? args[0] : args[0].name);
|
||||
try {
|
||||
return target.set(...args);
|
||||
} finally{
|
||||
updateResponseCookies();
|
||||
}
|
||||
};
|
||||
default:
|
||||
return ReflectAdapter.get(target, prop, receiver);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=request-cookies.js.map
|
||||
1
node_modules/next/dist/esm/server/web/spec-extension/adapters/request-cookies.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/server/web/spec-extension/adapters/request-cookies.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/web/spec-extension/adapters/request-cookies.ts"],"names":["ResponseCookies","ReflectAdapter","staticGenerationAsyncStorage","ReadonlyRequestCookiesError","Error","constructor","callable","RequestCookiesAdapter","seal","cookies","Proxy","get","target","prop","receiver","SYMBOL_MODIFY_COOKIE_VALUES","Symbol","for","getModifiedCookieValues","modified","Array","isArray","length","appendMutableCookies","headers","mutableCookies","modifiedCookieValues","resCookies","returnedCookies","getAll","cookie","set","MutableRequestCookiesAdapter","wrap","onUpdateCookies","responseCookies","Headers","modifiedValues","modifiedCookies","Set","updateResponseCookies","staticGenerationAsyncStore","getStore","pathWasRevalidated","allCookies","filter","c","has","name","serializedCookies","tempCookies","push","toString","args","add","delete"],"mappings":"AAEA,SAASA,eAAe,QAAQ,aAAY;AAC5C,SAASC,cAAc,QAAQ,YAAW;AAC1C,SAASC,4BAA4B,QAAQ,yEAAwE;AAErH;;CAEC,GACD,OAAO,MAAMC,oCAAoCC;IAC/CC,aAAc;QACZ,KAAK,CACH;IAEJ;IAEA,OAAcC,WAAW;QACvB,MAAM,IAAIH;IACZ;AACF;AAWA,OAAO,MAAMI;IACX,OAAcC,KAAKC,OAAuB,EAA0B;QAClE,OAAO,IAAIC,MAAMD,SAAgB;YAC/BE,KAAIC,MAAM,EAAEC,IAAI,EAAEC,QAAQ;gBACxB,OAAQD;oBACN,KAAK;oBACL,KAAK;oBACL,KAAK;wBACH,OAAOV,4BAA4BG,QAAQ;oBAC7C;wBACE,OAAOL,eAAeU,GAAG,CAACC,QAAQC,MAAMC;gBAC5C;YACF;QACF;IACF;AACF;AAEA,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