@preprio/prepr-nextjs 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-26CXDAG7.mjs +72 -0
- package/dist/chunk-26CXDAG7.mjs.map +1 -0
- package/dist/chunk-2BRZNIOK.js +2 -0
- package/dist/chunk-2BRZNIOK.js.map +1 -0
- package/dist/chunk-32XGP2RS.mjs +4218 -0
- package/dist/chunk-32XGP2RS.mjs.map +1 -0
- package/dist/chunk-6FNC3XMI.js +45 -0
- package/dist/chunk-C6L3X6KZ.js +201 -0
- package/dist/chunk-C6L3X6KZ.js.map +1 -0
- package/dist/chunk-DI26GYQY.js +201 -0
- package/dist/chunk-IL3U74YL.js +2 -0
- package/dist/chunk-IL3U74YL.js.map +1 -0
- package/dist/chunk-J3Y65EMB.js +2 -0
- package/dist/chunk-J3Y65EMB.js.map +1 -0
- package/dist/chunk-JPRRZPBL.js +43 -0
- package/dist/chunk-JPRRZPBL.js.map +1 -0
- package/dist/chunk-MKSF2TOK.js +2 -0
- package/dist/chunk-MKSF2TOK.js.map +1 -0
- package/dist/chunk-MZGTV4KW.js +2 -0
- package/dist/chunk-MZGTV4KW.js.map +1 -0
- package/dist/chunk-NWRQFDMF.js +2 -0
- package/dist/chunk-NWRQFDMF.js.map +1 -0
- package/dist/chunk-QZTUT4DH.js +2 -0
- package/dist/chunk-QZTUT4DH.js.map +1 -0
- package/dist/middleware/index.cjs +1 -1
- package/dist/middleware/index.cjs.map +1 -1
- package/dist/middleware/index.js +1 -1
- package/dist/middleware/index.mjs +4 -0
- package/dist/middleware/index.mjs.map +1 -0
- package/dist/pages/react/index.cjs +8 -0
- package/dist/pages/react/index.cjs.map +1 -0
- package/dist/pages/react/index.d.cts +99 -0
- package/dist/pages/react/index.d.ts +99 -0
- package/dist/pages/react/index.js +8 -0
- package/dist/pages/react/index.js.map +1 -0
- package/dist/pages/server/index.cjs +7 -0
- package/dist/pages/server/index.cjs.map +1 -0
- package/dist/pages/server/index.d.cts +83 -0
- package/dist/pages/server/index.d.ts +83 -0
- package/dist/pages/server/index.js +7 -0
- package/dist/pages/server/index.js.map +1 -0
- package/dist/react/index.mjs +10179 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/server/index.cjs +2 -2
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.mjs +1569 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/types/index.mjs +3 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/utils/index.mjs +3307 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1569 @@
|
|
|
1
|
+
import { require_cookies, require_reflect, require_work_async_storage_external, require_work_unit_async_storage_external, require_dynamic_rendering, require_static_generation_bailout, require_dynamic_rendering_utils, require_scheduler, require_utils, require_hooks_server_context, package_default } from '../chunk-32XGP2RS.mjs';
|
|
2
|
+
export { createPreprMiddleware } from '../chunk-32XGP2RS.mjs';
|
|
3
|
+
import { __commonJS, __require, __toESM, __async } from '../chunk-26CXDAG7.mjs';
|
|
4
|
+
|
|
5
|
+
// node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js
|
|
6
|
+
var require_request_cookies = __commonJS({
|
|
7
|
+
"node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js"(exports) {
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
function _export(target, all) {
|
|
12
|
+
for (var name in all) Object.defineProperty(target, name, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: all[name]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
_export(exports, {
|
|
18
|
+
MutableRequestCookiesAdapter: function() {
|
|
19
|
+
return MutableRequestCookiesAdapter;
|
|
20
|
+
},
|
|
21
|
+
ReadonlyRequestCookiesError: function() {
|
|
22
|
+
return ReadonlyRequestCookiesError;
|
|
23
|
+
},
|
|
24
|
+
RequestCookiesAdapter: function() {
|
|
25
|
+
return RequestCookiesAdapter;
|
|
26
|
+
},
|
|
27
|
+
appendMutableCookies: function() {
|
|
28
|
+
return appendMutableCookies;
|
|
29
|
+
},
|
|
30
|
+
areCookiesMutableInCurrentPhase: function() {
|
|
31
|
+
return areCookiesMutableInCurrentPhase;
|
|
32
|
+
},
|
|
33
|
+
getModifiedCookieValues: function() {
|
|
34
|
+
return getModifiedCookieValues;
|
|
35
|
+
},
|
|
36
|
+
responseCookiesToRequestCookies: function() {
|
|
37
|
+
return responseCookiesToRequestCookies;
|
|
38
|
+
},
|
|
39
|
+
wrapWithMutableAccessCheck: function() {
|
|
40
|
+
return wrapWithMutableAccessCheck;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
var _cookies = require_cookies();
|
|
44
|
+
var _reflect = require_reflect();
|
|
45
|
+
var _workasyncstorageexternal = require_work_async_storage_external();
|
|
46
|
+
var _workunitasyncstorageexternal = require_work_unit_async_storage_external();
|
|
47
|
+
var ReadonlyRequestCookiesError = class _ReadonlyRequestCookiesError extends Error {
|
|
48
|
+
constructor() {
|
|
49
|
+
super("Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options");
|
|
50
|
+
}
|
|
51
|
+
static callable() {
|
|
52
|
+
throw new _ReadonlyRequestCookiesError();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var RequestCookiesAdapter = class {
|
|
56
|
+
static seal(cookies) {
|
|
57
|
+
return new Proxy(cookies, {
|
|
58
|
+
get(target, prop, receiver) {
|
|
59
|
+
switch (prop) {
|
|
60
|
+
case "clear":
|
|
61
|
+
case "delete":
|
|
62
|
+
case "set":
|
|
63
|
+
return ReadonlyRequestCookiesError.callable;
|
|
64
|
+
default:
|
|
65
|
+
return _reflect.ReflectAdapter.get(target, prop, receiver);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var SYMBOL_MODIFY_COOKIE_VALUES = Symbol.for("next.mutated.cookies");
|
|
72
|
+
function getModifiedCookieValues(cookies) {
|
|
73
|
+
const modified = cookies[SYMBOL_MODIFY_COOKIE_VALUES];
|
|
74
|
+
if (!modified || !Array.isArray(modified) || modified.length === 0) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
return modified;
|
|
78
|
+
}
|
|
79
|
+
function appendMutableCookies(headers2, mutableCookies) {
|
|
80
|
+
const modifiedCookieValues = getModifiedCookieValues(mutableCookies);
|
|
81
|
+
if (modifiedCookieValues.length === 0) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const resCookies = new _cookies.ResponseCookies(headers2);
|
|
85
|
+
const returnedCookies = resCookies.getAll();
|
|
86
|
+
for (const cookie of modifiedCookieValues) {
|
|
87
|
+
resCookies.set(cookie);
|
|
88
|
+
}
|
|
89
|
+
for (const cookie of returnedCookies) {
|
|
90
|
+
resCookies.set(cookie);
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
var MutableRequestCookiesAdapter = class {
|
|
95
|
+
static wrap(cookies, onUpdateCookies) {
|
|
96
|
+
const responseCookies = new _cookies.ResponseCookies(new Headers());
|
|
97
|
+
for (const cookie of cookies.getAll()) {
|
|
98
|
+
responseCookies.set(cookie);
|
|
99
|
+
}
|
|
100
|
+
let modifiedValues = [];
|
|
101
|
+
const modifiedCookies = /* @__PURE__ */ new Set();
|
|
102
|
+
const updateResponseCookies = () => {
|
|
103
|
+
const workStore = _workasyncstorageexternal.workAsyncStorage.getStore();
|
|
104
|
+
if (workStore) {
|
|
105
|
+
workStore.pathWasRevalidated = true;
|
|
106
|
+
}
|
|
107
|
+
const allCookies = responseCookies.getAll();
|
|
108
|
+
modifiedValues = allCookies.filter((c) => modifiedCookies.has(c.name));
|
|
109
|
+
if (onUpdateCookies) {
|
|
110
|
+
const serializedCookies = [];
|
|
111
|
+
for (const cookie of modifiedValues) {
|
|
112
|
+
const tempCookies = new _cookies.ResponseCookies(new Headers());
|
|
113
|
+
tempCookies.set(cookie);
|
|
114
|
+
serializedCookies.push(tempCookies.toString());
|
|
115
|
+
}
|
|
116
|
+
onUpdateCookies(serializedCookies);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const wrappedCookies = new Proxy(responseCookies, {
|
|
120
|
+
get(target, prop, receiver) {
|
|
121
|
+
switch (prop) {
|
|
122
|
+
// A special symbol to get the modified cookie values
|
|
123
|
+
case SYMBOL_MODIFY_COOKIE_VALUES:
|
|
124
|
+
return modifiedValues;
|
|
125
|
+
// TODO: Throw error if trying to set a cookie after the response
|
|
126
|
+
// headers have been set.
|
|
127
|
+
case "delete":
|
|
128
|
+
return function(...args) {
|
|
129
|
+
modifiedCookies.add(typeof args[0] === "string" ? args[0] : args[0].name);
|
|
130
|
+
try {
|
|
131
|
+
target.delete(...args);
|
|
132
|
+
return wrappedCookies;
|
|
133
|
+
} finally {
|
|
134
|
+
updateResponseCookies();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
case "set":
|
|
138
|
+
return function(...args) {
|
|
139
|
+
modifiedCookies.add(typeof args[0] === "string" ? args[0] : args[0].name);
|
|
140
|
+
try {
|
|
141
|
+
target.set(...args);
|
|
142
|
+
return wrappedCookies;
|
|
143
|
+
} finally {
|
|
144
|
+
updateResponseCookies();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
default:
|
|
148
|
+
return _reflect.ReflectAdapter.get(target, prop, receiver);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return wrappedCookies;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
function wrapWithMutableAccessCheck(responseCookies) {
|
|
156
|
+
const wrappedCookies = new Proxy(responseCookies, {
|
|
157
|
+
get(target, prop, receiver) {
|
|
158
|
+
switch (prop) {
|
|
159
|
+
case "delete":
|
|
160
|
+
return function(...args) {
|
|
161
|
+
ensureCookiesAreStillMutable("cookies().delete");
|
|
162
|
+
target.delete(...args);
|
|
163
|
+
return wrappedCookies;
|
|
164
|
+
};
|
|
165
|
+
case "set":
|
|
166
|
+
return function(...args) {
|
|
167
|
+
ensureCookiesAreStillMutable("cookies().set");
|
|
168
|
+
target.set(...args);
|
|
169
|
+
return wrappedCookies;
|
|
170
|
+
};
|
|
171
|
+
default:
|
|
172
|
+
return _reflect.ReflectAdapter.get(target, prop, receiver);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
return wrappedCookies;
|
|
177
|
+
}
|
|
178
|
+
function areCookiesMutableInCurrentPhase(requestStore) {
|
|
179
|
+
return requestStore.phase === "action";
|
|
180
|
+
}
|
|
181
|
+
function ensureCookiesAreStillMutable(callingExpression) {
|
|
182
|
+
const requestStore = (0, _workunitasyncstorageexternal.getExpectedRequestStore)(callingExpression);
|
|
183
|
+
if (!areCookiesMutableInCurrentPhase(requestStore)) {
|
|
184
|
+
throw new ReadonlyRequestCookiesError();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function responseCookiesToRequestCookies(responseCookies) {
|
|
188
|
+
const requestCookies = new _cookies.RequestCookies(new Headers());
|
|
189
|
+
for (const cookie of responseCookies.getAll()) {
|
|
190
|
+
requestCookies.set(cookie);
|
|
191
|
+
}
|
|
192
|
+
return requestCookies;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/create-deduped-by-callsite-server-error-logger.js
|
|
198
|
+
var require_create_deduped_by_callsite_server_error_logger = __commonJS({
|
|
199
|
+
"node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/create-deduped-by-callsite-server-error-logger.js"(exports) {
|
|
200
|
+
Object.defineProperty(exports, "__esModule", {
|
|
201
|
+
value: true
|
|
202
|
+
});
|
|
203
|
+
Object.defineProperty(exports, "createDedupedByCallsiteServerErrorLoggerDev", {
|
|
204
|
+
enumerable: true,
|
|
205
|
+
get: function() {
|
|
206
|
+
return createDedupedByCallsiteServerErrorLoggerDev;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
var _react = /* @__PURE__ */ _interop_require_wildcard(__require("react"));
|
|
210
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
211
|
+
if (typeof WeakMap !== "function") return null;
|
|
212
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
213
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
214
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
215
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
216
|
+
})(nodeInterop);
|
|
217
|
+
}
|
|
218
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
219
|
+
if (obj && obj.__esModule) {
|
|
220
|
+
return obj;
|
|
221
|
+
}
|
|
222
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
223
|
+
return {
|
|
224
|
+
default: obj
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
var cache2 = _getRequireWildcardCache(nodeInterop);
|
|
228
|
+
if (cache2 && cache2.has(obj)) {
|
|
229
|
+
return cache2.get(obj);
|
|
230
|
+
}
|
|
231
|
+
var newObj = {
|
|
232
|
+
__proto__: null
|
|
233
|
+
};
|
|
234
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
235
|
+
for (var key in obj) {
|
|
236
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
237
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
238
|
+
if (desc && (desc.get || desc.set)) {
|
|
239
|
+
Object.defineProperty(newObj, key, desc);
|
|
240
|
+
} else {
|
|
241
|
+
newObj[key] = obj[key];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
newObj.default = obj;
|
|
246
|
+
if (cache2) {
|
|
247
|
+
cache2.set(obj, newObj);
|
|
248
|
+
}
|
|
249
|
+
return newObj;
|
|
250
|
+
}
|
|
251
|
+
var errorRef = {
|
|
252
|
+
current: null
|
|
253
|
+
};
|
|
254
|
+
var cache = typeof _react.cache === "function" ? _react.cache : (fn) => fn;
|
|
255
|
+
var logErrorOrWarn = process.env.__NEXT_DYNAMIC_IO ? console.error : console.warn;
|
|
256
|
+
var flushCurrentErrorIfNew = cache(
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- cache key
|
|
258
|
+
(key) => {
|
|
259
|
+
try {
|
|
260
|
+
logErrorOrWarn(errorRef.current);
|
|
261
|
+
} finally {
|
|
262
|
+
errorRef.current = null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
function createDedupedByCallsiteServerErrorLoggerDev(getMessage) {
|
|
267
|
+
return function logDedupedError(...args) {
|
|
268
|
+
const message = getMessage(...args);
|
|
269
|
+
if (process.env.NODE_ENV !== "production") {
|
|
270
|
+
var _stack;
|
|
271
|
+
const callStackFrames = (_stack = new Error().stack) == null ? void 0 : _stack.split("\n");
|
|
272
|
+
if (callStackFrames === void 0 || callStackFrames.length < 4) {
|
|
273
|
+
logErrorOrWarn(message);
|
|
274
|
+
} else {
|
|
275
|
+
const key = callStackFrames[4];
|
|
276
|
+
errorRef.current = message;
|
|
277
|
+
flushCurrentErrorIfNew(key);
|
|
278
|
+
}
|
|
279
|
+
} else {
|
|
280
|
+
logErrorOrWarn(message);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/request/cookies.js
|
|
288
|
+
var require_cookies2 = __commonJS({
|
|
289
|
+
"node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/request/cookies.js"(exports) {
|
|
290
|
+
Object.defineProperty(exports, "__esModule", {
|
|
291
|
+
value: true
|
|
292
|
+
});
|
|
293
|
+
Object.defineProperty(exports, "cookies", {
|
|
294
|
+
enumerable: true,
|
|
295
|
+
get: function() {
|
|
296
|
+
return cookies;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
var _requestcookies = require_request_cookies();
|
|
300
|
+
var _cookies = require_cookies();
|
|
301
|
+
var _workasyncstorageexternal = require_work_async_storage_external();
|
|
302
|
+
var _workunitasyncstorageexternal = require_work_unit_async_storage_external();
|
|
303
|
+
var _dynamicrendering = require_dynamic_rendering();
|
|
304
|
+
var _staticgenerationbailout = require_static_generation_bailout();
|
|
305
|
+
var _dynamicrenderingutils = require_dynamic_rendering_utils();
|
|
306
|
+
var _creatededupedbycallsiteservererrorlogger = require_create_deduped_by_callsite_server_error_logger();
|
|
307
|
+
var _scheduler = require_scheduler();
|
|
308
|
+
var _utils = require_utils();
|
|
309
|
+
function cookies() {
|
|
310
|
+
const callingExpression = "cookies";
|
|
311
|
+
const workStore = _workasyncstorageexternal.workAsyncStorage.getStore();
|
|
312
|
+
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
|
313
|
+
if (workStore) {
|
|
314
|
+
if (workUnitStore && workUnitStore.phase === "after" && !(0, _utils.isRequestAPICallableInsideAfter)()) {
|
|
315
|
+
throw Object.defineProperty(new Error(
|
|
316
|
+
// TODO(after): clarify that this only applies to pages?
|
|
317
|
+
`Route ${workStore.route} used "cookies" inside "after(...)". This is not supported. If you need this data inside an "after" callback, use "cookies" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after`
|
|
318
|
+
), "__NEXT_ERROR_CODE", {
|
|
319
|
+
value: "E88",
|
|
320
|
+
enumerable: false,
|
|
321
|
+
configurable: true
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
if (workStore.forceStatic) {
|
|
325
|
+
const underlyingCookies2 = createEmptyCookies();
|
|
326
|
+
return makeUntrackedExoticCookies(underlyingCookies2);
|
|
327
|
+
}
|
|
328
|
+
if (workUnitStore) {
|
|
329
|
+
if (workUnitStore.type === "cache") {
|
|
330
|
+
throw Object.defineProperty(new Error(`Route ${workStore.route} used "cookies" inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "cookies" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
|
|
331
|
+
value: "E398",
|
|
332
|
+
enumerable: false,
|
|
333
|
+
configurable: true
|
|
334
|
+
});
|
|
335
|
+
} else if (workUnitStore.type === "unstable-cache") {
|
|
336
|
+
throw Object.defineProperty(new Error(`Route ${workStore.route} used "cookies" 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 "cookies" 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`), "__NEXT_ERROR_CODE", {
|
|
337
|
+
value: "E157",
|
|
338
|
+
enumerable: false,
|
|
339
|
+
configurable: true
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (workStore.dynamicShouldError) {
|
|
344
|
+
throw Object.defineProperty(new _staticgenerationbailout.StaticGenBailoutError(`Route ${workStore.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`cookies\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
|
|
345
|
+
value: "E549",
|
|
346
|
+
enumerable: false,
|
|
347
|
+
configurable: true
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
if (workUnitStore) {
|
|
351
|
+
if (workUnitStore.type === "prerender") {
|
|
352
|
+
return makeDynamicallyTrackedExoticCookies(workStore.route, workUnitStore);
|
|
353
|
+
} else if (workUnitStore.type === "prerender-ppr") {
|
|
354
|
+
(0, _dynamicrendering.postponeWithTracking)(workStore.route, callingExpression, workUnitStore.dynamicTracking);
|
|
355
|
+
} else if (workUnitStore.type === "prerender-legacy") {
|
|
356
|
+
(0, _dynamicrendering.throwToInterruptStaticGeneration)(callingExpression, workStore, workUnitStore);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
(0, _dynamicrendering.trackDynamicDataInDynamicRender)(workStore, workUnitStore);
|
|
360
|
+
}
|
|
361
|
+
const requestStore = (0, _workunitasyncstorageexternal.getExpectedRequestStore)(callingExpression);
|
|
362
|
+
let underlyingCookies;
|
|
363
|
+
if ((0, _requestcookies.areCookiesMutableInCurrentPhase)(requestStore)) {
|
|
364
|
+
underlyingCookies = requestStore.userspaceMutableCookies;
|
|
365
|
+
} else {
|
|
366
|
+
underlyingCookies = requestStore.cookies;
|
|
367
|
+
}
|
|
368
|
+
if (process.env.NODE_ENV === "development" && !(workStore == null ? void 0 : workStore.isPrefetchRequest)) {
|
|
369
|
+
return makeUntrackedExoticCookiesWithDevWarnings(underlyingCookies, workStore == null ? void 0 : workStore.route);
|
|
370
|
+
} else {
|
|
371
|
+
return makeUntrackedExoticCookies(underlyingCookies);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function createEmptyCookies() {
|
|
375
|
+
return _requestcookies.RequestCookiesAdapter.seal(new _cookies.RequestCookies(new Headers({})));
|
|
376
|
+
}
|
|
377
|
+
var CachedCookies = /* @__PURE__ */ new WeakMap();
|
|
378
|
+
function makeDynamicallyTrackedExoticCookies(route, prerenderStore) {
|
|
379
|
+
const cachedPromise = CachedCookies.get(prerenderStore);
|
|
380
|
+
if (cachedPromise) {
|
|
381
|
+
return cachedPromise;
|
|
382
|
+
}
|
|
383
|
+
const promise = (0, _dynamicrenderingutils.makeHangingPromise)(prerenderStore.renderSignal, "`cookies()`");
|
|
384
|
+
CachedCookies.set(prerenderStore, promise);
|
|
385
|
+
Object.defineProperties(promise, {
|
|
386
|
+
[Symbol.iterator]: {
|
|
387
|
+
value: function() {
|
|
388
|
+
const expression = "`cookies()[Symbol.iterator]()`";
|
|
389
|
+
const error = createCookiesAccessError(route, expression);
|
|
390
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
size: {
|
|
394
|
+
get() {
|
|
395
|
+
const expression = "`cookies().size`";
|
|
396
|
+
const error = createCookiesAccessError(route, expression);
|
|
397
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
get: {
|
|
401
|
+
value: function get() {
|
|
402
|
+
let expression;
|
|
403
|
+
if (arguments.length === 0) {
|
|
404
|
+
expression = "`cookies().get()`";
|
|
405
|
+
} else {
|
|
406
|
+
expression = `\`cookies().get(${describeNameArg(arguments[0])})\``;
|
|
407
|
+
}
|
|
408
|
+
const error = createCookiesAccessError(route, expression);
|
|
409
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
getAll: {
|
|
413
|
+
value: function getAll() {
|
|
414
|
+
let expression;
|
|
415
|
+
if (arguments.length === 0) {
|
|
416
|
+
expression = "`cookies().getAll()`";
|
|
417
|
+
} else {
|
|
418
|
+
expression = `\`cookies().getAll(${describeNameArg(arguments[0])})\``;
|
|
419
|
+
}
|
|
420
|
+
const error = createCookiesAccessError(route, expression);
|
|
421
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
has: {
|
|
425
|
+
value: function has() {
|
|
426
|
+
let expression;
|
|
427
|
+
if (arguments.length === 0) {
|
|
428
|
+
expression = "`cookies().has()`";
|
|
429
|
+
} else {
|
|
430
|
+
expression = `\`cookies().has(${describeNameArg(arguments[0])})\``;
|
|
431
|
+
}
|
|
432
|
+
const error = createCookiesAccessError(route, expression);
|
|
433
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
set: {
|
|
437
|
+
value: function set() {
|
|
438
|
+
let expression;
|
|
439
|
+
if (arguments.length === 0) {
|
|
440
|
+
expression = "`cookies().set()`";
|
|
441
|
+
} else {
|
|
442
|
+
const arg = arguments[0];
|
|
443
|
+
if (arg) {
|
|
444
|
+
expression = `\`cookies().set(${describeNameArg(arg)}, ...)\``;
|
|
445
|
+
} else {
|
|
446
|
+
expression = "`cookies().set(...)`";
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
const error = createCookiesAccessError(route, expression);
|
|
450
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
delete: {
|
|
454
|
+
value: function() {
|
|
455
|
+
let expression;
|
|
456
|
+
if (arguments.length === 0) {
|
|
457
|
+
expression = "`cookies().delete()`";
|
|
458
|
+
} else if (arguments.length === 1) {
|
|
459
|
+
expression = `\`cookies().delete(${describeNameArg(arguments[0])})\``;
|
|
460
|
+
} else {
|
|
461
|
+
expression = `\`cookies().delete(${describeNameArg(arguments[0])}, ...)\``;
|
|
462
|
+
}
|
|
463
|
+
const error = createCookiesAccessError(route, expression);
|
|
464
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
clear: {
|
|
468
|
+
value: function clear() {
|
|
469
|
+
const expression = "`cookies().clear()`";
|
|
470
|
+
const error = createCookiesAccessError(route, expression);
|
|
471
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
toString: {
|
|
475
|
+
value: function toString() {
|
|
476
|
+
const expression = "`cookies().toString()`";
|
|
477
|
+
const error = createCookiesAccessError(route, expression);
|
|
478
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
return promise;
|
|
483
|
+
}
|
|
484
|
+
function makeUntrackedExoticCookies(underlyingCookies) {
|
|
485
|
+
const cachedCookies = CachedCookies.get(underlyingCookies);
|
|
486
|
+
if (cachedCookies) {
|
|
487
|
+
return cachedCookies;
|
|
488
|
+
}
|
|
489
|
+
const promise = Promise.resolve(underlyingCookies);
|
|
490
|
+
CachedCookies.set(underlyingCookies, promise);
|
|
491
|
+
Object.defineProperties(promise, {
|
|
492
|
+
[Symbol.iterator]: {
|
|
493
|
+
value: underlyingCookies[Symbol.iterator] ? underlyingCookies[Symbol.iterator].bind(underlyingCookies) : (
|
|
494
|
+
// We should remove this and unify our cookies types. We could just let this continue to throw lazily
|
|
495
|
+
// but that's already a hard thing to debug so we may as well implement it consistently. The biggest problem with
|
|
496
|
+
// implementing this in this way is the underlying cookie type is a ResponseCookie and not a RequestCookie and so it
|
|
497
|
+
// has extra properties not available on RequestCookie instances.
|
|
498
|
+
polyfilledResponseCookiesIterator.bind(underlyingCookies)
|
|
499
|
+
)
|
|
500
|
+
},
|
|
501
|
+
size: {
|
|
502
|
+
get() {
|
|
503
|
+
return underlyingCookies.size;
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
get: {
|
|
507
|
+
value: underlyingCookies.get.bind(underlyingCookies)
|
|
508
|
+
},
|
|
509
|
+
getAll: {
|
|
510
|
+
value: underlyingCookies.getAll.bind(underlyingCookies)
|
|
511
|
+
},
|
|
512
|
+
has: {
|
|
513
|
+
value: underlyingCookies.has.bind(underlyingCookies)
|
|
514
|
+
},
|
|
515
|
+
set: {
|
|
516
|
+
value: underlyingCookies.set.bind(underlyingCookies)
|
|
517
|
+
},
|
|
518
|
+
delete: {
|
|
519
|
+
value: underlyingCookies.delete.bind(underlyingCookies)
|
|
520
|
+
},
|
|
521
|
+
clear: {
|
|
522
|
+
value: (
|
|
523
|
+
// @ts-expect-error clear is defined in RequestCookies implementation but not in the type
|
|
524
|
+
typeof underlyingCookies.clear === "function" ? underlyingCookies.clear.bind(underlyingCookies) : (
|
|
525
|
+
// We should remove this and unify our cookies types. We could just let this continue to throw lazily
|
|
526
|
+
// but that's already a hard thing to debug so we may as well implement it consistently. The biggest problem with
|
|
527
|
+
// implementing this in this way is the underlying cookie type is a ResponseCookie and not a RequestCookie and so it
|
|
528
|
+
// has extra properties not available on RequestCookie instances.
|
|
529
|
+
polyfilledResponseCookiesClear.bind(underlyingCookies, promise)
|
|
530
|
+
)
|
|
531
|
+
)
|
|
532
|
+
},
|
|
533
|
+
toString: {
|
|
534
|
+
value: underlyingCookies.toString.bind(underlyingCookies)
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
return promise;
|
|
538
|
+
}
|
|
539
|
+
function makeUntrackedExoticCookiesWithDevWarnings(underlyingCookies, route) {
|
|
540
|
+
const cachedCookies = CachedCookies.get(underlyingCookies);
|
|
541
|
+
if (cachedCookies) {
|
|
542
|
+
return cachedCookies;
|
|
543
|
+
}
|
|
544
|
+
const promise = new Promise((resolve) => (0, _scheduler.scheduleImmediate)(() => resolve(underlyingCookies)));
|
|
545
|
+
CachedCookies.set(underlyingCookies, promise);
|
|
546
|
+
Object.defineProperties(promise, {
|
|
547
|
+
[Symbol.iterator]: {
|
|
548
|
+
value: function() {
|
|
549
|
+
const expression = "`...cookies()` or similar iteration";
|
|
550
|
+
syncIODev(route, expression);
|
|
551
|
+
return underlyingCookies[Symbol.iterator] ? underlyingCookies[Symbol.iterator].apply(underlyingCookies, arguments) : (
|
|
552
|
+
// We should remove this and unify our cookies types. We could just let this continue to throw lazily
|
|
553
|
+
// but that's already a hard thing to debug so we may as well implement it consistently. The biggest problem with
|
|
554
|
+
// implementing this in this way is the underlying cookie type is a ResponseCookie and not a RequestCookie and so it
|
|
555
|
+
// has extra properties not available on RequestCookie instances.
|
|
556
|
+
polyfilledResponseCookiesIterator.call(underlyingCookies)
|
|
557
|
+
);
|
|
558
|
+
},
|
|
559
|
+
writable: false
|
|
560
|
+
},
|
|
561
|
+
size: {
|
|
562
|
+
get() {
|
|
563
|
+
const expression = "`cookies().size`";
|
|
564
|
+
syncIODev(route, expression);
|
|
565
|
+
return underlyingCookies.size;
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
get: {
|
|
569
|
+
value: function get() {
|
|
570
|
+
let expression;
|
|
571
|
+
if (arguments.length === 0) {
|
|
572
|
+
expression = "`cookies().get()`";
|
|
573
|
+
} else {
|
|
574
|
+
expression = `\`cookies().get(${describeNameArg(arguments[0])})\``;
|
|
575
|
+
}
|
|
576
|
+
syncIODev(route, expression);
|
|
577
|
+
return underlyingCookies.get.apply(underlyingCookies, arguments);
|
|
578
|
+
},
|
|
579
|
+
writable: false
|
|
580
|
+
},
|
|
581
|
+
getAll: {
|
|
582
|
+
value: function getAll() {
|
|
583
|
+
let expression;
|
|
584
|
+
if (arguments.length === 0) {
|
|
585
|
+
expression = "`cookies().getAll()`";
|
|
586
|
+
} else {
|
|
587
|
+
expression = `\`cookies().getAll(${describeNameArg(arguments[0])})\``;
|
|
588
|
+
}
|
|
589
|
+
syncIODev(route, expression);
|
|
590
|
+
return underlyingCookies.getAll.apply(underlyingCookies, arguments);
|
|
591
|
+
},
|
|
592
|
+
writable: false
|
|
593
|
+
},
|
|
594
|
+
has: {
|
|
595
|
+
value: function get() {
|
|
596
|
+
let expression;
|
|
597
|
+
if (arguments.length === 0) {
|
|
598
|
+
expression = "`cookies().has()`";
|
|
599
|
+
} else {
|
|
600
|
+
expression = `\`cookies().has(${describeNameArg(arguments[0])})\``;
|
|
601
|
+
}
|
|
602
|
+
syncIODev(route, expression);
|
|
603
|
+
return underlyingCookies.has.apply(underlyingCookies, arguments);
|
|
604
|
+
},
|
|
605
|
+
writable: false
|
|
606
|
+
},
|
|
607
|
+
set: {
|
|
608
|
+
value: function set() {
|
|
609
|
+
let expression;
|
|
610
|
+
if (arguments.length === 0) {
|
|
611
|
+
expression = "`cookies().set()`";
|
|
612
|
+
} else {
|
|
613
|
+
const arg = arguments[0];
|
|
614
|
+
if (arg) {
|
|
615
|
+
expression = `\`cookies().set(${describeNameArg(arg)}, ...)\``;
|
|
616
|
+
} else {
|
|
617
|
+
expression = "`cookies().set(...)`";
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
syncIODev(route, expression);
|
|
621
|
+
return underlyingCookies.set.apply(underlyingCookies, arguments);
|
|
622
|
+
},
|
|
623
|
+
writable: false
|
|
624
|
+
},
|
|
625
|
+
delete: {
|
|
626
|
+
value: function() {
|
|
627
|
+
let expression;
|
|
628
|
+
if (arguments.length === 0) {
|
|
629
|
+
expression = "`cookies().delete()`";
|
|
630
|
+
} else if (arguments.length === 1) {
|
|
631
|
+
expression = `\`cookies().delete(${describeNameArg(arguments[0])})\``;
|
|
632
|
+
} else {
|
|
633
|
+
expression = `\`cookies().delete(${describeNameArg(arguments[0])}, ...)\``;
|
|
634
|
+
}
|
|
635
|
+
syncIODev(route, expression);
|
|
636
|
+
return underlyingCookies.delete.apply(underlyingCookies, arguments);
|
|
637
|
+
},
|
|
638
|
+
writable: false
|
|
639
|
+
},
|
|
640
|
+
clear: {
|
|
641
|
+
value: function clear() {
|
|
642
|
+
const expression = "`cookies().clear()`";
|
|
643
|
+
syncIODev(route, expression);
|
|
644
|
+
return typeof underlyingCookies.clear === "function" ? underlyingCookies.clear.apply(underlyingCookies, arguments) : (
|
|
645
|
+
// We should remove this and unify our cookies types. We could just let this continue to throw lazily
|
|
646
|
+
// but that's already a hard thing to debug so we may as well implement it consistently. The biggest problem with
|
|
647
|
+
// implementing this in this way is the underlying cookie type is a ResponseCookie and not a RequestCookie and so it
|
|
648
|
+
// has extra properties not available on RequestCookie instances.
|
|
649
|
+
polyfilledResponseCookiesClear.call(underlyingCookies, promise)
|
|
650
|
+
);
|
|
651
|
+
},
|
|
652
|
+
writable: false
|
|
653
|
+
},
|
|
654
|
+
toString: {
|
|
655
|
+
value: function toString() {
|
|
656
|
+
const expression = "`cookies().toString()` or implicit casting";
|
|
657
|
+
syncIODev(route, expression);
|
|
658
|
+
return underlyingCookies.toString.apply(underlyingCookies, arguments);
|
|
659
|
+
},
|
|
660
|
+
writable: false
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
return promise;
|
|
664
|
+
}
|
|
665
|
+
function describeNameArg(arg) {
|
|
666
|
+
return typeof arg === "object" && arg !== null && typeof arg.name === "string" ? `'${arg.name}'` : typeof arg === "string" ? `'${arg}'` : "...";
|
|
667
|
+
}
|
|
668
|
+
function syncIODev(route, expression) {
|
|
669
|
+
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
|
670
|
+
if (workUnitStore && workUnitStore.type === "request" && workUnitStore.prerenderPhase === true) {
|
|
671
|
+
const requestStore = workUnitStore;
|
|
672
|
+
(0, _dynamicrendering.trackSynchronousRequestDataAccessInDev)(requestStore);
|
|
673
|
+
}
|
|
674
|
+
warnForSyncAccess(route, expression);
|
|
675
|
+
}
|
|
676
|
+
var warnForSyncAccess = (0, _creatededupedbycallsiteservererrorlogger.createDedupedByCallsiteServerErrorLoggerDev)(createCookiesAccessError);
|
|
677
|
+
function createCookiesAccessError(route, expression) {
|
|
678
|
+
const prefix = route ? `Route "${route}" ` : "This route ";
|
|
679
|
+
return Object.defineProperty(new Error(`${prefix}used ${expression}. \`cookies()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis`), "__NEXT_ERROR_CODE", {
|
|
680
|
+
value: "E223",
|
|
681
|
+
enumerable: false,
|
|
682
|
+
configurable: true
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
function polyfilledResponseCookiesIterator() {
|
|
686
|
+
return this.getAll().map((c) => [
|
|
687
|
+
c.name,
|
|
688
|
+
c
|
|
689
|
+
]).values();
|
|
690
|
+
}
|
|
691
|
+
function polyfilledResponseCookiesClear(returnable) {
|
|
692
|
+
for (const cookie of this.getAll()) {
|
|
693
|
+
this.delete(cookie.name);
|
|
694
|
+
}
|
|
695
|
+
return returnable;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
// node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/web/spec-extension/adapters/headers.js
|
|
701
|
+
var require_headers = __commonJS({
|
|
702
|
+
"node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/web/spec-extension/adapters/headers.js"(exports) {
|
|
703
|
+
Object.defineProperty(exports, "__esModule", {
|
|
704
|
+
value: true
|
|
705
|
+
});
|
|
706
|
+
function _export(target, all) {
|
|
707
|
+
for (var name in all) Object.defineProperty(target, name, {
|
|
708
|
+
enumerable: true,
|
|
709
|
+
get: all[name]
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
_export(exports, {
|
|
713
|
+
HeadersAdapter: function() {
|
|
714
|
+
return HeadersAdapter;
|
|
715
|
+
},
|
|
716
|
+
ReadonlyHeadersError: function() {
|
|
717
|
+
return ReadonlyHeadersError;
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
var _reflect = require_reflect();
|
|
721
|
+
var ReadonlyHeadersError = class _ReadonlyHeadersError extends Error {
|
|
722
|
+
constructor() {
|
|
723
|
+
super("Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers");
|
|
724
|
+
}
|
|
725
|
+
static callable() {
|
|
726
|
+
throw new _ReadonlyHeadersError();
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
var HeadersAdapter = class _HeadersAdapter extends Headers {
|
|
730
|
+
constructor(headers2) {
|
|
731
|
+
super();
|
|
732
|
+
this.headers = new Proxy(headers2, {
|
|
733
|
+
get(target, prop, receiver) {
|
|
734
|
+
if (typeof prop === "symbol") {
|
|
735
|
+
return _reflect.ReflectAdapter.get(target, prop, receiver);
|
|
736
|
+
}
|
|
737
|
+
const lowercased = prop.toLowerCase();
|
|
738
|
+
const original = Object.keys(headers2).find((o) => o.toLowerCase() === lowercased);
|
|
739
|
+
if (typeof original === "undefined") return;
|
|
740
|
+
return _reflect.ReflectAdapter.get(target, original, receiver);
|
|
741
|
+
},
|
|
742
|
+
set(target, prop, value, receiver) {
|
|
743
|
+
if (typeof prop === "symbol") {
|
|
744
|
+
return _reflect.ReflectAdapter.set(target, prop, value, receiver);
|
|
745
|
+
}
|
|
746
|
+
const lowercased = prop.toLowerCase();
|
|
747
|
+
const original = Object.keys(headers2).find((o) => o.toLowerCase() === lowercased);
|
|
748
|
+
return _reflect.ReflectAdapter.set(target, original != null ? original : prop, value, receiver);
|
|
749
|
+
},
|
|
750
|
+
has(target, prop) {
|
|
751
|
+
if (typeof prop === "symbol") return _reflect.ReflectAdapter.has(target, prop);
|
|
752
|
+
const lowercased = prop.toLowerCase();
|
|
753
|
+
const original = Object.keys(headers2).find((o) => o.toLowerCase() === lowercased);
|
|
754
|
+
if (typeof original === "undefined") return false;
|
|
755
|
+
return _reflect.ReflectAdapter.has(target, original);
|
|
756
|
+
},
|
|
757
|
+
deleteProperty(target, prop) {
|
|
758
|
+
if (typeof prop === "symbol") return _reflect.ReflectAdapter.deleteProperty(target, prop);
|
|
759
|
+
const lowercased = prop.toLowerCase();
|
|
760
|
+
const original = Object.keys(headers2).find((o) => o.toLowerCase() === lowercased);
|
|
761
|
+
if (typeof original === "undefined") return true;
|
|
762
|
+
return _reflect.ReflectAdapter.deleteProperty(target, original);
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Seals a Headers instance to prevent modification by throwing an error when
|
|
768
|
+
* any mutating method is called.
|
|
769
|
+
*/
|
|
770
|
+
static seal(headers2) {
|
|
771
|
+
return new Proxy(headers2, {
|
|
772
|
+
get(target, prop, receiver) {
|
|
773
|
+
switch (prop) {
|
|
774
|
+
case "append":
|
|
775
|
+
case "delete":
|
|
776
|
+
case "set":
|
|
777
|
+
return ReadonlyHeadersError.callable;
|
|
778
|
+
default:
|
|
779
|
+
return _reflect.ReflectAdapter.get(target, prop, receiver);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Merges a header value into a string. This stores multiple values as an
|
|
786
|
+
* array, so we need to merge them into a string.
|
|
787
|
+
*
|
|
788
|
+
* @param value a header value
|
|
789
|
+
* @returns a merged header value (a string)
|
|
790
|
+
*/
|
|
791
|
+
merge(value) {
|
|
792
|
+
if (Array.isArray(value)) return value.join(", ");
|
|
793
|
+
return value;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Creates a Headers instance from a plain object or a Headers instance.
|
|
797
|
+
*
|
|
798
|
+
* @param headers a plain object or a Headers instance
|
|
799
|
+
* @returns a headers instance
|
|
800
|
+
*/
|
|
801
|
+
static from(headers2) {
|
|
802
|
+
if (headers2 instanceof Headers) return headers2;
|
|
803
|
+
return new _HeadersAdapter(headers2);
|
|
804
|
+
}
|
|
805
|
+
append(name, value) {
|
|
806
|
+
const existing = this.headers[name];
|
|
807
|
+
if (typeof existing === "string") {
|
|
808
|
+
this.headers[name] = [
|
|
809
|
+
existing,
|
|
810
|
+
value
|
|
811
|
+
];
|
|
812
|
+
} else if (Array.isArray(existing)) {
|
|
813
|
+
existing.push(value);
|
|
814
|
+
} else {
|
|
815
|
+
this.headers[name] = value;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
delete(name) {
|
|
819
|
+
delete this.headers[name];
|
|
820
|
+
}
|
|
821
|
+
get(name) {
|
|
822
|
+
const value = this.headers[name];
|
|
823
|
+
if (typeof value !== "undefined") return this.merge(value);
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
has(name) {
|
|
827
|
+
return typeof this.headers[name] !== "undefined";
|
|
828
|
+
}
|
|
829
|
+
set(name, value) {
|
|
830
|
+
this.headers[name] = value;
|
|
831
|
+
}
|
|
832
|
+
forEach(callbackfn, thisArg) {
|
|
833
|
+
for (const [name, value] of this.entries()) {
|
|
834
|
+
callbackfn.call(thisArg, value, name, this);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
*entries() {
|
|
838
|
+
for (const key of Object.keys(this.headers)) {
|
|
839
|
+
const name = key.toLowerCase();
|
|
840
|
+
const value = this.get(name);
|
|
841
|
+
yield [
|
|
842
|
+
name,
|
|
843
|
+
value
|
|
844
|
+
];
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
*keys() {
|
|
848
|
+
for (const key of Object.keys(this.headers)) {
|
|
849
|
+
const name = key.toLowerCase();
|
|
850
|
+
yield name;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
*values() {
|
|
854
|
+
for (const key of Object.keys(this.headers)) {
|
|
855
|
+
const value = this.get(key);
|
|
856
|
+
yield value;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
[Symbol.iterator]() {
|
|
860
|
+
return this.entries();
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
// node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/request/headers.js
|
|
867
|
+
var require_headers2 = __commonJS({
|
|
868
|
+
"node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/request/headers.js"(exports) {
|
|
869
|
+
Object.defineProperty(exports, "__esModule", {
|
|
870
|
+
value: true
|
|
871
|
+
});
|
|
872
|
+
Object.defineProperty(exports, "headers", {
|
|
873
|
+
enumerable: true,
|
|
874
|
+
get: function() {
|
|
875
|
+
return headers2;
|
|
876
|
+
}
|
|
877
|
+
});
|
|
878
|
+
var _headers = require_headers();
|
|
879
|
+
var _workasyncstorageexternal = require_work_async_storage_external();
|
|
880
|
+
var _workunitasyncstorageexternal = require_work_unit_async_storage_external();
|
|
881
|
+
var _dynamicrendering = require_dynamic_rendering();
|
|
882
|
+
var _staticgenerationbailout = require_static_generation_bailout();
|
|
883
|
+
var _dynamicrenderingutils = require_dynamic_rendering_utils();
|
|
884
|
+
var _creatededupedbycallsiteservererrorlogger = require_create_deduped_by_callsite_server_error_logger();
|
|
885
|
+
var _scheduler = require_scheduler();
|
|
886
|
+
var _utils = require_utils();
|
|
887
|
+
function headers2() {
|
|
888
|
+
const workStore = _workasyncstorageexternal.workAsyncStorage.getStore();
|
|
889
|
+
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
|
890
|
+
if (workStore) {
|
|
891
|
+
if (workUnitStore && workUnitStore.phase === "after" && !(0, _utils.isRequestAPICallableInsideAfter)()) {
|
|
892
|
+
throw Object.defineProperty(new Error(`Route ${workStore.route} used "headers" inside "after(...)". This is not supported. If you need this data inside an "after" callback, use "headers" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after`), "__NEXT_ERROR_CODE", {
|
|
893
|
+
value: "E367",
|
|
894
|
+
enumerable: false,
|
|
895
|
+
configurable: true
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
if (workStore.forceStatic) {
|
|
899
|
+
const underlyingHeaders = _headers.HeadersAdapter.seal(new Headers({}));
|
|
900
|
+
return makeUntrackedExoticHeaders(underlyingHeaders);
|
|
901
|
+
}
|
|
902
|
+
if (workUnitStore) {
|
|
903
|
+
if (workUnitStore.type === "cache") {
|
|
904
|
+
throw Object.defineProperty(new Error(`Route ${workStore.route} used "headers" inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "headers" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
|
|
905
|
+
value: "E304",
|
|
906
|
+
enumerable: false,
|
|
907
|
+
configurable: true
|
|
908
|
+
});
|
|
909
|
+
} else if (workUnitStore.type === "unstable-cache") {
|
|
910
|
+
throw Object.defineProperty(new Error(`Route ${workStore.route} used "headers" 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 "headers" 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`), "__NEXT_ERROR_CODE", {
|
|
911
|
+
value: "E127",
|
|
912
|
+
enumerable: false,
|
|
913
|
+
configurable: true
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
if (workStore.dynamicShouldError) {
|
|
918
|
+
throw Object.defineProperty(new _staticgenerationbailout.StaticGenBailoutError(`Route ${workStore.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`headers\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
|
|
919
|
+
value: "E525",
|
|
920
|
+
enumerable: false,
|
|
921
|
+
configurable: true
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
if (workUnitStore) {
|
|
925
|
+
if (workUnitStore.type === "prerender") {
|
|
926
|
+
return makeDynamicallyTrackedExoticHeaders(workStore.route, workUnitStore);
|
|
927
|
+
} else if (workUnitStore.type === "prerender-ppr") {
|
|
928
|
+
(0, _dynamicrendering.postponeWithTracking)(workStore.route, "headers", workUnitStore.dynamicTracking);
|
|
929
|
+
} else if (workUnitStore.type === "prerender-legacy") {
|
|
930
|
+
(0, _dynamicrendering.throwToInterruptStaticGeneration)("headers", workStore, workUnitStore);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
(0, _dynamicrendering.trackDynamicDataInDynamicRender)(workStore, workUnitStore);
|
|
934
|
+
}
|
|
935
|
+
const requestStore = (0, _workunitasyncstorageexternal.getExpectedRequestStore)("headers");
|
|
936
|
+
if (process.env.NODE_ENV === "development" && !(workStore == null ? void 0 : workStore.isPrefetchRequest)) {
|
|
937
|
+
return makeUntrackedExoticHeadersWithDevWarnings(requestStore.headers, workStore == null ? void 0 : workStore.route);
|
|
938
|
+
} else {
|
|
939
|
+
return makeUntrackedExoticHeaders(requestStore.headers);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
var CachedHeaders = /* @__PURE__ */ new WeakMap();
|
|
943
|
+
function makeDynamicallyTrackedExoticHeaders(route, prerenderStore) {
|
|
944
|
+
const cachedHeaders = CachedHeaders.get(prerenderStore);
|
|
945
|
+
if (cachedHeaders) {
|
|
946
|
+
return cachedHeaders;
|
|
947
|
+
}
|
|
948
|
+
const promise = (0, _dynamicrenderingutils.makeHangingPromise)(prerenderStore.renderSignal, "`headers()`");
|
|
949
|
+
CachedHeaders.set(prerenderStore, promise);
|
|
950
|
+
Object.defineProperties(promise, {
|
|
951
|
+
append: {
|
|
952
|
+
value: function append() {
|
|
953
|
+
const expression = `\`headers().append(${describeNameArg(arguments[0])}, ...)\``;
|
|
954
|
+
const error = createHeadersAccessError(route, expression);
|
|
955
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
956
|
+
}
|
|
957
|
+
},
|
|
958
|
+
delete: {
|
|
959
|
+
value: function _delete() {
|
|
960
|
+
const expression = `\`headers().delete(${describeNameArg(arguments[0])})\``;
|
|
961
|
+
const error = createHeadersAccessError(route, expression);
|
|
962
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
963
|
+
}
|
|
964
|
+
},
|
|
965
|
+
get: {
|
|
966
|
+
value: function get() {
|
|
967
|
+
const expression = `\`headers().get(${describeNameArg(arguments[0])})\``;
|
|
968
|
+
const error = createHeadersAccessError(route, expression);
|
|
969
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
has: {
|
|
973
|
+
value: function has() {
|
|
974
|
+
const expression = `\`headers().has(${describeNameArg(arguments[0])})\``;
|
|
975
|
+
const error = createHeadersAccessError(route, expression);
|
|
976
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
977
|
+
}
|
|
978
|
+
},
|
|
979
|
+
set: {
|
|
980
|
+
value: function set() {
|
|
981
|
+
const expression = `\`headers().set(${describeNameArg(arguments[0])}, ...)\``;
|
|
982
|
+
const error = createHeadersAccessError(route, expression);
|
|
983
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
984
|
+
}
|
|
985
|
+
},
|
|
986
|
+
getSetCookie: {
|
|
987
|
+
value: function getSetCookie() {
|
|
988
|
+
const expression = "`headers().getSetCookie()`";
|
|
989
|
+
const error = createHeadersAccessError(route, expression);
|
|
990
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
991
|
+
}
|
|
992
|
+
},
|
|
993
|
+
forEach: {
|
|
994
|
+
value: function forEach() {
|
|
995
|
+
const expression = "`headers().forEach(...)`";
|
|
996
|
+
const error = createHeadersAccessError(route, expression);
|
|
997
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
keys: {
|
|
1001
|
+
value: function keys() {
|
|
1002
|
+
const expression = "`headers().keys()`";
|
|
1003
|
+
const error = createHeadersAccessError(route, expression);
|
|
1004
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
1005
|
+
}
|
|
1006
|
+
},
|
|
1007
|
+
values: {
|
|
1008
|
+
value: function values() {
|
|
1009
|
+
const expression = "`headers().values()`";
|
|
1010
|
+
const error = createHeadersAccessError(route, expression);
|
|
1011
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
1012
|
+
}
|
|
1013
|
+
},
|
|
1014
|
+
entries: {
|
|
1015
|
+
value: function entries() {
|
|
1016
|
+
const expression = "`headers().entries()`";
|
|
1017
|
+
const error = createHeadersAccessError(route, expression);
|
|
1018
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
[Symbol.iterator]: {
|
|
1022
|
+
value: function() {
|
|
1023
|
+
const expression = "`headers()[Symbol.iterator]()`";
|
|
1024
|
+
const error = createHeadersAccessError(route, expression);
|
|
1025
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(route, expression, error, prerenderStore);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
return promise;
|
|
1030
|
+
}
|
|
1031
|
+
function makeUntrackedExoticHeaders(underlyingHeaders) {
|
|
1032
|
+
const cachedHeaders = CachedHeaders.get(underlyingHeaders);
|
|
1033
|
+
if (cachedHeaders) {
|
|
1034
|
+
return cachedHeaders;
|
|
1035
|
+
}
|
|
1036
|
+
const promise = Promise.resolve(underlyingHeaders);
|
|
1037
|
+
CachedHeaders.set(underlyingHeaders, promise);
|
|
1038
|
+
Object.defineProperties(promise, {
|
|
1039
|
+
append: {
|
|
1040
|
+
value: underlyingHeaders.append.bind(underlyingHeaders)
|
|
1041
|
+
},
|
|
1042
|
+
delete: {
|
|
1043
|
+
value: underlyingHeaders.delete.bind(underlyingHeaders)
|
|
1044
|
+
},
|
|
1045
|
+
get: {
|
|
1046
|
+
value: underlyingHeaders.get.bind(underlyingHeaders)
|
|
1047
|
+
},
|
|
1048
|
+
has: {
|
|
1049
|
+
value: underlyingHeaders.has.bind(underlyingHeaders)
|
|
1050
|
+
},
|
|
1051
|
+
set: {
|
|
1052
|
+
value: underlyingHeaders.set.bind(underlyingHeaders)
|
|
1053
|
+
},
|
|
1054
|
+
getSetCookie: {
|
|
1055
|
+
value: underlyingHeaders.getSetCookie.bind(underlyingHeaders)
|
|
1056
|
+
},
|
|
1057
|
+
forEach: {
|
|
1058
|
+
value: underlyingHeaders.forEach.bind(underlyingHeaders)
|
|
1059
|
+
},
|
|
1060
|
+
keys: {
|
|
1061
|
+
value: underlyingHeaders.keys.bind(underlyingHeaders)
|
|
1062
|
+
},
|
|
1063
|
+
values: {
|
|
1064
|
+
value: underlyingHeaders.values.bind(underlyingHeaders)
|
|
1065
|
+
},
|
|
1066
|
+
entries: {
|
|
1067
|
+
value: underlyingHeaders.entries.bind(underlyingHeaders)
|
|
1068
|
+
},
|
|
1069
|
+
[Symbol.iterator]: {
|
|
1070
|
+
value: underlyingHeaders[Symbol.iterator].bind(underlyingHeaders)
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
return promise;
|
|
1074
|
+
}
|
|
1075
|
+
function makeUntrackedExoticHeadersWithDevWarnings(underlyingHeaders, route) {
|
|
1076
|
+
const cachedHeaders = CachedHeaders.get(underlyingHeaders);
|
|
1077
|
+
if (cachedHeaders) {
|
|
1078
|
+
return cachedHeaders;
|
|
1079
|
+
}
|
|
1080
|
+
const promise = new Promise((resolve) => (0, _scheduler.scheduleImmediate)(() => resolve(underlyingHeaders)));
|
|
1081
|
+
CachedHeaders.set(underlyingHeaders, promise);
|
|
1082
|
+
Object.defineProperties(promise, {
|
|
1083
|
+
append: {
|
|
1084
|
+
value: function append() {
|
|
1085
|
+
const expression = `\`headers().append(${describeNameArg(arguments[0])}, ...)\``;
|
|
1086
|
+
syncIODev(route, expression);
|
|
1087
|
+
return underlyingHeaders.append.apply(underlyingHeaders, arguments);
|
|
1088
|
+
}
|
|
1089
|
+
},
|
|
1090
|
+
delete: {
|
|
1091
|
+
value: function _delete() {
|
|
1092
|
+
const expression = `\`headers().delete(${describeNameArg(arguments[0])})\``;
|
|
1093
|
+
syncIODev(route, expression);
|
|
1094
|
+
return underlyingHeaders.delete.apply(underlyingHeaders, arguments);
|
|
1095
|
+
}
|
|
1096
|
+
},
|
|
1097
|
+
get: {
|
|
1098
|
+
value: function get() {
|
|
1099
|
+
const expression = `\`headers().get(${describeNameArg(arguments[0])})\``;
|
|
1100
|
+
syncIODev(route, expression);
|
|
1101
|
+
return underlyingHeaders.get.apply(underlyingHeaders, arguments);
|
|
1102
|
+
}
|
|
1103
|
+
},
|
|
1104
|
+
has: {
|
|
1105
|
+
value: function has() {
|
|
1106
|
+
const expression = `\`headers().has(${describeNameArg(arguments[0])})\``;
|
|
1107
|
+
syncIODev(route, expression);
|
|
1108
|
+
return underlyingHeaders.has.apply(underlyingHeaders, arguments);
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
set: {
|
|
1112
|
+
value: function set() {
|
|
1113
|
+
const expression = `\`headers().set(${describeNameArg(arguments[0])}, ...)\``;
|
|
1114
|
+
syncIODev(route, expression);
|
|
1115
|
+
return underlyingHeaders.set.apply(underlyingHeaders, arguments);
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
getSetCookie: {
|
|
1119
|
+
value: function getSetCookie() {
|
|
1120
|
+
const expression = "`headers().getSetCookie()`";
|
|
1121
|
+
syncIODev(route, expression);
|
|
1122
|
+
return underlyingHeaders.getSetCookie.apply(underlyingHeaders, arguments);
|
|
1123
|
+
}
|
|
1124
|
+
},
|
|
1125
|
+
forEach: {
|
|
1126
|
+
value: function forEach() {
|
|
1127
|
+
const expression = "`headers().forEach(...)`";
|
|
1128
|
+
syncIODev(route, expression);
|
|
1129
|
+
return underlyingHeaders.forEach.apply(underlyingHeaders, arguments);
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
keys: {
|
|
1133
|
+
value: function keys() {
|
|
1134
|
+
const expression = "`headers().keys()`";
|
|
1135
|
+
syncIODev(route, expression);
|
|
1136
|
+
return underlyingHeaders.keys.apply(underlyingHeaders, arguments);
|
|
1137
|
+
}
|
|
1138
|
+
},
|
|
1139
|
+
values: {
|
|
1140
|
+
value: function values() {
|
|
1141
|
+
const expression = "`headers().values()`";
|
|
1142
|
+
syncIODev(route, expression);
|
|
1143
|
+
return underlyingHeaders.values.apply(underlyingHeaders, arguments);
|
|
1144
|
+
}
|
|
1145
|
+
},
|
|
1146
|
+
entries: {
|
|
1147
|
+
value: function entries() {
|
|
1148
|
+
const expression = "`headers().entries()`";
|
|
1149
|
+
syncIODev(route, expression);
|
|
1150
|
+
return underlyingHeaders.entries.apply(underlyingHeaders, arguments);
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
[Symbol.iterator]: {
|
|
1154
|
+
value: function() {
|
|
1155
|
+
const expression = "`...headers()` or similar iteration";
|
|
1156
|
+
syncIODev(route, expression);
|
|
1157
|
+
return underlyingHeaders[Symbol.iterator].apply(underlyingHeaders, arguments);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
return promise;
|
|
1162
|
+
}
|
|
1163
|
+
function describeNameArg(arg) {
|
|
1164
|
+
return typeof arg === "string" ? `'${arg}'` : "...";
|
|
1165
|
+
}
|
|
1166
|
+
function syncIODev(route, expression) {
|
|
1167
|
+
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
|
1168
|
+
if (workUnitStore && workUnitStore.type === "request" && workUnitStore.prerenderPhase === true) {
|
|
1169
|
+
const requestStore = workUnitStore;
|
|
1170
|
+
(0, _dynamicrendering.trackSynchronousRequestDataAccessInDev)(requestStore);
|
|
1171
|
+
}
|
|
1172
|
+
warnForSyncAccess(route, expression);
|
|
1173
|
+
}
|
|
1174
|
+
var warnForSyncAccess = (0, _creatededupedbycallsiteservererrorlogger.createDedupedByCallsiteServerErrorLoggerDev)(createHeadersAccessError);
|
|
1175
|
+
function createHeadersAccessError(route, expression) {
|
|
1176
|
+
const prefix = route ? `Route "${route}" ` : "This route ";
|
|
1177
|
+
return Object.defineProperty(new Error(`${prefix}used ${expression}. \`headers()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis`), "__NEXT_ERROR_CODE", {
|
|
1178
|
+
value: "E277",
|
|
1179
|
+
enumerable: false,
|
|
1180
|
+
configurable: true
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
|
|
1186
|
+
// node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/request/draft-mode.js
|
|
1187
|
+
var require_draft_mode = __commonJS({
|
|
1188
|
+
"node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/request/draft-mode.js"(exports) {
|
|
1189
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1190
|
+
value: true
|
|
1191
|
+
});
|
|
1192
|
+
Object.defineProperty(exports, "draftMode", {
|
|
1193
|
+
enumerable: true,
|
|
1194
|
+
get: function() {
|
|
1195
|
+
return draftMode;
|
|
1196
|
+
}
|
|
1197
|
+
});
|
|
1198
|
+
var _workunitasyncstorageexternal = require_work_unit_async_storage_external();
|
|
1199
|
+
var _workasyncstorageexternal = require_work_async_storage_external();
|
|
1200
|
+
var _dynamicrendering = require_dynamic_rendering();
|
|
1201
|
+
var _creatededupedbycallsiteservererrorlogger = require_create_deduped_by_callsite_server_error_logger();
|
|
1202
|
+
var _staticgenerationbailout = require_static_generation_bailout();
|
|
1203
|
+
var _hooksservercontext = require_hooks_server_context();
|
|
1204
|
+
function draftMode() {
|
|
1205
|
+
const callingExpression = "draftMode";
|
|
1206
|
+
const workStore = _workasyncstorageexternal.workAsyncStorage.getStore();
|
|
1207
|
+
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
|
1208
|
+
if (!workStore || !workUnitStore) {
|
|
1209
|
+
(0, _workunitasyncstorageexternal.throwForMissingRequestStore)(callingExpression);
|
|
1210
|
+
}
|
|
1211
|
+
switch (workUnitStore.type) {
|
|
1212
|
+
case "request":
|
|
1213
|
+
return createOrGetCachedExoticDraftMode(workUnitStore.draftMode, workStore);
|
|
1214
|
+
case "cache":
|
|
1215
|
+
case "unstable-cache":
|
|
1216
|
+
const draftModeProvider = (0, _workunitasyncstorageexternal.getDraftModeProviderForCacheScope)(workStore, workUnitStore);
|
|
1217
|
+
if (draftModeProvider) {
|
|
1218
|
+
return createOrGetCachedExoticDraftMode(draftModeProvider, workStore);
|
|
1219
|
+
}
|
|
1220
|
+
// Otherwise, we fall through to providing an empty draft mode.
|
|
1221
|
+
// eslint-disable-next-line no-fallthrough
|
|
1222
|
+
case "prerender":
|
|
1223
|
+
case "prerender-ppr":
|
|
1224
|
+
case "prerender-legacy":
|
|
1225
|
+
if (process.env.NODE_ENV === "development" && !(workStore == null ? void 0 : workStore.isPrefetchRequest)) {
|
|
1226
|
+
const route = workStore == null ? void 0 : workStore.route;
|
|
1227
|
+
return createExoticDraftModeWithDevWarnings(null, route);
|
|
1228
|
+
} else {
|
|
1229
|
+
return createExoticDraftMode(null);
|
|
1230
|
+
}
|
|
1231
|
+
default:
|
|
1232
|
+
const _exhaustiveCheck = workUnitStore;
|
|
1233
|
+
return _exhaustiveCheck;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
function createOrGetCachedExoticDraftMode(draftModeProvider, workStore) {
|
|
1237
|
+
const cachedDraftMode = CachedDraftModes.get(draftMode);
|
|
1238
|
+
if (cachedDraftMode) {
|
|
1239
|
+
return cachedDraftMode;
|
|
1240
|
+
}
|
|
1241
|
+
let promise;
|
|
1242
|
+
if (process.env.NODE_ENV === "development" && !(workStore == null ? void 0 : workStore.isPrefetchRequest)) {
|
|
1243
|
+
const route = workStore == null ? void 0 : workStore.route;
|
|
1244
|
+
promise = createExoticDraftModeWithDevWarnings(draftModeProvider, route);
|
|
1245
|
+
} else {
|
|
1246
|
+
promise = createExoticDraftMode(draftModeProvider);
|
|
1247
|
+
}
|
|
1248
|
+
CachedDraftModes.set(draftModeProvider, promise);
|
|
1249
|
+
return promise;
|
|
1250
|
+
}
|
|
1251
|
+
var CachedDraftModes = /* @__PURE__ */ new WeakMap();
|
|
1252
|
+
function createExoticDraftMode(underlyingProvider) {
|
|
1253
|
+
const instance = new DraftMode(underlyingProvider);
|
|
1254
|
+
const promise = Promise.resolve(instance);
|
|
1255
|
+
Object.defineProperty(promise, "isEnabled", {
|
|
1256
|
+
get() {
|
|
1257
|
+
return instance.isEnabled;
|
|
1258
|
+
},
|
|
1259
|
+
set(newValue) {
|
|
1260
|
+
Object.defineProperty(promise, "isEnabled", {
|
|
1261
|
+
value: newValue,
|
|
1262
|
+
writable: true,
|
|
1263
|
+
enumerable: true
|
|
1264
|
+
});
|
|
1265
|
+
},
|
|
1266
|
+
enumerable: true,
|
|
1267
|
+
configurable: true
|
|
1268
|
+
});
|
|
1269
|
+
promise.enable = instance.enable.bind(instance);
|
|
1270
|
+
promise.disable = instance.disable.bind(instance);
|
|
1271
|
+
return promise;
|
|
1272
|
+
}
|
|
1273
|
+
function createExoticDraftModeWithDevWarnings(underlyingProvider, route) {
|
|
1274
|
+
const instance = new DraftMode(underlyingProvider);
|
|
1275
|
+
const promise = Promise.resolve(instance);
|
|
1276
|
+
Object.defineProperty(promise, "isEnabled", {
|
|
1277
|
+
get() {
|
|
1278
|
+
const expression = "`draftMode().isEnabled`";
|
|
1279
|
+
syncIODev(route, expression);
|
|
1280
|
+
return instance.isEnabled;
|
|
1281
|
+
},
|
|
1282
|
+
set(newValue) {
|
|
1283
|
+
Object.defineProperty(promise, "isEnabled", {
|
|
1284
|
+
value: newValue,
|
|
1285
|
+
writable: true,
|
|
1286
|
+
enumerable: true
|
|
1287
|
+
});
|
|
1288
|
+
},
|
|
1289
|
+
enumerable: true,
|
|
1290
|
+
configurable: true
|
|
1291
|
+
});
|
|
1292
|
+
Object.defineProperty(promise, "enable", {
|
|
1293
|
+
value: function get() {
|
|
1294
|
+
const expression = "`draftMode().enable()`";
|
|
1295
|
+
syncIODev(route, expression);
|
|
1296
|
+
return instance.enable.apply(instance, arguments);
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1299
|
+
Object.defineProperty(promise, "disable", {
|
|
1300
|
+
value: function get() {
|
|
1301
|
+
const expression = "`draftMode().disable()`";
|
|
1302
|
+
syncIODev(route, expression);
|
|
1303
|
+
return instance.disable.apply(instance, arguments);
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
return promise;
|
|
1307
|
+
}
|
|
1308
|
+
var DraftMode = class {
|
|
1309
|
+
constructor(provider) {
|
|
1310
|
+
this._provider = provider;
|
|
1311
|
+
}
|
|
1312
|
+
get isEnabled() {
|
|
1313
|
+
if (this._provider !== null) {
|
|
1314
|
+
return this._provider.isEnabled;
|
|
1315
|
+
}
|
|
1316
|
+
return false;
|
|
1317
|
+
}
|
|
1318
|
+
enable() {
|
|
1319
|
+
trackDynamicDraftMode("draftMode().enable()");
|
|
1320
|
+
if (this._provider !== null) {
|
|
1321
|
+
this._provider.enable();
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
disable() {
|
|
1325
|
+
trackDynamicDraftMode("draftMode().disable()");
|
|
1326
|
+
if (this._provider !== null) {
|
|
1327
|
+
this._provider.disable();
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
function syncIODev(route, expression) {
|
|
1332
|
+
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
|
1333
|
+
if (workUnitStore && workUnitStore.type === "request" && workUnitStore.prerenderPhase === true) {
|
|
1334
|
+
const requestStore = workUnitStore;
|
|
1335
|
+
(0, _dynamicrendering.trackSynchronousRequestDataAccessInDev)(requestStore);
|
|
1336
|
+
}
|
|
1337
|
+
warnForSyncAccess(route, expression);
|
|
1338
|
+
}
|
|
1339
|
+
var warnForSyncAccess = (0, _creatededupedbycallsiteservererrorlogger.createDedupedByCallsiteServerErrorLoggerDev)(createDraftModeAccessError);
|
|
1340
|
+
function createDraftModeAccessError(route, expression) {
|
|
1341
|
+
const prefix = route ? `Route "${route}" ` : "This route ";
|
|
1342
|
+
return Object.defineProperty(new Error(`${prefix}used ${expression}. \`draftMode()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis`), "__NEXT_ERROR_CODE", {
|
|
1343
|
+
value: "E377",
|
|
1344
|
+
enumerable: false,
|
|
1345
|
+
configurable: true
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
function trackDynamicDraftMode(expression) {
|
|
1349
|
+
const store = _workasyncstorageexternal.workAsyncStorage.getStore();
|
|
1350
|
+
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
|
1351
|
+
if (store) {
|
|
1352
|
+
if (workUnitStore) {
|
|
1353
|
+
if (workUnitStore.type === "cache") {
|
|
1354
|
+
throw Object.defineProperty(new Error(`Route ${store.route} used "${expression}" inside "use cache". The enabled status of draftMode can be read in caches but you must not enable or disable draftMode inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
|
|
1355
|
+
value: "E246",
|
|
1356
|
+
enumerable: false,
|
|
1357
|
+
configurable: true
|
|
1358
|
+
});
|
|
1359
|
+
} else if (workUnitStore.type === "unstable-cache") {
|
|
1360
|
+
throw Object.defineProperty(new Error(`Route ${store.route} used "${expression}" inside a function cached with "unstable_cache(...)". The enabled status of draftMode can be read in caches but you must not enable or disable draftMode inside a cache. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`), "__NEXT_ERROR_CODE", {
|
|
1361
|
+
value: "E259",
|
|
1362
|
+
enumerable: false,
|
|
1363
|
+
configurable: true
|
|
1364
|
+
});
|
|
1365
|
+
} else if (workUnitStore.phase === "after") {
|
|
1366
|
+
throw Object.defineProperty(new Error(`Route ${store.route} used "${expression}" inside \`after\`. The enabled status of draftMode can be read inside \`after\` but you cannot enable or disable draftMode. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`), "__NEXT_ERROR_CODE", {
|
|
1367
|
+
value: "E348",
|
|
1368
|
+
enumerable: false,
|
|
1369
|
+
configurable: true
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
if (store.dynamicShouldError) {
|
|
1374
|
+
throw Object.defineProperty(new _staticgenerationbailout.StaticGenBailoutError(`Route ${store.route} 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`), "__NEXT_ERROR_CODE", {
|
|
1375
|
+
value: "E553",
|
|
1376
|
+
enumerable: false,
|
|
1377
|
+
configurable: true
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
if (workUnitStore) {
|
|
1381
|
+
if (workUnitStore.type === "prerender") {
|
|
1382
|
+
const error = Object.defineProperty(new Error(`Route ${store.route} used ${expression} without first calling \`await connection()\`. See more info here: https://nextjs.org/docs/messages/next-prerender-sync-headers`), "__NEXT_ERROR_CODE", {
|
|
1383
|
+
value: "E126",
|
|
1384
|
+
enumerable: false,
|
|
1385
|
+
configurable: true
|
|
1386
|
+
});
|
|
1387
|
+
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(store.route, expression, error, workUnitStore);
|
|
1388
|
+
} else if (workUnitStore.type === "prerender-ppr") {
|
|
1389
|
+
(0, _dynamicrendering.postponeWithTracking)(store.route, expression, workUnitStore.dynamicTracking);
|
|
1390
|
+
} else if (workUnitStore.type === "prerender-legacy") {
|
|
1391
|
+
workUnitStore.revalidate = 0;
|
|
1392
|
+
const err = Object.defineProperty(new _hooksservercontext.DynamicServerError(`Route ${store.route} couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`), "__NEXT_ERROR_CODE", {
|
|
1393
|
+
value: "E558",
|
|
1394
|
+
enumerable: false,
|
|
1395
|
+
configurable: true
|
|
1396
|
+
});
|
|
1397
|
+
store.dynamicUsageDescription = expression;
|
|
1398
|
+
store.dynamicUsageStack = err.stack;
|
|
1399
|
+
throw err;
|
|
1400
|
+
} else if (process.env.NODE_ENV === "development" && workUnitStore && workUnitStore.type === "request") {
|
|
1401
|
+
workUnitStore.usedDynamic = true;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
|
|
1409
|
+
// node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/headers.js
|
|
1410
|
+
var require_headers3 = __commonJS({
|
|
1411
|
+
"node_modules/.pnpm/next@15.3.1_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/headers.js"(exports, module) {
|
|
1412
|
+
module.exports.cookies = require_cookies2().cookies;
|
|
1413
|
+
module.exports.headers = require_headers2().headers;
|
|
1414
|
+
module.exports.draftMode = require_draft_mode().draftMode;
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
|
|
1418
|
+
// src/server/index.ts
|
|
1419
|
+
var import_headers = __toESM(require_headers3(), 1);
|
|
1420
|
+
var PreprError = class extends Error {
|
|
1421
|
+
constructor(message, code, context, originalError) {
|
|
1422
|
+
super(message);
|
|
1423
|
+
this.code = code;
|
|
1424
|
+
this.context = context;
|
|
1425
|
+
this.originalError = originalError;
|
|
1426
|
+
this.name = "PreprError";
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
function getPreprHeader(name) {
|
|
1430
|
+
return __async(this, null, function* () {
|
|
1431
|
+
const headersList = yield (0, import_headers.headers)();
|
|
1432
|
+
return headersList.get(name);
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
function getPreprUUID() {
|
|
1436
|
+
return __async(this, null, function* () {
|
|
1437
|
+
return getPreprHeader("prepr-customer-id");
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
function getActiveSegment() {
|
|
1441
|
+
return __async(this, null, function* () {
|
|
1442
|
+
return getPreprHeader("Prepr-Segments");
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
function getActiveVariant() {
|
|
1446
|
+
return __async(this, null, function* () {
|
|
1447
|
+
return getPreprHeader("Prepr-ABtesting");
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
function getPreprHeaders() {
|
|
1451
|
+
return __async(this, null, function* () {
|
|
1452
|
+
const preprHeaders = {};
|
|
1453
|
+
const headersList = yield (0, import_headers.headers)();
|
|
1454
|
+
headersList.forEach((value, key) => {
|
|
1455
|
+
if (key.startsWith("prepr") || key.startsWith("Prepr")) {
|
|
1456
|
+
preprHeaders[key] = value;
|
|
1457
|
+
}
|
|
1458
|
+
});
|
|
1459
|
+
return preprHeaders;
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
function validatePreprToken(token) {
|
|
1463
|
+
if (!token) {
|
|
1464
|
+
return { valid: false, error: "Token is required" };
|
|
1465
|
+
}
|
|
1466
|
+
if (!token.startsWith("https://")) {
|
|
1467
|
+
return { valid: false, error: "Token must be a valid HTTPS URL" };
|
|
1468
|
+
}
|
|
1469
|
+
return { valid: true };
|
|
1470
|
+
}
|
|
1471
|
+
function isPreviewMode() {
|
|
1472
|
+
return process.env.PREPR_ENV === "preview";
|
|
1473
|
+
}
|
|
1474
|
+
function extractAccessToken(graphqlUrl) {
|
|
1475
|
+
if (!graphqlUrl) return null;
|
|
1476
|
+
try {
|
|
1477
|
+
const url = new URL(graphqlUrl);
|
|
1478
|
+
if (url.hostname !== "graphql.prepr.io") return null;
|
|
1479
|
+
const pathParts = url.pathname.split("/");
|
|
1480
|
+
const token = pathParts[pathParts.length - 1];
|
|
1481
|
+
return token && token.length > 0 ? token : null;
|
|
1482
|
+
} catch (e) {
|
|
1483
|
+
return null;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
function getPreprEnvironmentSegments(token) {
|
|
1487
|
+
return __async(this, null, function* () {
|
|
1488
|
+
const validation = validatePreprToken(token);
|
|
1489
|
+
if (!validation.valid) {
|
|
1490
|
+
throw new PreprError(
|
|
1491
|
+
validation.error,
|
|
1492
|
+
"INVALID_TOKEN",
|
|
1493
|
+
"getPreprEnvironmentSegments"
|
|
1494
|
+
);
|
|
1495
|
+
}
|
|
1496
|
+
try {
|
|
1497
|
+
const response = yield fetch(token, {
|
|
1498
|
+
headers: {
|
|
1499
|
+
"User-Agent": `Prepr-Preview-Bar/${getPackageVersion()}`,
|
|
1500
|
+
"Content-Type": "application/json"
|
|
1501
|
+
},
|
|
1502
|
+
method: "POST",
|
|
1503
|
+
body: JSON.stringify({
|
|
1504
|
+
query: `{
|
|
1505
|
+
_Segments {
|
|
1506
|
+
_id
|
|
1507
|
+
name
|
|
1508
|
+
}
|
|
1509
|
+
}`
|
|
1510
|
+
})
|
|
1511
|
+
});
|
|
1512
|
+
if (!response.ok) {
|
|
1513
|
+
throw new PreprError(
|
|
1514
|
+
`HTTP ${response.status}: ${response.statusText}`,
|
|
1515
|
+
"HTTP_ERROR",
|
|
1516
|
+
"getPreprEnvironmentSegments"
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1519
|
+
const json = yield response.json();
|
|
1520
|
+
if (!json || !json.data || !json.data._Segments) {
|
|
1521
|
+
throw new PreprError(
|
|
1522
|
+
"Invalid response format from Prepr API",
|
|
1523
|
+
"INVALID_RESPONSE",
|
|
1524
|
+
"getPreprEnvironmentSegments"
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1527
|
+
return json.data._Segments;
|
|
1528
|
+
} catch (error) {
|
|
1529
|
+
if (error instanceof PreprError) {
|
|
1530
|
+
throw error;
|
|
1531
|
+
}
|
|
1532
|
+
throw new PreprError(
|
|
1533
|
+
"Failed to fetch segments from Prepr API",
|
|
1534
|
+
"FETCH_ERROR",
|
|
1535
|
+
"getPreprEnvironmentSegments",
|
|
1536
|
+
error instanceof Error ? error : new Error(String(error))
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
function getToolbarProps(token) {
|
|
1542
|
+
return __async(this, null, function* () {
|
|
1543
|
+
let data = [];
|
|
1544
|
+
let activeSegment = null;
|
|
1545
|
+
let activeVariant = null;
|
|
1546
|
+
if (isPreviewMode()) {
|
|
1547
|
+
try {
|
|
1548
|
+
data = yield getPreprEnvironmentSegments(token);
|
|
1549
|
+
activeSegment = yield getActiveSegment();
|
|
1550
|
+
activeVariant = yield getActiveVariant();
|
|
1551
|
+
} catch (error) {
|
|
1552
|
+
console.error("Failed to fetch toolbar props:", error);
|
|
1553
|
+
data = [];
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
return {
|
|
1557
|
+
activeSegment,
|
|
1558
|
+
activeVariant,
|
|
1559
|
+
data
|
|
1560
|
+
};
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1563
|
+
function getPackageVersion() {
|
|
1564
|
+
return package_default.version;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
export { PreprError, extractAccessToken, getActiveSegment, getActiveVariant, getPreprEnvironmentSegments, getPreprHeaders, getPreprUUID, getToolbarProps, isPreviewMode, validatePreprToken };
|
|
1568
|
+
//# sourceMappingURL=index.mjs.map
|
|
1569
|
+
//# sourceMappingURL=index.mjs.map
|