@solidjs/web 2.0.0-rc.10 → 2.0.0-rc.13
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 +533 -106
- package/dist/server.js +437 -79
- package/dist/server.observe.js +449 -79
- package/dist/web.dev.js +35 -9
- package/dist/web.js +35 -9
- package/dist/web.observe.js +35 -9
- package/frames/dist/client.dev.js +362 -107
- package/frames/dist/client.js +317 -104
- package/frames/dist/client.observe.js +318 -103
- package/frames/dist/server.dev.js +288 -55
- package/frames/dist/server.js +235 -55
- package/frames/dist/server.observe.js +235 -55
- package/package.json +4 -3
- package/server-functions/dist/client.dev.js +79 -11
- package/server-functions/dist/client.observe.js +79 -11
- package/server-functions/dist/server.dev.js +30 -6
- package/server-functions/dist/server.js +30 -6
- package/server-functions/dist/server.observe.js +30 -6
- package/skills/server-components/SKILL.md +206 -0
- package/types/client.d.ts +17 -2
- package/types/frames/client.d.ts +1 -1
- package/types/frames/frame-client.d.ts +0 -18
- package/types/frames/frame-container-plugin.d.ts +0 -8
- package/types/frames/server.d.ts +28 -0
- package/types/frames/tree-rewrite.d.ts +39 -0
- package/types/index.server.d.ts +1 -1
- package/types/jsx.d.ts +11 -1
- package/types/observe.d.ts +178 -10
- package/types/request-error-hook.d.ts +5 -0
- package/types/server-observe.d.ts +8 -0
- package/types/server.d.ts +95 -8
|
@@ -293,15 +293,6 @@ export interface FrameHostOptions {
|
|
|
293
293
|
* identity only.
|
|
294
294
|
*/
|
|
295
295
|
isContainer?(value: unknown): boolean;
|
|
296
|
-
/**
|
|
297
|
-
* Arms event types for behavior claims: the `_bnd` sweep collects the
|
|
298
|
-
* event names it finds and hands them here so delegated dispatch can
|
|
299
|
-
* reach them. Platform glue passes its `delegateEvents` — the option
|
|
300
|
-
* exists (rather than client.js importing the event system) so
|
|
301
|
-
* tree-shaken subsets without events pay nothing. Frames registered
|
|
302
|
-
* with this host inherit it unless they pass their own `delegate`.
|
|
303
|
-
*/
|
|
304
|
-
delegate?(eventNames: Iterable<string>): void;
|
|
305
296
|
}
|
|
306
297
|
/**
|
|
307
298
|
* Options for `createFrame` / `createFrameElement`.
|
|
@@ -313,13 +304,6 @@ export interface FrameOptions {
|
|
|
313
304
|
id?: string;
|
|
314
305
|
/** Client content keyed by prop name (occurrences resolve by prop). */
|
|
315
306
|
slots?: Record<string, Slot>;
|
|
316
|
-
/**
|
|
317
|
-
* Raw client props for behavior-claim resolution: server elements carrying
|
|
318
|
-
* `_bnd="pos=prop"` markers (compiled under the `serverComponents` option)
|
|
319
|
-
* resolve ref/event positions by name through this object — read live at
|
|
320
|
-
* dispatch/materialize time, so compiled prop getters stay latest-value.
|
|
321
|
-
*/
|
|
322
|
-
props?: Record<string, unknown>;
|
|
323
307
|
/**
|
|
324
308
|
* Adopt existing server-rendered DOM: the first apply morphs against it,
|
|
325
309
|
* and slots sync immediately (hydration attach) — a document-SSR boot
|
|
@@ -340,8 +324,6 @@ export interface FrameOptions {
|
|
|
340
324
|
* streamed chunks).
|
|
341
325
|
*/
|
|
342
326
|
ownerScope?<T>(fn: () => T): T;
|
|
343
|
-
/** Per-frame override of the host's `delegate` (see FrameHostOptions). */
|
|
344
|
-
delegate?(eventNames: Iterable<string>): void;
|
|
345
327
|
/**
|
|
346
328
|
* Boundary-driven segment reveal. When present, `#revealSegment` hands the
|
|
347
329
|
* placeholder seam to this hook instead of swapping imperatively: the binding
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The container tier at the slot border: reactive containers (projections)
|
|
3
|
-
* cross serialization boundaries as TRACES — an async iterable whose first
|
|
4
|
-
* yield is a full state snapshot and whose later yields are patch batches —
|
|
5
|
-
* and materialize back into live local containers. Renderer-agnostic glue;
|
|
6
|
-
* the reactive core injects both halves. See frame-container-plugin.js.
|
|
7
|
-
* @experimental
|
|
8
|
-
*/
|
|
9
1
|
/** A container's border serialization: one subscribe() per consumer. */
|
|
10
2
|
export interface ContainerTrace {
|
|
11
3
|
subscribe(): AsyncIterable<any>;
|
package/types/frames/server.d.ts
CHANGED
|
@@ -27,6 +27,34 @@ import type { Element as SolidElement } from "solid-js";
|
|
|
27
27
|
export type Slot<P = {}> = (props: P & {
|
|
28
28
|
$key?: string | number;
|
|
29
29
|
}) => SolidElement;
|
|
30
|
+
/**
|
|
31
|
+
* An attribute slot (principles §9.2.3): the client renders an object instead of
|
|
32
|
+
* markup, and the server template consumes it by reading properties at
|
|
33
|
+
* positions — `const row = props.row({ id, completed });` then
|
|
34
|
+
* `<li class={row.rowClass} hidden={row.removed}><input checked={row.done}
|
|
35
|
+
* onInput={row.toggle} /></li>`. One call is one data context: any element
|
|
36
|
+
* in the template may read from it, and the client owns exactly the values
|
|
37
|
+
* the template read. Keys are the client's names; the position decides what
|
|
38
|
+
* a property IS (attribute, class name, style property, handler, ref).
|
|
39
|
+
*
|
|
40
|
+
* `P` is the args the server passes (reactive props to the fill, as for
|
|
41
|
+
* `Slot`); `J` is the object the fill returns — the same type a shared
|
|
42
|
+
* component takes as a prop when the client renders it directly, so one
|
|
43
|
+
* `TodoRow` serves both sides. `$key` is occurrence identity, as for `Slot`,
|
|
44
|
+
* and optional: within a render, repeated calls with structurally equal
|
|
45
|
+
* args are one occurrence (a call in a component prop is re-evaluated per
|
|
46
|
+
* position the component binds), so the natural spelling needs no key;
|
|
47
|
+
* `$key` is for state inside the fill's scope that must follow the entity
|
|
48
|
+
* across responses. A slot with no args (`P` empty) is called bare —
|
|
49
|
+
* `const filters = props.filters();` — and is one occurrence named by the
|
|
50
|
+
* prop.
|
|
51
|
+
* @experimental
|
|
52
|
+
*/
|
|
53
|
+
export type AttributeSlot<P = {}, J extends object = Record<string, unknown>> = {} extends P ? (props?: P & {
|
|
54
|
+
$key?: string | number;
|
|
55
|
+
}) => J : (props: P & {
|
|
56
|
+
$key?: string | number;
|
|
57
|
+
}) => J;
|
|
30
58
|
/**
|
|
31
59
|
* Types an async value crossing the slot border (DR-2, value tier). What you
|
|
32
60
|
* pass is what ships — the promise / async iterable itself rides the data
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy-on-write rewrite of a value tree, for the serialization-border walks
|
|
3
|
+
* (`toBorderForm` — every document-face serialization and every slot-arg
|
|
4
|
+
* record — and the slot-arg stand-in scrub). `visit(value, path)` is asked
|
|
5
|
+
* at every OBJECT node first (primitives pass through unasked: no visitor
|
|
6
|
+
* replaces one, and leaves are most of a payload) and answers with the
|
|
7
|
+
* node's replacement, or `DESCEND` to walk the node's leaves — which
|
|
8
|
+
* happens for a plain array or plain object only; anything else (a class
|
|
9
|
+
* instance, a `Map`, a proxy) is the app's and passes through untouched.
|
|
10
|
+
*
|
|
11
|
+
* Author values are never mutated. The walk is plain recursion, copy-on-
|
|
12
|
+
* write: an untouched subtree passes by reference, a changed one is copied
|
|
13
|
+
* along the path to the root. That is the whole cost for acyclic data of
|
|
14
|
+
* ordinary depth (measured below what `next`'s direct recursion paid, the
|
|
15
|
+
* primitive short-circuit buying more than the visitor call costs).
|
|
16
|
+
*
|
|
17
|
+
* A back-reference to an ancestor has no copy-on-write answer (the copy's
|
|
18
|
+
* back-reference would point at the original, unrewritten), and tracking
|
|
19
|
+
* ancestors at every node would tax every walk. So ancestors are tracked
|
|
20
|
+
* only from a depth ordinary payloads never reach (`TRACK`): a cycle is
|
|
21
|
+
* caught within one cycle-length past it, the pass aborts and the tree is
|
|
22
|
+
* rewritten again as a memoized clone — one copy per container, a back-
|
|
23
|
+
* reference resolving to the ancestor's copy. Only cyclic (or unusually
|
|
24
|
+
* deep) values pay. Replacements are recorded as they are produced (a trace
|
|
25
|
+
* envelope, a multicast seat, a scrubbed stand-in): a node seen again on
|
|
26
|
+
* the first pass — a cycle revisits its nodes on every level down to the
|
|
27
|
+
* catch — and every node of the clone pass answer from the record, so a
|
|
28
|
+
* visitor's side effects run once per node whichever way the walk went.
|
|
29
|
+
* Walks that replace nothing never pay the lookup. A value reachable at two
|
|
30
|
+
* paths is one node: its replacement is shared (one seat for one iterable —
|
|
31
|
+
* the identity the input had, which the serializer writes once and the
|
|
32
|
+
* client materializes once), and a shared subtree with nothing to replace
|
|
33
|
+
* is visited at each occurrence on the first pass and once on the clone
|
|
34
|
+
* pass. `path` is built (`.key`, `[i]`) only when `withPath`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const DESCEND: unique symbol;
|
|
37
|
+
type Visit = (value: object, path: string | undefined) => any;
|
|
38
|
+
export declare function rewriteTree(value: any, visit: Visit, withPath: boolean): any;
|
|
39
|
+
export {};
|
package/types/index.server.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type Component } from "solid-js";
|
|
|
2
2
|
import type { JSX } from "./jsx.js";
|
|
3
3
|
export * from "./server.js";
|
|
4
4
|
export * from "./response.js";
|
|
5
|
-
export type { CallEvent, CallListener, CallLive, FrameAppliedEvent, FrameEvent, FrameListener, FrameLive, FrameProducedEvent, InvocationEvent, InvocationListener, InvocationLive, RenderEvent, RenderListener, RenderLive } from "./observe.js";
|
|
5
|
+
export type { CallEvent, CallListener, CallLive, CallRequestEvent, CallRequestListener, FrameAppliedEvent, FrameEvent, FrameListener, FrameLive, FrameProducedEvent, InvocationEvent, InvocationListener, InvocationLive, RenderEvent, RenderListener, RenderLive, RenderRoute } from "./observe.js";
|
|
6
6
|
export type { TraceContext, TraceProvider } from "./trace.js";
|
|
7
7
|
export type { JSX } from "./jsx.js";
|
|
8
8
|
export { For, Show, Loading, Reveal, Switch, Match, Repeat, Errored, NoHydration, Hydration } from "solid-js";
|
package/types/jsx.d.ts
CHANGED
|
@@ -231,7 +231,7 @@ export namespace JSX {
|
|
|
231
231
|
| boolean
|
|
232
232
|
| null
|
|
233
233
|
| undefined
|
|
234
|
-
| Record<string, boolean>
|
|
234
|
+
| Record<string, boolean | undefined>
|
|
235
235
|
| ClassValue[];
|
|
236
236
|
|
|
237
237
|
const SERIALIZABLE: unique symbol;
|
|
@@ -250,6 +250,16 @@ export namespace JSX {
|
|
|
250
250
|
ref?: Ref<T>;
|
|
251
251
|
children?: Element | undefined;
|
|
252
252
|
$ServerOnly?: boolean | undefined;
|
|
253
|
+
/**
|
|
254
|
+
* Entity identity for server markup: the frame morph matches keyed
|
|
255
|
+
* elements across responses by it, so client state attached to the
|
|
256
|
+
* element (an attribute slot's bound positions, focus) follows the entity
|
|
257
|
+
* through reorders and refetches. SSR compiles it to the `_key`
|
|
258
|
+
* attribute; a DOM compile strips it. On a component, `$key` is slot
|
|
259
|
+
* occurrence identity across responses (optional; a repeated call is
|
|
260
|
+
* one occurrence per render with or without it).
|
|
261
|
+
*/
|
|
262
|
+
$key?: string | number | undefined;
|
|
253
263
|
}
|
|
254
264
|
interface ExplicitProperties {}
|
|
255
265
|
type PropAttributes = {
|
package/types/observe.d.ts
CHANGED
|
@@ -110,6 +110,28 @@ export interface RenderEvent {
|
|
|
110
110
|
* threw, a stream's uncontained failure wound it down through `onError`.
|
|
111
111
|
*/
|
|
112
112
|
outcome: "complete" | "abandoned" | "error";
|
|
113
|
+
/**
|
|
114
|
+
* The route the render resolved to, as the router declared it while
|
|
115
|
+
* building its context under this render (`OBSERVE.attribution.withOrigin`
|
|
116
|
+
* with an `initial` ref — the same declaration the client's first
|
|
117
|
+
* `"navigation"` record comes from): `name` the matched pattern
|
|
118
|
+
* (`/users/:id`), `to` the concrete path, `params` what the pattern
|
|
119
|
+
* bound. Read from the router's ref when the render settles, so a match
|
|
120
|
+
* refined during the render is what lands. Absent when no router declared
|
|
121
|
+
* one — a render without a router, or a router that does not yet. What a
|
|
122
|
+
* consumer names the request by (`http.route`), where the URL would
|
|
123
|
+
* scatter one page across as many names as it has parameters.
|
|
124
|
+
*/
|
|
125
|
+
route?: RenderRoute;
|
|
126
|
+
}
|
|
127
|
+
/** `RenderEvent.route` — the route a render resolved to, as the router matched it. */
|
|
128
|
+
export interface RenderRoute {
|
|
129
|
+
/** The matched route pattern — `/users/:id`. */
|
|
130
|
+
name?: string;
|
|
131
|
+
/** The concrete path. */
|
|
132
|
+
to?: string;
|
|
133
|
+
/** The params the pattern bound (optional params unbound: `undefined`). */
|
|
134
|
+
params?: Readonly<Record<string, string | undefined>>;
|
|
113
135
|
}
|
|
114
136
|
/** The live half of a render record. */
|
|
115
137
|
export interface RenderLive {
|
|
@@ -131,6 +153,15 @@ export type RenderListener = (event: RenderEvent, live: RenderLive) => void;
|
|
|
131
153
|
export interface CallEvent {
|
|
132
154
|
/** The function id — the same `id` the server's `"invocation"` record carries. */
|
|
133
155
|
id: string;
|
|
156
|
+
/**
|
|
157
|
+
* The function's source name, from the reference's metadata
|
|
158
|
+
* (`ServerFunctionMetadata.name`): the compiled function's name, which
|
|
159
|
+
* the compiler seeds in development builds only, or an explicit label
|
|
160
|
+
* (`withMeta`, the `name` argument to `createServerReference`), which
|
|
161
|
+
* survives to production. A label, not an identity: not unique, and
|
|
162
|
+
* absent when the metadata carries none.
|
|
163
|
+
*/
|
|
164
|
+
name?: string;
|
|
134
165
|
/** `performance.now()` when the call was made. */
|
|
135
166
|
at: number;
|
|
136
167
|
/**
|
|
@@ -169,14 +200,78 @@ export interface CallEvent {
|
|
|
169
200
|
deferred?: true;
|
|
170
201
|
}
|
|
171
202
|
/**
|
|
172
|
-
* The live half of a call, for in-process consumers
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
203
|
+
* The live half of a call, for in-process consumers — ONE object across
|
|
204
|
+
* the call's records: the same `CallLive` is handed to the `"request"`
|
|
205
|
+
* listener at the send and to the `"call"` listener at settle, filled in
|
|
206
|
+
* as the call proceeds (`args` from the start, `request` at the send,
|
|
207
|
+
* `response` and `result`/`error` at settle — filled on every settle,
|
|
208
|
+
* whether or not a `"call"` record goes out, so a `"request"` listener
|
|
209
|
+
* holding it reads the outcome off it too), so an in-process consumer
|
|
210
|
+
* joins a call's request to its settle by identity — the way `origin`
|
|
211
|
+
* joins a record to the interaction's — with no id-plus-time join and no
|
|
212
|
+
* sequence number. One MUTABLE object shared by both records' listeners:
|
|
213
|
+
* treat it as read-only — a write shows up on the other record's
|
|
214
|
+
* listener. `error` is the value as thrown to the caller — a
|
|
215
|
+
* decoded server error, or the transport's own failure. The bodies —
|
|
216
|
+
* `request`, and `response` as an unread clone — are a body viewer's
|
|
217
|
+
* (devtools' network panel), and are taken only while a listener asked for
|
|
218
|
+
* them (`OBSERVE.records.subscribe("call", fn, { bodies: true })`, or the
|
|
219
|
+
* same on `"request"` for the request alone): each costs the call a
|
|
220
|
+
* reconstruction and a transient double-buffer of the payload, which a
|
|
221
|
+
* consumer that reads ids, statuses and timings never pays. With no such
|
|
222
|
+
* listener `request` is absent and `response` is the transport's own
|
|
223
|
+
* object, consumed by its decode. Whether bodies are taken is read once,
|
|
224
|
+
* as the call starts.
|
|
177
225
|
*/
|
|
178
226
|
export interface CallLive {
|
|
179
227
|
args: unknown[];
|
|
228
|
+
/**
|
|
229
|
+
* Bodies opted in — by a `"call"` listener or a `"request"` listener
|
|
230
|
+
* (`observed("call", "bodies") || observed("request", "bodies")`): the
|
|
231
|
+
* request as dispatched — the final url and `RequestInit` (the
|
|
232
|
+
* transport's headers, the `prepareRequest` hook applied), built into a
|
|
233
|
+
* `Request` of the listener's own at the send, so its headers and body
|
|
234
|
+
* are readable in full and reading them touches nothing the transport
|
|
235
|
+
* sent. Set before the `"request"` record is delivered, so that listener
|
|
236
|
+
* reads it too — and it is ONE `Request`, shared by the call's
|
|
237
|
+
* `"request"` and `"call"` records: a body reads once, so a listener that
|
|
238
|
+
* wants it reads through `request.clone()` (`live.request.clone().text()`)
|
|
239
|
+
* and the other record's listener can still read it; a direct
|
|
240
|
+
* `live.request.text()` leaves `bodyUsed` true for whoever reads next.
|
|
241
|
+
* Built WITH the body only when the body has a shape a
|
|
242
|
+
* second `Request` can hold without a competing consumer — `string`,
|
|
243
|
+
* `URLSearchParams`, `FormData`, `Blob`, `ArrayBuffer` or a view of one
|
|
244
|
+
* — and WITHOUT it otherwise (a `ReadableStream` or an async iterable,
|
|
245
|
+
* the transport's streaming-upload contract: reconstructing one would
|
|
246
|
+
* consume it ahead of the send), so the request then reads as bodyless.
|
|
247
|
+
* Absent without the opt-in; when the call failed before the request was
|
|
248
|
+
* built (argument serialization threw); when the address is relative and
|
|
249
|
+
* there is no `location` to resolve it against (absent beats a URL that
|
|
250
|
+
* was never sent); and when the reconstruction itself failed (an init
|
|
251
|
+
* the `Request` constructor rejects but the configured `fetch`
|
|
252
|
+
* tolerates) — a reconstruction never fails the call.
|
|
253
|
+
*/
|
|
254
|
+
request?: Request;
|
|
255
|
+
/**
|
|
256
|
+
* The response: with bodies opted in, one with an UNREAD body — a
|
|
257
|
+
* `clone()` taken as the response arrived, before the transport's
|
|
258
|
+
* decode, so the listener reads status, headers and body while the
|
|
259
|
+
* caller still gets its result from the original. The transport's own
|
|
260
|
+
* object instead — status and headers readable, body consumed by the
|
|
261
|
+
* transport's decode — without the opt-in, and, with it, for a response
|
|
262
|
+
* whose clone would be a branch nobody drains: an event-stream response
|
|
263
|
+
* (a `live()` source, `text/event-stream`, a connection open for the
|
|
264
|
+
* page's life), a deferred result (a generator's stream, `deferred:
|
|
265
|
+
* true`, served for the stream's life — its clone, taken before the
|
|
266
|
+
* result's shape was known, is cancelled at settle), and a response the
|
|
267
|
+
* `clone()` refused (one a configured `fetch` handed over already read).
|
|
268
|
+
* A response a `responseHandler` claimed whose result is not a deferred
|
|
269
|
+
* body — a non-live `application/x-frame-stream` frame render the frames
|
|
270
|
+
* transport claims, say — keeps its clone, so under the opt-in the
|
|
271
|
+
* clone's branch buffers that render until the listener reads it or
|
|
272
|
+
* drops the record; live frames are `text/event-stream` and are never
|
|
273
|
+
* cloned. Absent when the fetch itself rejected.
|
|
274
|
+
*/
|
|
180
275
|
response?: Response;
|
|
181
276
|
/** The settled value, when `outcome` is `"ok"`. */
|
|
182
277
|
result?: unknown;
|
|
@@ -184,6 +279,63 @@ export interface CallLive {
|
|
|
184
279
|
error?: unknown;
|
|
185
280
|
}
|
|
186
281
|
export type CallListener = (event: CallEvent, live: CallLive) => void;
|
|
282
|
+
/**
|
|
283
|
+
* One server-function request LEFT the browser — delivered on
|
|
284
|
+
* `OBSERVE.records.subscribe("request", …)` at the send: after the
|
|
285
|
+
* arguments were serialized and `prepareRequest` had its say, immediately
|
|
286
|
+
* before the transport's `fetch` is handed the request. "Left" means
|
|
287
|
+
* HANDED TO `fetch`, not that it reached the network: a `fetch` that
|
|
288
|
+
* throws synchronously still has its `"request"` (and a `"call"` with
|
|
289
|
+
* `outcome: "error"`). The `"call"` record of the same call follows at
|
|
290
|
+
* settle; this one exists because that one cannot show a call that is
|
|
291
|
+
* still in flight, or one that never settles (a hung fetch) — a network
|
|
292
|
+
* panel's pending row. The two records share their `CallLive` by identity
|
|
293
|
+
* (see `CallLive`): the object handed here is the object handed to the
|
|
294
|
+
* `"call"` listener, so an in-process consumer joins them with no
|
|
295
|
+
* id-plus-time join and no sequence number.
|
|
296
|
+
*
|
|
297
|
+
* Emitted only for a request that was handed over: a call that failed
|
|
298
|
+
* before its request was built (argument serialization threw, or
|
|
299
|
+
* `prepareRequest` did) emits no `"request"` — only its `"call"` settle; a
|
|
300
|
+
* call an integration answered locally (a handler's `intercept`) made no
|
|
301
|
+
* request and emits neither. A deferred or streaming result emits
|
|
302
|
+
* `"request"` at the send and `"call"` at handoff, as today. Serializable;
|
|
303
|
+
* `live.request` (under `bodies`) rides beside it.
|
|
304
|
+
*
|
|
305
|
+
* Listeners run synchronously, on the call's path, BEFORE the send: a slow
|
|
306
|
+
* listener delays the fetch and the time it spends is inside the call's
|
|
307
|
+
* `durationMs`. Read what is needed and hand the work off to a microtask
|
|
308
|
+
* (the same guidance the engine's records give).
|
|
309
|
+
*/
|
|
310
|
+
export interface CallRequestEvent {
|
|
311
|
+
/**
|
|
312
|
+
* Which end recorded it. Only `"client"` exists today — the request left
|
|
313
|
+
* the browser. The server half (the request arrived, ahead of its
|
|
314
|
+
* `"invocation"`) is `"server"`, additive later, the way the `"frame"`
|
|
315
|
+
* record has two halves.
|
|
316
|
+
*/
|
|
317
|
+
side: "client";
|
|
318
|
+
/** The function id — the same `id` the call's `"call"` and the server's `"invocation"` carry. */
|
|
319
|
+
id: string;
|
|
320
|
+
/** The function's source name, by the same rule as `CallEvent.name`. */
|
|
321
|
+
name?: string;
|
|
322
|
+
/**
|
|
323
|
+
* `performance.now()` at the send — when the request was handed to
|
|
324
|
+
* `fetch`, after serialization and `prepareRequest`. NOT the call's
|
|
325
|
+
* `CallEvent.at`, which is when the call was made: the gap between them
|
|
326
|
+
* is what building the request cost (an async `prepareRequest`
|
|
327
|
+
* included), and `CallEvent.at + durationMs` is never before this.
|
|
328
|
+
*/
|
|
329
|
+
at: number;
|
|
330
|
+
/** `GET` for a GET-encoded read (`GET(fn)`), `POST` otherwise — as on `CallEvent`. */
|
|
331
|
+
method: "GET" | "POST";
|
|
332
|
+
/**
|
|
333
|
+
* What the call ran for — the same object `CallEvent.origin` carries,
|
|
334
|
+
* read at dispatch (see `CallEvent.origin` for the rule).
|
|
335
|
+
*/
|
|
336
|
+
origin?: ChangeOrigin;
|
|
337
|
+
}
|
|
338
|
+
export type CallRequestListener = (event: CallRequestEvent, live: CallLive) => void;
|
|
187
339
|
interface FrameEventBase {
|
|
188
340
|
/**
|
|
189
341
|
* The frame id on the wire: the server function's id when the stream is a
|
|
@@ -299,6 +451,15 @@ declare module "solid-js" {
|
|
|
299
451
|
event: CallEvent;
|
|
300
452
|
live: CallLive;
|
|
301
453
|
};
|
|
454
|
+
/**
|
|
455
|
+
* Server-function requests left, from the client — see
|
|
456
|
+
* `CallRequestEvent`; the `live` is the call's own, shared with its
|
|
457
|
+
* `"call"` record.
|
|
458
|
+
*/
|
|
459
|
+
request: {
|
|
460
|
+
event: CallRequestEvent;
|
|
461
|
+
live: CallLive;
|
|
462
|
+
};
|
|
302
463
|
/** Frame streams, produced or applied — see `FrameEvent`. */
|
|
303
464
|
frame: {
|
|
304
465
|
event: FrameEvent;
|
|
@@ -316,6 +477,12 @@ export declare function isDeferredBody(value: unknown): boolean;
|
|
|
316
477
|
export declare function frameCensus(event: FrameEventBase, type: string, own: boolean): void;
|
|
317
478
|
/** What the client runtime hands a call observation as the call proceeds. */
|
|
318
479
|
export interface CallObservation {
|
|
480
|
+
/**
|
|
481
|
+
* The request is about to be sent: the address and the final
|
|
482
|
+
* `RequestInit` — what the transport's `fetch` receives, hook applied.
|
|
483
|
+
* The `"request"` record is delivered from here.
|
|
484
|
+
*/
|
|
485
|
+
request(url: string, init: RequestInit): void;
|
|
319
486
|
/** The response arrived (before decode); its status goes on the record. */
|
|
320
487
|
response(response: Response): void;
|
|
321
488
|
/** The call settled as the caller sees it: the value returned, or the error thrown. */
|
|
@@ -323,12 +490,13 @@ export interface CallObservation {
|
|
|
323
490
|
}
|
|
324
491
|
/**
|
|
325
492
|
* Opens the observation of one server-function call from the client, as
|
|
326
|
-
* the request is about to be built; the runtime reports the
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
493
|
+
* the request is about to be built; the runtime reports the request as it
|
|
494
|
+
* is sent (the `"request"` record), the response when it arrives and the
|
|
495
|
+
* settle when the caller gets its answer (the `"call"` record). `undefined`
|
|
496
|
+
* with no listener for either record or outside observe builds — the
|
|
497
|
+
* runtime then does nothing extra, not even read the clock.
|
|
330
498
|
*/
|
|
331
|
-
export declare function observeCall(id: string, method: "GET" | "POST", args: unknown[]): CallObservation | undefined;
|
|
499
|
+
export declare function observeCall(id: string, method: "GET" | "POST", args: unknown[], name?: string): CallObservation | undefined;
|
|
332
500
|
/** What the client's stream reader hands a frame observation. */
|
|
333
501
|
export interface FrameApplyObservation {
|
|
334
502
|
/**
|
|
@@ -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;
|
|
@@ -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 {
|
|
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";
|
|
@@ -394,16 +394,51 @@ export declare function ssrStyle(value: string | {
|
|
|
394
394
|
[k: string]: string;
|
|
395
395
|
}): string;
|
|
396
396
|
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)): {
|
|
397
|
+
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
398
|
t: string;
|
|
399
399
|
};
|
|
400
400
|
export declare function ssrElementAttribute(key: string, value: any): string;
|
|
401
401
|
export declare function ssrAttribute(key: string, value: any): string;
|
|
402
402
|
export declare function ssrHydrationKey(): string;
|
|
403
|
-
export declare const CLAIM_PROP: unique symbol;
|
|
404
403
|
export declare const CLAIMS_STREAM = 1;
|
|
405
404
|
export declare const CLAIMS_DOCUMENT = 2;
|
|
406
|
-
|
|
405
|
+
/** The brand on an attribute slot's stand-in for one property read. */
|
|
406
|
+
export declare const SLOT_VALUE: unique symbol;
|
|
407
|
+
/** Marker attribute prefix on a consuming element (`_s:class`, `_s:on:click`, `_s:ref`). */
|
|
408
|
+
export declare const SLOT_MARKER = "_s:";
|
|
409
|
+
/** Faces a stand-in can come from (`slotValue`'s `face`). */
|
|
410
|
+
export declare const SLOT_FACE_STREAM = 0;
|
|
411
|
+
export declare const SLOT_FACE_DATA = 1;
|
|
412
|
+
export declare const SLOT_FACE_MARKUP = 2;
|
|
413
|
+
export declare function isSlotValue(value: unknown): boolean;
|
|
414
|
+
/**
|
|
415
|
+
* An attribute slot's stand-in for one property read. `face` says what the
|
|
416
|
+
* occurrence's fill produced where this read happens: nothing (the stream
|
|
417
|
+
* face never runs fills), a data object (the document face — `value` is
|
|
418
|
+
* the t=0 value of `key`), or markup (the document face ran the fill and
|
|
419
|
+
* it returned content — a read off it is a dev finding at the position).
|
|
420
|
+
* The server has no value to compute with — on the stream face none at
|
|
421
|
+
* all, on the document face only the t=0 one — so the ONLY thing a stand-in
|
|
422
|
+
* can be is the whole value at one position. Every coercion the runtime can
|
|
423
|
+
* see (a template literal, `+`, a comparison, an explicit `String()`) is a
|
|
424
|
+
* dev finding, and it renders NOTHING on either face: the document face
|
|
425
|
+
* never shows a t=0 value the stream face cannot reproduce, so a misuse is
|
|
426
|
+
* visible on the first render rather than on the first refetch. Truthiness
|
|
427
|
+
* (`if (row.done)`, `row.x && …`) has no hook and is the one misuse only
|
|
428
|
+
* the rule can catch — a stand-in is an object and always truthy.
|
|
429
|
+
* @internal Created by the slot proxies (frames server).
|
|
430
|
+
*/
|
|
431
|
+
export declare function slotValue(occurrence: string, key: string, value: unknown, face: number): object;
|
|
432
|
+
/**
|
|
433
|
+
* The compiled per-element hole for ref/on* positions on a server
|
|
434
|
+
* intrinsic (behind the `serverComponents` compiler option):
|
|
435
|
+
* `ctx.claims ? ssrClaim({ click: expr, ref: expr2 }) : ""`. The compiler
|
|
436
|
+
* drops handler and ref expressions from plain SSR output, so this is
|
|
437
|
+
* where a stand-in at one of those positions is seen. A server-local
|
|
438
|
+
* function there can never run (the server has no client to run it on);
|
|
439
|
+
* dev says so, inside the component barrier only.
|
|
440
|
+
*/
|
|
441
|
+
export declare function ssrClaim(map: Record<string, unknown>): string;
|
|
407
442
|
export declare function ssrSelectValues(): void;
|
|
408
443
|
export declare function resolveSSRSelectValues(html: any): any;
|
|
409
444
|
export declare function escape(s: any, attr?: boolean): any;
|
|
@@ -486,15 +521,67 @@ export declare function configureServerErrors(config: ServerErrorsConfig): void;
|
|
|
486
521
|
* Read it above `await` boundaries in partially-polyfilled environments.
|
|
487
522
|
*/
|
|
488
523
|
export declare function getRequestEvent(): RequestEvent | undefined;
|
|
524
|
+
/** A render's keyed server-to-client value channel (`getHydrationWriter`). */
|
|
525
|
+
export interface HydrationWriter {
|
|
526
|
+
/**
|
|
527
|
+
* Whether the render takes promises and async iterables (`renderToStream`).
|
|
528
|
+
* `renderToString` takes synchronous values only; `write` throws on an
|
|
529
|
+
* async one.
|
|
530
|
+
*/
|
|
531
|
+
readonly async: boolean;
|
|
532
|
+
/**
|
|
533
|
+
* Serializes `value` for the client under `key`, readable there with
|
|
534
|
+
* `takeHydrationValue(key)`. Returns `false` without writing when `key` was
|
|
535
|
+
* already written by this render (the first write wins) or the render no
|
|
536
|
+
* longer takes values (a finished `renderToString`, a completed stream).
|
|
537
|
+
* `deferStream` holds the shell until a promise settles. Prefix keys with
|
|
538
|
+
* the library's own namespace (`"sq:"`); Solid's own entries are keyed by
|
|
539
|
+
* hydration id.
|
|
540
|
+
*/
|
|
541
|
+
write(key: string, value: unknown, options?: {
|
|
542
|
+
deferStream?: boolean;
|
|
543
|
+
}): boolean;
|
|
544
|
+
}
|
|
545
|
+
/** A keyed value taken from the hydration registry (`takeHydrationValue`). */
|
|
546
|
+
export type HydrationValue<T = unknown> = {
|
|
547
|
+
status: "resolved";
|
|
548
|
+
value: T;
|
|
549
|
+
} | {
|
|
550
|
+
status: "rejected";
|
|
551
|
+
error: unknown;
|
|
552
|
+
} | {
|
|
553
|
+
status: "pending";
|
|
554
|
+
promise: Promise<T>;
|
|
555
|
+
};
|
|
556
|
+
/**
|
|
557
|
+
* The keyed server-to-client value channel of the render the caller belongs
|
|
558
|
+
* to — found through the caller's owner, else (no owner) through the request
|
|
559
|
+
* scope when exactly one render is open for that request. `undefined`
|
|
560
|
+
* outside any render and on the client. Never another request's render.
|
|
561
|
+
*
|
|
562
|
+
* Capture it where the render is known (component setup) to write from IO
|
|
563
|
+
* later. A write is not gated on `<NoHydration>`: read `isHydratable()` where
|
|
564
|
+
* the value is produced to decide. Read the value on the client with
|
|
565
|
+
* `takeHydrationValue(key)`.
|
|
566
|
+
*
|
|
567
|
+
* @example
|
|
568
|
+
* ```ts
|
|
569
|
+
* const writer = getHydrationWriter();
|
|
570
|
+
* if (writer && isHydratable()) writer.write("sq:" + hash, data);
|
|
571
|
+
* ```
|
|
572
|
+
*/
|
|
573
|
+
export declare function getHydrationWriter(): HydrationWriter | undefined;
|
|
574
|
+
/** Server stub — the registry is the client's. See the client entry. */
|
|
575
|
+
export declare function takeHydrationValue<T = unknown>(_key: string): HydrationValue<T> | undefined;
|
|
489
576
|
/**
|
|
490
577
|
* The trace the current request belongs to — continued from the incoming
|
|
491
578
|
* W3C `traceparent` when there was one, originated by the runtime
|
|
492
579
|
* otherwise; in observe/dev builds, merged with the installed provider's
|
|
493
580
|
* answer (`OBSERVE.server.trace`). Same object for every read within the
|
|
494
581
|
* request, direct server-function calls included. For a render outside a
|
|
495
|
-
* request scope, the render's own trace
|
|
496
|
-
* the client. Forward it downstream from a
|
|
497
|
-
* `getTraceContext()?.entries.traceparent`.
|
|
582
|
+
* request scope, the render's own trace, read within it (under its owner).
|
|
583
|
+
* `undefined` outside both, and on the client. Forward it downstream from a
|
|
584
|
+
* server function with `getTraceContext()?.entries.traceparent`.
|
|
498
585
|
*/
|
|
499
586
|
export declare function getTraceContext(): TraceContext | undefined;
|
|
500
587
|
/** A fresh, uncommitted response head. */
|