@barqjs/start 0.2.0-next.0 → 0.2.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/{client-BHyIiYxt.js → client-BsyxVCyu.js} +49 -22
- package/dist/client-BsyxVCyu.js.map +1 -0
- package/dist/{client-DHCV7yvQ.d.ts → client-DidH0F2e.d.ts} +28 -18
- package/dist/client-DidH0F2e.d.ts.map +1 -0
- package/dist/client.d.ts +25 -3
- package/dist/client.js +3 -3
- package/dist/{env-qA8EyOr1.d.ts → env-Bhk_aIkx.d.ts} +1 -3
- package/dist/env-Bhk_aIkx.d.ts.map +1 -0
- package/dist/env.d.ts +1 -1
- package/dist/env.js +1 -2
- package/dist/{index-Bm_-MTj6.d.ts → index-B4o7eyCr.d.ts} +32 -22
- package/dist/index-B4o7eyCr.d.ts.map +1 -0
- package/dist/index.d.ts +18 -5
- package/dist/index.js +4 -4
- package/dist/{middleware-BdVlE8qm.d.ts → middleware-B-tI8QHQ.d.ts} +1 -3
- package/dist/middleware-B-tI8QHQ.d.ts.map +1 -0
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.js +1 -2
- package/dist/middleware.js.map +1 -1
- package/dist/prerender.d.ts +22 -2
- package/dist/prerender.d.ts.map +1 -1
- package/dist/prerender.js +4 -4
- package/dist/prerender.js.map +1 -1
- package/dist/protocol.d.ts +0 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +1 -2
- package/dist/serve.d.ts +14 -5
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +3 -5
- package/dist/serve.js.map +1 -1
- package/dist/{server-BV3xKmLa.js → server-DG6jb_NA.js} +162 -57
- package/dist/server-DG6jb_NA.js.map +1 -0
- package/dist/server.d.ts +21 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/dist/{src-ChnB_xug.js → src-odXG7kLA.js} +31 -20
- package/dist/src-odXG7kLA.js.map +1 -0
- package/dist/{static-fn-DgjNArBe.js → static-fn-CXjJi-It.js} +10 -11
- package/dist/{static-fn-DgjNArBe.js.map → static-fn-CXjJi-It.js.map} +1 -1
- package/package.json +11 -11
- package/src/client.ts +27 -1
- package/src/context.ts +33 -0
- package/src/fn-error.ts +25 -1
- package/src/frames-client.ts +5 -1
- package/src/index.ts +32 -6
- package/src/live-server.ts +154 -44
- package/src/server.ts +43 -7
- package/src/wire-types.ts +2 -3
- package/dist/client-BHyIiYxt.js.map +0 -1
- package/dist/client-DHCV7yvQ.d.ts.map +0 -1
- package/dist/env-qA8EyOr1.d.ts.map +0 -1
- package/dist/index-Bm_-MTj6.d.ts.map +0 -1
- package/dist/middleware-BdVlE8qm.d.ts.map +0 -1
- package/dist/server-BV3xKmLa.js.map +0 -1
- package/dist/src-ChnB_xug.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-BHyIiYxt.js","names":[],"sources":["../src/fn-error.ts","../src/stubs.ts","../src/frames.ts","../src/frames-client.ts","../src/start-instance.ts","../src/live-client.ts","../src/client.ts"],"sourcesContent":["/**\n * How a server function's failure reaches its caller in the browser. Its own\n * module, so every module that answers a call can raise it and none of them\n * has to import the stub to do so.\n */\n\n/** What a handler threw, as a development server tells its caller. */\nexport interface ServerFnThrown {\n readonly name: string;\n readonly message: string;\n /** Mapped to the source files by the development server. */\n readonly stack?: string;\n}\n\n/** One thing wrong with a call's input, and the path to the field it is about. */\nexport interface ServerFnIssue {\n readonly message: string;\n readonly path?: readonly (string | number)[];\n}\n\n/** What a failed call's JSON body may carry. */\nexport interface FailedAnswer {\n readonly message?: string;\n readonly issues?: readonly ServerFnIssue[];\n readonly thrown?: ServerFnThrown;\n}\n\n/**\n * A server function answered with a failure.\n *\n * THE MESSAGE IS NOT THE HANDLER'S, and that is deliberate rather than\n * unfinished. `server.ts` refuses to put a handler's error text on the wire\n * because it can name a table, a column or a filesystem path, and none of that\n * is the caller's business — TanStack serialises the whole error object to the\n * client instead. What a caller legitimately needs is the STATUS, so it is here\n * as a field rather than something to parse back out of a string.\n */\nexport class ServerFnError extends Error {\n readonly status: number;\n /**\n * What was wrong with the input, for a 400 the validator refused: one entry\n * per issue, with the path to the field it is about. Sent in every build,\n * because it describes the caller's own input.\n */\n readonly issues?: readonly ServerFnIssue[];\n /**\n * What the handler threw: its name, message and source-mapped stack. Only a\n * development server sends it; in production this is `undefined`, so handle\n * a failure by its `status` rather than by this.\n */\n readonly thrown?: ServerFnThrown;\n /**\n * The answer itself, unread.\n *\n * The server's own refusals land here: a 400 for input, a 403 for an origin,\n * a 404, a 405, a 413. A `Response` a middleware or a handler THREW is not\n * wrapped at all; the call rejects with it. A handler's own failure has\n * nothing here worth reading: the server answers those with one fixed line,\n * for the reason above.\n */\n readonly response?: Response;\n constructor(id: string, status: number, response?: Response, answer?: FailedAnswer) {\n super(failureMessage(id, status, answer));\n this.name = \"ServerFnError\";\n this.status = status;\n this.response = response;\n if (answer?.issues !== undefined) this.issues = answer.issues;\n if (answer?.thrown !== undefined) this.thrown = answer.thrown;\n }\n}\n\nfunction failureMessage(id: string, status: number, answer: FailedAnswer | undefined): string {\n const issues = answer?.issues;\n if (issues !== undefined && issues.length > 0) {\n const listed = issues\n .map((issue) =>\n issue.path === undefined ? issue.message : `\\`${issue.path.join(\".\")}\\`: ${issue.message}`,\n )\n .join(\"; \");\n return (\n `The server function \\`${id}\\` refused its input (${status}): ${listed}. ` +\n \"`error.issues` holds each issue with the path to its field.\"\n );\n }\n const thrown = answer?.thrown;\n if (thrown !== undefined) {\n return (\n `The server function \\`${id}\\` threw \\`${thrown.name}: ${thrown.message}\\` and answered ${status}. ` +\n \"The server's stack is in `error.thrown.stack` and in the development overlay. A production \" +\n \"server sends only the status, so handle a failure by `error.status`.\"\n );\n }\n return (\n `The server function \\`${id}\\` answered ${status}. A handler's own error text is never sent to the browser, so read it in the server's log. ` +\n \"`error.response` holds the server's answer.\"\n );\n}\n","/**\n * The stubs a page has made, and how `live` calls one: a module of its own so\n * the frames client finds a stub by id without importing the stub's module.\n */\n\n/** What the registry holds: a callable stub that knows its id. */\nexport type Stub = ((options?: unknown) => Promise<unknown>) & {\n readonly meta: { readonly id: string };\n};\n\n/** A call at the live address: where the last connection left off, and how to end this one. */\nexport interface LiveRequest {\n readonly lastEventId: string | null;\n readonly signal: AbortSignal;\n}\n\n/** How `live` calls a stub at the live address, its client middleware around the fetch. */\nexport const LIVE_CALL: unique symbol = Symbol.for(\"barq.server-fn.live\");\n\n/**\n * Every stub this page has made, by id: what a frame the page carries asks for\n * its connection through when it was called through `live` on the server.\n */\nconst STUBS = new Map<string, Stub>();\n\nexport function registerStub(id: string, stub: Stub): void {\n STUBS.set(id, stub);\n}\n\nexport function clientStub(id: string): Stub | undefined {\n return STUBS.get(id);\n}\n","/**\n * Frames: a region of server-rendered markup the browser can ask for again and\n * apply in place, Solid 2.0's partial rendering.\n *\n * A frame is what a server function returns when its handler returns a\n * component. The component runs on the server only; what crosses is its\n * markup. The props it is rendered with are SLOTS, positions it marks and the\n * browser fills: `props.children`, and a call such as\n * `props.comment({ cid })`, whose arguments cross as data and whose own\n * children cross as a nested region of server markup.\n *\n * This module is the wire both halves agree on, and nothing else.\n *\n * THE WIRE. A frame is its markup:\n *\n * ```html\n * <barq-frame data-frame=\"<address>\"><script type=\"application/barq-frame\">\n * { \"v\": 1, \"slots\": [...], \"head\": [...] }\n * </script> ...region... <!--s:0--> ...a slot's content... <!--/s:0--> ...</barq-frame>\n * ```\n *\n * The page carries it inline where a route rendered it, and a server-function\n * response carries the same bytes as its body under `x-barq-rpc: frame`. The\n * payload holds what the browser needs to fill the slots and nothing the\n * markup already says, so no piece of content arrives twice.\n */\n\nimport type { Child, Incoming, JSXElement } from \"@barqjs/core\";\nimport type { HeadTag } from \"@barqjs/web\";\n\n/**\n * A slot on a server component's props: a call the browser answers with its\n * own content. What the call is given crosses as data, and its `children` as a\n * region of server markup. `$key` names the occurrence, so its content follows\n * it across updates rather than its position.\n */\nexport type Slot<P extends object = {}> = (\n props: Incoming<P & { readonly $key?: string | number; readonly children?: Child }>,\n) => JSXElement;\n\n/**\n * A slot the server component reads as data: called once per data context,\n * `const like = props.like({ cid })`, and each property placed whole at a\n * position of the server's own markup, an attribute, a class name or style\n * property in object form, a handler, a ref or a text child. The page's fill\n * takes the call's arguments and returns the object those positions read; the\n * server never has its values to compute with.\n */\nexport type BindingSlot<\n A extends object = {},\n B extends object = Record<string, unknown>,\n> = keyof A extends never\n ? (args?: { readonly $key?: string | number }) => Readonly<B>\n : (args: A & { readonly $key?: string | number }) => Readonly<B>;\n\n/** The brand on a frame, on either side, carrying where it lives. */\nexport const FRAME: unique symbol = Symbol.for(\"barq.frame\") as never;\n\n/** How a frame is named across the wire: its server function and its address. */\nexport interface FrameRef {\n readonly id: string;\n readonly address: string;\n}\n\n/** Whether a value is a frame: a server function's component result, on either side. */\nexport function isFrame(value: unknown): boolean {\n return (\n typeof value === \"function\" &&\n (value as unknown as Record<symbol, unknown>)[FRAME] !== undefined\n );\n}\n\n/**\n * How a server function's component result becomes a frame, installed by\n * `@barqjs/start/server`: on the global, because a server bundle and the host\n * serving it each carry a copy of this module, and the copy that defines a\n * server function is not always the one that imported the server half.\n */\nconst MAKE = Symbol.for(\"barq.frames.make\");\n\ntype MakeFrame = (id: string, data: unknown, component: (props: never) => unknown) => unknown;\n\nexport function installFrames(make: MakeFrame): void {\n (globalThis as { [MAKE]?: MakeFrame })[MAKE] = make;\n}\n\n/** The handler's result, a frame when it is a component and the server half is here. */\nexport function asFrame(id: string, data: unknown, result: unknown): unknown {\n const make = (globalThis as { [MAKE]?: MakeFrame })[MAKE];\n if (make === undefined || typeof result !== \"function\" || isFrame(result)) return result;\n return make(id, data, result as (props: never) => unknown);\n}\n\n/** The element a frame's markup stands in. `display: contents`, so it takes no box. */\nexport const FRAME_TAG = \"barq-frame\";\n\n/** The element a nested region of server markup stands in, inside a slot's content. */\nexport const REGION_TAG = \"barq-region\";\n\n/** The `type` of the script that carries a frame's payload. Not JavaScript, so never run. */\nexport const PAYLOAD_TYPE = \"application/barq-frame\";\n\n/** The `x-barq-rpc` value a frame response carries. */\nexport const RPC_FRAME = \"frame\";\n\n/**\n * The `x-barq-rpc` value of a mutation's answer that carries the regions it\n * changed beside its value: single flight, one round trip for both.\n */\nexport const RPC_FLIGHT = \"flight\";\n\n/**\n * The request header a page sends with a mutation: the frames it has mounted,\n * as `[{ id, args }]`, so the answer can carry the ones the mutation changed.\n * Bounded, as a header is: a page with more mounted frames names the first ones.\n */\nexport const FRAMES_HEADER = \"x-barq-frames\";\nexport const FRAMES_BUDGET = 32;\n\n/** The `type` of the script a single-flight answer carries its value in. */\nexport const FLIGHT_TYPE = \"application/barq-flight\";\n\n/** Dispatched on `document` once a frame update has been applied to the page. */\nexport const FRAME_APPLIED_EVENT = \"barq:frame-applied\";\n\n/** The wire format's version: a browser reading a newer one fetches the page whole. */\nexport const FRAME_VERSION = 1;\n\n/**\n * One slot the server component marked: where it stands, by the index in its\n * markers, and what the browser needs to fill it.\n */\nexport interface SlotRecord {\n /** The index in the slot's markers, `<!--s:N-->` and `<!--/s:N-->`. */\n readonly at: number;\n /** The prop the component read: `children`, or the name it called. */\n readonly name: string;\n /**\n * The occurrence's identity across updates: `$key` when the call named one,\n * and its name and position among the calls of that name otherwise.\n */\n readonly key: string;\n /** The call's arguments, wire-encoded, its `children` aside. */\n readonly args?: unknown;\n /**\n * The call's `children`, as server markup: the nested region. Absent when\n * the page already carries it, inside the slot's content.\n */\n readonly region?: string;\n /** Whether the call passed `children` at all. */\n readonly hasRegion?: boolean;\n /**\n * The call was read as data, a binding slot: it has no range, and its\n * properties fill the positions marked with its index.\n */\n readonly bind?: boolean;\n}\n\n/** What a frame's script carries. */\nexport interface FramePayload {\n readonly v: number;\n /**\n * What the call was given, wire-encoded: what the page sends to ask for the\n * region again, live or after a mutation. It is the call's own input, which\n * the page could have sent itself.\n */\n readonly args?: unknown;\n /** Called through `live`: the page connects and keeps the region current. */\n readonly live?: boolean;\n readonly slots: readonly SlotRecord[];\n /** What the region declared for the head, and the assets it needs. */\n readonly head: readonly HeadTag[];\n}\n\nexport function slotOpen(at: number): string {\n return `s:${at}`;\n}\n\nexport function slotClose(at: number): string {\n return `/s:${at}`;\n}\n\n/** The marker index a comment's data names, or `-1` when it is not a slot's opening marker. */\nexport function slotIndex(data: string): number {\n return data.startsWith(\"s:\") ? Number(data.slice(2)) : -1;\n}\n\n/** The marker index a comment's data names, or `-1` when it is not a slot's closing marker. */\nexport function slotEnd(data: string): number {\n return data.startsWith(\"/s:\") ? Number(data.slice(3)) : -1;\n}\n\n/**\n * A string of 32-bit FNV-1a, in base 36: short enough to be an attribute,\n * stable across processes, which a frame's address has to be.\n */\nfunction digest(text: string): string {\n let hash = 0x811c9dc5;\n for (let at = 0; at < text.length; at++) {\n hash ^= text.charCodeAt(at);\n hash = Math.imul(hash, 0x01000193);\n }\n return (hash >>> 0).toString(36);\n}\n\n/**\n * Where a frame lives: the server function and what it was called with. One\n * address is one region, so asking for it again updates that region rather\n * than mounting a second one, and an answer for other arguments is another.\n */\nexport function frameAddress(id: string, wireArgs: unknown): string {\n return `${id}#${digest(JSON.stringify(wireArgs ?? null))}`;\n}\n\n/** The payload as the text of its script: `<` escaped, so no string in it can end the element. */\nexport function payloadText(payload: FramePayload): string {\n return JSON.stringify(payload).replaceAll(\"<\", \"\\\\u003c\");\n}\n\n/** The opening of a frame's markup, the payload's script included. */\nexport function frameOpen(address: string, payload: FramePayload): string {\n const attribute = address\n .replaceAll(\"&\", \"&\")\n .replaceAll('\"', \""\")\n .replaceAll(\"<\", \"<\");\n return (\n `<${FRAME_TAG} data-frame=\"${attribute}\" style=\"display:contents\">` +\n `<script type=\"${PAYLOAD_TYPE}\">${payloadText(payload)}</script>`\n );\n}\n\nexport const FRAME_CLOSE = `</${FRAME_TAG}>`;\n\nexport function regionMarkup(key: string, html: string): string {\n const attribute = key.replaceAll(\"&\", \"&\").replaceAll('\"', \""\").replaceAll(\"<\", \"<\");\n return `<${REGION_TAG} data-region=\"${attribute}\" style=\"display:contents\">${html}</${REGION_TAG}>`;\n}\n\n/**\n * A binding slot's markers, as `@barqjs/server` writes them: an attribute\n * `_b-<position>` on each element it fills, valued `<at>:<key>[=<member>]`\n * entries separated by commas, and a text child between `<!--_b:<at>:<key>-->`\n * and `<!--/_b-->`. The position is the attribute's name, `on-<event>` or\n * `ref`; a member is a class name or style property in object form, or\n * `capture` on a handler.\n */\nexport const BIND_ATTRIBUTE = \"_b-\";\nexport const BIND_EVENT = \"on-\";\nexport const BIND_TEXT = \"_b:\";\nexport const BIND_TEXT_END = \"/_b\";\n\nexport interface BindEntry {\n readonly at: number;\n readonly key: string;\n readonly member?: string;\n}\n\nfunction bindEntry(text: string): BindEntry | null {\n const colon = text.indexOf(\":\");\n if (colon < 1) return null;\n const at = Number(text.slice(0, colon));\n if (!Number.isInteger(at)) return null;\n const equals = text.indexOf(\"=\", colon);\n const key = decodeURIComponent(\n equals === -1 ? text.slice(colon + 1) : text.slice(colon + 1, equals),\n );\n return equals === -1\n ? { at, key }\n : { at, key, member: decodeURIComponent(text.slice(equals + 1)) };\n}\n\n/** The entries of a marker attribute's value. */\nexport function bindEntries(value: string): BindEntry[] {\n const out: BindEntry[] = [];\n for (const text of value.split(\",\")) {\n const entry = bindEntry(text);\n if (entry !== null) out.push(entry);\n }\n return out;\n}\n\n/** The entry a text position's opening comment names, or `null` when it is not one. */\nexport function bindTextEntry(data: string): BindEntry | null {\n return data.startsWith(BIND_TEXT) ? bindEntry(data.slice(BIND_TEXT.length)) : null;\n}\n","/**\n * The browser half of frames: the component a server function's frame answer\n * becomes, and the update that applies a new answer to every place it is\n * mounted without building any of the page again.\n *\n * One component per address. Asking for a frame again hands back the SAME\n * component, so a `dynamic` over it does not remount: the new markup is\n * morphed into the region where it stands. Server nodes are patched in place,\n * and a slot's content, which the browser owns, is kept, its arguments\n * updated, and moved only when the server moved it.\n */\n\nimport {\n type HeadTag,\n bindEvent,\n classToString,\n delegate,\n element,\n insert,\n isHydrating,\n onHydrationEnd,\n ref as bindRef,\n setClass,\n setProp,\n setStyle,\n useHead,\n} from \"@barqjs/web\";\nimport {\n type Owner,\n block,\n createRenderEffect,\n createRoot,\n createSignal,\n getOwner,\n onCleanup,\n runWithOwner,\n untrack,\n} from \"@barqjs/core\";\nimport { withoutClaim } from \"@barqjs/core/internal\";\nimport { type Range, withRange } from \"@barqjs/web/internal\";\nimport { type AnySerializationAdapter, decodeWire } from \"@barqjs/server/codec\";\n\nimport { ServerFnError } from \"./fn-error.ts\";\nimport { LIVE_CALL, type LiveRequest, type Stub, clientStub } from \"./stubs.ts\";\nimport {\n BIND_ATTRIBUTE,\n BIND_EVENT,\n BIND_TEXT_END,\n type BindEntry,\n FRAME,\n FRAME_APPLIED_EVENT,\n FRAME_TAG,\n FLIGHT_TYPE,\n FRAMES_BUDGET,\n FRAME_VERSION,\n type FramePayload,\n type FrameRef,\n PAYLOAD_TYPE,\n REGION_TAG,\n type SlotRecord,\n bindEntries,\n bindTextEntry,\n isFrame,\n slotClose,\n slotEnd,\n slotIndex,\n slotOpen,\n} from \"./frames.ts\";\n\n/** What a frame renders as: a component taking the slots' content as props. */\nexport type FrameComponent = ((props: Record<string, unknown>) => Node) & {\n readonly [FRAME]: FrameRef;\n};\n\n/** One slot's content, owned by the browser. */\ninterface Occurrence {\n readonly key: string;\n readonly name: string;\n readonly start: Comment;\n readonly end: Comment;\n readonly region: Element | null;\n readonly setArgs: (args: Record<string, unknown>) => void;\n readonly dispose: () => void;\n}\n\n/**\n * One binding slot occurrence: the page's fill, run once, and the positions of\n * the server's markup its properties fill, by the node that carries each and\n * the position's spelling.\n */\ninterface Binding {\n readonly name: string;\n readonly owner: Owner | null;\n readonly values: Record<string, unknown> | null;\n readonly setArgs: (args: Record<string, unknown>) => void;\n readonly dispose: () => void;\n readonly positions: Map<Node, Map<string, () => void>>;\n}\n\n/** One place a frame is mounted. */\ninterface Mount {\n readonly host: Element;\n /** The page is being claimed over this mount's server markup, slots included. */\n claiming: boolean;\n readonly owner: Owner | null;\n readonly props: Record<string, unknown>;\n readonly occurrences: Map<Comment, Occurrence>;\n /** The binding slot occurrences, by key. */\n bindings: Map<string, Binding>;\n}\n\ninterface FrameState {\n readonly ref: FrameRef;\n payload: FramePayload | null;\n /** The region's markup as the last answer carried it, for a mount that has none on the page. */\n markup: string | null;\n readonly mounts: Set<Mount>;\n readonly head: () => readonly HeadTag[];\n readonly setHead: (head: readonly HeadTag[]) => void;\n readonly component: FrameComponent;\n /** The live connection the page opened for a frame it was served, while one is open. */\n connection: { readonly stop: () => void } | null;\n}\n\nconst FRAMES = new Map<string, FrameState>();\n\n/**\n * Keep a frame the page was served through `live` current: the connection a\n * `live` call in the browser would have opened, through the same stub and so\n * its client middleware, opened once the page has been claimed and closed\n * when the last place the frame is mounted goes.\n */\nfunction connect(state: FrameState): void {\n if (state.connection !== null || state.payload?.live !== true) return;\n const stub = clientStub(state.ref.id) as Parameters<typeof liveIterable>[0] | undefined;\n if (stub === undefined) return;\n const options = {\n data: state.payload.args === undefined ? undefined : decodeWire(state.payload.args),\n };\n const iterator = liveIterable(stub, options)[Symbol.asyncIterator]();\n const connection = { stop: (): void => void iterator.return?.() };\n state.connection = connection;\n void (async () => {\n try {\n for (;;) if ((await iterator.next()).done === true) return;\n } catch (error) {\n console.error(\n `[barq] The live frame of ${JSON.stringify(state.ref.id)} could not stay connected, so it shows what it last received. The error:`,\n error,\n );\n } finally {\n if (state.connection === connection) state.connection = null;\n }\n })();\n}\n\nfunction stateFor(ref: FrameRef): FrameState {\n const known = FRAMES.get(ref.address);\n if (known !== undefined) return known;\n const [head, setHead] = createSignal<readonly HeadTag[]>([], { ownedWrite: true });\n const state: FrameState = {\n ref,\n payload: null,\n markup: null,\n mounts: new Set(),\n head,\n setHead,\n component: null as never,\n connection: null,\n };\n const component = (props: Record<string, unknown>): Node => mount(state, props);\n (state as { component: FrameComponent }).component = Object.assign(component, { [FRAME]: ref });\n FRAMES.set(ref.address, state);\n return state;\n}\n\n/**\n * How a frame named in the page's seed becomes the component for the region\n * the page already carries. The client entry installs it beside the\n * application's own adapters, before the seed is read.\n */\nexport const frameAdapter: AnySerializationAdapter = {\n key: \"barq.frame\",\n test: isFrame,\n toSerializable: (frame: FrameComponent): FrameRef => ({\n id: frame[FRAME].id,\n address: frame[FRAME].address,\n }),\n fromSerializable: (ref: FrameRef): FrameComponent => stateFor(ref).component,\n};\n\nfunction payloadOf(host: Element): FramePayload | null {\n const script = host.firstElementChild;\n if (script === null || script.localName !== \"script\") return null;\n if (script.getAttribute(\"type\") !== PAYLOAD_TYPE) return null;\n const text = script.textContent ?? \"\";\n return text === \"\" ? null : (JSON.parse(text) as FramePayload);\n}\n\n/** The frame's own script, which the morph leaves to `setPayload`. */\nfunction isPayload(node: Node | null): node is Element {\n return (\n node !== null &&\n node.nodeType === 1 &&\n (node as Element).localName === \"script\" &&\n (node as Element).getAttribute(\"type\") === PAYLOAD_TYPE\n );\n}\n\nfunction setPayload(host: Element, payload: FramePayload): void {\n const script = host.firstElementChild;\n if (script !== null && isPayload(script)) script.textContent = JSON.stringify(payload);\n}\n\nfunction recordAt(payload: FramePayload, at: number): SlotRecord | undefined {\n return payload.slots.find((record) => record.at === at);\n}\n\n/** The comment that closes the slot `start` opens, among its siblings. */\nfunction closeOf(start: Comment): Comment | null {\n const at = slotIndex(start.data);\n for (let node = start.nextSibling; node !== null; node = node.nextSibling) {\n if (node.nodeType === 8 && slotEnd((node as Comment).data) === at) return node as Comment;\n }\n return null;\n}\n\nfunction between(start: Node, end: Node): Node[] {\n const out: Node[] = [];\n for (let node = start.nextSibling; node !== null && node !== end; node = node.nextSibling) {\n out.push(node);\n }\n return out;\n}\n\n/** Every slot opening in `root` that no occurrence owns yet, in document order. */\nfunction unfilled(root: Element, owned: Map<Comment, Occurrence>): Comment | null {\n const walker = root.ownerDocument.createTreeWalker(root, NodeFilter.SHOW_COMMENT);\n for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {\n const comment = node as Comment;\n if (slotIndex(comment.data) !== -1 && !owned.has(comment)) return comment;\n }\n return null;\n}\n\nfunction regionElement(key: string, markup: string): Element {\n const region = document.createElement(REGION_TAG);\n region.setAttribute(\"data-region\", key);\n region.setAttribute(\"style\", \"display:contents\");\n region.innerHTML = markup;\n return region;\n}\n\n/**\n * Fill one slot: the page's `children` where the server placed them, or the\n * page's function for a named slot called with the occurrence's arguments.\n *\n * While the page is being claimed, the server's content for the slot is\n * CLAIMED: the fill runs over a cursor on the slot's range, as the content of\n * any other hole does, and takes the nodes the server wrote for it. Otherwise\n * the slot is empty and the fill builds into it. A nested region the server\n * wrote is handed to the fill as its children either way.\n */\nfunction fill(site: Mount, start: Comment, record: SlotRecord): Occurrence | null {\n const end = closeOf(start);\n if (end === null) return null;\n const parent = end.parentNode;\n if (parent === null) return null;\n const served = between(start, end);\n const claiming = site.claiming && served.length > 0;\n let region: Element | null = null;\n if (record.hasRegion === true) {\n for (const node of served) {\n const found =\n node.nodeType === 1 && (node as Element).localName === REGION_TAG\n ? (node as Element)\n : node.nodeType === 1\n ? (node as Element).querySelector(REGION_TAG)\n : null;\n if (found !== null) {\n region = found;\n break;\n }\n }\n if (!claiming) region?.remove();\n region ??= regionElement(String(record.at), record.region ?? \"\");\n }\n if (!claiming) for (const node of served) node.parentNode?.removeChild(node);\n const [args, setArgs] = createSignal<Record<string, unknown>>(\n record.args === undefined ? {} : decodeWire(record.args),\n { ownedWrite: true },\n );\n const given = site.props[record.name];\n const content = (): unknown => {\n if (record.name === \"children\") return given;\n // A fill that takes nothing reaches the props as the Cell it is, so reading\n // the prop is calling it.\n const fn = typeof given === \"function\" ? untrack(given as () => unknown) : given;\n if (typeof fn !== \"function\") return fn ?? null;\n const props: Record<string, unknown> = {};\n for (const key of Object.keys(untrack(args))) props[key] = (): unknown => args()[key];\n if (region !== null) {\n const placed = region;\n props.children = block(() => placed);\n }\n return untrack(() => (fn as (props: Record<string, unknown>) => unknown)(props));\n };\n const range: Range = { open: start, close: end, parent, nodes: served };\n const dispose = claiming\n ? runWithOwner(site.owner, () =>\n createRoot((release) => {\n withRange(range, () => {\n const value = content();\n // A Block is called with the scope it builds under, as `insert` calls one.\n return typeof value === \"function\"\n ? (value as (scope: unknown) => unknown)(getOwner())\n : value;\n });\n return release;\n }),\n )\n : withoutClaim(() =>\n runWithOwner(site.owner, () =>\n createRoot((release) => {\n insert(parent, content() as never, end);\n return release;\n }),\n ),\n );\n return { key: record.key, name: record.name, start, end, region, setArgs, dispose };\n}\n\n/** Fill every slot in the mount that has no content yet, outermost first. */\nfunction fillAll(site: Mount, payload: FramePayload): void {\n for (;;) {\n const start = unfilled(site.host, site.occurrences);\n if (start === null) return;\n const record = recordAt(payload, slotIndex(start.data));\n const occurrence = record === undefined ? null : fill(site, start, record);\n // A marker with no record, or no close, is left as it is rather than filled.\n site.occurrences.set(start, occurrence ?? DEAD);\n }\n}\n\nconst DEAD: Occurrence = {\n key: \"\",\n name: \"\",\n start: null as never,\n end: null as never,\n region: null,\n setArgs: () => {},\n dispose: () => {},\n};\n\nfunction mount(state: FrameState, props: Record<string, unknown>): Node {\n const owner = getOwner();\n // The server's element when the page is being claimed: its region stays\n // exactly as it is, and only the slots are filled.\n const host = element(FRAME_TAG, {});\n const adopted = host.getAttribute(\"data-frame\") === state.ref.address && payloadOf(host) !== null;\n if (!adopted) {\n withoutClaim(() => {\n host.setAttribute(\"data-frame\", state.ref.address);\n host.setAttribute(\"style\", \"display:contents\");\n host.innerHTML = `<script type=\"${PAYLOAD_TYPE}\"></script>${state.markup ?? markupOnPage(state) ?? \"\"}`;\n if (state.payload !== null) setPayload(host, state.payload);\n });\n }\n state.payload ??= payloadOf(host);\n const payload = state.payload ?? { v: FRAME_VERSION, slots: [], head: [] };\n if (untrack(state.head).length === 0 && payload.head.length > 0) state.setHead(payload.head);\n const placed: Mount = {\n host,\n owner,\n props,\n occurrences: new Map(),\n bindings: new Map(),\n claiming: adopted && isHydrating(),\n };\n fillAll(placed, payload);\n bindAll(placed, payload);\n placed.claiming = false;\n state.mounts.add(placed);\n useHead(() => state.head());\n if (adopted) onHydrationEnd(() => connect(state));\n onCleanup(() => {\n state.mounts.delete(placed);\n for (const occurrence of placed.occurrences.values()) occurrence.dispose();\n for (const binding of placed.bindings.values()) binding.dispose();\n if (state.mounts.size === 0) state.connection?.stop();\n });\n return host;\n}\n\n/**\n * A frame the page carries but this mount was not claimed over: one that\n * rendered on the server and is mounted again after the page started, from a\n * seed that named it. Its markup is taken from the page.\n */\nfunction markupOnPage(state: FrameState): string | null {\n for (const candidate of document.querySelectorAll(FRAME_TAG)) {\n if (candidate.getAttribute(\"data-frame\") !== state.ref.address) continue;\n state.payload ??= payloadOf(candidate);\n const copy = candidate.cloneNode(true) as Element;\n copy.firstElementChild?.remove();\n for (const comment of commentsIn(copy)) {\n const at = slotIndex(comment.data);\n if (at === -1) continue;\n const end = closeOf(comment);\n if (end !== null)\n for (const node of between(comment, end)) node.parentNode?.removeChild(node);\n }\n return copy.innerHTML;\n }\n return null;\n}\n\n/** Every comment in `root`, collected before the caller changes the tree around them. */\nfunction commentsIn(root: Node): Comment[] {\n const walker = (root.ownerDocument ?? document).createTreeWalker(root, NodeFilter.SHOW_COMMENT);\n const out: Comment[] = [];\n for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {\n out.push(node as Comment);\n }\n return out;\n}\n\n// ── binding slots ─────────────────────────────────────────────────────────\n\n/** The page's fill for a binding slot, run once: the object whose properties fill its positions. */\nfunction bindOccurrence(site: Mount, record: SlotRecord): Binding {\n const [args, setArgs] = createSignal<Record<string, unknown>>(\n record.args === undefined ? {} : decodeWire(record.args),\n { ownedWrite: true },\n );\n const given = site.props[record.name];\n return runWithOwner(site.owner, () =>\n createRoot((dispose): Binding => {\n const props: Record<string, unknown> = {};\n for (const key of Object.keys(untrack(args))) props[key] = (): unknown => args()[key];\n // A fill that takes nothing reaches the props as the Cell it is, so\n // reading the prop is calling it.\n const result = withoutClaim(() =>\n untrack(() => {\n const fn = typeof given === \"function\" ? (given as () => unknown)() : given;\n return typeof fn === \"function\"\n ? (fn as (props: Record<string, unknown>) => unknown)(props)\n : fn;\n }),\n );\n let values: Record<string, unknown> | null = null;\n if (\n typeof result === \"object\" &&\n result !== null &&\n !Array.isArray(result) &&\n !(result instanceof Node)\n ) {\n values = result as Record<string, unknown>;\n } else if (given !== undefined) {\n console.error(\n `[barq] The page's \\`${record.name}\\` fill returned ${result === null ? \"null\" : Array.isArray(result) ? \"an array\" : typeof result} where the server component reads it as data. ` +\n \"A binding slot's fill returns a plain object whose properties fill the positions the server marked, so the server's values stay in place.\",\n );\n }\n const binding: Binding = {\n name: record.name,\n owner: getOwner(),\n values,\n setArgs,\n positions: new Map(),\n dispose: () => {\n for (const at of binding.positions.values()) for (const release of at.values()) release();\n binding.positions.clear();\n dispose();\n },\n };\n return binding;\n }),\n );\n}\n\ninterface Found {\n readonly node: Node;\n readonly position: string;\n readonly entry: BindEntry;\n}\n\n/** Every position marked in `root`, a nested frame's aside, in document order. */\nfunction positionsIn(root: Element): Found[] {\n const out: Found[] = [];\n const walker = root.ownerDocument.createTreeWalker(\n root,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT,\n {\n acceptNode: (node) =>\n node !== root && node.nodeType === 1 && (node as Element).localName === FRAME_TAG\n ? NodeFilter.FILTER_REJECT\n : NodeFilter.FILTER_ACCEPT,\n },\n );\n for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {\n if (node.nodeType === 8) {\n const entry = bindTextEntry((node as Comment).data);\n if (entry !== null) out.push({ node, position: \"\", entry });\n continue;\n }\n const element = node as Element;\n for (const name of element.getAttributeNames()) {\n if (!name.startsWith(BIND_ATTRIBUTE)) continue;\n const position = name.slice(BIND_ATTRIBUTE.length);\n for (const entry of bindEntries(element.getAttribute(name) ?? \"\")) {\n out.push({ node, position, entry });\n }\n }\n }\n return out;\n}\n\n/**\n * Bring the binding slot occurrences up to date with a payload: a new one's\n * fill runs, a kept one's arguments move and its fill is not run again, and\n * each position in the markup is bound once, a position the morph replaced or\n * dropped released.\n */\nfunction bindAll(site: Mount, payload: FramePayload): void {\n const byAt = new Map<number, Binding>();\n const next = new Map<string, Binding>();\n for (const record of payload.slots) {\n if (record.bind !== true) continue;\n let binding = site.bindings.get(record.key);\n if (binding !== undefined && binding.name === record.name) {\n if (record.args !== undefined) binding.setArgs(decodeWire(record.args));\n } else {\n binding = bindOccurrence(site, record);\n }\n next.set(record.key, binding);\n byAt.set(record.at, binding);\n }\n for (const [key, binding] of site.bindings) if (next.get(key) !== binding) binding.dispose();\n site.bindings = next;\n if (next.size === 0) return;\n\n const seen = new Map<Binding, Map<Node, Set<string>>>();\n for (const found of positionsIn(site.host)) {\n const binding = byAt.get(found.entry.at);\n if (binding === undefined || binding.values === null) continue;\n const id = `${found.position}|${found.entry.key}|${found.entry.member ?? \"\"}`;\n let nodes = seen.get(binding);\n if (nodes === undefined) seen.set(binding, (nodes = new Map<Node, Set<string>>()));\n let ids = nodes.get(found.node);\n if (ids === undefined) nodes.set(found.node, (ids = new Set()));\n ids.add(id);\n let at = binding.positions.get(found.node);\n if (at === undefined) binding.positions.set(found.node, (at = new Map<string, () => void>()));\n if (at.has(id)) continue;\n const claiming = site.claiming;\n const values = binding.values;\n at.set(\n id,\n runWithOwner(binding.owner, () =>\n createRoot((release) => {\n bindPosition(found, values, claiming);\n return release;\n }),\n ),\n );\n }\n for (const binding of next.values()) {\n const nodes = seen.get(binding);\n for (const [node, at] of binding.positions) {\n const ids = nodes?.get(node);\n for (const [id, release] of at) {\n if (ids?.has(id) === true) continue;\n release();\n at.delete(id);\n }\n if (at.size === 0) binding.positions.delete(node);\n }\n }\n}\n\nfunction textOf(value: unknown): string {\n return typeof value === \"string\"\n ? value\n : typeof value === \"number\" || typeof value === \"bigint\"\n ? String(value)\n : \"\";\n}\n\n/**\n * A detached element for the style a claimed position already shows: what\n * `setStyle` would have applied, without writing to the page's element.\n */\nlet scratch: HTMLElement | null = null;\n\n/**\n * Fill one position from the fill's object. A value position follows the\n * property, a handler and a ref are read once, as the page's own JSX reads\n * them. While the page is claimed the server already wrote each value, so the\n * first run writes nothing.\n */\nfunction bindPosition(found: Found, values: Record<string, unknown>, claiming: boolean): void {\n const { node, position, entry } = found;\n const read = (): unknown => values[entry.key];\n if (position === \"\") {\n const start = node as Comment;\n let text: Text;\n if (start.nextSibling !== null && start.nextSibling.nodeType === 3) {\n text = start.nextSibling as Text;\n } else {\n text = document.createTextNode(\"\");\n start.parentNode?.insertBefore(text, start.nextSibling);\n }\n createRenderEffect(\n () => textOf(read()),\n (value) => {\n if (text.data !== value) text.data = value;\n },\n );\n return;\n }\n const element = node as Element;\n if (position === \"ref\") {\n bindRef(element, untrack(read));\n return;\n }\n if (position.startsWith(BIND_EVENT)) {\n const type = position.slice(BIND_EVENT.length);\n const capture = entry.member === \"capture\";\n bindEvent(element, type, untrack(read), capture);\n // A delegated handler is the element's own expando, which nothing else\n // takes back when the position is released.\n if (!capture) onCleanup(() => delegate(element, type, undefined));\n return;\n }\n if (position === \"class\" && entry.member !== undefined) {\n const name = entry.member;\n createRenderEffect(\n () => Boolean(read()),\n (on) => {\n if (element.classList.contains(name) !== on) element.classList.toggle(name, on);\n },\n );\n return;\n }\n // What the channel last applied, which `setStyle` and `setClass` diff against.\n let applied: unknown;\n let first = claiming;\n if (position === \"style\") {\n const member = entry.member;\n createRenderEffect(\n () => (member === undefined ? read() : { [member]: read() }),\n (value) => {\n if (first) {\n first = false;\n scratch ??= document.createElement(\"div\");\n scratch.removeAttribute(\"style\");\n applied = setStyle(scratch, \"style\", value);\n return;\n }\n applied = setStyle(element, \"style\", value, applied);\n },\n );\n return;\n }\n if (position === \"class\") {\n createRenderEffect(read, (value) => {\n if (first) {\n first = false;\n applied = classToString(value);\n return;\n }\n applied = setClass(element, \"class\", value, applied);\n });\n return;\n }\n createRenderEffect(read, (value) => {\n if (first) {\n first = false;\n return;\n }\n setProp(element, position, value);\n });\n}\n\n// ── the morph ─────────────────────────────────────────────────────────────\n\ninterface MorphContext {\n readonly mount: Mount;\n readonly payload: FramePayload;\n /** The occurrences still to place, by key. */\n readonly keep: Map<string, Occurrence>;\n readonly used: Set<Occurrence>;\n}\n\nfunction sameNode(current: Node, next: Node): boolean {\n if (current.nodeType !== next.nodeType) return false;\n if (current.nodeType !== 1) return true;\n const a = current as Element;\n const b = next as Element;\n return a.localName === b.localName && a.getAttribute(\"id\") === b.getAttribute(\"id\");\n}\n\n/**\n * The positions of an element a binding slot fills, by its markers: whole\n * attributes, and the class names and style properties it fills in object form.\n */\nfunction ownedBy(element: Element): {\n whole: Set<string>;\n classes: Set<string>;\n styles: Set<string>;\n} {\n const owned = { whole: new Set<string>(), classes: new Set<string>(), styles: new Set<string>() };\n for (const name of element.getAttributeNames()) {\n if (!name.startsWith(BIND_ATTRIBUTE)) continue;\n const position = name.slice(BIND_ATTRIBUTE.length);\n if (position === \"ref\" || position.startsWith(BIND_EVENT)) continue;\n for (const entry of bindEntries(element.getAttribute(name) ?? \"\")) {\n if (entry.member === undefined) owned.whole.add(position);\n else if (position === \"class\") owned.classes.add(entry.member);\n else if (position === \"style\") owned.styles.add(entry.member);\n }\n }\n return owned;\n}\n\n/**\n * The server's attributes, written over the element's, except where the page\n * fills a position: a whole attribute it fills is left as it stands, and the\n * class names and style properties it fills keep their current state inside\n * the server's new class and style.\n */\nfunction patchAttributes(current: Element, next: Element): void {\n const owned = ownedBy(next);\n const classes = owned.classes.size > 0;\n const styles = owned.styles.size > 0;\n for (const name of current.getAttributeNames()) {\n if (owned.whole.has(name) || (name === \"class\" && classes) || (name === \"style\" && styles)) {\n continue;\n }\n if (!next.hasAttribute(name)) current.removeAttribute(name);\n }\n for (const name of next.getAttributeNames()) {\n if (owned.whole.has(name) || (name === \"class\" && classes) || (name === \"style\" && styles)) {\n continue;\n }\n const value = next.getAttribute(name) ?? \"\";\n if (current.getAttribute(name) !== value) current.setAttribute(name, value);\n }\n if (classes) {\n const tokens = new Set((next.getAttribute(\"class\") ?? \"\").split(/\\s+/).filter(Boolean));\n for (const name of owned.classes) {\n if (current.classList.contains(name)) tokens.add(name);\n else tokens.delete(name);\n }\n const value = [...tokens].join(\" \");\n if ((current.getAttribute(\"class\") ?? \"\") !== value) current.setAttribute(\"class\", value);\n }\n if (styles) {\n const style = (current as HTMLElement).style;\n const kept = new Map<string, string>();\n for (const property of owned.styles) {\n const css = cssProperty(property);\n kept.set(css, style.getPropertyValue(css));\n }\n const value = next.getAttribute(\"style\");\n if (current.getAttribute(\"style\") !== value) {\n if (value === null) current.removeAttribute(\"style\");\n else current.setAttribute(\"style\", value);\n for (const [css, text] of kept) {\n if (text === \"\") style.removeProperty(css);\n else style.setProperty(css, text);\n }\n }\n }\n}\n\n/** A style object's key as the declaration's name, as `setStyle` writes it. */\nfunction cssProperty(property: string): string {\n return property.startsWith(\"--\")\n ? property\n : property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\nfunction isTextEnd(node: Node | null): boolean {\n return node !== null && node.nodeType === 8 && (node as Comment).data === BIND_TEXT_END;\n}\n\nfunction occurrenceAt(context: MorphContext, node: Node | null): Occurrence | null {\n if (node === null || node.nodeType !== 8) return null;\n const found = context.mount.occurrences.get(node as Comment);\n return found === undefined || found === DEAD ? null : found;\n}\n\n/** Move an occurrence's whole range, markers and content, to stand before `before`. */\nfunction place(occurrence: Occurrence, parent: Node, before: Node | null): void {\n const nodes = [occurrence.start, ...between(occurrence.start, occurrence.end), occurrence.end];\n for (const node of nodes) parent.insertBefore(node, before);\n}\n\nfunction morphChildren(current: Node, next: Node, context: MorphContext): void {\n let cursor: Node | null = current.firstChild;\n if (isPayload(cursor)) cursor = cursor.nextSibling;\n const incoming = [...next.childNodes];\n for (let at = 0; at < incoming.length; at++) {\n const node = incoming[at];\n // An occurrence standing here that the server no longer puts here is\n // stepped over: it is moved to where it now belongs, or removed after.\n for (let standing = occurrenceAt(context, cursor); standing !== null;) {\n cursor = standing.end.nextSibling;\n standing = occurrenceAt(context, cursor);\n }\n const opening = node.nodeType === 8 ? slotIndex((node as Comment).data) : -1;\n if (opening !== -1) {\n let close = at + 1;\n while (close < incoming.length) {\n const candidate = incoming[close];\n if (candidate.nodeType === 8 && slotEnd((candidate as Comment).data) === opening) break;\n close++;\n }\n at = close;\n const record = recordAt(context.payload, opening);\n const kept = record === undefined ? undefined : context.keep.get(record.key);\n if (kept !== undefined && kept.name === record!.name) {\n context.keep.delete(kept.key);\n context.used.add(kept);\n if (kept.start.nextSibling !== cursor || kept.start.parentNode !== current) {\n place(kept, current, cursor);\n }\n kept.start.data = slotOpen(opening);\n kept.end.data = slotClose(opening);\n continue;\n }\n current.insertBefore(document.createComment(slotOpen(opening)), cursor);\n current.insertBefore(document.createComment(slotClose(opening)), cursor);\n continue;\n }\n // A text position the page fills keeps the page's text: the server's\n // pair has nothing between, and the morph steps over both.\n if (\n node.nodeType === 8 &&\n bindTextEntry((node as Comment).data) !== null &&\n cursor !== null &&\n cursor.nodeType === 8 &&\n (cursor as Comment).data === (node as Comment).data\n ) {\n while (at + 1 < incoming.length && !isTextEnd(incoming[at])) at++;\n let end: Node | null = cursor.nextSibling;\n while (end !== null && !isTextEnd(end)) end = end.nextSibling;\n cursor = end === null ? null : end.nextSibling;\n continue;\n }\n if (cursor !== null && sameNode(cursor, node)) {\n if (cursor.nodeType === 1) {\n patchAttributes(cursor as Element, node as Element);\n morphChildren(cursor, node, context);\n } else if (cursor.nodeValue !== node.nodeValue) {\n cursor.nodeValue = node.nodeValue;\n }\n cursor = cursor.nextSibling;\n continue;\n }\n current.insertBefore(document.importNode(node, true), cursor);\n }\n // What is left is what the server no longer sends. An occurrence among it is\n // kept in the tree for now: it may still be placed elsewhere.\n while (cursor !== null) {\n const standing = occurrenceAt(context, cursor);\n if (standing !== null) {\n cursor = standing.end.nextSibling;\n continue;\n }\n const gone = cursor;\n cursor = cursor.nextSibling;\n current.removeChild(gone);\n }\n}\n\n/** Apply a new answer to one mount: morph the region, then bring the occurrences up to date. */\nfunction update(site: Mount, payload: FramePayload, markup: string): void {\n const next = document.createElement(\"template\");\n next.innerHTML = markup;\n const keep = new Map<string, Occurrence>();\n for (const occurrence of site.occurrences.values()) {\n if (occurrence !== DEAD) keep.set(occurrence.key, occurrence);\n }\n const context: MorphContext = { mount: site, payload, keep, used: new Set() };\n withoutClaim(() => {\n morphChildren(site.host, next.content, context);\n setPayload(site.host, payload);\n });\n const occurrences = new Map<Comment, Occurrence>();\n for (const occurrence of context.used) {\n occurrences.set(occurrence.start, occurrence);\n const record = recordAt(payload, slotIndex(occurrence.start.data));\n if (record === undefined) continue;\n if (record.args !== undefined) occurrence.setArgs(decodeWire(record.args));\n if (occurrence.region !== null && record.region !== undefined) {\n const region = document.createElement(\"template\");\n region.innerHTML = record.region;\n withoutClaim(() => morphChildren(occurrence.region!, region.content, context));\n for (const nested of context.used) occurrences.set(nested.start, nested);\n }\n }\n for (const occurrence of site.occurrences.values()) {\n if (occurrence === DEAD || context.used.has(occurrence)) continue;\n occurrence.dispose();\n for (const node of [\n occurrence.start,\n ...between(occurrence.start, occurrence.end),\n occurrence.end,\n ]) {\n node.parentNode?.removeChild(node);\n }\n }\n site.occurrences.clear();\n for (const [start, occurrence] of occurrences) site.occurrences.set(start, occurrence);\n fillAll(site, payload);\n bindAll(site, payload);\n}\n\n// ── assets ────────────────────────────────────────────────────────────────\n\n/**\n * The region's stylesheets, loaded before it is shown: a region revealed\n * before its styles is the flash a server render exists to prevent. Each is\n * the element `useHead` takes over when the frame mounts.\n */\nasync function loadStylesheets(head: readonly HeadTag[]): Promise<void> {\n const loading: Promise<void>[] = [];\n for (const tag of head) {\n const props = tag.props ?? {};\n if (tag.tag !== \"link\" || props.rel !== \"stylesheet\" || typeof props.href !== \"string\")\n continue;\n const key = `link:stylesheet:${props.href}`;\n let present = false;\n for (const candidate of document.head.querySelectorAll(\"[data-bh]\")) {\n if (candidate.getAttribute(\"data-bh\") === key) present = true;\n }\n if (present) continue;\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = props.href;\n link.setAttribute(\"data-bh\", key);\n loading.push(\n new Promise<void>((resolve) => {\n link.addEventListener(\"load\", () => resolve(), { once: true });\n link.addEventListener(\"error\", () => resolve(), { once: true });\n }),\n );\n document.head.appendChild(link);\n }\n await Promise.all(loading);\n}\n\n// ── the wire ──────────────────────────────────────────────────────────────\n\n/**\n * Read a frame answer and apply it: the component for its address, the same\n * one every time, with every place it is mounted morphed to the new markup\n * once the region's stylesheets have loaded.\n */\nexport async function applyFrameResponse(response: Response): Promise<FrameComponent> {\n const template = document.createElement(\"template\");\n template.innerHTML = await response.text();\n return applyFrameMarkup(template.content.firstElementChild);\n}\n\n/** A frame's markup as text, a live event's, applied as a frame answer is. */\nexport function applyFrameText(markup: string): Promise<FrameComponent> {\n const template = document.createElement(\"template\");\n template.innerHTML = markup;\n return applyFrameMarkup(template.content.firstElementChild);\n}\n\n/** One frame's markup, applied to every place its address is mounted. */\nasync function applyFrameMarkup(host: Element | null): Promise<FrameComponent> {\n const address = host?.getAttribute(\"data-frame\") ?? null;\n const payload = host === null ? null : payloadOf(host);\n if (host === null || address === null || payload === null) {\n throw new Error(\n \"[barq] A server function answered with a frame whose markup has no `barq-frame` element and payload, so there is nothing to apply. \" +\n \"The server and this page were built from different versions: reload the page.\",\n );\n }\n if (payload.v !== FRAME_VERSION) {\n throw new Error(\n `[barq] A server function answered with frame version ${payload.v}, and this page reads version ${FRAME_VERSION}. ` +\n \"The server was deployed after this page loaded: reload the page.\",\n );\n }\n host.firstElementChild?.remove();\n const markup = host.innerHTML;\n const id = address.slice(0, address.lastIndexOf(\"#\"));\n const state = stateFor({ id, address });\n await loadStylesheets(payload.head);\n state.payload = payload;\n state.markup = markup;\n state.setHead(payload.head);\n for (const placed of state.mounts) update(placed, payload, markup);\n document.dispatchEvent(new CustomEvent(FRAME_APPLIED_EVENT, { detail: { address } }));\n return state.component;\n}\n\n/**\n * What a mutation sends so its answer can carry the regions it changed: every\n * mounted frame's function and arguments, up to the budget, or `null` with\n * none mounted.\n */\nexport function mountedFramesHeader(): string | null {\n const out: { id: string; args: unknown }[] = [];\n for (const state of FRAMES.values()) {\n if (state.mounts.size === 0 || state.payload === null) continue;\n out.push({ id: state.ref.id, args: state.payload.args });\n if (out.length === FRAMES_BUDGET) break;\n }\n return out.length === 0 ? null : JSON.stringify(out);\n}\n\n/**\n * A mutation's single-flight answer: each region it carries applied where it\n * is mounted, then the value, which is what the caller is handed.\n */\nexport async function applyFlight(response: Response): Promise<unknown> {\n const template = document.createElement(\"template\");\n template.innerHTML = await response.text();\n const script = template.content.firstElementChild;\n if (\n script === null ||\n script.localName !== \"script\" ||\n script.getAttribute(\"type\") !== FLIGHT_TYPE\n ) {\n throw new Error(\n \"[barq] A server function answered with a single flight whose value script is missing, so there is no value to hand the caller. \" +\n \"The server and this page were built from different versions: reload the page.\",\n );\n }\n const value = decodeWire(JSON.parse(script.textContent ?? \"null\"));\n for (const host of template.content.children) {\n if (host.localName === FRAME_TAG) await applyFrameMarkup(host);\n }\n return value;\n}\n\n/** Forget every frame, for a test that renders more than one page. */\nexport function resetFrames(): void {\n FRAMES.clear();\n}\n\n// ── live ──────────────────────────────────────────────────────────────────\n//\n// `live`'s loop, here because a frame the page was served through `live`\n// connects through it as well as a `live` call does.\n\n/** What the loop says about its connection. */\nexport type LiveStatus = \"connected\" | \"reconnecting\" | \"closed\";\n\nexport interface LiveIterable<T> extends AsyncIterable<T> {\n /** Told `\"connected\"` per connection, `\"reconnecting\"` with the error per death, `\"closed\"` at the end. */\n onstatus?: (status: LiveStatus, error?: unknown) => void;\n}\n\ninterface ServerEvent {\n readonly event: string;\n readonly id: string | null;\n readonly data: string;\n}\n\n/** The events of a `text/event-stream` body, as the spec frames them. */\nasync function* eventsOf(body: ReadableStream<Uint8Array>): AsyncGenerator<ServerEvent> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let pending = \"\";\n let event = \"message\";\n let id: string | null = null;\n let data: string[] = [];\n try {\n for (;;) {\n const { done, value } = await reader.read();\n pending += done ? decoder.decode() : decoder.decode(value, { stream: true });\n let end = pending.search(/\\r\\n|\\r|\\n/);\n while (end !== -1) {\n const line = pending.slice(0, end);\n pending = pending.slice(end + (pending.startsWith(\"\\r\\n\", end) ? 2 : 1));\n if (line === \"\") {\n if (data.length > 0 || event !== \"message\") yield { event, id, data: data.join(\"\\n\") };\n event = \"message\";\n data = [];\n } else if (!line.startsWith(\":\")) {\n const colon = line.indexOf(\":\");\n const field = colon === -1 ? line : line.slice(0, colon);\n const text = colon === -1 ? \"\" : line.slice(colon + 1).replace(/^ /, \"\");\n if (field === \"data\") data.push(text);\n else if (field === \"event\") event = text;\n else if (field === \"id\") id = text;\n }\n end = pending.search(/\\r\\n|\\r|\\n/);\n }\n if (done) return;\n }\n } finally {\n void reader.cancel().catch(() => {});\n }\n}\n\n/** Statuses that say \"ask again\" even though they refuse this time. */\nconst RETRY = new Set([408, 425, 429]);\n\n/** How long to wait before the next connection, the nth failure in a row. */\nfunction pause(failures: number, signal: AbortSignal): Promise<void> {\n const ms = Math.min(30_000, 250 * 2 ** failures);\n return new Promise<void>((resolve) => {\n const timer = setTimeout(done, ms);\n function done(): void {\n clearTimeout(timer);\n globalThis.removeEventListener?.(\"online\", done);\n signal.removeEventListener(\"abort\", done);\n resolve();\n }\n globalThis.addEventListener?.(\"online\", done, { once: true });\n signal.addEventListener(\"abort\", done, { once: true });\n });\n}\n\nexport type LiveStub = Stub & {\n readonly [LIVE_CALL]: (options: unknown, live: LiveRequest) => Promise<Response>;\n};\n\n/** The reconnecting iteration of one live call. */\nexport function liveIterable(stub: LiveStub, options: unknown): LiveIterable<unknown> {\n const iterable: LiveIterable<unknown> = {\n [Symbol.asyncIterator]: (): AsyncIterator<unknown> => {\n const controller = new AbortController();\n const running = loop(stub, options, iterable, controller);\n return {\n next: () => running.next(),\n // The connection is ended here, not when the generator gets round to\n // it: one waiting on a body that sends nothing would never get there.\n return: (value?: unknown) => {\n controller.abort();\n return running.return(value);\n },\n };\n },\n };\n return iterable;\n}\n\nasync function* loop(\n stub: LiveStub,\n options: unknown,\n told: LiveIterable<unknown>,\n controller: AbortController,\n): AsyncGenerator {\n let lastEventId: string | null = null;\n let failures = 0;\n let connected = false;\n try {\n for (;;) {\n let response: Response;\n try {\n response = await stub[LIVE_CALL](options, { lastEventId, signal: controller.signal });\n } catch (error) {\n if (controller.signal.aborted) return;\n if (!connected) throw error;\n told.onstatus?.(\"reconnecting\", error);\n await pause(failures++, controller.signal);\n continue;\n }\n if (!response.ok || response.body === null) {\n const retries = RETRY.has(response.status) || response.headers.has(\"retry-after\");\n const error = new ServerFnError(stub.meta.id, response.status, response);\n if (!connected || (!retries && response.status >= 400 && response.status < 500))\n throw error;\n told.onstatus?.(\"reconnecting\", error);\n await pause(failures++, controller.signal);\n continue;\n }\n connected = true;\n failures = 0;\n told.onstatus?.(\"connected\");\n let yielded: unknown = undefined;\n let complete = false;\n let died: unknown = new Error(\n `[barq] The live connection of ${JSON.stringify(stub.meta.id)} ended before it was complete.`,\n );\n try {\n for await (const event of eventsOf(response.body)) {\n if (event.event === \"complete\") {\n complete = true;\n break;\n }\n if (event.id !== null) lastEventId = event.id;\n const data = JSON.parse(event.data) as unknown;\n if (event.event === \"frame\") {\n const component = await applyFrameText(data as string);\n if (component !== yielded) {\n yielded = component;\n yield component;\n }\n continue;\n }\n yield decodeWire(data);\n }\n } catch (error) {\n died = error;\n }\n if (complete || controller.signal.aborted) return;\n told.onstatus?.(\"reconnecting\", died);\n await pause(failures++, controller.signal);\n }\n } finally {\n controller.abort();\n told.onstatus?.(\"closed\");\n }\n}\n","/**\n * The application-wide middleware, declared once.\n *\n * TanStack Start's `createStart`, written in a project's `src/start.ts`:\n *\n * ```ts\n * export const startInstance = createStart(() => ({\n * requestMiddleware: [logging],\n * functionMiddleware: [requireSession],\n * }));\n * ```\n *\n * Its own module, importing nothing that reaches `node:async_hooks`, because\n * the client stub reads it: a global function middleware's client half runs in\n * the browser around every call.\n */\n\nimport { type AnySerializationAdapter, registerSerializationAdapters } from \"@barqjs/server/codec\";\n\nimport type { ChainContribution, Empty, Middleware } from \"./middleware.ts\";\n\nexport interface StartOptions {\n /** Runs for every request the server answers: a page, a route handler, a server function. */\n readonly requestMiddleware?: readonly Middleware[];\n /** Runs for every server function, ahead of the function's own chain. */\n readonly functionMiddleware?: readonly Middleware[];\n /**\n * How a type only the application knows crosses the wire, in a server\n * function's input and result and in the page's seed. Installed when the\n * options are first read, which both sides do before they encode anything.\n */\n readonly serializationAdapters?: readonly AnySerializationAdapter[];\n /**\n * What a route that says nothing about `ssr` does, for every route: `true`,\n * `false` (rendered in the browser alone) or `\"data-only\"` (loaders run on\n * the server, the component in the browser). Wins over the router's own\n * `defaultSsr`, as TanStack's does.\n */\n readonly defaultSsr?: boolean | \"data-only\";\n readonly serverFns?: {\n /**\n * The `fetch` every call goes out through, in place of the global one. A\n * client middleware's `next({ fetch })` and the call's own `fetch` win\n * over it.\n */\n readonly fetch?: typeof fetch;\n };\n}\n\nexport interface StartInstance<Options extends StartOptions = StartOptions> {\n getOptions(): Options;\n}\n\ndeclare const UNREGISTERED: unique symbol;\n\n/**\n * Where an application tells the types about its `src/start.ts`:\n *\n * ```ts\n * declare module \"@barqjs/start\" {\n * interface Register {\n * start: typeof startInstance;\n * }\n * }\n * ```\n *\n * With that, what the global middleware passes to `next({ context })` is typed\n * in every server function's `context` and in `getGlobalStartContext()`.\n * Without it they are untyped, never wrong. The member below exists so the\n * interface is not the empty object type before anything augments it.\n */\nexport interface Register {\n readonly [UNREGISTERED]?: never;\n}\n\ntype RegisteredInstance = Register extends { readonly start: infer Instance }\n ? Instance\n : StartInstance;\n\n/** What an instance's request middleware adds, for the whole request. */\nexport type RequestContextOf<Instance> =\n Instance extends StartInstance<infer Options>\n ? ChainContribution<NonNullable<Options[\"requestMiddleware\"]>>[\"context\"]\n : Empty;\n\n/** What an instance's middleware hands every server function: request, then function. */\nexport type FunctionContextOf<Instance> =\n Instance extends StartInstance<infer Options>\n ? RequestContextOf<Instance> &\n ChainContribution<NonNullable<Options[\"functionMiddleware\"]>>[\"context\"]\n : Empty;\n\n/** What the registered global request middleware adds, for the whole request. */\nexport type GlobalRequestContext = RequestContextOf<RegisteredInstance>;\n\n/** What every server function's `context` starts from. */\nexport type GlobalFunctionContext = FunctionContextOf<RegisteredInstance>;\n\n/**\n * One instance for the process, whichever copy of this module asks.\n *\n * It is configuration, fixed once the application has loaded, so it has none\n * of the hazards an ambient request would: nothing a visitor does changes it.\n * On the global registry for the reason the server-function registry is: a\n * build compiles this module into its server bundle, and a host serving that\n * bundle through its own `serveBarq` has imported a second copy.\n */\nconst REGISTERED = ((globalThis as Record<symbol, unknown>)[Symbol.for(\"barq.start.instance\")] ??= {\n instance: null,\n}) as { instance: StartInstance | null };\n\nconst NONE: StartOptions = Object.freeze({});\n\n/**\n * Declare the application's global middleware.\n *\n * The function is called once, the first time anything asks, so a middleware\n * module that imports this one back is fully evaluated by then.\n */\nexport function createStart<const Options extends StartOptions>(\n options: () => Options,\n): StartInstance<Options> {\n let resolved: Options | undefined;\n const instance: StartInstance<Options> = {\n getOptions: () => {\n if (resolved === undefined) {\n resolved = options();\n if (resolved.serializationAdapters !== undefined) {\n registerSerializationAdapters(resolved.serializationAdapters);\n }\n }\n return resolved;\n },\n };\n REGISTERED.instance = instance;\n return instance;\n}\n\n/** What the application declared, or nothing. */\nexport function startOptions(): StartOptions {\n return REGISTERED.instance?.getOptions() ?? NONE;\n}\n\n/** Test seam. Not for application use. */\nexport function clearStart(): void {\n REGISTERED.instance = null;\n}\n","/**\n * `live`: a server function's answer as a standing one, kept current for as\n * long as the caller reads it, Solid 2.0's declaration.\n *\n * In the browser, calling a live function returns an async iterable that\n * survives its connection. Each connection is a call at the live address,\n * read as server-sent events: a value per event, or, for a frame, the region\n * applied where it is mounted, the same component yielded once per connection\n * so a `dynamic` over it never remounts. A body that ends without saying it\n * is complete is a death, and the loop calls again, after a pause that grows\n * with each failure in a row and resets on a healthy connection, naming the\n * last event it applied. A failure on the first connection rejects as a call\n * would, and so does a refusal the server will repeat.\n *\n * On the server, in process, there is no connection: the call is the call,\n * and a frame it answers with is marked so the page connects once claimed.\n */\n\nimport type { ServerFn } from \"./client.ts\";\nimport { type LiveIterable, type LiveStub, liveIterable } from \"./frames-client.ts\";\nimport { FRAME } from \"./frames.ts\";\n\nexport type { LiveIterable, LiveStatus } from \"./frames-client.ts\";\n\n/** Whether a server function is the server half, which runs in this process. */\nfunction inProcess(fn: unknown): boolean {\n return typeof fn === \"function\" && \"built\" in fn;\n}\n\n/**\n * Declare a server function's answer a standing one. In the browser, calling\n * the result returns an iterable that stays connected; on the server it is the\n * call itself, a frame it answers with marked for the page to connect.\n */\nexport function live<In, Out>(\n fn: ServerFn<In, Out, never>,\n): (...args: Parameters<ServerFn<In, Out, never>>) => LiveIterable<Awaited<Out>> {\n if (inProcess(fn)) {\n return ((...args: unknown[]) =>\n (fn as unknown as (...given: unknown[]) => Promise<unknown>)(...args).then((answer) => {\n const frame =\n typeof answer === \"function\"\n ? (answer as unknown as Record<symbol, { live?: boolean }>)[FRAME]\n : undefined;\n if (frame !== undefined) frame.live = true;\n return answer;\n })) as never;\n }\n return ((options?: unknown) => liveIterable(fn as unknown as LiveStub, options)) as never;\n}\n","/**\n * The client half of a server function, and NOTHING the server half needs.\n *\n * Its own module because of what importing it costs. The compiler replaces a\n * server-function module's contents with `export const x = clientRpc(\"<id>\")`,\n * and that stub used to import from `@barqjs/start` — whose index re-exports\n * `context.ts`, which is `node:async_hooks`. Every client bundle that reached\n * one server function therefore pulled the request-context machinery, the\n * middleware runner, the validators and the error classes, and Vite printed\n * \"node:async_hooks has been externalized for browser compatibility\" on every\n * build.\n *\n * That was survivable while a route module was `lazy()`, because the cost sat\n * in that route's own chunk. It stopped being survivable when `routeTree.gen.ts`\n * started importing route modules STATICALLY: measured on\n * `packages/kitchen-sink`, 25.7 kB of it moved into the set every page\n * preloads, for an application with two server functions on one route.\n *\n * So the stub imports from here. `index.ts` re-exports every name below, so an\n * application still writes `import { createServerFn } from \"@barqjs/start\"` and\n * nothing about the authoring surface changes.\n */\n\nimport { decodeWire, encodeWire } from \"@barqjs/server/codec\";\nimport {\n type FailedAnswer,\n type ServerFnIssue,\n type ServerFnThrown,\n ServerFnError,\n} from \"./fn-error.ts\";\nimport { applyFlight, applyFrameResponse, mountedFramesHeader } from \"./frames-client.ts\";\nimport { LIVE_CALL, type LiveRequest, registerStub } from \"./stubs.ts\";\nimport { FRAMES_HEADER, RPC_FLIGHT, RPC_FRAME } from \"./frames.ts\";\nimport {\n type Middleware,\n NOT_FOUND,\n REDIRECT,\n flattenMiddleware,\n runMiddleware,\n} from \"./middleware.ts\";\nimport { startOptions } from \"./start-instance.ts\";\n\nexport { STATIC_PREFIX, staticFunctionMiddleware, staticUrl } from \"./static-fn.ts\";\nexport { NOT_FOUND, REDIRECT } from \"./middleware.ts\";\nexport { ServerFnError, type ServerFnIssue, type ServerFnThrown } from \"./fn-error.ts\";\nexport { LIVE_CALL, type LiveRequest, clientStub } from \"./stubs.ts\";\nexport { type FrameComponent, applyFrameResponse, frameAdapter } from \"./frames-client.ts\";\nexport { type LiveIterable, type LiveStatus, live } from \"./live-client.ts\";\nexport { type BindingSlot, FRAME_APPLIED_EVENT, type Slot, isFrame } from \"./frames.ts\";\n\nexport const SERVER_FN: unique symbol = Symbol.for(\"barq.server-fn\");\n\n/** Where mounted server functions answer. */\nexport const RPC_PREFIX = \"/_barq/fn/\";\n\n/**\n * What distinguishes an RPC call from a form submission: the URL, not a header.\n *\n * `/_barq/fn/<id>` is what `<form action={fn}>` writes, takes `FormData`, and\n * answers with a redirect a browser can follow with JS disabled.\n * `/_barq/fn/<id>.data` is the JSON channel and answers with a value.\n *\n * React Router's `.data` suffix, and the reason is its reason: a header decides\n * the response shape invisibly, and a form cannot set one. RedwoodSDK shows the\n * failure — it emits the right hidden fields for a no-JS submit and never reads\n * them, so the form posts, returns 200, and nothing happens.\n */\nexport const DATA_SUFFIX = \".data\";\n\n/**\n * `/_barq/fn/<id>.live` is the live address: the data address's answer, framed\n * as server-sent events for as long as it stands. Its own URL, because a cache\n * keys on the URL and not on a header nothing tells it to vary by.\n */\nexport const LIVE_SUFFIX = \".live\";\n\n/**\n * How the data channel says \"the answer is an instruction, not a value\".\n *\n * A HEADER rather than a body sniff, so a caller that does not care never\n * parses the body to find out, and so a handler returning a plain object that\n * happens to have a `to` field is never mistaken for a redirect.\n */\nexport const RPC_CONTROL = \"x-barq-rpc\";\n\n/**\n * The {@link RPC_CONTROL} value for a `Response` the handler returned.\n *\n * The response IS the result then, and its body is whatever the handler wrote,\n * so the stub hands it back whole rather than reading it as a wire value. No\n * body rides under this one, which is why it is not an {@link RpcControl} kind.\n */\nexport const RPC_RESPONSE = \"response\";\n\n/**\n * The {@link RPC_CONTROL} value for a `Response` a handler, a validator or a\n * middleware THREW: the call rejects with that response itself, as TanStack's\n * does. Its body and status are what the author wrote for the caller.\n */\nexport const RPC_THROWN = \"thrown\";\n\n/**\n * The {@link RPC_CONTROL} value for an answer that arrives over time.\n *\n * The body is then one JSON line for each value the function yielded, each\n * holding a wire-encoded value, and the stub hands the caller an async iterable\n * of them. A line that says the function failed ends it with a\n * {@link ServerFnError}.\n */\nexport const RPC_STREAM = \"stream\";\n\n/** One line of a streamed answer: a value, the chain's `sendContext`, or a failure. */\nexport type RpcStreamLine =\n | { readonly v: unknown }\n | { readonly c: unknown }\n | { readonly e: 1; readonly t?: ServerFnThrown };\n\n/** The body of a 400 for refused input. */\nexport interface ServerFnInputAnswer {\n readonly error: \"invalid input\";\n readonly message: string;\n readonly issues: readonly ServerFnIssue[];\n}\n\n/**\n * What a caller is handed for a handler's result.\n *\n * A function that returns a `ReadableStream` or an async iterable answers over\n * time, and both arrive as an async iterable of the values, in the browser and\n * in process alike.\n */\nexport type Streamed<Out> =\n Out extends ReadableStream<infer Value>\n ? AsyncIterableIterator<Value>\n : Out extends AsyncIterable<infer Value>\n ? AsyncIterableIterator<Value>\n : Out;\n\n/**\n * Present when a middleware's `sendContext` rides back with the result.\n *\n * A HEADER flagging a different body shape, which is what `RPC_CONTROL` already\n * does and for the same reason: an ordinary call — every call, in almost every\n * application — must not pay a second parse or a wrapper object to carry\n * something it does not have. With the flag the body is `{ result, context }`;\n * without it the body IS the result, byte for byte as before.\n */\nexport const RPC_CONTEXT = \"x-barq-ctx\";\n\n/** The body shape {@link RPC_CONTEXT} announces. */\nexport interface RpcEnvelope {\n readonly result: unknown;\n readonly context: unknown;\n}\n\n/**\n * What rides in the body under {@link RPC_CONTROL}.\n *\n * `options` and `data` are wire-encoded, so a `Date` in a redirect's search or\n * in a not-found's data arrives as one. Each is absent when the thrown value\n * carried none, which leaves the body the two fields it otherwise is.\n */\nexport type RpcControl =\n | {\n readonly kind: \"redirect\";\n readonly to: string;\n readonly status: number;\n readonly options?: unknown;\n }\n | {\n readonly kind: \"not-found\";\n readonly message: string;\n readonly data?: unknown;\n readonly routeId?: string;\n };\n\n/**\n * A redirect that arrived over the wire, rebuilt on the client.\n *\n * NOT `@barqjs/router`'s `Redirect` — this package cannot construct that one.\n * It carries the same brand, so `isRedirect` from the router accepts it and the\n * router navigates on it exactly as it would on a redirect a loader threw. That\n * interchangeability is the whole reason those predicates are brand checks\n * rather than `instanceof`.\n */\nexport class RpcRedirect extends Error {\n readonly [REDIRECT] = true as const;\n readonly to: string;\n readonly status: number;\n readonly statusCode: number;\n /**\n * The navigation an options-form redirect described: `to`, `params`,\n * `search`, `hash`, `replace`, `reloadDocument`, `href`. The router goes\n * there in place of `to` when it is present.\n */\n readonly options?: Record<string, unknown>;\n constructor(to: string, status: number, options?: Record<string, unknown>) {\n super(`redirect to ${to}`);\n this.name = \"Redirect\";\n this.to = to;\n this.status = status;\n this.statusCode = status;\n this.options = options;\n }\n}\n\n/** The `notFound()` counterpart, branded for the same reason. */\nexport class RpcNotFound extends Error {\n readonly [NOT_FOUND] = true as const;\n readonly isNotFound = true as const;\n /** What `notFound({ data })` carried, for the `notFoundComponent` that renders this. */\n readonly data?: unknown;\n /** The route whose `notFoundComponent` answers, when the thrower named one. */\n readonly routeId?: string;\n constructor(message: string, data?: unknown, routeId?: string) {\n super(message);\n this.name = \"NotFound\";\n this.data = data;\n this.routeId = routeId;\n }\n}\n\n/** The JSON a failed call answered with, read from a copy so `error.response` stays unread. */\nasync function failedAnswer(response: Response): Promise<FailedAnswer | undefined> {\n if (!(response.headers.get(\"content-type\") ?? \"\").includes(\"application/json\")) return undefined;\n try {\n return (await response.clone().json()) as FailedAnswer;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The HTTP methods a server function answers. `GET` is the default, for a read\n * the browser and a CDN may cache; see {@link RPC_CALLER} for what keeps a link\n * from reaching one. `POST` is for a write and is the only one a form can reach.\n */\nexport type ServerFnMethod = \"GET\" | \"POST\";\n\nexport interface ServerFnMeta {\n /** Stable across edits and deploys: the module path and the export name. */\n id: string;\n /** Absent for `POST`, which is every function that did not ask for `GET`. */\n readonly method?: ServerFnMethod;\n}\n\n/**\n * The request header every GET call the stub makes carries, and is refused\n * without.\n *\n * A link, an `<img>`, a prefetch and a navigation cannot set a header; only\n * script can, and a cross-origin script that sets one is preflighted and\n * refused by the origin check. So a `GET` server function stays out of reach\n * of everything that is not this application's own code, which is the reason\n * `GET` was once refused outright: a mutation reachable by navigation is a\n * one-click CSRF carrying `SameSite=Lax` cookies.\n */\nexport const RPC_CALLER = \"x-barq-fn\";\n\n/** Where a GET call's payload rides, since a GET has no body. */\nexport const PAYLOAD_PARAM = \"payload\";\n\n/**\n * How a server function is CALLED: `fn({ data })`, and `fn()` when it takes\n * none.\n *\n * TanStack's convention, and worth matching for a reason beyond fidelity: a\n * named field leaves room for the options that\n * come after it without ever changing the call shape again, and it removes the\n * `adminStats(undefined)` the bare form forced on every no-argument call.\n */\n/**\n * What a call may carry beside its `data`. TanStack's three, under their names.\n */\nexport interface ServerFnCallOptions {\n /**\n * Aborts the call. In the browser the fetch is cancelled, and the server sees\n * its request go away, which is what the handler's own `signal` follows.\n */\n readonly signal?: AbortSignal;\n /**\n * Sent with the request. A name set here wins over the same name from a\n * client middleware's `next({ headers })`, since the call is the more\n * specific of the two.\n */\n readonly headers?: HeadersInit;\n /** Used in place of the global `fetch`, for this call alone. */\n readonly fetch?: typeof fetch;\n}\n\nexport type ServerFnArgs<In, Method extends ServerFnMethod = \"POST\"> = [undefined] extends [In]\n ? // The argument is OPTIONAL exactly when `undefined` is an acceptable input,\n // which covers both cases that want it: no validator at all (`In` is\n // `undefined`), and `.validator(\"unchecked\")`, whose `In` is `unknown` and\n // which therefore admits `undefined` too. Asking `[In] extends [undefined]`\n // instead got the first and not the second, so every `unchecked` function\n // that takes nothing still had to be called with an argument.\n //\n // An optional ELEMENT, not a `void` one: a rest tuple with a `void` member\n // does not make the parameter optional, and `fn()` stayed \"Expected 1\n // arguments, but got 0\" until it was written this way.\n [options?: ({ readonly data?: In } & ServerFnCallOptions) | FormFor<Method>]\n : [options: ({ readonly data: In } & ServerFnCallOptions) | FormFor<Method>];\n\n/** A form is a body, so only a `POST` function takes one. */\ntype FormFor<Method extends ServerFnMethod> = Method extends \"POST\" ? FormData : never;\n\n/**\n * A server function, from either side.\n *\n * A bare `FormData` is accepted BESIDE the options object, and only there. It is\n * what `<form action={fn}>` hands the function on the enhanced path, and a\n * `FormData` can never be mistaken for an options object — so the no-JS\n * submission and the JS one reach the handler identically, which is the whole\n * point of that path. TanStack has no counterpart to match here.\n */\nexport type ServerFn<In, Out, Method extends ServerFnMethod = \"POST\"> = ((\n ...args: ServerFnArgs<In, Method>\n) => Promise<Out>) & {\n readonly [SERVER_FN]: true;\n readonly meta: ServerFnMeta;\n /** TanStack's name for `meta`: the id this function is mounted at. */\n readonly serverFnMeta: ServerFnMeta;\n /** The method this function answers. */\n readonly method: ServerFnMethod;\n /**\n * Where a form posts to reach this function: what `<form action={fn}>`\n * writes. Empty for a function that is not mounted, which has no endpoint.\n */\n readonly url: string;\n};\n\n/**\n * Any server function, whatever it takes and returns.\n *\n * `never` in, because the input sits in a parameter: a function that takes a\n * string does not accept `unknown`, and every function accepts `never`. The\n * method is `never` for the same reason: it decides whether a form is a\n * parameter.\n */\nexport type AnyServerFn = ServerFn<never, unknown, never>;\n\n/** The form endpoint of a mounted id, or nothing for a function with none. */\nexport function urlOf(id: string): string {\n return id === \"\" ? \"\" : RPC_PREFIX + encodeURIComponent(id);\n}\n\n/** The `data` out of a call, whichever of the two shapes it arrived in. */\nexport function dataOf(options: unknown): unknown {\n if (options instanceof FormData) return options;\n if (options === undefined || options === null) return undefined;\n return (options as { data?: unknown }).data;\n}\n\n/** What a call asked for beside its `data`. A bare `FormData` asks for nothing. */\nexport function callOptionsOf(options: unknown): ServerFnCallOptions | undefined {\n if (options instanceof FormData || options === undefined || options === null) return undefined;\n return options;\n}\n\n/**\n * The client half. The compiler emits this in a module compiled for the client,\n * with the id, the chain, and nothing else — no handler body, no validator, no\n * imports the body needed.\n *\n * `chain` is the middlewares the function declared, and it is here so a\n * `.client()` half can run around the fetch. Only the CLIENT halves survive the\n * compile: `createMiddleware(...).server(fn)` has its `server` argument deleted\n * in the client build, so a middleware may hold both without the server body —\n * or the database import it needed — reaching the browser.\n */\nexport function clientRpc<In, Out, Method extends ServerFnMethod = \"POST\">(\n id: string,\n declaredChain: readonly ChainStep[] = [],\n declared?: { readonly method?: Method },\n): ServerFn<In, Out, Method> {\n const method: ServerFnMethod = declared?.method ?? \"POST\";\n const chain = inlineServerFns(declaredChain);\n // With the application's global function middleware ahead of the function's\n // own, read when first needed for the reason `serverRpc` gives.\n let composed: { from: readonly Middleware[] | undefined; chain: readonly Middleware[] } | null =\n null;\n const composition = (): readonly Middleware[] => {\n const global = startOptions().functionMiddleware;\n if (composed === null || composed.from !== global) {\n composed = { from: global, chain: flattenMiddleware([...(global ?? []), ...chain]) };\n }\n return composed.chain;\n };\n\n /**\n * The fetch, as the INNERMOST step of the chain.\n *\n * A client middleware therefore wraps the request the way a server one wraps\n * the handler: it can read what it is about to send, add to `sendContext`,\n * and see the result on the way back. TanStack reaches the same arrangement\n * by appending the server function itself to the chain as a middleware.\n */\n const send = async (\n input: unknown,\n sendContext: Record<string, unknown>,\n /**\n * THIS call's context, which is where the server chain's answer is merged.\n * Absent on the path with no chain, where nothing could read it.\n */\n context?: Record<string, unknown>,\n asked?: ServerFnCallOptions,\n /** What the client halves passed to `next({ headers })`. */\n chainHeaders?: Headers,\n /** What the client halves passed to `next({ fetch })`, the last one winning. */\n chainFetch?: typeof fetch,\n /** A call at the live address, whose answer is handed back whole for `live`'s loop to read. */\n live?: LiveRequest,\n ): Promise<Out> => {\n // FormData goes as FormData. Routing it through the value codec would hand\n // the handler a plain OBJECT here and a real `FormData` on the no-JS path —\n // the same function seeing two input types depending on whether JS ran,\n // which is the divergence progressive enhancement exists to avoid. It also\n // keeps files, which no value codec in this class carries.\n const form = input instanceof FormData;\n if (form && method === \"GET\") {\n throw new TypeError(\n `[barq] The server function \\`${id}\\` answers GET, and a GET has no body to carry a form. ` +\n 'Declare it `createServerFn({ method: \"POST\" })` to accept a `FormData`.',\n );\n }\n // Otherwise seroval's JSON channel, so an argument carries a Date, a Map or\n // a cycle the same way a hydration seed does — and reconstructs through\n // `fromJSON`, which evaluates nothing.\n //\n // `context` is what the CLIENT halves asked to send. It is absent from the\n // payload when they asked for nothing, so an application with no client\n // middleware sends exactly the bytes it sent before.\n const payload = form\n ? undefined\n : JSON.stringify(\n Object.keys(sendContext).length === 0\n ? { input: encodeWire(input) }\n : { input: encodeWire(input), context: encodeWire(sendContext) },\n );\n // No content-type for the form case: the browser sets the multipart\n // boundary, and setting it by hand produces a body nothing can parse. None\n // for a GET either, which has no body to describe.\n let headers: HeadersInit | undefined = method === \"GET\" ? CALLER : form ? undefined : JSON_BODY;\n // A mutation names the frames the page has mounted, so its answer can\n // carry the ones it changed.\n const mountedFrames = method === \"POST\" && live === undefined ? mountedFramesHeader() : null;\n if (mountedFrames !== null) {\n const withFrames = new Headers(headers);\n withFrames.set(FRAMES_HEADER, mountedFrames);\n headers = withFrames;\n }\n if (chainHeaders !== undefined || asked?.headers !== undefined) {\n const merged = new Headers(chainHeaders);\n if (mountedFrames !== null) merged.set(FRAMES_HEADER, mountedFrames);\n if (asked?.headers !== undefined) {\n for (const [name, value] of new Headers(asked.headers)) merged.set(name, value);\n }\n // Ours either way: the body is what this function encoded, whatever a\n // caller or a middleware believes it is sending.\n if (form || method === \"GET\") merged.delete(\"content-type\");\n else merged.set(\"content-type\", \"application/json\");\n if (method === \"GET\") merged.set(RPC_CALLER, \"1\");\n headers = merged;\n }\n if (live !== undefined) {\n const withPosition = new Headers(headers);\n if (live.lastEventId !== null) withPosition.set(\"last-event-id\", live.lastEventId);\n headers = withPosition;\n }\n const endpoint =\n RPC_PREFIX + encodeURIComponent(id) + (live === undefined ? DATA_SUFFIX : LIVE_SUFFIX);\n const response = await (asked?.fetch ?? chainFetch ?? startOptions().serverFns?.fetch ?? fetch)(\n method === \"GET\"\n ? `${endpoint}?${PAYLOAD_PARAM}=${encodeURIComponent(payload ?? \"\")}`\n : endpoint,\n {\n method,\n headers,\n signal: live?.signal ?? asked?.signal,\n body: method === \"GET\" ? undefined : form ? input : payload,\n credentials: \"same-origin\",\n // `manual` so a handler that answers with its OWN 3xx — a real\n // `new Response(null, { status: 302 })`, not a `throw redirect(...)` —\n // is handed back as a response rather than silently followed. The\n // default `follow` would fetch the target and hand the CALLER that\n // page's body, which is how TanStack's fetcher turns a redirecting\n // server function into an opaque HTML string.\n redirect: \"manual\",\n },\n );\n // A control answer is an INSTRUCTION rather than a value, and it is read\n // off the header so an ordinary result never pays a second body parse.\n // A BROWSER hides a redirect it was told not to follow: status 0 and no\n // headers, so nothing below can recognise it. It is still the handler's\n // answer, and the status check would report it as a failure with no status.\n if (response.type === \"opaqueredirect\") return response as Out;\n if (live !== undefined) return response as Out;\n const control = response.headers.get(RPC_CONTROL);\n // Before the status check: a response the handler returned is its answer\n // whatever status it chose.\n if (control === RPC_RESPONSE) return response as Out;\n if (control === RPC_THROWN) throw response;\n if (control === RPC_STREAM) return received(response, id, context) as Out;\n if (control === RPC_FRAME) return (await applyFrameResponse(response)) as Out;\n if (control === RPC_FLIGHT) {\n const flown = await applyFlight(response);\n if (response.headers.get(RPC_CONTEXT) === null) return flown as Out;\n const envelope = flown as RpcEnvelope;\n if (context !== undefined) Object.assign(context, envelope.context);\n return envelope.result as Out;\n }\n if (control !== null) throw fromControl((await response.json()) as RpcControl);\n if (!response.ok) {\n throw new ServerFnError(id, response.status, response, await failedAnswer(response));\n }\n if (response.headers.get(RPC_CONTEXT) === null) return decodeWire<Out>(await response.json());\n const envelope = decodeWire<RpcEnvelope>(await response.json());\n // What the SERVER's chain sent back, merged into the same object the client\n // halves have been writing. A client middleware reads it on the way out\n // through the `context` it was handed, which is that object.\n if (context !== undefined) Object.assign(context, envelope.context);\n return envelope.result as Out;\n };\n\n const call = async (options?: unknown, live?: LiveRequest): Promise<Out> => {\n const input = dataOf(options);\n // NO CHAIN, NO RUNNER. Every application without a client middleware takes\n // this line, and it is the line the compiler emitted before any of this\n // existed — one fetch, no closures built, no objects allocated.\n const asked = callOptionsOf(options);\n const flattened = composition();\n if (flattened.length === 0)\n return send(input, EMPTY_CONTEXT, undefined, asked, undefined, undefined, live);\n\n const context: Record<string, unknown> = {};\n const sendContext: Record<string, unknown> = {};\n const headers = new Headers();\n const chosen: { current: typeof fetch | undefined } = { current: undefined };\n return (await runMiddleware(flattened, \"client\", {\n data: input,\n meta: { id },\n method,\n signal: asked?.signal ?? new AbortController().signal,\n context,\n sendContext,\n headers,\n fetch: chosen,\n run: (data) => send(data, sendContext, context, asked, headers, chosen.current, live),\n })) as Out;\n };\n\n const meta: ServerFnMeta = method === \"GET\" ? { id, method } : { id };\n const stub = Object.assign((options?: unknown) => call(options), {\n [SERVER_FN]: true as const,\n [SERVER_FN_CHAIN]: chain,\n [LIVE_CALL]: (options: unknown, live: LiveRequest): Promise<Response> =>\n call(options, live) as Promise<Response>,\n meta,\n serverFnMeta: meta,\n method,\n url: urlOf(id),\n });\n registerStub(id, stub);\n return stub;\n}\n\n/**\n * A streamed answer, as the values it carries.\n *\n * Read a line at a time, so a value is handed over when its line has arrived\n * rather than when the answer is complete. Leaving the loop early cancels the\n * body, which is what tells the server to stop producing.\n */\nasync function* received(\n response: Response,\n id: string,\n context: Record<string, unknown> | undefined,\n): AsyncIterableIterator<unknown> {\n const body = response.body;\n if (body === null) return;\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let pending = \"\";\n try {\n for (;;) {\n const { done, value } = await reader.read();\n pending += done ? decoder.decode() : decoder.decode(value, { stream: true });\n let end = pending.indexOf(\"\\n\");\n while (end !== -1) {\n const line = JSON.parse(pending.slice(0, end)) as RpcStreamLine;\n pending = pending.slice(end + 1);\n if (\"e\" in line) throw new ServerFnError(id, 500, undefined, { thrown: line.t });\n if (\"c\" in line) {\n if (context !== undefined) Object.assign(context, decodeWire(line.c));\n } else yield decodeWire(line.v);\n end = pending.indexOf(\"\\n\");\n }\n if (done) return;\n }\n } finally {\n void reader.cancel().catch(() => {});\n }\n}\n\n/** One object for every JSON call, which only ever reads it. */\nconst JSON_BODY = { \"content-type\": \"application/json\" };\n\n/** What a GET call carries in place of a body's type. */\nconst CALLER = { [RPC_CALLER]: \"1\" };\n\n/** Shared, because the no-middleware path never writes to it. */\nconst EMPTY_CONTEXT: Record<string, unknown> = {};\n\n/**\n * Rebuild the throwable a control answer describes.\n *\n * An UNKNOWN kind is an error rather than a pass-through: it means the server is\n * newer than the client and is describing something this build cannot act on,\n * and returning it as a value would let a navigation instruction be rendered as\n * data.\n */\nfunction fromControl(control: RpcControl): Error {\n if (control.kind === \"redirect\") {\n return new RpcRedirect(\n control.to,\n control.status,\n control.options === undefined ? undefined : decodeWire(control.options),\n );\n }\n if (control.kind === \"not-found\") {\n return new RpcNotFound(\n control.message,\n control.data === undefined ? undefined : decodeWire(control.data),\n control.routeId,\n );\n }\n return new Error(\n `[barq] server function answered with an unrecognised ${RPC_CONTROL} kind ` +\n `${JSON.stringify((control as { kind: string }).kind)}; the server is newer than this client bundle.`,\n );\n}\n\n/** Where a server function keeps the middleware it declared, for another to inline. */\nexport const SERVER_FN_CHAIN: unique symbol = Symbol.for(\"barq.server-fn-chain\");\n\n/** What `.middleware([...])` takes: a middleware, or a server function whose chain it inlines. */\nexport type ChainStep = Middleware | AnyServerFn;\n\n/**\n * A chain with each server function in it replaced by the middleware that\n * function declared, which is TanStack's rule: listing a function lists its\n * guards, never its handler.\n */\nexport function inlineServerFns(chain: readonly ChainStep[]): readonly Middleware[] {\n return chain.flatMap((step): readonly Middleware[] =>\n isServerFn(step) ? chainOf(step) : [step as Middleware],\n );\n}\n\nfunction chainOf(fn: AnyServerFn | ServerFn<unknown, unknown>): readonly Middleware[] {\n return (\n (fn as unknown as Record<symbol, readonly Middleware[] | undefined>)[SERVER_FN_CHAIN] ?? []\n );\n}\n\n/** Whether a value is a server function, by brand rather than by shape. */\nexport function isServerFn(value: unknown): value is ServerFn<unknown, unknown> {\n return (\n typeof value === \"function\" && (value as unknown as Record<symbol, unknown>)[SERVER_FN] === true\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqCA,IAAa,gBAAb,cAAmC,MAAM;CACvC;;;;;;CAMA;;;;;;CAMA;;;;;;;;;;CAUA;CACA,YAAY,IAAY,QAAgB,UAAqB,QAAuB;EAClF,MAAM,eAAe,IAAI,QAAQ,MAAM,CAAC;EACxC,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,WAAW;EAChB,IAAI,QAAQ,WAAW,KAAA,GAAW,KAAK,SAAS,OAAO;EACvD,IAAI,QAAQ,WAAW,KAAA,GAAW,KAAK,SAAS,OAAO;CACzD;AACF;AAEA,SAAS,eAAe,IAAY,QAAgB,QAA0C;CAC5F,MAAM,SAAS,QAAQ;CACvB,IAAI,WAAW,KAAA,KAAa,OAAO,SAAS,GAM1C,OACE,yBAAyB,GAAG,wBAAwB,OAAO,KAN9C,OACZ,KAAK,UACJ,MAA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MAAM,SAAS,SACpB,WAAW,IAAI,IAAI,QAAQ,IAAI,IAAI,CAAC,IAAkB,CACxD;AACF;AAEA,SAAS,QAAQ,IAAqE;CACpF,OACG,GAAoE,oBAAoB,CAAC;AAE9F;;AAGA,SAAgB,WAAW,OAAqD;CAC9E,OACE,OAAO,UAAU,cAAe,MAA6C,eAAe;AAEhG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-DHCV7yvQ.d.ts","names":[],"sources":["../src/fn-error.ts","../src/static-fn.ts","../src/stubs.ts","../src/frames.ts","../src/frames-client.ts","../src/live-client.ts","../src/client.ts"],"mappings":";;;;;;;;;;;UAOiB;WACN;WACA;;WAEA;;;UAIM;WACN;WACA;;;UAIM;WACN;WACA,kBAAkB;WAClB,SAAS;;;;;;;;;;;;cAaP,sBAAsB;WACxB;;;;;;WAMA,kBAAkB;;;;;;WAMlB,SAAS;;;;;;;;;;WAUT,WAAW;EACpB,YAAY,YAAY,gBAAgB,WAAW,UAAU,SAAS;;;;;cClC3D;;iBA8EG,UAAU,YAAY;;;;;;;;;;;;;cA+CzB,0BAA0B,gBACrC,WAAW,WAAW,iBAAiB,qBAAqB;;;;;;;;KCnJlD,SAAS,sBAAsB;WAChC;aAAiB;;;;UAIX;WACN;WACA,QAAQ;;;cAIN;iBAYG,WAAW,aAAa;;;;;;;;;KCO5B,KAAK,0BACf,OAAO,SAAS;WAAe;WAAiC,WAAW;OACxE;;;;;;;;;KAUO,YACV,uBACA,mBAAmB,iCACX,mBACL;WAAkB;MAA6B,SAAS,MACxD,MAAM;WAAe;MAA6B,SAAS;;cAGnD;;UAGI;WACN;WACA;;;iBAIK,QAAQ;;cA0DX;;;;KCrDD,mBAAmB,OAAO,4BAA4B;YACtD,QAAQ;;;;;;;cA8GP,cAAc;;;;;;iBA6wBL,mBAAmB,UAAU,WAAW,QAAQ;;KA6F1D;UAEK,aAAa,WAAW,cAAc;;EAErD,YAAY,QAAQ,YAAY;;;;;;;;;iBCj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I,KAAK;;cA6QR;;KAGD,YAAY,aAAa;;;;;;iBAOrB,gBAAgB,gBAAgB,uBAAuB;;iBAavD,WAAW,iBAAiB,SAAS"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env-qA8EyOr1.d.ts","names":[],"sources":["../src/env.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;KAqBY,aAAa,sCAAsC,uBAC1D,MAAM,SACN;UAEY,kBACf,sCACA,yBACQ,aAAa,MAAM;EAC3B,OAAO,8BAA8B,GAAG,QAAQ,MAAM,MAAM,IAAI,kBAAkB,GAAG;EACrF,OAAO,8BAA8B,GAAG,QAAQ,MAAM,MAAM,IAAI,kBAAkB,GAAG;;;;;;;;;;;iBAYvE,sBAAsB;;;;;;;;iBAgCtB,mBAAmB,iCAAiC,KAClE,QAAQ,MAAM,SAAS,UAClB,MAAM,SAAS;;iBAKN,mBAAmB,iCAAiC,KAClE,QAAQ,MAAM,SAAS,UAClB,MAAM,SAAS"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-Bm_-MTj6.d.ts","names":[],"sources":["../src/cookies.ts","../src/session.ts","../src/start-instance.ts","../src/context.ts","../src/rate-limit.ts","../src/timing.ts","../src/wire-types.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA2BiB;WACN;WACA,UAAU;WACV;;WAEA;;WAEA;WACA;WACA;WACA;WACA;;;;;;;WAOA,UAAU;;;;;;;;;;;iBA0CL,aAAa,oCAAoC;;;;;;;iBAmCjD,gBAAgB,cAAc,eAAe,UAAS;;;;;;;;;;iBAwGtD,iBAAiB,cAAc,UAAS;;;;KCpM5C,cAAc;UAET,QAAQ,UAAU,cAAc;;WAEtC;;WAEA;WACA,MAAM,QAAQ;;UAGR,eAAe,UAAU,cAAc;WAC7C;;WAEA;WACA,MAAM,QAAQ;;EAEvB,OACE,OAAO,QAAQ,OAAO,SAAS,QAAQ,OAAO,QAAQ,kBAC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BAAgB,cAChB,2BACA;WACW;WACA,QAAQ;;WAER,SAAS;;WAET,gBAAgB;;WAEhB,aAAa;;WAEb,UAAU;;WAEV;IAAU,gBAAgB;;;WAE1B;aAAkB;;;WAElB;;WAEA,MAAM,kBAAkB;IAElC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-BV3xKmLa.js","names":["isIterable"],"sources":["../src/frames-server.ts","../src/live-server.ts","../src/server.ts"],"sourcesContent":["/**\n * The server half of frames: what a server function's component result becomes,\n * rendered two ways.\n *\n * In the document, where a route renders it with the page's own props, the\n * frame is written inline and each slot holds the browser's content rendered\n * here for the first paint. Over the wire, answering a call from the browser,\n * the region is rendered on its own and its slots are left empty for the\n * browser to fill. Both write the markup `frames.ts` describes.\n */\n\nimport type { HeadTag } from \"@barqjs/web\";\nimport { block, childScope, getOwner, runWithOwner, untrack } from \"@barqjs/core\";\nimport { SSR_HTML_BRAND, setHeadSink } from \"@barqjs/web/internal\";\nimport { setHydratable } from \"@barqjs/core/internal\";\nimport { SlotValue, esc, html, renderFrame, setServerComponent } from \"@barqjs/server\";\nimport {\n encodeWire,\n registerSerializationAdapters,\n serializationAdapters,\n} from \"@barqjs/server/codec\";\n\nimport { collectRequestCss } from \"./context.ts\";\nimport {\n FRAME,\n FRAME_CLOSE,\n FLIGHT_TYPE,\n FRAMES_BUDGET,\n FRAME_VERSION,\n type FramePayload,\n RPC_FLIGHT,\n type FrameRef,\n RPC_FRAME,\n type SlotRecord,\n bindEntries,\n frameAddress,\n frameOpen,\n isFrame,\n regionMarkup,\n slotClose,\n slotOpen,\n} from \"./frames.ts\";\n\n/** A server component: what a frame-answering handler returns. */\ntype ServerComponent = (props: Record<string, unknown>) => unknown;\n\n/** What a server function returns in place of its handler's component. */\nexport interface ServerFrame {\n (props: Record<string, unknown>): unknown;\n readonly [FRAME]: FrameRef & {\n readonly args: unknown;\n readonly component: ServerComponent;\n readonly markup: (options: { readonly session?: symbol }) => Promise<string>;\n /** Called through `live`: the page keeps it current over a connection. */\n live?: boolean;\n };\n}\n\n/**\n * How a frame crosses inside the page's own seed: by address, as a reference\n * the browser resolves to the region already on the page. Registered when a\n * frame is made and the registry does not hold it, so an application that has\n * none sends the bytes it always did.\n */\nconst FRAME_ADAPTER = {\n key: \"barq.frame\",\n test: isFrame,\n toSerializable: (frame: ServerFrame): FrameRef => ({\n id: frame[FRAME].id,\n address: frame[FRAME].address,\n }),\n fromSerializable: (ref: FrameRef): FrameRef => ref,\n};\n\nfunction registerFrameAdapter(): void {\n if (serializationAdapters().some((adapter) => adapter.key === FRAME_ADAPTER.key)) return;\n registerSerializationAdapters([FRAME_ADAPTER]);\n}\n\n/** The server function's component result, as a frame. */\nexport function serverFrame(id: string, data: unknown, component: ServerComponent): ServerFrame {\n registerFrameAdapter();\n // What the call was given, absent when it was given nothing: a function with\n // no validator refuses a `data` it did not declare, `null` included.\n const args = data === undefined ? undefined : encodeWire(data);\n const address = frameAddress(id, encodeWire(data ?? null));\n const state: ServerFrame[typeof FRAME] = {\n id,\n address,\n args,\n component,\n markup: (options) => renderMarkup(state, options),\n };\n const render = (props: Record<string, unknown>): unknown =>\n documentFrame(address, args, component, props, state.live === true);\n return Object.assign(render, { [FRAME]: state });\n}\n\n/** A value read from a slot argument: a Cell is called, anything else is the value. */\nfunction valueOf(argument: unknown): unknown {\n return typeof argument === \"function\" ? untrack(argument as () => unknown) : argument;\n}\n\n/** What a slot call returns that is never one of its properties: the markup's own names. */\nconst NOT_A_PROPERTY = new Set([\"t\", \"then\", \"toString\", \"toJSON\", \"valueOf\", \"constructor\"]);\n\ntype Record_ = { -readonly [K in keyof SlotRecord]: SlotRecord[K] };\n\n/** The page's fill for one occurrence, run once, and the scope it ran under. */\ninterface Filled {\n readonly result: unknown;\n readonly scope: ReturnType<typeof childScope>;\n}\n\n/**\n * The props a server component is rendered with: every name is a slot.\n *\n * A slot call is placed as markup, `<props.comment … />`, or read as data,\n * `props.row(args).done`, which makes it a binding slot. Which one is known\n * only once the component uses what the call returned, so the call answers\n * both: its markup when it is placed, a stand-in for each property read.\n *\n * `fills` are the page's own props, when the frame is written into the page:\n * each slot then holds what the browser would put there, for the first paint,\n * and a binding slot's stand-ins hold the fill's first values.\n */\nclass Slots {\n private readonly records: (Record_ | null)[] = [];\n readonly props: Record<string, unknown>;\n\n constructor(private readonly fills: Record<string, unknown> | null) {\n this.props = new Proxy(\n {},\n { get: (_, name) => (typeof name === \"string\" ? this.slot(name) : undefined) },\n );\n }\n\n private slot(name: string): unknown {\n if (name === \"children\") {\n const at = this.reserve();\n this.records[at] = { at, name, key: \"\" };\n return html(this.markup(at, this.fill(name, at, {}, undefined)));\n }\n return (args?: Record<string, unknown>): unknown => this.call(name, args);\n }\n\n /**\n * Taken before the region renders, so an occurrence inside it numbers after\n * this one, in document order.\n */\n private reserve(): number {\n this.records.push(null);\n return this.records.length - 1;\n }\n\n private call(name: string, args: Record<string, unknown> | undefined): unknown {\n const at = this.reserve();\n const values: Record<string, unknown> = {};\n let explicit = \"\";\n for (const [key, argument] of Object.entries(args ?? {})) {\n if (key === \"children\") continue;\n if (key === \"$key\") explicit = String(valueOf(argument));\n else values[key] = valueOf(argument);\n }\n const children = args?.children;\n const region = children === undefined ? undefined : esc(children);\n const record: Record_ = {\n at,\n name,\n key: explicit,\n ...(args === undefined ? {} : { args: encodeWire(values) }),\n ...(region === undefined ? {} : { region, hasRegion: true }),\n };\n this.records[at] = record;\n const filled = this.fill(name, at, values, region);\n let markup: string | null = null;\n const placed = (): string => {\n if (record.bind === true) throw readTwice(name);\n markup ??= this.markup(at, filled);\n return markup;\n };\n const standIns = new Map<string, SlotValue>();\n const read = (key: string): SlotValue => {\n if (markup !== null) throw readTwice(name);\n record.bind = true;\n let standIn = standIns.get(key);\n if (standIn === undefined) {\n const result = filled?.result;\n const known = typeof result === \"object\" && result !== null;\n const value = known\n ? runWithOwner(filled!.scope, () =>\n untrack(() => (result as Record<string, unknown>)[key]),\n )\n : undefined;\n standIn = new SlotValue(at, key, this.fills !== null && known, value);\n standIns.set(key, standIn);\n }\n return standIn;\n };\n return new Proxy(\n {},\n {\n get: (_, key) => {\n if (key === SSR_HTML_BRAND) return record.bind !== true;\n if (key === \"t\") return placed();\n if (key === \"toString\") return placed;\n if (typeof key === \"symbol\" || NOT_A_PROPERTY.has(key)) return undefined;\n return read(key);\n },\n ownKeys: () => {\n throw new Error(\n `[barq] A server component spread what \\`props.${name}()\\` returned. A binding slot's properties are placed one position at a time, ` +\n \"so the markup shows what the browser fills: name each one, as in `<li hidden={row.hidden}>`.\",\n );\n },\n },\n );\n }\n\n private markup(at: number, filled: Filled | null): string {\n const content = filled === null ? \"\" : runWithOwner(filled.scope, () => esc(filled.result));\n return `<!--${slotOpen(at)}-->${content}<!--${slotClose(at)}-->`;\n }\n\n /**\n * The page's fill for a slot, run once for the first paint: its content for\n * a slot that is placed, its values for one read as data. Nothing over the\n * wire, where the browser fills every slot itself.\n */\n private fill(\n name: string,\n at: number,\n values: Record<string, unknown>,\n region: string | undefined,\n ): Filled | null {\n if (this.fills === null) return null;\n const given = this.fills[name];\n // The page's own content, which the browser claims, under a scope that\n // hydrates again inside the server component's.\n const scope = childScope(getOwner(), \"branch\");\n setHydratable(scope, true);\n setServerComponent(scope, false);\n if (name === \"children\") return { result: given, scope };\n const props: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(values)) props[key] = (): unknown => value;\n if (region !== undefined) props.children = block(() => html(regionMarkup(String(at), region)));\n // A fill that takes nothing reaches the props as the Cell it is, so reading\n // the prop is calling it.\n const result = runWithOwner(scope, () => {\n const fill = valueOf(given);\n return typeof fill === \"function\" ? (fill as ServerComponent)(props) : fill;\n });\n return result === undefined ? null : { result, scope };\n }\n\n /**\n * The records the markup still carries, keyed: a boundary resumed during the\n * render built its slots again, so only the occurrences in the final markup\n * count, and a positional key is taken in that markup's order. `inline`\n * drops each region, which the page already carries inside the slot.\n */\n final(markup: string, inline: boolean): SlotRecord[] {\n const present = new Set<number>();\n for (const found of markup.matchAll(/<!--s:(\\d+)-->/g)) present.add(Number(found[1]));\n for (const found of markup.matchAll(/ _b-[^\\s=>]+=\"([^\"]*)\"/g)) {\n for (const entry of bindEntries(found[1])) present.add(entry.at);\n }\n for (const found of markup.matchAll(/<!--_b:(\\d+):/g)) present.add(Number(found[1]));\n const ordinal = new Map<string, number>();\n const out: SlotRecord[] = [];\n for (const record of this.records) {\n if (record === null || !present.has(record.at)) continue;\n const count = ordinal.get(record.name) ?? 0;\n ordinal.set(record.name, count + 1);\n out.push({\n at: record.at,\n name: record.name,\n key: record.key === \"\" ? `${record.name}:${count}` : `$${record.key}`,\n ...(record.args === undefined ? {} : { args: record.args }),\n ...(record.bind === true\n ? { bind: true }\n : {\n ...(record.hasRegion === true ? { hasRegion: true } : {}),\n ...(inline || record.region === undefined ? {} : { region: record.region }),\n }),\n });\n }\n return out;\n }\n}\n\nfunction readTwice(name: string): Error {\n return new Error(\n `[barq] A server component both placed \\`props.${name}()\\` as markup and read it as data. ` +\n \"A slot call is one or the other: place it, `<props.\" +\n name +\n \" />`, for the browser's content, or read its properties, for a binding slot.\",\n );\n}\n\n/** Render a server component: what renders under it may read binding slots. */\nfunction asServerComponent<T>(render: () => T): T {\n const scope = childScope(getOwner(), \"branch\");\n setServerComponent(scope, true);\n return runWithOwner(scope, render);\n}\n\n/**\n * The frame written into the page, where a route renders it.\n *\n * What the component declares for the head goes to the page's head as any\n * component's does, and is recorded too, so the browser takes those tags over\n * with the frame and drops them with it.\n */\nfunction documentFrame(\n address: string,\n args: unknown,\n component: ServerComponent,\n fills: Record<string, unknown>,\n live: boolean,\n): unknown {\n const slots = new Slots(fills);\n const head: HeadTag[] = [];\n let outer: ReturnType<typeof setHeadSink> = null;\n outer = setHeadSink({\n add: (tags) => {\n head.push(...tags);\n outer?.add(tags);\n },\n module: (url) => outer?.module?.(url),\n });\n // Nothing the server component itself reads reaches the page's seed: the\n // browser never runs it, so a value seeded for it is one nothing claims.\n const scope = childScope(getOwner(), \"branch\");\n setHydratable(scope, false);\n setServerComponent(scope, true);\n let region: string;\n try {\n region = runWithOwner(scope, () => esc(component(slots.props)));\n } finally {\n setHeadSink(outer);\n }\n const payload: FramePayload = {\n v: FRAME_VERSION,\n args,\n ...(live ? { live: true } : {}),\n slots: slots.final(region, true),\n head,\n };\n return html(frameOpen(address, payload) + region + FRAME_CLOSE);\n}\n\n/**\n * The answer to a call from the browser: the region rendered on its own, its\n * slots empty. Its head carries what the region declared, the stylesheets and\n * chunks its `lazy()` modules need, and the rules `@barqjs/css` registered\n * while it rendered.\n */\nexport async function frameResponse(frame: ServerFrame): Promise<Response> {\n const answer = new Response(await frameMarkup(frame));\n answer.headers.set(\"content-type\", \"text/html; charset=utf-8\");\n answer.headers.set(\"cache-control\", \"no-store\");\n answer.headers.set(\"x-barq-rpc\", RPC_FRAME);\n return answer;\n}\n\n/**\n * A frame's markup over the wire: the region rendered on its own, its slots\n * empty. Rendered by the frame itself, so by the copy of this module that made\n * it: a host serving a built server through its own `serveBarq` answers the\n * call from another copy, whose renderer is not the one the component was\n * compiled against.\n */\nexport function frameMarkup(\n frame: ServerFrame,\n options: { readonly session?: symbol } = {},\n): Promise<string> {\n return frame[FRAME].markup(options);\n}\n\nasync function renderMarkup(\n frame: ServerFrame[typeof FRAME],\n options: { readonly session?: symbol },\n): Promise<string> {\n const { address, args, component } = frame;\n const slots = new Slots(null);\n const rendered = await renderFrame(\n () => asServerComponent(() => component(slots.props)) as never,\n {\n renderId: `f${address.slice(address.lastIndexOf(\"#\") + 1)}-`,\n session: options.session,\n },\n );\n const head = [...rendered.head];\n const css = collectRequestCss();\n if (css !== \"\") head.push({ tag: \"style\", props: { \"data-frame-css\": address }, children: css });\n const payload: FramePayload = {\n v: FRAME_VERSION,\n args,\n ...(frame.live === true ? { live: true } : {}),\n slots: slots.final(rendered.html, false),\n head,\n };\n return frameOpen(address, payload) + rendered.html + FRAME_CLOSE;\n}\n\n/** A frame the page says it has mounted, from the request's `x-barq-frames`. */\nexport interface MountedFrame {\n readonly id: string;\n readonly args: unknown;\n}\n\n/**\n * The frames a request says its page has mounted. Untrusted input like any\n * other: each one is asked for through its own function, validator and\n * middleware included, and a malformed list is no list.\n */\nexport function mountedFrames(header: string | null): MountedFrame[] {\n if (header === null || header === \"\") return [];\n let parsed: unknown;\n try {\n parsed = JSON.parse(header);\n } catch {\n return [];\n }\n if (!Array.isArray(parsed)) return [];\n const out: MountedFrame[] = [];\n for (const entry of parsed.slice(0, FRAMES_BUDGET)) {\n if (typeof entry !== \"object\" || entry === null) continue;\n const { id, args } = entry as { id?: unknown; args?: unknown };\n if (typeof id === \"string\") out.push({ id, args });\n }\n return out;\n}\n\n/**\n * A mutation's answer with the regions it changed: its value in a script, then\n * each changed frame's markup, as the page applies them. `ask` calls a mounted\n * frame's server function again with the arguments the page sent.\n */\nexport async function flightResponse(\n value: unknown,\n mounted: readonly MountedFrame[],\n invalidated: ReadonlySet<string>,\n ask: (frame: MountedFrame) => Promise<unknown>,\n): Promise<Response> {\n const seen = new Set<string>();\n let regions = \"\";\n for (const frame of mounted) {\n if (!invalidated.has(frame.id)) continue;\n const answered = await ask(frame);\n if (!isFrame(answered)) continue;\n const { address } = (answered as ServerFrame)[FRAME];\n if (seen.has(address)) continue;\n seen.add(address);\n regions += await frameMarkup(answered as ServerFrame);\n }\n const script = `<script type=\"${FLIGHT_TYPE}\">${JSON.stringify(encodeWire(value)).replaceAll(\"<\", \"\\\\u003c\")}</script>`;\n const answer = new Response(script + regions);\n answer.headers.set(\"content-type\", \"text/html; charset=utf-8\");\n answer.headers.set(\"cache-control\", \"no-store\");\n answer.headers.set(\"x-barq-rpc\", RPC_FLIGHT);\n return answer;\n}\n","/**\n * The server half of `live`: a call at the live address answered as server-sent\n * events, for as long as the answer stands.\n *\n * A frame is rendered again each time an async source it reads moves, and each\n * new rendering that differs from the last goes out as one event carrying the\n * frame's markup. Any other answer goes out a value per event. An answer whose\n * every source has ended says so with a `complete` event; a body that ends\n * without one is a connection that died, which the page's loop reconnects.\n *\n * Each event's id is the digest of what it carried. A reconnect names the last\n * one it applied in `Last-Event-ID`, and an answer that still matches it is not\n * sent again.\n */\n\nimport { SharedSources, shareSources, unshareSources } from \"@barqjs/core/internal\";\nimport { encodeWire } from \"@barqjs/server/codec\";\n\nimport { type ServerFrame, frameMarkup } from \"./frames-server.ts\";\nimport { isFrame } from \"./frames.ts\";\n\n/** The `x-barq-rpc` value a live answer carries. */\nexport const RPC_LIVE = \"live\";\n\n/** How often an idle connection says it is still there, against proxies that time one out. */\nconst HEARTBEAT_MS = 20_000;\n\nfunction digest(text: string): string {\n let hash = 0x811c9dc5;\n for (let at = 0; at < text.length; at++) {\n hash ^= text.charCodeAt(at);\n hash = Math.imul(hash, 0x01000193);\n }\n return (hash >>> 0).toString(36);\n}\n\nfunction isIterable(value: unknown): value is AsyncIterable<unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as AsyncIterable<unknown>)[Symbol.asyncIterator] === \"function\"\n );\n}\n\n/**\n * One event: its kind, an id, and data that is JSON and so carries no line\n * break of its own. A frame's markup is `frame`, a value the default kind.\n */\nfunction event(kind: \"frame\" | \"message\", id: string, data: string): string {\n return `${kind === \"frame\" ? \"event: frame\\n\" : \"\"}id: ${id}\\ndata: ${data}\\n\\n`;\n}\n\n/** The answer to a call at the live address. */\nexport function liveResponse(result: unknown, request: Request): Response {\n const encoder = new TextEncoder();\n const last = request.headers.get(\"last-event-id\");\n let controller: ReadableStreamDefaultController<Uint8Array> | null = null;\n let ended = false;\n const stops: (() => void)[] = [];\n const end = (complete: boolean): void => {\n if (ended) return;\n ended = true;\n for (const stop of stops) stop();\n if (controller === null) return;\n try {\n if (complete) controller.enqueue(encoder.encode(\"event: complete\\ndata: \\n\\n\"));\n controller.close();\n } catch {\n // The reader has gone.\n }\n };\n const send = (text: string): void => {\n if (ended || controller === null) return;\n try {\n controller.enqueue(encoder.encode(text));\n } catch {\n end(false);\n }\n };\n let sentId = last;\n const emit = (data: string, kind: \"frame\" | \"message\" = \"message\"): void => {\n const id = digest(data);\n if (id === sentId) return;\n sentId = id;\n send(event(kind, id, data));\n };\n\n const start = (): void => {\n const heartbeat = setInterval(() => send(\": still here\\n\\n\"), HEARTBEAT_MS);\n (heartbeat as { unref?: () => void }).unref?.();\n stops.push(() => clearInterval(heartbeat));\n const abort = (): void => end(false);\n request.signal.addEventListener(\"abort\", abort, { once: true });\n stops.push(() => request.signal.removeEventListener(\"abort\", abort));\n if (isFrame(result)) void frames(result as ServerFrame);\n else if (isIterable(result)) void values(result);\n else {\n emit(JSON.stringify(encodeWire(result)));\n end(true);\n }\n };\n\n const frames = async (frame: ServerFrame): Promise<void> => {\n const shared = new SharedSources();\n stops.push(() => shared.close());\n let rendering = false;\n let again = false;\n const render = async (): Promise<void> => {\n if (rendering) {\n again = true;\n return;\n }\n rendering = true;\n try {\n for (;;) {\n again = false;\n const session = Symbol(\"live-frame\");\n shared.begin();\n shareSources(session, shared);\n let markup: string;\n try {\n markup = await frameMarkup(frame, { session });\n } finally {\n unshareSources(session);\n }\n shared.sweep();\n if (ended) return;\n emit(JSON.stringify(markup), \"frame\");\n if (!again) break;\n }\n } catch (error) {\n console.error(\n \"[barq] A live frame failed to render, so its connection ends and the page reconnects. The error:\",\n error,\n );\n end(false);\n return;\n } finally {\n rendering = false;\n }\n if (shared.settled) end(true);\n };\n shared.onChange(() => void render());\n await render();\n };\n\n const values = async (source: AsyncIterable<unknown>): Promise<void> => {\n const iterator = source[Symbol.asyncIterator]();\n stops.push(() => void iterator.return?.());\n try {\n for (;;) {\n const step = await iterator.next();\n if (ended) return;\n if (step.done === true) break;\n emit(JSON.stringify(encodeWire(step.value)));\n }\n end(true);\n } catch (error) {\n console.error(\n \"[barq] A live answer failed while streaming, so its connection ends and the page reconnects. The error:\",\n error,\n );\n end(false);\n }\n };\n\n const body = new ReadableStream<Uint8Array>({\n start(given) {\n controller = given;\n start();\n },\n cancel() {\n end(false);\n },\n });\n const answer = new Response(body);\n answer.headers.set(\"content-type\", \"text/event-stream; charset=utf-8\");\n answer.headers.set(\"cache-control\", \"no-store\");\n answer.headers.set(\"x-accel-buffering\", \"no\");\n answer.headers.set(\"x-barq-rpc\", RPC_LIVE);\n return answer;\n}\n","/**\n * The request handler: one URL shape, one lookup, and the checks that run\n * before a handler body does.\n *\n * Every default here is the strict one, because the survey found the same four\n * failures composing across shipping frameworks — an unvalidated, CSRF-unchecked,\n * publicly-mounted endpoint reached by an id enumerable from the client bundle.\n * Each is cheap to close and expensive to retrofit.\n */\n\nimport { isDev, isSafeError } from \"@barqjs/core\";\nimport {\n commitEventResponse,\n commitResponseStub,\n createRequestEvent,\n isNavigable,\n} from \"@barqjs/web/internal\";\nimport { diagnosticsEnabled, emitDiagnostic } from \"@barqjs/core/internal\";\nimport { decodeWire, encodeWire } from \"@barqjs/server/codec\";\nimport { provideRequestEvent } from \"@barqjs/server/storage\";\nimport { createBodyTooLargeError, limitBodyStream } from \"srvx/body-limit\";\n\nimport {\n type ResponseDraft,\n applyResponseDraft,\n createResponseDraft,\n draftedStatus,\n invalidatedFrames,\n setRequestMiddlewareContext,\n} from \"./context.ts\";\nimport {\n NOT_FOUND,\n PAYLOAD_PARAM,\n REDIRECT,\n RPC_CALLER,\n RPC_CONTEXT,\n RPC_CONTROL,\n RPC_RESPONSE,\n RPC_THROWN,\n RPC_STREAM,\n type RpcControl,\n type RpcStreamLine,\n type ServerFnInputAnswer,\n type ServerFnIssue,\n type ServerFnThrown,\n} from \"./client.ts\";\nimport {\n type AnyServerFn,\n DATA_SUFFIX,\n LIVE_SUFFIX,\n type InputError,\n isInputError,\n RPC_PREFIX,\n type ServerFn,\n isServerFn,\n runRequestMiddleware,\n startOptions,\n takeSendContext,\n} from \"./index.ts\";\nimport { serverTiming } from \"./timing.ts\";\nimport {\n type ServerFrame,\n flightResponse,\n frameResponse,\n mountedFrames,\n serverFrame,\n} from \"./frames-server.ts\";\nimport { FRAMES_HEADER, installFrames, isFrame } from \"./frames.ts\";\nimport { liveResponse } from \"./live-server.ts\";\n\ninstallFrames(serverFrame as never);\n\n/**\n * id → function, and the ONLY way an id becomes callable.\n *\n * A `Map` rather than an object, because the id comes off the wire and an\n * object's prototype is reachable through one. A client-supplied name used as a\n * raw property access has shipped as a critical RCE elsewhere: asking for\n * `constructor` yields `Function`, and then arbitrary code. `Map.get`\n * has no prototype chain to walk into, so the guard is structural rather than a\n * `hasOwnProperty` call someone can later forget.\n */\ninterface Mounted {\n readonly registry: Map<string, ServerFn<unknown, unknown>>;\n /** How to mount the build's manifest, once something has said. */\n manifest: (() => Promise<unknown>) | null;\n}\n\n/**\n * ONE registry per process, whichever copy of this module asks.\n *\n * A build compiles this module INTO its server bundle, and a host that serves\n * that bundle through its own `serveBarq` has imported a second copy. Kept in\n * a module variable, each copy had a registry of its own: the bundle mounted\n * every function into one and the host answered 404 out of the other.\n */\nconst MOUNTED = ((globalThis as Record<symbol, unknown>)[Symbol.for(\"barq.start.server-fns\")] ??= {\n registry: new Map<string, ServerFn<unknown, unknown>>(),\n manifest: null,\n}) as Mounted;\n\nconst REGISTRY = MOUNTED.registry;\n\n/**\n * Say how the build's manifest is mounted, so a call can ask for it.\n *\n * The server entry imports the manifest when it first renders a page, which is\n * late for a function called before any page has been asked for: a server that\n * has just started and a browser tab that was already open. The id it names\n * was in no registry yet, and the answer was a 404 for a function that exists.\n */\nexport function mountOnDemand(manifest: () => Promise<unknown>): void {\n MOUNTED.manifest = manifest;\n}\n\n/**\n * Mount a server function. The compiler emits one call per EXPORTED server\n * function in a module compiled for the server.\n *\n * Export-ness is what decides reachability, which is SvelteKit's rule and the\n * only genuine notion of an internal server function in the survey: a\n * non-exported one is never registered, so it has no id and no endpoint, and is\n * still callable from its siblings.\n */\nexport function mount(id: string, fn: AnyServerFn): void {\n if (!isServerFn(fn))\n throw new TypeError(\n `[barq] \\`mount(${JSON.stringify(id)}, fn)\\` was given something that is not a server function, so there is nothing to answer calls with. Pass a function built with \\`createServerFn().handler(...)\\`.`,\n );\n if (id === \"\")\n throw new TypeError(\n \"[barq] `mount(id, fn)` was given an empty `id`, so no request could reach the function. Pass a non-empty string that is unique in the application.\",\n );\n // RE-MOUNTING AN ID REPLACES, and refusing it was a dev-server bug rather\n // than a safeguard. The generated manifest is invalidated whenever a\n // server-function module is transformed and re-imported on the next request,\n // while this registry lives in a module nothing invalidates — so the second\n // evaluation was refusing ids the first had legitimately claimed, and every\n // page answered 500 after the first edit.\n //\n // Nothing is lost by replacing: an id is `<root-relative file>#<export>`, so\n // two DISTINCT functions can only collide if two paths normalise to one, and\n // the manifest generator refuses that where it can see the whole set at once.\n // Here there is no second set to compare against — only the same module,\n // again, newer.\n // Stamped rather than read. The compiler leaves the SERVER half of a module\n // alone — it is the module, compiled — so the builder has no id of its own;\n // the id lives in the manifest the build generates, and mounting is where the\n // two meet. `formAttr` reads it back off the function to write a form's\n // action, so a function that is mounted has a URL and one that is not has\n // neither an id nor an endpoint.\n fn.meta.id = id;\n REGISTRY.set(id, fn);\n}\n\n/** The mounted surface, for the build to record and a reviewer to read. */\nexport function mounted(): string[] {\n return [...REGISTRY.keys()].toSorted();\n}\n\n/**\n * The function mounted at an id, or `undefined`.\n *\n * Exported for the BUILD's chain check, which has to ask each reachable id what\n * middleware it actually carries. It reads the registry inside whichever bundle\n * it is called from, which is why the check runs through the server entry\n * rather than from the Vite plugin: `resolve.noExternal` compiles `@barqjs/*`\n * INTO the ssr bundle, so a plugin importing this module would be asking a\n * second, empty registry.\n */\nexport function mountedFn(id: string): ServerFn<unknown, unknown> | undefined {\n return REGISTRY.get(id);\n}\n\n/** Test seam. Not for application use. */\nexport function unmountAll(): void {\n REGISTRY.clear();\n MOUNTED.manifest = null;\n}\n\nexport interface HandlerOptions {\n /**\n * Origins allowed to call, beyond the request's own. Same-origin is always\n * allowed; this widens it.\n */\n allowedOrigins?: readonly string[];\n /**\n * The largest body a call may send, in bytes. 1 MiB when omitted.\n *\n * Enforced on the bytes as they are read, and answered with a 413. The body\n * is parsed BEFORE the chain runs, so this is the only thing standing between\n * a caller no middleware has seen yet and the server's memory.\n *\n * srvx's `maxRequestBodySize` is the same idea for the whole server and has\n * no default; this one is for the server-function channel alone, so it holds\n * under a handler that srvx is not in front of.\n */\n maxBodySize?: number;\n /**\n * The largest FORM body, multipart or urlencoded. `maxBodySize` when omitted.\n *\n * Apart from it because a file upload is the one body that legitimately\n * outgrows the default, and raising `maxBodySize` to admit one would widen\n * the value channel by the same amount for no caller that needs it. A form is\n * parsed whole into memory, so this is what one request can make the server\n * hold.\n */\n maxFormSize?: number;\n /**\n * What a failed call may tell its caller about the error, beyond its status.\n *\n * Only the development server passes it, so a production server answers a\n * handler's failure with the status and a fixed line and nothing of the\n * error: its message can name a table, a column or a path. In development the\n * caller is the developer, and the error's name, message and stack (mapped\n * to source by the dev server) are what make the failure debuggable from the\n * browser.\n */\n revealError?: (error: unknown) => ServerFnThrown;\n /**\n * Whether some route in this application can reach this id.\n *\n * The narrow half of the route-action manifest. Export-ness already decides\n * what is MOUNTED, and that is deliberately generous — a server function\n * exported for a sibling to import is mounted whether or not any page calls\n * it. Next.js concedes the consequence in its own release notes: \"Even if a\n * Server Action or utility function is not imported elsewhere in your code,\n * it's still a publicly accessible HTTP endpoint.\"\n *\n * This closes that: an id no route reaches answers the 404 an unknown id\n * already answers, so the two are indistinguishable from outside.\n *\n * It takes NO route from the caller, deliberately. A client-supplied route\n * selecting a policy lets the caller pick the weakest one that reaches the\n * action, and this file's own rule says why that is not allowed — values\n * derived from the request are fine to navigate to and never fine to\n * authorize with. Which CHAIN runs is decided at build time by\n * `@barqjs/router`, not here and not per request.\n */\n reachable?: (id: string) => boolean;\n}\n\n/**\n * Is this request allowed to invoke a server function?\n *\n * `Origin` first, then `Sec-Fetch-Site` when `Origin` is absent. That fallback\n * is Waku's post-CVE shape and it is the strictest default found: `Origin` is\n * legitimately absent on some same-origin requests and on non-browser clients,\n * while `Sec-Fetch-Site` is sent by every modern browser and cannot be forged\n * from script. Next.js warns and PROCEEDS on a missing `Origin`; this refuses.\n */\nexport function originAllowed(request: Request, options?: HandlerOptions): boolean {\n const origin = request.headers.get(\"origin\");\n if (origin !== null) {\n // A sandboxed iframe sends the literal string, so it is refused rather than\n // read as absent and fallen through.\n if (origin === \"null\") return false;\n if (origin === new URL(request.url).origin) return true;\n return options?.allowedOrigins?.includes(origin) ?? false;\n }\n const site = request.headers.get(\"sec-fetch-site\");\n if (site === null) return false;\n return site === \"same-origin\" || site === \"none\";\n}\n\n/** Methods that cannot change state, so CSRF does not apply to them. */\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\n/**\n * Is this a request a BROWSER made from another origin?\n *\n * A DIFFERENT QUESTION FROM `originAllowed`, and the difference is the whole\n * design. `originAllowed` guards `/_barq/fn/*`, which only ever exists to be\n * called by this application's own pages — so a request with no origin signal at\n * all is refused there, because there is no legitimate caller that omits one.\n *\n * A route handler is the opposite: an API route exists so that something OTHER\n * than a browser can call it. A Stripe webhook, a GitHub delivery, a cron\n * hitting it with curl — none of them send `Origin` or `Sec-Fetch-Site`, and\n * refusing on their absence would refuse the main reason API routes exist.\n *\n * So this answers the narrower question, and the narrower question is the one\n * CSRF actually asks. A cross-site forgery is by definition made BY A BROWSER\n * with the victim's cookies attached, and a browser making a cross-origin\n * state-changing request always says so — `Origin` on any cross-origin POST\n * since forever, `Sec-Fetch-Site` on everything in every current browser. So:\n * refuse when a signal is present and says cross-origin; allow when there is no\n * signal, because then it is not a browser and cannot be a forgery.\n *\n * `null` origin — a sandboxed iframe, a `data:` URL — is refused rather than\n * read as absent, which is a bypass that has shipped.\n */\nexport function crossOriginRefused(request: Request, allowedOrigins?: readonly string[]): boolean {\n if (SAFE_METHODS.has(request.method.toUpperCase())) return false;\n\n const origin = request.headers.get(\"origin\");\n if (origin !== null) {\n if (origin === \"null\") return true;\n if (origin === new URL(request.url).origin) return false;\n return !(allowedOrigins?.includes(origin) ?? false);\n }\n\n const site = request.headers.get(\"sec-fetch-site\");\n // No signal at all: not a browser, so not a forgery.\n if (site === null) return false;\n return site !== \"same-origin\" && site !== \"none\";\n}\n\n/**\n * Handle one server-function request, or return null if the URL is not one.\n *\n * Returning null rather than a 404 is what lets this compose as middleware in\n * front of a page handler.\n */\nexport async function handleServerFn(\n request: Request,\n options?: HandlerOptions,\n): Promise<Response | null> {\n const url = new URL(request.url);\n if (!url.pathname.startsWith(RPC_PREFIX)) return null;\n\n // A mutation must not be reachable by navigation. RedwoodSDK shipped server\n // functions invocable over GET, which made a plain link a one-click mutation\n // carrying SameSite=Lax cookies. A GET reaches only a function that asked for\n // it, and only with the header no link can send; both are checked below.\n const method = request.method;\n if (method !== \"POST\" && method !== \"GET\") {\n return new Response(\"method not allowed\", { status: 405, headers: { allow: \"GET, POST\" } });\n }\n if (!originAllowed(request, options)) return new Response(\"forbidden\", { status: 403 });\n\n // The URL decides the shape, so a form and an RPC call cannot be confused for\n // one another by a header either of them can set.\n const path = url.pathname.slice(RPC_PREFIX.length);\n // The live address answers what the data address does, framed as events for\n // as long as the answer stands. Only `live`'s loop calls it.\n const isLive = path.endsWith(LIVE_SUFFIX);\n const isData = isLive || path.endsWith(DATA_SUFFIX);\n let id: string;\n try {\n id = decodeURIComponent(\n isLive\n ? path.slice(0, -LIVE_SUFFIX.length)\n : isData\n ? path.slice(0, -DATA_SUFFIX.length)\n : path,\n );\n } catch {\n // Not percent-encoding at all, so it names nothing.\n return new Response(\"bad request\", { status: 400 });\n }\n\n let fn = REGISTRY.get(id);\n if (fn === undefined && MOUNTED.manifest !== null) {\n await MOUNTED.manifest();\n fn = REGISTRY.get(id);\n }\n if (fn === undefined) return new Response(\"not found\", { status: 404 });\n // Same answer as an unknown id, so a caller cannot tell a function that\n // exists but is unrouted from one that does not exist.\n if (options?.reachable?.(id) === false) return new Response(\"not found\", { status: 404 });\n // The function's own method, and only on the channel that can carry it: a\n // form is a POST, so a GET function has the data channel alone.\n const expected = fn.meta.method ?? \"POST\";\n if (method !== expected) {\n return new Response(\"method not allowed\", { status: 405, headers: { allow: expected } });\n }\n if (method === \"GET\") {\n if (!isData) return new Response(\"not found\", { status: 404 });\n if (request.headers.get(RPC_CALLER) === null) return new Response(\"forbidden\", { status: 403 });\n }\n\n const bodyLimit = options?.maxBodySize ?? DEFAULT_BODY_LIMIT;\n const target = fn;\n // The draft the handler writes to through `setCookie` / `setResponseHeader`,\n // held HERE because the response is built after the handler has returned.\n const draft = createResponseDraft();\n\n /**\n * The call itself: read the body, run the function, build the answer. The\n * innermost step of the request middleware chain, so a global middleware\n * that refuses does so before a byte of the payload has been parsed.\n */\n const respond = async (): Promise<Response> => {\n let input: unknown;\n let clientContext: Record<string, unknown> | undefined;\n if (isData && (method === \"GET\" || !isFormBody(request))) {\n try {\n const body = (\n method === \"GET\" ? queryPayload(url, bodyLimit) : await capped(request, bodyLimit).json()\n ) as {\n input?: unknown;\n context?: unknown;\n };\n input = body?.input === undefined ? undefined : decodeWire(body.input);\n // WHAT THE CLIENT HALVES SENT, and it is UNTRUSTED — a caller writes this\n // body by hand as readily as the stub does. It reaches a server half as\n // `clientContext` and is never merged into `context`; `serverRpc` says\n // what merging it would let through. Spread, so a body that put a string\n // or a list here still hands the chain an object.\n clientContext =\n body?.context === undefined ? undefined : { ...(decodeWire(body.context) as object) };\n } catch (error) {\n return unreadable(error);\n }\n } else {\n try {\n input = await capped(request, options?.maxFormSize ?? bodyLimit).formData();\n } catch (error) {\n return unreadable(error);\n }\n }\n\n try {\n // `{ data }` on the value channel; a bare `FormData` on the form one, which\n // is the shape `<form action={fn}>` hands the function on the enhanced path\n // — so a handler sees the same input type whether or not JS ran.\n // `sendContext` is taken INSIDE the request context, because that is where\n // the function's chain left it: each request has its own, so two calls that\n // settle together cannot read one another's.\n const result = await (input instanceof FormData\n ? target(input)\n : (target as (o: unknown, c?: Record<string, unknown>) => Promise<unknown>)(\n { data: input },\n clientContext,\n ));\n const sendContext = takeSendContext();\n if (isLive) {\n if (result instanceof Response) return applyResponseDraft(result, draft);\n return applyResponseDraft(liveResponse(result, request), draft);\n }\n // A RETURNED RESPONSE IS HONOURED ON BOTH CHANNELS, and it did not used to\n // be: the value channel handed it to `encodeWire`, which answered\n // `Seroval Error (step: 1)` and a 500 with nothing in it. So a function that\n // set a cookie by returning a response worked with JS disabled and crashed\n // with JS enabled — the one divergence the form path exists to prevent.\n if (result instanceof Response) {\n // The data channel's client reads every other answer as a wire value, so\n // this one says it is not. A browser following a form needs no telling.\n if (isData) draft.headers.set(RPC_CONTROL, RPC_RESPONSE);\n return applyResponseDraft(result, draft);\n }\n // A component is a frame: the region it renders, for the page to apply.\n // A browser following a form has no page to apply it to.\n if (isFrame(result)) {\n if (isData) return applyResponseDraft(await frameResponse(result as ServerFrame), draft);\n return applyResponseDraft(seeOther(request), draft);\n }\n if (isIterable(result)) {\n if (isData) {\n return applyResponseDraft(streamed(result, sendContext, id, revealerOf(options)), draft);\n }\n // A browser following a form has nothing to read a stream with, so the\n // function is told nobody is listening and the form goes back.\n void result[Symbol.asyncIterator]().return?.();\n return applyResponseDraft(seeOther(request), draft);\n }\n if (isData) {\n // `draftedStatus` here and NOT inside `applyResponseDraft`, because the\n // two answer different questions: this response is the framework's to\n // build, so `setResponseStatus(201)` decides it — where a response the\n // handler RETURNED has already decided for itself.\n const answer = draftedStatus(draft, 200);\n // SINGLE FLIGHT: a mutation that said which frames it changed answers\n // with them, rendered again for the arguments the page has them\n // mounted with, beside its value. Each is asked for through its own\n // function, so its validator and its middleware decide as for a call.\n const mountedHere = mountedFrames(request.headers.get(FRAMES_HEADER));\n const changed = invalidatedFrames();\n if (mountedHere.length > 0 && changed.size > 0) {\n const flight = await flightResponse(\n Object.keys(sendContext).length === 0 ? result : { result, context: sendContext },\n mountedHere,\n changed,\n async (frame) => {\n const asked = REGISTRY.get(frame.id);\n if (asked === undefined || options?.reachable?.(frame.id) === false) return undefined;\n try {\n return await (asked as (o: unknown) => Promise<unknown>)({\n data: frame.args === undefined ? undefined : decodeWire(frame.args),\n });\n } catch (error) {\n console.error(\n `[barq] The frame of ${JSON.stringify(frame.id)} could not be rendered again for the mutation ${JSON.stringify(id)}, so its answer leaves it out. The error:`,\n error,\n );\n return undefined;\n }\n },\n );\n if (Object.keys(sendContext).length > 0) flight.headers.set(RPC_CONTEXT, \"1\");\n return applyResponseDraft(\n new Response(flight.body, { ...answer, headers: flight.headers }),\n draft,\n );\n }\n // The ordinary shape is the RESULT and nothing around it. A chain that\n // sent something back gets the envelope instead, flagged by a header, so\n // a call that sends nothing pays neither the wrapper nor a second parse.\n if (Object.keys(sendContext).length === 0) {\n return applyResponseDraft(Response.json(encodeWire(result), answer), draft);\n }\n return applyResponseDraft(\n Response.json(encodeWire({ result, context: sendContext }), {\n ...answer,\n headers: { [RPC_CONTEXT]: \"1\" },\n }),\n draft,\n );\n }\n // Otherwise the browser goes back where it came from, which is what makes\n // the no-JS path a round trip rather than a dead end.\n return applyResponseDraft(seeOther(request), draft);\n } catch (error) {\n // A middleware rejects by throwing a Response — `throw new Response(\"\", {\n // status: 401 })` — and it is returned as it stands.\n // The draft rides an error out as well. A middleware that rotated a session\n // cookie and THEN refused must not lose the rotation — the browser would\n // keep replaying a token the server has already retired.\n if (error instanceof Response) return thrownAnswer(error, isData, draft);\n // `throw redirect(...)` and `throw notFound()` are ANSWERS, and a server\n // function is entitled to both — a handler that finds the session expired\n // redirects to the login page, and one asked for a row that is gone says\n // so. Left to the catch-all below they would be a 500 with nothing in it,\n // and the two most ordinary control-flow throws in the framework would be\n // the two it could not carry.\n const control = controlOf(error);\n if (control !== null) {\n return applyResponseDraft(\n controlResponse(control, isData, (error as { headers?: unknown }).headers),\n draft,\n );\n }\n // A validation failure is the caller's fault and says so, with what was\n // wrong with each field: the issues describe the caller's own input, so a\n // form can show them. Anything else is reported without a body: a\n // handler's message can name a table, a column or a path, and none of that\n // is the caller's business.\n if (isInputError(error)) {\n return applyResponseDraft(\n isData\n ? Response.json(inputAnswer(error), { status: 400 })\n : new Response(\"invalid input\", { status: 400 }),\n draft,\n );\n }\n return applyResponseDraft(failed(id, error, isData, options, \"threw\"), draft);\n }\n };\n\n // AFTER the method, the origin and the id have been checked, never before: a\n // forged or mistyped call is refused above without a middleware having run\n // for it, so it costs nothing and reaches nothing.\n const context: Record<string, unknown> = {};\n const timing = isDev ? serverTiming() : undefined;\n const event = createRequestEvent(request, { response: draft });\n try {\n const response = await provideRequestEvent(event, () => {\n setRequestMiddlewareContext(context);\n return runRequestMiddleware(\n startOptions().requestMiddleware ?? [],\n { request, pathname: url.pathname, handlerType: \"serverFn\", context },\n respond,\n );\n });\n if (timing !== undefined) {\n timing.phase(\"barq-fn\", id);\n draft.headers.append(\"server-timing\", timing.header());\n }\n return commitEventResponse(response, event);\n } catch (error) {\n // A request middleware refuses the way a function's own does.\n if (error instanceof Response)\n return commitEventResponse(thrownAnswer(error, isData, draft), event);\n return commitEventResponse(failed(id, error, isData, options, \"middleware\"), event);\n } finally {\n commitResponseStub(draft, { event });\n }\n}\n\n/**\n * The 400 a refused input answers with: the refusal and each issue with the\n * path to the field it is about.\n */\nfunction inputAnswer(error: InputError): ServerFnInputAnswer {\n const issues = (error as { issues?: ReadonlyArray<unknown> }).issues ?? [];\n return {\n error: \"invalid input\",\n message: error.message,\n issues: issues.map((issue): ServerFnIssue => {\n const { message, path } = (issue ?? {}) as { message?: unknown; path?: unknown };\n const keys = Array.isArray(path)\n ? path.map((segment: unknown) => {\n const key =\n typeof segment === \"object\" && segment !== null && \"key\" in segment\n ? segment.key\n : segment;\n return typeof key === \"number\" ? key : String(key);\n })\n : [];\n return keys.length === 0\n ? { message: String(message) }\n : { message: String(message), path: keys };\n }),\n };\n}\n\n/**\n * What a failed call may tell its caller: everything the development server\n * asks for, and in production only an error the application branded with\n * `markSafeError`, by its name and message.\n */\nfunction revealerOf(\n options: HandlerOptions | undefined,\n): (error: unknown) => ServerFnThrown | undefined {\n const reveal = options?.revealError;\n return (error) => {\n if (reveal !== undefined) return reveal(error);\n if (!(error instanceof Error) || !isSafeError(error)) return undefined;\n return { name: error.name, message: error.message };\n };\n}\n\n/**\n * A call that failed on the server: logged there, reported on the diagnostics\n * channel, and answered 500. The caller learns what was thrown only when the\n * development server asked for it.\n */\nfunction failed(\n id: string,\n error: unknown,\n isData: boolean,\n options: HandlerOptions | undefined,\n where: \"threw\" | \"middleware\",\n): Response {\n const thrown = revealerOf(options)(error);\n const happened =\n where === \"threw\"\n ? `The server function ${JSON.stringify(id)} threw`\n : `A request middleware threw before the server function ${JSON.stringify(id)} ran`;\n if (diagnosticsEnabled()) reportFailure(id, error, happened);\n console.error(\n `[barq] ${happened}, so the call answered 500${thrown === undefined ? \" without the error's text\" : \"\"}. The error:`,\n error,\n );\n if (thrown === undefined) return new Response(\"internal server error\", { status: 500 });\n return isData\n ? Response.json({ error: \"internal server error\", thrown }, { status: 500 })\n : new Response(\n `internal server error\\n\\n${thrown.stack ?? `${thrown.name}: ${thrown.message}`}`,\n {\n status: 500,\n },\n );\n}\n\nfunction reportFailure(id: string, error: unknown, happened: string): void {\n const text = error instanceof Error ? `${error.name}: ${error.message}` : String(error);\n emitDiagnostic(\n {\n code: \"SERVER_FUNCTION_FAILED\",\n kind: \"ssr\",\n severity: \"error\",\n message:\n `${happened}: \\`${text}\\`. The caller received a 500. Fix the throw at the top of the ` +\n \"stack, or throw a `Response`, `redirect()` or `notFound()` to answer the caller on purpose.\",\n data: { id, error },\n },\n null,\n );\n}\n\n/**\n * A `Response` the chain or the handler threw, as the answer. The data\n * channel's client rejects the call with it, so the header says it was thrown\n * rather than returned; a browser following a form needs no telling.\n */\nfunction thrownAnswer(error: Response, isData: boolean, draft: ResponseDraft): Response {\n if (isData) draft.headers.set(RPC_CONTROL, RPC_THROWN);\n return applyResponseDraft(error, draft);\n}\n\n/**\n * Read a thrown value as a control answer, by BRAND rather than by class.\n *\n * The classes are `@barqjs/router`'s and this package cannot import them; see\n * {@link REDIRECT}. A brand check is also what lets the same code recognise a\n * redirect the router threw and one `@barqjs/start/client` rebuilt off the\n * wire, which matters when a server function calls another one.\n */\nfunction controlOf(error: unknown): RpcControl | null {\n if (typeof error !== \"object\" || error === null) return null;\n const branded = error as Record<symbol, unknown> & {\n to?: unknown;\n status?: unknown;\n options?: unknown;\n data?: unknown;\n routeId?: unknown;\n };\n if (branded[REDIRECT] === true) {\n // The shape is checked rather than trusted: the brand says what this claims\n // to be, and a `to` that is not a string would put `undefined` in a\n // `Location` header.\n if (typeof branded.to !== \"string\") return null;\n const status = typeof branded.status === \"number\" ? branded.status : 302;\n const options = describedNavigation(branded.options);\n return {\n kind: \"redirect\",\n to: branded.to,\n status,\n ...(options === undefined ? {} : { options: encodeWire(options) }),\n };\n }\n if (branded[NOT_FOUND] === true) {\n const message = (error as { message?: unknown }).message;\n return {\n kind: \"not-found\",\n message: typeof message === \"string\" ? message : \"not found\",\n ...(branded.data === undefined ? {} : { data: encodeWire(branded.data) }),\n ...(typeof branded.routeId === \"string\" ? { routeId: branded.routeId } : {}),\n };\n }\n return null;\n}\n\n/** The parts of a navigation that are values, and so can be sent. */\nconst NAVIGATION = [\"to\", \"from\", \"params\", \"search\", \"hash\", \"replace\", \"reloadDocument\", \"href\"];\n\n/**\n * The navigation an options-form redirect described, as far as it can cross.\n *\n * A function among them cannot: `search: (current) => ...` is asked about a\n * location only the browser has. A redirect holding one is sent as its resolved\n * target alone, which is what every redirect was sent as before this existed.\n * `statusCode` and `headers` are the answer rather than the navigation, and\n * travel as the status and on the response.\n */\nfunction describedNavigation(described: unknown): Record<string, unknown> | undefined {\n if (typeof described !== \"object\" || described === null) return undefined;\n const given = described as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const name of NAVIGATION) {\n const value = given[name];\n if (value === undefined) continue;\n if (typeof value === \"function\") return undefined;\n out[name] = value;\n }\n if (typeof given.statusCode === \"number\") out.statusCode = given.statusCode;\n return out;\n}\n\n/**\n * A control answer, on whichever channel asked.\n *\n * THE TWO CHANNELS DIVERGE HERE ON PURPOSE, because their clients are different\n * programs. The form channel's client is a BROWSER following the response\n * itself, so a redirect has to be a real 3xx with a `Location`. The data\n * channel's client is `clientRpc`, and a real 3xx there would be FOLLOWED by\n * `fetch` — the caller would receive the target page's HTML instead of a\n * navigation. So the data channel answers 200 and describes the redirect in the\n * body, and the client re-throws it for the router to act on. That is a soft\n * navigation rather than a document load, which is both correct and faster;\n * TanStack returns the raw 3xx and the fetch follows it.\n *\n * `not-found` is a 404 on both, because 404 is the honest status and no client\n * follows one.\n *\n * `extra` is the thrown value's own `headers`, which are the response's on\n * either channel: a redirect that signs a visitor out carries the cookie that\n * does it.\n */\nfunction controlResponse(control: RpcControl, isData: boolean, extra?: unknown): Response {\n const headers = answerHeaders(extra);\n if (control.kind === \"not-found\") {\n if (!isData) return new Response(control.message, { status: 404, headers });\n headers.set(RPC_CONTROL, control.kind);\n return Response.json(control, { status: 404, headers });\n }\n if (!isNavigable(control.to)) {\n reportRefusedRedirect(control.to);\n return new Response(\"bad redirect\", { status: 500 });\n }\n if (isData) {\n headers.set(RPC_CONTROL, control.kind);\n return Response.json(control, { status: 200, headers });\n }\n // 303 unless the handler asked for something else, so the browser re-issues\n // as GET and a reload does not repost — the same reason `seeOther` below is\n // 303. A handler that set an explicit status gets the one it set.\n const status = control.status === 302 ? 303 : control.status;\n headers.set(\"location\", control.to);\n return new Response(null, { status, headers });\n}\n\n/** A thrown answer's `headers`, or none when it carried nothing a response can take. */\nfunction answerHeaders(extra: unknown): Headers {\n if (extra === undefined || extra === null) return new Headers();\n try {\n return new Headers(extra as HeadersInit);\n } catch {\n return new Headers();\n }\n}\n\nfunction reportRefusedRedirect(to: string): void {\n console.error(\n `[barq] A server function threw \\`redirect(${JSON.stringify(to)})\\`, which is not a path or an \\`http(s)\\` URL, so the redirect was refused and the call answered 500. ` +\n \"Validate the value passed to `redirect()` before using it, especially when it comes from the request.\",\n );\n}\n\nfunction isIterable(value: unknown): value is AsyncIterable<unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as Partial<AsyncIterable<unknown>>)[Symbol.asyncIterator] === \"function\"\n );\n}\n\n/**\n * An answer that arrives over time: one JSON line for each value yielded.\n *\n * Produced from `start`, so the function keeps running inside the request it\n * was called for: a `pull` is made from wherever the body is read, where there\n * is no request. It waits to be asked all the same, so a reader that falls\n * behind holds the function at its next `yield` rather than filling memory.\n *\n * A failure after the first value cannot become a status, so it is one last\n * line that says so and nothing else: a handler's message can name a table, a\n * column or a path.\n */\nfunction streamed(\n values: AsyncIterable<unknown>,\n sendContext: Record<string, unknown>,\n id: string,\n reveal: (error: unknown) => ServerFnThrown | undefined,\n): Response {\n const encoder = new TextEncoder();\n const line = (payload: RpcStreamLine): Uint8Array =>\n encoder.encode(`${JSON.stringify(payload)}\\n`);\n const source = values[Symbol.asyncIterator]();\n let wanted: (() => void) | null = null;\n let cancelled = false;\n\n const produce = async (\n controller: ReadableStreamDefaultController<Uint8Array>,\n ): Promise<void> => {\n try {\n if (Object.keys(sendContext).length > 0) {\n controller.enqueue(line({ c: encodeWire(sendContext) }));\n }\n for (;;) {\n if ((controller.desiredSize ?? 1) <= 0) {\n await new Promise<void>((resolve) => {\n wanted = resolve;\n });\n }\n if (cancelled) return;\n const next = await source.next();\n if (cancelled || next.done === true) break;\n controller.enqueue(line({ v: encodeWire(next.value) }));\n }\n if (!cancelled) controller.close();\n } catch (error) {\n if (cancelled) return;\n const thrown = reveal(error);\n const happened = `The server function ${JSON.stringify(id)} threw while streaming its result`;\n if (diagnosticsEnabled()) reportFailure(id, error, happened);\n console.error(\n `[barq] ${happened}, so the stream ended early and the caller receives a \\`ServerFnError\\`. The error:`,\n error,\n );\n controller.enqueue(line(thrown === undefined ? { e: 1 } : { e: 1, t: thrown }));\n controller.close();\n }\n };\n\n const body = new ReadableStream<Uint8Array>({\n start(controller) {\n void produce(controller);\n },\n pull() {\n const waiting = wanted;\n wanted = null;\n waiting?.();\n },\n cancel() {\n cancelled = true;\n const waiting = wanted;\n wanted = null;\n waiting?.();\n void source.return?.();\n },\n });\n return new Response(body, {\n headers: {\n \"content-type\": \"application/x-ndjson; charset=utf-8\",\n \"cache-control\": \"no-store\",\n [RPC_CONTROL]: RPC_STREAM,\n },\n });\n}\n\nconst DEFAULT_BODY_LIMIT = 1024 * 1024;\n\n/**\n * The request's body behind a cap, as something that can still be parsed.\n *\n * The declared length is only the early exit. A chunked request declares none\n * and a header can understate, so the stream is counted as it is read and\n * errors the moment it passes the limit, with the rest left unread.\n *\n * A `Response` carrying the content type, because that is what parses a\n * multipart body: the boundary is in the header, and srvx's own\n * `limitRequestBody` drops it and so cannot read a form.\n */\nfunction capped(request: Request, limit: number): Response {\n if (Number(request.headers.get(\"content-length\")) > limit) throw createBodyTooLargeError(limit);\n const type = request.headers.get(\"content-type\");\n return new Response(\n request.body === null ? null : limitBodyStream(request.body, limit),\n type === null ? undefined : { headers: { \"content-type\": type } },\n );\n}\n\n/**\n * A GET call's payload: the body a POST would have sent, in `?payload=`.\n *\n * Held to the body limit, since a URL is a body a caller chose the size of,\n * and refused as a 413 the way an oversized body is.\n */\nfunction queryPayload(url: URL, limit: number): unknown {\n const payload = url.searchParams.get(PAYLOAD_PARAM);\n if (payload === null) return {};\n if (payload.length > limit) throw createBodyTooLargeError(limit);\n return JSON.parse(payload);\n}\n\n/**\n * What a body that could not be read is answered with.\n *\n * By the error's code and not by who threw it: a server in front that enforces\n * `maxRequestBodySize` fails the read with the same error, and that caller is\n * owed the same 413.\n */\nfunction unreadable(error: unknown): Response {\n return (error as { code?: unknown } | null)?.code === \"ERR_BODY_TOO_LARGE\"\n ? new Response(\"payload too large\", { status: 413 })\n : new Response(\"bad request\", { status: 400 });\n}\n\n/**\n * Whether the body is a form rather than a value. The enhanced path posts\n * `FormData` to the data channel so that a handler sees the SAME input type\n * whether or not JS ran.\n */\nfunction isFormBody(request: Request): boolean {\n const type = request.headers.get(\"content-type\") ?? \"\";\n return type.includes(\"multipart/form-data\") || type.includes(\"application/x-www-form-urlencoded\");\n}\n\n/**\n * Back where the form was. 303 and not 302, so the browser re-issues as GET and\n * a reload does not repost — the POST/redirect/GET the no-JS path exists for.\n *\n * `Referer` is used only as a destination and never as a decision. SvelteKit's\n * docs make the distinction for the same reason: values derived from the\n * request are fine to navigate to and never fine to authorize with.\n */\nfunction seeOther(request: Request): Response {\n const referer = request.headers.get(\"referer\");\n const origin = new URL(request.url).origin;\n let location = \"/\";\n if (referer !== null) {\n try {\n const target = new URL(referer);\n // An off-site Referer would make this an open redirect.\n if (target.origin === origin) {\n const path = target.pathname + target.search;\n // A path that opens `//` is another HOST to a browser handed it alone,\n // and `/\\` parses to the same thing. Written with its origin it can only\n // be what it was: a path on this one.\n location = path.startsWith(\"//\") ? origin + path : path;\n }\n } catch {\n // A malformed Referer is not a destination.\n }\n }\n return new Response(null, { status: 303, headers: { location } });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgEA,MAAM,gBAAgB;CACpB,KAAK;CACL,MAAM;CACN,iBAAiB,WAAkC;EACjD,IAAI,MAAM,MAAM,CAAC;EACjB,SAAS,MAAM,MAAM,CAAC;CACxB;CACA,mBAAmB,QAA4B;AACjD;AAEA,SAAS,uBAA6B;CACpC,IAAI,sBAAsB,CAAC,CAAC,MAAM,YAAY,QAAQ,QAAQ,cAAc,GAAG,GAAG;CAClF,8BAA8B,CAAC,aAAa,CAAC;AAC/C;;AAGA,SAAgB,YAAY,IAAY,MAAe,WAAyC;CAC9F,qBAAqB;CAGrB,MAAM,OAAO,SAAS,KAAA,IAAY,KAAA,IAAY,WAAW,IAAI;CAC7D,MAAM,UAAU,aAAa,IAAI,WAAW,QAAQ,IAAI,CAAC;CACzD,MAAM,QAAmC;EACvC;EACA;EACA;EACA;EACA,SAAS,YAAY,aAAa,OAAO,OAAO;CAClD;CACA,MAAM,UAAU,UACd,cAAc,SAAS,MAAM,WAAW,OAAO,MAAM,SAAS,IAAI;CACpE,OAAO,OAAO,OAAO,QAAQ,GAAG,QAAQ,MAAM,CAAC;AACjD;;AAGA,SAAS,QAAQ,UAA4B;CAC3C,OAAO,OAAO,aAAa,aAA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