@solidjs/web 2.0.0-rc.7 → 2.0.0-rc.8
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/dist/server.dev.js +15 -2
- package/dist/server.js +15 -2
- package/dist/web.dev.js +41 -9
- package/dist/web.js +39 -8
- package/dist/{web.cjs → web.observe.js} +137 -239
- package/frames/dist/server.dev.js +19 -0
- package/frames/dist/server.js +19 -0
- package/frames/package.json +6 -24
- package/package.json +81 -314
- package/serialization/decode/package.json +3 -9
- package/serialization/package.json +3 -9
- package/serialization/types/serializer-decode.d.ts +49 -2
- package/server-functions/dist/server.dev.js +28 -10
- package/server-functions/dist/server.js +28 -10
- package/server-functions/package.json +6 -24
- package/server-functions/rich-args/package.json +3 -9
- package/storage/package.json +3 -9
- package/types/client.d.ts +17 -0
- package/types/frames/serializer-decode.d.ts +49 -2
- package/types/serializer-decode.d.ts +49 -2
- package/types/server-functions/server.d.ts +27 -4
- package/types/server.d.ts +1 -1
- package/dist/server.cjs +0 -3708
- package/dist/server.dev.cjs +0 -3794
- package/dist/web.dev.cjs +0 -2285
- package/frames/dist/client.cjs +0 -2043
- package/frames/dist/client.dev.cjs +0 -2063
- package/frames/dist/server.cjs +0 -4542
- package/frames/dist/server.dev.cjs +0 -4584
- package/serialization/dist/decode.cjs +0 -155
- package/serialization/dist/serialization.cjs +0 -275
- package/serialization/types-cjs/index.d.cts +0 -101
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -172
- package/serialization/types-cjs/serializer.d.cts +0 -101
- package/server-functions/dist/client.cjs +0 -1069
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -2381
- package/server-functions/dist/server.dev.cjs +0 -2409
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types-cjs/client.d.cts +0 -197
- package/types-cjs/constants.d.cts +0 -20
- package/types-cjs/cookies.d.cts +0 -41
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -370
- package/types-cjs/frames/frame-container-plugin.d.cts +0 -71
- package/types-cjs/frames/frame-sink.d.cts +0 -92
- package/types-cjs/frames/frame-transport.d.cts +0 -189
- package/types-cjs/frames/serializer-decode.d.cts +0 -172
- package/types-cjs/frames/serializer.d.cts +0 -101
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/head.d.cts +0 -19
- package/types-cjs/index.d.cts +0 -191
- package/types-cjs/index.server.d.cts +0 -147
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4146
- package/types-cjs/package.json +0 -3
- package/types-cjs/reconcile.d.cts +0 -1
- package/types-cjs/render.d.cts +0 -6
- package/types-cjs/response.d.cts +0 -81
- package/types-cjs/serializer-decode.d.cts +0 -172
- package/types-cjs/serializer.d.cts +0 -101
- package/types-cjs/server-functions/client.d.cts +0 -184
- package/types-cjs/server-functions/flash.d.cts +0 -36
- package/types-cjs/server-functions/registry.d.cts +0 -100
- package/types-cjs/server-functions/rich-args.d.cts +0 -1
- package/types-cjs/server-functions/server.d.cts +0 -546
- package/types-cjs/server-functions/shared.d.cts +0 -283
- package/types-cjs/server-mock.d.cts +0 -337
- package/types-cjs/server.d.cts +0 -408
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
export { LIVE_SOURCE, SERVER_FUNCTION_INVOKE, SERVER_FUNCTION_METADATA, getServerFunctionMetadata, getServerFunctionRPC, invoke, isServerFunction, provideServerFunctionRPC, withMeta } from "./registry.cjs";
|
|
2
|
-
export { FLASH_COOKIE, clearFlashCookie, hasFlashCookie, matchFlashCookie } from "../cookies.cjs";
|
|
3
|
-
import { JSONCodecOptions } from "../serializer-decode.cjs";
|
|
4
|
-
/**
|
|
5
|
-
* The standardized body of a single-flight response (a response tagged with
|
|
6
|
-
* `SINGLE_FLIGHT_HEADER`): the function's return `value` plus the
|
|
7
|
-
* integration-produced `data` payload, folded into one round trip by the
|
|
8
|
-
* HTTP handler. Integrations decoding passthrough responses themselves (no
|
|
9
|
-
* registered consumer) see this shape from `decodeResponse`. The top level
|
|
10
|
-
* is reserved for the protocol — integration payload lives entirely under
|
|
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.
|
|
14
|
-
*/
|
|
15
|
-
export interface SingleFlightPayload<T = unknown, D = unknown> {
|
|
16
|
-
/** The server function's return (or thrown) value. */
|
|
17
|
-
value: T;
|
|
18
|
-
/** The integration-produced data payload, keyed by source id. */
|
|
19
|
-
data: D;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Envelope context delivered alongside single-flight data: the transport
|
|
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.
|
|
27
|
-
*/
|
|
28
|
-
export interface FlightDataContext {
|
|
29
|
-
/** The HTTP response the data arrived on (metadata only). */
|
|
30
|
-
response: Response;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Consumer receiving single-flight data on the client: `data` is the
|
|
34
|
-
* integration-produced payload (opaque to the protocol), `context` carries
|
|
35
|
-
* the envelope metadata. Async consumers are awaited before the function
|
|
36
|
-
* value is returned to the caller, so caches are seeded first.
|
|
37
|
-
*/
|
|
38
|
-
export type FlightDataConsumer<D = unknown> = (data: D, context: FlightDataContext) => void | Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* The public contract of a server function reference — what a `"use
|
|
41
|
-
* server"` import is at runtime on either side: an async callable plus its
|
|
42
|
-
* build-stable identity.
|
|
43
|
-
*/
|
|
44
|
-
export interface ServerFunction<A extends readonly any[] = any[], T = any> {
|
|
45
|
-
(...args: A): Promise<T>;
|
|
46
|
-
/** The build-stable function id (stable across the client and server builds). */
|
|
47
|
-
readonly id: string;
|
|
48
|
-
/** URL invoking this function directly over HTTP (form `action`s, raw fetches). */
|
|
49
|
-
readonly url: string;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Per-call, invocation-scoped options for `invoke` — things that vary
|
|
53
|
-
* between calls of the SAME function and cannot be declared (`GET`,
|
|
54
|
-
* `withMeta`) or configured (`prepareRequest`). On the server the call is
|
|
55
|
-
* in-process: `signal` still rejects the caller, the transport hints are
|
|
56
|
-
* no-ops (they describe a wire that does not exist).
|
|
57
|
-
*/
|
|
58
|
-
export interface InvokeOptions {
|
|
59
|
-
/**
|
|
60
|
-
* The call's lifecycle. Aborting rejects the call with the signal's
|
|
61
|
-
* reason and cancels the request (firing `request.signal` server-side);
|
|
62
|
-
* a live source's iteration ends across reconnects. When provided, the
|
|
63
|
-
* signal owns the wire — timeouts compose through it
|
|
64
|
-
* (`AbortSignal.timeout`, `AbortSignal.any`).
|
|
65
|
-
*/
|
|
66
|
-
signal?: AbortSignal;
|
|
67
|
-
/**
|
|
68
|
-
* Lets the request outlive the page — fire-and-forget calls during
|
|
69
|
-
* unload (`pagehide`). Maps to fetch's `keepalive`, body-size caps
|
|
70
|
-
* included.
|
|
71
|
-
*/
|
|
72
|
-
keepalive?: boolean;
|
|
73
|
-
/** Fetch priority hint — speculative prefetch vs. interaction fetch. */
|
|
74
|
-
priority?: "high" | "low" | "auto";
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* A reference's invocation channel, carried under `SERVER_FUNCTION_INVOKE`:
|
|
78
|
-
* applies one call with per-call options. Declaration wrappers (`GET`,
|
|
79
|
-
* `live`) forward it mechanically — they keep the call mapping 1:1. A
|
|
80
|
-
* wrapper that shares calls (a deduping cache, a multicast channel) opts
|
|
81
|
-
* in deliberately, deciding first what a caller's abort means for shared
|
|
82
|
-
* work — or declines, leaving `invoke` to answer with a directed error.
|
|
83
|
-
* Options arrive already validated — `invoke` admits only
|
|
84
|
-
* invocation-scoped keys.
|
|
85
|
-
*/
|
|
86
|
-
export type ServerFunctionInvoker<A extends readonly any[] = any[], R = any> = (args: A, options?: InvokeOptions) => R;
|
|
87
|
-
/**
|
|
88
|
-
* Declaration-static metadata attached to a server function reference
|
|
89
|
-
* through declaration wrappers (`GET`, `withMeta`). Read it with
|
|
90
|
-
* `getServerFunctionMetadata`; routers and integrations detect capability
|
|
91
|
-
* from here instead of property sniffing, and `prepareRequest` receives it
|
|
92
|
-
* as `context.meta`. Write through `withMeta` — later writes shallow-merge
|
|
93
|
-
* over earlier ones.
|
|
94
|
-
*/
|
|
95
|
-
export interface ServerFunctionMetadata {
|
|
96
|
-
/** The declared HTTP method. Undeclared references call over POST. */
|
|
97
|
-
readonly method?: "GET" | "POST";
|
|
98
|
-
/**
|
|
99
|
-
* A human-readable label for the function, seeded by development builds
|
|
100
|
-
* from the compiled function's source name (dev tooling — inspectors,
|
|
101
|
-
* logs). Dev-only: production builds emit no name. Not unique and not an
|
|
102
|
-
* identity key — use `id` for identity. Seeded as a default: an explicit
|
|
103
|
-
* `withMeta` write wins.
|
|
104
|
-
*/
|
|
105
|
-
readonly name?: string;
|
|
106
|
-
/** User-declared transport metadata attached with `withMeta`. */
|
|
107
|
-
readonly [key: string]: unknown;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* The transport surface integrations consume through the late-bound RPC
|
|
111
|
-
* seam (server-functions/registry.js) — filled by the transport halves when
|
|
112
|
-
* the first server function reference is created (code that only exists in
|
|
113
|
-
* a bundle when a `"use server"` function was actually compiled in), read
|
|
114
|
-
* by routers so they never import the transport/codec statically.
|
|
115
|
-
*/
|
|
116
|
-
export interface ServerFunctionRPC {
|
|
117
|
-
/**
|
|
118
|
-
* The build's `GET` declaration wrapper (client fetch transport or
|
|
119
|
-
* server in-process dispatch — see the respective entries).
|
|
120
|
-
*/
|
|
121
|
-
GET<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, Awaited<R>>;
|
|
122
|
-
/**
|
|
123
|
-
* `decodeResponse` bound to the configured codec: decodes a server
|
|
124
|
-
* function response body the transport handed over whole (redirects,
|
|
125
|
-
* revalidation). Resolves undefined for empty bodies and bodies without
|
|
126
|
-
* a recognized encoding (e.g. a raw user Response).
|
|
127
|
-
*/
|
|
128
|
-
decodeResponse<T = unknown>(response: Response): Promise<T | undefined>;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Transport wire detail; not meant for hand-written code.
|
|
132
|
-
* @internal
|
|
133
|
-
*/
|
|
134
|
-
export type BodyFormatValue = (typeof BodyFormat)[keyof typeof BodyFormat];
|
|
135
|
-
export declare function configureServerFunctionsCodec(codec: JSONCodecOptions | undefined): void;
|
|
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;
|
|
147
|
-
export declare function subscribeFlightData<D = unknown>(consumer: FlightDataConsumer<D>): () => void;
|
|
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[];
|
|
151
|
-
export declare function frameAddress(id: string, args?: readonly unknown[]): string;
|
|
152
|
-
export declare function serverFunctionAddress(endpoint: string, id: string): string;
|
|
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;
|
|
158
|
-
/**
|
|
159
|
-
* Response header marking a thrown server-function error. The value is the
|
|
160
|
-
* error's message (the structured error itself travels in the body); `"true"`
|
|
161
|
-
* for thrown control-flow responses and non-Error values.
|
|
162
|
-
*/
|
|
163
|
-
export declare const ERROR_HEADER = "X-Server-Function-Error";
|
|
164
|
-
export declare function encodeErrorHeaderValue(value: string): string;
|
|
165
|
-
export declare function decodeErrorHeaderValue(value: string): string;
|
|
166
|
-
/**
|
|
167
|
-
* Header carrying a per-call instance id. Its presence tells the server a
|
|
168
|
-
* scripted client is on the other end (vs. a no-JS form post).
|
|
169
|
-
*/
|
|
170
|
-
export declare const INSTANCE_HEADER = "X-Server-Function-Instance";
|
|
171
|
-
/** Header carrying the body format tag (a `BodyFormat` value). */
|
|
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;
|
|
218
|
-
/**
|
|
219
|
-
* Header driving the single-flight protocol on both legs: on the request it
|
|
220
|
-
* opts the call into flight-data collection (the integration sends it on
|
|
221
|
-
* calls whose response should fold in data), on the response it marks a
|
|
222
|
-
* body carrying the standardized `{ value, data }` payload. How the data
|
|
223
|
-
* is produced (and what it means) is entirely the integration's business —
|
|
224
|
-
* core only owns the wire shape and the delivery.
|
|
225
|
-
*/
|
|
226
|
-
export declare const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
227
|
-
/** FormData key used when a lone File is sent as the argument. */
|
|
228
|
-
export declare const FILE_FORM_KEY = "__server_function_file__";
|
|
229
|
-
export declare const BodyFormat: {
|
|
230
|
-
Serialized: string;
|
|
231
|
-
String: string;
|
|
232
|
-
FormData: string;
|
|
233
|
-
URLSearchParams: string;
|
|
234
|
-
Blob: string;
|
|
235
|
-
File: string;
|
|
236
|
-
ArrayBuffer: string;
|
|
237
|
-
Uint8Array: string;
|
|
238
|
-
/**
|
|
239
|
-
* Plain `JSON.stringify` — the fast path for JSON-safe payloads on both
|
|
240
|
-
* legs: argument lists on the request, results (single-flight envelopes
|
|
241
|
-
* included) on the response.
|
|
242
|
-
*/
|
|
243
|
-
Json: string;
|
|
244
|
-
/**
|
|
245
|
-
* No body at all — a function that returned nothing. It marks the response
|
|
246
|
-
* as one the runtime encoded, which separates a void result with a status
|
|
247
|
-
* on it from a refusal answered by something else. Decoding falls through
|
|
248
|
-
* to `undefined`, which is what a peer predating the tag reads too.
|
|
249
|
-
*/
|
|
250
|
-
Void: string;
|
|
251
|
-
};
|
|
252
|
-
export declare function isJSONSafe(value: unknown): boolean;
|
|
253
|
-
export declare function getHeadersAndBody(body: unknown): {
|
|
254
|
-
headers?: Record<string, string>;
|
|
255
|
-
body: BodyInit;
|
|
256
|
-
} | undefined;
|
|
257
|
-
export declare function extractBody(source: Request | Response, codecOptions?: JSONCodecOptions): Promise<unknown>;
|
|
258
|
-
export declare function createChunk(data: string): Uint8Array;
|
|
259
|
-
export declare class ChunkReader {
|
|
260
|
-
constructor(stream: any);
|
|
261
|
-
readChunk(): Promise<void>;
|
|
262
|
-
next(): Promise<{
|
|
263
|
-
done: boolean;
|
|
264
|
-
value: string;
|
|
265
|
-
}>;
|
|
266
|
-
drain(interpret: any): Promise<void>;
|
|
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.
|
|
272
|
-
* @internal
|
|
273
|
-
*/
|
|
274
|
-
export declare function encodeErrorTrailer(error: unknown): string;
|
|
275
|
-
export declare function serializeStream(value: unknown, codecOptions?: JSONCodecOptions): ReadableStream<Uint8Array>;
|
|
276
|
-
export declare function serializeString(value: unknown, codecOptions?: JSONCodecOptions): Promise<string>;
|
|
277
|
-
export declare function deserializeStream<T = unknown>(source: Request | Response, codecOptions?: JSONCodecOptions): Promise<T>;
|
|
278
|
-
export declare function deserializeString<T = unknown>(text: string, codecOptions?: JSONCodecOptions): Promise<T>;
|
|
279
|
-
export declare function decodeResponse<T = unknown>(response: Response, codecOptions?: JSONCodecOptions): Promise<T | undefined>;
|
|
280
|
-
export declare function decodeResponsePayload<T = unknown, D = unknown>(response: Response, codecOptions?: JSONCodecOptions): Promise<{
|
|
281
|
-
value: T | undefined;
|
|
282
|
-
flightData?: D;
|
|
283
|
-
}>;
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import type { RequestEvent, RequestEventLocals, ResponseStub } from "./client.cjs";
|
|
2
|
-
import type { JSX } from "./jsx.cjs";
|
|
3
|
-
type PreloadLinkAttributes = {
|
|
4
|
-
type?: string;
|
|
5
|
-
crossorigin?: JSX.HTMLCrossorigin;
|
|
6
|
-
integrity?: string;
|
|
7
|
-
referrerpolicy?: JSX.HTMLReferrerPolicy;
|
|
8
|
-
fetchpriority?: JSX.HTMLFetchPriority;
|
|
9
|
-
media?: string;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* An explicit `<link rel="preload">` emitted by the SSR asset pipeline.
|
|
13
|
-
*
|
|
14
|
-
* `as` is the HTML Standard's set of preload destinations exactly — anything
|
|
15
|
-
* else translates to null and the browser does nothing with the link.
|
|
16
|
-
*
|
|
17
|
-
* `imagesrcset` candidates must already be resolved by the integration: they
|
|
18
|
-
* are carried verbatim (a relative candidate resolves against the DOCUMENT
|
|
19
|
-
* URL, not the manifest base). Pair it with `imagesizes` whenever a candidate
|
|
20
|
-
* uses a width descriptor, which the spec requires — without it the source
|
|
21
|
-
* size falls back to `100vw` and the preload can miss the image the `<img>`
|
|
22
|
-
* selects. Omitting `href` is the spec's own recommendation for the source-set
|
|
23
|
-
* form: it would only serve browsers without `imagesrcset` support, and there
|
|
24
|
-
* it would likely preload the wrong candidate.
|
|
25
|
-
*/
|
|
26
|
-
export type PreloadLink = PreloadLinkAttributes & ({
|
|
27
|
-
href: string;
|
|
28
|
-
as: Exclude<JSX.HTMLPreloadAs, "image">;
|
|
29
|
-
imagesrcset?: never;
|
|
30
|
-
imagesizes?: never;
|
|
31
|
-
} | {
|
|
32
|
-
href: string;
|
|
33
|
-
as: "image";
|
|
34
|
-
imagesrcset?: string;
|
|
35
|
-
imagesizes?: string;
|
|
36
|
-
} | {
|
|
37
|
-
href?: never;
|
|
38
|
-
as: "image";
|
|
39
|
-
imagesrcset: string;
|
|
40
|
-
imagesizes?: string;
|
|
41
|
-
});
|
|
42
|
-
/**
|
|
43
|
-
* Static asset graph consumed by the SSR pipeline. This is Solid's own
|
|
44
|
-
* contract — a parsed Vite client manifest satisfies it structurally
|
|
45
|
-
* (unknown fields pass through untyped), but any bundler integration can
|
|
46
|
-
* produce it. Only these fields are ever read: `preloads` is Solid's
|
|
47
|
-
* extension slot for explicit typed links the integration selects.
|
|
48
|
-
*/
|
|
49
|
-
export type AssetManifest = Record<string, {
|
|
50
|
-
file: string;
|
|
51
|
-
css?: string[];
|
|
52
|
-
isEntry?: boolean;
|
|
53
|
-
imports?: string[];
|
|
54
|
-
preloads?: PreloadLink[];
|
|
55
|
-
}> & {
|
|
56
|
-
_base?: string;
|
|
57
|
-
};
|
|
58
|
-
/** Inline style content, e.g. dev CSS collected from a bundler's module graph. */
|
|
59
|
-
export type InlineStyleAsset = {
|
|
60
|
-
id: string;
|
|
61
|
-
content: string;
|
|
62
|
-
attrs?: Record<string, string>;
|
|
63
|
-
};
|
|
64
|
-
export type ResolvedAssets = {
|
|
65
|
-
js: string[];
|
|
66
|
-
css: (string | InlineStyleAsset)[];
|
|
67
|
-
preloads?: PreloadLink[];
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Resolver form of the manifest option — the primitive a dev server
|
|
71
|
-
* implements against its live module graph (a static manifest object is
|
|
72
|
-
* normalized into a sync resolver internally). `resolve` may return a
|
|
73
|
-
* promise (async resolvers require streaming rendering); CSS entries may be
|
|
74
|
-
* URL strings (emitted as load-gated `<link>` tags) or inline-style
|
|
75
|
-
* descriptors (emitted as `<style>` tags), and `preloads` carries explicit
|
|
76
|
-
* preload links selected by the integration. A bare `resolve`-shaped
|
|
77
|
-
* function is accepted as shorthand for `{ resolve }`.
|
|
78
|
-
*/
|
|
79
|
-
export type AssetResolver = {
|
|
80
|
-
resolve(key: string): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
81
|
-
/**
|
|
82
|
-
* Synchronous fast path answering with whatever is knowable without async
|
|
83
|
-
* work (typically js URLs, omitting css). Sync consumers — e.g. a lazy
|
|
84
|
-
* component's `moduleUrl` getter used by islands — use this when `resolve`
|
|
85
|
-
* would return a promise, so adapters should provide it whenever possible.
|
|
86
|
-
*/
|
|
87
|
-
resolveSync?(key: string): ResolvedAssets | null | undefined;
|
|
88
|
-
};
|
|
89
|
-
/** Bare-function shorthand for `AssetResolver` (no sync fast path). */
|
|
90
|
-
export type AssetResolverFn = (key: string) => ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
91
|
-
/**
|
|
92
|
-
* CSP nonce for the tags a server render emits. A string applies to both
|
|
93
|
-
* nonce-aware destinations; a `{ script, style }` pair routes each tag to
|
|
94
|
-
* its destination's nonce, with `false` leaving that destination un-nonced.
|
|
95
|
-
*/
|
|
96
|
-
export type CSPNonce = string | {
|
|
97
|
-
script: string | false;
|
|
98
|
-
style: string | false;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Renders a component tree synchronously to an HTML string. Async reads inside
|
|
102
|
-
* `<Loading>` boundaries emit their `fallback` content; for full-graph
|
|
103
|
-
* resolution await `renderToStream` instead.
|
|
104
|
-
*
|
|
105
|
-
* Pair the returned HTML with `hydrate()` on the client.
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* ```tsx
|
|
109
|
-
* import { renderToString } from "@solidjs/web";
|
|
110
|
-
*
|
|
111
|
-
* const html = renderToString(() => <App />);
|
|
112
|
-
* res.send(`<!doctype html><html><body><div id="root">${html}</div></body></html>`);
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
export declare function renderToString<T>(fn: () => T, options?: {
|
|
116
|
-
nonce?: CSPNonce;
|
|
117
|
-
renderId?: string;
|
|
118
|
-
noScripts?: boolean;
|
|
119
|
-
plugins?: any[];
|
|
120
|
-
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
121
|
-
onError?: (err: any) => void;
|
|
122
|
-
/**
|
|
123
|
-
* Embedded-render contract for hosts that own the document. When the
|
|
124
|
-
* render output contains no `</head>`, everything head-bound (resolved
|
|
125
|
-
* `useHead` winners, eager resources, tracked asset links, inline
|
|
126
|
-
* styles) is delivered here as one HTML string — prelude (charset/base)
|
|
127
|
-
* first — for the host to splice into its own `<head>` template, instead
|
|
128
|
-
* of being dropped. Called synchronously before `renderToString`
|
|
129
|
-
* returns; not called when the output has a `</head>` (splicing is
|
|
130
|
-
* automatic then).
|
|
131
|
-
*/
|
|
132
|
-
onHead?: (head: string) => void;
|
|
133
|
-
}): string;
|
|
134
|
-
/**
|
|
135
|
-
* Streams an HTML response, flushing the synchronous shell first and then
|
|
136
|
-
* progressively emitting async-resolved fragments as their `<Loading>`
|
|
137
|
-
* boundaries settle. Good for time-to-first-byte sensitive pages.
|
|
138
|
-
*
|
|
139
|
-
* Returns an object with `pipe`/`pipeTo` for piping to a Node `Writable` or
|
|
140
|
-
* a Web `WritableStream`, a lazy `readable` byte-stream view for
|
|
141
|
-
* `new Response(stream.readable)`, plus a thenable for awaiting full
|
|
142
|
-
* completion — `await renderToStream(...)` resolves with the settled HTML
|
|
143
|
-
* (the fully-resolved-string form of the render). `pipe`, `pipeTo`, and
|
|
144
|
-
* `readable` each consume the render — use exactly one of the three.
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```tsx
|
|
148
|
-
* import { renderToStream } from "@solidjs/web";
|
|
149
|
-
*
|
|
150
|
-
* // Node:
|
|
151
|
-
* renderToStream(() => <App />).pipe(res);
|
|
152
|
-
*
|
|
153
|
-
* // Web (Workers / Deno):
|
|
154
|
-
* return new Response(renderToStream(() => <App />).readable);
|
|
155
|
-
*
|
|
156
|
-
* // Fully settled string:
|
|
157
|
-
* const html = await renderToStream(() => <App />);
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
161
|
-
nonce?: CSPNonce;
|
|
162
|
-
renderId?: string;
|
|
163
|
-
noScripts?: boolean;
|
|
164
|
-
plugins?: any[];
|
|
165
|
-
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
166
|
-
onCompleteShell?: (info: {
|
|
167
|
-
write: (v: string) => void;
|
|
168
|
-
}) => void;
|
|
169
|
-
onCompleteAll?: (info: {
|
|
170
|
-
write: (v: string) => void;
|
|
171
|
-
}) => void;
|
|
172
|
-
onError?: (err: any) => void;
|
|
173
|
-
/**
|
|
174
|
-
* Embedded-render contract for hosts that own the document. When the
|
|
175
|
-
* shell contains no `</head>`, everything head-bound at first flush
|
|
176
|
-
* (resolved `useHead` winners, eager resources, tracked asset links,
|
|
177
|
-
* inline styles) is delivered here as one HTML string — prelude first —
|
|
178
|
-
* before the shell chunk is emitted, so the host can write its own
|
|
179
|
-
* `<head>` ahead of piping the stream. Post-shell head updates flow
|
|
180
|
-
* through the stream itself and apply in the browser. Not called when
|
|
181
|
-
* the shell has a `</head>` (splicing is automatic then).
|
|
182
|
-
*/
|
|
183
|
-
onHead?: (head: string) => void;
|
|
184
|
-
}): {
|
|
185
|
-
/**
|
|
186
|
-
* Awaiting the stream resolves with the complete HTML once every boundary
|
|
187
|
-
* settles — the fully-settled-string form of the render. Render errors
|
|
188
|
-
* route through `onError` and the promise resolves with whatever HTML the
|
|
189
|
-
* render produced; it never rejects.
|
|
190
|
-
*/
|
|
191
|
-
then<TResult1 = string, TResult2 = never>(onfulfilled?: ((html: string) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
192
|
-
pipe: (writable: {
|
|
193
|
-
write: (v: string) => void;
|
|
194
|
-
end: () => void;
|
|
195
|
-
}) => void;
|
|
196
|
-
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
197
|
-
readonly readable: ReadableStream<Uint8Array>;
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* Fetch-style middleware: receives the `Request` and a `next` continuation
|
|
201
|
-
* (pass a `Request` to substitute it downstream) and returns the `Response`.
|
|
202
|
-
* Composed with `composeMiddleware`; runs inside the request-event scope, so
|
|
203
|
-
* `getRequestEvent()` works exactly as in application code.
|
|
204
|
-
*/
|
|
205
|
-
export type FetchMiddleware = (request: Request, next: (request?: Request) => Promise<Response>) => Response | Promise<Response>;
|
|
206
|
-
/**
|
|
207
|
-
* Creates a fresh, uncommitted {@link ResponseStub}. Server-only.
|
|
208
|
-
*/
|
|
209
|
-
export declare function createResponseStub(): ResponseStub;
|
|
210
|
-
/**
|
|
211
|
-
* Builds the canonical request event — a web-standard `Request`, a `locals`
|
|
212
|
-
* bag, and a stub-backed `response` head — for `provideRequestEvent`.
|
|
213
|
-
* Server-only: on the client the request event belongs to the server that
|
|
214
|
-
* rendered the page.
|
|
215
|
-
*/
|
|
216
|
-
export declare function createRequestEvent<T extends object = {}>(request: Request, init?: T): {
|
|
217
|
-
request: Request;
|
|
218
|
-
locals: RequestEventLocals;
|
|
219
|
-
response: ResponseStub;
|
|
220
|
-
} & T;
|
|
221
|
-
/**
|
|
222
|
-
* The HTTP status a redirect should use: the stub's own status when it is a
|
|
223
|
-
* redirect status (301/302/303/307/308), 302 otherwise. Server-only.
|
|
224
|
-
*/
|
|
225
|
-
export declare function getExpectedRedirectStatus(response: ResponseStub): number;
|
|
226
|
-
/**
|
|
227
|
-
* Derives the outgoing `Response` for an SSR render result, running the
|
|
228
|
-
* response-head lifecycle against `event.response`: the stub commits at
|
|
229
|
-
* shell flush, a pre-flush `Location` becomes a real redirect
|
|
230
|
-
* (`getExpectedRedirectStatus`), and a post-flush one appends the
|
|
231
|
-
* nonce-aware `<script>window.location=...</script>` fallback. String
|
|
232
|
-
* results return a `Response` synchronously (an awaited `renderToStream`
|
|
233
|
-
* result arrives already committed — its head froze at completion); stream
|
|
234
|
-
* results resolve at shell flush. Server-only.
|
|
235
|
-
*/
|
|
236
|
-
export declare function createSSRResponse(result: string, event: RequestEvent | undefined, options?: {
|
|
237
|
-
responseInit?: ResponseInit;
|
|
238
|
-
nonce?: string;
|
|
239
|
-
transformChunk?: (chunk: string) => string;
|
|
240
|
-
}): Response;
|
|
241
|
-
export declare function createSSRResponse(result: {
|
|
242
|
-
pipe(writable: {
|
|
243
|
-
write: (v: string) => void;
|
|
244
|
-
end: () => void;
|
|
245
|
-
}): void;
|
|
246
|
-
}, event: RequestEvent | undefined, options?: {
|
|
247
|
-
responseInit?: ResponseInit;
|
|
248
|
-
nonce?: string;
|
|
249
|
-
transformChunk?: (chunk: string) => string;
|
|
250
|
-
}): Promise<Response>;
|
|
251
|
-
/**
|
|
252
|
-
* Handler-lifecycle plumbing — the exit for a `Response` that did not go
|
|
253
|
-
* through `createSSRResponse` (a middleware early return, an API result):
|
|
254
|
-
* folds the request event's response stub onto it (cookies append
|
|
255
|
-
* entry-by-entry, other headers gap-fill, status never) and commits the
|
|
256
|
-
* stub. Already-committed stubs pass the response through untouched, so
|
|
257
|
-
* handlers apply it unconditionally after their middleware chain unwinds.
|
|
258
|
-
* `event` defaults to the ambient `getRequestEvent()`. Application
|
|
259
|
-
* middleware never calls this. Server-only.
|
|
260
|
-
*/
|
|
261
|
-
export declare function commitEventResponse(response: Response, event?: RequestEvent): Response;
|
|
262
|
-
/**
|
|
263
|
-
* Composes fetch-style middleware — `(request, next) => Response` — into a
|
|
264
|
-
* single function of the same shape. Nothing reaches the wire until the
|
|
265
|
-
* outermost middleware returns, so headers on the returned `Response` stay
|
|
266
|
-
* mutable through the whole unwind, streamed bodies included. Server-only.
|
|
267
|
-
*/
|
|
268
|
-
export declare function composeMiddleware(middlewares: FetchMiddleware[]): (request: Request, next: (request?: Request) => Response | Promise<Response>) => Promise<Response>;
|
|
269
|
-
/**
|
|
270
|
-
* Compiler primitive — emitted by Solid's JSX compiler for tagged-template
|
|
271
|
-
* SSR output. Not meant for hand-written code.
|
|
272
|
-
* @internal
|
|
273
|
-
*/
|
|
274
|
-
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
275
|
-
t: string;
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* Compiler primitive — emitted by Solid's JSX compiler for SSR element
|
|
279
|
-
* output. Not meant for hand-written code.
|
|
280
|
-
* @internal
|
|
281
|
-
*/
|
|
282
|
-
export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
|
|
283
|
-
t: string;
|
|
284
|
-
};
|
|
285
|
-
/**
|
|
286
|
-
* Compiler primitive — serializes a class value (string, object map, or
|
|
287
|
-
* array) for SSR output. Not meant for hand-written code.
|
|
288
|
-
* @internal
|
|
289
|
-
*/
|
|
290
|
-
export declare function ssrClassName(value: string | {
|
|
291
|
-
[k: string]: boolean;
|
|
292
|
-
} | Array<any>): string;
|
|
293
|
-
/**
|
|
294
|
-
* Compiler primitive — serializes a style value for SSR output. Not meant
|
|
295
|
-
* for hand-written code.
|
|
296
|
-
* @internal
|
|
297
|
-
*/
|
|
298
|
-
export declare function ssrStyle(value: string | {
|
|
299
|
-
[k: string]: string;
|
|
300
|
-
}): string;
|
|
301
|
-
/**
|
|
302
|
-
* Compiler primitive — serializes one style property for SSR output. Not
|
|
303
|
-
* meant for hand-written code.
|
|
304
|
-
* @internal
|
|
305
|
-
*/
|
|
306
|
-
export declare function ssrStyleProperty(name: string, value: any): string;
|
|
307
|
-
/**
|
|
308
|
-
* Compiler primitive — serializes an attribute for SSR output. Not meant
|
|
309
|
-
* for hand-written code.
|
|
310
|
-
* @internal
|
|
311
|
-
*/
|
|
312
|
-
export declare function ssrAttribute(key: string, value: any): string;
|
|
313
|
-
/**
|
|
314
|
-
* Compiler primitive — wraps a template-group closure for SSR output. Not
|
|
315
|
-
* meant for hand-written code.
|
|
316
|
-
* @internal
|
|
317
|
-
*/
|
|
318
|
-
export declare function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
|
|
319
|
-
/**
|
|
320
|
-
* Compiler primitive — generates the hydration-key attribute for SSR
|
|
321
|
-
* output. Not meant for hand-written code.
|
|
322
|
-
* @internal
|
|
323
|
-
*/
|
|
324
|
-
export declare function ssrHydrationKey(): string;
|
|
325
|
-
/**
|
|
326
|
-
* Compiler primitive — collapses an SSR-shaped node into its HTML string.
|
|
327
|
-
* Not meant for hand-written code.
|
|
328
|
-
* @internal
|
|
329
|
-
*/
|
|
330
|
-
export declare function resolveSSRNode(node: any, result?: any, top?: boolean): any;
|
|
331
|
-
/**
|
|
332
|
-
* Escapes a string for safe inclusion in HTML output. Used by the SSR
|
|
333
|
-
* runtime; not generally part of user code.
|
|
334
|
-
* @internal
|
|
335
|
-
*/
|
|
336
|
-
export declare function escape(s: any, attr?: boolean): any;
|
|
337
|
-
export {};
|