vinext 0.0.21 → 0.0.22

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.
Files changed (51) hide show
  1. package/dist/deploy.d.ts.map +1 -1
  2. package/dist/deploy.js +6 -3
  3. package/dist/deploy.js.map +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +179 -10
  6. package/dist/index.js.map +1 -1
  7. package/dist/routing/app-router.d.ts.map +1 -1
  8. package/dist/routing/app-router.js +1 -41
  9. package/dist/routing/app-router.js.map +1 -1
  10. package/dist/routing/pages-router.d.ts.map +1 -1
  11. package/dist/routing/pages-router.js +1 -27
  12. package/dist/routing/pages-router.js.map +1 -1
  13. package/dist/routing/utils.d.ts +25 -0
  14. package/dist/routing/utils.d.ts.map +1 -0
  15. package/dist/routing/utils.js +70 -0
  16. package/dist/routing/utils.js.map +1 -0
  17. package/dist/server/app-dev-server.d.ts.map +1 -1
  18. package/dist/server/app-dev-server.js +70 -3
  19. package/dist/server/app-dev-server.js.map +1 -1
  20. package/dist/server/dev-server.d.ts.map +1 -1
  21. package/dist/server/dev-server.js +77 -4
  22. package/dist/server/dev-server.js.map +1 -1
  23. package/dist/server/prod-server.d.ts.map +1 -1
  24. package/dist/server/prod-server.js +7 -0
  25. package/dist/server/prod-server.js.map +1 -1
  26. package/dist/server/request-log.d.ts +34 -0
  27. package/dist/server/request-log.d.ts.map +1 -0
  28. package/dist/server/request-log.js +65 -0
  29. package/dist/server/request-log.js.map +1 -0
  30. package/dist/shims/cache-runtime.d.ts.map +1 -1
  31. package/dist/shims/cache-runtime.js +5 -1
  32. package/dist/shims/cache-runtime.js.map +1 -1
  33. package/dist/shims/cache.d.ts +6 -0
  34. package/dist/shims/cache.d.ts.map +1 -1
  35. package/dist/shims/cache.js +22 -2
  36. package/dist/shims/cache.js.map +1 -1
  37. package/dist/shims/head.d.ts +11 -0
  38. package/dist/shims/head.d.ts.map +1 -1
  39. package/dist/shims/head.js +21 -0
  40. package/dist/shims/head.js.map +1 -1
  41. package/dist/shims/headers.d.ts +8 -0
  42. package/dist/shims/headers.d.ts.map +1 -1
  43. package/dist/shims/headers.js +41 -0
  44. package/dist/shims/headers.js.map +1 -1
  45. package/dist/shims/script.d.ts.map +1 -1
  46. package/dist/shims/script.js +7 -1
  47. package/dist/shims/script.js.map +1 -1
  48. package/dist/shims/server.d.ts.map +1 -1
  49. package/dist/shims/server.js +2 -1
  50. package/dist/shims/server.js.map +1 -1
  51. package/package.json +1 -1
@@ -42,6 +42,44 @@ function _getState() {
42
42
  export function markDynamicUsage() {
43
43
  _getState().dynamicUsageDetected = true;
44
44
  }
45
+ // ---------------------------------------------------------------------------
46
+ // Cache scope detection — checks whether we're inside "use cache" or
47
+ // unstable_cache() by reading ALS instances stored on globalThis via Symbols.
48
+ // This avoids circular imports between headers.ts, cache.ts, and cache-runtime.ts.
49
+ // The ALS instances are registered by cache-runtime.ts and cache.ts respectively.
50
+ // ---------------------------------------------------------------------------
51
+ /** Symbol used by cache-runtime.ts to store the "use cache" ALS on globalThis */
52
+ const _USE_CACHE_ALS_KEY = Symbol.for("vinext.cacheRuntime.contextAls");
53
+ /** Symbol used by cache.ts to store the unstable_cache ALS on globalThis */
54
+ const _UNSTABLE_CACHE_ALS_KEY = Symbol.for("vinext.unstableCache.als");
55
+ const _gHeaders = globalThis;
56
+ function _isInsideUseCache() {
57
+ const als = _gHeaders[_USE_CACHE_ALS_KEY];
58
+ return als?.getStore() != null;
59
+ }
60
+ function _isInsideUnstableCache() {
61
+ const als = _gHeaders[_UNSTABLE_CACHE_ALS_KEY];
62
+ return als?.getStore() === true;
63
+ }
64
+ /**
65
+ * Throw if the current execution is inside a "use cache" or unstable_cache()
66
+ * scope. Called by dynamic request APIs (headers, cookies, connection) to
67
+ * prevent request-specific data from being frozen into cached results.
68
+ *
69
+ * @param apiName - The name of the API being called (e.g. "connection()")
70
+ */
71
+ export function throwIfInsideCacheScope(apiName) {
72
+ if (_isInsideUseCache()) {
73
+ throw new Error(`\`${apiName}\` cannot be called inside "use cache". ` +
74
+ `If you need this data inside a cached function, call \`${apiName}\` ` +
75
+ "outside and pass the required data as an argument.");
76
+ }
77
+ if (_isInsideUnstableCache()) {
78
+ throw new Error(`\`${apiName}\` cannot be called inside a function cached with \`unstable_cache()\`. ` +
79
+ `If you need this data inside a cached function, call \`${apiName}\` ` +
80
+ "outside and pass the required data as an argument.");
81
+ }
82
+ }
45
83
  /**
46
84
  * Check and reset the dynamic usage flag.
47
85
  * Called by the server after rendering to decide on caching.
@@ -172,6 +210,7 @@ export function headersContextFromRequest(request) {
172
210
  * the context is already available).
173
211
  */
174
212
  export async function headers() {
213
+ throwIfInsideCacheScope("headers()");
175
214
  const state = _getState();
176
215
  if (!state.headersContext) {
177
216
  throw new Error("headers() can only be called from a Server Component, Route Handler, " +
@@ -185,6 +224,7 @@ export async function headers() {
185
224
  * Returns a ReadonlyRequestCookies-like object.
186
225
  */
187
226
  export async function cookies() {
227
+ throwIfInsideCacheScope("cookies()");
188
228
  const state = _getState();
189
229
  if (!state.headersContext) {
190
230
  throw new Error("cookies() can only be called from a Server Component, Route Handler, " +
@@ -241,6 +281,7 @@ export function getDraftModeCookieHeader() {
241
281
  * - `disable()`: clears the bypass cookie
242
282
  */
243
283
  export async function draftMode() {
284
+ throwIfInsideCacheScope("draftMode()");
244
285
  const state = _getState();
245
286
  const secret = getDraftSecret();
246
287
  const isEnabled = state.headersContext
@@ -1 +1 @@
1
- {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../src/shims/headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAkBrD,QAAQ;AACR,uEAAuE;AACvE,sEAAsE;AACtE,2EAA2E;AAC3E,oCAAoC;AACpC,6EAA6E;AAC7E,yCAAyC;AACzC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAC1D,M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Q,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,SAAS,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,IAAI,sBAAsB,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxC,MAAM,IAAI,GAAgE;YACxE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;YACpC,IAAI;gBACF,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;gBACvC,IAAI,IAAI;oBAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAClD,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;gBAC1B,OAAO,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;YAC9D,CAAC;SACF,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF","sourcesContent":["/**\n * next/headers shim\n *\n * Provides cookies() and headers() functions for App Router Server Components.\n * These read from a request context set by the RSC handler before rendering.\n *\n * In Next.js 15+, cookies() and headers() return Promises (async).\n * We support both the sync (legacy) and async patterns.\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\n// ---------------------------------------------------------------------------\n// Request context\n// ---------------------------------------------------------------------------\n\ninterface HeadersContext {\n headers: Headers;\n cookies: Map<string, string>;\n}\n\ntype VinextHeadersShimState = {\n headersContext: HeadersContext | null;\n dynamicUsageDetected: boolean;\n pendingSetCookies: string[];\n draftModeCookieHeader: string | null;\n};\n\n// NOTE:\n// - This shim can be loaded under multiple module specifiers in Vite's\n// multi-environment setup (RSC/SSR). Store the AsyncLocalStorage on\n// globalThis so `connection()` (next/server) and `consumeDynamicUsage()`\n// (next/headers) always share it.\n// - We use AsyncLocalStorage so concurrent requests don't stomp each other's\n// headers/cookies/dynamic-usage state.\nconst _ALS_KEY = Symbol.for(\"vinext.nextHeadersShim.als\");\nconst _FALLBACK_KEY = Symbol.for(\"vinext.nextHeadersShim.fallback\");\nconst _g = globalThis as unknown as Record<PropertyKey, unknown>;\nconst _als = (_g[_ALS_KEY] ??= new AsyncLocalStorage<VinextHeadersShimState>()) as AsyncLocalStorage<VinextHeadersShimState>;\n\nconst _fallbackState = (_g[_FALLBACK_KEY] ??= {\n headersContext: null,\n dynamicUsageDetected: false,\n pendingSetCookies: [],\n draftModeCookieHeader: null,\n} satisfies VinextHeadersShimState) as VinextHeadersShimState;\n\nfunction _getState(): VinextHeadersShimState {\n const state = _als.getStore();\n return state ?? _fallbackState;\n}\n\n/**\n * Dynamic usage flag — set when a component calls connection(), cookies(),\n * headers(), or noStore() during rendering. When true, ISR caching is\n * bypassed and the response gets Cache-Control: no-store.\n */\n// (stored on _state)\n\n/**\n * Mark the current render as requiring dynamic (uncached) rendering.\n * Called by connection(), cookies(), headers(), and noStore().\n */\nexport function markDynamicUsage(): void {\n _getState().dynamicUsageDetected = true;\n}\n\n/**\n * Check and reset the dynamic usage flag.\n * Called by the server after rendering to decide on caching.\n */\nexport function consumeDynamicUsage(): boolean {\n const state = _getState();\n const used = state.dynamicUsageDetected;\n state.dynamicUsageDetected = false;\n return used;\n}\n\n/**\n * Set the headers/cookies context for the current RSC render.\n * Called by the framework's RSC entry before rendering each request.\n *\n * @deprecated Prefer runWithHeadersContext() which uses als.run() for\n * proper per-request isolation. This function mutates the ALS store\n * in-place and is only safe for cleanup (ctx=null) within an existing\n * als.run() scope.\n */\nexport function setHeadersContext(ctx: HeadersContext | null): void {\n if (ctx !== null) {\n // For backward compatibility, set context on the current ALS store\n // if one exists, otherwise update the fallback. Callers should\n // migrate to runWithHeadersContext() for new-request setup.\n const existing = _als.getStore();\n if (existing) {\n existing.headersContext = ctx;\n existing.dynamicUsageDetected = false;\n existing.pendingSetCookies = [];\n existing.draftModeCookieHeader = null;\n } else {\n _fallbackState.headersContext = ctx;\n _fallbackState.dynamicUsageDetected = false;\n _fallbackState.pendingSetCookies = [];\n _fallbackState.draftModeCookieHeader = null;\n }\n return;\n }\n\n // End of request cleanup: keep the store (so consumeDynamicUsage and\n // cookie flushing can still run), but clear the request headers/cookies.\n const state = _als.getStore();\n if (state) {\n state.headersContext = null;\n } else {\n _fallbackState.headersContext = null;\n }\n}\n\n/**\n * Run a function with headers context, ensuring the context propagates\n * through all async operations (including RSC streaming).\n *\n * Uses AsyncLocalStorage.run() to guarantee per-request isolation.\n * The ALS store propagates through all async continuations including\n * ReadableStream consumption, setTimeout callbacks, and Promise chains,\n * so RSC streaming works correctly — components that render when the\n * stream is consumed still see the correct request's context.\n */\nexport function runWithHeadersContext<T>(\n ctx: HeadersContext,\n fn: () => T | Promise<T>,\n): T | Promise<T> {\n const state: VinextHeadersShimState = {\n headersContext: ctx,\n dynamicUsageDetected: false,\n pendingSetCookies: [],\n draftModeCookieHeader: null,\n };\n\n return _als.run(state, fn);\n}\n\n/**\n * Apply middleware-forwarded request headers to the current headers context.\n *\n * When Next.js middleware calls `NextResponse.next({ request: { headers } })`,\n * the modified headers are encoded as `x-middleware-request-<name>` on the\n * middleware response. This function unpacks those prefixed headers and\n * replaces the corresponding entries on the live `HeadersContext` so that\n * subsequent calls to `headers()` / `cookies()` see the middleware changes.\n */\nexport function applyMiddlewareRequestHeaders(\n middlewareResponseHeaders: Headers,\n): void {\n const state = _getState();\n if (!state.headersContext) return;\n\n const ctx = state.headersContext;\n const PREFIX = \"x-middleware-request-\";\n\n for (const [key, value] of middlewareResponseHeaders) {\n if (key.startsWith(PREFIX)) {\n const realName = key.slice(PREFIX.length);\n ctx.headers.set(realName, value);\n }\n }\n\n // If middleware modified the cookie header, rebuild the cookies map.\n const newCookieHeader = ctx.headers.get(\"cookie\");\n if (newCookieHeader !== null) {\n ctx.cookies.clear();\n for (const part of newCookieHeader.split(\";\")) {\n const [k, ...rest] = part.split(\"=\");\n if (k) {\n ctx.cookies.set(k.trim(), rest.join(\"=\").trim());\n }\n }\n }\n}\n\n/**\n * Create a HeadersContext from a standard Request object.\n */\nexport function headersContextFromRequest(request: Request): HeadersContext {\n const cookies = new Map<string, string>();\n const cookieHeader = request.headers.get(\"cookie\") || \"\";\n for (const part of cookieHeader.split(\";\")) {\n const [key, ...rest] = part.split(\"=\");\n if (key) {\n cookies.set(key.trim(), rest.join(\"=\").trim());\n }\n }\n return {\n // Copy into a mutable Headers instance. In Cloudflare Workers the original\n // Request.headers is immutable; applyMiddlewareRequestHeaders() needs to\n // call .set() on this object after middleware runs.\n headers: new Headers(request.headers),\n cookies,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Read-only Headers instance from the incoming request.\n * Returns a Promise in Next.js 15+ style (but resolves synchronously since\n * the context is already available).\n */\nexport async function headers(): Promise<Headers> {\n const state = _getState();\n if (!state.headersContext) {\n throw new Error(\n \"headers() can only be called from a Server Component, Route Handler, \" +\n \"or Server Action. Make sure you're not calling it from a Client Component.\",\n );\n }\n markDynamicUsage();\n return state.headersContext.headers;\n}\n\n/**\n * Cookie jar from the incoming request.\n * Returns a ReadonlyRequestCookies-like object.\n */\nexport async function cookies(): Promise<RequestCookies> {\n const state = _getState();\n if (!state.headersContext) {\n throw new Error(\n \"cookies() can only be called from a Server Component, Route Handler, \" +\n \"or Server Action.\",\n );\n }\n markDynamicUsage();\n return new RequestCookies(state.headersContext.cookies);\n}\n\n// ---------------------------------------------------------------------------\n// Writable cookie accumulator for Route Handlers / Server Actions\n// ---------------------------------------------------------------------------\n\n/** Accumulated Set-Cookie headers from cookies().set() / .delete() calls */\n// (stored on _state)\n\n/**\n * Get and clear all pending Set-Cookie headers generated by cookies().set()/delete().\n * Called by the framework after rendering to attach headers to the response.\n */\nexport function getAndClearPendingCookies(): string[] {\n const state = _getState();\n const cookies = state.pendingSetCookies;\n state.pendingSetCookies = [];\n return cookies;\n}\n\n// Draft mode cookie name (matches Next.js convention)\nconst DRAFT_MODE_COOKIE = \"__prerender_bypass\";\n\n// Draft mode secret — generated once at build time via Vite `define` so the\n// __prerender_bypass cookie is consistent across all server instances (e.g.\n// multiple Cloudflare Workers isolates).\nfunction getDraftSecret(): string {\n const secret = process.env.__VINEXT_DRAFT_SECRET;\n if (!secret) {\n throw new Error(\n \"[vinext] __VINEXT_DRAFT_SECRET is not defined. \" +\n \"This should be set by the Vite plugin at build time.\",\n );\n }\n return secret;\n}\n\n// Store for Set-Cookie headers generated by draftMode().enable()/disable()\n// (stored on _state)\n\n/**\n * Get any Set-Cookie header generated by draftMode().enable()/disable().\n * Called by the framework after rendering to attach the header to the response.\n */\nexport function getDraftModeCookieHeader(): string | null {\n const state = _getState();\n const header = state.draftModeCookieHeader;\n state.draftModeCookieHeader = null;\n return header;\n}\n\ninterface DraftModeResult {\n isEnabled: boolean;\n enable(): void;\n disable(): void;\n}\n\n/**\n * Draft mode — check/toggle via a `__prerender_bypass` cookie.\n *\n * - `isEnabled`: true if the bypass cookie is present in the request\n * - `enable()`: sets the bypass cookie (for Route Handlers)\n * - `disable()`: clears the bypass cookie\n */\nexport async function draftMode(): Promise<DraftModeResult> {\n const state = _getState();\n const secret = getDraftSecret();\n const isEnabled = state.headersContext\n ? state.headersContext.cookies.get(DRAFT_MODE_COOKIE) === secret\n : false;\n\n return {\n isEnabled,\n enable(): void {\n if (state.headersContext) {\n state.headersContext.cookies.set(DRAFT_MODE_COOKIE, secret);\n }\n const secure = typeof process !== \"undefined\" && process.env?.NODE_ENV === \"production\" ? \"; Secure\" : \"\";\n state.draftModeCookieHeader =\n `${DRAFT_MODE_COOKIE}=${secret}; Path=/; HttpOnly; SameSite=Lax${secure}`;\n },\n disable(): void {\n if (state.headersContext) {\n state.headersContext.cookies.delete(DRAFT_MODE_COOKIE);\n }\n const secure = typeof process !== \"undefined\" && process.env?.NODE_ENV === \"production\" ? \"; Secure\" : \"\";\n state.draftModeCookieHeader =\n `${DRAFT_MODE_COOKIE}=; Path=/; HttpOnly; SameSite=Lax${secure}; Max-Age=0`;\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Cookie name/value validation (RFC 6265)\n// ---------------------------------------------------------------------------\n\n/**\n * RFC 6265 §4.1.1: cookie-name is a token (RFC 2616 §2.2).\n * Allowed: any visible ASCII (0x21-0x7E) except separators: ()<>@,;:\\\"/[]?={}\n */\nconst VALID_COOKIE_NAME_RE = /^[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2E\\x30-\\x39\\x41-\\x5A\\x5E-\\x7A\\x7C\\x7E]+$/;\n\nfunction validateCookieName(name: string): void {\n if (!name || !VALID_COOKIE_NAME_RE.test(name)) {\n throw new Error(`Invalid cookie name: ${JSON.stringify(name)}`);\n }\n}\n\n/**\n * Validate cookie attribute values (path, domain) to prevent injection\n * via semicolons, newlines, or other control characters.\n */\nfunction validateCookieAttributeValue(value: string, attributeName: string): void {\n for (let i = 0; i < value.length; i++) {\n const code = value.charCodeAt(i);\n if (code <= 0x1F || code === 0x7F || value[i] === \";\") {\n throw new Error(`Invalid cookie ${attributeName} value: ${JSON.stringify(value)}`);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// RequestCookies implementation\n// ---------------------------------------------------------------------------\n\nclass RequestCookies {\n private _cookies: Map<string, string>;\n\n constructor(cookies: Map<string, string>) {\n this._cookies = cookies;\n }\n\n get(name: string): { name: string; value: string } | undefined {\n const value = this._cookies.get(name);\n if (value === undefined) return undefined;\n return { name, value };\n }\n\n getAll(): Array<{ name: string; value: string }> {\n const result: Array<{ name: string; value: string }> = [];\n for (const [name, value] of this._cookies) {\n result.push({ name, value });\n }\n return result;\n }\n\n has(name: string): boolean {\n return this._cookies.has(name);\n }\n\n /**\n * Set a cookie. In Route Handlers and Server Actions, this produces\n * a Set-Cookie header on the response.\n */\n set(\n nameOrOptions: string | { name: string; value: string; path?: string; domain?: string; maxAge?: number; expires?: Date; httpOnly?: boolean; secure?: boolean; sameSite?: \"Strict\" | \"Lax\" | \"None\" },\n value?: string,\n options?: { path?: string; domain?: string; maxAge?: number; expires?: Date; httpOnly?: boolean; secure?: boolean; sameSite?: \"Strict\" | \"Lax\" | \"None\" },\n ): this {\n let cookieName: string;\n let cookieValue: string;\n let opts: typeof options;\n\n if (typeof nameOrOptions === \"string\") {\n cookieName = nameOrOptions;\n cookieValue = value ?? \"\";\n opts = options;\n } else {\n cookieName = nameOrOptions.name;\n cookieValue = nameOrOptions.value;\n opts = nameOrOptions;\n }\n\n validateCookieName(cookieName);\n\n // Update the local cookie map\n this._cookies.set(cookieName, cookieValue);\n\n // Build Set-Cookie header string\n const parts = [`${cookieName}=${encodeURIComponent(cookieValue)}`];\n if (opts?.path) {\n validateCookieAttributeValue(opts.path, \"Path\");\n parts.push(`Path=${opts.path}`);\n }\n if (opts?.domain) {\n validateCookieAttributeValue(opts.domain, \"Domain\");\n parts.push(`Domain=${opts.domain}`);\n }\n if (opts?.maxAge !== undefined) parts.push(`Max-Age=${opts.maxAge}`);\n if (opts?.expires) parts.push(`Expires=${opts.expires.toUTCString()}`);\n if (opts?.httpOnly) parts.push(\"HttpOnly\");\n if (opts?.secure) parts.push(\"Secure\");\n if (opts?.sameSite) parts.push(`SameSite=${opts.sameSite}`);\n\n _getState().pendingSetCookies.push(parts.join(\"; \"));\n return this;\n }\n\n /**\n * Delete a cookie by setting it with Max-Age=0.\n */\n delete(name: string): this {\n validateCookieName(name);\n this._cookies.delete(name);\n _getState().pendingSetCookies.push(`${name}=; Path=/; Max-Age=0`);\n return this;\n }\n\n get size(): number {\n return this._cookies.size;\n }\n\n [Symbol.iterator](): IterableIterator<[string, { name: string; value: string }]> {\n const entries = this._cookies.entries();\n const iter: IterableIterator<[string, { name: string; value: string }]> = {\n [Symbol.iterator]() { return iter; },\n next() {\n const { value, done } = entries.next();\n if (done) return { value: undefined, done: true };\n const [name, val] = value;\n return { value: [name, { name, value: val }], done: false };\n },\n };\n return iter;\n }\n\n toString(): string {\n const parts: string[] = [];\n for (const [name, value] of this._cookies) {\n parts.push(`${name}=${value}`);\n }\n return parts.join(\"; \");\n }\n}\n\n// Re-export types\nexport type { RequestCookies };\n"]}
1
+ {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../src/shims/headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAkBrD,QAAQ;AACR,uEAAuE;AACvE,sEAAsE;AACtE,2EAA2E;AAC3E,oCAAoC;AACpC,6EAA6E;AAC7E,yCAAyC;AACzC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAC1D,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;AACpE,MAAM,EAAE,GAAG,UAAqD,CAAC;AACjE,MAAM,IAAI,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,IAAI,iBAAiB,EAA0B,CAA8C,CAAC;AAE7H,MAAM,cAAc,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK;IAC5C,cAAc,EAAE,IAAI;IACpB,oBAAoB,EAAE,KAAK;IAC3B,iBAAiB,E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IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;gBACvC,IAAI,IAAI;oBAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAClD,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;gBAC1B,OAAO,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;YAC9D,CAAC;SACF,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF","sourcesContent":["/**\n * next/headers shim\n *\n * Provides cookies() and headers() functions for App Router Server Components.\n * These read from a request context set by the RSC handler before rendering.\n *\n * In Next.js 15+, cookies() and headers() return Promises (async).\n * We support both the sync (legacy) and async patterns.\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\n// ---------------------------------------------------------------------------\n// Request context\n// ---------------------------------------------------------------------------\n\ninterface HeadersContext {\n headers: Headers;\n cookies: Map<string, string>;\n}\n\ntype VinextHeadersShimState = {\n headersContext: HeadersContext | null;\n dynamicUsageDetected: boolean;\n pendingSetCookies: string[];\n draftModeCookieHeader: string | null;\n};\n\n// NOTE:\n// - This shim can be loaded under multiple module specifiers in Vite's\n// multi-environment setup (RSC/SSR). Store the AsyncLocalStorage on\n// globalThis so `connection()` (next/server) and `consumeDynamicUsage()`\n// (next/headers) always share it.\n// - We use AsyncLocalStorage so concurrent requests don't stomp each other's\n// headers/cookies/dynamic-usage state.\nconst _ALS_KEY = Symbol.for(\"vinext.nextHeadersShim.als\");\nconst _FALLBACK_KEY = Symbol.for(\"vinext.nextHeadersShim.fallback\");\nconst _g = globalThis as unknown as Record<PropertyKey, unknown>;\nconst _als = (_g[_ALS_KEY] ??= new AsyncLocalStorage<VinextHeadersShimState>()) as AsyncLocalStorage<VinextHeadersShimState>;\n\nconst _fallbackState = (_g[_FALLBACK_KEY] ??= {\n headersContext: null,\n dynamicUsageDetected: false,\n pendingSetCookies: [],\n draftModeCookieHeader: null,\n} satisfies VinextHeadersShimState) as VinextHeadersShimState;\n\nfunction _getState(): VinextHeadersShimState {\n const state = _als.getStore();\n return state ?? _fallbackState;\n}\n\n/**\n * Dynamic usage flag — set when a component calls connection(), cookies(),\n * headers(), or noStore() during rendering. When true, ISR caching is\n * bypassed and the response gets Cache-Control: no-store.\n */\n// (stored on _state)\n\n/**\n * Mark the current render as requiring dynamic (uncached) rendering.\n * Called by connection(), cookies(), headers(), and noStore().\n */\nexport function markDynamicUsage(): void {\n _getState().dynamicUsageDetected = true;\n}\n\n// ---------------------------------------------------------------------------\n// Cache scope detection — checks whether we're inside \"use cache\" or\n// unstable_cache() by reading ALS instances stored on globalThis via Symbols.\n// This avoids circular imports between headers.ts, cache.ts, and cache-runtime.ts.\n// The ALS instances are registered by cache-runtime.ts and cache.ts respectively.\n// ---------------------------------------------------------------------------\n\n/** Symbol used by cache-runtime.ts to store the \"use cache\" ALS on globalThis */\nconst _USE_CACHE_ALS_KEY = Symbol.for(\"vinext.cacheRuntime.contextAls\");\n/** Symbol used by cache.ts to store the unstable_cache ALS on globalThis */\nconst _UNSTABLE_CACHE_ALS_KEY = Symbol.for(\"vinext.unstableCache.als\");\nconst _gHeaders = globalThis as unknown as Record<PropertyKey, unknown>;\n\nfunction _isInsideUseCache(): boolean {\n const als = _gHeaders[_USE_CACHE_ALS_KEY] as AsyncLocalStorage<unknown> | undefined;\n return als?.getStore() != null;\n}\n\nfunction _isInsideUnstableCache(): boolean {\n const als = _gHeaders[_UNSTABLE_CACHE_ALS_KEY] as AsyncLocalStorage<unknown> | undefined;\n return als?.getStore() === true;\n}\n\n/**\n * Throw if the current execution is inside a \"use cache\" or unstable_cache()\n * scope. Called by dynamic request APIs (headers, cookies, connection) to\n * prevent request-specific data from being frozen into cached results.\n *\n * @param apiName - The name of the API being called (e.g. \"connection()\")\n */\nexport function throwIfInsideCacheScope(apiName: string): void {\n if (_isInsideUseCache()) {\n throw new Error(\n `\\`${apiName}\\` cannot be called inside \"use cache\". ` +\n `If you need this data inside a cached function, call \\`${apiName}\\` ` +\n \"outside and pass the required data as an argument.\",\n );\n }\n if (_isInsideUnstableCache()) {\n throw new Error(\n `\\`${apiName}\\` cannot be called inside a function cached with \\`unstable_cache()\\`. ` +\n `If you need this data inside a cached function, call \\`${apiName}\\` ` +\n \"outside and pass the required data as an argument.\",\n );\n }\n}\n\n/**\n * Check and reset the dynamic usage flag.\n * Called by the server after rendering to decide on caching.\n */\nexport function consumeDynamicUsage(): boolean {\n const state = _getState();\n const used = state.dynamicUsageDetected;\n state.dynamicUsageDetected = false;\n return used;\n}\n\n/**\n * Set the headers/cookies context for the current RSC render.\n * Called by the framework's RSC entry before rendering each request.\n *\n * @deprecated Prefer runWithHeadersContext() which uses als.run() for\n * proper per-request isolation. This function mutates the ALS store\n * in-place and is only safe for cleanup (ctx=null) within an existing\n * als.run() scope.\n */\nexport function setHeadersContext(ctx: HeadersContext | null): void {\n if (ctx !== null) {\n // For backward compatibility, set context on the current ALS store\n // if one exists, otherwise update the fallback. Callers should\n // migrate to runWithHeadersContext() for new-request setup.\n const existing = _als.getStore();\n if (existing) {\n existing.headersContext = ctx;\n existing.dynamicUsageDetected = false;\n existing.pendingSetCookies = [];\n existing.draftModeCookieHeader = null;\n } else {\n _fallbackState.headersContext = ctx;\n _fallbackState.dynamicUsageDetected = false;\n _fallbackState.pendingSetCookies = [];\n _fallbackState.draftModeCookieHeader = null;\n }\n return;\n }\n\n // End of request cleanup: keep the store (so consumeDynamicUsage and\n // cookie flushing can still run), but clear the request headers/cookies.\n const state = _als.getStore();\n if (state) {\n state.headersContext = null;\n } else {\n _fallbackState.headersContext = null;\n }\n}\n\n/**\n * Run a function with headers context, ensuring the context propagates\n * through all async operations (including RSC streaming).\n *\n * Uses AsyncLocalStorage.run() to guarantee per-request isolation.\n * The ALS store propagates through all async continuations including\n * ReadableStream consumption, setTimeout callbacks, and Promise chains,\n * so RSC streaming works correctly — components that render when the\n * stream is consumed still see the correct request's context.\n */\nexport function runWithHeadersContext<T>(\n ctx: HeadersContext,\n fn: () => T | Promise<T>,\n): T | Promise<T> {\n const state: VinextHeadersShimState = {\n headersContext: ctx,\n dynamicUsageDetected: false,\n pendingSetCookies: [],\n draftModeCookieHeader: null,\n };\n\n return _als.run(state, fn);\n}\n\n/**\n * Apply middleware-forwarded request headers to the current headers context.\n *\n * When Next.js middleware calls `NextResponse.next({ request: { headers } })`,\n * the modified headers are encoded as `x-middleware-request-<name>` on the\n * middleware response. This function unpacks those prefixed headers and\n * replaces the corresponding entries on the live `HeadersContext` so that\n * subsequent calls to `headers()` / `cookies()` see the middleware changes.\n */\nexport function applyMiddlewareRequestHeaders(\n middlewareResponseHeaders: Headers,\n): void {\n const state = _getState();\n if (!state.headersContext) return;\n\n const ctx = state.headersContext;\n const PREFIX = \"x-middleware-request-\";\n\n for (const [key, value] of middlewareResponseHeaders) {\n if (key.startsWith(PREFIX)) {\n const realName = key.slice(PREFIX.length);\n ctx.headers.set(realName, value);\n }\n }\n\n // If middleware modified the cookie header, rebuild the cookies map.\n const newCookieHeader = ctx.headers.get(\"cookie\");\n if (newCookieHeader !== null) {\n ctx.cookies.clear();\n for (const part of newCookieHeader.split(\";\")) {\n const [k, ...rest] = part.split(\"=\");\n if (k) {\n ctx.cookies.set(k.trim(), rest.join(\"=\").trim());\n }\n }\n }\n}\n\n/**\n * Create a HeadersContext from a standard Request object.\n */\nexport function headersContextFromRequest(request: Request): HeadersContext {\n const cookies = new Map<string, string>();\n const cookieHeader = request.headers.get(\"cookie\") || \"\";\n for (const part of cookieHeader.split(\";\")) {\n const [key, ...rest] = part.split(\"=\");\n if (key) {\n cookies.set(key.trim(), rest.join(\"=\").trim());\n }\n }\n return {\n // Copy into a mutable Headers instance. In Cloudflare Workers the original\n // Request.headers is immutable; applyMiddlewareRequestHeaders() needs to\n // call .set() on this object after middleware runs.\n headers: new Headers(request.headers),\n cookies,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Read-only Headers instance from the incoming request.\n * Returns a Promise in Next.js 15+ style (but resolves synchronously since\n * the context is already available).\n */\nexport async function headers(): Promise<Headers> {\n throwIfInsideCacheScope(\"headers()\");\n\n const state = _getState();\n if (!state.headersContext) {\n throw new Error(\n \"headers() can only be called from a Server Component, Route Handler, \" +\n \"or Server Action. Make sure you're not calling it from a Client Component.\",\n );\n }\n markDynamicUsage();\n return state.headersContext.headers;\n}\n\n/**\n * Cookie jar from the incoming request.\n * Returns a ReadonlyRequestCookies-like object.\n */\nexport async function cookies(): Promise<RequestCookies> {\n throwIfInsideCacheScope(\"cookies()\");\n\n const state = _getState();\n if (!state.headersContext) {\n throw new Error(\n \"cookies() can only be called from a Server Component, Route Handler, \" +\n \"or Server Action.\",\n );\n }\n markDynamicUsage();\n return new RequestCookies(state.headersContext.cookies);\n}\n\n// ---------------------------------------------------------------------------\n// Writable cookie accumulator for Route Handlers / Server Actions\n// ---------------------------------------------------------------------------\n\n/** Accumulated Set-Cookie headers from cookies().set() / .delete() calls */\n// (stored on _state)\n\n/**\n * Get and clear all pending Set-Cookie headers generated by cookies().set()/delete().\n * Called by the framework after rendering to attach headers to the response.\n */\nexport function getAndClearPendingCookies(): string[] {\n const state = _getState();\n const cookies = state.pendingSetCookies;\n state.pendingSetCookies = [];\n return cookies;\n}\n\n// Draft mode cookie name (matches Next.js convention)\nconst DRAFT_MODE_COOKIE = \"__prerender_bypass\";\n\n// Draft mode secret — generated once at build time via Vite `define` so the\n// __prerender_bypass cookie is consistent across all server instances (e.g.\n// multiple Cloudflare Workers isolates).\nfunction getDraftSecret(): string {\n const secret = process.env.__VINEXT_DRAFT_SECRET;\n if (!secret) {\n throw new Error(\n \"[vinext] __VINEXT_DRAFT_SECRET is not defined. \" +\n \"This should be set by the Vite plugin at build time.\",\n );\n }\n return secret;\n}\n\n// Store for Set-Cookie headers generated by draftMode().enable()/disable()\n// (stored on _state)\n\n/**\n * Get any Set-Cookie header generated by draftMode().enable()/disable().\n * Called by the framework after rendering to attach the header to the response.\n */\nexport function getDraftModeCookieHeader(): string | null {\n const state = _getState();\n const header = state.draftModeCookieHeader;\n state.draftModeCookieHeader = null;\n return header;\n}\n\ninterface DraftModeResult {\n isEnabled: boolean;\n enable(): void;\n disable(): void;\n}\n\n/**\n * Draft mode — check/toggle via a `__prerender_bypass` cookie.\n *\n * - `isEnabled`: true if the bypass cookie is present in the request\n * - `enable()`: sets the bypass cookie (for Route Handlers)\n * - `disable()`: clears the bypass cookie\n */\nexport async function draftMode(): Promise<DraftModeResult> {\n throwIfInsideCacheScope(\"draftMode()\");\n\n const state = _getState();\n const secret = getDraftSecret();\n const isEnabled = state.headersContext\n ? state.headersContext.cookies.get(DRAFT_MODE_COOKIE) === secret\n : false;\n\n return {\n isEnabled,\n enable(): void {\n if (state.headersContext) {\n state.headersContext.cookies.set(DRAFT_MODE_COOKIE, secret);\n }\n const secure = typeof process !== \"undefined\" && process.env?.NODE_ENV === \"production\" ? \"; Secure\" : \"\";\n state.draftModeCookieHeader =\n `${DRAFT_MODE_COOKIE}=${secret}; Path=/; HttpOnly; SameSite=Lax${secure}`;\n },\n disable(): void {\n if (state.headersContext) {\n state.headersContext.cookies.delete(DRAFT_MODE_COOKIE);\n }\n const secure = typeof process !== \"undefined\" && process.env?.NODE_ENV === \"production\" ? \"; Secure\" : \"\";\n state.draftModeCookieHeader =\n `${DRAFT_MODE_COOKIE}=; Path=/; HttpOnly; SameSite=Lax${secure}; Max-Age=0`;\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Cookie name/value validation (RFC 6265)\n// ---------------------------------------------------------------------------\n\n/**\n * RFC 6265 §4.1.1: cookie-name is a token (RFC 2616 §2.2).\n * Allowed: any visible ASCII (0x21-0x7E) except separators: ()<>@,;:\\\"/[]?={}\n */\nconst VALID_COOKIE_NAME_RE = /^[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2E\\x30-\\x39\\x41-\\x5A\\x5E-\\x7A\\x7C\\x7E]+$/;\n\nfunction validateCookieName(name: string): void {\n if (!name || !VALID_COOKIE_NAME_RE.test(name)) {\n throw new Error(`Invalid cookie name: ${JSON.stringify(name)}`);\n }\n}\n\n/**\n * Validate cookie attribute values (path, domain) to prevent injection\n * via semicolons, newlines, or other control characters.\n */\nfunction validateCookieAttributeValue(value: string, attributeName: string): void {\n for (let i = 0; i < value.length; i++) {\n const code = value.charCodeAt(i);\n if (code <= 0x1F || code === 0x7F || value[i] === \";\") {\n throw new Error(`Invalid cookie ${attributeName} value: ${JSON.stringify(value)}`);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// RequestCookies implementation\n// ---------------------------------------------------------------------------\n\nclass RequestCookies {\n private _cookies: Map<string, string>;\n\n constructor(cookies: Map<string, string>) {\n this._cookies = cookies;\n }\n\n get(name: string): { name: string; value: string } | undefined {\n const value = this._cookies.get(name);\n if (value === undefined) return undefined;\n return { name, value };\n }\n\n getAll(): Array<{ name: string; value: string }> {\n const result: Array<{ name: string; value: string }> = [];\n for (const [name, value] of this._cookies) {\n result.push({ name, value });\n }\n return result;\n }\n\n has(name: string): boolean {\n return this._cookies.has(name);\n }\n\n /**\n * Set a cookie. In Route Handlers and Server Actions, this produces\n * a Set-Cookie header on the response.\n */\n set(\n nameOrOptions: string | { name: string; value: string; path?: string; domain?: string; maxAge?: number; expires?: Date; httpOnly?: boolean; secure?: boolean; sameSite?: \"Strict\" | \"Lax\" | \"None\" },\n value?: string,\n options?: { path?: string; domain?: string; maxAge?: number; expires?: Date; httpOnly?: boolean; secure?: boolean; sameSite?: \"Strict\" | \"Lax\" | \"None\" },\n ): this {\n let cookieName: string;\n let cookieValue: string;\n let opts: typeof options;\n\n if (typeof nameOrOptions === \"string\") {\n cookieName = nameOrOptions;\n cookieValue = value ?? \"\";\n opts = options;\n } else {\n cookieName = nameOrOptions.name;\n cookieValue = nameOrOptions.value;\n opts = nameOrOptions;\n }\n\n validateCookieName(cookieName);\n\n // Update the local cookie map\n this._cookies.set(cookieName, cookieValue);\n\n // Build Set-Cookie header string\n const parts = [`${cookieName}=${encodeURIComponent(cookieValue)}`];\n if (opts?.path) {\n validateCookieAttributeValue(opts.path, \"Path\");\n parts.push(`Path=${opts.path}`);\n }\n if (opts?.domain) {\n validateCookieAttributeValue(opts.domain, \"Domain\");\n parts.push(`Domain=${opts.domain}`);\n }\n if (opts?.maxAge !== undefined) parts.push(`Max-Age=${opts.maxAge}`);\n if (opts?.expires) parts.push(`Expires=${opts.expires.toUTCString()}`);\n if (opts?.httpOnly) parts.push(\"HttpOnly\");\n if (opts?.secure) parts.push(\"Secure\");\n if (opts?.sameSite) parts.push(`SameSite=${opts.sameSite}`);\n\n _getState().pendingSetCookies.push(parts.join(\"; \"));\n return this;\n }\n\n /**\n * Delete a cookie by setting it with Max-Age=0.\n */\n delete(name: string): this {\n validateCookieName(name);\n this._cookies.delete(name);\n _getState().pendingSetCookies.push(`${name}=; Path=/; Max-Age=0`);\n return this;\n }\n\n get size(): number {\n return this._cookies.size;\n }\n\n [Symbol.iterator](): IterableIterator<[string, { name: string; value: string }]> {\n const entries = this._cookies.entries();\n const iter: IterableIterator<[string, { name: string; value: string }]> = {\n [Symbol.iterator]() { return iter; },\n next() {\n const { value, done } = entries.next();\n if (done) return { value: undefined, done: true };\n const [name, val] = value;\n return { value: [name, { name, value: val }], done: false };\n },\n };\n return iter;\n }\n\n toString(): string {\n const parts: string[] = [];\n for (const [name, value] of this._cookies) {\n parts.push(`${name}=${value}`);\n }\n return parts.join(\"; \");\n }\n}\n\n// Re-export types\nexport type { RequestCookies };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../src/shims/script.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,QAAQ,CAAC,EAAE,mBAAmB,GAAG,kBAAkB,GAAG,YAAY,GAAG,QAAQ,CAAC;IAC9E,uCAAuC;IACvC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,wCAAwC;IACxC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC5B,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,kCAAkC;IAClC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC7B,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,2BAA2B;IAC3B,uBAAuB,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sBAAsB;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4BAA4B;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAKD;;GAEG;AACH,wBAAgB,sBAAsB,CAA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B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAKD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CA6B/D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAI7D;AAED,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAoH7D;AAED,eAAe,MAAM,CAAC"}
@@ -12,6 +12,7 @@
12
12
  * - "worker": sets type="text/partytown" (requires Partytown setup)
13
13
  */
14
14
  import React, { useEffect, useRef } from "react";
15
+ import { escapeInlineContent } from "./head.js";
15
16
  // Track scripts that have already been loaded to avoid duplicates
16
17
  const loadedScripts = new Set();
17
18
  /**
@@ -149,7 +150,12 @@ function Script(props) {
149
150
  if (id)
150
151
  scriptProps.id = id;
151
152
  if (dangerouslySetInnerHTML) {
152
- scriptProps.dangerouslySetInnerHTML = dangerouslySetInnerHTML;
153
+ // Escape closing </script> sequences in inline content so the HTML
154
+ // parser doesn't prematurely terminate the element during SSR.
155
+ const raw = dangerouslySetInnerHTML.__html;
156
+ scriptProps.dangerouslySetInnerHTML = {
157
+ __html: escapeInlineContent(raw, "script"),
158
+ };
153
159
  }
154
160
  return React.createElement("script", scriptProps, children);
155
161
  }
@@ -1 +1 @@
1
- {"version":3,"file":"script.js","sourceRoot":"","sources":["../../src/shims/script.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAmCjD,kEAAkE;AAClE,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAkB;IACvD,MAAM,EAAE,GA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AAC;gBAC5B,WAAW,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;YAChE,CAAC;YACD,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC9D,CAAC;QACD,2CAA2C;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,2EAA2E;IAC3E,OAAO,IAAI,CAAC;AACd,CAAC;AAED,eAAe,MAAM,CAAC","sourcesContent":["\"use client\";\n\n/**\n * next/script shim\n *\n * Provides the <Script> component for loading third-party scripts with\n * configurable loading strategies.\n *\n * Strategies:\n * - \"beforeInteractive\": rendered as a <script> tag in SSR output\n * - \"afterInteractive\" (default): loaded client-side after hydration\n * - \"lazyOnload\": deferred until window.load + requestIdleCallback\n * - \"worker\": sets type=\"text/partytown\" (requires Partytown setup)\n */\nimport React, { useEffect, useRef } from \"react\";\n\nexport interface ScriptProps {\n /** Script source URL */\n src?: string;\n /** Loading strategy. Default: \"afterInteractive\" */\n strategy?: \"beforeInteractive\" | \"afterInteractive\" | \"lazyOnload\" | \"worker\";\n /** Unique identifier for the script */\n id?: string;\n /** Called when the script has loaded */\n onLoad?: (e: Event) => void;\n /** Called when the script is ready (after load, and on every re-render if already loaded) */\n onReady?: () => void;\n /** Called on script load error */\n onError?: (e: Event) => void;\n /** Inline script content */\n children?: React.ReactNode;\n /** Dangerous inner HTML */\n dangerouslySetInnerHTML?: { __html: string };\n /** Script type attribute */\n type?: string;\n /** Async attribute */\n async?: boolean;\n /** Defer attribute */\n defer?: boolean;\n /** Crossorigin attribute */\n crossOrigin?: string;\n /** Nonce for CSP */\n nonce?: string;\n /** Integrity hash */\n integrity?: string;\n /** Additional attributes */\n [key: string]: unknown;\n}\n\n// Track scripts that have already been loaded to avoid duplicates\nconst loadedScripts = new Set<string>();\n\n/**\n * Load a script imperatively (outside of React).\n */\nexport function handleClientScriptLoad(props: ScriptProps): void {\n const { src, id, onLoad, onError, strategy: _strategy, onReady: _onReady, children, ...rest } = props;\n if (typeof window === \"undefined\") return;\n\n const key = id ?? src ?? \"\";\n if (key && loadedScripts.has(key)) return;\n\n const el = document.createElement(\"script\");\n if (src) el.src = src;\n if (id) el.id = id;\n\n for (const [attr, value] of Object.entries(rest)) {\n if (attr === \"dangerouslySetInnerHTML\" || attr === \"className\") continue;\n if (typeof value === \"string\") {\n el.setAttribute(attr, value);\n } else if (typeof value === \"boolean\" && value) {\n el.setAttribute(attr, \"\");\n }\n }\n\n if (children && typeof children === \"string\") {\n el.textContent = children;\n }\n\n if (onLoad) el.addEventListener(\"load\", onLoad);\n if (onError) el.addEventListener(\"error\", onError);\n\n document.body.appendChild(el);\n if (key) loadedScripts.add(key);\n}\n\n/**\n * Initialize multiple scripts at once (called during app bootstrap).\n */\nexport function initScriptLoader(scripts: ScriptProps[]): void {\n for (const script of scripts) {\n handleClientScriptLoad(script);\n }\n}\n\nfunction Script(props: ScriptProps): React.ReactElement | null {\n const {\n src,\n id,\n strategy = \"afterInteractive\",\n onLoad,\n onReady,\n onError,\n children,\n dangerouslySetInnerHTML,\n ...rest\n } = props;\n\n const hasMounted = useRef(false);\n const key = id ?? src ?? \"\";\n\n // Client path: load scripts via useEffect based on strategy.\n // useEffect never runs during SSR, so it's safe to call unconditionally.\n useEffect(() => {\n if (hasMounted.current) return;\n hasMounted.current = true;\n\n // Already loaded — just fire onReady\n if (key && loadedScripts.has(key)) {\n onReady?.();\n return;\n }\n\n const load = () => {\n if (key && loadedScripts.has(key)) {\n onReady?.();\n return;\n }\n\n const el = document.createElement(\"script\");\n if (src) el.src = src;\n if (id) el.id = id;\n\n for (const [attr, value] of Object.entries(rest)) {\n if (attr === \"className\") {\n el.setAttribute(\"class\", String(value));\n } else if (typeof value === \"string\") {\n el.setAttribute(attr, value);\n } else if (typeof value === \"boolean\" && value) {\n el.setAttribute(attr, \"\");\n }\n }\n\n if (strategy === \"worker\") {\n el.setAttribute(\"type\", \"text/partytown\");\n }\n\n if (dangerouslySetInnerHTML?.__html) {\n el.innerHTML = dangerouslySetInnerHTML.__html as string;\n } else if (children && typeof children === \"string\") {\n el.textContent = children;\n }\n\n el.addEventListener(\"load\", (e) => {\n if (key) loadedScripts.add(key);\n onLoad?.(e);\n onReady?.();\n });\n\n if (onError) {\n el.addEventListener(\"error\", onError);\n }\n\n document.body.appendChild(el);\n };\n\n if (strategy === \"lazyOnload\") {\n // Wait for window load, then use idle callback\n if (document.readyState === \"complete\") {\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(load);\n } else {\n setTimeout(load, 1);\n }\n } else {\n window.addEventListener(\"load\", () => {\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(load);\n } else {\n setTimeout(load, 1);\n }\n });\n }\n } else {\n // \"afterInteractive\" (default), \"beforeInteractive\" (client re-mount), \"worker\"\n load();\n }\n }, [src, id, strategy, onLoad, onReady, onError, children, dangerouslySetInnerHTML, key, rest]);\n\n // SSR path: only \"beforeInteractive\" renders a <script> tag server-side\n if (typeof window === \"undefined\") {\n if (strategy === \"beforeInteractive\") {\n const scriptProps: Record<string, unknown> = { ...rest };\n if (src) scriptProps.src = src;\n if (id) scriptProps.id = id;\n if (dangerouslySetInnerHTML) {\n scriptProps.dangerouslySetInnerHTML = dangerouslySetInnerHTML;\n }\n return React.createElement(\"script\", scriptProps, children);\n }\n // Other strategies don't render during SSR\n return null;\n }\n\n // The component itself renders nothing — scripts are injected imperatively\n return null;\n}\n\nexport default Script;\n"]}
1
+ {"version":3,"file":"script.js","sourceRoot":"","sources":["../../src/shims/script.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAmChD,kEAAkE;AAClE,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,sBAAsB,C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AC;YAC5B,IAAI,uBAAuB,EAAE,CAAC;gBAC5B,mEAAmE;gBACnE,+DAA+D;gBAC/D,MAAM,GAAG,GAAG,uBAAuB,CAAC,MAAM,CAAC;gBAC3C,WAAW,CAAC,uBAAuB,GAAG;oBACpC,MAAM,EAAE,mBAAmB,CAAC,GAAG,EAAE,QAAQ,CAAC;iBAC3C,CAAC;YACJ,CAAC;YACD,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC9D,CAAC;QACD,2CAA2C;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,2EAA2E;IAC3E,OAAO,IAAI,CAAC;AACd,CAAC;AAED,eAAe,MAAM,CAAC","sourcesContent":["\"use client\";\n\n/**\n * next/script shim\n *\n * Provides the <Script> component for loading third-party scripts with\n * configurable loading strategies.\n *\n * Strategies:\n * - \"beforeInteractive\": rendered as a <script> tag in SSR output\n * - \"afterInteractive\" (default): loaded client-side after hydration\n * - \"lazyOnload\": deferred until window.load + requestIdleCallback\n * - \"worker\": sets type=\"text/partytown\" (requires Partytown setup)\n */\nimport React, { useEffect, useRef } from \"react\";\nimport { escapeInlineContent } from \"./head.js\";\n\nexport interface ScriptProps {\n /** Script source URL */\n src?: string;\n /** Loading strategy. Default: \"afterInteractive\" */\n strategy?: \"beforeInteractive\" | \"afterInteractive\" | \"lazyOnload\" | \"worker\";\n /** Unique identifier for the script */\n id?: string;\n /** Called when the script has loaded */\n onLoad?: (e: Event) => void;\n /** Called when the script is ready (after load, and on every re-render if already loaded) */\n onReady?: () => void;\n /** Called on script load error */\n onError?: (e: Event) => void;\n /** Inline script content */\n children?: React.ReactNode;\n /** Dangerous inner HTML */\n dangerouslySetInnerHTML?: { __html: string };\n /** Script type attribute */\n type?: string;\n /** Async attribute */\n async?: boolean;\n /** Defer attribute */\n defer?: boolean;\n /** Crossorigin attribute */\n crossOrigin?: string;\n /** Nonce for CSP */\n nonce?: string;\n /** Integrity hash */\n integrity?: string;\n /** Additional attributes */\n [key: string]: unknown;\n}\n\n// Track scripts that have already been loaded to avoid duplicates\nconst loadedScripts = new Set<string>();\n\n/**\n * Load a script imperatively (outside of React).\n */\nexport function handleClientScriptLoad(props: ScriptProps): void {\n const { src, id, onLoad, onError, strategy: _strategy, onReady: _onReady, children, ...rest } = props;\n if (typeof window === \"undefined\") return;\n\n const key = id ?? src ?? \"\";\n if (key && loadedScripts.has(key)) return;\n\n const el = document.createElement(\"script\");\n if (src) el.src = src;\n if (id) el.id = id;\n\n for (const [attr, value] of Object.entries(rest)) {\n if (attr === \"dangerouslySetInnerHTML\" || attr === \"className\") continue;\n if (typeof value === \"string\") {\n el.setAttribute(attr, value);\n } else if (typeof value === \"boolean\" && value) {\n el.setAttribute(attr, \"\");\n }\n }\n\n if (children && typeof children === \"string\") {\n el.textContent = children;\n }\n\n if (onLoad) el.addEventListener(\"load\", onLoad);\n if (onError) el.addEventListener(\"error\", onError);\n\n document.body.appendChild(el);\n if (key) loadedScripts.add(key);\n}\n\n/**\n * Initialize multiple scripts at once (called during app bootstrap).\n */\nexport function initScriptLoader(scripts: ScriptProps[]): void {\n for (const script of scripts) {\n handleClientScriptLoad(script);\n }\n}\n\nfunction Script(props: ScriptProps): React.ReactElement | null {\n const {\n src,\n id,\n strategy = \"afterInteractive\",\n onLoad,\n onReady,\n onError,\n children,\n dangerouslySetInnerHTML,\n ...rest\n } = props;\n\n const hasMounted = useRef(false);\n const key = id ?? src ?? \"\";\n\n // Client path: load scripts via useEffect based on strategy.\n // useEffect never runs during SSR, so it's safe to call unconditionally.\n useEffect(() => {\n if (hasMounted.current) return;\n hasMounted.current = true;\n\n // Already loaded — just fire onReady\n if (key && loadedScripts.has(key)) {\n onReady?.();\n return;\n }\n\n const load = () => {\n if (key && loadedScripts.has(key)) {\n onReady?.();\n return;\n }\n\n const el = document.createElement(\"script\");\n if (src) el.src = src;\n if (id) el.id = id;\n\n for (const [attr, value] of Object.entries(rest)) {\n if (attr === \"className\") {\n el.setAttribute(\"class\", String(value));\n } else if (typeof value === \"string\") {\n el.setAttribute(attr, value);\n } else if (typeof value === \"boolean\" && value) {\n el.setAttribute(attr, \"\");\n }\n }\n\n if (strategy === \"worker\") {\n el.setAttribute(\"type\", \"text/partytown\");\n }\n\n if (dangerouslySetInnerHTML?.__html) {\n el.innerHTML = dangerouslySetInnerHTML.__html as string;\n } else if (children && typeof children === \"string\") {\n el.textContent = children;\n }\n\n el.addEventListener(\"load\", (e) => {\n if (key) loadedScripts.add(key);\n onLoad?.(e);\n onReady?.();\n });\n\n if (onError) {\n el.addEventListener(\"error\", onError);\n }\n\n document.body.appendChild(el);\n };\n\n if (strategy === \"lazyOnload\") {\n // Wait for window load, then use idle callback\n if (document.readyState === \"complete\") {\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(load);\n } else {\n setTimeout(load, 1);\n }\n } else {\n window.addEventListener(\"load\", () => {\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(load);\n } else {\n setTimeout(load, 1);\n }\n });\n }\n } else {\n // \"afterInteractive\" (default), \"beforeInteractive\" (client re-mount), \"worker\"\n load();\n }\n }, [src, id, strategy, onLoad, onReady, onError, children, dangerouslySetInnerHTML, key, rest]);\n\n // SSR path: only \"beforeInteractive\" renders a <script> tag server-side\n if (typeof window === \"undefined\") {\n if (strategy === \"beforeInteractive\") {\n const scriptProps: Record<string, unknown> = { ...rest };\n if (src) scriptProps.src = src;\n if (id) scriptProps.id = id;\n if (dangerouslySetInnerHTML) {\n // Escape closing </script> sequences in inline content so the HTML\n // parser doesn't prematurely terminate the element during SSR.\n const raw = dangerouslySetInnerHTML.__html;\n scriptProps.dangerouslySetInnerHTML = {\n __html: escapeInlineContent(raw, \"script\"),\n };\n }\n return React.createElement(\"script\", scriptProps, children);\n }\n // Other strategies don't render during SSR\n return null;\n }\n\n // The component itself renders nothing — scripts are injected imperatively\n return null;\n}\n\nexport default Script;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"server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,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,MAAM,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,EAAE,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,GAAG,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAKxE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAIhD;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,OAAO,UAAU,CAAC,UAOvC,CAAC"}
@@ -370,7 +370,8 @@ export function after(task) {
370
370
  * and sets Cache-Control: no-store on the response.
371
371
  */
372
372
  export async function connection() {
373
- const { markDynamicUsage } = await import("./headers.js");
373
+ const { markDynamicUsage, throwIfInsideCacheScope } = await import("./headers.js");
374
+ throwIfInsideCacheScope("connection()");
374
375
  markDynamicUsage();
375
376
  }
376
377
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/shims/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E,MAAM,OAAO,WAAY,SAAQ,OAAO;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AC,MAAM,UAAU,GACrB,UAAU,CAAC,UAAU;IACrB,CAAC,GAAG,EAAE;QACJ,MAAM,IAAI,KAAK,CACb,+CAA+C;YAC7C,mEAAmE,CACtE,CAAC;IACJ,CAAC,CAAC,CAAC","sourcesContent":["/**\n * next/server shim\n *\n * Provides NextRequest, NextResponse, and related types that work with\n * standard Web APIs (Request/Response). This means they work on Node,\n * Cloudflare Workers, Deno, and any WinterCG-compatible runtime.\n *\n * This is a pragmatic subset — we implement the most commonly used APIs\n * rather than bug-for-bug parity with Next.js internals.\n */\n\n// ---------------------------------------------------------------------------\n// NextRequest\n// ---------------------------------------------------------------------------\n\nexport class NextRequest extends Request {\n private _nextUrl: NextURL;\n private _cookies: RequestCookies;\n\n constructor(input: URL | RequestInfo, init?: RequestInit) {\n // Handle the case where input is a Request object - we need to extract URL and init\n // to avoid Node.js undici issues with passing Request objects directly to super()\n if (input instanceof Request) {\n const req = input;\n super(req.url, {\n method: req.method,\n headers: req.headers,\n body: req.body,\n // @ts-expect-error - duplex is not in RequestInit type but needed for streams\n duplex: req.body ? \"half\" : undefined,\n ...init,\n });\n } else {\n super(input, init);\n }\n const url = typeof input === \"string\"\n ? new URL(input, \"http://localhost\")\n : input instanceof URL\n ? input\n : new URL(input.url, \"http://localhost\");\n this._nextUrl = new NextURL(url);\n this._cookies = new RequestCookies(this.headers);\n }\n\n get nextUrl(): NextURL {\n return this._nextUrl;\n }\n\n get cookies(): RequestCookies {\n return this._cookies;\n }\n\n /**\n * Client IP address. Prefers Cloudflare's trusted CF-Connecting-IP header\n * over the spoofable X-Forwarded-For. Returns undefined if unavailable.\n */\n get ip(): string | undefined {\n return this.headers.get(\"cf-connecting-ip\")\n ?? this.headers.get(\"x-real-ip\")\n ?? this.headers.get(\"x-forwarded-for\")?.split(\",\")[0]?.trim()\n ?? undefined;\n }\n\n /**\n * Geolocation data. Platform-dependent (e.g., Cloudflare, Vercel).\n * Returns undefined if not available.\n */\n get geo(): { city?: string; country?: string; region?: string; latitude?: string; longitude?: string } | undefined {\n // Check Cloudflare-style headers, Vercel-style headers\n const country = this.headers.get(\"cf-ipcountry\") ?? this.headers.get(\"x-vercel-ip-country\") ?? undefined;\n if (!country) return undefined;\n return {\n country,\n city: this.headers.get(\"cf-ipcity\") ?? this.headers.get(\"x-vercel-ip-city\") ?? undefined,\n region: this.headers.get(\"cf-region\") ?? this.headers.get(\"x-vercel-ip-country-region\") ?? undefined,\n latitude: this.headers.get(\"cf-iplatitude\") ?? this.headers.get(\"x-vercel-ip-latitude\") ?? undefined,\n longitude: this.headers.get(\"cf-iplongitude\") ?? this.headers.get(\"x-vercel-ip-longitude\") ?? undefined,\n };\n }\n}\n\n// ---------------------------------------------------------------------------\n// NextResponse\n// ---------------------------------------------------------------------------\n\nexport class NextResponse<_Body = unknown> extends Response {\n private _cookies: ResponseCookies;\n\n constructor(body?: BodyInit | null, init?: ResponseInit) {\n super(body, init);\n this._cookies = new ResponseCookies(this.headers);\n }\n\n get cookies(): ResponseCookies {\n return this._cookies;\n }\n\n /**\n * Create a JSON response.\n */\n static json<JsonBody>(body: JsonBody, init?: ResponseInit): NextResponse<JsonBody> {\n const headers = new Headers(init?.headers);\n if (!headers.has(\"content-type\")) {\n headers.set(\"content-type\", \"application/json\");\n }\n return new NextResponse(JSON.stringify(body), {\n ...init,\n headers,\n }) as NextResponse<JsonBody>;\n }\n\n /**\n * Create a redirect response.\n */\n static redirect(url: string | URL, init?: number | ResponseInit): NextResponse {\n const status = typeof init === \"number\" ? init : init?.status ?? 307;\n const destination = typeof url === \"string\" ? url : url.toString();\n const headers = new Headers(typeof init === \"object\" ? init?.headers : undefined);\n headers.set(\"Location\", destination);\n return new NextResponse(null, { status, headers });\n }\n\n /**\n * Create a rewrite response (middleware pattern).\n * Sets the x-middleware-rewrite header.\n */\n static rewrite(destination: string | URL, init?: MiddlewareResponseInit): NextResponse {\n const url = typeof destination === \"string\" ? destination : destination.toString();\n const headers = new Headers(init?.headers);\n headers.set(\"x-middleware-rewrite\", url);\n return new NextResponse(null, { ...init, headers });\n }\n\n /**\n * Continue to the next handler (middleware pattern).\n * Sets the x-middleware-next header.\n */\n static next(init?: MiddlewareResponseInit): NextResponse {\n const headers = new Headers(init?.headers);\n headers.set(\"x-middleware-next\", \"1\");\n // Forward request headers if provided\n if (init?.request?.headers) {\n for (const [key, value] of init.request.headers.entries()) {\n headers.set(`x-middleware-request-${key}`, value);\n }\n }\n return new NextResponse(null, { ...init, headers });\n }\n}\n\n\n\n// ---------------------------------------------------------------------------\n// NextURL — lightweight URL wrapper with pathname helpers\n// ---------------------------------------------------------------------------\n\nexport class NextURL {\n private _url: URL;\n\n constructor(input: string | URL, base?: string | URL) {\n this._url = new URL(input.toString(), base);\n }\n\n get href(): string { return this._url.href; }\n set href(value: string) { this._url.href = value; }\n\n get origin(): string { return this._url.origin; }\n\n get protocol(): string { return this._url.protocol; }\n set protocol(value: string) { this._url.protocol = value; }\n\n get username(): string { return this._url.username; }\n set username(value: string) { this._url.username = value; }\n\n get password(): string { return this._url.password; }\n set password(value: string) { this._url.password = value; }\n\n get host(): string { return this._url.host; }\n set host(value: string) { this._url.host = value; }\n\n get hostname(): string { return this._url.hostname; }\n set hostname(value: string) { this._url.hostname = value; }\n\n get port(): string { return this._url.port; }\n set port(value: string) { this._url.port = value; }\n\n get pathname(): string { return this._url.pathname; }\n set pathname(value: string) { this._url.pathname = value; }\n\n get search(): string { return this._url.search; }\n set search(value: string) { this._url.search = value; }\n\n get searchParams(): URLSearchParams { return this._url.searchParams; }\n\n get hash(): string { return this._url.hash; }\n set hash(value: string) { this._url.hash = value; }\n\n clone(): NextURL {\n return new NextURL(this._url.href);\n }\n\n toString(): string {\n return this._url.toString();\n }\n}\n\n// ---------------------------------------------------------------------------\n// Cookie helpers (minimal implementations)\n// ---------------------------------------------------------------------------\n\ninterface CookieEntry {\n name: string;\n value: string;\n}\n\nexport class RequestCookies {\n private _headers: Headers;\n\n constructor(headers: Headers) {\n this._headers = headers;\n }\n\n private _parse(): Map<string, string> {\n const map = new Map<string, string>();\n const cookie = this._headers.get(\"cookie\") ?? \"\";\n for (const part of cookie.split(\";\")) {\n const eq = part.indexOf(\"=\");\n if (eq === -1) continue;\n const name = part.slice(0, eq).trim();\n const value = part.slice(eq + 1).trim();\n map.set(name, value);\n }\n return map;\n }\n\n get(name: string): CookieEntry | undefined {\n const value = this._parse().get(name);\n return value !== undefined ? { name, value } : undefined;\n }\n\n getAll(): CookieEntry[] {\n return [...this._parse().entries()].map(([name, value]) => ({ name, value }));\n }\n\n has(name: string): boolean {\n return this._parse().has(name);\n }\n\n [Symbol.iterator](): IterableIterator<[string, CookieEntry]> {\n const entries = this.getAll().map((c) => [c.name, c] as [string, CookieEntry]);\n return entries[Symbol.iterator]();\n }\n}\n\n/**\n * RFC 6265 §4.1.1: cookie-name is a token (RFC 2616 §2.2).\n * Allowed: any visible ASCII (0x21-0x7E) except separators: ()<>@,;:\\\"/[]?={}\n */\nconst VALID_COOKIE_NAME_RE = /^[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2E\\x30-\\x39\\x41-\\x5A\\x5E-\\x7A\\x7C\\x7E]+$/;\n\nfunction validateCookieName(name: string): void {\n if (!name || !VALID_COOKIE_NAME_RE.test(name)) {\n throw new Error(`Invalid cookie name: ${JSON.stringify(name)}`);\n }\n}\n\nfunction validateCookieAttributeValue(value: string, attributeName: string): void {\n for (let i = 0; i < value.length; i++) {\n const code = value.charCodeAt(i);\n if (code <= 0x1F || code === 0x7F || value[i] === \";\") {\n throw new Error(`Invalid cookie ${attributeName} value: ${JSON.stringify(value)}`);\n }\n }\n}\n\nexport class ResponseCookies {\n private _headers: Headers;\n\n constructor(headers: Headers) {\n this._headers = headers;\n }\n\n set(name: string, value: string, options?: CookieOptions): this {\n validateCookieName(name);\n const parts = [`${name}=${encodeURIComponent(value)}`];\n if (options?.path) {\n validateCookieAttributeValue(options.path, \"Path\");\n parts.push(`Path=${options.path}`);\n }\n if (options?.domain) {\n validateCookieAttributeValue(options.domain, \"Domain\");\n parts.push(`Domain=${options.domain}`);\n }\n if (options?.maxAge !== undefined) parts.push(`Max-Age=${options.maxAge}`);\n if (options?.expires) parts.push(`Expires=${options.expires.toUTCString()}`);\n if (options?.httpOnly) parts.push(\"HttpOnly\");\n if (options?.secure) parts.push(\"Secure\");\n if (options?.sameSite) parts.push(`SameSite=${options.sameSite}`);\n this._headers.append(\"Set-Cookie\", parts.join(\"; \"));\n return this;\n }\n\n get(name: string): CookieEntry | undefined {\n for (const header of this._headers.getSetCookie()) {\n const eq = header.indexOf(\"=\");\n if (eq === -1) continue;\n const cookieName = header.slice(0, eq);\n if (cookieName === name) {\n const semi = header.indexOf(\";\", eq);\n const raw = header.slice(eq + 1, semi === -1 ? undefined : semi);\n let value: string;\n try { value = decodeURIComponent(raw); } catch { value = raw; }\n return { name, value };\n }\n }\n return undefined;\n }\n\n getAll(): CookieEntry[] {\n const entries: CookieEntry[] = [];\n for (const header of this._headers.getSetCookie()) {\n const eq = header.indexOf(\"=\");\n if (eq === -1) continue;\n const cookieName = header.slice(0, eq);\n const semi = header.indexOf(\";\", eq);\n const raw = header.slice(eq + 1, semi === -1 ? undefined : semi);\n let value: string;\n try { value = decodeURIComponent(raw); } catch { value = raw; }\n entries.push({ name: cookieName, value });\n }\n return entries;\n }\n\n delete(name: string): this {\n this.set(name, \"\", { maxAge: 0, path: \"/\" });\n return this;\n }\n\n [Symbol.iterator](): IterableIterator<[string, CookieEntry]> {\n const entries: [string, CookieEntry][] = [];\n for (const header of this._headers.getSetCookie()) {\n const eq = header.indexOf(\"=\");\n if (eq === -1) continue;\n const cookieName = header.slice(0, eq);\n const semi = header.indexOf(\";\", eq);\n const raw = header.slice(eq + 1, semi === -1 ? undefined : semi);\n let value: string;\n try { value = decodeURIComponent(raw); } catch { value = raw; }\n entries.push([cookieName, { name: cookieName, value }]);\n }\n return entries[Symbol.iterator]();\n }\n}\n\ninterface CookieOptions {\n path?: string;\n domain?: string;\n maxAge?: number;\n expires?: Date;\n httpOnly?: boolean;\n secure?: boolean;\n sameSite?: \"Strict\" | \"Lax\" | \"None\";\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface MiddlewareResponseInit extends ResponseInit {\n request?: {\n headers?: Headers;\n };\n}\n\nexport type NextMiddlewareResult = NextResponse | Response | null | undefined | void;\n\nexport type NextMiddleware = (\n request: NextRequest,\n event: NextFetchEvent,\n) => NextMiddlewareResult | Promise<NextMiddlewareResult>;\n\n/**\n * Minimal NextFetchEvent — extends FetchEvent where available,\n * otherwise provides the waitUntil pattern standalone.\n */\nexport class NextFetchEvent {\n sourcePage: string;\n private _waitUntilPromises: Promise<unknown>[] = [];\n\n constructor(params: { page: string }) {\n this.sourcePage = params.page;\n }\n\n waitUntil(promise: Promise<unknown>): void {\n this._waitUntilPromises.push(promise);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Utility exports\n// ---------------------------------------------------------------------------\n\n/**\n * Parse user agent string. Minimal implementation — for full UA parsing,\n * apps should use a dedicated library like `ua-parser-js`.\n */\nexport function userAgentFromString(ua: string | undefined): UserAgent {\n const input = ua ?? \"\";\n return {\n isBot: /bot|crawler|spider|crawling/i.test(input),\n ua: input,\n browser: {},\n device: {},\n engine: {},\n os: {},\n cpu: {},\n };\n}\n\nexport function userAgent({ headers }: { headers: Headers }): UserAgent {\n return userAgentFromString(headers.get(\"user-agent\") ?? undefined);\n}\n\nexport interface UserAgent {\n isBot: boolean;\n ua: string;\n browser: { name?: string; version?: string; major?: string };\n device: { model?: string; type?: string; vendor?: string };\n engine: { name?: string; version?: string };\n os: { name?: string; version?: string };\n cpu: { architecture?: string };\n}\n\n/**\n * after() — schedule work after the response is sent.\n * In a real server, this would use the platform's waitUntil.\n * Here we simply run it as a microtask (best-effort).\n */\nexport function after<T>(task: Promise<T> | (() => T | Promise<T>)): void {\n const promise = typeof task === \"function\" ? Promise.resolve().then(task) : task;\n promise.catch((err) => {\n console.error(\"[vinext] after() task failed:\", err);\n });\n}\n\n/**\n * connection() — signals that the response requires a live connection\n * (not a static/cached response). Opts the page out of ISR caching\n * and sets Cache-Control: no-store on the response.\n */\nexport async function connection(): Promise<void> {\n const { markDynamicUsage } = await import(\"./headers.js\");\n markDynamicUsage();\n}\n\n/**\n * URLPattern re-export — used in middleware for route matching.\n * Available natively in Node 20+, Cloudflare Workers, Deno.\n * Falls back to urlpattern-polyfill if the global is not available.\n */\nexport const URLPattern: typeof globalThis.URLPattern =\n globalThis.URLPattern ??\n (() => {\n throw new Error(\n \"URLPattern is not available in this runtime. \" +\n \"Install the `urlpattern-polyfill` package or upgrade to Node 20+.\",\n );\n });\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/shims/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E,MAAM,OAAO,WAAY,SAAQ,OAAO;IAC9B,QAAQ,CAAU;IAClB,QAAQ,CAAiB;IAEjC,YAAY,KAAwB,EAAE,IAAkB;QACtD,oFAAoF;QACpF,kFAAkF;QAClF,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,KAAK,CAAC;YAClB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;gBACb,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,8EAA8E;gBAC9E,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;gBACrC,GAAG,IAAI;aACR,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACrB,CAAC;QACD,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ;YACnC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,kBAAkB,CA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CAAC,CAAC;AACrE,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAI,IAAyC;IAChE,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjF,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACpB,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;IACnF,uBAAuB,CAAC,cAAc,CAAC,CAAC;IACxC,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,UAAU,CAAC,UAAU;IACrB,CAAC,GAAG,EAAE;QACJ,MAAM,IAAI,KAAK,CACb,+CAA+C;YAC7C,mEAAmE,CACtE,CAAC;IACJ,CAAC,CAAC,CAAC","sourcesContent":["/**\n * next/server shim\n *\n * Provides NextRequest, NextResponse, and related types that work with\n * standard Web APIs (Request/Response). This means they work on Node,\n * Cloudflare Workers, Deno, and any WinterCG-compatible runtime.\n *\n * This is a pragmatic subset — we implement the most commonly used APIs\n * rather than bug-for-bug parity with Next.js internals.\n */\n\n// ---------------------------------------------------------------------------\n// NextRequest\n// ---------------------------------------------------------------------------\n\nexport class NextRequest extends Request {\n private _nextUrl: NextURL;\n private _cookies: RequestCookies;\n\n constructor(input: URL | RequestInfo, init?: RequestInit) {\n // Handle the case where input is a Request object - we need to extract URL and init\n // to avoid Node.js undici issues with passing Request objects directly to super()\n if (input instanceof Request) {\n const req = input;\n super(req.url, {\n method: req.method,\n headers: req.headers,\n body: req.body,\n // @ts-expect-error - duplex is not in RequestInit type but needed for streams\n duplex: req.body ? \"half\" : undefined,\n ...init,\n });\n } else {\n super(input, init);\n }\n const url = typeof input === \"string\"\n ? new URL(input, \"http://localhost\")\n : input instanceof URL\n ? input\n : new URL(input.url, \"http://localhost\");\n this._nextUrl = new NextURL(url);\n this._cookies = new RequestCookies(this.headers);\n }\n\n get nextUrl(): NextURL {\n return this._nextUrl;\n }\n\n get cookies(): RequestCookies {\n return this._cookies;\n }\n\n /**\n * Client IP address. Prefers Cloudflare's trusted CF-Connecting-IP header\n * over the spoofable X-Forwarded-For. Returns undefined if unavailable.\n */\n get ip(): string | undefined {\n return this.headers.get(\"cf-connecting-ip\")\n ?? this.headers.get(\"x-real-ip\")\n ?? this.headers.get(\"x-forwarded-for\")?.split(\",\")[0]?.trim()\n ?? undefined;\n }\n\n /**\n * Geolocation data. Platform-dependent (e.g., Cloudflare, Vercel).\n * Returns undefined if not available.\n */\n get geo(): { city?: string; country?: string; region?: string; latitude?: string; longitude?: string } | undefined {\n // Check Cloudflare-style headers, Vercel-style headers\n const country = this.headers.get(\"cf-ipcountry\") ?? this.headers.get(\"x-vercel-ip-country\") ?? undefined;\n if (!country) return undefined;\n return {\n country,\n city: this.headers.get(\"cf-ipcity\") ?? this.headers.get(\"x-vercel-ip-city\") ?? undefined,\n region: this.headers.get(\"cf-region\") ?? this.headers.get(\"x-vercel-ip-country-region\") ?? undefined,\n latitude: this.headers.get(\"cf-iplatitude\") ?? this.headers.get(\"x-vercel-ip-latitude\") ?? undefined,\n longitude: this.headers.get(\"cf-iplongitude\") ?? this.headers.get(\"x-vercel-ip-longitude\") ?? undefined,\n };\n }\n}\n\n// ---------------------------------------------------------------------------\n// NextResponse\n// ---------------------------------------------------------------------------\n\nexport class NextResponse<_Body = unknown> extends Response {\n private _cookies: ResponseCookies;\n\n constructor(body?: BodyInit | null, init?: ResponseInit) {\n super(body, init);\n this._cookies = new ResponseCookies(this.headers);\n }\n\n get cookies(): ResponseCookies {\n return this._cookies;\n }\n\n /**\n * Create a JSON response.\n */\n static json<JsonBody>(body: JsonBody, init?: ResponseInit): NextResponse<JsonBody> {\n const headers = new Headers(init?.headers);\n if (!headers.has(\"content-type\")) {\n headers.set(\"content-type\", \"application/json\");\n }\n return new NextResponse(JSON.stringify(body), {\n ...init,\n headers,\n }) as NextResponse<JsonBody>;\n }\n\n /**\n * Create a redirect response.\n */\n static redirect(url: string | URL, init?: number | ResponseInit): NextResponse {\n const status = typeof init === \"number\" ? init : init?.status ?? 307;\n const destination = typeof url === \"string\" ? url : url.toString();\n const headers = new Headers(typeof init === \"object\" ? init?.headers : undefined);\n headers.set(\"Location\", destination);\n return new NextResponse(null, { status, headers });\n }\n\n /**\n * Create a rewrite response (middleware pattern).\n * Sets the x-middleware-rewrite header.\n */\n static rewrite(destination: string | URL, init?: MiddlewareResponseInit): NextResponse {\n const url = typeof destination === \"string\" ? destination : destination.toString();\n const headers = new Headers(init?.headers);\n headers.set(\"x-middleware-rewrite\", url);\n return new NextResponse(null, { ...init, headers });\n }\n\n /**\n * Continue to the next handler (middleware pattern).\n * Sets the x-middleware-next header.\n */\n static next(init?: MiddlewareResponseInit): NextResponse {\n const headers = new Headers(init?.headers);\n headers.set(\"x-middleware-next\", \"1\");\n // Forward request headers if provided\n if (init?.request?.headers) {\n for (const [key, value] of init.request.headers.entries()) {\n headers.set(`x-middleware-request-${key}`, value);\n }\n }\n return new NextResponse(null, { ...init, headers });\n }\n}\n\n\n\n// ---------------------------------------------------------------------------\n// NextURL — lightweight URL wrapper with pathname helpers\n// ---------------------------------------------------------------------------\n\nexport class NextURL {\n private _url: URL;\n\n constructor(input: string | URL, base?: string | URL) {\n this._url = new URL(input.toString(), base);\n }\n\n get href(): string { return this._url.href; }\n set href(value: string) { this._url.href = value; }\n\n get origin(): string { return this._url.origin; }\n\n get protocol(): string { return this._url.protocol; }\n set protocol(value: string) { this._url.protocol = value; }\n\n get username(): string { return this._url.username; }\n set username(value: string) { this._url.username = value; }\n\n get password(): string { return this._url.password; }\n set password(value: string) { this._url.password = value; }\n\n get host(): string { return this._url.host; }\n set host(value: string) { this._url.host = value; }\n\n get hostname(): string { return this._url.hostname; }\n set hostname(value: string) { this._url.hostname = value; }\n\n get port(): string { return this._url.port; }\n set port(value: string) { this._url.port = value; }\n\n get pathname(): string { return this._url.pathname; }\n set pathname(value: string) { this._url.pathname = value; }\n\n get search(): string { return this._url.search; }\n set search(value: string) { this._url.search = value; }\n\n get searchParams(): URLSearchParams { return this._url.searchParams; }\n\n get hash(): string { return this._url.hash; }\n set hash(value: string) { this._url.hash = value; }\n\n clone(): NextURL {\n return new NextURL(this._url.href);\n }\n\n toString(): string {\n return this._url.toString();\n }\n}\n\n// ---------------------------------------------------------------------------\n// Cookie helpers (minimal implementations)\n// ---------------------------------------------------------------------------\n\ninterface CookieEntry {\n name: string;\n value: string;\n}\n\nexport class RequestCookies {\n private _headers: Headers;\n\n constructor(headers: Headers) {\n this._headers = headers;\n }\n\n private _parse(): Map<string, string> {\n const map = new Map<string, string>();\n const cookie = this._headers.get(\"cookie\") ?? \"\";\n for (const part of cookie.split(\";\")) {\n const eq = part.indexOf(\"=\");\n if (eq === -1) continue;\n const name = part.slice(0, eq).trim();\n const value = part.slice(eq + 1).trim();\n map.set(name, value);\n }\n return map;\n }\n\n get(name: string): CookieEntry | undefined {\n const value = this._parse().get(name);\n return value !== undefined ? { name, value } : undefined;\n }\n\n getAll(): CookieEntry[] {\n return [...this._parse().entries()].map(([name, value]) => ({ name, value }));\n }\n\n has(name: string): boolean {\n return this._parse().has(name);\n }\n\n [Symbol.iterator](): IterableIterator<[string, CookieEntry]> {\n const entries = this.getAll().map((c) => [c.name, c] as [string, CookieEntry]);\n return entries[Symbol.iterator]();\n }\n}\n\n/**\n * RFC 6265 §4.1.1: cookie-name is a token (RFC 2616 §2.2).\n * Allowed: any visible ASCII (0x21-0x7E) except separators: ()<>@,;:\\\"/[]?={}\n */\nconst VALID_COOKIE_NAME_RE = /^[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2E\\x30-\\x39\\x41-\\x5A\\x5E-\\x7A\\x7C\\x7E]+$/;\n\nfunction validateCookieName(name: string): void {\n if (!name || !VALID_COOKIE_NAME_RE.test(name)) {\n throw new Error(`Invalid cookie name: ${JSON.stringify(name)}`);\n }\n}\n\nfunction validateCookieAttributeValue(value: string, attributeName: string): void {\n for (let i = 0; i < value.length; i++) {\n const code = value.charCodeAt(i);\n if (code <= 0x1F || code === 0x7F || value[i] === \";\") {\n throw new Error(`Invalid cookie ${attributeName} value: ${JSON.stringify(value)}`);\n }\n }\n}\n\nexport class ResponseCookies {\n private _headers: Headers;\n\n constructor(headers: Headers) {\n this._headers = headers;\n }\n\n set(name: string, value: string, options?: CookieOptions): this {\n validateCookieName(name);\n const parts = [`${name}=${encodeURIComponent(value)}`];\n if (options?.path) {\n validateCookieAttributeValue(options.path, \"Path\");\n parts.push(`Path=${options.path}`);\n }\n if (options?.domain) {\n validateCookieAttributeValue(options.domain, \"Domain\");\n parts.push(`Domain=${options.domain}`);\n }\n if (options?.maxAge !== undefined) parts.push(`Max-Age=${options.maxAge}`);\n if (options?.expires) parts.push(`Expires=${options.expires.toUTCString()}`);\n if (options?.httpOnly) parts.push(\"HttpOnly\");\n if (options?.secure) parts.push(\"Secure\");\n if (options?.sameSite) parts.push(`SameSite=${options.sameSite}`);\n this._headers.append(\"Set-Cookie\", parts.join(\"; \"));\n return this;\n }\n\n get(name: string): CookieEntry | undefined {\n for (const header of this._headers.getSetCookie()) {\n const eq = header.indexOf(\"=\");\n if (eq === -1) continue;\n const cookieName = header.slice(0, eq);\n if (cookieName === name) {\n const semi = header.indexOf(\";\", eq);\n const raw = header.slice(eq + 1, semi === -1 ? undefined : semi);\n let value: string;\n try { value = decodeURIComponent(raw); } catch { value = raw; }\n return { name, value };\n }\n }\n return undefined;\n }\n\n getAll(): CookieEntry[] {\n const entries: CookieEntry[] = [];\n for (const header of this._headers.getSetCookie()) {\n const eq = header.indexOf(\"=\");\n if (eq === -1) continue;\n const cookieName = header.slice(0, eq);\n const semi = header.indexOf(\";\", eq);\n const raw = header.slice(eq + 1, semi === -1 ? undefined : semi);\n let value: string;\n try { value = decodeURIComponent(raw); } catch { value = raw; }\n entries.push({ name: cookieName, value });\n }\n return entries;\n }\n\n delete(name: string): this {\n this.set(name, \"\", { maxAge: 0, path: \"/\" });\n return this;\n }\n\n [Symbol.iterator](): IterableIterator<[string, CookieEntry]> {\n const entries: [string, CookieEntry][] = [];\n for (const header of this._headers.getSetCookie()) {\n const eq = header.indexOf(\"=\");\n if (eq === -1) continue;\n const cookieName = header.slice(0, eq);\n const semi = header.indexOf(\";\", eq);\n const raw = header.slice(eq + 1, semi === -1 ? undefined : semi);\n let value: string;\n try { value = decodeURIComponent(raw); } catch { value = raw; }\n entries.push([cookieName, { name: cookieName, value }]);\n }\n return entries[Symbol.iterator]();\n }\n}\n\ninterface CookieOptions {\n path?: string;\n domain?: string;\n maxAge?: number;\n expires?: Date;\n httpOnly?: boolean;\n secure?: boolean;\n sameSite?: \"Strict\" | \"Lax\" | \"None\";\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface MiddlewareResponseInit extends ResponseInit {\n request?: {\n headers?: Headers;\n };\n}\n\nexport type NextMiddlewareResult = NextResponse | Response | null | undefined | void;\n\nexport type NextMiddleware = (\n request: NextRequest,\n event: NextFetchEvent,\n) => NextMiddlewareResult | Promise<NextMiddlewareResult>;\n\n/**\n * Minimal NextFetchEvent — extends FetchEvent where available,\n * otherwise provides the waitUntil pattern standalone.\n */\nexport class NextFetchEvent {\n sourcePage: string;\n private _waitUntilPromises: Promise<unknown>[] = [];\n\n constructor(params: { page: string }) {\n this.sourcePage = params.page;\n }\n\n waitUntil(promise: Promise<unknown>): void {\n this._waitUntilPromises.push(promise);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Utility exports\n// ---------------------------------------------------------------------------\n\n/**\n * Parse user agent string. Minimal implementation — for full UA parsing,\n * apps should use a dedicated library like `ua-parser-js`.\n */\nexport function userAgentFromString(ua: string | undefined): UserAgent {\n const input = ua ?? \"\";\n return {\n isBot: /bot|crawler|spider|crawling/i.test(input),\n ua: input,\n browser: {},\n device: {},\n engine: {},\n os: {},\n cpu: {},\n };\n}\n\nexport function userAgent({ headers }: { headers: Headers }): UserAgent {\n return userAgentFromString(headers.get(\"user-agent\") ?? undefined);\n}\n\nexport interface UserAgent {\n isBot: boolean;\n ua: string;\n browser: { name?: string; version?: string; major?: string };\n device: { model?: string; type?: string; vendor?: string };\n engine: { name?: string; version?: string };\n os: { name?: string; version?: string };\n cpu: { architecture?: string };\n}\n\n/**\n * after() — schedule work after the response is sent.\n * In a real server, this would use the platform's waitUntil.\n * Here we simply run it as a microtask (best-effort).\n */\nexport function after<T>(task: Promise<T> | (() => T | Promise<T>)): void {\n const promise = typeof task === \"function\" ? Promise.resolve().then(task) : task;\n promise.catch((err) => {\n console.error(\"[vinext] after() task failed:\", err);\n });\n}\n\n/**\n * connection() — signals that the response requires a live connection\n * (not a static/cached response). Opts the page out of ISR caching\n * and sets Cache-Control: no-store on the response.\n */\nexport async function connection(): Promise<void> {\n const { markDynamicUsage, throwIfInsideCacheScope } = await import(\"./headers.js\");\n throwIfInsideCacheScope(\"connection()\");\n markDynamicUsage();\n}\n\n/**\n * URLPattern re-export — used in middleware for route matching.\n * Available natively in Node 20+, Cloudflare Workers, Deno.\n * Falls back to urlpattern-polyfill if the global is not available.\n */\nexport const URLPattern: typeof globalThis.URLPattern =\n globalThis.URLPattern ??\n (() => {\n throw new Error(\n \"URLPattern is not available in this runtime. \" +\n \"Install the `urlpattern-polyfill` package or upgrade to Node 20+.\",\n );\n });\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vinext",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Run Next.js apps on Vite. Drop-in replacement for the next CLI.",
5
5
  "license": "MIT",
6
6
  "repository": {