@solidjs/web 2.0.0-experimental.9 → 2.0.0-rc.1

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 (85) hide show
  1. package/README.md +22 -4
  2. package/dist/dev.cjs +1588 -224
  3. package/dist/dev.js +1513 -200
  4. package/dist/server.cjs +2722 -254
  5. package/dist/server.js +2659 -245
  6. package/dist/web.cjs +1524 -218
  7. package/dist/web.js +1449 -194
  8. package/frames/dist/client.cjs +1916 -0
  9. package/frames/dist/client.dev.cjs +1933 -0
  10. package/frames/dist/client.dev.js +1921 -0
  11. package/frames/dist/client.js +1904 -0
  12. package/frames/dist/server.cjs +3756 -0
  13. package/frames/dist/server.js +3743 -0
  14. package/frames/package.json +30 -0
  15. package/package.json +350 -37
  16. package/serialization/decode/package.json +20 -0
  17. package/serialization/dist/decode.cjs +122 -0
  18. package/serialization/dist/decode.js +116 -0
  19. package/serialization/dist/serialization.cjs +244 -0
  20. package/serialization/dist/serialization.js +227 -0
  21. package/serialization/package.json +20 -0
  22. package/serialization/types/index.d.ts +182 -0
  23. package/serialization/types/serializer-decode.d.ts +182 -0
  24. package/serialization/types-cjs/index.d.cts +182 -0
  25. package/serialization/types-cjs/package.json +3 -0
  26. package/serialization/types-cjs/serializer-decode.d.cts +182 -0
  27. package/server-functions/dist/client.cjs +793 -0
  28. package/server-functions/dist/client.js +763 -0
  29. package/server-functions/dist/rich-args.cjs +11 -0
  30. package/server-functions/dist/rich-args.js +9 -0
  31. package/server-functions/dist/server.cjs +1171 -0
  32. package/server-functions/dist/server.dev.cjs +1171 -0
  33. package/server-functions/dist/server.dev.js +1137 -0
  34. package/server-functions/dist/server.js +1137 -0
  35. package/server-functions/package.json +40 -0
  36. package/server-functions/rich-args/package.json +20 -0
  37. package/storage/package.json +8 -3
  38. package/storage/types/index.d.ts +26 -0
  39. package/storage/types-cjs/index.d.cts +28 -0
  40. package/storage/types-cjs/package.json +3 -0
  41. package/types/client.d.ts +290 -27
  42. package/types/cookies.d.ts +93 -0
  43. package/types/core.d.ts +6 -2
  44. package/types/frames/client.d.ts +36 -0
  45. package/types/frames/frame-client.d.ts +338 -0
  46. package/types/frames/frame-sink.d.ts +194 -0
  47. package/types/frames/frame-transport.d.ts +222 -0
  48. package/types/frames/serializer.d.ts +182 -0
  49. package/types/frames/server.d.ts +52 -0
  50. package/types/index.d.ts +223 -24
  51. package/types/jsx-properties.d.ts +93 -0
  52. package/types/jsx.d.ts +4159 -1
  53. package/types/response.d.ts +174 -0
  54. package/types/serializer-decode.d.ts +182 -0
  55. package/types/serializer.d.ts +182 -0
  56. package/types/server-functions/client.d.ts +231 -0
  57. package/types/server-functions/flash.d.ts +38 -0
  58. package/types/server-functions/rich-args.d.ts +10 -0
  59. package/types/server-functions/server.d.ts +616 -0
  60. package/types/server-functions/shared.d.ts +523 -0
  61. package/types/server-mock.d.ts +249 -12
  62. package/types/server.d.ts +424 -51
  63. package/types-cjs/client.d.cts +337 -0
  64. package/types-cjs/cookies.d.cts +93 -0
  65. package/types-cjs/core.d.cts +6 -0
  66. package/types-cjs/frames/client.d.cts +36 -0
  67. package/types-cjs/frames/frame-client.d.cts +338 -0
  68. package/types-cjs/frames/frame-sink.d.cts +194 -0
  69. package/types-cjs/frames/frame-transport.d.cts +222 -0
  70. package/types-cjs/frames/serializer.d.cts +182 -0
  71. package/types-cjs/frames/server.d.cts +52 -0
  72. package/types-cjs/index.d.cts +244 -0
  73. package/types-cjs/jsx-properties.d.cts +93 -0
  74. package/types-cjs/jsx.d.cts +4159 -0
  75. package/types-cjs/package.json +3 -0
  76. package/types-cjs/response.d.cts +174 -0
  77. package/types-cjs/serializer-decode.d.cts +182 -0
  78. package/types-cjs/serializer.d.cts +182 -0
  79. package/types-cjs/server-functions/client.d.cts +231 -0
  80. package/types-cjs/server-functions/flash.d.cts +38 -0
  81. package/types-cjs/server-functions/rich-args.d.cts +10 -0
  82. package/types-cjs/server-functions/server.d.cts +616 -0
  83. package/types-cjs/server-functions/shared.d.cts +523 -0
  84. package/types-cjs/server-mock.d.cts +277 -0
  85. package/types-cjs/server.d.cts +523 -0
package/types/server.d.ts CHANGED
@@ -1,43 +1,132 @@
1
1
  import { JSX } from "./jsx.js";
2
- export const Properties: Set<string>;
2
+ import { SerializerPlugin } from "./serializer-decode.js";
3
+ export const DOMWithState: Record<string, Record<string, 1 | 2>>;
3
4
  export const ChildProperties: Set<string>;
4
5
  export const DelegatedEvents: Set<string>;
5
6
  export const DOMElements: Set<string>;
6
7
  export const SVGElements: Set<string>;
7
- export const SVGNamespace: Record<string, string>;
8
+ export const MathMLElements: Set<string>;
9
+ export const VoidElements: Set<string>;
10
+ export const RawTextElements: Set<string>;
11
+ export const Namespaces: Record<string, string>;
8
12
 
9
13
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
10
14
 
15
+ /** Static asset manifest produced by a build (e.g. parsed Vite manifest.json). */
16
+ export type AssetManifest = Record<
17
+ string,
18
+ { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
19
+ > & { _base?: string };
20
+
21
+ /** Inline style content, e.g. dev CSS collected from a bundler's module graph. */
22
+ export type InlineStyleAsset = {
23
+ id: string;
24
+ content: string;
25
+ attrs?: Record<string, string>;
26
+ };
27
+
28
+ export type ResolvedAssets = {
29
+ js: string[];
30
+ css: (string | InlineStyleAsset)[];
31
+ };
32
+
33
+ /**
34
+ * Resolver form of the manifest option — the primitive a dev server
35
+ * implements against its live module graph (a static manifest object is
36
+ * normalized into a sync resolver internally). `resolve` may return a
37
+ * promise (async resolvers require streaming rendering); CSS entries may be
38
+ * URL strings (emitted as load-gated `<link>` tags) or inline-style
39
+ * descriptors (emitted as `<style>` tags). A bare `resolve`-shaped function
40
+ * is accepted as shorthand for `{ resolve }`.
41
+ */
42
+ export type AssetResolver = {
43
+ resolve(
44
+ key: string
45
+ ): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
46
+ /**
47
+ * Synchronous fast path answering with whatever is knowable without async
48
+ * work (typically js URLs, omitting css). Sync consumers — e.g. a lazy
49
+ * component's `moduleUrl` getter used by islands — use this when `resolve`
50
+ * would return a promise, so adapters should provide it whenever possible.
51
+ */
52
+ resolveSync?(key: string): ResolvedAssets | null | undefined;
53
+ };
54
+
55
+ /** Bare-function shorthand for `AssetResolver` (no sync fast path). */
56
+ export type AssetResolverFn = (
57
+ key: string
58
+ ) => ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
59
+
11
60
  export function renderToString<T>(
12
61
  fn: () => T,
13
62
  options?: {
14
- nonce?: string;
15
- renderId?: string;
16
- onError?: (err: any) => void;
17
- }
18
- ): string;
19
- export function renderToStringAsync<T>(
20
- fn: () => T,
21
- options?: {
22
- timeoutMs?: number;
23
63
  nonce?: string;
24
64
  renderId?: string;
25
65
  noScripts?: boolean;
66
+ plugins?: SerializerPlugin[];
67
+ manifest?: AssetManifest | AssetResolver | AssetResolverFn;
26
68
  onError?: (err: any) => void;
69
+ /**
70
+ * Embedded-render contract for hosts that own the document. When the
71
+ * render output contains no `</head>`, everything head-bound (resolved
72
+ * `useHead` winners, eager resources, tracked asset links, inline
73
+ * styles) is delivered here as one HTML string — prelude (charset/base)
74
+ * first — for the host to splice into its own `<head>` template, instead
75
+ * of being dropped. Called synchronously before `renderToString`
76
+ * returns; not called when the output has a `</head>` (splicing is
77
+ * automatic then).
78
+ */
79
+ onHead?: (head: string) => void;
27
80
  }
28
- ): Promise<string>;
81
+ ): string;
29
82
  export function renderToStream<T>(
30
83
  fn: () => T,
31
84
  options?: {
32
85
  nonce?: string;
33
86
  renderId?: string;
87
+ noScripts?: boolean;
88
+ plugins?: SerializerPlugin[];
89
+ manifest?: AssetManifest | AssetResolver | AssetResolverFn;
34
90
  onCompleteShell?: (info: { write: (v: string) => void }) => void;
35
91
  onCompleteAll?: (info: { write: (v: string) => void }) => void;
36
92
  onError?: (err: any) => void;
93
+ /**
94
+ * Embedded-render contract for hosts that own the document. When the
95
+ * shell contains no `</head>`, everything head-bound at first flush
96
+ * (resolved `useHead` winners, eager resources, tracked asset links,
97
+ * inline styles) is delivered here as one HTML string — prelude first —
98
+ * before the shell chunk is emitted, so the host can write its own
99
+ * `<head>` ahead of piping the stream. Post-shell head updates flow
100
+ * through the stream itself and apply in the browser. Not called when
101
+ * the shell has a `</head>` (splicing is automatic then).
102
+ */
103
+ onHead?: (head: string) => void;
37
104
  }
38
105
  ): {
39
- pipe: (writable: { write: (v: string) => void }) => void;
106
+ /**
107
+ * Awaiting the stream resolves with the complete HTML once every boundary
108
+ * settles — the fully-settled-string form of the render (`const html =
109
+ * await renderToStream(...)`). Render errors route through `onError` and
110
+ * the promise resolves with whatever HTML the render produced; it never
111
+ * rejects.
112
+ */
113
+ then<TResult1 = string, TResult2 = never>(
114
+ onfulfilled?: ((html: string) => TResult1 | PromiseLike<TResult1>) | null,
115
+ onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
116
+ ): Promise<TResult1 | TResult2>;
117
+ pipe: (writable: { write: (v: string) => void; end: () => void }) => void;
40
118
  pipeTo: (writable: WritableStream) => Promise<void>;
119
+ /**
120
+ * Lazy `ReadableStream<Uint8Array>` view of the render — hand it straight
121
+ * to `new Response(stream.readable)`. First access starts the render
122
+ * piping through an internal `TransformStream` (chunks are UTF-8 encoded
123
+ * bytes, the same as `pipeTo` writes) and the stream is cached, so
124
+ * repeated access returns the same instance. Like `pipe`/`pipeTo`, this
125
+ * consumes the render: use exactly one of the three — mixing distinct
126
+ * consumers (`readable` after `pipe`/`pipeTo`, or vice versa) throws an
127
+ * error naming the conflict.
128
+ */
129
+ readonly readable: ReadableStream<Uint8Array>;
41
130
  };
42
131
 
43
132
  export function HydrationScript(props: { nonce?: string; eventNames?: string[] }): JSX.Element;
@@ -48,42 +137,289 @@ export function ssrElement(
48
137
  children: any,
49
138
  needsId: boolean
50
139
  ): { t: string };
51
- export function ssrClassList(value: { [k: string]: boolean }): string;
52
- export function ssrStyle(value: { [k: string]: string }): string;
53
- export function ssrAttribute(key: string, value: any, isBoolean: boolean): string;
140
+ export function ssrClassName(value: string | { [k: string]: boolean } | Array<any>): string;
141
+ export function ssrStyle(value: string | { [k: string]: string }): string;
142
+ export function ssrStyleProperty(name: string, value: any): string;
143
+ export function ssrAttribute(key: string, value: any): string;
144
+ export function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
145
+ export function scope<T>(fn: () => T): () => unknown;
54
146
  export function ssrHydrationKey(): string;
55
- export function resolveSSRNode(node: any): string;
56
- export function escape(html: string): string;
57
- export function useAssets(fn: () => JSX.Element): void;
58
- export function getAssets(): string;
59
- export function getHydrationKey(): string;
60
- export function effect<T>(fn: (prev?: T) => T, init?: T): void;
147
+ export function resolveSSRNode(node: any, result?: any, top?: boolean): any;
148
+ export function escape(s: any, attr?: boolean): any;
149
+ export function applyRef(
150
+ r: ((element: any) => void) | ((element: any) => void)[],
151
+ element: any
152
+ ): void;
153
+ /**
154
+ * A head tag descriptor. Props values may be getters (evaluated lazily on
155
+ * the server — at the owning flush boundary — and reactively on the client);
156
+ * `children` is the text body (title text, inline style/script content).
157
+ * `key` overrides the built-in dedupe identity (`title` is a hard singleton
158
+ * that `key` cannot fork).
159
+ *
160
+ * Getters must be plain reads: they evaluate at flush time here (under no
161
+ * component owner) and inside registry-owned computations on the client, so
162
+ * a getter that allocates a reactive owner (`createMemo`, a `children()`
163
+ * helper) consumes a hydration id slot on one side only and desyncs every
164
+ * id allocated after the `useHead` call. Create such helpers eagerly at
165
+ * component position and read them from the getter. See
166
+ * docs/head-management-rfc.md.
167
+ */
168
+ export type HeadTag = {
169
+ tag: "title" | "meta" | "link" | "style" | "script" | "base";
170
+ props: Record<string, any>;
171
+ key?: string | (() => string);
172
+ };
173
+ /**
174
+ * Registers head tags with the render's head registry. An array is a group —
175
+ * one replacement set; a single tag is a group of one; a function is a
176
+ * reactive group whose membership resolves at the owning flush boundary
177
+ * (resource tags inside it emit at that flush rather than eagerly).
178
+ * Replaceable tags (title/meta/canonical/…) resolve by last-committed group
179
+ * and stream as patches with their suspense boundary's reveal; resource tags
180
+ * (preload and friends, stylesheets, `script[src]`) emit eagerly and dedupe
181
+ * by identity. See docs/head-management-rfc.md.
182
+ */
183
+ export function useHead(tag: HeadTag | HeadTag[] | (() => HeadTag | HeadTag[])): void;
184
+ export function getHydrationKey(): string | undefined;
185
+ export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void): void;
61
186
  export function memo<T>(fn: () => T, equal: boolean): () => T;
62
187
  export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
63
188
  export function mergeProps(...sources: unknown[]): unknown;
64
189
  export function getOwner(): unknown;
65
- export function generateHydrationScript(options: { nonce?: string; eventNames?: string[] }): string;
190
+ export function generateHydrationScript(options?: {
191
+ nonce?: string;
192
+ eventNames?: string[];
193
+ }): string;
194
+ /**
195
+ * Registered symbol (`Symbol.for("solid.RequestContext")`) naming the
196
+ * global slot where `provideRequestEvent` parks the AsyncLocalStorage that
197
+ * scopes request events. Integration plumbing — application code reads the
198
+ * event through `getRequestEvent()` instead.
199
+ * @internal
200
+ */
66
201
  export declare const RequestContext: unique symbol;
202
+ /**
203
+ * The mutable response head an integration's handler exposes on the request
204
+ * event as `event.response`: status/statusText/headers it will apply when
205
+ * sending the response. A scaffold, not a `Response` — application code
206
+ * (e.g. JSX response components) writes to it during render, and the
207
+ * handler reads it when the head goes out. Core does not declare the
208
+ * `response` property on `RequestEvent` itself: integrations that provide
209
+ * one declare it through module augmentation (as `@solidjs/router` does),
210
+ * and this type names the shape they agree on. Core's server-function
211
+ * handler folds it onto the outgoing response when present — its
212
+ * `Set-Cookie` values (cookies appended during the call via
213
+ * `serializeCookie`) append cookie-by-cookie, other headers fill gaps —
214
+ * and reads it when folding single-flight cookies, but never requires it.
215
+ */
216
+ export interface ResponseStub {
217
+ status?: number;
218
+ statusText?: string;
219
+ headers: Headers;
220
+ /**
221
+ * Set once the response head has been derived/sent from this stub —
222
+ * status and headers can no longer change. Flip it through
223
+ * `commitResponseStub`, which also instruments the stub's `headers` so
224
+ * a post-commit write fails loudly (dev build throws, production
225
+ * reports + no-ops) instead of silently missing the wire. `status`/
226
+ * `statusText` stay plain fields: consumers that write response
227
+ * metadata during render (e.g. JSX response components) must still
228
+ * treat later status writes and cleanup-time retractions as no-ops.
229
+ */
230
+ committed?: boolean;
231
+ }
232
+
233
+ /**
234
+ * The type of `RequestEvent.locals` — a module-augmentable interface so
235
+ * applications can type the state their middleware hangs on the event.
236
+ * Augment it through the package that re-exports the event (interface
237
+ * identity flows through the re-export chain):
238
+ *
239
+ * ```ts
240
+ * declare module "@solidjs/web" {
241
+ * interface RequestEventLocals {
242
+ * user: User;
243
+ * }
244
+ * }
245
+ * ```
246
+ *
247
+ * The index signature keeps un-augmented usage permissive — `locals` is a
248
+ * free-form bag by default — so augmentation adds precision for the keys
249
+ * it names without gating existing code. The flip side: unaugmented keys
250
+ * read as `any` rather than erroring, a deliberate trade (a strict-only
251
+ * `locals` would break every untyped write that works today).
252
+ */
253
+ export interface RequestEventLocals {
254
+ [key: string | number | symbol]: any;
255
+ }
256
+
257
+ /**
258
+ * The per-request context available on the server: the incoming `Request`
259
+ * and a `locals` bag integrations and middleware can hang state on (typed
260
+ * through the augmentable `RequestEventLocals`). Frameworks typically
261
+ * extend this shape with richer fields (e.g. a `response` head — see
262
+ * `ResponseStub`).
263
+ */
67
264
  export interface RequestEvent {
68
265
  request: Request;
69
- locals: Record<string | number | symbol, any>;
266
+ locals: RequestEventLocals;
70
267
  }
268
+ /**
269
+ * The current request event, when called on the server inside a request
270
+ * scope (established by `provideRequestEvent` from `@solidjs/web/storage`
271
+ * or by the framework). Undefined on the client and outside a request.
272
+ * Read it above `await` boundaries in partially-polyfilled environments.
273
+ */
71
274
  export function getRequestEvent(): RequestEvent | undefined;
72
275
 
73
- export function Hydration(props: { children?: JSX.Element }): JSX.Element;
74
- export function NoHydration(props: { children?: JSX.Element }): JSX.Element;
75
- export function Assets(props: { children?: JSX.Element }): JSX.Element;
276
+ /** A fresh, uncommitted response head. */
277
+ export function createResponseStub(): ResponseStub;
278
+
279
+ /**
280
+ * The canonical request event for HTTP handlers: the incoming `Request`, a
281
+ * `locals` bag, and a `response` head stub the render writes to. `init`
282
+ * spreads over the defaults so frameworks can extend the shape.
283
+ */
284
+ export function createRequestEvent<T extends object = {}>(
285
+ request: Request,
286
+ init?: T
287
+ ): RequestEvent & { response: ResponseStub } & T;
288
+
289
+ /**
290
+ * The status an outgoing redirect should use for a response head carrying
291
+ * a `Location`: the stub's own status when it is a redirect status, 302
292
+ * otherwise.
293
+ */
294
+ export function getExpectedRedirectStatus(response: ResponseStub): number;
295
+
296
+ /**
297
+ * Flips a response stub to `committed` — the moment its head freezes on
298
+ * the wire — and instruments the stub's `headers` mutating methods
299
+ * (`set`/`append`/`delete`, patched in place; the `Headers` identity and
300
+ * reads are untouched) so a post-commit write fails loudly instead of
301
+ * silently missing the wire: it throws in the dev build and reports +
302
+ * no-ops otherwise. Every head materialization path commits through here
303
+ * (`createSSRResponse`, the server-function handler's commit seam);
304
+ * integrations deriving their own heads should too.
305
+ *
306
+ * `allowLateLocation` is the stream path's documented exception: a
307
+ * `Location` set after the shell flushed is still honored client-side
308
+ * (stream completion appends a `window.location` script), so that one
309
+ * write stays permitted there.
310
+ */
311
+ export function commitResponseStub(
312
+ stub: ResponseStub,
313
+ options?: { allowLateLocation?: boolean }
314
+ ): ResponseStub;
315
+
316
+ /**
317
+ * Handler-lifecycle plumbing — a response's exit through the request
318
+ * event's response-stub lifecycle: page results leave through
319
+ * `createSSRResponse`, any other `Response` (a middleware early return, an
320
+ * API result) leaves through `commitEventResponse`; application middleware
321
+ * never calls this. Folds the event's stub onto the outgoing response —
322
+ * `Set-Cookie` appends entry-by-entry alongside the response's own, other
323
+ * stub headers fill gaps only (never the wire-protocol family the handlers
324
+ * own, never `Content-Type`/`Content-Length` on a bodiless response), the
325
+ * status is never taken from the stub — then commits the stub
326
+ * (`commitResponseStub`: post-commit writes fail loudly). Responses with
327
+ * immutable headers are rebuilt around merged copies.
328
+ *
329
+ * Idempotent at handler edges: an already-committed stub passes the
330
+ * response through untouched, so a handler may apply this unconditionally
331
+ * after its middleware chain unwinds — page responses from
332
+ * `createSSRResponse` come back committed and do not double-fold.
333
+ *
334
+ * `event` defaults to the ambient `getRequestEvent()`.
335
+ */
336
+ export function commitEventResponse(response: Response, event?: RequestEvent): Response;
337
+
338
+ /**
339
+ * The cookie codec (the platform-gap primitives — see cookies.d.ts): ALL
340
+ * of core's cookie surface. The blessed patterns are
341
+ * `parseCookieHeader(event.request.headers.get("cookie"))` for reads and
342
+ * `event.response.headers.append("set-cookie", serializeCookie(name,
343
+ * value, options))` for writes.
344
+ */
345
+ export { parseCookieHeader, serializeCookie } from "./cookies.js";
346
+ export type { CookieOptions } from "./cookies.js";
347
+
348
+ /**
349
+ * The flash cookie's isomorphic half and the codec-free server-function
350
+ * layer (reference detection + the late-bound RPC seam) — mirrors of the
351
+ * client entry's exports, so integration code reading them stays
352
+ * universal. Declared through server-functions/shared.d.ts, the
353
+ * declaration home published-types layouts ship.
354
+ */
355
+ export {
356
+ clearFlashCookie,
357
+ getServerFunctionMetadata,
358
+ getServerFunctionRPC,
359
+ hasFlashCookie,
360
+ isServerFunction
361
+ } from "./server-functions/shared.js";
362
+ export type {
363
+ ServerFunction,
364
+ ServerFunctionMetadata,
365
+ ServerFunctionRPC
366
+ } from "./server-functions/shared.js";
367
+
368
+ export interface SSRResponseOptions {
369
+ /** Base head; the stub's status/headers win over it. */
370
+ responseInit?: ResponseInit;
371
+ /** Nonce carried by the post-flush `<script>` redirect fallback. */
372
+ nonce?: string;
373
+ /** Rewrites each outgoing HTML chunk (entry script injection, ...). */
374
+ transformChunk?: (chunk: string) => string;
375
+ }
376
+
377
+ /**
378
+ * Derives the outgoing `Response` for an SSR render result, running the
379
+ * response-head lifecycle against `event.response`: commit at shell flush,
380
+ * pre-flush `Location` becomes a real redirect, post-flush `Location`
381
+ * appends a client-side script redirect before the stream closes.
382
+ * Synchronous for string results; resolves at shell flush for stream
383
+ * results.
384
+ */
385
+ export function createSSRResponse(
386
+ result: string,
387
+ event: RequestEvent | undefined,
388
+ options?: SSRResponseOptions
389
+ ): Response;
390
+ export function createSSRResponse(
391
+ result: { pipe(writable: { write: (v: string) => void; end: () => void }): void },
392
+ event: RequestEvent | undefined,
393
+ options?: SSRResponseOptions
394
+ ): Promise<Response>;
395
+
396
+ /**
397
+ * Fetch-style middleware: return a `Response` to answer the request, or
398
+ * call `next()` (optionally with a substitute `Request`) to advance the
399
+ * chain and observe/replace the eventual response.
400
+ */
401
+ export type FetchMiddleware = (
402
+ request: Request,
403
+ next: (request?: Request) => Promise<Response>
404
+ ) => Response | Promise<Response>;
405
+
406
+ /**
407
+ * Composes fetch-style middleware into one function of the same shape;
408
+ * the terminal `next` dispatches to the actual handler. Runs in whatever
409
+ * scope the caller established (`provideRequestEvent`), so
410
+ * `getRequestEvent()` works exactly as in application code.
411
+ */
412
+ export function composeMiddleware(
413
+ middlewares: FetchMiddleware[]
414
+ ): (
415
+ request: Request,
416
+ next: (request?: Request) => Response | Promise<Response>
417
+ ) => Promise<Response>;
418
+
76
419
  export function untrack<T>(fn: () => T): T;
77
420
 
78
421
  // client-only APIs
79
422
 
80
- /** @deprecated not supported on the server side */
81
- export function classList(
82
- node: Element,
83
- value: { [k: string]: boolean },
84
- prev?: { [k: string]: boolean }
85
- ): { [k: string]: boolean };
86
-
87
423
  /** @deprecated not supported on the server side */
88
424
  export function style(
89
425
  node: Element,
@@ -100,15 +436,26 @@ export function insert<T>(
100
436
  ): JSX.Element;
101
437
 
102
438
  /** @deprecated not supported on the server side */
103
- export function spread<T>(
104
- node: Element,
105
- accessor: T,
106
- isSVG?: Boolean,
107
- skipChildren?: Boolean
108
- ): void;
439
+ export function spread<T>(node: Element, accessor: T, skipChildren?: Boolean): void;
109
440
 
110
441
  /** @deprecated not supported on the server side */
111
- export function delegateEvents(eventNames: string[], d?: Document): void;
442
+ export function delegateEvents(eventNames: string[]): void;
443
+ /** @deprecated not supported on the server side */
444
+ export function registerDelegatedRoot(root: MountableElement): void;
445
+ /** @deprecated not supported on the server side */
446
+ export function unregisterDelegatedRoot(root: MountableElement): void;
447
+ /** @deprecated not supported on the server side */
448
+ export function registerDelegatedContainer(
449
+ container: MountableElement,
450
+ owner?: MountableElement
451
+ ): void;
452
+ /** @deprecated not supported on the server side */
453
+ export function unregisterDelegatedContainer(
454
+ container: MountableElement,
455
+ owner?: MountableElement
456
+ ): void;
457
+ /** @deprecated not supported on the server side */
458
+ export function getDelegatedRoot(node: MountableElement): MountableElement | undefined;
112
459
  /** @deprecated not supported on the server side */
113
460
  export function dynamicProperty(props: unknown, key: string): unknown;
114
461
  /** @deprecated not supported on the server side */
@@ -116,24 +463,35 @@ export function setAttribute(node: Element, name: string, value: string): void;
116
463
  /** @deprecated not supported on the server side */
117
464
  export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
118
465
 
466
+ /**
467
+ * Server no-op: element claims are a client-only concern, but consumers may
468
+ * register isomorphically. Returns a no-op unregister function.
469
+ */
470
+ export function registerElementClaim(handler: (element: Element) => void): () => void;
471
+ /** Server no-op: returns `node` unchanged. Claims never fire during SSR. */
472
+ export function claimElement<T extends Element>(node: T): T;
473
+ /** Server no-op: returns `root` unchanged. Claims never fire during SSR. */
474
+ export function claimElementTree<T extends Node>(root: T): T;
475
+
119
476
  /** @deprecated not supported on the server side */
120
- export function addEventListener(
121
- node: Element,
122
- name: string,
123
- handler: () => void,
124
- delegate: boolean
125
- ): void;
477
+ export function addEvent(node: Element, name: string, handler: () => void, delegate: boolean): void;
126
478
 
127
479
  /** @deprecated not supported on the server side */
128
480
  export function render(code: () => JSX.Element, element: MountableElement): () => void;
129
- /** @deprecated not supported on the server side */
130
- export function template(html: string, isCE?: boolean, isSVG?: boolean): () => Element;
481
+ /**
482
+ * @deprecated not supported on the server side
483
+ * @param flag
484
+ * - `undefined` — clone the template as-is (uses `cloneNode`).
485
+ * - `1` — use `document.importNode` instead of `cloneNode`.
486
+ * - `2` — the template html is wrapped; the outer tag is stripped at clone time.
487
+ */
488
+ export function template(html: string, flag?: 1 | 2): () => Element;
131
489
  /** @deprecated not supported on the server side */
132
490
  export function setProperty(node: Element, name: string, value: any): void;
133
491
  /** @deprecated not supported on the server side */
134
492
  export function className(node: Element, value: string): void;
135
493
  /** @deprecated not supported on the server side */
136
- export function assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
494
+ export function assign(node: Element, props: any, skipChildren?: Boolean): void;
137
495
 
138
496
  /** @deprecated not supported on the server side */
139
497
  export function hydrate(
@@ -143,8 +501,23 @@ export function hydrate(
143
501
  ): () => void;
144
502
 
145
503
  /** @deprecated not supported on the server side */
146
- export function getNextElement(template?: HTMLTemplateElement): Element;
504
+ export function getNextElement(template?: () => Element): Element;
147
505
  /** @deprecated not supported on the server side */
148
506
  export function getNextMatch(start: Node, elementName: string): Element;
149
507
  /** @deprecated not supported on the server side */
150
508
  export function getNextMarker(start: Node): [Node, Array<Node>];
509
+ /** @deprecated not supported on the server side */
510
+ export function runHydrationEvents(): void;
511
+ /** @deprecated not supported on the server side */
512
+ export function ref(
513
+ fn: () => ((element: Element) => void) | ((element: Element) => void)[],
514
+ element: Element
515
+ ): void;
516
+ /** @deprecated not supported on the server side */
517
+ export function setStyleProperty(node: Element, name: string, value: any): void;
518
+ /**
519
+ * @internal See client.d.ts — head-management RFC policy: ambient CSS is
520
+ * unmanaged; the head registry owns directly-mounted stylesheet lifecycle.
521
+ * @deprecated not supported on the server side — register assets through the render context instead
522
+ */
523
+ export function acquireAsset(descriptor: unknown): () => void;