@solidjs/web 2.0.0-rc.11 → 2.0.0-rc.14

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 (60) hide show
  1. package/dist/server.dev.js +705 -151
  2. package/dist/server.js +604 -123
  3. package/dist/server.observe.js +617 -124
  4. package/dist/web.dev.js +102 -41
  5. package/dist/web.js +75 -37
  6. package/dist/web.observe.js +75 -39
  7. package/frames/dist/assets.js +92 -0
  8. package/frames/dist/bind.dev.js +326 -0
  9. package/frames/dist/bind.js +295 -0
  10. package/frames/dist/client.dev.js +693 -919
  11. package/frames/dist/client.js +636 -917
  12. package/frames/dist/client.observe.js +637 -917
  13. package/frames/dist/regions.js +130 -0
  14. package/frames/dist/server.dev.js +607 -212
  15. package/frames/dist/server.js +554 -212
  16. package/frames/dist/server.observe.js +554 -212
  17. package/frames/dist/trace.js +42 -0
  18. package/frames/dist/wire.js +133 -0
  19. package/package.json +30 -3
  20. package/performance-tracks/dist/performance-tracks.dev.js +2 -1
  21. package/performance-tracks/dist/performance-tracks.observe.js +2 -1
  22. package/performance-tracks/types/index.d.ts +8 -6
  23. package/serialization/dist/decode.js +37 -8
  24. package/serialization/dist/serialization.js +39 -10
  25. package/serialization/types/serializer-decode.d.ts +24 -2
  26. package/server-functions/dist/client.dev.js +178 -72
  27. package/server-functions/dist/client.js +99 -61
  28. package/server-functions/dist/client.observe.js +178 -72
  29. package/server-functions/dist/server.dev.js +117 -56
  30. package/server-functions/dist/server.js +117 -56
  31. package/server-functions/dist/server.observe.js +117 -56
  32. package/skills/server-components/SKILL.md +228 -0
  33. package/types/client.d.ts +37 -2
  34. package/types/constants.d.ts +2 -1
  35. package/types/diagnostics.d.ts +8 -0
  36. package/types/frames/assets-tier.d.ts +78 -0
  37. package/types/frames/bind-tier.d.ts +60 -0
  38. package/types/frames/client.d.ts +37 -3
  39. package/types/frames/frame-client.d.ts +249 -96
  40. package/types/frames/frame-container-plugin.d.ts +2 -10
  41. package/types/frames/frame-sink.d.ts +33 -0
  42. package/types/frames/frame-transport.d.ts +66 -18
  43. package/types/frames/regions-tier.d.ts +45 -0
  44. package/types/frames/serializer-decode.d.ts +24 -2
  45. package/types/frames/server.d.ts +53 -1
  46. package/types/frames/trace-tier.d.ts +2 -0
  47. package/types/frames/tree-rewrite.d.ts +39 -0
  48. package/types/frames/wire-tier.d.ts +116 -0
  49. package/types/index.d.ts +38 -0
  50. package/types/index.server.d.ts +10 -1
  51. package/types/jsx.d.ts +11 -1
  52. package/types/observe.d.ts +182 -12
  53. package/types/request-error-hook.d.ts +5 -0
  54. package/types/serializer-decode.d.ts +24 -2
  55. package/types/server-functions/client.d.ts +26 -0
  56. package/types/server-functions/registry.d.ts +4 -1
  57. package/types/server-functions/shared.d.ts +12 -8
  58. package/types/server-mock.d.ts +13 -1
  59. package/types/server-observe.d.ts +8 -0
  60. package/types/server.d.ts +125 -12
@@ -106,10 +106,34 @@ export interface RenderEvent {
106
106
  * `"complete"` — the render ran to its end; `"abandoned"` — the consumer
107
107
  * left mid-stream (the sink threw, the readable was cancelled — the
108
108
  * `SSR_STREAM_ABANDONED` finding is that request's account) and the
109
- * render was torn down; `"error"` — the render failed: a string render
110
- * threw, a stream's uncontained failure wound it down through `onError`.
109
+ * render was torn down, or `createSSRResponse` discarded the page for a
110
+ * pre-flush redirect (no finding); `"error"` — the render failed: a
111
+ * string render threw, a stream's uncontained failure wound it down
112
+ * through `onError`.
111
113
  */
112
114
  outcome: "complete" | "abandoned" | "error";
115
+ /**
116
+ * The route the render resolved to, as the router declared it while
117
+ * building its context under this render (`OBSERVE.attribution.withOrigin`
118
+ * with an `initial` ref — the same declaration the client's first
119
+ * `"navigation"` record comes from): `name` the matched pattern
120
+ * (`/users/:id`), `to` the concrete path, `params` what the pattern
121
+ * bound. Read from the router's ref when the render settles, so a match
122
+ * refined during the render is what lands. Absent when no router declared
123
+ * one — a render without a router, or a router that does not yet. What a
124
+ * consumer names the request by (`http.route`), where the URL would
125
+ * scatter one page across as many names as it has parameters.
126
+ */
127
+ route?: RenderRoute;
128
+ }
129
+ /** `RenderEvent.route` — the route a render resolved to, as the router matched it. */
130
+ export interface RenderRoute {
131
+ /** The matched route pattern — `/users/:id`. */
132
+ name?: string;
133
+ /** The concrete path. */
134
+ to?: string;
135
+ /** The params the pattern bound (optional params unbound: `undefined`). */
136
+ params?: Readonly<Record<string, string | undefined>>;
113
137
  }
114
138
  /** The live half of a render record. */
115
139
  export interface RenderLive {
@@ -131,6 +155,15 @@ export type RenderListener = (event: RenderEvent, live: RenderLive) => void;
131
155
  export interface CallEvent {
132
156
  /** The function id — the same `id` the server's `"invocation"` record carries. */
133
157
  id: string;
158
+ /**
159
+ * The function's source name, from the reference's metadata
160
+ * (`ServerFunctionMetadata.name`): the compiled function's name, which
161
+ * the compiler seeds in development builds only, or an explicit label
162
+ * (`withMeta`, the `name` argument to `createServerReference`), which
163
+ * survives to production. A label, not an identity: not unique, and
164
+ * absent when the metadata carries none.
165
+ */
166
+ name?: string;
134
167
  /** `performance.now()` when the call was made. */
135
168
  at: number;
136
169
  /**
@@ -169,14 +202,78 @@ export interface CallEvent {
169
202
  deferred?: true;
170
203
  }
171
204
  /**
172
- * The live half of a call, for in-process consumers. `response` is the
173
- * transport's own object, not a clone: its status and headers are
174
- * readable, its body is the decode's (already consumed, or being consumed
175
- * by the caller for a streaming result). `error` is the value as thrown to
176
- * the caller — a decoded server error, or the transport's own failure.
205
+ * The live half of a call, for in-process consumers — ONE object across
206
+ * the call's records: the same `CallLive` is handed to the `"request"`
207
+ * listener at the send and to the `"call"` listener at settle, filled in
208
+ * as the call proceeds (`args` from the start, `request` at the send,
209
+ * `response` and `result`/`error` at settle — filled on every settle,
210
+ * whether or not a `"call"` record goes out, so a `"request"` listener
211
+ * holding it reads the outcome off it too), so an in-process consumer
212
+ * joins a call's request to its settle by identity — the way `origin`
213
+ * joins a record to the interaction's — with no id-plus-time join and no
214
+ * sequence number. One MUTABLE object shared by both records' listeners:
215
+ * treat it as read-only — a write shows up on the other record's
216
+ * listener. `error` is the value as thrown to the caller — a
217
+ * decoded server error, or the transport's own failure. The bodies —
218
+ * `request`, and `response` as an unread clone — are a body viewer's
219
+ * (devtools' network panel), and are taken only while a listener asked for
220
+ * them (`OBSERVE.records.subscribe("call", fn, { bodies: true })`, or the
221
+ * same on `"request"` for the request alone): each costs the call a
222
+ * reconstruction and a transient double-buffer of the payload, which a
223
+ * consumer that reads ids, statuses and timings never pays. With no such
224
+ * listener `request` is absent and `response` is the transport's own
225
+ * object, consumed by its decode. Whether bodies are taken is read once,
226
+ * as the call starts.
177
227
  */
178
228
  export interface CallLive {
179
229
  args: unknown[];
230
+ /**
231
+ * Bodies opted in — by a `"call"` listener or a `"request"` listener
232
+ * (`observed("call", "bodies") || observed("request", "bodies")`): the
233
+ * request as dispatched — the final url and `RequestInit` (the
234
+ * transport's headers, the `prepareRequest` hook applied), built into a
235
+ * `Request` of the listener's own at the send, so its headers and body
236
+ * are readable in full and reading them touches nothing the transport
237
+ * sent. Set before the `"request"` record is delivered, so that listener
238
+ * reads it too — and it is ONE `Request`, shared by the call's
239
+ * `"request"` and `"call"` records: a body reads once, so a listener that
240
+ * wants it reads through `request.clone()` (`live.request.clone().text()`)
241
+ * and the other record's listener can still read it; a direct
242
+ * `live.request.text()` leaves `bodyUsed` true for whoever reads next.
243
+ * Built WITH the body only when the body has a shape a
244
+ * second `Request` can hold without a competing consumer — `string`,
245
+ * `URLSearchParams`, `FormData`, `Blob`, `ArrayBuffer` or a view of one
246
+ * — and WITHOUT it otherwise (a `ReadableStream` or an async iterable,
247
+ * the transport's streaming-upload contract: reconstructing one would
248
+ * consume it ahead of the send), so the request then reads as bodyless.
249
+ * Absent without the opt-in; when the call failed before the request was
250
+ * built (argument serialization threw); when the address is relative and
251
+ * there is no `location` to resolve it against (absent beats a URL that
252
+ * was never sent); and when the reconstruction itself failed (an init
253
+ * the `Request` constructor rejects but the configured `fetch`
254
+ * tolerates) — a reconstruction never fails the call.
255
+ */
256
+ request?: Request;
257
+ /**
258
+ * The response: with bodies opted in, one with an UNREAD body — a
259
+ * `clone()` taken as the response arrived, before the transport's
260
+ * decode, so the listener reads status, headers and body while the
261
+ * caller still gets its result from the original. The transport's own
262
+ * object instead — status and headers readable, body consumed by the
263
+ * transport's decode — without the opt-in, and, with it, for a response
264
+ * whose clone would be a branch nobody drains: an event-stream response
265
+ * (a `live()` source, `text/event-stream`, a connection open for the
266
+ * page's life), a deferred result (a generator's stream, `deferred:
267
+ * true`, served for the stream's life — its clone, taken before the
268
+ * result's shape was known, is cancelled at settle), and a response the
269
+ * `clone()` refused (one a configured `fetch` handed over already read).
270
+ * A response a `responseHandler` claimed whose result is not a deferred
271
+ * body — a non-live `application/x-frame-stream` frame render the frames
272
+ * transport claims, say — keeps its clone, so under the opt-in the
273
+ * clone's branch buffers that render until the listener reads it or
274
+ * drops the record; live frames are `text/event-stream` and are never
275
+ * cloned. Absent when the fetch itself rejected.
276
+ */
180
277
  response?: Response;
181
278
  /** The settled value, when `outcome` is `"ok"`. */
182
279
  result?: unknown;
@@ -184,6 +281,63 @@ export interface CallLive {
184
281
  error?: unknown;
185
282
  }
186
283
  export type CallListener = (event: CallEvent, live: CallLive) => void;
284
+ /**
285
+ * One server-function request LEFT the browser — delivered on
286
+ * `OBSERVE.records.subscribe("request", …)` at the send: after the
287
+ * arguments were serialized and `prepareRequest` had its say, immediately
288
+ * before the transport's `fetch` is handed the request. "Left" means
289
+ * HANDED TO `fetch`, not that it reached the network: a `fetch` that
290
+ * throws synchronously still has its `"request"` (and a `"call"` with
291
+ * `outcome: "error"`). The `"call"` record of the same call follows at
292
+ * settle; this one exists because that one cannot show a call that is
293
+ * still in flight, or one that never settles (a hung fetch) — a network
294
+ * panel's pending row. The two records share their `CallLive` by identity
295
+ * (see `CallLive`): the object handed here is the object handed to the
296
+ * `"call"` listener, so an in-process consumer joins them with no
297
+ * id-plus-time join and no sequence number.
298
+ *
299
+ * Emitted only for a request that was handed over: a call that failed
300
+ * before its request was built (argument serialization threw, or
301
+ * `prepareRequest` did) emits no `"request"` — only its `"call"` settle; a
302
+ * call an integration answered locally (a handler's `intercept`) made no
303
+ * request and emits neither. A deferred or streaming result emits
304
+ * `"request"` at the send and `"call"` at handoff, as today. Serializable;
305
+ * `live.request` (under `bodies`) rides beside it.
306
+ *
307
+ * Listeners run synchronously, on the call's path, BEFORE the send: a slow
308
+ * listener delays the fetch and the time it spends is inside the call's
309
+ * `durationMs`. Read what is needed and hand the work off to a microtask
310
+ * (the same guidance the engine's records give).
311
+ */
312
+ export interface CallRequestEvent {
313
+ /**
314
+ * Which end recorded it. Only `"client"` exists today — the request left
315
+ * the browser. The server half (the request arrived, ahead of its
316
+ * `"invocation"`) is `"server"`, additive later, the way the `"frame"`
317
+ * record has two halves.
318
+ */
319
+ side: "client";
320
+ /** The function id — the same `id` the call's `"call"` and the server's `"invocation"` carry. */
321
+ id: string;
322
+ /** The function's source name, by the same rule as `CallEvent.name`. */
323
+ name?: string;
324
+ /**
325
+ * `performance.now()` at the send — when the request was handed to
326
+ * `fetch`, after serialization and `prepareRequest`. NOT the call's
327
+ * `CallEvent.at`, which is when the call was made: the gap between them
328
+ * is what building the request cost (an async `prepareRequest`
329
+ * included), and `CallEvent.at + durationMs` is never before this.
330
+ */
331
+ at: number;
332
+ /** `GET` for a GET-encoded read (`GET(fn)`), `POST` otherwise — as on `CallEvent`. */
333
+ method: "GET" | "POST";
334
+ /**
335
+ * What the call ran for — the same object `CallEvent.origin` carries,
336
+ * read at dispatch (see `CallEvent.origin` for the rule).
337
+ */
338
+ origin?: ChangeOrigin;
339
+ }
340
+ export type CallRequestListener = (event: CallRequestEvent, live: CallLive) => void;
187
341
  interface FrameEventBase {
188
342
  /**
189
343
  * The frame id on the wire: the server function's id when the stream is a
@@ -299,6 +453,15 @@ declare module "solid-js" {
299
453
  event: CallEvent;
300
454
  live: CallLive;
301
455
  };
456
+ /**
457
+ * Server-function requests left, from the client — see
458
+ * `CallRequestEvent`; the `live` is the call's own, shared with its
459
+ * `"call"` record.
460
+ */
461
+ request: {
462
+ event: CallRequestEvent;
463
+ live: CallLive;
464
+ };
302
465
  /** Frame streams, produced or applied — see `FrameEvent`. */
303
466
  frame: {
304
467
  event: FrameEvent;
@@ -316,6 +479,12 @@ export declare function isDeferredBody(value: unknown): boolean;
316
479
  export declare function frameCensus(event: FrameEventBase, type: string, own: boolean): void;
317
480
  /** What the client runtime hands a call observation as the call proceeds. */
318
481
  export interface CallObservation {
482
+ /**
483
+ * The request is about to be sent: the address and the final
484
+ * `RequestInit` — what the transport's `fetch` receives, hook applied.
485
+ * The `"request"` record is delivered from here.
486
+ */
487
+ request(url: string, init: RequestInit): void;
319
488
  /** The response arrived (before decode); its status goes on the record. */
320
489
  response(response: Response): void;
321
490
  /** The call settled as the caller sees it: the value returned, or the error thrown. */
@@ -323,12 +492,13 @@ export interface CallObservation {
323
492
  }
324
493
  /**
325
494
  * Opens the observation of one server-function call from the client, as
326
- * the request is about to be built; the runtime reports the response when
327
- * it arrives and the settle when the caller gets its answer. `undefined`
328
- * with no listener or outside observe builds — the runtime then does
329
- * nothing extra, not even read the clock.
495
+ * the request is about to be built; the runtime reports the request as it
496
+ * is sent (the `"request"` record), the response when it arrives and the
497
+ * settle when the caller gets its answer (the `"call"` record). `undefined`
498
+ * with no listener for either record or outside observe builds — the
499
+ * runtime then does nothing extra, not even read the clock.
330
500
  */
331
- export declare function observeCall(id: string, method: "GET" | "POST", args: unknown[]): CallObservation | undefined;
501
+ export declare function observeCall(id: string, method: "GET" | "POST", args: unknown[], name?: string): CallObservation | undefined;
332
502
  /** What the client's stream reader hands a frame observation. */
333
503
  export interface FrameApplyObservation {
334
504
  /**
@@ -0,0 +1,5 @@
1
+ import type { ServerErrorHook } from "solid-js";
2
+ /** Files a render's `onError` as the hook of the request it serves. */
3
+ export declare function setRequestErrorHook(event: object, hook: ServerErrorHook | undefined): void;
4
+ /** The hook of the render serving `event`'s request, if one was given. */
5
+ export declare function requestErrorHook(event: object | undefined): ServerErrorHook | undefined;
@@ -121,8 +121,17 @@ export interface JSONCodecOptions {
121
121
  /**
122
122
  * A resident, response-scoped decode table over the keyed JSON codec: apply
123
123
  * each frame `data` chunk with `apply`, resolve `{ $ref }` slot args with
124
- * `resolve`. The frames client host wires one per response
125
- * (`applyData: c => table.apply(c)`).
124
+ * `resolve`, and `close` it when the response ends. The frames client host
125
+ * wires one per response (`applyData: c => table.apply(c)`,
126
+ * `closeData: (…) => table.close(error)`).
127
+ *
128
+ * A `{ $ref }` to a key no `apply` has delivered yet is a PENDING READ the
129
+ * table owns (`@internal` behaviour — the frames client is its consumer): a
130
+ * promise marked `s = 0`, settled by the key's `apply` and rejected by
131
+ * `close` — the response ended without delivering the key, so a value that
132
+ * never comes is an error where it is read, not a silence. Stamped `s`/`v`
133
+ * as it settles (`1` fulfilled, `2` rejected — the hydration serializer's
134
+ * marks, which a reader adopts synchronously).
126
135
  *
127
136
  * Integration-facing; may change (see the entry banner). This serialization
128
137
  * entry is the single home of the data table — the frames client consumes
@@ -134,9 +143,22 @@ export interface JSONDataTable {
134
143
  node?: unknown;
135
144
  initial?: boolean;
136
145
  }): void;
146
+ /**
147
+ * The value under `ref`, or the table's pending read of it: a promise
148
+ * marked `s = 0` carrying `c`, the callbacks the table runs in the
149
+ * `apply` / `close` that settles it — the key delivered (whatever its
150
+ * value's shape: a delivered promise is adopted by the read, the
151
+ * callbacks do not wait for it) or the table closed.
152
+ */
137
153
  resolve<T = unknown>(ref: {
138
154
  $ref: string;
139
155
  }): T;
156
+ /**
157
+ * The response has ended: every pending read of a key it never
158
+ * delivered rejects — with `error` (the response's own) when given, with
159
+ * an `Error` naming the key otherwise. Idempotent.
160
+ */
161
+ close(error?: unknown): void;
140
162
  }
141
163
  /**
142
164
  * Baseline plugin set for serializing web-platform values. Shared by the
@@ -115,11 +115,30 @@ export interface ServerFunctionsClientConfig {
115
115
  id: string;
116
116
  meta: unknown;
117
117
  }): unknown;
118
+ /**
119
+ * `ctx.retry` makes the same call again — the reference, arguments,
120
+ * declared shape and per-call options as dispatched (a `GET`-declared
121
+ * read stays a GET; a caller-supplied `signal` still owns the wire) —
122
+ * for a handler re-asking on its own account (a frames boundary's
123
+ * `reset`, frames-rulings 3.3).
124
+ */
118
125
  handle(response: Response, ctx: {
119
126
  id: string;
120
127
  meta: unknown;
121
128
  args: unknown[];
122
129
  context: unknown;
130
+ retry(): Promise<unknown>;
131
+ }): unknown;
132
+ /**
133
+ * Answer a call before any request is made (t = 0 local answers — see
134
+ * `createServerComponentHandler`). `info.retry` is the call as it would
135
+ * go to the wire, for a handler that answers now and re-asks later.
136
+ */
137
+ intercept?(info: {
138
+ id: string;
139
+ meta: unknown;
140
+ args: unknown[];
141
+ retry(): Promise<unknown>;
123
142
  }): unknown;
124
143
  /**
125
144
  * What a `live` (re)connect of the call resumes from, when the handler
@@ -135,6 +154,13 @@ export interface ServerFunctionsClientConfig {
135
154
  position?: string;
136
155
  headers?: Record<string, string>;
137
156
  } | undefined;
157
+ /**
158
+ * A `live()` call was made — fired at the call, before its first fetch,
159
+ * so a handler that serves live calls through code it loads on demand
160
+ * (the frames client's live wire tier) can start the load against the
161
+ * request's own latency. Per call, not per connect.
162
+ */
163
+ onLive?(): void;
138
164
  };
139
165
  /**
140
166
  * Encoder for argument lists JSON can't carry faithfully. JSON-safe args
@@ -96,7 +96,10 @@ export declare function provideServerFunctionRPC(rpc: any): void;
96
96
  /**
97
97
  * The registered RPC surface, or undefined when no server function exists
98
98
  * in this build's graph. Integration plumbing (routers): gate every use of
99
- * the transport/codec behind this read instead of importing it.
99
+ * the transport/codec behind this read instead of importing it. Both halves
100
+ * carry `GET` and `decodeResponse`. (A handler re-asking a call it answered
101
+ * does so through the call's own `retry` thunk — `responseHandler` in the
102
+ * client config — not through this slot.)
100
103
  * @internal
101
104
  */
102
105
  export declare function getServerFunctionRPC(): any;
@@ -178,11 +178,13 @@ export declare function hasFlightMetadata(response: Response): boolean;
178
178
  * envelope context, whose `SINGLE_FLIGHT_HEADER` names the folded sources.
179
179
  * Each registered consumer receives its own slice, in registration order,
180
180
  * awaited sequentially so caches are seeded before the caller sees the
181
- * value. A consumer whose source was not folded is skipped — unless the
182
- * response carries integration metadata, in which case it runs with `data`
183
- * `undefined` to apply the metadata. Consumers are looked up per delivery:
184
- * an awaited consumer may unsubscribe another (a provider tearing down
185
- * under a navigation).
181
+ * value. Pending entries in the slices (values the collector folded while
182
+ * still in flight, streamed after the response head) are settled before
183
+ * any consumer runs. A consumer whose source was not folded is skipped —
184
+ * unless the response carries integration metadata, in which case it runs
185
+ * with `data` `undefined` to apply the metadata. Consumers are looked up
186
+ * per delivery: an awaited consumer may unsubscribe another (a provider
187
+ * tearing down under a navigation).
186
188
  *
187
189
  * Transport building block; not meant for hand-written code.
188
190
  * @internal
@@ -354,14 +356,16 @@ export declare function extractBody(source: Request | Response, codecOptions?: J
354
356
  export declare function createChunk(data: string): Uint8Array;
355
357
  export declare class ChunkReader {
356
358
  constructor(stream: any);
357
- readChunk(): Promise<void>;
359
+ /** Reads once into the buffer; answers whether the reader was cancelled. */
360
+ readChunk(): Promise<any>;
358
361
  next(): Promise<{
359
362
  done: boolean;
360
- value: string;
363
+ value: any;
361
364
  }>;
362
365
  drain(interpret: any): Promise<void>;
363
366
  /** End the read: the body is cancelled through the lock this reader
364
- * holds, and a pending `next()` resolves done. */
367
+ * holds, and a pending `next()` resolves done, even partway through a
368
+ * frame. */
365
369
  cancel(reason: any): any;
366
370
  }
367
371
  /**
@@ -5,7 +5,7 @@ import type { ServerErrorSite } from "solid-js";
5
5
  * Where a server-side failure was met, as the server error hook hears it —
6
6
  * the client's view of the server entry's type (see `configureServerErrors`
7
7
  * there). `kind: "render"`: `fallback`/`client`/`failed`; `kind:
8
- * "server-function"`: `thrown`/`channel`.
8
+ * "server-function"`: `thrown`/`channel`; `kind: "request"`: `failed`.
9
9
  */
10
10
  export interface ServerErrorContext extends Omit<ServerErrorSite, "event"> {
11
11
  event?: RequestEvent;
@@ -20,6 +20,12 @@ export interface ServerErrorsConfig {
20
20
  * is a no-op so isomorphic setup code can call it unguarded.
21
21
  */
22
22
  export declare function configureServerErrors(_config: ServerErrorsConfig): void;
23
+ /**
24
+ * Reports a failure that fails a request outside any render (see the
25
+ * server entry's `reportRequestFailure`). Server-only; on the client this is
26
+ * a no-op.
27
+ */
28
+ export declare function reportRequestFailure(_error: unknown, _event: RequestEvent): void;
23
29
  type PreloadLinkAttributes = {
24
30
  type?: string;
25
31
  crossorigin?: JSX.HTMLCrossorigin;
@@ -341,6 +347,12 @@ export declare function ssrStyle(value: string | {
341
347
  * @internal
342
348
  */
343
349
  export declare function ssrStyleProperty(name: string, value: any): string;
350
+ /**
351
+ * Compiler primitive — serializes a style object's `name, value` pairs for
352
+ * SSR output. Not meant for hand-written code.
353
+ * @internal
354
+ */
355
+ export declare function ssrStyleProperties(...entries: any[]): string;
344
356
  /**
345
357
  * Compiler primitive — serializes an attribute for SSR output. Not meant
346
358
  * for hand-written code.
@@ -1,4 +1,5 @@
1
1
  import { type FrameProducedEvent, type RenderEvent } from "./observe.js";
2
+ import type { NavigationRef } from "solid-js";
2
3
  import { type TraceRecord } from "./trace.js";
3
4
  import type { RequestEvent } from "./server.js";
4
5
  /**
@@ -24,6 +25,13 @@ export interface RenderObservation {
24
25
  shell(): void;
25
26
  /** A `<Loading>` boundary the shell waited on settled: counts it (`boundaries`). */
26
27
  boundary(): void;
28
+ /**
29
+ * The router declared the render's route (`_declareRoute` on the render
30
+ * context): keeps the ref, read at `settle` into `RenderEvent.route`. A
31
+ * later declaration replaces an earlier one (a router remounted by a
32
+ * boundary's second pass describes the same route again).
33
+ */
34
+ route(ref: NavigationRef): void;
27
35
  /** The render ended; delivers the record. Once. */
28
36
  settle(outcome: RenderEvent["outcome"]): void;
29
37
  }
package/types/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { sharedConfig, getOwner, createComponent, untrack, merge as mergeProps } from "solid-js";
2
- import { ssrScope as scope } from "solid-js/internal";
1
+ import { getOwner, createComponent, untrack, merge as mergeProps } from "solid-js";
2
+ import { sharedConfig, ssrScope as scope } from "solid-js/internal";
3
3
  import type { ServerErrorSite } from "solid-js/internal";
4
4
  import { effect, memo } from "./render.js";
5
5
  import { type TraceContext } from "./trace.js";
@@ -230,8 +230,10 @@ export declare function renderToString<T>(fn: () => T, options?: {
230
230
  * This render's server error hook, ahead of `configureServerErrors`'
231
231
  * (see `ServerErrorHook`): every failure the render handles — an
232
232
  * `<Errored>` fallback (`handling: "fallback"`), a hydration value that
233
- * would not serialize (`"serialize"`) — once per error, with where it
234
- * was met. A one-argument listener still works; it hears them all.
233
+ * would not serialize (`"serialize"`) — and the throw that fails it
234
+ * (`"failed"`, heard before it is rethrown to the caller), once per
235
+ * error, with where it was met. A one-argument listener still works; it
236
+ * hears them all.
235
237
  */
236
238
  onError?: ServerErrorHook;
237
239
  /**
@@ -394,16 +396,54 @@ export declare function ssrStyle(value: string | {
394
396
  [k: string]: string;
395
397
  }): string;
396
398
  export declare function ssrStyleProperty(name: string, value: any): string;
397
- export declare function ssrElement(name: string, props: any | any[] | (() => any | any[]), children: any, needsId: boolean, skip?: (key: string) => boolean, attrs?: string | (() => string)): {
399
+ export declare function ssrStyleProperties(...entries: any[]): string;
400
+ export declare function ssrElement(name: string, props: any | any[] | (() => any | any[]), children: any, needsId: boolean, skip?: (key: string) => boolean, attrs?: string | (() => string), claims?: () => Record<number, Record<string, unknown>>): {
398
401
  t: string;
399
402
  };
400
403
  export declare function ssrElementAttribute(key: string, value: any): string;
401
404
  export declare function ssrAttribute(key: string, value: any): string;
402
405
  export declare function ssrHydrationKey(): string;
403
- export declare const CLAIM_PROP: unique symbol;
404
406
  export declare const CLAIMS_STREAM = 1;
405
407
  export declare const CLAIMS_DOCUMENT = 2;
406
- export declare function ssrClaim(map: any): string;
408
+ /** The brand on a binding slot's stand-in for one property read. */
409
+ export declare const SLOT_VALUE: unique symbol;
410
+ /** Marker attribute prefix on a consuming element (`_s:class`, `_s:on:click`, `_s:ref`). */
411
+ export declare const SLOT_MARKER = "_s:";
412
+ /** Faces a stand-in can come from (`slotValue`'s `face`). */
413
+ export declare const SLOT_FACE_STREAM = 0;
414
+ export declare const SLOT_FACE_DATA = 1;
415
+ export declare const SLOT_FACE_MARKUP = 2;
416
+ export declare function isSlotValue(value: unknown): boolean;
417
+ /**
418
+ * A binding slot's stand-in for one property read. `face` says what the
419
+ * occurrence's fill produced where this read happens: nothing (the stream
420
+ * face never runs fills), a data object (the document face — `value` is
421
+ * the t=0 value of `key`), or markup (the document face ran the fill and
422
+ * it returned content — a read off it is a dev finding at the position).
423
+ * The server has no value to compute with — on the stream face none at
424
+ * all, on the document face only the t=0 one — so the ONLY thing a stand-in
425
+ * can be is the whole value at one position. Every coercion the runtime can
426
+ * see (a template literal, `+`, a comparison, an explicit `String()`) is a
427
+ * dev finding, and it renders NOTHING on either face: the document face
428
+ * never shows a t=0 value the stream face cannot reproduce, so a misuse is
429
+ * visible on the first render rather than on the first refetch. Truthiness
430
+ * (`if (row.done)`, `row.x && …`) has no hook and is the one misuse only
431
+ * the rule can catch — a stand-in is an object and always truthy.
432
+ * @internal Created by the slot proxies (frames server).
433
+ */
434
+ export declare function slotValue(occurrence: string, key: string, value: unknown, face: number): object;
435
+ /**
436
+ * The compiled per-element hole for ref/onXxx positions on a server
437
+ * intrinsic (behind the `serverComponents` compiler option):
438
+ * `ctx.claims ? ssrClaim({ click: expr, ref: expr2 }) : ""`. The compiler
439
+ * drops handler and ref expressions from plain SSR output, so this is
440
+ * where a stand-in at one of those positions is seen. A server-local
441
+ * function there can never run (the server has no client to run it on);
442
+ * dev says so, inside the component barrier only. An element with a
443
+ * handler position bound is an EVENT-SLOT consumer and carries the
444
+ * replay-window stamp beside its markers (`eventSlotStamp`).
445
+ */
446
+ export declare function ssrClaim(map: Record<string, unknown>): string;
407
447
  export declare function ssrSelectValues(): void;
408
448
  export declare function resolveSSRSelectValues(html: any): any;
409
449
  export declare function escape(s: any, attr?: boolean): any;
@@ -419,12 +459,17 @@ export declare const RequestContext: unique symbol; /**
419
459
  *
420
460
  * `kind: "render"` — `fallback`: an `<Errored>` rendered its fallback;
421
461
  * `client`: a `<Loading>` fragment rejected and the client re-renders the
422
- * subtree; `failed`: nothing contained it and the request fails;
462
+ * subtree; `failed`: nothing contained it and the request fails — including
463
+ * a synchronous throw out of `renderToString` or `renderToStream`'s first
464
+ * pass, reported before it reaches the caller;
423
465
  * `serialize`: a hydration value would not serialize and the render went on
424
466
  * without it (a render that passed `onError`). `kind: "server-function"` — `thrown`:
425
467
  * the body threw; `channel`: a rejection or throw escaping through the
426
468
  * result graph (a promise, an iterable, a stream) with the head already
427
- * committed. `boundary` is the hydration id the boundary records and
469
+ * committed. `kind: "request"` (always `failed`): a failure that fails the
470
+ * request outside any render or server function the runtime reports — a
471
+ * middleware throw the framework's request handler catches (see
472
+ * `reportRequestFailure`). `boundary` is the hydration id the boundary records and
428
473
  * findings use; `ownerPath` is where the error was THROWN — the component
429
474
  * labels root-first up the owner chain it escaped, when the compiler emitted
430
475
  * them — and `boundaryPath` where it was MET, the same labels up the
@@ -479,6 +524,20 @@ export interface ServerErrorsConfig {
479
524
  * ```
480
525
  */
481
526
  export declare function configureServerErrors(config: ServerErrorsConfig): void;
527
+ /**
528
+ * Reports a failure that fails a request outside any render or server
529
+ * function the runtime reports, such as a throw a framework's request
530
+ * handler catches from its middleware. The ambient server error hook hears
531
+ * it as `{ kind: "request", handling: "failed", event }`, once per error
532
+ * object, and its return is ignored, as for every `handling: "failed"`. A
533
+ * render failure is the render's: a synchronous throw out of
534
+ * `renderToString` or `renderToStream` was already heard as `kind:
535
+ * "render"` before the caller caught it, so reporting it here adds nothing.
536
+ * With no hook registered the failure goes to `console.error`, as a render
537
+ * that fails before its shell does. There is no per-request hook at this
538
+ * layer.
539
+ */
540
+ export declare function reportRequestFailure(error: unknown, event: RequestEvent): void;
482
541
  /**
483
542
  * The current request event, when called on the server inside a request
484
543
  * scope (established by `provideRequestEvent` from `@solidjs/web/storage`
@@ -486,15 +545,67 @@ export declare function configureServerErrors(config: ServerErrorsConfig): void;
486
545
  * Read it above `await` boundaries in partially-polyfilled environments.
487
546
  */
488
547
  export declare function getRequestEvent(): RequestEvent | undefined;
548
+ /** A render's keyed server-to-client value channel (`getHydrationWriter`). */
549
+ export interface HydrationWriter {
550
+ /**
551
+ * Whether the render takes promises and async iterables (`renderToStream`).
552
+ * `renderToString` takes synchronous values only; `write` throws on an
553
+ * async one.
554
+ */
555
+ readonly async: boolean;
556
+ /**
557
+ * Serializes `value` for the client under `key`, readable there with
558
+ * `takeHydrationValue(key)`. Returns `false` without writing when `key` was
559
+ * already written by this render (the first write wins) or the render no
560
+ * longer takes values (a finished `renderToString`, a completed stream).
561
+ * `deferStream` holds the shell until a promise settles. Prefix keys with
562
+ * the library's own namespace (`"sq:"`); Solid's own entries are keyed by
563
+ * hydration id.
564
+ */
565
+ write(key: string, value: unknown, options?: {
566
+ deferStream?: boolean;
567
+ }): boolean;
568
+ }
569
+ /** A keyed value taken from the hydration registry (`takeHydrationValue`). */
570
+ export type HydrationValue<T = unknown> = {
571
+ status: "resolved";
572
+ value: T;
573
+ } | {
574
+ status: "rejected";
575
+ error: unknown;
576
+ } | {
577
+ status: "pending";
578
+ promise: Promise<T>;
579
+ };
580
+ /**
581
+ * The keyed server-to-client value channel of the render the caller belongs
582
+ * to — found through the caller's owner, else (no owner) through the request
583
+ * scope when exactly one render is open for that request. `undefined`
584
+ * outside any render and on the client. Never another request's render.
585
+ *
586
+ * Capture it where the render is known (component setup) to write from IO
587
+ * later. A write is not gated on `<NoHydration>`: read `isHydratable()` where
588
+ * the value is produced to decide. Read the value on the client with
589
+ * `takeHydrationValue(key)`.
590
+ *
591
+ * @example
592
+ * ```ts
593
+ * const writer = getHydrationWriter();
594
+ * if (writer && isHydratable()) writer.write("sq:" + hash, data);
595
+ * ```
596
+ */
597
+ export declare function getHydrationWriter(): HydrationWriter | undefined;
598
+ /** Server stub — the registry is the client's. See the client entry. */
599
+ export declare function takeHydrationValue<T = unknown>(_key: string): HydrationValue<T> | undefined;
489
600
  /**
490
601
  * The trace the current request belongs to — continued from the incoming
491
602
  * W3C `traceparent` when there was one, originated by the runtime
492
603
  * otherwise; in observe/dev builds, merged with the installed provider's
493
604
  * answer (`OBSERVE.server.trace`). Same object for every read within the
494
605
  * request, direct server-function calls included. For a render outside a
495
- * request scope, the render's own trace. `undefined` outside both, and on
496
- * the client. Forward it downstream from a server function with
497
- * `getTraceContext()?.entries.traceparent`.
606
+ * request scope, the render's own trace, read within it (under its owner).
607
+ * `undefined` outside both, and on the client. Forward it downstream from a
608
+ * server function with `getTraceContext()?.entries.traceparent`.
498
609
  */
499
610
  export declare function getTraceContext(): TraceContext | undefined;
500
611
  /** A fresh, uncommitted response head. */
@@ -519,5 +630,7 @@ export declare function composeMiddleware(middlewares: FetchMiddleware[]): (requ
519
630
  export declare function registerElementClaim(handler: (element: Element) => void): () => void;
520
631
  export declare function claimElement<T extends Element>(node: T): T;
521
632
  export declare function claimElementTree<T extends Node>(root: T): T;
633
+ /** Server: `fn()`. No event is dispatched during SSR, so there is no interaction to join. */
634
+ export declare function dispatchAsInteraction<T>(_e: Event, fn: () => T): T;
522
635
  export { notSup as style, notSup as insert, notSup as spread, notSup as delegateEvents, notSup as registerDelegatedRoot, notSup as unregisterDelegatedRoot, notSup as registerDelegatedContainer, notSup as unregisterDelegatedContainer, notSup as getDelegatedRoot, notSup as dynamicProperty, notSup as setAttribute, notSup as setAttributeNS, notSup as addEvent, notSup as render, notSup as template, notSup as setProperty, notSup as className, notSup as assign, notSup as hydrate, notSup as getNextElement, notSup as getNextMatch, notSup as getNextMarker, notSup as runHydrationEvents, notSup as ref, notSup as setStyleProperty, notSup as readShallow, notSup as acquireAsset };
523
636
  declare function notSup(): void;