reroute-js 0.38.3 → 0.40.0
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 +5 -1
- package/_/blog/src/client/routes/blog/[layout].tsx +3 -8
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +47 -22
- package/cli/bin.js.map +19 -18
- package/cli/index.d.ts +1 -1
- package/cli/index.js +4 -4
- package/cli/index.js.map +1 -1
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts +1 -1
- package/cli/src/commands/build.d.ts +1 -1
- package/cli/src/commands/dev.d.ts +1 -1
- package/cli/src/commands/gen.d.ts +1 -1
- package/cli/src/commands/index.d.ts +1 -1
- package/cli/src/commands/init.d.ts +1 -1
- package/cli/src/commands/lib/assets.d.ts +1 -1
- package/cli/src/commands/lib/bundler.d.ts +1 -1
- package/cli/src/commands/lib/command.d.ts +1 -1
- package/cli/src/commands/lib/env.d.ts +1 -1
- package/cli/src/commands/lib/index.d.ts +1 -1
- package/cli/src/commands/lib/log.d.ts +1 -1
- package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
- package/cli/src/commands/lib/markdown/index.d.ts +1 -1
- package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
- package/cli/src/commands/lib/production.d.ts +1 -1
- package/cli/src/commands/lib/server.d.ts +1 -1
- package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
- package/cli/src/commands/lib/streaming/analyzer.d.ts.map +1 -1
- package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
- package/cli/src/commands/lib/tailwind.d.ts +1 -1
- package/cli/src/commands/lib/terminal-ui.d.ts +1 -1
- package/cli/src/commands/lib/version.d.ts +1 -1
- package/cli/src/commands/og.d.ts +1 -1
- package/cli/src/commands/start.d.ts +1 -1
- package/cli/src/index.d.ts +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +41 -16
- package/core/index.js.map +18 -17
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/config.d.ts +17 -8
- package/core/src/config.d.ts.map +1 -1
- package/core/src/content/discovery.d.ts +1 -1
- package/core/src/content/index.d.ts +1 -1
- package/core/src/content/metadata.d.ts +1 -1
- package/core/src/index.d.ts +1 -1
- package/core/src/llms/extractor.d.ts +1 -1
- package/core/src/llms/formatter.d.ts +1 -1
- package/core/src/llms/full-generator.d.ts +1 -1
- package/core/src/llms/index-generator.d.ts +1 -1
- package/core/src/llms/index-generator.d.ts.map +1 -1
- package/core/src/llms/index.d.ts +1 -1
- package/core/src/og/discovery.d.ts +1 -1
- package/core/src/og/index.d.ts +1 -1
- package/core/src/og/meta.d.ts +1 -1
- package/core/src/og/render.d.ts +1 -1
- package/core/src/og/types.d.ts +1 -1
- package/core/src/robots/discovery.d.ts +1 -1
- package/core/src/robots/generator.d.ts +1 -1
- package/core/src/robots/index.d.ts +1 -1
- package/core/src/robots/policies.d.ts +1 -1
- package/core/src/rss/discovery.d.ts +1 -1
- package/core/src/rss/discovery.d.ts.map +1 -1
- package/core/src/rss/generator.d.ts +1 -1
- package/core/src/rss/index.d.ts +1 -1
- package/core/src/sitemap/discovery.d.ts +1 -1
- package/core/src/sitemap/discovery.d.ts.map +1 -1
- package/core/src/sitemap/generator.d.ts +1 -1
- package/core/src/sitemap/index.d.ts +1 -1
- package/core/src/ssr/index.d.ts +1 -1
- package/core/src/ssr/lib/cache.d.ts +1 -1
- package/core/src/ssr/lib/collections.d.ts +1 -1
- package/core/src/ssr/lib/compression.d.ts +1 -1
- package/core/src/ssr/lib/compute/content.d.ts +1 -1
- package/core/src/ssr/lib/compute/content.d.ts.map +1 -1
- package/core/src/ssr/lib/compute/index.d.ts +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts.map +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts.map +1 -1
- package/core/src/ssr/lib/data.d.ts +1 -1
- package/core/src/ssr/lib/data.d.ts.map +1 -1
- package/core/src/ssr/lib/html.d.ts +1 -1
- package/core/src/ssr/lib/imports.d.ts +1 -1
- package/core/src/ssr/lib/index.d.ts +1 -1
- package/core/src/ssr/lib/layouts.d.ts +1 -1
- package/core/src/ssr/lib/metadata.d.ts +1 -1
- package/core/src/ssr/lib/metadata.d.ts.map +1 -1
- package/core/src/ssr/lib/mime.d.ts +1 -1
- package/core/src/ssr/lib/modules.d.ts +1 -1
- package/core/src/ssr/lib/path.d.ts +1 -1
- package/core/src/ssr/lib/preload.d.ts +1 -1
- package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
- package/core/src/ssr/lib/scripts/data.d.ts +1 -1
- package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
- package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
- package/core/src/ssr/lib/scripts/index.d.ts +1 -1
- package/core/src/ssr/lib/seed.d.ts +1 -1
- package/core/src/ssr/lib/serialize.d.ts +1 -1
- package/core/src/ssr/lib/setup.d.ts +3 -1
- package/core/src/ssr/lib/setup.d.ts.map +1 -1
- package/core/src/ssr/lib/styles.d.ts +1 -1
- package/core/src/ssr/lib/template.d.ts +1 -1
- package/core/src/ssr/lib/types.d.ts +126 -2
- package/core/src/ssr/lib/types.d.ts.map +1 -1
- package/core/src/ssr/render.d.ts +3 -1
- package/core/src/ssr/render.d.ts.map +1 -1
- package/core/src/ssr/stream.d.ts +5 -1
- package/core/src/ssr/stream.d.ts.map +1 -1
- package/elysia/index.d.ts +1 -1
- package/elysia/index.js +83 -52
- package/elysia/index.js.map +20 -19
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/assets.d.ts +1 -1
- package/elysia/src/libs/cache.d.ts +1 -1
- package/elysia/src/libs/caching.d.ts +1 -1
- package/elysia/src/libs/http.d.ts +1 -1
- package/elysia/src/libs/image.d.ts +1 -1
- package/elysia/src/libs/index.d.ts +1 -1
- package/elysia/src/libs/llms.d.ts +1 -1
- package/elysia/src/libs/response.d.ts +1 -1
- package/elysia/src/libs/serving.d.ts +1 -1
- package/elysia/src/plugin.d.ts +1 -1
- package/elysia/src/plugin.d.ts.map +1 -1
- package/elysia/src/routes/artifacts.d.ts +1 -1
- package/elysia/src/routes/content.d.ts +1 -1
- package/elysia/src/routes/image.d.ts +1 -1
- package/elysia/src/routes/index.d.ts +1 -1
- package/elysia/src/routes/internal.d.ts +1 -1
- package/elysia/src/routes/llms.d.ts +1 -1
- package/elysia/src/routes/og.d.ts +1 -1
- package/elysia/src/routes/redirects.d.ts +1 -1
- package/elysia/src/routes/robots.d.ts +1 -1
- package/elysia/src/routes/rss.d.ts +1 -1
- package/elysia/src/routes/search.d.ts +1 -1
- package/elysia/src/routes/sitemap.d.ts +1 -1
- package/elysia/src/routes/ssr.d.ts +2 -1
- package/elysia/src/routes/ssr.d.ts.map +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/types.d.ts +1 -1
- package/package.json +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.js +2 -2
- package/react/index.js.map +1 -1
- package/react/src/components/ClientOnly.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts +1 -1
- package/react/src/components/Image.d.ts +1 -1
- package/react/src/components/LazyRoute.d.ts +1 -1
- package/react/src/components/Link.d.ts +1 -1
- package/react/src/components/Markdown.d.ts +1 -1
- package/react/src/components/Outlet.d.ts +1 -1
- package/react/src/components/index.d.ts +1 -1
- package/react/src/hooks/index.d.ts +1 -1
- package/react/src/hooks/useContent.d.ts +1 -1
- package/react/src/hooks/useData.d.ts +1 -1
- package/react/src/hooks/useFeed.d.ts +1 -1
- package/react/src/hooks/useLayoutData.d.ts +1 -1
- package/react/src/hooks/useLlms.d.ts +1 -1
- package/react/src/hooks/useNavigate.d.ts +1 -1
- package/react/src/hooks/useParams.d.ts +1 -1
- package/react/src/hooks/useRouter.d.ts +1 -1
- package/react/src/hooks/useSearch.d.ts +1 -1
- package/react/src/hooks/useSearchParams.d.ts +1 -1
- package/react/src/hooks/useToc.d.ts +1 -1
- package/react/src/index.d.ts +1 -1
- package/react/src/lib/collection.d.ts +1 -1
- package/react/src/lib/content.d.ts +1 -1
- package/react/src/lib/head.d.ts +1 -1
- package/react/src/lib/index.d.ts +1 -1
- package/react/src/lib/lazy-route.d.ts +1 -1
- package/react/src/lib/route-loader.d.ts +1 -1
- package/react/src/providers/ContentProvider.d.ts +1 -1
- package/react/src/providers/RerouteProvider.d.ts +1 -1
- package/react/src/providers/RouterProvider.d.ts +1 -1
- package/react/src/providers/index.d.ts +1 -1
- package/react/src/types/any.d.ts +1 -1
- package/react/src/types/index.d.ts +1 -1
- package/react/src/types/router.d.ts +1 -1
- package/telemetry/react.d.ts +1 -1
- package/telemetry/react.js +2 -2
- package/telemetry/react.js.map +1 -1
- package/telemetry/server.d.ts +1 -1
- package/telemetry/server.js +87 -25
- package/telemetry/server.js.map +18 -15
- package/telemetry/src/react/api.d.ts +1 -1
- package/telemetry/src/react/context.d.ts +1 -1
- package/telemetry/src/react/index.d.ts +1 -1
- package/telemetry/src/react/telemetry.d.ts +1 -1
- package/telemetry/src/server/context.d.ts +1 -1
- package/telemetry/src/server/headers/extractor.d.ts +32 -0
- package/telemetry/src/server/headers/extractor.d.ts.map +1 -0
- package/telemetry/src/server/headers/index.d.ts +12 -0
- package/telemetry/src/server/headers/index.d.ts.map +1 -0
- package/telemetry/src/server/headers/presets.d.ts +134 -0
- package/telemetry/src/server/headers/presets.d.ts.map +1 -0
- package/telemetry/src/server/index.d.ts +2 -1
- package/telemetry/src/server/index.d.ts.map +1 -1
- package/telemetry/src/server/instrumentation.d.ts +1 -1
- package/telemetry/src/server/plugin.d.ts +1 -1
- package/telemetry/src/server/plugin.d.ts.map +1 -1
- package/telemetry/src/server/sourcemap.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* reroute-js v0.
|
|
2
|
+
* reroute-js v0.40.0
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 stewones <hi@stewan.io>
|
|
@@ -88,6 +88,8 @@ type ComputeResult = {
|
|
|
88
88
|
type ComputeOptions = {
|
|
89
89
|
streaming?: boolean;
|
|
90
90
|
maxAge?: number;
|
|
91
|
+
/** Request headers from the incoming HTTP request */
|
|
92
|
+
headers?: Record<string, string>;
|
|
91
93
|
};
|
|
92
94
|
/**
|
|
93
95
|
* Result of metadata extraction
|
|
@@ -148,5 +150,127 @@ type RouteMatch = {
|
|
|
148
150
|
};
|
|
149
151
|
params: Record<string, string>;
|
|
150
152
|
} | null;
|
|
151
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Context passed to SSR data functions.
|
|
155
|
+
* This is the argument received by the `data` function in route/layout SSR exports.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* export const ssr = {
|
|
160
|
+
* async data({ pathname, params, set, searchParams, headers }: SSRContext) {
|
|
161
|
+
* // Forward browser headers to external APIs to avoid being flagged as bots
|
|
162
|
+
* const response = await fetch('https://api.example.com/data', {
|
|
163
|
+
* headers: {
|
|
164
|
+
* 'User-Agent': headers?.['user-agent'] || 'reroute-ssr',
|
|
165
|
+
* 'Accept-Language': headers?.['accept-language'] || 'en',
|
|
166
|
+
* 'Accept-Encoding': headers?.['accept-encoding'] || 'gzip, deflate',
|
|
167
|
+
* }
|
|
168
|
+
* });
|
|
169
|
+
* return response.json();
|
|
170
|
+
* }
|
|
171
|
+
* };
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
type SSRContext = {
|
|
175
|
+
/** The current pathname being rendered (e.g., "/blog/my-post") */
|
|
176
|
+
pathname: string;
|
|
177
|
+
/** Dynamic route parameters extracted from the URL pattern */
|
|
178
|
+
params: Record<string, string>;
|
|
179
|
+
/** Object to set HTTP status code (e.g., set.status = 404) */
|
|
180
|
+
set?: {
|
|
181
|
+
status: number;
|
|
182
|
+
};
|
|
183
|
+
/** URL search parameters (query string) */
|
|
184
|
+
searchParams?: URLSearchParams;
|
|
185
|
+
/** Request headers from the incoming HTTP request (useful for forwarding to APIs) */
|
|
186
|
+
headers?: Record<string, string>;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Context passed to SSR head functions.
|
|
190
|
+
* Provides access to the resolved data from the data function.
|
|
191
|
+
*/
|
|
192
|
+
type SSRHeadContext<DataType = unknown> = {
|
|
193
|
+
/** The resolved data from the SSR data function */
|
|
194
|
+
data?: DataType;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Type-safe SSR export for routes and layouts.
|
|
198
|
+
* Use this type to get full type safety for your SSR configuration.
|
|
199
|
+
*
|
|
200
|
+
* @template DataType - The type of data returned by the data function
|
|
201
|
+
*
|
|
202
|
+
* @example Basic usage with data
|
|
203
|
+
* ```ts
|
|
204
|
+
* import type { SSR } from 'reroute-js/core';
|
|
205
|
+
*
|
|
206
|
+
* type MyData = {
|
|
207
|
+
* title: string;
|
|
208
|
+
* items: string[];
|
|
209
|
+
* };
|
|
210
|
+
*
|
|
211
|
+
* export const ssr: SSR<MyData> = {
|
|
212
|
+
* async data({ pathname, params }) {
|
|
213
|
+
* return {
|
|
214
|
+
* title: 'My Page',
|
|
215
|
+
* items: ['a', 'b', 'c']
|
|
216
|
+
* };
|
|
217
|
+
* }
|
|
218
|
+
* };
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* @example With head and lang
|
|
222
|
+
* ```ts
|
|
223
|
+
* export const ssr: SSR<MyData> = {
|
|
224
|
+
* async data({ pathname }) {
|
|
225
|
+
* return { title: 'My Page', items: [] };
|
|
226
|
+
* },
|
|
227
|
+
* head: ({ data }) => `<meta name="description" content="${data?.title}" />`,
|
|
228
|
+
* lang: 'en-US'
|
|
229
|
+
* };
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
type SSR<DataType = unknown> = {
|
|
233
|
+
/**
|
|
234
|
+
* Server-side data fetching function.
|
|
235
|
+
* Called during SSR to provide data to your component.
|
|
236
|
+
*
|
|
237
|
+
* @param context - SSR context with pathname, params, set, and searchParams
|
|
238
|
+
* @returns Data to be passed to the component (can be a Promise or plain value)
|
|
239
|
+
*/
|
|
240
|
+
data?: (context: SSRContext) => DataType | Promise<DataType>;
|
|
241
|
+
/**
|
|
242
|
+
* Additional HTML to inject into the document <head>.
|
|
243
|
+
* Can be a string, array of strings, or function that receives the resolved data.
|
|
244
|
+
*
|
|
245
|
+
* @example String
|
|
246
|
+
* ```ts
|
|
247
|
+
* head: '<meta name="description" content="My page" />'
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @example Array
|
|
251
|
+
* ```ts
|
|
252
|
+
* head: [
|
|
253
|
+
* '<meta name="description" content="My page" />',
|
|
254
|
+
* '<meta property="og:title" content="My Page" />'
|
|
255
|
+
* ]
|
|
256
|
+
* ```
|
|
257
|
+
*
|
|
258
|
+
* @example Function (with access to data)
|
|
259
|
+
* ```ts
|
|
260
|
+
* head: ({ data }) => `<meta name="description" content="${data?.title}" />`
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
head?: string | string[] | ((context: SSRHeadContext<DataType>) => string);
|
|
264
|
+
/**
|
|
265
|
+
* Language code for the page (e.g., 'en', 'en-US', 'es').
|
|
266
|
+
* Sets the lang attribute on the <html> element.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```ts
|
|
270
|
+
* lang: 'en-US'
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
lang?: string;
|
|
274
|
+
};
|
|
275
|
+
export type { Doc, TemplateContext, BundleInfo, ContentMeta, ContentItemDTO, CompressionResult, PreloadResult, ComputeResult, ComputeOptions, MetadataResult, CacheEntry, TemplateParts, StreamCompressionResult, ComputeParams, LayoutDef, RouteMatch, SSRContext, SSRHeadContext, SSR, };
|
|
152
276
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":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,GAAG;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,KAAK,aAAa,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,eAAe,EAAE;QAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,KAAK,cAAc,GAAG;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/src/ssr/lib/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,GAAG,GAAG,GAAG,CAAC;AAEf;;GAEG;AACH,KAAK,eAAe,GAAG;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,KAAK,UAAU,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;CACJ,CAAC;AAEF;;GAEG;AACH,KAAK,WAAW,GAAG;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE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
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 stewones <hi@stewan.io>
|
|
@@ -29,6 +29,8 @@ type SSRRenderOptions = {
|
|
|
29
29
|
baseUrl?: string;
|
|
30
30
|
autoCanonical?: boolean;
|
|
31
31
|
parentSpan?: Span | null;
|
|
32
|
+
/** Request headers from the incoming HTTP request */
|
|
33
|
+
headers?: Record<string, string>;
|
|
32
34
|
};
|
|
33
35
|
type SSRRenderResult = {
|
|
34
36
|
html: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/src/ssr/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAOxD,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAW5D,KAAK,gBAAgB,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,YAAY,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAC9C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACx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AAO,EAAE,gBAAgB,GACvB,OAAO,CAAC,eAAe,CAAC,CA0I1B;AAED,OAAO,EAAE,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,CAAC"}
|
package/core/src/ssr/stream.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* reroute-js v0.
|
|
2
|
+
* reroute-js v0.40.0
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 stewones <hi@stewan.io>
|
|
@@ -30,6 +30,10 @@ type StreamingSSROptions = {
|
|
|
30
30
|
baseUrl?: string;
|
|
31
31
|
autoCanonical?: boolean;
|
|
32
32
|
parentSpan?: Span | null;
|
|
33
|
+
/** Request headers from the incoming HTTP request */
|
|
34
|
+
headers?: Record<string, string>;
|
|
35
|
+
/** Maximum streaming timeout in milliseconds (default: 120000 / 120s) */
|
|
36
|
+
timeout?: number;
|
|
33
37
|
};
|
|
34
38
|
type StreamingSSRResult = {
|
|
35
39
|
stream: ReadableStream<Uint8Array>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/src/ssr/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAOxD,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAa5D,KAAK,mBAAmB,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,YAAY,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC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C,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACzB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,iBAAe,uBAAuB,CACrC,OAAO,EAAE,mBAAmB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CAgK7B;AA4ND,OAAO,EAAE,uBAAuB,EAAE,CAAC;AACnC,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,CAAC"}
|
package/elysia/index.d.ts
CHANGED
package/elysia/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* reroute-js v0.
|
|
2
|
+
* reroute-js v0.40.0
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 stewones <hi@stewan.io>
|
|
@@ -199,6 +199,13 @@ var contextStorage;
|
|
|
199
199
|
var init_context = __esm(() => {
|
|
200
200
|
contextStorage = new AsyncLocalStorage;
|
|
201
201
|
});
|
|
202
|
+
// packages/telemetry/src/server/headers/presets.ts
|
|
203
|
+
var init_presets = () => {};
|
|
204
|
+
|
|
205
|
+
// packages/telemetry/src/server/headers/index.ts
|
|
206
|
+
var init_headers = __esm(() => {
|
|
207
|
+
init_presets();
|
|
208
|
+
});
|
|
202
209
|
|
|
203
210
|
// packages/telemetry/src/server/instrumentation.ts
|
|
204
211
|
import { context, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -367,6 +374,7 @@ var init_plugin = __esm(() => {
|
|
|
367
374
|
// packages/telemetry/src/server/index.ts
|
|
368
375
|
var init_server = __esm(() => {
|
|
369
376
|
init_context();
|
|
377
|
+
init_headers();
|
|
370
378
|
init_instrumentation();
|
|
371
379
|
init_plugin();
|
|
372
380
|
init_sourcemap();
|
|
@@ -599,12 +607,13 @@ function checkDataCache(cacheKey, maxAgeMs) {
|
|
|
599
607
|
return;
|
|
600
608
|
return ssrCache.get(cacheKey);
|
|
601
609
|
}
|
|
602
|
-
function createDataTask(dataFn, pathname, parts, searchParams, set) {
|
|
610
|
+
function createDataTask(dataFn, pathname, parts, searchParams, set, headers2) {
|
|
603
611
|
return toPromise(dataFn({
|
|
604
612
|
pathname,
|
|
605
613
|
params: { name: parts[1] },
|
|
606
614
|
set,
|
|
607
|
-
searchParams
|
|
615
|
+
searchParams,
|
|
616
|
+
headers: headers2
|
|
608
617
|
})).catch((err) => {
|
|
609
618
|
const msg = err instanceof Error ? err.message : String(err);
|
|
610
619
|
const error = `SSR data() failed: ${msg}`;
|
|
@@ -671,7 +680,7 @@ async function computeContentData(pathname, options, searchParams, sharedSsrData
|
|
|
671
680
|
return { data: ssrData, statusOverride, pendingTasks };
|
|
672
681
|
}
|
|
673
682
|
const set = { status: 200 };
|
|
674
|
-
const task = createDataTask(dataFn, pathname, parts, searchParams, set);
|
|
683
|
+
const task = createDataTask(dataFn, pathname, parts, searchParams, set, options.headers);
|
|
675
684
|
if (streaming) {
|
|
676
685
|
handleStreamingMode(ssrData, pathname, task, set, cacheKey, statusCacheKey, maxAgeMs, pendingTasks);
|
|
677
686
|
if (set.status !== 200) {
|
|
@@ -731,9 +740,15 @@ function checkLayoutCache(cacheKey, statusCacheKey, maxAgeMs) {
|
|
|
731
740
|
const cachedData = maxAgeMs > 0 ? ssrCache.get(cacheKey) : undefined;
|
|
732
741
|
return { cachedData, cachedStatus };
|
|
733
742
|
}
|
|
734
|
-
function createLayoutDataTask(dataFn, pathname, searchParams, layoutPattern) {
|
|
743
|
+
function createLayoutDataTask(dataFn, pathname, searchParams, layoutPattern, headers2) {
|
|
735
744
|
const set = { status: 200 };
|
|
736
|
-
return toPromise(dataFn({
|
|
745
|
+
return toPromise(dataFn({
|
|
746
|
+
pathname,
|
|
747
|
+
params: {},
|
|
748
|
+
set,
|
|
749
|
+
searchParams,
|
|
750
|
+
headers: headers2
|
|
751
|
+
})).catch((err) => {
|
|
737
752
|
const msg = err instanceof Error ? err.message : String(err);
|
|
738
753
|
console.error(`[reroute] Layout SSR data() failed for ${layoutPattern}:`, msg);
|
|
739
754
|
throw err;
|
|
@@ -741,6 +756,9 @@ function createLayoutDataTask(dataFn, pathname, searchParams, layoutPattern) {
|
|
|
741
756
|
}
|
|
742
757
|
function handleLayoutStreamingMode(ssrData, layoutKey, task, set, cacheKey, statusCacheKey, maxAgeMs, pendingTasks) {
|
|
743
758
|
ssrData[layoutKey] = task;
|
|
759
|
+
const g = globalThis;
|
|
760
|
+
g.__REROUTE_DATA__ = g.__REROUTE_DATA__ || {};
|
|
761
|
+
g.__REROUTE_DATA__[layoutKey] = task;
|
|
744
762
|
const storeTask = task.then((value) => {
|
|
745
763
|
if (maxAgeMs > 0) {
|
|
746
764
|
statusCache.set(statusCacheKey, set.status, maxAgeMs);
|
|
@@ -752,6 +770,9 @@ function handleLayoutStreamingMode(ssrData, layoutKey, task, set, cacheKey, stat
|
|
|
752
770
|
});
|
|
753
771
|
pendingTasks.push(storeTask.then((value) => {
|
|
754
772
|
ssrData[layoutKey] = value;
|
|
773
|
+
if (g.__REROUTE_DATA__) {
|
|
774
|
+
g.__REROUTE_DATA__[layoutKey] = value;
|
|
775
|
+
}
|
|
755
776
|
}).catch(() => {}));
|
|
756
777
|
}
|
|
757
778
|
async function handleLayoutNonStreamingMode(ssrData, layoutKey, task, cacheKey, statusCacheKey, maxAgeMs) {
|
|
@@ -765,7 +786,7 @@ async function handleLayoutNonStreamingMode(ssrData, layoutKey, task, cacheKey,
|
|
|
765
786
|
}
|
|
766
787
|
return result;
|
|
767
788
|
}
|
|
768
|
-
async function processLayout(layout, pathname, clientDir, isWatchMode, streaming, maxAgeMs, searchParams, ssrData, pendingTasks) {
|
|
789
|
+
async function processLayout(layout, pathname, clientDir, isWatchMode, streaming, maxAgeMs, searchParams, ssrData, pendingTasks, headers2) {
|
|
769
790
|
if (typeof layout?.path !== "string")
|
|
770
791
|
return;
|
|
771
792
|
const ssrExport = await loadLayoutSSRExport(layout, clientDir, isWatchMode);
|
|
@@ -785,7 +806,7 @@ async function processLayout(layout, pathname, clientDir, isWatchMode, streaming
|
|
|
785
806
|
return;
|
|
786
807
|
}
|
|
787
808
|
const set = { status: 200 };
|
|
788
|
-
const task = createLayoutDataTask(dataFn, pathname, searchParams, pattern);
|
|
809
|
+
const task = createLayoutDataTask(dataFn, pathname, searchParams, pattern, headers2);
|
|
789
810
|
if (streaming) {
|
|
790
811
|
handleLayoutStreamingMode(ssrData, layoutKey, task, set, cacheKey, statusCacheKey, maxAgeMs, pendingTasks);
|
|
791
812
|
} else {
|
|
@@ -805,7 +826,7 @@ async function computeLayoutData(pathname, clientDir, _cwd, isWatchMode, options
|
|
|
805
826
|
const matchingLayouts = getMatchingLayouts(pathname, layouts);
|
|
806
827
|
for (const layout of matchingLayouts) {
|
|
807
828
|
try {
|
|
808
|
-
const layoutStatus = await processLayout(layout, pathname, clientDir, isWatchMode, streaming, maxAgeMs, searchParams, ssrData, pendingTasks);
|
|
829
|
+
const layoutStatus = await processLayout(layout, pathname, clientDir, isWatchMode, streaming, maxAgeMs, searchParams, ssrData, pendingTasks, options.headers);
|
|
809
830
|
if (layoutStatus && !statusOverride) {
|
|
810
831
|
statusOverride = layoutStatus;
|
|
811
832
|
}
|
|
@@ -905,7 +926,8 @@ async function computeRouteData(pathname, clientDir, _cwd, isWatchMode, options,
|
|
|
905
926
|
pathname,
|
|
906
927
|
params,
|
|
907
928
|
set,
|
|
908
|
-
searchParams
|
|
929
|
+
searchParams,
|
|
930
|
+
headers: options.headers
|
|
909
931
|
});
|
|
910
932
|
const isPromise = rawResult instanceof Promise;
|
|
911
933
|
if (streaming) {
|
|
@@ -2496,7 +2518,7 @@ async function performSSRSetupInternal(options, streaming) {
|
|
|
2496
2518
|
const computeResult = await withSpan("ssr.compute.data", async (span) => {
|
|
2497
2519
|
span.setAttribute("pathname", pathname);
|
|
2498
2520
|
span.setAttribute("streaming", streaming);
|
|
2499
|
-
const result = await computeSSRData(pathname, clientDir, cwd, isWatchMode, { streaming, maxAge }, searchParams);
|
|
2521
|
+
const result = await computeSSRData(pathname, clientDir, cwd, isWatchMode, { streaming, maxAge, headers: options.headers }, searchParams);
|
|
2500
2522
|
span.setAttribute("has_error", !!result.error);
|
|
2501
2523
|
span.setAttribute("has_data", Object.keys(result.data).length > 0);
|
|
2502
2524
|
if (debug)
|
|
@@ -2704,7 +2726,8 @@ async function renderSSRDocument(options) {
|
|
|
2704
2726
|
baseUrl: options.baseUrl,
|
|
2705
2727
|
autoCanonical: options.autoCanonical,
|
|
2706
2728
|
cachedCollections: options.cachedCollections,
|
|
2707
|
-
cachedTailwindCSS: options.cachedTailwindCSS
|
|
2729
|
+
cachedTailwindCSS: options.cachedTailwindCSS,
|
|
2730
|
+
headers: options.headers
|
|
2708
2731
|
}, false);
|
|
2709
2732
|
const duplicatedData = duplicateQueryParamData(setup2.ssrData);
|
|
2710
2733
|
setGlobalSSRData(duplicatedData);
|
|
@@ -4814,7 +4837,8 @@ async function renderSSRDocumentStream(options) {
|
|
|
4814
4837
|
autoCanonical: options.autoCanonical,
|
|
4815
4838
|
cachedCollections: options.cachedCollections,
|
|
4816
4839
|
cachedTailwindCSS: options.cachedTailwindCSS,
|
|
4817
|
-
debug
|
|
4840
|
+
debug,
|
|
4841
|
+
headers: options.headers
|
|
4818
4842
|
}, true);
|
|
4819
4843
|
if (debug)
|
|
4820
4844
|
console.log(`[renderStream] ${pathname} - performSSRSetup: ${(performance.now() - t0).toFixed(2)}ms`);
|
|
@@ -4877,7 +4901,8 @@ async function renderSSRDocumentStream(options) {
|
|
|
4877
4901
|
preloadHydrationScript: setup2.preloadHydrationScript,
|
|
4878
4902
|
browserTelemetryConfig,
|
|
4879
4903
|
traceContext,
|
|
4880
|
-
parentSpan: options.parentSpan
|
|
4904
|
+
parentSpan: options.parentSpan,
|
|
4905
|
+
timeout: options.timeout
|
|
4881
4906
|
});
|
|
4882
4907
|
if (debug)
|
|
4883
4908
|
console.log(`[renderStream] ${pathname} - returning stream: ${(performance.now() - t0).toFixed(2)}ms`);
|
|
@@ -4886,7 +4911,7 @@ async function renderSSRDocumentStream(options) {
|
|
|
4886
4911
|
async function streamSSRContent(writer, encoder, ctx) {
|
|
4887
4912
|
return withParentSpan(ctx.parentSpan, async () => {
|
|
4888
4913
|
const t0 = ctx.debug ? performance.now() : 0;
|
|
4889
|
-
const STREAM_TIMEOUT_MS =
|
|
4914
|
+
const STREAM_TIMEOUT_MS = ctx.timeout ?? 120000;
|
|
4890
4915
|
let streamTimedOut = false;
|
|
4891
4916
|
let timeoutId = null;
|
|
4892
4917
|
const cleanup = () => {
|
|
@@ -5350,18 +5375,18 @@ function createResponse(body, contentType, options = {}) {
|
|
|
5350
5375
|
vary,
|
|
5351
5376
|
cacheStatus
|
|
5352
5377
|
} = options;
|
|
5353
|
-
const
|
|
5378
|
+
const headers2 = {
|
|
5354
5379
|
"content-type": CONTENT_TYPES[contentType],
|
|
5355
5380
|
"cache-control": buildCacheControl(maxAge, directive),
|
|
5356
5381
|
...extraHeaders
|
|
5357
5382
|
};
|
|
5358
5383
|
if (vary) {
|
|
5359
|
-
|
|
5384
|
+
headers2.Vary = vary;
|
|
5360
5385
|
}
|
|
5361
5386
|
if (cacheStatus) {
|
|
5362
|
-
|
|
5387
|
+
headers2["Reroute-Cache"] = cacheStatus;
|
|
5363
5388
|
}
|
|
5364
|
-
return new Response(body, { status, headers });
|
|
5389
|
+
return new Response(body, { status, headers: headers2 });
|
|
5365
5390
|
}
|
|
5366
5391
|
function xmlResponse(xml, options = {}) {
|
|
5367
5392
|
return createResponse(xml, "xml", options);
|
|
@@ -5468,9 +5493,9 @@ function getAssetCacheControl(filePath, contentType, maxAge, directive, isWatchM
|
|
|
5468
5493
|
// packages/elysia/src/routes/artifacts.ts
|
|
5469
5494
|
function registerArtifactsRoutes(app, cwd, fileCache, options) {
|
|
5470
5495
|
const { bundleMaxAge, directive, isWatchMode = false } = options;
|
|
5471
|
-
app.get("/.reroute/theme.css", async ({ headers }) => {
|
|
5496
|
+
app.get("/.reroute/theme.css", async ({ headers: headers2 }) => {
|
|
5472
5497
|
const filePath = join(cwd, ".reroute", "theme.css");
|
|
5473
|
-
const acceptEncoding =
|
|
5498
|
+
const acceptEncoding = headers2["accept-encoding"] ?? "";
|
|
5474
5499
|
try {
|
|
5475
5500
|
const cacheControl = isWatchMode ? "no-cache, no-store, must-revalidate" : `${directive}, max-age=${bundleMaxAge}`;
|
|
5476
5501
|
if (isWatchMode) {
|
|
@@ -5488,12 +5513,12 @@ function registerArtifactsRoutes(app, cwd, fileCache, options) {
|
|
|
5488
5513
|
});
|
|
5489
5514
|
} catch {}
|
|
5490
5515
|
});
|
|
5491
|
-
app.get("/bundles/*", async ({ params, headers }) => {
|
|
5516
|
+
app.get("/bundles/*", async ({ params, headers: headers2 }) => {
|
|
5492
5517
|
const fileName = String(params["*"] ?? "").replace(/^\/+/, "");
|
|
5493
5518
|
if (!fileName)
|
|
5494
5519
|
throw new NotFoundError2;
|
|
5495
5520
|
const filePath = join(cwd, ".reroute", "bundles", fileName);
|
|
5496
|
-
const acceptEncoding =
|
|
5521
|
+
const acceptEncoding = headers2["accept-encoding"] ?? "";
|
|
5497
5522
|
try {
|
|
5498
5523
|
const cacheControl = getHashedFileCacheControl(fileName, bundleMaxAge, directive, isWatchMode);
|
|
5499
5524
|
return await serveFile(filePath, acceptEncoding, fileCache, {
|
|
@@ -5506,12 +5531,12 @@ function registerArtifactsRoutes(app, cwd, fileCache, options) {
|
|
|
5506
5531
|
throw new NotFoundError2;
|
|
5507
5532
|
}
|
|
5508
5533
|
});
|
|
5509
|
-
app.get("/.reroute/collections/*", async ({ params, headers }) => {
|
|
5534
|
+
app.get("/.reroute/collections/*", async ({ params, headers: headers2 }) => {
|
|
5510
5535
|
const fileName = String(params["*"] ?? "").replace(/^\/+/, "");
|
|
5511
5536
|
if (!fileName)
|
|
5512
5537
|
throw new NotFoundError2;
|
|
5513
5538
|
const filePath = join(cwd, ".reroute", "collections", fileName);
|
|
5514
|
-
const acceptEncoding =
|
|
5539
|
+
const acceptEncoding = headers2["accept-encoding"] ?? "";
|
|
5515
5540
|
try {
|
|
5516
5541
|
const cacheControl = isWatchMode ? "no-cache, no-store, must-revalidate" : "public, max-age=31536000, immutable";
|
|
5517
5542
|
return await serveFile(filePath, acceptEncoding, fileCache, {
|
|
@@ -5684,7 +5709,7 @@ function registerImageRoutes(app, options) {
|
|
|
5684
5709
|
}
|
|
5685
5710
|
});
|
|
5686
5711
|
}
|
|
5687
|
-
async function processImageRequest(query,
|
|
5712
|
+
async function processImageRequest(query, headers2, clientDir2, maxWidth2, maxHeight2, compression3, maxAge2) {
|
|
5688
5713
|
const url = query.url;
|
|
5689
5714
|
if (!url) {
|
|
5690
5715
|
return {
|
|
@@ -5711,7 +5736,7 @@ function registerImageRoutes(app, options) {
|
|
|
5711
5736
|
}
|
|
5712
5737
|
return { response: null, status, error: imagePath };
|
|
5713
5738
|
}
|
|
5714
|
-
const acceptHeader =
|
|
5739
|
+
const acceptHeader = headers2.accept;
|
|
5715
5740
|
const format = formatParam ?? "auto";
|
|
5716
5741
|
const result = await optimizeImage(imagePath, {
|
|
5717
5742
|
width: finalWidth,
|
|
@@ -5720,16 +5745,16 @@ function registerImageRoutes(app, options) {
|
|
|
5720
5745
|
format,
|
|
5721
5746
|
fit: "cover"
|
|
5722
5747
|
}, acceptHeader);
|
|
5723
|
-
const { body, extraHeaders } = compression3 ? gzipIfAccepted(new Uint8Array(result.buffer), result.contentType,
|
|
5748
|
+
const { body, extraHeaders } = compression3 ? gzipIfAccepted(new Uint8Array(result.buffer), result.contentType, headers2["accept-encoding"]) : { body: result.buffer, extraHeaders: {} };
|
|
5724
5749
|
const response = createImageResponse(body, result.contentType, result, maxAge2);
|
|
5725
5750
|
for (const [key, value] of Object.entries(extraHeaders)) {
|
|
5726
5751
|
response.headers.set(key, value);
|
|
5727
5752
|
}
|
|
5728
5753
|
return { response };
|
|
5729
5754
|
}
|
|
5730
|
-
app.get("/__reroute_image", async ({ query, headers, set }) => {
|
|
5755
|
+
app.get("/__reroute_image", async ({ query, headers: headers2, set }) => {
|
|
5731
5756
|
try {
|
|
5732
|
-
const result = await processImageRequest(query,
|
|
5757
|
+
const result = await processImageRequest(query, headers2, clientDir, maxWidth, maxHeight, compression2, maxAge);
|
|
5733
5758
|
if (result.status) {
|
|
5734
5759
|
set.status = result.status;
|
|
5735
5760
|
if (result.error)
|
|
@@ -5769,11 +5794,11 @@ var makeETag = (s) => {
|
|
|
5769
5794
|
return `W/"${s.length.toString(16)}-${djb2Hash(s).toString(36)}"`;
|
|
5770
5795
|
}
|
|
5771
5796
|
};
|
|
5772
|
-
var getIfNoneMatch = (
|
|
5797
|
+
var getIfNoneMatch = (headers2) => {
|
|
5773
5798
|
try {
|
|
5774
|
-
if (!
|
|
5799
|
+
if (!headers2)
|
|
5775
5800
|
return;
|
|
5776
|
-
const h =
|
|
5801
|
+
const h = headers2;
|
|
5777
5802
|
if (typeof h?.get === "function")
|
|
5778
5803
|
return String(h.get("if-none-match") || "");
|
|
5779
5804
|
return String(h["if-none-match"] || h["If-None-Match"] || "");
|
|
@@ -5785,22 +5810,22 @@ function jsonWithCache(payload, cacheControl, reqHeaders, cacheStatus) {
|
|
|
5785
5810
|
const body = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
5786
5811
|
const etag = makeETag(body);
|
|
5787
5812
|
const inm = getIfNoneMatch(reqHeaders) || "";
|
|
5788
|
-
const
|
|
5813
|
+
const headers2 = {
|
|
5789
5814
|
ETag: etag,
|
|
5790
5815
|
"Cache-Control": cacheControl
|
|
5791
5816
|
};
|
|
5792
5817
|
if (cacheStatus) {
|
|
5793
|
-
|
|
5818
|
+
headers2["Reroute-Cache"] = cacheStatus;
|
|
5794
5819
|
}
|
|
5795
5820
|
if (etag && inm && inm === etag) {
|
|
5796
5821
|
return new Response(null, {
|
|
5797
5822
|
status: 304,
|
|
5798
|
-
headers
|
|
5823
|
+
headers: headers2
|
|
5799
5824
|
});
|
|
5800
5825
|
}
|
|
5801
5826
|
return new Response(body, {
|
|
5802
5827
|
headers: {
|
|
5803
|
-
...
|
|
5828
|
+
...headers2,
|
|
5804
5829
|
"Content-Type": "application/json; charset=utf-8"
|
|
5805
5830
|
}
|
|
5806
5831
|
});
|
|
@@ -5866,7 +5891,7 @@ function registerInternalRoutes(app, opts) {
|
|
|
5866
5891
|
}
|
|
5867
5892
|
});
|
|
5868
5893
|
});
|
|
5869
|
-
async function handleKeyRequest(pathname, dataKey,
|
|
5894
|
+
async function handleKeyRequest(pathname, dataKey, headers2) {
|
|
5870
5895
|
const { computeSSRData: computeSSRData2 } = await Promise.resolve().then(() => (init_core(), exports_core));
|
|
5871
5896
|
const cacheKey = `${pathname}:promises`;
|
|
5872
5897
|
let promiseData = maxAge > 0 ? dataCache?.get(cacheKey) : undefined;
|
|
@@ -5885,10 +5910,10 @@ function registerInternalRoutes(app, opts) {
|
|
|
5885
5910
|
const resolved = await value;
|
|
5886
5911
|
const resolvedCacheKey = `${pathname}:${dataKey}:resolved`;
|
|
5887
5912
|
dataCache?.set(resolvedCacheKey, resolved);
|
|
5888
|
-
return jsonWithCache({ data: resolved }, dataCacheControl || "no-cache",
|
|
5913
|
+
return jsonWithCache({ data: resolved }, dataCacheControl || "no-cache", headers2, promiseDataCached ? "HIT" : "MISS");
|
|
5889
5914
|
}
|
|
5890
5915
|
if (value !== undefined) {
|
|
5891
|
-
return jsonWithCache({ data: value }, dataCacheControl || "no-cache",
|
|
5916
|
+
return jsonWithCache({ data: value }, dataCacheControl || "no-cache", headers2, promiseDataCached ? "HIT" : "MISS");
|
|
5892
5917
|
}
|
|
5893
5918
|
}
|
|
5894
5919
|
return jsonError("key not found", 404);
|
|
@@ -5914,16 +5939,16 @@ function registerInternalRoutes(app, opts) {
|
|
|
5914
5939
|
}
|
|
5915
5940
|
return { data, cacheHit };
|
|
5916
5941
|
}
|
|
5917
|
-
app.get("/__reroute_data", async ({ query, headers }) => {
|
|
5942
|
+
app.get("/__reroute_data", async ({ query, headers: headers2 }) => {
|
|
5918
5943
|
const p = String(query.path || query.p || "/");
|
|
5919
5944
|
const dataKey = String(query.key || "");
|
|
5920
5945
|
const pathname = parsePathname(p);
|
|
5921
5946
|
try {
|
|
5922
5947
|
if (dataKey) {
|
|
5923
|
-
return await handleKeyRequest(pathname, dataKey,
|
|
5948
|
+
return await handleKeyRequest(pathname, dataKey, headers2);
|
|
5924
5949
|
}
|
|
5925
5950
|
const { data, cacheHit } = await handleFullDataRequest(pathname);
|
|
5926
|
-
return jsonWithCache({ data }, dataCacheControl || "no-cache",
|
|
5951
|
+
return jsonWithCache({ data }, dataCacheControl || "no-cache", headers2, cacheHit ? "HIT" : "MISS");
|
|
5927
5952
|
} catch {
|
|
5928
5953
|
return jsonError("failed", 500);
|
|
5929
5954
|
}
|
|
@@ -7427,6 +7452,10 @@ function registerSSRRoutes(app, options) {
|
|
|
7427
7452
|
const fullPath = pathname;
|
|
7428
7453
|
const searchParams = url.searchParams;
|
|
7429
7454
|
const acceptEncoding = request.headers.get("accept-encoding") || "";
|
|
7455
|
+
const headers2 = {};
|
|
7456
|
+
request.headers.forEach((value, key) => {
|
|
7457
|
+
headers2[key.toLowerCase()] = value;
|
|
7458
|
+
});
|
|
7430
7459
|
const parentSpan = store.telemetrySpan;
|
|
7431
7460
|
return withParentSpan(parentSpan, async () => {
|
|
7432
7461
|
let isFirstStreamingRequest = false;
|
|
@@ -7516,7 +7545,9 @@ function registerSSRRoutes(app, options) {
|
|
|
7516
7545
|
ogConfig: options.ogConfig,
|
|
7517
7546
|
baseUrl: options.baseUrl,
|
|
7518
7547
|
autoCanonical: options.autoCanonical,
|
|
7519
|
-
parentSpan: renderSpan
|
|
7548
|
+
parentSpan: renderSpan,
|
|
7549
|
+
headers: headers2,
|
|
7550
|
+
timeout: options.streamingTimeout
|
|
7520
7551
|
});
|
|
7521
7552
|
renderSpan?.setAttribute("http.response.status_code", result.status);
|
|
7522
7553
|
if (debug)
|
|
@@ -7644,8 +7675,7 @@ function registerSSRRoutes(app, options) {
|
|
|
7644
7675
|
headers: {
|
|
7645
7676
|
"Content-Type": "text/html; charset=utf-8",
|
|
7646
7677
|
"Cache-Control": cacheControlHeader,
|
|
7647
|
-
"Reroute-Cache": "MISS"
|
|
7648
|
-
"Transfer-Encoding": "chunked"
|
|
7678
|
+
"Reroute-Cache": "MISS"
|
|
7649
7679
|
}
|
|
7650
7680
|
});
|
|
7651
7681
|
if (debug)
|
|
@@ -7662,8 +7692,7 @@ function registerSSRRoutes(app, options) {
|
|
|
7662
7692
|
headers: {
|
|
7663
7693
|
"Content-Type": "text/html; charset=utf-8",
|
|
7664
7694
|
"Cache-Control": cacheControlHeader,
|
|
7665
|
-
"Reroute-Cache": "MISS"
|
|
7666
|
-
"Transfer-Encoding": "chunked"
|
|
7695
|
+
"Reroute-Cache": "MISS"
|
|
7667
7696
|
}
|
|
7668
7697
|
});
|
|
7669
7698
|
if (debug)
|
|
@@ -7694,7 +7723,8 @@ function registerSSRRoutes(app, options) {
|
|
|
7694
7723
|
ogConfig: options.ogConfig,
|
|
7695
7724
|
baseUrl: options.baseUrl,
|
|
7696
7725
|
autoCanonical: options.autoCanonical,
|
|
7697
|
-
parentSpan: renderSpan
|
|
7726
|
+
parentSpan: renderSpan,
|
|
7727
|
+
headers: headers2
|
|
7698
7728
|
});
|
|
7699
7729
|
renderSpan?.setAttribute("http.response.status_code", renderResult.status);
|
|
7700
7730
|
return renderResult;
|
|
@@ -7824,11 +7854,11 @@ function registerStaticRoutes(app, options) {
|
|
|
7824
7854
|
}
|
|
7825
7855
|
currentSpan?.setAttributes(attrs);
|
|
7826
7856
|
}
|
|
7827
|
-
app.get("/assets/*", async function serveStaticFile({ params, headers }) {
|
|
7857
|
+
app.get("/assets/*", async function serveStaticFile({ params, headers: headers2 }) {
|
|
7828
7858
|
const requestPath = params["*"];
|
|
7829
7859
|
const filePath = join(staticAssetsDir, requestPath);
|
|
7830
7860
|
try {
|
|
7831
|
-
const acceptEncoding =
|
|
7861
|
+
const acceptEncoding = headers2["accept-encoding"] ?? "";
|
|
7832
7862
|
const encoding = getEncoding(acceptEncoding);
|
|
7833
7863
|
const cacheKey = `${filePath}:${encoding}`;
|
|
7834
7864
|
const cached = fileCache.get(cacheKey);
|
|
@@ -8156,6 +8186,7 @@ var reroute = () => async (app) => {
|
|
|
8156
8186
|
directive,
|
|
8157
8187
|
compression: compression2,
|
|
8158
8188
|
streamingEnabled,
|
|
8189
|
+
streamingTimeout: globalConfig.streaming?.timeout,
|
|
8159
8190
|
ogConfig,
|
|
8160
8191
|
baseUrl,
|
|
8161
8192
|
autoCanonical
|
|
@@ -8227,4 +8258,4 @@ export {
|
|
|
8227
8258
|
reroute
|
|
8228
8259
|
};
|
|
8229
8260
|
|
|
8230
|
-
//# debugId=
|
|
8261
|
+
//# debugId=2EAF0AA689012AC064756E2164756E21
|