@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
@@ -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,6 +27,58 @@ 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;
31
+ /**
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
50
+ * `<li class={row.rowClass} hidden={row.removed}><input checked={row.done}
51
+ * onInput={row.toggle} /></li>`. One call is one data context: any element
52
+ * in the template may read from it, and the client owns exactly the values
53
+ * the template read. Keys are the client's names; the position decides what
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.
63
+ *
64
+ * `P` is the args the server passes (reactive props to the fill, as for
65
+ * `Slot`); `J` is the object the fill returns — the same type a shared
66
+ * component takes as a prop when the client renders it directly, so one
67
+ * `TodoRow` serves both sides. `$key` is occurrence identity, as for `Slot`,
68
+ * and optional: within a render, repeated calls with structurally equal
69
+ * args are one occurrence (a call in a component prop is re-evaluated per
70
+ * position the component binds), so the natural spelling needs no key;
71
+ * `$key` is for state inside the fill's scope that must follow the entity
72
+ * across responses. A slot with no args (`P` empty) is called bare —
73
+ * `const filters = props.filters();` — and is one occurrence named by the
74
+ * prop.
75
+ * @experimental
76
+ */
77
+ export type BindingSlot<P = {}, J extends object = Record<string, unknown>> = {} extends P ? (props?: P & {
78
+ $key?: string | number;
79
+ }) => SlotOutput<J> : (props: P & {
80
+ $key?: string | number;
81
+ }) => SlotOutput<J>;
30
82
  /**
31
83
  * Types an async value crossing the slot border (DR-2, value tier). What you
32
84
  * pass is what ships — the promise / async iterable itself rides the data
@@ -49,4 +101,4 @@ export type Slot<P = {}> = (props: P & {
49
101
  */
50
102
  export declare function asyncArg<T>(value: PromiseLike<T> | AsyncIterable<T>): T;
51
103
  export { renderToFrameStream, renderServerComponent, serverComponentResponse, frameTransformResult, frameTransformFlightResult, createFrameSink, frameTransformDirectResult, ServerComponentPlugin, SERVER_COMPONENT_BOOTSTRAP } from "./frame-sink.js";
52
- 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,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 {};
@@ -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
@@ -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";
@@ -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
@@ -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 (a binding 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 = {