@solidjs/web 2.0.0-rc.13 → 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 (57) hide show
  1. package/dist/server.dev.js +200 -73
  2. package/dist/server.js +182 -59
  3. package/dist/server.observe.js +183 -60
  4. package/dist/web.dev.js +70 -35
  5. package/dist/web.js +43 -31
  6. package/dist/web.observe.js +43 -33
  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 +605 -1086
  11. package/frames/dist/client.js +572 -1066
  12. package/frames/dist/client.observe.js +571 -1066
  13. package/frames/dist/regions.js +130 -0
  14. package/frames/dist/server.dev.js +339 -177
  15. package/frames/dist/server.js +335 -173
  16. package/frames/dist/server.observe.js +335 -173
  17. package/frames/dist/trace.js +42 -0
  18. package/frames/dist/wire.js +133 -0
  19. package/package.json +28 -2
  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 +99 -61
  27. package/server-functions/dist/client.js +99 -61
  28. package/server-functions/dist/client.observe.js +99 -61
  29. package/server-functions/dist/server.dev.js +87 -50
  30. package/server-functions/dist/server.js +87 -50
  31. package/server-functions/dist/server.observe.js +87 -50
  32. package/skills/server-components/SKILL.md +65 -43
  33. package/types/client.d.ts +20 -0
  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 -78
  40. package/types/frames/frame-container-plugin.d.ts +2 -2
  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 +32 -8
  46. package/types/frames/trace-tier.d.ts +2 -0
  47. package/types/frames/wire-tier.d.ts +116 -0
  48. package/types/index.d.ts +38 -0
  49. package/types/index.server.d.ts +9 -0
  50. package/types/jsx.d.ts +1 -1
  51. package/types/observe.d.ts +4 -2
  52. package/types/serializer-decode.d.ts +24 -2
  53. package/types/server-functions/client.d.ts +26 -0
  54. package/types/server-functions/registry.d.ts +4 -1
  55. package/types/server-functions/shared.d.ts +12 -8
  56. package/types/server-mock.d.ts +13 -1
  57. package/types/server.d.ts +34 -8
@@ -54,12 +54,6 @@ export interface ServerComponentHandlerOptions<C = unknown> {
54
54
  * to that address's store. Multi-mount fans out per site.
55
55
  */
56
56
  component(fnId: string): C;
57
- /**
58
- * A new response is about to stream into an address: rotate
59
- * response-scoped state (codec data tables) here. `version` is the
60
- * client-owned stream counter the chunks will be stamped with.
61
- */
62
- onStream?(address: string, version: number, response: Response): void;
63
57
  /**
64
58
  * Answer a call before any request is made (t = 0 local answers — a
65
59
  * boundary the document already carries). Returning `undefined` is a
@@ -82,6 +76,19 @@ export interface ServerComponentHandlerOptions<C = unknown> {
82
76
  * value.
83
77
  */
84
78
  export declare const FRAME_STREAM_HEADER = "X-Frame-Stream";
79
+ /**
80
+ * The tiers a frame stream needs (frames savings pass §2, the
81
+ * server-announced tier mechanism): the names, comma-separated, of the
82
+ * frames-client tiers the render had minted when the response head left
83
+ * — `bind,regions,assets,trace,wire` — so the client starts their loads
84
+ * before it reads the body. Omitted when nothing was minted. A tier first
85
+ * needed after the head rides in-band instead: `tiers` on the next chunk
86
+ * (`FrameChunk.tiers`). Additive wire: an old client ignores both; a new
87
+ * client without them falls back to detection at the readiness check and
88
+ * holds (frames-rulings 3.1) — the same DOM, later.
89
+ * @experimental
90
+ */
91
+ export declare const FRAME_TIERS_HEADER = "X-Frame-Tiers";
85
92
  /**
86
93
  * The resume request's have-list (RFC 11 §9.5, Resume request): the
87
94
  * digests the client holds for the address it is reconnecting — the root
@@ -98,13 +105,6 @@ export declare const FRAME_STREAM_HEADER = "X-Frame-Stream";
98
105
  export declare const FRAME_HAVE_HEADER = "X-Frame-Have";
99
106
  /** The have-list's size ceiling in encoded bytes (see FRAME_HAVE_HEADER). */
100
107
  export declare const FRAME_HAVE_BUDGET = 4096;
101
- /**
102
- * Encodes a have-list for the header: `key=digest` pairs, comma-joined
103
- * (keys never contain either separator; the root's key is empty).
104
- * `undefined` when the list is empty or over budget.
105
- * @internal
106
- */
107
- export declare function encodeHaveList(have: Record<string, string>): string | undefined;
108
108
  /**
109
109
  * Decodes a have-list header value; `undefined` for an absent/empty one.
110
110
  * Tolerant of malformed entries (skipped) — a wrong entry costs one
@@ -133,6 +133,41 @@ export declare const SERVER_COMPONENT_ADDRESS: unique symbol;
133
133
  * `Symbol.for`, so consumers honor it without importing this module.
134
134
  */
135
135
  export declare const COMPONENT_BINDING: unique symbol;
136
+ /**
137
+ * The address a content token belongs to; a plain address passes through.
138
+ * @internal
139
+ */
140
+ export declare function contentAddress(token: string): string;
141
+ /**
142
+ * The live handler's staged content (see `createServerComponentHandler`),
143
+ * by token; a plain address, or a token already committed or superseded,
144
+ * is a no-op. Mounts call both halves from the render effect that follows
145
+ * their address accessor: `preview` from its compute half — under the
146
+ * transaction that delivered the token, so the slot args it pushes into the
147
+ * live fills (see `FrameHost.preview`) are staged with it and a fill's
148
+ * derivation over an arg re-derives in that pass, never one flush behind
149
+ * the intent it held (principles §9.2.2) — and `commit` from its effect
150
+ * half, landing the buffered response as the store's writes in the commit.
151
+ * Installed by the handler (one active handler at a time, as for
152
+ * `resolveServerComponent` below).
153
+ * @internal
154
+ */
155
+ export declare const stagedContent: {
156
+ preview(token: string): void;
157
+ commit(token: string): void;
158
+ };
159
+ /**
160
+ * The call recorded for an address — `{ id, meta, args, retry }`, `retry`
161
+ * the thunk that makes the same call again — or `undefined` for an address
162
+ * no response or document answer named.
163
+ * @internal
164
+ */
165
+ export declare function callFor(address: string): {
166
+ id: string;
167
+ meta: unknown;
168
+ args: unknown[];
169
+ retry(): Promise<unknown>;
170
+ } | undefined;
136
171
  export declare function setServerComponentBootstrap(resolve: (ctx: unknown) => string): void;
137
172
  /**
138
173
  * Seroval plugin for a server component crossing a serialization boundary.
@@ -183,24 +218,39 @@ export declare const ServerComponentPlugin: {
183
218
  */
184
219
  export declare function flightCodec(codec?: JSONCodecOptions): JSONCodecOptions;
185
220
  export declare function createServerComponentHandler<C>(options: ServerComponentHandlerOptions<C>): {
221
+ /**
222
+ * `retry` (the server-function client's thunk for the call it is
223
+ * answering or dispatched, declared shape included) is recorded behind
224
+ * the call's address for the re-ask (`callFor`, frames-rulings 3.3).
225
+ */
186
226
  intercept?(info: {
187
227
  id: string;
188
228
  meta: unknown;
189
229
  args: unknown[];
230
+ retry?(): Promise<unknown>;
190
231
  }): unknown;
191
232
  handle(response: Response, ctx: {
192
233
  id: string;
193
234
  meta: unknown;
194
235
  args: unknown[];
195
236
  context: unknown;
237
+ retry?(): Promise<unknown>;
196
238
  }): unknown;
239
+ /**
240
+ * A `live()` call was made (before its first fetch): starts the live wire
241
+ * tier's load (`prepareTier("wire")`), so the import races only the
242
+ * request — preload-at-call.
243
+ */
244
+ onLive(): void;
197
245
  /**
198
246
  * What a `live` (re)connect of the call resumes from (RFC 11 §9.5,
199
247
  * Resume request): the address's version ordinal as the position
200
248
  * (`Last-Event-ID`) and, when a mount shows the address with a ledger,
201
249
  * its have-list under `FRAME_HAVE_HEADER` — omitted over budget, so the
202
250
  * render is a full snapshot then. `undefined` when nothing here has
203
- * shown the call.
251
+ * shown the call — or while the live wire tier, which keeps the ledger
252
+ * and answers this, is not resident yet (a first connect over content a
253
+ * plain call applied: a full snapshot, the degraded case accepted).
204
254
  */
205
255
  resume(info: {
206
256
  id: string;
@@ -214,10 +264,8 @@ export declare function createServerComponentHandler<C>(options: ServerComponent
214
264
  * Declares that the document is showing a call: hydration-data references
215
265
  * carry their call's address (`_$SC.r(id, address)`) but never travel
216
266
  * through the transport, so the integration forwards those records here.
217
- * Mints the call's binding (a post-load refetch then resolves a value
218
- * whose component matches what the document mounted) and brands the
219
- * per-function component so cache-seeded readers deliver instead of
220
- * remounting when their site later switches calls.
267
+ * Mints the call's binding, so a post-load refetch resolves a value
268
+ * whose component matches what the document mounted.
221
269
  */
222
270
  showing(address: string, functionId: string): void;
223
271
  };
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The `{$frame}` arm of a frame's arg resolution: for each region arg of
3
+ * the record (`regions`: arg name -> wire id), the region ELEMENT the
4
+ * wrapper places goes into `props` — cached per occurrence, so a re-call
5
+ * re-places the SAME element (no marker range to walk, no fragment refill)
6
+ * and the bound frame's parent follows live. `start` is given on the
7
+ * adopt-time mount (the frame's `claiming`): the interior's region elements
8
+ * are discovered first, so the record's addresses resolve to them.
9
+ */
10
+ export declare function resolve(frame: any, occurrence: string, regions: Record<string, string>, props: Record<string, unknown>, start?: unknown): void;
11
+ /**
12
+ * Bind a frame over each of the occurrence's region elements that has none
13
+ * yet — those `resolve` minted during the invoke or, on the adopt path,
14
+ * discovered in the interior before the fill ran (the fill owns its range
15
+ * through the framework's insert; the frame never reads its output back).
16
+ * Bind eagerly — the region ELEMENT always exists (unlike a marker range,
17
+ * which needs placement to count).
18
+ * This is what makes an OCCLUDED region work: its element is created when
19
+ * args resolve but the wrapper doesn't place it until (e.g.) expand, so it
20
+ * must bind and fill (from buffered/streamed chunks) off-DOM, then reveal
21
+ * in place when the wrapper finally inserts the single node. Host
22
+ * buffering flushes any queued childId chunks. The region inherits this
23
+ * frame's slot resolution (`parent`), so client slots revealed in its
24
+ * streamed content are filled by the same callbacks the client threaded
25
+ * down — no global registry.
26
+ */
27
+ export declare function bind(frame: any, occurrence: string): void;
28
+ /**
29
+ * Dispose the frames bound over an occurrence's regions and forget them;
30
+ * without an occurrence, every region of the frame (the frame is being
31
+ * disposed).
32
+ */
33
+ export declare function unmount(frame: any, occurrence?: string): void;
34
+ /**
35
+ * For the staged preview (`Frame.preview`): whether the record adds a
36
+ * region to the occurrence or renames one of its regions — its chunks ride
37
+ * the new name, so the rename must land with them at the commit, not in
38
+ * the preview. Read off the host's note of the record's `{$frame}` args.
39
+ */
40
+ export declare function changed(frame: any, occurrence: string, record: {
41
+ regions?: Record<string, string>;
42
+ }): boolean;
43
+ /** The frames bound over the frame's regions (the staged preview recurses
44
+ * into them). */
45
+ export declare function frames(frame: any): any[];
@@ -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
@@ -27,15 +27,39 @@ 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
+ declare const slotError: unique symbol;
30
31
  /**
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
32
+ * A binding slot's rejected return shape: assigning to it fails, and the
33
+ * error names the reason `M`.
34
+ * @experimental
35
+ */
36
+ export type SlotError<M extends string> = {
37
+ [slotError]: M;
38
+ };
39
+ /**
40
+ * What a binding slot's fill may return: `J` when it is a plain object with no
41
+ * `$`-prefixed key (reserved for occurrence identity), otherwise a
42
+ * `SlotError` naming why not.
43
+ * @experimental
44
+ */
45
+ export type SlotOutput<J> = J extends readonly unknown[] ? SlotError<"binding slot output must be an object, not an array"> : J extends Node ? SlotError<"binding slot output must be an object, not a DOM node"> : J extends (...args: any[]) => any ? SlotError<"binding slot output must be an object, not a function"> : J extends PromiseLike<unknown> | AsyncIterable<unknown> ? SlotError<"binding slot output must be settled, not async"> : Extract<keyof J, `$${string}`> extends never ? J : SlotError<`reserved key: ${Extract<keyof J, `$${string}`> & string}`>;
46
+ /**
47
+ * A binding slot (principles §9.2.3): the client renders an object instead of
48
+ * markup, and the server template binds its properties at positions —
49
+ * `const row = props.row({ id, completed });` then
34
50
  * `<li class={row.rowClass} hidden={row.removed}><input checked={row.done}
35
51
  * onInput={row.toggle} /></li>`. One call is one data context: any element
36
52
  * in the template may read from it, and the client owns exactly the values
37
53
  * the template read. Keys are the client's names; the position decides what
38
- * a property IS (attribute, class name, style property, handler, ref).
54
+ * a property IS (attribute, class name, style property, handler, ref, or
55
+ * text — `<strong>{list.remaining}</strong>`, a string or number). On
56
+ * the server a property is a stand-in, never the value: bind it, never
57
+ * branch on it or compute with it.
58
+ *
59
+ * The fill runs once per occurrence, untracked, as a component body does:
60
+ * state it creates lives with the occurrence, a top-level read is a
61
+ * one-time read, and a getter is the reactive form. Handlers and refs are
62
+ * read once, when an element binds.
39
63
  *
40
64
  * `P` is the args the server passes (reactive props to the fill, as for
41
65
  * `Slot`); `J` is the object the fill returns — the same type a shared
@@ -50,11 +74,11 @@ export type Slot<P = {}> = (props: P & {
50
74
  * prop.
51
75
  * @experimental
52
76
  */
53
- export type AttributeSlot<P = {}, J extends object = Record<string, unknown>> = {} extends P ? (props?: P & {
77
+ export type BindingSlot<P = {}, J extends object = Record<string, unknown>> = {} extends P ? (props?: P & {
54
78
  $key?: string | number;
55
- }) => J : (props: P & {
79
+ }) => SlotOutput<J> : (props: P & {
56
80
  $key?: string | number;
57
- }) => J;
81
+ }) => SlotOutput<J>;
58
82
  /**
59
83
  * Types an async value crossing the slot border (DR-2, value tier). What you
60
84
  * pass is what ships — the promise / async iterable itself rides the data
@@ -77,4 +101,4 @@ export type AttributeSlot<P = {}, J extends object = Record<string, unknown>> =
77
101
  */
78
102
  export declare function asyncArg<T>(value: PromiseLike<T> | AsyncIterable<T>): T;
79
103
  export { renderToFrameStream, renderServerComponent, serverComponentResponse, frameTransformResult, frameTransformFlightResult, createFrameSink, frameTransformDirectResult, ServerComponentPlugin, SERVER_COMPONENT_BOOTSTRAP } from "./frame-sink.js";
80
- export { FRAME_STREAM_HEADER, FRAME_HAVE_HEADER, FRAME_HAVE_BUDGET, isFrameStreamResponse } from "./frame-transport.js";
104
+ export { FRAME_STREAM_HEADER, FRAME_HAVE_HEADER, FRAME_HAVE_BUDGET, FRAME_TIERS_HEADER, isFrameStreamResponse } from "./frame-transport.js";
@@ -0,0 +1,2 @@
1
+ /** Install the traces tier into the frames client (called by `prepareTier`). */
2
+ export declare function install(): void;
@@ -0,0 +1,116 @@
1
+ import type { FrameHost, FrameHostOptions } from "./frame-client.js";
2
+ /**
3
+ * The host the handler hands over: the frame host, carrying the lazily
4
+ * loaded deserializer's load (`prepareData`) the transport awaits before a
5
+ * chunk that reads data — forwarded unchanged to the connection's proxy.
6
+ */
7
+ type Host = FrameHost & Pick<FrameHostOptions, "prepareData">;
8
+ /** A live loop's wire slot (see `LIVE_WIRE` in server-functions/shared.ts). */
9
+ interface WireSlot {
10
+ connection: Connection;
11
+ open(body: ReadableStream<Uint8Array> | null): {
12
+ next(): Promise<IteratorResult<string>>;
13
+ cancel?(reason?: unknown): unknown;
14
+ };
15
+ }
16
+ /** The connection slot the loop renews per connect (`wire.connection`). */
17
+ interface Connection {
18
+ ended?: Promise<ConnectionEnd>;
19
+ cancel?(reason: Error): void;
20
+ done?: boolean;
21
+ }
22
+ /** How a connection ended, as the loop reads it off `connection.ended`. */
23
+ interface ConnectionEnd {
24
+ open: number;
25
+ error: Error;
26
+ sweep(): void;
27
+ close(): void;
28
+ }
29
+ /**
30
+ * Ledger upkeep for an applied content record (the frame's `#recordHave`
31
+ * hands every one here): `""` is the root and RESETS the ledger to the
32
+ * root's digest and hole map; any other key takes the record's digest and
33
+ * the map of holes inside it. A record without a digest (an older
34
+ * producer) leaves the entry as it was. Without a ledger (no digest-
35
+ * carrying root applied) there is nothing to keep — the next resume is a
36
+ * full snapshot either way.
37
+ * @internal
38
+ */
39
+ export declare function have(frame: object, key: string, record: {
40
+ digest?: string;
41
+ holes?: Record<string, string>;
42
+ }): void;
43
+ /**
44
+ * The have-list of what a mount shows — the server-minted digests of the
45
+ * root skeleton under `""`, each live hole and attr hole by ledger key,
46
+ * each revealed fragment by name. `undefined` when the content's provenance
47
+ * carried no digests, or applied before this tier was resident (a
48
+ * document-adopted interior, a plain call's response): a resume then takes
49
+ * the full snapshot.
50
+ * @internal
51
+ */
52
+ export declare function haveOf(frame: object): Record<string, string> | undefined;
53
+ /**
54
+ * Encodes a have-list for the header: `key=digest` pairs, comma-joined
55
+ * (keys never contain either separator; the root's key is empty).
56
+ * `undefined` when the list is empty or over budget.
57
+ * @internal
58
+ */
59
+ export declare function encodeHaveList(have: Record<string, string>): string | undefined;
60
+ /**
61
+ * What a `live` (re)connect of a call resumes from (the handler's
62
+ * `resume`): the address's version ordinal as the position and, when a
63
+ * mount shows the address with a ledger, its have-list under
64
+ * `FRAME_HAVE_HEADER` — omitted over budget, so the render is a full
65
+ * snapshot then. `undefined` when nothing here has shown the call. The
66
+ * ledger is the MOUNT's (it tracks what the DOM shows); the first mount
67
+ * under the address speaks for all — they show the same store.
68
+ * @internal
69
+ */
70
+ export declare function resume(host: FrameHost, info: {
71
+ id: string;
72
+ args: unknown[];
73
+ }, versions: Map<string, number>): {
74
+ position: string;
75
+ headers?: Record<string, string>;
76
+ } | undefined;
77
+ /**
78
+ * Supersession (§9.5, Client face 4): a newer version for the address from
79
+ * another response — a getter refetch, a preload, a mutation's region —
80
+ * makes the open connection's later chunks inert under the stale-guard, so
81
+ * it is cancelled and the loop reconnects from the death. The handler's
82
+ * `bump` calls this for every bump, the loop's own reconnect included
83
+ * (whose predecessor has already ended and left the slot).
84
+ * @internal
85
+ */
86
+ export declare function cancel(host: object, address: string): void;
87
+ /**
88
+ * The live arm of the handler's `handle` (§9.5, Client face 2): the binding
89
+ * resolves the call now, and the response's lifetime — its end and how it
90
+ * ended — reaches the loop through its wire slot, so frames CONSUME the
91
+ * loop rather than mirror it: death → the loop's backoff and re-invoke,
92
+ * which resolves this same binding again (stable per address, so an
93
+ * equals-gated reader keeps its instance); completion → the loop
94
+ * completes.
95
+ *
96
+ * A live connection already streaming this address is JOINED: this
97
+ * response is ended here (the server tears its render down on the
98
+ * cancel) and the joining loop sees the shared connection's death when it
99
+ * comes, reconnecting like the loop that owns it (one of the two wins the
100
+ * next slot; the other joins again). Otherwise the response OPENS the
101
+ * address's connection: `bump` versions it and `begin` moves the store to
102
+ * the version at the header; the body is read through the loop's reader
103
+ * when it is framed as an event stream (`ChunkReader` otherwise), handed to
104
+ * the transport under the wire slot; and the end is judged HERE by what the
105
+ * body left open — `complete` is the bounded signal, an unkeyed `error` the
106
+ * failing kind of it; a body that ends with any still open is a DEATH, never
107
+ * a completion (§9.5, Wire) — and told to the loop with the sweep it may run
108
+ * over the open frames if the iteration ends for good by error (`close`
109
+ * leaves them as they stand: a superseding reconnect re-renders them). The
110
+ * transport's own end-of-body sweep (an error record per open frame, the
111
+ * no-loop verdict) is swallowed: the loop decides. A rejected read is a
112
+ * death the loop already sees, not an error record.
113
+ * @internal
114
+ */
115
+ export declare function connect(response: Response, wire: WireSlot, address: string, binding: unknown, host: Host, bump: (address: string) => number, begin: (address: string, version: number) => void): unknown;
116
+ export {};
package/types/index.d.ts CHANGED
@@ -108,8 +108,46 @@ export interface DynamicOptions {
108
108
  * (as a reference) or a serializable value (a tag name). A promise of a
109
109
  * client component function is a dev error on the server
110
110
  * (`DYNAMIC_ASYNC_COMPONENT`): resolve the async upstream, or use `lazy()`.
111
+ *
112
+ * Cost: because a source may answer with a tag name, one `dynamic` on a page
113
+ * retains the element runtime (create/claim, `spread`, the namespace tables)
114
+ * for everyone. A source that only ever answers with a component — a server
115
+ * component mount — should use `dynamicComponent`, which never does.
111
116
  */
112
117
  export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | AsyncIterable<T> | null | undefined | false, options?: DynamicOptions): Component<ComponentProps<T>>;
118
+ /**
119
+ * `dynamic` for a source that only ever answers with a component — never a
120
+ * tag name. Same contract, same semantics, same hydration shape (the two
121
+ * share one implementation): a reactive, optionally async source; a stable
122
+ * `Component` back; `{ static: true }` and `{ deferStream: true }` as on
123
+ * `dynamic`. The source's type excludes strings, so a tag name is a compile
124
+ * error here — use `dynamic` for one.
125
+ *
126
+ * Cost model, which is the reason this exists: `dynamic` must be able to
127
+ * render a tag, so one `dynamic` anywhere on a page retains the element
128
+ * runtime — `createElement`, `spread` and the prop-collection helpers, the
129
+ * SVG/MathML tables — for everyone, whether or not any source ever answers
130
+ * with a string (a bundler cannot know what a source will resolve to).
131
+ * `dynamicComponent` has no tag arm and never references that runtime, so a
132
+ * page whose only dynamic mounts are components pays nothing for it.
133
+ *
134
+ * This is the documented way to mount a server component: a server
135
+ * function's answer is a component reference, and the frames transport
136
+ * resolves every call for the same function to the same mount identity, so
137
+ * a refetch or an argument change is delivered into the mounted instance
138
+ * rather than remounting it (see `dynamic` for the full account).
139
+ *
140
+ * @example
141
+ * ```tsx
142
+ * const Story = dynamicComponent(() => getStory(props.storyId));
143
+ * return <Story comment={p => <Comment cid={p.cid}>{p.children}</Comment>} />;
144
+ *
145
+ * // A client component chosen by (sync) data — the same thing `dynamic`
146
+ * // does, without retaining the element runtime for the page.
147
+ * const Page = dynamicComponent(() => (page().editable ? Editor : Viewer));
148
+ * ```
149
+ */
150
+ export declare function dynamicComponent<C extends Component<any>>(source: () => C | Promise<C> | AsyncIterable<C> | null | undefined | false, options?: DynamicOptions): Component<ComponentProps<C>>;
113
151
  /**
114
152
  * @deprecated Use `dynamic()`. `<Dynamic>` is the same primitive, but its
115
153
  * shape puts the tag in the same bag as the element's props: every instance
@@ -43,6 +43,15 @@ export interface DynamicOptions {
43
43
  static?: boolean;
44
44
  }
45
45
  export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false, options?: DynamicOptions): Component<ComponentProps<T>>;
46
+ /**
47
+ * The server twin of the client's `dynamicComponent`: `dynamic` for a source
48
+ * that only ever answers with a component, never a tag name. Same owner
49
+ * shape as `dynamic` on both sides (the factory / value / render memos), so
50
+ * hydration ids agree with the client whichever of the two mounts the same
51
+ * value. The client entry's JSDoc carries the cost model; here the tag arm
52
+ * is simply absent.
53
+ */
54
+ export declare function dynamicComponent<C extends Component<any>>(source: () => C | Promise<C> | null | undefined | false, options?: DynamicOptions): Component<ComponentProps<C>>;
46
55
  /** @deprecated Props of the deprecated `<Dynamic>`; see `dynamic()`. */
47
56
  export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
48
57
  [K in keyof P]: P[K];
package/types/jsx.d.ts CHANGED
@@ -253,7 +253,7 @@ export namespace JSX {
253
253
  /**
254
254
  * Entity identity for server markup: the frame morph matches keyed
255
255
  * elements across responses by it, so client state attached to the
256
- * element (an attribute slot's bound positions, focus) follows the entity
256
+ * element (a binding slot's bound positions, focus) follows the entity
257
257
  * through reorders and refetches. SSR compiles it to the `_key`
258
258
  * attribute; a DOM compile strips it. On a component, `$key` is slot
259
259
  * occurrence identity across responses (optional; a repeated call is
@@ -106,8 +106,10 @@ 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";
113
115
  /**
@@ -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
  /**