@solidjs/web 2.0.0-rc.1 → 2.0.0-rc.10

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 (107) hide show
  1. package/dist/server.dev.js +4472 -0
  2. package/dist/server.js +1301 -251
  3. package/dist/{server.cjs → server.observe.js} +1501 -452
  4. package/dist/{dev.cjs → web.dev.js} +699 -360
  5. package/dist/web.js +454 -139
  6. package/dist/{dev.js → web.observe.js} +505 -211
  7. package/frames/dist/client.dev.js +463 -71
  8. package/frames/dist/client.js +363 -70
  9. package/frames/dist/{client.dev.cjs → client.observe.js} +486 -133
  10. package/frames/dist/server.dev.js +1713 -0
  11. package/frames/dist/server.js +552 -2583
  12. package/frames/dist/server.observe.js +1713 -0
  13. package/frames/package.json +2 -25
  14. package/package.json +214 -255
  15. package/performance-tracks/dist/performance-tracks.dev.js +678 -0
  16. package/performance-tracks/dist/performance-tracks.js +6 -0
  17. package/performance-tracks/dist/performance-tracks.observe.js +666 -0
  18. package/performance-tracks/package.json +7 -0
  19. package/performance-tracks/types/index.d.ts +67 -0
  20. package/serialization/decode/package.json +2 -15
  21. package/serialization/dist/decode.js +92 -15
  22. package/serialization/dist/serialization.js +103 -23
  23. package/serialization/package.json +2 -15
  24. package/serialization/types/index.d.ts +76 -157
  25. package/serialization/types/serializer-decode.d.ts +149 -112
  26. package/serialization/types/serializer.d.ts +101 -0
  27. package/server-functions/dist/client.dev.js +1364 -0
  28. package/server-functions/dist/client.js +611 -97
  29. package/server-functions/dist/client.observe.js +1343 -0
  30. package/server-functions/dist/server.dev.js +2138 -202
  31. package/server-functions/dist/server.js +2042 -199
  32. package/server-functions/dist/server.observe.js +3043 -0
  33. package/server-functions/package.json +2 -35
  34. package/server-functions/rich-args/package.json +2 -15
  35. package/storage/package.json +2 -15
  36. package/types/client.d.ts +193 -288
  37. package/types/constants.d.ts +20 -0
  38. package/types/cookies.d.ts +32 -84
  39. package/types/diagnostics.d.ts +56 -0
  40. package/types/frames/client.d.ts +1 -1
  41. package/types/frames/frame-client.d.ts +323 -259
  42. package/types/frames/frame-container-plugin.d.ts +72 -0
  43. package/types/frames/frame-sink.d.ts +101 -158
  44. package/types/frames/frame-transport.d.ts +192 -190
  45. package/types/frames/serializer-decode.d.ts +219 -0
  46. package/types/frames/serializer.d.ts +76 -157
  47. package/types/frames/server.d.ts +1 -1
  48. package/types/head.d.ts +19 -0
  49. package/types/index.d.ts +52 -80
  50. package/types/index.server.d.ts +174 -0
  51. package/types/jsx.d.ts +33 -35
  52. package/types/observe.d.ts +358 -0
  53. package/types/reconcile.d.ts +1 -0
  54. package/types/render.d.ts +9 -0
  55. package/types/response.d.ts +75 -150
  56. package/types/serializer-decode.d.ts +149 -112
  57. package/types/serializer.d.ts +76 -157
  58. package/types/server-functions/client.d.ts +192 -194
  59. package/types/server-functions/flash.d.ts +28 -30
  60. package/types/server-functions/registry.d.ts +102 -0
  61. package/types/server-functions/rich-args.d.ts +1 -10
  62. package/types/server-functions/server.d.ts +511 -475
  63. package/types/server-functions/shared.d.ts +366 -425
  64. package/types/server-mock.d.ts +110 -13
  65. package/types/server-observe.d.ts +77 -0
  66. package/types/server.d.ts +425 -425
  67. package/types/trace.d.ts +127 -0
  68. package/LICENSE +0 -21
  69. package/dist/web.cjs +0 -2008
  70. package/frames/dist/client.cjs +0 -1916
  71. package/frames/dist/server.cjs +0 -3756
  72. package/serialization/dist/decode.cjs +0 -122
  73. package/serialization/dist/serialization.cjs +0 -244
  74. package/serialization/types-cjs/index.d.cts +0 -182
  75. package/serialization/types-cjs/package.json +0 -3
  76. package/serialization/types-cjs/serializer-decode.d.cts +0 -182
  77. package/server-functions/dist/client.cjs +0 -793
  78. package/server-functions/dist/rich-args.cjs +0 -11
  79. package/server-functions/dist/server.cjs +0 -1171
  80. package/server-functions/dist/server.dev.cjs +0 -1171
  81. package/storage/dist/storage.cjs +0 -12
  82. package/storage/types-cjs/index.d.cts +0 -28
  83. package/storage/types-cjs/package.json +0 -3
  84. package/types/core.d.ts +0 -6
  85. package/types-cjs/client.d.cts +0 -337
  86. package/types-cjs/cookies.d.cts +0 -93
  87. package/types-cjs/core.d.cts +0 -6
  88. package/types-cjs/frames/client.d.cts +0 -36
  89. package/types-cjs/frames/frame-client.d.cts +0 -338
  90. package/types-cjs/frames/frame-sink.d.cts +0 -194
  91. package/types-cjs/frames/frame-transport.d.cts +0 -222
  92. package/types-cjs/frames/serializer.d.cts +0 -182
  93. package/types-cjs/frames/server.d.cts +0 -52
  94. package/types-cjs/index.d.cts +0 -244
  95. package/types-cjs/jsx-properties.d.cts +0 -93
  96. package/types-cjs/jsx.d.cts +0 -4159
  97. package/types-cjs/package.json +0 -3
  98. package/types-cjs/response.d.cts +0 -174
  99. package/types-cjs/serializer-decode.d.cts +0 -182
  100. package/types-cjs/serializer.d.cts +0 -182
  101. package/types-cjs/server-functions/client.d.cts +0 -231
  102. package/types-cjs/server-functions/flash.d.cts +0 -38
  103. package/types-cjs/server-functions/rich-args.d.cts +0 -10
  104. package/types-cjs/server-functions/server.d.cts +0 -616
  105. package/types-cjs/server-functions/shared.d.cts +0 -523
  106. package/types-cjs/server-mock.d.cts +0 -277
  107. package/types-cjs/server.d.cts +0 -523
@@ -0,0 +1,72 @@
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
+ /** A container's border serialization: one subscribe() per consumer. */
10
+ export interface ContainerTrace {
11
+ subscribe(): AsyncIterable<any>;
12
+ /** Whether the container's root is an array — the consumer's seed shape. */
13
+ array: boolean;
14
+ }
15
+ /** The eval-face wire literal a trace decodes to before materialization. */
16
+ export interface ContainerTraceMarker {
17
+ $tr: AsyncIterable<any>;
18
+ $ta?: number;
19
+ }
20
+ export declare function setContainerTraceResolver(fn: (value: unknown) => ContainerTrace | undefined): void;
21
+ export declare function setAsyncIterableSharer(fn: (source: AsyncIterable<any>) => AsyncIterable<any>): void;
22
+ export declare function setContainerTraceMaterializer(fn: (marker: ContainerTraceMarker) => unknown): void;
23
+ /**
24
+ * Serializer half: install the async-iterable → raw-seroval-stream mint
25
+ * (serializer-decode.js, which already carries seroval — this module must
26
+ * stay seroval-free because it also rides the EAGER frames-client graph,
27
+ * and seroval ships without `sideEffects: false`).
28
+ *
29
+ * Why a raw stream and not the iterable itself: seroval decodes an async
30
+ * iterable as a generator WRAPPER over its internal stream, so every
31
+ * buffered value is microtasks away — but hydration's claim walk is
32
+ * SYNCHRONOUS. A trace whose snapshot the document already delivered must
33
+ * read as ready DURING the walk (every other async source has a sync
34
+ * hydration answer: promise stamps, serialized records), or the consuming
35
+ * boundary renders a phantom fallback over settled markup (the chat
36
+ * welcome/status meter miss). A raw stream decodes as the stream object
37
+ * itself, whose `.on()` replays the buffer synchronously at subscribe.
38
+ */
39
+ export declare function setContainerTraceStreamMint(fn: any): void; /** Whether a value is a traced container (server side; WeakMap probe, trap-safe). */
40
+ export declare function isContainerTraced(value: unknown): boolean;
41
+ export declare function toBorderForm(value: unknown, envelopeContainers: boolean): unknown;
42
+ export declare function isMaterializedContainer(value: unknown): boolean;
43
+ export declare function isContainerTraceMarker(value: unknown): value is ContainerTraceMarker;
44
+ export declare function reviveContainerTraces(value: unknown): unknown;
45
+ declare function parseTrace(value: any, ctx: any): {
46
+ a: number;
47
+ i: any;
48
+ };
49
+ /**
50
+ * Seroval plugin carrying reactive containers across the slot border as
51
+ * traces. Part of the codec's DEFAULT plugin set (serializer-decode.js), so
52
+ * every face — the hydration serializer, the frames codec, flight
53
+ * payloads, the client data tables — carries it with nothing to wire, and
54
+ * its weight lives in the (lazy) codec graph, never the eager client.
55
+ *
56
+ * @type {import("seroval").Plugin<object, { a: number, i: any }>}
57
+ */
58
+ export declare const ContainerTracePlugin: {
59
+ tag: string;
60
+ test(value: any): boolean;
61
+ parse: {
62
+ sync(): never;
63
+ async(value: any, ctx: any): Promise<{
64
+ a: number;
65
+ i: any;
66
+ }>;
67
+ stream: typeof parseTrace;
68
+ };
69
+ serialize(node: any, ctx: any): string;
70
+ deserialize(node: any, ctx: any): any;
71
+ };
72
+ export {};
@@ -1,132 +1,96 @@
1
- // EXPERIMENTAL — the frames/server-components surface ships as an
2
- // experimental preview, excluded from the 2.0 stability guarantee: API
3
- // shapes and the wire format may change between prereleases (RFC 11).
4
- // Every export in this module is @experimental.
5
1
  import { FrameChunk } from "./frame-client.js";
6
-
7
2
  /**
8
3
  * Addresses a frame stream: the boundary id and this response's version.
9
4
  * @experimental
10
5
  */
11
6
  export interface FrameAddress {
12
- id: string;
13
- version: number;
7
+ id: string;
8
+ version: number;
14
9
  }
15
-
16
- /**
17
- * The emission surface `renderToStream` routes through when producing a
18
- * frame stream instead of a document (see the `sink` render option). Each
19
- * method emits transport-agnostic chunks; `emit` is the envelope boundary.
20
- * @internal Compiler/renderer wiring — use `renderToFrameStream` or
21
- * `renderServerComponent` instead.
22
- * @experimental
23
- */
24
- export function createFrameSink(
25
- emit: (chunk: FrameChunk) => void,
26
- frame: FrameAddress
27
- ): Record<string, (...args: any[]) => void>;
28
-
29
10
  /**
30
11
  * Options shared by the frame producers.
31
12
  * @experimental
32
13
  */
33
14
  export interface FrameStreamOptions {
34
- /** Boundary address; defaults to `{ id: "", version: 1 }`. */
35
- frame?: { id?: string; version?: number };
36
- /** Remaining `renderToStream` options (plugins, onError, manifest, ...). */
37
- [key: string]: unknown;
15
+ /** Boundary address; defaults to `{ id: "", version: 1 }`. */
16
+ frame?: {
17
+ id?: string;
18
+ version?: number;
19
+ };
20
+ /**
21
+ * The request's abort: tears the render down as a client disconnect would
22
+ * (see `renderToStream`'s `signal`). `serverComponentResponse` and
23
+ * `frameFlightResponse` chain it with their own body's `cancel`.
24
+ */
25
+ signal?: AbortSignal;
26
+ /**
27
+ * The call arrived at the live address — a `live` loop is reading
28
+ * (`getServerFunctionInvocation().live`). `serverComponentResponse` then
29
+ * frames the chunks as server-sent events, as the codec stream is framed
30
+ * there (`text/event-stream`, `no-store`, the idle heartbeat, the dev
31
+ * chaos knob), so the loop reads the frame stream through the reader it
32
+ * already has and a proxy holds the connection open as it would any
33
+ * event stream. The chunk protocol is unchanged; only the framing is.
34
+ */
35
+ live?: boolean;
36
+ /**
37
+ * A RESUME (RFC 11 §9.5): the have-list the reconnecting client sent —
38
+ * the digests it holds for this address, keyed as the chunks carry them
39
+ * (`""` the root skeleton, `lh:N` / `lha:N` holes, `pl-N` revealed
40
+ * fragments; see `FRAME_HAVE_HEADER`). With it the render is
41
+ * conditional: the root html is skipped when its skeleton digest matches,
42
+ * and a hole or fragment is emitted only once it has settled and its
43
+ * digest differs — so a no-op reconnect transfers nothing and a fallback
44
+ * is never emitted over content. Absent, the render is the progressive
45
+ * stream it always was. `frameTransformResult` reads it off the request.
46
+ */
47
+ resume?: {
48
+ have: Record<string, string>;
49
+ };
50
+ /** Remaining `renderToStream` options (plugins, onError, manifest, ...). */
51
+ [key: string]: unknown;
38
52
  }
39
-
40
53
  /**
41
54
  * A produced frame stream: pipe chunks, or await the collected array.
42
55
  * @experimental
43
56
  */
44
57
  export interface FrameStream extends PromiseLike<FrameChunk[]> {
45
- pipe(writable: { write(chunk: FrameChunk): void; end?(): void }): void;
58
+ pipe(writable: {
59
+ write(chunk: FrameChunk): void;
60
+ end?(): void;
61
+ }): void;
46
62
  }
47
-
63
+ export { SERVER_COMPONENT, SERVER_COMPONENT_SOURCE, SERVER_COMPONENT_ADDRESS, ServerComponentPlugin } from "./frame-transport.js";
48
64
  /**
49
- * Render to a FrameChunk stream: the same render core as `renderToStream`
50
- * with emission swapped to the frame sink and the document writable replaced
51
- * by a chunk envelope (`start` up front, `complete` at stream end). Data
52
- * records default to the keyed JSON codec (decode with
53
- * `createJSONDataTable`).
54
- * @experimental
55
- */
56
- export function renderToFrameStream(code: () => unknown, options?: FrameStreamOptions): FrameStream;
57
-
58
- /**
59
- * Render a **server component** — a `props => JSX` function, typically
60
- * returned from a server function — to a FrameChunk stream. `props` is a
61
- * slot-props proxy, not data:
62
- *
63
- * - reading a prop as a child emits a marker range the client fills;
64
- * - calling a prop as a render function emits a `slot` chunk for a fresh
65
- * occurrence (a primitive `$key` arg names it, so client state follows the
66
- * entity across responses — the slot-level analogue of For's `keyed`
67
- * function; positional otherwise, which is the right default for most
68
- * flows);
69
- * - primitive args ride the chunk; server JSX args stream as nested regions
70
- * (`{$frame}` — html once, never data); other values serialize as `{$ref}`
71
- * data records with referential dedupe.
72
- *
73
- * The props a *client* passes never reach the server — server inputs are the
74
- * function's arguments.
75
- * @experimental
76
- */
77
- export function renderServerComponent(
78
- component: (props: Record<string, any>) => unknown,
79
- options?: FrameStreamOptions
80
- ): FrameStream;
81
-
82
- /**
83
- * The slot props proxy used by `renderServerComponent`. Every key
84
- * virtually exists (`in` is always true — a prop is a position the client
85
- * may fill), enumeration is empty by design, and serialization goes through
86
- * the live render context, so it must only be used during the frame's
87
- * render.
88
- * @internal Exposed for framework bindings composing their own producers.
89
- * @experimental
65
+ * Statement form of the registry bootstrap, for a document shell that wants
66
+ * to install `_$SC` ahead of every data script (e.g. a plugin injecting it
67
+ * into `<head>`). No longer required — serialized references self-bootstrap
68
+ * — but kept for integrations still emitting it; the idempotent form makes
69
+ * the double-definition harmless. Never splice it before the authored
70
+ * `<head>` elements: a head-open script claims as the first walked child at
71
+ * hydration and drifts every positional claim after it.
90
72
  */
91
- export function createSlotProps(
92
- sink: ReturnType<typeof createFrameSink>,
93
- frame: FrameAddress
94
- ): Record<string, any>;
95
-
96
- /**
97
- * A server component as an HTTP Response: the chunk stream framed with the
98
- * server-function wire convention, tagged `X-Frame-Stream: <frame id>` for
99
- * the client and `X-Content-Raw` so the server-function handler forwards it
100
- * untouched. `init` (headers/status, e.g. from a `respond()` envelope)
101
- * merges in; the frame tags win on conflict.
73
+ export declare const SERVER_COMPONENT_BOOTSTRAP: string; /**
74
+ * The emission surface `renderToStream` routes through when producing a
75
+ * frame stream instead of a document (see the `sink` render option). Each
76
+ * method emits transport-agnostic chunks; `emit` is the envelope boundary.
77
+ * @internal Compiler/renderer wiring — use `renderToFrameStream` or
78
+ * `renderServerComponent` instead.
102
79
  * @experimental
103
80
  */
104
- export function serverComponentResponse(
105
- component: (props: Record<string, any>) => unknown,
106
- options?: FrameStreamOptions,
107
- init?: { headers?: HeadersInit; status?: number }
108
- ): Response;
109
-
81
+ export declare function createFrameSink(emit: (chunk: FrameChunk) => void, frame: FrameAddress, have?: Record<string, string>): Record<string, (...args: any[]) => void>;
110
82
  /**
111
- * The server-component convention as a `transformResult` policy for
112
- * `handleServerFunctionRequest`: a function result — or a `respond()`
113
- * envelope whose value is a function — becomes a frame-stream Response,
114
- * with the frame id defaulting to the server function's id so repeat calls
115
- * target the same client boundary. Everything else passes through.
116
- *
117
- * @example
118
- * ```ts
119
- * handleServerFunctionRequest(request, {
120
- * transformResult: frameTransformResult,
121
- * provideEvent
122
- * });
123
- * ```
124
- * @experimental
83
+ * The root's SKELETON: its html with every live-hole range and slot range
84
+ * emptied (markers kept). What remains is the structure hole emissions
85
+ * address into — static markup, marker ids and their nesting, placeholder
86
+ * ids and fallbacks. Equal skeletons mean equal hole/fragment keys, which
87
+ * is what makes emitting into the client's existing DOM sound; a differing
88
+ * one re-ships the root whole (structure changed — a hole count that moved
89
+ * with data, a static branch that flipped).
125
90
  */
126
- export function frameTransformResult(event: unknown, result: unknown): unknown;
127
-
128
- // === Document SSR (t = 0) ===
129
-
91
+ export declare function frameSkeleton(html: any): any;
92
+ export declare function renderToFrameStream(code: () => unknown, options?: FrameStreamOptions): FrameStream;
93
+ export declare function renderServerComponent(component: (props: Record<string, any>) => unknown, options?: FrameStreamOptions): FrameStream;
130
94
  /**
131
95
  * Document-mode slot props — the t = 0 counterpart of
132
96
  * `createSlotProps`: the server component renders INLINE in the
@@ -136,59 +100,38 @@ export function frameTransformResult(event: unknown, result: unknown): unknown;
136
100
  * regions onto the server-rendered ranges.
137
101
  * @experimental
138
102
  */
139
- export function createDocumentSlotProps(
140
- clientProps: Record<string, unknown>,
141
- frameId: string
142
- ): Record<string, unknown>;
143
-
103
+ export declare function createDocumentSlotProps(clientProps: Record<string, unknown>, frameId: string): Record<string, unknown>;
104
+ export declare function frameTransformDirectResult<T>(value: T, options: {
105
+ id: string;
106
+ args?: unknown[];
107
+ }): T;
108
+ export declare function createSlotProps(sink: ReturnType<typeof createFrameSink>, frame: FrameAddress): Record<string, any>;
109
+ export declare function serverComponentResponse(component: (props: Record<string, any>) => unknown, options?: FrameStreamOptions, init?: {
110
+ headers?: HeadersInit;
111
+ status?: number;
112
+ }): Response;
113
+ export declare function frameTransformResult(event: unknown, result: unknown): unknown;
114
+ export declare function frameTransformFlightResult(event: unknown, outcome: {
115
+ value: unknown;
116
+ data: unknown;
117
+ }, context?: unknown): Promise<Response | undefined>;
144
118
  /**
145
- * The in-process mirror of `frameTransformResult` for DOCUMENT SSR: install
146
- * as `configureServerFunctionsServer({ transformDirectResult })` and a
147
- * direct (same-process) server-function result that is a function comes back
148
- * as an inline-renderable server component (frame markers + document
149
- * slot props), branded with its function id and the call's wire address.
150
- * Non-function results pass through.
151
- * @experimental
152
- */
153
- export function frameTransformDirectResult<T>(
154
- value: T,
155
- options: { id: string; args?: unknown[] }
156
- ): T;
157
-
158
- /**
159
- * The frame half of single-flight, as a `transformFlightResult` policy for
160
- * `handleServerFunctionRequest`: when part of what a mutation invalidated is
161
- * markup (a component-valued flight-data entry), the frame stream carries
162
- * the whole payload — each component's content as a region addressed by its
163
- * call, the `{ value, data }` envelope as `outcome` chunks with the
164
- * component entries serialized as flight references. Returns `undefined`
165
- * when nothing invalidated is markup (the response stays the plain
166
- * single-flight envelope).
167
- * @experimental
168
- */
169
- export function frameTransformFlightResult(
170
- event: unknown,
171
- outcome: { value: unknown; data: unknown },
172
- context?: unknown
173
- ): Promise<Response | undefined>;
174
-
175
- // The brands and the codec plugin live with the transport (client bundles
176
- // resolve flight references against the live registry); re-exported here for
177
- // server integrations importing the document-SSR surface.
178
- export {
179
- SERVER_COMPONENT,
180
- SERVER_COMPONENT_ADDRESS,
181
- SERVER_COMPONENT_SOURCE,
182
- ServerComponentPlugin
183
- } from "./frame-transport.js";
184
-
185
- /**
186
- * Statement form of the `self._$SC` placeholder-registry bootstrap
187
- * (idempotent — first definition wins). No longer required in the document
188
- * shell: each hydration script's first serialized server-component reference
189
- * self-bootstraps the registry. Kept for integrations still installing it
190
- * document-wide; the client upgrades the registry via
191
- * `installServerComponents()`.
192
- * @experimental
119
+ * A framed response carrying several frames and a single-flight outcome:
120
+ * each frame's chunks in order (the host routes and buffers by id), then the
121
+ * `{ value, data }` envelope as `outcome` chunks.
122
+ *
123
+ * Those chunks carry the codec's own nodes, one per chunk, so async values
124
+ * inside flight data settle progressively exactly as they do in a plain
125
+ * single-flight body — the consumer replays them into the same decoder.
126
+ *
127
+ * `signal` is the request's abort (`frameTransformFlightResult` passes it):
128
+ * with the body's own `cancel`, either tears the frame in progress down and
129
+ * ends the response.
193
130
  */
194
- export const SERVER_COMPONENT_BOOTSTRAP: string;
131
+ export declare function frameFlightResponse({ primary, regions, outcome, codec, signal }: {
132
+ primary: any;
133
+ regions?: any[];
134
+ outcome: any;
135
+ codec: any;
136
+ signal: any;
137
+ }, init?: {}): Response;