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

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 (84) hide show
  1. package/dist/dev.cjs +116 -66
  2. package/dist/dev.js +109 -65
  3. package/dist/server.cjs +386 -109
  4. package/dist/server.js +378 -113
  5. package/dist/web.cjs +113 -64
  6. package/dist/web.js +106 -63
  7. package/frames/dist/client.cjs +100 -14
  8. package/frames/dist/client.dev.cjs +103 -14
  9. package/frames/dist/client.dev.js +104 -15
  10. package/frames/dist/client.js +101 -15
  11. package/frames/dist/server.cjs +285 -154
  12. package/frames/dist/server.js +287 -156
  13. package/package.json +20 -22
  14. package/serialization/dist/decode.cjs +22 -5
  15. package/serialization/dist/decode.js +23 -6
  16. package/serialization/dist/serialization.cjs +26 -13
  17. package/serialization/dist/serialization.js +26 -8
  18. package/serialization/types/index.d.ts +69 -157
  19. package/serialization/types/serializer-decode.d.ts +89 -112
  20. package/serialization/types/serializer.d.ts +94 -0
  21. package/serialization/types-cjs/index.d.cts +69 -157
  22. package/serialization/types-cjs/serializer-decode.d.cts +89 -112
  23. package/serialization/types-cjs/serializer.d.cts +94 -0
  24. package/server-functions/dist/client.cjs +48 -7
  25. package/server-functions/dist/client.js +48 -8
  26. package/server-functions/dist/server.cjs +76 -5
  27. package/server-functions/dist/server.dev.cjs +76 -5
  28. package/server-functions/dist/server.dev.js +76 -6
  29. package/server-functions/dist/server.js +76 -6
  30. package/types/client.d.ts +150 -290
  31. package/types/constants.d.ts +18 -0
  32. package/types/cookies.d.ts +31 -75
  33. package/types/frames/frame-client.d.ts +287 -259
  34. package/types/frames/frame-container-plugin.d.ts +71 -0
  35. package/types/frames/frame-sink.d.ts +58 -160
  36. package/types/frames/frame-transport.d.ts +161 -194
  37. package/types/frames/serializer-decode.d.ts +159 -0
  38. package/types/frames/serializer.d.ts +69 -157
  39. package/types/head.d.ts +16 -0
  40. package/types/index.d.ts +0 -65
  41. package/types/index.server.d.ts +125 -0
  42. package/types/jsx.d.ts +5 -13
  43. package/types/reconcile.d.ts +1 -0
  44. package/types/render.d.ts +4 -0
  45. package/types/response.d.ts +41 -153
  46. package/types/serializer-decode.d.ts +89 -112
  47. package/types/serializer.d.ts +69 -157
  48. package/types/server-functions/client.d.ts +101 -199
  49. package/types/server-functions/flash.d.ts +10 -30
  50. package/types/server-functions/registry.d.ts +63 -0
  51. package/types/server-functions/rich-args.d.ts +1 -10
  52. package/types/server-functions/server.d.ts +301 -518
  53. package/types/server-functions/shared.d.ts +112 -458
  54. package/types/server-mock.d.ts +13 -4
  55. package/types/server.d.ts +256 -427
  56. package/types-cjs/client.d.cts +150 -290
  57. package/types-cjs/constants.d.cts +18 -0
  58. package/types-cjs/cookies.d.cts +31 -75
  59. package/types-cjs/frames/frame-client.d.cts +287 -259
  60. package/types-cjs/frames/frame-container-plugin.d.cts +71 -0
  61. package/types-cjs/frames/frame-sink.d.cts +58 -160
  62. package/types-cjs/frames/frame-transport.d.cts +161 -194
  63. package/types-cjs/frames/serializer-decode.d.cts +159 -0
  64. package/types-cjs/frames/serializer.d.cts +69 -157
  65. package/types-cjs/head.d.cts +16 -0
  66. package/types-cjs/index.d.cts +0 -65
  67. package/types-cjs/index.server.d.cts +125 -0
  68. package/types-cjs/jsx.d.cts +5 -13
  69. package/types-cjs/reconcile.d.cts +1 -0
  70. package/types-cjs/render.d.cts +4 -0
  71. package/types-cjs/response.d.cts +41 -153
  72. package/types-cjs/serializer-decode.d.cts +89 -112
  73. package/types-cjs/serializer.d.cts +69 -157
  74. package/types-cjs/server-functions/client.d.cts +101 -199
  75. package/types-cjs/server-functions/flash.d.cts +10 -30
  76. package/types-cjs/server-functions/registry.d.cts +63 -0
  77. package/types-cjs/server-functions/rich-args.d.cts +1 -10
  78. package/types-cjs/server-functions/server.d.cts +301 -518
  79. package/types-cjs/server-functions/shared.d.cts +112 -458
  80. package/types-cjs/server-mock.d.cts +13 -4
  81. package/types-cjs/server.d.cts +256 -427
  82. package/LICENSE +0 -21
  83. package/types/core.d.ts +0 -6
  84. package/types-cjs/core.d.cts +0 -6
@@ -0,0 +1,71 @@
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 setContainerTraceMaterializer(fn: (marker: ContainerTraceMarker) => unknown): void;
22
+ /**
23
+ * Serializer half: install the async-iterable → raw-seroval-stream mint
24
+ * (serializer-decode.js, which already carries seroval — this module must
25
+ * stay seroval-free because it also rides the EAGER frames-client graph,
26
+ * and seroval ships without `sideEffects: false`).
27
+ *
28
+ * Why a raw stream and not the iterable itself: seroval decodes an async
29
+ * iterable as a generator WRAPPER over its internal stream, so every
30
+ * buffered value is microtasks away — but hydration's claim walk is
31
+ * SYNCHRONOUS. A trace whose snapshot the document already delivered must
32
+ * read as ready DURING the walk (every other async source has a sync
33
+ * hydration answer: promise stamps, serialized records), or the consuming
34
+ * boundary renders a phantom fallback over settled markup (the chat
35
+ * welcome/status meter miss). A raw stream decodes as the stream object
36
+ * itself, whose `.on()` replays the buffer synchronously at subscribe.
37
+ */
38
+ export declare function setContainerTraceStreamMint(fn: any): void; /** Whether a value is a traced container (server side; WeakMap probe, trap-safe). */
39
+ export declare function isContainerTraced(value: unknown): boolean;
40
+ export declare function envelopeContainerTraces(value: unknown): unknown;
41
+ export declare function isMaterializedContainer(value: unknown): boolean;
42
+ export declare function isContainerTraceMarker(value: unknown): value is ContainerTraceMarker;
43
+ export declare function reviveContainerTraces(value: unknown): unknown;
44
+ declare function parseTrace(value: any, ctx: any): {
45
+ a: number;
46
+ i: any;
47
+ };
48
+ /**
49
+ * Seroval plugin carrying reactive containers across the slot border as
50
+ * traces. Part of the codec's DEFAULT plugin set (serializer-decode.js), so
51
+ * every face — the hydration serializer, the frames codec, flight
52
+ * payloads, the client data tables — carries it with nothing to wire, and
53
+ * its weight lives in the (lazy) codec graph, never the eager client.
54
+ *
55
+ * @type {import("seroval").Plugin<object, { a: number, i: any }>}
56
+ */
57
+ export declare const ContainerTracePlugin: {
58
+ tag: string;
59
+ test(value: any): boolean;
60
+ parse: {
61
+ sync(): never;
62
+ async(value: any, ctx: any): Promise<{
63
+ a: number;
64
+ i: any;
65
+ }>;
66
+ stream: typeof parseTrace;
67
+ };
68
+ serialize(node: any, ctx: any): string;
69
+ deserialize(node: any, ctx: any): any;
70
+ };
71
+ export {};
@@ -1,132 +1,56 @@
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.cjs";
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
+ /** Remaining `renderToStream` options (plugins, onError, manifest, ...). */
21
+ [key: string]: unknown;
38
22
  }
39
-
40
23
  /**
41
24
  * A produced frame stream: pipe chunks, or await the collected array.
42
25
  * @experimental
43
26
  */
44
27
  export interface FrameStream extends PromiseLike<FrameChunk[]> {
45
- pipe(writable: { write(chunk: FrameChunk): void; end?(): void }): void;
28
+ pipe(writable: {
29
+ write(chunk: FrameChunk): void;
30
+ end?(): void;
31
+ }): void;
46
32
  }
47
-
48
- /**
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
-
33
+ export { SERVER_COMPONENT, SERVER_COMPONENT_SOURCE, SERVER_COMPONENT_ADDRESS, ServerComponentPlugin } from "./frame-transport.cjs";
58
34
  /**
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
35
+ * Statement form of the registry bootstrap, for a document shell that wants
36
+ * to install `_$SC` ahead of every data script (e.g. a plugin injecting it
37
+ * into `<head>`). No longer required — serialized references self-bootstrap
38
+ * — but kept for integrations still emitting it; the idempotent form makes
39
+ * the double-definition harmless. Never splice it before the authored
40
+ * `<head>` elements: a head-open script claims as the first walked child at
41
+ * hydration and drifts every positional claim after it.
76
42
  */
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
90
- */
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.
102
- * @experimental
103
- */
104
- export function serverComponentResponse(
105
- component: (props: Record<string, any>) => unknown,
106
- options?: FrameStreamOptions,
107
- init?: { headers?: HeadersInit; status?: number }
108
- ): Response;
109
-
110
- /**
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
- * ```
43
+ export declare const SERVER_COMPONENT_BOOTSTRAP: string; /**
44
+ * The emission surface `renderToStream` routes through when producing a
45
+ * frame stream instead of a document (see the `sink` render option). Each
46
+ * method emits transport-agnostic chunks; `emit` is the envelope boundary.
47
+ * @internal Compiler/renderer wiring — use `renderToFrameStream` or
48
+ * `renderServerComponent` instead.
124
49
  * @experimental
125
50
  */
126
- export function frameTransformResult(event: unknown, result: unknown): unknown;
127
-
128
- // === Document SSR (t = 0) ===
129
-
51
+ export declare function createFrameSink(emit: (chunk: FrameChunk) => void, frame: FrameAddress): Record<string, (...args: any[]) => void>;
52
+ export declare function renderToFrameStream(code: () => unknown, options?: FrameStreamOptions): FrameStream;
53
+ export declare function renderServerComponent(component: (props: Record<string, any>) => unknown, options?: FrameStreamOptions): FrameStream;
130
54
  /**
131
55
  * Document-mode slot props — the t = 0 counterpart of
132
56
  * `createSlotProps`: the server component renders INLINE in the
@@ -136,59 +60,33 @@ export function frameTransformResult(event: unknown, result: unknown): unknown;
136
60
  * regions onto the server-rendered ranges.
137
61
  * @experimental
138
62
  */
139
- export function createDocumentSlotProps(
140
- clientProps: Record<string, unknown>,
141
- frameId: string
142
- ): Record<string, unknown>;
143
-
63
+ export declare function createDocumentSlotProps(clientProps: Record<string, unknown>, frameId: string): Record<string, unknown>;
64
+ export declare function frameTransformDirectResult<T>(value: T, options: {
65
+ id: string;
66
+ args?: unknown[];
67
+ }): T;
68
+ export declare function createSlotProps(sink: ReturnType<typeof createFrameSink>, frame: FrameAddress): Record<string, any>;
69
+ export declare function serverComponentResponse(component: (props: Record<string, any>) => unknown, options?: FrameStreamOptions, init?: {
70
+ headers?: HeadersInit;
71
+ status?: number;
72
+ }): Response;
73
+ export declare function frameTransformResult(event: unknown, result: unknown): unknown;
74
+ export declare function frameTransformFlightResult(event: unknown, outcome: {
75
+ value: unknown;
76
+ data: unknown;
77
+ }, context?: unknown): Promise<Response | undefined>;
144
78
  /**
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.cjs";
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
79
+ * A framed response carrying several frames and a single-flight outcome:
80
+ * each frame's chunks in order (the host routes and buffers by id), then the
81
+ * `{ value, data }` envelope as `outcome` chunks.
82
+ *
83
+ * Those chunks carry the codec's own nodes, one per chunk, so async values
84
+ * inside flight data settle progressively exactly as they do in a plain
85
+ * single-flight body — the consumer replays them into the same decoder.
193
86
  */
194
- export const SERVER_COMPONENT_BOOTSTRAP: string;
87
+ export declare function frameFlightResponse({ primary, regions, outcome, codec }: {
88
+ primary: any;
89
+ regions?: any[];
90
+ outcome: any;
91
+ codec: any;
92
+ }, init?: {}): Response;