@rsc-kit/core 0.30.49 → 0.30.50

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.
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,6DAA6D;AAC7D,EAAE;AACF,iDAAiD;AACjD,mGAAmG;AACnG,mCAAmC;AACnC,MAAM;AACN,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,8EAA8E;AAC9E,iBAAiB;AACjB,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,qDAAqD;AACrD,EAAE;AACF,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;AAC/E,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,gDAAgD;AAChD,EAAE;AACF,yEAAyE;AACzE,0CAA0C;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAwF/C,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,OAAO;IACP,iEAAiE;IACjE,MAAM;IACN,OAAO;IACP,aAAa;IACb,YAAY;IACZ,iBAAiB;IACjB,YAAY;IACZ,QAAQ;IACR,MAAM;IACN,SAAS;IACT,SAAS;IACT,YAAY;IACZ,cAAc;IACd,SAAS;IACT,KAAK;IACL,aAAa;IACb,mBAAmB;IACnB,WAAW;IACX,KAAK;IACL,KAAK;IACL,KAAK;CACN,CAAC,CAAC;AAEH,mGAAmG;AACnG,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,SAAS;IACT,SAAS;IACT,YAAY;IACZ,cAAc;IACd,SAAS;IACT,KAA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AC,GAAG,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAEnE,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,eAAe,KAAK,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,6EAA6E;IAC7E,iDAAiD;IACjD,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC;IAErB,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC/D,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,GAAG,EAAE,CAAC;IAEzB,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,eAAe,EAAE,CAAC;AACnE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAA8B;IAC1D,MAAM,KAAK,GAAG,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC;IAElC,IAAI,KAAK;QAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;AACrC,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB;IAC9B,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,SAAS,IAAI,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["// Reading the request from inside a render.\n//\n// import { headers, cookies } from '@rsc-kit/core/request'\n//\n// export default async function middleware() {\n// const locale = cookies().get('locale')?.value ?? negotiate(headers().get('accept-language'))\n// if (!locale) redirect('/en')\n// }\n//\n// Server components have no arguments beyond their props, and middleware has\n// none at all, so without this an app on a JavaScript host cannot see a header\n// — no locale negotiation, no subdomain, no cookie. The Laravel host escaped\n// that through rpc(), because PHP has the request; this is the same thing for\n// everyone else.\n//\n// Read-only on purpose. Setting a cookie means writing a response header, and\n// by the time a component renders the shell may already have been flushed — an\n// API that appears to set one and silently does not is worse than not having\n// it. Set them in the host, which owns the response.\n//\n// Asynchronous on purpose too, and not for ergonomics. A build has no request,\n// so a read there suspends and never settles — which is the same thing the\n// prerender probe does to a host call. Anything still waiting when the probe's\n// budget expires becomes a fallback in the frozen shell, so a read inside a\n// Suspense boundary leaves the shell frozen and makes only that boundary\n// dynamic. Reading synchronously could only mark the whole route dynamic,\n// because there would be nothing to suspend on.\n//\n// Scoped to the request, on the same store cache() uses. Two requests in\n// flight cannot see each other's headers.\n\nimport { isCrawler } from \"./crawler.js\";\nimport { resolveScope } from \"./revalidate.js\";\n\nexport type { ServedRequest } from \"./served.js\";\n\n/** What a host can supply: a real Request, or the parts of one. */\nexport type RequestLike =\n Request | { url: string; headers: Record<string, string> } | null;\n\ninterface Slot {\n /** False during a build: there is nothing to answer with. */\n request: boolean;\n url: string | null;\n /**\n * Held as Headers rather than as a Request.\n *\n * `new Request(url, { headers })` drops Cookie: a spec-compliant Headers\n * built with the \"request\" guard refuses the forbidden header names, and\n * Cookie is one of them. `new Headers()` has no guard and keeps it. Bun\n * happens to allow both, which is why rebuilding a Request looked fine until\n * it ran anywhere stricter — and what it loses is every cookie, silently.\n */\n headers: Headers;\n original: Request | null;\n /**\n * Whether anything asked. Only for the build's report — the classification\n * comes from the suspension, not from this.\n */\n read: boolean;\n /**\n * What read it, in the order they did.\n *\n * Only the name of the accessor — `cookies()`, `headers()` — which is enough\n * for the build to say why a page could not be frozen. Without it the answer\n * is \"something in this page reached for the request\", and finding which is\n * the part that takes an afternoon.\n */\n readBy: string[];\n /**\n * The same reads with the component that made each one - `cookies() in\n * RootLayout` - taken from the stack at the moment of the read, which is\n * still the component's own call: an accessor runs synchronously up to\n * the point it suspends. Only the build reads this. \"Reads the request\" is\n * a category; this is the line to open.\n */\n readWhere: string[];\n /**\n * Reads the server could not answer and React caught at a boundary - the\n * fallback is what got stored - with the component that made each:\n * `useSearchParams() in Query`. Noted by the SSR entry, read by the build,\n * which attaches them to the route so a page stored as its own loading\n * screen says why.\n */\n fallbacks: string[];\n /**\n * For a read made inside a cache()-wrapped helper: the components that\n * awaited that helper, first caller included. The helper runs once, so\n * the stack at the read names only whoever got there first; every later\n * awaiter is a cache hit that never reaches the accessor. The one above\n * every boundary is usually one of the later ones.\n */\n awaiters: Map<unknown, string[]>;\n /** The cache()-wrapped helper whose body is running, while it runs. */\n inHelper: unknown;\n /** readWhere entry -> the helper it was read inside. */\n readVia: Map<string, unknown>;\n /** Work to run once the answer is on its way - see after(). */\n after: (() => unknown)[];\n /** The props the page was rendered with - its params and searchParams - for a region rendered inside it to read. */\n pageProps?: Record<string, unknown>;\n /**\n * A render that may be kept by a shared cache (`export const revalidate`):\n * backend calls carry no session, and what reads the visitor is written\n * down so the answer can be judged once it is whole. Optional: a store\n * written by an older bundle has none of these.\n */\n asNobody?: boolean;\n /** What read this visitor, with the component that did: `cookies() in Header`. */\n perVisitor?: string[];\n /** The tags of every cache() answer the render used, for the answer's Cache-Tag. */\n tags?: string[];\n /** The version each of those tags had when it was first read, for a kept page to be checked against. */\n tagVersions?: Record<string, number>;\n /** React reported a failure inside the payload: the answer is not a page to keep. */\n failed?: boolean;\n /** The render said notFound() inside its payload, where the browser's boundary shows not-found.tsx. */\n saidNotFound?: boolean;\n}\n\nconst SCOPE = Symbol.for(\"@rsc-kit/core.request-scope\");\n\n/**\n * The accessors themselves and the plumbing under them: frames to walk past\n * on the way to the component that called.\n */\nconst NOT_A_CALLER = new Set([\n \"never\",\n // A thenable's own method: the read is named by what it was for.\n \"then\",\n \"cache\",\n \"noteAwaiter\",\n \"withHelper\",\n \"noteRequestRead\",\n \"recordRead\",\n \"caller\",\n \"slot\",\n \"cookies\",\n \"headers\",\n \"connection\",\n \"searchParams\",\n \"request\",\n \"url\",\n \"parseParams\",\n \"parseSearchParams\",\n \"parseBody\",\n \"get\",\n \"set\",\n \"has\",\n]);\n\n/** The accessors a component calls by name. One calling another is plumbing, not a second read. */\nconst ACCESSORS = new Set([\n \"cookies\",\n \"headers\",\n \"connection\",\n \"searchParams\",\n \"request\",\n \"url\",\n]);\n\n/**\n * The nearest named function above the accessor on the stack, and whether\n * another accessor sits between: `cookies()` reads through `headers()`, and\n * that inner read is not a second thing the component did.\n *\n * Read from a thrown-away Error: the one thing a build cannot otherwise learn\n * is which component reached for the request, and the stack knows. Function\n * names survive a server bundle, which is not minified, so this is\n * `RootLayout` and not a line number in a chunk. Internal names are walked\n * past; an anonymous frame is skipped rather than reported as `<anonymous>`.\n */\nfunction caller(own: string): { name: string | null; nested: boolean } {\n const stack = new Error().stack ?? \"\";\n let accessors = 0;\n let helper: string | null = null;\n\n for (const line of stack.split(\"\\n\")) {\n const match = /^\\s*at (?:async )?([^\\s(]+)/.exec(line);\n\n if (!match) continue;\n\n const name = match[1]!.split(\".\").pop()!;\n\n // A frame with no function name prints its location instead - `js:6054:8`\n // - which is not a name to report.\n if (!/^[\\w$]+$/.test(name)) continue;\n\n if (ACCESSORS.has(name)) accessors++;\n if (\n NOT_A_CALLER.has(name) ||\n name === \"<anonymous>\" ||\n name === \"Object\" ||\n name === \"Promise\"\n )\n continue;\n\n const nested = accessors > (ACCESSORS.has(own) ? 1 : 0);\n\n // A function that is not a component - getCurrentUser, wrapped in\n // cache() - is the shared helper the read lives in. Named, because with\n // cache() the read runs once, on whichever component called first, and\n // every other caller of the helper is invisible to the stack. The helper\n // is what they have in common.\n if (/^[a-z_$]/.test(name) && !/^use[A-Z]/.test(name)) {\n helper ??= name;\n\n continue;\n }\n\n return {\n name: helper && helper !== name ? `${helper} (from ${name})` : name,\n nested,\n };\n }\n\n return { name: helper, nested: accessors > (ACCESSORS.has(own) ? 1 : 0) };\n}\n\nfunction recordRead(store: Slot, by: string): void {\n if (!store.readBy.includes(by)) store.readBy.push(by);\n\n // Older stores, written by a bundle built before this field existed.\n store.readWhere ??= [];\n\n const { name, nested } = caller(by.replace(/\\(.*$/, \"\"));\n\n if (nested) return;\n\n const entry = name ? `${by} in ${name}` : by;\n\n if (!store.readWhere.includes(entry)) store.readWhere.push(entry);\n if (store.inHelper) (store.readVia ??= new Map()).set(entry, store.inHelper);\n}\n\nconst globals = globalThis as Record<symbol | string, unknown>;\n\nlet ready: Promise<void> | null = null;\n\ninterface Scope {\n getStore(): Slot | undefined;\n run<T>(store: Slot, fn: () => T): T;\n}\n\nfunction scope(): Scope | null {\n return (globals[SCOPE] as Scope | undefined) ?? null;\n}\n\nfunction slot(): Slot {\n const store = scope()?.getStore();\n\n if (!store) {\n throw new Error(\n \"No request in scope. headers() and cookies() are for a render — middleware, a layout, \" +\n \"a page — and there is nothing to read outside one.\",\n );\n }\n\n store.read = true;\n\n return store;\n}\n\n/**\n * The request's headers.\n *\n * Empty during a build, where there is no request: the page is marked as\n * needing one instead, and rendered on demand rather than frozen.\n */\nexport async function headers(): Promise<Headers> {\n const store = slot();\n\n readVisitor(store, \"headers()\");\n\n return store.request ? store.headers : never(\"headers()\");\n}\n\n/** How a cookie should be written. The names browsers use. */\nexport interface 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 partitioned?: boolean;\n}\n\n/** One cookie as the request carried it: the shape Next's `cookies().get()` returns. */\nexport interface RequestCookie {\n name: string;\n value: string;\n}\n\n/**\n * The cookie jar, in the shape Next's `cookies()` has.\n *\n * `get()` returns `{ name, value }` rather than the string, because the guide\n * says \"the same names from `@rsc-kit/core/request`\" and a name that is the\n * same with a different return shape is the worst of both: ported code\n * reading `?.value` off a string got `undefined`, silently. `getAll()` is a\n * list for the same reason, and because a list composes where a record does\n * not.\n */\nexport interface Cookies {\n get(name: string): RequestCookie | undefined;\n has(name: string): boolean;\n getAll(): RequestCookie[];\n /**\n * Write one on the response.\n *\n * Only from a server action, which has a response of its own that has not\n * been sent. A render has already flushed its headers by the time a\n * component runs — that is what makes the first paint fast — so this throws\n * there rather than appearing to work.\n *\n * Either call shape Next takes: `set(name, value, options)` or\n * `set({ name, value, ...options })`.\n */\n set(name: string, value: string, options?: CookieOptions): void;\n set(cookie: RequestCookie & CookieOptions): void;\n /** Write one that expires immediately. Same rule about where. */\n delete(name: string, options?: CookieOptions): void;\n}\n\n/** Kept for the name it had when it could only read. */\nexport type ReadonlyCookies = Cookies;\n\n/**\n * The response being built, while it can still be changed.\n *\n * Open from the moment a request is picked up until the host constructs its\n * Response, and sealed the instant it does. Middleware runs inside that window\n * — before any rendering starts — so a header set there is on the answer. A\n * component runs after it, during streaming, where the status line and headers\n * are already on the wire; setting one there is refused rather than dropped.\n */\ninterface Draft {\n headers: Headers;\n sealed: boolean;\n /**\n * What this request wrote to the jar, over what it arrived with: a value,\n * or null for a deletion. Read back by `cookies()` for the rest of the\n * request, so a render that follows the write - the sections an action\n * revalidates travel back with its answer, rendered in the same request -\n * sees what the browser is about to hold. Next has the same rule, which\n * is why `set` then `revalidate` is what every port writes; without it\n * the sidebar re-rendered with the cookie the request arrived with, and\n * showed the old choice until a reload.\n */\n cookies: Map<string, string | null>;\n}\n\nconst DRAFT = Symbol.for(\"@rsc-kit/core.response-draft\");\n\nlet draftReady: Promise<void> | null = null;\n\ninterface DraftScope {\n getStore(): Draft | undefined;\n run<T>(store: Draft, fn: () => T): T;\n}\n\nfunction draft(): DraftScope | null {\n return (globals[DRAFT] as DraftScope | undefined) ?? null;\n}\n\n/** The open draft, or an explanation of why there is not one. */\nfunction writable(what: string): Draft {\n const open = draft()?.getStore();\n\n if (!open) {\n throw new Error(\n `${what} needs a response that has not been sent. Middleware and server actions have one; ` +\n \"a script outside a request does not.\",\n );\n }\n\n if (open.sealed) {\n throw new Error(\n `${what} was called after the response had been sent. Headers go out before the render ` +\n \"starts — that is what makes the first paint fast — so set them in middleware, which \" +\n \"runs before it.\",\n );\n }\n\n return open;\n}\n\n/**\n * Headers to put on the answer.\n *\n * Mutate it as you would any Headers. `append` is the one to reach for when a\n * header may legitimately appear twice; `set` replaces.\n */\n/**\n * The draft's headers, refusing writes once the response has gone.\n *\n * A proxy rather than the Headers itself: returning the live object means code\n * that captured it before the response was built can go on mutating a thing\n * nobody will read. Nothing in this package does that — the host copies the\n * headers onto the response the instant it seals — but \"safe because of the\n * order two other functions happen to run in\" is not a property, and an app\n * holding the object across an await would find writes silently doing nothing.\n */\nfunction sealable(draft: Draft): Headers {\n const guard =\n (method: \"set\" | \"append\" | \"delete\") =>\n (...args: [string, string]) => {\n writable(\"responseHeaders()\");\n\n return (draft.headers[method] as (...a: string[]) => void)(...args);\n };\n\n const proxy: Headers = new Proxy(draft.headers, {\n get(target, property, receiver) {\n if (\n property === \"set\" ||\n property === \"append\" ||\n property === \"delete\"\n ) {\n return guard(property);\n }\n\n // A maplike forEach passes the object it was called on as the third\n // callback argument, and binding to the target makes that the raw\n // Headers — a live, unguarded reference handed out by the very method\n // meant to be read-only. Substituted for the proxy so there is no way\n // through.\n if (property === \"forEach\") {\n return (\n fn: (value: string, key: string, parent: Headers) => void,\n thisArg?: unknown,\n ) =>\n target.forEach((value, key) => fn.call(thisArg, value, key, proxy));\n }\n\n const value = Reflect.get(target, property, receiver);\n\n return typeof value === \"function\" ? value.bind(target) : value;\n },\n });\n\n return proxy;\n}\n\n/**\n * Cookies a backend set while answering a host call - a login - put on the\n * page's response, as if the page had set them. Only while the response is\n * open: an action or middleware. A call made after the headers went out - a\n * read inside a Suspense boundary - has nothing to put them on, which is why\n * reads do not set cookies; said once, not dropped silently.\n */\nexport function passSetCookies(setCookies: string[]): void {\n if (setCookies.length === 0) return;\n\n const open = draft()?.getStore();\n\n if (!open) return;\n\n if (open.sealed) {\n if (!warnedLateCookie) {\n warnedLateCookie = true;\n console.warn(\n \"[rsc-kit] the backend set a cookie while answering a call made after the response was sent, \" +\n \"so it cannot reach the browser. Set cookies from an action or middleware.\",\n );\n }\n\n return;\n }\n\n for (const cookie of setCookies) {\n open.headers.append(\"Set-Cookie\", cookie);\n\n // The jar a later cookies() read sees: this request's own write.\n const pair = cookie.split(\";\", 1)[0] ?? \"\";\n const at = pair.indexOf(\"=\");\n\n if (at > 0) open.cookies.set(pair.slice(0, at).trim(), pair.slice(at + 1).trim());\n }\n}\n\nlet warnedLateCookie = false;\n\nexport function responseHeaders(): Headers {\n return sealable(writable(\"responseHeaders()\"));\n}\n\n/**\n * Run a request with a response that can still be changed, and take what was\n * put on it.\n *\n * `seal()` is called by the host the moment it builds the Response, so\n * anything set afterwards is refused instead of silently going nowhere.\n */\nexport async function withResponseDraft<T>(\n run: (draft: { taken: () => Headers; seal: () => void }) => Promise<T>,\n): Promise<T> {\n if (!globals[DRAFT]) {\n draftReady ??= resolveScope().then((resolved) => {\n globals[DRAFT] ??= resolved as unknown as DraftScope;\n });\n\n await draftReady;\n }\n\n const open: Draft = { headers: new Headers(), sealed: false, cookies: new Map() };\n\n return await draft()!.run(open, () =>\n run({\n taken: () => open.headers,\n seal: () => {\n open.sealed = true;\n },\n }),\n );\n}\n\n/**\n * A cookie name, as RFC 6265 defines one: a token, so no separators at all.\n *\n * Checked rather than escaped because there is no escaping — a name is not a\n * quoted string. An app that derives one from user input (`pref_${key}`) would\n * otherwise let that input close the pair and open another: a name of\n * `session=attacker; Path=/; HttpOnly; x` serializes to a header whose *first*\n * pair is a session cookie the caller chose, and the browser reads the first.\n */\nconst COOKIE_NAME = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\n/** No separator may appear in an attribute either, for the same reason. */\nconst COOKIE_ATTRIBUTE = /[;,\\r\\n]/;\n\n/** `name=value; Path=/; HttpOnly` — the header a browser expects. */\nexport function serializeCookie(cookie: {\n name: string;\n value: string;\n options: CookieOptions;\n}): string {\n if (!COOKIE_NAME.test(cookie.name)) {\n throw new Error(\n `Not a usable cookie name: ${JSON.stringify(cookie.name)}. ` +\n \"A name is a token — letters, digits and !#$%&'*+-.^_`|~ — with no spaces, \" +\n \"semicolons or equals signs. Nothing escapes them, so one cannot be encoded around.\",\n );\n }\n\n if (cookie.options.sameSite !== undefined) {\n const value = String(cookie.options.sameSite).toLowerCase();\n\n if (value !== \"strict\" && value !== \"lax\" && value !== \"none\") {\n throw new Error(\n `Not a SameSite value: ${JSON.stringify(cookie.options.sameSite)}. ` +\n \"It is written into the header as given, so anything else becomes further attributes.\",\n );\n }\n }\n\n for (const [attribute, value] of [\n [\"path\", cookie.options.path],\n [\"domain\", cookie.options.domain],\n ] as const) {\n if (typeof value === \"string\" && COOKIE_ATTRIBUTE.test(value)) {\n throw new Error(\n `The cookie ${attribute} ${JSON.stringify(value)} contains a separator. ` +\n \"It would be read as further attributes rather than as part of this one.\",\n );\n }\n }\n\n // Typed as a Date, but a cast reaches this and the result lands in the\n // header verbatim. Checked apart from the others because a date has commas\n // in it by definition - \"Sun, 20 Sep 2026 14:49:56 GMT\" - and the general\n // check refused every Expires ever written.\n const expires = cookie.options.expires?.toUTCString();\n\n if (typeof expires === \"string\" && /[;\\r\\n]/.test(expires)) {\n throw new Error(\n `The cookie expires ${JSON.stringify(expires)} contains a separator. ` +\n \"It would be read as further attributes rather than as part of this one.\",\n );\n }\n\n const parts = [`${cookie.name}=${encodeURIComponent(cookie.value)}`];\n const o = cookie.options;\n\n if (o.maxAge !== undefined) parts.push(`Max-Age=${Math.floor(o.maxAge)}`);\n if (o.expires) parts.push(`Expires=${o.expires.toUTCString()}`);\n // Defaulted, because a cookie without one is scoped to the path that set it\n // — a session written by POST /_rsc/action would not be sent for any page.\n parts.push(`Path=${o.path ?? \"/\"}`);\n if (o.domain) parts.push(`Domain=${o.domain}`);\n if (o.sameSite)\n parts.push(`SameSite=${o.sameSite[0].toUpperCase()}${o.sameSite.slice(1)}`);\n if (o.secure) parts.push(\"Secure\");\n if (o.httpOnly) parts.push(\"HttpOnly\");\n if (o.partitioned) parts.push(\"Partitioned\");\n\n return parts.join(\"; \");\n}\n\nexport async function cookies(): Promise<Cookies> {\n // Named before the await, because `headers()` never settles during a build —\n // nothing after this line runs there, and the reason would be recorded as\n // headers() for a call nobody wrote.\n const store = slot();\n\n if (!store.request) recordRead(store, \"cookies()\");\n\n readVisitor(store, \"cookies()\");\n\n const parsed = parseCookies((await headers()).get(\"cookie\") ?? \"\");\n\n // What arrived, then what this request wrote over it. Read at each call\n // rather than once: a write between two reads is the case that matters.\n const jar = (): Record<string, string> => {\n const written = draft()?.getStore()?.cookies;\n\n if (!written?.size) return parsed;\n\n const merged = { ...parsed };\n\n for (const [name, value] of written) {\n if (value === null) delete merged[name];\n else merged[name] = value;\n }\n\n return merged;\n };\n\n const write = (\n name: string,\n value: string,\n options: CookieOptions = {},\n ): void => {\n const open = writable(\"cookies().set()\");\n\n // Appended, never set: several cookies on one response are several\n // Set-Cookie headers, and replacing would leave only the last.\n open.headers.append(\"Set-Cookie\", serializeCookie({ name, value, options }));\n\n // A cookie told to expire is one the browser will not send back.\n const gone =\n options.maxAge !== undefined ? options.maxAge <= 0 : options.expires !== undefined && options.expires.getTime() <= Date.now();\n\n open.cookies.set(name, gone ? null : value);\n };\n\n return {\n get: (name) => {\n const current = jar();\n\n // Own keys only: `in` found \"constructor\" in any jar.\n return Object.hasOwn(current, name) ? { name, value: current[name] } : undefined;\n },\n has: (name) => Object.hasOwn(jar(), name),\n getAll: () => Object.entries(jar()).map(([name, value]) => ({ name, value })),\n set: (nameOrCookie: string | (RequestCookie & CookieOptions), value?: string, options?: CookieOptions) => {\n if (typeof nameOrCookie === \"string\") return write(nameOrCookie, value ?? \"\", options);\n\n const { name, value: v, ...rest } = nameOrCookie;\n\n return write(name, v, rest);\n },\n // Expired rather than removed: a browser drops a cookie when it is told\n // one has already passed, and there is no other way to say it.\n delete: (name, options = {}) => write(name, \"\", { ...options, maxAge: 0 }),\n };\n}\n\n/**\n * The whole request, for a host-specific need the accessors do not cover.\n *\n * Null on a host that forwards only the parts — the worker behind Laravel has\n * a socket, not a request. Use headers() and cookies(), which work everywhere.\n */\nexport async function request(): Promise<Request | null> {\n const store = slot();\n\n readVisitor(store, \"request()\");\n\n return store.request ? store.original : never(\"request()\");\n}\n\n/**\n * Mark everything below as belonging to the request, not to the build.\n *\n * export default async function Orders() {\n * await connection()\n *\n * const rows = await db.query('select * from orders')\n *\n * return <ul>{rows.map(...)}</ul>\n * }\n *\n * At build time this never resolves, so nothing after it runs: the query is not\n * made, the boundary above becomes a hole, and the rest of the page still\n * freezes. At request time it resolves immediately and the component runs\n * normally.\n *\n * **Once is enough.** It is a barrier, not a wrapper — everything after it in\n * this component belongs to the request, however many calls that is. Repeating\n * it before each query does nothing.\n *\n * It needs a boundary above it. With a <Suspense> or a loading.tsx there is a\n * fallback to store and the page becomes a shell; with neither, nothing can\n * paint and the build refuses the route rather than storing a blank.\n *\n * Reach for it when the build should not run something — a database the build\n * machine cannot see, or a value that must differ per visitor. A query the\n * build CAN run, whose answer is the same for everyone, wants none of this: it\n * should be frozen.\n *\n * The same name and behaviour as Next's `connection()`.\n */\nexport async function connection(): Promise<void> {\n const store = slot();\n\n readVisitor(store, \"connection()\");\n\n // No request means a build. Suspend rather than continue, the same way\n // headers() and cookies() do.\n if (!store.request) return never(\"connection()\");\n}\n\n/**\n * The query of the request being rendered - `?q=shoes`, or \"\" - and null when\n * there is no request: a build, whose render may be stored. For the server's\n * HTML render, which hands it to useSearchParams. Not a read of the request:\n * the render it serves is per request already.\n */\nexport function requestSearch(): string | null {\n const store = scope()?.getStore();\n\n if (!store?.request || !store.url) return null;\n\n try {\n return new URL(store.url, \"http://rsc.invalid\").search;\n } catch {\n return null;\n }\n}\n\n/**\n * Whether the request being rendered is a crawler's, which is answered with\n * the finished document - see crawler.ts. False when there is no request.\n */\nexport function requestFromCrawler(): boolean {\n const store = scope()?.getStore();\n\n return Boolean(store?.request && isCrawler(store.headers.get(\"user-agent\")));\n}\n\n/** The url this request was made to, whichever way the host supplied it. */\nexport async function url(): Promise<string | null> {\n const store = slot();\n\n return store.request ? store.url : never(\"url()\");\n}\n\nfunction parseCookies(header: string): Record<string, string> {\n const out: Record<string, string> = {};\n\n for (const part of header.split(\";\")) {\n const eq = part.indexOf(\"=\");\n\n if (eq === -1) continue;\n\n const name = part.slice(0, eq).trim();\n\n if (!name) continue;\n\n // Decoded because that is how they were written. A malformed escape is\n // left as it arrived rather than throwing the render away.\n const raw = part.slice(eq + 1).trim();\n\n try {\n out[name] = decodeURIComponent(raw);\n } catch {\n out[name] = raw;\n }\n }\n\n return out;\n}\n\n/**\n * Run one request with its headers readable.\n *\n * `null` is the build: a scope with nothing in it, so a page that reads is\n * caught rather than silently frozen holding whatever the machine that built\n * it happened to send.\n */\nexport async function withRequest<T>(\n from: RequestLike,\n run: () => Promise<T>,\n): Promise<T> {\n if (!globals[SCOPE]) {\n ready ??= resolveScope().then((resolved) => {\n globals[SCOPE] ??= resolved as unknown as Scope;\n });\n\n await ready;\n }\n\n const isRequest = from instanceof Request;\n const store: Slot = {\n request: from !== null,\n url: from ? (isRequest ? from.url : from.url) : null,\n headers: from\n ? isRequest\n ? from.headers\n : new Headers(from.headers)\n : new Headers(),\n original: isRequest ? from : null,\n read: false,\n readBy: [],\n readWhere: [],\n fallbacks: [],\n awaiters: new Map(),\n inHelper: null,\n readVia: new Map(),\n after: [],\n };\n\n return await scope()!.run(store, run);\n}\n\n/**\n * Run with no visitor: no request to read, no response to set cookies on.\n *\n * For what is kept between visitors. Inside, `cookies()` and `headers()`\n * throw rather than answer, a backend call carries no session, and a cookie\n * the backend sets goes nowhere - so an answer one visitor caused cannot be\n * about them, and cannot be handed to the next as though it were theirs.\n */\nexport function withoutRequest<T>(run: () => T): T {\n const requests = scope();\n const drafts = draft();\n const bare = drafts ? () => drafts.run(undefined as never, run) : run;\n\n return requests ? requests.run(undefined as never, bare) : bare();\n}\n\n/**\n * Run a render with a different url, the request otherwise unchanged.\n *\n * An action's response renders what it revalidated for the page it was called\n * from. The request is the action's POST, whose url is the endpoint's; the\n * page's query string lives in the page's url. A slot on /agent/test?c=25\n * re-rendered after a message was sent read the POST's empty query - through\n * searchParams() and through the page's own searchParams prop, which is built\n * on it - and came back as a new chat. Headers and cookies stay the request's:\n * it is the same visitor, asking about a different url.\n */\nexport async function withUrl<T>(href: string, run: () => Promise<T>): Promise<T> {\n const store = slot();\n\n if (!store.request) return await run();\n\n return await scope()!.run({ ...store, url: href }, run);\n}\n\n/**\n * A promise that never settles, so the caller suspends.\n *\n * What a read does during a build. React treats it exactly as it treats a host\n * call that never answers: the component suspends, its Suspense fallback goes\n * into the shell, and the probe's budget decides the rest.\n */\n/**\n * The build's probe hands a route a Request that records what is read out of\n * it, and a read of `url` marks the route as depending on the caller — the\n * Next way to read a query is `new URL(request.url).searchParams`, which the\n * probe cannot otherwise see. The engine itself reads the url to resolve the\n * awaited `searchParams`, and that read is accounted for by `searchParams`,\n * not by `url`; this is the door it goes through. A probe answers the real\n * Request to this key; anything else answers nothing, and the request is its\n * own.\n */\nexport const UNPROBED = Symbol.for(\"rsc-kit.unprobed\");\n\n/** The request's url, read by the engine rather than the route. */\nexport function urlOf(request: Request): string {\n return ((request as unknown as Record<symbol, Request | undefined>)[UNPROBED] ?? request).url;\n}\n\n/**\n * Record a read without suspending on it.\n *\n * For a reader that CAN answer during a build but whose answer would be wrong\n * to store — an api route's query string, which exists and is empty, and which\n * the build has no business freezing an answer to. `never()` is for a reader\n * with nothing to return; this is for one that has something and should still\n * be noticed.\n *\n * A no-op outside a render scope, so a handler called at request time pays a\n * property read and nothing else.\n */\nexport function noteRequestRead(by: string): void {\n const store = scope()?.getStore();\n\n if (!store) return;\n\n recordRead(store, by);\n}\n\n/**\n * Note a read of the visitor, in a render that may be kept for everyone.\n *\n * Only there: naming the component takes a stack, which every other render\n * has no use for. The first read is the one a refusal names.\n */\nfunction readVisitor(store: Slot, by: string): void {\n if (!store.request || !store.asNobody) return;\n\n const list = (store.perVisitor ??= []);\n const { name } = caller(by.replace(/\\(.*$/, \"\"));\n const entry = name ? `${by} in ${name}` : by;\n\n if (!list.includes(entry)) list.push(entry);\n}\n\n/**\n * Render the request that is open as nobody: a page that may be kept by a\n * shared cache (`export const revalidate`). Backend calls go without the\n * visitor's cookie and what they set is dropped - so `auth()->user()` is null\n * there, as `fetch` in a Next ISR page has no cookies - and every read of the\n * visitor is written down for pageCache to judge.\n */\nexport function renderAsNobody(): void {\n const store = scope()?.getStore();\n\n if (store?.request) store.asNobody = true;\n}\n\n/** Whether the render that is open is one renderAsNobody() marked. */\nexport function renderingAsNobody(): boolean {\n return scope()?.getStore()?.asNobody === true;\n}\n\n/**\n * Note the tags of an answer the render used, in a render that may be kept for\n * everyone: the kept copy is stale when any of them changes, and its Cache-Tag\n * lets a CDN purge it then. A no-op anywhere else.\n */\nexport function noteCacheTags(tags: readonly string[], versions: Record<string, number> = {}): void {\n const store = scope()?.getStore();\n\n if (!store?.request || !store.asNobody || tags.length === 0) return;\n\n const list = (store.tags ??= []);\n const seen = (store.tagVersions ??= {});\n\n for (const tag of tags) {\n if (!list.includes(tag)) list.push(tag);\n // The first read wins: a tag that moved mid-render leaves the older\n // version on the kept page, so the next lookup sees the move and misses.\n if (!(tag in seen)) seen[tag] = versions[tag] ?? 0;\n }\n}\n\n/** The version of each tag noteCacheTags() collected, as it was first read. */\nexport function cacheTagVersionsRead(): Record<string, number> {\n return { ...(scope()?.getStore()?.tagVersions ?? {}) };\n}\n\n/** The tags noteCacheTags() collected in the render that is open, in order. */\nexport function cacheTagsRead(): string[] {\n return scope()?.getStore()?.tags ?? [];\n}\n\n/** What read the visitor in a render renderAsNobody() marked, in order. */\nexport function visitorReads(): string[] {\n return scope()?.getStore()?.perVisitor ?? [];\n}\n\n/**\n * React reported a failure inside the payload. The render \"succeeded\" - the\n * row is in the stream - and the answer looks storable, but the browser\n * throws on that row. A no-op outside a request.\n */\nexport function noteRenderFailure(): void {\n const store = scope()?.getStore();\n\n if (store) store.failed = true;\n}\n\n/**\n * The payload carries notFound() as a row, after its 200 went out: the\n * browser shows not-found.tsx, and a cache must keep it no longer than a 404.\n */\nexport function noteNotFoundRow(): void {\n const store = scope()?.getStore();\n\n if (store) store.saidNotFound = true;\n}\n\n/** Whether noteNotFoundRow() was called in the scope that is open. */\nexport function notFoundRowSent(): boolean {\n return scope()?.getStore()?.saidNotFound === true;\n}\n\n/** Whether noteRenderFailure() was called in the scope that is open. */\nexport function renderFailed(): boolean {\n return scope()?.getStore()?.failed === true;\n}\n\nfunction never(by: string): Promise<never> {\n const store = slot();\n\n store.read = true;\n recordRead(store, by);\n\n return new Promise(() => {});\n}\n\n/**\n * Whether anything read the request during the scope that is open.\n *\n * For the prerenderer, which opens one with no request and asks afterwards.\n */\nexport function requestWasRead(): boolean {\n return scope()?.getStore()?.read ?? false;\n}\n\n/**\n * What reached for the request during the scope that is open.\n *\n * For the build, which asks afterwards so it can say why a page is rendered per\n * visitor rather than only that it is.\n */\nexport function requestReadBy(): string[] {\n return scope()?.getStore()?.readBy ?? [];\n}\n\n/** A read React caught at a boundary during SSR: `useSearchParams() in Query`. */\nexport function noteFallback(text: string): void {\n const store = scope()?.getStore();\n\n if (!store) return;\n\n store.fallbacks ??= [];\n\n if (!store.fallbacks.includes(text)) store.fallbacks.push(text);\n}\n\n/**\n * Run something once the answer is on its way, without making it wait.\n *\n * Logging, an audit row, an email, a cache warm: work the visitor should not\n * pay for, and that must still finish. Next's `after()`, and needed for the\n * same reason on every host: on a long-lived process a detached promise\n * happens to run to completion, but a Worker tears the isolate down when the\n * response ends unless the work is registered with the platform's\n * `waitUntil` - so a fire-and-forget promise there dies silently, some of\n * the time. The host hands these to `waitUntil` where one exists and runs\n * them detached where a process will keep them.\n *\n * From a component, a middleware, a server action or an api route. A\n * rejection is reported and never reaches the response, which has already\n * gone. Outside a request - a build - the work runs at once.\n */\nexport function after(work: () => unknown): void {\n const store = scope()?.getStore();\n\n if (!store || !store.request) {\n void Promise.resolve().then(work).catch(reportAfter);\n\n return;\n }\n\n store.after.push(work);\n}\n\n/**\n * @internal The request being answered, as an object to key per-request\n * state on - null outside one. For work that gathers itself into one after():\n * a purge of every name an action changed.\n */\nexport function requestKey(): object | null {\n const store = scope()?.getStore();\n\n return store?.request ? store : null;\n}\n\n// For purge.ts, which @rsc-kit/core/changed brings into client code and so\n// cannot import this file: the two calls it needs, on the global.\n(globalThis as Record<symbol, unknown>)[Symbol.for(\"rsc-kit.after\")] = { after, requestKey };\n\nfunction reportAfter(error: unknown): void {\n console.error(\"[rsc-kit] after() work failed:\", error);\n}\n\n/**\n * @internal For the host: the work `after()` collected for this request, as\n * one promise that never rejects. Taken once; a second call has nothing.\n */\nexport function takeAfterWork(): Promise<void> | null {\n const store = scope()?.getStore();\n\n if (!store || store.after.length === 0) return null;\n\n const work = store.after.splice(0);\n\n return Promise.allSettled(\n work.map((run) => Promise.resolve().then(run)),\n ).then((results) => {\n for (const result of results) {\n if (result.status === \"rejected\") reportAfter(result.reason);\n }\n });\n}\n\n/** The reads caught at a boundary during this render, with their components. */\nexport function requestFallbacks(): string[] {\n return scope()?.getStore()?.fallbacks ?? [];\n}\n\n/**\n * A component called a cache()-wrapped helper. Recorded on every call, hit\n * or miss, so a read the helper makes can name everyone who waited for it.\n */\nexport function noteAwaiter(helper: unknown): void {\n const store = scope()?.getStore();\n\n if (!store) return;\n\n const { name } = caller(\"cache\");\n\n if (!name) return;\n\n store.awaiters ??= new Map();\n\n const list = store.awaiters.get(helper) ?? [];\n\n if (!list.includes(name)) list.push(name);\n\n store.awaiters.set(helper, list);\n}\n\n/** Run a cache()-wrapped helper's body, so a read inside it is filed under the helper. */\nexport function withHelper<T>(helper: unknown, run: () => T): T {\n const store = scope()?.getStore();\n\n if (!store) return run();\n\n const before = store.inHelper;\n\n store.inHelper = helper;\n\n try {\n return run();\n } finally {\n store.inHelper = before;\n }\n}\n\n/**\n * The same reads, each with the component that made it: `cookies() in\n * RootLayout`. A read inside a cached helper with more than one awaiter\n * names them all - `connection() awaited by AuthLinks, AuthDialogSlot` -\n * because the stack saw only the first, and the first is rarely the one\n * that blocks.\n */\nexport function requestReadWhere(): string[] {\n const store = scope()?.getStore();\n\n if (!store?.readWhere?.length) return store?.readBy ?? [];\n\n return store.readWhere.map((entry) => {\n const helper = store.readVia?.get(entry);\n const awaiters = helper ? store.awaiters?.get(helper) : undefined;\n\n if (!awaiters || awaiters.length < 2) return entry;\n\n const names =\n awaiters.length === 2\n ? awaiters.join(\" and \")\n : awaiters.slice(0, -1).join(\", \") + \" and \" + awaiters.at(-1);\n\n return `${entry.split(\" in \")[0]} awaited by ${names}`;\n });\n}\n\n/**\n * The query string, as a page receives it.\n *\n * Derived from the request rather than passed down the render, so no host has\n * to forward it separately — and so it suspends during a build for the same\n * reason every other read does. A frozen page cannot know the query it will be\n * asked for.\n */\nexport async function searchParams(): Promise<URLSearchParams> {\n // Named before the await, so the build reports the call someone wrote rather\n // than url(), which this happens to be built on.\n const store = slot();\n\n if (!store.request && !store.readBy.includes(\"searchParams()\")) {\n store.readBy.push(\"searchParams()\");\n }\n\n const from = await url();\n\n return from ? new URL(from).searchParams : new URLSearchParams();\n}\n\n/**\n * The props the page is being rendered with, for whatever renders inside it.\n *\n * A section is rendered by its page with whatever the page passed, which is\n * usually nothing, and alone - on a refresh - with the page's own props. Its\n * refreshOn is a function of the page's params either way, so the engine notes\n * them here and the section reads them back, whichever way it was rendered.\n */\nexport function notePageProps(props: Record<string, unknown>): void {\n const store = scope()?.getStore();\n\n if (store) store.pageProps = props;\n}\n\n/** The page's props as noted by the engine; empty outside a page render. */\nexport function currentPageProps(): Record<string, unknown> {\n return scope()?.getStore()?.pageProps ?? {};\n}\n"]}
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,6DAA6D;AAC7D,EAAE;AACF,iDAAiD;AACjD,mGAAmG;AACnG,mCAAmC;AACnC,MAAM;AACN,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,8EAA8E;AAC9E,iB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IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC/D,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,GAAG,EAAE,CAAC;IAEzB,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,eAAe,EAAE,CAAC;AACnE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAA8B;IAC1D,MAAM,KAAK,GAAG,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC;IAElC,IAAI,KAAK;QAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;AACrC,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB;IAC9B,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,SAAS,IAAI,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["// Reading the request from inside a render.\n//\n// import { headers, cookies } from '@rsc-kit/core/request'\n//\n// export default async function middleware() {\n// const locale = cookies().get('locale')?.value ?? negotiate(headers().get('accept-language'))\n// if (!locale) redirect('/en')\n// }\n//\n// Server components have no arguments beyond their props, and middleware has\n// none at all, so without this an app on a JavaScript host cannot see a header\n// — no locale negotiation, no subdomain, no cookie. The Laravel host escaped\n// that through rpc(), because PHP has the request; this is the same thing for\n// everyone else.\n//\n// Read-only on purpose. Setting a cookie means writing a response header, and\n// by the time a component renders the shell may already have been flushed — an\n// API that appears to set one and silently does not is worse than not having\n// it. Set them in the host, which owns the response.\n//\n// Asynchronous on purpose too, and not for ergonomics. A build has no request,\n// so a read there suspends and never settles — which is the same thing the\n// prerender probe does to a host call. Anything still waiting when the probe's\n// budget expires becomes a fallback in the frozen shell, so a read inside a\n// Suspense boundary leaves the shell frozen and makes only that boundary\n// dynamic. Reading synchronously could only mark the whole route dynamic,\n// because there would be nothing to suspend on.\n//\n// Scoped to the request, on the same store cache() uses. Two requests in\n// flight cannot see each other's headers.\n\nimport { isCrawler } from \"./crawler.js\";\nimport { resolveScope } from \"./revalidate.js\";\n\nexport type { ServedRequest } from \"./served.js\";\n\n/** What a host can supply: a real Request, or the parts of one. */\nexport type RequestLike =\n Request | { url: string; headers: Record<string, string>; ip?: string } | null;\n\ninterface Slot {\n /** False during a build: there is nothing to answer with. */\n request: boolean;\n url: string | null;\n /**\n * Held as Headers rather than as a Request.\n *\n * `new Request(url, { headers })` drops Cookie: a spec-compliant Headers\n * built with the \"request\" guard refuses the forbidden header names, and\n * Cookie is one of them. `new Headers()` has no guard and keeps it. Bun\n * happens to allow both, which is why rebuilding a Request looked fine until\n * it ran anywhere stricter — and what it loses is every cookie, silently.\n */\n headers: Headers;\n original: Request | null;\n /** The visitor's address, when the server knows it - see clientAddress(). */\n ip: string | null;\n /** The backend guard checks this request has passed - see guardsPassed(). */\n guards: Set<string>;\n /**\n * Whether anything asked. Only for the build's report — the classification\n * comes from the suspension, not from this.\n */\n read: boolean;\n /**\n * What read it, in the order they did.\n *\n * Only the name of the accessor — `cookies()`, `headers()` — which is enough\n * for the build to say why a page could not be frozen. Without it the answer\n * is \"something in this page reached for the request\", and finding which is\n * the part that takes an afternoon.\n */\n readBy: string[];\n /**\n * The same reads with the component that made each one - `cookies() in\n * RootLayout` - taken from the stack at the moment of the read, which is\n * still the component's own call: an accessor runs synchronously up to\n * the point it suspends. Only the build reads this. \"Reads the request\" is\n * a category; this is the line to open.\n */\n readWhere: string[];\n /**\n * Reads the server could not answer and React caught at a boundary - the\n * fallback is what got stored - with the component that made each:\n * `useSearchParams() in Query`. Noted by the SSR entry, read by the build,\n * which attaches them to the route so a page stored as its own loading\n * screen says why.\n */\n fallbacks: string[];\n /**\n * For a read made inside a cache()-wrapped helper: the components that\n * awaited that helper, first caller included. The helper runs once, so\n * the stack at the read names only whoever got there first; every later\n * awaiter is a cache hit that never reaches the accessor. The one above\n * every boundary is usually one of the later ones.\n */\n awaiters: Map<unknown, string[]>;\n /** The cache()-wrapped helper whose body is running, while it runs. */\n inHelper: unknown;\n /** readWhere entry -> the helper it was read inside. */\n readVia: Map<string, unknown>;\n /** Work to run once the answer is on its way - see after(). */\n after: (() => unknown)[];\n /** The props the page was rendered with - its params and searchParams - for a region rendered inside it to read. */\n pageProps?: Record<string, unknown>;\n /**\n * A render that may be kept by a shared cache (`export const revalidate`):\n * backend calls carry no session, and what reads the visitor is written\n * down so the answer can be judged once it is whole. Optional: a store\n * written by an older bundle has none of these.\n */\n asNobody?: boolean;\n /** What read this visitor, with the component that did: `cookies() in Header`. */\n perVisitor?: string[];\n /** The tags of every cache() answer the render used, for the answer's Cache-Tag. */\n tags?: string[];\n /** The version each of those tags had when it was first read, for a kept page to be checked against. */\n tagVersions?: Record<string, number>;\n /** React reported a failure inside the payload: the answer is not a page to keep. */\n failed?: boolean;\n /** The render said notFound() inside its payload, where the browser's boundary shows not-found.tsx. */\n saidNotFound?: boolean;\n}\n\nconst SCOPE = Symbol.for(\"@rsc-kit/core.request-scope\");\n\n/**\n * The accessors themselves and the plumbing under them: frames to walk past\n * on the way to the component that called.\n */\nconst NOT_A_CALLER = new Set([\n \"never\",\n // A thenable's own method: the read is named by what it was for.\n \"then\",\n \"cache\",\n \"noteAwaiter\",\n \"withHelper\",\n \"noteRequestRead\",\n \"recordRead\",\n \"caller\",\n \"slot\",\n \"cookies\",\n \"headers\",\n \"connection\",\n \"searchParams\",\n \"request\",\n \"url\",\n \"parseParams\",\n \"parseSearchParams\",\n \"parseBody\",\n \"get\",\n \"set\",\n \"has\",\n]);\n\n/** The accessors a component calls by name. One calling another is plumbing, not a second read. */\nconst ACCESSORS = new Set([\n \"cookies\",\n \"headers\",\n \"connection\",\n \"searchParams\",\n \"request\",\n \"url\",\n]);\n\n/**\n * The nearest named function above the accessor on the stack, and whether\n * another accessor sits between: `cookies()` reads through `headers()`, and\n * that inner read is not a second thing the component did.\n *\n * Read from a thrown-away Error: the one thing a build cannot otherwise learn\n * is which component reached for the request, and the stack knows. Function\n * names survive a server bundle, which is not minified, so this is\n * `RootLayout` and not a line number in a chunk. Internal names are walked\n * past; an anonymous frame is skipped rather than reported as `<anonymous>`.\n */\nfunction caller(own: string): { name: string | null; nested: boolean } {\n const stack = new Error().stack ?? \"\";\n let accessors = 0;\n let helper: string | null = null;\n\n for (const line of stack.split(\"\\n\")) {\n const match = /^\\s*at (?:async )?([^\\s(]+)/.exec(line);\n\n if (!match) continue;\n\n const name = match[1]!.split(\".\").pop()!;\n\n // A frame with no function name prints its location instead - `js:6054:8`\n // - which is not a name to report.\n if (!/^[\\w$]+$/.test(name)) continue;\n\n if (ACCESSORS.has(name)) accessors++;\n if (\n NOT_A_CALLER.has(name) ||\n name === \"<anonymous>\" ||\n name === \"Object\" ||\n name === \"Promise\"\n )\n continue;\n\n const nested = accessors > (ACCESSORS.has(own) ? 1 : 0);\n\n // A function that is not a component - getCurrentUser, wrapped in\n // cache() - is the shared helper the read lives in. Named, because with\n // cache() the read runs once, on whichever component called first, and\n // every other caller of the helper is invisible to the stack. The helper\n // is what they have in common.\n if (/^[a-z_$]/.test(name) && !/^use[A-Z]/.test(name)) {\n helper ??= name;\n\n continue;\n }\n\n return {\n name: helper && helper !== name ? `${helper} (from ${name})` : name,\n nested,\n };\n }\n\n return { name: helper, nested: accessors > (ACCESSORS.has(own) ? 1 : 0) };\n}\n\nfunction recordRead(store: Slot, by: string): void {\n if (!store.readBy.includes(by)) store.readBy.push(by);\n\n // Older stores, written by a bundle built before this field existed.\n store.readWhere ??= [];\n\n const { name, nested } = caller(by.replace(/\\(.*$/, \"\"));\n\n if (nested) return;\n\n const entry = name ? `${by} in ${name}` : by;\n\n if (!store.readWhere.includes(entry)) store.readWhere.push(entry);\n if (store.inHelper) (store.readVia ??= new Map()).set(entry, store.inHelper);\n}\n\nconst globals = globalThis as Record<symbol | string, unknown>;\n\nlet ready: Promise<void> | null = null;\n\ninterface Scope {\n getStore(): Slot | undefined;\n run<T>(store: Slot, fn: () => T): T;\n}\n\nfunction scope(): Scope | null {\n return (globals[SCOPE] as Scope | undefined) ?? null;\n}\n\nfunction slot(): Slot {\n const store = scope()?.getStore();\n\n if (!store) {\n throw new Error(\n \"No request in scope. headers() and cookies() are for a render — middleware, a layout, \" +\n \"a page — and there is nothing to read outside one.\",\n );\n }\n\n store.read = true;\n\n return store;\n}\n\n/**\n * The request's headers.\n *\n * Empty during a build, where there is no request: the page is marked as\n * needing one instead, and rendered on demand rather than frozen.\n */\nexport async function headers(): Promise<Headers> {\n const store = slot();\n\n readVisitor(store, \"headers()\");\n\n return store.request ? store.headers : never(\"headers()\");\n}\n\n/** How a cookie should be written. The names browsers use. */\nexport interface 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 partitioned?: boolean;\n}\n\n/** One cookie as the request carried it: the shape Next's `cookies().get()` returns. */\nexport interface RequestCookie {\n name: string;\n value: string;\n}\n\n/**\n * The cookie jar, in the shape Next's `cookies()` has.\n *\n * `get()` returns `{ name, value }` rather than the string, because the guide\n * says \"the same names from `@rsc-kit/core/request`\" and a name that is the\n * same with a different return shape is the worst of both: ported code\n * reading `?.value` off a string got `undefined`, silently. `getAll()` is a\n * list for the same reason, and because a list composes where a record does\n * not.\n */\nexport interface Cookies {\n get(name: string): RequestCookie | undefined;\n has(name: string): boolean;\n getAll(): RequestCookie[];\n /**\n * Write one on the response.\n *\n * Only from a server action, which has a response of its own that has not\n * been sent. A render has already flushed its headers by the time a\n * component runs — that is what makes the first paint fast — so this throws\n * there rather than appearing to work.\n *\n * Either call shape Next takes: `set(name, value, options)` or\n * `set({ name, value, ...options })`.\n */\n set(name: string, value: string, options?: CookieOptions): void;\n set(cookie: RequestCookie & CookieOptions): void;\n /** Write one that expires immediately. Same rule about where. */\n delete(name: string, options?: CookieOptions): void;\n}\n\n/** Kept for the name it had when it could only read. */\nexport type ReadonlyCookies = Cookies;\n\n/**\n * The response being built, while it can still be changed.\n *\n * Open from the moment a request is picked up until the host constructs its\n * Response, and sealed the instant it does. Middleware runs inside that window\n * — before any rendering starts — so a header set there is on the answer. A\n * component runs after it, during streaming, where the status line and headers\n * are already on the wire; setting one there is refused rather than dropped.\n */\ninterface Draft {\n headers: Headers;\n sealed: boolean;\n /**\n * What this request wrote to the jar, over what it arrived with: a value,\n * or null for a deletion. Read back by `cookies()` for the rest of the\n * request, so a render that follows the write - the sections an action\n * revalidates travel back with its answer, rendered in the same request -\n * sees what the browser is about to hold. Next has the same rule, which\n * is why `set` then `revalidate` is what every port writes; without it\n * the sidebar re-rendered with the cookie the request arrived with, and\n * showed the old choice until a reload.\n */\n cookies: Map<string, string | null>;\n}\n\nconst DRAFT = Symbol.for(\"@rsc-kit/core.response-draft\");\n\nlet draftReady: Promise<void> | null = null;\n\ninterface DraftScope {\n getStore(): Draft | undefined;\n run<T>(store: Draft, fn: () => T): T;\n}\n\nfunction draft(): DraftScope | null {\n return (globals[DRAFT] as DraftScope | undefined) ?? null;\n}\n\n/** The open draft, or an explanation of why there is not one. */\nfunction writable(what: string): Draft {\n const open = draft()?.getStore();\n\n if (!open) {\n throw new Error(\n `${what} needs a response that has not been sent. Middleware and server actions have one; ` +\n \"a script outside a request does not.\",\n );\n }\n\n if (open.sealed) {\n throw new Error(\n `${what} was called after the response had been sent. Headers go out before the render ` +\n \"starts — that is what makes the first paint fast — so set them in middleware, which \" +\n \"runs before it.\",\n );\n }\n\n return open;\n}\n\n/**\n * Headers to put on the answer.\n *\n * Mutate it as you would any Headers. `append` is the one to reach for when a\n * header may legitimately appear twice; `set` replaces.\n */\n/**\n * The draft's headers, refusing writes once the response has gone.\n *\n * A proxy rather than the Headers itself: returning the live object means code\n * that captured it before the response was built can go on mutating a thing\n * nobody will read. Nothing in this package does that — the host copies the\n * headers onto the response the instant it seals — but \"safe because of the\n * order two other functions happen to run in\" is not a property, and an app\n * holding the object across an await would find writes silently doing nothing.\n */\nfunction sealable(draft: Draft): Headers {\n const guard =\n (method: \"set\" | \"append\" | \"delete\") =>\n (...args: [string, string]) => {\n writable(\"responseHeaders()\");\n\n return (draft.headers[method] as (...a: string[]) => void)(...args);\n };\n\n const proxy: Headers = new Proxy(draft.headers, {\n get(target, property, receiver) {\n if (\n property === \"set\" ||\n property === \"append\" ||\n property === \"delete\"\n ) {\n return guard(property);\n }\n\n // A maplike forEach passes the object it was called on as the third\n // callback argument, and binding to the target makes that the raw\n // Headers — a live, unguarded reference handed out by the very method\n // meant to be read-only. Substituted for the proxy so there is no way\n // through.\n if (property === \"forEach\") {\n return (\n fn: (value: string, key: string, parent: Headers) => void,\n thisArg?: unknown,\n ) =>\n target.forEach((value, key) => fn.call(thisArg, value, key, proxy));\n }\n\n const value = Reflect.get(target, property, receiver);\n\n return typeof value === \"function\" ? value.bind(target) : value;\n },\n });\n\n return proxy;\n}\n\n/**\n * Cookies a backend set while answering a host call - a login - put on the\n * page's response, as if the page had set them. Only while the response is\n * open: an action or middleware. A call made after the headers went out - a\n * read inside a Suspense boundary - has nothing to put them on, which is why\n * reads do not set cookies; said once, not dropped silently.\n */\nexport function passSetCookies(setCookies: string[]): void {\n if (setCookies.length === 0) return;\n\n const open = draft()?.getStore();\n\n if (!open) return;\n\n if (open.sealed) {\n if (!warnedLateCookie) {\n warnedLateCookie = true;\n console.warn(\n \"[rsc-kit] the backend set a cookie while answering a call made after the response was sent, \" +\n \"so it cannot reach the browser. Set cookies from an action or middleware.\",\n );\n }\n\n return;\n }\n\n for (const cookie of setCookies) {\n open.headers.append(\"Set-Cookie\", cookie);\n\n // The jar a later cookies() read sees: this request's own write.\n const pair = cookie.split(\";\", 1)[0] ?? \"\";\n const at = pair.indexOf(\"=\");\n\n if (at > 0) open.cookies.set(pair.slice(0, at).trim(), pair.slice(at + 1).trim());\n }\n}\n\nlet warnedLateCookie = false;\n\nexport function responseHeaders(): Headers {\n return sealable(writable(\"responseHeaders()\"));\n}\n\n/**\n * Run a request with a response that can still be changed, and take what was\n * put on it.\n *\n * `seal()` is called by the host the moment it builds the Response, so\n * anything set afterwards is refused instead of silently going nowhere.\n */\nexport async function withResponseDraft<T>(\n run: (draft: { taken: () => Headers; seal: () => void }) => Promise<T>,\n): Promise<T> {\n if (!globals[DRAFT]) {\n draftReady ??= resolveScope().then((resolved) => {\n globals[DRAFT] ??= resolved as unknown as DraftScope;\n });\n\n await draftReady;\n }\n\n const open: Draft = { headers: new Headers(), sealed: false, cookies: new Map() };\n\n return await draft()!.run(open, () =>\n run({\n taken: () => open.headers,\n seal: () => {\n open.sealed = true;\n },\n }),\n );\n}\n\n/**\n * A cookie name, as RFC 6265 defines one: a token, so no separators at all.\n *\n * Checked rather than escaped because there is no escaping — a name is not a\n * quoted string. An app that derives one from user input (`pref_${key}`) would\n * otherwise let that input close the pair and open another: a name of\n * `session=attacker; Path=/; HttpOnly; x` serializes to a header whose *first*\n * pair is a session cookie the caller chose, and the browser reads the first.\n */\nconst COOKIE_NAME = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\n/** No separator may appear in an attribute either, for the same reason. */\nconst COOKIE_ATTRIBUTE = /[;,\\r\\n]/;\n\n/** `name=value; Path=/; HttpOnly` — the header a browser expects. */\nexport function serializeCookie(cookie: {\n name: string;\n value: string;\n options: CookieOptions;\n}): string {\n if (!COOKIE_NAME.test(cookie.name)) {\n throw new Error(\n `Not a usable cookie name: ${JSON.stringify(cookie.name)}. ` +\n \"A name is a token — letters, digits and !#$%&'*+-.^_`|~ — with no spaces, \" +\n \"semicolons or equals signs. Nothing escapes them, so one cannot be encoded around.\",\n );\n }\n\n if (cookie.options.sameSite !== undefined) {\n const value = String(cookie.options.sameSite).toLowerCase();\n\n if (value !== \"strict\" && value !== \"lax\" && value !== \"none\") {\n throw new Error(\n `Not a SameSite value: ${JSON.stringify(cookie.options.sameSite)}. ` +\n \"It is written into the header as given, so anything else becomes further attributes.\",\n );\n }\n }\n\n for (const [attribute, value] of [\n [\"path\", cookie.options.path],\n [\"domain\", cookie.options.domain],\n ] as const) {\n if (typeof value === \"string\" && COOKIE_ATTRIBUTE.test(value)) {\n throw new Error(\n `The cookie ${attribute} ${JSON.stringify(value)} contains a separator. ` +\n \"It would be read as further attributes rather than as part of this one.\",\n );\n }\n }\n\n // Typed as a Date, but a cast reaches this and the result lands in the\n // header verbatim. Checked apart from the others because a date has commas\n // in it by definition - \"Sun, 20 Sep 2026 14:49:56 GMT\" - and the general\n // check refused every Expires ever written.\n const expires = cookie.options.expires?.toUTCString();\n\n if (typeof expires === \"string\" && /[;\\r\\n]/.test(expires)) {\n throw new Error(\n `The cookie expires ${JSON.stringify(expires)} contains a separator. ` +\n \"It would be read as further attributes rather than as part of this one.\",\n );\n }\n\n const parts = [`${cookie.name}=${encodeURIComponent(cookie.value)}`];\n const o = cookie.options;\n\n if (o.maxAge !== undefined) parts.push(`Max-Age=${Math.floor(o.maxAge)}`);\n if (o.expires) parts.push(`Expires=${o.expires.toUTCString()}`);\n // Defaulted, because a cookie without one is scoped to the path that set it\n // — a session written by POST /_rsc/action would not be sent for any page.\n parts.push(`Path=${o.path ?? \"/\"}`);\n if (o.domain) parts.push(`Domain=${o.domain}`);\n if (o.sameSite)\n parts.push(`SameSite=${o.sameSite[0].toUpperCase()}${o.sameSite.slice(1)}`);\n if (o.secure) parts.push(\"Secure\");\n if (o.httpOnly) parts.push(\"HttpOnly\");\n if (o.partitioned) parts.push(\"Partitioned\");\n\n return parts.join(\"; \");\n}\n\nexport async function cookies(): Promise<Cookies> {\n // Named before the await, because `headers()` never settles during a build —\n // nothing after this line runs there, and the reason would be recorded as\n // headers() for a call nobody wrote.\n const store = slot();\n\n if (!store.request) recordRead(store, \"cookies()\");\n\n readVisitor(store, \"cookies()\");\n\n const parsed = parseCookies((await headers()).get(\"cookie\") ?? \"\");\n\n // What arrived, then what this request wrote over it. Read at each call\n // rather than once: a write between two reads is the case that matters.\n const jar = (): Record<string, string> => {\n const written = draft()?.getStore()?.cookies;\n\n if (!written?.size) return parsed;\n\n const merged = { ...parsed };\n\n for (const [name, value] of written) {\n if (value === null) delete merged[name];\n else merged[name] = value;\n }\n\n return merged;\n };\n\n const write = (\n name: string,\n value: string,\n options: CookieOptions = {},\n ): void => {\n const open = writable(\"cookies().set()\");\n\n // Appended, never set: several cookies on one response are several\n // Set-Cookie headers, and replacing would leave only the last.\n open.headers.append(\"Set-Cookie\", serializeCookie({ name, value, options }));\n\n // A cookie told to expire is one the browser will not send back.\n const gone =\n options.maxAge !== undefined ? options.maxAge <= 0 : options.expires !== undefined && options.expires.getTime() <= Date.now();\n\n open.cookies.set(name, gone ? null : value);\n };\n\n return {\n get: (name) => {\n const current = jar();\n\n // Own keys only: `in` found \"constructor\" in any jar.\n return Object.hasOwn(current, name) ? { name, value: current[name] } : undefined;\n },\n has: (name) => Object.hasOwn(jar(), name),\n getAll: () => Object.entries(jar()).map(([name, value]) => ({ name, value })),\n set: (nameOrCookie: string | (RequestCookie & CookieOptions), value?: string, options?: CookieOptions) => {\n if (typeof nameOrCookie === \"string\") return write(nameOrCookie, value ?? \"\", options);\n\n const { name, value: v, ...rest } = nameOrCookie;\n\n return write(name, v, rest);\n },\n // Expired rather than removed: a browser drops a cookie when it is told\n // one has already passed, and there is no other way to say it.\n delete: (name, options = {}) => write(name, \"\", { ...options, maxAge: 0 }),\n };\n}\n\n/**\n * The whole request, for a host-specific need the accessors do not cover.\n *\n * Null on a host that forwards only the parts — the worker behind Laravel has\n * a socket, not a request. Use headers() and cookies(), which work everywhere.\n */\nexport async function request(): Promise<Request | null> {\n const store = slot();\n\n readVisitor(store, \"request()\");\n\n return store.request ? store.original : never(\"request()\");\n}\n\n/**\n * Mark everything below as belonging to the request, not to the build.\n *\n * export default async function Orders() {\n * await connection()\n *\n * const rows = await db.query('select * from orders')\n *\n * return <ul>{rows.map(...)}</ul>\n * }\n *\n * At build time this never resolves, so nothing after it runs: the query is not\n * made, the boundary above becomes a hole, and the rest of the page still\n * freezes. At request time it resolves immediately and the component runs\n * normally.\n *\n * **Once is enough.** It is a barrier, not a wrapper — everything after it in\n * this component belongs to the request, however many calls that is. Repeating\n * it before each query does nothing.\n *\n * It needs a boundary above it. With a <Suspense> or a loading.tsx there is a\n * fallback to store and the page becomes a shell; with neither, nothing can\n * paint and the build refuses the route rather than storing a blank.\n *\n * Reach for it when the build should not run something — a database the build\n * machine cannot see, or a value that must differ per visitor. A query the\n * build CAN run, whose answer is the same for everyone, wants none of this: it\n * should be frozen.\n *\n * The same name and behaviour as Next's `connection()`.\n */\nexport async function connection(): Promise<void> {\n const store = slot();\n\n readVisitor(store, \"connection()\");\n\n // No request means a build. Suspend rather than continue, the same way\n // headers() and cookies() do.\n if (!store.request) return never(\"connection()\");\n}\n\n/**\n * The query of the request being rendered - `?q=shoes`, or \"\" - and null when\n * there is no request: a build, whose render may be stored. For the server's\n * HTML render, which hands it to useSearchParams. Not a read of the request:\n * the render it serves is per request already.\n */\nexport function requestSearch(): string | null {\n const store = scope()?.getStore();\n\n if (!store?.request || !store.url) return null;\n\n try {\n return new URL(store.url, \"http://rsc.invalid\").search;\n } catch {\n return null;\n }\n}\n\n/**\n * The visitor's address, or null outside a request and when the server did not\n * say. Not a read of the request: it goes to the backend on every host call,\n * where `$request->ip()` and a throttle keyed on it are about the visitor\n * rather than about this renderer, which every visitor would otherwise share.\n */\nexport function requestClientIp(): string | null {\n const store = scope()?.getStore();\n\n return store?.request ? store.ip : null;\n}\n\n/**\n * The backend guard checks already passed during this request, or null\n * outside one. A stored page is guarded before the store is looked in, and\n * when nothing is stored the render guards it again: two calls for one page,\n * and a `throttle:6,1` that let three visits through. One visitor, one page,\n * one answer - asked once.\n */\nexport function guardsPassed(): Set<string> | null {\n const store = scope()?.getStore();\n\n return store?.request ? store.guards : null;\n}\n\n/**\n * The url the visitor asked for, as they typed it: the request's own, under the\n * host and scheme a proxy in front forwarded when one did. Null outside a\n * request. For the backend's route middleware, which judges the page rather\n * than the call asking about it - Laravel's `signed` checks a signature over\n * exactly this. Not a read of the request: a route with backend middleware is\n * never stored for everyone anyway.\n */\nexport function requestPageUrl(): string | null {\n const store = scope()?.getStore();\n\n if (!store?.request || !store.url) return null;\n\n try {\n const url = new URL(store.url);\n const host = store.headers.get(\"x-forwarded-host\")?.split(\",\")[0]?.trim();\n const forwarded = store.headers.get(\"x-forwarded-proto\")?.split(\",\")[0]?.trim();\n const proto = forwarded === \"http\" || forwarded === \"https\" ? forwarded : url.protocol.slice(0, -1);\n\n // Rebuilt rather than assigned to url.host, which keeps this server's\n // port when the forwarded name has none.\n return host ? new URL(url.pathname + url.search, `${proto}://${host}`).href : url.href;\n } catch {\n return null;\n }\n}\n\n/**\n * Who sent the request: the peer address the server put on it - srvx's\n * `request.ip`, which Nitro hands every route - or, when RSC_TRUST_FORWARDED=1\n * says a proxy of this deployment's own wrote the chain, the first hop of\n * X-Forwarded-For. Never the chain otherwise: a browser can write that header,\n * and would choose its own address for every throttle on the backend.\n */\nfunction clientAddress(from: Exclude<RequestLike, null>): string | null {\n const read = (name: string): string | null =>\n from instanceof Request ? from.headers.get(name) : (from.headers[name] ?? null);\n\n if (typeof process !== \"undefined\" && process.env.RSC_TRUST_FORWARDED === \"1\") {\n const first = read(\"x-forwarded-for\")?.split(\",\")[0]?.trim() || read(\"x-real-ip\")?.trim();\n\n if (first) return first;\n }\n\n let ip: unknown;\n\n try {\n ip = (from as { ip?: unknown }).ip;\n } catch {\n // A getter that throws for a request with no socket behind it.\n ip = undefined;\n }\n\n return typeof ip === \"string\" && ip !== \"\" ? ip : null;\n}\n\n/**\n * Whether the request being rendered is a crawler's, which is answered with\n * the finished document - see crawler.ts. False when there is no request.\n */\nexport function requestFromCrawler(): boolean {\n const store = scope()?.getStore();\n\n return Boolean(store?.request && isCrawler(store.headers.get(\"user-agent\")));\n}\n\n/** The url this request was made to, whichever way the host supplied it. */\nexport async function url(): Promise<string | null> {\n const store = slot();\n\n return store.request ? store.url : never(\"url()\");\n}\n\nfunction parseCookies(header: string): Record<string, string> {\n const out: Record<string, string> = {};\n\n for (const part of header.split(\";\")) {\n const eq = part.indexOf(\"=\");\n\n if (eq === -1) continue;\n\n const name = part.slice(0, eq).trim();\n\n if (!name) continue;\n\n // Decoded because that is how they were written. A malformed escape is\n // left as it arrived rather than throwing the render away.\n const raw = part.slice(eq + 1).trim();\n\n try {\n out[name] = decodeURIComponent(raw);\n } catch {\n out[name] = raw;\n }\n }\n\n return out;\n}\n\n/**\n * Run one request with its headers readable.\n *\n * `null` is the build: a scope with nothing in it, so a page that reads is\n * caught rather than silently frozen holding whatever the machine that built\n * it happened to send.\n */\nexport async function withRequest<T>(\n from: RequestLike,\n run: () => Promise<T>,\n): Promise<T> {\n if (!globals[SCOPE]) {\n ready ??= resolveScope().then((resolved) => {\n globals[SCOPE] ??= resolved as unknown as Scope;\n });\n\n await ready;\n }\n\n const isRequest = from instanceof Request;\n const store: Slot = {\n request: from !== null,\n url: from ? (isRequest ? from.url : from.url) : null,\n headers: from\n ? isRequest\n ? from.headers\n : new Headers(from.headers)\n : new Headers(),\n original: isRequest ? from : null,\n ip: from ? clientAddress(from) : null,\n guards: new Set(),\n read: false,\n readBy: [],\n readWhere: [],\n fallbacks: [],\n awaiters: new Map(),\n inHelper: null,\n readVia: new Map(),\n after: [],\n };\n\n return await scope()!.run(store, run);\n}\n\n/**\n * Run with no visitor: no request to read, no response to set cookies on.\n *\n * For what is kept between visitors. Inside, `cookies()` and `headers()`\n * throw rather than answer, a backend call carries no session, and a cookie\n * the backend sets goes nowhere - so an answer one visitor caused cannot be\n * about them, and cannot be handed to the next as though it were theirs.\n */\nexport function withoutRequest<T>(run: () => T): T {\n const requests = scope();\n const drafts = draft();\n const bare = drafts ? () => drafts.run(undefined as never, run) : run;\n\n return requests ? requests.run(undefined as never, bare) : bare();\n}\n\n/**\n * Run a render with a different url, the request otherwise unchanged.\n *\n * An action's response renders what it revalidated for the page it was called\n * from. The request is the action's POST, whose url is the endpoint's; the\n * page's query string lives in the page's url. A slot on /agent/test?c=25\n * re-rendered after a message was sent read the POST's empty query - through\n * searchParams() and through the page's own searchParams prop, which is built\n * on it - and came back as a new chat. Headers and cookies stay the request's:\n * it is the same visitor, asking about a different url.\n */\nexport async function withUrl<T>(href: string, run: () => Promise<T>): Promise<T> {\n const store = slot();\n\n if (!store.request) return await run();\n\n return await scope()!.run({ ...store, url: href }, run);\n}\n\n/**\n * A promise that never settles, so the caller suspends.\n *\n * What a read does during a build. React treats it exactly as it treats a host\n * call that never answers: the component suspends, its Suspense fallback goes\n * into the shell, and the probe's budget decides the rest.\n */\n/**\n * The build's probe hands a route a Request that records what is read out of\n * it, and a read of `url` marks the route as depending on the caller — the\n * Next way to read a query is `new URL(request.url).searchParams`, which the\n * probe cannot otherwise see. The engine itself reads the url to resolve the\n * awaited `searchParams`, and that read is accounted for by `searchParams`,\n * not by `url`; this is the door it goes through. A probe answers the real\n * Request to this key; anything else answers nothing, and the request is its\n * own.\n */\nexport const UNPROBED = Symbol.for(\"rsc-kit.unprobed\");\n\n/** The request's url, read by the engine rather than the route. */\nexport function urlOf(request: Request): string {\n return ((request as unknown as Record<symbol, Request | undefined>)[UNPROBED] ?? request).url;\n}\n\n/**\n * Record a read without suspending on it.\n *\n * For a reader that CAN answer during a build but whose answer would be wrong\n * to store — an api route's query string, which exists and is empty, and which\n * the build has no business freezing an answer to. `never()` is for a reader\n * with nothing to return; this is for one that has something and should still\n * be noticed.\n *\n * A no-op outside a render scope, so a handler called at request time pays a\n * property read and nothing else.\n */\nexport function noteRequestRead(by: string): void {\n const store = scope()?.getStore();\n\n if (!store) return;\n\n recordRead(store, by);\n}\n\n/**\n * Note a read of the visitor, in a render that may be kept for everyone.\n *\n * Only there: naming the component takes a stack, which every other render\n * has no use for. The first read is the one a refusal names.\n */\nfunction readVisitor(store: Slot, by: string): void {\n if (!store.request || !store.asNobody) return;\n\n const list = (store.perVisitor ??= []);\n const { name } = caller(by.replace(/\\(.*$/, \"\"));\n const entry = name ? `${by} in ${name}` : by;\n\n if (!list.includes(entry)) list.push(entry);\n}\n\n/**\n * Render the request that is open as nobody: a page that may be kept by a\n * shared cache (`export const revalidate`). Backend calls go without the\n * visitor's cookie and what they set is dropped - so `auth()->user()` is null\n * there, as `fetch` in a Next ISR page has no cookies - and every read of the\n * visitor is written down for pageCache to judge.\n */\nexport function renderAsNobody(): void {\n const store = scope()?.getStore();\n\n if (store?.request) store.asNobody = true;\n}\n\n/** Whether the render that is open is one renderAsNobody() marked. */\nexport function renderingAsNobody(): boolean {\n return scope()?.getStore()?.asNobody === true;\n}\n\n/**\n * Note the tags of an answer the render used, in a render that may be kept for\n * everyone: the kept copy is stale when any of them changes, and its Cache-Tag\n * lets a CDN purge it then. A no-op anywhere else.\n */\nexport function noteCacheTags(tags: readonly string[], versions: Record<string, number> = {}): void {\n const store = scope()?.getStore();\n\n if (!store?.request || !store.asNobody || tags.length === 0) return;\n\n const list = (store.tags ??= []);\n const seen = (store.tagVersions ??= {});\n\n for (const tag of tags) {\n if (!list.includes(tag)) list.push(tag);\n // The first read wins: a tag that moved mid-render leaves the older\n // version on the kept page, so the next lookup sees the move and misses.\n if (!(tag in seen)) seen[tag] = versions[tag] ?? 0;\n }\n}\n\n/** The version of each tag noteCacheTags() collected, as it was first read. */\nexport function cacheTagVersionsRead(): Record<string, number> {\n return { ...(scope()?.getStore()?.tagVersions ?? {}) };\n}\n\n/** The tags noteCacheTags() collected in the render that is open, in order. */\nexport function cacheTagsRead(): string[] {\n return scope()?.getStore()?.tags ?? [];\n}\n\n/** What read the visitor in a render renderAsNobody() marked, in order. */\nexport function visitorReads(): string[] {\n return scope()?.getStore()?.perVisitor ?? [];\n}\n\n/**\n * React reported a failure inside the payload. The render \"succeeded\" - the\n * row is in the stream - and the answer looks storable, but the browser\n * throws on that row. A no-op outside a request.\n */\nexport function noteRenderFailure(): void {\n const store = scope()?.getStore();\n\n if (store) store.failed = true;\n}\n\n/**\n * The payload carries notFound() as a row, after its 200 went out: the\n * browser shows not-found.tsx, and a cache must keep it no longer than a 404.\n */\nexport function noteNotFoundRow(): void {\n const store = scope()?.getStore();\n\n if (store) store.saidNotFound = true;\n}\n\n/** Whether noteNotFoundRow() was called in the scope that is open. */\nexport function notFoundRowSent(): boolean {\n return scope()?.getStore()?.saidNotFound === true;\n}\n\n/** Whether noteRenderFailure() was called in the scope that is open. */\nexport function renderFailed(): boolean {\n return scope()?.getStore()?.failed === true;\n}\n\nfunction never(by: string): Promise<never> {\n const store = slot();\n\n store.read = true;\n recordRead(store, by);\n\n return new Promise(() => {});\n}\n\n/**\n * Whether anything read the request during the scope that is open.\n *\n * For the prerenderer, which opens one with no request and asks afterwards.\n */\nexport function requestWasRead(): boolean {\n return scope()?.getStore()?.read ?? false;\n}\n\n/**\n * What reached for the request during the scope that is open.\n *\n * For the build, which asks afterwards so it can say why a page is rendered per\n * visitor rather than only that it is.\n */\nexport function requestReadBy(): string[] {\n return scope()?.getStore()?.readBy ?? [];\n}\n\n/** A read React caught at a boundary during SSR: `useSearchParams() in Query`. */\nexport function noteFallback(text: string): void {\n const store = scope()?.getStore();\n\n if (!store) return;\n\n store.fallbacks ??= [];\n\n if (!store.fallbacks.includes(text)) store.fallbacks.push(text);\n}\n\n/**\n * Run something once the answer is on its way, without making it wait.\n *\n * Logging, an audit row, an email, a cache warm: work the visitor should not\n * pay for, and that must still finish. Next's `after()`, and needed for the\n * same reason on every host: on a long-lived process a detached promise\n * happens to run to completion, but a Worker tears the isolate down when the\n * response ends unless the work is registered with the platform's\n * `waitUntil` - so a fire-and-forget promise there dies silently, some of\n * the time. The host hands these to `waitUntil` where one exists and runs\n * them detached where a process will keep them.\n *\n * From a component, a middleware, a server action or an api route. A\n * rejection is reported and never reaches the response, which has already\n * gone. Outside a request - a build - the work runs at once.\n */\nexport function after(work: () => unknown): void {\n const store = scope()?.getStore();\n\n if (!store || !store.request) {\n void Promise.resolve().then(work).catch(reportAfter);\n\n return;\n }\n\n store.after.push(work);\n}\n\n/**\n * @internal The request being answered, as an object to key per-request\n * state on - null outside one. For work that gathers itself into one after():\n * a purge of every name an action changed.\n */\nexport function requestKey(): object | null {\n const store = scope()?.getStore();\n\n return store?.request ? store : null;\n}\n\n// For purge.ts, which @rsc-kit/core/changed brings into client code and so\n// cannot import this file: the two calls it needs, on the global.\n(globalThis as Record<symbol, unknown>)[Symbol.for(\"rsc-kit.after\")] = { after, requestKey };\n\nfunction reportAfter(error: unknown): void {\n console.error(\"[rsc-kit] after() work failed:\", error);\n}\n\n/**\n * @internal For the host: the work `after()` collected for this request, as\n * one promise that never rejects. Taken once; a second call has nothing.\n */\nexport function takeAfterWork(): Promise<void> | null {\n const store = scope()?.getStore();\n\n if (!store || store.after.length === 0) return null;\n\n const work = store.after.splice(0);\n\n return Promise.allSettled(\n work.map((run) => Promise.resolve().then(run)),\n ).then((results) => {\n for (const result of results) {\n if (result.status === \"rejected\") reportAfter(result.reason);\n }\n });\n}\n\n/** The reads caught at a boundary during this render, with their components. */\nexport function requestFallbacks(): string[] {\n return scope()?.getStore()?.fallbacks ?? [];\n}\n\n/**\n * A component called a cache()-wrapped helper. Recorded on every call, hit\n * or miss, so a read the helper makes can name everyone who waited for it.\n */\nexport function noteAwaiter(helper: unknown): void {\n const store = scope()?.getStore();\n\n if (!store) return;\n\n const { name } = caller(\"cache\");\n\n if (!name) return;\n\n store.awaiters ??= new Map();\n\n const list = store.awaiters.get(helper) ?? [];\n\n if (!list.includes(name)) list.push(name);\n\n store.awaiters.set(helper, list);\n}\n\n/** Run a cache()-wrapped helper's body, so a read inside it is filed under the helper. */\nexport function withHelper<T>(helper: unknown, run: () => T): T {\n const store = scope()?.getStore();\n\n if (!store) return run();\n\n const before = store.inHelper;\n\n store.inHelper = helper;\n\n try {\n return run();\n } finally {\n store.inHelper = before;\n }\n}\n\n/**\n * The same reads, each with the component that made it: `cookies() in\n * RootLayout`. A read inside a cached helper with more than one awaiter\n * names them all - `connection() awaited by AuthLinks, AuthDialogSlot` -\n * because the stack saw only the first, and the first is rarely the one\n * that blocks.\n */\nexport function requestReadWhere(): string[] {\n const store = scope()?.getStore();\n\n if (!store?.readWhere?.length) return store?.readBy ?? [];\n\n return store.readWhere.map((entry) => {\n const helper = store.readVia?.get(entry);\n const awaiters = helper ? store.awaiters?.get(helper) : undefined;\n\n if (!awaiters || awaiters.length < 2) return entry;\n\n const names =\n awaiters.length === 2\n ? awaiters.join(\" and \")\n : awaiters.slice(0, -1).join(\", \") + \" and \" + awaiters.at(-1);\n\n return `${entry.split(\" in \")[0]} awaited by ${names}`;\n });\n}\n\n/**\n * The query string, as a page receives it.\n *\n * Derived from the request rather than passed down the render, so no host has\n * to forward it separately — and so it suspends during a build for the same\n * reason every other read does. A frozen page cannot know the query it will be\n * asked for.\n */\nexport async function searchParams(): Promise<URLSearchParams> {\n // Named before the await, so the build reports the call someone wrote rather\n // than url(), which this happens to be built on.\n const store = slot();\n\n if (!store.request && !store.readBy.includes(\"searchParams()\")) {\n store.readBy.push(\"searchParams()\");\n }\n\n const from = await url();\n\n return from ? new URL(from).searchParams : new URLSearchParams();\n}\n\n/**\n * The props the page is being rendered with, for whatever renders inside it.\n *\n * A section is rendered by its page with whatever the page passed, which is\n * usually nothing, and alone - on a refresh - with the page's own props. Its\n * refreshOn is a function of the page's params either way, so the engine notes\n * them here and the section reads them back, whichever way it was rendered.\n */\nexport function notePageProps(props: Record<string, unknown>): void {\n const store = scope()?.getStore();\n\n if (store) store.pageProps = props;\n}\n\n/** The page's props as noted by the engine; empty outside a page render. */\nexport function currentPageProps(): Record<string, unknown> {\n return scope()?.getStore()?.pageProps ?? {};\n}\n"]}
@@ -56,7 +56,10 @@ declare global {
56
56
  type Answer<T> = T | HostReply | Promise<T | HostReply>;
57
57
  type Guards = {
58
58
  [HOST_MIDDLEWARE]?: (call: {
59
- args: [names: string[]];
59
+ args: [names: string[], page?: {
60
+ url: string | null;
61
+ params: Record<string, string>;
62
+ }];
60
63
  headers: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":["// A backend for tests: answers rpc() calls and host middleware the way a Go\n// or Laravel host answers them over HTTP, without one running.\n//\n// The app under test talks to it through the real client, httpHostCalls,\n// handed a fetch that answers in-process. So a test exercises what ships -\n// batching, a redirect raised as the engine's own, an unauthenticated reply\n// becoming a 401 - and only the backend is stood in for.\n\nimport type { HostCallReply } from './hostCalls.js'\nimport { CHANGED_FUNCTION, memoryVersions } from './changed.js'\nimport type { ChangedAnswer, ChangedQuery } from './changed.js'\n\nconst REPLY = Symbol.for('rsc-kit.test-host-reply')\n/** Cookies a reply sets: sent as Set-Cookie headers, never in the body. */\nconst COOKIES = Symbol.for('rsc-kit.test-host-cookies')\n\n/** The name the engine asks a host's route guards under. */\nexport const HOST_MIDDLEWARE = '__rsc.middleware'\n\n/**\n * Tag versions for a test host, kept in the test.\n *\n * const names = testChanges()\n * const app = await createTestApp({ host: { ...names.host, 'Repos.list': () => repos } })\n * names.changed('team:1:repos') // what the backend's webhook would say\n *\n * `host` answers `__rsc.changed` the way an adapter does - holding the call up\n * to `wait` for a name to move - and `changed` moves one.\n */\n/**\n * The test host's answer to `__rsc.changed`: given what any test host is\n * given, answering a `ChangedAnswer`.\n *\n * Both halves matter. It takes `HostCallInput`, so an untyped host of\n * `HostHandler`s accepts it; it returns a `ChangedAnswer`, so a host typed\n * from the app's rsc-host.json - whose `__rsc.changed` must answer one -\n * accepts it too. Typed as `HostHandler`, it returned `unknown`, and\n * spreading it into a typed host did not compile.\n */\nexport interface ChangedHost {\n [CHANGED_FUNCTION]: (call: HostCallInput) => Promise<ChangedAnswer>\n}\n\nexport function testChanges(): { host: ChangedHost; changed: (...names: string[]) => void } {\n const source = memoryVersions()\n\n return {\n host: {\n [CHANGED_FUNCTION]: async ({ args }) => {\n const query = args[0] as Partial<ChangedQuery> | undefined\n\n return { versions: await source.changed(query?.since ?? {}, Math.min(query?.wait ?? 0, 5_000)) }\n },\n },\n changed: (...names) => void source.bump(names),\n }\n}\n\n/** What a test handler is given: the call's arguments, and the headers the renderer forwarded. */\nexport interface HostCallInput {\n args: unknown[]\n /** The visitor's request headers the renderer passed on - the cookie, the Accept-Language. */\n headers: Headers\n}\n\n/** Answers one function. Return a value for its result, or one of `hostReply`'s answers. */\nexport type HostHandler = (call: HostCallInput) => unknown\n\ntype Reply = Omit<HostCallReply, 'result'> & { [REPLY]: true }\n\n/** One of the protocol's own answers, from `hostReply`. */\nexport type HostReply = Reply\n\ndeclare global {\n /**\n * The backend's functions, as the build read them from rsc-host.json:\n * each one's arguments and result. Written into .rsc-kit/rsc-env.d.ts;\n * empty without a manifest.\n */\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface RscHostFunctions {}\n}\n\ntype Answer<T> = T | HostReply | Promise<T | HostReply>\n\ntype Guards = {\n [HOST_MIDDLEWARE]?: (call: { args: [names: string[]]; headers: Headers }) => Answer<true>\n [CHANGED_FUNCTION]?: (call: { args: [query: ChangedQuery]; headers: Headers }) => Answer<ChangedAnswer>\n}\n\n/**\n * The backend's functions, by the name rpc() calls them with.\n *\n * Typed from the app's rsc-host.json when it has one: a handler may only\n * answer for a function the backend has, is given its arguments, and returns\n * its result or one of `hostReply`'s answers - never a shape the backend\n * would not send, which is how a fake drifts from the real thing while its\n * tests stay green. Without a manifest, any name and any value.\n *\n * Route guards declared for the host are asked as `__rsc.middleware`\n * (`HOST_MIDDLEWARE`), with the guard names as the first argument; answer\n * `true` to let the page render.\n */\nexport type TestHost = [keyof RscHostFunctions] extends [never]\n ? Record<string, HostHandler>\n : {\n [K in keyof RscHostFunctions]?: RscHostFunctions[K] extends { args: infer A extends unknown[]; result: infer R }\n ? (call: { args: A; headers: Headers }) => Answer<R>\n : never\n } & Guards\n\nconst reply = (fields: Omit<Reply, typeof REPLY>): Reply => ({ ...fields, [REPLY]: true })\n\n/**\n * The protocol's own answers, for a handler to return.\n *\n * host: {\n * 'Apps.list': ({ headers }) =>\n * headers.get('cookie')?.includes('session=') ? [{ id: 1 }] : hostReply.unauthenticated(),\n * 'Apps.create': ({ args }) => hostReply.invalid({ name: ['Taken.'] }),\n * }\n */\nexport const hostReply = {\n /** No session: the page answers 401, an action its auth error. */\n unauthenticated: (message?: string): Reply => reply({ unauthenticated: true, error: message }),\n /** A session that still may not: 403. */\n unauthorized: (message?: string): Reply => reply({ unauthorized: true, error: message }),\n /** Send the visitor somewhere else, as the host's redirect does. */\n redirect: (to: string, status = 307): Reply => reply({ redirect: to, redirectStatus: status }),\n /**\n * Refuse with a status - a 404 for a record this caller cannot see, a 429 -\n * and, optionally, data for the page to act on: what is blocking a delete.\n * With data it reaches an action as `refuse()` does, as `result.refusal`.\n */\n refuse: (status: number, message = 'Refused.', data?: unknown): Reply =>\n reply(data === undefined ? { error: message, refusalStatus: status } : { error: message, refusalStatus: status, refusalData: data }),\n /** The input was refused, by field: an action returns these as validationErrors. */\n invalid: (errors: Record<string, string[]>): Reply => reply({ validationErrors: errors }),\n /** An unexpected failure, as an adapter answers a crash: an error, not a refusal. */\n fail: (message = 'Something went wrong.'): Reply => reply({ error: message }),\n /** A result, and the regions of the page the call says it changed. */\n revalidating: (result: unknown, ...targets: string[]): Reply =>\n reply({ result, revalidate: targets } as Omit<Reply, typeof REPLY>),\n /** A result, and cookies set on the response - a login's session: `'session=abc; Path=/; HttpOnly'`. */\n settingCookies: (result: unknown, ...cookies: string[]): Reply =>\n reply({ result, [COOKIES]: cookies } as unknown as Omit<Reply, typeof REPLY>),\n} as const\n\nfunction isReply(value: unknown): value is Reply {\n return typeof value === 'object' && value !== null && (value as Record<symbol, unknown>)[REPLY] === true\n}\n\nasync function answer(host: TestHost, name: string, args: unknown[], headers: Headers): Promise<HostCallReply> {\n // By a name only known at runtime: a typed host has no index signature.\n const handler = (host as Record<string, HostHandler | undefined>)[name]\n\n // Fails the call rather than answering null: a function the test forgot\n // is a test that would otherwise pass against nothing.\n if (!handler) {\n return {\n error:\n name === HOST_MIDDLEWARE\n ? `the page asked its host guards (${JSON.stringify(args[0])}) and the test host has no \"${HOST_MIDDLEWARE}\" handler`\n : `the test host has no handler for ${JSON.stringify(name)}`,\n }\n }\n\n const value = await handler({ args, headers })\n\n if (isReply(value)) {\n // Symbol keys survive the rest spread; COOKIES is read off by the fetch\n // below, and JSON leaves it out of the body.\n const { [REPLY]: _, ...fields } = value\n\n return fields\n }\n\n return { result: value === undefined ? null : value }\n}\n\n/**\n * A fetch that answers the host-call endpoint from `host`: one call as\n * itself, a batch as `{ replies }`, in order.\n */\nexport function testHostFetch(host: TestHost): typeof fetch {\n return (async (_input: RequestInfo | URL, init?: RequestInit) => {\n const headers = new Headers(init?.headers)\n const body = JSON.parse(String(init?.body ?? '{}')) as\n | { function: string; args?: unknown[] }\n | { calls: { function: string; args?: unknown[] }[] }\n\n // The renderer's own headers are not the visitor's.\n headers.delete('x-rsc-host-secret')\n headers.delete('content-type')\n\n const json = (value: unknown) =>\n new Response(JSON.stringify(value), { headers: { 'content-type': 'application/json' } })\n\n if ('calls' in body) {\n return json({\n replies: await Promise.all(body.calls.map((c) => answer(host, c.function, c.args ?? [], headers))),\n })\n }\n\n const single = await answer(host, body.function, body.args ?? [], headers)\n const cookies = (single as { [COOKIES]?: string[] })[COOKIES] ?? []\n const response = json(single)\n\n for (const cookie of cookies) response.headers.append('Set-Cookie', cookie)\n\n return response\n }) as typeof fetch\n}\n"]}
1
+ {"version":3,"file":"testHost.js","sourceRoot":"","sources":["../src/testHost.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,+DAA+D;AAC/D,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,4EAA4E;AAC5E,yDAAyD;AAGzD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG/D,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;AACnD,2EAA2E;AAC3E,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AAEvD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAA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AI,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC;gBACV,OAAO,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;aACnG,CAAC,CAAA;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,OAAO,CAAC,CAAA;QAC1E,MAAM,OAAO,GAAI,MAAmC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;QACnE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;QAE7B,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;QAE3E,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAiB,CAAA;AACpB,CAAC","sourcesContent":["// A backend for tests: answers rpc() calls and host middleware the way a Go\n// or Laravel host answers them over HTTP, without one running.\n//\n// The app under test talks to it through the real client, httpHostCalls,\n// handed a fetch that answers in-process. So a test exercises what ships -\n// batching, a redirect raised as the engine's own, an unauthenticated reply\n// becoming a 401 - and only the backend is stood in for.\n\nimport type { HostCallReply } from './hostCalls.js'\nimport { CHANGED_FUNCTION, memoryVersions } from './changed.js'\nimport type { ChangedAnswer, ChangedQuery } from './changed.js'\n\nconst REPLY = Symbol.for('rsc-kit.test-host-reply')\n/** Cookies a reply sets: sent as Set-Cookie headers, never in the body. */\nconst COOKIES = Symbol.for('rsc-kit.test-host-cookies')\n\n/** The name the engine asks a host's route guards under. */\nexport const HOST_MIDDLEWARE = '__rsc.middleware'\n\n/**\n * Tag versions for a test host, kept in the test.\n *\n * const names = testChanges()\n * const app = await createTestApp({ host: { ...names.host, 'Repos.list': () => repos } })\n * names.changed('team:1:repos') // what the backend's webhook would say\n *\n * `host` answers `__rsc.changed` the way an adapter does - holding the call up\n * to `wait` for a name to move - and `changed` moves one.\n */\n/**\n * The test host's answer to `__rsc.changed`: given what any test host is\n * given, answering a `ChangedAnswer`.\n *\n * Both halves matter. It takes `HostCallInput`, so an untyped host of\n * `HostHandler`s accepts it; it returns a `ChangedAnswer`, so a host typed\n * from the app's rsc-host.json - whose `__rsc.changed` must answer one -\n * accepts it too. Typed as `HostHandler`, it returned `unknown`, and\n * spreading it into a typed host did not compile.\n */\nexport interface ChangedHost {\n [CHANGED_FUNCTION]: (call: HostCallInput) => Promise<ChangedAnswer>\n}\n\nexport function testChanges(): { host: ChangedHost; changed: (...names: string[]) => void } {\n const source = memoryVersions()\n\n return {\n host: {\n [CHANGED_FUNCTION]: async ({ args }) => {\n const query = args[0] as Partial<ChangedQuery> | undefined\n\n return { versions: await source.changed(query?.since ?? {}, Math.min(query?.wait ?? 0, 5_000)) }\n },\n },\n changed: (...names) => void source.bump(names),\n }\n}\n\n/** What a test handler is given: the call's arguments, and the headers the renderer forwarded. */\nexport interface HostCallInput {\n args: unknown[]\n /** The visitor's request headers the renderer passed on - the cookie, the Accept-Language. */\n headers: Headers\n}\n\n/** Answers one function. Return a value for its result, or one of `hostReply`'s answers. */\nexport type HostHandler = (call: HostCallInput) => unknown\n\ntype Reply = Omit<HostCallReply, 'result'> & { [REPLY]: true }\n\n/** One of the protocol's own answers, from `hostReply`. */\nexport type HostReply = Reply\n\ndeclare global {\n /**\n * The backend's functions, as the build read them from rsc-host.json:\n * each one's arguments and result. Written into .rsc-kit/rsc-env.d.ts;\n * empty without a manifest.\n */\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface RscHostFunctions {}\n}\n\ntype Answer<T> = T | HostReply | Promise<T | HostReply>\n\ntype Guards = {\n [HOST_MIDDLEWARE]?: (call: { args: [names: string[], page?: { url: string | null; params: Record<string, string> }]; headers: Headers }) => Answer<true>\n [CHANGED_FUNCTION]?: (call: { args: [query: ChangedQuery]; headers: Headers }) => Answer<ChangedAnswer>\n}\n\n/**\n * The backend's functions, by the name rpc() calls them with.\n *\n * Typed from the app's rsc-host.json when it has one: a handler may only\n * answer for a function the backend has, is given its arguments, and returns\n * its result or one of `hostReply`'s answers - never a shape the backend\n * would not send, which is how a fake drifts from the real thing while its\n * tests stay green. Without a manifest, any name and any value.\n *\n * Route guards declared for the host are asked as `__rsc.middleware`\n * (`HOST_MIDDLEWARE`), with the guard names as the first argument; answer\n * `true` to let the page render.\n */\nexport type TestHost = [keyof RscHostFunctions] extends [never]\n ? Record<string, HostHandler>\n : {\n [K in keyof RscHostFunctions]?: RscHostFunctions[K] extends { args: infer A extends unknown[]; result: infer R }\n ? (call: { args: A; headers: Headers }) => Answer<R>\n : never\n } & Guards\n\nconst reply = (fields: Omit<Reply, typeof REPLY>): Reply => ({ ...fields, [REPLY]: true })\n\n/**\n * The protocol's own answers, for a handler to return.\n *\n * host: {\n * 'Apps.list': ({ headers }) =>\n * headers.get('cookie')?.includes('session=') ? [{ id: 1 }] : hostReply.unauthenticated(),\n * 'Apps.create': ({ args }) => hostReply.invalid({ name: ['Taken.'] }),\n * }\n */\nexport const hostReply = {\n /** No session: the page answers 401, an action its auth error. */\n unauthenticated: (message?: string): Reply => reply({ unauthenticated: true, error: message }),\n /** A session that still may not: 403. */\n unauthorized: (message?: string): Reply => reply({ unauthorized: true, error: message }),\n /** Send the visitor somewhere else, as the host's redirect does. */\n redirect: (to: string, status = 307): Reply => reply({ redirect: to, redirectStatus: status }),\n /**\n * Refuse with a status - a 404 for a record this caller cannot see, a 429 -\n * and, optionally, data for the page to act on: what is blocking a delete.\n * With data it reaches an action as `refuse()` does, as `result.refusal`.\n */\n refuse: (status: number, message = 'Refused.', data?: unknown): Reply =>\n reply(data === undefined ? { error: message, refusalStatus: status } : { error: message, refusalStatus: status, refusalData: data }),\n /** The input was refused, by field: an action returns these as validationErrors. */\n invalid: (errors: Record<string, string[]>): Reply => reply({ validationErrors: errors }),\n /** An unexpected failure, as an adapter answers a crash: an error, not a refusal. */\n fail: (message = 'Something went wrong.'): Reply => reply({ error: message }),\n /** A result, and the regions of the page the call says it changed. */\n revalidating: (result: unknown, ...targets: string[]): Reply =>\n reply({ result, revalidate: targets } as Omit<Reply, typeof REPLY>),\n /** A result, and cookies set on the response - a login's session: `'session=abc; Path=/; HttpOnly'`. */\n settingCookies: (result: unknown, ...cookies: string[]): Reply =>\n reply({ result, [COOKIES]: cookies } as unknown as Omit<Reply, typeof REPLY>),\n} as const\n\nfunction isReply(value: unknown): value is Reply {\n return typeof value === 'object' && value !== null && (value as Record<symbol, unknown>)[REPLY] === true\n}\n\nasync function answer(host: TestHost, name: string, args: unknown[], headers: Headers): Promise<HostCallReply> {\n // By a name only known at runtime: a typed host has no index signature.\n const handler = (host as Record<string, HostHandler | undefined>)[name]\n\n // Fails the call rather than answering null: a function the test forgot\n // is a test that would otherwise pass against nothing.\n if (!handler) {\n return {\n error:\n name === HOST_MIDDLEWARE\n ? `the page asked its host guards (${JSON.stringify(args[0])}) and the test host has no \"${HOST_MIDDLEWARE}\" handler`\n : `the test host has no handler for ${JSON.stringify(name)}`,\n }\n }\n\n const value = await handler({ args, headers })\n\n if (isReply(value)) {\n // Symbol keys survive the rest spread; COOKIES is read off by the fetch\n // below, and JSON leaves it out of the body.\n const { [REPLY]: _, ...fields } = value\n\n return fields\n }\n\n return { result: value === undefined ? null : value }\n}\n\n/**\n * A fetch that answers the host-call endpoint from `host`: one call as\n * itself, a batch as `{ replies }`, in order.\n */\nexport function testHostFetch(host: TestHost): typeof fetch {\n return (async (_input: RequestInfo | URL, init?: RequestInit) => {\n const headers = new Headers(init?.headers)\n const body = JSON.parse(String(init?.body ?? '{}')) as\n | { function: string; args?: unknown[] }\n | { calls: { function: string; args?: unknown[] }[] }\n\n // The renderer's own headers are not the visitor's.\n headers.delete('x-rsc-host-secret')\n headers.delete('content-type')\n\n const json = (value: unknown) =>\n new Response(JSON.stringify(value), { headers: { 'content-type': 'application/json' } })\n\n if ('calls' in body) {\n return json({\n replies: await Promise.all(body.calls.map((c) => answer(host, c.function, c.args ?? [], headers))),\n })\n }\n\n const single = await answer(host, body.function, body.args ?? [], headers)\n const cookies = (single as { [COOKIES]?: string[] })[COOKIES] ?? []\n const response = json(single)\n\n for (const cookie of cookies) response.headers.append('Set-Cookie', cookie)\n\n return response\n }) as typeof fetch\n}\n"]}
package/dist/vite.js CHANGED
@@ -3474,7 +3474,7 @@ ${
3474
3474
  import { shareRender } from ${JSON.stringify(join(packageDir, "sharedRenders"))}
3475
3475
  import { PathnameProvider } from ${JSON.stringify(join(packageDir, "js/PathnameProvider"))}
3476
3476
  import { DefaultRouteError } from ${JSON.stringify(join(packageDir, "js/DefaultRouteError"))}
3477
- import { noteNotFoundRow, noteRenderFailure, renderAsNobody, requestFromCrawler, requestSearch, searchParams as requestSearchParams, withRequest, withUrl } from ${JSON.stringify(join(packageDir, "request"))}
3477
+ import { guardsPassed, noteNotFoundRow, noteRenderFailure, renderAsNobody, requestFromCrawler, requestPageUrl, requestSearch, searchParams as requestSearchParams, withRequest, withUrl } from ${JSON.stringify(join(packageDir, "request"))}
3478
3478
  import { parseParams, parseSearchParams, parseBody, isSearchParamsError, isBodyError } from ${JSON.stringify(join(packageDir, "routeSchema"))}
3479
3479
  import { notFoundDigest, isNotFoundSignal } from ${JSON.stringify(join(packageDir, "notFound"))}
3480
3480
  import { noteRequestRead, notePageProps, urlOf } from ${JSON.stringify(join(packageDir, "request"))}
@@ -4855,6 +4855,13 @@ let middlewareChains: Record<string, string[]> | null = null
4855
4855
 
4856
4856
  let hostChains: Record<string, string[]> | null = null
4857
4857
 
4858
+ /** The params each guarded route's url binds, by the name runHostMiddleware is asked with. */
4859
+ let hostParamNames: Record<string, string[]> = {}
4860
+
4861
+ function boundNames(segments: { type: string; value: string }[] | undefined): string[] {
4862
+ return (segments ?? []).filter((segment) => segment.type !== 'static').map((segment) => segment.value)
4863
+ }
4864
+
4858
4865
  /**
4859
4866
  * Guards the host runs, named by a route.ts and meaningless here.
4860
4867
  *
@@ -4868,17 +4875,23 @@ let hostChains: Record<string, string[]> | null = null
4868
4875
  * whoever asked, if the absence of a refusal is read as permission. Only a
4869
4876
  * literal true allows.
4870
4877
  */
4871
- async function runHostMiddleware(component) {
4878
+ async function runHostMiddleware(component, props: Record<string, unknown> = {}) {
4872
4879
  if (!hostChains) {
4873
4880
  hostChains = {}
4874
4881
 
4875
4882
  for (const route of manifest().routes) {
4876
- if (route.hostMiddleware?.length) hostChains[route.component] = route.hostMiddleware
4883
+ if (route.hostMiddleware?.length) {
4884
+ hostChains[route.component] = route.hostMiddleware
4885
+ hostParamNames[route.component] = boundNames(route.segments)
4886
+ }
4877
4887
  }
4878
4888
 
4879
4889
  // Api routes, keyed by module name - the key runRouteMiddleware is asked with.
4880
4890
  for (const api of manifest().apis ?? []) {
4881
- if (api.hostMiddleware?.length) hostChains[api.name] = api.hostMiddleware
4891
+ if (api.hostMiddleware?.length) {
4892
+ hostChains[api.name] = api.hostMiddleware
4893
+ hostParamNames[api.name] = boundNames(api.segments)
4894
+ }
4882
4895
  }
4883
4896
  }
4884
4897
 
@@ -4893,7 +4906,21 @@ async function runHostMiddleware(component) {
4893
4906
  )
4894
4907
  }
4895
4908
 
4896
- const answer = await currentHost(HOST_MIDDLEWARE_FN, names)
4909
+ // The page the names are about, as a second argument a host may ignore. The
4910
+ // call itself is a POST from this renderer to an endpoint of the backend's,
4911
+ // so a middleware reading the request it runs under saw that: a signed-url
4912
+ // check verified the endpoint's url and refused every link, and a policy
4913
+ // on a route param had no param to bind. The url is the visitor's,
4914
+ // the params the route matched - strings only, a catch-all's list joined
4915
+ // the way its url spells it. Only the names the route binds: a page's props
4916
+ // carry its query beside them, and ?order=8 must not stand in for {order}.
4917
+ const page = { url: requestPageUrl(), params: routeParams(props, hostParamNames[component] ?? []) }
4918
+ const passed = guardsPassed()
4919
+ const asked = JSON.stringify([names, page])
4920
+
4921
+ if (passed?.has(asked)) return
4922
+
4923
+ const answer = await currentHost(HOST_MIDDLEWARE_FN, names, page)
4897
4924
 
4898
4925
  // Anything other than a literal true. A host answering null, undefined, a
4899
4926
  // string, or an object it happened to build on the way to an error is not
@@ -4901,11 +4928,27 @@ async function runHostMiddleware(component) {
4901
4928
  if (answer !== true) {
4902
4929
  throw new Error('Host middleware refused ' + component + ' (' + names.join(', ') + ').')
4903
4930
  }
4931
+
4932
+ passed?.add(asked)
4904
4933
  }
4905
4934
 
4906
4935
 
4936
+ /** A route's params as a backend can bind them: every value a string. */
4937
+ function routeParams(props: Record<string, unknown>, bound: string[]): Record<string, string> {
4938
+ const params: Record<string, string> = {}
4939
+
4940
+ for (const name of bound) {
4941
+ const value = props[name]
4942
+
4943
+ if (typeof value === 'string') params[name] = value
4944
+ else if (Array.isArray(value) && value.every((part) => typeof part === 'string')) params[name] = value.join('/')
4945
+ }
4946
+
4947
+ return params
4948
+ }
4949
+
4907
4950
  async function runMiddleware(component: string, props: Record<string, unknown> = {}): Promise<void> {
4908
- await runHostMiddleware(component)
4951
+ await runHostMiddleware(component, props)
4909
4952
 
4910
4953
  // Read from the route table rather than passed in, so every render path is
4911
4954
  // covered by construction and no host has to remember to forward them.