@solidjs/web 2.0.0-beta.29 → 2.0.0-beta.30

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.
package/types/index.d.ts CHANGED
@@ -138,27 +138,6 @@ export declare function Portal(props: {
138
138
  mount?: Element;
139
139
  children: JSX.Element;
140
140
  }): JSX.Element;
141
- /**
142
- * Returns a stable `Component` whose identity is driven by a reactive (and
143
- * optionally async) `source`. The returned component can be used anywhere a
144
- * normal component is used; children and props flow through JSX as usual.
145
- *
146
- * `source` may return a component, a native tag name (`'input'`, `'textarea'`,
147
- * etc.), `undefined`, or a `Promise` of any of the above. A pending promise
148
- * propagates as `NotReadyError` through the surrounding reactive scope, so
149
- * async swaps compose with `<Loading>` boundaries the same way as `lazy`.
150
- *
151
- * @example
152
- * ```tsx
153
- * // `source` can return either a custom Component or a native tag
154
- * // name — they're interchangeable, and the returned reference is a
155
- * // stable Component you can use anywhere a normal one would go.
156
- * const Field = dynamic(() => multiline() ? RichTextEditor : "input");
157
- * return <Field value={value()} onInput={onInput} />;
158
- * ```
159
- *
160
- * @description https://docs.solidjs.com/reference/components/dynamic
161
- */
162
141
  export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false): Component<ComponentProps<T>>;
163
142
  /**
164
143
  * Renders an arbitrary custom or native component and forwards the other
@@ -204,7 +183,7 @@ export declare function clientOnly<T extends Component<any>>(fn: () => Promise<{
204
183
  default: T;
205
184
  }>, options?: {
206
185
  lazy?: boolean;
207
- }): Component<ComponentProps<T> & {
186
+ }, _moduleUrl?: string): Component<ComponentProps<T> & {
208
187
  fallback?: JSX.Element;
209
188
  }>;
210
189
  /**
package/types/server.d.ts CHANGED
@@ -66,6 +66,17 @@ export function renderToString<T>(
66
66
  plugins?: SerializerPlugin[];
67
67
  manifest?: AssetManifest | AssetResolver | AssetResolverFn;
68
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;
69
80
  }
70
81
  ): string;
71
82
  /** @deprecated use renderToStream which also returns a promise */
@@ -92,6 +103,17 @@ export function renderToStream<T>(
92
103
  onCompleteShell?: (info: { write: (v: string) => void }) => void;
93
104
  onCompleteAll?: (info: { write: (v: string) => void }) => void;
94
105
  onError?: (err: any) => void;
106
+ /**
107
+ * Embedded-render contract for hosts that own the document. When the
108
+ * shell contains no `</head>`, everything head-bound at first flush
109
+ * (resolved `useHead` winners, eager resources, tracked asset links,
110
+ * inline styles) is delivered here as one HTML string — prelude first —
111
+ * before the shell chunk is emitted, so the host can write its own
112
+ * `<head>` ahead of piping the stream. Post-shell head updates flow
113
+ * through the stream itself and apply in the browser. Not called when
114
+ * the shell has a `</head>` (splicing is automatic then).
115
+ */
116
+ onHead?: (head: string) => void;
95
117
  }
96
118
  ): {
97
119
  then: (fn: (html: string) => void) => void;
@@ -131,8 +153,36 @@ export function applyRef(
131
153
  r: ((element: any) => void) | ((element: any) => void)[],
132
154
  element: any
133
155
  ): void;
156
+ /** @deprecated Use `useHead` — removed before `0.50.0` stable. */
134
157
  export function useAssets(fn: () => JSX.Element): void;
158
+ /**
159
+ * @deprecated Use the `onHead` render option — removed before `0.50.0`
160
+ * stable. Reads ambient render state, so it is unsafe across concurrent
161
+ * renders; `onHead` is closure-bound to its render and also carries
162
+ * `useHead` output, which this does not.
163
+ */
135
164
  export function getAssets(): string;
165
+ /**
166
+ * A head tag descriptor. Props values may be getters (evaluated lazily on
167
+ * the server — at the owning flush boundary — and reactively on the client);
168
+ * `children` is the text body (title text, inline style/script content).
169
+ * `key` overrides the built-in dedupe identity (`title` is a hard singleton
170
+ * that `key` cannot fork).
171
+ */
172
+ export type HeadTag = {
173
+ tag: "title" | "meta" | "link" | "style" | "script" | "base";
174
+ props: Record<string, any>;
175
+ key?: string | (() => string);
176
+ };
177
+ /**
178
+ * Registers head tags with the render's head registry. An array is a group —
179
+ * one replacement set; a single tag is a group of one. Replaceable tags
180
+ * (title/meta/canonical/…) resolve by last-committed group and stream as
181
+ * patches with their suspense boundary's reveal; resource tags (preload and
182
+ * friends, stylesheets, `script[src]`) emit eagerly and dedupe by identity.
183
+ * See docs/head-management-rfc.md.
184
+ */
185
+ export function useHead(tag: HeadTag | HeadTag[]): void;
136
186
  export function getHydrationKey(): string | undefined;
137
187
  export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void): void;
138
188
  export function memo<T>(fn: () => T, equal: boolean): () => T;
@@ -127,8 +127,28 @@ export function getHydrationKey(): string | undefined;
127
127
  export function getNextElement(template?: () => Element): Element;
128
128
  export function getNextMatch(start: Node, elementName: string): Element;
129
129
  export function getNextMarker(start: Node): [Node, Array<Node>];
130
+ /** @deprecated Use `useHead` — removed before `0.50.0` stable. */
130
131
  export function useAssets(fn: () => JSX.Element): void;
132
+ /** @deprecated Use `useHead` — removed before `0.50.0` stable. */
131
133
  export function getAssets(): string;
134
+ /**
135
+ * A head tag descriptor. Props values may be getters (reactive on the
136
+ * client); `children` is the text body. `key` overrides the built-in dedupe
137
+ * identity (`title` is a hard singleton that `key` cannot fork).
138
+ */
139
+ export type HeadTag = {
140
+ tag: "title" | "meta" | "link" | "style" | "script" | "base";
141
+ props: Record<string, any>;
142
+ key?: string | (() => string);
143
+ };
144
+ /**
145
+ * Registers head tags with the ambient head registry under the current
146
+ * owner. An array is a group — one replacement set. Resolution is
147
+ * last-committed group per identity; disposal restores the previous winner.
148
+ * During hydration the server-flushed head state stays authoritative until
149
+ * hydration completes. See docs/head-management-rfc.md.
150
+ */
151
+ export function useHead(tag: HeadTag | HeadTag[]): void;
132
152
  export type AssetDescriptor =
133
153
  | { type: "style"; href: string; attrs?: Record<string, string> }
134
154
  | { type: "inline-style"; id: string; content?: string; attrs?: Record<string, string> }
@@ -84,6 +84,15 @@ export interface SlotContext {
84
84
  * server content, or the owning frame is disposed.
85
85
  */
86
86
  onCleanup(fn: () => void): void;
87
+ /**
88
+ * Live-props opt-in: a binding that registers here receives the
89
+ * re-resolved props when a re-sent record's args CHANGE in value, instead
90
+ * of the occurrence being re-called — the invocation's instance (and its
91
+ * client state) survives the change. Register synchronously during the
92
+ * invocation; one updater per occurrence (last registration wins). A
93
+ * genuine re-call or unmount clears it before/with the binding it served.
94
+ */
95
+ onUpdate(fn: (props: Record<string, unknown>) => void): void;
87
96
  /**
88
97
  * The range's current interior — server-rendered client content on an
89
98
  * adopted document-SSR boot, or the previous output on a re-call. A
@@ -122,6 +131,22 @@ export interface Frame {
122
131
  readonly error: unknown;
123
132
  /** Whether the named fragment has been revealed into the boundary. */
124
133
  isRevealed(segment: string): boolean;
134
+ /**
135
+ * Re-key this live frame to a different boundary id (the mount-preserving
136
+ * half of a call-site handoff): nothing tears down — the element, store,
137
+ * and slot state stay — while leaving the old id stashes a retention
138
+ * snapshot under it and joining the new id seeds/drains its retained
139
+ * store and buffered chunks. Version affinity resets: histories are per
140
+ * boundary id.
141
+ */
142
+ rebind(id: string): void;
143
+ /**
144
+ * Forget the version baseline without touching content — the next write
145
+ * is accepted whatever its number. Called by the host after seeding a
146
+ * registration from a retained snapshot, whose numbering belongs to a
147
+ * different stream space.
148
+ */
149
+ rebase(): void;
125
150
  /** Tear down: slot cleanups cascade, later chunks are ignored. Idempotent. */
126
151
  dispose(): void;
127
152
  }
@@ -79,6 +79,32 @@ export const SERVER_COMPONENT_SOURCE: unique symbol;
79
79
  /** The call's wire address (`frameAddress`), for regions to be emitted under. */
80
80
  export const SERVER_COMPONENT_ADDRESS: unique symbol;
81
81
 
82
+ /**
83
+ * The handoff contract on components the transport resolves: `{ fnId,
84
+ * frameId, take(prev) }`. A reader whose source resolved a NEW component
85
+ * while a previous one is mounted offers the old one — `take` rebinds the
86
+ * live mount when both are boundaries of the same function (the element and
87
+ * its slot state stay; the incoming stream morphs it), and the reader keeps
88
+ * its previous value instead of remounting. `Symbol.for`, so frameworks can
89
+ * honor it without importing this module.
90
+ */
91
+ export const COMPONENT_HANDOFF: unique symbol;
92
+
93
+ /** The value under `COMPONENT_HANDOFF` on a transport-resolved component. */
94
+ export interface ComponentHandoff {
95
+ /** The server function id both peers derive the boundary's calls from. */
96
+ fnId: string;
97
+ /** The frame id this component's fresh mounts register under. */
98
+ frameId: string;
99
+ /**
100
+ * Offer `prev` (the reader's current value) to this component. Returns
101
+ * true when the reader should KEEP prev — the mounted frame was rebound
102
+ * to this component's id (or already showed it); false means swap
103
+ * normally (different function, unbranded prev, or nothing mounted).
104
+ */
105
+ take(prev: unknown): boolean;
106
+ }
107
+
82
108
  /**
83
109
  * Seroval plugin for a server component crossing a serialization boundary:
84
110
  * a branded component serializes as a REFERENCE — a per-function document
@@ -138,27 +138,6 @@ export declare function Portal(props: {
138
138
  mount?: Element;
139
139
  children: JSX.Element;
140
140
  }): JSX.Element;
141
- /**
142
- * Returns a stable `Component` whose identity is driven by a reactive (and
143
- * optionally async) `source`. The returned component can be used anywhere a
144
- * normal component is used; children and props flow through JSX as usual.
145
- *
146
- * `source` may return a component, a native tag name (`'input'`, `'textarea'`,
147
- * etc.), `undefined`, or a `Promise` of any of the above. A pending promise
148
- * propagates as `NotReadyError` through the surrounding reactive scope, so
149
- * async swaps compose with `<Loading>` boundaries the same way as `lazy`.
150
- *
151
- * @example
152
- * ```tsx
153
- * // `source` can return either a custom Component or a native tag
154
- * // name — they're interchangeable, and the returned reference is a
155
- * // stable Component you can use anywhere a normal one would go.
156
- * const Field = dynamic(() => multiline() ? RichTextEditor : "input");
157
- * return <Field value={value()} onInput={onInput} />;
158
- * ```
159
- *
160
- * @description https://docs.solidjs.com/reference/components/dynamic
161
- */
162
141
  export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false): Component<ComponentProps<T>>;
163
142
  /**
164
143
  * Renders an arbitrary custom or native component and forwards the other
@@ -204,7 +183,7 @@ export declare function clientOnly<T extends Component<any>>(fn: () => Promise<{
204
183
  default: T;
205
184
  }>, options?: {
206
185
  lazy?: boolean;
207
- }): Component<ComponentProps<T> & {
186
+ }, _moduleUrl?: string): Component<ComponentProps<T> & {
208
187
  fallback?: JSX.Element;
209
188
  }>;
210
189
  /**
@@ -66,6 +66,17 @@ export function renderToString<T>(
66
66
  plugins?: SerializerPlugin[];
67
67
  manifest?: AssetManifest | AssetResolver | AssetResolverFn;
68
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;
69
80
  }
70
81
  ): string;
71
82
  /** @deprecated use renderToStream which also returns a promise */
@@ -92,6 +103,17 @@ export function renderToStream<T>(
92
103
  onCompleteShell?: (info: { write: (v: string) => void }) => void;
93
104
  onCompleteAll?: (info: { write: (v: string) => void }) => void;
94
105
  onError?: (err: any) => void;
106
+ /**
107
+ * Embedded-render contract for hosts that own the document. When the
108
+ * shell contains no `</head>`, everything head-bound at first flush
109
+ * (resolved `useHead` winners, eager resources, tracked asset links,
110
+ * inline styles) is delivered here as one HTML string — prelude first —
111
+ * before the shell chunk is emitted, so the host can write its own
112
+ * `<head>` ahead of piping the stream. Post-shell head updates flow
113
+ * through the stream itself and apply in the browser. Not called when
114
+ * the shell has a `</head>` (splicing is automatic then).
115
+ */
116
+ onHead?: (head: string) => void;
95
117
  }
96
118
  ): {
97
119
  then: (fn: (html: string) => void) => void;
@@ -131,8 +153,36 @@ export function applyRef(
131
153
  r: ((element: any) => void) | ((element: any) => void)[],
132
154
  element: any
133
155
  ): void;
156
+ /** @deprecated Use `useHead` — removed before `0.50.0` stable. */
134
157
  export function useAssets(fn: () => JSX.Element): void;
158
+ /**
159
+ * @deprecated Use the `onHead` render option — removed before `0.50.0`
160
+ * stable. Reads ambient render state, so it is unsafe across concurrent
161
+ * renders; `onHead` is closure-bound to its render and also carries
162
+ * `useHead` output, which this does not.
163
+ */
135
164
  export function getAssets(): string;
165
+ /**
166
+ * A head tag descriptor. Props values may be getters (evaluated lazily on
167
+ * the server — at the owning flush boundary — and reactively on the client);
168
+ * `children` is the text body (title text, inline style/script content).
169
+ * `key` overrides the built-in dedupe identity (`title` is a hard singleton
170
+ * that `key` cannot fork).
171
+ */
172
+ export type HeadTag = {
173
+ tag: "title" | "meta" | "link" | "style" | "script" | "base";
174
+ props: Record<string, any>;
175
+ key?: string | (() => string);
176
+ };
177
+ /**
178
+ * Registers head tags with the render's head registry. An array is a group —
179
+ * one replacement set; a single tag is a group of one. Replaceable tags
180
+ * (title/meta/canonical/…) resolve by last-committed group and stream as
181
+ * patches with their suspense boundary's reveal; resource tags (preload and
182
+ * friends, stylesheets, `script[src]`) emit eagerly and dedupe by identity.
183
+ * See docs/head-management-rfc.md.
184
+ */
185
+ export function useHead(tag: HeadTag | HeadTag[]): void;
136
186
  export function getHydrationKey(): string | undefined;
137
187
  export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void): void;
138
188
  export function memo<T>(fn: () => T, equal: boolean): () => T;