@solidjs/web 2.0.0-beta.31 → 2.0.0-beta.33

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 (73) hide show
  1. package/README.md +1 -6
  2. package/dist/dev.cjs +285 -60
  3. package/dist/dev.js +267 -57
  4. package/dist/server.cjs +1148 -176
  5. package/dist/server.js +1133 -175
  6. package/dist/web.cjs +285 -60
  7. package/dist/web.js +267 -57
  8. package/frames/dist/client.cjs +397 -175
  9. package/frames/dist/client.dev.cjs +401 -175
  10. package/frames/dist/client.dev.js +399 -173
  11. package/frames/dist/client.js +395 -173
  12. package/frames/dist/server.cjs +1424 -277
  13. package/frames/dist/server.js +1426 -280
  14. package/package.json +69 -7
  15. package/serialization/decode/package.json +20 -0
  16. package/serialization/dist/decode.cjs +110 -0
  17. package/serialization/dist/decode.js +104 -0
  18. package/serialization/dist/serialization.cjs +106 -43
  19. package/serialization/dist/serialization.js +100 -44
  20. package/serialization/types/index.d.ts +85 -60
  21. package/serialization/types/serializer-decode.d.ts +182 -0
  22. package/serialization/types-cjs/index.d.cts +85 -60
  23. package/serialization/types-cjs/serializer-decode.d.cts +182 -0
  24. package/server-functions/dist/client.cjs +131 -98
  25. package/server-functions/dist/client.js +131 -99
  26. package/server-functions/dist/rich-args.cjs +11 -0
  27. package/server-functions/dist/rich-args.js +9 -0
  28. package/server-functions/dist/server.cjs +367 -194
  29. package/server-functions/dist/server.dev.cjs +1077 -0
  30. package/server-functions/dist/server.dev.js +1045 -0
  31. package/server-functions/dist/server.js +365 -195
  32. package/server-functions/package.json +10 -0
  33. package/server-functions/rich-args/package.json +20 -0
  34. package/storage/types/index.d.ts +1 -1
  35. package/storage/types-cjs/index.d.cts +1 -1
  36. package/types/client.d.ts +149 -6
  37. package/types/cookies.d.ts +93 -0
  38. package/types/core.d.ts +4 -2
  39. package/types/frames/client.d.ts +15 -1
  40. package/types/frames/frame-client.d.ts +63 -7
  41. package/types/frames/frame-sink.d.ts +26 -3
  42. package/types/frames/frame-transport.d.ts +40 -8
  43. package/types/frames/serializer.d.ts +85 -60
  44. package/types/frames/server.d.ts +22 -0
  45. package/types/index.d.ts +2 -3
  46. package/types/response.d.ts +45 -0
  47. package/types/serializer-decode.d.ts +182 -0
  48. package/types/serializer.d.ts +85 -60
  49. package/types/server-functions/client.d.ts +2 -1
  50. package/types/server-functions/rich-args.d.ts +10 -0
  51. package/types/server-functions/server.d.ts +99 -1
  52. package/types/server-functions/shared.d.ts +79 -1
  53. package/types/server-mock.d.ts +171 -59
  54. package/types/server.d.ts +209 -37
  55. package/types-cjs/client.d.cts +149 -6
  56. package/types-cjs/cookies.d.cts +93 -0
  57. package/types-cjs/core.d.cts +4 -2
  58. package/types-cjs/frames/client.d.cts +15 -1
  59. package/types-cjs/frames/frame-client.d.cts +63 -7
  60. package/types-cjs/frames/frame-sink.d.cts +26 -3
  61. package/types-cjs/frames/frame-transport.d.cts +40 -8
  62. package/types-cjs/frames/serializer.d.cts +85 -60
  63. package/types-cjs/frames/server.d.cts +22 -0
  64. package/types-cjs/index.d.cts +2 -3
  65. package/types-cjs/response.d.cts +45 -0
  66. package/types-cjs/serializer-decode.d.cts +182 -0
  67. package/types-cjs/serializer.d.cts +85 -60
  68. package/types-cjs/server-functions/client.d.cts +2 -1
  69. package/types-cjs/server-functions/rich-args.d.cts +10 -0
  70. package/types-cjs/server-functions/server.d.cts +99 -1
  71. package/types-cjs/server-functions/shared.d.cts +79 -1
  72. package/types-cjs/server-mock.d.cts +171 -59
  73. package/types-cjs/server.d.cts +209 -37
@@ -1,6 +1,13 @@
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.
1
5
  import { FrameChunk } from "./frame-client.js";
2
6
 
3
- /** Addresses a frame stream: the boundary id and this response's version. */
7
+ /**
8
+ * Addresses a frame stream: the boundary id and this response's version.
9
+ * @experimental
10
+ */
4
11
  export interface FrameAddress {
5
12
  id: string;
6
13
  version: number;
@@ -12,13 +19,17 @@ export interface FrameAddress {
12
19
  * method emits transport-agnostic chunks; `emit` is the envelope boundary.
13
20
  * @internal Compiler/renderer wiring — use `renderToFrameStream` or
14
21
  * `renderServerComponent` instead.
22
+ * @experimental
15
23
  */
16
24
  export function createFrameSink(
17
25
  emit: (chunk: FrameChunk) => void,
18
26
  frame: FrameAddress
19
27
  ): Record<string, (...args: any[]) => void>;
20
28
 
21
- /** Options shared by the frame producers. */
29
+ /**
30
+ * Options shared by the frame producers.
31
+ * @experimental
32
+ */
22
33
  export interface FrameStreamOptions {
23
34
  /** Boundary address; defaults to `{ id: "", version: 1 }`. */
24
35
  frame?: { id?: string; version?: number };
@@ -26,7 +37,10 @@ export interface FrameStreamOptions {
26
37
  [key: string]: unknown;
27
38
  }
28
39
 
29
- /** A produced frame stream: pipe chunks, or await the collected array. */
40
+ /**
41
+ * A produced frame stream: pipe chunks, or await the collected array.
42
+ * @experimental
43
+ */
30
44
  export interface FrameStream extends PromiseLike<FrameChunk[]> {
31
45
  pipe(writable: { write(chunk: FrameChunk): void; end?(): void }): void;
32
46
  }
@@ -37,6 +51,7 @@ export interface FrameStream extends PromiseLike<FrameChunk[]> {
37
51
  * by a chunk envelope (`start` up front, `complete` at stream end). Data
38
52
  * records default to the keyed JSON codec (decode with
39
53
  * `createJSONDataTable`).
54
+ * @experimental
40
55
  */
41
56
  export function renderToFrameStream(code: () => unknown, options?: FrameStreamOptions): FrameStream;
42
57
 
@@ -57,6 +72,7 @@ export function renderToFrameStream(code: () => unknown, options?: FrameStreamOp
57
72
  *
58
73
  * The props a *client* passes never reach the server — server inputs are the
59
74
  * function's arguments.
75
+ * @experimental
60
76
  */
61
77
  export function renderServerComponent(
62
78
  component: (props: Record<string, any>) => unknown,
@@ -70,6 +86,7 @@ export function renderServerComponent(
70
86
  * the live render context, so it must only be used during the frame's
71
87
  * render.
72
88
  * @internal Exposed for framework bindings composing their own producers.
89
+ * @experimental
73
90
  */
74
91
  export function createSlotProps(
75
92
  sink: ReturnType<typeof createFrameSink>,
@@ -82,6 +99,7 @@ export function createSlotProps(
82
99
  * the client and `X-Content-Raw` so the server-function handler forwards it
83
100
  * untouched. `init` (headers/status, e.g. from a `respond()` envelope)
84
101
  * merges in; the frame tags win on conflict.
102
+ * @experimental
85
103
  */
86
104
  export function serverComponentResponse(
87
105
  component: (props: Record<string, any>) => unknown,
@@ -103,6 +121,7 @@ export function serverComponentResponse(
103
121
  * provideEvent
104
122
  * });
105
123
  * ```
124
+ * @experimental
106
125
  */
107
126
  export function frameTransformResult(event: unknown, result: unknown): unknown;
108
127
 
@@ -115,6 +134,7 @@ export function frameTransformResult(event: unknown, result: unknown): unknown;
115
134
  * positions (the one hydration-time exception), wrapped in the same marker
116
135
  * dialect the chunk producer emits so the adopting client binds slots and
117
136
  * regions onto the server-rendered ranges.
137
+ * @experimental
118
138
  */
119
139
  export function createDocumentSlotProps(
120
140
  clientProps: Record<string, unknown>,
@@ -128,6 +148,7 @@ export function createDocumentSlotProps(
128
148
  * as an inline-renderable server component (frame markers + document
129
149
  * slot props), branded with its function id and the call's wire address.
130
150
  * Non-function results pass through.
151
+ * @experimental
131
152
  */
132
153
  export function frameTransformDirectResult<T>(
133
154
  value: T,
@@ -143,6 +164,7 @@ export function frameTransformDirectResult<T>(
143
164
  * component entries serialized as flight references. Returns `undefined`
144
165
  * when nothing invalidated is markup (the response stays the plain
145
166
  * single-flight envelope).
167
+ * @experimental
146
168
  */
147
169
  export function frameTransformFlightResult(
148
170
  event: unknown,
@@ -167,5 +189,6 @@ export {
167
189
  * self-bootstraps the registry. Kept for integrations still installing it
168
190
  * document-wide; the client upgrades the registry via
169
191
  * `installServerComponents()`.
192
+ * @experimental
170
193
  */
171
194
  export const SERVER_COMPONENT_BOOTSTRAP: string;
@@ -1,5 +1,9 @@
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.
1
5
  import { FrameChunk, FrameHost } from "./frame-client.js";
2
- import { JSONCodecOptions } from "./serializer.js";
6
+ import { JSONCodecOptions } from "./serializer-decode.js";
3
7
 
4
8
  // Structural mirror of server-functions/shared.js's FlightDataConsumer:
5
9
  // this file may only reference siblings that ship with it when integrations
@@ -11,13 +15,20 @@ type FlightConsumer = (data: unknown, context: { response: Response }) => void |
11
15
  * Header tagging a Response as a frame stream; its value is the producing
12
16
  * frame's id. Frame-owned wire contract — deliberately not a server-function
13
17
  * `BodyFormat` entry, since the body is frame chunks, not a serialized value.
18
+ * @experimental
14
19
  */
15
20
  export const FRAME_STREAM_HEADER: "X-Frame-Stream";
16
21
 
17
- /** Whether a fetch Response carries a frame stream. */
22
+ /**
23
+ * Whether a fetch Response carries a frame stream.
24
+ * @experimental
25
+ */
18
26
  export function isFrameStreamResponse(response: Response): boolean;
19
27
 
20
- /** Options for `applyFrameResponse`. */
28
+ /**
29
+ * Options for `applyFrameResponse`.
30
+ * @experimental
31
+ */
21
32
  export interface ApplyFrameResponseOptions {
22
33
  /**
23
34
  * Remap the producer's root frame id onto a local one — the id your
@@ -57,6 +68,7 @@ export interface ApplyFrameResponseOptions {
57
68
  * await applyFrameResponse(response, host, { as: "story-pane" });
58
69
  * }
59
70
  * ```
71
+ * @experimental
60
72
  */
61
73
  export function applyFrameResponse(
62
74
  response: Response,
@@ -64,13 +76,22 @@ export function applyFrameResponse(
64
76
  options?: ApplyFrameResponseOptions
65
77
  ): Promise<string>;
66
78
 
67
- /** Brands an inline-rendered server component with its function id. */
79
+ /**
80
+ * Brands an inline-rendered server component with its function id.
81
+ * @experimental
82
+ */
68
83
  export const SERVER_COMPONENT: unique symbol;
69
84
 
70
- /** The unwrapped server component behind an inline-render wrap. */
85
+ /**
86
+ * The unwrapped server component behind an inline-render wrap.
87
+ * @experimental
88
+ */
71
89
  export const SERVER_COMPONENT_SOURCE: unique symbol;
72
90
 
73
- /** The call's wire address (`frameAddress`), for regions to be emitted under. */
91
+ /**
92
+ * The call's wire address (`frameAddress`), for regions to be emitted under.
93
+ * @experimental
94
+ */
74
95
  export const SERVER_COMPONENT_ADDRESS: unique symbol;
75
96
 
76
97
  /**
@@ -81,10 +102,14 @@ export const SERVER_COMPONENT_ADDRESS: unique symbol;
81
102
  * instance, new binding" — keep the mounted instance and deliver the new
82
103
  * address into it; a different function swaps normally. `Symbol.for`, so
83
104
  * frameworks can honor it without importing this module.
105
+ * @experimental
84
106
  */
85
107
  export const COMPONENT_BINDING: unique symbol;
86
108
 
87
- /** The value under `COMPONENT_BINDING` on a transport-resolved binding. */
109
+ /**
110
+ * The value under `COMPONENT_BINDING` on a transport-resolved binding.
111
+ * @experimental
112
+ */
88
113
  export interface ComponentBinding<C = unknown> {
89
114
  /** The per-function mount component (the equals-gate identity). */
90
115
  component: C;
@@ -98,6 +123,7 @@ export interface ComponentBinding<C = unknown> {
98
123
  * placeholder in the hydration serializer, a live-registry lookup by call
99
124
  * address in the JSON codec (single-flight envelopes) — its markup never
100
125
  * rides as data.
126
+ * @experimental
101
127
  */
102
128
  export const ServerComponentPlugin: unknown;
103
129
 
@@ -108,6 +134,7 @@ export const ServerComponentPlugin: unknown;
108
134
  * on a script's first reference, a bare read after). Loaded document-SSR
109
135
  * modules install this (see frame-sink); client bundles never carry the
110
136
  * bootstrap text.
137
+ * @experimental
111
138
  */
112
139
  export function setServerComponentBootstrap(resolve: (ctx: unknown) => string): void;
113
140
 
@@ -115,10 +142,14 @@ export function setServerComponentBootstrap(resolve: (ctx: unknown) => string):
115
142
  * The codec options for a single-flight envelope: `codec` plus
116
143
  * `ServerComponentPlugin` (deduped by tag). Injected by the protocol on both
117
144
  * legs; exported for integrations composing their own flight carriers.
145
+ * @experimental
118
146
  */
119
147
  export function flightCodec(codec?: JSONCodecOptions): JSONCodecOptions;
120
148
 
121
- /** Options for `createServerComponentHandler`. */
149
+ /**
150
+ * Options for `createServerComponentHandler`.
151
+ * @experimental
152
+ */
122
153
  export interface ServerComponentHandlerOptions<C = unknown> {
123
154
  host: FrameHost;
124
155
  /**
@@ -170,6 +201,7 @@ export interface ServerComponentHandlerOptions<C = unknown> {
170
201
  * per-args entries — while mounts are per-SITE, rendering the per-function
171
202
  * component and following delivered addresses. An address nothing is bound
172
203
  * to warms its store (preload isolation is the default, not a rule).
204
+ * @experimental
173
205
  */
174
206
  export function createServerComponentHandler<C>(options: ServerComponentHandlerOptions<C>): {
175
207
  intercept?(info: { id: string; meta: unknown; args: unknown[] }): unknown;
@@ -1,35 +1,67 @@
1
- import { Plugin, Serializer, SerovalNode } from "seroval";
1
+ // Serialization surface (published as `@solidjs/web/serialization`): the
2
+ // runtime's Seroval machinery, exposed for the runtime's own entries and
3
+ // for integrations building transports on the same codec. This is
4
+ // INTEGRATION-FACING plumbing, not application API — it is exempt from the
5
+ // 2.0 stability guarantee and may change between releases. Application and
6
+ // router code should configure `codec` on the server-function entries
7
+ // instead of importing from here.
8
+ import type { Serializer } from "seroval";
9
+ import {
10
+ JSONCodecOptions,
11
+ PluginInfo,
12
+ SerializerPlugin,
13
+ SerovalNode
14
+ } from "./serializer-decode.js";
2
15
 
3
- /**
4
- * Seroval's node shape — the intermediate representation `serializeJSON`
5
- * emits and `createJSONDeserializer` consumes. Safe to `JSON.stringify`.
6
- */
7
- export type { SerovalNode };
16
+ // The decode half — `SerovalNode`, the plugin TYPES, `DEFAULT_WEB_PLUGINS`,
17
+ // `resolveSerializerPlugins`, `JSONCodecOptions`, `createJSONDeserializer`,
18
+ // `createJSONDataTable` is declared in serializer-decode.d.ts (published
19
+ // as `@solidjs/web/serialization/decode`, the module lazy client consumers
20
+ // load) and re-exported here so this remains the full surface.
21
+ export * from "./serializer-decode.js";
22
+
23
+ // ---- Plugin authoring ----
24
+ //
25
+ // Unlike the rest of this entry, plugin authoring is APPLICATION-FACING —
26
+ // it is the supported way to feed the serializers' `plugins` options and
27
+ // the server-function entries' `codec.plugins`. The values re-export
28
+ // seroval's own (`createPlugin`, `OpaqueReference` — see serializer.js);
29
+ // the plugin TYPES live in serializer-decode.d.ts (hand-declared there —
30
+ // see its banner for why).
8
31
 
9
32
  /**
10
- * A Seroval plugin usable with the web serializers teaches the codec how
11
- * to encode/decode a custom value type. Supply matching plugins on both
12
- * peers of a transport.
33
+ * Builds a `SerializerPlugin`seroval's `createPlugin`, re-exported so
34
+ * plugin authors stay on the exact seroval instance/version the runtime
35
+ * serializes with. Import it from HERE, not from your own `seroval`
36
+ * dependency: a plugin built against a different copy/version would not
37
+ * fail the build — it would emit nodes the other peer can't interpret.
38
+ *
39
+ * Application-facing (see the plugin-authoring banner above).
13
40
  */
14
- export type SerializerPlugin = Plugin<any, any>;
41
+ export function createPlugin<Value, Info extends PluginInfo>(
42
+ plugin: SerializerPlugin<Value, Info>
43
+ ): SerializerPlugin<Value, Info>;
15
44
 
16
45
  /**
17
- * Baseline plugin set for serializing web-platform values (AbortSignal,
18
- * Event, FormData, Headers, ReadableStream, Request, Response, URL, ...).
19
- * Applied by every serializer in this module; custom plugins compose ahead
20
- * of it via `resolveSerializerPlugins`.
46
+ * Seroval's `OpaqueReference`, re-exported from the runtime's own instance
47
+ * (an `OpaqueReference` from another seroval copy fails the serializer's
48
+ * instanceof check and serializes as a plain value): wraps a value so it
49
+ * crosses the wire as its `replacement` (default `undefined`) while
50
+ * staying readable in-process through `.value`.
51
+ *
52
+ * Application-facing (see the plugin-authoring banner above).
21
53
  */
22
- export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
54
+ export class OpaqueReference<V, R = undefined> {
55
+ readonly value: V;
56
+ readonly replacement?: R;
57
+ constructor(value: V, replacement?: R);
58
+ }
23
59
 
24
60
  /**
25
- * Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
26
- * first so they can shadow a default for values both would match. Returns a
27
- * fresh array; the defaults are never mutated. Useful when handing a full
28
- * plugin list to another serialization layer.
61
+ * Options for `createSerializer`.
62
+ *
63
+ * Integration-facing; may change (see the entry banner).
29
64
  */
30
- export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
31
-
32
- /** Options for `createSerializer`. */
33
65
  export interface WebSerializerOptions {
34
66
  /** Name of the global object the emitted scripts write resolved values into. */
35
67
  globalIdentifier: string;
@@ -58,6 +90,8 @@ export interface WebSerializerOptions {
58
90
  * evaluated — the script-injection form of serialization renderers build
59
91
  * on. For a JSON-based wire codec (no eval on the receiving side), use
60
92
  * `serializeJSON` / `createJSONDeserializer` instead.
93
+ *
94
+ * Integration-facing; may change (see the entry banner).
61
95
  */
62
96
  export function createSerializer(options: WebSerializerOptions): Serializer;
63
97
 
@@ -90,30 +124,14 @@ export function createHydrationSerializer(options: HydrationSerializerOptions):
90
124
  export function getLocalHeaderScript(id?: string): string;
91
125
 
92
126
  // ---- JSON codec (server function transports) ----
127
+ // (`JSONCodecOptions` and the decode half are declared in
128
+ // serializer-decode.d.ts and re-exported above.)
93
129
 
94
130
  /**
95
- * Options shared by both halves of the JSON codec. All of them must match
96
- * on the serializing and deserializing peer or payloads will not
97
- * round-trip for server functions, set them once through the
98
- * client/server `codec` config option.
131
+ * Options for `serializeJSON`.
132
+ *
133
+ * Integration-facing; may change (see the entry banner).
99
134
  */
100
- export interface JSONCodecOptions {
101
- /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
102
- plugins?: SerializerPlugin[];
103
- /**
104
- * Seroval feature bitflags to exclude. Defaults to disabling `RegExp`
105
- * (payloads may come from an untrusted peer). Must match on both peers.
106
- * Outside development, the encoding side additionally strips
107
- * `Error.prototype.stack` on top of any override — serialized stacks leak
108
- * server paths to the client. Decoding stays permissive, so payloads from
109
- * a development peer still round-trip.
110
- */
111
- disabledFeatures?: number;
112
- /** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
113
- depthLimit?: number;
114
- }
115
-
116
- /** Options for `serializeJSON`. */
117
135
  export interface JSONSerializeOptions extends JSONCodecOptions {
118
136
  /**
119
137
  * Receives each serialized node; `initial` is true for the first chunk
@@ -132,26 +150,33 @@ export interface JSONSerializeOptions extends JSONCodecOptions {
132
150
  * the deserializing peer needs no script evaluation, so CSP-safe). Wire
133
151
  * framing of the nodes is the transport's concern. Returns a cancel
134
152
  * function that aborts pending async serialization.
153
+ *
154
+ * Integration-facing; may change (see the entry banner).
135
155
  */
136
156
  export function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
137
157
 
138
- /**
139
- * Creates the decoding counterpart of `serializeJSON`. Cross-references
140
- * between chunks resolve through state shared across calls, so all chunks
141
- * from one stream must go through the same deserializer instance. The first
142
- * chunk's return value is the decoded source value; feeding later chunks
143
- * settles the async values referenced inside it.
144
- */
145
- export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
158
+ /** Options for `createJSONSerializer`. */
159
+ export interface JSONSerializerOptions extends JSONCodecOptions {
160
+ /**
161
+ * Receives each keyed record `initial` is true for a key's first node
162
+ * (the written value itself); async values patch through later records
163
+ * under the same key. The decoding peer is `createJSONDataTable`.
164
+ */
165
+ onData: (record: { key: string; node: SerovalNode; initial: boolean }) => void;
166
+ onError?: (error: unknown) => void;
167
+ /** Fires once `flush()` has been called and every pending value settled. */
168
+ onDone?: () => void;
169
+ }
146
170
 
147
171
  /**
148
- * A resident, response-scoped decode table over the keyed JSON codec: apply
149
- * each frame `data` chunk with `apply`, resolve `{ $ref }` slot args with
150
- * `resolve`. The frames client host wires one per response
151
- * (`applyData: c => table.apply(c)`).
172
+ * The keyed, streaming encoder of the eval-free JSON codec — the render
173
+ * stream's data serializer (frames default to it). Each `write(key, value)`
174
+ * shares one reference space, so cross-record identity holds; `flush()`
175
+ * marks the write set complete (writes after it are dropped, mirroring the
176
+ * hydration serializer); `close()` aborts pending async serialization.
152
177
  */
153
- export interface JSONDataTable {
154
- apply(chunk: { key?: string; node?: unknown; initial?: boolean }): void;
155
- resolve<T = unknown>(ref: { $ref: string }): T;
156
- }
157
- export function createJSONDataTable(options?: JSONCodecOptions): JSONDataTable;
178
+ export function createJSONSerializer(options: JSONSerializerOptions): {
179
+ write(key: string, value: unknown): void;
180
+ flush(): void;
181
+ close(): void;
182
+ };
@@ -22,9 +22,31 @@ import type { Element as SolidElement } from "solid-js";
22
22
  * re-creates everything. It is occurrence identity, not client data: it is
23
23
  * stripped before the client component sees its props. Positional identity is
24
24
  * the right default; `$key` matters when a live list reorders.
25
+ * @experimental
25
26
  */
26
27
  export type Slot<P = {}> = (props: P & {
27
28
  $key?: string | number;
28
29
  }) => SolidElement;
30
+ /**
31
+ * Types an async value crossing the slot border (DR-2, value tier). What you
32
+ * pass is what ships — the promise / async iterable itself rides the data
33
+ * channel — but the client's prop READ settles: it suspends into the covering
34
+ * boundary until first arrival (a promise's resolution, an iterable's first
35
+ * yield), then reads as the settled value, updating per yield for iterables.
36
+ *
37
+ * `asyncArg` is the type-level statement of that contract: identity at
38
+ * runtime, settled type at the border, so `Slot<P>` keeps the fill's props
39
+ * truthful to what its reads actually return.
40
+ *
41
+ * Slots render as JSX — the compiler wraps each prop in a getter so the read
42
+ * defers to the slot border, where the runtime owns it. A call form
43
+ * (`props.status({ … })`) evaluates its args eagerly in the component body —
44
+ * a top-level read, an error in most cases.
45
+ *
46
+ * ```tsx
47
+ * <props.status progress={asyncArg(gen.progress)} stats={asyncArg(gen.stats)} />
48
+ * ```
49
+ */
50
+ export declare function asyncArg<T>(value: PromiseLike<T> | AsyncIterable<T>): T;
29
51
  export { renderToFrameStream, renderServerComponent, serverComponentResponse, frameTransformResult, frameTransformFlightResult, createFrameSink, frameTransformDirectResult, ServerComponentPlugin, SERVER_COMPONENT_BOOTSTRAP } from "./frame-sink.js";
30
52
  export { FRAME_STREAM_HEADER, isFrameStreamResponse } from "./frame-transport.js";
package/types/index.d.ts CHANGED
@@ -96,9 +96,8 @@ export declare function render(code: () => JSX.Element, element: MountableElemen
96
96
  * and reactive bindings without reconstructing the DOM. Returns a `dispose`
97
97
  * function that tears down reactive scopes (DOM nodes are left in place).
98
98
  *
99
- * Use this when the page HTML was produced by `renderToString`,
100
- * `renderToStringAsync`, or `renderToStream`. For client-only apps, use
101
- * `render` instead.
99
+ * Use this when the page HTML was produced by `renderToString` or
100
+ * `renderToStream`. For client-only apps, use `render` instead.
102
101
  *
103
102
  * Pass `options.renderId` to hydrate one of multiple roots emitted by a
104
103
  * server render that used the same id.
@@ -49,6 +49,51 @@ export interface Href {
49
49
  */
50
50
  export function isHref(value: unknown): value is Href;
51
51
 
52
+ /**
53
+ * Registered-symbol brand (`Symbol.for("solid.SafeError")`) marking a thrown
54
+ * value as safe to serialize to the client verbatim. Declared `unique
55
+ * symbol` type-side; the runtime value is the registered symbol, so
56
+ * separately bundled copies agree on identity.
57
+ */
58
+ export declare const SAFE_ERROR: unique symbol;
59
+
60
+ /**
61
+ * Marks `error` as safe to serialize to the client verbatim, opting it out
62
+ * of the server-function handler's production error sanitization.
63
+ *
64
+ * By default a plain `Error` thrown from a server function is sanitized to a
65
+ * generic `Error` outside the dev build (the `development` export condition
66
+ * selects the full-fidelity copy; every other resolution sanitizes):
67
+ * its `message`, `stack`, and own-properties are dropped so a driver/ORM
68
+ * error can't leak a failing query or connection string over the wire.
69
+ * Dev builds keep full fidelity. This is the escape hatch for errors whose
70
+ * content is *intentional* client-facing information — brand them and their
71
+ * message/properties travel intact in every environment.
72
+ *
73
+ * The brand is a non-enumerable, symbol-keyed property, so it never itself
74
+ * serializes as an own-property. Sets the brand and returns the same value.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * import { markSafeError } from "@solidjs/web";
79
+ *
80
+ * async function transfer(amount: number) {
81
+ * "use server";
82
+ * if (amount > balance) {
83
+ * // The user must see this message; opt out of sanitization.
84
+ * throw markSafeError(new Error("Insufficient funds"));
85
+ * }
86
+ * }
87
+ * ```
88
+ */
89
+ export function markSafeError<E>(error: E): E;
90
+
91
+ /**
92
+ * Whether `value` is branded safe to serialize (via `markSafeError`).
93
+ * Registered-symbol check, correct across duplicated module instances.
94
+ */
95
+ export function isSafeError(value: unknown): value is Error;
96
+
52
97
  /**
53
98
  * Response header naming the cache keys a mutation invalidated
54
99
  * (`"X-Revalidate"`), comma separated. The response helpers below set it