Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

constants.ts

64 lines2.2 KB

1export const TSS_FORMDATA_CONTEXT = '__TSS_CONTEXT'
2export const TSS_SERVER_FUNCTION = Symbol.for('TSS_SERVER_FUNCTION')
3export const TSS_SERVER_FUNCTION_FACTORY = Symbol.for(
4 'TSS_SERVER_FUNCTION_FACTORY',
5)
6​
7export const X_TSS_SERIALIZED = 'x-tss-serialized'
8export const X_TSS_RAW_RESPONSE = 'x-tss-raw'
9export const X_TSS_CONTEXT = 'x-tss-context'
10​
11/** Content-Type for multiplexed framed responses (RawStream support) */
12export const TSS_CONTENT_TYPE_FRAMED = 'application/x-tss-framed'
13​
14/**
15 * Frame types for binary multiplexing protocol.
16 */
17export const FRAME_TYPE_JSON = 0
18export const FRAME_TYPE_CHUNK = 1
19export const FRAME_TYPE_END = 2
20export const FRAME_TYPE_ERROR = 3
21​
22/** Header size in bytes: type(1) + streamId(4) + length(4) */
23export const FRAME_HEADER_SIZE = 9
24​
25/** Largest payload accepted by one framed-protocol record. */
26export const MAX_FRAME_PAYLOAD_SIZE = 16 * 1024 * 1024
27​
28/** Largest number of raw streams accepted in one framed response. */
29export const MAX_FRAMED_STREAMS = 1024
30​
31/**
32 * Largest number of bytes one raw stream may hold unread. Raw streams share
33 * one ordered response, so an unread stream would otherwise buffer without
34 * bound while later frames arrive.
35 */
36export const MAX_UNREAD_RAW_STREAM_BYTES = 128 * 1024 * 1024
37​
38/** Current protocol version for framed responses */
39export const TSS_FRAMED_PROTOCOL_VERSION = 1
40​
41/** Full Content-Type header value with version parameter */
42export const TSS_CONTENT_TYPE_FRAMED_VERSIONED = `${TSS_CONTENT_TYPE_FRAMED}; v=${TSS_FRAMED_PROTOCOL_VERSION}`
43​
44/**
45 * Minimal metadata about a server function, available to client middleware.
46 * Only contains the function ID since name/filename may expose server internals.
47 */
48export interface ClientFnMeta {
49 /** The unique identifier for this server function */
50 id: string
52​
53/**
54 * Full metadata about a server function, available to server middleware and server functions.
55 * This information is embedded at compile time by the TanStack Start compiler.
56 */
57export interface ServerFnMeta extends ClientFnMeta {
58 /** The original variable name of the server function (e.g., "myServerFn") */
59 name: string
60 /** The source file path relative to the project root (e.g., "src/routes/api.ts") */
61 filename: string
63​
64export {}