@tanstack/start-server-core 1.166.9 → 1.166.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,227 +1,218 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
- import { H3Event, toResponse, getRequestIP as getRequestIP$1, getRequestHost as getRequestHost$1, getRequestURL, getRequestProtocol as getRequestProtocol$1, sanitizeStatusCode, sanitizeStatusMessage, parseCookies, setCookie as setCookie$1, deleteCookie as deleteCookie$1, useSession as useSession$1, getSession as getSession$1, updateSession as updateSession$1, sealSession as sealSession$1, unsealSession as unsealSession$1, clearSession as clearSession$1, getValidatedQuery as getValidatedQuery$1 } from "h3-v2";
3
- const GLOBAL_EVENT_STORAGE_KEY = /* @__PURE__ */ Symbol.for("tanstack-start:event-storage");
4
- const globalObj = globalThis;
5
- if (!globalObj[GLOBAL_EVENT_STORAGE_KEY]) {
6
- globalObj[GLOBAL_EVENT_STORAGE_KEY] = new AsyncLocalStorage();
7
- }
8
- const eventStorage = globalObj[GLOBAL_EVENT_STORAGE_KEY];
2
+ import { H3Event, clearSession, deleteCookie, getRequestHost, getRequestIP, getRequestProtocol, getRequestURL, getSession, getValidatedQuery, parseCookies, sanitizeStatusCode, sanitizeStatusMessage, sealSession, setCookie, toResponse, unsealSession, updateSession, useSession } from "h3-v2";
3
+ //#region src/request-response.ts
4
+ var GLOBAL_EVENT_STORAGE_KEY = Symbol.for("tanstack-start:event-storage");
5
+ var globalObj = globalThis;
6
+ if (!globalObj[GLOBAL_EVENT_STORAGE_KEY]) globalObj[GLOBAL_EVENT_STORAGE_KEY] = new AsyncLocalStorage();
7
+ var eventStorage = globalObj[GLOBAL_EVENT_STORAGE_KEY];
9
8
  function isPromiseLike(value) {
10
- return typeof value.then === "function";
9
+ return typeof value.then === "function";
11
10
  }
12
11
  function getSetCookieValues(headers) {
13
- const headersWithSetCookie = headers;
14
- if (typeof headersWithSetCookie.getSetCookie === "function") {
15
- return headersWithSetCookie.getSetCookie();
16
- }
17
- const value = headers.get("set-cookie");
18
- return value ? [value] : [];
12
+ const headersWithSetCookie = headers;
13
+ if (typeof headersWithSetCookie.getSetCookie === "function") return headersWithSetCookie.getSetCookie();
14
+ const value = headers.get("set-cookie");
15
+ return value ? [value] : [];
19
16
  }
20
17
  function mergeEventResponseHeaders(response, event) {
21
- if (response.ok) {
22
- return;
23
- }
24
- const eventSetCookies = getSetCookieValues(event.res.headers);
25
- if (eventSetCookies.length === 0) {
26
- return;
27
- }
28
- const responseSetCookies = getSetCookieValues(response.headers);
29
- response.headers.delete("set-cookie");
30
- for (const cookie of responseSetCookies) {
31
- response.headers.append("set-cookie", cookie);
32
- }
33
- for (const cookie of eventSetCookies) {
34
- response.headers.append("set-cookie", cookie);
35
- }
18
+ if (response.ok) return;
19
+ const eventSetCookies = getSetCookieValues(event.res.headers);
20
+ if (eventSetCookies.length === 0) return;
21
+ const responseSetCookies = getSetCookieValues(response.headers);
22
+ response.headers.delete("set-cookie");
23
+ for (const cookie of responseSetCookies) response.headers.append("set-cookie", cookie);
24
+ for (const cookie of eventSetCookies) response.headers.append("set-cookie", cookie);
36
25
  }
37
26
  function attachResponseHeaders(value, event) {
38
- if (isPromiseLike(value)) {
39
- return value.then((resolved) => {
40
- if (resolved instanceof Response) {
41
- mergeEventResponseHeaders(resolved, event);
42
- }
43
- return resolved;
44
- });
45
- }
46
- if (value instanceof Response) {
47
- mergeEventResponseHeaders(value, event);
48
- }
49
- return value;
27
+ if (isPromiseLike(value)) return value.then((resolved) => {
28
+ if (resolved instanceof Response) mergeEventResponseHeaders(resolved, event);
29
+ return resolved;
30
+ });
31
+ if (value instanceof Response) mergeEventResponseHeaders(value, event);
32
+ return value;
50
33
  }
51
34
  function requestHandler(handler) {
52
- return (request, requestOpts) => {
53
- const h3Event = new H3Event(request);
54
- const response = eventStorage.run(
55
- { h3Event },
56
- () => handler(request, requestOpts)
57
- );
58
- return toResponse(attachResponseHeaders(response, h3Event), h3Event);
59
- };
35
+ return (request, requestOpts) => {
36
+ const h3Event = new H3Event(request);
37
+ return toResponse(attachResponseHeaders(eventStorage.run({ h3Event }, () => handler(request, requestOpts)), h3Event), h3Event);
38
+ };
60
39
  }
61
40
  function getH3Event() {
62
- const event = eventStorage.getStore();
63
- if (!event) {
64
- throw new Error(
65
- `No StartEvent found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`
66
- );
67
- }
68
- return event.h3Event;
41
+ const event = eventStorage.getStore();
42
+ if (!event) throw new Error(`No StartEvent found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`);
43
+ return event.h3Event;
69
44
  }
70
45
  function getRequest() {
71
- const event = getH3Event();
72
- return event.req;
46
+ return getH3Event().req;
73
47
  }
74
48
  function getRequestHeaders() {
75
- return getH3Event().req.headers;
49
+ return getH3Event().req.headers;
76
50
  }
77
51
  function getRequestHeader(name) {
78
- return getRequestHeaders().get(name) || void 0;
79
- }
80
- function getRequestIP(opts) {
81
- return getRequestIP$1(getH3Event(), opts);
82
- }
83
- function getRequestHost(opts) {
84
- return getRequestHost$1(getH3Event(), opts);
85
- }
52
+ return getRequestHeaders().get(name) || void 0;
53
+ }
54
+ function getRequestIP$1(opts) {
55
+ return getRequestIP(getH3Event(), opts);
56
+ }
57
+ /**
58
+ * Get the request hostname.
59
+ *
60
+ * If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists.
61
+ *
62
+ * If no host header is found, it will default to "localhost".
63
+ */
64
+ function getRequestHost$1(opts) {
65
+ return getRequestHost(getH3Event(), opts);
66
+ }
67
+ /**
68
+ * Get the full incoming request URL.
69
+ *
70
+ * If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists.
71
+ *
72
+ * If `xForwardedProto` is `false`, it will not use the `x-forwarded-proto` header.
73
+ */
86
74
  function getRequestUrl(opts) {
87
- return getRequestURL(getH3Event(), opts);
88
- }
89
- function getRequestProtocol(opts) {
90
- return getRequestProtocol$1(getH3Event(), opts);
75
+ return getRequestURL(getH3Event(), opts);
76
+ }
77
+ /**
78
+ * Get the request protocol.
79
+ *
80
+ * If `x-forwarded-proto` header is set to "https", it will return "https". You can disable this behavior by setting `xForwardedProto` to `false`.
81
+ *
82
+ * If protocol cannot be determined, it will default to "http".
83
+ */
84
+ function getRequestProtocol$1(opts) {
85
+ return getRequestProtocol(getH3Event(), opts);
91
86
  }
92
87
  function setResponseHeaders(headers) {
93
- const event = getH3Event();
94
- for (const [name, value] of Object.entries(headers)) {
95
- event.res.headers.set(name, value);
96
- }
88
+ const event = getH3Event();
89
+ for (const [name, value] of Object.entries(headers)) event.res.headers.set(name, value);
97
90
  }
98
91
  function getResponseHeaders() {
99
- const event = getH3Event();
100
- return event.res.headers;
92
+ return getH3Event().res.headers;
101
93
  }
102
94
  function getResponseHeader(name) {
103
- const event = getH3Event();
104
- return event.res.headers.get(name) || void 0;
95
+ return getH3Event().res.headers.get(name) || void 0;
105
96
  }
106
97
  function setResponseHeader(name, value) {
107
- const event = getH3Event();
108
- if (Array.isArray(value)) {
109
- event.res.headers.delete(name);
110
- for (const valueItem of value) {
111
- event.res.headers.append(name, valueItem);
112
- }
113
- } else {
114
- event.res.headers.set(name, value);
115
- }
98
+ const event = getH3Event();
99
+ if (Array.isArray(value)) {
100
+ event.res.headers.delete(name);
101
+ for (const valueItem of value) event.res.headers.append(name, valueItem);
102
+ } else event.res.headers.set(name, value);
116
103
  }
117
104
  function removeResponseHeader(name) {
118
- const event = getH3Event();
119
- event.res.headers.delete(name);
105
+ getH3Event().res.headers.delete(name);
120
106
  }
121
107
  function clearResponseHeaders(headerNames) {
122
- const event = getH3Event();
123
- if (headerNames && headerNames.length > 0) {
124
- for (const name of headerNames) {
125
- event.res.headers.delete(name);
126
- }
127
- } else {
128
- for (const name of event.res.headers.keys()) {
129
- event.res.headers.delete(name);
130
- }
131
- }
108
+ const event = getH3Event();
109
+ if (headerNames && headerNames.length > 0) for (const name of headerNames) event.res.headers.delete(name);
110
+ else for (const name of event.res.headers.keys()) event.res.headers.delete(name);
132
111
  }
133
112
  function getResponseStatus() {
134
- return getH3Event().res.status || 200;
113
+ return getH3Event().res.status || 200;
135
114
  }
136
115
  function setResponseStatus(code, text) {
137
- const event = getH3Event();
138
- if (code) {
139
- event.res.status = sanitizeStatusCode(code, event.res.status);
140
- }
141
- if (text) {
142
- event.res.statusText = sanitizeStatusMessage(text);
143
- }
144
- }
116
+ const event = getH3Event();
117
+ if (code) event.res.status = sanitizeStatusCode(code, event.res.status);
118
+ if (text) event.res.statusText = sanitizeStatusMessage(text);
119
+ }
120
+ /**
121
+ * Parse the request to get HTTP Cookie header string and return an object of all cookie name-value pairs.
122
+ * @returns Object of cookie name-value pairs
123
+ * ```ts
124
+ * const cookies = getCookies()
125
+ * ```
126
+ */
145
127
  function getCookies() {
146
- const event = getH3Event();
147
- return parseCookies(event);
148
- }
128
+ return parseCookies(getH3Event());
129
+ }
130
+ /**
131
+ * Get a cookie value by name.
132
+ * @param name Name of the cookie to get
133
+ * @returns {*} Value of the cookie (String or undefined)
134
+ * ```ts
135
+ * const authorization = getCookie('Authorization')
136
+ * ```
137
+ */
149
138
  function getCookie(name) {
150
- return getCookies()[name] || void 0;
151
- }
152
- function setCookie(name, value, options) {
153
- const event = getH3Event();
154
- setCookie$1(event, name, value, options);
155
- }
156
- function deleteCookie(name, options) {
157
- const event = getH3Event();
158
- deleteCookie$1(event, name, options);
139
+ return getCookies()[name] || void 0;
140
+ }
141
+ /**
142
+ * Set a cookie value by name.
143
+ * @param name Name of the cookie to set
144
+ * @param value Value of the cookie to set
145
+ * @param options {CookieSerializeOptions} Options for serializing the cookie
146
+ * ```ts
147
+ * setCookie('Authorization', '1234567')
148
+ * ```
149
+ */
150
+ function setCookie$1(name, value, options) {
151
+ setCookie(getH3Event(), name, value, options);
152
+ }
153
+ /**
154
+ * Remove a cookie by name.
155
+ * @param name Name of the cookie to delete
156
+ * @param serializeOptions {CookieSerializeOptions} Cookie options
157
+ * ```ts
158
+ * deleteCookie('SessionId')
159
+ * ```
160
+ */
161
+ function deleteCookie$1(name, options) {
162
+ deleteCookie(getH3Event(), name, options);
159
163
  }
160
164
  function getDefaultSessionConfig(config) {
161
- return {
162
- name: "start",
163
- ...config
164
- };
165
- }
166
- function useSession(config) {
167
- const event = getH3Event();
168
- return useSession$1(event, getDefaultSessionConfig(config));
169
- }
170
- function getSession(config) {
171
- const event = getH3Event();
172
- return getSession$1(event, getDefaultSessionConfig(config));
173
- }
174
- function updateSession(config, update) {
175
- const event = getH3Event();
176
- return updateSession$1(event, getDefaultSessionConfig(config), update);
165
+ return {
166
+ name: "start",
167
+ ...config
168
+ };
169
+ }
170
+ /**
171
+ * Create a session manager for the current request.
172
+ */
173
+ function useSession$1(config) {
174
+ return useSession(getH3Event(), getDefaultSessionConfig(config));
175
+ }
176
+ /**
177
+ * Get the session for the current request
178
+ */
179
+ function getSession$1(config) {
180
+ return getSession(getH3Event(), getDefaultSessionConfig(config));
181
+ }
182
+ /**
183
+ * Update the session data for the current request.
184
+ */
185
+ function updateSession$1(config, update) {
186
+ return updateSession(getH3Event(), getDefaultSessionConfig(config), update);
187
+ }
188
+ /**
189
+ * Encrypt and sign the session data for the current request.
190
+ */
191
+ function sealSession$1(config) {
192
+ return sealSession(getH3Event(), getDefaultSessionConfig(config));
193
+ }
194
+ /**
195
+ * Decrypt and verify the session data for the current request.
196
+ */
197
+ function unsealSession$1(config, sealed) {
198
+ return unsealSession(getH3Event(), getDefaultSessionConfig(config), sealed);
199
+ }
200
+ /**
201
+ * Clear the session data for the current request.
202
+ */
203
+ function clearSession$1(config) {
204
+ return clearSession(getH3Event(), {
205
+ name: "start",
206
+ ...config
207
+ });
177
208
  }
178
- function sealSession(config) {
179
- const event = getH3Event();
180
- return sealSession$1(event, getDefaultSessionConfig(config));
181
- }
182
- function unsealSession(config, sealed) {
183
- const event = getH3Event();
184
- return unsealSession$1(event, getDefaultSessionConfig(config), sealed);
209
+ function getResponse() {
210
+ return getH3Event().res;
185
211
  }
186
- function clearSession(config) {
187
- const event = getH3Event();
188
- return clearSession$1(event, { name: "start", ...config });
212
+ function getValidatedQuery$1(schema) {
213
+ return getValidatedQuery(getH3Event(), schema);
189
214
  }
190
- function getResponse() {
191
- const event = getH3Event();
192
- return event.res;
193
- }
194
- function getValidatedQuery(schema) {
195
- return getValidatedQuery$1(getH3Event(), schema);
196
- }
197
- export {
198
- clearResponseHeaders,
199
- clearSession,
200
- deleteCookie,
201
- getCookie,
202
- getCookies,
203
- getRequest,
204
- getRequestHeader,
205
- getRequestHeaders,
206
- getRequestHost,
207
- getRequestIP,
208
- getRequestProtocol,
209
- getRequestUrl,
210
- getResponse,
211
- getResponseHeader,
212
- getResponseHeaders,
213
- getResponseStatus,
214
- getSession,
215
- getValidatedQuery,
216
- removeResponseHeader,
217
- requestHandler,
218
- sealSession,
219
- setCookie,
220
- setResponseHeader,
221
- setResponseHeaders,
222
- setResponseStatus,
223
- unsealSession,
224
- updateSession,
225
- useSession
226
- };
227
- //# sourceMappingURL=request-response.js.map
215
+ //#endregion
216
+ export { clearResponseHeaders, clearSession$1 as clearSession, deleteCookie$1 as deleteCookie, getCookie, getCookies, getRequest, getRequestHeader, getRequestHeaders, getRequestHost$1 as getRequestHost, getRequestIP$1 as getRequestIP, getRequestProtocol$1 as getRequestProtocol, getRequestUrl, getResponse, getResponseHeader, getResponseHeaders, getResponseStatus, getSession$1 as getSession, getValidatedQuery$1 as getValidatedQuery, removeResponseHeader, requestHandler, sealSession$1 as sealSession, setCookie$1 as setCookie, setResponseHeader, setResponseHeaders, setResponseStatus, unsealSession$1 as unsealSession, updateSession$1 as updateSession, useSession$1 as useSession };
217
+
218
+ //# sourceMappingURL=request-response.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request-response.js","sources":["../../src/request-response.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\n\nimport {\n H3Event,\n clearSession as h3_clearSession,\n deleteCookie as h3_deleteCookie,\n getRequestHost as h3_getRequestHost,\n getRequestIP as h3_getRequestIP,\n getRequestProtocol as h3_getRequestProtocol,\n getRequestURL as h3_getRequestURL,\n getSession as h3_getSession,\n getValidatedQuery as h3_getValidatedQuery,\n parseCookies as h3_parseCookies,\n sanitizeStatusCode as h3_sanitizeStatusCode,\n sanitizeStatusMessage as h3_sanitizeStatusMessage,\n sealSession as h3_sealSession,\n setCookie as h3_setCookie,\n toResponse as h3_toResponse,\n unsealSession as h3_unsealSession,\n updateSession as h3_updateSession,\n useSession as h3_useSession,\n} from 'h3-v2'\nimport type {\n RequestHeaderMap,\n RequestHeaderName,\n ResponseHeaderMap,\n ResponseHeaderName,\n TypedHeaders,\n} from 'fetchdts'\n\nimport type { CookieSerializeOptions } from 'cookie-es'\nimport type {\n Session,\n SessionConfig,\n SessionData,\n SessionManager,\n SessionUpdate,\n} from './session'\nimport type { StandardSchemaV1 } from '@standard-schema/spec'\nimport type { RequestHandler } from './request-handler'\n\ninterface StartEvent {\n h3Event: H3Event\n}\n\n// Use a global symbol to ensure the same AsyncLocalStorage instance is shared\n// across different bundles that may each bundle this module.\nconst GLOBAL_EVENT_STORAGE_KEY = Symbol.for('tanstack-start:event-storage')\n\nconst globalObj = globalThis as typeof globalThis & {\n [GLOBAL_EVENT_STORAGE_KEY]?: AsyncLocalStorage<StartEvent>\n}\n\nif (!globalObj[GLOBAL_EVENT_STORAGE_KEY]) {\n globalObj[GLOBAL_EVENT_STORAGE_KEY] = new AsyncLocalStorage<StartEvent>()\n}\n\nconst eventStorage = globalObj[GLOBAL_EVENT_STORAGE_KEY]\n\nexport type { ResponseHeaderName, RequestHeaderName }\n\ntype HeadersWithGetSetCookie = Headers & {\n getSetCookie?: () => Array<string>\n}\n\ntype MaybePromise<T> = T | Promise<T>\n\nfunction isPromiseLike<T>(value: MaybePromise<T>): value is Promise<T> {\n return typeof (value as Promise<T>).then === 'function'\n}\n\nfunction getSetCookieValues(headers: Headers): Array<string> {\n const headersWithSetCookie = headers as HeadersWithGetSetCookie\n if (typeof headersWithSetCookie.getSetCookie === 'function') {\n return headersWithSetCookie.getSetCookie()\n }\n const value = headers.get('set-cookie')\n return value ? [value] : []\n}\n\nfunction mergeEventResponseHeaders(response: Response, event: H3Event): void {\n if (response.ok) {\n return\n }\n\n const eventSetCookies = getSetCookieValues(event.res.headers)\n if (eventSetCookies.length === 0) {\n return\n }\n\n const responseSetCookies = getSetCookieValues(response.headers)\n response.headers.delete('set-cookie')\n for (const cookie of responseSetCookies) {\n response.headers.append('set-cookie', cookie)\n }\n for (const cookie of eventSetCookies) {\n response.headers.append('set-cookie', cookie)\n }\n}\n\nfunction attachResponseHeaders<T>(\n value: MaybePromise<T>,\n event: H3Event,\n): MaybePromise<T> {\n if (isPromiseLike(value)) {\n return value.then((resolved) => {\n if (resolved instanceof Response) {\n mergeEventResponseHeaders(resolved, event)\n }\n return resolved\n })\n }\n\n if (value instanceof Response) {\n mergeEventResponseHeaders(value, event)\n }\n\n return value\n}\n\nexport function requestHandler<TRegister = unknown>(\n handler: RequestHandler<TRegister>,\n) {\n return (request: Request, requestOpts: any): Promise<Response> | Response => {\n const h3Event = new H3Event(request)\n\n const response = eventStorage.run({ h3Event }, () =>\n handler(request, requestOpts),\n )\n return h3_toResponse(attachResponseHeaders(response, h3Event), h3Event)\n }\n}\n\nfunction getH3Event() {\n const event = eventStorage.getStore()\n if (!event) {\n throw new Error(\n `No StartEvent found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`,\n )\n }\n return event.h3Event\n}\n\nexport function getRequest(): Request {\n const event = getH3Event()\n return event.req\n}\n\nexport function getRequestHeaders(): TypedHeaders<RequestHeaderMap> {\n // TODO `as any` not needed when fetchdts is updated\n return getH3Event().req.headers as any\n}\n\nexport function getRequestHeader(name: RequestHeaderName): string | undefined {\n return getRequestHeaders().get(name) || undefined\n}\n\nexport function getRequestIP(opts?: {\n /**\n * Use the X-Forwarded-For HTTP header set by proxies.\n *\n * Note: Make sure that this header can be trusted (your application running behind a CDN or reverse proxy) before enabling.\n */\n xForwardedFor?: boolean\n}) {\n return h3_getRequestIP(getH3Event(), opts)\n}\n\n/**\n * Get the request hostname.\n *\n * If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists.\n *\n * If no host header is found, it will default to \"localhost\".\n */\nexport function getRequestHost(opts?: { xForwardedHost?: boolean }) {\n return h3_getRequestHost(getH3Event(), opts)\n}\n\n/**\n * Get the full incoming request URL.\n *\n * If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists.\n *\n * If `xForwardedProto` is `false`, it will not use the `x-forwarded-proto` header.\n */\nexport function getRequestUrl(opts?: {\n xForwardedHost?: boolean\n xForwardedProto?: boolean\n}) {\n return h3_getRequestURL(getH3Event(), opts)\n}\n\n/**\n * Get the request protocol.\n *\n * If `x-forwarded-proto` header is set to \"https\", it will return \"https\". You can disable this behavior by setting `xForwardedProto` to `false`.\n *\n * If protocol cannot be determined, it will default to \"http\".\n */\nexport function getRequestProtocol(opts?: {\n xForwardedProto?: boolean\n}): 'http' | 'https' | (string & {}) {\n return h3_getRequestProtocol(getH3Event(), opts)\n}\n\nexport function setResponseHeaders(\n headers: TypedHeaders<ResponseHeaderMap>,\n): void {\n const event = getH3Event()\n for (const [name, value] of Object.entries(headers)) {\n event.res.headers.set(name, value)\n }\n}\n\nexport function getResponseHeaders(): TypedHeaders<ResponseHeaderMap> {\n const event = getH3Event()\n return event.res.headers\n}\n\nexport function getResponseHeader(\n name: ResponseHeaderName,\n): string | undefined {\n const event = getH3Event()\n return event.res.headers.get(name) || undefined\n}\n\nexport function setResponseHeader(\n name: ResponseHeaderName,\n value: string | Array<string>,\n): void {\n const event = getH3Event()\n if (Array.isArray(value)) {\n event.res.headers.delete(name)\n for (const valueItem of value) {\n event.res.headers.append(name, valueItem)\n }\n } else {\n event.res.headers.set(name, value)\n }\n}\nexport function removeResponseHeader(name: ResponseHeaderName): void {\n const event = getH3Event()\n event.res.headers.delete(name)\n}\n\nexport function clearResponseHeaders(\n headerNames?: Array<ResponseHeaderName>,\n): void {\n const event = getH3Event()\n // If headerNames is provided, clear only those headers\n if (headerNames && headerNames.length > 0) {\n for (const name of headerNames) {\n event.res.headers.delete(name)\n }\n // Otherwise, clear all headers\n } else {\n for (const name of event.res.headers.keys()) {\n event.res.headers.delete(name)\n }\n }\n}\n\nexport function getResponseStatus(): number {\n return getH3Event().res.status || 200\n}\n\nexport function setResponseStatus(code?: number, text?: string): void {\n const event = getH3Event()\n if (code) {\n event.res.status = h3_sanitizeStatusCode(code, event.res.status)\n }\n if (text) {\n event.res.statusText = h3_sanitizeStatusMessage(text)\n }\n}\n\n/**\n * Parse the request to get HTTP Cookie header string and return an object of all cookie name-value pairs.\n * @returns Object of cookie name-value pairs\n * ```ts\n * const cookies = getCookies()\n * ```\n */\nexport function getCookies(): Record<string, string> {\n const event = getH3Event()\n return h3_parseCookies(event)\n}\n\n/**\n * Get a cookie value by name.\n * @param name Name of the cookie to get\n * @returns {*} Value of the cookie (String or undefined)\n * ```ts\n * const authorization = getCookie('Authorization')\n * ```\n */\nexport function getCookie(name: string): string | undefined {\n return getCookies()[name] || undefined\n}\n\n/**\n * Set a cookie value by name.\n * @param name Name of the cookie to set\n * @param value Value of the cookie to set\n * @param options {CookieSerializeOptions} Options for serializing the cookie\n * ```ts\n * setCookie('Authorization', '1234567')\n * ```\n */\nexport function setCookie(\n name: string,\n value: string,\n options?: CookieSerializeOptions,\n): void {\n const event = getH3Event()\n h3_setCookie(event, name, value, options)\n}\n\n/**\n * Remove a cookie by name.\n * @param name Name of the cookie to delete\n * @param serializeOptions {CookieSerializeOptions} Cookie options\n * ```ts\n * deleteCookie('SessionId')\n * ```\n */\nexport function deleteCookie(\n name: string,\n options?: CookieSerializeOptions,\n): void {\n const event = getH3Event()\n h3_deleteCookie(event, name, options)\n}\n\nfunction getDefaultSessionConfig(config: SessionConfig): SessionConfig {\n return {\n name: 'start',\n ...config,\n }\n}\n\n/**\n * Create a session manager for the current request.\n */\nexport function useSession<TSessionData extends SessionData = SessionData>(\n config: SessionConfig,\n): Promise<SessionManager<TSessionData>> {\n const event = getH3Event()\n return h3_useSession(event, getDefaultSessionConfig(config))\n}\n/**\n * Get the session for the current request\n */\nexport function getSession<TSessionData extends SessionData = SessionData>(\n config: SessionConfig,\n): Promise<Session<TSessionData>> {\n const event = getH3Event()\n return h3_getSession(event, getDefaultSessionConfig(config))\n}\n\n/**\n * Update the session data for the current request.\n */\nexport function updateSession<TSessionData extends SessionData = SessionData>(\n config: SessionConfig,\n update?: SessionUpdate<TSessionData>,\n): Promise<Session<TSessionData>> {\n const event = getH3Event()\n return h3_updateSession(event, getDefaultSessionConfig(config), update)\n}\n\n/**\n * Encrypt and sign the session data for the current request.\n */\nexport function sealSession(config: SessionConfig): Promise<string> {\n const event = getH3Event()\n return h3_sealSession(event, getDefaultSessionConfig(config))\n}\n/**\n * Decrypt and verify the session data for the current request.\n */\nexport function unsealSession(\n config: SessionConfig,\n sealed: string,\n): Promise<Partial<Session>> {\n const event = getH3Event()\n return h3_unsealSession(event, getDefaultSessionConfig(config), sealed)\n}\n\n/**\n * Clear the session data for the current request.\n */\nexport function clearSession(config: Partial<SessionConfig>): Promise<void> {\n const event = getH3Event()\n return h3_clearSession(event, { name: 'start', ...config })\n}\n\nexport function getResponse() {\n const event = getH3Event()\n return event.res\n}\n\n// not public API (yet)\nexport function getValidatedQuery<TSchema extends StandardSchemaV1>(\n schema: StandardSchemaV1,\n): Promise<StandardSchemaV1.InferOutput<TSchema>> {\n return h3_getValidatedQuery(getH3Event(), schema)\n}\n"],"names":["h3_toResponse","h3_getRequestIP","h3_getRequestHost","h3_getRequestURL","h3_getRequestProtocol","h3_sanitizeStatusCode","h3_sanitizeStatusMessage","h3_parseCookies","h3_setCookie","h3_deleteCookie","h3_useSession","h3_getSession","h3_updateSession","h3_sealSession","h3_unsealSession","h3_clearSession","h3_getValidatedQuery"],"mappings":";;AA+CA,MAAM,2BAA2B,uBAAO,IAAI,8BAA8B;AAE1E,MAAM,YAAY;AAIlB,IAAI,CAAC,UAAU,wBAAwB,GA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AACvC,QAAM,QAAQ,WAAA;AACd,SAAOC,aAAc,OAAO,wBAAwB,MAAM,CAAC;AAC7D;AAIO,SAAS,WACd,QACgC;AAChC,QAAM,QAAQ,WAAA;AACd,SAAOC,aAAc,OAAO,wBAAwB,MAAM,CAAC;AAC7D;AAKO,SAAS,cACd,QACA,QACgC;AAChC,QAAM,QAAQ,WAAA;AACd,SAAOC,gBAAiB,OAAO,wBAAwB,MAAM,GAAG,MAAM;AACxE;AAKO,SAAS,YAAY,QAAwC;AAClE,QAAM,QAAQ,WAAA;AACd,SAAOC,cAAe,OAAO,wBAAwB,MAAM,CAAC;AAC9D;AAIO,SAAS,cACd,QACA,QAC2B;AAC3B,QAAM,QAAQ,WAAA;AACd,SAAOC,gBAAiB,OAAO,wBAAwB,MAAM,GAAG,MAAM;AACxE;AAKO,SAAS,aAAa,QAA+C;AAC1E,QAAM,QAAQ,WAAA;AACd,SAAOC,eAAgB,OAAO,EAAE,MAAM,SAAS,GAAG,QAAQ;AAC5D;AAEO,SAAS,cAAc;AAC5B,QAAM,QAAQ,WAAA;AACd,SAAO,MAAM;AACf;AAGO,SAAS,kBACd,QACgD;AAChD,SAAOC,oBAAqB,WAAA,GAAc,MAAM;AAClD;"}
1
+ {"version":3,"file":"request-response.js","names":[],"sources":["../../src/request-response.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\n\nimport {\n H3Event,\n clearSession as h3_clearSession,\n deleteCookie as h3_deleteCookie,\n getRequestHost as h3_getRequestHost,\n getRequestIP as h3_getRequestIP,\n getRequestProtocol as h3_getRequestProtocol,\n getRequestURL as h3_getRequestURL,\n getSession as h3_getSession,\n getValidatedQuery as h3_getValidatedQuery,\n parseCookies as h3_parseCookies,\n sanitizeStatusCode as h3_sanitizeStatusCode,\n sanitizeStatusMessage as h3_sanitizeStatusMessage,\n sealSession as h3_sealSession,\n setCookie as h3_setCookie,\n toResponse as h3_toResponse,\n unsealSession as h3_unsealSession,\n updateSession as h3_updateSession,\n useSession as h3_useSession,\n} from 'h3-v2'\nimport type {\n RequestHeaderMap,\n RequestHeaderName,\n ResponseHeaderMap,\n ResponseHeaderName,\n TypedHeaders,\n} from 'fetchdts'\n\nimport type { CookieSerializeOptions } from 'cookie-es'\nimport type {\n Session,\n SessionConfig,\n SessionData,\n SessionManager,\n SessionUpdate,\n} from './session'\nimport type { StandardSchemaV1 } from '@standard-schema/spec'\nimport type { RequestHandler } from './request-handler'\n\ninterface StartEvent {\n h3Event: H3Event\n}\n\n// Use a global symbol to ensure the same AsyncLocalStorage instance is shared\n// across different bundles that may each bundle this module.\nconst GLOBAL_EVENT_STORAGE_KEY = Symbol.for('tanstack-start:event-storage')\n\nconst globalObj = globalThis as typeof globalThis & {\n [GLOBAL_EVENT_STORAGE_KEY]?: AsyncLocalStorage<StartEvent>\n}\n\nif (!globalObj[GLOBAL_EVENT_STORAGE_KEY]) {\n globalObj[GLOBAL_EVENT_STORAGE_KEY] = new AsyncLocalStorage<StartEvent>()\n}\n\nconst eventStorage = globalObj[GLOBAL_EVENT_STORAGE_KEY]\n\nexport type { ResponseHeaderName, RequestHeaderName }\n\ntype HeadersWithGetSetCookie = Headers & {\n getSetCookie?: () => Array<string>\n}\n\ntype MaybePromise<T> = T | Promise<T>\n\nfunction isPromiseLike<T>(value: MaybePromise<T>): value is Promise<T> {\n return typeof (value as Promise<T>).then === 'function'\n}\n\nfunction getSetCookieValues(headers: Headers): Array<string> {\n const headersWithSetCookie = headers as HeadersWithGetSetCookie\n if (typeof headersWithSetCookie.getSetCookie === 'function') {\n return headersWithSetCookie.getSetCookie()\n }\n const value = headers.get('set-cookie')\n return value ? [value] : []\n}\n\nfunction mergeEventResponseHeaders(response: Response, event: H3Event): void {\n if (response.ok) {\n return\n }\n\n const eventSetCookies = getSetCookieValues(event.res.headers)\n if (eventSetCookies.length === 0) {\n return\n }\n\n const responseSetCookies = getSetCookieValues(response.headers)\n response.headers.delete('set-cookie')\n for (const cookie of responseSetCookies) {\n response.headers.append('set-cookie', cookie)\n }\n for (const cookie of eventSetCookies) {\n response.headers.append('set-cookie', cookie)\n }\n}\n\nfunction attachResponseHeaders<T>(\n value: MaybePromise<T>,\n event: H3Event,\n): MaybePromise<T> {\n if (isPromiseLike(value)) {\n return value.then((resolved) => {\n if (resolved instanceof Response) {\n mergeEventResponseHeaders(resolved, event)\n }\n return resolved\n })\n }\n\n if (value instanceof Response) {\n mergeEventResponseHeaders(value, event)\n }\n\n return value\n}\n\nexport function requestHandler<TRegister = unknown>(\n handler: RequestHandler<TRegister>,\n) {\n return (request: Request, requestOpts: any): Promise<Response> | Response => {\n const h3Event = new H3Event(request)\n\n const response = eventStorage.run({ h3Event }, () =>\n handler(request, requestOpts),\n )\n return h3_toResponse(attachResponseHeaders(response, h3Event), h3Event)\n }\n}\n\nfunction getH3Event() {\n const event = eventStorage.getStore()\n if (!event) {\n throw new Error(\n `No StartEvent found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`,\n )\n }\n return event.h3Event\n}\n\nexport function getRequest(): Request {\n const event = getH3Event()\n return event.req\n}\n\nexport function getRequestHeaders(): TypedHeaders<RequestHeaderMap> {\n // TODO `as any` not needed when fetchdts is updated\n return getH3Event().req.headers as any\n}\n\nexport function getRequestHeader(name: RequestHeaderName): string | undefined {\n return getRequestHeaders().get(name) || undefined\n}\n\nexport function getRequestIP(opts?: {\n /**\n * Use the X-Forwarded-For HTTP header set by proxies.\n *\n * Note: Make sure that this header can be trusted (your application running behind a CDN or reverse proxy) before enabling.\n */\n xForwardedFor?: boolean\n}) {\n return h3_getRequestIP(getH3Event(), opts)\n}\n\n/**\n * Get the request hostname.\n *\n * If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists.\n *\n * If no host header is found, it will default to \"localhost\".\n */\nexport function getRequestHost(opts?: { xForwardedHost?: boolean }) {\n return h3_getRequestHost(getH3Event(), opts)\n}\n\n/**\n * Get the full incoming request URL.\n *\n * If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists.\n *\n * If `xForwardedProto` is `false`, it will not use the `x-forwarded-proto` header.\n */\nexport function getRequestUrl(opts?: {\n xForwardedHost?: boolean\n xForwardedProto?: boolean\n}) {\n return h3_getRequestURL(getH3Event(), opts)\n}\n\n/**\n * Get the request protocol.\n *\n * If `x-forwarded-proto` header is set to \"https\", it will return \"https\". You can disable this behavior by setting `xForwardedProto` to `false`.\n *\n * If protocol cannot be determined, it will default to \"http\".\n */\nexport function getRequestProtocol(opts?: {\n xForwardedProto?: boolean\n}): 'http' | 'https' | (string & {}) {\n return h3_getRequestProtocol(getH3Event(), opts)\n}\n\nexport function setResponseHeaders(\n headers: TypedHeaders<ResponseHeaderMap>,\n): void {\n const event = getH3Event()\n for (const [name, value] of Object.entries(headers)) {\n event.res.headers.set(name, value)\n }\n}\n\nexport function getResponseHeaders(): TypedHeaders<ResponseHeaderMap> {\n const event = getH3Event()\n return event.res.headers\n}\n\nexport function getResponseHeader(\n name: ResponseHeaderName,\n): string | undefined {\n const event = getH3Event()\n return event.res.headers.get(name) || undefined\n}\n\nexport function setResponseHeader(\n name: ResponseHeaderName,\n value: string | Array<string>,\n): void {\n const event = getH3Event()\n if (Array.isArray(value)) {\n event.res.headers.delete(name)\n for (const valueItem of value) {\n event.res.headers.append(name, valueItem)\n }\n } else {\n event.res.headers.set(name, value)\n }\n}\nexport function removeResponseHeader(name: ResponseHeaderName): void {\n const event = getH3Event()\n event.res.headers.delete(name)\n}\n\nexport function clearResponseHeaders(\n headerNames?: Array<ResponseHeaderName>,\n): void {\n const event = getH3Event()\n // If headerNames is provided, clear only those headers\n if (headerNames && headerNames.length > 0) {\n for (const name of headerNames) {\n event.res.headers.delete(name)\n }\n // Otherwise, clear all headers\n } else {\n for (const name of event.res.headers.keys()) {\n event.res.headers.delete(name)\n }\n }\n}\n\nexport function getResponseStatus(): number {\n return getH3Event().res.status || 200\n}\n\nexport function setResponseStatus(code?: number, text?: string): void {\n const event = getH3Event()\n if (code) {\n event.res.status = h3_sanitizeStatusCode(code, event.res.status)\n }\n if (text) {\n event.res.statusText = h3_sanitizeStatusMessage(text)\n }\n}\n\n/**\n * Parse the request to get HTTP Cookie header string and return an object of all cookie name-value pairs.\n * @returns Object of cookie name-value pairs\n * ```ts\n * const cookies = getCookies()\n * ```\n */\nexport function getCookies(): Record<string, string> {\n const event = getH3Event()\n return h3_parseCookies(event)\n}\n\n/**\n * Get a cookie value by name.\n * @param name Name of the cookie to get\n * @returns {*} Value of the cookie (String or undefined)\n * ```ts\n * const authorization = getCookie('Authorization')\n * ```\n */\nexport function getCookie(name: string): string | undefined {\n return getCookies()[name] || undefined\n}\n\n/**\n * Set a cookie value by name.\n * @param name Name of the cookie to set\n * @param value Value of the cookie to set\n * @param options {CookieSerializeOptions} Options for serializing the cookie\n * ```ts\n * setCookie('Authorization', '1234567')\n * ```\n */\nexport function setCookie(\n name: string,\n value: string,\n options?: CookieSerializeOptions,\n): void {\n const event = getH3Event()\n h3_setCookie(event, name, value, options)\n}\n\n/**\n * Remove a cookie by name.\n * @param name Name of the cookie to delete\n * @param serializeOptions {CookieSerializeOptions} Cookie options\n * ```ts\n * deleteCookie('SessionId')\n * ```\n */\nexport function deleteCookie(\n name: string,\n options?: CookieSerializeOptions,\n): void {\n const event = getH3Event()\n h3_deleteCookie(event, name, options)\n}\n\nfunction getDefaultSessionConfig(config: SessionConfig): SessionConfig {\n return {\n name: 'start',\n ...config,\n }\n}\n\n/**\n * Create a session manager for the current request.\n */\nexport function useSession<TSessionData extends SessionData = SessionData>(\n config: SessionConfig,\n): Promise<SessionManager<TSessionData>> {\n const event = getH3Event()\n return h3_useSession(event, getDefaultSessionConfig(config))\n}\n/**\n * Get the session for the current request\n */\nexport function getSession<TSessionData extends SessionData = SessionData>(\n config: SessionConfig,\n): Promise<Session<TSessionData>> {\n const event = getH3Event()\n return h3_getSession(event, getDefaultSessionConfig(config))\n}\n\n/**\n * Update the session data for the current request.\n */\nexport function updateSession<TSessionData extends SessionData = SessionData>(\n config: SessionConfig,\n update?: SessionUpdate<TSessionData>,\n): Promise<Session<TSessionData>> {\n const event = getH3Event()\n return h3_updateSession(event, getDefaultSessionConfig(config), update)\n}\n\n/**\n * Encrypt and sign the session data for the current request.\n */\nexport function sealSession(config: SessionConfig): Promise<string> {\n const event = getH3Event()\n return h3_sealSession(event, getDefaultSessionConfig(config))\n}\n/**\n * Decrypt and verify the session data for the current request.\n */\nexport function unsealSession(\n config: SessionConfig,\n sealed: string,\n): Promise<Partial<Session>> {\n const event = getH3Event()\n return h3_unsealSession(event, getDefaultSessionConfig(config), sealed)\n}\n\n/**\n * Clear the session data for the current request.\n */\nexport function clearSession(config: Partial<SessionConfig>): Promise<void> {\n const event = getH3Event()\n return h3_clearSession(event, { name: 'start', ...config })\n}\n\nexport function getResponse() {\n const event = getH3Event()\n return event.res\n}\n\n// not public API (yet)\nexport function getValidatedQuery<TSchema extends StandardSchemaV1>(\n schema: StandardSchemaV1,\n): Promise<StandardSchemaV1.InferOutput<TSchema>> {\n return h3_getValidatedQuery(getH3Event(), schema)\n}\n"],"mappings":";;;AA+CA,IAAM,2BAA2B,OAAO,IAAI,+BAA+B;AAE3E,IAAM,YAAY;AAIlB,IAAI,CAAC,UAAU,0BACb,WAAU,4BAA4B,IAAI,mBAA+B;AAG3E,IAAM,eAAe,UAAU;AAU/B,SAAS,cAAiB,OAA6C;AACrE,QAAO,OAAQ,MAAqB,SAAS;;AAG/C,SAAS,mBAAmB,SAAiC;CAC3D,MAAM,uBAAuB;AAC7B,KAAI,OAAO,qBAAqB,iBAAiB,WAC/C,QAAO,qBAAqB,cAAc;CAE5C,MAAM,QAAQ,QAAQ,IAAI,aAAa;AACvC,QAAO,QAAQ,CAAC,MAAM,GAAG,EAAE;;AAG7B,SAAS,0BAA0B,UAAoB,OAAsB;AAC3E,KAAI,SAAS,GACX;CAGF,MAAM,kBAAkB,mBAAmB,MAAM,IAAI,QAAQ;AAC7D,KAAI,gBAAgB,WAAW,EAC7B;CAGF,MAAM,qBAAqB,mBAAmB,SAAS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M,OAAO,QAAQ;;;;;;;;;;AAW3C,SAAgB,eACd,MACA,SACM;AAEN,cADc,YAAY,EACH,MAAM,QAAQ;;AAGvC,SAAS,wBAAwB,QAAsC;AACrE,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;AAMH,SAAgB,aACd,QACuC;AAEvC,QAAO,WADO,YAAY,EACE,wBAAwB,OAAO,CAAC;;;;;AAK9D,SAAgB,aACd,QACgC;AAEhC,QAAO,WADO,YAAY,EACE,wBAAwB,OAAO,CAAC;;;;;AAM9D,SAAgB,gBACd,QACA,QACgC;AAEhC,QAAO,cADO,YAAY,EACK,wBAAwB,OAAO,EAAE,OAAO;;;;;AAMzE,SAAgB,cAAY,QAAwC;AAElE,QAAO,YADO,YAAY,EACG,wBAAwB,OAAO,CAAC;;;;;AAK/D,SAAgB,gBACd,QACA,QAC2B;AAE3B,QAAO,cADO,YAAY,EACK,wBAAwB,OAAO,EAAE,OAAO;;;;;AAMzE,SAAgB,eAAa,QAA+C;AAE1E,QAAO,aADO,YAAY,EACI;EAAE,MAAM;EAAS,GAAG;EAAQ,CAAC;;AAG7D,SAAgB,cAAc;AAE5B,QADc,YAAY,CACb;;AAIf,SAAgB,oBACd,QACgD;AAChD,QAAO,kBAAqB,YAAY,EAAE,OAAO"}
@@ -1,55 +1,59 @@
1
- import { rootRouteId, buildDevStylesUrl } from "@tanstack/router-core";
2
- const DEV_SSR_STYLES_BASEPATH = process.env.TSS_DEV_SSR_STYLES_BASEPATH || "/";
1
+ import { buildDevStylesUrl, rootRouteId } from "@tanstack/router-core";
2
+ //#region src/router-manifest.ts
3
+ var DEV_SSR_STYLES_BASEPATH = process.env.TSS_DEV_SSR_STYLES_BASEPATH || "/";
4
+ /**
5
+ * @description Returns the router manifest data that should be sent to the client.
6
+ * This includes only the assets and preloads for the current route and any
7
+ * special assets that are needed for the client. It does not include relationships
8
+ * between routes or any other data that is not needed for the client.
9
+ *
10
+ * The client entry URL is returned separately so that it can be transformed
11
+ * (e.g. for CDN rewriting) before being embedded into the `<script>` tag.
12
+ *
13
+ * @param matchedRoutes - In dev mode, the matched routes are used to build
14
+ * the dev styles URL for route-scoped CSS collection.
15
+ */
3
16
  async function getStartManifest(matchedRoutes) {
4
- const { tsrStartManifest } = await import("tanstack-start-manifest:v");
5
- const startManifest = tsrStartManifest();
6
- const rootRoute = startManifest.routes[rootRouteId] = startManifest.routes[rootRouteId] || {};
7
- rootRoute.assets = rootRoute.assets || [];
8
- if (process.env.TSS_DEV_SERVER === "true" && process.env.TSS_DEV_SSR_STYLES_ENABLED !== "false" && matchedRoutes) {
9
- const matchedRouteIds = matchedRoutes.map((route) => route.id);
10
- rootRoute.assets.push({
11
- tag: "link",
12
- attrs: {
13
- rel: "stylesheet",
14
- href: buildDevStylesUrl(DEV_SSR_STYLES_BASEPATH, matchedRouteIds),
15
- "data-tanstack-router-dev-styles": "true"
16
- }
17
- });
18
- }
19
- let injectedHeadScripts;
20
- if (process.env.TSS_DEV_SERVER === "true") {
21
- const mod = await import("tanstack-start-injected-head-scripts:v");
22
- if (mod.injectedHeadScripts) {
23
- injectedHeadScripts = mod.injectedHeadScripts;
24
- }
25
- }
26
- const manifest = {
27
- routes: Object.fromEntries(
28
- Object.entries(startManifest.routes).flatMap(([k, v]) => {
29
- const result = {};
30
- let hasData = false;
31
- if (v.preloads && v.preloads.length > 0) {
32
- result["preloads"] = v.preloads;
33
- hasData = true;
34
- }
35
- if (v.assets && v.assets.length > 0) {
36
- result["assets"] = v.assets;
37
- hasData = true;
38
- }
39
- if (!hasData) {
40
- return [];
41
- }
42
- return [[k, result]];
43
- })
44
- )
45
- };
46
- return {
47
- manifest,
48
- clientEntry: startManifest.clientEntry,
49
- injectedHeadScripts
50
- };
17
+ const { tsrStartManifest } = await import("tanstack-start-manifest:v");
18
+ const startManifest = tsrStartManifest();
19
+ const rootRoute = startManifest.routes[rootRouteId] = startManifest.routes[rootRouteId] || {};
20
+ rootRoute.assets = rootRoute.assets || [];
21
+ if (process.env.TSS_DEV_SERVER === "true" && process.env.TSS_DEV_SSR_STYLES_ENABLED !== "false" && matchedRoutes) {
22
+ const matchedRouteIds = matchedRoutes.map((route) => route.id);
23
+ rootRoute.assets.push({
24
+ tag: "link",
25
+ attrs: {
26
+ rel: "stylesheet",
27
+ href: buildDevStylesUrl(DEV_SSR_STYLES_BASEPATH, matchedRouteIds),
28
+ "data-tanstack-router-dev-styles": "true"
29
+ }
30
+ });
31
+ }
32
+ let injectedHeadScripts;
33
+ if (process.env.TSS_DEV_SERVER === "true") {
34
+ const mod = await import("tanstack-start-injected-head-scripts:v");
35
+ if (mod.injectedHeadScripts) injectedHeadScripts = mod.injectedHeadScripts;
36
+ }
37
+ return {
38
+ manifest: { routes: Object.fromEntries(Object.entries(startManifest.routes).flatMap(([k, v]) => {
39
+ const result = {};
40
+ let hasData = false;
41
+ if (v.preloads && v.preloads.length > 0) {
42
+ result["preloads"] = v.preloads;
43
+ hasData = true;
44
+ }
45
+ if (v.assets && v.assets.length > 0) {
46
+ result["assets"] = v.assets;
47
+ hasData = true;
48
+ }
49
+ if (!hasData) return [];
50
+ return [[k, result]];
51
+ })) },
52
+ clientEntry: startManifest.clientEntry,
53
+ injectedHeadScripts
54
+ };
51
55
  }
52
- export {
53
- getStartManifest
54
- };
55
- //# sourceMappingURL=router-manifest.js.map
56
+ //#endregion
57
+ export { getStartManifest };
58
+
59
+ //# sourceMappingURL=router-manifest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router-manifest.js","sources":["../../src/router-manifest.ts"],"sourcesContent":["import { buildDevStylesUrl, rootRouteId } from '@tanstack/router-core'\nimport type { AnyRoute, RouterManagedTag } from '@tanstack/router-core'\nimport type { StartManifestWithClientEntry } from './transformAssetUrls'\n\n// Pre-computed constant for dev styles URL basepath.\n// Defaults to vite `base` (set via TSS_DEV_SSR_STYLES_BASEPATH in the plugin),\n// aligning dev styles with how other CSS/JS assets are served.\nconst DEV_SSR_STYLES_BASEPATH = process.env.TSS_DEV_SSR_STYLES_BASEPATH || '/'\n\n/**\n * @description Returns the router manifest data that should be sent to the client.\n * This includes only the assets and preloads for the current route and any\n * special assets that are needed for the client. It does not include relationships\n * between routes or any other data that is not needed for the client.\n *\n * The client entry URL is returned separately so that it can be transformed\n * (e.g. for CDN rewriting) before being embedded into the `<script>` tag.\n *\n * @param matchedRoutes - In dev mode, the matched routes are used to build\n * the dev styles URL for route-scoped CSS collection.\n */\nexport async function getStartManifest(\n matchedRoutes?: ReadonlyArray<AnyRoute>,\n): Promise<StartManifestWithClientEntry> {\n const { tsrStartManifest } = await import('tanstack-start-manifest:v')\n const startManifest = tsrStartManifest()\n\n const rootRoute = (startManifest.routes[rootRouteId] =\n startManifest.routes[rootRouteId] || {})\n\n rootRoute.assets = rootRoute.assets || []\n\n // Inject dev styles link in dev mode (when SSR styles are enabled)\n if (\n process.env.TSS_DEV_SERVER === 'true' &&\n process.env.TSS_DEV_SSR_STYLES_ENABLED !== 'false' &&\n matchedRoutes\n ) {\n const matchedRouteIds = matchedRoutes.map((route) => route.id)\n rootRoute.assets.push({\n tag: 'link',\n attrs: {\n rel: 'stylesheet',\n href: buildDevStylesUrl(DEV_SSR_STYLES_BASEPATH, matchedRouteIds),\n 'data-tanstack-router-dev-styles': 'true',\n },\n })\n }\n\n // Collect injected head scripts in dev mode (returned separately so we can\n // build the client entry script tag after URL transforms are applied)\n let injectedHeadScripts: string | undefined\n if (process.env.TSS_DEV_SERVER === 'true') {\n const mod = await import('tanstack-start-injected-head-scripts:v')\n if (mod.injectedHeadScripts) {\n injectedHeadScripts = mod.injectedHeadScripts\n }\n }\n\n const manifest = {\n routes: Object.fromEntries(\n Object.entries(startManifest.routes).flatMap(([k, v]) => {\n const result = {} as {\n preloads?: Array<string>\n assets?: Array<RouterManagedTag>\n }\n let hasData = false\n if (v.preloads && v.preloads.length > 0) {\n result['preloads'] = v.preloads\n hasData = true\n }\n if (v.assets && v.assets.length > 0) {\n result['assets'] = v.assets\n hasData = true\n }\n if (!hasData) {\n return []\n }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,iBAAO,CAAA;AAAA,QACT;AACA,eAAO,CAAC,CAAC,GAAG,MAAM,CAAC;AAAA,MACrB,CAAC;AAAA,IAAA;AAAA,EACH;AAGF,SAAO;AAAA,IACL;AAAA,IACA,aAAa,cAAc;AAAA,IAC3B;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"router-manifest.js","names":[],"sources":["../../src/router-manifest.ts"],"sourcesContent":["import { buildDevStylesUrl, rootRouteId } from '@tanstack/router-core'\nimport type { AnyRoute, RouterManagedTag } from '@tanstack/router-core'\nimport type { StartManifestWithClientEntry } from './transformAssetUrls'\n\n// Pre-computed constant for dev styles URL basepath.\n// Defaults to vite `base` (set via TSS_DEV_SSR_STYLES_BASEPATH in the plugin),\n// aligning dev styles with how other CSS/JS assets are served.\nconst DEV_SSR_STYLES_BASEPATH = process.env.TSS_DEV_SSR_STYLES_BASEPATH || '/'\n\n/**\n * @description Returns the router manifest data that should be sent to the client.\n * This includes only the assets and preloads for the current route and any\n * special assets that are needed for the client. It does not include relationships\n * between routes or any other data that is not needed for the client.\n *\n * The client entry URL is returned separately so that it can be transformed\n * (e.g. for CDN rewriting) before being embedded into the `<script>` tag.\n *\n * @param matchedRoutes - In dev mode, the matched routes are used to build\n * the dev styles URL for route-scoped CSS collection.\n */\nexport async function getStartManifest(\n matchedRoutes?: ReadonlyArray<AnyRoute>,\n): Promise<StartManifestWithClientEntry> {\n const { tsrStartManifest } = await import('tanstack-start-manifest:v')\n const startManifest = tsrStartManifest()\n\n const rootRoute = (startManifest.routes[rootRouteId] =\n startManifest.routes[rootRouteId] || {})\n\n rootRoute.assets = rootRoute.assets || []\n\n // Inject dev styles link in dev mode (when SSR styles are enabled)\n if (\n process.env.TSS_DEV_SERVER === 'true' &&\n process.env.TSS_DEV_SSR_STYLES_ENABLED !== 'false' &&\n matchedRoutes\n ) {\n const matchedRouteIds = matchedRoutes.map((route) => route.id)\n rootRoute.assets.push({\n tag: 'link',\n attrs: {\n rel: 'stylesheet',\n href: buildDevStylesUrl(DEV_SSR_STYLES_BASEPATH, matchedRouteIds),\n 'data-tanstack-router-dev-styles': 'true',\n },\n })\n }\n\n // Collect injected head scripts in dev mode (returned separately so we can\n // build the client entry script tag after URL transforms are applied)\n let injectedHeadScripts: string | undefined\n if (process.env.TSS_DEV_SERVER === 'true') {\n const mod = await import('tanstack-start-injected-head-scripts:v')\n if (mod.injectedHeadScripts) {\n injectedHeadScripts = mod.injectedHeadScripts\n }\n }\n\n const manifest = {\n routes: Object.fromEntries(\n Object.entries(startManifest.routes).flatMap(([k, v]) => {\n const result = {} as {\n preloads?: Array<string>\n assets?: Array<RouterManagedTag>\n }\n let hasData = false\n if (v.preloads && v.preloads.length > 0) {\n result['preloads'] = v.preloads\n hasData = true\n }\n if (v.assets && v.assets.length > 0) {\n result['assets'] = v.assets\n hasData = true\n }\n if (!hasData) {\n return []\n }\n return [[k, result]]\n }),\n ),\n }\n\n return {\n manifest,\n clientEntry: startManifest.clientEntry,\n injectedHeadScripts,\n }\n}\n"],"mappings":";;AAOA,IAAM,0BAA0B,QAAQ,IAAI,+BAA+B;;;;;;;;;;;;;AAc3E,eAAsB,iBACpB,eACuC;CACvC,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,MAAM,gBAAgB,kBAAkB;CAExC,MAAM,YAAa,cAAc,OAAO,eACtC,cAAc,OAAO,gBAAgB,EAAE;AAEzC,WAAU,SAAS,UAAU,UAAU,EAAE;AAGzC,KACE,QAAQ,IAAI,mBAAmB,UAC/B,QAAQ,IAAI,+BAA+B,WAC3C,eACA;EACA,MAAM,kBAAkB,cAAc,KAAK,UAAU,MAAM,GAAG;AAC9D,YAAU,OAAO,KAAK;GACpB,KAAK;GACL,OAAO;IACL,KAAK;IACL,MAAM,kBAAkB,yBAAyB,gBAAgB;IACjE,mCAAmC;IACpC;GACF,CAAC;;CAKJ,IAAI;AACJ,KAAI,QAAQ,IAAI,mBAAmB,QAAQ;EACzC,MAAM,MAAM,MAAM,OAAO;AACzB,MAAI,IAAI,oBACN,uBAAsB,IAAI;;AA4B9B,QAAO;EACL,UAzBe,EACf,QAAQ,OAAO,YACb,OAAO,QAAQ,cAAc,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO;GACvD,MAAM,SAAS,EAAE;GAIjB,IAAI,UAAU;AACd,OAAI,EAAE,YAAY,EAAE,SAAS,SAAS,GAAG;AACvC,WAAO,cAAc,EAAE;AACvB,cAAU;;AAEZ,OAAI,EAAE,UAAU,EAAE,OAAO,SAAS,GAAG;AACnC,WAAO,YAAY,EAAE;AACrB,cAAU;;AAEZ,OAAI,CAAC,QACH,QAAO,EAAE;AAEX,UAAO,CAAC,CAAC,GAAG,OAAO,CAAC;IACpB,CACH,EACF;EAIC,aAAa,cAAc;EAC3B;EACD"}