@solidjs/web 2.0.0-rc.4 → 2.0.0-rc.6

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.
Files changed (61) hide show
  1. package/dist/dev.cjs +163 -36
  2. package/dist/dev.js +161 -37
  3. package/dist/server.cjs +178 -37
  4. package/dist/server.js +177 -38
  5. package/dist/web.cjs +143 -36
  6. package/dist/web.js +141 -37
  7. package/frames/dist/client.cjs +41 -8
  8. package/frames/dist/client.dev.cjs +41 -8
  9. package/frames/dist/client.dev.js +41 -8
  10. package/frames/dist/client.js +41 -8
  11. package/frames/dist/server.cjs +497 -44
  12. package/frames/dist/server.js +497 -44
  13. package/package.json +2 -2
  14. package/serialization/dist/decode.cjs +4 -2
  15. package/serialization/dist/decode.js +4 -2
  16. package/serialization/dist/serialization.cjs +12 -8
  17. package/serialization/dist/serialization.js +12 -8
  18. package/serialization/types/index.d.ts +7 -0
  19. package/serialization/types/serializer-decode.d.ts +14 -1
  20. package/serialization/types/serializer.d.ts +7 -0
  21. package/serialization/types-cjs/index.d.cts +7 -0
  22. package/serialization/types-cjs/serializer-decode.d.cts +14 -1
  23. package/serialization/types-cjs/serializer.d.cts +7 -0
  24. package/server-functions/dist/client.cjs +164 -35
  25. package/server-functions/dist/client.js +161 -36
  26. package/server-functions/dist/server.cjs +899 -136
  27. package/server-functions/dist/server.dev.cjs +919 -136
  28. package/server-functions/dist/server.dev.js +915 -137
  29. package/server-functions/dist/server.js +895 -137
  30. package/types/client.d.ts +2 -1
  31. package/types/constants.d.ts +3 -1
  32. package/types/cookies.d.ts +6 -14
  33. package/types/frames/frame-client.d.ts +4 -0
  34. package/types/frames/serializer-decode.d.ts +14 -1
  35. package/types/frames/serializer.d.ts +7 -0
  36. package/types/jsx.d.ts +11 -16
  37. package/types/response.d.ts +11 -0
  38. package/types/serializer-decode.d.ts +14 -1
  39. package/types/serializer.d.ts +7 -0
  40. package/types/server-functions/client.d.ts +22 -2
  41. package/types/server-functions/flash.d.ts +9 -0
  42. package/types/server-functions/server.d.ts +131 -11
  43. package/types/server-functions/shared.d.ts +77 -14
  44. package/types/server-mock.d.ts +17 -2
  45. package/types/server.d.ts +16 -2
  46. package/types-cjs/client.d.cts +2 -1
  47. package/types-cjs/constants.d.cts +3 -1
  48. package/types-cjs/cookies.d.cts +6 -14
  49. package/types-cjs/frames/frame-client.d.cts +4 -0
  50. package/types-cjs/frames/serializer-decode.d.cts +14 -1
  51. package/types-cjs/frames/serializer.d.cts +7 -0
  52. package/types-cjs/jsx.d.cts +11 -16
  53. package/types-cjs/response.d.cts +11 -0
  54. package/types-cjs/serializer-decode.d.cts +14 -1
  55. package/types-cjs/serializer.d.cts +7 -0
  56. package/types-cjs/server-functions/client.d.cts +22 -2
  57. package/types-cjs/server-functions/flash.d.cts +9 -0
  58. package/types-cjs/server-functions/server.d.cts +131 -11
  59. package/types-cjs/server-functions/shared.d.cts +77 -14
  60. package/types-cjs/server-mock.d.cts +17 -2
  61. package/types-cjs/server.d.cts +16 -2
@@ -1,8 +1,9 @@
1
- export { ERROR_HEADER, FLASH_COOKIE, INSTANCE_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, clearFlashCookie, decodeErrorHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, getServerFunctionMetadata, hasFlashCookie, invoke, isServerFunction, subscribeFlightData, withMeta } from "./shared.cjs";
1
+ export { ERROR_HEADER, FLASH_COOKIE, INSTANCE_HEADER, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, clearFlashCookie, decodeErrorHeaderValue, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, getServerFunctionMetadata, hasFlashCookie, invoke, isServerFunction, subscribeFlightData, withMeta } from "./shared.cjs";
2
2
  export { decodeFlashCookie, encodeFlashCookie } from "./flash.cjs";
3
3
  import { ResponseEnvelope } from "../response.cjs";
4
4
  import { JSONCodecOptions } from "../serializer-decode.cjs";
5
5
  import { RequestEvent } from "../server.cjs";
6
+ import type { ServerFunction, ServerFunctionMetadata } from "./shared.cjs";
6
7
  export type { FlightDataConsumer, FlightDataContext, InvokeOptions, ServerFunction, ServerFunctionInvoker, ServerFunctionMetadata, SingleFlightPayload } from "./shared.cjs";
7
8
  export type { FlashSubmission } from "./flash.cjs";
8
9
  /**
@@ -130,6 +131,18 @@ export interface ServerFunctionCSRFOptions {
130
131
  * @default false
131
132
  */
132
133
  allowRequestsWithoutOriginCheck?: boolean;
134
+ /**
135
+ * Applies the origin gate to GET-declared reads as well. By default the
136
+ * gate is skipped for declared reads: same-origin policy already keeps a
137
+ * cross-site caller from READING the response, and the gate's `Vary`
138
+ * fragments (or, on CDNs that ignore Vary, poisons) the shared-cache
139
+ * entries the `GET` helper exists to enable (#3071). The premise that
140
+ * skip rests on is `GET()`'s safety contract — declared reads are safe
141
+ * to EXECUTE from any origin (#3114). A deployment that does not rely
142
+ * on shared caches can enable this to gate its reads too.
143
+ * @default false
144
+ */
145
+ protectDeclaredReads?: boolean;
133
146
  }
134
147
  /** Options for `configureServerFunctionsServer`. */
135
148
  export interface ServerFunctionsServerConfig {
@@ -150,10 +163,13 @@ export interface ServerFunctionsServerConfig {
150
163
  */
151
164
  wrapInvocation?: WrapInvocationHook;
152
165
  /**
153
- * The single-flight hook: produces the data payload folded into
166
+ * The unnamed single-flight hook: produces the data payload folded into
154
167
  * responses of calls that opted in (see `CollectFlightDataHook`).
155
168
  * Registered once by the integration that owns data production (a
156
- * router); per-handler `collectFlightData` options override it.
169
+ * router); per-handler `collectFlightData` options override it. Other
170
+ * integrations contribute additively through
171
+ * `registerFlightDataSource(id, hook)` instead of competing for this
172
+ * slot.
157
173
  */
158
174
  collectFlightData?: CollectFlightDataHook;
159
175
  /**
@@ -225,9 +241,29 @@ export interface ServerFunctionsServerConfig {
225
241
  /**
226
242
  * Codec options (extra plugins etc.) for decoding arguments and encoding
227
243
  * results — must match the client's. Stored in the shared layer, so
228
- * `decodeResponse` sees them too.
244
+ * `decodeResponse` sees them too. When `serializeErrorStacks` is omitted,
245
+ * the server-function boundary defaults it from this module's compiled
246
+ * development variant.
229
247
  */
230
248
  codec?: JSONCodecOptions;
249
+ /**
250
+ * Upper bound, in bytes, on a call's argument payload — the POST body,
251
+ * or the `?args=` query encoding. The payload is buffered and decoded
252
+ * before dispatch, so its cost is paid before application code can
253
+ * decline it; the bound is enforced up front and a request over it is
254
+ * refused with `413` before any decoding (#3115). Raise it for functions
255
+ * that accept large uploads, or set `Infinity` to remove the bound.
256
+ * @default 1_048_576 (1 MiB)
257
+ */
258
+ bodySizeLimit?: number;
259
+ /**
260
+ * Upper bound on the number of arguments a call may carry. The decoded
261
+ * argument array is spread into the function call, so an unbounded list
262
+ * forces a range error out of any function regardless of what it does;
263
+ * past the bound the request is refused with `400` (#3115).
264
+ * @default 1000
265
+ */
266
+ maxArguments?: number;
231
267
  }
232
268
  /**
233
269
  * A registered server function: its build-stable id paired with the
@@ -347,6 +383,16 @@ export interface HandleServerFunctionOptions {
347
383
  csrf?: boolean | ServerFunctionCSRFOptions;
348
384
  /** Overrides the configured codec options for this handler. */
349
385
  codec?: JSONCodecOptions;
386
+ /**
387
+ * Overrides the configured argument payload bound for this handler (see
388
+ * `ServerFunctionsServerConfig.bodySizeLimit`).
389
+ */
390
+ bodySizeLimit?: number;
391
+ /**
392
+ * Overrides the configured argument count bound for this handler (see
393
+ * `ServerFunctionsServerConfig.maxArguments`).
394
+ */
395
+ maxArguments?: number;
350
396
  }
351
397
  export interface ServerFunctionRequestCall {
352
398
  type: "request";
@@ -366,6 +412,7 @@ export interface ServerFunctionResponseCall {
366
412
  }
367
413
  export type ServerFunctionCall = ServerFunctionRequestCall | ServerFunctionResponseCall;
368
414
  export declare function configureServerFunctionsServer(config?: ServerFunctionsServerConfig): void;
415
+ export declare function registerFlightDataSource(source: string, hook: CollectFlightDataHook): () => void;
369
416
  export declare function registerServerFunction<T extends any[], R>(id: string, callback: (...args: T) => R): (...args: T) => R;
370
417
  export declare function getServerFunction<T extends any[], R>(id: string): (...args: T) => R;
371
418
  export declare function registerServerReference<T extends any[], R>(id: string, fn: (...args: T) => R, name?: string): ServerFunctionReference<T, R>;
@@ -376,6 +423,8 @@ export declare function getServerFunctionInvocation(): ServerFunctionInvocation
376
423
  export declare function getEventServerFunctionInvocation(event: RequestEvent | undefined): ServerFunctionInvocation | undefined;
377
424
  export declare function foldSetCookies(headers: Headers, setCookies: readonly string[]): Headers;
378
425
  export declare function createNoJSHandler(options?: NoJSHandlerOptions): (result: unknown, request: Request, args: unknown[], thrown?: boolean) => Response;
426
+ /** @internal */
427
+ export declare function guardFailures(value: any, state: any): any;
379
428
  /**
380
429
  * The response-side codec stream: `serializeStream` (shared.js) hardened
381
430
  * with request-lifetime teardown. Server-only on purpose — the shared half
@@ -384,14 +433,16 @@ export declare function createNoJSHandler(options?: NoJSHandlerOptions): (result
384
433
  * An abort of `signal` (the platform fires request.signal when the caller's
385
434
  * fetch aborts or the tab goes away) or the consumer cancelling the
386
435
  * ReadableStream (how platforms surface a dropped connection to the body)
387
- * stops pending serialization and tears down a top-level async-iterable
388
- * value the producer's `iterator.return()` runs, so generator `finally`
389
- * blocks execute instead of the server pumping a stream nobody is reading.
390
- * Top-level only: that is the value-tier shape ("return a stream from the
391
- * server function"); iterables nested inside user objects are consumed by
392
- * the codec directly and stay untouched.
436
+ * stops pending serialization and tears down EVERY async-iterable or
437
+ * ReadableStream source in the result graph, nested ones included (#3125) —
438
+ * each producer's `iterator.return()` / `reader.cancel()` runs, so
439
+ * generator `finally` blocks execute instead of the server pumping streams
440
+ * nobody is reading. The wiring rides guardFailures' walk: it already wraps
441
+ * every channel before the codec sees the value, so the demand gate and the
442
+ * teardown registry are threaded through its state (`{ items: rows() }` —
443
+ * a cursor beside a total — gets the same two guarantees as `return rows()`).
393
444
  */
394
- export declare function serializeResponseStream(value: any, codecOptions: any, signal: any): ReadableStream<any>;
445
+ export declare function serializeResponseStream(value: any, codecOptions: any, signal: any, scope: any): ReadableStream<any>;
395
446
  /** Message a sanitized (production) server error carries on the wire. */
396
447
  export declare const GENERIC_SERVER_ERROR_MESSAGE = "Internal Server Error";
397
448
  export declare function setServerFunctionsDev(dev: boolean): void;
@@ -399,4 +450,73 @@ export declare function sanitizeServerError(value: unknown): unknown;
399
450
  export declare function observeServerFunctionCalls(observer: (call: ServerFunctionCall) => void): () => void;
400
451
  export declare function serverFunctionUrl(id: string, boundArgs?: readonly unknown[]): string;
401
452
  export declare function parseServerFunctionUrl(url: string): string | null;
453
+ /**
454
+ * Web-standard HTTP handler for server function calls: resolves the
455
+ * function id from the request, enforces the method allowlist (POST always
456
+ * dispatches; GET and HEAD dispatch only to functions that declared `GET`,
457
+ * with HEAD returning the equivalent GET's status and headers minus the
458
+ * body; every other method answers 405), decodes arguments, runs the
459
+ * function under a request-event scope, and encodes the result (forwarding
460
+ * redirect/revalidation metadata through headers). Mount it on the endpoint
461
+ * the client transport targets (default `/_server`); platform adapters (h3,
462
+ * express, ...) convert their request shape to a web `Request` around it.
463
+ *
464
+ * Requests are same-origin by default. The handler accepts browser requests
465
+ * proven by `Sec-Fetch-Site`, `Origin`, or `Referer`, and rejects requests
466
+ * without usable metadata unless explicitly configured otherwise. GET/HEAD
467
+ * requests to `GET`-declared functions skip this gate: they are reads by
468
+ * contract, cross-site response READING is already blocked by same-origin
469
+ * policy, and skipping it keeps the `Vary: Sec-Fetch-Site, Origin, Referer`
470
+ * it would impose off the responses shared caches are meant to store.
471
+ *
472
+ * Every response leaves with `Cache-Control: no-store` unless the function
473
+ * set its own cache policy (via `respond()` headers or a returned
474
+ * `Response`) — caching is opt-in on the wire, not just in prose.
475
+ *
476
+ * When the event carries a `response` head stub (`event.response`, see the
477
+ * server entry's `ResponseStub`), the handler folds it onto every outgoing
478
+ * response as the head freezes — its `Set-Cookie` values (cookies appended
479
+ * during the call) append cookie-by-cookie alongside the result's own,
480
+ * other stub headers fill gaps (the call's response metadata wins; the
481
+ * protocol-owned family — the error/format/single-flight tags, `Location`,
482
+ * `X-Revalidate` — never fills, and neither does `Content-Type`/`Content-
483
+ * Length` onto a bodiless response) — and marks the stub `committed`, so
484
+ * later cookie/header writes report instead of silently missing the wire.
485
+ *
486
+ * ## Thrown-error sanitization (security default)
487
+ *
488
+ * A thrown `Response`/envelope (`redirect`/`reload`/`respond`) is intentional
489
+ * control flow and is forwarded untouched. A *plain* thrown value (a bare
490
+ * `Error`, string, or object) is different: serialized verbatim it would ship
491
+ * its `message` and every own-property to the client — a driver/ORM error's
492
+ * failing query, connection string, or bound parameters included. So outside
493
+ * the dev build a plain thrown value is replaced with a generic `Error`
494
+ * before serialization; the client still receives *an* `Error` (the shape
495
+ * `submission.error` etc. expect), just with no leaked content. The dev
496
+ * build keeps full fidelity (message, stack, own-props) for DX and the dev
497
+ * toolbar inspector. Dev/prod is the BUILD VARIANT, not `NODE_ENV`:
498
+ * `@solidjs/web` publishes a dev copy of this entry behind the
499
+ * `development` export condition (what Vite dev resolves) and the default
500
+ * resolution sanitizes — as does importing the runtime source directly with
501
+ * no bundler signal (fail-safe).
502
+ *
503
+ * Escape hatch: brand the value with `markSafeError` (`Symbol.for(
504
+ * "solid.SafeError")`) to send its content intact in every environment.
505
+ * A `wrapInvocation`/`transformResult` override that maps errors expresses
506
+ * intent the same way — throw a `Response`/envelope, or brand the mapped
507
+ * error safe; an unbranded plain error it lets propagate is sanitized like
508
+ * any other, so a framework onError policy must brand its result to keep a
509
+ * custom client-facing message in production.
510
+ *
511
+ * @example
512
+ * ```ts
513
+ * import { handleServerFunctionRequest } from "@solidjs/web/server-functions";
514
+ * import "virtual:solid-server-function-manifest";
515
+ *
516
+ * // in the server's request handling:
517
+ * if (url.pathname.startsWith("/_server")) {
518
+ * return handleServerFunctionRequest(request);
519
+ * }
520
+ * ```
521
+ */
402
522
  export declare function handleServerFunctionRequest(request: Request, options?: HandleServerFunctionOptions): Promise<Response>;
@@ -8,19 +8,22 @@ import { JSONCodecOptions } from "../serializer-decode.cjs";
8
8
  * HTTP handler. Integrations decoding passthrough responses themselves (no
9
9
  * registered consumer) see this shape from `decodeResponse`. The top level
10
10
  * is reserved for the protocol — integration payload lives entirely under
11
- * `data`, which can be any codec-serializable value.
11
+ * `data`, the envelope keyed by source id (the unnamed registration's
12
+ * slice rides under the reserved id "true"); each slice can be any
13
+ * codec-serializable value.
12
14
  */
13
15
  export interface SingleFlightPayload<T = unknown, D = unknown> {
14
16
  /** The server function's return (or thrown) value. */
15
17
  value: T;
16
- /** The integration-produced data payload. */
18
+ /** The integration-produced data payload, keyed by source id. */
17
19
  data: D;
18
20
  }
19
21
  /**
20
22
  * Envelope context delivered alongside single-flight data: the transport
21
- * response, whose headers carry the integration metadata (`Location` for
22
- * redirect-with-data, `X-Revalidate` keys) and status. The body is already
23
- * consumed — read `data` and `value` from the delivery, not from here.
23
+ * response, whose headers carry the integration metadata (the redirect
24
+ * carrier for redirect-with-data, `X-Revalidate` keys) and status. The
25
+ * body is already consumed — read `data` and `value` from the delivery,
26
+ * not from here.
24
27
  */
25
28
  export interface FlightDataContext {
26
29
  /** The HTTP response the data arrived on (metadata only). */
@@ -131,11 +134,27 @@ export interface ServerFunctionRPC {
131
134
  export type BodyFormatValue = (typeof BodyFormat)[keyof typeof BodyFormat];
132
135
  export declare function configureServerFunctionsCodec(codec: JSONCodecOptions | undefined): void;
133
136
  export declare function getServerFunctionsCodec(): JSONCodecOptions | undefined;
137
+ /**
138
+ * Validates a flight data source id (both registration halves share the
139
+ * rule): ids travel the `SINGLE_FLIGHT_HEADER` as a comma-separated list,
140
+ * so they cannot be empty or contain commas, and "true" is reserved for
141
+ * the unnamed registration.
142
+ *
143
+ * Transport building block; not meant for hand-written code.
144
+ * @internal
145
+ */
146
+ export declare function assertFlightSource(source: string): void;
134
147
  export declare function subscribeFlightData<D = unknown>(consumer: FlightDataConsumer<D>): () => void;
135
- export declare function getFlightDataConsumer(): FlightDataConsumer | undefined;
148
+ export declare function subscribeFlightData<D = unknown>(source: string, consumer: FlightDataConsumer<D>): () => void;
149
+ export declare function getFlightDataConsumer(source?: string): FlightDataConsumer | undefined;
150
+ export declare function getFlightDataSourceIds(): string[];
136
151
  export declare function frameAddress(id: string, args?: readonly unknown[]): string;
137
152
  export declare function serverFunctionAddress(endpoint: string, id: string): string;
138
- export declare function parseServerFunctionAddress(pathname: string, endpoint: string): string | null;
153
+ export declare function serverFunctionDataAddress(endpoint: string, id: string): string;
154
+ export declare function parseServerFunctionAddress(pathname: string, endpoint: string): {
155
+ id: string;
156
+ data: boolean;
157
+ } | null;
139
158
  /**
140
159
  * Response header marking a thrown server-function error. The value is the
141
160
  * error's message (the structured error itself travels in the body); `"true"`
@@ -151,6 +170,51 @@ export declare function decodeErrorHeaderValue(value: string): string;
151
170
  export declare const INSTANCE_HEADER = "X-Server-Function-Instance";
152
171
  /** Header carrying the body format tag (a `BodyFormat` value). */
153
172
  export declare const BODY_FORMAT_HEADER = "X-Server-Function-Format";
173
+ /**
174
+ * Header labelling the unknown-id 404: the address was well-formed but its
175
+ * id is not registered in the deployment that answered (#3110). This is the
176
+ * ordinary shape of version skew — a tab holding the previous build's ids
177
+ * across a deploy — and the label is what lets an integration recover
178
+ * (e.g. reload the document) instead of surfacing a generic failed call.
179
+ * Nothing distinguishes it otherwise: a CDN 404 and a skew 404 look alike.
180
+ */
181
+ export declare const UNKNOWN_HEADER = "X-Server-Function-Unknown";
182
+ /**
183
+ * Header carrying a redirect to scripted callers. fetch FOLLOWS redirect
184
+ * statuses before the transport can read them, so a scripted answer masks
185
+ * the 3xx to 200 and this header carries what the mask erases: the author's
186
+ * status and the target RESOLVED against the request url — exactly the
187
+ * meaning HTTP assigns the `Location` a form post would have received.
188
+ * Value: `<status> <absolute-url>`, decode with `decodeRedirectHeaderValue`.
189
+ *
190
+ * Carrying the resolved absolute form is the point (#3102, #3107): the
191
+ * reader never guesses navigation strategy from how the author spelled the
192
+ * target — `redirect("/")` and `redirect(new URL("/", url).href)` arrive
193
+ * identical by construction, and same-origin vs cross-origin is a real URL
194
+ * comparison, not a `startsWith("http")` coin toss. `Location` itself never
195
+ * rides a masked answer: on a 200 it has no HTTP meaning, and it collided
196
+ * with authored Locations on statuses that forward (a 201's created-at is
197
+ * data, not navigation).
198
+ */
199
+ export declare const REDIRECT_HEADER = "X-Server-Function-Redirect";
200
+ /**
201
+ * Decodes a `REDIRECT_HEADER` value into the author's status and the
202
+ * resolved absolute target. Integration plumbing for readers of the header
203
+ * (routers); the wire format is the runtime's own, not a contract to parse
204
+ * by hand.
205
+ *
206
+ * The documented output — a resolved ABSOLUTE http(s) target and a redirect
207
+ * status — is enforced, not assumed (#3175): the absoluteness used to be a
208
+ * property of the server having resolved it, and a hostile or buggy peer
209
+ * could ride a `javascript:` target straight into the `location.href =
210
+ * decoded.url` an integration reasonably writes. A value that does not
211
+ * parse as an absolute http(s) url, or whose status is not one the runtime
212
+ * masks, decodes to `undefined` — the same answer a missing header gives.
213
+ */
214
+ export declare function decodeRedirectHeaderValue(value: string | null | undefined): {
215
+ status: number;
216
+ url: string;
217
+ } | undefined;
154
218
  /**
155
219
  * Header driving the single-flight protocol on both legs: on the request it
156
220
  * opts the call into flight-data collection (the integration sends it on
@@ -200,15 +264,14 @@ export declare class ChunkReader {
200
264
  value: string;
201
265
  }>;
202
266
  drain(interpret: any): Promise<void>;
203
- } /**
204
- * Serializes a value as a stream of length-prefixed SerovalNode chunks.
205
- * Async values (promises, streams) keep the stream open until they settle,
206
- * so one connection carries incremental results. Codec options must match
207
- * the deserializing peer.
208
- *
209
- * Transport building block; not meant for hand-written code.
267
+ }
268
+ /**
269
+ * Encodes a terminal error-trailer frame payload. The value is expected to
270
+ * be already sanitized by the caller; only `name` and `message` travel.
271
+ * Transport wire detail; not meant for hand-written code.
210
272
  * @internal
211
273
  */
274
+ export declare function encodeErrorTrailer(error: unknown): string;
212
275
  export declare function serializeStream(value: unknown, codecOptions?: JSONCodecOptions): ReadableStream<Uint8Array>;
213
276
  export declare function serializeString(value: unknown, codecOptions?: JSONCodecOptions): Promise<string>;
214
277
  export declare function deserializeStream<T = unknown>(source: Request | Response, codecOptions?: JSONCodecOptions): Promise<T>;
@@ -1,10 +1,23 @@
1
1
  import type { RequestEvent, RequestEventLocals, ResponseStub } from "./client.cjs";
2
+ import type { JSX } from "./jsx.cjs";
3
+ /** An explicit `<link rel="preload">` emitted by the SSR asset pipeline. */
4
+ export type PreloadLink = {
5
+ href: string;
6
+ as: JSX.HTMLPreloadAs;
7
+ type?: string;
8
+ crossorigin?: JSX.HTMLCrossorigin;
9
+ integrity?: string;
10
+ referrerpolicy?: JSX.HTMLReferrerPolicy;
11
+ fetchpriority?: JSX.HTMLFetchPriority;
12
+ media?: string;
13
+ };
2
14
  /** Static asset manifest produced by a build (e.g. parsed Vite manifest.json). */
3
15
  export type AssetManifest = Record<string, {
4
16
  file: string;
5
17
  css?: string[];
6
18
  isEntry?: boolean;
7
19
  imports?: string[];
20
+ preloads?: PreloadLink[];
8
21
  }> & {
9
22
  _base?: string;
10
23
  };
@@ -17,6 +30,7 @@ export type InlineStyleAsset = {
17
30
  export type ResolvedAssets = {
18
31
  js: string[];
19
32
  css: (string | InlineStyleAsset)[];
33
+ preloads?: PreloadLink[];
20
34
  };
21
35
  /**
22
36
  * Resolver form of the manifest option — the primitive a dev server
@@ -24,8 +38,9 @@ export type ResolvedAssets = {
24
38
  * normalized into a sync resolver internally). `resolve` may return a
25
39
  * promise (async resolvers require streaming rendering); CSS entries may be
26
40
  * URL strings (emitted as load-gated `<link>` tags) or inline-style
27
- * descriptors (emitted as `<style>` tags). A bare `resolve`-shaped function
28
- * is accepted as shorthand for `{ resolve }`.
41
+ * descriptors (emitted as `<style>` tags), and `preloads` carries explicit
42
+ * preload links selected by the integration. A bare `resolve`-shaped
43
+ * function is accepted as shorthand for `{ resolve }`.
29
44
  */
30
45
  export type AssetResolver = {
31
46
  resolve(key: string): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
@@ -5,12 +5,24 @@ export { clearFlashCookie, hasFlashCookie } from "./cookies.cjs";
5
5
  export { getServerFunctionMetadata, getServerFunctionRPC, isServerFunction } from "./server-functions/registry.cjs";
6
6
  import { JSX } from "./jsx.cjs";
7
7
  import { SerializerPlugin } from "./serializer-decode.cjs";
8
+ /** An explicit `<link rel="preload">` emitted by the SSR asset pipeline. */
9
+ export type PreloadLink = {
10
+ href: string;
11
+ as: JSX.HTMLPreloadAs;
12
+ type?: string;
13
+ crossorigin?: JSX.HTMLCrossorigin;
14
+ integrity?: string;
15
+ referrerpolicy?: JSX.HTMLReferrerPolicy;
16
+ fetchpriority?: JSX.HTMLFetchPriority;
17
+ media?: string;
18
+ };
8
19
  /** Static asset manifest produced by a build (e.g. parsed Vite manifest.json). */
9
20
  export type AssetManifest = Record<string, {
10
21
  file: string;
11
22
  css?: string[];
12
23
  isEntry?: boolean;
13
24
  imports?: string[];
25
+ preloads?: PreloadLink[];
14
26
  }> & {
15
27
  _base?: string;
16
28
  };
@@ -23,6 +35,7 @@ export type InlineStyleAsset = {
23
35
  export type ResolvedAssets = {
24
36
  js: string[];
25
37
  css: (string | InlineStyleAsset)[];
38
+ preloads?: PreloadLink[];
26
39
  };
27
40
  /**
28
41
  * Resolver form of the manifest option — the primitive a dev server
@@ -30,8 +43,9 @@ export type ResolvedAssets = {
30
43
  * normalized into a sync resolver internally). `resolve` may return a
31
44
  * promise (async resolvers require streaming rendering); CSS entries may be
32
45
  * URL strings (emitted as load-gated `<link>` tags) or inline-style
33
- * descriptors (emitted as `<style>` tags). A bare `resolve`-shaped function
34
- * is accepted as shorthand for `{ resolve }`.
46
+ * descriptors (emitted as `<style>` tags), and `preloads` carries explicit
47
+ * preload links selected by the integration. A bare `resolve`-shaped
48
+ * function is accepted as shorthand for `{ resolve }`.
35
49
  */
36
50
  export type AssetResolver = {
37
51
  resolve(key: string): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;